@burdenoff/microfe-healthybowl 2026.902.21 → 2026.902.23
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/components/assistant/AssistantChatArea.js +244 -243
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/AssistantSpeechProvider.js +175 -174
- package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
- package/dist/components/assistant/voice/AssistantVoiceSession.js.map +1 -1
- package/dist/components/assistant/voice/VoiceConversationView.js +36 -20
- package/dist/components/assistant/voice/VoiceConversationView.js.map +1 -1
- package/dist/components/assistant/voice/VoiceTranscriptDrawer.js.map +1 -1
- package/dist/hooks/useVoiceSession.js +10 -10
- package/dist/hooks/useVoiceSession.js.map +1 -1
- package/dist/types/assistant.js.map +1 -1
- package/dist/utils/voiceTurnVisibility.js +22 -4
- package/dist/utils/voiceTurnVisibility.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,21 +2,22 @@ import { getSpeechEngine as e } from "../../services/speech/createSpeechEngine.j
|
|
|
2
2
|
import "../../services/speech/index.js";
|
|
3
3
|
import { useAssistantStore as t } from "../../store/assistantStore.js";
|
|
4
4
|
import { useTr as n } from "../../shared/hooks/useTr.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { isVoiceTurn as r } from "../../utils/voiceTurnVisibility.js";
|
|
6
|
+
import { voicePreviewText as i } from "../../utils/voicePreview.js";
|
|
7
|
+
import { chunkForSpeech as a, toSpeakableText as o } from "../../utils/speakableText.js";
|
|
8
|
+
import { speechLabelsFor as s } from "../../config/speechLabels.js";
|
|
9
|
+
import { VOICE_LIST_TIMEOUT_MS as c, languageDisplayName as ee, selectVoiceForLocale as l, speechGate as te, speechLangForLocale as ne, voiceAvailability as u, voicesForLocale as re } from "../../utils/speechVoices.js";
|
|
9
10
|
import { resolveSpeechLocale as ie } from "../../utils/replyLanguage.js";
|
|
10
|
-
import { findAssistantLanguage as
|
|
11
|
-
import { resolveLanguagePair as
|
|
12
|
-
import { IDLE_PLAYBACK as
|
|
13
|
-
import { isTurnInFlight as
|
|
14
|
-
import { parseToolActivity as
|
|
15
|
-
import { createContext as
|
|
16
|
-
import { useI18n as
|
|
17
|
-
import { jsx as
|
|
11
|
+
import { findAssistantLanguage as ae } from "../../config/assistantLanguages.js";
|
|
12
|
+
import { resolveLanguagePair as oe } from "../../config/assistantLanguagePair.js";
|
|
13
|
+
import { IDLE_PLAYBACK as se, isSpeakingMessage as d, speechPlaybackReducer as ce } from "../../utils/speechPlayback.js";
|
|
14
|
+
import { isTurnInFlight as le } from "../../utils/assistantTurnState.js";
|
|
15
|
+
import { parseToolActivity as ue } from "./AssistantToolActivity.js";
|
|
16
|
+
import { createContext as de, useCallback as f, useContext as p, useEffect as m, useMemo as h, useReducer as fe, useRef as g, useState as _ } from "react";
|
|
17
|
+
import { useI18n as pe } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
18
|
+
import { jsx as me } from "react/jsx-runtime";
|
|
18
19
|
//#region src/components/assistant/AssistantSpeechProvider.tsx
|
|
19
|
-
var
|
|
20
|
+
var he = {
|
|
20
21
|
codeBlock: "",
|
|
21
22
|
image: "",
|
|
22
23
|
link: "",
|
|
@@ -25,7 +26,7 @@ var pe = {
|
|
|
25
26
|
emailAt: "at",
|
|
26
27
|
emailDot: "dot",
|
|
27
28
|
nestedItem: ""
|
|
28
|
-
},
|
|
29
|
+
}, v = de({
|
|
29
30
|
isSupported: !1,
|
|
30
31
|
availability: "unsupported",
|
|
31
32
|
isBlocked: !0,
|
|
@@ -45,236 +46,236 @@ var pe = {
|
|
|
45
46
|
setSessionSpeaking: () => {},
|
|
46
47
|
previewVoice: () => {}
|
|
47
48
|
});
|
|
48
|
-
function
|
|
49
|
-
return
|
|
49
|
+
function y() {
|
|
50
|
+
return p(v);
|
|
50
51
|
}
|
|
51
|
-
var
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
}, []),
|
|
55
|
-
|
|
56
|
-
if (!
|
|
52
|
+
var b = ({ children: de, visible: p = !0, engine: y = e() }) => {
|
|
53
|
+
let b = n(), { locale: x } = pe(), [S, C] = fe(ce, se), [w, T] = _(() => y.listVoices()), [E, D] = _(!1), [O, k] = _(() => /* @__PURE__ */ new Map()), A = g(0), j = g(null), M = g(() => {}), N = f(() => {
|
|
54
|
+
j.current?.(), j.current = null;
|
|
55
|
+
}, []), P = t((e) => e.autoSpeakEnabled), F = t((e) => e.setAutoSpeak), [I, ge] = _(!1), _e = t((e) => e.activeConversationId), L = h(() => y.isSupported(), [y]);
|
|
56
|
+
m(() => {
|
|
57
|
+
if (!L) return;
|
|
57
58
|
let e = () => {
|
|
58
|
-
|
|
59
|
+
T(y.listVoices()), k((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
59
60
|
};
|
|
60
|
-
return e(),
|
|
61
|
-
}, [
|
|
62
|
-
let
|
|
63
|
-
z,
|
|
64
|
-
B,
|
|
65
|
-
S
|
|
66
|
-
]), W = U.code, G = p((e) => u(e)?.tag ?? l(e), []), K = p((e) => u(e)?.rate ?? .9, []), q = g(() => ne(R, T, U.tag, D), [
|
|
61
|
+
return e(), y.subscribeVoices(e);
|
|
62
|
+
}, [y, L]);
|
|
63
|
+
let R = t((e) => e.assistantLanguage), z = t((e) => e.replyLanguage), B = t((e) => e.preferredVoices), V = t((e) => e.setPreferredVoice), H = h(() => oe(R, z, x).reply, [
|
|
67
64
|
R,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
z,
|
|
66
|
+
x
|
|
67
|
+
]), U = H.code, W = f((e) => ae(e)?.tag ?? ne(e), []), G = f((e) => ae(e)?.rate ?? .9, []), K = h(() => u(L, w, H.tag, E), [
|
|
68
|
+
L,
|
|
69
|
+
w,
|
|
70
|
+
H,
|
|
71
|
+
E
|
|
72
|
+
]), q = h(() => ({
|
|
73
|
+
codeBlock: b("healthybowl.assistant.speech.codeBlock", "Code block"),
|
|
74
|
+
image: b("healthybowl.assistant.speech.image", "image"),
|
|
75
|
+
link: b("healthybowl.assistant.speech.link", "link"),
|
|
76
|
+
largeTable: b("healthybowl.assistant.speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
|
|
77
|
+
truncated: b("healthybowl.assistant.speech.truncated", "The rest of this message is not read aloud"),
|
|
78
|
+
nestedItem: b("healthybowl.assistant.speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
79
|
+
emailAt: b("healthybowl.assistant.speech.emailAt", "at"),
|
|
80
|
+
emailDot: b("healthybowl.assistant.speech.emailDot", "dot")
|
|
81
|
+
}), [b]), J = f(() => {
|
|
82
|
+
N(), y.cancel(), C({ type: "stop" });
|
|
83
|
+
}, [N, y]), Y = f((e) => {
|
|
84
|
+
let t = y.listVoices().find((t) => t.name === e) ?? null;
|
|
85
|
+
t && (J(), y.speak([i(U)], {
|
|
85
86
|
voice: t,
|
|
86
|
-
lang:
|
|
87
|
+
lang: W(U)
|
|
87
88
|
}));
|
|
88
89
|
}, [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
]),
|
|
94
|
-
|
|
90
|
+
y,
|
|
91
|
+
U,
|
|
92
|
+
J,
|
|
93
|
+
W
|
|
94
|
+
]), X = f((e) => O.get(e) ?? null, [O]), ve = f((e, t, n) => {
|
|
95
|
+
N();
|
|
95
96
|
let r = !1, i = () => {}, a = (a) => {
|
|
96
97
|
if (!r) {
|
|
97
|
-
if (r = !0,
|
|
98
|
-
|
|
98
|
+
if (r = !0, j.current = null, clearTimeout(o), i(), a.length === 0) {
|
|
99
|
+
D(!0);
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
+
T(a), M.current(e, t, a, n);
|
|
102
103
|
}
|
|
103
|
-
}, o = setTimeout(() => a(
|
|
104
|
-
i =
|
|
105
|
-
r || (r = !0, clearTimeout(o), i(),
|
|
104
|
+
}, o = setTimeout(() => a(y.listVoices()), c);
|
|
105
|
+
i = y.subscribeVoices(() => a(y.listVoices())), j.current = () => {
|
|
106
|
+
r || (r = !0, clearTimeout(o), i(), j.current = null);
|
|
106
107
|
};
|
|
107
|
-
}, [
|
|
108
|
-
let
|
|
109
|
-
if (
|
|
110
|
-
let e =
|
|
111
|
-
e.length > 0 && (
|
|
108
|
+
}, [N, y]), Z = f((e, t, n, r) => {
|
|
109
|
+
let i = n;
|
|
110
|
+
if (i.length === 0) {
|
|
111
|
+
let e = y.listVoices();
|
|
112
|
+
e.length > 0 && (i = e, T(e));
|
|
112
113
|
}
|
|
113
|
-
let o =
|
|
114
|
+
let o = W(r), s = te(u(!0, i, r, E));
|
|
114
115
|
if (s === "block") {
|
|
115
|
-
let t =
|
|
116
|
-
|
|
116
|
+
let t = b("healthybowl.assistant.speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: ee(o, x) });
|
|
117
|
+
k((n) => new Map(n).set(e, t));
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
120
|
if (s === "wait-for-voices") {
|
|
120
|
-
|
|
121
|
+
ve(e, t, r);
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
k((t) => {
|
|
124
125
|
if (!t.has(e)) return t;
|
|
125
126
|
let n = new Map(t);
|
|
126
127
|
return n.delete(e), n;
|
|
127
128
|
});
|
|
128
|
-
let
|
|
129
|
-
|
|
129
|
+
let c = A.current + 1;
|
|
130
|
+
A.current = c, C({
|
|
130
131
|
type: "start",
|
|
131
132
|
messageId: e,
|
|
132
|
-
requestId:
|
|
133
|
-
}),
|
|
134
|
-
voice:
|
|
133
|
+
requestId: c
|
|
134
|
+
}), y.speak(a(t), {
|
|
135
|
+
voice: l(i, o, B[r]),
|
|
135
136
|
lang: o,
|
|
136
|
-
rate:
|
|
137
|
+
rate: G(r)
|
|
137
138
|
}, {
|
|
138
|
-
onEnd: () =>
|
|
139
|
+
onEnd: () => C({
|
|
139
140
|
type: "finished",
|
|
140
|
-
requestId:
|
|
141
|
+
requestId: c
|
|
141
142
|
}),
|
|
142
|
-
onError: () =>
|
|
143
|
+
onError: () => C({
|
|
143
144
|
type: "failed",
|
|
144
|
-
requestId:
|
|
145
|
+
requestId: c
|
|
145
146
|
})
|
|
146
147
|
});
|
|
147
148
|
}, [
|
|
148
|
-
|
|
149
|
-
S,
|
|
150
|
-
V,
|
|
151
|
-
K,
|
|
152
|
-
G,
|
|
149
|
+
y,
|
|
153
150
|
x,
|
|
154
|
-
|
|
155
|
-
|
|
151
|
+
B,
|
|
152
|
+
G,
|
|
153
|
+
W,
|
|
154
|
+
b,
|
|
155
|
+
E,
|
|
156
|
+
ve
|
|
156
157
|
]);
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
m(() => {
|
|
159
|
+
M.current = Z;
|
|
159
160
|
}, [Z]);
|
|
160
|
-
let Q =
|
|
161
|
-
if (!
|
|
162
|
-
let r = ie(
|
|
163
|
-
i && Z(e, i,
|
|
161
|
+
let Q = f((e, t, n) => {
|
|
162
|
+
if (!L) return;
|
|
163
|
+
let r = ie(o(t, { labels: he }), n ?? U), i = o(t, { labels: s(r, q) });
|
|
164
|
+
i && Z(e, i, w, r);
|
|
164
165
|
}, [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
L,
|
|
167
|
+
q,
|
|
168
|
+
U,
|
|
168
169
|
Z,
|
|
169
|
-
|
|
170
|
-
]),
|
|
171
|
-
if (d(
|
|
172
|
-
|
|
170
|
+
w
|
|
171
|
+
]), ye = f((e, t, n) => {
|
|
172
|
+
if (d(S, e)) {
|
|
173
|
+
J();
|
|
173
174
|
return;
|
|
174
175
|
}
|
|
175
176
|
Q(e, t, n);
|
|
176
177
|
}, [
|
|
177
|
-
|
|
178
|
+
S,
|
|
178
179
|
Q,
|
|
179
|
-
|
|
180
|
+
J
|
|
180
181
|
]);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}, [
|
|
184
|
-
|
|
185
|
-
}, [
|
|
186
|
-
|
|
187
|
-
}, [
|
|
188
|
-
|
|
189
|
-
}, [
|
|
182
|
+
m(() => {
|
|
183
|
+
p || J();
|
|
184
|
+
}, [p, J]), m(() => {
|
|
185
|
+
J(), k(/* @__PURE__ */ new Map());
|
|
186
|
+
}, [_e, J]), m(() => {
|
|
187
|
+
k((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), J();
|
|
188
|
+
}, [U, J]), m(() => () => {
|
|
189
|
+
j.current?.(), j.current = null, y.cancel();
|
|
190
|
+
}, [y]), m(() => {
|
|
190
191
|
if (typeof window > "u") return;
|
|
191
|
-
let e = () =>
|
|
192
|
+
let e = () => y.cancel();
|
|
192
193
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
193
|
-
}, [
|
|
194
|
-
if (typeof document > "u" || !
|
|
194
|
+
}, [y]), m(() => {
|
|
195
|
+
if (typeof document > "u" || !L) return;
|
|
195
196
|
let e = () => {
|
|
196
197
|
if (document.visibilityState !== "visible") return;
|
|
197
|
-
let e =
|
|
198
|
-
e.length > 0 &&
|
|
198
|
+
let e = y.listVoices();
|
|
199
|
+
e.length > 0 && N(), T(e), D(!1), k((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
199
200
|
};
|
|
200
201
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
201
202
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
202
203
|
};
|
|
203
204
|
}, [
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
N,
|
|
206
|
+
y,
|
|
207
|
+
L
|
|
207
208
|
]);
|
|
208
|
-
let
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}, [Q]),
|
|
212
|
-
if (!(!
|
|
209
|
+
let be = g(Q);
|
|
210
|
+
m(() => {
|
|
211
|
+
be.current = Q;
|
|
212
|
+
}, [Q]), m(() => {
|
|
213
|
+
if (!(!P && !I || !p || !L)) return t.subscribe((e, t) => {
|
|
213
214
|
let n = e.activeConversationId;
|
|
214
215
|
if (!n || n !== t.activeConversationId) return;
|
|
215
|
-
let
|
|
216
|
-
if (
|
|
217
|
-
let
|
|
218
|
-
if (!
|
|
219
|
-
let
|
|
220
|
-
if (!
|
|
221
|
-
let { text:
|
|
222
|
-
|
|
216
|
+
let i = e.processingByConversationId[n], a = t.processingByConversationId[n];
|
|
217
|
+
if (i?.status !== "complete" || !le(a?.status)) return;
|
|
218
|
+
let o = i.messageId ?? a?.messageId ?? null;
|
|
219
|
+
if (!o) return;
|
|
220
|
+
let s = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === o);
|
|
221
|
+
if (!s || s.role !== "assistant" || r(s) !== I) return;
|
|
222
|
+
let { text: c } = ue(s.content);
|
|
223
|
+
c.trim() && be.current(o, c, s.metadata?.lang);
|
|
223
224
|
});
|
|
224
225
|
}, [
|
|
225
|
-
|
|
226
|
+
P,
|
|
227
|
+
I,
|
|
226
228
|
L,
|
|
227
|
-
|
|
228
|
-
m
|
|
229
|
+
p
|
|
229
230
|
]);
|
|
230
|
-
let
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
]),
|
|
236
|
-
isSupported:
|
|
237
|
-
availability:
|
|
238
|
-
isBlocked:
|
|
239
|
-
disabledReason:
|
|
240
|
-
blockedFor:
|
|
241
|
-
voiceChoices:
|
|
231
|
+
let xe = h(() => re(w, H.tag), [w, H]), $ = h(() => l(w, H.tag, B[U]), [
|
|
232
|
+
w,
|
|
233
|
+
H,
|
|
234
|
+
B,
|
|
235
|
+
U
|
|
236
|
+
]), Se = h(() => ({
|
|
237
|
+
isSupported: L,
|
|
238
|
+
availability: K,
|
|
239
|
+
isBlocked: K === "no-voices",
|
|
240
|
+
disabledReason: K === "no-voices" ? b("healthybowl.assistant.speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
241
|
+
blockedFor: X,
|
|
242
|
+
voiceChoices: xe,
|
|
242
243
|
activeVoiceName: $?.name ?? null,
|
|
243
|
-
preferredVoiceName:
|
|
244
|
-
setVoice: (e) =>
|
|
245
|
-
speakingMessageId:
|
|
246
|
-
isSpeaking: (e) => d(
|
|
247
|
-
toggle:
|
|
248
|
-
stop:
|
|
249
|
-
autoSpeakEnabled:
|
|
250
|
-
setAutoSpeak:
|
|
251
|
-
sessionSpeaking:
|
|
252
|
-
setSessionSpeaking:
|
|
253
|
-
previewVoice:
|
|
244
|
+
preferredVoiceName: B[U] ?? null,
|
|
245
|
+
setVoice: (e) => V(U, e),
|
|
246
|
+
speakingMessageId: S.status === "speaking" ? S.messageId : null,
|
|
247
|
+
isSpeaking: (e) => d(S, e),
|
|
248
|
+
toggle: ye,
|
|
249
|
+
stop: J,
|
|
250
|
+
autoSpeakEnabled: P,
|
|
251
|
+
setAutoSpeak: F,
|
|
252
|
+
sessionSpeaking: I,
|
|
253
|
+
setSessionSpeaking: ge,
|
|
254
|
+
previewVoice: Y
|
|
254
255
|
}), [
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
256
|
+
L,
|
|
257
|
+
K,
|
|
258
|
+
X,
|
|
259
|
+
xe,
|
|
259
260
|
$,
|
|
261
|
+
B,
|
|
260
262
|
V,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
U,
|
|
264
|
+
S,
|
|
265
|
+
ye,
|
|
266
|
+
J,
|
|
267
|
+
P,
|
|
266
268
|
F,
|
|
267
269
|
I,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
x
|
|
270
|
+
Y,
|
|
271
|
+
b
|
|
271
272
|
]);
|
|
272
|
-
return /* @__PURE__ */
|
|
273
|
-
value:
|
|
274
|
-
children:
|
|
273
|
+
return /* @__PURE__ */ me(v.Provider, {
|
|
274
|
+
value: Se,
|
|
275
|
+
children: de
|
|
275
276
|
});
|
|
276
277
|
};
|
|
277
278
|
//#endregion
|
|
278
|
-
export {
|
|
279
|
+
export { b as AssistantSpeechProvider, y as useAssistantSpeech };
|
|
279
280
|
|
|
280
281
|
//# sourceMappingURL=AssistantSpeechProvider.js.map
|