agora-agents 2.5.0 → 2.6.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.
Files changed (105) hide show
  1. package/dist/cjs/AgoraPoolClient.js +39 -1
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/agentkit/Agent.d.ts +6 -6
  4. package/dist/cjs/agentkit/Agent.js +4 -3
  5. package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +26 -0
  6. package/dist/cjs/agentkit/index.d.ts +8 -8
  7. package/dist/cjs/agentkit/index.js +6 -2
  8. package/dist/cjs/agentkit/region-vendors.d.ts +3 -1
  9. package/dist/cjs/agentkit/types.d.ts +8 -4
  10. package/dist/cjs/agentkit/vendors/base.d.ts +11 -1
  11. package/dist/cjs/agentkit/vendors/base.js +18 -2
  12. package/dist/cjs/agentkit/vendors/cn.d.ts +8 -0
  13. package/dist/cjs/agentkit/vendors/cn.js +9 -3
  14. package/dist/cjs/agentkit/vendors/mllm.d.ts +99 -1
  15. package/dist/cjs/agentkit/vendors/mllm.js +68 -1
  16. package/dist/cjs/agentkit/vendors/stt.d.ts +15 -5
  17. package/dist/cjs/agentkit/vendors/stt.js +14 -7
  18. package/dist/cjs/agentkit/vendors/tts.d.ts +19 -0
  19. package/dist/cjs/agentkit/vendors/tts.js +16 -1
  20. package/dist/cjs/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.d.ts +9 -0
  21. package/dist/cjs/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.js +6 -0
  22. package/dist/cjs/api/resources/agents/client/Client.js +17 -1
  23. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +49 -4
  24. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +9 -0
  25. package/dist/cjs/api/types/AresAsr.d.ts +2 -0
  26. package/dist/cjs/api/types/AssemblyAiAsrParams.d.ts +1 -1
  27. package/dist/cjs/api/types/FengmingAsr.d.ts +3 -2
  28. package/dist/cjs/api/types/FengmingAsrParams.d.ts +4 -0
  29. package/dist/cjs/api/types/FengmingAsrParams.js +3 -0
  30. package/dist/cjs/api/types/Llm.d.ts +12 -0
  31. package/dist/cjs/api/types/LlmTool.d.ts +14 -0
  32. package/dist/cjs/api/types/LlmTool.js +3 -0
  33. package/dist/cjs/api/types/LlmToolExecution.d.ts +9 -0
  34. package/dist/cjs/api/types/LlmToolExecution.js +3 -0
  35. package/dist/cjs/api/types/LlmToolFunction.d.ts +28 -0
  36. package/dist/cjs/api/types/LlmToolFunction.js +3 -0
  37. package/dist/cjs/api/types/LlmToolServer.d.ts +42 -0
  38. package/dist/cjs/api/types/LlmToolServer.js +12 -0
  39. package/dist/cjs/api/types/Mllm.d.ts +4 -0
  40. package/dist/cjs/api/types/Mllm.js +2 -0
  41. package/dist/cjs/api/types/SpeechmaticsAsrParams.d.ts +12 -3
  42. package/dist/cjs/api/types/Tts.d.ts +4 -1
  43. package/dist/cjs/api/types/TypecastTts.d.ts +9 -0
  44. package/dist/cjs/api/types/TypecastTts.js +3 -0
  45. package/dist/cjs/api/types/TypecastTtsParams.d.ts +13 -0
  46. package/dist/cjs/api/types/TypecastTtsParams.js +3 -0
  47. package/dist/cjs/api/types/index.d.ts +7 -0
  48. package/dist/cjs/api/types/index.js +7 -0
  49. package/dist/cjs/index.d.ts +2 -2
  50. package/dist/cjs/index.js +7 -3
  51. package/dist/cjs/version.d.ts +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/esm/AgoraPoolClient.mjs +40 -2
  54. package/dist/esm/BaseClient.mjs +2 -2
  55. package/dist/esm/agentkit/Agent.d.mts +6 -6
  56. package/dist/esm/agentkit/Agent.mjs +4 -3
  57. package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +26 -0
  58. package/dist/esm/agentkit/index.d.mts +8 -8
  59. package/dist/esm/agentkit/index.mjs +3 -3
  60. package/dist/esm/agentkit/region-vendors.d.mts +3 -1
  61. package/dist/esm/agentkit/types.d.mts +8 -4
  62. package/dist/esm/agentkit/vendors/base.d.mts +11 -1
  63. package/dist/esm/agentkit/vendors/base.mjs +16 -1
  64. package/dist/esm/agentkit/vendors/cn.d.mts +8 -0
  65. package/dist/esm/agentkit/vendors/cn.mjs +9 -3
  66. package/dist/esm/agentkit/vendors/mllm.d.mts +99 -1
  67. package/dist/esm/agentkit/vendors/mllm.mjs +66 -1
  68. package/dist/esm/agentkit/vendors/stt.d.mts +15 -5
  69. package/dist/esm/agentkit/vendors/stt.mjs +14 -7
  70. package/dist/esm/agentkit/vendors/tts.d.mts +19 -0
  71. package/dist/esm/agentkit/vendors/tts.mjs +14 -0
  72. package/dist/esm/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.d.mts +9 -0
  73. package/dist/esm/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.mjs +6 -0
  74. package/dist/esm/api/resources/agents/client/Client.mjs +17 -1
  75. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +49 -4
  76. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +9 -0
  77. package/dist/esm/api/types/AresAsr.d.mts +2 -0
  78. package/dist/esm/api/types/AssemblyAiAsrParams.d.mts +1 -1
  79. package/dist/esm/api/types/FengmingAsr.d.mts +3 -2
  80. package/dist/esm/api/types/FengmingAsrParams.d.mts +4 -0
  81. package/dist/esm/api/types/FengmingAsrParams.mjs +2 -0
  82. package/dist/esm/api/types/Llm.d.mts +12 -0
  83. package/dist/esm/api/types/LlmTool.d.mts +14 -0
  84. package/dist/esm/api/types/LlmTool.mjs +2 -0
  85. package/dist/esm/api/types/LlmToolExecution.d.mts +9 -0
  86. package/dist/esm/api/types/LlmToolExecution.mjs +2 -0
  87. package/dist/esm/api/types/LlmToolFunction.d.mts +28 -0
  88. package/dist/esm/api/types/LlmToolFunction.mjs +2 -0
  89. package/dist/esm/api/types/LlmToolServer.d.mts +42 -0
  90. package/dist/esm/api/types/LlmToolServer.mjs +9 -0
  91. package/dist/esm/api/types/Mllm.d.mts +4 -0
  92. package/dist/esm/api/types/Mllm.mjs +2 -0
  93. package/dist/esm/api/types/SpeechmaticsAsrParams.d.mts +12 -3
  94. package/dist/esm/api/types/Tts.d.mts +4 -1
  95. package/dist/esm/api/types/TypecastTts.d.mts +9 -0
  96. package/dist/esm/api/types/TypecastTts.mjs +2 -0
  97. package/dist/esm/api/types/TypecastTtsParams.d.mts +13 -0
  98. package/dist/esm/api/types/TypecastTtsParams.mjs +2 -0
  99. package/dist/esm/api/types/index.d.mts +7 -0
  100. package/dist/esm/api/types/index.mjs +7 -0
  101. package/dist/esm/index.d.mts +2 -2
  102. package/dist/esm/index.mjs +3 -3
  103. package/dist/esm/version.d.mts +1 -1
  104. package/dist/esm/version.mjs +1 -1
  105. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  * Clean type aliases for the Agora Conversational AI SDK.
3
3
  * These provide shorter, more intuitive names for the verbose Fern-generated types.
4
4
  */
5
- import type { AgentThinkAgentManagementResponse, AmazonTtsParams as AmazonTtsParamsType, AmazonTts as AmazonTtsType, Asr, AsrLanguage, CartesiaTtsParams as CartesiaTtsParamsType, CartesiaTts as CartesiaTtsType, ElevenLabsTtsParams as ElevenLabsTtsParamsType, ElevenLabsTts as ElevenLabsTtsType, FishAudioTtsParams as FishAudioTtsParamsType, FishAudioTts as FishAudioTtsType, GenericHttpTtsParams as GenericTtsParamsType, GenericHttpTts as GenericTtsType, GetAgentsResponse, GetHistoryAgentsResponse, GetTurnsAgentsResponse, GoogleTtsParams as GoogleTtsParamsType, GoogleTts as GoogleTtsType, GradiumTtsParams as GradiumTtsParamsType, GradiumTts as GradiumTtsType, HumeAiTtsParams as HumeAiTtsParamsType, HumeAiTts as HumeAiTtsType, ListAgentsResponse, Llm, MicrosoftTtsParams as MicrosoftTtsParamsType, MicrosoftTts as MicrosoftTtsType, MinimaxTtsParams as MinimaxTtsParamsType, MinimaxTts as MinimaxTtsType, MistralTtsParams as MistralTtsParamsType, MistralTts as MistralTtsType, Mllm, MllmTurnDetection, MllmTurnDetection as MllmTurnDetectionNS, MurfTtsParams as MurfTtsParamsType, MurfTts as MurfTtsType, OpenAiTtsParams as OpenAiTtsParamsType, OpenAiTts as OpenAiTtsType, RimeTtsParams as RimeTtsParamsType, RimeTts as RimeTtsType, SarvamTtsParams as SarvamTtsParamsType, SarvamTts as SarvamTtsType, SpatiusAvatarParams as SpatiusAvatarParamsType, SpeakAgentsRequest, StartAgentsRequest, Tts, UpdateAgentsRequest, XAiAsrParams as XAiAsrParamsType, XAiAsr as XAiAsrType, XAiTtsParams as XAiTtsParamsType, XAiTts as XAiTtsType } from "../api/index.mjs";
5
+ import type { AgentThinkAgentManagementResponse, AmazonTtsParams as AmazonTtsParamsType, AmazonTts as AmazonTtsType, Asr, AsrLanguage, CartesiaTtsParams as CartesiaTtsParamsType, CartesiaTts as CartesiaTtsType, ElevenLabsTtsParams as ElevenLabsTtsParamsType, ElevenLabsTts as ElevenLabsTtsType, FishAudioTtsParams as FishAudioTtsParamsType, FishAudioTts as FishAudioTtsType, GenericHttpTtsParams as GenericTtsParamsType, GenericHttpTts as GenericTtsType, GetAgentsResponse, GetHistoryAgentsResponse, GetTurnsAgentsResponse, GoogleTtsParams as GoogleTtsParamsType, GoogleTts as GoogleTtsType, GradiumTtsParams as GradiumTtsParamsType, GradiumTts as GradiumTtsType, HumeAiTtsParams as HumeAiTtsParamsType, HumeAiTts as HumeAiTtsType, ListAgentsResponse, Llm, MicrosoftTtsParams as MicrosoftTtsParamsType, MicrosoftTts as MicrosoftTtsType, MinimaxTtsParams as MinimaxTtsParamsType, MinimaxTts as MinimaxTtsType, MistralTtsParams as MistralTtsParamsType, MistralTts as MistralTtsType, Mllm, MllmTurnDetection, MllmTurnDetection as MllmTurnDetectionNS, MurfTtsParams as MurfTtsParamsType, MurfTts as MurfTtsType, OpenAiTtsParams as OpenAiTtsParamsType, OpenAiTts as OpenAiTtsType, RimeTtsParams as RimeTtsParamsType, RimeTts as RimeTtsType, SarvamTtsParams as SarvamTtsParamsType, SarvamTts as SarvamTtsType, SpatiusAvatarParams as SpatiusAvatarParamsType, SpeakAgentsRequest, StartAgentsRequest, Tts, TypecastTtsParams as TypecastTtsParamsType, TypecastTts as TypecastTtsType, UpdateAgentsRequest, XAiAsrParams as XAiAsrParamsType, XAiAsr as XAiAsrType, XAiTtsParams as XAiTtsParamsType, XAiTts as XAiTtsType } from "../api/index.mjs";
6
6
  import type { AgentThinkAgentManagementRequest } from "../api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.mjs";
7
7
  import type { PresetInput } from "./presets.mjs";
8
8
  /** LLM request style (openai, gemini, anthropic, dify) */
@@ -81,7 +81,7 @@ export type AsrVendorName = string;
81
81
  export type TtsConfig = Tts;
82
82
  /** MLLM (Multimodal LLM) configuration */
83
83
  export type MllmConfig = Mllm;
84
- /** MLLM vendor (openai, gemini, vertexai, xai) */
84
+ /** MLLM wire vendor name (openai, azure, gemini, vertexai, xai, qwen_omni) */
85
85
  export type MllmVendor = Mllm.Vendor;
86
86
  /** Avatar configuration */
87
87
  export type AvatarConfig = StartAgentsRequest.Properties.Avatar;
@@ -409,7 +409,9 @@ export type LlmConfig = (BaseLlmConfig & {
409
409
  */
410
410
  export interface SpeechmaticsParams {
411
411
  /** Speechmatics API key for authentication (required) */
412
- api_key: string;
412
+ key: string;
413
+ /** @deprecated The REST API expects `key`; use `key` instead. */
414
+ api_key?: string;
413
415
  /** Language code for transcription (e.g., 'en', 'es', 'fr') (required) */
414
416
  language: string;
415
417
  /** Speechmatics streaming WebSocket URL */
@@ -510,7 +512,7 @@ export interface AssemblyAiParams {
510
512
  /** Language code */
511
513
  language?: string;
512
514
  /** AssemblyAI streaming WebSocket URL */
513
- uri?: string;
515
+ ws_url?: string;
514
516
  /** Additional AssemblyAI-specific parameters */
515
517
  [key: string]: unknown;
516
518
  }
@@ -572,5 +574,7 @@ export type SarvamTts = SarvamTtsType;
572
574
  export type SarvamTtsParams = SarvamTtsParamsType;
573
575
  export type XAiTts = XAiTtsType;
574
576
  export type XAiTtsParams = XAiTtsParamsType;
577
+ export type TypecastTts = TypecastTtsType;
578
+ export type TypecastTtsParams = TypecastTtsParamsType;
575
579
  export type SpatiusAvatarParams = SpatiusAvatarParamsType;
576
580
  export {};
@@ -163,12 +163,22 @@ export declare abstract class BaseCNSTT extends ScopedBaseSTT<"cn"> {
163
163
  /**
164
164
  * Base class for MLLM (Multimodal Large Language Model) vendors.
165
165
  */
166
- export declare abstract class BaseMLLM {
166
+ declare abstract class ScopedBaseMLLM<TScope extends VendorScope> {
167
+ readonly areaScope: TScope;
168
+ constructor(areaScope: TScope);
167
169
  /**
168
170
  * Converts the vendor configuration to the Agora API format.
169
171
  */
170
172
  abstract toConfig(): MllmConfig;
171
173
  }
174
+ /** Base class for global MLLM vendors. */
175
+ export declare abstract class BaseMLLM extends ScopedBaseMLLM<"global"> {
176
+ constructor();
177
+ }
178
+ /** Base class for Chinese mainland MLLM vendors. */
179
+ export declare abstract class BaseCNMLLM extends ScopedBaseMLLM<"cn"> {
180
+ constructor();
181
+ }
172
182
  /**
173
183
  * Base class for Avatar vendors with required sample rate.
174
184
  * @template RequiredSR - Required sample rate literal type
@@ -104,7 +104,22 @@ export class BaseCNSTT extends ScopedBaseSTT {
104
104
  /**
105
105
  * Base class for MLLM (Multimodal Large Language Model) vendors.
106
106
  */
107
- export class BaseMLLM {
107
+ class ScopedBaseMLLM {
108
+ constructor(areaScope) {
109
+ this.areaScope = areaScope;
110
+ }
111
+ }
112
+ /** Base class for global MLLM vendors. */
113
+ export class BaseMLLM extends ScopedBaseMLLM {
114
+ constructor() {
115
+ super("global");
116
+ }
117
+ }
118
+ /** Base class for Chinese mainland MLLM vendors. */
119
+ export class BaseCNMLLM extends ScopedBaseMLLM {
120
+ constructor() {
121
+ super("cn");
122
+ }
108
123
  }
109
124
  /**
110
125
  * Base class for Avatar vendors with required sample rate.
@@ -1,6 +1,14 @@
1
1
  import type { AvatarConfig, LlmConfig, SttConfig, TtsConfig } from "../types.mjs";
2
2
  import { BaseCNAvatar, BaseCNLLM, BaseCNSTT, BaseCNTTS, type BaseLlmOptions } from "./base.mjs";
3
+ export interface FengmingSTTOptions {
4
+ /** Hotwords that improve recognition accuracy */
5
+ keywords?: string[];
6
+ /** Additional vendor-specific parameters */
7
+ additionalParams?: Record<string, unknown>;
8
+ }
3
9
  export declare class FengmingSTT extends BaseCNSTT {
10
+ private readonly options;
11
+ constructor(options?: FengmingSTTOptions);
4
12
  toConfig(): SttConfig;
5
13
  }
6
14
  export interface MicrosoftCNSTTOptions {
@@ -5,10 +5,16 @@ function requireString(value, field, vendor) {
5
5
  }
6
6
  }
7
7
  export class FengmingSTT extends BaseCNSTT {
8
+ constructor(options = {}) {
9
+ super();
10
+ this.options = options;
11
+ }
8
12
  toConfig() {
9
- return {
10
- vendor: "fengming",
11
- };
13
+ const { keywords, additionalParams } = this.options;
14
+ const hasParams = keywords !== undefined || (additionalParams !== undefined && Object.keys(additionalParams).length > 0);
15
+ return Object.assign({ vendor: "fengming" }, (hasParams && {
16
+ params: Object.assign(Object.assign({}, additionalParams), (keywords !== undefined && { keywords })),
17
+ }));
12
18
  }
13
19
  }
14
20
  export class MicrosoftCNSTT extends BaseCNSTT {
@@ -6,7 +6,7 @@
6
6
  * sets `mllm.enable: true`.
7
7
  */
8
8
  import type { MllmConfig, MllmTurnDetectionConfig } from "../types.mjs";
9
- import { BaseMLLM } from "./base.mjs";
9
+ import { BaseCNMLLM, BaseMLLM } from "./base.mjs";
10
10
  /**
11
11
  * Constructor options for OpenAI Realtime API.
12
12
  */
@@ -56,6 +56,59 @@ export declare class OpenAIRealtime extends BaseMLLM {
56
56
  constructor(options: OpenAIRealtimeOptions);
57
57
  toConfig(): MllmConfig;
58
58
  }
59
+ /** Parameters accepted by Azure OpenAI Realtime. */
60
+ export interface AzureOpenAIRealtimeParams {
61
+ /** System instructions that define agent behavior */
62
+ instructions?: string;
63
+ /** Model or deployment model identifier */
64
+ model?: string;
65
+ /** Voice identifier for audio output */
66
+ voice?: string;
67
+ }
68
+ /** Constructor options for Azure OpenAI Realtime API. */
69
+ export interface AzureOpenAIRealtimeOptions {
70
+ /** Azure OpenAI API key */
71
+ apiKey: string;
72
+ /** Azure OpenAI Realtime WebSocket URL, including deployment routing when required */
73
+ url: string;
74
+ /** Model or deployment model identifier */
75
+ model?: string;
76
+ /** Voice identifier for audio output */
77
+ voice?: string;
78
+ /** System instructions that define agent behavior */
79
+ instructions?: string;
80
+ /** Number of conversation history messages cached by the MLLM */
81
+ maxHistory?: number;
82
+ /** Agent greeting message */
83
+ greetingMessage?: string;
84
+ /** Output modalities (e.g., ['text', 'audio']) */
85
+ outputModalities?: string[];
86
+ /** Conversation messages for short-term memory */
87
+ messages?: Record<string, unknown>[];
88
+ /** Azure Realtime model parameters */
89
+ params?: AzureOpenAIRealtimeParams;
90
+ /** Required MLLM turn detection configuration. Overrides top-level turn_detection. */
91
+ turnDetection: MllmTurnDetectionConfig;
92
+ }
93
+ /**
94
+ * Azure OpenAI Realtime MLLM vendor for global deployments.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const agent = new Agent({ client }).withMllm(new AzureOpenAIRealtime({
99
+ * apiKey: process.env.AZURE_OPENAI_API_KEY,
100
+ * url: 'wss://example.openai.azure.com/openai/realtime',
101
+ * model: 'gpt-4o-realtime-preview',
102
+ * maxHistory: 32,
103
+ * turnDetection: { mode: 'server_vad' },
104
+ * }));
105
+ * ```
106
+ */
107
+ export declare class AzureOpenAIRealtime extends BaseMLLM {
108
+ private readonly options;
109
+ constructor(options: AzureOpenAIRealtimeOptions);
110
+ toConfig(): MllmConfig;
111
+ }
59
112
  /**
60
113
  * Constructor options for Google Gemini Live (direct API, non-Vertex AI).
61
114
  */
@@ -225,3 +278,48 @@ export declare class XaiGrok extends BaseMLLM {
225
278
  constructor(options: XaiGrokOptions);
226
279
  toConfig(): MllmConfig;
227
280
  }
281
+ /** Constructor options for Alibaba Cloud Qwen Omni Realtime. */
282
+ export interface QwenOmniOptions {
283
+ /** Alibaba Cloud DashScope API key */
284
+ apiKey: string;
285
+ /** Qwen Omni model identifier */
286
+ model: string;
287
+ /** Qwen Omni Realtime WebSocket URL */
288
+ url: string;
289
+ /** Voice identifier for audio output */
290
+ voice?: string;
291
+ /** System instructions that define agent behavior */
292
+ instructions?: string;
293
+ /** Agent greeting message */
294
+ greetingMessage?: string;
295
+ /** Message played on failure */
296
+ failureMessage?: string;
297
+ /** Input modalities (e.g., ['audio'], ['audio', 'text']) */
298
+ inputModalities?: string[];
299
+ /** Output modalities (e.g., ['text', 'audio']) */
300
+ outputModalities?: string[];
301
+ /** Conversation messages for short-term memory */
302
+ messages?: Record<string, unknown>[];
303
+ /** Additional Qwen Omni parameters */
304
+ params?: Record<string, unknown>;
305
+ /** MLLM turn detection configuration. Overrides top-level turn_detection. */
306
+ turnDetection?: MllmTurnDetectionConfig;
307
+ }
308
+ /**
309
+ * Alibaba Cloud Qwen Omni Realtime MLLM vendor for Chinese mainland deployments.
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * const agent = new Agent({ client }).withMllm(new QwenOmni({
314
+ * apiKey: process.env.DASHSCOPE_API_KEY,
315
+ * model: 'qwen3.5-omni-plus-realtime',
316
+ * url: 'wss://dashscope.aliyuncs.com/api-ws/v1/realtime',
317
+ * greetingMessage: '你好,有什么可以帮你?',
318
+ * }));
319
+ * ```
320
+ */
321
+ export declare class QwenOmni extends BaseCNMLLM {
322
+ private readonly options;
323
+ constructor(options: QwenOmniOptions);
324
+ toConfig(): MllmConfig;
325
+ }
@@ -5,7 +5,17 @@
5
5
  * ASR → LLM → TTS pipeline. Calling `agent.withMllm(vendor)` automatically
6
6
  * sets `mllm.enable: true`.
7
7
  */
8
- import { BaseMLLM } from "./base.mjs";
8
+ import { BaseCNMLLM, BaseMLLM } from "./base.mjs";
9
+ function requireString(value, field, vendor) {
10
+ if (typeof value !== "string" || value.length === 0) {
11
+ throw new Error(`${vendor} requires ${field}`);
12
+ }
13
+ }
14
+ function requireObject(value, field, vendor) {
15
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
16
+ throw new Error(`${vendor} requires ${field}`);
17
+ }
18
+ }
9
19
  /**
10
20
  * OpenAI Realtime API MLLM vendor.
11
21
  *
@@ -39,6 +49,35 @@ export class OpenAIRealtime extends BaseMLLM {
39
49
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ vendor: "openai", api_key: apiKey, url: url || "wss://api.openai.com/v1/realtime" }, (hasParams && { params: mergedParams })), (greetingMessage && { greeting_message: greetingMessage })), (inputModalities && { input_modalities: inputModalities })), (outputModalities && { output_modalities: outputModalities })), (messages && { messages })), (this.options.failureMessage && { failure_message: this.options.failureMessage })), (turnDetection && { turn_detection: turnDetection }));
40
50
  }
41
51
  }
52
+ /**
53
+ * Azure OpenAI Realtime MLLM vendor for global deployments.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const agent = new Agent({ client }).withMllm(new AzureOpenAIRealtime({
58
+ * apiKey: process.env.AZURE_OPENAI_API_KEY,
59
+ * url: 'wss://example.openai.azure.com/openai/realtime',
60
+ * model: 'gpt-4o-realtime-preview',
61
+ * maxHistory: 32,
62
+ * turnDetection: { mode: 'server_vad' },
63
+ * }));
64
+ * ```
65
+ */
66
+ export class AzureOpenAIRealtime extends BaseMLLM {
67
+ constructor(options) {
68
+ super();
69
+ requireString(options.apiKey, "apiKey", "AzureOpenAIRealtime");
70
+ requireString(options.url, "url", "AzureOpenAIRealtime");
71
+ requireObject(options.turnDetection, "turnDetection", "AzureOpenAIRealtime");
72
+ this.options = options;
73
+ }
74
+ toConfig() {
75
+ const { apiKey, url, model, voice, instructions, maxHistory, greetingMessage, outputModalities, messages, params, turnDetection, } = this.options;
76
+ const mergedParams = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((params === null || params === void 0 ? void 0 : params.model) !== undefined && { model: params.model })), ((params === null || params === void 0 ? void 0 : params.voice) !== undefined && { voice: params.voice })), ((params === null || params === void 0 ? void 0 : params.instructions) !== undefined && { instructions: params.instructions })), (model !== undefined && { model })), (voice !== undefined && { voice })), (instructions !== undefined && { instructions }));
77
+ const hasParams = Object.keys(mergedParams).length > 0;
78
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ vendor: "azure", api_key: apiKey, url }, (hasParams && { params: mergedParams })), (maxHistory !== undefined && { max_history: maxHistory })), (greetingMessage && { greeting_message: greetingMessage })), (outputModalities && { output_modalities: outputModalities })), (messages && { messages })), { turn_detection: turnDetection });
79
+ }
80
+ }
42
81
  /**
43
82
  * Google Gemini Live MLLM vendor (direct API, non-Vertex AI).
44
83
  *
@@ -125,3 +164,29 @@ export class XaiGrok extends BaseMLLM {
125
164
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ vendor: "xai", api_key: apiKey, url }, (messages && { messages })), { params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), (voice && { voice })), (language && { language })), (sampleRate !== undefined && { sample_rate: sampleRate })) }), (inputModalities && { input_modalities: inputModalities })), (outputModalities && { output_modalities: outputModalities })), (greetingMessage && { greeting_message: greetingMessage })), (failureMessage && { failure_message: failureMessage })), (turnDetection && { turn_detection: turnDetection }));
126
165
  }
127
166
  }
167
+ /**
168
+ * Alibaba Cloud Qwen Omni Realtime MLLM vendor for Chinese mainland deployments.
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const agent = new Agent({ client }).withMllm(new QwenOmni({
173
+ * apiKey: process.env.DASHSCOPE_API_KEY,
174
+ * model: 'qwen3.5-omni-plus-realtime',
175
+ * url: 'wss://dashscope.aliyuncs.com/api-ws/v1/realtime',
176
+ * greetingMessage: '你好,有什么可以帮你?',
177
+ * }));
178
+ * ```
179
+ */
180
+ export class QwenOmni extends BaseCNMLLM {
181
+ constructor(options) {
182
+ super();
183
+ requireString(options.apiKey, "apiKey", "QwenOmni");
184
+ requireString(options.model, "model", "QwenOmni");
185
+ requireString(options.url, "url", "QwenOmni");
186
+ this.options = options;
187
+ }
188
+ toConfig() {
189
+ const { apiKey, model, url, voice, instructions, greetingMessage, failureMessage, inputModalities, outputModalities, messages, params, turnDetection, } = this.options;
190
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ vendor: "qwen_omni", api_key: apiKey, url, params: Object.assign(Object.assign(Object.assign(Object.assign({}, params), { model }), (voice !== undefined && { voice })), (instructions !== undefined && { instructions })) }, (greetingMessage && { greeting_message: greetingMessage })), (failureMessage && { failure_message: failureMessage })), (inputModalities && { input_modalities: inputModalities })), (outputModalities && { output_modalities: outputModalities })), (messages && { messages })), (turnDetection && { turn_detection: turnDetection }));
191
+ }
192
+ }
@@ -7,9 +7,7 @@ import { BaseSTT } from "./base.mjs";
7
7
  /**
8
8
  * Constructor options for Speechmatics STT.
9
9
  */
10
- export interface SpeechmaticsSTTOptions {
11
- /** Speechmatics API key */
12
- apiKey: string;
10
+ interface SpeechmaticsSTTCommonOptions {
13
11
  /** Language code (e.g., 'en', 'es', 'fr') */
14
12
  language: string;
15
13
  /** Model name */
@@ -19,13 +17,23 @@ export interface SpeechmaticsSTTOptions {
19
17
  /** Additional vendor-specific parameters */
20
18
  additionalParams?: Record<string, unknown>;
21
19
  }
20
+ export type SpeechmaticsSTTOptions = SpeechmaticsSTTCommonOptions & ({
21
+ /** Speechmatics API key */
22
+ key: string;
23
+ /** @deprecated Use `key` instead. This alias is normalized to the REST API's `key` field. */
24
+ apiKey?: string;
25
+ } | {
26
+ key?: undefined;
27
+ /** @deprecated Use `key` instead. This alias is normalized to the REST API's `key` field. */
28
+ apiKey: string;
29
+ });
22
30
  /**
23
31
  * Speechmatics STT vendor.
24
32
  *
25
33
  * @example
26
34
  * ```typescript
27
35
  * const stt = new SpeechmaticsSTT({
28
- * apiKey: process.env.SPEECHMATICS_API_KEY,
36
+ * key: process.env.SPEECHMATICS_API_KEY,
29
37
  * language: 'en',
30
38
  * });
31
39
  * ```
@@ -216,7 +224,7 @@ export interface AssemblyAISTTOptions {
216
224
  /** Language code */
217
225
  language: string;
218
226
  /** AssemblyAI streaming WebSocket URL */
219
- uri?: string;
227
+ ws_url?: string;
220
228
  /** Additional vendor-specific parameters */
221
229
  additionalParams?: Record<string, unknown>;
222
230
  }
@@ -240,6 +248,8 @@ export declare class AssemblyAISTT extends BaseSTT {
240
248
  * Constructor options for Agora ARES STT.
241
249
  */
242
250
  export interface AresSTTOptions {
251
+ /** Hotwords that improve recognition accuracy */
252
+ keywords?: string[];
243
253
  /** Additional vendor-specific parameters */
244
254
  additionalParams?: Record<string, unknown>;
245
255
  }
@@ -17,7 +17,7 @@ function isDeepgramManagedModel(model) {
17
17
  * @example
18
18
  * ```typescript
19
19
  * const stt = new SpeechmaticsSTT({
20
- * apiKey: process.env.SPEECHMATICS_API_KEY,
20
+ * key: process.env.SPEECHMATICS_API_KEY,
21
21
  * language: 'en',
22
22
  * });
23
23
  * ```
@@ -28,10 +28,14 @@ export class SpeechmaticsSTT extends BaseSTT {
28
28
  this.options = options;
29
29
  }
30
30
  toConfig() {
31
- const { apiKey, language, model, uri, additionalParams } = this.options;
31
+ const { key, apiKey, language, model, uri, additionalParams } = this.options;
32
+ const wireKey = key !== null && key !== void 0 ? key : apiKey;
33
+ _requireString(wireKey, "key", "SpeechmaticsSTT");
34
+ const params = Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { key: wireKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri }));
35
+ delete params.api_key;
32
36
  return {
33
37
  vendor: "speechmatics",
34
- params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri })),
38
+ params,
35
39
  };
36
40
  }
37
41
  }
@@ -188,10 +192,10 @@ export class AssemblyAISTT extends BaseSTT {
188
192
  this.options = options;
189
193
  }
190
194
  toConfig() {
191
- const { apiKey, language, uri, additionalParams } = this.options;
195
+ const { apiKey, language, ws_url, additionalParams } = this.options;
192
196
  return {
193
197
  vendor: "assemblyai",
194
- params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (uri && { uri })),
198
+ params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (ws_url && { ws_url })),
195
199
  };
196
200
  }
197
201
  }
@@ -209,8 +213,11 @@ export class AresSTT extends BaseSTT {
209
213
  this.options = options;
210
214
  }
211
215
  toConfig() {
212
- const { additionalParams } = this.options;
213
- return Object.assign({ vendor: "ares" }, (additionalParams && Object.keys(additionalParams).length > 0 && { params: additionalParams }));
216
+ const { keywords, additionalParams } = this.options;
217
+ const hasParams = keywords !== undefined || (additionalParams !== undefined && Object.keys(additionalParams).length > 0);
218
+ return Object.assign({ vendor: "ares" }, (hasParams && {
219
+ params: Object.assign(Object.assign({}, additionalParams), (keywords !== undefined && { keywords })),
220
+ }));
214
221
  }
215
222
  }
216
223
  /**
@@ -322,6 +322,25 @@ export declare class MistralTTS extends BaseTTS {
322
322
  constructor(options: MistralTTSOptions);
323
323
  toConfig(): TtsConfig;
324
324
  }
325
+ /** Constructor options for Typecast TTS. */
326
+ export interface TypecastTTSOptions {
327
+ /** Typecast API key */
328
+ apiKey: string;
329
+ /** Typecast voice identifier */
330
+ voiceId: string;
331
+ /** Typecast TTS model name (e.g., 'ssfm-v30') */
332
+ model: string;
333
+ /** Additional vendor-specific parameters */
334
+ additionalParams?: Record<string, unknown>;
335
+ /** Skip patterns for bracketed content */
336
+ skipPatterns?: number[];
337
+ }
338
+ /** Typecast TTS vendor. */
339
+ export declare class TypecastTTS extends BaseTTS {
340
+ private readonly options;
341
+ constructor(options: TypecastTTSOptions);
342
+ toConfig(): TtsConfig;
343
+ }
325
344
  /**
326
345
  * Constructor options for Hume AI TTS.
327
346
  */
@@ -211,6 +211,20 @@ export class MistralTTS extends BaseTTS {
211
211
  return Object.assign({ vendor: "mistral", params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (model !== undefined && { model })), (voice !== undefined && { voice })) }, (skipPatterns && { skip_patterns: skipPatterns }));
212
212
  }
213
213
  }
214
+ /** Typecast TTS vendor. */
215
+ export class TypecastTTS extends BaseTTS {
216
+ constructor(options) {
217
+ super();
218
+ requireString(options.apiKey, "apiKey", "TypecastTTS");
219
+ requireString(options.voiceId, "voiceId", "TypecastTTS");
220
+ requireString(options.model, "model", "TypecastTTS");
221
+ this.options = options;
222
+ }
223
+ toConfig() {
224
+ const { apiKey, voiceId, model, additionalParams, skipPatterns } = this.options;
225
+ return Object.assign({ vendor: "typecast", params: Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, voice_id: voiceId, model }) }, (skipPatterns && { skip_patterns: skipPatterns }));
226
+ }
227
+ }
214
228
  /**
215
229
  * Hume AI TTS vendor.
216
230
  *
@@ -26,18 +26,21 @@ export interface AgentThinkAgentManagementRequest {
26
26
  * - `inject`: Inject the custom text instruction into the current turn without interrupting it.
27
27
  * - `interrupt`: Immediately interrupt the current flow and initiate a new round of dialogue.
28
28
  * - `ignore`: Ignore the request.
29
+ * - `append`: Do not interrupt the user. Wait for the user's ASR text to be sent to the LLM and for the resulting response to finish, then send the custom text instruction to the LLM.
29
30
  */
30
31
  on_listening_action?: AgentThinkAgentManagementRequest.OnListeningAction;
31
32
  /**
32
33
  * The action to take when the agent is in a thinking state:
33
34
  * - `interrupt`: Interrupt the current state and start a new conversation turn.
34
35
  * - `ignore`: Ignore the request.
36
+ * - `append`: Do not interrupt the current LLM inference. Allow the current turn to finish generating and playing its response first. After the current turn's LLM output is complete, send the queued custom text instruction to the LLM.
35
37
  */
36
38
  on_thinking_action?: AgentThinkAgentManagementRequest.OnThinkingAction;
37
39
  /**
38
40
  * The action to take when the agent is in a speaking state:
39
41
  * - `interrupt`: Interrupt the current state and start a new conversation turn.
40
42
  * - `ignore`: Ignore the request.
43
+ * - `append`: Do not interrupt the current TTS playback; the audio stream continues. After the current turn's LLM output is complete, send the custom text instruction directly to the LLM.
41
44
  */
42
45
  on_speaking_action?: AgentThinkAgentManagementRequest.OnSpeakingAction;
43
46
  /**
@@ -55,31 +58,37 @@ export declare namespace AgentThinkAgentManagementRequest {
55
58
  * - `inject`: Inject the custom text instruction into the current turn without interrupting it.
56
59
  * - `interrupt`: Immediately interrupt the current flow and initiate a new round of dialogue.
57
60
  * - `ignore`: Ignore the request.
61
+ * - `append`: Do not interrupt the user. Wait for the user's ASR text to be sent to the LLM and for the resulting response to finish, then send the custom text instruction to the LLM.
58
62
  */
59
63
  const OnListeningAction: {
60
64
  readonly Inject: "inject";
61
65
  readonly Interrupt: "interrupt";
62
66
  readonly Ignore: "ignore";
67
+ readonly Append: "append";
63
68
  };
64
69
  type OnListeningAction = (typeof OnListeningAction)[keyof typeof OnListeningAction];
65
70
  /**
66
71
  * The action to take when the agent is in a thinking state:
67
72
  * - `interrupt`: Interrupt the current state and start a new conversation turn.
68
73
  * - `ignore`: Ignore the request.
74
+ * - `append`: Do not interrupt the current LLM inference. Allow the current turn to finish generating and playing its response first. After the current turn's LLM output is complete, send the queued custom text instruction to the LLM.
69
75
  */
70
76
  const OnThinkingAction: {
71
77
  readonly Interrupt: "interrupt";
72
78
  readonly Ignore: "ignore";
79
+ readonly Append: "append";
73
80
  };
74
81
  type OnThinkingAction = (typeof OnThinkingAction)[keyof typeof OnThinkingAction];
75
82
  /**
76
83
  * The action to take when the agent is in a speaking state:
77
84
  * - `interrupt`: Interrupt the current state and start a new conversation turn.
78
85
  * - `ignore`: Ignore the request.
86
+ * - `append`: Do not interrupt the current TTS playback; the audio stream continues. After the current turn's LLM output is complete, send the custom text instruction directly to the LLM.
79
87
  */
80
88
  const OnSpeakingAction: {
81
89
  readonly Interrupt: "interrupt";
82
90
  readonly Ignore: "ignore";
91
+ readonly Append: "append";
83
92
  };
84
93
  type OnSpeakingAction = (typeof OnSpeakingAction)[keyof typeof OnSpeakingAction];
85
94
  }
@@ -6,28 +6,34 @@ export var AgentThinkAgentManagementRequest;
6
6
  * - `inject`: Inject the custom text instruction into the current turn without interrupting it.
7
7
  * - `interrupt`: Immediately interrupt the current flow and initiate a new round of dialogue.
8
8
  * - `ignore`: Ignore the request.
9
+ * - `append`: Do not interrupt the user. Wait for the user's ASR text to be sent to the LLM and for the resulting response to finish, then send the custom text instruction to the LLM.
9
10
  */
10
11
  AgentThinkAgentManagementRequest.OnListeningAction = {
11
12
  Inject: "inject",
12
13
  Interrupt: "interrupt",
13
14
  Ignore: "ignore",
15
+ Append: "append",
14
16
  };
15
17
  /**
16
18
  * The action to take when the agent is in a thinking state:
17
19
  * - `interrupt`: Interrupt the current state and start a new conversation turn.
18
20
  * - `ignore`: Ignore the request.
21
+ * - `append`: Do not interrupt the current LLM inference. Allow the current turn to finish generating and playing its response first. After the current turn's LLM output is complete, send the queued custom text instruction to the LLM.
19
22
  */
20
23
  AgentThinkAgentManagementRequest.OnThinkingAction = {
21
24
  Interrupt: "interrupt",
22
25
  Ignore: "ignore",
26
+ Append: "append",
23
27
  };
24
28
  /**
25
29
  * The action to take when the agent is in a speaking state:
26
30
  * - `interrupt`: Interrupt the current state and start a new conversation turn.
27
31
  * - `ignore`: Ignore the request.
32
+ * - `append`: Do not interrupt the current TTS playback; the audio stream continues. After the current turn's LLM output is complete, send the custom text instruction directly to the LLM.
28
33
  */
29
34
  AgentThinkAgentManagementRequest.OnSpeakingAction = {
30
35
  Interrupt: "interrupt",
31
36
  Ignore: "ignore",
37
+ Append: "append",
32
38
  };
33
39
  })(AgentThinkAgentManagementRequest || (AgentThinkAgentManagementRequest = {}));
@@ -24,6 +24,21 @@ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.
24
24
  import * as core from "../../../../core/index.mjs";
25
25
  import * as environments from "../../../../environments.mjs";
26
26
  import * as errors from "../../../../errors/index.mjs";
27
+ function normalizeSpeechmaticsCredential(body) {
28
+ var _a;
29
+ const asr = body.properties.asr;
30
+ if ((asr === null || asr === void 0 ? void 0 : asr.vendor) !== "speechmatics" || asr.params == null) {
31
+ return body;
32
+ }
33
+ const params = asr.params;
34
+ const wireKey = (_a = params.key) !== null && _a !== void 0 ? _a : params.api_key;
35
+ if (wireKey === undefined) {
36
+ return body;
37
+ }
38
+ const normalizedParams = Object.assign(Object.assign({}, params), { key: wireKey });
39
+ delete normalizedParams.api_key;
40
+ return Object.assign(Object.assign({}, body), { properties: Object.assign(Object.assign({}, body.properties), { asr: Object.assign(Object.assign({}, asr), { params: normalizedParams }) }) });
41
+ }
27
42
  export class AgentsClient {
28
43
  constructor(options) {
29
44
  this._options = normalizeClientOptions(options);
@@ -88,6 +103,7 @@ export class AgentsClient {
88
103
  return __awaiter(this, void 0, void 0, function* () {
89
104
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
90
105
  const { appid } = request, _body = __rest(request, ["appid"]);
106
+ const _normalizedBody = normalizeSpeechmaticsCredential(_body);
91
107
  const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders(Object.assign({ Authorization: yield this._getAuthorizationHeader() }, (yield this._getCustomAuthorizationHeaders()))), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
92
108
  const _response = yield core.fetcher({
93
109
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgoraEnvironment.Default, `v2/projects/${core.url.encodePathParam(appid)}/join`),
@@ -96,7 +112,7 @@ export class AgentsClient {
96
112
  contentType: "application/json",
97
113
  queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
98
114
  requestType: "json",
99
- body: _body,
115
+ body: _normalizedBody,
100
116
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
101
117
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
102
118
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,