@alexkroman1/aai-cli 9.1.0 → 10.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 (81) hide show
  1. package/dist/{_bundler-CDuYl5Gb.mjs → _bundler-B31MqYaD.mjs} +7 -33
  2. package/dist/_bundler.d.ts +3 -41
  3. package/dist/{_dev-server-BAR8Ya43.mjs → _dev-server-Bo5dSBzQ.mjs} +140 -44
  4. package/dist/_dev-server.d.ts +1 -8
  5. package/dist/_dev-vite-config.d.ts +21 -0
  6. package/dist/{_init-BNotRgV1.mjs → _init-BURbdHNM.mjs} +1 -1
  7. package/dist/{_slug-api--ZBmIGH-.mjs → _slug-api-CfGQq1Tt.mjs} +1 -1
  8. package/dist/{_templates-4WcKOjS5.mjs → _templates-0Zr2z6yA.mjs} +37 -2
  9. package/dist/_templates.d.ts +29 -0
  10. package/dist/{build-DvDdSwAS.mjs → build-DKC2e9o_.mjs} +1 -2
  11. package/dist/cli.mjs +46 -22
  12. package/dist/{delete-8pjH8n8n.mjs → delete-X_CRgCf6.mjs} +1 -1
  13. package/dist/{deploy-CjU3e-3P.mjs → deploy-CchW5pmw.mjs} +2 -2
  14. package/dist/{dev-dFzdvwa7.mjs → dev-BfVl1uBA.mjs} +1 -1
  15. package/dist/{init-DK7GpIF9.mjs → init-BRfoc2EK.mjs} +2 -2
  16. package/dist/{logs-D2Yhqe2w.mjs → logs-hWnJ66Bl.mjs} +2 -2
  17. package/dist/scaffold/CLAUDE.md +162 -54
  18. package/dist/scaffold/package.json +4 -6
  19. package/dist/scaffold/server.mjs +12 -23
  20. package/dist/{secret-CwgDLpSy.mjs → secret-B-3T5tvr.mjs} +2 -2
  21. package/dist/{studio-D3-HWIfk.mjs → studio-wVWNLREn.mjs} +4 -3
  22. package/dist/templates/call-audit/agent.eval.test.ts +1 -1
  23. package/dist/templates/call-audit/agent.test.ts +80 -8
  24. package/dist/templates/call-audit/client.tsx +87 -3
  25. package/dist/templates/call-audit/workflows/audit.ts +52 -32
  26. package/dist/templates/call-audit/workflows/ingest.ts +15 -15
  27. package/dist/templates/call-audit/workflows/media.ts +1 -1
  28. package/dist/templates/call-audit/workflows/summarize.ts +0 -4
  29. package/dist/templates/link-digest/agent.eval.test.ts +4 -2
  30. package/dist/templates/link-digest/agent.test.ts +25 -5
  31. package/dist/templates/link-digest/client.tsx +65 -7
  32. package/dist/templates/link-digest/workflows/digest.ts +39 -29
  33. package/dist/templates/podcast-digest/agent.eval.test.ts +5 -5
  34. package/dist/templates/podcast-digest/agent.test.ts +108 -2
  35. package/dist/templates/podcast-digest/client.tsx +89 -8
  36. package/dist/templates/podcast-digest/workflows/digest.ts +67 -48
  37. package/dist/templates/podcast-digest/workflows/feeds.ts +1 -4
  38. package/dist/templates/podcast-digest/workflows/slack.ts +5 -6
  39. package/dist/templates/recap-workflow/agent.eval.test.ts +72 -8
  40. package/dist/templates/recap-workflow/agent.test.ts +323 -83
  41. package/dist/templates/recap-workflow/shared.ts +4 -3
  42. package/dist/templates/recap-workflow/workflows/recap.ts +322 -86
  43. package/dist/templates/recap-workflow/workflows/tokens.ts +21 -0
  44. package/dist/templates/redline/agent.eval.test.ts +1 -1
  45. package/dist/templates/redline/agent.test.ts +1 -1
  46. package/dist/templates/redline/client.tsx +83 -3
  47. package/dist/templates/redline/workflows/redline.ts +26 -23
  48. package/dist/templates/research-workflow/agent.eval.test.ts +9 -8
  49. package/dist/templates/research-workflow/agent.test.ts +32 -6
  50. package/dist/templates/research-workflow/agent.ts +4 -4
  51. package/dist/templates/research-workflow/shared.ts +4 -3
  52. package/dist/templates/research-workflow/workflows/prompts.ts +1 -1
  53. package/dist/templates/research-workflow/workflows/research.ts +35 -38
  54. package/dist/templates/spoken-summary/agent.eval.test.ts +3 -3
  55. package/dist/templates/spoken-summary/agent.test.ts +10 -8
  56. package/dist/templates/spoken-summary/client.tsx +72 -3
  57. package/dist/templates/spoken-summary/workflows/summarize.ts +25 -21
  58. package/dist/templates/spoken-summary/workflows/transcribe.ts +15 -18
  59. package/dist/templates/transcription-workflow/agent.eval.test.ts +1 -1
  60. package/dist/templates/transcription-workflow/agent.test.ts +720 -16
  61. package/dist/templates/transcription-workflow/agent.ts +6 -4
  62. package/dist/templates/transcription-workflow/client.tsx +106 -308
  63. package/dist/templates/transcription-workflow/recover.test.ts +141 -0
  64. package/dist/templates/transcription-workflow/recover.ts +130 -0
  65. package/dist/templates/transcription-workflow/run-panel.tsx +203 -0
  66. package/dist/templates/transcription-workflow/total-latency.tsx +144 -0
  67. package/dist/templates/transcription-workflow/workflows/batch.ts +21 -24
  68. package/dist/templates/transcription-workflow/workflows/downsample.ts +273 -0
  69. package/dist/templates/transcription-workflow/workflows/normalize.ts +17 -40
  70. package/dist/templates/transcription-workflow/workflows/stream.ts +311 -38
  71. package/dist/templates/transcription-workflow/workflows/transcribe.ts +69 -32
  72. package/dist/templates/transcription-workflow/workflows/wav.ts +15 -4
  73. package/dist/worker-bundler.d.ts +0 -14
  74. package/dist/worker-bundler.mjs +149 -1
  75. package/dist/{workflow-BflATMmU.mjs → workflow-BBu5oEDw.mjs} +84 -10
  76. package/dist/workflow.d.ts +1 -0
  77. package/package.json +4 -6
  78. package/dist/_workflow-scan.d.ts +0 -108
  79. package/dist/worker-bundler-CCVEDjm1.mjs +0 -650
  80. package/dist/workflow-bundler.d.ts +0 -138
  81. package/dist/{_studio-CKrsixd0.mjs → _studio-B1waXMuR.mjs} +1 -1
@@ -1,138 +0,0 @@
1
- /**
2
- * Workflow bundling — turning a project's `workflows/` directory into the two
3
- * small artifacts a guest needs to run durable workflows.
4
- *
5
- * Public (no `_` prefix) for the same reason as `worker-bundler.ts`: the studio
6
- * builds its workspaces through this too, so a workflow published from the
7
- * browser comes out of the same pass as one from `aai build`.
8
- *
9
- * @internal — build hook for aai-server/the studio; not a supported public API
10
- * and not covered by semver.
11
- *
12
- * ## Why this exists at all
13
- *
14
- * The Workflow Development Kit's own integrations (Next, Nitro, SvelteKit) build
15
- * workflow routes while building the SERVER, by scanning `workflows/` and
16
- * emitting handler files. That model does not fit this platform: the guest image
17
- * is baked once and then serves MANY tenants' agents, each arriving over
18
- * `bundle/load` at runtime. There is no `workflows/` directory in existence when
19
- * the harness is built. So the transform has to happen per tenant at deploy
20
- * time — here — and the guest receives the result as data.
21
- *
22
- * ## The two artifacts, and why they are small
23
- *
24
- * A default `workflow build` emits a 3.7 MB flow bundle and a 12 MB step bundle,
25
- * because each one inlines the whole WDK runtime. Neither could ride the guest's
26
- * single-ESM-string delivery. Two settings fix that, and both are load-bearing:
27
- *
28
- * - **`externalPackages: ["workflow", …]`** — the WDK is resolved from the
29
- * guest's BAKED image instead of being inlined. Step bundle: 12 MB → ~7 KB.
30
- * - **`bundleFinalOutput: false`** — skips wrapping the workflow-mode code in a
31
- * runtime host, which is exactly what `workflowEntrypoint(code)` supplies
32
- * itself at the other end. Dialog bundle: 3.7 MB → ~69 KB.
33
- *
34
- * So `workflowCode` is passed to `workflowEntrypoint()` in the guest and
35
- * `stepCode` is evaluated there to register its step functions.
36
- *
37
- * ## The THIRD transform, which is the agent bundle's
38
- *
39
- * Those two are what the queue runs. The agent bundle needs a third —
40
- * `applySwcTransform(…, "client")`, wired in as {@link workflowClientPlugin} —
41
- * and without it the whole mechanism is inert: `ctx.workflows.start` reads the
42
- * `workflowId` the compiler attaches to a directive body, and Vite bundling
43
- * `workflows/research.ts` the ordinary way attaches nothing. The symptom is
44
- * `MISSING_WORKFLOW_ID_MESSAGE` at the first `start()` — an agent that builds,
45
- * deploys, boots and answers the phone, and cannot start a run.
46
- *
47
- * The plugin transforms EXACTLY the files the builder scanned (`inputFiles`),
48
- * not "every file with a directive". Same list, same `moduleSpecifierRoot`,
49
- * therefore the same ids by construction — a body outside `workflows/` cannot
50
- * acquire an id that no flow bundle registered, which would trade a clear
51
- * failure at `start()` for a run that enqueues and then fails at replay.
52
- *
53
- * ## Config details that are not optional
54
- *
55
- * Each of these cost real time to find, and none fails in a way that names
56
- * itself:
57
- *
58
- * - `dirs` must carry the `./` prefix. A bare `"workflows"` crashes inside
59
- * enhanced-resolve with `Cannot read properties of undefined (reading
60
- * 'length')` from `join(undefined, …)`, nowhere near the cause.
61
- * - Every bundle path must be ABSOLUTE, for the same reason.
62
- * - `projectRoot` and `moduleSpecifierRoot` must be set explicitly; they do not
63
- * default to `workingDir` on the path this takes.
64
- * - `keepInterimBundleContext` must stay off — it leaves an esbuild watch context
65
- * alive, so a one-shot build never exits.
66
- */
67
- import type { Plugin } from "vite";
68
- /**
69
- * The directory a project's `"use workflow"` bodies live in.
70
- *
71
- * The WDK builder's convention, not ours, and it is why a workflow body cannot
72
- * live in `agent.ts`: only files under here are transformed. A body outside it
73
- * runs inline, once, with no durability and nothing reporting that.
74
- */
75
- export declare const WORKFLOWS_DIR = "workflows";
76
- /** What a guest needs to serve workflows for one agent. */
77
- export type WorkflowBundleOutput = {
78
- /**
79
- * The workflow-mode transform of every `"use workflow"` body, as code.
80
- *
81
- * Passed to `workflowEntrypoint(code)` in the guest — which is why it is a
82
- * STRING rather than a file: the guest never sees this project's filesystem.
83
- */
84
- workflowCode: string;
85
- /**
86
- * The step-mode transform, as code. Evaluated in the guest so its
87
- * `registerStepFunction` calls run; nothing imports anything from it.
88
- */
89
- stepCode: string;
90
- /**
91
- * The builder's manifest — `workflowId` per exported workflow, plus the step
92
- * graph. The ids are what `ctx.workflows.start` needs, and the SDK reads them
93
- * off each body's own `workflowId` property, so nothing consumes this at
94
- * runtime; it is the builder's own output, kept for inspection and asserted
95
- * by this package's spec.
96
- *
97
- * It is deliberately NOT emitted into the worker bundle. It was, as a
98
- * double-encoded `__aaiWorkflowManifest` string literal, on the stated
99
- * grounds that "the studio's workflows card renders it" — which was never
100
- * true (the card calls `GET /workflows`). Nothing anywhere read the export,
101
- * so it was bytes in every deploy artifact, re-fetched and hash-verified on
102
- * every cold guest boot, for no reader.
103
- */
104
- manifest: unknown;
105
- /**
106
- * The absolute paths the builder scanned — the agent bundle's client
107
- * transform runs over exactly these. See the module doc's third-transform
108
- * section for why it is this list and not a content sniff.
109
- */
110
- inputFiles: readonly string[];
111
- /**
112
- * Replay-safety findings, as lines to print. See {@link replayWarnings} for
113
- * why they are warnings rather than a failed build.
114
- */
115
- warnings: readonly string[];
116
- };
117
- /**
118
- * Attach the compiler's `workflowId`/`stepId` to the agent bundle's copy of
119
- * each directive body — the third transform, see the module doc.
120
- *
121
- * `enforce: "pre"` so it sees the file before Vite's own TypeScript pass: the
122
- * swc transform reads types itself (it is given the filename to infer syntax),
123
- * and its output is plain JS that the later pass leaves alone.
124
- *
125
- * @internal
126
- */
127
- export declare function workflowClientPlugin(cwd: string, inputFiles: readonly string[]): Plugin;
128
- /**
129
- * Build a project's workflows, or resolve `undefined` when it declares none.
130
- *
131
- * `undefined` rather than empty strings, because "this project has no workflows"
132
- * is the common case — every voice agent that never reaches for one — and the
133
- * guest must be able to tell it apart from "the build produced nothing", which
134
- * would be a bug.
135
- *
136
- * @internal
137
- */
138
- export declare function buildWorkflows(cwd: string): Promise<WorkflowBundleOutput | undefined>;
@@ -3,9 +3,9 @@ import { t as CliError } from "./_output-CKkmWs7i.mjs";
3
3
  import path from "node:path";
4
4
  import { isRecord, omitUndefined } from "@alexkroman1/aai/utils";
5
5
  import { MAX_SLUG_LENGTH, PREVIEW_SLUG_SUFFIX, VALID_SLUG_RE } from "@alexkroman1/aai/internal";
6
+ import { isLocalOnlyFile, snapshotWorkspaceFiles } from "@alexkroman1/aai/workspace-files";
6
7
  import { FetchError, ofetch } from "ofetch";
7
8
  import { slugifyName } from "@alexkroman1/aai/slugify";
8
- import { isLocalOnlyFile, snapshotWorkspaceFiles } from "@alexkroman1/aai/workspace-files";
9
9
  //#region _api-client.ts
10
10
  /**
11
11
  * Shared HTTP helper for platform API calls (deploy, delete, secrets).