@openclaw/voice-call 2026.5.2 → 2026.5.3-beta.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 (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
@@ -1,14 +0,0 @@
1
- import type { OpenClawPluginApi } from "../api.js";
2
- import type { VoiceCallTtsConfig } from "./config.js";
3
-
4
- export type CoreConfig = {
5
- session?: {
6
- store?: string;
7
- };
8
- messages?: {
9
- tts?: VoiceCallTtsConfig;
10
- };
11
- [key: string]: unknown;
12
- };
13
-
14
- export type CoreAgentDeps = OpenClawPluginApi["runtime"]["agent"];
@@ -1,40 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { deepMergeDefined } from "./deep-merge.js";
3
-
4
- describe("deepMergeDefined", () => {
5
- it("deep merges nested plain objects and preserves base values for undefined overrides", () => {
6
- expect(
7
- deepMergeDefined(
8
- {
9
- provider: { voice: "alloy", language: "en" },
10
- enabled: true,
11
- },
12
- {
13
- provider: { voice: "echo", language: undefined },
14
- enabled: undefined,
15
- },
16
- ),
17
- ).toEqual({
18
- provider: { voice: "echo", language: "en" },
19
- enabled: true,
20
- });
21
- });
22
-
23
- it("replaces non-objects directly and blocks dangerous prototype keys", () => {
24
- expect(deepMergeDefined(["a"], ["b"])).toEqual(["b"]);
25
- expect(deepMergeDefined("base", undefined)).toBe("base");
26
- expect(
27
- deepMergeDefined(
28
- { safe: { keep: true } },
29
- {
30
- safe: { next: true },
31
- __proto__: { polluted: true },
32
- constructor: { polluted: true },
33
- prototype: { polluted: true },
34
- },
35
- ),
36
- ).toEqual({
37
- safe: { keep: true, next: true },
38
- });
39
- });
40
- });
package/src/deep-merge.ts DELETED
@@ -1,23 +0,0 @@
1
- const BLOCKED_MERGE_KEYS = new Set(["__proto__", "prototype", "constructor"]);
2
-
3
- export function deepMergeDefined(base: unknown, override: unknown): unknown {
4
- if (!isPlainObject(base) || !isPlainObject(override)) {
5
- return override === undefined ? base : override;
6
- }
7
-
8
- const result: Record<string, unknown> = { ...base };
9
- for (const [key, value] of Object.entries(override)) {
10
- if (BLOCKED_MERGE_KEYS.has(key) || value === undefined) {
11
- continue;
12
- }
13
-
14
- const existing = result[key];
15
- result[key] = key in result ? deepMergeDefined(existing, value) : value;
16
- }
17
-
18
- return result;
19
- }
20
-
21
- function isPlainObject(value: unknown): value is Record<string, unknown> {
22
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
23
- }
@@ -1,200 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
- import type { VoiceCallConfig } from "./config.js";
4
- import type { CoreConfig } from "./core-bridge.js";
5
- import type { VoiceCallRuntime } from "./runtime.js";
6
- import { TELEPHONY_DEFAULT_TTS_TIMEOUT_MS } from "./telephony-tts.js";
7
-
8
- const VOICE_CALL_CONTINUE_OPERATION_BUFFER_MS = 30000;
9
- const VOICE_CALL_CONTINUE_OPERATION_CLEANUP_MS = 5 * 60 * 1000;
10
-
11
- type VoiceCallContinueOperation =
12
- | {
13
- operationId: string;
14
- status: "pending";
15
- callId: string;
16
- startedAtMs: number;
17
- pollTimeoutMs: number;
18
- }
19
- | {
20
- operationId: string;
21
- status: "completed";
22
- callId: string;
23
- startedAtMs: number;
24
- completedAtMs: number;
25
- pollTimeoutMs: number;
26
- result: { success: true; transcript?: string };
27
- }
28
- | {
29
- operationId: string;
30
- status: "failed";
31
- callId: string;
32
- startedAtMs: number;
33
- completedAtMs: number;
34
- pollTimeoutMs: number;
35
- error: string;
36
- };
37
-
38
- type VoiceCallContinueOperationStartPayload = {
39
- operationId: string;
40
- status: "pending";
41
- pollTimeoutMs: number;
42
- };
43
-
44
- type VoiceCallContinueOperationResultPayload =
45
- | {
46
- operationId: string;
47
- status: "pending";
48
- pollTimeoutMs: number;
49
- }
50
- | {
51
- operationId: string;
52
- status: "completed";
53
- result: { success: true; transcript?: string };
54
- }
55
- | {
56
- operationId: string;
57
- status: "failed";
58
- error: string;
59
- };
60
-
61
- type VoiceCallContinueOperationRequest = {
62
- rt: VoiceCallRuntime;
63
- callId: string;
64
- message: string;
65
- };
66
-
67
- export function createVoiceCallContinueOperationStore(params: {
68
- config: VoiceCallConfig;
69
- coreConfig: CoreConfig;
70
- }) {
71
- const operations = new Map<string, VoiceCallContinueOperation>();
72
-
73
- const resolvePollTimeoutMs = (rt: VoiceCallRuntime): number => {
74
- const ttsTimeoutMs =
75
- rt.config.tts?.timeoutMs ??
76
- params.config.tts?.timeoutMs ??
77
- params.coreConfig.messages?.tts?.timeoutMs ??
78
- TELEPHONY_DEFAULT_TTS_TIMEOUT_MS;
79
- return (
80
- (rt.config.transcriptTimeoutMs ?? params.config.transcriptTimeoutMs) +
81
- ttsTimeoutMs +
82
- VOICE_CALL_CONTINUE_OPERATION_BUFFER_MS
83
- );
84
- };
85
-
86
- const scheduleCleanup = (operationId: string) => {
87
- const timer = setTimeout(() => {
88
- operations.delete(operationId);
89
- }, VOICE_CALL_CONTINUE_OPERATION_CLEANUP_MS);
90
- timer.unref?.();
91
- };
92
-
93
- const start = (
94
- request: VoiceCallContinueOperationRequest,
95
- ): VoiceCallContinueOperationStartPayload => {
96
- const operationId = randomUUID();
97
- const startedAtMs = Date.now();
98
- const pollTimeoutMs = resolvePollTimeoutMs(request.rt);
99
- operations.set(operationId, {
100
- operationId,
101
- status: "pending",
102
- callId: request.callId,
103
- startedAtMs,
104
- pollTimeoutMs,
105
- });
106
-
107
- void request.rt.manager
108
- .continueCall(request.callId, request.message)
109
- .then((result) => {
110
- const current = operations.get(operationId);
111
- if (!current || current.status !== "pending") {
112
- return;
113
- }
114
- if (!result.success) {
115
- operations.set(operationId, {
116
- operationId,
117
- status: "failed",
118
- callId: request.callId,
119
- startedAtMs,
120
- completedAtMs: Date.now(),
121
- pollTimeoutMs,
122
- error: result.error || "continue failed",
123
- });
124
- return;
125
- }
126
- operations.set(operationId, {
127
- operationId,
128
- status: "completed",
129
- callId: request.callId,
130
- startedAtMs,
131
- completedAtMs: Date.now(),
132
- pollTimeoutMs,
133
- result: { success: true, transcript: result.transcript },
134
- });
135
- })
136
- .catch((err) => {
137
- const current = operations.get(operationId);
138
- if (!current || current.status !== "pending") {
139
- return;
140
- }
141
- operations.set(operationId, {
142
- operationId,
143
- status: "failed",
144
- callId: request.callId,
145
- startedAtMs,
146
- completedAtMs: Date.now(),
147
- pollTimeoutMs,
148
- error: formatErrorMessage(err),
149
- });
150
- })
151
- .finally(() => {
152
- scheduleCleanup(operationId);
153
- });
154
-
155
- return { operationId, status: "pending", pollTimeoutMs };
156
- };
157
-
158
- const read = (
159
- operationId: string,
160
- ):
161
- | { ok: true; payload: VoiceCallContinueOperationResultPayload }
162
- | { ok: false; error: string } => {
163
- const operation = operations.get(operationId);
164
- if (!operation) {
165
- return { ok: false, error: "operation not found" };
166
- }
167
- if (operation.status === "pending") {
168
- return {
169
- ok: true,
170
- payload: {
171
- operationId,
172
- status: "pending",
173
- pollTimeoutMs: operation.pollTimeoutMs,
174
- },
175
- };
176
- }
177
- if (operation.status === "failed") {
178
- operations.delete(operationId);
179
- return {
180
- ok: true,
181
- payload: {
182
- operationId,
183
- status: "failed",
184
- error: operation.error,
185
- },
186
- };
187
- }
188
- operations.delete(operationId);
189
- return {
190
- ok: true,
191
- payload: {
192
- operationId,
193
- status: "completed",
194
- result: operation.result,
195
- },
196
- };
197
- };
198
-
199
- return { start, read };
200
- }
@@ -1,16 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { getHeader } from "./http-headers.js";
3
-
4
- describe("getHeader", () => {
5
- it("returns first value when header is an array", () => {
6
- expect(getHeader({ "x-test": ["first", "second"] }, "x-test")).toBe("first");
7
- });
8
-
9
- it("matches headers case-insensitively", () => {
10
- expect(getHeader({ "X-Twilio-Signature": "sig-1" }, "x-twilio-signature")).toBe("sig-1");
11
- });
12
-
13
- it("returns undefined for missing header", () => {
14
- expect(getHeader({ host: "example.com" }, "x-missing")).toBeUndefined();
15
- });
16
- });
@@ -1,15 +0,0 @@
1
- import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
2
-
3
- type HttpHeaderMap = Record<string, string | string[] | undefined>;
4
-
5
- export function getHeader(headers: HttpHeaderMap, name: string): string | undefined {
6
- const target = normalizeLowercaseStringOrEmpty(name);
7
- const direct = headers[target];
8
- const value =
9
- direct ??
10
- Object.entries(headers).find(([key]) => normalizeLowercaseStringOrEmpty(key) === target)?.[1];
11
- if (Array.isArray(value)) {
12
- return value[0];
13
- }
14
- return value;
15
- }
@@ -1,42 +0,0 @@
1
- import type { VoiceCallConfig } from "../config.js";
2
- import type { VoiceCallProvider } from "../providers/base.js";
3
- import type { CallId, CallRecord } from "../types.js";
4
-
5
- type TranscriptWaiter = {
6
- resolve: (text: string) => void;
7
- reject: (err: Error) => void;
8
- timeout: NodeJS.Timeout;
9
- turnToken?: string;
10
- };
11
-
12
- type CallManagerRuntimeState = {
13
- activeCalls: Map<CallId, CallRecord>;
14
- providerCallIdMap: Map<string, CallId>;
15
- processedEventIds: Set<string>;
16
- /** Provider call IDs we already sent a reject hangup for; avoids duplicate hangup calls. */
17
- rejectedProviderCallIds: Set<string>;
18
- };
19
-
20
- type CallManagerRuntimeDeps = {
21
- provider: VoiceCallProvider | null;
22
- config: VoiceCallConfig;
23
- storePath: string;
24
- webhookUrl: string | null;
25
- };
26
-
27
- type CallManagerTransientState = {
28
- activeTurnCalls: Set<CallId>;
29
- transcriptWaiters: Map<CallId, TranscriptWaiter>;
30
- maxDurationTimers: Map<CallId, NodeJS.Timeout>;
31
- initialMessageInFlight: Set<CallId>;
32
- };
33
-
34
- type CallManagerHooks = {
35
- /** Optional runtime hook invoked after an event transitions a call into answered state. */
36
- onCallAnswered?: (call: CallRecord) => void;
37
- };
38
-
39
- export type CallManagerContext = CallManagerRuntimeState &
40
- CallManagerRuntimeDeps &
41
- CallManagerTransientState &
42
- CallManagerHooks;