@burdenoff/microfe-botmanor 2026.1203.4 → 2026.1203.6

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.
Files changed (135) hide show
  1. package/dist/botlit/BotlitRoutes.js +0 -1
  2. package/dist/botlit/BotlitRoutes.js.map +1 -1
  3. package/dist/botlit/components/A2ACardVerificationCard.js +0 -1
  4. package/dist/botlit/components/A2ACardVerificationCard.js.map +1 -1
  5. package/dist/botlit/components/AgentA2APanel.js +20 -21
  6. package/dist/botlit/components/AgentA2APanel.js.map +1 -1
  7. package/dist/botlit/components/AgentApprovalPanel.js +22 -23
  8. package/dist/botlit/components/AgentApprovalPanel.js.map +1 -1
  9. package/dist/botlit/components/AgentBindingsPanel.js +66 -68
  10. package/dist/botlit/components/AgentBindingsPanel.js.map +1 -1
  11. package/dist/botlit/components/AiOperationsPanel.js +34 -35
  12. package/dist/botlit/components/AiOperationsPanel.js.map +1 -1
  13. package/dist/botlit/components/BotAgentsPanel.js +59 -60
  14. package/dist/botlit/components/BotAgentsPanel.js.map +1 -1
  15. package/dist/botlit/components/BotVersionHistoryPanel.js +19 -20
  16. package/dist/botlit/components/BotVersionHistoryPanel.js.map +1 -1
  17. package/dist/botlit/components/BucketDialogs.js +0 -1
  18. package/dist/botlit/components/BucketDialogs.js.map +1 -1
  19. package/dist/botlit/components/ChannelRoutesPanel.js +82 -84
  20. package/dist/botlit/components/ChannelRoutesPanel.js.map +1 -1
  21. package/dist/botlit/components/CreateChannelRouteDialog.js +4 -5
  22. package/dist/botlit/components/CreateChannelRouteDialog.js.map +1 -1
  23. package/dist/botlit/components/DescribeBotDialog.js +0 -1
  24. package/dist/botlit/components/DescribeBotDialog.js.map +1 -1
  25. package/dist/botlit/components/GettingStartedChecklist.js +9 -10
  26. package/dist/botlit/components/GettingStartedChecklist.js.map +1 -1
  27. package/dist/botlit/components/HandoffConfigPanel.js +0 -1
  28. package/dist/botlit/components/HandoffConfigPanel.js.map +1 -1
  29. package/dist/botlit/components/RetentionStatusPanel.js +10 -12
  30. package/dist/botlit/components/RetentionStatusPanel.js.map +1 -1
  31. package/dist/botlit/components/StewardApprovalsInbox.js +201 -212
  32. package/dist/botlit/components/StewardApprovalsInbox.js.map +1 -1
  33. package/dist/botlit/components/StoreOwnPackagesCard.js +21 -22
  34. package/dist/botlit/components/StoreOwnPackagesCard.js.map +1 -1
  35. package/dist/botlit/components/StorePackageDraftCard.js +38 -39
  36. package/dist/botlit/components/StorePackageDraftCard.js.map +1 -1
  37. package/dist/botlit/components/StorePolicyBundleCard.js +27 -29
  38. package/dist/botlit/components/StorePolicyBundleCard.js.map +1 -1
  39. package/dist/botlit/components/StoreSubmissionsCard.js +64 -65
  40. package/dist/botlit/components/StoreSubmissionsCard.js.map +1 -1
  41. package/dist/botlit/components/VersionHistoryPanel.js +18 -19
  42. package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
  43. package/dist/botlit/hooks/internal/workspaceGateway.d.ts +6 -0
  44. package/dist/botlit/hooks/internal/workspaceGateway.js +40 -40
  45. package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
  46. package/dist/botlit/hooks/useChannels.js +2 -0
  47. package/dist/botlit/hooks/useChannels.js.map +1 -1
  48. package/dist/botlit/hooks/useToolApprovals.d.ts +8 -3
  49. package/dist/botlit/hooks/useToolApprovals.js +68 -73
  50. package/dist/botlit/hooks/useToolApprovals.js.map +1 -1
  51. package/dist/botlit/pages/A2AAgentDetailPage.js +331 -332
  52. package/dist/botlit/pages/A2AAgentDetailPage.js.map +1 -1
  53. package/dist/botlit/pages/A2ARegistryPage.js +39 -41
  54. package/dist/botlit/pages/A2ARegistryPage.js.map +1 -1
  55. package/dist/botlit/pages/AgentApprovalsPage.js +24 -25
  56. package/dist/botlit/pages/AgentApprovalsPage.js.map +1 -1
  57. package/dist/botlit/pages/AgentBuilderPage.js +470 -471
  58. package/dist/botlit/pages/AgentBuilderPage.js.map +1 -1
  59. package/dist/botlit/pages/AgentDetailPage.js +68 -69
  60. package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
  61. package/dist/botlit/pages/AgentsListPage.js +277 -278
  62. package/dist/botlit/pages/AgentsListPage.js.map +1 -1
  63. package/dist/botlit/pages/AiOperationsPage.js +44 -46
  64. package/dist/botlit/pages/AiOperationsPage.js.map +1 -1
  65. package/dist/botlit/pages/BotChannelsTab.js +354 -356
  66. package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
  67. package/dist/botlit/pages/BotDetailPage.js +138 -139
  68. package/dist/botlit/pages/BotDetailPage.js.map +1 -1
  69. package/dist/botlit/pages/BotWorkflowTab.js +23 -24
  70. package/dist/botlit/pages/BotWorkflowTab.js.map +1 -1
  71. package/dist/botlit/pages/BotsListPage.js +32 -33
  72. package/dist/botlit/pages/BotsListPage.js.map +1 -1
  73. package/dist/botlit/pages/BucketDetailPage.js +110 -112
  74. package/dist/botlit/pages/BucketDetailPage.js.map +1 -1
  75. package/dist/botlit/pages/BucketsPage.js +115 -117
  76. package/dist/botlit/pages/BucketsPage.js.map +1 -1
  77. package/dist/botlit/pages/ChannelDetailPage.js +105 -107
  78. package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
  79. package/dist/botlit/pages/ChannelsPage.js +38 -40
  80. package/dist/botlit/pages/ChannelsPage.js.map +1 -1
  81. package/dist/botlit/pages/DashboardPage.js +26 -27
  82. package/dist/botlit/pages/DashboardPage.js.map +1 -1
  83. package/dist/botlit/pages/ExecutionDetailPage.js +70 -71
  84. package/dist/botlit/pages/ExecutionDetailPage.js.map +1 -1
  85. package/dist/botlit/pages/ExecutionsPage.js +219 -220
  86. package/dist/botlit/pages/ExecutionsPage.js.map +1 -1
  87. package/dist/botlit/pages/HandoffsPage.js +208 -210
  88. package/dist/botlit/pages/HandoffsPage.js.map +1 -1
  89. package/dist/botlit/pages/InstalledPackagesPage.js +179 -181
  90. package/dist/botlit/pages/InstalledPackagesPage.js.map +1 -1
  91. package/dist/botlit/pages/KnowledgeBaseDetailPage.js +194 -195
  92. package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -1
  93. package/dist/botlit/pages/KnowledgeBasesPage.js +38 -39
  94. package/dist/botlit/pages/KnowledgeBasesPage.js.map +1 -1
  95. package/dist/botlit/pages/MCPServerDetailPage.js +178 -180
  96. package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -1
  97. package/dist/botlit/pages/MCPServersPage.js +42 -43
  98. package/dist/botlit/pages/MCPServersPage.js.map +1 -1
  99. package/dist/botlit/pages/PoliciesPage.js +77 -78
  100. package/dist/botlit/pages/PoliciesPage.js.map +1 -1
  101. package/dist/botlit/pages/PolicyDetailPage.js +517 -519
  102. package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
  103. package/dist/botlit/pages/PromptStudioPage.js +81 -83
  104. package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
  105. package/dist/botlit/pages/PromptTemplateDetailPage.js +137 -139
  106. package/dist/botlit/pages/PromptTemplateDetailPage.js.map +1 -1
  107. package/dist/botlit/pages/PromptTemplatesPage.js +28 -30
  108. package/dist/botlit/pages/PromptTemplatesPage.js.map +1 -1
  109. package/dist/botlit/pages/RetrievalProfileDetailPage.js +64 -65
  110. package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -1
  111. package/dist/botlit/pages/RetrievalProfilesPage.js +59 -60
  112. package/dist/botlit/pages/RetrievalProfilesPage.js.map +1 -1
  113. package/dist/botlit/pages/SettingsPage.js +30 -31
  114. package/dist/botlit/pages/SettingsPage.js.map +1 -1
  115. package/dist/botlit/pages/SkillDetailPage.js +205 -207
  116. package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
  117. package/dist/botlit/pages/SkillsPage.js +68 -69
  118. package/dist/botlit/pages/SkillsPage.js.map +1 -1
  119. package/dist/botlit/pages/StorePackageDetailPage.js +39 -41
  120. package/dist/botlit/pages/StorePackageDetailPage.js.map +1 -1
  121. package/dist/botlit/pages/StorePage.js +169 -171
  122. package/dist/botlit/pages/StorePage.js.map +1 -1
  123. package/dist/botlit/pages/ToolApprovalsPage.js +61 -62
  124. package/dist/botlit/pages/ToolApprovalsPage.js.map +1 -1
  125. package/dist/generated/global-types.d.ts +540 -171
  126. package/dist/generated/global-types.js.map +1 -1
  127. package/dist/generated/wspace-operations.d.ts +38 -4
  128. package/dist/generated/wspace-operations.js.map +1 -1
  129. package/dist/generated/wspace-types.d.ts +9539 -686
  130. package/dist/generated/wspace-types.js.map +1 -1
  131. package/dist/index.js +0 -1
  132. package/package.json +4 -1
  133. package/dist/botlit/hooks/index.js +0 -21
  134. package/dist/botlit/index.js +0 -12
  135. package/dist/botlit/permissions/index.js +0 -4
@@ -1,18 +1,24 @@
1
1
  import { useBotlit as e } from "../providers/BotlitProvider.js";
2
- import { useCallback as t, useEffect as n, useState as r } from "react";
3
- import { gql as i } from "@apollo/client";
4
- import { useGatewayClient as a } from "@burdenoff/fe-libs/shared/graphql";
2
+ import { useWorkspacePaginatedQuery as t } from "./internal/workspaceGateway.js";
3
+ import { useCallback as n, useMemo as r, useState as i } from "react";
4
+ import { gql as a } from "@apollo/client";
5
+ import { useGatewayClient as o } from "@burdenoff/fe-libs/shared/graphql";
5
6
  // 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 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
- query ListBotmanorToolApprovals(
7
+ var s = "\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", c = a`
8
+ query ListBotmanorToolApprovalsPage(
8
9
  $filter: BotmanorToolApprovalFilterInput
9
- $pagination: PaginationInput
10
+ $pagination: BotmanorOffsetPaginationInput
10
11
  ) {
11
- listBotmanorToolApprovals(filter: $filter, pagination: $pagination) {
12
- ${o}
12
+ listBotmanorToolApprovalsPage(filter: $filter, pagination: $pagination) {
13
+ items {
14
+ ${s}
15
+ }
16
+ total
17
+ hasMore
18
+ nextOffset
13
19
  }
14
20
  }
15
- `, c = i`
21
+ `, l = a`
16
22
  mutation DecideBotmanorToolApproval(
17
23
  $id: ID!
18
24
  $decision: BotmanorToolApprovalDecision!
@@ -20,11 +26,11 @@ var o = "\n id\n agentId\n agentName\n connectionId\n connectionName\n too
20
26
  $scope: BotmanorApprovalScope
21
27
  ) {
22
28
  decideBotmanorToolApproval(id: $id, decision: $decision, note: $note, scope: $scope) {
23
- ${o}
29
+ ${s}
24
30
  }
25
31
  }
26
32
  `;
27
- function l(e) {
33
+ function u(e) {
28
34
  return {
29
35
  status: e.status || void 0,
30
36
  agentId: e.agentId || void 0,
@@ -33,85 +39,74 @@ function l(e) {
33
39
  mine: e.mine ? !0 : void 0
34
40
  };
35
41
  }
36
- function u(e, t) {
42
+ function d(e, t) {
37
43
  return e instanceof Error ? e : Error(t);
38
44
  }
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);
42
- else {
43
- h(!0), _(void 0);
44
- try {
45
- let e = await c.query({
46
- query: s,
47
- variables: {
48
- filter: l({
49
- status: v,
50
- agentId: y,
51
- source: b,
52
- stewardId: x,
53
- mine: S
54
- }),
55
- pagination: {
56
- limit: C,
57
- offset: 0
58
- }
59
- },
60
- fetchPolicy: "network-only"
61
- });
62
- p(e.data?.listBotmanorToolApprovals ?? []);
63
- } catch (e) {
64
- _(u(e, "Failed to load tool approvals"));
65
- } finally {
66
- h(!1);
67
- }
68
- }
69
- }, [
70
- y,
71
- c,
72
- w,
73
- C,
74
- S,
75
- b,
76
- v,
77
- x,
78
- d
79
- ]);
80
- return n(() => {
81
- T();
82
- }, [T]), {
83
- data: f,
84
- loading: m,
85
- error: g,
86
- refetch: T
45
+ var f = [], p = (e) => e?.listBotmanorToolApprovalsPage?.items, m = (e) => {
46
+ let t = e?.listBotmanorToolApprovalsPage;
47
+ return t?.hasMore ? t.nextOffset ?? null : null;
48
+ }, h = (e) => e;
49
+ function g(n, i = {}) {
50
+ let { workspaceId: a } = e(), { status: o, agentId: s, source: l, stewardId: d, mine: g } = n, { enabled: _ = !0 } = i, v = !!a && _, y = r(() => ({ filter: u({
51
+ status: o,
52
+ agentId: s,
53
+ source: l,
54
+ stewardId: d,
55
+ mine: g
56
+ }) }), [
57
+ o,
58
+ s,
59
+ l,
60
+ d,
61
+ g
62
+ ]), b = t({
63
+ document: c,
64
+ variables: y,
65
+ pageSize: 50,
66
+ extractRows: p,
67
+ extractNextOffset: m,
68
+ select: h,
69
+ fallback: f,
70
+ enabled: v,
71
+ errorMessage: "Failed to load tool approvals",
72
+ loadingBeforeFirstRead: !0
73
+ });
74
+ return {
75
+ data: b.data,
76
+ loading: b.loading,
77
+ loadingMore: b.loadingMore,
78
+ hasMore: b.hasMore,
79
+ error: b.error,
80
+ refetch: b.refetch,
81
+ loadMore: b.loadMore
87
82
  };
88
83
  }
89
- function f() {
90
- let e = a("workspace"), [n, i] = r(null);
84
+ function _() {
85
+ let e = o("workspace"), [t, r] = i(null);
91
86
  return {
92
- decide: t(async (t, n, r, a) => {
93
- i(t);
87
+ decide: n(async (t, n, i, a) => {
88
+ r(t);
94
89
  try {
95
- let i = (await e.mutate({
96
- mutation: c,
90
+ let r = (await e.mutate({
91
+ mutation: l,
97
92
  variables: {
98
93
  id: t,
99
94
  decision: n,
100
- note: r?.trim() || void 0,
95
+ note: i?.trim() || void 0,
101
96
  scope: a
102
97
  }
103
98
  })).data?.decideBotmanorToolApproval;
104
- if (!i) throw Error("Failed to record the decision");
105
- return i;
99
+ if (!r) throw Error("Failed to record the decision");
100
+ return r;
106
101
  } catch (e) {
107
- throw u(e, "Failed to record the decision");
102
+ throw d(e, "Failed to record the decision");
108
103
  } finally {
109
- i(null);
104
+ r(null);
110
105
  }
111
106
  }, [e]),
112
- pendingId: n
107
+ pendingId: t
113
108
  };
114
109
  }
115
- export { l as toFilterInput, f as useDecideToolApproval, d as useToolApprovals };
110
+ export { u as toFilterInput, _ as useDecideToolApproval, g as useToolApprovals };
116
111
 
117
112
  //# sourceMappingURL=useToolApprovals.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"useToolApprovals.js","names":["TOOL_APPROVAL_FIELDS","LIST_DOCUMENT","DECIDE_DOCUMENT","toFilterInput","filter","toError","error","fallback","NO_APPROVALS","extractRows","data","extractNextOffset","page","selectRows","rows","useToolApprovals","useBotlit","options","active","workspaceId","enabled","variables","useMemo","status","agentId","source","stewardId","mine","result","useWorkspacePaginatedQuery","useDecideToolApproval","client","useGatewayClient","pendingId","setPendingId","useState","useCallback","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, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { useWorkspacePaginatedQuery } from './internal/workspaceGateway';\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\n/**\n * The paged twin (BOFF-18147): the service caps a page at 100 rows and says\n * whether more follow, so \"Load more\" walks pages instead of asking for an\n * ever larger first page.\n */\nconst LIST_DOCUMENT = gql`\n query ListBotmanorToolApprovalsPage(\n $filter: BotmanorToolApprovalFilterInput\n $pagination: BotmanorOffsetPaginationInput\n ) {\n listBotmanorToolApprovalsPage(filter: $filter, pagination: $pagination) {\n items {\n ${TOOL_APPROVAL_FIELDS}\n }\n total\n hasMore\n nextOffset\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 /** When false the query is not sent and the result stays empty. */\n enabled?: boolean;\n}\n\n/** Rows per page; the service accepts at most 100 (BOFF-18147). */\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\ninterface ToolApprovalsPagePayload {\n listBotmanorToolApprovalsPage?: {\n items: ToolApprovalRecord[];\n total: number;\n hasMore: boolean;\n nextOffset?: number | null;\n } | null;\n}\n\nconst NO_APPROVALS: ToolApprovalRecord[] = [];\nconst extractRows = (data: ToolApprovalsPagePayload | undefined) =>\n data?.listBotmanorToolApprovalsPage?.items;\n// The continuation comes from the server's normalised page, never from the\n// requested size, so a smaller server cap cannot end the list early.\nconst extractNextOffset = (data: ToolApprovalsPagePayload | undefined) => {\n const page = data?.listBotmanorToolApprovalsPage;\n return page?.hasMore ? (page.nextOffset ?? null) : null;\n};\nconst selectRows = (rows: ToolApprovalRecord[]) => rows;\n\n/**\n * Tool approval requests in the workspace, newest first, one page at a time.\n * `loadMore` appends the next page; `hasMore` is the server's continuation.\n */\nexport function useToolApprovals(\n filter: ToolApprovalFilter,\n options: ToolApprovalListOptions = {}\n) {\n const { workspaceId } = useBotlit();\n const { status, agentId, source, stewardId, mine } = filter;\n const { enabled = true } = options;\n const active = Boolean(workspaceId) && enabled;\n\n // A new filter starts again from page one; the paging helper also starts\n // again when the workspace changes.\n const variables = useMemo(\n () => ({ filter: toFilterInput({ status, agentId, source, stewardId, mine }) }),\n [status, agentId, source, stewardId, mine]\n );\n\n const result = useWorkspacePaginatedQuery<\n ToolApprovalsPagePayload,\n ToolApprovalRecord,\n ToolApprovalRecord[]\n >({\n document: LIST_DOCUMENT,\n variables,\n pageSize: TOOL_APPROVALS_PAGE_SIZE,\n extractRows,\n extractNextOffset,\n select: selectRows,\n fallback: NO_APPROVALS,\n enabled: active,\n errorMessage: 'Failed to load tool approvals',\n // Loading from the first render, so the page shows its loading state\n // instead of flashing the empty message before the first read starts.\n loadingBeforeFirstRead: true,\n });\n\n return {\n data: result.data,\n loading: result.loading,\n loadingMore: result.loadingMore,\n hasMore: result.hasMore,\n error: result.error,\n refetch: result.refetch,\n loadMore: result.loadMore,\n };\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":";;;;;;AAgBA,IAAMA,IAAuB,glBAgDvBC,IAAgB,CAAG;;;;;;;UAOfD,EAAqB;;;;;;;GASzBE,IAAkB,CAAG;;;;;;;;QAQnBF,EAAqB;;;;AA4B7B,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;AAWA,IAAMC,IAAqC,CAAC,GACtCC,KAAe,MACnBC,GAAM,+BAA+B,OAGjCC,KAAqB,MAA+C;CACxE,IAAMC,IAAOF,GAAM;CACnB,OAAOE,GAAM,UAAWA,EAAK,cAAc,OAAQ;AACrD,GACMC,KAAc,MAA+BC;AAMnD,SAAgBC,EACd,GACA,IAAmC,CAAC,GACpC;CACA,IAAM,EAAE,mBAAgBC,EAAU,GAC5B,EAAE,WAAQ,YAAS,WAAQ,cAAW,YAASZ,GAC/C,EAAE,aAAU,OAASa,GACrBC,IAAS,EAAQC,KAAgBC,GAIjCC,IAAYC,SACT,EAAE,QAAQnB,EAAc;EAAE;EAAQ;EAAS;EAAQ;EAAW;CAAK,CAAC,EAAE,IAC7E;EAACoB;EAAQC;EAASC;EAAQC;EAAWC;CAAI,CAC3C,GAEMC,IAASC,EAIb;EACA,UAAU5B;EACV;EACA,UAAA;EACA;EACA;EACA,QAAQY;EACR,UAAUL;EACV,SAASU;EACT,cAAc;EAGd,wBAAwB;CAC1B,CAAC;CAED,OAAO;EACL,MAAMU,EAAO;EACb,SAASA,EAAO;EAChB,aAAaA,EAAO;EACpB,SAASA,EAAO;EAChB,OAAOA,EAAO;EACd,SAASA,EAAO;EAChB,UAAUA,EAAO;CACnB;AACF;AAGA,SAAgBE,IAAwB;CACtC,IAAMC,IAASC,EAAiB,WAAW,GACrC,CAACC,GAAWC,KAAgBC,EAAwB,IAAI;CA2B9D,OAAO;EAAE,QAzBMC,EACb,OACE,GACA,GACA,GACA,MACgC;GAChC,EAAaC,CAAE;GACf,IAAI;IAKF,IAAMC,KAAS,MAJMP,EAAO,OAA2D;KACrF,UAAU7B;KACV,WAAW;MAAE;MAAI;MAAU,MAAMqC,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,MAAMnC,EAAQmC,GAAe,+BAA+B;GAC9D,UAAU;IACR,EAAa,IAAI;GACnB;EACF,GACA,CAACT,CAAM,CAGA;EAAQ;CAAU;AAC7B"}