@burdenoff/microfe-healthybowl 2026.829.2 → 2026.829.4

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.
Files changed (28) hide show
  1. package/dist/components/assistant/AssistantChatArea.js +188 -182
  2. package/dist/components/assistant/AssistantChatArea.js.map +1 -1
  3. package/dist/components/assistant/AssistantHeader.js +40 -38
  4. package/dist/components/assistant/AssistantHeader.js.map +1 -1
  5. package/dist/components/assistant/AssistantMessageItem.js +1 -1
  6. package/dist/components/assistant/AssistantMessageItem.js.map +1 -1
  7. package/dist/components/assistant/AssistantSpeechProvider.js +163 -136
  8. package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
  9. package/dist/components/assistant/composer/AssistantComposer.js +96 -84
  10. package/dist/components/assistant/composer/AssistantComposer.js.map +1 -1
  11. package/dist/components/assistant/composer/AssistantLanguageSelector.js +44 -0
  12. package/dist/components/assistant/composer/AssistantLanguageSelector.js.map +1 -0
  13. package/dist/components/assistant/composer/AssistantVoiceSelector.js +39 -0
  14. package/dist/components/assistant/composer/AssistantVoiceSelector.js.map +1 -0
  15. package/dist/config/assistantLanguages.js +126 -0
  16. package/dist/config/assistantLanguages.js.map +1 -0
  17. package/dist/hooks/useVoiceInput.js +34 -34
  18. package/dist/hooks/useVoiceInput.js.map +1 -1
  19. package/dist/store/assistantStore.js +14 -3
  20. package/dist/store/assistantStore.js.map +1 -1
  21. package/dist/types/assistant.js.map +1 -1
  22. package/dist/utils/assistantPrompt.js +5 -5
  23. package/dist/utils/assistantPrompt.js.map +1 -1
  24. package/dist/utils/speakableText.js +7 -5
  25. package/dist/utils/speakableText.js.map +1 -1
  26. package/dist/utils/speechVoices.js +25 -12
  27. package/dist/utils/speechVoices.js.map +1 -1
  28. package/package.json +1 -1
@@ -2,58 +2,58 @@ 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 { languageDisplayName as h } from "../../utils/speechVoices.js";
6
- import { isTurnInFlight as g } from "../../utils/assistantTurnState.js";
7
- import { getOrganizationId as _, getWorkspaceId as ee } from "../../utils/assistantContext.js";
8
- import { buildPromptParts as te, buildPromptWithAttachments as ne, countInlineImageCandidates as re, countInlinedImageParts as ie, toMessageAttachment as ae } from "../../utils/assistantAttachments.js";
9
- import { AssistantMessageList as v } from "./AssistantMessageList.js";
10
- import { AssistantApiCallsConsentDialog as y } from "./AssistantApiCallsConsentDialog.js";
11
- import { ASSISTANT_MODES as b } from "../../types/assistant.js";
12
- import { AssistantEmptyState as x } from "./AssistantEmptyState.js";
13
- import { AssistantComposer as S } from "./composer/AssistantComposer.js";
14
- import { useAssistantApiAccess as C } from "../../hooks/useAssistantApiAccess.js";
15
- import { isQuotaExhaustedError as w } from "../../utils/quotaUtils.js";
16
- import { dispatchAssistantQuotaExhausted as oe, notifyAiCreditsUpdated as se } from "../../utils/aiCredits.js";
17
- import { buildPromptForMode as ce } from "../../utils/assistantPrompt.js";
18
- import { isMultimodalBodyRejection as le, isRecoverableAssistantError as ue } from "../../utils/assistantTransportErrors.js";
19
- import { useCallback as T, useEffect as de, useMemo as fe, useRef as E, useState as pe } from "react";
20
- import { useI18n as me } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
21
- import { jsx as D, jsxs as he } from "react/jsx-runtime";
22
- import { useGatewayClient as ge } from "@burdenoff/fe-libs/shared/graphql";
23
- import { useAuthToken as _e } from "@burdenoff/fe-libs/shared/providers/shell";
24
- import { getAssistantMedia as O } from "@burdenoff/fe-libs/shared/assistant";
5
+ import { findAssistantLanguage as h, resolveAssistantLanguage as g } from "../../config/assistantLanguages.js";
6
+ import { isTurnInFlight as _ } from "../../utils/assistantTurnState.js";
7
+ import { getOrganizationId as v, getWorkspaceId as ee } from "../../utils/assistantContext.js";
8
+ import { buildPromptParts as te, buildPromptWithAttachments as ne, countInlineImageCandidates as re, countInlinedImageParts as ie, toMessageAttachment as y } from "../../utils/assistantAttachments.js";
9
+ import { AssistantMessageList as b } from "./AssistantMessageList.js";
10
+ import { AssistantApiCallsConsentDialog as x } from "./AssistantApiCallsConsentDialog.js";
11
+ import { ASSISTANT_MODES as S } from "../../types/assistant.js";
12
+ import { AssistantEmptyState as C } from "./AssistantEmptyState.js";
13
+ import { AssistantComposer as w } from "./composer/AssistantComposer.js";
14
+ import { useAssistantApiAccess as ae } from "../../hooks/useAssistantApiAccess.js";
15
+ import { isQuotaExhaustedError as oe } from "../../utils/quotaUtils.js";
16
+ import { dispatchAssistantQuotaExhausted as se, notifyAiCreditsUpdated as ce } from "../../utils/aiCredits.js";
17
+ import { buildPromptForMode as le } from "../../utils/assistantPrompt.js";
18
+ import { isMultimodalBodyRejection as ue, isRecoverableAssistantError as de } from "../../utils/assistantTransportErrors.js";
19
+ import { useCallback as T, useEffect as E, useMemo as D, useRef as O, useState as fe } from "react";
20
+ import { useI18n as pe } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
21
+ import { jsx as k, jsxs as me } from "react/jsx-runtime";
22
+ import { useGatewayClient as he } from "@burdenoff/fe-libs/shared/graphql";
23
+ import { useAuthToken as ge } from "@burdenoff/fe-libs/shared/providers/shell";
24
+ import { getAssistantMedia as A } from "@burdenoff/fe-libs/shared/assistant";
25
25
  //#region src/components/assistant/AssistantChatArea.tsx
26
- var ve = {
26
+ var _e = {
27
27
  general: 18e4,
28
28
  assistant: 18e4,
29
29
  "api-calls": 18e4,
30
30
  "vibe-plugins": 6e5
31
- }, ye = 18e4;
32
- function be() {
31
+ }, ve = 18e4;
32
+ function ye() {
33
33
  return `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
34
34
  }
35
- function xe(e) {
35
+ function be(e) {
36
36
  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]");
37
37
  }
38
- function k(e) {
38
+ function j(e) {
39
39
  return e.info?.time?.created ?? 0;
40
40
  }
41
- function A(e) {
41
+ function M(e) {
42
42
  return (e ?? []).filter((e) => e.type === "text" && typeof e.text == "string").map((e) => e.text?.trim() ?? "").filter(Boolean).join("\n");
43
43
  }
44
- function j(e) {
44
+ function N(e) {
45
45
  return (e ?? []).filter((e) => e.type === "tool" && e.tool).map((e) => {
46
46
  let t = e.state?.status ?? "running", n = e.tool ?? "tool";
47
47
  return t === "completed" ? `Completed: ${n}` : t === "failed" ? `Failed: ${n}` : `Running: ${n}`;
48
48
  });
49
49
  }
50
- function Se(e, t) {
51
- let n = e.filter((e) => e.info?.role === "assistant" && k(e) > t).sort((e, t) => k(e) - k(t));
50
+ function xe(e, t) {
51
+ let n = e.filter((e) => e.info?.role === "assistant" && j(e) > t).sort((e, t) => j(e) - j(t));
52
52
  if (n.length === 0) return {
53
53
  content: "Thinking...",
54
54
  done: !1
55
55
  };
56
- let r = n[n.length - 1], i = A(r.parts), a = O(r.parts), o = j(r.parts);
56
+ let r = n[n.length - 1], i = M(r.parts), a = A(r.parts), o = N(r.parts);
57
57
  return {
58
58
  content: [
59
59
  i,
@@ -64,7 +64,7 @@ function Se(e, t) {
64
64
  tokens: r.info?.tokens
65
65
  };
66
66
  }
67
- function Ce(e) {
67
+ function Se(e) {
68
68
  switch (e) {
69
69
  case "provisioning": return "Starting assistant environment...";
70
70
  case "connecting": return "Connecting to assistant...";
@@ -72,254 +72,260 @@ function Ce(e) {
72
72
  default: return "";
73
73
  }
74
74
  }
75
- var M = () => {
76
- let O = t(), A = ge("workspace"), { getAccessToken: j, getWorkspaceToken: M, userId: we } = _e(), { locale: Te } = me(), Ee = fe(() => h(Te, "en"), [Te]), { conversations: De, activeConversationId: N, mode: P, processingByConversationId: Oe, setMode: F, setConversationMode: I, setActiveConversation: ke, createConversation: L, addMessage: R, updateMessage: z, patchMessage: B, setConversationProcessing: V, clearConversationProcessing: Ae, setBackendSessionId: H, clearBackendSessionId: U, setSandbox: W, clearSandbox: je, acknowledgeApiCalls: Me } = e(), G = De.find((e) => e.id === N)?.messages ?? [], K = N ? Oe[N] : void 0, Ne = g(K?.status), Pe = Ne ? K?.messageId ?? null : null, Fe = K?.status === "error" ? K.messageId : null, { canUseApiCalls: q, loading: Ie } = C(_()), Le = fe(() => b.filter((e) => !e.requiresAdmin || q), [q]), [J, Y] = pe(null), Re = E({}), X = E(/* @__PURE__ */ new Set());
77
- de(() => {
78
- if (Ie) return;
79
- let e = b.find((e) => e.id === P);
80
- (!e || e.requiresAdmin && !q) && P !== "assistant" && F("assistant");
75
+ var P = () => {
76
+ let A = t(), M = he("workspace"), { getAccessToken: N, getWorkspaceToken: P, userId: Ce } = ge(), { locale: F } = pe(), I = e((e) => e.assistantLanguage), we = D(() => g(I, F).english, [I, F]), Te = h(I) !== null, L = D(() => g(I, F).code, [I, F]), { conversations: Ee, activeConversationId: R, mode: z, processingByConversationId: De, setMode: B, setConversationMode: V, setActiveConversation: Oe, createConversation: H, addMessage: U, updateMessage: ke, patchMessage: W, setConversationProcessing: G, clearConversationProcessing: Ae, setBackendSessionId: je, clearBackendSessionId: K, setSandbox: q, clearSandbox: Me, acknowledgeApiCalls: Ne } = e(), J = Ee.find((e) => e.id === R)?.messages ?? [], Y = R ? De[R] : void 0, Pe = _(Y?.status), Fe = Pe ? Y?.messageId ?? null : null, Ie = Y?.status === "error" ? Y.messageId : null, { canUseApiCalls: X, loading: Le } = ae(v()), Re = D(() => S.filter((e) => !e.requiresAdmin || X), [X]), [ze, Be] = fe(null), Ve = O({}), He = O(/* @__PURE__ */ new Set());
77
+ E(() => {
78
+ if (Le) return;
79
+ let e = S.find((e) => e.id === z);
80
+ (!e || e.requiresAdmin && !X) && z !== "assistant" && B("assistant");
81
81
  }, [
82
- P,
83
- q,
84
- Ie,
85
- F
82
+ z,
83
+ X,
84
+ Le,
85
+ B
86
86
  ]);
87
87
  let Z = T((e, t, n, r) => {
88
- V(e, n, t, null), r ? z(e, t, r) : z(e, t, Ce(n));
89
- }, [V, z]), ze = T(async (t, n, a, s, c) => {
88
+ G(e, n, t, null), r ? ke(e, t, r) : ke(e, t, Se(n));
89
+ }, [G, ke]), Ue = T(async (t, n, a, s, c) => {
90
90
  let u = e.getState().sandboxesByMode[a]?.sandboxId ?? null, d = async (e) => {
91
91
  try {
92
- return await p(A, e, s, c, 3e5, (e) => Z(t, n, "provisioning", e)), await f(A, e, s, c, 9e4, (e) => Z(t, n, "connecting", e)), !0;
92
+ return await p(M, e, s, c, 3e5, (e) => Z(t, n, "provisioning", e)), await f(M, e, s, c, 9e4, (e) => Z(t, n, "connecting", e)), !0;
93
93
  } catch {
94
94
  return !1;
95
95
  }
96
96
  };
97
- if (u && (W(a, u, "provisioning"), Z(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (W(a, null, "provisioning"), u = null)), !u) {
97
+ if (u && (q(a, u, "provisioning"), Z(t, n, "provisioning", "Reusing assistant environment..."), await d(u) || (q(a, null, "provisioning"), u = null)), !u) {
98
98
  Z(t, n, "provisioning", "Looking for existing environment...");
99
- let e = await o(A, s, a, c);
100
- e && (W(a, e, "provisioning"), Z(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : W(a, null, "provisioning"));
99
+ let e = await o(M, s, a, c);
100
+ e && (q(a, e, "provisioning"), Z(t, n, "provisioning", "Reusing assistant environment..."), await d(e) ? u = e : q(a, null, "provisioning"));
101
101
  }
102
102
  if (!u) {
103
- if (a === "api-calls" && !j()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
104
- Z(t, n, "provisioning", "Starting assistant environment..."), W(a, null, "provisioning"), u = await r(A, a, s, c), W(a, u, "provisioning"), await p(A, u, s, c, 3e5, (e) => Z(t, n, "provisioning", e)), await f(A, u, s, c, 9e4, (e) => Z(t, n, "connecting", e));
103
+ if (a === "api-calls" && !N()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
104
+ Z(t, n, "provisioning", "Starting assistant environment..."), q(a, null, "provisioning"), u = await r(M, a, s, c), q(a, u, "provisioning"), await p(M, u, s, c, 3e5, (e) => Z(t, n, "provisioning", e)), await f(M, u, s, c, 9e4, (e) => Z(t, n, "connecting", e));
105
105
  }
106
- W(a, u, "running");
106
+ q(a, u, "running");
107
107
  let m = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
108
108
  if (m) try {
109
- let e = await l(A, u, s, m, c);
109
+ let e = await l(M, u, s, m, c);
110
110
  if (e.mode !== a) throw Error(`Session mode mismatch: expected ${a}, received ${e.mode}`);
111
111
  } catch {
112
- U(t), m = null;
112
+ K(t), m = null;
113
113
  }
114
- return m || (Z(t, n, "connecting", "Preparing session..."), m = (await i(A, u, s, a, c)).sessionId, H(t, m)), {
114
+ return m || (Z(t, n, "connecting", "Preparing session..."), m = (await i(M, u, s, a, c)).sessionId, je(t, m)), {
115
115
  sandboxId: u,
116
116
  sessionId: m
117
117
  };
118
118
  }, [
119
- A,
120
- U,
121
- j,
122
- H,
123
- W,
119
+ M,
120
+ K,
121
+ N,
122
+ je,
123
+ q,
124
124
  Z
125
125
  ]), Q = T(async (t, r = []) => {
126
- let i = e.getState(), o = i.activeConversationId ?? N;
127
- if (o && (g(i.processingByConversationId[o]?.status) || X.current.has(o))) return;
128
- let l = i.mode, f = N, p = f ? e.getState().conversations.find((e) => e.id === f) : void 0;
129
- if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f = L(void 0, l) : p && p.mode !== l && I(f, l) : f = L(void 0, l), !f) return;
130
- Re.current[f] = r;
131
- let h = ee(), v = {
132
- accessToken: j(),
133
- workspaceToken: M(),
134
- userId: we,
135
- organizationId: _()
136
- }, y = {
137
- id: be(),
126
+ let i = e.getState(), o = i.activeConversationId ?? R;
127
+ if (o && (_(i.processingByConversationId[o]?.status) || He.current.has(o))) return;
128
+ let l = i.mode, f = R, p = f ? e.getState().conversations.find((e) => e.id === f) : void 0;
129
+ if (f ? p && p.mode !== l && (p.messages.length > 0 || p.backendSessionId) ? f = H(void 0, l) : p && p.mode !== l && V(f, l) : f = H(void 0, l), !f) return;
130
+ Ve.current[f] = r;
131
+ let h = ee(), g = {
132
+ accessToken: N(),
133
+ workspaceToken: P(),
134
+ userId: Ce,
135
+ organizationId: v()
136
+ }, b = {
137
+ id: ye(),
138
138
  role: "user",
139
139
  content: t,
140
140
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
141
- metadata: r.length ? { attachments: r.map(ae) } : void 0
141
+ metadata: r.length ? { attachments: r.map(y) } : void 0
142
142
  };
143
- R(f, y);
144
- let b = be();
145
- R(f, {
146
- id: b,
143
+ U(f, b);
144
+ let x = ye();
145
+ U(f, {
146
+ id: x,
147
147
  role: "assistant",
148
148
  content: "",
149
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
150
- }), V(f, "provisioning", b, null);
151
- let x = (e, t, n, r) => {
152
- B(f, b, {
153
- content: xe(e),
154
- metadata: t?.length || n || r ? {
155
- artifacts: t,
156
- mode: l,
157
- sessionId: n,
158
- sandboxId: r
159
- } : void 0
149
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
150
+ metadata: { lang: L }
151
+ }), G(f, "provisioning", x, null);
152
+ let S = (e, t, n, r, i = L) => {
153
+ W(f, x, {
154
+ content: be(e),
155
+ metadata: {
156
+ lang: i,
157
+ ...t?.length ? { artifacts: t } : {},
158
+ ...t?.length || n || r ? { mode: l } : {},
159
+ ...n ? { sessionId: n } : {},
160
+ ...r ? { sandboxId: r } : {}
161
+ }
160
162
  });
161
- }, S = async (e = 1) => {
163
+ }, C = async (e = 1) => {
162
164
  let i = !1;
163
165
  try {
164
- await n(A, h, v);
166
+ await n(M, h, g);
165
167
  } catch (e) {
166
- if (w(e)) {
167
- oe("ai-credits"), x("You've run out of AI credits for this billing cycle. Upgrade your plan to keep chatting."), V(f, "error", b, null);
168
+ if (oe(e)) {
169
+ se("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"), G(f, "error", x, null);
168
170
  return;
169
171
  }
170
172
  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);
171
173
  }
172
174
  try {
173
- let { sandboxId: e, sessionId: n } = await ze(f, b, l, h, v), o = (await c(A, e, h, n, v, 50).catch(() => [])).reduce((e, t) => Math.max(e, k(t)), 0);
174
- Z(f, b, "streaming", "Thinking...");
175
- let p = ce(l, ne(t, r), Ee), g = te(p, r), _ = ie(g), ee = _ > 0, ae = m();
176
- i = re(r) > _;
175
+ let { sandboxId: e, sessionId: n } = await Ue(f, x, l, h, g), o = (await c(M, e, h, n, g, 50).catch(() => [])).reduce((e, t) => Math.max(e, j(t)), 0);
176
+ Z(f, x, "streaming", "Thinking...");
177
+ let p = le(l, ne(t, r), we, Te), _ = te(p, r), v = ie(_), ee = v > 0, y = m();
178
+ i = re(r) > v;
177
179
  try {
178
- await d(A, e, h, n, p, l, ae, v, g);
180
+ await d(M, e, h, n, p, l, y, g, _);
179
181
  } catch (t) {
180
- if (!g || !le(t)) throw t;
181
- await d(A, e, h, n, p, l, ae, v, void 0), i ||= ee;
182
+ if (!_ || !ue(t)) throw t;
183
+ await d(M, e, h, n, p, l, y, g, void 0), i ||= ee;
182
184
  }
183
- let y = Se([], o), S = Date.now() + (ve[l] ?? ye), C = Date.now();
184
- for (; Date.now() < S && (y = Se(await c(A, e, h, n, v, 50), o), B(f, b, { content: xe(y.content) }), !y.done);) Date.now() - C > 3e4 && (await a(A, e, h, 600, v).catch(() => void 0), C = Date.now()), await new Promise((e) => setTimeout(e, 1500));
185
- if (!y.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
186
- let w = l === "vibe-plugins" ? await s(A, e, h, n, v).catch(() => []) : void 0;
187
- if (y.done || (y = {
188
- ...y,
189
- content: `${y.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
190
- }), i && (y = {
191
- ...y,
192
- content: `${y.content}\n\n${O("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._")}`
193
- }), x(y.content, w, n, e), y.tokens) {
194
- B(f, b, { tokens: y.tokens });
185
+ let b = xe([], o), C = Date.now() + (_e[l] ?? ve), w = Date.now();
186
+ for (; Date.now() < C && (b = xe(await c(M, e, h, n, g, 50), o), W(f, x, { content: be(b.content) }), !b.done);) Date.now() - w > 3e4 && (await a(M, e, h, 600, g).catch(() => void 0), w = Date.now()), await new Promise((e) => setTimeout(e, 1500));
187
+ if (!b.done && l !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
188
+ let ae = l === "vibe-plugins" ? await s(M, e, h, n, g).catch(() => []) : void 0;
189
+ if (b.done || (b = {
190
+ ...b,
191
+ content: `${b.content}\n\n_Still building in the background — any artifacts below will finish shortly. Re-open this conversation to pick up the completed plugin._`
192
+ }), i && (b = {
193
+ ...b,
194
+ content: `${b.content}\n\n${A("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._")}`
195
+ }), S(b.content, ae, n, e), b.tokens) {
196
+ W(f, x, { tokens: b.tokens });
195
197
  try {
196
- await u(A, h, n, y.tokens, v), se();
198
+ await u(M, h, n, b.tokens, g), ce();
197
199
  } catch {}
198
200
  }
199
- V(f, "complete", b, null);
201
+ G(f, "complete", x, null);
200
202
  } catch (t) {
201
- if (e === 1 && ue(t)) return U(f), je(l), S(2);
203
+ if (e === 1 && de(t)) return K(f), Me(l), C(2);
202
204
  throw t;
203
205
  }
204
- }, C = f;
205
- X.current.add(C);
206
+ }, w = f;
207
+ He.current.add(w);
206
208
  try {
207
209
  if (!h) throw Error("Assistant backend is unavailable without an active workspace context.");
208
- await S();
210
+ await C();
209
211
  } catch (e) {
210
- if (w(e)) {
211
- oe("sandbox"), x("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant."), V(f, "error", b, null);
212
+ if (oe(e)) {
213
+ se("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"), G(f, "error", x, null);
212
214
  return;
213
215
  }
214
216
  let t = e instanceof Error ? e.message : "Something went wrong";
215
- V(f, "error", b, t), z(f, b, `Sorry, an error occurred: ${t}. Please try again.`);
217
+ G(f, "error", x, t), W(f, x, {
218
+ content: `Sorry, an error occurred: ${t}. Please try again.`,
219
+ metadata: { lang: "en" }
220
+ });
216
221
  } finally {
217
- X.current.delete(C);
222
+ He.current.delete(w);
218
223
  }
219
224
  }, [
220
- N,
221
225
  R,
222
- A,
223
226
  U,
224
- je,
225
- De,
226
- L,
227
- ze,
228
- j,
229
227
  M,
230
- B,
228
+ K,
229
+ Me,
231
230
  Ee,
232
231
  H,
233
- I,
232
+ Ue,
233
+ N,
234
+ P,
235
+ W,
236
+ Te,
237
+ L,
238
+ we,
239
+ je,
234
240
  V,
235
- O,
241
+ G,
242
+ A,
236
243
  Z,
237
- z,
238
- we
239
- ]), Be = T((e) => {
244
+ Ce
245
+ ]), We = T((e) => {
240
246
  Q(e);
241
- }, [Q]), Ve = T(() => {
242
- let e = [...G].reverse().find((e) => e.role === "user"), t = N ? Re.current[N] ?? [] : [];
247
+ }, [Q]), Ge = T(() => {
248
+ let e = [...J].reverse().find((e) => e.role === "user"), t = R ? Ve.current[R] ?? [] : [];
243
249
  e && Q(e.content, t);
244
250
  }, [
245
- G,
251
+ J,
246
252
  Q,
247
- N
248
- ]), He = E(Q);
249
- de(() => {
250
- He.current = Q;
251
- }, [Q]), de(() => {
253
+ R
254
+ ]), Ke = O(Q);
255
+ E(() => {
256
+ Ke.current = Q;
257
+ }, [Q]), E(() => {
252
258
  let t = e.getState().consumePendingPrompt();
253
- return t && He.current(t), e.subscribe((t, n) => {
259
+ return t && Ke.current(t), e.subscribe((t, n) => {
254
260
  if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
255
261
  let t = e.getState().consumePendingPrompt();
256
- t && He.current(t);
262
+ t && Ke.current(t);
257
263
  }
258
264
  });
259
265
  }, []);
260
266
  let $ = T((t) => {
261
- let n = N ? e.getState().conversations.find((e) => e.id === N) : void 0;
267
+ let n = R ? e.getState().conversations.find((e) => e.id === R) : void 0;
262
268
  if (n && (n.messages.length > 0 || n.backendSessionId)) {
263
269
  if (n.mode !== t) {
264
270
  let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
265
- n ? ke(n.id) : L(void 0, t);
271
+ n ? Oe(n.id) : H(void 0, t);
266
272
  }
267
- } else N && I(N, t);
268
- F(t);
273
+ } else R && V(R, t);
274
+ B(t);
269
275
  }, [
270
- N,
271
- L,
272
- ke,
273
- I,
274
- F
275
- ]), Ue = T((t) => {
276
- if (b.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
277
- Y(t);
276
+ R,
277
+ H,
278
+ Oe,
279
+ V,
280
+ B
281
+ ]), qe = T((t) => {
282
+ if (S.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
283
+ Be(t);
278
284
  return;
279
285
  }
280
286
  $(t);
281
- }, [$]), We = T(() => {
282
- let e = J;
283
- Y(null), Me(), e && $(e);
287
+ }, [$]), Je = T(() => {
288
+ let e = ze;
289
+ Be(null), Ne(), e && $(e);
284
290
  }, [
285
- J,
286
- Me,
291
+ ze,
292
+ Ne,
287
293
  $
288
- ]), Ge = T(() => {
289
- Y(null);
294
+ ]), Ye = T(() => {
295
+ Be(null);
290
296
  }, []);
291
- return /* @__PURE__ */ he("div", {
297
+ return /* @__PURE__ */ me("div", {
292
298
  className: "flex flex-1 flex-col overflow-hidden",
293
299
  children: [
294
- G.length === 0 ? /* @__PURE__ */ D(x, {
295
- mode: P,
296
- onSuggestionClick: Be
297
- }) : /* @__PURE__ */ D("div", {
300
+ J.length === 0 ? /* @__PURE__ */ k(C, {
301
+ mode: z,
302
+ onSuggestionClick: We
303
+ }) : /* @__PURE__ */ k("div", {
298
304
  className: "flex min-h-0 flex-1 flex-col",
299
- children: /* @__PURE__ */ D(v, {
300
- messages: G,
301
- streamingMessageId: Pe,
302
- failedMessageId: Fe,
303
- onRetry: Ve
305
+ children: /* @__PURE__ */ k(b, {
306
+ messages: J,
307
+ streamingMessageId: Fe,
308
+ failedMessageId: Ie,
309
+ onRetry: Ge
304
310
  })
305
311
  }),
306
- /* @__PURE__ */ D(S, {
312
+ /* @__PURE__ */ k(w, {
307
313
  onSend: (e, t) => void Q(e, t),
308
- disabled: Ne,
309
- placeholder: P === "api-calls" ? O("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : O("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
310
- mode: P,
311
- availableModes: Le,
312
- onModeChange: Ue
314
+ disabled: Pe,
315
+ placeholder: z === "api-calls" ? A("healthybowl.assistant.chatArea.placeholderActions", "What would you like me to do?") : A("healthybowl.assistant.chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
316
+ mode: z,
317
+ availableModes: Re,
318
+ onModeChange: qe
313
319
  }),
314
- /* @__PURE__ */ D(y, {
315
- open: J !== null,
316
- onConfirm: We,
317
- onCancel: Ge
320
+ /* @__PURE__ */ k(x, {
321
+ open: ze !== null,
322
+ onConfirm: Je,
323
+ onCancel: Ye
318
324
  })
319
325
  ]
320
326
  });
321
327
  };
322
328
  //#endregion
323
- export { M as AssistantChatArea };
329
+ export { P as AssistantChatArea };
324
330
 
325
331
  //# sourceMappingURL=AssistantChatArea.js.map