@alexkroman1/aai-cli 16.1.0 → 18.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.
Files changed (220) hide show
  1. package/README.md +2 -1
  2. package/dist/{_build-target-ClEEuUuW.mjs → _build-target-C08aM-Es.mjs} +504 -43
  3. package/dist/_build-target.d.ts +98 -19
  4. package/dist/_console-audio.d.ts +17 -0
  5. package/dist/_console-session.d.ts +70 -0
  6. package/dist/_deno-target.d.ts +15 -14
  7. package/dist/_dev-env.d.ts +19 -13
  8. package/dist/{_dev-server-D1wKiA0_.mjs → _dev-server-Dtp4aAlo.mjs} +26 -18
  9. package/dist/_dev-server.d.ts +5 -3
  10. package/dist/_init.d.ts +39 -0
  11. package/dist/_modal-target.d.ts +11 -6
  12. package/dist/_preflight-CnW9QiE7.mjs +116 -0
  13. package/dist/_preflight.d.ts +110 -5
  14. package/dist/_target-bundle.d.ts +112 -0
  15. package/dist/_target-entry.d.ts +81 -0
  16. package/dist/_templates-DXadVNsL.mjs +135 -0
  17. package/dist/_templates.d.ts +11 -34
  18. package/dist/{_vitest-runner-BiAMIir1.mjs → _vitest-runner-CZNGj0ZC.mjs} +21 -16
  19. package/dist/_vitest-runner.d.ts +35 -23
  20. package/dist/{build-O6BT51x_.mjs → build-DrQTSc2R.mjs} +128 -293
  21. package/dist/build.d.ts +34 -4
  22. package/dist/cli.mjs +40 -16
  23. package/dist/console-BsyE3DyB.mjs +422 -0
  24. package/dist/console.d.ts +37 -0
  25. package/dist/{deploy-lldQyJVj.mjs → deploy-B68-x7xM.mjs} +12 -4
  26. package/dist/deploy.d.ts +9 -0
  27. package/dist/{dev-Du8pCWFq.mjs → dev-BGWU2zPP.mjs} +1 -1
  28. package/dist/dev.d.ts +1 -1
  29. package/dist/{eval-Ducmkt1n.mjs → eval-DB07kTxO.mjs} +1 -1
  30. package/dist/init-CbOhyNYe.mjs +559 -0
  31. package/dist/init.d.ts +43 -3
  32. package/dist/scaffold/CLAUDE.md +161 -166
  33. package/dist/scaffold/package.json +6 -6
  34. package/dist/scaffold/vite.config.ts +29 -1
  35. package/dist/start.d.ts +3 -3
  36. package/dist/{studio-It7SRfUN.mjs → studio-BRJsw7lr.mjs} +19 -9
  37. package/dist/templates/applicant-screening-agent/agent.eval.test.ts +20 -6
  38. package/dist/templates/applicant-screening-agent/agent.test.ts +17 -13
  39. package/dist/templates/applicant-screening-agent/agent.ts +28 -0
  40. package/dist/templates/applicant-screening-agent/crews.ts +4 -4
  41. package/dist/templates/applicant-screening-agent/shared.ts +11 -11
  42. package/dist/templates/call-audit-workflow/agent.ts +2 -0
  43. package/dist/templates/code-interpreter-agent/agent.eval.test.ts +3 -2
  44. package/dist/templates/code-interpreter-agent/agent.test.ts +2 -2
  45. package/dist/templates/code-interpreter-agent/agent.ts +1 -0
  46. package/dist/templates/coding-agent/agent.eval.test.ts +136 -0
  47. package/dist/templates/coding-agent/agent.test.ts +109 -0
  48. package/dist/templates/coding-agent/agent.ts +45 -0
  49. package/dist/templates/coding-agent/chat.ts +63 -0
  50. package/dist/templates/coding-agent/shared.ts +46 -0
  51. package/dist/templates/coding-agent/system-prompt.md +32 -0
  52. package/dist/templates/coding-agent/tools/bash.ts +6 -0
  53. package/dist/templates/coding-agent/tools/delete_file.ts +6 -0
  54. package/dist/templates/coding-agent/tools/edit_file.ts +6 -0
  55. package/dist/templates/coding-agent/tools/glob.ts +6 -0
  56. package/dist/templates/coding-agent/tools/grep.ts +6 -0
  57. package/dist/templates/coding-agent/tools/list_files.ts +6 -0
  58. package/dist/templates/coding-agent/tools/read_file.ts +6 -0
  59. package/dist/templates/coding-agent/tools/todo_write.ts +6 -0
  60. package/dist/templates/coding-agent/tools/write_file.ts +6 -0
  61. package/dist/templates/custom-pipeline-agent/agent.ts +3 -2
  62. package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
  63. package/dist/templates/custom-pipeline-agent/stages.test.ts +75 -83
  64. package/dist/templates/document-redline-workflow/agent.ts +2 -0
  65. package/dist/templates/emergency-dispatch-agent/agent.eval.test.ts +1 -1
  66. package/dist/templates/emergency-dispatch-agent/agent.test.ts +103 -0
  67. package/dist/templates/emergency-dispatch-agent/agent.ts +15 -0
  68. package/dist/templates/emergency-dispatch-agent/guardrails.ts +105 -0
  69. package/dist/templates/emergency-dispatch-agent/system-prompt.md +1 -0
  70. package/dist/templates/entertainment-picks-agent/agent.eval.test.ts +9 -2
  71. package/dist/templates/entertainment-picks-agent/agent.ts +1 -0
  72. package/dist/templates/entertainment-picks-agent/system-prompt.md +6 -0
  73. package/dist/templates/entertainment-picks-agent/tools/revisit.ts +7 -0
  74. package/dist/templates/executive-inbox-agent/agent.eval.test.ts +84 -23
  75. package/dist/templates/executive-inbox-agent/agent.test.ts +35 -25
  76. package/dist/templates/executive-inbox-agent/agent.ts +1 -0
  77. package/dist/templates/executive-inbox-agent/calendar.test.ts +13 -7
  78. package/dist/templates/executive-inbox-agent/meeting.ts +3 -3
  79. package/dist/templates/executive-inbox-agent/prompts.ts +3 -1
  80. package/dist/templates/executive-inbox-agent/system-prompt.md +3 -3
  81. package/dist/templates/executive-inbox-agent/tools/meeting_assistant.ts +3 -3
  82. package/dist/templates/executive-inbox-agent/tools/open_email.ts +8 -16
  83. package/dist/templates/front-desk-agent/agent.eval.test.ts +174 -0
  84. package/dist/templates/front-desk-agent/agent.test.ts +150 -0
  85. package/dist/templates/front-desk-agent/agent.ts +22 -0
  86. package/dist/templates/front-desk-agent/shared.ts +234 -0
  87. package/dist/templates/front-desk-agent/system-prompt.md +13 -0
  88. package/dist/templates/front-desk-agent/tools/verify_account.ts +41 -0
  89. package/dist/templates/hotel-reception-agent/agent.eval.test.ts +85 -21
  90. package/dist/templates/hotel-reception-agent/agent.test.ts +3 -3
  91. package/dist/templates/hotel-reception-agent/agent.ts +6 -3
  92. package/dist/templates/hotel-reception-agent/client.tsx +14 -2
  93. package/dist/templates/hotel-reception-agent/concierge.ts +2 -1
  94. package/dist/templates/hotel-reception-agent/desk-seams.test.ts +3 -3
  95. package/dist/templates/hotel-reception-agent/disputes.ts +9 -11
  96. package/dist/templates/hotel-reception-agent/events.ts +2 -1
  97. package/dist/templates/hotel-reception-agent/session.ts +56 -0
  98. package/dist/templates/hotel-reception-agent/shared.ts +20 -21
  99. package/dist/templates/hotel-reception-agent/system-prompt.md +1 -1
  100. package/dist/templates/hotel-reception-agent/tools/abandon_booking.ts +2 -1
  101. package/dist/templates/hotel-reception-agent/tools/add_to_waitlist.ts +2 -1
  102. package/dist/templates/hotel-reception-agent/tools/book_airport_car.ts +2 -1
  103. package/dist/templates/hotel-reception-agent/tools/cancel_restaurant_reservation.ts +2 -1
  104. package/dist/templates/hotel-reception-agent/tools/cancel_room_booking.ts +2 -1
  105. package/dist/templates/hotel-reception-agent/tools/check_restaurant_availability.ts +1 -1
  106. package/dist/templates/hotel-reception-agent/tools/check_room_availability.ts +1 -1
  107. package/dist/templates/hotel-reception-agent/tools/choose_room.ts +1 -1
  108. package/dist/templates/hotel-reception-agent/tools/confirm_booking.ts +2 -1
  109. package/dist/templates/hotel-reception-agent/tools/dispatch_emergency.ts +2 -1
  110. package/dist/templates/hotel-reception-agent/tools/dispute_charge.ts +2 -1
  111. package/dist/templates/hotel-reception-agent/tools/flag_late_arrival.ts +2 -1
  112. package/dist/templates/hotel-reception-agent/tools/lookup_booking.ts +2 -1
  113. package/dist/templates/hotel-reception-agent/tools/lookup_guest_history.ts +1 -1
  114. package/dist/templates/hotel-reception-agent/tools/lookup_invoice.ts +2 -1
  115. package/dist/templates/hotel-reception-agent/tools/lookup_restaurant_reservation.ts +1 -1
  116. package/dist/templates/hotel-reception-agent/tools/modify_restaurant_reservation.ts +1 -1
  117. package/dist/templates/hotel-reception-agent/tools/record_card.ts +1 -1
  118. package/dist/templates/hotel-reception-agent/tools/record_followup.ts +2 -1
  119. package/dist/templates/hotel-reception-agent/tools/record_group_inquiry.ts +2 -1
  120. package/dist/templates/hotel-reception-agent/tools/record_guest_details.ts +1 -1
  121. package/dist/templates/hotel-reception-agent/tools/reinstate_booking.ts +1 -1
  122. package/dist/templates/hotel-reception-agent/tools/request_flight_reconfirmation.ts +2 -1
  123. package/dist/templates/hotel-reception-agent/tools/resend_confirmation.ts +2 -1
  124. package/dist/templates/hotel-reception-agent/tools/reserve_table.ts +1 -1
  125. package/dist/templates/hotel-reception-agent/tools/resolve_room_conflict.ts +2 -1
  126. package/dist/templates/hotel-reception-agent/tools/schedule_wakeup_call.ts +2 -1
  127. package/dist/templates/hotel-reception-agent/tools/set_do_not_disturb.ts +2 -1
  128. package/dist/templates/hotel-reception-agent/tools/set_extras.ts +1 -1
  129. package/dist/templates/hotel-reception-agent/tools/set_stay.ts +2 -1
  130. package/dist/templates/hotel-reception-agent/tools/start_booking_modification.ts +2 -1
  131. package/dist/templates/hotel-reception-agent/tools/start_room_booking.ts +2 -1
  132. package/dist/templates/hotel-reception-agent/tools/take_guest_message.ts +2 -1
  133. package/dist/templates/hotel-reception-agent/tools/transfer_call.ts +2 -1
  134. package/dist/templates/hotel-reception-agent/tools/update_card.ts +2 -1
  135. package/dist/templates/hotel-reception-agent/tools/verify_booking.ts +2 -1
  136. package/dist/templates/link-digest-workflow/agent.eval.test.ts +16 -1
  137. package/dist/templates/link-digest-workflow/agent.ts +5 -0
  138. package/dist/templates/medication-safety-agent/agent.test.ts +57 -4
  139. package/dist/templates/medication-safety-agent/agent.ts +48 -1
  140. package/dist/templates/meeting-recap-agent/agent.test.ts +2 -2
  141. package/dist/templates/meeting-recap-agent/agent.ts +4 -0
  142. package/dist/templates/pizza-ordering-agent/agent.eval.test.ts +68 -2
  143. package/dist/templates/pizza-ordering-agent/agent.ts +3 -0
  144. package/dist/templates/podcast-digest-workflow/agent.ts +4 -0
  145. package/dist/templates/push-to-talk-agent/agent.eval.test.ts +74 -0
  146. package/dist/templates/push-to-talk-agent/agent.test.ts +61 -0
  147. package/dist/templates/push-to-talk-agent/agent.ts +22 -0
  148. package/dist/templates/push-to-talk-agent/client.tsx +124 -0
  149. package/dist/templates/push-to-talk-agent/shared.ts +34 -0
  150. package/dist/templates/push-to-talk-agent/system-prompt.md +11 -0
  151. package/dist/templates/push-to-talk-agent/tools/list_notes.ts +15 -0
  152. package/dist/templates/push-to-talk-agent/tools/save_note.ts +26 -0
  153. package/dist/templates/quickstart-agent/agent.eval.test.ts +91 -3
  154. package/dist/templates/quickstart-agent/agent.test.ts +22 -0
  155. package/dist/templates/quickstart-agent/agent.ts +18 -2
  156. package/dist/templates/quickstart-agent/system-prompt.md +8 -0
  157. package/dist/templates/quickstart-agent/tools/get_weather.ts +59 -0
  158. package/dist/templates/research-handoff-agent/agent.eval.test.ts +1 -1
  159. package/dist/templates/research-handoff-agent/agent.test.ts +34 -26
  160. package/dist/templates/research-handoff-agent/agent.ts +4 -0
  161. package/dist/templates/research-planner-agent/agent.eval.test.ts +24 -2
  162. package/dist/templates/research-planner-agent/agent.test.ts +26 -16
  163. package/dist/templates/research-planner-agent/agent.ts +3 -0
  164. package/dist/templates/research-planner-agent/system-prompt.md +1 -1
  165. package/dist/templates/retail-orders-agent/agent.eval.test.ts +1 -1
  166. package/dist/templates/retail-orders-agent/agent.ts +32 -3
  167. package/dist/templates/retail-orders-agent/keyterms.ts +154 -0
  168. package/dist/templates/retail-orders-agent/resolve.ts +18 -3
  169. package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +124 -5
  170. package/dist/templates/roadside-assistance-agent/agent.test.ts +39 -7
  171. package/dist/templates/roadside-assistance-agent/agent.ts +4 -0
  172. package/dist/templates/roadside-assistance-agent/shared.ts +12 -0
  173. package/dist/templates/roadside-assistance-agent/tools/acknowledge_disclosure.ts +14 -0
  174. package/dist/templates/roadside-assistance-agent/tools/lookup_coverage.ts +11 -0
  175. package/dist/templates/roadside-assistance-agent/tools/service_disclosure.ts +17 -11
  176. package/dist/templates/roadside-assistance-agent/yard.test.ts +4 -0
  177. package/dist/templates/spoken-summary-workflow/agent.ts +4 -0
  178. package/dist/templates/tabletop-rpg-agent/agent.eval.test.ts +6 -0
  179. package/dist/templates/tabletop-rpg-agent/agent.test.ts +125 -1
  180. package/dist/templates/tabletop-rpg-agent/agent.ts +30 -1
  181. package/dist/templates/tabletop-rpg-agent/shared.ts +81 -0
  182. package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
  183. package/dist/templates/tabletop-rpg-agent/tools/check_state.ts +16 -7
  184. package/dist/templates/technical-support-agent/agent.test.ts +29 -23
  185. package/dist/templates/technical-support-agent/agent.ts +5 -1
  186. package/dist/templates/technical-support-agent/knowledge.ts +165 -0
  187. package/dist/templates/technical-support-agent/nodes.ts +3 -2
  188. package/dist/templates/technical-support-agent/procedure.ts +7 -6
  189. package/dist/templates/technical-support-agent/shared.ts +10 -146
  190. package/dist/templates/technical-support-agent/tools/list_topics.ts +2 -1
  191. package/dist/templates/text-adventure-agent/agent.eval.test.ts +39 -6
  192. package/dist/templates/text-adventure-agent/agent.test.ts +79 -1
  193. package/dist/templates/text-adventure-agent/agent.ts +30 -1
  194. package/dist/templates/text-adventure-agent/shared.ts +37 -0
  195. package/dist/templates/text-adventure-agent/system-prompt.md +9 -2
  196. package/dist/templates/topic-briefing-agent/agent.eval.test.ts +18 -4
  197. package/dist/templates/topic-briefing-agent/agent.test.ts +61 -36
  198. package/dist/templates/topic-briefing-agent/agent.ts +4 -1
  199. package/dist/templates/topic-briefing-agent/shared.ts +19 -18
  200. package/dist/templates/topic-briefing-agent/system-prompt.md +13 -8
  201. package/dist/templates/topic-briefing-agent/tools/send_briefing.ts +43 -5
  202. package/dist/templates/transcription-workflow/agent.ts +3 -0
  203. package/dist/templates/travel-concierge-agent/agent.eval.test.ts +9 -7
  204. package/dist/templates/travel-concierge-agent/agent.test.ts +1 -2
  205. package/dist/templates/travel-concierge-agent/agent.ts +4 -0
  206. package/dist/templates/web-research-agent/agent.eval.test.ts +31 -5
  207. package/dist/templates/web-research-agent/agent.test.ts +16 -0
  208. package/dist/templates/web-research-agent/agent.ts +30 -0
  209. package/dist/templates/web-research-agent/system-prompt.md +8 -2
  210. package/dist/templates/word-game-agent/agent.eval.test.ts +79 -18
  211. package/dist/templates/word-game-agent/agent.test.ts +3 -1
  212. package/dist/templates/word-game-agent/agent.ts +20 -0
  213. package/dist/test-CjKPQ9_B.mjs +102 -0
  214. package/dist/test.d.ts +37 -12
  215. package/package.json +5 -5
  216. package/dist/_init-Bp1CjRrU.mjs +0 -199
  217. package/dist/_preflight-CcAR577V.mjs +0 -46
  218. package/dist/_templates-CuP74F8D.mjs +0 -291
  219. package/dist/init-CY4NAXAA.mjs +0 -183
  220. package/dist/test-PHHv0Vj6.mjs +0 -83
@@ -55,10 +55,11 @@ export type VitestRunOptions = {
55
55
  /**
56
56
  * Run EVERY non-eval spec in the project rather than the first candidate.
57
57
  *
58
- * The opt-in half of the narrowing documented on {@link unrunSpecFiles}: the
59
- * default stays one file, and this is how a caller says "I want the whole
60
- * suite" without the command having to guess. Still a filter list rather than
61
- * an include glob, so the eval tier stays disjoint by construction.
58
+ * What both gates over a project's own suite pass — `aai test` unless
59
+ * `--only` narrows it, and `aai build`'s pre-build gate — because a verdict
60
+ * over a subset of a project's specs is the false green documented on
61
+ * {@link unrunSpecFiles}. Still a filter LIST rather than an include glob, so
62
+ * the eval tier stays disjoint by construction.
62
63
  */
63
64
  readonly all?: boolean;
64
65
  /**
@@ -67,10 +68,16 @@ export type VitestRunOptions = {
67
68
  * Default TRUE, and the default is the point: the caller most in need of the
68
69
  * notice is the one that does not know it is narrowing. `aai build` runs this
69
70
  * as its pre-build gate and reports nothing of its own, so a build gated on
70
- * one file out of eight said so nowhere. `aai test` and `aai eval` pass
71
- * `false` — the first because it reports the same set itself, in its result
72
- * as well as its output, and the second because "did not run" is a claim
73
- * about the TEST tier and every unit spec in the project would be named
71
+ * one file out of eight said so nowhere — it passes `all` now, but the
72
+ * default is what closed that without the gate having to know.
73
+ *
74
+ * `aai test` takes the default too, and used to pass `false`: it reported the
75
+ * skipped set itself, as an `incomplete_run` FAILURE, which is what made its
76
+ * own default invocation unpassable on any project with a second spec file
77
+ * (see `executeTest`). The widened run is the default there now and has
78
+ * nothing to announce; `--only` is a deliberate narrowing, and this notice is
79
+ * its report. `aai eval` still passes `false`, because "did not run" is a
80
+ * claim about the TEST tier and every unit spec in the project would be named
74
81
  * falsely by an eval run.
75
82
  */
76
83
  readonly announceUnrun?: boolean;
@@ -120,12 +127,15 @@ export declare function projectSpecFiles(cwd: string): string[];
120
127
  * of them, so `aai test` there ran 1 file / 67 tests, printed "Tests passed",
121
128
  * and left 211 of the project's 278 tests unrun with nothing saying so.
122
129
  *
123
- * The narrow default STANDS — which files `aai test` runs is a documented
124
- * contract (the scaffold guide says "Run agent.test.ts via vitest"), and running
125
- * a project's other specs by default could reach ones that are slow or want
126
- * credentials. What does not stand is a GREEN VERDICT over the difference: this
127
- * set is what `executeTest` refuses to call a pass, what it puts in its result
128
- * for a script to read, and what `--all` opts into running.
130
+ * The narrow default did NOT stand, and this set is why. It was defensible on
131
+ * its own terms — one documented file, so a spec that is slow or wants
132
+ * credentials is not dragged into every save — but neither verdict over the
133
+ * difference was liveable: a green one is the false pass above, and the
134
+ * failure that replaced it made bare `aai test` red on every project with a
135
+ * second spec file. So `all` is the default for both gates now and `--only`
136
+ * is the inner loop, and what this set feeds is the honest report of a
137
+ * narrowing somebody asked for: {@link warnUnrunSpecs}'s notice, plus
138
+ * `unrun`/`complete` on `aai test`'s own result for a script to read.
129
139
  */
130
140
  export declare function unrunSpecFiles(cwd: string, ran: RanSpecs): string[];
131
141
  /**
@@ -136,19 +146,21 @@ export type RanSpecs = string | readonly string[] | false;
136
146
  /**
137
147
  * The remedy, named the same way wherever the narrowing is reported.
138
148
  *
139
- * The project's own `npm test` comes FIRST because it is the command a
140
- * scaffolded project already ships (`scaffold/package.json`), so it is the one
141
- * answer that needs nothing installed or remembered; `--all` is the same thing
142
- * without leaving the CLI.
149
+ * It is a bare `aai test` now rather than a flag: the whole suite IS the
150
+ * default, so the remedy for a narrowed run is to stop narrowing it. The
151
+ * project's own `npm test` comes second because it is the command a scaffolded
152
+ * project already ships (`scaffold/package.json`) and runs the same set with
153
+ * nothing to remember.
143
154
  */
144
155
  export declare const WIDEN_HINT: string;
145
156
  /**
146
157
  * Warn, once, naming the spec files this run did not cover.
147
158
  *
148
- * This is the notice for a caller whose own result says nothing about the
149
- * narrowing — today that is `aai build`'s pre-build gate, which ran one file
150
- * out of eight and printed "Build complete". `aai test` does not use it: an
151
- * incomplete run is a FAILURE there, and the failure's own message is the
152
- * report.
159
+ * This is the notice for a run that covered a SUBSET, and `aai test --only` is
160
+ * the caller it now serves: an author asking for the fast inner loop gets
161
+ * vitest's own summary and then the files that loop did not reach. It was
162
+ * written for `aai build`'s pre-build gate, which ran one file out of eight
163
+ * and printed "Build complete" — that gate passes `all` now, so the notice is
164
+ * silent there, which is the correct end state rather than a lost check.
153
165
  */
154
166
  export declare function warnUnrunSpecs(cwd: string, ran: RanSpecs): void;
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { _ as DENO_CONFIG_SOURCE, a as VERCEL_BUILD_CONFIG_SOURCE, b as DENO_OUTPUT_DIR, c as VERCEL_OUTPUT_DIR, d as MODAL_APP_FILE, f as MODAL_ENTRY_FILE, g as DENO_CONFIG_FILE, h as MODAL_PORT, i as resolveBuildTarget, l as VERCEL_STATIC_DIR, m as MODAL_OUTPUT_DIR, n as SECRET_NAME_PLACEHOLDER, o as VERCEL_ENTRY_SOURCE, p as MODAL_ENTRY_SOURCE, r as TARGET_OUTPUTS, s as VERCEL_FUNCTION_DIR, u as vercelFunctionConfigSource, v as DENO_ENTRY_FILE, y as DENO_ENTRY_SOURCE } from "./_build-target-ClEEuUuW.mjs";
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-BiAMIir1.mjs";
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-PHHv0Vj6.mjs";
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 resolved prompt, which
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, resolved) {
605
- if (resolved === DEFAULT_SYSTEM_PROMPT) return FRAMEWORK_DEFAULT_PROMPT_SOURCE;
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 === "" || !resolved.includes(trimmed)) return "agent.ts";
608
- return resolved.trim() === trimmed ? SYSTEM_PROMPT_FILE : `agent.ts (composing ${SYSTEM_PROMPT_FILE})`;
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 missingEnv = await missingDeployEnv(cwd, target);
641
- for (const warning of missingEnvWarnings(missingEnv, target)) notify("warn", warning);
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
- if (output.deploy !== void 0) log.info(`Deploy it with \`${output.deploy}\``);
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: output.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
- return (await declaredEnvNames(cwd, [DEPLOY_ENV_DECLARATION_FILE])).filter((name) => {
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 { secret } = TARGET_OUTPUTS[target];
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.`;