@streamoji/aitwin 0.6.5 → 0.6.8
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 +1 -0
- package/dist/aitwin.cjs +6 -6
- package/dist/aitwin.js +2446 -2310
- package/dist/index.d.ts +58 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare type AiTwinCaptionsOptions = {
|
|
|
17
17
|
|
|
18
18
|
export declare type AiTwinHandle = {
|
|
19
19
|
speakText: (text: string, options?: AvatarTtsSpeakOptions) => Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Generate an LLM reply and speak it in one `/avatar_ttsWithPoses` request
|
|
22
|
+
* (`generateReply: true`). Prefer this over `/avatarReply` + `speakText`.
|
|
23
|
+
*/
|
|
24
|
+
speakWithReply: (message: string, options?: SpeakWithReplyOptions) => Promise<SpeakWithReplyResult>;
|
|
20
25
|
stop: () => void;
|
|
21
26
|
setTtsEngineId: (engineId: TtsEngineId) => void;
|
|
22
27
|
renderViseme: (toViseme: string, options?: AiTwinRenderVisemeOptions) => Promise<void>;
|
|
@@ -49,10 +54,12 @@ export declare type AiTwinHandle = {
|
|
|
49
54
|
/** Mute/unmute bot audio output (TTS + voice). */
|
|
50
55
|
setMuted: (muted: boolean) => void;
|
|
51
56
|
isMuted: () => boolean;
|
|
52
|
-
/** Brain id from getAiTwin (for
|
|
57
|
+
/** Brain id from getAiTwin (for speakWithReply and /ws/voice). */
|
|
53
58
|
getBrainId: () => string | null;
|
|
54
59
|
/** @deprecated Use `getBrainId`. */
|
|
55
60
|
getPersonaId: () => string | null;
|
|
61
|
+
/** Client SSE brain URL from getAiTwin (for speakWithReply / /ws/voice). */
|
|
62
|
+
getBrainUrl: () => string | null;
|
|
56
63
|
};
|
|
57
64
|
|
|
58
65
|
export declare class AiTwinNotFoundError extends Error {
|
|
@@ -159,6 +166,8 @@ export declare type AiTwinRecord = {
|
|
|
159
166
|
brainId?: string;
|
|
160
167
|
/** @deprecated Use `brainId`. */
|
|
161
168
|
knowledgeContextId?: string;
|
|
169
|
+
/** Client SSE brain URL. Passed as `brainUrl` on `/ws/voice`. */
|
|
170
|
+
brainUrl?: string;
|
|
162
171
|
gender?: string;
|
|
163
172
|
createdAt?: string;
|
|
164
173
|
updatedAt?: string;
|
|
@@ -182,6 +191,7 @@ export declare const AiTwinWidget: ForwardRefExoticComponent<AiTwinWidgetProps &
|
|
|
182
191
|
/** Imperative API shared by React ref and HTML widget handle. */
|
|
183
192
|
export declare type AiTwinWidgetHandle = {
|
|
184
193
|
speakText: (text: string, options?: AvatarTtsSpeakOptions) => Promise<void>;
|
|
194
|
+
speakWithReply: (message: string, options?: SpeakWithReplyOptions) => Promise<SpeakWithReplyResult>;
|
|
185
195
|
connect: (options?: VoiceConnectOptions) => Promise<void>;
|
|
186
196
|
disconnect: () => Promise<void>;
|
|
187
197
|
stop: () => void;
|
|
@@ -232,12 +242,17 @@ export declare type AiTwinWidgetProps = {
|
|
|
232
242
|
*/
|
|
233
243
|
float?: boolean;
|
|
234
244
|
/**
|
|
235
|
-
* Brain id for
|
|
245
|
+
* Brain id for `speakWithReply` (Text mode) and `/ws/voice`.
|
|
236
246
|
* When omitted, uses getAiTwin `brainId` if available.
|
|
237
247
|
*/
|
|
238
248
|
brainId?: string;
|
|
239
249
|
/** @deprecated Use `brainId`. */
|
|
240
250
|
personaId?: string;
|
|
251
|
+
/**
|
|
252
|
+
* Client SSE brain URL for `speakWithReply` / `/ws/voice`.
|
|
253
|
+
* When omitted, uses getAiTwin `brainUrl` if available.
|
|
254
|
+
*/
|
|
255
|
+
brainUrl?: string;
|
|
241
256
|
/**
|
|
242
257
|
* Optional poster shown (blurred) on `<AiTwin>` while sil/atlas/idle assets load.
|
|
243
258
|
* When omitted, AiTwin derives it from `faceId`/`avatarId`.
|
|
@@ -265,6 +280,11 @@ export declare type AvatarTtsLipsyncController = {
|
|
|
265
280
|
setTtsEngineId: (engineId: TtsEngineId) => void;
|
|
266
281
|
getTtsEngineId: () => TtsEngineId;
|
|
267
282
|
speak: (userQuery: string, options?: AvatarTtsSpeakOptions) => Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* LLM reply + TTS in one `/avatar_ttsWithPoses` request (`generateReply: true`).
|
|
285
|
+
* Avoids a separate `/avatarReply` round-trip.
|
|
286
|
+
*/
|
|
287
|
+
speakWithReply: (message: string, options?: SpeakWithReplyOptions) => Promise<SpeakWithReplyResult>;
|
|
268
288
|
stop: () => void;
|
|
269
289
|
getVisemeQueue: () => VisemeQueueItem[];
|
|
270
290
|
getWordQueue: () => WordQueueItem[];
|
|
@@ -454,6 +474,12 @@ export declare function parsePackedVoiceId(raw?: string): {
|
|
|
454
474
|
voiceId?: string;
|
|
455
475
|
};
|
|
456
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Validate a client SSE brain URL. Empty/whitespace is unset.
|
|
479
|
+
* Must be http(s) with a host and no fragment — same rules as `/ws/voice`.
|
|
480
|
+
*/
|
|
481
|
+
export declare function parseTwinBrainUrl(value?: string | null): string | undefined;
|
|
482
|
+
|
|
457
483
|
export declare const PLAYBACK_SAMPLE_RATE = 16000;
|
|
458
484
|
|
|
459
485
|
declare type RawVisemeTransition = {
|
|
@@ -517,6 +543,8 @@ export declare function resolveDirectFaceId(avatarId?: string, faceId?: string):
|
|
|
517
543
|
/** Canonical `brainId`, then legacy `knowledgeContextId`, then extra fallbacks. */
|
|
518
544
|
export declare function resolveTwinBrainId(source?: TwinBrainFields | string | null, ...fallbacks: Array<string | null | undefined>): string | undefined;
|
|
519
545
|
|
|
546
|
+
export declare function resolveTwinBrainUrl(source?: TwinBrainFields | string | null, ...fallbacks: Array<string | null | undefined>): string | undefined;
|
|
547
|
+
|
|
520
548
|
/** Pick the active viseme at playback offset (latest vtime wins on overlap). */
|
|
521
549
|
export declare function resolveVisemeAtTime(queue: VisemeQueueItem[], elapsedMs: number): string;
|
|
522
550
|
|
|
@@ -557,6 +585,27 @@ export declare const SPEAKING_RATE_MAX = 1.5;
|
|
|
557
585
|
|
|
558
586
|
export declare const SPEAKING_RATE_MIN = 0.5;
|
|
559
587
|
|
|
588
|
+
export declare type SpeakWithReplyMessage = {
|
|
589
|
+
role: "user" | "assistant";
|
|
590
|
+
content: string;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
/** Options for `/avatar_ttsWithPoses` with `generateReply: true`. */
|
|
594
|
+
export declare type SpeakWithReplyOptions = AvatarTtsSpeakOptions & {
|
|
595
|
+
brainId?: string;
|
|
596
|
+
brainUrl?: string;
|
|
597
|
+
history?: SpeakWithReplyMessage[];
|
|
598
|
+
/** Called as soon as spokenText arrives on the SSE stream. */
|
|
599
|
+
onSpokenText?: (spokenText: string) => void;
|
|
600
|
+
/** Called as soon as displayText arrives on the SSE stream. */
|
|
601
|
+
onDisplayText?: (displayText: string) => void;
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
export declare type SpeakWithReplyResult = {
|
|
605
|
+
displayText: string;
|
|
606
|
+
spokenText: string;
|
|
607
|
+
};
|
|
608
|
+
|
|
560
609
|
/** Merge explicit `ttsEngineId` with a possibly packed `voiceId`. Packed engine wins only if engine is omitted. */
|
|
561
610
|
export declare function splitVoiceIdSpec(ttsEngineId?: TtsEngineId, voiceId?: string): {
|
|
562
611
|
ttsEngineId?: TtsEngineId;
|
|
@@ -845,6 +894,8 @@ declare type TwinBrainFields = {
|
|
|
845
894
|
brainId?: string | null;
|
|
846
895
|
/** @deprecated Use `brainId`. Older getAiTwin responses still send this. */
|
|
847
896
|
knowledgeContextId?: string | null;
|
|
897
|
+
/** Client SSE brain URL. When set, `/ws/voice` skips hosted brainId / Grok / OpenAI. */
|
|
898
|
+
brainUrl?: string | null;
|
|
848
899
|
};
|
|
849
900
|
|
|
850
901
|
export declare const VISEME_IDS: readonly ["aa", "E", "I", "O", "U", "PP", "FF", "DD", "SS", "TH", "CH", "RR", "kk", "nn"];
|
|
@@ -889,6 +940,11 @@ export declare type VoiceConnectOptions = {
|
|
|
889
940
|
brainId?: string;
|
|
890
941
|
/** @deprecated Use `brainId`. */
|
|
891
942
|
personaId?: string;
|
|
943
|
+
/**
|
|
944
|
+
* Client SSE brain URL. When set, `/ws/voice` skips hosted brainId / Grok / OpenAI
|
|
945
|
+
* and GETs this URL with socket query params plus `text=<user turn>`.
|
|
946
|
+
*/
|
|
947
|
+
brainUrl?: string;
|
|
892
948
|
speakingRate?: number;
|
|
893
949
|
/** Default true — server streams TTS + avatar messages. */
|
|
894
950
|
ttsStream?: boolean;
|