@alexkroman1/aai-cli 0.15.4 → 0.16.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 (31) hide show
  1. package/dist/scaffold/CLAUDE.md +2 -2
  2. package/dist/scaffold/agent-guide/PIPELINE-TUNING.md +1 -1
  3. package/dist/scaffold/agent-guide/PROVIDERS.md +14 -15
  4. package/dist/scaffold/agent-guide/WORKFLOWS.md +1 -1
  5. package/dist/scaffold/package.json +4 -4
  6. package/dist/templates/call-audit-workflow/agent.eval.test.ts +1 -1
  7. package/dist/templates/call-audit-workflow/agent.test.ts +3 -2
  8. package/dist/templates/call-audit-workflow/agent.ts +6 -11
  9. package/dist/templates/call-audit-workflow/workflows/summarize.ts +1 -1
  10. package/dist/templates/custom-pipeline-agent/modes.test.ts +4 -4
  11. package/dist/templates/custom-pipeline-agent/stages.test.ts +8 -29
  12. package/dist/templates/executive-inbox-agent/agent.eval.test.ts +28 -5
  13. package/dist/templates/executive-inbox-agent/review.ts +3 -1
  14. package/dist/templates/executive-inbox-agent/shared.ts +1 -1
  15. package/dist/templates/home-assistant-agent/agent.ts +1 -1
  16. package/dist/templates/meeting-recap-agent/agent.ts +3 -0
  17. package/dist/templates/meeting-recap-agent/tools/cancel_recap.ts +3 -1
  18. package/dist/templates/pizza-ordering-agent/system-prompt.md +3 -0
  19. package/dist/templates/quickstart-agent/agent.eval.test.ts +5 -1
  20. package/dist/templates/quickstart-agent/agent.ts +1 -1
  21. package/dist/templates/quickstart-agent/system-prompt.md +3 -1
  22. package/dist/templates/roadside-assistance-agent/agent.eval.test.ts +3 -1
  23. package/dist/templates/spoken-summary-workflow/agent.eval.test.ts +3 -3
  24. package/dist/templates/spoken-summary-workflow/agent.test.ts +11 -13
  25. package/dist/templates/spoken-summary-workflow/agent.ts +8 -24
  26. package/dist/templates/spoken-summary-workflow/workflows/summarize.ts +1 -1
  27. package/dist/templates/tabletop-rpg-agent/system-prompt.md +1 -1
  28. package/dist/templates/text-adventure-agent/agent.ts +1 -1
  29. package/dist/templates/topic-briefing-agent/system-prompt.md +4 -0
  30. package/dist/templates/travel-concierge-agent/agent.eval.test.ts +3 -1
  31. package/package.json +4 -4
@@ -168,7 +168,7 @@ import { assemblyAITts } from "@alexkroman1/aai/tts";
168
168
 
169
169
  export default agent({
170
170
  name: "My Agent",
171
- tts: assemblyAITts({ voice: "paul" }),
171
+ tts: assemblyAITts({ voice: "aai-paul" }),
172
172
  llm: "claude-sonnet-4-6",
173
173
  greeting: "Hi, how can I help?",
174
174
  builtinTools: ["think", "web_search"],
@@ -178,7 +178,7 @@ export default agent({
178
178
  ```
179
179
 
180
180
  The fields almost every agent sets: `name` (required), `greeting` (default: "Hey
181
- there..."; `""` starts silent), `tts` (voice `jane` unless set), `llm`,
181
+ there..."; `""` starts silent), `tts` (voice `aai-jane` unless set), `llm`,
182
182
  `builtinTools` (omitted = `["think"]` only; setting it REPLACES the default),
183
183
  `maxSteps` (default 10 tool-calling steps per reply) and `requiredEnv` (every
184
184
  env var a tool or step reads; **publishing checks it**, so a missing key fails
@@ -41,7 +41,7 @@ export default agent({
41
41
  mode: "s2s",
42
42
  sttPrompt: "Callers spell order numbers one character at a time.",
43
43
  s2s: assemblyAIS2s({
44
- voice: "michael",
44
+ voice: "aai-michael",
45
45
  languages: ["en"],
46
46
  keyterms: ["Acme Rewards", "SKU"],
47
47
  }),
@@ -100,7 +100,7 @@ export default agent({
100
100
 
101
101
  | Factory | Default voice | Env var |
102
102
  | --------------- | ---------------------------------------- | -------------------- |
103
- | `assemblyAITts` | `"jane"` | `ASSEMBLYAI_API_KEY` |
103
+ | `assemblyAITts` | `"aai-jane"` | `ASSEMBLYAI_API_KEY` |
104
104
  | `cartesiaTts` | `"f786b574-daa5-4673-aa0c-cbe3e8534c02"` | `CARTESIA_API_KEY` |
105
105
  | `rimeTts` | `"cove"` (model `mistv2`) | `RIME_API_KEY` |
106
106
 
@@ -109,20 +109,19 @@ Override with `{ voice, model, language }`.
109
109
 
110
110
  **AssemblyAI TTS** shares `ASSEMBLYAI_API_KEY` with AssemblyAI STT and the LLM
111
111
  Gateway, so an all-AssemblyAI pipeline needs exactly one secret. On the default
112
- pipeline, `tts: assemblyAITts({ voice: "michael" })` changes the voice and
113
- leaves the other two stages on the default. Each voice speaks one language, and
114
- this is the whole catalog — **a voice not on this list is rejected after the
115
- socket opens, which leaves the agent connected, "ready", and permanently
116
- silent**, so pick one from here rather than guessing a plausible name:
117
-
118
- - **English, US accent**: `alba`, `anna`, `charles`, `eve`, `george`, `jane`
119
- (the default), `jean`, `mary`, `michael`
120
- - **English, UK accent**: `paul`, `vera`
121
- - **Native accent, code-switches with English**: `estelle` (fr), `giovanni`
122
- (it), `juergen` (de), `lola` (es), `rafael` (pt)
123
-
124
- There is no separate age/gender/style axis — match the persona by picking a name
125
- and accent, and put the delivery in the system prompt instead.
112
+ pipeline, `tts: assemblyAITts({ voice: "aai-michael" })` changes the voice and
113
+ leaves the other two stages on the default. A voice is a `voice_id` SLUG — the
114
+ `aai-` prefix is part of it, and the bare name is refused — and **an unknown one
115
+ is refused when the session opens**, so pick from the library
116
+ (`ASSEMBLYAI_TTS_VOICES`) rather than guessing a plausible name:
117
+
118
+ `aai-alba`, `aai-anna`, `aai-charles`, `aai-eve`, `aai-george`, `aai-jane` (the
119
+ default), `aai-jean`, `aai-mary`, `aai-michael`, `aai-paul`, `aai-vera`
120
+
121
+ Every library voice speaks all six languages; `language` (`"en"`, `"fr"`,
122
+ `"de"`, `"it"`, `"pt"`, `"es"`) picks which. There is no separate
123
+ age/gender/style axis — match the persona by picking a voice, and put the
124
+ delivery in the system prompt instead.
126
125
 
127
126
  Set `language` only alongside a voice that speaks it, as an ISO 639-1 code —
128
127
  `"en"`, `"fr"`, `"de"`, `"it"`, `"pt"`, `"es"` are the six the catalog covers,
@@ -670,7 +670,7 @@ trip.
670
670
  import { stepSpeak, stepWriteUpload } from "@alexkroman1/aai/step";
671
671
 
672
672
  export async function narrate(script: string) {
673
- const spoken = await stepSpeak(script, { voice: "jane" });
673
+ const spoken = await stepSpeak(script, { voice: "aai-jane" });
674
674
  const stored = await stepWriteUpload(spoken.audio, { name: "summary.wav", type: "audio/wav" });
675
675
  return { audio: stored.id, durationMs: spoken.durationMs };
676
676
  }
@@ -15,10 +15,10 @@
15
15
  "publish:agent": "aai publish"
16
16
  },
17
17
  "dependencies": {
18
- "@alexkroman1/aai": "^0.15.4",
19
- "@alexkroman1/aai-cli": "^0.15.4",
20
- "@alexkroman1/aai-runtime": "^0.15.4",
21
- "@alexkroman1/aai-ui": "^0.15.4",
18
+ "@alexkroman1/aai": "^0.16.0",
19
+ "@alexkroman1/aai-cli": "^0.16.0",
20
+ "@alexkroman1/aai-runtime": "^0.16.0",
21
+ "@alexkroman1/aai-ui": "^0.16.0",
22
22
  "react": "^19.3.0",
23
23
  "react-dom": "^19.3.0",
24
24
  "tailwindcss": "^4.0.0",
@@ -409,7 +409,7 @@ describeWorkflowEvalWithFfmpeg(
409
409
  expect(output.audioBytes).toBeLessThan(wavBytes / 4);
410
410
  // The run says both numbers, which is what makes the trade visible.
411
411
  expect(run.reported.at(-1)).toMatch(
412
- /^Recorded a \d+s audit in \w+'s voice — .* of MP3, from .* of WAV\.$/,
412
+ /^Recorded a \d+s audit with voice [\w-]+ — .* of MP3, from .* of WAV\.$/,
413
413
  );
414
414
 
415
415
  // The model really read the transcript, and the audit really reached the
@@ -220,7 +220,8 @@ describe("the declaration", () => {
220
220
  ?.issues,
221
221
  ).toBeTruthy();
222
222
  expect(
223
- (await audit.input?.["~standard"].validate({ recording: UPLOAD_ID, voice: "jane" }))?.issues,
223
+ (await audit.input?.["~standard"].validate({ recording: UPLOAD_ID, voice: "aai-jane" }))
224
+ ?.issues,
224
225
  ).toBeUndefined();
225
226
  });
226
227
 
@@ -829,7 +830,7 @@ describe("the ffmpeg steps, up to the spawn", () => {
829
830
  installStubReporter();
830
831
  installStubUploads({}, { writable: true });
831
832
 
832
- await expect(narrate("Read this back.", "jane")).rejects.toBeInstanceOf(FatalError);
833
+ await expect(narrate("Read this back.", "aai-jane")).rejects.toBeInstanceOf(FatalError);
833
834
  expect(speech.calls.length).toBe(1);
834
835
  expect(speech.calls[0]?.text).toBe("Read this back.");
835
836
  });
@@ -86,23 +86,18 @@
86
86
  */
87
87
 
88
88
  import { workflow, workflowApp } from "@alexkroman1/aai";
89
- import { ttsVoiceIds } from "@alexkroman1/aai/tts";
89
+ import { ASSEMBLYAI_TTS_VOICES } from "@alexkroman1/aai/tts";
90
90
  import type { WorkflowDef } from "@alexkroman1/aai/workflow-api";
91
91
  import { z } from "zod";
92
92
  import { auditFlow, type CallAudit } from "./workflows/audit.ts";
93
93
 
94
94
  /**
95
- * The voices the form offers, as the tuple `z.enum` takes.
96
- *
97
- * READ from the SDK's catalog rather than listed, because a wrong voice id is a
98
- * SILENT failure — it is a free-form string the service rejects in band after
99
- * the socket is open, so the synthesis simply produces nothing. Narrowed to the
100
- * English ones because the audit is written in the transcript's language and
101
- * the prompt does not translate; every voice in the catalog speaks exactly one.
102
- * `ttsVoiceIds` owns the derivation, including the fallback to the SDK's own
103
- * default voice should the filter ever match nothing.
95
+ * The voices the form offers: the SDK's library voices, as the tuple `z.enum`
96
+ * takes. READ from the catalog rather than listed, because a wrong voice id is
97
+ * refused when the synthesis socket opens. Every library voice speaks every
98
+ * supported language, so none needs filtering out.
104
99
  */
105
- const VOICES = ttsVoiceIds("en");
100
+ const VOICES = ASSEMBLYAI_TTS_VOICES;
106
101
 
107
102
  /**
108
103
  * The run input, as its own const.
@@ -186,7 +186,7 @@ export async function narrate(
186
186
  });
187
187
 
188
188
  await stepReport(
189
- `Recorded a ${Math.round(spoken.durationMs / 1000)}s audit in ${spoken.voice}'s voice — ` +
189
+ `Recorded a ${Math.round(spoken.durationMs / 1000)}s audit with voice ${spoken.voice} — ` +
190
190
  `${formatBytes(bytes)} of MP3, from ${formatBytes(spoken.audio.byteLength)} of WAV.`,
191
191
  );
192
192
  return {
@@ -86,11 +86,11 @@ describe("three modes, three members", () => {
86
86
  // reads the second. A voice has no shorthand: it is the TTS descriptor's.
87
87
  const def: AgentDef = agent({
88
88
  ...SHARED,
89
- tts: assemblyAITts({ voice: "michael" }),
89
+ tts: assemblyAITts({ voice: "aai-michael" }),
90
90
  llm: "claude-sonnet-4-6",
91
91
  });
92
92
  expect(def.tts?.kind).toBe("assemblyai");
93
- expect(def.tts?.options.voice).toBe("michael");
93
+ expect(def.tts?.options.voice).toBe("aai-michael");
94
94
  expect(def.llm?.options.model).toBe("claude-sonnet-4-6");
95
95
  });
96
96
  });
@@ -104,11 +104,11 @@ test("the preset takes OPTIONS — one setting across the three stages at once",
104
104
  // on two descriptors that can drift apart, and `voice` to TTS. (An EU agent
105
105
  // also has to name a model the EU gateway carries — Claude and most Gemini
106
106
  // ids — which is the half no shorthand can do for you.)
107
- const options: AssemblyAIPipelineOptions = { region: "eu", voice: "michael" };
107
+ const options: AssemblyAIPipelineOptions = { region: "eu", voice: "aai-michael" };
108
108
  const pipeline = assemblyAIPipeline(options);
109
109
  expect(pipeline.stt.options.region).toBe("eu");
110
110
  expect(pipeline.llm.options.providerOptions).toMatchObject({ region: "eu" });
111
- expect(pipeline.tts.options.voice).toBe("michael");
111
+ expect(pipeline.tts.options.voice).toBe("aai-michael");
112
112
 
113
113
  // And a stage declared AFTER the spread still wins — that is the whole point
114
114
  // of it being a plain object, and it is how this template's own `agent.ts`
@@ -58,7 +58,6 @@ import {
58
58
  type AssemblyAITtsLanguage,
59
59
  type AssemblyAITtsOptions,
60
60
  type AssemblyAITtsVoice,
61
- type AssemblyAITtsVoiceInfo,
62
61
  assemblyAITts,
63
62
  CARTESIA_DEFAULT_VOICE,
64
63
  type CartesiaTtsOptions,
@@ -67,8 +66,6 @@ import {
67
66
  type RimeTtsOptions,
68
67
  rimeTts,
69
68
  type TtsProvider,
70
- ttsVoiceIds,
71
- ttsVoiceInfo,
72
69
  } from "@alexkroman1/aai/tts";
73
70
  import { describe, expect, test } from "vitest";
74
71
 
@@ -261,34 +258,16 @@ describe("the TTS stage", () => {
261
258
  }
262
259
  });
263
260
 
264
- test("a voice speaks exactly ONE language, and a pair that disagrees is refused", () => {
265
- // The catalog is `voice id -> { language, accent }`, and every language the
266
- // stage supports has at least one speaker. Pick from it rather than pairing
267
- // by hand: `{ language: "fr" }` alone fills in the default voice, which
268
- // speaks English, so asking for French and nothing else used to produce an
269
- // agent that connected, reported ready, and never spoke.
270
- // `ttsVoiceInfo` is the lookup by an OPEN voice id — `undefined` for one
271
- // this release's catalog does not list — so it needs no cast.
272
- const info: AssemblyAITtsVoiceInfo | undefined = ttsVoiceInfo(ASSEMBLYAI_TTS_DEFAULT_VOICE);
273
- expect(info?.language).toBe("en");
274
- expect(ttsVoiceInfo("a-voice-shipped-next-week")).toBeUndefined();
275
- // With no language, `ttsVoiceIds()` is the whole catalog, in its order.
276
- expect(ttsVoiceIds()).toEqual(Object.keys(ASSEMBLYAI_TTS_VOICES));
277
-
261
+ test("every library voice speaks every supported language", () => {
262
+ // The catalog is a tuple of `voice_id` slugs (what `z.enum` takes), and
263
+ // language is a separate axis: any voice, any of the six languages.
264
+ expect(ASSEMBLYAI_TTS_VOICES).toContain(ASSEMBLYAI_TTS_DEFAULT_VOICE);
278
265
  for (const language of Object.keys(ASSEMBLYAI_TTS_LANGUAGES) as AssemblyAITtsLanguage[]) {
279
- // `ttsVoiceIds(language)` is the catalog filtered to its speakers.
280
- const [voice] = ttsVoiceIds(language);
281
- expect(voice, language).toBeDefined();
282
- if (!voice) continue;
283
- const speaking = agent({ name: NAME, tts: assemblyAITts({ language, voice }) });
284
- expect(() => toAgentConfig(speaking), language).not.toThrow();
266
+ for (const voice of ASSEMBLYAI_TTS_VOICES) {
267
+ const speaking = agent({ name: NAME, tts: assemblyAITts({ language, voice }) });
268
+ expect(() => toAgentConfig(speaking), `${voice}/${language}`).not.toThrow();
269
+ }
285
270
  }
286
-
287
- // `toAgentConfig` is the last layer that sees the mismatch while somebody
288
- // is still authoring — after it, the refusal is in-band, after the socket
289
- // opens, with the agent ready and mute.
290
- const mismatched = agent({ name: NAME, tts: assemblyAITts({ language: "fr" }) });
291
- expect(() => toAgentConfig(mismatched)).toThrow(/speaks en/);
292
271
  });
293
272
 
294
273
  test("the catalog is not an allow-list: a voice shipped later still compiles", () => {
@@ -71,6 +71,21 @@ const REWRITE = JSON.stringify({
71
71
  const DRAFT =
72
72
  "Yes — the on-prem deployment runs the speech models inside your VPC; nothing calls out.";
73
73
 
74
+ /**
75
+ * The request, then the drafting nudge only if the request did not already stage.
76
+ *
77
+ * Whether the desk chains `draft_reply` into its first reply is a coin the live
78
+ * model flips. Sent unconditionally, the nudge can land on a WAITING draft,
79
+ * where it reads as dictated content and is answered with `edit`.
80
+ */
81
+ async function untilStaged(session: EvalSession, request: string, nudge: string) {
82
+ const turns = [await session.say(request)];
83
+ if (!toolNames(turns[0]!.toolCalls).includes("draft_reply")) {
84
+ turns.push(await session.say(nudge));
85
+ }
86
+ return turns;
87
+ }
88
+
74
89
  describeEval(agentDef, (test) => {
75
90
  test(
76
91
  "the call opens with a triage, and a triage sends nothing",
@@ -133,10 +148,16 @@ describeEval(agentDef, (test) => {
133
148
  // for me" was no better. What works is an instruction to ACT that names
134
149
  // the reply AND its content while saying nothing about sending — there is
135
150
  // no yes in it to mishear, and nothing to read as "wait".
136
- const turns = await session.sayAll([
151
+ //
152
+ // And the nudge is sent ONLY when the first turn stopped short of staging.
153
+ // A desk that chained `draft_reply` into its first reply hears the nudge
154
+ // while the draft is waiting, as dictated content — which is `edit`, and
155
+ // `edit` sends.
156
+ const turns = await untilStaged(
157
+ session,
137
158
  "Open the one from Dana at Northwind and reply that yes, inference stays inside their VPC.",
138
159
  "Write the reply now — say yes, it stays inside their VPC.",
139
- ]);
160
+ );
140
161
  const calls = toolCallsInTurns(turns);
141
162
  const names = toolNames(calls);
142
163
  // Across BOTH turns, and named: "expected [ 'open_email' ] to include
@@ -194,11 +215,13 @@ describeEval(agentDef, (test) => {
194
215
  // rather than chaining the staging into the same reply, which left this
195
216
  // case failing on a draft that had not happened yet rather than on the
196
217
  // gate it is here to measure. The yes is still the only send.
197
- const turns = await session.sayAll([
218
+ // The middle one is sent only when needed, for the reason the case above gives.
219
+ const turns = await untilStaged(
220
+ session,
198
221
  "Open Dana's email from Northwind and reply that inference stays inside their VPC.",
199
222
  "Write the reply now — say inference stays inside their VPC.",
200
- "Yes. Send it.",
201
- ]);
223
+ );
224
+ turns.push(await session.say("Yes. Send it."));
202
225
  const calls = toolCallsInTurns(turns);
203
226
  const names = toolNames(calls);
204
227
  // Staged first, sent second, once each — reversed, or a send with nothing
@@ -317,7 +317,9 @@ const applyEdit = failable(async (args: InferSchemaOutput<typeof EDIT_ARGS>, ctx
317
317
  export function editTool(): ToolDef {
318
318
  return reviewFlow.tool({
319
319
  description:
320
- `${name} dictated changes to the draft or the invite — send THEIR version. Give the ` +
320
+ `${name} dictated changes to the draft or the invite — send THEIR version. Only when ` +
321
+ "their words CHANGE what you read back; a restatement of it is not an edit, so ask " +
322
+ "whether to send. Give the " +
321
323
  "whole corrected email text, not the change; for an invite, the fields that change. " +
322
324
  "Use respond instead when they want you to redraft it yourself.",
323
325
  when: AWAITING,
@@ -395,7 +395,7 @@ const reviewSpec = {
395
395
  instruction:
396
396
  "Something is waiting on the executive's word. Read it back and hear their " +
397
397
  "answer, then call exactly one of accept, edit, ignore or respond. Nothing is " +
398
- "sent until accept has run.",
398
+ "sent until accept or edit has run.",
399
399
  on: { SETTLED: "inbox", REDRAFT: "drafting" },
400
400
  },
401
401
  },
@@ -23,7 +23,7 @@ export default agent({
23
23
  // The first thing a caller hears. Without one the agent waits for them to speak.
24
24
  greeting: "Hi, what can I do for you?",
25
25
  // Only the speaking stage is declared; speech-to-text and the LLM are the defaults.
26
- tts: assemblyAITts({ voice: "jane" }),
26
+ tts: assemblyAITts({ voice: "aai-jane" }),
27
27
  // Setting this REPLACES the default (`["think"]`), so `think` is listed to keep it. All
28
28
  // keyless but text_me, which reads TEXTBELT_KEY and SMS_TO_PHONE and texts only the
29
29
  // owner: without them it says it can't, and nothing else here depends on it.
@@ -93,6 +93,9 @@ export default agent({
93
93
  "keep_transcript with their answer.",
94
94
  "If they ask how it is going, call recap_progress. If they ask about earlier work, call",
95
95
  "recap_status. If they say to stop or forget it, call cancel_recap.",
96
+ "If they ask to start it again while one is running, call request_recap — it tells you",
97
+ "about the run they already have — and never cancel_recap first: a restart pays for a",
98
+ "second transcription of the same audio.",
96
99
  "Keep replies to one or two sentences; this is a voice call.",
97
100
  ].join(" "),
98
101
 
@@ -2,7 +2,9 @@ import { tool } from "@alexkroman1/aai";
2
2
  import { recap } from "../shared.ts";
3
3
 
4
4
  export default tool({
5
- description: "Stop the recap that is running. Use when the caller says to forget it.",
5
+ description:
6
+ "Stop the recap that is running. Use when the caller says to forget it — never as a " +
7
+ "step toward starting it again.",
6
8
  execute: async (_args, ctx) => {
7
9
  const [latest] = await ctx.workflows.find(recap, ctx.sessionId, { limit: 1 });
8
10
  if (!latest) return { cancelled: false, note: "Nothing started yet." };
@@ -7,6 +7,9 @@ The menu (sizes, crusts, toppings, and prices) is appended below this prompt —
7
7
  Behavior:
8
8
  - When a customer wants a pizza, collect size, crust, and toppings, then use add_pizza to add it.
9
9
  - If they just say something like "pepperoni pizza", assume medium, regular crust, and confirm before adding.
10
+ - If they name the size and toppings but not the crust, add it on regular crust
11
+ right away and say the crust when you confirm — they can change it. Do not
12
+ hold the order for a crust question.
10
13
  - Always confirm what you added after using add_pizza.
11
14
  - NEVER say a pizza was added, changed, or removed unless the matching tool has
12
15
  returned it. Saying "I've added that" with no tool call leaves the customer's
@@ -120,7 +120,11 @@ describeEval(agentDef, (test) => {
120
120
  // scripted case never writes.
121
121
  const call = await simulate({
122
122
  persona: "a friendly commuter on a phone, who answers in short sentences",
123
- goal: "find out whether to bring an umbrella in Seattle today",
123
+ // "Ask … in so many words": a short-sentence caller told only to FIND
124
+ // OUT answered the greeting's "which city?" with "Seattle.", heard a
125
+ // clear forecast and hung up — and the judge then graded the agent on a
126
+ // question nobody had said out loud.
127
+ goal: "ask, in so many words, whether you need an umbrella in Seattle today",
124
128
  });
125
129
 
126
130
  // The call ending on the caller's terms is the first thing to know: a
@@ -21,5 +21,5 @@ export default agent({
21
21
  // Any name from `ASSEMBLYAI_TTS_VOICES`. The voice is the speaking stage's
22
22
  // own option, so this replaces only that stage; the other two stay on the
23
23
  // default pipeline.
24
- tts: assemblyAITts({ voice: "jane" }),
24
+ tts: assemblyAITts({ voice: "aai-jane" }),
25
25
  });
@@ -3,6 +3,8 @@ sentences — a caller is listening, not reading.
3
3
 
4
4
  Use the get_weather tool whenever someone asks what it is like somewhere, and
5
5
  answer from what it returns rather than from memory. Round temperatures to
6
- whole degrees and say the city back, so a mishearing is obvious.
6
+ whole degrees and say the city back, so a mishearing is obvious. Answer the
7
+ question they actually asked: if it was "do I need an umbrella?" or "should I
8
+ wear a coat?", say yes or no, with the weather as the reason.
7
9
 
8
10
  If a lookup fails, say so plainly and offer to try another city.
@@ -41,7 +41,9 @@ describeEval(agentDef, (test) => {
41
41
  "takes where they are and what they are driving before anything else",
42
42
  async ({ session }) => {
43
43
  const turn = await session.say(
44
- "Hi — my car just died on me. I'm on route nine eastbound, past the Millfield exit, " +
44
+ // "Won't start", not "died": `report_location` says not to guess the
45
+ // situation, and "died" is `battery` as much as `wont_start`.
46
+ "Hi — my car won't start. I'm on route nine eastbound, past the Millfield exit, " +
45
47
  "it's a silver Toyota Corolla. I'm well off the road on the grass.",
46
48
  );
47
49
 
@@ -200,7 +200,7 @@ describeWorkflowEval(
200
200
  // the run renders.
201
201
  expect(run.reported[0]).toMatch(/^Uploading standup\.wav /);
202
202
  expect(run.reported).toContain("Summarizing the transcript.");
203
- expect(run.reported.at(-1)).toMatch(/^Recorded a 2s summary in \w+'s voice\.$/);
203
+ expect(run.reported.at(-1)).toMatch(/^Recorded a 2s summary with voice [\w-]+\.$/);
204
204
  // The job finished on its first poll, so no durable wait was asked for.
205
205
  expect(run.slept).toEqual([]);
206
206
  // One upload of the recording, and one submit — the split that exists so a
@@ -218,7 +218,7 @@ describeWorkflowEval(
218
218
  const { model } = scriptProvider();
219
219
  const speech = installStubSpeech();
220
220
 
221
- const run = await app.run(spokenSummary, { recording: UPLOAD_ID, voice: "michael" });
221
+ const run = await app.run(spokenSummary, { recording: UPLOAD_ID, voice: "aai-michael" });
222
222
 
223
223
  expect(run.error).toBeUndefined();
224
224
  const spokenText = speech.calls[0]?.text;
@@ -227,7 +227,7 @@ describeWorkflowEval(
227
227
  // whatever was spoken, it was not the list.
228
228
  for (const point of REPLY.points) expect(spokenText).not.toContain(point);
229
229
  // The form's choice really reaches the synthesizer.
230
- expect(speech.calls[0]?.voice).toBe("michael");
230
+ expect(speech.calls[0]?.voice).toBe("aai-michael");
231
231
  // Both shapes survive to the output — one to read, one that was heard.
232
232
  expect(run.output?.points).toEqual(REPLY.points);
233
233
  expect(run.output?.spoken).toBe(REPLY.spoken);
@@ -26,7 +26,7 @@ import {
26
26
  WAV_HEADER_BYTES,
27
27
  } from "@alexkroman1/aai/step";
28
28
  import { FatalError, RetryableError } from "@alexkroman1/aai/step-errors";
29
- import { ASSEMBLYAI_TTS_DEFAULT_VOICE, ttsVoiceInfo } from "@alexkroman1/aai/tts";
29
+ import { ASSEMBLYAI_TTS_DEFAULT_VOICE } from "@alexkroman1/aai/tts";
30
30
  import {
31
31
  createWorkflowContext,
32
32
  runWorkflow,
@@ -41,7 +41,7 @@ import {
41
41
  installStubUploads,
42
42
  } from "@alexkroman1/aai-runtime/testing/vitest";
43
43
  import { beforeEach, describe, expect, test, vi } from "vitest";
44
- import agentDef, { SUMMARY_LANGUAGE, spokenSummary, VOICES } from "./agent.ts";
44
+ import agentDef, { spokenSummary, VOICES } from "./agent.ts";
45
45
  import { speak, spokenSummaryFlow, summarize } from "./workflows/summarize.ts";
46
46
  import { createJob, pollTranscript, uploadToProvider } from "./workflows/transcribe.ts";
47
47
 
@@ -118,14 +118,9 @@ describe("the declaration", () => {
118
118
 
119
119
  test("the voice that fills in when nobody chooses is one the form would have offered", () => {
120
120
  // `voice` is OPTIONAL, so an unchosen summary is read by the SDK's own
121
- // default rather than by anything this template names — and every voice in
122
- // the catalog speaks exactly one language. If that default ever stopped
123
- // speaking `SUMMARY_LANGUAGE`, the form would still offer nothing but
124
- // English while the common path spoke something else, which is the failure
125
- // no voice-id validation can see: the id is real, it is simply the wrong
126
- // one. Asked of the catalog rather than restated, so the answer stays true.
121
+ // default rather than by anything this template names. Asked of the
122
+ // catalog rather than restated, so the answer stays true.
127
123
  expect(VOICES).toContain(ASSEMBLYAI_TTS_DEFAULT_VOICE);
128
- expect(ttsVoiceInfo(ASSEMBLYAI_TTS_DEFAULT_VOICE)?.language).toBe(SUMMARY_LANGUAGE);
129
124
  });
130
125
  });
131
126
 
@@ -285,10 +280,10 @@ describe("speaking", () => {
285
280
  const speech = installStubSpeech();
286
281
  installStubReporter();
287
282
 
288
- await speak("Hello.", { voice: "michael" });
283
+ await speak("Hello.", { voice: "aai-michael" });
289
284
  await speak("Hello.");
290
285
 
291
- expect(speech.calls[0]?.voice).toBe("michael");
286
+ expect(speech.calls[0]?.voice).toBe("aai-michael");
292
287
  // The SDK's own default, named rather than restated — a literal here would
293
288
  // have been this template quietly keeping a second copy of it.
294
289
  expect(speech.calls[1]?.voice).toBe(ASSEMBLYAI_TTS_DEFAULT_VOICE);
@@ -369,9 +364,12 @@ describe("the whole run", () => {
369
364
  installStubReporter();
370
365
  const speech = installStubSpeech();
371
366
 
372
- await spokenSummaryFlow({ recording: UPLOAD_ID, voice: "michael" }, createWorkflowContext());
367
+ await spokenSummaryFlow(
368
+ { recording: UPLOAD_ID, voice: "aai-michael" },
369
+ createWorkflowContext(),
370
+ );
373
371
 
374
- expect(speech.calls[0]).toMatchObject({ text: "Spoken.", voice: "michael" });
372
+ expect(speech.calls[0]).toMatchObject({ text: "Spoken.", voice: "aai-michael" });
375
373
  });
376
374
 
377
375
  test("a recording the provider gave up on fails the run rather than half-summarizing", async () => {
@@ -76,40 +76,24 @@
76
76
  */
77
77
 
78
78
  import { workflow, workflowApp } from "@alexkroman1/aai";
79
- import { type AssemblyAITtsLanguage, ttsVoiceIds } from "@alexkroman1/aai/tts";
79
+ import { ASSEMBLYAI_TTS_VOICES } from "@alexkroman1/aai/tts";
80
80
  import type { WorkflowDef } from "@alexkroman1/aai/workflow-api";
81
81
  import { z } from "zod";
82
82
  import { type SpokenSummary, spokenSummaryFlow } from "./workflows/summarize.ts";
83
83
 
84
84
  /**
85
- * The one language this app speaks, stated once.
86
- *
87
- * The voice list below is filtered by it, and the prompt in
88
- * `workflows/summarize.ts` writes the summary in the transcript's own language
89
- * rather than translating — so this is a claim about the VOICES, which is why
90
- * it lives next to them. Typed as the catalog's own union rather than the
91
- * literal `"en"`, so a fork changing it can only name a language the voices
92
- * actually cover — `ttsVoiceIds` answers the SDK's default voice ALONE when a
93
- * filter matches nothing, and a select with one entry in it is not a failure
94
- * anybody would look at twice.
95
- */
96
- export const SUMMARY_LANGUAGE: AssemblyAITtsLanguage = "en";
97
-
98
- /**
99
- * The voices the form offers, as the tuple `z.enum` takes.
85
+ * The voices the form offers: the SDK's library voices, as the tuple `z.enum`
86
+ * takes.
100
87
  *
101
- * READ from the SDK's catalog rather than listed, because a wrong voice id is a
102
- * SILENT failure — it is a free-form string the service rejects in band after
103
- * the socket is open, so the synthesis simply produces nothing. Narrowed to
104
- * {@link SUMMARY_LANGUAGE} because the summary is written in the transcript's
105
- * language and the prompt does not translate; every voice in the catalog speaks
106
- * exactly one. `ttsVoiceIds` owns the derivation, including the fallback to the
107
- * SDK's own default voice should the filter ever match nothing.
88
+ * READ from the SDK's catalog rather than listed, because a wrong voice id is
89
+ * refused when the synthesis socket opens — the run fails at the step rather
90
+ * than at the form. Every library voice speaks every supported language, so the
91
+ * summary (written in the transcript's own language) can be read by any of them.
108
92
  *
109
93
  * Exported so `agent.test.ts` can hold the list to the catalog it came from —
110
94
  * in particular that the voice the SDK fills in for an unchosen one is on it.
111
95
  */
112
- export const VOICES = ttsVoiceIds(SUMMARY_LANGUAGE);
96
+ export const VOICES = ASSEMBLYAI_TTS_VOICES;
113
97
 
114
98
  /**
115
99
  * The run input, as its own const.
@@ -254,7 +254,7 @@ export async function speak(
254
254
  });
255
255
 
256
256
  await stepReport(
257
- `Recorded a ${Math.round(spoken.durationMs / 1000)}s summary in ${spoken.voice}'s voice.`,
257
+ `Recorded a ${Math.round(spoken.durationMs / 1000)}s summary with voice ${spoken.voice}.`,
258
258
  );
259
259
  return { audio: stored.id, durationMs: spoken.durationMs };
260
260
  }
@@ -98,7 +98,7 @@ CORRECTION SYSTEM:
98
98
  If the player starts a message with ##, treat it as a correction to the previous turn. Acknowledge the correction and rewrite the scene.
99
99
 
100
100
  FLOW:
101
- 1. The LIVE CAMPAIGN SHEET at the end of these instructions is refreshed before every reply: the tracks, momentum, chaos factor, clocks, cast, and which act you are in. It is the engine's own record and it is never a turn behind, so read it rather than remembering, and never state a number that contradicts it. You do not have to open a turn with a tool call to find out where you are. `check_state` is still there for the full board — the chronicle, the whole NPC records, the story blueprint — and for the position (`state` and `instruction`) restated on demand; every other tool answers with that same pair, and a tool that is not available yet refuses and tells you what has to happen first.
101
+ 1. The LIVE CAMPAIGN SHEET at the end of these instructions is refreshed before every reply: the tracks, momentum, chaos factor, clocks, cast, and which act you are in. It is the engine's own record and it is never a turn behind, so read it rather than remembering, and never state a number that contradicts it. You do not have to open a turn with a tool call to find out where you are. `check_state` is still there for the full board — the chronicle, the whole NPC records, the story blueprint — and for the position (`state` and `instruction`) restated on demand — when the player asks you to check the state, or whether the story is over, call it rather than answering from the sheet; every other tool answers with that same pair, and a tool that is not available yet refuses and tells you what has to happen first.
102
102
  2. Present situations with tension and choice. Two to three options, but accept anything.
103
103
  3. For ANY risky action, you MUST call action_roll. NEVER narrate success or failure without rolling. NEVER reduce health, spirit, supply, or momentum yourself — action_roll does this through code. If you narrate damage without calling action_roll, the sidebar will be wrong and the game will break.
104
104
  4. After location changes, new NPCs, or other world changes, call update_state. But NEVER manually set health, spirit, supply, or momentum in update_state unless the player is resting or trading — action_roll handles combat and risk.
@@ -16,7 +16,7 @@ export default agent({
16
16
  // something to project rather than an empty state object.
17
17
  // A narrator wants a narrative voice; everything else stays on the
18
18
  // default all-AssemblyAI pipeline.
19
- tts: assemblyAITts({ voice: "paul" }),
19
+ tts: assemblyAITts({ voice: "aai-paul" }),
20
20
  /**
21
21
  * The status line, pushed to the CRT's top bar — where you are, your score,
22
22
  * your rank and the turn count, the four facts the printed games put across
@@ -9,6 +9,10 @@ and you have a small team of researchers you can put on it.
9
9
  that word mean", the counterpoint for "who says otherwise". Use it for a
10
10
  question that stands on its own — a subject worth several angles is
11
11
  `research_topic`, and a fact to check is `verify_claim`.
12
+ - When the caller brings you one claim to check — something they heard or
13
+ read, "is that right?" — call `verify_claim` with that claim in full, not
14
+ `research_topic`, however broad its subject sounds. Offer a full briefing
15
+ afterwards if they want one.
12
16
  - When the caller names a subject, decide the two or three ANGLES worth
13
17
  researching and call `research_topic` once with all of them. Do not call it
14
18
  once per angle — they run in parallel, and that is why the caller is not
@@ -135,7 +135,9 @@ describeEval(agentDef, (test) => {
135
135
  // before `to_flight_assistant` is told so and recovers inside the turn.
136
136
  // That refusal is a legal step and it is asserted rather than tolerated —
137
137
  // its own message is what pointed the model at the way in.
138
- for (const attempt of attempts.filter((call) => call !== staged)) {
138
+ // A second staging is not one: a desk that hears the request again
139
+ // without a yes may `cancel_action` and stage it afresh.
140
+ for (const attempt of attempts.filter((call) => !stagedSomething(call))) {
139
141
  expect(attempt.result).toMatch(
140
142
  new RegExp(`to_flight_assistant|${dialogRefusalPattern().source}`),
141
143
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexkroman1/aai-cli",
3
- "version": "0.15.4",
3
+ "version": "0.16.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,9 +58,9 @@
58
58
  "vite": "^8.3.1",
59
59
  "xstate": "^5.33.2",
60
60
  "zod": "^4.6.5",
61
- "@alexkroman1/aai": "0.15.4",
62
- "@alexkroman1/aai-runtime": "0.15.4",
63
- "@alexkroman1/aai-ui": "0.15.4"
61
+ "@alexkroman1/aai": "0.16.0",
62
+ "@alexkroman1/aai-runtime": "0.16.0",
63
+ "@alexkroman1/aai-ui": "0.16.0"
64
64
  },
65
65
  "devDependencies": {
66
66
  "playwright": "^1.63.0",