@alexkroman1/aai-cli 13.3.0 → 15.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 (158) hide show
  1. package/dist/{_agent-Clbq3a4h.mjs → _agent-BzUeqOdj.mjs} +32 -9
  2. package/dist/_agent.d.ts +23 -0
  3. package/dist/_artifacts-BJOYGQPp.mjs +21 -0
  4. package/dist/_artifacts.d.ts +16 -0
  5. package/dist/_build-target.d.ts +172 -0
  6. package/dist/{_bundler-DEkjO1d8.mjs → _bundler-DM0d0M7m.mjs} +8 -7
  7. package/dist/_cli-common.d.ts +45 -6
  8. package/dist/{_config-ZY2euhdh.mjs → _config-DYzC6WMD.mjs} +2 -2
  9. package/dist/_dev-env.d.ts +1 -1
  10. package/dist/{_dev-server-C13xuGB1.mjs → _dev-server-BzWB6-4y.mjs} +25 -24
  11. package/dist/_dev-vite-config.d.ts +3 -3
  12. package/dist/_e2e-test-utils.d.ts +1 -1
  13. package/dist/{_init-Ci4QGjp8.mjs → _init-Bsi3DZNJ.mjs} +9 -23
  14. package/dist/{_output-DbJt9gsl.mjs → _output-DBP9Op_d.mjs} +22 -13
  15. package/dist/_output.d.ts +10 -9
  16. package/dist/{_preflight-B2laWPdU.mjs → _preflight-CcAR577V.mjs} +2 -2
  17. package/dist/_resource-commands.d.ts +9 -9
  18. package/dist/_server-common-De0haHr9.mjs +70 -0
  19. package/dist/_server-common.d.ts +20 -1
  20. package/dist/{_slug-api-DlKpj91X.mjs → _slug-api-CGvc2YSQ.mjs} +18 -9
  21. package/dist/_slug-api.d.ts +19 -0
  22. package/dist/{_studio-DTi3EdXQ.mjs → _studio-DnR_BqFp.mjs} +7 -3
  23. package/dist/_studio-commands.d.ts +13 -13
  24. package/dist/{_templates-V4l5sZJy.mjs → _templates-CIlJ3Vay.mjs} +4 -4
  25. package/dist/_templates.d.ts +1 -1
  26. package/dist/{_typecheck-gate-sV4N5F93.mjs → _typecheck-gate-U3jcil8L.mjs} +3 -2
  27. package/dist/_typecheck-gate.d.ts +3 -1
  28. package/dist/{_utils-Dhd058D9.mjs → _utils-D5JGcjiW.mjs} +43 -1
  29. package/dist/_utils.d.ts +35 -0
  30. package/dist/_vercel-output.d.ts +63 -0
  31. package/dist/{_workflow-determinism-C9l8uC2R.mjs → _workflow-determinism-CvpqMpdh.mjs} +18 -26
  32. package/dist/_workflow-determinism.d.ts +3 -3
  33. package/dist/build-BhEaxBPu.mjs +481 -0
  34. package/dist/build.d.ts +23 -10
  35. package/dist/cli.d.ts +1 -2
  36. package/dist/cli.mjs +155 -138
  37. package/dist/{client-bundler-CT-_26c5.mjs → client-bundler-6mTLs6ny.mjs} +5 -5
  38. package/dist/client-bundler.d.ts +1 -1
  39. package/dist/client-bundler.mjs +1 -1
  40. package/dist/{delete-RqlQZ6Y_.mjs → delete-BdFnbnVR.mjs} +4 -4
  41. package/dist/{deploy-B7f3CK7v.mjs → deploy-CGqPU5U-.mjs} +11 -11
  42. package/dist/{dev-DamXieW_.mjs → dev-Bx9gYBHM.mjs} +3 -3
  43. package/dist/{eval-h3DTVfRw.mjs → eval-B3I7FqN9.mjs} +3 -3
  44. package/dist/{init-D-vFrV8h.mjs → init-CFyusRbq.mjs} +48 -20
  45. package/dist/init.d.ts +14 -0
  46. package/dist/{login-CDiemNmC.mjs → login-DaLrPOFg.mjs} +4 -6
  47. package/dist/{logs-DGwPNCzB.mjs → logs-7BRwq0cG.mjs} +21 -14
  48. package/dist/project-config.mjs +1 -1
  49. package/dist/scaffold/CLAUDE.md +155 -76
  50. package/dist/scaffold/package.json +6 -6
  51. package/dist/{secret-V1w7y9-j.mjs → secret-Cjp912yF.mjs} +5 -5
  52. package/dist/secret.d.ts +8 -6
  53. package/dist/start.d.ts +112 -0
  54. package/dist/start.mjs +156 -0
  55. package/dist/{studio-BpMCfUNx.mjs → studio-C_zuRC_z.mjs} +13 -15
  56. package/dist/templates/briefing-desk/agent.eval.test.ts +156 -0
  57. package/dist/templates/call-audit/agent.test.ts +11 -6
  58. package/dist/templates/call-audit/agent.ts +2 -2
  59. package/dist/templates/call-audit/client.tsx +27 -42
  60. package/dist/templates/call-audit/workflows/audit.ts +7 -5
  61. package/dist/templates/call-audit/workflows/ingest.ts +7 -7
  62. package/dist/templates/call-audit/workflows/media.ts +12 -37
  63. package/dist/templates/call-audit/workflows/summarize.ts +8 -8
  64. package/dist/templates/call-audit/workflows/sync-api.ts +3 -3
  65. package/dist/templates/code-interpreter/agent.test.ts +103 -0
  66. package/dist/templates/dispatch-center/agent.test.ts +7 -7
  67. package/dist/templates/dispatch-center/client.tsx +53 -61
  68. package/dist/templates/dispatch-center/shared.ts +0 -8
  69. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +4 -1
  70. package/dist/templates/embedded-assets/agent.eval.test.ts +4 -2
  71. package/dist/templates/health-assistant/agent.eval.test.ts +4 -2
  72. package/dist/templates/infocom-adventure/client.tsx +40 -36
  73. package/dist/templates/link-digest/agent.test.ts +3 -3
  74. package/dist/templates/link-digest/agent.ts +2 -2
  75. package/dist/templates/link-digest/client.tsx +81 -19
  76. package/dist/templates/link-digest/workflows/digest.ts +13 -16
  77. package/dist/templates/math-buddy/agent.test.ts +126 -0
  78. package/dist/templates/night-owl/agent.eval.test.ts +4 -2
  79. package/dist/templates/night-owl/client.tsx +8 -2
  80. package/dist/templates/personal-finance/agent.test.ts +127 -0
  81. package/dist/templates/pipeline-simple/agent.test.ts +2 -2
  82. package/dist/templates/pizza-ordering/client.tsx +5 -4
  83. package/dist/templates/pizza-ordering/shared.ts +3 -8
  84. package/dist/templates/pizza-ordering/tools/add_pizza.ts +3 -2
  85. package/dist/templates/pizza-ordering/tools/place_order.ts +3 -2
  86. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +3 -2
  87. package/dist/templates/pizza-ordering/tools/update_pizza.ts +3 -2
  88. package/dist/templates/pizza-ordering/tools/view_order.ts +3 -2
  89. package/dist/templates/plan-and-execute/agent.test.ts +10 -5
  90. package/dist/templates/plan-and-execute/client.tsx +2 -2
  91. package/dist/templates/podcast-digest/agent.test.ts +20 -11
  92. package/dist/templates/podcast-digest/client.tsx +16 -22
  93. package/dist/templates/podcast-digest/workflows/digest.ts +21 -19
  94. package/dist/templates/podcast-digest/workflows/feeds.ts +61 -33
  95. package/dist/templates/podcast-digest/workflows/slack.ts +7 -7
  96. package/dist/templates/recap-workflow/agent.eval.test.ts +21 -13
  97. package/dist/templates/recap-workflow/agent.test.ts +27 -23
  98. package/dist/templates/recap-workflow/workflows/recap.ts +24 -28
  99. package/dist/templates/redline/agent.eval.test.ts +5 -8
  100. package/dist/templates/redline/agent.test.ts +1 -1
  101. package/dist/templates/redline/client.tsx +36 -34
  102. package/dist/templates/redline/workflows/redline.ts +17 -17
  103. package/dist/templates/research-workflow/agent.eval.test.ts +5 -5
  104. package/dist/templates/research-workflow/agent.test.ts +10 -7
  105. package/dist/templates/research-workflow/workflows/research.ts +28 -30
  106. package/dist/templates/retail/agent.test.ts +17 -15
  107. package/dist/templates/retail/cancel.ts +7 -6
  108. package/dist/templates/retail/client.tsx +39 -58
  109. package/dist/templates/retail/payment.ts +4 -3
  110. package/dist/templates/retail/pending.test.ts +19 -19
  111. package/dist/templates/retail/store.test.ts +5 -5
  112. package/dist/templates/retail/swap.ts +8 -11
  113. package/dist/templates/solo-rpg/agent.eval.test.ts +2 -16
  114. package/dist/templates/solo-rpg/agent.test.ts +12 -12
  115. package/dist/templates/solo-rpg/client.tsx +3 -3
  116. package/dist/templates/spoken-summary/agent.test.ts +9 -9
  117. package/dist/templates/spoken-summary/agent.ts +3 -3
  118. package/dist/templates/spoken-summary/client.tsx +23 -30
  119. package/dist/templates/spoken-summary/workflows/summarize.ts +11 -11
  120. package/dist/templates/spoken-summary/workflows/transcribe.ts +14 -14
  121. package/dist/templates/support-line/agent.ts +8 -0
  122. package/dist/templates/support-line/client.tsx +4 -3
  123. package/dist/templates/support-line/prompts.ts +0 -2
  124. package/dist/templates/transcription-workflow/agent.test.ts +20 -12
  125. package/dist/templates/transcription-workflow/agent.ts +2 -2
  126. package/dist/templates/transcription-workflow/client.tsx +15 -14
  127. package/dist/templates/transcription-workflow/recover.ts +1 -1
  128. package/dist/templates/transcription-workflow/run-panel.tsx +34 -14
  129. package/dist/templates/transcription-workflow/total-latency.tsx +46 -20
  130. package/dist/templates/transcription-workflow/workflows/batch.ts +15 -15
  131. package/dist/templates/transcription-workflow/workflows/downsample.ts +1 -1
  132. package/dist/templates/transcription-workflow/workflows/normalize.ts +15 -19
  133. package/dist/templates/transcription-workflow/workflows/stream.ts +12 -12
  134. package/dist/templates/transcription-workflow/workflows/sync-api.ts +3 -3
  135. package/dist/templates/transcription-workflow/workflows/transcribe.ts +23 -34
  136. package/dist/templates/travel-concierge/agent.eval.test.ts +2 -2
  137. package/dist/templates/travel-concierge/agent.test.ts +15 -7
  138. package/dist/templates/travel-concierge/client.tsx +2 -2
  139. package/dist/templates/travel-concierge/routing.ts +64 -55
  140. package/dist/templates/travel-concierge/shared.ts +10 -14
  141. package/dist/templates/travel-concierge/tools/cancel_action.ts +3 -1
  142. package/dist/templates/travel-concierge/tools/complete_or_escalate.ts +3 -1
  143. package/dist/templates/travel-concierge/tools/confirm_action.ts +3 -1
  144. package/dist/templates/travel-concierge/tools/lookup_booking.ts +4 -3
  145. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -2
  146. package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -2
  147. package/dist/templates/travel-concierge/tools/search_flights.ts +3 -2
  148. package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -2
  149. package/dist/templates/web-researcher/agent.test.ts +130 -0
  150. package/dist/{test-guenJUxi.mjs → test-D032V2cA.mjs} +4 -17
  151. package/dist/typecheck.mjs +1 -1
  152. package/dist/worker-bundler.d.ts +1 -1
  153. package/dist/worker-bundler.mjs +8 -8
  154. package/dist/{workflow-BZyKLkhV.mjs → workflow-CVioyO3V.mjs} +6 -5
  155. package/package.json +9 -4
  156. package/dist/_server-common-BV4_CrP3.mjs +0 -43
  157. package/dist/build-CWyFGe-W.mjs +0 -69
  158. package/dist/scaffold/server.mjs +0 -204
package/dist/build.d.ts CHANGED
@@ -4,32 +4,45 @@
4
4
  * artifact and its failures alike.
5
5
  *
6
6
  * It also LEAVES that artifact on disk, at {@link WORKER_ARTIFACT_REL}, which is
7
- * what makes self-hosting work: `server.mjs` loads the built worker rather than
7
+ * what makes self-hosting work: `aai start` loads the built worker rather than
8
8
  * `agent.ts`, because a tool is discovered by the bundler enumerating `tools/`
9
- * and no un-bundled loader can see that directory. See the scaffold's own
10
- * `server.mjs` and "Self-hosting runs the built worker" in
11
- * `packages/aai-templates/CLAUDE.md`.
9
+ * and no un-bundled loader can see that directory. See `start.ts` and
10
+ * "Self-hosting is the scaffold's default" in `packages/aai-cli/CLAUDE.md`.
11
+ *
12
+ * `--target` decides what else it emits — see `_build-target.ts`.
12
13
  */
14
+ import { type BuildTarget } from "./_build-target.ts";
13
15
  import { type CommandResult } from "./_output.ts";
14
16
  /**
15
17
  * Where the built worker lands, relative to the project root — under `.aai/`,
16
18
  * beside the built client, so one gitignore rule covers every build output.
17
19
  *
18
- * `server.mjs` hardcodes this path: it is a plain `.mjs` file in a user's
19
- * project and may not import from the CLI (which a deployed project does not
20
- * install at all). The pair is covered end-to-end by the `npm start` leg of
21
- * `e2e.test.ts` — the only tier that runs both halves as a user does.
20
+ * `start.ts` imports this constant rather than restating the path, which it
21
+ * could not do while the loader was a `.mjs` file in the user's project. The
22
+ * pair is covered end-to-end by the `npm start` leg of `e2e.test.ts` — the only
23
+ * tier that runs both halves as a user does.
22
24
  */
23
- export declare const WORKER_ARTIFACT_REL: string;
25
+ export { WORKER_ARTIFACT_REL } from "./_artifacts.ts";
24
26
  type BuildData = {
25
27
  name: string;
26
28
  workerBytes: number;
27
29
  /** Absolute path of the worker written — what `npm start` boots. */
28
30
  worker: string;
31
+ /**
32
+ * WHERE the prompt this bundle carries came from — see
33
+ * {@link systemPromptSource}.
34
+ */
35
+ systemPrompt: string;
36
+ /** Which deployment shape this build emitted — see `_build-target.ts`. */
37
+ target: BuildTarget;
29
38
  };
30
39
  export declare function executeBuild(opts: {
31
40
  cwd: string;
32
41
  skipTests?: boolean | undefined;
33
42
  skipTypecheck?: boolean | undefined;
43
+ /**
44
+ * Which deployment shape to emit beside the worker. Absent, it is detected
45
+ * from the host's own build environment — see `resolveBuildTarget`.
46
+ */
47
+ target?: string | undefined;
34
48
  }): Promise<CommandResult<BuildData>>;
35
- export {};
package/dist/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { type ArgsDef, type CommandDef } from "citty";
2
- export declare const mainCommand: CommandDef<ArgsDef>;
1
+ export declare const mainCommand: import("citty").CommandDef<import("citty").ArgsDef>;
package/dist/cli.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { i as installStdoutGuard, n as fail, o as writeLine, r as getOutputMode, t as CliError } from "./_output-DbJt9gsl.mjs";
3
- import { n as log, o as silenceOutput } from "./_ui-DCt4qZrk.mjs";
4
- import { d as resolveCwd, o as errorMessage$1, s as fileExists, t as AGENT_ENTRY, u as readPackageJson } from "./_utils-Dhd058D9.mjs";
2
+ import { i as installStdoutGuard, n as fail, o as writeLine, r as getOutputMode, t as CliError } from "./_output-DBP9Op_d.mjs";
3
+ import { a as parsePort, n as log, o as silenceOutput } from "./_ui-DCt4qZrk.mjs";
4
+ import { c as fileExists, f as readPackageJson, p as resolveCwd, s as errorMessage$1, t as AGENT_ENTRY } from "./_utils-D5JGcjiW.mjs";
5
5
  import { existsSync } from "node:fs";
6
6
  import path from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { isRecord, omitUndefined, plural } from "@alexkroman1/aai/utils";
8
9
  import { defineCommand, runMain, showUsage } from "citty";
9
- import { isRecord } from "@alexkroman1/aai/utils";
10
10
  //#region src/_cli-common.ts
11
11
  /** Shared arg definitions for citty commands. */
12
12
  const sharedArgs = {
@@ -25,6 +25,19 @@ const sharedArgs = {
25
25
  description: "Output JSON (auto-detected in non-TTY)"
26
26
  }
27
27
  };
28
+ /**
29
+ * What every PLATFORM command accepts — the pair, as a group to spread.
30
+ *
31
+ * `sharedArgs` supplies the field VALUES, so each of the twelve credentialed
32
+ * commands still restated the shape (`server: sharedArgs.server, json:
33
+ * sharedArgs.json`). A flag all of them should take is then twelve edits, and
34
+ * `assertKnownArgv` refuses the flag on whichever one was missed — after
35
+ * release. `cli-workflow.ts`'s `workflowArgs` is the same pattern for its group.
36
+ */
37
+ const platformArgs = {
38
+ server: sharedArgs.server,
39
+ json: sharedArgs.json
40
+ };
28
41
  /** Flags citty handles itself, so no command declares them. */
29
42
  const BUILTIN_FLAGS = /* @__PURE__ */ new Set([
30
43
  "help",
@@ -106,31 +119,42 @@ function commandPath(cmd, parent) {
106
119
  return named.startsWith("aai") ? named : `aai ${named}`.trim();
107
120
  }
108
121
  /**
109
- * Unknown flags in `argv` for whichever (possibly nested) subcommand it
110
- * selects `[]` when everything is declared.
122
+ * Walk the real command tree for `argv` and report everything the pre-parse
123
+ * guards in `cli.ts` need: which command it selects, what that command
124
+ * declares, and whether a token mistyped a subcommand.
111
125
  *
112
- * Walks the real command tree rather than re-listing flags, so this cannot
113
- * drift from what the commands accept. An unknown SUBCOMMAND is not reported:
114
- * citty already answers that with usage text and a non-zero exit.
126
+ * ONE walk, because there used to be two this one and a copy in `cli.ts`,
127
+ * each with its own `Resolvable` narrowing, whose only difference was the
128
+ * terminal action. The copies also had an ORDERING dependency nothing
129
+ * enforced: the flag guard reports nothing for a mistyped subcommand (the
130
+ * flags would be matched against the wrong command's definition), which is
131
+ * only safe because the command guard ran first. Answering both from one
132
+ * result removes the ordering rather than documenting it.
115
133
  */
116
- async function unknownFlagsForArgv(root, argv) {
134
+ async function resolveArgv(root, argv) {
117
135
  let cmd = root;
136
+ const named = ["aai"];
118
137
  let i = 0;
119
138
  for (; i < argv.length; i++) {
120
139
  const token = argv[i];
121
140
  if (token === void 0 || token.startsWith("-")) break;
122
141
  const subCommands = await resolve(cmd.subCommands);
123
- const next = subCommands?.[token];
124
- if (next === void 0) {
125
- if (subCommands && Object.keys(subCommands).length > 0) return [];
126
- break;
127
- }
128
- const resolved = await resolve(next);
129
- if (resolved === void 0) break;
130
- cmd = resolved;
142
+ if (!subCommands || Object.keys(subCommands).length === 0) break;
143
+ const next = await resolve(subCommands[token]);
144
+ if (next === void 0) return {
145
+ named,
146
+ unknownCommand: token,
147
+ argsDef: await resolve(cmd.args) ?? {},
148
+ rest: []
149
+ };
150
+ cmd = next;
151
+ named.push(token);
131
152
  }
132
- const argsDef = await resolve(cmd.args) ?? {};
133
- return findUnknownFlags(argv.slice(i), argsDef);
153
+ return {
154
+ named,
155
+ argsDef: await resolve(cmd.args) ?? {},
156
+ rest: argv.slice(i)
157
+ };
134
158
  }
135
159
  /** Shared command setup: resolve cwd, optionally require agent.ts. */
136
160
  async function setup(opts) {
@@ -267,13 +291,12 @@ const secretPut = defineExec({
267
291
  description: "Secret name. The VALUE is not an argument — pipe it in (`printf %s \"$VALUE\" | aai secret put NAME`), or be prompted, masked, when stdin is a terminal",
268
292
  required: true
269
293
  },
270
- server: sharedArgs.server,
271
- json: sharedArgs.json
294
+ ...platformArgs
272
295
  },
273
296
  cwd: "any",
274
297
  async run({ args, mode, cwd }) {
275
298
  refuseValueInArgv(args._);
276
- const { executeSecretPut, resolveSecretValue } = await import("./secret-V1w7y9-j.mjs");
299
+ const { executeSecretPut, resolveSecretValue } = await import("./secret-Cjp912yF.mjs");
277
300
  const value = await resolveSecretValue(args.name, mode);
278
301
  return executeSecretPut(cwd, args.name, value, args.server);
279
302
  }
@@ -289,12 +312,11 @@ const secretDelete = defineExec({
289
312
  description: "Secret name",
290
313
  required: true
291
314
  },
292
- server: sharedArgs.server,
293
- json: sharedArgs.json
315
+ ...platformArgs
294
316
  },
295
317
  cwd: "any",
296
318
  async run({ args, cwd }) {
297
- const { executeSecretDelete } = await import("./secret-V1w7y9-j.mjs");
319
+ const { executeSecretDelete } = await import("./secret-Cjp912yF.mjs");
298
320
  return executeSecretDelete(cwd, args.name, args.server);
299
321
  }
300
322
  });
@@ -303,13 +325,10 @@ const secretList = defineExec({
303
325
  name: "list",
304
326
  description: "List all secrets"
305
327
  },
306
- args: {
307
- server: sharedArgs.server,
308
- json: sharedArgs.json
309
- },
328
+ args: { ...platformArgs },
310
329
  cwd: "any",
311
330
  async run({ args, cwd }) {
312
- const { executeSecretList } = await import("./secret-V1w7y9-j.mjs");
331
+ const { executeSecretList } = await import("./secret-Cjp912yF.mjs");
313
332
  return executeSecretList(cwd, args.server);
314
333
  }
315
334
  });
@@ -344,12 +363,11 @@ const logs = defineExec({
344
363
  alias: "f",
345
364
  description: "Keep printing new output"
346
365
  },
347
- server: sharedArgs.server,
348
- json: sharedArgs.json
366
+ ...platformArgs
349
367
  },
350
368
  cwd: "any",
351
369
  async run({ args, cwd }) {
352
- const { executeLogs } = await import("./logs-DGwPNCzB.mjs");
370
+ const { executeLogs } = await import("./logs-7BRwq0cG.mjs");
353
371
  return executeLogs(resolveDirArg(cwd, args.dir), {
354
372
  server: args.server,
355
373
  follow: args.follow
@@ -374,13 +392,10 @@ const list = defineExec({
374
392
  name: "list",
375
393
  description: "List your studio projects"
376
394
  },
377
- args: {
378
- server: sharedArgs.server,
379
- json: sharedArgs.json
380
- },
395
+ args: { ...platformArgs },
381
396
  cwd: "any",
382
397
  async run({ args, cwd }) {
383
- const { executeList } = await import("./studio-BpMCfUNx.mjs");
398
+ const { executeList } = await import("./studio-C_zuRC_z.mjs");
384
399
  return executeList({
385
400
  cwd,
386
401
  server: args.server
@@ -408,12 +423,11 @@ const pull = defineExec({
408
423
  alias: "f",
409
424
  description: "Overwrite files in a non-empty directory"
410
425
  },
411
- server: sharedArgs.server,
412
- json: sharedArgs.json
426
+ ...platformArgs
413
427
  },
414
428
  cwd: "any",
415
429
  async run({ args, cwd }) {
416
- const { executePull } = await import("./studio-BpMCfUNx.mjs");
430
+ const { executePull } = await import("./studio-C_zuRC_z.mjs");
417
431
  return executePull({
418
432
  cwd,
419
433
  project: args.project,
@@ -430,12 +444,11 @@ const push = defineExec({
430
444
  },
431
445
  args: {
432
446
  force: forceArg,
433
- server: sharedArgs.server,
434
- json: sharedArgs.json
447
+ ...platformArgs
435
448
  },
436
449
  cwd: "agent",
437
450
  async run({ args, cwd }) {
438
- const { executePush } = await import("./studio-BpMCfUNx.mjs");
451
+ const { executePush } = await import("./studio-C_zuRC_z.mjs");
439
452
  return executePush({
440
453
  cwd,
441
454
  server: args.server,
@@ -450,8 +463,7 @@ const publish = defineExec({
450
463
  },
451
464
  args: {
452
465
  force: forceArg,
453
- server: sharedArgs.server,
454
- json: sharedArgs.json,
466
+ ...platformArgs,
455
467
  skipTypecheck: {
456
468
  type: "boolean",
457
469
  description: "Skip type checking before publishing"
@@ -459,7 +471,7 @@ const publish = defineExec({
459
471
  },
460
472
  cwd: "agent",
461
473
  async run({ args, cwd }) {
462
- const { executePublish } = await import("./studio-BpMCfUNx.mjs");
474
+ const { executePublish } = await import("./studio-C_zuRC_z.mjs");
463
475
  return executePublish({
464
476
  cwd,
465
477
  server: args.server,
@@ -497,7 +509,7 @@ const workflowToken = {
497
509
  * and until this flag existed there was no way to say so: every verb resolved a
498
510
  * platform origin plus a PUBLISHED slug, so an undeployed project was told to
499
511
  * `aai publish` while the runs it asked about were answering on localhost. A
500
- * dev server also has no slug segment at all (`createServer` mounts the API on
512
+ * dev server also has no slug segment at all (`createRuntimeServer` mounts the API on
501
513
  * the origin), so a different `--server` could not express it either.
502
514
  *
503
515
  * Separate from `--server` rather than a mode of it, because the two carry
@@ -521,8 +533,7 @@ const runIdArg = {
521
533
  * without `--token`.
522
534
  */
523
535
  const workflowArgs = {
524
- server: sharedArgs.server,
525
- json: sharedArgs.json,
536
+ ...platformArgs,
526
537
  token: workflowToken,
527
538
  agent: workflowAgent
528
539
  };
@@ -532,6 +543,19 @@ const workflowArgs = {
532
543
  * never edited still names a deployed agent whose runs are worth asking about.
533
544
  */
534
545
  const WORKFLOW_CWD = "any";
546
+ /**
547
+ * The group flags, forwarded.
548
+ *
549
+ * The declaration side is DRY (`workflowArgs`) and the forwarding side was not:
550
+ * four hand-copied `{ server, token, agent }` triples, in the module whose own
551
+ * doc argues that "four hand-copied triples is how one of them ends up without
552
+ * `--token`". A fifth group flag is one edit here rather than four below.
553
+ */
554
+ const workflowOpts = (args) => ({
555
+ server: args.server,
556
+ token: args.token,
557
+ agent: args.agent
558
+ });
535
559
  const workflowList = defineExec({
536
560
  meta: {
537
561
  name: "list",
@@ -540,12 +564,8 @@ const workflowList = defineExec({
540
564
  args: workflowArgs,
541
565
  cwd: WORKFLOW_CWD,
542
566
  async run({ args, cwd }) {
543
- const { executeWorkflowList } = await import("./workflow-BZyKLkhV.mjs");
544
- return executeWorkflowList(cwd, {
545
- server: args.server,
546
- token: args.token,
547
- agent: args.agent
548
- });
567
+ const { executeWorkflowList } = await import("./workflow-CVioyO3V.mjs");
568
+ return executeWorkflowList(cwd, workflowOpts(args));
549
569
  }
550
570
  });
551
571
  const workflowRuns = defineExec({
@@ -567,13 +587,11 @@ const workflowRuns = defineExec({
567
587
  },
568
588
  cwd: WORKFLOW_CWD,
569
589
  async run({ args, cwd }) {
570
- const { executeWorkflowRuns } = await import("./workflow-BZyKLkhV.mjs");
590
+ const { executeWorkflowRuns } = await import("./workflow-CVioyO3V.mjs");
571
591
  const limit = args.limit === void 0 ? void 0 : Number(args.limit);
572
592
  if (limit !== void 0 && !Number.isFinite(limit)) throw new CliError("bad_limit", "--limit must be a number");
573
593
  return executeWorkflowRuns(cwd, args.workflow, {
574
- server: args.server,
575
- token: args.token,
576
- agent: args.agent,
594
+ ...workflowOpts(args),
577
595
  limit
578
596
  });
579
597
  }
@@ -589,12 +607,8 @@ const workflowShow = defineExec({
589
607
  },
590
608
  cwd: WORKFLOW_CWD,
591
609
  async run({ args, cwd }) {
592
- const { executeWorkflowShow } = await import("./workflow-BZyKLkhV.mjs");
593
- return executeWorkflowShow(cwd, args.runId, {
594
- server: args.server,
595
- token: args.token,
596
- agent: args.agent
597
- });
610
+ const { executeWorkflowShow } = await import("./workflow-CVioyO3V.mjs");
611
+ return executeWorkflowShow(cwd, args.runId, workflowOpts(args));
598
612
  }
599
613
  });
600
614
  const workflowCancel = defineExec({
@@ -608,12 +622,8 @@ const workflowCancel = defineExec({
608
622
  },
609
623
  cwd: WORKFLOW_CWD,
610
624
  async run({ args, cwd }) {
611
- const { executeWorkflowCancel } = await import("./workflow-BZyKLkhV.mjs");
612
- return executeWorkflowCancel(cwd, args.runId, {
613
- server: args.server,
614
- token: args.token,
615
- agent: args.agent
616
- });
625
+ const { executeWorkflowCancel } = await import("./workflow-CVioyO3V.mjs");
626
+ return executeWorkflowCancel(cwd, args.runId, workflowOpts(args));
617
627
  }
618
628
  });
619
629
  const workflow = defineCommand({
@@ -683,7 +693,7 @@ const init = defineExec({
683
693
  template: {
684
694
  type: "string",
685
695
  alias: "t",
686
- description: "Template to use (run `aai templates` for the list)"
696
+ description: "Template to use (prompted when omitted)"
687
697
  },
688
698
  server: sharedArgs.server,
689
699
  yes: sharedArgs.yes,
@@ -695,7 +705,7 @@ const init = defineExec({
695
705
  },
696
706
  cwd: "none",
697
707
  async run({ args, mode }) {
698
- const { executeInit } = await import("./init-D-vFrV8h.mjs");
708
+ const { executeInit } = await import("./init-CFyusRbq.mjs");
699
709
  return executeInit({
700
710
  dir: args.dir,
701
711
  force: args.force,
@@ -726,7 +736,7 @@ const dev = defineExec({
726
736
  },
727
737
  cwd: "agent",
728
738
  async run({ args, cwd }) {
729
- const { executeDev } = await import("./dev-DamXieW_.mjs");
739
+ const { executeDev } = await import("./dev-Bx9gYBHM.mjs");
730
740
  return executeDev({
731
741
  cwd,
732
742
  port: args.port,
@@ -734,6 +744,35 @@ const dev = defineExec({
734
744
  });
735
745
  }
736
746
  });
747
+ const start = defineExec({
748
+ meta: {
749
+ name: "start",
750
+ description: "Serve the built agent (production)"
751
+ },
752
+ args: {
753
+ port: {
754
+ type: "string",
755
+ alias: "p",
756
+ description: "Port to listen on"
757
+ },
758
+ host: {
759
+ type: "string",
760
+ description: "Address to bind (default: loopback)"
761
+ },
762
+ json: sharedArgs.json
763
+ },
764
+ cwd: "agent",
765
+ async run({ args, cwd }) {
766
+ const { executeStart } = await import("./start.mjs");
767
+ return executeStart({
768
+ cwd,
769
+ ...omitUndefined({
770
+ port: args.port === void 0 ? void 0 : parsePort(args.port),
771
+ host: args.host?.trim() || void 0
772
+ })
773
+ });
774
+ }
775
+ });
737
776
  const test = defineExec({
738
777
  meta: {
739
778
  name: "test",
@@ -748,7 +787,7 @@ const test = defineExec({
748
787
  },
749
788
  cwd: "agent",
750
789
  async run({ args, cwd }) {
751
- const { executeTest } = await import("./test-guenJUxi.mjs");
790
+ const { executeTest } = await import("./test-D032V2cA.mjs");
752
791
  return executeTest(cwd, { all: args.all === true });
753
792
  }
754
793
  });
@@ -760,7 +799,7 @@ const evalCommand = defineExec({
760
799
  args: { json: sharedArgs.json },
761
800
  cwd: "agent",
762
801
  async run({ cwd }) {
763
- const { executeEval } = await import("./eval-h3DTVfRw.mjs");
802
+ const { executeEval } = await import("./eval-B3I7FqN9.mjs");
764
803
  return executeEval(cwd);
765
804
  }
766
805
  });
@@ -778,15 +817,20 @@ const build = defineExec({
778
817
  skipTypecheck: {
779
818
  type: "boolean",
780
819
  description: "Skip type checking before build"
820
+ },
821
+ target: {
822
+ type: "string",
823
+ description: "Deployment shape to emit (node, vercel; default: detected)"
781
824
  }
782
825
  },
783
826
  cwd: "agent",
784
827
  async run({ args, cwd }) {
785
- const { executeBuild } = await import("./build-CWyFGe-W.mjs");
828
+ const { executeBuild } = await import("./build-BhEaxBPu.mjs");
786
829
  return executeBuild({
787
830
  cwd,
788
831
  skipTests: args.skipTests,
789
- skipTypecheck: args.skipTypecheck
832
+ skipTypecheck: args.skipTypecheck,
833
+ target: args.target
790
834
  });
791
835
  }
792
836
  });
@@ -797,8 +841,7 @@ const deploy = defineExec({
797
841
  hidden: true
798
842
  },
799
843
  args: {
800
- server: sharedArgs.server,
801
- json: sharedArgs.json,
844
+ ...platformArgs,
802
845
  allowPreviewSlug: {
803
846
  type: "boolean",
804
847
  description: "Permit a `-preview`-suffixed slug (reserved for studio auto-previews; studio-internal — a slug you claim this way is subject to the preview reaper)"
@@ -810,7 +853,7 @@ const deploy = defineExec({
810
853
  },
811
854
  cwd: "agent",
812
855
  async run({ args, cwd }) {
813
- const { executeDeploy } = await import("./deploy-B7f3CK7v.mjs");
856
+ const { executeDeploy } = await import("./deploy-CGqPU5U-.mjs");
814
857
  return executeDeploy({
815
858
  cwd,
816
859
  server: args.server,
@@ -824,13 +867,10 @@ const del = defineExec({
824
867
  name: "delete",
825
868
  description: "Delete the studio project and its deployed agents"
826
869
  },
827
- args: {
828
- server: sharedArgs.server,
829
- json: sharedArgs.json
830
- },
870
+ args: { ...platformArgs },
831
871
  cwd: "any",
832
872
  async run({ args, cwd }) {
833
- const { executeDelete } = await import("./delete-RqlQZ6Y_.mjs");
873
+ const { executeDelete } = await import("./delete-BdFnbnVR.mjs");
834
874
  return executeDelete({
835
875
  cwd,
836
876
  server: args.server
@@ -842,13 +882,10 @@ const login = defineExec({
842
882
  name: "login",
843
883
  description: "Link your signed-in browser account and save your API key"
844
884
  },
845
- args: {
846
- server: sharedArgs.server,
847
- json: sharedArgs.json
848
- },
885
+ args: { ...platformArgs },
849
886
  cwd: "none",
850
887
  async run({ args }) {
851
- const { executeLogin } = await import("./login-CDiemNmC.mjs");
888
+ const { executeLogin } = await import("./login-DaLrPOFg.mjs");
852
889
  return executeLogin({ server: args.server });
853
890
  }
854
891
  });
@@ -860,7 +897,7 @@ const templates = defineExec({
860
897
  args: { json: sharedArgs.json },
861
898
  cwd: "none",
862
899
  async run({ mode }) {
863
- const { listTemplates } = await import("./_templates-V4l5sZJy.mjs");
900
+ const { listTemplates } = await import("./_templates-CIlJ3Vay.mjs");
864
901
  const names = await listTemplates();
865
902
  if (mode === "human") {
866
903
  for (const name of names) log.message(name);
@@ -877,6 +914,7 @@ const mainCommand = defineCommand({
877
914
  subCommands: {
878
915
  init,
879
916
  dev,
917
+ start,
880
918
  test,
881
919
  eval: evalCommand,
882
920
  build,
@@ -955,57 +993,36 @@ if (process.env.VITEST !== "true") {
955
993
  process.exit(1);
956
994
  };
957
995
  /**
958
- * Resolve a citty `Resolvable` field. The cast is `Resolvable<T>` admitting
959
- * `T` itself, so `typeof value === "function"` narrows to `T & Function`
960
- * alongside the two thunk signatures; `_cli-common.ts`'s copy does the same.
961
- */
962
- const resolveField = async (value) => typeof value === "function" ? await value() : await value;
963
- /**
964
- * Answer an unknown SUBCOMMAND here rather than leaving it to citty.
996
+ * Refuse a mistyped command or an unrecognized flag instead of letting
997
+ * either through both read off ONE walk of the command tree.
965
998
  *
966
- * citty throws `Unknown command ${cyan(name)}` and its own catch writes that
967
- * message with `console.error` — colour escapes and all, whatever the output
968
- * mode and whether or not stderr is a terminal AFTER `showUsage` has
969
- * already emitted the result line. So `aai deploy-now | jq` produced an
970
- * envelope that named `aai` instead of the token the user typed, plus an
971
- * ANSI-studded sentence on stderr that no JSON consumer asked for. Reported
972
- * here instead: the envelope names the command, and nothing colours a pipe.
999
+ * An unknown SUBCOMMAND is answered here rather than by citty, which throws
1000
+ * `Unknown command ${cyan(name)}` and writes it with `console.error` —
1001
+ * colour escapes and all, whatever the output mode and whether or not stderr
1002
+ * is a terminal — AFTER `showUsage` has already emitted the result line. So
1003
+ * `aai deploy-now | jq` produced an envelope that named `aai` instead of the
1004
+ * token the user typed, plus an ANSI-studded sentence on stderr that no JSON
1005
+ * consumer asked for. Reported here instead: the envelope names the command,
1006
+ * and nothing colours a pipe.
973
1007
  *
974
- * The tree walk is the same one `unknownFlagsForArgv` does in
975
- * `_cli-common.ts`, which cannot report this case (it returns `[]` for it,
976
- * because the flags would be matched against the wrong command). Worth
977
- * hoisting into that module next to it.
978
- */
979
- const assertKnownCommand = async () => {
980
- let cmd = mainCommand;
981
- const named = ["aai"];
982
- for (const token of process.argv.slice(2)) {
983
- if (token.startsWith("-")) return;
984
- const subCommands = await resolveField(cmd.subCommands);
985
- if (!subCommands || Object.keys(subCommands).length === 0) return;
986
- const next = await resolveField(subCommands[token]);
987
- if (next === void 0) {
988
- await reportAndExit(`Unknown command: ${token}`, `Run \`${named.join(" ")} --help\` to see the commands it accepts.`);
989
- return;
990
- }
991
- cmd = next;
992
- named.push(token);
993
- }
994
- };
995
- /**
996
- * Refuse an unrecognized flag instead of ignoring it.
1008
+ * An unknown FLAG is refused because citty drops one silently, so
1009
+ * `aai push --serverr=http://x` exited 0 having pushed to the DEFAULT server.
1010
+ * `--server` decides where the API key and secret values go, so a typo that
1011
+ * quietly retargets it is worth failing on.
997
1012
  *
998
- * citty drops one silently, so `aai push --serverr=http://x` exited 0 having
999
- * pushed to the DEFAULT server. `--server` decides where the API key and
1000
- * secret values go, so a typo that quietly retargets it is worth failing on.
1013
+ * The command check comes first because a flag can only be judged against
1014
+ * the right command's `argsDef` which is why `resolveArgv` reports the two
1015
+ * together instead of leaving the order to this call site.
1001
1016
  */
1002
- const assertKnownFlags = async () => {
1003
- const unknown = await unknownFlagsForArgv(mainCommand, process.argv.slice(2));
1017
+ const assertKnownArgv = async () => {
1018
+ const { named, unknownCommand, argsDef, rest } = await resolveArgv(mainCommand, process.argv.slice(2));
1019
+ if (unknownCommand !== void 0) await reportAndExit(`Unknown command: ${unknownCommand}`, `Run \`${named.join(" ")} --help\` to see the commands it accepts.`);
1020
+ const unknown = findUnknownFlags(rest, argsDef);
1004
1021
  if (unknown.length === 0) return;
1005
- const label = `Unknown ${unknown.length === 1 ? "option" : "options"}: ${unknown.join(", ")}`;
1022
+ const label = `Unknown ${plural(unknown.length, "option")}: ${unknown.join(", ")}`;
1006
1023
  await reportAndExit(label, "Run `aai <command> --help` to see the options it accepts.");
1007
1024
  };
1008
- runDefault().then(assertKnownCommand).then(assertKnownFlags).then(() => runMain(mainCommand, { showUsage: usageForMode })).catch((err) => {
1025
+ runDefault().then(assertKnownArgv).then(() => runMain(mainCommand, { showUsage: usageForMode })).catch((err) => {
1009
1026
  log.error(errorMessage$1(err));
1010
1027
  process.exitCode = 1;
1011
1028
  });
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { o as errorMessage$1, s as fileExists } from "./_utils-Dhd058D9.mjs";
2
+ import { c as fileExists, s as errorMessage$1 } from "./_utils-D5JGcjiW.mjs";
3
3
  import { n as withPreservedNodeEnv, t as DEDUPED_PEERS } from "./_vite-env-kejF0p2L.mjs";
4
4
  import { existsSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import path from "node:path";
@@ -81,10 +81,10 @@ const DEFAULT_OUT_DIR = ".aai/client";
81
81
  * @internal — build hook for aai-server/the studio; not a supported public
82
82
  * API and not covered by semver.
83
83
  */
84
- async function buildClient(cwd, opts = {}) {
84
+ async function buildClient(cwd, options = {}) {
85
85
  const clientEntry = path.join(cwd, "client.tsx");
86
86
  if (!await fileExists(clientEntry)) return {};
87
- const outDir = opts.outDir ?? DEFAULT_OUT_DIR;
87
+ const outDir = options.outDir ?? DEFAULT_OUT_DIR;
88
88
  const clientDir = path.join(cwd, outDir);
89
89
  let cleanupHtml = () => {};
90
90
  try {
@@ -93,8 +93,8 @@ async function buildClient(cwd, opts = {}) {
93
93
  root: cwd,
94
94
  base: "./",
95
95
  logLevel: "silent",
96
- ...opts.configFile === false && { configFile: false },
97
- ...omitUndefined({ plugins: opts.plugins }),
96
+ ...options.configFile === false && { configFile: false },
97
+ ...omitUndefined({ plugins: options.plugins }),
98
98
  resolve: { dedupe: DEDUPED_PEERS },
99
99
  build: {
100
100
  outDir,
@@ -27,4 +27,4 @@ export type BuildClientOptions = {
27
27
  * @internal — build hook for aai-server/the studio; not a supported public
28
28
  * API and not covered by semver.
29
29
  */
30
- export declare function buildClient(cwd: string, opts?: BuildClientOptions): Promise<Record<string, string>>;
30
+ export declare function buildClient(cwd: string, options?: BuildClientOptions): Promise<Record<string, string>>;
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { t as buildClient } from "./client-bundler-CT-_26c5.mjs";
2
+ import { t as buildClient } from "./client-bundler-6mTLs6ny.mjs";
3
3
  export { buildClient };