@vellumai/assistant 0.12.0-dev.202609111617.f60422f → 0.12.0-dev.202609111819.3dcbf21
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.
- package/ARCHITECTURE.md +1 -1
- package/package.json +1 -1
- package/src/__tests__/config-schema.test.ts +12 -6
- package/src/calls/__tests__/call-controller.test.ts +106 -0
- package/src/calls/__tests__/media-stream-output.test.ts +32 -0
- package/src/{live-voice → calls}/__tests__/progress-narration.test.ts +4 -4
- package/src/{live-voice → calls}/__tests__/progress-phrases.test.ts +1 -1
- package/src/calls/__tests__/voice-leg-coordinator.test.ts +229 -0
- package/src/calls/__tests__/voice-progress-cadence.test.ts +274 -0
- package/src/calls/call-controller.ts +190 -113
- package/src/calls/call-transport.ts +16 -0
- package/src/calls/media-stream-output.ts +32 -0
- package/src/{live-voice → calls}/progress-narration.ts +2 -2
- package/src/calls/voice-leg-coordinator.ts +189 -0
- package/src/calls/voice-progress-cadence.ts +423 -0
- package/src/config/default-profile-catalog.ts +1 -1
- package/src/config/schema.ts +2 -0
- package/src/config/schemas/__tests__/live-voice.test.ts +0 -134
- package/src/config/schemas/__tests__/voice.test.ts +148 -0
- package/src/config/schemas/live-voice.ts +1 -153
- package/src/config/schemas/voice.ts +150 -0
- package/src/live-voice/__tests__/live-voice-progress.test.ts +15 -15
- package/src/live-voice/__tests__/live-voice-vad.test.ts +2 -2
- package/src/live-voice/live-voice-session.ts +178 -521
- package/src/workspace/migrations/155-move-front-model-config-to-voice.ts +78 -0
- package/src/workspace/migrations/__tests__/155-move-front-model-config-to-voice.test.ts +102 -0
- package/src/workspace/migrations/registry.ts +2 -0
- /package/src/{live-voice → calls}/progress-phrases.ts +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { VoiceProgressConfigSchema } from "../../config/schemas/voice.js";
|
|
4
|
+
import type { VoiceProgressNarrator } from "../progress-narration.js";
|
|
5
|
+
import {
|
|
6
|
+
PROGRESS_FALLBACK_PHRASES,
|
|
7
|
+
PROGRESS_FALLBACK_PHRASES_BY_LANGUAGE,
|
|
8
|
+
} from "../progress-phrases.js";
|
|
9
|
+
import {
|
|
10
|
+
createProgressCadence,
|
|
11
|
+
type ProgressCadence,
|
|
12
|
+
type ProgressCadenceHost,
|
|
13
|
+
} from "../voice-progress-cadence.js";
|
|
14
|
+
|
|
15
|
+
const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
|
16
|
+
|
|
17
|
+
async function waitFor(predicate: () => boolean, attempts = 60): Promise<void> {
|
|
18
|
+
for (let i = 0; i < attempts; i += 1) {
|
|
19
|
+
if (predicate()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
await sleep(5);
|
|
23
|
+
}
|
|
24
|
+
throw new Error("waitFor timed out");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface Harness {
|
|
28
|
+
cadence: ProgressCadence;
|
|
29
|
+
spoken: Array<{ phrase: string; language: string | undefined }>;
|
|
30
|
+
host: {
|
|
31
|
+
live: boolean;
|
|
32
|
+
audioIdle: boolean;
|
|
33
|
+
tailUntilMs: number;
|
|
34
|
+
language: string | undefined;
|
|
35
|
+
deltaEpoch: number;
|
|
36
|
+
narrationsSpoken: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function harness(opts: {
|
|
41
|
+
config?: Partial<ReturnType<typeof VoiceProgressConfigSchema.parse>>;
|
|
42
|
+
narrator?: VoiceProgressNarrator | null;
|
|
43
|
+
language?: string;
|
|
44
|
+
}): Harness {
|
|
45
|
+
const state = {
|
|
46
|
+
live: true,
|
|
47
|
+
audioIdle: true,
|
|
48
|
+
tailUntilMs: 0,
|
|
49
|
+
language: opts.language,
|
|
50
|
+
deltaEpoch: 0,
|
|
51
|
+
narrationsSpoken: 0,
|
|
52
|
+
};
|
|
53
|
+
const spoken: Harness["spoken"] = [];
|
|
54
|
+
const host: ProgressCadenceHost = {
|
|
55
|
+
turnId: "turn-1",
|
|
56
|
+
launchedAtMs: Date.now(),
|
|
57
|
+
signal: new AbortController().signal,
|
|
58
|
+
canNarrate: () => state.live,
|
|
59
|
+
isAudioIdle: () => state.audioIdle,
|
|
60
|
+
playbackTailUntilMs: () => state.tailUntilMs,
|
|
61
|
+
transcriptSoFar: () => "what is on my calendar",
|
|
62
|
+
language: () => state.language,
|
|
63
|
+
deltaEpoch: () => state.deltaEpoch,
|
|
64
|
+
speak: (phrase, language) => {
|
|
65
|
+
spoken.push({ phrase, language });
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
onNarrationSpoken: () => {
|
|
69
|
+
state.narrationsSpoken += 1;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
let counter = 0;
|
|
73
|
+
const cadence = createProgressCadence({
|
|
74
|
+
config: VoiceProgressConfigSchema.parse({
|
|
75
|
+
opsThreshold: 3,
|
|
76
|
+
idleIntervalMs: 60_000,
|
|
77
|
+
maxSilenceMs: 60_000,
|
|
78
|
+
longOpMs: 15_000,
|
|
79
|
+
minGapMs: 10,
|
|
80
|
+
generationTimeoutMs: 1_500,
|
|
81
|
+
...opts.config,
|
|
82
|
+
}),
|
|
83
|
+
narrator:
|
|
84
|
+
opts.narrator === undefined
|
|
85
|
+
? { generateProgressText: async () => "Checking your calendar now." }
|
|
86
|
+
: opts.narrator,
|
|
87
|
+
host,
|
|
88
|
+
nextFallbackPhraseIndex: () => counter++,
|
|
89
|
+
});
|
|
90
|
+
return { cadence, spoken, host: state };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
describe("createProgressCadence", () => {
|
|
94
|
+
test("the ops trigger narrates once the threshold of started tools is reached", async () => {
|
|
95
|
+
const h = harness({});
|
|
96
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
97
|
+
h.cadence.toolStarted("web_fetch", "t2");
|
|
98
|
+
await sleep(15);
|
|
99
|
+
expect(h.spoken).toEqual([]);
|
|
100
|
+
|
|
101
|
+
h.cadence.toolStarted("file_read", "t3");
|
|
102
|
+
await waitFor(() => h.spoken.length === 1);
|
|
103
|
+
|
|
104
|
+
expect(h.spoken[0]).toEqual({
|
|
105
|
+
phrase: "Checking your calendar now.",
|
|
106
|
+
language: undefined,
|
|
107
|
+
});
|
|
108
|
+
expect(h.cadence.updatesSpoken).toBe(1);
|
|
109
|
+
expect(h.host.narrationsSpoken).toBe(1);
|
|
110
|
+
h.cadence.clear();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("a long operation completing narrates on its own beat", async () => {
|
|
114
|
+
const h = harness({ config: { longOpMs: 20 } });
|
|
115
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
116
|
+
await sleep(30);
|
|
117
|
+
h.cadence.toolFinished({
|
|
118
|
+
toolName: "web_search",
|
|
119
|
+
toolUseId: "t1",
|
|
120
|
+
resultPreview: "three results",
|
|
121
|
+
});
|
|
122
|
+
await waitFor(() => h.spoken.length === 1);
|
|
123
|
+
|
|
124
|
+
expect(h.cadence.ops[0].completedAtMs).toBeDefined();
|
|
125
|
+
expect(h.cadence.ops[0].resultPreview).toBe("three results");
|
|
126
|
+
h.cadence.clear();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("a quick operation completing is only news, not a narration", async () => {
|
|
130
|
+
const h = harness({});
|
|
131
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
132
|
+
h.cadence.toolFinished({ toolName: "web_search", toolUseId: "t1" });
|
|
133
|
+
await sleep(20);
|
|
134
|
+
|
|
135
|
+
expect(h.spoken).toEqual([]);
|
|
136
|
+
h.cadence.clear();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("a tool_result with no id matches the newest incomplete op of that name", () => {
|
|
140
|
+
const h = harness({});
|
|
141
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
142
|
+
h.cadence.toolStarted("web_search", "t2");
|
|
143
|
+
h.cadence.toolFinished({ toolName: "web_search", isError: true });
|
|
144
|
+
|
|
145
|
+
expect(h.cadence.ops[1].completedAtMs).toBeDefined();
|
|
146
|
+
expect(h.cadence.ops[1].isError).toBe(true);
|
|
147
|
+
expect(h.cadence.ops[0].completedAtMs).toBeUndefined();
|
|
148
|
+
h.cadence.clear();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("the idle tick narrates news since the last update, and the static fallback covers a null generation", async () => {
|
|
152
|
+
const h = harness({
|
|
153
|
+
config: { idleIntervalMs: 30, maxSilenceMs: 60_000 },
|
|
154
|
+
narrator: { generateProgressText: async () => null },
|
|
155
|
+
language: "es",
|
|
156
|
+
});
|
|
157
|
+
h.cadence.arm();
|
|
158
|
+
await sleep(60);
|
|
159
|
+
// Nothing observable happened: the tick stays quiet.
|
|
160
|
+
expect(h.spoken).toEqual([]);
|
|
161
|
+
|
|
162
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
163
|
+
await waitFor(() => h.spoken.length === 1);
|
|
164
|
+
|
|
165
|
+
expect(
|
|
166
|
+
PROGRESS_FALLBACK_PHRASES_BY_LANGUAGE.es.map((p) => p.trim()),
|
|
167
|
+
).toContain(h.spoken[0].phrase.trim());
|
|
168
|
+
// The Spanish table has an entry: the phrase rides the turn's language.
|
|
169
|
+
expect(h.spoken[0].language).toBeUndefined();
|
|
170
|
+
h.cadence.clear();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("a static fallback the table lacks in the turn's language is pinned to English", async () => {
|
|
174
|
+
const h = harness({
|
|
175
|
+
config: { idleIntervalMs: 30 },
|
|
176
|
+
narrator: { generateProgressText: async () => null },
|
|
177
|
+
language: "ko",
|
|
178
|
+
});
|
|
179
|
+
h.cadence.arm();
|
|
180
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
181
|
+
await waitFor(() => h.spoken.length === 1);
|
|
182
|
+
|
|
183
|
+
expect(PROGRESS_FALLBACK_PHRASES).toContain(h.spoken[0].phrase);
|
|
184
|
+
expect(h.spoken[0].language).toBe("en");
|
|
185
|
+
h.cadence.clear();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test("the heartbeat speaks after maxSilenceMs even with nothing new", async () => {
|
|
189
|
+
const h = harness({
|
|
190
|
+
config: { idleIntervalMs: 30, maxSilenceMs: 30 },
|
|
191
|
+
});
|
|
192
|
+
h.cadence.arm();
|
|
193
|
+
await waitFor(() => h.spoken.length === 1);
|
|
194
|
+
h.cadence.clear();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("nothing speaks while audio is still playing; the countdown restarts once it drains", async () => {
|
|
198
|
+
const h = harness({ config: { idleIntervalMs: 30, maxSilenceMs: 30 } });
|
|
199
|
+
h.host.audioIdle = false;
|
|
200
|
+
h.cadence.arm();
|
|
201
|
+
await sleep(80);
|
|
202
|
+
expect(h.spoken).toEqual([]);
|
|
203
|
+
|
|
204
|
+
h.host.audioIdle = true;
|
|
205
|
+
h.cadence.noteAudioSettled();
|
|
206
|
+
await waitFor(() => h.spoken.length === 1);
|
|
207
|
+
h.cadence.clear();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test("a narration generated while the model resumed speaking is dropped", async () => {
|
|
211
|
+
let release: () => void = () => {};
|
|
212
|
+
const h = harness({
|
|
213
|
+
config: { opsThreshold: 1 },
|
|
214
|
+
narrator: {
|
|
215
|
+
generateProgressText: () =>
|
|
216
|
+
new Promise<string | null>((resolve) => {
|
|
217
|
+
release = () => resolve("Still on it.");
|
|
218
|
+
}),
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
222
|
+
await sleep(10);
|
|
223
|
+
h.host.deltaEpoch += 1;
|
|
224
|
+
release();
|
|
225
|
+
await sleep(20);
|
|
226
|
+
|
|
227
|
+
expect(h.spoken).toEqual([]);
|
|
228
|
+
h.cadence.clear();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("minGapMs spaces narration from another floor holder", async () => {
|
|
232
|
+
const h = harness({ config: { opsThreshold: 1, minGapMs: 200 } });
|
|
233
|
+
h.cadence.noteFloorHolder();
|
|
234
|
+
h.cadence.toolStarted("web_search", "t1");
|
|
235
|
+
await sleep(30);
|
|
236
|
+
|
|
237
|
+
expect(h.spoken).toEqual([]);
|
|
238
|
+
h.cadence.clear();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("a null narrator or a disabled config never speaks or arms", async () => {
|
|
242
|
+
const off = harness({ narrator: null, config: { idleIntervalMs: 20 } });
|
|
243
|
+
off.cadence.arm();
|
|
244
|
+
off.cadence.toolStarted("a", "1");
|
|
245
|
+
off.cadence.toolStarted("b", "2");
|
|
246
|
+
off.cadence.toolStarted("c", "3");
|
|
247
|
+
const disabled = harness({
|
|
248
|
+
config: { enabled: false, idleIntervalMs: 20 },
|
|
249
|
+
});
|
|
250
|
+
disabled.cadence.arm();
|
|
251
|
+
disabled.cadence.toolStarted("a", "1");
|
|
252
|
+
disabled.cadence.toolStarted("b", "2");
|
|
253
|
+
disabled.cadence.toolStarted("c", "3");
|
|
254
|
+
await sleep(60);
|
|
255
|
+
|
|
256
|
+
expect(off.spoken).toEqual([]);
|
|
257
|
+
expect(disabled.spoken).toEqual([]);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test("clear stops the dead-air timer and a dead turn is never narrated", async () => {
|
|
261
|
+
const h = harness({ config: { idleIntervalMs: 20, maxSilenceMs: 20 } });
|
|
262
|
+
h.cadence.arm();
|
|
263
|
+
h.cadence.clear();
|
|
264
|
+
await sleep(60);
|
|
265
|
+
expect(h.spoken).toEqual([]);
|
|
266
|
+
|
|
267
|
+
h.host.live = false;
|
|
268
|
+
h.cadence.toolStarted("a", "1");
|
|
269
|
+
h.cadence.toolStarted("b", "2");
|
|
270
|
+
h.cadence.toolStarted("c", "3");
|
|
271
|
+
await sleep(20);
|
|
272
|
+
expect(h.spoken).toEqual([]);
|
|
273
|
+
});
|
|
274
|
+
});
|