@burdenoff/microfe-healthybowl 2026.904.29 → 2026.904.31
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":"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;
|
|
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 // ★★ The user must never see this fail. Metering is best-effort by\n // contract — the answer is already on screen — but `graphqlFetch`\n // dispatches a GLOBAL error event on any non-2xx, and the app's handler\n // turns that into a red toast. Catching the rejection here (below) stops\n // the throw; it does NOT stop the toast, which is fired from inside\n // `graphqlFetch` before the promise ever rejects.\n //\n // So a farmer would read a correct answer and then, ~200ms later, get\n // \"Forbidden\" or a raw GraphQL field error across the screen — worst\n // during the hours-long supergraph propagation window after a schema\n // change, i.e. exactly when this mutation is most likely to 400.\n //\n // Every comparable best-effort call in fe-libs sets this\n // (`useWorkspaceWriteAccess`, `useAssistantApiAccess`,\n // `useAssistantAttachments`, `gatewayClient`); this one was the outlier.\n suppressGlobalErrorEvent: true,\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;GAgBA,0BAA0B;EAC5B,CAAC;CACH,SAAS,GAAO;EAId,QAAQ,KAAK,mDAAmD;GAC9D;GACA;GACA,OAAO,aAAiB,QAAQ,EAAM,UAAU,OAAO,CAAK;EAC9D,CAAC;CACH;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.31",
|
|
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.28",
|
|
52
52
|
"@burdenoff/planmagnet-fe-sdk": "2026.831.1",
|
|
53
53
|
"@tanstack/react-query": "^5.90.16",
|
|
54
54
|
"clsx": "^2.1.1",
|