@burdenoff/microfe-healthybowl 2026.904.5 → 2026.904.7

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