@unith-ai/core-client 2.0.6 → 2.0.62
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/index.d.ts +516 -84
- package/dist/lib.js +24245 -2
- package/dist/lib.js.map +1 -1
- package/dist/lib.module.js +24229 -2
- package/dist/lib.module.js.map +1 -1
- package/dist/lib.web.js +23970 -27099
- package/dist/lib.web.js.map +1 -1
- package/package.json +12 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/modules/audio.d.ts +0 -18
- package/dist/modules/audio.d.ts.map +0 -1
- package/dist/modules/av.d.ts +0 -23
- package/dist/modules/av.d.ts.map +0 -1
- package/dist/modules/connection.d.ts +0 -21
- package/dist/modules/connection.d.ts.map +0 -1
- package/dist/modules/environment.d.ts +0 -4
- package/dist/modules/environment.d.ts.map +0 -1
- package/dist/modules/event.d.ts +0 -3
- package/dist/modules/event.d.ts.map +0 -1
- package/dist/modules/idle-video.d.ts +0 -9
- package/dist/modules/idle-video.d.ts.map +0 -1
- package/dist/modules/microphone.d.ts +0 -46
- package/dist/modules/microphone.d.ts.map +0 -1
- package/dist/modules/monitor.d.ts +0 -33
- package/dist/modules/monitor.d.ts.map +0 -1
- package/dist/modules/sync.d.ts +0 -15
- package/dist/modules/sync.d.ts.map +0 -1
- package/dist/modules/user.d.ts +0 -28
- package/dist/modules/user.d.ts.map +0 -1
- package/dist/modules/video.d.ts +0 -64
- package/dist/modules/video.d.ts.map +0 -1
- package/dist/modules/vp8.d.ts +0 -40
- package/dist/modules/vp8.d.ts.map +0 -1
- package/dist/types/Conversation.d.ts +0 -70
- package/dist/types/Conversation.d.ts.map +0 -1
- package/dist/types/User.d.ts +0 -44
- package/dist/types/User.d.ts.map +0 -1
- package/dist/types/audio.d.ts +0 -17
- package/dist/types/audio.d.ts.map +0 -1
- package/dist/types/chat.d.ts +0 -29
- package/dist/types/chat.d.ts.map +0 -1
- package/dist/types/connection.d.ts +0 -14
- package/dist/types/connection.d.ts.map +0 -1
- package/dist/types/environment.d.ts +0 -2
- package/dist/types/environment.d.ts.map +0 -1
- package/dist/types/event.d.ts +0 -144
- package/dist/types/event.d.ts.map +0 -1
- package/dist/types/idle-video.d.ts +0 -8
- package/dist/types/idle-video.d.ts.map +0 -1
- package/dist/types/microphone.d.ts +0 -30
- package/dist/types/microphone.d.ts.map +0 -1
- package/dist/types/sync.d.ts +0 -24
- package/dist/types/sync.d.ts.map +0 -1
- package/dist/types/vp8.d.ts +0 -49
- package/dist/types/vp8.d.ts.map +0 -1
- package/dist/utils/audio.d.ts +0 -9
- package/dist/utils/audio.d.ts.map +0 -1
- package/dist/utils/microphone.d.ts +0 -16
- package/dist/utils/microphone.d.ts.map +0 -1
- package/dist/utils/storage.d.ts +0 -5
- package/dist/utils/storage.d.ts.map +0 -1
- package/dist/utils/sync.d.ts +0 -3
- package/dist/utils/sync.d.ts.map +0 -1
- package/dist/utils/worklet-loader.d.ts +0 -2
- package/dist/utils/worklet-loader.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,89 +1,521 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type AudioFormatConfig = {
|
|
4
|
+
sampleRate: number;
|
|
5
|
+
format: "pcm" | "wav" | "ulaw";
|
|
6
|
+
};
|
|
7
|
+
declare class AudioOutput {
|
|
8
|
+
readonly context: AudioContext;
|
|
9
|
+
readonly analyser: AnalyserNode;
|
|
10
|
+
readonly gain: GainNode;
|
|
11
|
+
readonly worklet: AudioWorkletNode;
|
|
12
|
+
private _isMuted;
|
|
13
|
+
static createAudioOutput({ sampleRate, format, }: AudioFormatConfig): Promise<AudioOutput>;
|
|
14
|
+
private ensureIOSCompatibility;
|
|
15
|
+
private constructor();
|
|
16
|
+
getOutputDevice(): Promise<MediaDeviceInfo | null>;
|
|
17
|
+
getAvailableOutputDevices(): Promise<MediaDeviceInfo[]>;
|
|
18
|
+
mute(): void;
|
|
19
|
+
unmute(): void;
|
|
20
|
+
toggleMute(): boolean;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export type Environment = "production" | "staging" | "development";
|
|
24
|
+
export declare enum EventType {
|
|
25
|
+
TEXT = "text",
|
|
26
|
+
CONVERSATION_END = "conversation_end",
|
|
27
|
+
JOIN = "join",
|
|
28
|
+
ERROR = "error",
|
|
29
|
+
TIME_OUT = "timeout",
|
|
30
|
+
UNITH_NLP_EXCEPTION = "unith_nlp_exception",
|
|
31
|
+
ANALYTICS = "analytics-userFeedback",
|
|
32
|
+
CHOICE = "choice",
|
|
33
|
+
TIMEOUT_WARNING = "timeout_warning",
|
|
34
|
+
KEEP_SESSION = "keep_session",
|
|
35
|
+
RESPONSE = "response",
|
|
36
|
+
STREAMING = "streaming",
|
|
37
|
+
PING = "ping",
|
|
38
|
+
PONG = "pong",
|
|
39
|
+
BINARY = "binary",
|
|
40
|
+
STOP = "stop"
|
|
41
|
+
}
|
|
42
|
+
export declare enum StreamingEventType {
|
|
43
|
+
VIDEO_FRAME = "video_frame",
|
|
44
|
+
AUDIO_FRAME = "audio_frame",
|
|
45
|
+
METADATA = "metadata",
|
|
46
|
+
ERROR = "error",
|
|
47
|
+
CACHE = "cache",
|
|
48
|
+
STOP = "stop"
|
|
49
|
+
}
|
|
50
|
+
export interface Message {
|
|
51
|
+
id: number;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
speaker: string;
|
|
54
|
+
text: string;
|
|
55
|
+
isSent: boolean;
|
|
56
|
+
user_id: string;
|
|
57
|
+
username?: string;
|
|
58
|
+
event: EventType.TEXT | EventType.KEEP_SESSION | EventType.STOP;
|
|
59
|
+
session_id?: string;
|
|
60
|
+
visible: boolean;
|
|
61
|
+
}
|
|
62
|
+
export type JoinEventData = {
|
|
63
|
+
granted: boolean;
|
|
64
|
+
};
|
|
65
|
+
export type GlobalEventData = {
|
|
66
|
+
event: EventType;
|
|
67
|
+
user_id: string;
|
|
68
|
+
username: string;
|
|
69
|
+
type?: string;
|
|
70
|
+
};
|
|
71
|
+
export type BinaryEventData = {
|
|
72
|
+
data: ArrayBuffer;
|
|
73
|
+
};
|
|
74
|
+
export type SpeakerType = "user" | "ai";
|
|
75
|
+
export type TextEventData = {
|
|
76
|
+
id: string;
|
|
77
|
+
timestamp: Date;
|
|
78
|
+
speaker: SpeakerType;
|
|
79
|
+
text: string;
|
|
80
|
+
isSent: boolean;
|
|
81
|
+
session_id: string;
|
|
82
|
+
visible: boolean;
|
|
83
|
+
is_last?: boolean;
|
|
84
|
+
part_order?: number;
|
|
85
|
+
input_message_id?: string;
|
|
86
|
+
suggestions: string[];
|
|
87
|
+
has_error?: boolean;
|
|
88
|
+
error_code?: number;
|
|
89
|
+
error_message?: string;
|
|
90
|
+
media?: string[];
|
|
91
|
+
video?: string;
|
|
92
|
+
stream_id?: string;
|
|
93
|
+
};
|
|
94
|
+
export type ConversationEndEventData = {
|
|
95
|
+
reason: string;
|
|
96
|
+
duration: number;
|
|
97
|
+
};
|
|
98
|
+
export type TimeoutEventData = {
|
|
99
|
+
remaining_time: number;
|
|
100
|
+
};
|
|
101
|
+
export type AnalyticsEventData = {
|
|
102
|
+
feedback_type: string;
|
|
103
|
+
rating: number;
|
|
104
|
+
comment?: string;
|
|
105
|
+
};
|
|
106
|
+
export type ChoiceEventData = {
|
|
107
|
+
choices: string[];
|
|
108
|
+
selected_choice?: string;
|
|
109
|
+
};
|
|
110
|
+
export type StreamingEventData = {
|
|
111
|
+
message?: string;
|
|
112
|
+
metadata_type?: string;
|
|
113
|
+
session_id?: string;
|
|
114
|
+
suggestions: string[];
|
|
115
|
+
event_timestamp_ms: number;
|
|
116
|
+
type: StreamingEventType;
|
|
117
|
+
video_url?: string;
|
|
118
|
+
text?: string;
|
|
119
|
+
error_type?: "resource_exhausted" | "deadline_exceeded" | "inactivity_timeout" | "canceled";
|
|
120
|
+
format?: "jpeg" | "wav";
|
|
121
|
+
frame_data?: string;
|
|
122
|
+
height?: number;
|
|
123
|
+
width?: string;
|
|
124
|
+
sample_rate?: string;
|
|
125
|
+
duration_ms?: number;
|
|
126
|
+
is_keyframe?: boolean;
|
|
127
|
+
};
|
|
128
|
+
export type PingEventData = {
|
|
129
|
+
event: EventType.PING;
|
|
130
|
+
timestamp: string;
|
|
131
|
+
id: string;
|
|
132
|
+
};
|
|
133
|
+
export type PongEventData = {
|
|
134
|
+
type: EventType.PONG;
|
|
135
|
+
timestamp: string;
|
|
136
|
+
id: string;
|
|
137
|
+
};
|
|
138
|
+
export type MessageEventData = {
|
|
139
|
+
timestamp: Date;
|
|
140
|
+
sender: SpeakerType;
|
|
141
|
+
text: string;
|
|
142
|
+
visible: boolean;
|
|
143
|
+
};
|
|
144
|
+
export type IncomingSocketEvent<T extends EventType = EventType> = T extends EventType.BINARY ? GlobalEventData & BinaryEventData : T extends EventType.JOIN ? GlobalEventData & JoinEventData : T extends EventType.TEXT ? GlobalEventData & TextEventData : T extends EventType.RESPONSE ? GlobalEventData & TextEventData : T extends EventType.CONVERSATION_END ? GlobalEventData & ConversationEndEventData : T extends EventType.STREAMING ? GlobalEventData & StreamingEventData : T extends EventType.TIME_OUT ? GlobalEventData & TimeoutEventData : T extends EventType.TIMEOUT_WARNING ? GlobalEventData & TimeoutEventData : T extends EventType.KEEP_SESSION ? GlobalEventData & JoinEventData : T extends EventType.ANALYTICS ? GlobalEventData & AnalyticsEventData : T extends EventType.PING ? GlobalEventData & PingEventData : T extends EventType.PONG ? GlobalEventData & PongEventData : T extends EventType.CHOICE ? GlobalEventData & ChoiceEventData : GlobalEventData;
|
|
145
|
+
export type AnyIncomingSocketEvent = IncomingSocketEvent<EventType.JOIN> | IncomingSocketEvent<EventType.TEXT> | IncomingSocketEvent<EventType.RESPONSE> | IncomingSocketEvent<EventType.STREAMING> | IncomingSocketEvent<EventType.BINARY> | IncomingSocketEvent<EventType.CONVERSATION_END> | IncomingSocketEvent<EventType.TIME_OUT> | IncomingSocketEvent<EventType.TIMEOUT_WARNING> | IncomingSocketEvent<EventType.KEEP_SESSION> | IncomingSocketEvent<EventType.ANALYTICS> | IncomingSocketEvent<EventType.CHOICE> | IncomingSocketEvent<EventType.PING> | IncomingSocketEvent<EventType.PONG> | (GlobalEventData & {
|
|
146
|
+
event: Exclude<EventType, EventType.JOIN | EventType.TEXT | EventType.CONVERSATION_END | EventType.TIME_OUT | EventType.TIMEOUT_WARNING | EventType.ANALYTICS | EventType.CHOICE | EventType.RESPONSE | EventType.STREAMING | EventType.PING | EventType.KEEP_SESSION | EventType.BINARY>;
|
|
147
|
+
});
|
|
148
|
+
export type DisconnectionDetails = {
|
|
149
|
+
reason: "error" | "user";
|
|
150
|
+
message?: string;
|
|
151
|
+
context?: Event;
|
|
152
|
+
};
|
|
153
|
+
export type OnDisconnectCallback = (details: DisconnectionDetails) => void;
|
|
154
|
+
export type OnMessageCallback = (event: AnyIncomingSocketEvent) => void;
|
|
155
|
+
export type OnPingPongCallback = (event: PongEventData) => void;
|
|
156
|
+
export declare function isJoinEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.JOIN>;
|
|
157
|
+
export declare function isTextEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.TEXT>;
|
|
158
|
+
export declare function isResponseEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.RESPONSE>;
|
|
159
|
+
export declare function isStreamingEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.STREAMING>;
|
|
160
|
+
export declare function isStreamingErrorEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.STREAMING>;
|
|
161
|
+
export declare function isBinaryEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.BINARY>;
|
|
162
|
+
export declare function isConversationEndEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.CONVERSATION_END>;
|
|
163
|
+
export declare function isPongEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.PONG>;
|
|
164
|
+
export declare function isTimeoutWarningEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.TIMEOUT_WARNING>;
|
|
165
|
+
export declare function isTimeoutEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.TIME_OUT>;
|
|
166
|
+
export declare function isKeepSessionEvent(event: AnyIncomingSocketEvent): event is IncomingSocketEvent<EventType.KEEP_SESSION>;
|
|
167
|
+
export type MicrophoneEvents = {
|
|
168
|
+
onMicrophoneError: (prop: {
|
|
169
|
+
message: string;
|
|
170
|
+
}) => void;
|
|
171
|
+
onMicrophoneStatusChange: (prop: {
|
|
172
|
+
status: "ON" | "OFF" | "PROCESSING";
|
|
173
|
+
}) => void;
|
|
174
|
+
onMicrophoneSpeechRecognitionResult: (prop: {
|
|
175
|
+
transcript: string;
|
|
176
|
+
}) => void;
|
|
177
|
+
onMicrophonePartialSpeechRecognitionResult: (prop: {
|
|
178
|
+
transcript: string;
|
|
179
|
+
}) => void;
|
|
180
|
+
};
|
|
181
|
+
export type MicrophoneProvider = "azure" | "custom" | "eleven_labs";
|
|
182
|
+
export type MicrophoneStatus = "ON" | "OFF" | "PROCESSING";
|
|
183
|
+
export type ElevenLabsOptions = {
|
|
184
|
+
noiseSuppression: boolean;
|
|
185
|
+
vadSilenceThresholdSecs: number;
|
|
186
|
+
vadThreshold: number;
|
|
187
|
+
minSpeechDurationMs: number;
|
|
188
|
+
minSilenceDurationMs: number;
|
|
189
|
+
disableDynamicSpeechRecognition?: boolean;
|
|
190
|
+
};
|
|
191
|
+
export type MicTokenResponseType = {
|
|
192
|
+
token: string;
|
|
193
|
+
region: string;
|
|
194
|
+
generatedAt: number | null;
|
|
195
|
+
};
|
|
196
|
+
export type ApiErrorType = {
|
|
197
|
+
response?: {
|
|
198
|
+
data?: {
|
|
199
|
+
detail?: string;
|
|
200
|
+
};
|
|
201
|
+
status_code?: number;
|
|
202
|
+
status?: number;
|
|
203
|
+
};
|
|
204
|
+
name?: string;
|
|
205
|
+
};
|
|
206
|
+
export type TokenResponseType = {
|
|
207
|
+
access_token: string;
|
|
208
|
+
user_id: string;
|
|
209
|
+
token_type: string;
|
|
210
|
+
};
|
|
211
|
+
export type HeadType = {
|
|
212
|
+
alias: string;
|
|
213
|
+
icon_config: undefined;
|
|
214
|
+
lang_speech_recognition: string;
|
|
215
|
+
language: Language;
|
|
216
|
+
name: string;
|
|
217
|
+
operation_mode: "ttt" | "oc" | "doc_qa";
|
|
218
|
+
phrases: string[];
|
|
219
|
+
streaming_enabled: boolean;
|
|
220
|
+
allowed_iframe_origins: string[];
|
|
221
|
+
avatarSrc?: string;
|
|
222
|
+
};
|
|
223
|
+
export type ConnectHeadType = {
|
|
224
|
+
name: string;
|
|
225
|
+
phrases: string[];
|
|
226
|
+
language: Language;
|
|
227
|
+
avatar?: string;
|
|
228
|
+
};
|
|
229
|
+
export type AuthTokenType = {
|
|
230
|
+
exp: number;
|
|
231
|
+
username: string;
|
|
232
|
+
admin: boolean;
|
|
233
|
+
};
|
|
234
|
+
export type ApiAsrTokenType = {
|
|
235
|
+
token: string;
|
|
236
|
+
region: string;
|
|
237
|
+
};
|
|
238
|
+
export declare enum VideoTransitionType {
|
|
239
|
+
NONE = "none",
|
|
240
|
+
CROSSFADE = "crossfade",
|
|
241
|
+
FADEIN = "fadein",
|
|
242
|
+
FADEOUT = "fadeout"
|
|
243
|
+
}
|
|
244
|
+
export interface VideoFormatConfig {
|
|
245
|
+
width: number;
|
|
246
|
+
height: number;
|
|
247
|
+
frameRate: number;
|
|
248
|
+
format: "jpeg" | "webp" | "png";
|
|
249
|
+
backgroundColor?: string;
|
|
250
|
+
antialias?: boolean;
|
|
251
|
+
resolution?: number;
|
|
252
|
+
maxBufferSize?: number;
|
|
253
|
+
enableAdaptiveQuality?: boolean;
|
|
254
|
+
}
|
|
255
|
+
export type Language = "ar-AE" | "bg-BG" | "bs-BA" | "cs-CZ" | "de-DE" | "en-US" | "es-ES" | "fr-FR" | "hu-HU" | "id-ID" | "it-IT" | "ka-GE" | "kk-KZ" | "lt-LT" | "lv-LV" | "nl-NL" | "pl-PL" | "pt-PT" | "ro-RO" | "ru-RU" | "sk-SK" | "sr-RS" | "th-TH" | "uk-UA";
|
|
256
|
+
export type Status = "connecting" | "connected" | "disconnecting" | "disconnected";
|
|
257
|
+
export type DigitalHumanOptions = {
|
|
258
|
+
username: string;
|
|
259
|
+
apiKey: string;
|
|
260
|
+
environment: Environment;
|
|
261
|
+
mode: ConversationMode;
|
|
262
|
+
language?: Language;
|
|
263
|
+
allowWakeLock?: boolean;
|
|
264
|
+
fadeTransitionsType?: VideoTransitionType;
|
|
265
|
+
voiceInterruptions?: boolean;
|
|
266
|
+
};
|
|
267
|
+
export type HeadOptions = {
|
|
268
|
+
orgId: string;
|
|
269
|
+
headId: string;
|
|
270
|
+
};
|
|
271
|
+
export type VideoHtmlElement = {
|
|
272
|
+
element: HTMLElement;
|
|
273
|
+
};
|
|
274
|
+
export type KeepSessionEventData = {
|
|
275
|
+
granted: boolean;
|
|
276
|
+
};
|
|
277
|
+
export type ConversationOptions = DigitalHumanOptions & HeadOptions;
|
|
278
|
+
export type MicrophoneType = {
|
|
279
|
+
microphoneProvider: MicrophoneProvider;
|
|
280
|
+
microphoneOptions: MicrophoneEvents;
|
|
281
|
+
elevenLabsOptions?: ElevenLabsOptions;
|
|
282
|
+
};
|
|
283
|
+
export type ConversationEvents = {
|
|
284
|
+
onStatusChange: (prop: {
|
|
285
|
+
status: Status;
|
|
286
|
+
}) => void;
|
|
287
|
+
onConnect: (prop: {
|
|
288
|
+
userId: string;
|
|
289
|
+
headInfo: ConnectHeadType;
|
|
290
|
+
microphoneAccess: boolean;
|
|
291
|
+
}) => void;
|
|
292
|
+
onDisconnect: OnDisconnectCallback;
|
|
293
|
+
onMessage: (prop: MessageEventData) => void;
|
|
294
|
+
onSuggestions: (prop: {
|
|
295
|
+
suggestions: string[];
|
|
296
|
+
}) => void;
|
|
297
|
+
onTimeoutWarning: () => void;
|
|
298
|
+
onTimeout: () => void;
|
|
299
|
+
onMuteStatusChange: (prop: {
|
|
300
|
+
isMuted: boolean;
|
|
301
|
+
}) => void;
|
|
302
|
+
onSpeakingStart: () => void;
|
|
303
|
+
onSpeakingEnd: () => void;
|
|
304
|
+
onStoppingEnd: () => void;
|
|
305
|
+
onStoppingStart: () => void;
|
|
306
|
+
onKeepSession: (prop: KeepSessionEventData) => void;
|
|
307
|
+
onError: (prop: {
|
|
308
|
+
message: string;
|
|
309
|
+
endConversation: boolean;
|
|
310
|
+
type: "toast" | "modal" | "silent";
|
|
311
|
+
}) => void;
|
|
312
|
+
onHighDemand: () => void;
|
|
313
|
+
};
|
|
314
|
+
export type ConversationMode = "chat" | "audio" | "video" | "default";
|
|
315
|
+
export type Role = "user" | "ai";
|
|
316
|
+
export type Mode = "speaking" | "listening" | "thinking" | "stopping";
|
|
317
|
+
export type StreamingType = "jpg" | "vp8";
|
|
318
|
+
export type QualityType = "low" | "standard" | "high" | "premium";
|
|
319
|
+
export type WebsocketConnectionConfig = {
|
|
320
|
+
environment: Environment;
|
|
321
|
+
orgId: string;
|
|
322
|
+
headId: string;
|
|
323
|
+
token: string;
|
|
324
|
+
apiKey: string;
|
|
325
|
+
mode: ConversationMode;
|
|
326
|
+
language: Language;
|
|
327
|
+
onJoin?: () => void;
|
|
328
|
+
onError?: (error: string) => void;
|
|
329
|
+
};
|
|
330
|
+
declare class Connection {
|
|
331
|
+
readonly socket: WebSocket;
|
|
332
|
+
readonly userId: string;
|
|
333
|
+
static create(config: WebsocketConnectionConfig): Promise<Connection>;
|
|
334
|
+
private queue;
|
|
335
|
+
private disconnectionDetails;
|
|
336
|
+
private onDisconnectCallback;
|
|
337
|
+
private onMessageCallback;
|
|
338
|
+
private onPingPongCallback;
|
|
339
|
+
private constructor();
|
|
340
|
+
private disconnect;
|
|
341
|
+
close(): void;
|
|
342
|
+
sendMessage(message: Message): void;
|
|
343
|
+
sendPingEvent(message: PingEventData): void;
|
|
344
|
+
onPingPong(callback: OnPingPongCallback): void;
|
|
345
|
+
onMessage(callback: OnMessageCallback): void;
|
|
346
|
+
onDisconnect(callback: OnDisconnectCallback): void;
|
|
347
|
+
}
|
|
348
|
+
declare class IdleVideo {
|
|
349
|
+
readonly idleVideoSource: string;
|
|
350
|
+
readonly videoId: string;
|
|
351
|
+
constructor(idleVideoSource: string, videoId: string);
|
|
352
|
+
static getIdleVideo(apiUrl: string, orgId: string, headId: string): Promise<IdleVideo>;
|
|
353
|
+
getAvatarSrc(apiUrl: string, orgId: string, headId: string): Promise<string>;
|
|
354
|
+
private static getIdleVideoId;
|
|
355
|
+
}
|
|
356
|
+
declare class User {
|
|
357
|
+
readonly id: string;
|
|
358
|
+
username: string;
|
|
359
|
+
readonly password: string;
|
|
360
|
+
readonly orgId: string;
|
|
361
|
+
readonly headId: string;
|
|
362
|
+
readonly apiBase: string;
|
|
363
|
+
static loginUser(username: string, password: string, apiUrl: string, orgId: string, headId: string): Promise<User>;
|
|
364
|
+
private EXPIRATION_OFFSET;
|
|
365
|
+
accessToken: string;
|
|
366
|
+
tokenType: string;
|
|
367
|
+
sessionId: number;
|
|
368
|
+
private constructor();
|
|
369
|
+
getHeadDetails(apiKey: string): Promise<HeadType>;
|
|
370
|
+
getAuthToken(username: string, password: string): Promise<TokenResponseType>;
|
|
371
|
+
getProviderToken(auth_jwt: string, provider: "elevenlabs" | "azure"): Promise<ApiAsrTokenType>;
|
|
372
|
+
getAccessToken(): Promise<{
|
|
373
|
+
access_token: string;
|
|
374
|
+
user_id: string | null | undefined;
|
|
375
|
+
session_id: number;
|
|
376
|
+
}>;
|
|
377
|
+
getAsrToken(provider: "elevenlabs" | "azure"): Promise<{
|
|
378
|
+
token: string;
|
|
379
|
+
region: string;
|
|
380
|
+
}>;
|
|
381
|
+
}
|
|
382
|
+
export type IdleVideoConfig = {
|
|
383
|
+
src: string;
|
|
384
|
+
enabled: boolean;
|
|
385
|
+
};
|
|
386
|
+
export interface VideoEffectConfig {
|
|
387
|
+
background?: BackgroundConfig;
|
|
388
|
+
}
|
|
389
|
+
export interface BackgroundConfig {
|
|
390
|
+
type: "color" | "image";
|
|
391
|
+
value: number | string;
|
|
392
|
+
}
|
|
393
|
+
declare class VideoOutput {
|
|
394
|
+
private videoOutput;
|
|
395
|
+
private container;
|
|
396
|
+
private idleVideo;
|
|
397
|
+
private cachedVideo;
|
|
398
|
+
private idleVideoConfig;
|
|
399
|
+
private videoTransitionConfig;
|
|
400
|
+
private readonly CROSSFADE_DURATION;
|
|
401
|
+
private isTransitioning;
|
|
402
|
+
private isShowingIdleVideo;
|
|
403
|
+
private bufferCheckAnimationId;
|
|
404
|
+
private lastBufferCheckTime;
|
|
405
|
+
private sessionStarted;
|
|
406
|
+
private isRestoringIdleVideo;
|
|
407
|
+
private isShowingCachedVideo;
|
|
408
|
+
private onIdleVideoShown?;
|
|
409
|
+
private onIdleVideoHidden?;
|
|
410
|
+
private onSpeakingStartCallback;
|
|
411
|
+
private onSpeakingEndCallback;
|
|
412
|
+
static createVideoOutput(container: HTMLElement, config: VideoFormatConfig & {
|
|
413
|
+
effects?: VideoEffectConfig;
|
|
414
|
+
idleVideo: IdleVideoConfig;
|
|
415
|
+
transition: VideoTransitionType;
|
|
416
|
+
}): Promise<VideoOutput>;
|
|
417
|
+
private constructor();
|
|
418
|
+
private setupIdleVideo;
|
|
419
|
+
private setupCachedVideo;
|
|
420
|
+
onSpeakingStart(speakingStartCallback: () => void): void;
|
|
421
|
+
onSpeakingEnd(speakingEndCallback: () => void): void;
|
|
422
|
+
startStreaming(init?: boolean): void;
|
|
423
|
+
stopBufferMonitoring(): void;
|
|
424
|
+
getBufferLength(): number;
|
|
425
|
+
startBufferMonitoring(): void;
|
|
426
|
+
toggleCacheVideoMute(): void;
|
|
427
|
+
playCachedVideo(cachedVideoUrl: string): Promise<void>;
|
|
428
|
+
stopCachedVideo(): Promise<void>;
|
|
429
|
+
private crossfadeFromIdleToCached;
|
|
430
|
+
private crossfadeFromCachedToIdle;
|
|
431
|
+
private cleanupCachedVideo;
|
|
432
|
+
private hideIdleVideo;
|
|
433
|
+
private hideIdleVideoBeforeStream;
|
|
434
|
+
setEventCallbacks(callbacks: {
|
|
435
|
+
onIdleVideoShown?: () => void;
|
|
436
|
+
onIdleVideoHidden?: () => void;
|
|
437
|
+
}): void;
|
|
438
|
+
getStreamingStatus(): boolean;
|
|
439
|
+
isPlayingCachedVideo(): boolean;
|
|
440
|
+
showIdleVideo(): Promise<void>;
|
|
441
|
+
showIdleVideoAfterStream(): Promise<void>;
|
|
442
|
+
addFrame(frameData: Blob | ArrayBuffer, timeStamp: number, isKeyframe?: boolean): Promise<void>;
|
|
443
|
+
clearFrame(): void;
|
|
444
|
+
toggleStream(status: boolean): Promise<void>;
|
|
445
|
+
destroy(): void;
|
|
446
|
+
}
|
|
447
|
+
export declare const defaultElevenLabsOptions: ElevenLabsOptions;
|
|
17
448
|
export type Options = ConversationOptions & ConversationEvents & MicrophoneType;
|
|
18
449
|
export type HeadConfigOptions = HeadOptions & Partial<DigitalHumanOptions>;
|
|
19
450
|
export type PartialOptions = HeadConfigOptions & Partial<MicrophoneType> & VideoHtmlElement & Partial<ConversationEvents>;
|
|
20
451
|
export declare class Conversation {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
452
|
+
private options;
|
|
453
|
+
private microphoneAccess;
|
|
454
|
+
private connection;
|
|
455
|
+
private idleVideo;
|
|
456
|
+
private wakeLock;
|
|
457
|
+
private user;
|
|
458
|
+
private audioOutput;
|
|
459
|
+
private videoOutput;
|
|
460
|
+
private headInfo;
|
|
461
|
+
private status;
|
|
462
|
+
protected volume: number;
|
|
463
|
+
private sessionStarted;
|
|
464
|
+
private isStoppingLastResponse;
|
|
465
|
+
private messageCounter;
|
|
466
|
+
private syncController;
|
|
467
|
+
private avController;
|
|
468
|
+
private monitor;
|
|
469
|
+
private microphone;
|
|
470
|
+
private videoFrameQueue;
|
|
471
|
+
private cachedResponseQueue;
|
|
472
|
+
private suggestionsQueue;
|
|
473
|
+
private static getFullOptions;
|
|
474
|
+
/**
|
|
475
|
+
* Starts a digital human conversation.
|
|
476
|
+
* @param options - The options for the conversation.
|
|
477
|
+
* @returns A promise that resolves to a Conversation instance.
|
|
478
|
+
*/
|
|
479
|
+
static startDigitalHuman(options: PartialOptions): Promise<Conversation>;
|
|
480
|
+
/**
|
|
481
|
+
* This retrieves the background video to use for widget mode & welcome screen
|
|
482
|
+
* @param options PartialOptions
|
|
483
|
+
* @returns Video link to use as widget background
|
|
484
|
+
*/
|
|
485
|
+
static getBackgroundVideo(options: {
|
|
486
|
+
orgId: string;
|
|
487
|
+
headId: string;
|
|
488
|
+
environment?: Environment;
|
|
489
|
+
}): Promise<string>;
|
|
490
|
+
constructor(options: Options, microphoneAccess: boolean, connection: Connection, idleVideo: IdleVideo, wakeLock: WakeLockSentinel | null, user: User, audioOutput: AudioOutput, videoOutput: VideoOutput, headInfo: HeadType);
|
|
491
|
+
private startLatencyMonitoring;
|
|
492
|
+
private handleIOSSilentMode;
|
|
493
|
+
private onOutputWorkletMessage;
|
|
494
|
+
private handleMessage;
|
|
495
|
+
private handleStreamError;
|
|
496
|
+
private handleStreamingEvent;
|
|
497
|
+
private handleVideoFrame;
|
|
498
|
+
private handleBinaryData;
|
|
499
|
+
private handleAudioFrame;
|
|
500
|
+
private onMessage;
|
|
501
|
+
private handleStopVideoEvents;
|
|
502
|
+
private endSessionWithDetails;
|
|
503
|
+
getUserId(): string;
|
|
504
|
+
private handleEndSession;
|
|
505
|
+
private updateStatus;
|
|
506
|
+
/**
|
|
507
|
+
* To stop streaming response, we'll send a stop message to the BE. The BE will then stop sending audio and video frames, which will naturally end the response. This is more efficient and leads to a better user experience as it allows for a smoother transition when stopping the response.
|
|
508
|
+
*
|
|
509
|
+
* To stop cached response, we just stop the video and fade to idle.
|
|
510
|
+
*/
|
|
511
|
+
stopResponse(): Promise<void>;
|
|
512
|
+
toggleMute(): Promise<number>;
|
|
513
|
+
startSession(): Promise<Connection>;
|
|
514
|
+
toggleMicrophone(): Promise<void>;
|
|
515
|
+
getMicrophoneStatus(): MicrophoneStatus;
|
|
516
|
+
endSession(): Promise<void>;
|
|
517
|
+
sendMessage(text: string): void;
|
|
518
|
+
keepSession(): void;
|
|
88
519
|
}
|
|
89
|
-
|
|
520
|
+
|
|
521
|
+
export {};
|