agora-agents 2.2.0 → 2.4.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 +48 -26
- package/dist/cjs/AgoraPoolClient.d.ts +9 -6
- package/dist/cjs/AgoraPoolClient.js +1 -0
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.js +8 -16
- package/dist/cjs/agentkit/Agent.d.ts +52 -51
- package/dist/cjs/agentkit/Agent.js +46 -44
- package/dist/cjs/agentkit/AgentSession.d.ts +11 -10
- package/dist/cjs/agentkit/AgentSession.js +12 -6
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.d.ts +1 -0
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +57 -0
- package/dist/cjs/agentkit/__tests__/readme-examples.test.d.ts +1 -0
- package/dist/cjs/agentkit/__tests__/readme-examples.test.js +126 -0
- package/dist/cjs/agentkit/__tests__/type-safety.test.js +24 -17
- package/dist/cjs/agentkit/area.d.ts +4 -0
- package/dist/cjs/agentkit/area.js +2 -0
- package/dist/cjs/agentkit/avatar-types.d.ts +43 -4
- package/dist/cjs/agentkit/avatar-types.js +52 -2
- package/dist/cjs/agentkit/index.d.ts +12 -9
- package/dist/cjs/agentkit/index.js +32 -2
- package/dist/cjs/agentkit/region-vendors.d.ts +15 -0
- package/dist/cjs/agentkit/region-vendors.js +2 -0
- package/dist/cjs/agentkit/token.d.ts +3 -2
- package/dist/cjs/agentkit/token.js +3 -2
- package/dist/cjs/agentkit/types.d.ts +47 -9
- package/dist/cjs/agentkit/vendors/avatar.d.ts +9 -6
- package/dist/cjs/agentkit/vendors/avatar.js +9 -6
- package/dist/cjs/agentkit/vendors/base.d.ts +42 -5
- package/dist/cjs/agentkit/vendors/base.js +64 -6
- package/dist/cjs/agentkit/vendors/cn.d.ts +269 -0
- package/dist/cjs/agentkit/vendors/cn.js +313 -0
- package/dist/cjs/agentkit/vendors/llm.d.ts +1 -1
- package/dist/cjs/agentkit/vendors/llm.js +13 -3
- package/dist/cjs/agentkit/vendors/mllm.d.ts +8 -4
- package/dist/cjs/agentkit/vendors/mllm.js +10 -6
- package/dist/cjs/agentkit/vendors/stt.d.ts +31 -0
- package/dist/cjs/agentkit/vendors/stt.js +31 -1
- package/dist/cjs/agentkit/vendors/tts.d.ts +63 -3
- package/dist/cjs/agentkit/vendors/tts.js +42 -1
- package/dist/cjs/api/resources/agents/client/requests/ListAgentsRequest.d.ts +2 -3
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +23 -3
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +12 -0
- package/dist/cjs/api/resources/agents/types/GetHistoryAgentsResponse.d.ts +6 -0
- package/dist/cjs/api/resources/agents/types/index.d.ts +0 -1
- package/dist/cjs/api/resources/agents/types/index.js +0 -1
- package/dist/cjs/api/types/Asr.d.ts +19 -1
- package/dist/cjs/api/types/BytedanceDuplexTts.d.ts +9 -0
- package/dist/cjs/api/types/BytedanceDuplexTts.js +3 -0
- package/dist/cjs/api/types/BytedanceDuplexTtsParams.d.ts +13 -0
- package/dist/cjs/api/types/BytedanceDuplexTtsParams.js +3 -0
- package/dist/cjs/api/types/BytedanceTts.d.ts +9 -0
- package/dist/cjs/api/types/BytedanceTts.js +3 -0
- package/dist/cjs/api/types/BytedanceTtsParams.d.ts +23 -0
- package/dist/cjs/api/types/BytedanceTtsParams.js +3 -0
- package/dist/cjs/api/types/CosyvoiceTts.d.ts +9 -0
- package/dist/cjs/api/types/CosyvoiceTts.js +3 -0
- package/dist/cjs/api/types/CosyvoiceTtsParams.d.ts +15 -0
- package/dist/cjs/api/types/CosyvoiceTtsParams.js +3 -0
- package/dist/cjs/api/types/FengmingAsr.d.ts +11 -0
- package/dist/cjs/api/types/FengmingAsr.js +3 -0
- package/dist/cjs/api/types/GenericTts.d.ts +13 -0
- package/dist/cjs/api/types/GenericTts.js +3 -0
- package/dist/cjs/api/types/GenericTtsParams.d.ts +21 -0
- package/dist/cjs/api/types/GenericTtsParams.js +3 -0
- package/dist/cjs/api/types/Llm.d.ts +24 -1
- package/dist/cjs/api/types/Llm.js +8 -0
- package/dist/cjs/api/types/MinimaxTtsParams.d.ts +52 -3
- package/dist/cjs/api/types/OpenAiTtsParams.d.ts +1 -1
- package/dist/cjs/api/types/SensetimeAvatarParams.d.ts +48 -0
- package/dist/cjs/api/types/SensetimeAvatarParams.js +3 -0
- package/dist/cjs/api/types/SpatiusAvatarParams.d.ts +23 -0
- package/dist/cjs/api/types/SpatiusAvatarParams.js +3 -0
- package/dist/cjs/api/types/StepfunTts.d.ts +9 -0
- package/dist/cjs/api/types/StepfunTts.js +3 -0
- package/dist/cjs/api/types/StepfunTtsParams.d.ts +13 -0
- package/dist/cjs/api/types/StepfunTtsParams.js +3 -0
- package/dist/cjs/api/types/TencentAsr.d.ts +10 -0
- package/dist/cjs/api/types/TencentAsr.js +3 -0
- package/dist/cjs/api/types/TencentAsrParams.d.ts +17 -0
- package/dist/cjs/api/types/TencentAsrParams.js +3 -0
- package/dist/cjs/api/types/TencentTts.d.ts +9 -0
- package/dist/cjs/api/types/TencentTts.js +3 -0
- package/dist/cjs/api/types/TencentTtsParams.d.ts +23 -0
- package/dist/cjs/api/types/TencentTtsParams.js +3 -0
- package/dist/cjs/api/types/Tts.d.ts +22 -1
- package/dist/cjs/api/types/XAiAsr.d.ts +10 -0
- package/dist/cjs/api/types/XAiAsr.js +3 -0
- package/dist/cjs/api/types/XAiAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/XAiAsrParams.js +3 -0
- package/dist/cjs/api/types/XAiTts.d.ts +9 -0
- package/dist/cjs/api/types/XAiTts.js +3 -0
- package/dist/cjs/api/types/XAiTtsParams.d.ts +15 -0
- package/dist/cjs/api/types/XAiTtsParams.js +3 -0
- package/dist/cjs/api/types/XfyunAsr.d.ts +10 -0
- package/dist/cjs/api/types/XfyunAsr.js +3 -0
- package/dist/cjs/api/types/XfyunAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/XfyunAsrParams.js +3 -0
- package/dist/cjs/api/types/XfyunBigmodelAsr.d.ts +10 -0
- package/dist/cjs/api/types/XfyunBigmodelAsr.js +3 -0
- package/dist/cjs/api/types/XfyunBigmodelAsrParams.d.ts +17 -0
- package/dist/cjs/api/types/XfyunBigmodelAsrParams.js +3 -0
- package/dist/cjs/api/types/XfyunDialectAsr.d.ts +10 -0
- package/dist/cjs/api/types/XfyunDialectAsr.js +3 -0
- package/dist/cjs/api/types/XfyunDialectAsrParams.d.ts +15 -0
- package/dist/cjs/api/types/XfyunDialectAsrParams.js +3 -0
- package/dist/cjs/api/types/index.d.ts +27 -0
- package/dist/cjs/api/types/index.js +27 -0
- package/dist/cjs/core/base64.js +1 -5
- package/dist/cjs/core/domain/index.d.ts +2 -1
- package/dist/cjs/core/domain/index.js +5 -3
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +31 -2
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/AgoraPoolClient.d.mts +9 -6
- package/dist/esm/AgoraPoolClient.mjs +1 -0
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.mjs +8 -16
- package/dist/esm/agentkit/Agent.d.mts +52 -51
- package/dist/esm/agentkit/Agent.mjs +46 -44
- package/dist/esm/agentkit/AgentSession.d.mts +11 -10
- package/dist/esm/agentkit/AgentSession.mjs +13 -7
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.d.mts +1 -0
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +55 -0
- package/dist/esm/agentkit/__tests__/readme-examples.test.d.mts +1 -0
- package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +124 -0
- package/dist/esm/agentkit/__tests__/type-safety.test.mjs +24 -17
- package/dist/esm/agentkit/area.d.mts +4 -0
- package/dist/esm/agentkit/area.mjs +1 -0
- package/dist/esm/agentkit/avatar-types.d.mts +43 -4
- package/dist/esm/agentkit/avatar-types.mjs +50 -2
- package/dist/esm/agentkit/index.d.mts +12 -9
- package/dist/esm/agentkit/index.mjs +5 -4
- package/dist/esm/agentkit/region-vendors.d.mts +15 -0
- package/dist/esm/agentkit/region-vendors.mjs +1 -0
- package/dist/esm/agentkit/token.d.mts +3 -2
- package/dist/esm/agentkit/token.mjs +3 -2
- package/dist/esm/agentkit/types.d.mts +47 -9
- package/dist/esm/agentkit/vendors/avatar.d.mts +9 -6
- package/dist/esm/agentkit/vendors/avatar.mjs +9 -6
- package/dist/esm/agentkit/vendors/base.d.mts +42 -5
- package/dist/esm/agentkit/vendors/base.mjs +59 -5
- package/dist/esm/agentkit/vendors/cn.d.mts +269 -0
- package/dist/esm/agentkit/vendors/cn.mjs +291 -0
- package/dist/esm/agentkit/vendors/llm.d.mts +1 -1
- package/dist/esm/agentkit/vendors/llm.mjs +13 -3
- package/dist/esm/agentkit/vendors/mllm.d.mts +8 -4
- package/dist/esm/agentkit/vendors/mllm.mjs +10 -6
- package/dist/esm/agentkit/vendors/stt.d.mts +31 -0
- package/dist/esm/agentkit/vendors/stt.mjs +29 -0
- package/dist/esm/agentkit/vendors/tts.d.mts +63 -3
- package/dist/esm/agentkit/vendors/tts.mjs +39 -0
- package/dist/esm/api/resources/agents/client/requests/ListAgentsRequest.d.mts +2 -3
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +23 -3
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +12 -0
- package/dist/esm/api/resources/agents/types/GetHistoryAgentsResponse.d.mts +6 -0
- package/dist/esm/api/resources/agents/types/index.d.mts +0 -1
- package/dist/esm/api/resources/agents/types/index.mjs +0 -1
- package/dist/esm/api/types/Asr.d.mts +19 -1
- package/dist/esm/api/types/BytedanceDuplexTts.d.mts +9 -0
- package/dist/esm/api/types/BytedanceDuplexTts.mjs +2 -0
- package/dist/esm/api/types/BytedanceDuplexTtsParams.d.mts +13 -0
- package/dist/esm/api/types/BytedanceDuplexTtsParams.mjs +2 -0
- package/dist/esm/api/types/BytedanceTts.d.mts +9 -0
- package/dist/esm/api/types/BytedanceTts.mjs +2 -0
- package/dist/esm/api/types/BytedanceTtsParams.d.mts +23 -0
- package/dist/esm/api/types/BytedanceTtsParams.mjs +2 -0
- package/dist/esm/api/types/CosyvoiceTts.d.mts +9 -0
- package/dist/esm/api/types/CosyvoiceTts.mjs +2 -0
- package/dist/esm/api/types/CosyvoiceTtsParams.d.mts +15 -0
- package/dist/esm/api/types/CosyvoiceTtsParams.mjs +2 -0
- package/dist/esm/api/types/FengmingAsr.d.mts +11 -0
- package/dist/esm/api/types/FengmingAsr.mjs +2 -0
- package/dist/esm/api/types/GenericTts.d.mts +13 -0
- package/dist/esm/api/types/GenericTts.mjs +2 -0
- package/dist/esm/api/types/GenericTtsParams.d.mts +21 -0
- package/dist/esm/api/types/GenericTtsParams.mjs +2 -0
- package/dist/esm/api/types/Llm.d.mts +24 -1
- package/dist/esm/api/types/Llm.mjs +8 -0
- package/dist/esm/api/types/MinimaxTtsParams.d.mts +52 -3
- package/dist/esm/api/types/OpenAiTtsParams.d.mts +1 -1
- package/dist/esm/api/types/SensetimeAvatarParams.d.mts +48 -0
- package/dist/esm/api/types/SensetimeAvatarParams.mjs +2 -0
- package/dist/esm/api/types/SpatiusAvatarParams.d.mts +23 -0
- package/dist/esm/api/types/SpatiusAvatarParams.mjs +2 -0
- package/dist/esm/api/types/StepfunTts.d.mts +9 -0
- package/dist/esm/api/types/StepfunTts.mjs +2 -0
- package/dist/esm/api/types/StepfunTtsParams.d.mts +13 -0
- package/dist/esm/api/types/StepfunTtsParams.mjs +2 -0
- package/dist/esm/api/types/TencentAsr.d.mts +10 -0
- package/dist/esm/api/types/TencentAsr.mjs +2 -0
- package/dist/esm/api/types/TencentAsrParams.d.mts +17 -0
- package/dist/esm/api/types/TencentAsrParams.mjs +2 -0
- package/dist/esm/api/types/TencentTts.d.mts +9 -0
- package/dist/esm/api/types/TencentTts.mjs +2 -0
- package/dist/esm/api/types/TencentTtsParams.d.mts +23 -0
- package/dist/esm/api/types/TencentTtsParams.mjs +2 -0
- package/dist/esm/api/types/Tts.d.mts +22 -1
- package/dist/esm/api/types/XAiAsr.d.mts +10 -0
- package/dist/esm/api/types/XAiAsr.mjs +2 -0
- package/dist/esm/api/types/XAiAsrParams.d.mts +15 -0
- package/dist/esm/api/types/XAiAsrParams.mjs +2 -0
- package/dist/esm/api/types/XAiTts.d.mts +9 -0
- package/dist/esm/api/types/XAiTts.mjs +2 -0
- package/dist/esm/api/types/XAiTtsParams.d.mts +15 -0
- package/dist/esm/api/types/XAiTtsParams.mjs +2 -0
- package/dist/esm/api/types/XfyunAsr.d.mts +10 -0
- package/dist/esm/api/types/XfyunAsr.mjs +2 -0
- package/dist/esm/api/types/XfyunAsrParams.d.mts +15 -0
- package/dist/esm/api/types/XfyunAsrParams.mjs +2 -0
- package/dist/esm/api/types/XfyunBigmodelAsr.d.mts +10 -0
- package/dist/esm/api/types/XfyunBigmodelAsr.mjs +2 -0
- package/dist/esm/api/types/XfyunBigmodelAsrParams.d.mts +17 -0
- package/dist/esm/api/types/XfyunBigmodelAsrParams.mjs +2 -0
- package/dist/esm/api/types/XfyunDialectAsr.d.mts +10 -0
- package/dist/esm/api/types/XfyunDialectAsr.mjs +2 -0
- package/dist/esm/api/types/XfyunDialectAsrParams.d.mts +15 -0
- package/dist/esm/api/types/XfyunDialectAsrParams.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +27 -0
- package/dist/esm/api/types/index.mjs +27 -0
- package/dist/esm/core/base64.mjs +1 -5
- package/dist/esm/core/domain/index.d.mts +2 -1
- package/dist/esm/core/domain/index.mjs +4 -2
- package/dist/esm/index.d.mts +3 -2
- package/dist/esm/index.mjs +6 -6
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/api/resources/agents/types/ListAgentsRequestState.d.ts +0 -10
- package/dist/cjs/api/resources/agents/types/ListAgentsRequestState.js +0 -13
- package/dist/esm/api/resources/agents/types/ListAgentsRequestState.d.mts +0 -10
- package/dist/esm/api/resources/agents/types/ListAgentsRequestState.mjs +0 -10
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AgoraClient } from "../../AgoraPoolClient.mjs";
|
|
2
|
+
import { Area } from "../../core/domain/index.mjs";
|
|
3
|
+
import { Agent } from "../Agent.mjs";
|
|
4
|
+
import { AliyunLLM, FengmingSTT, MiniMaxCNTTS } from "../vendors/cn.mjs";
|
|
5
|
+
import { OpenAI } from "../vendors/llm.mjs";
|
|
6
|
+
import { DeepgramSTT } from "../vendors/stt.mjs";
|
|
7
|
+
import { MiniMaxTTS } from "../vendors/tts.mjs";
|
|
8
|
+
const client = new AgoraClient({
|
|
9
|
+
area: Area.US,
|
|
10
|
+
appId: "app-id",
|
|
11
|
+
appCertificate: "app-certificate",
|
|
12
|
+
});
|
|
13
|
+
new Agent({ client, turnDetection: { language: "en-US" } })
|
|
14
|
+
.withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }))
|
|
15
|
+
.withLlm(new OpenAI({ model: "gpt-5-mini" }))
|
|
16
|
+
.withTts(new MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }))
|
|
17
|
+
.createSession({
|
|
18
|
+
name: "assistant",
|
|
19
|
+
channel: "test-room",
|
|
20
|
+
agentUid: "1",
|
|
21
|
+
remoteUids: ["100"],
|
|
22
|
+
});
|
|
23
|
+
// Area and provider may differ.
|
|
24
|
+
new Agent({ client }).withStt(new FengmingSTT());
|
|
25
|
+
new Agent({ client }).withLlm(new AliyunLLM({ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", model: "qwen-plus" }));
|
|
26
|
+
new Agent({ client }).withTts(new MiniMaxCNTTS({ key: "minimax-key", model: "speech-01-turbo", voiceSetting: { voice_id: "female-shaonv" } }));
|
|
27
|
+
{
|
|
28
|
+
const client = new AgoraClient({
|
|
29
|
+
area: Area.CN,
|
|
30
|
+
appId: "app-id",
|
|
31
|
+
appCertificate: "app-certificate",
|
|
32
|
+
});
|
|
33
|
+
new Agent({ client, turnDetection: { language: "zh-CN" } })
|
|
34
|
+
.withStt(new FengmingSTT())
|
|
35
|
+
.withLlm(new AliyunLLM({
|
|
36
|
+
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
37
|
+
model: "qwen-plus",
|
|
38
|
+
}))
|
|
39
|
+
.withTts(new MiniMaxCNTTS({
|
|
40
|
+
key: "minimax-key",
|
|
41
|
+
model: "speech-01-turbo",
|
|
42
|
+
voiceSetting: { voice_id: "female-shaonv" },
|
|
43
|
+
audioSetting: { sample_rate: 16000 },
|
|
44
|
+
}))
|
|
45
|
+
.createSession({
|
|
46
|
+
name: "assistant",
|
|
47
|
+
channel: "cn-room",
|
|
48
|
+
agentUid: "1",
|
|
49
|
+
remoteUids: ["100"],
|
|
50
|
+
});
|
|
51
|
+
new Agent({ client }).withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
52
|
+
new Agent({ client }).withLlm(new OpenAI({ model: "gpt-5-mini" }));
|
|
53
|
+
new Agent({ client }).withTts(new MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }));
|
|
54
|
+
}
|
|
55
|
+
new Agent({ client }).withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { AgoraClient } from "../../AgoraPoolClient.mjs";
|
|
2
|
+
import { Area } from "../../core/domain/index.mjs";
|
|
3
|
+
import { Agent } from "../Agent.mjs";
|
|
4
|
+
import { AliyunLLM, FengmingSTT, MiniMaxCNTTS } from "../vendors/cn.mjs";
|
|
5
|
+
import { OpenAI } from "../vendors/llm.mjs";
|
|
6
|
+
import { DeepgramSTT } from "../vendors/stt.mjs";
|
|
7
|
+
import { MiniMaxTTS } from "../vendors/tts.mjs";
|
|
8
|
+
const AGENT_PROMPT = "You are a concise, technically credible voice assistant. Keep replies short unless the user asks for detail.";
|
|
9
|
+
const GREETING = "Hi there! I am your Agora voice assistant. How can I help?";
|
|
10
|
+
const SUPPORT_PROMPT = "You are a concise support assistant.";
|
|
11
|
+
const client = new AgoraClient({
|
|
12
|
+
area: Area.US,
|
|
13
|
+
appId: "app-id",
|
|
14
|
+
appCertificate: "app-certificate",
|
|
15
|
+
});
|
|
16
|
+
new Agent({
|
|
17
|
+
client,
|
|
18
|
+
turnDetection: {
|
|
19
|
+
language: "en-US",
|
|
20
|
+
config: {
|
|
21
|
+
speech_threshold: 0.5,
|
|
22
|
+
start_of_speech: {
|
|
23
|
+
mode: "vad",
|
|
24
|
+
vad_config: {
|
|
25
|
+
interrupt_duration_ms: 160,
|
|
26
|
+
prefix_padding_ms: 300,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
end_of_speech: {
|
|
30
|
+
mode: "vad",
|
|
31
|
+
vad_config: {
|
|
32
|
+
silence_duration_ms: 480,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
advancedFeatures: {
|
|
38
|
+
enable_rtm: true,
|
|
39
|
+
enable_tools: true,
|
|
40
|
+
},
|
|
41
|
+
parameters: {
|
|
42
|
+
data_channel: "rtm",
|
|
43
|
+
enable_error_message: true,
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
.withStt(new DeepgramSTT({ model: "nova-3", language: "en" }))
|
|
47
|
+
.withLlm(new OpenAI({
|
|
48
|
+
model: "gpt-4o-mini",
|
|
49
|
+
systemMessages: [{ role: "system", content: AGENT_PROMPT }],
|
|
50
|
+
greetingMessage: GREETING,
|
|
51
|
+
failureMessage: "Please wait a moment.",
|
|
52
|
+
maxHistory: 50,
|
|
53
|
+
params: {
|
|
54
|
+
max_tokens: 1024,
|
|
55
|
+
temperature: 0.7,
|
|
56
|
+
top_p: 0.95,
|
|
57
|
+
},
|
|
58
|
+
}))
|
|
59
|
+
.withTts(new MiniMaxTTS({
|
|
60
|
+
model: "speech_2_6_turbo",
|
|
61
|
+
voiceId: "English_captivating_female1",
|
|
62
|
+
}))
|
|
63
|
+
.createSession({
|
|
64
|
+
name: `conversation-${Date.now()}`,
|
|
65
|
+
channel: `demo-channel-${Date.now()}`,
|
|
66
|
+
agentUid: "123456",
|
|
67
|
+
remoteUids: ["*"],
|
|
68
|
+
idleTimeout: 30,
|
|
69
|
+
});
|
|
70
|
+
{
|
|
71
|
+
const client = new AgoraClient({
|
|
72
|
+
area: Area.CN,
|
|
73
|
+
appId: "app-id",
|
|
74
|
+
appCertificate: "app-certificate",
|
|
75
|
+
});
|
|
76
|
+
new Agent({
|
|
77
|
+
client,
|
|
78
|
+
turnDetection: { language: "zh-CN" },
|
|
79
|
+
})
|
|
80
|
+
.withStt(new FengmingSTT())
|
|
81
|
+
.withLlm(new AliyunLLM({
|
|
82
|
+
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
83
|
+
model: "qwen-plus",
|
|
84
|
+
}))
|
|
85
|
+
.withTts(new MiniMaxCNTTS({
|
|
86
|
+
key: "minimax-key",
|
|
87
|
+
model: "speech-01-turbo",
|
|
88
|
+
voiceSetting: { voice_id: "female-shaonv" },
|
|
89
|
+
audioSetting: { sample_rate: 16000 },
|
|
90
|
+
}))
|
|
91
|
+
.createSession({
|
|
92
|
+
name: `conversation-${Date.now()}`,
|
|
93
|
+
channel: `demo-channel-${Date.now()}`,
|
|
94
|
+
agentUid: "1001",
|
|
95
|
+
remoteUids: ["100"],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
{
|
|
99
|
+
const client = new AgoraClient({
|
|
100
|
+
area: Area.US,
|
|
101
|
+
appId: "app-id",
|
|
102
|
+
appCertificate: "app-certificate",
|
|
103
|
+
});
|
|
104
|
+
new Agent({ client, turnDetection: { language: "en-US" } })
|
|
105
|
+
.withStt(new DeepgramSTT({
|
|
106
|
+
apiKey: "deepgram-key",
|
|
107
|
+
model: "nova-3",
|
|
108
|
+
language: "en",
|
|
109
|
+
}))
|
|
110
|
+
.withLlm(new OpenAI({
|
|
111
|
+
apiKey: "openai-key",
|
|
112
|
+
url: "https://api.openai.com/v1/chat/completions",
|
|
113
|
+
model: "gpt-4o-mini",
|
|
114
|
+
systemMessages: [{ role: "system", content: SUPPORT_PROMPT }],
|
|
115
|
+
greetingMessage: GREETING,
|
|
116
|
+
maxTokens: 1024,
|
|
117
|
+
temperature: 0.7,
|
|
118
|
+
topP: 0.95,
|
|
119
|
+
}))
|
|
120
|
+
.withTts(new MiniMaxTTS({
|
|
121
|
+
model: "speech_2_6_turbo",
|
|
122
|
+
voiceId: "English_captivating_female1",
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
@@ -11,17 +11,24 @@
|
|
|
11
11
|
* 2. Run: npm run build
|
|
12
12
|
* 3. TypeScript should show errors for the uncommented invalid sections
|
|
13
13
|
*/
|
|
14
|
+
import { AgoraClient } from "../../AgoraPoolClient.mjs";
|
|
15
|
+
import { Area } from "../../core/domain/index.mjs";
|
|
14
16
|
import { Agent } from "../Agent.mjs";
|
|
15
17
|
import { AkoolAvatar, LiveAvatarAvatar } from "../vendors/avatar.mjs";
|
|
16
18
|
import { OpenAI } from "../vendors/llm.mjs";
|
|
17
19
|
import { DeepgramSTT } from "../vendors/stt.mjs";
|
|
18
20
|
import { CartesiaTTS, ElevenLabsTTS, MicrosoftTTS, MiniMaxTTS, OpenAITTS } from "../vendors/tts.mjs";
|
|
21
|
+
const TEST_AGENT_CLIENT = new AgoraClient({
|
|
22
|
+
area: Area.US,
|
|
23
|
+
appId: "test-app-id",
|
|
24
|
+
appCertificate: "test-app-certificate",
|
|
25
|
+
});
|
|
19
26
|
// ============================================
|
|
20
27
|
// ✅ VALID CONFIGURATIONS
|
|
21
28
|
// ============================================
|
|
22
29
|
// Example 1: ElevenLabs 24kHz + HeyGen avatar
|
|
23
30
|
function _validExample1() {
|
|
24
|
-
return new Agent({ instructions: "Test" })
|
|
31
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
25
32
|
.withTts(new ElevenLabsTTS({
|
|
26
33
|
key: "test",
|
|
27
34
|
modelId: "eleven_flash_v2_5",
|
|
@@ -37,7 +44,7 @@ function _validExample1() {
|
|
|
37
44
|
}
|
|
38
45
|
// Example 2: ElevenLabs 16kHz + Akool avatar
|
|
39
46
|
function _validExample2() {
|
|
40
|
-
return new Agent({ instructions: "Test" })
|
|
47
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
41
48
|
.withTts(new ElevenLabsTTS({
|
|
42
49
|
key: "test",
|
|
43
50
|
modelId: "eleven_flash_v2_5",
|
|
@@ -51,7 +58,7 @@ function _validExample2() {
|
|
|
51
58
|
}
|
|
52
59
|
// Example 3: Microsoft 24kHz + HeyGen avatar
|
|
53
60
|
function _validExample3() {
|
|
54
|
-
return new Agent({ instructions: "Test" })
|
|
61
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
55
62
|
.withTts(new MicrosoftTTS({
|
|
56
63
|
key: "test",
|
|
57
64
|
region: "eastus",
|
|
@@ -66,7 +73,7 @@ function _validExample3() {
|
|
|
66
73
|
}
|
|
67
74
|
// Example 4: OpenAI (fixed 24kHz) + HeyGen avatar
|
|
68
75
|
function _validExample4() {
|
|
69
|
-
return new Agent({ instructions: "Test" })
|
|
76
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
70
77
|
.withTts(new OpenAITTS({
|
|
71
78
|
apiKey: "test",
|
|
72
79
|
voice: "alloy",
|
|
@@ -81,7 +88,7 @@ function _validExample4() {
|
|
|
81
88
|
}
|
|
82
89
|
// Example 5: Cartesia 16kHz + Akool avatar
|
|
83
90
|
function _validExample5() {
|
|
84
|
-
return new Agent({ instructions: "Test" })
|
|
91
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
85
92
|
.withTts(new CartesiaTTS({
|
|
86
93
|
apiKey: "test",
|
|
87
94
|
voiceId: "test",
|
|
@@ -129,7 +136,7 @@ new MiniMaxTTS({
|
|
|
129
136
|
/*
|
|
130
137
|
// @ts-expect-error - HeyGen requires 24kHz, but TTS is configured for 16kHz
|
|
131
138
|
function invalidMismatch1(): Agent<24000> {
|
|
132
|
-
return new Agent({ instructions: "Test" })
|
|
139
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
133
140
|
.withTts(
|
|
134
141
|
new ElevenLabsTTS({
|
|
135
142
|
key: "test",
|
|
@@ -151,7 +158,7 @@ function invalidMismatch1(): Agent<24000> {
|
|
|
151
158
|
/*
|
|
152
159
|
// @ts-expect-error - Akool requires 16kHz, but TTS is configured for 24kHz
|
|
153
160
|
function invalidMismatch2(): Agent<16000> {
|
|
154
|
-
return new Agent({ instructions: "Test" })
|
|
161
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
155
162
|
.withTts(
|
|
156
163
|
new ElevenLabsTTS({
|
|
157
164
|
key: "test",
|
|
@@ -171,7 +178,7 @@ function invalidMismatch2(): Agent<16000> {
|
|
|
171
178
|
/*
|
|
172
179
|
// @ts-expect-error - HeyGen requires 24kHz, not 48kHz
|
|
173
180
|
function invalidMismatch3(): Agent<24000> {
|
|
174
|
-
return new Agent({ instructions: "Test" })
|
|
181
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
175
182
|
.withTts(
|
|
176
183
|
new MicrosoftTTS({
|
|
177
184
|
key: "test",
|
|
@@ -196,7 +203,7 @@ function invalidMismatch3(): Agent<24000> {
|
|
|
196
203
|
/*
|
|
197
204
|
// @ts-expect-error - 25000 is not a valid ElevenLabs sample rate
|
|
198
205
|
function invalidEnum1() {
|
|
199
|
-
return new Agent({ instructions: "Test" }).withTts(
|
|
206
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
200
207
|
new ElevenLabsTTS({
|
|
201
208
|
key: "test",
|
|
202
209
|
modelId: "eleven_flash_v2_5",
|
|
@@ -210,7 +217,7 @@ function invalidEnum1() {
|
|
|
210
217
|
/*
|
|
211
218
|
// @ts-expect-error - 8000 is not a valid Microsoft sample rate
|
|
212
219
|
function invalidEnum2() {
|
|
213
|
-
return new Agent({ instructions: "Test" }).withTts(
|
|
220
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
214
221
|
new MicrosoftTTS({
|
|
215
222
|
key: "test",
|
|
216
223
|
region: "eastus",
|
|
@@ -223,7 +230,7 @@ function invalidEnum2() {
|
|
|
223
230
|
/*
|
|
224
231
|
// @ts-expect-error - 32000 is not a valid Cartesia sample rate
|
|
225
232
|
function invalidEnum3() {
|
|
226
|
-
return new Agent({ instructions: "Test" }).withTts(
|
|
233
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
227
234
|
new CartesiaTTS({
|
|
228
235
|
key: "test",
|
|
229
236
|
voiceId: "test",
|
|
@@ -238,7 +245,7 @@ function invalidEnum3() {
|
|
|
238
245
|
// ============================================
|
|
239
246
|
// Avatar without TTS configured (allowed)
|
|
240
247
|
function _edgeCase1() {
|
|
241
|
-
return new Agent({ instructions: "Test" }).withAvatar(new LiveAvatarAvatar({
|
|
248
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withAvatar(new LiveAvatarAvatar({
|
|
242
249
|
apiKey: "test",
|
|
243
250
|
quality: "high",
|
|
244
251
|
agoraUid: "12345",
|
|
@@ -246,7 +253,7 @@ function _edgeCase1() {
|
|
|
246
253
|
}
|
|
247
254
|
// TTS without avatar (allowed)
|
|
248
255
|
function _edgeCase2() {
|
|
249
|
-
return new Agent({ instructions: "Test" }).withTts(new ElevenLabsTTS({
|
|
256
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new ElevenLabsTTS({
|
|
250
257
|
key: "test",
|
|
251
258
|
modelId: "eleven_flash_v2_5",
|
|
252
259
|
voiceId: "test",
|
|
@@ -256,7 +263,7 @@ function _edgeCase2() {
|
|
|
256
263
|
}
|
|
257
264
|
// Method chaining preserves type tracking
|
|
258
265
|
function _edgeCase3() {
|
|
259
|
-
return new Agent({ instructions: "Test" })
|
|
266
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
260
267
|
.withTts(new ElevenLabsTTS({
|
|
261
268
|
key: "test",
|
|
262
269
|
modelId: "eleven_flash_v2_5",
|
|
@@ -276,7 +283,7 @@ function _edgeCase3() {
|
|
|
276
283
|
// Type inference verification
|
|
277
284
|
// ============================================
|
|
278
285
|
function _typeInference1() {
|
|
279
|
-
const agentWith24k = new Agent({ instructions: "Test" }).withTts(new ElevenLabsTTS({
|
|
286
|
+
const agentWith24k = new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new ElevenLabsTTS({
|
|
280
287
|
key: "test",
|
|
281
288
|
modelId: "eleven_flash_v2_5",
|
|
282
289
|
voiceId: "test",
|
|
@@ -288,7 +295,7 @@ function _typeInference1() {
|
|
|
288
295
|
return agentWith24k;
|
|
289
296
|
}
|
|
290
297
|
function _typeInference2() {
|
|
291
|
-
const agentWith16k = new Agent({ instructions: "Test" }).withTts(new ElevenLabsTTS({
|
|
298
|
+
const agentWith16k = new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new ElevenLabsTTS({
|
|
292
299
|
key: "test",
|
|
293
300
|
modelId: "eleven_flash_v2_5",
|
|
294
301
|
voiceId: "test",
|
|
@@ -300,7 +307,7 @@ function _typeInference2() {
|
|
|
300
307
|
return agentWith16k;
|
|
301
308
|
}
|
|
302
309
|
function _typeInference3() {
|
|
303
|
-
const openAIAgent = new Agent({ instructions: "Test" }).withTts(new OpenAITTS({
|
|
310
|
+
const openAIAgent = new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new OpenAITTS({
|
|
304
311
|
apiKey: "test",
|
|
305
312
|
voice: "alloy",
|
|
306
313
|
model: "gpt-4o-mini-tts",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* This provides type safety for vendor-specific parameters like sample rates,
|
|
5
5
|
* ensuring that invalid combinations are caught at compile time.
|
|
6
6
|
*/
|
|
7
|
+
import type { SensetimeAvatarParams } from "../api/types/SensetimeAvatarParams.mjs";
|
|
8
|
+
import type { SpatiusAvatarParams } from "../api/types/SpatiusAvatarParams.mjs";
|
|
7
9
|
import type { AvatarConfig as BaseAvatarConfig } from "./types.mjs";
|
|
8
10
|
/**
|
|
9
11
|
* HeyGen-specific avatar configuration (legacy wire vendor `heygen`).
|
|
@@ -73,8 +75,8 @@ export interface AnamAvatarConfig {
|
|
|
73
75
|
params: {
|
|
74
76
|
/** API key for Anam authentication (required) */
|
|
75
77
|
api_key: string;
|
|
76
|
-
/** Anam
|
|
77
|
-
|
|
78
|
+
/** Anam avatar ID (optional) */
|
|
79
|
+
avatar_id?: string;
|
|
78
80
|
[key: string]: unknown;
|
|
79
81
|
};
|
|
80
82
|
}
|
|
@@ -123,11 +125,39 @@ export interface GenericAvatarConfig {
|
|
|
123
125
|
[key: string]: unknown;
|
|
124
126
|
};
|
|
125
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* SenseTime-specific avatar configuration (CN).
|
|
130
|
+
*/
|
|
131
|
+
export interface SensetimeAvatarConfig {
|
|
132
|
+
enable?: boolean;
|
|
133
|
+
vendor: "sensetime";
|
|
134
|
+
params: {
|
|
135
|
+
/** RTC UID for the avatar video publisher (required) */
|
|
136
|
+
agora_uid: string;
|
|
137
|
+
/** Avatar ConvoAI token (filled by AgentKit at session start when omitted) */
|
|
138
|
+
agora_token?: string;
|
|
139
|
+
/** SenseTime application ID (required) */
|
|
140
|
+
appId: string;
|
|
141
|
+
/** SenseTime application key (required) */
|
|
142
|
+
app_key: string;
|
|
143
|
+
/** SenseTime scene configuration list (optional) */
|
|
144
|
+
sceneList?: SensetimeAvatarParams.SceneList.Item[];
|
|
145
|
+
[key: string]: unknown;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Spatius-specific avatar configuration.
|
|
150
|
+
*/
|
|
151
|
+
export interface SpatiusAvatarConfig {
|
|
152
|
+
enable?: boolean;
|
|
153
|
+
vendor: "spatius";
|
|
154
|
+
params: SpatiusAvatarParams;
|
|
155
|
+
}
|
|
126
156
|
/**
|
|
127
157
|
* Discriminated union of all avatar configurations.
|
|
128
158
|
* TypeScript will enforce vendor-specific constraints based on the vendor field.
|
|
129
159
|
*/
|
|
130
|
-
export type StrictAvatarConfig = HeyGenAvatarConfig | LiveAvatarAvatarConfig | AkoolAvatarConfig | AnamAvatarConfig | GenericAvatarConfig;
|
|
160
|
+
export type StrictAvatarConfig = HeyGenAvatarConfig | LiveAvatarAvatarConfig | AkoolAvatarConfig | AnamAvatarConfig | GenericAvatarConfig | SensetimeAvatarConfig | SpatiusAvatarConfig;
|
|
131
161
|
/**
|
|
132
162
|
* Helper type guard to check if an avatar config uses the legacy HeyGen wire vendor.
|
|
133
163
|
*/
|
|
@@ -148,6 +178,14 @@ export declare function isAnamAvatar(config: StrictAvatarConfig): config is Anam
|
|
|
148
178
|
* Helper type guard to check if an avatar config is for Generic Avatar.
|
|
149
179
|
*/
|
|
150
180
|
export declare function isGenericAvatar(config: StrictAvatarConfig): config is GenericAvatarConfig;
|
|
181
|
+
/**
|
|
182
|
+
* Helper type guard to check if an avatar config is for SenseTime (CN).
|
|
183
|
+
*/
|
|
184
|
+
export declare function isSensetimeAvatar(config: StrictAvatarConfig): config is SensetimeAvatarConfig;
|
|
185
|
+
/**
|
|
186
|
+
* Helper type guard to check if an avatar config is for Spatius.
|
|
187
|
+
*/
|
|
188
|
+
export declare function isSpatiusAvatar(config: StrictAvatarConfig): config is SpatiusAvatarConfig;
|
|
151
189
|
/**
|
|
152
190
|
* Returns true when AgentKit manages the avatar's RTC publisher identity
|
|
153
191
|
* (i.e. fills `agora_token`, validates uniqueness against the agent UID).
|
|
@@ -161,7 +199,8 @@ export declare function isAvatarTokenManaged(config: StrictAvatarConfig): boolea
|
|
|
161
199
|
* for cases where types are bypassed or data comes from external sources.
|
|
162
200
|
*
|
|
163
201
|
* @param options.requireSessionFields - When true, require fields AgentKit
|
|
164
|
-
* fills during `AgentSession.start()` for Generic avatars
|
|
202
|
+
* fills during `AgentSession.start()` for Generic avatars (`agora_appid`,
|
|
203
|
+
* `agora_channel`, `agora_token`).
|
|
165
204
|
* @throws {Error} If the configuration is invalid
|
|
166
205
|
*/
|
|
167
206
|
export declare function validateAvatarConfig(config: StrictAvatarConfig, options?: {
|
|
@@ -34,6 +34,18 @@ export function isAnamAvatar(config) {
|
|
|
34
34
|
export function isGenericAvatar(config) {
|
|
35
35
|
return config.vendor === "generic";
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Helper type guard to check if an avatar config is for SenseTime (CN).
|
|
39
|
+
*/
|
|
40
|
+
export function isSensetimeAvatar(config) {
|
|
41
|
+
return config.vendor === "sensetime";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Helper type guard to check if an avatar config is for Spatius.
|
|
45
|
+
*/
|
|
46
|
+
export function isSpatiusAvatar(config) {
|
|
47
|
+
return config.vendor === "spatius";
|
|
48
|
+
}
|
|
37
49
|
/**
|
|
38
50
|
* Returns true when AgentKit manages the avatar's RTC publisher identity
|
|
39
51
|
* (i.e. fills `agora_token`, validates uniqueness against the agent UID).
|
|
@@ -41,7 +53,11 @@ export function isGenericAvatar(config) {
|
|
|
41
53
|
* Mirrors the Go and Python SDK gate so all language SDKs behave identically.
|
|
42
54
|
*/
|
|
43
55
|
export function isAvatarTokenManaged(config) {
|
|
44
|
-
return isHeyGenAvatar(config) ||
|
|
56
|
+
return (isHeyGenAvatar(config) ||
|
|
57
|
+
isLiveAvatarAvatar(config) ||
|
|
58
|
+
isGenericAvatar(config) ||
|
|
59
|
+
isSensetimeAvatar(config) ||
|
|
60
|
+
isSpatiusAvatar(config));
|
|
45
61
|
}
|
|
46
62
|
/**
|
|
47
63
|
* Validates avatar configuration at runtime.
|
|
@@ -49,7 +65,8 @@ export function isAvatarTokenManaged(config) {
|
|
|
49
65
|
* for cases where types are bypassed or data comes from external sources.
|
|
50
66
|
*
|
|
51
67
|
* @param options.requireSessionFields - When true, require fields AgentKit
|
|
52
|
-
* fills during `AgentSession.start()` for Generic avatars
|
|
68
|
+
* fills during `AgentSession.start()` for Generic avatars (`agora_appid`,
|
|
69
|
+
* `agora_channel`, `agora_token`).
|
|
53
70
|
* @throws {Error} If the configuration is invalid
|
|
54
71
|
*/
|
|
55
72
|
export function validateAvatarConfig(config, options = {}) {
|
|
@@ -105,6 +122,37 @@ export function validateAvatarConfig(config, options = {}) {
|
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
124
|
}
|
|
125
|
+
else if (isSensetimeAvatar(config)) {
|
|
126
|
+
if (!config.params.agora_uid) {
|
|
127
|
+
throw new Error("SenseTime avatar requires agora_uid");
|
|
128
|
+
}
|
|
129
|
+
if (!config.params.appId) {
|
|
130
|
+
throw new Error("SenseTime avatar requires appId");
|
|
131
|
+
}
|
|
132
|
+
if (!config.params.app_key) {
|
|
133
|
+
throw new Error("SenseTime avatar requires app_key");
|
|
134
|
+
}
|
|
135
|
+
if (config.params.sceneList !== undefined && !Array.isArray(config.params.sceneList)) {
|
|
136
|
+
throw new Error("SenseTime avatar sceneList must be an array when provided");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else if (isSpatiusAvatar(config)) {
|
|
140
|
+
if (!config.params.agora_uid) {
|
|
141
|
+
throw new Error("Spatius avatar requires agora_uid");
|
|
142
|
+
}
|
|
143
|
+
if (!config.params.spatius_api_key) {
|
|
144
|
+
throw new Error("Spatius avatar requires spatius_api_key");
|
|
145
|
+
}
|
|
146
|
+
if (!config.params.spatius_app_id) {
|
|
147
|
+
throw new Error("Spatius avatar requires spatius_app_id");
|
|
148
|
+
}
|
|
149
|
+
if (!config.params.spatius_avatar_id) {
|
|
150
|
+
throw new Error("Spatius avatar requires spatius_avatar_id");
|
|
151
|
+
}
|
|
152
|
+
if (options.requireSessionFields && !config.params.agora_token) {
|
|
153
|
+
throw new Error("Spatius avatar requires agora_token after session enrichment");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
108
156
|
}
|
|
109
157
|
/**
|
|
110
158
|
* Validates that TTS sample rate is compatible with the avatar vendor.
|
|
@@ -23,23 +23,26 @@ export type { AgentOptions } from "./Agent.mjs";
|
|
|
23
23
|
export { Agent } from "./Agent.mjs";
|
|
24
24
|
export type { AgentSessionEvent, AgentSessionEventHandler, AgentSessionOptions, } from "./AgentSession.mjs";
|
|
25
25
|
export { AgentSession } from "./AgentSession.mjs";
|
|
26
|
-
export type { AkoolAvatarConfig, AnamAvatarConfig, GenericAvatarConfig, HeyGenAvatarConfig, LiveAvatarAvatarConfig, StrictAvatarConfig, } from "./avatar-types.mjs";
|
|
27
|
-
export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
|
|
26
|
+
export type { AkoolAvatarConfig, AnamAvatarConfig, GenericAvatarConfig, HeyGenAvatarConfig, LiveAvatarAvatarConfig, SensetimeAvatarConfig, SpatiusAvatarConfig, StrictAvatarConfig, } from "./avatar-types.mjs";
|
|
27
|
+
export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
|
|
28
28
|
export { AudioScenario, DataChannel, FillerWordsSelectionRule, Geofence, InterruptionDisabledStrategy, InterruptionDisabledStrategyAppend, InterruptionDisabledStrategyIgnore, InterruptionModeKeywords, InterruptionModeStartOfSpeech, InterruptionModeValues, MllmTurnDetectionModeAgoraVad, MllmTurnDetectionModeSemanticVad, MllmTurnDetectionModeServerVad, MllmTurnDetectionModeValues, SalModeValues, SilenceActionValues, SpeakPriorityAppend, SpeakPriorityIgnore, SpeakPriorityInterrupt, SpeakPriorityValues, ThinkOnListeningActionIgnore, ThinkOnListeningActionInject, ThinkOnListeningActionInterrupt, ThinkOnSpeakingActionIgnore, ThinkOnSpeakingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnThinkingActionInterrupt, TurnDetectionTypeValues, } from "./constants.mjs";
|
|
29
|
-
export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPresetModel, OpenAIPresetModel, OpenAITtsPresetModel, PresetInput, TtsPreset, } from "./presets.mjs";
|
|
29
|
+
export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPresetModel, OpenAIPresetModel, OpenAITtsPresetModel, PresetCategory, PresetInput, TtsPreset, } from "./presets.mjs";
|
|
30
30
|
export { AgentPresets, normalizePresetInput } from "./presets.mjs";
|
|
31
|
+
export type { AvatarVendor, CNAvatarVendor, CNLlmVendor, CNSttVendor, CNTtsVendor, GlobalAvatarVendor, GlobalLlmVendor, GlobalSttVendor, GlobalTtsVendor, LlmVendor, SttVendor, TtsVendor, } from "./region-vendors.mjs";
|
|
31
32
|
export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.mjs";
|
|
32
33
|
export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.mjs";
|
|
33
|
-
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AvatarConfig,
|
|
34
|
+
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AsrVendorName, AvatarConfig, AvatarWireVendor, CartesiaTts, CartesiaTtsParams, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, Eagerness, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FillerWordsConfig, FillerWordsContent, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTts, FishAudioTtsParams, GenericTts, GenericTtsParams, 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, SpatiusAvatarParams, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, XAiAsr, XAiAsrParams, XAiTts, XAiTtsParams, } from "./types.mjs";
|
|
34
35
|
export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LiveAvatarAvatarOptions, } from "./vendors/avatar.mjs";
|
|
35
36
|
export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.mjs";
|
|
36
37
|
export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.mjs";
|
|
37
|
-
export { BaseAvatar, BaseLLM, type BaseLlmOptions, BaseMLLM, BaseSTT, BaseTTS, type GoogleTTSSampleRate, } from "./vendors/base.mjs";
|
|
38
|
+
export { BaseAvatar, BaseCNAvatar, BaseCNLLM, BaseCNSTT, BaseCNTTS, BaseLLM, type BaseLlmOptions, BaseMLLM, BaseSTT, BaseTTS, type GoogleTTSSampleRate, } from "./vendors/base.mjs";
|
|
39
|
+
export type { AliyunLLMOptions, BytedanceDuplexTTSOptions, BytedanceLLMOptions, BytedanceTTSOptions, CosyVoiceTTSOptions, DeepSeekLLMOptions, MicrosoftCNSampleRate, MicrosoftCNSTTOptions, MicrosoftCNTTSOptions, MiniMaxCNTTSOptions, SensetimeAvatarOptions, SpatiusAvatarOptions, StepFunTTSOptions, TencentLLMOptions, TencentSTTOptions, TencentTTSOptions, XfyunBigModelSTTOptions, XfyunDialectSTTOptions, XfyunSTTOptions, } from "./vendors/cn.mjs";
|
|
40
|
+
export { AliyunLLM, BytedanceDuplexTTS, BytedanceLLM, BytedanceTTS, CosyVoiceTTS, DeepSeekLLM, FengmingSTT, MicrosoftCNSTT, MicrosoftCNTTS, MiniMaxCNTTS, SensetimeAvatar, SpatiusAvatar, StepFunTTS, TencentLLM, TencentSTT, TencentTTS, XfyunBigModelSTT, XfyunDialectSTT, XfyunSTT, } from "./vendors/cn.mjs";
|
|
38
41
|
export type { AmazonBedrockOptions, AnthropicOptions, AzureOpenAIOptions, CustomLLMOptions, DifyOptions, GeminiOptions, GroqOptions, OpenAIOptions, VertexAILLMOptions, } from "./vendors/llm.mjs";
|
|
39
42
|
export { AmazonBedrock, Anthropic, AzureOpenAI, CustomLLM, Dify, Gemini, Groq, OpenAI, VertexAILLM, } from "./vendors/llm.mjs";
|
|
40
43
|
export type { GeminiLiveOptions, OpenAIRealtimeOptions, VertexAIOptions, XaiGrokOptions, } from "./vendors/mllm.mjs";
|
|
41
44
|
export { GeminiLive, OpenAIRealtime, VertexAI, XaiGrok, } from "./vendors/mllm.mjs";
|
|
42
|
-
export type { AmazonSTTOptions, AresSTTOptions, AssemblyAISTTOptions, DeepgramSTTOptions, GoogleSTTOptions, MicrosoftSTTOptions, OpenAISTTOptions, SarvamSTTOptions, SpeechmaticsSTTOptions, } from "./vendors/stt.mjs";
|
|
43
|
-
export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, } from "./vendors/stt.mjs";
|
|
44
|
-
export type { AmazonTTSOptions, CartesiaTTSOptions, DeepgramTTSOptions, ElevenLabsTTSOptions, FishAudioTTSOptions, GoogleTTSOptions, HumeAITTSOptions, MicrosoftTTSOptions, MiniMaxTTSOptions, MurfTTSOptions, OpenAITTSOptions, RimeTTSOptions, SarvamTTSOptions, } from "./vendors/tts.mjs";
|
|
45
|
-
export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GoogleTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, } from "./vendors/tts.mjs";
|
|
45
|
+
export type { AmazonSTTOptions, AresSTTOptions, AssemblyAISTTOptions, DeepgramSTTOptions, GoogleSTTOptions, MicrosoftSTTOptions, OpenAISTTOptions, SarvamSTTOptions, SpeechmaticsSTTOptions, XAiSTTOptions, } from "./vendors/stt.mjs";
|
|
46
|
+
export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.mjs";
|
|
47
|
+
export type { AmazonTTSOptions, CartesiaTTSOptions, DeepgramTTSOptions, ElevenLabsTTSOptions, FishAudioTTSOptions, GenericTTSOptions, GoogleTTSOptions, HumeAITTSOptions, MicrosoftTTSOptions, MiniMaxTTSOptions, MurfTTSOptions, OpenAITTSOptions, RimeTTSOptions, SarvamTTSOptions, XAiTTSOptions, } from "./vendors/tts.mjs";
|
|
48
|
+
export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GenericTTS, GoogleTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, XAiTTS, } from "./vendors/tts.mjs";
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// Core classes
|
|
22
22
|
export { Agent } from "./Agent.mjs";
|
|
23
23
|
export { AgentSession } from "./AgentSession.mjs";
|
|
24
|
-
export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
|
|
24
|
+
export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
|
|
25
25
|
// Type-safe constants
|
|
26
26
|
export { AudioScenario, DataChannel, FillerWordsSelectionRule, Geofence, InterruptionDisabledStrategy, InterruptionDisabledStrategyAppend, InterruptionDisabledStrategyIgnore, InterruptionModeKeywords, InterruptionModeStartOfSpeech, InterruptionModeValues, MllmTurnDetectionModeAgoraVad, MllmTurnDetectionModeSemanticVad, MllmTurnDetectionModeServerVad, MllmTurnDetectionModeValues, SalModeValues, SilenceActionValues, SpeakPriorityAppend, SpeakPriorityIgnore, SpeakPriorityInterrupt, SpeakPriorityValues, ThinkOnListeningActionIgnore, ThinkOnListeningActionInject, ThinkOnListeningActionInterrupt, ThinkOnSpeakingActionIgnore, ThinkOnSpeakingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnThinkingActionInterrupt, TurnDetectionTypeValues, } from "./constants.mjs";
|
|
27
27
|
export { AgentPresets, normalizePresetInput } from "./presets.mjs";
|
|
@@ -30,12 +30,13 @@ export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS,
|
|
|
30
30
|
// Avatar vendor classes
|
|
31
31
|
export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.mjs";
|
|
32
32
|
// Base vendor classes
|
|
33
|
-
export { BaseAvatar, BaseLLM, BaseMLLM, BaseSTT, BaseTTS, } from "./vendors/base.mjs";
|
|
33
|
+
export { BaseAvatar, BaseCNAvatar, BaseCNLLM, BaseCNSTT, BaseCNTTS, BaseLLM, BaseMLLM, BaseSTT, BaseTTS, } from "./vendors/base.mjs";
|
|
34
|
+
export { AliyunLLM, BytedanceDuplexTTS, BytedanceLLM, BytedanceTTS, CosyVoiceTTS, DeepSeekLLM, FengmingSTT, MicrosoftCNSTT, MicrosoftCNTTS, MiniMaxCNTTS, SensetimeAvatar, SpatiusAvatar, StepFunTTS, TencentLLM, TencentSTT, TencentTTS, XfyunBigModelSTT, XfyunDialectSTT, XfyunSTT, } from "./vendors/cn.mjs";
|
|
34
35
|
// LLM vendor classes
|
|
35
36
|
export { AmazonBedrock, Anthropic, AzureOpenAI, CustomLLM, Dify, Gemini, Groq, OpenAI, VertexAILLM, } from "./vendors/llm.mjs";
|
|
36
37
|
// MLLM vendor classes
|
|
37
38
|
export { GeminiLive, OpenAIRealtime, VertexAI, XaiGrok, } from "./vendors/mllm.mjs";
|
|
38
39
|
// STT vendor classes
|
|
39
|
-
export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, } from "./vendors/stt.mjs";
|
|
40
|
+
export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.mjs";
|
|
40
41
|
// TTS vendor classes
|
|
41
|
-
export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GoogleTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, } from "./vendors/tts.mjs";
|
|
42
|
+
export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GenericTTS, GoogleTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, XAiTTS, } from "./vendors/tts.mjs";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BaseAvatar, BaseCNAvatar, BaseCNLLM, BaseCNSTT, BaseCNTTS, BaseLLM, BaseSTT, BaseTTS } from "./vendors/base.mjs";
|
|
2
|
+
import type { MicrosoftCNSampleRate, MicrosoftCNSTT, MicrosoftCNTTS } from "./vendors/cn.mjs";
|
|
3
|
+
import type { CustomLLM } from "./vendors/llm.mjs";
|
|
4
|
+
export type GlobalLlmVendor = BaseLLM;
|
|
5
|
+
export type GlobalTtsVendor<SR extends number = number> = BaseTTS<SR>;
|
|
6
|
+
export type GlobalSttVendor = BaseSTT;
|
|
7
|
+
export type GlobalAvatarVendor<SR extends number = number> = BaseAvatar<SR>;
|
|
8
|
+
export type CNLlmVendor = BaseCNLLM | CustomLLM;
|
|
9
|
+
export type CNTtsVendor<SR extends number = number> = BaseCNTTS<SR> | (SR extends MicrosoftCNSampleRate ? MicrosoftCNTTS<SR> : never);
|
|
10
|
+
export type CNSttVendor = BaseCNSTT | MicrosoftCNSTT;
|
|
11
|
+
export type CNAvatarVendor<SR extends number = number> = BaseCNAvatar<SR>;
|
|
12
|
+
export type LlmVendor = GlobalLlmVendor | CNLlmVendor;
|
|
13
|
+
export type TtsVendor<SR extends number = number> = GlobalTtsVendor<SR> | CNTtsVendor<SR>;
|
|
14
|
+
export type SttVendor = GlobalSttVendor | CNSttVendor;
|
|
15
|
+
export type AvatarVendor<SR extends number = number> = GlobalAvatarVendor<SR> | CNAvatarVendor<SR>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,8 +18,9 @@ export declare const MAX_EXPIRY_SECONDS = 86400;
|
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```typescript
|
|
21
|
-
* agent.createSession(
|
|
22
|
-
*
|
|
21
|
+
* agent.createSession({
|
|
22
|
+
* name: `conversation-${Date.now()}`,
|
|
23
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
23
24
|
* agentUid: '1',
|
|
24
25
|
* remoteUids: ['100'],
|
|
25
26
|
* expiresIn: ExpiresIn.hours(12),
|
|
@@ -20,8 +20,9 @@ export const MAX_EXPIRY_SECONDS = 86400;
|
|
|
20
20
|
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
|
-
* agent.createSession(
|
|
24
|
-
*
|
|
23
|
+
* agent.createSession({
|
|
24
|
+
* name: `conversation-${Date.now()}`,
|
|
25
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
25
26
|
* agentUid: '1',
|
|
26
27
|
* remoteUids: ['100'],
|
|
27
28
|
* expiresIn: ExpiresIn.hours(12),
|