agora-agents 2.1.1 → 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 (36) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/agentkit/Agent.js +12 -13
  4. package/dist/cjs/agentkit/AgentSession.d.ts +1 -0
  5. package/dist/cjs/agentkit/AgentSession.js +1 -0
  6. package/dist/cjs/agentkit/presets.js +11 -4
  7. package/dist/cjs/agentkit/types.d.ts +3 -1
  8. package/dist/cjs/agentkit/vendors/avatar.d.ts +3 -1
  9. package/dist/cjs/agentkit/vendors/llm.d.ts +4 -2
  10. package/dist/cjs/agentkit/vendors/llm.js +10 -5
  11. package/dist/cjs/agentkit/vendors/stt.d.ts +4 -6
  12. package/dist/cjs/agentkit/vendors/stt.js +44 -63
  13. package/dist/cjs/agentkit/vendors/tts.js +1 -1
  14. package/dist/cjs/api/types/DeepgramAsr.d.ts +0 -2
  15. package/dist/cjs/api/types/DeepgramAsrParams.d.ts +1 -1
  16. package/dist/cjs/api/types/OpenAiTtsParams.d.ts +1 -1
  17. package/dist/cjs/version.d.ts +1 -1
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/esm/BaseClient.mjs +2 -2
  20. package/dist/esm/agentkit/Agent.mjs +12 -13
  21. package/dist/esm/agentkit/AgentSession.d.mts +1 -0
  22. package/dist/esm/agentkit/AgentSession.mjs +1 -0
  23. package/dist/esm/agentkit/presets.mjs +11 -4
  24. package/dist/esm/agentkit/types.d.mts +3 -1
  25. package/dist/esm/agentkit/vendors/avatar.d.mts +3 -1
  26. package/dist/esm/agentkit/vendors/llm.d.mts +4 -2
  27. package/dist/esm/agentkit/vendors/llm.mjs +10 -5
  28. package/dist/esm/agentkit/vendors/stt.d.mts +4 -6
  29. package/dist/esm/agentkit/vendors/stt.mjs +44 -63
  30. package/dist/esm/agentkit/vendors/tts.mjs +1 -1
  31. package/dist/esm/api/types/DeepgramAsr.d.mts +0 -2
  32. package/dist/esm/api/types/DeepgramAsrParams.d.mts +1 -1
  33. package/dist/esm/api/types/OpenAiTtsParams.d.mts +1 -1
  34. package/dist/esm/version.d.mts +1 -1
  35. package/dist/esm/version.mjs +1 -1
  36. package/package.json +1 -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 {
@@ -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.1",
45
- "User-Agent": "agora-agents/v2.1.1",
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);
@@ -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
  /**
@@ -669,13 +669,15 @@ class Agent {
669
669
  throw new Error("LLM configuration is required. Use withLlm() to set it.");
670
670
  }
671
671
  const llmConfig = this._llm
672
- ? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
673
- ? [{ role: "system", content: this._instructions }]
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;
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;
677
+ const turnDetectionConfig = this._resolveTurnDetectionConfig();
675
678
  const asrConfig = this._stt !== undefined || !allowMissingAsr
676
- ? this._resolveAsrConfig()
679
+ ? this._resolveAsrConfig(turnDetectionConfig)
677
680
  : undefined;
678
- const turnDetectionConfig = this._resolveTurnDetectionConfig();
679
681
  const ttsConfig = this._tts;
680
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 }));
681
683
  }
@@ -713,23 +715,20 @@ class Agent {
713
715
  newAgent._greetingConfigs = this._greetingConfigs;
714
716
  return newAgent;
715
717
  }
716
- _resolveAsrConfig() {
718
+ _resolveAsrConfig(turnDetectionConfig) {
717
719
  var _a;
718
720
  const asrConfig = Object.assign({}, ((_a = this._stt) !== null && _a !== void 0 ? _a : {}));
719
721
  if (this._stt === undefined) {
720
722
  asrConfig.vendor = "ares";
721
723
  }
722
- delete asrConfig.language;
724
+ asrConfig.language = turnDetectionConfig.language;
723
725
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
724
726
  }
725
727
  _resolveTurnDetectionConfig() {
726
- var _a, _b;
728
+ var _a;
727
729
  const turnDetection = Object.assign({}, ((_a = this._turnDetection) !== null && _a !== void 0 ? _a : {}));
728
730
  const existingTurnDetectionLanguage = turnDetection.language;
729
- const existingAsrLanguage = (_b = this._stt) === null || _b === void 0 ? void 0 : _b.language;
730
- const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : (existingAsrLanguage !== undefined && isTurnDetectionLanguage(existingAsrLanguage)
731
- ? existingAsrLanguage
732
- : DEFAULT_TURN_DETECTION_LANGUAGE);
731
+ const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : DEFAULT_TURN_DETECTION_LANGUAGE;
733
732
  assertTurnDetectionLanguage(language);
734
733
  turnDetection.language = language;
735
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
  * });
@@ -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
  * });
@@ -94,7 +94,7 @@ function omitUndefinedKeys(value) {
94
94
  }
95
95
  function inferAsrPreset(asr) {
96
96
  var _a, _b, _c;
97
- 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))
98
98
  return undefined;
99
99
  const preset = deepgramModelToPreset[(_c = normalizeModelName((_b = asr.params) === null || _b === void 0 ? void 0 : _b.model)) !== null && _c !== void 0 ? _c : ""];
100
100
  if (!preset)
@@ -124,7 +124,7 @@ function inferLlmPreset(llm) {
124
124
  };
125
125
  }
126
126
  function inferTtsPreset(tts) {
127
- var _a, _b, _c, _d, _e, _f;
127
+ var _a, _b, _c, _d, _e, _f, _g;
128
128
  if (!tts)
129
129
  return undefined;
130
130
  if (tts.vendor === "openai") {
@@ -143,7 +143,9 @@ function inferTtsPreset(tts) {
143
143
  if (tts.vendor === "minimax") {
144
144
  if ((_d = tts.params) === null || _d === void 0 ? void 0 : _d.key)
145
145
  return undefined;
146
- 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];
147
149
  if (!preset)
148
150
  return undefined;
149
151
  return {
@@ -175,9 +177,14 @@ function stripInferredPresetFields(properties, inferred) {
175
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 })) });
176
178
  }
177
179
  else if (ttsInference.vendor === "minimax" && tts.vendor === "minimax") {
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 })) });
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 })) });
179
182
  }
180
183
  }
184
+ if (tts && "_minimaxPresetModel" in tts) {
185
+ const _f = tts, { _minimaxPresetModel: _discarded } = _f, rest = __rest(_f, ["_minimaxPresetModel"]);
186
+ tts = rest;
187
+ }
181
188
  return Object.assign(Object.assign(Object.assign(Object.assign({}, properties), (asr && { asr })), (llm && { llm })), (tts && { tts }));
182
189
  }
183
190
  function normalizePresetInput(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 {
@@ -6,45 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SarvamSTT = exports.AresSTT = exports.AssemblyAISTT = exports.AmazonSTT = exports.GoogleSTT = exports.OpenAISTT = exports.MicrosoftSTT = exports.DeepgramSTT = exports.SpeechmaticsSTT = void 0;
7
7
  const presets_js_1 = require("../presets.js");
8
8
  const base_js_1 = require("./base.js");
9
- const INTERACTION_LANGUAGES = new Set([
10
- "ar-EG",
11
- "ar-JO",
12
- "ar-SA",
13
- "ar-AE",
14
- "bn-IN",
15
- "zh-CN",
16
- "zh-HK",
17
- "zh-TW",
18
- "nl-NL",
19
- "en-IN",
20
- "en-US",
21
- "fil-PH",
22
- "fr-FR",
23
- "de-DE",
24
- "gu-IN",
25
- "he-IL",
26
- "hi-IN",
27
- "id-ID",
28
- "it-IT",
29
- "ja-JP",
30
- "kn-IN",
31
- "ko-KR",
32
- "ms-MY",
33
- "fa-IR",
34
- "pt-PT",
35
- "ru-RU",
36
- "es-ES",
37
- "ta-IN",
38
- "te-IN",
39
- "th-TH",
40
- "tr-TR",
41
- "vi-VN",
42
- ]);
43
- function toTurnDetectionLanguage(language) {
44
- return language !== undefined && INTERACTION_LANGUAGES.has(language)
45
- ? language
46
- : undefined;
47
- }
48
9
  function isDeepgramManagedModel(model) {
49
10
  return model !== undefined && presets_js_1.DeepgramPresetModels.includes(model.trim().toLowerCase());
50
11
  }
@@ -66,8 +27,10 @@ class SpeechmaticsSTT extends base_js_1.BaseSTT {
66
27
  }
67
28
  toConfig() {
68
29
  const { apiKey, language, model, uri, additionalParams } = this.options;
69
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
70
- return Object.assign(Object.assign({ vendor: "speechmatics" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri })) });
30
+ return {
31
+ vendor: "speechmatics",
32
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri })),
33
+ };
71
34
  }
72
35
  }
73
36
  exports.SpeechmaticsSTT = SpeechmaticsSTT;
@@ -92,9 +55,11 @@ class DeepgramSTT extends base_js_1.BaseSTT {
92
55
  this.options = options !== null && options !== void 0 ? options : {};
93
56
  }
94
57
  toConfig() {
95
- const { apiKey, model, language, smartFormat, punctuation, additionalParams } = this.options;
96
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
97
- return Object.assign(Object.assign({ vendor: "deepgram" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), (apiKey && { key: apiKey })), (model && { model })), (language && { language })), (smartFormat !== undefined && { smart_format: smartFormat })), (punctuation !== undefined && { punctuation })) });
58
+ const { apiKey, model, language, smartFormat, punctuation, keyterm, additionalParams } = this.options;
59
+ return {
60
+ vendor: "deepgram",
61
+ params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), (apiKey && { key: apiKey })), (model && { model })), (language && { language })), (smartFormat !== undefined && { smart_format: smartFormat })), (punctuation !== undefined && { punctuation })), (keyterm && { keyterm })),
62
+ };
98
63
  }
99
64
  }
100
65
  exports.DeepgramSTT = DeepgramSTT;
@@ -117,9 +82,11 @@ class MicrosoftSTT extends base_js_1.BaseSTT {
117
82
  }
118
83
  toConfig() {
119
84
  const { key, region, language, additionalParams } = this.options;
120
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
121
- return Object.assign(Object.assign({ vendor: "microsoft" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign({}, additionalParams), { key,
122
- region }), (language && { language })) });
85
+ return {
86
+ vendor: "microsoft",
87
+ params: Object.assign(Object.assign(Object.assign({}, additionalParams), { key,
88
+ region }), (language && { language })),
89
+ };
123
90
  }
124
91
  }
125
92
  exports.MicrosoftSTT = MicrosoftSTT;
@@ -140,9 +107,17 @@ class OpenAISTT extends base_js_1.BaseSTT {
140
107
  }
141
108
  toConfig() {
142
109
  const { apiKey, model, language, prompt, inputAudioTranscription, additionalParams } = this.options;
143
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
144
- const transcription = Object.assign(Object.assign(Object.assign(Object.assign({ model: "whisper-1" }, inputAudioTranscription), (model && { model })), (prompt && { prompt })), (language && { language }));
145
- return Object.assign(Object.assign({ vendor: "openai" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, input_audio_transcription: transcription }) });
110
+ const transcription = Object.assign(Object.assign(Object.assign(Object.assign({ model: "gpt-4o-mini-transcribe" }, inputAudioTranscription), (model && { model })), (prompt && { prompt })), (language && { language }));
111
+ if (!transcription.model)
112
+ throw new Error("OpenAISTT: inputAudioTranscription.model is required");
113
+ if (!transcription.prompt)
114
+ throw new Error("OpenAISTT: inputAudioTranscription.prompt is required");
115
+ if (!transcription.language)
116
+ throw new Error("OpenAISTT: inputAudioTranscription.language is required");
117
+ return {
118
+ vendor: "openai",
119
+ params: Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, input_audio_transcription: transcription }),
120
+ };
146
121
  }
147
122
  }
148
123
  exports.OpenAISTT = OpenAISTT;
@@ -166,8 +141,10 @@ class GoogleSTT extends base_js_1.BaseSTT {
166
141
  }
167
142
  toConfig() {
168
143
  const { projectId, location, adcCredentialsString, language, model, additionalParams } = this.options;
169
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
170
- return Object.assign(Object.assign({ vendor: "google" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { project_id: projectId, location, adc_credentials_string: adcCredentialsString }), (language && { language })), (model && { model })) });
144
+ return {
145
+ vendor: "google",
146
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { project_id: projectId, location, adc_credentials_string: adcCredentialsString }), (language && { language })), (model && { model })),
147
+ };
171
148
  }
172
149
  }
173
150
  exports.GoogleSTT = GoogleSTT;
@@ -191,8 +168,10 @@ class AmazonSTT extends base_js_1.BaseSTT {
191
168
  }
192
169
  toConfig() {
193
170
  const { accessKey, secretKey, region, language, additionalParams } = this.options;
194
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
195
- return Object.assign(Object.assign({ vendor: "amazon" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign({}, additionalParams), { access_key_id: accessKey, secret_access_key: secretKey, region }), (language && { language_code: language })) });
171
+ return {
172
+ vendor: "amazon",
173
+ params: Object.assign(Object.assign(Object.assign({}, additionalParams), { access_key_id: accessKey, secret_access_key: secretKey, region }), (language && { language_code: language })),
174
+ };
196
175
  }
197
176
  }
198
177
  exports.AmazonSTT = AmazonSTT;
@@ -214,8 +193,10 @@ class AssemblyAISTT extends base_js_1.BaseSTT {
214
193
  }
215
194
  toConfig() {
216
195
  const { apiKey, language, uri, additionalParams } = this.options;
217
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
218
- return Object.assign(Object.assign({ vendor: "assemblyai" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (uri && { uri })) });
196
+ return {
197
+ vendor: "assemblyai",
198
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (uri && { uri })),
199
+ };
219
200
  }
220
201
  }
221
202
  exports.AssemblyAISTT = AssemblyAISTT;
@@ -224,9 +205,7 @@ exports.AssemblyAISTT = AssemblyAISTT;
224
205
  *
225
206
  * @example
226
207
  * ```typescript
227
- * const stt = new AresSTT({
228
- * language: 'en-US',
229
- * });
208
+ * const stt = new AresSTT();
230
209
  * ```
231
210
  */
232
211
  class AresSTT extends base_js_1.BaseSTT {
@@ -235,8 +214,8 @@ class AresSTT extends base_js_1.BaseSTT {
235
214
  this.options = options;
236
215
  }
237
216
  toConfig() {
238
- const { language, additionalParams } = this.options;
239
- return Object.assign(Object.assign({ vendor: "ares" }, (language && { language })), (additionalParams && Object.keys(additionalParams).length > 0 && { params: additionalParams }));
217
+ const { additionalParams } = this.options;
218
+ return Object.assign({ vendor: "ares" }, (additionalParams && Object.keys(additionalParams).length > 0 && { params: additionalParams }));
240
219
  }
241
220
  }
242
221
  exports.AresSTT = AresSTT;
@@ -258,8 +237,10 @@ class SarvamSTT extends base_js_1.BaseSTT {
258
237
  }
259
238
  toConfig() {
260
239
  const { apiKey, language, model, additionalParams } = this.options;
261
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
262
- return Object.assign(Object.assign({ vendor: "sarvam" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })) });
240
+ return {
241
+ vendor: "sarvam",
242
+ params: Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })),
243
+ };
263
244
  }
264
245
  }
265
246
  exports.SarvamSTT = SarvamSTT;
@@ -295,7 +295,7 @@ class MiniMaxTTS extends base_js_1.BaseTTS {
295
295
  }
296
296
  toConfig() {
297
297
  const { key, groupId, model, voiceId, url, skipPatterns } = this.options;
298
- return Object.assign({ vendor: "minimax", params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (key && { key })), (groupId && { group_id: groupId })), { model }), (voiceId && { voice_setting: { voice_id: voiceId } })), (url && { url })) }, (skipPatterns && { skip_patterns: skipPatterns }));
298
+ return Object.assign(Object.assign({ vendor: "minimax", params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (key && { key })), (key && groupId && { group_id: groupId })), (key && { model })), (voiceId && { voice_setting: { voice_id: voiceId } })), (key && url && { url })) }, (!key && { _minimaxPresetModel: model })), (skipPatterns && { skip_patterns: skipPatterns }));
299
299
  }
300
300
  }
301
301
  exports.MiniMaxTTS = MiniMaxTTS;
@@ -5,8 +5,6 @@ import type * as Agora from "../index.js";
5
5
  export interface DeepgramAsr {
6
6
  language?: Agora.AsrLanguage;
7
7
  params: Agora.DeepgramAsrParams;
8
- /** Boost specialized terms and brands for preset-backed Deepgram usage. */
9
- keyterm?: string;
10
8
  /** Accepts any additional properties */
11
9
  [key: string]: any;
12
10
  }
@@ -10,7 +10,7 @@ export interface DeepgramAsrParams {
10
10
  model?: string | null;
11
11
  /** Language code for speech recognition */
12
12
  language?: string | null;
13
- /** Boost specialized terms and brands */
13
+ /** Boost specialized terms and brands for Deepgram. */
14
14
  keyterm?: string | null;
15
15
  /** Accepts any additional properties */
16
16
  [key: string]: any;
@@ -2,7 +2,7 @@
2
2
  * OpenAI TTS configuration parameters.
3
3
  */
4
4
  export interface OpenAiTtsParams {
5
- /** OpenAI API key. Optional for preset-backed OpenAI TTS usage. */
5
+ /** OpenAI API key. Optional for Agora-managed OpenAI TTS usage. */
6
6
  api_key?: string;
7
7
  /** Endpoint URL for the OpenAI TTS service. */
8
8
  base_url?: string;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "v2.1.1";
1
+ export declare const SDK_VERSION = "v2.2.0";
@@ -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.1";
4
+ exports.SDK_VERSION = "v2.2.0";
@@ -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.1",
9
- "User-Agent": "agora-agents/v2.1.1",
8
+ "X-Fern-SDK-Version": "v2.2.0",
9
+ "User-Agent": "agora-agents/v2.2.0",
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);
@@ -46,7 +46,7 @@ function isTurnDetectionLanguage(value) {
46
46
  }
47
47
  function assertTurnDetectionLanguage(value) {
48
48
  if (!isTurnDetectionLanguage(value)) {
49
- throw new Error(`Invalid interaction language: ${value}`);
49
+ throw new Error(`Invalid turnDetection.language: ${value}`);
50
50
  }
51
51
  }
52
52
  /**
@@ -666,13 +666,15 @@ export class Agent {
666
666
  throw new Error("LLM configuration is required. Use withLlm() to set it.");
667
667
  }
668
668
  const llmConfig = this._llm
669
- ? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
670
- ? [{ role: "system", content: this._instructions }]
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;
669
+ ? Object.assign(Object.assign({}, this._llm), { system_messages: this._llm.system_messages !== undefined
670
+ ? this._llm.system_messages
671
+ : this._instructions
672
+ ? [{ role: "system", content: this._instructions }]
673
+ : 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;
674
+ const turnDetectionConfig = this._resolveTurnDetectionConfig();
672
675
  const asrConfig = this._stt !== undefined || !allowMissingAsr
673
- ? this._resolveAsrConfig()
676
+ ? this._resolveAsrConfig(turnDetectionConfig)
674
677
  : undefined;
675
- const turnDetectionConfig = this._resolveTurnDetectionConfig();
676
678
  const ttsConfig = this._tts;
677
679
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig }), (llmConfig && { llm: llmConfig })), (ttsConfig && { tts: ttsConfig })), (asrConfig && { asr: asrConfig }));
678
680
  }
@@ -710,23 +712,20 @@ export class Agent {
710
712
  newAgent._greetingConfigs = this._greetingConfigs;
711
713
  return newAgent;
712
714
  }
713
- _resolveAsrConfig() {
715
+ _resolveAsrConfig(turnDetectionConfig) {
714
716
  var _a;
715
717
  const asrConfig = Object.assign({}, ((_a = this._stt) !== null && _a !== void 0 ? _a : {}));
716
718
  if (this._stt === undefined) {
717
719
  asrConfig.vendor = "ares";
718
720
  }
719
- delete asrConfig.language;
721
+ asrConfig.language = turnDetectionConfig.language;
720
722
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
721
723
  }
722
724
  _resolveTurnDetectionConfig() {
723
- var _a, _b;
725
+ var _a;
724
726
  const turnDetection = Object.assign({}, ((_a = this._turnDetection) !== null && _a !== void 0 ? _a : {}));
725
727
  const existingTurnDetectionLanguage = turnDetection.language;
726
- const existingAsrLanguage = (_b = this._stt) === null || _b === void 0 ? void 0 : _b.language;
727
- const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : (existingAsrLanguage !== undefined && isTurnDetectionLanguage(existingAsrLanguage)
728
- ? existingAsrLanguage
729
- : DEFAULT_TURN_DETECTION_LANGUAGE);
728
+ const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : DEFAULT_TURN_DETECTION_LANGUAGE;
730
729
  assertTurnDetectionLanguage(language);
731
730
  turnDetection.language = language;
732
731
  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
  * });
@@ -28,6 +28,7 @@ import { ExpiresIn as ExpiresInHelper, generateConvoAIToken } from "./token.mjs"
28
28
  *
29
29
  * const client = new AgoraClient({
30
30
  * area: Area.US,
31
+
31
32
  * appId: '...',
32
33
  * appCertificate: '...',
33
34
  * });
@@ -85,7 +85,7 @@ function omitUndefinedKeys(value) {
85
85
  }
86
86
  export function inferAsrPreset(asr) {
87
87
  var _a, _b, _c;
88
- if (!asr || asr.vendor !== "deepgram" || ((_a = asr.params) === null || _a === void 0 ? void 0 : _a.api_key))
88
+ if (!asr || asr.vendor !== "deepgram" || ((_a = asr.params) === null || _a === void 0 ? void 0 : _a.key))
89
89
  return undefined;
90
90
  const preset = deepgramModelToPreset[(_c = normalizeModelName((_b = asr.params) === null || _b === void 0 ? void 0 : _b.model)) !== null && _c !== void 0 ? _c : ""];
91
91
  if (!preset)
@@ -115,7 +115,7 @@ export function inferLlmPreset(llm) {
115
115
  };
116
116
  }
117
117
  export function inferTtsPreset(tts) {
118
- var _a, _b, _c, _d, _e, _f;
118
+ var _a, _b, _c, _d, _e, _f, _g;
119
119
  if (!tts)
120
120
  return undefined;
121
121
  if (tts.vendor === "openai") {
@@ -134,7 +134,9 @@ export function inferTtsPreset(tts) {
134
134
  if (tts.vendor === "minimax") {
135
135
  if ((_d = tts.params) === null || _d === void 0 ? void 0 : _d.key)
136
136
  return undefined;
137
- const preset = minimaxModelToPreset[(_f = normalizeModelName((_e = tts.params) === null || _e === void 0 ? void 0 : _e.model)) !== null && _f !== void 0 ? _f : ""];
137
+ // Model is no longer in params for the preset path; fall back to the top-level hint.
138
+ 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 : "";
139
+ const preset = minimaxModelToPreset[model];
138
140
  if (!preset)
139
141
  return undefined;
140
142
  return {
@@ -166,9 +168,14 @@ function stripInferredPresetFields(properties, inferred) {
166
168
  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 })) });
167
169
  }
168
170
  else if (ttsInference.vendor === "minimax" && tts.vendor === "minimax") {
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 })) });
171
+ const _e = tts, { _minimaxPresetModel: _stripped } = _e, ttsWithoutHint = __rest(_e, ["_minimaxPresetModel"]);
172
+ 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 })) });
170
173
  }
171
174
  }
175
+ if (tts && "_minimaxPresetModel" in tts) {
176
+ const _f = tts, { _minimaxPresetModel: _discarded } = _f, rest = __rest(_f, ["_minimaxPresetModel"]);
177
+ tts = rest;
178
+ }
172
179
  return Object.assign(Object.assign(Object.assign(Object.assign({}, properties), (asr && { asr })), (llm && { llm })), (tts && { tts }));
173
180
  }
174
181
  export function normalizePresetInput(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.mjs";
8
8
  import type { AkoolSampleRate, HeyGenSampleRate, LiveAvatarSampleRate } from "./base.mjs";
9
9
  import { BaseAvatar } from "./base.mjs";
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') */
@@ -78,15 +78,19 @@ export class AzureOpenAI extends BaseLLM {
78
78
  super(options);
79
79
  requireString(options.apiKey, "apiKey", "AzureOpenAI");
80
80
  requireString(options.model, "model", "AzureOpenAI");
81
- requireString(options.resourceName, "resourceName", "AzureOpenAI");
81
+ if (!options.resourceName && !options.endpoint) {
82
+ throw new Error("AzureOpenAI requires either resourceName or endpoint");
83
+ }
82
84
  requireString(options.deploymentName, "deploymentName", "AzureOpenAI");
83
85
  this.options = options;
84
86
  }
85
87
  toConfig() {
86
88
  var _a;
87
- const { apiKey, model, resourceName, deploymentName, apiVersion = "2024-08-01-preview", maxHistory, temperature, topP, maxTokens, systemMessages, greetingMessage, failureMessage, inputModalities, params, headers, } = this.options;
89
+ const { apiKey, model, resourceName, endpoint, deploymentName, apiVersion = "2024-08-01-preview", maxHistory, temperature, topP, maxTokens, systemMessages, greetingMessage, failureMessage, inputModalities, params, headers, } = this.options;
90
+ const rawBase = endpoint !== null && endpoint !== void 0 ? endpoint : `https://${resourceName}.openai.azure.com`;
91
+ const baseUrl = rawBase.replace(/\/$/, "");
88
92
  return {
89
- url: `https://${resourceName}.openai.azure.com/openai/deployments/${deploymentName}/chat/completions?api-version=${apiVersion}`,
93
+ url: `${baseUrl}/openai/deployments/${deploymentName}/chat/completions?api-version=${apiVersion}`,
90
94
  api_key: apiKey,
91
95
  // "azure" is required by Agora for Azure OpenAI; user-supplied vendor overrides if needed.
92
96
  vendor: (_a = this.vendor) !== null && _a !== void 0 ? _a : "azure",
@@ -248,10 +252,11 @@ export class VertexAILLM extends BaseLLM {
248
252
  toConfig() {
249
253
  var _a, _b;
250
254
  const o = this.options;
255
+ const defaultUrl = `https://${o.location}-aiplatform.googleapis.com/v1/projects/${o.projectId}/locations/${o.location}/publishers/google/models/${o.model}:streamGenerateContent?alt=sse`;
251
256
  return {
252
- url: (_a = o.url) !== null && _a !== void 0 ? _a : "https://aiplatform.googleapis.com/v1/projects",
257
+ url: (_a = o.url) !== null && _a !== void 0 ? _a : defaultUrl,
253
258
  api_key: o.apiKey,
254
- 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 })),
259
+ 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 })),
255
260
  headers: o.headers,
256
261
  max_history: o.maxHistory,
257
262
  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.mjs";
5
- import type { SttConfig, TurnDetectionLanguage } from "../types.mjs";
5
+ import type { SttConfig } from "../types.mjs";
6
6
  import { BaseSTT } from "./base.mjs";
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 {
@@ -3,45 +3,6 @@
3
3
  */
4
4
  import { DeepgramPresetModels } from "../presets.mjs";
5
5
  import { BaseSTT } from "./base.mjs";
6
- const INTERACTION_LANGUAGES = new Set([
7
- "ar-EG",
8
- "ar-JO",
9
- "ar-SA",
10
- "ar-AE",
11
- "bn-IN",
12
- "zh-CN",
13
- "zh-HK",
14
- "zh-TW",
15
- "nl-NL",
16
- "en-IN",
17
- "en-US",
18
- "fil-PH",
19
- "fr-FR",
20
- "de-DE",
21
- "gu-IN",
22
- "he-IL",
23
- "hi-IN",
24
- "id-ID",
25
- "it-IT",
26
- "ja-JP",
27
- "kn-IN",
28
- "ko-KR",
29
- "ms-MY",
30
- "fa-IR",
31
- "pt-PT",
32
- "ru-RU",
33
- "es-ES",
34
- "ta-IN",
35
- "te-IN",
36
- "th-TH",
37
- "tr-TR",
38
- "vi-VN",
39
- ]);
40
- function toTurnDetectionLanguage(language) {
41
- return language !== undefined && INTERACTION_LANGUAGES.has(language)
42
- ? language
43
- : undefined;
44
- }
45
6
  function isDeepgramManagedModel(model) {
46
7
  return model !== undefined && DeepgramPresetModels.includes(model.trim().toLowerCase());
47
8
  }
@@ -63,8 +24,10 @@ export class SpeechmaticsSTT extends BaseSTT {
63
24
  }
64
25
  toConfig() {
65
26
  const { apiKey, language, model, uri, additionalParams } = this.options;
66
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
67
- return Object.assign(Object.assign({ vendor: "speechmatics" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri })) });
27
+ return {
28
+ vendor: "speechmatics",
29
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri })),
30
+ };
68
31
  }
69
32
  }
70
33
  /**
@@ -88,9 +51,11 @@ export class DeepgramSTT extends BaseSTT {
88
51
  this.options = options !== null && options !== void 0 ? options : {};
89
52
  }
90
53
  toConfig() {
91
- const { apiKey, model, language, smartFormat, punctuation, additionalParams } = this.options;
92
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
93
- return Object.assign(Object.assign({ vendor: "deepgram" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), (apiKey && { key: apiKey })), (model && { model })), (language && { language })), (smartFormat !== undefined && { smart_format: smartFormat })), (punctuation !== undefined && { punctuation })) });
54
+ const { apiKey, model, language, smartFormat, punctuation, keyterm, additionalParams } = this.options;
55
+ return {
56
+ vendor: "deepgram",
57
+ params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), (apiKey && { key: apiKey })), (model && { model })), (language && { language })), (smartFormat !== undefined && { smart_format: smartFormat })), (punctuation !== undefined && { punctuation })), (keyterm && { keyterm })),
58
+ };
94
59
  }
95
60
  }
96
61
  /**
@@ -112,9 +77,11 @@ export class MicrosoftSTT extends BaseSTT {
112
77
  }
113
78
  toConfig() {
114
79
  const { key, region, language, additionalParams } = this.options;
115
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
116
- return Object.assign(Object.assign({ vendor: "microsoft" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign({}, additionalParams), { key,
117
- region }), (language && { language })) });
80
+ return {
81
+ vendor: "microsoft",
82
+ params: Object.assign(Object.assign(Object.assign({}, additionalParams), { key,
83
+ region }), (language && { language })),
84
+ };
118
85
  }
119
86
  }
120
87
  /**
@@ -134,9 +101,17 @@ export class OpenAISTT extends BaseSTT {
134
101
  }
135
102
  toConfig() {
136
103
  const { apiKey, model, language, prompt, inputAudioTranscription, additionalParams } = this.options;
137
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
138
- const transcription = Object.assign(Object.assign(Object.assign(Object.assign({ model: "whisper-1" }, inputAudioTranscription), (model && { model })), (prompt && { prompt })), (language && { language }));
139
- return Object.assign(Object.assign({ vendor: "openai" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, input_audio_transcription: transcription }) });
104
+ const transcription = Object.assign(Object.assign(Object.assign(Object.assign({ model: "gpt-4o-mini-transcribe" }, inputAudioTranscription), (model && { model })), (prompt && { prompt })), (language && { language }));
105
+ if (!transcription.model)
106
+ throw new Error("OpenAISTT: inputAudioTranscription.model is required");
107
+ if (!transcription.prompt)
108
+ throw new Error("OpenAISTT: inputAudioTranscription.prompt is required");
109
+ if (!transcription.language)
110
+ throw new Error("OpenAISTT: inputAudioTranscription.language is required");
111
+ return {
112
+ vendor: "openai",
113
+ params: Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, input_audio_transcription: transcription }),
114
+ };
140
115
  }
141
116
  }
142
117
  /**
@@ -159,8 +134,10 @@ export class GoogleSTT extends BaseSTT {
159
134
  }
160
135
  toConfig() {
161
136
  const { projectId, location, adcCredentialsString, language, model, additionalParams } = this.options;
162
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
163
- return Object.assign(Object.assign({ vendor: "google" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { project_id: projectId, location, adc_credentials_string: adcCredentialsString }), (language && { language })), (model && { model })) });
137
+ return {
138
+ vendor: "google",
139
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { project_id: projectId, location, adc_credentials_string: adcCredentialsString }), (language && { language })), (model && { model })),
140
+ };
164
141
  }
165
142
  }
166
143
  /**
@@ -183,8 +160,10 @@ export class AmazonSTT extends BaseSTT {
183
160
  }
184
161
  toConfig() {
185
162
  const { accessKey, secretKey, region, language, additionalParams } = this.options;
186
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
187
- return Object.assign(Object.assign({ vendor: "amazon" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign({}, additionalParams), { access_key_id: accessKey, secret_access_key: secretKey, region }), (language && { language_code: language })) });
163
+ return {
164
+ vendor: "amazon",
165
+ params: Object.assign(Object.assign(Object.assign({}, additionalParams), { access_key_id: accessKey, secret_access_key: secretKey, region }), (language && { language_code: language })),
166
+ };
188
167
  }
189
168
  }
190
169
  /**
@@ -205,8 +184,10 @@ export class AssemblyAISTT extends BaseSTT {
205
184
  }
206
185
  toConfig() {
207
186
  const { apiKey, language, uri, additionalParams } = this.options;
208
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
209
- return Object.assign(Object.assign({ vendor: "assemblyai" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (uri && { uri })) });
187
+ return {
188
+ vendor: "assemblyai",
189
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (uri && { uri })),
190
+ };
210
191
  }
211
192
  }
212
193
  /**
@@ -214,9 +195,7 @@ export class AssemblyAISTT extends BaseSTT {
214
195
  *
215
196
  * @example
216
197
  * ```typescript
217
- * const stt = new AresSTT({
218
- * language: 'en-US',
219
- * });
198
+ * const stt = new AresSTT();
220
199
  * ```
221
200
  */
222
201
  export class AresSTT extends BaseSTT {
@@ -225,8 +204,8 @@ export class AresSTT extends BaseSTT {
225
204
  this.options = options;
226
205
  }
227
206
  toConfig() {
228
- const { language, additionalParams } = this.options;
229
- return Object.assign(Object.assign({ vendor: "ares" }, (language && { language })), (additionalParams && Object.keys(additionalParams).length > 0 && { params: additionalParams }));
207
+ const { additionalParams } = this.options;
208
+ return Object.assign({ vendor: "ares" }, (additionalParams && Object.keys(additionalParams).length > 0 && { params: additionalParams }));
230
209
  }
231
210
  }
232
211
  /**
@@ -247,7 +226,9 @@ export class SarvamSTT extends BaseSTT {
247
226
  }
248
227
  toConfig() {
249
228
  const { apiKey, language, model, additionalParams } = this.options;
250
- const turnDetectionLanguage = toTurnDetectionLanguage(language);
251
- return Object.assign(Object.assign({ vendor: "sarvam" }, (turnDetectionLanguage && { language: turnDetectionLanguage })), { params: Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })) });
229
+ return {
230
+ vendor: "sarvam",
231
+ params: Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })),
232
+ };
252
233
  }
253
234
  }
@@ -282,7 +282,7 @@ export class MiniMaxTTS extends BaseTTS {
282
282
  }
283
283
  toConfig() {
284
284
  const { key, groupId, model, voiceId, url, skipPatterns } = this.options;
285
- return Object.assign({ vendor: "minimax", params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (key && { key })), (groupId && { group_id: groupId })), { model }), (voiceId && { voice_setting: { voice_id: voiceId } })), (url && { url })) }, (skipPatterns && { skip_patterns: skipPatterns }));
285
+ return Object.assign(Object.assign({ vendor: "minimax", params: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (key && { key })), (key && groupId && { group_id: groupId })), (key && { model })), (voiceId && { voice_setting: { voice_id: voiceId } })), (key && url && { url })) }, (!key && { _minimaxPresetModel: model })), (skipPatterns && { skip_patterns: skipPatterns }));
286
286
  }
287
287
  }
288
288
  /**
@@ -5,8 +5,6 @@ import type * as Agora from "../index.mjs";
5
5
  export interface DeepgramAsr {
6
6
  language?: Agora.AsrLanguage;
7
7
  params: Agora.DeepgramAsrParams;
8
- /** Boost specialized terms and brands for preset-backed Deepgram usage. */
9
- keyterm?: string;
10
8
  /** Accepts any additional properties */
11
9
  [key: string]: any;
12
10
  }
@@ -10,7 +10,7 @@ export interface DeepgramAsrParams {
10
10
  model?: string | null;
11
11
  /** Language code for speech recognition */
12
12
  language?: string | null;
13
- /** Boost specialized terms and brands */
13
+ /** Boost specialized terms and brands for Deepgram. */
14
14
  keyterm?: string | null;
15
15
  /** Accepts any additional properties */
16
16
  [key: string]: any;
@@ -2,7 +2,7 @@
2
2
  * OpenAI TTS configuration parameters.
3
3
  */
4
4
  export interface OpenAiTtsParams {
5
- /** OpenAI API key. Optional for preset-backed OpenAI TTS usage. */
5
+ /** OpenAI API key. Optional for Agora-managed OpenAI TTS usage. */
6
6
  api_key?: string;
7
7
  /** Endpoint URL for the OpenAI TTS service. */
8
8
  base_url?: string;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "v2.1.1";
1
+ export declare const SDK_VERSION = "v2.2.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "v2.1.1";
1
+ export const SDK_VERSION = "v2.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-agents",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "private": false,
5
5
  "repository": "github:AgoraIO/agora-agents-ts",
6
6
  "type": "commonjs",