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