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