@burdenoff/microfe-healthybowl 2026.919.3 → 2026.919.5

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.
@@ -1 +1 @@
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\n/**\n * Where this product's assistant files already live.\n *\n * ★★ These strings are LOAD-BEARING and must not be \"tidied\". They are the real\n * folders in the workspace file library holding every attachment and artifact\n * users have saved. Changing them does not fail — it starts a second folder\n * beside the first and orphans everything in the original.\n *\n * ★ Note the capitalisation: `/HealthyBowl/…`, while the product id is\n * `healthybowl`. That mismatch is exactly why fe-libs cannot derive this and why\n * it is supplied here. The shared default (`/<product>/AI Assistant/…`) is right\n * for a product starting fresh and would be a rename for this one.\n */\nconst STORAGE_FOLDERS = {\n attachments: '/HealthyBowl/AI Assistant/Attachments',\n artifacts: '/HealthyBowl/AI Assistant/Artifacts',\n} as const;\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 storageFolders={STORAGE_FOLDERS}\n >\n <SharedAIAssistantPanel {...props} writeAccess={writeAccess} />\n </AssistantProductProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AAsDA,IAAM,IAAkB;CACtB,aAAa;CACb,WAAW;AACb,GAIa,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;EAClB,gBAAgB;YAEhB,kBAAC,GAAD;GAAwB,GAAI;GAAoB;EAAc,CAAA;CACtC,CAAA;AAE9B"}
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\n/**\n * Where this product's assistant files already live.\n *\n * ★★ These strings are LOAD-BEARING and must not be \"tidied\". They are the real\n * folders in the workspace file library holding every attachment and artifact\n * users have saved. Changing them does not fail — it starts a second folder\n * beside the first and orphans everything in the original.\n *\n * ★ Note the capitalisation: `/HealthyBowl/…`, while the product id is\n * `healthybowl`. That mismatch is exactly why fe-libs cannot derive this and why\n * it is supplied here. The shared default (`/<product>/AI Assistant/…`) is right\n * for a product starting fresh and would be a rename for this one.\n */\nconst STORAGE_FOLDERS = {\n attachments: '/HealthyBowl/AI Assistant/Attachments',\n artifacts: '/HealthyBowl/AI Assistant/Artifacts',\n} as const;\n\nexport type AIAssistantPanelProps = Omit<SharedProps, 'writeAccess'>;\n\nexport const AIAssistantPanel: FC<AIAssistantPanelProps> = (props) => {\n /**\n * ★ Advisory, never a gate — see `useWorkspaceWriteAccess`. The `@rbac` check\n * on each mutation is the authority; this only warns before the effort instead\n * of after it. A client-side permission read can be wrong, and a wrong GATE\n * would hide Take-action from a user who is allowed to use it. (The \"no roles\n * provisioned\" reading of 2026-09-02 was one uninitialised workspace, fixed on\n * 2026-09-07 — not the platform.)\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 storageFolders={STORAGE_FOLDERS}\n >\n <SharedAIAssistantPanel {...props} writeAccess={writeAccess} />\n </AssistantProductProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AAsDA,IAAM,IAAkB;CACtB,aAAa;CACb,WAAW;AACb,GAIa,KAA+C,MAAU;CASpE,IAAM,IAAc,EAAwB,EAAW,GAAG,EAAe,KAAK,IAAI;CAElF,OACE,kBAAC,GAAD;EACE,SAAS;EACT,OAAO;EACc;EACF;EACnB,aAAa;EACb,kBAAkB;EAClB,gBAAgB;YAEhB,kBAAC,GAAD;GAAwB,GAAI;GAAoB;EAAc,CAAA;CACtC,CAAA;AAE9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"assistantUsecases.js","names":[],"sources":["../../src/config/assistantUsecases.ts"],"sourcesContent":["/**\n * HealthyBowl AI Assistant usecases.\n *\n * `AssistantUsecaseId` is the full set of modes the transport/runtime\n * understands — it drives the image/resource switches in `services/assistantApi`.\n * `ASSISTANT_USECASE_CONFIG` is the set of modes the panel KNOWS about; the mode\n * selector further filters them at runtime by the user's role (see\n * `useAssistantApiAccess`) so a write-capable mode only appears for org admins.\n * - `general` — docs Q&A (proxy-token auth, available to everyone).\n * - `api-calls` — WRITE-CAPABLE: the agent executes GraphQL on the user's\n * behalf (app-client-credentials auth). Minting its per-sandbox OAuth app\n * requires a global Owner/Admin actor, so it is gated to admins, guarded by a\n * confirm-before-mutate dialog + a soft agent preamble, and master-flagged.\n * - `vibe-plugins` — a VibeControls-only concept HealthyBowl never exposes.\n */\n\n// Full set of runtime-understood modes. Keep in sync with the image/resource\n// switches in `services/assistantApi.ts`.\nexport type AssistantUsecaseId = 'general' | 'assistant' | 'api-calls' | 'vibe-plugins';\n\nexport interface AssistantUsecase {\n id: AssistantUsecaseId;\n label: string;\n description: string;\n suggestions: readonly string[];\n /** Only offered to a global Owner/Admin (minting the OAuth app needs admin). */\n requiresAdmin?: boolean;\n /** Executes mutations on live data → triggers the confirm-before-mutate guard. */\n writeCapable?: boolean;\n}\n\n/**\n * Master switch for the write-capable `api-calls` (\"Actions\") mode. Enabled on\n * ALL environments (alpha + production) as of 2026-06-30, by explicit product\n * decision. The mode remains gated by: (1) the admin check — only org\n * Owners/Admins ever see it (useAssistantApiAccess), (2) a one-time consent\n * dialog, and (3) a describe-and-confirm instruction prepended to the prompt.\n * The in-sandbox agent still auto-executes (no hard server-side confirm yet) —\n * that residual risk was accepted when enabling on prod.\n *\n * `typeof window` keeps it false during any non-browser evaluation; in the\n * browser it's always on (the admin gate is the real boundary).\n */\nexport const API_CALLS_MODE_ENABLED = typeof window !== 'undefined';\n\n// Default \"Ask\" for EVERY user: docs Q&A + READ-ONLY live data. Unlike\n// `api-calls` it authenticates with the user's OWN forwarded token (no\n// admin-gated OAuth-app mint), and the in-sandbox helper rejects mutations\n// (AI_ASSISTANT_READONLY) — so it needs no admin and answers questions like\n// \"list my livestock\" against real data. Writes live in `api-calls` below.\nconst ASSISTANT: AssistantUsecase = {\n id: 'assistant',\n label: 'Ask',\n description:\n 'Ask about HealthyBowl and your own farm data — crops, livestock, weather, finances. Reads your live records; use \"Take action\" to make changes.',\n suggestions: [\n 'List all my livestock',\n 'How many crops do I have?',\n 'Explain the livestock health tracker',\n 'What government schemes can I apply for?',\n ],\n};\n\nconst API_CALLS: AssistantUsecase = {\n id: 'api-calls',\n // Display label only — the mode ID stays 'api-calls' (see services/assistantApi).\n label: 'Take action',\n description:\n 'Let the assistant take actions for you — add crops, log harvests, update records. It describes what it will do and asks before changing anything.',\n suggestions: [\n 'Add a new crop',\n 'Log a harvest for one of my fields',\n 'List all my livestock',\n \"Update a crop's status\",\n ],\n requiresAdmin: true,\n writeCapable: true,\n};\n\n// Modes the panel knows about. The default \"Ask\" is now the read-only\n// `assistant` mode (docs + live data, available to everyone). `api-calls`\n// (\"Take action\", write) is added when enabled and further filtered to admins\n// at runtime by the mode selector. `general` (docs-only) is retained in the\n// type for back-compat with persisted conversations but no longer surfaced.\nexport const ASSISTANT_USECASE_CONFIG: readonly AssistantUsecase[] = API_CALLS_MODE_ENABLED\n ? [ASSISTANT, API_CALLS]\n : [ASSISTANT];\n"],"mappings":";AA2CA,IAAa,IAAyB,OAAO,SAAW,KAOlD,IAA8B;CAClC,IAAI;CACJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;AACF,GAuBa,IAAwD,IACjE,CAAC,GAAW;CArBd,IAAI;CAEJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;CACA,eAAe;CACf,cAAc;AASA,CAAS,IACrB,CAAC,CAAS"}
1
+ {"version":3,"file":"assistantUsecases.js","names":[],"sources":["../../src/config/assistantUsecases.ts"],"sourcesContent":["/**\n * HealthyBowl AI Assistant usecases.\n *\n * `AssistantUsecaseId` is the full set of modes the transport/runtime\n * understands — it drives the image/resource switches in `services/assistantApi`.\n * `ASSISTANT_USECASE_CONFIG` is the set of modes the panel KNOWS about; the mode\n * selector further filters them at runtime by the user's role (see\n * `useAssistantApiAccess`) so a write-capable mode only appears for org admins.\n * - `general` — docs Q&A (proxy-token auth, available to everyone).\n * - `api-calls` — WRITE-CAPABLE: the agent executes GraphQL on the user's\n * behalf (app-client-credentials auth). Minting its per-sandbox OAuth app\n * requires a global Owner/Admin actor, so it is gated to admins, guarded by a\n * confirm-before-mutate dialog + a soft agent preamble, and master-flagged.\n * - `vibe-plugins` — a VibeControls-only concept HealthyBowl never exposes.\n */\n\n// Full set of runtime-understood modes. Keep in sync with the image/resource\n// switches in `services/assistantApi.ts`.\nexport type AssistantUsecaseId = 'general' | 'assistant' | 'api-calls' | 'vibe-plugins';\n\nexport interface AssistantUsecase {\n id: AssistantUsecaseId;\n label: string;\n description: string;\n suggestions: readonly string[];\n /** Only offered to a global Owner/Admin (minting the OAuth app needs admin). */\n requiresAdmin?: boolean;\n /** Executes mutations on live data → triggers the confirm-before-mutate guard. */\n writeCapable?: boolean;\n}\n\n/**\n * Master switch for the write-capable `api-calls` (\"Actions\") mode. Enabled on\n * ALL environments (alpha + production) as of 2026-06-30, by explicit product\n * decision. The mode remains gated by: (1) the admin check — only org\n * Owners/Admins ever see it (useAssistantApiAccess), (2) a one-time consent\n * dialog, (3) the user's approval of each write — since 2026-09-07 the sandbox\n * refuses a mutation and holds it until the user presses Approve on the\n * pending-write card (ai-assistant #41/#42, fe-libs #194), and the model holds\n * no token that could send it — and (4) a describe-and-confirm instruction\n * prepended to the prompt, which is advisory. The approval is recorded inside\n * the sandbox, so it stops an accidental or misread write; it is not a wall\n * against a model set on getting round it.\n *\n * `typeof window` keeps it false during any non-browser evaluation; in the\n * browser it's always on (the admin gate is the real boundary).\n */\nexport const API_CALLS_MODE_ENABLED = typeof window !== 'undefined';\n\n// Default \"Ask\" for EVERY user: docs Q&A + READ-ONLY live data. Unlike\n// `api-calls` it authenticates with the user's OWN forwarded token (no\n// admin-gated OAuth-app mint), and the in-sandbox helper rejects mutations\n// (AI_ASSISTANT_READONLY) — so it needs no admin and answers questions like\n// \"list my livestock\" against real data. Writes live in `api-calls` below.\nconst ASSISTANT: AssistantUsecase = {\n id: 'assistant',\n label: 'Ask',\n description:\n 'Ask about HealthyBowl and your own farm data — crops, livestock, weather, finances. Reads your live records; use \"Take action\" to make changes.',\n suggestions: [\n 'List all my livestock',\n 'How many crops do I have?',\n 'Explain the livestock health tracker',\n 'What government schemes can I apply for?',\n ],\n};\n\nconst API_CALLS: AssistantUsecase = {\n id: 'api-calls',\n // Display label only — the mode ID stays 'api-calls' (see services/assistantApi).\n label: 'Take action',\n description:\n 'Let the assistant take actions for you — add crops, log harvests, update records. It describes what it will do and asks before changing anything.',\n suggestions: [\n 'Add a new crop',\n 'Log a harvest for one of my fields',\n 'List all my livestock',\n \"Update a crop's status\",\n ],\n requiresAdmin: true,\n writeCapable: true,\n};\n\n// Modes the panel knows about. The default \"Ask\" is now the read-only\n// `assistant` mode (docs + live data, available to everyone). `api-calls`\n// (\"Take action\", write) is added when enabled and further filtered to admins\n// at runtime by the mode selector. `general` (docs-only) is retained in the\n// type for back-compat with persisted conversations but no longer surfaced.\nexport const ASSISTANT_USECASE_CONFIG: readonly AssistantUsecase[] = API_CALLS_MODE_ENABLED\n ? [ASSISTANT, API_CALLS]\n : [ASSISTANT];\n"],"mappings":";AA+CA,IAAa,IAAyB,OAAO,SAAW,KAOlD,IAA8B;CAClC,IAAI;CACJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;AACF,GAuBa,IAAwD,IACjE,CAAC,GAAW;CArBd,IAAI;CAEJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;CACF;CACA,eAAe;CACf,cAAc;AASA,CAAS,IACrB,CAAC,CAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"GetHelpButton.js","names":[],"sources":["../../../src/healthybowl/components/GetHelpButton.tsx"],"sourcesContent":["import { HelpCircle } from 'lucide-react';\nimport { useOpenAssistantHelp } from '@/hooks/useOpenAssistantHelp';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface GetHelpButtonProps {\n /** The prompt auto-sent to the assistant (general mode) when clicked. */\n prompt: string;\n /** Optional label override. Defaults to \"Get Help\". */\n label?: string;\n /** `ghost` (default) is a subtle outlined button; `link` is text-only. */\n variant?: 'ghost' | 'link';\n /** Additional CSS class names. */\n className?: string;\n}\n\n/**\n * Shared \"Get Help\" button — a contextual help affordance that opens the AI\n * assistant and auto-asks about the current screen, so a user can get help\n * without leaving the page or typing. Rendered by `PageLayout` on every page\n * (prompt derived from the page title), and usable standalone next to \"Add X\"\n * empty states. Mirrors the VibeControls pattern; HB semantic tokens only.\n *\n * Clicking it: switches the assistant to `general` mode, opens the shell panel\n * (`hb:toggle-ai-assistant` { open: true }), and queues `prompt` — the\n * AssistantChatArea auto-sends it. See `useOpenAssistantHelp`.\n */\nexport function GetHelpButton({ prompt, label, variant = 'ghost', className = '' }: GetHelpButtonProps) {\n const tr = useTr();\n const resolvedLabel = label ?? tr('healthybowl.shared.getHelpButton.label', 'Get Help');\n const openHelp = useOpenAssistantHelp();\n\n const baseClass =\n variant === 'ghost'\n ? 'inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border border-border-default text-text-secondary hover:text-text-primary hover:bg-bg-sunken rounded-md transition-colors'\n : 'inline-flex items-center gap-1.5 text-sm text-action-primary-bg hover:underline';\n\n return (\n <button\n type=\"button\"\n onClick={() => openHelp(prompt)}\n className={`${baseClass} ${className}`.trim()}\n title={tr('healthybowl.shared.getHelpButton.tooltip', 'Ask the assistant about this page')}\n data-testid=\"get-help-button\"\n >\n <HelpCircle className=\"size-4\" />\n {resolvedLabel}\n </button>\n );\n}\n"],"mappings":";;;;;AA0BA,SAAgB,EAAc,EAAE,WAAQ,UAAO,aAAU,SAAS,eAAY,MAA0B;CACtG,IAAM,IAAK,EAAM,GACX,IAAgB,KAAS,EAAG,0CAA0C,UAAU,GAChF,IAAW,EAAqB;CAOtC,OACE,kBAAC,UAAD;EACE,MAAK;EACL,eAAe,EAAS,CAAM;EAC9B,WAAW,GARb,MAAY,UACR,kLACA,kFAMsB,GAAG,IAAY,KAAK;EAC5C,OAAO,EAAG,4CAA4C,mCAAmC;EACzF,eAAY;YALd,CAOE,kBAAC,GAAD,EAAY,WAAU,SAAU,CAAA,GAC/B,CACK;;AAEZ"}
1
+ {"version":3,"file":"GetHelpButton.js","names":[],"sources":["../../../src/healthybowl/components/GetHelpButton.tsx"],"sourcesContent":["import { HelpCircle } from 'lucide-react';\nimport { useOpenAssistantHelp } from '@/hooks/useOpenAssistantHelp';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface GetHelpButtonProps {\n /** The prompt auto-sent to the assistant, in whatever mode it is already in, when clicked. */\n prompt: string;\n /** Optional label override. Defaults to \"Get Help\". */\n label?: string;\n /** `ghost` (default) is a subtle outlined button; `link` is text-only. */\n variant?: 'ghost' | 'link';\n /** Additional CSS class names. */\n className?: string;\n}\n\n/**\n * Shared \"Get Help\" button — a contextual help affordance that opens the AI\n * assistant and auto-asks about the current screen, so a user can get help\n * without leaving the page or typing. Rendered by `PageLayout` on every page\n * (prompt derived from the page title), and usable standalone next to \"Add X\"\n * empty states. Mirrors the VibeControls pattern; HB semantic tokens only.\n *\n * Clicking it opens the shell panel (`hb:toggle-ai-assistant` { open: true })\n * and queues `prompt`, which the AssistantChatArea auto-sends. It leaves the\n * MODE alone: forcing `general` — a documentation-only sandbox with no data\n * tools, absent from the mode selector — stranded users in a mode they could\n * neither see nor leave. See `useOpenAssistantHelp`.\n */\nexport function GetHelpButton({ prompt, label, variant = 'ghost', className = '' }: GetHelpButtonProps) {\n const tr = useTr();\n const resolvedLabel = label ?? tr('healthybowl.shared.getHelpButton.label', 'Get Help');\n const openHelp = useOpenAssistantHelp();\n\n const baseClass =\n variant === 'ghost'\n ? 'inline-flex items-center gap-1.5 px-3 py-1.5 text-sm border border-border-default text-text-secondary hover:text-text-primary hover:bg-bg-sunken rounded-md transition-colors'\n : 'inline-flex items-center gap-1.5 text-sm text-action-primary-bg hover:underline';\n\n return (\n <button\n type=\"button\"\n onClick={() => openHelp(prompt)}\n className={`${baseClass} ${className}`.trim()}\n title={tr('healthybowl.shared.getHelpButton.tooltip', 'Ask the assistant about this page')}\n data-testid=\"get-help-button\"\n >\n <HelpCircle className=\"size-4\" />\n {resolvedLabel}\n </button>\n );\n}\n"],"mappings":";;;;;AA4BA,SAAgB,EAAc,EAAE,WAAQ,UAAO,aAAU,SAAS,eAAY,MAA0B;CACtG,IAAM,IAAK,EAAM,GACX,IAAgB,KAAS,EAAG,0CAA0C,UAAU,GAChF,IAAW,EAAqB;CAOtC,OACE,kBAAC,UAAD;EACE,MAAK;EACL,eAAe,EAAS,CAAM;EAC9B,WAAW,GARb,MAAY,UACR,kLACA,kFAMsB,GAAG,IAAY,KAAK;EAC5C,OAAO,EAAG,4CAA4C,mCAAmC;EACzF,eAAY;YALd,CAOE,kBAAC,GAAD,EAAY,WAAU,SAAU,CAAA,GAC/B,CACK;;AAEZ"}
@@ -6,4 +6,3 @@ import "./HealthyBowlRoot.js";
6
6
  import "./public/PublicTracePage.js";
7
7
  import "./public/PublicSeedLotPage.js";
8
8
  import "./store/healthybowlStore.js";
9
- import "./hooks/useOpenAssistantHelp.js";
@@ -1 +1 @@
1
- {"version":3,"file":"assistantPrompt.js","names":[],"sources":["../../src/utils/assistantPrompt.ts"],"sourcesContent":["/**\n * Soft confirm-before-mutate guardrail for the assistant's api-calls (write)\n * mode. The in-sandbox agent executes mutations autonomously — there is no hard\n * server-side confirmation — so we prepend a describe-and-confirm instruction to\n * the user's TURN (not the session system prompt, which would clobber the\n * agent's api-calls behaviour). This is ADVISORY; the dependable guard is the\n * host-side consent dialog + the admin gate. Only the agent receives the\n * prepended text — the user-facing message bubble keeps the raw content.\n */\n\nimport type { AssistantMode } from '@/types/assistant';\n\n/**\n * Marks where our instructions stop and the user's words begin. Exactly one may\n * exist in a prompt, and it must be last — see `buildPromptForMode`.\n */\nexport const USER_REQUEST_DELIMITER = '--- User request ---';\n\nexport const API_CALLS_CONFIRM_PREAMBLE = [\n \"You are in api-calls mode for HealthyBowl and can run GraphQL queries and mutations on the user's behalf.\",\n 'Before performing ANY write (create, update, delete — any mutation):',\n '1. State exactly what you are about to change (entity, fields, and values).',\n '2. Ask the user to confirm, and WAIT for an explicit \"yes\"/\"confirm\" before executing it.',\n 'Read-only queries may run without confirmation. Confirm each write separately; never batch mutations behind a single confirmation.',\n '',\n USER_REQUEST_DELIMITER,\n].join('\\n');\n\n/**\n * Ask for the reply in the user's language (BOFF-7107).\n *\n * Nothing else does. The sandbox system prompt carries no language instruction,\n * the grounding documentation is entirely in English, and the persona insists on\n * grounding in it — so every force in the session pushes the answer towards\n * English regardless of what the user wrote. The model's tendency to mirror the\n * input is the only thing resisting that, and it is being outvoted.\n *\n * Three deliberate choices:\n *\n * - **The user's own language wins over the UI language.** The chrome being in\n * English says nothing about the person typing Tamil into it; treating the\n * locale as an instruction rather than a default would be the actual bug.\n * - **Translate the docs, do not switch to their language.** This is the clause\n * that matters. Without it a grounded answer drifts back to English mid-reply\n * simply because the source material is English.\n * - **Prepended per TURN, not sent as `system`.** The transport's `system` field\n * REPLACES the whole mode prompt, which would silently delete the docs and\n * api-calls instructions along with it.\n */\n/**\n * The instruction lines only — deliberately WITHOUT the delimiter.\n *\n * The delimiter marks where our instructions stop and the user's words begin, so\n * exactly one may exist and it must be last. Emitting it here too put a second\n * one mid-prompt, which left the api-calls safety instructions sitting *after* a\n * \"User request\" marker — i.e. presented to the model as though the user had\n * written them. `buildPromptForMode` owns placing it, once.\n */\n/**\n * Told to the model when the turn was SPOKEN rather than typed.\n *\n * Speech recognition does not fail uniformly — it fails on specific words, and\n * the ones it fails on here are predictable: English technical terms, product\n * and crop names, and numbers spoken inside an Indic sentence. A recogniser set\n * to `ta-IN` has no good model for \"urea\", \"pH\" or \"NPK\", so a Tamil sentence\n * comes back mostly right with a few words wrong. That is exactly the report:\n * \"some word some times\".\n *\n * The model is far better placed to repair that than the recogniser is, because\n * it has the farming context — but only if it is TOLD the text was dictated.\n * Otherwise it answers the garbled word literally, which is what makes the\n * assistant look like it misunderstood.\n *\n * ★ The refusal to guess is the important half. Charitable interpretation is\n * right for a mangled verb and dangerous for a mangled QUANTITY: this is\n * agriculture, and a dose or a unit that the recogniser mis-heard must be asked\n * about, not inferred. One extra question costs a few seconds; a wrong dose\n * costs a crop.\n */\nconst DICTATION_PREAMBLE = [\n 'This message was DICTATED using speech recognition, so some words may be mis-heard.',\n 'Errors cluster on English technical terms, product and crop names, and numbers spoken inside a sentence in another language.',\n 'Read the message for INTENT rather than literally: where a word is clearly a recognition error, infer what was meant from the agricultural context instead of answering the garbled word.',\n 'But do NOT guess when a mis-heard word would change what is being asked — a crop, a chemical, a quantity or a unit. Ask one short clarifying question instead. A wrong dose is far worse than an extra question.',\n].join('\\n');\n\n/**\n * Told to the model when its answer will be SPOKEN ALOUD, not read.\n *\n * The assistant was never told this, so it replied the way it replies in chat:\n * documentation-style markdown with `##` headings, `**bold**` and long\n * enumerated sections. In the chat panel that renders correctly. In the voice\n * panel it is read aloud AND shown as a caption, where the syntax is literal\n * and the length is unusable — the operator screenshotted a live session whose\n * caption was a wall of \"### **Budget Planning Features:**\".\n *\n * ★ This is the fix at SOURCE. Stripping markdown at render time is a\n * necessary backstop, but it cannot shorten a 500-word answer that was never\n * meant to be listened to. A spoken reply has to be short because the listener\n * cannot skim it.\n */\nconst VOICE_REPLY_PREAMBLE = [\n 'Your answer will be SPOKEN ALOUD and shown as a live caption, not read as a document.',\n 'Write plain conversational sentences. Use NO markdown whatsoever: no #, ##, ###, no **bold**, no bullet or numbered lists, no tables, no code fences.',\n 'Keep it SHORT — normally one to four sentences. The listener cannot skim, so a long answer is worse than an incomplete one.',\n 'If the full answer is genuinely long, give the useful part first and offer to go deeper, rather than listing every option.',\n 'Speak numbers, units and quantities the way a person says them.',\n].join('\\n');\n\nexport function buildLanguagePreamble(languageName: string, isExplicitChoice = false): string {\n return [\n `Answer in ${languageName}.`,\n // The mirror clause is right for a DEFAULT and wrong for a CHOICE.\n //\n // Derived from the interface language it is only a guess, and the language\n // the user actually wrote in is better evidence. But once they have picked a\n // language deliberately, \"what they wrote in wins\" silently overrides them —\n // and it does so hardest for people who TYPE, since a typed English question\n // would come back in English no matter what they selected. That makes the\n // preference inert for exactly the users who cannot dictate.\n isExplicitChoice\n ? `The user has chosen ${languageName} deliberately: answer in it even when their message is written in another language.`\n : 'If the user writes in a different language, answer in THAT language instead — what they wrote in always wins.',\n 'Your documentation and tool output are in English: translate what you quote from them rather than switching language.',\n ].join('\\n');\n}\n\n/**\n * `languageName` is the human name of the user's language (\"Tamil\"), not a code:\n * a code invites the model to answer *about* the tag instead of *in* it.\n * Omitted (or empty) leaves the prompt untouched, so a caller without locale\n * context behaves exactly as before.\n *\n * Order is load-bearing: instructions, then the delimiter, then the user's text.\n * The language preamble goes FIRST so the api-calls preamble keeps its own\n * delimiter adjacent to the content it introduces.\n */\nexport function buildPromptForMode(\n mode: AssistantMode,\n content: string,\n languageName?: string,\n isExplicitChoice = false,\n dictated = false\n): string {\n // Dictation goes AFTER the language lines and before the delimiter: it is an\n // instruction about the user's text, so it belongs with the instructions, not\n // inside them. Defaults to false, so every typed turn is byte-identical to\n // before — the composer's own dictation is excluded deliberately, because the\n // user can read and edit that text before sending it.\n const preamble = [\n languageName ? buildLanguagePreamble(languageName, isExplicitChoice) : '',\n dictated ? DICTATION_PREAMBLE : '',\n // A dictated turn is a SPOKEN conversation, so the reply is spoken too.\n dictated ? VOICE_REPLY_PREAMBLE : '',\n ]\n .filter(Boolean)\n .join('\\n\\n');\n const language = preamble ? `${preamble}\\n\\n` : '';\n if (mode === 'api-calls') return `${language}${API_CALLS_CONFIRM_PREAMBLE}\\n${content}`;\n return language ? `${language}${USER_REQUEST_DELIMITER}\\n${content}` : content;\n}\n"],"mappings":";AAgBA,IAAa,IAAyB,wBAEzB,IAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAqDL,IAAqB;CACzB;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAiBL,IAAuB;CAC3B;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI;AAEX,SAAgB,EAAsB,GAAsB,IAAmB,IAAe;CAC5F,OAAO;EACL,aAAa,EAAa;EAS1B,IACI,uBAAuB,EAAa,uFACpC;EACJ;CACF,EAAE,KAAK,IAAI;AACb;AAYA,SAAgB,EACd,GACA,GACA,GACA,IAAmB,IACnB,IAAW,IACH;CAMR,IAAM,IAAW;EACf,IAAe,EAAsB,GAAc,CAAgB,IAAI;EACvE,IAAW,IAAqB;EAEhC,IAAW,IAAuB;CACpC,EACG,OAAO,OAAO,EACd,KAAK,MAAM,GACR,IAAW,IAAW,GAAG,EAAS,QAAQ;CAEhD,OADI,MAAS,cAAoB,GAAG,IAAW,EAA2B,IAAI,MACvE,IAAW,GAAG,IAAW,EAAuB,IAAI,MAAY;AACzE"}
1
+ {"version":3,"file":"assistantPrompt.js","names":[],"sources":["../../src/utils/assistantPrompt.ts"],"sourcesContent":["/**\n * Soft confirm-before-mutate guardrail for the assistant's api-calls (write)\n * mode: a describe-and-confirm instruction prepended to the user's TURN (not the\n * session system prompt, which would clobber the agent's api-calls behaviour).\n * This is ADVISORY — the model is asked, not made. What holds a write is the\n * sandbox: since 2026-09-07 it refuses the mutation and keeps it pending until\n * the user presses Approve on the pending-write card, behind the admin gate and\n * the consent dialog. This text shapes what the model says before that card\n * appears. Only the agent receives the prepended text — the user-facing message\n * bubble keeps the raw content.\n */\n\nimport type { AssistantMode } from '@/types/assistant';\n\n/**\n * Marks where our instructions stop and the user's words begin. Exactly one may\n * exist in a prompt, and it must be last — see `buildPromptForMode`.\n */\nexport const USER_REQUEST_DELIMITER = '--- User request ---';\n\nexport const API_CALLS_CONFIRM_PREAMBLE = [\n \"You are in api-calls mode for HealthyBowl and can run GraphQL queries and mutations on the user's behalf.\",\n 'Before performing ANY write (create, update, delete — any mutation):',\n '1. State exactly what you are about to change (entity, fields, and values).',\n '2. Ask the user to confirm, and WAIT for an explicit \"yes\"/\"confirm\" before executing it.',\n 'Read-only queries may run without confirmation. Confirm each write separately; never batch mutations behind a single confirmation.',\n '',\n USER_REQUEST_DELIMITER,\n].join('\\n');\n\n/**\n * Ask for the reply in the user's language (BOFF-7107).\n *\n * Nothing else does. The sandbox system prompt carries no language instruction,\n * the grounding documentation is entirely in English, and the persona insists on\n * grounding in it — so every force in the session pushes the answer towards\n * English regardless of what the user wrote. The model's tendency to mirror the\n * input is the only thing resisting that, and it is being outvoted.\n *\n * Three deliberate choices:\n *\n * - **The user's own language wins over the UI language.** The chrome being in\n * English says nothing about the person typing Tamil into it; treating the\n * locale as an instruction rather than a default would be the actual bug.\n * - **Translate the docs, do not switch to their language.** This is the clause\n * that matters. Without it a grounded answer drifts back to English mid-reply\n * simply because the source material is English.\n * - **Prepended per TURN, not sent as `system`.** The transport's `system` field\n * REPLACES the whole mode prompt, which would silently delete the docs and\n * api-calls instructions along with it.\n */\n/**\n * The instruction lines only — deliberately WITHOUT the delimiter.\n *\n * The delimiter marks where our instructions stop and the user's words begin, so\n * exactly one may exist and it must be last. Emitting it here too put a second\n * one mid-prompt, which left the api-calls safety instructions sitting *after* a\n * \"User request\" marker — i.e. presented to the model as though the user had\n * written them. `buildPromptForMode` owns placing it, once.\n */\n/**\n * Told to the model when the turn was SPOKEN rather than typed.\n *\n * Speech recognition does not fail uniformly — it fails on specific words, and\n * the ones it fails on here are predictable: English technical terms, product\n * and crop names, and numbers spoken inside an Indic sentence. A recogniser set\n * to `ta-IN` has no good model for \"urea\", \"pH\" or \"NPK\", so a Tamil sentence\n * comes back mostly right with a few words wrong. That is exactly the report:\n * \"some word some times\".\n *\n * The model is far better placed to repair that than the recogniser is, because\n * it has the farming context — but only if it is TOLD the text was dictated.\n * Otherwise it answers the garbled word literally, which is what makes the\n * assistant look like it misunderstood.\n *\n * ★ The refusal to guess is the important half. Charitable interpretation is\n * right for a mangled verb and dangerous for a mangled QUANTITY: this is\n * agriculture, and a dose or a unit that the recogniser mis-heard must be asked\n * about, not inferred. One extra question costs a few seconds; a wrong dose\n * costs a crop.\n */\nconst DICTATION_PREAMBLE = [\n 'This message was DICTATED using speech recognition, so some words may be mis-heard.',\n 'Errors cluster on English technical terms, product and crop names, and numbers spoken inside a sentence in another language.',\n 'Read the message for INTENT rather than literally: where a word is clearly a recognition error, infer what was meant from the agricultural context instead of answering the garbled word.',\n 'But do NOT guess when a mis-heard word would change what is being asked — a crop, a chemical, a quantity or a unit. Ask one short clarifying question instead. A wrong dose is far worse than an extra question.',\n].join('\\n');\n\n/**\n * Told to the model when its answer will be SPOKEN ALOUD, not read.\n *\n * The assistant was never told this, so it replied the way it replies in chat:\n * documentation-style markdown with `##` headings, `**bold**` and long\n * enumerated sections. In the chat panel that renders correctly. In the voice\n * panel it is read aloud AND shown as a caption, where the syntax is literal\n * and the length is unusable — the operator screenshotted a live session whose\n * caption was a wall of \"### **Budget Planning Features:**\".\n *\n * ★ This is the fix at SOURCE. Stripping markdown at render time is a\n * necessary backstop, but it cannot shorten a 500-word answer that was never\n * meant to be listened to. A spoken reply has to be short because the listener\n * cannot skim it.\n */\nconst VOICE_REPLY_PREAMBLE = [\n 'Your answer will be SPOKEN ALOUD and shown as a live caption, not read as a document.',\n 'Write plain conversational sentences. Use NO markdown whatsoever: no #, ##, ###, no **bold**, no bullet or numbered lists, no tables, no code fences.',\n 'Keep it SHORT — normally one to four sentences. The listener cannot skim, so a long answer is worse than an incomplete one.',\n 'If the full answer is genuinely long, give the useful part first and offer to go deeper, rather than listing every option.',\n 'Speak numbers, units and quantities the way a person says them.',\n].join('\\n');\n\nexport function buildLanguagePreamble(languageName: string, isExplicitChoice = false): string {\n return [\n `Answer in ${languageName}.`,\n // The mirror clause is right for a DEFAULT and wrong for a CHOICE.\n //\n // Derived from the interface language it is only a guess, and the language\n // the user actually wrote in is better evidence. But once they have picked a\n // language deliberately, \"what they wrote in wins\" silently overrides them —\n // and it does so hardest for people who TYPE, since a typed English question\n // would come back in English no matter what they selected. That makes the\n // preference inert for exactly the users who cannot dictate.\n isExplicitChoice\n ? `The user has chosen ${languageName} deliberately: answer in it even when their message is written in another language.`\n : 'If the user writes in a different language, answer in THAT language instead — what they wrote in always wins.',\n 'Your documentation and tool output are in English: translate what you quote from them rather than switching language.',\n ].join('\\n');\n}\n\n/**\n * `languageName` is the human name of the user's language (\"Tamil\"), not a code:\n * a code invites the model to answer *about* the tag instead of *in* it.\n * Omitted (or empty) leaves the prompt untouched, so a caller without locale\n * context behaves exactly as before.\n *\n * Order is load-bearing: instructions, then the delimiter, then the user's text.\n * The language preamble goes FIRST so the api-calls preamble keeps its own\n * delimiter adjacent to the content it introduces.\n */\nexport function buildPromptForMode(\n mode: AssistantMode,\n content: string,\n languageName?: string,\n isExplicitChoice = false,\n dictated = false\n): string {\n // Dictation goes AFTER the language lines and before the delimiter: it is an\n // instruction about the user's text, so it belongs with the instructions, not\n // inside them. Defaults to false, so every typed turn is byte-identical to\n // before — the composer's own dictation is excluded deliberately, because the\n // user can read and edit that text before sending it.\n const preamble = [\n languageName ? buildLanguagePreamble(languageName, isExplicitChoice) : '',\n dictated ? DICTATION_PREAMBLE : '',\n // A dictated turn is a SPOKEN conversation, so the reply is spoken too.\n dictated ? VOICE_REPLY_PREAMBLE : '',\n ]\n .filter(Boolean)\n .join('\\n\\n');\n const language = preamble ? `${preamble}\\n\\n` : '';\n if (mode === 'api-calls') return `${language}${API_CALLS_CONFIRM_PREAMBLE}\\n${content}`;\n return language ? `${language}${USER_REQUEST_DELIMITER}\\n${content}` : content;\n}\n"],"mappings":";AAkBA,IAAa,IAAyB,wBAEzB,IAA6B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAqDL,IAAqB;CACzB;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI,GAiBL,IAAuB;CAC3B;CACA;CACA;CACA;CACA;AACF,EAAE,KAAK,IAAI;AAEX,SAAgB,EAAsB,GAAsB,IAAmB,IAAe;CAC5F,OAAO;EACL,aAAa,EAAa;EAS1B,IACI,uBAAuB,EAAa,uFACpC;EACJ;CACF,EAAE,KAAK,IAAI;AACb;AAYA,SAAgB,EACd,GACA,GACA,GACA,IAAmB,IACnB,IAAW,IACH;CAMR,IAAM,IAAW;EACf,IAAe,EAAsB,GAAc,CAAgB,IAAI;EACvE,IAAW,IAAqB;EAEhC,IAAW,IAAuB;CACpC,EACG,OAAO,OAAO,EACd,KAAK,MAAM,GACR,IAAW,IAAW,GAAG,EAAS,QAAQ;CAEhD,OADI,MAAS,cAAoB,GAAG,IAAW,EAA2B,IAAI,MACvE,IAAW,GAAG,IAAW,EAAuB,IAAI,MAAY;AACzE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.919.3",
3
+ "version": "2026.919.5",
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.905.2",
51
+ "@burdenoff/fe-libs": "2026.917.2",
52
52
  "@burdenoff/planmagnet-fe-sdk": "2026.831.1",
53
53
  "@tanstack/react-query": "^5.90.16",
54
54
  "clsx": "^2.1.1",
@@ -1 +0,0 @@
1
- import "react";