@sinch/functions-runtime 0.1.0-beta.28 → 0.2.1-beta
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 +166 -207
- package/dist/bin/sinch-runtime.js +454 -6
- package/dist/bin/sinch-runtime.js.map +1 -1
- package/dist/index.d.ts +91 -5
- package/dist/index.js +343 -71
- package/dist/index.js.map +1 -1
- package/package.json +5 -13
package/dist/index.d.ts
CHANGED
|
@@ -136,8 +136,18 @@ export interface RunMenuAction extends BaseAction {
|
|
|
136
136
|
enableDice?: boolean;
|
|
137
137
|
custom?: string;
|
|
138
138
|
}
|
|
139
|
+
/** Connect to AI agent via SIP action */
|
|
140
|
+
export interface ConnectAgentAction extends BaseAction {
|
|
141
|
+
name: "connectSip";
|
|
142
|
+
destination: {
|
|
143
|
+
endpoint: string;
|
|
144
|
+
};
|
|
145
|
+
cli?: string;
|
|
146
|
+
maxDuration?: number;
|
|
147
|
+
suppressCallbacks?: boolean;
|
|
148
|
+
}
|
|
139
149
|
/** Union type for all SVAML actions */
|
|
140
|
-
export type SvamletAction = HangupAction | ContinueAction | ConnectPstnAction | ConnectSipAction | ConnectMxpAction | ConnectConfAction | ParkAction | RunMenuAction;
|
|
150
|
+
export type SvamletAction = HangupAction | ContinueAction | ConnectPstnAction | ConnectSipAction | ConnectMxpAction | ConnectConfAction | ParkAction | RunMenuAction | ConnectAgentAction;
|
|
141
151
|
/** Menu option definition */
|
|
142
152
|
export interface MenuOption {
|
|
143
153
|
dtmf: string;
|
|
@@ -367,6 +377,26 @@ export declare const MenuTemplates: {
|
|
|
367
377
|
*/
|
|
368
378
|
readonly numericInput: (prompt: string, digits?: number) => MenuStructure;
|
|
369
379
|
};
|
|
380
|
+
declare enum AgentProvider {
|
|
381
|
+
ElevenLabs = "elevenlabs"
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Options for connecting to an AI agent
|
|
385
|
+
*/
|
|
386
|
+
export interface ConnectAgentOptions {
|
|
387
|
+
/** Optional caller ID to display */
|
|
388
|
+
cli?: string;
|
|
389
|
+
/** Maximum call duration in seconds */
|
|
390
|
+
maxDuration?: number;
|
|
391
|
+
/** Suppress subsequent callbacks */
|
|
392
|
+
suppressCallbacks?: boolean;
|
|
393
|
+
/** Custom headers to send to the agent */
|
|
394
|
+
customHeaders?: Record<string, string>;
|
|
395
|
+
/** Call ID for tracking */
|
|
396
|
+
callId?: string;
|
|
397
|
+
/** Caller ID for personalization */
|
|
398
|
+
callerId?: string;
|
|
399
|
+
}
|
|
370
400
|
export interface RecordingOptions {
|
|
371
401
|
/** URL to send the recording to */
|
|
372
402
|
destinationUrl?: string;
|
|
@@ -564,6 +594,22 @@ export declare class IceSvamlBuilder extends BaseSvamlBuilder<IceSvamlBuilder> {
|
|
|
564
594
|
* @param options - Park options
|
|
565
595
|
*/
|
|
566
596
|
park(holdPrompt?: string, options?: ParkOptions): this;
|
|
597
|
+
/**
|
|
598
|
+
* Connect to an AI voice agent
|
|
599
|
+
*
|
|
600
|
+
* @param provider - The AI agent provider (e.g., AgentProvider.ElevenLabs)
|
|
601
|
+
* @param agentId - The agent ID to connect to
|
|
602
|
+
* @param options - Connection options
|
|
603
|
+
*
|
|
604
|
+
* @example
|
|
605
|
+
* ```typescript
|
|
606
|
+
* return new IceSvamlBuilder()
|
|
607
|
+
* .say('Connecting you to our AI assistant.')
|
|
608
|
+
* .connectAgent(AgentProvider.ElevenLabs, 'agent_123')
|
|
609
|
+
* .build();
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
612
|
+
connectAgent(provider: AgentProvider, agentId: string, options?: ConnectAgentOptions): this;
|
|
567
613
|
}
|
|
568
614
|
/**
|
|
569
615
|
* ACE (Answered Call Event) SVAML Builder
|
|
@@ -631,6 +677,25 @@ export declare class PieSvamlBuilder extends BaseSvamlBuilder<PieSvamlBuilder> {
|
|
|
631
677
|
* @param options - Park options
|
|
632
678
|
*/
|
|
633
679
|
park(holdPrompt?: string, options?: ParkOptions): this;
|
|
680
|
+
/**
|
|
681
|
+
* Connect to an AI voice agent
|
|
682
|
+
*
|
|
683
|
+
* @param provider - The AI agent provider (e.g., AgentProvider.ElevenLabs)
|
|
684
|
+
* @param agentId - The agent ID to connect to
|
|
685
|
+
* @param options - Connection options
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* ```typescript
|
|
689
|
+
* // Transfer to AI agent based on menu selection
|
|
690
|
+
* if (event.menuResult?.value === 'ai') {
|
|
691
|
+
* return new PieSvamlBuilder()
|
|
692
|
+
* .say('Connecting you to our AI assistant.')
|
|
693
|
+
* .connectAgent(AgentProvider.ElevenLabs, 'agent_123')
|
|
694
|
+
* .build();
|
|
695
|
+
* }
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
connectAgent(provider: AgentProvider, agentId: string, options?: ConnectAgentOptions): this;
|
|
634
699
|
}
|
|
635
700
|
/**
|
|
636
701
|
* Create a new ICE SVAML builder
|
|
@@ -1283,28 +1348,49 @@ export declare function createCacheClient(_projectId?: string, _functionName?: s
|
|
|
1283
1348
|
/**
|
|
1284
1349
|
* Tunnel Client for Sinch Functions
|
|
1285
1350
|
*
|
|
1286
|
-
* Connects to the Sinch
|
|
1287
|
-
* incoming voice callbacks during local development.
|
|
1351
|
+
* Connects to the Sinch tunnel gateway via WebSocket to receive
|
|
1352
|
+
* incoming voice and conversation callbacks during local development.
|
|
1353
|
+
*
|
|
1354
|
+
* Features:
|
|
1355
|
+
* - Voice webhook auto-configuration
|
|
1356
|
+
* - Conversation webhook auto-configuration with cleanup
|
|
1357
|
+
* - ElevenLabs auto-configuration (when enabled)
|
|
1358
|
+
* - Stale webhook cleanup on connect
|
|
1359
|
+
* - Webhook cleanup on disconnect
|
|
1288
1360
|
*/
|
|
1289
1361
|
export declare class TunnelClient {
|
|
1290
1362
|
private ws;
|
|
1291
1363
|
private tunnelUrl;
|
|
1364
|
+
private tunnelId;
|
|
1292
1365
|
private isConnected;
|
|
1293
1366
|
private reconnectAttempts;
|
|
1294
1367
|
private maxReconnectAttempts;
|
|
1295
1368
|
private reconnectDelay;
|
|
1296
1369
|
private heartbeatInterval;
|
|
1297
1370
|
private localPort;
|
|
1371
|
+
private webhookConfig;
|
|
1372
|
+
private welcomeResolver;
|
|
1298
1373
|
constructor(localPort?: number);
|
|
1374
|
+
private getTunnelGatewayUrl;
|
|
1375
|
+
private generateTunnelId;
|
|
1299
1376
|
connect(): Promise<void>;
|
|
1300
1377
|
private handleMessage;
|
|
1378
|
+
private handleWelcomeMessage;
|
|
1301
1379
|
private handleRequest;
|
|
1302
1380
|
private sendPong;
|
|
1303
1381
|
private startHeartbeat;
|
|
1304
1382
|
private stopHeartbeat;
|
|
1305
|
-
|
|
1383
|
+
/**
|
|
1384
|
+
* Configure all webhooks (Voice, Conversation, ElevenLabs)
|
|
1385
|
+
*/
|
|
1386
|
+
private configureWebhooks;
|
|
1387
|
+
/**
|
|
1388
|
+
* Cleanup webhooks on disconnect
|
|
1389
|
+
*/
|
|
1390
|
+
private cleanupWebhooks;
|
|
1391
|
+
private configureVoiceWebhooks;
|
|
1306
1392
|
private scheduleReconnect;
|
|
1307
|
-
disconnect(): void
|
|
1393
|
+
disconnect(): Promise<void>;
|
|
1308
1394
|
getTunnelUrl(): string | null;
|
|
1309
1395
|
getIsConnected(): boolean;
|
|
1310
1396
|
}
|