@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
@@ -1,214 +0,0 @@
1
- import { EventEmitter } from "node:events";
2
- import { beforeEach, describe, expect, it, vi } from "vitest";
3
-
4
- const { spawnMock } = vi.hoisted(() => ({
5
- spawnMock: vi.fn(),
6
- }));
7
-
8
- vi.mock("node:child_process", async () => {
9
- const { mockNodeBuiltinModule } = await import("openclaw/plugin-sdk/test-node-mocks");
10
- return mockNodeBuiltinModule(
11
- () => vi.importActual<typeof import("node:child_process")>("node:child_process"),
12
- {
13
- spawn: spawnMock,
14
- },
15
- );
16
- });
17
-
18
- import {
19
- cleanupTailscaleExposure,
20
- cleanupTailscaleExposureRoute,
21
- getTailscaleDnsName,
22
- getTailscaleSelfInfo,
23
- setupTailscaleExposure,
24
- setupTailscaleExposureRoute,
25
- } from "./tailscale.js";
26
-
27
- function createProc(params?: { code?: number; stdout?: string }) {
28
- const proc = new EventEmitter() as EventEmitter & {
29
- stdout: EventEmitter;
30
- kill: ReturnType<typeof vi.fn>;
31
- };
32
- proc.stdout = new EventEmitter();
33
- proc.kill = vi.fn();
34
- setTimeout(() => {
35
- if (params?.stdout) {
36
- proc.stdout.emit("data", Buffer.from(params.stdout));
37
- }
38
- proc.emit("close", params?.code ?? 0);
39
- }, 0);
40
- return proc;
41
- }
42
-
43
- function createErrorProc() {
44
- const proc = new EventEmitter() as EventEmitter & {
45
- stdout: EventEmitter;
46
- kill: ReturnType<typeof vi.fn>;
47
- };
48
- proc.stdout = new EventEmitter();
49
- proc.kill = vi.fn();
50
- setTimeout(() => {
51
- proc.emit("error", Object.assign(new Error("spawn tailscale ENOENT"), { code: "ENOENT" }));
52
- }, 0);
53
- return proc;
54
- }
55
-
56
- describe("voice-call tailscale helpers", () => {
57
- beforeEach(() => {
58
- vi.clearAllMocks();
59
- });
60
-
61
- it("reads dns and node id from tailscale status json", async () => {
62
- spawnMock
63
- .mockReturnValueOnce(
64
- createProc({
65
- stdout: JSON.stringify({
66
- Self: {
67
- DNSName: "bot.example.ts.net.",
68
- ID: "node-123",
69
- },
70
- }),
71
- }),
72
- )
73
- .mockReturnValueOnce(
74
- createProc({
75
- stdout: JSON.stringify({
76
- Self: {
77
- DNSName: "bot.example.ts.net.",
78
- ID: "node-123",
79
- },
80
- }),
81
- }),
82
- );
83
-
84
- await expect(getTailscaleSelfInfo()).resolves.toEqual({
85
- dnsName: "bot.example.ts.net",
86
- nodeId: "node-123",
87
- });
88
- await expect(getTailscaleDnsName()).resolves.toBe("bot.example.ts.net");
89
- });
90
-
91
- it("returns null for failing or invalid status responses", async () => {
92
- spawnMock.mockReturnValueOnce(createProc({ code: 1, stdout: "bad" }));
93
- await expect(getTailscaleSelfInfo()).resolves.toBeNull();
94
-
95
- spawnMock.mockReturnValueOnce(createProc({ stdout: "{not-json" }));
96
- await expect(getTailscaleSelfInfo()).resolves.toBeNull();
97
- });
98
-
99
- it("treats missing tailscale binary as unavailable instead of leaking spawn errors", async () => {
100
- spawnMock.mockReturnValueOnce(createErrorProc());
101
-
102
- await expect(getTailscaleSelfInfo()).resolves.toBeNull();
103
- });
104
-
105
- it("sets up and cleans up exposure routes with the selected mode", async () => {
106
- spawnMock
107
- .mockReturnValueOnce(
108
- createProc({
109
- stdout: JSON.stringify({ Self: { DNSName: "bot.example.ts.net." } }),
110
- }),
111
- )
112
- .mockReturnValueOnce(createProc({ code: 0 }))
113
- .mockReturnValueOnce(createProc({ code: 0 }));
114
-
115
- await expect(
116
- setupTailscaleExposureRoute({
117
- mode: "serve",
118
- path: "/voice",
119
- localUrl: "http://127.0.0.1:8787/webhook",
120
- }),
121
- ).resolves.toBe("https://bot.example.ts.net/voice");
122
-
123
- await cleanupTailscaleExposureRoute({ mode: "serve", path: "/voice" });
124
-
125
- expect(spawnMock).toHaveBeenNthCalledWith(
126
- 1,
127
- "tailscale",
128
- ["status", "--json"],
129
- expect.objectContaining({ stdio: ["ignore", "pipe", "pipe"] }),
130
- );
131
- expect(spawnMock).toHaveBeenNthCalledWith(
132
- 2,
133
- "tailscale",
134
- ["serve", "--bg", "--yes", "--set-path", "/voice", "http://127.0.0.1:8787/webhook"],
135
- expect.any(Object),
136
- );
137
- expect(spawnMock).toHaveBeenNthCalledWith(
138
- 3,
139
- "tailscale",
140
- ["serve", "off", "/voice"],
141
- expect.any(Object),
142
- );
143
- });
144
-
145
- it("returns null when setup cannot resolve dns or route activation fails", async () => {
146
- spawnMock
147
- .mockReturnValueOnce(createProc({ code: 1 }))
148
- .mockReturnValueOnce(
149
- createProc({
150
- stdout: JSON.stringify({ Self: { DNSName: "bot.example.ts.net." } }),
151
- }),
152
- )
153
- .mockReturnValueOnce(createProc({ code: 1 }));
154
-
155
- await expect(
156
- setupTailscaleExposureRoute({
157
- mode: "funnel",
158
- path: "/voice",
159
- localUrl: "http://127.0.0.1:8787/webhook",
160
- }),
161
- ).resolves.toBeNull();
162
-
163
- await expect(
164
- setupTailscaleExposureRoute({
165
- mode: "funnel",
166
- path: "/voice",
167
- localUrl: "http://127.0.0.1:8787/webhook",
168
- }),
169
- ).resolves.toBeNull();
170
- });
171
-
172
- it("maps config modes to serve or funnel and skips off", async () => {
173
- spawnMock
174
- .mockReturnValueOnce(
175
- createProc({
176
- stdout: JSON.stringify({ Self: { DNSName: "bot.example.ts.net." } }),
177
- }),
178
- )
179
- .mockReturnValueOnce(createProc({ code: 0 }))
180
- .mockReturnValueOnce(createProc({ code: 0 }));
181
-
182
- await expect(
183
- setupTailscaleExposure({
184
- tailscale: { mode: "off", path: "/voice" },
185
- serve: { port: 8787, path: "/webhook" },
186
- } as never),
187
- ).resolves.toBeNull();
188
-
189
- await expect(
190
- setupTailscaleExposure({
191
- tailscale: { mode: "funnel", path: "/voice" },
192
- serve: { port: 8787, path: "/webhook" },
193
- } as never),
194
- ).resolves.toBe("https://bot.example.ts.net/voice");
195
-
196
- await cleanupTailscaleExposure({
197
- tailscale: { mode: "serve", path: "/voice" },
198
- serve: { port: 8787, path: "/webhook" },
199
- } as never);
200
-
201
- expect(spawnMock).toHaveBeenNthCalledWith(
202
- 2,
203
- "tailscale",
204
- ["funnel", "--bg", "--yes", "--set-path", "/voice", "http://127.0.0.1:8787/webhook"],
205
- expect.any(Object),
206
- );
207
- expect(spawnMock).toHaveBeenNthCalledWith(
208
- 3,
209
- "tailscale",
210
- ["serve", "off", "/voice"],
211
- expect.any(Object),
212
- );
213
- });
214
- });
@@ -1,129 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import type { VoiceCallConfig } from "../config.js";
3
-
4
- type TailscaleSelfInfo = {
5
- dnsName: string | null;
6
- nodeId: string | null;
7
- };
8
-
9
- function runTailscaleCommand(
10
- args: string[],
11
- timeoutMs = 2500,
12
- ): Promise<{ code: number; stdout: string }> {
13
- return new Promise((resolve) => {
14
- const proc = spawn("tailscale", args, {
15
- stdio: ["ignore", "pipe", "pipe"],
16
- });
17
-
18
- let stdout = "";
19
- let settled = false;
20
- let timer: ReturnType<typeof setTimeout>;
21
- const finish = (result: { code: number; stdout: string }) => {
22
- if (settled) {
23
- return;
24
- }
25
- settled = true;
26
- clearTimeout(timer);
27
- resolve(result);
28
- };
29
-
30
- proc.stdout.on("data", (data) => {
31
- stdout += data;
32
- });
33
-
34
- timer = setTimeout(() => {
35
- proc.kill("SIGKILL");
36
- finish({ code: -1, stdout: "" });
37
- }, timeoutMs);
38
-
39
- proc.on("error", () => {
40
- finish({ code: -1, stdout: "" });
41
- });
42
-
43
- proc.on("close", (code) => {
44
- finish({ code: code ?? -1, stdout });
45
- });
46
- });
47
- }
48
-
49
- export async function getTailscaleSelfInfo(): Promise<TailscaleSelfInfo | null> {
50
- const { code, stdout } = await runTailscaleCommand(["status", "--json"]);
51
- if (code !== 0) {
52
- return null;
53
- }
54
-
55
- try {
56
- const status = JSON.parse(stdout);
57
- return {
58
- dnsName: status.Self?.DNSName?.replace(/\.$/, "") || null,
59
- nodeId: status.Self?.ID || null,
60
- };
61
- } catch {
62
- return null;
63
- }
64
- }
65
-
66
- export async function getTailscaleDnsName(): Promise<string | null> {
67
- const info = await getTailscaleSelfInfo();
68
- return info?.dnsName ?? null;
69
- }
70
-
71
- export async function setupTailscaleExposureRoute(opts: {
72
- mode: "serve" | "funnel";
73
- path: string;
74
- localUrl: string;
75
- }): Promise<string | null> {
76
- const dnsName = await getTailscaleDnsName();
77
- if (!dnsName) {
78
- console.warn("[voice-call] Could not get Tailscale DNS name");
79
- return null;
80
- }
81
-
82
- const { code } = await runTailscaleCommand([
83
- opts.mode,
84
- "--bg",
85
- "--yes",
86
- "--set-path",
87
- opts.path,
88
- opts.localUrl,
89
- ]);
90
-
91
- if (code === 0) {
92
- const publicUrl = `https://${dnsName}${opts.path}`;
93
- console.log(`[voice-call] Tailscale ${opts.mode} active: ${publicUrl}`);
94
- return publicUrl;
95
- }
96
-
97
- console.warn(`[voice-call] Tailscale ${opts.mode} failed`);
98
- return null;
99
- }
100
-
101
- export async function cleanupTailscaleExposureRoute(opts: {
102
- mode: "serve" | "funnel";
103
- path: string;
104
- }): Promise<void> {
105
- await runTailscaleCommand([opts.mode, "off", opts.path]);
106
- }
107
-
108
- export async function setupTailscaleExposure(config: VoiceCallConfig): Promise<string | null> {
109
- if (config.tailscale.mode === "off") {
110
- return null;
111
- }
112
-
113
- const mode = config.tailscale.mode === "funnel" ? "funnel" : "serve";
114
- const localUrl = `http://127.0.0.1:${config.serve.port}${config.serve.path}`;
115
- return setupTailscaleExposureRoute({
116
- mode,
117
- path: config.tailscale.path,
118
- localUrl,
119
- });
120
- }
121
-
122
- export async function cleanupTailscaleExposure(config: VoiceCallConfig): Promise<void> {
123
- if (config.tailscale.mode === "off") {
124
- return;
125
- }
126
-
127
- const mode = config.tailscale.mode === "funnel" ? "funnel" : "serve";
128
- await cleanupTailscaleExposureRoute({ mode, path: config.tailscale.path });
129
- }
@@ -1,33 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { isLocalOnlyWebhookHost, isProviderUnreachableWebhookUrl } from "./webhook-exposure.js";
3
-
4
- describe("webhook exposure host classification", () => {
5
- it.each([
6
- "http://[::]:3334/voice/webhook",
7
- "http://[::1]:3334/voice/webhook",
8
- "http://[fc00::1]/voice/webhook",
9
- "http://[fd00::1]/voice/webhook",
10
- "http://[::ffff:127.0.0.1]/voice/webhook",
11
- "http://[::ffff:10.0.0.1]/voice/webhook",
12
- "http://[::ffff:192.168.0.1]/voice/webhook",
13
- "http://[::ffff:172.16.0.1]/voice/webhook",
14
- "http://[fe80::1]/voice/webhook",
15
- ])("treats local/private webhook URL %s as provider-unreachable", (url) => {
16
- expect(isProviderUnreachableWebhookUrl(url)).toBe(true);
17
- });
18
-
19
- it.each([
20
- "http://[::ffff:8.8.8.8]/voice/webhook",
21
- "https://voice.example.com/voice/webhook",
22
- "https://fcloud.example/voice/webhook",
23
- ])("does not reject public webhook URL %s", (url) => {
24
- expect(isProviderUnreachableWebhookUrl(url)).toBe(false);
25
- });
26
-
27
- it.each(["[::1]", "[fc00::1]", "[fd00::1]", "::ffff:7f00:1", "::ffff:a00:1", "[fe80::1]"])(
28
- "normalizes local/private URL hostnames like %s",
29
- (host) => {
30
- expect(isLocalOnlyWebhookHost(host)).toBe(true);
31
- },
32
- );
33
- });
@@ -1,84 +0,0 @@
1
- import { isBlockedHostnameOrIp } from "../api.js";
2
-
3
- type VoiceCallWebhookExposureConfig = {
4
- provider?: string;
5
- publicUrl?: string;
6
- tunnel?: {
7
- provider?: string;
8
- };
9
- tailscale?: {
10
- mode?: string;
11
- };
12
- };
13
-
14
- type VoiceCallWebhookExposureStatus = {
15
- ok: boolean;
16
- configured: boolean;
17
- message: string;
18
- };
19
-
20
- export function providerRequiresPublicWebhook(providerName: string | undefined): boolean {
21
- return providerName === "twilio" || providerName === "telnyx" || providerName === "plivo";
22
- }
23
-
24
- export function isLocalOnlyWebhookHost(hostname: string): boolean {
25
- return isBlockedHostnameOrIp(hostname);
26
- }
27
-
28
- export function isProviderUnreachableWebhookUrl(webhookUrl: string): boolean {
29
- try {
30
- const parsed = new URL(webhookUrl);
31
- return isLocalOnlyWebhookHost(parsed.hostname);
32
- } catch {
33
- return false;
34
- }
35
- }
36
-
37
- export function resolveWebhookExposureStatus(
38
- config: VoiceCallWebhookExposureConfig,
39
- ): VoiceCallWebhookExposureStatus {
40
- if (config.provider === "mock") {
41
- return {
42
- ok: true,
43
- configured: true,
44
- message: "Mock provider does not need a public webhook",
45
- };
46
- }
47
-
48
- if (config.publicUrl) {
49
- if (isProviderUnreachableWebhookUrl(config.publicUrl)) {
50
- return {
51
- ok: false,
52
- configured: true,
53
- message: `Public webhook URL is local/private and cannot be reached by ${config.provider ?? "the provider"}: ${config.publicUrl}`,
54
- };
55
- }
56
- return {
57
- ok: true,
58
- configured: true,
59
- message: `Public webhook URL configured: ${config.publicUrl}`,
60
- };
61
- }
62
-
63
- if (config.tunnel?.provider && config.tunnel.provider !== "none") {
64
- return {
65
- ok: true,
66
- configured: true,
67
- message: "Webhook exposure configured through tunnel",
68
- };
69
- }
70
-
71
- if (config.tailscale?.mode && config.tailscale.mode !== "off") {
72
- return {
73
- ok: true,
74
- configured: true,
75
- message: "Webhook exposure configured through Tailscale",
76
- };
77
- }
78
-
79
- return {
80
- ok: false,
81
- configured: false,
82
- message: "Set publicUrl or configure tunnel/tailscale so the provider can reach webhooks",
83
- };
84
- }