@jambonz/sdk 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/AGENTS.md +1 -1
  2. package/dist/client/index.cjs +4 -0
  3. package/dist/client/index.cjs.map +1 -1
  4. package/dist/client/index.d.cts +4 -2
  5. package/dist/client/index.d.ts +4 -2
  6. package/dist/client/index.js +4 -0
  7. package/dist/client/index.js.map +1 -1
  8. package/dist/index.cjs +13 -0
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +3 -3
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +13 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/{rest-CIi3fP4n.d.ts → rest-C1bMbs6-.d.cts} +3 -1
  15. package/dist/{rest-BehrJ_ai.d.cts → rest-arm-pIoj.d.ts} +3 -1
  16. package/dist/types/index.cjs +3 -1
  17. package/dist/types/index.cjs.map +1 -1
  18. package/dist/types/index.d.cts +2 -2
  19. package/dist/types/index.d.ts +2 -2
  20. package/dist/types/index.js +3 -1
  21. package/dist/types/index.js.map +1 -1
  22. package/dist/{verb-builder-8zDaN7ba.d.ts → verb-builder-BcM7Cth-.d.ts} +3 -1
  23. package/dist/{verb-builder-Cc9cLrYj.d.cts → verb-builder-DpeNsmyP.d.cts} +3 -1
  24. package/dist/{verbs-BuObLiyU.d.cts → verbs-Bq-MRFKt.d.cts} +103 -3
  25. package/dist/{verbs-BuObLiyU.d.ts → verbs-Bq-MRFKt.d.ts} +103 -3
  26. package/dist/webhook/index.cjs +4 -0
  27. package/dist/webhook/index.cjs.map +1 -1
  28. package/dist/webhook/index.d.cts +2 -2
  29. package/dist/webhook/index.d.ts +2 -2
  30. package/dist/webhook/index.js +4 -0
  31. package/dist/webhook/index.js.map +1 -1
  32. package/dist/websocket/index.cjs +9 -0
  33. package/dist/websocket/index.cjs.map +1 -1
  34. package/dist/websocket/index.d.cts +4 -2
  35. package/dist/websocket/index.d.ts +4 -2
  36. package/dist/websocket/index.js +9 -0
  37. package/dist/websocket/index.js.map +1 -1
  38. package/package.json +2 -2
@@ -12,7 +12,9 @@ var LLM_VENDORS = [
12
12
  "baseten",
13
13
  "azure-openai",
14
14
  "groq",
15
- "huggingface"
15
+ "huggingface",
16
+ "moonshot",
17
+ "zai"
16
18
  ];
17
19
 
18
20
  exports.LLM_VENDORS = LLM_VENDORS;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/llm-vendors.generated.ts"],"names":[],"mappings":";;;AAQO,IAAM,WAAA,GAAc;AAAA,EACzB,QAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF","file":"index.cjs","sourcesContent":["// AUTO-GENERATED — DO NOT EDIT BY HAND.\n// Source of truth: @jambonz/schema@0.3.15 verbs/agent.schema.json (llm.vendor.enum)\n// Regenerate with: npm run gen:types\n//\n// This file derives the LLM vendor list from the JSON schema so the SDK's\n// types never drift from the schema when a new vendor is added.\n\n/** Supported LLM vendors for the agent verb, derived from the schema enum. */\nexport const LLM_VENDORS = [\n 'openai',\n 'anthropic',\n 'google',\n 'vertex-gemini',\n 'vertex-openai',\n 'bedrock',\n 'deepseek',\n 'baseten',\n 'azure-openai',\n 'groq',\n 'huggingface',\n] as const;\n\n/** Union of LLM vendor ids accepted by the agent verb's `llm.vendor`. */\nexport type LlmVendor = (typeof LLM_VENDORS)[number];\n"]}
1
+ {"version":3,"sources":["../../src/types/llm-vendors.generated.ts"],"names":[],"mappings":";;;AAQO,IAAM,WAAA,GAAc;AAAA,EACzB,QAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF","file":"index.cjs","sourcesContent":["// AUTO-GENERATED — DO NOT EDIT BY HAND.\n// Source of truth: @jambonz/schema@0.3.18 verbs/agent.schema.json (llm.vendor.enum)\n// Regenerate with: npm run gen:types\n//\n// This file derives the LLM vendor list from the JSON schema so the SDK's\n// types never drift from the schema when a new vendor is added.\n\n/** Supported LLM vendors for the agent verb, derived from the schema enum. */\nexport const LLM_VENDORS = [\n 'openai',\n 'anthropic',\n 'google',\n 'vertex-gemini',\n 'vertex-openai',\n 'bedrock',\n 'deepseek',\n 'baseten',\n 'azure-openai',\n 'groq',\n 'huggingface',\n 'moonshot',\n 'zai',\n] as const;\n\n/** Union of LLM vendor ids accepted by the agent verb's `llm.vendor`. */\nexport type LlmVendor = (typeof LLM_VENDORS)[number];\n"]}
@@ -1,4 +1,4 @@
1
- export { A as ActionHook, a as ActionHookDelayAction, b as ActionHookObject, c as AgentLlm, d as AgentLlmOptions, e as AgentVerb, f as AlertVerb, g as Amd, h as AmdTimers, i as AnswerVerb, j as Auth, B as BidirectionalAudio, C as ConferenceVerb, k as ConfigVerb, D as DequeueVerb, l as DialVerb, m as DtmfVerb, n as DubVerb, E as EnqueueVerb, F as FillerNoise, G as GatherVerb, H as HangupVerb, J as JambonzApp, L as LLM_VENDORS, o as LeaveVerb, p as ListenVerb, q as LlmMessage, r as LlmTool, s as LlmToolOpenAIWrapped, t as LlmToolOutputData, u as LlmVendor, v as LlmVerb, M as McpServerConfig, w as MessageVerb, P as PauseVerb, x as PlayVerb, R as Recognizer, y as RedirectVerb, S as SayVerb, z as SipDeclineVerb, I as SipReferVerb, K as SipRequestVerb, N as StreamVerb, O as Synthesizer, T as TagVerb, Q as Target, U as TranscribeVerb, V as Vad, W as Verb, X as VerbName } from '../verbs-BuObLiyU.cjs';
1
+ export { A as ActionHook, a as ActionHookDelayAction, b as ActionHookObject, c as AgentLlm, d as AgentLlmOptions, e as AgentVerb, f as AlertVerb, g as Amd, h as AmdTimers, i as AnswerVerb, j as Auth, B as BidirectionalAudio, C as ConferenceVerb, k as ConfigVerb, D as DequeueVerb, l as DialVerb, m as DtmfVerb, n as DubVerb, E as EnqueueVerb, F as FillerNoise, G as GatherVerb, H as Handoff, o as HangupVerb, J as JambonzApp, L as LLM_VENDORS, p as LeaveVerb, q as ListenVerb, r as LlmMessage, s as LlmTool, t as LlmToolOpenAIWrapped, u as LlmToolOutputData, v as LlmVendor, w as LlmVerb, M as McpServerConfig, x as MessageVerb, P as PauseVerb, y as PlayVerb, R as Recognizer, z as RedirectVerb, S as SayVerb, I as SipDeclineVerb, K as SipReferVerb, N as SipRequestVerb, O as StreamVerb, Q as Synthesizer, T as TagVerb, U as Target, V as TranscribeVerb, W as TransferConfirm, X as TransferDisposition, Y as TransferOptions, Z as TransferVerb, _ as Vad, $ as Verb, a0 as VerbName } from '../verbs-Bq-MRFKt.cjs';
2
2
  export { A as AgentEvent, a as AgentEventType, b as AgentLlmResponseEvent, c as AgentPreflightMetrics, d as AgentTurnEndEvent, e as AgentTurnLatency, f as AgentUserInterruptionEvent, g as AgentUserTranscriptEvent, C as CallSession, T as TtsStreamingEvent, h as TtsStreamingEventType, W as WsMessage, i as WsMessageType, j as WsResponse } from '../session-DKaSRkIo.cjs';
3
3
  export { E as EnvVarDef, a as EnvVarSchema, L as Logger } from '../common-BSJZX7WO.cjs';
4
- export { C as CallCount, a as CallInfo, b as CreateCallRequest, L as ListCallsFilter, Q as QueueInfo, U as UpdateCallRequest } from '../rest-BehrJ_ai.cjs';
4
+ export { C as CallCount, a as CallInfo, b as CreateCallRequest, L as ListCallsFilter, Q as QueueInfo, U as UpdateCallRequest } from '../rest-C1bMbs6-.cjs';
@@ -1,4 +1,4 @@
1
- export { A as ActionHook, a as ActionHookDelayAction, b as ActionHookObject, c as AgentLlm, d as AgentLlmOptions, e as AgentVerb, f as AlertVerb, g as Amd, h as AmdTimers, i as AnswerVerb, j as Auth, B as BidirectionalAudio, C as ConferenceVerb, k as ConfigVerb, D as DequeueVerb, l as DialVerb, m as DtmfVerb, n as DubVerb, E as EnqueueVerb, F as FillerNoise, G as GatherVerb, H as HangupVerb, J as JambonzApp, L as LLM_VENDORS, o as LeaveVerb, p as ListenVerb, q as LlmMessage, r as LlmTool, s as LlmToolOpenAIWrapped, t as LlmToolOutputData, u as LlmVendor, v as LlmVerb, M as McpServerConfig, w as MessageVerb, P as PauseVerb, x as PlayVerb, R as Recognizer, y as RedirectVerb, S as SayVerb, z as SipDeclineVerb, I as SipReferVerb, K as SipRequestVerb, N as StreamVerb, O as Synthesizer, T as TagVerb, Q as Target, U as TranscribeVerb, V as Vad, W as Verb, X as VerbName } from '../verbs-BuObLiyU.js';
1
+ export { A as ActionHook, a as ActionHookDelayAction, b as ActionHookObject, c as AgentLlm, d as AgentLlmOptions, e as AgentVerb, f as AlertVerb, g as Amd, h as AmdTimers, i as AnswerVerb, j as Auth, B as BidirectionalAudio, C as ConferenceVerb, k as ConfigVerb, D as DequeueVerb, l as DialVerb, m as DtmfVerb, n as DubVerb, E as EnqueueVerb, F as FillerNoise, G as GatherVerb, H as Handoff, o as HangupVerb, J as JambonzApp, L as LLM_VENDORS, p as LeaveVerb, q as ListenVerb, r as LlmMessage, s as LlmTool, t as LlmToolOpenAIWrapped, u as LlmToolOutputData, v as LlmVendor, w as LlmVerb, M as McpServerConfig, x as MessageVerb, P as PauseVerb, y as PlayVerb, R as Recognizer, z as RedirectVerb, S as SayVerb, I as SipDeclineVerb, K as SipReferVerb, N as SipRequestVerb, O as StreamVerb, Q as Synthesizer, T as TagVerb, U as Target, V as TranscribeVerb, W as TransferConfirm, X as TransferDisposition, Y as TransferOptions, Z as TransferVerb, _ as Vad, $ as Verb, a0 as VerbName } from '../verbs-Bq-MRFKt.js';
2
2
  export { A as AgentEvent, a as AgentEventType, b as AgentLlmResponseEvent, c as AgentPreflightMetrics, d as AgentTurnEndEvent, e as AgentTurnLatency, f as AgentUserInterruptionEvent, g as AgentUserTranscriptEvent, C as CallSession, T as TtsStreamingEvent, h as TtsStreamingEventType, W as WsMessage, i as WsMessageType, j as WsResponse } from '../session-DKaSRkIo.js';
3
3
  export { E as EnvVarDef, a as EnvVarSchema, L as Logger } from '../common-BSJZX7WO.js';
4
- export { C as CallCount, a as CallInfo, b as CreateCallRequest, L as ListCallsFilter, Q as QueueInfo, U as UpdateCallRequest } from '../rest-CIi3fP4n.js';
4
+ export { C as CallCount, a as CallInfo, b as CreateCallRequest, L as ListCallsFilter, Q as QueueInfo, U as UpdateCallRequest } from '../rest-arm-pIoj.js';
@@ -10,7 +10,9 @@ var LLM_VENDORS = [
10
10
  "baseten",
11
11
  "azure-openai",
12
12
  "groq",
13
- "huggingface"
13
+ "huggingface",
14
+ "moonshot",
15
+ "zai"
14
16
  ];
15
17
 
16
18
  export { LLM_VENDORS };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/llm-vendors.generated.ts"],"names":[],"mappings":";AAQO,IAAM,WAAA,GAAc;AAAA,EACzB,QAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["// AUTO-GENERATED — DO NOT EDIT BY HAND.\n// Source of truth: @jambonz/schema@0.3.15 verbs/agent.schema.json (llm.vendor.enum)\n// Regenerate with: npm run gen:types\n//\n// This file derives the LLM vendor list from the JSON schema so the SDK's\n// types never drift from the schema when a new vendor is added.\n\n/** Supported LLM vendors for the agent verb, derived from the schema enum. */\nexport const LLM_VENDORS = [\n 'openai',\n 'anthropic',\n 'google',\n 'vertex-gemini',\n 'vertex-openai',\n 'bedrock',\n 'deepseek',\n 'baseten',\n 'azure-openai',\n 'groq',\n 'huggingface',\n] as const;\n\n/** Union of LLM vendor ids accepted by the agent verb's `llm.vendor`. */\nexport type LlmVendor = (typeof LLM_VENDORS)[number];\n"]}
1
+ {"version":3,"sources":["../../src/types/llm-vendors.generated.ts"],"names":[],"mappings":";AAQO,IAAM,WAAA,GAAc;AAAA,EACzB,QAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,SAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,cAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["// AUTO-GENERATED — DO NOT EDIT BY HAND.\n// Source of truth: @jambonz/schema@0.3.18 verbs/agent.schema.json (llm.vendor.enum)\n// Regenerate with: npm run gen:types\n//\n// This file derives the LLM vendor list from the JSON schema so the SDK's\n// types never drift from the schema when a new vendor is added.\n\n/** Supported LLM vendors for the agent verb, derived from the schema enum. */\nexport const LLM_VENDORS = [\n 'openai',\n 'anthropic',\n 'google',\n 'vertex-gemini',\n 'vertex-openai',\n 'bedrock',\n 'deepseek',\n 'baseten',\n 'azure-openai',\n 'groq',\n 'huggingface',\n 'moonshot',\n 'zai',\n] as const;\n\n/** Union of LLM vendor ids accepted by the agent verb's `llm.vendor`. */\nexport type LlmVendor = (typeof LLM_VENDORS)[number];\n"]}
@@ -1,4 +1,4 @@
1
- import { W as Verb, S as SayVerb, x as PlayVerb, G as GatherVerb, v as LlmVerb, Y as S2sVerb, Z as LlmBaseOptions, _ as DialogflowVerb, e as AgentVerb, p as ListenVerb, N as StreamVerb, U as TranscribeVerb, l as DialVerb, C as ConferenceVerb, $ as RoomVerb, E as EnqueueVerb, D as DequeueVerb, H as HangupVerb, y as RedirectVerb, P as PauseVerb, o as LeaveVerb, z as SipDeclineVerb, K as SipRequestVerb, I as SipReferVerb, k as ConfigVerb, i as AnswerVerb, f as AlertVerb, T as TagVerb, m as DtmfVerb, n as DubVerb, w as MessageVerb } from './verbs-BuObLiyU.js';
1
+ import { $ as Verb, S as SayVerb, y as PlayVerb, G as GatherVerb, w as LlmVerb, a1 as S2sVerb, a2 as LlmBaseOptions, a3 as DialogflowVerb, e as AgentVerb, q as ListenVerb, O as StreamVerb, V as TranscribeVerb, l as DialVerb, C as ConferenceVerb, a4 as RoomVerb, E as EnqueueVerb, D as DequeueVerb, o as HangupVerb, z as RedirectVerb, P as PauseVerb, p as LeaveVerb, I as SipDeclineVerb, N as SipRequestVerb, K as SipReferVerb, Z as TransferVerb, k as ConfigVerb, i as AnswerVerb, f as AlertVerb, T as TagVerb, m as DtmfVerb, n as DubVerb, x as MessageVerb } from './verbs-Bq-MRFKt.js';
2
2
 
3
3
  /**
4
4
  * Schema-based validation using AJV.
@@ -100,6 +100,8 @@ declare class VerbBuilder {
100
100
  sipRequest(opts: Omit<SipRequestVerb, 'verb'>): this;
101
101
  /** Transfer the call via SIP REFER. */
102
102
  sipRefer(opts: Omit<SipReferVerb, 'verb'>): this;
103
+ /** Transfer the caller to a destination (blind, or warm parked/three-way) with built-in failure handling. */
104
+ transfer(opts: Omit<TransferVerb, 'verb'>): this;
103
105
  /** Set session-level defaults (TTS vendor/voice, STT vendor, VAD, etc.). */
104
106
  config(opts: Omit<ConfigVerb, 'verb'>): this;
105
107
  /** Explicitly answer the call (sends a 200 OK). */
@@ -1,4 +1,4 @@
1
- import { W as Verb, S as SayVerb, x as PlayVerb, G as GatherVerb, v as LlmVerb, Y as S2sVerb, Z as LlmBaseOptions, _ as DialogflowVerb, e as AgentVerb, p as ListenVerb, N as StreamVerb, U as TranscribeVerb, l as DialVerb, C as ConferenceVerb, $ as RoomVerb, E as EnqueueVerb, D as DequeueVerb, H as HangupVerb, y as RedirectVerb, P as PauseVerb, o as LeaveVerb, z as SipDeclineVerb, K as SipRequestVerb, I as SipReferVerb, k as ConfigVerb, i as AnswerVerb, f as AlertVerb, T as TagVerb, m as DtmfVerb, n as DubVerb, w as MessageVerb } from './verbs-BuObLiyU.cjs';
1
+ import { $ as Verb, S as SayVerb, y as PlayVerb, G as GatherVerb, w as LlmVerb, a1 as S2sVerb, a2 as LlmBaseOptions, a3 as DialogflowVerb, e as AgentVerb, q as ListenVerb, O as StreamVerb, V as TranscribeVerb, l as DialVerb, C as ConferenceVerb, a4 as RoomVerb, E as EnqueueVerb, D as DequeueVerb, o as HangupVerb, z as RedirectVerb, P as PauseVerb, p as LeaveVerb, I as SipDeclineVerb, N as SipRequestVerb, K as SipReferVerb, Z as TransferVerb, k as ConfigVerb, i as AnswerVerb, f as AlertVerb, T as TagVerb, m as DtmfVerb, n as DubVerb, x as MessageVerb } from './verbs-Bq-MRFKt.cjs';
2
2
 
3
3
  /**
4
4
  * Schema-based validation using AJV.
@@ -100,6 +100,8 @@ declare class VerbBuilder {
100
100
  sipRequest(opts: Omit<SipRequestVerb, 'verb'>): this;
101
101
  /** Transfer the call via SIP REFER. */
102
102
  sipRefer(opts: Omit<SipReferVerb, 'verb'>): this;
103
+ /** Transfer the caller to a destination (blind, or warm parked/three-way) with built-in failure handling. */
104
+ transfer(opts: Omit<TransferVerb, 'verb'>): this;
103
105
  /** Set session-level defaults (TTS vendor/voice, STT vendor, VAD, etc.). */
104
106
  config(opts: Omit<ConfigVerb, 'verb'>): this;
105
107
  /** Explicitly answer the call (sends a 200 OK). */
@@ -252,7 +252,7 @@ interface Amd {
252
252
  }
253
253
 
254
254
  /** Supported LLM vendors for the agent verb, derived from the schema enum. */
255
- declare const LLM_VENDORS: readonly ["openai", "anthropic", "google", "vertex-gemini", "vertex-openai", "bedrock", "deepseek", "baseten", "azure-openai", "groq", "huggingface"];
255
+ declare const LLM_VENDORS: readonly ["openai", "anthropic", "google", "vertex-gemini", "vertex-openai", "bedrock", "deepseek", "baseten", "azure-openai", "groq", "huggingface", "moonshot", "zai"];
256
256
  /** Union of LLM vendor ids accepted by the agent verb's `llm.vendor`. */
257
257
  type LlmVendor = (typeof LLM_VENDORS)[number];
258
258
 
@@ -426,6 +426,18 @@ interface LlmBaseOptions {
426
426
  toolHook?: ActionHook;
427
427
  /** Event types to receive via eventHook. */
428
428
  events?: string[];
429
+ /** Declarative transfer-to-human: injects a transfer tool and runs the packaged transfer when the model calls it. */
430
+ handoff?: Handoff;
431
+ /** Enable the built-in hangup tool for s2s verbs. When present, the runtime injects a 'hangup' tool; when the model calls it the call ends with the reason placed in an X-Reason SIP header (LLM-supplied reason wins, falling back to hangup.reason). */
432
+ hangup?: {
433
+ reason?: string;
434
+ };
435
+ /** Opt-in per-response stall watchdog (ms) for s2s vendors that support app-driven turn-taking. Omit or set to 0 to disable (the default). */
436
+ responseTimeoutMs?: number;
437
+ /** When a response stall is detected (see responseTimeoutMs), cancel the in-progress server-side response. Has no effect unless responseTimeoutMs is set. */
438
+ cancelOnResponseTimeout?: boolean;
439
+ /** On caller barge-in, cancel the in-progress server-side response (app-driven turn-taking configurations). */
440
+ cancelOnBargeIn?: boolean;
429
441
  }
430
442
  interface LlmVerb extends LlmBaseOptions {
431
443
  verb: 'llm';
@@ -530,6 +542,12 @@ interface AgentVerb {
530
542
  eventHook?: ActionHook;
531
543
  /** Webhook when the LLM requests a tool/function call. */
532
544
  toolHook?: ActionHook;
545
+ /** Declarative transfer-to-human: injects a transfer tool and runs the packaged transfer when the model calls it. */
546
+ handoff?: Handoff;
547
+ /** Enable the built-in hangup tool. When present, the runtime injects a 'hangup' tool; when the model calls it the call ends with the reason placed in an X-Reason SIP header (LLM-supplied reason wins, falling back to hangup.reason). */
548
+ hangup?: {
549
+ reason?: string;
550
+ };
533
551
  /** Configuration for playing filler audio while tool calls are in progress. Prevents silence during long-running tool executions. */
534
552
  toolFiller?: false | {
535
553
  /** Filler mode. 'audio' plays a looping audio file. 'backchannel' uses TTS to speak short phrases. */
@@ -848,6 +866,88 @@ interface SipReferVerb {
848
866
  /** Webhook for NOTIFY progress events. */
849
867
  eventHook?: ActionHook;
850
868
  }
869
+ /** Per-outcome fallback actions when a transfer does not complete normally. */
870
+ interface TransferDisposition {
871
+ /** Action when the destination does not answer within timeout. Default: 'return'. */
872
+ onNoAnswer?: 'return' | 'voicemail' | 'hangup';
873
+ /** Action when the destination is busy. Default: 'return'. */
874
+ onBusy?: 'return' | 'voicemail' | 'hangup';
875
+ /** Action when the destination declines (confirm gate failed, AMD machine, or rejection). Default: 'return'. */
876
+ onDecline?: 'return' | 'voicemail' | 'hangup';
877
+ /** Action when a protocol-level error occurs on the destination leg. Default: 'return'. */
878
+ onFailure?: 'return' | 'voicemail' | 'hangup';
879
+ /** SIP URI or HTTP URL for voicemail. Required when any disposition value is 'voicemail'. */
880
+ voicemailUrl?: string;
881
+ }
882
+ /** Human-side acceptance gate: the destination must press a digit to accept. */
883
+ interface TransferConfirm {
884
+ /** Text or URL of the prompt played to the destination. */
885
+ prompt: string;
886
+ /** Single DTMF digit the destination must press to accept. */
887
+ digit: string;
888
+ }
889
+ /**
890
+ * Shared configuration for blind and warm transfer choreography. Reused by the
891
+ * `transfer` verb and the `handoff` block on conversational verbs.
892
+ */
893
+ interface TransferOptions {
894
+ /** 'blind' hands off immediately; 'warm' lets the agent brief the destination first. */
895
+ mode: 'blind' | 'warm';
896
+ /** blind only: 'refer' sends a SIP REFER; 'dial' places a bridged outbound call. Default: 'refer'. */
897
+ blindMethod?: 'refer' | 'dial';
898
+ /** warm only: true = caller joins a three-way conference and hears the brief; false = caller is parked. Default: false. */
899
+ callerPresent?: boolean;
900
+ /** One or more destinations. All are rung simultaneously; first to answer wins. */
901
+ target: Target[];
902
+ /** Caller ID presented to the destination. */
903
+ callerId?: string;
904
+ /** warm/parked only: verbs for the parked caller while the agent briefs the destination. */
905
+ onHoldHook?: ActionHook;
906
+ /** Seconds to wait for the destination to answer before applying onNoAnswer. Default: 30. */
907
+ timeout?: number;
908
+ /** Optional human-side acceptance gate. */
909
+ confirm?: TransferConfirm;
910
+ /** warm only: optional answering-machine detection on the destination leg. */
911
+ amd?: Amd;
912
+ /** Per-outcome fallback actions. */
913
+ disposition?: TransferDisposition;
914
+ /** Fires when the transfer resolves (bridged, returned, voicemail, or failed). */
915
+ actionHook?: ActionHook;
916
+ /** Optional hook for in-progress transfer events (ringing, brief started). */
917
+ eventHook?: ActionHook;
918
+ }
919
+ /**
920
+ * Declarative transfer-to-human config for conversational verbs (`agent`, `llm`/`s2s`).
921
+ * The runtime injects a `transfer_to_human` tool and runs the packaged transfer
922
+ * choreography when the model calls it.
923
+ */
924
+ interface Handoff extends TransferOptions {
925
+ /** 'auto' = LLM writes the summary; 'none' = no spoken brief; {template} = guidance for the summary. Default: 'auto'. */
926
+ brief?: 'auto' | 'none' | {
927
+ template: string;
928
+ };
929
+ /** Optional voice/vendor for the spoken brief. Defaults to the session synthesizer. */
930
+ briefSynthesizer?: Synthesizer;
931
+ /** Override the injected tool name. Default: 'transfer_to_human'. */
932
+ toolName?: string;
933
+ /** Override the injected tool description shown to the LLM. */
934
+ toolDescription?: string;
935
+ }
936
+ /**
937
+ * Packaged blind and warm (parked / three-way) transfer with built-in failure
938
+ * handling. Composes {@link TransferOptions} for the shared choreography.
939
+ */
940
+ interface TransferVerb extends TransferOptions {
941
+ verb: 'transfer';
942
+ id?: string;
943
+ /** warm only: the spoken summary delivered to the destination (human). */
944
+ brief?: {
945
+ /** The spoken briefing text. */
946
+ text: string;
947
+ /** Optional voice/vendor for the brief. Defaults to the session synthesizer. */
948
+ synthesizer?: Synthesizer;
949
+ };
950
+ }
851
951
  interface ConfigVerb {
852
952
  verb: 'config';
853
953
  id?: string;
@@ -982,10 +1082,10 @@ interface MessageVerb {
982
1082
  actionHook?: ActionHook;
983
1083
  }
984
1084
  /** Any jambonz verb. Discriminated on the 'verb' property. */
985
- type Verb = AnswerVerb | AlertVerb | ConfigVerb | SayVerb | PlayVerb | GatherVerb | DialVerb | ListenVerb | StreamVerb | LlmVerb | S2sVerb | OpenaiS2sVerb | GoogleS2sVerb | ElevenlabsS2sVerb | DeepgramS2sVerb | UltravoxS2sVerb | DialogflowVerb | AgentVerb | ConferenceVerb | RoomVerb | TranscribeVerb | EnqueueVerb | DequeueVerb | DtmfVerb | DubVerb | HangupVerb | LeaveVerb | MessageVerb | PauseVerb | RedirectVerb | TagVerb | SipDeclineVerb | SipRequestVerb | SipReferVerb;
1085
+ type Verb = AnswerVerb | AlertVerb | ConfigVerb | SayVerb | PlayVerb | GatherVerb | DialVerb | ListenVerb | StreamVerb | LlmVerb | S2sVerb | OpenaiS2sVerb | GoogleS2sVerb | ElevenlabsS2sVerb | DeepgramS2sVerb | UltravoxS2sVerb | DialogflowVerb | AgentVerb | ConferenceVerb | RoomVerb | TranscribeVerb | EnqueueVerb | DequeueVerb | DtmfVerb | DubVerb | HangupVerb | LeaveVerb | MessageVerb | PauseVerb | RedirectVerb | TagVerb | SipDeclineVerb | SipRequestVerb | SipReferVerb | TransferVerb;
986
1086
  /** A jambonz application — an array of verbs executed sequentially. */
987
1087
  type JambonzApp = Verb[];
988
1088
  /** All valid verb names. */
989
1089
  type VerbName = Verb['verb'];
990
1090
 
991
- export { type RoomVerb as $, type ActionHook as A, type BidirectionalAudio as B, type ConferenceVerb as C, type DequeueVerb as D, type EnqueueVerb as E, type FillerNoise as F, type GatherVerb as G, type HangupVerb as H, type SipReferVerb as I, type JambonzApp as J, type SipRequestVerb as K, LLM_VENDORS as L, type McpServerConfig as M, type StreamVerb as N, type Synthesizer as O, type PauseVerb as P, type Target as Q, type Recognizer as R, type SayVerb as S, type TagVerb as T, type TranscribeVerb as U, type Vad as V, type Verb as W, type VerbName as X, type S2sVerb as Y, type LlmBaseOptions as Z, type DialogflowVerb as _, type ActionHookDelayAction as a, type ActionHookObject as b, type AgentLlm as c, type AgentLlmOptions as d, type AgentVerb as e, type AlertVerb as f, type Amd as g, type AmdTimers as h, type AnswerVerb as i, type Auth as j, type ConfigVerb as k, type DialVerb as l, type DtmfVerb as m, type DubVerb as n, type LeaveVerb as o, type ListenVerb as p, type LlmMessage as q, type LlmTool as r, type LlmToolOpenAIWrapped as s, type LlmToolOutputData as t, type LlmVendor as u, type LlmVerb as v, type MessageVerb as w, type PlayVerb as x, type RedirectVerb as y, type SipDeclineVerb as z };
1091
+ export { type Verb as $, type ActionHook as A, type BidirectionalAudio as B, type ConferenceVerb as C, type DequeueVerb as D, type EnqueueVerb as E, type FillerNoise as F, type GatherVerb as G, type Handoff as H, type SipDeclineVerb as I, type JambonzApp as J, type SipReferVerb as K, LLM_VENDORS as L, type McpServerConfig as M, type SipRequestVerb as N, type StreamVerb as O, type PauseVerb as P, type Synthesizer as Q, type Recognizer as R, type SayVerb as S, type TagVerb as T, type Target as U, type TranscribeVerb as V, type TransferConfirm as W, type TransferDisposition as X, type TransferOptions as Y, type TransferVerb as Z, type Vad as _, type ActionHookDelayAction as a, type VerbName as a0, type S2sVerb as a1, type LlmBaseOptions as a2, type DialogflowVerb as a3, type RoomVerb as a4, type ActionHookObject as b, type AgentLlm as c, type AgentLlmOptions as d, type AgentVerb as e, type AlertVerb as f, type Amd as g, type AmdTimers as h, type AnswerVerb as i, type Auth as j, type ConfigVerb as k, type DialVerb as l, type DtmfVerb as m, type DubVerb as n, type HangupVerb as o, type LeaveVerb as p, type ListenVerb as q, type LlmMessage as r, type LlmTool as s, type LlmToolOpenAIWrapped as t, type LlmToolOutputData as u, type LlmVendor as v, type LlmVerb as w, type MessageVerb as x, type PlayVerb as y, type RedirectVerb as z };
@@ -252,7 +252,7 @@ interface Amd {
252
252
  }
253
253
 
254
254
  /** Supported LLM vendors for the agent verb, derived from the schema enum. */
255
- declare const LLM_VENDORS: readonly ["openai", "anthropic", "google", "vertex-gemini", "vertex-openai", "bedrock", "deepseek", "baseten", "azure-openai", "groq", "huggingface"];
255
+ declare const LLM_VENDORS: readonly ["openai", "anthropic", "google", "vertex-gemini", "vertex-openai", "bedrock", "deepseek", "baseten", "azure-openai", "groq", "huggingface", "moonshot", "zai"];
256
256
  /** Union of LLM vendor ids accepted by the agent verb's `llm.vendor`. */
257
257
  type LlmVendor = (typeof LLM_VENDORS)[number];
258
258
 
@@ -426,6 +426,18 @@ interface LlmBaseOptions {
426
426
  toolHook?: ActionHook;
427
427
  /** Event types to receive via eventHook. */
428
428
  events?: string[];
429
+ /** Declarative transfer-to-human: injects a transfer tool and runs the packaged transfer when the model calls it. */
430
+ handoff?: Handoff;
431
+ /** Enable the built-in hangup tool for s2s verbs. When present, the runtime injects a 'hangup' tool; when the model calls it the call ends with the reason placed in an X-Reason SIP header (LLM-supplied reason wins, falling back to hangup.reason). */
432
+ hangup?: {
433
+ reason?: string;
434
+ };
435
+ /** Opt-in per-response stall watchdog (ms) for s2s vendors that support app-driven turn-taking. Omit or set to 0 to disable (the default). */
436
+ responseTimeoutMs?: number;
437
+ /** When a response stall is detected (see responseTimeoutMs), cancel the in-progress server-side response. Has no effect unless responseTimeoutMs is set. */
438
+ cancelOnResponseTimeout?: boolean;
439
+ /** On caller barge-in, cancel the in-progress server-side response (app-driven turn-taking configurations). */
440
+ cancelOnBargeIn?: boolean;
429
441
  }
430
442
  interface LlmVerb extends LlmBaseOptions {
431
443
  verb: 'llm';
@@ -530,6 +542,12 @@ interface AgentVerb {
530
542
  eventHook?: ActionHook;
531
543
  /** Webhook when the LLM requests a tool/function call. */
532
544
  toolHook?: ActionHook;
545
+ /** Declarative transfer-to-human: injects a transfer tool and runs the packaged transfer when the model calls it. */
546
+ handoff?: Handoff;
547
+ /** Enable the built-in hangup tool. When present, the runtime injects a 'hangup' tool; when the model calls it the call ends with the reason placed in an X-Reason SIP header (LLM-supplied reason wins, falling back to hangup.reason). */
548
+ hangup?: {
549
+ reason?: string;
550
+ };
533
551
  /** Configuration for playing filler audio while tool calls are in progress. Prevents silence during long-running tool executions. */
534
552
  toolFiller?: false | {
535
553
  /** Filler mode. 'audio' plays a looping audio file. 'backchannel' uses TTS to speak short phrases. */
@@ -848,6 +866,88 @@ interface SipReferVerb {
848
866
  /** Webhook for NOTIFY progress events. */
849
867
  eventHook?: ActionHook;
850
868
  }
869
+ /** Per-outcome fallback actions when a transfer does not complete normally. */
870
+ interface TransferDisposition {
871
+ /** Action when the destination does not answer within timeout. Default: 'return'. */
872
+ onNoAnswer?: 'return' | 'voicemail' | 'hangup';
873
+ /** Action when the destination is busy. Default: 'return'. */
874
+ onBusy?: 'return' | 'voicemail' | 'hangup';
875
+ /** Action when the destination declines (confirm gate failed, AMD machine, or rejection). Default: 'return'. */
876
+ onDecline?: 'return' | 'voicemail' | 'hangup';
877
+ /** Action when a protocol-level error occurs on the destination leg. Default: 'return'. */
878
+ onFailure?: 'return' | 'voicemail' | 'hangup';
879
+ /** SIP URI or HTTP URL for voicemail. Required when any disposition value is 'voicemail'. */
880
+ voicemailUrl?: string;
881
+ }
882
+ /** Human-side acceptance gate: the destination must press a digit to accept. */
883
+ interface TransferConfirm {
884
+ /** Text or URL of the prompt played to the destination. */
885
+ prompt: string;
886
+ /** Single DTMF digit the destination must press to accept. */
887
+ digit: string;
888
+ }
889
+ /**
890
+ * Shared configuration for blind and warm transfer choreography. Reused by the
891
+ * `transfer` verb and the `handoff` block on conversational verbs.
892
+ */
893
+ interface TransferOptions {
894
+ /** 'blind' hands off immediately; 'warm' lets the agent brief the destination first. */
895
+ mode: 'blind' | 'warm';
896
+ /** blind only: 'refer' sends a SIP REFER; 'dial' places a bridged outbound call. Default: 'refer'. */
897
+ blindMethod?: 'refer' | 'dial';
898
+ /** warm only: true = caller joins a three-way conference and hears the brief; false = caller is parked. Default: false. */
899
+ callerPresent?: boolean;
900
+ /** One or more destinations. All are rung simultaneously; first to answer wins. */
901
+ target: Target[];
902
+ /** Caller ID presented to the destination. */
903
+ callerId?: string;
904
+ /** warm/parked only: verbs for the parked caller while the agent briefs the destination. */
905
+ onHoldHook?: ActionHook;
906
+ /** Seconds to wait for the destination to answer before applying onNoAnswer. Default: 30. */
907
+ timeout?: number;
908
+ /** Optional human-side acceptance gate. */
909
+ confirm?: TransferConfirm;
910
+ /** warm only: optional answering-machine detection on the destination leg. */
911
+ amd?: Amd;
912
+ /** Per-outcome fallback actions. */
913
+ disposition?: TransferDisposition;
914
+ /** Fires when the transfer resolves (bridged, returned, voicemail, or failed). */
915
+ actionHook?: ActionHook;
916
+ /** Optional hook for in-progress transfer events (ringing, brief started). */
917
+ eventHook?: ActionHook;
918
+ }
919
+ /**
920
+ * Declarative transfer-to-human config for conversational verbs (`agent`, `llm`/`s2s`).
921
+ * The runtime injects a `transfer_to_human` tool and runs the packaged transfer
922
+ * choreography when the model calls it.
923
+ */
924
+ interface Handoff extends TransferOptions {
925
+ /** 'auto' = LLM writes the summary; 'none' = no spoken brief; {template} = guidance for the summary. Default: 'auto'. */
926
+ brief?: 'auto' | 'none' | {
927
+ template: string;
928
+ };
929
+ /** Optional voice/vendor for the spoken brief. Defaults to the session synthesizer. */
930
+ briefSynthesizer?: Synthesizer;
931
+ /** Override the injected tool name. Default: 'transfer_to_human'. */
932
+ toolName?: string;
933
+ /** Override the injected tool description shown to the LLM. */
934
+ toolDescription?: string;
935
+ }
936
+ /**
937
+ * Packaged blind and warm (parked / three-way) transfer with built-in failure
938
+ * handling. Composes {@link TransferOptions} for the shared choreography.
939
+ */
940
+ interface TransferVerb extends TransferOptions {
941
+ verb: 'transfer';
942
+ id?: string;
943
+ /** warm only: the spoken summary delivered to the destination (human). */
944
+ brief?: {
945
+ /** The spoken briefing text. */
946
+ text: string;
947
+ /** Optional voice/vendor for the brief. Defaults to the session synthesizer. */
948
+ synthesizer?: Synthesizer;
949
+ };
950
+ }
851
951
  interface ConfigVerb {
852
952
  verb: 'config';
853
953
  id?: string;
@@ -982,10 +1082,10 @@ interface MessageVerb {
982
1082
  actionHook?: ActionHook;
983
1083
  }
984
1084
  /** Any jambonz verb. Discriminated on the 'verb' property. */
985
- type Verb = AnswerVerb | AlertVerb | ConfigVerb | SayVerb | PlayVerb | GatherVerb | DialVerb | ListenVerb | StreamVerb | LlmVerb | S2sVerb | OpenaiS2sVerb | GoogleS2sVerb | ElevenlabsS2sVerb | DeepgramS2sVerb | UltravoxS2sVerb | DialogflowVerb | AgentVerb | ConferenceVerb | RoomVerb | TranscribeVerb | EnqueueVerb | DequeueVerb | DtmfVerb | DubVerb | HangupVerb | LeaveVerb | MessageVerb | PauseVerb | RedirectVerb | TagVerb | SipDeclineVerb | SipRequestVerb | SipReferVerb;
1085
+ type Verb = AnswerVerb | AlertVerb | ConfigVerb | SayVerb | PlayVerb | GatherVerb | DialVerb | ListenVerb | StreamVerb | LlmVerb | S2sVerb | OpenaiS2sVerb | GoogleS2sVerb | ElevenlabsS2sVerb | DeepgramS2sVerb | UltravoxS2sVerb | DialogflowVerb | AgentVerb | ConferenceVerb | RoomVerb | TranscribeVerb | EnqueueVerb | DequeueVerb | DtmfVerb | DubVerb | HangupVerb | LeaveVerb | MessageVerb | PauseVerb | RedirectVerb | TagVerb | SipDeclineVerb | SipRequestVerb | SipReferVerb | TransferVerb;
986
1086
  /** A jambonz application — an array of verbs executed sequentially. */
987
1087
  type JambonzApp = Verb[];
988
1088
  /** All valid verb names. */
989
1089
  type VerbName = Verb['verb'];
990
1090
 
991
- export { type RoomVerb as $, type ActionHook as A, type BidirectionalAudio as B, type ConferenceVerb as C, type DequeueVerb as D, type EnqueueVerb as E, type FillerNoise as F, type GatherVerb as G, type HangupVerb as H, type SipReferVerb as I, type JambonzApp as J, type SipRequestVerb as K, LLM_VENDORS as L, type McpServerConfig as M, type StreamVerb as N, type Synthesizer as O, type PauseVerb as P, type Target as Q, type Recognizer as R, type SayVerb as S, type TagVerb as T, type TranscribeVerb as U, type Vad as V, type Verb as W, type VerbName as X, type S2sVerb as Y, type LlmBaseOptions as Z, type DialogflowVerb as _, type ActionHookDelayAction as a, type ActionHookObject as b, type AgentLlm as c, type AgentLlmOptions as d, type AgentVerb as e, type AlertVerb as f, type Amd as g, type AmdTimers as h, type AnswerVerb as i, type Auth as j, type ConfigVerb as k, type DialVerb as l, type DtmfVerb as m, type DubVerb as n, type LeaveVerb as o, type ListenVerb as p, type LlmMessage as q, type LlmTool as r, type LlmToolOpenAIWrapped as s, type LlmToolOutputData as t, type LlmVendor as u, type LlmVerb as v, type MessageVerb as w, type PlayVerb as x, type RedirectVerb as y, type SipDeclineVerb as z };
1091
+ export { type Verb as $, type ActionHook as A, type BidirectionalAudio as B, type ConferenceVerb as C, type DequeueVerb as D, type EnqueueVerb as E, type FillerNoise as F, type GatherVerb as G, type Handoff as H, type SipDeclineVerb as I, type JambonzApp as J, type SipReferVerb as K, LLM_VENDORS as L, type McpServerConfig as M, type SipRequestVerb as N, type StreamVerb as O, type PauseVerb as P, type Synthesizer as Q, type Recognizer as R, type SayVerb as S, type TagVerb as T, type Target as U, type TranscribeVerb as V, type TransferConfirm as W, type TransferDisposition as X, type TransferOptions as Y, type TransferVerb as Z, type Vad as _, type ActionHookDelayAction as a, type VerbName as a0, type S2sVerb as a1, type LlmBaseOptions as a2, type DialogflowVerb as a3, type RoomVerb as a4, type ActionHookObject as b, type AgentLlm as c, type AgentLlmOptions as d, type AgentVerb as e, type AlertVerb as f, type Amd as g, type AmdTimers as h, type AnswerVerb as i, type Auth as j, type ConfigVerb as k, type DialVerb as l, type DtmfVerb as m, type DubVerb as n, type HangupVerb as o, type LeaveVerb as p, type ListenVerb as q, type LlmMessage as r, type LlmTool as s, type LlmToolOpenAIWrapped as t, type LlmToolOutputData as u, type LlmVendor as v, type LlmVerb as w, type MessageVerb as x, type PlayVerb as y, type RedirectVerb as z };
@@ -222,6 +222,10 @@ var VerbBuilder = class {
222
222
  sipRefer(opts) {
223
223
  return this.addVerb({ verb: "sip:refer", ...opts });
224
224
  }
225
+ /** Transfer the caller to a destination (blind, or warm parked/three-way) with built-in failure handling. */
226
+ transfer(opts) {
227
+ return this.addVerb({ verb: "transfer", ...opts });
228
+ }
225
229
  // --- Utility ---
226
230
  /** Set session-level defaults (TTS vendor/voice, STT vendor, VAD, etc.). */
227
231
  config(opts) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/validator.ts","../../src/verb-builder.ts","../../src/webhook/response.ts","../../src/webhook/env-vars.ts"],"names":["createRequire","dir","resolve","existsSync","dirname","fileURLToPath","readdirSync","basename","readFileSync","Ajv","create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schemas from the @jambonz/schema package.\n */\n\nimport Ajv, { type ValidateFunction, type ErrorObject } from 'ajv';\nimport { readFileSync, readdirSync, existsSync } from 'fs';\nimport { resolve, dirname, basename } from 'path';\nimport { fileURLToPath } from 'url';\nimport { createRequire } from 'module';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ValidationError[];\n}\n\nexport interface ValidationError {\n path: string;\n message: string;\n}\n\n/** Locate the @jambonz/schema package directory. */\nfunction findSchemaDir(): string {\n // Method 1: use createRequire to resolve the package\n try {\n const req = createRequire(import.meta.url);\n const schemaIndex = req.resolve('@jambonz/schema');\n const dir = resolve(schemaIndex, '..');\n if (existsSync(resolve(dir, 'jambonz-app.schema.json'))) {\n return dir;\n }\n } catch {\n // fall through\n }\n\n // Method 2: walk up from this file to find node_modules/@jambonz/schema\n const currentDir = typeof __dirname !== 'undefined'\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\n let dir = currentDir;\n for (let i = 0; i < 10; i++) {\n const candidate = resolve(dir, 'node_modules', '@jambonz', 'schema');\n if (existsSync(resolve(candidate, 'jambonz-app.schema.json'))) {\n return candidate;\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n throw new Error(\n 'Could not find @jambonz/schema package. Ensure it is installed as a dependency.'\n );\n}\n\n/** Discover schema files in a subdirectory. */\nfunction discoverSchemas(dir: string): string[] {\n try {\n return readdirSync(dir)\n .filter((f) => f.endsWith('.schema.json'))\n .map((f) => basename(f, '.schema.json'));\n } catch {\n return [];\n }\n}\n\nfunction loadSchema(filePath: string): Record<string, unknown> {\n return JSON.parse(readFileSync(filePath, 'utf-8')) as Record<string, unknown>;\n}\n\nexport class JambonzValidator {\n private validateApp: ValidateFunction;\n private ajv: Ajv;\n\n constructor(schemaDir?: string) {\n const dir = schemaDir ?? findSchemaDir();\n this.ajv = new Ajv({\n allErrors: true,\n strict: false,\n validateSchema: false,\n logger: false,\n });\n\n // Register component schemas first (they are referenced by verb schemas)\n const componentsDir = resolve(dir, 'components');\n for (const name of discoverSchemas(componentsDir)) {\n const schema = loadSchema(resolve(componentsDir, `${name}.schema.json`));\n this.ajv.addSchema(schema);\n }\n\n // Register verb schemas\n const verbsDir = resolve(dir, 'verbs');\n for (const name of discoverSchemas(verbsDir)) {\n const schema = loadSchema(resolve(verbsDir, `${name}.schema.json`));\n this.ajv.addSchema(schema);\n }\n\n // Compile the root app schema\n const appSchema = loadSchema(resolve(dir, 'jambonz-app.schema.json'));\n this.validateApp = this.ajv.compile(appSchema);\n }\n\n /** Validate a complete verb array (a jambonz application). */\n validate(app: unknown): ValidationResult {\n const valid = this.validateApp(app);\n if (valid) {\n return { valid: true, errors: [] };\n }\n return {\n valid: false,\n errors: formatErrors(this.validateApp.errors),\n };\n }\n\n /** Validate a single verb object. */\n validateVerb(verb: unknown): ValidationResult {\n // Wrap in an array and validate as an app\n return this.validate([verb]);\n }\n}\n\nfunction formatErrors(errors: ErrorObject[] | null | undefined): ValidationError[] {\n if (!errors) return [];\n return errors.map((err) => ({\n path: err.instancePath || '/',\n message: err.message || 'Unknown validation error',\n }));\n}\n\nlet _defaultValidator: JambonzValidator | null = null;\n\n/** Get a shared validator instance. */\nexport function getValidator(schemaDir?: string): JambonzValidator {\n if (!_defaultValidator) {\n _defaultValidator = new JambonzValidator(schemaDir);\n }\n return _defaultValidator;\n}\n","/**\n * Shared VerbBuilder base class.\n * Provides typed verb methods and raw JSON input for both WebhookResponse and WS Session.\n */\n\nimport type {\n AgentVerb,\n AlertVerb,\n AnswerVerb,\n ConferenceVerb,\n ConfigVerb,\n DequeueVerb,\n DialogflowVerb,\n DialVerb,\n DtmfVerb,\n DubVerb,\n EnqueueVerb,\n GatherVerb,\n HangupVerb,\n LeaveVerb,\n ListenVerb,\n LlmBaseOptions,\n LlmVerb,\n MessageVerb,\n PauseVerb,\n PlayVerb,\n RedirectVerb,\n RoomVerb,\n S2sVerb,\n SayVerb,\n SipDeclineVerb,\n SipReferVerb,\n SipRequestVerb,\n StreamVerb,\n TagVerb,\n TranscribeVerb,\n Verb,\n} from './types/verbs.js';\nimport { JambonzValidator } from './validator.js';\n\nexport interface VerbBuilderOptions {\n /** Enable runtime schema validation. Default: true. */\n validate?: boolean;\n /** Path to schema directory. Auto-detected if omitted. */\n schemaDir?: string;\n}\n\n/**\n * Base class for building jambonz verb arrays. Extended by {@link WebhookResponse}\n * and WsSession. Provides typed verb methods and optional runtime schema validation.\n */\nexport class VerbBuilder {\n protected verbs: Verb[] = [];\n protected validator: JambonzValidator | null;\n\n /**\n * @param opts - Options for validation and schema directory.\n */\n constructor(opts?: VerbBuilderOptions) {\n if (opts?.validate === false) {\n this.validator = null;\n } else {\n this.validator = new JambonzValidator(opts?.schemaDir);\n }\n }\n\n // --- Audio & Speech ---\n\n /** Speak text using TTS. Supports SSML, multiple voices, and streaming. */\n say(opts: Omit<SayVerb, 'verb'>): this {\n return this.addVerb({ verb: 'say', ...opts });\n }\n\n /** Play an audio file from a URL. */\n play(opts: Omit<PlayVerb, 'verb'>): this {\n return this.addVerb({ verb: 'play', ...opts });\n }\n\n /** Collect speech (STT) and/or DTMF input from the caller. */\n gather(opts: Omit<GatherVerb, 'verb'>): this {\n return this.addVerb({ verb: 'gather', ...opts });\n }\n\n // --- AI & Real-time ---\n\n /** Connect the caller to an LLM for real-time voice conversation. */\n llm(opts: Omit<LlmVerb, 'verb'>): this {\n return this.addVerb({ verb: 'llm', ...opts });\n }\n\n /** Synonym for {@link llm}. Requires vendor to be specified. */\n s2s(opts: Omit<S2sVerb, 'verb'>): this {\n return this.addVerb({ verb: 's2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='openai'. */\n openai_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'openai_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='google'. */\n google_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'google_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='elevenlabs'. */\n elevenlabs_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'elevenlabs_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='deepgram'. */\n deepgram_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'deepgram_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='ultravox'. */\n ultravox_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'ultravox_s2s', ...opts });\n }\n\n /** Connect the caller to a Google Dialogflow agent (ES, CX, or CES). */\n dialogflow(opts: Omit<DialogflowVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dialogflow', ...opts });\n }\n\n /** Voice AI agent with integrated turn detection. */\n agent(opts: Omit<AgentVerb, 'verb'>): this {\n return this.addVerb({ verb: 'agent', ...opts });\n }\n\n /** Stream real-time call audio to a WebSocket endpoint. Supports bidirectional audio. */\n listen(opts: Omit<ListenVerb, 'verb'>): this {\n return this.addVerb({ verb: 'listen', ...opts });\n }\n\n /** Stream real-time call audio to a WebSocket endpoint. Synonym for {@link listen}. */\n stream(opts: Omit<StreamVerb, 'verb'>): this {\n return this.addVerb({ verb: 'stream', ...opts });\n }\n\n /** Real-time call transcription sent to a webhook. */\n transcribe(opts: Omit<TranscribeVerb, 'verb'>): this {\n return this.addVerb({ verb: 'transcribe', ...opts });\n }\n\n // --- Call Control ---\n\n /** Place an outbound call and bridge it to the current caller. */\n dial(opts: Omit<DialVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dial', ...opts });\n }\n\n /** Join or create a multi-party conference room. */\n conference(opts: Omit<ConferenceVerb, 'verb'>): this {\n return this.addVerb({ verb: 'conference', ...opts });\n }\n\n /** `room` is a synonym for `conference` — prefer it in new applications. */\n room(opts: Omit<RoomVerb, 'verb'>): this {\n return this.addVerb({ verb: 'room', ...opts });\n }\n\n /** Place the caller into a named queue. */\n enqueue(opts: Omit<EnqueueVerb, 'verb'>): this {\n return this.addVerb({ verb: 'enqueue', ...opts });\n }\n\n /** Remove a caller from a queue and bridge them. */\n dequeue(opts: Omit<DequeueVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dequeue', ...opts });\n }\n\n /** End the call. */\n hangup(opts?: Omit<HangupVerb, 'verb'>): this {\n return this.addVerb({ verb: 'hangup', ...opts });\n }\n\n /** Transfer control to a different webhook URL. */\n redirect(opts: Omit<RedirectVerb, 'verb'>): this {\n return this.addVerb({ verb: 'redirect', ...opts });\n }\n\n /** Wait for a specified duration before continuing. */\n pause(opts: Omit<PauseVerb, 'verb'>): this {\n return this.addVerb({ verb: 'pause', ...opts });\n }\n\n /** Leave a conference or queue. */\n leave(opts?: Omit<LeaveVerb, 'verb'>): this {\n return this.addVerb({ verb: 'leave', ...opts });\n }\n\n // --- SIP ---\n\n /** Reject an incoming call with a SIP error response. */\n sipDecline(opts: Omit<SipDeclineVerb, 'verb'>): this {\n return this.addVerb({ verb: 'sip:decline', ...opts });\n }\n\n /** Send a SIP INFO or other request within the dialog. */\n sipRequest(opts: Omit<SipRequestVerb, 'verb'>): this {\n return this.addVerb({ verb: 'sip:request', ...opts });\n }\n\n /** Transfer the call via SIP REFER. */\n sipRefer(opts: Omit<SipReferVerb, 'verb'>): this {\n return this.addVerb({ verb: 'sip:refer', ...opts });\n }\n\n // --- Utility ---\n\n /** Set session-level defaults (TTS vendor/voice, STT vendor, VAD, etc.). */\n config(opts: Omit<ConfigVerb, 'verb'>): this {\n return this.addVerb({ verb: 'config', ...opts });\n }\n\n /** Explicitly answer the call (sends a 200 OK). */\n answer(opts?: Omit<AnswerVerb, 'verb'>): this {\n return this.addVerb({ verb: 'answer', ...opts });\n }\n\n /** Send a SIP 180 Ringing with optional Alert-Info header. */\n alert(opts: Omit<AlertVerb, 'verb'>): this {\n return this.addVerb({ verb: 'alert', ...opts });\n }\n\n /** Attach metadata to the call for tracking or routing. */\n tag(opts: Omit<TagVerb, 'verb'>): this {\n return this.addVerb({ verb: 'tag', ...opts });\n }\n\n /** Send DTMF tones into the call. */\n dtmf(opts: Omit<DtmfVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dtmf', ...opts });\n }\n\n /** Mix an auxiliary audio track into the call. */\n dub(opts: Omit<DubVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dub', ...opts });\n }\n\n /** Send an SMS or MMS message. */\n message(opts: Omit<MessageVerb, 'verb'>): this {\n return this.addVerb({ verb: 'message', ...opts });\n }\n\n // --- Raw JSON input (primary AI agent path) ---\n\n /**\n * Add one or more verbs from raw JSON.\n * Validates against the JSON schemas at runtime if validation is enabled.\n */\n addVerbs(verbs: Verb[]): this {\n if (this.validator) {\n const result = this.validator.validate(verbs);\n if (!result.valid) {\n const messages = result.errors.map((e) => `${e.path}: ${e.message}`).join('; ');\n throw new Error(`Verb validation failed: ${messages}`);\n }\n }\n this.verbs.push(...verbs);\n return this;\n }\n\n // --- Internal ---\n\n protected addVerb(verb: Verb): this {\n if (this.validator) {\n const result = this.validator.validateVerb(verb);\n if (!result.valid) {\n const messages = result.errors.map((e) => `${e.path}: ${e.message}`).join('; ');\n throw new Error(`Verb '${verb.verb}' validation failed: ${messages}`);\n }\n }\n this.verbs.push(verb);\n return this;\n }\n\n /** Get the current verb count. */\n get length(): number {\n return this.verbs.length;\n }\n\n /** Clear all queued verbs. */\n clear(): this {\n this.verbs = [];\n return this;\n }\n\n /** Returns a copy of the current verb array. */\n toJSON(): Verb[] {\n return [...this.verbs];\n }\n}\n","/**\n * WebhookResponse — verb builder for HTTP webhook applications.\n * Extends VerbBuilder with toJSON() and signature verification.\n */\n\nimport { createHmac, timingSafeEqual } from 'crypto';\nimport { VerbBuilder, type VerbBuilderOptions } from '../verb-builder.js';\nimport type { JambonzApp } from '../types/verbs.js';\nimport type { IncomingMessage, ServerResponse } from 'http';\n\n/**\n * Verb builder for HTTP webhook applications.\n * Construct one per request, chain verb methods, and pass to `res.json()`.\n *\n * @example\n * ```typescript\n * app.post('/incoming', (req, res) => {\n * const jambonz = new WebhookResponse();\n * jambonz.say({ text: 'Hello!' }).hangup();\n * res.json(jambonz);\n * });\n * ```\n */\nexport class WebhookResponse extends VerbBuilder {\n /** @param opts - Options for validation and schema directory. */\n constructor(opts?: VerbBuilderOptions) {\n super(opts);\n }\n\n /** Returns the verb array for JSON serialization. */\n toJSON(): JambonzApp {\n return [...this.verbs];\n }\n\n /**\n * Express-compatible middleware for verifying jambonz webhook signatures.\n * Uses HMAC-SHA256 with timing-safe comparison.\n */\n static verifySignature(secret: string, opts?: { tolerance?: number }) {\n const tolerance = opts?.tolerance ?? 300; // 5 minutes default\n\n return (\n req: IncomingMessage & { body?: unknown; rawBody?: Buffer },\n _res: ServerResponse,\n next: (err?: Error) => void\n ) => {\n try {\n const signature = (req.headers as Record<string, string | undefined>)['jambonz-signature'];\n if (!signature) {\n throw new Error('Missing Jambonz-Signature header');\n }\n\n const parts = signature.split(',');\n let timestamp = '';\n const signatures: string[] = [];\n\n for (const part of parts) {\n const [key, value] = part.split('=');\n if (key === 't') timestamp = value;\n else if (key === 'v1') signatures.push(value);\n }\n\n if (!timestamp || signatures.length === 0) {\n throw new Error('Invalid Jambonz-Signature format');\n }\n\n // Check timestamp tolerance\n const ts = parseInt(timestamp, 10);\n const now = Math.floor(Date.now() / 1000);\n if (Math.abs(now - ts) > tolerance) {\n throw new Error('Webhook signature timestamp outside tolerance');\n }\n\n // Compute expected signature\n const payload = typeof req.body === 'string'\n ? req.body\n : JSON.stringify(req.body);\n const signedPayload = `${timestamp}.${payload}`;\n const expected = createHmac('sha256', secret)\n .update(signedPayload)\n .digest('hex');\n\n // Timing-safe comparison\n const matched = signatures.some((sig) => {\n try {\n return timingSafeEqual(Buffer.from(sig), Buffer.from(expected));\n } catch {\n return false;\n }\n });\n\n if (!matched) {\n throw new Error('Webhook signature verification failed');\n }\n\n next();\n } catch (err) {\n next(err instanceof Error ? err : new Error(String(err)));\n }\n };\n }\n}\n","/**\n * Express middleware that auto-responds to HTTP OPTIONS requests with the\n * application environment variables schema for jambonz portal discovery.\n */\n\nimport type { EnvVarSchema } from '../types/common.js';\n\n/**\n * Express middleware that auto-responds to HTTP OPTIONS requests with the\n * application's environment variable schema, enabling jambonz portal discovery.\n *\n * @param schema - The environment variable schema to expose.\n *\n * @example\n * ```typescript\n * import { envVarsMiddleware } from '@jambonz/sdk/webhook';\n *\n * const envVars = {\n * API_KEY: { type: 'string', description: 'Your API key', required: true },\n * };\n * app.use(envVarsMiddleware(envVars));\n * ```\n */\nexport function envVarsMiddleware(schema: EnvVarSchema) {\n return (req: { method: string }, res: { json: (body: unknown) => void }, next: () => void) => {\n if (req.method === 'OPTIONS') {\n res.json(schema);\n return;\n }\n next();\n };\n}\n"]}
1
+ {"version":3,"sources":["../../src/validator.ts","../../src/verb-builder.ts","../../src/webhook/response.ts","../../src/webhook/env-vars.ts"],"names":["createRequire","dir","resolve","existsSync","dirname","fileURLToPath","readdirSync","basename","readFileSync","Ajv","createHmac","timingSafeEqual"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAS,aAAA,GAAwB;AAE/B,EAAA,IAAI;AACF,IAAA,MAAM,GAAA,GAAMA,sBAAA,CAAc,2PAAe,CAAA;AACzC,IAAA,MAAM,WAAA,GAAc,GAAA,CAAI,OAAA,CAAQ,iBAAiB,CAAA;AACjD,IAAA,MAAMC,IAAAA,GAAMC,YAAA,CAAQ,WAAA,EAAa,IAAI,CAAA;AACrC,IAAA,IAAIC,aAAA,CAAWD,YAAA,CAAQD,IAAAA,EAAK,yBAAyB,CAAC,CAAA,EAAG;AACvD,MAAA,OAAOA,IAAAA;AAAA,IACT;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AAGA,EAAA,MAAM,UAAA,GAAa,OAAO,SAAA,KAAc,WAAA,GACpC,YACAG,YAAA,CAAQC,iBAAA,CAAc,2PAAe,CAAC,CAAA;AAE1C,EAAA,IAAI,GAAA,GAAM,UAAA;AACV,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,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AAK,QAAQ,CAAC,CAAA;AAAA,UAChE,CAAA,CAAA,MAAQ;AACN,YAAA,OAAO,KAAA;AAAA,UACT;AAAA,QACF,CAAC,CAAA;AAED,QAAA,IAAI,CAAC,OAAA,EAAS;AACZ,UAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,QACzD;AAEA,QAAA,IAAA,EAAK;AAAA,MACP,SAAS,GAAA,EAAK;AACZ,QAAA,IAAA,CAAK,GAAA,YAAe,QAAQ,GAAA,GAAM,IAAI,MAAM,MAAA,CAAO,GAAG,CAAC,CAAC,CAAA;AAAA,MAC1D;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;AC9EO,SAAS,kBAAkB,MAAA,EAAsB;AACtD,EAAA,OAAO,CAAC,GAAA,EAAyB,GAAA,EAAwC,IAAA,KAAqB;AAC5F,IAAA,IAAI,GAAA,CAAI,WAAW,SAAA,EAAW;AAC5B,MAAA,GAAA,CAAI,KAAK,MAAM,CAAA;AACf,MAAA;AAAA,IACF;AACA,IAAA,IAAA,EAAK;AAAA,EACP,CAAA;AACF","file":"index.cjs","sourcesContent":["/**\n * Schema-based validation using AJV.\n * Loads all JSON schemas from the @jambonz/schema package.\n */\n\nimport Ajv, { type ValidateFunction, type ErrorObject } from 'ajv';\nimport { readFileSync, readdirSync, existsSync } from 'fs';\nimport { resolve, dirname, basename } from 'path';\nimport { fileURLToPath } from 'url';\nimport { createRequire } from 'module';\n\nexport interface ValidationResult {\n valid: boolean;\n errors: ValidationError[];\n}\n\nexport interface ValidationError {\n path: string;\n message: string;\n}\n\n/** Locate the @jambonz/schema package directory. */\nfunction findSchemaDir(): string {\n // Method 1: use createRequire to resolve the package\n try {\n const req = createRequire(import.meta.url);\n const schemaIndex = req.resolve('@jambonz/schema');\n const dir = resolve(schemaIndex, '..');\n if (existsSync(resolve(dir, 'jambonz-app.schema.json'))) {\n return dir;\n }\n } catch {\n // fall through\n }\n\n // Method 2: walk up from this file to find node_modules/@jambonz/schema\n const currentDir = typeof __dirname !== 'undefined'\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\n let dir = currentDir;\n for (let i = 0; i < 10; i++) {\n const candidate = resolve(dir, 'node_modules', '@jambonz', 'schema');\n if (existsSync(resolve(candidate, 'jambonz-app.schema.json'))) {\n return candidate;\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n\n throw new Error(\n 'Could not find @jambonz/schema package. Ensure it is installed as a dependency.'\n );\n}\n\n/** Discover schema files in a subdirectory. */\nfunction discoverSchemas(dir: string): string[] {\n try {\n return readdirSync(dir)\n .filter((f) => f.endsWith('.schema.json'))\n .map((f) => basename(f, '.schema.json'));\n } catch {\n return [];\n }\n}\n\nfunction loadSchema(filePath: string): Record<string, unknown> {\n return JSON.parse(readFileSync(filePath, 'utf-8')) as Record<string, unknown>;\n}\n\nexport class JambonzValidator {\n private validateApp: ValidateFunction;\n private ajv: Ajv;\n\n constructor(schemaDir?: string) {\n const dir = schemaDir ?? findSchemaDir();\n this.ajv = new Ajv({\n allErrors: true,\n strict: false,\n validateSchema: false,\n logger: false,\n });\n\n // Register component schemas first (they are referenced by verb schemas)\n const componentsDir = resolve(dir, 'components');\n for (const name of discoverSchemas(componentsDir)) {\n const schema = loadSchema(resolve(componentsDir, `${name}.schema.json`));\n this.ajv.addSchema(schema);\n }\n\n // Register verb schemas\n const verbsDir = resolve(dir, 'verbs');\n for (const name of discoverSchemas(verbsDir)) {\n const schema = loadSchema(resolve(verbsDir, `${name}.schema.json`));\n this.ajv.addSchema(schema);\n }\n\n // Compile the root app schema\n const appSchema = loadSchema(resolve(dir, 'jambonz-app.schema.json'));\n this.validateApp = this.ajv.compile(appSchema);\n }\n\n /** Validate a complete verb array (a jambonz application). */\n validate(app: unknown): ValidationResult {\n const valid = this.validateApp(app);\n if (valid) {\n return { valid: true, errors: [] };\n }\n return {\n valid: false,\n errors: formatErrors(this.validateApp.errors),\n };\n }\n\n /** Validate a single verb object. */\n validateVerb(verb: unknown): ValidationResult {\n // Wrap in an array and validate as an app\n return this.validate([verb]);\n }\n}\n\nfunction formatErrors(errors: ErrorObject[] | null | undefined): ValidationError[] {\n if (!errors) return [];\n return errors.map((err) => ({\n path: err.instancePath || '/',\n message: err.message || 'Unknown validation error',\n }));\n}\n\nlet _defaultValidator: JambonzValidator | null = null;\n\n/** Get a shared validator instance. */\nexport function getValidator(schemaDir?: string): JambonzValidator {\n if (!_defaultValidator) {\n _defaultValidator = new JambonzValidator(schemaDir);\n }\n return _defaultValidator;\n}\n","/**\n * Shared VerbBuilder base class.\n * Provides typed verb methods and raw JSON input for both WebhookResponse and WS Session.\n */\n\nimport type {\n AgentVerb,\n AlertVerb,\n AnswerVerb,\n ConferenceVerb,\n ConfigVerb,\n DequeueVerb,\n DialogflowVerb,\n DialVerb,\n DtmfVerb,\n DubVerb,\n EnqueueVerb,\n GatherVerb,\n HangupVerb,\n LeaveVerb,\n ListenVerb,\n LlmBaseOptions,\n LlmVerb,\n MessageVerb,\n PauseVerb,\n PlayVerb,\n RedirectVerb,\n RoomVerb,\n S2sVerb,\n SayVerb,\n SipDeclineVerb,\n SipReferVerb,\n SipRequestVerb,\n StreamVerb,\n TagVerb,\n TranscribeVerb,\n TransferVerb,\n Verb,\n} from './types/verbs.js';\nimport { JambonzValidator } from './validator.js';\n\nexport interface VerbBuilderOptions {\n /** Enable runtime schema validation. Default: true. */\n validate?: boolean;\n /** Path to schema directory. Auto-detected if omitted. */\n schemaDir?: string;\n}\n\n/**\n * Base class for building jambonz verb arrays. Extended by {@link WebhookResponse}\n * and WsSession. Provides typed verb methods and optional runtime schema validation.\n */\nexport class VerbBuilder {\n protected verbs: Verb[] = [];\n protected validator: JambonzValidator | null;\n\n /**\n * @param opts - Options for validation and schema directory.\n */\n constructor(opts?: VerbBuilderOptions) {\n if (opts?.validate === false) {\n this.validator = null;\n } else {\n this.validator = new JambonzValidator(opts?.schemaDir);\n }\n }\n\n // --- Audio & Speech ---\n\n /** Speak text using TTS. Supports SSML, multiple voices, and streaming. */\n say(opts: Omit<SayVerb, 'verb'>): this {\n return this.addVerb({ verb: 'say', ...opts });\n }\n\n /** Play an audio file from a URL. */\n play(opts: Omit<PlayVerb, 'verb'>): this {\n return this.addVerb({ verb: 'play', ...opts });\n }\n\n /** Collect speech (STT) and/or DTMF input from the caller. */\n gather(opts: Omit<GatherVerb, 'verb'>): this {\n return this.addVerb({ verb: 'gather', ...opts });\n }\n\n // --- AI & Real-time ---\n\n /** Connect the caller to an LLM for real-time voice conversation. */\n llm(opts: Omit<LlmVerb, 'verb'>): this {\n return this.addVerb({ verb: 'llm', ...opts });\n }\n\n /** Synonym for {@link llm}. Requires vendor to be specified. */\n s2s(opts: Omit<S2sVerb, 'verb'>): this {\n return this.addVerb({ verb: 's2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='openai'. */\n openai_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'openai_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='google'. */\n google_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'google_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='elevenlabs'. */\n elevenlabs_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'elevenlabs_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='deepgram'. */\n deepgram_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'deepgram_s2s', ...opts });\n }\n\n /** Shortcut for s2s with vendor='ultravox'. */\n ultravox_s2s(opts: Omit<LlmBaseOptions, 'vendor'>): this {\n return this.addVerb({ verb: 'ultravox_s2s', ...opts });\n }\n\n /** Connect the caller to a Google Dialogflow agent (ES, CX, or CES). */\n dialogflow(opts: Omit<DialogflowVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dialogflow', ...opts });\n }\n\n /** Voice AI agent with integrated turn detection. */\n agent(opts: Omit<AgentVerb, 'verb'>): this {\n return this.addVerb({ verb: 'agent', ...opts });\n }\n\n /** Stream real-time call audio to a WebSocket endpoint. Supports bidirectional audio. */\n listen(opts: Omit<ListenVerb, 'verb'>): this {\n return this.addVerb({ verb: 'listen', ...opts });\n }\n\n /** Stream real-time call audio to a WebSocket endpoint. Synonym for {@link listen}. */\n stream(opts: Omit<StreamVerb, 'verb'>): this {\n return this.addVerb({ verb: 'stream', ...opts });\n }\n\n /** Real-time call transcription sent to a webhook. */\n transcribe(opts: Omit<TranscribeVerb, 'verb'>): this {\n return this.addVerb({ verb: 'transcribe', ...opts });\n }\n\n // --- Call Control ---\n\n /** Place an outbound call and bridge it to the current caller. */\n dial(opts: Omit<DialVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dial', ...opts });\n }\n\n /** Join or create a multi-party conference room. */\n conference(opts: Omit<ConferenceVerb, 'verb'>): this {\n return this.addVerb({ verb: 'conference', ...opts });\n }\n\n /** `room` is a synonym for `conference` — prefer it in new applications. */\n room(opts: Omit<RoomVerb, 'verb'>): this {\n return this.addVerb({ verb: 'room', ...opts });\n }\n\n /** Place the caller into a named queue. */\n enqueue(opts: Omit<EnqueueVerb, 'verb'>): this {\n return this.addVerb({ verb: 'enqueue', ...opts });\n }\n\n /** Remove a caller from a queue and bridge them. */\n dequeue(opts: Omit<DequeueVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dequeue', ...opts });\n }\n\n /** End the call. */\n hangup(opts?: Omit<HangupVerb, 'verb'>): this {\n return this.addVerb({ verb: 'hangup', ...opts });\n }\n\n /** Transfer control to a different webhook URL. */\n redirect(opts: Omit<RedirectVerb, 'verb'>): this {\n return this.addVerb({ verb: 'redirect', ...opts });\n }\n\n /** Wait for a specified duration before continuing. */\n pause(opts: Omit<PauseVerb, 'verb'>): this {\n return this.addVerb({ verb: 'pause', ...opts });\n }\n\n /** Leave a conference or queue. */\n leave(opts?: Omit<LeaveVerb, 'verb'>): this {\n return this.addVerb({ verb: 'leave', ...opts });\n }\n\n // --- SIP ---\n\n /** Reject an incoming call with a SIP error response. */\n sipDecline(opts: Omit<SipDeclineVerb, 'verb'>): this {\n return this.addVerb({ verb: 'sip:decline', ...opts });\n }\n\n /** Send a SIP INFO or other request within the dialog. */\n sipRequest(opts: Omit<SipRequestVerb, 'verb'>): this {\n return this.addVerb({ verb: 'sip:request', ...opts });\n }\n\n /** Transfer the call via SIP REFER. */\n sipRefer(opts: Omit<SipReferVerb, 'verb'>): this {\n return this.addVerb({ verb: 'sip:refer', ...opts });\n }\n\n /** Transfer the caller to a destination (blind, or warm parked/three-way) with built-in failure handling. */\n transfer(opts: Omit<TransferVerb, 'verb'>): this {\n return this.addVerb({ verb: 'transfer', ...opts });\n }\n\n // --- Utility ---\n\n /** Set session-level defaults (TTS vendor/voice, STT vendor, VAD, etc.). */\n config(opts: Omit<ConfigVerb, 'verb'>): this {\n return this.addVerb({ verb: 'config', ...opts });\n }\n\n /** Explicitly answer the call (sends a 200 OK). */\n answer(opts?: Omit<AnswerVerb, 'verb'>): this {\n return this.addVerb({ verb: 'answer', ...opts });\n }\n\n /** Send a SIP 180 Ringing with optional Alert-Info header. */\n alert(opts: Omit<AlertVerb, 'verb'>): this {\n return this.addVerb({ verb: 'alert', ...opts });\n }\n\n /** Attach metadata to the call for tracking or routing. */\n tag(opts: Omit<TagVerb, 'verb'>): this {\n return this.addVerb({ verb: 'tag', ...opts });\n }\n\n /** Send DTMF tones into the call. */\n dtmf(opts: Omit<DtmfVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dtmf', ...opts });\n }\n\n /** Mix an auxiliary audio track into the call. */\n dub(opts: Omit<DubVerb, 'verb'>): this {\n return this.addVerb({ verb: 'dub', ...opts });\n }\n\n /** Send an SMS or MMS message. */\n message(opts: Omit<MessageVerb, 'verb'>): this {\n return this.addVerb({ verb: 'message', ...opts });\n }\n\n // --- Raw JSON input (primary AI agent path) ---\n\n /**\n * Add one or more verbs from raw JSON.\n * Validates against the JSON schemas at runtime if validation is enabled.\n */\n addVerbs(verbs: Verb[]): this {\n if (this.validator) {\n const result = this.validator.validate(verbs);\n if (!result.valid) {\n const messages = result.errors.map((e) => `${e.path}: ${e.message}`).join('; ');\n throw new Error(`Verb validation failed: ${messages}`);\n }\n }\n this.verbs.push(...verbs);\n return this;\n }\n\n // --- Internal ---\n\n protected addVerb(verb: Verb): this {\n if (this.validator) {\n const result = this.validator.validateVerb(verb);\n if (!result.valid) {\n const messages = result.errors.map((e) => `${e.path}: ${e.message}`).join('; ');\n throw new Error(`Verb '${verb.verb}' validation failed: ${messages}`);\n }\n }\n this.verbs.push(verb);\n return this;\n }\n\n /** Get the current verb count. */\n get length(): number {\n return this.verbs.length;\n }\n\n /** Clear all queued verbs. */\n clear(): this {\n this.verbs = [];\n return this;\n }\n\n /** Returns a copy of the current verb array. */\n toJSON(): Verb[] {\n return [...this.verbs];\n }\n}\n","/**\n * WebhookResponse — verb builder for HTTP webhook applications.\n * Extends VerbBuilder with toJSON() and signature verification.\n */\n\nimport { createHmac, timingSafeEqual } from 'crypto';\nimport { VerbBuilder, type VerbBuilderOptions } from '../verb-builder.js';\nimport type { JambonzApp } from '../types/verbs.js';\nimport type { IncomingMessage, ServerResponse } from 'http';\n\n/**\n * Verb builder for HTTP webhook applications.\n * Construct one per request, chain verb methods, and pass to `res.json()`.\n *\n * @example\n * ```typescript\n * app.post('/incoming', (req, res) => {\n * const jambonz = new WebhookResponse();\n * jambonz.say({ text: 'Hello!' }).hangup();\n * res.json(jambonz);\n * });\n * ```\n */\nexport class WebhookResponse extends VerbBuilder {\n /** @param opts - Options for validation and schema directory. */\n constructor(opts?: VerbBuilderOptions) {\n super(opts);\n }\n\n /** Returns the verb array for JSON serialization. */\n toJSON(): JambonzApp {\n return [...this.verbs];\n }\n\n /**\n * Express-compatible middleware for verifying jambonz webhook signatures.\n * Uses HMAC-SHA256 with timing-safe comparison.\n */\n static verifySignature(secret: string, opts?: { tolerance?: number }) {\n const tolerance = opts?.tolerance ?? 300; // 5 minutes default\n\n return (\n req: IncomingMessage & { body?: unknown; rawBody?: Buffer },\n _res: ServerResponse,\n next: (err?: Error) => void\n ) => {\n try {\n const signature = (req.headers as Record<string, string | undefined>)['jambonz-signature'];\n if (!signature) {\n throw new Error('Missing Jambonz-Signature header');\n }\n\n const parts = signature.split(',');\n let timestamp = '';\n const signatures: string[] = [];\n\n for (const part of parts) {\n const [key, value] = part.split('=');\n if (key === 't') timestamp = value;\n else if (key === 'v1') signatures.push(value);\n }\n\n if (!timestamp || signatures.length === 0) {\n throw new Error('Invalid Jambonz-Signature format');\n }\n\n // Check timestamp tolerance\n const ts = parseInt(timestamp, 10);\n const now = Math.floor(Date.now() / 1000);\n if (Math.abs(now - ts) > tolerance) {\n throw new Error('Webhook signature timestamp outside tolerance');\n }\n\n // Compute expected signature\n const payload = typeof req.body === 'string'\n ? req.body\n : JSON.stringify(req.body);\n const signedPayload = `${timestamp}.${payload}`;\n const expected = createHmac('sha256', secret)\n .update(signedPayload)\n .digest('hex');\n\n // Timing-safe comparison\n const matched = signatures.some((sig) => {\n try {\n return timingSafeEqual(Buffer.from(sig), Buffer.from(expected));\n } catch {\n return false;\n }\n });\n\n if (!matched) {\n throw new Error('Webhook signature verification failed');\n }\n\n next();\n } catch (err) {\n next(err instanceof Error ? err : new Error(String(err)));\n }\n };\n }\n}\n","/**\n * Express middleware that auto-responds to HTTP OPTIONS requests with the\n * application environment variables schema for jambonz portal discovery.\n */\n\nimport type { EnvVarSchema } from '../types/common.js';\n\n/**\n * Express middleware that auto-responds to HTTP OPTIONS requests with the\n * application's environment variable schema, enabling jambonz portal discovery.\n *\n * @param schema - The environment variable schema to expose.\n *\n * @example\n * ```typescript\n * import { envVarsMiddleware } from '@jambonz/sdk/webhook';\n *\n * const envVars = {\n * API_KEY: { type: 'string', description: 'Your API key', required: true },\n * };\n * app.use(envVarsMiddleware(envVars));\n * ```\n */\nexport function envVarsMiddleware(schema: EnvVarSchema) {\n return (req: { method: string }, res: { json: (body: unknown) => void }, next: () => void) => {\n if (req.method === 'OPTIONS') {\n res.json(schema);\n return;\n }\n next();\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { b as VerbBuilder, c as VerbBuilderOptions } from '../verb-builder-Cc9cLrYj.cjs';
2
- import { J as JambonzApp } from '../verbs-BuObLiyU.cjs';
1
+ import { b as VerbBuilder, c as VerbBuilderOptions } from '../verb-builder-DpeNsmyP.cjs';
2
+ import { J as JambonzApp } from '../verbs-Bq-MRFKt.cjs';
3
3
  import { IncomingMessage, ServerResponse } from 'http';
4
4
  import { a as EnvVarSchema } from '../common-BSJZX7WO.cjs';
5
5
 
@@ -1,5 +1,5 @@
1
- import { b as VerbBuilder, c as VerbBuilderOptions } from '../verb-builder-8zDaN7ba.js';
2
- import { J as JambonzApp } from '../verbs-BuObLiyU.js';
1
+ import { b as VerbBuilder, c as VerbBuilderOptions } from '../verb-builder-BcM7Cth-.js';
2
+ import { J as JambonzApp } from '../verbs-Bq-MRFKt.js';
3
3
  import { IncomingMessage, ServerResponse } from 'http';
4
4
  import { a as EnvVarSchema } from '../common-BSJZX7WO.js';
5
5
 
@@ -215,6 +215,10 @@ var VerbBuilder = class {
215
215
  sipRefer(opts) {
216
216
  return this.addVerb({ verb: "sip:refer", ...opts });
217
217
  }
218
+ /** Transfer the caller to a destination (blind, or warm parked/three-way) with built-in failure handling. */
219
+ transfer(opts) {
220
+ return this.addVerb({ verb: "transfer", ...opts });
221
+ }
218
222
  // --- Utility ---
219
223
  /** Set session-level defaults (TTS vendor/voice, STT vendor, VAD, etc.). */
220
224
  config(opts) {