@burdenoff/fe-libs 2026.1115.10 → 2026.1115.12

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.
Files changed (37) hide show
  1. package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +8 -1
  2. package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +126 -123
  3. package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +7 -0
  4. package/dist/shared/assistant/avatar/live/liveAvatarController.js +3 -2
  5. package/dist/shared/assistant/index.d.ts +1 -0
  6. package/dist/shared/assistant/ui/AssistantAvatar.js +18 -14
  7. package/dist/shared/assistant/ui/AssistantChatArea.js +1 -0
  8. package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +5 -0
  9. package/dist/shared/assistant/ui/AssistantMessageItem.js +57 -56
  10. package/dist/shared/assistant/ui/AssistantMessageList.js +57 -44
  11. package/dist/shared/assistant/ui/AssistantTurnActivity.d.ts +2 -0
  12. package/dist/shared/assistant/ui/AssistantTurnActivity.js +20 -17
  13. package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +26 -0
  14. package/dist/shared/assistant/ui/assistantLiveAvatarSeam.js +87 -79
  15. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +5 -0
  16. package/dist/shared/assistant/ui/composer/AssistantComposer.js +348 -343
  17. package/dist/shared/assistant/ui/composer/AssistantDictation.js +57 -56
  18. package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.d.ts +4 -0
  19. package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.js +22 -22
  20. package/dist/shared/assistant/ui/composer/pageBoxClass.d.ts +13 -0
  21. package/dist/shared/assistant/ui/composer/pageBoxClass.js +5 -0
  22. package/dist/shared/assistant/ui/useVoiceSession.js +223 -223
  23. package/dist/shared/assistant/ui/voice/AssistantPageVoiceBar.js +41 -35
  24. package/dist/shared/assistant/ui/voice/AssistantVoiceSessionButton.js +13 -12
  25. package/dist/shared/assistant/ui/voice/LiveWaveform.js +28 -27
  26. package/dist/shared/assistant/voice/handsfree/handsFreeController.js +79 -79
  27. package/dist/shared/assistant/voice/handsfree/handsFreeSetting.d.ts +6 -1
  28. package/dist/shared/assistant/voice/handsfree/handsFreeSetting.js +2 -2
  29. package/dist/shared/assistant/voice/handsfree/playbackReference.d.ts +45 -3
  30. package/dist/shared/assistant/voice/handsfree/playbackReference.js +62 -15
  31. package/dist/shared-assistant.js +371 -370
  32. package/package.json +1 -1
  33. package/src/shared/styles/app-shell.css +5 -0
  34. package/src/shared/tokens/build/semantic.css +12 -0
  35. package/src/shared/tokens/build/tailwind.preset.js +5 -0
  36. package/src/shared/tokens/build/themes.css +14 -0
  37. package/src/shared/tokens/tokens.css +268 -0
@@ -15,18 +15,24 @@ function _(e, t) {
15
15
  return e === "mic-error" ? "error" : t ? "off" : e === "listening" || e === "endpoint-grace" || e === "interrupting" ? "hearing" : e === "speaking" ? "talking" : "waiting";
16
16
  }
17
17
  var v = {
18
- hearing: "border-status-warning-bg ring-1 ring-status-warning-bg",
19
- talking: "border-status-info-bg ring-1 ring-status-info-bg",
20
- waiting: "border-border-default",
18
+ hearing: "boff-dock boff-dock--listening",
19
+ talking: "boff-dock boff-dock--speaking",
20
+ waiting: "boff-dock boff-dock--thinking",
21
21
  off: "border-border-default",
22
22
  error: "border-status-error-bg"
23
23
  }, y = {
24
- hearing: "bg-status-warning-bg-subtle text-status-warning-bg",
25
- talking: "bg-status-info-bg-subtle text-status-info-bg",
26
- waiting: "bg-bg-sunken text-text-secondary",
24
+ hearing: "boff-orb boff-orb--listening boff-ripple",
25
+ talking: "boff-orb boff-orb--speaking boff-ripple boff-ripple--fill",
26
+ waiting: "boff-orb boff-orb--thinking",
27
27
  off: "bg-bg-sunken text-text-muted",
28
28
  error: "bg-status-error-bg-subtle text-status-error-text"
29
- }, b = ({ level: e }) => {
29
+ }, b = {
30
+ hearing: "boff-text-listening",
31
+ talking: "boff-text-speaking",
32
+ waiting: "boff-text-thinking",
33
+ off: "",
34
+ error: ""
35
+ }, x = ({ level: e }) => {
30
36
  let t = r(), n = u([]);
31
37
  return l(() => {
32
38
  if (t) return;
@@ -53,22 +59,22 @@ var v = {
53
59
  className: "h-full w-[3px] origin-center scale-y-[0.35] rounded-full bg-current transition-transform duration-75"
54
60
  }, e))
55
61
  });
56
- }, x = ({ tone: e, level: t }) => {
62
+ }, S = ({ tone: e, level: t }) => {
57
63
  let n = r();
58
64
  return /* @__PURE__ */ h("span", {
59
65
  "aria-hidden": "true",
60
66
  className: `flex size-11 shrink-0 items-center justify-center rounded-full ${y[e]}`,
61
67
  "data-testid": "assistant-voice-circle",
62
68
  "data-tone": e,
63
- children: e === "hearing" || e === "talking" ? /* @__PURE__ */ h(b, { level: t }) : e === "off" || e === "error" ? /* @__PURE__ */ h(p, { className: "size-5" }) : /* @__PURE__ */ h(f, { className: `size-5${n ? "" : " motion-safe:animate-spin"}` })
69
+ children: e === "hearing" || e === "talking" ? /* @__PURE__ */ h(x, { level: t }) : e === "off" || e === "error" ? /* @__PURE__ */ h(p, { className: "size-5" }) : /* @__PURE__ */ h(f, { className: `size-5${n ? "" : " motion-safe:animate-spin"}` })
64
70
  });
65
71
  };
66
- function S(e, t) {
72
+ function C(e, t) {
67
73
  if (t.heard) return t.heard;
68
74
  let n = e("voiceDock.listeningCaption", "Go ahead, I am listening.");
69
75
  return t.stage === "listening" && t.stageText === e("voiceSession.listening", "Listening…") ? n : t.stageText || n;
70
76
  }
71
- function C(e, t) {
77
+ function w(e, t) {
72
78
  let { stage: n } = t;
73
79
  return n === "mic-error" ? {
74
80
  title: e("voiceDock.problem", "Microphone problem"),
@@ -87,20 +93,20 @@ function C(e, t) {
87
93
  caption: t.bargeIn ? e("voiceDock.speakingCaption", "Speak or tap Interrupt to cut in.") : e("voiceDock.speakingCaptionTap", "Tap Interrupt to cut in.")
88
94
  } : {
89
95
  title: e("voiceDock.listening", "Listening"),
90
- caption: S(e, t)
96
+ caption: C(e, t)
91
97
  };
92
98
  }
93
- function w(t) {
94
- return C(e(), t);
99
+ function T(t) {
100
+ return w(e(), t);
95
101
  }
96
- function T() {
102
+ function E() {
97
103
  let [e, t] = d(0);
98
104
  return l(() => {
99
105
  let e = Date.now(), n = setInterval(() => t(Math.floor((Date.now() - e) / 1e3)), 1e3);
100
106
  return () => clearInterval(n);
101
107
  }, []), e;
102
108
  }
103
- function E(e) {
109
+ function D(e) {
104
110
  let t = u(null);
105
111
  l(() => {
106
112
  if (typeof document < "u") return t.current = document.title, () => {
@@ -110,7 +116,7 @@ function E(e) {
110
116
  typeof document < "u" && t.current !== null && (document.title = `${e} · ${t.current}`);
111
117
  }, [e]);
112
118
  }
113
- var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r }) => /* @__PURE__ */ g(m, { children: [
119
+ var O = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r }) => /* @__PURE__ */ g(m, { children: [
114
120
  /* @__PURE__ */ g("div", {
115
121
  className: "flex flex-col items-center gap-1 px-1 text-center text-xs empty:hidden [&:not(:empty)]:pb-1.5",
116
122
  "data-testid": "assistant-voice-page-notices",
@@ -150,7 +156,7 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
150
156
  "data-testid": "assistant-voice-started-cue-announced",
151
157
  children: r
152
158
  })
153
- ] }), O = "flex h-11 shrink-0 items-center justify-center gap-1.5 rounded-full border px-4 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:cursor-default disabled:opacity-50 sm:h-10", k = `${O} border-border-default bg-bg-elevated text-text-primary hover:bg-bg-sunken`, A = (t) => {
159
+ ] }), k = "flex h-11 shrink-0 items-center justify-center gap-1.5 rounded-full border px-4 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:cursor-default disabled:opacity-50 sm:h-10", A = `${k} border-border-default bg-bg-elevated text-text-primary hover:bg-bg-sunken`, j = (t) => {
154
160
  let n = e(), { muted: r, stage: a, hold: o, onAttachFiles: s, endRef: c, onEnd: d, onInterrupt: f, onToggleMute: p } = t, m = a === "speaking" && !r, _ = u(null), v = u(!1);
155
161
  return l(() => {
156
162
  !m && v.current && (v.current = !1, _.current?.focus());
@@ -164,7 +170,7 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
164
170
  onClick: p,
165
171
  disabled: t.muteDisabled,
166
172
  "aria-pressed": r,
167
- className: k,
173
+ className: A,
168
174
  "data-testid": "assistant-voice-mute",
169
175
  children: r ? n("window.unmute", "Unmute") : n("window.mute", "Mute")
170
176
  }),
@@ -179,14 +185,14 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
179
185
  onBlur: () => {
180
186
  v.current = !1;
181
187
  },
182
- className: k,
188
+ className: A,
183
189
  "data-testid": "assistant-voice-interrupt",
184
190
  children: n("voiceDock.interrupt", "Interrupt")
185
191
  }) : null,
186
192
  o ? /* @__PURE__ */ h("button", {
187
193
  type: "button",
188
194
  onClick: o.onPress,
189
- className: o.holding ? `${O} border-transparent bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg-hover` : k,
195
+ className: o.holding ? `${k} border-transparent bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg-hover` : A,
190
196
  title: o.holding ? n("voiceSession.imDoneHint", "Send what you said now") : n("voiceSession.letMeFinishHint", "Pause sending until you tap “I’m done”"),
191
197
  "data-testid": "assistant-voice-hold",
192
198
  "data-holding": o.holding ? "true" : "false",
@@ -205,17 +211,17 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
205
211
  ref: c,
206
212
  type: "button",
207
213
  onClick: d,
208
- className: `${O} basis-full border-transparent bg-text-primary text-bg-elevated hover:opacity-90 sm:basis-auto`,
214
+ className: `${k} basis-full border-transparent bg-text-primary text-bg-elevated hover:opacity-90 sm:basis-auto`,
209
215
  title: n("voiceSession.end", "End the voice conversation"),
210
216
  "data-testid": "assistant-voice-end",
211
217
  children: n("voiceDock.end", "End voice chat")
212
218
  })
213
219
  ]
214
220
  });
215
- }, j = (r) => {
216
- let i = e(), { rootRef: l, stage: u, muted: d, attachments: f, preparingAttachments: p, attachmentsLocked: m } = r, y = _(u, d), b = w(r), S = T();
217
- E(b.title);
218
- let C = f.length > 0 || p > 0;
221
+ }, M = (r) => {
222
+ let i = e(), { rootRef: l, stage: u, muted: d, attachments: f, preparingAttachments: p, attachmentsLocked: m } = r, y = _(u, d), x = T(r), C = E();
223
+ D(x.title);
224
+ let w = f.length > 0 || p > 0;
219
225
  return /* @__PURE__ */ g("div", {
220
226
  ref: l,
221
227
  role: "region",
@@ -225,14 +231,14 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
225
231
  "data-presentation": "page",
226
232
  [n]: "",
227
233
  children: [
228
- /* @__PURE__ */ h(D, { ...r }),
234
+ /* @__PURE__ */ h(O, { ...r }),
229
235
  /* @__PURE__ */ g("div", {
230
236
  className: `flex flex-col gap-1 rounded-3xl border bg-bg-elevated transition-colors ${v[y]}`,
231
237
  "data-testid": "assistant-voice-page-bar",
232
238
  "data-state": u,
233
239
  "data-tone": y,
234
240
  children: [
235
- C ? /* @__PURE__ */ h("div", {
241
+ w ? /* @__PURE__ */ h("div", {
236
242
  className: "px-3 pt-3",
237
243
  "data-testid": "assistant-voice-attachments",
238
244
  children: /* @__PURE__ */ h(a, {
@@ -246,27 +252,27 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
246
252
  /* @__PURE__ */ g("div", {
247
253
  className: "flex items-center gap-3 px-3 pt-3",
248
254
  children: [
249
- /* @__PURE__ */ h(x, {
255
+ /* @__PURE__ */ h(S, {
250
256
  tone: y,
251
257
  level: r.level
252
258
  }),
253
259
  /* @__PURE__ */ g("div", {
254
260
  className: "min-w-0 flex-1",
255
261
  children: [/* @__PURE__ */ h("p", {
256
- className: "text-base font-semibold text-text-primary",
262
+ className: `text-base font-semibold text-text-primary ${b[y]}`,
257
263
  "data-testid": "assistant-voice-title",
258
- children: b.title
264
+ children: x.title
259
265
  }), /* @__PURE__ */ h("p", {
260
266
  className: `line-clamp-2 text-sm ${r.heard ? "text-text-primary" : "text-text-secondary"}`,
261
267
  "data-testid": r.heard ? "assistant-voice-heard" : "assistant-voice-caption-line",
262
- children: b.caption
268
+ children: x.caption
263
269
  })]
264
270
  }),
265
271
  /* @__PURE__ */ h("span", {
266
272
  className: "shrink-0 self-start text-xs tabular-nums text-text-secondary",
267
273
  "aria-hidden": "true",
268
274
  "data-testid": "assistant-voice-time",
269
- children: o(S)
275
+ children: o(C)
270
276
  })
271
277
  ]
272
278
  }),
@@ -276,7 +282,7 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
276
282
  rotating: r.rotateStatus,
277
283
  className: "sr-only"
278
284
  }),
279
- /* @__PURE__ */ h(A, { ...r })
285
+ /* @__PURE__ */ h(j, { ...r })
280
286
  ]
281
287
  }),
282
288
  r.privacyNotice ? /* @__PURE__ */ h(s, {
@@ -287,4 +293,4 @@ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r })
287
293
  ]
288
294
  });
289
295
  };
290
- export { j as AssistantPageVoiceBar };
296
+ export { M as AssistantPageVoiceBar };
@@ -1,18 +1,19 @@
1
1
  import { useAssistantTr as e } from "../../i18n.js";
2
- import { AudioLines as t } from "lucide-react";
3
- import { jsx as n } from "react/jsx-runtime";
2
+ import { useAssistantPageLayout as t } from "../assistantPageLayout.js";
3
+ import { AudioLines as n } from "lucide-react";
4
+ import { jsx as r } from "react/jsx-runtime";
4
5
  // src/shared/assistant/ui/voice/AssistantVoiceSessionButton.tsx
5
- var r = ({ onStart: r, disabled: i = !1, compact: a = !1, invisible: o = !1 }) => {
6
- let s = e();
7
- return /* @__PURE__ */ n("button", {
6
+ var i = ({ onStart: i, disabled: a = !1, compact: o = !1, invisible: s = !1 }) => {
7
+ let c = e(), l = t();
8
+ return /* @__PURE__ */ r("button", {
8
9
  type: "button",
9
- onClick: r,
10
- disabled: i,
11
- className: a ? `flex size-11 shrink-0 items-center justify-center rounded-full bg-action-primary-bg text-action-primary-text transition-colors hover:bg-action-primary-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50 sm:size-10${o ? " invisible" : ""}` : "flex size-9 flex-shrink-0 items-center justify-center rounded-full bg-bg-elevated text-text-secondary shadow-sm transition-all hover:scale-105 hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:scale-100",
12
- "aria-label": s("voiceSession.start", "Start a voice conversation"),
13
- title: s("voiceSession.start", "Start a voice conversation"),
10
+ onClick: i,
11
+ disabled: a,
12
+ className: o ? `flex size-11 shrink-0 items-center justify-center rounded-full bg-action-primary-bg text-action-primary-text transition-colors hover:bg-action-primary-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50 sm:size-10${l ? " boff-voice-start" : ""}${s ? " invisible" : ""}` : "flex size-9 flex-shrink-0 items-center justify-center rounded-full bg-bg-elevated text-text-secondary shadow-sm transition-all hover:scale-105 hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:scale-100",
13
+ "aria-label": c("voiceSession.start", "Start a voice conversation"),
14
+ title: c("voiceSession.start", "Start a voice conversation"),
14
15
  "data-testid": "assistant-voice-session-start",
15
- children: /* @__PURE__ */ n(t, { className: a ? "size-5" : "size-4" })
16
+ children: /* @__PURE__ */ r(n, { className: o ? "size-5" : "size-4" })
16
17
  });
17
18
  };
18
- export { r as AssistantVoiceSessionButton };
19
+ export { i as AssistantVoiceSessionButton };
@@ -1,52 +1,53 @@
1
1
  import { pushLevel as e } from "../../voice/liveLevel.js";
2
2
  import { usePrefersReducedMotion as t } from "../usePrefersReducedMotion.js";
3
- import { useEffect as n, useRef as r } from "react";
4
- import { jsx as i } from "react/jsx-runtime";
3
+ import { useAssistantPageLayout as n } from "../assistantPageLayout.js";
4
+ import { useEffect as r, useRef as i } from "react";
5
+ import { jsx as a } from "react/jsx-runtime";
5
6
  // src/shared/assistant/ui/voice/LiveWaveform.tsx
6
- var a = 3, o = 2, s = 2, c = ({ source: c, tone: l, className: u = "", testId: d }) => {
7
- let f = t(), p = r(null), m = r(null);
8
- return n(() => {
9
- let t = p.current, n = m.current;
7
+ var o = 3, s = 2, c = 2, l = ({ source: l, tone: u, className: d = "", testId: f }) => {
8
+ let p = t(), m = n(), h = i(null), g = i(null);
9
+ return r(() => {
10
+ let t = h.current, n = g.current;
10
11
  if (!t || !n) return;
11
12
  let r = typeof n.getContext == "function" ? n.getContext("2d") : null;
12
13
  if (!r) return;
13
- let i = 0, l = 0, u = 0, d = [], h = "", g = () => {
14
- if (i === 0 || l === 0) return;
14
+ let i = 0, a = 0, u = 0, d = [], f = "", m = () => {
15
+ if (i === 0 || a === 0) return;
15
16
  let e = typeof window > "u" ? 1 : window.devicePixelRatio || 1;
16
- r.setTransform(e, 0, 0, e, 0, 0), r.clearRect(0, 0, i, l), r.fillStyle = h;
17
- let t = u * 5 - o, n = i - t;
17
+ r.setTransform(e, 0, 0, e, 0, 0), r.clearRect(0, 0, i, a), r.fillStyle = f;
18
+ let t = u * 5 - s, n = i - t;
18
19
  for (let e = 0; e < u; e += 1) {
19
- let t = f ? 0 : d[e] ?? 0, i = Math.max(s, t * l), o = n + e * 5, c = (l - i) / 2, u = Math.min(a / 2, i / 2);
20
- typeof r.roundRect == "function" ? (r.beginPath(), r.roundRect(o, c, a, i, u), r.fill()) : r.fillRect(o, c, a, i);
20
+ let t = p ? 0 : d[e] ?? 0, i = Math.max(c, t * a), s = n + e * 5, l = (a - i) / 2, u = Math.min(o / 2, i / 2);
21
+ typeof r.roundRect == "function" ? (r.beginPath(), r.roundRect(s, l, o, i, u), r.fill()) : r.fillRect(s, l, o, i);
21
22
  }
22
23
  }, _ = () => {
23
24
  let e = t.getBoundingClientRect(), r = typeof window > "u" ? 1 : window.devicePixelRatio || 1;
24
- for (i = Math.max(0, Math.floor(e.width)), l = Math.max(0, Math.floor(e.height)), n.width = Math.round(i * r), n.height = Math.round(l * r), n.style.width = `${i}px`, n.style.height = `${l}px`, u = Math.max(0, Math.floor((i + o) / 5)), d = d.length > u ? d.slice(d.length - u) : d; d.length < u;) d.unshift(0);
25
- h = typeof getComputedStyle == "function" ? getComputedStyle(n).color : "", g();
25
+ for (i = Math.max(0, Math.floor(e.width)), a = Math.max(0, Math.floor(e.height)), n.width = Math.round(i * r), n.height = Math.round(a * r), n.style.width = `${i}px`, n.style.height = `${a}px`, u = Math.max(0, Math.floor((i + s) / 5)), d = d.length > u ? d.slice(d.length - u) : d; d.length < u;) d.unshift(0);
26
+ f = typeof getComputedStyle == "function" ? getComputedStyle(n).color : "", m();
26
27
  };
27
28
  _();
28
29
  let v = typeof ResizeObserver > "u" ? null : new ResizeObserver(_);
29
30
  v?.observe(t);
30
- let y = c.subscribe((t) => {
31
- f || (d = e(d, t, u), g());
31
+ let y = l.subscribe((t) => {
32
+ p || (d = e(d, t, u), m());
32
33
  });
33
34
  return () => {
34
35
  y(), v?.disconnect();
35
36
  };
36
37
  }, [
37
- c,
38
38
  l,
39
- f
40
- ]), /* @__PURE__ */ i("div", {
41
- ref: p,
42
- className: `relative min-w-0 overflow-hidden ${u}`,
39
+ u,
40
+ p
41
+ ]), /* @__PURE__ */ a("div", {
42
+ ref: h,
43
+ className: `relative min-w-0 overflow-hidden ${d}`,
43
44
  "aria-hidden": "true",
44
- "data-testid": d,
45
- "data-tone": l,
46
- children: /* @__PURE__ */ i("canvas", {
47
- ref: m,
48
- className: `absolute inset-0 ${l === "speaking" ? "text-status-info-bg" : "text-status-warning-bg"}`
45
+ "data-testid": f,
46
+ "data-tone": u,
47
+ children: /* @__PURE__ */ a("canvas", {
48
+ ref: g,
49
+ className: `absolute inset-0 ${u === "speaking" ? "text-status-info-bg" : "text-status-warning-bg"}${m ? u === "speaking" ? " boff-text-speaking" : " boff-text-listening" : ""}`
49
50
  })
50
51
  });
51
52
  };
52
- export { c as LiveWaveform };
53
+ export { l as LiveWaveform };
@@ -1,11 +1,11 @@
1
1
  import "./captureWorklet.js";
2
2
  import { NOTHING_HEARD_MS as e, createEpochGuard as t, planOnset as n, shouldFallBackToTap as r } from "./bargeIn.js";
3
- import { EchoGate as i } from "./echoGate.js";
4
- import { MicCaptureError as a } from "./micCapture.js";
5
- import { PreRollRing as o } from "./preRollRing.js";
6
- import { DEFAULT_VAD_PARAMS as s, createVad as c } from "./vad.js";
3
+ import { DEFAULT_ECHO_GATE_PARAMS as i, EchoGate as a } from "./echoGate.js";
4
+ import { MicCaptureError as o } from "./micCapture.js";
5
+ import { PreRollRing as s } from "./preRollRing.js";
6
+ import { DEFAULT_VAD_PARAMS as c, createVad as l } from "./vad.js";
7
7
  // src/shared/assistant/voice/handsfree/handsFreeController.ts
8
- var l = {
8
+ var u = i.referenceSilentDb, d = i.tailFrames, f = {
9
9
  unavailable: "transport-unavailable",
10
10
  auth: "transport-auth",
11
11
  quota: "transport-quota",
@@ -13,113 +13,113 @@ var l = {
13
13
  closed: "transport-upstream",
14
14
  "not-allowed": "mic-denied"
15
15
  };
16
- function u(u) {
17
- let d = u.setTimer ?? ((e, t) => setTimeout(e, t)), f = u.clearTimer ?? ((e) => clearTimeout(e)), p = new i(), m = c(), h = new o(u.prerollMs ?? 700, 20), g = t(), _ = null, v = !1, y = 0, b = null, x = null, S = 0, C = null, w = 0, T = null, E = !1, D = (e) => u.onTelemetry?.(e), O = (e) => {
18
- E || (E = !0, D({
16
+ function p(i) {
17
+ let p = i.setTimer ?? ((e, t) => setTimeout(e, t)), m = i.clearTimer ?? ((e) => clearTimeout(e)), h = new a(), g = l(), _ = new s(i.prerollMs ?? 700, 20), v = t(), y = null, b = !1, x = 0, S = null, C = null, w = 0, T = null, E = -1, D = 0, O = null, k = !1, A = (e) => i.onTelemetry?.(e), j = (e) => {
18
+ k || (k = !0, A({
19
19
  type: "fallback",
20
20
  reason: e
21
- }), P(), u.onFallback(e));
22
- }, k = () => {
23
- T !== null && f(T), T = null;
24
- }, A = (e) => {
25
- if (e === C) return;
26
- let t = C;
27
- C = e, e === null ? p.playbackStopped() : (t === null || t !== e) && p.playbackStarted(e === "hosted"), m.setOnsetFrames(e === "device" ? 6 : s.onsetFrames);
28
- }, j = () => {
29
- b &&= (u.transport.closeUtterance(b.id), null);
30
- }, M = (t) => {
31
- let i = u.getSession(), a = n({
32
- enabled: u.isEnabled(),
33
- muted: i.muted,
34
- phase: i.phase,
35
- playbackAudible: C !== null
21
+ }), R(), i.onFallback(e));
22
+ }, M = () => {
23
+ O !== null && m(O), O = null;
24
+ }, N = (e, t) => e === "avatar" ? (t > u && (E = x + d), x <= E ? "avatar" : null) : (E = -1, e === "avatar-unrouted" ? i.getSession().phase === "speaking" ? "device" : null : e), P = (e) => {
25
+ if (e === T) return;
26
+ let t = T;
27
+ T = e, e === null ? h.playbackStopped() : (t === null || t !== e) && h.playbackStarted(e === "hosted" || e === "avatar"), g.setOnsetFrames(e === "device" ? 6 : c.onsetFrames);
28
+ }, F = () => {
29
+ S &&= (i.transport.closeUtterance(S.id), null);
30
+ }, I = (t) => {
31
+ let a = i.getSession(), o = n({
32
+ enabled: i.isEnabled(),
33
+ muted: a.muted,
34
+ phase: a.phase,
35
+ playbackAudible: T !== null
36
36
  });
37
- if (D({
37
+ if (A({
38
38
  type: "onset",
39
- plan: a.kind,
40
- atFrame: y,
41
- playbackSource: C,
39
+ plan: o.kind,
40
+ atFrame: x,
41
+ playbackSource: T,
42
42
  gate: t,
43
- calibration: p.calibration
44
- }), a.kind === "ignore") return;
45
- a.kind === "barge-in" && (u.onBargeIn(), D({
43
+ calibration: h.calibration
44
+ }), o.kind === "ignore") return;
45
+ o.kind === "barge-in" && (i.onBargeIn(), A({
46
46
  type: "stopped-playback",
47
- frame: y
48
- }), p.playbackStopped(), C = null, k(), u.transport.recognitionOwner === "transport" && (T = d(() => {
49
- T = null, w += 1, D({ type: "nothing-heard" }), u.onNothingHeard?.(), r(w) && O("phantom-barge-ins");
50
- }, e))), x && u.transport.cancelUtterance(x);
51
- let o = g.open();
52
- S += 1, b = {
53
- id: `u${S}`,
54
- epoch: o
55
- }, x = b.id, u.transport.openUtterance({
56
- utteranceId: b.id,
57
- epoch: o,
58
- preRoll: h.snapshot()
47
+ frame: x
48
+ }), h.playbackStopped(), T = null, M(), i.transport.recognitionOwner === "transport" && (O = p(() => {
49
+ O = null, D += 1, A({ type: "nothing-heard" }), i.onNothingHeard?.(), r(D) && j("phantom-barge-ins");
50
+ }, e))), C && i.transport.cancelUtterance(C);
51
+ let s = v.open();
52
+ w += 1, S = {
53
+ id: `u${w}`,
54
+ epoch: s
55
+ }, C = S.id, i.transport.openUtterance({
56
+ utteranceId: S.id,
57
+ epoch: s,
58
+ preRoll: _.snapshot()
59
59
  });
60
- }, N = (e) => {
61
- if (!v) return;
62
- y += 1, A(u.getPlaybackSource()), u.getHeadsetHint && p.setHeadset(u.getHeadsetHint());
63
- let t = p.pushFrame(e.rmsDb, e.refDb), n = new Int16Array(e.pcm);
64
- h.push(n);
65
- let r = m.push({
60
+ }, L = (e) => {
61
+ if (!b) return;
62
+ x += 1, P(N(i.getPlaybackSource(), e.refDb)), i.getHeadsetHint && h.setHeadset(i.getHeadsetHint());
63
+ let t = h.pushFrame(e.rmsDb, e.refDb), n = new Int16Array(e.pcm);
64
+ _.push(n);
65
+ let r = g.push({
66
66
  rmsDb: e.rmsDb,
67
67
  zcr: e.zcr
68
68
  }, t.pass);
69
- if (r.event === "onset" && M(t.reason), b && r.voiced && t.pass) {
70
- let t = u.now?.() ?? performance.now(), n = _?.context ? Math.max(0, (_.context.currentTime - e.ctxTime) * 1e3) : 0;
71
- u.onSpeechFrame?.(t - n);
69
+ if (r.event === "onset" && I(t.reason), S && r.voiced && t.pass) {
70
+ let t = i.now?.() ?? performance.now(), n = y?.context ? Math.max(0, (y.context.currentTime - e.ctxTime) * 1e3) : 0;
71
+ i.onSpeechFrame?.(t - n);
72
72
  }
73
- r.event !== "onset" && b && r.inSegment && u.transport.pushFrame(n), r.event === "end" && j();
74
- }, P = () => {
75
- if (!v && !_) return;
76
- v = !1, k(), b && u.transport.cancelUtterance(b.id), b = null, g.invalidate(), u.transport.stop(), h.clear(), p.reset(), m.reset();
77
- let e = _;
78
- _ = null, e?.stop();
73
+ r.event !== "onset" && S && r.inSegment && i.transport.pushFrame(n), r.event === "end" && F();
74
+ }, R = () => {
75
+ if (!b && !y) return;
76
+ b = !1, M(), S && i.transport.cancelUtterance(S.id), S = null, v.invalidate(), i.transport.stop(), _.clear(), h.reset(), g.reset();
77
+ let e = y;
78
+ y = null, e?.stop();
79
79
  };
80
80
  return {
81
81
  async start() {
82
- if (v || E) return;
83
- let e = u.getSession();
84
- if (!u.isEnabled() || e.muted || e.phase === "ended" || e.phase === "idle") return;
85
- v = !0;
82
+ if (b || k) return;
83
+ let e = i.getSession();
84
+ if (!i.isEnabled() || e.muted || e.phase === "ended" || e.phase === "idle") return;
85
+ b = !0;
86
86
  try {
87
- _ = await u.startCapture(N);
87
+ y = await i.startCapture(L);
88
88
  } catch (e) {
89
- v = !1, O(e instanceof a && e.reason === "not-allowed" ? "mic-denied" : "mic-unavailable");
89
+ b = !1, j(e instanceof o && e.reason === "not-allowed" ? "mic-denied" : "mic-unavailable");
90
90
  return;
91
91
  }
92
- if (!v) {
93
- _.stop(), _ = null;
92
+ if (!b) {
93
+ y.stop(), y = null;
94
94
  return;
95
95
  }
96
- let t = _ && "context" in _ && _.context && _.micSource && _.track ? {
97
- context: _.context,
98
- micSource: _.micSource,
99
- track: _.track
96
+ let t = y && "context" in y && y.context && y.micSource && y.track ? {
97
+ context: y.context,
98
+ micSource: y.micSource,
99
+ track: y.track
100
100
  } : null;
101
- await u.transport.start(t, u.language(), {
101
+ await i.transport.start(t, i.language(), {
102
102
  onTranscript(e) {
103
- g.accepts(e.epoch) ? (k(), u.onTranscript(e.text, e.final, e.language)) : D({
103
+ v.accepts(e.epoch) ? (M(), i.onTranscript(e.text, e.final, e.language)) : A({
104
104
  type: "stale-transcript-dropped",
105
105
  epoch: e.epoch,
106
- current: g.current()
106
+ current: v.current()
107
107
  });
108
108
  },
109
109
  onError(e) {
110
- O(l[e.code]);
110
+ j(f[e.code]);
111
111
  }
112
112
  });
113
113
  },
114
- stop: P,
114
+ stop: R,
115
115
  get frames() {
116
- return y;
116
+ return x;
117
117
  },
118
- feed: N,
119
- epoch: g,
118
+ feed: L,
119
+ epoch: v,
120
120
  get running() {
121
- return v;
121
+ return b;
122
122
  }
123
123
  };
124
124
  }
125
- export { u as createHandsFreeController };
125
+ export { p as createHandsFreeController };
@@ -24,8 +24,13 @@ export declare function resolveStoredHandsFree(value: unknown): boolean;
24
24
  * override included (`useLiveAvatarHandsFreeGuard`). Its voice plays on the
25
25
  * speakers, where the microphone hears it, and hands-free would take it for
26
26
  * the person speaking over the reply. Without an avatar, as before.
27
+ *
28
+ * ★ P5 (BOFF-12936) lifts that rule only where `avatarEchoReference` is true:
29
+ * the host opted in (`AssistantLiveAvatarSeam.handsFreeWithAvatar`) and this
30
+ * browser can route the avatar's received voice into the echo gate's reference
31
+ * (`isAvatarVoiceReferenceSupported`). The person's own setting still decides.
27
32
  */
28
- export declare function resolveHandsFreeEnabled(stored: unknown, override: unknown, avatarOn?: boolean): boolean;
33
+ export declare function resolveHandsFreeEnabled(stored: unknown, override: unknown, avatarOn?: boolean, avatarEchoReference?: boolean): boolean;
29
34
  export declare function readHandsFreeOverride(): HandsFreeOverride | undefined;
30
35
  export type TransportOverride = 'web-speech' | 'audio-track' | 'backend-stream';
31
36
  export declare function readTransportOverride(): TransportOverride | undefined;
@@ -3,8 +3,8 @@ var e = "__boffHandsFreeInterrupt", t = "__boffHandsFreeTransport";
3
3
  function n(e) {
4
4
  return e === !0;
5
5
  }
6
- function r(e, t, r = !1) {
7
- return r ? !1 : t === "on" || t !== "off" && n(e);
6
+ function r(e, t, r = !1, i = !1) {
7
+ return r && !i ? !1 : t === "on" || t !== "off" && n(e);
8
8
  }
9
9
  function i(e) {
10
10
  try {
@@ -18,13 +18,48 @@
18
18
  * The device `speechSynthesis` voice does not pass through the browser's output
19
19
  * graph and cannot be tapped. It reports itself through `setDeviceVoice` so the
20
20
  * gate can switch to its no-reference mode; the browser engine calls it.
21
+ *
22
+ * ★ P5, the live avatar's voice (BOFF-12936). The avatar does not speak through
23
+ * an element made here: its voice arrives on a WebRTC track that the avatar room
24
+ * plays in its own element. While the avatar is connected its controller
25
+ * registers here (`registerAvatarVoice`) and hands over the received track once
26
+ * the room has it (`setTrack`). While a capture graph is attached the track is
27
+ * routed
28
+ * track -> MediaStreamSource -> reference bus
29
+ * and NOT to the speakers (the room's element already plays it), so the echo
30
+ * gate meters the avatar's voice on the microphone's clock exactly as it meters
31
+ * the hosted voice. FAIL CLOSED: while an avatar is registered and its voice is
32
+ * not routed (no track yet, no MediaStreamSource, a routing error), the source
33
+ * is 'avatar-unrouted': there is no reference, so the controller treats the
34
+ * avatar like the device voice while a reply is spoken, and tap-to-interrupt
35
+ * stays the fallback.
36
+ */
37
+ export type PlaybackSource = 'hosted' | 'avatar' | 'avatar-unrouted' | 'device' | null;
38
+ /** The avatar controller's handle on its voice reference (P5). */
39
+ export interface AvatarVoiceRegistration {
40
+ /** The avatar's received audio track, once the room has it; null when it has none to give. */
41
+ setTrack(track: MediaStreamTrack | null): void;
42
+ /** The avatar disconnected: stop referencing its voice. Idempotent. */
43
+ release(): void;
44
+ }
45
+ /**
46
+ * Whether this browser can route a received audio track into the reference bus
47
+ * so that the gate hears the avatar. Without it the avatar's voice can never be
48
+ * referenced, so the avatar pilot rule (hands-free OFF while the avatar is ON)
49
+ * must hold. WebKit is excluded until proven (see `isWebKitEngine`).
21
50
  */
22
- export type PlaybackSource = 'hosted' | 'device' | null;
51
+ export declare function isAvatarVoiceReferenceSupported(): boolean;
52
+ /**
53
+ * Register a connected live avatar (P5). Until `setTrack` gives a track that is
54
+ * routed, the playback source reads 'avatar-unrouted' (fail closed).
55
+ */
56
+ export declare function registerAvatarVoice(): AvatarVoiceRegistration;
23
57
  export declare function attachPlaybackReference(context: AudioContext, referenceBus: AudioNode): void;
24
58
  /**
25
59
  * Stop referencing. `closeContext` is run now, or - if a tapped element is
26
60
  * still playing through the context - when the last one ends, so muting the
27
- * microphone never cuts a reply off mid-word.
61
+ * microphone never cuts a reply off mid-word. An avatar's voice route belongs to
62
+ * the closing context, so it is dropped now; the next attach routes it again.
28
63
  */
29
64
  export declare function detachPlaybackReference(closeContext: () => void): void;
30
65
  /**
@@ -42,7 +77,14 @@ export declare function tapPlaybackElement(element: HTMLMediaElement): void;
42
77
  /** Cut every tapped element's output at once (a barge-in). */
43
78
  export declare function silencePlaybackReference(): void;
44
79
  export declare function setDeviceVoice(speaking: boolean): void;
45
- /** What is making sound right now, if anything. */
80
+ /**
81
+ * What is making sound right now, if anything. A connected avatar is reported
82
+ * the whole time it is connected, silent or not ('avatar' when its voice is
83
+ * routed, 'avatar-unrouted' when not): the controller decides from the
84
+ * reference level when it is audible, and from the session when an unrouted
85
+ * one may be speaking. The device voice wins over a connected avatar: it has no
86
+ * reference, so while it speaks nothing on the reference bus can explain it.
87
+ */
46
88
  export declare function activePlaybackSource(): PlaybackSource;
47
89
  /** Test seam: forget everything. */
48
90
  export declare function resetPlaybackReferenceForTest(): void;