@burdenoff/microfe-healthybowl 2026.902.25 → 2026.902.27

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