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