agora-agents 2.4.0 → 2.6.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.
- package/dist/cjs/AgoraPoolClient.js +39 -1
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/agentkit/Agent.d.ts +4 -4
- package/dist/cjs/agentkit/Agent.js +2 -1
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +30 -0
- package/dist/cjs/agentkit/constants.d.ts +6 -0
- package/dist/cjs/agentkit/constants.js +6 -1
- package/dist/cjs/agentkit/index.d.ts +9 -9
- package/dist/cjs/agentkit/index.js +10 -3
- package/dist/cjs/agentkit/region-vendors.d.ts +5 -2
- package/dist/cjs/agentkit/types.d.ts +9 -3
- package/dist/cjs/agentkit/vendors/base.d.ts +11 -1
- package/dist/cjs/agentkit/vendors/base.js +18 -2
- package/dist/cjs/agentkit/vendors/cn.d.ts +8 -0
- package/dist/cjs/agentkit/vendors/cn.js +9 -3
- package/dist/cjs/agentkit/vendors/mllm.d.ts +100 -2
- package/dist/cjs/agentkit/vendors/mllm.js +69 -2
- package/dist/cjs/agentkit/vendors/stt.d.ts +3 -1
- package/dist/cjs/agentkit/vendors/stt.js +7 -4
- package/dist/cjs/agentkit/vendors/tts.d.ts +100 -9
- package/dist/cjs/agentkit/vendors/tts.js +85 -12
- package/dist/cjs/api/types/AresAsrParams.d.ts +6 -1
- package/dist/cjs/api/types/AssemblyAiAsrParams.d.ts +1 -1
- package/dist/cjs/api/types/FengmingAsr.d.ts +1 -2
- package/dist/cjs/api/types/FengmingAsrParams.d.ts +9 -0
- package/dist/cjs/api/types/{GenericTts.d.ts → GenericHttpTts.d.ts} +3 -3
- package/dist/cjs/api/types/{GenericTtsParams.d.ts → GenericHttpTtsParams.d.ts} +3 -3
- package/dist/cjs/api/types/GenericHttpTtsParams.js +3 -0
- package/dist/cjs/api/types/GradiumTts.d.ts +9 -0
- package/dist/cjs/api/types/GradiumTts.js +3 -0
- package/dist/cjs/api/types/GradiumTtsParams.d.ts +17 -0
- package/dist/cjs/api/types/GradiumTtsParams.js +3 -0
- package/dist/cjs/api/types/MistralTts.d.ts +9 -0
- package/dist/cjs/api/types/MistralTts.js +3 -0
- package/dist/cjs/api/types/MistralTtsParams.d.ts +13 -0
- package/dist/cjs/api/types/MistralTtsParams.js +3 -0
- package/dist/cjs/api/types/Mllm.d.ts +4 -0
- package/dist/cjs/api/types/Mllm.js +2 -0
- package/dist/cjs/api/types/RimeTts.d.ts +10 -0
- package/dist/cjs/api/types/RimeTts.js +9 -0
- package/dist/cjs/api/types/RimeTtsParams.d.ts +2 -2
- package/dist/cjs/api/types/Tts.d.ts +12 -3
- package/dist/cjs/api/types/TypecastTts.d.ts +9 -0
- package/dist/cjs/api/types/TypecastTts.js +3 -0
- package/dist/cjs/api/types/TypecastTtsParams.d.ts +13 -0
- package/dist/cjs/api/types/TypecastTtsParams.js +3 -0
- package/dist/cjs/api/types/index.d.ts +9 -2
- package/dist/cjs/api/types/index.js +9 -2
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +10 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/AgoraPoolClient.mjs +40 -2
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/agentkit/Agent.d.mts +4 -4
- package/dist/esm/agentkit/Agent.mjs +2 -1
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +31 -1
- package/dist/esm/agentkit/constants.d.mts +6 -0
- package/dist/esm/agentkit/constants.mjs +5 -0
- package/dist/esm/agentkit/index.d.mts +9 -9
- package/dist/esm/agentkit/index.mjs +4 -4
- package/dist/esm/agentkit/region-vendors.d.mts +5 -2
- package/dist/esm/agentkit/types.d.mts +9 -3
- package/dist/esm/agentkit/vendors/base.d.mts +11 -1
- package/dist/esm/agentkit/vendors/base.mjs +16 -1
- package/dist/esm/agentkit/vendors/cn.d.mts +8 -0
- package/dist/esm/agentkit/vendors/cn.mjs +9 -3
- package/dist/esm/agentkit/vendors/mllm.d.mts +100 -2
- package/dist/esm/agentkit/vendors/mllm.mjs +67 -2
- package/dist/esm/agentkit/vendors/stt.d.mts +3 -1
- package/dist/esm/agentkit/vendors/stt.mjs +7 -4
- package/dist/esm/agentkit/vendors/tts.d.mts +100 -9
- package/dist/esm/agentkit/vendors/tts.mjs +81 -11
- package/dist/esm/api/types/AresAsrParams.d.mts +6 -1
- package/dist/esm/api/types/AssemblyAiAsrParams.d.mts +1 -1
- package/dist/esm/api/types/FengmingAsr.d.mts +1 -2
- package/dist/esm/api/types/FengmingAsrParams.d.mts +9 -0
- package/dist/esm/api/types/{GenericTts.d.mts → GenericHttpTts.d.mts} +3 -3
- package/dist/esm/api/types/{GenericTtsParams.d.mts → GenericHttpTtsParams.d.mts} +3 -3
- package/dist/esm/api/types/GenericHttpTtsParams.mjs +2 -0
- package/dist/esm/api/types/GradiumTts.d.mts +9 -0
- package/dist/esm/api/types/GradiumTts.mjs +2 -0
- package/dist/esm/api/types/GradiumTtsParams.d.mts +17 -0
- package/dist/esm/api/types/GradiumTtsParams.mjs +2 -0
- package/dist/esm/api/types/MistralTts.d.mts +9 -0
- package/dist/esm/api/types/MistralTts.mjs +2 -0
- package/dist/esm/api/types/MistralTtsParams.d.mts +13 -0
- package/dist/esm/api/types/MistralTtsParams.mjs +2 -0
- package/dist/esm/api/types/Mllm.d.mts +4 -0
- package/dist/esm/api/types/Mllm.mjs +2 -0
- package/dist/esm/api/types/RimeTts.d.mts +10 -0
- package/dist/esm/api/types/RimeTts.mjs +8 -1
- package/dist/esm/api/types/RimeTtsParams.d.mts +2 -2
- package/dist/esm/api/types/Tts.d.mts +12 -3
- package/dist/esm/api/types/TypecastTts.d.mts +9 -0
- package/dist/esm/api/types/TypecastTts.mjs +2 -0
- package/dist/esm/api/types/TypecastTtsParams.d.mts +13 -0
- package/dist/esm/api/types/TypecastTtsParams.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +9 -2
- package/dist/esm/api/types/index.mjs +9 -2
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- /package/dist/cjs/api/types/{GenericTts.js → FengmingAsrParams.js} +0 -0
- /package/dist/cjs/api/types/{GenericTtsParams.js → GenericHttpTts.js} +0 -0
- /package/dist/esm/api/types/{GenericTts.mjs → FengmingAsrParams.mjs} +0 -0
- /package/dist/esm/api/types/{GenericTtsParams.mjs → GenericHttpTts.mjs} +0 -0
|
@@ -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,
|
|
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;
|
|
@@ -510,7 +510,7 @@ export interface AssemblyAiParams {
|
|
|
510
510
|
/** Language code */
|
|
511
511
|
language?: string;
|
|
512
512
|
/** AssemblyAI streaming WebSocket URL */
|
|
513
|
-
|
|
513
|
+
ws_url?: string;
|
|
514
514
|
/** Additional AssemblyAI-specific parameters */
|
|
515
515
|
[key: string]: unknown;
|
|
516
516
|
}
|
|
@@ -558,15 +558,21 @@ export type GenericTts = GenericTtsType;
|
|
|
558
558
|
export type GenericTtsParams = GenericTtsParamsType;
|
|
559
559
|
export type GoogleTts = GoogleTtsType;
|
|
560
560
|
export type GoogleTtsParams = GoogleTtsParamsType;
|
|
561
|
+
export type GradiumTts = GradiumTtsType;
|
|
562
|
+
export type GradiumTtsParams = GradiumTtsParamsType;
|
|
561
563
|
export type AmazonTts = AmazonTtsType;
|
|
562
564
|
export type AmazonTtsParams = AmazonTtsParamsType;
|
|
563
565
|
export type MinimaxTts = MinimaxTtsType;
|
|
564
566
|
export type MinimaxTtsParams = MinimaxTtsParamsType;
|
|
567
|
+
export type MistralTts = MistralTtsType;
|
|
568
|
+
export type MistralTtsParams = MistralTtsParamsType;
|
|
565
569
|
export type MurfTts = MurfTtsType;
|
|
566
570
|
export type MurfTtsParams = MurfTtsParamsType;
|
|
567
571
|
export type SarvamTts = SarvamTtsType;
|
|
568
572
|
export type SarvamTtsParams = SarvamTtsParamsType;
|
|
569
573
|
export type XAiTts = XAiTtsType;
|
|
570
574
|
export type XAiTtsParams = XAiTtsParamsType;
|
|
575
|
+
export type TypecastTts = TypecastTtsType;
|
|
576
|
+
export type TypecastTtsParams = TypecastTtsParamsType;
|
|
571
577
|
export type SpatiusAvatarParams = SpatiusAvatarParamsType;
|
|
572
578
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
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
|
*/
|
|
@@ -21,7 +21,7 @@ export interface OpenAIRealtimeOptions {
|
|
|
21
21
|
instructions?: string;
|
|
22
22
|
/** Audio transcription settings */
|
|
23
23
|
inputAudioTranscription?: Record<string, unknown>;
|
|
24
|
-
/** WebSocket URL
|
|
24
|
+
/** WebSocket URL. Defaults to `wss://api.openai.com/v1/realtime` when omitted or empty. */
|
|
25
25
|
url?: string;
|
|
26
26
|
/** Agent greeting message */
|
|
27
27
|
greetingMessage?: string;
|
|
@@ -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
|
*
|
|
@@ -36,7 +46,36 @@ export class OpenAIRealtime extends BaseMLLM {
|
|
|
36
46
|
voice !== undefined ||
|
|
37
47
|
instructions !== undefined ||
|
|
38
48
|
inputAudioTranscription !== undefined;
|
|
39
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
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 }));
|
|
50
|
+
}
|
|
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 });
|
|
40
79
|
}
|
|
41
80
|
}
|
|
42
81
|
/**
|
|
@@ -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
|
+
}
|
|
@@ -216,7 +216,7 @@ export interface AssemblyAISTTOptions {
|
|
|
216
216
|
/** Language code */
|
|
217
217
|
language: string;
|
|
218
218
|
/** AssemblyAI streaming WebSocket URL */
|
|
219
|
-
|
|
219
|
+
ws_url?: string;
|
|
220
220
|
/** Additional vendor-specific parameters */
|
|
221
221
|
additionalParams?: Record<string, unknown>;
|
|
222
222
|
}
|
|
@@ -240,6 +240,8 @@ export declare class AssemblyAISTT extends BaseSTT {
|
|
|
240
240
|
* Constructor options for Agora ARES STT.
|
|
241
241
|
*/
|
|
242
242
|
export interface AresSTTOptions {
|
|
243
|
+
/** Hotwords that improve recognition accuracy */
|
|
244
|
+
keywords?: string[];
|
|
243
245
|
/** Additional vendor-specific parameters */
|
|
244
246
|
additionalParams?: Record<string, unknown>;
|
|
245
247
|
}
|
|
@@ -188,10 +188,10 @@ export class AssemblyAISTT extends BaseSTT {
|
|
|
188
188
|
this.options = options;
|
|
189
189
|
}
|
|
190
190
|
toConfig() {
|
|
191
|
-
const { apiKey, language,
|
|
191
|
+
const { apiKey, language, ws_url, additionalParams } = this.options;
|
|
192
192
|
return {
|
|
193
193
|
vendor: "assemblyai",
|
|
194
|
-
params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (
|
|
194
|
+
params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey }), (language && { language })), (ws_url && { ws_url })),
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
}
|
|
@@ -209,8 +209,11 @@ export class AresSTT extends BaseSTT {
|
|
|
209
209
|
this.options = options;
|
|
210
210
|
}
|
|
211
211
|
toConfig() {
|
|
212
|
-
const { additionalParams } = this.options;
|
|
213
|
-
|
|
212
|
+
const { keywords, additionalParams } = this.options;
|
|
213
|
+
const hasParams = keywords !== undefined || (additionalParams !== undefined && Object.keys(additionalParams).length > 0);
|
|
214
|
+
return Object.assign({ vendor: "ares" }, (hasParams && {
|
|
215
|
+
params: Object.assign(Object.assign({}, additionalParams), (keywords !== undefined && { keywords })),
|
|
216
|
+
}));
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type-safe TTS (Text-to-Speech) vendor classes.
|
|
3
3
|
*/
|
|
4
|
+
import { CredentialMode } from "../constants.mjs";
|
|
4
5
|
import { type MiniMaxPresetModel, type OpenAITtsPresetModel } from "../presets.mjs";
|
|
5
6
|
import type { TtsConfig } from "../types.mjs";
|
|
6
7
|
import type { CartesiaSampleRate, ElevenLabsSampleRate, GoogleTTSSampleRate, MicrosoftSampleRate } from "./base.mjs";
|
|
@@ -279,6 +280,67 @@ export declare class DeepgramTTS extends BaseTTS {
|
|
|
279
280
|
constructor(options: DeepgramTTSOptions);
|
|
280
281
|
toConfig(): TtsConfig;
|
|
281
282
|
}
|
|
283
|
+
/** Constructor options for Gradium TTS. */
|
|
284
|
+
export interface GradiumTTSOptions {
|
|
285
|
+
/** Gradium API key */
|
|
286
|
+
apiKey: string;
|
|
287
|
+
/** WebSocket endpoint for streaming TTS output */
|
|
288
|
+
url?: string;
|
|
289
|
+
/** Gradium TTS model name (e.g., 'default') */
|
|
290
|
+
modelName?: string;
|
|
291
|
+
/** Gradium voice identifier */
|
|
292
|
+
voiceId?: string;
|
|
293
|
+
/** Audio sample rate in Hz */
|
|
294
|
+
sampleRate?: number;
|
|
295
|
+
/** Additional vendor-specific parameters */
|
|
296
|
+
additionalParams?: Record<string, unknown>;
|
|
297
|
+
/** Skip patterns for bracketed content */
|
|
298
|
+
skipPatterns?: number[];
|
|
299
|
+
}
|
|
300
|
+
/** Gradium TTS vendor. */
|
|
301
|
+
export declare class GradiumTTS extends BaseTTS {
|
|
302
|
+
private readonly options;
|
|
303
|
+
constructor(options: GradiumTTSOptions);
|
|
304
|
+
toConfig(): TtsConfig;
|
|
305
|
+
}
|
|
306
|
+
/** Constructor options for Mistral TTS. */
|
|
307
|
+
export interface MistralTTSOptions {
|
|
308
|
+
/** Mistral API key */
|
|
309
|
+
apiKey: string;
|
|
310
|
+
/** Mistral TTS model name (e.g., 'voxtral-mini-tts-2603') */
|
|
311
|
+
model?: string;
|
|
312
|
+
/** Mistral voice identifier */
|
|
313
|
+
voice?: string;
|
|
314
|
+
/** Additional vendor-specific parameters */
|
|
315
|
+
additionalParams?: Record<string, unknown>;
|
|
316
|
+
/** Skip patterns for bracketed content */
|
|
317
|
+
skipPatterns?: number[];
|
|
318
|
+
}
|
|
319
|
+
/** Mistral TTS vendor. */
|
|
320
|
+
export declare class MistralTTS extends BaseTTS {
|
|
321
|
+
private readonly options;
|
|
322
|
+
constructor(options: MistralTTSOptions);
|
|
323
|
+
toConfig(): TtsConfig;
|
|
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
|
+
}
|
|
282
344
|
/**
|
|
283
345
|
* Constructor options for Hume AI TTS.
|
|
284
346
|
*/
|
|
@@ -319,8 +381,28 @@ export declare class HumeAITTS extends BaseTTS {
|
|
|
319
381
|
}
|
|
320
382
|
/**
|
|
321
383
|
* Constructor options for Rime TTS.
|
|
384
|
+
*
|
|
385
|
+
* - `credentialMode: CredentialMode.Managed` requires `baseUrl` and `modelId`
|
|
386
|
+
* - omitted / `CredentialMode.Byok` requires `key`, `speaker`, and `modelId`
|
|
322
387
|
*/
|
|
323
|
-
|
|
388
|
+
type RimeTTSCommonOptions = {
|
|
389
|
+
/** Skip patterns for bracketed content */
|
|
390
|
+
skipPatterns?: number[];
|
|
391
|
+
};
|
|
392
|
+
export type RimeTTSOptions = (RimeTTSCommonOptions & {
|
|
393
|
+
/** Use Agora-managed Rime credentials */
|
|
394
|
+
credentialMode: typeof CredentialMode.Managed;
|
|
395
|
+
/** Model ID */
|
|
396
|
+
modelId: string;
|
|
397
|
+
/** WebSocket URL for the Rime streaming API */
|
|
398
|
+
baseUrl: string;
|
|
399
|
+
/** Rime API key (optional for managed credentials) */
|
|
400
|
+
key?: string;
|
|
401
|
+
/** Speaker ID (optional for managed credentials) */
|
|
402
|
+
speaker?: string;
|
|
403
|
+
}) | (RimeTTSCommonOptions & {
|
|
404
|
+
/** Bring-your-own Rime credentials (default when omitted) */
|
|
405
|
+
credentialMode?: typeof CredentialMode.Byok;
|
|
324
406
|
/** Rime API key */
|
|
325
407
|
key: string;
|
|
326
408
|
/** Speaker ID */
|
|
@@ -329,15 +411,24 @@ export interface RimeTTSOptions {
|
|
|
329
411
|
modelId: string;
|
|
330
412
|
/** WebSocket URL for the Rime streaming API */
|
|
331
413
|
baseUrl?: string;
|
|
332
|
-
|
|
333
|
-
skipPatterns?: number[];
|
|
334
|
-
}
|
|
414
|
+
});
|
|
335
415
|
/**
|
|
336
416
|
* Rime TTS vendor.
|
|
337
417
|
*
|
|
338
418
|
* @example
|
|
419
|
+
* Agora-managed credentials:
|
|
420
|
+
* ```typescript
|
|
421
|
+
* const managedTts = new RimeTTS({
|
|
422
|
+
* credentialMode: CredentialMode.Managed,
|
|
423
|
+
* baseUrl: 'wss://users.rime.ai/ws',
|
|
424
|
+
* modelId: 'mist',
|
|
425
|
+
* });
|
|
426
|
+
* ```
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* Bring your own credentials (the default mode):
|
|
339
430
|
* ```typescript
|
|
340
|
-
* const
|
|
431
|
+
* const byokTts = new RimeTTS({
|
|
341
432
|
* key: process.env.RIME_API_KEY,
|
|
342
433
|
* speaker: 'speaker-id',
|
|
343
434
|
* modelId: 'mist',
|
|
@@ -505,16 +596,16 @@ export declare class MurfTTS extends BaseTTS {
|
|
|
505
596
|
* Constructor options for Generic OpenAI-compatible TTS.
|
|
506
597
|
*/
|
|
507
598
|
export interface GenericTTSOptions {
|
|
508
|
-
/**
|
|
599
|
+
/** HTTP(S) endpoint of the generic TTS service */
|
|
509
600
|
url: string;
|
|
510
601
|
/** Custom headers to include in requests to the generic TTS service */
|
|
511
|
-
headers
|
|
602
|
+
headers?: Record<string, string>;
|
|
512
603
|
/** API key for the generic TTS service */
|
|
513
604
|
apiKey?: string;
|
|
514
605
|
/** TTS model name */
|
|
515
|
-
model
|
|
606
|
+
model?: string;
|
|
516
607
|
/** Voice name */
|
|
517
|
-
voice
|
|
608
|
+
voice?: string;
|
|
518
609
|
/** Speech rate */
|
|
519
610
|
speed?: number;
|
|
520
611
|
/** Output audio sample rate in Hz */
|