@burdenoff/microfe-healthybowl 2026.902.10 → 2026.902.12

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