@burdenoff/microfe-botmanor 2026.1203.9 → 2026.1205.1
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/botlit/BotmanorRootInner.js +46 -50
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/pages/ToolApprovalsPage.d.ts +5 -2
- package/dist/botlit/pages/ToolApprovalsPage.js +18 -284
- package/dist/botlit/pages/ToolApprovalsPage.js.map +1 -1
- package/package.json +1 -1
- package/dist/botlit/providers/WorkspaceFlagScope.d.ts +0 -7
- package/dist/botlit/providers/WorkspaceFlagScope.js +0 -17
- package/dist/botlit/providers/WorkspaceFlagScope.js.map +0 -1
- package/dist/botlit/providers/workspaceFlagKeys.d.ts +0 -18
- package/dist/botlit/providers/workspaceFlagKeys.js +0 -8
- package/dist/botlit/providers/workspaceFlagKeys.js.map +0 -1
|
@@ -1,75 +1,71 @@
|
|
|
1
1
|
import { BotlitProvider as e } from "./providers/BotlitProvider.js";
|
|
2
2
|
import { QuotaGuard as t } from "./providers/QuotaGuard.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { ErrorBoundary as y } from "@burdenoff/fe-libs/shared/components";
|
|
3
|
+
import { BotlitRoutes as n } from "./BotlitRoutes.js";
|
|
4
|
+
import { RouteLoader as r } from "./components/RouteLoader.js";
|
|
5
|
+
import { useTr as i } from "../shared/hooks/useTr.js";
|
|
6
|
+
import { WorkspaceRequired as a } from "./components/WorkspaceRequired.js";
|
|
7
|
+
import { ConfirmActionBridge as o } from "./utils/confirmAction.js";
|
|
8
|
+
import { BOTMANOR_TOUR_PRODUCT_ID as s, botmanorTourRoutes as c } from "./tours/tourRoutes.js";
|
|
9
|
+
import { useEffect as l, useState as u } from "react";
|
|
10
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
|
+
import { useGatewayClient as p } from "@burdenoff/fe-libs/shared/graphql";
|
|
12
|
+
import { ApolloProvider as m } from "@apollo/client/react";
|
|
13
|
+
import { QueryClient as h, QueryClientProvider as g } from "@tanstack/react-query";
|
|
14
|
+
import { registerTourRouteCatalog as _ } from "@burdenoff/fe-libs/shared/tours";
|
|
15
|
+
import { ErrorBoundary as v } from "@burdenoff/fe-libs/shared/components";
|
|
17
16
|
// src/botlit/BotmanorRootInner.tsx
|
|
18
|
-
var
|
|
17
|
+
var y = 1e4, b = 2e3, x = new h({ defaultOptions: { queries: {
|
|
19
18
|
staleTime: 3e5,
|
|
20
19
|
retry: 1
|
|
21
|
-
} } }),
|
|
22
|
-
let
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
20
|
+
} } }), S = (h) => {
|
|
21
|
+
let S = i(), C = p("workspace"), w = !!C, [T, E] = u(!1), [D, O] = u(!1);
|
|
22
|
+
if (l(() => _(s, c(h.basePath)), [h.basePath]), l(() => {
|
|
23
|
+
if (w) return;
|
|
25
24
|
let e = setTimeout(() => {
|
|
26
|
-
|
|
27
|
-
},
|
|
25
|
+
E(!0);
|
|
26
|
+
}, y);
|
|
28
27
|
return () => clearTimeout(e);
|
|
29
|
-
}, [
|
|
30
|
-
if (
|
|
31
|
-
let e = setTimeout(() =>
|
|
28
|
+
}, [w]), l(() => {
|
|
29
|
+
if (h.workspaceId) return;
|
|
30
|
+
let e = setTimeout(() => O(!0), b);
|
|
32
31
|
return () => clearTimeout(e);
|
|
33
|
-
}, [
|
|
34
|
-
basePath:
|
|
35
|
-
navigate:
|
|
36
|
-
}) : /* @__PURE__ */
|
|
37
|
-
if (!
|
|
32
|
+
}, [h.workspaceId]), !h.workspaceId) return D ? /* @__PURE__ */ d(a, {
|
|
33
|
+
basePath: h.basePath,
|
|
34
|
+
navigate: h.navigate
|
|
35
|
+
}) : /* @__PURE__ */ d(r, { label: S("botlit.root.loadingWorkspace", "Loading your workspace…") });
|
|
36
|
+
if (!w) return T ? /* @__PURE__ */ d("div", {
|
|
38
37
|
className: "flex h-full min-h-[200px] w-full items-center justify-center p-6",
|
|
39
|
-
children: /* @__PURE__ */
|
|
38
|
+
children: /* @__PURE__ */ f("div", {
|
|
40
39
|
className: "text-center",
|
|
41
|
-
children: [/* @__PURE__ */
|
|
40
|
+
children: [/* @__PURE__ */ d("p", {
|
|
42
41
|
className: "mb-4 text-sm text-text-secondary",
|
|
43
|
-
children:
|
|
44
|
-
}), /* @__PURE__ */
|
|
42
|
+
children: S("botlit.root.connectError", "BotManor could not connect to the gateway. Please refresh the page or check your configuration.")
|
|
43
|
+
}), /* @__PURE__ */ d("button", {
|
|
45
44
|
type: "button",
|
|
46
45
|
onClick: () => window.location.reload(),
|
|
47
46
|
className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover",
|
|
48
|
-
children:
|
|
47
|
+
children: S("botlit.root.reload", "Reload Page")
|
|
49
48
|
})]
|
|
50
49
|
})
|
|
51
|
-
}) : /* @__PURE__ */
|
|
52
|
-
let
|
|
53
|
-
...
|
|
54
|
-
children: /* @__PURE__ */
|
|
50
|
+
}) : /* @__PURE__ */ d(r, {});
|
|
51
|
+
let k = !!h.basePath, A = /* @__PURE__ */ d(e, {
|
|
52
|
+
...h,
|
|
53
|
+
children: /* @__PURE__ */ d(t, { children: /* @__PURE__ */ d(n, {}) })
|
|
55
54
|
});
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
fallback: /* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ f(v, {
|
|
56
|
+
fallback: /* @__PURE__ */ d("div", {
|
|
58
57
|
className: "p-6 text-center text-text-secondary",
|
|
59
|
-
children:
|
|
58
|
+
children: S("botlit.root.loadFailed", "Something went wrong loading BotManor. Please refresh the page.")
|
|
60
59
|
}),
|
|
61
|
-
children: [/* @__PURE__ */
|
|
62
|
-
|
|
63
|
-
children: /* @__PURE__ */
|
|
64
|
-
client:
|
|
65
|
-
children: A
|
|
66
|
-
client: w,
|
|
67
|
-
children: j
|
|
68
|
-
})
|
|
60
|
+
children: [/* @__PURE__ */ d(o, {}), /* @__PURE__ */ d(g, {
|
|
61
|
+
client: x,
|
|
62
|
+
children: k ? A : /* @__PURE__ */ d(m, {
|
|
63
|
+
client: C,
|
|
64
|
+
children: A
|
|
69
65
|
})
|
|
70
66
|
})]
|
|
71
67
|
});
|
|
72
68
|
};
|
|
73
|
-
export {
|
|
69
|
+
export { S as BotmanorRootInner };
|
|
74
70
|
|
|
75
71
|
//# sourceMappingURL=BotmanorRootInner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotmanorRootInner.js","names":["CLIENT_READY_TIMEOUT_MS","WORKSPACE_SETTLE_MS","queryClient","QueryClient","BotmanorRootInner","tr","useTr","workspaceClient","useGatewayClient","clientReady","clientTimedOut","setClientTimedOut","useState","workspaceSettled","setWorkspaceSettled","useEffect","registerTourRouteCatalog","BOTMANOR_TOUR_PRODUCT_ID","botmanorTourRoutes","props","timer","WorkspaceRequired","RouteLoader","isIntegrated","content","BotlitProvider","QuotaGuard","BotlitRoutes","ErrorBoundary","ConfirmActionBridge","
|
|
1
|
+
{"version":3,"file":"BotmanorRootInner.js","names":["CLIENT_READY_TIMEOUT_MS","WORKSPACE_SETTLE_MS","queryClient","QueryClient","BotmanorRootInner","tr","useTr","workspaceClient","useGatewayClient","clientReady","clientTimedOut","setClientTimedOut","useState","workspaceSettled","setWorkspaceSettled","useEffect","registerTourRouteCatalog","BOTMANOR_TOUR_PRODUCT_ID","botmanorTourRoutes","props","timer","WorkspaceRequired","RouteLoader","isIntegrated","content","BotlitProvider","QuotaGuard","BotlitRoutes","ErrorBoundary","ConfirmActionBridge","QueryClientProvider","ApolloProvider"],"sources":["../../src/botlit/BotmanorRootInner.tsx"],"sourcesContent":["/**\n * BotManor Root — implementation\n * @module botlit\n *\n * Product pages live behind this lazy boundary. Workflow routes and SDK\n * lifecycle are owned by the app-shell WorkflowsRoot, shared with every host.\n */\n\nimport type { FC } from 'react';\nimport { useEffect, useState } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ApolloProvider } from '@apollo/client/react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport { BotlitProvider } from './providers/BotlitProvider';\nimport { QuotaGuard } from './providers/QuotaGuard';\nimport { BotlitRoutes } from './BotlitRoutes';\nimport { RouteLoader } from './components/RouteLoader';\nimport { useTr } from '../shared/hooks/useTr';\nimport { WorkspaceRequired } from './components/WorkspaceRequired';\nimport { ConfirmActionBridge } from './utils/confirmAction';\nimport type { BotmanorRootProps } from './types';\n\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { registerTourRouteCatalog } from '@burdenoff/fe-libs/shared/tours';\nimport { BOTMANOR_TOUR_PRODUCT_ID, botmanorTourRoutes } from './tours/tourRoutes';\n\n/** How long to wait for the shell's gateway clients before showing an error. */\nconst CLIENT_READY_TIMEOUT_MS = 10_000;\n\n/**\n * How long to keep showing the loading skeleton before concluding that the\n * shell really has no active workspace.\n *\n * The shell resolves org/workspace asynchronously and passes `workspaceId=\"\"`\n * until it lands, which is indistinguishable from \"this user has no\n * workspace\". Without this settle window the guided zero state would flash on\n * every cold load — a get-started screen appearing and vanishing reads as a\n * broken page, which is exactly what this component exists to avoid.\n */\nconst WORKSPACE_SETTLE_MS = 2_000;\n\n// Create a query client for this microfrontend\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 5 * 60 * 1000,\n retry: 1,\n },\n },\n});\n\nexport const BotmanorRootInner: FC<BotmanorRootProps> = (props) => {\n // NOTE: Navigation is now handled by the shell's NavRegistration.tsx\n // The shell manages all product submenu items in a centralized way\n\n // Product operations use the shell's authenticated workspace gateway client.\n const tr = useTr();\n const workspaceClient = useGatewayClient('workspace');\n const clientReady = Boolean(workspaceClient);\n const [clientTimedOut, setClientTimedOut] = useState(false);\n const [workspaceSettled, setWorkspaceSettled] = useState(false);\n\n // Name each BotManor screen for product tours (BOFF-15482). Without this the\n // shell resolves every screen under the mount path to one pageId.\n useEffect(\n () => registerTourRouteCatalog(BOTMANOR_TOUR_PRODUCT_ID, botmanorTourRoutes(props.basePath)),\n [props.basePath]\n );\n\n // Timeout fallback: if gateway clients are never provided (test env, shell\n // misconfiguration, auth failure before hydration), show an error rather than\n // spinning indefinitely.\n useEffect(() => {\n if (clientReady) return;\n const timer = setTimeout(() => {\n setClientTimedOut(true);\n }, CLIENT_READY_TIMEOUT_MS);\n return () => clearTimeout(timer);\n }, [clientReady]);\n\n // Give the shell a bounded window to resolve the active workspace before the\n // guided zero state is allowed to render. Cancelled the moment a workspace\n // arrives — a workspace that is already present never starts the timer.\n useEffect(() => {\n if (props.workspaceId) return;\n const timer = setTimeout(() => setWorkspaceSettled(true), WORKSPACE_SETTLE_MS);\n return () => clearTimeout(timer);\n }, [props.workspaceId]);\n\n // Without a workspace every BotManor query is unscoped and every write is\n // rejected — guide the user instead of rendering empty lists. Until the\n // settle window elapses we cannot tell \"still resolving\" from \"none\", so we\n // keep the same skeleton the shell was already showing.\n if (!props.workspaceId) {\n if (!workspaceSettled) {\n return <RouteLoader label={tr('botlit.root.loadingWorkspace', 'Loading your workspace…')} />;\n }\n return <WorkspaceRequired basePath={props.basePath} navigate={props.navigate} />;\n }\n\n // Don't render until clients are ready (same pattern as microfe-bigconsole)\n if (!clientReady) {\n if (clientTimedOut) {\n return (\n <div className=\"flex h-full min-h-[200px] w-full items-center justify-center p-6\">\n <div className=\"text-center\">\n <p className=\"mb-4 text-sm text-text-secondary\">\n {tr(\n 'botlit.root.connectError',\n 'BotManor could not connect to the gateway. Please refresh the page or check your configuration.'\n )}\n </p>\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text transition-colors hover:bg-action-primary-bg-hover\"\n >\n {tr('botlit.root.reload', 'Reload Page')}\n </button>\n </div>\n </div>\n );\n }\n // Same skeleton as the lazy-chunk fallback, so the content region never\n // switches loading idioms between first paint and the page rendering.\n return <RouteLoader />;\n }\n\n const isIntegrated = !!props.basePath;\n\n const content = (\n <BotlitProvider {...props}>\n {/* Every metered mutation that hits a plan limit opens one translated dialog. */}\n <QuotaGuard>\n <BotlitRoutes />\n </QuotaGuard>\n </BotlitProvider>\n );\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'botlit.root.loadFailed',\n 'Something went wrong loading BotManor. Please refresh the page.'\n )}\n </div>\n }\n >\n {/* Every confirmAction asks through fe-libs' useConfirm (BOFF-16859). */}\n <ConfirmActionBridge />\n <QueryClientProvider client={queryClient}>\n {isIntegrated ? (\n content\n ) : (\n <ApolloProvider client={workspaceClient}>{content}</ApolloProvider>\n )}\n </QueryClientProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAMA,IAA0B,KAY1BC,IAAsB,KAGtBC,IAAc,IAAIC,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW;CACX,OAAO;AACT,EACF,EACF,CAAC,GAEYC,KAA4C,MAAU;CAKjE,IAAMC,IAAKC,EAAM,GACXC,IAAkBC,EAAiB,WAAW,GAC9CC,IAAc,EAAQF,GACtB,CAACG,GAAgBC,KAAqBC,EAAS,EAAK,GACpD,CAACC,GAAkBC,KAAuBF,EAAS,EAAK;CAiC9D,IA7BAG,QACQC,EAAyBC,GAA0BC,EAAmBC,EAAM,QAAQ,CAAC,GAC3F,CAACA,EAAM,QAAQ,CACjB,GAKAJ,QAAgB;EACd,IAAIN,GAAa;EACjB,IAAMW,IAAQ,iBAAiB;GAC7B,EAAkB,EAAI;EACxB,GAAGpB,CAAuB;EAC1B,aAAa,aAAaoB,CAAK;CACjC,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|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The approvals inbox: tool calls from agent chats and from stewards, gated on
|
|
4
|
+
* `botmanor-policy:read`. Stewards are generally available, so no feature
|
|
5
|
+
* flag picks between this and the older agent-chat-only queue.
|
|
6
|
+
*/
|
|
4
7
|
export declare const ToolApprovalsPage: FC;
|
|
@@ -1,292 +1,26 @@
|
|
|
1
1
|
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
2
|
import { PageLayout as t } from "../components/PageLayout.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useDecideToolApproval as d, useToolApprovals as f } from "../hooks/useToolApprovals.js";
|
|
10
|
-
import { useBotlit as p } from "../providers/BotlitProvider.js";
|
|
11
|
-
import { formatRelativeTime as m } from "../utils/formatters.js";
|
|
12
|
-
import { BOTMANOR_PERMISSIONS as h } from "../permissions/botmanorPermissions.js";
|
|
13
|
-
import { BotmanorPermissionGate as g, useBotmanorPermissionDecision as _ } from "../permissions/useBotmanorPermissions.js";
|
|
14
|
-
import { useState as v } from "react";
|
|
15
|
-
import { PagePurpose as y, ResponsiveDialog as b, ResponsiveDialogContent as x, ResponsiveDialogDescription as S, ResponsiveDialogFooter as C, ResponsiveDialogHeader as w, ResponsiveDialogTitle as T, Textarea as E } from "@burdenoff/fe-libs/ui";
|
|
16
|
-
import { jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
17
|
-
import { useFeatureFlag as k } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
18
|
-
import { ArrowLeft as A, CheckCircle2 as j, ShieldAlert as M, XCircle as N } from "lucide-react";
|
|
19
|
-
import { toast as P } from "sonner";
|
|
3
|
+
import { EmptyState as n } from "../components/EmptyState.js";
|
|
4
|
+
import { StewardApprovalsInbox as r } from "../components/StewardApprovalsInbox.js";
|
|
5
|
+
import { useBotlit as i } from "../providers/BotlitProvider.js";
|
|
6
|
+
import { BOTMANOR_PERMISSIONS as a } from "../permissions/botmanorPermissions.js";
|
|
7
|
+
import { useBotmanorPermissionDecision as o } from "../permissions/useBotmanorPermissions.js";
|
|
8
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
20
9
|
// src/botlit/pages/ToolApprovalsPage.tsx
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} catch {
|
|
28
|
-
return String(e);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
var L = ({ request: t }) => {
|
|
32
|
-
let n = e();
|
|
33
|
-
return /* @__PURE__ */ O("div", {
|
|
34
|
-
className: "space-y-2 text-sm",
|
|
35
|
-
children: [
|
|
36
|
-
t.userMessage && /* @__PURE__ */ O("p", {
|
|
37
|
-
className: "break-words",
|
|
38
|
-
children: [/* @__PURE__ */ O("span", {
|
|
39
|
-
className: "text-text-secondary",
|
|
40
|
-
children: [n("botlit.toolApprovals.userAsked", "User asked:"), " "]
|
|
41
|
-
}), t.userMessage]
|
|
42
|
-
}),
|
|
43
|
-
/* @__PURE__ */ D("div", {
|
|
44
|
-
className: "flex flex-wrap gap-1",
|
|
45
|
-
children: t.reasons.map((e) => /* @__PURE__ */ D(s, {
|
|
46
|
-
variant: "outline",
|
|
47
|
-
children: e
|
|
48
|
-
}, e))
|
|
49
|
-
}),
|
|
50
|
-
/* @__PURE__ */ D("pre", {
|
|
51
|
-
className: "text-xs bg-bg-sunken rounded-md p-2 overflow-x-auto max-h-48 whitespace-pre-wrap break-all",
|
|
52
|
-
children: I(t.arguments)
|
|
53
|
-
})
|
|
54
|
-
]
|
|
55
|
-
});
|
|
56
|
-
}, R = () => {
|
|
57
|
-
let l = e(), { navigateTo: u, currentUser: _ } = p(), k = f({
|
|
58
|
-
status: "PENDING",
|
|
59
|
-
source: "AGENT_CHAT"
|
|
60
|
-
}), I = f({ source: "AGENT_CHAT" }), { decide: R, pendingId: z } = d(), [B, V] = v(null), [H, U] = v(""), W = I.data.filter((e) => e.status !== "PENDING").slice(0, 20), G = (e) => e && e === _?.id ? l("botlit.toolApprovals.you", "you") : e ?? "—", K = () => {
|
|
61
|
-
V(null), U("");
|
|
62
|
-
}, q = async () => {
|
|
63
|
-
if (B) try {
|
|
64
|
-
await R(B.request.id, B.decision, H), P.success(B.decision === "APPROVE" ? l("botlit.toolApprovals.toast.approved", "Approved — the tool is running and the agent will answer in the conversation") : l("botlit.toolApprovals.toast.denied", "Denied — the user is told it was not run")), K(), await Promise.all([k.refetch(), I.refetch()]);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
P.error(e instanceof Error ? e.message : l("botlit.toolApprovals.toast.error", "Could not record the decision"));
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return /* @__PURE__ */ O(t, {
|
|
70
|
-
title: /* @__PURE__ */ O("div", {
|
|
71
|
-
className: "flex items-center gap-3",
|
|
72
|
-
children: [/* @__PURE__ */ D(o, {
|
|
73
|
-
variant: "ghost",
|
|
74
|
-
size: "icon",
|
|
75
|
-
onClick: () => u("policies"),
|
|
76
|
-
children: /* @__PURE__ */ D(A, { size: 20 })
|
|
77
|
-
}), /* @__PURE__ */ D("span", { children: l("botlit.toolApprovals.title", "Tool approvals") })]
|
|
78
|
-
}),
|
|
79
|
-
description: l("botlit.toolApprovals.description", "Approve or deny risky tool calls your TOOL policies hold for a human"),
|
|
80
|
-
children: [/* @__PURE__ */ O("div", {
|
|
81
|
-
className: "space-y-6",
|
|
82
|
-
children: [
|
|
83
|
-
/* @__PURE__ */ D(y, {
|
|
84
|
-
icon: /* @__PURE__ */ D(M, { size: 18 }),
|
|
85
|
-
children: l("botlit.toolApprovals.purpose", "When a TOOL policy marks a tool, an MCP server or a risk level as needing approval, the agent does not run the call. It tells the user the call is waiting, and the request appears here. Approving runs the call and the agent posts its answer in the same conversation. Denying tells the user it was not run. Requests expire at the time shown.")
|
|
86
|
-
}),
|
|
87
|
-
/* @__PURE__ */ O(n, { children: [/* @__PURE__ */ D(i, { children: /* @__PURE__ */ D(a, { children: l("botlit.toolApprovals.pending.title", "Waiting for a decision") }) }), /* @__PURE__ */ D(r, { children: k.error ? /* @__PURE__ */ D(c, {
|
|
88
|
-
resource: l("botlit.toolApprovals.resource", "tool approvals"),
|
|
89
|
-
error: k.error,
|
|
90
|
-
onRetry: () => void k.refetch()
|
|
91
|
-
}) : k.loading && k.data.length === 0 ? /* @__PURE__ */ D("div", { className: "h-24 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg" }) : k.data.length === 0 ? /* @__PURE__ */ D("p", {
|
|
92
|
-
className: "text-sm text-text-secondary",
|
|
93
|
-
children: l("botlit.toolApprovals.pending.empty", "No tool calls are waiting for approval.")
|
|
94
|
-
}) : /* @__PURE__ */ D("ul", {
|
|
95
|
-
className: "space-y-3",
|
|
96
|
-
"data-testid": "tool-approvals-pending",
|
|
97
|
-
children: k.data.map((e) => /* @__PURE__ */ O("li", {
|
|
98
|
-
className: "p-4 border border-border-subtle rounded-lg space-y-3",
|
|
99
|
-
"data-testid": `tool-approval-${e.id}`,
|
|
100
|
-
children: [
|
|
101
|
-
/* @__PURE__ */ O("div", {
|
|
102
|
-
className: "flex items-center gap-2 flex-wrap",
|
|
103
|
-
children: [
|
|
104
|
-
/* @__PURE__ */ D("button", {
|
|
105
|
-
type: "button",
|
|
106
|
-
className: "font-medium text-primary hover:underline",
|
|
107
|
-
onClick: () => u(`agents/${e.agentId}`),
|
|
108
|
-
children: e.agentName ?? e.agentId
|
|
109
|
-
}),
|
|
110
|
-
/* @__PURE__ */ O("span", {
|
|
111
|
-
className: "text-sm",
|
|
112
|
-
children: [
|
|
113
|
-
l("botlit.toolApprovals.wantsToRun", "wants to run"),
|
|
114
|
-
" ",
|
|
115
|
-
/* @__PURE__ */ D("code", {
|
|
116
|
-
className: "font-mono",
|
|
117
|
-
children: e.toolName
|
|
118
|
-
}),
|
|
119
|
-
" ",
|
|
120
|
-
l("botlit.toolApprovals.on", "on"),
|
|
121
|
-
" ",
|
|
122
|
-
e.connectionName
|
|
123
|
-
]
|
|
124
|
-
}),
|
|
125
|
-
/* @__PURE__ */ D(s, {
|
|
126
|
-
variant: e.riskLevel === "HIGH" ? "destructive" : "warning",
|
|
127
|
-
children: e.riskLevel
|
|
128
|
-
}),
|
|
129
|
-
e.mode === "REQUESTER" && /* @__PURE__ */ D(s, {
|
|
130
|
-
variant: "outline",
|
|
131
|
-
children: l("botlit.toolApprovals.requesterMode", "Requester confirms")
|
|
132
|
-
})
|
|
133
|
-
]
|
|
134
|
-
}),
|
|
135
|
-
/* @__PURE__ */ O("p", {
|
|
136
|
-
className: "text-xs text-text-secondary",
|
|
137
|
-
children: [
|
|
138
|
-
l("botlit.toolApprovals.requested", "Requested"),
|
|
139
|
-
" ",
|
|
140
|
-
m(e.createdAt),
|
|
141
|
-
" ·",
|
|
142
|
-
" ",
|
|
143
|
-
l("botlit.toolApprovals.expires", "expires"),
|
|
144
|
-
" ",
|
|
145
|
-
m(e.expiresAt)
|
|
146
|
-
]
|
|
147
|
-
}),
|
|
148
|
-
/* @__PURE__ */ D(L, { request: e }),
|
|
149
|
-
/* @__PURE__ */ O("div", {
|
|
150
|
-
className: "flex gap-2",
|
|
151
|
-
children: [/* @__PURE__ */ D(g, {
|
|
152
|
-
permission: h.AGENT_APPROVE,
|
|
153
|
-
children: /* @__PURE__ */ D(o, {
|
|
154
|
-
size: "sm",
|
|
155
|
-
leftIcon: /* @__PURE__ */ D(j, { size: 14 }),
|
|
156
|
-
isLoading: z === e.id && B?.decision === "APPROVE",
|
|
157
|
-
onClick: () => V({
|
|
158
|
-
decision: "APPROVE",
|
|
159
|
-
request: e
|
|
160
|
-
}),
|
|
161
|
-
children: l("botlit.toolApprovals.approve", "Approve")
|
|
162
|
-
})
|
|
163
|
-
}), /* @__PURE__ */ D(g, {
|
|
164
|
-
permission: h.AGENT_APPROVE,
|
|
165
|
-
children: /* @__PURE__ */ D(o, {
|
|
166
|
-
size: "sm",
|
|
167
|
-
variant: "destructive",
|
|
168
|
-
leftIcon: /* @__PURE__ */ D(N, { size: 14 }),
|
|
169
|
-
onClick: () => V({
|
|
170
|
-
decision: "DENY",
|
|
171
|
-
request: e
|
|
172
|
-
}),
|
|
173
|
-
children: l("botlit.toolApprovals.deny", "Deny")
|
|
174
|
-
})
|
|
175
|
-
})]
|
|
176
|
-
})
|
|
177
|
-
]
|
|
178
|
-
}, e.id))
|
|
179
|
-
}) })] }),
|
|
180
|
-
/* @__PURE__ */ O(n, { children: [/* @__PURE__ */ D(i, { children: /* @__PURE__ */ D(a, { children: l("botlit.toolApprovals.history.title", "Recent decisions") }) }), /* @__PURE__ */ D(r, { children: I.error ? /* @__PURE__ */ D(c, {
|
|
181
|
-
resource: l("botlit.toolApprovals.resource", "tool approvals"),
|
|
182
|
-
error: I.error,
|
|
183
|
-
onRetry: () => void I.refetch()
|
|
184
|
-
}) : I.loading && W.length === 0 ? /* @__PURE__ */ D("div", { className: "h-16 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg" }) : W.length === 0 ? /* @__PURE__ */ D("p", {
|
|
185
|
-
className: "text-sm text-text-secondary",
|
|
186
|
-
children: l("botlit.toolApprovals.history.empty", "No decisions yet.")
|
|
187
|
-
}) : /* @__PURE__ */ D("ul", {
|
|
188
|
-
className: "space-y-2",
|
|
189
|
-
"data-testid": "tool-approvals-history",
|
|
190
|
-
children: W.map((e) => /* @__PURE__ */ O("li", {
|
|
191
|
-
className: "p-3 border border-border-subtle rounded-lg text-sm space-y-1",
|
|
192
|
-
children: [
|
|
193
|
-
/* @__PURE__ */ O("div", {
|
|
194
|
-
className: "flex items-center gap-2 flex-wrap",
|
|
195
|
-
children: [
|
|
196
|
-
/* @__PURE__ */ D("span", {
|
|
197
|
-
className: "font-medium",
|
|
198
|
-
children: e.agentName ?? e.agentId
|
|
199
|
-
}),
|
|
200
|
-
/* @__PURE__ */ D("code", {
|
|
201
|
-
className: "font-mono",
|
|
202
|
-
children: e.toolName
|
|
203
|
-
}),
|
|
204
|
-
/* @__PURE__ */ D(s, {
|
|
205
|
-
variant: F(e.status),
|
|
206
|
-
children: e.status
|
|
207
|
-
}),
|
|
208
|
-
e.resumeStatus && /* @__PURE__ */ O(s, {
|
|
209
|
-
variant: e.resumeStatus === "FAILED" ? "destructive" : "outline",
|
|
210
|
-
children: [
|
|
211
|
-
l("botlit.toolApprovals.run", "Run"),
|
|
212
|
-
": ",
|
|
213
|
-
e.resumeStatus
|
|
214
|
-
]
|
|
215
|
-
}),
|
|
216
|
-
/* @__PURE__ */ O("span", {
|
|
217
|
-
className: "text-text-secondary",
|
|
218
|
-
children: [
|
|
219
|
-
l("botlit.toolApprovals.by", "by"),
|
|
220
|
-
" ",
|
|
221
|
-
G(e.deciderId),
|
|
222
|
-
" ",
|
|
223
|
-
e.decidedAt ? m(e.decidedAt) : ""
|
|
224
|
-
]
|
|
225
|
-
})
|
|
226
|
-
]
|
|
227
|
-
}),
|
|
228
|
-
e.decisionNote && /* @__PURE__ */ D("p", {
|
|
229
|
-
className: "break-words",
|
|
230
|
-
children: e.decisionNote
|
|
231
|
-
}),
|
|
232
|
-
e.resumeError && /* @__PURE__ */ D("p", {
|
|
233
|
-
className: "break-words text-status-error-text",
|
|
234
|
-
children: e.resumeError
|
|
235
|
-
}),
|
|
236
|
-
e.resumeExecutionId && /* @__PURE__ */ D("button", {
|
|
237
|
-
type: "button",
|
|
238
|
-
className: "text-primary hover:underline",
|
|
239
|
-
onClick: () => u(`executions/${e.resumeExecutionId}`),
|
|
240
|
-
children: l("botlit.toolApprovals.viewRun", "View the resumed run")
|
|
241
|
-
})
|
|
242
|
-
]
|
|
243
|
-
}, e.id))
|
|
244
|
-
}) })] })
|
|
245
|
-
]
|
|
246
|
-
}), /* @__PURE__ */ D(b, {
|
|
247
|
-
open: B !== null,
|
|
248
|
-
onOpenChange: (e) => {
|
|
249
|
-
e || K();
|
|
250
|
-
},
|
|
251
|
-
children: /* @__PURE__ */ O(x, { children: [
|
|
252
|
-
/* @__PURE__ */ O(w, { children: [/* @__PURE__ */ D(T, { children: B?.decision === "APPROVE" ? l("botlit.toolApprovals.dialog.approveTitle", "Approve and run this tool call") : l("botlit.toolApprovals.dialog.denyTitle", "Deny this tool call") }), /* @__PURE__ */ D(S, { children: B?.decision === "APPROVE" ? l("botlit.toolApprovals.dialog.approveDescription", "The tool runs now with the arguments shown, and the agent posts its answer in the conversation.") : l("botlit.toolApprovals.dialog.denyDescription", "The tool is not run. The user is told the request was declined, with your reason.") })] }),
|
|
253
|
-
B && /* @__PURE__ */ D(L, { request: B.request }),
|
|
254
|
-
/* @__PURE__ */ D(E, {
|
|
255
|
-
"aria-label": l("botlit.toolApprovals.dialog.noteLabel", "Reason"),
|
|
256
|
-
value: H,
|
|
257
|
-
maxLength: 2e3,
|
|
258
|
-
onChange: (e) => U(e.target.value),
|
|
259
|
-
placeholder: B?.decision === "DENY" ? l("botlit.toolApprovals.dialog.reasonRequired", "Reason (required)") : l("botlit.toolApprovals.dialog.reasonOptional", "Note (optional)"),
|
|
260
|
-
rows: 3
|
|
261
|
-
}),
|
|
262
|
-
/* @__PURE__ */ O(C, { children: [/* @__PURE__ */ D(o, {
|
|
263
|
-
variant: "outline",
|
|
264
|
-
onClick: K,
|
|
265
|
-
children: l("botlit.common.cancel", "Cancel")
|
|
266
|
-
}), /* @__PURE__ */ D(o, {
|
|
267
|
-
variant: B?.decision === "DENY" ? "destructive" : "default",
|
|
268
|
-
isLoading: z !== null,
|
|
269
|
-
disabled: B?.decision === "DENY" && H.trim().length === 0,
|
|
270
|
-
onClick: () => void q(),
|
|
271
|
-
children: B?.decision === "APPROVE" ? l("botlit.toolApprovals.approve", "Approve") : l("botlit.toolApprovals.deny", "Deny")
|
|
272
|
-
})] })
|
|
273
|
-
] })
|
|
274
|
-
})]
|
|
275
|
-
});
|
|
276
|
-
}, z = () => {
|
|
277
|
-
let n = e(), { navigateTo: r } = p(), i = _(h.POLICY_READ);
|
|
278
|
-
return /* @__PURE__ */ D(t, {
|
|
279
|
-
title: n("botlit.stewardApprovals.title", "Approvals"),
|
|
280
|
-
description: n("botlit.stewardApprovals.description", "Tool calls waiting for a person, from agent chats and stewards."),
|
|
281
|
-
children: i === "allowed" ? /* @__PURE__ */ D(u, { onOpenAgent: (e) => r(`agents/${e}`) }) : i === "denied" ? /* @__PURE__ */ D("div", {
|
|
10
|
+
var c = () => {
|
|
11
|
+
let c = e(), { navigateTo: l } = i(), u = o(a.POLICY_READ);
|
|
12
|
+
return /* @__PURE__ */ s(t, {
|
|
13
|
+
title: c("botlit.stewardApprovals.title", "Approvals"),
|
|
14
|
+
description: c("botlit.stewardApprovals.description", "Tool calls waiting for a person, from agent chats and stewards."),
|
|
15
|
+
children: u === "allowed" ? /* @__PURE__ */ s(r, { onOpenAgent: (e) => l(`agents/${e}`) }) : u === "denied" ? /* @__PURE__ */ s("div", {
|
|
282
16
|
"data-testid": "approvals-forbidden",
|
|
283
|
-
children: /* @__PURE__ */
|
|
284
|
-
title:
|
|
285
|
-
description:
|
|
17
|
+
children: /* @__PURE__ */ s(n, {
|
|
18
|
+
title: c("botlit.stewardApprovals.noAccess.title", "You cannot view approvals"),
|
|
19
|
+
description: c("botlit.stewardApprovals.noAccess.description", "Ask a workspace admin for access to tool approvals.")
|
|
286
20
|
})
|
|
287
|
-
}) : /* @__PURE__ */
|
|
21
|
+
}) : /* @__PURE__ */ s("div", { className: "h-48 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer" })
|
|
288
22
|
});
|
|
289
|
-
}
|
|
290
|
-
export {
|
|
23
|
+
};
|
|
24
|
+
export { c as ToolApprovalsPage };
|
|
291
25
|
|
|
292
26
|
//# sourceMappingURL=ToolApprovalsPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolApprovalsPage.js","names":["EmptyState","EmptyState$1","toolApprovalStatusVariant","status","argumentsText","value","ApprovalRequestDetails","t","useTr","request","Badge","reason","AgentToolApprovalsView","useBotlit","pending","useToolApprovals","all","useDecideToolApproval","dialog","setDialog","useState","note","setNote","decided","who","id","currentUser","close","submitDecision","decide","toast","err","PageLayout","Button","navigateTo","ArrowLeft","PagePurpose","ShieldAlert","Card","CardHeader","CardTitle","CardContent","ErrorState","formatRelativeTime","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","CheckCircle2","pendingId","XCircle","ResponsiveDialog","open","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Textarea","event","ResponsiveDialogFooter","StewardToolApprovalsView","read","useBotmanorPermissionDecision","StewardApprovalsInbox","agentId","ToolApprovalsPage","useFeatureFlag"],"sources":["../../../src/botlit/pages/ToolApprovalsPage.tsx"],"sourcesContent":["/**\n * Tool Approvals Page (BOFF-15360)\n * @module botlit/pages\n *\n * Approver queue for tool calls a TOOL policy holds for a human decision:\n * which agent wants to run which tool, with what arguments, why it needs\n * approval and when the request expires. Approving runs the call and the\n * agent posts its answer in the original conversation; denying (with a\n * reason) tells the user it was not run. Recent decisions show how each\n * resumed call ended.\n */\n\nimport { useState, type FC } from 'react';\nimport { ArrowLeft, CheckCircle2, ShieldAlert, XCircle } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { useFeatureFlag } from '@burdenoff/fe-libs/shared/feature-flags';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n PagePurpose,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardContent, CardHeader, CardTitle } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport { EmptyState } from '../components/EmptyState';\nimport { StewardApprovalsInbox } from '../components/StewardApprovalsInbox';\nimport {\n useDecideToolApproval,\n useToolApprovals,\n type ToolApprovalRecord,\n type ToolApprovalStatus,\n} from '../hooks/useToolApprovals';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime } from '../utils/formatters';\nimport {\n BOTMANOR_PERMISSIONS,\n BotmanorPermissionGate,\n useBotmanorPermissionDecision,\n} from '../permissions';\n\nexport function toolApprovalStatusVariant(\n status: ToolApprovalStatus\n): 'warning' | 'success' | 'destructive' | 'outline' {\n if (status === 'PENDING') return 'warning';\n if (status === 'APPROVED') return 'success';\n if (status === 'DENIED') return 'destructive';\n return 'outline';\n}\n\nfunction argumentsText(value: unknown): string {\n try {\n return JSON.stringify(value ?? {}, null, 2);\n } catch {\n return String(value);\n }\n}\n\nconst ApprovalRequestDetails: FC<{ request: ToolApprovalRecord }> = ({ request }) => {\n const t = useTr();\n return (\n <div className=\"space-y-2 text-sm\">\n {request.userMessage && (\n <p className=\"break-words\">\n <span className=\"text-text-secondary\">\n {t('botlit.toolApprovals.userAsked', 'User asked:')}{' '}\n </span>\n {request.userMessage}\n </p>\n )}\n <div className=\"flex flex-wrap gap-1\">\n {request.reasons.map((reason) => (\n <Badge key={reason} variant=\"outline\">\n {reason}\n </Badge>\n ))}\n </div>\n <pre className=\"text-xs bg-bg-sunken rounded-md p-2 overflow-x-auto max-h-48 whitespace-pre-wrap break-all\">\n {argumentsText(request.arguments)}\n </pre>\n </div>\n );\n};\n\n/** The queue of tool calls from agent chats, as before Stewards (flag off). */\nconst AgentToolApprovalsView: FC = () => {\n const t = useTr();\n const { navigateTo, currentUser } = useBotlit();\n // Steward requests belong to the Steward inbox; keep them out while the flag is off.\n const pending = useToolApprovals({ status: 'PENDING', source: 'AGENT_CHAT' });\n const all = useToolApprovals({ source: 'AGENT_CHAT' });\n const { decide, pendingId } = useDecideToolApproval();\n const [dialog, setDialog] = useState<{\n decision: 'APPROVE' | 'DENY';\n request: ToolApprovalRecord;\n } | null>(null);\n const [note, setNote] = useState('');\n\n const decided = all.data.filter((request) => request.status !== 'PENDING').slice(0, 20);\n const who = (id?: string | null): string =>\n id && id === currentUser?.id ? t('botlit.toolApprovals.you', 'you') : (id ?? '—');\n\n const close = (): void => {\n setDialog(null);\n setNote('');\n };\n\n const submitDecision = async (): Promise<void> => {\n if (!dialog) return;\n try {\n await decide(dialog.request.id, dialog.decision, note);\n toast.success(\n dialog.decision === 'APPROVE'\n ? t(\n 'botlit.toolApprovals.toast.approved',\n 'Approved — the tool is running and the agent will answer in the conversation'\n )\n : t('botlit.toolApprovals.toast.denied', 'Denied — the user is told it was not run')\n );\n close();\n await Promise.all([pending.refetch(), all.refetch()]);\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.toolApprovals.toast.error', 'Could not record the decision')\n );\n }\n };\n\n return (\n <PageLayout\n title={\n <div className=\"flex items-center gap-3\">\n <Button variant=\"ghost\" size=\"icon\" onClick={() => navigateTo('policies')}>\n <ArrowLeft size={20} />\n </Button>\n <span>{t('botlit.toolApprovals.title', 'Tool approvals')}</span>\n </div>\n }\n description={t(\n 'botlit.toolApprovals.description',\n 'Approve or deny risky tool calls your TOOL policies hold for a human'\n )}\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<ShieldAlert size={18} />}>\n {t(\n 'botlit.toolApprovals.purpose',\n 'When a TOOL policy marks a tool, an MCP server or a risk level as needing approval, the agent does not run the call. It tells the user the call is waiting, and the request appears here. Approving runs the call and the agent posts its answer in the same conversation. Denying tells the user it was not run. Requests expire at the time shown.'\n )}\n </PagePurpose>\n\n <Card>\n <CardHeader>\n <CardTitle>\n {t('botlit.toolApprovals.pending.title', 'Waiting for a decision')}\n </CardTitle>\n </CardHeader>\n <CardContent>\n {pending.error ? (\n <ErrorState\n resource={t('botlit.toolApprovals.resource', 'tool approvals')}\n error={pending.error}\n onRetry={() => void pending.refetch()}\n />\n ) : pending.loading && pending.data.length === 0 ? (\n <div className=\"h-24 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : pending.data.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.toolApprovals.pending.empty', 'No tool calls are waiting for approval.')}\n </p>\n ) : (\n <ul className=\"space-y-3\" data-testid=\"tool-approvals-pending\">\n {pending.data.map((request) => (\n <li\n key={request.id}\n className=\"p-4 border border-border-subtle rounded-lg space-y-3\"\n data-testid={`tool-approval-${request.id}`}\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <button\n type=\"button\"\n className=\"font-medium text-primary hover:underline\"\n onClick={() => navigateTo(`agents/${request.agentId}`)}\n >\n {request.agentName ?? request.agentId}\n </button>\n <span className=\"text-sm\">\n {t('botlit.toolApprovals.wantsToRun', 'wants to run')}{' '}\n <code className=\"font-mono\">{request.toolName}</code>{' '}\n {t('botlit.toolApprovals.on', 'on')} {request.connectionName}\n </span>\n <Badge variant={request.riskLevel === 'HIGH' ? 'destructive' : 'warning'}>\n {request.riskLevel}\n </Badge>\n {request.mode === 'REQUESTER' && (\n <Badge variant=\"outline\">\n {t('botlit.toolApprovals.requesterMode', 'Requester confirms')}\n </Badge>\n )}\n </div>\n <p className=\"text-xs text-text-secondary\">\n {t('botlit.toolApprovals.requested', 'Requested')}{' '}\n {formatRelativeTime(request.createdAt)} ·{' '}\n {t('botlit.toolApprovals.expires', 'expires')}{' '}\n {formatRelativeTime(request.expiresAt)}\n </p>\n <ApprovalRequestDetails request={request} />\n <div className=\"flex gap-2\">\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n leftIcon={<CheckCircle2 size={14} />}\n isLoading={pendingId === request.id && dialog?.decision === 'APPROVE'}\n onClick={() => setDialog({ decision: 'APPROVE', request })}\n >\n {t('botlit.toolApprovals.approve', 'Approve')}\n </Button>\n </BotmanorPermissionGate>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n variant=\"destructive\"\n leftIcon={<XCircle size={14} />}\n onClick={() => setDialog({ decision: 'DENY', request })}\n >\n {t('botlit.toolApprovals.deny', 'Deny')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n\n <Card>\n <CardHeader>\n <CardTitle>{t('botlit.toolApprovals.history.title', 'Recent decisions')}</CardTitle>\n </CardHeader>\n <CardContent>\n {all.error ? (\n <ErrorState\n resource={t('botlit.toolApprovals.resource', 'tool approvals')}\n error={all.error}\n onRetry={() => void all.refetch()}\n />\n ) : all.loading && decided.length === 0 ? (\n <div className=\"h-16 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : decided.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.toolApprovals.history.empty', 'No decisions yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\" data-testid=\"tool-approvals-history\">\n {decided.map((request) => (\n <li\n key={request.id}\n className=\"p-3 border border-border-subtle rounded-lg text-sm space-y-1\"\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className=\"font-medium\">{request.agentName ?? request.agentId}</span>\n <code className=\"font-mono\">{request.toolName}</code>\n <Badge variant={toolApprovalStatusVariant(request.status)}>\n {request.status}\n </Badge>\n {request.resumeStatus && (\n <Badge\n variant={request.resumeStatus === 'FAILED' ? 'destructive' : 'outline'}\n >\n {t('botlit.toolApprovals.run', 'Run')}: {request.resumeStatus}\n </Badge>\n )}\n <span className=\"text-text-secondary\">\n {t('botlit.toolApprovals.by', 'by')} {who(request.deciderId)}{' '}\n {request.decidedAt ? formatRelativeTime(request.decidedAt) : ''}\n </span>\n </div>\n {request.decisionNote && <p className=\"break-words\">{request.decisionNote}</p>}\n {request.resumeError && (\n <p className=\"break-words text-status-error-text\">{request.resumeError}</p>\n )}\n {request.resumeExecutionId && (\n <button\n type=\"button\"\n className=\"text-primary hover:underline\"\n onClick={() => navigateTo(`executions/${request.resumeExecutionId}`)}\n >\n {t('botlit.toolApprovals.viewRun', 'View the resumed run')}\n </button>\n )}\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n </div>\n\n <ResponsiveDialog\n open={dialog !== null}\n onOpenChange={(open) => {\n if (!open) close();\n }}\n >\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {dialog?.decision === 'APPROVE'\n ? t('botlit.toolApprovals.dialog.approveTitle', 'Approve and run this tool call')\n : t('botlit.toolApprovals.dialog.denyTitle', 'Deny this tool call')}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {dialog?.decision === 'APPROVE'\n ? t(\n 'botlit.toolApprovals.dialog.approveDescription',\n 'The tool runs now with the arguments shown, and the agent posts its answer in the conversation.'\n )\n : t(\n 'botlit.toolApprovals.dialog.denyDescription',\n 'The tool is not run. The user is told the request was declined, with your reason.'\n )}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n {dialog && <ApprovalRequestDetails request={dialog.request} />}\n <Textarea\n aria-label={t('botlit.toolApprovals.dialog.noteLabel', 'Reason')}\n value={note}\n maxLength={2000}\n onChange={(event) => setNote(event.target.value)}\n placeholder={\n dialog?.decision === 'DENY'\n ? t('botlit.toolApprovals.dialog.reasonRequired', 'Reason (required)')\n : t('botlit.toolApprovals.dialog.reasonOptional', 'Note (optional)')\n }\n rows={3}\n />\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={close}>\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button\n variant={dialog?.decision === 'DENY' ? 'destructive' : 'default'}\n isLoading={pendingId !== null}\n disabled={dialog?.decision === 'DENY' && note.trim().length === 0}\n onClick={() => void submitDecision()}\n >\n {dialog?.decision === 'APPROVE'\n ? t('botlit.toolApprovals.approve', 'Approve')\n : t('botlit.toolApprovals.deny', 'Deny')}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </PageLayout>\n );\n};\n\n/** Steward-aware inbox (flag `botmanor.stewards`), gated on `botmanor-policy:read`. */\nconst StewardToolApprovalsView: FC = () => {\n const t = useTr();\n const { navigateTo } = useBotlit();\n const read = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.POLICY_READ);\n\n return (\n <PageLayout\n title={t('botlit.stewardApprovals.title', 'Approvals')}\n description={t(\n 'botlit.stewardApprovals.description',\n 'Tool calls waiting for a person, from agent chats and stewards.'\n )}\n >\n {read === 'allowed' ? (\n <StewardApprovalsInbox onOpenAgent={(agentId) => navigateTo(`agents/${agentId}`)} />\n ) : read === 'denied' ? (\n <div data-testid=\"approvals-forbidden\">\n <EmptyState\n title={t('botlit.stewardApprovals.noAccess.title', 'You cannot view approvals')}\n description={t(\n 'botlit.stewardApprovals.noAccess.description',\n 'Ask a workspace admin for access to tool approvals.'\n )}\n />\n </div>\n ) : (\n <div className=\"h-48 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\" />\n )}\n </PageLayout>\n );\n};\n\nexport const ToolApprovalsPage: FC = () => {\n const stewardsEnabled = useFeatureFlag('botmanor.stewards', false);\n return stewardsEnabled ? <StewardToolApprovalsView /> : <AgentToolApprovalsView />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,SAAgBE,EACd,GACmD;CAInD,OAHIC,MAAW,YAAkB,YAC7BA,MAAW,aAAmB,YAC9BA,MAAW,WAAiB,gBACzB;AACT;AAEA,SAASC,EAAc,GAAwB;CAC7C,IAAI;EACF,OAAO,KAAK,UAAUC,KAAS,CAAC,GAAG,MAAM,CAAC;CAC5C,QAAQ;EACN,OAAO,OAAOA,CAAK;CACrB;AACF;AAEA,IAAMC,KAA+D,EAAE,iBAAc;CACnF,IAAMC,IAAIC,EAAM;CAChB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACGC,EAAQ,eACP,kBAAC,KAAD;IAAG,WAAU;IAAb,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACGF,EAAE,kCAAkC,aAAa,GAAG,GACjD;IACL,CAAA,GAAAE,EAAQ,WACR;;GAEL,kBAAC,OAAD;IAAK,WAAU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AAQ,aAAa,SAAS,gBAAgB;KACvD,WAAW6B,MAAc;KACzB,UAAU7B,GAAQ,aAAa,UAAUG,EAAK,KAAK,CAAC,CAAC,WAAW;KAChE,eAAe,KAAKO,EAAe;KAElC,UAAAV,GAAQ,aAAa,YAClBX,EAAE,gCAAgC,SAAS,IAC3CA,EAAE,6BAA6B,MAAM;IACnC,CAAA,CACc,EAAA,CAAA;GACD,EAAA,CAAA;EACT,CAAA,CACR;;AAEhB,GAGMmD,UAAqC;CACzC,IAAMnD,IAAIC,EAAM,GACV,EAAE,kBAAeK,EAAU,GAC3B8C,IAAOC,EAA8Bf,EAAqB,WAAW;CAE3E,OACE,kBAACb,GAAD;EACE,OAAOzB,EAAE,iCAAiC,WAAW;EACrD,aAAaA,EACX,uCACA,iEACF;EAEC,UAAAoD,MAAS,YACR,kBAACE,GAAD,EAAuB,cAAc,MAAY3B,EAAW,UAAU4B,GAAS,EAAI,CAAA,IACjFH,MAAS,WACX,kBAAC,OAAD;GAAK,eAAY;GACf,UAAA,kBAAC3D,GAAD;IACE,OAAOO,EAAE,0CAA0C,2BAA2B;IAC9E,aAAaA,EACX,gDACA,qDACF;GACD,CAAA;EACE,CAAA,IAEL,kBAAC,OAAD,EAAK,WAAU,8DAA+D,CAAA;CAEtE,CAAA;AAEhB,GAEawD,UACaC,EAAe,qBAAqB,EACrD,IAAkB,kBAACN,GAAD,CAA2B,CAAA,IAAI,kBAAC9C,GAAD,CAAyB,CAAA"}
|
|
1
|
+
{"version":3,"file":"ToolApprovalsPage.js","names":["ToolApprovalsPage","t","useTr","useBotlit","read","useBotmanorPermissionDecision","BOTMANOR_PERMISSIONS","PageLayout","StewardApprovalsInbox","navigateTo","agentId","EmptyState"],"sources":["../../../src/botlit/pages/ToolApprovalsPage.tsx"],"sourcesContent":["/**\n * Tool Approvals Page (BOFF-15360)\n * @module botlit/pages\n *\n * Approver inbox for tool calls a TOOL policy holds for a human decision,\n * from agent chats and from stewards (`StewardApprovalsInbox`). Stewards are\n * generally available, so the inbox no longer depends on the deprecated\n * `botmanor.stewards` flag; `botmanor-policy:read` decides who sees it.\n */\n\nimport type { FC } from 'react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { EmptyState } from '../components/EmptyState';\nimport { StewardApprovalsInbox } from '../components/StewardApprovalsInbox';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { BOTMANOR_PERMISSIONS, useBotmanorPermissionDecision } from '../permissions';\n\n/**\n * The approvals inbox: tool calls from agent chats and from stewards, gated on\n * `botmanor-policy:read`. Stewards are generally available, so no feature\n * flag picks between this and the older agent-chat-only queue.\n */\nexport const ToolApprovalsPage: FC = () => {\n const t = useTr();\n const { navigateTo } = useBotlit();\n const read = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.POLICY_READ);\n\n return (\n <PageLayout\n title={t('botlit.stewardApprovals.title', 'Approvals')}\n description={t(\n 'botlit.stewardApprovals.description',\n 'Tool calls waiting for a person, from agent chats and stewards.'\n )}\n >\n {read === 'allowed' ? (\n <StewardApprovalsInbox onOpenAgent={(agentId) => navigateTo(`agents/${agentId}`)} />\n ) : read === 'denied' ? (\n <div data-testid=\"approvals-forbidden\">\n <EmptyState\n title={t('botlit.stewardApprovals.noAccess.title', 'You cannot view approvals')}\n description={t(\n 'botlit.stewardApprovals.noAccess.description',\n 'Ask a workspace admin for access to tool approvals.'\n )}\n />\n </div>\n ) : (\n <div className=\"h-48 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\" />\n )}\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;AAuBA,IAAaA,UAA8B;CACzC,IAAMC,IAAIC,EAAM,GACV,EAAE,kBAAeC,EAAU,GAC3BC,IAAOC,EAA8BC,EAAqB,WAAW;CAE3E,OACE,kBAACC,GAAD;EACE,OAAON,EAAE,iCAAiC,WAAW;EACrD,aAAaA,EACX,uCACA,iEACF;EAEC,UAAAG,MAAS,YACR,kBAACI,GAAD,EAAuB,cAAc,MAAYC,EAAW,UAAUC,GAAS,EAAI,CAAA,IACjFN,MAAS,WACX,kBAAC,OAAD;GAAK,eAAY;GACf,UAAA,kBAACO,GAAD;IACE,OAAOV,EAAE,0CAA0C,2BAA2B;IAC9E,aAAaA,EACX,gDACA,qDACF;GACD,CAAA;EACE,CAAA,IAEL,kBAAC,OAAD,EAAK,WAAU,8DAA+D,CAAA;CAEtE,CAAA;AAEhB"}
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
export interface WorkspaceFlagScopeProps {
|
|
3
|
-
/** The page's workspace; empty or null while the shell is still resolving it. */
|
|
4
|
-
workspaceId: string | null | undefined;
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const WorkspaceFlagScope: FC<WorkspaceFlagScopeProps>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { BOTMANOR_FLAG_KEYS as e, enclosingProviderCoversWorkspace as t } from "./workspaceFlagKeys.js";
|
|
2
|
-
import { Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
3
|
-
import { FeatureFlagProvider as i, useOptionalFeatureFlags as a } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
4
|
-
// src/botlit/providers/WorkspaceFlagScope.tsx
|
|
5
|
-
var o = ({ workspaceId: o, children: s }) => {
|
|
6
|
-
let c = a();
|
|
7
|
-
return t(c?.workspaceId, o) ? /* @__PURE__ */ r(n, { children: s }) : /* @__PURE__ */ r(i, {
|
|
8
|
-
workspaceId: o || null,
|
|
9
|
-
gateway: "global",
|
|
10
|
-
flagKeys: e,
|
|
11
|
-
defaultEnabled: !0,
|
|
12
|
-
children: s
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export { o as WorkspaceFlagScope };
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=WorkspaceFlagScope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WorkspaceFlagScope.js","names":["_Fragment","WorkspaceFlagScope","enclosing","useOptionalFeatureFlags","enclosingProviderCoversWorkspace","workspaceId","Fragment","FeatureFlagProvider","BOTMANOR_FLAG_KEYS"],"sources":["../../../src/botlit/providers/WorkspaceFlagScope.tsx"],"sourcesContent":["/**\n * Feature flags for BotManor's pages, evaluated once per workspace.\n * @module botlit\n *\n * BotManor's only flag today is `botmanor.stewards`. The BotManor app shell\n * already evaluates every flag for the active workspace in its own\n * FeatureFlagProvider (botmanor-app `WorkspaceFeatureFlags`, BOFF-16146), and\n * this module used to mount a second provider underneath it that asked again\n * for `botmanor.stewards` alone. Every signed-in BotManor page therefore sent\n * `EvaluateFeatureFlags` twice for the same workspace (BOFF-18147).\n *\n * When an enclosing provider already evaluates flags for the same workspace,\n * this scope reuses it and sends nothing. A host that mounts no provider, or\n * one with no workspace or a different workspace, still gets BotManor's own\n * provider, so `useFeatureFlag('botmanor.stewards')` keeps answering for the\n * page's workspace in every host.\n */\n\nimport type { FC, ReactNode } from 'react';\nimport {\n FeatureFlagProvider,\n useOptionalFeatureFlags,\n} from '@burdenoff/fe-libs/shared/feature-flags';\nimport { BOTMANOR_FLAG_KEYS, enclosingProviderCoversWorkspace } from './workspaceFlagKeys';\n\nexport interface WorkspaceFlagScopeProps {\n /** The page's workspace; empty or null while the shell is still resolving it. */\n workspaceId: string | null | undefined;\n children: ReactNode;\n}\n\nexport const WorkspaceFlagScope: FC<WorkspaceFlagScopeProps> = ({ workspaceId, children }) => {\n const enclosing = useOptionalFeatureFlags();\n\n if (enclosingProviderCoversWorkspace(enclosing?.workspaceId, workspaceId)) {\n return <>{children}</>;\n }\n\n return (\n <FeatureFlagProvider\n workspaceId={workspaceId || null}\n gateway=\"global\"\n flagKeys={BOTMANOR_FLAG_KEYS}\n defaultEnabled={true}\n >\n {children}\n </FeatureFlagProvider>\n );\n};\n"],"mappings":";;;;AA+BA,IAAaC,KAAmD,EAAE,gBAAa,kBAAe;CAC5F,IAAMC,IAAYC,EAAwB;CAM1C,OAJIC,EAAiCF,GAAW,aAAaG,CAAW,IAC/D,kBAAAL,GAAA,EAAG,YAAW,CAAA,IAIrB,kBAACO,GAAD;EACE,aAAaF,KAAe;EAC5B,SAAQ;EACR,UAAUG;EACV,gBAAgB;EAEf;CACkB,CAAA;AAEzB"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Flag keys and the reuse rule behind WorkspaceFlagScope (BOFF-18147).
|
|
3
|
-
* @module botlit
|
|
4
|
-
*
|
|
5
|
-
* Kept out of the component file so Fast Refresh can preserve the scope's
|
|
6
|
-
* state (react-doctor `only-export-components`).
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* The flags BotManor's pages read. A module constant on purpose: the provider
|
|
10
|
-
* re-runs its fetch whenever this array changes identity, so an inline literal
|
|
11
|
-
* would evaluate the flags again on every render of the module root.
|
|
12
|
-
*/
|
|
13
|
-
export declare const BOTMANOR_FLAG_KEYS: string[];
|
|
14
|
-
/**
|
|
15
|
-
* `true` when the enclosing flag provider already evaluates flags for
|
|
16
|
-
* `workspaceId`, so a nested provider would only repeat its request.
|
|
17
|
-
*/
|
|
18
|
-
export declare function enclosingProviderCoversWorkspace(enclosingWorkspaceId: string | null | undefined, workspaceId: string | null | undefined): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspaceFlagKeys.js","names":["BOTMANOR_FLAG_KEYS","enclosingProviderCoversWorkspace","enclosingWorkspaceId","workspaceId"],"sources":["../../../src/botlit/providers/workspaceFlagKeys.ts"],"sourcesContent":["/**\n * Flag keys and the reuse rule behind WorkspaceFlagScope (BOFF-18147).\n * @module botlit\n *\n * Kept out of the component file so Fast Refresh can preserve the scope's\n * state (react-doctor `only-export-components`).\n */\n\n/**\n * The flags BotManor's pages read. A module constant on purpose: the provider\n * re-runs its fetch whenever this array changes identity, so an inline literal\n * would evaluate the flags again on every render of the module root.\n */\nexport const BOTMANOR_FLAG_KEYS: string[] = ['botmanor.stewards'];\n\n/**\n * `true` when the enclosing flag provider already evaluates flags for\n * `workspaceId`, so a nested provider would only repeat its request.\n */\nexport function enclosingProviderCoversWorkspace(\n enclosingWorkspaceId: string | null | undefined,\n workspaceId: string | null | undefined\n): boolean {\n return Boolean(enclosingWorkspaceId) && enclosingWorkspaceId === workspaceId;\n}\n"],"mappings":";AAaA,IAAaA,IAA+B,CAAC,mBAAmB;AAMhE,SAAgBC,EACd,GACA,GACS;CACT,OAAO,EAAQC,KAAyBA,MAAyBC;AACnE"}
|