@sinch/functions-runtime 0.5.20 → 0.5.22
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 +26 -0
- package/dist/bin/sinch-runtime.js +1 -1
- package/dist/{chunk-4GLU7JTD.js → chunk-JP6PANB3.js} +102 -4
- package/dist/chunk-JP6PANB3.js.map +1 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +3 -1
- package/dist/voice/v2.d.ts +58 -0
- package/dist/voice/v2.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-4GLU7JTD.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -2600,6 +2600,64 @@ export declare class Client {
|
|
|
2600
2600
|
* ```
|
|
2601
2601
|
*/
|
|
2602
2602
|
export declare function createClient(context?: ClientContext, options?: Options): Client;
|
|
2603
|
+
/** SIP-based agent providers {@link connectAgent} can bridge to. */
|
|
2604
|
+
export type SipAgentProvider = "elevenlabs" | "grok";
|
|
2605
|
+
/** Options for {@link connectAgent}. */
|
|
2606
|
+
interface ConnectAgentOptions$1 {
|
|
2607
|
+
/**
|
|
2608
|
+
* The `call.incoming` event, when available. Used to default `from` to the caller's E.164
|
|
2609
|
+
* number and to add the `X-Sinch-Call-Id` / `X-Caller-Number` / `X-Dialed-Number` SIP
|
|
2610
|
+
* headers the grok-voice template sends — how per-call context reaches the agent without an
|
|
2611
|
+
* API round trip. Omit it and none of that context rides along.
|
|
2612
|
+
*/
|
|
2613
|
+
call?: WebhookRequest;
|
|
2614
|
+
/** Extra SIP headers, merged with the ones derived from `call` (these win on conflict). */
|
|
2615
|
+
headers?: Headers$1;
|
|
2616
|
+
/** Hard cap on call length, in seconds. Both providers bill per minute of audio. Default 1800. */
|
|
2617
|
+
maxDuration?: number;
|
|
2618
|
+
/** SIP transport. Defaults to what the provider requires — TLS for Grok, TCP for ElevenLabs. */
|
|
2619
|
+
transport?: "UDP" | "TCP" | "TLS";
|
|
2620
|
+
/** SIP host. Defaults to the provider's fixed endpoint — override only for a sandbox or proxy. */
|
|
2621
|
+
host?: string;
|
|
2622
|
+
/** SIP port. Defaults to the provider's fixed endpoint. */
|
|
2623
|
+
port?: number;
|
|
2624
|
+
/** Bridge both legs join. Defaults to {@link DEFAULT_BRIDGE_NAME}. */
|
|
2625
|
+
bridgeName?: string;
|
|
2626
|
+
/** Name for the inbound leg. Defaults to `'caller'`. */
|
|
2627
|
+
callerLeg?: string;
|
|
2628
|
+
/** Name for the leg dialled to the agent. Defaults to `'agent'`. */
|
|
2629
|
+
agentLeg?: string;
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
* Answer the caller, bridge them, dial a SIP-based AI agent into the same bridge, and end the
|
|
2633
|
+
* agent leg when the caller hangs up.
|
|
2634
|
+
*
|
|
2635
|
+
* @param provider - `'elevenlabs'` or `'grok'`. `AgentProvider.ElevenLabs` / `.Grok` from
|
|
2636
|
+
* `@sinch/functions-runtime` work here too — this parameter is a plain string, not the v1
|
|
2637
|
+
* enum, since this package cannot import from the rest of the runtime.
|
|
2638
|
+
* @param number - The number in the SIP URI's user part: for Grok, the Direct SIP phone
|
|
2639
|
+
* number registered in the xAI console; for ElevenLabs, the number attached to the agent's
|
|
2640
|
+
* phone integration. Neither provider routes by agent id. Must be an E.164 number you
|
|
2641
|
+
* configured, never a value read off a caller-controlled webhook field — it is interpolated
|
|
2642
|
+
* straight into a SIP URI.
|
|
2643
|
+
* @param options - Caller context, extra headers, duration, transport/host/port overrides,
|
|
2644
|
+
* bridge and leg names.
|
|
2645
|
+
* @throws If `provider` is not a SIP-based provider this helper supports, if `number` is not
|
|
2646
|
+
* E.164, or if `options.host` contains a character a SIP host cannot
|
|
2647
|
+
*
|
|
2648
|
+
* Return the {@link Plan} directly from `incoming` — `callName` and `onHangup` are only
|
|
2649
|
+
* honoured on a response to `call.incoming`. Handing `.commands` on to something else and
|
|
2650
|
+
* dropping the rest of the plan silently loses the agent-leg teardown, and the SIP leg bills
|
|
2651
|
+
* until `maxDuration`.
|
|
2652
|
+
*
|
|
2653
|
+
* @example
|
|
2654
|
+
* ```typescript
|
|
2655
|
+
* export const voiceWebhook = onCall({
|
|
2656
|
+
* incoming: (call) => connectAgent(AgentProvider.ElevenLabs, '+15551234567', { call }),
|
|
2657
|
+
* });
|
|
2658
|
+
* ```
|
|
2659
|
+
*/
|
|
2660
|
+
export declare function connectAgent(provider: SipAgentProvider | (string & Record<never, never>), number: string, options?: ConnectAgentOptions$1): Plan;
|
|
2603
2661
|
/**
|
|
2604
2662
|
* What `context.voice` is: the Voice API v2 client, with the v1 SDK namespace still reachable
|
|
2605
2663
|
* on `.v1`.
|
|
@@ -4670,6 +4728,7 @@ export declare const secretsLoader: SecretsLoader;
|
|
|
4670
4728
|
export {
|
|
4671
4729
|
CallResult$1 as CallResult,
|
|
4672
4730
|
CamelCaseOptions as ParserCamelCaseOptions,
|
|
4731
|
+
ConnectAgentOptions$1 as ConnectAgentV2Options,
|
|
4673
4732
|
JsonParsingOptions as ParserOptions,
|
|
4674
4733
|
createLenientJsonParser as createJsonParser,
|
|
4675
4734
|
parseJson as parseJsonLenient,
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
buildBaseContext,
|
|
38
38
|
buildVoiceSignedRequest,
|
|
39
39
|
commands,
|
|
40
|
+
connectAgent,
|
|
40
41
|
createAceBuilder,
|
|
41
42
|
createApp,
|
|
42
43
|
createCacheClient,
|
|
@@ -112,7 +113,7 @@ import {
|
|
|
112
113
|
validateVoiceSignature,
|
|
113
114
|
validateVoiceV1Request,
|
|
114
115
|
verifyVoiceWebhook
|
|
115
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-JP6PANB3.js";
|
|
116
117
|
export {
|
|
117
118
|
AceSvamlBuilder,
|
|
118
119
|
AgentProvider,
|
|
@@ -148,6 +149,7 @@ export {
|
|
|
148
149
|
buildBaseContext,
|
|
149
150
|
buildVoiceSignedRequest,
|
|
150
151
|
commands,
|
|
152
|
+
connectAgent,
|
|
151
153
|
toCamelCase as convertToCamelCase,
|
|
152
154
|
createAceBuilder,
|
|
153
155
|
createApp,
|
package/dist/voice/v2.d.ts
CHANGED
|
@@ -1086,6 +1086,64 @@ export declare const REDACTED = "[redacted]";
|
|
|
1086
1086
|
export declare function redactCredentials<T>(body: T): T;
|
|
1087
1087
|
/** `JSON.stringify`, but honouring any {@link tagOrder} tag found on nested objects. */
|
|
1088
1088
|
declare function stringify(value: unknown): string;
|
|
1089
|
+
/** SIP-based agent providers {@link connectAgent} can bridge to. */
|
|
1090
|
+
export type SipAgentProvider = "elevenlabs" | "grok";
|
|
1091
|
+
/** Options for {@link connectAgent}. */
|
|
1092
|
+
export interface ConnectAgentOptions {
|
|
1093
|
+
/**
|
|
1094
|
+
* The `call.incoming` event, when available. Used to default `from` to the caller's E.164
|
|
1095
|
+
* number and to add the `X-Sinch-Call-Id` / `X-Caller-Number` / `X-Dialed-Number` SIP
|
|
1096
|
+
* headers the grok-voice template sends — how per-call context reaches the agent without an
|
|
1097
|
+
* API round trip. Omit it and none of that context rides along.
|
|
1098
|
+
*/
|
|
1099
|
+
call?: WebhookRequest;
|
|
1100
|
+
/** Extra SIP headers, merged with the ones derived from `call` (these win on conflict). */
|
|
1101
|
+
headers?: Headers$1;
|
|
1102
|
+
/** Hard cap on call length, in seconds. Both providers bill per minute of audio. Default 1800. */
|
|
1103
|
+
maxDuration?: number;
|
|
1104
|
+
/** SIP transport. Defaults to what the provider requires — TLS for Grok, TCP for ElevenLabs. */
|
|
1105
|
+
transport?: "UDP" | "TCP" | "TLS";
|
|
1106
|
+
/** SIP host. Defaults to the provider's fixed endpoint — override only for a sandbox or proxy. */
|
|
1107
|
+
host?: string;
|
|
1108
|
+
/** SIP port. Defaults to the provider's fixed endpoint. */
|
|
1109
|
+
port?: number;
|
|
1110
|
+
/** Bridge both legs join. Defaults to {@link DEFAULT_BRIDGE_NAME}. */
|
|
1111
|
+
bridgeName?: string;
|
|
1112
|
+
/** Name for the inbound leg. Defaults to `'caller'`. */
|
|
1113
|
+
callerLeg?: string;
|
|
1114
|
+
/** Name for the leg dialled to the agent. Defaults to `'agent'`. */
|
|
1115
|
+
agentLeg?: string;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Answer the caller, bridge them, dial a SIP-based AI agent into the same bridge, and end the
|
|
1119
|
+
* agent leg when the caller hangs up.
|
|
1120
|
+
*
|
|
1121
|
+
* @param provider - `'elevenlabs'` or `'grok'`. `AgentProvider.ElevenLabs` / `.Grok` from
|
|
1122
|
+
* `@sinch/functions-runtime` work here too — this parameter is a plain string, not the v1
|
|
1123
|
+
* enum, since this package cannot import from the rest of the runtime.
|
|
1124
|
+
* @param number - The number in the SIP URI's user part: for Grok, the Direct SIP phone
|
|
1125
|
+
* number registered in the xAI console; for ElevenLabs, the number attached to the agent's
|
|
1126
|
+
* phone integration. Neither provider routes by agent id. Must be an E.164 number you
|
|
1127
|
+
* configured, never a value read off a caller-controlled webhook field — it is interpolated
|
|
1128
|
+
* straight into a SIP URI.
|
|
1129
|
+
* @param options - Caller context, extra headers, duration, transport/host/port overrides,
|
|
1130
|
+
* bridge and leg names.
|
|
1131
|
+
* @throws If `provider` is not a SIP-based provider this helper supports, if `number` is not
|
|
1132
|
+
* E.164, or if `options.host` contains a character a SIP host cannot
|
|
1133
|
+
*
|
|
1134
|
+
* Return the {@link Plan} directly from `incoming` — `callName` and `onHangup` are only
|
|
1135
|
+
* honoured on a response to `call.incoming`. Handing `.commands` on to something else and
|
|
1136
|
+
* dropping the rest of the plan silently loses the agent-leg teardown, and the SIP leg bills
|
|
1137
|
+
* until `maxDuration`.
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```typescript
|
|
1141
|
+
* export const voiceWebhook = onCall({
|
|
1142
|
+
* incoming: (call) => connectAgent(AgentProvider.ElevenLabs, '+15551234567', { call }),
|
|
1143
|
+
* });
|
|
1144
|
+
* ```
|
|
1145
|
+
*/
|
|
1146
|
+
export declare function connectAgent(provider: SipAgentProvider | (string & Record<never, never>), number: string, options?: ConnectAgentOptions): Plan;
|
|
1089
1147
|
|
|
1090
1148
|
export {
|
|
1091
1149
|
Headers$1 as Headers,
|
package/dist/voice/v2.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
REDACTED,
|
|
17
17
|
buildTransferCommands,
|
|
18
18
|
commands,
|
|
19
|
+
connectAgent,
|
|
19
20
|
createClient,
|
|
20
21
|
dialPhone,
|
|
21
22
|
dialRelay,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
stringify,
|
|
28
29
|
toCallRequest,
|
|
29
30
|
toWebhookResponse
|
|
30
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-JP6PANB3.js";
|
|
31
32
|
export {
|
|
32
33
|
Client,
|
|
33
34
|
CommandBuilder,
|
|
@@ -42,6 +43,7 @@ export {
|
|
|
42
43
|
REDACTED,
|
|
43
44
|
buildTransferCommands,
|
|
44
45
|
commands,
|
|
46
|
+
connectAgent,
|
|
45
47
|
createClient,
|
|
46
48
|
dialPhone,
|
|
47
49
|
dialRelay,
|
package/package.json
CHANGED