@voicelayer/sdk 0.1.2 → 0.1.4

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,88 +1,8 @@
1
1
  import { z, ZodType } from 'zod';
2
- import { JobContext, voice } from '@livekit/agents';
3
-
4
- declare const brand: unique symbol;
5
- type Brand<T, B> = T & {
6
- readonly [brand]: B;
7
- };
8
- type TenantId = Brand<string, 'TenantId'>;
9
- declare const TenantId: (s: string) => TenantId;
10
- type CallId = Brand<string, 'CallId'>;
11
- declare const CallId: (s: string) => CallId;
12
- type ModuleId = Brand<string, 'ModuleId'>;
13
- declare const ModuleId: (s: string) => ModuleId;
14
-
15
- declare const participantBrand: unique symbol;
16
- type ParticipantId = string & {
17
- readonly [participantBrand]: 'ParticipantId';
18
- };
19
- declare const ParticipantId: (s: string) => ParticipantId;
20
- /**
21
- * How this participant is connected to the room. Determines which transport
22
- * adapter owns the underlying media track.
23
- * - `sip` — PSTN-side via LiveKit SIP (Twilio/Telnyx trunk)
24
- * - `webrtc` — browser/native WebRTC peer
25
- * - `agent` — the AI agent itself (server-published track)
26
- * - `bridge` — incoming non-WebRTC ingress (e.g. an Egress recorder)
27
- */
28
- type ParticipantKind = 'sip' | 'webrtc' | 'agent' | 'bridge';
29
- /**
30
- * One participant in a room. Snapshot semantics: callers read from
31
- * `ParticipantSet`, which owns lifecycle. Fields are readonly because
32
- * mutations must go through the routing primitive to stay observable.
33
- */
34
- interface Participant {
35
- readonly id: ParticipantId;
36
- readonly kind: ParticipantKind;
37
- /** True iff `kind === 'agent'`. Convenience for filtering. */
38
- readonly isAgent: boolean;
39
- /** E.164 when known (always for SIP, never for agent, sometimes for WebRTC). */
40
- readonly phone: string | null;
41
- /** Human-readable label (caller name, agent name). */
42
- readonly displayName: string | null;
43
- /**
44
- * Free-form attributes attached by the dispatcher or runtime. Standardised
45
- * keys the platform reads:
46
- * - `lang` — BCP-47 (e.g. `en-US`, `es-MX`). Used by audio-experience.
47
- * - `role` — e.g. `claimant`, `witness`, `interpreter`. Used by handoff.
48
- * - `tier` — e.g. `vip`, `standard`. Used by audio-experience.
49
- */
50
- readonly attributes: Readonly<Record<string, string>>;
51
- readonly joinedAt: Date;
52
- /** Set when the participant has left. Stays in the set until call end. */
53
- readonly leftAt: Date | null;
54
- }
55
- /**
56
- * Live view of room participants. The agent-worker owns the underlying
57
- * collection; primitives consume it read-only. Snapshot semantics: methods
58
- * return arrays/values valid at call time. The set itself updates in place
59
- * as participants join/leave — re-call to see new state.
60
- */
61
- interface ParticipantSet {
62
- /** All participants ever in the room, including those who have left. */
63
- readonly all: readonly Participant[];
64
- /** Currently-connected, non-agent participants. */
65
- readonly humans: readonly Participant[];
66
- /** Currently-connected agents. Usually exactly one. */
67
- readonly agents: readonly Participant[];
68
- readonly size: number;
69
- get(id: ParticipantId): Participant | undefined;
70
- where(pred: (p: Participant) => boolean): readonly Participant[];
71
- }
72
- /**
73
- * The call container. One Room per call. Replaces the singular call+caller
74
- * model for multi-participant primitives; existing single-caller primitives
75
- * keep reading CallContext.callerId until migrated.
76
- */
77
- interface Room {
78
- readonly id: CallId;
79
- readonly tenantId: TenantId;
80
- readonly moduleId: ModuleId;
81
- readonly startedAt: Date;
82
- readonly participants: ParticipantSet;
83
- /** Dispatch metadata (LK job metadata) — projectId, agentId, etc. */
84
- readonly metadata: Readonly<Record<string, unknown>>;
85
- }
2
+ import { A as AgentContext, P as Participant, C as CallInfo } from './text-session-B8-jhQzv.js';
3
+ export { a as AgentTurnEvent, b as AudioProfile, c as AudioSurface, d as ChannelKind, D as DtmfEvent, e as DtmfHandler, E as EndCallControllerHandle, f as EndCallOutcome, F as FakeSessionAdapter, g as FloorControlConfig, I as InboundOptions, L as LK_AGENT_STATE_MAP, M as MemoryHandle, h as MetricsEvent, N as NON_BUSY_STATES, i as ParticipantId, j as ParticipantKind, k as ParticipantSet, l as ProcessSnapshot, R as RespondOptions, m as Room, n as RouteEntry, o as RoutingRule, p as RoutingSnapshot, q as RunTextSessionOptions, r as RunTextTranscriptOptions, S as SayOptions, s as SendDtmfOptions, t as SessionAdapter, u as SessionCapabilities, v as SessionErrorEvent, w as SessionEvent, x as SessionEventMap, y as SessionFactory, z as SessionFactoryInput, B as SessionOutbound, G as SessionState, H as SpeechResult, J as SpeechTarget, K as StateChangeEvent, T as TextSession, O as TextTranscriptResult, Q as TtsVoiceConfig, U as TurnEvent, V as Unsubscribe, W as UserInputEvent, X as UserTurn, Y as applySpeechTurnHandling, Z as dtmfCodeToDigit, _ as dtmfDigitToCode, $ as duck, a0 as mute, a1 as normalizeState, i as participantId, a2 as passthrough, a3 as runTextSession, a4 as runTextTranscript, a5 as transform } from './text-session-B8-jhQzv.js';
4
+ import { llm } from '@livekit/agents';
5
+ import { Redis } from 'ioredis';
86
6
 
87
7
  declare const AgentEnvironment: z.ZodEnum<["dev", "stg", "prd"]>;
88
8
  type AgentEnvironment = z.infer<typeof AgentEnvironment>;
@@ -226,7 +146,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
226
146
  entry: z.ZodArray<z.ZodString, "many">;
227
147
  nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
228
148
  id: z.ZodString;
229
- type: z.ZodEnum<["say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "route", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
149
+ type: z.ZodEnum<["start", "say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
230
150
  config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
231
151
  out: z.ZodArray<z.ZodObject<{
232
152
  to: z.ZodString;
@@ -245,7 +165,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
245
165
  condition?: string | undefined;
246
166
  }>, "many">;
247
167
  }, "strip", z.ZodTypeAny, {
248
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
168
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
249
169
  id: string;
250
170
  config: Record<string, unknown>;
251
171
  out: {
@@ -255,7 +175,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
255
175
  condition?: string | undefined;
256
176
  }[];
257
177
  }, {
258
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
178
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
259
179
  id: string;
260
180
  config: Record<string, unknown>;
261
181
  out: {
@@ -289,7 +209,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
289
209
  v: 1;
290
210
  id: string;
291
211
  nodes: Record<string, {
292
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
212
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
293
213
  id: string;
294
214
  config: Record<string, unknown>;
295
215
  out: {
@@ -312,7 +232,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
312
232
  v: 1;
313
233
  id: string;
314
234
  nodes: Record<string, {
315
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
235
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
316
236
  id: string;
317
237
  config: Record<string, unknown>;
318
238
  out: {
@@ -384,7 +304,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
384
304
  v: 1;
385
305
  id: string;
386
306
  nodes: Record<string, {
387
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
307
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
388
308
  id: string;
389
309
  config: Record<string, unknown>;
390
310
  out: {
@@ -456,7 +376,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
456
376
  v: 1;
457
377
  id: string;
458
378
  nodes: Record<string, {
459
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
379
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
460
380
  id: string;
461
381
  config: Record<string, unknown>;
462
382
  out: {
@@ -640,7 +560,7 @@ declare const AgentDTO: z.ZodObject<{
640
560
  entry: z.ZodArray<z.ZodString, "many">;
641
561
  nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
642
562
  id: z.ZodString;
643
- type: z.ZodEnum<["say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "route", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
563
+ type: z.ZodEnum<["start", "say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
644
564
  config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
645
565
  out: z.ZodArray<z.ZodObject<{
646
566
  to: z.ZodString;
@@ -659,7 +579,7 @@ declare const AgentDTO: z.ZodObject<{
659
579
  condition?: string | undefined;
660
580
  }>, "many">;
661
581
  }, "strip", z.ZodTypeAny, {
662
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
582
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
663
583
  id: string;
664
584
  config: Record<string, unknown>;
665
585
  out: {
@@ -669,7 +589,7 @@ declare const AgentDTO: z.ZodObject<{
669
589
  condition?: string | undefined;
670
590
  }[];
671
591
  }, {
672
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
592
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
673
593
  id: string;
674
594
  config: Record<string, unknown>;
675
595
  out: {
@@ -703,7 +623,7 @@ declare const AgentDTO: z.ZodObject<{
703
623
  v: 1;
704
624
  id: string;
705
625
  nodes: Record<string, {
706
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
626
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
707
627
  id: string;
708
628
  config: Record<string, unknown>;
709
629
  out: {
@@ -726,7 +646,7 @@ declare const AgentDTO: z.ZodObject<{
726
646
  v: 1;
727
647
  id: string;
728
648
  nodes: Record<string, {
729
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
649
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
730
650
  id: string;
731
651
  config: Record<string, unknown>;
732
652
  out: {
@@ -798,7 +718,7 @@ declare const AgentDTO: z.ZodObject<{
798
718
  v: 1;
799
719
  id: string;
800
720
  nodes: Record<string, {
801
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
721
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
802
722
  id: string;
803
723
  config: Record<string, unknown>;
804
724
  out: {
@@ -870,7 +790,7 @@ declare const AgentDTO: z.ZodObject<{
870
790
  v: 1;
871
791
  id: string;
872
792
  nodes: Record<string, {
873
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
793
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
874
794
  id: string;
875
795
  config: Record<string, unknown>;
876
796
  out: {
@@ -963,7 +883,7 @@ declare const AgentDTO: z.ZodObject<{
963
883
  v: 1;
964
884
  id: string;
965
885
  nodes: Record<string, {
966
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
886
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
967
887
  id: string;
968
888
  config: Record<string, unknown>;
969
889
  out: {
@@ -1054,7 +974,7 @@ declare const AgentDTO: z.ZodObject<{
1054
974
  v: 1;
1055
975
  id: string;
1056
976
  nodes: Record<string, {
1057
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
977
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
1058
978
  id: string;
1059
979
  config: Record<string, unknown>;
1060
980
  out: {
@@ -1101,7 +1021,7 @@ declare const CallPlan: z.ZodObject<{
1101
1021
  displayName?: string | undefined;
1102
1022
  }>;
1103
1023
  draftConfig: z.ZodDefault<z.ZodObject<{
1104
- source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["sdk", "flow"]>>>;
1024
+ source: z.ZodOptional<z.ZodOptional<z.ZodEnum<["sdk", "flow", "playbook", "connector"]>>>;
1105
1025
  name: z.ZodOptional<z.ZodString>;
1106
1026
  triggers: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
1107
1027
  on: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
@@ -1400,6 +1320,7 @@ declare const CallPlan: z.ZodObject<{
1400
1320
  completeWhen?: "all-required-captured" | "all-captured" | undefined;
1401
1321
  }>>>;
1402
1322
  tags: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
1323
+ brainConnectorId: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
1403
1324
  modeLocked: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
1404
1325
  requiredInfo: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
1405
1326
  name: z.ZodString;
@@ -1421,7 +1342,7 @@ declare const CallPlan: z.ZodObject<{
1421
1342
  description?: string | undefined;
1422
1343
  }>, "many">>>;
1423
1344
  }, "strip", z.ZodTypeAny, {
1424
- source?: "sdk" | "flow" | undefined;
1345
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1425
1346
  name?: string | undefined;
1426
1347
  triggers?: Record<string, {
1427
1348
  then: {
@@ -1510,6 +1431,7 @@ declare const CallPlan: z.ZodObject<{
1510
1431
  } | undefined;
1511
1432
  } | undefined;
1512
1433
  tags?: string[] | undefined;
1434
+ brainConnectorId?: string | null | undefined;
1513
1435
  modeLocked?: boolean | undefined;
1514
1436
  requiredInfo?: {
1515
1437
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -1519,7 +1441,7 @@ declare const CallPlan: z.ZodObject<{
1519
1441
  description?: string | undefined;
1520
1442
  }[] | undefined;
1521
1443
  }, {
1522
- source?: "sdk" | "flow" | undefined;
1444
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1523
1445
  name?: string | undefined;
1524
1446
  triggers?: Record<string, {
1525
1447
  then: {
@@ -1608,6 +1530,7 @@ declare const CallPlan: z.ZodObject<{
1608
1530
  completeWhen?: "all-required-captured" | "all-captured" | undefined;
1609
1531
  } | undefined;
1610
1532
  tags?: string[] | undefined;
1533
+ brainConnectorId?: string | null | undefined;
1611
1534
  modeLocked?: boolean | undefined;
1612
1535
  requiredInfo?: {
1613
1536
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -1688,7 +1611,7 @@ declare const CallPlan: z.ZodObject<{
1688
1611
  displayName?: string | undefined;
1689
1612
  };
1690
1613
  draftConfig: {
1691
- source?: "sdk" | "flow" | undefined;
1614
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1692
1615
  name?: string | undefined;
1693
1616
  triggers?: Record<string, {
1694
1617
  then: {
@@ -1777,6 +1700,7 @@ declare const CallPlan: z.ZodObject<{
1777
1700
  } | undefined;
1778
1701
  } | undefined;
1779
1702
  tags?: string[] | undefined;
1703
+ brainConnectorId?: string | null | undefined;
1780
1704
  modeLocked?: boolean | undefined;
1781
1705
  requiredInfo?: {
1782
1706
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -1827,7 +1751,7 @@ declare const CallPlan: z.ZodObject<{
1827
1751
  secondary?: "ask_callee" | "fallback_phrase" | undefined;
1828
1752
  };
1829
1753
  draftConfig?: {
1830
- source?: "sdk" | "flow" | undefined;
1754
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
1831
1755
  name?: string | undefined;
1832
1756
  triggers?: Record<string, {
1833
1757
  then: {
@@ -1916,6 +1840,7 @@ declare const CallPlan: z.ZodObject<{
1916
1840
  completeWhen?: "all-required-captured" | "all-captured" | undefined;
1917
1841
  } | undefined;
1918
1842
  tags?: string[] | undefined;
1843
+ brainConnectorId?: string | null | undefined;
1919
1844
  modeLocked?: boolean | undefined;
1920
1845
  requiredInfo?: {
1921
1846
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -2375,7 +2300,8 @@ declare const AgentConfig$1: z.ZodObject<{
2375
2300
  onlyWhile?: string | undefined;
2376
2301
  }>>>;
2377
2302
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2378
- source: z.ZodOptional<z.ZodEnum<["sdk", "flow"]>>;
2303
+ brainConnectorId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2304
+ source: z.ZodOptional<z.ZodEnum<["sdk", "flow", "playbook", "connector"]>>;
2379
2305
  modeLocked: z.ZodOptional<z.ZodBoolean>;
2380
2306
  requiredInfo: z.ZodDefault<z.ZodArray<z.ZodObject<{
2381
2307
  name: z.ZodString;
@@ -2444,7 +2370,7 @@ declare const AgentConfig$1: z.ZodObject<{
2444
2370
  enum?: string[] | undefined;
2445
2371
  description?: string | undefined;
2446
2372
  }[];
2447
- source?: "sdk" | "flow" | undefined;
2373
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
2448
2374
  triggers?: Record<string, {
2449
2375
  then: {
2450
2376
  kind: "handoff";
@@ -2499,6 +2425,7 @@ declare const AgentConfig$1: z.ZodObject<{
2499
2425
  } | undefined;
2500
2426
  } | undefined;
2501
2427
  tags?: string[] | undefined;
2428
+ brainConnectorId?: string | null | undefined;
2502
2429
  modeLocked?: boolean | undefined;
2503
2430
  }, {
2504
2431
  id: string;
@@ -2533,7 +2460,7 @@ declare const AgentConfig$1: z.ZodObject<{
2533
2460
  normal?: number | undefined;
2534
2461
  } | undefined;
2535
2462
  };
2536
- source?: "sdk" | "flow" | undefined;
2463
+ source?: "playbook" | "sdk" | "flow" | "connector" | undefined;
2537
2464
  triggers?: Record<string, {
2538
2465
  then: {
2539
2466
  kind: "handoff";
@@ -2594,6 +2521,7 @@ declare const AgentConfig$1: z.ZodObject<{
2594
2521
  completeWhen?: "all-required-captured" | "all-captured" | undefined;
2595
2522
  } | undefined;
2596
2523
  tags?: string[] | undefined;
2524
+ brainConnectorId?: string | null | undefined;
2597
2525
  modeLocked?: boolean | undefined;
2598
2526
  requiredInfo?: {
2599
2527
  type: "string" | "number" | "boolean" | "string[]" | "datetime" | "email" | "phone";
@@ -2605,6 +2533,96 @@ declare const AgentConfig$1: z.ZodObject<{
2605
2533
  }>;
2606
2534
  type AgentConfig$1 = z.infer<typeof AgentConfig$1>;
2607
2535
 
2536
+ /** Frames a daemon sends up to the relay. */
2537
+ declare const ConnectorUpFrame: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
2538
+ kind: z.ZodLiteral<"hello">;
2539
+ token: z.ZodString;
2540
+ replicaId: z.ZodString;
2541
+ version: z.ZodString;
2542
+ caps: z.ZodObject<{
2543
+ streaming: z.ZodBoolean;
2544
+ tools: z.ZodBoolean;
2545
+ litellm: z.ZodBoolean;
2546
+ }, "strip", z.ZodTypeAny, {
2547
+ tools: boolean;
2548
+ streaming: boolean;
2549
+ litellm: boolean;
2550
+ }, {
2551
+ tools: boolean;
2552
+ streaming: boolean;
2553
+ litellm: boolean;
2554
+ }>;
2555
+ }, "strip", z.ZodTypeAny, {
2556
+ kind: "hello";
2557
+ version: string;
2558
+ token: string;
2559
+ replicaId: string;
2560
+ caps: {
2561
+ tools: boolean;
2562
+ streaming: boolean;
2563
+ litellm: boolean;
2564
+ };
2565
+ }, {
2566
+ kind: "hello";
2567
+ version: string;
2568
+ token: string;
2569
+ replicaId: string;
2570
+ caps: {
2571
+ tools: boolean;
2572
+ streaming: boolean;
2573
+ litellm: boolean;
2574
+ };
2575
+ }>, z.ZodObject<{
2576
+ kind: z.ZodLiteral<"pong">;
2577
+ ts: z.ZodNumber;
2578
+ }, "strip", z.ZodTypeAny, {
2579
+ kind: "pong";
2580
+ ts: number;
2581
+ }, {
2582
+ kind: "pong";
2583
+ ts: number;
2584
+ }>, z.ZodObject<{
2585
+ kind: z.ZodLiteral<"brain.delta">;
2586
+ streamId: z.ZodString;
2587
+ content: z.ZodString;
2588
+ }, "strip", z.ZodTypeAny, {
2589
+ kind: "brain.delta";
2590
+ content: string;
2591
+ streamId: string;
2592
+ }, {
2593
+ kind: "brain.delta";
2594
+ content: string;
2595
+ streamId: string;
2596
+ }>, z.ZodObject<{
2597
+ kind: z.ZodLiteral<"brain.done">;
2598
+ streamId: z.ZodString;
2599
+ finishReason: z.ZodString;
2600
+ }, "strip", z.ZodTypeAny, {
2601
+ kind: "brain.done";
2602
+ streamId: string;
2603
+ finishReason: string;
2604
+ }, {
2605
+ kind: "brain.done";
2606
+ streamId: string;
2607
+ finishReason: string;
2608
+ }>, z.ZodObject<{
2609
+ kind: z.ZodLiteral<"brain.error">;
2610
+ streamId: z.ZodString;
2611
+ code: z.ZodEnum<["upstream_timeout", "upstream_error", "bad_response", "normalize_failed", "unreachable"]>;
2612
+ message: z.ZodString;
2613
+ }, "strip", z.ZodTypeAny, {
2614
+ message: string;
2615
+ kind: "brain.error";
2616
+ code: "upstream_timeout" | "upstream_error" | "bad_response" | "normalize_failed" | "unreachable";
2617
+ streamId: string;
2618
+ }, {
2619
+ message: string;
2620
+ kind: "brain.error";
2621
+ code: "upstream_timeout" | "upstream_error" | "bad_response" | "normalize_failed" | "unreachable";
2622
+ streamId: string;
2623
+ }>]>;
2624
+ type ConnectorUpFrame = z.infer<typeof ConnectorUpFrame>;
2625
+
2608
2626
  interface TransportOptions {
2609
2627
  readonly apiKey: string;
2610
2628
  readonly baseUrl: string;
@@ -2907,7 +2925,7 @@ declare class AgentsClient {
2907
2925
  v: 1;
2908
2926
  id: string;
2909
2927
  nodes: Record<string, {
2910
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
2928
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
2911
2929
  id: string;
2912
2930
  config: Record<string, unknown>;
2913
2931
  out: {
@@ -2988,6 +3006,23 @@ interface CallSummary {
2988
3006
  readonly status: CallStatus;
2989
3007
  readonly startedAt: string;
2990
3008
  }
3009
+ interface CallUsageReport {
3010
+ readonly durationMs: number;
3011
+ readonly llm: readonly {
3012
+ readonly provider: string;
3013
+ readonly model: string;
3014
+ readonly inputTokens: number;
3015
+ readonly outputTokens: number;
3016
+ }[];
3017
+ readonly tts: readonly {
3018
+ readonly provider: string;
3019
+ readonly chars: number;
3020
+ }[];
3021
+ readonly stt: readonly {
3022
+ readonly provider: string;
3023
+ readonly seconds: number;
3024
+ }[];
3025
+ }
2991
3026
  interface AppendTranscriptInput {
2992
3027
  readonly speaker: 'caller' | 'agent';
2993
3028
  readonly text: string;
@@ -2995,6 +3030,13 @@ interface AppendTranscriptInput {
2995
3030
  readonly endMs: number;
2996
3031
  readonly final?: boolean;
2997
3032
  }
3033
+ type DtmfDirection = 'received' | 'sent';
3034
+ interface AppendDtmfEventInput {
3035
+ readonly direction: DtmfDirection;
3036
+ readonly digit: string;
3037
+ readonly code: number;
3038
+ readonly participantId?: string;
3039
+ }
2998
3040
  interface EnsureCallByRoomInput {
2999
3041
  readonly roomName: string;
3000
3042
  readonly phoneNumberId?: string;
@@ -3042,6 +3084,8 @@ declare class CallsClient {
3042
3084
  ensureByRoom(input: EnsureCallByRoomInput): Promise<CallSummary>;
3043
3085
  syncState(callId: string, input: SyncCallStateInput): Promise<void>;
3044
3086
  appendTranscriptSegment(callId: string, input: AppendTranscriptInput): Promise<void>;
3087
+ reportUsage(callId: string, report: CallUsageReport): Promise<void>;
3088
+ appendDtmfEvent(callId: string, input: AppendDtmfEventInput): Promise<void>;
3045
3089
  /**
3046
3090
  * Append a structured call event. Today the API accepts consultation
3047
3091
  * lifecycle kinds only — see apps/api/src/routes/calls.ts AppendEventBody.
@@ -3161,332 +3205,127 @@ declare const ProviderCredential: z.ZodObject<{
3161
3205
  baseUrl?: string | undefined;
3162
3206
  }>;
3163
3207
  type ProviderCredential = z.infer<typeof ProviderCredential>;
3208
+ declare const BrainConnectorConfig: z.ZodObject<{
3209
+ connector: z.ZodObject<{
3210
+ id: z.ZodString;
3211
+ mode: z.ZodEnum<["tunnel", "direct"]>;
3212
+ connectionId: z.ZodNullable<z.ZodString>;
3213
+ defaultModel: z.ZodNullable<z.ZodString>;
3214
+ normalize: z.ZodEnum<["auto", "on", "off"]>;
3215
+ enabled: z.ZodBoolean;
3216
+ credential: z.ZodOptional<z.ZodNullable<z.ZodObject<{
3217
+ apiKey: z.ZodString;
3218
+ baseUrl: z.ZodString;
3219
+ }, "strip", z.ZodTypeAny, {
3220
+ apiKey: string;
3221
+ baseUrl: string;
3222
+ }, {
3223
+ apiKey: string;
3224
+ baseUrl: string;
3225
+ }>>>;
3226
+ }, "strip", z.ZodTypeAny, {
3227
+ id: string;
3228
+ enabled: boolean;
3229
+ mode: "tunnel" | "direct";
3230
+ defaultModel: string | null;
3231
+ connectionId: string | null;
3232
+ normalize: "on" | "off" | "auto";
3233
+ credential?: {
3234
+ apiKey: string;
3235
+ baseUrl: string;
3236
+ } | null | undefined;
3237
+ }, {
3238
+ id: string;
3239
+ enabled: boolean;
3240
+ mode: "tunnel" | "direct";
3241
+ defaultModel: string | null;
3242
+ connectionId: string | null;
3243
+ normalize: "on" | "off" | "auto";
3244
+ credential?: {
3245
+ apiKey: string;
3246
+ baseUrl: string;
3247
+ } | null | undefined;
3248
+ }>;
3249
+ }, "strip", z.ZodTypeAny, {
3250
+ connector: {
3251
+ id: string;
3252
+ enabled: boolean;
3253
+ mode: "tunnel" | "direct";
3254
+ defaultModel: string | null;
3255
+ connectionId: string | null;
3256
+ normalize: "on" | "off" | "auto";
3257
+ credential?: {
3258
+ apiKey: string;
3259
+ baseUrl: string;
3260
+ } | null | undefined;
3261
+ };
3262
+ }, {
3263
+ connector: {
3264
+ id: string;
3265
+ enabled: boolean;
3266
+ mode: "tunnel" | "direct";
3267
+ defaultModel: string | null;
3268
+ connectionId: string | null;
3269
+ normalize: "on" | "off" | "auto";
3270
+ credential?: {
3271
+ apiKey: string;
3272
+ baseUrl: string;
3273
+ } | null | undefined;
3274
+ };
3275
+ }>;
3276
+ type BrainConnectorConfig = z.infer<typeof BrainConnectorConfig>['connector'];
3164
3277
  declare class ConnectionsClient {
3165
3278
  private readonly transport;
3166
3279
  constructor(transport: Transport);
3167
3280
  resolveProviderCredential(provider: string): Promise<ProviderCredential | null>;
3281
+ resolveBrainConnectorConfig(id: string): Promise<BrainConnectorConfig | null>;
3168
3282
  }
3169
3283
 
3170
- interface DefaultMetadata {
3171
- readonly hostname: string;
3172
- readonly platform: NodeJS.Platform;
3173
- readonly arch: string;
3174
- readonly nodeVersion: string;
3175
- readonly pid: number;
3176
- /** From BUILD_SHA / GIT_COMMIT / VERCEL_GIT_COMMIT_SHA, or null. */
3177
- readonly buildSha: string | null;
3178
- readonly startedAt: string;
3284
+ interface BrainMessage {
3285
+ readonly role: 'system' | 'user' | 'assistant';
3286
+ readonly content: string;
3179
3287
  }
3180
- declare function collectDefaultMetadata(): DefaultMetadata;
3181
- /**
3182
- * Merge default metadata with user-supplied metadata. User values win on
3183
- * conflict; defaults fill in the rest. Returns a plain object suitable for
3184
- * the registry's metadata field.
3185
- */
3186
- declare function mergeMetadata(user: Record<string, unknown> | undefined, defaults: DefaultMetadata): Record<string, unknown>;
3187
-
3188
- interface TtsVoiceConfig {
3189
- readonly provider: 'deepgram' | 'openai' | 'elevenlabs' | 'cartesia';
3190
- readonly model: string;
3191
- readonly voice?: string;
3192
- readonly instructions?: string;
3193
- }
3194
- interface AudioProfile {
3195
- readonly holdMusicUrl: string;
3196
- readonly duckingDb: number;
3197
- readonly dtmfFallbackThreshold: number;
3198
- readonly languageHint: string;
3199
- readonly tts: TtsVoiceConfig;
3200
- }
3201
-
3202
- type RoutingRule = {
3203
- readonly kind: 'passthrough';
3204
- } | {
3205
- readonly kind: 'mute';
3206
- } | {
3207
- readonly kind: 'duck';
3208
- readonly db: number;
3209
- } | {
3210
- readonly kind: 'transform';
3211
- readonly id: string;
3212
- };
3213
- declare const passthrough: () => RoutingRule;
3214
- declare const mute: () => RoutingRule;
3215
- declare const duck: (db: number) => RoutingRule;
3216
- declare const transform: (id: string) => RoutingRule;
3217
- interface RouteEntry {
3218
- readonly source: ParticipantId;
3219
- readonly destination: ParticipantId;
3220
- readonly rule: RoutingRule;
3221
- }
3222
- interface FloorControlConfig {
3223
- /**
3224
- * Minimum quiet window (ms) after the last human utterance before the
3225
- * agent is allowed to speak. Prevents the agent from talking over a
3226
- * human who hasn't yielded the floor. Default 400ms.
3227
- */
3228
- readonly humanQuietWindowMs: number;
3229
- /**
3230
- * If true, the agent may speak immediately at call start before any
3231
- * human has spoken (the greeting). Default true.
3232
- */
3233
- readonly allowAgentGreeting: boolean;
3234
- }
3235
- interface RoutingSnapshot {
3236
- readonly entries: readonly RouteEntry[];
3237
- readonly lastSpokeAt: ReadonlyMap<ParticipantId, number>;
3238
- }
3239
-
3240
- interface CallInfo {
3241
- /** Stable id for the call; comes from dispatch metadata or room name. */
3242
- readonly callId: string;
3243
- /** Caller phone number (E.164) when available, else participant identity. */
3244
- readonly callerId: string;
3245
- /** Phone number that was called (E.164) when available. */
3246
- readonly to: string | null;
3247
- /** Wall-clock when the agent joined. */
3248
- readonly startedAt: Date;
3249
- /** Free-form metadata from the dispatch rule (e.g. projectId, agentId). */
3250
- readonly metadata: Record<string, unknown>;
3251
- }
3252
- interface MemoryHandle {
3253
- get(key: string): Promise<unknown>;
3254
- set(key: string, value: unknown): Promise<void>;
3255
- }
3256
- interface ProcessSnapshot {
3257
- /** Captured field values. */
3258
- readonly data: Record<string, unknown>;
3259
- /** True once the process completion gate has fired. */
3260
- readonly complete: boolean;
3261
- }
3262
- /**
3263
- * Input to ctx.recordEvent — id and timestamp are stamped by the runtime so
3264
- * callers only supply the semantic fields. `source` defaults to 'agent' for
3265
- * tool-call events; pass 'form'/'platform'/'caller' when emitting from a
3266
- * different surface (form-page bridge, webhook handler).
3267
- */
3268
- interface RecordEventInput {
3269
- readonly kind: string;
3270
- readonly source?: 'agent' | 'caller' | 'form' | 'platform';
3271
- readonly data?: Record<string, unknown>;
3272
- }
3273
- /**
3274
- * Targets for participant-scoped speech operations. Either a raw
3275
- * `ParticipantId`, a `Participant` snapshot, or an array of either.
3276
- * `'broadcast'` is the explicit form of the default — everyone in the room.
3277
- */
3278
- type SpeechTarget = ParticipantId | Participant | readonly (ParticipantId | Participant)[] | 'broadcast';
3279
- /**
3280
- * Audio surface — per-participant profiles, routing matrix, and floor
3281
- * control. Exposed on `ctx.audio` so user hooks (e.g. translation in
3282
- * onUtterance) can drive the underlying primitives without importing
3283
- * them directly.
3284
- *
3285
- * In PR#4 these are wired to live LK participant events but the audio
3286
- * fanout itself (per-participant STT, per-listener TTS) is still single-
3287
- * pipeline; users that need actual per-listener delivery should go
3288
- * through `ctx.livekit` for now.
3289
- */
3290
- interface AudioSurface {
3291
- /** Profile (voice/lang/DTMF) for one participant. */
3292
- profileFor(participantId: ParticipantId): AudioProfile;
3293
- /** Update one participant's language hint (also swaps TTS voice). */
3294
- setLanguage(participantId: ParticipantId, languageHint: string): AudioProfile;
3295
- /** Current routing matrix snapshot. */
3296
- routes(): RoutingSnapshot;
3297
- /** Override a single (source, destination) edge in the routing matrix. */
3298
- setRoute(source: ParticipantId, destination: ParticipantId, rule: RoutingRule): void;
3299
- /** Floor-control: true iff no human has spoken inside the quiet window. */
3300
- canAgentSpeak(): boolean;
3288
+ interface BrainCallMetadata {
3289
+ readonly channel: 'voice' | 'text';
3290
+ readonly callId?: string;
3291
+ readonly projectId?: string;
3301
3292
  }
3302
- interface SayOptions {
3303
- /** Restrict the spoken track to one or more participants. Default: broadcast. */
3304
- readonly to?: SpeechTarget;
3293
+ interface BrainRequest {
3294
+ readonly messages: readonly BrainMessage[];
3295
+ /** Upstream model id / alias. Omitted → the brain's own default. */
3296
+ readonly model?: string;
3297
+ readonly temperature?: number;
3298
+ readonly metadata: BrainCallMetadata;
3305
3299
  }
3306
- /**
3307
- * A DTMF keypress received from a participant. `code` is the RFC 4733 event
3308
- * code (0–15: digits 0–9, *=10, #=11, A–D=12–15); `digit` is the canonical
3309
- * single-character representation. `participantId` identifies the sender in
3310
- * the synthesized room (matches Room.participants).
3311
- */
3312
- interface DtmfEvent {
3313
- readonly participantId: ParticipantId;
3314
- readonly code: number;
3315
- readonly digit: string;
3316
- readonly at: Date;
3317
- }
3318
- /** Handler signature for ctx.onDtmf. Returning false unsubscribes. */
3319
- type DtmfHandler = (event: DtmfEvent) => void | Promise<void>;
3320
- interface SendDtmfOptions {
3321
- /** Milliseconds between consecutive digits. Default 100. */
3322
- readonly delayMs?: number;
3300
+ /** One streamed piece of the brain's reply. */
3301
+ interface BrainChunk {
3302
+ readonly content?: string;
3323
3303
  }
3324
- interface RespondOptions {
3325
- readonly instructions?: string;
3326
- readonly to?: SpeechTarget;
3304
+ interface BrainCapabilities {
3305
+ readonly reachable: boolean;
3306
+ readonly streaming: boolean;
3327
3307
  }
3328
- interface AgentContext {
3329
- readonly call: CallInfo;
3330
- readonly memory: MemoryHandle;
3331
- /** Typed connector APIs. Empty record when no connectors are configured. */
3332
- readonly connectors: Readonly<Record<string, unknown>>;
3333
- /** Read-only view of process state. Undefined when no process is configured. */
3334
- readonly process: ProcessSnapshot | undefined;
3335
- /**
3336
- * Record a side-channel lifecycle event into the process actor. Visible
3337
- * to the dashboard React Flow board in real time alongside field
3338
- * captures. Use for "this happened on the call" facts — tool calls,
3339
- * form-page activity, webhook dispatches — that aren't field captures.
3340
- * No-op when the agent has no process configured.
3341
- */
3342
- recordEvent(event: RecordEventInput): void;
3343
- /**
3344
- * Subscribe the agent to a form-page session's WS stream so values typed
3345
- * on the form-page mirror into the process actor (channel-agnostic field
3346
- * capture). Tools call this after a successful sendFormLink; the runtime
3347
- * owns the lifecycle of the underlying WebSocket.
3348
- *
3349
- * Returns a function the tool can call to tear down the subscription
3350
- * early. The subscription also self-closes on form submission or idle.
3351
- *
3352
- * No-op (returns a no-op teardown) when the agent has no process or
3353
- * VOICELAYER_API_URL is unset.
3354
- */
3355
- watchFormSession(token: string): () => void;
3356
- /** Free-form scratch space for hooks to share state within a call. */
3357
- readonly metadata: Record<string, unknown>;
3358
- /**
3359
- * Live view of the call as a participant room. Always populated — for
3360
- * 1:1 calls the room contains one human participant + the agent.
3361
- */
3362
- readonly room: Room;
3363
- /** Per-participant audio profiles + routing matrix + floor control. */
3364
- readonly audio: AudioSurface;
3365
- /**
3366
- * Speak text (via TTS). Returns when the speech is queued.
3367
- * `opts.to` selects a participant subset; default is broadcast. The
3368
- * runtime currently publishes a single shared track; targeted delivery
3369
- * lands with the per-listener track work (PR#4).
3370
- */
3371
- say(text: string, opts?: SayOptions): Promise<void>;
3372
- /** Ask the LLM to produce a reply now (optionally with extra instructions). */
3373
- respond(instructionsOrOpts?: string | RespondOptions): Promise<void>;
3374
- /** Pose a question and resolve with the caller's transcribed answer. */
3375
- ask(question: string): Promise<string>;
3376
- /** Transfer the caller to another phone number. Ends the agent's leg.
3377
- * `mode` overrides the agent-level warm/cold default for this transfer. */
3378
- handoff(to: string, opts?: {
3379
- reason?: string;
3380
- briefing?: string;
3381
- mode?: 'warm' | 'cold';
3382
- }): Promise<void>;
3383
- /**
3384
- * Hang up the call. Optionally records a reason (surfaced to logs and
3385
- * `endCall.onEnd`). Teardown is owned by the SDK end-call controller, which
3386
- * deletes the whole LiveKit room by default so the SIP/PSTN leg drops too —
3387
- * not just the agent participant.
3388
- */
3389
- endCall(opts?: {
3390
- reason?: string;
3391
- }): Promise<void>;
3392
- /**
3393
- * Subscribe to inbound DTMF keypresses from participants. Returns an
3394
- * unsubscribe function. Handlers are called once per digit in the order
3395
- * received. Errors thrown inside a handler are caught and logged so one
3396
- * bad handler can't break others.
3397
- *
3398
- * @example
3399
- * ctx.onDtmf(async (ev) => {
3400
- * if (ev.digit === '0') await ctx.handoff('+18005551212');
3401
- * });
3402
- */
3403
- onDtmf(handler: DtmfHandler): () => void;
3404
- /**
3405
- * Send DTMF digits from the agent's leg. Each character is published as
3406
- * a separate RFC 4733 event; non-DTMF characters (anything not in
3407
- * 0-9*#A-D) are dropped. `opts.delayMs` controls pacing between digits.
3408
- *
3409
- * Useful for IVR navigation post-handoff or during outbound calls.
3410
- */
3411
- sendDtmf(digits: string, opts?: SendDtmfOptions): Promise<void>;
3412
- /** Escape hatch to LiveKit primitives — use when a hook isn't enough. */
3413
- readonly livekit: {
3414
- readonly job: JobContext;
3415
- readonly session: voice.AgentSession;
3416
- };
3417
- }
3418
- /**
3419
- * Map a single character to its RFC 4733 event code, or null when the
3420
- * character isn't a valid DTMF digit. 0–9 → 0–9, * → 10, # → 11, A–D → 12–15.
3421
- */
3422
- declare function dtmfDigitToCode(digit: string): number | null;
3423
- /** Inverse of dtmfDigitToCode. Returns null for codes outside 0..15. */
3424
- declare function dtmfCodeToDigit(code: number): string | null;
3425
-
3426
- /** Primitive shorthand types accepted in tool input. Extendable. */
3427
- type ShorthandPrimitive$1 = 'string' | 'number' | 'boolean';
3428
- /** What the user passes for a tool's input shape. */
3429
- type ToolInputShape$1 = Record<string, ShorthandPrimitive$1> | z.ZodTypeAny;
3430
- interface ToolDefinition$1<I = unknown, R = unknown> {
3431
- readonly description: string;
3432
- readonly input: ToolInputShape$1;
3433
- /** Implementation. Receives parsed input and the agent context. */
3434
- readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
3435
- /** Capability required for Action Guard. Defaults to `tool.<name>`. */
3436
- readonly capability?: string;
3437
- }
3438
-
3439
- interface ResendCredentials {
3440
- /** Resend API key — find under "API Keys" in the Resend dashboard. */
3441
- readonly apiKey: string;
3442
- /**
3443
- * The verified `From:` address — must be a sender on a domain you've
3444
- * verified in Resend (Settings → Domains). Accepts plain
3445
- * "you@yourdomain.com" or "Display Name <you@yourdomain.com>" format.
3446
- */
3447
- readonly from: string;
3448
- }
3449
- interface ResendEmailToolOptions extends ResendCredentials {
3450
- /**
3451
- * Optional subject prefix prepended to every send. Useful when an agent
3452
- * should always brand its emails consistently (e.g. "[Acme Support]").
3453
- * Agents can still override the full subject per call.
3454
- */
3455
- readonly subjectPrefix?: string;
3456
- /**
3457
- * Optional canned signature appended to the plain-text body. Lets agent
3458
- * authors enforce a sign-off without prompting the LLM to remember.
3459
- */
3460
- readonly signature?: string;
3308
+ interface BrainTransport {
3309
+ readonly kind: 'callback' | 'http' | 'tunnel';
3310
+ /** Stream the reply token-by-token (the voice path: first sentence → TTS ASAP). */
3311
+ stream(req: BrainRequest, signal: AbortSignal): AsyncIterable<BrainChunk>;
3312
+ /** Non-streaming convenience (the text path). */
3313
+ complete(req: BrainRequest, signal: AbortSignal): Promise<string>;
3461
3314
  }
3462
- declare function resendEmailTool(options: ResendEmailToolOptions): ToolDefinition$1;
3463
-
3464
- interface FormToolsOptions {
3465
- /**
3466
- * Optional default webhook URL to attach to every form session the agent
3467
- * creates. Customers usually want this set globally per environment.
3468
- */
3469
- readonly defaultWebhookUrl?: string;
3470
- /**
3471
- * Customer-supplied Resend credentials. When set, sendFormLink mints the
3472
- * form session via the platform (so token/state lives on the platform)
3473
- * but sends the email DIRECTLY from the agent worker using the customer's
3474
- * Resend account. The API key never leaves the customer's process; the
3475
- * platform receives a structured log event after the send instead.
3476
- *
3477
- * When omitted, sendFormLink falls back to the platform's email path
3478
- * (POST /v1/forms with `sendEmail` block), which uses VoiceLayer's
3479
- * shared Resend account.
3480
- */
3481
- readonly resend?: ResendCredentials;
3315
+ /** Context handed to a customer's in-process `onQuery` brain. */
3316
+ interface OnQueryContext {
3317
+ /** Full conversation so far (system + prior turns + latest user message). */
3318
+ readonly messages: readonly BrainMessage[];
3319
+ /** Aborts when the caller barges in / the turn is cancelled. */
3320
+ readonly signal: AbortSignal;
3482
3321
  }
3322
+ type OnQueryResult = string | AsyncIterable<string>;
3483
3323
  /**
3484
- * Build the standard set of form tools, bound to a VoiceLayer client.
3485
- *
3486
- * Each entry conforms to ToolDefinition and can be spread directly into an
3487
- * agent's `tools: {}` map (see defineAgent).
3324
+ * Bring-your-own brain, in-process. Receives the latest user utterance (and the
3325
+ * full history via `ctx.messages`) and returns the reply — either a string or an
3326
+ * async-iterable of string pieces for token streaming.
3488
3327
  */
3489
- declare function formTools(vl: VoiceLayerClient, options?: FormToolsOptions): Record<string, ToolDefinition$1>;
3328
+ type OnQuery = (text: string, ctx: OnQueryContext) => OnQueryResult | Promise<OnQueryResult>;
3490
3329
 
3491
3330
  /** Primitive field types accepted in a process definition. */
3492
3331
  type ProcessFieldType = 'string' | 'string[]' | 'number' | 'boolean' | 'datetime' | 'email' | 'phone';
@@ -3717,11 +3556,42 @@ interface OutboundCallConfig {
3717
3556
  */
3718
3557
  readonly voicemailScript?: string;
3719
3558
  }
3559
+ /**
3560
+ * Barge-in tuning. The pipeline allows interruptions by default (LK defaults:
3561
+ * any speech ≥500ms cuts the agent off). These knobs tune that behavior per
3562
+ * agent WITHOUT switching to puppet/hostControlled mode — e.g. a senior-living
3563
+ * help desk wants `minWords: 2` so backchannels ("mm-hm", "okay") don't
3564
+ * truncate the agent mid-sentence, while a fast-paced escalation desk keeps
3565
+ * the zero-word default. Set `enabled: false` to make the agent
3566
+ * non-interruptible (kiosk / broadcast announcements).
3567
+ */
3568
+ interface InterruptionConfig {
3569
+ /** Allow the caller to barge in over agent speech. Default true. */
3570
+ readonly enabled?: boolean;
3571
+ /** Words the caller must say before it counts as an interruption. Default 0
3572
+ * (any speech interrupts). 2–3 filters out backchannels. */
3573
+ readonly minWords?: number;
3574
+ /** Minimum caller speech duration (ms) to count as an interruption. Default 500. */
3575
+ readonly minDuration?: number;
3576
+ }
3577
+ /**
3578
+ * End-of-turn detection tuning: how long the pipeline waits after the caller
3579
+ * stops speaking before treating the turn as finished. Raise `minDelay` for
3580
+ * callers who pause mid-thought (e.g. elderly speakers); lower it for
3581
+ * fast-paced lines.
3582
+ */
3583
+ interface EndpointingConfig {
3584
+ /** Minimum silence (ms) before the caller's turn is considered done. Default 500. */
3585
+ readonly minDelay?: number;
3586
+ /** Hard ceiling (ms) after which the turn ends regardless. Default 3000. */
3587
+ readonly maxDelay?: number;
3588
+ }
3720
3589
  /**
3721
3590
  * Speech polish. `pronunciations` rewrites brand names / acronyms / jargon to
3722
3591
  * a spoken form before TTS (e.g. `{ VoiceLayer: 'Voice Layer', API: 'A P I' }`)
3723
3592
  * via applyPronunciations(). `backgroundAudio` plays ambient room tone under
3724
3593
  * the agent so silence feels less dead (a URL or a named preset).
3594
+ * `interruption` + `endpointing` tune barge-in and turn-taking per agent.
3725
3595
  */
3726
3596
  interface SpeechConfig {
3727
3597
  readonly pronunciations?: Readonly<Record<string, string>>;
@@ -3729,6 +3599,8 @@ interface SpeechConfig {
3729
3599
  readonly url?: string;
3730
3600
  readonly volume?: number;
3731
3601
  };
3602
+ readonly interruption?: InterruptionConfig;
3603
+ readonly endpointing?: EndpointingConfig;
3732
3604
  }
3733
3605
  /** What caused the call to end. Surfaced to `endCall.onEnd` + logs. */
3734
3606
  type EndCallTrigger =
@@ -3738,6 +3610,8 @@ type EndCallTrigger =
3738
3610
  | 'host'
3739
3611
  /** The dead-air backstop fired (`idleHangupMs` of silence while idle). */
3740
3612
  | 'idle'
3613
+ /** The hard per-call ceiling fired (`maxCallDurationMs` elapsed). */
3614
+ | 'max_duration'
3741
3615
  /** The last non-agent participant left the room. */
3742
3616
  | 'participant-left'
3743
3617
  /** A flow/graph run finished and asked to hang up. */
@@ -3791,7 +3665,16 @@ interface EndCallPolicy {
3791
3665
  */
3792
3666
  readonly idleHangupMs?: number | false;
3793
3667
  /**
3794
- * Hook fired the moment a hang-up is decided, just before teardown. Return
3668
+ * Hard call ceiling: hang up once the call has run this many ms from when
3669
+ * the session becomes ready, regardless of activity. Catches runaway calls
3670
+ * that never end naturally (stuck loops, hijacked keys dialing premium
3671
+ * numbers). Fires with trigger `'max_duration'`. Default 3600000 (60
3672
+ * minutes). `false` disables.
3673
+ */
3674
+ readonly maxCallDurationMs?: number | false;
3675
+ /**
3676
+ * Hook fired the moment a hang-up is decided, just before teardown — for
3677
+ * every trigger (tool, host, idle, max_duration, engine-closed, …). Return
3795
3678
  * `false` to take over teardown yourself (the SDK then does nothing — the
3796
3679
  * call will NOT end unless you end it). Returning anything else (or nothing)
3797
3680
  * runs the default teardown. Throwing is caught + logged, then the default
@@ -3799,11 +3682,11 @@ interface EndCallPolicy {
3799
3682
  */
3800
3683
  readonly onEnd?: (ctx: AgentContext, info: EndCallInfo) => boolean | void | Promise<boolean | void>;
3801
3684
  }
3802
- type ShorthandPrimitive = 'string' | 'number' | 'boolean';
3803
- type ToolInputShape = Record<string, ShorthandPrimitive> | z.ZodTypeAny;
3804
- interface ToolDefinition<I = unknown, R = unknown> {
3685
+ type ShorthandPrimitive$1 = 'string' | 'number' | 'boolean';
3686
+ type ToolInputShape$1 = Record<string, ShorthandPrimitive$1> | z.ZodTypeAny;
3687
+ interface ToolDefinition$1<I = unknown, R = unknown> {
3805
3688
  readonly description: string;
3806
- readonly input: ToolInputShape;
3689
+ readonly input: ToolInputShape$1;
3807
3690
  readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
3808
3691
  /**
3809
3692
  * Capability this tool requires. Action Guard hard-blocks the call if not
@@ -3850,6 +3733,9 @@ interface SecurityConfig {
3850
3733
  interface FlowRuntimeConfig {
3851
3734
  /** Prepended to the flow's compiled say/confirm prompt fragments. */
3852
3735
  readonly basePrompt?: string;
3736
+ /** Spoken (verbatim) before hanging up when a flow call's schema cannot be
3737
+ * loaded. A failed flow boot NEVER silently answers as a generic assistant. */
3738
+ readonly bootFailureMessage?: string;
3853
3739
  }
3854
3740
  interface AgentConfig<TProcess extends Record<string, ProcessField> = Record<string, ProcessField>> {
3855
3741
  /** Lowercase, kebab-case identifier. Used for LiveKit dispatch + presence. */
@@ -3877,7 +3763,11 @@ interface AgentConfig<TProcess extends Record<string, ProcessField> = Record<str
3877
3763
  readonly outbound?: OutboundCallConfig;
3878
3764
  readonly speech?: SpeechConfig;
3879
3765
  readonly endCall?: EndCallPolicy;
3880
- readonly tools?: Readonly<Record<string, ToolDefinition>>;
3766
+ readonly tools?: Readonly<Record<string, ToolDefinition$1>>;
3767
+ /** Per-agent registry-tool scoping (stored ToolBinding names, applied at
3768
+ * boot). Non-empty → only these dashboard HTTP tools attach; absent/[] →
3769
+ * every enabled registry tool attaches (the historical default). */
3770
+ readonly toolBindings?: readonly string[];
3881
3771
  readonly security?: SecurityConfig;
3882
3772
  /**
3883
3773
  * Per-call ConsultationPolicy used by the built-in `ask_host` tool. When
@@ -3887,6 +3777,17 @@ interface AgentConfig<TProcess extends Record<string, ProcessField> = Record<str
3887
3777
  * packages/contracts/src/consultation.ts for the schema + semantics.
3888
3778
  */
3889
3779
  readonly consultation?: ConsultationPolicy;
3780
+ /**
3781
+ * Use your existing text agent as the LLM. When set (and `models.llm` is
3782
+ * unset), defineAgent wires the pipeline's LLM slot to this function: the
3783
+ * caller's STT transcript is passed to `onQuery`, and its returned text (or
3784
+ * streamed pieces) is spoken by TTS. The "two lines, keep your stack" path.
3785
+ *
3786
+ * Equivalent to `models: { llm: connector.llm({ onQuery }) }`. For a remote
3787
+ * brain instead, use `connector.llm({ url })` (direct) or a tunnel transport.
3788
+ * See docs/specs/voice-brain-connector/.
3789
+ */
3790
+ readonly onQuery?: OnQuery;
3890
3791
  readonly onUtterance?: (text: string, ctx: AgentContext) => Promise<void> | void;
3891
3792
  readonly onFieldCaptured?: (field: string, value: unknown, ctx: AgentContext) => Promise<void> | void;
3892
3793
  readonly onCallEnd?: (outcome: CallOutcomeSummary, ctx: AgentContext) => Promise<void> | void;
@@ -3964,6 +3865,107 @@ interface CallOutcomeSummary {
3964
3865
  */
3965
3866
  declare function defineProcess<T extends Record<string, ProcessField>>(def: ProcessDefinition<T>): ProcessDefinition<T>;
3966
3867
 
3868
+ interface RunAgentTextTranscriptOptions {
3869
+ /** The agent's system prompt / instructions (its code-defined behavior). */
3870
+ readonly instructions: string;
3871
+ /** The LLM that generates replies — injected so this stays provider-agnostic and
3872
+ * unit-testable (real inference/openai LLM in prod; a scripted fake in tests). */
3873
+ readonly llm: llm.LLM;
3874
+ /** Scripted caller turns, run in order; each produces the agent's reply turn(s). */
3875
+ readonly messages: readonly string[];
3876
+ /** Optional id surfaced on the Agent (for traceability). */
3877
+ readonly agentId?: string;
3878
+ }
3879
+ interface AgentTextTranscriptResult {
3880
+ readonly replies: string[];
3881
+ }
3882
+ /** Drive an instruction-based agent over text and collect its replies. Stateless
3883
+ * batch turn — the request/response shape the text playground's agent path uses. */
3884
+ declare function runAgentTextTranscript(opts: RunAgentTextTranscriptOptions): Promise<AgentTextTranscriptResult>;
3885
+
3886
+ interface DefaultMetadata {
3887
+ readonly hostname: string;
3888
+ readonly platform: NodeJS.Platform;
3889
+ readonly arch: string;
3890
+ readonly nodeVersion: string;
3891
+ readonly pid: number;
3892
+ /** From BUILD_SHA / GIT_COMMIT / VERCEL_GIT_COMMIT_SHA, or null. */
3893
+ readonly buildSha: string | null;
3894
+ readonly startedAt: string;
3895
+ }
3896
+ declare function collectDefaultMetadata(): DefaultMetadata;
3897
+ /**
3898
+ * Merge default metadata with user-supplied metadata. User values win on
3899
+ * conflict; defaults fill in the rest. Returns a plain object suitable for
3900
+ * the registry's metadata field.
3901
+ */
3902
+ declare function mergeMetadata(user: Record<string, unknown> | undefined, defaults: DefaultMetadata): Record<string, unknown>;
3903
+
3904
+ /** Primitive shorthand types accepted in tool input. Extendable. */
3905
+ type ShorthandPrimitive = 'string' | 'number' | 'boolean';
3906
+ /** What the user passes for a tool's input shape. */
3907
+ type ToolInputShape = Record<string, ShorthandPrimitive> | z.ZodTypeAny;
3908
+ interface ToolDefinition<I = unknown, R = unknown> {
3909
+ readonly description: string;
3910
+ readonly input: ToolInputShape;
3911
+ /** Implementation. Receives parsed input and the agent context. */
3912
+ readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
3913
+ /** Capability required for Action Guard. Defaults to `tool.<name>`. */
3914
+ readonly capability?: string;
3915
+ }
3916
+
3917
+ interface ResendCredentials {
3918
+ /** Resend API key — find under "API Keys" in the Resend dashboard. */
3919
+ readonly apiKey: string;
3920
+ /**
3921
+ * The verified `From:` address — must be a sender on a domain you've
3922
+ * verified in Resend (Settings → Domains). Accepts plain
3923
+ * "you@yourdomain.com" or "Display Name <you@yourdomain.com>" format.
3924
+ */
3925
+ readonly from: string;
3926
+ }
3927
+ interface ResendEmailToolOptions extends ResendCredentials {
3928
+ /**
3929
+ * Optional subject prefix prepended to every send. Useful when an agent
3930
+ * should always brand its emails consistently (e.g. "[Acme Support]").
3931
+ * Agents can still override the full subject per call.
3932
+ */
3933
+ readonly subjectPrefix?: string;
3934
+ /**
3935
+ * Optional canned signature appended to the plain-text body. Lets agent
3936
+ * authors enforce a sign-off without prompting the LLM to remember.
3937
+ */
3938
+ readonly signature?: string;
3939
+ }
3940
+ declare function resendEmailTool(options: ResendEmailToolOptions): ToolDefinition;
3941
+
3942
+ interface FormToolsOptions {
3943
+ /**
3944
+ * Optional default webhook URL to attach to every form session the agent
3945
+ * creates. Customers usually want this set globally per environment.
3946
+ */
3947
+ readonly defaultWebhookUrl?: string;
3948
+ /**
3949
+ * Customer-supplied Resend credentials. When set, sendFormLink mints the
3950
+ * form session via the platform (so token/state lives on the platform)
3951
+ * but sends the email DIRECTLY from the agent worker using the customer's
3952
+ * Resend account. The API key never leaves the customer's process; the
3953
+ * platform receives a structured log event after the send instead.
3954
+ *
3955
+ * When omitted, sendFormLink falls back to the platform's email path
3956
+ * (POST /v1/forms with `sendEmail` block), which uses VoiceLayer's
3957
+ * shared Resend account.
3958
+ */
3959
+ readonly resend?: ResendCredentials;
3960
+ }
3961
+ /**
3962
+ * Build the standard set of form tools, bound to a VoiceLayer client.
3963
+ *
3964
+ * Each entry conforms to ToolDefinition and can be spread directly into an
3965
+ * agent's `tools: {}` map (see defineAgent).
3966
+ */
3967
+ declare function formTools(vl: VoiceLayerClient, options?: FormToolsOptions): Record<string, ToolDefinition>;
3968
+
3967
3969
  declare class Agent {
3968
3970
  private readonly config;
3969
3971
  private registered;
@@ -4202,6 +4204,128 @@ declare const livekitTurn: {
4202
4204
  english(): ProviderFactory<TurnDetectorProvider>;
4203
4205
  multilingual(): ProviderFactory<TurnDetectorProvider>;
4204
4206
  };
4207
+ interface ConnectorLLMConfig {
4208
+ /** Upstream model id / alias (defaults to the brain's own default). */
4209
+ readonly model?: string;
4210
+ readonly temperature?: number;
4211
+ /** Spoken instead of dead air when the brain errors before replying. */
4212
+ readonly fallbackText?: string;
4213
+ /** In-process brain. */
4214
+ readonly onQuery?: OnQuery;
4215
+ /** Direct-egress brain — a public OpenAI-compatible base URL. */
4216
+ readonly url?: string;
4217
+ /** API key for the direct-egress endpoint. */
4218
+ readonly apiKey?: string;
4219
+ /** Hostnames that bypass the SSRF IP checks (direct mode). */
4220
+ readonly allowHosts?: readonly string[];
4221
+ /** Advanced: a custom transport (tunnel, etc.). */
4222
+ readonly transport?: BrainTransport;
4223
+ }
4224
+ declare const connector: {
4225
+ llm(config?: ConnectorLLMConfig): ProviderFactory<LLMProvider>;
4226
+ };
4227
+
4228
+ declare function callbackTransport(onQuery: OnQuery): BrainTransport;
4229
+
4230
+ interface ConnectorLLMOptions {
4231
+ readonly model?: string;
4232
+ readonly temperature?: number;
4233
+ readonly callId?: string;
4234
+ readonly projectId?: string;
4235
+ /** Spoken instead of dead air when the brain errors before any reply. */
4236
+ readonly fallbackText?: string;
4237
+ }
4238
+ /**
4239
+ * Build a ConnectorLLM instance for the pipeline's `llm` slot. The returned
4240
+ * object's chat() yields the brain reply and exposes close() for barge-in.
4241
+ */
4242
+ declare function createConnectorLLM(transport: BrainTransport, options?: ConnectorLLMOptions): Promise<unknown>;
4243
+
4244
+ interface ConnectorChatModelOptions {
4245
+ readonly model?: string;
4246
+ }
4247
+ interface ChatModelInput {
4248
+ readonly messages: readonly {
4249
+ readonly role: 'system' | 'user' | 'assistant';
4250
+ readonly content: string;
4251
+ }[];
4252
+ readonly json?: boolean;
4253
+ readonly temperature?: number;
4254
+ readonly model?: string;
4255
+ }
4256
+ declare class ConnectorChatModel {
4257
+ private readonly transport;
4258
+ private readonly options;
4259
+ constructor(transport: BrainTransport, options?: ConnectorChatModelOptions);
4260
+ complete(input: ChatModelInput): Promise<string>;
4261
+ }
4262
+
4263
+ declare class BrainConfigError extends Error {
4264
+ constructor(message: string);
4265
+ }
4266
+ /** Resolve a hostname to a list of IP strings. Injectable for tests. */
4267
+ type HostLookup = (host: string) => Promise<readonly string[]>;
4268
+ interface AssertUrlOptions {
4269
+ /** Hostnames that bypass IP checks (explicit per-connector allowlist). */
4270
+ readonly allowHosts?: readonly string[];
4271
+ /** Override DNS resolution (tests). */
4272
+ readonly lookup?: HostLookup;
4273
+ }
4274
+ /**
4275
+ * Validate a brain URL for direct egress. Throws BrainConfigError on any
4276
+ * violation; returns the parsed URL when safe.
4277
+ */
4278
+ declare function assertPublicHttpsUrl(raw: string, opts?: AssertUrlOptions): Promise<URL>;
4279
+
4280
+ interface BrainPubSub {
4281
+ publish(channel: string, message: string): Promise<void>;
4282
+ /** Subscribe to a channel; returns an unsubscribe handle. */
4283
+ subscribe(channel: string, handler: (raw: string) => void): Promise<() => Promise<void>>;
4284
+ }
4285
+ interface TunnelBrainTransportOptions {
4286
+ readonly connectorId: string;
4287
+ readonly pubsub: BrainPubSub;
4288
+ /** Fail the turn if the daemon sends nothing within this window. Default 20s. */
4289
+ readonly firstChunkTimeoutMs?: number;
4290
+ }
4291
+ declare function tunnelBrainTransport(options: TunnelBrainTransportOptions): BrainTransport;
4292
+
4293
+ declare class RedisBrainPubSub implements BrainPubSub {
4294
+ private readonly sub;
4295
+ private readonly pub;
4296
+ private readonly listeners;
4297
+ constructor(sub: Redis, pub: Redis);
4298
+ publish(channel: string, message: string): Promise<void>;
4299
+ subscribe(channel: string, handler: (raw: string) => void): Promise<() => Promise<void>>;
4300
+ close(): Promise<void>;
4301
+ }
4302
+ declare function buildRedisBrainPubSub(redisUrl: string | undefined): RedisBrainPubSub | null;
4303
+
4304
+ interface SseDelta {
4305
+ readonly content?: string;
4306
+ readonly finishReason?: string;
4307
+ }
4308
+ declare function parseChatCompletionSse(source: AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>): AsyncGenerator<SseDelta>;
4309
+
4310
+ interface BrainEndpointConfig {
4311
+ /** Base URL of the OpenAI-compatible endpoint, e.g. http://localhost:4000/v1. */
4312
+ readonly brainUrl: string;
4313
+ readonly apiKey?: string;
4314
+ readonly defaultModel?: string;
4315
+ /** Injectable for tests; defaults to global fetch. */
4316
+ readonly fetchImpl?: typeof fetch;
4317
+ }
4318
+ interface IncomingBrainRequest {
4319
+ readonly streamId: string;
4320
+ readonly model?: string;
4321
+ readonly temperature?: number;
4322
+ readonly messages: ReadonlyArray<{
4323
+ role: 'system' | 'user' | 'assistant';
4324
+ content: string;
4325
+ }>;
4326
+ }
4327
+ /** Run one brain.request and yield the reply frames. Never throws. */
4328
+ declare function runBrainRequest(req: IncomingBrainRequest, cfg: BrainEndpointConfig, signal: AbortSignal): AsyncGenerator<ConnectorUpFrame>;
4205
4329
 
4206
4330
  /**
4207
4331
  * Turn the persisted `agents.process_schema` (or a freshly-compiled flow) into a
@@ -4217,7 +4341,7 @@ interface CompiledAgentParts {
4217
4341
  readonly triggers?: Record<string, TriggerDefinition>;
4218
4342
  readonly handoff?: HandoffConfig;
4219
4343
  readonly memory?: MemoryConfig;
4220
- readonly tools?: Record<string, ToolDefinition>;
4344
+ readonly tools?: Record<string, ToolDefinition$1>;
4221
4345
  }
4222
4346
  /**
4223
4347
  * Turn a compiled ProcessSchemaDTO into the full set of `defineAgent` parts a
@@ -4239,22 +4363,22 @@ declare function processSchemaToAgentParts(schema: ProcessSchemaDTO, opts?: {
4239
4363
  declare abstract class BaseTool<I = unknown, R = unknown> {
4240
4364
  abstract readonly name: string;
4241
4365
  abstract readonly description: string;
4242
- abstract readonly input: ToolInputShape$1;
4366
+ abstract readonly input: ToolInputShape;
4243
4367
  readonly capability?: string;
4244
4368
  abstract run(input: I, ctx: AgentContext): Promise<R> | R;
4245
4369
  /** The ToolDefinition the runtime consumes. */
4246
- toDefinition(): ToolDefinition$1<I, R>;
4370
+ toDefinition(): ToolDefinition<I, R>;
4247
4371
  /** `{ [name]: definition }` — spread straight into `defineAgent({ tools })`. */
4248
- register(): Record<string, ToolDefinition$1>;
4372
+ register(): Record<string, ToolDefinition>;
4249
4373
  }
4250
4374
  /** Functional equivalent of BaseTool — same output, no class. */
4251
4375
  declare function defineTool<I = unknown, R = unknown>(spec: {
4252
4376
  readonly name: string;
4253
4377
  readonly description: string;
4254
- readonly input: ToolInputShape$1;
4378
+ readonly input: ToolInputShape;
4255
4379
  readonly capability?: string;
4256
4380
  readonly run: (input: I, ctx: AgentContext) => Promise<R> | R;
4257
- }): Record<string, ToolDefinition$1>;
4381
+ }): Record<string, ToolDefinition>;
4258
4382
  interface HttpToolResult {
4259
4383
  readonly ok: boolean;
4260
4384
  readonly status: number;
@@ -4263,7 +4387,7 @@ interface HttpToolResult {
4263
4387
  interface HttpToolSpec {
4264
4388
  readonly name: string;
4265
4389
  readonly description: string;
4266
- readonly input: ToolInputShape$1;
4390
+ readonly input: ToolInputShape;
4267
4391
  /** May contain `{field}` placeholders filled from input (URL-encoded). */
4268
4392
  readonly url: string;
4269
4393
  readonly method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
@@ -4279,7 +4403,7 @@ interface HttpToolSpec {
4279
4403
  * case. Use this for public/no-auth endpoints (e.g. an n8n webhook). Secrets
4280
4404
  * should NOT be inlined here; vault-backed credentials resolve server-side.
4281
4405
  */
4282
- declare function httpTool(spec: HttpToolSpec): Record<string, ToolDefinition$1>;
4406
+ declare function httpTool(spec: HttpToolSpec): Record<string, ToolDefinition>;
4283
4407
 
4284
4408
  interface CreateClientOptions {
4285
4409
  readonly apiKey?: string;
@@ -4302,4 +4426,4 @@ interface VoiceLayerClient {
4302
4426
  }
4303
4427
  declare function createClient(options?: CreateClientOptions): VoiceLayerClient;
4304
4428
 
4305
- export { Agent, type AgentConfig, type AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AppendTranscriptInput, type AudioProfile, type AudioSurface, BaseTool, type CallAttributeValue, type CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfEvent, type DtmfHandler, EmailClient, type SendEmailInput as EmailSendInput, type EndCallInfo, type EndCallPolicy, type EndCallTrigger, type EnsureCallByRoomInput, type FloorControlConfig, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InferProcessData, type LLMProvider, type MemoryConfig, type MemoryHandle, type MemoryScope, type ModelConfig, type Participant, ParticipantId, type ParticipantKind, type ParticipantSet, type ParticipantsConfig, type PipelineConfig, PlansClient, type ProcessBackendAck, type ProcessDefinition, type ProcessField, type ProcessFieldType, type ProcessSnapshot, 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 RespondOptions, type Room, type RouteEntry, type RoutingRule, type RoutingSnapshot, type STTProvider, type SayOptions, type SecurityConfig, type SendDtmfOptions, type SentEmail, type ShorthandPrimitive, type SpeechConfig, type SpeechTarget, type SyncCallStateInput, type TTSProvider, type ToolDefinition, type ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TtsVoiceConfig, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, asyncProbe, cartesia, collectDefaultMetadata, createClient, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, dtmfCodeToDigit, dtmfDigitToCode, duck, elevenlabs, envProbe, formTools, google, httpTool, livekitTurn, mergeMetadata, mute, openai, ParticipantId as participantId, passthrough, processSchemaToAgentParts, processSchemaToDefinition, puppetEnvAvailable, resendEmailTool, runProbes, silero, startPuppetControl, transform, urlProbe, webhook, wrap };
4429
+ export { Agent, type AgentConfig, AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AgentTextTranscriptResult, type AppendDtmfEventInput, type AppendTranscriptInput, BaseTool, type BrainCallMetadata, type BrainCapabilities, type BrainChunk, BrainConfigError, type BrainEndpointConfig, type BrainMessage, type BrainPubSub, type BrainRequest, type BrainTransport, type CallAttributeValue, CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, ConnectorChatModel, type ConnectorChatModelOptions, type ConnectorInstance, type ConnectorLLMConfig, type ConnectorLLMOptions, 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 CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type IncomingBrainRequest, type InferProcessData, type InterruptionConfig, type LLMProvider, type MemoryConfig, type MemoryScope, type ModelConfig, type OnQuery, type OnQueryContext, type OnQueryResult, 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, RedisBrainPubSub, type RegisterInput, type RegisterOptions, type RegisteredAgent, type ResendCredentials, type ResendEmailToolOptions, type RunAgentTextTranscriptOptions, type STTProvider, type SecurityConfig, type SentEmail, type ShorthandPrimitive$1 as ShorthandPrimitive, type SpeechConfig, type SseDelta, type SyncCallStateInput, type TTSProvider, type ToolDefinition$1 as ToolDefinition, type ToolInputShape$1 as ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TunnelBrainTransportOptions, type TurnDetectorProvider, type VADProvider, VoiceLayerAuthError, type VoiceLayerClient, VoiceLayerError, VoiceLayerHttpError, VoiceLayerNetworkError, VoiceLayerValidationError, type WebhookApi, type WebhookConfig, type WrapOptions, applyPronunciations, assemblyai, assertPublicHttpsUrl, asyncProbe, buildRedisBrainPubSub, callbackTransport, cartesia, collectDefaultMetadata, connector, createClient, createConnectorLLM, createNoOpLLM, deepgram, defineAgent, defineFlowRuntime, defineProcess, defineTool, elevenlabs, envProbe, formTools, google, httpTool, livekitTurn, mergeMetadata, openai, parseChatCompletionSse, processSchemaToAgentParts, processSchemaToDefinition, puppetEnvAvailable, resendEmailTool, runAgentTextTranscript, runBrainRequest, runProbes, silero, startPuppetControl, tunnelBrainTransport, urlProbe, webhook, wrap };