@sinch/functions-runtime 0.4.8 → 0.4.10

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/index.d.ts CHANGED
@@ -137,7 +137,20 @@ export interface RunMenuAction extends BaseAction {
137
137
  enableDice?: boolean;
138
138
  custom?: string;
139
139
  }
140
- /** Connect to AI agent via SIP action */
140
+ /** Connect to a WebSocket media stream (Sinch agents SDK) */
141
+ export interface ConnectStreamAction extends BaseAction {
142
+ name: "connectStream";
143
+ destination: {
144
+ type: "websocket";
145
+ endpoint: string;
146
+ };
147
+ streamingOptions?: {
148
+ sampleRate?: 8000 | 16000;
149
+ maxFrameSizeMs?: 20 | 40;
150
+ };
151
+ custom?: string;
152
+ }
153
+ /** Connect to an AI agent via SIP (e.g. ElevenLabs) */
141
154
  export interface ConnectAgentAction extends BaseAction {
142
155
  name: "connectSip";
143
156
  destination: {
@@ -146,9 +159,10 @@ export interface ConnectAgentAction extends BaseAction {
146
159
  cli?: string;
147
160
  maxDuration?: number;
148
161
  suppressCallbacks?: boolean;
162
+ custom?: string;
149
163
  }
150
164
  /** Union type for all SVAML actions */
151
- export type SvamletAction = HangupAction | ContinueAction | ConnectPstnAction | ConnectSipAction | ConnectMxpAction | ConnectConfAction | ParkAction | RunMenuAction | ConnectAgentAction;
165
+ export type SvamletAction = HangupAction | ContinueAction | ConnectPstnAction | ConnectSipAction | ConnectMxpAction | ConnectConfAction | ParkAction | RunMenuAction | ConnectStreamAction | ConnectAgentAction;
152
166
  /** Menu option definition */
153
167
  export interface MenuOption {
154
168
  dtmf: string;
@@ -387,6 +401,9 @@ export declare const MenuTemplates: {
387
401
  * Supported AI agent providers
388
402
  */
389
403
  export declare enum AgentProvider {
404
+ /** Sinch agents SDK — WebSocket media stream (default) */
405
+ Sinch = "sinch",
406
+ /** ElevenLabs — SIP-based agent */
390
407
  ElevenLabs = "elevenlabs"
391
408
  }
392
409
  /**
@@ -950,6 +967,8 @@ export interface FunctionContext {
950
967
  requestId?: string;
951
968
  /** Timestamp of the request */
952
969
  timestamp?: string;
970
+ /** Hostname from the incoming HTTP request (e.g. `my-fn.fn-dev.sinch.com`). Present in production; absent in local dev. */
971
+ host?: string;
953
972
  /** Environment variables */
954
973
  env?: Record<string, string | undefined>;
955
974
  /**
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // ../runtime-shared/dist/ai/connect-agent.js
2
2
  var AgentProvider;
3
3
  (function(AgentProvider2) {
4
+ AgentProvider2["Sinch"] = "sinch";
4
5
  AgentProvider2["ElevenLabs"] = "elevenlabs";
5
6
  })(AgentProvider || (AgentProvider = {}));
6
7
  var AgentSipHelper = class {
@@ -28,23 +29,17 @@ var AgentSipHelper = class {
28
29
  }
29
30
  };
30
31
  function createConnectAgentAction(provider, agentId, options) {
32
+ if (provider === AgentProvider.Sinch) {
33
+ throw new Error("AgentProvider.Sinch uses connectStream, not connectSip. Use connectAgent() from @sinch/agents instead.");
34
+ }
31
35
  const sipUri = AgentSipHelper.buildSipUri(provider, agentId, options);
32
- const action = {
36
+ return {
33
37
  name: "connectSip",
34
- destination: {
35
- endpoint: sipUri
36
- }
38
+ destination: { endpoint: sipUri },
39
+ ...options?.cli && { cli: options.cli },
40
+ ...options?.maxDuration !== void 0 && { maxDuration: options.maxDuration },
41
+ ...options?.suppressCallbacks !== void 0 && { suppressCallbacks: options.suppressCallbacks }
37
42
  };
38
- if (options?.cli) {
39
- action.cli = options.cli;
40
- }
41
- if (options?.maxDuration !== void 0) {
42
- action.maxDuration = options.maxDuration;
43
- }
44
- if (options?.suppressCallbacks !== void 0) {
45
- action.suppressCallbacks = options.suppressCallbacks;
46
- }
47
- return action;
48
43
  }
49
44
 
50
45
  // ../runtime-shared/dist/builders/svaml.js
@@ -1282,6 +1277,7 @@ var noOpStorage = {
1282
1277
  function buildBaseContext(req, config = {}) {
1283
1278
  return {
1284
1279
  requestId: req?.headers?.["x-request-id"] || generateRequestId(),
1280
+ host: req?.headers?.["host"],
1285
1281
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1286
1282
  env: process.env,
1287
1283
  config: {