@alexkroman1/aai-cli 6.11.0 → 8.0.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/README.md +1 -0
- package/dist/{_agent-DpH2pBJd.mjs → _agent-BTwZJu4P.mjs} +2 -2
- package/dist/{_bundler-C2BDwU7r.mjs → _bundler-CDuYl5Gb.mjs} +2 -2
- package/dist/_dev-env.d.ts +22 -2
- package/dist/{_dev-server-LLLWnFBs.mjs → _dev-server-Me06wgeF.mjs} +38 -47
- package/dist/_dev-server.d.ts +0 -17
- package/dist/{_init-C57bWAQ8.mjs → _init-BhEfQ6Yi.mjs} +3 -2
- package/dist/{_preflight-BtfaYtbE.mjs → _preflight-Co1G9Jww.mjs} +1 -1
- package/dist/_preflight.d.ts +1 -1
- package/dist/_resource-commands.d.ts +23 -0
- package/dist/{_slug-api-BxrsJXVI.mjs → _slug-api-z-USxPtL.mjs} +16 -12
- package/dist/_slug-api.d.ts +5 -2
- package/dist/{_studio-U3jhKlA3.mjs → _studio-DR5yzZ1T.mjs} +2 -1
- package/dist/{_templates-Dxb_P2Wz.mjs → _templates-4WcKOjS5.mjs} +5 -6
- package/dist/_templates.d.ts +3 -4
- package/dist/_workflow-scan.d.ts +108 -0
- package/dist/{build-Dfza2pRI.mjs → build-BBxf8vom.mjs} +6 -3
- package/dist/cli.mjs +346 -349
- package/dist/{client-bundler-BEIqgOtd.mjs → client-bundler-CWnG42cU.mjs} +2 -1
- package/dist/client-bundler.mjs +1 -1
- package/dist/{delete-vbpjGzqs.mjs → delete-Dl_LSfvI.mjs} +3 -3
- package/dist/{deploy-B8lubiRT.mjs → deploy-DRC8jWr8.mjs} +5 -5
- package/dist/{dev-Uq5ujP8a.mjs → dev-BvcctCn2.mjs} +1 -1
- package/dist/eval-DfQ8cm5p.mjs +56 -0
- package/dist/eval.d.ts +43 -0
- package/dist/{init-l6xfU4xX.mjs → init-CUo87gcI.mjs} +3 -3
- package/dist/{login-C71-qz8F.mjs → login-BBuM1sxH.mjs} +3 -4
- package/dist/{logs-BWVGSjLR.mjs → logs-CQ2T46dr.mjs} +2 -2
- package/dist/project-config.mjs +1 -1
- package/dist/scaffold/CLAUDE.md +442 -80
- package/dist/scaffold/package.json +6 -3
- package/dist/scaffold/server.mjs +11 -4
- package/dist/scaffold/tsconfig.json +0 -1
- package/dist/{secret-BuMuFR4B.mjs → secret-Ct34kdgU.mjs} +2 -2
- package/dist/{storage-DzRZ-eCw.mjs → storage-i_79ZwAR.mjs} +2 -2
- package/dist/{studio-BCNUpDgP.mjs → studio-CzTzPqe1.mjs} +4 -4
- package/dist/templates/briefing-desk/agent.test.ts +350 -0
- package/dist/templates/briefing-desk/agent.ts +30 -0
- package/dist/templates/briefing-desk/shared.ts +200 -0
- package/dist/templates/briefing-desk/system-prompt.md +39 -0
- package/dist/templates/briefing-desk/tools/briefing_so_far.ts +35 -0
- package/dist/templates/briefing-desk/tools/research_topic.ts +88 -0
- package/dist/templates/briefing-desk/tools/verify_claim.ts +77 -0
- package/dist/templates/call-audit/agent.eval.test.ts +474 -0
- package/dist/templates/call-audit/agent.test.ts +57 -204
- package/dist/templates/call-audit/agent.ts +32 -19
- package/dist/templates/call-audit/client.tsx +17 -54
- package/dist/templates/call-audit/workflows/audit.ts +11 -18
- package/dist/templates/call-audit/workflows/ingest.ts +106 -114
- package/dist/templates/call-audit/workflows/media.ts +2 -12
- package/dist/templates/call-audit/workflows/summarize.ts +47 -52
- package/dist/templates/call-audit/workflows/sync-api.ts +7 -7
- package/dist/templates/code-interpreter/agent.eval.test.ts +165 -0
- package/dist/templates/dispatch-center/agent.eval.test.ts +349 -0
- package/dist/templates/dispatch-center/agent.test.ts +149 -25
- package/dist/templates/dispatch-center/client.tsx +239 -129
- package/dist/templates/dispatch-center/shared.ts +99 -1
- package/dist/templates/dispatch-center/system-prompt.md +3 -1
- package/dist/templates/dispatch-center/tools/incident_add_note.ts +16 -13
- package/dist/templates/dispatch-center/tools/incident_create.ts +19 -1
- package/dist/templates/dispatch-center/tools/incident_escalate.ts +68 -59
- package/dist/templates/dispatch-center/tools/incident_triage.ts +57 -43
- package/dist/templates/dispatch-center/tools/incident_update_status.ts +49 -40
- package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +8 -2
- package/dist/templates/dispatch-center/tools/resources_dispatch.ts +69 -52
- package/dist/templates/dispatch-center/tools/resources_update_status.ts +45 -41
- package/dist/templates/embedded-assets/agent.eval.test.ts +138 -0
- package/dist/templates/embedded-assets/agent.test.ts +17 -14
- package/dist/templates/health-assistant/agent.eval.test.ts +167 -0
- package/dist/templates/health-assistant/agent.test.ts +22 -4
- package/dist/templates/infocom-adventure/agent.eval.test.ts +158 -0
- package/dist/templates/infocom-adventure/agent.test.ts +53 -24
- package/dist/templates/infocom-adventure/agent.ts +21 -0
- package/dist/templates/infocom-adventure/client.tsx +246 -164
- package/dist/templates/infocom-adventure/shared.ts +20 -9
- package/dist/templates/infocom-adventure/system-prompt.md +1 -1
- package/dist/templates/infocom-adventure/tools/game_state_move.ts +3 -2
- package/dist/templates/link-digest/agent.eval.test.ts +195 -0
- package/dist/templates/link-digest/agent.test.ts +24 -19
- package/dist/templates/link-digest/client.tsx +47 -61
- package/dist/templates/link-digest/workflows/digest.ts +19 -31
- package/dist/templates/math-buddy/agent.eval.test.ts +146 -0
- package/dist/templates/night-owl/agent.eval.test.ts +272 -0
- package/dist/templates/night-owl/agent.test.ts +70 -19
- package/dist/templates/night-owl/agent.ts +5 -0
- package/dist/templates/night-owl/client.tsx +56 -56
- package/dist/templates/night-owl/shared.ts +24 -0
- package/dist/templates/night-owl/tools/recommend.ts +18 -6
- package/dist/templates/personal-finance/agent.eval.test.ts +168 -0
- package/dist/templates/personal-finance/system-prompt.md +4 -0
- package/dist/templates/pipeline-simple/agent.eval.test.ts +78 -0
- package/dist/templates/pipeline-simple/agent.ts +2 -2
- package/dist/templates/pizza-ordering/agent.eval.test.ts +171 -0
- package/dist/templates/pizza-ordering/agent.test.ts +42 -27
- package/dist/templates/pizza-ordering/client.tsx +9 -26
- package/dist/templates/pizza-ordering/shared.ts +20 -1
- package/dist/templates/pizza-ordering/system-prompt.md +6 -0
- package/dist/templates/plan-and-execute/agent.eval.test.ts +209 -0
- package/dist/templates/plan-and-execute/agent.test.ts +99 -58
- package/dist/templates/plan-and-execute/agent.ts +1 -1
- package/dist/templates/plan-and-execute/client.tsx +12 -15
- package/dist/templates/plan-and-execute/shared.ts +71 -2
- package/dist/templates/plan-and-execute/tools/plan_status.ts +18 -6
- package/dist/templates/plan-and-execute/tools/revise_plan.ts +18 -10
- package/dist/templates/plan-and-execute/tools/start_plan.ts +13 -2
- package/dist/templates/plan-and-execute/tools/work_next_step.ts +70 -22
- package/dist/templates/podcast-digest/agent.eval.test.ts +411 -0
- package/dist/templates/podcast-digest/agent.test.ts +717 -0
- package/dist/templates/podcast-digest/agent.ts +139 -0
- package/dist/templates/podcast-digest/client.tsx +154 -0
- package/dist/templates/podcast-digest/workflows/digest.ts +444 -0
- package/dist/templates/podcast-digest/workflows/feeds.ts +507 -0
- package/dist/templates/podcast-digest/workflows/slack.ts +88 -0
- package/dist/templates/recap-workflow/agent.eval.test.ts +366 -0
- package/dist/templates/recap-workflow/agent.test.ts +97 -94
- package/dist/templates/recap-workflow/tools/recap_progress.ts +9 -12
- package/dist/templates/recap-workflow/tools/recap_status.ts +8 -9
- package/dist/templates/recap-workflow/tools/request_recap.ts +2 -1
- package/dist/templates/recap-workflow/workflows/recap.ts +36 -40
- package/dist/templates/redline/agent.eval.test.ts +209 -0
- package/dist/templates/redline/agent.test.ts +17 -15
- package/dist/templates/redline/client.tsx +12 -12
- package/dist/templates/redline/workflows/redline.ts +19 -31
- package/dist/templates/research-workflow/agent.eval.test.ts +329 -0
- package/dist/templates/research-workflow/agent.test.ts +60 -59
- package/dist/templates/research-workflow/tools/research_progress.ts +9 -12
- package/dist/templates/research-workflow/tools/research_status.ts +9 -11
- package/dist/templates/research-workflow/workflows/research.ts +44 -61
- package/dist/templates/retail/address.ts +87 -1
- package/dist/templates/retail/agent.eval.test.ts +314 -0
- package/dist/templates/retail/agent.test.ts +195 -112
- package/dist/templates/retail/agent.ts +35 -1
- package/dist/templates/retail/cancel.ts +116 -0
- package/dist/templates/retail/client.tsx +265 -117
- package/dist/templates/retail/payment.ts +107 -0
- package/dist/templates/retail/pending.test.ts +196 -0
- package/dist/templates/retail/pending.ts +137 -0
- package/dist/templates/retail/registry.test.ts +150 -7
- package/dist/templates/retail/returns.ts +102 -0
- package/dist/templates/retail/shared.test.ts +42 -0
- package/dist/templates/retail/shared.ts +35 -0
- package/dist/templates/retail/store.test.ts +84 -15
- package/dist/templates/retail/store.ts +231 -48
- package/dist/templates/retail/swap.test.ts +4 -4
- package/dist/templates/retail/swap.ts +248 -15
- package/dist/templates/retail/system-prompt.md +69 -28
- package/dist/templates/retail/tools/cancel_change.ts +33 -0
- package/dist/templates/retail/tools/cancel_pending_order.ts +16 -60
- package/dist/templates/retail/tools/confirm_change.ts +42 -0
- package/dist/templates/retail/tools/exchange_delivered_order_items.ts +22 -67
- package/dist/templates/retail/tools/find_user_id_by_email.ts +8 -5
- package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +4 -5
- package/dist/templates/retail/tools/get_item_details.ts +3 -4
- package/dist/templates/retail/tools/get_order_details.ts +3 -4
- package/dist/templates/retail/tools/get_product_details.ts +3 -4
- package/dist/templates/retail/tools/get_user_details.ts +2 -2
- package/dist/templates/retail/tools/list_all_product_types.ts +5 -5
- package/dist/templates/retail/tools/modify_pending_order_address.ts +13 -25
- package/dist/templates/retail/tools/modify_pending_order_items.ts +23 -62
- package/dist/templates/retail/tools/modify_pending_order_payment.ts +16 -78
- package/dist/templates/retail/tools/modify_user_address.ts +13 -16
- package/dist/templates/retail/tools/return_delivered_order_items.ts +17 -72
- package/dist/templates/retail/tools/transfer_to_human_agents.ts +12 -6
- package/dist/templates/simple/agent.eval.test.ts +54 -0
- package/dist/templates/solo-rpg/agent.eval.test.ts +320 -0
- package/dist/templates/solo-rpg/agent.test.ts +227 -48
- package/dist/templates/solo-rpg/client.tsx +38 -37
- package/dist/templates/solo-rpg/shared.ts +145 -19
- package/dist/templates/solo-rpg/system-prompt.md +3 -2
- package/dist/templates/solo-rpg/tools/action_roll.ts +82 -63
- package/dist/templates/solo-rpg/tools/burn_momentum.ts +85 -50
- package/dist/templates/solo-rpg/tools/check_state.ts +24 -7
- package/dist/templates/solo-rpg/tools/load_game.ts +13 -1
- package/dist/templates/solo-rpg/tools/save_game.ts +16 -7
- package/dist/templates/solo-rpg/tools/setup_character.ts +22 -2
- package/dist/templates/solo-rpg/tools/update_state.ts +113 -100
- package/dist/templates/spoken-summary/agent.eval.test.ts +342 -0
- package/dist/templates/spoken-summary/agent.test.ts +68 -97
- package/dist/templates/spoken-summary/agent.ts +30 -17
- package/dist/templates/spoken-summary/client.tsx +10 -50
- package/dist/templates/spoken-summary/workflows/summarize.ts +17 -22
- package/dist/templates/spoken-summary/workflows/transcribe.ts +19 -26
- package/dist/templates/support-line/agent.eval.test.ts +273 -0
- package/dist/templates/support-line/agent.test.ts +11 -16
- package/dist/templates/support-line/agent.ts +1 -1
- package/dist/templates/support-line/client.tsx +9 -9
- package/dist/templates/support-line/nodes.ts +100 -0
- package/dist/templates/support-line/procedure.ts +407 -0
- package/dist/templates/support-line/system-prompt.md +2 -1
- package/dist/templates/support-line/tools/answer_question.ts +66 -4
- package/dist/templates/transcription-workflow/agent.eval.test.ts +234 -0
- package/dist/templates/transcription-workflow/agent.test.ts +94 -194
- package/dist/templates/transcription-workflow/agent.ts +1 -1
- package/dist/templates/transcription-workflow/client.tsx +17 -42
- package/dist/templates/transcription-workflow/workflows/batch.ts +19 -22
- package/dist/templates/transcription-workflow/workflows/normalize.ts +90 -186
- package/dist/templates/transcription-workflow/workflows/stitch.ts +0 -11
- package/dist/templates/transcription-workflow/workflows/stream.ts +4 -5
- package/dist/templates/transcription-workflow/workflows/sync-api.ts +6 -6
- package/dist/templates/transcription-workflow/workflows/transcribe.ts +32 -26
- package/dist/templates/transcription-workflow/workflows/wav.ts +0 -31
- package/dist/templates/travel-concierge/agent.eval.test.ts +323 -0
- package/dist/templates/travel-concierge/agent.test.ts +174 -43
- package/dist/templates/travel-concierge/agent.ts +18 -9
- package/dist/templates/travel-concierge/client.tsx +11 -23
- package/dist/templates/travel-concierge/routing.ts +34 -15
- package/dist/templates/travel-concierge/shared.ts +180 -12
- package/dist/templates/travel-concierge/system-prompt.md +7 -1
- package/dist/templates/travel-concierge/tools/book_car_rental.ts +8 -5
- package/dist/templates/travel-concierge/tools/book_excursion.ts +8 -5
- package/dist/templates/travel-concierge/tools/book_hotel.ts +8 -5
- package/dist/templates/travel-concierge/tools/cancel_ticket.ts +8 -5
- package/dist/templates/travel-concierge/tools/search_car_rentals.ts +9 -5
- package/dist/templates/travel-concierge/tools/search_excursions.ts +9 -5
- package/dist/templates/travel-concierge/tools/search_flights.ts +9 -6
- package/dist/templates/travel-concierge/tools/search_hotels.ts +9 -5
- package/dist/templates/travel-concierge/tools/update_ticket.ts +8 -5
- package/dist/templates/web-researcher/agent.eval.test.ts +121 -0
- package/dist/templates/web-researcher/system-prompt.md +15 -4
- package/dist/{test-9kPKJI-w.mjs → test-BvyT6sAc.mjs} +24 -10
- package/dist/test.d.ts +29 -5
- package/dist/{worker-bundler-CGD4r8Kc.mjs → worker-bundler-CCVEDjm1.mjs} +241 -3
- package/dist/worker-bundler.mjs +1 -1
- package/dist/{workflow-CFpxOFfQ.mjs → workflow-BflATMmU.mjs} +47 -12
- package/dist/workflow-bundler.d.ts +6 -1
- package/dist/workflow.d.ts +1 -1
- package/package.json +5 -4
- package/dist/eject-31gjtaHF.mjs +0 -116
- package/dist/eject.d.ts +0 -60
- package/dist/templates/call-audit/workflows/temp-media.ts +0 -138
- package/dist/templates/infocom-adventure/tools/game_state_history.ts +0 -14
- package/dist/templates/support-line/graph.ts +0 -224
- package/dist/{_config-D_s09e7g.mjs → _config-CmJOFsAP.mjs} +1 -1
- /package/dist/templates/plan-and-execute/{graph.ts → procedure.ts} +0 -0
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ npm i -g @alexkroman1/aai-cli # or: npx @alexkroman1/aai-cli@latest
|
|
|
14
14
|
| `aai templates` | List the shipped project templates |
|
|
15
15
|
| `aai dev` | Local dev server: loads `agent.ts`, rebuilds on change, serves the browser client (`--port`) |
|
|
16
16
|
| `aai test` | Run the project's vitest suite |
|
|
17
|
+
| `aai eval` | Run the project's behaviour evals (`agent.eval.test.ts`) — a real session, a live model with a key, a scripted one without |
|
|
17
18
|
| `aai build` | Bundle without deploying (type-checks first; `--skipTypecheck` opts out) |
|
|
18
19
|
| `aai list` | List your studio projects |
|
|
19
20
|
| `aai pull <project>` | Pull a studio project into a local directory, ready for `aai dev` |
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as serverOrigin, i as readProjectConfig, n as ensureApiKey, r as readGlobalConfig, t as approveServer } from "./_config-
|
|
2
|
+
import { a as serverOrigin, i as readProjectConfig, n as ensureApiKey, r as readGlobalConfig, t as approveServer } from "./_config-CmJOFsAP.mjs";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { VALID_SLUG_RE } from "@alexkroman1/aai/
|
|
6
|
+
import { VALID_SLUG_RE } from "@alexkroman1/aai/internal";
|
|
7
7
|
//#region _agent.ts
|
|
8
8
|
const DEFAULT_SERVER = "https://alexkroman--aai-server-web-server.modal.run";
|
|
9
9
|
const DEFAULT_DEV_SERVER = "http://localhost:8080";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { f as validateAgentExport } from "./_utils-B8QmtFhK.mjs";
|
|
3
|
-
import { t as buildClient } from "./client-bundler-
|
|
4
|
-
import { n as buildWorkflows, t as buildWorker } from "./worker-bundler-
|
|
3
|
+
import { t as buildClient } from "./client-bundler-CWnG42cU.mjs";
|
|
4
|
+
import { n as buildWorkflows, t as buildWorker } from "./worker-bundler-CCVEDjm1.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
import { omitUndefined } from "@alexkroman1/aai/utils";
|
package/dist/_dev-env.d.ts
CHANGED
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
* (who may connect, where it binds, whether it restarts), so they are read from
|
|
10
10
|
* the environment on purpose and must never leak into `ctx.env`.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* `createDevLogger` sits here for the second half of that reason rather than
|
|
13
|
+
* the first: it is not a control variable, it READS one — the same auto-
|
|
14
|
+
* detected JSON mode — to decide where the runtime's diagnostics go. Both
|
|
15
|
+
* were split out of `_dev-server.ts` to keep it under the file-length cap,
|
|
16
|
+
* and `_dev-server.ts` is the only consumer of either.
|
|
14
17
|
*/
|
|
18
|
+
import type { Logger } from "@alexkroman1/aai-runtime";
|
|
15
19
|
/**
|
|
16
20
|
* The env handed to `createServer` for host-mode connections: provider
|
|
17
21
|
* credentials plus the `AAI_ALLOW_HOST` gate read straight from the shell
|
|
@@ -36,3 +40,19 @@ export declare function devBindHost(): string | undefined;
|
|
|
36
40
|
* as a provider failure several records deep.
|
|
37
41
|
*/
|
|
38
42
|
export declare function devWatchEnabled(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The logger the dev server's runtime writes through.
|
|
45
|
+
*
|
|
46
|
+
* The SDK's default logger is console-backed and `console.log` is STDOUT, so
|
|
47
|
+
* in JSON mode the runtime's own diagnostics — the multi-line "Session mode
|
|
48
|
+
* resolved" dump at startup, every later warning — landed on stdout ahead of
|
|
49
|
+
* the single result line `aai dev` promises there. JSON mode is AUTO-DETECTED
|
|
50
|
+
* on a pipe, so that is the normal case rather than an opt-in one:
|
|
51
|
+
* `aai dev > dev.log`, a process supervisor, a container. It is the same
|
|
52
|
+
* hazard `notify` exists for, one layer down: `silenceOutput()` only reaches
|
|
53
|
+
* this CLI's own `log`, and the runtime is not using it.
|
|
54
|
+
*
|
|
55
|
+
* Human mode keeps the console logger exactly as it was — a TTY has nothing
|
|
56
|
+
* to parse, and stdout is where people are already reading these.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createDevLogger(silenced: boolean): Logger;
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { i as outputSilenced, r as notify } from "./_ui-u7T4YooX.mjs";
|
|
3
3
|
import { i as errorCode, o as errorMessage$1 } from "./_utils-B8QmtFhK.mjs";
|
|
4
|
-
import { n as fallbackHtmlPlugin } from "./client-bundler-
|
|
4
|
+
import { n as fallbackHtmlPlugin } from "./client-bundler-CWnG42cU.mjs";
|
|
5
5
|
import { t as DEDUPED_PEERS } from "./_vite-env-BNveawd1.mjs";
|
|
6
|
-
import { n as buildWorkflows, t as buildWorker } from "./worker-bundler-
|
|
7
|
-
import { n as ensureApiKey } from "./_config-
|
|
8
|
-
import { n as createWorkerEvaluator } from "./_bundler-
|
|
6
|
+
import { n as buildWorkflows, t as buildWorker } from "./worker-bundler-CCVEDjm1.mjs";
|
|
7
|
+
import { n as ensureApiKey } from "./_config-CmJOFsAP.mjs";
|
|
8
|
+
import { n as createWorkerEvaluator } from "./_bundler-CDuYl5Gb.mjs";
|
|
9
9
|
import { t as resolveServerEnv } from "./_server-common-6e0QI4mq.mjs";
|
|
10
10
|
import { existsSync } from "node:fs";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { omitUndefined } from "@alexkroman1/aai/utils";
|
|
13
13
|
import { createCoalescingRunner, sleep } from "@alexkroman1/aai/internal";
|
|
14
|
-
import {
|
|
14
|
+
import { agentConfigWarnings } from "@alexkroman1/aai/manifest";
|
|
15
|
+
import { WORKFLOW_API_PREFIX, createRuntime, createServer, requiredProviderEnvVars, withHostCredentialFallback } from "@alexkroman1/aai-runtime";
|
|
16
|
+
import { configureWorkflowWorld, consoleLogger, createWorkflowSurface, handleWorkflowRequest, publishStepEnv, startWorkflowWorldIfDeclared } from "@alexkroman1/aai-runtime/internal";
|
|
15
17
|
import { defaultClientDir } from "@alexkroman1/aai-ui/client-dir";
|
|
16
18
|
import { watch } from "chokidar";
|
|
17
19
|
import getPort, { portNumbers } from "get-port";
|
|
18
20
|
import pDebounce from "p-debounce";
|
|
19
21
|
//#region _dev-env.ts
|
|
20
22
|
/**
|
|
21
|
-
* The dev server's CONTROL variables — the three things read straight from the
|
|
22
|
-
* shell rather than from the agent's `.env`.
|
|
23
|
-
*
|
|
24
|
-
* That distinction is the reason these live together. `resolveServerEnv` builds
|
|
25
|
-
* `ctx.env` from `.env`-declared keys only, deliberately, so an agent cannot
|
|
26
|
-
* come to depend on a shell variable that will not exist after deploy. These
|
|
27
|
-
* three are not agent config at all — they configure the *dev server process*
|
|
28
|
-
* (who may connect, where it binds, whether it restarts), so they are read from
|
|
29
|
-
* the environment on purpose and must never leak into `ctx.env`.
|
|
30
|
-
*
|
|
31
|
-
* Split out of `_dev-server.ts` purely to keep that module under the
|
|
32
|
-
* file-length cap; it is the only consumer.
|
|
33
|
-
*/
|
|
34
|
-
/**
|
|
35
23
|
* The env handed to `createServer` for host-mode connections: provider
|
|
36
24
|
* credentials plus the `AAI_ALLOW_HOST` gate read straight from the shell
|
|
37
25
|
* (it is a control variable, not something an agent declares in `.env`).
|
|
@@ -66,6 +54,33 @@ function devBindHost() {
|
|
|
66
54
|
function devWatchEnabled() {
|
|
67
55
|
return /^(1|true|yes|on)$/i.test(process.env.AAI_DEV_WATCH?.trim() ?? "");
|
|
68
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* The logger the dev server's runtime writes through.
|
|
59
|
+
*
|
|
60
|
+
* The SDK's default logger is console-backed and `console.log` is STDOUT, so
|
|
61
|
+
* in JSON mode the runtime's own diagnostics — the multi-line "Session mode
|
|
62
|
+
* resolved" dump at startup, every later warning — landed on stdout ahead of
|
|
63
|
+
* the single result line `aai dev` promises there. JSON mode is AUTO-DETECTED
|
|
64
|
+
* on a pipe, so that is the normal case rather than an opt-in one:
|
|
65
|
+
* `aai dev > dev.log`, a process supervisor, a container. It is the same
|
|
66
|
+
* hazard `notify` exists for, one layer down: `silenceOutput()` only reaches
|
|
67
|
+
* this CLI's own `log`, and the runtime is not using it.
|
|
68
|
+
*
|
|
69
|
+
* Human mode keeps the console logger exactly as it was — a TTY has nothing
|
|
70
|
+
* to parse, and stdout is where people are already reading these.
|
|
71
|
+
*/
|
|
72
|
+
function createDevLogger(silenced) {
|
|
73
|
+
if (!silenced) return consoleLogger;
|
|
74
|
+
const write = (msg, ctx) => {
|
|
75
|
+
process.stderr.write(`${msg}${ctx === void 0 ? "" : ` ${JSON.stringify(ctx)}`}\n`);
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
info: write,
|
|
79
|
+
warn: write,
|
|
80
|
+
error: write,
|
|
81
|
+
debug: () => void 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
69
84
|
//#endregion
|
|
70
85
|
//#region _dev-restart.ts
|
|
71
86
|
/**
|
|
@@ -237,6 +252,7 @@ async function resolveAgentEnv(root, agentDef) {
|
|
|
237
252
|
const hasShellKey = Boolean(process.env.ASSEMBLYAI_API_KEY);
|
|
238
253
|
if (required.includes("ASSEMBLYAI_API_KEY") && !env.ASSEMBLYAI_API_KEY && !hasShellKey) env.ASSEMBLYAI_API_KEY = await ensureApiKey();
|
|
239
254
|
for (const warning of agentEnvWarnings(agentDef, env)) notify("warn", warning);
|
|
255
|
+
for (const warning of agentConfigWarnings(agentDef)) notify("warn", warning);
|
|
240
256
|
return env;
|
|
241
257
|
}
|
|
242
258
|
/**
|
|
@@ -260,9 +276,11 @@ async function resolveAgentEnv(root, agentDef) {
|
|
|
260
276
|
* without starting a builder.
|
|
261
277
|
*/
|
|
262
278
|
async function loadWorker(cwd, evaluate) {
|
|
279
|
+
const workflows = await buildWorkflows(cwd);
|
|
280
|
+
for (const warning of workflows?.warnings ?? []) notify("warn", warning);
|
|
263
281
|
return evaluate(await buildWorker(cwd, {
|
|
264
282
|
runtime: false,
|
|
265
|
-
workflows
|
|
283
|
+
workflows
|
|
266
284
|
}));
|
|
267
285
|
}
|
|
268
286
|
/**
|
|
@@ -284,33 +302,6 @@ function isIgnoredPath(dir, filePath) {
|
|
|
284
302
|
});
|
|
285
303
|
}
|
|
286
304
|
/**
|
|
287
|
-
* The logger the dev server's runtime writes through.
|
|
288
|
-
*
|
|
289
|
-
* The SDK's default logger is console-backed and `console.log` is STDOUT, so
|
|
290
|
-
* in JSON mode the runtime's own diagnostics — the multi-line "Session mode
|
|
291
|
-
* resolved" dump at startup, every later warning — landed on stdout ahead of
|
|
292
|
-
* the single result line `aai dev` promises there. JSON mode is AUTO-DETECTED
|
|
293
|
-
* on a pipe, so that is the normal case rather than an opt-in one:
|
|
294
|
-
* `aai dev > dev.log`, a process supervisor, a container. It is the same
|
|
295
|
-
* hazard `notify` exists for, one layer down: `silenceOutput()` only reaches
|
|
296
|
-
* this CLI's own `log`, and the runtime is not using it.
|
|
297
|
-
*
|
|
298
|
-
* Human mode keeps the console logger exactly as it was — a TTY has nothing
|
|
299
|
-
* to parse, and stdout is where people are already reading these.
|
|
300
|
-
*/
|
|
301
|
-
function createDevLogger(silenced) {
|
|
302
|
-
if (!silenced) return consoleLogger;
|
|
303
|
-
const write = (msg, ctx) => {
|
|
304
|
-
process.stderr.write(`${msg}${ctx === void 0 ? "" : ` ${JSON.stringify(ctx)}`}\n`);
|
|
305
|
-
};
|
|
306
|
-
return {
|
|
307
|
-
info: write,
|
|
308
|
-
warn: write,
|
|
309
|
-
error: write,
|
|
310
|
-
debug: () => void 0
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
305
|
* Watch the agent directory for changes and call `onChange` when detected.
|
|
315
306
|
* Debounces to avoid rapid restarts. Uses chokidar for reliable recursive
|
|
316
307
|
* watching across platforms (raw `fs.watch` misses events on Linux).
|
package/dist/_dev-server.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
* client SPA HMR.
|
|
8
8
|
*/
|
|
9
9
|
import type { AgentDef } from "@alexkroman1/aai";
|
|
10
|
-
import { type Logger } from "@alexkroman1/aai/runtime";
|
|
11
10
|
import { type FSWatcher } from "chokidar";
|
|
12
11
|
import { type EvaluatedWorker } from "./_bundler.ts";
|
|
13
12
|
/**
|
|
@@ -55,22 +54,6 @@ export declare function loadWorker(cwd: string, evaluate: (code: string) => Prom
|
|
|
55
54
|
* restart the server with the new values.
|
|
56
55
|
*/
|
|
57
56
|
export declare function isIgnoredPath(dir: string, filePath: string): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* The logger the dev server's runtime writes through.
|
|
60
|
-
*
|
|
61
|
-
* The SDK's default logger is console-backed and `console.log` is STDOUT, so
|
|
62
|
-
* in JSON mode the runtime's own diagnostics — the multi-line "Session mode
|
|
63
|
-
* resolved" dump at startup, every later warning — landed on stdout ahead of
|
|
64
|
-
* the single result line `aai dev` promises there. JSON mode is AUTO-DETECTED
|
|
65
|
-
* on a pipe, so that is the normal case rather than an opt-in one:
|
|
66
|
-
* `aai dev > dev.log`, a process supervisor, a container. It is the same
|
|
67
|
-
* hazard `notify` exists for, one layer down: `silenceOutput()` only reaches
|
|
68
|
-
* this CLI's own `log`, and the runtime is not using it.
|
|
69
|
-
*
|
|
70
|
-
* Human mode keeps the console logger exactly as it was — a TTY has nothing
|
|
71
|
-
* to parse, and stdout is where people are already reading these.
|
|
72
|
-
*/
|
|
73
|
-
export declare function createDevLogger(silenced: boolean): Logger;
|
|
74
57
|
/**
|
|
75
58
|
* Watch the agent directory for changes and call `onChange` when detected.
|
|
76
59
|
* Debounces to avoid rapid restarts. Uses chokidar for reliable recursive
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { c as isEexist, l as readJson, p as writeJson } from "./_utils-B8QmtFhK.mjs";
|
|
3
|
-
import { r as isDevMode, t as getMonorepoRoot } from "./_agent-
|
|
4
|
-
import { REPO_URL, downloadAndMergeTemplate } from "./_templates-
|
|
3
|
+
import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BTwZJu4P.mjs";
|
|
4
|
+
import { REPO_URL, downloadAndMergeTemplate } from "./_templates-4WcKOjS5.mjs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
//#region _init.ts
|
|
@@ -46,6 +46,7 @@ aai secret delete MY_KEY # Remove a secret
|
|
|
46
46
|
const WORKSPACE_PKG_DIRS = {
|
|
47
47
|
"@alexkroman1/aai": "aai",
|
|
48
48
|
"@alexkroman1/aai-cli": "aai-cli",
|
|
49
|
+
"@alexkroman1/aai-runtime": "aai-runtime",
|
|
49
50
|
"@alexkroman1/aai-ui": "aai-ui"
|
|
50
51
|
};
|
|
51
52
|
/** Rewrite workspace deps to link: paths so pnpm links to local source. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { requiredProviderEnvVars } from "@alexkroman1/aai
|
|
2
|
+
import { requiredProviderEnvVars } from "@alexkroman1/aai-runtime";
|
|
3
3
|
//#region _preflight.ts
|
|
4
4
|
/**
|
|
5
5
|
* The deploy-time credential preflight — the classic dev/prod failure, caught
|
package/dist/_preflight.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* accuracy, and a false rejection is worse than a false warning: it blocks a
|
|
23
23
|
* deploy that would have worked.
|
|
24
24
|
*/
|
|
25
|
-
import { requiredProviderEnvVars } from "@alexkroman1/aai
|
|
25
|
+
import { requiredProviderEnvVars } from "@alexkroman1/aai-runtime";
|
|
26
26
|
/**
|
|
27
27
|
* The config shape read out of a bundle's `__aaiConfig` export: the provider
|
|
28
28
|
* descriptors the credential derivation needs, plus the agent's declared
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const secret: import("citty").CommandDef<import("citty").ArgsDef>;
|
|
2
|
+
export declare const logs: import("citty").CommandDef<{
|
|
3
|
+
readonly dir: {
|
|
4
|
+
readonly type: "positional";
|
|
5
|
+
readonly description: "Project directory";
|
|
6
|
+
readonly required: false;
|
|
7
|
+
};
|
|
8
|
+
readonly follow: {
|
|
9
|
+
readonly type: "boolean";
|
|
10
|
+
readonly alias: "f";
|
|
11
|
+
readonly description: "Keep printing new output";
|
|
12
|
+
};
|
|
13
|
+
readonly server: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly alias: "s";
|
|
16
|
+
readonly description: "Platform server URL";
|
|
17
|
+
};
|
|
18
|
+
readonly json: {
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
readonly description: "Output JSON (auto-detected in non-TTY)";
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export declare const storage: import("citty").CommandDef<import("citty").ArgsDef>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as getServerInfo } from "./_agent-
|
|
3
|
-
import { l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-
|
|
2
|
+
import { n as getServerInfo } from "./_agent-BTwZJu4P.mjs";
|
|
3
|
+
import { l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-DR5yzZ1T.mjs";
|
|
4
4
|
//#region _slug-api.ts
|
|
5
5
|
/**
|
|
6
6
|
* Authenticated request against a deployed agent's slug-scoped resource
|
|
@@ -13,6 +13,18 @@ import { l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } fro
|
|
|
13
13
|
* stays real — an intra-module call would bypass those mocks.
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
|
+
* The request itself — one definition so the "not deployed" 404 hint this
|
|
17
|
+
* module exists to attach cannot be present on one route and missing on the
|
|
18
|
+
* other. Only the URL differs between the two callers.
|
|
19
|
+
*/
|
|
20
|
+
function deployedAgentRequest(url, init, apiKey) {
|
|
21
|
+
return apiRequest(url, {
|
|
22
|
+
...init,
|
|
23
|
+
apiKey,
|
|
24
|
+
hints: { 404: HINT_NOT_DEPLOYED }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
16
28
|
* A SECRET request, routed to the project when this directory is linked to
|
|
17
29
|
* one and to the bare slug otherwise.
|
|
18
30
|
*
|
|
@@ -27,22 +39,14 @@ import { l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } fro
|
|
|
27
39
|
async function secretRequest(cwd, resourcePath, init, server) {
|
|
28
40
|
const { serverUrl, slug, apiKey, studioProject } = await getServerInfo(cwd, server);
|
|
29
41
|
return {
|
|
30
|
-
data: await
|
|
31
|
-
...init,
|
|
32
|
-
apiKey,
|
|
33
|
-
hints: { 404: HINT_NOT_DEPLOYED }
|
|
34
|
-
}),
|
|
42
|
+
data: await deployedAgentRequest(`${studioProject ? studioProjectApiUrl(serverUrl, studioProject) : `${serverUrl}/${slug}`}/secret${resourcePath}`, init, apiKey),
|
|
35
43
|
target: studioProject ?? slug
|
|
36
44
|
};
|
|
37
45
|
}
|
|
38
46
|
async function slugRequest(cwd, resourcePath, init, server) {
|
|
39
47
|
const { serverUrl, slug, apiKey } = await getServerInfo(cwd, server);
|
|
40
48
|
return {
|
|
41
|
-
data: await
|
|
42
|
-
...init,
|
|
43
|
-
apiKey,
|
|
44
|
-
hints: { 404: HINT_NOT_DEPLOYED }
|
|
45
|
-
}),
|
|
49
|
+
data: await deployedAgentRequest(`${serverUrl}/${slug}${resourcePath}`, init, apiKey),
|
|
46
50
|
slug
|
|
47
51
|
};
|
|
48
52
|
}
|
package/dist/_slug-api.d.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* stays real — an intra-module call would bypass those mocks.
|
|
10
10
|
*/
|
|
11
11
|
import { type ApiRequestOptions } from "./_api-client.ts";
|
|
12
|
+
/** What both requests below pass through to the API client. */
|
|
13
|
+
type SlugRequestInit = Pick<ApiRequestOptions, "method" | "body" | "action">;
|
|
12
14
|
/**
|
|
13
15
|
* A SECRET request, routed to the project when this directory is linked to
|
|
14
16
|
* one and to the bare slug otherwise.
|
|
@@ -21,11 +23,12 @@ import { type ApiRequestOptions } from "./_api-client.ts";
|
|
|
21
23
|
* user's own `aai publish` had created. An unlinked directory has one agent
|
|
22
24
|
* and keeps the per-slug route, which is the platform primitive underneath.
|
|
23
25
|
*/
|
|
24
|
-
export declare function secretRequest<T = unknown>(cwd: string, resourcePath: string, init:
|
|
26
|
+
export declare function secretRequest<T = unknown>(cwd: string, resourcePath: string, init: SlugRequestInit, server?: string): Promise<{
|
|
25
27
|
data: T;
|
|
26
28
|
target: string;
|
|
27
29
|
}>;
|
|
28
|
-
export declare function slugRequest<T = unknown>(cwd: string, resourcePath: string, init:
|
|
30
|
+
export declare function slugRequest<T = unknown>(cwd: string, resourcePath: string, init: SlugRequestInit, server?: string): Promise<{
|
|
29
31
|
data: T;
|
|
30
32
|
slug: string;
|
|
31
33
|
}>;
|
|
34
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { t as CliError } from "./_output-CKkmWs7i.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
|
|
5
|
+
import { MAX_SLUG_LENGTH, PREVIEW_SLUG_SUFFIX, VALID_SLUG_RE } from "@alexkroman1/aai/internal";
|
|
5
6
|
import { FetchError, ofetch } from "ofetch";
|
|
6
7
|
import { slugifyName } from "@alexkroman1/aai/slugify";
|
|
7
8
|
import { isLocalOnlyFile, snapshotWorkspaceFiles } from "@alexkroman1/aai/workspace-files";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { o as errorMessage$1 } from "./_utils-B8QmtFhK.mjs";
|
|
3
|
-
import { t as getMonorepoRoot } from "./_agent-
|
|
3
|
+
import { t as getMonorepoRoot } from "./_agent-BTwZJu4P.mjs";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { isRecord } from "@alexkroman1/aai/utils";
|
|
@@ -120,10 +120,9 @@ async function readJsonFile(file) {
|
|
|
120
120
|
* Directory holding the base scaffold — the files every project gets
|
|
121
121
|
* underneath its template (package.json, tsconfig, `server.mjs`, …).
|
|
122
122
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* byte-identical output to one `aai init` scaffolded.
|
|
123
|
+
* The scaffold is the single definition of the self-hosted entrypoint, so a
|
|
124
|
+
* caller needing one of its files resolves it here rather than carrying a
|
|
125
|
+
* second copy of that file's contents.
|
|
127
126
|
*/
|
|
128
127
|
function scaffoldDir() {
|
|
129
128
|
return path.join(resolveTemplatesDir(), "scaffold");
|
|
@@ -164,4 +163,4 @@ async function downloadAndMergeTemplate(template, targetDir) {
|
|
|
164
163
|
await layerScaffold(targetDir);
|
|
165
164
|
}
|
|
166
165
|
//#endregion
|
|
167
|
-
export { REPO_URL, downloadAndMergeTemplate, layerScaffold, listTemplates
|
|
166
|
+
export { REPO_URL, downloadAndMergeTemplate, layerScaffold, listTemplates };
|
package/dist/_templates.d.ts
CHANGED
|
@@ -39,10 +39,9 @@ export declare function mergeScaffoldManifest(existing: Manifest, scaffold: Mani
|
|
|
39
39
|
* Directory holding the base scaffold — the files every project gets
|
|
40
40
|
* underneath its template (package.json, tsconfig, `server.mjs`, …).
|
|
41
41
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* byte-identical output to one `aai init` scaffolded.
|
|
42
|
+
* The scaffold is the single definition of the self-hosted entrypoint, so a
|
|
43
|
+
* caller needing one of its files resolves it here rather than carrying a
|
|
44
|
+
* second copy of that file's contents.
|
|
46
45
|
*/
|
|
47
46
|
export declare function scaffoldDir(): string;
|
|
48
47
|
/**
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the BUILT flow bundle carries — the two scans that read it, and the
|
|
3
|
+
* checks over them.
|
|
4
|
+
*
|
|
5
|
+
* Split out of `workflow-bundler.ts` when that file crossed the 500-line cap,
|
|
6
|
+
* along the seam the two scans already share: both read the same artifact after
|
|
7
|
+
* the builder has written it, both attribute a line to a module through
|
|
8
|
+
* esbuild's `// <path>` headers, and neither has anything to do with
|
|
9
|
+
* CONFIGURING the build. One of them fails the build (a `require` the workflow
|
|
10
|
+
* VM cannot answer) and the other warns (a call that replays differently), which
|
|
11
|
+
* is the only real difference between them.
|
|
12
|
+
*
|
|
13
|
+
* Internal: `workflow-bundler.ts` is the surface the studio and the CLI's own
|
|
14
|
+
* build call, and it re-exports nothing from here that they need.
|
|
15
|
+
*
|
|
16
|
+
* @module _workflow-scan
|
|
17
|
+
*/
|
|
18
|
+
/** One `require` the workflow VM cannot answer, and the module it was written for. */
|
|
19
|
+
export type VmRequireSite = {
|
|
20
|
+
/** The module specifier — `node:child_process`. */
|
|
21
|
+
specifier: string;
|
|
22
|
+
/** The bundled file esbuild attributed it to, or `undefined` when it said none. */
|
|
23
|
+
module: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Find the Node builtins a flow bundle would `require` at load.
|
|
27
|
+
*
|
|
28
|
+
* The flow bundle is compiled in a `node:vm` `Script` whose context has
|
|
29
|
+
* `module` and `exports` and **no `require`**, so one of these is a run that
|
|
30
|
+
* dies at replay with `ReferenceError: require is not defined` — never a build
|
|
31
|
+
* failure, and never a symptom before the first run. The WDK's own builder
|
|
32
|
+
* bundles everything for exactly this reason and carries
|
|
33
|
+
* `createNodeModuleErrorPlugin` to reject a builtin import at build time.
|
|
34
|
+
*
|
|
35
|
+
* That plugin has two blind spots this scan covers, and both are the DEPLOYED
|
|
36
|
+
* shape rather than an exotic one:
|
|
37
|
+
*
|
|
38
|
+
* - It reports a violation only when it can point at the import LINE in a
|
|
39
|
+
* first-party file, matched with a single-line regex — so a multi-line
|
|
40
|
+
* `import {\n x,\n} from "pkg"` finds nothing and the builtin is marked
|
|
41
|
+
* external in silence.
|
|
42
|
+
* - It resolves that file against `process.cwd()`, which is not the project
|
|
43
|
+
* being built when the studio builds a workspace, so the read fails and the
|
|
44
|
+
* same silent path is taken.
|
|
45
|
+
*
|
|
46
|
+
* Both were reproduced. What reaches the VM either way is
|
|
47
|
+
* `var import_node_child_process = require("node:child_process");` at the top
|
|
48
|
+
* of the bundle, i.e. every run of every workflow in the project fails, and the
|
|
49
|
+
* stack names a line of generated code inside a dependency.
|
|
50
|
+
*
|
|
51
|
+
* Restricted to builtin specifiers deliberately: those are the only ones this
|
|
52
|
+
* builder leaves external (it marks nothing else so, precisely so nothing can
|
|
53
|
+
* need a `require`), and a narrow set is what keeps the scan from reading the
|
|
54
|
+
* text of a prompt as a violation.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export declare function findVmRequires(workflowCode: string): VmRequireSite[];
|
|
59
|
+
/** One replay-unsafe call the flow bundle carries, and where it came from. */
|
|
60
|
+
export type ReplayUnsafeSite = {
|
|
61
|
+
/** The call, as written — `Date.now(`. */
|
|
62
|
+
call: string;
|
|
63
|
+
/** What it does on a replay, and what to do instead. */
|
|
64
|
+
fix: string;
|
|
65
|
+
/** The project file esbuild attributed it to. */
|
|
66
|
+
module: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Replay-unsafe calls the flow bundle carries, attributed to the project's OWN
|
|
70
|
+
* `workflows/` files.
|
|
71
|
+
*
|
|
72
|
+
* Attribution is the whole design. The bundle inlines every non-external
|
|
73
|
+
* dependency a workflow module imports — zod, a markdown parser, whatever — and
|
|
74
|
+
* third-party code is full of `Date.now()` on paths a workflow never reaches, so
|
|
75
|
+
* a scan of the bundle's text reports a library and blocks a correct project.
|
|
76
|
+
* esbuild writes a `// <path>` header per module (the same one
|
|
77
|
+
* {@link findVmRequires} reads), so lines can be charged to the file they were
|
|
78
|
+
* written in, and only the project's own workflow sources are read.
|
|
79
|
+
*
|
|
80
|
+
* Scanning the BUNDLE rather than the sources is what makes a `"use step"` body
|
|
81
|
+
* exempt for free: the workflow-mode transform has already removed them, so
|
|
82
|
+
* what is left is the part that really does replay.
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
export declare function findReplayUnsafeCalls(workflowCode: string): ReplayUnsafeSite[];
|
|
87
|
+
/**
|
|
88
|
+
* The warning `aai build` and `aai dev` print for a replay-unsafe call.
|
|
89
|
+
*
|
|
90
|
+
* A WARNING and not a build failure, deliberately. The attribution above makes
|
|
91
|
+
* the scan accurate about which FILE a call is in, and it cannot know whether a
|
|
92
|
+
* plain function in a `workflows/` module is reached from a body (where the
|
|
93
|
+
* rule bites) or only from a step (where it does not) — so the one thing it
|
|
94
|
+
* must not do is refuse a correct project. A silent build was the actual
|
|
95
|
+
* problem; a line naming the file solves it without that risk.
|
|
96
|
+
*/
|
|
97
|
+
export declare function replayWarnings(workflowCode: string): string[];
|
|
98
|
+
/**
|
|
99
|
+
* Fail the build when the flow bundle carries a `require` — see
|
|
100
|
+
* {@link findVmRequires} for what that means and why nothing upstream catches it.
|
|
101
|
+
*
|
|
102
|
+
* The message has to name the MODULE as well as the specifier, because the
|
|
103
|
+
* import that caused it is not in the file an author is looking at: only a
|
|
104
|
+
* `"use step"` body is stripped from this bundle, so a value a `workflows/`
|
|
105
|
+
* module holds at module scope — an exported helper, a constant — keeps its
|
|
106
|
+
* import, and that import's whole graph rides into the VM.
|
|
107
|
+
*/
|
|
108
|
+
export declare function assertNoVmRequires(workflowCode: string): void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as ok, t as CliError } from "./_output-CKkmWs7i.mjs";
|
|
3
|
-
import { n as log } from "./_ui-u7T4YooX.mjs";
|
|
4
|
-
import { r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-
|
|
3
|
+
import { n as log, r as notify } from "./_ui-u7T4YooX.mjs";
|
|
4
|
+
import { r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-CDuYl5Gb.mjs";
|
|
5
5
|
import { assertTypechecks } from "./_typecheck-gate-BXvUNnfs.mjs";
|
|
6
|
-
import { classifyVitestError, runVitest } from "./test-
|
|
6
|
+
import { classifyVitestError, runVitest } from "./test-BvyT6sAc.mjs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
|
+
import { agentConfigWarnings } from "@alexkroman1/aai/manifest";
|
|
9
10
|
//#region build.ts
|
|
10
11
|
/**
|
|
11
12
|
* `aai build` — bundle the agent without deploying, behind the same gates
|
|
@@ -47,7 +48,9 @@ async function executeBuild(opts) {
|
|
|
47
48
|
}
|
|
48
49
|
if (!opts.skipTypecheck) await assertTypechecks(cwd);
|
|
49
50
|
const bundle = await buildAgentBundle(cwd, { minify: true });
|
|
51
|
+
for (const warning of bundle.workflows?.warnings ?? []) notify("warn", warning);
|
|
50
52
|
const agentDef = await evalWorkerBundle(bundle.worker);
|
|
53
|
+
for (const warning of agentConfigWarnings(agentDef)) notify("warn", warning);
|
|
51
54
|
const worker = path.join(cwd, WORKER_ARTIFACT_REL);
|
|
52
55
|
await fs.mkdir(path.dirname(worker), { recursive: true });
|
|
53
56
|
await fs.writeFile(worker, bundle.worker, "utf-8");
|