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