@alexkroman1/aai-cli 0.13.0 → 0.14.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 (66) hide show
  1. package/README.md +15 -15
  2. package/dist/{_bundler-CgBw5Bcu.mjs → _bundler-B6v31ROV.mjs} +1 -1
  3. package/dist/_console-audio.d.ts +18 -0
  4. package/dist/{_dev-server-BNq5OnUJ.mjs → _dev-server-GoEXEVpA.mjs} +2 -2
  5. package/dist/_resource-commands.d.ts +34 -2
  6. package/dist/{_slug-api-DJuwYZ6T.mjs → _slug-api-BnmTHtjd.mjs} +1 -1
  7. package/dist/{_studio-BH05zugt.mjs → _studio-B5m4jBTD.mjs} +14 -9
  8. package/dist/_studio.d.ts +16 -4
  9. package/dist/_target-bundle.d.ts +2 -0
  10. package/dist/{_templates-Bv-rd0SO.mjs → _templates-BVMVsQh0.mjs} +10 -6
  11. package/dist/_templates.d.ts +9 -2
  12. package/dist/{build-B37oBfEv.mjs → build-CKhanHVv.mjs} +28 -32
  13. package/dist/cli-workflow.d.ts +7 -0
  14. package/dist/cli.mjs +213 -181
  15. package/dist/{client-bundler-D4SeZJ8E.mjs → client-bundler-DZ_Zoznn.mjs} +2 -1
  16. package/dist/client-bundler.d.ts +7 -1
  17. package/dist/client-bundler.mjs +1 -1
  18. package/dist/{console-D6OOjjeJ.mjs → console-Dxq26Adz.mjs} +14 -10
  19. package/dist/{delete-Br0EOH0g.mjs → delete-DwXCHzTl.mjs} +8 -8
  20. package/dist/delete.d.ts +4 -3
  21. package/dist/{deploy-CLUH5cv2.mjs → deploy-CbA8Ibiu.mjs} +2 -2
  22. package/dist/{dev-ZVuyPLUk.mjs → dev-BWBDbUEb.mjs} +1 -1
  23. package/dist/{init-x3FsKl2q.mjs → init-CidslZZz.mjs} +1 -1
  24. package/dist/{logs-BfRq1HX9.mjs → logs-CnPK-Prw.mjs} +25 -3
  25. package/dist/scaffold/CLAUDE.md +52 -52
  26. package/dist/scaffold/agent-guide/AGENT-API.md +20 -20
  27. package/dist/scaffold/agent-guide/HOSTING.md +32 -33
  28. package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +44 -47
  29. package/dist/scaffold/agent-guide/PROVIDERS.md +54 -57
  30. package/dist/scaffold/agent-guide/TESTING-EVALS.md +31 -31
  31. package/dist/scaffold/agent-guide/TOOLS.md +86 -87
  32. package/dist/scaffold/agent-guide/UI.md +59 -58
  33. package/dist/scaffold/agent-guide/WORKFLOWS.md +129 -127
  34. package/dist/scaffold/package.json +4 -4
  35. package/dist/scaffold/vitest.config.ts +3 -3
  36. package/dist/{secret-Db1UWLSZ.mjs → secret-DPdPEet2.mjs} +2 -2
  37. package/dist/{studio-DAoJApzD.mjs → studio-COjK25Rl.mjs} +23 -24
  38. package/dist/studio.d.ts +5 -4
  39. package/dist/templates/call-audit-workflow/agent.eval.test.ts +6 -6
  40. package/dist/templates/call-audit-workflow/agent.test.ts +2 -2
  41. package/dist/templates/document-redline-workflow/agent.eval.test.ts +14 -17
  42. package/dist/templates/home-assistant-agent/agent.test.ts +0 -1
  43. package/dist/templates/link-digest-workflow/agent.eval.test.ts +2 -2
  44. package/dist/templates/link-digest-workflow/agent.test.ts +24 -25
  45. package/dist/templates/medication-safety-agent/agent.test.ts +15 -18
  46. package/dist/templates/medication-safety-agent/fda.test.ts +16 -17
  47. package/dist/templates/medication-safety-agent/fda.ts +7 -0
  48. package/dist/templates/medication-safety-agent/tools/check_drug_interaction.ts +61 -53
  49. package/dist/templates/medication-safety-agent/tools/medication_lookup.ts +42 -32
  50. package/dist/templates/meeting-recap-agent/agent.eval.test.ts +29 -16
  51. package/dist/templates/podcast-digest-workflow/agent.eval.test.ts +3 -3
  52. package/dist/templates/podcast-digest-workflow/agent.test.ts +17 -17
  53. package/dist/templates/research-handoff-agent/agent.eval.test.ts +22 -15
  54. package/dist/templates/research-handoff-agent/agent.test.ts +2 -15
  55. package/dist/templates/research-planner-agent/agent.test.ts +22 -17
  56. package/dist/templates/research-planner-agent/shared.ts +122 -93
  57. package/dist/templates/retail-orders-agent/shared.ts +2 -2
  58. package/dist/templates/retail-orders-agent/tools/get_order_details.ts +1 -1
  59. package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +6 -6
  60. package/dist/templates/spoken-summary-workflow/agent.test.ts +2 -2
  61. package/dist/templates/transcription-workflow/agent.eval.test.ts +3 -3
  62. package/dist/templates/transcription-workflow/agent.test.ts +2 -1
  63. package/dist/templates/transcription-workflow/recover.test.ts +4 -7
  64. package/dist/templates/web-research-agent/agent.test.ts +4 -3
  65. package/dist/templates/word-game-agent/agent.test.ts +11 -5
  66. package/package.json +6 -6
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @alexkroman1/aai-cli
2
2
 
3
- The `aai` command — scaffold, run, test, and publish voice agents built with
4
- the AssemblyAI Agent SDK.
3
+ The `aai` command — scaffold, run, test, and publish voice agents built with the
4
+ AssemblyAI Agent SDK.
5
5
 
6
6
  ```sh
7
7
  npm i -g @alexkroman1/aai-cli
@@ -28,8 +28,8 @@ npm i -g @alexkroman1/aai-cli
28
28
  | `aai logs` | Read the deployed agent's log ring (`--follow` polls it) |
29
29
  | `aai workflow list\|runs\|show\|cancel` | Inspect the deployed agent's durable workflow runs |
30
30
 
31
- Every command accepts `--json` for machine-readable output (auto-detected
32
- when stdout is not a TTY). `aai <command> --help` shows flags.
31
+ Every command accepts `--json` for machine-readable output (auto-detected when
32
+ stdout is not a TTY). `aai <command> --help` shows flags.
33
33
 
34
34
  ## Typical flow
35
35
 
@@ -41,11 +41,11 @@ aai dev # talk to it at the printed URL
41
41
  aai publish # ship it; .env values become the agent's secrets
42
42
  ```
43
43
 
44
- Every published agent is also a **studio project**: publishing prints a
45
- studio link where the same source can be edited in the browser (with the
46
- coding agent), and `aai pull` brings those edits back to your machine.
47
- `push`/`pull` are fast-forward-only — an edit made in the studio since your
48
- last pull surfaces as a conflict instead of being overwritten.
44
+ Every published agent is also a **studio project**: publishing prints a studio
45
+ link where the same source can be edited in the browser (with the coding agent),
46
+ and `aai pull` brings those edits back to your machine. `push`/`pull` are
47
+ fast-forward-only — an edit made in the studio since your last pull surfaces as
48
+ a conflict instead of being overwritten.
49
49
 
50
50
  `aai publish` type-checks the project locally, then builds and deploys inside
51
51
  the project's sandbox — byte-for-byte the studio's Publish path. It preflights
@@ -53,13 +53,13 @@ the credentials the agent declares, and prints the agent's public URL.
53
53
 
54
54
  ## Notes
55
55
 
56
- - A bare `aai` in a project directory offers to publish (TTY-confirmed);
57
- outside one it runs `init`.
58
- - `--server <url>` targets a self-hosted platform; the origin is remembered
59
- in your user config after explicit approval.
56
+ - A bare `aai` in a project directory offers to publish (TTY-confirmed); outside
57
+ one it runs `init`.
58
+ - `--server <url>` targets a self-hosted platform; the origin is remembered in
59
+ your user config after explicit approval.
60
60
  - `aai login` is the only way to authenticate — it links an account already
61
- signed in to the studio. An exported `ASSEMBLYAI_API_KEY` does not log you
62
- in; in a project that variable is a provider credential for `aai dev`.
61
+ signed in to the studio. An exported `ASSEMBLYAI_API_KEY` does not log you in;
62
+ in a project that variable is a provider credential for `aai dev`.
63
63
  - The API key is stored `0600` in your user config dir (`AAI_CONFIG_DIR`
64
64
  overrides the location). Non-interactive callers point `AAI_CONFIG_DIR` at a
65
65
  config dir holding a key from an interactive `aai login`.
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { g as validateAgentExport } from "./_utils-BVLdBvdT.mjs";
3
- import { t as buildClient } from "./client-bundler-D4SeZJ8E.mjs";
3
+ import { t as buildClient } from "./client-bundler-DZ_Zoznn.mjs";
4
4
  import { buildWorker } from "./worker-bundler.mjs";
5
5
  import path from "node:path";
6
6
  import { pathToFileURL } from "node:url";
@@ -10,8 +10,26 @@
10
10
  * Both run in raw PCM16LE mono (`-t raw -b 16 -e signed-integer -c 1 -L`),
11
11
  * the format the session speaks, at the rate the session announced.
12
12
  */
13
+ import { type StdioOptions } from "node:child_process";
14
+ import type { Readable, Writable } from "node:stream";
13
15
  import type { ConsoleAudio } from "./_console-session.ts";
16
+ /** The slice of a `ChildProcess` these devices touch — all a fake has to provide. */
17
+ export type SoxProcess = {
18
+ readonly exitCode: number | null;
19
+ readonly killed: boolean;
20
+ readonly stdin: Writable | null;
21
+ readonly stdout: Readable | null;
22
+ kill(signal?: NodeJS.Signals): boolean;
23
+ on(event: "error", listener: (err: NodeJS.ErrnoException) => void): unknown;
24
+ on(event: "exit", listener: (code: number | null) => void): unknown;
25
+ };
26
+ /** How a device starts its SoX process — `node:child_process`'s `spawn` by default. */
27
+ export type SoxSpawn = (command: string, args: string[], options: {
28
+ stdio: StdioOptions;
29
+ }) => SoxProcess;
14
30
  /** What to tell a developer whose machine has no SoX. */
15
31
  export declare function missingSoxMessage(binary: string): string;
32
+ /** SoX-backed devices that start their processes through `spawnFn`. */
33
+ export declare function createSoxAudio(spawnFn?: SoxSpawn): ConsoleAudio;
16
34
  /** The SoX-backed devices. */
17
35
  export declare const soxAudio: ConsoleAudio;
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as defaultUi } from "./_ui-Coe0zwmm.mjs";
3
3
  import { a as errorCode, s as errorMessage$1 } from "./_utils-BVLdBvdT.mjs";
4
- import { n as fallbackHtmlPlugin, r as defaultClientPlugins } from "./client-bundler-D4SeZJ8E.mjs";
4
+ import { n as fallbackHtmlPlugin, r as defaultClientPlugins } from "./client-bundler-DZ_Zoznn.mjs";
5
5
  import { r as devSourceViteConfig, t as DEDUPED_PEERS } from "./_vite-env-BiyJ0GQH.mjs";
6
6
  import { buildWorker } from "./worker-bundler.mjs";
7
7
  import { typecheckProject } from "./typecheck.mjs";
8
8
  import { n as ensureApiKey } from "./_config-mq1I5Cva.mjs";
9
9
  import { t as resolveDenoRunCode } from "./_run-code-deno-C0AtfHeH.mjs";
10
10
  import { i as resolveServerEnv } from "./_server-common-CVXIeWrY.mjs";
11
- import { n as createWorkerEvaluator } from "./_bundler-CgBw5Bcu.mjs";
11
+ import { n as createWorkerEvaluator } from "./_bundler-B6v31ROV.mjs";
12
12
  import { i as hostModeEnv, n as devBindHost, r as devWatchEnabled, t as createDevLogger } from "./_dev-env-D9Uy5wNt.mjs";
13
13
  import { existsSync, statSync } from "node:fs";
14
14
  import path from "node:path";
@@ -1,5 +1,37 @@
1
- export declare const secret: import("citty").CommandDef<import("citty").ArgsDef>;
2
- export declare const logs: import("citty").CommandDef<{
1
+ /** The executors these groups dispatch to, each module loaded on first use. */
2
+ export type ResourceExecutors = {
3
+ secret: () => Promise<Pick<typeof import("./secret.ts"), "executeSecretPut" | "executeSecretDelete" | "executeSecretList" | "executeLocalSecretPut" | "executeLocalSecretDelete" | "resolveSecretValue">>;
4
+ logs: () => Promise<Pick<typeof import("./logs.ts"), "executeLogs">>;
5
+ };
6
+ /**
7
+ * Build `aai secret` and `aai logs` over `load`. The seam a spec hands fake
8
+ * executors through; the CLI uses the exported `secret`/`logs` below.
9
+ */
10
+ export declare function createResourceCommands(load?: ResourceExecutors): {
11
+ secret: import("citty").CommandDef<import("citty").ArgsDef>;
12
+ logs: import("citty").CommandDef<{
13
+ readonly server: {
14
+ readonly type: "string";
15
+ readonly alias: "s";
16
+ readonly description: "Platform server URL";
17
+ };
18
+ readonly json: {
19
+ readonly type: "boolean";
20
+ readonly description: "Output JSON (auto-detected in non-TTY)";
21
+ };
22
+ readonly dir: {
23
+ readonly type: "positional";
24
+ readonly description: "Project directory";
25
+ readonly required: false;
26
+ };
27
+ readonly follow: {
28
+ readonly type: "boolean";
29
+ readonly alias: "f";
30
+ readonly description: "Keep printing new output";
31
+ };
32
+ }>;
33
+ };
34
+ export declare const secret: import("citty").CommandDef<import("citty").ArgsDef>, logs: import("citty").CommandDef<{
3
35
  readonly server: {
4
36
  readonly type: "string";
5
37
  readonly alias: "s";
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as getServerInfo } from "./_agent-BopNO5Bq.mjs";
3
- import { l as HINT_NOT_DEPLOYED, s as studioProjectApiUrl, u as apiRequest } from "./_studio-BH05zugt.mjs";
3
+ import { c as studioProjectApiUrl, d as apiRequest, u as HINT_NOT_DEPLOYED } from "./_studio-B5m4jBTD.mjs";
4
4
  //#region src/_slug-api.ts
5
5
  /**
6
6
  * Authenticated request against a deployed agent's slug-scoped resource
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as CliError } from "./_output-DBP9Op_d.mjs";
3
+ import { o as resolveDeployTarget } from "./_agent-BopNO5Bq.mjs";
3
4
  import path from "node:path";
4
5
  import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
5
6
  import { MAX_SLUG_LENGTH, PREVIEW_SLUG_SUFFIX, VALID_SLUG_RE } from "@alexkroman1/aai/internal";
@@ -209,15 +210,19 @@ function studioProjectUrl(serverUrl, project) {
209
210
  function studioProjectApiUrl(serverUrl, project) {
210
211
  return `${serverUrl}/studio/projects/${encodeURIComponent(project)}`;
211
212
  }
212
- function listStudioProjects(serverUrl, apiKey) {
213
- return apiRequest(`${serverUrl}/studio/projects`, {
213
+ const REAL_STUDIO_DEPS = {
214
+ resolveDeployTarget,
215
+ apiRequest
216
+ };
217
+ function listStudioProjects(serverUrl, apiKey, request = apiRequest) {
218
+ return request(`${serverUrl}/studio/projects`, {
214
219
  apiKey,
215
220
  action: "list"
216
221
  }).then((res) => checkedResponse(res, (value) => isRecord(value) && isStringArray(value.projects), `the studio project list at ${serverUrl}`).projects);
217
222
  }
218
223
  /** Fetch a project, or null when it doesn't exist (the push existence probe). */
219
- function fetchStudioProject(serverUrl, apiKey, project) {
220
- return apiRequest(studioProjectApiUrl(serverUrl, project), {
224
+ function fetchStudioProject(serverUrl, apiKey, project, request = apiRequest) {
225
+ return request(studioProjectApiUrl(serverUrl, project), {
221
226
  apiKey,
222
227
  action: "pull",
223
228
  allow404: true
@@ -228,8 +233,8 @@ function isStudioProject(value) {
228
233
  return isRecord(value) && isRecord(value.files) && Object.values(value.files).every((v) => typeof v === "string") && typeof value.sourceHash === "string";
229
234
  }
230
235
  /** `PUT /studio/projects/:project/source` — the atomic whole-tree push. */
231
- function pushStudioSource(serverUrl, apiKey, project, body) {
232
- return apiRequest(`${studioProjectApiUrl(serverUrl, project)}/source`, {
236
+ function pushStudioSource(serverUrl, apiKey, project, body, request = apiRequest) {
237
+ return request(`${studioProjectApiUrl(serverUrl, project)}/source`, {
233
238
  apiKey,
234
239
  action: "push",
235
240
  method: "PUT",
@@ -238,8 +243,8 @@ function pushStudioSource(serverUrl, apiKey, project, body) {
238
243
  }).then((res) => checkedResponse(res, (value) => isRecord(value) && typeof value.sourceHash === "string" && typeof value.created === "boolean", `the studio push route at ${serverUrl}`));
239
244
  }
240
245
  /** `POST /studio/projects/:project/deploy` — Publish, in the project's sandbox. */
241
- function publishStudioProject(serverUrl, apiKey, project, opts = {}) {
242
- return apiRequest(`${studioProjectApiUrl(serverUrl, project)}/deploy`, {
246
+ function publishStudioProject(serverUrl, apiKey, project, opts = {}, request = apiRequest) {
247
+ return request(`${studioProjectApiUrl(serverUrl, project)}/deploy`, {
243
248
  apiKey,
244
249
  action: "publish",
245
250
  method: "POST",
@@ -248,4 +253,4 @@ function publishStudioProject(serverUrl, apiKey, project, opts = {}) {
248
253
  });
249
254
  }
250
255
  //#endregion
251
- export { publishStudioProject as a, studioProjectUrl as c, apiTestSeam as d, checkedResponse as f, projectNameFromDir as i, HINT_NOT_DEPLOYED as l, fetchStudioProject as n, pushStudioSource as o, isStringArray as p, listStudioProjects as r, studioProjectApiUrl as s, collectSourceFiles as t, apiRequest as u };
256
+ export { projectNameFromDir as a, studioProjectApiUrl as c, apiRequest as d, apiTestSeam as f, listStudioProjects as i, studioProjectUrl as l, isStringArray as m, collectSourceFiles as n, publishStudioProject as o, checkedResponse as p, fetchStudioProject as r, pushStudioSource as s, REAL_STUDIO_DEPS as t, HINT_NOT_DEPLOYED as u };
package/dist/_studio.d.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  * Publish route (which runs the deploy machinery in the project's sandbox).
8
8
  */
9
9
  import { type WorkspaceSnapshot } from "@alexkroman1/aai/workspace-files";
10
+ import { resolveDeployTarget } from "./_agent.ts";
11
+ import { apiRequest } from "./_api-client.ts";
10
12
  /**
11
13
  * Snapshot the local project into a workspace file map.
12
14
  *
@@ -51,6 +53,16 @@ export declare function studioProjectUrl(serverUrl: string, project: string): st
51
53
  * question the reader had to answer six times.
52
54
  */
53
55
  export declare function studioProjectApiUrl(serverUrl: string, project: string): string;
56
+ /**
57
+ * What the studio commands (`aai list/pull/push/publish/delete`) reach the
58
+ * platform through: the target resolver and the one request function. The
59
+ * seam a spec hands fakes through; every command defaults to the real pair.
60
+ */
61
+ export type StudioDeps = {
62
+ resolveDeployTarget: typeof resolveDeployTarget;
63
+ apiRequest: typeof apiRequest;
64
+ };
65
+ export declare const REAL_STUDIO_DEPS: StudioDeps;
54
66
  /** `GET /studio/projects/:project` — see `projectPayload` server-side. */
55
67
  export type StudioProject = {
56
68
  files: Record<string, string>;
@@ -58,21 +70,21 @@ export type StudioProject = {
58
70
  deployedSlug?: string;
59
71
  unpublished?: boolean;
60
72
  };
61
- export declare function listStudioProjects(serverUrl: string, apiKey: string): Promise<string[]>;
73
+ export declare function listStudioProjects(serverUrl: string, apiKey: string, request?: typeof apiRequest): Promise<string[]>;
62
74
  /** Fetch a project, or null when it doesn't exist (the push existence probe). */
63
- export declare function fetchStudioProject(serverUrl: string, apiKey: string, project: string): Promise<StudioProject | null>;
75
+ export declare function fetchStudioProject(serverUrl: string, apiKey: string, project: string, request?: typeof apiRequest): Promise<StudioProject | null>;
64
76
  /** `PUT /studio/projects/:project/source` — the atomic whole-tree push. */
65
77
  export declare function pushStudioSource(serverUrl: string, apiKey: string, project: string, body: {
66
78
  files: Record<string, string>;
67
79
  baseHash?: string | undefined;
68
- }): Promise<{
80
+ }, request?: typeof apiRequest): Promise<{
69
81
  sourceHash: string;
70
82
  created: boolean;
71
83
  }>;
72
84
  /** `POST /studio/projects/:project/deploy` — Publish, in the project's sandbox. */
73
85
  export declare function publishStudioProject(serverUrl: string, apiKey: string, project: string, opts?: {
74
86
  skipTypecheck?: boolean | undefined;
75
- }): Promise<{
87
+ }, request?: typeof apiRequest): Promise<{
76
88
  ok: true;
77
89
  slug: string;
78
90
  url: string;
@@ -137,3 +137,5 @@ export declare const FEATURE_DETECTED_NODE_BUILTINS: readonly string[];
137
137
  export declare function bundleTargetEntry(cwd: string, source: string, name: string): Promise<string>;
138
138
  /** Whether a path exists — the check every emit makes of an optional file. */
139
139
  export declare function targetPathExists(target: string): Promise<boolean>;
140
+ /** Copy each {@link RUNTIME_FILES} entry that exists under `cwd` into `outDir`. */
141
+ export declare function copyRuntimeFiles(cwd: string, outDir: string): Promise<void>;
@@ -23,11 +23,15 @@ const REPO_URL = `https://github.com/alexkroman/agent`;
23
23
  function bundledTemplatesDir() {
24
24
  return import.meta.dirname;
25
25
  }
26
- /** Resolve the templates root — env override, then monorepo, then bundled. */
27
- function resolveTemplatesDir() {
26
+ /**
27
+ * Resolve the templates root — env override, then monorepo, then bundled.
28
+ * `findMonorepoRoot` is injectable so a spec, which always runs inside the
29
+ * monorepo, can stand outside it.
30
+ */
31
+ function resolveTemplatesDir(findMonorepoRoot = getMonorepoRoot) {
28
32
  const override = process.env.AAI_TEMPLATES_DIR;
29
33
  if (override) return override;
30
- const monorepoRoot = getMonorepoRoot();
34
+ const monorepoRoot = findMonorepoRoot();
31
35
  if (monorepoRoot) return path.join(monorepoRoot, "packages", "aai-templates");
32
36
  return bundledTemplatesDir();
33
37
  }
@@ -117,10 +121,10 @@ function templateCopyFilter(src) {
117
121
  return !(IGNORED_WORKSPACE_DIRS.has(name) || isLocalOnlyFile(name));
118
122
  }
119
123
  /**
120
- * Copy a template into targetDir, merging scaffold files underneath.
124
+ * Copy a template into targetDir, merging scaffold files underneath. `root` is
125
+ * the templates root, resolved by {@link resolveTemplatesDir} unless given.
121
126
  */
122
- async function downloadAndMergeTemplate(template, targetDir) {
123
- const root = resolveTemplatesDir();
127
+ async function downloadAndMergeTemplate(template, targetDir, root = resolveTemplatesDir()) {
124
128
  const templatesDir = path.join(root, "templates");
125
129
  const names = await listTemplates(root);
126
130
  if (!names.includes(template)) throw new Error(`Unknown template "${template}". Available templates: ${names.join(", ")}`);
@@ -15,6 +15,12 @@ export declare const REPO_URL = "https://github.com/alexkroman/agent";
15
15
  * anything from GitHub.
16
16
  */
17
17
  export declare function bundledTemplatesDir(): string;
18
+ /**
19
+ * Resolve the templates root — env override, then monorepo, then bundled.
20
+ * `findMonorepoRoot` is injectable so a spec, which always runs inside the
21
+ * monorepo, can stand outside it.
22
+ */
23
+ export declare function resolveTemplatesDir(findMonorepoRoot?: () => string | null): string;
18
24
  /**
19
25
  * List the shipped template names (sorted). Backs `aai templates` and the
20
26
  * unknown-template error, so the discoverable list and the validated list
@@ -77,6 +83,7 @@ export declare function layerScaffold(targetDir: string): Promise<void>;
77
83
  */
78
84
  export declare function templateCopyFilter(src: string): boolean;
79
85
  /**
80
- * Copy a template into targetDir, merging scaffold files underneath.
86
+ * Copy a template into targetDir, merging scaffold files underneath. `root` is
87
+ * the templates root, resolved by {@link resolveTemplatesDir} unless given.
81
88
  */
82
- export declare function downloadAndMergeTemplate(template: string, targetDir: string): Promise<void>;
89
+ export declare function downloadAndMergeTemplate(template: string, targetDir: string, root?: string): Promise<void>;
@@ -5,7 +5,7 @@ import { t as defaultUi } from "./_ui-Coe0zwmm.mjs";
5
5
  import { n as withPreservedNodeEnv } from "./_vite-env-BiyJ0GQH.mjs";
6
6
  import { n as WORKER_ARTIFACT_REL, t as CLIENT_ARTIFACT_REL } from "./_artifacts-BJOYGQPp.mjs";
7
7
  import { r as declaredEnvNames, t as DEPLOY_ENV_DECLARATION_FILE } from "./_server-common-CVXIeWrY.mjs";
8
- import { i as evalWorkerConfig, r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-CgBw5Bcu.mjs";
8
+ import { i as evalWorkerConfig, r as evalWorkerBundle, t as buildAgentBundle } from "./_bundler-B6v31ROV.mjs";
9
9
  import { assertTypechecks } from "./_typecheck-gate-CcX2gLJZ.mjs";
10
10
  import { n as classifyVitestError, r as runVitest } from "./_vitest-runner-CKI8_K1b.mjs";
11
11
  import { n as scanWorkflowDeterminism, t as determinismWarnings } from "./_workflow-determinism-CLxFQ5ox.mjs";
@@ -152,6 +152,30 @@ async function bundleTargetEntry(cwd, source, name) {
152
152
  async function targetPathExists(target) {
153
153
  return await fs.stat(target).then(() => true, () => false);
154
154
  }
155
+ /**
156
+ * Files copied verbatim into a target's output, each one read at RUNTIME by a
157
+ * path no bundler can see. A missing one is skipped rather than fatal.
158
+ *
159
+ * **`.env` is deliberately NOT here.** `resolveServerEnv` reads
160
+ * `DEPLOY_ENV_FILES` — `.env.example` then `.env` — but only the first is a
161
+ * DECLARATION; the second holds a developer's own keys, and copying it would
162
+ * bake them into a deployment artifact and let them silently win over the
163
+ * values set in the target's own environment. Declarations ship, values come
164
+ * from the platform environment. Verified by building the `quickstart-agent`
165
+ * template for Vercel: a local `.env` with live credentials landed in the
166
+ * function until this list dropped it.
167
+ */
168
+ const RUNTIME_FILES = [WORKER_ARTIFACT_REL, ".env.example"];
169
+ /** Copy each {@link RUNTIME_FILES} entry that exists under `cwd` into `outDir`. */
170
+ async function copyRuntimeFiles(cwd, outDir) {
171
+ for (const rel of RUNTIME_FILES) {
172
+ const from = path.join(cwd, rel);
173
+ if (!await targetPathExists(from)) continue;
174
+ const to = path.join(outDir, rel);
175
+ await fs.mkdir(path.dirname(to), { recursive: true });
176
+ await fs.copyFile(from, to);
177
+ }
178
+ }
155
179
  //#endregion
156
180
  //#region src/_target-output.ts
157
181
  /**
@@ -184,8 +208,6 @@ async function targetPathExists(target) {
184
208
  * the output holds its own `.aai/` — the layout the server already knows,
185
209
  * rather than a second one this module would have to teach it.
186
210
  */
187
- /** Files copied verbatim, each read at RUNTIME by a path no bundler can see. */
188
- const RUNTIME_FILES$1 = [WORKER_ARTIFACT_REL, ".env.example"];
189
211
  /**
190
212
  * Write a target's self-contained directory and answer its absolute path.
191
213
  *
@@ -204,13 +226,7 @@ async function emitSelfContainedOutput(cwd, target, options = {}) {
204
226
  await fs.mkdir(outputDir, { recursive: true });
205
227
  const bundle = options.bundle ?? ((dir) => bundleTargetEntry(dir, target.entrySource, target.name));
206
228
  await fs.writeFile(path.join(outputDir, target.entryFile), await bundle(cwd), "utf-8");
207
- for (const rel of RUNTIME_FILES$1) {
208
- const from = path.join(cwd, rel);
209
- if (!await targetPathExists(from)) continue;
210
- const to = path.join(outputDir, rel);
211
- await fs.mkdir(path.dirname(to), { recursive: true });
212
- await fs.copyFile(from, to);
213
- }
229
+ await copyRuntimeFiles(cwd, outputDir);
214
230
  const clientSource = await targetPathExists(path.join(cwd, CLIENT_ARTIFACT_REL, "index.html")) ? path.join(cwd, CLIENT_ARTIFACT_REL) : defaultClientDir();
215
231
  await fs.cp(clientSource, path.join(outputDir, CLIENT_ARTIFACT_REL), { recursive: true });
216
232
  return outputDir;
@@ -304,20 +320,6 @@ async function emitModalOutput(cwd, options) {
304
320
  * `_target-bundle.ts`, which every target that emits an entry shares.
305
321
  */
306
322
  /**
307
- * Files copied verbatim into the function, each one read at RUNTIME by a path
308
- * no bundler can see. A missing one is skipped rather than fatal.
309
- *
310
- * **`.env` is deliberately NOT here.** `resolveServerEnv` reads
311
- * {@link DEPLOY_ENV_FILES} — `.env.example` then `.env` — but only the first is
312
- * a DECLARATION; the second holds a developer's own keys, and copying it would
313
- * bake them into a deployment artifact and let them silently win over the
314
- * values set in the Vercel project. Declarations ship, values come from the
315
- * platform environment. Verified by building the `quickstart-agent` template: a local
316
- * `.env` with live credentials landed in the function until this list dropped
317
- * it.
318
- */
319
- const RUNTIME_FILES = [WORKER_ARTIFACT_REL, ".env.example"];
320
- /**
321
323
  * Write `.vercel/output/` for this project.
322
324
  *
323
325
  * The directory is REMOVED first. It is not addressed by content, so a
@@ -338,13 +340,7 @@ async function emitVercelOutput(cwd, options = {}) {
338
340
  await fs.writeFile(path.join(functionDir, ".vc-config.json"), vercelFunctionConfigSource(), "utf-8");
339
341
  const bundle = options.bundle ?? ((dir) => bundleTargetEntry(dir, VERCEL_ENTRY_SOURCE, "vercel"));
340
342
  await fs.writeFile(path.join(functionDir, "index.mjs"), await bundle(cwd), "utf-8");
341
- for (const rel of RUNTIME_FILES) {
342
- const from = path.join(cwd, rel);
343
- if (!await targetPathExists(from)) continue;
344
- const to = path.join(functionDir, rel);
345
- await fs.mkdir(path.dirname(to), { recursive: true });
346
- await fs.copyFile(from, to);
347
- }
343
+ await copyRuntimeFiles(cwd, functionDir);
348
344
  const clientSource = await targetPathExists(path.join(cwd, CLIENT_ARTIFACT_REL, "index.html")) ? path.join(cwd, CLIENT_ARTIFACT_REL) : defaultClientDir();
349
345
  await fs.cp(clientSource, staticDir, { recursive: true });
350
346
  await fs.cp(clientSource, path.join(functionDir, CLIENT_ARTIFACT_REL), { recursive: true });
@@ -367,7 +363,7 @@ async function emitVercelOutput(cwd, options = {}) {
367
363
  /**
368
364
  * The prose slot, named by convention. Mirrors `worker-bundler.ts`'s constant of
369
365
  * the same name — the two cannot share one without an import cycle
370
- * (`build.ts` → `_bundler.ts` → `worker-bundler.ts`), so `_build.test.ts` pins
366
+ * (`build.ts` → `_bundler.ts` → `worker-bundler.ts`), so `build.test.ts` pins
371
367
  * the pair end to end instead: a build whose prompt really came from the file
372
368
  * has to report the file.
373
369
  */
@@ -7,4 +7,11 @@
7
7
  * `workflow.ts` and are imported lazily, exactly as every other command here
8
8
  * does it — the CLI's startup path must not pay for a group nobody invoked.
9
9
  */
10
+ /** The executors this group dispatches to — `workflow.ts`'s, loaded on first use. */
11
+ export type WorkflowExecutors = Pick<typeof import("./workflow.ts"), "executeWorkflowList" | "executeWorkflowRuns" | "executeWorkflowShow" | "executeWorkflowCancel">;
12
+ /**
13
+ * Build the group over `load`, which resolves the executors only when a verb
14
+ * runs (the lazy import above). The seam a spec hands fake executors through.
15
+ */
16
+ export declare function createWorkflowCommand(load?: () => Promise<WorkflowExecutors>): import("citty").CommandDef<import("citty").ArgsDef>;
10
17
  export declare const workflow: import("citty").CommandDef<import("citty").ArgsDef>;