@burdenoff/microfe-healthybowl 2026.904.6 → 2026.904.8

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);
71
+ let r = n[n.length - 1], i = M(r.parts), a = k(r.parts), o = N(r.parts), s = Ee(r.parts);
72
72
  return {
73
73
  content: [
74
74
  i,
@@ -80,7 +80,7 @@ function We(e, t) {
80
80
  ...s ? { pendingWrite: s } : {}
81
81
  };
82
82
  }
83
- function Ge(e) {
83
+ function We(e) {
84
84
  switch (e) {
85
85
  case "provisioning": return "Starting assistant environment...";
86
86
  case "connecting": return "Connecting to assistant...";
@@ -88,95 +88,95 @@ function Ge(e) {
88
88
  default: return "";
89
89
  }
90
90
  }
91
- var Ke = ({ visible: De = !0 }) => {
92
- 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), [
91
+ var Ge = ({ visible: Ee = !0 }) => {
92
+ 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), [
93
+ Je,
93
94
  Ye,
94
- Xe,
95
- Je
96
- ]), 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]);
97
- T(() => {
98
- mt || (!wt || wt.requiresAdmin && !pt) && P !== "assistant" && F("assistant");
95
+ qe
96
+ ]), 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]);
97
+ E(() => {
98
+ mt || (!wt || wt.requiresAdmin && !pt) && F !== "assistant" && I("assistant");
99
99
  }, [
100
- P,
100
+ F,
101
101
  wt,
102
102
  pt,
103
103
  mt,
104
- F
104
+ I
105
105
  ]);
106
- let K = w((e, t, n, r) => {
107
- B(e, n, t, null), r ? it(e, t, r) : it(e, t, Ge(n));
108
- }, [B, it]), Tt = w(async (t, i, o, s, c) => {
106
+ let K = T((e, t, n, r) => {
107
+ V(e, n, t, null), r ? rt(e, t, r) : rt(e, t, We(n));
108
+ }, [V, rt]), Tt = T(async (t, i, o, s, c) => {
109
109
  let l = e.getState().sandboxesByMode[o]?.sandboxId ?? null, te = async (e) => {
110
110
  if (St.current.isFresh(e)) return !0;
111
111
  try {
112
- 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;
112
+ 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;
113
113
  } catch {
114
114
  return St.current.invalidate(e), !1;
115
115
  }
116
116
  };
117
- if (l && (H(o, l, "provisioning"), K(t, i, "provisioning", "Reusing assistant environment..."), await te(l) || (H(o, null, "provisioning"), l = null)), !l) {
117
+ if (l && (U(o, l, "provisioning"), K(t, i, "provisioning", "Reusing assistant environment..."), await te(l) || (U(o, null, "provisioning"), l = null)), !l) {
118
118
  K(t, i, "provisioning", "Looking for existing environment...");
119
- let e = await a(j, s, o, c);
120
- e && (H(o, e, "provisioning"), K(t, i, "provisioning", "Reusing assistant environment..."), await te(e) ? l = e : H(o, null, "provisioning"));
119
+ let e = await a(M, s, o, c);
120
+ e && (U(o, e, "provisioning"), K(t, i, "provisioning", "Reusing assistant environment..."), await te(e) ? l = e : U(o, null, "provisioning"));
121
121
  }
122
122
  if (!l) {
123
- if (o === "api-calls" && !M()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
124
- 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));
123
+ if (o === "api-calls" && !N()) throw Error("API Calls mode requires an authenticated session. Please sign in again.");
124
+ 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));
125
125
  }
126
- H(o, l, "running");
126
+ U(o, l, "running");
127
127
  let f = e.getState().conversations.find((e) => e.id === t)?.backendSessionId ?? null;
128
128
  if (f) try {
129
- let e = await ee(j, l, s, f, c);
129
+ let e = await ee(M, l, s, f, c);
130
130
  if (e.mode !== o) throw Error(`Session mode mismatch: expected ${o}, received ${e.mode}`);
131
131
  } catch {
132
- V(t), f = null;
132
+ H(t), f = null;
133
133
  }
134
- return f || (K(t, i, "connecting", "Preparing session..."), f = (await r(j, l, s, o, c)).sessionId, st(t, f)), {
134
+ return f || (K(t, i, "connecting", "Preparing session..."), f = (await r(M, l, s, o, c)).sessionId, ot(t, f)), {
135
135
  sandboxId: l,
136
136
  sessionId: f
137
137
  };
138
138
  }, [
139
- j,
140
- V,
141
139
  M,
142
- st,
143
140
  H,
141
+ N,
142
+ ot,
143
+ U,
144
144
  K
145
- ]), q = w(async (n, r = [], a = {}) => {
146
- let ee = a.voiceSessionId !== void 0, u = e.getState(), d = u.activeConversationId ?? N;
147
- if (d && (ne(u.processingByConversationId[d]?.status) || Ct.current.has(d))) return;
148
- let f = u.mode, m = N, h = m ? e.getState().conversations.find((e) => e.id === m) : void 0;
149
- 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;
145
+ ]), q = T(async (n, r = [], a = {}) => {
146
+ let ee = a.voiceSessionId !== void 0, u = e.getState(), d = u.activeConversationId ?? P;
147
+ if (d && (we(u.processingByConversationId[d]?.status) || Ct.current.has(d))) return;
148
+ let f = u.mode, m = P, h = m ? e.getState().conversations.find((e) => e.id === m) : void 0;
149
+ 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;
150
150
  xt.current[m] = r;
151
- let g = re(), _ = {
152
- accessToken: M(),
153
- workspaceToken: Ke(),
154
- userId: qe,
155
- organizationId: b()
156
- }, v = {
157
- id: He(),
151
+ let g = y(), _ = {
152
+ accessToken: N(),
153
+ workspaceToken: Ge(),
154
+ userId: Ke,
155
+ organizationId: v()
156
+ }, ne = {
157
+ id: Ve(),
158
158
  role: "user",
159
159
  content: n,
160
160
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
161
161
  metadata: {
162
- ...r.length ? { attachments: r.map(ce) } : {},
162
+ ...r.length ? { attachments: r.map(se) } : {},
163
163
  ...p(a.voiceSessionId)
164
164
  }
165
165
  };
166
- R(m, v);
167
- let y = He();
168
- R(m, {
169
- id: y,
166
+ z(m, ne);
167
+ let b = Ve();
168
+ z(m, {
169
+ id: b,
170
170
  role: "assistant",
171
171
  content: "",
172
172
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
173
173
  metadata: {
174
- lang: et,
174
+ lang: $e,
175
175
  ...p(a.voiceSessionId)
176
176
  }
177
- }), B(m, "provisioning", y, null);
178
- let x = (e, t, n, r, i = et) => {
179
- z(m, y, { content: Ue(e) }), at(m, y, {
177
+ }), V(m, "provisioning", b, null);
178
+ let x = (e, t, n, r, i = $e) => {
179
+ B(m, b, { content: He(e) }), it(m, b, {
180
180
  lang: i,
181
181
  ...t?.length ? { artifacts: t } : {},
182
182
  ...t?.length || n || r ? { mode: f } : {},
@@ -187,44 +187,44 @@ var Ke = ({ visible: De = !0 }) => {
187
187
  }, S = async (e = 1) => {
188
188
  let a = !1;
189
189
  try {
190
- await t(j, g, _);
190
+ await t(M, g, _);
191
191
  } catch (e) {
192
- if (be(e)) {
193
- 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);
192
+ if (ve(e)) {
193
+ 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);
194
194
  return;
195
195
  }
196
196
  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);
197
197
  }
198
198
  try {
199
- 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);
200
- K(m, y, "streaming", "Thinking...");
201
- let d = Ce(f, ae(n, r), Qe, $e, ee), p = ie(d, r), h = se(p), ne = h > 0, v = te();
202
- a = oe(r) > h;
199
+ 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);
200
+ K(m, b, "streaming", "Thinking...");
201
+ let d = xe(f, ie(n, r), Ze, Qe, ee), p = re(d, r), h = oe(p), ne = h > 0, v = te();
202
+ a = ae(r) > h;
203
203
  try {
204
- await l(j, e, g, t, d, f, v, _, p);
204
+ await l(M, e, g, t, d, f, v, _, p);
205
205
  } catch (n) {
206
- if (!p || !we(n)) throw n;
207
- await l(j, e, g, t, d, f, v, _, void 0), a ||= ne;
206
+ if (!p || !Se(n)) throw n;
207
+ await l(M, e, g, t, d, f, v, _, void 0), a ||= ne;
208
208
  }
209
- let b = We([], u), re = Date.now() + (ze[f] ?? Be), ce = Date.now(), S = Date.now();
210
- 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)));
211
- if (!b.done && f !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
212
- let C = f === "vibe-plugins" ? await o(j, e, g, t, _).catch(() => []) : void 0;
213
- if (b.done || (b = {
214
- ...b,
215
- 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._`
216
- }), a && (b = {
217
- ...b,
218
- 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._")}`
219
- }), x(b.content, C, t, e), b.tokens) {
220
- z(m, y, { tokens: b.tokens });
209
+ let y = Ue([], u), se = Date.now() + (Re[f] ?? ze), S = Date.now(), C = Date.now();
210
+ 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)));
211
+ if (!y.done && f !== "vibe-plugins") throw Error("Assistant response timed out while streaming progress");
212
+ let w = f === "vibe-plugins" ? await o(M, e, g, t, _).catch(() => []) : void 0;
213
+ if (y.done || (y = {
214
+ ...y,
215
+ 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._`
216
+ }), a && (y = {
217
+ ...y,
218
+ 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._")}`
219
+ }), x(y.content, w, t, e), y.tokens) {
220
+ B(m, b, { tokens: y.tokens });
221
221
  try {
222
- await c(j, g, t, b.tokens, _), Se();
222
+ await c(M, g, t, y.tokens, _), be();
223
223
  } catch {}
224
224
  }
225
- B(m, "complete", y, null);
225
+ V(m, "complete", b, null);
226
226
  } catch (t) {
227
- if (e === 1 && Te(t)) return V(m), ct(f), S(2);
227
+ if (e === 1 && Ce(t)) return H(m), st(f), S(2);
228
228
  throw t;
229
229
  }
230
230
  }, C = m;
@@ -233,12 +233,12 @@ var Ke = ({ visible: De = !0 }) => {
233
233
  if (!g) throw Error("Assistant backend is unavailable without an active workspace context.");
234
234
  await S();
235
235
  } catch (t) {
236
- if (St.current.invalidate(e.getState().sandboxesByMode[f]?.sandboxId ?? null), be(t)) {
237
- 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);
236
+ if (St.current.invalidate(e.getState().sandboxesByMode[f]?.sandboxId ?? null), ve(t)) {
237
+ 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);
238
238
  return;
239
239
  }
240
240
  let n = t instanceof Error ? t.message : "Something went wrong";
241
- B(m, "error", y, n), z(m, y, { content: `Sorry, an error occurred: ${n}. Please try again.` }), at(m, y, {
241
+ V(m, "error", b, n), B(m, b, { content: `Sorry, an error occurred: ${n}. Please try again.` }), it(m, b, {
242
242
  lang: "en",
243
243
  ...p(a.voiceSessionId)
244
244
  });
@@ -246,188 +246,188 @@ var Ke = ({ visible: De = !0 }) => {
246
246
  Ct.current.delete(C);
247
247
  }
248
248
  }, [
249
- N,
250
- R,
251
- j,
252
- V,
253
- ct,
254
- tt,
255
- L,
256
- Tt,
257
- M,
258
- Ke,
249
+ P,
259
250
  z,
260
- $e,
261
- et,
262
- Qe,
251
+ M,
252
+ H,
263
253
  st,
264
- I,
254
+ et,
255
+ R,
256
+ Tt,
257
+ N,
258
+ Ge,
265
259
  B,
266
- O,
260
+ Qe,
261
+ $e,
262
+ Ze,
263
+ ot,
264
+ L,
265
+ V,
266
+ k,
267
267
  K,
268
- qe
269
- ]), Et = w((e) => {
268
+ Ke
269
+ ]), Et = T((e) => {
270
270
  q(e);
271
- }, [q]), Dt = w(() => {
272
- let e = [...U.chat].reverse().find((e) => e.role === "user"), t = N ? xt.current[N] ?? [] : [];
271
+ }, [q]), Dt = T(() => {
272
+ let e = [...W.chat].reverse().find((e) => e.role === "user"), t = P ? xt.current[P] ?? [] : [];
273
273
  e && q(e.content, t);
274
274
  }, [
275
- W,
275
+ G,
276
276
  q,
277
- N
278
- ]), J = D(q);
279
- T(() => {
280
- J.current = q;
277
+ P
278
+ ]), Ot = O(q);
279
+ E(() => {
280
+ Ot.current = q;
281
281
  }, [q]);
282
- let Ot = E(() => {
282
+ let J = D(() => {
283
283
  if (ut) return null;
284
- for (let e = W.length - 1; e >= 0; --e) {
285
- let t = W[e];
284
+ for (let e = G.length - 1; e >= 0; --e) {
285
+ let t = G[e];
286
286
  if (t?.role !== "assistant" || !f(t)) continue;
287
- let n = v(t.content).text.trim();
287
+ let n = x(t.content).text.trim();
288
288
  return n ? {
289
289
  id: t.id,
290
290
  text: n
291
291
  } : null;
292
292
  }
293
293
  return null;
294
- }, [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) => ({
294
+ }, [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) => ({
295
295
  id: e.id,
296
296
  role: e.role,
297
- text: v(e.content).text.trim(),
297
+ text: x(e.content).text.trim(),
298
298
  sessionId: m(e),
299
299
  timestamp: e.timestamp
300
- })).filter((e) => e.text.length > 0), [U.voice]), jt = w(() => {
300
+ })).filter((e) => e.text.length > 0), [W.voice]), jt = T(() => {
301
301
  if (Y.length === 0) return;
302
302
  let e = /* @__PURE__ */ new Date();
303
- h(Ae(Y, {
304
- title: O("voiceSession.transcript", "Voice conversation"),
305
- savedAt: O("voiceSession.savedAt", "Saved"),
306
- session: O("voiceSession.sessionLabel", "Session"),
307
- earlier: O("voiceSession.earlierLabel", "Earlier"),
308
- you: O("voiceSession.speakerYou", "You"),
309
- assistant: O("voiceSession.speakerAssistant", "Assistant")
310
- }, e), je(e), "text/markdown");
311
- }, [Y, O]), X = pe(), Z = D(X);
303
+ h(ke(Y, {
304
+ title: k("voiceSession.transcript", "Voice conversation"),
305
+ savedAt: k("voiceSession.savedAt", "Saved"),
306
+ session: k("voiceSession.sessionLabel", "Session"),
307
+ earlier: k("voiceSession.earlierLabel", "Earlier"),
308
+ you: k("voiceSession.speakerYou", "You"),
309
+ assistant: k("voiceSession.speakerAssistant", "Assistant")
310
+ }, e), Ae(e), "text/markdown");
311
+ }, [Y, k]), X = de(), Z = O(X);
312
312
  Z.current = X;
313
- let Q = ge({
314
- onSubmit: w((e, t) => {
313
+ let Q = me({
314
+ onSubmit: T((e, t) => {
315
315
  let n = () => {
316
- let n = Z.current, r = x(n.attachments);
317
- J.current(e, r, { voiceSessionId: t }), n.clear();
316
+ let n = Z.current, r = b(n.attachments);
317
+ Ot.current(e, r, { voiceSessionId: t }), n.clear();
318
318
  };
319
319
  if (!Z.current.isBusy) {
320
320
  n();
321
321
  return;
322
322
  }
323
323
  let r = Date.now(), i = window.setInterval(() => {
324
- Z.current.isBusy && Date.now() - r < Ve || (window.clearInterval(i), n());
324
+ Z.current.isBusy && Date.now() - r < Be || (window.clearInterval(i), n());
325
325
  }, 200);
326
326
  }, []),
327
- latestReply: Ot,
328
- language: g(Ye, Je).tag
329
- }), Mt = w(() => {
327
+ latestReply: J,
328
+ language: g(Je, qe).tag
329
+ }), Mt = T(() => {
330
330
  let t = e.getState().activeConversationId;
331
- !t || Y.length === 0 || (R(t, {
332
- id: He(),
331
+ !t || Y.length === 0 || (z(t, {
332
+ id: Ve(),
333
333
  role: "system",
334
- content: ke(Y, {
335
- intro: O("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
336
- nothing: O("voiceSession.continuedNothing", "Continued from a voice conversation."),
337
- more: (e) => O("voiceSession.continuedMore", "…and {{count}} more", { count: e })
334
+ content: Oe(Y, {
335
+ intro: k("voiceSession.continuedIntro", "Continued from a voice conversation. You asked about:"),
336
+ nothing: k("voiceSession.continuedNothing", "Continued from a voice conversation."),
337
+ more: (e) => k("voiceSession.continuedMore", "…and {{count}} more", { count: e })
338
338
  }),
339
339
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
340
340
  }), bt(!1), Q.end());
341
341
  }, [
342
342
  Y,
343
- R,
344
- O
343
+ z,
344
+ k
345
345
  ]);
346
- T(() => {
347
- !De && Q.active && Q.end();
348
- }, [De, Q]), T(() => {
346
+ E(() => {
347
+ !Ee && Q.active && Q.end();
348
+ }, [Ee, Q]), E(() => {
349
349
  Q.active || Z.current.clear();
350
- }, [Q.active]), T(() => {
350
+ }, [Q.active]), E(() => {
351
351
  let t = e.getState().consumePendingPrompt();
352
- return t && J.current(t), e.subscribe((t, n) => {
352
+ return t && Ot.current(t), e.subscribe((t, n) => {
353
353
  if (t.pendingPrompt && t.pendingPrompt !== n.pendingPrompt) {
354
354
  let t = e.getState().consumePendingPrompt();
355
- t && J.current(t);
355
+ t && Ot.current(t);
356
356
  }
357
357
  });
358
358
  }, []);
359
- let $ = w((t) => {
360
- let n = N ? e.getState().conversations.find((e) => e.id === N) : void 0;
359
+ let $ = T((t) => {
360
+ let n = P ? e.getState().conversations.find((e) => e.id === P) : void 0;
361
361
  if (n && (n.messages.length > 0 || n.backendSessionId)) {
362
362
  if (n.mode !== t) {
363
363
  let n = e.getState().conversations.find((n) => n.mode === t && n.messages.length === 0 && !n.backendSessionId && !e.getState().processingByConversationId[n.id]);
364
- n ? rt(n.id) : L(void 0, t);
364
+ n ? nt(n.id) : R(void 0, t);
365
365
  }
366
- } else N && I(N, t);
367
- F(t);
366
+ } else P && L(P, t);
367
+ I(t);
368
368
  }, [
369
- N,
369
+ P,
370
+ R,
371
+ nt,
370
372
  L,
371
- rt,
372
- I,
373
- F
374
- ]), Nt = w((t) => {
375
- if (le.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
373
+ I
374
+ ]), Nt = T((t) => {
375
+ if (w.find((e) => e.id === t)?.writeCapable && !e.getState().apiCallsAcknowledged) {
376
376
  vt(t);
377
377
  return;
378
378
  }
379
379
  $(t);
380
- }, [$]), Pt = w(() => {
380
+ }, [$]), Pt = T(() => {
381
381
  let e = _t;
382
- vt(null), lt(), e && $(e);
382
+ vt(null), ct(), e && $(e);
383
383
  }, [
384
384
  _t,
385
- lt,
385
+ ct,
386
386
  $
387
- ]), Ft = w(() => {
387
+ ]), Ft = T(() => {
388
388
  vt(null);
389
389
  }, []);
390
- return /* @__PURE__ */ Ie("div", {
390
+ return /* @__PURE__ */ Fe("div", {
391
391
  className: "relative flex flex-1 flex-col overflow-hidden",
392
392
  children: [
393
- /* @__PURE__ */ Ie("div", {
393
+ /* @__PURE__ */ Fe("div", {
394
394
  className: "contents",
395
395
  inert: Q.active || void 0,
396
396
  children: [
397
- Y.length > 0 && !Q.active ? /* @__PURE__ */ k(de, {
397
+ Y.length > 0 && !Q.active ? /* @__PURE__ */ A(le, {
398
398
  count: Y.length,
399
399
  onOpenTranscript: () => bt(!0)
400
400
  }) : null,
401
- At.length === 0 ? /* @__PURE__ */ k(ue, {
402
- mode: P,
401
+ At.length === 0 ? /* @__PURE__ */ A(ce, {
402
+ mode: F,
403
403
  onSuggestionClick: Et
404
- }) : /* @__PURE__ */ k("div", {
404
+ }) : /* @__PURE__ */ A("div", {
405
405
  className: "flex min-h-0 flex-1 flex-col",
406
- children: /* @__PURE__ */ k(S, {
406
+ children: /* @__PURE__ */ A(S, {
407
407
  messages: At,
408
408
  streamingMessageId: dt,
409
409
  failedMessageId: ft,
410
410
  onRetry: Dt
411
411
  })
412
412
  }),
413
- /* @__PURE__ */ k(me, {
414
- onStartVoiceSession: Q.available && P !== "api-calls" ? Q.start : void 0,
413
+ /* @__PURE__ */ A(fe, {
414
+ onStartVoiceSession: Q.available && F !== "api-calls" ? Q.start : void 0,
415
415
  onSend: (e, t) => void q(e, t),
416
416
  disabled: ut,
417
- placeholder: P === "api-calls" ? O("chatArea.placeholderActions", "What would you like me to do?") : O("chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
418
- mode: P,
417
+ placeholder: F === "api-calls" ? k("chatArea.placeholderActions", "What would you like me to do?") : k("chatArea.placeholderGeneral", "Ask HealthyBowl anything…"),
418
+ mode: F,
419
419
  writeAccessDenied: ht === "denied" && !!wt?.writeCapable,
420
420
  availableModes: gt,
421
421
  onModeChange: Nt
422
422
  })
423
423
  ]
424
424
  }),
425
- yt && !Q.active ? /* @__PURE__ */ k(fe, {
425
+ yt && !Q.active ? /* @__PURE__ */ A(ue, {
426
426
  turns: Y,
427
427
  onClose: () => bt(!1),
428
428
  onSave: jt
429
429
  }) : null,
430
- Q.active && /* @__PURE__ */ k(he, {
430
+ Q.active && /* @__PURE__ */ A(pe, {
431
431
  session: Q.session,
432
432
  notice: Q.notice,
433
433
  capturing: Q.capturing,
@@ -448,7 +448,7 @@ var Ke = ({ visible: De = !0 }) => {
448
448
  onToggleMute: Q.toggleMute,
449
449
  onEnd: Q.end
450
450
  }),
451
- /* @__PURE__ */ k(C, {
451
+ /* @__PURE__ */ A(C, {
452
452
  open: _t !== null,
453
453
  onConfirm: Pt,
454
454
  onCancel: Ft
@@ -457,6 +457,6 @@ var Ke = ({ visible: De = !0 }) => {
457
457
  });
458
458
  };
459
459
  //#endregion
460
- export { Ke as AssistantChatArea };
460
+ export { Ge as AssistantChatArea };
461
461
 
462
462
  //# sourceMappingURL=AssistantChatArea.js.map