@burdenoff/microfe-healthybowl 2026.902.19 → 2026.902.21

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