@burdenoff/microfe-healthybowl 2026.904.22 → 2026.904.24
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/AssistantChatArea.js +5 -5
- package/dist/hooks/useWorkspaceWriteAccess.js +6 -38
- package/dist/hooks/useWorkspaceWriteAccess.js.map +1 -1
- package/dist/utils/aiCredits.js +7 -9
- package/dist/utils/aiCredits.js.map +1 -1
- package/dist/utils/quotaUtils.js +2 -38
- package/package.json +2 -2
- package/dist/utils/quotaUtils.js.map +0 -1
|
@@ -18,8 +18,8 @@ import { useVoiceSession as ue } from "../../hooks/useVoiceSession.js";
|
|
|
18
18
|
import { useAssistantApiAccess as de } from "../../hooks/useAssistantApiAccess.js";
|
|
19
19
|
import { useWorkspaceWriteAccess as fe } from "../../hooks/useWorkspaceWriteAccess.js";
|
|
20
20
|
import { useConversationTurns as pe } from "../../hooks/useConversationTurns.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
21
|
+
import { dispatchAssistantQuotaExhausted as me, notifyAiCreditsUpdated as he } from "../../utils/aiCredits.js";
|
|
22
|
+
import { isQuotaExhaustedError as ge } from "../../utils/quotaUtils.js";
|
|
23
23
|
import { buildPromptForMode as _e } from "../../utils/assistantPrompt.js";
|
|
24
24
|
import { isMultimodalBodyRejection as ve, isRecoverableAssistantError as ye } from "../../utils/assistantTransportErrors.js";
|
|
25
25
|
import { isTurnInFlight as be } from "../../utils/assistantTurnState.js";
|
|
@@ -208,7 +208,7 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
208
208
|
}), te(x.content, le, l, e), x.tokens) {
|
|
209
209
|
R(p, v, { tokens: x.tokens });
|
|
210
210
|
try {
|
|
211
|
-
await s(A, h, l, x.tokens, g),
|
|
211
|
+
await s(A, h, l, x.tokens, g), he();
|
|
212
212
|
} catch {}
|
|
213
213
|
}
|
|
214
214
|
z(p, "complete", v, null);
|
|
@@ -222,8 +222,8 @@ var Ke = ({ visible: Ce = !0 }) => {
|
|
|
222
222
|
if (!h) throw Error("Assistant backend is unavailable without an active workspace context.");
|
|
223
223
|
await b();
|
|
224
224
|
} catch (t) {
|
|
225
|
-
if (q.current.invalidate(e.getState().sandboxesByMode[f]?.sandboxId ?? null),
|
|
226
|
-
|
|
225
|
+
if (q.current.invalidate(e.getState().sandboxesByMode[f]?.sandboxId ?? null), ge(t)) {
|
|
226
|
+
me("sandbox"), te("You've reached your sandbox limit on the current plan. Upgrade to start the AI assistant.", void 0, void 0, void 0, "en"), z(p, "error", v, null);
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
229
|
let n = t instanceof Error ? t.message : "Something went wrong";
|
|
@@ -1,46 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { graphqlFetch as n } from "@burdenoff/fe-libs/shared/graphql";
|
|
1
|
+
import { useWorkspaceWriteAccess as e } from "@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess";
|
|
3
2
|
//#region src/hooks/useWorkspaceWriteAccess.ts
|
|
4
|
-
var
|
|
3
|
+
var t = [
|
|
5
4
|
"healthybowl_crop",
|
|
6
5
|
"healthybowl_field",
|
|
7
6
|
"healthybowl_task"
|
|
8
|
-
]
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
return e(() => {
|
|
12
|
-
if (!a || !o) {
|
|
13
|
-
c("unknown");
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
let e = !1;
|
|
17
|
-
return c("unknown"), n({
|
|
18
|
-
gateway: "workspace",
|
|
19
|
-
query: i,
|
|
20
|
-
variables: { inputs: r.map((e) => ({
|
|
21
|
-
actorId: a,
|
|
22
|
-
actorType: "USER",
|
|
23
|
-
scopeId: o,
|
|
24
|
-
resourceType: e,
|
|
25
|
-
action: "create"
|
|
26
|
-
})) },
|
|
27
|
-
suppressGlobalErrorEvent: !0
|
|
28
|
-
}).then((t) => {
|
|
29
|
-
if (e) return;
|
|
30
|
-
let n = t.data?.checkPermissions;
|
|
31
|
-
if (!Array.isArray(n) || n.length === 0) {
|
|
32
|
-
c("unknown");
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
c(n.some((e) => e.allowed) ? "granted" : "denied");
|
|
36
|
-
}).catch(() => {
|
|
37
|
-
e || c("unknown");
|
|
38
|
-
}), () => {
|
|
39
|
-
e = !0;
|
|
40
|
-
};
|
|
41
|
-
}, [a, o]), s;
|
|
7
|
+
];
|
|
8
|
+
function n(n, r) {
|
|
9
|
+
return e(n, r, t);
|
|
42
10
|
}
|
|
43
11
|
//#endregion
|
|
44
|
-
export {
|
|
12
|
+
export { n as useWorkspaceWriteAccess };
|
|
45
13
|
|
|
46
14
|
//# sourceMappingURL=useWorkspaceWriteAccess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWorkspaceWriteAccess.js","names":[],"sources":["../../src/hooks/useWorkspaceWriteAccess.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"useWorkspaceWriteAccess.js","names":[],"sources":["../../src/hooks/useWorkspaceWriteAccess.ts"],"sourcesContent":["/**\n * HealthyBowl's write-access probe.\n *\n * ★ The mechanism moved to `fe-libs/shared/assistant`; the RESOURCE TYPES stay\n * here, because which resources prove \"this user can write in this workspace\"\n * is the product's answer. The shared hook takes them with no default, so\n * another product cannot accidentally probe crops.\n */\nimport { useWorkspaceWriteAccess as useShared } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\nexport type { WorkspaceWriteAccess } from '@burdenoff/fe-libs/shared/assistant/useWorkspaceWriteAccess';\n\n/**\n * Resources a Take-action turn is most likely to write. Not exhaustive — the\n * assistant can reach far more — but a representative probe.\n */\nconst PROBE_RESOURCES = ['healthybowl_crop', 'healthybowl_field', 'healthybowl_task'] as const;\n\nexport function useWorkspaceWriteAccess(actorId: string | null, workspaceId: string | null) {\n return useShared(actorId, workspaceId, PROBE_RESOURCES);\n}\n"],"mappings":";;AAeA,IAAM,IAAkB;CAAC;CAAoB;CAAqB;AAAkB;AAEpF,SAAgB,EAAwB,GAAwB,GAA4B;CAC1F,OAAO,EAAU,GAAS,GAAa,CAAe;AACxD"}
|
package/dist/utils/aiCredits.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PRODUCT as e } from "../services/assistantApi.js";
|
|
2
|
+
import { dispatchAssistantQuotaExhausted as t, notifyAiCreditsUpdated as n } from "@burdenoff/fe-libs/shared/assistant/aiCredits";
|
|
2
3
|
//#region src/utils/aiCredits.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
typeof window > "u" || window.dispatchEvent(new CustomEvent(t));
|
|
4
|
+
function r() {
|
|
5
|
+
n(e);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
let n = { kind: t };
|
|
10
|
-
window.dispatchEvent(new CustomEvent(e, { detail: n }));
|
|
7
|
+
function i(n) {
|
|
8
|
+
t(e, n);
|
|
11
9
|
}
|
|
12
10
|
//#endregion
|
|
13
|
-
export {
|
|
11
|
+
export { i as dispatchAssistantQuotaExhausted, r as notifyAiCreditsUpdated };
|
|
14
12
|
|
|
15
13
|
//# sourceMappingURL=aiCredits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiCredits.js","names":[],"sources":["../../src/utils/aiCredits.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"aiCredits.js","names":[],"sources":["../../src/utils/aiCredits.ts"],"sourcesContent":["/**\n * Re-export of the SHARED credits/quota event dispatchers, bound to this product.\n *\n * ★ The shared versions take the product namespace so two products in one page\n * cannot collide. Binding them here keeps every call site in this repo unchanged\n * and keeps the emitted names byte-identical: `healthybowl:quota-exhausted` and\n * `healthybowl:ai-credits-updated`.\n */\nimport {\n dispatchAssistantQuotaExhausted as dispatchShared,\n notifyAiCreditsUpdated as notifyShared,\n} from '@burdenoff/fe-libs/shared/assistant/aiCredits';\nimport type { QuotaKind } from '@burdenoff/fe-libs/shared/assistant/quota';\nimport { PRODUCT } from '@/services/assistantApi';\n\nexport function notifyAiCreditsUpdated(): void {\n notifyShared(PRODUCT);\n}\n\nexport function dispatchAssistantQuotaExhausted(kind: QuotaKind): void {\n dispatchShared(PRODUCT, kind);\n}\n"],"mappings":";;;AAeA,SAAgB,IAA+B;CAC7C,EAAa,CAAO;AACtB;AAEA,SAAgB,EAAgC,GAAuB;CACrE,EAAe,GAAS,CAAI;AAC9B"}
|
package/dist/utils/quotaUtils.js
CHANGED
|
@@ -1,38 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (!e || typeof e != "object") return;
|
|
4
|
-
let n = e[t];
|
|
5
|
-
return Array.isArray(n) ? n : void 0;
|
|
6
|
-
}
|
|
7
|
-
function t(e) {
|
|
8
|
-
let t = i(e);
|
|
9
|
-
return t ? t === "exhausted" : e instanceof Error && e.message.toLowerCase().includes("quota exhausted");
|
|
10
|
-
}
|
|
11
|
-
var n = {
|
|
12
|
-
QUOTA_EXHAUSTED: "exhausted",
|
|
13
|
-
QUOTA_NOT_PROVISIONED: "not-provisioned"
|
|
14
|
-
};
|
|
15
|
-
function r(t) {
|
|
16
|
-
if (!t || typeof t != "object") return [];
|
|
17
|
-
let r = [
|
|
18
|
-
t,
|
|
19
|
-
t.result,
|
|
20
|
-
t.networkError
|
|
21
|
-
], i = [];
|
|
22
|
-
for (let t of r) for (let n of e(t, "errors") ?? []) n.extensions?.code && i.push(n.extensions.code), n.extensions?.errorCode && i.push(n.extensions.errorCode);
|
|
23
|
-
let a = t.bodyText, o = t instanceof Error ? t.message : void 0;
|
|
24
|
-
for (let e of [a, o]) if (typeof e == "string") for (let t of Object.keys(n)) e.includes(t) && i.push(t);
|
|
25
|
-
return i;
|
|
26
|
-
}
|
|
27
|
-
function i(e) {
|
|
28
|
-
let t = r(e);
|
|
29
|
-
if (t.includes("QUOTA_NOT_PROVISIONED")) return "not-provisioned";
|
|
30
|
-
if (t.includes("QUOTA_EXHAUSTED")) return "exhausted";
|
|
31
|
-
let n = e?.statusCode;
|
|
32
|
-
return typeof n == "number" && n === 429 ? "exhausted" : null;
|
|
33
|
-
}
|
|
34
|
-
var a = "healthybowl:quota-exhausted";
|
|
35
|
-
//#endregion
|
|
36
|
-
export { a as QUOTA_EXHAUSTED_EVENT, t as isQuotaExhaustedError };
|
|
37
|
-
|
|
38
|
-
//# sourceMappingURL=quotaUtils.js.map
|
|
1
|
+
import { isQuotaExhaustedError as e } from "@burdenoff/fe-libs/shared/assistant/quota";
|
|
2
|
+
export { e as isQuotaExhaustedError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-healthybowl",
|
|
3
|
-
"version": "2026.904.
|
|
3
|
+
"version": "2026.904.24",
|
|
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.21",
|
|
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
|
-
{"version":3,"file":"quotaUtils.js","names":[],"sources":["../../src/utils/quotaUtils.ts"],"sourcesContent":["/**\n * Quota-error detection for the assistant's raw-fetch transport.\n *\n * The assistant talks to the wspace gateway over `fetch` (not Apollo), so it\n * can't rely on the Apollo error link. `isQuotaExhaustedError` inspects the\n * thrown error for the gateway's 429 / QUOTA_EXHAUSTED signal across the shapes\n * `executeSandboxGraphQL` surfaces (Error.message, `.statusCode`, `.result`).\n *\n * Only the assistant's two quota walls are modelled: `sandbox` (the\n * sandboxes-created @usage limit hit during provisioning) and `ai-credits`\n * (per-token budget).\n */\n\ntype GraphQLErrorLike = {\n message?: string;\n extensions?: {\n code?: string;\n errorCode?: string;\n };\n};\n\nfunction arrayOfErrorsAt(host: object | undefined, key: 'errors'): GraphQLErrorLike[] | undefined {\n if (!host || typeof host !== 'object') return undefined;\n const value = (host as Record<string, unknown>)[key];\n return Array.isArray(value) ? (value as GraphQLErrorLike[]) : undefined;\n}\n\n/**\n * Whether this error is an EXHAUSTED quota specifically.\n *\n * ★ BOFF-6302 — this used to match any HTTP 429, and a workspace with no assignment row is refused\n * `429 QUOTA_NOT_PROVISIONED`. That is not exhaustion: the farmer has not used anything up, their\n * plan was never granted, and \"you have reached your limit\" sends them to buy an upgrade that would\n * not unblock them. {@link classifyQuotaError} now owns the distinction and this delegates to it.\n */\nexport function isQuotaExhaustedError(error: unknown): boolean {\n const refusal = classifyQuotaError(error);\n if (refusal) return refusal === 'exhausted';\n\n // The one shape the classifier deliberately does not match: prose with no code in it. Kept for the\n // assistant's raw-fetch transport, which can surface a bare \"quota exhausted\" string.\n return error instanceof Error && error.message.toLowerCase().includes('quota exhausted');\n}\n\n/**\n * The two ways the gateway refuses a metered mutation. They are NOT the same thing and must not be\n * shown to a farmer with the same words (BOFF-6302).\n *\n * - `exhausted` — the workspace has the quota and has used it up. Deleting something, or upgrading,\n * fixes it. Actionable by the user.\n * - `not-provisioned` — the workspace has **no assignment row for that quota at all**, so the\n * gateway fails closed. Nothing the user does fixes it: they have not hit a limit, their plan was\n * never granted. Measured in prod 2026-08-13, this is why `createHealthyBowlFarm` returns\n * `429 QUOTA_NOT_PROVISIONED` on several workspaces — the core create path is simply dead there.\n *\n * ★ Keyed on `extensions.code`, never on the HTTP status or the message text. Both refusals are\n * `429`, so status alone cannot tell them apart — which is exactly how \"no active subscription\n * covers this\" would otherwise be reported to a farmer as \"you have reached your limit\".\n */\nexport type QuotaRefusal = 'exhausted' | 'not-provisioned';\n\nconst REFUSAL_BY_CODE: Record<string, QuotaRefusal> = {\n QUOTA_EXHAUSTED: 'exhausted',\n QUOTA_NOT_PROVISIONED: 'not-provisioned',\n};\n\n/** Every `extensions.code` reachable on an error, across the shapes Apollo and raw-fetch produce. */\nfunction codesIn(error: unknown): string[] {\n if (!error || typeof error !== 'object') return [];\n const hosts = [\n error as object,\n (error as { result?: object }).result,\n (error as { networkError?: object }).networkError,\n ];\n const codes: string[] = [];\n for (const host of hosts) {\n for (const e of arrayOfErrorsAt(host, 'errors') ?? []) {\n if (e.extensions?.code) codes.push(e.extensions.code);\n if (e.extensions?.errorCode) codes.push(e.extensions.errorCode);\n }\n }\n const bodyText = (error as { bodyText?: unknown }).bodyText;\n const message = error instanceof Error ? error.message : undefined;\n for (const text of [bodyText, message]) {\n if (typeof text !== 'string') continue;\n for (const code of Object.keys(REFUSAL_BY_CODE)) if (text.includes(code)) codes.push(code);\n }\n return codes;\n}\n\n/**\n * Which refusal this is, or null when the error is not a quota wall at all.\n *\n * `not-provisioned` wins when both appear: it is the more specific and the more serious of the two,\n * and telling someone to upgrade when their plan was never granted sends them to buy something that\n * would not help.\n */\nexport function classifyQuotaError(error: unknown): QuotaRefusal | null {\n const codes = codesIn(error);\n if (codes.includes('QUOTA_NOT_PROVISIONED')) return 'not-provisioned';\n if (codes.includes('QUOTA_EXHAUSTED')) return 'exhausted';\n // A bare 429 with no discernible code: the assistant's raw-fetch transport can surface one, and\n // exhaustion is the likelier cause. Deliberately last, so an explicit code always wins.\n const statusCode = (error as { statusCode?: unknown } | null)?.statusCode;\n if (typeof statusCode === 'number' && statusCode === 429) return 'exhausted';\n return null;\n}\n\nexport type QuotaKind = 'sandbox' | 'ai-credits' | 'generic';\n\n// Event the assistant dispatches on a quota wall. HealthyBowl does not yet\n// mount a listener (the chat area also surfaces the wall inline), so this is a\n// best-effort hook for a future upgrade dialog.\nexport const QUOTA_EXHAUSTED_EVENT = 'healthybowl:quota-exhausted';\n\nexport interface QuotaExhaustedEventDetail {\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