@alexkroman1/aai-cli 13.3.0 → 14.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 (134) hide show
  1. package/dist/{_agent-Clbq3a4h.mjs → _agent-BzUeqOdj.mjs} +32 -9
  2. package/dist/_agent.d.ts +23 -0
  3. package/dist/{_bundler-DEkjO1d8.mjs → _bundler-DolUCMxu.mjs} +8 -7
  4. package/dist/_cli-common.d.ts +45 -6
  5. package/dist/{_config-ZY2euhdh.mjs → _config-DYzC6WMD.mjs} +2 -2
  6. package/dist/_dev-env.d.ts +1 -1
  7. package/dist/{_dev-server-C13xuGB1.mjs → _dev-server-CSMqF8PN.mjs} +20 -22
  8. package/dist/_dev-vite-config.d.ts +3 -3
  9. package/dist/{_init-Ci4QGjp8.mjs → _init-CQ8idAwo.mjs} +9 -23
  10. package/dist/{_output-DbJt9gsl.mjs → _output-DBP9Op_d.mjs} +22 -13
  11. package/dist/_output.d.ts +10 -9
  12. package/dist/{_preflight-B2laWPdU.mjs → _preflight-CcAR577V.mjs} +2 -2
  13. package/dist/_resource-commands.d.ts +9 -9
  14. package/dist/{_server-common-BV4_CrP3.mjs → _server-common-vILJp3it.mjs} +1 -1
  15. package/dist/{_slug-api-DlKpj91X.mjs → _slug-api-CGvc2YSQ.mjs} +18 -9
  16. package/dist/_slug-api.d.ts +19 -0
  17. package/dist/{_studio-DTi3EdXQ.mjs → _studio-DnR_BqFp.mjs} +7 -3
  18. package/dist/_studio-commands.d.ts +13 -13
  19. package/dist/{_templates-V4l5sZJy.mjs → _templates-CK4oKoeX.mjs} +3 -3
  20. package/dist/{_typecheck-gate-sV4N5F93.mjs → _typecheck-gate-U3jcil8L.mjs} +3 -2
  21. package/dist/_typecheck-gate.d.ts +3 -1
  22. package/dist/{_utils-Dhd058D9.mjs → _utils-D5JGcjiW.mjs} +43 -1
  23. package/dist/_utils.d.ts +35 -0
  24. package/dist/{_workflow-determinism-C9l8uC2R.mjs → _workflow-determinism-CvpqMpdh.mjs} +18 -26
  25. package/dist/_workflow-determinism.d.ts +3 -3
  26. package/dist/{build-CWyFGe-W.mjs → build-Mxk8gWvX.mjs} +46 -7
  27. package/dist/build.d.ts +5 -0
  28. package/dist/cli.d.ts +1 -2
  29. package/dist/cli.mjs +117 -135
  30. package/dist/{client-bundler-CT-_26c5.mjs → client-bundler-BJgREAh6.mjs} +1 -1
  31. package/dist/client-bundler.mjs +1 -1
  32. package/dist/{delete-RqlQZ6Y_.mjs → delete-BdFnbnVR.mjs} +4 -4
  33. package/dist/{deploy-B7f3CK7v.mjs → deploy-uAJ4NukN.mjs} +11 -11
  34. package/dist/{dev-DamXieW_.mjs → dev-DApPSaE_.mjs} +3 -3
  35. package/dist/{eval-h3DTVfRw.mjs → eval-BK47A_K5.mjs} +3 -3
  36. package/dist/{init-D-vFrV8h.mjs → init-DukDxECd.mjs} +11 -19
  37. package/dist/{login-CDiemNmC.mjs → login-DaLrPOFg.mjs} +4 -6
  38. package/dist/{logs-DGwPNCzB.mjs → logs-7BRwq0cG.mjs} +21 -14
  39. package/dist/project-config.mjs +1 -1
  40. package/dist/scaffold/CLAUDE.md +84 -56
  41. package/dist/scaffold/package.json +4 -4
  42. package/dist/scaffold/server.mjs +129 -25
  43. package/dist/{secret-V1w7y9-j.mjs → secret-Cjp912yF.mjs} +5 -5
  44. package/dist/secret.d.ts +8 -6
  45. package/dist/{studio-BpMCfUNx.mjs → studio-CpHlNHUZ.mjs} +13 -15
  46. package/dist/templates/call-audit/agent.test.ts +11 -6
  47. package/dist/templates/call-audit/agent.ts +2 -2
  48. package/dist/templates/call-audit/client.tsx +27 -42
  49. package/dist/templates/call-audit/workflows/audit.ts +7 -5
  50. package/dist/templates/call-audit/workflows/ingest.ts +7 -7
  51. package/dist/templates/call-audit/workflows/media.ts +12 -37
  52. package/dist/templates/call-audit/workflows/summarize.ts +8 -8
  53. package/dist/templates/call-audit/workflows/sync-api.ts +3 -3
  54. package/dist/templates/dispatch-center/agent.test.ts +7 -7
  55. package/dist/templates/dispatch-center/client.tsx +53 -61
  56. package/dist/templates/dispatch-center/shared.ts +0 -8
  57. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +4 -1
  58. package/dist/templates/embedded-assets/agent.eval.test.ts +4 -2
  59. package/dist/templates/health-assistant/agent.eval.test.ts +4 -2
  60. package/dist/templates/infocom-adventure/client.tsx +40 -36
  61. package/dist/templates/link-digest/agent.test.ts +3 -3
  62. package/dist/templates/link-digest/agent.ts +2 -2
  63. package/dist/templates/link-digest/client.tsx +27 -17
  64. package/dist/templates/link-digest/workflows/digest.ts +13 -16
  65. package/dist/templates/night-owl/agent.eval.test.ts +4 -2
  66. package/dist/templates/night-owl/client.tsx +8 -2
  67. package/dist/templates/pipeline-simple/agent.test.ts +2 -2
  68. package/dist/templates/pizza-ordering/client.tsx +5 -4
  69. package/dist/templates/pizza-ordering/shared.ts +3 -8
  70. package/dist/templates/pizza-ordering/tools/add_pizza.ts +3 -2
  71. package/dist/templates/pizza-ordering/tools/place_order.ts +3 -2
  72. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +3 -2
  73. package/dist/templates/pizza-ordering/tools/update_pizza.ts +3 -2
  74. package/dist/templates/pizza-ordering/tools/view_order.ts +3 -2
  75. package/dist/templates/plan-and-execute/agent.test.ts +10 -5
  76. package/dist/templates/plan-and-execute/client.tsx +2 -2
  77. package/dist/templates/podcast-digest/agent.test.ts +20 -11
  78. package/dist/templates/podcast-digest/client.tsx +16 -22
  79. package/dist/templates/podcast-digest/workflows/digest.ts +21 -19
  80. package/dist/templates/podcast-digest/workflows/feeds.ts +61 -33
  81. package/dist/templates/podcast-digest/workflows/slack.ts +7 -7
  82. package/dist/templates/recap-workflow/agent.eval.test.ts +21 -13
  83. package/dist/templates/recap-workflow/agent.test.ts +27 -23
  84. package/dist/templates/recap-workflow/workflows/recap.ts +24 -28
  85. package/dist/templates/redline/agent.eval.test.ts +5 -8
  86. package/dist/templates/redline/agent.test.ts +1 -1
  87. package/dist/templates/redline/client.tsx +36 -34
  88. package/dist/templates/redline/workflows/redline.ts +17 -17
  89. package/dist/templates/research-workflow/agent.eval.test.ts +5 -5
  90. package/dist/templates/research-workflow/agent.test.ts +10 -7
  91. package/dist/templates/research-workflow/workflows/research.ts +28 -30
  92. package/dist/templates/retail/agent.test.ts +17 -15
  93. package/dist/templates/retail/cancel.ts +7 -6
  94. package/dist/templates/retail/client.tsx +39 -58
  95. package/dist/templates/retail/payment.ts +4 -3
  96. package/dist/templates/retail/pending.test.ts +19 -19
  97. package/dist/templates/retail/store.test.ts +5 -5
  98. package/dist/templates/retail/swap.ts +8 -11
  99. package/dist/templates/solo-rpg/agent.eval.test.ts +2 -16
  100. package/dist/templates/solo-rpg/agent.test.ts +12 -12
  101. package/dist/templates/solo-rpg/client.tsx +3 -3
  102. package/dist/templates/spoken-summary/agent.test.ts +9 -9
  103. package/dist/templates/spoken-summary/agent.ts +3 -3
  104. package/dist/templates/spoken-summary/client.tsx +23 -30
  105. package/dist/templates/spoken-summary/workflows/summarize.ts +11 -11
  106. package/dist/templates/spoken-summary/workflows/transcribe.ts +14 -14
  107. package/dist/templates/support-line/client.tsx +4 -3
  108. package/dist/templates/support-line/prompts.ts +0 -2
  109. package/dist/templates/transcription-workflow/agent.test.ts +20 -12
  110. package/dist/templates/transcription-workflow/agent.ts +2 -2
  111. package/dist/templates/transcription-workflow/client.tsx +15 -14
  112. package/dist/templates/transcription-workflow/recover.ts +1 -1
  113. package/dist/templates/transcription-workflow/run-panel.tsx +34 -14
  114. package/dist/templates/transcription-workflow/total-latency.tsx +46 -20
  115. package/dist/templates/transcription-workflow/workflows/batch.ts +15 -15
  116. package/dist/templates/transcription-workflow/workflows/downsample.ts +1 -1
  117. package/dist/templates/transcription-workflow/workflows/normalize.ts +15 -19
  118. package/dist/templates/transcription-workflow/workflows/stream.ts +12 -12
  119. package/dist/templates/transcription-workflow/workflows/sync-api.ts +3 -3
  120. package/dist/templates/transcription-workflow/workflows/transcribe.ts +23 -34
  121. package/dist/templates/travel-concierge/agent.eval.test.ts +2 -2
  122. package/dist/templates/travel-concierge/agent.test.ts +15 -7
  123. package/dist/templates/travel-concierge/client.tsx +2 -2
  124. package/dist/templates/travel-concierge/shared.ts +10 -14
  125. package/dist/templates/travel-concierge/tools/lookup_booking.ts +4 -3
  126. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -2
  127. package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -2
  128. package/dist/templates/travel-concierge/tools/search_flights.ts +3 -2
  129. package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -2
  130. package/dist/{test-guenJUxi.mjs → test-D032V2cA.mjs} +4 -17
  131. package/dist/typecheck.mjs +1 -1
  132. package/dist/worker-bundler.mjs +1 -1
  133. package/dist/{workflow-BZyKLkhV.mjs → workflow-CVioyO3V.mjs} +6 -5
  134. package/package.json +4 -4
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";
2
+ import { i as installStdoutGuard, n as fail, o as writeLine, r as getOutputMode, t as CliError } from "./_output-DBP9Op_d.mjs";
3
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";
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, 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-CpHlNHUZ.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-CpHlNHUZ.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-CpHlNHUZ.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-CpHlNHUZ.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({
@@ -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-DukDxECd.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-DApPSaE_.mjs");
730
740
  return executeDev({
731
741
  cwd,
732
742
  port: args.port,
@@ -748,7 +758,7 @@ const test = defineExec({
748
758
  },
749
759
  cwd: "agent",
750
760
  async run({ args, cwd }) {
751
- const { executeTest } = await import("./test-guenJUxi.mjs");
761
+ const { executeTest } = await import("./test-D032V2cA.mjs");
752
762
  return executeTest(cwd, { all: args.all === true });
753
763
  }
754
764
  });
@@ -760,7 +770,7 @@ const evalCommand = defineExec({
760
770
  args: { json: sharedArgs.json },
761
771
  cwd: "agent",
762
772
  async run({ cwd }) {
763
- const { executeEval } = await import("./eval-h3DTVfRw.mjs");
773
+ const { executeEval } = await import("./eval-BK47A_K5.mjs");
764
774
  return executeEval(cwd);
765
775
  }
766
776
  });
@@ -782,7 +792,7 @@ const build = defineExec({
782
792
  },
783
793
  cwd: "agent",
784
794
  async run({ args, cwd }) {
785
- const { executeBuild } = await import("./build-CWyFGe-W.mjs");
795
+ const { executeBuild } = await import("./build-Mxk8gWvX.mjs");
786
796
  return executeBuild({
787
797
  cwd,
788
798
  skipTests: args.skipTests,
@@ -797,8 +807,7 @@ const deploy = defineExec({
797
807
  hidden: true
798
808
  },
799
809
  args: {
800
- server: sharedArgs.server,
801
- json: sharedArgs.json,
810
+ ...platformArgs,
802
811
  allowPreviewSlug: {
803
812
  type: "boolean",
804
813
  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 +819,7 @@ const deploy = defineExec({
810
819
  },
811
820
  cwd: "agent",
812
821
  async run({ args, cwd }) {
813
- const { executeDeploy } = await import("./deploy-B7f3CK7v.mjs");
822
+ const { executeDeploy } = await import("./deploy-uAJ4NukN.mjs");
814
823
  return executeDeploy({
815
824
  cwd,
816
825
  server: args.server,
@@ -824,13 +833,10 @@ const del = defineExec({
824
833
  name: "delete",
825
834
  description: "Delete the studio project and its deployed agents"
826
835
  },
827
- args: {
828
- server: sharedArgs.server,
829
- json: sharedArgs.json
830
- },
836
+ args: { ...platformArgs },
831
837
  cwd: "any",
832
838
  async run({ args, cwd }) {
833
- const { executeDelete } = await import("./delete-RqlQZ6Y_.mjs");
839
+ const { executeDelete } = await import("./delete-BdFnbnVR.mjs");
834
840
  return executeDelete({
835
841
  cwd,
836
842
  server: args.server
@@ -842,13 +848,10 @@ const login = defineExec({
842
848
  name: "login",
843
849
  description: "Link your signed-in browser account and save your API key"
844
850
  },
845
- args: {
846
- server: sharedArgs.server,
847
- json: sharedArgs.json
848
- },
851
+ args: { ...platformArgs },
849
852
  cwd: "none",
850
853
  async run({ args }) {
851
- const { executeLogin } = await import("./login-CDiemNmC.mjs");
854
+ const { executeLogin } = await import("./login-DaLrPOFg.mjs");
852
855
  return executeLogin({ server: args.server });
853
856
  }
854
857
  });
@@ -860,7 +863,7 @@ const templates = defineExec({
860
863
  args: { json: sharedArgs.json },
861
864
  cwd: "none",
862
865
  async run({ mode }) {
863
- const { listTemplates } = await import("./_templates-V4l5sZJy.mjs");
866
+ const { listTemplates } = await import("./_templates-CK4oKoeX.mjs");
864
867
  const names = await listTemplates();
865
868
  if (mode === "human") {
866
869
  for (const name of names) log.message(name);
@@ -955,57 +958,36 @@ if (process.env.VITEST !== "true") {
955
958
  process.exit(1);
956
959
  };
957
960
  /**
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.
961
+ * Refuse a mistyped command or an unrecognized flag instead of letting
962
+ * either through both read off ONE walk of the command tree.
965
963
  *
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.
964
+ * An unknown SUBCOMMAND is answered here rather than by citty, which throws
965
+ * `Unknown command ${cyan(name)}` and writes it with `console.error` —
966
+ * colour escapes and all, whatever the output mode and whether or not stderr
967
+ * is a terminal — AFTER `showUsage` has already emitted the result line. So
968
+ * `aai deploy-now | jq` produced an envelope that named `aai` instead of the
969
+ * token the user typed, plus an ANSI-studded sentence on stderr that no JSON
970
+ * consumer asked for. Reported here instead: the envelope names the command,
971
+ * and nothing colours a pipe.
973
972
  *
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.
973
+ * An unknown FLAG is refused because citty drops one silently, so
974
+ * `aai push --serverr=http://x` exited 0 having pushed to the DEFAULT server.
975
+ * `--server` decides where the API key and secret values go, so a typo that
976
+ * quietly retargets it is worth failing on.
997
977
  *
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.
978
+ * The command check comes first because a flag can only be judged against
979
+ * the right command's `argsDef` which is why `resolveArgv` reports the two
980
+ * together instead of leaving the order to this call site.
1001
981
  */
1002
- const assertKnownFlags = async () => {
1003
- const unknown = await unknownFlagsForArgv(mainCommand, process.argv.slice(2));
982
+ const assertKnownArgv = async () => {
983
+ const { named, unknownCommand, argsDef, rest } = await resolveArgv(mainCommand, process.argv.slice(2));
984
+ if (unknownCommand !== void 0) await reportAndExit(`Unknown command: ${unknownCommand}`, `Run \`${named.join(" ")} --help\` to see the commands it accepts.`);
985
+ const unknown = findUnknownFlags(rest, argsDef);
1004
986
  if (unknown.length === 0) return;
1005
- const label = `Unknown ${unknown.length === 1 ? "option" : "options"}: ${unknown.join(", ")}`;
987
+ const label = `Unknown ${plural(unknown.length, "option")}: ${unknown.join(", ")}`;
1006
988
  await reportAndExit(label, "Run `aai <command> --help` to see the options it accepts.");
1007
989
  };
1008
- runDefault().then(assertKnownCommand).then(assertKnownFlags).then(() => runMain(mainCommand, { showUsage: usageForMode })).catch((err) => {
990
+ runDefault().then(assertKnownArgv).then(() => runMain(mainCommand, { showUsage: usageForMode })).catch((err) => {
1009
991
  log.error(errorMessage$1(err));
1010
992
  process.exitCode = 1;
1011
993
  });
@@ -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";
@@ -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-BJgREAh6.mjs";
3
3
  export { buildClient };
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log } from "./_ui-DCt4qZrk.mjs";
4
- import { l as writeProjectConfig } from "./_config-ZY2euhdh.mjs";
5
- import { a as resolveDeployTarget, i as requireDeployedSlug } from "./_agent-Clbq3a4h.mjs";
6
- import { d as apiTestSeam, l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-DTi3EdXQ.mjs";
4
+ import { l as writeProjectConfig } from "./_config-DYzC6WMD.mjs";
5
+ import { i as requireDeployedSlug, o as resolveDeployTarget } from "./_agent-BzUeqOdj.mjs";
6
+ import { d as apiTestSeam, l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-DnR_BqFp.mjs";
7
7
  import { omitUndefined } from "@alexkroman1/aai/utils";
8
8
  //#region src/delete.ts
9
9
  async function runDelete(opts) {
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log, r as notify, t as fmtUrl } from "./_ui-DCt4qZrk.mjs";
4
- import { o as errorMessage$1 } from "./_utils-Dhd058D9.mjs";
5
- import { s as updateProjectConfig } from "./_config-ZY2euhdh.mjs";
6
- import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-DEkjO1d8.mjs";
7
- import { t as resolveServerEnv } from "./_server-common-BV4_CrP3.mjs";
8
- import { a as resolveDeployTarget } from "./_agent-Clbq3a4h.mjs";
9
- import { assertTypechecks } from "./_typecheck-gate-sV4N5F93.mjs";
10
- import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-C9l8uC2R.mjs";
11
- import { d as apiTestSeam, f as checkedResponse, i as projectNameFromDir, u as apiRequest } from "./_studio-DTi3EdXQ.mjs";
4
+ import { s as errorMessage$1 } from "./_utils-D5JGcjiW.mjs";
5
+ import { s as updateProjectConfig } from "./_config-DYzC6WMD.mjs";
6
+ import { i as evalWorkerConfig, t as buildAgentBundle } from "./_bundler-DolUCMxu.mjs";
7
+ import { t as resolveServerEnv } from "./_server-common-vILJp3it.mjs";
8
+ import { o as resolveDeployTarget } from "./_agent-BzUeqOdj.mjs";
9
+ import { assertTypechecks } from "./_typecheck-gate-U3jcil8L.mjs";
10
+ import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-CvpqMpdh.mjs";
11
+ import { d as apiTestSeam, f as checkedResponse, i as projectNameFromDir, u as apiRequest } from "./_studio-DnR_BqFp.mjs";
12
12
  import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
13
13
  import { gzipSync } from "node:zlib";
14
14
  //#region src/_deploy.ts
@@ -40,8 +40,8 @@ async function runDeploy(opts) {
40
40
  async function executeDeploy(opts) {
41
41
  const { cwd } = opts;
42
42
  const { config: projectConfig, serverUrl, apiKey } = await resolveDeployTarget(cwd, opts.server);
43
- if (!opts.skipTypecheck) await assertTypechecks(cwd);
44
- const preflightModule = import("./_preflight-B2laWPdU.mjs");
43
+ await assertTypechecks(cwd, { skip: opts.skipTypecheck });
44
+ const preflightModule = import("./_preflight-CcAR577V.mjs");
45
45
  const bundle = await buildAgentBundle(cwd, { minify: true });
46
46
  const slug = projectConfig?.slug ?? projectNameFromDir(cwd) ?? void 0;
47
47
  const uploadEnv = {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { a as parsePort, n as log, r as notify, t as fmtUrl } from "./_ui-DCt4qZrk.mjs";
4
- import { a as errorDetail } from "./_utils-Dhd058D9.mjs";
4
+ import { o as errorDetail } from "./_utils-D5JGcjiW.mjs";
5
5
  import path from "node:path";
6
6
  import { styleText } from "node:util";
7
7
  //#region src/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-C13xuGB1.mjs");
15
+ const { startDevServer } = await import("./_dev-server-CSMqF8PN.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, n as fail } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok, n as fail } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log } from "./_ui-DCt4qZrk.mjs";
4
- import { t as resolveServerEnv } from "./_server-common-BV4_CrP3.mjs";
5
- import { classifyVitestError, runVitest } from "./test-guenJUxi.mjs";
4
+ import { t as resolveServerEnv } from "./_server-common-vILJp3it.mjs";
5
+ import { classifyVitestError, runVitest } from "./test-D032V2cA.mjs";
6
6
  //#region src/eval.ts
7
7
  /**
8
8
  * `aai eval` — run the agent's behaviour evals via vitest.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as ok } from "./_output-DbJt9gsl.mjs";
2
+ import { a as ok } from "./_output-DBP9Op_d.mjs";
3
3
  import { n as log, s as unwrapCancel } from "./_ui-DCt4qZrk.mjs";
4
- import { d as resolveCwd, l as readJson, o as errorMessage$1, s as fileExists, t as AGENT_ENTRY } from "./_utils-Dhd058D9.mjs";
5
- import { r as isDevMode, t as getMonorepoRoot } from "./_agent-Clbq3a4h.mjs";
4
+ import { c as fileExists, d as readJson, p as resolveCwd, s as errorMessage$1, t as AGENT_ENTRY } from "./_utils-D5JGcjiW.mjs";
5
+ import { r as isDevMode, t as getMonorepoRoot } from "./_agent-BzUeqOdj.mjs";
6
6
  import path from "node:path";
7
7
  import { omitUndefined } from "@alexkroman1/aai/utils";
8
8
  import { styleText } from "node:util";
@@ -106,7 +106,7 @@ function collectWarnings() {
106
106
  }
107
107
  /** Publish after init and return deploy metadata if successful. */
108
108
  async function tryPublish(cwd, server, warn) {
109
- const { executePublish } = await import("./studio-BpMCfUNx.mjs");
109
+ const { executePublish } = await import("./studio-CpHlNHUZ.mjs");
110
110
  try {
111
111
  const result = await executePublish({
112
112
  cwd,
@@ -127,7 +127,7 @@ async function tryPublish(cwd, server, warn) {
127
127
  }
128
128
  /** Scaffold the project, optionally showing a spinner. */
129
129
  async function scaffoldProject(dir, cwd, template, silent) {
130
- const { runInit } = await import("./_init-Ci4QGjp8.mjs");
130
+ const { runInit } = await import("./_init-CQ8idAwo.mjs");
131
131
  await withSpinner(silent, {
132
132
  start: `Creating ${dir}`,
133
133
  done: "Project created",
@@ -154,26 +154,18 @@ async function executeInit(opts, extra) {
154
154
  const { warn, warnings } = collectWarnings();
155
155
  await scaffoldProject(dir, cwd, template, suppressUi);
156
156
  const installed = await installDeps(cwd, warn, suppressUi);
157
- let deployed = false;
158
- let slug;
159
- let url;
160
157
  if (!installed) warn("Skipping publish because dependencies were not installed.");
161
- else if (!opts.skipDeploy) {
162
- const published = await tryPublish(cwd, opts.server, warn);
163
- if (published) {
164
- deployed = true;
165
- slug = published.slug;
166
- url = published.url;
167
- }
168
- }
158
+ const published = installed && !opts.skipDeploy ? await tryPublish(cwd, opts.server, warn) : null;
169
159
  if (!suppressUi) printPostInitInfo(cwd, monorepoRoot);
170
160
  const data = {
171
161
  dir: cwd,
172
162
  template,
173
- deployed
163
+ deployed: published !== null
174
164
  };
175
- if (slug) data.slug = slug;
176
- if (url) data.url = url;
165
+ if (published) {
166
+ data.slug = published.slug;
167
+ data.url = published.url;
168
+ }
177
169
  if (warnings.length > 0) data.warnings = warnings;
178
170
  return ok(data);
179
171
  }