@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.
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +8 -1
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +126 -123
- package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +7 -0
- package/dist/shared/assistant/avatar/live/liveAvatarController.js +3 -2
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/ui/AssistantAvatar.js +18 -14
- package/dist/shared/assistant/ui/AssistantChatArea.js +1 -0
- package/dist/shared/assistant/ui/AssistantMessageItem.d.ts +5 -0
- package/dist/shared/assistant/ui/AssistantMessageItem.js +57 -56
- package/dist/shared/assistant/ui/AssistantMessageList.js +57 -44
- package/dist/shared/assistant/ui/AssistantTurnActivity.d.ts +2 -0
- package/dist/shared/assistant/ui/AssistantTurnActivity.js +20 -17
- package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +26 -0
- package/dist/shared/assistant/ui/assistantLiveAvatarSeam.js +87 -79
- package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +5 -0
- package/dist/shared/assistant/ui/composer/AssistantComposer.js +348 -343
- package/dist/shared/assistant/ui/composer/AssistantDictation.js +57 -56
- package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.d.ts +4 -0
- package/dist/shared/assistant/ui/composer/AssistantHandsFreeInterruptToggle.js +22 -22
- package/dist/shared/assistant/ui/composer/pageBoxClass.d.ts +13 -0
- package/dist/shared/assistant/ui/composer/pageBoxClass.js +5 -0
- package/dist/shared/assistant/ui/useVoiceSession.js +223 -223
- package/dist/shared/assistant/ui/voice/AssistantPageVoiceBar.js +41 -35
- package/dist/shared/assistant/ui/voice/AssistantVoiceSessionButton.js +13 -12
- package/dist/shared/assistant/ui/voice/LiveWaveform.js +28 -27
- package/dist/shared/assistant/voice/handsfree/handsFreeController.js +79 -79
- package/dist/shared/assistant/voice/handsfree/handsFreeSetting.d.ts +6 -1
- package/dist/shared/assistant/voice/handsfree/handsFreeSetting.js +2 -2
- package/dist/shared/assistant/voice/handsfree/playbackReference.d.ts +45 -3
- package/dist/shared/assistant/voice/handsfree/playbackReference.js +62 -15
- package/dist/shared-assistant.js +371 -370
- package/package.json +1 -1
- package/src/shared/styles/app-shell.css +5 -0
- package/src/shared/tokens/build/semantic.css +12 -0
- package/src/shared/tokens/build/tailwind.preset.js +5 -0
- package/src/shared/tokens/build/themes.css +14 -0
- 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: "
|
|
19
|
-
talking: "
|
|
20
|
-
waiting: "
|
|
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: "
|
|
25
|
-
talking: "
|
|
26
|
-
waiting: "
|
|
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 =
|
|
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
|
-
},
|
|
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(
|
|
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
|
|
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
|
|
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:
|
|
96
|
+
caption: C(e, t)
|
|
91
97
|
};
|
|
92
98
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
99
|
+
function T(t) {
|
|
100
|
+
return w(e(), t);
|
|
95
101
|
}
|
|
96
|
-
function
|
|
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
|
|
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
|
|
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
|
-
] }),
|
|
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:
|
|
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:
|
|
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 ? `${
|
|
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: `${
|
|
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
|
-
},
|
|
216
|
-
let i = e(), { rootRef: l, stage: u, muted: d, attachments: f, preparingAttachments: p, attachmentsLocked: m } = r, y = _(u, d),
|
|
217
|
-
|
|
218
|
-
let
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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:
|
|
262
|
+
className: `text-base font-semibold text-text-primary ${b[y]}`,
|
|
257
263
|
"data-testid": "assistant-voice-title",
|
|
258
|
-
children:
|
|
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:
|
|
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(
|
|
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(
|
|
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 {
|
|
296
|
+
export { M as AssistantPageVoiceBar };
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useAssistantTr as e } from "../../i18n.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
6
|
-
let
|
|
7
|
-
return /* @__PURE__ */
|
|
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:
|
|
10
|
-
disabled:
|
|
11
|
-
className:
|
|
12
|
-
"aria-label":
|
|
13
|
-
title:
|
|
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
|
|
16
|
+
children: /* @__PURE__ */ r(n, { className: o ? "size-5" : "size-4" })
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
|
-
export {
|
|
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 {
|
|
4
|
-
import {
|
|
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
|
|
7
|
-
let
|
|
8
|
-
return
|
|
9
|
-
let t =
|
|
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,
|
|
14
|
-
if (i === 0 ||
|
|
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,
|
|
17
|
-
let t = u * 5 -
|
|
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 =
|
|
20
|
-
typeof r.roundRect == "function" ? (r.beginPath(), r.roundRect(
|
|
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)),
|
|
25
|
-
|
|
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 =
|
|
31
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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":
|
|
45
|
-
"data-tone":
|
|
46
|
-
children: /* @__PURE__ */
|
|
47
|
-
ref:
|
|
48
|
-
className: `absolute inset-0 ${
|
|
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 {
|
|
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 {
|
|
4
|
-
import { MicCaptureError as
|
|
5
|
-
import { PreRollRing as
|
|
6
|
-
import { DEFAULT_VAD_PARAMS as
|
|
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
|
|
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
|
|
17
|
-
let
|
|
18
|
-
|
|
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
|
-
}),
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
if (e ===
|
|
26
|
-
let t =
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
let
|
|
32
|
-
enabled:
|
|
33
|
-
muted:
|
|
34
|
-
phase:
|
|
35
|
-
playbackAudible:
|
|
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 (
|
|
37
|
+
if (A({
|
|
38
38
|
type: "onset",
|
|
39
|
-
plan:
|
|
40
|
-
atFrame:
|
|
41
|
-
playbackSource:
|
|
39
|
+
plan: o.kind,
|
|
40
|
+
atFrame: x,
|
|
41
|
+
playbackSource: T,
|
|
42
42
|
gate: t,
|
|
43
|
-
calibration:
|
|
44
|
-
}),
|
|
45
|
-
|
|
43
|
+
calibration: h.calibration
|
|
44
|
+
}), o.kind === "ignore") return;
|
|
45
|
+
o.kind === "barge-in" && (i.onBargeIn(), A({
|
|
46
46
|
type: "stopped-playback",
|
|
47
|
-
frame:
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
}, e))),
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
id: `u${
|
|
54
|
-
epoch:
|
|
55
|
-
},
|
|
56
|
-
utteranceId:
|
|
57
|
-
epoch:
|
|
58
|
-
preRoll:
|
|
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
|
-
},
|
|
61
|
-
if (!
|
|
62
|
-
|
|
63
|
-
let t =
|
|
64
|
-
|
|
65
|
-
let r =
|
|
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" &&
|
|
70
|
-
let t =
|
|
71
|
-
|
|
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" &&
|
|
74
|
-
},
|
|
75
|
-
if (!
|
|
76
|
-
|
|
77
|
-
let e =
|
|
78
|
-
|
|
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 (
|
|
83
|
-
let e =
|
|
84
|
-
if (!
|
|
85
|
-
|
|
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
|
-
|
|
87
|
+
y = await i.startCapture(L);
|
|
88
88
|
} catch (e) {
|
|
89
|
-
|
|
89
|
+
b = !1, j(e instanceof o && e.reason === "not-allowed" ? "mic-denied" : "mic-unavailable");
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
if (!
|
|
93
|
-
|
|
92
|
+
if (!b) {
|
|
93
|
+
y.stop(), y = null;
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
let t =
|
|
97
|
-
context:
|
|
98
|
-
micSource:
|
|
99
|
-
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
|
|
101
|
+
await i.transport.start(t, i.language(), {
|
|
102
102
|
onTranscript(e) {
|
|
103
|
-
|
|
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:
|
|
106
|
+
current: v.current()
|
|
107
107
|
});
|
|
108
108
|
},
|
|
109
109
|
onError(e) {
|
|
110
|
-
|
|
110
|
+
j(f[e.code]);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
},
|
|
114
|
-
stop:
|
|
114
|
+
stop: R,
|
|
115
115
|
get frames() {
|
|
116
|
-
return
|
|
116
|
+
return x;
|
|
117
117
|
},
|
|
118
|
-
feed:
|
|
119
|
-
epoch:
|
|
118
|
+
feed: L,
|
|
119
|
+
epoch: v,
|
|
120
120
|
get running() {
|
|
121
|
-
return
|
|
121
|
+
return b;
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
|
-
export {
|
|
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
|
|
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
|
-
/**
|
|
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;
|