agora-agents 2.0.1 → 2.1.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.
- package/README.md +38 -9
- package/dist/cjs/AgoraPoolClient.js +7 -2
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.js +16 -8
- package/dist/cjs/agentkit/Agent.d.ts +56 -11
- package/dist/cjs/agentkit/Agent.js +114 -15
- package/dist/cjs/agentkit/AgentSession.d.ts +4 -3
- package/dist/cjs/agentkit/AgentSession.js +39 -10
- 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/presets.d.ts +30 -0
- package/dist/cjs/agentkit/presets.js +9 -2
- 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/core/base64.js +5 -1
- 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/AgoraPoolClient.mjs +7 -2
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.mjs +16 -8
- package/dist/esm/agentkit/Agent.d.mts +56 -11
- package/dist/esm/agentkit/Agent.mjs +114 -15
- package/dist/esm/agentkit/AgentSession.d.mts +4 -3
- package/dist/esm/agentkit/AgentSession.mjs +40 -11
- 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/presets.d.mts +30 -0
- package/dist/esm/agentkit/presets.mjs +9 -6
- 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/core/base64.mjs +5 -1
- 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 +2 -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
|
*/
|
|
@@ -388,10 +426,15 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
388
426
|
idleTimeout?: number;
|
|
389
427
|
enableStringUid?: boolean;
|
|
390
428
|
/**
|
|
391
|
-
*
|
|
392
|
-
* `
|
|
429
|
+
* @deprecated Use `skipVendorValidationCategories` and
|
|
430
|
+
* `allowMissingVendorCategories` instead. This broad escape hatch will be
|
|
431
|
+
* removed in a future release.
|
|
393
432
|
*/
|
|
394
433
|
skipVendorValidation?: boolean;
|
|
434
|
+
/** Skip generated request-shape validation for the listed provider categories. */
|
|
435
|
+
skipVendorValidationCategories?: ReadonlySet<"asr" | "llm" | "tts">;
|
|
436
|
+
/** Allow the listed provider categories to be omitted from properties. */
|
|
437
|
+
allowMissingVendorCategories?: ReadonlySet<"asr" | "llm" | "tts">;
|
|
395
438
|
} & ({
|
|
396
439
|
token: string;
|
|
397
440
|
appId?: undefined;
|
|
@@ -412,4 +455,6 @@ export declare class Agent<TTSSampleRate extends number = number> {
|
|
|
412
455
|
* If a new private field is added to Agent, it MUST also be added here.
|
|
413
456
|
*/
|
|
414
457
|
private _clone;
|
|
458
|
+
private _resolveAsrConfig;
|
|
459
|
+
private _resolveTurnDetectionConfig;
|
|
415
460
|
}
|
|
@@ -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,
|
|
@@ -516,7 +578,7 @@ export class Agent {
|
|
|
516
578
|
* and RTM privileges (required for RTM-enabled sessions).
|
|
517
579
|
*/
|
|
518
580
|
toProperties(opts) {
|
|
519
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
581
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
520
582
|
// In MLLM mode the backend handles audio end-to-end; LLM, TTS, and ASR
|
|
521
583
|
// are not required.
|
|
522
584
|
const isMllmMode = ((_a = this._mllm) === null || _a === void 0 ? void 0 : _a.enable) === true || this._mllm !== undefined;
|
|
@@ -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,21 +644,37 @@ 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
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
649
|
+
const skipCategories = new Set((_d = opts.skipVendorValidationCategories) !== null && _d !== void 0 ? _d : []);
|
|
650
|
+
const allowMissingCategories = new Set((_e = opts.allowMissingVendorCategories) !== null && _e !== void 0 ? _e : []);
|
|
651
|
+
if (opts.skipVendorValidation) {
|
|
652
|
+
for (const category of ["asr", "llm", "tts"]) {
|
|
653
|
+
skipCategories.add(category);
|
|
654
|
+
allowMissingCategories.add(category);
|
|
594
655
|
}
|
|
595
656
|
}
|
|
657
|
+
const skipLlmValidation = skipCategories.has("llm");
|
|
658
|
+
const skipTtsValidation = skipCategories.has("tts");
|
|
659
|
+
const allowMissingAsr = allowMissingCategories.has("asr");
|
|
660
|
+
const allowMissingLlm = allowMissingCategories.has("llm");
|
|
661
|
+
const allowMissingTts = allowMissingCategories.has("tts");
|
|
662
|
+
if (!this._tts && !(skipTtsValidation || allowMissingTts)) {
|
|
663
|
+
throw new Error("TTS configuration is required. Use withTts() to set it.");
|
|
664
|
+
}
|
|
665
|
+
if (!this._llm && !(skipLlmValidation || allowMissingLlm)) {
|
|
666
|
+
throw new Error("LLM configuration is required. Use withLlm() to set it.");
|
|
667
|
+
}
|
|
596
668
|
const llmConfig = this._llm
|
|
597
669
|
? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
|
|
598
670
|
? [{ role: "system", content: this._instructions }]
|
|
599
|
-
: this._llm.system_messages, greeting_message: (
|
|
600
|
-
|
|
671
|
+
: this._llm.system_messages, greeting_message: (_f = this._greeting) !== null && _f !== void 0 ? _f : this._llm.greeting_message, greeting_configs: (_g = this._greetingConfigs) !== null && _g !== void 0 ? _g : this._llm.greeting_configs, failure_message: (_h = this._failureMessage) !== null && _h !== void 0 ? _h : this._llm.failure_message, max_history: (_j = this._maxHistory) !== null && _j !== void 0 ? _j : this._llm.max_history }) : undefined;
|
|
672
|
+
const asrConfig = this._stt !== undefined || !allowMissingAsr
|
|
673
|
+
? this._resolveAsrConfig()
|
|
674
|
+
: undefined;
|
|
675
|
+
const turnDetectionConfig = this._resolveTurnDetectionConfig();
|
|
676
|
+
const ttsConfig = this._tts;
|
|
677
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig }), (llmConfig && { llm: llmConfig })), (ttsConfig && { tts: ttsConfig })), (asrConfig && { asr: asrConfig }));
|
|
601
678
|
}
|
|
602
679
|
/**
|
|
603
680
|
* Creates a shallow copy of this Agent, preserving the TTSSampleRate type
|
|
@@ -611,6 +688,7 @@ export class Agent {
|
|
|
611
688
|
_clone() {
|
|
612
689
|
const newAgent = new Agent();
|
|
613
690
|
newAgent._name = this._name;
|
|
691
|
+
newAgent._pipelineId = this._pipelineId;
|
|
614
692
|
newAgent._llm = this._llm;
|
|
615
693
|
newAgent._tts = this._tts;
|
|
616
694
|
newAgent._stt = this._stt;
|
|
@@ -632,6 +710,27 @@ export class Agent {
|
|
|
632
710
|
newAgent._greetingConfigs = this._greetingConfigs;
|
|
633
711
|
return newAgent;
|
|
634
712
|
}
|
|
713
|
+
_resolveAsrConfig() {
|
|
714
|
+
var _a;
|
|
715
|
+
const asrConfig = Object.assign({}, ((_a = this._stt) !== null && _a !== void 0 ? _a : {}));
|
|
716
|
+
if (this._stt === undefined) {
|
|
717
|
+
asrConfig.vendor = "ares";
|
|
718
|
+
}
|
|
719
|
+
delete asrConfig.language;
|
|
720
|
+
return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
|
|
721
|
+
}
|
|
722
|
+
_resolveTurnDetectionConfig() {
|
|
723
|
+
var _a, _b;
|
|
724
|
+
const turnDetection = Object.assign({}, ((_a = this._turnDetection) !== null && _a !== void 0 ? _a : {}));
|
|
725
|
+
const existingTurnDetectionLanguage = turnDetection.language;
|
|
726
|
+
const existingAsrLanguage = (_b = this._stt) === null || _b === void 0 ? void 0 : _b.language;
|
|
727
|
+
const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : (existingAsrLanguage !== undefined && isTurnDetectionLanguage(existingAsrLanguage)
|
|
728
|
+
? existingAsrLanguage
|
|
729
|
+
: DEFAULT_TURN_DETECTION_LANGUAGE);
|
|
730
|
+
assertTurnDetectionLanguage(language);
|
|
731
|
+
turnDetection.language = language;
|
|
732
|
+
return turnDetection;
|
|
733
|
+
}
|
|
635
734
|
}
|
|
636
735
|
function _parseNumericUid(uid, label) {
|
|
637
736
|
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, {
|
|
@@ -188,6 +188,7 @@ export declare class AgentSession {
|
|
|
188
188
|
*/
|
|
189
189
|
private _enrichAvatarParams;
|
|
190
190
|
private _validateEnrichedAvatarConfig;
|
|
191
|
+
private _vendorValidationCategories;
|
|
191
192
|
/**
|
|
192
193
|
* Start the agent session.
|
|
193
194
|
*
|
|
@@ -15,7 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
15
|
};
|
|
16
16
|
import { AgoraError } from "../errors/index.mjs";
|
|
17
17
|
import { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
|
|
18
|
-
import { resolveSessionPresets } from "./presets.mjs";
|
|
18
|
+
import { getPresetCategory, inferAsrPreset, inferLlmPreset, inferTtsPreset, normalizePresetInput, resolveSessionPresets, } from "./presets.mjs";
|
|
19
19
|
import { ExpiresIn as ExpiresInHelper, generateConvoAIToken } from "./token.mjs";
|
|
20
20
|
/**
|
|
21
21
|
* AgentSession class for managing agent lifecycle and interactions.
|
|
@@ -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, {
|
|
@@ -292,6 +292,35 @@ export class AgentSession {
|
|
|
292
292
|
"Pass agoraToken on the avatar vendor or provide appCertificate for automatic token generation.");
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
+
_vendorValidationCategories(pipelineId) {
|
|
296
|
+
const skipVendorValidationCategories = new Set();
|
|
297
|
+
const allowMissingVendorCategories = new Set();
|
|
298
|
+
if (pipelineId) {
|
|
299
|
+
allowMissingVendorCategories.add("asr");
|
|
300
|
+
allowMissingVendorCategories.add("llm");
|
|
301
|
+
allowMissingVendorCategories.add("tts");
|
|
302
|
+
}
|
|
303
|
+
const normalizedPreset = normalizePresetInput(this._preset);
|
|
304
|
+
if (normalizedPreset) {
|
|
305
|
+
for (const item of normalizedPreset.split(",")) {
|
|
306
|
+
const category = getPresetCategory(item);
|
|
307
|
+
if (category) {
|
|
308
|
+
skipVendorValidationCategories.add(category);
|
|
309
|
+
allowMissingVendorCategories.add(category);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (inferAsrPreset(this._agent.stt)) {
|
|
314
|
+
skipVendorValidationCategories.add("asr");
|
|
315
|
+
}
|
|
316
|
+
if (inferLlmPreset(this._agent.llm)) {
|
|
317
|
+
skipVendorValidationCategories.add("llm");
|
|
318
|
+
}
|
|
319
|
+
if (inferTtsPreset(this._agent.tts)) {
|
|
320
|
+
skipVendorValidationCategories.add("tts");
|
|
321
|
+
}
|
|
322
|
+
return { skipVendorValidationCategories, allowMissingVendorCategories };
|
|
323
|
+
}
|
|
295
324
|
/**
|
|
296
325
|
* Start the agent session.
|
|
297
326
|
*
|
|
@@ -302,7 +331,7 @@ export class AgentSession {
|
|
|
302
331
|
*/
|
|
303
332
|
start() {
|
|
304
333
|
return __awaiter(this, void 0, void 0, function* () {
|
|
305
|
-
var _a, _b;
|
|
334
|
+
var _a, _b, _c;
|
|
306
335
|
if (this._status !== "idle" && this._status !== "stopped" && this._status !== "error") {
|
|
307
336
|
throw new Error(`Cannot start session in ${this._status} state`);
|
|
308
337
|
}
|
|
@@ -315,6 +344,7 @@ export class AgentSession {
|
|
|
315
344
|
}
|
|
316
345
|
this._status = "starting";
|
|
317
346
|
try {
|
|
347
|
+
const pipelineId = (_a = this._pipelineId) !== null && _a !== void 0 ? _a : this._agent.pipelineId;
|
|
318
348
|
// appCertificate presence is guaranteed by the guard above when no token is provided.
|
|
319
349
|
let expiresIn = this._expiresIn;
|
|
320
350
|
if (expiresIn !== undefined) {
|
|
@@ -327,10 +357,9 @@ export class AgentSession {
|
|
|
327
357
|
appCertificate: this._appCertificate,
|
|
328
358
|
expiresIn,
|
|
329
359
|
};
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
skipVendorValidation: !!(this._preset || this._pipelineId) }, tokenOpts));
|
|
360
|
+
const { skipVendorValidationCategories, allowMissingVendorCategories } = this._vendorValidationCategories(pipelineId);
|
|
361
|
+
const properties = this._agent.toProperties(Object.assign({ channel: this._channel, agentUid: this._agentUid, remoteUids: this._remoteUids, idleTimeout: this._idleTimeout, enableStringUid: this._enableStringUid, skipVendorValidationCategories,
|
|
362
|
+
allowMissingVendorCategories }, tokenOpts));
|
|
334
363
|
const resolved = resolveSessionPresets({
|
|
335
364
|
preset: this._preset,
|
|
336
365
|
properties,
|
|
@@ -341,7 +370,7 @@ export class AgentSession {
|
|
|
341
370
|
appid: this._appId,
|
|
342
371
|
name: this._name,
|
|
343
372
|
preset: resolved.preset,
|
|
344
|
-
pipeline_id:
|
|
373
|
+
pipeline_id: pipelineId,
|
|
345
374
|
properties: enrichedProperties,
|
|
346
375
|
};
|
|
347
376
|
if (this._debug) {
|
|
@@ -352,10 +381,10 @@ export class AgentSession {
|
|
|
352
381
|
console.log("[Agora Debug] Request:", JSON.stringify(request, null, 2));
|
|
353
382
|
}
|
|
354
383
|
const response = yield this._client.agents.start(request, { headers: this._convoAIHeaders() });
|
|
355
|
-
this._agentId = (
|
|
384
|
+
this._agentId = (_b = response.agent_id) !== null && _b !== void 0 ? _b : null;
|
|
356
385
|
this._status = "running";
|
|
357
386
|
this._emit("started", { agentId: this._agentId });
|
|
358
|
-
return (
|
|
387
|
+
return (_c = this._agentId) !== null && _c !== void 0 ? _c : "";
|
|
359
388
|
}
|
|
360
389
|
catch (error) {
|
|
361
390
|
this._status = "error";
|