@burdenoff/microfe-healthybowl 2026.629.1 → 2026.629.2
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,4 +1,4 @@
|
|
|
1
|
-
var e =
|
|
1
|
+
var e = typeof window < "u" && window.location.hostname !== "app.gethealthybowl.com", t = {
|
|
2
2
|
id: "general",
|
|
3
3
|
label: "General",
|
|
4
4
|
description: "General help with HealthyBowl — crops, livestock, the marketplace, and farm operations",
|
|
@@ -8,7 +8,7 @@ var e = [{
|
|
|
8
8
|
"How does the marketplace work?",
|
|
9
9
|
"What government schemes can I apply for?"
|
|
10
10
|
]
|
|
11
|
-
}, {
|
|
11
|
+
}, n = e ? [t, {
|
|
12
12
|
id: "api-calls",
|
|
13
13
|
label: "Actions",
|
|
14
14
|
description: "Let the assistant take actions for you — add crops, log harvests, update records. It describes what it will do and asks before changing anything.",
|
|
@@ -20,8 +20,8 @@ var e = [{
|
|
|
20
20
|
],
|
|
21
21
|
requiresAdmin: !0,
|
|
22
22
|
writeCapable: !0
|
|
23
|
-
}];
|
|
23
|
+
}] : [t];
|
|
24
24
|
//#endregion
|
|
25
|
-
export { e as ASSISTANT_USECASE_CONFIG };
|
|
25
|
+
export { e as API_CALLS_MODE_ENABLED, n as ASSISTANT_USECASE_CONFIG };
|
|
26
26
|
|
|
27
27
|
//# sourceMappingURL=assistantUsecases.js.map
|
|
@@ -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' | '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` mode. It is admin-gated, shows\n * a one-time confirm dialog, and prepends a describe-and-confirm instruction —\n * but the in-sandbox agent still auto-executes (there is no hard server-side\n * confirmation yet, per the ai-assistant agent).
|
|
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' | '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` mode. It is admin-gated, shows\n * a one-time confirm dialog, and prepends a describe-and-confirm instruction —\n * but the in-sandbox agent still auto-executes (there is no hard server-side\n * confirmation yet, per the ai-assistant agent). So it is held OFF on the\n * PRODUCTION app (`app.gethealthybowl.com`) and stays ON for alpha\n * (`alphaapp.gethealthybowl.com`) + local dev, until the agent-side hard confirm\n * lands. Flipping it does not touch the transport, which already supports the mode.\n *\n * Why a RUNTIME hostname check and not `import.meta.env.VITE_*`: this microfe\n * ships a PREBUILT dist (the app bundles dist/index.js, not src), so Vite bakes\n * any `import.meta.env` at MICROFE build time — where the env is never 'prod' —\n * making a build-time env flag unable to distinguish prod from alpha. The\n * runtime `window.location.hostname` is the reliable signal in the browser.\n */\nconst PROD_APP_HOST = 'app.gethealthybowl.com';\nexport const API_CALLS_MODE_ENABLED = typeof window !== 'undefined' && window.location.hostname !== PROD_APP_HOST;\n\nconst GENERAL: AssistantUsecase = {\n id: 'general',\n label: 'General',\n description: 'General help with HealthyBowl — crops, livestock, the marketplace, and farm operations',\n suggestions: [\n 'How do I add a new crop?',\n 'Explain the livestock health tracker',\n 'How does the marketplace work?',\n 'What government schemes can I apply for?',\n ],\n};\n\nconst API_CALLS: AssistantUsecase = {\n id: 'api-calls',\n label: 'Actions',\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. Phase 1 = general; phase 2 adds api-calls (admin-\n// gated + guarded). The mode selector filters this further by role at runtime.\nexport const ASSISTANT_USECASE_CONFIG: readonly AssistantUsecase[] = API_CALLS_MODE_ENABLED\n ? [GENERAL, API_CALLS]\n : [GENERAL];\n"],"mappings":"AA+CA,IAAa,IAAyB,OAAO,SAAW,OAAe,OAAO,SAAS,aADjE,0BAGhB,IAA4B;CAChC,IAAI;CACJ,OAAO;CACP,aAAa;CACb,aAAa;EACX;EACA;EACA;EACA;EACD;CACF,EAmBY,IAAwD,IACjE,CAAC,GAlB+B;CAClC,IAAI;CACJ,OAAO;CACP,aACE;CACF,aAAa;EACX;EACA;EACA;EACA;EACD;CACD,eAAe;CACf,cAAc;CACf,CAKuB,GACpB,CAAC,EAAQ"}
|
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { API_CALLS_MODE_ENABLED as e } from "../config/assistantUsecases.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import { graphqlFetch as r } from "@burdenoff/fe-libs/shared/graphql";
|
|
3
4
|
//#region src/hooks/useAssistantApiAccess.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
return
|
|
8
|
-
if (!
|
|
9
|
-
|
|
5
|
+
var i = "query AssistantMyRoles($scopeId: String!) {\n myRoles(scopeId: $scopeId) {\n isAdmin\n isOwner\n }\n}";
|
|
6
|
+
function a(a) {
|
|
7
|
+
let o = e && !!a, [s, c] = n(!1), [l, u] = n(o);
|
|
8
|
+
return t(() => {
|
|
9
|
+
if (!o) {
|
|
10
|
+
c(!1), u(!1);
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
let e = !1;
|
|
13
|
-
return
|
|
14
|
+
return u(!0), r({
|
|
14
15
|
gateway: "global",
|
|
15
|
-
query:
|
|
16
|
-
variables: { scopeId:
|
|
16
|
+
query: i,
|
|
17
|
+
variables: { scopeId: a },
|
|
17
18
|
suppressGlobalErrorEvent: !0
|
|
18
19
|
}).then((t) => {
|
|
19
20
|
if (e) return;
|
|
20
21
|
let n = t.data?.myRoles;
|
|
21
|
-
|
|
22
|
+
c(!!(n?.isOwner || n?.isAdmin));
|
|
22
23
|
}).catch(() => {
|
|
23
|
-
e ||
|
|
24
|
+
e || c(!1);
|
|
24
25
|
}).finally(() => {
|
|
25
|
-
e ||
|
|
26
|
+
e || u(!1);
|
|
26
27
|
}), () => {
|
|
27
28
|
e = !0;
|
|
28
29
|
};
|
|
29
|
-
}, [
|
|
30
|
-
canUseApiCalls:
|
|
31
|
-
loading:
|
|
30
|
+
}, [o, a]), {
|
|
31
|
+
canUseApiCalls: s,
|
|
32
|
+
loading: l
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
//#endregion
|
|
35
|
-
export {
|
|
36
|
+
export { a as useAssistantApiAccess };
|
|
36
37
|
|
|
37
38
|
//# sourceMappingURL=useAssistantApiAccess.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantApiAccess.js","names":[],"sources":["../../src/hooks/useAssistantApiAccess.ts"],"sourcesContent":["/**\n * Resolves whether the current user may use the write-capable `api-calls`\n * assistant mode.\n *\n * That mode mints a per-sandbox OAuth app under the caller's identity\n * (createApp/createApplication in wspace-sandbox-svc), which is RBAC-gated to a\n * global Owner/Admin — a non-admin would only discover this as a FORBIDDEN at\n * provision time. So we gate the UI on the same signal up front, via the global\n * gateway's `myRoles(scopeId)` query (`@rbac(public: true)`, auth-only, returns\n * `isAdmin`/`isOwner` directly — no extra provider wiring needed).\n *\n * Fails CLOSED: an error, an empty org scope, or the master flag being off all\n * resolve to `canUseApiCalls = false`, so the mode stays hidden unless the user\n * is provably an org admin.\n */\n\nimport { useEffect, useState } from 'react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { API_CALLS_MODE_ENABLED } from '@/config/assistantUsecases';\n\nconst MY_ROLES_QUERY = `query AssistantMyRoles($scopeId: String!) {\n myRoles(scopeId: $scopeId) {\n isAdmin\n isOwner\n }\n}`;\n\ninterface MyRolesData {\n myRoles: { isAdmin: boolean; isOwner: boolean };\n}\n\nexport interface AssistantApiAccess {\n /** True only for a confirmed global Owner/Admin (and when the mode is enabled). */\n canUseApiCalls: boolean;\n /** True while the role check is in flight. */\n loading: boolean;\n}\n\nexport function useAssistantApiAccess(scopeId: string): AssistantApiAccess {\n const enabled = API_CALLS_MODE_ENABLED && Boolean(scopeId);\n const [canUseApiCalls, setCanUseApiCalls] = useState(false);\n const [loading, setLoading] = useState(enabled);\n\n useEffect(() => {\n if (!enabled) {\n setCanUseApiCalls(false);\n setLoading(false);\n return;\n }\n\n let cancelled = false;\n setLoading(true);\n\n graphqlFetch<MyRolesData>({\n gateway: 'global',\n query: MY_ROLES_QUERY,\n variables: { scopeId },\n // The gate fails closed on its own; don't surface a global error toast.\n suppressGlobalErrorEvent: true,\n })\n .then((result) => {\n if (cancelled) return;\n const roles = result.data?.myRoles;\n setCanUseApiCalls(Boolean(roles?.isOwner || roles?.isAdmin));\n })\n .catch(() => {\n if (!cancelled) setCanUseApiCalls(false);\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n\n return () => {\n cancelled = true;\n };\n }, [enabled, scopeId]);\n\n return { canUseApiCalls, loading };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAssistantApiAccess.js","names":[],"sources":["../../src/hooks/useAssistantApiAccess.ts"],"sourcesContent":["/**\n * Resolves whether the current user may use the write-capable `api-calls`\n * assistant mode.\n *\n * That mode mints a per-sandbox OAuth app under the caller's identity\n * (createApp/createApplication in wspace-sandbox-svc), which is RBAC-gated to a\n * global Owner/Admin — a non-admin would only discover this as a FORBIDDEN at\n * provision time. So we gate the UI on the same signal up front, via the global\n * gateway's `myRoles(scopeId)` query (`@rbac(public: true)`, auth-only, returns\n * `isAdmin`/`isOwner` directly — no extra provider wiring needed).\n *\n * Fails CLOSED: an error, an empty org scope, or the master flag being off all\n * resolve to `canUseApiCalls = false`, so the mode stays hidden unless the user\n * is provably an org admin.\n */\n\nimport { useEffect, useState } from 'react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { API_CALLS_MODE_ENABLED } from '@/config/assistantUsecases';\n\nconst MY_ROLES_QUERY = `query AssistantMyRoles($scopeId: String!) {\n myRoles(scopeId: $scopeId) {\n isAdmin\n isOwner\n }\n}`;\n\ninterface MyRolesData {\n myRoles: { isAdmin: boolean; isOwner: boolean };\n}\n\nexport interface AssistantApiAccess {\n /** True only for a confirmed global Owner/Admin (and when the mode is enabled). */\n canUseApiCalls: boolean;\n /** True while the role check is in flight. */\n loading: boolean;\n}\n\nexport function useAssistantApiAccess(scopeId: string): AssistantApiAccess {\n const enabled = API_CALLS_MODE_ENABLED && Boolean(scopeId);\n const [canUseApiCalls, setCanUseApiCalls] = useState(false);\n const [loading, setLoading] = useState(enabled);\n\n useEffect(() => {\n if (!enabled) {\n setCanUseApiCalls(false);\n setLoading(false);\n return;\n }\n\n let cancelled = false;\n setLoading(true);\n\n graphqlFetch<MyRolesData>({\n gateway: 'global',\n query: MY_ROLES_QUERY,\n variables: { scopeId },\n // The gate fails closed on its own; don't surface a global error toast.\n suppressGlobalErrorEvent: true,\n })\n .then((result) => {\n if (cancelled) return;\n const roles = result.data?.myRoles;\n setCanUseApiCalls(Boolean(roles?.isOwner || roles?.isAdmin));\n })\n .catch(() => {\n if (!cancelled) setCanUseApiCalls(false);\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n\n return () => {\n cancelled = true;\n };\n }, [enabled, scopeId]);\n\n return { canUseApiCalls, loading };\n}\n"],"mappings":";;;;AAoBA,IAAM,IAAiB;AAkBvB,SAAgB,EAAsB,GAAqC;CACzE,IAAM,IAAU,KAA0B,EAAQ,GAC5C,CAAC,GAAgB,KAAqB,EAAS,GAAM,EACrD,CAAC,GAAS,KAAc,EAAS,EAAQ;AAoC/C,QAlCA,QAAgB;AACd,MAAI,CAAC,GAAS;AAEZ,GADA,EAAkB,GAAM,EACxB,EAAW,GAAM;AACjB;;EAGF,IAAI,IAAY;AAsBhB,SArBA,EAAW,GAAK,EAEhB,EAA0B;GACxB,SAAS;GACT,OAAO;GACP,WAAW,EAAE,YAAS;GAEtB,0BAA0B;GAC3B,CAAC,CACC,MAAM,MAAW;AAChB,OAAI,EAAW;GACf,IAAM,IAAQ,EAAO,MAAM;AAC3B,KAAkB,GAAQ,GAAO,WAAW,GAAO,SAAS;IAC5D,CACD,YAAY;AACX,GAAK,KAAW,EAAkB,GAAM;IACxC,CACD,cAAc;AACb,GAAK,KAAW,EAAW,GAAM;IACjC,QAES;AACX,OAAY;;IAEb,CAAC,GAAS,EAAQ,CAAC,EAEf;EAAE;EAAgB;EAAS"}
|
package/package.json
CHANGED