@voicelayer/sdk 0.2.0 → 0.3.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.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,131 @@
1
- import { A as AgentDTO, a as AgentStatus, b as AgentEnvironment, c as AgentContext, P as Participant, C as CallInfo, d as ProcessSchemaDTO } from './text-session-BqMWaNsN.js';
2
- export { e as AgentTurnEvent, f as AudioProfile, g as AudioSurface, h as ChannelKind, D as DtmfEvent, i as DtmfHandler, E as EndCallControllerHandle, j as EndCallOutcome, F as FakeSessionAdapter, k as FloorControlConfig, I as InboundOptions, L as LK_AGENT_STATE_MAP, M as MemoryHandle, l as MetricsEvent, N as NON_BUSY_STATES, m as ParticipantId, n as ParticipantKind, o as ParticipantSet, p as ProcessSnapshot, R as RespondOptions, q as Room, r as RouteEntry, s as RoutingRule, t as RoutingSnapshot, u as RunTextSessionOptions, v as RunTextTranscriptOptions, S as SayOptions, w as SendDtmfOptions, x as SessionAdapter, y as SessionCapabilities, z as SessionErrorEvent, B as SessionEvent, G as SessionEventMap, H as SessionFactory, J as SessionFactoryInput, K as SessionOutbound, O as SessionState, Q as SpeechResult, T as SpeechTarget, U as StateChangeEvent, V as TextSession, W as TextTranscriptResult, X as TtsVoiceConfig, Y as TurnEvent, Z as Unsubscribe, _ as UserInputEvent, $ as UserStateEvent, a0 as UserTurn, a1 as applySpeechTurnHandling, a2 as dtmfCodeToDigit, a3 as dtmfDigitToCode, a4 as duck, a5 as mute, a6 as normalizeState, m as participantId, a7 as passthrough, a8 as runTextSession, a9 as runTextTranscript, aa as transform } from './text-session-BqMWaNsN.js';
3
- import { llm } from '@livekit/agents';
1
+ import { A as AgentDTO, a as AgentStatus, b as AgentEnvironment, c as AgentContext, P as Participant, C as CallInfo, d as ProcessSchemaDTO } from './text-session-B7oyrhwQ.js';
2
+ export { e as AgentTurnEvent, f as AudioProfile, g as AudioSurface, h as ChannelKind, D as DtmfEvent, i as DtmfHandler, E as EndCallControllerHandle, j as EndCallOutcome, F as FakeSessionAdapter, k as FloorControlConfig, I as InboundOptions, L as LK_AGENT_STATE_MAP, M as MemoryHandle, l as MetricsEvent, N as NON_BUSY_STATES, m as ParticipantId, n as ParticipantKind, o as ParticipantSet, p as ProcessSnapshot, R as RespondOptions, q as Room, r as RouteEntry, s as RoutingRule, t as RoutingSnapshot, u as RunTextSessionOptions, v as RunTextTranscriptOptions, S as SayOptions, w as SendDtmfOptions, x as SessionAdapter, y as SessionCapabilities, z as SessionErrorEvent, B as SessionEvent, G as SessionEventMap, H as SessionFactory, J as SessionFactoryInput, K as SessionOutbound, O as SessionState, Q as SpeechResult, T as SpeechTarget, U as StateChangeEvent, V as TextSession, W as TextTranscriptResult, X as TtsVoiceConfig, Y as TurnEvent, Z as Unsubscribe, _ as UserInputEvent, $ as UserStateEvent, a0 as UserTurn, a1 as applySpeechTurnHandling, a2 as dtmfCodeToDigit, a3 as dtmfDigitToCode, a4 as duck, a5 as mute, a6 as normalizeState, m as participantId, a7 as passthrough, a8 as runTextSession, a9 as runTextTranscript, aa as transform } from './text-session-B7oyrhwQ.js';
4
3
  import { z, ZodType } from 'zod';
5
4
  import { OnQuery, BrainTransport } from './brain/index.js';
6
5
  export { BrainCallMetadata, BrainCapabilities, BrainChunk, BrainConfigError, BrainEndpointConfig, BrainMessage, BrainPubSub, BrainRequest, BrainRequestError, ConnectorChatModel, ConnectorChatModelOptions, ConnectorLLMOptions, IncomingBrainRequest, OnQueryContext, OnQueryResult, RedisBrainPubSub, SseDelta, TunnelBrainTransportOptions, assertPublicHttpsUrl, buildRedisBrainPubSub, callbackTransport, createConnectorLLM, httpBrainTransport, parseChatCompletionSse, runBrainRequest, tunnelBrainTransport } from './brain/index.js';
6
+ import '@livekit/agents';
7
7
  import 'openai';
8
8
  import 'ioredis';
9
9
 
10
+ /** What the worker fetches: the message, the conversation before it, and who sent it. */
11
+ declare const TextTurn: z.ZodObject<{
12
+ turnId: z.ZodString;
13
+ agentId: z.ZodString;
14
+ /** The Line the message came in on (`sms`, `discord`, `web`, `playground`, …). */
15
+ channel: z.ZodString;
16
+ /** The sender on that Line (phone number, Discord user, widget visitor) — the agent's caller-scoped memory key. */
17
+ from: z.ZodString;
18
+ /** The conversation this turn belongs to (stable across turns) — the tool context's call id. */
19
+ conversationKey: z.ZodString;
20
+ history: z.ZodArray<z.ZodObject<{
21
+ role: z.ZodEnum<["user", "assistant"]>;
22
+ content: z.ZodString;
23
+ }, "strip", z.ZodTypeAny, {
24
+ role: "user" | "assistant";
25
+ content: string;
26
+ }, {
27
+ role: "user" | "assistant";
28
+ content: string;
29
+ }>, "many">;
30
+ text: z.ZodString;
31
+ /** When the API stops waiting; the worker stops the run before it. */
32
+ deadlineAt: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ text: string;
35
+ from: string;
36
+ agentId: string;
37
+ turnId: string;
38
+ channel: string;
39
+ conversationKey: string;
40
+ history: {
41
+ role: "user" | "assistant";
42
+ content: string;
43
+ }[];
44
+ deadlineAt: string;
45
+ }, {
46
+ text: string;
47
+ from: string;
48
+ agentId: string;
49
+ turnId: string;
50
+ channel: string;
51
+ conversationKey: string;
52
+ history: {
53
+ role: "user" | "assistant";
54
+ content: string;
55
+ }[];
56
+ deadlineAt: string;
57
+ }>;
58
+ type TextTurn = z.infer<typeof TextTurn>;
59
+ declare const TextTurnReply: z.ZodUnion<[z.ZodObject<{
60
+ agentId: z.ZodString;
61
+ replies: z.ZodArray<z.ZodString, "many">;
62
+ usage: z.ZodDefault<z.ZodArray<z.ZodObject<{
63
+ provider: z.ZodString;
64
+ model: z.ZodString;
65
+ inputTokens: z.ZodNumber;
66
+ outputTokens: z.ZodNumber;
67
+ /** Only a first-party worker's label is used; a customer's worker runs on its own key (the API decides). */
68
+ byok: z.ZodBoolean;
69
+ }, "strip", z.ZodTypeAny, {
70
+ provider: string;
71
+ model: string;
72
+ inputTokens: number;
73
+ outputTokens: number;
74
+ byok: boolean;
75
+ }, {
76
+ provider: string;
77
+ model: string;
78
+ inputTokens: number;
79
+ outputTokens: number;
80
+ byok: boolean;
81
+ }>, "many">>;
82
+ }, "strip", z.ZodTypeAny, {
83
+ replies: string[];
84
+ agentId: string;
85
+ usage: {
86
+ provider: string;
87
+ model: string;
88
+ inputTokens: number;
89
+ outputTokens: number;
90
+ byok: boolean;
91
+ }[];
92
+ }, {
93
+ replies: string[];
94
+ agentId: string;
95
+ usage?: {
96
+ provider: string;
97
+ model: string;
98
+ inputTokens: number;
99
+ outputTokens: number;
100
+ byok: boolean;
101
+ }[] | undefined;
102
+ }>, z.ZodObject<{
103
+ agentId: z.ZodString;
104
+ error: z.ZodObject<{
105
+ code: z.ZodEnum<["agent_unavailable", "agent_timeout"]>;
106
+ detail: z.ZodOptional<z.ZodString>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ code: "agent_unavailable" | "agent_timeout";
109
+ detail?: string | undefined;
110
+ }, {
111
+ code: "agent_unavailable" | "agent_timeout";
112
+ detail?: string | undefined;
113
+ }>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ error: {
116
+ code: "agent_unavailable" | "agent_timeout";
117
+ detail?: string | undefined;
118
+ };
119
+ agentId: string;
120
+ }, {
121
+ error: {
122
+ code: "agent_unavailable" | "agent_timeout";
123
+ detail?: string | undefined;
124
+ };
125
+ agentId: string;
126
+ }>]>;
127
+ type TextTurnReply = z.infer<typeof TextTurnReply>;
128
+
10
129
  /**
11
130
  * The plan itself. Everything the agent needs to run the call without the
12
131
  * host being present turn-by-turn.
@@ -30,61 +149,6 @@ declare const CallPlan: z.ZodObject<{
30
149
  displayName?: string | undefined;
31
150
  }>;
32
151
  draftConfig: z.ZodDefault<z.ZodObject<{
33
- stt: z.ZodOptional<z.ZodOptional<z.ZodObject<{
34
- provider: z.ZodEnum<["deepgram", "cartesia", "assemblyai"]>;
35
- model: z.ZodOptional<z.ZodString>;
36
- language: z.ZodOptional<z.ZodString>;
37
- endOfTurnConfidence: z.ZodOptional<z.ZodNumber>;
38
- endOfTurnTimeoutMs: z.ZodOptional<z.ZodNumber>;
39
- keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
40
- }, "strip", z.ZodTypeAny, {
41
- provider: "deepgram" | "cartesia" | "assemblyai";
42
- model?: string | undefined;
43
- language?: string | undefined;
44
- endOfTurnConfidence?: number | undefined;
45
- endOfTurnTimeoutMs?: number | undefined;
46
- keywords?: string[] | undefined;
47
- }, {
48
- provider: "deepgram" | "cartesia" | "assemblyai";
49
- model?: string | undefined;
50
- language?: string | undefined;
51
- endOfTurnConfidence?: number | undefined;
52
- endOfTurnTimeoutMs?: number | undefined;
53
- keywords?: string[] | undefined;
54
- }>>>;
55
- realtime: z.ZodOptional<z.ZodOptional<z.ZodObject<{
56
- provider: z.ZodEnum<["openai", "google"]>;
57
- model: z.ZodString;
58
- voice: z.ZodOptional<z.ZodString>;
59
- temperature: z.ZodOptional<z.ZodNumber>;
60
- }, "strip", z.ZodTypeAny, {
61
- provider: "openai" | "google";
62
- model: string;
63
- voice?: string | undefined;
64
- temperature?: number | undefined;
65
- }, {
66
- provider: "openai" | "google";
67
- model: string;
68
- voice?: string | undefined;
69
- temperature?: number | undefined;
70
- }>>>;
71
- voice: z.ZodOptional<z.ZodObject<{
72
- provider: z.ZodEnum<["deepgram", "elevenlabs", "openai", "cartesia"]>;
73
- voiceId: z.ZodString;
74
- model: z.ZodOptional<z.ZodString>;
75
- rate: z.ZodOptional<z.ZodNumber>;
76
- }, "strip", z.ZodTypeAny, {
77
- provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
78
- voiceId: string;
79
- model?: string | undefined;
80
- rate?: number | undefined;
81
- }, {
82
- provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
83
- voiceId: string;
84
- model?: string | undefined;
85
- rate?: number | undefined;
86
- }>>;
87
- source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["sdk", "flow", "playbook", "connector"]>>>;
88
152
  name: z.ZodOptional<z.ZodString>;
89
153
  triggers: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
90
154
  on: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
@@ -92,22 +156,22 @@ declare const CallPlan: z.ZodObject<{
92
156
  pattern: z.ZodString;
93
157
  flags: z.ZodOptional<z.ZodString>;
94
158
  }, "strip", z.ZodTypeAny, {
95
- kind: "regex";
96
159
  pattern: string;
160
+ kind: "regex";
97
161
  flags?: string | undefined;
98
162
  }, {
99
- kind: "regex";
100
163
  pattern: string;
164
+ kind: "regex";
101
165
  flags?: string | undefined;
102
166
  }>, z.ZodObject<{
103
167
  kind: z.ZodLiteral<"signal">;
104
168
  name: z.ZodString;
105
169
  }, "strip", z.ZodTypeAny, {
106
- kind: "signal";
107
170
  name: string;
108
- }, {
109
171
  kind: "signal";
172
+ }, {
110
173
  name: string;
174
+ kind: "signal";
111
175
  }>]>;
112
176
  then: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
113
177
  kind: z.ZodLiteral<"handoff">;
@@ -142,12 +206,12 @@ declare const CallPlan: z.ZodObject<{
142
206
  kind: "say";
143
207
  };
144
208
  on: {
145
- kind: "regex";
146
209
  pattern: string;
210
+ kind: "regex";
147
211
  flags?: string | undefined;
148
212
  } | {
149
- kind: "signal";
150
213
  name: string;
214
+ kind: "signal";
151
215
  };
152
216
  onlyWhile?: string | undefined;
153
217
  }, {
@@ -160,12 +224,12 @@ declare const CallPlan: z.ZodObject<{
160
224
  kind: "say";
161
225
  };
162
226
  on: {
163
- kind: "regex";
164
227
  pattern: string;
228
+ kind: "regex";
165
229
  flags?: string | undefined;
166
230
  } | {
167
- kind: "signal";
168
231
  name: string;
232
+ kind: "signal";
169
233
  };
170
234
  onlyWhile?: string | undefined;
171
235
  }>>>>;
@@ -179,6 +243,61 @@ declare const CallPlan: z.ZodObject<{
179
243
  toolName: string;
180
244
  defaultArgs?: Record<string, unknown> | undefined;
181
245
  }>, "many">>>;
246
+ stt: z.ZodOptional<z.ZodOptional<z.ZodObject<{
247
+ provider: z.ZodEnum<["deepgram", "cartesia", "assemblyai"]>;
248
+ model: z.ZodOptional<z.ZodString>;
249
+ language: z.ZodOptional<z.ZodString>;
250
+ endOfTurnConfidence: z.ZodOptional<z.ZodNumber>;
251
+ endOfTurnTimeoutMs: z.ZodOptional<z.ZodNumber>;
252
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
253
+ }, "strip", z.ZodTypeAny, {
254
+ provider: "deepgram" | "cartesia" | "assemblyai";
255
+ model?: string | undefined;
256
+ language?: string | undefined;
257
+ endOfTurnConfidence?: number | undefined;
258
+ endOfTurnTimeoutMs?: number | undefined;
259
+ keywords?: string[] | undefined;
260
+ }, {
261
+ provider: "deepgram" | "cartesia" | "assemblyai";
262
+ model?: string | undefined;
263
+ language?: string | undefined;
264
+ endOfTurnConfidence?: number | undefined;
265
+ endOfTurnTimeoutMs?: number | undefined;
266
+ keywords?: string[] | undefined;
267
+ }>>>;
268
+ realtime: z.ZodOptional<z.ZodOptional<z.ZodObject<{
269
+ provider: z.ZodEnum<["openai", "google"]>;
270
+ model: z.ZodString;
271
+ voice: z.ZodOptional<z.ZodString>;
272
+ temperature: z.ZodOptional<z.ZodNumber>;
273
+ }, "strip", z.ZodTypeAny, {
274
+ provider: "openai" | "google";
275
+ model: string;
276
+ voice?: string | undefined;
277
+ temperature?: number | undefined;
278
+ }, {
279
+ provider: "openai" | "google";
280
+ model: string;
281
+ voice?: string | undefined;
282
+ temperature?: number | undefined;
283
+ }>>>;
284
+ voice: z.ZodOptional<z.ZodObject<{
285
+ provider: z.ZodEnum<["deepgram", "elevenlabs", "openai", "cartesia"]>;
286
+ voiceId: z.ZodString;
287
+ model: z.ZodOptional<z.ZodString>;
288
+ rate: z.ZodOptional<z.ZodNumber>;
289
+ }, "strip", z.ZodTypeAny, {
290
+ provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
291
+ voiceId: string;
292
+ model?: string | undefined;
293
+ rate?: number | undefined;
294
+ }, {
295
+ provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
296
+ voiceId: string;
297
+ model?: string | undefined;
298
+ rate?: number | undefined;
299
+ }>>;
300
+ source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["sdk", "flow", "playbook", "connector"]>>>;
182
301
  mode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["cascade", "realtime"]>>>;
183
302
  model: z.ZodOptional<z.ZodObject<{
184
303
  provider: z.ZodEnum<["openai", "anthropic", "gemini"]>;
@@ -286,12 +405,12 @@ declare const CallPlan: z.ZodObject<{
286
405
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
287
406
  }, "strip", z.ZodTypeAny, {
288
407
  url: string;
289
- headers?: Record<string, string> | undefined;
290
408
  timeoutMs?: number | undefined;
409
+ headers?: Record<string, string> | undefined;
291
410
  }, {
292
411
  url: string;
293
- headers?: Record<string, string> | undefined;
294
412
  timeoutMs?: number | undefined;
413
+ headers?: Record<string, string> | undefined;
295
414
  }>>;
296
415
  }, "strip", z.ZodTypeAny, {
297
416
  collect: Record<string, {
@@ -307,14 +426,14 @@ declare const CallPlan: z.ZodObject<{
307
426
  completeWhen: "all-required-captured" | "all-captured";
308
427
  backendAck?: {
309
428
  url: string;
310
- headers?: Record<string, string> | undefined;
311
429
  timeoutMs?: number | undefined;
430
+ headers?: Record<string, string> | undefined;
312
431
  } | undefined;
313
432
  }, {
314
433
  backendAck?: {
315
434
  url: string;
316
- headers?: Record<string, string> | undefined;
317
435
  timeoutMs?: number | undefined;
436
+ headers?: Record<string, string> | undefined;
318
437
  } | undefined;
319
438
  collect?: Record<string, {
320
439
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -351,27 +470,6 @@ declare const CallPlan: z.ZodObject<{
351
470
  description?: string | undefined;
352
471
  }>, "many">>>;
353
472
  }, "strip", z.ZodTypeAny, {
354
- stt?: {
355
- provider: "deepgram" | "cartesia" | "assemblyai";
356
- model?: string | undefined;
357
- language?: string | undefined;
358
- endOfTurnConfidence?: number | undefined;
359
- endOfTurnTimeoutMs?: number | undefined;
360
- keywords?: string[] | undefined;
361
- } | undefined;
362
- realtime?: {
363
- provider: "openai" | "google";
364
- model: string;
365
- voice?: string | undefined;
366
- temperature?: number | undefined;
367
- } | undefined;
368
- voice?: {
369
- provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
370
- voiceId: string;
371
- model?: string | undefined;
372
- rate?: number | undefined;
373
- } | undefined;
374
- source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
375
473
  name?: string | undefined;
376
474
  triggers?: Record<string, {
377
475
  then: {
@@ -383,12 +481,12 @@ declare const CallPlan: z.ZodObject<{
383
481
  kind: "say";
384
482
  };
385
483
  on: {
386
- kind: "regex";
387
484
  pattern: string;
485
+ kind: "regex";
388
486
  flags?: string | undefined;
389
487
  } | {
390
- kind: "signal";
391
488
  name: string;
489
+ kind: "signal";
392
490
  };
393
491
  onlyWhile?: string | undefined;
394
492
  }> | undefined;
@@ -396,6 +494,27 @@ declare const CallPlan: z.ZodObject<{
396
494
  toolName: string;
397
495
  defaultArgs?: Record<string, unknown> | undefined;
398
496
  }[] | undefined;
497
+ stt?: {
498
+ provider: "deepgram" | "cartesia" | "assemblyai";
499
+ model?: string | undefined;
500
+ language?: string | undefined;
501
+ endOfTurnConfidence?: number | undefined;
502
+ endOfTurnTimeoutMs?: number | undefined;
503
+ keywords?: string[] | undefined;
504
+ } | undefined;
505
+ realtime?: {
506
+ provider: "openai" | "google";
507
+ model: string;
508
+ voice?: string | undefined;
509
+ temperature?: number | undefined;
510
+ } | undefined;
511
+ voice?: {
512
+ provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
513
+ voiceId: string;
514
+ model?: string | undefined;
515
+ rate?: number | undefined;
516
+ } | undefined;
517
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
399
518
  mode?: "realtime" | "cascade" | undefined;
400
519
  model?: {
401
520
  provider: "openai" | "anthropic" | "gemini";
@@ -435,8 +554,8 @@ declare const CallPlan: z.ZodObject<{
435
554
  completeWhen: "all-required-captured" | "all-captured";
436
555
  backendAck?: {
437
556
  url: string;
438
- headers?: Record<string, string> | undefined;
439
557
  timeoutMs?: number | undefined;
558
+ headers?: Record<string, string> | undefined;
440
559
  } | undefined;
441
560
  } | undefined;
442
561
  tags?: string[] | undefined;
@@ -450,27 +569,6 @@ declare const CallPlan: z.ZodObject<{
450
569
  description?: string | undefined;
451
570
  }[] | undefined;
452
571
  }, {
453
- stt?: {
454
- provider: "deepgram" | "cartesia" | "assemblyai";
455
- model?: string | undefined;
456
- language?: string | undefined;
457
- endOfTurnConfidence?: number | undefined;
458
- endOfTurnTimeoutMs?: number | undefined;
459
- keywords?: string[] | undefined;
460
- } | undefined;
461
- realtime?: {
462
- provider: "openai" | "google";
463
- model: string;
464
- voice?: string | undefined;
465
- temperature?: number | undefined;
466
- } | undefined;
467
- voice?: {
468
- provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
469
- voiceId: string;
470
- model?: string | undefined;
471
- rate?: number | undefined;
472
- } | undefined;
473
- source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
474
572
  name?: string | undefined;
475
573
  triggers?: Record<string, {
476
574
  then: {
@@ -482,12 +580,12 @@ declare const CallPlan: z.ZodObject<{
482
580
  kind: "say";
483
581
  };
484
582
  on: {
485
- kind: "regex";
486
583
  pattern: string;
584
+ kind: "regex";
487
585
  flags?: string | undefined;
488
586
  } | {
489
- kind: "signal";
490
587
  name: string;
588
+ kind: "signal";
491
589
  };
492
590
  onlyWhile?: string | undefined;
493
591
  }> | undefined;
@@ -495,6 +593,27 @@ declare const CallPlan: z.ZodObject<{
495
593
  toolName: string;
496
594
  defaultArgs?: Record<string, unknown> | undefined;
497
595
  }[] | undefined;
596
+ stt?: {
597
+ provider: "deepgram" | "cartesia" | "assemblyai";
598
+ model?: string | undefined;
599
+ language?: string | undefined;
600
+ endOfTurnConfidence?: number | undefined;
601
+ endOfTurnTimeoutMs?: number | undefined;
602
+ keywords?: string[] | undefined;
603
+ } | undefined;
604
+ realtime?: {
605
+ provider: "openai" | "google";
606
+ model: string;
607
+ voice?: string | undefined;
608
+ temperature?: number | undefined;
609
+ } | undefined;
610
+ voice?: {
611
+ provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
612
+ voiceId: string;
613
+ model?: string | undefined;
614
+ rate?: number | undefined;
615
+ } | undefined;
616
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
498
617
  mode?: "realtime" | "cascade" | undefined;
499
618
  model?: {
500
619
  provider: "openai" | "anthropic" | "gemini";
@@ -523,8 +642,8 @@ declare const CallPlan: z.ZodObject<{
523
642
  process?: {
524
643
  backendAck?: {
525
644
  url: string;
526
- headers?: Record<string, string> | undefined;
527
645
  timeoutMs?: number | undefined;
646
+ headers?: Record<string, string> | undefined;
528
647
  } | undefined;
529
648
  collect?: Record<string, {
530
649
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -556,14 +675,14 @@ declare const CallPlan: z.ZodObject<{
556
675
  options: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
557
676
  deferrableToCallee: z.ZodDefault<z.ZodBoolean>;
558
677
  }, "strip", z.ZodTypeAny, {
559
- kind: "decision" | "auth" | "fact";
560
678
  id: string;
679
+ kind: "decision" | "auth" | "fact";
561
680
  prompt: string;
562
681
  deferrableToCallee: boolean;
563
682
  options?: string[] | undefined;
564
683
  }, {
565
- kind: "decision" | "auth" | "fact";
566
684
  id: string;
685
+ kind: "decision" | "auth" | "fact";
567
686
  prompt: string;
568
687
  options?: string[] | undefined;
569
688
  deferrableToCallee?: boolean | undefined;
@@ -575,14 +694,14 @@ declare const CallPlan: z.ZodObject<{
575
694
  options: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
576
695
  deferrableToCallee: z.ZodDefault<z.ZodBoolean>;
577
696
  }, "strip", z.ZodTypeAny, {
578
- kind: "decision" | "auth" | "fact";
579
697
  id: string;
698
+ kind: "decision" | "auth" | "fact";
580
699
  prompt: string;
581
700
  deferrableToCallee: boolean;
582
701
  options?: string[] | undefined;
583
702
  }, {
584
- kind: "decision" | "auth" | "fact";
585
703
  id: string;
704
+ kind: "decision" | "auth" | "fact";
586
705
  prompt: string;
587
706
  options?: string[] | undefined;
588
707
  deferrableToCallee?: boolean | undefined;
@@ -620,27 +739,6 @@ declare const CallPlan: z.ZodObject<{
620
739
  displayName?: string | undefined;
621
740
  };
622
741
  draftConfig: {
623
- stt?: {
624
- provider: "deepgram" | "cartesia" | "assemblyai";
625
- model?: string | undefined;
626
- language?: string | undefined;
627
- endOfTurnConfidence?: number | undefined;
628
- endOfTurnTimeoutMs?: number | undefined;
629
- keywords?: string[] | undefined;
630
- } | undefined;
631
- realtime?: {
632
- provider: "openai" | "google";
633
- model: string;
634
- voice?: string | undefined;
635
- temperature?: number | undefined;
636
- } | undefined;
637
- voice?: {
638
- provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
639
- voiceId: string;
640
- model?: string | undefined;
641
- rate?: number | undefined;
642
- } | undefined;
643
- source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
644
742
  name?: string | undefined;
645
743
  triggers?: Record<string, {
646
744
  then: {
@@ -652,12 +750,12 @@ declare const CallPlan: z.ZodObject<{
652
750
  kind: "say";
653
751
  };
654
752
  on: {
655
- kind: "regex";
656
753
  pattern: string;
754
+ kind: "regex";
657
755
  flags?: string | undefined;
658
756
  } | {
659
- kind: "signal";
660
757
  name: string;
758
+ kind: "signal";
661
759
  };
662
760
  onlyWhile?: string | undefined;
663
761
  }> | undefined;
@@ -665,6 +763,27 @@ declare const CallPlan: z.ZodObject<{
665
763
  toolName: string;
666
764
  defaultArgs?: Record<string, unknown> | undefined;
667
765
  }[] | undefined;
766
+ stt?: {
767
+ provider: "deepgram" | "cartesia" | "assemblyai";
768
+ model?: string | undefined;
769
+ language?: string | undefined;
770
+ endOfTurnConfidence?: number | undefined;
771
+ endOfTurnTimeoutMs?: number | undefined;
772
+ keywords?: string[] | undefined;
773
+ } | undefined;
774
+ realtime?: {
775
+ provider: "openai" | "google";
776
+ model: string;
777
+ voice?: string | undefined;
778
+ temperature?: number | undefined;
779
+ } | undefined;
780
+ voice?: {
781
+ provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
782
+ voiceId: string;
783
+ model?: string | undefined;
784
+ rate?: number | undefined;
785
+ } | undefined;
786
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
668
787
  mode?: "realtime" | "cascade" | undefined;
669
788
  model?: {
670
789
  provider: "openai" | "anthropic" | "gemini";
@@ -704,8 +823,8 @@ declare const CallPlan: z.ZodObject<{
704
823
  completeWhen: "all-required-captured" | "all-captured";
705
824
  backendAck?: {
706
825
  url: string;
707
- headers?: Record<string, string> | undefined;
708
826
  timeoutMs?: number | undefined;
827
+ headers?: Record<string, string> | undefined;
709
828
  } | undefined;
710
829
  } | undefined;
711
830
  tags?: string[] | undefined;
@@ -720,15 +839,15 @@ declare const CallPlan: z.ZodObject<{
720
839
  }[] | undefined;
721
840
  };
722
841
  openQuestions: {
723
- kind: "decision" | "auth" | "fact";
724
842
  id: string;
843
+ kind: "decision" | "auth" | "fact";
725
844
  prompt: string;
726
845
  deferrableToCallee: boolean;
727
846
  options?: string[] | undefined;
728
847
  }[];
729
848
  unresolvedQuestions: {
730
- kind: "decision" | "auth" | "fact";
731
849
  id: string;
850
+ kind: "decision" | "auth" | "fact";
732
851
  prompt: string;
733
852
  deferrableToCallee: boolean;
734
853
  options?: string[] | undefined;
@@ -760,27 +879,6 @@ declare const CallPlan: z.ZodObject<{
760
879
  secondary?: "ask_callee" | "fallback_phrase" | undefined;
761
880
  };
762
881
  draftConfig?: {
763
- stt?: {
764
- provider: "deepgram" | "cartesia" | "assemblyai";
765
- model?: string | undefined;
766
- language?: string | undefined;
767
- endOfTurnConfidence?: number | undefined;
768
- endOfTurnTimeoutMs?: number | undefined;
769
- keywords?: string[] | undefined;
770
- } | undefined;
771
- realtime?: {
772
- provider: "openai" | "google";
773
- model: string;
774
- voice?: string | undefined;
775
- temperature?: number | undefined;
776
- } | undefined;
777
- voice?: {
778
- provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
779
- voiceId: string;
780
- model?: string | undefined;
781
- rate?: number | undefined;
782
- } | undefined;
783
- source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
784
882
  name?: string | undefined;
785
883
  triggers?: Record<string, {
786
884
  then: {
@@ -792,12 +890,12 @@ declare const CallPlan: z.ZodObject<{
792
890
  kind: "say";
793
891
  };
794
892
  on: {
795
- kind: "regex";
796
893
  pattern: string;
894
+ kind: "regex";
797
895
  flags?: string | undefined;
798
896
  } | {
799
- kind: "signal";
800
897
  name: string;
898
+ kind: "signal";
801
899
  };
802
900
  onlyWhile?: string | undefined;
803
901
  }> | undefined;
@@ -805,6 +903,27 @@ declare const CallPlan: z.ZodObject<{
805
903
  toolName: string;
806
904
  defaultArgs?: Record<string, unknown> | undefined;
807
905
  }[] | undefined;
906
+ stt?: {
907
+ provider: "deepgram" | "cartesia" | "assemblyai";
908
+ model?: string | undefined;
909
+ language?: string | undefined;
910
+ endOfTurnConfidence?: number | undefined;
911
+ endOfTurnTimeoutMs?: number | undefined;
912
+ keywords?: string[] | undefined;
913
+ } | undefined;
914
+ realtime?: {
915
+ provider: "openai" | "google";
916
+ model: string;
917
+ voice?: string | undefined;
918
+ temperature?: number | undefined;
919
+ } | undefined;
920
+ voice?: {
921
+ provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
922
+ voiceId: string;
923
+ model?: string | undefined;
924
+ rate?: number | undefined;
925
+ } | undefined;
926
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
808
927
  mode?: "realtime" | "cascade" | undefined;
809
928
  model?: {
810
929
  provider: "openai" | "anthropic" | "gemini";
@@ -833,8 +952,8 @@ declare const CallPlan: z.ZodObject<{
833
952
  process?: {
834
953
  backendAck?: {
835
954
  url: string;
836
- headers?: Record<string, string> | undefined;
837
955
  timeoutMs?: number | undefined;
956
+ headers?: Record<string, string> | undefined;
838
957
  } | undefined;
839
958
  collect?: Record<string, {
840
959
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -860,15 +979,15 @@ declare const CallPlan: z.ZodObject<{
860
979
  }[] | undefined;
861
980
  } | undefined;
862
981
  openQuestions?: {
863
- kind: "decision" | "auth" | "fact";
864
982
  id: string;
983
+ kind: "decision" | "auth" | "fact";
865
984
  prompt: string;
866
985
  options?: string[] | undefined;
867
986
  deferrableToCallee?: boolean | undefined;
868
987
  }[] | undefined;
869
988
  unresolvedQuestions?: {
870
- kind: "decision" | "auth" | "fact";
871
989
  id: string;
990
+ kind: "decision" | "auth" | "fact";
872
991
  prompt: string;
873
992
  options?: string[] | undefined;
874
993
  deferrableToCallee?: boolean | undefined;
@@ -886,13 +1005,13 @@ declare const RelevantContext: z.ZodObject<{
886
1005
  account: z.ZodRecord<z.ZodString, z.ZodUnknown>;
887
1006
  platform: z.ZodRecord<z.ZodString, z.ZodUnknown>;
888
1007
  }, "strip", z.ZodTypeAny, {
889
- caller: Record<string, unknown>;
890
1008
  call: Record<string, unknown>;
1009
+ caller: Record<string, unknown>;
891
1010
  account: Record<string, unknown>;
892
1011
  platform: Record<string, unknown>;
893
1012
  }, {
894
- caller: Record<string, unknown>;
895
1013
  call: Record<string, unknown>;
1014
+ caller: Record<string, unknown>;
896
1015
  account: Record<string, unknown>;
897
1016
  platform: Record<string, unknown>;
898
1017
  }>;
@@ -950,10 +1069,10 @@ declare const DeleteCallerResponse: z.ZodObject<{
950
1069
  scopesPurged: z.ZodArray<z.ZodEnum<["call", "caller", "account", "platform"]>, "many">;
951
1070
  }, "strip", z.ZodTypeAny, {
952
1071
  ok: true;
953
- scopesPurged: ("caller" | "call" | "account" | "platform")[];
1072
+ scopesPurged: ("call" | "caller" | "account" | "platform")[];
954
1073
  }, {
955
1074
  ok: true;
956
- scopesPurged: ("caller" | "call" | "account" | "platform")[];
1075
+ scopesPurged: ("call" | "caller" | "account" | "platform")[];
957
1076
  }>;
958
1077
  type DeleteCallerResponse = z.infer<typeof DeleteCallerResponse>;
959
1078
 
@@ -1183,12 +1302,12 @@ declare const AgentConfig$1: z.ZodObject<{
1183
1302
  headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1184
1303
  }, "strip", z.ZodTypeAny, {
1185
1304
  url: string;
1186
- headers?: Record<string, string> | undefined;
1187
1305
  timeoutMs?: number | undefined;
1306
+ headers?: Record<string, string> | undefined;
1188
1307
  }, {
1189
1308
  url: string;
1190
- headers?: Record<string, string> | undefined;
1191
1309
  timeoutMs?: number | undefined;
1310
+ headers?: Record<string, string> | undefined;
1192
1311
  }>>;
1193
1312
  }, "strip", z.ZodTypeAny, {
1194
1313
  collect: Record<string, {
@@ -1204,14 +1323,14 @@ declare const AgentConfig$1: z.ZodObject<{
1204
1323
  completeWhen: "all-required-captured" | "all-captured";
1205
1324
  backendAck?: {
1206
1325
  url: string;
1207
- headers?: Record<string, string> | undefined;
1208
1326
  timeoutMs?: number | undefined;
1327
+ headers?: Record<string, string> | undefined;
1209
1328
  } | undefined;
1210
1329
  }, {
1211
1330
  backendAck?: {
1212
1331
  url: string;
1213
- headers?: Record<string, string> | undefined;
1214
1332
  timeoutMs?: number | undefined;
1333
+ headers?: Record<string, string> | undefined;
1215
1334
  } | undefined;
1216
1335
  collect?: Record<string, {
1217
1336
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -1231,22 +1350,22 @@ declare const AgentConfig$1: z.ZodObject<{
1231
1350
  pattern: z.ZodString;
1232
1351
  flags: z.ZodOptional<z.ZodString>;
1233
1352
  }, "strip", z.ZodTypeAny, {
1234
- kind: "regex";
1235
1353
  pattern: string;
1354
+ kind: "regex";
1236
1355
  flags?: string | undefined;
1237
1356
  }, {
1238
- kind: "regex";
1239
1357
  pattern: string;
1358
+ kind: "regex";
1240
1359
  flags?: string | undefined;
1241
1360
  }>, z.ZodObject<{
1242
1361
  kind: z.ZodLiteral<"signal">;
1243
1362
  name: z.ZodString;
1244
1363
  }, "strip", z.ZodTypeAny, {
1245
- kind: "signal";
1246
1364
  name: string;
1247
- }, {
1248
1365
  kind: "signal";
1366
+ }, {
1249
1367
  name: string;
1368
+ kind: "signal";
1250
1369
  }>]>;
1251
1370
  then: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1252
1371
  kind: z.ZodLiteral<"handoff">;
@@ -1281,12 +1400,12 @@ declare const AgentConfig$1: z.ZodObject<{
1281
1400
  kind: "say";
1282
1401
  };
1283
1402
  on: {
1284
- kind: "regex";
1285
1403
  pattern: string;
1404
+ kind: "regex";
1286
1405
  flags?: string | undefined;
1287
1406
  } | {
1288
- kind: "signal";
1289
1407
  name: string;
1408
+ kind: "signal";
1290
1409
  };
1291
1410
  onlyWhile?: string | undefined;
1292
1411
  }, {
@@ -1299,12 +1418,12 @@ declare const AgentConfig$1: z.ZodObject<{
1299
1418
  kind: "say";
1300
1419
  };
1301
1420
  on: {
1302
- kind: "regex";
1303
1421
  pattern: string;
1422
+ kind: "regex";
1304
1423
  flags?: string | undefined;
1305
1424
  } | {
1306
- kind: "signal";
1307
1425
  name: string;
1426
+ kind: "signal";
1308
1427
  };
1309
1428
  onlyWhile?: string | undefined;
1310
1429
  }>>>;
@@ -1334,21 +1453,21 @@ declare const AgentConfig$1: z.ZodObject<{
1334
1453
  createdAt: z.ZodString;
1335
1454
  updatedAt: z.ZodString;
1336
1455
  }, "strip", z.ZodTypeAny, {
1456
+ id: string;
1457
+ name: string;
1458
+ tools: {
1459
+ toolName: string;
1460
+ defaultArgs?: Record<string, unknown> | undefined;
1461
+ }[];
1337
1462
  voice: {
1338
1463
  provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
1339
1464
  voiceId: string;
1340
1465
  model?: string | undefined;
1341
1466
  rate?: number | undefined;
1342
1467
  };
1343
- id: string;
1344
1468
  projectId: string;
1345
- name: string;
1346
1469
  createdAt: string;
1347
1470
  updatedAt: string;
1348
- tools: {
1349
- toolName: string;
1350
- defaultArgs?: Record<string, unknown> | undefined;
1351
- }[];
1352
1471
  mode: "realtime" | "cascade";
1353
1472
  model: {
1354
1473
  provider: "openai" | "anthropic" | "gemini";
@@ -1379,21 +1498,6 @@ declare const AgentConfig$1: z.ZodObject<{
1379
1498
  enum?: string[] | undefined;
1380
1499
  description?: string | undefined;
1381
1500
  }[];
1382
- stt?: {
1383
- provider: "deepgram" | "cartesia" | "assemblyai";
1384
- model?: string | undefined;
1385
- language?: string | undefined;
1386
- endOfTurnConfidence?: number | undefined;
1387
- endOfTurnTimeoutMs?: number | undefined;
1388
- keywords?: string[] | undefined;
1389
- } | undefined;
1390
- realtime?: {
1391
- provider: "openai" | "google";
1392
- model: string;
1393
- voice?: string | undefined;
1394
- temperature?: number | undefined;
1395
- } | undefined;
1396
- source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1397
1501
  triggers?: Record<string, {
1398
1502
  then: {
1399
1503
  kind: "handoff";
@@ -1404,15 +1508,30 @@ declare const AgentConfig$1: z.ZodObject<{
1404
1508
  kind: "say";
1405
1509
  };
1406
1510
  on: {
1407
- kind: "regex";
1408
1511
  pattern: string;
1512
+ kind: "regex";
1409
1513
  flags?: string | undefined;
1410
1514
  } | {
1411
- kind: "signal";
1412
1515
  name: string;
1516
+ kind: "signal";
1413
1517
  };
1414
1518
  onlyWhile?: string | undefined;
1415
1519
  }> | undefined;
1520
+ stt?: {
1521
+ provider: "deepgram" | "cartesia" | "assemblyai";
1522
+ model?: string | undefined;
1523
+ language?: string | undefined;
1524
+ endOfTurnConfidence?: number | undefined;
1525
+ endOfTurnTimeoutMs?: number | undefined;
1526
+ keywords?: string[] | undefined;
1527
+ } | undefined;
1528
+ realtime?: {
1529
+ provider: "openai" | "google";
1530
+ model: string;
1531
+ voice?: string | undefined;
1532
+ temperature?: number | undefined;
1533
+ } | undefined;
1534
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1416
1535
  systemPrompt?: string | undefined;
1417
1536
  routingInstructions?: string | undefined;
1418
1537
  process?: {
@@ -1429,23 +1548,23 @@ declare const AgentConfig$1: z.ZodObject<{
1429
1548
  completeWhen: "all-required-captured" | "all-captured";
1430
1549
  backendAck?: {
1431
1550
  url: string;
1432
- headers?: Record<string, string> | undefined;
1433
1551
  timeoutMs?: number | undefined;
1552
+ headers?: Record<string, string> | undefined;
1434
1553
  } | undefined;
1435
1554
  } | undefined;
1436
1555
  tags?: string[] | undefined;
1437
1556
  brainConnectorId?: string | null | undefined;
1438
1557
  modeLocked?: boolean | undefined;
1439
1558
  }, {
1559
+ id: string;
1560
+ name: string;
1440
1561
  voice: {
1441
1562
  provider: "deepgram" | "elevenlabs" | "openai" | "cartesia";
1442
1563
  voiceId: string;
1443
1564
  model?: string | undefined;
1444
1565
  rate?: number | undefined;
1445
1566
  };
1446
- id: string;
1447
1567
  projectId: string;
1448
- name: string;
1449
1568
  createdAt: string;
1450
1569
  updatedAt: string;
1451
1570
  model: {
@@ -1469,21 +1588,6 @@ declare const AgentConfig$1: z.ZodObject<{
1469
1588
  normal?: number | undefined;
1470
1589
  } | undefined;
1471
1590
  };
1472
- stt?: {
1473
- provider: "deepgram" | "cartesia" | "assemblyai";
1474
- model?: string | undefined;
1475
- language?: string | undefined;
1476
- endOfTurnConfidence?: number | undefined;
1477
- endOfTurnTimeoutMs?: number | undefined;
1478
- keywords?: string[] | undefined;
1479
- } | undefined;
1480
- realtime?: {
1481
- provider: "openai" | "google";
1482
- model: string;
1483
- voice?: string | undefined;
1484
- temperature?: number | undefined;
1485
- } | undefined;
1486
- source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1487
1591
  triggers?: Record<string, {
1488
1592
  then: {
1489
1593
  kind: "handoff";
@@ -1494,12 +1598,12 @@ declare const AgentConfig$1: z.ZodObject<{
1494
1598
  kind: "say";
1495
1599
  };
1496
1600
  on: {
1497
- kind: "regex";
1498
1601
  pattern: string;
1602
+ kind: "regex";
1499
1603
  flags?: string | undefined;
1500
1604
  } | {
1501
- kind: "signal";
1502
1605
  name: string;
1606
+ kind: "signal";
1503
1607
  };
1504
1608
  onlyWhile?: string | undefined;
1505
1609
  }> | undefined;
@@ -1507,6 +1611,21 @@ declare const AgentConfig$1: z.ZodObject<{
1507
1611
  toolName: string;
1508
1612
  defaultArgs?: Record<string, unknown> | undefined;
1509
1613
  }[] | undefined;
1614
+ stt?: {
1615
+ provider: "deepgram" | "cartesia" | "assemblyai";
1616
+ model?: string | undefined;
1617
+ language?: string | undefined;
1618
+ endOfTurnConfidence?: number | undefined;
1619
+ endOfTurnTimeoutMs?: number | undefined;
1620
+ keywords?: string[] | undefined;
1621
+ } | undefined;
1622
+ realtime?: {
1623
+ provider: "openai" | "google";
1624
+ model: string;
1625
+ voice?: string | undefined;
1626
+ temperature?: number | undefined;
1627
+ } | undefined;
1628
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1510
1629
  mode?: "realtime" | "cascade" | undefined;
1511
1630
  language?: string | undefined;
1512
1631
  systemPrompt?: string | undefined;
@@ -1514,8 +1633,8 @@ declare const AgentConfig$1: z.ZodObject<{
1514
1633
  process?: {
1515
1634
  backendAck?: {
1516
1635
  url: string;
1517
- headers?: Record<string, string> | undefined;
1518
1636
  timeoutMs?: number | undefined;
1637
+ headers?: Record<string, string> | undefined;
1519
1638
  } | undefined;
1520
1639
  collect?: Record<string, {
1521
1640
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -2124,352 +2243,86 @@ interface AgentConfig<TProcess extends Record<string, ProcessField> = Record<str
2124
2243
  *
2125
2244
  * Equivalent to `models: { llm: connector.llm({ onQuery }) }`. For a remote
2126
2245
  * brain instead, use `connector.llm({ url })` (direct) or a tunnel transport.
2127
- * See docs/specs/voice-brain-connector/.
2128
- */
2129
- readonly onQuery?: OnQuery;
2130
- readonly onUtterance?: (text: string, ctx: AgentContext) => Promise<void> | void;
2131
- readonly onFieldCaptured?: (field: string, value: unknown, ctx: AgentContext) => Promise<void> | void;
2132
- readonly onCallEnd?: (outcome: CallOutcomeSummary, ctx: AgentContext) => Promise<void> | void;
2133
- readonly onEvent?: (event: AgentLifecycleEvent) => void;
2134
- /** Replace the default conversation loop. The SDK does NOT auto-greet. */
2135
- readonly onCall?: (ctx: AgentContext) => Promise<void>;
2136
- readonly readiness?: readonly ReadinessProbe[];
2137
- /**
2138
- * Run as a remote-controlled (puppet) agent: no autonomous LLM loop, no
2139
- * process/triggers pipeline. STT utterances are still published to
2140
- * `call-events:{callId}` via the existing transcript-segments sync, and
2141
- * the SDK subscribes to `call-control:{room}` to receive `say`,
2142
- * `hangup`, `dtmf` commands from an external driver (typically the MCP
2143
- * server invoked by a coding agent).
2144
- *
2145
- * When this is on, `process`, `triggers`, `onUtterance`, `onCall` are
2146
- * ignored. `tools`, `connectors`, `memory` still work.
2147
- */
2148
- readonly puppetMode?: boolean;
2149
- /**
2150
- * Host-controlled autonomous agent (the "smart puppet"). UNLIKE puppetMode,
2151
- * the agent keeps its REAL LLM and drives the conversation itself from its
2152
- * prompt (the per-call `intent` is appended at boot). Since 0.2.0 EVERY
2153
- * agent listens on its call's control channel (the MCP host can interject
2154
- * with `say`, `hangup` or send `dtmf`, and answer `ask_host`), so this flag
2155
- * now only shapes turn handling for a host-driven call. Use this for an agent that takes a customer's
2156
- * intent and runs the call like a human secretary, asking the host for any
2157
- * info it's missing. Mutually exclusive in spirit with puppetMode (which is
2158
- * the older NoOp "dumb mouth").
2159
- */
2160
- readonly hostControlled?: boolean;
2161
- /** When set, this agent boots each call from a deployed flow's process_schema. */
2162
- readonly flowRuntime?: FlowRuntimeConfig;
2163
- /**
2164
- * Opt a hand-coded (non-flow) agent into the dashboard-driven pipeline: on
2165
- * each call the SDK fetches this agent's PUBLISHED configuration (a saved
2166
- * dashboard draft applies only once the owner publishes it) and applies
2167
- * the operator-selected voice / model / STT over the coded defaults. The
2168
- * pipeline *mode* (cascade vs realtime) stays pinned to what the code
2169
- * declares — a stale `mode=realtime` in the dashboard can't flip a
2170
- * cascade-only worker. Flow agents (`flowRuntime`) get this implicitly and
2171
- * may additionally switch mode; this flag is the SDK opt-in. The agent id is
2172
- * read from dispatch metadata (the inbound router injects it from
2173
- * phone_numbers.agentId), so it's a no-op for calls without one.
2174
- */
2175
- readonly pipelineFromConfig?: boolean;
2176
- /**
2177
- * Opt this agent into MCP-layer visibility. When true, on register the API
2178
- * also writes an `agent_config` row keyed by (project_id, name,
2179
- * environment) so MCP / dashboard / REST can list and inspect this agent
2180
- * (and, post-step-7, drive call_say / call_send_guidance / etc against
2181
- * its live calls).
2182
- *
2183
- * Defaults to true so newly-registered agents show up in dashboards and
2184
- * MCP-host listings without opt-in. Pass `false` for autonomous-only
2185
- * agents that should stay invisible to MCP. See
2186
- * docs/architecture/contracts-design.md §2b.
2187
- */
2188
- readonly mcpExposed?: boolean;
2189
- }
2190
- interface CallOutcomeSummary {
2191
- readonly reason: 'completed' | 'handoff' | 'caller_hung_up' | 'agent_hung_up' | 'error';
2192
- readonly durationMs: number;
2193
- readonly processCompleted: boolean;
2194
- readonly fieldsCaptured: number;
2195
- readonly handoffOccurred: boolean;
2196
- }
2197
- /**
2198
- * Identity helper that gives users a typed `defineProcess` entry point with
2199
- * full inference on `onComplete`'s `data` argument.
2200
- *
2201
- * defineProcess({
2202
- * collect: { name: { type: 'string', required: true } },
2203
- * onComplete: (data) => { data.name // string },
2204
- * })
2205
- */
2206
- declare function defineProcess<T extends Record<string, ProcessField>>(def: ProcessDefinition<T>): ProcessDefinition<T>;
2207
-
2208
- interface RunAgentTextTranscriptOptions {
2209
- /** The agent's system prompt / instructions (its code-defined behavior). */
2210
- readonly instructions: string;
2211
- /** The LLM that generates replies — injected so this stays provider-agnostic and
2212
- * unit-testable (real inference/openai LLM in prod; a scripted fake in tests). */
2213
- readonly llm: llm.LLM;
2214
- /** Scripted caller turns, run in order; each produces the agent's reply turn(s). */
2215
- readonly messages: readonly string[];
2216
- /** Optional id surfaced on the Agent (for traceability). */
2217
- readonly agentId?: string;
2218
- }
2219
- interface AgentTextTranscriptResult {
2220
- readonly replies: string[];
2221
- }
2222
- interface RunLiveAgentTextOptions {
2223
- /** The agent's system prompt / instructions (its code-defined behavior). */
2224
- readonly instructions: string;
2225
- /** The LLM that generates replies (injected — real provider LLM or a fake). */
2226
- readonly llm: llm.LLM;
2227
- /** Optional id surfaced on the Agent (for traceability). */
2228
- readonly agentId?: string;
2229
- /**
2230
- * Labels for the model usage each turn reports (the surface that owns the reply meters it): which provider and
2231
- * model this session's LLM is, and whether the workspace's own key (BYOK) serves it. Absent ⇒ turns report no usage.
2232
- */
2233
- readonly meter?: {
2234
- readonly provider: string;
2235
- readonly model: string;
2236
- readonly byok: boolean;
2237
- };
2238
- }
2239
- /** Model usage behind one turn (one entry per model request) — the host-sdk `TurnModelUsage` shape, structurally. */
2240
- interface LiveAgentTurnUsage {
2241
- readonly provider: string;
2242
- readonly model: string;
2243
- readonly inputTokens: number;
2244
- readonly outputTokens: number;
2245
- readonly byok: boolean;
2246
- }
2247
- /** One live turn of a code-first agent: the assistant text for that turn, and
2248
- * whether the conversation ended (code-first sessions stay open until `end`). */
2249
- interface LiveAgentTurn {
2250
- readonly replies: string[];
2251
- readonly done: boolean;
2252
- /** The model requests this turn made (only when the session was given `meter` labels). */
2253
- readonly usage?: readonly LiveAgentTurnUsage[];
2254
- }
2255
- /** A live, turn-by-turn conversation with a code-first agent — the AgentSession is
2256
- * kept alive across turns (it carries chat history internally), so this is the
2257
- * code-first analogue of `runLiveTextConversation` (the flow driver). Shape
2258
- * matches the engine's AgentConversation so the agent-runner drives both alike. */
2259
- interface LiveAgentTextSession {
2260
- /** Start the session. Code-first agents don't auto-greet in no-room text mode,
2261
- * so the opening turn is empty; the first user turn produces the first reply. */
2262
- start(): Promise<LiveAgentTurn>;
2263
- /** Feed one user message; resolves with the agent's replies for that turn. */
2264
- turn(text: string): Promise<LiveAgentTurn>;
2265
- /** Close the session. */
2266
- end(): Promise<void>;
2267
- }
2268
- declare function runLiveAgentTextSession(opts: RunLiveAgentTextOptions): LiveAgentTextSession;
2269
- /** Drive an instruction-based agent over text and collect its replies. Stateless
2270
- * batch turn — built on the live driver (start → turn per message → end). */
2271
- declare function runAgentTextTranscript(opts: RunAgentTextTranscriptOptions): Promise<AgentTextTranscriptResult>;
2272
-
2273
- interface WrapOptions<T> {
2274
- /** Emit OTel spans around each method call. Default: true. */
2275
- readonly trace?: boolean;
2276
- /** Tag spans with `vl.provider.label` for easy filtering. */
2277
- readonly label?: string;
2278
- /**
2279
- * Fallback provider used if the primary throws. Accepts an instance OR a
2280
- * ProviderFactory (so `deepgram.tts(...)` works directly). The fallback is
2281
- * resolved lazily on first error.
2282
- */
2283
- readonly fallback?: T | ProviderFactory<T>;
2284
- /**
2285
- * Methods to instrument. By default the wrapper instruments every method
2286
- * call. Pass an explicit list to limit overhead on hot paths.
2287
- */
2288
- readonly methods?: readonly string[];
2289
- }
2290
- /**
2291
- * Returns either the wrapped instance directly (when called with one) or a
2292
- * ProviderFactory that produces the wrapped instance (when called with one of
2293
- * those). This keeps the lazy import story intact: `wrap(deepgram.tts(...))`
2294
- * is itself a factory.
2295
- */
2296
- declare function wrap<T extends object>(target: T | ProviderFactory<T>, options?: WrapOptions<T>): T | ProviderFactory<T>;
2297
-
2298
- interface ProviderCreds {
2299
- readonly apiKey?: string;
2300
- readonly baseURL?: string;
2301
- }
2302
- declare const deepgram: {
2303
- stt(options?: {
2304
- model?: string;
2305
- language?: string;
2306
- apiKey?: string;
2307
- baseURL?: string;
2308
- }): ProviderFactory<STTProvider>;
2309
- tts(options?: {
2310
- model?: string;
2311
- apiKey?: string;
2312
- baseURL?: string;
2313
- }): ProviderFactory<TTSProvider>;
2314
- };
2315
- declare const openai: {
2316
- llm(options?: {
2317
- model?: string;
2318
- apiKey?: string;
2319
- baseURL?: string;
2320
- }): ProviderFactory<LLMProvider>;
2321
- tts(options?: {
2322
- model?: string;
2323
- voice?: string;
2324
- instructions?: string;
2325
- apiKey?: string;
2326
- baseURL?: string;
2327
- }): ProviderFactory<TTSProvider>;
2328
- realtime(options?: {
2329
- model?: string;
2330
- voice?: string;
2331
- apiKey?: string;
2332
- baseURL?: string;
2333
- }): ProviderFactory<RealtimeProvider>;
2334
- };
2335
- declare const cartesia: {
2336
- tts(options?: {
2337
- voice?: string;
2338
- model?: string;
2339
- apiKey?: string;
2340
- baseURL?: string;
2341
- }): ProviderFactory<TTSProvider>;
2342
- stt(options?: {
2343
- model?: string;
2344
- language?: string;
2345
- apiKey?: string;
2346
- baseURL?: string;
2347
- }): ProviderFactory<STTProvider>;
2348
- };
2349
- declare const elevenlabs: {
2350
- tts(options?: {
2351
- voice?: string;
2352
- model?: string;
2353
- apiKey?: string;
2354
- baseURL?: string;
2355
- }): ProviderFactory<TTSProvider>;
2356
- };
2357
- declare const assemblyai: {
2358
- stt(options?: {
2359
- language?: string;
2360
- apiKey?: string;
2361
- baseURL?: string;
2362
- }): ProviderFactory<STTProvider>;
2363
- };
2364
- declare const google: {
2365
- llm(options?: {
2366
- model?: string;
2367
- apiKey?: string;
2368
- baseURL?: string;
2369
- }): ProviderFactory<LLMProvider>;
2370
- realtime(options?: {
2371
- model?: string;
2372
- voice?: string;
2373
- apiKey?: string;
2374
- baseURL?: string;
2375
- }): ProviderFactory<RealtimeProvider>;
2376
- };
2377
- declare const silero: {
2378
- vad(): ProviderFactory<VADProvider>;
2379
- };
2380
- declare const livekitTurn: {
2381
- english(): ProviderFactory<TurnDetectorProvider>;
2382
- multilingual(): ProviderFactory<TurnDetectorProvider>;
2383
- };
2384
- interface ConnectorLLMConfig {
2385
- /** Upstream model id / alias (defaults to the brain's own default). */
2386
- readonly model?: string;
2387
- readonly temperature?: number;
2388
- /** Spoken instead of dead air when the brain errors before replying. */
2389
- readonly fallbackText?: string;
2390
- /** In-process brain. */
2246
+ * See docs/specs/voice-brain-connector/.
2247
+ */
2391
2248
  readonly onQuery?: OnQuery;
2392
- /** Direct-egress brain — a public OpenAI-compatible base URL. */
2393
- readonly url?: string;
2394
- /** API key for the direct-egress endpoint. */
2395
- readonly apiKey?: string;
2396
- /** Hostnames that bypass the SSRF IP checks (direct mode). */
2397
- readonly allowHosts?: readonly string[];
2398
- /** Advanced: a custom transport (tunnel, etc.). */
2399
- readonly transport?: BrainTransport;
2400
- }
2401
- declare const connector: {
2402
- llm(config?: ConnectorLLMConfig): ProviderFactory<LLMProvider>;
2403
- };
2404
-
2405
- /** The control-plane reads the resolver needs. Structural (not the full
2406
- * VoiceLayerClient) so it stays trivially fakeable in tests — a real client
2407
- * satisfies it. */
2408
- interface AgentTextRuntimeClient {
2409
- readonly agents: {
2410
- getPrompt(agentId: string): Promise<string | null>;
2411
- getConfig(agentId: string): Promise<{
2412
- readonly model?: {
2413
- readonly provider: string;
2414
- readonly model: string;
2415
- };
2416
- readonly routingInstructions?: string | undefined;
2417
- } | null>;
2418
- };
2419
- readonly connections: {
2420
- resolveProviderCredential(provider: string): Promise<{
2421
- readonly apiKey: string;
2422
- readonly baseUrl?: string | undefined;
2423
- } | null>;
2424
- };
2249
+ readonly onUtterance?: (text: string, ctx: AgentContext) => Promise<void> | void;
2250
+ readonly onFieldCaptured?: (field: string, value: unknown, ctx: AgentContext) => Promise<void> | void;
2251
+ readonly onCallEnd?: (outcome: CallOutcomeSummary, ctx: AgentContext) => Promise<void> | void;
2252
+ readonly onEvent?: (event: AgentLifecycleEvent) => void;
2253
+ /** Replace the default conversation loop. The SDK does NOT auto-greet. */
2254
+ readonly onCall?: (ctx: AgentContext) => Promise<void>;
2255
+ readonly readiness?: readonly ReadinessProbe[];
2256
+ /**
2257
+ * Run as a remote-controlled (puppet) agent: no autonomous LLM loop, no
2258
+ * process/triggers pipeline. STT utterances are still published to
2259
+ * `call-events:{callId}` via the existing transcript-segments sync, and
2260
+ * the SDK subscribes to `call-control:{room}` to receive `say`,
2261
+ * `hangup`, `dtmf` commands from an external driver (typically the MCP
2262
+ * server invoked by a coding agent).
2263
+ *
2264
+ * When this is on, `process`, `triggers`, `onUtterance`, `onCall` are
2265
+ * ignored. `tools`, `connectors`, `memory` still work.
2266
+ */
2267
+ readonly puppetMode?: boolean;
2268
+ /**
2269
+ * Host-controlled autonomous agent (the "smart puppet"). UNLIKE puppetMode,
2270
+ * the agent keeps its REAL LLM and drives the conversation itself from its
2271
+ * prompt (the per-call `intent` is appended at boot). Since 0.2.0 EVERY
2272
+ * agent listens on its call's control channel (the MCP host can interject
2273
+ * with `say`, `hangup` or send `dtmf`, and answer `ask_host`), so this flag
2274
+ * now only shapes turn handling for a host-driven call. Use this for an agent that takes a customer's
2275
+ * intent and runs the call like a human secretary, asking the host for any
2276
+ * info it's missing. Mutually exclusive in spirit with puppetMode (which is
2277
+ * the older NoOp "dumb mouth").
2278
+ */
2279
+ readonly hostControlled?: boolean;
2280
+ /** When set, this agent boots each call from a deployed flow's process_schema. */
2281
+ readonly flowRuntime?: FlowRuntimeConfig;
2282
+ /**
2283
+ * Opt a hand-coded (non-flow) agent into the dashboard-driven pipeline: on
2284
+ * each call the SDK fetches this agent's PUBLISHED configuration (a saved
2285
+ * dashboard draft applies only once the owner publishes it) and applies
2286
+ * the operator-selected voice / model / STT over the coded defaults. The
2287
+ * pipeline *mode* (cascade vs realtime) stays pinned to what the code
2288
+ * declares — a stale `mode=realtime` in the dashboard can't flip a
2289
+ * cascade-only worker. Flow agents (`flowRuntime`) get this implicitly and
2290
+ * may additionally switch mode; this flag is the SDK opt-in. The agent id is
2291
+ * read from dispatch metadata (the inbound router injects it from
2292
+ * phone_numbers.agentId), so it's a no-op for calls without one.
2293
+ */
2294
+ readonly pipelineFromConfig?: boolean;
2295
+ /**
2296
+ * Opt this agent into MCP-layer visibility. When true, on register the API
2297
+ * also writes an `agent_config` row keyed by (project_id, name,
2298
+ * environment) so MCP / dashboard / REST can list and inspect this agent
2299
+ * (and, post-step-7, drive call_say / call_send_guidance / etc against
2300
+ * its live calls).
2301
+ *
2302
+ * Defaults to true so newly-registered agents show up in dashboards and
2303
+ * MCP-host listings without opt-in. Pass `false` for autonomous-only
2304
+ * agents that should stay invisible to MCP. See
2305
+ * docs/architecture/contracts-design.md §2b.
2306
+ */
2307
+ readonly mcpExposed?: boolean;
2425
2308
  }
2426
- interface ResolvedAgentTextRuntime {
2427
- /** The composed system prompt (persona + routing), ready for the AgentSession. */
2428
- readonly instructions: string;
2429
- /** The concrete provider LLM that generates replies. */
2430
- readonly llm: llm.LLM;
2431
- /** Which provider/model resolved — surfaced for traceability/logging. */
2432
- readonly model: {
2433
- readonly provider: string;
2434
- readonly model: string;
2435
- };
2436
- /** True when a project BYOK key backed the LLM (vs the platform env key). */
2437
- readonly byok: boolean;
2438
- }
2439
- /** Builds the concrete provider LLM from (provider, model, BYOK creds). Injectable
2440
- * so tests can substitute a fake without loading a provider plugin. */
2441
- type BuildTextLlm = (providerId: string, modelId: string, creds: ProviderCreds | undefined) => Promise<llm.LLM>;
2442
- interface ResolveAgentTextRuntimeOptions {
2443
- /** Override the LLM build (tests). Defaults to the real provider registry. */
2444
- readonly buildLlm?: BuildTextLlm;
2445
- }
2446
- /** A code-first agent's resolved text runtime WITHOUT the built LLM — the cheap,
2447
- * shareable part (instructions + which provider/model + BYOK creds). Cache THIS
2448
- * and build a fresh LLM per session, never the LLM itself (an lk.LLM is a live
2449
- * EventEmitter — sharing one across concurrent sessions cross-fires errors). */
2450
- interface AgentTextPlan {
2451
- readonly instructions: string;
2452
- readonly provider: string;
2453
- readonly model: string;
2454
- readonly creds?: ProviderCreds;
2455
- readonly byok: boolean;
2309
+ interface CallOutcomeSummary {
2310
+ readonly reason: 'completed' | 'handoff' | 'caller_hung_up' | 'agent_hung_up' | 'error';
2311
+ readonly durationMs: number;
2312
+ readonly processCompleted: boolean;
2313
+ readonly fieldsCaptured: number;
2314
+ readonly handoffOccurred: boolean;
2456
2315
  }
2457
2316
  /**
2458
- * Resolve a code-first agent's text PLAN (instructions + provider/model + BYOK),
2459
- * or `null` when it isn't code-first-runnable (no synced prompt). No LLM built —
2460
- * this is the cacheable part. Best-effort on the pipeline: a missing/blank config
2461
- * falls back to the platform default model, mirroring the live path.
2462
- */
2463
- declare function resolveAgentTextPlan(agentId: string, client: AgentTextRuntimeClient): Promise<AgentTextPlan | null>;
2464
- /** Build a fresh provider LLM for a plan. Call once PER SESSION so no two live
2465
- * sessions ever share an lk.LLM instance. */
2466
- declare function buildTextLlm(plan: AgentTextPlan, buildLlm?: BuildTextLlm): Promise<llm.LLM>;
2467
- /**
2468
- * Resolve a code-first agent's text runtime (plan + a freshly-built LLM), or
2469
- * `null` when it isn't runnable. Convenience over resolveAgentTextPlan +
2470
- * buildTextLlm — kept for callers that want a one-shot runtime (and tests).
2317
+ * Identity helper that gives users a typed `defineProcess` entry point with
2318
+ * full inference on `onComplete`'s `data` argument.
2319
+ *
2320
+ * defineProcess({
2321
+ * collect: { name: { type: 'string', required: true } },
2322
+ * onComplete: (data) => { data.name // string },
2323
+ * })
2471
2324
  */
2472
- declare function resolveAgentTextRuntime(agentId: string, client: AgentTextRuntimeClient, opts?: ResolveAgentTextRuntimeOptions): Promise<ResolvedAgentTextRuntime | null>;
2325
+ declare function defineProcess<T extends Record<string, ProcessField>>(def: ProcessDefinition<T>): ProcessDefinition<T>;
2473
2326
 
2474
2327
  interface TransportOptions {
2475
2328
  readonly apiKey: string;
@@ -2512,10 +2365,15 @@ interface RegisterInput {
2512
2365
  readonly processSchema?: ProcessSchemaDTO | null;
2513
2366
  /**
2514
2367
  * A code-first agent's base prompt (its `defineAgent({ prompt })`). Synced to
2515
- * the agent's record so a generic runner can run it over text by id (P2). Omit
2516
- * for flow agents (their behavior lives in the compiled program).
2368
+ * the agent's record (the dashboard shows it). Omit for flow agents (their
2369
+ * behavior lives in the compiled program).
2517
2370
  */
2518
2371
  readonly prompt?: string | null;
2372
+ /**
2373
+ * The text-turn protocol this worker speaks (burn-down G-4): it registered `<name>::text` and answers text turns as
2374
+ * the agent. Omit when it doesn't — the agent is then not text-runnable.
2375
+ */
2376
+ readonly textTurns?: number;
2519
2377
  /**
2520
2378
  * Opt this agent into MCP exposure. When true, the API upserts a matching
2521
2379
  * agent_config row keyed by (project_id, name, environment) so MCP /
@@ -2603,6 +2461,10 @@ declare class AgentsClient {
2603
2461
  * through the engine over text. Returns null on 404 or when the agent has no
2604
2462
  * synced prompt (flow agents, or agents registered before the sync landed).
2605
2463
  */
2464
+ /** A text turn dispatched to this worker (burn-down G-4); null when it's gone or isn't this agent's. */
2465
+ fetchTextTurn(turnId: string, agentId: string): Promise<TextTurn | null>;
2466
+ /** Answer a text turn. False when the API no longer waits for it (answered already, or past its deadline). */
2467
+ replyTextTurn(turnId: string, reply: TextTurnReply): Promise<boolean>;
2606
2468
  getPrompt(agentId: string): Promise<string | null>;
2607
2469
  /**
2608
2470
  * Fetch a deployed agent's PUBLISHED AgentConfig — the pipeline the owner
@@ -2619,8 +2481,8 @@ declare class AgentsClient {
2619
2481
  agents: {
2620
2482
  status: "online" | "offline" | "degraded";
2621
2483
  id: string;
2622
- projectId: string;
2623
2484
  name: string;
2485
+ projectId: string;
2624
2486
  createdAt: string;
2625
2487
  updatedAt: string;
2626
2488
  version: string;
@@ -2658,7 +2520,7 @@ declare class AgentsClient {
2658
2520
  routes?: Record<string, string> | undefined;
2659
2521
  } | undefined;
2660
2522
  memory?: {
2661
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
2523
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
2662
2524
  retentionDays?: number | undefined;
2663
2525
  piiFields?: string[] | undefined;
2664
2526
  } | undefined;
@@ -2674,8 +2536,8 @@ declare class AgentsClient {
2674
2536
  } | undefined;
2675
2537
  } | undefined;
2676
2538
  prompts?: {
2677
- text: string;
2678
2539
  id: string;
2540
+ text: string;
2679
2541
  }[] | undefined;
2680
2542
  triggers?: {
2681
2543
  then: string;
@@ -2685,29 +2547,29 @@ declare class AgentsClient {
2685
2547
  }[] | undefined;
2686
2548
  tools?: {
2687
2549
  name: string;
2550
+ url: string;
2688
2551
  description: string;
2689
2552
  input: Record<string, "string" | "number" | "boolean">;
2690
- url: string;
2691
2553
  method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2692
2554
  auth: "none" | "connection";
2693
2555
  headers?: Record<string, string> | undefined;
2694
2556
  connectionRef?: string | undefined;
2695
2557
  }[] | undefined;
2696
2558
  program?: {
2559
+ v: 1;
2697
2560
  id: string;
2561
+ entry: string[];
2698
2562
  nodes: Record<string, {
2699
- type: "llm" | "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
2563
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
2700
2564
  id: string;
2701
2565
  config: Record<string, unknown>;
2702
2566
  out: {
2703
2567
  to: string;
2568
+ condition?: string | undefined;
2704
2569
  sourceHandle?: string | undefined;
2705
2570
  label?: string | undefined;
2706
- condition?: string | undefined;
2707
2571
  }[];
2708
2572
  }>;
2709
- v: 1;
2710
- entry: string[];
2711
2573
  completionGate: {
2712
2574
  requiredFields: string[];
2713
2575
  };
@@ -3001,8 +2863,8 @@ declare const BrainConnectorConfig: z.ZodObject<{
3001
2863
  baseUrl: string;
3002
2864
  }>>>;
3003
2865
  }, "strip", z.ZodTypeAny, {
3004
- enabled: boolean;
3005
2866
  id: string;
2867
+ enabled: boolean;
3006
2868
  mode: "tunnel" | "direct";
3007
2869
  defaultModel: string | null;
3008
2870
  connectionId: string | null;
@@ -3012,8 +2874,8 @@ declare const BrainConnectorConfig: z.ZodObject<{
3012
2874
  baseUrl: string;
3013
2875
  } | null | undefined;
3014
2876
  }, {
3015
- enabled: boolean;
3016
2877
  id: string;
2878
+ enabled: boolean;
3017
2879
  mode: "tunnel" | "direct";
3018
2880
  defaultModel: string | null;
3019
2881
  connectionId: string | null;
@@ -3025,8 +2887,8 @@ declare const BrainConnectorConfig: z.ZodObject<{
3025
2887
  }>;
3026
2888
  }, "strip", z.ZodTypeAny, {
3027
2889
  connector: {
3028
- enabled: boolean;
3029
2890
  id: string;
2891
+ enabled: boolean;
3030
2892
  mode: "tunnel" | "direct";
3031
2893
  defaultModel: string | null;
3032
2894
  connectionId: string | null;
@@ -3038,8 +2900,8 @@ declare const BrainConnectorConfig: z.ZodObject<{
3038
2900
  };
3039
2901
  }, {
3040
2902
  connector: {
3041
- enabled: boolean;
3042
2903
  id: string;
2904
+ enabled: boolean;
3043
2905
  mode: "tunnel" | "direct";
3044
2906
  defaultModel: string | null;
3045
2907
  connectionId: string | null;
@@ -3165,6 +3027,8 @@ declare function formTools(vl: VoiceLayerClient, options?: FormToolsOptions): Re
3165
3027
  declare class Agent {
3166
3028
  private readonly config;
3167
3029
  private registered;
3030
+ /** Whether this process registered `<name>::text` and takes text turns (said so at registration). */
3031
+ private textTurns;
3168
3032
  private processStatePublisher;
3169
3033
  constructor(config: AgentConfig);
3170
3034
  /**
@@ -3205,41 +3069,6 @@ declare function defineFlowRuntime(opts: {
3205
3069
  readonly version?: string;
3206
3070
  }): Agent;
3207
3071
 
3208
- interface PuppetControlDeps {
3209
- /**
3210
- * LiveKit room name — used as the control-channel key. This is the only
3211
- * identifier the agent reliably has at dispatch time (the API-side
3212
- * project_calls UUID may not even exist yet when the agent boots, since
3213
- * the LK `room_started` webhook fires after dispatch).
3214
- *
3215
- * The API translates UUID → room name before publishing — see
3216
- * apps/api/src/routes/call-control.ts.
3217
- */
3218
- readonly roomName: string;
3219
- readonly session: unknown;
3220
- readonly onHangup: () => Promise<void>;
3221
- readonly onDtmf?: (digits: string) => Promise<void>;
3222
- readonly log?: (msg: string, attrs?: Record<string, unknown>) => void;
3223
- }
3224
- interface PuppetControlHandle {
3225
- /** Stop listening for commands and tear down the Redis subscription. */
3226
- close(): Promise<void>;
3227
- }
3228
- /** @deprecated since 0.2.0 — see startPuppetControl. True if we should run puppet wiring — REDIS_URL must be set. */
3229
- declare function puppetEnvAvailable(): boolean;
3230
- /**
3231
- * @deprecated since 0.2.0 (burn-down G-5): every agent now listens on its call's control channel and confirms each
3232
- * command (runtime/call-control.ts + runtime/host-control.ts). This listener never confirms, so the API refuses its
3233
- * commands. Kept for SDK consumers that call it directly; removed in the next major.
3234
- *
3235
- * Start a puppet-mode control listener for the given call. Returns a handle
3236
- * the caller invokes when the call ends to release the Redis connection.
3237
- *
3238
- * Pubsub semantics: one IORedis subscriber per call. Cheap (Valkey handles
3239
- * thousands of subscriptions per node) and isolates listener teardown from
3240
- * other calls in the same agent process.
3241
- */
3242
- declare function startPuppetControl(deps: PuppetControlDeps): Promise<PuppetControlHandle>;
3243
3072
  /**
3244
3073
  * Build a no-op LLM compatible with @livekit/agents voice.AgentSession.
3245
3074
  * Used in puppet mode to suppress autonomous replies — every STT turn
@@ -3282,6 +3111,134 @@ declare function webhook(config: WebhookConfig): ConnectorInstance<'webhook', We
3282
3111
  /** Subset of ModelConfig the Agent class converts AgentConfig.models into. */
3283
3112
  type PipelineConfig = ModelConfig;
3284
3113
 
3114
+ interface WrapOptions<T> {
3115
+ /** Emit OTel spans around each method call. Default: true. */
3116
+ readonly trace?: boolean;
3117
+ /** Tag spans with `vl.provider.label` for easy filtering. */
3118
+ readonly label?: string;
3119
+ /**
3120
+ * Fallback provider used if the primary throws. Accepts an instance OR a
3121
+ * ProviderFactory (so `deepgram.tts(...)` works directly). The fallback is
3122
+ * resolved lazily on first error.
3123
+ */
3124
+ readonly fallback?: T | ProviderFactory<T>;
3125
+ /**
3126
+ * Methods to instrument. By default the wrapper instruments every method
3127
+ * call. Pass an explicit list to limit overhead on hot paths.
3128
+ */
3129
+ readonly methods?: readonly string[];
3130
+ }
3131
+ /**
3132
+ * Returns either the wrapped instance directly (when called with one) or a
3133
+ * ProviderFactory that produces the wrapped instance (when called with one of
3134
+ * those). This keeps the lazy import story intact: `wrap(deepgram.tts(...))`
3135
+ * is itself a factory.
3136
+ */
3137
+ declare function wrap<T extends object>(target: T | ProviderFactory<T>, options?: WrapOptions<T>): T | ProviderFactory<T>;
3138
+
3139
+ declare const deepgram: {
3140
+ stt(options?: {
3141
+ model?: string;
3142
+ language?: string;
3143
+ apiKey?: string;
3144
+ baseURL?: string;
3145
+ }): ProviderFactory<STTProvider>;
3146
+ tts(options?: {
3147
+ model?: string;
3148
+ apiKey?: string;
3149
+ baseURL?: string;
3150
+ }): ProviderFactory<TTSProvider>;
3151
+ };
3152
+ declare const openai: {
3153
+ llm(options?: {
3154
+ model?: string;
3155
+ apiKey?: string;
3156
+ baseURL?: string;
3157
+ }): ProviderFactory<LLMProvider>;
3158
+ tts(options?: {
3159
+ model?: string;
3160
+ voice?: string;
3161
+ instructions?: string;
3162
+ apiKey?: string;
3163
+ baseURL?: string;
3164
+ }): ProviderFactory<TTSProvider>;
3165
+ realtime(options?: {
3166
+ model?: string;
3167
+ voice?: string;
3168
+ apiKey?: string;
3169
+ baseURL?: string;
3170
+ }): ProviderFactory<RealtimeProvider>;
3171
+ };
3172
+ declare const cartesia: {
3173
+ tts(options?: {
3174
+ voice?: string;
3175
+ model?: string;
3176
+ apiKey?: string;
3177
+ baseURL?: string;
3178
+ }): ProviderFactory<TTSProvider>;
3179
+ stt(options?: {
3180
+ model?: string;
3181
+ language?: string;
3182
+ apiKey?: string;
3183
+ baseURL?: string;
3184
+ }): ProviderFactory<STTProvider>;
3185
+ };
3186
+ declare const elevenlabs: {
3187
+ tts(options?: {
3188
+ voice?: string;
3189
+ model?: string;
3190
+ apiKey?: string;
3191
+ baseURL?: string;
3192
+ }): ProviderFactory<TTSProvider>;
3193
+ };
3194
+ declare const assemblyai: {
3195
+ stt(options?: {
3196
+ language?: string;
3197
+ apiKey?: string;
3198
+ baseURL?: string;
3199
+ }): ProviderFactory<STTProvider>;
3200
+ };
3201
+ declare const google: {
3202
+ llm(options?: {
3203
+ model?: string;
3204
+ apiKey?: string;
3205
+ baseURL?: string;
3206
+ }): ProviderFactory<LLMProvider>;
3207
+ realtime(options?: {
3208
+ model?: string;
3209
+ voice?: string;
3210
+ apiKey?: string;
3211
+ baseURL?: string;
3212
+ }): ProviderFactory<RealtimeProvider>;
3213
+ };
3214
+ declare const silero: {
3215
+ vad(): ProviderFactory<VADProvider>;
3216
+ };
3217
+ declare const livekitTurn: {
3218
+ english(): ProviderFactory<TurnDetectorProvider>;
3219
+ multilingual(): ProviderFactory<TurnDetectorProvider>;
3220
+ };
3221
+ interface ConnectorLLMConfig {
3222
+ /** Upstream model id / alias (defaults to the brain's own default). */
3223
+ readonly model?: string;
3224
+ readonly temperature?: number;
3225
+ /** Spoken instead of dead air when the brain errors before replying. */
3226
+ readonly fallbackText?: string;
3227
+ /** In-process brain. */
3228
+ readonly onQuery?: OnQuery;
3229
+ /** Direct-egress brain — a public OpenAI-compatible base URL. */
3230
+ readonly url?: string;
3231
+ /** API key for the direct-egress endpoint. */
3232
+ readonly apiKey?: string;
3233
+ /** Hostnames that bypass the SSRF IP checks (direct mode). */
3234
+ readonly allowHosts?: readonly string[];
3235
+ /** Advanced: a custom transport (tunnel, etc.). */
3236
+ readonly transport?: BrainTransport;
3237
+ }
3238
+ declare const connector: {
3239
+ llm(config?: ConnectorLLMConfig): ProviderFactory<LLMProvider>;
3240
+ };
3241
+
3285
3242
  /**
3286
3243
  * Turn the persisted `agents.process_schema` (or a freshly-compiled flow) into a
3287
3244
  * ProcessDefinition. The completion gate drives the `required` flags so the
@@ -3321,13 +3278,6 @@ interface ExchangeWorkerTokenInput {
3321
3278
  * attributable to a specific call in the API's audit log. Returns null when
3322
3279
  * the exchange isn't configured or fails — callers fall back to the env key. */
3323
3280
  declare function exchangeWorkerToken(input: ExchangeWorkerTokenInput): Promise<string | null>;
3324
- /** Build a client directly from a PRE-MINTED worker token (W3-lite control-plane
3325
- * mint). The authority (API for text, call-router for voice) minted the token
3326
- * from the projectId it already holds and handed it to the worker — so the
3327
- * worker never self-mints via /v1/internal/worker-token, closing the master-key
3328
- * path where a worker asserts its own projectId. Returns null on a bad token so
3329
- * callers can fall back to the self-mint chain (resolveWorkerClient). */
3330
- declare function workerClientFromToken(token: string): VoiceLayerClient | null;
3331
3281
  /** Build the per-call SDK client under the calling project's identity, with
3332
3282
  * the env-key fallback chain above. `md` is the parsed dispatch metadata. */
3333
3283
  declare function resolveWorkerClient(md: Record<string, unknown>, fetchImpl?: typeof fetch): Promise<VoiceLayerClient | null>;
@@ -3383,4 +3333,4 @@ interface HttpToolSpec {
3383
3333
  */
3384
3334
  declare function httpTool(spec: HttpToolSpec): Record<string, ToolDefinition>;
3385
3335
 
3386
- export { Agent, type AgentConfig, AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AgentTextPlan, type AgentTextRuntimeClient, type AgentTextTranscriptResult, type AppendDtmfEventInput, type AppendTranscriptInput, BaseTool, BrainTransport, type BuildTextLlm, type CallAttributeValue, CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, type ConnectorLLMConfig, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfDirection, EmailClient, type SendEmailInput as EmailSendInput, type EndCallInfo, type EndCallPolicy, type EndCallTrigger, type EndpointingConfig, type EnsureCallByRoomInput, type ExchangeWorkerTokenInput, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InferProcessData, type InterruptionConfig, type LLMProvider, type LiveAgentTextSession, type LiveAgentTurn, type LiveAgentTurnUsage, type MemoryConfig, type MemoryScope, type ModelConfig, OnQuery, Participant, type ParticipantsConfig, type PipelineConfig, PlansClient, type ProcessBackendAck, type ProcessDefinition, type ProcessField, type ProcessFieldType, type PronunciationDict, type ProviderFactory, type PublicFormSessionView, type PuppetControlDeps, type PuppetControlHandle, type ReadinessProbe, type ReadinessReport, type ReadinessResult, type RealtimeProvider, type RegisterInput, type RegisterOptions, type RegisteredAgent, type ResendCredentials, type ResendEmailToolOptions, type ResolveAgentTextRuntimeOptions, type ResolvedAgentTextRuntime, type RunAgentTextTranscriptOptions, type RunLiveAgentTextOptions, type STTProvider, type SecurityConfig, type SentEmail, type ShorthandPrimitive$1 as ShorthandPrimitive, type SpeechConfig, type SyncCallStateInput, type TTSProvider, type ToolDefinition$1 as ToolDefinition, type ToolInputShape$1 as ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, asyncProbe, buildTextLlm, cartesia, collectDefaultMetadata, connector, createClient, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, elevenlabs, envProbe, exchangeWorkerToken, formTools, google, httpTool, livekitTurn, mergeMetadata, openai, processSchemaToAgentParts, processSchemaToDefinition, puppetEnvAvailable, resendEmailTool, resolveAgentTextPlan, resolveAgentTextRuntime, resolveWorkerClient, runAgentTextTranscript, runLiveAgentTextSession, runProbes, silero, startPuppetControl, urlProbe, webhook, workerClientFromToken, wrap };
3336
+ export { Agent, type AgentConfig, AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AppendDtmfEventInput, type AppendTranscriptInput, BaseTool, BrainTransport, type CallAttributeValue, CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, type ConnectorLLMConfig, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfDirection, EmailClient, type SendEmailInput as EmailSendInput, type EndCallInfo, type EndCallPolicy, type EndCallTrigger, type EndpointingConfig, type EnsureCallByRoomInput, type ExchangeWorkerTokenInput, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InferProcessData, type InterruptionConfig, type LLMProvider, type MemoryConfig, type MemoryScope, type ModelConfig, OnQuery, Participant, type ParticipantsConfig, type PipelineConfig, PlansClient, type ProcessBackendAck, type ProcessDefinition, type ProcessField, type ProcessFieldType, type PronunciationDict, type ProviderFactory, type PublicFormSessionView, type ReadinessProbe, type ReadinessReport, type ReadinessResult, type RealtimeProvider, type RegisterInput, type RegisterOptions, type RegisteredAgent, type ResendCredentials, type ResendEmailToolOptions, type STTProvider, type SecurityConfig, type SentEmail, type ShorthandPrimitive$1 as ShorthandPrimitive, type SpeechConfig, type SyncCallStateInput, type TTSProvider, type ToolDefinition$1 as ToolDefinition, type ToolInputShape$1 as ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, asyncProbe, cartesia, collectDefaultMetadata, connector, createClient, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, elevenlabs, envProbe, exchangeWorkerToken, formTools, google, httpTool, livekitTurn, mergeMetadata, openai, processSchemaToAgentParts, processSchemaToDefinition, resendEmailTool, resolveWorkerClient, runProbes, silero, urlProbe, webhook, wrap };