@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.
Files changed (28) hide show
  1. package/ARCHITECTURE.md +1 -1
  2. package/package.json +1 -1
  3. package/src/__tests__/config-schema.test.ts +12 -6
  4. package/src/calls/__tests__/call-controller.test.ts +106 -0
  5. package/src/calls/__tests__/media-stream-output.test.ts +32 -0
  6. package/src/{live-voice → calls}/__tests__/progress-narration.test.ts +4 -4
  7. package/src/{live-voice → calls}/__tests__/progress-phrases.test.ts +1 -1
  8. package/src/calls/__tests__/voice-leg-coordinator.test.ts +229 -0
  9. package/src/calls/__tests__/voice-progress-cadence.test.ts +274 -0
  10. package/src/calls/call-controller.ts +190 -113
  11. package/src/calls/call-transport.ts +16 -0
  12. package/src/calls/media-stream-output.ts +32 -0
  13. package/src/{live-voice → calls}/progress-narration.ts +2 -2
  14. package/src/calls/voice-leg-coordinator.ts +189 -0
  15. package/src/calls/voice-progress-cadence.ts +423 -0
  16. package/src/config/default-profile-catalog.ts +1 -1
  17. package/src/config/schema.ts +2 -0
  18. package/src/config/schemas/__tests__/live-voice.test.ts +0 -134
  19. package/src/config/schemas/__tests__/voice.test.ts +148 -0
  20. package/src/config/schemas/live-voice.ts +1 -153
  21. package/src/config/schemas/voice.ts +150 -0
  22. package/src/live-voice/__tests__/live-voice-progress.test.ts +15 -15
  23. package/src/live-voice/__tests__/live-voice-vad.test.ts +2 -2
  24. package/src/live-voice/live-voice-session.ts +178 -521
  25. package/src/workspace/migrations/155-move-front-model-config-to-voice.ts +78 -0
  26. package/src/workspace/migrations/__tests__/155-move-front-model-config-to-voice.test.ts +102 -0
  27. package/src/workspace/migrations/registry.ts +2 -0
  28. /package/src/{live-voice → calls}/progress-phrases.ts +0 -0
@@ -3,27 +3,9 @@ import { describe, expect, test } from "bun:test";
3
3
  import {
4
4
  LiveVoiceConfigSchema,
5
5
  LiveVoiceFluxConfigSchema,
6
- LiveVoiceFrontModelConfigSchema,
7
6
  LiveVoiceVadConfigSchema,
8
7
  } from "../live-voice.js";
9
8
 
10
- const PROGRESS_DEFAULTS = {
11
- enabled: true,
12
- opsThreshold: 3,
13
- idleIntervalMs: 5_000,
14
- maxSilenceMs: 35_000,
15
- longOpMs: 15_000,
16
- minGapMs: 6_000,
17
- generationTimeoutMs: 1_500,
18
- };
19
-
20
- const FRONT_MODEL_DEFAULTS = {
21
- endpointDecisionTimeoutMs: 1200,
22
- endpointExtensionMs: 1500,
23
- endpointMaxExtensions: 2,
24
- progress: PROGRESS_DEFAULTS,
25
- };
26
-
27
9
  // `eagerEotThreshold` is deliberately absent: it has no default, and leaving it
28
10
  // unset is what keeps Deepgram from emitting speculative turn events. `model`
29
11
  // is absent for a related reason: unset means the spoken language selects the
@@ -129,117 +111,6 @@ describe("LiveVoiceVadConfigSchema", () => {
129
111
  });
130
112
  });
131
113
 
132
- describe("LiveVoiceFrontModelConfigSchema", () => {
133
- test("empty object parses to defaults", () => {
134
- const parsed = LiveVoiceFrontModelConfigSchema.parse({});
135
- expect(parsed).toEqual(FRONT_MODEL_DEFAULTS);
136
- });
137
-
138
- test("accepts overrides", () => {
139
- const parsed = LiveVoiceFrontModelConfigSchema.parse({
140
- endpointDecisionTimeoutMs: 400,
141
- endpointMaxExtensions: 0,
142
- });
143
- expect(parsed.endpointDecisionTimeoutMs).toBe(400);
144
- expect(parsed.endpointMaxExtensions).toBe(0);
145
- // Unspecified fields still get defaults
146
- expect(parsed.endpointExtensionMs).toBe(1500);
147
- });
148
-
149
- test("strips retired generated-ack settings", () => {
150
- const parsed = LiveVoiceFrontModelConfigSchema.parse({
151
- ackFirstDeltaTimeoutMs: 2500,
152
- ackGenerationTimeoutMs: 600,
153
- });
154
- expect(parsed).not.toHaveProperty("ackFirstDeltaTimeoutMs");
155
- expect(parsed).not.toHaveProperty("ackGenerationTimeoutMs");
156
- });
157
-
158
- test("rejects non-positive endpointDecisionTimeoutMs", () => {
159
- const result = LiveVoiceFrontModelConfigSchema.safeParse({
160
- endpointDecisionTimeoutMs: 0,
161
- });
162
- expect(result.success).toBe(false);
163
- });
164
-
165
- test("rejects negative endpointMaxExtensions", () => {
166
- const result = LiveVoiceFrontModelConfigSchema.safeParse({
167
- endpointMaxExtensions: -1,
168
- });
169
- expect(result.success).toBe(false);
170
- });
171
-
172
- test("absent progress namespace parses to full progress defaults", () => {
173
- const parsed = LiveVoiceFrontModelConfigSchema.parse({});
174
- expect(parsed.progress).toEqual(PROGRESS_DEFAULTS);
175
- });
176
-
177
- test("partial progress overrides merge with defaults", () => {
178
- const parsed = LiveVoiceFrontModelConfigSchema.parse({
179
- progress: { enabled: false, opsThreshold: 5 },
180
- });
181
- expect(parsed.progress.enabled).toBe(false);
182
- expect(parsed.progress.opsThreshold).toBe(5);
183
- // Unspecified progress fields still get defaults
184
- expect(parsed.progress.idleIntervalMs).toBe(5_000);
185
- expect(parsed.progress.maxSilenceMs).toBe(35_000);
186
- expect(parsed.progress.longOpMs).toBe(15_000);
187
- expect(parsed.progress.minGapMs).toBe(6_000);
188
- expect(parsed.progress.generationTimeoutMs).toBe(1_500);
189
- });
190
-
191
- test("a stale maxPerTurn key is stripped, not rejected", () => {
192
- // The cap was removed; configs written while it existed must still parse.
193
- const parsed = LiveVoiceFrontModelConfigSchema.parse({
194
- progress: { maxPerTurn: 3 },
195
- });
196
- expect("maxPerTurn" in parsed.progress).toBe(false);
197
- });
198
-
199
- test("rejects non-positive progress.opsThreshold", () => {
200
- const result = LiveVoiceFrontModelConfigSchema.safeParse({
201
- progress: { opsThreshold: 0 },
202
- });
203
- expect(result.success).toBe(false);
204
- });
205
-
206
- test("rejects a heartbeat ceiling shorter than the idle tick interval", () => {
207
- // The heartbeat is only checked on the idle tick, so a shorter ceiling
208
- // could be overshot by a full interval.
209
- const result = LiveVoiceFrontModelConfigSchema.safeParse({
210
- progress: { idleIntervalMs: 60_000, maxSilenceMs: 10_000 },
211
- });
212
- expect(result.success).toBe(false);
213
- if (!result.success) {
214
- const msgs = result.error.issues.map((issue) => issue.message);
215
- expect(
216
- msgs.some((msg) =>
217
- msg.includes("liveVoice.frontModel.progress.maxSilenceMs"),
218
- ),
219
- ).toBe(true);
220
- }
221
- // The floor itself is allowed: the tick is exactly on the ceiling.
222
- expect(
223
- LiveVoiceFrontModelConfigSchema.safeParse({
224
- progress: { idleIntervalMs: 60_000, maxSilenceMs: 60_000 },
225
- }).success,
226
- ).toBe(true);
227
- });
228
-
229
- test("rejects a non-boolean progress.enabled", () => {
230
- const result = LiveVoiceFrontModelConfigSchema.safeParse({
231
- progress: { enabled: "yes" },
232
- });
233
- expect(result.success).toBe(false);
234
- if (!result.success) {
235
- const msgs = result.error.issues.map((i) => i.message);
236
- expect(
237
- msgs.some((m) => m.includes("liveVoice.frontModel.progress.enabled")),
238
- ).toBe(true);
239
- }
240
- });
241
- });
242
-
243
114
  describe("LiveVoiceFluxConfigSchema", () => {
244
115
  test("empty object parses to defaults, with turn-end on", () => {
245
116
  expect(LiveVoiceFluxConfigSchema.parse({})).toEqual(FLUX_DEFAULTS);
@@ -335,7 +206,6 @@ describe("LiveVoiceConfigSchema", () => {
335
206
  echoEmaHalfLifeMs: 400,
336
207
  echoDrainSlackMs: 300,
337
208
  },
338
- frontModel: FRONT_MODEL_DEFAULTS,
339
209
  // Off by default: Flux turn detection is opt-in, so the front-door hold
340
210
  // verdict keeps committing turns until it is enabled.
341
211
  flux: FLUX_DEFAULTS,
@@ -363,16 +233,12 @@ describe("LiveVoiceConfigSchema", () => {
363
233
  test("accepts overrides", () => {
364
234
  const parsed = LiveVoiceConfigSchema.parse({
365
235
  vad: { silenceThresholdMs: 900 },
366
- frontModel: { endpointDecisionTimeoutMs: 300 },
367
236
  flux: { turnEnd: { enabled: true } },
368
237
  });
369
238
  expect(parsed.vad.silenceThresholdMs).toBe(900);
370
239
  // Unspecified vad fields still get defaults
371
240
  expect(parsed.vad.speechEnergyThreshold).toBe(800);
372
241
  expect(parsed.vad.maxTurnDurationMs).toBe(30_000);
373
- // Partial frontModel overrides merge with defaults
374
- expect(parsed.frontModel.endpointDecisionTimeoutMs).toBe(300);
375
- expect(parsed.frontModel.endpointExtensionMs).toBe(1500);
376
242
  // Partial flux overrides merge with defaults
377
243
  expect(parsed.flux.turnEnd.enabled).toBe(true);
378
244
  expect(parsed.flux.eotThreshold).toBe(0.7);
@@ -0,0 +1,148 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { VoiceConfigSchema, VoiceFrontModelConfigSchema } from "../voice.js";
4
+
5
+ const PROGRESS_DEFAULTS = {
6
+ enabled: true,
7
+ opsThreshold: 3,
8
+ idleIntervalMs: 5_000,
9
+ maxSilenceMs: 35_000,
10
+ longOpMs: 15_000,
11
+ minGapMs: 6_000,
12
+ generationTimeoutMs: 1_500,
13
+ };
14
+
15
+ const FRONT_MODEL_DEFAULTS = {
16
+ endpointDecisionTimeoutMs: 1200,
17
+ endpointExtensionMs: 1500,
18
+ endpointMaxExtensions: 2,
19
+ progress: PROGRESS_DEFAULTS,
20
+ };
21
+
22
+ describe("VoiceFrontModelConfigSchema", () => {
23
+ test("empty object parses to defaults", () => {
24
+ const parsed = VoiceFrontModelConfigSchema.parse({});
25
+ expect(parsed).toEqual(FRONT_MODEL_DEFAULTS);
26
+ });
27
+
28
+ test("accepts overrides", () => {
29
+ const parsed = VoiceFrontModelConfigSchema.parse({
30
+ endpointDecisionTimeoutMs: 400,
31
+ endpointMaxExtensions: 0,
32
+ });
33
+ expect(parsed.endpointDecisionTimeoutMs).toBe(400);
34
+ expect(parsed.endpointMaxExtensions).toBe(0);
35
+ // Unspecified fields still get defaults
36
+ expect(parsed.endpointExtensionMs).toBe(1500);
37
+ });
38
+
39
+ test("strips retired generated-ack settings", () => {
40
+ const parsed = VoiceFrontModelConfigSchema.parse({
41
+ ackFirstDeltaTimeoutMs: 2500,
42
+ ackGenerationTimeoutMs: 600,
43
+ });
44
+ expect(parsed).not.toHaveProperty("ackFirstDeltaTimeoutMs");
45
+ expect(parsed).not.toHaveProperty("ackGenerationTimeoutMs");
46
+ });
47
+
48
+ test("rejects non-positive endpointDecisionTimeoutMs", () => {
49
+ const result = VoiceFrontModelConfigSchema.safeParse({
50
+ endpointDecisionTimeoutMs: 0,
51
+ });
52
+ expect(result.success).toBe(false);
53
+ });
54
+
55
+ test("rejects negative endpointMaxExtensions", () => {
56
+ const result = VoiceFrontModelConfigSchema.safeParse({
57
+ endpointMaxExtensions: -1,
58
+ });
59
+ expect(result.success).toBe(false);
60
+ });
61
+
62
+ test("absent progress namespace parses to full progress defaults", () => {
63
+ const parsed = VoiceFrontModelConfigSchema.parse({});
64
+ expect(parsed.progress).toEqual(PROGRESS_DEFAULTS);
65
+ });
66
+
67
+ test("partial progress overrides merge with defaults", () => {
68
+ const parsed = VoiceFrontModelConfigSchema.parse({
69
+ progress: { enabled: false, opsThreshold: 5 },
70
+ });
71
+ expect(parsed.progress.enabled).toBe(false);
72
+ expect(parsed.progress.opsThreshold).toBe(5);
73
+ // Unspecified progress fields still get defaults
74
+ expect(parsed.progress.idleIntervalMs).toBe(5_000);
75
+ expect(parsed.progress.maxSilenceMs).toBe(35_000);
76
+ expect(parsed.progress.longOpMs).toBe(15_000);
77
+ expect(parsed.progress.minGapMs).toBe(6_000);
78
+ expect(parsed.progress.generationTimeoutMs).toBe(1_500);
79
+ });
80
+
81
+ test("a stale maxPerTurn key is stripped, not rejected", () => {
82
+ // The cap was removed; configs written while it existed must still parse.
83
+ const parsed = VoiceFrontModelConfigSchema.parse({
84
+ progress: { maxPerTurn: 3 },
85
+ });
86
+ expect("maxPerTurn" in parsed.progress).toBe(false);
87
+ });
88
+
89
+ test("rejects non-positive progress.opsThreshold", () => {
90
+ const result = VoiceFrontModelConfigSchema.safeParse({
91
+ progress: { opsThreshold: 0 },
92
+ });
93
+ expect(result.success).toBe(false);
94
+ });
95
+
96
+ test("rejects a heartbeat ceiling shorter than the idle tick interval", () => {
97
+ // The heartbeat is only checked on the idle tick, so a shorter ceiling
98
+ // could be overshot by a full interval.
99
+ const result = VoiceFrontModelConfigSchema.safeParse({
100
+ progress: { idleIntervalMs: 60_000, maxSilenceMs: 10_000 },
101
+ });
102
+ expect(result.success).toBe(false);
103
+ if (!result.success) {
104
+ const msgs = result.error.issues.map((issue) => issue.message);
105
+ expect(
106
+ msgs.some((msg) =>
107
+ msg.includes("voice.frontModel.progress.maxSilenceMs"),
108
+ ),
109
+ ).toBe(true);
110
+ }
111
+ // The floor itself is allowed: the tick is exactly on the ceiling.
112
+ expect(
113
+ VoiceFrontModelConfigSchema.safeParse({
114
+ progress: { idleIntervalMs: 60_000, maxSilenceMs: 60_000 },
115
+ }).success,
116
+ ).toBe(true);
117
+ });
118
+
119
+ test("rejects a non-boolean progress.enabled", () => {
120
+ const result = VoiceFrontModelConfigSchema.safeParse({
121
+ progress: { enabled: "yes" },
122
+ });
123
+ expect(result.success).toBe(false);
124
+ if (!result.success) {
125
+ const msgs = result.error.issues.map((i) => i.message);
126
+ expect(
127
+ msgs.some((m) => m.includes("voice.frontModel.progress.enabled")),
128
+ ).toBe(true);
129
+ }
130
+ });
131
+ });
132
+
133
+ describe("VoiceConfigSchema", () => {
134
+ test("empty object parses to front-model defaults", () => {
135
+ expect(VoiceConfigSchema.parse({})).toEqual({
136
+ frontModel: FRONT_MODEL_DEFAULTS,
137
+ });
138
+ });
139
+
140
+ test("partial frontModel overrides merge with defaults", () => {
141
+ const parsed = VoiceConfigSchema.parse({
142
+ frontModel: { endpointDecisionTimeoutMs: 300 },
143
+ });
144
+ expect(parsed.frontModel.endpointDecisionTimeoutMs).toBe(300);
145
+ expect(parsed.frontModel.endpointExtensionMs).toBe(1500);
146
+ expect(parsed.frontModel.progress).toEqual(PROGRESS_DEFAULTS);
147
+ });
148
+ });
@@ -77,149 +77,6 @@ export const LiveVoiceVadConfigSchema = z
77
77
  "Voice-activity-detection tuning for live voice sessions (open-mic turn segmentation)",
78
78
  );
79
79
 
80
- export const LiveVoiceProgressConfigSchema = z
81
- .object({
82
- enabled: z
83
- .boolean({
84
- error: "liveVoice.frontModel.progress.enabled must be a boolean",
85
- })
86
- .default(true)
87
- .describe(
88
- "Speak short progress updates during long-running tool-heavy turns; the opt-out for progress narration",
89
- ),
90
- opsThreshold: z
91
- .number({
92
- error: "liveVoice.frontModel.progress.opsThreshold must be a number",
93
- })
94
- .int("liveVoice.frontModel.progress.opsThreshold must be an integer")
95
- .positive(
96
- "liveVoice.frontModel.progress.opsThreshold must be a positive integer",
97
- )
98
- .default(3)
99
- .describe(
100
- "Narrate after this many tool operations since the last narration",
101
- ),
102
- idleIntervalMs: z
103
- .number({
104
- error: "liveVoice.frontModel.progress.idleIntervalMs must be a number",
105
- })
106
- .int("liveVoice.frontModel.progress.idleIntervalMs must be an integer")
107
- .positive(
108
- "liveVoice.frontModel.progress.idleIntervalMs must be a positive integer",
109
- )
110
- .default(5_000)
111
- .describe(
112
- "How often (ms) a running turn's silence is checked, and so the soonest new tool activity is narrated",
113
- ),
114
- maxSilenceMs: z
115
- .number({
116
- error: "liveVoice.frontModel.progress.maxSilenceMs must be a number",
117
- })
118
- .int("liveVoice.frontModel.progress.maxSilenceMs must be an integer")
119
- .positive(
120
- "liveVoice.frontModel.progress.maxSilenceMs must be a positive integer",
121
- )
122
- .default(35_000)
123
- .describe(
124
- "Heartbeat ceiling (ms): narrate after this much unbroken silence even when nothing new has happened. Evaluated on the idle tick, so its resolution is idleIntervalMs and it must be at least that long",
125
- ),
126
- longOpMs: z
127
- .number({
128
- error: "liveVoice.frontModel.progress.longOpMs must be a number",
129
- })
130
- .int("liveVoice.frontModel.progress.longOpMs must be an integer")
131
- .positive(
132
- "liveVoice.frontModel.progress.longOpMs must be a positive integer",
133
- )
134
- .default(15_000)
135
- .describe(
136
- "A tool operation that ran at least this long (ms) narrates the moment it completes, without waiting for opsThreshold",
137
- ),
138
- minGapMs: z
139
- .number({
140
- error: "liveVoice.frontModel.progress.minGapMs must be a number",
141
- })
142
- .int("liveVoice.frontModel.progress.minGapMs must be an integer")
143
- .positive(
144
- "liveVoice.frontModel.progress.minGapMs must be a positive integer",
145
- )
146
- .default(6_000)
147
- .describe(
148
- "Minimum spacing (ms) from any spoken floor-holder — ack or narration",
149
- ),
150
- generationTimeoutMs: z
151
- .number({
152
- error:
153
- "liveVoice.frontModel.progress.generationTimeoutMs must be a number",
154
- })
155
- .int(
156
- "liveVoice.frontModel.progress.generationTimeoutMs must be an integer",
157
- )
158
- .positive(
159
- "liveVoice.frontModel.progress.generationTimeoutMs must be a positive integer",
160
- )
161
- .default(1_500)
162
- .describe(
163
- "Budget (ms) for LLM-generated progress text — not latency-critical: it speaks into dead air",
164
- ),
165
- })
166
- // The heartbeat is checked when the idle tick finds the turn silent, so a
167
- // ceiling shorter than the tick interval would be missed by up to a full
168
- // interval — a promise the cadence cannot keep. Rejecting the combination
169
- // beats silently overshooting it.
170
- .refine((progress) => progress.maxSilenceMs >= progress.idleIntervalMs, {
171
- error:
172
- "liveVoice.frontModel.progress.maxSilenceMs must be at least idleIntervalMs — the heartbeat is evaluated on the idle tick",
173
- })
174
- .describe(
175
- "Progress-narration tuning for live voice sessions (spoken updates during long-running turns)",
176
- );
177
-
178
- export const LiveVoiceFrontModelConfigSchema = z
179
- .object({
180
- endpointDecisionTimeoutMs: z
181
- .number({
182
- error:
183
- "liveVoice.frontModel.endpointDecisionTimeoutMs must be a number",
184
- })
185
- .int("liveVoice.frontModel.endpointDecisionTimeoutMs must be an integer")
186
- .positive(
187
- "liveVoice.frontModel.endpointDecisionTimeoutMs must be a positive integer",
188
- )
189
- .default(1200)
190
- .describe(
191
- "Hard budget (ms) for the endpoint decision LLM call. This adds to end-of-turn latency when semantic endpointing is on, so keep it as tight as the decider model's real roundtrip allows — measured Haiku roundtrips through the managed proxy run ~670-1130ms (dev), so tighter budgets turn the feature into a fail-open no-op.",
192
- ),
193
- endpointExtensionMs: z
194
- .number({
195
- error: "liveVoice.frontModel.endpointExtensionMs must be a number",
196
- })
197
- .int("liveVoice.frontModel.endpointExtensionMs must be an integer")
198
- .positive(
199
- "liveVoice.frontModel.endpointExtensionMs must be a positive integer",
200
- )
201
- .default(1500)
202
- .describe(
203
- "How long (ms) a 'hold' decision keeps the turn open before turn-end replays",
204
- ),
205
- endpointMaxExtensions: z
206
- .number({
207
- error: "liveVoice.frontModel.endpointMaxExtensions must be a number",
208
- })
209
- .int("liveVoice.frontModel.endpointMaxExtensions must be an integer")
210
- .nonnegative(
211
- "liveVoice.frontModel.endpointMaxExtensions must be a nonnegative integer",
212
- )
213
- .default(2)
214
- .describe("Cap on consecutive 'hold' extensions per utterance"),
215
- progress: LiveVoiceProgressConfigSchema.default(
216
- LiveVoiceProgressConfigSchema.parse({}),
217
- ),
218
- })
219
- .describe(
220
- "Voice front-door endpointing and long-turn progress narration tuning",
221
- );
222
-
223
80
  const LiveVoiceFluxTurnEndConfigSchema = z
224
81
  .object({
225
82
  enabled: z
@@ -284,9 +141,6 @@ export const LiveVoiceFluxConfigSchema = z
284
141
  export const LiveVoiceConfigSchema = z
285
142
  .object({
286
143
  vad: LiveVoiceVadConfigSchema.default(LiveVoiceVadConfigSchema.parse({})),
287
- frontModel: LiveVoiceFrontModelConfigSchema.default(
288
- LiveVoiceFrontModelConfigSchema.parse({}),
289
- ),
290
144
  flux: LiveVoiceFluxConfigSchema.default(
291
145
  LiveVoiceFluxConfigSchema.parse({}),
292
146
  ),
@@ -298,15 +152,9 @@ export const LiveVoiceConfigSchema = z
298
152
  ),
299
153
  })
300
154
  .describe(
301
- "Live voice (in-app duplex audio) configuration: VAD tuning, front-model routing, Flux turn detection, and audio archiving",
155
+ "Live voice (in-app duplex audio) configuration: VAD tuning, Flux turn detection, and audio archiving",
302
156
  );
303
157
 
304
158
  export type LiveVoiceConfig = z.infer<typeof LiveVoiceConfigSchema>;
305
159
  export type LiveVoiceVadConfig = z.infer<typeof LiveVoiceVadConfigSchema>;
306
- export type LiveVoiceFrontModelConfig = z.infer<
307
- typeof LiveVoiceFrontModelConfigSchema
308
- >;
309
- export type LiveVoiceProgressConfig = z.infer<
310
- typeof LiveVoiceProgressConfigSchema
311
- >;
312
160
  export type LiveVoiceFluxConfig = z.infer<typeof LiveVoiceFluxConfigSchema>;
@@ -0,0 +1,150 @@
1
+ import { z } from "zod";
2
+
3
+ export const VoiceProgressConfigSchema = z
4
+ .object({
5
+ enabled: z
6
+ .boolean({
7
+ error: "voice.frontModel.progress.enabled must be a boolean",
8
+ })
9
+ .default(true)
10
+ .describe(
11
+ "Speak short progress updates during long-running tool-heavy turns; the opt-out for progress narration",
12
+ ),
13
+ opsThreshold: z
14
+ .number({
15
+ error: "voice.frontModel.progress.opsThreshold must be a number",
16
+ })
17
+ .int("voice.frontModel.progress.opsThreshold must be an integer")
18
+ .positive(
19
+ "voice.frontModel.progress.opsThreshold must be a positive integer",
20
+ )
21
+ .default(3)
22
+ .describe(
23
+ "Narrate after this many tool operations since the last narration",
24
+ ),
25
+ idleIntervalMs: z
26
+ .number({
27
+ error: "voice.frontModel.progress.idleIntervalMs must be a number",
28
+ })
29
+ .int("voice.frontModel.progress.idleIntervalMs must be an integer")
30
+ .positive(
31
+ "voice.frontModel.progress.idleIntervalMs must be a positive integer",
32
+ )
33
+ .default(5_000)
34
+ .describe(
35
+ "How often (ms) a running turn's silence is checked, and so the soonest new tool activity is narrated",
36
+ ),
37
+ maxSilenceMs: z
38
+ .number({
39
+ error: "voice.frontModel.progress.maxSilenceMs must be a number",
40
+ })
41
+ .int("voice.frontModel.progress.maxSilenceMs must be an integer")
42
+ .positive(
43
+ "voice.frontModel.progress.maxSilenceMs must be a positive integer",
44
+ )
45
+ .default(35_000)
46
+ .describe(
47
+ "Heartbeat ceiling (ms): narrate after this much unbroken silence even when nothing new has happened. Evaluated on the idle tick, so its resolution is idleIntervalMs and it must be at least that long",
48
+ ),
49
+ longOpMs: z
50
+ .number({
51
+ error: "voice.frontModel.progress.longOpMs must be a number",
52
+ })
53
+ .int("voice.frontModel.progress.longOpMs must be an integer")
54
+ .positive("voice.frontModel.progress.longOpMs must be a positive integer")
55
+ .default(15_000)
56
+ .describe(
57
+ "A tool operation that ran at least this long (ms) narrates the moment it completes, without waiting for opsThreshold",
58
+ ),
59
+ minGapMs: z
60
+ .number({
61
+ error: "voice.frontModel.progress.minGapMs must be a number",
62
+ })
63
+ .int("voice.frontModel.progress.minGapMs must be an integer")
64
+ .positive("voice.frontModel.progress.minGapMs must be a positive integer")
65
+ .default(6_000)
66
+ .describe(
67
+ "Minimum spacing (ms) from any spoken floor-holder (ack or narration)",
68
+ ),
69
+ generationTimeoutMs: z
70
+ .number({
71
+ error: "voice.frontModel.progress.generationTimeoutMs must be a number",
72
+ })
73
+ .int("voice.frontModel.progress.generationTimeoutMs must be an integer")
74
+ .positive(
75
+ "voice.frontModel.progress.generationTimeoutMs must be a positive integer",
76
+ )
77
+ .default(1_500)
78
+ .describe(
79
+ "Budget (ms) for LLM-generated progress text. Not latency-critical: it speaks into dead air",
80
+ ),
81
+ })
82
+ // The heartbeat is checked when the idle tick finds the turn silent, so a
83
+ // ceiling shorter than the tick interval would be missed by up to a full
84
+ // interval, a promise the cadence cannot keep. Rejecting the combination
85
+ // beats silently overshooting it.
86
+ .refine((progress) => progress.maxSilenceMs >= progress.idleIntervalMs, {
87
+ error:
88
+ "voice.frontModel.progress.maxSilenceMs must be at least idleIntervalMs: the heartbeat is evaluated on the idle tick",
89
+ })
90
+ .describe(
91
+ "Progress-narration tuning for live voice sessions (spoken updates during long-running turns)",
92
+ );
93
+
94
+ export const VoiceFrontModelConfigSchema = z
95
+ .object({
96
+ endpointDecisionTimeoutMs: z
97
+ .number({
98
+ error: "voice.frontModel.endpointDecisionTimeoutMs must be a number",
99
+ })
100
+ .int("voice.frontModel.endpointDecisionTimeoutMs must be an integer")
101
+ .positive(
102
+ "voice.frontModel.endpointDecisionTimeoutMs must be a positive integer",
103
+ )
104
+ .default(1200)
105
+ .describe(
106
+ "Hard budget (ms) for the endpoint decision LLM call. This adds to end-of-turn latency when semantic endpointing is on, so keep it as tight as the decider model's real roundtrip allows. Measured Haiku roundtrips through the managed proxy run ~670-1130ms (dev), so tighter budgets turn the feature into a fail-open no-op.",
107
+ ),
108
+ endpointExtensionMs: z
109
+ .number({
110
+ error: "voice.frontModel.endpointExtensionMs must be a number",
111
+ })
112
+ .int("voice.frontModel.endpointExtensionMs must be an integer")
113
+ .positive(
114
+ "voice.frontModel.endpointExtensionMs must be a positive integer",
115
+ )
116
+ .default(1500)
117
+ .describe(
118
+ "How long (ms) a 'hold' decision keeps the turn open before turn-end replays",
119
+ ),
120
+ endpointMaxExtensions: z
121
+ .number({
122
+ error: "voice.frontModel.endpointMaxExtensions must be a number",
123
+ })
124
+ .int("voice.frontModel.endpointMaxExtensions must be an integer")
125
+ .nonnegative(
126
+ "voice.frontModel.endpointMaxExtensions must be a nonnegative integer",
127
+ )
128
+ .default(2)
129
+ .describe("Cap on consecutive 'hold' extensions per utterance"),
130
+ progress: VoiceProgressConfigSchema.default(
131
+ VoiceProgressConfigSchema.parse({}),
132
+ ),
133
+ })
134
+ .describe(
135
+ "Voice front-door endpointing and long-turn progress narration tuning, shared by live voice and phone calls",
136
+ );
137
+
138
+ export const VoiceConfigSchema = z
139
+ .object({
140
+ frontModel: VoiceFrontModelConfigSchema.default(
141
+ VoiceFrontModelConfigSchema.parse({}),
142
+ ),
143
+ })
144
+ .describe(
145
+ "Transport-agnostic voice configuration shared by live voice and phone calls: front-door routing and progress narration tuning",
146
+ );
147
+
148
+ export type VoiceConfig = z.infer<typeof VoiceConfigSchema>;
149
+ export type VoiceFrontModelConfig = z.infer<typeof VoiceFrontModelConfigSchema>;
150
+ export type VoiceProgressConfig = z.infer<typeof VoiceProgressConfigSchema>;