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