@voicelayer/sdk 0.1.11 → 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.
@@ -1,5 +1,254 @@
1
1
  import { JobContext, voice } from '@livekit/agents';
2
2
  import { z } from 'zod';
3
+ import OpenAI from 'openai';
4
+
5
+ type SessionState = 'initializing' | 'idle' | 'listening' | 'thinking' | 'speaking';
6
+ declare const LK_AGENT_STATE_MAP: Readonly<Record<string, SessionState>>;
7
+ declare const NON_BUSY_STATES: ReadonlySet<SessionState>;
8
+ /** Normalize a raw LK state string to SessionState; unknown -> 'thinking' (fail-safe). */
9
+ declare function normalizeState(raw: string): SessionState;
10
+ interface UserInputEvent {
11
+ readonly transcript: string;
12
+ readonly isFinal: boolean;
13
+ readonly speakerId: string | null;
14
+ }
15
+ interface AgentTurnEvent {
16
+ readonly text: string;
17
+ }
18
+ interface DtmfEvent$1 {
19
+ readonly digit: string;
20
+ readonly code: number;
21
+ readonly participantId: string | null;
22
+ }
23
+ interface StateChangeEvent {
24
+ readonly oldState: SessionState | null;
25
+ readonly newState: SessionState | null;
26
+ readonly rawOldState: string | null;
27
+ readonly rawNewState: string | null;
28
+ }
29
+ interface UserStateEvent {
30
+ readonly speaking: boolean;
31
+ readonly at: number;
32
+ }
33
+ interface SessionErrorEvent {
34
+ readonly error: unknown;
35
+ readonly source: 'llm' | 'stt' | 'tts' | 'realtime' | 'unknown';
36
+ readonly fatalTransport: boolean;
37
+ }
38
+ interface MetricsEvent {
39
+ readonly metrics: unknown;
40
+ }
41
+ interface SessionEventMap {
42
+ user_input: UserInputEvent;
43
+ agent_turn: AgentTurnEvent;
44
+ dtmf: DtmfEvent$1;
45
+ state: StateChangeEvent;
46
+ user_state: UserStateEvent;
47
+ error: SessionErrorEvent;
48
+ metrics: MetricsEvent;
49
+ close: void;
50
+ }
51
+ type SessionEvent = keyof SessionEventMap;
52
+ type Unsubscribe = () => void;
53
+ type ChannelKind = 'voice' | 'text';
54
+ interface SessionCapabilities {
55
+ readonly channel: ChannelKind;
56
+ readonly usingRealtime: boolean;
57
+ readonly hasStreamingTranscripts: boolean;
58
+ readonly canBargeIn: boolean;
59
+ readonly canReceiveDtmf: boolean;
60
+ readonly canPublishDtmf: boolean;
61
+ readonly canResolveSpeaker: boolean;
62
+ }
63
+ interface SayOptions$1 {
64
+ readonly allowInterruptions?: boolean;
65
+ readonly to?: string | readonly string[];
66
+ }
67
+ interface SpeechResult {
68
+ readonly interrupted: boolean;
69
+ }
70
+ interface EndCallOutcome {
71
+ readonly torn: 'room' | 'agent' | 'none';
72
+ readonly stranded: boolean;
73
+ }
74
+ interface SessionOutbound {
75
+ /** Speak verbatim. Under usingRealtime the LiveKit adapter routes to
76
+ * generateReply(verbatim) NOT session.say (no TTS in S2S). Resolves after
77
+ * playout (voice) or after the text turn is committed (text). */
78
+ say(text: string, opts?: SayOptions$1): Promise<SpeechResult>;
79
+ /** Queue a verbatim line and return once it is QUEUED, not played out (a host's `say` — burn-down G-5). `interrupt`
80
+ * first cancels what the agent is saying. Realtime routes through the model, as say() does. */
81
+ enqueueSay(text: string, opts?: {
82
+ readonly interrupt?: boolean;
83
+ readonly allowInterruptions?: boolean;
84
+ }): Promise<void>;
85
+ /** Ask the LLM to produce a turn. */
86
+ generateReply(opts?: {
87
+ readonly instructions?: string;
88
+ }): Promise<void>;
89
+ /** Barge-in cancel (puppet interrupt mode). text => no-op. */
90
+ interrupt(): Promise<void>;
91
+ /** Publish outbound DTMF from the agent leg. Throws if !canPublishDtmf. */
92
+ sendDtmf(code: number, digit: string): Promise<void>;
93
+ /** Hang up via the SDK end-call controller (deletes room so the SIP leg drops). */
94
+ endCall(opts?: {
95
+ readonly reason?: string;
96
+ readonly trigger?: string;
97
+ }): Promise<EndCallOutcome>;
98
+ }
99
+ type TurnEvent = {
100
+ readonly kind: 'partial';
101
+ readonly text: string;
102
+ readonly speakerId: string | null;
103
+ } | {
104
+ readonly kind: 'final';
105
+ readonly text: string;
106
+ readonly speakerId: string | null;
107
+ readonly at: Date;
108
+ } | {
109
+ readonly kind: 'dtmf';
110
+ readonly digit: string;
111
+ readonly code: number;
112
+ readonly participantId: string | null;
113
+ readonly at: Date;
114
+ } | {
115
+ readonly kind: 'hangup';
116
+ } | {
117
+ readonly kind: 'timeout';
118
+ };
119
+ interface InboundOptions {
120
+ readonly idleTimeoutMs?: number;
121
+ readonly finalsOnly?: boolean;
122
+ }
123
+ interface SessionAdapter extends SessionOutbound {
124
+ readonly capabilities: SessionCapabilities;
125
+ on<E extends SessionEvent>(event: E, handler: (payload: SessionEventMap[E]) => void): Unsubscribe;
126
+ once<E extends SessionEvent>(event: E, handler: (payload: SessionEventMap[E]) => void): Unsubscribe;
127
+ /** Graph read side. ONE underlying subscription. Mutually exclusive with the
128
+ * flat on('user_input') consumer (THROWS if both active). The iterator's
129
+ * return()/finally MUST unsubscribe. */
130
+ inbound(opts?: InboundOptions): AsyncIterableIterator<TurnEvent>;
131
+ /** Begin the session (was session.start + waitForSessionActivity). The LiveKit
132
+ * impl preserves the activity sequence VERBATIM so a provider/LLM init failure
133
+ * REJECTS rather than producing a silently-dead answered call. */
134
+ start(opts?: {
135
+ readonly agent?: unknown;
136
+ readonly room?: unknown;
137
+ }): Promise<void>;
138
+ readonly state: SessionState;
139
+ /** Resolve when idle/listening, on timeout, or on close. Synchronous fast-path:
140
+ * if already non-busy, resolves 'idle' in the same microtask. */
141
+ waitForIdle(timeoutMs: number): Promise<'idle' | 'timeout' | 'closed'>;
142
+ waitForClose(): Promise<void>;
143
+ /** Escape hatch for genuinely LK-coupled sites. undefined on the text adapter. */
144
+ readonly raw?: {
145
+ readonly job: JobContext;
146
+ readonly session: unknown;
147
+ readonly room: unknown;
148
+ };
149
+ dispose(): void;
150
+ /**
151
+ * Phase 0b-2: span-end teardown of the adapter's own engine-session listeners.
152
+ * Optional — the text adapter has none. Awaited from runCallSpan's finally
153
+ * AFTER close, so the post-close engine-death Error listener survives its
154
+ * window (PR #141). Distinct from `dispose()` (per-call fan-out cleanup).
155
+ */
156
+ [Symbol.asyncDispose]?(): Promise<void>;
157
+ }
158
+ interface EndCallControllerHandle {
159
+ hangUp(opts?: {
160
+ readonly trigger?: string;
161
+ readonly reason?: string;
162
+ }): Promise<void>;
163
+ armIdle(): void;
164
+ cancelIdle(): void;
165
+ noteEngineClosed(): void;
166
+ }
167
+ /**
168
+ * Fold the user's `speech.interruption` / `speech.endpointing` config into an
169
+ * LK turnHandling object. User-set fields are merged over whatever mode
170
+ * defaults (puppet/hostControlled) already put there — explicit agent config
171
+ * wins. No-op when the config is absent, so existing agents keep LK defaults.
172
+ * Lives here (not session-adapter-livekit) so agent.ts can import it without
173
+ * pulling @livekit/agents in at module load.
174
+ */
175
+ declare function applySpeechTurnHandling(turnHandling: Record<string, unknown>, speech?: {
176
+ readonly interruption?: {
177
+ readonly enabled?: boolean;
178
+ readonly minWords?: number;
179
+ readonly minDuration?: number;
180
+ };
181
+ readonly endpointing?: {
182
+ readonly minDelay?: number;
183
+ readonly maxDelay?: number;
184
+ };
185
+ }): Record<string, unknown>;
186
+ interface SessionFactoryInput {
187
+ readonly usingRealtime: boolean;
188
+ readonly graphMode: boolean;
189
+ readonly puppetMode: boolean;
190
+ readonly hostControlled: boolean;
191
+ /** Connector-brain agent: disable preemptive generation (a multi-second remote
192
+ * turn otherwise regenerates on the final transcript and drops the reply). */
193
+ readonly connectorAgentMode?: boolean;
194
+ /**
195
+ * The SecurityPrimitive wraps this session (SecureAgent): preemptive generation is off. It would send the raw,
196
+ * unsealed transcript (PII included) to the model before the input guard runs — and its reply is always discarded,
197
+ * since the guard rewrites the message it was generated from.
198
+ */
199
+ readonly secured?: boolean;
200
+ readonly captureDtmf: boolean;
201
+ readonly pipeline?: {
202
+ readonly stt?: unknown;
203
+ readonly tts?: unknown;
204
+ readonly vad?: unknown;
205
+ readonly llm: unknown;
206
+ };
207
+ readonly turnHandling?: Record<string, unknown>;
208
+ /** Per-agent barge-in + endpointing tuning (AgentConfig `speech`). Merged
209
+ * over mode defaults by applySpeechTurnHandling — explicit config wins. */
210
+ readonly speech?: {
211
+ readonly interruption?: {
212
+ readonly enabled?: boolean;
213
+ readonly minWords?: number;
214
+ readonly minDuration?: number;
215
+ };
216
+ readonly endpointing?: {
217
+ readonly minDelay?: number;
218
+ readonly maxDelay?: number;
219
+ };
220
+ };
221
+ readonly resolveSpeaker?: (speakerId: string | null) => {
222
+ readonly id: string | null;
223
+ readonly label: string;
224
+ };
225
+ readonly classifyEngineClosed?: (err: unknown) => boolean;
226
+ readonly endCallController?: EndCallControllerHandle;
227
+ }
228
+ type SessionFactory = (input: SessionFactoryInput) => Promise<SessionAdapter>;
229
+ interface UserTurn {
230
+ readonly text: string;
231
+ readonly speakerLabel: string;
232
+ readonly speakerId: string | null;
233
+ readonly at: Date;
234
+ }
235
+ interface FakeSessionAdapter extends SessionAdapter {
236
+ emitUserInput(e: UserInputEvent): void;
237
+ emitAgentTurn(text: string): void;
238
+ emitDtmf(digit: string): void;
239
+ /** Drives 'state' with correct oldState/rawOldState AND runs the SAME
240
+ * arm/cancel + idle-release as production. Unknown string => 'thinking'. */
241
+ setState(next: SessionState | string): void;
242
+ emitError(error: unknown, fatalTransport?: boolean): void;
243
+ emitClose(): void;
244
+ readonly spoken: ReadonlyArray<string>;
245
+ readonly generatedReplies: ReadonlyArray<string | undefined>;
246
+ readonly sentDtmf: ReadonlyArray<string>;
247
+ readonly endCalls: ReadonlyArray<{
248
+ readonly reason?: string;
249
+ readonly trigger?: string;
250
+ }>;
251
+ }
3
252
 
4
253
  declare const brand: unique symbol;
5
254
  type Brand<T, B> = T & {
@@ -184,11 +433,11 @@ declare const ProcessSchemaDTO: z.ZodObject<{
184
433
  retentionDays: z.ZodOptional<z.ZodNumber>;
185
434
  piiFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
186
435
  }, "strip", z.ZodTypeAny, {
187
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
436
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
188
437
  retentionDays?: number | undefined;
189
438
  piiFields?: string[] | undefined;
190
439
  }, {
191
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
440
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
192
441
  retentionDays?: number | undefined;
193
442
  piiFields?: string[] | undefined;
194
443
  }>>;
@@ -203,19 +452,19 @@ declare const ProcessSchemaDTO: z.ZodObject<{
203
452
  connectionRef: z.ZodOptional<z.ZodString>;
204
453
  }, "strip", z.ZodTypeAny, {
205
454
  name: string;
455
+ url: string;
206
456
  description: string;
207
457
  input: Record<string, "string" | "number" | "boolean">;
208
- url: string;
209
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
458
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
210
459
  auth: "none" | "connection";
211
460
  headers?: Record<string, string> | undefined;
212
461
  connectionRef?: string | undefined;
213
462
  }, {
214
463
  name: string;
464
+ url: string;
215
465
  description: string;
216
466
  input: Record<string, "string" | "number" | "boolean">;
217
- url: string;
218
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
467
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
219
468
  auth: "none" | "connection";
220
469
  headers?: Record<string, string> | undefined;
221
470
  connectionRef?: string | undefined;
@@ -280,34 +529,34 @@ declare const ProcessSchemaDTO: z.ZodObject<{
280
529
  label: z.ZodOptional<z.ZodString>;
281
530
  }, "strip", z.ZodTypeAny, {
282
531
  to: string;
532
+ condition?: string | undefined;
283
533
  sourceHandle?: string | undefined;
284
534
  label?: string | undefined;
285
- condition?: string | undefined;
286
535
  }, {
287
536
  to: string;
537
+ condition?: string | undefined;
288
538
  sourceHandle?: string | undefined;
289
539
  label?: string | undefined;
290
- condition?: string | undefined;
291
540
  }>, "many">;
292
541
  }, "strip", z.ZodTypeAny, {
293
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
542
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
294
543
  id: string;
295
544
  config: Record<string, unknown>;
296
545
  out: {
297
546
  to: string;
547
+ condition?: string | undefined;
298
548
  sourceHandle?: string | undefined;
299
549
  label?: string | undefined;
300
- condition?: string | undefined;
301
550
  }[];
302
551
  }, {
303
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
552
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
304
553
  id: string;
305
554
  config: Record<string, unknown>;
306
555
  out: {
307
556
  to: string;
557
+ condition?: string | undefined;
308
558
  sourceHandle?: string | undefined;
309
559
  label?: string | undefined;
310
- condition?: string | undefined;
311
560
  }[];
312
561
  }>>;
313
562
  completionGate: z.ZodObject<{
@@ -321,30 +570,33 @@ declare const ProcessSchemaDTO: z.ZodObject<{
321
570
  acyclic: z.ZodBoolean;
322
571
  droppedEdges: z.ZodArray<z.ZodString, "many">;
323
572
  unsupportedNodes: z.ZodArray<z.ZodString, "many">;
573
+ labelOnlyEdges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
324
574
  }, "strip", z.ZodTypeAny, {
325
575
  acyclic: boolean;
326
576
  droppedEdges: string[];
327
577
  unsupportedNodes: string[];
578
+ labelOnlyEdges?: string[] | undefined;
328
579
  }, {
329
580
  acyclic: boolean;
330
581
  droppedEdges: string[];
331
582
  unsupportedNodes: string[];
583
+ labelOnlyEdges?: string[] | undefined;
332
584
  }>>;
333
585
  }, "strip", z.ZodTypeAny, {
334
586
  v: 1;
335
587
  id: string;
588
+ entry: string[];
336
589
  nodes: Record<string, {
337
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
590
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
338
591
  id: string;
339
592
  config: Record<string, unknown>;
340
593
  out: {
341
594
  to: string;
595
+ condition?: string | undefined;
342
596
  sourceHandle?: string | undefined;
343
597
  label?: string | undefined;
344
- condition?: string | undefined;
345
598
  }[];
346
599
  }>;
347
- entry: string[];
348
600
  completionGate: {
349
601
  requiredFields: string[];
350
602
  };
@@ -352,22 +604,23 @@ declare const ProcessSchemaDTO: z.ZodObject<{
352
604
  acyclic: boolean;
353
605
  droppedEdges: string[];
354
606
  unsupportedNodes: string[];
607
+ labelOnlyEdges?: string[] | undefined;
355
608
  } | undefined;
356
609
  }, {
357
610
  v: 1;
358
611
  id: string;
612
+ entry: string[];
359
613
  nodes: Record<string, {
360
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
614
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
361
615
  id: string;
362
616
  config: Record<string, unknown>;
363
617
  out: {
364
618
  to: string;
619
+ condition?: string | undefined;
365
620
  sourceHandle?: string | undefined;
366
621
  label?: string | undefined;
367
- condition?: string | undefined;
368
622
  }[];
369
623
  }>;
370
- entry: string[];
371
624
  completionGate: {
372
625
  requiredFields: string[];
373
626
  };
@@ -375,6 +628,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
375
628
  acyclic: boolean;
376
629
  droppedEdges: string[];
377
630
  unsupportedNodes: string[];
631
+ labelOnlyEdges?: string[] | undefined;
378
632
  } | undefined;
379
633
  }>>;
380
634
  }, "strip", z.ZodTypeAny, {
@@ -401,7 +655,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
401
655
  routes?: Record<string, string> | undefined;
402
656
  } | undefined;
403
657
  memory?: {
404
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
658
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
405
659
  retentionDays?: number | undefined;
406
660
  piiFields?: string[] | undefined;
407
661
  } | undefined;
@@ -428,10 +682,10 @@ declare const ProcessSchemaDTO: z.ZodObject<{
428
682
  }[] | undefined;
429
683
  tools?: {
430
684
  name: string;
685
+ url: string;
431
686
  description: string;
432
687
  input: Record<string, "string" | "number" | "boolean">;
433
- url: string;
434
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
688
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
435
689
  auth: "none" | "connection";
436
690
  headers?: Record<string, string> | undefined;
437
691
  connectionRef?: string | undefined;
@@ -439,18 +693,18 @@ declare const ProcessSchemaDTO: z.ZodObject<{
439
693
  program?: {
440
694
  v: 1;
441
695
  id: string;
696
+ entry: string[];
442
697
  nodes: Record<string, {
443
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
698
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
444
699
  id: string;
445
700
  config: Record<string, unknown>;
446
701
  out: {
447
702
  to: string;
703
+ condition?: string | undefined;
448
704
  sourceHandle?: string | undefined;
449
705
  label?: string | undefined;
450
- condition?: string | undefined;
451
706
  }[];
452
707
  }>;
453
- entry: string[];
454
708
  completionGate: {
455
709
  requiredFields: string[];
456
710
  };
@@ -458,6 +712,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
458
712
  acyclic: boolean;
459
713
  droppedEdges: string[];
460
714
  unsupportedNodes: string[];
715
+ labelOnlyEdges?: string[] | undefined;
461
716
  } | undefined;
462
717
  } | undefined;
463
718
  }, {
@@ -484,7 +739,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
484
739
  routes?: Record<string, string> | undefined;
485
740
  } | undefined;
486
741
  memory?: {
487
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
742
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
488
743
  retentionDays?: number | undefined;
489
744
  piiFields?: string[] | undefined;
490
745
  } | undefined;
@@ -511,10 +766,10 @@ declare const ProcessSchemaDTO: z.ZodObject<{
511
766
  }[] | undefined;
512
767
  tools?: {
513
768
  name: string;
769
+ url: string;
514
770
  description: string;
515
771
  input: Record<string, "string" | "number" | "boolean">;
516
- url: string;
517
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
772
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
518
773
  auth: "none" | "connection";
519
774
  headers?: Record<string, string> | undefined;
520
775
  connectionRef?: string | undefined;
@@ -522,18 +777,18 @@ declare const ProcessSchemaDTO: z.ZodObject<{
522
777
  program?: {
523
778
  v: 1;
524
779
  id: string;
780
+ entry: string[];
525
781
  nodes: Record<string, {
526
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
782
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
527
783
  id: string;
528
784
  config: Record<string, unknown>;
529
785
  out: {
530
786
  to: string;
787
+ condition?: string | undefined;
531
788
  sourceHandle?: string | undefined;
532
789
  label?: string | undefined;
533
- condition?: string | undefined;
534
790
  }[];
535
791
  }>;
536
- entry: string[];
537
792
  completionGate: {
538
793
  requiredFields: string[];
539
794
  };
@@ -541,6 +796,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
541
796
  acyclic: boolean;
542
797
  droppedEdges: string[];
543
798
  unsupportedNodes: string[];
799
+ labelOnlyEdges?: string[] | undefined;
544
800
  } | undefined;
545
801
  } | undefined;
546
802
  }>;
@@ -665,11 +921,11 @@ declare const AgentDTO: z.ZodObject<{
665
921
  retentionDays: z.ZodOptional<z.ZodNumber>;
666
922
  piiFields: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
667
923
  }, "strip", z.ZodTypeAny, {
668
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
924
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
669
925
  retentionDays?: number | undefined;
670
926
  piiFields?: string[] | undefined;
671
927
  }, {
672
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
928
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
673
929
  retentionDays?: number | undefined;
674
930
  piiFields?: string[] | undefined;
675
931
  }>>;
@@ -684,19 +940,19 @@ declare const AgentDTO: z.ZodObject<{
684
940
  connectionRef: z.ZodOptional<z.ZodString>;
685
941
  }, "strip", z.ZodTypeAny, {
686
942
  name: string;
943
+ url: string;
687
944
  description: string;
688
945
  input: Record<string, "string" | "number" | "boolean">;
689
- url: string;
690
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
946
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
691
947
  auth: "none" | "connection";
692
948
  headers?: Record<string, string> | undefined;
693
949
  connectionRef?: string | undefined;
694
950
  }, {
695
951
  name: string;
952
+ url: string;
696
953
  description: string;
697
954
  input: Record<string, "string" | "number" | "boolean">;
698
- url: string;
699
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
955
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
700
956
  auth: "none" | "connection";
701
957
  headers?: Record<string, string> | undefined;
702
958
  connectionRef?: string | undefined;
@@ -761,34 +1017,34 @@ declare const AgentDTO: z.ZodObject<{
761
1017
  label: z.ZodOptional<z.ZodString>;
762
1018
  }, "strip", z.ZodTypeAny, {
763
1019
  to: string;
1020
+ condition?: string | undefined;
764
1021
  sourceHandle?: string | undefined;
765
1022
  label?: string | undefined;
766
- condition?: string | undefined;
767
1023
  }, {
768
1024
  to: string;
1025
+ condition?: string | undefined;
769
1026
  sourceHandle?: string | undefined;
770
1027
  label?: string | undefined;
771
- condition?: string | undefined;
772
1028
  }>, "many">;
773
1029
  }, "strip", z.ZodTypeAny, {
774
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1030
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
775
1031
  id: string;
776
1032
  config: Record<string, unknown>;
777
1033
  out: {
778
1034
  to: string;
1035
+ condition?: string | undefined;
779
1036
  sourceHandle?: string | undefined;
780
1037
  label?: string | undefined;
781
- condition?: string | undefined;
782
1038
  }[];
783
1039
  }, {
784
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1040
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
785
1041
  id: string;
786
1042
  config: Record<string, unknown>;
787
1043
  out: {
788
1044
  to: string;
1045
+ condition?: string | undefined;
789
1046
  sourceHandle?: string | undefined;
790
1047
  label?: string | undefined;
791
- condition?: string | undefined;
792
1048
  }[];
793
1049
  }>>;
794
1050
  completionGate: z.ZodObject<{
@@ -802,30 +1058,33 @@ declare const AgentDTO: z.ZodObject<{
802
1058
  acyclic: z.ZodBoolean;
803
1059
  droppedEdges: z.ZodArray<z.ZodString, "many">;
804
1060
  unsupportedNodes: z.ZodArray<z.ZodString, "many">;
1061
+ labelOnlyEdges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
805
1062
  }, "strip", z.ZodTypeAny, {
806
1063
  acyclic: boolean;
807
1064
  droppedEdges: string[];
808
1065
  unsupportedNodes: string[];
1066
+ labelOnlyEdges?: string[] | undefined;
809
1067
  }, {
810
1068
  acyclic: boolean;
811
1069
  droppedEdges: string[];
812
1070
  unsupportedNodes: string[];
1071
+ labelOnlyEdges?: string[] | undefined;
813
1072
  }>>;
814
1073
  }, "strip", z.ZodTypeAny, {
815
1074
  v: 1;
816
1075
  id: string;
1076
+ entry: string[];
817
1077
  nodes: Record<string, {
818
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1078
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
819
1079
  id: string;
820
1080
  config: Record<string, unknown>;
821
1081
  out: {
822
1082
  to: string;
1083
+ condition?: string | undefined;
823
1084
  sourceHandle?: string | undefined;
824
1085
  label?: string | undefined;
825
- condition?: string | undefined;
826
1086
  }[];
827
1087
  }>;
828
- entry: string[];
829
1088
  completionGate: {
830
1089
  requiredFields: string[];
831
1090
  };
@@ -833,22 +1092,23 @@ declare const AgentDTO: z.ZodObject<{
833
1092
  acyclic: boolean;
834
1093
  droppedEdges: string[];
835
1094
  unsupportedNodes: string[];
1095
+ labelOnlyEdges?: string[] | undefined;
836
1096
  } | undefined;
837
1097
  }, {
838
1098
  v: 1;
839
1099
  id: string;
1100
+ entry: string[];
840
1101
  nodes: Record<string, {
841
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1102
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
842
1103
  id: string;
843
1104
  config: Record<string, unknown>;
844
1105
  out: {
845
1106
  to: string;
1107
+ condition?: string | undefined;
846
1108
  sourceHandle?: string | undefined;
847
1109
  label?: string | undefined;
848
- condition?: string | undefined;
849
1110
  }[];
850
1111
  }>;
851
- entry: string[];
852
1112
  completionGate: {
853
1113
  requiredFields: string[];
854
1114
  };
@@ -856,6 +1116,7 @@ declare const AgentDTO: z.ZodObject<{
856
1116
  acyclic: boolean;
857
1117
  droppedEdges: string[];
858
1118
  unsupportedNodes: string[];
1119
+ labelOnlyEdges?: string[] | undefined;
859
1120
  } | undefined;
860
1121
  }>>;
861
1122
  }, "strip", z.ZodTypeAny, {
@@ -882,7 +1143,7 @@ declare const AgentDTO: z.ZodObject<{
882
1143
  routes?: Record<string, string> | undefined;
883
1144
  } | undefined;
884
1145
  memory?: {
885
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
1146
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
886
1147
  retentionDays?: number | undefined;
887
1148
  piiFields?: string[] | undefined;
888
1149
  } | undefined;
@@ -909,10 +1170,10 @@ declare const AgentDTO: z.ZodObject<{
909
1170
  }[] | undefined;
910
1171
  tools?: {
911
1172
  name: string;
1173
+ url: string;
912
1174
  description: string;
913
1175
  input: Record<string, "string" | "number" | "boolean">;
914
- url: string;
915
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
1176
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
916
1177
  auth: "none" | "connection";
917
1178
  headers?: Record<string, string> | undefined;
918
1179
  connectionRef?: string | undefined;
@@ -920,18 +1181,18 @@ declare const AgentDTO: z.ZodObject<{
920
1181
  program?: {
921
1182
  v: 1;
922
1183
  id: string;
1184
+ entry: string[];
923
1185
  nodes: Record<string, {
924
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1186
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
925
1187
  id: string;
926
1188
  config: Record<string, unknown>;
927
1189
  out: {
928
1190
  to: string;
1191
+ condition?: string | undefined;
929
1192
  sourceHandle?: string | undefined;
930
1193
  label?: string | undefined;
931
- condition?: string | undefined;
932
1194
  }[];
933
1195
  }>;
934
- entry: string[];
935
1196
  completionGate: {
936
1197
  requiredFields: string[];
937
1198
  };
@@ -939,6 +1200,7 @@ declare const AgentDTO: z.ZodObject<{
939
1200
  acyclic: boolean;
940
1201
  droppedEdges: string[];
941
1202
  unsupportedNodes: string[];
1203
+ labelOnlyEdges?: string[] | undefined;
942
1204
  } | undefined;
943
1205
  } | undefined;
944
1206
  }, {
@@ -965,7 +1227,7 @@ declare const AgentDTO: z.ZodObject<{
965
1227
  routes?: Record<string, string> | undefined;
966
1228
  } | undefined;
967
1229
  memory?: {
968
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
1230
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
969
1231
  retentionDays?: number | undefined;
970
1232
  piiFields?: string[] | undefined;
971
1233
  } | undefined;
@@ -992,10 +1254,10 @@ declare const AgentDTO: z.ZodObject<{
992
1254
  }[] | undefined;
993
1255
  tools?: {
994
1256
  name: string;
1257
+ url: string;
995
1258
  description: string;
996
1259
  input: Record<string, "string" | "number" | "boolean">;
997
- url: string;
998
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
1260
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
999
1261
  auth: "none" | "connection";
1000
1262
  headers?: Record<string, string> | undefined;
1001
1263
  connectionRef?: string | undefined;
@@ -1003,18 +1265,18 @@ declare const AgentDTO: z.ZodObject<{
1003
1265
  program?: {
1004
1266
  v: 1;
1005
1267
  id: string;
1268
+ entry: string[];
1006
1269
  nodes: Record<string, {
1007
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1270
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1008
1271
  id: string;
1009
1272
  config: Record<string, unknown>;
1010
1273
  out: {
1011
1274
  to: string;
1275
+ condition?: string | undefined;
1012
1276
  sourceHandle?: string | undefined;
1013
1277
  label?: string | undefined;
1014
- condition?: string | undefined;
1015
1278
  }[];
1016
1279
  }>;
1017
- entry: string[];
1018
1280
  completionGate: {
1019
1281
  requiredFields: string[];
1020
1282
  };
@@ -1022,16 +1284,18 @@ declare const AgentDTO: z.ZodObject<{
1022
1284
  acyclic: boolean;
1023
1285
  droppedEdges: string[];
1024
1286
  unsupportedNodes: string[];
1287
+ labelOnlyEdges?: string[] | undefined;
1025
1288
  } | undefined;
1026
1289
  } | undefined;
1027
1290
  }>>>;
1291
+ textRunnable: z.ZodOptional<z.ZodBoolean>;
1028
1292
  createdAt: z.ZodString;
1029
1293
  updatedAt: z.ZodString;
1030
1294
  }, "strip", z.ZodTypeAny, {
1031
1295
  status: "online" | "offline" | "degraded";
1032
1296
  id: string;
1033
- projectId: string;
1034
1297
  name: string;
1298
+ projectId: string;
1035
1299
  createdAt: string;
1036
1300
  updatedAt: string;
1037
1301
  version: string;
@@ -1069,7 +1333,7 @@ declare const AgentDTO: z.ZodObject<{
1069
1333
  routes?: Record<string, string> | undefined;
1070
1334
  } | undefined;
1071
1335
  memory?: {
1072
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
1336
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
1073
1337
  retentionDays?: number | undefined;
1074
1338
  piiFields?: string[] | undefined;
1075
1339
  } | undefined;
@@ -1096,10 +1360,10 @@ declare const AgentDTO: z.ZodObject<{
1096
1360
  }[] | undefined;
1097
1361
  tools?: {
1098
1362
  name: string;
1363
+ url: string;
1099
1364
  description: string;
1100
1365
  input: Record<string, "string" | "number" | "boolean">;
1101
- url: string;
1102
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
1366
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1103
1367
  auth: "none" | "connection";
1104
1368
  headers?: Record<string, string> | undefined;
1105
1369
  connectionRef?: string | undefined;
@@ -1107,18 +1371,18 @@ declare const AgentDTO: z.ZodObject<{
1107
1371
  program?: {
1108
1372
  v: 1;
1109
1373
  id: string;
1374
+ entry: string[];
1110
1375
  nodes: Record<string, {
1111
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1376
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1112
1377
  id: string;
1113
1378
  config: Record<string, unknown>;
1114
1379
  out: {
1115
1380
  to: string;
1381
+ condition?: string | undefined;
1116
1382
  sourceHandle?: string | undefined;
1117
1383
  label?: string | undefined;
1118
- condition?: string | undefined;
1119
1384
  }[];
1120
1385
  }>;
1121
- entry: string[];
1122
1386
  completionGate: {
1123
1387
  requiredFields: string[];
1124
1388
  };
@@ -1126,14 +1390,16 @@ declare const AgentDTO: z.ZodObject<{
1126
1390
  acyclic: boolean;
1127
1391
  droppedEdges: string[];
1128
1392
  unsupportedNodes: string[];
1393
+ labelOnlyEdges?: string[] | undefined;
1129
1394
  } | undefined;
1130
1395
  } | undefined;
1131
1396
  } | null | undefined;
1397
+ textRunnable?: boolean | undefined;
1132
1398
  }, {
1133
1399
  status: "online" | "offline" | "degraded";
1134
1400
  id: string;
1135
- projectId: string;
1136
1401
  name: string;
1402
+ projectId: string;
1137
1403
  createdAt: string;
1138
1404
  updatedAt: string;
1139
1405
  version: string;
@@ -1171,7 +1437,7 @@ declare const AgentDTO: z.ZodObject<{
1171
1437
  routes?: Record<string, string> | undefined;
1172
1438
  } | undefined;
1173
1439
  memory?: {
1174
- scope?: "caller" | "call" | "account" | "participant" | "platform" | undefined;
1440
+ scope?: "call" | "caller" | "participant" | "account" | "platform" | undefined;
1175
1441
  retentionDays?: number | undefined;
1176
1442
  piiFields?: string[] | undefined;
1177
1443
  } | undefined;
@@ -1198,10 +1464,10 @@ declare const AgentDTO: z.ZodObject<{
1198
1464
  }[] | undefined;
1199
1465
  tools?: {
1200
1466
  name: string;
1467
+ url: string;
1201
1468
  description: string;
1202
1469
  input: Record<string, "string" | "number" | "boolean">;
1203
- url: string;
1204
- method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE";
1470
+ method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
1205
1471
  auth: "none" | "connection";
1206
1472
  headers?: Record<string, string> | undefined;
1207
1473
  connectionRef?: string | undefined;
@@ -1209,18 +1475,18 @@ declare const AgentDTO: z.ZodObject<{
1209
1475
  program?: {
1210
1476
  v: 1;
1211
1477
  id: string;
1478
+ entry: string[];
1212
1479
  nodes: Record<string, {
1213
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1480
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1214
1481
  id: string;
1215
1482
  config: Record<string, unknown>;
1216
1483
  out: {
1217
1484
  to: string;
1485
+ condition?: string | undefined;
1218
1486
  sourceHandle?: string | undefined;
1219
1487
  label?: string | undefined;
1220
- condition?: string | undefined;
1221
1488
  }[];
1222
1489
  }>;
1223
- entry: string[];
1224
1490
  completionGate: {
1225
1491
  requiredFields: string[];
1226
1492
  };
@@ -1228,9 +1494,11 @@ declare const AgentDTO: z.ZodObject<{
1228
1494
  acyclic: boolean;
1229
1495
  droppedEdges: string[];
1230
1496
  unsupportedNodes: string[];
1497
+ labelOnlyEdges?: string[] | undefined;
1231
1498
  } | undefined;
1232
1499
  } | undefined;
1233
1500
  } | null | undefined;
1501
+ textRunnable?: boolean | undefined;
1234
1502
  }>;
1235
1503
  type AgentDTO = z.infer<typeof AgentDTO>;
1236
1504
 
@@ -1249,34 +1517,34 @@ declare const FlowProgram: z.ZodObject<{
1249
1517
  label: z.ZodOptional<z.ZodString>;
1250
1518
  }, "strip", z.ZodTypeAny, {
1251
1519
  to: string;
1520
+ condition?: string | undefined;
1252
1521
  sourceHandle?: string | undefined;
1253
1522
  label?: string | undefined;
1254
- condition?: string | undefined;
1255
1523
  }, {
1256
1524
  to: string;
1525
+ condition?: string | undefined;
1257
1526
  sourceHandle?: string | undefined;
1258
1527
  label?: string | undefined;
1259
- condition?: string | undefined;
1260
1528
  }>, "many">;
1261
1529
  }, "strip", z.ZodTypeAny, {
1262
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1530
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1263
1531
  id: string;
1264
1532
  config: Record<string, unknown>;
1265
1533
  out: {
1266
1534
  to: string;
1535
+ condition?: string | undefined;
1267
1536
  sourceHandle?: string | undefined;
1268
1537
  label?: string | undefined;
1269
- condition?: string | undefined;
1270
1538
  }[];
1271
1539
  }, {
1272
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1540
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1273
1541
  id: string;
1274
1542
  config: Record<string, unknown>;
1275
1543
  out: {
1276
1544
  to: string;
1545
+ condition?: string | undefined;
1277
1546
  sourceHandle?: string | undefined;
1278
1547
  label?: string | undefined;
1279
- condition?: string | undefined;
1280
1548
  }[];
1281
1549
  }>>;
1282
1550
  completionGate: z.ZodObject<{
@@ -1290,30 +1558,33 @@ declare const FlowProgram: z.ZodObject<{
1290
1558
  acyclic: z.ZodBoolean;
1291
1559
  droppedEdges: z.ZodArray<z.ZodString, "many">;
1292
1560
  unsupportedNodes: z.ZodArray<z.ZodString, "many">;
1561
+ labelOnlyEdges: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1293
1562
  }, "strip", z.ZodTypeAny, {
1294
1563
  acyclic: boolean;
1295
1564
  droppedEdges: string[];
1296
1565
  unsupportedNodes: string[];
1566
+ labelOnlyEdges?: string[] | undefined;
1297
1567
  }, {
1298
1568
  acyclic: boolean;
1299
1569
  droppedEdges: string[];
1300
1570
  unsupportedNodes: string[];
1571
+ labelOnlyEdges?: string[] | undefined;
1301
1572
  }>>;
1302
1573
  }, "strip", z.ZodTypeAny, {
1303
1574
  v: 1;
1304
1575
  id: string;
1576
+ entry: string[];
1305
1577
  nodes: Record<string, {
1306
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1578
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1307
1579
  id: string;
1308
1580
  config: Record<string, unknown>;
1309
1581
  out: {
1310
1582
  to: string;
1583
+ condition?: string | undefined;
1311
1584
  sourceHandle?: string | undefined;
1312
1585
  label?: string | undefined;
1313
- condition?: string | undefined;
1314
1586
  }[];
1315
1587
  }>;
1316
- entry: string[];
1317
1588
  completionGate: {
1318
1589
  requiredFields: string[];
1319
1590
  };
@@ -1321,22 +1592,23 @@ declare const FlowProgram: z.ZodObject<{
1321
1592
  acyclic: boolean;
1322
1593
  droppedEdges: string[];
1323
1594
  unsupportedNodes: string[];
1595
+ labelOnlyEdges?: string[] | undefined;
1324
1596
  } | undefined;
1325
1597
  }, {
1326
1598
  v: 1;
1327
1599
  id: string;
1600
+ entry: string[];
1328
1601
  nodes: Record<string, {
1329
- type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1602
+ type: "code" | "set" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "menu" | "subflow" | "llm" | "rag" | "memory" | "speech" | "classify" | "router" | "note";
1330
1603
  id: string;
1331
1604
  config: Record<string, unknown>;
1332
1605
  out: {
1333
1606
  to: string;
1607
+ condition?: string | undefined;
1334
1608
  sourceHandle?: string | undefined;
1335
1609
  label?: string | undefined;
1336
- condition?: string | undefined;
1337
1610
  }[];
1338
1611
  }>;
1339
- entry: string[];
1340
1612
  completionGate: {
1341
1613
  requiredFields: string[];
1342
1614
  };
@@ -1344,231 +1616,11 @@ declare const FlowProgram: z.ZodObject<{
1344
1616
  acyclic: boolean;
1345
1617
  droppedEdges: string[];
1346
1618
  unsupportedNodes: string[];
1619
+ labelOnlyEdges?: string[] | undefined;
1347
1620
  } | undefined;
1348
1621
  }>;
1349
1622
  type FlowProgram = z.infer<typeof FlowProgram>;
1350
1623
 
1351
- type SessionState = 'initializing' | 'idle' | 'listening' | 'thinking' | 'speaking';
1352
- declare const LK_AGENT_STATE_MAP: Readonly<Record<string, SessionState>>;
1353
- declare const NON_BUSY_STATES: ReadonlySet<SessionState>;
1354
- /** Normalize a raw LK state string to SessionState; unknown -> 'thinking' (fail-safe). */
1355
- declare function normalizeState(raw: string): SessionState;
1356
- interface UserInputEvent {
1357
- readonly transcript: string;
1358
- readonly isFinal: boolean;
1359
- readonly speakerId: string | null;
1360
- }
1361
- interface AgentTurnEvent {
1362
- readonly text: string;
1363
- }
1364
- interface DtmfEvent$1 {
1365
- readonly digit: string;
1366
- readonly code: number;
1367
- readonly participantId: string | null;
1368
- }
1369
- interface StateChangeEvent {
1370
- readonly oldState: SessionState | null;
1371
- readonly newState: SessionState | null;
1372
- readonly rawOldState: string | null;
1373
- readonly rawNewState: string | null;
1374
- }
1375
- interface SessionErrorEvent {
1376
- readonly error: unknown;
1377
- readonly source: 'llm' | 'stt' | 'tts' | 'realtime' | 'unknown';
1378
- readonly fatalTransport: boolean;
1379
- }
1380
- interface MetricsEvent {
1381
- readonly metrics: unknown;
1382
- }
1383
- interface SessionEventMap {
1384
- user_input: UserInputEvent;
1385
- agent_turn: AgentTurnEvent;
1386
- dtmf: DtmfEvent$1;
1387
- state: StateChangeEvent;
1388
- error: SessionErrorEvent;
1389
- metrics: MetricsEvent;
1390
- close: void;
1391
- }
1392
- type SessionEvent = keyof SessionEventMap;
1393
- type Unsubscribe = () => void;
1394
- type ChannelKind = 'voice' | 'text';
1395
- interface SessionCapabilities {
1396
- readonly channel: ChannelKind;
1397
- readonly usingRealtime: boolean;
1398
- readonly hasStreamingTranscripts: boolean;
1399
- readonly canBargeIn: boolean;
1400
- readonly canReceiveDtmf: boolean;
1401
- readonly canPublishDtmf: boolean;
1402
- readonly canResolveSpeaker: boolean;
1403
- }
1404
- interface SayOptions$1 {
1405
- readonly allowInterruptions?: boolean;
1406
- readonly to?: string | readonly string[];
1407
- }
1408
- interface SpeechResult {
1409
- readonly interrupted: boolean;
1410
- }
1411
- interface EndCallOutcome {
1412
- readonly torn: 'room' | 'agent' | 'none';
1413
- readonly stranded: boolean;
1414
- }
1415
- interface SessionOutbound {
1416
- /** Speak verbatim. Under usingRealtime the LiveKit adapter routes to
1417
- * generateReply(verbatim) NOT session.say (no TTS in S2S). Resolves after
1418
- * playout (voice) or after the text turn is committed (text). */
1419
- say(text: string, opts?: SayOptions$1): Promise<SpeechResult>;
1420
- /** Ask the LLM to produce a turn. */
1421
- generateReply(opts?: {
1422
- readonly instructions?: string;
1423
- }): Promise<void>;
1424
- /** Barge-in cancel (puppet interrupt mode). text => no-op. */
1425
- interrupt(): Promise<void>;
1426
- /** Publish outbound DTMF from the agent leg. Throws if !canPublishDtmf. */
1427
- sendDtmf(code: number, digit: string): Promise<void>;
1428
- /** Hang up via the SDK end-call controller (deletes room so the SIP leg drops). */
1429
- endCall(opts?: {
1430
- readonly reason?: string;
1431
- readonly trigger?: string;
1432
- }): Promise<EndCallOutcome>;
1433
- }
1434
- type TurnEvent = {
1435
- readonly kind: 'partial';
1436
- readonly text: string;
1437
- readonly speakerId: string | null;
1438
- } | {
1439
- readonly kind: 'final';
1440
- readonly text: string;
1441
- readonly speakerId: string | null;
1442
- readonly at: Date;
1443
- } | {
1444
- readonly kind: 'dtmf';
1445
- readonly digit: string;
1446
- readonly code: number;
1447
- readonly participantId: string | null;
1448
- readonly at: Date;
1449
- } | {
1450
- readonly kind: 'hangup';
1451
- } | {
1452
- readonly kind: 'timeout';
1453
- };
1454
- interface InboundOptions {
1455
- readonly idleTimeoutMs?: number;
1456
- readonly finalsOnly?: boolean;
1457
- }
1458
- interface SessionAdapter extends SessionOutbound {
1459
- readonly capabilities: SessionCapabilities;
1460
- on<E extends SessionEvent>(event: E, handler: (payload: SessionEventMap[E]) => void): Unsubscribe;
1461
- once<E extends SessionEvent>(event: E, handler: (payload: SessionEventMap[E]) => void): Unsubscribe;
1462
- /** Graph read side. ONE underlying subscription. Mutually exclusive with the
1463
- * flat on('user_input') consumer (THROWS if both active). The iterator's
1464
- * return()/finally MUST unsubscribe. */
1465
- inbound(opts?: InboundOptions): AsyncIterableIterator<TurnEvent>;
1466
- /** Begin the session (was session.start + waitForSessionActivity). The LiveKit
1467
- * impl preserves the activity sequence VERBATIM so a provider/LLM init failure
1468
- * REJECTS rather than producing a silently-dead answered call. */
1469
- start(opts?: {
1470
- readonly agent?: unknown;
1471
- readonly room?: unknown;
1472
- }): Promise<void>;
1473
- readonly state: SessionState;
1474
- /** Resolve when idle/listening, on timeout, or on close. Synchronous fast-path:
1475
- * if already non-busy, resolves 'idle' in the same microtask. */
1476
- waitForIdle(timeoutMs: number): Promise<'idle' | 'timeout' | 'closed'>;
1477
- waitForClose(): Promise<void>;
1478
- /** Escape hatch for genuinely LK-coupled sites. undefined on the text adapter. */
1479
- readonly raw?: {
1480
- readonly job: JobContext;
1481
- readonly session: unknown;
1482
- readonly room: unknown;
1483
- };
1484
- dispose(): void;
1485
- }
1486
- interface EndCallControllerHandle {
1487
- hangUp(opts?: {
1488
- readonly trigger?: string;
1489
- readonly reason?: string;
1490
- }): Promise<void>;
1491
- armIdle(): void;
1492
- cancelIdle(): void;
1493
- noteEngineClosed(): void;
1494
- }
1495
- /**
1496
- * Fold the user's `speech.interruption` / `speech.endpointing` config into an
1497
- * LK turnHandling object. User-set fields are merged over whatever mode
1498
- * defaults (puppet/hostControlled) already put there — explicit agent config
1499
- * wins. No-op when the config is absent, so existing agents keep LK defaults.
1500
- * Lives here (not session-adapter-livekit) so agent.ts can import it without
1501
- * pulling @livekit/agents in at module load.
1502
- */
1503
- declare function applySpeechTurnHandling(turnHandling: Record<string, unknown>, speech?: {
1504
- readonly interruption?: {
1505
- readonly enabled?: boolean;
1506
- readonly minWords?: number;
1507
- readonly minDuration?: number;
1508
- };
1509
- readonly endpointing?: {
1510
- readonly minDelay?: number;
1511
- readonly maxDelay?: number;
1512
- };
1513
- }): Record<string, unknown>;
1514
- interface SessionFactoryInput {
1515
- readonly usingRealtime: boolean;
1516
- readonly graphMode: boolean;
1517
- readonly puppetMode: boolean;
1518
- readonly hostControlled: boolean;
1519
- readonly captureDtmf: boolean;
1520
- readonly pipeline?: {
1521
- readonly stt?: unknown;
1522
- readonly tts?: unknown;
1523
- readonly vad?: unknown;
1524
- readonly llm: unknown;
1525
- };
1526
- readonly turnHandling?: Record<string, unknown>;
1527
- /** Per-agent barge-in + endpointing tuning (AgentConfig `speech`). Merged
1528
- * over mode defaults by applySpeechTurnHandling — explicit config wins. */
1529
- readonly speech?: {
1530
- readonly interruption?: {
1531
- readonly enabled?: boolean;
1532
- readonly minWords?: number;
1533
- readonly minDuration?: number;
1534
- };
1535
- readonly endpointing?: {
1536
- readonly minDelay?: number;
1537
- readonly maxDelay?: number;
1538
- };
1539
- };
1540
- readonly resolveSpeaker?: (speakerId: string | null) => {
1541
- readonly id: string | null;
1542
- readonly label: string;
1543
- };
1544
- readonly classifyEngineClosed?: (err: unknown) => boolean;
1545
- readonly endCallController?: EndCallControllerHandle;
1546
- }
1547
- type SessionFactory = (input: SessionFactoryInput) => Promise<SessionAdapter>;
1548
- interface UserTurn {
1549
- readonly text: string;
1550
- readonly speakerLabel: string;
1551
- readonly speakerId: string | null;
1552
- readonly at: Date;
1553
- }
1554
- interface FakeSessionAdapter extends SessionAdapter {
1555
- emitUserInput(e: UserInputEvent): void;
1556
- emitAgentTurn(text: string): void;
1557
- emitDtmf(digit: string): void;
1558
- /** Drives 'state' with correct oldState/rawOldState AND runs the SAME
1559
- * arm/cancel + idle-release as production. Unknown string => 'thinking'. */
1560
- setState(next: SessionState | string): void;
1561
- emitError(error: unknown, fatalTransport?: boolean): void;
1562
- emitClose(): void;
1563
- readonly spoken: ReadonlyArray<string>;
1564
- readonly generatedReplies: ReadonlyArray<string | undefined>;
1565
- readonly sentDtmf: ReadonlyArray<string>;
1566
- readonly endCalls: ReadonlyArray<{
1567
- readonly reason?: string;
1568
- readonly trigger?: string;
1569
- }>;
1570
- }
1571
-
1572
1624
  interface ProcessSchema {
1573
1625
  readonly id: string;
1574
1626
  readonly fields: readonly FieldSpec[];
@@ -1931,6 +1983,13 @@ type FlowOutcome = {
1931
1983
  readonly message: string;
1932
1984
  };
1933
1985
 
1986
+ /**
1987
+ * Run `fn` with `client` as the internal helpers' OpenAI client. The scope follows the async work `fn` starts (an
1988
+ * interpreter loop started inside keeps it for its whole life), so a conversation started inside it uses `client`
1989
+ * for every extraction, condition judge and embedding it makes.
1990
+ */
1991
+ declare function runWithOpenAIScope<T>(client: OpenAI, fn: () => T): T;
1992
+
1934
1993
  /** One graph-lifecycle event, for the builder's dry-run trace overlay. */
1935
1994
  interface GraphTraceEvent {
1936
1995
  readonly kind: string;
@@ -1953,6 +2012,9 @@ interface RunTextSessionOptions {
1953
2012
  /** Tap the graph lifecycle (node.entered / edge.traversed / notes) — the
1954
2013
  * same stream the live timeline records, surfaced for the dry-run trace. */
1955
2014
  readonly onTrace?: (event: GraphTraceEvent) => void;
2015
+ /** Fires when the interpreter finishes a turn and blocks for the next user
2016
+ * message — the per-turn boundary used by the live driver below. */
2017
+ readonly onAwaitInput?: () => void;
1956
2018
  }
1957
2019
  interface TextSession {
1958
2020
  /** Feed an inbound user message (a final turn). */
@@ -1992,5 +2054,38 @@ interface TextTranscriptResult {
1992
2054
  * flow consumes them in order as it reaches ask points. Stateless — the request/
1993
2055
  * response shape the text playground route uses. */
1994
2056
  declare function runTextTranscript(opts: RunTextTranscriptOptions): Promise<TextTranscriptResult>;
2057
+ /** One live turn's result: the agent text emitted for this turn, whether the flow
2058
+ * has ended, and (when ended) the final outcome. */
2059
+ interface LiveTurnResult {
2060
+ readonly replies: readonly string[];
2061
+ readonly done: boolean;
2062
+ readonly outcome?: FlowOutcome;
2063
+ }
2064
+ /** A live, turn-by-turn flow conversation: keeps ONE interpreter session alive
2065
+ * (graph cursor + collected slots preserved between turns), so each `turn()`
2066
+ * advances the real flow one user message at a time — the incremental complement
2067
+ * to the stateless `runTextTranscript`. Backs a chat UI / an HTTP turn endpoint. */
2068
+ interface LiveTextConversation {
2069
+ /** Collect the agent's opening turn (greeting / first prompt) before any user
2070
+ * input. Call once, right after construction. */
2071
+ start(): Promise<LiveTurnResult>;
2072
+ /** Feed one user message; resolves with the agent's replies for THIS turn once
2073
+ * the interpreter parks for the next input (or the flow ends). */
2074
+ turn(text: string): Promise<LiveTurnResult>;
2075
+ /** End the conversation (hangup); resolves with the final outcome. */
2076
+ end(): Promise<FlowOutcome>;
2077
+ }
2078
+ type RunLiveTextOptions = Omit<RunTextSessionOptions, 'onAgentText' | 'onAwaitInput'> & {
2079
+ /** Optional extra sink for agent text (the driver always buffers per turn). */
2080
+ readonly onAgentText?: (text: string) => void | Promise<void>;
2081
+ /** The flow's compiled schema. When `processRt` is not supplied, the runtime is
2082
+ * built from this (else derived from the program) — required for ask nodes to
2083
+ * capture, exactly as `runTextTranscript` does. */
2084
+ readonly schema?: ProcessSchemaDTO;
2085
+ };
2086
+ /** Drive a flow live, one user turn at a time, preserving interpreter state
2087
+ * between turns. Uses the `onAwaitInput` boundary: a turn is "done" once the
2088
+ * interpreter blocks for the next message, or the flow ends. */
2089
+ declare function runLiveTextConversation(opts: RunLiveTextOptions): LiveTextConversation;
1995
2090
 
1996
- export { type UserTurn as $, AgentDTO as A, type SessionEvent as B, type CallInfo as C, type DtmfEvent as D, type EndCallControllerHandle as E, type FakeSessionAdapter as F, type SessionEventMap as G, type SessionFactory as H, type InboundOptions as I, type SessionFactoryInput as J, type SessionOutbound as K, LK_AGENT_STATE_MAP as L, type MemoryHandle as M, NON_BUSY_STATES as N, type SessionState as O, ProcessSchemaDTO as P, type SpeechResult as Q, type RespondOptions as R, type SayOptions as S, type SpeechTarget as T, type StateChangeEvent as U, type TextSession as V, type TextTranscriptResult as W, type TtsVoiceConfig as X, type TurnEvent as Y, type Unsubscribe as Z, type UserInputEvent as _, AgentStatus as a, applySpeechTurnHandling as a0, dtmfCodeToDigit as a1, dtmfDigitToCode as a2, duck as a3, mute as a4, normalizeState as a5, passthrough as a6, runTextSession as a7, runTextTranscript as a8, transform as a9, type GraphTraceEvent as aa, AgentEnvironment as b, type AgentContext as c, type Participant as d, type AgentTurnEvent as e, type AudioProfile as f, type AudioSurface as g, type ChannelKind as h, type DtmfHandler as i, type EndCallOutcome as j, type FloorControlConfig as k, type MetricsEvent as l, ParticipantId as m, type ParticipantKind as n, type ParticipantSet as o, type ProcessSnapshot as p, type Room as q, type RouteEntry as r, type RoutingRule as s, type RoutingSnapshot as t, type RunTextSessionOptions as u, type RunTextTranscriptOptions as v, type SendDtmfOptions as w, type SessionAdapter as x, type SessionCapabilities as y, type SessionErrorEvent as z };
2091
+ export { type UserStateEvent as $, AgentDTO as A, type SessionEvent as B, type CallInfo as C, type DtmfEvent as D, type EndCallControllerHandle as E, type FakeSessionAdapter as F, type SessionEventMap as G, type SessionFactory as H, type InboundOptions as I, type SessionFactoryInput as J, type SessionOutbound as K, LK_AGENT_STATE_MAP as L, type MemoryHandle as M, NON_BUSY_STATES as N, type SessionState as O, type Participant as P, type SpeechResult as Q, type RespondOptions as R, type SayOptions as S, type SpeechTarget as T, type StateChangeEvent as U, type TextSession as V, type TextTranscriptResult as W, type TtsVoiceConfig as X, type TurnEvent as Y, type Unsubscribe as Z, type UserInputEvent as _, AgentStatus as a, type UserTurn as a0, applySpeechTurnHandling as a1, dtmfCodeToDigit as a2, dtmfDigitToCode as a3, duck as a4, mute as a5, normalizeState as a6, passthrough as a7, runTextSession as a8, runTextTranscript as a9, transform as aa, type GraphTraceEvent as ab, type LiveTextConversation as ac, type LiveTurnResult as ad, type RunLiveTextOptions as ae, runLiveTextConversation as af, runWithOpenAIScope as ag, AgentEnvironment as b, type AgentContext as c, ProcessSchemaDTO as d, type AgentTurnEvent as e, type AudioProfile as f, type AudioSurface as g, type ChannelKind as h, type DtmfHandler as i, type EndCallOutcome as j, type FloorControlConfig as k, type MetricsEvent as l, ParticipantId as m, type ParticipantKind as n, type ParticipantSet as o, type ProcessSnapshot as p, type Room as q, type RouteEntry as r, type RoutingRule as s, type RoutingSnapshot as t, type RunTextSessionOptions as u, type RunTextTranscriptOptions as v, type SendDtmfOptions as w, type SessionAdapter as x, type SessionCapabilities as y, type SessionErrorEvent as z };