livekit-server-sdk 2.15.5 → 2.17.0

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.
Files changed (101) hide show
  1. package/dist/AgentDispatchClient.cjs +5 -3
  2. package/dist/AgentDispatchClient.cjs.map +1 -1
  3. package/dist/AgentDispatchClient.js +5 -3
  4. package/dist/AgentDispatchClient.js.map +1 -1
  5. package/dist/ClientOptions.cjs.map +1 -1
  6. package/dist/ClientOptions.d.cts +12 -0
  7. package/dist/ClientOptions.d.ts +12 -0
  8. package/dist/ClientOptions.d.ts.map +1 -1
  9. package/dist/ConnectorClient.cjs +9 -5
  10. package/dist/ConnectorClient.cjs.map +1 -1
  11. package/dist/ConnectorClient.d.cts +6 -3
  12. package/dist/ConnectorClient.d.ts +6 -3
  13. package/dist/ConnectorClient.d.ts.map +1 -1
  14. package/dist/ConnectorClient.js +9 -5
  15. package/dist/ConnectorClient.js.map +1 -1
  16. package/dist/EgressClient.cjs +5 -3
  17. package/dist/EgressClient.cjs.map +1 -1
  18. package/dist/EgressClient.js +5 -3
  19. package/dist/EgressClient.js.map +1 -1
  20. package/dist/IngressClient.cjs +5 -3
  21. package/dist/IngressClient.cjs.map +1 -1
  22. package/dist/IngressClient.js +5 -3
  23. package/dist/IngressClient.js.map +1 -1
  24. package/dist/LiveKitAPI.cjs +80 -0
  25. package/dist/LiveKitAPI.cjs.map +1 -0
  26. package/dist/LiveKitAPI.d.cts +77 -0
  27. package/dist/LiveKitAPI.d.ts +77 -0
  28. package/dist/LiveKitAPI.d.ts.map +1 -0
  29. package/dist/LiveKitAPI.js +56 -0
  30. package/dist/LiveKitAPI.js.map +1 -0
  31. package/dist/RoomServiceClient.cjs +5 -3
  32. package/dist/RoomServiceClient.cjs.map +1 -1
  33. package/dist/RoomServiceClient.js +5 -3
  34. package/dist/RoomServiceClient.js.map +1 -1
  35. package/dist/ServiceBase.cjs +9 -9
  36. package/dist/ServiceBase.cjs.map +1 -1
  37. package/dist/ServiceBase.d.cts +20 -1
  38. package/dist/ServiceBase.d.ts +20 -1
  39. package/dist/ServiceBase.d.ts.map +1 -1
  40. package/dist/ServiceBase.js +9 -9
  41. package/dist/ServiceBase.js.map +1 -1
  42. package/dist/SipClient.cjs +56 -21
  43. package/dist/SipClient.cjs.map +1 -1
  44. package/dist/SipClient.d.cts +22 -4
  45. package/dist/SipClient.d.ts +22 -4
  46. package/dist/SipClient.d.ts.map +1 -1
  47. package/dist/SipClient.js +58 -22
  48. package/dist/SipClient.js.map +1 -1
  49. package/dist/TwirpRPC.cjs +135 -48
  50. package/dist/TwirpRPC.cjs.map +1 -1
  51. package/dist/TwirpRPC.d.cts +38 -2
  52. package/dist/TwirpRPC.d.ts +38 -2
  53. package/dist/TwirpRPC.d.ts.map +1 -1
  54. package/dist/TwirpRPC.js +140 -38
  55. package/dist/TwirpRPC.js.map +1 -1
  56. package/dist/dialTimeout.cjs +39 -0
  57. package/dist/dialTimeout.cjs.map +1 -0
  58. package/dist/dialTimeout.d.cts +21 -0
  59. package/dist/dialTimeout.d.ts +21 -0
  60. package/dist/dialTimeout.d.ts.map +1 -0
  61. package/dist/dialTimeout.js +13 -0
  62. package/dist/dialTimeout.js.map +1 -0
  63. package/dist/failover.cjs +139 -0
  64. package/dist/failover.cjs.map +1 -0
  65. package/dist/failover.d.cts +30 -0
  66. package/dist/failover.d.ts +30 -0
  67. package/dist/failover.d.ts.map +1 -0
  68. package/dist/failover.js +107 -0
  69. package/dist/failover.js.map +1 -0
  70. package/dist/index.cjs +8 -0
  71. package/dist/index.cjs.map +1 -1
  72. package/dist/index.d.cts +5 -4
  73. package/dist/index.d.ts +5 -4
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +6 -1
  76. package/dist/index.js.map +1 -1
  77. package/dist/version.cjs +29 -0
  78. package/dist/version.cjs.map +1 -0
  79. package/dist/version.d.cts +3 -0
  80. package/dist/version.d.ts +3 -0
  81. package/dist/version.d.ts.map +1 -0
  82. package/dist/version.js +5 -0
  83. package/dist/version.js.map +1 -0
  84. package/package.json +3 -3
  85. package/src/AgentDispatchClient.ts +5 -5
  86. package/src/ClientOptions.ts +12 -0
  87. package/src/ConnectorClient.ts +20 -11
  88. package/src/EgressClient.ts +5 -5
  89. package/src/IngressClient.ts +5 -5
  90. package/src/LiveKitAPI.ts +126 -0
  91. package/src/RoomServiceClient.ts +5 -5
  92. package/src/ServiceBase.ts +35 -4
  93. package/src/SipClient.ts +89 -24
  94. package/src/TwirpRPC.test.ts +42 -0
  95. package/src/TwirpRPC.ts +187 -39
  96. package/src/dialTimeout.test.ts +41 -0
  97. package/src/dialTimeout.ts +37 -0
  98. package/src/failover.test.ts +188 -0
  99. package/src/failover.ts +170 -0
  100. package/src/index.ts +4 -1
  101. package/src/version.ts +1 -0
@@ -33,9 +33,11 @@ class AgentDispatchClient extends import_ServiceBase.ServiceBase {
33
33
  * @param options - client options
34
34
  */
35
35
  constructor(host, apiKey, secret, options) {
36
- super(apiKey, secret);
37
- const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
38
- this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, rpcOptions);
36
+ super({ apiKey, secret, token: options == null ? void 0 : options.token });
37
+ this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, {
38
+ requestTimeout: options == null ? void 0 : options.requestTimeout,
39
+ failover: options == null ? void 0 : options.failover
40
+ });
39
41
  }
40
42
  /**
41
43
  * Create an explicit dispatch for an agent to join a room. To use explicit
@@ -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 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 */\n metadata?: string;\n /** controls whether the job should be restarted when it fails (cloud only) */\n restartPolicy?: JobRestartPolicy;\n /** optional deployment to dispatch to. Leave empty to target the production deployment. */\n deployment?: 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 restartPolicy: options?.restartPolicy,\n deployment: options?.deployment,\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;AAanD,MAAM,MAAM;AAKL,MAAM,4BAA4B,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnD,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;A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AAA,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
+ {"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 */\n metadata?: string;\n /** controls whether the job should be restarted when it fails (cloud only) */\n restartPolicy?: JobRestartPolicy;\n /** optional deployment to dispatch to. Leave empty to target the production deployment. */\n deployment?: 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, token: options?.token });\n this.rpc = new TwirpRpc(host, livekitPackage, {\n requestTimeout: options?.requestTimeout,\n failover: options?.failover,\n });\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 deployment: options?.deployment,\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;AAanD,MAAM,MAAM;AAKL,MAAM,4BAA4B,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnD,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,EAAE,QAAQ,QAAQ,OAAO,mCAAS,MAAM,CAAC;AAC/C,SAAK,MAAM,IAAI,yBAAS,MAAM,gCAAgB;AAAA,MAC5C,gBAAgB,mCAAS;AAAA,MACzB,UAAU,mCAAS;AAAA,IACrB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,eACJ,UACA,WACA,SACwB;AACxB,UAAM,MAAM,IAAI,2CAA2B;AAAA,MACzC,MAAM;AAAA,MACN;AAAA,MACA,UAAU,mCAAS;AAAA,MACnB,eAAe,mCAAS;AAAA,MACxB,YAAY,mCAAS;AAAA,IACvB,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,WAAO,8BAAc,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,eAAe,YAAoB,UAAiC;AACxE,UAAM,MAAM,IAAI,2CAA2B;AAAA,MACzC;AAAA,MACA,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YAAY,YAAoB,UAAsD;AAC1F,UAAM,MAAM,IAAI,yCAAyB;AAAA,MACvC;AAAA,MACA,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,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":[]}
@@ -16,9 +16,11 @@ class AgentDispatchClient extends ServiceBase {
16
16
  * @param options - client options
17
17
  */
18
18
  constructor(host, apiKey, secret, options) {
19
- super(apiKey, secret);
20
- const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
21
- this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);
19
+ super({ apiKey, secret, token: options == null ? void 0 : options.token });
20
+ this.rpc = new TwirpRpc(host, livekitPackage, {
21
+ requestTimeout: options == null ? void 0 : options.requestTimeout,
22
+ failover: options == null ? void 0 : options.failover
23
+ });
22
24
  }
23
25
  /**
24
26
  * Create an explicit dispatch for an agent to join a room. To use explicit
@@ -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 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 */\n metadata?: string;\n /** controls whether the job should be restarted when it fails (cloud only) */\n restartPolicy?: JobRestartPolicy;\n /** optional deployment to dispatch to. Leave empty to target the production deployment. */\n deployment?: 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 restartPolicy: options?.restartPolicy,\n deployment: options?.deployment,\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,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB;AAC5B,SAAmB,UAAU,sBAAsB;AAanD,MAAM,MAAM;AAKL,MAAM,4BAA4B,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnD,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;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,eACJ,UACA,WACA,SACwB;AACxB,UAAM,MAAM,IAAI,2BAA2B;AAAA,MACzC,MAAM;AAAA,MACN;AAAA,MACA,UAAU,mCAAS;AAAA,MACnB,eAAe,mCAAS;AAAA,MACxB,YAAY,mCAAS;AAAA,IACvB,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,WAAO,cAAc,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,eAAe,YAAoB,UAAiC;AACxE,UAAM,MAAM,IAAI,2BAA2B;AAAA,MACzC;AAAA,MACA,MAAM;AAAA,IACR,CAAC,EAAE,OAAO;AACV,UAAM,KAAK,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,WAAW,MAAM,MAAM,SAAS,CAAC;AAAA,IAC3D;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,YAAY,YAAoB,UAAsD;AAC1F,UAAM,MAAM,IAAI,yBAAyB;AAAA,MACvC;AAAA,MACA,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,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":[]}
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 */\n metadata?: string;\n /** controls whether the job should be restarted when it fails (cloud only) */\n restartPolicy?: JobRestartPolicy;\n /** optional deployment to dispatch to. Leave empty to target the production deployment. */\n deployment?: 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, token: options?.token });\n this.rpc = new TwirpRpc(host, livekitPackage, {\n requestTimeout: options?.requestTimeout,\n failover: options?.failover,\n });\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 deployment: options?.deployment,\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,EACA;AAAA,OACK;AAEP,SAAS,mBAAmB;AAC5B,SAAmB,UAAU,sBAAsB;AAanD,MAAM,MAAM;AAKL,MAAM,4BAA4B,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASnD,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,EAAE,QAAQ,QAAQ,OAAO,mCAAS,MAAM,CAAC;AAC/C,SAAK,MAAM,IAAI,SAAS,MAAM,gBAAgB;AAAA,MAC5C,gBAAgB,mCAAS;AAAA,MACzB,UAAU,mCAAS;AAAA,IACrB,CAAC;AAAA,EACH;AA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B,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":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ClientOptions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Options common to all clients\n */\nexport type ClientOptions = {\n /**\n * Optional timeout, in seconds, for all server requests\n */\n requestTimeout?: number;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/ClientOptions.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Options common to all clients\n */\nexport type ClientOptions = {\n /**\n * Optional timeout, in seconds, for all server requests\n */\n requestTimeout?: number;\n /**\n * Whether to fail over to alternative regions on retryable errors (LiveKit\n * Cloud hosts only). Defaults to true; set to false to disable.\n */\n failover?: boolean;\n /**\n * A pre-signed access token, sent verbatim as the Authorization header on\n * every request instead of signing one per call from an API key and secret.\n * The token must already carry the grants for the calls it's used with; since\n * it needs no secret, the client can run client-side.\n */\n token?: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -6,6 +6,18 @@ type ClientOptions = {
6
6
  * Optional timeout, in seconds, for all server requests
7
7
  */
8
8
  requestTimeout?: number;
9
+ /**
10
+ * Whether to fail over to alternative regions on retryable errors (LiveKit
11
+ * Cloud hosts only). Defaults to true; set to false to disable.
12
+ */
13
+ failover?: boolean;
14
+ /**
15
+ * A pre-signed access token, sent verbatim as the Authorization header on
16
+ * every request instead of signing one per call from an API key and secret.
17
+ * The token must already carry the grants for the calls it's used with; since
18
+ * it needs no secret, the client can run client-side.
19
+ */
20
+ token?: string;
9
21
  };
10
22
 
11
23
  export type { ClientOptions };
@@ -6,6 +6,18 @@ type ClientOptions = {
6
6
  * Optional timeout, in seconds, for all server requests
7
7
  */
8
8
  requestTimeout?: number;
9
+ /**
10
+ * Whether to fail over to alternative regions on retryable errors (LiveKit
11
+ * Cloud hosts only). Defaults to true; set to false to disable.
12
+ */
13
+ failover?: boolean;
14
+ /**
15
+ * A pre-signed access token, sent verbatim as the Authorization header on
16
+ * every request instead of signing one per call from an API key and secret.
17
+ * The token must already carry the grants for the calls it's used with; since
18
+ * it needs no secret, the client can run client-side.
19
+ */
20
+ token?: string;
9
21
  };
10
22
 
11
23
  export type { ClientOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"ClientOptions.d.ts","sourceRoot":"","sources":["../src/ClientOptions.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC"}
1
+ {"version":3,"file":"ClientOptions.d.ts","sourceRoot":"","sources":["../src/ClientOptions.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -25,6 +25,7 @@ var import_protobuf = require("@bufbuild/protobuf");
25
25
  var import_protocol = require("@livekit/protocol");
26
26
  var import_ServiceBase = require("./ServiceBase.cjs");
27
27
  var import_TwirpRPC = require("./TwirpRPC.cjs");
28
+ var import_dialTimeout = require("./dialTimeout.cjs");
28
29
  const svc = "Connector";
29
30
  class ConnectorClient extends import_ServiceBase.ServiceBase {
30
31
  /**
@@ -34,9 +35,11 @@ class ConnectorClient extends import_ServiceBase.ServiceBase {
34
35
  * @param options - client options
35
36
  */
36
37
  constructor(host, apiKey, secret, options) {
37
- super(apiKey, secret);
38
- const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
39
- this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, rpcOptions);
38
+ super({ apiKey, secret, token: options == null ? void 0 : options.token });
39
+ this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, {
40
+ requestTimeout: options == null ? void 0 : options.requestTimeout,
41
+ failover: options == null ? void 0 : options.failover
42
+ });
40
43
  }
41
44
  /**
42
45
  * Initiate an outbound WhatsApp call
@@ -101,14 +104,15 @@ class ConnectorClient extends import_ServiceBase.ServiceBase {
101
104
  participantMetadata,
102
105
  participantAttributes: options.participantAttributes,
103
106
  destinationCountry,
104
- ringingTimeout: options.ringingTimeout ? new import_protobuf.Duration({ seconds: BigInt(options.ringingTimeout) }) : void 0,
105
107
  waitUntilAnswered: options.waitUntilAnswered
106
108
  }).toJson();
109
+ const timeout = options.waitUntilAnswered ? options.timeout ?? import_dialTimeout.DEFAULT_RINGING_TIMEOUT_SECONDS : options.timeout;
107
110
  const data = await this.rpc.request(
108
111
  svc,
109
112
  "AcceptWhatsAppCall",
110
113
  req,
111
- await this.authHeader({ roomCreate: true })
114
+ await this.authHeader({ roomCreate: true }),
115
+ timeout
112
116
  );
113
117
  return import_protocol.AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
114
118
  }
@@ -1 +1 @@
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;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,g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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
+ {"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';\nimport { DEFAULT_RINGING_TIMEOUT_SECONDS } from './dialTimeout.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 - Wait until the inbound party joins before returning. */\n waitUntilAnswered?: boolean;\n /**\n * Optional - Request timeout in seconds. When `waitUntilAnswered` is set it\n * defaults to the standard ring window; otherwise the client default applies.\n */\n timeout?: number;\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, token: options?.token });\n this.rpc = new TwirpRpc(host, livekitPackage, {\n requestTimeout: options?.requestTimeout,\n failover: options?.failover,\n });\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 waitUntilAnswered: options.waitUntilAnswered,\n }).toJson();\n\n // When waiting for the inbound party to join, the request can block, so\n // default the timeout to the standard ring window; otherwise the client\n // default applies.\n const timeout = options.waitUntilAnswered\n ? (options.timeout ?? DEFAULT_RINGING_TIMEOUT_SECONDS)\n : options.timeout;\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n timeout,\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;AACnD,yBAAgD;AAEhD,MAAM,MAAM;AA2FL,MAAM,wBAAwB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS/C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,EAAE,QAAQ,QAAQ,OAAO,mCAAS,MAAM,CAAC;AAC/C,SAAK,MAAM,IAAI,yBAAS,MAAM,gCAAgB;AAAA,MAC5C,gBAAgB,mCAAS;AAAA,MACzB,UAAU,mCAAS;AAAA,IACrB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,iBAAiB,SAAqE;AAC1F,UAAM,gCAAgC,QAAQ,iCAAiC;AAC/E,U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AA;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":[]}
@@ -63,10 +63,13 @@ interface AcceptWhatsAppCallOptions {
63
63
  };
64
64
  /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
65
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 */
66
+ /** Optional - Wait until the inbound party joins before returning. */
69
67
  waitUntilAnswered?: boolean;
68
+ /**
69
+ * Optional - Request timeout in seconds. When `waitUntilAnswered` is set it
70
+ * defaults to the standard ring window; otherwise the client default applies.
71
+ */
72
+ timeout?: number;
70
73
  }
71
74
  interface ConnectTwilioCallOptions {
72
75
  /** The direction of the call */
@@ -63,10 +63,13 @@ interface AcceptWhatsAppCallOptions {
63
63
  };
64
64
  /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
65
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 */
66
+ /** Optional - Wait until the inbound party joins before returning. */
69
67
  waitUntilAnswered?: boolean;
68
+ /**
69
+ * Optional - Request timeout in seconds. When `waitUntilAnswered` is set it
70
+ * defaults to the standard ring window; otherwise the client default applies.
71
+ */
72
+ timeout?: number;
70
73
  }
71
74
  interface ConnectTwilioCallOptions {
72
75
  /** The direction of the call */
@@ -1 +1 @@
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,8BAA8B,EAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C,MAAM,WAAW,uBAAuB;IACtC,yFAAyF;IACzF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,uBAAuB,EAAE,MAAM,CAAC;IAChC,sGAAsG;IACtG,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,yDAAyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iGAAiG;IACjG,qBAAqB,CAAC,EAAE;QAAE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AI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,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;IA0CtC;;;;;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"}
@@ -13,6 +13,7 @@ import {
13
13
  } from "@livekit/protocol";
14
14
  import { ServiceBase } from "./ServiceBase.js";
15
15
  import { TwirpRpc, livekitPackage } from "./TwirpRPC.js";
16
+ import { DEFAULT_RINGING_TIMEOUT_SECONDS } from "./dialTimeout.js";
16
17
  const svc = "Connector";
17
18
  class ConnectorClient extends ServiceBase {
18
19
  /**
@@ -22,9 +23,11 @@ class ConnectorClient extends ServiceBase {
22
23
  * @param options - client options
23
24
  */
24
25
  constructor(host, apiKey, secret, options) {
25
- super(apiKey, secret);
26
- const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
27
- this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);
26
+ super({ apiKey, secret, token: options == null ? void 0 : options.token });
27
+ this.rpc = new TwirpRpc(host, livekitPackage, {
28
+ requestTimeout: options == null ? void 0 : options.requestTimeout,
29
+ failover: options == null ? void 0 : options.failover
30
+ });
28
31
  }
29
32
  /**
30
33
  * Initiate an outbound WhatsApp call
@@ -89,14 +92,15 @@ class ConnectorClient extends ServiceBase {
89
92
  participantMetadata,
90
93
  participantAttributes: options.participantAttributes,
91
94
  destinationCountry,
92
- ringingTimeout: options.ringingTimeout ? new Duration({ seconds: BigInt(options.ringingTimeout) }) : void 0,
93
95
  waitUntilAnswered: options.waitUntilAnswered
94
96
  }).toJson();
97
+ const timeout = options.waitUntilAnswered ? options.timeout ?? DEFAULT_RINGING_TIMEOUT_SECONDS : options.timeout;
95
98
  const data = await this.rpc.request(
96
99
  svc,
97
100
  "AcceptWhatsAppCall",
98
101
  req,
99
- await this.authHeader({ roomCreate: true })
102
+ await this.authHeader({ roomCreate: true }),
103
+ timeout
100
104
  );
101
105
  return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
102
106
  }
@@ -1 +1 @@
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;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,wBAAwB;AAAA,MACtC,uBAAuB,QAAQ;AAAA,MAC/B,uBAAuB,QAAQ;AAAA,MAC/B,gBAAgB,QAAQ;AAAA,MACxB,yBAAyB,QAAQ;AAAA,MACjC;AAAA,MACA;AAAA,MACA,QAAQ,QAAQ;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A;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';\nimport { DEFAULT_RINGING_TIMEOUT_SECONDS } from './dialTimeout.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 - Wait until the inbound party joins before returning. */\n waitUntilAnswered?: boolean;\n /**\n * Optional - Request timeout in seconds. When `waitUntilAnswered` is set it\n * defaults to the standard ring window; otherwise the client default applies.\n */\n timeout?: number;\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, token: options?.token });\n this.rpc = new TwirpRpc(host, livekitPackage, {\n requestTimeout: options?.requestTimeout,\n failover: options?.failover,\n });\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 waitUntilAnswered: options.waitUntilAnswered,\n }).toJson();\n\n // When waiting for the inbound party to join, the request can block, so\n // default the timeout to the standard ring window; otherwise the client\n // default applies.\n const timeout = options.waitUntilAnswered\n ? (options.timeout ?? DEFAULT_RINGING_TIMEOUT_SECONDS)\n : options.timeout;\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n timeout,\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;AACnD,SAAS,uCAAuC;AAEhD,MAAM,MAAM;AA2FL,MAAM,wBAAwB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS/C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,EAAE,QAAQ,QAAQ,OAAO,mCAAS,MAAM,CAAC;AAC/C,SAAK,MAAM,IAAI,SAAS,MAAM,gBAAgB;AAAA,MAC5C,gBAAgB,mCAAS;AAAA,MACzB,UAAU,mCAAS;AAAA,IACrB,CAAC;AAAA,EACH;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,wBAAwB;AAAA,MACtC,uBAAuB,QAAQ;AAAA,MAC/B,uBAAuB,QAAQ;AAAA,MAC/B,gBAAgB,QAAQ;AAAA,MACxB,yBAAyB,QAAQ;AAAA,MACjC;AAAA,MACA;AAAA,MACA,QAAQ,QAAQ;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,Q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AAM,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":[]}
@@ -33,9 +33,11 @@ class EgressClient extends import_ServiceBase.ServiceBase {
33
33
  * @param options - client options
34
34
  */
35
35
  constructor(host, apiKey, secret, options) {
36
- super(apiKey, secret);
37
- const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
38
- this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, rpcOptions);
36
+ super({ apiKey, secret, token: options == null ? void 0 : options.token });
37
+ this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, {
38
+ requestTimeout: options == null ? void 0 : options.requestTimeout,
39
+ failover: options == null ? void 0 : options.failover
40
+ });
39
41
  }
40
42
  async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl, audioMixing) {
41
43
  let layout;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/EgressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n DirectFileOutput,\n EncodedFileOutput,\n EncodingOptions,\n EncodingOptionsPreset,\n ImageOutput,\n SegmentedFileOutput,\n StreamOutput,\n WebhookConfig,\n} from '@livekit/protocol';\nimport {\n AudioMixing,\n EgressInfo,\n ListEgressRequest,\n ListEgressResponse,\n ParticipantEgressRequest,\n RoomCompositeEgressRequest,\n StopEgressRequest,\n TrackCompositeEgressRequest,\n TrackEgressRequest,\n UpdateLayoutRequest,\n UpdateStreamRequest,\n WebEgressRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Egress';\n\nexport interface BaseOptions {\n /**\n * webhooks to call for this request, optional.\n */\n webhooks?: WebhookConfig[];\n}\n\nexport interface RoomCompositeOptions extends BaseOptions {\n /**\n * egress layout. optional\n */\n layout?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * custom template url. optional\n */\n customBaseUrl?: string;\n /**\n * audio mixing options. optional\n */\n audioMixing?: AudioMixing;\n}\n\nexport interface WebOptions extends BaseOptions {\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * await START_RECORDING chrome log\n */\n awaitStartSignal?: boolean;\n}\n\nexport interface ParticipantEgressOptions extends BaseOptions {\n /**\n * true to capture source screenshare and screenshare_audio\n * false to capture camera and microphone\n */\n screenShare?: boolean;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\nexport interface TrackCompositeOptions extends BaseOptions {\n /**\n * audio track ID\n */\n audioTrackId?: string;\n /**\n * video track ID\n */\n videoTrackId?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\n/**\n * Used to supply multiple outputs with an egress request\n */\nexport interface EncodedOutputs {\n file?: EncodedFileOutput | undefined;\n stream?: StreamOutput | undefined;\n segments?: SegmentedFileOutput | undefined;\n images?: ImageOutput | undefined;\n}\n\nexport interface ListEgressOptions {\n roomName?: string;\n egressId?: string;\n active?: boolean;\n}\n\n/**\n * Client to access Egress APIs\n */\nexport class EgressClient 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 * @param roomName - room name\n * @param output - file or stream output\n * @param opts - RoomCompositeOptions\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: RoomCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use RoomCompositeOptions instead\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n layout?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo>;\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrLayout?: RoomCompositeOptions | string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo> {\n let layout: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrLayout !== undefined) {\n if (typeof optsOrLayout === 'string') {\n layout = optsOrLayout;\n } else {\n const opts = <RoomCompositeOptions>optsOrLayout;\n layout = opts.layout;\n options = opts.encodingOptions;\n audioOnly = opts.audioOnly;\n videoOnly = opts.videoOnly;\n customBaseUrl = opts.customBaseUrl;\n audioMixing = opts.audioMixing;\n webhooks = opts.webhooks;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n audioMixing ??= AudioMixing.DEFAULT_MIXING;\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n\n const req = new RoomCompositeEgressRequest({\n roomName,\n layout,\n audioOnly,\n audioMixing,\n videoOnly,\n customBaseUrl,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartRoomCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param url - url\n * @param output - file or stream output\n * @param opts - WebOptions\n */\n async startWebEgress(\n url: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: WebOptions,\n ): Promise<EgressInfo> {\n const audioOnly = opts?.audioOnly || false;\n const videoOnly = opts?.videoOnly || false;\n const awaitStartSignal = opts?.awaitStartSignal || false;\n const webhooks = opts?.webhooks || [];\n const {\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, opts?.encodingOptions);\n\n const req = new WebEgressRequest({\n url,\n audioOnly,\n videoOnly,\n awaitStartSignal,\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartWebEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Export a participant's audio and video tracks,\n *\n * @param roomName - room name\n * @param output - one or more outputs\n * @param opts - ParticipantEgressOptions\n */\n async startParticipantEgress(\n roomName: string,\n identity: string,\n output: EncodedOutputs,\n opts?: ParticipantEgressOptions,\n ): Promise<EgressInfo> {\n const webhooks = opts?.webhooks || [];\n const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =\n this.getOutputParams(output, opts?.encodingOptions);\n const req = new ParticipantEgressRequest({\n roomName,\n identity,\n screenShare: opts?.screenShare ?? false,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartParticipantEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - TrackCompositeOptions\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: TrackCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use TrackCompositeOptions instead\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n audioTrackId?: string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo>;\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrAudioTrackId?: TrackCompositeOptions | string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo> {\n let audioTrackId: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrAudioTrackId !== undefined) {\n if (typeof optsOrAudioTrackId === 'string') {\n audioTrackId = optsOrAudioTrackId;\n } else {\n const opts = <TrackCompositeOptions>optsOrAudioTrackId;\n audioTrackId = opts.audioTrackId;\n videoTrackId = opts.videoTrackId;\n options = opts.encodingOptions;\n webhooks = opts.webhooks;\n }\n }\n\n audioTrackId ??= '';\n videoTrackId ??= '';\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n const req = new TrackCompositeEgressRequest({\n roomName,\n audioTrackId,\n videoTrackId,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedOutputs(output: any): output is EncodedOutputs {\n return (\n (<EncodedOutputs>output).file !== undefined ||\n (<EncodedOutputs>output).stream !== undefined ||\n (<EncodedOutputs>output).segments !== undefined ||\n (<EncodedOutputs>output).images !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedFileOutput(output: any): output is EncodedFileOutput {\n return (\n (<EncodedFileOutput>output).filepath !== undefined ||\n (<EncodedFileOutput>output).fileType !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isSegmentedFileOutput(output: any): output is SegmentedFileOutput {\n return (\n (<SegmentedFileOutput>output).filenamePrefix !== undefined ||\n (<SegmentedFileOutput>output).playlistName !== undefined ||\n (<SegmentedFileOutput>output).filenameSuffix !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isStreamOutput(output: any): output is StreamOutput {\n return (\n (<StreamOutput>output).protocol !== undefined || (<StreamOutput>output).urls !== undefined\n );\n }\n\n private getOutputParams(\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: EncodingOptionsPreset | EncodingOptions,\n ) {\n let file: EncodedFileOutput | undefined;\n let fileOutputs: Array<EncodedFileOutput> | undefined;\n let stream: StreamOutput | undefined;\n let streamOutputs: Array<StreamOutput> | undefined;\n let segments: SegmentedFileOutput | undefined;\n let segmentOutputs: Array<SegmentedFileOutput> | undefined;\n let imageOutputs: Array<ImageOutput> | undefined;\n\n if (this.isEncodedOutputs(output)) {\n if (output.file !== undefined) {\n fileOutputs = [output.file];\n }\n if (output.stream !== undefined) {\n streamOutputs = [output.stream];\n }\n if (output.segments !== undefined) {\n segmentOutputs = [output.segments];\n }\n if (output.images !== undefined) {\n imageOutputs = [output.images];\n }\n } else if (this.isEncodedFileOutput(output)) {\n file = output;\n fileOutputs = [file];\n } else if (this.isSegmentedFileOutput(output)) {\n segments = output;\n segmentOutputs = [segments];\n } else if (this.isStreamOutput(output)) {\n stream = output;\n streamOutputs = [stream];\n }\n\n let legacyOutput:\n | {\n value: EncodedFileOutput;\n case: 'file';\n }\n | {\n value: StreamOutput;\n case: 'stream';\n }\n | {\n value: SegmentedFileOutput;\n case: 'segments';\n }\n | undefined;\n\n if (file) {\n legacyOutput = {\n case: 'file',\n value: file,\n };\n } else if (stream) {\n legacyOutput = {\n case: 'stream',\n value: stream,\n };\n } else if (segments) {\n legacyOutput = {\n case: 'segments',\n value: segments,\n };\n }\n let egressOptions:\n | {\n value: EncodingOptionsPreset;\n case: 'preset';\n }\n | {\n value: EncodingOptions;\n case: 'advanced';\n }\n | undefined;\n if (opts) {\n if (typeof opts === 'number') {\n egressOptions = {\n case: 'preset',\n value: opts,\n };\n } else {\n egressOptions = {\n case: 'advanced',\n value: <EncodingOptions>opts,\n };\n }\n }\n\n return {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n };\n }\n\n /**\n * @param roomName - room name\n * @param output - file or websocket output\n * @param trackId - track Id\n */\n async startTrackEgress(\n roomName: string,\n output: DirectFileOutput | string,\n trackId: string,\n webhooks?: WebhookConfig[],\n ): Promise<EgressInfo> {\n let legacyOutput:\n | {\n value: DirectFileOutput;\n case: 'file';\n }\n | {\n value: string;\n case: 'websocketUrl';\n }\n | undefined;\n\n if (typeof output === 'string') {\n legacyOutput = {\n case: 'websocketUrl',\n value: output,\n };\n } else {\n legacyOutput = {\n case: 'file',\n value: output,\n };\n }\n\n const req = new TrackEgressRequest({\n roomName,\n trackId,\n output: legacyOutput,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param layout -\n */\n async updateLayout(egressId: string, layout: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'UpdateLayout',\n new UpdateLayoutRequest({ egressId, layout }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param addOutputUrls -\n * @param removeOutputUrls -\n */\n async updateStream(\n egressId: string,\n addOutputUrls?: string[],\n removeOutputUrls?: string[],\n ): Promise<EgressInfo> {\n addOutputUrls ??= [];\n removeOutputUrls ??= [];\n\n const data = await this.rpc.request(\n svc,\n 'UpdateStream',\n new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param options - options to filter listed Egresses, by default returns all\n * Egress instances\n */\n async listEgress(options?: ListEgressOptions): Promise<Array<EgressInfo>>;\n /**\n * @deprecated use `listEgress(options?: ListEgressOptions)` instead\n * @param roomName - list egress for one room only\n */\n async listEgress(roomName?: string): Promise<Array<EgressInfo>>;\n /**\n * @param roomName - list egress for one room only\n */\n async listEgress(options?: string | ListEgressOptions): Promise<Array<EgressInfo>> {\n let req: Partial<ListEgressRequest> = {};\n if (typeof options === 'string') {\n req.roomName = options;\n } else if (options !== undefined) {\n req = options;\n }\n\n const data = await this.rpc.request(\n svc,\n 'ListEgress',\n new ListEgressRequest(req).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param egressId -\n */\n async stopEgress(egressId: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'StopEgress',\n new StopEgressRequest({ egressId }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,sBAaO;AAEP,yBAA4B;AAE5B,sBAAyC;AAEzC,MAAM,MAAM;AAqGL,MAAM,qBAAqB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5C,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,EAyBA,MAAM,yBACJ,UACA,QACA,cACA,SACA,WACA,WACA,eACA,aACqB;AACrB,QAAI;AACJ,QAAI;AACJ,QAAI,iBAAiB,QAAW;AAC9B,UAAI,OAAO,iBAAiB,UAAU;AACpC,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,OAA6B;AACnC,iBAAS,KAAK;AACd,kBAAU,KAAK;AACf,oBAAY,KAAK;AACjB,oBAAY,KAAK;AACjB,wBAAgB,KAAK;AACrB,sBAAc,KAAK;AACnB,mBAAW,KAAK;AAAA,MAClB;AAAA,IACF;AAEA,eAAW;AACX,kBAAc;AACd,kBAAc;AACd,sBAAkB;AAClB,oBAAgB,4BAAY;AAE5B,UAAM;AAAA,MACJ,QAAQ;AAAA,MACR,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,IAAI,KAAK,gBAAgB,QAAQ,OAAO;AAExC,UAAM,MAAM,IAAI,2CAA2B;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA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AK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,2BAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/EgressClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n DirectFileOutput,\n EncodedFileOutput,\n EncodingOptions,\n EncodingOptionsPreset,\n ImageOutput,\n SegmentedFileOutput,\n StreamOutput,\n WebhookConfig,\n} from '@livekit/protocol';\nimport {\n AudioMixing,\n EgressInfo,\n ListEgressRequest,\n ListEgressResponse,\n ParticipantEgressRequest,\n RoomCompositeEgressRequest,\n StopEgressRequest,\n TrackCompositeEgressRequest,\n TrackEgressRequest,\n UpdateLayoutRequest,\n UpdateStreamRequest,\n WebEgressRequest,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport type { Rpc } from './TwirpRPC.js';\nimport { TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Egress';\n\nexport interface BaseOptions {\n /**\n * webhooks to call for this request, optional.\n */\n webhooks?: WebhookConfig[];\n}\n\nexport interface RoomCompositeOptions extends BaseOptions {\n /**\n * egress layout. optional\n */\n layout?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * custom template url. optional\n */\n customBaseUrl?: string;\n /**\n * audio mixing options. optional\n */\n audioMixing?: AudioMixing;\n}\n\nexport interface WebOptions extends BaseOptions {\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n /**\n * record audio only. optional\n */\n audioOnly?: boolean;\n /**\n * record video only. optional\n */\n videoOnly?: boolean;\n /**\n * await START_RECORDING chrome log\n */\n awaitStartSignal?: boolean;\n}\n\nexport interface ParticipantEgressOptions extends BaseOptions {\n /**\n * true to capture source screenshare and screenshare_audio\n * false to capture camera and microphone\n */\n screenShare?: boolean;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\nexport interface TrackCompositeOptions extends BaseOptions {\n /**\n * audio track ID\n */\n audioTrackId?: string;\n /**\n * video track ID\n */\n videoTrackId?: string;\n /**\n * encoding options or preset. optional\n */\n encodingOptions?: EncodingOptionsPreset | EncodingOptions;\n}\n\n/**\n * Used to supply multiple outputs with an egress request\n */\nexport interface EncodedOutputs {\n file?: EncodedFileOutput | undefined;\n stream?: StreamOutput | undefined;\n segments?: SegmentedFileOutput | undefined;\n images?: ImageOutput | undefined;\n}\n\nexport interface ListEgressOptions {\n roomName?: string;\n egressId?: string;\n active?: boolean;\n}\n\n/**\n * Client to access Egress APIs\n */\nexport class EgressClient 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, token: options?.token });\n this.rpc = new TwirpRpc(host, livekitPackage, {\n requestTimeout: options?.requestTimeout,\n failover: options?.failover,\n });\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - RoomCompositeOptions\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: RoomCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use RoomCompositeOptions instead\n */\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n layout?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo>;\n async startRoomCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrLayout?: RoomCompositeOptions | string,\n options?: EncodingOptionsPreset | EncodingOptions,\n audioOnly?: boolean,\n videoOnly?: boolean,\n customBaseUrl?: string,\n audioMixing?: AudioMixing,\n ): Promise<EgressInfo> {\n let layout: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrLayout !== undefined) {\n if (typeof optsOrLayout === 'string') {\n layout = optsOrLayout;\n } else {\n const opts = <RoomCompositeOptions>optsOrLayout;\n layout = opts.layout;\n options = opts.encodingOptions;\n audioOnly = opts.audioOnly;\n videoOnly = opts.videoOnly;\n customBaseUrl = opts.customBaseUrl;\n audioMixing = opts.audioMixing;\n webhooks = opts.webhooks;\n }\n }\n\n layout ??= '';\n audioOnly ??= false;\n videoOnly ??= false;\n customBaseUrl ??= '';\n audioMixing ??= AudioMixing.DEFAULT_MIXING;\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n\n const req = new RoomCompositeEgressRequest({\n roomName,\n layout,\n audioOnly,\n audioMixing,\n videoOnly,\n customBaseUrl,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartRoomCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param url - url\n * @param output - file or stream output\n * @param opts - WebOptions\n */\n async startWebEgress(\n url: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: WebOptions,\n ): Promise<EgressInfo> {\n const audioOnly = opts?.audioOnly || false;\n const videoOnly = opts?.videoOnly || false;\n const awaitStartSignal = opts?.awaitStartSignal || false;\n const webhooks = opts?.webhooks || [];\n const {\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, opts?.encodingOptions);\n\n const req = new WebEgressRequest({\n url,\n audioOnly,\n videoOnly,\n awaitStartSignal,\n output: legacyOutput,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartWebEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Export a participant's audio and video tracks,\n *\n * @param roomName - room name\n * @param output - one or more outputs\n * @param opts - ParticipantEgressOptions\n */\n async startParticipantEgress(\n roomName: string,\n identity: string,\n output: EncodedOutputs,\n opts?: ParticipantEgressOptions,\n ): Promise<EgressInfo> {\n const webhooks = opts?.webhooks || [];\n const { options, fileOutputs, streamOutputs, segmentOutputs, imageOutputs } =\n this.getOutputParams(output, opts?.encodingOptions);\n const req = new ParticipantEgressRequest({\n roomName,\n identity,\n screenShare: opts?.screenShare ?? false,\n options,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartParticipantEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param roomName - room name\n * @param output - file or stream output\n * @param opts - TrackCompositeOptions\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: TrackCompositeOptions,\n ): Promise<EgressInfo>;\n /**\n * @deprecated use TrackCompositeOptions instead\n */\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n audioTrackId?: string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo>;\n async startTrackCompositeEgress(\n roomName: string,\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n optsOrAudioTrackId?: TrackCompositeOptions | string,\n videoTrackId?: string,\n options?: EncodingOptionsPreset | EncodingOptions,\n ): Promise<EgressInfo> {\n let audioTrackId: string | undefined;\n let webhooks: WebhookConfig[] | undefined;\n if (optsOrAudioTrackId !== undefined) {\n if (typeof optsOrAudioTrackId === 'string') {\n audioTrackId = optsOrAudioTrackId;\n } else {\n const opts = <TrackCompositeOptions>optsOrAudioTrackId;\n audioTrackId = opts.audioTrackId;\n videoTrackId = opts.videoTrackId;\n options = opts.encodingOptions;\n webhooks = opts.webhooks;\n }\n }\n\n audioTrackId ??= '';\n videoTrackId ??= '';\n\n const {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n } = this.getOutputParams(output, options);\n const req = new TrackCompositeEgressRequest({\n roomName,\n audioTrackId,\n videoTrackId,\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackCompositeEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedOutputs(output: any): output is EncodedOutputs {\n return (\n (<EncodedOutputs>output).file !== undefined ||\n (<EncodedOutputs>output).stream !== undefined ||\n (<EncodedOutputs>output).segments !== undefined ||\n (<EncodedOutputs>output).images !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isEncodedFileOutput(output: any): output is EncodedFileOutput {\n return (\n (<EncodedFileOutput>output).filepath !== undefined ||\n (<EncodedFileOutput>output).fileType !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isSegmentedFileOutput(output: any): output is SegmentedFileOutput {\n return (\n (<SegmentedFileOutput>output).filenamePrefix !== undefined ||\n (<SegmentedFileOutput>output).playlistName !== undefined ||\n (<SegmentedFileOutput>output).filenameSuffix !== undefined\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private isStreamOutput(output: any): output is StreamOutput {\n return (\n (<StreamOutput>output).protocol !== undefined || (<StreamOutput>output).urls !== undefined\n );\n }\n\n private getOutputParams(\n output: EncodedOutputs | EncodedFileOutput | StreamOutput | SegmentedFileOutput,\n opts?: EncodingOptionsPreset | EncodingOptions,\n ) {\n let file: EncodedFileOutput | undefined;\n let fileOutputs: Array<EncodedFileOutput> | undefined;\n let stream: StreamOutput | undefined;\n let streamOutputs: Array<StreamOutput> | undefined;\n let segments: SegmentedFileOutput | undefined;\n let segmentOutputs: Array<SegmentedFileOutput> | undefined;\n let imageOutputs: Array<ImageOutput> | undefined;\n\n if (this.isEncodedOutputs(output)) {\n if (output.file !== undefined) {\n fileOutputs = [output.file];\n }\n if (output.stream !== undefined) {\n streamOutputs = [output.stream];\n }\n if (output.segments !== undefined) {\n segmentOutputs = [output.segments];\n }\n if (output.images !== undefined) {\n imageOutputs = [output.images];\n }\n } else if (this.isEncodedFileOutput(output)) {\n file = output;\n fileOutputs = [file];\n } else if (this.isSegmentedFileOutput(output)) {\n segments = output;\n segmentOutputs = [segments];\n } else if (this.isStreamOutput(output)) {\n stream = output;\n streamOutputs = [stream];\n }\n\n let legacyOutput:\n | {\n value: EncodedFileOutput;\n case: 'file';\n }\n | {\n value: StreamOutput;\n case: 'stream';\n }\n | {\n value: SegmentedFileOutput;\n case: 'segments';\n }\n | undefined;\n\n if (file) {\n legacyOutput = {\n case: 'file',\n value: file,\n };\n } else if (stream) {\n legacyOutput = {\n case: 'stream',\n value: stream,\n };\n } else if (segments) {\n legacyOutput = {\n case: 'segments',\n value: segments,\n };\n }\n let egressOptions:\n | {\n value: EncodingOptionsPreset;\n case: 'preset';\n }\n | {\n value: EncodingOptions;\n case: 'advanced';\n }\n | undefined;\n if (opts) {\n if (typeof opts === 'number') {\n egressOptions = {\n case: 'preset',\n value: opts,\n };\n } else {\n egressOptions = {\n case: 'advanced',\n value: <EncodingOptions>opts,\n };\n }\n }\n\n return {\n output: legacyOutput,\n options: egressOptions,\n fileOutputs,\n streamOutputs,\n segmentOutputs,\n imageOutputs,\n };\n }\n\n /**\n * @param roomName - room name\n * @param output - file or websocket output\n * @param trackId - track Id\n */\n async startTrackEgress(\n roomName: string,\n output: DirectFileOutput | string,\n trackId: string,\n webhooks?: WebhookConfig[],\n ): Promise<EgressInfo> {\n let legacyOutput:\n | {\n value: DirectFileOutput;\n case: 'file';\n }\n | {\n value: string;\n case: 'websocketUrl';\n }\n | undefined;\n\n if (typeof output === 'string') {\n legacyOutput = {\n case: 'websocketUrl',\n value: output,\n };\n } else {\n legacyOutput = {\n case: 'file',\n value: output,\n };\n }\n\n const req = new TrackEgressRequest({\n roomName,\n trackId,\n output: legacyOutput,\n webhooks,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'StartTrackEgress',\n req,\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param layout -\n */\n async updateLayout(egressId: string, layout: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'UpdateLayout',\n new UpdateLayoutRequest({ egressId, layout }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param egressId -\n * @param addOutputUrls -\n * @param removeOutputUrls -\n */\n async updateStream(\n egressId: string,\n addOutputUrls?: string[],\n removeOutputUrls?: string[],\n ): Promise<EgressInfo> {\n addOutputUrls ??= [];\n removeOutputUrls ??= [];\n\n const data = await this.rpc.request(\n svc,\n 'UpdateStream',\n new UpdateStreamRequest({ egressId, addOutputUrls, removeOutputUrls }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * @param options - options to filter listed Egresses, by default returns all\n * Egress instances\n */\n async listEgress(options?: ListEgressOptions): Promise<Array<EgressInfo>>;\n /**\n * @deprecated use `listEgress(options?: ListEgressOptions)` instead\n * @param roomName - list egress for one room only\n */\n async listEgress(roomName?: string): Promise<Array<EgressInfo>>;\n /**\n * @param roomName - list egress for one room only\n */\n async listEgress(options?: string | ListEgressOptions): Promise<Array<EgressInfo>> {\n let req: Partial<ListEgressRequest> = {};\n if (typeof options === 'string') {\n req.roomName = options;\n } else if (options !== undefined) {\n req = options;\n }\n\n const data = await this.rpc.request(\n svc,\n 'ListEgress',\n new ListEgressRequest(req).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return ListEgressResponse.fromJson(data, { ignoreUnknownFields: true }).items ?? [];\n }\n\n /**\n * @param egressId -\n */\n async stopEgress(egressId: string): Promise<EgressInfo> {\n const data = await this.rpc.request(\n svc,\n 'StopEgress',\n new StopEgressRequest({ egressId }).toJson(),\n await this.authHeader({ roomRecord: true }),\n );\n return EgressInfo.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,sBAaO;AAEP,yBAA4B;AAE5B,sBAAyC;AAEzC,MAAM,MAAM;AAqGL,MAAM,qBAAqB,+BAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS5C,YAAY,MAAc,QAAiB,QAAiB,SAAyB;AACnF,UAAM,EAAE,QAAQ,QAAQ,OAAO,mCAAS,MAAM,CAAC;AAC/C,SAAK,MAAM,IAAI,yBAAS,MAAM,gCAAgB;AAAA,MAC5C,gBAAgB,mCAAS;AAAA,MACzB,UAAU,mCAAS;AAAA,IACrB,CAAC;AAAA,EACH;AAAA,EAyBA,MA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AAAA,EAChE;AAAA;AAAA;AAAA;AAAA,EAeA,MAAM,WAAW,SAAkE;AACjF,QAAI,MAAkC,CAAC;AACvC,QAAI,OAAO,YAAY,UAAU;AAC/B,UAAI,WAAW;AAAA,IACjB,WAAW,YAAY,QAAW;AAChC,YAAM;AAAA,IACR;AAEA,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,GAAG,EAAE,OAAO;AAAA,MAClC,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,mCAAmB,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC,EAAE,SAAS,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAW,UAAuC;AACtD,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA,IAAI,kCAAkB,EAAE,SAAS,CAAC,EAAE,OAAO;AAAA,MAC3C,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,2BAAW,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAChE;AACF;","names":[]}
@@ -23,9 +23,11 @@ class EgressClient extends ServiceBase {
23
23
  * @param options - client options
24
24
  */
25
25
  constructor(host, apiKey, secret, options) {
26
- super(apiKey, secret);
27
- const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
28
- this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);
26
+ super({ apiKey, secret, token: options == null ? void 0 : options.token });
27
+ this.rpc = new TwirpRpc(host, livekitPackage, {
28
+ requestTimeout: options == null ? void 0 : options.requestTimeout,
29
+ failover: options == null ? void 0 : options.failover
30
+ });
29
31
  }
30
32
  async startRoomCompositeEgress(roomName, output, optsOrLayout, options, audioOnly, videoOnly, customBaseUrl, audioMixing) {
31
33
  let layout;