@streamoji/aitwin 0.5.3 → 0.5.5
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 +41 -0
- package/dist/aitwin.cjs +6 -5
- package/dist/aitwin.js +3095 -2589
- package/dist/index.d.ts +96 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,11 @@ export declare type AiTwinHandle = {
|
|
|
46
46
|
* Null until a voice session (or TTS playback) has primed audio.
|
|
47
47
|
*/
|
|
48
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;
|
|
49
54
|
};
|
|
50
55
|
|
|
51
56
|
export declare class AiTwinNotFoundError extends Error {
|
|
@@ -146,6 +151,81 @@ export declare type AiTwinRenderVisemeOptions = {
|
|
|
146
151
|
/** Basename for the original portrait stored on CDN (e.g. source.png). */
|
|
147
152
|
export declare function aiTwinSourceFilename(extension?: string): string;
|
|
148
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
|
+
|
|
149
229
|
export declare type AvatarTtsLipsyncController = {
|
|
150
230
|
setDeveloperToken: (token: string) => void;
|
|
151
231
|
setTtsEngineId: (engineId: TtsEngineId) => void;
|
|
@@ -221,6 +301,22 @@ export declare function faceAssetUrls(faceId: string, cdnBase?: string): TwinAss
|
|
|
221
301
|
|
|
222
302
|
export declare function fetchAiTwin(id: string, baseUrl?: string): Promise<AiTwinRecord>;
|
|
223
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
|
+
|
|
224
320
|
/** Bearer token for /avatar_ttsWithPoses and /api/session-value. */
|
|
225
321
|
export declare function fetchDevAuthToken(): Promise<string>;
|
|
226
322
|
|