agora-agents 3.0.0-alpha.2 → 3.0.0-alpha.4

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 (135) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/AgoraPoolClient.d.ts +16 -3
  3. package/dist/cjs/AgoraPoolClient.js +47 -16
  4. package/dist/cjs/agentkit/Agent.js +17 -7
  5. package/dist/cjs/agentkit/AgentSession.js +8 -10
  6. package/dist/cjs/agentkit/avatar-types.d.ts +6 -0
  7. package/dist/cjs/agentkit/index.d.ts +7 -9
  8. package/dist/cjs/agentkit/index.js +8 -6
  9. package/dist/cjs/agentkit/presets.js +3 -3
  10. package/dist/cjs/agentkit/preview/client.d.ts +6 -5
  11. package/dist/cjs/agentkit/preview/client.js +7 -7
  12. package/dist/cjs/agentkit/preview/gemini-tts.d.ts +3 -31
  13. package/dist/cjs/agentkit/preview/gemini-tts.js +4 -30
  14. package/dist/cjs/agentkit/preview/index.d.ts +2 -2
  15. package/dist/cjs/agentkit/preview/index.js +4 -4
  16. package/dist/cjs/agentkit/session-backend.d.ts +3 -1
  17. package/dist/cjs/agentkit/session-backend.js +32 -33
  18. package/dist/cjs/agentkit/token.d.ts +46 -9
  19. package/dist/cjs/agentkit/token.js +35 -7
  20. package/dist/cjs/agentkit/types.d.ts +12 -3
  21. package/dist/cjs/agentkit/v3.d.ts +7 -3
  22. package/dist/cjs/agentkit/v3.js +35 -21
  23. package/dist/cjs/agentkit/vendors/avatar.d.ts +6 -0
  24. package/dist/cjs/agentkit/vendors/avatar.js +14 -2
  25. package/dist/cjs/agentkit/vendors/stt.d.ts +35 -0
  26. package/dist/cjs/agentkit/vendors/stt.js +19 -2
  27. package/dist/cjs/agentkit/vendors/tts.d.ts +72 -18
  28. package/dist/cjs/agentkit/vendors/tts.js +60 -11
  29. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +13 -0
  30. package/dist/cjs/api/resources/agents/types/GetTurnsAgentsResponse.d.ts +3 -1
  31. package/dist/cjs/api/types/Asr.d.ts +4 -1
  32. package/dist/cjs/api/types/CartesiaTts.d.ts +10 -0
  33. package/dist/cjs/api/types/CartesiaTts.js +9 -0
  34. package/dist/cjs/api/types/CartesiaTtsParams.d.ts +1 -1
  35. package/dist/cjs/api/types/DeepgramAsrParams.d.ts +1 -1
  36. package/dist/cjs/api/types/FishAudioTts.d.ts +10 -0
  37. package/dist/cjs/api/types/FishAudioTts.js +9 -0
  38. package/dist/cjs/api/types/FishAudioTtsParams.d.ts +1 -1
  39. package/dist/cjs/api/types/GeminiTts.d.ts +9 -0
  40. package/dist/cjs/api/types/GeminiTts.js +3 -0
  41. package/dist/cjs/api/types/GeminiTtsParams.d.ts +15 -0
  42. package/dist/cjs/api/types/GeminiTtsParams.js +3 -0
  43. package/dist/cjs/api/types/RtzrAsr.d.ts +10 -0
  44. package/dist/cjs/api/types/RtzrAsr.js +3 -0
  45. package/dist/cjs/api/types/RtzrAsrParams.d.ts +31 -0
  46. package/dist/cjs/api/types/RtzrAsrParams.js +3 -0
  47. package/dist/cjs/api/types/SarvamTtsParams.d.ts +12 -8
  48. package/dist/cjs/api/types/SarvamTtsParams.js +1 -1
  49. package/dist/cjs/api/types/Tts.d.ts +4 -1
  50. package/dist/cjs/api/types/index.d.ts +4 -0
  51. package/dist/cjs/api/types/index.js +4 -0
  52. package/dist/cjs/core/auth/publicAuthorization.d.ts +3 -0
  53. package/dist/cjs/core/auth/publicAuthorization.js +37 -0
  54. package/dist/cjs/index.d.ts +6 -6
  55. package/dist/cjs/index.js +14 -6
  56. package/dist/cjs/v3/campaigns.js +5 -2
  57. package/dist/cjs/v3/errors.d.ts +103 -0
  58. package/dist/cjs/v3/errors.js +179 -0
  59. package/dist/cjs/v3/index.d.ts +2 -0
  60. package/dist/cjs/v3/index.js +9 -1
  61. package/dist/cjs/v3/resources.js +17 -8
  62. package/dist/cjs/v3/session-lifecycle.d.ts +2 -1
  63. package/dist/cjs/v3/session-lifecycle.js +22 -18
  64. package/dist/cjs/v3/transport.d.ts +1 -13
  65. package/dist/cjs/v3/transport.js +88 -42
  66. package/dist/cjs/version.d.ts +1 -1
  67. package/dist/cjs/version.js +1 -1
  68. package/dist/esm/AgoraPoolClient.d.mts +16 -3
  69. package/dist/esm/AgoraPoolClient.mjs +48 -17
  70. package/dist/esm/agentkit/Agent.mjs +17 -7
  71. package/dist/esm/agentkit/AgentSession.mjs +8 -10
  72. package/dist/esm/agentkit/avatar-types.d.mts +6 -0
  73. package/dist/esm/agentkit/index.d.mts +7 -9
  74. package/dist/esm/agentkit/index.mjs +3 -4
  75. package/dist/esm/agentkit/presets.mjs +3 -3
  76. package/dist/esm/agentkit/preview/client.d.mts +6 -5
  77. package/dist/esm/agentkit/preview/client.mjs +7 -7
  78. package/dist/esm/agentkit/preview/gemini-tts.d.mts +3 -31
  79. package/dist/esm/agentkit/preview/gemini-tts.mjs +1 -28
  80. package/dist/esm/agentkit/preview/index.d.mts +2 -2
  81. package/dist/esm/agentkit/preview/index.mjs +1 -1
  82. package/dist/esm/agentkit/session-backend.d.mts +3 -1
  83. package/dist/esm/agentkit/session-backend.mjs +33 -34
  84. package/dist/esm/agentkit/token.d.mts +46 -9
  85. package/dist/esm/agentkit/token.mjs +34 -7
  86. package/dist/esm/agentkit/types.d.mts +12 -3
  87. package/dist/esm/agentkit/v3.d.mts +7 -3
  88. package/dist/esm/agentkit/v3.mjs +34 -20
  89. package/dist/esm/agentkit/vendors/avatar.d.mts +6 -0
  90. package/dist/esm/agentkit/vendors/avatar.mjs +14 -2
  91. package/dist/esm/agentkit/vendors/stt.d.mts +35 -0
  92. package/dist/esm/agentkit/vendors/stt.mjs +17 -1
  93. package/dist/esm/agentkit/vendors/tts.d.mts +72 -18
  94. package/dist/esm/agentkit/vendors/tts.mjs +58 -10
  95. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +13 -0
  96. package/dist/esm/api/resources/agents/types/GetTurnsAgentsResponse.d.mts +3 -1
  97. package/dist/esm/api/types/Asr.d.mts +4 -1
  98. package/dist/esm/api/types/CartesiaTts.d.mts +10 -0
  99. package/dist/esm/api/types/CartesiaTts.mjs +8 -1
  100. package/dist/esm/api/types/CartesiaTtsParams.d.mts +1 -1
  101. package/dist/esm/api/types/DeepgramAsrParams.d.mts +1 -1
  102. package/dist/esm/api/types/FishAudioTts.d.mts +10 -0
  103. package/dist/esm/api/types/FishAudioTts.mjs +8 -1
  104. package/dist/esm/api/types/FishAudioTtsParams.d.mts +1 -1
  105. package/dist/esm/api/types/GeminiTts.d.mts +9 -0
  106. package/dist/esm/api/types/GeminiTts.mjs +2 -0
  107. package/dist/esm/api/types/GeminiTtsParams.d.mts +15 -0
  108. package/dist/esm/api/types/GeminiTtsParams.mjs +2 -0
  109. package/dist/esm/api/types/RtzrAsr.d.mts +10 -0
  110. package/dist/esm/api/types/RtzrAsr.mjs +2 -0
  111. package/dist/esm/api/types/RtzrAsrParams.d.mts +31 -0
  112. package/dist/esm/api/types/RtzrAsrParams.mjs +2 -0
  113. package/dist/esm/api/types/SarvamTtsParams.d.mts +12 -8
  114. package/dist/esm/api/types/SarvamTtsParams.mjs +1 -1
  115. package/dist/esm/api/types/Tts.d.mts +4 -1
  116. package/dist/esm/api/types/index.d.mts +4 -0
  117. package/dist/esm/api/types/index.mjs +4 -0
  118. package/dist/esm/core/auth/publicAuthorization.d.mts +3 -0
  119. package/dist/esm/core/auth/publicAuthorization.mjs +33 -0
  120. package/dist/esm/index.d.mts +6 -6
  121. package/dist/esm/index.mjs +4 -4
  122. package/dist/esm/v3/campaigns.mjs +5 -2
  123. package/dist/esm/v3/errors.d.mts +103 -0
  124. package/dist/esm/v3/errors.mjs +167 -0
  125. package/dist/esm/v3/index.d.mts +2 -0
  126. package/dist/esm/v3/index.mjs +1 -0
  127. package/dist/esm/v3/resources.mjs +17 -8
  128. package/dist/esm/v3/session-lifecycle.d.mts +2 -1
  129. package/dist/esm/v3/session-lifecycle.mjs +22 -18
  130. package/dist/esm/v3/transport.d.mts +1 -13
  131. package/dist/esm/v3/transport.mjs +85 -39
  132. package/dist/esm/version.d.mts +1 -1
  133. package/dist/esm/version.mjs +1 -1
  134. package/openapi.yaml +13 -5
  135. package/package.json +2 -2
@@ -6,13 +6,16 @@
6
6
  * the production vendor modules independently.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.GeminiThinkingLevels = exports.GeminiLiveModels = exports.GEMINI_PREVIEW_MLLM_URL = exports.GEMINI_MLLM_URL = exports.GEMINI_MLLM_DEFAULT_MODEL = exports.GeminiTTSModels = exports.GeminiTTS = exports.requiredPreviewFeatures = exports.previewRequestHeaders = exports.PreviewFeatures = exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.createPreviewRoute = exports.applyPreviewShape = exports.GeminiTranscriptionMode = exports.GeminiSTTModels = exports.GeminiSTT = exports.OpenAIGPTLive = void 0;
9
+ exports.GeminiThinkingLevels = exports.GeminiLiveModels = exports.GEMINI_PREVIEW_MLLM_URL = exports.GEMINI_MLLM_URL = exports.GEMINI_MLLM_DEFAULT_MODEL = exports.requiredPreviewFeatures = exports.previewRequestHeaders = exports.PreviewFeatures = exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.createPreviewRoute = exports.applyPreviewShape = exports.GeminiTTSModels = exports.GeminiTTS = exports.GeminiTranscriptionMode = exports.GeminiSTTModels = exports.GeminiSTT = exports.OpenAIGPTLive = void 0;
10
10
  var mllm_js_1 = require("../vendors/mllm.js");
11
11
  Object.defineProperty(exports, "OpenAIGPTLive", { enumerable: true, get: function () { return mllm_js_1.OpenAIGPTLive; } });
12
12
  var stt_js_1 = require("../vendors/stt.js");
13
13
  Object.defineProperty(exports, "GeminiSTT", { enumerable: true, get: function () { return stt_js_1.GeminiSTT; } });
14
14
  Object.defineProperty(exports, "GeminiSTTModels", { enumerable: true, get: function () { return stt_js_1.GeminiSTTModels; } });
15
15
  Object.defineProperty(exports, "GeminiTranscriptionMode", { enumerable: true, get: function () { return stt_js_1.GeminiTranscriptionMode; } });
16
+ var tts_js_1 = require("../vendors/tts.js");
17
+ Object.defineProperty(exports, "GeminiTTS", { enumerable: true, get: function () { return tts_js_1.GeminiTTS; } });
18
+ Object.defineProperty(exports, "GeminiTTSModels", { enumerable: true, get: function () { return tts_js_1.GeminiTTSModels; } });
16
19
  var client_js_1 = require("./client.js");
17
20
  Object.defineProperty(exports, "applyPreviewShape", { enumerable: true, get: function () { return client_js_1.applyPreviewShape; } });
18
21
  Object.defineProperty(exports, "createPreviewRoute", { enumerable: true, get: function () { return client_js_1.createPreviewRoute; } });
@@ -21,9 +24,6 @@ Object.defineProperty(exports, "PREVIEW_FEATURE_HEADER", { enumerable: true, get
21
24
  Object.defineProperty(exports, "PreviewFeatures", { enumerable: true, get: function () { return client_js_1.PreviewFeatures; } });
22
25
  Object.defineProperty(exports, "previewRequestHeaders", { enumerable: true, get: function () { return client_js_1.previewRequestHeaders; } });
23
26
  Object.defineProperty(exports, "requiredPreviewFeatures", { enumerable: true, get: function () { return client_js_1.requiredPreviewFeatures; } });
24
- var gemini_tts_js_1 = require("./gemini-tts.js");
25
- Object.defineProperty(exports, "GeminiTTS", { enumerable: true, get: function () { return gemini_tts_js_1.GeminiTTS; } });
26
- Object.defineProperty(exports, "GeminiTTSModels", { enumerable: true, get: function () { return gemini_tts_js_1.GeminiTTSModels; } });
27
27
  var vendors_js_1 = require("./vendors.js");
28
28
  Object.defineProperty(exports, "GEMINI_MLLM_DEFAULT_MODEL", { enumerable: true, get: function () { return vendors_js_1.GEMINI_MLLM_DEFAULT_MODEL; } });
29
29
  Object.defineProperty(exports, "GEMINI_MLLM_URL", { enumerable: true, get: function () { return vendors_js_1.GEMINI_MLLM_URL; } });
@@ -1,5 +1,6 @@
1
1
  /** Internal adapter for session identities, without mixing them with running-agent IDs. */
2
2
  import type { AgoraClient } from "../AgoraPoolClient.js";
3
+ import { V3ValidationError } from "../v3/errors.js";
3
4
  import type { AgentCreateRequest, TelephonyTransport } from "../v3/types.js";
4
5
  import type { Agent } from "./Agent.js";
5
6
  import { AgentSession } from "./AgentSession.js";
@@ -13,7 +14,8 @@ export interface SessionBackend {
13
14
  update(id: string, config: AgentConfigUpdate): Promise<void>;
14
15
  getInfo(id: string): Promise<SessionInfo>;
15
16
  }
16
- export declare class UnsupportedSessionOperationError extends Error {
17
+ /** The operation is not available on a v3 Platform session. A {@link V3ValidationError}. */
18
+ export declare class UnsupportedSessionOperationError extends V3ValidationError {
17
19
  constructor(operation: string);
18
20
  }
19
21
  /** Validate mixed transports before replacing internal RTC placeholders. */
@@ -12,16 +12,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UnsupportedSessionOperationError = void 0;
13
13
  exports.callSessionOptions = callSessionOptions;
14
14
  exports.createStoredSession = createStoredSession;
15
+ const errors_js_1 = require("../v3/errors.js");
15
16
  const session_lifecycle_js_1 = require("../v3/session-lifecycle.js");
16
17
  const AgentSession_js_1 = require("./AgentSession.js");
17
18
  const token_js_1 = require("./token.js");
18
- class UnsupportedSessionOperationError extends Error {
19
+ /** The operation is not available on a v3 Platform session. A {@link V3ValidationError}. */
20
+ class UnsupportedSessionOperationError extends errors_js_1.V3ValidationError {
19
21
  constructor(operation) {
20
22
  super(`${operation} is not supported by this session backend; start, stop, getInfo and update are available`);
21
23
  this.name = "UnsupportedSessionOperationError";
22
24
  }
23
25
  }
24
26
  exports.UnsupportedSessionOperationError = UnsupportedSessionOperationError;
27
+ (0, errors_js_1.registerV3ErrorClass)(UnsupportedSessionOperationError, "UnsupportedSessionOperationError");
25
28
  /** Validate mixed transports before replacing internal RTC placeholders. */
26
29
  function callSessionOptions(options) {
27
30
  for (const key of [
@@ -36,7 +39,7 @@ function callSessionOptions(options) {
36
39
  "expiresIn",
37
40
  ]) {
38
41
  if (options[key] !== undefined)
39
- throw new Error(`Phone calls do not accept RTC option ${key}`);
42
+ throw new errors_js_1.V3ValidationError(`Phone calls do not accept RTC option ${key}`);
40
43
  }
41
44
  return Object.assign(Object.assign({}, options), { channel: "", remoteUids: [] });
42
45
  }
@@ -44,7 +47,7 @@ function createStoredSession(client, options, source, config, telephony) {
44
47
  var _a, _b;
45
48
  for (const key of ["clientReference", "client_reference", "enableStringUid", "preset", "pipelineId"]) {
46
49
  if (key in options && options[key] !== undefined)
47
- throw new Error(`${key} is not supported by this session backend`);
50
+ throw new errors_js_1.V3ValidationError(`${key} is not supported by this session backend`);
48
51
  }
49
52
  const lifecycle = {};
50
53
  for (const [key, wire] of [
@@ -69,10 +72,10 @@ function createStoredSession(client, options, source, config, telephony) {
69
72
  (0, session_lifecycle_js_1.validateSessionStart)(payload);
70
73
  if (options.expiresIn !== undefined &&
71
74
  (!Number.isInteger(options.expiresIn) || !Number.isFinite(options.expiresIn)))
72
- throw new Error("expiresIn must be a whole number of seconds");
75
+ throw new errors_js_1.V3ValidationError("expiresIn must be a whole number of seconds");
73
76
  if (telephony &&
74
77
  [options.agentUid, options.token, options.encryption, options.audioScenario, options.geofence].some((value) => value !== undefined))
75
- throw new Error("RTC options are not supported for phone calls");
78
+ throw new errors_js_1.V3ValidationError("RTC options are not supported for phone calls");
76
79
  const expiry = options.expiresIn === undefined ? undefined : token_js_1.ExpiresIn.seconds(options.expiresIn);
77
80
  const signing = !telephony &&
78
81
  options.token === undefined &&
@@ -91,7 +94,7 @@ function createStoredSession(client, options, source, config, telephony) {
91
94
  start() {
92
95
  return __awaiter(this, void 0, void 0, function* () {
93
96
  if (payload.idempotencyKey && successfullyStarted)
94
- throw new Error("This idempotency key already started a session; create a new handle with a new key for another session");
97
+ throw new errors_js_1.V3ValidationError("This idempotency key already started a session; create a new handle with a new key for another session");
95
98
  if (successfullyStarted && !payload.idempotencyKey) {
96
99
  // A new unkeyed session needs a fresh token. Failed starts retain
97
100
  // their request snapshot, and keyed starts cannot be reused.
@@ -105,27 +108,23 @@ function createStoredSession(client, options, source, config, telephony) {
105
108
  (Number.isSafeInteger(Number(signing.uid)) && Number(signing.uid) <= 4294967295))) {
106
109
  // Larger numeric identities remain opaque; the service provisions
107
110
  // their token instead of coercing them through the local signer.
108
- payload.transport.token = /^\d+$/.test(signing.uid)
109
- ? (0, token_js_1.generateConvoAIToken)({
110
- appId: signing.appId,
111
- appCertificate: signing.appCertificate,
112
- channelName: signing.channel,
113
- uid: Number(signing.uid),
114
- tokenExpire: expiry,
115
- })
116
- : (0, token_js_1.generateRtcTokenWithAccount)({
117
- appId: signing.appId,
118
- appCertificate: signing.appCertificate,
119
- channel: signing.channel,
120
- account: signing.uid,
121
- expirySeconds: expiry,
122
- });
111
+ // String accounts get the same RTC + RTM + ConvoAI token as numeric
112
+ // UIDs: RTM is the session's only data channel.
113
+ payload.transport.token = (0, token_js_1.generateConvoAIToken)({
114
+ appId: signing.appId,
115
+ appCertificate: signing.appCertificate,
116
+ channelName: signing.channel,
117
+ uid: /^\d+$/.test(signing.uid) ? Number(signing.uid) : signing.uid,
118
+ tokenExpire: expiry,
119
+ });
123
120
  }
124
- const result = "agent_id" in payload
125
- ? yield client.v3.sessions.start(payload)
126
- : yield client.v3.sessions.startEphemeral(payload);
121
+ const { data: result, rawResponse } = yield ("agent_id" in payload
122
+ ? client.v3.sessions.start(payload)
123
+ : client.v3.sessions.startEphemeral(payload)).withRawResponse();
127
124
  if (typeof result.agent_session_id !== "string" || !result.agent_session_id.trim()) {
128
- throw new Error("Session start response is missing agent_session_id");
125
+ throw new errors_js_1.V3Error(rawResponse.status, result, rawResponse, {
126
+ message: "Session start response is missing agent_session_id",
127
+ });
129
128
  }
130
129
  successfullyStarted = true;
131
130
  return { id: result.agent_session_id, status: result.status === "STARTING" ? "starting" : "running" };
@@ -141,16 +140,16 @@ function createStoredSession(client, options, source, config, telephony) {
141
140
  var _a, _b, _c;
142
141
  const input = config;
143
142
  if (!input || typeof input !== "object" || Array.isArray(input))
144
- throw new Error("Invalid session update");
143
+ throw new errors_js_1.V3ValidationError("Invalid session update");
145
144
  for (const key of Object.keys(input))
146
145
  if (!["token", "messages", "llm"].includes(key))
147
- throw new Error(`Unsupported session update field: ${key}`);
146
+ throw new errors_js_1.V3ValidationError(`Unsupported session update field: ${key}`);
148
147
  if (input.messages !== undefined && ((_a = input.llm) === null || _a === void 0 ? void 0 : _a.system_messages) !== undefined)
149
- throw new Error("Provide messages or llm.system_messages, not both");
148
+ throw new errors_js_1.V3ValidationError("Provide messages or llm.system_messages, not both");
150
149
  const patch = {};
151
150
  if (input.token !== undefined) {
152
151
  if (typeof input.token !== "string" || !input.token)
153
- throw new Error("token must be a string");
152
+ throw new errors_js_1.V3ValidationError("token must be a string");
154
153
  patch.transport = { token: input.token };
155
154
  }
156
155
  const overrides = {};
@@ -161,7 +160,7 @@ function createStoredSession(client, options, source, config, telephony) {
161
160
  !["system", "user", "assistant"].includes(message.role) ||
162
161
  typeof message.content !== "string" ||
163
162
  Object.keys(message).some((key) => !["role", "content"].includes(key))))
164
- throw new Error("Invalid session messages");
163
+ throw new errors_js_1.V3ValidationError("Invalid session messages");
165
164
  overrides.messages = messages;
166
165
  }
167
166
  for (const kind of ["llm"])
@@ -171,12 +170,12 @@ function createStoredSession(client, options, source, config, telephony) {
171
170
  typeof module !== "object" ||
172
171
  Array.isArray(module) ||
173
172
  Object.keys(module).some((key) => !["params", ...(kind === "llm" ? ["system_messages"] : [])].includes(key)))
174
- throw new Error(`Invalid ${kind} update`);
173
+ throw new errors_js_1.V3ValidationError(`Invalid ${kind} update`);
175
174
  if (module.params !== undefined) {
176
175
  if (!module.params || typeof module.params !== "object" || Array.isArray(module.params))
177
- throw new Error("params must be an object");
176
+ throw new errors_js_1.V3ValidationError("params must be an object");
178
177
  if (Object.keys(module.params).some((key) => ["url", "base_url", "api_base_url", "endpoint"].includes(key.toLowerCase())))
179
- throw new Error("Runtime endpoint aliases are not mutable");
178
+ throw new errors_js_1.V3ValidationError("Runtime endpoint aliases are not mutable");
180
179
  overrides.pipeline = { [kind]: { params: module.params } };
181
180
  }
182
181
  }
@@ -3,10 +3,13 @@
3
3
  *
4
4
  * - RTC tokens authenticate a specific (appId, channel, uid) combination with
5
5
  * the Agora RTC network.
6
- * - ConvoAI tokens are combined RTC + RTM tokens used to authenticate ConvoAI
7
- * REST API calls via `Authorization: agora token=<token>`.
6
+ * - ConvoAI tokens are RTC + RTM + ConvoAI tokens used to authenticate
7
+ * ConvoAI REST API calls via `Authorization: agora token=<token>`. Keep them
8
+ * on the server.
9
+ * - Client tokens are RTC + RTM only, for front-end token routes. They join a
10
+ * channel and log in to RTM but cannot call the ConvoAI REST API.
8
11
  *
9
- * The `agora-token` library handles the JWT signing.
12
+ * The `agora-token` library handles the AccessToken2 signing.
10
13
  */
11
14
  export declare const MAX_EXPIRY_SECONDS = 86400;
12
15
  /**
@@ -74,23 +77,57 @@ export interface GenerateConvoAITokenOptions {
74
77
  appCertificate: string;
75
78
  /** The channel the agent will join — must match the channel used in the start request */
76
79
  channelName: string;
77
- /** Numeric ConvoAI participant UID. Use the RTC UID for a user, agent, or avatar. */
78
- uid: number;
80
+ /**
81
+ * ConvoAI participant UID: a numeric RTC UID or a string user account. Use the
82
+ * RTC UID for a user, agent, or avatar. Both forms are signed as the UID's
83
+ * string form, which is also the RTM user ID.
84
+ */
85
+ uid: number | string;
79
86
  /** Seconds until the token expires (default: 86400) */
80
87
  tokenExpire?: number;
81
88
  /**
82
- * Seconds until privileges expire. Defaults to the same value as `tokenExpire`.
89
+ * Seconds until RTC privileges expire. Defaults to `tokenExpire`.
90
+ * RTM login retains the token lifetime; ConvoAI carries no privilege map.
83
91
  * Per Agora docs, setting this to 0 would expire privileges immediately — the SDK
84
92
  * always substitutes `tokenExpire` when this is 0 or omitted.
85
93
  */
86
94
  privilegeExpire?: number;
87
95
  }
88
96
  /**
89
- * Builds a combined RTC + RTM token for ConvoAI REST API authentication.
97
+ * Builds a ConvoAI token carrying RTC, RTM, and ConvoAI services for REST API authentication.
90
98
  *
91
99
  * The resulting token is used as: `Authorization: agora token=<token>`
92
100
  *
93
- * Uses `buildTokenWithRtm` which bundles both RTC channel access and RTM
94
- * messaging privileges in a single AccessToken2 token.
101
+ * Uses `ConvoAITokenBuilder.buildTokenWithPrivilege`, which adds the ConvoAI service marker
102
+ * required by the ConvoAI REST API alongside RTC channel access and RTM login
103
+ * privileges in a single AccessToken2 token.
95
104
  */
96
105
  export declare function generateConvoAIToken(opts: GenerateConvoAITokenOptions): string;
106
+ export interface GenerateClientTokenOptions {
107
+ appId: string;
108
+ appCertificate: string;
109
+ /** The channel the client will join. */
110
+ channelName: string;
111
+ /**
112
+ * The client's RTC UID or string user account. It is also the RTM user ID, so
113
+ * it must be nonzero and nonempty.
114
+ */
115
+ uid: number | string;
116
+ /** Seconds until the token expires (default: 86400) */
117
+ tokenExpire?: number;
118
+ /**
119
+ * Seconds until RTC privileges expire. Defaults to `tokenExpire`. RTM login
120
+ * keeps the token lifetime.
121
+ */
122
+ privilegeExpire?: number;
123
+ }
124
+ /**
125
+ * Builds an RTC + RTM token for a front-end client. Use it in token routes that
126
+ * hand tokens to browsers or apps.
127
+ *
128
+ * The token joins the RTC channel as a publisher and logs in to RTM, the data
129
+ * channel for agent transcripts and state. It carries no ConvoAI service, so it
130
+ * cannot authenticate ConvoAI REST calls. Use {@link generateConvoAIToken} for
131
+ * server-side REST authentication and agent tokens instead.
132
+ */
133
+ export declare function generateClientToken(opts: GenerateClientTokenOptions): string;
@@ -4,10 +4,13 @@
4
4
  *
5
5
  * - RTC tokens authenticate a specific (appId, channel, uid) combination with
6
6
  * the Agora RTC network.
7
- * - ConvoAI tokens are combined RTC + RTM tokens used to authenticate ConvoAI
8
- * REST API calls via `Authorization: agora token=<token>`.
7
+ * - ConvoAI tokens are RTC + RTM + ConvoAI tokens used to authenticate
8
+ * ConvoAI REST API calls via `Authorization: agora token=<token>`. Keep them
9
+ * on the server.
10
+ * - Client tokens are RTC + RTM only, for front-end token routes. They join a
11
+ * channel and log in to RTM but cannot call the ConvoAI REST API.
9
12
  *
10
- * The `agora-token` library handles the JWT signing.
13
+ * The `agora-token` library handles the AccessToken2 signing.
11
14
  */
12
15
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
16
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -17,6 +20,7 @@ exports.ExpiresIn = exports.MAX_EXPIRY_SECONDS = void 0;
17
20
  exports.generateRtcToken = generateRtcToken;
18
21
  exports.generateRtcTokenWithAccount = generateRtcTokenWithAccount;
19
22
  exports.generateConvoAIToken = generateConvoAIToken;
23
+ exports.generateClientToken = generateClientToken;
20
24
  const agora_token_1 = __importDefault(require("agora-token"));
21
25
  const DEFAULT_EXPIRY_SECONDS = 86400;
22
26
  exports.MAX_EXPIRY_SECONDS = 86400;
@@ -137,12 +141,13 @@ function generateRtcTokenWithAccount(opts) {
137
141
  return _requireBuiltToken(agora_token_1.default.RtcTokenBuilder.buildTokenWithUserAccount(opts.appId, opts.appCertificate, opts.channel, opts.account, (_b = opts.role) !== null && _b !== void 0 ? _b : agora_token_1.default.RtcRole.PUBLISHER, expiry, expiry), opts.appId, opts.appCertificate);
138
142
  }
139
143
  /**
140
- * Builds a combined RTC + RTM token for ConvoAI REST API authentication.
144
+ * Builds a ConvoAI token carrying RTC, RTM, and ConvoAI services for REST API authentication.
141
145
  *
142
146
  * The resulting token is used as: `Authorization: agora token=<token>`
143
147
  *
144
- * Uses `buildTokenWithRtm` which bundles both RTC channel access and RTM
145
- * messaging privileges in a single AccessToken2 token.
148
+ * Uses `ConvoAITokenBuilder.buildTokenWithPrivilege`, which adds the ConvoAI service marker
149
+ * required by the ConvoAI REST API alongside RTC channel access and RTM login
150
+ * privileges in a single AccessToken2 token.
146
151
  */
147
152
  function generateConvoAIToken(opts) {
148
153
  var _a, _b;
@@ -152,11 +157,34 @@ function generateConvoAIToken(opts) {
152
157
  const configuredPrivilegeExpire = (_b = opts.privilegeExpire) !== null && _b !== void 0 ? _b : 0;
153
158
  const privilegeExpire = configuredPrivilegeExpire === 0 ? tokenExpire : configuredPrivilegeExpire;
154
159
  const account = _uidToAccount(opts.uid);
155
- return _requireBuiltToken(agora_token_1.default.RtcTokenBuilder.buildTokenWithRtm(opts.appId, opts.appCertificate, opts.channelName, account, agora_token_1.default.RtcRole.PUBLISHER, tokenExpire, privilegeExpire), opts.appId, opts.appCertificate);
160
+ return _requireBuiltToken(agora_token_1.default.ConvoAITokenBuilder.buildTokenWithPrivilege(opts.appId, opts.appCertificate, opts.channelName, account, agora_token_1.default.RtcRole.PUBLISHER, tokenExpire, privilegeExpire, privilegeExpire, privilegeExpire, privilegeExpire, account, tokenExpire), opts.appId, opts.appCertificate);
156
161
  }
157
162
  function _uidToAccount(uid) {
163
+ if (typeof uid === "string") {
164
+ return uid;
165
+ }
158
166
  if (!Number.isInteger(uid)) {
159
167
  throw new Error("uid must be an integer when provided as a number");
160
168
  }
161
169
  return String(uid);
162
170
  }
171
+ /**
172
+ * Builds an RTC + RTM token for a front-end client. Use it in token routes that
173
+ * hand tokens to browsers or apps.
174
+ *
175
+ * The token joins the RTC channel as a publisher and logs in to RTM, the data
176
+ * channel for agent transcripts and state. It carries no ConvoAI service, so it
177
+ * cannot authenticate ConvoAI REST calls. Use {@link generateConvoAIToken} for
178
+ * server-side REST authentication and agent tokens instead.
179
+ */
180
+ function generateClientToken(opts) {
181
+ var _a;
182
+ const account = _uidToAccount(opts.uid);
183
+ if (account === "" || /^0+$/.test(account)) {
184
+ throw new Error("uid must be nonzero and nonempty: it is also the RTM user ID");
185
+ }
186
+ const tokenExpire = (_a = opts.tokenExpire) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRY_SECONDS;
187
+ // Per Agora docs, privilegeExpire=0 means "expires immediately", which is invalid.
188
+ const privilegeExpire = opts.privilegeExpire || tokenExpire;
189
+ return _requireBuiltToken(agora_token_1.default.RtcTokenBuilder.buildTokenWithRtm(opts.appId, opts.appCertificate, opts.channelName, account, agora_token_1.default.RtcRole.PUBLISHER, tokenExpire, privilegeExpire), opts.appId, opts.appCertificate);
190
+ }
@@ -2,10 +2,9 @@
2
2
  * Clean type aliases for the Agora Conversational AI SDK.
3
3
  * These provide shorter, more intuitive names for the verbose Fern-generated types.
4
4
  */
5
- import type { AgentThinkAgentManagementResponse, AmazonTtsParams as AmazonTtsParamsType, AmazonTts as AmazonTtsType, Asr, AsrLanguage, CartesiaTtsParams as CartesiaTtsParamsType, CartesiaTts as CartesiaTtsType, ElevenLabsTtsParams as ElevenLabsTtsParamsType, ElevenLabsTts as ElevenLabsTtsType, FishAudioTtsParams as FishAudioTtsParamsType, FishAudioTts as FishAudioTtsType, GeminiAsrParams as GeminiAsrParamsType, GenericHttpTtsParams as GenericTtsParamsType, GenericHttpTts as GenericTtsType, GetAgentsResponse, GetHistoryAgentsResponse, GetTurnsAgentsResponse, GoogleTtsParams as GoogleTtsParamsType, GoogleTts as GoogleTtsType, GradiumTtsParams as GradiumTtsParamsType, GradiumTts as GradiumTtsType, HumeAiTtsParams as HumeAiTtsParamsType, HumeAiTts as HumeAiTtsType, ListAgentsResponse, Llm, LlmToolExecution as LlmToolExecutionType, LlmToolFunction as LlmToolFunctionType, LlmToolServer as LlmToolServerType, LlmTool as LlmToolType, McpServer as McpServerType, MicrosoftTtsParams as MicrosoftTtsParamsType, MicrosoftTts as MicrosoftTtsType, MinimaxTtsParams as MinimaxTtsParamsType, MinimaxTts as MinimaxTtsType, MistralTtsParams as MistralTtsParamsType, MistralTts as MistralTtsType, Mllm, MllmTurnDetection, MllmTurnDetection as MllmTurnDetectionNS, MurfTtsParams as MurfTtsParamsType, MurfTts as MurfTtsType, OpenAiTtsParams as OpenAiTtsParamsType, OpenAiTts as OpenAiTtsType, RimeTtsParams as RimeTtsParamsType, RimeTts as RimeTtsType, SarvamTtsParams as SarvamTtsParamsType, SarvamTts as SarvamTtsType, SmallestAiAsrParams as SmallestAiAsrParamsType, SmallestAiAsr as SmallestAiAsrType, SmallestAiTtsParams as SmallestAiTtsParamsType, SmallestAiTts as SmallestAiTtsType, SpatiusAvatarParams as SpatiusAvatarParamsType, SpeakAgentsRequest, StartAgentsRequest, Tts, TypecastTtsParams as TypecastTtsParamsType, TypecastTts as TypecastTtsType, UpdateAgentsRequest, XAiAsrParams as XAiAsrParamsType, XAiAsr as XAiAsrType, XAiTtsParams as XAiTtsParamsType, XAiTts as XAiTtsType } from "../api/index.js";
5
+ import type { AgentThinkAgentManagementResponse, AmazonTtsParams as AmazonTtsParamsType, AmazonTts as AmazonTtsType, Asr, AsrLanguage, CartesiaTtsParams as CartesiaTtsParamsType, CartesiaTts as CartesiaTtsType, ElevenLabsTtsParams as ElevenLabsTtsParamsType, ElevenLabsTts as ElevenLabsTtsType, FishAudioTtsParams as FishAudioTtsParamsType, FishAudioTts as FishAudioTtsType, GeminiAsrParams as GeminiAsrParamsType, GenericHttpTtsParams as GenericTtsParamsType, GenericHttpTts as GenericTtsType, GetAgentsResponse, GetHistoryAgentsResponse, GetTurnsAgentsResponse, GoogleTtsParams as GoogleTtsParamsType, GoogleTts as GoogleTtsType, GradiumTtsParams as GradiumTtsParamsType, GradiumTts as GradiumTtsType, HumeAiTtsParams as HumeAiTtsParamsType, HumeAiTts as HumeAiTtsType, ListAgentsResponse, Llm, LlmToolExecution as LlmToolExecutionType, LlmToolFunction as LlmToolFunctionType, LlmToolServer as LlmToolServerType, LlmTool as LlmToolType, McpServer as McpServerType, MicrosoftTtsParams as MicrosoftTtsParamsType, MicrosoftTts as MicrosoftTtsType, MinimaxTtsParams as MinimaxTtsParamsType, MinimaxTts as MinimaxTtsType, MistralTtsParams as MistralTtsParamsType, MistralTts as MistralTtsType, Mllm, MllmTurnDetection, MllmTurnDetection as MllmTurnDetectionNS, MurfTtsParams as MurfTtsParamsType, MurfTts as MurfTtsType, OpenAiTtsParams as OpenAiTtsParamsType, OpenAiTts as OpenAiTtsType, RimeTtsParams as RimeTtsParamsType, RimeTts as RimeTtsType, RtzrAsrParams as RtzrAsrParamsType, RtzrAsr as RtzrAsrType, SarvamTtsParams as SarvamTtsParamsType, SarvamTts as SarvamTtsType, SmallestAiAsrParams as SmallestAiAsrParamsType, SmallestAiAsr as SmallestAiAsrType, SmallestAiTtsParams as SmallestAiTtsParamsType, SmallestAiTts as SmallestAiTtsType, SpatiusAvatarParams as SpatiusAvatarParamsType, SpeakAgentsRequest, StartAgentsRequest, Tts, TypecastTtsParams as TypecastTtsParamsType, TypecastTts as TypecastTtsType, UpdateAgentsRequest, XAiAsrParams as XAiAsrParamsType, XAiAsr as XAiAsrType, XAiTtsParams as XAiTtsParamsType, XAiTts as XAiTtsType } from "../api/index.js";
6
6
  import type { AgentThinkAgentManagementRequest } from "../api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.js";
7
7
  import type { PresetInput } from "./presets.js";
8
- import type { GeminiTTSConfig } from "./preview/gemini-tts.js";
9
8
  /** LLM request style (openai, gemini, anthropic, dify) */
10
9
  export type LlmStyle = Llm.Style;
11
10
  /**
@@ -71,6 +70,10 @@ export type SttConfig = {
71
70
  vendor: "sarvam";
72
71
  language?: TurnDetectionLanguage;
73
72
  params: SarvamAsrParams;
73
+ } | {
74
+ vendor: "rtzr";
75
+ language?: TurnDetectionLanguage;
76
+ params: RtzrAsrParamsType;
74
77
  } | {
75
78
  vendor: "xai";
76
79
  language?: TurnDetectionLanguage;
@@ -85,7 +88,7 @@ export type AsrConfig = SttConfig;
85
88
  /** Wire ASR vendor identifier (e.g. `"deepgram"`, `"fengming"`). */
86
89
  export type AsrVendorName = string;
87
90
  /** TTS (Text-to-Speech) configuration - discriminated union */
88
- export type TtsConfig = Tts | GeminiTTSConfig;
91
+ export type TtsConfig = Tts;
89
92
  /** Inline synchronous REST tool exposed to a standard text LLM. */
90
93
  export type LlmTool = LlmToolType;
91
94
  export type LlmToolExecution = LlmToolExecutionType;
@@ -155,6 +158,8 @@ export type AdvancedFeatures = StartAgentsRequest.Properties.AdvancedFeatures;
155
158
  export type SessionParams = StartAgentsRequest.Properties.Parameters;
156
159
  /** RTC audio scenario for the session parameters object. */
157
160
  export type ParametersAudioScenario = StartAgentsRequest.Properties.Parameters.AudioScenario;
161
+ /** Speak request sentence-segmentation behavior. */
162
+ export type SpeakConfig = StartAgentsRequest.Properties.Parameters.Speak;
158
163
  /**
159
164
  * AgentKit session parameters input.
160
165
  * Allows providing `audio_scenario` through the AgentKit layer.
@@ -470,6 +475,8 @@ export interface SpeechmaticsParams {
470
475
  */
471
476
  export interface DeepgramParams {
472
477
  /** Deepgram API key */
478
+ api_key?: string;
479
+ /** @deprecated Use `api_key` instead. AgentKit normalizes this alias before sending. */
473
480
  key?: string;
474
481
  /** Model to use (e.g., 'nova-2', 'enhanced', 'base') */
475
482
  model?: string;
@@ -589,6 +596,8 @@ export type XAiAsr = XAiAsrType;
589
596
  export type XAiAsrParams = XAiAsrParamsType;
590
597
  export type SmallestAiAsr = SmallestAiAsrType;
591
598
  export type SmallestAiAsrParams = SmallestAiAsrParamsType;
599
+ export type RtzrAsr = RtzrAsrType;
600
+ export type RtzrAsrParams = RtzrAsrParamsType;
592
601
  /** Google Gemini STT parameters generated from the API schema. */
593
602
  export type GeminiAsrParams = GeminiAsrParamsType;
594
603
  export type MicrosoftTts = MicrosoftTtsType;
@@ -1,4 +1,5 @@
1
1
  import type { AgoraClient } from "../AgoraPoolClient.js";
2
+ import { V3ValidationError } from "../v3/errors.js";
2
3
  import type * as V3 from "../v3/types.js";
3
4
  import type { Agent, AgentOptions } from "./Agent.js";
4
5
  import type { AgentSession } from "./AgentSession.js";
@@ -7,14 +8,17 @@ export type SecretRef = string & {
7
8
  readonly __secretRef: unique symbol;
8
9
  };
9
10
  export declare function secretRef(set: string, key: string): SecretRef;
10
- export declare class SecretRefNotSupportedError extends Error {
11
+ /** A `secretRef()` value was used where only saved agents can resolve it. A {@link V3ValidationError}. */
12
+ export declare class SecretRefNotSupportedError extends V3ValidationError {
11
13
  constructor();
12
14
  }
13
- export declare class UnsupportedFieldError extends Error {
15
+ /** The configuration uses fields the v3 API does not accept. A {@link V3ValidationError}. */
16
+ export declare class UnsupportedFieldError extends V3ValidationError {
14
17
  readonly fields: string[];
15
18
  constructor(fields: string[]);
16
19
  }
17
- export declare class NumberNotFoundError extends Error {
20
+ /** A phone number given by E.164 value is not registered in the project. A {@link V3ValidationError}. */
21
+ export declare class NumberNotFoundError extends V3ValidationError {
18
22
  constructor(number: string, appid: string);
19
23
  }
20
24
  export declare function assertNoSecretRefs(value: unknown): void;
@@ -37,21 +37,23 @@ exports.redeployPatch = redeployPatch;
37
37
  exports.deployAgent = deployAgent;
38
38
  const index_js_1 = require("../core/domain/index.js");
39
39
  const contract_js_1 = require("../v3/contract.js");
40
- const transport_js_1 = require("../v3/transport.js");
40
+ const errors_js_1 = require("../v3/errors.js");
41
41
  const session_backend_js_1 = require("./session-backend.js");
42
42
  function secretRef(set, key) {
43
43
  if (![set, key].every((v) => /^[A-Za-z0-9_]{1,64}$/.test(v)))
44
- throw new Error("Secret names and keys must be 1–64 letters, digits or underscores");
44
+ throw new errors_js_1.V3ValidationError("Secret names and keys must be 1–64 letters, digits or underscores");
45
45
  return `$secrets.${set}.${key}`;
46
46
  }
47
- class SecretRefNotSupportedError extends Error {
47
+ /** A `secretRef()` value was used where only saved agents can resolve it. A {@link V3ValidationError}. */
48
+ class SecretRefNotSupportedError extends errors_js_1.V3ValidationError {
48
49
  constructor() {
49
50
  super("secretRef requires save()");
50
51
  this.name = "SecretRefNotSupportedError";
51
52
  }
52
53
  }
53
54
  exports.SecretRefNotSupportedError = SecretRefNotSupportedError;
54
- class UnsupportedFieldError extends Error {
55
+ /** The configuration uses fields the v3 API does not accept. A {@link V3ValidationError}. */
56
+ class UnsupportedFieldError extends errors_js_1.V3ValidationError {
55
57
  constructor(fields) {
56
58
  super(`Unsupported v3 fields: ${fields.join(", ")}`);
57
59
  this.fields = fields;
@@ -59,13 +61,17 @@ class UnsupportedFieldError extends Error {
59
61
  }
60
62
  }
61
63
  exports.UnsupportedFieldError = UnsupportedFieldError;
62
- class NumberNotFoundError extends Error {
64
+ /** A phone number given by E.164 value is not registered in the project. A {@link V3ValidationError}. */
65
+ class NumberNotFoundError extends errors_js_1.V3ValidationError {
63
66
  constructor(number, appid) {
64
67
  super(`Number ${number} not found in project ${appid}; create it first with client.v3.numbers.create()`);
65
68
  this.name = "NumberNotFoundError";
66
69
  }
67
70
  }
68
71
  exports.NumberNotFoundError = NumberNotFoundError;
72
+ (0, errors_js_1.registerV3ErrorClass)(SecretRefNotSupportedError, "SecretRefNotSupportedError");
73
+ (0, errors_js_1.registerV3ErrorClass)(UnsupportedFieldError, "UnsupportedFieldError");
74
+ (0, errors_js_1.registerV3ErrorClass)(NumberNotFoundError, "NumberNotFoundError");
69
75
  function assertNoSecretRefs(value) {
70
76
  if (typeof value === "string" && value.startsWith("$secrets."))
71
77
  throw new SecretRefNotSupportedError();
@@ -76,15 +82,15 @@ function assertNoSecretRefs(value) {
76
82
  function validateVariable(name, def) {
77
83
  var _a;
78
84
  if (!/^[a-z][a-z0-9_]{0,63}$/.test(name))
79
- throw new Error("Invalid v3 variable name");
85
+ throw new errors_js_1.V3ValidationError("Invalid v3 variable name");
80
86
  if (!["str", "int", "float", "bool", "date", "datetime"].includes(def.type))
81
- throw new Error("Invalid v3 variable type");
87
+ throw new errors_js_1.V3ValidationError("Invalid v3 variable type");
82
88
  if (def.options && new Set(def.options.map((value) => JSON.stringify(value))).size !== def.options.length)
83
- throw new Error("Variable options must be unique");
89
+ throw new errors_js_1.V3ValidationError("Variable options must be unique");
84
90
  if (def.extract && !((_a = def.description) === null || _a === void 0 ? void 0 : _a.trim()))
85
- throw new Error("Extracted variables require a description");
91
+ throw new errors_js_1.V3ValidationError("Extracted variables require a description");
86
92
  if (validateContract(def, contract_js_1.contract.AgentRequest_VariableDefinition, `variables.${name}`).length)
87
- throw new Error("Invalid v3 variable definition");
93
+ throw new errors_js_1.V3ValidationError("Invalid v3 variable definition");
88
94
  }
89
95
  const clean = (value) => Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
90
96
  function leftovers(value, allowed, path, errors) {
@@ -102,7 +108,7 @@ const moved = [
102
108
  "turn_detection",
103
109
  ];
104
110
  function toV3Module(config, kind, errors = []) {
105
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
111
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
106
112
  const c = Object.assign({}, config), params = Object.assign({}, c.params);
107
113
  const path = `pipeline.${kind}`;
108
114
  if (kind === "avatar" && c.vendor === "heygen")
@@ -113,20 +119,26 @@ function toV3Module(config, kind, errors = []) {
113
119
  }
114
120
  if (kind === "asr") {
115
121
  (_a = c.language) !== null && _a !== void 0 ? _a : (c.language = (_b = params.language) !== null && _b !== void 0 ? _b : (c.vendor === "ares" ? "en-US" : undefined));
116
- delete params.language;
122
+ if (["assemblyai", "google", "microsoft", "sarvam", "speechmatics"].includes(c.vendor)) {
123
+ // These providers require their own language in addition to the interaction language.
124
+ (_c = params.language) !== null && _c !== void 0 ? _c : (params.language = c.language);
125
+ }
126
+ else {
127
+ delete params.language;
128
+ }
117
129
  }
118
130
  if (kind === "llm" && (c.vendor === "gemini" || c.style === "gemini") && c.url) {
119
131
  // Legacy Gemini uses a query key; Platform credentials must never live in URLs.
120
132
  const url = new URL(c.url);
121
133
  const key = url.searchParams.get("key");
122
134
  if (key !== null) {
123
- (_c = c.api_key) !== null && _c !== void 0 ? _c : (c.api_key = key);
135
+ (_d = c.api_key) !== null && _d !== void 0 ? _d : (c.api_key = key);
124
136
  url.searchParams.delete("key");
125
137
  c.url = url.toString();
126
138
  }
127
139
  }
128
140
  if (kind === "llm" && c.style === "bedrock") {
129
- (_d = c.vendor) !== null && _d !== void 0 ? _d : (c.vendor = "amazon");
141
+ (_e = c.vendor) !== null && _e !== void 0 ? _e : (c.vendor = "amazon");
130
142
  for (const key of ["access_key", "secret_key", "region"]) {
131
143
  if (c[key] !== undefined) {
132
144
  if (params[key] !== undefined && params[key] !== c[key])
@@ -223,7 +235,7 @@ function toV3Module(config, kind, errors = []) {
223
235
  : undefined;
224
236
  const url = kind === "avatar"
225
237
  ? undefined
226
- : ((_h = (_g = (_f = (_e = c.url) !== null && _e !== void 0 ? _e : (endpointAlias ? params[endpointAlias] : undefined)) !== null && _f !== void 0 ? _f : params.url) !== null && _g !== void 0 ? _g : params.base_url) !== null && _h !== void 0 ? _h : params.api_base_url);
238
+ : ((_j = (_h = (_g = (_f = c.url) !== null && _f !== void 0 ? _f : (endpointAlias ? params[endpointAlias] : undefined)) !== null && _g !== void 0 ? _g : params.url) !== null && _h !== void 0 ? _h : params.base_url) !== null && _j !== void 0 ? _j : params.api_base_url);
227
239
  if (kind !== "avatar") {
228
240
  delete params.url;
229
241
  delete params.base_url;
@@ -235,7 +247,7 @@ function toV3Module(config, kind, errors = []) {
235
247
  if (url !== undefined)
236
248
  result.url = url;
237
249
  if ((kind === "llm" || kind === "asr") && params.model !== undefined) {
238
- result.model = (_j = c.model) !== null && _j !== void 0 ? _j : params.model;
250
+ result.model = (_k = c.model) !== null && _k !== void 0 ? _k : params.model;
239
251
  delete params.model;
240
252
  }
241
253
  if (kind === "tts" && c._minimaxPresetModel !== undefined)
@@ -243,7 +255,7 @@ function toV3Module(config, kind, errors = []) {
243
255
  if (kind === "avatar") {
244
256
  if (!["akool", "liveavatar", "anam", "generic", "sensetime", "spatius"].includes(c.vendor))
245
257
  errors.push(`${path}.vendor`);
246
- result.enabled = (_k = c.enable) !== null && _k !== void 0 ? _k : true;
258
+ result.enabled = (_l = c.enable) !== null && _l !== void 0 ? _l : true;
247
259
  }
248
260
  else if (c.enable === false)
249
261
  errors.push(`${path}.enable`);
@@ -543,7 +555,9 @@ function redeployPatch(previous, desired) {
543
555
  function etag(response) {
544
556
  const tag = response.rawResponse.headers.get("ETag");
545
557
  if (!tag)
546
- throw new Error("v3 response is missing ETag");
558
+ throw new errors_js_1.V3Error(response.rawResponse.status, response.data, response.rawResponse, {
559
+ message: "v3 response is missing ETag",
560
+ });
547
561
  return tag;
548
562
  }
549
563
  function deployAgent(client, body, options) {
@@ -556,7 +570,7 @@ function deployAgent(client, body, options) {
556
570
  if (object(module) && "credential" in module && ((_b = module.credential) === null || _b === void 0 ? void 0 : _b.mode) === "byok") {
557
571
  for (const value of Object.values((_c = module.credential.fields) !== null && _c !== void 0 ? _c : {}))
558
572
  if (typeof value !== "string" || !/^\$secrets\.[A-Za-z0-9_]{1,64}\.[A-Za-z0-9_]{1,64}$/.test(value))
559
- throw new Error(`Saved ${kind} credentials require secretRef(); use an ephemeral session for inline credentials`);
573
+ throw new errors_js_1.V3ValidationError(`Saved ${kind} credentials require secretRef(); use an ephemeral session for inline credentials`);
560
574
  }
561
575
  }
562
576
  const agentId = options.agentId;
@@ -602,7 +616,7 @@ class SavedAgent {
602
616
  update(config, options = {}) {
603
617
  var _a;
604
618
  if (config.config.client !== this.client) {
605
- throw new Error("SavedAgent.update requires a configuration bound to the same client");
619
+ throw new errors_js_1.V3ValidationError("SavedAgent.update requires a configuration bound to the same client");
606
620
  }
607
621
  return config.save({ agentId: this.id, name: (_a = options.name) !== null && _a !== void 0 ? _a : this.name });
608
622
  }
@@ -689,7 +703,7 @@ class SavedAgent {
689
703
  });
690
704
  }
691
705
  catch (error) {
692
- if (!(error instanceof transport_js_1.PreconditionFailedError) || attempt >= 1)
706
+ if (!(error instanceof errors_js_1.PreconditionFailedError) || attempt >= 1)
693
707
  throw error;
694
708
  }
695
709
  }
@@ -153,6 +153,12 @@ export interface AnamAvatarOptions {
153
153
  apiKey: string;
154
154
  /** Anam avatar ID */
155
155
  avatarId?: string;
156
+ /** Anam avatar model, such as `cara_mk4` for Cara 4 portrait mode */
157
+ avatarModel?: string;
158
+ /** Output video width in pixels. Set together with `videoHeight`. */
159
+ videoWidth?: number;
160
+ /** Output video height in pixels. Set together with `videoWidth`. */
161
+ videoHeight?: number;
156
162
  /** Enable avatar (default: true) */
157
163
  enable?: boolean;
158
164
  /** Additional vendor-specific parameters */