agora-agents 2.0.1 → 2.1.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/README.md +38 -9
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/agentkit/Agent.d.ts +49 -9
- package/dist/cjs/agentkit/Agent.js +92 -7
- package/dist/cjs/agentkit/AgentSession.d.ts +3 -3
- package/dist/cjs/agentkit/AgentSession.js +8 -7
- package/dist/cjs/agentkit/__tests__/type-safety.test.js +23 -3
- package/dist/cjs/agentkit/constants.d.ts +5 -4
- package/dist/cjs/agentkit/constants.js +5 -4
- package/dist/cjs/agentkit/index.d.ts +1 -1
- package/dist/cjs/agentkit/types.d.ts +50 -35
- package/dist/cjs/agentkit/vendors/avatar.d.ts +3 -1
- package/dist/cjs/agentkit/vendors/avatar.js +3 -1
- package/dist/cjs/agentkit/vendors/llm.d.ts +18 -8
- package/dist/cjs/agentkit/vendors/llm.js +83 -15
- package/dist/cjs/agentkit/vendors/mllm.d.ts +16 -0
- package/dist/cjs/agentkit/vendors/mllm.js +11 -7
- package/dist/cjs/agentkit/vendors/stt.d.ts +29 -11
- package/dist/cjs/agentkit/vendors/stt.js +74 -53
- package/dist/cjs/agentkit/vendors/tts.d.ts +70 -22
- package/dist/cjs/agentkit/vendors/tts.js +67 -34
- package/dist/cjs/api/resources/agents/client/Client.d.ts +3 -2
- package/dist/cjs/api/resources/agents/client/Client.js +3 -2
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +8 -331
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +0 -107
- package/dist/cjs/api/types/AmazonAsr.d.ts +10 -0
- package/dist/cjs/api/types/AmazonAsr.js +3 -0
- package/dist/cjs/api/types/AmazonAsrParams.d.ts +19 -0
- package/dist/cjs/api/types/AmazonAsrParams.js +3 -0
- package/dist/cjs/api/types/AmazonTtsParams.d.ts +19 -5
- package/dist/cjs/api/types/AmazonTtsParams.js +11 -0
- package/dist/cjs/api/types/AresAsr.d.ts +10 -0
- package/dist/cjs/api/types/AresAsr.js +3 -0
- package/dist/cjs/api/types/AresAsrParams.d.ts +4 -0
- package/dist/cjs/api/types/AresAsrParams.js +3 -0
- package/dist/cjs/api/types/Asr.d.ts +31 -0
- package/dist/cjs/api/types/Asr.js +3 -0
- package/dist/cjs/api/types/AsrLanguage.d.ts +36 -0
- package/dist/cjs/api/types/AsrLanguage.js +39 -0
- package/dist/cjs/api/types/AssemblyAiAsr.d.ts +10 -0
- package/dist/cjs/api/types/AssemblyAiAsr.js +3 -0
- package/dist/cjs/api/types/AssemblyAiAsrParams.d.ts +13 -0
- package/dist/cjs/api/types/AssemblyAiAsrParams.js +3 -0
- package/dist/cjs/api/types/CartesiaTtsOutputFormat.d.ts +11 -0
- package/dist/cjs/api/types/CartesiaTtsOutputFormat.js +3 -0
- package/dist/cjs/api/types/CartesiaTtsParams.d.ts +9 -4
- package/dist/cjs/api/types/CartesiaTtsVoice.d.ts +2 -0
- package/dist/cjs/api/types/DeepgramAsr.d.ts +12 -0
- package/dist/cjs/api/types/DeepgramAsr.js +3 -0
- package/dist/cjs/api/types/DeepgramAsrParams.d.ts +17 -0
- package/dist/cjs/api/types/DeepgramAsrParams.js +3 -0
- package/dist/cjs/api/types/DeepgramTtsParams.d.ts +2 -2
- package/dist/cjs/api/types/ElevenLabsTtsParams.d.ts +13 -1
- package/dist/cjs/api/types/FishAudioTtsParams.d.ts +5 -1
- package/dist/cjs/api/types/GoogleAsr.d.ts +10 -0
- package/dist/cjs/api/types/GoogleAsr.js +3 -0
- package/dist/cjs/api/types/GoogleAsrParams.d.ts +17 -0
- package/dist/cjs/api/types/GoogleAsrParams.js +3 -0
- package/dist/cjs/api/types/GoogleTtsAudioConfig.d.ts +11 -0
- package/dist/cjs/api/types/GoogleTtsAudioConfig.js +3 -0
- package/dist/cjs/api/types/GoogleTtsParams.d.ts +7 -8
- package/dist/cjs/api/types/GoogleTtsVoiceSelectionParams.d.ts +9 -0
- package/dist/cjs/api/types/GoogleTtsVoiceSelectionParams.js +3 -0
- package/dist/cjs/api/types/HumeAiTtsParams.d.ts +21 -1
- package/dist/cjs/api/types/HumeAiTtsParams.js +9 -0
- package/dist/cjs/api/types/Llm.d.ts +58 -0
- package/dist/cjs/api/types/Llm.js +15 -0
- package/dist/cjs/api/types/LlmParams.d.ts +11 -0
- package/dist/cjs/api/types/LlmParams.js +3 -0
- package/dist/cjs/api/types/MicrosoftAsr.d.ts +10 -0
- package/dist/cjs/api/types/MicrosoftAsr.js +3 -0
- package/dist/cjs/api/types/MicrosoftAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/MicrosoftAsrParams.js +3 -0
- package/dist/cjs/api/types/MicrosoftTtsParams.d.ts +6 -0
- package/dist/cjs/api/types/MinimaxTtsParams.d.ts +4 -0
- package/dist/cjs/api/types/Mllm.d.ts +44 -0
- package/dist/cjs/api/types/Mllm.js +14 -0
- package/dist/cjs/api/types/MllmHttpOptions.d.ts +9 -0
- package/dist/cjs/api/types/MllmHttpOptions.js +3 -0
- package/dist/cjs/api/types/MllmInputAudioTranscription.d.ts +13 -0
- package/dist/cjs/api/types/MllmInputAudioTranscription.js +3 -0
- package/dist/cjs/api/types/MllmParams.d.ts +28 -0
- package/dist/cjs/api/types/MllmParams.js +3 -0
- package/dist/cjs/api/types/MllmTurnDetection.d.ts +65 -0
- package/dist/cjs/api/types/MllmTurnDetection.js +33 -0
- package/dist/cjs/api/types/MurfTtsParams.d.ts +17 -5
- package/dist/cjs/api/types/OpenAiAsr.d.ts +10 -0
- package/dist/cjs/api/types/OpenAiAsr.js +3 -0
- package/dist/cjs/api/types/OpenAiAsrParams.d.ts +11 -0
- package/dist/cjs/api/types/OpenAiAsrParams.js +3 -0
- package/dist/cjs/api/types/OpenAiInputAudioTranscription.d.ts +13 -0
- package/dist/cjs/api/types/OpenAiInputAudioTranscription.js +3 -0
- package/dist/cjs/api/types/OpenAiTtsParams.d.ts +9 -1
- package/dist/cjs/api/types/RimeTtsParams.d.ts +7 -3
- package/dist/cjs/api/types/SarvamAsr.d.ts +10 -0
- package/dist/cjs/api/types/SarvamAsr.js +3 -0
- package/dist/cjs/api/types/SarvamAsrParams.d.ts +11 -0
- package/dist/cjs/api/types/SarvamAsrParams.js +3 -0
- package/dist/cjs/api/types/SarvamTtsParams.d.ts +29 -2
- package/dist/cjs/api/types/SarvamTtsParams.js +18 -0
- package/dist/cjs/api/types/SpeechmaticsAsr.d.ts +10 -0
- package/dist/cjs/api/types/SpeechmaticsAsr.js +3 -0
- package/dist/cjs/api/types/SpeechmaticsAsrParams.d.ts +13 -0
- package/dist/cjs/api/types/SpeechmaticsAsrParams.js +3 -0
- package/dist/cjs/api/types/index.d.ts +31 -0
- package/dist/cjs/api/types/index.js +31 -0
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/agentkit/Agent.d.mts +49 -9
- package/dist/esm/agentkit/Agent.mjs +92 -7
- package/dist/esm/agentkit/AgentSession.d.mts +3 -3
- package/dist/esm/agentkit/AgentSession.mjs +8 -7
- package/dist/esm/agentkit/__tests__/type-safety.test.mjs +23 -3
- package/dist/esm/agentkit/constants.d.mts +5 -4
- package/dist/esm/agentkit/constants.mjs +5 -4
- package/dist/esm/agentkit/index.d.mts +1 -1
- package/dist/esm/agentkit/types.d.mts +50 -35
- package/dist/esm/agentkit/vendors/avatar.d.mts +3 -1
- package/dist/esm/agentkit/vendors/avatar.mjs +3 -1
- package/dist/esm/agentkit/vendors/llm.d.mts +18 -8
- package/dist/esm/agentkit/vendors/llm.mjs +83 -15
- package/dist/esm/agentkit/vendors/mllm.d.mts +16 -0
- package/dist/esm/agentkit/vendors/mllm.mjs +11 -7
- package/dist/esm/agentkit/vendors/stt.d.mts +29 -11
- package/dist/esm/agentkit/vendors/stt.mjs +74 -53
- package/dist/esm/agentkit/vendors/tts.d.mts +70 -22
- package/dist/esm/agentkit/vendors/tts.mjs +67 -34
- package/dist/esm/api/resources/agents/client/Client.d.mts +3 -2
- package/dist/esm/api/resources/agents/client/Client.mjs +3 -2
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +8 -331
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +0 -107
- package/dist/esm/api/types/AmazonAsr.d.mts +10 -0
- package/dist/esm/api/types/AmazonAsr.mjs +2 -0
- package/dist/esm/api/types/AmazonAsrParams.d.mts +19 -0
- package/dist/esm/api/types/AmazonAsrParams.mjs +2 -0
- package/dist/esm/api/types/AmazonTtsParams.d.mts +19 -5
- package/dist/esm/api/types/AmazonTtsParams.mjs +10 -1
- package/dist/esm/api/types/AresAsr.d.mts +10 -0
- package/dist/esm/api/types/AresAsr.mjs +2 -0
- package/dist/esm/api/types/AresAsrParams.d.mts +4 -0
- package/dist/esm/api/types/AresAsrParams.mjs +2 -0
- package/dist/esm/api/types/Asr.d.mts +31 -0
- package/dist/esm/api/types/Asr.mjs +2 -0
- package/dist/esm/api/types/AsrLanguage.d.mts +36 -0
- package/dist/esm/api/types/AsrLanguage.mjs +36 -0
- package/dist/esm/api/types/AssemblyAiAsr.d.mts +10 -0
- package/dist/esm/api/types/AssemblyAiAsr.mjs +2 -0
- package/dist/esm/api/types/AssemblyAiAsrParams.d.mts +13 -0
- package/dist/esm/api/types/AssemblyAiAsrParams.mjs +2 -0
- package/dist/esm/api/types/CartesiaTtsOutputFormat.d.mts +11 -0
- package/dist/esm/api/types/CartesiaTtsOutputFormat.mjs +2 -0
- package/dist/esm/api/types/CartesiaTtsParams.d.mts +9 -4
- package/dist/esm/api/types/CartesiaTtsVoice.d.mts +2 -0
- package/dist/esm/api/types/DeepgramAsr.d.mts +12 -0
- package/dist/esm/api/types/DeepgramAsr.mjs +2 -0
- package/dist/esm/api/types/DeepgramAsrParams.d.mts +17 -0
- package/dist/esm/api/types/DeepgramAsrParams.mjs +2 -0
- package/dist/esm/api/types/DeepgramTtsParams.d.mts +2 -2
- package/dist/esm/api/types/ElevenLabsTtsParams.d.mts +13 -1
- package/dist/esm/api/types/FishAudioTtsParams.d.mts +5 -1
- package/dist/esm/api/types/GoogleAsr.d.mts +10 -0
- package/dist/esm/api/types/GoogleAsr.mjs +2 -0
- package/dist/esm/api/types/GoogleAsrParams.d.mts +17 -0
- package/dist/esm/api/types/GoogleAsrParams.mjs +2 -0
- package/dist/esm/api/types/GoogleTtsAudioConfig.d.mts +11 -0
- package/dist/esm/api/types/GoogleTtsAudioConfig.mjs +2 -0
- package/dist/esm/api/types/GoogleTtsParams.d.mts +7 -8
- package/dist/esm/api/types/GoogleTtsVoiceSelectionParams.d.mts +9 -0
- package/dist/esm/api/types/GoogleTtsVoiceSelectionParams.mjs +2 -0
- package/dist/esm/api/types/HumeAiTtsParams.d.mts +21 -1
- package/dist/esm/api/types/HumeAiTtsParams.mjs +8 -1
- package/dist/esm/api/types/Llm.d.mts +58 -0
- package/dist/esm/api/types/Llm.mjs +12 -0
- package/dist/esm/api/types/LlmParams.d.mts +11 -0
- package/dist/esm/api/types/LlmParams.mjs +2 -0
- package/dist/esm/api/types/MicrosoftAsr.d.mts +10 -0
- package/dist/esm/api/types/MicrosoftAsr.mjs +2 -0
- package/dist/esm/api/types/MicrosoftAsrParams.d.mts +15 -0
- package/dist/esm/api/types/MicrosoftAsrParams.mjs +2 -0
- package/dist/esm/api/types/MicrosoftTtsParams.d.mts +6 -0
- package/dist/esm/api/types/MinimaxTtsParams.d.mts +4 -0
- package/dist/esm/api/types/Mllm.d.mts +44 -0
- package/dist/esm/api/types/Mllm.mjs +11 -0
- package/dist/esm/api/types/MllmHttpOptions.d.mts +9 -0
- package/dist/esm/api/types/MllmHttpOptions.mjs +2 -0
- package/dist/esm/api/types/MllmInputAudioTranscription.d.mts +13 -0
- package/dist/esm/api/types/MllmInputAudioTranscription.mjs +2 -0
- package/dist/esm/api/types/MllmParams.d.mts +28 -0
- package/dist/esm/api/types/MllmParams.mjs +2 -0
- package/dist/esm/api/types/MllmTurnDetection.d.mts +65 -0
- package/dist/esm/api/types/MllmTurnDetection.mjs +30 -0
- package/dist/esm/api/types/MurfTtsParams.d.mts +17 -5
- package/dist/esm/api/types/OpenAiAsr.d.mts +10 -0
- package/dist/esm/api/types/OpenAiAsr.mjs +2 -0
- package/dist/esm/api/types/OpenAiAsrParams.d.mts +11 -0
- package/dist/esm/api/types/OpenAiAsrParams.mjs +2 -0
- package/dist/esm/api/types/OpenAiInputAudioTranscription.d.mts +13 -0
- package/dist/esm/api/types/OpenAiInputAudioTranscription.mjs +2 -0
- package/dist/esm/api/types/OpenAiTtsParams.d.mts +9 -1
- package/dist/esm/api/types/RimeTtsParams.d.mts +7 -3
- package/dist/esm/api/types/SarvamAsr.d.mts +10 -0
- package/dist/esm/api/types/SarvamAsr.mjs +2 -0
- package/dist/esm/api/types/SarvamAsrParams.d.mts +11 -0
- package/dist/esm/api/types/SarvamAsrParams.mjs +2 -0
- package/dist/esm/api/types/SarvamTtsParams.d.mts +29 -2
- package/dist/esm/api/types/SarvamTtsParams.mjs +17 -1
- package/dist/esm/api/types/SpeechmaticsAsr.d.mts +10 -0
- package/dist/esm/api/types/SpeechmaticsAsr.mjs +2 -0
- package/dist/esm/api/types/SpeechmaticsAsrParams.d.mts +13 -0
- package/dist/esm/api/types/SpeechmaticsAsrParams.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +31 -0
- package/dist/esm/api/types/index.mjs +31 -0
- package/dist/esm/index.d.mts +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,17 @@ import type { BaseAvatar, BaseLLM, BaseMLLM, BaseSTT, BaseTTS } from "./vendors/
|
|
|
18
18
|
export interface AgentOptions {
|
|
19
19
|
/** Optional name for the agent (used as default session name) */
|
|
20
20
|
name?: string;
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Published AI Studio pipeline ID to use as this agent's base configuration.
|
|
23
|
+
* Explicit Agent config such as .withLlm(), .withTts(), .withStt(),
|
|
24
|
+
* advancedFeatures, and other builder options may send fields in
|
|
25
|
+
* `properties` that override the saved pipeline settings.
|
|
26
|
+
*/
|
|
27
|
+
pipelineId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* System instructions for the agent.
|
|
30
|
+
* @deprecated Configure this on the LLM vendor with `systemMessages` instead.
|
|
31
|
+
*/
|
|
22
32
|
instructions?: string;
|
|
23
33
|
/** Turn detection configuration */
|
|
24
34
|
turnDetection?: TurnDetectionConfig;
|
|
@@ -32,11 +42,20 @@ export interface AgentOptions {
|
|
|
32
42
|
advancedFeatures?: AdvancedFeatures;
|
|
33
43
|
/** Session parameters */
|
|
34
44
|
parameters?: SessionParamsInput;
|
|
35
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Greeting message.
|
|
47
|
+
* @deprecated Configure this on the LLM or MLLM vendor with `greetingMessage` instead.
|
|
48
|
+
*/
|
|
36
49
|
greeting?: string;
|
|
37
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Failure message.
|
|
52
|
+
* @deprecated Configure this on the LLM or MLLM vendor with `failureMessage` instead.
|
|
53
|
+
*/
|
|
38
54
|
failureMessage?: string;
|
|
39
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Max conversation history for the standard LLM pipeline. Does not apply to MLLM.
|
|
57
|
+
* @deprecated Configure this on the LLM vendor with `maxHistory` instead.
|
|
58
|
+
*/
|
|
40
59
|
maxHistory?: number;
|
|
41
60
|
/** Regional access restriction configuration */
|
|
42
61
|
geofence?: GeofenceConfig;
|
|
@@ -46,7 +65,10 @@ export interface AgentOptions {
|
|
|
46
65
|
rtc?: RtcConfig;
|
|
47
66
|
/** Filler word configuration (plays filler words while waiting for LLM responses) */
|
|
48
67
|
fillerWords?: FillerWordsConfig;
|
|
49
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Greeting playback configuration for multi-user channels.
|
|
70
|
+
* @deprecated Configure this on the LLM vendor with `greetingConfigs` instead.
|
|
71
|
+
*/
|
|
50
72
|
greetingConfigs?: LlmGreetingConfigs;
|
|
51
73
|
}
|
|
52
74
|
/**
|
|
@@ -60,13 +82,14 @@ export interface AgentOptions {
|
|
|
60
82
|
*
|
|
61
83
|
* // Use the fluent builder pattern to configure vendors
|
|
62
84
|
* const agent = new Agent({ instructions: 'You are helpful.' })
|
|
63
|
-
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4' }))
|
|
64
|
-
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
85
|
+
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
86
|
+
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
65
87
|
* .withStt(new DeepgramSTT({ apiKey: '...', model: 'nova-2' }));
|
|
66
88
|
* ```
|
|
67
89
|
*/
|
|
68
90
|
export declare class Agent<TTSSampleRate extends number = number> {
|
|
69
91
|
private _name?;
|
|
92
|
+
private _pipelineId?;
|
|
70
93
|
private _llm?;
|
|
71
94
|
private _tts?;
|
|
72
95
|
private _stt?;
|
|
@@ -90,7 +113,7 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
90
113
|
/**
|
|
91
114
|
* Returns a new Agent with the specified LLM vendor.
|
|
92
115
|
*
|
|
93
|
-
* @param vendor - LLM vendor instance (e.g., new OpenAI({ apiKey: '...', model: 'gpt-4' }))
|
|
116
|
+
* @param vendor - LLM vendor instance (e.g., new OpenAI({ apiKey: '...', model: 'gpt-4', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
94
117
|
*/
|
|
95
118
|
withLlm(vendor: BaseLLM): Agent<TTSSampleRate>;
|
|
96
119
|
/**
|
|
@@ -99,7 +122,7 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
99
122
|
* The sample rate type is tracked for compile-time avatar compatibility checking.
|
|
100
123
|
*
|
|
101
124
|
* @template SR - Sample rate literal type
|
|
102
|
-
* @param vendor - TTS vendor instance (e.g., new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
125
|
+
* @param vendor - TTS vendor instance (e.g., new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
103
126
|
* @returns Agent with tracked sample rate type
|
|
104
127
|
*/
|
|
105
128
|
withTts<SR extends number>(vendor: BaseTTS<SR>): Agent<SR>;
|
|
@@ -162,6 +185,7 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
162
185
|
* key: '...',
|
|
163
186
|
* modelId: '...',
|
|
164
187
|
* voiceId: '...',
|
|
188
|
+
* baseUrl: 'wss://api.elevenlabs.io/v1',
|
|
165
189
|
* sampleRate: 24000, // Required for HeyGen
|
|
166
190
|
* }))
|
|
167
191
|
* .withAvatar(new HeyGenAvatar({
|
|
@@ -182,10 +206,14 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
182
206
|
withInterruption(config: InterruptionConfig): Agent<TTSSampleRate>;
|
|
183
207
|
/**
|
|
184
208
|
* Returns a new Agent with the specified instructions.
|
|
209
|
+
*
|
|
210
|
+
* @deprecated Configure system messages on the LLM vendor instead.
|
|
185
211
|
*/
|
|
186
212
|
withInstructions(instructions: string): Agent<TTSSampleRate>;
|
|
187
213
|
/**
|
|
188
214
|
* Returns a new Agent with the specified greeting message.
|
|
215
|
+
*
|
|
216
|
+
* @deprecated Configure the greeting on the LLM or MLLM vendor instead.
|
|
189
217
|
*/
|
|
190
218
|
withGreeting(greeting: string): Agent<TTSSampleRate>;
|
|
191
219
|
/**
|
|
@@ -193,6 +221,8 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
193
221
|
*
|
|
194
222
|
* Serializes to `llm.greeting_configs`. Agent-level values override any
|
|
195
223
|
* vendor-level `greeting_configs` configured on the LLM vendor.
|
|
224
|
+
*
|
|
225
|
+
* @deprecated Configure greeting playback on the LLM vendor instead.
|
|
196
226
|
*/
|
|
197
227
|
withGreetingConfigs(configs: LlmGreetingConfigs): Agent<TTSSampleRate>;
|
|
198
228
|
/**
|
|
@@ -227,11 +257,15 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
227
257
|
* Returns a new Agent with the specified failure message.
|
|
228
258
|
*
|
|
229
259
|
* The failure message is played via TTS when the LLM call fails.
|
|
260
|
+
*
|
|
261
|
+
* @deprecated Configure the failure message on the LLM or MLLM vendor instead.
|
|
230
262
|
*/
|
|
231
263
|
withFailureMessage(message: string): Agent<TTSSampleRate>;
|
|
232
264
|
/**
|
|
233
265
|
* Returns a new Agent with the specified maximum conversation history length.
|
|
234
266
|
* Applies to the standard LLM pipeline only; the v2.7 MLLM core schema has no max_history field.
|
|
267
|
+
*
|
|
268
|
+
* @deprecated Configure max history on the LLM vendor instead.
|
|
235
269
|
*/
|
|
236
270
|
withMaxHistory(maxHistory: number): Agent<TTSSampleRate>;
|
|
237
271
|
/**
|
|
@@ -260,6 +294,10 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
260
294
|
* Get the agent name.
|
|
261
295
|
*/
|
|
262
296
|
get name(): string | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* Get the AI Studio pipeline ID used as this agent's base configuration.
|
|
299
|
+
*/
|
|
300
|
+
get pipelineId(): string | undefined;
|
|
263
301
|
/**
|
|
264
302
|
* Get the LLM configuration.
|
|
265
303
|
*/
|
|
@@ -412,4 +450,6 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
412
450
|
* If a new private field is added to Agent, it MUST also be added here.
|
|
413
451
|
*/
|
|
414
452
|
private _clone;
|
|
453
|
+
private _resolveAsrConfig;
|
|
454
|
+
private _resolveTurnDetectionConfig;
|
|
415
455
|
}
|
|
@@ -6,6 +6,49 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { AgentSession } from "./AgentSession.mjs";
|
|
8
8
|
import { generateConvoAIToken } from "./token.mjs";
|
|
9
|
+
const DEFAULT_TURN_DETECTION_LANGUAGE = "en-US";
|
|
10
|
+
const INTERACTION_LANGUAGES = new Set([
|
|
11
|
+
"ar-EG",
|
|
12
|
+
"ar-JO",
|
|
13
|
+
"ar-SA",
|
|
14
|
+
"ar-AE",
|
|
15
|
+
"bn-IN",
|
|
16
|
+
"zh-CN",
|
|
17
|
+
"zh-HK",
|
|
18
|
+
"zh-TW",
|
|
19
|
+
"nl-NL",
|
|
20
|
+
"en-IN",
|
|
21
|
+
"en-US",
|
|
22
|
+
"fil-PH",
|
|
23
|
+
"fr-FR",
|
|
24
|
+
"de-DE",
|
|
25
|
+
"gu-IN",
|
|
26
|
+
"he-IL",
|
|
27
|
+
"hi-IN",
|
|
28
|
+
"id-ID",
|
|
29
|
+
"it-IT",
|
|
30
|
+
"ja-JP",
|
|
31
|
+
"kn-IN",
|
|
32
|
+
"ko-KR",
|
|
33
|
+
"ms-MY",
|
|
34
|
+
"fa-IR",
|
|
35
|
+
"pt-PT",
|
|
36
|
+
"ru-RU",
|
|
37
|
+
"es-ES",
|
|
38
|
+
"ta-IN",
|
|
39
|
+
"te-IN",
|
|
40
|
+
"th-TH",
|
|
41
|
+
"tr-TR",
|
|
42
|
+
"vi-VN",
|
|
43
|
+
]);
|
|
44
|
+
function isTurnDetectionLanguage(value) {
|
|
45
|
+
return INTERACTION_LANGUAGES.has(value);
|
|
46
|
+
}
|
|
47
|
+
function assertTurnDetectionLanguage(value) {
|
|
48
|
+
if (!isTurnDetectionLanguage(value)) {
|
|
49
|
+
throw new Error(`Invalid interaction language: ${value}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
9
52
|
/**
|
|
10
53
|
* Agent class representing a reusable agent configuration.
|
|
11
54
|
*
|
|
@@ -17,14 +60,15 @@ import { generateConvoAIToken } from "./token.mjs";
|
|
|
17
60
|
*
|
|
18
61
|
* // Use the fluent builder pattern to configure vendors
|
|
19
62
|
* const agent = new Agent({ instructions: 'You are helpful.' })
|
|
20
|
-
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4' }))
|
|
21
|
-
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
63
|
+
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
64
|
+
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
22
65
|
* .withStt(new DeepgramSTT({ apiKey: '...', model: 'nova-2' }));
|
|
23
66
|
* ```
|
|
24
67
|
*/
|
|
25
68
|
export class Agent {
|
|
26
69
|
constructor(options = {}) {
|
|
27
70
|
this._name = options.name;
|
|
71
|
+
this._pipelineId = options.pipelineId;
|
|
28
72
|
this._instructions = options.instructions;
|
|
29
73
|
this._greeting = options.greeting;
|
|
30
74
|
this._failureMessage = options.failureMessage;
|
|
@@ -66,7 +110,7 @@ export class Agent {
|
|
|
66
110
|
/**
|
|
67
111
|
* Returns a new Agent with the specified LLM vendor.
|
|
68
112
|
*
|
|
69
|
-
* @param vendor - LLM vendor instance (e.g., new OpenAI({ apiKey: '...', model: 'gpt-4' }))
|
|
113
|
+
* @param vendor - LLM vendor instance (e.g., new OpenAI({ apiKey: '...', model: 'gpt-4', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
70
114
|
*/
|
|
71
115
|
withLlm(vendor) {
|
|
72
116
|
const newAgent = this._clone();
|
|
@@ -79,7 +123,7 @@ export class Agent {
|
|
|
79
123
|
* The sample rate type is tracked for compile-time avatar compatibility checking.
|
|
80
124
|
*
|
|
81
125
|
* @template SR - Sample rate literal type
|
|
82
|
-
* @param vendor - TTS vendor instance (e.g., new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
126
|
+
* @param vendor - TTS vendor instance (e.g., new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
83
127
|
* @returns Agent with tracked sample rate type
|
|
84
128
|
*/
|
|
85
129
|
withTts(vendor) {
|
|
@@ -163,6 +207,7 @@ export class Agent {
|
|
|
163
207
|
* key: '...',
|
|
164
208
|
* modelId: '...',
|
|
165
209
|
* voiceId: '...',
|
|
210
|
+
* baseUrl: 'wss://api.elevenlabs.io/v1',
|
|
166
211
|
* sampleRate: 24000, // Required for HeyGen
|
|
167
212
|
* }))
|
|
168
213
|
* .withAvatar(new HeyGenAvatar({
|
|
@@ -197,6 +242,8 @@ export class Agent {
|
|
|
197
242
|
}
|
|
198
243
|
/**
|
|
199
244
|
* Returns a new Agent with the specified instructions.
|
|
245
|
+
*
|
|
246
|
+
* @deprecated Configure system messages on the LLM vendor instead.
|
|
200
247
|
*/
|
|
201
248
|
withInstructions(instructions) {
|
|
202
249
|
const newAgent = this._clone();
|
|
@@ -205,6 +252,8 @@ export class Agent {
|
|
|
205
252
|
}
|
|
206
253
|
/**
|
|
207
254
|
* Returns a new Agent with the specified greeting message.
|
|
255
|
+
*
|
|
256
|
+
* @deprecated Configure the greeting on the LLM or MLLM vendor instead.
|
|
208
257
|
*/
|
|
209
258
|
withGreeting(greeting) {
|
|
210
259
|
const newAgent = this._clone();
|
|
@@ -216,6 +265,8 @@ export class Agent {
|
|
|
216
265
|
*
|
|
217
266
|
* Serializes to `llm.greeting_configs`. Agent-level values override any
|
|
218
267
|
* vendor-level `greeting_configs` configured on the LLM vendor.
|
|
268
|
+
*
|
|
269
|
+
* @deprecated Configure greeting playback on the LLM vendor instead.
|
|
219
270
|
*/
|
|
220
271
|
withGreetingConfigs(configs) {
|
|
221
272
|
const newAgent = this._clone();
|
|
@@ -278,6 +329,8 @@ export class Agent {
|
|
|
278
329
|
* Returns a new Agent with the specified failure message.
|
|
279
330
|
*
|
|
280
331
|
* The failure message is played via TTS when the LLM call fails.
|
|
332
|
+
*
|
|
333
|
+
* @deprecated Configure the failure message on the LLM or MLLM vendor instead.
|
|
281
334
|
*/
|
|
282
335
|
withFailureMessage(message) {
|
|
283
336
|
const newAgent = this._clone();
|
|
@@ -287,6 +340,8 @@ export class Agent {
|
|
|
287
340
|
/**
|
|
288
341
|
* Returns a new Agent with the specified maximum conversation history length.
|
|
289
342
|
* Applies to the standard LLM pipeline only; the v2.7 MLLM core schema has no max_history field.
|
|
343
|
+
*
|
|
344
|
+
* @deprecated Configure max history on the LLM vendor instead.
|
|
290
345
|
*/
|
|
291
346
|
withMaxHistory(maxHistory) {
|
|
292
347
|
const newAgent = this._clone();
|
|
@@ -337,6 +392,12 @@ export class Agent {
|
|
|
337
392
|
get name() {
|
|
338
393
|
return this._name;
|
|
339
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
* Get the AI Studio pipeline ID used as this agent's base configuration.
|
|
397
|
+
*/
|
|
398
|
+
get pipelineId() {
|
|
399
|
+
return this._pipelineId;
|
|
400
|
+
}
|
|
340
401
|
/**
|
|
341
402
|
* Get the LLM configuration.
|
|
342
403
|
*/
|
|
@@ -459,6 +520,7 @@ export class Agent {
|
|
|
459
520
|
get config() {
|
|
460
521
|
return {
|
|
461
522
|
name: this._name,
|
|
523
|
+
pipelineId: this._pipelineId,
|
|
462
524
|
instructions: this._instructions,
|
|
463
525
|
turnDetection: this._turnDetection,
|
|
464
526
|
interruption: this._interruption,
|
|
@@ -559,7 +621,6 @@ export class Agent {
|
|
|
559
621
|
idle_timeout: opts.idleTimeout,
|
|
560
622
|
enable_string_uid: opts.enableStringUid,
|
|
561
623
|
mllm: this._mllm,
|
|
562
|
-
turn_detection: this._turnDetection,
|
|
563
624
|
interruption: this._interruption,
|
|
564
625
|
sal: this._sal,
|
|
565
626
|
avatar: this._avatar,
|
|
@@ -583,7 +644,7 @@ export class Agent {
|
|
|
583
644
|
c.failure_message = this._failureMessage;
|
|
584
645
|
}
|
|
585
646
|
}
|
|
586
|
-
return Object.assign(Object.assign({}, base), { mllm: mllmConfig });
|
|
647
|
+
return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
|
|
587
648
|
}
|
|
588
649
|
if (!opts.skipVendorValidation) {
|
|
589
650
|
if (!this._tts) {
|
|
@@ -597,7 +658,9 @@ export class Agent {
|
|
|
597
658
|
? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
|
|
598
659
|
? [{ role: "system", content: this._instructions }]
|
|
599
660
|
: this._llm.system_messages, greeting_message: (_d = this._greeting) !== null && _d !== void 0 ? _d : this._llm.greeting_message, greeting_configs: (_e = this._greetingConfigs) !== null && _e !== void 0 ? _e : this._llm.greeting_configs, failure_message: (_f = this._failureMessage) !== null && _f !== void 0 ? _f : this._llm.failure_message, max_history: (_g = this._maxHistory) !== null && _g !== void 0 ? _g : this._llm.max_history }) : undefined;
|
|
600
|
-
|
|
661
|
+
const asrConfig = this._resolveAsrConfig();
|
|
662
|
+
const turnDetectionConfig = this._resolveTurnDetectionConfig();
|
|
663
|
+
return Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig, llm: llmConfig, tts: this._tts, asr: asrConfig });
|
|
601
664
|
}
|
|
602
665
|
/**
|
|
603
666
|
* Creates a shallow copy of this Agent, preserving the TTSSampleRate type
|
|
@@ -611,6 +674,7 @@ export class Agent {
|
|
|
611
674
|
_clone() {
|
|
612
675
|
const newAgent = new Agent();
|
|
613
676
|
newAgent._name = this._name;
|
|
677
|
+
newAgent._pipelineId = this._pipelineId;
|
|
614
678
|
newAgent._llm = this._llm;
|
|
615
679
|
newAgent._tts = this._tts;
|
|
616
680
|
newAgent._stt = this._stt;
|
|
@@ -632,6 +696,27 @@ export class Agent {
|
|
|
632
696
|
newAgent._greetingConfigs = this._greetingConfigs;
|
|
633
697
|
return newAgent;
|
|
634
698
|
}
|
|
699
|
+
_resolveAsrConfig() {
|
|
700
|
+
var _a;
|
|
701
|
+
const asrConfig = Object.assign({}, ((_a = this._stt) !== null && _a !== void 0 ? _a : {}));
|
|
702
|
+
if (this._stt === undefined) {
|
|
703
|
+
asrConfig.vendor = "ares";
|
|
704
|
+
}
|
|
705
|
+
delete asrConfig.language;
|
|
706
|
+
return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
|
|
707
|
+
}
|
|
708
|
+
_resolveTurnDetectionConfig() {
|
|
709
|
+
var _a, _b;
|
|
710
|
+
const turnDetection = Object.assign({}, ((_a = this._turnDetection) !== null && _a !== void 0 ? _a : {}));
|
|
711
|
+
const existingTurnDetectionLanguage = turnDetection.language;
|
|
712
|
+
const existingAsrLanguage = (_b = this._stt) === null || _b === void 0 ? void 0 : _b.language;
|
|
713
|
+
const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : (existingAsrLanguage !== undefined && isTurnDetectionLanguage(existingAsrLanguage)
|
|
714
|
+
? existingAsrLanguage
|
|
715
|
+
: DEFAULT_TURN_DETECTION_LANGUAGE);
|
|
716
|
+
assertTurnDetectionLanguage(language);
|
|
717
|
+
turnDetection.language = language;
|
|
718
|
+
return turnDetection;
|
|
719
|
+
}
|
|
635
720
|
}
|
|
636
721
|
function _parseNumericUid(uid, label) {
|
|
637
722
|
if (!/^\d+$/.test(uid)) {
|
|
@@ -46,7 +46,7 @@ export interface AgentSessionOptions {
|
|
|
46
46
|
enableStringUid?: boolean;
|
|
47
47
|
/** Preset IDs to use as the base ASR/LLM/TTS configuration for this session */
|
|
48
48
|
preset?: PresetInput;
|
|
49
|
-
/** Published AI Studio pipeline ID to use as
|
|
49
|
+
/** Published AI Studio pipeline ID to use as this session's base configuration. Overrides agent.pipelineId. */
|
|
50
50
|
pipelineId?: string;
|
|
51
51
|
/**
|
|
52
52
|
* Token lifetime in seconds (default: 86400 = 24 hours, Agora maximum).
|
|
@@ -78,8 +78,8 @@ export interface AgentSessionOptions {
|
|
|
78
78
|
* });
|
|
79
79
|
*
|
|
80
80
|
* const agent = new Agent({ name: 'support-assistant', instructions: 'You are a helpful voice assistant.' })
|
|
81
|
-
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini' }))
|
|
82
|
-
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
81
|
+
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
82
|
+
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
83
83
|
* .withStt(new DeepgramSTT({ apiKey: '...', language: 'en-US' }));
|
|
84
84
|
*
|
|
85
85
|
* const session = agent.createSession(client, {
|
|
@@ -33,8 +33,8 @@ import { ExpiresIn as ExpiresInHelper, generateConvoAIToken } from "./token.mjs"
|
|
|
33
33
|
* });
|
|
34
34
|
*
|
|
35
35
|
* const agent = new Agent({ name: 'support-assistant', instructions: 'You are a helpful voice assistant.' })
|
|
36
|
-
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini' }))
|
|
37
|
-
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
36
|
+
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
37
|
+
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
38
38
|
* .withStt(new DeepgramSTT({ apiKey: '...', language: 'en-US' }));
|
|
39
39
|
*
|
|
40
40
|
* const session = agent.createSession(client, {
|
|
@@ -302,7 +302,7 @@ export class AgentSession {
|
|
|
302
302
|
*/
|
|
303
303
|
start() {
|
|
304
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
-
var _a, _b;
|
|
305
|
+
var _a, _b, _c;
|
|
306
306
|
if (this._status !== "idle" && this._status !== "stopped" && this._status !== "error") {
|
|
307
307
|
throw new Error(`Cannot start session in ${this._status} state`);
|
|
308
308
|
}
|
|
@@ -315,6 +315,7 @@ export class AgentSession {
|
|
|
315
315
|
}
|
|
316
316
|
this._status = "starting";
|
|
317
317
|
try {
|
|
318
|
+
const pipelineId = (_a = this._pipelineId) !== null && _a !== void 0 ? _a : this._agent.pipelineId;
|
|
318
319
|
// appCertificate presence is guaranteed by the guard above when no token is provided.
|
|
319
320
|
let expiresIn = this._expiresIn;
|
|
320
321
|
if (expiresIn !== undefined) {
|
|
@@ -330,7 +331,7 @@ export class AgentSession {
|
|
|
330
331
|
const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid,
|
|
331
332
|
// When a preset or pipeline_id is supplied, ASR/LLM/TTS vendor
|
|
332
333
|
// config is optional — the backend fills it from the preset/pipeline.
|
|
333
|
-
skipVendorValidation: !!(this._preset ||
|
|
334
|
+
skipVendorValidation: !!(this._preset || pipelineId) }, tokenOpts));
|
|
334
335
|
const resolved = resolveSessionPresets({
|
|
335
336
|
preset: this._preset,
|
|
336
337
|
properties,
|
|
@@ -341,7 +342,7 @@ export class AgentSession {
|
|
|
341
342
|
appid: this._appId,
|
|
342
343
|
name: this._name,
|
|
343
344
|
preset: resolved.preset,
|
|
344
|
-
pipeline_id:
|
|
345
|
+
pipeline_id: pipelineId,
|
|
345
346
|
properties: enrichedProperties,
|
|
346
347
|
};
|
|
347
348
|
if (this._debug) {
|
|
@@ -352,10 +353,10 @@ export class AgentSession {
|
|
|
352
353
|
console.log("[Agora Debug] Request:", JSON.stringify(request, null, 2));
|
|
353
354
|
}
|
|
354
355
|
const response = yield this._client.agents.start(request, { headers: this._convoAIHeaders() });
|
|
355
|
-
this._agentId = (
|
|
356
|
+
this._agentId = (_b = response.agent_id) !== null && _b !== void 0 ? _b : null;
|
|
356
357
|
this._status = "running";
|
|
357
358
|
this._emit("started", { agentId: this._agentId });
|
|
358
|
-
return (
|
|
359
|
+
return (_c = this._agentId) !== null && _c !== void 0 ? _c : "";
|
|
359
360
|
}
|
|
360
361
|
catch (error) {
|
|
361
362
|
this._status = "error";
|
|
@@ -26,6 +26,7 @@ function _validExample1() {
|
|
|
26
26
|
key: "test",
|
|
27
27
|
modelId: "eleven_flash_v2_5",
|
|
28
28
|
voiceId: "test",
|
|
29
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
29
30
|
sampleRate: 24000,
|
|
30
31
|
}))
|
|
31
32
|
.withAvatar(new LiveAvatarAvatar({
|
|
@@ -41,6 +42,7 @@ function _validExample2() {
|
|
|
41
42
|
key: "test",
|
|
42
43
|
modelId: "eleven_flash_v2_5",
|
|
43
44
|
voiceId: "test",
|
|
45
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
44
46
|
sampleRate: 16000,
|
|
45
47
|
}))
|
|
46
48
|
.withAvatar(new AkoolAvatar({
|
|
@@ -68,6 +70,8 @@ function _validExample4() {
|
|
|
68
70
|
.withTts(new OpenAITTS({
|
|
69
71
|
apiKey: "test",
|
|
70
72
|
voice: "alloy",
|
|
73
|
+
model: "gpt-4o-mini-tts",
|
|
74
|
+
baseUrl: "https://api.openai.com/v1",
|
|
71
75
|
}))
|
|
72
76
|
.withAvatar(new LiveAvatarAvatar({
|
|
73
77
|
apiKey: "test",
|
|
@@ -81,6 +85,7 @@ function _validExample5() {
|
|
|
81
85
|
.withTts(new CartesiaTTS({
|
|
82
86
|
apiKey: "test",
|
|
83
87
|
voiceId: "test",
|
|
88
|
+
modelId: "sonic-2",
|
|
84
89
|
sampleRate: 16000,
|
|
85
90
|
}))
|
|
86
91
|
.withAvatar(new AkoolAvatar({
|
|
@@ -91,7 +96,12 @@ function _validExample5() {
|
|
|
91
96
|
new DeepgramSTT({ model: "nova-3" });
|
|
92
97
|
new OpenAI({ model: "gpt-5-mini" });
|
|
93
98
|
new OpenAITTS({ voice: "alloy" });
|
|
94
|
-
new OpenAI({
|
|
99
|
+
new OpenAI({
|
|
100
|
+
apiKey: "test",
|
|
101
|
+
model: "gpt-5-mini",
|
|
102
|
+
url: "https://api.openai.com/v1/chat/completions",
|
|
103
|
+
vendor: "custom",
|
|
104
|
+
});
|
|
95
105
|
new MiniMaxTTS({
|
|
96
106
|
model: "speech-2.6-turbo",
|
|
97
107
|
});
|
|
@@ -125,6 +135,7 @@ function invalidMismatch1(): Agent<24000> {
|
|
|
125
135
|
key: "test",
|
|
126
136
|
modelId: "eleven_flash_v2_5",
|
|
127
137
|
voiceId: "test",
|
|
138
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
128
139
|
sampleRate: 16000, // ❌ Wrong rate for HeyGen
|
|
129
140
|
})
|
|
130
141
|
)
|
|
@@ -146,6 +157,7 @@ function invalidMismatch2(): Agent<16000> {
|
|
|
146
157
|
key: "test",
|
|
147
158
|
modelId: "eleven_flash_v2_5",
|
|
148
159
|
voiceId: "test",
|
|
160
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
149
161
|
sampleRate: 24000, // ❌ Wrong rate for Akool
|
|
150
162
|
})
|
|
151
163
|
)
|
|
@@ -189,7 +201,8 @@ function invalidEnum1() {
|
|
|
189
201
|
key: "test",
|
|
190
202
|
modelId: "eleven_flash_v2_5",
|
|
191
203
|
voiceId: "test",
|
|
192
|
-
|
|
204
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
205
|
+
sampleRate: 25000, // ❌ Not in enum: 16000, 22050, 24000, 44100
|
|
193
206
|
})
|
|
194
207
|
);
|
|
195
208
|
}
|
|
@@ -214,7 +227,8 @@ function invalidEnum3() {
|
|
|
214
227
|
new CartesiaTTS({
|
|
215
228
|
key: "test",
|
|
216
229
|
voiceId: "test",
|
|
217
|
-
|
|
230
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
231
|
+
sampleRate: 32000, // ❌ Not in enum: 8000-48000 (specific values)
|
|
218
232
|
})
|
|
219
233
|
);
|
|
220
234
|
}
|
|
@@ -236,6 +250,7 @@ function _edgeCase2() {
|
|
|
236
250
|
key: "test",
|
|
237
251
|
modelId: "eleven_flash_v2_5",
|
|
238
252
|
voiceId: "test",
|
|
253
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
239
254
|
sampleRate: 16000,
|
|
240
255
|
}));
|
|
241
256
|
}
|
|
@@ -246,6 +261,7 @@ function _edgeCase3() {
|
|
|
246
261
|
key: "test",
|
|
247
262
|
modelId: "eleven_flash_v2_5",
|
|
248
263
|
voiceId: "test",
|
|
264
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
249
265
|
sampleRate: 24000,
|
|
250
266
|
}))
|
|
251
267
|
.withInstructions("Updated instructions")
|
|
@@ -264,6 +280,7 @@ function _typeInference1() {
|
|
|
264
280
|
key: "test",
|
|
265
281
|
modelId: "eleven_flash_v2_5",
|
|
266
282
|
voiceId: "test",
|
|
283
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
267
284
|
sampleRate: 24000,
|
|
268
285
|
}));
|
|
269
286
|
// Verify: Type should be Agent<24000>
|
|
@@ -275,6 +292,7 @@ function _typeInference2() {
|
|
|
275
292
|
key: "test",
|
|
276
293
|
modelId: "eleven_flash_v2_5",
|
|
277
294
|
voiceId: "test",
|
|
295
|
+
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
278
296
|
sampleRate: 16000,
|
|
279
297
|
}));
|
|
280
298
|
// Verify: Type should be Agent<16000>
|
|
@@ -285,6 +303,8 @@ function _typeInference3() {
|
|
|
285
303
|
const openAIAgent = new Agent({ instructions: "Test" }).withTts(new OpenAITTS({
|
|
286
304
|
apiKey: "test",
|
|
287
305
|
voice: "alloy",
|
|
306
|
+
model: "gpt-4o-mini-tts",
|
|
307
|
+
baseUrl: "https://api.openai.com/v1",
|
|
288
308
|
}));
|
|
289
309
|
// Verify: OpenAI is fixed at 24kHz, so type should be Agent<24000>
|
|
290
310
|
const _typeCheck = openAIAgent;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { AgentThinkAgentManagementRequest as AgentThinkRequestNS } from "../api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.mjs";
|
|
6
6
|
import { SpeakAgentsRequest as SpeakAgentsRequestNS } from "../api/resources/agents/client/requests/SpeakAgentsRequest.mjs";
|
|
7
7
|
import { StartAgentsRequest as StartAgentsRequestNS } from "../api/resources/agents/client/requests/StartAgentsRequest.mjs";
|
|
8
|
+
import { MllmTurnDetection as MllmTurnDetectionNS } from "../api/types/MllmTurnDetection.mjs";
|
|
8
9
|
/** Data channel: `"rtm"` | `"datastream"` */
|
|
9
10
|
export declare const DataChannel: typeof StartAgentsRequestNS.Properties.Parameters.DataChannel;
|
|
10
11
|
/** RTC audio scenario: `"default"` | `"chorus"` | `"aiserver"` */
|
|
@@ -45,13 +46,13 @@ export declare const SpeakPriorityAppend: SpeakAgentsRequestNS.Priority;
|
|
|
45
46
|
/** Drop the message if the agent is busy. */
|
|
46
47
|
export declare const SpeakPriorityIgnore: SpeakAgentsRequestNS.Priority;
|
|
47
48
|
/** MLLM turn-detection mode: `"agora_vad"` | `"server_vad"` | `"semantic_vad"` */
|
|
48
|
-
export declare const MllmTurnDetectionModeValues: typeof
|
|
49
|
+
export declare const MllmTurnDetectionModeValues: typeof MllmTurnDetectionNS.Mode;
|
|
49
50
|
/** MLLM turn-detection mode: Agora VAD. */
|
|
50
|
-
export declare const MllmTurnDetectionModeAgoraVad:
|
|
51
|
+
export declare const MllmTurnDetectionModeAgoraVad: MllmTurnDetectionNS.Mode;
|
|
51
52
|
/** MLLM turn-detection mode: server/vendor VAD. */
|
|
52
|
-
export declare const MllmTurnDetectionModeServerVad:
|
|
53
|
+
export declare const MllmTurnDetectionModeServerVad: MllmTurnDetectionNS.Mode;
|
|
53
54
|
/** MLLM turn-detection mode: semantic VAD. */
|
|
54
|
-
export declare const MllmTurnDetectionModeSemanticVad:
|
|
55
|
+
export declare const MllmTurnDetectionModeSemanticVad: MllmTurnDetectionNS.Mode;
|
|
55
56
|
/** Think action when the agent is listening: inject custom text without interrupting. */
|
|
56
57
|
export declare const ThinkOnListeningActionInject: AgentThinkRequestNS.OnListeningAction;
|
|
57
58
|
/** Think action when the agent is listening: interrupt and start a new turn. */
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { AgentThinkAgentManagementRequest as AgentThinkRequestNS } from "../api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.mjs";
|
|
7
7
|
import { SpeakAgentsRequest as SpeakAgentsRequestNS } from "../api/resources/agents/client/requests/SpeakAgentsRequest.mjs";
|
|
8
8
|
import { StartAgentsRequest as StartAgentsRequestNS } from "../api/resources/agents/client/requests/StartAgentsRequest.mjs";
|
|
9
|
+
import { MllmTurnDetection as MllmTurnDetectionNS } from "../api/types/MllmTurnDetection.mjs";
|
|
9
10
|
/** Data channel: `"rtm"` | `"datastream"` */
|
|
10
11
|
export const DataChannel = StartAgentsRequestNS.Properties.Parameters.DataChannel;
|
|
11
12
|
/** RTC audio scenario: `"default"` | `"chorus"` | `"aiserver"` */
|
|
@@ -46,13 +47,13 @@ export const SpeakPriorityAppend = SpeakAgentsRequestNS.Priority.Append;
|
|
|
46
47
|
/** Drop the message if the agent is busy. */
|
|
47
48
|
export const SpeakPriorityIgnore = SpeakAgentsRequestNS.Priority.Ignore;
|
|
48
49
|
/** MLLM turn-detection mode: `"agora_vad"` | `"server_vad"` | `"semantic_vad"` */
|
|
49
|
-
export const MllmTurnDetectionModeValues =
|
|
50
|
+
export const MllmTurnDetectionModeValues = MllmTurnDetectionNS.Mode;
|
|
50
51
|
/** MLLM turn-detection mode: Agora VAD. */
|
|
51
|
-
export const MllmTurnDetectionModeAgoraVad =
|
|
52
|
+
export const MllmTurnDetectionModeAgoraVad = MllmTurnDetectionNS.Mode.AgoraVad;
|
|
52
53
|
/** MLLM turn-detection mode: server/vendor VAD. */
|
|
53
|
-
export const MllmTurnDetectionModeServerVad =
|
|
54
|
+
export const MllmTurnDetectionModeServerVad = MllmTurnDetectionNS.Mode.ServerVad;
|
|
54
55
|
/** MLLM turn-detection mode: semantic VAD. */
|
|
55
|
-
export const MllmTurnDetectionModeSemanticVad =
|
|
56
|
+
export const MllmTurnDetectionModeSemanticVad = MllmTurnDetectionNS.Mode.SemanticVad;
|
|
56
57
|
/** Think action when the agent is listening: inject custom text without interrupting. */
|
|
57
58
|
export const ThinkOnListeningActionInject = AgentThinkRequestNS.OnListeningAction.Inject;
|
|
58
59
|
/** Think action when the agent is listening: interrupt and start a new turn. */
|
|
@@ -30,7 +30,7 @@ export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPre
|
|
|
30
30
|
export { AgentPresets, normalizePresetInput } from "./presets.mjs";
|
|
31
31
|
export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.mjs";
|
|
32
32
|
export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.mjs";
|
|
33
|
-
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AvatarConfig, AvatarVendor, CartesiaTts, CartesiaTtsParams, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, Eagerness, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FillerWordsConfig, FillerWordsContent, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTts, FishAudioTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GoogleTts, GoogleTtsParams, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmStyle, McpServersItem, MicrosoftTts, MicrosoftTtsParams, MinimaxTts, MinimaxTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTts, MurfTtsParams, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, RimeTts, RimeTtsParams, RtcConfig, SalConfig, SalMode, SarvamTts, SarvamTtsParams, SayOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, SttVendor, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionNestedConfig, TurnDetectionType, } from "./types.mjs";
|
|
33
|
+
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AvatarConfig, AvatarVendor, CartesiaTts, CartesiaTtsParams, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, Eagerness, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FillerWordsConfig, FillerWordsContent, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTts, FishAudioTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GoogleTts, GoogleTtsParams, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmStyle, McpServersItem, MicrosoftTts, MicrosoftTtsParams, MinimaxTts, MinimaxTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTts, MurfTtsParams, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, RimeTts, RimeTtsParams, RtcConfig, SalConfig, SalMode, SarvamTts, SarvamTtsParams, SayOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, SttVendor, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, } from "./types.mjs";
|
|
34
34
|
export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LiveAvatarAvatarOptions, } from "./vendors/avatar.mjs";
|
|
35
35
|
export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.mjs";
|
|
36
36
|
export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.mjs";
|