@streamoji/aitwin 0.5.2 → 0.5.4
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 +64 -0
- package/dist/aitwin.cjs +6 -5
- package/dist/aitwin.js +3152 -2543
- package/dist/index.d.ts +107 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,15 @@ export declare const AI_TWIN_THUMBNAIL_FILENAME = "thumbnail.webp";
|
|
|
6
6
|
|
|
7
7
|
export declare const AiTwin: ForwardRefExoticComponent<AiTwinProps & RefAttributes<AiTwinHandle>>;
|
|
8
8
|
|
|
9
|
+
export declare type AiTwinCaptionsOptions = {
|
|
10
|
+
/** CSS font-family, e.g. "Inter, sans-serif" or "Georgia, serif". */
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
/** CSS font-size, e.g. "1rem" or "18px". Default: clamp for readability. */
|
|
13
|
+
fontSize?: string;
|
|
14
|
+
/** Text color. Default: rgba(255,255,255,0.85). */
|
|
15
|
+
color?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
9
18
|
export declare type AiTwinHandle = {
|
|
10
19
|
speakText: (text: string, options?: AvatarTtsSpeakOptions) => Promise<void>;
|
|
11
20
|
stop: () => void;
|
|
@@ -37,6 +46,11 @@ export declare type AiTwinHandle = {
|
|
|
37
46
|
* Null until a voice session (or TTS playback) has primed audio.
|
|
38
47
|
*/
|
|
39
48
|
getVoiceStream: () => MediaStream | null;
|
|
49
|
+
/** Mute/unmute bot audio output (TTS + voice). */
|
|
50
|
+
setMuted: (muted: boolean) => void;
|
|
51
|
+
isMuted: () => boolean;
|
|
52
|
+
/** Persona / knowledge context id from getAiTwin (for /avatarReply). */
|
|
53
|
+
getPersonaId: () => string | null;
|
|
40
54
|
};
|
|
41
55
|
|
|
42
56
|
export declare class AiTwinNotFoundError extends Error {
|
|
@@ -110,6 +124,8 @@ export declare type AiTwinProps = {
|
|
|
110
124
|
* atlas handling. Omit to use the device limit.
|
|
111
125
|
*/
|
|
112
126
|
pixiMaxTextureSize?: number;
|
|
127
|
+
/** Plain subtitles during TTS/voice playback. */
|
|
128
|
+
captions?: boolean | AiTwinCaptionsOptions;
|
|
113
129
|
};
|
|
114
130
|
|
|
115
131
|
export declare type AiTwinRecord = {
|
|
@@ -135,6 +151,81 @@ export declare type AiTwinRenderVisemeOptions = {
|
|
|
135
151
|
/** Basename for the original portrait stored on CDN (e.g. source.png). */
|
|
136
152
|
export declare function aiTwinSourceFilename(extension?: string): string;
|
|
137
153
|
|
|
154
|
+
/**
|
|
155
|
+
* React embed with optional Talk / Text / mute chrome (`showControls`)
|
|
156
|
+
* and bottom-right overlay (`float`). Same surface as the HTML UMD widget.
|
|
157
|
+
*/
|
|
158
|
+
export declare const AiTwinWidget: ForwardRefExoticComponent<AiTwinWidgetProps & RefAttributes<AiTwinWidgetHandle>>;
|
|
159
|
+
|
|
160
|
+
/** Imperative API shared by React ref and HTML widget handle. */
|
|
161
|
+
export declare type AiTwinWidgetHandle = {
|
|
162
|
+
speakText: (text: string, options?: AvatarTtsSpeakOptions) => Promise<void>;
|
|
163
|
+
connect: (options?: VoiceConnectOptions) => Promise<void>;
|
|
164
|
+
disconnect: () => Promise<void>;
|
|
165
|
+
stop: () => void;
|
|
166
|
+
isReady: () => boolean;
|
|
167
|
+
isConnected: () => boolean;
|
|
168
|
+
getTwin: () => AiTwinHandle | null;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** HTML script-tag handle (React ref plus update/destroy). */
|
|
172
|
+
export declare type AiTwinWidgetHtmlHandle = AiTwinWidgetHandle & {
|
|
173
|
+
destroy: () => void;
|
|
174
|
+
/** Merge options and re-render. */
|
|
175
|
+
update: (options: Partial<AiTwinWidgetProps>) => void;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/** @deprecated Use AiTwinWidgetProps */
|
|
179
|
+
export declare type AiTwinWidgetInitOptions = AiTwinWidgetProps;
|
|
180
|
+
|
|
181
|
+
/** Shared options for HTML `AiTwinWidget.init` and React `<AiTwinWidget />`. */
|
|
182
|
+
export declare type AiTwinWidgetProps = {
|
|
183
|
+
/** Twin id for getAiTwin (e.g. `zoe`). */
|
|
184
|
+
id?: string;
|
|
185
|
+
/** 64-char hex R2 custom-faces id. */
|
|
186
|
+
avatarId?: string;
|
|
187
|
+
/** Alias for avatarId. */
|
|
188
|
+
faceId?: string;
|
|
189
|
+
/** Bearer token for TTS and encrypted assets; omit → SDK dev token. */
|
|
190
|
+
authToken?: string;
|
|
191
|
+
/** Avatar API base. Default: https://ai.aitwin.me */
|
|
192
|
+
apiBase?: string;
|
|
193
|
+
/** TTS voice id override. */
|
|
194
|
+
voiceId?: string;
|
|
195
|
+
/** API speakingRate (default 0.85). */
|
|
196
|
+
speakingRate?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Show built-in Talk / Text / mute controls under the face.
|
|
199
|
+
* Default: false (face-only; host builds its own UI via the handle).
|
|
200
|
+
*/
|
|
201
|
+
showControls?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Pin the widget to the bottom-right of the viewport (fixed overlay).
|
|
204
|
+
* Default: false (inline in the mount target).
|
|
205
|
+
*/
|
|
206
|
+
float?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Persona / knowledge context id for /avatarReply (Text mode).
|
|
209
|
+
* When omitted, uses getAiTwin `knowledgeContextId` if available.
|
|
210
|
+
*/
|
|
211
|
+
personaId?: string;
|
|
212
|
+
onReady?: () => void;
|
|
213
|
+
onStatusChange?: (status: AvatarTtsLipsyncStatus) => void;
|
|
214
|
+
onError?: (message: string) => void;
|
|
215
|
+
onUserTranscript?: (text: string, final: boolean) => void;
|
|
216
|
+
onBotOutput?: (text: string) => void;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export declare type AvatarReply = {
|
|
220
|
+
displayText: string;
|
|
221
|
+
spokenText: string;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export declare type AvatarReplyMessage = {
|
|
225
|
+
role: "user" | "assistant";
|
|
226
|
+
content: string;
|
|
227
|
+
};
|
|
228
|
+
|
|
138
229
|
export declare type AvatarTtsLipsyncController = {
|
|
139
230
|
setDeveloperToken: (token: string) => void;
|
|
140
231
|
setTtsEngineId: (engineId: TtsEngineId) => void;
|
|
@@ -210,6 +301,22 @@ export declare function faceAssetUrls(faceId: string, cdnBase?: string): TwinAss
|
|
|
210
301
|
|
|
211
302
|
export declare function fetchAiTwin(id: string, baseUrl?: string): Promise<AiTwinRecord>;
|
|
212
303
|
|
|
304
|
+
/**
|
|
305
|
+
* POST /avatarReply — LLM reply as displayText + spokenText (SSE).
|
|
306
|
+
* Same contract as aitwin-fe studio / Azure-test avatar_reply.
|
|
307
|
+
*/
|
|
308
|
+
export declare function fetchAvatarReply(options: FetchAvatarReplyOptions): Promise<AvatarReply>;
|
|
309
|
+
|
|
310
|
+
export declare type FetchAvatarReplyOptions = {
|
|
311
|
+
message: string;
|
|
312
|
+
authToken: string;
|
|
313
|
+
apiBase?: string;
|
|
314
|
+
personaId?: string;
|
|
315
|
+
history?: AvatarReplyMessage[];
|
|
316
|
+
/** Called as soon as spokenText arrives on the SSE stream. */
|
|
317
|
+
onSpokenText?: (spokenText: string) => void;
|
|
318
|
+
};
|
|
319
|
+
|
|
213
320
|
/** Bearer token for /avatar_ttsWithPoses and /api/session-value. */
|
|
214
321
|
export declare function fetchDevAuthToken(): Promise<string>;
|
|
215
322
|
|