@burdenoff/microfe-botmanor 2026.1127.7 → 2026.1201.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/BotlitRoutes.js +40 -36
- package/dist/botlit/BotlitRoutes.js.map +1 -1
- package/dist/botlit/components/AiOperationsPanel.js +215 -140
- package/dist/botlit/components/AiOperationsPanel.js.map +1 -1
- package/dist/botlit/components/ToolApprovalPolicyFields.d.ts +15 -0
- package/dist/botlit/components/ToolApprovalPolicyFields.js +152 -0
- package/dist/botlit/components/ToolApprovalPolicyFields.js.map +1 -0
- package/dist/botlit/hooks/useToolApprovals.d.ts +44 -0
- package/dist/botlit/hooks/useToolApprovals.js +98 -0
- package/dist/botlit/hooks/useToolApprovals.js.map +1 -0
- package/dist/botlit/pages/PoliciesPage.js +16 -7
- package/dist/botlit/pages/PoliciesPage.js.map +1 -1
- package/dist/botlit/pages/PolicyDetailPage.js +438 -429
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
- package/dist/botlit/pages/ToolApprovalsPage.d.ts +4 -0
- package/dist/botlit/pages/ToolApprovalsPage.js +274 -0
- package/dist/botlit/pages/ToolApprovalsPage.js.map +1 -0
- package/dist/botlit/permissions/index.js +3 -3
- package/dist/botlit/providers/BotlitProvider.js +39 -31
- package/dist/botlit/providers/BotlitProvider.js.map +1 -1
- package/dist/botlit/providers/SupervisorActionScope.d.ts +20 -0
- package/dist/botlit/providers/SupervisorActionScope.js +61 -0
- package/dist/botlit/providers/SupervisorActionScope.js.map +1 -0
- package/dist/botlit/utils/policyConfig.d.ts +12 -0
- package/dist/botlit/utils/policyConfig.js +134 -76
- package/dist/botlit/utils/policyConfig.js.map +1 -1
- package/dist/generated/wspace-types.js +13 -11
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import { PageLayout as t } from "../components/PageLayout.js";
|
|
3
|
+
import { Card as n, CardContent as r, CardHeader as i, CardTitle as a } from "../components/Card.js";
|
|
4
|
+
import { BOTMANOR_PERMISSIONS as o } from "../permissions/botmanorPermissions.js";
|
|
5
|
+
import { BotmanorPermissionGate as s } from "../permissions/useBotmanorPermissions.js";
|
|
6
|
+
import { Button as c } from "../components/Button.js";
|
|
7
|
+
import { Badge as l } from "../components/Badge.js";
|
|
8
|
+
import { ErrorState as u } from "../components/ErrorState.js";
|
|
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 "../permissions/index.js";
|
|
13
|
+
import { useState as h } from "react";
|
|
14
|
+
import { PagePurpose as g, ResponsiveDialog as _, ResponsiveDialogContent as v, ResponsiveDialogDescription as y, ResponsiveDialogFooter as b, ResponsiveDialogHeader as x, ResponsiveDialogTitle as S, Textarea as C } from "@burdenoff/fe-libs/ui";
|
|
15
|
+
import { jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
16
|
+
import { ArrowLeft as E, CheckCircle2 as D, ShieldAlert as O, XCircle as k } from "lucide-react";
|
|
17
|
+
import { toast as A } from "sonner";
|
|
18
|
+
// src/botlit/pages/ToolApprovalsPage.tsx
|
|
19
|
+
function j(e) {
|
|
20
|
+
return e === "PENDING" ? "warning" : e === "APPROVED" ? "success" : e === "DENIED" ? "destructive" : "outline";
|
|
21
|
+
}
|
|
22
|
+
function M(e) {
|
|
23
|
+
try {
|
|
24
|
+
return JSON.stringify(e ?? {}, null, 2);
|
|
25
|
+
} catch {
|
|
26
|
+
return String(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
var N = ({ request: t }) => {
|
|
30
|
+
let n = e();
|
|
31
|
+
return /* @__PURE__ */ T("div", {
|
|
32
|
+
className: "space-y-2 text-sm",
|
|
33
|
+
children: [
|
|
34
|
+
t.userMessage && /* @__PURE__ */ T("p", {
|
|
35
|
+
className: "break-words",
|
|
36
|
+
children: [/* @__PURE__ */ T("span", {
|
|
37
|
+
className: "text-text-secondary",
|
|
38
|
+
children: [n("botlit.toolApprovals.userAsked", "User asked:"), " "]
|
|
39
|
+
}), t.userMessage]
|
|
40
|
+
}),
|
|
41
|
+
/* @__PURE__ */ w("div", {
|
|
42
|
+
className: "flex flex-wrap gap-1",
|
|
43
|
+
children: t.reasons.map((e) => /* @__PURE__ */ w(l, {
|
|
44
|
+
variant: "outline",
|
|
45
|
+
children: e
|
|
46
|
+
}, e))
|
|
47
|
+
}),
|
|
48
|
+
/* @__PURE__ */ w("pre", {
|
|
49
|
+
className: "text-xs bg-bg-sunken rounded-md p-2 overflow-x-auto max-h-48 whitespace-pre-wrap break-all",
|
|
50
|
+
children: M(t.arguments)
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}, P = () => {
|
|
55
|
+
let M = e(), { navigateTo: P, currentUser: F } = p(), I = f({ status: "PENDING" }), L = f({}), { decide: R, pendingId: z } = d(), [B, V] = h(null), [H, U] = h(""), W = L.data.filter((e) => e.status !== "PENDING").slice(0, 20), G = (e) => e && e === F?.id ? M("botlit.toolApprovals.you", "you") : e ?? "—", K = () => {
|
|
56
|
+
V(null), U("");
|
|
57
|
+
}, q = async () => {
|
|
58
|
+
if (B) try {
|
|
59
|
+
await R(B.request.id, B.decision, H), A.success(B.decision === "APPROVE" ? M("botlit.toolApprovals.toast.approved", "Approved — the tool is running and the agent will answer in the conversation") : M("botlit.toolApprovals.toast.denied", "Denied — the user is told it was not run")), K(), await Promise.all([I.refetch(), L.refetch()]);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
A.error(e instanceof Error ? e.message : M("botlit.toolApprovals.toast.error", "Could not record the decision"));
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ T(t, {
|
|
65
|
+
title: /* @__PURE__ */ T("div", {
|
|
66
|
+
className: "flex items-center gap-3",
|
|
67
|
+
children: [/* @__PURE__ */ w(c, {
|
|
68
|
+
variant: "ghost",
|
|
69
|
+
size: "icon",
|
|
70
|
+
onClick: () => P("policies"),
|
|
71
|
+
children: /* @__PURE__ */ w(E, { size: 20 })
|
|
72
|
+
}), /* @__PURE__ */ w("span", { children: M("botlit.toolApprovals.title", "Tool approvals") })]
|
|
73
|
+
}),
|
|
74
|
+
description: M("botlit.toolApprovals.description", "Approve or deny risky tool calls your TOOL policies hold for a human"),
|
|
75
|
+
children: [/* @__PURE__ */ T("div", {
|
|
76
|
+
className: "space-y-6",
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ w(g, {
|
|
79
|
+
icon: /* @__PURE__ */ w(O, { size: 18 }),
|
|
80
|
+
children: M("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.")
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ T(n, { children: [/* @__PURE__ */ w(i, { children: /* @__PURE__ */ w(a, { children: M("botlit.toolApprovals.pending.title", "Waiting for a decision") }) }), /* @__PURE__ */ w(r, { children: I.error ? /* @__PURE__ */ w(u, {
|
|
83
|
+
resource: M("botlit.toolApprovals.resource", "tool approvals"),
|
|
84
|
+
error: I.error,
|
|
85
|
+
onRetry: () => void I.refetch()
|
|
86
|
+
}) : I.loading && I.data.length === 0 ? /* @__PURE__ */ w("div", { className: "h-24 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg" }) : I.data.length === 0 ? /* @__PURE__ */ w("p", {
|
|
87
|
+
className: "text-sm text-text-secondary",
|
|
88
|
+
children: M("botlit.toolApprovals.pending.empty", "No tool calls are waiting for approval.")
|
|
89
|
+
}) : /* @__PURE__ */ w("ul", {
|
|
90
|
+
className: "space-y-3",
|
|
91
|
+
"data-testid": "tool-approvals-pending",
|
|
92
|
+
children: I.data.map((e) => /* @__PURE__ */ T("li", {
|
|
93
|
+
className: "p-4 border border-border-subtle rounded-lg space-y-3",
|
|
94
|
+
"data-testid": `tool-approval-${e.id}`,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ T("div", {
|
|
97
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ w("button", {
|
|
100
|
+
type: "button",
|
|
101
|
+
className: "font-medium text-primary hover:underline",
|
|
102
|
+
onClick: () => P(`agents/${e.agentId}`),
|
|
103
|
+
children: e.agentName ?? e.agentId
|
|
104
|
+
}),
|
|
105
|
+
/* @__PURE__ */ T("span", {
|
|
106
|
+
className: "text-sm",
|
|
107
|
+
children: [
|
|
108
|
+
M("botlit.toolApprovals.wantsToRun", "wants to run"),
|
|
109
|
+
" ",
|
|
110
|
+
/* @__PURE__ */ w("code", {
|
|
111
|
+
className: "font-mono",
|
|
112
|
+
children: e.toolName
|
|
113
|
+
}),
|
|
114
|
+
" ",
|
|
115
|
+
M("botlit.toolApprovals.on", "on"),
|
|
116
|
+
" ",
|
|
117
|
+
e.connectionName
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
/* @__PURE__ */ w(l, {
|
|
121
|
+
variant: e.riskLevel === "HIGH" ? "destructive" : "warning",
|
|
122
|
+
children: e.riskLevel
|
|
123
|
+
}),
|
|
124
|
+
e.mode === "REQUESTER" && /* @__PURE__ */ w(l, {
|
|
125
|
+
variant: "outline",
|
|
126
|
+
children: M("botlit.toolApprovals.requesterMode", "Requester confirms")
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
}),
|
|
130
|
+
/* @__PURE__ */ T("p", {
|
|
131
|
+
className: "text-xs text-text-secondary",
|
|
132
|
+
children: [
|
|
133
|
+
M("botlit.toolApprovals.requested", "Requested"),
|
|
134
|
+
" ",
|
|
135
|
+
m(e.createdAt),
|
|
136
|
+
" ·",
|
|
137
|
+
" ",
|
|
138
|
+
M("botlit.toolApprovals.expires", "expires"),
|
|
139
|
+
" ",
|
|
140
|
+
m(e.expiresAt)
|
|
141
|
+
]
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ w(N, { request: e }),
|
|
144
|
+
/* @__PURE__ */ T("div", {
|
|
145
|
+
className: "flex gap-2",
|
|
146
|
+
children: [/* @__PURE__ */ w(s, {
|
|
147
|
+
permission: o.AGENT_APPROVE,
|
|
148
|
+
children: /* @__PURE__ */ w(c, {
|
|
149
|
+
size: "sm",
|
|
150
|
+
leftIcon: /* @__PURE__ */ w(D, { size: 14 }),
|
|
151
|
+
isLoading: z === e.id && B?.decision === "APPROVE",
|
|
152
|
+
onClick: () => V({
|
|
153
|
+
decision: "APPROVE",
|
|
154
|
+
request: e
|
|
155
|
+
}),
|
|
156
|
+
children: M("botlit.toolApprovals.approve", "Approve")
|
|
157
|
+
})
|
|
158
|
+
}), /* @__PURE__ */ w(s, {
|
|
159
|
+
permission: o.AGENT_APPROVE,
|
|
160
|
+
children: /* @__PURE__ */ w(c, {
|
|
161
|
+
size: "sm",
|
|
162
|
+
variant: "destructive",
|
|
163
|
+
leftIcon: /* @__PURE__ */ w(k, { size: 14 }),
|
|
164
|
+
onClick: () => V({
|
|
165
|
+
decision: "DENY",
|
|
166
|
+
request: e
|
|
167
|
+
}),
|
|
168
|
+
children: M("botlit.toolApprovals.deny", "Deny")
|
|
169
|
+
})
|
|
170
|
+
})]
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}, e.id))
|
|
174
|
+
}) })] }),
|
|
175
|
+
/* @__PURE__ */ T(n, { children: [/* @__PURE__ */ w(i, { children: /* @__PURE__ */ w(a, { children: M("botlit.toolApprovals.history.title", "Recent decisions") }) }), /* @__PURE__ */ w(r, { children: L.error ? /* @__PURE__ */ w(u, {
|
|
176
|
+
resource: M("botlit.toolApprovals.resource", "tool approvals"),
|
|
177
|
+
error: L.error,
|
|
178
|
+
onRetry: () => void L.refetch()
|
|
179
|
+
}) : L.loading && W.length === 0 ? /* @__PURE__ */ w("div", { className: "h-16 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg" }) : W.length === 0 ? /* @__PURE__ */ w("p", {
|
|
180
|
+
className: "text-sm text-text-secondary",
|
|
181
|
+
children: M("botlit.toolApprovals.history.empty", "No decisions yet.")
|
|
182
|
+
}) : /* @__PURE__ */ w("ul", {
|
|
183
|
+
className: "space-y-2",
|
|
184
|
+
"data-testid": "tool-approvals-history",
|
|
185
|
+
children: W.map((e) => /* @__PURE__ */ T("li", {
|
|
186
|
+
className: "p-3 border border-border-subtle rounded-lg text-sm space-y-1",
|
|
187
|
+
children: [
|
|
188
|
+
/* @__PURE__ */ T("div", {
|
|
189
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
190
|
+
children: [
|
|
191
|
+
/* @__PURE__ */ w("span", {
|
|
192
|
+
className: "font-medium",
|
|
193
|
+
children: e.agentName ?? e.agentId
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ w("code", {
|
|
196
|
+
className: "font-mono",
|
|
197
|
+
children: e.toolName
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ w(l, {
|
|
200
|
+
variant: j(e.status),
|
|
201
|
+
children: e.status
|
|
202
|
+
}),
|
|
203
|
+
e.resumeStatus && /* @__PURE__ */ T(l, {
|
|
204
|
+
variant: e.resumeStatus === "FAILED" ? "destructive" : "outline",
|
|
205
|
+
children: [
|
|
206
|
+
M("botlit.toolApprovals.run", "Run"),
|
|
207
|
+
": ",
|
|
208
|
+
e.resumeStatus
|
|
209
|
+
]
|
|
210
|
+
}),
|
|
211
|
+
/* @__PURE__ */ T("span", {
|
|
212
|
+
className: "text-text-secondary",
|
|
213
|
+
children: [
|
|
214
|
+
M("botlit.toolApprovals.by", "by"),
|
|
215
|
+
" ",
|
|
216
|
+
G(e.deciderId),
|
|
217
|
+
" ",
|
|
218
|
+
e.decidedAt ? m(e.decidedAt) : ""
|
|
219
|
+
]
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
}),
|
|
223
|
+
e.decisionNote && /* @__PURE__ */ w("p", {
|
|
224
|
+
className: "break-words",
|
|
225
|
+
children: e.decisionNote
|
|
226
|
+
}),
|
|
227
|
+
e.resumeError && /* @__PURE__ */ w("p", {
|
|
228
|
+
className: "break-words text-status-error-text",
|
|
229
|
+
children: e.resumeError
|
|
230
|
+
}),
|
|
231
|
+
e.resumeExecutionId && /* @__PURE__ */ w("button", {
|
|
232
|
+
type: "button",
|
|
233
|
+
className: "text-primary hover:underline",
|
|
234
|
+
onClick: () => P(`executions/${e.resumeExecutionId}`),
|
|
235
|
+
children: M("botlit.toolApprovals.viewRun", "View the resumed run")
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
}, e.id))
|
|
239
|
+
}) })] })
|
|
240
|
+
]
|
|
241
|
+
}), /* @__PURE__ */ w(_, {
|
|
242
|
+
open: B !== null,
|
|
243
|
+
onOpenChange: (e) => {
|
|
244
|
+
e || K();
|
|
245
|
+
},
|
|
246
|
+
children: /* @__PURE__ */ T(v, { children: [
|
|
247
|
+
/* @__PURE__ */ T(x, { children: [/* @__PURE__ */ w(S, { children: B?.decision === "APPROVE" ? M("botlit.toolApprovals.dialog.approveTitle", "Approve and run this tool call") : M("botlit.toolApprovals.dialog.denyTitle", "Deny this tool call") }), /* @__PURE__ */ w(y, { children: B?.decision === "APPROVE" ? M("botlit.toolApprovals.dialog.approveDescription", "The tool runs now with the arguments shown, and the agent posts its answer in the conversation.") : M("botlit.toolApprovals.dialog.denyDescription", "The tool is not run. The user is told the request was declined, with your reason.") })] }),
|
|
248
|
+
B && /* @__PURE__ */ w(N, { request: B.request }),
|
|
249
|
+
/* @__PURE__ */ w(C, {
|
|
250
|
+
"aria-label": M("botlit.toolApprovals.dialog.noteLabel", "Reason"),
|
|
251
|
+
value: H,
|
|
252
|
+
maxLength: 2e3,
|
|
253
|
+
onChange: (e) => U(e.target.value),
|
|
254
|
+
placeholder: B?.decision === "DENY" ? M("botlit.toolApprovals.dialog.reasonRequired", "Reason (required)") : M("botlit.toolApprovals.dialog.reasonOptional", "Note (optional)"),
|
|
255
|
+
rows: 3
|
|
256
|
+
}),
|
|
257
|
+
/* @__PURE__ */ T(b, { children: [/* @__PURE__ */ w(c, {
|
|
258
|
+
variant: "outline",
|
|
259
|
+
onClick: K,
|
|
260
|
+
children: M("botlit.common.cancel", "Cancel")
|
|
261
|
+
}), /* @__PURE__ */ w(c, {
|
|
262
|
+
variant: B?.decision === "DENY" ? "destructive" : "default",
|
|
263
|
+
isLoading: z !== null,
|
|
264
|
+
disabled: B?.decision === "DENY" && H.trim().length === 0,
|
|
265
|
+
onClick: () => void q(),
|
|
266
|
+
children: B?.decision === "APPROVE" ? M("botlit.toolApprovals.approve", "Approve") : M("botlit.toolApprovals.deny", "Deny")
|
|
267
|
+
})] })
|
|
268
|
+
] })
|
|
269
|
+
})]
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
export { P as ToolApprovalsPage, j as toolApprovalStatusVariant };
|
|
273
|
+
|
|
274
|
+
//# sourceMappingURL=ToolApprovalsPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolApprovalsPage.js","names":["toolApprovalStatusVariant","status","argumentsText","value","ApprovalRequestDetails","t","useTr","request","Badge","reason","ToolApprovalsPage","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"],"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 {\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 {\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 { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } 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\nexport const ToolApprovalsPage: FC = () => {\n const t = useTr();\n const { navigateTo, currentUser } = useBotlit();\n const pending = useToolApprovals({ status: 'PENDING' });\n const all = useToolApprovals({});\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"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,SAAgBA,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;IACZ,UAAAA,EAAQ,QAAQ,KAAK,MACpB,kBAACC,GAAD;KAAoB,SAAQ;KACzB,UAAAC;IACI,GAFKA,CAEL,CACR;GACE,CAAA;GACL,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAAP,EAAcK,EAAQ,SAAS;GAC7B,CAA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M;IACnC,CAAA,CACc,EAAA,CAAA;GACD,EAAA,CAAA;EACT,CAAA,CACR;;AAEhB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BOTMANOR_PERMISSIONS as e } from "./botmanorPermissions.js";
|
|
2
|
-
import { BotmanorPermissionGate as t,
|
|
3
|
-
import { RequirePermission as
|
|
4
|
-
export { e as BOTMANOR_PERMISSIONS, t as BotmanorPermissionGate,
|
|
2
|
+
import { BotmanorPermissionGate as t, resolvePermission as n, useBotmanorCan as r, useBotmanorPermission as i, useBotmanorPermissionDecision as a } from "./useBotmanorPermissions.js";
|
|
3
|
+
import { RequirePermission as o } from "./PermissionRequired.js";
|
|
4
|
+
export { e as BOTMANOR_PERMISSIONS, t as BotmanorPermissionGate, o as RequirePermission, n as resolvePermission, r as useBotmanorCan, i as useBotmanorPermission, a as useBotmanorPermissionDecision };
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { joinPath as e } from "../utils/navigation.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { SupervisorActionProvider as t } from "./SupervisorActionScope.js";
|
|
3
|
+
import { createContext as n, useCallback as r, useContext as i, useMemo as a } from "react";
|
|
4
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
5
|
+
import { MemoryRouter as s, useNavigate as c } from "react-router";
|
|
5
6
|
// src/botlit/providers/BotlitProvider.tsx
|
|
6
|
-
var
|
|
7
|
-
function
|
|
8
|
-
let e =
|
|
7
|
+
var l = n(null);
|
|
8
|
+
function u() {
|
|
9
|
+
let e = i(l);
|
|
9
10
|
if (!e) throw Error("useBotlit must be used within a BotlitProvider");
|
|
10
11
|
return e;
|
|
11
12
|
}
|
|
12
|
-
var
|
|
13
|
-
let _ =
|
|
13
|
+
var d = ({ children: t, basePath: n, currentUser: i, tenantId: s, organizationId: u, workspaceId: d, apiGatewayUrl: f, authToken: p, productId: m, onBotSelect: h, onAgentSelect: g }) => {
|
|
14
|
+
let _ = c(), v = n || "/", y = r((t) => e(v, t), [v]), b = r((t) => {
|
|
14
15
|
let n = e(v, t);
|
|
15
16
|
_(n);
|
|
16
|
-
}, [v, _]), x =
|
|
17
|
+
}, [v, _]), x = a(() => ({
|
|
17
18
|
basePath: v,
|
|
18
19
|
navigate: void 0,
|
|
19
|
-
currentUser:
|
|
20
|
-
tenantId:
|
|
20
|
+
currentUser: i,
|
|
21
|
+
tenantId: s,
|
|
21
22
|
organizationId: u,
|
|
22
23
|
workspaceId: d,
|
|
23
24
|
apiGatewayUrl: f,
|
|
@@ -30,8 +31,8 @@ var u = ({ children: t, basePath: r, currentUser: o, tenantId: l, organizationId
|
|
|
30
31
|
getPath: y
|
|
31
32
|
}), [
|
|
32
33
|
v,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
i,
|
|
35
|
+
s,
|
|
35
36
|
u,
|
|
36
37
|
d,
|
|
37
38
|
f,
|
|
@@ -42,18 +43,18 @@ var u = ({ children: t, basePath: r, currentUser: o, tenantId: l, organizationId
|
|
|
42
43
|
b,
|
|
43
44
|
y
|
|
44
45
|
]);
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
+
return /* @__PURE__ */ o(l.Provider, {
|
|
46
47
|
value: x,
|
|
47
48
|
children: t
|
|
48
49
|
});
|
|
49
|
-
},
|
|
50
|
-
let _ =
|
|
51
|
-
|
|
52
|
-
}, [_,
|
|
50
|
+
}, f = ({ children: t, basePath: n, navigate: i, currentUser: s, tenantId: c, organizationId: u, workspaceId: d, apiGatewayUrl: f, authToken: p, productId: m, onBotSelect: h, onAgentSelect: g }) => {
|
|
51
|
+
let _ = n || "/", v = r((t) => e(_, t), [_]), y = r((t) => {
|
|
52
|
+
i(e(_, t));
|
|
53
|
+
}, [_, i]), b = a(() => ({
|
|
53
54
|
basePath: _,
|
|
54
|
-
navigate:
|
|
55
|
+
navigate: i,
|
|
55
56
|
currentUser: s,
|
|
56
|
-
tenantId:
|
|
57
|
+
tenantId: c,
|
|
57
58
|
organizationId: u,
|
|
58
59
|
workspaceId: d,
|
|
59
60
|
apiGatewayUrl: f,
|
|
@@ -66,9 +67,9 @@ var u = ({ children: t, basePath: r, currentUser: o, tenantId: l, organizationId
|
|
|
66
67
|
getPath: v
|
|
67
68
|
}), [
|
|
68
69
|
_,
|
|
69
|
-
|
|
70
|
+
i,
|
|
70
71
|
s,
|
|
71
|
-
|
|
72
|
+
c,
|
|
72
73
|
u,
|
|
73
74
|
d,
|
|
74
75
|
f,
|
|
@@ -79,23 +80,30 @@ var u = ({ children: t, basePath: r, currentUser: o, tenantId: l, organizationId
|
|
|
79
80
|
y,
|
|
80
81
|
v
|
|
81
82
|
]);
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ o(l.Provider, {
|
|
83
84
|
value: b,
|
|
84
85
|
children: t
|
|
85
86
|
});
|
|
86
|
-
},
|
|
87
|
-
let { children:
|
|
88
|
-
|
|
87
|
+
}, p = (e) => {
|
|
88
|
+
let { children: n, navigate: r, tenantId: i, workspaceId: a, currentUser: c } = e, l = JSON.stringify([
|
|
89
|
+
i,
|
|
90
|
+
a,
|
|
91
|
+
c?.id
|
|
92
|
+
]), u = /* @__PURE__ */ o(t, {
|
|
93
|
+
scopeKey: l,
|
|
94
|
+
children: n
|
|
95
|
+
});
|
|
96
|
+
return r ? /* @__PURE__ */ o(f, {
|
|
89
97
|
...e,
|
|
90
|
-
navigate:
|
|
98
|
+
navigate: r,
|
|
91
99
|
isStandalone: !1,
|
|
92
|
-
children:
|
|
93
|
-
}) : /* @__PURE__ */
|
|
100
|
+
children: u
|
|
101
|
+
}) : /* @__PURE__ */ o(s, { children: /* @__PURE__ */ o(d, {
|
|
94
102
|
...e,
|
|
95
103
|
isStandalone: !0,
|
|
96
|
-
children:
|
|
104
|
+
children: u
|
|
97
105
|
}) });
|
|
98
106
|
};
|
|
99
|
-
export {
|
|
107
|
+
export { p as BotlitProvider, u as useBotlit };
|
|
100
108
|
|
|
101
109
|
//# sourceMappingURL=BotlitProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotlitProvider.js","names":["useRouterNavigate","BotlitContext","createContext","useBotlit","context","useContext","StandaloneProviderInner","routerNavigate","useNavigate","effectiveBasePath","basePath","getPath","useCallback","joinPath","relativePath","navigateTo","fullPath","contextValue","useMemo","currentUser","tenantId","organizationId","workspaceId","apiGatewayUrl","authToken","productId","onBotSelect","onAgentSelect","IntegratedProviderInner","navigate","BotlitProvider","props","MemoryRouter"],"sources":["../../../src/botlit/providers/BotlitProvider.tsx"],"sourcesContent":["/**\n * BotManor Context Provider\n * @module botlit/providers\n */\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createContext, useContext, useMemo, useCallback } from 'react';\nimport { MemoryRouter, useNavigate as useRouterNavigate } from 'react-router';\nimport type { BotmanorRootProps } from '../types';\nimport { joinPath } from '../utils/navigation';\n\n// ============================================================================\n// Context\n// ============================================================================\n\ninterface BotlitContextValue extends Omit<\n BotmanorRootProps,\n 'registerNavItems' | 'registerFooterItems' | 'navigate'\n> {\n isStandalone: boolean;\n /** Shell's navigate function (only available in integrated mode) */\n navigate?: (path: string) => void;\n /** Navigate to a path relative to basePath */\n navigateTo: (relativePath: string) => void;\n /** Get the full path for a relative path */\n getPath: (relativePath: string) => string;\n}\n\nconst BotlitContext = createContext<BotlitContextValue | null>(null);\n\n// ============================================================================\n// Hook\n// ============================================================================\n\nexport function useBotlit(): BotlitContextValue {\n const context = useContext(BotlitContext);\n if (!context) {\n throw new Error('useBotlit must be used within a BotlitProvider');\n }\n return context;\n}\n\n// ============================================================================\n// Provider Component\n// ============================================================================\n\ntype ProviderProps = Omit<BotmanorRootProps, 'registerNavItems' | 'registerFooterItems'> & {\n isStandalone: boolean;\n};\n\n/** Provider for standalone mode (has access to MemoryRouter) */\nconst StandaloneProviderInner: FC<PropsWithChildren<ProviderProps>> = ({\n children,\n basePath,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n}) => {\n // Always call hooks unconditionally in this component\n const routerNavigate = useRouterNavigate();\n const effectiveBasePath = basePath || '/';\n\n const getPath = useCallback(\n (relativePath: string) => joinPath(effectiveBasePath, relativePath),\n [effectiveBasePath]\n );\n\n const navigateTo = useCallback(\n (relativePath: string) => {\n const fullPath = joinPath(effectiveBasePath, relativePath);\n routerNavigate(fullPath);\n },\n [effectiveBasePath, routerNavigate]\n );\n\n const contextValue = useMemo<BotlitContextValue>(\n () => ({\n basePath: effectiveBasePath,\n navigate: undefined,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n isStandalone: true,\n navigateTo,\n getPath,\n }),\n [\n effectiveBasePath,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n navigateTo,\n getPath,\n ]\n );\n\n return <BotlitContext.Provider value={contextValue}>{children}</BotlitContext.Provider>;\n};\n\n/** Provider for integrated mode (shell provides navigate) */\nconst IntegratedProviderInner: FC<\n PropsWithChildren<ProviderProps & { navigate: (path: string) => void }>\n> = ({\n children,\n basePath,\n navigate,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n}) => {\n const effectiveBasePath = basePath || '/';\n\n const getPath = useCallback(\n (relativePath: string) => joinPath(effectiveBasePath, relativePath),\n [effectiveBasePath]\n );\n\n const navigateTo = useCallback(\n (relativePath: string) => {\n const fullPath = joinPath(effectiveBasePath, relativePath);\n navigate(fullPath);\n },\n [effectiveBasePath, navigate]\n );\n\n const contextValue = useMemo<BotlitContextValue>(\n () => ({\n basePath: effectiveBasePath,\n navigate,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n isStandalone: false,\n navigateTo,\n getPath,\n }),\n [\n effectiveBasePath,\n navigate,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n navigateTo,\n getPath,\n ]\n );\n\n return <BotlitContext.Provider value={contextValue}>{children}</BotlitContext.Provider>;\n};\n\nexport const BotlitProvider: FC<PropsWithChildren<BotmanorRootProps>> = (props) => {\n const { children, navigate } = props;\n // Standalone mode: no navigate function provided (MFE manages its own router)\n // Integrated mode: navigate function provided by shell (shell provides router)\n const isStandalone = !navigate;\n\n // Standalone mode: wrap in MemoryRouter\n if (isStandalone) {\n return (\n <MemoryRouter>\n <StandaloneProviderInner {...props} isStandalone={true}>\n {
|
|
1
|
+
{"version":3,"file":"BotlitProvider.js","names":["useRouterNavigate","BotlitContext","createContext","useBotlit","context","useContext","StandaloneProviderInner","routerNavigate","useNavigate","effectiveBasePath","basePath","getPath","useCallback","joinPath","relativePath","navigateTo","fullPath","contextValue","useMemo","currentUser","tenantId","organizationId","workspaceId","apiGatewayUrl","authToken","productId","onBotSelect","onAgentSelect","IntegratedProviderInner","navigate","BotlitProvider","props","scopeKey","workspaceChildren","SupervisorActionProvider","MemoryRouter"],"sources":["../../../src/botlit/providers/BotlitProvider.tsx"],"sourcesContent":["/**\n * BotManor Context Provider\n * @module botlit/providers\n */\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createContext, useContext, useMemo, useCallback } from 'react';\nimport { MemoryRouter, useNavigate as useRouterNavigate } from 'react-router';\nimport type { BotmanorRootProps } from '../types';\nimport { joinPath } from '../utils/navigation';\nimport { SupervisorActionProvider } from './SupervisorActionScope';\n\n// ============================================================================\n// Context\n// ============================================================================\n\ninterface BotlitContextValue extends Omit<\n BotmanorRootProps,\n 'registerNavItems' | 'registerFooterItems' | 'navigate'\n> {\n isStandalone: boolean;\n /** Shell's navigate function (only available in integrated mode) */\n navigate?: (path: string) => void;\n /** Navigate to a path relative to basePath */\n navigateTo: (relativePath: string) => void;\n /** Get the full path for a relative path */\n getPath: (relativePath: string) => string;\n}\n\nconst BotlitContext = createContext<BotlitContextValue | null>(null);\n\n// ============================================================================\n// Hook\n// ============================================================================\n\nexport function useBotlit(): BotlitContextValue {\n const context = useContext(BotlitContext);\n if (!context) {\n throw new Error('useBotlit must be used within a BotlitProvider');\n }\n return context;\n}\n\n// ============================================================================\n// Provider Component\n// ============================================================================\n\ntype ProviderProps = Omit<BotmanorRootProps, 'registerNavItems' | 'registerFooterItems'> & {\n isStandalone: boolean;\n};\n\n/** Provider for standalone mode (has access to MemoryRouter) */\nconst StandaloneProviderInner: FC<PropsWithChildren<ProviderProps>> = ({\n children,\n basePath,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n}) => {\n // Always call hooks unconditionally in this component\n const routerNavigate = useRouterNavigate();\n const effectiveBasePath = basePath || '/';\n\n const getPath = useCallback(\n (relativePath: string) => joinPath(effectiveBasePath, relativePath),\n [effectiveBasePath]\n );\n\n const navigateTo = useCallback(\n (relativePath: string) => {\n const fullPath = joinPath(effectiveBasePath, relativePath);\n routerNavigate(fullPath);\n },\n [effectiveBasePath, routerNavigate]\n );\n\n const contextValue = useMemo<BotlitContextValue>(\n () => ({\n basePath: effectiveBasePath,\n navigate: undefined,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n isStandalone: true,\n navigateTo,\n getPath,\n }),\n [\n effectiveBasePath,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n navigateTo,\n getPath,\n ]\n );\n\n return <BotlitContext.Provider value={contextValue}>{children}</BotlitContext.Provider>;\n};\n\n/** Provider for integrated mode (shell provides navigate) */\nconst IntegratedProviderInner: FC<\n PropsWithChildren<ProviderProps & { navigate: (path: string) => void }>\n> = ({\n children,\n basePath,\n navigate,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n}) => {\n const effectiveBasePath = basePath || '/';\n\n const getPath = useCallback(\n (relativePath: string) => joinPath(effectiveBasePath, relativePath),\n [effectiveBasePath]\n );\n\n const navigateTo = useCallback(\n (relativePath: string) => {\n const fullPath = joinPath(effectiveBasePath, relativePath);\n navigate(fullPath);\n },\n [effectiveBasePath, navigate]\n );\n\n const contextValue = useMemo<BotlitContextValue>(\n () => ({\n basePath: effectiveBasePath,\n navigate,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n isStandalone: false,\n navigateTo,\n getPath,\n }),\n [\n effectiveBasePath,\n navigate,\n currentUser,\n tenantId,\n organizationId,\n workspaceId,\n apiGatewayUrl,\n authToken,\n productId,\n onBotSelect,\n onAgentSelect,\n navigateTo,\n getPath,\n ]\n );\n\n return <BotlitContext.Provider value={contextValue}>{children}</BotlitContext.Provider>;\n};\n\nexport const BotlitProvider: FC<PropsWithChildren<BotmanorRootProps>> = (props) => {\n const { children, navigate, tenantId, workspaceId, currentUser } = props;\n const scopeKey = JSON.stringify([tenantId, workspaceId, currentUser?.id]);\n const workspaceChildren = (\n <SupervisorActionProvider scopeKey={scopeKey}>{children}</SupervisorActionProvider>\n );\n // Standalone mode: no navigate function provided (MFE manages its own router)\n // Integrated mode: navigate function provided by shell (shell provides router)\n const isStandalone = !navigate;\n\n // Standalone mode: wrap in MemoryRouter\n if (isStandalone) {\n return (\n <MemoryRouter>\n <StandaloneProviderInner {...props} isStandalone={true}>\n {workspaceChildren}\n </StandaloneProviderInner>\n </MemoryRouter>\n );\n }\n\n // Integrated mode: shell provides router\n return (\n <IntegratedProviderInner {...props} navigate={navigate} isStandalone={false}>\n {workspaceChildren}\n </IntegratedProviderInner>\n );\n};\n"],"mappings":";;;;;;AA6BA,IAAMC,IAAgBC,EAAyC,IAAI;AAMnE,SAAgBC,IAAgC;CAC9C,IAAMC,IAAUC,EAAWJ,CAAa;CACxC,IAAI,CAACG,GACH,MAAU,MAAM,gDAAgD;CAElE,OAAOA;AACT;AAWA,IAAME,KAAiE,EACrE,aACA,aACA,gBACA,aACA,mBACA,gBACA,kBACA,cACA,cACA,gBACA,uBACI;CAEJ,IAAMC,IAAiBP,EAAkB,GACnCS,IAAoBC,KAAY,KAEhCC,IAAUC,GACb,MAAyBC,EAASJ,GAAmBK,CAAY,GAClE,CAACL,CAAiB,CACpB,GAEMM,IAAaH,GAChB,MAAyB;EACxB,IAAMI,IAAWH,EAASJ,GAAmBK,CAAY;EACzD,EAAeE,CAAQ;CACzB,GACA,CAACP,GAAmBF,CAAc,CACpC,GAEMU,IAAeC,SACZ;EACL,UAAUT;EACV,UAAU,KAAA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;CACF,IACA;EACEA;EACAU;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAZ;EACAJ;CACF,CACF;CAEA,OAAO,kBAACV,EAAc,UAAf;EAAwB,OAAOgB;EAAe;CAAiC,CAAA;AACxF,GAGMW,KAED,EACH,aACA,aACA,aACA,gBACA,aACA,mBACA,gBACA,kBACA,cACA,cACA,gBACA,uBACI;CACJ,IAAMnB,IAAoBC,KAAY,KAEhCC,IAAUC,GACb,MAAyBC,EAASJ,GAAmBK,CAAY,GAClE,CAACL,CAAiB,CACpB,GAEMM,IAAaH,GAChB,MAAyB;EAExB,EADiBC,EAASJ,GAAmBK,CACpC,CAAQ;CACnB,GACA,CAACL,GAAmBoB,CAAQ,CAC9B,GAEMZ,IAAeC,SACZ;EACL,UAAUT;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;CACF,IACA;EACEA;EACAoB;EACAV;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAZ;EACAJ;CACF,CACF;CAEA,OAAO,kBAACV,EAAc,UAAf;EAAwB,OAAOgB;EAAe;CAAiC,CAAA;AACxF,GAEaa,KAA4D,MAAU;CACjF,IAAM,EAAE,aAAU,aAAU,aAAU,gBAAa,mBAAgBC,GAC7DC,IAAW,KAAK,UAAU;EAACZ;EAAUE;EAAaH,GAAa;CAAE,CAAC,GAClEc,IACJ,kBAACC,GAAD;EAAoC;EAAW;CAAmC,CAAA;CAkBpF,OAdsBL,IAepB,kBAACD,GAAD;EAAyB,GAAIG;EAAiB;EAAU,cAAc;EACnE,UAAAE;CACsB,CAAA,IAZvB,kBAACE,GAAD,EAAA,UACE,kBAAC7B,GAAD;EAAyB,GAAIyB;EAAO,cAAc;EAC/C,UAAAE;CACsB,CAAA,EACb,CAAA;AAUpB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
interface ActionSnapshot {
|
|
3
|
+
busy: boolean;
|
|
4
|
+
completedActions: ReadonlySet<string>;
|
|
5
|
+
}
|
|
6
|
+
/** Keeps Supervisor receipts and in-flight actions across routes within one workspace session. */
|
|
7
|
+
export declare function SupervisorActionProvider({ children, scopeKey, }: PropsWithChildren<{
|
|
8
|
+
scopeKey: string;
|
|
9
|
+
}>): import('react').JSX.Element;
|
|
10
|
+
export declare function useSupervisorActionScope(): {
|
|
11
|
+
key: string;
|
|
12
|
+
activate(): () => void;
|
|
13
|
+
isActive: () => boolean;
|
|
14
|
+
getSnapshot: () => ActionSnapshot;
|
|
15
|
+
subscribe(listener: () => void): () => void;
|
|
16
|
+
start(): boolean;
|
|
17
|
+
finish(): void;
|
|
18
|
+
acknowledge(id: string): void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createContext as e, useContext as t, useLayoutEffect as n, useMemo as r } from "react";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
// src/botlit/providers/SupervisorActionScope.tsx
|
|
4
|
+
function a(e) {
|
|
5
|
+
let t = !1, n = {
|
|
6
|
+
busy: !1,
|
|
7
|
+
completedActions: /* @__PURE__ */ new Set()
|
|
8
|
+
}, r = /* @__PURE__ */ new Set();
|
|
9
|
+
function i(e) {
|
|
10
|
+
n = e, r.forEach((e) => e());
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
key: e,
|
|
14
|
+
activate() {
|
|
15
|
+
return t = !0, () => {
|
|
16
|
+
t = !1;
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
isActive: () => t,
|
|
20
|
+
getSnapshot: () => n,
|
|
21
|
+
subscribe(e) {
|
|
22
|
+
return r.add(e), () => {
|
|
23
|
+
r.delete(e);
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
start() {
|
|
27
|
+
return !t || n.busy ? !1 : (i({
|
|
28
|
+
...n,
|
|
29
|
+
busy: !0
|
|
30
|
+
}), !0);
|
|
31
|
+
},
|
|
32
|
+
finish() {
|
|
33
|
+
i({
|
|
34
|
+
...n,
|
|
35
|
+
busy: !1
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
acknowledge(e) {
|
|
39
|
+
i({
|
|
40
|
+
...n,
|
|
41
|
+
completedActions: new Set(n.completedActions).add(e)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var o = e(null);
|
|
47
|
+
function s({ children: e, scopeKey: t }) {
|
|
48
|
+
let s = r(() => a(t), [t]);
|
|
49
|
+
return n(() => s.activate(), [s]), /* @__PURE__ */ i(o.Provider, {
|
|
50
|
+
value: s,
|
|
51
|
+
children: e
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function c() {
|
|
55
|
+
let e = t(o);
|
|
56
|
+
if (!e) throw Error("Supervisor actions require a BotManor workspace provider.");
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
export { s as SupervisorActionProvider, c as useSupervisorActionScope };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=SupervisorActionScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SupervisorActionScope.js","names":["createActionScope","active","snapshot","listeners","publish","next","listener","id","SupervisorActionContext","createContext","SupervisorActionProvider","scope","useMemo","scopeKey","useLayoutEffect","useSupervisorActionScope","useContext"],"sources":["../../../src/botlit/providers/SupervisorActionScope.tsx"],"sourcesContent":["import { createContext, useContext, useLayoutEffect, useMemo, type PropsWithChildren } from 'react';\n\ninterface ActionSnapshot {\n busy: boolean;\n completedActions: ReadonlySet<string>;\n}\n\nfunction createActionScope(key: string) {\n let active = false;\n let snapshot: ActionSnapshot = { busy: false, completedActions: new Set() };\n const listeners = new Set<() => void>();\n\n function publish(next: ActionSnapshot) {\n snapshot = next;\n listeners.forEach((listener) => listener());\n }\n\n return {\n key,\n activate() {\n active = true;\n return () => {\n active = false;\n };\n },\n isActive: () => active,\n getSnapshot: () => snapshot,\n subscribe(listener: () => void) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n start() {\n if (!active || snapshot.busy) return false;\n publish({ ...snapshot, busy: true });\n return true;\n },\n finish() {\n publish({ ...snapshot, busy: false });\n },\n acknowledge(id: string) {\n publish({ ...snapshot, completedActions: new Set(snapshot.completedActions).add(id) });\n },\n };\n}\n\nconst SupervisorActionContext = createContext<ReturnType<typeof createActionScope> | null>(null);\n\n/** Keeps Supervisor receipts and in-flight actions across routes within one workspace session. */\nexport function SupervisorActionProvider({\n children,\n scopeKey,\n}: PropsWithChildren<{ scopeKey: string }>) {\n const scope = useMemo(() => createActionScope(scopeKey), [scopeKey]);\n useLayoutEffect(() => scope.activate(), [scope]);\n return (\n <SupervisorActionContext.Provider value={scope}>{children}</SupervisorActionContext.Provider>\n );\n}\n\nexport function useSupervisorActionScope() {\n const scope = useContext(SupervisorActionContext);\n if (!scope) throw new Error('Supervisor actions require a BotManor workspace provider.');\n return scope;\n}\n"],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
|
25
25
|
blockedPatterns: string;
|
|
26
|
+
/** BOFF-15360 — refuse input that tries to override the agent's instructions. */
|
|
27
|
+
promptInjectionDetection: boolean;
|
|
26
28
|
};
|
|
27
29
|
tool: {
|
|
28
30
|
allowedTools: string;
|
|
@@ -31,6 +33,14 @@ export interface PolicyFormState {
|
|
|
31
33
|
a2aMinTrustLevel: '' | (typeof A2A_TRUST_LEVELS)[number];
|
|
32
34
|
maxCallsPerExecution: string;
|
|
33
35
|
timeoutSeconds: string;
|
|
36
|
+
/** BOFF-15360 — tool calls that wait for a human decision. */
|
|
37
|
+
approvalRiskLevels: Array<(typeof TOOL_RISK_LEVELS)[number]>;
|
|
38
|
+
approvalTools: string;
|
|
39
|
+
approvalServers: string;
|
|
40
|
+
approverRoles: string;
|
|
41
|
+
approverUserIds: string;
|
|
42
|
+
approvalTimeoutMinutes: string;
|
|
43
|
+
requesterConfirmation: boolean;
|
|
34
44
|
};
|
|
35
45
|
budget: {
|
|
36
46
|
maxTokensPerDay: string;
|
|
@@ -88,6 +98,8 @@ export type PolicyConfigResult = {
|
|
|
88
98
|
export declare function splitList(value: string): string[];
|
|
89
99
|
/** Split a one-entry-per-line form value into trimmed, non-empty entries. */
|
|
90
100
|
export declare function splitLines(value: string): string[];
|
|
101
|
+
/** Longest a tool call may wait for a decision (seven days, as the runtime clamps it). */
|
|
102
|
+
export declare const MAX_APPROVAL_TIMEOUT_MINUTES: number;
|
|
91
103
|
/**
|
|
92
104
|
* Build the config for a new policy from the editor state, or explain what is
|
|
93
105
|
* wrong with the input. Only enforced keys are ever written.
|