@alexkroman1/aai-cli 5.14.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{_agent-C8Jk-ZcP.mjs → _agent-vGW5SBnX.mjs} +23 -5
- package/dist/_agent.d.ts +18 -0
- package/dist/{_api-client-BX8Qv51n.mjs → _api-client-LgLksMhN.mjs} +45 -8
- package/dist/_api-client.d.ts +39 -0
- package/dist/{_bundler-BuIyDdvs.mjs → _bundler-BapCUUJN.mjs} +42 -14
- package/dist/_bundler.d.ts +43 -5
- package/dist/_cli-common.d.ts +67 -3
- package/dist/{_config-CzwAWOWr.mjs → _config-D_s09e7g.mjs} +36 -18
- package/dist/_deploy.d.ts +2 -5
- package/dist/_dev-restart.d.ts +6 -1
- package/dist/{_dev-server-Ch7K8e8i.mjs → _dev-server-DQ1t9sbw.mjs} +94 -38
- package/dist/_dev-server.d.ts +30 -2
- package/dist/_e2e-test-utils.d.ts +80 -0
- package/dist/_fault-mode.d.ts +175 -0
- package/dist/{_init-CbkrE2wq.mjs → _init-CpISqoR8.mjs} +3 -3
- package/dist/{_output-CC300DzW.mjs → _output-CKkmWs7i.mjs} +8 -1
- package/dist/_output.d.ts +9 -2
- package/dist/{_server-common-61fL__39.mjs → _server-common-6e0QI4mq.mjs} +1 -1
- package/dist/{_slug-api-D30zPmsn.mjs → _slug-api-D2heILuC.mjs} +2 -2
- package/dist/{_studio-D2ciIhbi.mjs → _studio-zAJycZ8j.mjs} +3 -3
- package/dist/{_templates-B1kt3BGt.mjs → _templates-iDGjGiPf.mjs} +4 -6
- package/dist/{_typecheck-gate-4v9UBZHh.mjs → _typecheck-gate-BXvUNnfs.mjs} +1 -1
- package/dist/{_utils-0DHbcqUb.mjs → _utils-B8QmtFhK.mjs} +21 -7
- package/dist/_utils.d.ts +18 -2
- package/dist/{_vite-env-Dg_QlVv0.mjs → _vite-env-BNveawd1.mjs} +31 -1
- package/dist/_vite-env.d.ts +30 -0
- package/dist/build-BO1Ni6oJ.mjs +62 -0
- package/dist/build.d.ts +19 -0
- package/dist/cli-workflow.d.ts +10 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.mjs +406 -224
- package/dist/{client-bundler-C9qXL8A2.mjs → client-bundler-B8Q9F8gJ.mjs} +3 -22
- package/dist/client-bundler.mjs +1 -1
- package/dist/{delete-DCRX3d96.mjs → delete-4I0uNR4a.mjs} +6 -7
- package/dist/delete.d.ts +2 -8
- package/dist/{deploy-DjsEV-40.mjs → deploy-DJ3HRcia.mjs} +13 -14
- package/dist/{dev-CvPH5dbF.mjs → dev-C6SWaAZP.mjs} +3 -3
- package/dist/{eject-LgBRfnbH.mjs → eject-Zrzk5KV3.mjs} +41 -15
- package/dist/eject.d.ts +30 -3
- package/dist/{init-BppxMR8r.mjs → init-BTRGiPQr.mjs} +61 -26
- package/dist/init.d.ts +11 -0
- package/dist/{login-BQQaxJhL.mjs → login-k0Z3VQu9.mjs} +5 -5
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/CLAUDE.md +498 -91
- package/dist/scaffold/package.json +11 -8
- package/dist/scaffold/pnpm-workspace.yaml +8 -0
- package/dist/scaffold/server.mjs +53 -57
- package/dist/{secret-Ds9dvqAj.mjs → secret-DzSQx1Ds.mjs} +6 -3
- package/dist/{storage-DbrQSHFk.mjs → storage-C-Do0mIA.mjs} +18 -6
- package/dist/{studio-GSFd4s5O.mjs → studio-BGVmCA2G.mjs} +10 -10
- package/dist/templates/code-interpreter/agent.ts +0 -2
- package/dist/templates/dispatch-center/agent.test.ts +17 -19
- package/dist/templates/dispatch-center/agent.ts +2 -29
- package/dist/templates/dispatch-center/client.tsx +33 -16
- package/dist/templates/dispatch-center/shared.ts +53 -19
- package/dist/templates/dispatch-center/tools/incident_add_note.ts +12 -14
- package/dist/templates/dispatch-center/tools/incident_create.ts +41 -44
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +59 -61
- package/dist/templates/dispatch-center/tools/incident_get.ts +3 -4
- package/dist/templates/dispatch-center/tools/incident_triage.ts +43 -45
- package/dist/templates/dispatch-center/tools/incident_update_status.ts +39 -41
- package/dist/templates/dispatch-center/tools/ops_dashboard.ts +2 -5
- package/dist/templates/dispatch-center/tools/ops_protocols.ts +1 -1
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +20 -23
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +52 -54
- package/dist/templates/dispatch-center/tools/resources_get_available.ts +2 -4
- package/dist/templates/dispatch-center/tools/resources_update_status.ts +39 -42
- package/dist/templates/embedded-assets/agent.test.ts +83 -0
- package/dist/templates/embedded-assets/agent.ts +1 -48
- package/dist/templates/embedded-assets/shared.ts +17 -0
- package/dist/templates/embedded-assets/system-prompt.md +13 -0
- package/dist/templates/embedded-assets/tools/list_topics.ts +9 -0
- package/dist/templates/embedded-assets/tools/search_knowledge.ts +26 -0
- package/dist/templates/health-assistant/agent.test.ts +169 -0
- package/dist/templates/health-assistant/agent.ts +1 -166
- package/dist/templates/health-assistant/fda.ts +100 -0
- package/dist/templates/health-assistant/tools/check_drug_interaction.ts +59 -0
- package/dist/templates/health-assistant/tools/medication_lookup.ts +31 -0
- package/dist/templates/infocom-adventure/agent.test.ts +205 -0
- package/dist/templates/infocom-adventure/agent.ts +3 -106
- package/dist/templates/infocom-adventure/client.tsx +28 -12
- package/dist/templates/infocom-adventure/shared.ts +28 -11
- package/dist/templates/infocom-adventure/tools/game_state_drop.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_flag.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_get.ts +16 -0
- package/dist/templates/infocom-adventure/tools/game_state_history.ts +14 -0
- package/dist/templates/infocom-adventure/tools/game_state_move.ts +14 -0
- package/dist/templates/infocom-adventure/tools/game_state_restart.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_score.ts +13 -0
- package/dist/templates/infocom-adventure/tools/game_state_take.ts +13 -0
- package/dist/templates/link-digest/agent.test.ts +223 -0
- package/dist/templates/link-digest/agent.ts +79 -0
- package/dist/templates/link-digest/client.tsx +146 -0
- package/dist/templates/link-digest/workflows/digest.ts +248 -0
- package/dist/templates/math-buddy/agent.ts +0 -2
- package/dist/templates/night-owl/agent.test.ts +80 -0
- package/dist/templates/night-owl/agent.ts +1 -68
- package/dist/templates/night-owl/system-prompt.md +10 -0
- package/dist/templates/night-owl/tools/recommend.ts +64 -0
- package/dist/templates/personal-finance/agent.ts +0 -2
- package/dist/templates/pizza-ordering/agent.test.ts +52 -47
- package/dist/templates/pizza-ordering/agent.ts +9 -158
- package/dist/templates/pizza-ordering/shared.ts +35 -12
- package/dist/templates/pizza-ordering/tools/add_pizza.ts +31 -0
- package/dist/templates/pizza-ordering/tools/place_order.ts +22 -0
- package/dist/templates/pizza-ordering/tools/remove_pizza.ts +22 -0
- package/dist/templates/pizza-ordering/tools/set_customer_name.ts +13 -0
- package/dist/templates/pizza-ordering/tools/update_pizza.ts +28 -0
- package/dist/templates/pizza-ordering/tools/view_order.ts +21 -0
- package/dist/templates/plan-and-execute/agent.test.ts +411 -0
- package/dist/templates/plan-and-execute/agent.ts +23 -0
- package/dist/templates/plan-and-execute/client.tsx +115 -0
- package/dist/templates/plan-and-execute/graph.ts +178 -0
- package/dist/templates/plan-and-execute/prompts.ts +110 -0
- package/dist/templates/plan-and-execute/shared.ts +161 -0
- package/dist/templates/plan-and-execute/system-prompt.md +18 -0
- package/dist/templates/plan-and-execute/tools/plan_status.ts +20 -0
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +63 -0
- package/dist/templates/plan-and-execute/tools/start_plan.ts +51 -0
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +101 -0
- package/dist/templates/recap-workflow/agent.test.ts +762 -0
- package/dist/templates/recap-workflow/agent.ts +95 -0
- package/dist/templates/recap-workflow/shared.ts +43 -0
- package/dist/templates/recap-workflow/tools/cancel_recap.ts +23 -0
- package/dist/templates/recap-workflow/tools/keep_transcript.ts +31 -0
- package/dist/templates/recap-workflow/tools/recap_progress.ts +27 -0
- package/dist/templates/recap-workflow/tools/recap_status.ts +46 -0
- package/dist/templates/recap-workflow/tools/request_recap.ts +43 -0
- package/dist/templates/recap-workflow/workflows/recap.ts +544 -0
- package/dist/templates/recap-workflow/workflows/tokens.ts +26 -0
- package/dist/templates/redline/agent.test.ts +222 -0
- package/dist/templates/redline/agent.ts +89 -0
- package/dist/templates/redline/client.tsx +184 -0
- package/dist/templates/redline/workflows/prompts.ts +68 -0
- package/dist/templates/redline/workflows/redline.ts +258 -0
- package/dist/templates/research-workflow/agent.test.ts +525 -0
- package/dist/templates/research-workflow/agent.ts +94 -0
- package/dist/templates/research-workflow/shared.ts +35 -0
- package/dist/templates/research-workflow/tools/file_it_now.ts +22 -0
- package/dist/templates/research-workflow/tools/request_research.ts +33 -0
- package/dist/templates/research-workflow/tools/research_progress.ts +26 -0
- package/dist/templates/research-workflow/tools/research_status.ts +40 -0
- package/dist/templates/research-workflow/workflows/prompts.ts +143 -0
- package/dist/templates/research-workflow/workflows/research.ts +558 -0
- package/dist/templates/retail/agent.test.ts +236 -172
- package/dist/templates/retail/agent.ts +5 -42
- package/dist/templates/retail/client.tsx +33 -11
- package/dist/templates/retail/registry.test.ts +31 -16
- package/dist/templates/retail/resolve.ts +28 -64
- package/dist/templates/retail/shared.test.ts +4 -3
- package/dist/templates/retail/shared.ts +24 -7
- package/dist/templates/retail/store.test.ts +12 -10
- package/dist/templates/retail/store.ts +69 -30
- package/dist/templates/retail/tools/cancel_pending_order.ts +4 -9
- package/dist/templates/retail/tools/exchange_delivered_order_items.ts +22 -11
- package/dist/templates/retail/tools/find_user_id_by_email.ts +5 -9
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +5 -7
- package/dist/templates/retail/tools/get_item_details.ts +5 -7
- package/dist/templates/retail/tools/get_order_details.ts +5 -7
- package/dist/templates/retail/tools/get_product_details.ts +4 -7
- package/dist/templates/retail/tools/get_user_details.ts +4 -7
- package/dist/templates/retail/tools/list_all_product_types.ts +5 -7
- package/dist/templates/retail/tools/modify_pending_order_address.ts +4 -9
- package/dist/templates/retail/tools/modify_pending_order_items.ts +4 -16
- package/dist/templates/retail/tools/modify_pending_order_payment.ts +3 -9
- package/dist/templates/retail/tools/modify_user_address.ts +4 -9
- package/dist/templates/retail/tools/return_delivered_order_items.ts +3 -9
- package/dist/templates/retail/tools/transfer_to_human_agents.ts +1 -1
- package/dist/templates/solo-rpg/agent.test.ts +152 -29
- package/dist/templates/solo-rpg/agent.ts +3 -21
- package/dist/templates/solo-rpg/client.tsx +19 -6
- package/dist/templates/solo-rpg/shared.ts +19 -11
- package/dist/templates/solo-rpg/tools/action_roll.ts +2 -4
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +2 -4
- package/dist/templates/solo-rpg/tools/check_state.ts +6 -6
- package/dist/templates/solo-rpg/tools/load_game.ts +1 -1
- package/dist/templates/solo-rpg/tools/oracle.ts +18 -11
- package/dist/templates/solo-rpg/tools/save_game.ts +10 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +1 -1
- package/dist/templates/solo-rpg/tools/update_state.ts +3 -4
- package/dist/templates/support-line/agent.test.ts +343 -0
- package/dist/templates/support-line/agent.ts +27 -0
- package/dist/templates/support-line/client.tsx +122 -0
- package/dist/templates/support-line/graph.ts +224 -0
- package/dist/templates/support-line/knowledge.json +65 -0
- package/dist/templates/support-line/prompts.ts +95 -0
- package/dist/templates/support-line/shared.ts +240 -0
- package/dist/templates/support-line/system-prompt.md +17 -0
- package/dist/templates/support-line/tools/answer_question.ts +72 -0
- package/dist/templates/support-line/tools/list_topics.ts +22 -0
- package/dist/templates/support-line/tools/log_ticket.ts +30 -0
- package/dist/templates/transcription-workflow/agent.test.ts +563 -0
- package/dist/templates/transcription-workflow/agent.ts +92 -0
- package/dist/templates/transcription-workflow/client.tsx +234 -0
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +416 -0
- package/dist/templates/transcription-workflow/workflows/wav.ts +314 -0
- package/dist/templates/travel-concierge/agent.test.ts +338 -0
- package/dist/templates/travel-concierge/agent.ts +29 -0
- package/dist/templates/travel-concierge/client.tsx +161 -0
- package/dist/templates/travel-concierge/routing.ts +138 -0
- package/dist/templates/travel-concierge/shared.ts +547 -0
- package/dist/templates/travel-concierge/system-prompt.md +24 -0
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +20 -0
- package/dist/templates/travel-concierge/tools/book_excursion.ts +18 -0
- package/dist/templates/travel-concierge/tools/book_hotel.ts +20 -0
- package/dist/templates/travel-concierge/tools/cancel_action.ts +7 -0
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +16 -0
- package/dist/templates/travel-concierge/tools/complete_or_escalate.ts +7 -0
- package/dist/templates/travel-concierge/tools/confirm_action.ts +7 -0
- package/dist/templates/travel-concierge/tools/lookup_booking.ts +35 -0
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +33 -0
- package/dist/templates/travel-concierge/tools/search_excursions.ts +37 -0
- package/dist/templates/travel-concierge/tools/search_flights.ts +43 -0
- package/dist/templates/travel-concierge/tools/search_hotels.ts +36 -0
- package/dist/templates/travel-concierge/tools/to_car_rental_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/to_excursion_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/to_flight_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/to_hotel_assistant.ts +11 -0
- package/dist/templates/travel-concierge/tools/update_ticket.ts +22 -0
- package/dist/templates/web-researcher/agent.ts +0 -2
- package/dist/templates/web-researcher/system-prompt.md +10 -0
- package/dist/{test-2LWBcXvY.mjs → test-B6ZBxSpk.mjs} +2 -2
- package/dist/typecheck.mjs +17 -15
- package/dist/worker-bundler-CIdDhZ0c.mjs +398 -0
- package/dist/worker-bundler.d.ts +14 -0
- package/dist/worker-bundler.mjs +1 -108
- package/dist/workflow-B-O97AqI.mjs +125 -0
- package/dist/workflow-bundler.d.ts +133 -0
- package/dist/workflow.d.ts +67 -0
- package/package.json +13 -9
- package/dist/build-DQJ1ZSm9.mjs +0 -39
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow bundling — turning a project's `workflows/` directory into the two
|
|
3
|
+
* small artifacts a guest needs to run durable workflows.
|
|
4
|
+
*
|
|
5
|
+
* Public (no `_` prefix) for the same reason as `worker-bundler.ts`: the studio
|
|
6
|
+
* builds its workspaces through this too, so a workflow published from the
|
|
7
|
+
* browser comes out of the same pass as one from `aai build`.
|
|
8
|
+
*
|
|
9
|
+
* @internal — build hook for aai-server/the studio; not a supported public API
|
|
10
|
+
* and not covered by semver.
|
|
11
|
+
*
|
|
12
|
+
* ## Why this exists at all
|
|
13
|
+
*
|
|
14
|
+
* The Workflow Development Kit's own integrations (Next, Nitro, SvelteKit) build
|
|
15
|
+
* workflow routes while building the SERVER, by scanning `workflows/` and
|
|
16
|
+
* emitting handler files. That model does not fit this platform: the guest image
|
|
17
|
+
* is baked once and then serves MANY tenants' agents, each arriving over
|
|
18
|
+
* `bundle/load` at runtime. There is no `workflows/` directory in existence when
|
|
19
|
+
* the harness is built. So the transform has to happen per tenant at deploy
|
|
20
|
+
* time — here — and the guest receives the result as data.
|
|
21
|
+
*
|
|
22
|
+
* ## The two artifacts, and why they are small
|
|
23
|
+
*
|
|
24
|
+
* A default `workflow build` emits a 3.7 MB flow bundle and a 12 MB step bundle,
|
|
25
|
+
* because each one inlines the whole WDK runtime. Neither could ride the guest's
|
|
26
|
+
* single-ESM-string delivery. Two settings fix that, and both are load-bearing:
|
|
27
|
+
*
|
|
28
|
+
* - **`externalPackages: ["workflow", …]`** — the WDK is resolved from the
|
|
29
|
+
* guest's BAKED image instead of being inlined. Step bundle: 12 MB → ~7 KB.
|
|
30
|
+
* - **`bundleFinalOutput: false`** — skips wrapping the workflow-mode code in a
|
|
31
|
+
* runtime host, which is exactly what `workflowEntrypoint(code)` supplies
|
|
32
|
+
* itself at the other end. Flow bundle: 3.7 MB → ~69 KB.
|
|
33
|
+
*
|
|
34
|
+
* So `workflowCode` is passed to `workflowEntrypoint()` in the guest and
|
|
35
|
+
* `stepCode` is evaluated there to register its step functions.
|
|
36
|
+
*
|
|
37
|
+
* ## The THIRD transform, which is the agent bundle's
|
|
38
|
+
*
|
|
39
|
+
* Those two are what the queue runs. The agent bundle needs a third —
|
|
40
|
+
* `applySwcTransform(…, "client")`, wired in as {@link workflowClientPlugin} —
|
|
41
|
+
* and without it the whole mechanism is inert: `ctx.workflows.start` reads the
|
|
42
|
+
* `workflowId` the compiler attaches to a directive body, and Vite bundling
|
|
43
|
+
* `workflows/research.ts` the ordinary way attaches nothing. The symptom is
|
|
44
|
+
* `MISSING_WORKFLOW_ID_MESSAGE` at the first `start()` — an agent that builds,
|
|
45
|
+
* deploys, boots and answers the phone, and cannot start a run.
|
|
46
|
+
*
|
|
47
|
+
* The plugin transforms EXACTLY the files the builder scanned (`inputFiles`),
|
|
48
|
+
* not "every file with a directive". Same list, same `moduleSpecifierRoot`,
|
|
49
|
+
* therefore the same ids by construction — a body outside `workflows/` cannot
|
|
50
|
+
* acquire an id that no flow bundle registered, which would trade a clear
|
|
51
|
+
* failure at `start()` for a run that enqueues and then fails at replay.
|
|
52
|
+
*
|
|
53
|
+
* ## Config details that are not optional
|
|
54
|
+
*
|
|
55
|
+
* Each of these cost real time to find, and none fails in a way that names
|
|
56
|
+
* itself:
|
|
57
|
+
*
|
|
58
|
+
* - `dirs` must carry the `./` prefix. A bare `"workflows"` crashes inside
|
|
59
|
+
* enhanced-resolve with `Cannot read properties of undefined (reading
|
|
60
|
+
* 'length')` from `join(undefined, …)`, nowhere near the cause.
|
|
61
|
+
* - Every bundle path must be ABSOLUTE, for the same reason.
|
|
62
|
+
* - `projectRoot` and `moduleSpecifierRoot` must be set explicitly; they do not
|
|
63
|
+
* default to `workingDir` on the path this takes.
|
|
64
|
+
* - `keepInterimBundleContext` must stay off — it leaves an esbuild watch context
|
|
65
|
+
* alive, so a one-shot build never exits.
|
|
66
|
+
*/
|
|
67
|
+
import type { Plugin } from "vite";
|
|
68
|
+
/**
|
|
69
|
+
* The directory a project's `"use workflow"` bodies live in.
|
|
70
|
+
*
|
|
71
|
+
* The WDK builder's convention, not ours, and it is why a workflow body cannot
|
|
72
|
+
* live in `agent.ts`: only files under here are transformed. A body outside it
|
|
73
|
+
* runs inline, once, with no durability and nothing reporting that.
|
|
74
|
+
*/
|
|
75
|
+
export declare const WORKFLOWS_DIR = "workflows";
|
|
76
|
+
/** What a guest needs to serve workflows for one agent. */
|
|
77
|
+
export type WorkflowBundleOutput = {
|
|
78
|
+
/**
|
|
79
|
+
* The workflow-mode transform of every `"use workflow"` body, as code.
|
|
80
|
+
*
|
|
81
|
+
* Passed to `workflowEntrypoint(code)` in the guest — which is why it is a
|
|
82
|
+
* STRING rather than a file: the guest never sees this project's filesystem.
|
|
83
|
+
*/
|
|
84
|
+
workflowCode: string;
|
|
85
|
+
/**
|
|
86
|
+
* The step-mode transform, as code. Evaluated in the guest so its
|
|
87
|
+
* `registerStepFunction` calls run; nothing imports anything from it.
|
|
88
|
+
*/
|
|
89
|
+
stepCode: string;
|
|
90
|
+
/**
|
|
91
|
+
* The builder's manifest — `workflowId` per exported workflow, plus the step
|
|
92
|
+
* graph. The ids are what `ctx.workflows.start` needs, and the SDK reads them
|
|
93
|
+
* off each body's own `workflowId` property, so nothing consumes this at
|
|
94
|
+
* runtime; it is the builder's own output, kept for inspection and asserted
|
|
95
|
+
* by this package's spec.
|
|
96
|
+
*
|
|
97
|
+
* It is deliberately NOT emitted into the worker bundle. It was, as a
|
|
98
|
+
* double-encoded `__aaiWorkflowManifest` string literal, on the stated
|
|
99
|
+
* grounds that "the studio's workflows card renders it" — which was never
|
|
100
|
+
* true (the card calls `GET /workflows`). Nothing anywhere read the export,
|
|
101
|
+
* so it was bytes in every deploy artifact, re-fetched and hash-verified on
|
|
102
|
+
* every cold guest boot, for no reader.
|
|
103
|
+
*/
|
|
104
|
+
manifest: unknown;
|
|
105
|
+
/**
|
|
106
|
+
* The absolute paths the builder scanned — the agent bundle's client
|
|
107
|
+
* transform runs over exactly these. See the module doc's third-transform
|
|
108
|
+
* section for why it is this list and not a content sniff.
|
|
109
|
+
*/
|
|
110
|
+
inputFiles: readonly string[];
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Attach the compiler's `workflowId`/`stepId` to the agent bundle's copy of
|
|
114
|
+
* each directive body — the third transform, see the module doc.
|
|
115
|
+
*
|
|
116
|
+
* `enforce: "pre"` so it sees the file before Vite's own TypeScript pass: the
|
|
117
|
+
* swc transform reads types itself (it is given the filename to infer syntax),
|
|
118
|
+
* and its output is plain JS that the later pass leaves alone.
|
|
119
|
+
*
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
export declare function workflowClientPlugin(cwd: string, inputFiles: readonly string[]): Plugin;
|
|
123
|
+
/**
|
|
124
|
+
* Build a project's workflows, or resolve `undefined` when it declares none.
|
|
125
|
+
*
|
|
126
|
+
* `undefined` rather than empty strings, because "this project has no workflows"
|
|
127
|
+
* is the common case — every voice agent that never reaches for one — and the
|
|
128
|
+
* guest must be able to tell it apart from "the build produced nothing", which
|
|
129
|
+
* would be a bug.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export declare function buildWorkflows(cwd: string): Promise<WorkflowBundleOutput | undefined>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `aai workflow` — reading and steering a deployed agent's durable runs from a
|
|
3
|
+
* terminal.
|
|
4
|
+
*
|
|
5
|
+
* A run outlives every surface that can show it: the studio's runs card is one
|
|
6
|
+
* project's, and a page holds only the id it started. Without this the only way
|
|
7
|
+
* to ask "what has this agent been doing" is to hand-build a `curl` against
|
|
8
|
+
* `/:slug/workflows`, which needs the platform origin and the PUBLISHED slug —
|
|
9
|
+
* neither of which is the project's name.
|
|
10
|
+
*
|
|
11
|
+
* **It talks to the platform's brokered route, unauthenticated by default**,
|
|
12
|
+
* which is the same posture the page has: that surface carries no credential
|
|
13
|
+
* unless the agent's operator set `AAI_WORKFLOW_API_TOKEN`, and `--token` is how
|
|
14
|
+
* a caller passes it. So this is deliberately NOT an `apiRequest` — the caller's
|
|
15
|
+
* API key is not what authorizes here, and sending it would put a platform
|
|
16
|
+
* credential on a route that does not want one.
|
|
17
|
+
*
|
|
18
|
+
* Every request BROKERS, so the first one may boot the agent's sandbox. That is
|
|
19
|
+
* the same trade the studio card makes and worth knowing before scripting a loop
|
|
20
|
+
* around it.
|
|
21
|
+
*
|
|
22
|
+
* **The requests are the SDK's** (`createWorkflowApiClient`,
|
|
23
|
+
* `@alexkroman1/aai/workflow-api`). What is left here is the two things that are
|
|
24
|
+
* genuinely the CLI's: turning "this directory" into an origin plus a published
|
|
25
|
+
* slug, and PRINTING — which is most of why the verbs exist separately from the
|
|
26
|
+
* client's methods.
|
|
27
|
+
*/
|
|
28
|
+
import type { WorkflowRunSnapshot, WorkflowSummary } from "@alexkroman1/aai";
|
|
29
|
+
import { type CommandResult } from "./_output.ts";
|
|
30
|
+
/**
|
|
31
|
+
* One run, as the API reports it.
|
|
32
|
+
*
|
|
33
|
+
* The SDK's own type, not a restatement: this command prints `status`, `key` and
|
|
34
|
+
* `error`, and a copy is how a field added to the snapshot silently stops being
|
|
35
|
+
* printed. `WorkflowRunSnapshot` is a discriminated union, so `error` is
|
|
36
|
+
* reachable only after narrowing — which is what {@link formatRun} does.
|
|
37
|
+
*/
|
|
38
|
+
type Run = WorkflowRunSnapshot;
|
|
39
|
+
type WorkflowOptions = {
|
|
40
|
+
server?: string | undefined;
|
|
41
|
+
token?: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
/** `aai workflow list` — what this agent declares. */
|
|
44
|
+
export declare function executeWorkflowList(cwd: string, opts: WorkflowOptions): Promise<CommandResult<{
|
|
45
|
+
workflows: WorkflowSummary[];
|
|
46
|
+
}>>;
|
|
47
|
+
/**
|
|
48
|
+
* `aai workflow runs <name>` — recent runs, newest first.
|
|
49
|
+
*
|
|
50
|
+
* `recent` rather than `find`, so the query carries no `key`: a terminal has no
|
|
51
|
+
* correlation key to ask about, and most runs carry none.
|
|
52
|
+
*/
|
|
53
|
+
export declare function executeWorkflowRuns(cwd: string, workflow: string, opts: WorkflowOptions & {
|
|
54
|
+
limit?: number | undefined;
|
|
55
|
+
}): Promise<CommandResult<{
|
|
56
|
+
runs: Run[];
|
|
57
|
+
}>>;
|
|
58
|
+
/** `aai workflow show <runId>` — one run in full, including its output. */
|
|
59
|
+
export declare function executeWorkflowShow(cwd: string, runId: string, opts: WorkflowOptions): Promise<CommandResult<{
|
|
60
|
+
run: Run;
|
|
61
|
+
}>>;
|
|
62
|
+
/** `aai workflow cancel <runId>` — stop a live run. */
|
|
63
|
+
export declare function executeWorkflowCancel(cwd: string, runId: string, opts: WorkflowOptions): Promise<CommandResult<{
|
|
64
|
+
runId: string;
|
|
65
|
+
cancelled: boolean;
|
|
66
|
+
}>>;
|
|
67
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexkroman1/aai-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"aai": "bin.mjs"
|
|
@@ -33,24 +33,26 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@clack/prompts": "^1.7.0",
|
|
36
|
+
"@workflow/builders": "4.1.7",
|
|
36
37
|
"chokidar": "^5.0.0",
|
|
37
38
|
"citty": "^0.2.2",
|
|
38
39
|
"env-paths": "^4.0.0",
|
|
39
|
-
"execa": "^10.0.
|
|
40
|
+
"execa": "^10.0.1",
|
|
40
41
|
"get-port": "^7.2.0",
|
|
41
42
|
"ofetch": "^1.5.1",
|
|
42
43
|
"p-debounce": "^5.1.0",
|
|
43
44
|
"p-timeout": "^7.0.1",
|
|
44
|
-
"vite": "^8.1
|
|
45
|
+
"vite": "^8.2.1",
|
|
45
46
|
"zod": "^4.4.3",
|
|
46
|
-
"@alexkroman1/aai": "
|
|
47
|
-
"@alexkroman1/aai-ui": "
|
|
47
|
+
"@alexkroman1/aai": "6.1.0",
|
|
48
|
+
"@alexkroman1/aai-ui": "6.1.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"playwright": "^1.
|
|
51
|
-
"tsdown": "^0.22.
|
|
52
|
-
"verdaccio": "^6.
|
|
51
|
+
"playwright": "^1.62.1",
|
|
52
|
+
"tsdown": "^0.22.14",
|
|
53
|
+
"verdaccio": "^6.9.2",
|
|
53
54
|
"vitest": "^4.1.10",
|
|
55
|
+
"workflow": "4.8.2",
|
|
54
56
|
"aai-templates": "0.3.4"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
@@ -77,7 +79,9 @@
|
|
|
77
79
|
"lint": "biome check .",
|
|
78
80
|
"check:publint": "publint",
|
|
79
81
|
"check:attw": "attw --pack --profile esm-only",
|
|
80
|
-
"test:
|
|
82
|
+
"test:scenario": "VITEST_PROFILE=scenario VITEST_SETUP=./_test-setup.ts VITEST_INCLUDE=**/*.scenario.test.ts vitest run -c ../../vitest.slow.config.ts",
|
|
83
|
+
"check:scenario": "pnpm run test:scenario",
|
|
84
|
+
"test:e2e": "VITEST_PROFILE=e2e VITEST_SETUP=./_test-setup.ts VITEST_INCLUDE=e2e*.test.ts vitest run -c ../../vitest.slow.config.ts",
|
|
81
85
|
"check:e2e": "pnpm run test:e2e"
|
|
82
86
|
}
|
|
83
87
|
}
|
package/dist/build-DQJ1ZSm9.mjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { a as ok, t as CliError } from "./_output-CC300DzW.mjs";
|
|
3
|
-
import { n as log } from "./_ui-u7T4YooX.mjs";
|
|
4
|
-
import { r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-BuIyDdvs.mjs";
|
|
5
|
-
import { assertTypechecks } from "./_typecheck-gate-4v9UBZHh.mjs";
|
|
6
|
-
import { classifyVitestError, runVitest } from "./test-2LWBcXvY.mjs";
|
|
7
|
-
//#region build.ts
|
|
8
|
-
/**
|
|
9
|
-
* `aai build` — bundle the agent without deploying, behind the same gates
|
|
10
|
-
* deploy runs (tests, then typecheck), so the command previews the deploy
|
|
11
|
-
* artifact and its failures alike.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Map a {@link runVitest} failure to a CliError — distinguishing a real test
|
|
15
|
-
* failure (test_failed) from the runner not spawning (spawn_failed) instead
|
|
16
|
-
* of a generic command_failed.
|
|
17
|
-
*/
|
|
18
|
-
function testGateError(err) {
|
|
19
|
-
const { code, message } = classifyVitestError(err);
|
|
20
|
-
return new CliError(code, message, "Re-run with --skipTests to build without tests", { cause: err });
|
|
21
|
-
}
|
|
22
|
-
async function executeBuild(opts) {
|
|
23
|
-
const { cwd } = opts;
|
|
24
|
-
if (!opts.skipTests) try {
|
|
25
|
-
runVitest(cwd);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
throw testGateError(err);
|
|
28
|
-
}
|
|
29
|
-
if (!opts.skipTypecheck) await assertTypechecks(cwd);
|
|
30
|
-
const bundle = await buildAgentBundle(cwd, { minify: true });
|
|
31
|
-
const agentDef = await evalWorkerBundle(bundle.worker);
|
|
32
|
-
log.success("Build complete");
|
|
33
|
-
return ok({
|
|
34
|
-
name: agentDef.name,
|
|
35
|
-
workerBytes: bundle.worker.length
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
export { executeBuild };
|