@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
|
@@ -6,44 +6,44 @@ import { silencePlaybackReference as te } from "../voice/handsfree/playbackRefer
|
|
|
6
6
|
import { primeHostedPlayback as ne } from "../speech/hostedTtsSpeechEngine.js";
|
|
7
7
|
import { turnClockMs as i } from "../turnTimeline.js";
|
|
8
8
|
import { useAssistantSpeech as re } from "./AssistantSpeechProvider.js";
|
|
9
|
-
import {
|
|
10
|
-
import { captionChunks as
|
|
9
|
+
import { useLiveAvatarEchoReference as ie, useLiveAvatarOn as ae } from "./assistantLiveAvatarSeam.js";
|
|
10
|
+
import { captionChunks as oe } from "../voice/speechPlayback.js";
|
|
11
11
|
import { speechFeed as a } from "../speech/speechFeed.js";
|
|
12
|
-
import { planSubmitTimer as
|
|
13
|
-
import { isTurnSuperseded as
|
|
14
|
-
import { INITIAL_SESSION as le, INTERRUPT_MAX_MS as ue, NOTHING_HEARD as de, advanceHeardClock as fe, isCapturing as pe, isSubmittable as me, planListeningHold as he, planReplyConsumption as ge, planVoiceAnnouncement as _e, shouldRecognise as ve, spokenSoFar as
|
|
15
|
-
import { useCallback as
|
|
12
|
+
import { planSubmitTimer as se, resolveVoiceGraceMs as ce } from "../voice/handsFree.js";
|
|
13
|
+
import { isTurnSuperseded as o } from "../voice/supersededTurns.js";
|
|
14
|
+
import { INITIAL_SESSION as le, INTERRUPT_MAX_MS as ue, NOTHING_HEARD as de, advanceHeardClock as fe, isCapturing as pe, isSubmittable as me, planListeningHold as he, planReplyConsumption as ge, planVoiceAnnouncement as _e, shouldRecognise as ve, spokenSoFar as s, voiceSessionReducer as ye } from "../voice/voiceSession.js";
|
|
15
|
+
import { useCallback as c, useEffect as l, useLayoutEffect as be, useMemo as xe, useReducer as Se, useRef as u, useState as d } from "react";
|
|
16
16
|
// src/shared/assistant/ui/useVoiceSession.ts
|
|
17
17
|
var Ce = 4e3, we = 2500, Te = 5e3, Ee = 12e3;
|
|
18
|
-
function De({ onSubmit: De, latestReply:
|
|
19
|
-
let
|
|
18
|
+
function De({ onSubmit: De, latestReply: f, language: p, graceMs: Oe, onSupersede: ke, handsFreeInterrupt: Ae, handsFreeStreamNoticeAccepted: je, onAcceptHandsFreeStreamNotice: Me, onBargeIn: Ne }) {
|
|
19
|
+
let m = ce(Oe), h = u(null), Pe = c((e, t) => ye(e, t, h.current), []), [g, _] = Se(Pe, le), v = re(), { setSessionSpeaking: y, setSessionMicOpen: b, speakingMessageId: x, stop: S } = v, Fe = u(v.toggle), Ie = v.toggle;
|
|
20
20
|
be(() => {
|
|
21
21
|
Fe.current = Ie;
|
|
22
22
|
}, [Ie]);
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
let e =
|
|
26
|
-
if (e && e !==
|
|
27
|
-
|
|
28
|
-
for (let [t, n] of k.current) e.accepted && t >= e.candidateId && (
|
|
23
|
+
let C = u(null), w = u({}), T = u(de), E = u(void 0), D = u(void 0), Le = u(0), O = u(void 0), k = u(/* @__PURE__ */ new Map()), Re = u(void 0);
|
|
24
|
+
l(() => {
|
|
25
|
+
let e = g.correctionTimingDecision;
|
|
26
|
+
if (e && e !== Re.current) {
|
|
27
|
+
Re.current = e;
|
|
28
|
+
for (let [t, n] of k.current) e.accepted && t >= e.candidateId && (E.current = n.lastSpeechFrame ?? E.current, D.current = n.recognizerSpeechEnded ?? D.current), (e.accepted || t <= e.candidateId) && k.current.delete(t);
|
|
29
29
|
O.current !== void 0 && O.current <= e.candidateId && (O.current = void 0);
|
|
30
30
|
}
|
|
31
|
-
(
|
|
31
|
+
(g.phase !== "thinking" || g.muted) && (k.current.clear(), O.current = void 0), (g.phase === "idle" || g.phase === "ended") && (E.current = void 0, D.current = void 0);
|
|
32
32
|
}, [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
g.phase,
|
|
34
|
+
g.muted,
|
|
35
|
+
g.correctionTimingDecision
|
|
36
36
|
]);
|
|
37
|
-
let A =
|
|
38
|
-
z.current =
|
|
39
|
-
let B =
|
|
37
|
+
let A = u(null), ze = u(!1), [Be, j] = d(null), M = u(null), [Ve, N] = d(null), [P, F] = d(!1), [He, I] = d(!1), [L, R] = d(!1), z = u(g);
|
|
38
|
+
z.current = g;
|
|
39
|
+
let B = u([]), V = u(null), H = u(!1), U = c(() => {
|
|
40
40
|
B.current = [], V.current = null, H.current = !1;
|
|
41
|
-
}, []), W =
|
|
41
|
+
}, []), W = c(() => {
|
|
42
42
|
for (;;) {
|
|
43
43
|
let e = B.current.shift();
|
|
44
44
|
if (!e) return !1;
|
|
45
45
|
if (!e.stillWanted || e.stillWanted()) {
|
|
46
|
-
V.current = e,
|
|
46
|
+
V.current = e, h.current = h.current ? `${h.current} ${e.text}` : e.text;
|
|
47
47
|
try {
|
|
48
48
|
Fe.current(e.id, e.text, e.lang);
|
|
49
49
|
} catch {
|
|
@@ -53,178 +53,178 @@ function De({ onSubmit: De, latestReply: d, language: f, graceMs: Oe, onSupersed
|
|
|
53
53
|
return !0;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
}, []), G =
|
|
56
|
+
}, []), G = u(!1), Ue = c((e) => {
|
|
57
57
|
let t = he({
|
|
58
58
|
requested: e,
|
|
59
59
|
held: G.current,
|
|
60
60
|
muted: z.current.muted
|
|
61
61
|
});
|
|
62
|
-
G.current = t.held, t.mute !== null &&
|
|
62
|
+
G.current = t.held, t.mute !== null && _({
|
|
63
63
|
type: "mute",
|
|
64
64
|
muted: t.mute
|
|
65
65
|
});
|
|
66
|
-
}, []), K =
|
|
66
|
+
}, []), K = c((e) => {
|
|
67
67
|
let t = _e(z.current);
|
|
68
|
-
t !== "drop" && (V.current?.id === e.id || B.current.some((t) => t.id === e.id) || (B.current.push(e), t === "start" && !H.current && (H.current = !0,
|
|
69
|
-
}, []),
|
|
70
|
-
z.current.phase === "thinking" ? (B.current.push(e), H.current = !0,
|
|
71
|
-
}, [K]),
|
|
72
|
-
|
|
73
|
-
if (
|
|
68
|
+
t !== "drop" && (V.current?.id === e.id || B.current.some((t) => t.id === e.id) || (B.current.push(e), t === "start" && !H.current && (H.current = !0, _({ type: "announce" }))));
|
|
69
|
+
}, []), We = c((e) => {
|
|
70
|
+
z.current.phase === "thinking" ? (B.current.push(e), H.current = !0, _({ type: "answered-locally" })) : K(e);
|
|
71
|
+
}, [K]), Ge = u(f);
|
|
72
|
+
Ge.current = f, l(() => {
|
|
73
|
+
if (g.phase === "speaking") {
|
|
74
74
|
let e = M.current;
|
|
75
|
-
|
|
75
|
+
h.current = e && A.current === e.id && f?.id !== e.id ? e.text : f?.text ?? null;
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
if (
|
|
78
|
+
if (h.current === null) return;
|
|
79
79
|
let e = setTimeout(() => {
|
|
80
|
-
|
|
80
|
+
h.current = null;
|
|
81
81
|
}, we);
|
|
82
82
|
return () => clearTimeout(e);
|
|
83
|
-
}, [
|
|
84
|
-
let
|
|
85
|
-
|
|
86
|
-
let
|
|
83
|
+
}, [g.phase, f]);
|
|
84
|
+
let Ke = u(p);
|
|
85
|
+
Ke.current = p;
|
|
86
|
+
let qe = c((e, t) => {
|
|
87
87
|
let n = z.current;
|
|
88
88
|
if (!n.muted) {
|
|
89
89
|
if (n.phase === "thinking") {
|
|
90
90
|
e === "lastSpeechFrame" && (O.current = void 0);
|
|
91
|
-
let n = O.current ??
|
|
91
|
+
let n = O.current ?? Le.current, r = k.current.get(n) ?? {};
|
|
92
92
|
r[e] = t, k.current.set(n, r);
|
|
93
|
-
} else n.phase === "listening" && (e === "lastSpeechFrame" ?
|
|
93
|
+
} else n.phase === "listening" && (e === "lastSpeechFrame" ? E.current = t : D.current = t);
|
|
94
94
|
}
|
|
95
|
-
}, []), q =
|
|
95
|
+
}, []), q = c((e) => {
|
|
96
96
|
let t = z.current;
|
|
97
97
|
if (t.phase !== "thinking" || t.muted) return;
|
|
98
|
-
let n =
|
|
99
|
-
return e && (O.current = n,
|
|
100
|
-
}, []), J =
|
|
101
|
-
|
|
98
|
+
let n = Le.current;
|
|
99
|
+
return e && (O.current = n, Le.current += 1), n;
|
|
100
|
+
}, []), J = c((e, t) => {
|
|
101
|
+
_({
|
|
102
102
|
type: "speech",
|
|
103
103
|
transcript: e,
|
|
104
104
|
final: t,
|
|
105
105
|
at: Date.now(),
|
|
106
|
-
language:
|
|
106
|
+
language: Ke.current,
|
|
107
107
|
timingCandidateId: q(t)
|
|
108
108
|
});
|
|
109
|
-
}, [q]),
|
|
110
|
-
|
|
109
|
+
}, [q]), Je = c((e, t, n) => {
|
|
110
|
+
_({
|
|
111
111
|
type: "speech",
|
|
112
112
|
transcript: e,
|
|
113
113
|
final: t,
|
|
114
114
|
at: Date.now(),
|
|
115
|
-
language: n ??
|
|
115
|
+
language: n ?? Ke.current,
|
|
116
116
|
gated: !0,
|
|
117
117
|
timingCandidateId: q(t)
|
|
118
118
|
});
|
|
119
|
-
}, [q]),
|
|
120
|
-
U(),
|
|
121
|
-
}, [
|
|
122
|
-
onFinalize:
|
|
123
|
-
language:
|
|
124
|
-
deviceId:
|
|
119
|
+
}, [q]), Ye = u(0), Xe = c(() => {
|
|
120
|
+
U(), S(), Ye.current = Date.now(), F(!0), _({ type: "interrupt" });
|
|
121
|
+
}, [S, U]), Ze = c((e) => J(e, !0), [J]), Qe = e((e) => e.micDeviceId), Y = t({
|
|
122
|
+
onFinalize: Ze,
|
|
123
|
+
language: p,
|
|
124
|
+
deviceId: Qe,
|
|
125
125
|
onSpeechEnd: (e) => {
|
|
126
|
-
|
|
126
|
+
qe("recognizerSpeechEnded", e);
|
|
127
127
|
}
|
|
128
|
-
}),
|
|
129
|
-
|
|
130
|
-
let
|
|
131
|
-
U(), te(),
|
|
132
|
-
}, [
|
|
133
|
-
enabled: ee(Ae, r(),
|
|
134
|
-
phase:
|
|
135
|
-
muted:
|
|
136
|
-
language:
|
|
128
|
+
}), $e = Y.stop, et = u(Ne);
|
|
129
|
+
et.current = Ne;
|
|
130
|
+
let tt = c(() => {
|
|
131
|
+
U(), te(), S(), Ye.current = Date.now(), F(!0), _({ type: "interrupt" }), et.current?.();
|
|
132
|
+
}, [S, U]), nt = ae(), rt = ie(), X = n({
|
|
133
|
+
enabled: ee(Ae, r(), nt, rt),
|
|
134
|
+
phase: g.phase,
|
|
135
|
+
muted: g.muted,
|
|
136
|
+
language: p,
|
|
137
137
|
streamNoticeAccepted: je ?? null,
|
|
138
138
|
onAcceptStreamNotice: Me,
|
|
139
|
-
onBargeIn:
|
|
140
|
-
onTranscript:
|
|
139
|
+
onBargeIn: tt,
|
|
140
|
+
onTranscript: Je,
|
|
141
141
|
onSpeechFrame: (e) => {
|
|
142
|
-
|
|
142
|
+
qe("lastSpeechFrame", e);
|
|
143
143
|
}
|
|
144
|
-
}),
|
|
145
|
-
|
|
144
|
+
}), it = X.mode === "notice", Z = Y.isListening || X.suppressWebSpeech && X.mode === "active";
|
|
145
|
+
l(() => {
|
|
146
146
|
Y.interim && J(Y.interim, !1);
|
|
147
|
-
}, [Y.interim, J]),
|
|
148
|
-
|
|
149
|
-
let e =
|
|
150
|
-
phase:
|
|
151
|
-
muted:
|
|
152
|
-
spoken:
|
|
147
|
+
}, [Y.interim, J]), l(() => {
|
|
148
|
+
C.current && clearTimeout(C.current), I(!1), T.current = fe(T.current, g, i());
|
|
149
|
+
let e = se({
|
|
150
|
+
phase: g.phase,
|
|
151
|
+
muted: g.muted,
|
|
152
|
+
spoken: s(g),
|
|
153
153
|
holding: L,
|
|
154
|
-
graceMs:
|
|
154
|
+
graceMs: m
|
|
155
155
|
});
|
|
156
156
|
if (!e.arm) return;
|
|
157
157
|
let t = setTimeout(() => I(!0), Math.min(800, e.delayMs)), n = i();
|
|
158
|
-
return
|
|
159
|
-
|
|
160
|
-
speechEnded:
|
|
161
|
-
lastSpeechFrame:
|
|
162
|
-
recognizerSpeechEnded:
|
|
163
|
-
selectedGraceMs:
|
|
158
|
+
return C.current = setTimeout(() => {
|
|
159
|
+
w.current = {
|
|
160
|
+
speechEnded: T.current.at ?? n,
|
|
161
|
+
lastSpeechFrame: E.current,
|
|
162
|
+
recognizerSpeechEnded: D.current,
|
|
163
|
+
selectedGraceMs: m,
|
|
164
164
|
graceStarted: n,
|
|
165
165
|
graceEnded: i()
|
|
166
|
-
},
|
|
166
|
+
}, _({
|
|
167
167
|
type: "silence",
|
|
168
168
|
at: Date.now()
|
|
169
169
|
});
|
|
170
170
|
}, e.delayMs), () => {
|
|
171
|
-
clearTimeout(t),
|
|
171
|
+
clearTimeout(t), C.current && clearTimeout(C.current);
|
|
172
172
|
};
|
|
173
173
|
}, [
|
|
174
|
-
|
|
174
|
+
g,
|
|
175
175
|
L,
|
|
176
|
-
|
|
177
|
-
]),
|
|
178
|
-
(
|
|
179
|
-
}, [
|
|
176
|
+
m
|
|
177
|
+
]), l(() => {
|
|
178
|
+
(g.phase !== "listening" || g.muted) && R(!1);
|
|
179
|
+
}, [g.phase, g.muted]), l(() => {
|
|
180
180
|
if (!P) return;
|
|
181
|
-
let e = Date.now() -
|
|
181
|
+
let e = Date.now() - Ye.current, t = Z ? Math.max(0, 500 - e) : Math.max(0, ue - e), n = setTimeout(() => F(!1), t);
|
|
182
182
|
return () => clearTimeout(n);
|
|
183
183
|
}, [P, Z]);
|
|
184
|
-
let
|
|
185
|
-
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
let e =
|
|
189
|
-
e && De(e, $.current ?? `vs-orphan-${Date.now().toString(36)}`,
|
|
190
|
-
}, [
|
|
191
|
-
let e = ge(
|
|
192
|
-
e.claim && (A.current =
|
|
184
|
+
let at = u("");
|
|
185
|
+
g.phase === "listening" && (at.current = s(g)), l(() => {
|
|
186
|
+
if (g.phase !== "thinking") return;
|
|
187
|
+
b(!1), U(), N((e) => typeof e == "object" && e ? null : e);
|
|
188
|
+
let e = at.current.trim();
|
|
189
|
+
e && De(e, $.current ?? `vs-orphan-${Date.now().toString(36)}`, w.current, { correction: z.current.correcting }), w.current = {}, T.current = de, E.current = void 0, D.current = void 0;
|
|
190
|
+
}, [g.phase]), l(() => {
|
|
191
|
+
let e = ge(f?.id, g.phase, A.current, o(f?.id));
|
|
192
|
+
e.claim && (A.current = f?.id ?? null, e.advance && f && (f.refused ? (U(), N({
|
|
193
193
|
kind: "turn-refused",
|
|
194
|
-
text:
|
|
195
|
-
}),
|
|
194
|
+
text: f.text
|
|
195
|
+
}), _({ type: "turn-refused" })) : _({
|
|
196
196
|
type: "reply",
|
|
197
|
-
text:
|
|
197
|
+
text: f.text
|
|
198
198
|
})));
|
|
199
199
|
}, [
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
f,
|
|
201
|
+
g.phase,
|
|
202
202
|
U
|
|
203
|
-
]),
|
|
204
|
-
if (
|
|
205
|
-
if (
|
|
206
|
-
|
|
203
|
+
]), l(() => {
|
|
204
|
+
if (x === null || g.phase !== "thinking" || A.current === x) return;
|
|
205
|
+
if (o(x)) {
|
|
206
|
+
S();
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
|
-
let e = a.peek(
|
|
210
|
-
e && e.final && e.channel === "voice" && e.voiceSessionId !== void 0 && e.voiceSessionId === $.current && (A.current =
|
|
211
|
-
id:
|
|
209
|
+
let e = a.peek(x);
|
|
210
|
+
e && e.final && e.channel === "voice" && e.voiceSessionId !== void 0 && e.voiceSessionId === $.current && (A.current = x, M.current = {
|
|
211
|
+
id: x,
|
|
212
212
|
text: e.text
|
|
213
|
-
},
|
|
213
|
+
}, _({
|
|
214
214
|
type: "reply-audio-started",
|
|
215
|
-
replyId:
|
|
215
|
+
replyId: x
|
|
216
216
|
}));
|
|
217
217
|
}, [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
]),
|
|
218
|
+
x,
|
|
219
|
+
g.phase,
|
|
220
|
+
S
|
|
221
|
+
]), l(() => a.subscribe((e) => {
|
|
222
222
|
if (e.type !== "audio") return;
|
|
223
223
|
let t = z.current.phase;
|
|
224
224
|
if (t !== "thinking" && t !== "speaking") return;
|
|
225
225
|
if (e.state === "retrying") {
|
|
226
226
|
if (A.current !== e.messageId || M.current?.id !== e.messageId) return;
|
|
227
|
-
A.current = null, M.current = null, j(e.messageId),
|
|
227
|
+
A.current = null, M.current = null, j(e.messageId), _({ type: "reply-audio-paused" });
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
230
|
if (e.state === "ended") {
|
|
@@ -236,105 +236,105 @@ function De({ onSubmit: De, latestReply: d, language: f, graceMs: Oe, onSupersed
|
|
|
236
236
|
}), j(null);
|
|
237
237
|
let r = M.current;
|
|
238
238
|
t === "thinking" && queueMicrotask(() => {
|
|
239
|
-
M.current === r && z.current.phase === "thinking" &&
|
|
239
|
+
M.current === r && z.current.phase === "thinking" && _({ type: "reply-audio-ended" });
|
|
240
240
|
});
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
|
-
if (
|
|
243
|
+
if (o(e.messageId)) return;
|
|
244
244
|
let n = a.peek(e.messageId);
|
|
245
245
|
if (n && n.channel === "voice" && n.voiceSessionId === $.current) {
|
|
246
246
|
if (e.state === "queued") j(e.messageId), A.current = e.messageId, M.current = {
|
|
247
247
|
id: e.messageId,
|
|
248
248
|
text: n.text
|
|
249
|
-
},
|
|
249
|
+
}, $e();
|
|
250
250
|
else if (A.current !== e.messageId) return;
|
|
251
251
|
else e.state === "started" ? (A.current = e.messageId, M.current = {
|
|
252
252
|
id: e.messageId,
|
|
253
253
|
text: n.text
|
|
254
|
-
},
|
|
254
|
+
}, _({
|
|
255
255
|
type: "reply-audio-started",
|
|
256
256
|
replyId: e.messageId,
|
|
257
257
|
partial: !n.final
|
|
258
|
-
})) : e.state === "paused" && A.current === e.messageId &&
|
|
258
|
+
})) : e.state === "paused" && A.current === e.messageId && _({ type: "reply-audio-paused" });
|
|
259
259
|
}
|
|
260
|
-
}), [
|
|
261
|
-
|
|
262
|
-
}, [
|
|
263
|
-
let e =
|
|
264
|
-
|
|
265
|
-
}, [
|
|
266
|
-
|
|
267
|
-
}, [
|
|
268
|
-
if (
|
|
260
|
+
}), [$e]), l(() => {
|
|
261
|
+
g.phase !== "thinking" && g.phase !== "speaking" && j(null);
|
|
262
|
+
}, [g.phase]), l(() => {
|
|
263
|
+
let e = x !== null;
|
|
264
|
+
ze.current && !e && (V.current = null, z.current.phase === "speaking" && W() || _({ type: "speech-ended" })), ze.current = e;
|
|
265
|
+
}, [x, W]), l(() => {
|
|
266
|
+
g.phase !== "listening" && N((e) => e === "nothing-heard" ? null : e);
|
|
267
|
+
}, [g.phase]), l(() => {
|
|
268
|
+
if (g.phase !== "speaking" || x !== null) return;
|
|
269
269
|
let e = setTimeout(() => {
|
|
270
|
-
|
|
270
|
+
ze.current || (U(), _({ type: "speech-ended" }));
|
|
271
271
|
}, Ce);
|
|
272
272
|
return () => clearTimeout(e);
|
|
273
273
|
}, [
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
g.phase,
|
|
275
|
+
x,
|
|
276
276
|
U
|
|
277
277
|
]);
|
|
278
|
-
let Q =
|
|
279
|
-
|
|
278
|
+
let Q = v.outputNotCleared;
|
|
279
|
+
l(() => {
|
|
280
280
|
if (Q === null || A.current !== Q.messageId) return;
|
|
281
281
|
let { phase: e } = z.current;
|
|
282
282
|
e !== "idle" && e !== "ended" && e !== "thinking" && N("reply-not-heard");
|
|
283
|
-
}, [Q]),
|
|
284
|
-
|
|
285
|
-
}, [
|
|
286
|
-
let
|
|
287
|
-
|
|
288
|
-
let
|
|
289
|
-
|
|
290
|
-
let e =
|
|
291
|
-
e !==
|
|
283
|
+
}, [Q]), l(() => {
|
|
284
|
+
g.phase !== "listening" && g.phase !== "thinking" && N((e) => e === "reply-not-heard" ? null : e);
|
|
285
|
+
}, [g.phase]);
|
|
286
|
+
let ot = u(ke);
|
|
287
|
+
ot.current = ke;
|
|
288
|
+
let st = u(0);
|
|
289
|
+
l(() => {
|
|
290
|
+
let e = g.superseded;
|
|
291
|
+
e !== st.current && (st.current = e, e !== 0 && (U(), S(), ot.current?.()));
|
|
292
292
|
}, [
|
|
293
|
-
|
|
293
|
+
g.superseded,
|
|
294
294
|
U,
|
|
295
|
-
|
|
296
|
-
]),
|
|
297
|
-
let e = pe(
|
|
298
|
-
|
|
295
|
+
S
|
|
296
|
+
]), l(() => {
|
|
297
|
+
let e = pe(g);
|
|
298
|
+
b(e), ve(g) && Be === null && !X.suppressWebSpeech ? Y.isActive || Y.start("auto") : Y.isActive && Y.stop();
|
|
299
299
|
}, [
|
|
300
|
-
|
|
300
|
+
g,
|
|
301
301
|
Y,
|
|
302
|
-
|
|
302
|
+
b,
|
|
303
303
|
X.suppressWebSpeech,
|
|
304
|
-
|
|
305
|
-
]),
|
|
306
|
-
|
|
307
|
-
}, [
|
|
308
|
-
Y.error === "not-allowed" || Y.error === "audio-capture" ?
|
|
304
|
+
Be
|
|
305
|
+
]), l(() => {
|
|
306
|
+
g.phase === "speaking" && H.current && (H.current = !1, W() || _({ type: "speech-ended" }));
|
|
307
|
+
}, [g.phase, W]), l(() => {
|
|
308
|
+
Y.error === "not-allowed" || Y.error === "audio-capture" ? _({
|
|
309
309
|
type: "fail",
|
|
310
310
|
error: "mic-denied"
|
|
311
|
-
}) : Y.error === "language-not-supported" ?
|
|
311
|
+
}) : Y.error === "language-not-supported" ? _({
|
|
312
312
|
type: "fail",
|
|
313
313
|
error: "no-speech-support"
|
|
314
314
|
}) : Y.error === "network" ? N("network") : Y.error === "unknown" && N("recognition-failed");
|
|
315
|
-
}, [Y.error]),
|
|
315
|
+
}, [Y.error]), l(() => {
|
|
316
316
|
Y.error === null && Z && N((e) => e === "network" || e === "recognition-failed" ? null : e);
|
|
317
|
-
}, [Y.error, Z]),
|
|
318
|
-
if (Z && N((e) => e === "not-capturing" ? null : e), !pe(
|
|
317
|
+
}, [Y.error, Z]), l(() => {
|
|
318
|
+
if (Z && N((e) => e === "not-capturing" ? null : e), !pe(g) || Z || it) return;
|
|
319
319
|
let e = setTimeout(() => N("not-capturing"), Te);
|
|
320
320
|
return () => clearTimeout(e);
|
|
321
321
|
}, [
|
|
322
|
-
|
|
322
|
+
g,
|
|
323
323
|
Z,
|
|
324
|
-
|
|
325
|
-
]),
|
|
326
|
-
if (
|
|
324
|
+
it
|
|
325
|
+
]), l(() => {
|
|
326
|
+
if (g.phase !== "listening" || g.muted || !Z || s(g) !== "") return;
|
|
327
327
|
let e = setTimeout(() => N("nothing-heard"), Ee);
|
|
328
328
|
return () => clearTimeout(e);
|
|
329
|
-
}, [
|
|
330
|
-
|
|
331
|
-
}, [
|
|
332
|
-
let $ =
|
|
333
|
-
if (F(!1), I(!1), R(!1), U(), G.current = !1, !Y.isSupported)
|
|
329
|
+
}, [g, Z]), l(() => {
|
|
330
|
+
s(g) !== "" && N(null);
|
|
331
|
+
}, [g]);
|
|
332
|
+
let $ = u(null), ct = c(() => {
|
|
333
|
+
if (F(!1), I(!1), R(!1), U(), G.current = !1, !Y.isSupported) _({
|
|
334
334
|
type: "fail",
|
|
335
335
|
error: "no-speech-support"
|
|
336
336
|
});
|
|
337
|
-
else if (
|
|
337
|
+
else if (v.isBlocked) _({
|
|
338
338
|
type: "fail",
|
|
339
339
|
error: "no-voice-support"
|
|
340
340
|
});
|
|
@@ -346,58 +346,58 @@ function De({ onSubmit: De, latestReply: d, language: f, graceMs: Oe, onSupersed
|
|
|
346
346
|
t.volume = 0, e.speak(t);
|
|
347
347
|
}
|
|
348
348
|
} catch {}
|
|
349
|
-
ne(),
|
|
349
|
+
ne(), y(!0), N(null), A.current = Ge.current?.id ?? null, M.current = null, $.current = `vs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, _({ type: "start" });
|
|
350
350
|
}
|
|
351
351
|
}, [
|
|
352
352
|
Y.isSupported,
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
v.isBlocked,
|
|
354
|
+
y,
|
|
355
355
|
U
|
|
356
|
-
]),
|
|
357
|
-
F(!1), I(!1), R(!1), U(), G.current = !1, $.current = null,
|
|
356
|
+
]), lt = c(() => {
|
|
357
|
+
F(!1), I(!1), R(!1), U(), G.current = !1, $.current = null, _({ type: "end" }), S(), y(!1);
|
|
358
358
|
}, [
|
|
359
|
-
|
|
360
|
-
|
|
359
|
+
S,
|
|
360
|
+
y,
|
|
361
361
|
U
|
|
362
|
-
]),
|
|
362
|
+
]), ut = c((e) => $.current === e, []), dt = c(() => {
|
|
363
363
|
let e = z.current;
|
|
364
364
|
e.phase !== "listening" || e.muted || R(!0);
|
|
365
|
-
}, []),
|
|
365
|
+
}, []), ft = c(() => {
|
|
366
366
|
R(!1);
|
|
367
367
|
let e = z.current;
|
|
368
|
-
if (e.phase !== "listening" || e.muted || !me(
|
|
368
|
+
if (e.phase !== "listening" || e.muted || !me(s(e))) return;
|
|
369
369
|
let t = i();
|
|
370
|
-
|
|
371
|
-
speechEnded:
|
|
372
|
-
lastSpeechFrame:
|
|
373
|
-
recognizerSpeechEnded:
|
|
374
|
-
selectedGraceMs:
|
|
370
|
+
w.current = {
|
|
371
|
+
speechEnded: T.current.at ?? t,
|
|
372
|
+
lastSpeechFrame: E.current,
|
|
373
|
+
recognizerSpeechEnded: D.current,
|
|
374
|
+
selectedGraceMs: m,
|
|
375
375
|
graceStarted: t,
|
|
376
376
|
graceEnded: t
|
|
377
|
-
},
|
|
377
|
+
}, _({
|
|
378
378
|
type: "silence",
|
|
379
379
|
at: Date.now()
|
|
380
380
|
});
|
|
381
|
-
}, [
|
|
382
|
-
|
|
381
|
+
}, [m]), pt = c(() => {
|
|
382
|
+
_({
|
|
383
383
|
type: "mute",
|
|
384
384
|
muted: !z.current.muted
|
|
385
385
|
});
|
|
386
386
|
}, []);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}, [
|
|
390
|
-
let
|
|
387
|
+
l(() => () => {
|
|
388
|
+
y(!1), b(!1);
|
|
389
|
+
}, [y, b]);
|
|
390
|
+
let mt = oe(v.spokenChunks, g.phase, x);
|
|
391
391
|
return xe(() => ({
|
|
392
|
-
session:
|
|
393
|
-
notice:
|
|
394
|
-
spokenChunks:
|
|
392
|
+
session: g,
|
|
393
|
+
notice: Ve ?? (X.fallbackReason !== null && X.fallbackReason !== "notice-declined" ? "hands-free-fallback" : X.nothingHeard ? "hands-free-nothing-heard" : null),
|
|
394
|
+
spokenChunks: mt,
|
|
395
395
|
capturing: Z,
|
|
396
|
-
active:
|
|
396
|
+
active: g.phase !== "idle" && (g.phase !== "ended" || g.error !== null),
|
|
397
397
|
interrupting: P,
|
|
398
|
-
awaitingEndpoint:
|
|
398
|
+
awaitingEndpoint: He,
|
|
399
399
|
holding: L,
|
|
400
|
-
correcting:
|
|
400
|
+
correcting: g.correcting,
|
|
401
401
|
handsFree: {
|
|
402
402
|
mode: X.mode,
|
|
403
403
|
nothingHeard: X.nothingHeard,
|
|
@@ -405,22 +405,22 @@ function De({ onSubmit: De, latestReply: d, language: f, graceMs: Oe, onSupersed
|
|
|
405
405
|
fallbackReason: X.fallbackReason,
|
|
406
406
|
privacyNotice: X.privacyNotice
|
|
407
407
|
},
|
|
408
|
-
available: Y.isSupported && !
|
|
409
|
-
start:
|
|
410
|
-
end:
|
|
411
|
-
isCurrentSession:
|
|
412
|
-
toggleMute:
|
|
413
|
-
interrupt:
|
|
414
|
-
letMeFinish:
|
|
415
|
-
imDone:
|
|
408
|
+
available: Y.isSupported && !v.isBlocked,
|
|
409
|
+
start: ct,
|
|
410
|
+
end: lt,
|
|
411
|
+
isCurrentSession: ut,
|
|
412
|
+
toggleMute: pt,
|
|
413
|
+
interrupt: Xe,
|
|
414
|
+
letMeFinish: dt,
|
|
415
|
+
imDone: ft,
|
|
416
416
|
announce: K,
|
|
417
|
-
holdListening:
|
|
418
|
-
answerLocally:
|
|
417
|
+
holdListening: Ue,
|
|
418
|
+
answerLocally: We
|
|
419
419
|
}), [
|
|
420
|
-
|
|
421
|
-
Be,
|
|
422
|
-
P,
|
|
420
|
+
g,
|
|
423
421
|
Ve,
|
|
422
|
+
P,
|
|
423
|
+
He,
|
|
424
424
|
L,
|
|
425
425
|
Z,
|
|
426
426
|
X.mode,
|
|
@@ -429,18 +429,18 @@ function De({ onSubmit: De, latestReply: d, language: f, graceMs: Oe, onSupersed
|
|
|
429
429
|
X.fallbackReason,
|
|
430
430
|
X.privacyNotice,
|
|
431
431
|
Y.isSupported,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
ot,
|
|
435
|
-
st,
|
|
432
|
+
v.isBlocked,
|
|
433
|
+
mt,
|
|
436
434
|
ct,
|
|
437
|
-
dt,
|
|
438
|
-
Ye,
|
|
439
435
|
lt,
|
|
440
436
|
ut,
|
|
437
|
+
pt,
|
|
438
|
+
Xe,
|
|
439
|
+
dt,
|
|
440
|
+
ft,
|
|
441
441
|
K,
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
Ue,
|
|
443
|
+
We
|
|
444
444
|
]);
|
|
445
445
|
}
|
|
446
446
|
export { De as useVoiceSession };
|