@alexkroman1/aai-cli 16.1.0 → 17.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 +2 -1
- package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
- package/dist/_build-target.d.ts +98 -19
- package/dist/_deno-target.d.ts +15 -14
- package/dist/_dev-env.d.ts +19 -13
- package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-CLU9xjH5.mjs} +25 -17
- package/dist/_dev-server.d.ts +4 -3
- package/dist/_init.d.ts +39 -0
- package/dist/_modal-target.d.ts +11 -6
- package/dist/_preflight-CnW9QiE7.mjs +116 -0
- package/dist/_preflight.d.ts +110 -5
- package/dist/_target-bundle.d.ts +112 -0
- package/dist/_target-entry.d.ts +81 -0
- package/dist/{_templates-CuP74F8D.mjs → _templates-IMeKMVIj.mjs} +1 -1
- package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
- package/dist/_vitest-runner.d.ts +35 -23
- package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
- package/dist/build.d.ts +34 -4
- package/dist/cli.mjs +20 -16
- package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
- package/dist/deploy.d.ts +9 -0
- package/dist/{dev-Du8pCWFq.mjs → dev-ChsrNHpK.mjs} +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
- package/dist/init-W-4k-lCF.mjs +559 -0
- package/dist/init.d.ts +43 -3
- package/dist/scaffold/CLAUDE.md +51 -64
- package/dist/scaffold/package.json +6 -6
- package/dist/scaffold/vite.config.ts +29 -1
- package/dist/{studio-It7SRfUN.mjs → studio-DEAJGBXa.mjs} +19 -9
- package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
- package/dist/templates/applicant-screening-agent/agent.ts +28 -0
- package/dist/templates/applicant-screening-agent/shared.ts +11 -11
- package/dist/templates/call-audit-workflow/agent.ts +2 -0
- package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
- package/dist/templates/code-interpreter-agent/agent.ts +1 -0
- package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
- package/dist/templates/coding-agent/agent.test.ts +109 -0
- package/dist/templates/coding-agent/agent.ts +45 -0
- package/dist/templates/coding-agent/chat.ts +63 -0
- package/dist/templates/coding-agent/shared.ts +46 -0
- package/dist/templates/coding-agent/system-prompt.md +32 -0
- package/dist/templates/coding-agent/tools/bash.ts +6 -0
- package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
- package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
- package/dist/templates/coding-agent/tools/glob.ts +6 -0
- package/dist/templates/coding-agent/tools/grep.ts +6 -0
- package/dist/templates/coding-agent/tools/list_files.ts +6 -0
- package/dist/templates/coding-agent/tools/read_file.ts +6 -0
- package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
- package/dist/templates/coding-agent/tools/write_file.ts +6 -0
- package/dist/templates/custom-pipeline-agent/agent.ts +1 -0
- package/dist/templates/document-redline-workflow/agent.ts +2 -0
- package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
- package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
- package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
- package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
- package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +8 -1
- package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
- package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
- package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
- package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
- package/dist/templates/executive-inbox-agent/agent.ts +1 -0
- package/dist/templates/executive-inbox-agent/meeting.ts +1 -1
- package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
- package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
- package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
- package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
- package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
- package/dist/templates/hotel-reception-agent/agent.test.ts +2 -1
- package/dist/templates/hotel-reception-agent/agent.ts +6 -3
- package/dist/templates/hotel-reception-agent/client.tsx +14 -2
- package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
- package/dist/templates/hotel-reception-agent/desk-seams.test.ts +2 -1
- package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
- package/dist/templates/hotel-reception-agent/events.ts +2 -1
- package/dist/templates/hotel-reception-agent/session.ts +56 -0
- package/dist/templates/hotel-reception-agent/shared.ts +20 -21
- package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
- package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
- package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
- package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
- package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
- package/dist/templates/link-digest-workflow/agent.ts +5 -0
- package/dist/templates/medication-safety-agent/agent.test.ts +54 -0
- package/dist/templates/medication-safety-agent/agent.ts +48 -1
- package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
- package/dist/templates/meeting-recap-agent/agent.ts +4 -0
- package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
- package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
- package/dist/templates/quickstart-agent/agent.eval.test.ts +39 -3
- package/dist/templates/quickstart-agent/agent.test.ts +22 -0
- package/dist/templates/quickstart-agent/agent.ts +18 -2
- package/dist/templates/quickstart-agent/system-prompt.md +8 -0
- package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
- package/dist/templates/research-handoff-agent/agent.ts +4 -0
- package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
- package/dist/templates/research-planner-agent/agent.ts +3 -0
- package/dist/templates/research-planner-agent/system-prompt.md +1 -1
- package/dist/templates/retail-orders-agent/agent.ts +32 -3
- package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
- package/dist/templates/retail-orders-agent/resolve.ts +18 -3
- package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +37 -5
- package/dist/templates/roadside-assistance-agent/agent.test.ts +38 -6
- package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
- package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
- package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
- package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
- package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
- package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
- package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
- package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
- package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
- package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
- package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
- package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
- package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
- package/dist/templates/technical-support-agent/agent.test.ts +3 -3
- package/dist/templates/technical-support-agent/agent.ts +5 -1
- package/dist/templates/technical-support-agent/knowledge.ts +165 -0
- package/dist/templates/technical-support-agent/nodes.ts +3 -2
- package/dist/templates/technical-support-agent/procedure.ts +4 -3
- package/dist/templates/technical-support-agent/shared.ts +10 -146
- package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
- package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
- package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
- package/dist/templates/text-adventure-agent/agent.ts +30 -1
- package/dist/templates/text-adventure-agent/shared.ts +37 -0
- package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
- package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
- package/dist/templates/topic-briefing-agent/agent.test.ts +23 -11
- package/dist/templates/topic-briefing-agent/agent.ts +4 -1
- package/dist/templates/topic-briefing-agent/shared.ts +10 -10
- package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
- package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
- package/dist/templates/transcription-workflow/agent.ts +3 -0
- package/dist/templates/travel-concierge-agent/agent.ts +4 -0
- package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
- package/dist/templates/web-research-agent/agent.test.ts +16 -0
- package/dist/templates/web-research-agent/agent.ts +30 -0
- package/dist/templates/web-research-agent/system-prompt.md +8 -2
- package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
- package/dist/templates/word-game-agent/agent.ts +20 -0
- package/dist/test-CjKPQ9_B.mjs +102 -0
- package/dist/test.d.ts +37 -12
- package/package.json +5 -5
- package/dist/_init-Bp1CjRrU.mjs +0 -199
- package/dist/_preflight-CcAR577V.mjs +0 -46
- package/dist/init-CY4NAXAA.mjs +0 -183
- package/dist/test-PHHv0Vj6.mjs +0 -83
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as
|
|
2
|
+
import { _ as DENO_CONFIG_FILE, a as resolveDeploySteps, b as DENO_ENTRY_SOURCE, c as VERCEL_FUNCTION_DIR, d as vercelFunctionConfigSource, f as modalAppSource, g as MODAL_OUTPUT_DIR, h as MODAL_ENTRY_SOURCE, i as resolveBuildTarget, l as VERCEL_OUTPUT_DIR, m as MODAL_ENTRY_FILE, n as SECRET_NAME_PLACEHOLDER, o as VERCEL_BUILD_CONFIG_SOURCE, p as MODAL_APP_FILE, r as TARGET_OUTPUTS, s as VERCEL_ENTRY_SOURCE, u as VERCEL_STATIC_DIR, v as DENO_CONFIG_SOURCE, x as DENO_OUTPUT_DIR, y as DENO_ENTRY_FILE } from "./_build-target-C08aM-Es.mjs";
|
|
3
3
|
import { a as ok, t as CliError } from "./_output-DBP9Op_d.mjs";
|
|
4
4
|
import { n as log, r as notify } from "./_ui-DCt4qZrk.mjs";
|
|
5
5
|
import { n as withPreservedNodeEnv } from "./_vite-env-kejF0p2L.mjs";
|
|
6
6
|
import { n as WORKER_ARTIFACT_REL, t as CLIENT_ARTIFACT_REL } from "./_artifacts-BJOYGQPp.mjs";
|
|
7
7
|
import { r as declaredEnvNames, t as DEPLOY_ENV_DECLARATION_FILE } from "./_server-common-DAcv1nC5.mjs";
|
|
8
|
-
import { r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-DM0d0M7m.mjs";
|
|
8
|
+
import { i as evalWorkerConfig, r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-DM0d0M7m.mjs";
|
|
9
9
|
import { assertTypechecks } from "./_typecheck-gate-U3jcil8L.mjs";
|
|
10
|
-
import { n as classifyVitestError, r as runVitest } from "./_vitest-runner-
|
|
10
|
+
import { n as classifyVitestError, r as runVitest } from "./_vitest-runner-CZNGj0ZC.mjs";
|
|
11
11
|
import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-CLxFQ5ox.mjs";
|
|
12
|
-
import { TEST_FILES } from "./test-
|
|
12
|
+
import { TEST_FILES } from "./test-CjKPQ9_B.mjs";
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import fs from "node:fs/promises";
|
|
15
15
|
import { invariant } from "@alexkroman1/aai/internal";
|
|
@@ -36,11 +36,77 @@ import { DEFAULT_SYSTEM_PROMPT } from "@alexkroman1/aai";
|
|
|
36
36
|
* A bundle removes the question. The host resolves nothing, installs nothing,
|
|
37
37
|
* and what runs is what the project's own lockfile pinned.
|
|
38
38
|
*
|
|
39
|
+
* ...as long as the bundle really has nothing left to resolve, which is what
|
|
40
|
+
* {@link JSDOC_FREE_COMMENTS} is about — a bundle can carry a dependency it
|
|
41
|
+
* never imports.
|
|
42
|
+
*
|
|
39
43
|
* The entry is written INTO the project rather than a temp directory, because
|
|
40
44
|
* that is what makes `@alexkroman1/aai-cli/start` resolve against the user's
|
|
41
45
|
* install. Removed in a `finally`: a build that throws must not leave a file
|
|
42
46
|
* that looks authored.
|
|
43
47
|
*/
|
|
48
|
+
/**
|
|
49
|
+
* Drop JSDoc from the bundle, and KEEP the other two comment classes.
|
|
50
|
+
*
|
|
51
|
+
* ## A commented `import()` is a real dependency
|
|
52
|
+
*
|
|
53
|
+
* A JSDoc `@type {import(<specifier>).Webidl}` is a comment to every runtime
|
|
54
|
+
* that executes this file and an EDGE in the module graph to every tool that
|
|
55
|
+
* walks it. Deno resolves the specifier out of a JSDoc type position, so a
|
|
56
|
+
* bundle full of third-party JSDoc arrives at Deno Deploy carrying dependencies
|
|
57
|
+
* that were never bundled because nothing imports them.
|
|
58
|
+
*
|
|
59
|
+
* **Every specifier below is written with a `<placeholder>` rather than
|
|
60
|
+
* quoted**, and that is this bug rather than pedantry: spelling them the real
|
|
61
|
+
* way made `pnpm check:knip` fail on THIS file, reporting `selderee` as an
|
|
62
|
+
* unlisted dependency and undici's relative path as an unresolved import — a
|
|
63
|
+
* comment describing the defect reproducing it, in a second graph-walking tool.
|
|
64
|
+
* Keep the placeholders.
|
|
65
|
+
*
|
|
66
|
+
* **Deno Deploy TOLERATES them today, and that is not a reason to ship them.**
|
|
67
|
+
* Measured, because the first version of this comment guessed otherwise and was
|
|
68
|
+
* wrong: a `quickstart-agent` emit carrying all the JSDoc below deployed and
|
|
69
|
+
* served a full voice session, so nothing here is load-bearing for that host.
|
|
70
|
+
* What the phantom edges cost is the property `app.py` states in its own header
|
|
71
|
+
* — "a bundle with no imports left to resolve" — which was false: `deno info`
|
|
72
|
+
* on the emitted entry reported NINE unresolvable specifiers, and after this
|
|
73
|
+
* setting reports zero. Any tool that walks the graph rather than executing it
|
|
74
|
+
* sees them (`deno info`, `deno check`, `@vercel/nft`), and a host that starts
|
|
75
|
+
* enforcing what Deploy currently ignores would present as a build failure with
|
|
76
|
+
* no line of ours in it.
|
|
77
|
+
*
|
|
78
|
+
* Nine phantom specifiers in that bundle, from THREE sources, which is why
|
|
79
|
+
* this is a bundler setting rather than nine fixes:
|
|
80
|
+
* - undici's JSDoc — `../api/api-request`, `../dispatcher/client`,
|
|
81
|
+
* `../core/request`, `types/dispatcher`, `types/client`, `types/webidl`
|
|
82
|
+
* - html-to-text's — a `@param` naming the `selderee` package, which IS in the
|
|
83
|
+
* bundle, so the bare specifier resolves nowhere from inside it
|
|
84
|
+
* - **our own SDK's** — an `{@link import(<step-generate-json>)}` in the
|
|
85
|
+
* workflow docs' prose, the half no dependency bump would ever fix
|
|
86
|
+
*
|
|
87
|
+
* ## Why not `comments: false`
|
|
88
|
+
*
|
|
89
|
+
* `annotation` carries `@__PURE__` and `@__NO_SIDE_EFFECTS__`: those are
|
|
90
|
+
* instructions to the tree-shaker, and dropping them changes what the bundle
|
|
91
|
+
* DOES, not just how it reads. `legal` carries `@license` and `@preserve` from
|
|
92
|
+
* every third-party package in here — stripping those wholesale is a licensing
|
|
93
|
+
* decision and not one a deploy target gets to make quietly. `jsdoc` is the
|
|
94
|
+
* only class that can name a module, so it is the only one that goes.
|
|
95
|
+
*
|
|
96
|
+
* Applied to EVERY target rather than to Deno alone, on this module's own
|
|
97
|
+
* thesis: what a host does with the graph "differs in ways that are all bad",
|
|
98
|
+
* and a phantom edge is a hazard to any host that walks one — `@vercel/nft`
|
|
99
|
+
* traces imports too. One bundler, one behaviour.
|
|
100
|
+
*
|
|
101
|
+
* @see https://docs.deno.com/runtime/reference/cli/info — `deno info` resolves
|
|
102
|
+
* the graph instead of executing it, which is why it is the gate and why
|
|
103
|
+
* booting the emitted directory is not.
|
|
104
|
+
*/
|
|
105
|
+
const JSDOC_FREE_COMMENTS = {
|
|
106
|
+
legal: true,
|
|
107
|
+
annotation: true,
|
|
108
|
+
jsdoc: false
|
|
109
|
+
};
|
|
44
110
|
/** Bundle `source` as if it were a module in `cwd`, and answer the code. */
|
|
45
111
|
async function bundleTargetEntry(cwd, source, name) {
|
|
46
112
|
const entryPath = path.join(cwd, ".aai", `${name}-entry.mjs`);
|
|
@@ -65,7 +131,8 @@ async function bundleTargetEntry(cwd, source, name) {
|
|
|
65
131
|
write: false,
|
|
66
132
|
rollupOptions: { output: {
|
|
67
133
|
entryFileNames: "[name].mjs",
|
|
68
|
-
codeSplitting: false
|
|
134
|
+
codeSplitting: false,
|
|
135
|
+
comments: JSDOC_FREE_COMMENTS
|
|
69
136
|
} }
|
|
70
137
|
}
|
|
71
138
|
}));
|
|
@@ -179,281 +246,6 @@ async function emitDenoOutput(cwd, options = {}) {
|
|
|
179
246
|
await fs.writeFile(path.join(outputDir, DENO_CONFIG_FILE), DENO_CONFIG_SOURCE, "utf-8");
|
|
180
247
|
}
|
|
181
248
|
//#endregion
|
|
182
|
-
//#region src/_modal-app.ts
|
|
183
|
-
/**
|
|
184
|
-
* The Modal app definition `aai build --target modal` emits — `app.py`.
|
|
185
|
-
*
|
|
186
|
-
* ## Why this target is a generated PYTHON file
|
|
187
|
-
*
|
|
188
|
-
* Every other target emits the host's expected entry shape and lets the host
|
|
189
|
-
* hold the rest: Vercel reads a routing table it already understands, Deno
|
|
190
|
-
* Deploy takes a directory and an entrypoint. Modal has no such descriptor.
|
|
191
|
-
* Its deploy unit is a Python module — `modal.App`, an image recipe, and a
|
|
192
|
-
* decorated function — and `modal deploy` runs that module rather than reading
|
|
193
|
-
* a manifest out of it. So the "preset" for Modal is the module itself, which
|
|
194
|
-
* is why this is the one target whose emit generates code in another language.
|
|
195
|
-
*
|
|
196
|
-
* ## The knobs are DEPLOY-TIME ENV, not edits to this file
|
|
197
|
-
*
|
|
198
|
-
* The awkward consequence is that Modal's policy — how many containers, how
|
|
199
|
-
* much CPU, which secret — lives in Python arguments rather than in a platform
|
|
200
|
-
* dashboard. A generated file carrying policy is a file people edit, and this
|
|
201
|
-
* one is overwritten by the next `aai build`, so "do not edit" would be a lie
|
|
202
|
-
* the first time somebody wanted a warm container.
|
|
203
|
-
*
|
|
204
|
-
* Four knobs are therefore read from the environment at deploy time
|
|
205
|
-
* ({@link MODAL_ENV_KNOBS}), which keeps the project committing nothing
|
|
206
|
-
* host-specific — the property `_build-target.ts` opens by defending:
|
|
207
|
-
*
|
|
208
|
-
* ```sh
|
|
209
|
-
* AAI_MODAL_MIN_CONTAINERS=1 modal deploy .aai/modal/app.py
|
|
210
|
-
* ```
|
|
211
|
-
*
|
|
212
|
-
* The rest — cpu, memory, timeout, concurrency — stays a documented constant
|
|
213
|
-
* in the emitted file. Those are the numbers a reader needs to SEE to trust
|
|
214
|
-
* the deployment, and regenerating restates the default, which is the same
|
|
215
|
-
* contract every other generated artifact here has.
|
|
216
|
-
*/
|
|
217
|
-
/**
|
|
218
|
-
* The Node major the emitted image may not go below — the SDK's own `engines`
|
|
219
|
-
* floor.
|
|
220
|
-
*
|
|
221
|
-
* The tag otherwise tracks the Node running the build, so the bundle runs on
|
|
222
|
-
* the runtime it was bundled for. Modal pulls any tag that exists on Docker
|
|
223
|
-
* Hub, so there is nothing to clamp from ABOVE — unlike `vercelNodeRuntime`,
|
|
224
|
-
* whose platform publishes a fixed list. The floor is the half that matters:
|
|
225
|
-
* npm does not enforce `engines` by default, so a build on Node 22 would
|
|
226
|
-
* otherwise emit a `node:22-slim` image in which the SDK genuinely does not
|
|
227
|
-
* run, and the failure would arrive as a crash-looping container.
|
|
228
|
-
*/
|
|
229
|
-
const MODAL_NODE_MAJOR_FLOOR = 24;
|
|
230
|
-
/**
|
|
231
|
-
* The Python `add_python` layers beside Node.
|
|
232
|
-
*
|
|
233
|
-
* Matches `scripts/modal_image.py`, which is the same arrangement one layer up:
|
|
234
|
-
* the container entrypoint is Modal's own Python runtime, and it spawns node.
|
|
235
|
-
*/
|
|
236
|
-
const MODAL_ADD_PYTHON = "3.13";
|
|
237
|
-
/** What a name sanitizes to when nothing usable survives — see {@link modalAppName}. */
|
|
238
|
-
const MODAL_FALLBACK_APP_NAME = "aai-agent";
|
|
239
|
-
/**
|
|
240
|
-
* Modal caps a resource name at 64 characters. Truncated rather than refused:
|
|
241
|
-
* the name is cosmetic (it appears in the app's URL), and failing a build over
|
|
242
|
-
* a long agent name would be the target's first impression.
|
|
243
|
-
*/
|
|
244
|
-
const MODAL_NAME_MAX = 64;
|
|
245
|
-
/**
|
|
246
|
-
* An agent name as a Modal app name.
|
|
247
|
-
*
|
|
248
|
-
* Modal accepts a narrow character set here and the name reaches a hostname —
|
|
249
|
-
* a deployed function is served at `<workspace>--<app>-<function>.modal.run` —
|
|
250
|
-
* so anything outside `[a-z0-9-]` becomes a dash rather than being passed
|
|
251
|
-
* through and rejected by the platform. Agent names are free text
|
|
252
|
-
* (`define({ name: "Retail Support Bot" })`), which is why this is a mapping
|
|
253
|
-
* and not a validation.
|
|
254
|
-
*
|
|
255
|
-
* Collapsed and trimmed, because `--` is what a hostname reader sees as the
|
|
256
|
-
* workspace separator, and a leading or trailing dash is not a legal label.
|
|
257
|
-
*/
|
|
258
|
-
function modalAppName(agentName) {
|
|
259
|
-
const slug = agentName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, MODAL_NAME_MAX).replace(/-+$/g, "");
|
|
260
|
-
return slug === "" ? MODAL_FALLBACK_APP_NAME : slug;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* The Modal Secret the deployment reads its env from.
|
|
264
|
-
*
|
|
265
|
-
* `-env` rather than the app name alone: the secret holds exactly what
|
|
266
|
-
* `.env.example` declares, and a name that says so makes
|
|
267
|
-
* `modal secret create <name> …` self-explaining. Derived rather than
|
|
268
|
-
* configured, so the emitted file and the command in its docstring cannot name
|
|
269
|
-
* two different secrets.
|
|
270
|
-
*/
|
|
271
|
-
function modalSecretName(appName) {
|
|
272
|
-
return `${appName}-env`.slice(0, MODAL_NAME_MAX);
|
|
273
|
-
}
|
|
274
|
-
/** `node:<major>-slim` for the Node running this build, floored at the SDK's minimum. */
|
|
275
|
-
function modalNodeImageTag(version = process.versions.node) {
|
|
276
|
-
const major = Number.parseInt(version.split(".")[0] ?? "", 10);
|
|
277
|
-
return `node:${Number.isNaN(major) || major < MODAL_NODE_MAJOR_FLOOR ? MODAL_NODE_MAJOR_FLOOR : major}-slim`;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Render `app.py` for this agent.
|
|
281
|
-
*
|
|
282
|
-
* Every number the platform needs appears ONCE and is interpolated, so the
|
|
283
|
-
* emitted file cannot disagree with itself or with the entry beside it — see
|
|
284
|
-
* {@link MODAL_PORT} for the failure that motivates it.
|
|
285
|
-
*/
|
|
286
|
-
function modalAppSource(options) {
|
|
287
|
-
const app = modalAppName(options.name);
|
|
288
|
-
const secret = modalSecretName(app);
|
|
289
|
-
const image = options.nodeImage ?? modalNodeImageTag();
|
|
290
|
-
return `# Generated by \`aai build --target modal\` — do not edit, and do not commit.
|
|
291
|
-
"""Deploys this agent to Modal.
|
|
292
|
-
|
|
293
|
-
modal secret create ${secret} ASSEMBLYAI_API_KEY=... # once
|
|
294
|
-
modal deploy .aai/modal/${MODAL_APP_FILE}
|
|
295
|
-
|
|
296
|
-
Everything this serves is in THIS directory. \`${MODAL_ENTRY_FILE}\` is a bundle
|
|
297
|
-
with no imports left to resolve, so the image installs nothing, carries no
|
|
298
|
-
lockfile and needs no node_modules.
|
|
299
|
-
|
|
300
|
-
Policy is read from the environment at DEPLOY time rather than edited here,
|
|
301
|
-
because \`aai build --target modal\` overwrites this file:
|
|
302
|
-
|
|
303
|
-
AAI_MODAL_APP app name (default: ${app})
|
|
304
|
-
AAI_MODAL_SECRET secret holding the agent env (default: ${secret})
|
|
305
|
-
AAI_MODAL_MIN_CONTAINERS warm floor (default: 0, i.e. scales to zero)
|
|
306
|
-
AAI_MODAL_MAX_CONTAINERS autoscaler ceiling (default: 10)
|
|
307
|
-
"""
|
|
308
|
-
|
|
309
|
-
import atexit
|
|
310
|
-
import contextlib
|
|
311
|
-
import os
|
|
312
|
-
import signal
|
|
313
|
-
import subprocess
|
|
314
|
-
from pathlib import Path
|
|
315
|
-
|
|
316
|
-
import modal
|
|
317
|
-
|
|
318
|
-
# This file's OWN directory, never the shell's. \`modal deploy\` resolves a
|
|
319
|
-
# relative local path against the directory it was invoked FROM, so an
|
|
320
|
-
# \`add_local_dir(".")\` here would upload the project root or nothing at all,
|
|
321
|
-
# depending on where the deploy was run.
|
|
322
|
-
HERE = Path(__file__).parent
|
|
323
|
-
|
|
324
|
-
# Bound to \`@modal.web_server\` and baked into the image env from this one
|
|
325
|
-
# place. The proxy routes to the port it is told about, and a node process
|
|
326
|
-
# reading a different number listens where nothing is routed — a deployment
|
|
327
|
-
# that builds, starts, reports healthy and answers no request.
|
|
328
|
-
PORT = ${MODAL_PORT}
|
|
329
|
-
|
|
330
|
-
# The node server, spawned by \`server()\` below.
|
|
331
|
-
ENTRY = "${MODAL_ENTRY_FILE}"
|
|
332
|
-
|
|
333
|
-
APP_NAME = os.environ.get("AAI_MODAL_APP", "${app}")
|
|
334
|
-
SECRET_NAME = os.environ.get("AAI_MODAL_SECRET", "${secret}")
|
|
335
|
-
MIN_CONTAINERS = int(os.environ.get("AAI_MODAL_MIN_CONTAINERS", "0"))
|
|
336
|
-
MAX_CONTAINERS = int(os.environ.get("AAI_MODAL_MAX_CONTAINERS", "10"))
|
|
337
|
-
|
|
338
|
-
# How long a container stop waits for node to close its sessions before the
|
|
339
|
-
# force-kill. Modal's own SIGKILL backstop still bounds the real grace period,
|
|
340
|
-
# so this is headroom rather than a budget the shutdown spends.
|
|
341
|
-
NODE_STOP_TIMEOUT_SECS = 30
|
|
342
|
-
|
|
343
|
-
image = (
|
|
344
|
-
# \`add_python\` layers Modal's own Python beside Node: the container
|
|
345
|
-
# entrypoint is that Python runtime, and it spawns node. The Node major
|
|
346
|
-
# tracks the one this was BUILT with, so the bundle runs on the runtime it
|
|
347
|
-
# was bundled for.
|
|
348
|
-
modal.Image.from_registry("${image}", add_python="${MODAL_ADD_PYTHON}")
|
|
349
|
-
.env({"NODE_ENV": "production", "PORT": str(PORT)})
|
|
350
|
-
# \`copy=True\` puts these files in an image LAYER. The default mounts them
|
|
351
|
-
# at container start instead, which re-uploads the browser client on every
|
|
352
|
-
# cold start and makes the boot slower the larger the UI gets.
|
|
353
|
-
.add_local_dir(
|
|
354
|
-
HERE,
|
|
355
|
-
remote_path="/app",
|
|
356
|
-
copy=True,
|
|
357
|
-
ignore=["${MODAL_APP_FILE}", "__pycache__"],
|
|
358
|
-
)
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
app = modal.App(APP_NAME)
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
def _run_node(entry: str, env: dict[str, str]) -> subprocess.Popen:
|
|
365
|
-
"""Spawn the node server and hand container stop signals to it.
|
|
366
|
-
|
|
367
|
-
Modal stops a container by signalling THIS Python process, and a child
|
|
368
|
-
spawned with a bare Popen receives nothing of its own — so the node
|
|
369
|
-
server's SIGTERM handler, the thing that closes live voice sessions, would
|
|
370
|
-
never run on a scale-in or a redeploy. Every call in progress would just
|
|
371
|
-
lose its socket.
|
|
372
|
-
|
|
373
|
-
Two hooks, because neither alone is reliable: \`signal.signal\` only works on
|
|
374
|
-
the main thread and Modal may call this off it, while the atexit fallback
|
|
375
|
-
catches the runtime handling the signal itself and exiting normally. Both
|
|
376
|
-
funnel into one memoized stop(), and the node handler is idempotent, so
|
|
377
|
-
double delivery is harmless.
|
|
378
|
-
"""
|
|
379
|
-
proc = subprocess.Popen(["node", entry], cwd="/app", env=env)
|
|
380
|
-
stopped = False
|
|
381
|
-
|
|
382
|
-
def stop() -> None:
|
|
383
|
-
nonlocal stopped
|
|
384
|
-
if stopped or proc.poll() is not None:
|
|
385
|
-
return
|
|
386
|
-
stopped = True
|
|
387
|
-
with contextlib.suppress(ProcessLookupError):
|
|
388
|
-
proc.send_signal(signal.SIGTERM)
|
|
389
|
-
with contextlib.suppress(subprocess.TimeoutExpired):
|
|
390
|
-
proc.wait(timeout=NODE_STOP_TIMEOUT_SECS)
|
|
391
|
-
if proc.poll() is None:
|
|
392
|
-
proc.kill()
|
|
393
|
-
|
|
394
|
-
def forward(signum: int) -> None:
|
|
395
|
-
previous = signal.getsignal(signum)
|
|
396
|
-
|
|
397
|
-
def handler(sig: int, frame: object) -> None:
|
|
398
|
-
stop()
|
|
399
|
-
if callable(previous):
|
|
400
|
-
previous(sig, frame)
|
|
401
|
-
elif previous == signal.SIG_DFL:
|
|
402
|
-
# Re-deliver with the default disposition so this runtime still
|
|
403
|
-
# dies the way the platform expects.
|
|
404
|
-
signal.signal(sig, signal.SIG_DFL)
|
|
405
|
-
os.kill(os.getpid(), sig)
|
|
406
|
-
|
|
407
|
-
signal.signal(signum, handler)
|
|
408
|
-
|
|
409
|
-
for signum in (signal.SIGTERM, signal.SIGINT):
|
|
410
|
-
with contextlib.suppress(ValueError): # not the main thread
|
|
411
|
-
forward(signum)
|
|
412
|
-
|
|
413
|
-
atexit.register(stop)
|
|
414
|
-
return proc
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
@app.function(
|
|
418
|
-
image=image,
|
|
419
|
-
# Values live in a Modal Secret; the \`.env.example\` beside this file
|
|
420
|
-
# DECLARES which names reach \`ctx.env\`. Deploy FAILS when the secret does
|
|
421
|
-
# not exist, which is the right time to hear about it — the alternative is
|
|
422
|
-
# a container that starts and has no provider credential.
|
|
423
|
-
secrets=[modal.Secret.from_name(SECRET_NAME)],
|
|
424
|
-
# An audio pipeline is not a burstable workload: STT framing, the LLM turn
|
|
425
|
-
# and TTS playback all run in this process.
|
|
426
|
-
cpu=1,
|
|
427
|
-
memory=1024,
|
|
428
|
-
min_containers=MIN_CONTAINERS,
|
|
429
|
-
max_containers=MAX_CONTAINERS,
|
|
430
|
-
# Hold a container after the last call rather than paying a cold start on
|
|
431
|
-
# the next one.
|
|
432
|
-
scaledown_window=300,
|
|
433
|
-
# Bounds ONE input, and a WebSocket is one input for as long as the call
|
|
434
|
-
# lasts — so this is the longest single call this deployment will carry.
|
|
435
|
-
timeout=3600,
|
|
436
|
-
)
|
|
437
|
-
# Without this a container serves ONE input at a time, and a voice call holds
|
|
438
|
-
# its input until the caller hangs up: the second caller would wait out the
|
|
439
|
-
# first, and every asset request for the browser client would queue behind
|
|
440
|
-
# whichever call is in progress. \`target_inputs\` is the scale-out set point,
|
|
441
|
-
# under the cap, so a container is joined by another before it saturates.
|
|
442
|
-
@modal.concurrent(max_inputs=50, target_inputs=25)
|
|
443
|
-
@modal.web_server(port=PORT, startup_timeout=180)
|
|
444
|
-
def server() -> None:
|
|
445
|
-
env = os.environ.copy()
|
|
446
|
-
# Modal points this at an in-container Unix socket serving its own Python
|
|
447
|
-
# task runtime. The \`modal\` JS SDK prefers that variable over the public
|
|
448
|
-
# endpoint, so anything in node that talks to Modal would dial a socket
|
|
449
|
-
# that does not answer it.
|
|
450
|
-
env.pop("MODAL_SERVER_URL", None)
|
|
451
|
-
# _run_node, not a bare Popen, so the container's stop signal reaches node
|
|
452
|
-
# and live sessions are closed rather than dropped.
|
|
453
|
-
_run_node(ENTRY, env)
|
|
454
|
-
`;
|
|
455
|
-
}
|
|
456
|
-
//#endregion
|
|
457
249
|
//#region src/_modal-output.ts
|
|
458
250
|
/**
|
|
459
251
|
* Assemble a self-contained Modal deployment directory — `.aai/modal/`.
|
|
@@ -595,17 +387,18 @@ const FRAMEWORK_DEFAULT_PROMPT_SOURCE = "the framework default (DEFAULT_SYSTEM_P
|
|
|
595
387
|
* is what an agent with no file legitimately looks like. So this is a report
|
|
596
388
|
* rather than a check.
|
|
597
389
|
*
|
|
598
|
-
* Decided by comparing VALUES against the built agent's
|
|
390
|
+
* Decided by comparing VALUES against the built agent's declared prompt, which
|
|
599
391
|
* is the same method `withSystemPrompt` uses and for the same reason — the
|
|
600
392
|
* alternative asks the bundler's module graph a question, and the author may
|
|
601
393
|
* have imported the file and composed it, which is neither "the file" nor
|
|
602
394
|
* "agent.ts" alone.
|
|
603
395
|
*/
|
|
604
|
-
async function systemPromptSource(cwd,
|
|
605
|
-
if (
|
|
396
|
+
async function systemPromptSource(cwd, declared) {
|
|
397
|
+
if (typeof declared !== "string") return "agent.ts (a per-request resolver)";
|
|
398
|
+
if (declared === DEFAULT_SYSTEM_PROMPT) return FRAMEWORK_DEFAULT_PROMPT_SOURCE;
|
|
606
399
|
const trimmed = (await fs.readFile(path.join(cwd, SYSTEM_PROMPT_FILE), "utf-8").catch(() => void 0))?.trim();
|
|
607
|
-
if (trimmed === void 0 || trimmed === "" || !
|
|
608
|
-
return
|
|
400
|
+
if (trimmed === void 0 || trimmed === "" || !declared.includes(trimmed)) return "agent.ts";
|
|
401
|
+
return declared.trim() === trimmed ? SYSTEM_PROMPT_FILE : `agent.ts (composing ${SYSTEM_PROMPT_FILE})`;
|
|
609
402
|
}
|
|
610
403
|
/**
|
|
611
404
|
* Map a {@link runVitest} failure to a CliError — distinguishing a real test
|
|
@@ -637,10 +430,22 @@ async function executeBuild(opts) {
|
|
|
637
430
|
await fs.writeFile(worker, bundle.worker, "utf-8");
|
|
638
431
|
await emitTargetFiles(cwd, target, { name: agentDef.name });
|
|
639
432
|
const output = TARGET_OUTPUTS[target];
|
|
640
|
-
const
|
|
641
|
-
|
|
433
|
+
const deployConfig = output.dir === void 0 ? void 0 : await evalWorkerConfig(bundle.worker);
|
|
434
|
+
const missingEnv = await missingDeployEnv(cwd, target, process.env, deployConfig || void 0);
|
|
435
|
+
for (const warning of missingEnvWarnings(missingEnv, target, agentDef.name)) notify("warn", warning);
|
|
642
436
|
if (output.dir !== void 0) log.info(`Target ${target}: wrote ${output.dir}`);
|
|
643
|
-
|
|
437
|
+
const deploy = resolveDeploySteps(target, {
|
|
438
|
+
agentName: agentDef.name,
|
|
439
|
+
missingEnv
|
|
440
|
+
});
|
|
441
|
+
if (deploy.length > 0) {
|
|
442
|
+
log.info("Deploy it with:");
|
|
443
|
+
deploy.filter((step) => step.when !== "build").forEach((step, index) => {
|
|
444
|
+
const note = step.when === "once" ? " (first deploy only)" : "";
|
|
445
|
+
log.info(` ${index + 1}. ${step.run}${note}`);
|
|
446
|
+
});
|
|
447
|
+
log.info(`Re-run \`aai build --target ${target}\` before every deploy.`);
|
|
448
|
+
}
|
|
644
449
|
const systemPrompt = await systemPromptSource(cwd, agentDef.systemPrompt);
|
|
645
450
|
log.info(`System prompt: ${systemPrompt}`);
|
|
646
451
|
log.success("Build complete");
|
|
@@ -651,7 +456,7 @@ async function executeBuild(opts) {
|
|
|
651
456
|
systemPrompt,
|
|
652
457
|
target,
|
|
653
458
|
outputDir: output.dir,
|
|
654
|
-
deploy
|
|
459
|
+
deploy,
|
|
655
460
|
missingEnv
|
|
656
461
|
});
|
|
657
462
|
}
|
|
@@ -693,6 +498,27 @@ async function emitTargetFiles(cwd, target, agent) {
|
|
|
693
498
|
* Which variables the DEPLOYMENT declares that this build's host has no value
|
|
694
499
|
* for — the check behind the warning `aai build` prints for a host target.
|
|
695
500
|
*
|
|
501
|
+
* ## Where the DECLARATIONS come from
|
|
502
|
+
*
|
|
503
|
+
* Two sources, and for a long time only the first: `.env.example`, the one
|
|
504
|
+
* dotenv file that ships, plus — when the caller has the built bundle's
|
|
505
|
+
* normalized config — {@link requiredEnvNames}, i.e. the provider credentials
|
|
506
|
+
* the stt/llm/tts/s2s descriptors imply and the agent's own `requiredEnv`.
|
|
507
|
+
*
|
|
508
|
+
* The example file alone was the wrong half of a pair. `anywhere.md` told
|
|
509
|
+
* authors to "list what your tools read in `requiredEnv`" and promised the
|
|
510
|
+
* build would warn by name about anything the deployment was missing, which was
|
|
511
|
+
* true of the MANAGED path (`_preflight.ts`, which has always derived both) and
|
|
512
|
+
* false here — so an agent declaring `requiredEnv: ["ORDERS_API_KEY"]` and no
|
|
513
|
+
* matching example entry got neither the warning nor the `env add` step the
|
|
514
|
+
* `perSecret` sequence expands from this same list. Both paths now read one
|
|
515
|
+
* derivation.
|
|
516
|
+
*
|
|
517
|
+
* `.env.example` stays a source rather than becoming redundant: it is where a
|
|
518
|
+
* variable that nothing static can see gets declared — one a tool reads
|
|
519
|
+
* straight off `process.env`, or a host setting like `PORT` — and it is what a
|
|
520
|
+
* user editing a deployment's configuration actually reads.
|
|
521
|
+
*
|
|
696
522
|
* ## Why the host environment and not `resolveServerEnv`
|
|
697
523
|
*
|
|
698
524
|
* The obvious implementation resolves {@link DEPLOY_ENV_FILES} the way the
|
|
@@ -725,10 +551,16 @@ async function emitTargetFiles(cwd, target, agent) {
|
|
|
725
551
|
*
|
|
726
552
|
* @param env - Where values are read from. Defaults to the build's own
|
|
727
553
|
* environment; a parameter so a spec need not mutate `process.env`.
|
|
554
|
+
* @param config - The built bundle's `__aaiConfig`, when the caller has it.
|
|
555
|
+
* Omitted, only `.env.example` is read — which is what a spec asserting the
|
|
556
|
+
* file-declaration half wants, and what an older bundle carrying no such
|
|
557
|
+
* export leaves the caller with.
|
|
728
558
|
*/
|
|
729
|
-
async function missingDeployEnv(cwd, target, env = process.env) {
|
|
559
|
+
async function missingDeployEnv(cwd, target, env = process.env, config) {
|
|
730
560
|
if (TARGET_OUTPUTS[target].dir === void 0) return [];
|
|
731
|
-
|
|
561
|
+
const derived = config ? (await import("./_preflight-CnW9QiE7.mjs")).requiredEnvNames(config) : [];
|
|
562
|
+
const declared = await declaredEnvNames(cwd, [DEPLOY_ENV_DECLARATION_FILE]);
|
|
563
|
+
return [.../* @__PURE__ */ new Set([...declared, ...derived])].filter((name) => {
|
|
732
564
|
const value = env[name];
|
|
733
565
|
return value === void 0 || value === "";
|
|
734
566
|
});
|
|
@@ -741,8 +573,11 @@ async function missingDeployEnv(cwd, target, env = process.env) {
|
|
|
741
573
|
* and `determinismWarnings`: each is independently actionable, and the command
|
|
742
574
|
* differs per name.
|
|
743
575
|
*/
|
|
744
|
-
function missingEnvWarnings(missing, target) {
|
|
745
|
-
const
|
|
576
|
+
function missingEnvWarnings(missing, target, agentName) {
|
|
577
|
+
const secret = resolveDeploySteps(target, {
|
|
578
|
+
agentName,
|
|
579
|
+
missingEnv: []
|
|
580
|
+
}).find((step) => step.when === "perSecret")?.run;
|
|
746
581
|
return missing.map((name) => {
|
|
747
582
|
const fix = secret === void 0 ? `Set it in the ${target} environment` : `Set it with \`${secret.replaceAll(SECRET_NAME_PLACEHOLDER, name)}\``;
|
|
748
583
|
return `${name} is declared in ${DEPLOY_ENV_DECLARATION_FILE} but has no value in this build's environment, so the deployed agent will see none. ${fix}, then deploy again.`;
|
package/dist/build.d.ts
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
*
|
|
12
12
|
* `--target` decides what else it emits — see `_build-target.ts`.
|
|
13
13
|
*/
|
|
14
|
-
import { type BuildTarget } from "./_build-target.ts";
|
|
14
|
+
import { type BuildTarget, type DeployStep } from "./_build-target.ts";
|
|
15
15
|
import { type CommandResult } from "./_output.ts";
|
|
16
|
+
import type { PreflightConfig } from "./_preflight.ts";
|
|
16
17
|
/**
|
|
17
18
|
* Where the built worker lands, relative to the project root — under `.aai/`,
|
|
18
19
|
* beside the built client, so one gitignore rule covers every build output.
|
|
@@ -43,9 +44,13 @@ type BuildData = {
|
|
|
43
44
|
* above is: `log` is silenced under `--json`, so a CI job that builds and
|
|
44
45
|
* then deploys could read neither the directory it should upload nor the
|
|
45
46
|
* command that uploads it, and had to restate both from this file.
|
|
47
|
+
*
|
|
48
|
+
* `deploy` is the RESOLVED sequence — see {@link resolveDeploySteps} — so a
|
|
49
|
+
* CI job can execute it in order rather than re-encoding each host's
|
|
50
|
+
* prerequisites. Empty for a target that deploys nowhere.
|
|
46
51
|
*/
|
|
47
52
|
outputDir: string | undefined;
|
|
48
|
-
deploy:
|
|
53
|
+
deploy: DeployStep[];
|
|
49
54
|
/**
|
|
50
55
|
* Variables the deployment DECLARES and this build's host had no value for —
|
|
51
56
|
* see {@link missingDeployEnv}. Empty for a target that deploys nowhere.
|
|
@@ -70,6 +75,27 @@ export declare function executeBuild(opts: {
|
|
|
70
75
|
* Which variables the DEPLOYMENT declares that this build's host has no value
|
|
71
76
|
* for — the check behind the warning `aai build` prints for a host target.
|
|
72
77
|
*
|
|
78
|
+
* ## Where the DECLARATIONS come from
|
|
79
|
+
*
|
|
80
|
+
* Two sources, and for a long time only the first: `.env.example`, the one
|
|
81
|
+
* dotenv file that ships, plus — when the caller has the built bundle's
|
|
82
|
+
* normalized config — {@link requiredEnvNames}, i.e. the provider credentials
|
|
83
|
+
* the stt/llm/tts/s2s descriptors imply and the agent's own `requiredEnv`.
|
|
84
|
+
*
|
|
85
|
+
* The example file alone was the wrong half of a pair. `anywhere.md` told
|
|
86
|
+
* authors to "list what your tools read in `requiredEnv`" and promised the
|
|
87
|
+
* build would warn by name about anything the deployment was missing, which was
|
|
88
|
+
* true of the MANAGED path (`_preflight.ts`, which has always derived both) and
|
|
89
|
+
* false here — so an agent declaring `requiredEnv: ["ORDERS_API_KEY"]` and no
|
|
90
|
+
* matching example entry got neither the warning nor the `env add` step the
|
|
91
|
+
* `perSecret` sequence expands from this same list. Both paths now read one
|
|
92
|
+
* derivation.
|
|
93
|
+
*
|
|
94
|
+
* `.env.example` stays a source rather than becoming redundant: it is where a
|
|
95
|
+
* variable that nothing static can see gets declared — one a tool reads
|
|
96
|
+
* straight off `process.env`, or a host setting like `PORT` — and it is what a
|
|
97
|
+
* user editing a deployment's configuration actually reads.
|
|
98
|
+
*
|
|
73
99
|
* ## Why the host environment and not `resolveServerEnv`
|
|
74
100
|
*
|
|
75
101
|
* The obvious implementation resolves {@link DEPLOY_ENV_FILES} the way the
|
|
@@ -102,8 +128,12 @@ export declare function executeBuild(opts: {
|
|
|
102
128
|
*
|
|
103
129
|
* @param env - Where values are read from. Defaults to the build's own
|
|
104
130
|
* environment; a parameter so a spec need not mutate `process.env`.
|
|
131
|
+
* @param config - The built bundle's `__aaiConfig`, when the caller has it.
|
|
132
|
+
* Omitted, only `.env.example` is read — which is what a spec asserting the
|
|
133
|
+
* file-declaration half wants, and what an older bundle carrying no such
|
|
134
|
+
* export leaves the caller with.
|
|
105
135
|
*/
|
|
106
|
-
export declare function missingDeployEnv(cwd: string, target: BuildTarget, env?: Record<string, string | undefined
|
|
136
|
+
export declare function missingDeployEnv(cwd: string, target: BuildTarget, env?: Record<string, string | undefined>, config?: PreflightConfig): Promise<string[]>;
|
|
107
137
|
/**
|
|
108
138
|
* One warning sentence per variable {@link missingDeployEnv} reported, naming
|
|
109
139
|
* the command that sets it where the target knows one.
|
|
@@ -112,4 +142,4 @@ export declare function missingDeployEnv(cwd: string, target: BuildTarget, env?:
|
|
|
112
142
|
* and `determinismWarnings`: each is independently actionable, and the command
|
|
113
143
|
* differs per name.
|
|
114
144
|
*/
|
|
115
|
-
export declare function missingEnvWarnings(missing: readonly string[], target: BuildTarget): string[];
|
|
145
|
+
export declare function missingEnvWarnings(missing: readonly string[], target: BuildTarget, agentName: string): string[];
|