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