agora-agents 2.7.0 → 2.8.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 +3 -3
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/agentkit/Agent.d.ts +1 -1
- package/dist/cjs/agentkit/Agent.js +27 -12
- package/dist/cjs/agentkit/AgentSession.d.ts +0 -3
- package/dist/cjs/agentkit/AgentSession.js +3 -3
- package/dist/cjs/agentkit/debug.d.ts +2 -4
- package/dist/cjs/agentkit/debug.js +15 -6
- package/dist/cjs/agentkit/index.d.ts +7 -5
- package/dist/cjs/agentkit/index.js +15 -12
- package/dist/cjs/agentkit/preview/client.d.ts +6 -5
- package/dist/cjs/agentkit/preview/client.js +10 -5
- package/dist/cjs/agentkit/preview/index.d.ts +6 -5
- package/dist/cjs/agentkit/preview/index.js +8 -6
- package/dist/cjs/agentkit/preview/vendors.d.ts +65 -63
- package/dist/cjs/agentkit/preview/vendors.js +71 -36
- package/dist/cjs/agentkit/types.d.ts +23 -41
- package/dist/cjs/agentkit/vendors/base.d.ts +6 -2
- package/dist/cjs/agentkit/vendors/base.js +4 -0
- package/dist/cjs/agentkit/vendors/cn.js +7 -5
- package/dist/cjs/agentkit/vendors/llm.js +8 -1
- package/dist/cjs/agentkit/vendors/stt.d.ts +45 -2
- package/dist/cjs/agentkit/vendors/stt.js +53 -5
- package/dist/cjs/agentkit/vendors/tts.js +1 -1
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +12 -20
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +1 -1
- package/dist/cjs/api/types/Asr.d.ts +4 -1
- package/dist/cjs/api/types/GeminiAsr.d.ts +10 -0
- package/dist/cjs/api/types/GeminiAsr.js +3 -0
- package/dist/cjs/api/types/GeminiAsrParams.d.ts +33 -0
- package/dist/cjs/api/types/GeminiAsrParams.js +12 -0
- package/dist/cjs/api/types/index.d.ts +2 -0
- package/dist/cjs/api/types/index.js +2 -0
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/agentkit/Agent.d.mts +1 -1
- package/dist/esm/agentkit/Agent.mjs +27 -12
- package/dist/esm/agentkit/AgentSession.d.mts +0 -3
- package/dist/esm/agentkit/AgentSession.mjs +3 -3
- package/dist/esm/agentkit/debug.d.mts +2 -4
- package/dist/esm/agentkit/debug.mjs +15 -6
- package/dist/esm/agentkit/index.d.mts +7 -5
- package/dist/esm/agentkit/index.mjs +3 -2
- package/dist/esm/agentkit/preview/client.d.mts +6 -5
- package/dist/esm/agentkit/preview/client.mjs +10 -5
- package/dist/esm/agentkit/preview/index.d.mts +6 -5
- package/dist/esm/agentkit/preview/index.mjs +4 -4
- package/dist/esm/agentkit/preview/vendors.d.mts +65 -63
- package/dist/esm/agentkit/preview/vendors.mjs +69 -35
- package/dist/esm/agentkit/types.d.mts +23 -41
- package/dist/esm/agentkit/vendors/base.d.mts +6 -2
- package/dist/esm/agentkit/vendors/base.mjs +4 -0
- package/dist/esm/agentkit/vendors/cn.mjs +7 -5
- package/dist/esm/agentkit/vendors/llm.mjs +8 -1
- package/dist/esm/agentkit/vendors/stt.d.mts +45 -2
- package/dist/esm/agentkit/vendors/stt.mjs +51 -4
- package/dist/esm/agentkit/vendors/tts.mjs +1 -1
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +12 -20
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +1 -1
- package/dist/esm/api/types/Asr.d.mts +4 -1
- package/dist/esm/api/types/GeminiAsr.d.mts +10 -0
- package/dist/esm/api/types/GeminiAsr.mjs +2 -0
- package/dist/esm/api/types/GeminiAsrParams.d.mts +33 -0
- package/dist/esm/api/types/GeminiAsrParams.mjs +9 -0
- package/dist/esm/api/types/index.d.mts +2 -0
- package/dist/esm/api/types/index.mjs +2 -0
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +4 -2
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.d.ts +0 -1
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +0 -87
- package/dist/cjs/agentkit/__tests__/preview-types.test.d.ts +0 -7
- package/dist/cjs/agentkit/__tests__/preview-types.test.js +0 -57
- package/dist/cjs/agentkit/__tests__/readme-examples.test.d.ts +0 -1
- package/dist/cjs/agentkit/__tests__/readme-examples.test.js +0 -126
- package/dist/cjs/agentkit/__tests__/type-safety.test.d.ts +0 -14
- package/dist/cjs/agentkit/__tests__/type-safety.test.js +0 -321
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.d.mts +0 -1
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +0 -85
- package/dist/esm/agentkit/__tests__/preview-types.test.d.mts +0 -7
- package/dist/esm/agentkit/__tests__/preview-types.test.mjs +0 -55
- package/dist/esm/agentkit/__tests__/readme-examples.test.d.mts +0 -1
- package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +0 -124
- package/dist/esm/agentkit/__tests__/type-safety.test.d.mts +0 -14
- package/dist/esm/agentkit/__tests__/type-safety.test.mjs +0 -319
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AgoraPoolClient_js_1 = require("../../AgoraPoolClient.js");
|
|
4
|
-
const index_js_1 = require("../../core/domain/index.js");
|
|
5
|
-
const Agent_js_1 = require("../Agent.js");
|
|
6
|
-
const cn_js_1 = require("../vendors/cn.js");
|
|
7
|
-
const llm_js_1 = require("../vendors/llm.js");
|
|
8
|
-
const stt_js_1 = require("../vendors/stt.js");
|
|
9
|
-
const tts_js_1 = require("../vendors/tts.js");
|
|
10
|
-
const AGENT_PROMPT = "You are a concise, technically credible voice assistant. Keep replies short unless the user asks for detail.";
|
|
11
|
-
const GREETING = "Hi there! I am your Agora voice assistant. How can I help?";
|
|
12
|
-
const SUPPORT_PROMPT = "You are a concise support assistant.";
|
|
13
|
-
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
14
|
-
area: index_js_1.Area.US,
|
|
15
|
-
appId: "app-id",
|
|
16
|
-
appCertificate: "app-certificate-0123456789abcdef",
|
|
17
|
-
});
|
|
18
|
-
new Agent_js_1.Agent({
|
|
19
|
-
client,
|
|
20
|
-
turnDetection: {
|
|
21
|
-
language: "en-US",
|
|
22
|
-
config: {
|
|
23
|
-
speech_threshold: 0.5,
|
|
24
|
-
start_of_speech: {
|
|
25
|
-
mode: "vad",
|
|
26
|
-
vad_config: {
|
|
27
|
-
interrupt_duration_ms: 160,
|
|
28
|
-
prefix_padding_ms: 300,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
end_of_speech: {
|
|
32
|
-
mode: "vad",
|
|
33
|
-
vad_config: {
|
|
34
|
-
silence_duration_ms: 480,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
advancedFeatures: {
|
|
40
|
-
enable_rtm: true,
|
|
41
|
-
enable_tools: true,
|
|
42
|
-
},
|
|
43
|
-
parameters: {
|
|
44
|
-
data_channel: "rtm",
|
|
45
|
-
enable_error_message: true,
|
|
46
|
-
},
|
|
47
|
-
})
|
|
48
|
-
.withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en" }))
|
|
49
|
-
.withLlm(new llm_js_1.OpenAI({
|
|
50
|
-
model: "gpt-4o-mini",
|
|
51
|
-
systemMessages: [{ role: "system", content: AGENT_PROMPT }],
|
|
52
|
-
greetingMessage: GREETING,
|
|
53
|
-
failureMessage: "Please wait a moment.",
|
|
54
|
-
maxHistory: 50,
|
|
55
|
-
params: {
|
|
56
|
-
max_tokens: 1024,
|
|
57
|
-
temperature: 0.7,
|
|
58
|
-
top_p: 0.95,
|
|
59
|
-
},
|
|
60
|
-
}))
|
|
61
|
-
.withTts(new tts_js_1.MiniMaxTTS({
|
|
62
|
-
model: "speech_2_6_turbo",
|
|
63
|
-
voiceId: "English_captivating_female1",
|
|
64
|
-
}))
|
|
65
|
-
.createSession({
|
|
66
|
-
name: `conversation-${Date.now()}`,
|
|
67
|
-
channel: `demo-channel-${Date.now()}`,
|
|
68
|
-
agentUid: "123456",
|
|
69
|
-
remoteUids: ["*"],
|
|
70
|
-
idleTimeout: 30,
|
|
71
|
-
});
|
|
72
|
-
{
|
|
73
|
-
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
74
|
-
area: index_js_1.Area.CN,
|
|
75
|
-
appId: "app-id",
|
|
76
|
-
appCertificate: "app-certificate-0123456789abcdef",
|
|
77
|
-
});
|
|
78
|
-
new Agent_js_1.Agent({
|
|
79
|
-
client,
|
|
80
|
-
turnDetection: { language: "zh-CN" },
|
|
81
|
-
})
|
|
82
|
-
.withStt(new cn_js_1.FengmingSTT())
|
|
83
|
-
.withLlm(new cn_js_1.AliyunLLM({
|
|
84
|
-
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
85
|
-
model: "qwen-plus",
|
|
86
|
-
}))
|
|
87
|
-
.withTts(new cn_js_1.MiniMaxCNTTS({
|
|
88
|
-
key: "minimax-key",
|
|
89
|
-
model: "speech-01-turbo",
|
|
90
|
-
voiceSetting: { voice_id: "female-shaonv" },
|
|
91
|
-
audioSetting: { sample_rate: 16000 },
|
|
92
|
-
}))
|
|
93
|
-
.createSession({
|
|
94
|
-
name: `conversation-${Date.now()}`,
|
|
95
|
-
channel: `demo-channel-${Date.now()}`,
|
|
96
|
-
agentUid: "1001",
|
|
97
|
-
remoteUids: ["100"],
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
{
|
|
101
|
-
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
102
|
-
area: index_js_1.Area.US,
|
|
103
|
-
appId: "app-id",
|
|
104
|
-
appCertificate: "app-certificate-0123456789abcdef",
|
|
105
|
-
});
|
|
106
|
-
new Agent_js_1.Agent({ client, turnDetection: { language: "en-US" } })
|
|
107
|
-
.withStt(new stt_js_1.DeepgramSTT({
|
|
108
|
-
apiKey: "deepgram-key",
|
|
109
|
-
model: "nova-3",
|
|
110
|
-
language: "en",
|
|
111
|
-
}))
|
|
112
|
-
.withLlm(new llm_js_1.OpenAI({
|
|
113
|
-
apiKey: "openai-key",
|
|
114
|
-
url: "https://api.openai.com/v1/chat/completions",
|
|
115
|
-
model: "gpt-4o-mini",
|
|
116
|
-
systemMessages: [{ role: "system", content: SUPPORT_PROMPT }],
|
|
117
|
-
greetingMessage: GREETING,
|
|
118
|
-
maxTokens: 1024,
|
|
119
|
-
temperature: 0.7,
|
|
120
|
-
topP: 0.95,
|
|
121
|
-
}))
|
|
122
|
-
.withTts(new tts_js_1.MiniMaxTTS({
|
|
123
|
-
model: "speech_2_6_turbo",
|
|
124
|
-
voiceId: "English_captivating_female1",
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type safety demonstrations for sample rate enforcement.
|
|
3
|
-
*
|
|
4
|
-
* This file demonstrates compile-time type checking for:
|
|
5
|
-
* 1. Invalid sample rates (e.g., 25000 Hz)
|
|
6
|
-
* 2. Avatar/TTS sample rate mismatches (e.g., 16kHz TTS + HeyGen 24kHz avatar)
|
|
7
|
-
* 3. Valid configurations that compile successfully
|
|
8
|
-
*
|
|
9
|
-
* To verify type checking works:
|
|
10
|
-
* 1. Uncomment sections marked with @ts-expect-error
|
|
11
|
-
* 2. Run: npm run build
|
|
12
|
-
* 3. TypeScript should show errors for the uncommented invalid sections
|
|
13
|
-
*/
|
|
14
|
-
export {};
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Type safety demonstrations for sample rate enforcement.
|
|
4
|
-
*
|
|
5
|
-
* This file demonstrates compile-time type checking for:
|
|
6
|
-
* 1. Invalid sample rates (e.g., 25000 Hz)
|
|
7
|
-
* 2. Avatar/TTS sample rate mismatches (e.g., 16kHz TTS + HeyGen 24kHz avatar)
|
|
8
|
-
* 3. Valid configurations that compile successfully
|
|
9
|
-
*
|
|
10
|
-
* To verify type checking works:
|
|
11
|
-
* 1. Uncomment sections marked with @ts-expect-error
|
|
12
|
-
* 2. Run: npm run build
|
|
13
|
-
* 3. TypeScript should show errors for the uncommented invalid sections
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const AgoraPoolClient_js_1 = require("../../AgoraPoolClient.js");
|
|
17
|
-
const index_js_1 = require("../../core/domain/index.js");
|
|
18
|
-
const Agent_js_1 = require("../Agent.js");
|
|
19
|
-
const avatar_js_1 = require("../vendors/avatar.js");
|
|
20
|
-
const llm_js_1 = require("../vendors/llm.js");
|
|
21
|
-
const stt_js_1 = require("../vendors/stt.js");
|
|
22
|
-
const tts_js_1 = require("../vendors/tts.js");
|
|
23
|
-
const TEST_AGENT_CLIENT = new AgoraPoolClient_js_1.AgoraClient({
|
|
24
|
-
area: index_js_1.Area.US,
|
|
25
|
-
appId: "test-app-id",
|
|
26
|
-
appCertificate: "test-app-certificate-01234567890",
|
|
27
|
-
});
|
|
28
|
-
// ============================================
|
|
29
|
-
// ✅ VALID CONFIGURATIONS
|
|
30
|
-
// ============================================
|
|
31
|
-
// Example 1: ElevenLabs 24kHz + HeyGen avatar
|
|
32
|
-
function _validExample1() {
|
|
33
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
34
|
-
.withTts(new tts_js_1.ElevenLabsTTS({
|
|
35
|
-
key: "test",
|
|
36
|
-
modelId: "eleven_flash_v2_5",
|
|
37
|
-
voiceId: "test",
|
|
38
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
39
|
-
sampleRate: 24000,
|
|
40
|
-
}))
|
|
41
|
-
.withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
42
|
-
apiKey: "test",
|
|
43
|
-
quality: "high",
|
|
44
|
-
agoraUid: "12345",
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
// Example 2: ElevenLabs 16kHz + Akool avatar
|
|
48
|
-
function _validExample2() {
|
|
49
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
50
|
-
.withTts(new tts_js_1.ElevenLabsTTS({
|
|
51
|
-
key: "test",
|
|
52
|
-
modelId: "eleven_flash_v2_5",
|
|
53
|
-
voiceId: "test",
|
|
54
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
55
|
-
sampleRate: 16000,
|
|
56
|
-
}))
|
|
57
|
-
.withAvatar(new avatar_js_1.AkoolAvatar({
|
|
58
|
-
apiKey: "test",
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
// Example 3: Microsoft 24kHz + HeyGen avatar
|
|
62
|
-
function _validExample3() {
|
|
63
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
64
|
-
.withTts(new tts_js_1.MicrosoftTTS({
|
|
65
|
-
key: "test",
|
|
66
|
-
region: "eastus",
|
|
67
|
-
voiceName: "en-US-JennyNeural",
|
|
68
|
-
sampleRate: 24000,
|
|
69
|
-
}))
|
|
70
|
-
.withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
71
|
-
apiKey: "test",
|
|
72
|
-
quality: "high",
|
|
73
|
-
agoraUid: "12345",
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
// Example 4: OpenAI (fixed 24kHz) + HeyGen avatar
|
|
77
|
-
function _validExample4() {
|
|
78
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
79
|
-
.withTts(new tts_js_1.OpenAITTS({
|
|
80
|
-
apiKey: "test",
|
|
81
|
-
voice: "alloy",
|
|
82
|
-
model: "gpt-4o-mini-tts",
|
|
83
|
-
baseUrl: "https://api.openai.com/v1",
|
|
84
|
-
}))
|
|
85
|
-
.withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
86
|
-
apiKey: "test",
|
|
87
|
-
quality: "high",
|
|
88
|
-
agoraUid: "12345",
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
// Example 5: Cartesia 16kHz + Akool avatar
|
|
92
|
-
function _validExample5() {
|
|
93
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
94
|
-
.withTts(new tts_js_1.CartesiaTTS({
|
|
95
|
-
apiKey: "test",
|
|
96
|
-
voiceId: "test",
|
|
97
|
-
modelId: "sonic-2",
|
|
98
|
-
sampleRate: 16000,
|
|
99
|
-
}))
|
|
100
|
-
.withAvatar(new avatar_js_1.AkoolAvatar({
|
|
101
|
-
apiKey: "test",
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
// Agora-managed models may omit credentials.
|
|
105
|
-
new stt_js_1.DeepgramSTT({ model: "nova-3" });
|
|
106
|
-
new llm_js_1.OpenAI({ model: "gpt-5-mini" });
|
|
107
|
-
new tts_js_1.OpenAITTS({ voice: "alloy" });
|
|
108
|
-
new llm_js_1.OpenAI({
|
|
109
|
-
apiKey: "test",
|
|
110
|
-
model: "gpt-5-mini",
|
|
111
|
-
url: "https://api.openai.com/v1/chat/completions",
|
|
112
|
-
vendor: "custom",
|
|
113
|
-
});
|
|
114
|
-
new tts_js_1.MiniMaxTTS({
|
|
115
|
-
model: "speech-2.6-turbo",
|
|
116
|
-
});
|
|
117
|
-
// @ts-expect-error Missing apiKey is only allowed for Agora-managed Deepgram models.
|
|
118
|
-
new stt_js_1.DeepgramSTT({ model: "enhanced" });
|
|
119
|
-
// @ts-expect-error Missing apiKey is only allowed for Agora-managed OpenAI models.
|
|
120
|
-
new llm_js_1.OpenAI({ model: "gpt-4o" });
|
|
121
|
-
// @ts-expect-error Missing apiKey cannot be combined with a custom vendor hint.
|
|
122
|
-
new llm_js_1.OpenAI({ model: "gpt-5-mini", vendor: "custom" });
|
|
123
|
-
// @ts-expect-error Missing apiKey cannot be combined with a custom URL.
|
|
124
|
-
new llm_js_1.OpenAI({ model: "gpt-5-mini", url: "https://proxy.example.com/chat" });
|
|
125
|
-
// @ts-expect-error Missing apiKey is only allowed for the openai_tts_1 preset model.
|
|
126
|
-
new tts_js_1.OpenAITTS({ voice: "alloy", model: "tts-1-hd" });
|
|
127
|
-
// @ts-expect-error Missing key is only allowed for supported MiniMax preset models.
|
|
128
|
-
new tts_js_1.MiniMaxTTS({
|
|
129
|
-
groupId: "group",
|
|
130
|
-
model: "speech-02-turbo",
|
|
131
|
-
voiceId: "voice",
|
|
132
|
-
url: "wss://example.com",
|
|
133
|
-
});
|
|
134
|
-
// ============================================
|
|
135
|
-
// ❌ INVALID: Sample rate mismatches
|
|
136
|
-
// Uncomment to verify compile errors
|
|
137
|
-
// ============================================
|
|
138
|
-
/*
|
|
139
|
-
// @ts-expect-error - HeyGen requires 24kHz, but TTS is configured for 16kHz
|
|
140
|
-
function invalidMismatch1(): Agent<24000> {
|
|
141
|
-
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
142
|
-
.withTts(
|
|
143
|
-
new ElevenLabsTTS({
|
|
144
|
-
key: "test",
|
|
145
|
-
modelId: "eleven_flash_v2_5",
|
|
146
|
-
voiceId: "test",
|
|
147
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
148
|
-
sampleRate: 16000, // ❌ Wrong rate for HeyGen
|
|
149
|
-
})
|
|
150
|
-
)
|
|
151
|
-
.withAvatar(
|
|
152
|
-
new LiveAvatarAvatar({
|
|
153
|
-
apiKey: "test",
|
|
154
|
-
quality: "high",
|
|
155
|
-
agoraUid: "12345",
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
*/
|
|
160
|
-
/*
|
|
161
|
-
// @ts-expect-error - Akool requires 16kHz, but TTS is configured for 24kHz
|
|
162
|
-
function invalidMismatch2(): Agent<16000> {
|
|
163
|
-
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
164
|
-
.withTts(
|
|
165
|
-
new ElevenLabsTTS({
|
|
166
|
-
key: "test",
|
|
167
|
-
modelId: "eleven_flash_v2_5",
|
|
168
|
-
voiceId: "test",
|
|
169
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
170
|
-
sampleRate: 24000, // ❌ Wrong rate for Akool
|
|
171
|
-
})
|
|
172
|
-
)
|
|
173
|
-
.withAvatar(
|
|
174
|
-
new AkoolAvatar({
|
|
175
|
-
apiKey: "test",
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
*/
|
|
180
|
-
/*
|
|
181
|
-
// @ts-expect-error - HeyGen requires 24kHz, not 48kHz
|
|
182
|
-
function invalidMismatch3(): Agent<24000> {
|
|
183
|
-
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
184
|
-
.withTts(
|
|
185
|
-
new MicrosoftTTS({
|
|
186
|
-
key: "test",
|
|
187
|
-
region: "eastus",
|
|
188
|
-
voiceName: "en-US-JennyNeural",
|
|
189
|
-
sampleRate: 48000, // ❌ Wrong rate for HeyGen
|
|
190
|
-
})
|
|
191
|
-
)
|
|
192
|
-
.withAvatar(
|
|
193
|
-
new LiveAvatarAvatar({
|
|
194
|
-
apiKey: "test",
|
|
195
|
-
quality: "high",
|
|
196
|
-
agoraUid: "12345",
|
|
197
|
-
})
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
*/
|
|
201
|
-
// ============================================
|
|
202
|
-
// ❌ INVALID: Invalid enum values
|
|
203
|
-
// Uncomment to verify compile errors
|
|
204
|
-
// ============================================
|
|
205
|
-
/*
|
|
206
|
-
// @ts-expect-error - 25000 is not a valid ElevenLabs sample rate
|
|
207
|
-
function invalidEnum1() {
|
|
208
|
-
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
209
|
-
new ElevenLabsTTS({
|
|
210
|
-
key: "test",
|
|
211
|
-
modelId: "eleven_flash_v2_5",
|
|
212
|
-
voiceId: "test",
|
|
213
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
214
|
-
sampleRate: 25000, // ❌ Not in enum: 16000, 22050, 24000, 44100
|
|
215
|
-
})
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
*/
|
|
219
|
-
/*
|
|
220
|
-
// @ts-expect-error - 8000 is not a valid Microsoft sample rate
|
|
221
|
-
function invalidEnum2() {
|
|
222
|
-
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
223
|
-
new MicrosoftTTS({
|
|
224
|
-
key: "test",
|
|
225
|
-
region: "eastus",
|
|
226
|
-
voiceName: "en-US-JennyNeural",
|
|
227
|
-
sampleRate: 8000, // ❌ Not in enum: 16000, 24000, 48000
|
|
228
|
-
})
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
*/
|
|
232
|
-
/*
|
|
233
|
-
// @ts-expect-error - 32000 is not a valid Cartesia sample rate
|
|
234
|
-
function invalidEnum3() {
|
|
235
|
-
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
236
|
-
new CartesiaTTS({
|
|
237
|
-
key: "test",
|
|
238
|
-
voiceId: "test",
|
|
239
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
240
|
-
sampleRate: 32000, // ❌ Not in enum: 8000-48000 (specific values)
|
|
241
|
-
})
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
*/
|
|
245
|
-
// ============================================
|
|
246
|
-
// ✅ VALID: Edge cases
|
|
247
|
-
// ============================================
|
|
248
|
-
// Avatar without TTS configured (allowed)
|
|
249
|
-
function _edgeCase1() {
|
|
250
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
251
|
-
apiKey: "test",
|
|
252
|
-
quality: "high",
|
|
253
|
-
agoraUid: "12345",
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
|
-
// TTS without avatar (allowed)
|
|
257
|
-
function _edgeCase2() {
|
|
258
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
259
|
-
key: "test",
|
|
260
|
-
modelId: "eleven_flash_v2_5",
|
|
261
|
-
voiceId: "test",
|
|
262
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
263
|
-
sampleRate: 16000,
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
// Method chaining preserves type tracking
|
|
267
|
-
function _edgeCase3() {
|
|
268
|
-
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
269
|
-
.withTts(new tts_js_1.ElevenLabsTTS({
|
|
270
|
-
key: "test",
|
|
271
|
-
modelId: "eleven_flash_v2_5",
|
|
272
|
-
voiceId: "test",
|
|
273
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
274
|
-
sampleRate: 24000,
|
|
275
|
-
}))
|
|
276
|
-
.withInstructions("Updated instructions")
|
|
277
|
-
.withGreeting("Hello!")
|
|
278
|
-
.withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
279
|
-
apiKey: "test",
|
|
280
|
-
quality: "high",
|
|
281
|
-
agoraUid: "12345",
|
|
282
|
-
}));
|
|
283
|
-
}
|
|
284
|
-
// ============================================
|
|
285
|
-
// Type inference verification
|
|
286
|
-
// ============================================
|
|
287
|
-
function _typeInference1() {
|
|
288
|
-
const agentWith24k = new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
289
|
-
key: "test",
|
|
290
|
-
modelId: "eleven_flash_v2_5",
|
|
291
|
-
voiceId: "test",
|
|
292
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
293
|
-
sampleRate: 24000,
|
|
294
|
-
}));
|
|
295
|
-
// Verify: Type should be Agent<24000>
|
|
296
|
-
const _typeCheck = agentWith24k;
|
|
297
|
-
return agentWith24k;
|
|
298
|
-
}
|
|
299
|
-
function _typeInference2() {
|
|
300
|
-
const agentWith16k = new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
301
|
-
key: "test",
|
|
302
|
-
modelId: "eleven_flash_v2_5",
|
|
303
|
-
voiceId: "test",
|
|
304
|
-
baseUrl: "wss://api.elevenlabs.io/v1",
|
|
305
|
-
sampleRate: 16000,
|
|
306
|
-
}));
|
|
307
|
-
// Verify: Type should be Agent<16000>
|
|
308
|
-
const _typeCheck = agentWith16k;
|
|
309
|
-
return agentWith16k;
|
|
310
|
-
}
|
|
311
|
-
function _typeInference3() {
|
|
312
|
-
const openAIAgent = new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.OpenAITTS({
|
|
313
|
-
apiKey: "test",
|
|
314
|
-
voice: "alloy",
|
|
315
|
-
model: "gpt-4o-mini-tts",
|
|
316
|
-
baseUrl: "https://api.openai.com/v1",
|
|
317
|
-
}));
|
|
318
|
-
// Verify: OpenAI is fixed at 24kHz, so type should be Agent<24000>
|
|
319
|
-
const _typeCheck = openAIAgent;
|
|
320
|
-
return openAIAgent;
|
|
321
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
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 { AzureOpenAIRealtime, QwenOmni } from "../vendors/mllm.mjs";
|
|
7
|
-
import { DeepgramSTT } from "../vendors/stt.mjs";
|
|
8
|
-
import { GenericTTS, MiniMaxTTS } from "../vendors/tts.mjs";
|
|
9
|
-
const client = new AgoraClient({
|
|
10
|
-
area: Area.US,
|
|
11
|
-
appId: "app-id",
|
|
12
|
-
appCertificate: "app-certificate-0123456789abcdef",
|
|
13
|
-
});
|
|
14
|
-
new Agent({ client, turnDetection: { language: "en-US" } })
|
|
15
|
-
.withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }))
|
|
16
|
-
.withLlm(new OpenAI({ model: "gpt-5-mini" }))
|
|
17
|
-
.withTts(new MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }))
|
|
18
|
-
.createSession({
|
|
19
|
-
name: "assistant",
|
|
20
|
-
channel: "test-room",
|
|
21
|
-
agentUid: "1",
|
|
22
|
-
remoteUids: ["100"],
|
|
23
|
-
});
|
|
24
|
-
// Area and provider may differ.
|
|
25
|
-
new Agent({ client }).withStt(new FengmingSTT());
|
|
26
|
-
new Agent({ client }).withLlm(new AliyunLLM({ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", model: "qwen-plus" }));
|
|
27
|
-
new Agent({ client }).withTts(new MiniMaxCNTTS({ key: "minimax-key", model: "speech-01-turbo", voiceSetting: { voice_id: "female-shaonv" } }));
|
|
28
|
-
const globalGenericTts = new GenericTTS({ url: "https://tts.example.com/v1/audio/speech" });
|
|
29
|
-
new Agent({ client }).withTts(globalGenericTts);
|
|
30
|
-
const globalMllm = new AzureOpenAIRealtime({
|
|
31
|
-
apiKey: "azure-key",
|
|
32
|
-
url: "wss://example.openai.azure.com/openai/realtime",
|
|
33
|
-
turnDetection: { mode: "server_vad" },
|
|
34
|
-
});
|
|
35
|
-
new Agent({ client }).withMllm(globalMllm);
|
|
36
|
-
// @ts-expect-error Qwen Omni is a Chinese mainland MLLM vendor.
|
|
37
|
-
const _invalidGlobalMllm = new QwenOmni({
|
|
38
|
-
apiKey: "key",
|
|
39
|
-
model: "qwen3.5-omni-plus-realtime",
|
|
40
|
-
url: "wss://dashscope.aliyuncs.com/api-ws/v1/realtime",
|
|
41
|
-
turnDetection: { mode: "server_vad" },
|
|
42
|
-
});
|
|
43
|
-
{
|
|
44
|
-
const client = new AgoraClient({
|
|
45
|
-
area: Area.CN,
|
|
46
|
-
appId: "app-id",
|
|
47
|
-
appCertificate: "app-certificate-0123456789abcdef",
|
|
48
|
-
});
|
|
49
|
-
new Agent({ client, turnDetection: { language: "zh-CN" } })
|
|
50
|
-
.withStt(new FengmingSTT())
|
|
51
|
-
.withLlm(new AliyunLLM({
|
|
52
|
-
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
53
|
-
model: "qwen-plus",
|
|
54
|
-
}))
|
|
55
|
-
.withTts(new MiniMaxCNTTS({
|
|
56
|
-
key: "minimax-key",
|
|
57
|
-
model: "speech-01-turbo",
|
|
58
|
-
voiceSetting: { voice_id: "female-shaonv" },
|
|
59
|
-
audioSetting: { sample_rate: 16000 },
|
|
60
|
-
}))
|
|
61
|
-
.createSession({
|
|
62
|
-
name: "assistant",
|
|
63
|
-
channel: "cn-room",
|
|
64
|
-
agentUid: "1",
|
|
65
|
-
remoteUids: ["100"],
|
|
66
|
-
});
|
|
67
|
-
new Agent({ client }).withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
68
|
-
new Agent({ client }).withLlm(new OpenAI({ model: "gpt-5-mini" }));
|
|
69
|
-
new Agent({ client }).withTts(new MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }));
|
|
70
|
-
const cnGenericTts = new GenericTTS({ url: "https://tts.example.cn/v1/audio/speech" });
|
|
71
|
-
new Agent({ client }).withTts(cnGenericTts);
|
|
72
|
-
const cnMllm = new QwenOmni({
|
|
73
|
-
apiKey: "key",
|
|
74
|
-
model: "qwen3.5-omni-plus-realtime",
|
|
75
|
-
url: "wss://dashscope.aliyuncs.com/api-ws/v1/realtime",
|
|
76
|
-
});
|
|
77
|
-
new Agent({ client }).withMllm(cnMllm);
|
|
78
|
-
// @ts-expect-error Azure OpenAI Realtime is a global MLLM vendor.
|
|
79
|
-
const _invalidCnMllm = new AzureOpenAIRealtime({
|
|
80
|
-
apiKey: "azure-key",
|
|
81
|
-
url: "wss://example.openai.azure.com/openai/realtime",
|
|
82
|
-
turnDetection: { mode: "server_vad" },
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
new Agent({ client }).withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compile-time type checks for the preview providers.
|
|
3
|
-
*
|
|
4
|
-
* This file is type-checked by `tsc` (it is under `src`), not executed by
|
|
5
|
-
* vitest. A regression here fails `pnpm build`.
|
|
6
|
-
*/
|
|
7
|
-
import { AgoraClient } from "../../AgoraPoolClient.mjs";
|
|
8
|
-
import { Area } from "../../core/domain/index.mjs";
|
|
9
|
-
import { Agent } from "../Agent.mjs";
|
|
10
|
-
import { GeminiSTT } from "../preview/index.mjs";
|
|
11
|
-
const CLIENT = new AgoraClient({
|
|
12
|
-
area: Area.US,
|
|
13
|
-
appId: "test-app-id",
|
|
14
|
-
appCertificate: "test-app-certificate-01234567890",
|
|
15
|
-
});
|
|
16
|
-
// ============================================
|
|
17
|
-
// ✅ VALID CONFIGURATIONS
|
|
18
|
-
// ============================================
|
|
19
|
-
function _validTranscribeStt() {
|
|
20
|
-
return new Agent({ client: CLIENT }).withStt(new GeminiSTT({
|
|
21
|
-
apiKey: "test",
|
|
22
|
-
model: "gemini-3.5-transcribe-live",
|
|
23
|
-
languageCodes: ["en-US"],
|
|
24
|
-
customVocabulary: ["Agora"],
|
|
25
|
-
sampleRate: 16000,
|
|
26
|
-
wordTimestamp: false,
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
/** The preview ASR variant is part of `SttConfig`, so hand-written configs type-check too. */
|
|
30
|
-
const _handWrittenAsr = {
|
|
31
|
-
vendor: "gemini",
|
|
32
|
-
language: "en-US",
|
|
33
|
-
params: {
|
|
34
|
-
api_key: "test",
|
|
35
|
-
model: "gemini-3.5-transcribe-live",
|
|
36
|
-
sample_rate: 16000,
|
|
37
|
-
language_codes: ["en-US"],
|
|
38
|
-
custom_vocabulary: ["Agora"],
|
|
39
|
-
word_timestamp: false,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
// ============================================
|
|
43
|
-
// ❌ INVALID CONFIGURATIONS
|
|
44
|
-
// ============================================
|
|
45
|
-
/** The API key is required — it is the only credential these providers accept. */
|
|
46
|
-
function _transcribeRequiresApiKey() {
|
|
47
|
-
// @ts-expect-error - apiKey is required
|
|
48
|
-
return new GeminiSTT({ languageCodes: ["en-US"] });
|
|
49
|
-
}
|
|
50
|
-
/** ASR params must carry a model; the preview gateway rejects a bare vendor. */
|
|
51
|
-
// @ts-expect-error - params.model is required
|
|
52
|
-
const _asrRequiresModel = {
|
|
53
|
-
vendor: "gemini",
|
|
54
|
-
params: { api_key: "test" },
|
|
55
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|