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