@burdenoff/microfe-healthybowl 2026.829.4 → 2026.830.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/components/assistant/AssistantChatArea.js +210 -180
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/AssistantSpeechProvider.js +3 -2
- package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
- package/dist/components/assistant/composer/AssistantComposer.js +26 -22
- package/dist/components/assistant/composer/AssistantComposer.js.map +1 -1
- package/dist/components/assistant/voice/AssistantVoiceOrb.js +20 -0
- package/dist/components/assistant/voice/AssistantVoiceOrb.js.map +1 -0
- package/dist/components/assistant/voice/AssistantVoiceSession.js +83 -0
- package/dist/components/assistant/voice/AssistantVoiceSession.js.map +1 -0
- package/dist/components/assistant/voice/AssistantVoiceSessionButton.js +21 -0
- package/dist/components/assistant/voice/AssistantVoiceSessionButton.js.map +1 -0
- package/dist/hooks/useVoiceSession.js +117 -0
- package/dist/hooks/useVoiceSession.js.map +1 -0
- package/dist/services/speech/createSpeechEngine.js +32 -0
- package/dist/services/speech/createSpeechEngine.js.map +1 -0
- package/dist/services/speech/hostedTtsProtocol.js +41 -0
- package/dist/services/speech/hostedTtsProtocol.js.map +1 -0
- package/dist/services/speech/hostedTtsSpeechEngine.js +119 -0
- package/dist/services/speech/hostedTtsSpeechEngine.js.map +1 -0
- package/dist/services/speech/hostedVoiceCatalogue.js +52 -0
- package/dist/services/speech/hostedVoiceCatalogue.js.map +1 -0
- package/dist/services/speech/index.js +5 -0
- package/dist/services/speech/routingSpeechEngine.js +28 -0
- package/dist/services/speech/routingSpeechEngine.js.map +1 -0
- package/dist/utils/voiceSession.js +101 -0
- package/dist/utils/voiceSession.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,56 +4,59 @@ import { checkAssistantAiCredits as n, createAssistantSandbox as r, createAssist
|
|
|
4
4
|
import { gatherPageContext as m } from "../../utils/pageContext.js";
|
|
5
5
|
import { findAssistantLanguage as h, resolveAssistantLanguage as g } from "../../config/assistantLanguages.js";
|
|
6
6
|
import { isTurnInFlight as _ } from "../../utils/assistantTurnState.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { parseToolActivity as v } from "./AssistantToolActivity.js";
|
|
8
|
+
import { getOrganizationId as ee, getWorkspaceId as te } from "../../utils/assistantContext.js";
|
|
9
|
+
import { buildPromptParts as ne, buildPromptWithAttachments as re, countInlineImageCandidates as ie, countInlinedImageParts as ae, toMessageAttachment as y } from "../../utils/assistantAttachments.js";
|
|
9
10
|
import { AssistantMessageList as b } from "./AssistantMessageList.js";
|
|
10
11
|
import { AssistantApiCallsConsentDialog as x } from "./AssistantApiCallsConsentDialog.js";
|
|
11
12
|
import { ASSISTANT_MODES as S } from "../../types/assistant.js";
|
|
12
13
|
import { AssistantEmptyState as C } from "./AssistantEmptyState.js";
|
|
13
|
-
import { AssistantComposer as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
14
|
+
import { AssistantComposer as oe } from "./composer/AssistantComposer.js";
|
|
15
|
+
import { AssistantVoiceSession as se } from "./voice/AssistantVoiceSession.js";
|
|
16
|
+
import { useVoiceSession as ce } from "../../hooks/useVoiceSession.js";
|
|
17
|
+
import { useAssistantApiAccess as le } from "../../hooks/useAssistantApiAccess.js";
|
|
18
|
+
import { isQuotaExhaustedError as ue } from "../../utils/quotaUtils.js";
|
|
19
|
+
import { dispatchAssistantQuotaExhausted as de, notifyAiCreditsUpdated as fe } from "../../utils/aiCredits.js";
|
|
20
|
+
import { buildPromptForMode as pe } from "../../utils/assistantPrompt.js";
|
|
21
|
+
import { isMultimodalBodyRejection as me, isRecoverableAssistantError as he } from "../../utils/assistantTransportErrors.js";
|
|
22
|
+
import { useCallback as w, useEffect as ge, useMemo as T, useRef as E, useState as _e } from "react";
|
|
23
|
+
import { useI18n as ve } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
24
|
+
import { jsx as D, jsxs as ye } from "react/jsx-runtime";
|
|
25
|
+
import { useGatewayClient as be } from "@burdenoff/fe-libs/shared/graphql";
|
|
26
|
+
import { useAuthToken as xe } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
27
|
+
import { getAssistantMedia as O } from "@burdenoff/fe-libs/shared/assistant";
|
|
25
28
|
//#region src/components/assistant/AssistantChatArea.tsx
|
|
26
|
-
var
|
|
29
|
+
var Se = {
|
|
27
30
|
general: 18e4,
|
|
28
31
|
assistant: 18e4,
|
|
29
32
|
"api-calls": 18e4,
|
|
30
33
|
"vibe-plugins": 6e5
|
|
31
|
-
},
|
|
32
|
-
function
|
|
34
|
+
}, Ce = 18e4;
|
|
35
|
+
function we() {
|
|
33
36
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
34
37
|
}
|
|
35
|
-
function
|
|
38
|
+
function Te(e) {
|
|
36
39
|
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]");
|
|
37
40
|
}
|
|
38
|
-
function
|
|
41
|
+
function k(e) {
|
|
39
42
|
return e.info?.time?.created ?? 0;
|
|
40
43
|
}
|
|
41
|
-
function
|
|
44
|
+
function A(e) {
|
|
42
45
|
return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
|
|
43
46
|
}
|
|
44
|
-
function
|
|
47
|
+
function j(e) {
|
|
45
48
|
return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
|
|
46
49
|
let t = e.state?.status ?? "running", n = e.tool ?? "tool";
|
|
47
50
|
return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
|
|
48
51
|
});
|
|
49
52
|
}
|
|
50
|
-
function
|
|
51
|
-
let n = e.filter((e) => e.info?.role === "assistant" &&
|
|
53
|
+
function Ee(e, t) {
|
|
54
|
+
let n = e.filter((e) => e.info?.role === "assistant" && k(e) > t).sort((e, t) => k(e) - k(t));
|
|
52
55
|
if (n.length === 0) return {
|
|
53
56
|
content: "Thinking...",
|
|
54
57
|
done: !1
|
|
55
58
|
};
|
|
56
|
-
let r = n[n.length - 1], i =
|
|
59
|
+
let r = n[n.length - 1], i = A(r.parts), a = O(r.parts), o = j(r.parts);
|
|
57
60
|
return {
|
|
58
61
|
content: [
|
|
59
62
|
i,
|
|
@@ -64,7 +67,7 @@ function xe(e, t) {
|
|
|
64
67
|
tokens: r.info?.tokens
|
|
65
68
|
};
|
|
66
69
|
}
|
|
67
|
-
function
|
|
70
|
+
function De(e) {
|
|
68
71
|
switch (e) {
|
|
69
72
|
case "provisioning": return "Starting assistant environment...";
|
|
70
73
|
case "connecting": return "Connecting to assistant...";
|
|
@@ -72,86 +75,86 @@ function Se(e) {
|
|
|
72
75
|
default: return "";
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
var
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
let e = S.find((e) => e.id ===
|
|
80
|
-
(!e || e.requiresAdmin && !
|
|
78
|
+
var Oe = () => {
|
|
79
|
+
let O = t(), A = be("workspace"), { getAccessToken: j, getWorkspaceToken: Oe, userId: ke } = xe(), { locale: M } = ve(), N = e((e) => e.assistantLanguage), Ae = T(() => g(N, M).english, [N, M]), je = h(N) !== null, Me = T(() => g(N, M).code, [N, M]), { conversations: Ne, activeConversationId: P, mode: F, processingByConversationId: Pe, setMode: I, setConversationMode: L, setActiveConversation: Fe, createConversation: R, addMessage: z, updateMessage: B, patchMessage: V, setConversationProcessing: H, clearConversationProcessing: Ie, setBackendSessionId: Le, clearBackendSessionId: U, setSandbox: W, clearSandbox: Re, acknowledgeApiCalls: ze } = e(), G = Ne.find((e) => e.id === P)?.messages ?? [], K = P ? Pe[P] : void 0, q = _(K?.status), Be = q ? K?.messageId ?? null : null, Ve = K?.status === "error" ? K.messageId : null, { canUseApiCalls: J, loading: He } = le(ee()), Ue = T(() => S.filter((e) => !e.requiresAdmin || J), [J]), [We, Ge] = _e(null), Ke = E({}), qe = E(/* @__PURE__ */ new Set());
|
|
80
|
+
ge(() => {
|
|
81
|
+
if (He) return;
|
|
82
|
+
let e = S.find((e) => e.id === F);
|
|
83
|
+
(!e || e.requiresAdmin && !J) && F !== "assistant" && I("assistant");
|
|
81
84
|
}, [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
F,
|
|
86
|
+
J,
|
|
87
|
+
He,
|
|
88
|
+
I
|
|
86
89
|
]);
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
}, [
|
|
90
|
+
let Y = w((e, t, n, r) => {
|
|
91
|
+
H(e, n, t, null), r ? B(e, t, r) : B(e, t, De(n));
|
|
92
|
+
}, [H, B]), Je = w(async (t, n, a, s, c) => {
|
|
90
93
|
let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
|
|
91
94
|
try {
|
|
92
|
-
return await p(
|
|
95
|
+
return await p(A, e, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(A, e, s, c, 9e4, (e) => Y(t, n, "connecting", e)), !0;
|
|
93
96
|
} catch {
|
|
94
97
|
return !1;
|
|
95
98
|
}
|
|
96
99
|
};
|
|
97
|
-
if (u && (
|
|
98
|
-
|
|
99
|
-
let e = await o(
|
|
100
|
-
e && (
|
|
100
|
+
if (u && (W(a, u, "provisioning"), Y(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
|
|
101
|
+
Y(t, n, "provisioning", "Looking for existing environment...");
|
|
102
|
+
let e = await o(A, s, a, c);
|
|
103
|
+
e && (W(a, e, "provisioning"), Y(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
|
|
101
104
|
}
|
|
102
105
|
if (!u) {
|
|
103
|
-
if (a === "api-calls" && !
|
|
104
|
-
|
|
106
|
+
if (a === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
107
|
+
Y(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(A, a, s, c), W(a, u, "provisioning"), await p(A, u, s, c, 3e5, (e) => Y(t, n, "provisioning", e)), await f(A, u, s, c, 9e4, (e) => Y(t, n, "connecting", e));
|
|
105
108
|
}
|
|
106
|
-
|
|
109
|
+
W(a, u, "running");
|
|
107
110
|
let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
|
|
108
111
|
if (m) try {
|
|
109
|
-
let e = await l(
|
|
112
|
+
let e = await l(A, u, s, m, c);
|
|
110
113
|
if (e.mode !== a) throw Error(`Session mode mismatch: expected ${a}, received ${e.mode}`);
|
|
111
114
|
} catch {
|
|
112
|
-
|
|
115
|
+
U(t), m = null;
|
|
113
116
|
}
|
|
114
|
-
return m || (
|
|
117
|
+
return m || (Y(t, n, "connecting", "Preparing session..."), m = (await i(A, u, s, a, c)).sessionId, Le(t, m)), {
|
|
115
118
|
sandboxId: u,
|
|
116
119
|
sessionId: m
|
|
117
120
|
};
|
|
118
121
|
}, [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
]),
|
|
126
|
-
let i = e.getState(), o = i.activeConversationId ??
|
|
127
|
-
if (o && (_(i.processingByConversationId[o]?.status) ||
|
|
128
|
-
let l = i.mode, f =
|
|
129
|
-
if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f =
|
|
130
|
-
|
|
131
|
-
let h =
|
|
132
|
-
accessToken:
|
|
133
|
-
workspaceToken:
|
|
134
|
-
userId:
|
|
135
|
-
organizationId:
|
|
136
|
-
},
|
|
137
|
-
id:
|
|
122
|
+
A,
|
|
123
|
+
U,
|
|
124
|
+
j,
|
|
125
|
+
Le,
|
|
126
|
+
W,
|
|
127
|
+
Y
|
|
128
|
+
]), X = w(async (t, r = []) => {
|
|
129
|
+
let i = e.getState(), o = i.activeConversationId ?? P;
|
|
130
|
+
if (o && (_(i.processingByConversationId[o]?.status) || qe.current.has(o))) return;
|
|
131
|
+
let l = i.mode, f = P, p = f ? e.getState().conversations.find((e) => e.id === f) : void 0;
|
|
132
|
+
if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f = R(void 0, l) : p && p.mode !== l && L(f, l) : f = R(void 0, l), !f) return;
|
|
133
|
+
Ke.current[f] = r;
|
|
134
|
+
let h = te(), g = {
|
|
135
|
+
accessToken: j(),
|
|
136
|
+
workspaceToken: Oe(),
|
|
137
|
+
userId: ke,
|
|
138
|
+
organizationId: ee()
|
|
139
|
+
}, v = {
|
|
140
|
+
id: we(),
|
|
138
141
|
role: "user",
|
|
139
142
|
content: t,
|
|
140
143
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
141
144
|
metadata: r.length ? { attachments: r.map(y) } : void 0
|
|
142
145
|
};
|
|
143
|
-
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
id:
|
|
146
|
+
z(f, v);
|
|
147
|
+
let b = we();
|
|
148
|
+
z(f, {
|
|
149
|
+
id: b,
|
|
147
150
|
role: "assistant",
|
|
148
151
|
content: "",
|
|
149
152
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
150
|
-
metadata: { lang:
|
|
151
|
-
}),
|
|
152
|
-
let
|
|
153
|
-
|
|
154
|
-
content:
|
|
153
|
+
metadata: { lang: Me }
|
|
154
|
+
}), H(f, "provisioning", b, null);
|
|
155
|
+
let x = (e, t, n, r, i = Me) => {
|
|
156
|
+
V(f, b, {
|
|
157
|
+
content: Te(e),
|
|
155
158
|
metadata: {
|
|
156
159
|
lang: i,
|
|
157
160
|
...t?.length ? { artifacts: t } : {},
|
|
@@ -160,172 +163,199 @@ var P = () => {
|
|
|
160
163
|
...r ? { sandboxId: r } : {}
|
|
161
164
|
}
|
|
162
165
|
});
|
|
163
|
-
},
|
|
166
|
+
}, S = async (e = 1) => {
|
|
164
167
|
let i = !1;
|
|
165
168
|
try {
|
|
166
|
-
await n(
|
|
169
|
+
await n(A, h, g);
|
|
167
170
|
} catch (e) {
|
|
168
|
-
if (
|
|
169
|
-
|
|
171
|
+
if (ue(e)) {
|
|
172
|
+
de("ai-credits"), x("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting.", void 0, void 0, void 0, "en"), H(f, "error", b, null);
|
|
170
173
|
return;
|
|
171
174
|
}
|
|
172
175
|
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);
|
|
173
176
|
}
|
|
174
177
|
try {
|
|
175
|
-
let { sandboxId: e, sessionId: n } = await
|
|
176
|
-
|
|
177
|
-
let p =
|
|
178
|
-
i =
|
|
178
|
+
let { sandboxId: e, sessionId: n } = await Je(f, b, l, h, g), o = (await c(A, e, h, n, g, 50).catch(() => [])).reduce((e, t) => Math.max(e, k(t)), 0);
|
|
179
|
+
Y(f, b, "streaming", "Thinking...");
|
|
180
|
+
let p = pe(l, re(t, r), Ae, je), _ = ne(p, r), v = ae(_), ee = v > 0, te = m();
|
|
181
|
+
i = ie(r) > v;
|
|
179
182
|
try {
|
|
180
|
-
await d(
|
|
183
|
+
await d(A, e, h, n, p, l, te, g, _);
|
|
181
184
|
} catch (t) {
|
|
182
|
-
if (!_ || !
|
|
183
|
-
await d(
|
|
185
|
+
if (!_ || !me(t)) throw t;
|
|
186
|
+
await d(A, e, h, n, p, l, te, g, void 0), i ||= ee;
|
|
184
187
|
}
|
|
185
|
-
let
|
|
186
|
-
for (; Date.now() <
|
|
187
|
-
if (!
|
|
188
|
-
let
|
|
189
|
-
if (
|
|
190
|
-
...
|
|
191
|
-
content: `${
|
|
192
|
-
}), i && (
|
|
193
|
-
...
|
|
194
|
-
content: `${
|
|
195
|
-
}),
|
|
196
|
-
|
|
188
|
+
let y = Ee([], o), S = Date.now() + (Se[l] ?? Ce), C = Date.now();
|
|
189
|
+
for (; Date.now() < S && (y = Ee(await c(A, e, h, n, g, 50), o), V(f, b, { content: Te(y.content) }), !y.done);) Date.now() - C > 3e4 && (await a(A, e, h, 600, g).catch(() => void 0), C = Date.now()), await new Promise((e) => setTimeout(e, 1500));
|
|
190
|
+
if (!y.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
191
|
+
let oe = l === "vibe-plugins" ? await s(A, e, h, n, g).catch(() => []) : void 0;
|
|
192
|
+
if (y.done || (y = {
|
|
193
|
+
...y,
|
|
194
|
+
content: `${y.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
|
|
195
|
+
}), i && (y = {
|
|
196
|
+
...y,
|
|
197
|
+
content: `${y.content}\n\n${O("healthybowl.assistant.attachments.imagesNotSent", "_Your photo was too large to include with this message, so the answer above is from the text and the file link only. Try a smaller or more tightly cropped photo._")}`
|
|
198
|
+
}), x(y.content, oe, n, e), y.tokens) {
|
|
199
|
+
V(f, b, { tokens: y.tokens });
|
|
197
200
|
try {
|
|
198
|
-
await u(
|
|
201
|
+
await u(A, h, n, y.tokens, g), fe();
|
|
199
202
|
} catch {}
|
|
200
203
|
}
|
|
201
|
-
|
|
204
|
+
H(f, "complete", b, null);
|
|
202
205
|
} catch (t) {
|
|
203
|
-
if (e === 1 &&
|
|
206
|
+
if (e === 1 && he(t)) return U(f), Re(l), S(2);
|
|
204
207
|
throw t;
|
|
205
208
|
}
|
|
206
|
-
},
|
|
207
|
-
|
|
209
|
+
}, C = f;
|
|
210
|
+
qe.current.add(C);
|
|
208
211
|
try {
|
|
209
212
|
if (!h) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
210
|
-
await
|
|
213
|
+
await S();
|
|
211
214
|
} catch (e) {
|
|
212
|
-
if (
|
|
213
|
-
|
|
215
|
+
if (ue(e)) {
|
|
216
|
+
de("sandbox"), x("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), H(f, "error", b, null);
|
|
214
217
|
return;
|
|
215
218
|
}
|
|
216
219
|
let t = e instanceof Error ? e.message : "Something went wrong";
|
|
217
|
-
|
|
220
|
+
H(f, "error", b, t), V(f, b, {
|
|
218
221
|
content: `Sorry, an error occurred: ${t}. Please try again.`,
|
|
219
222
|
metadata: { lang: "en" }
|
|
220
223
|
});
|
|
221
224
|
} finally {
|
|
222
|
-
|
|
225
|
+
qe.current.delete(C);
|
|
223
226
|
}
|
|
224
227
|
}, [
|
|
225
|
-
|
|
228
|
+
P,
|
|
229
|
+
z,
|
|
230
|
+
A,
|
|
226
231
|
U,
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
Re,
|
|
233
|
+
Ne,
|
|
234
|
+
R,
|
|
235
|
+
Je,
|
|
236
|
+
j,
|
|
237
|
+
Oe,
|
|
238
|
+
V,
|
|
239
|
+
je,
|
|
229
240
|
Me,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
Ue,
|
|
233
|
-
N,
|
|
234
|
-
P,
|
|
235
|
-
W,
|
|
236
|
-
Te,
|
|
241
|
+
Ae,
|
|
242
|
+
Le,
|
|
237
243
|
L,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}, [Q]), Ge = T(() => {
|
|
248
|
-
let e = [...J].reverse().find((e) => e.role === "user"), t = R ? Ve.current[R] ?? [] : [];
|
|
249
|
-
e && Q(e.content, t);
|
|
244
|
+
H,
|
|
245
|
+
O,
|
|
246
|
+
Y,
|
|
247
|
+
ke
|
|
248
|
+
]), Ye = w((e) => {
|
|
249
|
+
X(e);
|
|
250
|
+
}, [X]), Xe = w(() => {
|
|
251
|
+
let e = [...G].reverse().find((e) => e.role === "user"), t = P ? Ke.current[P] ?? [] : [];
|
|
252
|
+
e && X(e.content, t);
|
|
250
253
|
}, [
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
]),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}, [
|
|
254
|
+
G,
|
|
255
|
+
X,
|
|
256
|
+
P
|
|
257
|
+
]), Z = E(X);
|
|
258
|
+
ge(() => {
|
|
259
|
+
Z.current = X;
|
|
260
|
+
}, [X]);
|
|
261
|
+
let Ze = T(() => {
|
|
262
|
+
if (q) return null;
|
|
263
|
+
for (let e = G.length - 1; e >= 0; --e) {
|
|
264
|
+
let t = G[e];
|
|
265
|
+
if (t?.role !== "assistant") continue;
|
|
266
|
+
let n = v(t.content).text.trim();
|
|
267
|
+
return n ? {
|
|
268
|
+
id: t.id,
|
|
269
|
+
text: n
|
|
270
|
+
} : null;
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}, [G, q]), Q = ce({
|
|
274
|
+
onSubmit: w((e) => {
|
|
275
|
+
Z.current(e);
|
|
276
|
+
}, []),
|
|
277
|
+
latestReply: Ze,
|
|
278
|
+
language: g(N, M).tag
|
|
279
|
+
});
|
|
280
|
+
ge(() => {
|
|
258
281
|
let t = e.getState().consumePendingPrompt();
|
|
259
|
-
return t &&
|
|
282
|
+
return t && Z.current(t), e.subscribe((t, n) => {
|
|
260
283
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
261
284
|
let t = e.getState().consumePendingPrompt();
|
|
262
|
-
t &&
|
|
285
|
+
t && Z.current(t);
|
|
263
286
|
}
|
|
264
287
|
});
|
|
265
288
|
}, []);
|
|
266
|
-
let $ =
|
|
267
|
-
let n =
|
|
289
|
+
let $ = w((t) => {
|
|
290
|
+
let n = P ? e.getState().conversations.find((e) => e.id === P) : void 0;
|
|
268
291
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
269
292
|
if (n.mode !== t) {
|
|
270
293
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
271
|
-
n ?
|
|
294
|
+
n ? Fe(n.id) : R(void 0, t);
|
|
272
295
|
}
|
|
273
|
-
} else
|
|
274
|
-
|
|
296
|
+
} else P && L(P, t);
|
|
297
|
+
I(t);
|
|
275
298
|
}, [
|
|
299
|
+
P,
|
|
276
300
|
R,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
]), qe = T((t) => {
|
|
301
|
+
Fe,
|
|
302
|
+
L,
|
|
303
|
+
I
|
|
304
|
+
]), Qe = w((t) => {
|
|
282
305
|
if (S.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
283
|
-
|
|
306
|
+
Ge(t);
|
|
284
307
|
return;
|
|
285
308
|
}
|
|
286
309
|
$(t);
|
|
287
|
-
}, [$]),
|
|
288
|
-
let e =
|
|
289
|
-
|
|
310
|
+
}, [$]), $e = w(() => {
|
|
311
|
+
let e = We;
|
|
312
|
+
Ge(null), ze(), e && $(e);
|
|
290
313
|
}, [
|
|
314
|
+
We,
|
|
291
315
|
ze,
|
|
292
|
-
Ne,
|
|
293
316
|
$
|
|
294
|
-
]),
|
|
295
|
-
|
|
317
|
+
]), et = w(() => {
|
|
318
|
+
Ge(null);
|
|
296
319
|
}, []);
|
|
297
|
-
return /* @__PURE__ */
|
|
320
|
+
return /* @__PURE__ */ ye("div", {
|
|
298
321
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
299
322
|
children: [
|
|
300
|
-
|
|
301
|
-
mode:
|
|
302
|
-
onSuggestionClick:
|
|
303
|
-
}) : /* @__PURE__ */
|
|
323
|
+
G.length === 0 ? /* @__PURE__ */ D(C, {
|
|
324
|
+
mode: F,
|
|
325
|
+
onSuggestionClick: Ye
|
|
326
|
+
}) : /* @__PURE__ */ D("div", {
|
|
304
327
|
className: "flex min-h-0 flex-1 flex-col",
|
|
305
|
-
children: /* @__PURE__ */
|
|
306
|
-
messages:
|
|
307
|
-
streamingMessageId:
|
|
308
|
-
failedMessageId:
|
|
309
|
-
onRetry:
|
|
328
|
+
children: /* @__PURE__ */ D(b, {
|
|
329
|
+
messages: G,
|
|
330
|
+
streamingMessageId: Be,
|
|
331
|
+
failedMessageId: Ve,
|
|
332
|
+
onRetry: Xe
|
|
310
333
|
})
|
|
311
334
|
}),
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
335
|
+
/* @__PURE__ */ D(oe, {
|
|
336
|
+
onStartVoiceSession: Q.available && F !== "api-calls" ? Q.start : void 0,
|
|
337
|
+
onSend: (e, t) => void X(e, t),
|
|
338
|
+
disabled: q,
|
|
339
|
+
placeholder: F === "api-calls" ? O("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : O("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
|
|
340
|
+
mode: F,
|
|
341
|
+
availableModes: Ue,
|
|
342
|
+
onModeChange: Qe
|
|
343
|
+
}),
|
|
344
|
+
Q.active && /* @__PURE__ */ D(se, {
|
|
345
|
+
session: Q.session,
|
|
346
|
+
spoken: Ze?.text ?? null,
|
|
347
|
+
onToggleMute: Q.toggleMute,
|
|
348
|
+
onEnd: Q.end
|
|
319
349
|
}),
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
open:
|
|
322
|
-
onConfirm:
|
|
323
|
-
onCancel:
|
|
350
|
+
/* @__PURE__ */ D(x, {
|
|
351
|
+
open: We !== null,
|
|
352
|
+
onConfirm: $e,
|
|
353
|
+
onCancel: et
|
|
324
354
|
})
|
|
325
355
|
]
|
|
326
356
|
});
|
|
327
357
|
};
|
|
328
358
|
//#endregion
|
|
329
|
-
export {
|
|
359
|
+
export { Oe as AssistantChatArea };
|
|
330
360
|
|
|
331
361
|
//# sourceMappingURL=AssistantChatArea.js.map
|