@voicelayer/sdk 0.1.2 → 0.1.3

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
@@ -226,7 +226,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
226
226
  entry: z.ZodArray<z.ZodString, "many">;
227
227
  nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
228
228
  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"]>;
229
+ type: z.ZodEnum<["start", "say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "route", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
230
230
  config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
231
231
  out: z.ZodArray<z.ZodObject<{
232
232
  to: z.ZodString;
@@ -245,7 +245,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
245
245
  condition?: string | undefined;
246
246
  }>, "many">;
247
247
  }, "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";
248
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
249
249
  id: string;
250
250
  config: Record<string, unknown>;
251
251
  out: {
@@ -255,7 +255,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
255
255
  condition?: string | undefined;
256
256
  }[];
257
257
  }, {
258
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
258
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
259
259
  id: string;
260
260
  config: Record<string, unknown>;
261
261
  out: {
@@ -289,7 +289,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
289
289
  v: 1;
290
290
  id: string;
291
291
  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";
292
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
293
293
  id: string;
294
294
  config: Record<string, unknown>;
295
295
  out: {
@@ -312,7 +312,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
312
312
  v: 1;
313
313
  id: string;
314
314
  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";
315
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
316
316
  id: string;
317
317
  config: Record<string, unknown>;
318
318
  out: {
@@ -384,7 +384,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
384
384
  v: 1;
385
385
  id: string;
386
386
  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";
387
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
388
388
  id: string;
389
389
  config: Record<string, unknown>;
390
390
  out: {
@@ -456,7 +456,7 @@ declare const ProcessSchemaDTO: z.ZodObject<{
456
456
  v: 1;
457
457
  id: string;
458
458
  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";
459
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
460
460
  id: string;
461
461
  config: Record<string, unknown>;
462
462
  out: {
@@ -640,7 +640,7 @@ declare const AgentDTO: z.ZodObject<{
640
640
  entry: z.ZodArray<z.ZodString, "many">;
641
641
  nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
642
642
  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"]>;
643
+ type: z.ZodEnum<["start", "say", "ask", "confirm", "tool", "decision", "handoff", "end", "trigger", "gate", "playbook", "route", "menu", "code", "set", "subflow", "llm", "rag", "memory", "classify", "router", "note"]>;
644
644
  config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
645
645
  out: z.ZodArray<z.ZodObject<{
646
646
  to: z.ZodString;
@@ -659,7 +659,7 @@ declare const AgentDTO: z.ZodObject<{
659
659
  condition?: string | undefined;
660
660
  }>, "many">;
661
661
  }, "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";
662
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
663
663
  id: string;
664
664
  config: Record<string, unknown>;
665
665
  out: {
@@ -669,7 +669,7 @@ declare const AgentDTO: z.ZodObject<{
669
669
  condition?: string | undefined;
670
670
  }[];
671
671
  }, {
672
- type: "code" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
672
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
673
673
  id: string;
674
674
  config: Record<string, unknown>;
675
675
  out: {
@@ -703,7 +703,7 @@ declare const AgentDTO: z.ZodObject<{
703
703
  v: 1;
704
704
  id: string;
705
705
  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";
706
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
707
707
  id: string;
708
708
  config: Record<string, unknown>;
709
709
  out: {
@@ -726,7 +726,7 @@ declare const AgentDTO: z.ZodObject<{
726
726
  v: 1;
727
727
  id: string;
728
728
  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";
729
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
730
730
  id: string;
731
731
  config: Record<string, unknown>;
732
732
  out: {
@@ -798,7 +798,7 @@ declare const AgentDTO: z.ZodObject<{
798
798
  v: 1;
799
799
  id: string;
800
800
  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";
801
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
802
802
  id: string;
803
803
  config: Record<string, unknown>;
804
804
  out: {
@@ -870,7 +870,7 @@ declare const AgentDTO: z.ZodObject<{
870
870
  v: 1;
871
871
  id: string;
872
872
  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";
873
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
874
874
  id: string;
875
875
  config: Record<string, unknown>;
876
876
  out: {
@@ -963,7 +963,7 @@ declare const AgentDTO: z.ZodObject<{
963
963
  v: 1;
964
964
  id: string;
965
965
  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";
966
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
967
967
  id: string;
968
968
  config: Record<string, unknown>;
969
969
  out: {
@@ -1054,7 +1054,7 @@ declare const AgentDTO: z.ZodObject<{
1054
1054
  v: 1;
1055
1055
  id: string;
1056
1056
  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";
1057
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
1058
1058
  id: string;
1059
1059
  config: Record<string, unknown>;
1060
1060
  out: {
@@ -2907,7 +2907,7 @@ declare class AgentsClient {
2907
2907
  v: 1;
2908
2908
  id: string;
2909
2909
  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";
2910
+ type: "code" | "start" | "say" | "ask" | "confirm" | "tool" | "decision" | "handoff" | "end" | "trigger" | "gate" | "playbook" | "route" | "menu" | "set" | "subflow" | "llm" | "rag" | "memory" | "classify" | "router" | "note";
2911
2911
  id: string;
2912
2912
  config: Record<string, unknown>;
2913
2913
  out: {
@@ -2995,6 +2995,13 @@ interface AppendTranscriptInput {
2995
2995
  readonly endMs: number;
2996
2996
  readonly final?: boolean;
2997
2997
  }
2998
+ type DtmfDirection = 'received' | 'sent';
2999
+ interface AppendDtmfEventInput {
3000
+ readonly direction: DtmfDirection;
3001
+ readonly digit: string;
3002
+ readonly code: number;
3003
+ readonly participantId?: string;
3004
+ }
2998
3005
  interface EnsureCallByRoomInput {
2999
3006
  readonly roomName: string;
3000
3007
  readonly phoneNumberId?: string;
@@ -3042,6 +3049,7 @@ declare class CallsClient {
3042
3049
  ensureByRoom(input: EnsureCallByRoomInput): Promise<CallSummary>;
3043
3050
  syncState(callId: string, input: SyncCallStateInput): Promise<void>;
3044
3051
  appendTranscriptSegment(callId: string, input: AppendTranscriptInput): Promise<void>;
3052
+ appendDtmfEvent(callId: string, input: AppendDtmfEventInput): Promise<void>;
3045
3053
  /**
3046
3054
  * Append a structured call event. Today the API accepts consultation
3047
3055
  * lifecycle kinds only — see apps/api/src/routes/calls.ts AppendEventBody.
@@ -3167,6 +3175,195 @@ declare class ConnectionsClient {
3167
3175
  resolveProviderCredential(provider: string): Promise<ProviderCredential | null>;
3168
3176
  }
3169
3177
 
3178
+ type SessionState = 'initializing' | 'idle' | 'listening' | 'thinking' | 'speaking';
3179
+ declare const LK_AGENT_STATE_MAP: Readonly<Record<string, SessionState>>;
3180
+ declare const NON_BUSY_STATES: ReadonlySet<SessionState>;
3181
+ /** Normalize a raw LK state string to SessionState; unknown -> 'thinking' (fail-safe). */
3182
+ declare function normalizeState(raw: string): SessionState;
3183
+ interface UserInputEvent {
3184
+ readonly transcript: string;
3185
+ readonly isFinal: boolean;
3186
+ readonly speakerId: string | null;
3187
+ }
3188
+ interface AgentTurnEvent {
3189
+ readonly text: string;
3190
+ }
3191
+ interface DtmfEvent$1 {
3192
+ readonly digit: string;
3193
+ readonly code: number;
3194
+ readonly participantId: string | null;
3195
+ }
3196
+ interface StateChangeEvent {
3197
+ readonly oldState: SessionState | null;
3198
+ readonly newState: SessionState | null;
3199
+ readonly rawOldState: string | null;
3200
+ readonly rawNewState: string | null;
3201
+ }
3202
+ interface SessionErrorEvent {
3203
+ readonly error: unknown;
3204
+ readonly source: 'llm' | 'stt' | 'tts' | 'realtime' | 'unknown';
3205
+ readonly fatalTransport: boolean;
3206
+ }
3207
+ interface MetricsEvent {
3208
+ readonly metrics: unknown;
3209
+ }
3210
+ interface SessionEventMap {
3211
+ user_input: UserInputEvent;
3212
+ agent_turn: AgentTurnEvent;
3213
+ dtmf: DtmfEvent$1;
3214
+ state: StateChangeEvent;
3215
+ error: SessionErrorEvent;
3216
+ metrics: MetricsEvent;
3217
+ close: void;
3218
+ }
3219
+ type SessionEvent = keyof SessionEventMap;
3220
+ type Unsubscribe = () => void;
3221
+ type ChannelKind = 'voice' | 'text';
3222
+ interface SessionCapabilities {
3223
+ readonly channel: ChannelKind;
3224
+ readonly usingRealtime: boolean;
3225
+ readonly hasStreamingTranscripts: boolean;
3226
+ readonly canBargeIn: boolean;
3227
+ readonly canReceiveDtmf: boolean;
3228
+ readonly canPublishDtmf: boolean;
3229
+ readonly canResolveSpeaker: boolean;
3230
+ }
3231
+ interface SayOptions$1 {
3232
+ readonly allowInterruptions?: boolean;
3233
+ readonly to?: string | readonly string[];
3234
+ }
3235
+ interface SpeechResult {
3236
+ readonly interrupted: boolean;
3237
+ }
3238
+ interface EndCallOutcome {
3239
+ readonly torn: 'room' | 'agent' | 'none';
3240
+ readonly stranded: boolean;
3241
+ }
3242
+ interface SessionOutbound {
3243
+ /** Speak verbatim. Under usingRealtime the LiveKit adapter routes to
3244
+ * generateReply(verbatim) NOT session.say (no TTS in S2S). Resolves after
3245
+ * playout (voice) or after the text turn is committed (text). */
3246
+ say(text: string, opts?: SayOptions$1): Promise<SpeechResult>;
3247
+ /** Ask the LLM to produce a turn. */
3248
+ generateReply(opts?: {
3249
+ readonly instructions?: string;
3250
+ }): Promise<void>;
3251
+ /** Barge-in cancel (puppet interrupt mode). text => no-op. */
3252
+ interrupt(): Promise<void>;
3253
+ /** Publish outbound DTMF from the agent leg. Throws if !canPublishDtmf. */
3254
+ sendDtmf(code: number, digit: string): Promise<void>;
3255
+ /** Hang up via the SDK end-call controller (deletes room so the SIP leg drops). */
3256
+ endCall(opts?: {
3257
+ readonly reason?: string;
3258
+ readonly trigger?: string;
3259
+ }): Promise<EndCallOutcome>;
3260
+ }
3261
+ type TurnEvent = {
3262
+ readonly kind: 'partial';
3263
+ readonly text: string;
3264
+ readonly speakerId: string | null;
3265
+ } | {
3266
+ readonly kind: 'final';
3267
+ readonly text: string;
3268
+ readonly speakerId: string | null;
3269
+ readonly at: Date;
3270
+ } | {
3271
+ readonly kind: 'dtmf';
3272
+ readonly digit: string;
3273
+ readonly code: number;
3274
+ readonly participantId: string | null;
3275
+ readonly at: Date;
3276
+ } | {
3277
+ readonly kind: 'hangup';
3278
+ } | {
3279
+ readonly kind: 'timeout';
3280
+ };
3281
+ interface InboundOptions {
3282
+ readonly idleTimeoutMs?: number;
3283
+ readonly finalsOnly?: boolean;
3284
+ }
3285
+ interface SessionAdapter extends SessionOutbound {
3286
+ readonly capabilities: SessionCapabilities;
3287
+ on<E extends SessionEvent>(event: E, handler: (payload: SessionEventMap[E]) => void): Unsubscribe;
3288
+ once<E extends SessionEvent>(event: E, handler: (payload: SessionEventMap[E]) => void): Unsubscribe;
3289
+ /** Graph read side. ONE underlying subscription. Mutually exclusive with the
3290
+ * flat on('user_input') consumer (THROWS if both active). The iterator's
3291
+ * return()/finally MUST unsubscribe. */
3292
+ inbound(opts?: InboundOptions): AsyncIterableIterator<TurnEvent>;
3293
+ /** Begin the session (was session.start + waitForSessionActivity). The LiveKit
3294
+ * impl preserves the activity sequence VERBATIM so a provider/LLM init failure
3295
+ * REJECTS rather than producing a silently-dead answered call. */
3296
+ start(opts?: {
3297
+ readonly agent?: unknown;
3298
+ readonly room?: unknown;
3299
+ }): Promise<void>;
3300
+ readonly state: SessionState;
3301
+ /** Resolve when idle/listening, on timeout, or on close. Synchronous fast-path:
3302
+ * if already non-busy, resolves 'idle' in the same microtask. */
3303
+ waitForIdle(timeoutMs: number): Promise<'idle' | 'timeout' | 'closed'>;
3304
+ waitForClose(): Promise<void>;
3305
+ /** Escape hatch for genuinely LK-coupled sites. undefined on the text adapter. */
3306
+ readonly raw?: {
3307
+ readonly job: JobContext;
3308
+ readonly session: unknown;
3309
+ readonly room: unknown;
3310
+ };
3311
+ dispose(): void;
3312
+ }
3313
+ interface EndCallControllerHandle {
3314
+ hangUp(o: {
3315
+ readonly trigger: string;
3316
+ readonly reason?: string;
3317
+ }): Promise<EndCallOutcome>;
3318
+ armIdle(): void;
3319
+ cancelIdle(): void;
3320
+ noteEngineClosed(): void;
3321
+ }
3322
+ interface SessionFactoryInput {
3323
+ readonly usingRealtime: boolean;
3324
+ readonly graphMode: boolean;
3325
+ readonly puppetMode: boolean;
3326
+ readonly hostControlled: boolean;
3327
+ readonly captureDtmf: boolean;
3328
+ readonly pipeline?: {
3329
+ readonly stt?: unknown;
3330
+ readonly tts?: unknown;
3331
+ readonly vad?: unknown;
3332
+ readonly llm: unknown;
3333
+ };
3334
+ readonly turnHandling?: Record<string, unknown>;
3335
+ readonly resolveSpeaker?: (speakerId: string | null) => {
3336
+ readonly id: string | null;
3337
+ readonly label: string;
3338
+ };
3339
+ readonly classifyEngineClosed?: (err: unknown) => boolean;
3340
+ readonly endCallController?: EndCallControllerHandle;
3341
+ }
3342
+ type SessionFactory = (input: SessionFactoryInput) => Promise<SessionAdapter>;
3343
+ interface UserTurn {
3344
+ readonly text: string;
3345
+ readonly speakerLabel: string;
3346
+ readonly speakerId: string | null;
3347
+ readonly at: Date;
3348
+ }
3349
+ interface FakeSessionAdapter extends SessionAdapter {
3350
+ emitUserInput(e: UserInputEvent): void;
3351
+ emitAgentTurn(text: string): void;
3352
+ emitDtmf(digit: string): void;
3353
+ /** Drives 'state' with correct oldState/rawOldState AND runs the SAME
3354
+ * arm/cancel + idle-release as production. Unknown string => 'thinking'. */
3355
+ setState(next: SessionState | string): void;
3356
+ emitError(error: unknown, fatalTransport?: boolean): void;
3357
+ emitClose(): void;
3358
+ readonly spoken: ReadonlyArray<string>;
3359
+ readonly generatedReplies: ReadonlyArray<string | undefined>;
3360
+ readonly sentDtmf: ReadonlyArray<string>;
3361
+ readonly endCalls: ReadonlyArray<{
3362
+ readonly reason?: string;
3363
+ readonly trigger?: string;
3364
+ }>;
3365
+ }
3366
+
3170
3367
  interface DefaultMetadata {
3171
3368
  readonly hostname: string;
3172
3369
  readonly platform: NodeJS.Platform;
@@ -3738,6 +3935,8 @@ type EndCallTrigger =
3738
3935
  | 'host'
3739
3936
  /** The dead-air backstop fired (`idleHangupMs` of silence while idle). */
3740
3937
  | 'idle'
3938
+ /** The hard per-call ceiling fired (`maxCallDurationMs` elapsed). */
3939
+ | 'max_duration'
3741
3940
  /** The last non-agent participant left the room. */
3742
3941
  | 'participant-left'
3743
3942
  /** A flow/graph run finished and asked to hang up. */
@@ -3791,7 +3990,16 @@ interface EndCallPolicy {
3791
3990
  */
3792
3991
  readonly idleHangupMs?: number | false;
3793
3992
  /**
3794
- * Hook fired the moment a hang-up is decided, just before teardown. Return
3993
+ * Hard call ceiling: hang up once the call has run this many ms from when
3994
+ * the session becomes ready, regardless of activity. Catches runaway calls
3995
+ * that never end naturally (stuck loops, hijacked keys dialing premium
3996
+ * numbers). Fires with trigger `'max_duration'`. Default 3600000 (60
3997
+ * minutes). `false` disables.
3998
+ */
3999
+ readonly maxCallDurationMs?: number | false;
4000
+ /**
4001
+ * Hook fired the moment a hang-up is decided, just before teardown — for
4002
+ * every trigger (tool, host, idle, max_duration, engine-closed, …). Return
3795
4003
  * `false` to take over teardown yourself (the SDK then does nothing — the
3796
4004
  * call will NOT end unless you end it). Returning anything else (or nothing)
3797
4005
  * runs the default teardown. Throwing is caught + logged, then the default
@@ -3850,6 +4058,9 @@ interface SecurityConfig {
3850
4058
  interface FlowRuntimeConfig {
3851
4059
  /** Prepended to the flow's compiled say/confirm prompt fragments. */
3852
4060
  readonly basePrompt?: string;
4061
+ /** Spoken (verbatim) before hanging up when a flow call's schema cannot be
4062
+ * loaded. A failed flow boot NEVER silently answers as a generic assistant. */
4063
+ readonly bootFailureMessage?: string;
3853
4064
  }
3854
4065
  interface AgentConfig<TProcess extends Record<string, ProcessField> = Record<string, ProcessField>> {
3855
4066
  /** Lowercase, kebab-case identifier. Used for LiveKit dispatch + presence. */
@@ -4302,4 +4513,4 @@ interface VoiceLayerClient {
4302
4513
  }
4303
4514
  declare function createClient(options?: CreateClientOptions): VoiceLayerClient;
4304
4515
 
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 };
4516
+ export { Agent, type AgentConfig, type AgentContext, type AgentEventEmitter, type AgentEventListener, type AgentLifecycleEvent, type AgentTurnEvent, type AppendDtmfEventInput, type AppendTranscriptInput, type AudioProfile, type AudioSurface, BaseTool, type CallAttributeValue, type CallInfo, type CallLegInput, type CallOutcomeSummary, type CallParticipantInput, type CallStatus, type CallSummary, CallsClient, type ChannelKind, type CompiledAgentParts, type CompletionStrategy, type ComplianceTag, type ConnectorInstance, ConsultationPolicy, type CreateClientOptions, type CreatedFormSession, type DefaultMetadata, type DtmfDirection, type DtmfEvent, type DtmfHandler, EmailClient, type SendEmailInput as EmailSendInput, type EndCallControllerHandle, type EndCallInfo, type EndCallOutcome, type EndCallPolicy, type EndCallTrigger, type EnsureCallByRoomInput, type FakeSessionAdapter, type FloorControlConfig, type CreateFormSessionInput as FormCreateInput, type FormToolsOptions, FormsClient, type HandoffConfig, type HttpToolResult, type HttpToolSpec, type InboundOptions, type InferProcessData, LK_AGENT_STATE_MAP, type LLMProvider, type MemoryConfig, type MemoryHandle, type MemoryScope, type MetricsEvent, type ModelConfig, NON_BUSY_STATES, 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 SessionAdapter, type SessionCapabilities, type SessionErrorEvent, type SessionEvent, type SessionEventMap, type SessionFactory, type SessionFactoryInput, type SessionOutbound, type SessionState, type ShorthandPrimitive, type SpeechConfig, type SpeechResult, type SpeechTarget, type StateChangeEvent, type SyncCallStateInput, type TTSProvider, type ToolDefinition, type ToolInputShape, type TriggerAction, type TriggerCondition, type TriggerDefinition, type TtsVoiceConfig, type TurnDetectorProvider, type TurnEvent, type Unsubscribe, type UserInputEvent, type UserTurn, 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, normalizeState, openai, ParticipantId as participantId, passthrough, processSchemaToAgentParts, processSchemaToDefinition, puppetEnvAvailable, resendEmailTool, runProbes, silero, startPuppetControl, transform, urlProbe, webhook, wrap };