@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
package/src/types.ts DELETED
@@ -1,291 +0,0 @@
1
- import { z } from "openclaw/plugin-sdk/zod";
2
- import type { CallMode } from "./config.js";
3
-
4
- // -----------------------------------------------------------------------------
5
- // Provider Identifiers
6
- // -----------------------------------------------------------------------------
7
-
8
- const ProviderNameSchema = z.enum(["telnyx", "twilio", "plivo", "mock"]);
9
- export type ProviderName = z.infer<typeof ProviderNameSchema>;
10
-
11
- // -----------------------------------------------------------------------------
12
- // Core Call Identifiers
13
- // -----------------------------------------------------------------------------
14
-
15
- /** Internal call identifier (UUID) */
16
- export type CallId = string;
17
-
18
- /** Provider-specific call identifier */
19
- type ProviderCallId = string;
20
-
21
- // -----------------------------------------------------------------------------
22
- // Call Lifecycle States
23
- // -----------------------------------------------------------------------------
24
-
25
- const CallStateSchema = z.enum([
26
- // Non-terminal states
27
- "initiated",
28
- "ringing",
29
- "answered",
30
- "active",
31
- "speaking",
32
- "listening",
33
- // Terminal states
34
- "completed",
35
- "hangup-user",
36
- "hangup-bot",
37
- "timeout",
38
- "error",
39
- "failed",
40
- "no-answer",
41
- "busy",
42
- "voicemail",
43
- ]);
44
- export type CallState = z.infer<typeof CallStateSchema>;
45
-
46
- export const TerminalStates = new Set<CallState>([
47
- "completed",
48
- "hangup-user",
49
- "hangup-bot",
50
- "timeout",
51
- "error",
52
- "failed",
53
- "no-answer",
54
- "busy",
55
- "voicemail",
56
- ]);
57
-
58
- const EndReasonSchema = z.enum([
59
- "completed",
60
- "hangup-user",
61
- "hangup-bot",
62
- "timeout",
63
- "error",
64
- "failed",
65
- "no-answer",
66
- "busy",
67
- "voicemail",
68
- ]);
69
- export type EndReason = z.infer<typeof EndReasonSchema>;
70
-
71
- // -----------------------------------------------------------------------------
72
- // Normalized Call Events
73
- // -----------------------------------------------------------------------------
74
-
75
- const BaseEventSchema = z.object({
76
- id: z.string(),
77
- // Stable provider-derived key for idempotency/replay dedupe.
78
- dedupeKey: z.string().optional(),
79
- callId: z.string(),
80
- providerCallId: z.string().optional(),
81
- timestamp: z.number(),
82
- // Optional per-turn nonce for speech events (Twilio <Gather> replay hardening).
83
- turnToken: z.string().optional(),
84
- // Optional fields for inbound call detection
85
- direction: z.enum(["inbound", "outbound"]).optional(),
86
- from: z.string().optional(),
87
- to: z.string().optional(),
88
- });
89
-
90
- const NormalizedEventSchema = z.discriminatedUnion("type", [
91
- BaseEventSchema.extend({
92
- type: z.literal("call.initiated"),
93
- }),
94
- BaseEventSchema.extend({
95
- type: z.literal("call.ringing"),
96
- }),
97
- BaseEventSchema.extend({
98
- type: z.literal("call.answered"),
99
- }),
100
- BaseEventSchema.extend({
101
- type: z.literal("call.active"),
102
- }),
103
- BaseEventSchema.extend({
104
- type: z.literal("call.speaking"),
105
- text: z.string(),
106
- }),
107
- BaseEventSchema.extend({
108
- type: z.literal("call.speech"),
109
- transcript: z.string(),
110
- isFinal: z.boolean(),
111
- confidence: z.number().min(0).max(1).optional(),
112
- }),
113
- BaseEventSchema.extend({
114
- type: z.literal("call.silence"),
115
- durationMs: z.number(),
116
- }),
117
- BaseEventSchema.extend({
118
- type: z.literal("call.dtmf"),
119
- digits: z.string(),
120
- }),
121
- BaseEventSchema.extend({
122
- type: z.literal("call.ended"),
123
- reason: EndReasonSchema,
124
- }),
125
- BaseEventSchema.extend({
126
- type: z.literal("call.error"),
127
- error: z.string(),
128
- retryable: z.boolean().optional(),
129
- }),
130
- ]);
131
- export type NormalizedEvent = z.infer<typeof NormalizedEventSchema>;
132
-
133
- // -----------------------------------------------------------------------------
134
- // Call Direction
135
- // -----------------------------------------------------------------------------
136
-
137
- const CallDirectionSchema = z.enum(["outbound", "inbound"]);
138
-
139
- // -----------------------------------------------------------------------------
140
- // Call Record
141
- // -----------------------------------------------------------------------------
142
-
143
- const TranscriptEntrySchema = z.object({
144
- timestamp: z.number(),
145
- speaker: z.enum(["bot", "user"]),
146
- text: z.string(),
147
- isFinal: z.boolean().default(true),
148
- });
149
- export type TranscriptEntry = z.infer<typeof TranscriptEntrySchema>;
150
-
151
- export const CallRecordSchema = z.object({
152
- callId: z.string(),
153
- providerCallId: z.string().optional(),
154
- provider: ProviderNameSchema,
155
- direction: CallDirectionSchema,
156
- state: CallStateSchema,
157
- from: z.string(),
158
- to: z.string(),
159
- sessionKey: z.string().optional(),
160
- startedAt: z.number(),
161
- answeredAt: z.number().optional(),
162
- endedAt: z.number().optional(),
163
- endReason: EndReasonSchema.optional(),
164
- transcript: z.array(TranscriptEntrySchema).default([]),
165
- processedEventIds: z.array(z.string()).default([]),
166
- metadata: z.record(z.string(), z.unknown()).optional(),
167
- });
168
- export type CallRecord = z.infer<typeof CallRecordSchema>;
169
-
170
- // -----------------------------------------------------------------------------
171
- // Webhook Types
172
- // -----------------------------------------------------------------------------
173
-
174
- export type WebhookVerificationResult = {
175
- ok: boolean;
176
- reason?: string;
177
- /** Signature is valid, but request was seen before within replay window. */
178
- isReplay?: boolean;
179
- /** Stable key derived from authenticated request material. */
180
- verifiedRequestKey?: string;
181
- };
182
-
183
- export type WebhookParseOptions = {
184
- /** Stable request key from verifyWebhook. */
185
- verifiedRequestKey?: string;
186
- };
187
-
188
- export type WebhookContext = {
189
- headers: Record<string, string | string[] | undefined>;
190
- rawBody: string;
191
- url: string;
192
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
193
- query?: Record<string, string | string[] | undefined>;
194
- remoteAddress?: string;
195
- };
196
-
197
- export type ProviderWebhookParseResult = {
198
- events: NormalizedEvent[];
199
- providerResponseBody?: string;
200
- providerResponseHeaders?: Record<string, string>;
201
- statusCode?: number;
202
- };
203
-
204
- // -----------------------------------------------------------------------------
205
- // Provider Method Types
206
- // -----------------------------------------------------------------------------
207
-
208
- export type InitiateCallInput = {
209
- callId: CallId;
210
- from: string;
211
- to: string;
212
- webhookUrl: string;
213
- clientState?: Record<string, string>;
214
- /** Inline TwiML to execute without fetching webhook TwiML. */
215
- inlineTwiml?: string;
216
- /** TwiML to serve once before normal webhook-driven call handling resumes. */
217
- preConnectTwiml?: string;
218
- };
219
-
220
- export type InitiateCallResult = {
221
- providerCallId: ProviderCallId;
222
- status: "initiated" | "queued";
223
- };
224
-
225
- export type HangupCallInput = {
226
- callId: CallId;
227
- providerCallId: ProviderCallId;
228
- reason: EndReason;
229
- };
230
-
231
- export type AnswerCallInput = {
232
- callId: CallId;
233
- providerCallId: ProviderCallId;
234
- };
235
-
236
- export type PlayTtsInput = {
237
- callId: CallId;
238
- providerCallId: ProviderCallId;
239
- text: string;
240
- voice?: string;
241
- locale?: string;
242
- };
243
-
244
- export type SendDtmfInput = {
245
- callId: CallId;
246
- providerCallId: ProviderCallId;
247
- digits: string;
248
- };
249
-
250
- export type StartListeningInput = {
251
- callId: CallId;
252
- providerCallId: ProviderCallId;
253
- language?: string;
254
- /** Optional per-turn nonce for provider callbacks (replay hardening). */
255
- turnToken?: string;
256
- };
257
-
258
- export type StopListeningInput = {
259
- callId: CallId;
260
- providerCallId: ProviderCallId;
261
- };
262
-
263
- // -----------------------------------------------------------------------------
264
- // Call Status Verification (used on restart to verify persisted calls)
265
- // -----------------------------------------------------------------------------
266
-
267
- export type GetCallStatusInput = {
268
- providerCallId: ProviderCallId;
269
- };
270
-
271
- export type GetCallStatusResult = {
272
- /** Provider-specific status string (e.g. "completed", "in-progress") */
273
- status: string;
274
- /** True when the provider confirms the call has ended */
275
- isTerminal: boolean;
276
- /** True when the status could not be determined (transient error) */
277
- isUnknown?: boolean;
278
- };
279
-
280
- // -----------------------------------------------------------------------------
281
- // Outbound Call Options
282
- // -----------------------------------------------------------------------------
283
-
284
- export type OutboundCallOptions = {
285
- /** Message to speak when call connects */
286
- message?: string;
287
- /** Call mode (overrides config default) */
288
- mode?: CallMode;
289
- /** DTMF digits to send after the call is connected */
290
- dtmfSequence?: string;
291
- };
package/src/utils.test.ts DELETED
@@ -1,17 +0,0 @@
1
- import os from "node:os";
2
- import path from "node:path";
3
- import { describe, expect, it } from "vitest";
4
- import { resolveUserPath } from "./utils.js";
5
-
6
- describe("resolveUserPath", () => {
7
- it("returns trimmed empty input unchanged", () => {
8
- expect(resolveUserPath(" ")).toBe("");
9
- });
10
-
11
- it("expands tildes and resolves relative paths", () => {
12
- expect(resolveUserPath("~/voice-call/config.json")).toBe(
13
- path.resolve(os.homedir(), "voice-call/config.json"),
14
- );
15
- expect(resolveUserPath("./voice-call")).toBe(path.resolve("./voice-call"));
16
- });
17
- });
package/src/utils.ts DELETED
@@ -1,14 +0,0 @@
1
- import os from "node:os";
2
- import path from "node:path";
3
-
4
- export function resolveUserPath(input: string): string {
5
- const trimmed = input.trim();
6
- if (!trimmed) {
7
- return trimmed;
8
- }
9
- if (trimmed.startsWith("~")) {
10
- const expanded = trimmed.replace(/^~(?=$|[\\/])/, os.homedir());
11
- return path.resolve(expanded);
12
- }
13
- return path.resolve(trimmed);
14
- }
@@ -1,34 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- DEFAULT_POLLY_VOICE,
4
- escapeXml,
5
- getOpenAiVoiceNames,
6
- isOpenAiVoice,
7
- mapVoiceToPolly,
8
- } from "./voice-mapping.js";
9
-
10
- describe("voice mapping", () => {
11
- it("escapes xml-special characters", () => {
12
- expect(escapeXml(`5 < 6 & "quote" 'apostrophe' > 4`)).toBe(
13
- "5 &lt; 6 &amp; &quot;quote&quot; &apos;apostrophe&apos; &gt; 4",
14
- );
15
- });
16
-
17
- it("maps openai voices, passes through provider voices, and falls back to default", () => {
18
- expect(mapVoiceToPolly("alloy")).toBe("Polly.Joanna");
19
- expect(mapVoiceToPolly("ECHO")).toBe("Polly.Matthew");
20
- expect(mapVoiceToPolly("Polly.Brian")).toBe("Polly.Brian");
21
- expect(mapVoiceToPolly("Google.en-US-Standard-C")).toBe("Google.en-US-Standard-C");
22
- expect(mapVoiceToPolly("unknown")).toBe(DEFAULT_POLLY_VOICE);
23
- expect(mapVoiceToPolly(undefined)).toBe(DEFAULT_POLLY_VOICE);
24
- });
25
-
26
- it("detects known openai voices and lists them", () => {
27
- expect(isOpenAiVoice("nova")).toBe(true);
28
- expect(isOpenAiVoice("NOVA")).toBe(true);
29
- expect(isOpenAiVoice("Polly.Joanna")).toBe(false);
30
- expect(getOpenAiVoiceNames()).toEqual(
31
- expect.arrayContaining(["alloy", "echo", "fable", "nova", "onyx", "shimmer"]),
32
- );
33
- });
34
- });
@@ -1,68 +0,0 @@
1
- /**
2
- * Voice mapping and XML utilities for voice call providers.
3
- */
4
- import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
5
-
6
- /**
7
- * Escape XML special characters for TwiML and other XML responses.
8
- */
9
- export function escapeXml(text: string): string {
10
- return text
11
- .replace(/&/g, "&amp;")
12
- .replace(/</g, "&lt;")
13
- .replace(/>/g, "&gt;")
14
- .replace(/"/g, "&quot;")
15
- .replace(/'/g, "&apos;");
16
- }
17
-
18
- /**
19
- * Map of OpenAI voice names to similar Twilio Polly voices.
20
- */
21
- const OPENAI_TO_POLLY_MAP: Record<string, string> = {
22
- alloy: "Polly.Joanna", // neutral, warm
23
- echo: "Polly.Matthew", // male, warm
24
- fable: "Polly.Amy", // British, expressive
25
- onyx: "Polly.Brian", // deep male
26
- nova: "Polly.Salli", // female, friendly
27
- shimmer: "Polly.Kimberly", // female, clear
28
- };
29
-
30
- /**
31
- * Default Polly voice when no mapping is found.
32
- */
33
- export const DEFAULT_POLLY_VOICE = "Polly.Joanna";
34
-
35
- /**
36
- * Map OpenAI voice names to Twilio Polly equivalents.
37
- * Falls through if already a valid Polly/Google voice.
38
- *
39
- * @param voice - OpenAI voice name (alloy, echo, etc.) or Polly voice name
40
- * @returns Polly voice name suitable for Twilio TwiML
41
- */
42
- export function mapVoiceToPolly(voice: string | undefined): string {
43
- if (!voice) {
44
- return DEFAULT_POLLY_VOICE;
45
- }
46
-
47
- // Already a Polly/Google voice - pass through
48
- if (voice.startsWith("Polly.") || voice.startsWith("Google.")) {
49
- return voice;
50
- }
51
-
52
- // Map OpenAI voices to Polly equivalents
53
- return OPENAI_TO_POLLY_MAP[normalizeLowercaseStringOrEmpty(voice)] || DEFAULT_POLLY_VOICE;
54
- }
55
-
56
- /**
57
- * Check if a voice name is a known OpenAI voice.
58
- */
59
- export function isOpenAiVoice(voice: string): boolean {
60
- return normalizeLowercaseStringOrEmpty(voice) in OPENAI_TO_POLLY_MAP;
61
- }
62
-
63
- /**
64
- * Get all supported OpenAI voice names.
65
- */
66
- export function getOpenAiVoiceNames(): string[] {
67
- return Object.keys(OPENAI_TO_POLLY_MAP);
68
- }