@burdenoff/microfe-botmanor 2026.1201.2 → 2026.1202.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 +2 -1
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/components/GettingStartedChecklist.js +1 -1
- package/dist/botlit/components/GettingStartedChecklist.js.map +1 -1
- package/dist/botlit/components/StewardApprovalsInbox.d.ts +4 -0
- package/dist/botlit/components/StewardApprovalsInbox.js +419 -0
- package/dist/botlit/components/StewardApprovalsInbox.js.map +1 -0
- package/dist/botlit/hooks/useAgentApprovals.js +28 -17
- package/dist/botlit/hooks/useAgentApprovals.js.map +1 -1
- package/dist/botlit/hooks/useBotAgents.js +15 -11
- package/dist/botlit/hooks/useBotAgents.js.map +1 -1
- package/dist/botlit/hooks/useBots.js +36 -62
- package/dist/botlit/hooks/useBots.js.map +1 -1
- package/dist/botlit/hooks/useBuckets.js +31 -24
- package/dist/botlit/hooks/useBuckets.js.map +1 -1
- package/dist/botlit/hooks/useChannels.js +44 -30
- package/dist/botlit/hooks/useChannels.js.map +1 -1
- package/dist/botlit/hooks/useLLMProviders.js +8 -6
- package/dist/botlit/hooks/useLLMProviders.js.map +1 -1
- package/dist/botlit/hooks/useMCPServers.js +21 -17
- package/dist/botlit/hooks/useMCPServers.js.map +1 -1
- package/dist/botlit/hooks/usePromptTemplates.js +5 -3
- package/dist/botlit/hooks/usePromptTemplates.js.map +1 -1
- package/dist/botlit/hooks/useStorePublishing.js +20 -10
- package/dist/botlit/hooks/useStorePublishing.js.map +1 -1
- package/dist/botlit/hooks/useTemplates.js +35 -29
- package/dist/botlit/hooks/useTemplates.js.map +1 -1
- package/dist/botlit/hooks/useToolApprovals.d.ts +38 -5
- package/dist/botlit/hooks/useToolApprovals.js +50 -31
- package/dist/botlit/hooks/useToolApprovals.js.map +1 -1
- package/dist/botlit/pages/ToolApprovalsPage.js +125 -106
- package/dist/botlit/pages/ToolApprovalsPage.js.map +1 -1
- package/dist/botlit/permissions/botmanorPermissions.d.ts +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
- package/dist/botlit/utils/stewardApprovals.d.ts +80 -0
- package/dist/botlit/utils/stewardApprovals.js +90 -0
- package/dist/botlit/utils/stewardApprovals.js.map +1 -0
- package/dist/generated/global-types.d.ts +7580 -811
- package/dist/generated/global-types.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +522 -3
- package/dist/generated/wspace-operations.js +281 -15
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +9369 -61
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useWorkspaceAllPagesQuery as e, useWorkspaceId as t, useWorkspaceMutation as n } from "./internal/workspaceGateway.js";
|
|
2
2
|
import { useMemo as r } from "react";
|
|
3
3
|
import { gql as i } from "@apollo/client";
|
|
4
4
|
// src/botlit/hooks/useTemplates.ts
|
|
5
5
|
var a = i`
|
|
6
|
-
query ListBotTemplates($pagination:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
query ListBotTemplates($pagination: BotmanorOffsetPaginationInput) {
|
|
7
|
+
listBotmanorAppTemplatesPage(pagination: $pagination) {
|
|
8
|
+
items {
|
|
9
|
+
id
|
|
10
|
+
name
|
|
11
|
+
description
|
|
12
|
+
category
|
|
13
|
+
}
|
|
14
|
+
nextOffset
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
17
|
`, o = i`
|
|
15
|
-
query ListAgentTemplatesForCreate($pagination:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
query ListAgentTemplatesForCreate($pagination: BotmanorOffsetPaginationInput) {
|
|
19
|
+
listBotmanorAgentTemplatesPage(pagination: $pagination) {
|
|
20
|
+
items {
|
|
21
|
+
id
|
|
22
|
+
name
|
|
23
|
+
description
|
|
24
|
+
category
|
|
25
|
+
}
|
|
26
|
+
nextOffset
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
`, s = i`
|
|
@@ -38,34 +44,34 @@ var a = i`
|
|
|
38
44
|
name
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
|
-
`, l = [], u =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let i = e(), s = r(() => u, []);
|
|
47
|
-
return n({
|
|
48
|
-
document: t === "bot" ? a : o,
|
|
47
|
+
`, l = [], u = 100, d = {};
|
|
48
|
+
function f(n) {
|
|
49
|
+
let i = t(), s = r(() => d, []);
|
|
50
|
+
return e({
|
|
51
|
+
document: n === "bot" ? a : o,
|
|
49
52
|
variables: s,
|
|
50
|
-
|
|
53
|
+
pageSize: u,
|
|
54
|
+
extractRows: (e) => (n === "bot" ? e?.listBotmanorAppTemplatesPage?.items : e?.listBotmanorAgentTemplatesPage?.items) ?? l,
|
|
55
|
+
extractNextOffset: (e) => (n === "bot" ? e?.listBotmanorAppTemplatesPage?.nextOffset : e?.listBotmanorAgentTemplatesPage?.nextOffset) ?? null,
|
|
56
|
+
select: (e) => e,
|
|
51
57
|
fallback: l,
|
|
52
58
|
enabled: !!i,
|
|
53
59
|
errorMessage: "Failed to load templates"
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
|
-
function
|
|
57
|
-
let r =
|
|
58
|
-
return
|
|
59
|
-
document:
|
|
62
|
+
function p(e) {
|
|
63
|
+
let r = t();
|
|
64
|
+
return n({
|
|
65
|
+
document: e === "bot" ? s : c,
|
|
60
66
|
variables: ({ name: e, templateId: t }) => ({
|
|
61
67
|
name: e.trim(),
|
|
62
68
|
templateId: t,
|
|
63
69
|
workspaceId: r
|
|
64
70
|
}),
|
|
65
|
-
select: (
|
|
66
|
-
errorMessage:
|
|
71
|
+
select: (t) => (e === "bot" ? t?.createAppFromTemplate : t?.createBotmanorAgentFromTemplate) ?? void 0,
|
|
72
|
+
errorMessage: e === "bot" ? "Failed to create the bot from the template" : "Failed to create the agent from the template"
|
|
67
73
|
});
|
|
68
74
|
}
|
|
69
|
-
export {
|
|
75
|
+
export { p as useCreateFromTemplate, f as useTemplates };
|
|
70
76
|
|
|
71
77
|
//# sourceMappingURL=useTemplates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTemplates.js","names":["LIST_APP_TEMPLATES_DOCUMENT","LIST_AGENT_TEMPLATES_DOCUMENT","CREATE_APP_FROM_TEMPLATE_DOCUMENT","CREATE_AGENT_FROM_TEMPLATE_DOCUMENT","NO_TEMPLATES","
|
|
1
|
+
{"version":3,"file":"useTemplates.js","names":["LIST_APP_TEMPLATES_DOCUMENT","LIST_AGENT_TEMPLATES_DOCUMENT","CREATE_APP_FROM_TEMPLATE_DOCUMENT","CREATE_AGENT_FROM_TEMPLATE_DOCUMENT","NO_TEMPLATES","TEMPLATE_PAGE_SIZE","EMPTY_VARIABLES","useTemplates","workspaceId","useWorkspaceId","variables","useMemo","useWorkspaceAllPagesQuery","kind","data","rows","useCreateFromTemplate","useWorkspaceMutation","name"],"sources":["../../../src/botlit/hooks/useTemplates.ts"],"sourcesContent":["/**\n * App and agent templates (BOFF-15360)\n * @module botlit/hooks\n *\n * Every workspace is provisioned with a starter catalogue of bot (app) and\n * agent templates. These hooks list them and create a bot or an agent from one\n * in a single step, the \"Create from template\" flow on the create pages.\n */\n\nimport { gql } from '@apollo/client';\nimport { useMemo } from 'react';\n\nimport {\n useWorkspaceAllPagesQuery,\n useWorkspaceId,\n useWorkspaceMutation,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nexport interface TemplateRecord {\n id: string;\n name: string;\n description?: string | null;\n category?: string | null;\n}\n\ninterface ListAppTemplatesData {\n listBotmanorAppTemplatesPage?: {\n items: TemplateRecord[];\n nextOffset: number | null;\n } | null;\n}\n\ninterface ListAgentTemplatesData {\n listBotmanorAgentTemplatesPage?: {\n items: TemplateRecord[];\n nextOffset: number | null;\n } | null;\n}\n\ninterface CreatedRecord {\n id: string;\n name: string;\n}\n\ninterface CreateAppFromTemplateData {\n createAppFromTemplate?: CreatedRecord | null;\n}\n\ninterface CreateAgentFromTemplateData {\n createBotmanorAgentFromTemplate?: CreatedRecord | null;\n}\n\nconst LIST_APP_TEMPLATES_DOCUMENT = gql`\n query ListBotTemplates($pagination: BotmanorOffsetPaginationInput) {\n listBotmanorAppTemplatesPage(pagination: $pagination) {\n items {\n id\n name\n description\n category\n }\n nextOffset\n }\n }\n`;\n\nconst LIST_AGENT_TEMPLATES_DOCUMENT = gql`\n query ListAgentTemplatesForCreate($pagination: BotmanorOffsetPaginationInput) {\n listBotmanorAgentTemplatesPage(pagination: $pagination) {\n items {\n id\n name\n description\n category\n }\n nextOffset\n }\n }\n`;\n\nconst CREATE_APP_FROM_TEMPLATE_DOCUMENT = gql`\n mutation CreateBotFromTemplate($name: String!, $templateId: ID!, $workspaceId: ID!) {\n createAppFromTemplate(name: $name, templateId: $templateId, workspaceId: $workspaceId) {\n id\n name\n }\n }\n`;\n\nconst CREATE_AGENT_FROM_TEMPLATE_DOCUMENT = gql`\n mutation CreateAgentFromTemplate($name: String!, $templateId: ID!, $workspaceId: ID!) {\n createBotmanorAgentFromTemplate(\n name: $name\n templateId: $templateId\n workspaceId: $workspaceId\n ) {\n id\n name\n }\n }\n`;\n\nconst NO_TEMPLATES: TemplateRecord[] = [];\nconst TEMPLATE_PAGE_SIZE = 100;\nconst EMPTY_VARIABLES = {};\n\nexport type TemplateKind = 'bot' | 'agent';\n\nexport function useTemplates(kind: TemplateKind): QueryResult<TemplateRecord[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => EMPTY_VARIABLES, []);\n return useWorkspaceAllPagesQuery<\n ListAppTemplatesData & ListAgentTemplatesData,\n TemplateRecord,\n TemplateRecord[]\n >({\n document: kind === 'bot' ? LIST_APP_TEMPLATES_DOCUMENT : LIST_AGENT_TEMPLATES_DOCUMENT,\n variables,\n pageSize: TEMPLATE_PAGE_SIZE,\n extractRows: (data) =>\n (kind === 'bot'\n ? data?.listBotmanorAppTemplatesPage?.items\n : data?.listBotmanorAgentTemplatesPage?.items) ?? NO_TEMPLATES,\n extractNextOffset: (data) =>\n (kind === 'bot'\n ? data?.listBotmanorAppTemplatesPage?.nextOffset\n : data?.listBotmanorAgentTemplatesPage?.nextOffset) ?? null,\n select: (rows) => rows,\n fallback: NO_TEMPLATES,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load templates',\n });\n}\n\nexport interface CreateFromTemplateInput {\n name: string;\n templateId: string;\n}\n\nexport function useCreateFromTemplate(kind: TemplateKind) {\n const workspaceId = useWorkspaceId();\n return useWorkspaceMutation<\n CreateAppFromTemplateData & CreateAgentFromTemplateData,\n CreateFromTemplateInput,\n CreatedRecord\n >({\n document:\n kind === 'bot' ? CREATE_APP_FROM_TEMPLATE_DOCUMENT : CREATE_AGENT_FROM_TEMPLATE_DOCUMENT,\n variables: ({ name, templateId }) => ({ name: name.trim(), templateId, workspaceId }),\n select: (data) =>\n (kind === 'bot' ? data?.createAppFromTemplate : data?.createBotmanorAgentFromTemplate) ??\n undefined,\n errorMessage:\n kind === 'bot'\n ? 'Failed to create the bot from the template'\n : 'Failed to create the agent from the template',\n });\n}\n"],"mappings":";;;;AAqDA,IAAMA,IAA8B,CAAG;;;;;;;;;;;;GAcjCC,IAAgC,CAAG;;;;;;;;;;;;GAcnCC,IAAoC,CAAG;;;;;;;GASvCC,IAAsC,CAAG;;;;;;;;;;;GAazCC,IAAiC,CAAC,GAClCC,IAAqB,KACrBC,IAAkB,CAAC;AAIzB,SAAgBC,EAAa,GAAmD;CAC9E,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,QAAcL,GAAiB,CAAC,CAAC;CACnD,OAAOM,EAIL;EACA,UAAUC,MAAS,QAAQb,IAA8BC;EACzD;EACA,UAAUI;EACV,cAAc,OACXQ,MAAS,QACNC,GAAM,8BAA8B,QACpCA,GAAM,gCAAgC,UAAUV;EACtD,oBAAoB,OACjBS,MAAS,QACNC,GAAM,8BAA8B,aACpCA,GAAM,gCAAgC,eAAe;EAC3D,SAAS,MAASC;EAClB,UAAUX;EACV,SAAS,EAAQI;EACjB,cAAc;CAChB,CAAC;AACH;AAOA,SAAgBQ,EAAsB,GAAoB;CACxD,IAAMR,IAAcC,EAAe;CACnC,OAAOQ,EAIL;EACA,UACEJ,MAAS,QAAQX,IAAoCC;EACvD,YAAY,EAAE,SAAM,qBAAkB;GAAE,MAAMe,EAAK,KAAK;GAAG;GAAY;EAAY;EACnF,SAAS,OACNL,MAAS,QAAQC,GAAM,wBAAwBA,GAAM,oCACtD,KAAA;EACF,cACED,MAAS,QACL,+CACA;CACR,CAAC;AACH"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
export type ToolApprovalStatus = 'PENDING' | 'APPROVED' | 'DENIED' | 'EXPIRED' | 'CANCELLED';
|
|
2
2
|
export type ToolApprovalDecision = 'APPROVE' | 'DENY';
|
|
3
|
+
export type ToolApprovalSource = 'AGENT_CHAT' | 'STEWARD';
|
|
4
|
+
export type ToolApprovalScope = 'ONCE' | 'RUN' | 'DUTY' | 'TIME_LIMITED' | 'STANDING';
|
|
5
|
+
export interface ToolApprovalFilter {
|
|
6
|
+
status?: ToolApprovalStatus;
|
|
7
|
+
agentId?: string;
|
|
8
|
+
source?: ToolApprovalSource;
|
|
9
|
+
stewardId?: string;
|
|
10
|
+
/** Only the requests the caller can act on (their steward approvals inbox). */
|
|
11
|
+
mine?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolApprovalListOptions {
|
|
14
|
+
/** Page size; the inbox raises it to load more. */
|
|
15
|
+
limit?: number;
|
|
16
|
+
/** When false the query is not sent and the result stays empty. */
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const TOOL_APPROVALS_PAGE_SIZE = 50;
|
|
20
|
+
/** The filter input the service takes; empty values are left out. */
|
|
21
|
+
export declare function toFilterInput(filter: ToolApprovalFilter): Record<string, unknown>;
|
|
3
22
|
export interface ToolApprovalRecord {
|
|
4
23
|
id: string;
|
|
5
24
|
agentId: string;
|
|
@@ -26,12 +45,26 @@ export interface ToolApprovalRecord {
|
|
|
26
45
|
resumeError?: string | null;
|
|
27
46
|
resultPreview?: string | null;
|
|
28
47
|
createdAt: string;
|
|
48
|
+
source?: ToolApprovalSource | null;
|
|
49
|
+
stewardId?: string | null;
|
|
50
|
+
stewardRunId?: string | null;
|
|
51
|
+
argumentsHash?: string | null;
|
|
52
|
+
destination?: string | null;
|
|
53
|
+
purpose?: string | null;
|
|
54
|
+
requestedScope?: ToolApprovalScope | null;
|
|
55
|
+
grantedScope?: ToolApprovalScope | null;
|
|
56
|
+
/** The reviewer's verified quote of the owner's own words. */
|
|
57
|
+
charterCitation?: string | null;
|
|
58
|
+
reviewerVerdict?: string | null;
|
|
59
|
+
reviewerNote?: string | null;
|
|
60
|
+
batchKey?: string | null;
|
|
61
|
+
consumedAt?: string | null;
|
|
62
|
+
createdRuleId?: string | null;
|
|
63
|
+
/** Set for calls that always go to a person (password, payment, one-time code, external message). */
|
|
64
|
+
fixedDefault?: string | null;
|
|
29
65
|
}
|
|
30
66
|
/** Tool approval requests in the workspace, newest first. */
|
|
31
|
-
export declare function useToolApprovals(filter: {
|
|
32
|
-
status?: ToolApprovalStatus;
|
|
33
|
-
agentId?: string;
|
|
34
|
-
}): {
|
|
67
|
+
export declare function useToolApprovals(filter: ToolApprovalFilter, options?: ToolApprovalListOptions): {
|
|
35
68
|
data: ToolApprovalRecord[];
|
|
36
69
|
loading: boolean;
|
|
37
70
|
error: Error | undefined;
|
|
@@ -39,6 +72,6 @@ export declare function useToolApprovals(filter: {
|
|
|
39
72
|
};
|
|
40
73
|
/** Approve or deny a pending tool call. */
|
|
41
74
|
export declare function useDecideToolApproval(): {
|
|
42
|
-
decide: (id: string, decision: ToolApprovalDecision, note?: string) => Promise<ToolApprovalRecord>;
|
|
75
|
+
decide: (id: string, decision: ToolApprovalDecision, note?: string, scope?: ToolApprovalScope) => Promise<ToolApprovalRecord>;
|
|
43
76
|
pendingId: string | null;
|
|
44
77
|
};
|
|
@@ -3,7 +3,7 @@ import { useCallback as t, useEffect as n, useState as r } from "react";
|
|
|
3
3
|
import { gql as i } from "@apollo/client";
|
|
4
4
|
import { useGatewayClient as a } from "@burdenoff/fe-libs/shared/graphql";
|
|
5
5
|
// src/botlit/hooks/useToolApprovals.ts
|
|
6
|
-
var o = "\n id\n agentId\n agentName\n connectionId\n connectionName\n toolName\n riskLevel\n arguments\n reasons\n mode\n status\n requestedById\n userMessage\n approverRoles\n approverUserIds\n originExecutionId\n expiresAt\n deciderId\n decisionNote\n decidedAt\n resumeStatus\n resumeExecutionId\n resumeError\n resultPreview\n createdAt\n", s = i`
|
|
6
|
+
var o = "\n id\n agentId\n agentName\n connectionId\n connectionName\n toolName\n riskLevel\n arguments\n reasons\n mode\n status\n requestedById\n userMessage\n approverRoles\n approverUserIds\n originExecutionId\n expiresAt\n deciderId\n decisionNote\n decidedAt\n resumeStatus\n resumeExecutionId\n resumeError\n resultPreview\n createdAt\n source\n stewardId\n stewardRunId\n argumentsHash\n destination\n purpose\n requestedScope\n grantedScope\n charterCitation\n reviewerVerdict\n reviewerNote\n batchKey\n consumedAt\n createdRuleId\n fixedDefault\n", s = i`
|
|
7
7
|
query ListBotmanorToolApprovals(
|
|
8
8
|
$filter: BotmanorToolApprovalFilterInput
|
|
9
9
|
$pagination: PaginationInput
|
|
@@ -17,61 +17,79 @@ var o = "\n id\n agentId\n agentName\n connectionId\n connectionName\n too
|
|
|
17
17
|
$id: ID!
|
|
18
18
|
$decision: BotmanorToolApprovalDecision!
|
|
19
19
|
$note: String
|
|
20
|
+
$scope: BotmanorApprovalScope
|
|
20
21
|
) {
|
|
21
|
-
decideBotmanorToolApproval(id: $id, decision: $decision, note: $note) {
|
|
22
|
+
decideBotmanorToolApproval(id: $id, decision: $decision, note: $note, scope: $scope) {
|
|
22
23
|
${o}
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
`;
|
|
26
|
-
function l(e
|
|
27
|
+
function l(e) {
|
|
28
|
+
return {
|
|
29
|
+
status: e.status || void 0,
|
|
30
|
+
agentId: e.agentId || void 0,
|
|
31
|
+
source: e.source || void 0,
|
|
32
|
+
stewardId: e.stewardId || void 0,
|
|
33
|
+
mine: e.mine ? !0 : void 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function u(e, t) {
|
|
27
37
|
return e instanceof Error ? e : Error(t);
|
|
28
38
|
}
|
|
29
|
-
function
|
|
30
|
-
let
|
|
31
|
-
if (!
|
|
39
|
+
function d(i, o = {}) {
|
|
40
|
+
let c = a("workspace"), { workspaceId: d } = e(), [f, p] = r([]), [m, h] = r(!0), [g, _] = r(), { status: v, agentId: y, source: b, stewardId: x, mine: S } = i, { limit: C = 50, enabled: w = !0 } = o, T = t(async () => {
|
|
41
|
+
if (!d || !w) p([]), h(!1);
|
|
32
42
|
else {
|
|
33
|
-
|
|
43
|
+
h(!0), _(void 0);
|
|
34
44
|
try {
|
|
35
|
-
let e = await
|
|
45
|
+
let e = await c.query({
|
|
36
46
|
query: s,
|
|
37
47
|
variables: {
|
|
38
|
-
filter: {
|
|
39
|
-
status:
|
|
40
|
-
agentId:
|
|
41
|
-
|
|
48
|
+
filter: l({
|
|
49
|
+
status: v,
|
|
50
|
+
agentId: y,
|
|
51
|
+
source: b,
|
|
52
|
+
stewardId: x,
|
|
53
|
+
mine: S
|
|
54
|
+
}),
|
|
42
55
|
pagination: {
|
|
43
|
-
limit:
|
|
56
|
+
limit: C,
|
|
44
57
|
offset: 0
|
|
45
58
|
}
|
|
46
59
|
},
|
|
47
60
|
fetchPolicy: "network-only"
|
|
48
61
|
});
|
|
49
|
-
|
|
62
|
+
p(e.data?.listBotmanorToolApprovals ?? []);
|
|
50
63
|
} catch (e) {
|
|
51
|
-
|
|
64
|
+
_(u(e, "Failed to load tool approvals"));
|
|
52
65
|
} finally {
|
|
53
|
-
|
|
66
|
+
h(!1);
|
|
54
67
|
}
|
|
55
68
|
}
|
|
56
69
|
}, [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
y,
|
|
71
|
+
c,
|
|
72
|
+
w,
|
|
73
|
+
C,
|
|
74
|
+
S,
|
|
75
|
+
b,
|
|
76
|
+
v,
|
|
77
|
+
x,
|
|
78
|
+
d
|
|
61
79
|
]);
|
|
62
80
|
return n(() => {
|
|
63
|
-
|
|
64
|
-
}, [
|
|
65
|
-
data:
|
|
66
|
-
loading:
|
|
67
|
-
error:
|
|
68
|
-
refetch:
|
|
81
|
+
T();
|
|
82
|
+
}, [T]), {
|
|
83
|
+
data: f,
|
|
84
|
+
loading: m,
|
|
85
|
+
error: g,
|
|
86
|
+
refetch: T
|
|
69
87
|
};
|
|
70
88
|
}
|
|
71
|
-
function
|
|
89
|
+
function f() {
|
|
72
90
|
let e = a("workspace"), [n, i] = r(null);
|
|
73
91
|
return {
|
|
74
|
-
decide: t(async (t, n, r) => {
|
|
92
|
+
decide: t(async (t, n, r, a) => {
|
|
75
93
|
i(t);
|
|
76
94
|
try {
|
|
77
95
|
let i = (await e.mutate({
|
|
@@ -79,13 +97,14 @@ function d() {
|
|
|
79
97
|
variables: {
|
|
80
98
|
id: t,
|
|
81
99
|
decision: n,
|
|
82
|
-
note: r?.trim() || void 0
|
|
100
|
+
note: r?.trim() || void 0,
|
|
101
|
+
scope: a
|
|
83
102
|
}
|
|
84
103
|
})).data?.decideBotmanorToolApproval;
|
|
85
104
|
if (!i) throw Error("Failed to record the decision");
|
|
86
105
|
return i;
|
|
87
106
|
} catch (e) {
|
|
88
|
-
throw
|
|
107
|
+
throw u(e, "Failed to record the decision");
|
|
89
108
|
} finally {
|
|
90
109
|
i(null);
|
|
91
110
|
}
|
|
@@ -93,6 +112,6 @@ function d() {
|
|
|
93
112
|
pendingId: n
|
|
94
113
|
};
|
|
95
114
|
}
|
|
96
|
-
export {
|
|
115
|
+
export { l as toFilterInput, f as useDecideToolApproval, d as useToolApprovals };
|
|
97
116
|
|
|
98
117
|
//# sourceMappingURL=useToolApprovals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolApprovals.js","names":["TOOL_APPROVAL_FIELDS","LIST_DOCUMENT","DECIDE_DOCUMENT","toError","error","fallback","useToolApprovals","client","useGatewayClient","useBotlit","data","setData","useState","loading","setLoading","setError","
|
|
1
|
+
{"version":3,"file":"useToolApprovals.js","names":["TOOL_APPROVAL_FIELDS","LIST_DOCUMENT","DECIDE_DOCUMENT","toFilterInput","filter","toError","error","fallback","useToolApprovals","client","useGatewayClient","useBotlit","data","setData","useState","loading","setLoading","setError","options","refetch","useCallback","workspaceId","enabled","result","queryError","agentId","limit","mine","source","status","stewardId","useEffect","useDecideToolApproval","pendingId","setPendingId","id","record","note","mutationError"],"sources":["../../../src/botlit/hooks/useToolApprovals.ts"],"sourcesContent":["/**\n * Tool approval hooks (BOFF-15360).\n *\n * A TOOL policy can hold risky tool calls for a human decision. The agent\n * answers without the call; approvers see it in the approvals queue and\n * approve (the call runs and the agent posts its answer in the same\n * conversation) or deny it with a reason. These hooks wrap the\n * `*BotmanorToolApproval*` fields of wspace-botmanor-svc.\n */\nimport { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../providers/BotlitProvider';\n\nconst TOOL_APPROVAL_FIELDS = `\n id\n agentId\n agentName\n connectionId\n connectionName\n toolName\n riskLevel\n arguments\n reasons\n mode\n status\n requestedById\n userMessage\n approverRoles\n approverUserIds\n originExecutionId\n expiresAt\n deciderId\n decisionNote\n decidedAt\n resumeStatus\n resumeExecutionId\n resumeError\n resultPreview\n createdAt\n source\n stewardId\n stewardRunId\n argumentsHash\n destination\n purpose\n requestedScope\n grantedScope\n charterCitation\n reviewerVerdict\n reviewerNote\n batchKey\n consumedAt\n createdRuleId\n fixedDefault\n`;\n\nconst LIST_DOCUMENT = gql`\n query ListBotmanorToolApprovals(\n $filter: BotmanorToolApprovalFilterInput\n $pagination: PaginationInput\n ) {\n listBotmanorToolApprovals(filter: $filter, pagination: $pagination) {\n ${TOOL_APPROVAL_FIELDS}\n }\n }\n`;\n\nconst DECIDE_DOCUMENT = gql`\n mutation DecideBotmanorToolApproval(\n $id: ID!\n $decision: BotmanorToolApprovalDecision!\n $note: String\n $scope: BotmanorApprovalScope\n ) {\n decideBotmanorToolApproval(id: $id, decision: $decision, note: $note, scope: $scope) {\n ${TOOL_APPROVAL_FIELDS}\n }\n }\n`;\n\nexport type ToolApprovalStatus = 'PENDING' | 'APPROVED' | 'DENIED' | 'EXPIRED' | 'CANCELLED';\nexport type ToolApprovalDecision = 'APPROVE' | 'DENY';\nexport type ToolApprovalSource = 'AGENT_CHAT' | 'STEWARD';\nexport type ToolApprovalScope = 'ONCE' | 'RUN' | 'DUTY' | 'TIME_LIMITED' | 'STANDING';\n\nexport interface ToolApprovalFilter {\n status?: ToolApprovalStatus;\n agentId?: string;\n source?: ToolApprovalSource;\n stewardId?: string;\n /** Only the requests the caller can act on (their steward approvals inbox). */\n mine?: boolean;\n}\n\nexport interface ToolApprovalListOptions {\n /** Page size; the inbox raises it to load more. */\n limit?: number;\n /** When false the query is not sent and the result stays empty. */\n enabled?: boolean;\n}\n\nexport const TOOL_APPROVALS_PAGE_SIZE = 50;\n\n/** The filter input the service takes; empty values are left out. */\nexport function toFilterInput(filter: ToolApprovalFilter): Record<string, unknown> {\n return {\n status: filter.status || undefined,\n agentId: filter.agentId || undefined,\n source: filter.source || undefined,\n stewardId: filter.stewardId || undefined,\n mine: filter.mine ? true : undefined,\n };\n}\n\nexport interface ToolApprovalRecord {\n id: string;\n agentId: string;\n agentName?: string | null;\n connectionId: string;\n connectionName: string;\n toolName: string;\n riskLevel: string;\n arguments: unknown;\n reasons: string[];\n mode: 'APPROVER' | 'REQUESTER' | string;\n status: ToolApprovalStatus;\n requestedById: string;\n userMessage?: string | null;\n approverRoles: string[];\n approverUserIds: string[];\n originExecutionId?: string | null;\n expiresAt: string;\n deciderId?: string | null;\n decisionNote?: string | null;\n decidedAt?: string | null;\n resumeStatus?: 'RUNNING' | 'COMPLETED' | 'FAILED' | string | null;\n resumeExecutionId?: string | null;\n resumeError?: string | null;\n resultPreview?: string | null;\n createdAt: string;\n source?: ToolApprovalSource | null;\n stewardId?: string | null;\n stewardRunId?: string | null;\n argumentsHash?: string | null;\n destination?: string | null;\n purpose?: string | null;\n requestedScope?: ToolApprovalScope | null;\n grantedScope?: ToolApprovalScope | null;\n /** The reviewer's verified quote of the owner's own words. */\n charterCitation?: string | null;\n reviewerVerdict?: string | null;\n reviewerNote?: string | null;\n batchKey?: string | null;\n consumedAt?: string | null;\n createdRuleId?: string | null;\n /** Set for calls that always go to a person (password, payment, one-time code, external message). */\n fixedDefault?: string | null;\n}\n\nfunction toError(error: unknown, fallback: string): Error {\n return error instanceof Error ? error : new Error(fallback);\n}\n\n/** Tool approval requests in the workspace, newest first. */\nexport function useToolApprovals(\n filter: ToolApprovalFilter,\n options: ToolApprovalListOptions = {}\n) {\n const client = useGatewayClient('workspace') as ApolloClient;\n const { workspaceId } = useBotlit();\n const [data, setData] = useState<ToolApprovalRecord[]>([]);\n // True until the first read settles, so the page shows its loading state\n // instead of flashing the empty message before the effect runs.\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | undefined>();\n const { status, agentId, source, stewardId, mine } = filter;\n const { limit = TOOL_APPROVALS_PAGE_SIZE, enabled = true } = options;\n\n const refetch = useCallback(async () => {\n if (!workspaceId || !enabled) {\n setData([]);\n setLoading(false);\n return;\n }\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<{ listBotmanorToolApprovals: ToolApprovalRecord[] }>({\n query: LIST_DOCUMENT,\n variables: {\n filter: toFilterInput({ status, agentId, source, stewardId, mine }),\n pagination: { limit, offset: 0 },\n },\n fetchPolicy: 'network-only',\n });\n setData(result.data?.listBotmanorToolApprovals ?? []);\n } catch (queryError) {\n setError(toError(queryError, 'Failed to load tool approvals'));\n } finally {\n setLoading(false);\n }\n }, [agentId, client, enabled, limit, mine, source, status, stewardId, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n/** Approve or deny a pending tool call. */\nexport function useDecideToolApproval() {\n const client = useGatewayClient('workspace') as ApolloClient;\n const [pendingId, setPendingId] = useState<string | null>(null);\n\n const decide = useCallback(\n async (\n id: string,\n decision: ToolApprovalDecision,\n note?: string,\n scope?: ToolApprovalScope\n ): Promise<ToolApprovalRecord> => {\n setPendingId(id);\n try {\n const result = await client.mutate<{ decideBotmanorToolApproval: ToolApprovalRecord }>({\n mutation: DECIDE_DOCUMENT,\n variables: { id, decision, note: note?.trim() || undefined, scope },\n });\n const record = result.data?.decideBotmanorToolApproval;\n if (!record) throw new Error('Failed to record the decision');\n return record;\n } catch (mutationError) {\n throw toError(mutationError, 'Failed to record the decision');\n } finally {\n setPendingId(null);\n }\n },\n [client]\n );\n\n return { decide, pendingId };\n}\n"],"mappings":";;;;;AAeA,IAAMA,IAAuB,glBA2CvBC,IAAgB,CAAG;;;;;;QAMjBD,EAAqB;;;GAKvBE,IAAkB,CAAG;;;;;;;;QAQnBF,EAAqB;;;;AA6B7B,SAAgBG,EAAc,GAAqD;CACjF,OAAO;EACL,QAAQC,EAAO,UAAU,KAAA;EACzB,SAASA,EAAO,WAAW,KAAA;EAC3B,QAAQA,EAAO,UAAU,KAAA;EACzB,WAAWA,EAAO,aAAa,KAAA;EAC/B,MAAMA,EAAO,OAAO,KAAO,KAAA;CAC7B;AACF;AA+CA,SAASC,EAAQ,GAAgB,GAAyB;CACxD,OAAOC,aAAiB,QAAQA,IAAY,MAAMC,CAAQ;AAC5D;AAGA,SAAgBC,EACd,GACA,IAAmC,CAAC,GACpC;CACA,IAAMC,IAASC,EAAiB,WAAW,GACrC,EAAE,mBAAgBC,EAAU,GAC5B,CAACC,GAAMC,KAAWC,EAA+B,CAAC,CAAC,GAGnD,CAACC,GAASC,KAAcF,EAAS,EAAI,GACrC,CAACR,GAAOW,KAAYH,EAA4B,GAChD,EAAE,WAAQ,YAAS,WAAQ,cAAW,YAASV,GAC/C,EAAE,WAAA,IAAkC,aAAU,OAASc,GAEvDC,IAAUC,EAAY,YAAY;EACtC,IAAI,CAACC,KAAe,CAACC,GAEnB,AADAT,EAAQ,CAAC,CAAC,GACVG,EAAW,EAAK;OAGlB;GACA,AADAA,EAAW,EAAI,GACfC,EAAS,KAAA,CAAS;GAClB,IAAI;IACF,IAAMM,IAAS,MAAMd,EAAO,MAA2D;KACrF,OAAOR;KACP,WAAW;MACT,QAAQE,EAAc;OAAE;OAAQ;OAAS;OAAQ;OAAW;MAAK,CAAC;MAClE,YAAY;OAAE;OAAO,QAAQ;MAAE;KACjC;KACA,aAAa;IACf,CAAC;IACD,EAAQoB,EAAO,MAAM,6BAA6B,CAAC,CAAC;GACtD,SAASC,GAAY;IACnB,EAASnB,EAAQmB,GAAY,+BAA+B,CAAC;GAC/D,UAAU;IACR,EAAW,EAAK;GAClB;EAhBe;CAiBjB,GAAG;EAACC;EAAShB;EAAQa;EAASI;EAAOC;EAAMC;EAAQC;EAAQC;EAAWT;CAAW,CAAC;CAMlF,OAJAU,QAAgB;EACd,EAAa;CACf,GAAG,CAACZ,CAAO,CAAC,GAEL;EAAE;EAAM;EAAS;EAAO;CAAQ;AACzC;AAGA,SAAgBa,IAAwB;CACtC,IAAMvB,IAASC,EAAiB,WAAW,GACrC,CAACuB,GAAWC,KAAgBpB,EAAwB,IAAI;CA2B9D,OAAO;EAAE,QAzBMM,EACb,OACE,GACA,GACA,GACA,MACgC;GAChC,EAAae,CAAE;GACf,IAAI;IAKF,IAAMC,KAAS,MAJM3B,EAAO,OAA2D;KACrF,UAAUP;KACV,WAAW;MAAE;MAAI;MAAU,MAAMmC,GAAM,KAAK,KAAK,KAAA;MAAW;KAAM;IACpE,CAAC,EAAA,CACqB,MAAM;IAC5B,IAAI,CAACD,GAAQ,MAAU,MAAM,+BAA+B;IAC5D,OAAOA;GACT,SAASE,GAAe;IACtB,MAAMjC,EAAQiC,GAAe,+BAA+B;GAC9D,UAAU;IACR,EAAa,IAAI;GACnB;EACF,GACA,CAAC7B,CAAM,CAGA;EAAQ;CAAU;AAC7B"}
|