@burdenoff/microfe-healthybowl 2026.627.1 → 2026.629.1
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/AssistantApiCallsConsentDialog.js +33 -0
- package/dist/components/assistant/AssistantApiCallsConsentDialog.js.map +1 -0
- package/dist/components/assistant/AssistantChatArea.js +166 -127
- package/dist/components/assistant/AssistantChatArea.js.map +1 -1
- package/dist/components/assistant/AssistantMarkdownRenderer.js +59 -62
- package/dist/components/assistant/AssistantMarkdownRenderer.js.map +1 -1
- package/dist/components/assistant/AssistantModeSelector.js +14 -14
- package/dist/components/assistant/AssistantModeSelector.js.map +1 -1
- package/dist/components/assistant/AssistantWelcome.js +1 -1
- package/dist/components/assistant/AssistantWelcome.js.map +1 -1
- package/dist/config/assistantUsecases.js +12 -1
- package/dist/config/assistantUsecases.js.map +1 -1
- package/dist/hooks/useAssistantApiAccess.js +37 -0
- package/dist/hooks/useAssistantApiAccess.js.map +1 -0
- package/dist/services/assistantApi.js +5 -1
- package/dist/services/assistantApi.js.map +1 -1
- package/dist/store/assistantStore.js +7 -3
- package/dist/store/assistantStore.js.map +1 -1
- package/dist/types/assistant.js.map +1 -1
- package/dist/utils/assistantPrompt.js +17 -0
- package/dist/utils/assistantPrompt.js.map +1 -0
- package/dist/utils/pageContext.js.map +1 -1
- package/dist/utils/sanitizeUrl.js +9 -0
- package/dist/utils/sanitizeUrl.js.map +1 -0
- package/package.json +8 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Modal as e } from "../../healthybowl/components/Modal.js";
|
|
2
|
+
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
+
import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
|
+
import { Button as a } from "@burdenoff/fe-libs/ui";
|
|
5
|
+
//#region src/components/assistant/AssistantApiCallsConsentDialog.tsx
|
|
6
|
+
var o = ({ open: o, onConfirm: s, onCancel: c }) => {
|
|
7
|
+
let l = t();
|
|
8
|
+
return /* @__PURE__ */ r(e, {
|
|
9
|
+
open: o,
|
|
10
|
+
onClose: c,
|
|
11
|
+
size: "sm",
|
|
12
|
+
title: l("healthybowl.assistant.apiCalls.consentTitle", "Switch to Actions mode?"),
|
|
13
|
+
footer: /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ r(a, {
|
|
14
|
+
variant: "outline",
|
|
15
|
+
onClick: c,
|
|
16
|
+
"data-testid": "assistant-api-calls-consent-cancel",
|
|
17
|
+
children: l("healthybowl.assistant.apiCalls.consentCancel", "Stay in General")
|
|
18
|
+
}), /* @__PURE__ */ r(a, {
|
|
19
|
+
variant: "default",
|
|
20
|
+
onClick: s,
|
|
21
|
+
"data-testid": "assistant-api-calls-consent-confirm",
|
|
22
|
+
children: l("healthybowl.assistant.apiCalls.consentConfirm", "Enable Actions")
|
|
23
|
+
})] }),
|
|
24
|
+
children: /* @__PURE__ */ i("div", {
|
|
25
|
+
className: "space-y-2 text-sm text-text-secondary",
|
|
26
|
+
children: [/* @__PURE__ */ r("p", { children: l("healthybowl.assistant.apiCalls.consentBody", "In Actions mode the assistant can read AND change your HealthyBowl data — creating crops, logging harvests, updating records, and more, on your behalf.") }), /* @__PURE__ */ r("p", { children: l("healthybowl.assistant.apiCalls.consentBody2", "It will describe what it is about to do and ask you to confirm before making a change. Only continue if you want the assistant to take actions for you.") })]
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { o as AssistantApiCallsConsentDialog };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=AssistantApiCallsConsentDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssistantApiCallsConsentDialog.js","names":[],"sources":["../../../src/components/assistant/AssistantApiCallsConsentDialog.tsx"],"sourcesContent":["/**\n * One-time consent dialog shown the first time a user switches the assistant\n * into the write-capable `api-calls` (\"Actions\") mode. This is the DEPENDABLE\n * guardrail: the in-sandbox agent executes mutations autonomously, so a host-\n * side acknowledgement (plus the soft describe-and-confirm prompt preamble) is\n * the FE's strongest lever short of an agent-side hard confirm. The ack is\n * persisted per-profile in the assistant store, so this shows once, not on\n * every switch.\n */\n\nimport type { FC } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { Modal } from '@/healthybowl/components/Modal';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n open: boolean;\n onConfirm: () => void;\n onCancel: () => void;\n}\n\nexport const AssistantApiCallsConsentDialog: FC<Props> = ({ open, onConfirm, onCancel }) => {\n const tr = useTr();\n\n return (\n <Modal\n open={open}\n onClose={onCancel}\n size=\"sm\"\n title={tr('healthybowl.assistant.apiCalls.consentTitle', 'Switch to Actions mode?')}\n footer={\n <>\n <Button variant=\"outline\" onClick={onCancel} data-testid=\"assistant-api-calls-consent-cancel\">\n {tr('healthybowl.assistant.apiCalls.consentCancel', 'Stay in General')}\n </Button>\n <Button variant=\"default\" onClick={onConfirm} data-testid=\"assistant-api-calls-consent-confirm\">\n {tr('healthybowl.assistant.apiCalls.consentConfirm', 'Enable Actions')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-2 text-sm text-text-secondary\">\n <p>\n {tr(\n 'healthybowl.assistant.apiCalls.consentBody',\n 'In Actions mode the assistant can read AND change your HealthyBowl data — creating crops, logging harvests, updating records, and more, on your behalf.'\n )}\n </p>\n <p>\n {tr(\n 'healthybowl.assistant.apiCalls.consentBody2',\n 'It will describe what it is about to do and ask you to confirm before making a change. Only continue if you want the assistant to take actions for you.'\n )}\n </p>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;AAqBA,IAAa,KAA6C,EAAE,SAAM,cAAW,kBAAe;CAC1F,IAAM,IAAK,GAAO;AAElB,QACE,kBAAC,GAAD;EACQ;EACN,SAAS;EACT,MAAK;EACL,OAAO,EAAG,+CAA+C,0BAA0B;EACnF,QACE,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;GAAQ,SAAQ;GAAU,SAAS;GAAU,eAAY;aACtD,EAAG,gDAAgD,kBAAkB;GAC/D,CAAA,EACT,kBAAC,GAAD;GAAQ,SAAQ;GAAU,SAAS;GAAW,eAAY;aACvD,EAAG,iDAAiD,iBAAiB;GAC/D,CAAA,CACR,EAAA,CAAA;YAGL,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD,EAAA,UACG,EACC,8CACA,0JACD,EACC,CAAA,EACJ,kBAAC,KAAD,EAAA,UACG,EACC,+CACA,0JACD,EACC,CAAA,CACA;;EACA,CAAA"}
|
|
@@ -3,25 +3,29 @@ import { checkAssistantAiCredits as t, createAssistantSandbox as n, createAssist
|
|
|
3
3
|
import { useTr as p } from "../../shared/hooks/useTr.js";
|
|
4
4
|
import { AssistantChatInput as m } from "./AssistantChatInput.js";
|
|
5
5
|
import { AssistantMessageList as h } from "./AssistantMessageList.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
6
|
+
import { ASSISTANT_MODES as g } from "../../types/assistant.js";
|
|
7
|
+
import { AssistantModeSelector as _ } from "./AssistantModeSelector.js";
|
|
8
|
+
import { AssistantApiCallsConsentDialog as v } from "./AssistantApiCallsConsentDialog.js";
|
|
9
|
+
import { AssistantWelcome as ee } from "./AssistantWelcome.js";
|
|
10
|
+
import { useAssistantApiAccess as te } from "../../hooks/useAssistantApiAccess.js";
|
|
11
|
+
import { gatherPageContext as ne } from "../../utils/pageContext.js";
|
|
12
|
+
import { isQuotaExhaustedError as re } from "../../utils/quotaUtils.js";
|
|
13
|
+
import { dispatchAssistantQuotaExhausted as ie, notifyAiCreditsUpdated as ae } from "../../utils/aiCredits.js";
|
|
14
|
+
import { buildPromptForMode as oe } from "../../utils/assistantPrompt.js";
|
|
15
|
+
import { useCallback as y, useEffect as b, useMemo as se, useRef as ce, useState as le } from "react";
|
|
16
|
+
import { jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
17
|
+
import { useGatewayClient as ue } from "@burdenoff/fe-libs/shared/graphql";
|
|
18
|
+
import { useAuthToken as de } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
15
19
|
//#region src/components/assistant/AssistantChatArea.tsx
|
|
16
|
-
var
|
|
20
|
+
var fe = {
|
|
17
21
|
general: 18e4,
|
|
18
22
|
"api-calls": 18e4,
|
|
19
23
|
"vibe-plugins": 6e5
|
|
20
|
-
},
|
|
21
|
-
function
|
|
24
|
+
}, pe = 18e4;
|
|
25
|
+
function C() {
|
|
22
26
|
return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
23
27
|
}
|
|
24
|
-
function
|
|
28
|
+
function w(e) {
|
|
25
29
|
try {
|
|
26
30
|
let t = e === "workspaceId" ? "burdenoff-active-context-workspace" : "burdenoff-active-context-organization", n = localStorage.getItem(t);
|
|
27
31
|
if (n) return n;
|
|
@@ -33,13 +37,13 @@ function T(e) {
|
|
|
33
37
|
return "";
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
|
-
function
|
|
37
|
-
return new URLSearchParams(window.location.search).get("workspace") ??
|
|
40
|
+
function me() {
|
|
41
|
+
return new URLSearchParams(window.location.search).get("workspace") ?? w("workspaceId");
|
|
38
42
|
}
|
|
39
|
-
function
|
|
40
|
-
return new URLSearchParams(window.location.search).get("org") ??
|
|
43
|
+
function he() {
|
|
44
|
+
return new URLSearchParams(window.location.search).get("org") ?? w("organizationId");
|
|
41
45
|
}
|
|
42
|
-
function
|
|
46
|
+
function ge(e) {
|
|
43
47
|
let t = e instanceof Error ? e.message.toLowerCase() : String(e).toLowerCase();
|
|
44
48
|
return t.includes("rate limit exceeded") || t.includes("unauthorized") || t.includes("k8s api error 401") ? !1 : [
|
|
45
49
|
"sandbox not found",
|
|
@@ -54,35 +58,35 @@ function le(e) {
|
|
|
54
58
|
"session mode mismatch"
|
|
55
59
|
].some((e) => t.includes(e));
|
|
56
60
|
}
|
|
57
|
-
function
|
|
61
|
+
function _e(e) {
|
|
58
62
|
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]");
|
|
59
63
|
}
|
|
60
|
-
function
|
|
64
|
+
function T(e) {
|
|
61
65
|
return e.info?.time?.created ?? 0;
|
|
62
66
|
}
|
|
63
|
-
function
|
|
67
|
+
function E(e) {
|
|
64
68
|
return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
|
|
65
69
|
}
|
|
66
|
-
function
|
|
70
|
+
function D(e) {
|
|
67
71
|
return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
|
|
68
72
|
let t = e.state?.status ?? "running", n = e.tool ?? "tool";
|
|
69
73
|
return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
|
|
70
74
|
});
|
|
71
75
|
}
|
|
72
|
-
function
|
|
73
|
-
let n = e.filter((e) => e.info?.role === "assistant" &&
|
|
76
|
+
function ve(e, t) {
|
|
77
|
+
let n = e.filter((e) => e.info?.role === "assistant" && T(e) >= t).sort((e, t) => T(e) - T(t));
|
|
74
78
|
if (n.length === 0) return {
|
|
75
79
|
content: "Thinking...",
|
|
76
80
|
done: !1
|
|
77
81
|
};
|
|
78
|
-
let r = n[n.length - 1], i =
|
|
82
|
+
let r = n[n.length - 1], i = E(r.parts), a = D(r.parts);
|
|
79
83
|
return {
|
|
80
84
|
content: [i, ...a].filter(Boolean).join("\n\n") || "Thinking...",
|
|
81
85
|
done: !!r.info?.time?.completed && (!!i || a.length > 0),
|
|
82
86
|
tokens: r.info?.tokens
|
|
83
87
|
};
|
|
84
88
|
}
|
|
85
|
-
function
|
|
89
|
+
function ye(e) {
|
|
86
90
|
switch (e) {
|
|
87
91
|
case "provisioning": return "Starting assistant environment...";
|
|
88
92
|
case "connecting": return "Connecting to assistant...";
|
|
@@ -90,67 +94,78 @@ function ue(e) {
|
|
|
90
94
|
default: return "";
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
var
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
var O = () => {
|
|
98
|
+
let w = p(), T = ue("workspace"), { getAccessToken: E, getWorkspaceToken: D, userId: O } = de(), { conversations: k, activeConversationId: A, mode: j, processingByConversationId: M, setMode: N, setConversationMode: P, setActiveConversation: F, createConversation: I, addMessage: L, updateMessage: R, patchMessage: z, setConversationProcessing: B, clearConversationProcessing: be, setBackendSessionId: V, clearBackendSessionId: H, setSandbox: U, clearSandbox: W, acknowledgeApiCalls: xe } = e(), Se = k.find((e) => e.id === A)?.messages ?? [], G = A ? M[A] : void 0, Ce = G?.messageId ?? null, we = G?.status === "provisioning" || G?.status === "connecting" || G?.status === "streaming", { canUseApiCalls: K, loading: Te } = te(he()), Ee = se(() => g.filter((e) => !e.requiresAdmin || K), [K]), [q, J] = le(null);
|
|
99
|
+
b(() => {
|
|
100
|
+
if (Te) return;
|
|
101
|
+
let e = g.find((e) => e.id === j);
|
|
102
|
+
(!e || e.requiresAdmin && !K) && j !== "general" && N("general");
|
|
103
|
+
}, [
|
|
104
|
+
j,
|
|
105
|
+
K,
|
|
106
|
+
Te,
|
|
107
|
+
N
|
|
108
|
+
]);
|
|
109
|
+
let Y = y((e, t, n, r) => {
|
|
110
|
+
B(e, n, t, null), r ? R(e, t, r) : R(e, t, ye(n));
|
|
111
|
+
}, [B, R]), X = y(async (t, i, o, s, l) => {
|
|
97
112
|
let u = e.getState().sandboxesByMode[o]?.sandboxId ?? null;
|
|
98
113
|
if (!u) {
|
|
99
|
-
|
|
100
|
-
let e = await a(
|
|
101
|
-
if (e) u = e,
|
|
114
|
+
Y(t, i, "provisioning", "Looking for existing environment...");
|
|
115
|
+
let e = await a(T, s, o, l);
|
|
116
|
+
if (e) u = e, U(o, u, "provisioning"), Y(t, i, "provisioning", "Reusing assistant environment..."), await f(T, u, s, l, 3e5, (e) => Y(t, i, "provisioning", e)), await d(T, u, s, l, 9e4, (e) => Y(t, i, "connecting", e)), U(o, u, "running");
|
|
102
117
|
else {
|
|
103
|
-
if (o === "api-calls" && !
|
|
104
|
-
|
|
118
|
+
if (o === "api-calls" && !E()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
|
|
119
|
+
Y(t, i, "provisioning", "Starting assistant environment..."), U(o, null, "provisioning"), u = await n(T, o, s, l), U(o, u, "provisioning"), await f(T, u, s, l, 3e5, (e) => Y(t, i, "provisioning", e)), await d(T, u, s, l, 9e4, (e) => Y(t, i, "connecting", e)), U(o, u, "running");
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
122
|
let p = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
|
|
108
123
|
if (p) try {
|
|
109
|
-
let e = await c(
|
|
124
|
+
let e = await c(T, u, s, p, l);
|
|
110
125
|
if (e.mode !== o) throw Error(`Session mode mismatch: expected ${o}, received ${e.mode}`);
|
|
111
126
|
} catch {
|
|
112
|
-
|
|
127
|
+
H(t), p = null;
|
|
113
128
|
}
|
|
114
|
-
return p || (
|
|
129
|
+
return p || (Y(t, i, "connecting", "Preparing session..."), p = (await r(T, u, s, o, l)).sessionId, V(t, p)), {
|
|
115
130
|
sandboxId: u,
|
|
116
131
|
sessionId: p
|
|
117
132
|
};
|
|
118
133
|
}, [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
]),
|
|
126
|
-
if (
|
|
127
|
-
let e =
|
|
134
|
+
T,
|
|
135
|
+
H,
|
|
136
|
+
E,
|
|
137
|
+
V,
|
|
138
|
+
U,
|
|
139
|
+
Y
|
|
140
|
+
]), Z = y(async (n) => {
|
|
141
|
+
if (A) {
|
|
142
|
+
let e = M[A]?.status;
|
|
128
143
|
if (e === "provisioning" || e === "connecting" || e === "streaming") return;
|
|
129
144
|
}
|
|
130
|
-
let r = e.getState().mode, a =
|
|
131
|
-
if (a ? c && c.mode !== r && (c.messages.length > 0 || c.backendSessionId) ? a =
|
|
132
|
-
let d =
|
|
133
|
-
accessToken:
|
|
134
|
-
workspaceToken:
|
|
135
|
-
userId:
|
|
136
|
-
organizationId:
|
|
145
|
+
let r = e.getState().mode, a = A, c = a ? e.getState().conversations.find((e) => e.id === a) : void 0;
|
|
146
|
+
if (a ? c && c.mode !== r && (c.messages.length > 0 || c.backendSessionId) ? a = I(void 0, r) : c && c.mode !== r && P(a, r) : a = I(void 0, r), !a) return;
|
|
147
|
+
let d = me(), f = {
|
|
148
|
+
accessToken: E(),
|
|
149
|
+
workspaceToken: D(),
|
|
150
|
+
userId: O,
|
|
151
|
+
organizationId: he()
|
|
137
152
|
}, p = {
|
|
138
|
-
id:
|
|
153
|
+
id: C(),
|
|
139
154
|
role: "user",
|
|
140
155
|
content: n,
|
|
141
156
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
142
157
|
};
|
|
143
|
-
|
|
144
|
-
let m =
|
|
145
|
-
|
|
158
|
+
L(a, p);
|
|
159
|
+
let m = C();
|
|
160
|
+
L(a, {
|
|
146
161
|
id: m,
|
|
147
162
|
role: "assistant",
|
|
148
163
|
content: "",
|
|
149
164
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
150
165
|
});
|
|
151
166
|
let h = (e, t, n, i) => {
|
|
152
|
-
|
|
153
|
-
content:
|
|
167
|
+
z(a, m, {
|
|
168
|
+
content: _e(e),
|
|
154
169
|
metadata: t?.length || n || i ? {
|
|
155
170
|
artifacts: t,
|
|
156
171
|
mode: r,
|
|
@@ -160,35 +175,35 @@ var j = () => {
|
|
|
160
175
|
});
|
|
161
176
|
}, g = async (e = 1) => {
|
|
162
177
|
try {
|
|
163
|
-
await t(
|
|
178
|
+
await t(T, d, f);
|
|
164
179
|
} catch (e) {
|
|
165
|
-
if (
|
|
166
|
-
|
|
180
|
+
if (re(e)) {
|
|
181
|
+
ie("ai-credits"), h("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting."), B(a, "error", m, null);
|
|
167
182
|
return;
|
|
168
183
|
}
|
|
169
184
|
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);
|
|
170
185
|
}
|
|
171
186
|
try {
|
|
172
|
-
let { sandboxId: e, sessionId: t } = await
|
|
173
|
-
|
|
187
|
+
let { sandboxId: e, sessionId: t } = await X(a, m, r, d, f);
|
|
188
|
+
Y(a, m, "streaming", "Thinking...");
|
|
174
189
|
let c = Date.now();
|
|
175
|
-
await u(
|
|
176
|
-
let p =
|
|
177
|
-
for (; Date.now() < g && (p =
|
|
190
|
+
await u(T, e, d, t, oe(r, n), r, ne(), f);
|
|
191
|
+
let p = ve([], c), g = Date.now() + (fe[r] ?? pe), _ = Date.now();
|
|
192
|
+
for (; Date.now() < g && (p = ve(await s(T, e, d, t, f, 50), c), z(a, m, { content: _e(p.content) }), !p.done);) Date.now() - _ > 3e4 && (await i(T, e, d, 600, f).catch(() => void 0), _ = Date.now()), await new Promise((e) => setTimeout(e, 1500));
|
|
178
193
|
if (!p.done && r !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
|
|
179
|
-
let v = r === "vibe-plugins" ? await o(
|
|
194
|
+
let v = r === "vibe-plugins" ? await o(T, e, d, t, f).catch(() => []) : void 0;
|
|
180
195
|
if (p.done || (p = {
|
|
181
196
|
...p,
|
|
182
197
|
content: `${p.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
|
|
183
198
|
}), h(p.content, v, t, e), p.tokens) {
|
|
184
|
-
|
|
199
|
+
z(a, m, { tokens: p.tokens });
|
|
185
200
|
try {
|
|
186
|
-
await l(
|
|
201
|
+
await l(T, d, t, p.tokens, f), ae();
|
|
187
202
|
} catch {}
|
|
188
203
|
}
|
|
189
|
-
|
|
204
|
+
B(a, "complete", m, null);
|
|
190
205
|
} catch (t) {
|
|
191
|
-
if (e === 1 &&
|
|
206
|
+
if (e === 1 && ge(t)) return H(a), W(r), g(2);
|
|
192
207
|
throw t;
|
|
193
208
|
}
|
|
194
209
|
};
|
|
@@ -196,84 +211,108 @@ var j = () => {
|
|
|
196
211
|
if (!d) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
197
212
|
await g();
|
|
198
213
|
} catch (e) {
|
|
199
|
-
if (
|
|
200
|
-
|
|
214
|
+
if (re(e)) {
|
|
215
|
+
ie("sandbox"), h("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant."), B(a, "error", m, null);
|
|
201
216
|
return;
|
|
202
217
|
}
|
|
203
218
|
let t = e instanceof Error ? e.message : "Something went wrong";
|
|
204
|
-
|
|
219
|
+
B(a, "error", m, t), R(a, m, `Sorry, an error occurred: ${t}. Please try again.`);
|
|
205
220
|
}
|
|
206
221
|
}, [
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
G,
|
|
211
|
-
q,
|
|
212
|
-
M,
|
|
213
|
-
z,
|
|
214
|
-
Z,
|
|
215
|
-
O,
|
|
216
|
-
k,
|
|
222
|
+
A,
|
|
223
|
+
L,
|
|
224
|
+
T,
|
|
217
225
|
H,
|
|
218
|
-
F,
|
|
219
226
|
W,
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
k,
|
|
228
|
+
I,
|
|
222
229
|
X,
|
|
230
|
+
E,
|
|
231
|
+
D,
|
|
232
|
+
z,
|
|
233
|
+
M,
|
|
223
234
|
V,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
235
|
+
P,
|
|
236
|
+
B,
|
|
237
|
+
Y,
|
|
238
|
+
R,
|
|
239
|
+
O
|
|
240
|
+
]), De = y((e) => {
|
|
241
|
+
Z(e);
|
|
242
|
+
}, [Z]), Q = ce(Z);
|
|
243
|
+
b(() => {
|
|
244
|
+
Q.current = Z;
|
|
245
|
+
}, [Z]), b(() => {
|
|
231
246
|
let t = e.getState().consumePendingPrompt();
|
|
232
|
-
return t &&
|
|
247
|
+
return t && Q.current(t), e.subscribe((t, n) => {
|
|
233
248
|
if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
|
|
234
249
|
let t = e.getState().consumePendingPrompt();
|
|
235
|
-
t &&
|
|
250
|
+
t && Q.current(t);
|
|
236
251
|
}
|
|
237
252
|
});
|
|
238
253
|
}, []);
|
|
239
|
-
let
|
|
240
|
-
let n =
|
|
254
|
+
let $ = y((t) => {
|
|
255
|
+
let n = A ? e.getState().conversations.find((e) => e.id === A) : void 0;
|
|
241
256
|
if (n && (n.messages.length > 0 || n.backendSessionId)) {
|
|
242
257
|
if (n.mode !== t) {
|
|
243
258
|
let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
|
|
244
|
-
n ?
|
|
259
|
+
n ? F(n.id) : I(void 0, t);
|
|
245
260
|
}
|
|
246
|
-
} else
|
|
247
|
-
|
|
261
|
+
} else A && P(A, t);
|
|
262
|
+
N(t);
|
|
248
263
|
}, [
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
])
|
|
255
|
-
|
|
264
|
+
A,
|
|
265
|
+
I,
|
|
266
|
+
F,
|
|
267
|
+
P,
|
|
268
|
+
N
|
|
269
|
+
]), Oe = y((t) => {
|
|
270
|
+
if (g.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
|
|
271
|
+
J(t);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
$(t);
|
|
275
|
+
}, [$]), ke = y(() => {
|
|
276
|
+
let e = q;
|
|
277
|
+
J(null), xe(), e && $(e);
|
|
278
|
+
}, [
|
|
279
|
+
q,
|
|
280
|
+
xe,
|
|
281
|
+
$
|
|
282
|
+
]), Ae = y(() => {
|
|
283
|
+
J(null);
|
|
284
|
+
}, []);
|
|
285
|
+
return /* @__PURE__ */ S("div", {
|
|
256
286
|
className: "flex flex-col flex-1 overflow-hidden pt-3",
|
|
257
|
-
children: [
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
children: /* @__PURE__ */
|
|
266
|
-
|
|
267
|
-
|
|
287
|
+
children: [
|
|
288
|
+
Se.length === 0 ? /* @__PURE__ */ x(ee, {
|
|
289
|
+
mode: j,
|
|
290
|
+
onSuggestionClick: De
|
|
291
|
+
}) : /* @__PURE__ */ x(h, {
|
|
292
|
+
messages: Se,
|
|
293
|
+
streamingMessageId: Ce
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
|
|
296
|
+
className: "px-3 pb-1",
|
|
297
|
+
children: /* @__PURE__ */ x(_, {
|
|
298
|
+
mode: j,
|
|
299
|
+
availableModes: Ee,
|
|
300
|
+
onModeChange: Oe
|
|
301
|
+
})
|
|
302
|
+
}), /* @__PURE__ */ x(m, {
|
|
303
|
+
onSend: (e) => void Z(e),
|
|
304
|
+
disabled: we,
|
|
305
|
+
placeholder: w("healthybowl.assistant.chatArea.placeholder", `Ask about ${j.replace(/-/g, " ")}...`)
|
|
306
|
+
})] }),
|
|
307
|
+
/* @__PURE__ */ x(v, {
|
|
308
|
+
open: q !== null,
|
|
309
|
+
onConfirm: ke,
|
|
310
|
+
onCancel: Ae
|
|
268
311
|
})
|
|
269
|
-
|
|
270
|
-
onSend: (e) => void Q(e),
|
|
271
|
-
disabled: pe,
|
|
272
|
-
placeholder: T("healthybowl.assistant.chatArea.placeholder", `Ask about ${P.replace(/-/g, " ")}...`)
|
|
273
|
-
})] })]
|
|
312
|
+
]
|
|
274
313
|
});
|
|
275
314
|
};
|
|
276
315
|
//#endregion
|
|
277
|
-
export {
|
|
316
|
+
export { O as AssistantChatArea };
|
|
278
317
|
|
|
279
318
|
//# sourceMappingURL=AssistantChatArea.js.map
|