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