agora-agents 2.1.0 → 2.1.1

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.
@@ -69,14 +69,19 @@ class AgoraClient extends Client_js_1.AgoraClient {
69
69
  let authMode;
70
70
  let username;
71
71
  let password;
72
+ let authToken = "";
72
73
  const opts = options;
73
- if (opts.customerId != null) {
74
+ if (opts.customerId != null && opts.customerSecret != null) {
74
75
  authMode = "basic";
75
76
  username = opts.customerId;
76
77
  password = opts.customerSecret;
77
78
  }
79
+ else if (opts.customerId != null) {
80
+ throw new Error("customerSecret is required when customerId is provided");
81
+ }
78
82
  else if (opts.authToken != null) {
79
83
  authMode = "token";
84
+ authToken = opts.authToken;
80
85
  username = "";
81
86
  password = "";
82
87
  }
@@ -91,7 +96,7 @@ class AgoraClient extends Client_js_1.AgoraClient {
91
96
  const authorization = authMode === "basic"
92
97
  ? `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`
93
98
  : authMode === "token"
94
- ? `agora token=${opts.authToken}`
99
+ ? `agora token=${authToken}`
95
100
  : "";
96
101
  super(Object.assign(Object.assign({}, rest), { username,
97
102
  password,
@@ -41,8 +41,8 @@ function normalizeClientOptions(options) {
41
41
  const headers = (0, headers_js_1.mergeHeaders)({
42
42
  "X-Fern-Language": "JavaScript",
43
43
  "X-Fern-SDK-Name": "agora-agents",
44
- "X-Fern-SDK-Version": "v2.1.0",
45
- "User-Agent": "agora-agents/v2.1.0",
44
+ "X-Fern-SDK-Version": "v2.1.1",
45
+ "User-Agent": "agora-agents/v2.1.1",
46
46
  "X-Fern-Runtime": core.RUNTIME.type,
47
47
  "X-Fern-Runtime-Version": core.RUNTIME.version,
48
48
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -12,20 +12,28 @@ class AgoraClient {
12
12
  this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
13
13
  }
14
14
  get agents() {
15
- var _a;
16
- return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Client_js_2.AgentsClient(this._options)));
15
+ if (this._agents == null) {
16
+ this._agents = new Client_js_2.AgentsClient(this._options);
17
+ }
18
+ return this._agents;
17
19
  }
18
20
  get agentManagement() {
19
- var _a;
20
- return ((_a = this._agentManagement) !== null && _a !== void 0 ? _a : (this._agentManagement = new Client_js_1.AgentManagementClient(this._options)));
21
+ if (this._agentManagement == null) {
22
+ this._agentManagement = new Client_js_1.AgentManagementClient(this._options);
23
+ }
24
+ return this._agentManagement;
21
25
  }
22
26
  get telephony() {
23
- var _a;
24
- return ((_a = this._telephony) !== null && _a !== void 0 ? _a : (this._telephony = new Client_js_4.TelephonyClient(this._options)));
27
+ if (this._telephony == null) {
28
+ this._telephony = new Client_js_4.TelephonyClient(this._options);
29
+ }
30
+ return this._telephony;
25
31
  }
26
32
  get phoneNumbers() {
27
- var _a;
28
- return ((_a = this._phoneNumbers) !== null && _a !== void 0 ? _a : (this._phoneNumbers = new Client_js_3.PhoneNumbersClient(this._options)));
33
+ if (this._phoneNumbers == null) {
34
+ this._phoneNumbers = new Client_js_3.PhoneNumbersClient(this._options);
35
+ }
36
+ return this._phoneNumbers;
29
37
  }
30
38
  }
31
39
  exports.AgoraClient = AgoraClient;
@@ -426,10 +426,15 @@ export declare class Agent<TTSSampleRate extends number = number> {
426
426
  idleTimeout?: number;
427
427
  enableStringUid?: boolean;
428
428
  /**
429
- * Skip the LLM and TTS required-field guards. Set this when `preset` or
430
- * `pipeline_id` is in use — those fields supply the vendor config server-side.
429
+ * @deprecated Use `skipVendorValidationCategories` and
430
+ * `allowMissingVendorCategories` instead. This broad escape hatch will be
431
+ * removed in a future release.
431
432
  */
432
433
  skipVendorValidation?: boolean;
434
+ /** Skip generated request-shape validation for the listed provider categories. */
435
+ skipVendorValidationCategories?: ReadonlySet<"asr" | "llm" | "tts">;
436
+ /** Allow the listed provider categories to be omitted from properties. */
437
+ allowMissingVendorCategories?: ReadonlySet<"asr" | "llm" | "tts">;
433
438
  } & ({
434
439
  token: string;
435
440
  appId?: undefined;
@@ -581,7 +581,7 @@ class Agent {
581
581
  * and RTM privileges (required for RTM-enabled sessions).
582
582
  */
583
583
  toProperties(opts) {
584
- var _a, _b, _c, _d, _e, _f, _g;
584
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
585
585
  // In MLLM mode the backend handles audio end-to-end; LLM, TTS, and ASR
586
586
  // are not required.
587
587
  const isMllmMode = ((_a = this._mllm) === null || _a === void 0 ? void 0 : _a.enable) === true || this._mllm !== undefined;
@@ -649,21 +649,35 @@ class Agent {
649
649
  }
650
650
  return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
651
651
  }
652
- if (!opts.skipVendorValidation) {
653
- if (!this._tts) {
654
- throw new Error("TTS configuration is required. Use withTts() to set it.");
655
- }
656
- if (!this._llm) {
657
- throw new Error("LLM configuration is required. Use withLlm() to set it.");
652
+ const skipCategories = new Set((_d = opts.skipVendorValidationCategories) !== null && _d !== void 0 ? _d : []);
653
+ const allowMissingCategories = new Set((_e = opts.allowMissingVendorCategories) !== null && _e !== void 0 ? _e : []);
654
+ if (opts.skipVendorValidation) {
655
+ for (const category of ["asr", "llm", "tts"]) {
656
+ skipCategories.add(category);
657
+ allowMissingCategories.add(category);
658
658
  }
659
659
  }
660
+ const skipLlmValidation = skipCategories.has("llm");
661
+ const skipTtsValidation = skipCategories.has("tts");
662
+ const allowMissingAsr = allowMissingCategories.has("asr");
663
+ const allowMissingLlm = allowMissingCategories.has("llm");
664
+ const allowMissingTts = allowMissingCategories.has("tts");
665
+ if (!this._tts && !(skipTtsValidation || allowMissingTts)) {
666
+ throw new Error("TTS configuration is required. Use withTts() to set it.");
667
+ }
668
+ if (!this._llm && !(skipLlmValidation || allowMissingLlm)) {
669
+ throw new Error("LLM configuration is required. Use withLlm() to set it.");
670
+ }
660
671
  const llmConfig = this._llm
661
672
  ? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
662
673
  ? [{ role: "system", content: this._instructions }]
663
- : this._llm.system_messages, greeting_message: (_d = this._greeting) !== null && _d !== void 0 ? _d : this._llm.greeting_message, greeting_configs: (_e = this._greetingConfigs) !== null && _e !== void 0 ? _e : this._llm.greeting_configs, failure_message: (_f = this._failureMessage) !== null && _f !== void 0 ? _f : this._llm.failure_message, max_history: (_g = this._maxHistory) !== null && _g !== void 0 ? _g : this._llm.max_history }) : undefined;
664
- const asrConfig = this._resolveAsrConfig();
674
+ : this._llm.system_messages, greeting_message: (_f = this._greeting) !== null && _f !== void 0 ? _f : this._llm.greeting_message, greeting_configs: (_g = this._greetingConfigs) !== null && _g !== void 0 ? _g : this._llm.greeting_configs, failure_message: (_h = this._failureMessage) !== null && _h !== void 0 ? _h : this._llm.failure_message, max_history: (_j = this._maxHistory) !== null && _j !== void 0 ? _j : this._llm.max_history }) : undefined;
675
+ const asrConfig = this._stt !== undefined || !allowMissingAsr
676
+ ? this._resolveAsrConfig()
677
+ : undefined;
665
678
  const turnDetectionConfig = this._resolveTurnDetectionConfig();
666
- return Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig, llm: llmConfig, tts: this._tts, asr: asrConfig });
679
+ const ttsConfig = this._tts;
680
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig }), (llmConfig && { llm: llmConfig })), (ttsConfig && { tts: ttsConfig })), (asrConfig && { asr: asrConfig }));
667
681
  }
668
682
  /**
669
683
  * Creates a shallow copy of this Agent, preserving the TTSSampleRate type
@@ -188,6 +188,7 @@ export declare class AgentSession {
188
188
  */
189
189
  private _enrichAvatarParams;
190
190
  private _validateEnrichedAvatarConfig;
191
+ private _vendorValidationCategories;
191
192
  /**
192
193
  * Start the agent session.
193
194
  *
@@ -295,6 +295,35 @@ class AgentSession {
295
295
  "Pass agoraToken on the avatar vendor or provide appCertificate for automatic token generation.");
296
296
  }
297
297
  }
298
+ _vendorValidationCategories(pipelineId) {
299
+ const skipVendorValidationCategories = new Set();
300
+ const allowMissingVendorCategories = new Set();
301
+ if (pipelineId) {
302
+ allowMissingVendorCategories.add("asr");
303
+ allowMissingVendorCategories.add("llm");
304
+ allowMissingVendorCategories.add("tts");
305
+ }
306
+ const normalizedPreset = (0, presets_js_1.normalizePresetInput)(this._preset);
307
+ if (normalizedPreset) {
308
+ for (const item of normalizedPreset.split(",")) {
309
+ const category = (0, presets_js_1.getPresetCategory)(item);
310
+ if (category) {
311
+ skipVendorValidationCategories.add(category);
312
+ allowMissingVendorCategories.add(category);
313
+ }
314
+ }
315
+ }
316
+ if ((0, presets_js_1.inferAsrPreset)(this._agent.stt)) {
317
+ skipVendorValidationCategories.add("asr");
318
+ }
319
+ if ((0, presets_js_1.inferLlmPreset)(this._agent.llm)) {
320
+ skipVendorValidationCategories.add("llm");
321
+ }
322
+ if ((0, presets_js_1.inferTtsPreset)(this._agent.tts)) {
323
+ skipVendorValidationCategories.add("tts");
324
+ }
325
+ return { skipVendorValidationCategories, allowMissingVendorCategories };
326
+ }
298
327
  /**
299
328
  * Start the agent session.
300
329
  *
@@ -331,10 +360,9 @@ class AgentSession {
331
360
  appCertificate: this._appCertificate,
332
361
  expiresIn,
333
362
  };
334
- const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid,
335
- // When a preset or pipeline_id is supplied, ASR/LLM/TTS vendor
336
- // config is optional — the backend fills it from the preset/pipeline.
337
- skipVendorValidation: !!(this._preset || pipelineId) }, tokenOpts));
363
+ const { skipVendorValidationCategories, allowMissingVendorCategories } = this._vendorValidationCategories(pipelineId);
364
+ const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid, skipVendorValidationCategories,
365
+ allowMissingVendorCategories }, tokenOpts));
338
366
  const resolved = (0, presets_js_1.resolveSessionPresets)({
339
367
  preset: this._preset,
340
368
  properties,
@@ -29,6 +29,35 @@ export type DeepgramPresetModel = (typeof DeepgramPresetModels)[number];
29
29
  export type OpenAIPresetModel = (typeof OpenAIPresetModels)[number];
30
30
  export type OpenAITtsPresetModel = (typeof OpenAITtsPresetModels)[number];
31
31
  export type MiniMaxPresetModel = (typeof MiniMaxPresetModels)[number];
32
+ export type PresetCategory = "asr" | "llm" | "tts";
33
+ type AsrInference = {
34
+ category: "asr";
35
+ preset: AsrPreset;
36
+ stripModel: boolean;
37
+ };
38
+ type LlmInference = {
39
+ category: "llm";
40
+ preset: LlmPreset;
41
+ stripModel: boolean;
42
+ stripDefaultUrl: boolean;
43
+ };
44
+ type OpenAITtsInference = {
45
+ category: "tts";
46
+ preset: typeof AgentPresets.tts.openaiTts1;
47
+ vendor: "openai";
48
+ stripModel: boolean;
49
+ };
50
+ type MiniMaxTtsInference = {
51
+ category: "tts";
52
+ preset: TtsPreset;
53
+ vendor: "minimax";
54
+ stripModel: boolean;
55
+ };
56
+ type TtsInference = OpenAITtsInference | MiniMaxTtsInference;
57
+ export declare function getPresetCategory(preset: string): PresetCategory | undefined;
58
+ export declare function inferAsrPreset(asr?: Agora.Asr): AsrInference | undefined;
59
+ export declare function inferLlmPreset(llm?: Agora.Llm): LlmInference | undefined;
60
+ export declare function inferTtsPreset(tts?: Agora.Tts): TtsInference | undefined;
32
61
  export declare function normalizePresetInput(preset?: PresetInput | readonly string[]): string | undefined;
33
62
  export declare function resolveSessionPresets(args: {
34
63
  preset?: PresetInput;
@@ -37,3 +66,4 @@ export declare function resolveSessionPresets(args: {
37
66
  preset?: string;
38
67
  properties: Agora.StartAgentsRequest.Properties;
39
68
  };
69
+ export {};
@@ -12,6 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.MiniMaxPresetModels = exports.OpenAITtsPresetModels = exports.OpenAIPresetModels = exports.DeepgramPresetModels = exports.AgentPresets = void 0;
15
+ exports.getPresetCategory = getPresetCategory;
16
+ exports.inferAsrPreset = inferAsrPreset;
17
+ exports.inferLlmPreset = inferLlmPreset;
18
+ exports.inferTtsPreset = inferTtsPreset;
15
19
  exports.normalizePresetInput = normalizePresetInput;
16
20
  exports.resolveSessionPresets = resolveSessionPresets;
17
21
  exports.AgentPresets = {
@@ -58,7 +62,10 @@ const minimaxModelToPreset = {
58
62
  speech_2_8_turbo: exports.AgentPresets.tts.minimaxSpeech28Turbo,
59
63
  };
60
64
  function normalizeModelName(value) {
61
- return typeof value === "string" ? value.trim().toLowerCase() : undefined;
65
+ if (typeof value !== "string")
66
+ return undefined;
67
+ const normalized = value.trim().toLowerCase();
68
+ return normalized.length > 0 ? normalized : undefined;
62
69
  }
63
70
  function getPresetCategory(preset) {
64
71
  if (Object.values(exports.AgentPresets.asr).includes(preset))
@@ -171,7 +178,7 @@ function stripInferredPresetFields(properties, inferred) {
171
178
  tts = Object.assign(Object.assign({}, tts), { params: omitUndefinedKeys(Object.assign(Object.assign({}, tts.params), { key: undefined, group_id: undefined, url: undefined, model: ttsInference.stripModel ? undefined : (_d = tts.params) === null || _d === void 0 ? void 0 : _d.model })) });
172
179
  }
173
180
  }
174
- return Object.assign(Object.assign({}, properties), { asr, llm, tts });
181
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, properties), (asr && { asr })), (llm && { llm })), (tts && { tts }));
175
182
  }
176
183
  function normalizePresetInput(preset) {
177
184
  const entries = parsePresetInput(preset);
@@ -4,7 +4,11 @@ exports.base64Encode = base64Encode;
4
4
  exports.base64Decode = base64Decode;
5
5
  function base64ToBytes(base64) {
6
6
  const binString = atob(base64);
7
- return Uint8Array.from(binString, (m) => m.codePointAt(0));
7
+ const bytes = new Uint8Array(binString.length);
8
+ for (let i = 0; i < binString.length; i++) {
9
+ bytes[i] = binString.charCodeAt(i);
10
+ }
11
+ return bytes;
8
12
  }
9
13
  function bytesToBase64(bytes) {
10
14
  const binString = String.fromCodePoint(...bytes);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "v2.1.0";
1
+ export declare const SDK_VERSION = "v2.1.1";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "v2.1.0";
4
+ exports.SDK_VERSION = "v2.1.1";
@@ -66,14 +66,19 @@ export class AgoraClient extends BaseAgoraClient {
66
66
  let authMode;
67
67
  let username;
68
68
  let password;
69
+ let authToken = "";
69
70
  const opts = options;
70
- if (opts.customerId != null) {
71
+ if (opts.customerId != null && opts.customerSecret != null) {
71
72
  authMode = "basic";
72
73
  username = opts.customerId;
73
74
  password = opts.customerSecret;
74
75
  }
76
+ else if (opts.customerId != null) {
77
+ throw new Error("customerSecret is required when customerId is provided");
78
+ }
75
79
  else if (opts.authToken != null) {
76
80
  authMode = "token";
81
+ authToken = opts.authToken;
77
82
  username = "";
78
83
  password = "";
79
84
  }
@@ -88,7 +93,7 @@ export class AgoraClient extends BaseAgoraClient {
88
93
  const authorization = authMode === "basic"
89
94
  ? `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`
90
95
  : authMode === "token"
91
- ? `agora token=${opts.authToken}`
96
+ ? `agora token=${authToken}`
92
97
  : "";
93
98
  super(Object.assign(Object.assign({}, rest), { username,
94
99
  password,
@@ -5,8 +5,8 @@ export function normalizeClientOptions(options) {
5
5
  const headers = mergeHeaders({
6
6
  "X-Fern-Language": "JavaScript",
7
7
  "X-Fern-SDK-Name": "agora-agents",
8
- "X-Fern-SDK-Version": "v2.1.0",
9
- "User-Agent": "agora-agents/v2.1.0",
8
+ "X-Fern-SDK-Version": "v2.1.1",
9
+ "User-Agent": "agora-agents/v2.1.1",
10
10
  "X-Fern-Runtime": core.RUNTIME.type,
11
11
  "X-Fern-Runtime-Version": core.RUNTIME.version,
12
12
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -9,19 +9,27 @@ export class AgoraClient {
9
9
  this._options = normalizeClientOptions(options);
10
10
  }
11
11
  get agents() {
12
- var _a;
13
- return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new AgentsClient(this._options)));
12
+ if (this._agents == null) {
13
+ this._agents = new AgentsClient(this._options);
14
+ }
15
+ return this._agents;
14
16
  }
15
17
  get agentManagement() {
16
- var _a;
17
- return ((_a = this._agentManagement) !== null && _a !== void 0 ? _a : (this._agentManagement = new AgentManagementClient(this._options)));
18
+ if (this._agentManagement == null) {
19
+ this._agentManagement = new AgentManagementClient(this._options);
20
+ }
21
+ return this._agentManagement;
18
22
  }
19
23
  get telephony() {
20
- var _a;
21
- return ((_a = this._telephony) !== null && _a !== void 0 ? _a : (this._telephony = new TelephonyClient(this._options)));
24
+ if (this._telephony == null) {
25
+ this._telephony = new TelephonyClient(this._options);
26
+ }
27
+ return this._telephony;
22
28
  }
23
29
  get phoneNumbers() {
24
- var _a;
25
- return ((_a = this._phoneNumbers) !== null && _a !== void 0 ? _a : (this._phoneNumbers = new PhoneNumbersClient(this._options)));
30
+ if (this._phoneNumbers == null) {
31
+ this._phoneNumbers = new PhoneNumbersClient(this._options);
32
+ }
33
+ return this._phoneNumbers;
26
34
  }
27
35
  }
@@ -426,10 +426,15 @@ export declare class Agent<TTSSampleRate extends number = number> {
426
426
  idleTimeout?: number;
427
427
  enableStringUid?: boolean;
428
428
  /**
429
- * Skip the LLM and TTS required-field guards. Set this when `preset` or
430
- * `pipeline_id` is in use — those fields supply the vendor config server-side.
429
+ * @deprecated Use `skipVendorValidationCategories` and
430
+ * `allowMissingVendorCategories` instead. This broad escape hatch will be
431
+ * removed in a future release.
431
432
  */
432
433
  skipVendorValidation?: boolean;
434
+ /** Skip generated request-shape validation for the listed provider categories. */
435
+ skipVendorValidationCategories?: ReadonlySet<"asr" | "llm" | "tts">;
436
+ /** Allow the listed provider categories to be omitted from properties. */
437
+ allowMissingVendorCategories?: ReadonlySet<"asr" | "llm" | "tts">;
433
438
  } & ({
434
439
  token: string;
435
440
  appId?: undefined;
@@ -578,7 +578,7 @@ export class Agent {
578
578
  * and RTM privileges (required for RTM-enabled sessions).
579
579
  */
580
580
  toProperties(opts) {
581
- var _a, _b, _c, _d, _e, _f, _g;
581
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
582
582
  // In MLLM mode the backend handles audio end-to-end; LLM, TTS, and ASR
583
583
  // are not required.
584
584
  const isMllmMode = ((_a = this._mllm) === null || _a === void 0 ? void 0 : _a.enable) === true || this._mllm !== undefined;
@@ -646,21 +646,35 @@ export class Agent {
646
646
  }
647
647
  return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
648
648
  }
649
- if (!opts.skipVendorValidation) {
650
- if (!this._tts) {
651
- throw new Error("TTS configuration is required. Use withTts() to set it.");
652
- }
653
- if (!this._llm) {
654
- throw new Error("LLM configuration is required. Use withLlm() to set it.");
649
+ const skipCategories = new Set((_d = opts.skipVendorValidationCategories) !== null && _d !== void 0 ? _d : []);
650
+ const allowMissingCategories = new Set((_e = opts.allowMissingVendorCategories) !== null && _e !== void 0 ? _e : []);
651
+ if (opts.skipVendorValidation) {
652
+ for (const category of ["asr", "llm", "tts"]) {
653
+ skipCategories.add(category);
654
+ allowMissingCategories.add(category);
655
655
  }
656
656
  }
657
+ const skipLlmValidation = skipCategories.has("llm");
658
+ const skipTtsValidation = skipCategories.has("tts");
659
+ const allowMissingAsr = allowMissingCategories.has("asr");
660
+ const allowMissingLlm = allowMissingCategories.has("llm");
661
+ const allowMissingTts = allowMissingCategories.has("tts");
662
+ if (!this._tts && !(skipTtsValidation || allowMissingTts)) {
663
+ throw new Error("TTS configuration is required. Use withTts() to set it.");
664
+ }
665
+ if (!this._llm && !(skipLlmValidation || allowMissingLlm)) {
666
+ throw new Error("LLM configuration is required. Use withLlm() to set it.");
667
+ }
657
668
  const llmConfig = this._llm
658
669
  ? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
659
670
  ? [{ role: "system", content: this._instructions }]
660
- : this._llm.system_messages, greeting_message: (_d = this._greeting) !== null && _d !== void 0 ? _d : this._llm.greeting_message, greeting_configs: (_e = this._greetingConfigs) !== null && _e !== void 0 ? _e : this._llm.greeting_configs, failure_message: (_f = this._failureMessage) !== null && _f !== void 0 ? _f : this._llm.failure_message, max_history: (_g = this._maxHistory) !== null && _g !== void 0 ? _g : this._llm.max_history }) : undefined;
661
- const asrConfig = this._resolveAsrConfig();
671
+ : this._llm.system_messages, greeting_message: (_f = this._greeting) !== null && _f !== void 0 ? _f : this._llm.greeting_message, greeting_configs: (_g = this._greetingConfigs) !== null && _g !== void 0 ? _g : this._llm.greeting_configs, failure_message: (_h = this._failureMessage) !== null && _h !== void 0 ? _h : this._llm.failure_message, max_history: (_j = this._maxHistory) !== null && _j !== void 0 ? _j : this._llm.max_history }) : undefined;
672
+ const asrConfig = this._stt !== undefined || !allowMissingAsr
673
+ ? this._resolveAsrConfig()
674
+ : undefined;
662
675
  const turnDetectionConfig = this._resolveTurnDetectionConfig();
663
- return Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig, llm: llmConfig, tts: this._tts, asr: asrConfig });
676
+ const ttsConfig = this._tts;
677
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig }), (llmConfig && { llm: llmConfig })), (ttsConfig && { tts: ttsConfig })), (asrConfig && { asr: asrConfig }));
664
678
  }
665
679
  /**
666
680
  * Creates a shallow copy of this Agent, preserving the TTSSampleRate type
@@ -188,6 +188,7 @@ export declare class AgentSession {
188
188
  */
189
189
  private _enrichAvatarParams;
190
190
  private _validateEnrichedAvatarConfig;
191
+ private _vendorValidationCategories;
191
192
  /**
192
193
  * Start the agent session.
193
194
  *
@@ -15,7 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
15
15
  };
16
16
  import { AgoraError } from "../errors/index.mjs";
17
17
  import { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
18
- import { resolveSessionPresets } from "./presets.mjs";
18
+ import { getPresetCategory, inferAsrPreset, inferLlmPreset, inferTtsPreset, normalizePresetInput, resolveSessionPresets, } from "./presets.mjs";
19
19
  import { ExpiresIn as ExpiresInHelper, generateConvoAIToken } from "./token.mjs";
20
20
  /**
21
21
  * AgentSession class for managing agent lifecycle and interactions.
@@ -292,6 +292,35 @@ export class AgentSession {
292
292
  "Pass agoraToken on the avatar vendor or provide appCertificate for automatic token generation.");
293
293
  }
294
294
  }
295
+ _vendorValidationCategories(pipelineId) {
296
+ const skipVendorValidationCategories = new Set();
297
+ const allowMissingVendorCategories = new Set();
298
+ if (pipelineId) {
299
+ allowMissingVendorCategories.add("asr");
300
+ allowMissingVendorCategories.add("llm");
301
+ allowMissingVendorCategories.add("tts");
302
+ }
303
+ const normalizedPreset = normalizePresetInput(this._preset);
304
+ if (normalizedPreset) {
305
+ for (const item of normalizedPreset.split(",")) {
306
+ const category = getPresetCategory(item);
307
+ if (category) {
308
+ skipVendorValidationCategories.add(category);
309
+ allowMissingVendorCategories.add(category);
310
+ }
311
+ }
312
+ }
313
+ if (inferAsrPreset(this._agent.stt)) {
314
+ skipVendorValidationCategories.add("asr");
315
+ }
316
+ if (inferLlmPreset(this._agent.llm)) {
317
+ skipVendorValidationCategories.add("llm");
318
+ }
319
+ if (inferTtsPreset(this._agent.tts)) {
320
+ skipVendorValidationCategories.add("tts");
321
+ }
322
+ return { skipVendorValidationCategories, allowMissingVendorCategories };
323
+ }
295
324
  /**
296
325
  * Start the agent session.
297
326
  *
@@ -328,10 +357,9 @@ export class AgentSession {
328
357
  appCertificate: this._appCertificate,
329
358
  expiresIn,
330
359
  };
331
- const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid,
332
- // When a preset or pipeline_id is supplied, ASR/LLM/TTS vendor
333
- // config is optional — the backend fills it from the preset/pipeline.
334
- skipVendorValidation: !!(this._preset || pipelineId) }, tokenOpts));
360
+ const { skipVendorValidationCategories, allowMissingVendorCategories } = this._vendorValidationCategories(pipelineId);
361
+ const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid, skipVendorValidationCategories,
362
+ allowMissingVendorCategories }, tokenOpts));
335
363
  const resolved = resolveSessionPresets({
336
364
  preset: this._preset,
337
365
  properties,
@@ -29,6 +29,35 @@ export type DeepgramPresetModel = (typeof DeepgramPresetModels)[number];
29
29
  export type OpenAIPresetModel = (typeof OpenAIPresetModels)[number];
30
30
  export type OpenAITtsPresetModel = (typeof OpenAITtsPresetModels)[number];
31
31
  export type MiniMaxPresetModel = (typeof MiniMaxPresetModels)[number];
32
+ export type PresetCategory = "asr" | "llm" | "tts";
33
+ type AsrInference = {
34
+ category: "asr";
35
+ preset: AsrPreset;
36
+ stripModel: boolean;
37
+ };
38
+ type LlmInference = {
39
+ category: "llm";
40
+ preset: LlmPreset;
41
+ stripModel: boolean;
42
+ stripDefaultUrl: boolean;
43
+ };
44
+ type OpenAITtsInference = {
45
+ category: "tts";
46
+ preset: typeof AgentPresets.tts.openaiTts1;
47
+ vendor: "openai";
48
+ stripModel: boolean;
49
+ };
50
+ type MiniMaxTtsInference = {
51
+ category: "tts";
52
+ preset: TtsPreset;
53
+ vendor: "minimax";
54
+ stripModel: boolean;
55
+ };
56
+ type TtsInference = OpenAITtsInference | MiniMaxTtsInference;
57
+ export declare function getPresetCategory(preset: string): PresetCategory | undefined;
58
+ export declare function inferAsrPreset(asr?: Agora.Asr): AsrInference | undefined;
59
+ export declare function inferLlmPreset(llm?: Agora.Llm): LlmInference | undefined;
60
+ export declare function inferTtsPreset(tts?: Agora.Tts): TtsInference | undefined;
32
61
  export declare function normalizePresetInput(preset?: PresetInput | readonly string[]): string | undefined;
33
62
  export declare function resolveSessionPresets(args: {
34
63
  preset?: PresetInput;
@@ -37,3 +66,4 @@ export declare function resolveSessionPresets(args: {
37
66
  preset?: string;
38
67
  properties: Agora.StartAgentsRequest.Properties;
39
68
  };
69
+ export {};
@@ -53,9 +53,12 @@ const minimaxModelToPreset = {
53
53
  speech_2_8_turbo: AgentPresets.tts.minimaxSpeech28Turbo,
54
54
  };
55
55
  function normalizeModelName(value) {
56
- return typeof value === "string" ? value.trim().toLowerCase() : undefined;
56
+ if (typeof value !== "string")
57
+ return undefined;
58
+ const normalized = value.trim().toLowerCase();
59
+ return normalized.length > 0 ? normalized : undefined;
57
60
  }
58
- function getPresetCategory(preset) {
61
+ export function getPresetCategory(preset) {
59
62
  if (Object.values(AgentPresets.asr).includes(preset))
60
63
  return "asr";
61
64
  if (Object.values(AgentPresets.llm).includes(preset))
@@ -80,7 +83,7 @@ function omitUndefinedKeys(value) {
80
83
  const next = Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
81
84
  return Object.keys(next).length > 0 ? next : undefined;
82
85
  }
83
- function inferAsrPreset(asr) {
86
+ export function inferAsrPreset(asr) {
84
87
  var _a, _b, _c;
85
88
  if (!asr || asr.vendor !== "deepgram" || ((_a = asr.params) === null || _a === void 0 ? void 0 : _a.api_key))
86
89
  return undefined;
@@ -93,7 +96,7 @@ function inferAsrPreset(asr) {
93
96
  stripModel: true,
94
97
  };
95
98
  }
96
- function inferLlmPreset(llm) {
99
+ export function inferLlmPreset(llm) {
97
100
  var _a, _b;
98
101
  if (!llm || llm.api_key)
99
102
  return undefined;
@@ -111,7 +114,7 @@ function inferLlmPreset(llm) {
111
114
  stripDefaultUrl: true,
112
115
  };
113
116
  }
114
- function inferTtsPreset(tts) {
117
+ export function inferTtsPreset(tts) {
115
118
  var _a, _b, _c, _d, _e, _f;
116
119
  if (!tts)
117
120
  return undefined;
@@ -166,7 +169,7 @@ function stripInferredPresetFields(properties, inferred) {
166
169
  tts = Object.assign(Object.assign({}, tts), { params: omitUndefinedKeys(Object.assign(Object.assign({}, tts.params), { key: undefined, group_id: undefined, url: undefined, model: ttsInference.stripModel ? undefined : (_d = tts.params) === null || _d === void 0 ? void 0 : _d.model })) });
167
170
  }
168
171
  }
169
- return Object.assign(Object.assign({}, properties), { asr, llm, tts });
172
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, properties), (asr && { asr })), (llm && { llm })), (tts && { tts }));
170
173
  }
171
174
  export function normalizePresetInput(preset) {
172
175
  const entries = parsePresetInput(preset);
@@ -1,6 +1,10 @@
1
1
  function base64ToBytes(base64) {
2
2
  const binString = atob(base64);
3
- return Uint8Array.from(binString, (m) => m.codePointAt(0));
3
+ const bytes = new Uint8Array(binString.length);
4
+ for (let i = 0; i < binString.length; i++) {
5
+ bytes[i] = binString.charCodeAt(i);
6
+ }
7
+ return bytes;
4
8
  }
5
9
  function bytesToBase64(bytes) {
6
10
  const binString = String.fromCodePoint(...bytes);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "v2.1.0";
1
+ export declare const SDK_VERSION = "v2.1.1";
@@ -1 +1 @@
1
- export const SDK_VERSION = "v2.1.0";
1
+ export const SDK_VERSION = "v2.1.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-agents",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "private": false,
5
5
  "repository": "github:AgoraIO/agora-agents-ts",
6
6
  "type": "commonjs",
@@ -35,6 +35,7 @@
35
35
  "check": "biome check --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
36
36
  "check:fix": "biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --max-diagnostics=none",
37
37
  "docs:check": "node scripts/docs-check.js",
38
+ "release:check": "node scripts/check-release-workflow.js",
38
39
  "release:prepare": "node scripts/prepare-release.js",
39
40
  "build": "rm -rf dist && pnpm build:cjs && pnpm build:esm",
40
41
  "build:cjs": "tsc --project ./tsconfig.cjs.json",