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
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ npm install agora-agents
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
18
|
Start with the `Agent` builder: create a client with app credentials, choose your ASR, LLM, and TTS providers, then start a session. Omit vendor API keys for supported Agora-managed models, or provide keys when you want BYOK.
|
|
19
|
+
Set Agora interaction language with `turnDetection.language`; provider-specific STT language values remain under `asr.params`.
|
|
19
20
|
|
|
20
21
|
```typescript
|
|
21
22
|
import {
|
|
@@ -44,11 +45,8 @@ export async function startConversation(): Promise<string> {
|
|
|
44
45
|
|
|
45
46
|
const agent = new Agent({
|
|
46
47
|
name: `conversation-${Date.now()}`,
|
|
47
|
-
instructions: AGENT_PROMPT,
|
|
48
|
-
greeting: GREETING,
|
|
49
|
-
failureMessage: 'Please wait a moment.',
|
|
50
|
-
maxHistory: 50,
|
|
51
48
|
turnDetection: {
|
|
49
|
+
language: 'en-US',
|
|
52
50
|
config: {
|
|
53
51
|
speech_threshold: 0.5,
|
|
54
52
|
start_of_speech: {
|
|
@@ -84,9 +82,10 @@ export async function startConversation(): Promise<string> {
|
|
|
84
82
|
.withLlm(
|
|
85
83
|
new OpenAI({
|
|
86
84
|
model: 'gpt-4o-mini',
|
|
85
|
+
systemMessages: [{ role: 'system', content: AGENT_PROMPT }],
|
|
87
86
|
greetingMessage: GREETING,
|
|
88
87
|
failureMessage: 'Please wait a moment.',
|
|
89
|
-
maxHistory:
|
|
88
|
+
maxHistory: 50,
|
|
90
89
|
params: {
|
|
91
90
|
max_tokens: 1024,
|
|
92
91
|
temperature: 0.7,
|
|
@@ -118,15 +117,42 @@ export async function startConversation(): Promise<string> {
|
|
|
118
117
|
|
|
119
118
|
`AgoraClient` generates the required ConvoAI REST auth and RTC join tokens automatically when you provide `appId` and `appCertificate`. For supported Agora-managed models, leave vendor API keys unset; provide keys when you want BYOK.
|
|
120
119
|
|
|
120
|
+
## AI Studio pipeline IDs
|
|
121
|
+
|
|
122
|
+
Use `pipelineId` when you want a published AI Studio pipeline to provide the base agent configuration:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const agent = new Agent({
|
|
126
|
+
name: 'support',
|
|
127
|
+
pipelineId: 'studio-pipeline-id',
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const session = agent.createSession(client, {
|
|
131
|
+
channel: 'support-room',
|
|
132
|
+
agentUid: '1',
|
|
133
|
+
remoteUids: ['100'],
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
You can override it per session:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const session = agent.createSession(client, {
|
|
141
|
+
channel: 'support-room',
|
|
142
|
+
agentUid: '1',
|
|
143
|
+
remoteUids: ['100'],
|
|
144
|
+
pipelineId: 'session-pipeline-id',
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
AgentKit sends the resolved value as the top-level `/join` field `pipeline_id`, not inside `properties`. Explicit Agent config such as `.withLlm()`, `.withTts()`, `.withStt()`, `.withMllm()`, and `advancedFeatures` may send `properties` fields that override the saved pipeline settings.
|
|
149
|
+
|
|
121
150
|
### BYOK version
|
|
122
151
|
|
|
123
152
|
Use the same `Agent` builder shape, but provide credentials explicitly when you want vendor-managed billing and routing instead of Agora-managed models.
|
|
124
153
|
|
|
125
154
|
```typescript
|
|
126
|
-
const agent = new Agent({
|
|
127
|
-
instructions: SUPPORT_PROMPT,
|
|
128
|
-
greeting: GREETING,
|
|
129
|
-
})
|
|
155
|
+
const agent = new Agent({ turnDetection: { language: 'en-US' } })
|
|
130
156
|
.withStt(
|
|
131
157
|
new DeepgramSTT({
|
|
132
158
|
apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
@@ -137,7 +163,10 @@ const agent = new Agent({
|
|
|
137
163
|
.withLlm(
|
|
138
164
|
new OpenAI({
|
|
139
165
|
apiKey: process.env.OPENAI_API_KEY!,
|
|
166
|
+
url: 'https://api.openai.com/v1/chat/completions',
|
|
140
167
|
model: 'gpt-4o-mini',
|
|
168
|
+
systemMessages: [{ role: 'system', content: SUPPORT_PROMPT }],
|
|
169
|
+
greetingMessage: GREETING,
|
|
141
170
|
maxTokens: 1024,
|
|
142
171
|
temperature: 0.7,
|
|
143
172
|
topP: 0.95,
|
|
@@ -69,14 +69,19 @@ class AgoraClient extends Client_js_1.AgoraClient {
|
|
|
69
69
|
let authMode;
|
|
70
70
|
let username;
|
|
71
71
|
let password;
|
|
72
|
+
let authToken = "";
|
|
72
73
|
const opts = options;
|
|
73
|
-
if (opts.customerId != null) {
|
|
74
|
+
if (opts.customerId != null && opts.customerSecret != null) {
|
|
74
75
|
authMode = "basic";
|
|
75
76
|
username = opts.customerId;
|
|
76
77
|
password = opts.customerSecret;
|
|
77
78
|
}
|
|
79
|
+
else if (opts.customerId != null) {
|
|
80
|
+
throw new Error("customerSecret is required when customerId is provided");
|
|
81
|
+
}
|
|
78
82
|
else if (opts.authToken != null) {
|
|
79
83
|
authMode = "token";
|
|
84
|
+
authToken = opts.authToken;
|
|
80
85
|
username = "";
|
|
81
86
|
password = "";
|
|
82
87
|
}
|
|
@@ -91,7 +96,7 @@ class AgoraClient extends Client_js_1.AgoraClient {
|
|
|
91
96
|
const authorization = authMode === "basic"
|
|
92
97
|
? `Basic ${Buffer.from(`${username}:${password}`).toString("base64")}`
|
|
93
98
|
: authMode === "token"
|
|
94
|
-
? `agora token=${
|
|
99
|
+
? `agora token=${authToken}`
|
|
95
100
|
: "";
|
|
96
101
|
super(Object.assign(Object.assign({}, rest), { username,
|
|
97
102
|
password,
|
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -41,8 +41,8 @@ function normalizeClientOptions(options) {
|
|
|
41
41
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
42
42
|
"X-Fern-Language": "JavaScript",
|
|
43
43
|
"X-Fern-SDK-Name": "agora-agents",
|
|
44
|
-
"X-Fern-SDK-Version": "v2.
|
|
45
|
-
"User-Agent": "agora-agents/v2.
|
|
44
|
+
"X-Fern-SDK-Version": "v2.1.1",
|
|
45
|
+
"User-Agent": "agora-agents/v2.1.1",
|
|
46
46
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
47
47
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
48
48
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
package/dist/cjs/Client.js
CHANGED
|
@@ -12,20 +12,28 @@ class AgoraClient {
|
|
|
12
12
|
this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
|
|
13
13
|
}
|
|
14
14
|
get agents() {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if (this._agents == null) {
|
|
16
|
+
this._agents = new Client_js_2.AgentsClient(this._options);
|
|
17
|
+
}
|
|
18
|
+
return this._agents;
|
|
17
19
|
}
|
|
18
20
|
get agentManagement() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
if (this._agentManagement == null) {
|
|
22
|
+
this._agentManagement = new Client_js_1.AgentManagementClient(this._options);
|
|
23
|
+
}
|
|
24
|
+
return this._agentManagement;
|
|
21
25
|
}
|
|
22
26
|
get telephony() {
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
if (this._telephony == null) {
|
|
28
|
+
this._telephony = new Client_js_4.TelephonyClient(this._options);
|
|
29
|
+
}
|
|
30
|
+
return this._telephony;
|
|
25
31
|
}
|
|
26
32
|
get phoneNumbers() {
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
if (this._phoneNumbers == null) {
|
|
34
|
+
this._phoneNumbers = new Client_js_3.PhoneNumbersClient(this._options);
|
|
35
|
+
}
|
|
36
|
+
return this._phoneNumbers;
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
exports.AgoraClient = AgoraClient;
|
|
@@ -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
|
}
|
|
@@ -9,6 +9,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.Agent = void 0;
|
|
10
10
|
const AgentSession_js_1 = require("./AgentSession.js");
|
|
11
11
|
const token_js_1 = require("./token.js");
|
|
12
|
+
const DEFAULT_TURN_DETECTION_LANGUAGE = "en-US";
|
|
13
|
+
const INTERACTION_LANGUAGES = new Set([
|
|
14
|
+
"ar-EG",
|
|
15
|
+
"ar-JO",
|
|
16
|
+
"ar-SA",
|
|
17
|
+
"ar-AE",
|
|
18
|
+
"bn-IN",
|
|
19
|
+
"zh-CN",
|
|
20
|
+
"zh-HK",
|
|
21
|
+
"zh-TW",
|
|
22
|
+
"nl-NL",
|
|
23
|
+
"en-IN",
|
|
24
|
+
"en-US",
|
|
25
|
+
"fil-PH",
|
|
26
|
+
"fr-FR",
|
|
27
|
+
"de-DE",
|
|
28
|
+
"gu-IN",
|
|
29
|
+
"he-IL",
|
|
30
|
+
"hi-IN",
|
|
31
|
+
"id-ID",
|
|
32
|
+
"it-IT",
|
|
33
|
+
"ja-JP",
|
|
34
|
+
"kn-IN",
|
|
35
|
+
"ko-KR",
|
|
36
|
+
"ms-MY",
|
|
37
|
+
"fa-IR",
|
|
38
|
+
"pt-PT",
|
|
39
|
+
"ru-RU",
|
|
40
|
+
"es-ES",
|
|
41
|
+
"ta-IN",
|
|
42
|
+
"te-IN",
|
|
43
|
+
"th-TH",
|
|
44
|
+
"tr-TR",
|
|
45
|
+
"vi-VN",
|
|
46
|
+
]);
|
|
47
|
+
function isTurnDetectionLanguage(value) {
|
|
48
|
+
return INTERACTION_LANGUAGES.has(value);
|
|
49
|
+
}
|
|
50
|
+
function assertTurnDetectionLanguage(value) {
|
|
51
|
+
if (!isTurnDetectionLanguage(value)) {
|
|
52
|
+
throw new Error(`Invalid interaction language: ${value}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
12
55
|
/**
|
|
13
56
|
* Agent class representing a reusable agent configuration.
|
|
14
57
|
*
|
|
@@ -20,14 +63,15 @@ const token_js_1 = require("./token.js");
|
|
|
20
63
|
*
|
|
21
64
|
* // Use the fluent builder pattern to configure vendors
|
|
22
65
|
* const agent = new Agent({ instructions: 'You are helpful.' })
|
|
23
|
-
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4' }))
|
|
24
|
-
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
66
|
+
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
67
|
+
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
25
68
|
* .withStt(new DeepgramSTT({ apiKey: '...', model: 'nova-2' }));
|
|
26
69
|
* ```
|
|
27
70
|
*/
|
|
28
71
|
class Agent {
|
|
29
72
|
constructor(options = {}) {
|
|
30
73
|
this._name = options.name;
|
|
74
|
+
this._pipelineId = options.pipelineId;
|
|
31
75
|
this._instructions = options.instructions;
|
|
32
76
|
this._greeting = options.greeting;
|
|
33
77
|
this._failureMessage = options.failureMessage;
|
|
@@ -69,7 +113,7 @@ class Agent {
|
|
|
69
113
|
/**
|
|
70
114
|
* Returns a new Agent with the specified LLM vendor.
|
|
71
115
|
*
|
|
72
|
-
* @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' }))
|
|
73
117
|
*/
|
|
74
118
|
withLlm(vendor) {
|
|
75
119
|
const newAgent = this._clone();
|
|
@@ -82,7 +126,7 @@ class Agent {
|
|
|
82
126
|
* The sample rate type is tracked for compile-time avatar compatibility checking.
|
|
83
127
|
*
|
|
84
128
|
* @template SR - Sample rate literal type
|
|
85
|
-
* @param vendor - TTS vendor instance (e.g., new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', sampleRate: 24000 }))
|
|
129
|
+
* @param vendor - TTS vendor instance (e.g., new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
86
130
|
* @returns Agent with tracked sample rate type
|
|
87
131
|
*/
|
|
88
132
|
withTts(vendor) {
|
|
@@ -166,6 +210,7 @@ class Agent {
|
|
|
166
210
|
* key: '...',
|
|
167
211
|
* modelId: '...',
|
|
168
212
|
* voiceId: '...',
|
|
213
|
+
* baseUrl: 'wss://api.elevenlabs.io/v1',
|
|
169
214
|
* sampleRate: 24000, // Required for HeyGen
|
|
170
215
|
* }))
|
|
171
216
|
* .withAvatar(new HeyGenAvatar({
|
|
@@ -200,6 +245,8 @@ class Agent {
|
|
|
200
245
|
}
|
|
201
246
|
/**
|
|
202
247
|
* Returns a new Agent with the specified instructions.
|
|
248
|
+
*
|
|
249
|
+
* @deprecated Configure system messages on the LLM vendor instead.
|
|
203
250
|
*/
|
|
204
251
|
withInstructions(instructions) {
|
|
205
252
|
const newAgent = this._clone();
|
|
@@ -208,6 +255,8 @@ class Agent {
|
|
|
208
255
|
}
|
|
209
256
|
/**
|
|
210
257
|
* Returns a new Agent with the specified greeting message.
|
|
258
|
+
*
|
|
259
|
+
* @deprecated Configure the greeting on the LLM or MLLM vendor instead.
|
|
211
260
|
*/
|
|
212
261
|
withGreeting(greeting) {
|
|
213
262
|
const newAgent = this._clone();
|
|
@@ -219,6 +268,8 @@ class Agent {
|
|
|
219
268
|
*
|
|
220
269
|
* Serializes to `llm.greeting_configs`. Agent-level values override any
|
|
221
270
|
* vendor-level `greeting_configs` configured on the LLM vendor.
|
|
271
|
+
*
|
|
272
|
+
* @deprecated Configure greeting playback on the LLM vendor instead.
|
|
222
273
|
*/
|
|
223
274
|
withGreetingConfigs(configs) {
|
|
224
275
|
const newAgent = this._clone();
|
|
@@ -281,6 +332,8 @@ class Agent {
|
|
|
281
332
|
* Returns a new Agent with the specified failure message.
|
|
282
333
|
*
|
|
283
334
|
* The failure message is played via TTS when the LLM call fails.
|
|
335
|
+
*
|
|
336
|
+
* @deprecated Configure the failure message on the LLM or MLLM vendor instead.
|
|
284
337
|
*/
|
|
285
338
|
withFailureMessage(message) {
|
|
286
339
|
const newAgent = this._clone();
|
|
@@ -290,6 +343,8 @@ class Agent {
|
|
|
290
343
|
/**
|
|
291
344
|
* Returns a new Agent with the specified maximum conversation history length.
|
|
292
345
|
* Applies to the standard LLM pipeline only; the v2.7 MLLM core schema has no max_history field.
|
|
346
|
+
*
|
|
347
|
+
* @deprecated Configure max history on the LLM vendor instead.
|
|
293
348
|
*/
|
|
294
349
|
withMaxHistory(maxHistory) {
|
|
295
350
|
const newAgent = this._clone();
|
|
@@ -340,6 +395,12 @@ class Agent {
|
|
|
340
395
|
get name() {
|
|
341
396
|
return this._name;
|
|
342
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* Get the AI Studio pipeline ID used as this agent's base configuration.
|
|
400
|
+
*/
|
|
401
|
+
get pipelineId() {
|
|
402
|
+
return this._pipelineId;
|
|
403
|
+
}
|
|
343
404
|
/**
|
|
344
405
|
* Get the LLM configuration.
|
|
345
406
|
*/
|
|
@@ -462,6 +523,7 @@ class Agent {
|
|
|
462
523
|
get config() {
|
|
463
524
|
return {
|
|
464
525
|
name: this._name,
|
|
526
|
+
pipelineId: this._pipelineId,
|
|
465
527
|
instructions: this._instructions,
|
|
466
528
|
turnDetection: this._turnDetection,
|
|
467
529
|
interruption: this._interruption,
|
|
@@ -519,7 +581,7 @@ class Agent {
|
|
|
519
581
|
* and RTM privileges (required for RTM-enabled sessions).
|
|
520
582
|
*/
|
|
521
583
|
toProperties(opts) {
|
|
522
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
584
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
523
585
|
// In MLLM mode the backend handles audio end-to-end; LLM, TTS, and ASR
|
|
524
586
|
// are not required.
|
|
525
587
|
const isMllmMode = ((_a = this._mllm) === null || _a === void 0 ? void 0 : _a.enable) === true || this._mllm !== undefined;
|
|
@@ -562,7 +624,6 @@ class Agent {
|
|
|
562
624
|
idle_timeout: opts.idleTimeout,
|
|
563
625
|
enable_string_uid: opts.enableStringUid,
|
|
564
626
|
mllm: this._mllm,
|
|
565
|
-
turn_detection: this._turnDetection,
|
|
566
627
|
interruption: this._interruption,
|
|
567
628
|
sal: this._sal,
|
|
568
629
|
avatar: this._avatar,
|
|
@@ -586,21 +647,37 @@ class Agent {
|
|
|
586
647
|
c.failure_message = this._failureMessage;
|
|
587
648
|
}
|
|
588
649
|
}
|
|
589
|
-
return Object.assign(Object.assign({}, base), { mllm: mllmConfig });
|
|
650
|
+
return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
|
|
590
651
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
652
|
+
const skipCategories = new Set((_d = opts.skipVendorValidationCategories) !== null && _d !== void 0 ? _d : []);
|
|
653
|
+
const allowMissingCategories = new Set((_e = opts.allowMissingVendorCategories) !== null && _e !== void 0 ? _e : []);
|
|
654
|
+
if (opts.skipVendorValidation) {
|
|
655
|
+
for (const category of ["asr", "llm", "tts"]) {
|
|
656
|
+
skipCategories.add(category);
|
|
657
|
+
allowMissingCategories.add(category);
|
|
597
658
|
}
|
|
598
659
|
}
|
|
660
|
+
const skipLlmValidation = skipCategories.has("llm");
|
|
661
|
+
const skipTtsValidation = skipCategories.has("tts");
|
|
662
|
+
const allowMissingAsr = allowMissingCategories.has("asr");
|
|
663
|
+
const allowMissingLlm = allowMissingCategories.has("llm");
|
|
664
|
+
const allowMissingTts = allowMissingCategories.has("tts");
|
|
665
|
+
if (!this._tts && !(skipTtsValidation || allowMissingTts)) {
|
|
666
|
+
throw new Error("TTS configuration is required. Use withTts() to set it.");
|
|
667
|
+
}
|
|
668
|
+
if (!this._llm && !(skipLlmValidation || allowMissingLlm)) {
|
|
669
|
+
throw new Error("LLM configuration is required. Use withLlm() to set it.");
|
|
670
|
+
}
|
|
599
671
|
const llmConfig = this._llm
|
|
600
672
|
? Object.assign(Object.assign({}, this._llm), { system_messages: this._instructions
|
|
601
673
|
? [{ role: "system", content: this._instructions }]
|
|
602
|
-
: this._llm.system_messages, greeting_message: (
|
|
603
|
-
|
|
674
|
+
: this._llm.system_messages, greeting_message: (_f = this._greeting) !== null && _f !== void 0 ? _f : this._llm.greeting_message, greeting_configs: (_g = this._greetingConfigs) !== null && _g !== void 0 ? _g : this._llm.greeting_configs, failure_message: (_h = this._failureMessage) !== null && _h !== void 0 ? _h : this._llm.failure_message, max_history: (_j = this._maxHistory) !== null && _j !== void 0 ? _j : this._llm.max_history }) : undefined;
|
|
675
|
+
const asrConfig = this._stt !== undefined || !allowMissingAsr
|
|
676
|
+
? this._resolveAsrConfig()
|
|
677
|
+
: undefined;
|
|
678
|
+
const turnDetectionConfig = this._resolveTurnDetectionConfig();
|
|
679
|
+
const ttsConfig = this._tts;
|
|
680
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { turn_detection: turnDetectionConfig }), (llmConfig && { llm: llmConfig })), (ttsConfig && { tts: ttsConfig })), (asrConfig && { asr: asrConfig }));
|
|
604
681
|
}
|
|
605
682
|
/**
|
|
606
683
|
* Creates a shallow copy of this Agent, preserving the TTSSampleRate type
|
|
@@ -614,6 +691,7 @@ class Agent {
|
|
|
614
691
|
_clone() {
|
|
615
692
|
const newAgent = new Agent();
|
|
616
693
|
newAgent._name = this._name;
|
|
694
|
+
newAgent._pipelineId = this._pipelineId;
|
|
617
695
|
newAgent._llm = this._llm;
|
|
618
696
|
newAgent._tts = this._tts;
|
|
619
697
|
newAgent._stt = this._stt;
|
|
@@ -635,6 +713,27 @@ class Agent {
|
|
|
635
713
|
newAgent._greetingConfigs = this._greetingConfigs;
|
|
636
714
|
return newAgent;
|
|
637
715
|
}
|
|
716
|
+
_resolveAsrConfig() {
|
|
717
|
+
var _a;
|
|
718
|
+
const asrConfig = Object.assign({}, ((_a = this._stt) !== null && _a !== void 0 ? _a : {}));
|
|
719
|
+
if (this._stt === undefined) {
|
|
720
|
+
asrConfig.vendor = "ares";
|
|
721
|
+
}
|
|
722
|
+
delete asrConfig.language;
|
|
723
|
+
return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
|
|
724
|
+
}
|
|
725
|
+
_resolveTurnDetectionConfig() {
|
|
726
|
+
var _a, _b;
|
|
727
|
+
const turnDetection = Object.assign({}, ((_a = this._turnDetection) !== null && _a !== void 0 ? _a : {}));
|
|
728
|
+
const existingTurnDetectionLanguage = turnDetection.language;
|
|
729
|
+
const existingAsrLanguage = (_b = this._stt) === null || _b === void 0 ? void 0 : _b.language;
|
|
730
|
+
const language = existingTurnDetectionLanguage !== null && existingTurnDetectionLanguage !== void 0 ? existingTurnDetectionLanguage : (existingAsrLanguage !== undefined && isTurnDetectionLanguage(existingAsrLanguage)
|
|
731
|
+
? existingAsrLanguage
|
|
732
|
+
: DEFAULT_TURN_DETECTION_LANGUAGE);
|
|
733
|
+
assertTurnDetectionLanguage(language);
|
|
734
|
+
turnDetection.language = language;
|
|
735
|
+
return turnDetection;
|
|
736
|
+
}
|
|
638
737
|
}
|
|
639
738
|
exports.Agent = Agent;
|
|
640
739
|
function _parseNumericUid(uid, label) {
|
|
@@ -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
|
*
|