@burdenoff/fe-libs 2026.1028.2 → 2026.1028.4
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/turnTimeline.d.ts +18 -6
- package/dist/shared/assistant/turnTimeline.js +57 -39
- package/dist/shared/assistant/turnTimingReport.d.ts +10 -1
- package/dist/shared/assistant/turnTimingReport.js +19 -6
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +239 -237
- package/dist/shared/assistant/ui/useVoiceSession.js +218 -202
- package/dist/shared/assistant/voice/handsfree/handsFreeController.d.ts +3 -0
- package/dist/shared/assistant/voice/handsfree/handsFreeController.js +5 -1
- package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.d.ts +1 -0
- package/dist/shared/assistant/voice/handsfree/useHandsFreeInterrupt.js +1 -0
- package/dist/shared/assistant/voice/useVoiceInput.d.ts +3 -1
- package/dist/shared/assistant/voice/useVoiceInput.js +49 -43
- package/dist/shared/config/gatewayUrls.d.ts +13 -0
- package/dist/shared/config/gatewayUrls.js +7 -3
- package/dist/shared/config/index.d.ts +1 -1
- package/dist/shared-assistant.js +206 -206
- package/dist/shared-config.js +16 -16
- package/dist/shared.js +140 -140
- package/package.json +1 -1
|
@@ -9,17 +9,17 @@ import { speechFeed as d } from "../speech/speechFeed.js";
|
|
|
9
9
|
import { hasPendingReplyRequests as f, releaseReplyRequestsOutside as p, replyWantsAvatar as re, settleReplyRequest as m, subscribeReplyRequests as h } from "../speech/replySpeechRequests.js";
|
|
10
10
|
import { isTurnSuperseded as g } from "../voice/supersededTurns.js";
|
|
11
11
|
import { chunkForSpeech as ie, toSpeakableText as _ } from "../voice/speakableText.js";
|
|
12
|
-
import { voicePreviewText as
|
|
13
|
-
import { findAssistantLanguage as
|
|
14
|
-
import { resolveLanguagePair as
|
|
15
|
-
import { speechLabelsFor as
|
|
16
|
-
import { resolveSpeechLocale as
|
|
17
|
-
import { IDLE_PLAYBACK as
|
|
18
|
-
import { isTurnInFlight as
|
|
19
|
-
import { parseToolActivity as
|
|
12
|
+
import { voicePreviewText as v } from "../voice/voicePreview.js";
|
|
13
|
+
import { findAssistantLanguage as ae } from "../voice/languages.js";
|
|
14
|
+
import { resolveLanguagePair as y } from "../voice/languagePair.js";
|
|
15
|
+
import { speechLabelsFor as oe } from "../voice/speechLabels.js";
|
|
16
|
+
import { resolveSpeechLocale as se } from "../voice/replyLanguage.js";
|
|
17
|
+
import { IDLE_PLAYBACK as ce, isSpeakingMessage as le, publishedChunks as ue, speechPlaybackReducer as de } from "../voice/speechPlayback.js";
|
|
18
|
+
import { isTurnInFlight as fe } from "../turnState.js";
|
|
19
|
+
import { parseToolActivity as pe } from "./AssistantToolActivity.js";
|
|
20
20
|
import "../speech/index.js";
|
|
21
|
-
import { markTurn as he } from "../turnTimeline.js";
|
|
22
|
-
import { createContext as ge, useCallback as
|
|
21
|
+
import { beginListenTurn as me, finishListenTurn as b, markTurn as he } from "../turnTimeline.js";
|
|
22
|
+
import { createContext as ge, useCallback as x, useContext as _e, useEffect as S, useMemo as C, useReducer as ve, useRef as w, useState as T, useSyncExternalStore as ye } from "react";
|
|
23
23
|
import { jsx as be } from "react/jsx-runtime";
|
|
24
24
|
//#region src/shared/assistant/ui/AssistantSpeechProvider.tsx
|
|
25
25
|
var xe = {
|
|
@@ -31,8 +31,8 @@ var xe = {
|
|
|
31
31
|
emailAt: "at",
|
|
32
32
|
emailDot: "dot",
|
|
33
33
|
nestedItem: ""
|
|
34
|
-
}, Se = 4e3,
|
|
35
|
-
subscribe: () =>
|
|
34
|
+
}, Se = 4e3, E = () => {}, Ce = {
|
|
35
|
+
subscribe: () => E,
|
|
36
36
|
getSnapshot: () => !1
|
|
37
37
|
}, we = {
|
|
38
38
|
subscribe: h,
|
|
@@ -48,7 +48,7 @@ function Ee(e, t) {
|
|
|
48
48
|
let n = e.activeConversationId;
|
|
49
49
|
if (!n || n !== t.activeConversationId) return null;
|
|
50
50
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
51
|
-
if (r?.status !== "complete" || !
|
|
51
|
+
if (r?.status !== "complete" || !fe(i?.status)) return null;
|
|
52
52
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
53
53
|
if (!a) return null;
|
|
54
54
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
@@ -79,166 +79,168 @@ var De = ge({
|
|
|
79
79
|
speakFinishedReply: () => {},
|
|
80
80
|
previewVoice: () => {}
|
|
81
81
|
});
|
|
82
|
-
function
|
|
82
|
+
function D() {
|
|
83
83
|
return _e(De);
|
|
84
84
|
}
|
|
85
|
-
var
|
|
86
|
-
let _e = ye(ne, u, u),
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
var O = ({ children: f, visible: h = !0, engine: ge }) => {
|
|
86
|
+
let _e = ye(ne, u, u), E = ge ?? _e, D = t(), { locale: O } = e(), [k, A] = ve(de, ce), [j, M] = T(() => E.listVoices()), [N, Oe] = T(!1), [ke, P] = T(() => /* @__PURE__ */ new Map()), [Ae, F] = T(() => /* @__PURE__ */ new Set()), [je, Me] = T(null), I = w(0), L = w(null), R = w(null), z = w(void 0), B = w(null), V = w(null);
|
|
87
|
+
S(() => () => {
|
|
88
|
+
V.current !== null && clearTimeout(V.current);
|
|
89
89
|
}, []);
|
|
90
|
-
let [Ne, Pe] =
|
|
91
|
-
|
|
92
|
-
}, []),
|
|
90
|
+
let [Ne, Pe] = T(null), H = w(null), Fe = w(() => {}), U = x(() => {
|
|
91
|
+
H.current?.(), H.current = null;
|
|
92
|
+
}, []), W = n((e) => e.autoSpeakEnabled), Ie = n((e) => e.setAutoSpeak), [G, Le] = T(!1), Re = w(!1), ze = x((e) => {
|
|
93
93
|
Re.current = e;
|
|
94
|
-
}, []), Be = n((e) => e.activeConversationId),
|
|
95
|
-
|
|
96
|
-
if (!
|
|
94
|
+
}, []), Be = n((e) => e.activeConversationId), K = C(() => E.isSupported(), [E]), Ve = E.wouldSpeakOnAvatar === void 0 ? Ce : we, He = ye(Ve.subscribe, Ve.getSnapshot, Ve.getSnapshot);
|
|
95
|
+
S(() => {
|
|
96
|
+
if (!K) return;
|
|
97
97
|
let e = () => {
|
|
98
|
-
|
|
98
|
+
M(E.listVoices()), P((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
99
99
|
};
|
|
100
|
-
return e(),
|
|
101
|
-
}, [
|
|
102
|
-
let Ue = n((e) => e.assistantLanguage), We = n((e) => e.replyLanguage),
|
|
100
|
+
return e(), E.subscribeVoices(e);
|
|
101
|
+
}, [E, K]);
|
|
102
|
+
let Ue = n((e) => e.assistantLanguage), We = n((e) => e.replyLanguage), q = n((e) => e.preferredVoices), Ge = n((e) => e.setPreferredVoice), J = C(() => y(Ue, We, O).reply, [
|
|
103
103
|
Ue,
|
|
104
104
|
We,
|
|
105
|
-
|
|
106
|
-
]),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
]),
|
|
112
|
-
codeBlock:
|
|
113
|
-
image:
|
|
114
|
-
link:
|
|
115
|
-
largeTable:
|
|
116
|
-
truncated:
|
|
117
|
-
nestedItem:
|
|
118
|
-
emailAt:
|
|
119
|
-
emailDot:
|
|
120
|
-
}), [
|
|
121
|
-
|
|
122
|
-
}, [
|
|
123
|
-
let t =
|
|
105
|
+
O
|
|
106
|
+
]), Y = J.code, Ke = x((e) => ae(e)?.tag ?? c(e), []), qe = x((e) => ae(e)?.rate ?? .9, []), X = C(() => te(K, j, J.tag, N), [
|
|
107
|
+
K,
|
|
108
|
+
j,
|
|
109
|
+
J,
|
|
110
|
+
N
|
|
111
|
+
]), Je = C(() => ({
|
|
112
|
+
codeBlock: D("speech.codeBlock", "Code block"),
|
|
113
|
+
image: D("speech.image", "image"),
|
|
114
|
+
link: D("speech.link", "link"),
|
|
115
|
+
largeTable: D("speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
|
|
116
|
+
truncated: D("speech.truncated", "The rest of this message is not read aloud"),
|
|
117
|
+
nestedItem: D("speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
118
|
+
emailAt: D("speech.emailAt", "at"),
|
|
119
|
+
emailDot: D("speech.emailDot", "dot")
|
|
120
|
+
}), [D]), Z = x(() => {
|
|
121
|
+
U(), R.current = null, b(z.current, "stopped"), z.current = void 0, E.cancel(), m(L.current, "stopped"), A({ type: "stop" });
|
|
122
|
+
}, [U, E]), Ye = x((e) => {
|
|
123
|
+
let t = E.listVoices().find((t) => t.name === e) ?? null;
|
|
124
124
|
if (t) {
|
|
125
|
-
|
|
125
|
+
Z();
|
|
126
126
|
try {
|
|
127
|
-
|
|
127
|
+
E.speak([v(Y)], {
|
|
128
128
|
voice: t,
|
|
129
|
-
lang:
|
|
129
|
+
lang: Ke(Y),
|
|
130
130
|
fallback: !1
|
|
131
131
|
});
|
|
132
132
|
} catch {}
|
|
133
133
|
}
|
|
134
134
|
}, [
|
|
135
|
-
|
|
136
|
-
K,
|
|
135
|
+
E,
|
|
137
136
|
Y,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
Z,
|
|
138
|
+
Ke
|
|
139
|
+
]), Xe = x((e) => ke.get(e) ?? null, [ke]), Ze = x((e) => Ae.has(e) ? D("speech.deviceFallback", "Device voice used: the selected voice was unavailable.") : null, [Ae, D]), Qe = x((e, t, n, r, i) => {
|
|
140
|
+
U();
|
|
141
141
|
let o = !1, s = () => {}, ee = (a) => {
|
|
142
142
|
if (!o) {
|
|
143
|
-
if (o = !0,
|
|
143
|
+
if (o = !0, H.current = null, clearTimeout(c), s(), a.length === 0) {
|
|
144
144
|
Oe(!0), m(e, "declined");
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
M(a), Fe.current(e, t, a, n, r, i);
|
|
148
148
|
}
|
|
149
|
-
}, c = setTimeout(() => ee(
|
|
150
|
-
s =
|
|
151
|
-
o || (o = !0, clearTimeout(c), s(),
|
|
149
|
+
}, c = setTimeout(() => ee(E.listVoices()), a);
|
|
150
|
+
s = E.subscribeVoices(() => ee(E.listVoices())), H.current = () => {
|
|
151
|
+
o || (o = !0, clearTimeout(c), s(), H.current = null, m(e, "stopped"));
|
|
152
152
|
};
|
|
153
|
-
}, [
|
|
153
|
+
}, [U, E]), $e = x((e, t, n, r, a = !1, c) => {
|
|
154
154
|
let l = n;
|
|
155
155
|
if (l.length === 0) {
|
|
156
|
-
let e =
|
|
157
|
-
e.length > 0 && (l = e,
|
|
156
|
+
let e = E.listVoices();
|
|
157
|
+
e.length > 0 && (l = e, M(e));
|
|
158
158
|
}
|
|
159
|
-
let u =
|
|
159
|
+
let u = Ke(r), ne = ee(te(!0, l, r, N));
|
|
160
160
|
if (ne === "block") {
|
|
161
|
-
let t =
|
|
162
|
-
|
|
161
|
+
let t = D("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: o(u, O) });
|
|
162
|
+
P((n) => new Map(n).set(e, t)), m(e, "declined");
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
165
|
if (ne === "wait-for-voices") {
|
|
166
|
-
|
|
166
|
+
Qe(e, t, r, a, c);
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
let d = {
|
|
170
|
-
voice: s(l, u,
|
|
170
|
+
voice: s(l, u, q[r]),
|
|
171
171
|
lang: u,
|
|
172
|
-
rate:
|
|
173
|
-
}, f =
|
|
172
|
+
rate: qe(r)
|
|
173
|
+
}, f = tt.current;
|
|
174
174
|
if (a && !f.autoSpeakEnabled && !f.sessionSpeaking && re(e)) {
|
|
175
|
-
if (
|
|
175
|
+
if (E.wouldSpeakOnAvatar?.(d) !== !0) {
|
|
176
176
|
m(e, "declined");
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
d.avatarOnly = !0;
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
P((t) => {
|
|
182
182
|
if (!t.has(e)) return t;
|
|
183
183
|
let n = new Map(t);
|
|
184
184
|
return n.delete(e), n;
|
|
185
185
|
});
|
|
186
|
-
let p =
|
|
187
|
-
|
|
186
|
+
let p = q[r], h = typeof p == "string" && i.some((e) => e.name === p) && !l.some((e) => e.name === p);
|
|
187
|
+
F((t) => {
|
|
188
188
|
if (t.has(e) === h) return t;
|
|
189
189
|
let n = new Set(t);
|
|
190
190
|
return h ? n.add(e) : n.delete(e), n;
|
|
191
|
-
}),
|
|
192
|
-
let g =
|
|
193
|
-
|
|
191
|
+
}), U();
|
|
192
|
+
let g = I.current + 1;
|
|
193
|
+
I.current = g, L.current !== e && m(L.current, "stopped"), L.current = e, m(e, "speaking"), A({
|
|
194
194
|
type: "start",
|
|
195
195
|
messageId: e,
|
|
196
196
|
requestId: g
|
|
197
|
-
}),
|
|
198
|
-
let _ =
|
|
197
|
+
}), R.current = a ? g : null, a && he(e, "ttsStarted"), b(z.current, "stopped");
|
|
198
|
+
let _ = a ? void 0 : me(e);
|
|
199
|
+
z.current = _;
|
|
200
|
+
let v = c === void 0 ? ie(t) : ie(t, void 0, void 0, { firstChunkMaxChars: c });
|
|
199
201
|
Pe({
|
|
200
202
|
requestId: g,
|
|
201
|
-
chunks:
|
|
203
|
+
chunks: v,
|
|
202
204
|
index: -1
|
|
203
|
-
}),
|
|
205
|
+
}), V.current !== null && clearTimeout(V.current), V.current = setTimeout(() => {
|
|
204
206
|
Pe((e) => e?.requestId === g && e.index < 0 ? null : e);
|
|
205
207
|
}, Se);
|
|
206
208
|
let ae = () => {
|
|
207
|
-
|
|
209
|
+
b(_, "failed"), I.current === g && V.current !== null && (clearTimeout(V.current), V.current = null), m(e, "failed"), A({
|
|
208
210
|
type: "failed",
|
|
209
211
|
requestId: g
|
|
210
212
|
});
|
|
211
|
-
},
|
|
213
|
+
}, y = !1;
|
|
212
214
|
try {
|
|
213
|
-
|
|
215
|
+
E.speak(v, d, {
|
|
214
216
|
onStart: () => {
|
|
215
|
-
|
|
217
|
+
I.current === g && b(_, "answered"), I.current === g && R.current === g && he(e, "firstAudio");
|
|
216
218
|
},
|
|
217
219
|
onChunkStart: (e) => {
|
|
218
|
-
|
|
220
|
+
y = !0, I.current === g && V.current !== null && (clearTimeout(V.current), V.current = null), Pe((t) => t?.requestId === g ? {
|
|
219
221
|
...t,
|
|
220
222
|
index: e
|
|
221
|
-
} :
|
|
223
|
+
} : I.current === g ? {
|
|
222
224
|
requestId: g,
|
|
223
|
-
chunks:
|
|
225
|
+
chunks: v,
|
|
224
226
|
index: e
|
|
225
227
|
} : t);
|
|
226
228
|
},
|
|
227
229
|
onDeviceFallback: () => {
|
|
228
|
-
|
|
230
|
+
I.current === g && F((t) => t.has(e) ? t : new Set(t).add(e));
|
|
229
231
|
},
|
|
230
232
|
onEnd: () => {
|
|
231
|
-
|
|
233
|
+
b(_, "stopped"), I.current === g && R.current === g && he(e, "audioEnded"), m(e, "spoken"), A({
|
|
232
234
|
type: "finished",
|
|
233
235
|
requestId: g
|
|
234
236
|
});
|
|
235
237
|
},
|
|
236
238
|
onError: (t) => {
|
|
237
|
-
!
|
|
239
|
+
b(_, t === "cancelled" ? "stopped" : "failed"), !y && I.current === g && F((t) => {
|
|
238
240
|
if (!t.has(e)) return t;
|
|
239
241
|
let n = new Set(t);
|
|
240
242
|
return n.delete(e), n;
|
|
241
|
-
}), t === "output-not-cleared" &&
|
|
243
|
+
}), t === "output-not-cleared" && I.current === g && Me({ messageId: e }), m(e, t === "output-not-cleared" ? "not-cleared" : t === "output-left" ? y ? "cut" : "declined" : t === "cancelled" ? "stopped" : "failed"), A({
|
|
242
244
|
type: "failed",
|
|
243
245
|
requestId: g
|
|
244
246
|
});
|
|
@@ -248,229 +250,229 @@ var E = ({ children: f, visible: h = !0, engine: ge }) => {
|
|
|
248
250
|
ae();
|
|
249
251
|
}
|
|
250
252
|
}, [
|
|
251
|
-
|
|
252
|
-
w,
|
|
253
|
+
U,
|
|
253
254
|
E,
|
|
254
|
-
|
|
255
|
-
Ke,
|
|
255
|
+
O,
|
|
256
256
|
q,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
qe,
|
|
258
|
+
Ke,
|
|
259
|
+
D,
|
|
260
|
+
N,
|
|
261
|
+
Qe
|
|
260
262
|
]);
|
|
261
|
-
|
|
262
|
-
Fe.current =
|
|
263
|
-
}, [
|
|
264
|
-
let
|
|
265
|
-
if (!
|
|
266
|
-
let i =
|
|
267
|
-
a &&
|
|
263
|
+
S(() => {
|
|
264
|
+
Fe.current = $e;
|
|
265
|
+
}, [$e]);
|
|
266
|
+
let Q = x((e, t, n, r) => {
|
|
267
|
+
if (!K) return;
|
|
268
|
+
let i = se(_(t, { labels: xe }), n ?? Y), a = _(t, { labels: oe(i, Je) });
|
|
269
|
+
a && $e(e, a, j, i, r?.auto === !0, r?.firstChunkMaxChars);
|
|
268
270
|
}, [
|
|
269
|
-
U,
|
|
270
|
-
qe,
|
|
271
271
|
K,
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
Je,
|
|
273
|
+
Y,
|
|
274
|
+
$e,
|
|
275
|
+
j
|
|
276
|
+
]), et = x((e, t, n) => {
|
|
277
|
+
if (le(k, e)) {
|
|
278
|
+
Z();
|
|
277
279
|
return;
|
|
278
280
|
}
|
|
279
|
-
|
|
281
|
+
Q(e, t, n);
|
|
280
282
|
}, [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
283
|
+
k,
|
|
284
|
+
Q,
|
|
285
|
+
Z
|
|
284
286
|
]);
|
|
285
|
-
|
|
286
|
-
h ||
|
|
287
|
-
}, [h,
|
|
288
|
-
let
|
|
289
|
-
autoSpeakEnabled:
|
|
290
|
-
sessionSpeaking:
|
|
287
|
+
S(() => {
|
|
288
|
+
h || Z();
|
|
289
|
+
}, [h, Z]);
|
|
290
|
+
let tt = w({
|
|
291
|
+
autoSpeakEnabled: W,
|
|
292
|
+
sessionSpeaking: G,
|
|
291
293
|
visible: h,
|
|
292
|
-
isSupported:
|
|
294
|
+
isSupported: K
|
|
293
295
|
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
autoSpeakEnabled:
|
|
297
|
-
sessionSpeaking:
|
|
296
|
+
S(() => {
|
|
297
|
+
tt.current = {
|
|
298
|
+
autoSpeakEnabled: W,
|
|
299
|
+
sessionSpeaking: G,
|
|
298
300
|
visible: h,
|
|
299
|
-
isSupported:
|
|
301
|
+
isSupported: K
|
|
300
302
|
};
|
|
301
303
|
}, [
|
|
302
|
-
|
|
303
|
-
|
|
304
|
+
W,
|
|
305
|
+
G,
|
|
304
306
|
h,
|
|
305
|
-
|
|
307
|
+
K
|
|
306
308
|
]);
|
|
307
|
-
let
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
let e =
|
|
311
|
-
|
|
312
|
-
}, [Be,
|
|
313
|
-
|
|
314
|
-
}, [
|
|
315
|
-
|
|
316
|
-
}, [
|
|
309
|
+
let nt = w(null), rt = w(null), it = w(() => {});
|
|
310
|
+
S(() => {
|
|
311
|
+
Z(), P(/* @__PURE__ */ new Map()), F(/* @__PURE__ */ new Set()), p(n.getState().activeConversationId), nt.current = Be;
|
|
312
|
+
let e = rt.current;
|
|
313
|
+
rt.current = null, e && e.conversationId === Be && it.current(e.conversationId, e.messageId);
|
|
314
|
+
}, [Be, Z]), S(() => {
|
|
315
|
+
P((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Z();
|
|
316
|
+
}, [Y, Z]), S(() => () => {
|
|
317
|
+
H.current?.(), H.current = null, E.cancel();
|
|
318
|
+
}, [E]), S(() => {
|
|
317
319
|
if (typeof window > "u") return;
|
|
318
|
-
let e = () =>
|
|
320
|
+
let e = () => E.cancel();
|
|
319
321
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
320
|
-
}, [
|
|
321
|
-
if (typeof document > "u" || !
|
|
322
|
+
}, [E]), S(() => {
|
|
323
|
+
if (typeof document > "u" || !K) return;
|
|
322
324
|
let e = () => {
|
|
323
325
|
if (document.visibilityState !== "visible") return;
|
|
324
|
-
let e =
|
|
325
|
-
e.length > 0 &&
|
|
326
|
+
let e = E.listVoices();
|
|
327
|
+
e.length > 0 && U(), M(e), Oe(!1), P((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
326
328
|
};
|
|
327
329
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
328
330
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
329
331
|
};
|
|
330
332
|
}, [
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
U,
|
|
334
|
+
E,
|
|
335
|
+
K
|
|
334
336
|
]);
|
|
335
|
-
let
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}, [
|
|
339
|
-
let
|
|
340
|
-
if (r(e) !== t || g(e.id) ||
|
|
341
|
-
let { text: n } =
|
|
337
|
+
let at = w(Q);
|
|
338
|
+
S(() => {
|
|
339
|
+
at.current = Q;
|
|
340
|
+
}, [Q]);
|
|
341
|
+
let $ = x((e, t) => {
|
|
342
|
+
if (r(e) !== t || g(e.id) || B.current?.messageId === e.id || Re.current) return;
|
|
343
|
+
let { text: n } = pe(e.content);
|
|
342
344
|
if (n.trim()) try {
|
|
343
|
-
|
|
345
|
+
at.current(e.id, n, e.metadata?.lang, { auto: !0 });
|
|
344
346
|
} catch {}
|
|
345
|
-
}, []),
|
|
346
|
-
if (e !==
|
|
347
|
-
n.getState().activeConversationId === e && (
|
|
347
|
+
}, []), ot = x((e, t) => {
|
|
348
|
+
if (e !== nt.current) {
|
|
349
|
+
n.getState().activeConversationId === e && (rt.current = {
|
|
348
350
|
conversationId: e,
|
|
349
351
|
messageId: t
|
|
350
352
|
});
|
|
351
353
|
return;
|
|
352
354
|
}
|
|
353
|
-
let r = Te(
|
|
355
|
+
let r = Te(tt.current, t);
|
|
354
356
|
if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
|
|
355
357
|
let i = n.getState();
|
|
356
358
|
if (i.activeConversationId !== e) return;
|
|
357
359
|
let a = i.conversations.find((t) => t.id === e)?.messages.find((e) => e.id === t);
|
|
358
|
-
!a || a.role !== "assistant" ||
|
|
359
|
-
}, [
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}, [
|
|
363
|
-
if (!(!
|
|
360
|
+
!a || a.role !== "assistant" || $(a, r.sessionSpeaking);
|
|
361
|
+
}, [$]);
|
|
362
|
+
S(() => {
|
|
363
|
+
it.current = ot;
|
|
364
|
+
}, [ot]), S(() => {
|
|
365
|
+
if (!(!W && !G || !h || !K)) return n.subscribe((e, t) => {
|
|
364
366
|
let n = e.activeConversationId;
|
|
365
367
|
if (!n || n !== t.activeConversationId) return;
|
|
366
368
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
367
|
-
if (r?.status !== "complete" || !
|
|
369
|
+
if (r?.status !== "complete" || !fe(i?.status)) return;
|
|
368
370
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
369
371
|
if (!a) return;
|
|
370
372
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
371
|
-
!o || o.role !== "assistant" ||
|
|
373
|
+
!o || o.role !== "assistant" || $(o, G);
|
|
372
374
|
});
|
|
373
375
|
}, [
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
W,
|
|
377
|
+
G,
|
|
378
|
+
K,
|
|
377
379
|
h,
|
|
378
|
-
|
|
379
|
-
]),
|
|
380
|
-
if (!(
|
|
380
|
+
$
|
|
381
|
+
]), S(() => {
|
|
382
|
+
if (!(W || G || !He || !h || !K)) return n.subscribe((e, t) => {
|
|
381
383
|
let n = Ee(e, t);
|
|
382
|
-
!n || !re(n.id) ||
|
|
384
|
+
!n || !re(n.id) || $(n, !1);
|
|
383
385
|
});
|
|
384
386
|
}, [
|
|
385
|
-
|
|
386
|
-
|
|
387
|
+
W,
|
|
388
|
+
G,
|
|
387
389
|
He,
|
|
388
|
-
|
|
390
|
+
K,
|
|
389
391
|
h,
|
|
390
|
-
|
|
392
|
+
$
|
|
391
393
|
]);
|
|
392
|
-
let
|
|
394
|
+
let st = x((e) => {
|
|
393
395
|
if (e.type === "abort") {
|
|
394
|
-
let t =
|
|
396
|
+
let t = B.current;
|
|
395
397
|
if (!t || t.messageId !== e.messageId) return;
|
|
396
|
-
|
|
398
|
+
B.current = null, (t.requestId === null ? t.waiting && H.current !== null : I.current === t.requestId) && Z();
|
|
397
399
|
return;
|
|
398
400
|
}
|
|
399
|
-
let { messageId: t, item: r } = e, i = Te(
|
|
400
|
-
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || g(t) || Re.current ||
|
|
401
|
-
let { text: a } =
|
|
401
|
+
let { messageId: t, item: r } = e, i = Te(tt.current, t);
|
|
402
|
+
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || g(t) || Re.current || B.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || nt.current !== r.conversationId) return;
|
|
403
|
+
let { text: a } = pe(r.text);
|
|
402
404
|
if (!a.trim()) return;
|
|
403
|
-
let o =
|
|
405
|
+
let o = I.current;
|
|
404
406
|
try {
|
|
405
|
-
|
|
407
|
+
at.current(t, a, r.lang, {
|
|
406
408
|
auto: !0,
|
|
407
409
|
firstChunkMaxChars: 110
|
|
408
410
|
});
|
|
409
411
|
} catch {}
|
|
410
|
-
let s =
|
|
411
|
-
|
|
412
|
+
let s = I.current !== o;
|
|
413
|
+
B.current = {
|
|
412
414
|
messageId: t,
|
|
413
|
-
requestId: s ?
|
|
414
|
-
waiting: !s &&
|
|
415
|
+
requestId: s ? I.current : null,
|
|
416
|
+
waiting: !s && H.current !== null
|
|
415
417
|
};
|
|
416
|
-
}, [
|
|
417
|
-
|
|
418
|
-
let
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
]),
|
|
424
|
-
isSupported:
|
|
425
|
-
availability:
|
|
426
|
-
isBlocked:
|
|
427
|
-
disabledReason:
|
|
428
|
-
blockedFor:
|
|
429
|
-
deviceFallbackFor:
|
|
430
|
-
voiceChoices:
|
|
431
|
-
spokenChunks:
|
|
432
|
-
activeVoiceName:
|
|
433
|
-
preferredVoiceName:
|
|
434
|
-
setVoice: (e) => Ge(
|
|
435
|
-
speakingMessageId:
|
|
418
|
+
}, [Z]);
|
|
419
|
+
S(() => d.subscribe(st), [st]);
|
|
420
|
+
let ct = C(() => l(j, J.tag), [j, J]), lt = C(() => s(j, J.tag, q[Y]), [
|
|
421
|
+
j,
|
|
422
|
+
J,
|
|
423
|
+
q,
|
|
424
|
+
Y
|
|
425
|
+
]), ut = C(() => ({
|
|
426
|
+
isSupported: K,
|
|
427
|
+
availability: X,
|
|
428
|
+
isBlocked: X === "no-voices",
|
|
429
|
+
disabledReason: X === "no-voices" ? D("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
430
|
+
blockedFor: Xe,
|
|
431
|
+
deviceFallbackFor: Ze,
|
|
432
|
+
voiceChoices: ct,
|
|
433
|
+
spokenChunks: ue(k, Ne),
|
|
434
|
+
activeVoiceName: lt?.name ?? null,
|
|
435
|
+
preferredVoiceName: q[Y] ?? null,
|
|
436
|
+
setVoice: (e) => Ge(Y, e),
|
|
437
|
+
speakingMessageId: k.status === "speaking" ? k.messageId : null,
|
|
436
438
|
outputNotCleared: je,
|
|
437
|
-
isSpeaking: (e) =>
|
|
438
|
-
toggle:
|
|
439
|
-
stop:
|
|
440
|
-
autoSpeakEnabled:
|
|
439
|
+
isSpeaking: (e) => le(k, e),
|
|
440
|
+
toggle: et,
|
|
441
|
+
stop: Z,
|
|
442
|
+
autoSpeakEnabled: W,
|
|
441
443
|
setAutoSpeak: Ie,
|
|
442
|
-
sessionSpeaking:
|
|
444
|
+
sessionSpeaking: G,
|
|
443
445
|
setSessionSpeaking: Le,
|
|
444
446
|
setSessionMicOpen: ze,
|
|
445
|
-
speakFinishedReply:
|
|
446
|
-
previewVoice:
|
|
447
|
+
speakFinishedReply: ot,
|
|
448
|
+
previewVoice: Ye
|
|
447
449
|
}), [
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
Ye,
|
|
450
|
+
K,
|
|
451
|
+
X,
|
|
451
452
|
Xe,
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
453
|
+
Ze,
|
|
454
|
+
ct,
|
|
455
|
+
lt,
|
|
456
|
+
q,
|
|
455
457
|
Ge,
|
|
456
|
-
K,
|
|
457
|
-
D,
|
|
458
|
-
je,
|
|
459
|
-
Qe,
|
|
460
458
|
Y,
|
|
461
|
-
|
|
459
|
+
k,
|
|
460
|
+
je,
|
|
461
|
+
et,
|
|
462
|
+
Z,
|
|
463
|
+
W,
|
|
462
464
|
Ie,
|
|
463
|
-
|
|
465
|
+
G,
|
|
464
466
|
ze,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
467
|
+
ot,
|
|
468
|
+
Ye,
|
|
469
|
+
D,
|
|
468
470
|
Ne
|
|
469
471
|
]);
|
|
470
472
|
return /* @__PURE__ */ be(De.Provider, {
|
|
471
|
-
value:
|
|
473
|
+
value: ut,
|
|
472
474
|
children: f
|
|
473
475
|
});
|
|
474
476
|
};
|
|
475
477
|
//#endregion
|
|
476
|
-
export {
|
|
478
|
+
export { O as AssistantSpeechProvider, D as useAssistantSpeech };
|