@xmov/avatar 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/avatar.cjs +1 -2
- package/dist/agent/avatar.modern.js +1 -2
- package/dist/agent/avatar.module.js +1 -2
- package/dist/agent/avatar.umd.js +1 -2
- package/dist/agent/index.cjs +1 -4
- package/dist/agent/index.d.ts +12 -5
- package/dist/agent/index.umd.js +3 -5
- package/dist/agent/types.d.ts +5 -43
- package/dist/index.cjs +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +21 -4
- package/dist/agent/__tests__/agent.test.d.ts +0 -1
- package/dist/agent/audio-debug.d.ts +0 -3
- package/dist/agent/audio-uplink.d.ts +0 -62
- package/dist/agent/avatar.cjs.map +0 -1
- package/dist/agent/avatar.modern.js.map +0 -1
- package/dist/agent/avatar.module.js.map +0 -1
- package/dist/agent/avatar.umd.js.map +0 -1
- package/dist/agent/cdn-entry.d.ts +0 -1
- package/dist/agent/e2e-client.d.ts +0 -32
- package/dist/agent/fixed-audio-track.d.ts +0 -48
- package/dist/agent/microphone.d.ts +0 -49
- package/src/agent/__tests__/agent.test.ts +0 -3787
- package/src/agent/audio-debug.ts +0 -36
- package/src/agent/audio-uplink.ts +0 -392
- package/src/agent/cdn-entry.ts +0 -15
- package/src/agent/e2e-client.ts +0 -215
- package/src/agent/fixed-audio-track.ts +0 -547
- package/src/agent/index.ts +0 -1393
- package/src/agent/microphone.ts +0 -534
- package/src/agent/types.ts +0 -197
package/src/agent/types.ts
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import type { IAvatarOptions, IInitParams, INetworkInfo, RenderState } from "../types";
|
|
2
|
-
|
|
3
|
-
export type AgentState =
|
|
4
|
-
| "idle"
|
|
5
|
-
| "initializing"
|
|
6
|
-
| "ready"
|
|
7
|
-
| "running"
|
|
8
|
-
| "reconnecting"
|
|
9
|
-
| "stopped"
|
|
10
|
-
| "destroyed"
|
|
11
|
-
| "failed";
|
|
12
|
-
export type AgentSocketState = "idle" | "connecting" | "open" | "closed" | "error";
|
|
13
|
-
export type AgentASRState = "idle" | "requesting-permission" | "starting" | "listening" | "stopping" | "failed";
|
|
14
|
-
export type AgentConversationState =
|
|
15
|
-
| "idle"
|
|
16
|
-
| "asking"
|
|
17
|
-
| "speaking-directly"
|
|
18
|
-
| "speaking"
|
|
19
|
-
| "completed"
|
|
20
|
-
| "interrupted"
|
|
21
|
-
| "failed";
|
|
22
|
-
|
|
23
|
-
export type AgentErrorDomain = "permission" | "network" | "asr" | "brain" | "ttsa" | "quota" | "sdk";
|
|
24
|
-
|
|
25
|
-
export interface AgentAudioOptions {
|
|
26
|
-
chunkMs?: number;
|
|
27
|
-
inputEnabled?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated Session 返回 features.speech_frontend.enable_aec 后,以服务端返回值为准。
|
|
30
|
-
*/
|
|
31
|
-
echoCancellationEnabled?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface AgentReconnectOptions {
|
|
35
|
-
enabled?: boolean;
|
|
36
|
-
maxAttempts?: number;
|
|
37
|
-
initialDelayMs?: number;
|
|
38
|
-
maxDelayMs?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface AgentError {
|
|
42
|
-
code: string;
|
|
43
|
-
message: string;
|
|
44
|
-
domain: AgentErrorDomain;
|
|
45
|
-
retryable?: boolean;
|
|
46
|
-
cause?: unknown;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface AgentASRResult {
|
|
50
|
-
text: string;
|
|
51
|
-
isFinal: boolean;
|
|
52
|
-
raw?: unknown;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface AgentASRStartOptions {
|
|
56
|
-
/**
|
|
57
|
-
* Optional caller-owned audio stream used instead of requesting the physical microphone.
|
|
58
|
-
* The Agent clones one live audio track and never stops the caller-owned stream.
|
|
59
|
-
*/
|
|
60
|
-
inputStream?: MediaStream;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface AgentLLMUsage {
|
|
64
|
-
promptTokens: number;
|
|
65
|
-
completionTokens: number;
|
|
66
|
-
totalTokens: number;
|
|
67
|
-
cachedTokens: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface AgentLLMResponse {
|
|
71
|
-
event: "chunk" | "done";
|
|
72
|
-
text?: string;
|
|
73
|
-
isFirst?: boolean;
|
|
74
|
-
usage?: AgentLLMUsage;
|
|
75
|
-
raw?: unknown;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface AgentSemanticJudgeResult {
|
|
79
|
-
query: string;
|
|
80
|
-
meaningful: boolean;
|
|
81
|
-
action: string;
|
|
82
|
-
raw?: unknown;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface AgentSpeakStateEvent {
|
|
86
|
-
state: string;
|
|
87
|
-
clientSpeakId?: string | number;
|
|
88
|
-
raw?: unknown;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface AgentConversationEvent {
|
|
92
|
-
state: AgentConversationState;
|
|
93
|
-
text?: string;
|
|
94
|
-
raw?: unknown;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface XingyunAvatarAgentCallbacks {
|
|
98
|
-
onAgentStateChange?: (state: AgentState) => void;
|
|
99
|
-
onSocketStateChange?: (state: AgentSocketState) => void;
|
|
100
|
-
onASRStateChange?: (state: AgentASRState) => void;
|
|
101
|
-
onASRResult?: (result: AgentASRResult) => void;
|
|
102
|
-
onLLMResponse?: (response: AgentLLMResponse) => void;
|
|
103
|
-
onSpeakStateChange?: (event: AgentSpeakStateEvent) => void;
|
|
104
|
-
onConversationChange?: (event: AgentConversationEvent) => void;
|
|
105
|
-
onSemanticJudgeResult?: (result: AgentSemanticJudgeResult) => void;
|
|
106
|
-
onRenderChange?: (state: RenderState) => void;
|
|
107
|
-
onNetworkInfo?: (info: INetworkInfo) => void;
|
|
108
|
-
onError?: (error: AgentError) => void;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export type AgentServiceConfig = Record<string, unknown>;
|
|
112
|
-
|
|
113
|
-
export interface AgentBrainConfig extends AgentServiceConfig {
|
|
114
|
-
extra_body?: Record<string, unknown>;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface AgentFeatures extends AgentServiceConfig {
|
|
118
|
-
anti_interference?: {
|
|
119
|
-
semantic_judge_enabled?: boolean;
|
|
120
|
-
};
|
|
121
|
-
speech_frontend?: {
|
|
122
|
-
enabled?: boolean;
|
|
123
|
-
enable_aec?: boolean;
|
|
124
|
-
enable_speech_separation?: boolean;
|
|
125
|
-
};
|
|
126
|
-
vad_merge_mode?: boolean;
|
|
127
|
-
volume_and_repetition_text_detection?: boolean;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export interface XingyunAvatarAgentOptions extends IAvatarOptions {
|
|
131
|
-
asr_id?: number;
|
|
132
|
-
asr_config?: AgentServiceConfig;
|
|
133
|
-
tts_config?: AgentServiceConfig;
|
|
134
|
-
features?: AgentFeatures;
|
|
135
|
-
extras?: AgentServiceConfig;
|
|
136
|
-
llm_id?: number;
|
|
137
|
-
brain_config?: AgentBrainConfig;
|
|
138
|
-
session_speak_req_id?: 0 | 1;
|
|
139
|
-
e2eServer?: string;
|
|
140
|
-
authToken?: string;
|
|
141
|
-
audio?: AgentAudioOptions;
|
|
142
|
-
reconnect?: AgentReconnectOptions;
|
|
143
|
-
agentCallbacks?: XingyunAvatarAgentCallbacks;
|
|
144
|
-
webSocketCtor?: typeof WebSocket;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export type XingyunAvatarAgentInitParams = Omit<IInitParams, "onDownloadProgress"> & {
|
|
148
|
-
onDownloadProgress?: IInitParams["onDownloadProgress"];
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export interface AgentSessionInfo {
|
|
152
|
-
ws_url?: string;
|
|
153
|
-
e2e_token?: string;
|
|
154
|
-
monitor_ws_url?: string;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export interface AgentClientMessage {
|
|
158
|
-
type: string;
|
|
159
|
-
message?: unknown;
|
|
160
|
-
[key: string]: unknown;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export interface AgentServerEvent {
|
|
164
|
-
type: string;
|
|
165
|
-
domain?: string;
|
|
166
|
-
code?: string | number;
|
|
167
|
-
event?: string;
|
|
168
|
-
message?: unknown;
|
|
169
|
-
text?: string;
|
|
170
|
-
is_first?: boolean;
|
|
171
|
-
is_final?: boolean;
|
|
172
|
-
usage?: {
|
|
173
|
-
prompt_tokens?: number;
|
|
174
|
-
completion_tokens?: number;
|
|
175
|
-
total_tokens?: number;
|
|
176
|
-
cached_tokens?: number;
|
|
177
|
-
};
|
|
178
|
-
[key: string]: unknown;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export interface AgentAudioMetadata {
|
|
182
|
-
format: "webm_opus";
|
|
183
|
-
mimeType: "audio/webm;codecs=opus";
|
|
184
|
-
/** Fixed output track sample rate passed to the MediaRecorder pipeline. */
|
|
185
|
-
sampleRate: number;
|
|
186
|
-
/** Fixed output track channel count passed to the MediaRecorder pipeline. */
|
|
187
|
-
channels: number;
|
|
188
|
-
chunkMs: number;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export const DEFAULT_AGENT_AUDIO: AgentAudioMetadata = {
|
|
192
|
-
format: "webm_opus",
|
|
193
|
-
mimeType: "audio/webm;codecs=opus",
|
|
194
|
-
sampleRate: 16000,
|
|
195
|
-
channels: 1,
|
|
196
|
-
chunkMs: 100,
|
|
197
|
-
};
|