@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
@@ -2,13 +2,13 @@
2
2
 
3
3
  Part of the aai authoring guide (start with the core guide). A voice agent's
4
4
  page mounts with `mountClient()`; a workflow app's mounts with `mountPage()`
5
- (see "The page" in `WORKFLOWS.md`). Both are React 19 + Tailwind v4, bundled
6
- by the CLI with no `vite.config.ts`.
5
+ (see "The page" in `WORKFLOWS.md`). Both are React 19 + Tailwind v4, bundled by
6
+ the CLI with no `vite.config.ts`.
7
7
 
8
8
  ## Custom UI — `mountClient()`
9
9
 
10
- File: `client.tsx` alongside `agent.ts`. Uses **React** (not Preact).
11
- Always import `"@alexkroman1/aai-ui/styles.css"` first.
10
+ File: `client.tsx` alongside `agent.ts`. Uses **React** (not Preact). Always
11
+ import `"@alexkroman1/aai-ui/styles.css"` first.
12
12
 
13
13
  ### Tier 1 — config only (default UI)
14
14
 
@@ -101,15 +101,14 @@ Beside a `component`, `sidebar` still renders; `name` becomes the page title.
101
101
  | `started` | `boolean` | Whether session started |
102
102
  | `running` | `boolean` | Whether session active |
103
103
 
104
- Methods: `start()`, `toggle()`, `cancel()`, `disconnect()`, `resetState()`,
105
- and:
104
+ Methods: `start()`, `toggle()`, `cancel()`, `disconnect()`, `resetState()`, and:
106
105
 
107
- - `end()` hangs up: `started` goes `false`; the next `start()` is a new
108
- session (fresh tool state, greeting). For End/Hang up/New game.
109
- - `reset()` clears the conversation, keeping the call and tool state. For
110
- "clear chat", not ending.
111
- - `sendText(text)`: a TYPED turn, answered as if spoken. The server's
112
- transcript adds it to `messages`; don't. Pipeline agents only.
106
+ - `end()` hangs up: `started` goes `false`; the next `start()` is a new session
107
+ (fresh tool state, greeting). For End/Hang up/New game.
108
+ - `reset()` clears the conversation, keeping the call and tool state. For "clear
109
+ chat", not ending.
110
+ - `sendText(text)`: a TYPED turn, answered as if spoken. The server's transcript
111
+ adds it to `messages`; don't. Pipeline agents only.
113
112
  - `setMicMuted(muted)`: mute without hanging up (streams silence), e.g.
114
113
  hold-to-talk. Read as `micMuted`.
115
114
 
@@ -125,13 +124,13 @@ useToolResult<ResultType>("tool_name", (result) => { ... }) // typed (opt
125
124
  ```
126
125
 
127
126
  `result` is the tool's return value, already JSON-parsed and untyped — read
128
- fields off it directly (`result.price`). The type parameter is optional; add
129
- it only when you want the shape checked.
127
+ fields off it directly (`result.price`). The type parameter is optional; add it
128
+ only when you want the shape checked.
130
129
 
131
- **There is no global `JSX` namespace.** React 19 removed it, so
132
- `JSX.Element` is `Cannot find namespace 'JSX'` (`TS2503`). Type a component's
133
- return as `ReactNode` — `import type { ReactNode } from "react"` — which is
134
- also what you want for anything that can be a string, an array, or null.
130
+ **There is no global `JSX` namespace.** React 19 removed it, so `JSX.Element` is
131
+ `Cannot find namespace 'JSX'` (`TS2503`). Type a component's return as
132
+ `ReactNode` — `import type { ReactNode } from "react"` — which is also what you
133
+ want for anything that can be a string, an array, or null.
135
134
 
136
135
  **`useAgentState`** — the agent's session state, pushed automatically:
137
136
 
@@ -161,16 +160,16 @@ pushed before the first tool call); `useAgentState("cart", fallback)` returns
161
160
  factory is expensive to import into the browser. `selectAgentState("cart")` is
162
161
  the same slot as a `useSessionSelector` selector.
163
162
 
164
- **Reach for this before wiring `useToolResult` into `useState`.** Without
165
- it the pattern is: return a cart snapshot from every tool, declare a type
166
- describing what those tools return, and mirror it into `useState` — three
167
- things to keep in step, and the usual source of drift when you add a tool
168
- and forget to return the snapshot from it.
163
+ **Reach for this before wiring `useToolResult` into `useState`.** Without it the
164
+ pattern is: return a cart snapshot from every tool, declare a type describing
165
+ what those tools return, and mirror it into `useState` — three things to keep in
166
+ step, and the usual source of drift when you add a tool and forget to return the
167
+ snapshot from it.
169
168
 
170
- `syncState` holds projections, not flags, because state often holds things
171
- that should not reach a browser (keys, PINs, scratch) or cannot be
172
- serialized. Whatever it returns is exactly what the client receives. It runs
173
- after every tool call and is sent only when the result changed.
169
+ `syncState` holds projections, not flags, because state often holds things that
170
+ should not reach a browser (keys, PINs, scratch) or cannot be serialized.
171
+ Whatever it returns is exactly what the client receives. It runs after every
172
+ tool call and is sent only when the result changed.
174
173
 
175
174
  **`useEvent`** — fires for custom events from `ctx.send()`:
176
175
 
@@ -178,15 +177,16 @@ after every tool call and is sent only when the result changed.
178
177
  useEvent<DataType>("event_name", (data) => { ... })
179
178
  ```
180
179
 
181
- Server: `ctx.send("order", { total: "$14.99" })` —
182
- Client: `useEvent("order", (data) => ...)`.
180
+ Server: `ctx.send("order", { total: "$14.99" })` — Client:
181
+ `useEvent("order", (data) => ...)`.
183
182
 
184
183
  **`useTheme`** — returns `{ bg, primary, text, surface, border }`.
185
184
 
186
185
  **`useToolCallStart`** — fires when a tool call begins (status `"pending"`).
187
186
 
188
187
  **`useClientTool`** — runs a server `clientTool` in the page and answers the
189
- model with the handler's return value (see "A tool the BROWSER runs" in `TOOLS.md`):
188
+ model with the handler's return value (see "A tool the BROWSER runs" in
189
+ `TOOLS.md`):
190
190
 
191
191
  ```tsx
192
192
  import { useClientTool } from "@alexkroman1/aai-ui";
@@ -199,9 +199,9 @@ export function ConfirmTool({ ask }: { ask: (question: string) => Promise<boolea
199
199
  }
200
200
  ```
201
201
 
202
- **Anti-pattern:** Do NOT use `useEffect` + `toolCalls` to build derived
203
- state. Use `useToolResult` — it deduplicates. The `useEffect` pattern
204
- re-processes every tool call on every render, causing duplicates.
202
+ **Anti-pattern:** Do NOT use `useEffect` + `toolCalls` to build derived state.
203
+ Use `useToolResult` — it deduplicates. The `useEffect` pattern re-processes
204
+ every tool call on every render, causing duplicates.
205
205
 
206
206
  ## Components
207
207
 
@@ -222,9 +222,10 @@ the DOM and hands them over once the browser's own validation passes; the field
222
222
  components — `TextField`, `TextAreaField`, `NumberField`, `SelectField`,
223
223
  `CheckboxField`, `FileField` and `SubmitButton` — are plain named inputs, and
224
224
  `Field`/`FieldShell` are what a custom control wraps itself in to match them.
225
- For a workflow app there is usually no field markup at all: `<WorkflowFields
226
- workflow="name" />` fetches that workflow's input schema and renders a control
227
- per field, so a page written against one workflow serves another.
225
+ For a workflow app there is usually no field markup at all:
226
+ `<WorkflowFields workflow="name" />` fetches that workflow's input schema and
227
+ renders a control per field, so a page written against one workflow serves
228
+ another.
228
229
 
229
230
  ```tsx no-check
230
231
  import { Form, WorkflowFields } from "@alexkroman1/aai-ui";
@@ -238,8 +239,8 @@ import { Form, WorkflowFields } from "@alexkroman1/aai-ui";
238
239
  writes its form by hand, which is what the two are for.
239
240
 
240
241
  The usual shape — note `StartScreen` **wraps** the app rather than sitting
241
- beside it; writing `<StartScreen ... />` self-closing is a `TS2741:
242
- Property 'children' is missing` build error:
242
+ beside it; writing `<StartScreen ... />` self-closing is a
243
+ `TS2741: Property 'children' is missing` build error:
243
244
 
244
245
  ```tsx
245
246
  /// <reference types="vite/client" />
@@ -259,12 +260,12 @@ mountClient({ component: PizzaApp });
259
260
 
260
261
  ## Styling
261
262
 
262
- - **Tailwind CSS v4** — compiled at bundle time, configured via CSS.
263
- Do NOT create `tailwind.config.js` — it will be ignored.
263
+ - **Tailwind CSS v4** — compiled at bundle time, configured via CSS. Do NOT
264
+ create `tailwind.config.js` — it will be ignored.
264
265
  - Use Tailwind classes for layout, `useTheme()` for dynamic colors.
265
266
  - Set theme: `mountClient({ theme: { bg, primary, text, surface, border } })`.
266
- - Override CSS custom properties for extra tokens:
267
- `--color-aai-*`, `--radius-aai`, `--font-aai`.
267
+ - Override CSS custom properties for extra tokens: `--color-aai-*`,
268
+ `--radius-aai`, `--font-aai`.
268
269
  - Always import `"@alexkroman1/aai-ui/styles.css"` at the top of `client.tsx`.
269
270
 
270
271
  ### Design guidelines
@@ -273,19 +274,19 @@ A custom UI should look deliberate, not like boilerplate. When building or
273
274
  restyling a `client.tsx`:
274
275
 
275
276
  - **Color:** pick one primary brand color, 2-3 neutrals (white/grays/black
276
- variants), and at most 1-2 accents — 3-5 colors total. Avoid gradients
277
- unless asked. If you override an element's background color, also set its
278
- text color so contrast holds.
279
- - **Typography:** at most 2 font families — one for headings, one for body.
280
- Body text 14px or larger with a relaxed line height (`leading-relaxed`).
281
- - **Layout:** design mobile-first, then enhance with responsive prefixes
282
- (`md:`, `lg:`). Prefer flexbox (`flex items-center justify-between`);
283
- use grid only for genuinely two-dimensional layouts; avoid absolute
284
- positioning unless nothing else works.
285
- - **Tailwind:** stay on the spacing scale (`p-4`, never `p-[16px]`), use
286
- `gap-*` between siblings rather than per-child margins, and wrap headings
287
- and key copy in `text-balance` or `text-pretty`.
288
- - **Accessibility:** semantic elements (`main`, `header`, `button`), alt
289
- text on meaningful images, `sr-only` labels on icon-only buttons.
290
- - **No filler:** no emojis as icons, no decorative gradient blobs or
291
- abstract placeholder shapes, no lorem-ipsum-looking content.
277
+ variants), and at most 1-2 accents — 3-5 colors total. Avoid gradients unless
278
+ asked. If you override an element's background color, also set its text color
279
+ so contrast holds.
280
+ - **Typography:** at most 2 font families — one for headings, one for body. Body
281
+ text 14px or larger with a relaxed line height (`leading-relaxed`).
282
+ - **Layout:** design mobile-first, then enhance with responsive prefixes (`md:`,
283
+ `lg:`). Prefer flexbox (`flex items-center justify-between`); use grid only
284
+ for genuinely two-dimensional layouts; avoid absolute positioning unless
285
+ nothing else works.
286
+ - **Tailwind:** stay on the spacing scale (`p-4`, never `p-[16px]`), use `gap-*`
287
+ between siblings rather than per-child margins, and wrap headings and key copy
288
+ in `text-balance` or `text-pretty`.
289
+ - **Accessibility:** semantic elements (`main`, `header`, `button`), alt text on
290
+ meaningful images, `sr-only` labels on icon-only buttons.
291
+ - **No filler:** no emojis as icons, no decorative gradient blobs or abstract
292
+ placeholder shapes, no lorem-ipsum-looking content.