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