@alexkroman1/aai-cli 13.2.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 (152) hide show
  1. package/bin.mjs +1 -1
  2. package/dist/{_agent-BTwZJu4P.mjs → _agent-BzUeqOdj.mjs} +33 -10
  3. package/dist/_agent.d.ts +23 -0
  4. package/dist/{_bundler-C31rlcYz.mjs → _bundler-DolUCMxu.mjs} +9 -8
  5. package/dist/_cli-common.d.ts +45 -6
  6. package/dist/{_config-CmJOFsAP.mjs → _config-DYzC6WMD.mjs} +7 -4
  7. package/dist/_config.d.ts +25 -1
  8. package/dist/_dev-env.d.ts +1 -1
  9. package/dist/{_dev-server-DWvkNoIS.mjs → _dev-server-CSMqF8PN.mjs} +28 -30
  10. package/dist/_dev-vite-config.d.ts +3 -3
  11. package/dist/_e2e-test-utils.d.ts +15 -7
  12. package/dist/{_init-BURbdHNM.mjs → _init-CQ8idAwo.mjs} +64 -30
  13. package/dist/{_output-CKkmWs7i.mjs → _output-DBP9Op_d.mjs} +43 -3
  14. package/dist/_output.d.ts +24 -7
  15. package/dist/{_preflight-Co1G9Jww.mjs → _preflight-CcAR577V.mjs} +3 -3
  16. package/dist/_resource-commands.d.ts +9 -9
  17. package/dist/{_server-common-6e0QI4mq.mjs → _server-common-vILJp3it.mjs} +3 -3
  18. package/dist/{_slug-api-CfGQq1Tt.mjs → _slug-api-CGvc2YSQ.mjs} +19 -10
  19. package/dist/_slug-api.d.ts +19 -0
  20. package/dist/{_studio-B1waXMuR.mjs → _studio-DnR_BqFp.mjs} +9 -5
  21. package/dist/_studio-commands.d.ts +13 -13
  22. package/dist/{_templates-0Zr2z6yA.mjs → _templates-CK4oKoeX.mjs} +3 -3
  23. package/dist/{_typecheck-gate-BXvUNnfs.mjs → _typecheck-gate-U3jcil8L.mjs} +5 -4
  24. package/dist/_typecheck-gate.d.ts +3 -1
  25. package/dist/{_ui-u7T4YooX.mjs → _ui-DCt4qZrk.mjs} +1 -1
  26. package/dist/{_utils-B8QmtFhK.mjs → _utils-D5JGcjiW.mjs} +44 -2
  27. package/dist/_utils.d.ts +35 -0
  28. package/dist/{_vite-env-D9Qj6KPX.mjs → _vite-env-kejF0p2L.mjs} +1 -1
  29. package/dist/{_workflow-determinism-f9J-5Zlj.mjs → _workflow-determinism-CvpqMpdh.mjs} +19 -27
  30. package/dist/_workflow-determinism.d.ts +3 -3
  31. package/dist/build-Mxk8gWvX.mjs +108 -0
  32. package/dist/build.d.ts +5 -0
  33. package/dist/cli.mjs +172 -116
  34. package/dist/{client-bundler-j5c46x0G.mjs → client-bundler-BJgREAh6.mjs} +4 -4
  35. package/dist/client-bundler.mjs +1 -1
  36. package/dist/{delete-X_CRgCf6.mjs → delete-BdFnbnVR.mjs} +6 -6
  37. package/dist/{deploy-BzZ-r4iM.mjs → deploy-uAJ4NukN.mjs} +14 -14
  38. package/dist/{dev-BDykFvcc.mjs → dev-DApPSaE_.mjs} +5 -5
  39. package/dist/{eval-0qEOdm0l.mjs → eval-BK47A_K5.mjs} +27 -11
  40. package/dist/eval.d.ts +2 -0
  41. package/dist/{init-BtJI306C.mjs → init-DukDxECd.mjs} +13 -21
  42. package/dist/{login-DeUETobb.mjs → login-DaLrPOFg.mjs} +6 -8
  43. package/dist/{logs-hWnJ66Bl.mjs → logs-7BRwq0cG.mjs} +22 -15
  44. package/dist/project-config.mjs +1 -1
  45. package/dist/scaffold/.env.example +17 -1
  46. package/dist/scaffold/CLAUDE.md +84 -56
  47. package/dist/scaffold/package.json +6 -5
  48. package/dist/scaffold/server.mjs +129 -25
  49. package/dist/secret-Cjp912yF.mjs +162 -0
  50. package/dist/secret.d.ts +48 -13
  51. package/dist/{studio-BxAS_FQQ.mjs → studio-CpHlNHUZ.mjs} +15 -17
  52. package/dist/templates/briefing-desk/agent.test.ts +7 -3
  53. package/dist/templates/call-audit/agent.test.ts +25 -9
  54. package/dist/templates/call-audit/agent.ts +2 -2
  55. package/dist/templates/call-audit/client.tsx +40 -58
  56. package/dist/templates/call-audit/workflows/audit.ts +7 -5
  57. package/dist/templates/call-audit/workflows/ingest.ts +7 -7
  58. package/dist/templates/call-audit/workflows/media.ts +12 -37
  59. package/dist/templates/call-audit/workflows/summarize.ts +8 -8
  60. package/dist/templates/call-audit/workflows/sync-api.ts +3 -3
  61. package/dist/templates/dispatch-center/agent.test.ts +7 -7
  62. package/dist/templates/dispatch-center/client.tsx +53 -61
  63. package/dist/templates/dispatch-center/shared.ts +0 -8
  64. package/dist/templates/dispatch-center/tools/ops_dashboard.ts +4 -1
  65. package/dist/templates/embedded-assets/agent.eval.test.ts +4 -2
  66. package/dist/templates/embedded-assets/agent.test.ts +7 -1
  67. package/dist/templates/health-assistant/agent.eval.test.ts +4 -2
  68. package/dist/templates/health-assistant/agent.test.ts +8 -4
  69. package/dist/templates/infocom-adventure/client.tsx +40 -36
  70. package/dist/templates/link-digest/agent.test.ts +10 -4
  71. package/dist/templates/link-digest/agent.ts +2 -2
  72. package/dist/templates/link-digest/client.tsx +42 -36
  73. package/dist/templates/link-digest/workflows/digest.ts +13 -16
  74. package/dist/templates/night-owl/agent.eval.test.ts +4 -2
  75. package/dist/templates/night-owl/agent.test.ts +6 -1
  76. package/dist/templates/night-owl/client.tsx +8 -2
  77. package/dist/templates/pipeline-simple/agent.test.ts +33 -16
  78. package/dist/templates/pizza-ordering/client.tsx +5 -4
  79. package/dist/templates/pizza-ordering/shared.ts +3 -8
  80. package/dist/templates/pizza-ordering/tools/add_pizza.ts +3 -2
  81. package/dist/templates/pizza-ordering/tools/place_order.ts +3 -2
  82. package/dist/templates/pizza-ordering/tools/remove_pizza.ts +3 -2
  83. package/dist/templates/pizza-ordering/tools/update_pizza.ts +3 -2
  84. package/dist/templates/pizza-ordering/tools/view_order.ts +3 -2
  85. package/dist/templates/plan-and-execute/agent.test.ts +10 -5
  86. package/dist/templates/plan-and-execute/client.tsx +2 -2
  87. package/dist/templates/podcast-digest/agent.test.ts +33 -14
  88. package/dist/templates/podcast-digest/client.tsx +27 -36
  89. package/dist/templates/podcast-digest/workflows/digest.ts +21 -19
  90. package/dist/templates/podcast-digest/workflows/feeds.ts +61 -33
  91. package/dist/templates/podcast-digest/workflows/slack.ts +7 -7
  92. package/dist/templates/recap-workflow/agent.eval.test.ts +21 -13
  93. package/dist/templates/recap-workflow/agent.test.ts +49 -32
  94. package/dist/templates/recap-workflow/workflows/recap.ts +24 -28
  95. package/dist/templates/redline/agent.eval.test.ts +5 -8
  96. package/dist/templates/redline/agent.test.ts +8 -2
  97. package/dist/templates/redline/client.tsx +47 -48
  98. package/dist/templates/redline/workflows/redline.ts +17 -17
  99. package/dist/templates/research-workflow/agent.eval.test.ts +5 -5
  100. package/dist/templates/research-workflow/agent.test.ts +17 -8
  101. package/dist/templates/research-workflow/workflows/research.ts +28 -30
  102. package/dist/templates/retail/agent.test.ts +17 -15
  103. package/dist/templates/retail/cancel.ts +7 -6
  104. package/dist/templates/retail/client.tsx +39 -58
  105. package/dist/templates/retail/payment.ts +4 -3
  106. package/dist/templates/retail/pending.test.ts +19 -19
  107. package/dist/templates/retail/registry.test.ts +99 -58
  108. package/dist/templates/retail/store.test.ts +5 -5
  109. package/dist/templates/retail/swap.ts +8 -11
  110. package/dist/templates/simple/agent.test.ts +39 -6
  111. package/dist/templates/solo-rpg/agent.eval.test.ts +2 -16
  112. package/dist/templates/solo-rpg/agent.test.ts +12 -12
  113. package/dist/templates/solo-rpg/client.tsx +3 -3
  114. package/dist/templates/spoken-summary/agent.test.ts +21 -12
  115. package/dist/templates/spoken-summary/agent.ts +3 -3
  116. package/dist/templates/spoken-summary/client.tsx +36 -47
  117. package/dist/templates/spoken-summary/workflows/summarize.ts +11 -11
  118. package/dist/templates/spoken-summary/workflows/transcribe.ts +14 -14
  119. package/dist/templates/support-line/client.tsx +4 -3
  120. package/dist/templates/support-line/prompts.ts +0 -2
  121. package/dist/templates/transcription-workflow/agent.test.ts +36 -20
  122. package/dist/templates/transcription-workflow/agent.ts +2 -2
  123. package/dist/templates/transcription-workflow/client.tsx +34 -40
  124. package/dist/templates/transcription-workflow/recover.ts +1 -1
  125. package/dist/templates/transcription-workflow/run-panel.tsx +34 -14
  126. package/dist/templates/transcription-workflow/total-latency.tsx +46 -20
  127. package/dist/templates/transcription-workflow/workflows/batch.ts +15 -15
  128. package/dist/templates/transcription-workflow/workflows/downsample.ts +1 -1
  129. package/dist/templates/transcription-workflow/workflows/normalize.ts +15 -19
  130. package/dist/templates/transcription-workflow/workflows/stream.ts +12 -12
  131. package/dist/templates/transcription-workflow/workflows/sync-api.ts +3 -3
  132. package/dist/templates/transcription-workflow/workflows/transcribe.ts +23 -34
  133. package/dist/templates/travel-concierge/agent.eval.test.ts +2 -2
  134. package/dist/templates/travel-concierge/agent.test.ts +15 -7
  135. package/dist/templates/travel-concierge/client.tsx +2 -2
  136. package/dist/templates/travel-concierge/shared.ts +10 -14
  137. package/dist/templates/travel-concierge/tools/lookup_booking.ts +4 -3
  138. package/dist/templates/travel-concierge/tools/search_car_rentals.ts +3 -2
  139. package/dist/templates/travel-concierge/tools/search_excursions.ts +3 -2
  140. package/dist/templates/travel-concierge/tools/search_flights.ts +3 -2
  141. package/dist/templates/travel-concierge/tools/search_hotels.ts +3 -2
  142. package/dist/test-D032V2cA.mjs +242 -0
  143. package/dist/test.d.ts +97 -31
  144. package/dist/typecheck.mjs +2 -2
  145. package/dist/worker-bundler.mjs +3 -3
  146. package/dist/{workflow-BBu5oEDw.mjs → workflow-CVioyO3V.mjs} +8 -7
  147. package/package.json +10 -10
  148. package/dist/bin.d.mts +0 -2
  149. package/dist/build-BLlLOrng.mjs +0 -66
  150. package/dist/secret-B-3T5tvr.mjs +0 -61
  151. package/dist/test-CiLab-AA.mjs +0 -182
  152. package/dist/tsdown.config.d.ts +0 -2
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env node
2
- import { a as ok, n as fail } from "./_output-CKkmWs7i.mjs";
3
- import { n as log, s as unwrapCancel } from "./_ui-u7T4YooX.mjs";
4
- import { f as checkedResponse, p as isStringArray } from "./_studio-B1waXMuR.mjs";
5
- import { t as secretRequest } from "./_slug-api-CfGQq1Tt.mjs";
6
- import { isRecord } from "@alexkroman1/aai/utils";
7
- import * as p from "@clack/prompts";
8
- import { text } from "node:stream/consumers";
9
- //#region secret.ts
10
- /**
11
- * The one `no_input` failure for `secret put`, shared by the JSON-mode stdin
12
- * path (cli.ts) and the TTY prompt path below so the two can't drift.
13
- */
14
- const NO_INPUT = [
15
- "no_input",
16
- "No value provided",
17
- "Pipe secret value to stdin"
18
- ];
19
- /** Read secret value from stdin (for non-TTY / piped input). */
20
- async function readStdin() {
21
- return (await text(process.stdin)).trim();
22
- }
23
- /**
24
- * Execute secret put. If `value` is provided, use it directly (non-TTY path).
25
- * If not provided, prompt interactively (TTY path).
26
- */
27
- async function executeSecretPut(cwd, name, value, server) {
28
- let secretValue = value;
29
- if (!secretValue) {
30
- const result = unwrapCancel(await p.password({ message: `Enter value for ${name}` }));
31
- if (!result) return fail(...NO_INPUT);
32
- secretValue = result;
33
- }
34
- const { target } = await secretRequest(cwd, "", {
35
- method: "PUT",
36
- body: { [name]: secretValue },
37
- action: "secret"
38
- }, server);
39
- log.success(`Set ${name} for ${target}`);
40
- return ok({ name });
41
- }
42
- async function executeSecretDelete(cwd, name, server) {
43
- const { target } = await secretRequest(cwd, `/${encodeURIComponent(name)}`, {
44
- method: "DELETE",
45
- action: "secret"
46
- }, server);
47
- log.success(`Deleted ${name} from ${target}`);
48
- return ok({ name });
49
- }
50
- async function executeSecretList(cwd, server) {
51
- const { data, target } = await secretRequest(cwd, "", { action: "secret" }, server);
52
- const { vars } = checkedResponse(data, (value) => isRecord(value) && isStringArray(value.vars), `the secret list for ${target}`);
53
- if (vars.length === 0) log.info("No secrets set. Use `aai secret put <name>` to add one.");
54
- else {
55
- log.message(`${vars.length} secret${vars.length === 1 ? "" : "s"}:`);
56
- for (const v of vars) log.message(` ${v}`);
57
- }
58
- return ok({ secrets: vars });
59
- }
60
- //#endregion
61
- export { NO_INPUT, executeSecretDelete, executeSecretList, executeSecretPut, readStdin };
@@ -1,182 +0,0 @@
1
- #!/usr/bin/env node
2
- import { a as ok, n as fail } from "./_output-CKkmWs7i.mjs";
3
- import { n as log, r as notify } from "./_ui-u7T4YooX.mjs";
4
- import { i as errorCode, o as errorMessage$1, r as binFromPackageJson } from "./_utils-B8QmtFhK.mjs";
5
- import { createRequire } from "node:module";
6
- import { existsSync, readdirSync } from "node:fs";
7
- import path from "node:path";
8
- import { omitUndefined } from "@alexkroman1/aai/utils";
9
- import { execaSync } from "execa";
10
- //#region test.ts
11
- /**
12
- * `aai test` — run agent tests via vitest.
13
- */
14
- /**
15
- * Resolve the agent project's own vitest binary so tests run without the
16
- * npx resolution overhead (and its potential network fetch of vitest).
17
- *
18
- * Resolves `vitest/package.json` from the agent directory, derives the bin
19
- * script, and runs it with the current Node executable. Falls back to
20
- * `npx vitest` only when no local install is resolvable.
21
- */
22
- function resolveVitestCommand(cwd, resolve = createRequire(path.join(cwd, "package.json")).resolve) {
23
- try {
24
- const bin = binFromPackageJson(resolve("vitest/package.json"), "vitest");
25
- if (bin) return {
26
- cmd: process.execPath,
27
- args: [bin]
28
- };
29
- } catch {}
30
- return {
31
- cmd: "npx",
32
- args: ["vitest"]
33
- };
34
- }
35
- /** The files `aai test` runs, in preference order. */
36
- const TEST_FILES = ["agent.test.ts", "agent.test.js"];
37
- /**
38
- * Run vitest over one of `candidates` in the given project directory.
39
- *
40
- * Returns the FILE it ran, or `false` if none of the candidate files exists.
41
- * Throws on failure.
42
- *
43
- * A vitest FILTER, not an include glob: the argument is matched as a substring
44
- * against the paths vitest's own include globs already found, which is why the
45
- * candidates are named `*.test.ts` — `agent.test.ts` cannot match
46
- * `agent.eval.test.ts` and vice versa, so the two commands stay disjoint
47
- * without either one having to exclude the other's file.
48
- */
49
- function runVitest(cwd, opts = { candidates: TEST_FILES }) {
50
- const testFile = opts.candidates.find((name) => existsSync(path.join(cwd, name)));
51
- if (!testFile) return false;
52
- const { cmd, args } = resolveVitestCommand(cwd);
53
- execaSync(cmd, [
54
- ...args,
55
- "run",
56
- "--root",
57
- ".",
58
- ...opts.extraArgs ?? [],
59
- testFile
60
- ], {
61
- cwd,
62
- stdio: "inherit",
63
- ...omitUndefined({ env: opts.env ? {
64
- ...process.env,
65
- ...opts.env
66
- } : void 0 })
67
- });
68
- return testFile;
69
- }
70
- /**
71
- * Classify a {@link runVitest} failure. execaSync throws an ENOENT-coded
72
- * error when the binary itself couldn't be spawned (infrastructure problem)
73
- * and an exit-code error when vitest ran and the tests failed.
74
- */
75
- function classifyVitestError(err, label = "Tests") {
76
- if (errorCode(err) === "ENOENT") return {
77
- code: "spawn_failed",
78
- message: `Could not launch the test runner: ${errorMessage$1(err)} — is the binary on your PATH?`
79
- };
80
- return {
81
- code: "test_failed",
82
- message: `${label} failed: ${errorMessage$1(err)}`
83
- };
84
- }
85
- /** Directories a project's own specs never live in. */
86
- const UNSCANNED_DIRS = /* @__PURE__ */ new Set([
87
- "node_modules",
88
- ".aai",
89
- ".git",
90
- "dist",
91
- ".workflow-data"
92
- ]);
93
- /** What counts as a spec file. */
94
- const SPEC_FILE_RE = /\.test\.(ts|js|tsx|mts|cts)$/;
95
- /**
96
- * Spec files in the project that `aai test` did NOT run.
97
- *
98
- * `runVitest` passes ONE filename as a vitest FILTER, which is what keeps `test`
99
- * and `eval` disjoint without either excluding the other's file — see its doc.
100
- * The cost is that every other `*.test.ts` in the project is skipped, and the
101
- * skip was SILENT: the shipped `retail` template carries seven of them, so
102
- * `aai test` there ran 1 file / 67 tests, printed "Tests passed", and left
103
- * 211 of the project's 278 tests unrun with nothing saying so.
104
- *
105
- * A silent skip is the worst outcome available, so the skip is announced rather
106
- * than the filter widened: which files `aai test` runs is a documented contract
107
- * (the scaffold guide says "Run agent.test.ts via vitest"), and running a
108
- * project's other specs by default could reach ones that are slow or want
109
- * credentials. Naming them costs nothing and is what a reader needs.
110
- *
111
- * Eval files are excluded because they have their OWN command, named in the
112
- * message.
113
- */
114
- function unrunSpecFiles(cwd, ran) {
115
- const found = [];
116
- collectSpecs(cwd, "", ran, found);
117
- return found.sort(compareCodeUnits);
118
- }
119
- /** Code-unit comparison — see {@link unrunSpecFiles} for why not `localeCompare`. */
120
- function compareCodeUnits(a, b) {
121
- if (a < b) return -1;
122
- return a > b ? 1 : 0;
123
- }
124
- /** One directory of {@link unrunSpecFiles}, recursing into the ones that count. */
125
- function collectSpecs(dir, prefix, ran, out) {
126
- let entries;
127
- try {
128
- entries = readdirSync(dir, { withFileTypes: true });
129
- } catch {
130
- return;
131
- }
132
- for (const e of entries) {
133
- const rel = prefix ? `${prefix}/${e.name}` : e.name;
134
- if (e.isDirectory()) {
135
- if (!(UNSCANNED_DIRS.has(e.name) || e.name.startsWith("."))) collectSpecs(path.join(dir, e.name), rel, ran, out);
136
- } else if (isUnrunSpec(e.name, rel, ran)) out.push(rel);
137
- }
138
- }
139
- /** A spec file this run did not cover. The `.eval.` INFIX is the tier convention. */
140
- function isUnrunSpec(name, rel, ran) {
141
- if (!SPEC_FILE_RE.test(name)) return false;
142
- return rel !== ran && !name.includes(".eval.test.");
143
- }
144
- /**
145
- * Warn, once, naming the spec files this run did not cover.
146
- *
147
- * `ran` is `false` when there was no `agent.test.ts` to run, and that case
148
- * needs the warning MORE rather than less: `aai test` then prints "No test file
149
- * found" while the project's spec files sit right there unrun, which reads as
150
- * "this project has no tests". Measured on a project whose only spec was
151
- * `tools/echo_back.test.ts` — `{"passed":true,"skipped":true}` and not a word
152
- * about it. It stays silent when there is nothing to name, in both arms.
153
- */
154
- function warnUnrunSpecs(cwd, ran) {
155
- const skipped = unrunSpecFiles(cwd, ran === false ? "" : ran);
156
- if (skipped.length === 0) return;
157
- const preamble = ran === false ? `\`aai test\` found no agent.test.ts, so it ran nothing. ${skipped.length} spec file(s) exist and were NOT run:` : `\`aai test\` ran ${ran} only. ${skipped.length} other spec file(s) were NOT run:`;
158
- notify("warn", `${preamble} ${skipped.join(", ")}. Run them with your own vitest (\`npx vitest run\`); behaviour evals have their own command (\`aai eval\`).`);
159
- }
160
- /** Execute agent tests and return structured result. */
161
- async function executeTest(cwd) {
162
- log.step("Running agent tests");
163
- try {
164
- const ran = runVitest(cwd);
165
- if (!ran) {
166
- log.info("No test file found. Create agent.test.ts to add tests.");
167
- warnUnrunSpecs(cwd, ran);
168
- return ok({
169
- passed: true,
170
- skipped: true
171
- });
172
- }
173
- log.success("Tests passed");
174
- warnUnrunSpecs(cwd, ran);
175
- return ok({ passed: true });
176
- } catch (err) {
177
- const { code, message } = classifyVitestError(err);
178
- return fail(code, message);
179
- }
180
- }
181
- //#endregion
182
- export { classifyVitestError, executeTest, runVitest };
@@ -1,2 +0,0 @@
1
- declare const _default: import("tsdown").UserConfig;
2
- export default _default;