@alexkroman1/aai-cli 5.14.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/{_agent-C8Jk-ZcP.mjs → _agent-vGW5SBnX.mjs} +23 -5
  2. package/dist/_agent.d.ts +18 -0
  3. package/dist/{_api-client-BX8Qv51n.mjs → _api-client-LgLksMhN.mjs} +45 -8
  4. package/dist/_api-client.d.ts +39 -0
  5. package/dist/{_bundler-BuIyDdvs.mjs → _bundler-BapCUUJN.mjs} +42 -14
  6. package/dist/_bundler.d.ts +43 -5
  7. package/dist/_cli-common.d.ts +67 -3
  8. package/dist/{_config-CzwAWOWr.mjs → _config-D_s09e7g.mjs} +36 -18
  9. package/dist/_deploy.d.ts +2 -5
  10. package/dist/_dev-restart.d.ts +6 -1
  11. package/dist/{_dev-server-Ch7K8e8i.mjs → _dev-server-DQ1t9sbw.mjs} +94 -38
  12. package/dist/_dev-server.d.ts +30 -2
  13. package/dist/_e2e-test-utils.d.ts +80 -0
  14. package/dist/_fault-mode.d.ts +175 -0
  15. package/dist/{_init-CbkrE2wq.mjs → _init-CpISqoR8.mjs} +3 -3
  16. package/dist/{_output-CC300DzW.mjs → _output-CKkmWs7i.mjs} +8 -1
  17. package/dist/_output.d.ts +9 -2
  18. package/dist/{_server-common-61fL__39.mjs → _server-common-6e0QI4mq.mjs} +1 -1
  19. package/dist/{_slug-api-D30zPmsn.mjs → _slug-api-D2heILuC.mjs} +2 -2
  20. package/dist/{_studio-D2ciIhbi.mjs → _studio-zAJycZ8j.mjs} +3 -3
  21. package/dist/{_templates-B1kt3BGt.mjs → _templates-iDGjGiPf.mjs} +4 -6
  22. package/dist/{_typecheck-gate-4v9UBZHh.mjs → _typecheck-gate-BXvUNnfs.mjs} +1 -1
  23. package/dist/{_utils-0DHbcqUb.mjs → _utils-B8QmtFhK.mjs} +21 -7
  24. package/dist/_utils.d.ts +18 -2
  25. package/dist/{_vite-env-Dg_QlVv0.mjs → _vite-env-BNveawd1.mjs} +31 -1
  26. package/dist/_vite-env.d.ts +30 -0
  27. package/dist/build-BO1Ni6oJ.mjs +62 -0
  28. package/dist/build.d.ts +19 -0
  29. package/dist/cli-workflow.d.ts +10 -0
  30. package/dist/cli.d.ts +1 -2
  31. package/dist/cli.mjs +406 -224
  32. package/dist/{client-bundler-C9qXL8A2.mjs → client-bundler-B8Q9F8gJ.mjs} +3 -22
  33. package/dist/client-bundler.mjs +1 -1
  34. package/dist/{delete-DCRX3d96.mjs → delete-4I0uNR4a.mjs} +6 -7
  35. package/dist/delete.d.ts +2 -8
  36. package/dist/{deploy-DjsEV-40.mjs → deploy-DJ3HRcia.mjs} +13 -14
  37. package/dist/{dev-CvPH5dbF.mjs → dev-C6SWaAZP.mjs} +3 -3
  38. package/dist/{eject-LgBRfnbH.mjs → eject-Zrzk5KV3.mjs} +41 -15
  39. package/dist/eject.d.ts +30 -3
  40. package/dist/{init-BppxMR8r.mjs → init-BTRGiPQr.mjs} +61 -26
  41. package/dist/init.d.ts +11 -0
  42. package/dist/{login-BQQaxJhL.mjs → login-k0Z3VQu9.mjs} +5 -5
  43. package/dist/project-config.mjs +1 -1
  44. package/dist/scaffold/CLAUDE.md +498 -91
  45. package/dist/scaffold/package.json +11 -8
  46. package/dist/scaffold/pnpm-workspace.yaml +8 -0
  47. package/dist/scaffold/server.mjs +53 -57
  48. package/dist/{secret-Ds9dvqAj.mjs → secret-DzSQx1Ds.mjs} +6 -3
  49. package/dist/{storage-DbrQSHFk.mjs → storage-C-Do0mIA.mjs} +18 -6
  50. package/dist/{studio-GSFd4s5O.mjs → studio-BGVmCA2G.mjs} +10 -10
  51. package/dist/templates/code-interpreter/agent.ts +0 -2
  52. package/dist/templates/dispatch-center/agent.test.ts +17 -19
  53. package/dist/templates/dispatch-center/agent.ts +2 -29
  54. package/dist/templates/dispatch-center/client.tsx +33 -16
  55. package/dist/templates/dispatch-center/shared.ts +53 -19
  56. package/dist/templates/dispatch-center/tools/incident_add_note.ts +12 -14
  57. package/dist/templates/dispatch-center/tools/incident_create.ts +41 -44
  58. package/dist/templates/dispatch-center/tools/incident_escalate.ts +59 -61
  59. package/dist/templates/dispatch-center/tools/incident_get.ts +3 -4
  60. package/dist/templates/dispatch-center/tools/incident_triage.ts +43 -45
  61. package/dist/templates/dispatch-center/tools/incident_update_status.ts +39 -41
  62. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +2 -5
  63. package/dist/templates/dispatch-center/tools/ops_protocols.ts +1 -1
  64. package/dist/templates/dispatch-center/tools/ops_run_scenario.ts +20 -23
  65. package/dist/templates/dispatch-center/tools/resources_dispatch.ts +52 -54
  66. package/dist/templates/dispatch-center/tools/resources_get_available.ts +2 -4
  67. package/dist/templates/dispatch-center/tools/resources_update_status.ts +39 -42
  68. package/dist/templates/embedded-assets/agent.test.ts +83 -0
  69. package/dist/templates/embedded-assets/agent.ts +1 -48
  70. package/dist/templates/embedded-assets/shared.ts +17 -0
  71. package/dist/templates/embedded-assets/system-prompt.md +13 -0
  72. package/dist/templates/embedded-assets/tools/list_topics.ts +9 -0
  73. package/dist/templates/embedded-assets/tools/search_knowledge.ts +26 -0
  74. package/dist/templates/health-assistant/agent.test.ts +169 -0
  75. package/dist/templates/health-assistant/agent.ts +1 -166
  76. package/dist/templates/health-assistant/fda.ts +100 -0
  77. package/dist/templates/health-assistant/tools/check_drug_interaction.ts +59 -0
  78. package/dist/templates/health-assistant/tools/medication_lookup.ts +31 -0
  79. package/dist/templates/infocom-adventure/agent.test.ts +205 -0
  80. package/dist/templates/infocom-adventure/agent.ts +3 -106
  81. package/dist/templates/infocom-adventure/client.tsx +28 -12
  82. package/dist/templates/infocom-adventure/shared.ts +28 -11
  83. package/dist/templates/infocom-adventure/tools/game_state_drop.ts +13 -0
  84. package/dist/templates/infocom-adventure/tools/game_state_flag.ts +13 -0
  85. package/dist/templates/infocom-adventure/tools/game_state_get.ts +16 -0
  86. package/dist/templates/infocom-adventure/tools/game_state_history.ts +14 -0
  87. package/dist/templates/infocom-adventure/tools/game_state_move.ts +14 -0
  88. package/dist/templates/infocom-adventure/tools/game_state_restart.ts +13 -0
  89. package/dist/templates/infocom-adventure/tools/game_state_score.ts +13 -0
  90. package/dist/templates/infocom-adventure/tools/game_state_take.ts +13 -0
  91. package/dist/templates/link-digest/agent.test.ts +223 -0
  92. package/dist/templates/link-digest/agent.ts +79 -0
  93. package/dist/templates/link-digest/client.tsx +146 -0
  94. package/dist/templates/link-digest/workflows/digest.ts +248 -0
  95. package/dist/templates/math-buddy/agent.ts +0 -2
  96. package/dist/templates/night-owl/agent.test.ts +80 -0
  97. package/dist/templates/night-owl/agent.ts +1 -68
  98. package/dist/templates/night-owl/system-prompt.md +10 -0
  99. package/dist/templates/night-owl/tools/recommend.ts +64 -0
  100. package/dist/templates/personal-finance/agent.ts +0 -2
  101. package/dist/templates/pizza-ordering/agent.test.ts +52 -47
  102. package/dist/templates/pizza-ordering/agent.ts +9 -158
  103. package/dist/templates/pizza-ordering/shared.ts +35 -12
  104. package/dist/templates/pizza-ordering/tools/add_pizza.ts +31 -0
  105. package/dist/templates/pizza-ordering/tools/place_order.ts +22 -0
  106. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +22 -0
  107. package/dist/templates/pizza-ordering/tools/set_customer_name.ts +13 -0
  108. package/dist/templates/pizza-ordering/tools/update_pizza.ts +28 -0
  109. package/dist/templates/pizza-ordering/tools/view_order.ts +21 -0
  110. package/dist/templates/plan-and-execute/agent.test.ts +411 -0
  111. package/dist/templates/plan-and-execute/agent.ts +23 -0
  112. package/dist/templates/plan-and-execute/client.tsx +115 -0
  113. package/dist/templates/plan-and-execute/graph.ts +178 -0
  114. package/dist/templates/plan-and-execute/prompts.ts +110 -0
  115. package/dist/templates/plan-and-execute/shared.ts +161 -0
  116. package/dist/templates/plan-and-execute/system-prompt.md +18 -0
  117. package/dist/templates/plan-and-execute/tools/plan_status.ts +20 -0
  118. package/dist/templates/plan-and-execute/tools/revise_plan.ts +63 -0
  119. package/dist/templates/plan-and-execute/tools/start_plan.ts +51 -0
  120. package/dist/templates/plan-and-execute/tools/work_next_step.ts +101 -0
  121. package/dist/templates/recap-workflow/agent.test.ts +762 -0
  122. package/dist/templates/recap-workflow/agent.ts +95 -0
  123. package/dist/templates/recap-workflow/shared.ts +43 -0
  124. package/dist/templates/recap-workflow/tools/cancel_recap.ts +23 -0
  125. package/dist/templates/recap-workflow/tools/keep_transcript.ts +31 -0
  126. package/dist/templates/recap-workflow/tools/recap_progress.ts +27 -0
  127. package/dist/templates/recap-workflow/tools/recap_status.ts +46 -0
  128. package/dist/templates/recap-workflow/tools/request_recap.ts +43 -0
  129. package/dist/templates/recap-workflow/workflows/recap.ts +544 -0
  130. package/dist/templates/recap-workflow/workflows/tokens.ts +26 -0
  131. package/dist/templates/redline/agent.test.ts +222 -0
  132. package/dist/templates/redline/agent.ts +89 -0
  133. package/dist/templates/redline/client.tsx +184 -0
  134. package/dist/templates/redline/workflows/prompts.ts +68 -0
  135. package/dist/templates/redline/workflows/redline.ts +258 -0
  136. package/dist/templates/research-workflow/agent.test.ts +525 -0
  137. package/dist/templates/research-workflow/agent.ts +94 -0
  138. package/dist/templates/research-workflow/shared.ts +35 -0
  139. package/dist/templates/research-workflow/tools/file_it_now.ts +22 -0
  140. package/dist/templates/research-workflow/tools/request_research.ts +33 -0
  141. package/dist/templates/research-workflow/tools/research_progress.ts +26 -0
  142. package/dist/templates/research-workflow/tools/research_status.ts +40 -0
  143. package/dist/templates/research-workflow/workflows/prompts.ts +143 -0
  144. package/dist/templates/research-workflow/workflows/research.ts +558 -0
  145. package/dist/templates/retail/agent.test.ts +236 -172
  146. package/dist/templates/retail/agent.ts +5 -42
  147. package/dist/templates/retail/client.tsx +33 -11
  148. package/dist/templates/retail/registry.test.ts +31 -16
  149. package/dist/templates/retail/resolve.ts +28 -64
  150. package/dist/templates/retail/shared.test.ts +4 -3
  151. package/dist/templates/retail/shared.ts +24 -7
  152. package/dist/templates/retail/store.test.ts +12 -10
  153. package/dist/templates/retail/store.ts +69 -30
  154. package/dist/templates/retail/tools/cancel_pending_order.ts +4 -9
  155. package/dist/templates/retail/tools/exchange_delivered_order_items.ts +22 -11
  156. package/dist/templates/retail/tools/find_user_id_by_email.ts +5 -9
  157. package/dist/templates/retail/tools/find_user_id_by_name_zip.ts +5 -7
  158. package/dist/templates/retail/tools/get_item_details.ts +5 -7
  159. package/dist/templates/retail/tools/get_order_details.ts +5 -7
  160. package/dist/templates/retail/tools/get_product_details.ts +4 -7
  161. package/dist/templates/retail/tools/get_user_details.ts +4 -7
  162. package/dist/templates/retail/tools/list_all_product_types.ts +5 -7
  163. package/dist/templates/retail/tools/modify_pending_order_address.ts +4 -9
  164. package/dist/templates/retail/tools/modify_pending_order_items.ts +4 -16
  165. package/dist/templates/retail/tools/modify_pending_order_payment.ts +3 -9
  166. package/dist/templates/retail/tools/modify_user_address.ts +4 -9
  167. package/dist/templates/retail/tools/return_delivered_order_items.ts +3 -9
  168. package/dist/templates/retail/tools/transfer_to_human_agents.ts +1 -1
  169. package/dist/templates/solo-rpg/agent.test.ts +152 -29
  170. package/dist/templates/solo-rpg/agent.ts +3 -21
  171. package/dist/templates/solo-rpg/client.tsx +19 -6
  172. package/dist/templates/solo-rpg/shared.ts +19 -11
  173. package/dist/templates/solo-rpg/tools/action_roll.ts +2 -4
  174. package/dist/templates/solo-rpg/tools/burn_momentum.ts +2 -4
  175. package/dist/templates/solo-rpg/tools/check_state.ts +6 -6
  176. package/dist/templates/solo-rpg/tools/load_game.ts +1 -1
  177. package/dist/templates/solo-rpg/tools/oracle.ts +18 -11
  178. package/dist/templates/solo-rpg/tools/save_game.ts +10 -7
  179. package/dist/templates/solo-rpg/tools/setup_character.ts +1 -1
  180. package/dist/templates/solo-rpg/tools/update_state.ts +3 -4
  181. package/dist/templates/support-line/agent.test.ts +343 -0
  182. package/dist/templates/support-line/agent.ts +27 -0
  183. package/dist/templates/support-line/client.tsx +122 -0
  184. package/dist/templates/support-line/graph.ts +224 -0
  185. package/dist/templates/support-line/knowledge.json +65 -0
  186. package/dist/templates/support-line/prompts.ts +95 -0
  187. package/dist/templates/support-line/shared.ts +240 -0
  188. package/dist/templates/support-line/system-prompt.md +17 -0
  189. package/dist/templates/support-line/tools/answer_question.ts +72 -0
  190. package/dist/templates/support-line/tools/list_topics.ts +22 -0
  191. package/dist/templates/support-line/tools/log_ticket.ts +30 -0
  192. package/dist/templates/transcription-workflow/agent.test.ts +563 -0
  193. package/dist/templates/transcription-workflow/agent.ts +92 -0
  194. package/dist/templates/transcription-workflow/client.tsx +234 -0
  195. package/dist/templates/transcription-workflow/workflows/transcribe.ts +416 -0
  196. package/dist/templates/transcription-workflow/workflows/wav.ts +314 -0
  197. package/dist/templates/travel-concierge/agent.test.ts +338 -0
  198. package/dist/templates/travel-concierge/agent.ts +29 -0
  199. package/dist/templates/travel-concierge/client.tsx +161 -0
  200. package/dist/templates/travel-concierge/routing.ts +138 -0
  201. package/dist/templates/travel-concierge/shared.ts +547 -0
  202. package/dist/templates/travel-concierge/system-prompt.md +24 -0
  203. package/dist/templates/travel-concierge/tools/book_car_rental.ts +20 -0
  204. package/dist/templates/travel-concierge/tools/book_excursion.ts +18 -0
  205. package/dist/templates/travel-concierge/tools/book_hotel.ts +20 -0
  206. package/dist/templates/travel-concierge/tools/cancel_action.ts +7 -0
  207. package/dist/templates/travel-concierge/tools/cancel_ticket.ts +16 -0
  208. package/dist/templates/travel-concierge/tools/complete_or_escalate.ts +7 -0
  209. package/dist/templates/travel-concierge/tools/confirm_action.ts +7 -0
  210. package/dist/templates/travel-concierge/tools/lookup_booking.ts +35 -0
  211. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +33 -0
  212. package/dist/templates/travel-concierge/tools/search_excursions.ts +37 -0
  213. package/dist/templates/travel-concierge/tools/search_flights.ts +43 -0
  214. package/dist/templates/travel-concierge/tools/search_hotels.ts +36 -0
  215. package/dist/templates/travel-concierge/tools/to_car_rental_assistant.ts +11 -0
  216. package/dist/templates/travel-concierge/tools/to_excursion_assistant.ts +11 -0
  217. package/dist/templates/travel-concierge/tools/to_flight_assistant.ts +11 -0
  218. package/dist/templates/travel-concierge/tools/to_hotel_assistant.ts +11 -0
  219. package/dist/templates/travel-concierge/tools/update_ticket.ts +22 -0
  220. package/dist/templates/web-researcher/agent.ts +0 -2
  221. package/dist/templates/web-researcher/system-prompt.md +10 -0
  222. package/dist/{test-2LWBcXvY.mjs → test-B6ZBxSpk.mjs} +2 -2
  223. package/dist/typecheck.mjs +17 -15
  224. package/dist/worker-bundler-CIdDhZ0c.mjs +398 -0
  225. package/dist/worker-bundler.d.ts +14 -0
  226. package/dist/worker-bundler.mjs +1 -108
  227. package/dist/workflow-B-O97AqI.mjs +125 -0
  228. package/dist/workflow-bundler.d.ts +133 -0
  229. package/dist/workflow.d.ts +67 -0
  230. package/package.json +13 -9
  231. package/dist/build-DQJ1ZSm9.mjs +0 -39
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { a as errorMessage$1, o as fileExists } from "./_utils-0DHbcqUb.mjs";
3
- import { t as withPreservedNodeEnv } from "./_vite-env-Dg_QlVv0.mjs";
2
+ import { o as errorMessage$1, s as fileExists } from "./_utils-B8QmtFhK.mjs";
3
+ import { n as withPreservedNodeEnv, t as DEDUPED_PEERS } from "./_vite-env-BNveawd1.mjs";
4
4
  import { existsSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import path from "node:path";
6
- import fs from "node:fs/promises";
7
6
  import { isTextAssetPath } from "@alexkroman1/aai/utils";
7
+ import fs from "node:fs/promises";
8
8
  import { build } from "vite";
9
9
  //#region _default-html.ts
10
10
  /**
@@ -73,25 +73,6 @@ function writeTempHtml(root) {
73
73
  //#region client-bundler.ts
74
74
  const DEFAULT_OUT_DIR = ".aai/client";
75
75
  /**
76
- * Packages resolved from the build root rather than from whichever
77
- * `node_modules` happens to sit above the importing file.
78
- *
79
- * `@alexkroman1/aai-ui` declares React as a **peer** dependency — "my consumer
80
- * supplies it" — but a bundler resolves the bare `react/jsx-runtime` import
81
- * inside `aai-ui/dist/**` from that file's own real path, not from the
82
- * consumer's. In the studio's case the two differ: the workspace scratch dir
83
- * (the build root, under `aai-server`, which owns the React dependency) is
84
- * nowhere above `packages/aai-ui/dist`, and the production image installs prod
85
- * deps only, so aai-ui's own devDependency copy of React is pruned there.
86
- * The result was a publish that failed with *"Rolldown failed to resolve
87
- * import react/jsx-runtime"* while every local build passed.
88
- *
89
- * Deduping states the peer contract in terms the bundler enforces, and it is
90
- * what a React app wants anyway: two copies of React in one bundle break
91
- * hooks. Guarded by `client-bundler.test.ts`.
92
- */
93
- const DEDUPED_PEERS = ["react", "react-dom"];
94
- /**
95
76
  * Build the client SPA with Vite if `client.tsx` exists.
96
77
  * Returns a map of relative file paths to string contents for deploy,
97
78
  * or `{}` when the project has no `client.tsx`.
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { t as buildClient } from "./client-bundler-C9qXL8A2.mjs";
2
+ import { t as buildClient } from "./client-bundler-B8Q9F8gJ.mjs";
3
3
  export { buildClient };
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-CC300DzW.mjs";
2
+ import { a as ok } from "./_output-CKkmWs7i.mjs";
3
3
  import { n as log } from "./_ui-u7T4YooX.mjs";
4
- import { l as writeProjectConfig } from "./_config-CzwAWOWr.mjs";
5
- import { i as resolveDeployTarget, n as getServerInfo } from "./_agent-C8Jk-ZcP.mjs";
6
- import { n as apiRequest, t as HINT_NOT_DEPLOYED } from "./_api-client-BX8Qv51n.mjs";
4
+ import { l as writeProjectConfig } from "./_config-D_s09e7g.mjs";
5
+ import { a as resolveDeployTarget, i as requireDeployedSlug } from "./_agent-vGW5SBnX.mjs";
6
+ import { n as apiRequest, r as apiTestSeam, t as HINT_NOT_DEPLOYED } from "./_api-client-LgLksMhN.mjs";
7
7
  //#region delete.ts
8
8
  async function runDelete(opts) {
9
9
  await apiRequest(`${opts.url}/${opts.slug}`, {
@@ -11,8 +11,7 @@ async function runDelete(opts) {
11
11
  apiKey: opts.apiKey,
12
12
  action: "delete",
13
13
  hints: { 404: HINT_NOT_DEPLOYED },
14
- ...opts.fetch ? { fetch: opts.fetch } : {},
15
- ...opts.retryDelay === void 0 ? {} : { retryDelay: opts.retryDelay }
14
+ ...apiTestSeam(opts)
16
15
  });
17
16
  }
18
17
  /**
@@ -41,7 +40,7 @@ async function executeDelete(opts) {
41
40
  ...config.slug ? { slug: config.slug } : {}
42
41
  });
43
42
  }
44
- const { slug } = await getServerInfo(cwd, opts.server);
43
+ const slug = requireDeployedSlug(config);
45
44
  log.step(`Deleting ${slug}`);
46
45
  await runDelete({
47
46
  url: serverUrl,
package/dist/delete.d.ts CHANGED
@@ -1,15 +1,9 @@
1
+ import { type ApiTestSeam } from "./_api-client.ts";
1
2
  import { type CommandResult } from "./_output.ts";
2
- export type DeleteOpts = {
3
+ export type DeleteOpts = ApiTestSeam & {
3
4
  url: string;
4
5
  slug: string;
5
6
  apiKey: string;
6
- /** Optional fetch implementation for testing. Defaults to globalThis.fetch. */
7
- fetch?: typeof globalThis.fetch;
8
- /**
9
- * Delay between retries in ms (default 300, see `_api-client.ts`). Tests
10
- * pass 0 so retry-path assertions don't sleep real wall-clock time.
11
- */
12
- retryDelay?: number;
13
7
  };
14
8
  export declare function runDelete(opts: DeleteOpts): Promise<void>;
15
9
  type DeleteData = {
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-CC300DzW.mjs";
2
+ import { a as ok } from "./_output-CKkmWs7i.mjs";
3
3
  import { n as log, r as notify, t as fmtUrl } from "./_ui-u7T4YooX.mjs";
4
- import { a as errorMessage$1 } from "./_utils-0DHbcqUb.mjs";
5
- import { s as updateProjectConfig } from "./_config-CzwAWOWr.mjs";
6
- import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-BuIyDdvs.mjs";
7
- import { t as resolveServerEnv } from "./_server-common-61fL__39.mjs";
8
- import { i as resolveDeployTarget } from "./_agent-C8Jk-ZcP.mjs";
9
- import { assertTypechecks } from "./_typecheck-gate-4v9UBZHh.mjs";
10
- import { n as apiRequest } from "./_api-client-BX8Qv51n.mjs";
11
- import { i as projectNameFromDir } from "./_studio-D2ciIhbi.mjs";
12
- import { omitUndefined } from "@alexkroman1/aai/utils";
4
+ import { o as errorMessage$1 } from "./_utils-B8QmtFhK.mjs";
5
+ import { s as updateProjectConfig } from "./_config-D_s09e7g.mjs";
6
+ import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-BapCUUJN.mjs";
7
+ import { t as resolveServerEnv } from "./_server-common-6e0QI4mq.mjs";
8
+ import { a as resolveDeployTarget } from "./_agent-vGW5SBnX.mjs";
9
+ import { assertTypechecks } from "./_typecheck-gate-BXvUNnfs.mjs";
10
+ import { i as checkedResponse, n as apiRequest, r as apiTestSeam } from "./_api-client-LgLksMhN.mjs";
11
+ import { i as projectNameFromDir } from "./_studio-zAJycZ8j.mjs";
12
+ import { isRecord } from "@alexkroman1/aai/utils";
13
13
  import { gzipSync } from "node:zlib";
14
14
  //#region _deploy.ts
15
15
  async function runDeploy(opts) {
@@ -20,7 +20,7 @@ async function runDeploy(opts) {
20
20
  worker: opts.bundle.worker,
21
21
  clientFiles: opts.bundle.clientFiles
22
22
  }));
23
- return { slug: (await apiRequest(`${opts.url}/deploy`, {
23
+ return checkedResponse(await apiRequest(`${opts.url}/deploy`, {
24
24
  method: "POST",
25
25
  body,
26
26
  headers: {
@@ -31,9 +31,8 @@ async function runDeploy(opts) {
31
31
  action: "deploy",
32
32
  hints: { 413: "Your bundle is too large. Try reducing dependencies or splitting your agent." },
33
33
  ...opts.slug ? {} : { retry: 0 },
34
- ...omitUndefined({ retryDelay: opts.retryDelay }),
35
- ...opts.fetch ? { fetch: opts.fetch } : {}
36
- })).slug };
34
+ ...apiTestSeam(opts)
35
+ }), (value) => isRecord(value) && typeof value.slug === "string", `the deploy route at ${opts.url}`);
37
36
  }
38
37
  //#endregion
39
38
  //#region deploy.ts
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-CC300DzW.mjs";
2
+ import { a as ok } from "./_output-CKkmWs7i.mjs";
3
3
  import { a as parsePort, n as log, r as notify, t as fmtUrl } from "./_ui-u7T4YooX.mjs";
4
- import { i as errorDetail } from "./_utils-0DHbcqUb.mjs";
4
+ import { a as errorDetail } from "./_utils-B8QmtFhK.mjs";
5
5
  import path from "node:path";
6
6
  import { styleText } from "node:util";
7
7
  //#region dev.ts
@@ -12,7 +12,7 @@ import { styleText } from "node:util";
12
12
  async function executeDev(opts) {
13
13
  const port = parsePort(opts.port);
14
14
  const agentName = path.basename(path.resolve(opts.cwd));
15
- const { startDevServer } = await import("./_dev-server-Ch7K8e8i.mjs");
15
+ const { startDevServer } = await import("./_dev-server-DQ1t9sbw.mjs");
16
16
  let cleanup;
17
17
  let shuttingDown = false;
18
18
  const onSignal = () => {
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok, t as CliError } from "./_output-CC300DzW.mjs";
2
+ import { a as ok, t as CliError } from "./_output-CKkmWs7i.mjs";
3
3
  import { n as log } from "./_ui-u7T4YooX.mjs";
4
- import { a as errorMessage, c as readJson, d as writeJson, o as fileExists } from "./_utils-0DHbcqUb.mjs";
5
- import { scaffoldDir } from "./_templates-B1kt3BGt.mjs";
4
+ import { l as readJson, o as errorMessage, p as writeJson, s as fileExists } from "./_utils-B8QmtFhK.mjs";
5
+ import { scaffoldDir } from "./_templates-iDGjGiPf.mjs";
6
6
  import path from "node:path";
7
7
  import fs from "node:fs/promises";
8
8
  //#region eject.ts
@@ -10,7 +10,7 @@ import fs from "node:fs/promises";
10
10
  * `aai eject` — retrofit the self-hosted entrypoint into an existing project.
11
11
  *
12
12
  * Every project scaffolded from this CLI version onwards already has
13
- * `server.mjs` and an `npm start` script: the scaffold ships them, so
13
+ * `server.mjs` and the `prestart`/`start` pair: the scaffold ships them, so
14
14
  * self-hosting is the default rather than something to opt into. This command
15
15
  * exists for the projects that predate that — `aai init` before it, or a
16
16
  * workspace pulled from a studio that was created earlier — where the files
@@ -20,34 +20,61 @@ import fs from "node:fs/promises";
20
20
  * definitions of "the self-hosted entrypoint" would drift, and the one nobody
21
21
  * runs locally is the one that would rot; this way an ejected project is
22
22
  * byte-identical to a freshly scaffolded one.
23
+ *
24
+ * The SCRIPTS are the exception it cannot copy, since a project's package.json
25
+ * is its own — so `PRESTART_SCRIPT`/`START_SCRIPT` are written here and pinned
26
+ * against the scaffold's manifest by `eject.test.ts`. Both matter: the
27
+ * entrypoint boots the BUILT worker, so an ejected project with no `prestart`
28
+ * exits at once naming the missing artifact.
23
29
  */
24
30
  /** The file `npm start` runs. Named once — the scaffold ships it under this name. */
25
31
  const SERVER_ENTRY = "server.mjs";
26
32
  /** The `scripts.start` value that runs {@link SERVER_ENTRY}. */
27
33
  const START_SCRIPT = `node ${SERVER_ENTRY}`;
28
34
  /**
29
- * Add `scripts.start` unless the project already declares one.
35
+ * The `scripts.prestart` value, which npm runs before `start`.
36
+ *
37
+ * {@link SERVER_ENTRY} boots the BUILT worker (`.aai/worker.mjs`), because a
38
+ * tool is discovered by the bundler enumerating `tools/` and an un-bundled
39
+ * loader would serve an agent with no tools at all — so an entrypoint with no
40
+ * build in front of it is not a working project. `--skip-tests` because this
41
+ * runs on the way to serving traffic: `npm test` is where a suite belongs, and
42
+ * a failing test must not be what stops a container from starting. The
43
+ * typecheck stays, since the bundlers strip types unchecked and self-hosting
44
+ * has no other gate.
45
+ *
46
+ * Kept in step with the scaffold's own `package.json`, which the two together
47
+ * are the only definition of — `eject.test.ts` asserts they agree.
48
+ */
49
+ const PRESTART_SCRIPT = "aai build --skip-tests";
50
+ /**
51
+ * Add `scripts.start` — and the `prestart` that builds what it boots — unless
52
+ * the project already declares a `start` of its own.
30
53
  *
31
54
  * An existing `start` is left alone even under `--force`: `--force` is about
32
55
  * replacing the entrypoint file, and silently rewriting the command a project
33
- * boots with is a different, larger act. The mismatch is reported instead, so
34
- * the choice stays the author's.
56
+ * boots with is a different, larger act. `prestart` is part of the same act
57
+ * rather than a separate one, so it is written only alongside a `start` we
58
+ * wrote — bolting a build onto someone else's start command changes what that
59
+ * command does, which is precisely what the rule above refuses. The mismatch is
60
+ * reported instead, naming both halves, so the choice stays the author's.
35
61
  */
36
62
  async function ensureStartScript(cwd) {
37
63
  const manifestPath = path.join(cwd, "package.json");
38
64
  const manifest = await readJson(manifestPath);
39
65
  if (!manifest) {
40
- log.warn(`No package.json here — add "start": "${START_SCRIPT}" yourself to get \`npm start\`.`);
66
+ log.warn(`No package.json here — add "prestart": "${PRESTART_SCRIPT}" and "start": "${START_SCRIPT}" yourself to get \`npm start\`.`);
41
67
  return false;
42
68
  }
43
69
  const existing = manifest.scripts?.start;
44
- if (existing === START_SCRIPT) return false;
45
- if (existing !== void 0) {
46
- log.warn(`Kept your existing "start" script (${existing}) — run \`node ${SERVER_ENTRY}\`.`);
70
+ if (existing === START_SCRIPT && manifest.scripts?.prestart === "aai build --skip-tests") return false;
71
+ if (existing !== void 0 && existing !== START_SCRIPT) {
72
+ log.warn(`Kept your existing "start" script (${existing}) — run \`${PRESTART_SCRIPT}\` then \`node ${SERVER_ENTRY}\`.`);
47
73
  return false;
48
74
  }
49
75
  manifest.scripts = {
50
76
  ...manifest.scripts,
77
+ prestart: PRESTART_SCRIPT,
51
78
  start: START_SCRIPT
52
79
  };
53
80
  await writeJson(manifestPath, manifest);
@@ -76,14 +103,13 @@ async function executeEject(opts) {
76
103
  } catch (err) {
77
104
  throw scaffoldMissingError(source, err);
78
105
  }
79
- const addedStartScript = await ensureStartScript(cwd);
106
+ const addedScripts = await ensureStartScript(cwd);
80
107
  log.success(`Wrote ${SERVER_ENTRY}${overwritten ? " (replaced)" : ""}`);
81
- if (await fileExists(path.join(cwd, "client.tsx"))) log.info("This project has a custom UI: run `aai build` first so it is served.");
82
- log.info("Next: npm start (PORT and HOST override the 127.0.0.1:3000 default)");
108
+ log.info(`Next: npm start it builds first (\`${PRESTART_SCRIPT}\`), then serves on 127.0.0.1:3000 (PORT and HOST override that)`);
83
109
  return ok({
84
110
  file: target,
85
111
  overwritten,
86
- addedStartScript
112
+ addedScripts
87
113
  });
88
114
  }
89
115
  //#endregion
package/dist/eject.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * `aai eject` — retrofit the self-hosted entrypoint into an existing project.
3
3
  *
4
4
  * Every project scaffolded from this CLI version onwards already has
5
- * `server.mjs` and an `npm start` script: the scaffold ships them, so
5
+ * `server.mjs` and the `prestart`/`start` pair: the scaffold ships them, so
6
6
  * self-hosting is the default rather than something to opt into. This command
7
7
  * exists for the projects that predate that — `aai init` before it, or a
8
8
  * workspace pulled from a studio that was created earlier — where the files
@@ -12,19 +12,46 @@
12
12
  * definitions of "the self-hosted entrypoint" would drift, and the one nobody
13
13
  * runs locally is the one that would rot; this way an ejected project is
14
14
  * byte-identical to a freshly scaffolded one.
15
+ *
16
+ * The SCRIPTS are the exception it cannot copy, since a project's package.json
17
+ * is its own — so `PRESTART_SCRIPT`/`START_SCRIPT` are written here and pinned
18
+ * against the scaffold's manifest by `eject.test.ts`. Both matter: the
19
+ * entrypoint boots the BUILT worker, so an ejected project with no `prestart`
20
+ * exits at once naming the missing artifact.
15
21
  */
16
22
  import { type CommandResult } from "./_output.ts";
17
23
  /** The file `npm start` runs. Named once — the scaffold ships it under this name. */
18
24
  export declare const SERVER_ENTRY = "server.mjs";
19
25
  /** The `scripts.start` value that runs {@link SERVER_ENTRY}. */
20
26
  export declare const START_SCRIPT = "node server.mjs";
27
+ /**
28
+ * The `scripts.prestart` value, which npm runs before `start`.
29
+ *
30
+ * {@link SERVER_ENTRY} boots the BUILT worker (`.aai/worker.mjs`), because a
31
+ * tool is discovered by the bundler enumerating `tools/` and an un-bundled
32
+ * loader would serve an agent with no tools at all — so an entrypoint with no
33
+ * build in front of it is not a working project. `--skip-tests` because this
34
+ * runs on the way to serving traffic: `npm test` is where a suite belongs, and
35
+ * a failing test must not be what stops a container from starting. The
36
+ * typecheck stays, since the bundlers strip types unchecked and self-hosting
37
+ * has no other gate.
38
+ *
39
+ * Kept in step with the scaffold's own `package.json`, which the two together
40
+ * are the only definition of — `eject.test.ts` asserts they agree.
41
+ */
42
+ export declare const PRESTART_SCRIPT = "aai build --skip-tests";
21
43
  type EjectData = {
22
44
  /** Absolute path of the entrypoint written. */
23
45
  file: string;
24
46
  /** True when an existing `server.mjs` was replaced (`--force`). */
25
47
  overwritten: boolean;
26
- /** True when `scripts.start` was added to package.json by this run. */
27
- addedStartScript: boolean;
48
+ /**
49
+ * True when this run wrote `scripts.prestart`/`scripts.start` into
50
+ * package.json. Also true for a project ejected by an older CLI, whose
51
+ * `start` is already correct and whose `prestart` is missing — the entrypoint
52
+ * this run just wrote needs the build in front of it.
53
+ */
54
+ addedScripts: boolean;
28
55
  };
29
56
  export declare function executeEject(opts: {
30
57
  cwd: string;
@@ -1,13 +1,33 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-CC300DzW.mjs";
2
+ import { a as ok } from "./_output-CKkmWs7i.mjs";
3
3
  import { n as log, s as unwrapCancel } from "./_ui-u7T4YooX.mjs";
4
- import { a as errorMessage, c as readJson, l as resolveCwd, o as fileExists, t as AGENT_ENTRY } from "./_utils-0DHbcqUb.mjs";
5
- import { r as isDevMode, t as getMonorepoRoot } from "./_agent-C8Jk-ZcP.mjs";
4
+ import { d as resolveCwd, l as readJson, o as errorMessage, s as fileExists, t as AGENT_ENTRY } from "./_utils-B8QmtFhK.mjs";
5
+ import { r as isDevMode, t as getMonorepoRoot } from "./_agent-vGW5SBnX.mjs";
6
6
  import path from "node:path";
7
7
  import { styleText } from "node:util";
8
8
  import * as p from "@clack/prompts";
9
9
  import { execa } from "execa";
10
10
  //#region init.ts
11
+ /**
12
+ * Run `fn` behind a clack spinner, stopping it in EVERY outcome.
13
+ *
14
+ * The naked form (`s?.start(); await work(); s?.stop()`) leaks the spinner on a
15
+ * failure: clack keeps its interval and its raw-mode stdin hook, so a throw
16
+ * left a spinner ticking under the error message with the cursor hidden. The
17
+ * `catch` label is what the terminal is left showing, so it names the step.
18
+ */
19
+ async function withSpinner(silent, labels, fn) {
20
+ const s = silent ? void 0 : p.spinner();
21
+ s?.start(labels.start);
22
+ let succeeded = false;
23
+ try {
24
+ const value = await fn();
25
+ succeeded = true;
26
+ return value;
27
+ } finally {
28
+ s?.stop(succeeded ? labels.done : labels.failed);
29
+ }
30
+ }
11
31
  const DEFAULT_PROJECT_NAME = "my-voice-agent";
12
32
  /** Prompt for project name or return default when --yes is set. */
13
33
  async function promptProjectName(yes) {
@@ -53,19 +73,19 @@ async function runPnpmInstall(cwd) {
53
73
  await execa(cmd, [...args, ...pnpmArgs], { cwd });
54
74
  }
55
75
  /** Install deps with pnpm. Returns true on success (or no deps to install). */
56
- async function installDeps(cwd, silent) {
76
+ async function installDeps(cwd, warn, silent) {
57
77
  if (!await hasDeps(cwd)) return true;
58
78
  await ensurePnpm();
59
- const s = silent ? void 0 : p.spinner();
60
- s?.start("Installing dependencies with pnpm");
61
79
  try {
62
- await runPnpmInstall(cwd);
63
- s?.stop("Dependencies installed");
80
+ await withSpinner(silent, {
81
+ start: "Installing dependencies with pnpm",
82
+ done: "Dependencies installed",
83
+ failed: "Dependency install failed"
84
+ }, () => runPnpmInstall(cwd));
64
85
  return true;
65
86
  } catch (err) {
66
- s?.stop("Dependency install failed");
67
- log.warn(`pnpm install failed: ${errorMessage(err)}`);
68
- log.warn("Install pnpm (`npm install -g pnpm`), then run `pnpm install` in the project.");
87
+ warn(`pnpm install failed: ${errorMessage(err)}`);
88
+ warn("Install pnpm (`npm install -g pnpm`), then run `pnpm install` in the project.");
69
89
  return false;
70
90
  }
71
91
  }
@@ -73,35 +93,48 @@ async function installDeps(cwd, silent) {
73
93
  function resolveTargetDir(dir) {
74
94
  return path.resolve(resolveCwd(), dir);
75
95
  }
96
+ function collectWarnings() {
97
+ const warnings = [];
98
+ return {
99
+ warnings,
100
+ warn: (message) => {
101
+ warnings.push(message);
102
+ log.warn(message);
103
+ }
104
+ };
105
+ }
76
106
  /** Publish after init and return deploy metadata if successful. */
77
- async function tryPublish(cwd, server) {
78
- const { executePublish } = await import("./studio-GSFd4s5O.mjs");
107
+ async function tryPublish(cwd, server, warn) {
108
+ const { executePublish } = await import("./studio-BGVmCA2G.mjs");
79
109
  try {
80
110
  const result = await executePublish({
81
111
  cwd,
82
112
  ...server ? { server } : {}
83
113
  });
84
- return result.ok ? {
114
+ if (result.ok) return {
85
115
  slug: result.data.slug,
86
116
  url: result.data.url,
87
117
  studioUrl: result.data.studioUrl
88
- } : null;
118
+ };
119
+ warn(`Publish failed: ${result.error}`);
120
+ return null;
89
121
  } catch (err) {
90
- log.warn(`Publish failed: ${errorMessage(err)}`);
91
- log.warn("Your project was still created — run `aai publish` in it to retry.");
122
+ warn(`Publish failed: ${errorMessage(err)}`);
123
+ warn("Your project was still created — run `aai publish` in it to retry.");
92
124
  return null;
93
125
  }
94
126
  }
95
127
  /** Scaffold the project, optionally showing a spinner. */
96
128
  async function scaffoldProject(dir, cwd, template, silent) {
97
- const { runInit } = await import("./_init-CbkrE2wq.mjs");
98
- const s = silent ? void 0 : p.spinner();
99
- s?.start(`Creating ${dir}`);
100
- await runInit({
129
+ const { runInit } = await import("./_init-CpISqoR8.mjs");
130
+ await withSpinner(silent, {
131
+ start: `Creating ${dir}`,
132
+ done: "Project created",
133
+ failed: `Could not create ${dir}`
134
+ }, () => runInit({
101
135
  targetDir: cwd,
102
136
  template
103
- });
104
- s?.stop("Project created");
137
+ }));
105
138
  }
106
139
  /** Print post-init instructions. */
107
140
  function printPostInitInfo(cwd, monorepoRoot) {
@@ -117,14 +150,15 @@ async function executeInit(opts, extra) {
117
150
  const cwd = resolveTargetDir(dir);
118
151
  if (!opts.force && await fileExists(path.join(cwd, "agent.ts"))) throw new Error(`${AGENT_ENTRY} already exists in this directory. Use ${styleText("cyanBright", "--force")} to overwrite.`);
119
152
  const template = opts.template ?? "simple";
153
+ const { warn, warnings } = collectWarnings();
120
154
  await scaffoldProject(dir, cwd, template, suppressUi);
121
- const installed = await installDeps(cwd, suppressUi);
155
+ const installed = await installDeps(cwd, warn, suppressUi);
122
156
  let deployed = false;
123
157
  let slug;
124
158
  let url;
125
- if (!installed) log.warn("Skipping publish because dependencies were not installed.");
159
+ if (!installed) warn("Skipping publish because dependencies were not installed.");
126
160
  else if (!opts.skipDeploy) {
127
- const published = await tryPublish(cwd, opts.server);
161
+ const published = await tryPublish(cwd, opts.server, warn);
128
162
  if (published) {
129
163
  deployed = true;
130
164
  slug = published.slug;
@@ -139,6 +173,7 @@ async function executeInit(opts, extra) {
139
173
  };
140
174
  if (slug) data.slug = slug;
141
175
  if (url) data.url = url;
176
+ if (warnings.length > 0) data.warnings = warnings;
142
177
  return ok(data);
143
178
  }
144
179
  //#endregion
package/dist/init.d.ts CHANGED
@@ -5,6 +5,17 @@ type InitData = {
5
5
  deployed: boolean;
6
6
  slug?: string;
7
7
  url?: string;
8
+ /**
9
+ * Diagnostics a human sees as `log.warn` lines: a failed `pnpm install`, a
10
+ * failed publish, the publish skipped because of the former.
11
+ *
12
+ * They have to ride the result for the same reason `PushOutcome.warnings`
13
+ * does — `log.warn` is silenced in JSON mode and JSON mode is AUTO-DETECTED
14
+ * on a pipe, so a scripted `aai init` was told `{ ok: true, deployed: false }`
15
+ * for a project whose dependencies never installed and could not tell that
16
+ * apart from `--skipDeploy`.
17
+ */
18
+ warnings?: string[];
8
19
  };
9
20
  /** Build the command + args for running pnpm, routing through safe-chain when available. */
10
21
  export declare function resolvePnpmCommand(checkSafeChain?: () => Promise<boolean>): Promise<{
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok, t as CliError } from "./_output-CC300DzW.mjs";
2
+ import { a as ok, t as CliError } from "./_output-CKkmWs7i.mjs";
3
3
  import { n as log } from "./_ui-u7T4YooX.mjs";
4
- import { o as updateGlobalConfig, r as readGlobalConfig, t as approveServer } from "./_config-CzwAWOWr.mjs";
5
- import { a as resolveServerUrl } from "./_agent-C8Jk-ZcP.mjs";
4
+ import { o as updateGlobalConfig, r as readGlobalConfig, t as approveServer } from "./_config-D_s09e7g.mjs";
5
+ import { o as resolveServerUrl } from "./_agent-vGW5SBnX.mjs";
6
6
  import { linkConfirmationCode } from "@alexkroman1/aai/utils";
7
7
  import { spawn } from "node:child_process";
8
- import { setTimeout } from "node:timers/promises";
8
+ import { sleep } from "@alexkroman1/aai/internal";
9
9
  import { randomBytes } from "node:crypto";
10
10
  //#region login.ts
11
11
  /**
@@ -101,7 +101,7 @@ async function pollForGrant(fetchFn, serverUrl, code, opts) {
101
101
  if (lastTransportError !== void 0) throw unreachableError(serverUrl, lastTransportError);
102
102
  throw new CliError("login_timeout", "Timed out waiting for the link to be approved in the browser.", "Run `aai login` again and approve the link within five minutes.");
103
103
  }
104
- await setTimeout(opts.intervalMs);
104
+ await sleep(opts.intervalMs);
105
105
  }
106
106
  }
107
107
  function requireTty() {
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { c as writeGlobalConfig, s as updateProjectConfig } from "./_config-CzwAWOWr.mjs";
2
+ import { c as writeGlobalConfig, s as updateProjectConfig } from "./_config-D_s09e7g.mjs";
3
3
  export { updateProjectConfig, writeGlobalConfig as writeConfigHome };