agora-agents 2.1.0 → 2.2.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 (46) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/AgoraPoolClient.js +7 -2
  3. package/dist/cjs/BaseClient.js +2 -2
  4. package/dist/cjs/Client.js +16 -8
  5. package/dist/cjs/agentkit/Agent.d.ts +7 -2
  6. package/dist/cjs/agentkit/Agent.js +33 -20
  7. package/dist/cjs/agentkit/AgentSession.d.ts +2 -0
  8. package/dist/cjs/agentkit/AgentSession.js +33 -4
  9. package/dist/cjs/agentkit/presets.d.ts +30 -0
  10. package/dist/cjs/agentkit/presets.js +20 -6
  11. package/dist/cjs/agentkit/types.d.ts +3 -1
  12. package/dist/cjs/agentkit/vendors/avatar.d.ts +3 -1
  13. package/dist/cjs/agentkit/vendors/llm.d.ts +4 -2
  14. package/dist/cjs/agentkit/vendors/llm.js +10 -5
  15. package/dist/cjs/agentkit/vendors/stt.d.ts +4 -6
  16. package/dist/cjs/agentkit/vendors/stt.js +44 -63
  17. package/dist/cjs/agentkit/vendors/tts.js +1 -1
  18. package/dist/cjs/api/types/DeepgramAsr.d.ts +0 -2
  19. package/dist/cjs/api/types/DeepgramAsrParams.d.ts +1 -1
  20. package/dist/cjs/api/types/OpenAiTtsParams.d.ts +1 -1
  21. package/dist/cjs/core/base64.js +5 -1
  22. package/dist/cjs/version.d.ts +1 -1
  23. package/dist/cjs/version.js +1 -1
  24. package/dist/esm/AgoraPoolClient.mjs +7 -2
  25. package/dist/esm/BaseClient.mjs +2 -2
  26. package/dist/esm/Client.mjs +16 -8
  27. package/dist/esm/agentkit/Agent.d.mts +7 -2
  28. package/dist/esm/agentkit/Agent.mjs +33 -20
  29. package/dist/esm/agentkit/AgentSession.d.mts +2 -0
  30. package/dist/esm/agentkit/AgentSession.mjs +34 -5
  31. package/dist/esm/agentkit/presets.d.mts +30 -0
  32. package/dist/esm/agentkit/presets.mjs +20 -10
  33. package/dist/esm/agentkit/types.d.mts +3 -1
  34. package/dist/esm/agentkit/vendors/avatar.d.mts +3 -1
  35. package/dist/esm/agentkit/vendors/llm.d.mts +4 -2
  36. package/dist/esm/agentkit/vendors/llm.mjs +10 -5
  37. package/dist/esm/agentkit/vendors/stt.d.mts +4 -6
  38. package/dist/esm/agentkit/vendors/stt.mjs +44 -63
  39. package/dist/esm/agentkit/vendors/tts.mjs +1 -1
  40. package/dist/esm/api/types/DeepgramAsr.d.mts +0 -2
  41. package/dist/esm/api/types/DeepgramAsrParams.d.mts +1 -1
  42. package/dist/esm/api/types/OpenAiTtsParams.d.mts +1 -1
  43. package/dist/esm/core/base64.mjs +5 -1
  44. package/dist/esm/version.d.mts +1 -1
  45. package/dist/esm/version.mjs +1 -1
  46. package/package.json +2 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ npm install agora-agents
16
16
  ## Quick Start
17
17
 
18
18
  Start with the `Agent` builder: create a client with app credentials, choose your ASR, LLM, and TTS providers, then start a session. Omit vendor API keys for supported Agora-managed models, or provide keys when you want BYOK.
19
- Set Agora interaction language with `turnDetection.language`; provider-specific STT language values remain under `asr.params`.
19
+ Set Agora interaction language with `turnDetection.language`; provider-specific STT language values remain under `asr.params`. Ares uses only the REST `asr.language` value sourced from `turnDetection.language`.
20
20
 
21
21
  ```typescript
22
22
  import {
@@ -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.2.0",
45
+ "User-Agent": "agora-agents/v2.2.0",
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;
@@ -49,7 +49,7 @@ function isTurnDetectionLanguage(value) {
49
49
  }
50
50
  function assertTurnDetectionLanguage(value) {
51
51
  if (!isTurnDetectionLanguage(value)) {
52
- throw new Error(`Invalid interaction language: ${value}`);
52
+ throw new Error(`Invalid turnDetection.language: ${value}`);
53
53
  }
54
54
  }
55
55
  /**
@@ -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,37 @@ 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
- ? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
662
- ? [{ 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();
672
+ ? Object.assign(Object.assign({}, this._llm), { system_messages: this._llm.system_messages !== undefined
673
+ ? this._llm.system_messages
674
+ : this._instructions
675
+ ? [{ role: "system", content: this._instructions }]
676
+ : undefined, greeting_message: (_f = this._llm.greeting_message) !== null && _f !== void 0 ? _f : this._greeting, greeting_configs: (_g = this._llm.greeting_configs) !== null && _g !== void 0 ? _g : this._greetingConfigs, failure_message: (_h = this._llm.failure_message) !== null && _h !== void 0 ? _h : this._failureMessage, max_history: (_j = this._llm.max_history) !== null && _j !== void 0 ? _j : this._maxHistory }) : undefined;
665
677
  const turnDetectionConfig = this._resolveTurnDetectionConfig();
666
- return Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig, llm: llmConfig, tts: this._tts, asr: asrConfig });
678
+ const asrConfig = this._stt !== undefined || !allowMissingAsr
679
+ ? this._resolveAsrConfig(turnDetectionConfig)
680
+ : undefined;
681
+ const ttsConfig = this._tts;
682
+ 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
683
  }
668
684
  /**
669
685
  * Creates a shallow copy of this Agent, preserving the TTSSampleRate type
@@ -699,23 +715,20 @@ class Agent {
699
715
  newAgent._greetingConfigs = this._greetingConfigs;
700
716
  return newAgent;
701
717
  }
702
- _resolveAsrConfig() {
718
+ _resolveAsrConfig(turnDetectionConfig) {
703
719
  var _a;
704
720
  const asrConfig = Object.assign({}, ((_a = this._stt) !== null && _a !== void 0 ? _a : {}));
705
721
  if (this._stt === undefined) {
706
722
  asrConfig.vendor = "ares";
707
723
  }
708
- delete asrConfig.language;
724
+ asrConfig.language = turnDetectionConfig.language;
709
725
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
710
726
  }
711
727
  _resolveTurnDetectionConfig() {
712
- var _a, _b;
728
+ var _a;
713
729
  const turnDetection = Object.assign({}, ((_a = this._turnDetection) !== null && _a !== void 0 ? _a : {}));
714
730
  const existingTurnDetectionLanguage = turnDetection.language;
715
- const existingAsrLanguage = (_b = this._stt) === null || _b === void 0 ? void 0 : _b.language;
716
- const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : (existingAsrLanguage !== undefined && isTurnDetectionLanguage(existingAsrLanguage)
717
- ? existingAsrLanguage
718
- : DEFAULT_TURN_DETECTION_LANGUAGE);
731
+ const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : DEFAULT_TURN_DETECTION_LANGUAGE;
719
732
  assertTurnDetectionLanguage(language);
720
733
  turnDetection.language = language;
721
734
  return turnDetection;
@@ -73,6 +73,7 @@ export interface AgentSessionOptions {
73
73
  *
74
74
  * const client = new AgoraClient({
75
75
  * area: Area.US,
76
+
76
77
  * appId: '...',
77
78
  * appCertificate: '...',
78
79
  * });
@@ -188,6 +189,7 @@ export declare class AgentSession {
188
189
  */
189
190
  private _enrichAvatarParams;
190
191
  private _validateEnrichedAvatarConfig;
192
+ private _vendorValidationCategories;
191
193
  /**
192
194
  * Start the agent session.
193
195
  *
@@ -31,6 +31,7 @@ const token_js_1 = require("./token.js");
31
31
  *
32
32
  * const client = new AgoraClient({
33
33
  * area: Area.US,
34
+
34
35
  * appId: '...',
35
36
  * appCertificate: '...',
36
37
  * });
@@ -295,6 +296,35 @@ class AgentSession {
295
296
  "Pass agoraToken on the avatar vendor or provide appCertificate for automatic token generation.");
296
297
  }
297
298
  }
299
+ _vendorValidationCategories(pipelineId) {
300
+ const skipVendorValidationCategories = new Set();
301
+ const allowMissingVendorCategories = new Set();
302
+ if (pipelineId) {
303
+ allowMissingVendorCategories.add("asr");
304
+ allowMissingVendorCategories.add("llm");
305
+ allowMissingVendorCategories.add("tts");
306
+ }
307
+ const normalizedPreset = (0, presets_js_1.normalizePresetInput)(this._preset);
308
+ if (normalizedPreset) {
309
+ for (const item of normalizedPreset.split(",")) {
310
+ const category = (0, presets_js_1.getPresetCategory)(item);
311
+ if (category) {
312
+ skipVendorValidationCategories.add(category);
313
+ allowMissingVendorCategories.add(category);
314
+ }
315
+ }
316
+ }
317
+ if ((0, presets_js_1.inferAsrPreset)(this._agent.stt)) {
318
+ skipVendorValidationCategories.add("asr");
319
+ }
320
+ if ((0, presets_js_1.inferLlmPreset)(this._agent.llm)) {
321
+ skipVendorValidationCategories.add("llm");
322
+ }
323
+ if ((0, presets_js_1.inferTtsPreset)(this._agent.tts)) {
324
+ skipVendorValidationCategories.add("tts");
325
+ }
326
+ return { skipVendorValidationCategories, allowMissingVendorCategories };
327
+ }
298
328
  /**
299
329
  * Start the agent session.
300
330
  *
@@ -331,10 +361,9 @@ class AgentSession {
331
361
  appCertificate: this._appCertificate,
332
362
  expiresIn,
333
363
  };
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));
364
+ const { skipVendorValidationCategories, allowMissingVendorCategories } = this._vendorValidationCategories(pipelineId);
365
+ const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid, skipVendorValidationCategories,
366
+ allowMissingVendorCategories }, tokenOpts));
338
367
  const resolved = (0, presets_js_1.resolveSessionPresets)({
339
368
  preset: this._preset,
340
369
  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))
@@ -87,7 +94,7 @@ function omitUndefinedKeys(value) {
87
94
  }
88
95
  function inferAsrPreset(asr) {
89
96
  var _a, _b, _c;
90
- if (!asr || asr.vendor !== "deepgram" || ((_a = asr.params) === null || _a === void 0 ? void 0 : _a.api_key))
97
+ if (!asr || asr.vendor !== "deepgram" || ((_a = asr.params) === null || _a === void 0 ? void 0 : _a.key))
91
98
  return undefined;
92
99
  const preset = deepgramModelToPreset[(_c = normalizeModelName((_b = asr.params) === null || _b === void 0 ? void 0 : _b.model)) !== null && _c !== void 0 ? _c : ""];
93
100
  if (!preset)
@@ -117,7 +124,7 @@ function inferLlmPreset(llm) {
117
124
  };
118
125
  }
119
126
  function inferTtsPreset(tts) {
120
- var _a, _b, _c, _d, _e, _f;
127
+ var _a, _b, _c, _d, _e, _f, _g;
121
128
  if (!tts)
122
129
  return undefined;
123
130
  if (tts.vendor === "openai") {
@@ -136,7 +143,9 @@ function inferTtsPreset(tts) {
136
143
  if (tts.vendor === "minimax") {
137
144
  if ((_d = tts.params) === null || _d === void 0 ? void 0 : _d.key)
138
145
  return undefined;
139
- const preset = minimaxModelToPreset[(_f = normalizeModelName((_e = tts.params) === null || _e === void 0 ? void 0 : _e.model)) !== null && _f !== void 0 ? _f : ""];
146
+ // Model is no longer in params for the preset path; fall back to the top-level hint.
147
+ const model = (_g = (_f = normalizeModelName((_e = tts.params) === null || _e === void 0 ? void 0 : _e.model)) !== null && _f !== void 0 ? _f : normalizeModelName(tts._minimaxPresetModel)) !== null && _g !== void 0 ? _g : "";
148
+ const preset = minimaxModelToPreset[model];
140
149
  if (!preset)
141
150
  return undefined;
142
151
  return {
@@ -168,10 +177,15 @@ function stripInferredPresetFields(properties, inferred) {
168
177
  tts = Object.assign(Object.assign({}, tts), { params: omitUndefinedKeys(Object.assign(Object.assign({}, tts.params), { api_key: undefined, model: ttsInference.stripModel ? undefined : (_c = tts.params) === null || _c === void 0 ? void 0 : _c.model })) });
169
178
  }
170
179
  else if (ttsInference.vendor === "minimax" && tts.vendor === "minimax") {
171
- 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 })) });
180
+ const _e = tts, { _minimaxPresetModel: _stripped } = _e, ttsWithoutHint = __rest(_e, ["_minimaxPresetModel"]);
181
+ tts = Object.assign(Object.assign({}, ttsWithoutHint), { 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
182
  }
173
183
  }
174
- return Object.assign(Object.assign({}, properties), { asr, llm, tts });
184
+ if (tts && "_minimaxPresetModel" in tts) {
185
+ const _f = tts, { _minimaxPresetModel: _discarded } = _f, rest = __rest(_f, ["_minimaxPresetModel"]);
186
+ tts = rest;
187
+ }
188
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, properties), (asr && { asr })), (llm && { llm })), (tts && { tts }));
175
189
  }
176
190
  function normalizePresetInput(preset) {
177
191
  const entries = parsePresetInput(preset);
@@ -66,7 +66,9 @@ export type AvatarVendor = StartAgentsRequest.Properties.Avatar.Vendor;
66
66
  /** BCP-47 language tag used by `turn_detection.language`. */
67
67
  export type TurnDetectionLanguage = AsrLanguage;
68
68
  /** Turn detection configuration */
69
- export type TurnDetectionConfig = StartAgentsRequest.Properties.TurnDetection;
69
+ export type TurnDetectionConfig = Omit<StartAgentsRequest.Properties.TurnDetection, "language"> & {
70
+ language?: TurnDetectionLanguage;
71
+ };
70
72
  /** Detailed nested config for turn detection (`turn_detection.config`) */
71
73
  export type TurnDetectionNestedConfig = StartAgentsRequest.Properties.TurnDetection.Config;
72
74
  /** Start of Speech (SoS) detection configuration (`turn_detection.config.start_of_speech`) */
@@ -7,6 +7,8 @@
7
7
  import type { AvatarConfig } from "../types.js";
8
8
  import type { AkoolSampleRate, HeyGenSampleRate, LiveAvatarSampleRate } from "./base.js";
9
9
  import { BaseAvatar } from "./base.js";
10
+ /**
11
+ * Constructor options for HeyGen Avatar.
10
12
  /**
11
13
  * Constructor options for LiveAvatar.
12
14
  */
@@ -19,7 +21,7 @@ export interface LiveAvatarAvatarOptions {
19
21
  agoraUid: string;
20
22
  /** Avatar ConvoAI token. Omit to auto-generate at session start. */
21
23
  agoraToken?: string;
22
- /** Avatar ID */
24
+ /** HeyGen avatar ID */
23
25
  avatarId?: string;
24
26
  /** Whether to disable idle timeout (default: false) */
25
27
  disableIdleTimeout?: boolean;
@@ -69,8 +69,10 @@ export interface AzureOpenAIOptions extends BaseLlmOptions {
69
69
  apiKey: string;
70
70
  /** Model/deployment name */
71
71
  model: string;
72
- /** Azure resource name (e.g., 'my-resource') */
73
- resourceName: string;
72
+ /** Azure resource name (e.g., 'my-resource'). Required when endpoint is not set. */
73
+ resourceName?: string;
74
+ /** Full Azure base URL (e.g., for sovereign clouds or private endpoints). Takes precedence over resourceName. */
75
+ endpoint?: string;
74
76
  /** Deployment name in Azure */
75
77
  deploymentName: string;
76
78
  /** Azure API version (defaults to '2024-08-01-preview') */
@@ -82,15 +82,19 @@ class AzureOpenAI extends base_js_1.BaseLLM {
82
82
  super(options);
83
83
  requireString(options.apiKey, "apiKey", "AzureOpenAI");
84
84
  requireString(options.model, "model", "AzureOpenAI");
85
- requireString(options.resourceName, "resourceName", "AzureOpenAI");
85
+ if (!options.resourceName && !options.endpoint) {
86
+ throw new Error("AzureOpenAI requires either resourceName or endpoint");
87
+ }
86
88
  requireString(options.deploymentName, "deploymentName", "AzureOpenAI");
87
89
  this.options = options;
88
90
  }
89
91
  toConfig() {
90
92
  var _a;
91
- const { apiKey, model, resourceName, deploymentName, apiVersion = "2024-08-01-preview", maxHistory, temperature, topP, maxTokens, systemMessages, greetingMessage, failureMessage, inputModalities, params, headers, } = this.options;
93
+ const { apiKey, model, resourceName, endpoint, deploymentName, apiVersion = "2024-08-01-preview", maxHistory, temperature, topP, maxTokens, systemMessages, greetingMessage, failureMessage, inputModalities, params, headers, } = this.options;
94
+ const rawBase = endpoint !== null && endpoint !== void 0 ? endpoint : `https://${resourceName}.openai.azure.com`;
95
+ const baseUrl = rawBase.replace(/\/$/, "");
92
96
  return {
93
- url: `https://${resourceName}.openai.azure.com/openai/deployments/${deploymentName}/chat/completions?api-version=${apiVersion}`,
97
+ url: `${baseUrl}/openai/deployments/${deploymentName}/chat/completions?api-version=${apiVersion}`,
94
98
  api_key: apiKey,
95
99
  // "azure" is required by Agora for Azure OpenAI; user-supplied vendor overrides if needed.
96
100
  vendor: (_a = this.vendor) !== null && _a !== void 0 ? _a : "azure",
@@ -257,10 +261,11 @@ class VertexAILLM extends base_js_1.BaseLLM {
257
261
  toConfig() {
258
262
  var _a, _b;
259
263
  const o = this.options;
264
+ const defaultUrl = `https://${o.location}-aiplatform.googleapis.com/v1/projects/${o.projectId}/locations/${o.location}/publishers/google/models/${o.model}:streamGenerateContent?alt=sse`;
260
265
  return {
261
- url: (_a = o.url) !== null && _a !== void 0 ? _a : "https://aiplatform.googleapis.com/v1/projects",
266
+ url: (_a = o.url) !== null && _a !== void 0 ? _a : defaultUrl,
262
267
  api_key: o.apiKey,
263
- params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ model: o.model, project_id: o.projectId, location: o.location }, o.params), (o.temperature !== undefined && { temperature: o.temperature })), (o.topP !== undefined && { top_p: o.topP })), (o.topK !== undefined && { top_k: o.topK })), (o.maxOutputTokens !== undefined && { max_output_tokens: o.maxOutputTokens })),
268
+ params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ model: o.model }, o.params), (o.temperature !== undefined && { temperature: o.temperature })), (o.topP !== undefined && { top_p: o.topP })), (o.topK !== undefined && { top_k: o.topK })), (o.maxOutputTokens !== undefined && { max_output_tokens: o.maxOutputTokens })),
264
269
  headers: o.headers,
265
270
  max_history: o.maxHistory,
266
271
  system_messages: o.systemMessages,
@@ -2,7 +2,7 @@
2
2
  * Type-safe STT (Speech-to-Text) vendor classes.
3
3
  */
4
4
  import { type DeepgramPresetModel } from "../presets.js";
5
- import type { SttConfig, TurnDetectionLanguage } from "../types.js";
5
+ import type { SttConfig } from "../types.js";
6
6
  import { BaseSTT } from "./base.js";
7
7
  /**
8
8
  * Constructor options for Speechmatics STT.
@@ -49,6 +49,8 @@ type DeepgramSTTCommonOptions = {
49
49
  smartFormat?: boolean;
50
50
  /** Enable punctuation */
51
51
  punctuation?: boolean;
52
+ /** Boost specialized terms and brands for Deepgram */
53
+ keyterm?: string;
52
54
  /** Additional vendor-specific parameters */
53
55
  additionalParams?: Record<string, unknown>;
54
56
  };
@@ -238,8 +240,6 @@ export declare class AssemblyAISTT extends BaseSTT {
238
240
  * Constructor options for Agora ARES STT.
239
241
  */
240
242
  export interface AresSTTOptions {
241
- /** Language code for ARES ASR */
242
- language?: TurnDetectionLanguage;
243
243
  /** Additional vendor-specific parameters */
244
244
  additionalParams?: Record<string, unknown>;
245
245
  }
@@ -248,9 +248,7 @@ export interface AresSTTOptions {
248
248
  *
249
249
  * @example
250
250
  * ```typescript
251
- * const stt = new AresSTT({
252
- * language: 'en-US',
253
- * });
251
+ * const stt = new AresSTT();
254
252
  * ```
255
253
  */
256
254
  export declare class AresSTT extends BaseSTT {