livekit-server-sdk 2.15.1 → 2.15.3
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/AgentDispatchClient.cjs +2 -1
- package/dist/AgentDispatchClient.cjs.map +1 -1
- package/dist/AgentDispatchClient.d.cts +2 -1
- package/dist/AgentDispatchClient.d.ts +2 -1
- package/dist/AgentDispatchClient.d.ts.map +1 -1
- package/dist/AgentDispatchClient.js +2 -1
- package/dist/AgentDispatchClient.js.map +1 -1
- package/dist/ConnectorClient.cjs +12 -5
- package/dist/ConnectorClient.cjs.map +1 -1
- package/dist/ConnectorClient.d.cts +11 -3
- package/dist/ConnectorClient.d.ts +11 -3
- package/dist/ConnectorClient.d.ts.map +1 -1
- package/dist/ConnectorClient.js +12 -5
- package/dist/ConnectorClient.js.map +1 -1
- package/dist/SipClient.cjs +2 -1
- package/dist/SipClient.cjs.map +1 -1
- package/dist/SipClient.d.cts +2 -0
- package/dist/SipClient.d.ts +2 -0
- package/dist/SipClient.d.ts.map +1 -1
- package/dist/SipClient.js +2 -3
- package/dist/SipClient.js.map +1 -1
- package/dist/grants.cjs.map +1 -1
- package/dist/grants.d.cts +2 -0
- package/dist/grants.d.ts +2 -0
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js.map +1 -1
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/AgentDispatchClient.ts +4 -0
- package/src/ConnectorClient.ts +20 -1
- package/src/SipClient.ts +7 -2
- package/src/grants.ts +3 -0
- package/src/index.ts +2 -0
|
@@ -49,7 +49,8 @@ class AgentDispatchClient extends import_ServiceBase.ServiceBase {
|
|
|
49
49
|
const req = new import_protocol.CreateAgentDispatchRequest({
|
|
50
50
|
room: roomName,
|
|
51
51
|
agentName,
|
|
52
|
-
metadata: options == null ? void 0 : options.metadata
|
|
52
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
53
|
+
restartPolicy: options == null ? void 0 : options.restartPolicy
|
|
53
54
|
}).toJson();
|
|
54
55
|
const data = await this.rpc.request(
|
|
55
56
|
svc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AgentDispatchClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport {\n AgentDispatch,\n CreateAgentDispatchRequest,\n DeleteAgentDispatchRequest,\n ListAgentDispatchRequest,\n ListAgentDispatchResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\ninterface CreateDispatchOptions {\n // any custom data to send along with the job.\n // note: this is different from room and participant metadata\n metadata?: string;\n}\n\nconst svc = 'AgentDispatchService';\n\n/**\n * Client to access Agent APIs\n */\nexport class AgentDispatchClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Create an explicit dispatch for an agent to join a room. To use explicit\n * dispatch, your agent must be registered with an `agentName`.\n * @param roomName - name of the room to dispatch to\n * @param agentName - name of the agent to dispatch\n * @param options - optional metadata to send along with the dispatch\n * @returns the dispatch that was created\n */\n async createDispatch(\n roomName: string,\n agentName: string,\n options?: CreateDispatchOptions,\n ): Promise<AgentDispatch> {\n const req = new CreateAgentDispatchRequest({\n room: roomName,\n agentName,\n metadata: options?.metadata,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'CreateDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n return AgentDispatch.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Delete an explicit dispatch for an agent in a room.\n * @param dispatchId - id of the dispatch to delete\n * @param roomName - name of the room the dispatch is for\n */\n async deleteDispatch(dispatchId: string, roomName: string): Promise<void> {\n const req = new DeleteAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n await this.rpc.request(\n svc,\n 'DeleteDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n }\n\n /**\n * Get an Agent dispatch by ID\n * @param dispatchId - id of the dispatch to get\n * @param roomName - name of the room the dispatch is for\n * @returns the dispatch that was found, or undefined if not found\n */\n async getDispatch(dispatchId: string, roomName: string): Promise<AgentDispatch | undefined> {\n const req = new ListAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n if (res.agentDispatches.length === 0) {\n return undefined;\n }\n return res.agentDispatches[0];\n }\n\n /**\n * List all agent dispatches for a room\n * @param roomName - name of the room to list dispatches for\n * @returns the list of dispatches\n */\n async listDispatch(roomName: string): Promise<AgentDispatch[]> {\n const req = new ListAgentDispatchRequest({\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.agentDispatches;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
1
|
+
{"version":3,"sources":["../src/AgentDispatchClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport {\n AgentDispatch,\n CreateAgentDispatchRequest,\n DeleteAgentDispatchRequest,\n type JobRestartPolicy,\n ListAgentDispatchRequest,\n ListAgentDispatchResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\ninterface CreateDispatchOptions {\n // any custom data to send along with the job.\n // note: this is different from room and participant metadata\n metadata?: string;\n // controls whether the job should be restarted when it fails (cloud only)\n restartPolicy?: JobRestartPolicy;\n}\n\nconst svc = 'AgentDispatchService';\n\n/**\n * Client to access Agent APIs\n */\nexport class AgentDispatchClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Create an explicit dispatch for an agent to join a room. To use explicit\n * dispatch, your agent must be registered with an `agentName`.\n * @param roomName - name of the room to dispatch to\n * @param agentName - name of the agent to dispatch\n * @param options - optional metadata to send along with the dispatch\n * @returns the dispatch that was created\n */\n async createDispatch(\n roomName: string,\n agentName: string,\n options?: CreateDispatchOptions,\n ): Promise<AgentDispatch> {\n const req = new CreateAgentDispatchRequest({\n room: roomName,\n agentName,\n metadata: options?.metadata,\n restartPolicy: options?.restartPolicy,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'CreateDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n return AgentDispatch.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Delete an explicit dispatch for an agent in a room.\n * @param dispatchId - id of the dispatch to delete\n * @param roomName - name of the room the dispatch is for\n */\n async deleteDispatch(dispatchId: string, roomName: string): Promise<void> {\n const req = new DeleteAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n await this.rpc.request(\n svc,\n 'DeleteDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n }\n\n /**\n * Get an Agent dispatch by ID\n * @param dispatchId - id of the dispatch to get\n * @param roomName - name of the room the dispatch is for\n * @returns the dispatch that was found, or undefined if not found\n */\n async getDispatch(dispatchId: string, roomName: string): Promise<AgentDispatch | undefined> {\n const req = new ListAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n if (res.agentDispatches.length === 0) {\n return undefined;\n }\n return res.agentDispatches[0];\n }\n\n /**\n * List all agent dispatches for a room\n * @param roomName - name of the room to list dispatches for\n * @returns the list of dispatches\n */\n async listDispatch(roomName: string): Promise<AgentDispatch[]> {\n const req = new ListAgentDispatchRequest({\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.agentDispatches;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAOO;AAEP,yBAA4B;AAC5B,sBAAmD;AAUnD,MAAM,MAAM;AAKL,MAAM,4BAA4B,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnD,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM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,EAAE,qBAAqB,KAAK,CAAC;AAClF,QAAI,IAAI,gBAAgB,WAAW,GAAG;AACpC,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gBAAgB,CAAC;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA4C;AAC7D,UAAM,MAAM,IAAI,yCAAyB;AAAA,MACvC,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AACA,UAAM,MAAM,0CAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAClF,WAAO,IAAI;AAAA,EACb;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentDispatch } from '@livekit/protocol';
|
|
1
|
+
import { JobRestartPolicy, AgentDispatch } from '@livekit/protocol';
|
|
2
2
|
import { ClientOptions } from './ClientOptions.cjs';
|
|
3
3
|
import { ServiceBase } from './ServiceBase.cjs';
|
|
4
4
|
import './grants.cjs';
|
|
@@ -6,6 +6,7 @@ import 'jose';
|
|
|
6
6
|
|
|
7
7
|
interface CreateDispatchOptions {
|
|
8
8
|
metadata?: string;
|
|
9
|
+
restartPolicy?: JobRestartPolicy;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Client to access Agent APIs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentDispatch } from '@livekit/protocol';
|
|
1
|
+
import { JobRestartPolicy, AgentDispatch } from '@livekit/protocol';
|
|
2
2
|
import { ClientOptions } from './ClientOptions.js';
|
|
3
3
|
import { ServiceBase } from './ServiceBase.js';
|
|
4
4
|
import './grants.js';
|
|
@@ -6,6 +6,7 @@ import 'jose';
|
|
|
6
6
|
|
|
7
7
|
interface CreateDispatchOptions {
|
|
8
8
|
metadata?: string;
|
|
9
|
+
restartPolicy?: JobRestartPolicy;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Client to access Agent APIs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentDispatchClient.d.ts","sourceRoot":"","sources":["../src/AgentDispatchClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"AgentDispatchClient.d.ts","sourceRoot":"","sources":["../src/AgentDispatchClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAGb,KAAK,gBAAgB,EAGtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,UAAU,qBAAqB;IAG7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,aAAa,CAAC,EAAE,gBAAgB,CAAC;CAClC;AAID;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAE1B;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;IAQnF;;;;;;;OAOG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,CAAC;IAgBzB;;;;OAIG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAazE;;;;;OAKG;IACG,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAkB3F;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAa/D"}
|
|
@@ -32,7 +32,8 @@ class AgentDispatchClient extends ServiceBase {
|
|
|
32
32
|
const req = new CreateAgentDispatchRequest({
|
|
33
33
|
room: roomName,
|
|
34
34
|
agentName,
|
|
35
|
-
metadata: options == null ? void 0 : options.metadata
|
|
35
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
36
|
+
restartPolicy: options == null ? void 0 : options.restartPolicy
|
|
36
37
|
}).toJson();
|
|
37
38
|
const data = await this.rpc.request(
|
|
38
39
|
svc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AgentDispatchClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport {\n AgentDispatch,\n CreateAgentDispatchRequest,\n DeleteAgentDispatchRequest,\n ListAgentDispatchRequest,\n ListAgentDispatchResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\ninterface CreateDispatchOptions {\n // any custom data to send along with the job.\n // note: this is different from room and participant metadata\n metadata?: string;\n}\n\nconst svc = 'AgentDispatchService';\n\n/**\n * Client to access Agent APIs\n */\nexport class AgentDispatchClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Create an explicit dispatch for an agent to join a room. To use explicit\n * dispatch, your agent must be registered with an `agentName`.\n * @param roomName - name of the room to dispatch to\n * @param agentName - name of the agent to dispatch\n * @param options - optional metadata to send along with the dispatch\n * @returns the dispatch that was created\n */\n async createDispatch(\n roomName: string,\n agentName: string,\n options?: CreateDispatchOptions,\n ): Promise<AgentDispatch> {\n const req = new CreateAgentDispatchRequest({\n room: roomName,\n agentName,\n metadata: options?.metadata,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'CreateDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n return AgentDispatch.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Delete an explicit dispatch for an agent in a room.\n * @param dispatchId - id of the dispatch to delete\n * @param roomName - name of the room the dispatch is for\n */\n async deleteDispatch(dispatchId: string, roomName: string): Promise<void> {\n const req = new DeleteAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n await this.rpc.request(\n svc,\n 'DeleteDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n }\n\n /**\n * Get an Agent dispatch by ID\n * @param dispatchId - id of the dispatch to get\n * @param roomName - name of the room the dispatch is for\n * @returns the dispatch that was found, or undefined if not found\n */\n async getDispatch(dispatchId: string, roomName: string): Promise<AgentDispatch | undefined> {\n const req = new ListAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n if (res.agentDispatches.length === 0) {\n return undefined;\n }\n return res.agentDispatches[0];\n }\n\n /**\n * List all agent dispatches for a room\n * @param roomName - name of the room to list dispatches for\n * @returns the list of dispatches\n */\n async listDispatch(roomName: string): Promise<AgentDispatch[]> {\n const req = new ListAgentDispatchRequest({\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.agentDispatches;\n }\n}\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/AgentDispatchClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport {\n AgentDispatch,\n CreateAgentDispatchRequest,\n DeleteAgentDispatchRequest,\n type JobRestartPolicy,\n ListAgentDispatchRequest,\n ListAgentDispatchResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\ninterface CreateDispatchOptions {\n // any custom data to send along with the job.\n // note: this is different from room and participant metadata\n metadata?: string;\n // controls whether the job should be restarted when it fails (cloud only)\n restartPolicy?: JobRestartPolicy;\n}\n\nconst svc = 'AgentDispatchService';\n\n/**\n * Client to access Agent APIs\n */\nexport class AgentDispatchClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Create an explicit dispatch for an agent to join a room. To use explicit\n * dispatch, your agent must be registered with an `agentName`.\n * @param roomName - name of the room to dispatch to\n * @param agentName - name of the agent to dispatch\n * @param options - optional metadata to send along with the dispatch\n * @returns the dispatch that was created\n */\n async createDispatch(\n roomName: string,\n agentName: string,\n options?: CreateDispatchOptions,\n ): Promise<AgentDispatch> {\n const req = new CreateAgentDispatchRequest({\n room: roomName,\n agentName,\n metadata: options?.metadata,\n restartPolicy: options?.restartPolicy,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'CreateDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n return AgentDispatch.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Delete an explicit dispatch for an agent in a room.\n * @param dispatchId - id of the dispatch to delete\n * @param roomName - name of the room the dispatch is for\n */\n async deleteDispatch(dispatchId: string, roomName: string): Promise<void> {\n const req = new DeleteAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n await this.rpc.request(\n svc,\n 'DeleteDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n }\n\n /**\n * Get an Agent dispatch by ID\n * @param dispatchId - id of the dispatch to get\n * @param roomName - name of the room the dispatch is for\n * @returns the dispatch that was found, or undefined if not found\n */\n async getDispatch(dispatchId: string, roomName: string): Promise<AgentDispatch | undefined> {\n const req = new ListAgentDispatchRequest({\n dispatchId,\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n if (res.agentDispatches.length === 0) {\n return undefined;\n }\n return res.agentDispatches[0];\n }\n\n /**\n * List all agent dispatches for a room\n * @param roomName - name of the room to list dispatches for\n * @returns the list of dispatches\n */\n async listDispatch(roomName: string): Promise<AgentDispatch[]> {\n const req = new ListAgentDispatchRequest({\n room: roomName,\n }).toJson();\n const data = await this.rpc.request(\n svc,\n 'ListDispatch',\n req,\n await this.authHeader({ roomAdmin: true, room: roomName }),\n );\n const res = ListAgentDispatchResponse.fromJson(data, { ignoreUnknownFields: true });\n return res.agentDispatches;\n }\n}\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,E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AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AACA,UAAM,MAAM,0BAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAClF,QAAI,IAAI,gBAAgB,WAAW,GAAG;AACpC,aAAO;AAAA,IACT;AACA,WAAO,IAAI,gBAAgB,CAAC;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,aAAa,UAA4C;AAC7D,UAAM,MAAM,IAAI,yBAAyB;AAAA,MACvC,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AACA,UAAM,MAAM,0BAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAClF,WAAO,IAAI;AAAA,EACb;AACF;","names":[]}
|
package/dist/ConnectorClient.cjs
CHANGED
|
@@ -21,6 +21,7 @@ __export(ConnectorClient_exports, {
|
|
|
21
21
|
ConnectorClient: () => ConnectorClient
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(ConnectorClient_exports);
|
|
24
|
+
var import_protobuf = require("@bufbuild/protobuf");
|
|
24
25
|
var import_protocol = require("@livekit/protocol");
|
|
25
26
|
var import_ServiceBase = require("./ServiceBase.cjs");
|
|
26
27
|
var import_TwirpRPC = require("./TwirpRPC.cjs");
|
|
@@ -62,7 +63,8 @@ class ConnectorClient extends import_ServiceBase.ServiceBase {
|
|
|
62
63
|
participantName,
|
|
63
64
|
participantMetadata,
|
|
64
65
|
participantAttributes: options.participantAttributes,
|
|
65
|
-
destinationCountry
|
|
66
|
+
destinationCountry,
|
|
67
|
+
ringingTimeout: options.ringingTimeout ? new import_protobuf.Duration({ seconds: BigInt(options.ringingTimeout) }) : void 0
|
|
66
68
|
}).toJson();
|
|
67
69
|
const data = await this.rpc.request(
|
|
68
70
|
svc,
|
|
@@ -98,7 +100,9 @@ class ConnectorClient extends import_ServiceBase.ServiceBase {
|
|
|
98
100
|
participantName,
|
|
99
101
|
participantMetadata,
|
|
100
102
|
participantAttributes: options.participantAttributes,
|
|
101
|
-
destinationCountry
|
|
103
|
+
destinationCountry,
|
|
104
|
+
ringingTimeout: options.ringingTimeout ? new import_protobuf.Duration({ seconds: BigInt(options.ringingTimeout) }) : void 0,
|
|
105
|
+
waitUntilAnswered: options.waitUntilAnswered
|
|
102
106
|
}).toJson();
|
|
103
107
|
const data = await this.rpc.request(
|
|
104
108
|
svc,
|
|
@@ -131,12 +135,15 @@ class ConnectorClient extends import_ServiceBase.ServiceBase {
|
|
|
131
135
|
* Disconnect an active WhatsApp call
|
|
132
136
|
*
|
|
133
137
|
* @param whatsappCallId - Call ID sent by Meta
|
|
134
|
-
* @param whatsappApiKey - The API key of the business that is disconnecting the call
|
|
138
|
+
* @param whatsappApiKey - The API key of the business that is disconnecting the call.
|
|
139
|
+
* Required when `disconnectReason` is BUSINESS_INITIATED, optional for USER_INITIATED.
|
|
140
|
+
* @param disconnectReason - Optional reason for disconnecting the call. Defaults to BUSINESS_INITIATED.
|
|
135
141
|
*/
|
|
136
|
-
async disconnectWhatsAppCall(whatsappCallId, whatsappApiKey) {
|
|
142
|
+
async disconnectWhatsAppCall(whatsappCallId, whatsappApiKey, disconnectReason) {
|
|
137
143
|
const req = new import_protocol.DisconnectWhatsAppCallRequest({
|
|
138
144
|
whatsappCallId,
|
|
139
|
-
whatsappApiKey
|
|
145
|
+
whatsappApiKey,
|
|
146
|
+
disconnectReason
|
|
140
147
|
}).toJson();
|
|
141
148
|
const data = await this.rpc.request(
|
|
142
149
|
svc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ConnectorClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n ConnectTwilioCallRequest_TwilioCallDirection,\n RoomAgentDispatch,\n SessionDescription,\n} from '@livekit/protocol';\nimport {\n AcceptWhatsAppCallRequest,\n AcceptWhatsAppCallResponse,\n ConnectTwilioCallRequest,\n ConnectTwilioCallResponse,\n ConnectWhatsAppCallRequest,\n ConnectWhatsAppCallResponse,\n DialWhatsAppCallRequest,\n DialWhatsAppCallResponse,\n DisconnectWhatsAppCallRequest,\n DisconnectWhatsAppCallResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Connector';\n\n// WhatsApp types\nexport interface DialWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is initiating the call */\n whatsappPhoneNumberId: string;\n /** Required - The number of the user that is supposed to receive the call */\n whatsappToPhoneNumber: string;\n /** Required - The API key of the business that is initiating the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\nexport interface AcceptWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is connecting the call */\n whatsappPhoneNumberId: string;\n /** Required - The API key of the business that is connecting the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Required - Call ID sent by Meta */\n whatsappCallId: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Required - The call accept webhook comes with SDP from Meta */\n sdp: SessionDescription;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n// Twilio types\nexport interface ConnectTwilioCallOptions {\n /** The direction of the call */\n twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;\n /** What LiveKit room should this call be connected to */\n roomName: string;\n /** Optional agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional name of the participant in LiveKit room */\n participantName?: string;\n /** Optional user-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional user-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n/**\n * Client to access Connector APIs for WhatsApp and Twilio integrations\n */\nexport class ConnectorClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Initiate an outbound WhatsApp call\n *\n * @param options - WhatsApp call options\n * @returns Promise containing the WhatsApp call ID and room name\n */\n async dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new DialWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappToPhoneNumber: options.whatsappToPhoneNumber,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappBizOpaqueCallbackData,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DialWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Accept an inbound WhatsApp call\n *\n * @param options - WhatsApp call accept options\n * @returns Promise containing the room name\n */\n async acceptWhatsAppCall(\n options: AcceptWhatsAppCallOptions,\n ): Promise<AcceptWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new AcceptWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappCallId: options.whatsappCallId,\n whatsappBizOpaqueCallbackData,\n sdp: options.sdp,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect an established WhatsApp call (used for business-initiated calls)\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param sdp - Session description from Meta\n */\n async connectWhatsAppCall(\n whatsappCallId: string,\n sdp: SessionDescription,\n ): Promise<ConnectWhatsAppCallResponse> {\n const req = new ConnectWhatsAppCallRequest({\n whatsappCallId,\n sdp,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Disconnect an active WhatsApp call\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param whatsappApiKey - The API key of the business that is disconnecting the call\n */\n async disconnectWhatsAppCall(\n whatsappCallId: string,\n whatsappApiKey: string,\n ): Promise<DisconnectWhatsAppCallResponse> {\n const req = new DisconnectWhatsAppCallRequest({\n whatsappCallId,\n whatsappApiKey,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DisconnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect a Twilio call to a LiveKit room\n *\n * @param options - Twilio call connection options\n * @returns Promise containing the WebSocket connect URL for Twilio media stream\n */\n async connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse> {\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new ConnectTwilioCallRequest({\n twilioCallDirection: options.twilioCallDirection,\n roomName: options.roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectTwilioCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectTwilioCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,sBAWO;AAEP,yBAA4B;AAC5B,sBAAmD;AAEnD,MAAM,MAAM;AAkFL,MAAM,wBAAwB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS/C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM;AACpB,UAAM,cAAa,mCAAS,kBACxB,EAAE,gBAAgB,QAAQ,eAAe,IACzC;AACJ,SAAK,MAAM,IAAI,yBAAS,MAAM,gCAAgB,UAAU;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,iBAAiB,SAAqE;AAC1F,UAAM,gCAAgC,QAAQ,iCAAiC;AAC/E,UAAM,WAAW,QAAQ,YAAY;AACrC,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,kBAAkB,QAAQ,mBAAmB;AACnD,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,qBAAqB,QAAQ,sBAAsB;AAEzD,UAAM,MAAM,IAAI,wCAAwB;AAAA,MACtC,uBAAuB,QAAQ;AAAA,MAC/B,uBAAuB,QAAQ;AAAA,MAC/B,gBAAgB,QAAQ;AAAA,MACxB,yBAAyB,QA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AAA,IAC5C;AACA,WAAO,0CAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC/E;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/ConnectorClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Duration } from '@bufbuild/protobuf';\nimport type {\n ConnectTwilioCallRequest_TwilioCallDirection,\n DisconnectWhatsAppCallRequest_DisconnectReason,\n RoomAgentDispatch,\n SessionDescription,\n} from '@livekit/protocol';\nimport {\n AcceptWhatsAppCallRequest,\n AcceptWhatsAppCallResponse,\n ConnectTwilioCallRequest,\n ConnectTwilioCallResponse,\n ConnectWhatsAppCallRequest,\n ConnectWhatsAppCallResponse,\n DialWhatsAppCallRequest,\n DialWhatsAppCallResponse,\n DisconnectWhatsAppCallRequest,\n DisconnectWhatsAppCallResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Connector';\n\n// WhatsApp types\nexport interface DialWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is initiating the call */\n whatsappPhoneNumberId: string;\n /** Required - The number of the user that is supposed to receive the call */\n whatsappToPhoneNumber: string;\n /** Required - The API key of the business that is initiating the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n /** Optional - Max time in seconds for the callee to answer the call */\n ringingTimeout?: number;\n}\n\nexport interface AcceptWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is connecting the call */\n whatsappPhoneNumberId: string;\n /** Required - The API key of the business that is connecting the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Required - Call ID sent by Meta */\n whatsappCallId: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Required - The call accept webhook comes with SDP from Meta */\n sdp: SessionDescription;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n /** Optional - Max time in seconds for the callee to answer the call */\n ringingTimeout?: number;\n /** Optional - Wait for the call to be answered before returning */\n waitUntilAnswered?: boolean;\n}\n\n// Twilio types\nexport interface ConnectTwilioCallOptions {\n /** The direction of the call */\n twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;\n /** What LiveKit room should this call be connected to */\n roomName: string;\n /** Optional agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional name of the participant in LiveKit room */\n participantName?: string;\n /** Optional user-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional user-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n/**\n * Client to access Connector APIs for WhatsApp and Twilio integrations\n */\nexport class ConnectorClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Initiate an outbound WhatsApp call\n *\n * @param options - WhatsApp call options\n * @returns Promise containing the WhatsApp call ID and room name\n */\n async dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new DialWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappToPhoneNumber: options.whatsappToPhoneNumber,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappBizOpaqueCallbackData,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n ringingTimeout: options.ringingTimeout\n ? new Duration({ seconds: BigInt(options.ringingTimeout) })\n : undefined,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DialWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Accept an inbound WhatsApp call\n *\n * @param options - WhatsApp call accept options\n * @returns Promise containing the room name\n */\n async acceptWhatsAppCall(\n options: AcceptWhatsAppCallOptions,\n ): Promise<AcceptWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new AcceptWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappCallId: options.whatsappCallId,\n whatsappBizOpaqueCallbackData,\n sdp: options.sdp,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n ringingTimeout: options.ringingTimeout\n ? new Duration({ seconds: BigInt(options.ringingTimeout) })\n : undefined,\n waitUntilAnswered: options.waitUntilAnswered,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect an established WhatsApp call (used for business-initiated calls)\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param sdp - Session description from Meta\n */\n async connectWhatsAppCall(\n whatsappCallId: string,\n sdp: SessionDescription,\n ): Promise<ConnectWhatsAppCallResponse> {\n const req = new ConnectWhatsAppCallRequest({\n whatsappCallId,\n sdp,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Disconnect an active WhatsApp call\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param whatsappApiKey - The API key of the business that is disconnecting the call.\n * Required when `disconnectReason` is BUSINESS_INITIATED, optional for USER_INITIATED.\n * @param disconnectReason - Optional reason for disconnecting the call. Defaults to BUSINESS_INITIATED.\n */\n async disconnectWhatsAppCall(\n whatsappCallId: string,\n whatsappApiKey: string,\n disconnectReason?: DisconnectWhatsAppCallRequest_DisconnectReason,\n ): Promise<DisconnectWhatsAppCallResponse> {\n const req = new DisconnectWhatsAppCallRequest({\n whatsappCallId,\n whatsappApiKey,\n disconnectReason,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DisconnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect a Twilio call to a LiveKit room\n *\n * @param options - Twilio call connection options\n * @returns Promise containing the WebSocket connect URL for Twilio media stream\n */\n async connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse> {\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new ConnectTwilioCallRequest({\n twilioCallDirection: options.twilioCallDirection,\n roomName: options.roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectTwilioCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectTwilioCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAyB;AAOzB,sBAWO;AAEP,yBAA4B;AAC5B,sBAAmD;AAEnD,MAAM,MAAM;AAwFL,MAAM,wBAAwB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;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uBACJ,gBACA,gBACA,kBACyC;AACzC,UAAM,MAAM,IAAI,8CAA8B;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,+CAA+B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,kBAAkB,SAAuE;AAC7F,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,kBAAkB,QAAQ,mBAAmB;AACnD,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,qBAAqB,QAAQ,sBAAsB;AAEzD,UAAM,MAAM,IAAI,yCAAyB;AAAA,MACvC,qBAAqB,QAAQ;AAAA,MAC7B,UAAU,QAAQ;AAAA,MAClB,QAAQ,QAAQ;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,QAAQ;AAAA,MAC/B;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,0CAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC/E;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RoomAgentDispatch, SessionDescription, ConnectTwilioCallRequest_TwilioCallDirection, DialWhatsAppCallResponse, AcceptWhatsAppCallResponse, ConnectWhatsAppCallResponse, DisconnectWhatsAppCallResponse, ConnectTwilioCallResponse } from '@livekit/protocol';
|
|
1
|
+
import { RoomAgentDispatch, SessionDescription, ConnectTwilioCallRequest_TwilioCallDirection, DialWhatsAppCallResponse, AcceptWhatsAppCallResponse, ConnectWhatsAppCallResponse, DisconnectWhatsAppCallRequest_DisconnectReason, DisconnectWhatsAppCallResponse, ConnectTwilioCallResponse } from '@livekit/protocol';
|
|
2
2
|
import { ClientOptions } from './ClientOptions.cjs';
|
|
3
3
|
import { ServiceBase } from './ServiceBase.cjs';
|
|
4
4
|
import './grants.cjs';
|
|
@@ -31,6 +31,8 @@ interface DialWhatsAppCallOptions {
|
|
|
31
31
|
};
|
|
32
32
|
/** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
|
|
33
33
|
destinationCountry?: string;
|
|
34
|
+
/** Optional - Max time in seconds for the callee to answer the call */
|
|
35
|
+
ringingTimeout?: number;
|
|
34
36
|
}
|
|
35
37
|
interface AcceptWhatsAppCallOptions {
|
|
36
38
|
/** Required - The identifier of the WhatsApp phone number that is connecting the call */
|
|
@@ -61,6 +63,10 @@ interface AcceptWhatsAppCallOptions {
|
|
|
61
63
|
};
|
|
62
64
|
/** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
|
|
63
65
|
destinationCountry?: string;
|
|
66
|
+
/** Optional - Max time in seconds for the callee to answer the call */
|
|
67
|
+
ringingTimeout?: number;
|
|
68
|
+
/** Optional - Wait for the call to be answered before returning */
|
|
69
|
+
waitUntilAnswered?: boolean;
|
|
64
70
|
}
|
|
65
71
|
interface ConnectTwilioCallOptions {
|
|
66
72
|
/** The direction of the call */
|
|
@@ -119,9 +125,11 @@ declare class ConnectorClient extends ServiceBase {
|
|
|
119
125
|
* Disconnect an active WhatsApp call
|
|
120
126
|
*
|
|
121
127
|
* @param whatsappCallId - Call ID sent by Meta
|
|
122
|
-
* @param whatsappApiKey - The API key of the business that is disconnecting the call
|
|
128
|
+
* @param whatsappApiKey - The API key of the business that is disconnecting the call.
|
|
129
|
+
* Required when `disconnectReason` is BUSINESS_INITIATED, optional for USER_INITIATED.
|
|
130
|
+
* @param disconnectReason - Optional reason for disconnecting the call. Defaults to BUSINESS_INITIATED.
|
|
123
131
|
*/
|
|
124
|
-
disconnectWhatsAppCall(whatsappCallId: string, whatsappApiKey: string): Promise<DisconnectWhatsAppCallResponse>;
|
|
132
|
+
disconnectWhatsAppCall(whatsappCallId: string, whatsappApiKey: string, disconnectReason?: DisconnectWhatsAppCallRequest_DisconnectReason): Promise<DisconnectWhatsAppCallResponse>;
|
|
125
133
|
/**
|
|
126
134
|
* Connect a Twilio call to a LiveKit room
|
|
127
135
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RoomAgentDispatch, SessionDescription, ConnectTwilioCallRequest_TwilioCallDirection, DialWhatsAppCallResponse, AcceptWhatsAppCallResponse, ConnectWhatsAppCallResponse, DisconnectWhatsAppCallResponse, ConnectTwilioCallResponse } from '@livekit/protocol';
|
|
1
|
+
import { RoomAgentDispatch, SessionDescription, ConnectTwilioCallRequest_TwilioCallDirection, DialWhatsAppCallResponse, AcceptWhatsAppCallResponse, ConnectWhatsAppCallResponse, DisconnectWhatsAppCallRequest_DisconnectReason, DisconnectWhatsAppCallResponse, ConnectTwilioCallResponse } from '@livekit/protocol';
|
|
2
2
|
import { ClientOptions } from './ClientOptions.js';
|
|
3
3
|
import { ServiceBase } from './ServiceBase.js';
|
|
4
4
|
import './grants.js';
|
|
@@ -31,6 +31,8 @@ interface DialWhatsAppCallOptions {
|
|
|
31
31
|
};
|
|
32
32
|
/** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
|
|
33
33
|
destinationCountry?: string;
|
|
34
|
+
/** Optional - Max time in seconds for the callee to answer the call */
|
|
35
|
+
ringingTimeout?: number;
|
|
34
36
|
}
|
|
35
37
|
interface AcceptWhatsAppCallOptions {
|
|
36
38
|
/** Required - The identifier of the WhatsApp phone number that is connecting the call */
|
|
@@ -61,6 +63,10 @@ interface AcceptWhatsAppCallOptions {
|
|
|
61
63
|
};
|
|
62
64
|
/** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
|
|
63
65
|
destinationCountry?: string;
|
|
66
|
+
/** Optional - Max time in seconds for the callee to answer the call */
|
|
67
|
+
ringingTimeout?: number;
|
|
68
|
+
/** Optional - Wait for the call to be answered before returning */
|
|
69
|
+
waitUntilAnswered?: boolean;
|
|
64
70
|
}
|
|
65
71
|
interface ConnectTwilioCallOptions {
|
|
66
72
|
/** The direction of the call */
|
|
@@ -119,9 +125,11 @@ declare class ConnectorClient extends ServiceBase {
|
|
|
119
125
|
* Disconnect an active WhatsApp call
|
|
120
126
|
*
|
|
121
127
|
* @param whatsappCallId - Call ID sent by Meta
|
|
122
|
-
* @param whatsappApiKey - The API key of the business that is disconnecting the call
|
|
128
|
+
* @param whatsappApiKey - The API key of the business that is disconnecting the call.
|
|
129
|
+
* Required when `disconnectReason` is BUSINESS_INITIATED, optional for USER_INITIATED.
|
|
130
|
+
* @param disconnectReason - Optional reason for disconnecting the call. Defaults to BUSINESS_INITIATED.
|
|
123
131
|
*/
|
|
124
|
-
disconnectWhatsAppCall(whatsappCallId: string, whatsappApiKey: string): Promise<DisconnectWhatsAppCallResponse>;
|
|
132
|
+
disconnectWhatsAppCall(whatsappCallId: string, whatsappApiKey: string, disconnectReason?: DisconnectWhatsAppCallRequest_DisconnectReason): Promise<DisconnectWhatsAppCallResponse>;
|
|
125
133
|
/**
|
|
126
134
|
* Connect a Twilio call to a LiveKit room
|
|
127
135
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectorClient.d.ts","sourceRoot":"","sources":["../src/ConnectorClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConnectorClient.d.ts","sourceRoot":"","sources":["../src/ConnectorClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,4CAA4C,EAC5C,8CAA8C,EAC9C,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,0BAA0B,EAE1B,yBAAyB,EAEzB,2BAA2B,EAE3B,wBAAwB,EAExB,8BA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AAE,aAAa;IAQnF;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmC3F;;;;;OAKG;IACG,kBAAkB,CACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,0BAA0B,CAAC;IAqCtC;;;;;OAKG;IACG,mBAAmB,CACvB,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,2BAA2B,CAAC;IAevC;;;;;;;OAOG;IACG,sBAAsB,CAC1B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,gBAAgB,CAAC,EAAE,8CAA8C,GAChE,OAAO,CAAC,8BAA8B,CAAC;IAgB1C;;;;;OAKG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAyB/F"}
|
package/dist/ConnectorClient.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Duration } from "@bufbuild/protobuf";
|
|
1
2
|
import {
|
|
2
3
|
AcceptWhatsAppCallRequest,
|
|
3
4
|
AcceptWhatsAppCallResponse,
|
|
@@ -50,7 +51,8 @@ class ConnectorClient extends ServiceBase {
|
|
|
50
51
|
participantName,
|
|
51
52
|
participantMetadata,
|
|
52
53
|
participantAttributes: options.participantAttributes,
|
|
53
|
-
destinationCountry
|
|
54
|
+
destinationCountry,
|
|
55
|
+
ringingTimeout: options.ringingTimeout ? new Duration({ seconds: BigInt(options.ringingTimeout) }) : void 0
|
|
54
56
|
}).toJson();
|
|
55
57
|
const data = await this.rpc.request(
|
|
56
58
|
svc,
|
|
@@ -86,7 +88,9 @@ class ConnectorClient extends ServiceBase {
|
|
|
86
88
|
participantName,
|
|
87
89
|
participantMetadata,
|
|
88
90
|
participantAttributes: options.participantAttributes,
|
|
89
|
-
destinationCountry
|
|
91
|
+
destinationCountry,
|
|
92
|
+
ringingTimeout: options.ringingTimeout ? new Duration({ seconds: BigInt(options.ringingTimeout) }) : void 0,
|
|
93
|
+
waitUntilAnswered: options.waitUntilAnswered
|
|
90
94
|
}).toJson();
|
|
91
95
|
const data = await this.rpc.request(
|
|
92
96
|
svc,
|
|
@@ -119,12 +123,15 @@ class ConnectorClient extends ServiceBase {
|
|
|
119
123
|
* Disconnect an active WhatsApp call
|
|
120
124
|
*
|
|
121
125
|
* @param whatsappCallId - Call ID sent by Meta
|
|
122
|
-
* @param whatsappApiKey - The API key of the business that is disconnecting the call
|
|
126
|
+
* @param whatsappApiKey - The API key of the business that is disconnecting the call.
|
|
127
|
+
* Required when `disconnectReason` is BUSINESS_INITIATED, optional for USER_INITIATED.
|
|
128
|
+
* @param disconnectReason - Optional reason for disconnecting the call. Defaults to BUSINESS_INITIATED.
|
|
123
129
|
*/
|
|
124
|
-
async disconnectWhatsAppCall(whatsappCallId, whatsappApiKey) {
|
|
130
|
+
async disconnectWhatsAppCall(whatsappCallId, whatsappApiKey, disconnectReason) {
|
|
125
131
|
const req = new DisconnectWhatsAppCallRequest({
|
|
126
132
|
whatsappCallId,
|
|
127
|
-
whatsappApiKey
|
|
133
|
+
whatsappApiKey,
|
|
134
|
+
disconnectReason
|
|
128
135
|
}).toJson();
|
|
129
136
|
const data = await this.rpc.request(
|
|
130
137
|
svc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ConnectorClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n ConnectTwilioCallRequest_TwilioCallDirection,\n RoomAgentDispatch,\n SessionDescription,\n} from '@livekit/protocol';\nimport {\n AcceptWhatsAppCallRequest,\n AcceptWhatsAppCallResponse,\n ConnectTwilioCallRequest,\n ConnectTwilioCallResponse,\n ConnectWhatsAppCallRequest,\n ConnectWhatsAppCallResponse,\n DialWhatsAppCallRequest,\n DialWhatsAppCallResponse,\n DisconnectWhatsAppCallRequest,\n DisconnectWhatsAppCallResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Connector';\n\n// WhatsApp types\nexport interface DialWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is initiating the call */\n whatsappPhoneNumberId: string;\n /** Required - The number of the user that is supposed to receive the call */\n whatsappToPhoneNumber: string;\n /** Required - The API key of the business that is initiating the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\nexport interface AcceptWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is connecting the call */\n whatsappPhoneNumberId: string;\n /** Required - The API key of the business that is connecting the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Required - Call ID sent by Meta */\n whatsappCallId: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Required - The call accept webhook comes with SDP from Meta */\n sdp: SessionDescription;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n// Twilio types\nexport interface ConnectTwilioCallOptions {\n /** The direction of the call */\n twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;\n /** What LiveKit room should this call be connected to */\n roomName: string;\n /** Optional agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional name of the participant in LiveKit room */\n participantName?: string;\n /** Optional user-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional user-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n/**\n * Client to access Connector APIs for WhatsApp and Twilio integrations\n */\nexport class ConnectorClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Initiate an outbound WhatsApp call\n *\n * @param options - WhatsApp call options\n * @returns Promise containing the WhatsApp call ID and room name\n */\n async dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new DialWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappToPhoneNumber: options.whatsappToPhoneNumber,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappBizOpaqueCallbackData,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DialWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Accept an inbound WhatsApp call\n *\n * @param options - WhatsApp call accept options\n * @returns Promise containing the room name\n */\n async acceptWhatsAppCall(\n options: AcceptWhatsAppCallOptions,\n ): Promise<AcceptWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new AcceptWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappCallId: options.whatsappCallId,\n whatsappBizOpaqueCallbackData,\n sdp: options.sdp,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect an established WhatsApp call (used for business-initiated calls)\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param sdp - Session description from Meta\n */\n async connectWhatsAppCall(\n whatsappCallId: string,\n sdp: SessionDescription,\n ): Promise<ConnectWhatsAppCallResponse> {\n const req = new ConnectWhatsAppCallRequest({\n whatsappCallId,\n sdp,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Disconnect an active WhatsApp call\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param whatsappApiKey - The API key of the business that is disconnecting the call\n */\n async disconnectWhatsAppCall(\n whatsappCallId: string,\n whatsappApiKey: string,\n ): Promise<DisconnectWhatsAppCallResponse> {\n const req = new DisconnectWhatsAppCallRequest({\n whatsappCallId,\n whatsappApiKey,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DisconnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect a Twilio call to a LiveKit room\n *\n * @param options - Twilio call connection options\n * @returns Promise containing the WebSocket connect URL for Twilio media stream\n */\n async connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse> {\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new ConnectTwilioCallRequest({\n twilioCallDirection: options.twilioCallDirection,\n roomName: options.roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectTwilioCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectTwilioCallResponse.fromJson(data, { ignoreUn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;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,uBACJ,gBACA,gBACyC;AACzC,UAAM,MAAM,IAAI,8BAA8B;AAAA,MAC5C;AAAA,MACA;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,+BAA+B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,kBAAkB,SAAuE;AAC7F,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,kBAAkB,QAAQ,mBAAmB;AACnD,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,qBAAqB,QAAQ,sBAAsB;AAEzD,UAAM,MAAM,IAAI,yBAAyB;AAAA,MACvC,qBAAqB,QAAQ;AAAA,MAC7B,UAAU,QAAQ;AAAA,MAClB,QAAQ,QAAQ;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,QAAQ;AAAA,MAC/B;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,0BAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC/E;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/ConnectorClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Duration } from '@bufbuild/protobuf';\nimport type {\n ConnectTwilioCallRequest_TwilioCallDirection,\n DisconnectWhatsAppCallRequest_DisconnectReason,\n RoomAgentDispatch,\n SessionDescription,\n} from '@livekit/protocol';\nimport {\n AcceptWhatsAppCallRequest,\n AcceptWhatsAppCallResponse,\n ConnectTwilioCallRequest,\n ConnectTwilioCallResponse,\n ConnectWhatsAppCallRequest,\n ConnectWhatsAppCallResponse,\n DialWhatsAppCallRequest,\n DialWhatsAppCallResponse,\n DisconnectWhatsAppCallRequest,\n DisconnectWhatsAppCallResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Connector';\n\n// WhatsApp types\nexport interface DialWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is initiating the call */\n whatsappPhoneNumberId: string;\n /** Required - The number of the user that is supposed to receive the call */\n whatsappToPhoneNumber: string;\n /** Required - The API key of the business that is initiating the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n /** Optional - Max time in seconds for the callee to answer the call */\n ringingTimeout?: number;\n}\n\nexport interface AcceptWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is connecting the call */\n whatsappPhoneNumberId: string;\n /** Required - The API key of the business that is connecting the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Required - Call ID sent by Meta */\n whatsappCallId: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Required - The call accept webhook comes with SDP from Meta */\n sdp: SessionDescription;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n /** Optional - Max time in seconds for the callee to answer the call */\n ringingTimeout?: number;\n /** Optional - Wait for the call to be answered before returning */\n waitUntilAnswered?: boolean;\n}\n\n// Twilio types\nexport interface ConnectTwilioCallOptions {\n /** The direction of the call */\n twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;\n /** What LiveKit room should this call be connected to */\n roomName: string;\n /** Optional agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional name of the participant in LiveKit room */\n participantName?: string;\n /** Optional user-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional user-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n/**\n * Client to access Connector APIs for WhatsApp and Twilio integrations\n */\nexport class ConnectorClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Initiate an outbound WhatsApp call\n *\n * @param options - WhatsApp call options\n * @returns Promise containing the WhatsApp call ID and room name\n */\n async dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new DialWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappToPhoneNumber: options.whatsappToPhoneNumber,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappBizOpaqueCallbackData,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n ringingTimeout: options.ringingTimeout\n ? new Duration({ seconds: BigInt(options.ringingTimeout) })\n : undefined,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DialWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Accept an inbound WhatsApp call\n *\n * @param options - WhatsApp call accept options\n * @returns Promise containing the room name\n */\n async acceptWhatsAppCall(\n options: AcceptWhatsAppCallOptions,\n ): Promise<AcceptWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new AcceptWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappCallId: options.whatsappCallId,\n whatsappBizOpaqueCallbackData,\n sdp: options.sdp,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n ringingTimeout: options.ringingTimeout\n ? new Duration({ seconds: BigInt(options.ringingTimeout) })\n : undefined,\n waitUntilAnswered: options.waitUntilAnswered,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect an established WhatsApp call (used for business-initiated calls)\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param sdp - Session description from Meta\n */\n async connectWhatsAppCall(\n whatsappCallId: string,\n sdp: SessionDescription,\n ): Promise<ConnectWhatsAppCallResponse> {\n const req = new ConnectWhatsAppCallRequest({\n whatsappCallId,\n sdp,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Disconnect an active WhatsApp call\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param whatsappApiKey - The API key of the business that is disconnecting the call.\n * Required when `disconnectReason` is BUSINESS_INITIATED, optional for USER_INITIATED.\n * @param disconnectReason - Optional reason for disconnecting the call. Defaults to BUSINESS_INITIATED.\n */\n async disconnectWhatsAppCall(\n whatsappCallId: string,\n whatsappApiKey: string,\n disconnectReason?: DisconnectWhatsAppCallRequest_DisconnectReason,\n ): Promise<DisconnectWhatsAppCallResponse> {\n const req = new DisconnectWhatsAppCallRequest({\n whatsappCallId,\n whatsappApiKey,\n disconnectReason,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DisconnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect a Twilio call to a LiveKit room\n *\n * @param options - Twilio call connection options\n * @returns Promise containing the WebSocket connect URL for Twilio media stream\n */\n async connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse> {\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new ConnectTwilioCallRequest({\n twilioCallDirection: options.twilioCallDirection,\n roomName: options.roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectTwilioCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectTwilioCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":"AAGA,SAAS,gBAAgB;AAOzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB;AAC5B,SAAmB,UAAU,sBAAsB;AAEnD,MAAM,MAAM;AAwFL,MAAM,wBAAwB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS/C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,QAAQ,MAAM;AACpB,UAAM,cAAa,mCAAS,kBACxB,EAAE,gBAAgB,QAAQ,eAAe,IACzC;AACJ,SAAK,MAAM,IAAI,SAAS,MAAM,gBAAgB,UAAU;AAAA,EAC1D;AAAA;AAAA;AAAA;AAAA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KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,+BAA+B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,kBAAkB,SAAuE;AAC7F,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,kBAAkB,QAAQ,mBAAmB;AACnD,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,qBAAqB,QAAQ,sBAAsB;AAEzD,UAAM,MAAM,IAAI,yBAAyB;AAAA,MACvC,qBAAqB,QAAQ;AAAA,MAC7B,UAAU,QAAQ;AAAA,MAClB,QAAQ,QAAQ;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,QAAQ;AAAA,MAC/B;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,0BAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC/E;AACF;","names":[]}
|
package/dist/SipClient.cjs
CHANGED
|
@@ -109,7 +109,8 @@ class SipClient extends import_ServiceBase.ServiceBase {
|
|
|
109
109
|
headersToAttributes: opts.headersToAttributes,
|
|
110
110
|
includeHeaders: opts.includeHeaders,
|
|
111
111
|
krispEnabled: opts.krispEnabled,
|
|
112
|
-
mediaEncryption: opts.mediaEncryption
|
|
112
|
+
mediaEncryption: opts.mediaEncryption,
|
|
113
|
+
ringingTimeout: opts.ringingTimeout ? new import_protobuf.Duration({ seconds: BigInt(opts.ringingTimeout) }) : void 0
|
|
113
114
|
})
|
|
114
115
|
}).toJson();
|
|
115
116
|
const data = await this.rpc.request(
|