@openclaw/voice-call 2026.5.2 → 2026.5.3-beta.1

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 (126) hide show
  1. package/dist/api.js +2 -0
  2. package/dist/call-status-CXldV5o8.js +32 -0
  3. package/dist/cli-metadata.js +12 -0
  4. package/dist/config-7w04YpHh.js +548 -0
  5. package/dist/config-compat-B0me39_4.js +129 -0
  6. package/dist/guarded-json-api-Btx5EE4w.js +591 -0
  7. package/dist/http-headers-BrnxBasF.js +10 -0
  8. package/dist/index.js +1284 -0
  9. package/dist/mock-CeKvfVEd.js +135 -0
  10. package/dist/plivo-B-a7KFoT.js +393 -0
  11. package/dist/realtime-handler-B63CIDP2.js +325 -0
  12. package/dist/realtime-transcription.runtime-B2h70y2W.js +2 -0
  13. package/dist/realtime-voice.runtime-Bkh4nvLn.js +2 -0
  14. package/dist/response-generator-BrcmwDZU.js +182 -0
  15. package/dist/response-model-CyF5K80p.js +12 -0
  16. package/dist/runtime-api.js +6 -0
  17. package/dist/runtime-entry-88ytYAQa.js +3119 -0
  18. package/dist/runtime-entry.js +2 -0
  19. package/dist/setup-api.js +37 -0
  20. package/dist/telnyx-jjBE8boz.js +260 -0
  21. package/dist/twilio-1OqbcXLL.js +676 -0
  22. package/dist/voice-mapping-BYDGdWGx.js +40 -0
  23. package/package.json +14 -6
  24. package/api.ts +0 -16
  25. package/cli-metadata.ts +0 -10
  26. package/config-api.ts +0 -12
  27. package/index.test.ts +0 -943
  28. package/index.ts +0 -794
  29. package/runtime-api.ts +0 -20
  30. package/runtime-entry.ts +0 -1
  31. package/setup-api.ts +0 -47
  32. package/src/allowlist.test.ts +0 -18
  33. package/src/allowlist.ts +0 -19
  34. package/src/cli.ts +0 -845
  35. package/src/config-compat.test.ts +0 -120
  36. package/src/config-compat.ts +0 -227
  37. package/src/config.test.ts +0 -479
  38. package/src/config.ts +0 -808
  39. package/src/core-bridge.ts +0 -14
  40. package/src/deep-merge.test.ts +0 -40
  41. package/src/deep-merge.ts +0 -23
  42. package/src/gateway-continue-operation.ts +0 -200
  43. package/src/http-headers.test.ts +0 -16
  44. package/src/http-headers.ts +0 -15
  45. package/src/manager/context.ts +0 -42
  46. package/src/manager/events.test.ts +0 -581
  47. package/src/manager/events.ts +0 -288
  48. package/src/manager/lifecycle.ts +0 -53
  49. package/src/manager/lookup.test.ts +0 -52
  50. package/src/manager/lookup.ts +0 -35
  51. package/src/manager/outbound.test.ts +0 -528
  52. package/src/manager/outbound.ts +0 -486
  53. package/src/manager/state.ts +0 -48
  54. package/src/manager/store.ts +0 -106
  55. package/src/manager/timers.test.ts +0 -129
  56. package/src/manager/timers.ts +0 -113
  57. package/src/manager/twiml.test.ts +0 -13
  58. package/src/manager/twiml.ts +0 -17
  59. package/src/manager.closed-loop.test.ts +0 -236
  60. package/src/manager.inbound-allowlist.test.ts +0 -188
  61. package/src/manager.notify.test.ts +0 -377
  62. package/src/manager.restore.test.ts +0 -183
  63. package/src/manager.test-harness.ts +0 -127
  64. package/src/manager.ts +0 -392
  65. package/src/media-stream.test.ts +0 -768
  66. package/src/media-stream.ts +0 -708
  67. package/src/providers/base.ts +0 -97
  68. package/src/providers/mock.test.ts +0 -78
  69. package/src/providers/mock.ts +0 -185
  70. package/src/providers/plivo.test.ts +0 -93
  71. package/src/providers/plivo.ts +0 -601
  72. package/src/providers/shared/call-status.test.ts +0 -24
  73. package/src/providers/shared/call-status.ts +0 -24
  74. package/src/providers/shared/guarded-json-api.test.ts +0 -106
  75. package/src/providers/shared/guarded-json-api.ts +0 -42
  76. package/src/providers/telnyx.test.ts +0 -340
  77. package/src/providers/telnyx.ts +0 -394
  78. package/src/providers/twilio/api.test.ts +0 -145
  79. package/src/providers/twilio/api.ts +0 -93
  80. package/src/providers/twilio/twiml-policy.test.ts +0 -84
  81. package/src/providers/twilio/twiml-policy.ts +0 -87
  82. package/src/providers/twilio/webhook.ts +0 -34
  83. package/src/providers/twilio.test.ts +0 -591
  84. package/src/providers/twilio.ts +0 -861
  85. package/src/providers/twilio.types.ts +0 -17
  86. package/src/realtime-defaults.ts +0 -3
  87. package/src/realtime-fast-context.test.ts +0 -88
  88. package/src/realtime-fast-context.ts +0 -165
  89. package/src/realtime-transcription.runtime.ts +0 -4
  90. package/src/realtime-voice.runtime.ts +0 -5
  91. package/src/response-generator.test.ts +0 -321
  92. package/src/response-generator.ts +0 -318
  93. package/src/response-model.test.ts +0 -71
  94. package/src/response-model.ts +0 -23
  95. package/src/runtime.test.ts +0 -536
  96. package/src/runtime.ts +0 -510
  97. package/src/telephony-audio.test.ts +0 -61
  98. package/src/telephony-audio.ts +0 -12
  99. package/src/telephony-tts.test.ts +0 -196
  100. package/src/telephony-tts.ts +0 -235
  101. package/src/test-fixtures.ts +0 -73
  102. package/src/tts-provider-voice.test.ts +0 -34
  103. package/src/tts-provider-voice.ts +0 -21
  104. package/src/tunnel.test.ts +0 -166
  105. package/src/tunnel.ts +0 -314
  106. package/src/types.ts +0 -291
  107. package/src/utils.test.ts +0 -17
  108. package/src/utils.ts +0 -14
  109. package/src/voice-mapping.test.ts +0 -34
  110. package/src/voice-mapping.ts +0 -68
  111. package/src/webhook/realtime-handler.test.ts +0 -598
  112. package/src/webhook/realtime-handler.ts +0 -485
  113. package/src/webhook/stale-call-reaper.test.ts +0 -88
  114. package/src/webhook/stale-call-reaper.ts +0 -38
  115. package/src/webhook/tailscale.test.ts +0 -214
  116. package/src/webhook/tailscale.ts +0 -129
  117. package/src/webhook-exposure.test.ts +0 -33
  118. package/src/webhook-exposure.ts +0 -84
  119. package/src/webhook-security.test.ts +0 -770
  120. package/src/webhook-security.ts +0 -994
  121. package/src/webhook.hangup-once.lifecycle.test.ts +0 -135
  122. package/src/webhook.test.ts +0 -1470
  123. package/src/webhook.ts +0 -908
  124. package/src/webhook.types.ts +0 -5
  125. package/src/websocket-test-support.ts +0 -72
  126. package/tsconfig.json +0 -16
@@ -0,0 +1,2 @@
1
+ import { t as createVoiceCallRuntime } from "./runtime-entry-88ytYAQa.js";
2
+ export { createVoiceCallRuntime };
@@ -0,0 +1,37 @@
1
+ import { n as migrateVoiceCallLegacyConfigInput } from "./config-compat-B0me39_4.js";
2
+ import { isRecord } from "openclaw/plugin-sdk/text-runtime";
3
+ import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
4
+ //#region extensions/voice-call/setup-api.ts
5
+ function migrateVoiceCallPluginConfig(config) {
6
+ const rawVoiceCallConfig = config.plugins?.entries?.["voice-call"]?.config;
7
+ if (!isRecord(rawVoiceCallConfig)) return null;
8
+ const migration = migrateVoiceCallLegacyConfigInput({
9
+ value: rawVoiceCallConfig,
10
+ configPathPrefix: "plugins.entries.voice-call.config"
11
+ });
12
+ if (migration.changes.length === 0) return null;
13
+ const plugins = structuredClone(config.plugins ?? {});
14
+ const entries = { ...plugins.entries };
15
+ entries["voice-call"] = {
16
+ ...isRecord(entries["voice-call"]) ? entries["voice-call"] : {},
17
+ config: migration.config
18
+ };
19
+ plugins.entries = entries;
20
+ return {
21
+ config: {
22
+ ...config,
23
+ plugins
24
+ },
25
+ changes: migration.changes
26
+ };
27
+ }
28
+ var setup_api_default = definePluginEntry({
29
+ id: "voice-call",
30
+ name: "Voice Call Setup",
31
+ description: "Lightweight Voice Call setup hooks",
32
+ register(api) {
33
+ api.registerConfigMigration((config) => migrateVoiceCallPluginConfig(config));
34
+ }
35
+ });
36
+ //#endregion
37
+ export { setup_api_default as default };
@@ -0,0 +1,260 @@
1
+ import { i as verifyTelnyxWebhook, t as guardedJsonApiRequest } from "./guarded-json-api-Btx5EE4w.js";
2
+ import crypto from "node:crypto";
3
+ //#region extensions/voice-call/src/providers/telnyx.ts
4
+ function normalizeTelnyxDirection(direction) {
5
+ switch (direction) {
6
+ case "incoming":
7
+ case "inbound": return "inbound";
8
+ case "outgoing":
9
+ case "outbound": return "outbound";
10
+ default: return;
11
+ }
12
+ }
13
+ var TelnyxProvider = class {
14
+ constructor(config, options = {}) {
15
+ this.name = "telnyx";
16
+ this.baseUrl = "https://api.telnyx.com/v2";
17
+ this.apiHost = "api.telnyx.com";
18
+ if (!config.apiKey) throw new Error("Telnyx API key is required");
19
+ if (!config.connectionId) throw new Error("Telnyx connection ID is required");
20
+ this.apiKey = config.apiKey;
21
+ this.connectionId = config.connectionId;
22
+ this.publicKey = config.publicKey;
23
+ this.options = options;
24
+ }
25
+ /**
26
+ * Make an authenticated request to the Telnyx API.
27
+ */
28
+ async apiRequest(endpoint, body, options) {
29
+ return await guardedJsonApiRequest({
30
+ url: `${this.baseUrl}${endpoint}`,
31
+ method: "POST",
32
+ headers: {
33
+ Authorization: `Bearer ${this.apiKey}`,
34
+ "Content-Type": "application/json"
35
+ },
36
+ body,
37
+ allowNotFound: options?.allowNotFound,
38
+ allowedHostnames: [this.apiHost],
39
+ auditContext: "voice-call.telnyx.api",
40
+ errorPrefix: "Telnyx API error"
41
+ });
42
+ }
43
+ /**
44
+ * Verify Telnyx webhook signature using Ed25519.
45
+ */
46
+ verifyWebhook(ctx) {
47
+ const result = verifyTelnyxWebhook(ctx, this.publicKey, { skipVerification: this.options.skipVerification });
48
+ return {
49
+ ok: result.ok,
50
+ reason: result.reason,
51
+ isReplay: result.isReplay,
52
+ verifiedRequestKey: result.verifiedRequestKey
53
+ };
54
+ }
55
+ /**
56
+ * Parse Telnyx webhook event into normalized format.
57
+ */
58
+ parseWebhookEvent(ctx, options) {
59
+ try {
60
+ const data = JSON.parse(ctx.rawBody).data;
61
+ if (!data || !data.event_type) return {
62
+ events: [],
63
+ statusCode: 200
64
+ };
65
+ const event = this.normalizeEvent(data, options?.verifiedRequestKey);
66
+ return {
67
+ events: event ? [event] : [],
68
+ statusCode: 200
69
+ };
70
+ } catch {
71
+ return {
72
+ events: [],
73
+ statusCode: 400
74
+ };
75
+ }
76
+ }
77
+ /**
78
+ * Convert Telnyx event to normalized event format.
79
+ */
80
+ normalizeEvent(data, dedupeKey) {
81
+ let callId = "";
82
+ if (data.payload?.client_state) try {
83
+ callId = Buffer.from(data.payload.client_state, "base64").toString("utf8");
84
+ } catch {
85
+ callId = data.payload.client_state;
86
+ }
87
+ if (!callId) callId = data.payload?.call_control_id || "";
88
+ const baseEvent = {
89
+ id: data.id || crypto.randomUUID(),
90
+ dedupeKey,
91
+ callId,
92
+ providerCallId: data.payload?.call_control_id,
93
+ timestamp: Date.now(),
94
+ direction: normalizeTelnyxDirection(data.payload?.direction),
95
+ from: data.payload?.from,
96
+ to: data.payload?.to
97
+ };
98
+ switch (data.event_type) {
99
+ case "call.initiated": return {
100
+ ...baseEvent,
101
+ type: "call.initiated"
102
+ };
103
+ case "call.ringing": return {
104
+ ...baseEvent,
105
+ type: "call.ringing"
106
+ };
107
+ case "call.answered": return {
108
+ ...baseEvent,
109
+ type: "call.answered"
110
+ };
111
+ case "call.bridged": return {
112
+ ...baseEvent,
113
+ type: "call.active"
114
+ };
115
+ case "call.speak.started": return {
116
+ ...baseEvent,
117
+ type: "call.speaking",
118
+ text: data.payload?.text || ""
119
+ };
120
+ case "call.transcription": return {
121
+ ...baseEvent,
122
+ type: "call.speech",
123
+ transcript: data.payload?.transcription_data?.transcript ?? data.payload?.transcription ?? "",
124
+ isFinal: data.payload?.transcription_data?.is_final ?? data.payload?.is_final ?? true,
125
+ confidence: data.payload?.transcription_data?.confidence ?? data.payload?.confidence
126
+ };
127
+ case "call.hangup": return {
128
+ ...baseEvent,
129
+ type: "call.ended",
130
+ reason: this.mapHangupCause(data.payload?.hangup_cause)
131
+ };
132
+ case "call.dtmf.received": return {
133
+ ...baseEvent,
134
+ type: "call.dtmf",
135
+ digits: data.payload?.digit || ""
136
+ };
137
+ default: return null;
138
+ }
139
+ }
140
+ /**
141
+ * Map Telnyx hangup cause to normalized end reason.
142
+ * @see https://developers.telnyx.com/docs/api/v2/call-control/Call-Commands#hangup-causes
143
+ */
144
+ mapHangupCause(cause) {
145
+ switch (cause) {
146
+ case "normal_clearing":
147
+ case "normal_unspecified": return "completed";
148
+ case "originator_cancel": return "hangup-bot";
149
+ case "call_rejected":
150
+ case "user_busy": return "busy";
151
+ case "no_answer":
152
+ case "no_user_response": return "no-answer";
153
+ case "destination_out_of_order":
154
+ case "network_out_of_order":
155
+ case "service_unavailable":
156
+ case "recovery_on_timer_expire": return "failed";
157
+ case "machine_detected":
158
+ case "fax_detected": return "voicemail";
159
+ case "user_hangup":
160
+ case "subscriber_absent": return "hangup-user";
161
+ default:
162
+ if (cause) console.warn(`[telnyx] Unknown hangup cause: ${cause}`);
163
+ return "completed";
164
+ }
165
+ }
166
+ /**
167
+ * Initiate an outbound call via Telnyx API.
168
+ */
169
+ async initiateCall(input) {
170
+ return {
171
+ providerCallId: (await this.apiRequest("/calls", {
172
+ connection_id: this.connectionId,
173
+ to: input.to,
174
+ from: input.from,
175
+ webhook_url: input.webhookUrl,
176
+ webhook_url_method: "POST",
177
+ client_state: Buffer.from(input.callId).toString("base64"),
178
+ timeout_secs: 30
179
+ })).data.call_control_id,
180
+ status: "initiated"
181
+ };
182
+ }
183
+ /**
184
+ * Hang up a call via Telnyx API.
185
+ */
186
+ async hangupCall(input) {
187
+ await this.apiRequest(`/calls/${input.providerCallId}/actions/hangup`, { command_id: crypto.randomUUID() }, { allowNotFound: true });
188
+ }
189
+ /**
190
+ * Answer an inbound Telnyx Call Control leg.
191
+ */
192
+ async answerCall(input) {
193
+ await this.apiRequest(`/calls/${input.providerCallId}/actions/answer`, { command_id: `openclaw-answer-${input.callId}` });
194
+ }
195
+ /**
196
+ * Play TTS audio via Telnyx speak action.
197
+ */
198
+ async playTts(input) {
199
+ await this.apiRequest(`/calls/${input.providerCallId}/actions/speak`, {
200
+ command_id: crypto.randomUUID(),
201
+ payload: input.text,
202
+ voice: input.voice || "female",
203
+ language: input.locale || "en-US"
204
+ });
205
+ }
206
+ /**
207
+ * Start transcription (STT) via Telnyx.
208
+ */
209
+ async startListening(input) {
210
+ await this.apiRequest(`/calls/${input.providerCallId}/actions/transcription_start`, {
211
+ command_id: crypto.randomUUID(),
212
+ language: input.language || "en"
213
+ });
214
+ }
215
+ /**
216
+ * Stop transcription via Telnyx.
217
+ */
218
+ async stopListening(input) {
219
+ await this.apiRequest(`/calls/${input.providerCallId}/actions/transcription_stop`, { command_id: crypto.randomUUID() }, { allowNotFound: true });
220
+ }
221
+ async getCallStatus(input) {
222
+ try {
223
+ const data = await guardedJsonApiRequest({
224
+ url: `${this.baseUrl}/calls/${input.providerCallId}`,
225
+ method: "GET",
226
+ headers: {
227
+ Authorization: `Bearer ${this.apiKey}`,
228
+ "Content-Type": "application/json"
229
+ },
230
+ allowNotFound: true,
231
+ allowedHostnames: [this.apiHost],
232
+ auditContext: "telnyx-get-call-status",
233
+ errorPrefix: "Telnyx get call status error"
234
+ });
235
+ if (!data) return {
236
+ status: "not-found",
237
+ isTerminal: true
238
+ };
239
+ const state = data.data?.state ?? "unknown";
240
+ const isAlive = data.data?.is_alive;
241
+ if (isAlive === void 0) return {
242
+ status: state,
243
+ isTerminal: false,
244
+ isUnknown: true
245
+ };
246
+ return {
247
+ status: state,
248
+ isTerminal: !isAlive
249
+ };
250
+ } catch {
251
+ return {
252
+ status: "error",
253
+ isTerminal: false,
254
+ isUnknown: true
255
+ };
256
+ }
257
+ }
258
+ };
259
+ //#endregion
260
+ export { TelnyxProvider };