@burdenoff/microfe-healthybowl 2026.901.3 → 2026.901.5
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 +94 -87
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/voice/AssistantVoiceSession.js +3 -3
- package/dist/components/assistant/voice/AssistantVoiceSession.js.map +1 -1
- package/dist/hooks/useVoiceSession.js +2 -0
- package/dist/hooks/useVoiceSession.js.map +1 -1
- package/dist/services/speech/hostedTtsProtocol.js +13 -10
- package/dist/services/speech/hostedTtsProtocol.js.map +1 -1
- package/dist/services/speech/hostedTtsSpeechEngine.js +45 -45
- package/dist/services/speech/hostedTtsSpeechEngine.js.map +1 -1
- package/dist/types/assistant.js.map +1 -1
- package/dist/utils/assistantPrompt.js +15 -5
- package/dist/utils/assistantPrompt.js.map +1 -1
- package/dist/utils/voiceTurnVisibility.js +14 -0
- package/dist/utils/voiceTurnVisibility.js.map +1 -0
- package/package.json +1 -1
|
@@ -20,24 +20,25 @@ import { dispatchAssistantQuotaExhausted as ue, notifyAiCreditsUpdated as de } f
|
|
|
20
20
|
import { buildPromptForMode as fe } from "../../utils/assistantPrompt.js";
|
|
21
21
|
import { isMultimodalBodyRejection as pe, isRecoverableAssistantError as me } from "../../utils/assistantTransportErrors.js";
|
|
22
22
|
import { pollDelayMs as he } from "../../utils/assistantPollSchedule.js";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
23
|
+
import { chatTurns as ge, voiceTurnsOnly as _e } from "../../utils/voiceTurnVisibility.js";
|
|
24
|
+
import { createReadinessTracker as ve } from "../../utils/sandboxReadiness.js";
|
|
25
|
+
import { useCallback as T, useEffect as E, useMemo as D, useRef as O, useState as ye } from "react";
|
|
26
|
+
import { useI18n as be } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
27
|
+
import { jsx as k, jsxs as xe } from "react/jsx-runtime";
|
|
28
|
+
import { useGatewayClient as Se } from "@burdenoff/fe-libs/shared/graphql";
|
|
29
|
+
import { useAuthToken as Ce } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
30
|
+
import { getAssistantMedia as we } from "@burdenoff/fe-libs/shared/assistant";
|
|
30
31
|
//#region src/components/assistant/AssistantChatArea.tsx
|
|
31
|
-
var
|
|
32
|
+
var Te = {
|
|
32
33
|
general: 18e4,
|
|
33
34
|
assistant: 18e4,
|
|
34
35
|
"api-calls": 18e4,
|
|
35
36
|
"vibe-plugins": 6e5
|
|
36
|
-
},
|
|
37
|
-
function
|
|
37
|
+
}, Ee = 18e4;
|
|
38
|
+
function De() {
|
|
38
39
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function Oe(e) {
|
|
41
42
|
return e.replace(/(Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/(X-Workspace-Authorization\s*:\s*Bearer\s+)[^\s\n]+/gi, "$1[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+\b/g, "[REDACTED_JWT]").replace(/\bsk-ant-[A-Za-z0-9-]+\b/g, "[REDACTED_API_KEY]");
|
|
42
43
|
}
|
|
43
44
|
function A(e) {
|
|
@@ -52,13 +53,13 @@ function M(e) {
|
|
|
52
53
|
return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function ke(e, t) {
|
|
56
57
|
let n = e.filter((e) => e.info?.role === "assistant" && A(e) > t).sort((e, t) => A(e) - A(t));
|
|
57
58
|
if (n.length === 0) return {
|
|
58
59
|
content: "Thinking...",
|
|
59
60
|
done: !1
|
|
60
61
|
};
|
|
61
|
-
let r = n[n.length - 1], i = j(r.parts), a =
|
|
62
|
+
let r = n[n.length - 1], i = j(r.parts), a = we(r.parts), o = M(r.parts);
|
|
62
63
|
return {
|
|
63
64
|
content: [
|
|
64
65
|
i,
|
|
@@ -69,7 +70,7 @@ function De(e, t) {
|
|
|
69
70
|
tokens: r.info?.tokens
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function Ae(e) {
|
|
73
74
|
switch (e) {
|
|
74
75
|
case "provisioning": return "Starting assistant environment...";
|
|
75
76
|
case "connecting": return "Connecting to assistant...";
|
|
@@ -77,21 +78,21 @@ function Oe(e) {
|
|
|
77
78
|
default: return "";
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
var N = ({ visible:
|
|
81
|
-
let j = t(), M =
|
|
81
|
+
var N = ({ visible: we = !0 }) => {
|
|
82
|
+
let j = t(), M = Se("workspace"), { getAccessToken: N, getWorkspaceToken: je, userId: Me } = Ce(), { locale: P } = be(), F = e((e) => e.assistantLanguage), Ne = D(() => g(F, P).english, [F, P]), Pe = h(F) !== null, Fe = D(() => g(F, P).code, [F, P]), { conversations: Ie, activeConversationId: I, mode: L, processingByConversationId: Le, setMode: R, setConversationMode: z, setActiveConversation: Re, createConversation: B, addMessage: ze, updateMessage: Be, patchMessage: V, setConversationProcessing: H, clearConversationProcessing: Ve, setBackendSessionId: He, clearBackendSessionId: U, setSandbox: W, clearSandbox: Ue, acknowledgeApiCalls: We } = e(), G = Ie.find((e) => e.id === I)?.messages ?? [], K = I ? Le[I] : void 0, q = _(K?.status), Ge = q ? K?.messageId ?? null : null, Ke = K?.status === "error" ? K.messageId : null, { canUseApiCalls: J, loading: qe } = ce(y()), Je = D(() => S.filter((e) => !e.requiresAdmin || J), [J]), [Ye, Xe] = ye(null), Ze = O({}), Y = O(ve()), Qe = O(/* @__PURE__ */ new Set());
|
|
82
83
|
E(() => {
|
|
83
|
-
if (
|
|
84
|
+
if (qe) return;
|
|
84
85
|
let e = S.find((e) => e.id === L);
|
|
85
86
|
(!e || e.requiresAdmin && !J) && L !== "assistant" && R("assistant");
|
|
86
87
|
}, [
|
|
87
88
|
L,
|
|
88
89
|
J,
|
|
89
|
-
|
|
90
|
+
qe,
|
|
90
91
|
R
|
|
91
92
|
]);
|
|
92
93
|
let X = T((e, t, n, r) => {
|
|
93
|
-
H(e, n, t, null), r ?
|
|
94
|
-
}, [H,
|
|
94
|
+
H(e, n, t, null), r ? Be(e, t, r) : Be(e, t, Ae(n));
|
|
95
|
+
}, [H, Be]), $e = T(async (t, n, a, s, c) => {
|
|
95
96
|
let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
|
|
96
97
|
if (Y.current.isFresh(e)) return !0;
|
|
97
98
|
try {
|
|
@@ -117,7 +118,7 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
117
118
|
} catch {
|
|
118
119
|
U(t), m = null;
|
|
119
120
|
}
|
|
120
|
-
return m || (X(t, n, "connecting", "Preparing session..."), m = (await i(M, u, s, a, c)).sessionId,
|
|
121
|
+
return m || (X(t, n, "connecting", "Preparing session..."), m = (await i(M, u, s, a, c)).sessionId, He(t, m)), {
|
|
121
122
|
sandboxId: u,
|
|
122
123
|
sessionId: m
|
|
123
124
|
};
|
|
@@ -125,39 +126,45 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
125
126
|
M,
|
|
126
127
|
U,
|
|
127
128
|
N,
|
|
128
|
-
|
|
129
|
+
He,
|
|
129
130
|
W,
|
|
130
131
|
X
|
|
131
132
|
]), Z = T(async (t, r = [], i = {}) => {
|
|
132
133
|
let o = e.getState(), l = o.activeConversationId ?? I;
|
|
133
|
-
if (l && (_(o.processingByConversationId[l]?.status) ||
|
|
134
|
+
if (l && (_(o.processingByConversationId[l]?.status) || Qe.current.has(l))) return;
|
|
134
135
|
let f = o.mode, p = I, h = p ? e.getState().conversations.find((e) => e.id === p) : void 0;
|
|
135
136
|
if (p ? h && h.mode !== f && (h.messages.length > 0 || h.backendSessionId) ? p = B(void 0, f) : h && h.mode !== f && z(p, f) : p = B(void 0, f), !p) return;
|
|
136
|
-
|
|
137
|
+
Ze.current[p] = r;
|
|
137
138
|
let g = ee(), v = {
|
|
138
139
|
accessToken: N(),
|
|
139
|
-
workspaceToken:
|
|
140
|
-
userId:
|
|
140
|
+
workspaceToken: je(),
|
|
141
|
+
userId: Me,
|
|
141
142
|
organizationId: y()
|
|
142
143
|
}, b = {
|
|
143
|
-
id:
|
|
144
|
+
id: De(),
|
|
144
145
|
role: "user",
|
|
145
146
|
content: t,
|
|
146
147
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
147
|
-
metadata:
|
|
148
|
+
metadata: {
|
|
149
|
+
...r.length ? { attachments: r.map(ae) } : {},
|
|
150
|
+
...i.dictated === !0 ? { voice: !0 } : {}
|
|
151
|
+
}
|
|
148
152
|
};
|
|
149
|
-
|
|
150
|
-
let x =
|
|
151
|
-
|
|
153
|
+
ze(p, b);
|
|
154
|
+
let x = De();
|
|
155
|
+
ze(p, {
|
|
152
156
|
id: x,
|
|
153
157
|
role: "assistant",
|
|
154
158
|
content: "",
|
|
155
159
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
156
|
-
metadata: {
|
|
160
|
+
metadata: {
|
|
161
|
+
lang: Fe,
|
|
162
|
+
...i.dictated === !0 ? { voice: !0 } : {}
|
|
163
|
+
}
|
|
157
164
|
}), H(p, "provisioning", x, null);
|
|
158
|
-
let S = (e, t, n, r, i =
|
|
165
|
+
let S = (e, t, n, r, i = Fe) => {
|
|
159
166
|
V(p, x, {
|
|
160
|
-
content:
|
|
167
|
+
content: Oe(e),
|
|
161
168
|
metadata: {
|
|
162
169
|
lang: i,
|
|
163
170
|
...t?.length ? { artifacts: t } : {},
|
|
@@ -178,9 +185,9 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
178
185
|
console.warn("[assistant] AI-credit pre-flight check failed with a non-quota error; proceeding — gateway @usage(checkQuota) still enforces the real budget downstream", e);
|
|
179
186
|
}
|
|
180
187
|
try {
|
|
181
|
-
let { sandboxId: e, sessionId: n } = await
|
|
188
|
+
let { sandboxId: e, sessionId: n } = await $e(p, x, f, g, v), l = (await c(M, e, g, n, v, 50).catch(() => [])).reduce((e, t) => Math.max(e, A(t)), 0);
|
|
182
189
|
X(p, x, "streaming", "Thinking...");
|
|
183
|
-
let h = fe(f, ne(t, r),
|
|
190
|
+
let h = fe(f, ne(t, r), Ne, Pe, i.dictated === !0), _ = te(h, r), y = ie(_), ee = y > 0, ae = m();
|
|
184
191
|
o = re(r) > y;
|
|
185
192
|
try {
|
|
186
193
|
await d(M, e, g, n, h, f, ae, v, _);
|
|
@@ -188,8 +195,8 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
188
195
|
if (!_ || !pe(t)) throw t;
|
|
189
196
|
await d(M, e, g, n, h, f, ae, v, void 0), o ||= ee;
|
|
190
197
|
}
|
|
191
|
-
let b =
|
|
192
|
-
for (; Date.now() < C && (b =
|
|
198
|
+
let b = ke([], l), C = Date.now() + (Te[f] ?? Ee), w = Date.now(), oe = Date.now();
|
|
199
|
+
for (; Date.now() < C && (b = ke(await c(M, e, g, n, v, 50), l), V(p, x, { content: Oe(b.content) }), !b.done);) Date.now() - w > 3e4 && (await a(M, e, g, 600, v).catch(() => void 0), w = Date.now()), await new Promise((e) => setTimeout(e, he(Date.now() - oe)));
|
|
193
200
|
if (!b.done && f !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
194
201
|
let se = f === "vibe-plugins" ? await s(M, e, g, n, v).catch(() => []) : void 0;
|
|
195
202
|
if (b.done || (b = {
|
|
@@ -206,11 +213,11 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
206
213
|
}
|
|
207
214
|
H(p, "complete", x, null);
|
|
208
215
|
} catch (t) {
|
|
209
|
-
if (e === 1 && me(t)) return U(p),
|
|
216
|
+
if (e === 1 && me(t)) return U(p), Ue(f), C(2);
|
|
210
217
|
throw t;
|
|
211
218
|
}
|
|
212
219
|
}, w = p;
|
|
213
|
-
|
|
220
|
+
Qe.current.add(w);
|
|
214
221
|
try {
|
|
215
222
|
if (!g) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
216
223
|
await C();
|
|
@@ -225,33 +232,33 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
225
232
|
metadata: { lang: "en" }
|
|
226
233
|
});
|
|
227
234
|
} finally {
|
|
228
|
-
|
|
235
|
+
Qe.current.delete(w);
|
|
229
236
|
}
|
|
230
237
|
}, [
|
|
231
238
|
I,
|
|
232
|
-
|
|
239
|
+
ze,
|
|
233
240
|
M,
|
|
234
241
|
U,
|
|
235
|
-
|
|
236
|
-
|
|
242
|
+
Ue,
|
|
243
|
+
Ie,
|
|
237
244
|
B,
|
|
238
|
-
|
|
245
|
+
$e,
|
|
239
246
|
N,
|
|
240
|
-
|
|
247
|
+
je,
|
|
241
248
|
V,
|
|
242
|
-
|
|
249
|
+
Pe,
|
|
250
|
+
Fe,
|
|
243
251
|
Ne,
|
|
244
|
-
|
|
245
|
-
Be,
|
|
252
|
+
He,
|
|
246
253
|
z,
|
|
247
254
|
H,
|
|
248
255
|
j,
|
|
249
256
|
X,
|
|
250
|
-
|
|
251
|
-
]),
|
|
257
|
+
Me
|
|
258
|
+
]), et = T((e) => {
|
|
252
259
|
Z(e);
|
|
253
|
-
}, [Z]),
|
|
254
|
-
let e = [...G].reverse().find((e) => e.role === "user"), t = I ?
|
|
260
|
+
}, [Z]), tt = T(() => {
|
|
261
|
+
let e = [...G].reverse().find((e) => e.role === "user"), t = I ? Ze.current[I] ?? [] : [];
|
|
255
262
|
e && Z(e.content, t);
|
|
256
263
|
}, [
|
|
257
264
|
G,
|
|
@@ -261,7 +268,7 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
261
268
|
E(() => {
|
|
262
269
|
Q.current = Z;
|
|
263
270
|
}, [Z]);
|
|
264
|
-
let
|
|
271
|
+
let nt = D(() => {
|
|
265
272
|
if (q) return null;
|
|
266
273
|
for (let e = G.length - 1; e >= 0; --e) {
|
|
267
274
|
let t = G[e];
|
|
@@ -273,7 +280,7 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
273
280
|
} : null;
|
|
274
281
|
}
|
|
275
282
|
return null;
|
|
276
|
-
}, [G, q]),
|
|
283
|
+
}, [G, q]), rt = D(() => ge(G), [G]), it = D(() => _e(G).filter((e) => e.role === "user" || e.role === "assistant").slice(-6).map((e) => ({
|
|
277
284
|
id: e.id,
|
|
278
285
|
role: e.role,
|
|
279
286
|
text: v(e.content).text.trim()
|
|
@@ -281,12 +288,12 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
281
288
|
onSubmit: T((e) => {
|
|
282
289
|
Q.current(e, [], { dictated: !0 });
|
|
283
290
|
}, []),
|
|
284
|
-
latestReply:
|
|
291
|
+
latestReply: nt,
|
|
285
292
|
language: g(F, P).tag
|
|
286
293
|
});
|
|
287
294
|
E(() => {
|
|
288
|
-
!
|
|
289
|
-
}, [
|
|
295
|
+
!we && $.active && $.end();
|
|
296
|
+
}, [we, $]), E(() => {
|
|
290
297
|
let t = e.getState().consumePendingPrompt();
|
|
291
298
|
return t && Q.current(t), e.subscribe((t, n) => {
|
|
292
299
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
@@ -295,53 +302,53 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
295
302
|
}
|
|
296
303
|
});
|
|
297
304
|
}, []);
|
|
298
|
-
let
|
|
305
|
+
let at = T((t) => {
|
|
299
306
|
let n = I ? e.getState().conversations.find((e) => e.id === I) : void 0;
|
|
300
307
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
301
308
|
if (n.mode !== t) {
|
|
302
309
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
303
|
-
n ?
|
|
310
|
+
n ? Re(n.id) : B(void 0, t);
|
|
304
311
|
}
|
|
305
312
|
} else I && z(I, t);
|
|
306
313
|
R(t);
|
|
307
314
|
}, [
|
|
308
315
|
I,
|
|
309
316
|
B,
|
|
310
|
-
|
|
317
|
+
Re,
|
|
311
318
|
z,
|
|
312
319
|
R
|
|
313
|
-
]),
|
|
320
|
+
]), ot = T((t) => {
|
|
314
321
|
if (S.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
315
|
-
|
|
322
|
+
Xe(t);
|
|
316
323
|
return;
|
|
317
324
|
}
|
|
318
|
-
|
|
319
|
-
}, [
|
|
320
|
-
let e =
|
|
321
|
-
|
|
325
|
+
at(t);
|
|
326
|
+
}, [at]), st = T(() => {
|
|
327
|
+
let e = Ye;
|
|
328
|
+
Xe(null), We(), e && at(e);
|
|
322
329
|
}, [
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
]),
|
|
327
|
-
|
|
330
|
+
Ye,
|
|
331
|
+
We,
|
|
332
|
+
at
|
|
333
|
+
]), ct = T(() => {
|
|
334
|
+
Xe(null);
|
|
328
335
|
}, []);
|
|
329
|
-
return /* @__PURE__ */
|
|
336
|
+
return /* @__PURE__ */ xe("div", {
|
|
330
337
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
331
338
|
children: [
|
|
332
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ xe("div", {
|
|
333
340
|
className: "contents",
|
|
334
341
|
inert: $.active || void 0,
|
|
335
|
-
children: [
|
|
342
|
+
children: [rt.length === 0 ? /* @__PURE__ */ k(C, {
|
|
336
343
|
mode: L,
|
|
337
|
-
onSuggestionClick:
|
|
344
|
+
onSuggestionClick: et
|
|
338
345
|
}) : /* @__PURE__ */ k("div", {
|
|
339
346
|
className: "flex min-h-0 flex-1 flex-col",
|
|
340
347
|
children: /* @__PURE__ */ k(b, {
|
|
341
|
-
messages:
|
|
342
|
-
streamingMessageId:
|
|
343
|
-
failedMessageId:
|
|
344
|
-
onRetry:
|
|
348
|
+
messages: rt,
|
|
349
|
+
streamingMessageId: Ge,
|
|
350
|
+
failedMessageId: Ke,
|
|
351
|
+
onRetry: tt
|
|
345
352
|
})
|
|
346
353
|
}), /* @__PURE__ */ k(w, {
|
|
347
354
|
onStartVoiceSession: $.available && L !== "api-calls" ? $.start : void 0,
|
|
@@ -349,23 +356,23 @@ var N = ({ visible: Se = !0 }) => {
|
|
|
349
356
|
disabled: q,
|
|
350
357
|
placeholder: L === "api-calls" ? j("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : j("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
|
|
351
358
|
mode: L,
|
|
352
|
-
availableModes:
|
|
353
|
-
onModeChange:
|
|
359
|
+
availableModes: Je,
|
|
360
|
+
onModeChange: ot
|
|
354
361
|
})]
|
|
355
362
|
}),
|
|
356
363
|
$.active && /* @__PURE__ */ k(oe, {
|
|
357
364
|
session: $.session,
|
|
358
365
|
notice: $.notice,
|
|
359
|
-
turns:
|
|
366
|
+
turns: it,
|
|
360
367
|
onInterrupt: $.interrupt,
|
|
361
|
-
spoken:
|
|
368
|
+
spoken: nt?.text ?? null,
|
|
362
369
|
onToggleMute: $.toggleMute,
|
|
363
370
|
onEnd: $.end
|
|
364
371
|
}),
|
|
365
372
|
/* @__PURE__ */ k(x, {
|
|
366
|
-
open:
|
|
367
|
-
onConfirm:
|
|
368
|
-
onCancel:
|
|
373
|
+
open: Ye !== null,
|
|
374
|
+
onConfirm: st,
|
|
375
|
+
onCancel: ct
|
|
369
376
|
})
|
|
370
377
|
]
|
|
371
378
|
});
|