@alxxsck/ai-assistant 3.1.2 → 3.2.0

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.
@@ -1,4 +1,4 @@
1
- import { l as qs } from "./index-inp1tYlp.js";
1
+ import { l as qs } from "./index-C_7vxlzf.js";
2
2
  var Dr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
3
  const Lc = "182", Nd = 0, Tl = 1, Fd = 2, Ks = 1, Zu = 2, Wr = 3, ti = 0, qt = 1, Ln = 2, $n = 0, lr = 1, Al = 2, El = 3, wl = 4, Ud = 5, Ii = 100, Od = 101, kd = 102, Bd = 103, zd = 104, Hd = 200, Gd = 201, Vd = 202, Wd = 203, yo = 204, Mo = 205, Xd = 206, jd = 207, qd = 208, Kd = 209, Yd = 210, Jd = 211, Zd = 212, Qd = 213, $d = 214, To = 0, Ao = 1, Eo = 2, pr = 3, wo = 4, Ro = 5, Co = 6, Po = 7, Dc = 0, ef = 1, tf = 2, Un = 0, Qu = 1, $u = 2, eh = 3, th = 4, nh = 5, ih = 6, Nc = 7, Rl = "attached", nf = "detached", rh = 300, Bi = 301, mr = 302, Io = 303, Lo = 304, ga = 306, Ft = 1e3, Nn = 1001, ra = 1002, Tt = 1003, sh = 1004, Xr = 1005, At = 1006, Ys = 1007, Zn = 1008, en = 1009, ah = 1010, oh = 1011, ns = 1012, Fc = 1013, kn = 1014, un = 1015, ni = 1016, Uc = 1017, Oc = 1018, is = 1020, ch = 35902, lh = 35899, uh = 1021, hh = 1022, hn = 1023, ii = 1026, Di = 1027, kc = 1028, Bc = 1029, _r = 1030, zc = 1031, Hc = 1033, Js = 33776, Zs = 33777, Qs = 33778, $s = 33779, Do = 35840, No = 35841, Fo = 35842, Uo = 35843, Oo = 36196, ko = 37492, Bo = 37496, zo = 37488, Ho = 37489, Go = 37490, Vo = 37491, Wo = 37808, Xo = 37809, jo = 37810, qo = 37811, Ko = 37812, Yo = 37813, Jo = 37814, Zo = 37815, Qo = 37816, $o = 37817, ec = 37818, tc = 37819, nc = 37820, ic = 37821, rc = 36492, sc = 36494, ac = 36495, oc = 36283, cc = 36284, lc = 36285, uc = 36286, dh = 2200, rf = 2201, sf = 2202, rs = 2300, ss = 2301, Ca = 2302, ar = 2400, or = 2401, sa = 2402, Gc = 2500, af = 2501, of = 0, fh = 1, hc = 2, cf = 3200, Vc = 0, lf = 1, pi = "", nt = "srgb", Wt = "srgb-linear", aa = "linear", $e = "srgb", Wi = 7680, Cl = 519, uf = 512, hf = 513, df = 514, Wc = 515, ff = 516, pf = 517, Xc = 518, mf = 519, dc = 35044, Pl = "300 es", Fn = 2e3, oa = 2001;
4
4
  function ph(s) {
@@ -29425,8 +29425,8 @@ const Wv = [
29425
29425
  function Xv(s) {
29426
29426
  return Wv.filter((e) => !s[e]);
29427
29427
  }
29428
- const jv = 1, qv = 5922928, Kv = 4, Yv = 16773858, Jv = 3.2, Zv = 9357055, Qv = 2, $v = [-120, 150, -130], eS = 16775149, tS = 9e4, nS = 300, iS = 0.52, rS = 0.88, sS = 2, aS = [20, 190, 135], oS = 120, cS = 14674431, lS = 6968672, uS = 0.7;
29429
- class dS extends EventTarget {
29428
+ const jv = 1, qv = 5922928, Kv = 4, Yv = 16773858, Jv = 3.2, Zv = 9357055, Qv = 2, $v = [-120, 150, -130], eS = 16775149, tS = 9e4, nS = 300, iS = 0.52, rS = 0.88, sS = 2, aS = [20, 190, 135], oS = 120, cS = 14674431, lS = 6968672, uS = 0.7, hS = 1e3;
29429
+ class fS extends EventTarget {
29430
29430
  constructor(e, t, n) {
29431
29431
  super(), this.canvas = e, this.videoContainer = t, this.api = n, this.renderer = new K0({
29432
29432
  canvas: this.canvas,
@@ -29733,15 +29733,21 @@ class dS extends EventTarget {
29733
29733
  idleAnimationName = this.IDLE_ANIMATION_NAME_1;
29734
29734
  talkingRequested = !1;
29735
29735
  talkingApplied = !1;
29736
+ lipSyncUnderrunTimer = null;
29736
29737
  reportOptionalAnimationFailure(e) {
29737
29738
  qs.warn("Optional avatar animation failed", e);
29738
29739
  }
29740
+ clearLipSyncUnderrunTimer() {
29741
+ this.lipSyncUnderrunTimer && clearTimeout(this.lipSyncUnderrunTimer), this.lipSyncUnderrunTimer = null;
29742
+ }
29739
29743
  applyLipSyncSnapshot(e) {
29740
29744
  const t = e.phase === "playing";
29741
29745
  t ? this.animationManager?.setLipSyncTarget(
29742
29746
  e.mouthOpen,
29743
29747
  e.activeViseme
29744
- ) : this.animationManager?.resetLipSync(), this.talkingRequested !== t ? this.setTalking(t) : t && !this.talkingApplied && this.applyTalkingWhenReady();
29748
+ ) : this.animationManager?.resetLipSync(), e.phase === "underrun" ? this.lipSyncUnderrunTimer || (this.lipSyncUnderrunTimer = setTimeout(() => {
29749
+ this.lipSyncUnderrunTimer = null, this.talkingRequested && this.setTalking(!1);
29750
+ }, hS)) : this.clearLipSyncUnderrunTimer(), t && !this.talkingRequested ? this.setTalking(!0) : t && !this.talkingApplied ? this.applyTalkingWhenReady() : e.phase === "idle" && this.talkingRequested && this.setTalking(!1);
29745
29751
  }
29746
29752
  setTalking(e) {
29747
29753
  if (this.talkingRequested = e, e) {
@@ -29815,5 +29821,5 @@ class dS extends EventTarget {
29815
29821
  };
29816
29822
  }
29817
29823
  export {
29818
- dS as Avatar
29824
+ fS as Avatar
29819
29825
  };
@@ -1,8 +1,8 @@
1
1
  import { jsxs as C, jsx as u, Fragment as $e } from "react/jsx-runtime";
2
2
  import * as le from "react";
3
3
  import B, { useRef as T, useCallback as R, useEffect as k, useState as I, useMemo as ce, useContext as Ae, createContext as De, useId as ut, useSyncExternalStore as Kn, Fragment as un, useReducer as ta, createRef as Lo, useLayoutEffect as Ne, forwardRef as na, createElement as $n, memo as ra } from "react";
4
- import { s as gt, p as qn, o as re, Y as be, V as aa, K as Se, y as ze, n as dt, a as Ut, u as Pt, b as Vt, t as Yn, T as ko, l as oa, f as sa, O as rn, c as ia, d as Xe, i as qt, e as Ro, A as Tr, g as ae, P as _e, h as ye, j as Bt, v as Fo, k as dn, m as Zn, q as ca, r as Xn, w as ke, C as Te, N as vt, x as Ve, z as Io, B as Oo, D as Po, E as Do, F as la, G as Ho, H as Uo, S as Vo, I as Jn, J as Bo, L as jo, M as Qn, Q as st, R as Wo, U as zo, W as Go, X as Ko, Z as qo, _ as ua, $ as da, a0 as Yo, a1 as Zo, a2 as Xo, a3 as Jo, a4 as Qo, a5 as es, a6 as fa, a7 as er, a8 as ha, a9 as ts, aa as ns, ab as rs, ac as as, ad as tr, ae as os, af as en, ag as ss, ah as is, ai as cs, aj as ls, ak as us, al as ds, am as wt, an as fs, ao as En, ap as hs, aq as Nt, ar as _n } from "./mount-CD0D1VqC.js";
5
- import { o as ms, L as ps, a as vs } from "./index-inp1tYlp.js";
4
+ import { s as gt, p as qn, o as re, Y as be, V as aa, K as Se, y as ze, n as dt, a as Ut, u as Pt, b as Vt, t as Yn, T as ko, l as oa, f as sa, O as rn, c as ia, d as Xe, i as qt, e as Ro, A as Tr, g as ae, P as _e, h as ye, j as Bt, v as Fo, k as dn, m as Zn, q as ca, r as Xn, w as ke, C as Te, N as vt, x as Ve, z as Io, B as Oo, D as Po, E as Do, F as la, G as Ho, H as Uo, S as Vo, I as Jn, J as Bo, L as jo, M as Qn, Q as st, R as Wo, U as zo, W as Go, X as Ko, Z as qo, _ as ua, $ as da, a0 as Yo, a1 as Zo, a2 as Xo, a3 as Jo, a4 as Qo, a5 as es, a6 as fa, a7 as er, a8 as ha, a9 as ts, aa as ns, ab as rs, ac as as, ad as tr, ae as os, af as en, ag as ss, ah as is, ai as cs, aj as ls, ak as us, al as ds, am as wt, an as fs, ao as En, ap as hs, aq as Nt, ar as _n } from "./mount-B0T35SHn.js";
5
+ import { o as ms, L as ps, a as vs } from "./index-C_7vxlzf.js";
6
6
  import { createPortal as gs } from "react-dom";
7
7
  const ws = typeof document < "u" ? B.useLayoutEffect : () => {
8
8
  }, tt = (e) => {
@@ -73,7 +73,9 @@ export declare class Avatar extends EventTarget {
73
73
  private idleAnimationName;
74
74
  private talkingRequested;
75
75
  private talkingApplied;
76
+ private lipSyncUnderrunTimer;
76
77
  private reportOptionalAnimationFailure;
78
+ private clearLipSyncUnderrunTimer;
77
79
  applyLipSyncSnapshot(snapshot: LipSyncSnapshot): void;
78
80
  setTalking(talking: boolean): void;
79
81
  private applyTalkingWhenReady;
@@ -1,4 +1,4 @@
1
- import { C as A, E as e, S as s, d as E, c } from "./index-inp1tYlp.js";
1
+ import { C as A, E as e, S as s, d as E, c } from "./index-C_7vxlzf.js";
2
2
  export {
3
3
  A as ChatWidgetInstance,
4
4
  e as EXTERNALLY_AVAILABLE_ACTIONS,
@@ -8,10 +8,23 @@ export type PcmStreamLoader = (signal: AbortSignal) => Promise<ReadableStream<Ui
8
8
  export type PcmPlaybackOptions = SpeechPlaybackOptions & {
9
9
  sampleRate: number;
10
10
  jitterBufferMs?: number;
11
+ minimumStartupChunks?: number;
12
+ maximumJitterBufferMs?: number;
13
+ underrunBufferStepMs?: number;
14
+ underrunResumeBufferMs?: number;
15
+ startNotBeforeMs?: number;
16
+ allowPartialStartupQuantum?: boolean;
11
17
  onProgress?: (progress: PcmPlaybackProgress) => void;
12
- onUnderrun?: () => void;
13
- onResumed?: () => void;
18
+ onBufferUnderrun?: (diagnostics: PcmPlaybackBufferDiagnostics) => void;
19
+ onUnderrun?: (diagnostics: PcmPlaybackBufferDiagnostics) => void;
20
+ onResumed?: (diagnostics: PcmPlaybackBufferDiagnostics) => void;
14
21
  };
22
+ export type PcmPlaybackBufferDiagnostics = Readonly<{
23
+ targetBufferMs: number;
24
+ queuedBufferMs: number;
25
+ underrunCount: number;
26
+ resumeBufferMs: number;
27
+ }>;
15
28
  export type PcmPlaybackProgress = Readonly<{
16
29
  sourceSample: number;
17
30
  renderContextFrame: number;
@@ -1,10 +1,10 @@
1
1
  import type { CapturedAudioChunk, VoiceAudioAcknowledgement } from "./voice-media.types";
2
- /** Serializes immutable v5 PCM frames; a frame leaves memory only after its matching ACK. */
2
+ /** Sends immutable v5 PCM frames through an ordered bounded window. */
3
3
  export declare class ReliableVoiceUplink {
4
4
  private readonly send;
5
5
  private readonly onFailure;
6
6
  private readonly queue;
7
- private sending;
7
+ private inFlight;
8
8
  private closed;
9
9
  private enabled;
10
10
  private epoch;
@@ -15,6 +15,8 @@ export declare class ReliableVoiceUplink {
15
15
  enqueue(chunk: CapturedAudioChunk): void;
16
16
  setEnabled(enabled: boolean): void;
17
17
  close(): void;
18
- private drain;
18
+ private pump;
19
+ private sendQueuedChunk;
20
+ private fail;
19
21
  private waitForPacing;
20
22
  }
@@ -0,0 +1,44 @@
1
+ export declare const VOICE_OUTPUT_UNDERRUN_BUFFER_STEP_MS = 80;
2
+ export declare const VOICE_OUTPUT_UNDERRUN_RESUME_BUFFER_MS = 40;
3
+ export type VoiceOutputChunkTiming = Readonly<{
4
+ arrivalTimeMs: number;
5
+ mediaDurationMs: number;
6
+ }>;
7
+ export type VoiceOutputSpeechPlayerPolicy = Readonly<{
8
+ jitterBufferMs: number;
9
+ startupDelayMs: number;
10
+ minimumStartupChunks: number;
11
+ maximumJitterBufferMs: number;
12
+ underrunBufferStepMs: number;
13
+ underrunResumeBufferMs: number;
14
+ }>;
15
+ export declare const VOICE_OUTPUT_PLAYBACK_POLICY: {
16
+ readonly jitterBufferMs: 120;
17
+ readonly startupDelayMs: 40;
18
+ readonly minimumStartupChunks: 2;
19
+ readonly maximumJitterBufferMs: 800;
20
+ readonly underrunBufferStepMs: 80;
21
+ readonly underrunResumeBufferMs: 40;
22
+ };
23
+ export declare class AdaptiveVoicePlaybackPolicy {
24
+ private readonly deliverySkewSamples;
25
+ private sampledMediaDurationMs;
26
+ private targetStartupDelayMs;
27
+ private recoveryFloorMs;
28
+ private cleanCompletedResponses;
29
+ private responseActive;
30
+ private responseHadUnderrun;
31
+ private responseHasAudio;
32
+ private previousChunk;
33
+ private firstChunkArrivalTimeMs;
34
+ private mediaDurationBeforeNextChunkMs;
35
+ beginResponse(): void;
36
+ observeChunk(chunk: VoiceOutputChunkTiming): void;
37
+ reportUnderrun(reportedTargetBufferMs: number): void;
38
+ completeResponse(): void;
39
+ cancelResponse(): void;
40
+ reset(): void;
41
+ getSpeechPlayerOptions(): VoiceOutputSpeechPlayerPolicy;
42
+ private addDeliverySkewSample;
43
+ private getMeasuredSteadyTargetMs;
44
+ }