@burdenoff/fe-libs 2026.1114.13 → 2026.1114.15
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/conversation.d.ts +16 -0
- package/dist/shared/assistant/i18nManifest.d.ts +30 -0
- package/dist/shared/assistant/i18nManifest.js +30 -0
- package/dist/shared/assistant/index.d.ts +6 -0
- package/dist/shared/assistant/store.d.ts +7 -0
- package/dist/shared/assistant/store.js +3 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +1269 -1188
- package/dist/shared/assistant/ui/AssistantMessageList.d.ts +14 -0
- package/dist/shared/assistant/ui/AssistantMessageList.js +55 -52
- package/dist/shared/assistant/ui/composer/AssistantComposer.js +348 -362
- package/dist/shared/assistant/ui/composer/AssistantDictation.d.ts +42 -0
- package/dist/shared/assistant/ui/composer/AssistantDictation.js +127 -0
- package/dist/shared/assistant/ui/composer/AssistantMicMenu.d.ts +23 -0
- package/dist/shared/assistant/ui/composer/AssistantMicMenu.js +176 -0
- package/dist/shared/assistant/ui/composer/microphones.d.ts +13 -0
- package/dist/shared/assistant/ui/composer/microphones.js +15 -0
- package/dist/shared/assistant/ui/composer/useCompactDictation.d.ts +70 -0
- package/dist/shared/assistant/ui/composer/useCompactDictation.js +136 -0
- package/dist/shared/assistant/ui/useVoiceSession.js +166 -164
- package/dist/shared/assistant/ui/voice/AssistantPageVoiceBar.d.ts +20 -17
- package/dist/shared/assistant/ui/voice/AssistantPageVoiceBar.js +230 -123
- package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +2 -0
- package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +227 -229
- package/dist/shared/assistant/ui/voice/LiveWaveform.d.ts +4 -3
- package/dist/shared/assistant/ui/voice/LiveWaveform.js +1 -1
- package/dist/shared/assistant/ui/voice/VoiceTurnMarks.d.ts +15 -0
- package/dist/shared/assistant/ui/voice/VoiceTurnMarks.js +43 -0
- package/dist/shared/assistant/ui/voice/formatClock.d.ts +2 -0
- package/dist/shared/assistant/ui/voice/formatClock.js +3 -0
- package/dist/shared/assistant/ui/voice/useLiveLevel.d.ts +3 -1
- package/dist/shared/assistant/ui/voice/useLiveLevel.js +23 -19
- package/dist/shared/assistant/voice/liveLevel.d.ts +4 -3
- package/dist/shared/assistant/voice/liveLevel.js +18 -15
- package/dist/shared/assistant/voice/useVoiceInput.d.ts +27 -1
- package/dist/shared/assistant/voice/useVoiceInput.js +141 -71
- package/dist/shared-assistant.js +383 -377
- package/package.json +1 -1
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { useAssistantStore as e } from "../store.js";
|
|
2
|
+
import { useVoiceInput as t } from "../voice/useVoiceInput.js";
|
|
3
|
+
import { useHandsFreeInterrupt as n } from "../voice/handsfree/useHandsFreeInterrupt.js";
|
|
4
|
+
import { readHandsFreeOverride as r, resolveHandsFreeEnabled as ee } from "../voice/handsfree/handsFreeSetting.js";
|
|
5
|
+
import { silencePlaybackReference as te } from "../voice/handsfree/playbackReference.js";
|
|
6
|
+
import { primeHostedPlayback as ne } from "../speech/hostedTtsSpeechEngine.js";
|
|
6
7
|
import { turnClockMs as i } from "../turnTimeline.js";
|
|
7
|
-
import { useAssistantSpeech as
|
|
8
|
-
import { useLiveAvatarOn as
|
|
9
|
-
import { captionChunks as
|
|
8
|
+
import { useAssistantSpeech as re } from "./AssistantSpeechProvider.js";
|
|
9
|
+
import { useLiveAvatarOn as ie } from "./assistantLiveAvatarSeam.js";
|
|
10
|
+
import { captionChunks as ae } from "../voice/speechPlayback.js";
|
|
10
11
|
import { speechFeed as a } from "../speech/speechFeed.js";
|
|
11
|
-
import { planSubmitTimer as
|
|
12
|
-
import { isTurnSuperseded as
|
|
13
|
-
import { INITIAL_SESSION as
|
|
14
|
-
import { useCallback as s, useEffect as c, useLayoutEffect as
|
|
12
|
+
import { planSubmitTimer as oe, resolveVoiceGraceMs as se } from "../voice/handsFree.js";
|
|
13
|
+
import { isTurnSuperseded as ce } 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 o, voiceSessionReducer as ye } from "../voice/voiceSession.js";
|
|
15
|
+
import { useCallback as s, useEffect as c, useLayoutEffect as be, useMemo as xe, useReducer as Se, useRef as l, useState as u } from "react";
|
|
15
16
|
// src/shared/assistant/ui/useVoiceSession.ts
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
let p =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
let S = l(null), C = l({}), w = l(
|
|
17
|
+
var Ce = 4e3, we = 2500, Te = 5e3, Ee = 12e3;
|
|
18
|
+
function De({ onSubmit: De, latestReply: d, language: f, graceMs: Oe, onSupersede: ke, handsFreeInterrupt: Ae, handsFreeStreamNoticeAccepted: je, onAcceptHandsFreeStreamNotice: Me, onBargeIn: Ne }) {
|
|
19
|
+
let p = se(Oe), m = l(null), Pe = s((e, t) => ye(e, t, m.current), []), [h, g] = Se(Pe, le), _ = re(), { setSessionSpeaking: v, setSessionMicOpen: y, speakingMessageId: b, stop: x } = _, Fe = l(_.toggle), Ie = _.toggle;
|
|
20
|
+
be(() => {
|
|
21
|
+
Fe.current = Ie;
|
|
22
|
+
}, [Ie]);
|
|
23
|
+
let S = l(null), C = l({}), w = l(de), T = l(void 0), E = l(void 0), D = l(0), O = l(void 0), k = l(/* @__PURE__ */ new Map()), Le = l(void 0);
|
|
23
24
|
c(() => {
|
|
24
25
|
let e = h.correctionTimingDecision;
|
|
25
26
|
if (e && e !== Le.current) {
|
|
26
27
|
Le.current = e;
|
|
27
|
-
for (let [t, n] of
|
|
28
|
-
|
|
28
|
+
for (let [t, n] of k.current) e.accepted && t >= e.candidateId && (T.current = n.lastSpeechFrame ?? T.current, E.current = n.recognizerSpeechEnded ?? E.current), (e.accepted || t <= e.candidateId) && k.current.delete(t);
|
|
29
|
+
O.current !== void 0 && O.current <= e.candidateId && (O.current = void 0);
|
|
29
30
|
}
|
|
30
|
-
(h.phase !== "thinking" || h.muted) && (
|
|
31
|
+
(h.phase !== "thinking" || h.muted) && (k.current.clear(), O.current = void 0), (h.phase === "idle" || h.phase === "ended") && (T.current = void 0, E.current = void 0);
|
|
31
32
|
}, [
|
|
32
33
|
h.phase,
|
|
33
34
|
h.muted,
|
|
34
35
|
h.correctionTimingDecision
|
|
35
36
|
]);
|
|
36
|
-
let
|
|
37
|
+
let A = l(null), Re = l(!1), [ze, j] = u(null), M = l(null), [Be, N] = u(null), [P, F] = u(!1), [Ve, I] = u(!1), [L, R] = u(!1), z = l(h);
|
|
37
38
|
z.current = h;
|
|
38
39
|
let B = l([]), V = l(null), H = l(!1), U = s(() => {
|
|
39
40
|
B.current = [], V.current = null, H.current = !1;
|
|
@@ -44,7 +45,7 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
44
45
|
if (!e.stillWanted || e.stillWanted()) {
|
|
45
46
|
V.current = e, m.current = m.current ? `${m.current} ${e.text}` : e.text;
|
|
46
47
|
try {
|
|
47
|
-
|
|
48
|
+
Fe.current(e.id, e.text, e.lang);
|
|
48
49
|
} catch {
|
|
49
50
|
V.current = null;
|
|
50
51
|
continue;
|
|
@@ -52,8 +53,8 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
52
53
|
return !0;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
}, []), G = l(!1),
|
|
56
|
-
let t =
|
|
56
|
+
}, []), G = l(!1), He = s((e) => {
|
|
57
|
+
let t = he({
|
|
57
58
|
requested: e,
|
|
58
59
|
held: G.current,
|
|
59
60
|
muted: z.current.muted
|
|
@@ -63,88 +64,89 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
63
64
|
muted: t.mute
|
|
64
65
|
});
|
|
65
66
|
}, []), K = s((e) => {
|
|
66
|
-
let t =
|
|
67
|
+
let t = _e(z.current);
|
|
67
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, g({ type: "announce" }))));
|
|
68
|
-
}, []),
|
|
69
|
+
}, []), Ue = s((e) => {
|
|
69
70
|
z.current.phase === "thinking" ? (B.current.push(e), H.current = !0, g({ type: "answered-locally" })) : K(e);
|
|
70
|
-
}, [K]),
|
|
71
|
-
|
|
71
|
+
}, [K]), We = l(d);
|
|
72
|
+
We.current = d, c(() => {
|
|
72
73
|
if (h.phase === "speaking") {
|
|
73
74
|
let e = M.current;
|
|
74
|
-
m.current = e &&
|
|
75
|
+
m.current = e && A.current === e.id && d?.id !== e.id ? e.text : d?.text ?? null;
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
if (m.current === null) return;
|
|
78
79
|
let e = setTimeout(() => {
|
|
79
80
|
m.current = null;
|
|
80
|
-
},
|
|
81
|
+
}, we);
|
|
81
82
|
return () => clearTimeout(e);
|
|
82
83
|
}, [h.phase, d]);
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
let
|
|
84
|
+
let Ge = l(f);
|
|
85
|
+
Ge.current = f;
|
|
86
|
+
let Ke = s((e, t) => {
|
|
86
87
|
let n = z.current;
|
|
87
88
|
if (!n.muted) {
|
|
88
89
|
if (n.phase === "thinking") {
|
|
89
|
-
e === "lastSpeechFrame" && (
|
|
90
|
-
let n =
|
|
91
|
-
r[e] = t,
|
|
90
|
+
e === "lastSpeechFrame" && (O.current = void 0);
|
|
91
|
+
let n = O.current ?? D.current, r = k.current.get(n) ?? {};
|
|
92
|
+
r[e] = t, k.current.set(n, r);
|
|
92
93
|
} else n.phase === "listening" && (e === "lastSpeechFrame" ? T.current = t : E.current = t);
|
|
93
94
|
}
|
|
94
|
-
}, []),
|
|
95
|
+
}, []), q = s((e) => {
|
|
95
96
|
let t = z.current;
|
|
96
97
|
if (t.phase !== "thinking" || t.muted) return;
|
|
97
|
-
let n =
|
|
98
|
-
return e && (
|
|
99
|
-
}, []),
|
|
98
|
+
let n = D.current;
|
|
99
|
+
return e && (O.current = n, D.current += 1), n;
|
|
100
|
+
}, []), J = s((e, t) => {
|
|
100
101
|
g({
|
|
101
102
|
type: "speech",
|
|
102
103
|
transcript: e,
|
|
103
104
|
final: t,
|
|
104
105
|
at: Date.now(),
|
|
105
|
-
language:
|
|
106
|
-
timingCandidateId:
|
|
106
|
+
language: Ge.current,
|
|
107
|
+
timingCandidateId: q(t)
|
|
107
108
|
});
|
|
108
|
-
}, [
|
|
109
|
+
}, [q]), qe = s((e, t, n) => {
|
|
109
110
|
g({
|
|
110
111
|
type: "speech",
|
|
111
112
|
transcript: e,
|
|
112
113
|
final: t,
|
|
113
114
|
at: Date.now(),
|
|
114
|
-
language: n ??
|
|
115
|
+
language: n ?? Ge.current,
|
|
115
116
|
gated: !0,
|
|
116
|
-
timingCandidateId:
|
|
117
|
+
timingCandidateId: q(t)
|
|
117
118
|
});
|
|
118
|
-
}, [
|
|
119
|
-
U(), x(),
|
|
120
|
-
}, [x, U]),
|
|
121
|
-
onFinalize:
|
|
119
|
+
}, [q]), Je = l(0), Ye = s(() => {
|
|
120
|
+
U(), x(), Je.current = Date.now(), F(!0), g({ type: "interrupt" });
|
|
121
|
+
}, [x, U]), Xe = s((e) => J(e, !0), [J]), Ze = e((e) => e.micDeviceId), Y = t({
|
|
122
|
+
onFinalize: Xe,
|
|
122
123
|
language: f,
|
|
124
|
+
deviceId: Ze,
|
|
123
125
|
onSpeechEnd: (e) => {
|
|
124
|
-
|
|
126
|
+
Ke("recognizerSpeechEnded", e);
|
|
125
127
|
}
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
let
|
|
129
|
-
U(),
|
|
130
|
-
}, [x, U]),
|
|
131
|
-
enabled:
|
|
128
|
+
}), Qe = Y.stop, $e = l(Ne);
|
|
129
|
+
$e.current = Ne;
|
|
130
|
+
let et = s(() => {
|
|
131
|
+
U(), te(), x(), Je.current = Date.now(), F(!0), g({ type: "interrupt" }), $e.current?.();
|
|
132
|
+
}, [x, U]), tt = ie(), X = n({
|
|
133
|
+
enabled: ee(Ae, r(), tt),
|
|
132
134
|
phase: h.phase,
|
|
133
135
|
muted: h.muted,
|
|
134
136
|
language: f,
|
|
135
|
-
streamNoticeAccepted:
|
|
136
|
-
onAcceptStreamNotice:
|
|
137
|
-
onBargeIn:
|
|
138
|
-
onTranscript:
|
|
137
|
+
streamNoticeAccepted: je ?? null,
|
|
138
|
+
onAcceptStreamNotice: Me,
|
|
139
|
+
onBargeIn: et,
|
|
140
|
+
onTranscript: qe,
|
|
139
141
|
onSpeechFrame: (e) => {
|
|
140
|
-
|
|
142
|
+
Ke("lastSpeechFrame", e);
|
|
141
143
|
}
|
|
142
|
-
}),
|
|
144
|
+
}), nt = X.mode === "notice", Z = Y.isListening || X.suppressWebSpeech && X.mode === "active";
|
|
143
145
|
c(() => {
|
|
144
|
-
|
|
145
|
-
}, [
|
|
146
|
-
S.current && clearTimeout(S.current), I(!1), w.current =
|
|
147
|
-
let e =
|
|
146
|
+
Y.interim && J(Y.interim, !1);
|
|
147
|
+
}, [Y.interim, J]), c(() => {
|
|
148
|
+
S.current && clearTimeout(S.current), I(!1), w.current = fe(w.current, h, i());
|
|
149
|
+
let e = oe({
|
|
148
150
|
phase: h.phase,
|
|
149
151
|
muted: h.muted,
|
|
150
152
|
spoken: o(h),
|
|
@@ -176,18 +178,18 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
176
178
|
(h.phase !== "listening" || h.muted) && R(!1);
|
|
177
179
|
}, [h.phase, h.muted]), c(() => {
|
|
178
180
|
if (!P) return;
|
|
179
|
-
let e = Date.now() -
|
|
181
|
+
let e = Date.now() - Je.current, t = Z ? Math.max(0, 500 - e) : Math.max(0, ue - e), n = setTimeout(() => F(!1), t);
|
|
180
182
|
return () => clearTimeout(n);
|
|
181
|
-
}, [P,
|
|
182
|
-
let
|
|
183
|
-
h.phase === "listening" && (
|
|
183
|
+
}, [P, Z]);
|
|
184
|
+
let rt = l("");
|
|
185
|
+
h.phase === "listening" && (rt.current = o(h)), c(() => {
|
|
184
186
|
if (h.phase !== "thinking") return;
|
|
185
187
|
y(!1), U(), N((e) => typeof e == "object" && e ? null : e);
|
|
186
|
-
let e =
|
|
187
|
-
e &&
|
|
188
|
+
let e = rt.current.trim();
|
|
189
|
+
e && De(e, $.current ?? `vs-orphan-${Date.now().toString(36)}`, C.current, { correction: z.current.correcting }), C.current = {}, w.current = de, T.current = void 0, E.current = void 0;
|
|
188
190
|
}, [h.phase]), c(() => {
|
|
189
|
-
let e =
|
|
190
|
-
e.claim && (
|
|
191
|
+
let e = ge(d?.id, h.phase, A.current, ce(d?.id));
|
|
192
|
+
e.claim && (A.current = d?.id ?? null, e.advance && d && (d.refused ? (U(), N({
|
|
191
193
|
kind: "turn-refused",
|
|
192
194
|
text: d.text
|
|
193
195
|
}), g({ type: "turn-refused" })) : g({
|
|
@@ -199,13 +201,13 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
199
201
|
h.phase,
|
|
200
202
|
U
|
|
201
203
|
]), c(() => {
|
|
202
|
-
if (b === null || h.phase !== "thinking" ||
|
|
203
|
-
if (
|
|
204
|
+
if (b === null || h.phase !== "thinking" || A.current === b) return;
|
|
205
|
+
if (ce(b)) {
|
|
204
206
|
x();
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
207
209
|
let e = a.peek(b);
|
|
208
|
-
e && e.final && e.channel === "voice" && e.voiceSessionId !== void 0 && e.voiceSessionId === $.current && (
|
|
210
|
+
e && e.final && e.channel === "voice" && e.voiceSessionId !== void 0 && e.voiceSessionId === $.current && (A.current = b, M.current = {
|
|
209
211
|
id: b,
|
|
210
212
|
text: e.text
|
|
211
213
|
}, g({
|
|
@@ -221,12 +223,12 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
221
223
|
let t = z.current.phase;
|
|
222
224
|
if (t !== "thinking" && t !== "speaking") return;
|
|
223
225
|
if (e.state === "retrying") {
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
+
if (A.current !== e.messageId || M.current?.id !== e.messageId) return;
|
|
227
|
+
A.current = null, M.current = null, j(e.messageId), g({ type: "reply-audio-paused" });
|
|
226
228
|
return;
|
|
227
229
|
}
|
|
228
230
|
if (e.state === "ended") {
|
|
229
|
-
if (
|
|
231
|
+
if (A.current !== e.messageId || M.current?.id !== e.messageId) return;
|
|
230
232
|
let n = a.peek(e.messageId);
|
|
231
233
|
n?.channel === "voice" && n.voiceSessionId === $.current && (M.current = {
|
|
232
234
|
id: e.messageId,
|
|
@@ -238,97 +240,97 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
238
240
|
});
|
|
239
241
|
return;
|
|
240
242
|
}
|
|
241
|
-
if (
|
|
243
|
+
if (ce(e.messageId)) return;
|
|
242
244
|
let n = a.peek(e.messageId);
|
|
243
245
|
if (n && n.channel === "voice" && n.voiceSessionId === $.current) {
|
|
244
|
-
if (e.state === "queued") j(e.messageId),
|
|
246
|
+
if (e.state === "queued") j(e.messageId), A.current = e.messageId, M.current = {
|
|
245
247
|
id: e.messageId,
|
|
246
248
|
text: n.text
|
|
247
|
-
},
|
|
248
|
-
else if (
|
|
249
|
-
else e.state === "started" ? (
|
|
249
|
+
}, Qe();
|
|
250
|
+
else if (A.current !== e.messageId) return;
|
|
251
|
+
else e.state === "started" ? (A.current = e.messageId, M.current = {
|
|
250
252
|
id: e.messageId,
|
|
251
253
|
text: n.text
|
|
252
254
|
}, g({
|
|
253
255
|
type: "reply-audio-started",
|
|
254
256
|
replyId: e.messageId,
|
|
255
257
|
partial: !n.final
|
|
256
|
-
})) : e.state === "paused" &&
|
|
258
|
+
})) : e.state === "paused" && A.current === e.messageId && g({ type: "reply-audio-paused" });
|
|
257
259
|
}
|
|
258
|
-
}), [
|
|
260
|
+
}), [Qe]), c(() => {
|
|
259
261
|
h.phase !== "thinking" && h.phase !== "speaking" && j(null);
|
|
260
262
|
}, [h.phase]), c(() => {
|
|
261
263
|
let e = b !== null;
|
|
262
|
-
|
|
264
|
+
Re.current && !e && (V.current = null, z.current.phase === "speaking" && W() || g({ type: "speech-ended" })), Re.current = e;
|
|
263
265
|
}, [b, W]), c(() => {
|
|
264
266
|
h.phase !== "listening" && N((e) => e === "nothing-heard" ? null : e);
|
|
265
267
|
}, [h.phase]), c(() => {
|
|
266
268
|
if (h.phase !== "speaking" || b !== null) return;
|
|
267
269
|
let e = setTimeout(() => {
|
|
268
|
-
|
|
269
|
-
},
|
|
270
|
+
Re.current || (U(), g({ type: "speech-ended" }));
|
|
271
|
+
}, Ce);
|
|
270
272
|
return () => clearTimeout(e);
|
|
271
273
|
}, [
|
|
272
274
|
h.phase,
|
|
273
275
|
b,
|
|
274
276
|
U
|
|
275
277
|
]);
|
|
276
|
-
let
|
|
278
|
+
let Q = _.outputNotCleared;
|
|
277
279
|
c(() => {
|
|
278
|
-
if (
|
|
280
|
+
if (Q === null || A.current !== Q.messageId) return;
|
|
279
281
|
let { phase: e } = z.current;
|
|
280
282
|
e !== "idle" && e !== "ended" && e !== "thinking" && N("reply-not-heard");
|
|
281
|
-
}, [
|
|
283
|
+
}, [Q]), c(() => {
|
|
282
284
|
h.phase !== "listening" && h.phase !== "thinking" && N((e) => e === "reply-not-heard" ? null : e);
|
|
283
285
|
}, [h.phase]);
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
let
|
|
286
|
+
let it = l(ke);
|
|
287
|
+
it.current = ke;
|
|
288
|
+
let at = l(0);
|
|
287
289
|
c(() => {
|
|
288
290
|
let e = h.superseded;
|
|
289
|
-
e !==
|
|
291
|
+
e !== at.current && (at.current = e, e !== 0 && (U(), x(), it.current?.()));
|
|
290
292
|
}, [
|
|
291
293
|
h.superseded,
|
|
292
294
|
U,
|
|
293
295
|
x
|
|
294
296
|
]), c(() => {
|
|
295
|
-
let e =
|
|
296
|
-
y(e),
|
|
297
|
+
let e = pe(h);
|
|
298
|
+
y(e), ve(h) && ze === null && !X.suppressWebSpeech ? Y.isActive || Y.start("auto") : Y.isActive && Y.stop();
|
|
297
299
|
}, [
|
|
298
300
|
h,
|
|
299
|
-
|
|
301
|
+
Y,
|
|
300
302
|
y,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
X.suppressWebSpeech,
|
|
304
|
+
ze
|
|
303
305
|
]), c(() => {
|
|
304
306
|
h.phase === "speaking" && H.current && (H.current = !1, W() || g({ type: "speech-ended" }));
|
|
305
307
|
}, [h.phase, W]), c(() => {
|
|
306
|
-
|
|
308
|
+
Y.error === "not-allowed" || Y.error === "audio-capture" ? g({
|
|
307
309
|
type: "fail",
|
|
308
310
|
error: "mic-denied"
|
|
309
|
-
}) :
|
|
311
|
+
}) : Y.error === "language-not-supported" ? g({
|
|
310
312
|
type: "fail",
|
|
311
313
|
error: "no-speech-support"
|
|
312
|
-
}) :
|
|
313
|
-
}, [
|
|
314
|
-
|
|
315
|
-
}, [
|
|
316
|
-
if (
|
|
317
|
-
let e = setTimeout(() => N("not-capturing"),
|
|
314
|
+
}) : Y.error === "network" ? N("network") : Y.error === "unknown" && N("recognition-failed");
|
|
315
|
+
}, [Y.error]), c(() => {
|
|
316
|
+
Y.error === null && Z && N((e) => e === "network" || e === "recognition-failed" ? null : e);
|
|
317
|
+
}, [Y.error, Z]), c(() => {
|
|
318
|
+
if (Z && N((e) => e === "not-capturing" ? null : e), !pe(h) || Z || nt) return;
|
|
319
|
+
let e = setTimeout(() => N("not-capturing"), Te);
|
|
318
320
|
return () => clearTimeout(e);
|
|
319
321
|
}, [
|
|
320
322
|
h,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
Z,
|
|
324
|
+
nt
|
|
323
325
|
]), c(() => {
|
|
324
|
-
if (h.phase !== "listening" || h.muted || !
|
|
325
|
-
let e = setTimeout(() => N("nothing-heard"),
|
|
326
|
+
if (h.phase !== "listening" || h.muted || !Z || o(h) !== "") return;
|
|
327
|
+
let e = setTimeout(() => N("nothing-heard"), Ee);
|
|
326
328
|
return () => clearTimeout(e);
|
|
327
|
-
}, [h,
|
|
329
|
+
}, [h, Z]), c(() => {
|
|
328
330
|
o(h) !== "" && N(null);
|
|
329
331
|
}, [h]);
|
|
330
|
-
let $ = l(null),
|
|
331
|
-
if (F(!1), I(!1), R(!1), U(), G.current = !1, !
|
|
332
|
+
let $ = l(null), ot = s(() => {
|
|
333
|
+
if (F(!1), I(!1), R(!1), U(), G.current = !1, !Y.isSupported) g({
|
|
332
334
|
type: "fail",
|
|
333
335
|
error: "no-speech-support"
|
|
334
336
|
});
|
|
@@ -344,26 +346,26 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
344
346
|
t.volume = 0, e.speak(t);
|
|
345
347
|
}
|
|
346
348
|
} catch {}
|
|
347
|
-
|
|
349
|
+
ne(), v(!0), N(null), A.current = We.current?.id ?? null, M.current = null, $.current = `vs-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`, g({ type: "start" });
|
|
348
350
|
}
|
|
349
351
|
}, [
|
|
350
|
-
|
|
352
|
+
Y.isSupported,
|
|
351
353
|
_.isBlocked,
|
|
352
354
|
v,
|
|
353
355
|
U
|
|
354
|
-
]),
|
|
356
|
+
]), st = s(() => {
|
|
355
357
|
F(!1), I(!1), R(!1), U(), G.current = !1, $.current = null, g({ type: "end" }), x(), v(!1);
|
|
356
358
|
}, [
|
|
357
359
|
x,
|
|
358
360
|
v,
|
|
359
361
|
U
|
|
360
|
-
]),
|
|
362
|
+
]), ct = s((e) => $.current === e, []), lt = s(() => {
|
|
361
363
|
let e = z.current;
|
|
362
364
|
e.phase !== "listening" || e.muted || R(!0);
|
|
363
|
-
}, []),
|
|
365
|
+
}, []), ut = s(() => {
|
|
364
366
|
R(!1);
|
|
365
367
|
let e = z.current;
|
|
366
|
-
if (e.phase !== "listening" || e.muted || !
|
|
368
|
+
if (e.phase !== "listening" || e.muted || !me(o(e))) return;
|
|
367
369
|
let t = i();
|
|
368
370
|
C.current = {
|
|
369
371
|
speechEnded: w.current.at ?? t,
|
|
@@ -376,7 +378,7 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
376
378
|
type: "silence",
|
|
377
379
|
at: Date.now()
|
|
378
380
|
});
|
|
379
|
-
}, [p]),
|
|
381
|
+
}, [p]), dt = s(() => {
|
|
380
382
|
g({
|
|
381
383
|
type: "mute",
|
|
382
384
|
muted: !z.current.muted
|
|
@@ -385,60 +387,60 @@ function Ee({ onSubmit: Ee, latestReply: d, language: f, graceMs: De, onSupersed
|
|
|
385
387
|
c(() => () => {
|
|
386
388
|
v(!1), y(!1);
|
|
387
389
|
}, [v, y]);
|
|
388
|
-
let
|
|
389
|
-
return
|
|
390
|
+
let ft = ae(_.spokenChunks, h.phase, b);
|
|
391
|
+
return xe(() => ({
|
|
390
392
|
session: h,
|
|
391
|
-
notice:
|
|
392
|
-
spokenChunks:
|
|
393
|
-
capturing:
|
|
393
|
+
notice: Be ?? (X.fallbackReason !== null && X.fallbackReason !== "notice-declined" ? "hands-free-fallback" : X.nothingHeard ? "hands-free-nothing-heard" : null),
|
|
394
|
+
spokenChunks: ft,
|
|
395
|
+
capturing: Z,
|
|
394
396
|
active: h.phase !== "idle" && (h.phase !== "ended" || h.error !== null),
|
|
395
397
|
interrupting: P,
|
|
396
|
-
awaitingEndpoint:
|
|
398
|
+
awaitingEndpoint: Ve,
|
|
397
399
|
holding: L,
|
|
398
400
|
correcting: h.correcting,
|
|
399
401
|
handsFree: {
|
|
400
|
-
mode:
|
|
401
|
-
nothingHeard:
|
|
402
|
-
transportKind:
|
|
403
|
-
fallbackReason:
|
|
404
|
-
privacyNotice:
|
|
402
|
+
mode: X.mode,
|
|
403
|
+
nothingHeard: X.nothingHeard,
|
|
404
|
+
transportKind: X.transportKind,
|
|
405
|
+
fallbackReason: X.fallbackReason,
|
|
406
|
+
privacyNotice: X.privacyNotice
|
|
405
407
|
},
|
|
406
|
-
available:
|
|
407
|
-
start:
|
|
408
|
-
end:
|
|
409
|
-
isCurrentSession:
|
|
410
|
-
toggleMute:
|
|
411
|
-
interrupt:
|
|
412
|
-
letMeFinish:
|
|
413
|
-
imDone:
|
|
408
|
+
available: Y.isSupported && !_.isBlocked,
|
|
409
|
+
start: ot,
|
|
410
|
+
end: st,
|
|
411
|
+
isCurrentSession: ct,
|
|
412
|
+
toggleMute: dt,
|
|
413
|
+
interrupt: Ye,
|
|
414
|
+
letMeFinish: lt,
|
|
415
|
+
imDone: ut,
|
|
414
416
|
announce: K,
|
|
415
|
-
holdListening:
|
|
416
|
-
answerLocally:
|
|
417
|
+
holdListening: He,
|
|
418
|
+
answerLocally: Ue
|
|
417
419
|
}), [
|
|
418
420
|
h,
|
|
419
|
-
ze,
|
|
420
|
-
P,
|
|
421
421
|
Be,
|
|
422
|
+
P,
|
|
423
|
+
Ve,
|
|
422
424
|
L,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
425
|
+
Z,
|
|
426
|
+
X.mode,
|
|
427
|
+
X.nothingHeard,
|
|
428
|
+
X.transportKind,
|
|
429
|
+
X.fallbackReason,
|
|
430
|
+
X.privacyNotice,
|
|
431
|
+
Y.isSupported,
|
|
430
432
|
_.isBlocked,
|
|
431
|
-
|
|
432
|
-
it,
|
|
433
|
-
at,
|
|
433
|
+
ft,
|
|
434
434
|
ot,
|
|
435
|
-
lt,
|
|
436
|
-
qe,
|
|
437
435
|
st,
|
|
438
436
|
ct,
|
|
437
|
+
dt,
|
|
438
|
+
Ye,
|
|
439
|
+
lt,
|
|
440
|
+
ut,
|
|
439
441
|
K,
|
|
440
|
-
|
|
441
|
-
|
|
442
|
+
He,
|
|
443
|
+
Ue
|
|
442
444
|
]);
|
|
443
445
|
}
|
|
444
|
-
export {
|
|
446
|
+
export { De as useVoiceSession };
|
|
@@ -13,11 +13,13 @@ export interface AssistantPageVoiceBarProps {
|
|
|
13
13
|
status: string;
|
|
14
14
|
statusSuffix: string | null;
|
|
15
15
|
rotateStatus: boolean;
|
|
16
|
+
/** The session's own line for this stage (holding, correcting, still listening…). */
|
|
17
|
+
stageText: string;
|
|
16
18
|
/** What the person is saying, as it is heard; empty when not listening. */
|
|
17
19
|
heard: string;
|
|
18
|
-
/** The
|
|
20
|
+
/** The circle's level (`useLiveLevel`). */
|
|
19
21
|
level: LiveLevelSource;
|
|
20
|
-
/** A recoverable problem, shown above the
|
|
22
|
+
/** A recoverable problem, shown above the dock, and the same text when it is to be announced. */
|
|
21
23
|
notice: string | null;
|
|
22
24
|
announcedNotice: string | null;
|
|
23
25
|
attachmentNotice: string | null;
|
|
@@ -37,26 +39,27 @@ export interface AssistantPageVoiceBarProps {
|
|
|
37
39
|
holding: boolean;
|
|
38
40
|
onPress: () => void;
|
|
39
41
|
} | null;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
onToggleMute: () => void;
|
|
43
|
+
/** Mute / Unmute can be pressed (not while connecting, ended or after an error). */
|
|
44
|
+
muteDisabled: boolean;
|
|
45
|
+
/** Cut the assistant off; offered while it speaks. */
|
|
46
|
+
onInterrupt?: () => void;
|
|
47
|
+
/** Speaking over the assistant cuts in too (hands-free interrupt is on). */
|
|
48
|
+
bargeIn: boolean;
|
|
46
49
|
onEnd: () => void;
|
|
47
50
|
privacyNotice: HandsFreePrivacyNoticeActions | null;
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
|
-
* The live voice
|
|
51
|
-
*
|
|
53
|
+
* The live voice chat on a page: the assistant dock (BOFF-13461; the operator's
|
|
54
|
+
* design of 14 Nov, "Voice chat: the assistant dock").
|
|
52
55
|
*
|
|
53
|
-
* The
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* The message box turns into this dock, in its place and shape, and the chat stays
|
|
57
|
+
* in view above it, filling with both sides of the conversation (the chat area draws
|
|
58
|
+
* the spoken turns). The dock: a circle and a title that say what is happening
|
|
59
|
+
* (Connecting, Listening, Thinking, Speaking, Muted), what is being heard or what to
|
|
60
|
+
* do, the call's time; then Mute / Unmute, Interrupt while the assistant talks, Let
|
|
61
|
+
* me finish (H1), Attach, and End voice chat. Amber means "we are hearing you",
|
|
62
|
+
* blue "the assistant is talking"; the tab's title says the state too.
|
|
60
63
|
*
|
|
61
64
|
* All the session's state and rules stay in `AssistantVoiceSession` (`view="page"`),
|
|
62
65
|
* which renders this through a portal into the page's slot.
|