@burdenoff/microfe-healthybowl 2026.904.25 → 2026.904.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 (47) hide show
  1. package/dist/components/assistant/AIAssistantPanel.js +23 -62
  2. package/dist/components/assistant/AIAssistantPanel.js.map +1 -1
  3. package/dist/components/assistant/AssistantConversationList.js +1 -2
  4. package/dist/components/assistant/AssistantEmptyState.js +1 -2
  5. package/dist/components/assistant/AssistantHeader.js +1 -2
  6. package/dist/components/assistant/AssistantMessageList.js +1 -2
  7. package/dist/components/assistant/AssistantSpeechProvider.js +1 -2
  8. package/dist/components/assistant/AssistantToolActivity.js +1 -2
  9. package/dist/components/assistant/composer/AssistantComposer.js +1 -2
  10. package/dist/components/assistant/index.js +7 -7
  11. package/dist/healthybowl/components/Modal.js +2 -29
  12. package/dist/services/assistantApi.js +17 -58
  13. package/dist/services/assistantApi.js.map +1 -1
  14. package/dist/utils/pageContext.js.map +1 -1
  15. package/package.json +2 -2
  16. package/dist/components/assistant/AssistantApiCallsConsentDialog.js +0 -33
  17. package/dist/components/assistant/AssistantApiCallsConsentDialog.js.map +0 -1
  18. package/dist/components/assistant/AssistantChatArea.js +0 -453
  19. package/dist/components/assistant/AssistantChatArea.js.map +0 -1
  20. package/dist/components/assistant/AssistantSpokenTurnsNotice.js +0 -2
  21. package/dist/components/assistant/voice/AssistantVoiceSession.js +0 -2
  22. package/dist/components/assistant/voice/VoiceTranscriptDrawer.js +0 -2
  23. package/dist/config/assistantLanguagePair.js +0 -2
  24. package/dist/config/assistantLanguages.js +0 -2
  25. package/dist/healthybowl/components/Modal.js.map +0 -1
  26. package/dist/hooks/useAssistantApiAccess.js +0 -2
  27. package/dist/hooks/useAssistantAttachments.js +0 -2
  28. package/dist/hooks/useAssistantHeartbeat.js +0 -40
  29. package/dist/hooks/useAssistantHeartbeat.js.map +0 -1
  30. package/dist/hooks/useAssistantKeyboardShortcuts.js +0 -37
  31. package/dist/hooks/useAssistantKeyboardShortcuts.js.map +0 -1
  32. package/dist/hooks/useConversationTurns.js +0 -2
  33. package/dist/hooks/useVoiceSession.js +0 -2
  34. package/dist/services/assistantExportService.js +0 -2
  35. package/dist/utils/aiCredits.js +0 -13
  36. package/dist/utils/aiCredits.js.map +0 -1
  37. package/dist/utils/assistantAttachments.js +0 -2
  38. package/dist/utils/assistantContext.js +0 -2
  39. package/dist/utils/assistantPollSchedule.js +0 -2
  40. package/dist/utils/assistantTransportErrors.js +0 -2
  41. package/dist/utils/assistantTurnState.js +0 -2
  42. package/dist/utils/captionText.js +0 -2
  43. package/dist/utils/pendingWrite.js +0 -2
  44. package/dist/utils/quotaUtils.js +0 -2
  45. package/dist/utils/sandboxReadiness.js +0 -2
  46. package/dist/utils/voiceTranscript.js +0 -2
  47. package/dist/utils/voiceTurnVisibility.js +0 -2
@@ -1,68 +1,29 @@
1
- import { useAssistantStore as e } from "../../store/assistantStore.js";
2
- import { useAssistantKeyboardShortcuts as t } from "../../hooks/useAssistantKeyboardShortcuts.js";
3
- import { PRODUCT as n } from "../../services/assistantApi.js";
4
- import { useAssistantHeartbeat as r } from "../../hooks/useAssistantHeartbeat.js";
5
- import { describeCurrentPage as i } from "../../utils/pageContext.js";
6
- import { AssistantHeader as a } from "./AssistantHeader.js";
7
- import { ASSISTANT_MODES as o } from "../../types/assistant.js";
8
- import { AssistantChatArea as s } from "./AssistantChatArea.js";
9
- import { AssistantConversationList as c } from "./AssistantConversationList.js";
10
- import { AssistantSpeechProvider as l } from "./AssistantSpeechProvider.js";
11
- import { useEffect as u, useRef as d, useState as f } from "react";
12
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
13
- import { useFilesServiceWarmup as h } from "@burdenoff/fe-libs/storage";
14
- import { useAssistantTr as g } from "@burdenoff/fe-libs/shared/assistant/i18n";
15
- import { AssistantProductProvider as _ } from "@burdenoff/fe-libs/shared/assistant/product";
1
+ import { ASSISTANT_MODES as e } from "../../types/assistant.js";
2
+ import { PRODUCT as t, reportAssistantAiTokenUsage as n } from "../../services/assistantApi.js";
3
+ import { useWorkspaceWriteAccess as r } from "../../hooks/useWorkspaceWriteAccess.js";
4
+ import { describeCurrentPage as i, gatherPageContext as a } from "../../utils/pageContext.js";
5
+ import { buildPromptForMode as o } from "../../utils/assistantPrompt.js";
6
+ import { jsx as s } from "react/jsx-runtime";
7
+ import { AIAssistantPanel as c } from "@burdenoff/fe-libs/shared/assistant/ui/AIAssistantPanel";
8
+ import { AssistantProductProvider as l } from "@burdenoff/fe-libs/shared/assistant/product";
9
+ import { getActorId as u, getWorkspaceId as d } from "@burdenoff/fe-libs/shared/assistant/context";
16
10
  //#region src/components/assistant/AIAssistantPanel.tsx
17
- var v = 1e3, y = ({ onClose: n, visible: o, docked: _, onToggleDock: y }) => {
18
- let b = g(), x = d(null), { conversations: S, activeConversationId: C, conversationListOpen: w, toggleConversationList: T, createConversation: E } = e(), D = S.find((e) => e.id === C);
19
- r(D?.backendSessionId ?? null, D?.mode ?? null, o ?? !0), h(o ?? !0);
20
- let [O, k] = f(i);
21
- return u(() => {
22
- if (o === !1) return;
23
- let e = () => k((e) => {
24
- let t = i();
25
- return t === e ? e : t;
26
- });
27
- e(), window.addEventListener("popstate", e);
28
- let t = window.setInterval(e, v);
29
- return () => {
30
- window.removeEventListener("popstate", e), window.clearInterval(t);
31
- };
32
- }, [o]), t({
33
- panelRef: x,
34
- onClose: n
35
- }), /* @__PURE__ */ p(l, {
36
- visible: o ?? !0,
37
- children: /* @__PURE__ */ m("div", {
38
- ref: x,
39
- className: "relative flex h-full w-full flex-col bg-bg-surface",
40
- role: "complementary",
41
- "aria-label": b("panel.ariaLabel", "AI Assistant"),
42
- "data-testid": "ai-assistant-panel",
43
- tabIndex: -1,
44
- children: [
45
- /* @__PURE__ */ p(a, {
46
- contextLabel: O,
47
- onNewConversation: () => E(),
48
- onOpenHistory: T,
49
- historyOpen: w,
50
- onClose: n,
51
- docked: _,
52
- onToggleDock: y
53
- }),
54
- w && /* @__PURE__ */ p(c, {}),
55
- /* @__PURE__ */ p(s, { visible: o ?? !0 })
56
- ]
11
+ var f = (f) => {
12
+ let p = r(u(), d() || null);
13
+ return /* @__PURE__ */ s(l, {
14
+ product: t,
15
+ modes: e,
16
+ describeCurrentPage: i,
17
+ gatherPageContext: a,
18
+ buildPrompt: o,
19
+ reportTokenUsage: n,
20
+ children: /* @__PURE__ */ s(c, {
21
+ ...f,
22
+ writeAccess: p
57
23
  })
58
24
  });
59
- }, b = (e) => /* @__PURE__ */ p(_, {
60
- product: n,
61
- modes: o,
62
- describeCurrentPage: i,
63
- children: /* @__PURE__ */ p(y, { ...e })
64
- });
25
+ };
65
26
  //#endregion
66
- export { b as AIAssistantPanel };
27
+ export { f as AIAssistantPanel };
67
28
 
68
29
  //# sourceMappingURL=AIAssistantPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AIAssistantPanel.js","names":[],"sources":["../../../src/components/assistant/AIAssistantPanel.tsx"],"sourcesContent":["/**\n * AI Assistant Panel — top-level component for the in-page assistant.\n *\n * Layout (v2): a fixed identity header (AssistantHeader) with the brand mark,\n * an availability/context subtitle and icon actions (new conversation, history,\n * export, dock, close), an always-visible transcript, and the composer pinned\n * to the bottom. Conversation history opens as an overlay drawer over the panel\n * — never as an accordion over the transcript.\n *\n * The external prop contract ({ onClose, visible, docked, onToggleDock }) is\n * unchanged; the sandbox/session/transport logic lives in AssistantChatArea.\n */\n\nimport { useEffect, useRef, useState, type FC } from 'react';\nimport type { PanelProps } from '@burdenoff/fe-libs/shared/plugins';\nimport { useFilesServiceWarmup } from '@burdenoff/fe-libs/storage';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useAssistantKeyboardShortcuts } from '@/hooks/useAssistantKeyboardShortcuts';\nimport { useAssistantHeartbeat } from '@/hooks/useAssistantHeartbeat';\nimport { describeCurrentPage } from '@/utils/pageContext';\n\n/**\n * How often the header re-reads the current page while the panel is open.\n *\n * Fast enough that the label is right by the time a user looks at it after\n * navigating, slow enough to be free: one `window.location` read and a string\n * compare, and no render unless the page actually changed.\n */\nconst PAGE_LABEL_POLL_MS = 1_000;\nimport { AssistantHeader } from './AssistantHeader';\nimport { AssistantChatArea } from './AssistantChatArea';\nimport { AssistantConversationList } from './AssistantConversationList';\nimport { AssistantSpeechProvider } from './AssistantSpeechProvider';\nimport { useAssistantTr } from '@burdenoff/fe-libs/shared/assistant/i18n';\nimport { AssistantProductProvider } from '@burdenoff/fe-libs/shared/assistant/product';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { PRODUCT } from '@/services/assistantApi';\n\nexport type AIAssistantPanelProps = PanelProps & {\n /** When provided, renders a dock/float toggle in the header. */\n docked?: boolean;\n onToggleDock?: () => void;\n};\n\nconst AIAssistantPanelInner: FC<AIAssistantPanelProps> = ({ onClose, visible, docked, onToggleDock }) => {\n const tr = useAssistantTr();\n const panelRef = useRef<HTMLDivElement>(null);\n\n const { conversations, activeConversationId, conversationListOpen, toggleConversationList, createConversation } =\n useAssistantStore();\n\n const activeConversation = conversations.find((c) => c.id === activeConversationId);\n const activeSessionId = activeConversation?.backendSessionId ?? null;\n\n // Keep sandbox alive while panel is open\n useAssistantHeartbeat(activeSessionId, activeConversation?.mode ?? null, visible ?? true);\n\n // Wake wspace-files-svc the moment the panel opens. It runs at minReplicas 0 and\n // needs >=51s to bind its port (prisma migrate deploy 26.0s + boot ~25.5s) against\n // the gateway's 15s budget, so the first attachment after any quiet period would\n // otherwise fail outright. Firing here means the container boots while the user is\n // still typing. Best-effort by construction: single-flighted, rate-limited, and it\n // never surfaces an error — see fe-libs `warmFilesService`.\n useFilesServiceWarmup(visible ?? true);\n\n /**\n * Which page the user is on — LIVE, not as it was when the panel first opened.\n *\n * ★ This was `useMemo(() => describeCurrentPage(), [])`. An empty dependency\n * array on a function that reads `window.location` freezes it at first mount,\n * so the header kept naming the page the user opened the assistant from while\n * they navigated the whole app. The label is the one thing on screen that\n * claims the assistant knows where they are, and it was the one thing that\n * stopped being true the moment they moved.\n *\n * (The context actually SENT to the model was always fresh — `gatherPageContext`\n * runs per turn. Only the visible promise was stale, which is the worse half:\n * the user could not tell.)\n *\n * ★ Not `useLocation()`. This panel is exported for a HOST app to mount, and a\n * consumer that mounts it outside a Router would get a thrown hook rather than\n * a stale label — a much worse failure for a caption. Polling `window.location`\n * is router-agnostic and works for pushState navigation, which `popstate`\n * alone misses entirely (it fires only on back/forward).\n *\n * Cheap by construction: only while the panel is visible, and the state is set\n * only when the string actually changes, so an unchanged page costs one string\n * comparison per tick and no render.\n */\n const [contextLabel, setContextLabel] = useState(describeCurrentPage);\n\n useEffect(() => {\n if (visible === false) return;\n const sync = () =>\n setContextLabel((current) => {\n const next = describeCurrentPage();\n return next === current ? current : next;\n });\n sync();\n window.addEventListener('popstate', sync);\n const timer = window.setInterval(sync, PAGE_LABEL_POLL_MS);\n return () => {\n window.removeEventListener('popstate', sync);\n window.clearInterval(timer);\n };\n }, [visible]);\n\n useAssistantKeyboardShortcuts({\n panelRef,\n onClose,\n });\n\n return (\n // Speech output (BOFF-6290) is provided at the panel root so that hiding the\n // panel — not only unmounting it — stops the voice, and so the header toggle\n // and every message's speak button share one playback state.\n <AssistantSpeechProvider visible={visible ?? true}>\n <div\n ref={panelRef}\n className=\"relative flex h-full w-full flex-col bg-bg-surface\"\n role=\"complementary\"\n aria-label={tr('panel.ariaLabel', 'AI Assistant')}\n data-testid=\"ai-assistant-panel\"\n tabIndex={-1}\n >\n <AssistantHeader\n contextLabel={contextLabel}\n onNewConversation={() => createConversation()}\n onOpenHistory={toggleConversationList}\n historyOpen={conversationListOpen}\n onClose={onClose}\n docked={docked}\n onToggleDock={onToggleDock}\n />\n\n {/* Conversation history overlay drawer (switch between chats) */}\n {conversationListOpen && <AssistantConversationList />}\n\n <AssistantChatArea visible={visible ?? true} />\n </div>\n </AssistantSpeechProvider>\n );\n};\n\n/**\n * The panel, with its translation namespace supplied.\n *\n * ★ The provider has to wrap from OUTSIDE rather than sit inside the returned\n * tree: the panel calls `useAssistantTr()` in its own body, so a provider nested\n * in its JSX would be below the consumer and the namespace would read as null —\n * which does not throw, it just renders English. Every string would silently\n * stop being translated while every test still passed.\n *\n * The namespace is the SAME constant the transport uses for\n * `AI_ASSISTANT_PRODUCT`, so \"which product is this?\" has exactly one answer.\n */\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = (props) => (\n <AssistantProductProvider product={PRODUCT} modes={ASSISTANT_MODES} describeCurrentPage={describeCurrentPage}>\n <AIAssistantPanelInner {...props} />\n </AssistantProductProvider>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,IAAM,IAAqB,KAgBrB,KAAoD,EAAE,YAAS,YAAS,WAAQ,sBAAmB;CACvG,IAAM,IAAK,EAAe,GACpB,IAAW,EAAuB,IAAI,GAEtC,EAAE,kBAAe,yBAAsB,yBAAsB,2BAAwB,0BACzF,EAAkB,GAEd,IAAqB,EAAc,MAAM,MAAM,EAAE,OAAO,CAAoB;CAYlF,AARA,EAHwB,GAAoB,oBAAoB,MAGzB,GAAoB,QAAQ,MAAM,KAAW,EAAI,GAQxF,EAAsB,KAAW,EAAI;CA0BrC,IAAM,CAAC,GAAc,KAAmB,EAAS,CAAmB;CAuBpE,OArBA,QAAgB;EACd,IAAI,MAAY,IAAO;EACvB,IAAM,UACJ,GAAiB,MAAY;GAC3B,IAAM,IAAO,EAAoB;GACjC,OAAO,MAAS,IAAU,IAAU;EACtC,CAAC;EAEH,AADA,EAAK,GACL,OAAO,iBAAiB,YAAY,CAAI;EACxC,IAAM,IAAQ,OAAO,YAAY,GAAM,CAAkB;EACzD,aAAa;GAEX,AADA,OAAO,oBAAoB,YAAY,CAAI,GAC3C,OAAO,cAAc,CAAK;EAC5B;CACF,GAAG,CAAC,CAAO,CAAC,GAEZ,EAA8B;EAC5B;EACA;CACF,CAAC,GAMC,kBAAC,GAAD;EAAyB,SAAS,KAAW;YAC3C,kBAAC,OAAD;GACE,KAAK;GACL,WAAU;GACV,MAAK;GACL,cAAY,EAAG,mBAAmB,cAAc;GAChD,eAAY;GACZ,UAAU;aANZ;IAQE,kBAAC,GAAD;KACgB;KACd,yBAAyB,EAAmB;KAC5C,eAAe;KACf,aAAa;KACJ;KACD;KACM;IACf,CAAA;IAGA,KAAwB,kBAAC,GAAD,CAA4B,CAAA;IAErD,kBAAC,GAAD,EAAmB,SAAS,KAAW,GAAO,CAAA;GAC3C;;CACkB,CAAA;AAE7B,GAca,KAA+C,MAC1D,kBAAC,GAAD;CAA0B,SAAS;CAAS,OAAO;CAAsC;WACvF,kBAAC,GAAD,EAAuB,GAAI,EAAQ,CAAA;AACX,CAAA"}
1
+ {"version":3,"file":"AIAssistantPanel.js","names":[],"sources":["../../../src/components/assistant/AIAssistantPanel.tsx"],"sourcesContent":["/**\n * HealthyBowl's AI assistant.\n *\n * ★★ Everything below this file is now shared. The panel, the orchestrator, the\n * transport, the voice session, the composer and every component in them live in\n * `fe-libs/shared/assistant` and answer to any product that mounts them. What is\n * left here is the four things that are genuinely HealthyBowl's, and nothing\n * else:\n *\n * modes which use cases this product offers.\n * describeCurrentPage what to CALL the page the user is on.\n * gatherPageContext the same page, as structured context for the agent.\n * buildPrompt the system preamble — that this is an agronomy\n * assistant, what it may do, and in which language.\n * reportTokenUsage the charge, against HealthyBowl's OWN mutation.\n *\n * Plus `writeAccess`, which is a PROP rather than a fifth seam field: which\n * resource types prove \"this user can write here\" is a product answer, but the\n * product can simply compute it and hand it down. A capability a product can\n * work out for itself does not belong in an interface every product must\n * satisfy.\n *\n * ★ The provider wraps from OUTSIDE the shared panel rather than sitting inside\n * its tree: the panel calls `useAssistantProduct()` and `useAssistantTr()` in its\n * own body, so a provider nested in its JSX would be below the consumer and read\n * as null — which does not throw, it silently renders English with no modes.\n */\n\nimport type { FC } from 'react';\nimport {\n AIAssistantPanel as SharedAIAssistantPanel,\n type AIAssistantPanelProps as SharedProps,\n} from '@burdenoff/fe-libs/shared/assistant/ui/AIAssistantPanel';\nimport { AssistantProductProvider } from '@burdenoff/fe-libs/shared/assistant/product';\nimport { getActorId, getWorkspaceId } from '@burdenoff/fe-libs/shared/assistant/context';\nimport { ASSISTANT_MODES } from '@/types/assistant';\nimport { PRODUCT, reportAssistantAiTokenUsage } from '@/services/assistantApi';\nimport { useWorkspaceWriteAccess } from '@/hooks/useWorkspaceWriteAccess';\nimport { describeCurrentPage, gatherPageContext } from '@/utils/pageContext';\nimport { buildPromptForMode } from '@/utils/assistantPrompt';\n\nexport type AIAssistantPanelProps = Omit<SharedProps, 'writeAccess'>;\n\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = (props) => {\n /**\n * ★ Advisory, never a gate — see `useWorkspaceWriteAccess`. Measured against\n * prod on 2026-09-02, workspace scopes have no roles provisioned at all, so\n * gating on this would delete Take-action from the product until an ops task\n * lands. It warns before the effort instead of after it, and self-corrects\n * with no code change the moment roles exist.\n */\n const writeAccess = useWorkspaceWriteAccess(getActorId(), getWorkspaceId() || null);\n\n return (\n <AssistantProductProvider\n product={PRODUCT}\n modes={ASSISTANT_MODES}\n describeCurrentPage={describeCurrentPage}\n gatherPageContext={gatherPageContext}\n buildPrompt={buildPromptForMode}\n reportTokenUsage={reportAssistantAiTokenUsage}\n >\n <SharedAIAssistantPanel {...props} writeAccess={writeAccess} />\n </AssistantProductProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AA2CA,IAAa,KAA+C,MAAU;CAQpE,IAAM,IAAc,EAAwB,EAAW,GAAG,EAAe,KAAK,IAAI;CAElF,OACE,kBAAC,GAAD;EACE,SAAS;EACT,OAAO;EACc;EACF;EACnB,aAAa;EACb,kBAAkB;YAElB,kBAAC,GAAD;GAAwB,GAAI;GAAoB;EAAc,CAAA;CACtC,CAAA;AAE9B"}
@@ -1,2 +1 @@
1
- import { AssistantConversationList as e } from "@burdenoff/fe-libs/shared/assistant/ui/AssistantConversationList";
2
- export { e as AssistantConversationList };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantConversationList";
@@ -1,2 +1 @@
1
- import { AssistantEmptyState as e } from "@burdenoff/fe-libs/shared/assistant/ui/AssistantEmptyState";
2
- export { e as AssistantEmptyState };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantEmptyState";
@@ -1,2 +1 @@
1
- import { AssistantHeader as e } from "@burdenoff/fe-libs/shared/assistant/ui/AssistantHeader";
2
- export { e as AssistantHeader };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantHeader";
@@ -1,2 +1 @@
1
- import { AssistantMessageList as e } from "@burdenoff/fe-libs/shared/assistant/ui/AssistantMessageList";
2
- export { e as AssistantMessageList };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantMessageList";
@@ -1,2 +1 @@
1
- import { AssistantSpeechProvider as e } from "@burdenoff/fe-libs/shared/assistant/ui/AssistantSpeechProvider";
2
- export { e as AssistantSpeechProvider };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantSpeechProvider";
@@ -1,2 +1 @@
1
- import { parseToolActivity as e } from "@burdenoff/fe-libs/shared/assistant/ui/AssistantToolActivity";
2
- export { e as parseToolActivity };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantToolActivity";
@@ -1,2 +1 @@
1
- import { AssistantComposer as e } from "@burdenoff/fe-libs/shared/assistant/ui/composer/AssistantComposer";
2
- export { e as AssistantComposer };
1
+ import "@burdenoff/fe-libs/shared/assistant/ui/composer/AssistantComposer";
@@ -1,19 +1,19 @@
1
+ import "./AIAssistantPanel.js";
1
2
  import "./AssistantHeader.js";
2
- import "./AssistantMessageList.js";
3
- import "./AssistantEmptyState.js";
4
- import "./composer/AssistantComposer.js";
5
- import "./AssistantToolActivity.js";
6
- import "./AssistantChatArea.js";
7
3
  import "./AssistantConversationList.js";
8
- import "./AssistantSpeechProvider.js";
9
- import "./AIAssistantPanel.js";
4
+ import "./AssistantEmptyState.js";
10
5
  import "./AssistantMoreMenu.js";
11
6
  import "./AssistantMarkdownRenderer.js";
12
7
  import "./AssistantMessageAttachments.js";
13
8
  import "./AssistantMessageItem.js";
9
+ import "./AssistantMessageList.js";
14
10
  import "./AssistantSpeakButton.js";
15
11
  import "./AssistantAutoSpeakToggle.js";
12
+ import "./AssistantSpeechProvider.js";
13
+ import "./AssistantToolActivity.js";
16
14
  import "./composer/AssistantAttachmentButton.js";
17
15
  import "./composer/AssistantAttachmentChips.js";
16
+ import "./composer/AssistantComposer.js";
18
17
  import "./composer/AssistantModeSelector.js";
19
18
  import "./composer/AssistantVoiceButton.js";
19
+ import "@burdenoff/fe-libs/shared/assistant/ui/AssistantChatArea";
@@ -1,29 +1,2 @@
1
- import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
- import { ResponsiveDialog as n, ResponsiveDialogContent as r, ResponsiveDialogDescription as i, ResponsiveDialogFooter as a, ResponsiveDialogHeader as o, ResponsiveDialogTitle as s } from "@burdenoff/fe-libs/ui";
3
- //#region src/healthybowl/components/Modal.tsx
4
- var c = {
5
- sm: "sm:max-w-sm",
6
- md: "sm:max-w-lg",
7
- lg: "sm:max-w-2xl",
8
- xl: "sm:max-w-3xl"
9
- }, l = ({ open: l, onClose: u, title: d, description: f, children: p, size: m = "md", footer: h }) => /* @__PURE__ */ e(n, {
10
- open: l,
11
- onOpenChange: (e) => {
12
- e || u();
13
- },
14
- children: /* @__PURE__ */ t(r, {
15
- className: c[m],
16
- children: [
17
- /* @__PURE__ */ t(o, { children: [d && /* @__PURE__ */ e(s, { children: d }), f && /* @__PURE__ */ e(i, { children: f })] }),
18
- /* @__PURE__ */ e("div", {
19
- className: "max-h-[60dvh] overflow-y-auto overscroll-contain pr-1",
20
- children: p
21
- }),
22
- h && /* @__PURE__ */ e(a, { children: h })
23
- ]
24
- })
25
- });
26
- //#endregion
27
- export { l as Modal };
28
-
29
- //# sourceMappingURL=Modal.js.map
1
+ import { ModalShell as e } from "@burdenoff/fe-libs/ui";
2
+ export { e as Modal };
@@ -1,79 +1,38 @@
1
1
  import { graphqlFetch as e } from "@burdenoff/fe-libs/shared/graphql";
2
- import { createAssistantSandbox as t, createAssistantSession as n, extendAssistantSandboxTTL as r, findExistingSandbox as i, getAssistantArtifacts as a, getAssistantMessages as o, getAssistantSession as s, sendAssistantPromptAsync as c, sendHeartbeat as l, waitForAssistantServiceReady as u, waitForSandboxRunning as d } from "@burdenoff/fe-libs/shared/assistant";
3
2
  //#region src/services/assistantApi.ts
4
- var f = "healthybowl", p = 600;
5
- function m() {
6
- return !1;
7
- }
8
- var h = (e) => e ?? {};
9
- function g(e, t, n, r) {
10
- return i(t, n, m(), h(r));
11
- }
12
- function _(e, n, r, i) {
13
- return t(f, n, r, m(), p, h(i));
14
- }
15
- function v(e, t, n, r, i = 3e5, a) {
16
- return d(t, n, h(r), i);
17
- }
18
- function y(e, t, n, r, i = 9e4, a) {
19
- return u(t, n, h(r), i);
20
- }
21
- function b(e, t, r, i, a) {
22
- return n(t, r, i, h(a));
23
- }
24
- function x(e, t, n, r, i) {
25
- return s(t, n, r, h(i));
26
- }
27
- function S(e, t, n, r, i, a, o, s, l) {
28
- return c(t, n, r, i, a, o, h(s), l?.length ? { parts: l } : void 0).then(() => void 0);
29
- }
30
- function C(e, t, n, r, i, a = 50, s) {
31
- return o(t, n, r, h(i), {
32
- limit: a,
33
- sinceMs: s
34
- });
35
- }
36
- var w = "mutation ReportHealthyBowlAiTokenUsage($input: ReportHealthyBowlAiTokenUsageInput!) {\n reportHealthyBowlAiTokenUsage(input: $input)\n}";
37
- async function T(t, n, r, i, a, o, s) {
38
- if (!i || !a) {
3
+ var t = "healthybowl", n = "mutation ReportHealthyBowlAiTokenUsage($input: ReportHealthyBowlAiTokenUsageInput!) {\n reportHealthyBowlAiTokenUsage(input: $input)\n}";
4
+ async function r(t) {
5
+ let { workspaceId: r, sessionId: i, messageId: a, model: o, tokens: s } = t;
6
+ if (!a || !o) {
39
7
  console.warn("[assistant] skipping AI-credit charge — turn is missing messageId or model", {
40
- sessionId: r,
41
- hasMessageId: !!i,
42
- hasModel: !!a
8
+ sessionId: i,
9
+ hasMessageId: !!a,
10
+ hasModel: !!o
43
11
  });
44
12
  return;
45
13
  }
46
14
  try {
47
15
  await e({
48
16
  gateway: "workspace",
49
- query: w,
17
+ query: n,
50
18
  variables: { input: {
51
- context: { workspaceId: n },
52
- sessionId: r,
53
- messageId: i,
54
- model: a,
55
- inputTokens: o.input,
56
- outputTokens: o.output
19
+ context: { workspaceId: r },
20
+ sessionId: i,
21
+ messageId: a,
22
+ model: o,
23
+ inputTokens: s.input,
24
+ outputTokens: s.output
57
25
  } }
58
26
  });
59
27
  } catch (e) {
60
28
  console.warn("[assistant] AI-credit charge failed (non-fatal)", {
61
- sessionId: r,
62
- messageId: i,
29
+ sessionId: i,
30
+ messageId: a,
63
31
  error: e instanceof Error ? e.message : String(e)
64
32
  });
65
33
  }
66
34
  }
67
- function E(e, t, n, r, i) {
68
- return a(t, n, r, h(i)).then((e) => e);
69
- }
70
- function D(e, t, n, r, i) {
71
- return l(t, n, r, h(i));
72
- }
73
- function O(e, t, n, i = 600, a) {
74
- return r(t, n, i, h(a));
75
- }
76
35
  //#endregion
77
- export { f as PRODUCT, _ as createAssistantSandbox, b as createAssistantSession, O as extendAssistantSandboxTTL, g as findExistingSandbox, E as getAssistantArtifacts, C as getAssistantMessages, x as getAssistantSession, T as reportAssistantAiTokenUsage, S as sendAssistantPromptAsync, D as sendHeartbeat, y as waitForAssistantServiceReady, v as waitForSandboxReady };
36
+ export { t as PRODUCT, r as reportAssistantAiTokenUsage };
78
37
 
79
38
  //# sourceMappingURL=assistantApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"assistantApi.js","names":[],"sources":["../../src/services/assistantApi.ts"],"sourcesContent":["/**\n * AI Assistant API — thin adapter over @burdenoff/fe-libs/shared/assistant.\n *\n * The legacy slide-in panel (AssistantChatArea / AssistantMessageItem /\n * useAssistantHeartbeat) calls these with the historical (apollo-first)\n * signatures. The real implementation now lives once in fe-libs; this file only\n * maps the old signatures onto it, retiring ~726 lines of duplicated logic. The\n * `apollo` argument is vestigial (the shared layer uses graphqlFetch) and is\n * ignored; the product id + prod-runtime + TTL the shared functions need are\n * supplied here.\n *\n * HealthyBowl-specific AI credits (BOFF-7126): the shared `checkAiCredits` /\n * `reportAiTokenUsage` mutations live in the VibeControls subgraph and hardcode\n * `vibecontrols.ai.credits` + `productId: 'vibecontrols'`, so delegating to them\n * would bill VibeControls for HealthyBowl chat. Both therefore stay off the shared\n * path — but they now differ from each other:\n *\n * · `reportAssistantAiTokenUsage` CHARGES, against HealthyBowl's own\n * `reportHealthyBowlAiTokenUsage` mutation. Until this landed the assistant\n * was the only genuinely uncapped model spend in the product, and that failure\n * mode has already cost ~11 days of silent fleet-wide outage (BOFF-6284, a\n * vendor account with no credits left).\n * · `checkAssistantAiCredits` REMAINS a no-op, deliberately. Credits price at\n * roughly one credit per input token while the Free tier is seeded at 500, so\n * one assistant turn is many times the whole monthly budget. Gating on that\n * today would block every turn after the first. Meter first; re-size the\n * limits against real usage; only then add a gate.\n *\n * Also HealthyBowl-specific: `sendAssistantPromptAsync` takes an optional\n * multimodal `parts` array (Workstream 4) and forwards it to the shared\n * transport, which carries it in the JSON-scalar proxy body alongside the\n * unchanged `prompt`.\n */\n\nimport {\n findExistingSandbox as sharedFindExisting,\n createAssistantSandbox as sharedCreate,\n waitForSandboxRunning as sharedWaitRunning,\n waitForAssistantServiceReady as sharedWaitService,\n createAssistantSession as sharedCreateSession,\n getAssistantSession as sharedGetSession,\n sendAssistantPromptAsync as sharedSendAsync,\n getAssistantMessages as sharedGetMessages,\n extendAssistantSandboxTTL as sharedExtendTtl,\n sendHeartbeat as sharedHeartbeat,\n getAssistantArtifacts as sharedGetArtifacts,\n downloadAssistantArtifact as sharedDownloadArtifact,\n} from '@burdenoff/fe-libs/shared/assistant';\nimport type {\n AssistantRawMessage as SharedRawMessage,\n AssistantSandboxAuthContext as SharedAuthContext,\n AssistantSessionInfo as SharedSessionInfo,\n DownloadedAssistantArtifact,\n} from '@burdenoff/fe-libs/shared/assistant';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport type { AssistantArtifact as LocalAssistantArtifact, AssistantMode } from '@/types/assistant';\nimport type { AssistantPromptPart } from '@/utils/assistantAttachments';\nimport type { PageContext } from '@/utils/pageContext';\n\n// Re-export the shared types under the names the panel already imports.\nexport type AssistantRawMessage = SharedRawMessage;\nexport type AssistantSandboxAuthContext = SharedAuthContext;\nexport type AssistantSessionInfo = SharedSessionInfo;\n\n// Vestigial Apollo arg — accepted for signature compatibility, ignored.\ntype ApolloClientLike = unknown;\n\n/**\n * Which product this assistant belongs to.\n *\n * ★ Exported because it now answers TWO questions that must never disagree:\n * `AI_ASSISTANT_PRODUCT` for the sandbox (which docs corpus the agent reads) and\n * the translation namespace for the shared assistant UI (`healthybowl.assistant.*`).\n * Two separate literals would drift, and the i18n half would fail silently —\n * every string quietly falling back to English while the tests stayed green.\n */\nexport const PRODUCT = 'healthybowl';\n// Matches the original panel behavior: create at 600s, kept warm while open by\n// useAssistantHeartbeat's +600s extend.\nconst DEFAULT_TTL_SECONDS = 600;\n\n// Build-time env parity with the original `assistantApi.ts` image-tag selection\n// (VITE_APP_ENV === 'prod' → prod image tag). Drives getImageTagForMode.\nfunction isProdRuntime(): boolean {\n return import.meta.env.VITE_APP_ENV === 'prod';\n}\n\nconst ctx = (a?: SharedAuthContext): SharedAuthContext => a ?? {};\n\nexport function findExistingSandbox(\n _apollo: ApolloClientLike,\n workspaceId: string,\n mode: AssistantMode,\n authContext?: SharedAuthContext\n): Promise<string | null> {\n return sharedFindExisting(workspaceId, mode, isProdRuntime(), ctx(authContext));\n}\n\nexport function createAssistantSandbox(\n _apollo: ApolloClientLike,\n mode: AssistantMode,\n workspaceId: string,\n authContext?: SharedAuthContext\n): Promise<string> {\n return sharedCreate(PRODUCT, mode, workspaceId, isProdRuntime(), DEFAULT_TTL_SECONDS, ctx(authContext));\n}\n\nexport function waitForSandboxReady(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n authContext?: SharedAuthContext,\n maxWaitMs = 300_000,\n _onProgress?: (message: string) => void\n): Promise<void> {\n return sharedWaitRunning(sandboxId, workspaceId, ctx(authContext), maxWaitMs);\n}\n\nexport function waitForAssistantServiceReady(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n authContext?: SharedAuthContext,\n maxWaitMs = 90_000,\n _onProgress?: (message: string) => void\n): Promise<void> {\n return sharedWaitService(sandboxId, workspaceId, ctx(authContext), maxWaitMs);\n}\n\nexport function createAssistantSession(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n mode: AssistantMode,\n authContext?: SharedAuthContext\n): Promise<{ sessionId: string }> {\n return sharedCreateSession(sandboxId, workspaceId, mode, ctx(authContext));\n}\n\nexport function getAssistantSession(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n sessionId: string,\n authContext?: SharedAuthContext\n): Promise<SharedSessionInfo> {\n return sharedGetSession(sandboxId, workspaceId, sessionId, ctx(authContext));\n}\n\nexport function sendAssistantPromptAsync(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n sessionId: string,\n prompt: string,\n mode: AssistantMode,\n pageContext?: PageContext,\n authContext?: SharedAuthContext,\n /**\n * Optional multimodal turn (Workstream 4). `prompt` is still ALWAYS sent, so a\n * bridge that predates `parts` answers from the text exactly as before, and a\n * text-only turn produces a byte-identical body.\n *\n * The local `AssistantPromptPart` is a structural mirror of the fe-libs type\n * (kept local so the pure attachment utils need no transport import); passing\n * it here is what proves the two stay in step at compile time.\n */\n parts?: AssistantPromptPart[]\n): Promise<void> {\n return sharedSendAsync(\n sandboxId,\n workspaceId,\n sessionId,\n prompt,\n mode,\n pageContext as Record<string, unknown> | undefined,\n ctx(authContext),\n parts?.length ? { parts } : undefined\n ).then(() => undefined);\n}\n\n/**\n * Messages for a session.\n *\n * ★ `sinceMs` is a DELTA cursor: the agent returns only messages created at or\n * after it (`>=`, deliberately, so an in-progress reply whose parts are still\n * growing keeps coming back). Without it every poll re-downloaded all `limit`\n * messages plus the injected page context — up to twice a second, for the whole\n * length of a turn. `assistantPollSchedule.ts` names this as the fix.\n *\n * Pass it ONLY for polling within a turn. The pre-prompt call that establishes\n * the floor must stay a full fetch, or there is nothing to compute a floor from.\n *\n * Degrades on its own: the shared client drops `&since=` if the backend reports\n * the capability unsupported, and `0` is falsy on both sides — so a brand-new\n * session with no prior messages naturally asks for everything.\n */\nexport function getAssistantMessages(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n sessionId: string,\n authContext?: SharedAuthContext,\n limit = 50,\n sinceMs?: number\n): Promise<SharedRawMessage[]> {\n return sharedGetMessages(sandboxId, workspaceId, sessionId, ctx(authContext), { limit, sinceMs });\n}\n\n/**\n * Deliberate no-op for HealthyBowl (see file header): always report budget\n * available; never gate an HB chat on VibeControls' credit quota.\n */\nexport function checkAssistantAiCredits(\n _apollo: ApolloClientLike,\n _workspaceId: string,\n _authContext?: SharedAuthContext\n): Promise<boolean> {\n return Promise.resolve(true);\n}\n\nconst REPORT_HB_AI_TOKEN_USAGE = `mutation ReportHealthyBowlAiTokenUsage($input: ReportHealthyBowlAiTokenUsageInput!) {\n reportHealthyBowlAiTokenUsage(input: $input)\n}`;\n\n/**\n * Charge a completed assistant turn against `healthybowl.ai.credits` (BOFF-7126).\n *\n * Calls HealthyBowl's OWN mutation rather than the shared one: fe-libs' transport\n * hardcodes the VibeControls field names, which bill the wrong product.\n *\n * `messageId` and `model` are required by the server — the first is half the\n * idempotency hash (without it every turn in a conversation shares one hash and\n * only the first is ever charged), the second selects the per-token prices. Both\n * come from the same `info` block the token counts do. A turn missing either is\n * skipped rather than sent, because the server would reject it anyway.\n *\n * Best-effort by contract, matching the server: the farmer already has their\n * answer, so a metering failure must never surface. Resolves either way.\n */\nexport async function reportAssistantAiTokenUsage(\n _apollo: ApolloClientLike,\n workspaceId: string,\n sessionId: string,\n messageId: string | undefined,\n model: string | undefined,\n tokens: { input: number; output: number },\n _authContext?: SharedAuthContext\n): Promise<void> {\n if (!messageId || !model) {\n // Visible on purpose. This meter exists because assistant spend was invisible; a silently\n // skipped charge would recreate exactly that blind spot, one turn at a time.\n console.warn('[assistant] skipping AI-credit charge — turn is missing messageId or model', {\n sessionId,\n hasMessageId: Boolean(messageId),\n hasModel: Boolean(model),\n });\n return;\n }\n try {\n await graphqlFetch({\n gateway: 'workspace',\n query: REPORT_HB_AI_TOKEN_USAGE,\n variables: {\n input: {\n context: { workspaceId },\n sessionId,\n messageId,\n model,\n inputTokens: tokens.input,\n outputTokens: tokens.output,\n },\n },\n });\n } catch (error) {\n // Swallowed on purpose — see the contract above. The server-side charge is idempotent, so a\n // dropped report is a missing datapoint, never a double charge. Logged rather than silent:\n // a metering regression that produces no signal is indistinguishable from no usage.\n console.warn('[assistant] AI-credit charge failed (non-fatal)', {\n sessionId,\n messageId,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n}\n\nexport function getAssistantArtifacts(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n sessionId: string,\n authContext?: SharedAuthContext\n): Promise<LocalAssistantArtifact[]> {\n // The shared surface widens `type` to `string`; at runtime the agent only ever\n // returns 'file' | 'directory', so the array is structurally the local type.\n return sharedGetArtifacts(sandboxId, workspaceId, sessionId, ctx(authContext)).then(\n (artifacts) => artifacts as unknown as LocalAssistantArtifact[]\n );\n}\n\nexport function downloadAssistantArtifact(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n sessionId: string,\n artifactPath: string,\n authContext?: SharedAuthContext\n): Promise<DownloadedAssistantArtifact> {\n return sharedDownloadArtifact(sandboxId, workspaceId, sessionId, artifactPath, ctx(authContext));\n}\n\nexport function sendHeartbeat(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n sessionId: string,\n authContext?: SharedAuthContext\n): Promise<void> {\n return sharedHeartbeat(sandboxId, workspaceId, sessionId, ctx(authContext));\n}\n\nexport function extendAssistantSandboxTTL(\n _apollo: ApolloClientLike,\n sandboxId: string,\n workspaceId: string,\n additionalSeconds = 600,\n authContext?: SharedAuthContext\n): Promise<void> {\n return sharedExtendTtl(sandboxId, workspaceId, additionalSeconds, ctx(authContext));\n}\n"],"mappings":";;;AA4EA,IAAa,IAAU,eAGjB,IAAsB;AAI5B,SAAS,IAAyB;CAChC,OAAO;AACT;AAEA,IAAM,KAAO,MAA6C,KAAK,CAAC;AAEhE,SAAgB,EACd,GACA,GACA,GACA,GACwB;CACxB,OAAO,EAAmB,GAAa,GAAM,EAAc,GAAG,EAAI,CAAW,CAAC;AAChF;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACiB;CACjB,OAAO,EAAa,GAAS,GAAM,GAAa,EAAc,GAAG,GAAqB,EAAI,CAAW,CAAC;AACxG;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,IAAY,KACZ,GACe;CACf,OAAO,EAAkB,GAAW,GAAa,EAAI,CAAW,GAAG,CAAS;AAC9E;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,IAAY,KACZ,GACe;CACf,OAAO,EAAkB,GAAW,GAAa,EAAI,CAAW,GAAG,CAAS;AAC9E;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACgC;CAChC,OAAO,EAAoB,GAAW,GAAa,GAAM,EAAI,CAAW,CAAC;AAC3E;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GAC4B;CAC5B,OAAO,EAAiB,GAAW,GAAa,GAAW,EAAI,CAAW,CAAC;AAC7E;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GAUA,GACe;CACf,OAAO,EACL,GACA,GACA,GACA,GACA,GACA,GACA,EAAI,CAAW,GACf,GAAO,SAAS,EAAE,SAAM,IAAI,KAAA,CAC9B,EAAE,WAAW,KAAA,CAAS;AACxB;AAkBA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACA,IAAQ,IACR,GAC6B;CAC7B,OAAO,EAAkB,GAAW,GAAa,GAAW,EAAI,CAAW,GAAG;EAAE;EAAO;CAAQ,CAAC;AAClG;AAcA,IAAM,IAA2B;AAmBjC,eAAsB,EACpB,GACA,GACA,GACA,GACA,GACA,GACA,GACe;CACf,IAAI,CAAC,KAAa,CAAC,GAAO;EAGxB,QAAQ,KAAK,8EAA8E;GACzF;GACA,cAAc,EAAQ;GACtB,UAAU,EAAQ;EACpB,CAAC;EACD;CACF;CACA,IAAI;EACF,MAAM,EAAa;GACjB,SAAS;GACT,OAAO;GACP,WAAW,EACT,OAAO;IACL,SAAS,EAAE,eAAY;IACvB;IACA;IACA;IACA,aAAa,EAAO;IACpB,cAAc,EAAO;GACvB,EACF;EACF,CAAC;CACH,SAAS,GAAO;EAId,QAAQ,KAAK,mDAAmD;GAC9D;GACA;GACA,OAAO,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;EAC9D,CAAC;CACH;AACF;AAEA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACmC;CAGnC,OAAO,EAAmB,GAAW,GAAa,GAAW,EAAI,CAAW,CAAC,EAAE,MAC5E,MAAc,CACjB;AACF;AAaA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACe;CACf,OAAO,EAAgB,GAAW,GAAa,GAAW,EAAI,CAAW,CAAC;AAC5E;AAEA,SAAgB,EACd,GACA,GACA,GACA,IAAoB,KACpB,GACe;CACf,OAAO,EAAgB,GAAW,GAAa,GAAmB,EAAI,CAAW,CAAC;AACpF"}
1
+ {"version":3,"file":"assistantApi.js","names":[],"sources":["../../src/services/assistantApi.ts"],"sourcesContent":["/**\n * What HealthyBowl still owns of the assistant's backend contract.\n *\n * ★★ This file used to be a ~330-line adapter mapping the panel's historical\n * apollo-first signatures onto fe-libs. The panel moved, so the adapter went\n * with it: every call site now uses the shared signatures directly and the\n * vestigial `apollo` argument is gone. What is left is the two things that are\n * genuinely this product's answer.\n */\n\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\n/**\n * Which product this assistant belongs to.\n *\n * ★ It answers TWO questions that must never disagree: `AI_ASSISTANT_PRODUCT`\n * for the sandbox (which docs corpus the agent reads) and the translation\n * namespace for the shared assistant UI (`healthybowl.assistant.*`). Two\n * separate literals would drift, and the i18n half would fail silently — every\n * string quietly falling back to English while the tests stayed green.\n */\nexport const PRODUCT = 'healthybowl';\n\nconst REPORT_HB_AI_TOKEN_USAGE = `mutation ReportHealthyBowlAiTokenUsage($input: ReportHealthyBowlAiTokenUsageInput!) {\n reportHealthyBowlAiTokenUsage(input: $input)\n}`;\n\n/**\n * Charge a completed assistant turn against `healthybowl.ai.credits` (BOFF-7126).\n *\n * ★★ Supplied to the shared panel as `reportTokenUsage`, and the reason that is\n * a seam field rather than shared code: fe-libs' own `reportAiTokenUsage` lives\n * in the VibeControls subgraph and hardcodes `vibecontrols.ai.credits` +\n * `productId: 'vibecontrols'`, so delegating to it would bill VibeControls for\n * HealthyBowl chat. Different mutation, different row. A shared default here\n * would be a silent mis-charge, which is worse than no charge at all.\n *\n * ★ There is deliberately no pre-flight CREDIT GATE to match. Credits price at\n * roughly one credit per input token while the Free tier is seeded at 500, so\n * one assistant turn is many times the whole monthly budget and a gate would\n * refuse every turn after the first. Meter first; re-size the limits against\n * real usage; only then gate. The budget is still enforced downstream, by the\n * gateway's `@usage(checkQuota)` on createSandbox.\n *\n * `messageId` and `model` are required by the server — the first is half the\n * idempotency hash (without it every turn in a conversation shares one hash and\n * only the first is ever charged), the second selects the per-token prices. Both\n * come from the same `info` block the token counts do. A turn missing either is\n * skipped rather than sent, because the server would reject it anyway.\n *\n * Best-effort by contract, matching the server: the farmer already has their\n * answer, so a metering failure must never surface. Resolves either way.\n */\nexport async function reportAssistantAiTokenUsage(usage: {\n workspaceId: string;\n sessionId: string;\n messageId?: string;\n model?: string;\n tokens: { input: number; output: number };\n}): Promise<void> {\n const { workspaceId, sessionId, messageId, model, tokens } = usage;\n if (!messageId || !model) {\n // Visible on purpose. This meter exists because assistant spend was invisible; a silently\n // skipped charge would recreate exactly that blind spot, one turn at a time.\n console.warn('[assistant] skipping AI-credit charge — turn is missing messageId or model', {\n sessionId,\n hasMessageId: Boolean(messageId),\n hasModel: Boolean(model),\n });\n return;\n }\n try {\n await graphqlFetch({\n gateway: 'workspace',\n query: REPORT_HB_AI_TOKEN_USAGE,\n variables: {\n input: {\n context: { workspaceId },\n sessionId,\n messageId,\n model,\n inputTokens: tokens.input,\n outputTokens: tokens.output,\n },\n },\n });\n } catch (error) {\n // Swallowed on purpose — see the contract above. The server-side charge is idempotent, so a\n // dropped report is a missing datapoint, never a double charge. Logged rather than silent:\n // a metering regression that produces no signal is indistinguishable from no usage.\n console.warn('[assistant] AI-credit charge failed (non-fatal)', {\n sessionId,\n messageId,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n}\n"],"mappings":";;AAqBA,IAAa,IAAU,eAEjB,IAA2B;AA8BjC,eAAsB,EAA4B,GAMhC;CAChB,IAAM,EAAE,gBAAa,cAAW,cAAW,UAAO,cAAW;CAC7D,IAAI,CAAC,KAAa,CAAC,GAAO;EAGxB,QAAQ,KAAK,8EAA8E;GACzF;GACA,cAAc,EAAQ;GACtB,UAAU,EAAQ;EACpB,CAAC;EACD;CACF;CACA,IAAI;EACF,MAAM,EAAa;GACjB,SAAS;GACT,OAAO;GACP,WAAW,EACT,OAAO;IACL,SAAS,EAAE,eAAY;IACvB;IACA;IACA;IACA,aAAa,EAAO;IACpB,cAAc,EAAO;GACvB,EACF;EACF,CAAC;CACH,SAAS,GAAO;EAId,QAAQ,KAAK,mDAAmD;GAC9D;GACA;GACA,OAAO,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;EAC9D,CAAC;CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"pageContext.js","names":[],"sources":["../../src/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context gathering — captures the user's current browser context to send\n * alongside every assistant prompt so the agent is aware of where the user is.\n *\n * Only keys the ai-assistant agent's context-loader allow-lists are emitted\n * (currentUrl / currentPage / entityType / entityId / …); anything else is\n * dropped server-side. entityType/entityId are resolved from the HealthyBowl\n * route by matching the pathname SUFFIX, because the MFE mounts under a\n * host-controlled base path (…/healthybowl/…) rather than a fixed prefix.\n */\n\nexport interface PageContext {\n currentUrl: string;\n currentPage: string;\n platform: string;\n entityType?: string;\n entityId?: string;\n viewportSize: string;\n version: string;\n timestamp: string;\n}\n\n// HealthyBowl detail routes → entityType. Matched on the pathname SUFFIX, so the\n// host base path / workspace segment is irrelevant. Order: most specific first.\n// The single-segment matchers (crops/:id, marketplace/:id) negative-lookahead\n// their STATIC sibling list-routes (crops/{fields,planning,harvest} and\n// marketplace/{cart,wishlist,orders} — see HealthyBowlRoutes.tsx) so a list page\n// like /crops/fields isn't mis-tagged as a crop with a fabricated entityId\n// \"fields\". Keep the exclusions in sync if new static sub-routes are added under\n// those parents.\n//\n// ORDER IS LOAD-BEARING in one more place: /compliance/ics/growers/:id also matches the ICS GROUP\n// pattern, so growers are listed first AND the group pattern excludes them. Get that wrong and the\n// agent is handed a group whose id is the literal string \"growers\" — a fabricated entity it will\n// then confidently try to explain. That is the failure mode this whole resolver exists to avoid:\n// a wrong entity is worse than no entity, because no entity merely costs a follow-up question.\n//\n// Two routes deliberately map to an entity they do not name: /satellite/:fieldId is a field seen\n// through a different lens, and /livestock/records/:animalId is the same animal as\n// /livestock/animals/:animalId. Resolving them to FIELD and ANIMAL is what lets \"explain this\"\n// work on those pages at all.\nconst HB_ENTITY_ROUTES: ReadonlyArray<readonly [RegExp, string]> = [\n // ── Crops ─────────────────────────────────────────────────────────────────\n [/\\/crops\\/fields\\/([^/]+)\\/?$/, 'HEALTHYBOWL_FIELD'],\n [/\\/crops\\/planning\\/([^/]+)\\/?$/, 'HEALTHYBOWL_PLAN'],\n [/\\/crops\\/harvest\\/([^/]+)\\/?$/, 'HEALTHYBOWL_HARVEST'],\n [/\\/crops\\/(?!fields\\/?$|planning\\/?$|harvest\\/?$)([^/]+)\\/?$/, 'HEALTHYBOWL_CROP'],\n // A field seen through the satellite lens is still that field — the agent should be able to\n // answer \"explain this\" here without asking which field the user means.\n [/\\/satellite\\/([^/]+)\\/?$/, 'HEALTHYBOWL_FIELD'],\n [/\\/garden\\/plantings\\/([^/]+)\\/?$/, 'HEALTHYBOWL_GARDEN_PLANTING'],\n\n // ── Livestock ─────────────────────────────────────────────────────────────\n [/\\/livestock\\/animals\\/([^/]+)\\/?$/, 'HEALTHYBOWL_ANIMAL'],\n // Same animal, different view. Both routes take an animalId, so both resolve to the animal.\n [/\\/livestock\\/records\\/([^/]+)\\/?$/, 'HEALTHYBOWL_ANIMAL'],\n\n // ── Compliance ────────────────────────────────────────────────────────────\n // Growers MUST be matched before groups. `/compliance/ics/growers/g-1` also matches the group\n // pattern, and would resolve to a group whose id is the literal string \"growers\" — a fabricated\n // entity the agent would then try to explain.\n [/\\/compliance\\/ics\\/growers\\/([^/]+)\\/?$/, 'HEALTHYBOWL_ICS_GROWER'],\n [/\\/compliance\\/ics\\/(?!growers\\/?$)([^/]+)\\/?$/, 'HEALTHYBOWL_ICS_GROUP'],\n [/\\/compliance\\/certifications\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CERTIFICATION'],\n\n // ── Distribution, storage and the co-op ───────────────────────────────────\n [/\\/distribution\\/csa\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CSA_PLAN'],\n [/\\/distribution\\/routes\\/([^/]+)\\/?$/, 'HEALTHYBOWL_DELIVERY_ROUTE'],\n [/\\/storage\\/lots\\/([^/]+)\\/?$/, 'HEALTHYBOWL_STORAGE_LOT'],\n [/\\/coop\\/lots\\/([^/]+)\\/?$/, 'HEALTHYBOWL_COOP_LOT'],\n [/\\/coop\\/members\\/([^/]+)\\/?$/, 'HEALTHYBOWL_COOP_MEMBERSHIP'],\n\n // ── Marketplace, money and people ─────────────────────────────────────────\n [/\\/marketplace\\/(?!cart\\/?$|wishlist\\/?$|orders\\/?$)([^/]+)\\/?$/, 'HEALTHYBOWL_MARKETPLACE_PRODUCT'],\n [/\\/inputs-insurance\\/claims\\/([^/]+)\\/?$/, 'HEALTHYBOWL_INSURANCE_CLAIM'],\n [/\\/government-schemes\\/schemes\\/([^/]+)\\/?$/, 'HEALTHYBOWL_SCHEME'],\n [/\\/contacts\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CONTACT'],\n [/\\/consultant\\/clients\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CLIENT_WORKSPACE'],\n [/\\/field-capture\\/conflicts\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CAPTURE_CONFLICT'],\n];\n\nexport function resolveHealthyBowlEntity(pathname: string): {\n entityType?: string;\n entityId?: string;\n} {\n for (const [pattern, entityType] of HB_ENTITY_ROUTES) {\n const match = pathname.match(pattern);\n if (match) return { entityType, entityId: match[1] };\n }\n return {};\n}\n\n// Friendly display labels for the top HealthyBowl sections. Anything not listed\n// falls back to a title-cased version of the first path segment.\nconst PAGE_LABELS: Readonly<Record<string, string>> = {\n home: 'Dashboard',\n crops: 'Crops',\n livestock: 'Livestock',\n marketplace: 'Marketplace',\n inventory: 'Inventory',\n weather: 'Weather',\n tasks: 'Farm Tasks',\n analytics: 'Analytics',\n consultant: 'Advisory',\n 'government-schemes': 'Government Schemes',\n 'market-prices': 'Market Prices',\n contracts: 'Contracts',\n};\n\n/**\n * A short, human-friendly label for the page the user is currently on — used by\n * the assistant header subtitle (\"Context: <page>\") and the empty state. Derived\n * from the same route parsing as `gatherPageContext`.\n */\nexport function describeCurrentPage(): string {\n const { currentPage } = gatherPageContext();\n const firstSegment = currentPage.split('/')[0] ?? '';\n if (!firstSegment || firstSegment === 'home') return PAGE_LABELS.home;\n return (\n PAGE_LABELS[firstSegment] ??\n firstSegment\n .split('-')\n .map((word) => (word ? word.charAt(0).toUpperCase() + word.slice(1) : word))\n .join(' ')\n );\n}\n\nexport function gatherPageContext(): PageContext {\n const pathname = window.location.pathname;\n const pathSegments = pathname.split('/').filter(Boolean);\n // Human-readable page label: the portion of the path after the `healthybowl`\n // mount segment, falling back to the trailing segments.\n const hbIndex = pathSegments.indexOf('healthybowl');\n const currentPage =\n (hbIndex >= 0 ? pathSegments.slice(hbIndex + 1, hbIndex + 4) : pathSegments.slice(-3)).join('/') || 'home';\n\n return {\n currentUrl: window.location.href,\n currentPage,\n platform: 'healthybowl',\n ...resolveHealthyBowlEntity(pathname),\n viewportSize: `${window.innerWidth}x${window.innerHeight}`,\n version: import.meta.env.VITE_APP_VERSION ?? '2026.627.1',\n timestamp: new Date().toISOString(),\n };\n}\n"],"mappings":";AAyCA,IAAM,IAA6D;CAEjE,CAAC,gCAAgC,mBAAmB;CACpD,CAAC,kCAAkC,kBAAkB;CACrD,CAAC,iCAAiC,qBAAqB;CACvD,CAAC,+DAA+D,kBAAkB;CAGlF,CAAC,4BAA4B,mBAAmB;CAChD,CAAC,oCAAoC,6BAA6B;CAGlE,CAAC,qCAAqC,oBAAoB;CAE1D,CAAC,qCAAqC,oBAAoB;CAM1D,CAAC,2CAA2C,wBAAwB;CACpE,CAAC,iDAAiD,uBAAuB;CACzE,CAAC,6CAA6C,2BAA2B;CAGzE,CAAC,oCAAoC,sBAAsB;CAC3D,CAAC,uCAAuC,4BAA4B;CACpE,CAAC,gCAAgC,yBAAyB;CAC1D,CAAC,6BAA6B,sBAAsB;CACpD,CAAC,gCAAgC,6BAA6B;CAG9D,CAAC,kEAAkE,iCAAiC;CACpG,CAAC,2CAA2C,6BAA6B;CACzE,CAAC,8CAA8C,oBAAoB;CACnE,CAAC,2BAA2B,qBAAqB;CACjD,CAAC,sCAAsC,8BAA8B;CACrE,CAAC,2CAA2C,8BAA8B;AAC5E;AAEA,SAAgB,EAAyB,GAGvC;CACA,KAAK,IAAM,CAAC,GAAS,MAAe,GAAkB;EACpD,IAAM,IAAQ,EAAS,MAAM,CAAO;EACpC,IAAI,GAAO,OAAO;GAAE;GAAY,UAAU,EAAM;EAAG;CACrD;CACA,OAAO,CAAC;AACV;AAIA,IAAM,IAAgD;CACpD,MAAM;CACN,OAAO;CACP,WAAW;CACX,aAAa;CACb,WAAW;CACX,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,sBAAsB;CACtB,iBAAiB;CACjB,WAAW;AACb;AAOA,SAAgB,IAA8B;CAC5C,IAAM,EAAE,mBAAgB,EAAkB,GACpC,IAAe,EAAY,MAAM,GAAG,EAAE,MAAM;CAElD,OADI,CAAC,KAAgB,MAAiB,SAAe,EAAY,OAE/D,EAAY,MACZ,EACG,MAAM,GAAG,EACT,KAAK,MAAU,KAAO,EAAK,OAAO,CAAC,EAAE,YAAY,IAAI,EAAK,MAAM,CAAC,CAAS,EAC1E,KAAK,GAAG;AAEf;AAEA,SAAgB,IAAiC;CAC/C,IAAM,IAAW,OAAO,SAAS,UAC3B,IAAe,EAAS,MAAM,GAAG,EAAE,OAAO,OAAO,GAGjD,IAAU,EAAa,QAAQ,aAAa,GAC5C,KACH,KAAW,IAAI,EAAa,MAAM,IAAU,GAAG,IAAU,CAAC,IAAI,EAAa,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK;CAEtG,OAAO;EACL,YAAY,OAAO,SAAS;EAC5B;EACA,UAAU;EACV,GAAG,EAAyB,CAAQ;EACpC,cAAc,GAAG,OAAO,WAAW,GAAG,OAAO;EAC7C,SAA6C;EAC7C,4BAAW,IAAI,KAAK,GAAE,YAAY;CACpC;AACF"}
1
+ {"version":3,"file":"pageContext.js","names":[],"sources":["../../src/utils/pageContext.ts"],"sourcesContent":["/**\n * Page context gathering — captures the user's current browser context to send\n * alongside every assistant prompt so the agent is aware of where the user is.\n *\n * Only keys the ai-assistant agent's context-loader allow-lists are emitted\n * (currentUrl / currentPage / entityType / entityId / …); anything else is\n * dropped server-side. entityType/entityId are resolved from the HealthyBowl\n * route by matching the pathname SUFFIX, because the MFE mounts under a\n * host-controlled base path (…/healthybowl/…) rather than a fixed prefix.\n */\n\n/**\n * ★ A type ALIAS, not an interface, and that distinction is load-bearing.\n *\n * The shared `PageContext` carries `[key: string]: unknown` so the transport can\n * pass a product's extra keys through untouched. TypeScript grants an implicit\n * index signature to object type aliases but NOT to interfaces, so as an\n * `interface` this shape was rejected where the seam expects the shared one —\n * despite being a strict superset of it. Nothing about the fields changed.\n */\nexport type PageContext = {\n currentUrl: string;\n currentPage: string;\n platform: string;\n entityType?: string;\n entityId?: string;\n viewportSize: string;\n version: string;\n timestamp: string;\n};\n\n// HealthyBowl detail routes → entityType. Matched on the pathname SUFFIX, so the\n// host base path / workspace segment is irrelevant. Order: most specific first.\n// The single-segment matchers (crops/:id, marketplace/:id) negative-lookahead\n// their STATIC sibling list-routes (crops/{fields,planning,harvest} and\n// marketplace/{cart,wishlist,orders} — see HealthyBowlRoutes.tsx) so a list page\n// like /crops/fields isn't mis-tagged as a crop with a fabricated entityId\n// \"fields\". Keep the exclusions in sync if new static sub-routes are added under\n// those parents.\n//\n// ORDER IS LOAD-BEARING in one more place: /compliance/ics/growers/:id also matches the ICS GROUP\n// pattern, so growers are listed first AND the group pattern excludes them. Get that wrong and the\n// agent is handed a group whose id is the literal string \"growers\" — a fabricated entity it will\n// then confidently try to explain. That is the failure mode this whole resolver exists to avoid:\n// a wrong entity is worse than no entity, because no entity merely costs a follow-up question.\n//\n// Two routes deliberately map to an entity they do not name: /satellite/:fieldId is a field seen\n// through a different lens, and /livestock/records/:animalId is the same animal as\n// /livestock/animals/:animalId. Resolving them to FIELD and ANIMAL is what lets \"explain this\"\n// work on those pages at all.\nconst HB_ENTITY_ROUTES: ReadonlyArray<readonly [RegExp, string]> = [\n // ── Crops ─────────────────────────────────────────────────────────────────\n [/\\/crops\\/fields\\/([^/]+)\\/?$/, 'HEALTHYBOWL_FIELD'],\n [/\\/crops\\/planning\\/([^/]+)\\/?$/, 'HEALTHYBOWL_PLAN'],\n [/\\/crops\\/harvest\\/([^/]+)\\/?$/, 'HEALTHYBOWL_HARVEST'],\n [/\\/crops\\/(?!fields\\/?$|planning\\/?$|harvest\\/?$)([^/]+)\\/?$/, 'HEALTHYBOWL_CROP'],\n // A field seen through the satellite lens is still that field — the agent should be able to\n // answer \"explain this\" here without asking which field the user means.\n [/\\/satellite\\/([^/]+)\\/?$/, 'HEALTHYBOWL_FIELD'],\n [/\\/garden\\/plantings\\/([^/]+)\\/?$/, 'HEALTHYBOWL_GARDEN_PLANTING'],\n\n // ── Livestock ─────────────────────────────────────────────────────────────\n [/\\/livestock\\/animals\\/([^/]+)\\/?$/, 'HEALTHYBOWL_ANIMAL'],\n // Same animal, different view. Both routes take an animalId, so both resolve to the animal.\n [/\\/livestock\\/records\\/([^/]+)\\/?$/, 'HEALTHYBOWL_ANIMAL'],\n\n // ── Compliance ────────────────────────────────────────────────────────────\n // Growers MUST be matched before groups. `/compliance/ics/growers/g-1` also matches the group\n // pattern, and would resolve to a group whose id is the literal string \"growers\" — a fabricated\n // entity the agent would then try to explain.\n [/\\/compliance\\/ics\\/growers\\/([^/]+)\\/?$/, 'HEALTHYBOWL_ICS_GROWER'],\n [/\\/compliance\\/ics\\/(?!growers\\/?$)([^/]+)\\/?$/, 'HEALTHYBOWL_ICS_GROUP'],\n [/\\/compliance\\/certifications\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CERTIFICATION'],\n\n // ── Distribution, storage and the co-op ───────────────────────────────────\n [/\\/distribution\\/csa\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CSA_PLAN'],\n [/\\/distribution\\/routes\\/([^/]+)\\/?$/, 'HEALTHYBOWL_DELIVERY_ROUTE'],\n [/\\/storage\\/lots\\/([^/]+)\\/?$/, 'HEALTHYBOWL_STORAGE_LOT'],\n [/\\/coop\\/lots\\/([^/]+)\\/?$/, 'HEALTHYBOWL_COOP_LOT'],\n [/\\/coop\\/members\\/([^/]+)\\/?$/, 'HEALTHYBOWL_COOP_MEMBERSHIP'],\n\n // ── Marketplace, money and people ─────────────────────────────────────────\n [/\\/marketplace\\/(?!cart\\/?$|wishlist\\/?$|orders\\/?$)([^/]+)\\/?$/, 'HEALTHYBOWL_MARKETPLACE_PRODUCT'],\n [/\\/inputs-insurance\\/claims\\/([^/]+)\\/?$/, 'HEALTHYBOWL_INSURANCE_CLAIM'],\n [/\\/government-schemes\\/schemes\\/([^/]+)\\/?$/, 'HEALTHYBOWL_SCHEME'],\n [/\\/contacts\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CONTACT'],\n [/\\/consultant\\/clients\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CLIENT_WORKSPACE'],\n [/\\/field-capture\\/conflicts\\/([^/]+)\\/?$/, 'HEALTHYBOWL_CAPTURE_CONFLICT'],\n];\n\nexport function resolveHealthyBowlEntity(pathname: string): {\n entityType?: string;\n entityId?: string;\n} {\n for (const [pattern, entityType] of HB_ENTITY_ROUTES) {\n const match = pathname.match(pattern);\n if (match) return { entityType, entityId: match[1] };\n }\n return {};\n}\n\n// Friendly display labels for the top HealthyBowl sections. Anything not listed\n// falls back to a title-cased version of the first path segment.\nconst PAGE_LABELS: Readonly<Record<string, string>> = {\n home: 'Dashboard',\n crops: 'Crops',\n livestock: 'Livestock',\n marketplace: 'Marketplace',\n inventory: 'Inventory',\n weather: 'Weather',\n tasks: 'Farm Tasks',\n analytics: 'Analytics',\n consultant: 'Advisory',\n 'government-schemes': 'Government Schemes',\n 'market-prices': 'Market Prices',\n contracts: 'Contracts',\n};\n\n/**\n * A short, human-friendly label for the page the user is currently on — used by\n * the assistant header subtitle (\"Context: <page>\") and the empty state. Derived\n * from the same route parsing as `gatherPageContext`.\n */\nexport function describeCurrentPage(): string {\n const { currentPage } = gatherPageContext();\n const firstSegment = currentPage.split('/')[0] ?? '';\n if (!firstSegment || firstSegment === 'home') return PAGE_LABELS.home;\n return (\n PAGE_LABELS[firstSegment] ??\n firstSegment\n .split('-')\n .map((word) => (word ? word.charAt(0).toUpperCase() + word.slice(1) : word))\n .join(' ')\n );\n}\n\nexport function gatherPageContext(): PageContext {\n const pathname = window.location.pathname;\n const pathSegments = pathname.split('/').filter(Boolean);\n // Human-readable page label: the portion of the path after the `healthybowl`\n // mount segment, falling back to the trailing segments.\n const hbIndex = pathSegments.indexOf('healthybowl');\n const currentPage =\n (hbIndex >= 0 ? pathSegments.slice(hbIndex + 1, hbIndex + 4) : pathSegments.slice(-3)).join('/') || 'home';\n\n return {\n currentUrl: window.location.href,\n currentPage,\n platform: 'healthybowl',\n ...resolveHealthyBowlEntity(pathname),\n viewportSize: `${window.innerWidth}x${window.innerHeight}`,\n version: import.meta.env.VITE_APP_VERSION ?? '2026.627.1',\n timestamp: new Date().toISOString(),\n };\n}\n"],"mappings":";AAkDA,IAAM,IAA6D;CAEjE,CAAC,gCAAgC,mBAAmB;CACpD,CAAC,kCAAkC,kBAAkB;CACrD,CAAC,iCAAiC,qBAAqB;CACvD,CAAC,+DAA+D,kBAAkB;CAGlF,CAAC,4BAA4B,mBAAmB;CAChD,CAAC,oCAAoC,6BAA6B;CAGlE,CAAC,qCAAqC,oBAAoB;CAE1D,CAAC,qCAAqC,oBAAoB;CAM1D,CAAC,2CAA2C,wBAAwB;CACpE,CAAC,iDAAiD,uBAAuB;CACzE,CAAC,6CAA6C,2BAA2B;CAGzE,CAAC,oCAAoC,sBAAsB;CAC3D,CAAC,uCAAuC,4BAA4B;CACpE,CAAC,gCAAgC,yBAAyB;CAC1D,CAAC,6BAA6B,sBAAsB;CACpD,CAAC,gCAAgC,6BAA6B;CAG9D,CAAC,kEAAkE,iCAAiC;CACpG,CAAC,2CAA2C,6BAA6B;CACzE,CAAC,8CAA8C,oBAAoB;CACnE,CAAC,2BAA2B,qBAAqB;CACjD,CAAC,sCAAsC,8BAA8B;CACrE,CAAC,2CAA2C,8BAA8B;AAC5E;AAEA,SAAgB,EAAyB,GAGvC;CACA,KAAK,IAAM,CAAC,GAAS,MAAe,GAAkB;EACpD,IAAM,IAAQ,EAAS,MAAM,CAAO;EACpC,IAAI,GAAO,OAAO;GAAE;GAAY,UAAU,EAAM;EAAG;CACrD;CACA,OAAO,CAAC;AACV;AAIA,IAAM,IAAgD;CACpD,MAAM;CACN,OAAO;CACP,WAAW;CACX,aAAa;CACb,WAAW;CACX,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,sBAAsB;CACtB,iBAAiB;CACjB,WAAW;AACb;AAOA,SAAgB,IAA8B;CAC5C,IAAM,EAAE,mBAAgB,EAAkB,GACpC,IAAe,EAAY,MAAM,GAAG,EAAE,MAAM;CAElD,OADI,CAAC,KAAgB,MAAiB,SAAe,EAAY,OAE/D,EAAY,MACZ,EACG,MAAM,GAAG,EACT,KAAK,MAAU,KAAO,EAAK,OAAO,CAAC,EAAE,YAAY,IAAI,EAAK,MAAM,CAAC,CAAS,EAC1E,KAAK,GAAG;AAEf;AAEA,SAAgB,IAAiC;CAC/C,IAAM,IAAW,OAAO,SAAS,UAC3B,IAAe,EAAS,MAAM,GAAG,EAAE,OAAO,OAAO,GAGjD,IAAU,EAAa,QAAQ,aAAa,GAC5C,KACH,KAAW,IAAI,EAAa,MAAM,IAAU,GAAG,IAAU,CAAC,IAAI,EAAa,MAAM,EAAE,GAAG,KAAK,GAAG,KAAK;CAEtG,OAAO;EACL,YAAY,OAAO,SAAS;EAC5B;EACA,UAAU;EACV,GAAG,EAAyB,CAAQ;EACpC,cAAc,GAAG,OAAO,WAAW,GAAG,OAAO;EAC7C,SAA6C;EAC7C,4BAAW,IAAI,KAAK,GAAE,YAAY;CACpC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.904.25",
3
+ "version": "2026.904.27",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@apollo/client": "^4.0.11",
51
- "@burdenoff/fe-libs": "2026.904.23",
51
+ "@burdenoff/fe-libs": "2026.904.25",
52
52
  "@burdenoff/planmagnet-fe-sdk": "2026.831.1",
53
53
  "@tanstack/react-query": "^5.90.16",
54
54
  "clsx": "^2.1.1",
@@ -1,33 +0,0 @@
1
- import { Modal as e } from "../../healthybowl/components/Modal.js";
2
- import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
3
- import { Button as i } from "@burdenoff/fe-libs/ui";
4
- import { useAssistantTr as a } from "@burdenoff/fe-libs/shared/assistant/i18n";
5
- //#region src/components/assistant/AssistantApiCallsConsentDialog.tsx
6
- var o = ({ open: o, onConfirm: s, onCancel: c }) => {
7
- let l = a();
8
- return /* @__PURE__ */ n(e, {
9
- open: o,
10
- onClose: c,
11
- size: "sm",
12
- title: l("apiCalls.consentTitle", "Switch to Take action mode?"),
13
- footer: /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ n(i, {
14
- variant: "outline",
15
- onClick: c,
16
- "data-testid": "assistant-api-calls-consent-cancel",
17
- children: l("apiCalls.consentCancel", "Stay in Ask")
18
- }), /* @__PURE__ */ n(i, {
19
- variant: "default",
20
- onClick: s,
21
- "data-testid": "assistant-api-calls-consent-confirm",
22
- children: l("apiCalls.consentConfirm", "Enable Take action")
23
- })] }),
24
- children: /* @__PURE__ */ r("div", {
25
- className: "space-y-2 text-sm text-text-secondary",
26
- children: [/* @__PURE__ */ n("p", { children: l("apiCalls.consentBody", "In Take action mode the assistant can read AND change your HealthyBowl data — creating crops, logging harvests, updating records, and more, on your behalf.") }), /* @__PURE__ */ n("p", { children: l("apiCalls.consentBody2", "It will describe what it is about to do and ask you to confirm before making a change. Only continue if you want the assistant to take actions for you.") })]
27
- })
28
- });
29
- };
30
- //#endregion
31
- export { o as AssistantApiCallsConsentDialog };
32
-
33
- //# sourceMappingURL=AssistantApiCallsConsentDialog.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AssistantApiCallsConsentDialog.js","names":[],"sources":["../../../src/components/assistant/AssistantApiCallsConsentDialog.tsx"],"sourcesContent":["/**\n * One-time consent dialog shown the first time a user switches the assistant\n * into the write-capable `api-calls` (\"Actions\") mode. This is the DEPENDABLE\n * guardrail: the in-sandbox agent executes mutations autonomously, so a host-\n * side acknowledgement (plus the soft describe-and-confirm prompt preamble) is\n * the FE's strongest lever short of an agent-side hard confirm. The ack is\n * persisted per-profile in the assistant store, so this shows once, not on\n * every switch.\n */\n\nimport type { FC } from 'react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { Modal } from '@/healthybowl/components/Modal';\nimport { useAssistantTr } from '@burdenoff/fe-libs/shared/assistant/i18n';\n\ninterface Props {\n open: boolean;\n onConfirm: () => void;\n onCancel: () => void;\n}\n\nexport const AssistantApiCallsConsentDialog: FC<Props> = ({ open, onConfirm, onCancel }) => {\n const tr = useAssistantTr();\n\n return (\n <Modal\n open={open}\n onClose={onCancel}\n size=\"sm\"\n title={tr('apiCalls.consentTitle', 'Switch to Take action mode?')}\n footer={\n <>\n <Button variant=\"outline\" onClick={onCancel} data-testid=\"assistant-api-calls-consent-cancel\">\n {tr('apiCalls.consentCancel', 'Stay in Ask')}\n </Button>\n <Button variant=\"default\" onClick={onConfirm} data-testid=\"assistant-api-calls-consent-confirm\">\n {tr('apiCalls.consentConfirm', 'Enable Take action')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-2 text-sm text-text-secondary\">\n <p>\n {tr(\n 'apiCalls.consentBody',\n 'In Take action mode the assistant can read AND change your HealthyBowl data — creating crops, logging harvests, updating records, and more, on your behalf.'\n )}\n </p>\n <p>\n {tr(\n 'apiCalls.consentBody2',\n 'It will describe what it is about to do and ask you to confirm before making a change. Only continue if you want the assistant to take actions for you.'\n )}\n </p>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;AAqBA,IAAa,KAA6C,EAAE,SAAM,cAAW,kBAAe;CAC1F,IAAM,IAAK,EAAe;CAE1B,OACE,kBAAC,GAAD;EACQ;EACN,SAAS;EACT,MAAK;EACL,OAAO,EAAG,yBAAyB,6BAA6B;EAChE,QACE,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;GAAQ,SAAQ;GAAU,SAAS;GAAU,eAAY;aACtD,EAAG,0BAA0B,aAAa;EACrC,CAAA,GACR,kBAAC,GAAD;GAAQ,SAAQ;GAAU,SAAS;GAAW,eAAY;aACvD,EAAG,2BAA2B,oBAAoB;EAC7C,CAAA,CACR,EAAA,CAAA;YAGJ,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD,EAAA,UACG,EACC,wBACA,6JACF,EACC,CAAA,GACH,kBAAC,KAAD,EAAA,UACG,EACC,yBACA,yJACF,EACC,CAAA,CACA;;CACA,CAAA;AAEX"}