@kodelyth/voice-call 2026.5.39 → 2026.5.42
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.
- package/README.md +167 -0
- package/api.ts +16 -0
- package/cli-metadata.ts +10 -0
- package/config-api.ts +12 -0
- package/dist/api.js +2 -0
- package/dist/cli-metadata.js +12 -0
- package/dist/config-DAwbG2aw.js +621 -0
- package/dist/config-compat-BYfJ5ueI.js +129 -0
- package/dist/guarded-json-api-xAIbFPZh.js +591 -0
- package/dist/index.js +1341 -0
- package/dist/mock-jtSdKDQN.js +135 -0
- package/dist/plivo-L-JTeuEc.js +392 -0
- package/dist/realtime-handler-5pSItXxX.js +1227 -0
- package/dist/realtime-transcription.runtime-CAbQKwCN.js +2 -0
- package/dist/realtime-voice.runtime-vCpCAutg.js +2 -0
- package/dist/response-generator-B-MjbtsM.js +199 -0
- package/dist/runtime-api.js +6 -0
- package/dist/runtime-entry-ohPMJR46.js +3435 -0
- package/dist/runtime-entry.js +2 -0
- package/dist/setup-api.js +37 -0
- package/dist/telnyx-BWr9EZ4x.js +278 -0
- package/dist/twilio-D9B0zY1k.js +679 -0
- package/index.test.ts +1075 -0
- package/index.ts +863 -0
- package/klaw.plugin.json +30 -133
- package/package.json +3 -3
- package/runtime-api.ts +20 -0
- package/runtime-entry.ts +1 -0
- package/setup-api.ts +47 -0
- package/src/allowlist.test.ts +18 -0
- package/src/allowlist.ts +19 -0
- package/src/cli.test.ts +12 -0
- package/src/cli.ts +866 -0
- package/src/config-compat.test.ts +130 -0
- package/src/config-compat.ts +227 -0
- package/src/config.test.ts +542 -0
- package/src/config.ts +883 -0
- package/src/core-bridge.ts +14 -0
- package/src/deep-merge.test.ts +40 -0
- package/src/deep-merge.ts +23 -0
- package/src/gateway-continue-operation.ts +200 -0
- package/src/http-headers.test.ts +16 -0
- package/src/http-headers.ts +15 -0
- package/src/manager/context.ts +50 -0
- package/src/manager/events.test.ts +578 -0
- package/src/manager/events.ts +332 -0
- package/src/manager/lifecycle.ts +53 -0
- package/src/manager/lookup.test.ts +52 -0
- package/src/manager/lookup.ts +35 -0
- package/src/manager/outbound.test.ts +629 -0
- package/src/manager/outbound.ts +508 -0
- package/src/manager/state.ts +48 -0
- package/src/manager/store.ts +107 -0
- package/src/manager/timers.test.ts +127 -0
- package/src/manager/timers.ts +113 -0
- package/src/manager/twiml.test.ts +13 -0
- package/src/manager/twiml.ts +17 -0
- package/src/manager.closed-loop.test.ts +259 -0
- package/src/manager.inbound-allowlist.test.ts +183 -0
- package/src/manager.notify.test.ts +390 -0
- package/src/manager.restore.test.ts +310 -0
- package/src/manager.test-harness.ts +127 -0
- package/src/manager.ts +441 -0
- package/src/media-stream.test.ts +953 -0
- package/src/media-stream.ts +876 -0
- package/src/providers/base.ts +99 -0
- package/src/providers/mock.test.ts +86 -0
- package/src/providers/mock.ts +185 -0
- package/src/providers/plivo.test.ts +93 -0
- package/src/providers/plivo.ts +601 -0
- package/src/providers/shared/call-status.test.ts +24 -0
- package/src/providers/shared/call-status.ts +24 -0
- package/src/providers/shared/guarded-json-api.test.ts +127 -0
- package/src/providers/shared/guarded-json-api.ts +49 -0
- package/src/providers/telnyx.test.ts +489 -0
- package/src/providers/telnyx.ts +419 -0
- package/src/providers/twilio/api.test.ts +184 -0
- package/src/providers/twilio/api.ts +100 -0
- package/src/providers/twilio/twiml-policy.test.ts +84 -0
- package/src/providers/twilio/twiml-policy.ts +87 -0
- package/src/providers/twilio/webhook.ts +34 -0
- package/src/providers/twilio.test.ts +607 -0
- package/src/providers/twilio.ts +861 -0
- package/src/providers/twilio.types.ts +17 -0
- package/src/realtime-agent-context.test.ts +101 -0
- package/src/realtime-agent-context.ts +149 -0
- package/src/realtime-defaults.ts +3 -0
- package/src/realtime-fast-context.test.ts +74 -0
- package/src/realtime-fast-context.ts +27 -0
- package/src/realtime-transcription.runtime.ts +4 -0
- package/src/realtime-voice.runtime.ts +5 -0
- package/src/response-generator.test.ts +385 -0
- package/src/response-generator.ts +348 -0
- package/src/response-model.test.ts +71 -0
- package/src/response-model.ts +23 -0
- package/src/runtime.test.ts +625 -0
- package/src/runtime.ts +528 -0
- package/src/telephony-audio.test.ts +61 -0
- package/src/telephony-audio.ts +12 -0
- package/src/telephony-tts.test.ts +196 -0
- package/src/telephony-tts.ts +235 -0
- package/src/test-fixtures.ts +82 -0
- package/src/tts-provider-voice.test.ts +34 -0
- package/src/tts-provider-voice.ts +21 -0
- package/src/tunnel.test.ts +173 -0
- package/src/tunnel.ts +314 -0
- package/src/types.ts +311 -0
- package/src/utils.test.ts +17 -0
- package/src/utils.ts +14 -0
- package/src/voice-mapping.test.ts +32 -0
- package/src/voice-mapping.ts +65 -0
- package/src/webhook/realtime-audio-pacer.test.ts +146 -0
- package/src/webhook/realtime-audio-pacer.ts +204 -0
- package/src/webhook/realtime-handler.test.ts +1450 -0
- package/src/webhook/realtime-handler.ts +1382 -0
- package/src/webhook/stale-call-reaper.test.ts +89 -0
- package/src/webhook/stale-call-reaper.ts +38 -0
- package/src/webhook/stream-frame-adapter.test.ts +187 -0
- package/src/webhook/stream-frame-adapter.ts +219 -0
- package/src/webhook/tailscale.test.ts +216 -0
- package/src/webhook/tailscale.ts +129 -0
- package/src/webhook-exposure.test.ts +33 -0
- package/src/webhook-exposure.ts +84 -0
- package/src/webhook-security.test.ts +813 -0
- package/src/webhook-security.ts +982 -0
- package/src/webhook.hangup-once.lifecycle.test.ts +179 -0
- package/src/webhook.test.ts +1615 -0
- package/src/webhook.ts +933 -0
- package/src/webhook.types.ts +5 -0
- package/src/websocket-test-support.ts +72 -0
- package/tsconfig.json +16 -0
- package/api.js +0 -7
- package/cli-metadata.js +0 -7
- package/index.js +0 -7
- package/runtime-api.js +0 -7
- package/runtime-entry.js +0 -7
- package/setup-api.js +0 -7
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { once } from "node:events";
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { WebSocket } from "ws";
|
|
4
|
+
|
|
5
|
+
export const withTimeout = async <T>(promise: Promise<T>, timeoutMs = 2000): Promise<T> => {
|
|
6
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
7
|
+
const timeout = new Promise<never>((_, reject) => {
|
|
8
|
+
timer = setTimeout(() => reject(new Error(`Timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
return await Promise.race([promise, timeout]);
|
|
13
|
+
} finally {
|
|
14
|
+
if (timer) {
|
|
15
|
+
clearTimeout(timer);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const startUpgradeWsServer = async (params: {
|
|
21
|
+
urlPath: string;
|
|
22
|
+
onUpgrade: (
|
|
23
|
+
request: http.IncomingMessage,
|
|
24
|
+
socket: Parameters<http.Server["emit"]>[2],
|
|
25
|
+
head: Buffer,
|
|
26
|
+
) => void;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
url: string;
|
|
29
|
+
close: () => Promise<void>;
|
|
30
|
+
}> => {
|
|
31
|
+
const server = http.createServer();
|
|
32
|
+
server.on("upgrade", (request, socket, head) => {
|
|
33
|
+
params.onUpgrade(request, socket, head);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await new Promise<void>((resolve) => {
|
|
37
|
+
server.listen(0, "127.0.0.1", resolve);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const address = server.address();
|
|
41
|
+
if (!address || typeof address === "string") {
|
|
42
|
+
throw new Error("Failed to resolve test server address");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
url: `ws://127.0.0.1:${address.port}${params.urlPath}`,
|
|
47
|
+
close: async () => {
|
|
48
|
+
await new Promise<void>((resolve, reject) => {
|
|
49
|
+
server.close((err) => (err ? reject(err) : resolve()));
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const connectWs = async (url: string): Promise<WebSocket> => {
|
|
56
|
+
const ws = new WebSocket(url);
|
|
57
|
+
await withTimeout(once(ws, "open") as Promise<[unknown]>);
|
|
58
|
+
return ws;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const waitForClose = async (
|
|
62
|
+
ws: WebSocket,
|
|
63
|
+
): Promise<{
|
|
64
|
+
code: number;
|
|
65
|
+
reason: string;
|
|
66
|
+
}> => {
|
|
67
|
+
const [code, reason] = (await withTimeout(once(ws, "close") as Promise<[number, Buffer]>)) ?? [];
|
|
68
|
+
return {
|
|
69
|
+
code,
|
|
70
|
+
reason: Buffer.isBuffer(reason) ? reason.toString("utf8") : String(reason || ""),
|
|
71
|
+
};
|
|
72
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.package-boundary.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "."
|
|
5
|
+
},
|
|
6
|
+
"include": ["./*.ts", "./src/**/*.ts"],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"./**/*.test.ts",
|
|
9
|
+
"./dist/**",
|
|
10
|
+
"./node_modules/**",
|
|
11
|
+
"./src/test-support/**",
|
|
12
|
+
"./src/**/*test-helpers.ts",
|
|
13
|
+
"./src/**/*test-harness.ts",
|
|
14
|
+
"./src/**/*test-support.ts"
|
|
15
|
+
]
|
|
16
|
+
}
|
package/api.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/extensions/voice-call/api.js";
|
|
2
|
-
import * as module from "../../../dist/extensions/voice-call/api.js";
|
|
3
|
-
let defaultExport = "default" in module ? module.default : module;
|
|
4
|
-
for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {
|
|
5
|
-
defaultExport = defaultExport.default;
|
|
6
|
-
}
|
|
7
|
-
export { defaultExport as default };
|
package/cli-metadata.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/extensions/voice-call/cli-metadata.js";
|
|
2
|
-
import defaultModule from "../../../dist/extensions/voice-call/cli-metadata.js";
|
|
3
|
-
let defaultExport = defaultModule;
|
|
4
|
-
for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {
|
|
5
|
-
defaultExport = defaultExport.default;
|
|
6
|
-
}
|
|
7
|
-
export { defaultExport as default };
|
package/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/extensions/voice-call/index.js";
|
|
2
|
-
import defaultModule from "../../../dist/extensions/voice-call/index.js";
|
|
3
|
-
let defaultExport = defaultModule;
|
|
4
|
-
for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {
|
|
5
|
-
defaultExport = defaultExport.default;
|
|
6
|
-
}
|
|
7
|
-
export { defaultExport as default };
|
package/runtime-api.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/extensions/voice-call/runtime-api.js";
|
|
2
|
-
import * as module from "../../../dist/extensions/voice-call/runtime-api.js";
|
|
3
|
-
let defaultExport = "default" in module ? module.default : module;
|
|
4
|
-
for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {
|
|
5
|
-
defaultExport = defaultExport.default;
|
|
6
|
-
}
|
|
7
|
-
export { defaultExport as default };
|
package/runtime-entry.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/extensions/voice-call/runtime-entry.js";
|
|
2
|
-
import * as module from "../../../dist/extensions/voice-call/runtime-entry.js";
|
|
3
|
-
let defaultExport = "default" in module ? module.default : module;
|
|
4
|
-
for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {
|
|
5
|
-
defaultExport = defaultExport.default;
|
|
6
|
-
}
|
|
7
|
-
export { defaultExport as default };
|
package/setup-api.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from "../../../dist/extensions/voice-call/setup-api.js";
|
|
2
|
-
import defaultModule from "../../../dist/extensions/voice-call/setup-api.js";
|
|
3
|
-
let defaultExport = defaultModule;
|
|
4
|
-
for (let index = 0; index < 4 && defaultExport && typeof defaultExport === "object" && "default" in defaultExport; index += 1) {
|
|
5
|
-
defaultExport = defaultExport.default;
|
|
6
|
-
}
|
|
7
|
-
export { defaultExport as default };
|