@burdenoff/microfe-healthybowl 2026.904.26 → 2026.904.28
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.
- package/dist/components/assistant/AIAssistantPanel.js +23 -62
- package/dist/components/assistant/AIAssistantPanel.js.map +1 -1
- package/dist/components/assistant/AssistantConversationList.js +1 -2
- package/dist/components/assistant/AssistantEmptyState.js +1 -2
- package/dist/components/assistant/AssistantHeader.js +1 -2
- package/dist/components/assistant/AssistantMessageList.js +1 -2
- package/dist/components/assistant/AssistantSpeechProvider.js +1 -2
- package/dist/components/assistant/AssistantToolActivity.js +1 -2
- package/dist/components/assistant/composer/AssistantComposer.js +1 -2
- package/dist/components/assistant/index.js +7 -7
- package/dist/healthybowl/components/Modal.js +2 -29
- package/dist/services/assistantApi.js +33 -45
- package/dist/services/assistantApi.js.map +1 -1
- package/dist/utils/pageContext.js +15 -1
- package/dist/utils/pageContext.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/assistant/AssistantApiCallsConsentDialog.js +0 -33
- package/dist/components/assistant/AssistantApiCallsConsentDialog.js.map +0 -1
- package/dist/components/assistant/AssistantChatArea.js +0 -451
- package/dist/components/assistant/AssistantChatArea.js.map +0 -1
- package/dist/components/assistant/AssistantSpokenTurnsNotice.js +0 -2
- package/dist/components/assistant/voice/AssistantVoiceSession.js +0 -2
- package/dist/components/assistant/voice/VoiceTranscriptDrawer.js +0 -2
- package/dist/config/assistantLanguagePair.js +0 -2
- package/dist/config/assistantLanguages.js +0 -2
- package/dist/healthybowl/components/Modal.js.map +0 -1
- package/dist/hooks/useAssistantApiAccess.js +0 -2
- package/dist/hooks/useAssistantAttachments.js +0 -2
- package/dist/hooks/useAssistantHeartbeat.js +0 -40
- package/dist/hooks/useAssistantHeartbeat.js.map +0 -1
- package/dist/hooks/useAssistantKeyboardShortcuts.js +0 -37
- package/dist/hooks/useAssistantKeyboardShortcuts.js.map +0 -1
- package/dist/hooks/useConversationTurns.js +0 -2
- package/dist/hooks/useVoiceSession.js +0 -2
- package/dist/services/assistantExportService.js +0 -2
- package/dist/utils/aiCredits.js +0 -13
- package/dist/utils/aiCredits.js.map +0 -1
- package/dist/utils/assistantAttachments.js +0 -2
- package/dist/utils/assistantContext.js +0 -2
- package/dist/utils/assistantPollSchedule.js +0 -2
- package/dist/utils/assistantTransportErrors.js +0 -2
- package/dist/utils/assistantTurnState.js +0 -2
- package/dist/utils/captionText.js +0 -2
- package/dist/utils/pendingWrite.js +0 -2
- package/dist/utils/quotaUtils.js +0 -2
- package/dist/utils/sandboxReadiness.js +0 -2
- package/dist/utils/voiceTranscript.js +0 -2
- package/dist/utils/voiceTurnVisibility.js +0 -2
|
@@ -1,68 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
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
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
}
|
|
60
|
-
product: n,
|
|
61
|
-
modes: o,
|
|
62
|
-
describeCurrentPage: i,
|
|
63
|
-
children: /* @__PURE__ */ p(y, { ...e })
|
|
64
|
-
});
|
|
25
|
+
};
|
|
65
26
|
//#endregion
|
|
66
|
-
export {
|
|
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
|
|
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
|
|
2
|
-
export { e as AssistantConversationList };
|
|
1
|
+
import "@burdenoff/fe-libs/shared/assistant/ui/AssistantConversationList";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { e as AssistantEmptyState };
|
|
1
|
+
import "@burdenoff/fe-libs/shared/assistant/ui/AssistantEmptyState";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { e as AssistantHeader };
|
|
1
|
+
import "@burdenoff/fe-libs/shared/assistant/ui/AssistantHeader";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { e as AssistantMessageList };
|
|
1
|
+
import "@burdenoff/fe-libs/shared/assistant/ui/AssistantMessageList";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { e as AssistantSpeechProvider };
|
|
1
|
+
import "@burdenoff/fe-libs/shared/assistant/ui/AssistantSpeechProvider";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { e as parseToolActivity };
|
|
1
|
+
import "@burdenoff/fe-libs/shared/assistant/ui/AssistantToolActivity";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
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 "./
|
|
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 {
|
|
2
|
-
|
|
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,50 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { graphqlFetch as e } from "@burdenoff/fe-libs/shared/graphql";
|
|
2
2
|
//#region src/services/assistantApi.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function C(e, t, n, r, i) {
|
|
36
|
-
return Promise.resolve();
|
|
37
|
-
}
|
|
38
|
-
function w(e, t, n, r, a) {
|
|
39
|
-
return i(t, n, r, m(a)).then((e) => e);
|
|
40
|
-
}
|
|
41
|
-
function T(e, t, n, r, i) {
|
|
42
|
-
return c(t, n, r, m(i));
|
|
43
|
-
}
|
|
44
|
-
function E(e, t, r, i = 600, a) {
|
|
45
|
-
return n(t, r, i, m(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) {
|
|
7
|
+
console.warn("[assistant] skipping AI-credit charge — turn is missing messageId or model", {
|
|
8
|
+
sessionId: i,
|
|
9
|
+
hasMessageId: !!a,
|
|
10
|
+
hasModel: !!o
|
|
11
|
+
});
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
await e({
|
|
16
|
+
gateway: "workspace",
|
|
17
|
+
query: n,
|
|
18
|
+
variables: { input: {
|
|
19
|
+
context: { workspaceId: r },
|
|
20
|
+
sessionId: i,
|
|
21
|
+
messageId: a,
|
|
22
|
+
model: o,
|
|
23
|
+
inputTokens: s.input,
|
|
24
|
+
outputTokens: s.output
|
|
25
|
+
} }
|
|
26
|
+
});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.warn("[assistant] AI-credit charge failed (non-fatal)", {
|
|
29
|
+
sessionId: i,
|
|
30
|
+
messageId: a,
|
|
31
|
+
error: e instanceof Error ? e.message : String(e)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
46
34
|
}
|
|
47
35
|
//#endregion
|
|
48
|
-
export {
|
|
36
|
+
export { t as PRODUCT, r as reportAssistantAiTokenUsage };
|
|
49
37
|
|
|
50
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: `checkAssistantAiCredits` / `reportAssistantAiTokenUsage`\n * remain **deliberate no-ops** — the wspace checkAiCredits / reportAiTokenUsage\n * mutations live in the VibeControls subgraph and bill the `vibecontrols`\n * product, so an HB chat must NOT gate on (or charge against) VibeControls'\n * credit quota. The coarse createSandbox `@usage(sandboxes-created)` limit still\n * applies downstream. These two functions therefore do NOT delegate to the\n * shared credit calls.\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 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\n/**\n * Deliberate no-op for HealthyBowl (see file header): per-token charging routes\n * to the VibeControls AI-credit quota, which HB does not bill against.\n */\nexport function reportAssistantAiTokenUsage(\n _apollo: ApolloClientLike,\n _workspaceId: string,\n _sessionId: string,\n _tokens: { input: number; output: number },\n _authContext?: SharedAuthContext\n): Promise<void> {\n return Promise.resolve();\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":";;AAkEA,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;AAkBA,SAAgB,EACd,GACA,GACA,GACA,GACA,GACe;CACf,OAAO,QAAQ,QAAQ;AACzB;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"}
|
|
@@ -4,10 +4,24 @@ var e = [
|
|
|
4
4
|
[/\/crops\/planning\/([^/]+)\/?$/, "HEALTHYBOWL_PLAN"],
|
|
5
5
|
[/\/crops\/harvest\/([^/]+)\/?$/, "HEALTHYBOWL_HARVEST"],
|
|
6
6
|
[/\/crops\/(?!fields\/?$|planning\/?$|harvest\/?$)([^/]+)\/?$/, "HEALTHYBOWL_CROP"],
|
|
7
|
+
[/\/satellite\/([^/]+)\/?$/, "HEALTHYBOWL_FIELD"],
|
|
8
|
+
[/\/garden\/plantings\/([^/]+)\/?$/, "HEALTHYBOWL_GARDEN_PLANTING"],
|
|
7
9
|
[/\/livestock\/animals\/([^/]+)\/?$/, "HEALTHYBOWL_ANIMAL"],
|
|
10
|
+
[/\/livestock\/records\/([^/]+)\/?$/, "HEALTHYBOWL_ANIMAL"],
|
|
11
|
+
[/\/compliance\/ics\/growers\/([^/]+)\/?$/, "HEALTHYBOWL_ICS_GROWER"],
|
|
12
|
+
[/\/compliance\/ics\/(?!growers\/?$)([^/]+)\/?$/, "HEALTHYBOWL_ICS_GROUP"],
|
|
13
|
+
[/\/compliance\/certifications\/([^/]+)\/?$/, "HEALTHYBOWL_CERTIFICATION"],
|
|
14
|
+
[/\/distribution\/csa\/([^/]+)\/?$/, "HEALTHYBOWL_CSA_PLAN"],
|
|
15
|
+
[/\/distribution\/routes\/([^/]+)\/?$/, "HEALTHYBOWL_DELIVERY_ROUTE"],
|
|
16
|
+
[/\/storage\/lots\/([^/]+)\/?$/, "HEALTHYBOWL_STORAGE_LOT"],
|
|
17
|
+
[/\/coop\/lots\/([^/]+)\/?$/, "HEALTHYBOWL_COOP_LOT"],
|
|
18
|
+
[/\/coop\/members\/([^/]+)\/?$/, "HEALTHYBOWL_COOP_MEMBERSHIP"],
|
|
8
19
|
[/\/marketplace\/(?!cart\/?$|wishlist\/?$|orders\/?$)([^/]+)\/?$/, "HEALTHYBOWL_MARKETPLACE_PRODUCT"],
|
|
20
|
+
[/\/inputs-insurance\/claims\/([^/]+)\/?$/, "HEALTHYBOWL_INSURANCE_CLAIM"],
|
|
9
21
|
[/\/government-schemes\/schemes\/([^/]+)\/?$/, "HEALTHYBOWL_SCHEME"],
|
|
10
|
-
[/\/
|
|
22
|
+
[/\/contacts\/([^/]+)\/?$/, "HEALTHYBOWL_CONTACT"],
|
|
23
|
+
[/\/consultant\/clients\/([^/]+)\/?$/, "HEALTHYBOWL_CLIENT_WORKSPACE"],
|
|
24
|
+
[/\/field-capture\/conflicts\/([^/]+)\/?$/, "HEALTHYBOWL_CAPTURE_CONFLICT"]
|
|
11
25
|
];
|
|
12
26
|
function t(t) {
|
|
13
27
|
for (let [n, r] of e) {
|
|
@@ -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\
|
|
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.
|
|
3
|
+
"version": "2026.904.28",
|
|
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.
|
|
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"}
|