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