@sinch/functions-runtime 0.5.9 → 0.5.12
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/dist/bin/sinch-runtime.js +6 -4
- package/dist/bin/sinch-runtime.js.map +1 -1
- package/dist/{chunk-LU5JRQ64.js → chunk-IRSTA74R.js} +293 -62
- package/dist/chunk-IRSTA74R.js.map +1 -0
- package/dist/chunk-X44DQ6CI.js +52 -0
- package/dist/chunk-X44DQ6CI.js.map +1 -0
- package/dist/index.d.ts +67 -19
- package/dist/index.js +2 -1
- package/dist/voice/v2.d.ts +1597 -0
- package/dist/voice/v2.js +1259 -0
- package/dist/voice/v2.js.map +1 -0
- package/package.json +7 -2
- package/dist/chunk-LU5JRQ64.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __sinchCreateRequire } from 'node:module';
|
|
3
|
+
const require = __sinchCreateRequire(import.meta.url);
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
11
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
12
|
+
}) : x)(function(x) {
|
|
13
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
14
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
15
|
+
});
|
|
16
|
+
var __esm = (fn, res) => function __init() {
|
|
17
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
+
};
|
|
19
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
20
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
21
|
+
};
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
42
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
__require,
|
|
46
|
+
__esm,
|
|
47
|
+
__commonJS,
|
|
48
|
+
__export,
|
|
49
|
+
__toESM,
|
|
50
|
+
__toCommonJS
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=chunk-X44DQ6CI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -102,7 +102,11 @@ export interface ConnectPstnAction extends BaseAction {
|
|
|
102
102
|
/** Connect to SIP action */
|
|
103
103
|
export interface ConnectSipAction extends BaseAction {
|
|
104
104
|
name: "connectSip";
|
|
105
|
-
|
|
105
|
+
/** SVAML `destinationSip` — a discriminated object; both fields are required. */
|
|
106
|
+
destination: {
|
|
107
|
+
type: "sip";
|
|
108
|
+
endpoint: string;
|
|
109
|
+
};
|
|
106
110
|
cli?: string;
|
|
107
111
|
headers?: Record<string, string>;
|
|
108
112
|
custom?: string;
|
|
@@ -110,7 +114,11 @@ export interface ConnectSipAction extends BaseAction {
|
|
|
110
114
|
/** Connect to MXP (Sinch SDK) action */
|
|
111
115
|
export interface ConnectMxpAction extends BaseAction {
|
|
112
116
|
name: "connectMxp";
|
|
113
|
-
|
|
117
|
+
/** SVAML `destinationMxp` — a discriminated object; both fields are required. */
|
|
118
|
+
destination: {
|
|
119
|
+
type: "username" | "Username";
|
|
120
|
+
endpoint: string;
|
|
121
|
+
};
|
|
114
122
|
cli?: string;
|
|
115
123
|
custom?: string;
|
|
116
124
|
}
|
|
@@ -155,11 +163,19 @@ export interface ConnectStreamAction extends BaseAction {
|
|
|
155
163
|
export interface ConnectAgentAction extends BaseAction {
|
|
156
164
|
name: "connectSip";
|
|
157
165
|
destination: {
|
|
166
|
+
type: "sip";
|
|
158
167
|
endpoint: string;
|
|
159
168
|
};
|
|
169
|
+
/** SIP transport. Grok's endpoint is TLS-only; most others accept TCP. */
|
|
170
|
+
transport?: "UDP" | "TCP" | "TLS";
|
|
160
171
|
cli?: string;
|
|
161
172
|
maxDuration?: number;
|
|
162
173
|
suppressCallbacks?: boolean;
|
|
174
|
+
/** Private SIP headers the far end sees — xAI surfaces these to the agent as `sip_headers`. */
|
|
175
|
+
callHeaders?: {
|
|
176
|
+
key: string;
|
|
177
|
+
value: string;
|
|
178
|
+
}[];
|
|
163
179
|
custom?: string;
|
|
164
180
|
}
|
|
165
181
|
/** Union type for all SVAML actions */
|
|
@@ -393,11 +409,6 @@ export declare const MenuTemplates: {
|
|
|
393
409
|
*/
|
|
394
410
|
readonly numericInput: (prompt: string, digits?: number) => MenuStructure;
|
|
395
411
|
};
|
|
396
|
-
/**
|
|
397
|
-
* Connect Agent Action for SVAML Builders
|
|
398
|
-
*
|
|
399
|
-
* Provides the ability to connect voice calls to AI agents via SIP.
|
|
400
|
-
*/
|
|
401
412
|
/**
|
|
402
413
|
* Supported AI agent providers
|
|
403
414
|
*/
|
|
@@ -405,7 +416,9 @@ export declare enum AgentProvider {
|
|
|
405
416
|
/** Sinch agents SDK — WebSocket media stream (default) */
|
|
406
417
|
Sinch = "sinch",
|
|
407
418
|
/** ElevenLabs — SIP-based agent */
|
|
408
|
-
ElevenLabs = "elevenlabs"
|
|
419
|
+
ElevenLabs = "elevenlabs",
|
|
420
|
+
/** xAI Grok Voice — SIP-based agent, TLS only */
|
|
421
|
+
Grok = "grok"
|
|
409
422
|
}
|
|
410
423
|
/**
|
|
411
424
|
* Options for connecting to an AI agent
|
|
@@ -417,7 +430,21 @@ export interface ConnectAgentOptions {
|
|
|
417
430
|
maxDuration?: number;
|
|
418
431
|
/** Suppress subsequent callbacks */
|
|
419
432
|
suppressCallbacks?: boolean;
|
|
420
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* Private SIP headers sent with the INVITE.
|
|
435
|
+
*
|
|
436
|
+
* These become SVAML `callHeaders` — real headers the far end sees. xAI surfaces them to the
|
|
437
|
+
* agent as `sip_headers`, which is how per-call context reaches it without an API round trip.
|
|
438
|
+
*/
|
|
439
|
+
callHeaders?: Record<string, string>;
|
|
440
|
+
/** SIP transport. Defaults to what the provider requires — TLS for Grok, TCP otherwise. */
|
|
441
|
+
transport?: "UDP" | "TCP" | "TLS";
|
|
442
|
+
/**
|
|
443
|
+
* Parameters appended to the SIP URI itself (`;key=value`).
|
|
444
|
+
*
|
|
445
|
+
* NOT SIP headers, despite the historical name — most providers will not surface these to an
|
|
446
|
+
* agent. Use `callHeaders` for per-call context.
|
|
447
|
+
*/
|
|
421
448
|
customHeaders?: Record<string, string>;
|
|
422
449
|
/** Call ID for tracking */
|
|
423
450
|
callId?: string;
|
|
@@ -432,6 +459,23 @@ export declare class AgentSipHelper {
|
|
|
432
459
|
* Build a SIP URI for connecting to an ElevenLabs agent
|
|
433
460
|
*/
|
|
434
461
|
static buildElevenLabsSipUri(agentId: string, options?: ConnectAgentOptions): string;
|
|
462
|
+
/**
|
|
463
|
+
* Build a SIP URI for connecting to an xAI Grok Voice agent.
|
|
464
|
+
*
|
|
465
|
+
* Note the user part is the **Direct SIP phone number** registered in the xAI console, not an
|
|
466
|
+
* agent id — xAI routes the INVITE to whichever agent is attached to that number. This is the
|
|
467
|
+
* one place Grok differs sharply from ElevenLabs, which puts the agent id there.
|
|
468
|
+
*
|
|
469
|
+
* @see https://docs.x.ai/developers/model-capabilities/audio/voice-agent/sip
|
|
470
|
+
*/
|
|
471
|
+
static buildGrokSipUri(phoneNumber: string, options?: ConnectAgentOptions): string;
|
|
472
|
+
/**
|
|
473
|
+
* The SIP transport a provider's endpoint requires.
|
|
474
|
+
*
|
|
475
|
+
* Mirrors the C# runtime's `GetTransport`. xAI's endpoint is TLS-only — sending TCP to it is
|
|
476
|
+
* refused outright.
|
|
477
|
+
*/
|
|
478
|
+
static getTransport(provider: AgentProvider): "UDP" | "TCP" | "TLS";
|
|
435
479
|
/**
|
|
436
480
|
* Build a SIP URI for the given provider and agent
|
|
437
481
|
*/
|
|
@@ -441,15 +485,7 @@ export declare class AgentSipHelper {
|
|
|
441
485
|
* Create a connectSip SVAML action for SIP-based AI agent providers (e.g. ElevenLabs).
|
|
442
486
|
* For Sinch WebSocket agents use connectStream directly.
|
|
443
487
|
*/
|
|
444
|
-
export declare function createConnectAgentAction(provider: AgentProvider, agentId: string, options?: ConnectAgentOptions):
|
|
445
|
-
name: "connectSip";
|
|
446
|
-
destination: {
|
|
447
|
-
endpoint: string;
|
|
448
|
-
};
|
|
449
|
-
cli?: string;
|
|
450
|
-
maxDuration?: number;
|
|
451
|
-
suppressCallbacks?: boolean;
|
|
452
|
-
};
|
|
488
|
+
export declare function createConnectAgentAction(provider: AgentProvider, agentId: string, options?: ConnectAgentOptions): ConnectAgentAction;
|
|
453
489
|
export interface RecordingOptions {
|
|
454
490
|
/** URL to send the recording to */
|
|
455
491
|
destinationUrl?: string;
|
|
@@ -1495,7 +1531,16 @@ export interface FormattedResponse {
|
|
|
1495
1531
|
headers?: Record<string, string>;
|
|
1496
1532
|
body?: unknown;
|
|
1497
1533
|
}
|
|
1498
|
-
/**
|
|
1534
|
+
/**
|
|
1535
|
+
* Voice callback function names @internal
|
|
1536
|
+
*
|
|
1537
|
+
* Membership here is what makes a route signature-validated — see the `isVoiceCallback` gate
|
|
1538
|
+
* below. Deliberately v1-only: the validator is `validateAuthenticationHeader`, which is the v1
|
|
1539
|
+
* scheme keyed on `VOICE_APPLICATION_KEY`/`SECRET`. Adding the v2 route (`voiceWebhook`) here
|
|
1540
|
+
* would reject every legitimate v2 webhook, and on a v2-only function those credentials do not
|
|
1541
|
+
* exist at all, so the gate would silently do nothing. v2 defends itself in
|
|
1542
|
+
* `handleVoiceV2Webhook` instead — see the note there.
|
|
1543
|
+
*/
|
|
1499
1544
|
export declare const VOICE_CALLBACKS: readonly [
|
|
1500
1545
|
"ice",
|
|
1501
1546
|
"ace",
|
|
@@ -2661,7 +2706,10 @@ export declare class TunnelClient {
|
|
|
2661
2706
|
private localPort;
|
|
2662
2707
|
private webhookConfig;
|
|
2663
2708
|
private welcomeResolver;
|
|
2709
|
+
private streams;
|
|
2664
2710
|
constructor(localPort?: number);
|
|
2711
|
+
/** Sends one JSON message up the tunnel channel, if it is still connected. */
|
|
2712
|
+
private sendMessage;
|
|
2665
2713
|
private getTunnelGatewayUrl;
|
|
2666
2714
|
private generateTunnelId;
|
|
2667
2715
|
connect(): Promise<void>;
|
package/dist/index.js
CHANGED