agora-agents 2.2.0 → 2.3.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 +48 -26
- package/dist/cjs/AgoraPoolClient.d.ts +9 -6
- package/dist/cjs/AgoraPoolClient.js +1 -0
- package/dist/cjs/agentkit/Agent.d.ts +52 -51
- package/dist/cjs/agentkit/Agent.js +40 -39
- package/dist/cjs/agentkit/AgentSession.d.ts +11 -10
- package/dist/cjs/agentkit/AgentSession.js +10 -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 +28 -2
- package/dist/cjs/agentkit/avatar-types.js +24 -2
- package/dist/cjs/agentkit/index.d.ts +8 -5
- package/dist/cjs/agentkit/index.js +27 -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 +26 -5
- package/dist/cjs/agentkit/vendors/avatar.d.ts +6 -3
- package/dist/cjs/agentkit/vendors/avatar.js +6 -3
- package/dist/cjs/agentkit/vendors/base.d.ts +38 -5
- package/dist/cjs/agentkit/vendors/base.js +60 -6
- package/dist/cjs/agentkit/vendors/cn.d.ts +251 -0
- package/dist/cjs/agentkit/vendors/cn.js +293 -0
- package/dist/cjs/agentkit/vendors/mllm.d.ts +8 -4
- package/dist/cjs/agentkit/vendors/mllm.js +8 -4
- package/dist/cjs/agentkit/vendors/stt.js +5 -0
- package/dist/cjs/agentkit/vendors/tts.d.ts +3 -3
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +5 -2
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +4 -0
- package/dist/cjs/api/types/Asr.d.ts +16 -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/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/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 +16 -1
- 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 +20 -0
- package/dist/cjs/api/types/index.js +20 -0
- 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 +26 -2
- package/dist/esm/AgoraPoolClient.d.mts +9 -6
- package/dist/esm/AgoraPoolClient.mjs +1 -0
- package/dist/esm/agentkit/Agent.d.mts +52 -51
- package/dist/esm/agentkit/Agent.mjs +40 -39
- package/dist/esm/agentkit/AgentSession.d.mts +11 -10
- package/dist/esm/agentkit/AgentSession.mjs +11 -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 +28 -2
- package/dist/esm/agentkit/avatar-types.mjs +23 -2
- package/dist/esm/agentkit/index.d.mts +8 -5
- package/dist/esm/agentkit/index.mjs +3 -2
- 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 +26 -5
- package/dist/esm/agentkit/vendors/avatar.d.mts +6 -3
- package/dist/esm/agentkit/vendors/avatar.mjs +6 -3
- package/dist/esm/agentkit/vendors/base.d.mts +38 -5
- package/dist/esm/agentkit/vendors/base.mjs +55 -5
- package/dist/esm/agentkit/vendors/cn.d.mts +251 -0
- package/dist/esm/agentkit/vendors/cn.mjs +272 -0
- package/dist/esm/agentkit/vendors/mllm.d.mts +8 -4
- package/dist/esm/agentkit/vendors/mllm.mjs +8 -4
- package/dist/esm/agentkit/vendors/stt.mjs +5 -0
- package/dist/esm/agentkit/vendors/tts.d.mts +3 -3
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +5 -2
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +4 -0
- package/dist/esm/api/types/Asr.d.mts +16 -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/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/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 +16 -1
- 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 +20 -0
- package/dist/esm/api/types/index.mjs +20 -0
- 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/package.json +1 -1
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
* This class provides a high-level interface for managing agent sessions,
|
|
5
5
|
* including starting, stopping, and interacting with the agent.
|
|
6
6
|
*/
|
|
7
|
+
import type { AgoraClient } from "../AgoraPoolClient.js";
|
|
7
8
|
import type { AgentManagementClient } from "../api/resources/agentManagement/client/Client.js";
|
|
8
9
|
import type { AgentsClient } from "../api/resources/agents/client/Client.js";
|
|
9
|
-
import type { AgoraClient } from "../Client.js";
|
|
10
10
|
import type { Agent } from "./Agent.js";
|
|
11
|
+
import type { AgoraArea } from "./area.js";
|
|
11
12
|
import { type PresetInput } from "./presets.js";
|
|
12
13
|
import type { AgentConfigUpdate, ConversationHistory, ConversationTurns, GetTurnsOptions, SayOptions, SessionInfo, ThinkOptions, ThinkResponse } from "./types.js";
|
|
13
14
|
/**
|
|
@@ -23,14 +24,14 @@ export type AgentSessionEventHandler<T = unknown> = (data: T) => void;
|
|
|
23
24
|
*/
|
|
24
25
|
export interface AgentSessionOptions {
|
|
25
26
|
/** The Agora client instance */
|
|
26
|
-
client: AgoraClient
|
|
27
|
+
client: AgoraClient<AgoraArea>;
|
|
27
28
|
/** The agent configuration */
|
|
28
|
-
agent: Agent
|
|
29
|
+
agent: Agent<number, AgoraArea>;
|
|
29
30
|
/** The App ID */
|
|
30
31
|
appId: string;
|
|
31
32
|
/** The App Certificate — enables automatic RTC token generation when starting sessions */
|
|
32
33
|
appCertificate?: string;
|
|
33
|
-
/** Unique name
|
|
34
|
+
/** Unique agent instance name (set via {@link Agent.createSession}) */
|
|
34
35
|
name: string;
|
|
35
36
|
/** The channel to join */
|
|
36
37
|
channel: string;
|
|
@@ -73,18 +74,18 @@ export interface AgentSessionOptions {
|
|
|
73
74
|
*
|
|
74
75
|
* const client = new AgoraClient({
|
|
75
76
|
* area: Area.US,
|
|
76
|
-
|
|
77
77
|
* appId: '...',
|
|
78
78
|
* appCertificate: '...',
|
|
79
79
|
* });
|
|
80
80
|
*
|
|
81
|
-
* const agent = new Agent({
|
|
81
|
+
* const agent = new Agent({ client, instructions: 'You are a helpful voice assistant.' })
|
|
82
82
|
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
83
83
|
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
84
84
|
* .withStt(new DeepgramSTT({ apiKey: '...', language: 'en-US' }));
|
|
85
85
|
*
|
|
86
|
-
* const session = agent.createSession(
|
|
87
|
-
*
|
|
86
|
+
* const session = agent.createSession({
|
|
87
|
+
* name: `conversation-${Date.now()}`,
|
|
88
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
88
89
|
* agentUid: '1',
|
|
89
90
|
* remoteUids: ['100'],
|
|
90
91
|
* });
|
|
@@ -137,7 +138,7 @@ export declare class AgentSession {
|
|
|
137
138
|
/**
|
|
138
139
|
* The agent configuration.
|
|
139
140
|
*/
|
|
140
|
-
get agent(): Agent
|
|
141
|
+
get agent(): Agent<number, AgoraArea>;
|
|
141
142
|
/**
|
|
142
143
|
* The App ID for this session.
|
|
143
144
|
*/
|
|
@@ -184,7 +185,7 @@ export declare class AgentSession {
|
|
|
184
185
|
* Fills session-derived avatar fields and generates avatar ConvoAI tokens.
|
|
185
186
|
*
|
|
186
187
|
* Token management is gated to vendors that publish a separate RTC video
|
|
187
|
-
* identity (HeyGen, LiveAvatar, Generic). Other vendors (Akool, Anam) do
|
|
188
|
+
* identity (HeyGen, LiveAvatar, Generic, SenseTime). Other vendors (Akool, Anam) do
|
|
188
189
|
* not run a separate publisher and never receive an auto-generated token.
|
|
189
190
|
*/
|
|
190
191
|
private _enrichAvatarParams;
|
|
@@ -31,18 +31,18 @@ const token_js_1 = require("./token.js");
|
|
|
31
31
|
*
|
|
32
32
|
* const client = new AgoraClient({
|
|
33
33
|
* area: Area.US,
|
|
34
|
-
|
|
35
34
|
* appId: '...',
|
|
36
35
|
* appCertificate: '...',
|
|
37
36
|
* });
|
|
38
37
|
*
|
|
39
|
-
* const agent = new Agent({
|
|
38
|
+
* const agent = new Agent({ client, instructions: 'You are a helpful voice assistant.' })
|
|
40
39
|
* .withLlm(new OpenAI({ apiKey: '...', model: 'gpt-4o-mini', url: 'https://api.openai.com/v1/chat/completions' }))
|
|
41
40
|
* .withTts(new ElevenLabsTTS({ key: '...', modelId: '...', voiceId: '...', baseUrl: 'wss://api.elevenlabs.io/v1', sampleRate: 24000 }))
|
|
42
41
|
* .withStt(new DeepgramSTT({ apiKey: '...', language: 'en-US' }));
|
|
43
42
|
*
|
|
44
|
-
* const session = agent.createSession(
|
|
45
|
-
*
|
|
43
|
+
* const session = agent.createSession({
|
|
44
|
+
* name: `conversation-${Date.now()}`,
|
|
45
|
+
* channel: `demo-channel-${Date.now()}`,
|
|
46
46
|
* agentUid: '1',
|
|
47
47
|
* remoteUids: ['100'],
|
|
48
48
|
* });
|
|
@@ -194,6 +194,7 @@ class AgentSession {
|
|
|
194
194
|
// are filled by `_enrichAvatarParams()` and validated separately.
|
|
195
195
|
if ((0, avatar_types_js_1.isHeyGenAvatar)(strictAvatar) ||
|
|
196
196
|
(0, avatar_types_js_1.isLiveAvatarAvatar)(strictAvatar) ||
|
|
197
|
+
(0, avatar_types_js_1.isSensetimeAvatar)(strictAvatar) ||
|
|
197
198
|
(0, avatar_types_js_1.isAkoolAvatar)(strictAvatar) ||
|
|
198
199
|
(0, avatar_types_js_1.isAnamAvatar)(strictAvatar) ||
|
|
199
200
|
(0, avatar_types_js_1.isGenericAvatar)(strictAvatar)) {
|
|
@@ -229,7 +230,7 @@ class AgentSession {
|
|
|
229
230
|
* Fills session-derived avatar fields and generates avatar ConvoAI tokens.
|
|
230
231
|
*
|
|
231
232
|
* Token management is gated to vendors that publish a separate RTC video
|
|
232
|
-
* identity (HeyGen, LiveAvatar, Generic). Other vendors (Akool, Anam) do
|
|
233
|
+
* identity (HeyGen, LiveAvatar, Generic, SenseTime). Other vendors (Akool, Anam) do
|
|
233
234
|
* not run a separate publisher and never receive an auto-generated token.
|
|
234
235
|
*/
|
|
235
236
|
_enrichAvatarParams(properties, expirySeconds) {
|
|
@@ -280,10 +281,13 @@ class AgentSession {
|
|
|
280
281
|
const strictAvatar = avatar;
|
|
281
282
|
if ((0, avatar_types_js_1.isHeyGenAvatar)(strictAvatar) ||
|
|
282
283
|
(0, avatar_types_js_1.isLiveAvatarAvatar)(strictAvatar) ||
|
|
284
|
+
(0, avatar_types_js_1.isSensetimeAvatar)(strictAvatar) ||
|
|
283
285
|
(0, avatar_types_js_1.isAkoolAvatar)(strictAvatar) ||
|
|
284
286
|
(0, avatar_types_js_1.isAnamAvatar)(strictAvatar) ||
|
|
285
287
|
(0, avatar_types_js_1.isGenericAvatar)(strictAvatar)) {
|
|
286
|
-
(0, avatar_types_js_1.validateAvatarConfig)(strictAvatar, {
|
|
288
|
+
(0, avatar_types_js_1.validateAvatarConfig)(strictAvatar, {
|
|
289
|
+
requireSessionFields: (0, avatar_types_js_1.isGenericAvatar)(strictAvatar),
|
|
290
|
+
});
|
|
287
291
|
}
|
|
288
292
|
if (!(0, avatar_types_js_1.isAvatarTokenManaged)(strictAvatar)) {
|
|
289
293
|
return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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 client = new AgoraPoolClient_js_1.AgoraClient({
|
|
11
|
+
area: index_js_1.Area.US,
|
|
12
|
+
appId: "app-id",
|
|
13
|
+
appCertificate: "app-certificate",
|
|
14
|
+
});
|
|
15
|
+
new Agent_js_1.Agent({ client, turnDetection: { language: "en-US" } })
|
|
16
|
+
.withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }))
|
|
17
|
+
.withLlm(new llm_js_1.OpenAI({ model: "gpt-5-mini" }))
|
|
18
|
+
.withTts(new tts_js_1.MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }))
|
|
19
|
+
.createSession({
|
|
20
|
+
name: "assistant",
|
|
21
|
+
channel: "test-room",
|
|
22
|
+
agentUid: "1",
|
|
23
|
+
remoteUids: ["100"],
|
|
24
|
+
});
|
|
25
|
+
// Area and provider may differ.
|
|
26
|
+
new Agent_js_1.Agent({ client }).withStt(new cn_js_1.FengmingSTT());
|
|
27
|
+
new Agent_js_1.Agent({ client }).withLlm(new cn_js_1.AliyunLLM({ url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions", model: "qwen-plus" }));
|
|
28
|
+
new Agent_js_1.Agent({ client }).withTts(new cn_js_1.MiniMaxCNTTS({ key: "minimax-key", model: "speech-01-turbo", voiceSetting: { voice_id: "female-shaonv" } }));
|
|
29
|
+
{
|
|
30
|
+
const client = new AgoraPoolClient_js_1.AgoraClient({
|
|
31
|
+
area: index_js_1.Area.CN,
|
|
32
|
+
appId: "app-id",
|
|
33
|
+
appCertificate: "app-certificate",
|
|
34
|
+
});
|
|
35
|
+
new Agent_js_1.Agent({ client, turnDetection: { language: "zh-CN" } })
|
|
36
|
+
.withStt(new cn_js_1.FengmingSTT())
|
|
37
|
+
.withLlm(new cn_js_1.AliyunLLM({
|
|
38
|
+
url: "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions",
|
|
39
|
+
model: "qwen-plus",
|
|
40
|
+
}))
|
|
41
|
+
.withTts(new cn_js_1.MiniMaxCNTTS({
|
|
42
|
+
key: "minimax-key",
|
|
43
|
+
model: "speech-01-turbo",
|
|
44
|
+
voiceSetting: { voice_id: "female-shaonv" },
|
|
45
|
+
audioSetting: { sample_rate: 16000 },
|
|
46
|
+
}))
|
|
47
|
+
.createSession({
|
|
48
|
+
name: "assistant",
|
|
49
|
+
channel: "cn-room",
|
|
50
|
+
agentUid: "1",
|
|
51
|
+
remoteUids: ["100"],
|
|
52
|
+
});
|
|
53
|
+
new Agent_js_1.Agent({ client }).withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
54
|
+
new Agent_js_1.Agent({ client }).withLlm(new llm_js_1.OpenAI({ model: "gpt-5-mini" }));
|
|
55
|
+
new Agent_js_1.Agent({ client }).withTts(new tts_js_1.MiniMaxTTS({ model: "speech-2.6-turbo", voiceId: "English_captivating_female1" }));
|
|
56
|
+
}
|
|
57
|
+
new Agent_js_1.Agent({ client }).withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
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",
|
|
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",
|
|
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",
|
|
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
|
+
}
|
|
@@ -13,17 +13,24 @@
|
|
|
13
13
|
* 3. TypeScript should show errors for the uncommented invalid sections
|
|
14
14
|
*/
|
|
15
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");
|
|
16
18
|
const Agent_js_1 = require("../Agent.js");
|
|
17
19
|
const avatar_js_1 = require("../vendors/avatar.js");
|
|
18
20
|
const llm_js_1 = require("../vendors/llm.js");
|
|
19
21
|
const stt_js_1 = require("../vendors/stt.js");
|
|
20
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",
|
|
27
|
+
});
|
|
21
28
|
// ============================================
|
|
22
29
|
// ✅ VALID CONFIGURATIONS
|
|
23
30
|
// ============================================
|
|
24
31
|
// Example 1: ElevenLabs 24kHz + HeyGen avatar
|
|
25
32
|
function _validExample1() {
|
|
26
|
-
return new Agent_js_1.Agent({ instructions: "Test" })
|
|
33
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
27
34
|
.withTts(new tts_js_1.ElevenLabsTTS({
|
|
28
35
|
key: "test",
|
|
29
36
|
modelId: "eleven_flash_v2_5",
|
|
@@ -39,7 +46,7 @@ function _validExample1() {
|
|
|
39
46
|
}
|
|
40
47
|
// Example 2: ElevenLabs 16kHz + Akool avatar
|
|
41
48
|
function _validExample2() {
|
|
42
|
-
return new Agent_js_1.Agent({ instructions: "Test" })
|
|
49
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
43
50
|
.withTts(new tts_js_1.ElevenLabsTTS({
|
|
44
51
|
key: "test",
|
|
45
52
|
modelId: "eleven_flash_v2_5",
|
|
@@ -53,7 +60,7 @@ function _validExample2() {
|
|
|
53
60
|
}
|
|
54
61
|
// Example 3: Microsoft 24kHz + HeyGen avatar
|
|
55
62
|
function _validExample3() {
|
|
56
|
-
return new Agent_js_1.Agent({ instructions: "Test" })
|
|
63
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
57
64
|
.withTts(new tts_js_1.MicrosoftTTS({
|
|
58
65
|
key: "test",
|
|
59
66
|
region: "eastus",
|
|
@@ -68,7 +75,7 @@ function _validExample3() {
|
|
|
68
75
|
}
|
|
69
76
|
// Example 4: OpenAI (fixed 24kHz) + HeyGen avatar
|
|
70
77
|
function _validExample4() {
|
|
71
|
-
return new Agent_js_1.Agent({ instructions: "Test" })
|
|
78
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
72
79
|
.withTts(new tts_js_1.OpenAITTS({
|
|
73
80
|
apiKey: "test",
|
|
74
81
|
voice: "alloy",
|
|
@@ -83,7 +90,7 @@ function _validExample4() {
|
|
|
83
90
|
}
|
|
84
91
|
// Example 5: Cartesia 16kHz + Akool avatar
|
|
85
92
|
function _validExample5() {
|
|
86
|
-
return new Agent_js_1.Agent({ instructions: "Test" })
|
|
93
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
87
94
|
.withTts(new tts_js_1.CartesiaTTS({
|
|
88
95
|
apiKey: "test",
|
|
89
96
|
voiceId: "test",
|
|
@@ -131,7 +138,7 @@ new tts_js_1.MiniMaxTTS({
|
|
|
131
138
|
/*
|
|
132
139
|
// @ts-expect-error - HeyGen requires 24kHz, but TTS is configured for 16kHz
|
|
133
140
|
function invalidMismatch1(): Agent<24000> {
|
|
134
|
-
return new Agent({ instructions: "Test" })
|
|
141
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
135
142
|
.withTts(
|
|
136
143
|
new ElevenLabsTTS({
|
|
137
144
|
key: "test",
|
|
@@ -153,7 +160,7 @@ function invalidMismatch1(): Agent<24000> {
|
|
|
153
160
|
/*
|
|
154
161
|
// @ts-expect-error - Akool requires 16kHz, but TTS is configured for 24kHz
|
|
155
162
|
function invalidMismatch2(): Agent<16000> {
|
|
156
|
-
return new Agent({ instructions: "Test" })
|
|
163
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
157
164
|
.withTts(
|
|
158
165
|
new ElevenLabsTTS({
|
|
159
166
|
key: "test",
|
|
@@ -173,7 +180,7 @@ function invalidMismatch2(): Agent<16000> {
|
|
|
173
180
|
/*
|
|
174
181
|
// @ts-expect-error - HeyGen requires 24kHz, not 48kHz
|
|
175
182
|
function invalidMismatch3(): Agent<24000> {
|
|
176
|
-
return new Agent({ instructions: "Test" })
|
|
183
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
177
184
|
.withTts(
|
|
178
185
|
new MicrosoftTTS({
|
|
179
186
|
key: "test",
|
|
@@ -198,7 +205,7 @@ function invalidMismatch3(): Agent<24000> {
|
|
|
198
205
|
/*
|
|
199
206
|
// @ts-expect-error - 25000 is not a valid ElevenLabs sample rate
|
|
200
207
|
function invalidEnum1() {
|
|
201
|
-
return new Agent({ instructions: "Test" }).withTts(
|
|
208
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
202
209
|
new ElevenLabsTTS({
|
|
203
210
|
key: "test",
|
|
204
211
|
modelId: "eleven_flash_v2_5",
|
|
@@ -212,7 +219,7 @@ function invalidEnum1() {
|
|
|
212
219
|
/*
|
|
213
220
|
// @ts-expect-error - 8000 is not a valid Microsoft sample rate
|
|
214
221
|
function invalidEnum2() {
|
|
215
|
-
return new Agent({ instructions: "Test" }).withTts(
|
|
222
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
216
223
|
new MicrosoftTTS({
|
|
217
224
|
key: "test",
|
|
218
225
|
region: "eastus",
|
|
@@ -225,7 +232,7 @@ function invalidEnum2() {
|
|
|
225
232
|
/*
|
|
226
233
|
// @ts-expect-error - 32000 is not a valid Cartesia sample rate
|
|
227
234
|
function invalidEnum3() {
|
|
228
|
-
return new Agent({ instructions: "Test" }).withTts(
|
|
235
|
+
return new Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(
|
|
229
236
|
new CartesiaTTS({
|
|
230
237
|
key: "test",
|
|
231
238
|
voiceId: "test",
|
|
@@ -240,7 +247,7 @@ function invalidEnum3() {
|
|
|
240
247
|
// ============================================
|
|
241
248
|
// Avatar without TTS configured (allowed)
|
|
242
249
|
function _edgeCase1() {
|
|
243
|
-
return new Agent_js_1.Agent({ instructions: "Test" }).withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
250
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withAvatar(new avatar_js_1.LiveAvatarAvatar({
|
|
244
251
|
apiKey: "test",
|
|
245
252
|
quality: "high",
|
|
246
253
|
agoraUid: "12345",
|
|
@@ -248,7 +255,7 @@ function _edgeCase1() {
|
|
|
248
255
|
}
|
|
249
256
|
// TTS without avatar (allowed)
|
|
250
257
|
function _edgeCase2() {
|
|
251
|
-
return new Agent_js_1.Agent({ instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
258
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
252
259
|
key: "test",
|
|
253
260
|
modelId: "eleven_flash_v2_5",
|
|
254
261
|
voiceId: "test",
|
|
@@ -258,7 +265,7 @@ function _edgeCase2() {
|
|
|
258
265
|
}
|
|
259
266
|
// Method chaining preserves type tracking
|
|
260
267
|
function _edgeCase3() {
|
|
261
|
-
return new Agent_js_1.Agent({ instructions: "Test" })
|
|
268
|
+
return new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" })
|
|
262
269
|
.withTts(new tts_js_1.ElevenLabsTTS({
|
|
263
270
|
key: "test",
|
|
264
271
|
modelId: "eleven_flash_v2_5",
|
|
@@ -278,7 +285,7 @@ function _edgeCase3() {
|
|
|
278
285
|
// Type inference verification
|
|
279
286
|
// ============================================
|
|
280
287
|
function _typeInference1() {
|
|
281
|
-
const agentWith24k = new Agent_js_1.Agent({ instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
288
|
+
const agentWith24k = new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
282
289
|
key: "test",
|
|
283
290
|
modelId: "eleven_flash_v2_5",
|
|
284
291
|
voiceId: "test",
|
|
@@ -290,7 +297,7 @@ function _typeInference1() {
|
|
|
290
297
|
return agentWith24k;
|
|
291
298
|
}
|
|
292
299
|
function _typeInference2() {
|
|
293
|
-
const agentWith16k = new Agent_js_1.Agent({ instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
300
|
+
const agentWith16k = new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.ElevenLabsTTS({
|
|
294
301
|
key: "test",
|
|
295
302
|
modelId: "eleven_flash_v2_5",
|
|
296
303
|
voiceId: "test",
|
|
@@ -302,7 +309,7 @@ function _typeInference2() {
|
|
|
302
309
|
return agentWith16k;
|
|
303
310
|
}
|
|
304
311
|
function _typeInference3() {
|
|
305
|
-
const openAIAgent = new Agent_js_1.Agent({ instructions: "Test" }).withTts(new tts_js_1.OpenAITTS({
|
|
312
|
+
const openAIAgent = new Agent_js_1.Agent({ client: TEST_AGENT_CLIENT, instructions: "Test" }).withTts(new tts_js_1.OpenAITTS({
|
|
306
313
|
apiKey: "test",
|
|
307
314
|
voice: "alloy",
|
|
308
315
|
model: "gpt-4o-mini-tts",
|
|
@@ -4,6 +4,7 @@
|
|
|
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.js";
|
|
7
8
|
import type { AvatarConfig as BaseAvatarConfig } from "./types.js";
|
|
8
9
|
/**
|
|
9
10
|
* HeyGen-specific avatar configuration (legacy wire vendor `heygen`).
|
|
@@ -123,11 +124,31 @@ export interface GenericAvatarConfig {
|
|
|
123
124
|
[key: string]: unknown;
|
|
124
125
|
};
|
|
125
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* SenseTime-specific avatar configuration (CN).
|
|
129
|
+
*/
|
|
130
|
+
export interface SensetimeAvatarConfig {
|
|
131
|
+
enable?: boolean;
|
|
132
|
+
vendor: "sensetime";
|
|
133
|
+
params: {
|
|
134
|
+
/** RTC UID for the avatar video publisher (required) */
|
|
135
|
+
agora_uid: string;
|
|
136
|
+
/** Avatar ConvoAI token (filled by AgentKit at session start when omitted) */
|
|
137
|
+
agora_token?: string;
|
|
138
|
+
/** SenseTime application ID (required) */
|
|
139
|
+
appId: string;
|
|
140
|
+
/** SenseTime application key (required) */
|
|
141
|
+
app_key: string;
|
|
142
|
+
/** SenseTime scene configuration list (required) */
|
|
143
|
+
sceneList: SensetimeAvatarParams.SceneList.Item[];
|
|
144
|
+
[key: string]: unknown;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
126
147
|
/**
|
|
127
148
|
* Discriminated union of all avatar configurations.
|
|
128
149
|
* TypeScript will enforce vendor-specific constraints based on the vendor field.
|
|
129
150
|
*/
|
|
130
|
-
export type StrictAvatarConfig = HeyGenAvatarConfig | LiveAvatarAvatarConfig | AkoolAvatarConfig | AnamAvatarConfig | GenericAvatarConfig;
|
|
151
|
+
export type StrictAvatarConfig = HeyGenAvatarConfig | LiveAvatarAvatarConfig | AkoolAvatarConfig | AnamAvatarConfig | GenericAvatarConfig | SensetimeAvatarConfig;
|
|
131
152
|
/**
|
|
132
153
|
* Helper type guard to check if an avatar config uses the legacy HeyGen wire vendor.
|
|
133
154
|
*/
|
|
@@ -148,6 +169,10 @@ export declare function isAnamAvatar(config: StrictAvatarConfig): config is Anam
|
|
|
148
169
|
* Helper type guard to check if an avatar config is for Generic Avatar.
|
|
149
170
|
*/
|
|
150
171
|
export declare function isGenericAvatar(config: StrictAvatarConfig): config is GenericAvatarConfig;
|
|
172
|
+
/**
|
|
173
|
+
* Helper type guard to check if an avatar config is for SenseTime (CN).
|
|
174
|
+
*/
|
|
175
|
+
export declare function isSensetimeAvatar(config: StrictAvatarConfig): config is SensetimeAvatarConfig;
|
|
151
176
|
/**
|
|
152
177
|
* Returns true when AgentKit manages the avatar's RTC publisher identity
|
|
153
178
|
* (i.e. fills `agora_token`, validates uniqueness against the agent UID).
|
|
@@ -161,7 +186,8 @@ export declare function isAvatarTokenManaged(config: StrictAvatarConfig): boolea
|
|
|
161
186
|
* for cases where types are bypassed or data comes from external sources.
|
|
162
187
|
*
|
|
163
188
|
* @param options.requireSessionFields - When true, require fields AgentKit
|
|
164
|
-
* fills during `AgentSession.start()` for Generic avatars
|
|
189
|
+
* fills during `AgentSession.start()` for Generic avatars (`agora_appid`,
|
|
190
|
+
* `agora_channel`, `agora_token`).
|
|
165
191
|
* @throws {Error} If the configuration is invalid
|
|
166
192
|
*/
|
|
167
193
|
export declare function validateAvatarConfig(config: StrictAvatarConfig, options?: {
|
|
@@ -11,6 +11,7 @@ exports.isLiveAvatarAvatar = isLiveAvatarAvatar;
|
|
|
11
11
|
exports.isAkoolAvatar = isAkoolAvatar;
|
|
12
12
|
exports.isAnamAvatar = isAnamAvatar;
|
|
13
13
|
exports.isGenericAvatar = isGenericAvatar;
|
|
14
|
+
exports.isSensetimeAvatar = isSensetimeAvatar;
|
|
14
15
|
exports.isAvatarTokenManaged = isAvatarTokenManaged;
|
|
15
16
|
exports.validateAvatarConfig = validateAvatarConfig;
|
|
16
17
|
exports.validateTtsSampleRate = validateTtsSampleRate;
|
|
@@ -45,6 +46,12 @@ function isAnamAvatar(config) {
|
|
|
45
46
|
function isGenericAvatar(config) {
|
|
46
47
|
return config.vendor === "generic";
|
|
47
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Helper type guard to check if an avatar config is for SenseTime (CN).
|
|
51
|
+
*/
|
|
52
|
+
function isSensetimeAvatar(config) {
|
|
53
|
+
return config.vendor === "sensetime";
|
|
54
|
+
}
|
|
48
55
|
/**
|
|
49
56
|
* Returns true when AgentKit manages the avatar's RTC publisher identity
|
|
50
57
|
* (i.e. fills `agora_token`, validates uniqueness against the agent UID).
|
|
@@ -52,7 +59,7 @@ function isGenericAvatar(config) {
|
|
|
52
59
|
* Mirrors the Go and Python SDK gate so all language SDKs behave identically.
|
|
53
60
|
*/
|
|
54
61
|
function isAvatarTokenManaged(config) {
|
|
55
|
-
return isHeyGenAvatar(config) || isLiveAvatarAvatar(config) || isGenericAvatar(config);
|
|
62
|
+
return isHeyGenAvatar(config) || isLiveAvatarAvatar(config) || isGenericAvatar(config) || isSensetimeAvatar(config);
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
58
65
|
* Validates avatar configuration at runtime.
|
|
@@ -60,7 +67,8 @@ function isAvatarTokenManaged(config) {
|
|
|
60
67
|
* for cases where types are bypassed or data comes from external sources.
|
|
61
68
|
*
|
|
62
69
|
* @param options.requireSessionFields - When true, require fields AgentKit
|
|
63
|
-
* fills during `AgentSession.start()` for Generic avatars
|
|
70
|
+
* fills during `AgentSession.start()` for Generic avatars (`agora_appid`,
|
|
71
|
+
* `agora_channel`, `agora_token`).
|
|
64
72
|
* @throws {Error} If the configuration is invalid
|
|
65
73
|
*/
|
|
66
74
|
function validateAvatarConfig(config, options = {}) {
|
|
@@ -116,6 +124,20 @@ function validateAvatarConfig(config, options = {}) {
|
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
}
|
|
127
|
+
else if (isSensetimeAvatar(config)) {
|
|
128
|
+
if (!config.params.agora_uid) {
|
|
129
|
+
throw new Error("SenseTime avatar requires agora_uid");
|
|
130
|
+
}
|
|
131
|
+
if (!config.params.appId) {
|
|
132
|
+
throw new Error("SenseTime avatar requires appId");
|
|
133
|
+
}
|
|
134
|
+
if (!config.params.app_key) {
|
|
135
|
+
throw new Error("SenseTime avatar requires app_key");
|
|
136
|
+
}
|
|
137
|
+
if (!Array.isArray(config.params.sceneList) || config.params.sceneList.length === 0) {
|
|
138
|
+
throw new Error("SenseTime avatar requires a non-empty sceneList");
|
|
139
|
+
}
|
|
140
|
+
}
|
|
119
141
|
}
|
|
120
142
|
/**
|
|
121
143
|
* Validates that TTS sample rate is compatible with the avatar vendor.
|
|
@@ -23,18 +23,21 @@ export type { AgentOptions } from "./Agent.js";
|
|
|
23
23
|
export { Agent } from "./Agent.js";
|
|
24
24
|
export type { AgentSessionEvent, AgentSessionEventHandler, AgentSessionOptions, } from "./AgentSession.js";
|
|
25
25
|
export { AgentSession } from "./AgentSession.js";
|
|
26
|
-
export type { AkoolAvatarConfig, AnamAvatarConfig, GenericAvatarConfig, HeyGenAvatarConfig, LiveAvatarAvatarConfig, StrictAvatarConfig, } from "./avatar-types.js";
|
|
27
|
-
export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.js";
|
|
26
|
+
export type { AkoolAvatarConfig, AnamAvatarConfig, GenericAvatarConfig, HeyGenAvatarConfig, LiveAvatarAvatarConfig, SensetimeAvatarConfig, StrictAvatarConfig, } from "./avatar-types.js";
|
|
27
|
+
export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.js";
|
|
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.js";
|
|
29
|
-
export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPresetModel, OpenAIPresetModel, OpenAITtsPresetModel, PresetInput, TtsPreset, } from "./presets.js";
|
|
29
|
+
export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPresetModel, OpenAIPresetModel, OpenAITtsPresetModel, PresetCategory, PresetInput, TtsPreset, } from "./presets.js";
|
|
30
30
|
export { AgentPresets, normalizePresetInput } from "./presets.js";
|
|
31
|
+
export type { AvatarVendor, CNAvatarVendor, CNLlmVendor, CNSttVendor, CNTtsVendor, GlobalAvatarVendor, GlobalLlmVendor, GlobalSttVendor, GlobalTtsVendor, LlmVendor, SttVendor, TtsVendor, } from "./region-vendors.js";
|
|
31
32
|
export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.js";
|
|
32
33
|
export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.js";
|
|
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, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GoogleTts, GoogleTtsParams, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmStyle, McpServersItem, MicrosoftTts, MicrosoftTtsParams, MinimaxTts, MinimaxTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTts, MurfTtsParams, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, RimeTts, RimeTtsParams, RtcConfig, SalConfig, SalMode, SarvamTts, SarvamTtsParams, SayOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, } from "./types.js";
|
|
34
35
|
export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LiveAvatarAvatarOptions, } from "./vendors/avatar.js";
|
|
35
36
|
export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.js";
|
|
36
37
|
export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.js";
|
|
37
|
-
export { BaseAvatar, BaseLLM, type BaseLlmOptions, BaseMLLM, BaseSTT, BaseTTS, type GoogleTTSSampleRate, } from "./vendors/base.js";
|
|
38
|
+
export { BaseAvatar, BaseCNAvatar, BaseCNLLM, BaseCNSTT, BaseCNTTS, BaseLLM, type BaseLlmOptions, BaseMLLM, BaseSTT, BaseTTS, type GoogleTTSSampleRate, } from "./vendors/base.js";
|
|
39
|
+
export type { AliyunLLMOptions, BytedanceDuplexTTSOptions, BytedanceLLMOptions, BytedanceTTSOptions, CosyVoiceTTSOptions, DeepSeekLLMOptions, MicrosoftCNSampleRate, MicrosoftCNSTTOptions, MicrosoftCNTTSOptions, MiniMaxCNTTSOptions, SensetimeAvatarOptions, StepFunTTSOptions, TencentLLMOptions, TencentSTTOptions, TencentTTSOptions, XfyunBigModelSTTOptions, XfyunDialectSTTOptions, XfyunSTTOptions, } from "./vendors/cn.js";
|
|
40
|
+
export { AliyunLLM, BytedanceDuplexTTS, BytedanceLLM, BytedanceTTS, CosyVoiceTTS, DeepSeekLLM, FengmingSTT, MicrosoftCNSTT, MicrosoftCNTTS, MiniMaxCNTTS, SensetimeAvatar, StepFunTTS, TencentLLM, TencentSTT, TencentTTS, XfyunBigModelSTT, XfyunDialectSTT, XfyunSTT, } from "./vendors/cn.js";
|
|
38
41
|
export type { AmazonBedrockOptions, AnthropicOptions, AzureOpenAIOptions, CustomLLMOptions, DifyOptions, GeminiOptions, GroqOptions, OpenAIOptions, VertexAILLMOptions, } from "./vendors/llm.js";
|
|
39
42
|
export { AmazonBedrock, Anthropic, AzureOpenAI, CustomLLM, Dify, Gemini, Groq, OpenAI, VertexAILLM, } from "./vendors/llm.js";
|
|
40
43
|
export type { GeminiLiveOptions, OpenAIRealtimeOptions, VertexAIOptions, XaiGrokOptions, } from "./vendors/mllm.js";
|