@burdenoff/microfe-botmanor 2026.1203.3 → 2026.1203.5

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/BotmanorRootInner.js +38 -41
  4. package/dist/botlit/BotmanorRootInner.js.map +1 -1
  5. package/dist/botlit/components/A2ACardVerificationCard.js +0 -1
  6. package/dist/botlit/components/A2ACardVerificationCard.js.map +1 -1
  7. package/dist/botlit/components/AgentA2APanel.js +20 -21
  8. package/dist/botlit/components/AgentA2APanel.js.map +1 -1
  9. package/dist/botlit/components/AgentApprovalPanel.js +22 -23
  10. package/dist/botlit/components/AgentApprovalPanel.js.map +1 -1
  11. package/dist/botlit/components/AgentBindingsPanel.js +66 -68
  12. package/dist/botlit/components/AgentBindingsPanel.js.map +1 -1
  13. package/dist/botlit/components/AiOperationsPanel.js +34 -35
  14. package/dist/botlit/components/AiOperationsPanel.js.map +1 -1
  15. package/dist/botlit/components/BotAgentsPanel.js +59 -60
  16. package/dist/botlit/components/BotAgentsPanel.js.map +1 -1
  17. package/dist/botlit/components/BotVersionHistoryPanel.js +19 -20
  18. package/dist/botlit/components/BotVersionHistoryPanel.js.map +1 -1
  19. package/dist/botlit/components/BucketDialogs.js +0 -1
  20. package/dist/botlit/components/BucketDialogs.js.map +1 -1
  21. package/dist/botlit/components/ChannelRoutesPanel.js +82 -84
  22. package/dist/botlit/components/ChannelRoutesPanel.js.map +1 -1
  23. package/dist/botlit/components/CreateChannelRouteDialog.js +4 -5
  24. package/dist/botlit/components/CreateChannelRouteDialog.js.map +1 -1
  25. package/dist/botlit/components/DescribeBotDialog.js +0 -1
  26. package/dist/botlit/components/DescribeBotDialog.js.map +1 -1
  27. package/dist/botlit/components/GettingStartedChecklist.js +9 -10
  28. package/dist/botlit/components/GettingStartedChecklist.js.map +1 -1
  29. package/dist/botlit/components/HandoffConfigPanel.js +0 -1
  30. package/dist/botlit/components/HandoffConfigPanel.js.map +1 -1
  31. package/dist/botlit/components/RetentionStatusPanel.js +10 -12
  32. package/dist/botlit/components/RetentionStatusPanel.js.map +1 -1
  33. package/dist/botlit/components/StewardApprovalsInbox.js +201 -212
  34. package/dist/botlit/components/StewardApprovalsInbox.js.map +1 -1
  35. package/dist/botlit/components/StoreOwnPackagesCard.js +21 -22
  36. package/dist/botlit/components/StoreOwnPackagesCard.js.map +1 -1
  37. package/dist/botlit/components/StorePackageDraftCard.js +38 -39
  38. package/dist/botlit/components/StorePackageDraftCard.js.map +1 -1
  39. package/dist/botlit/components/StorePolicyBundleCard.js +27 -29
  40. package/dist/botlit/components/StorePolicyBundleCard.js.map +1 -1
  41. package/dist/botlit/components/StoreSubmissionsCard.js +64 -65
  42. package/dist/botlit/components/StoreSubmissionsCard.js.map +1 -1
  43. package/dist/botlit/components/VersionHistoryPanel.js +18 -19
  44. package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
  45. package/dist/botlit/hooks/internal/workspaceGateway.d.ts +6 -0
  46. package/dist/botlit/hooks/internal/workspaceGateway.js +40 -40
  47. package/dist/botlit/hooks/internal/workspaceGateway.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/botlit/providers/WorkspaceFlagScope.d.ts +7 -0
  126. package/dist/botlit/providers/WorkspaceFlagScope.js +17 -0
  127. package/dist/botlit/providers/WorkspaceFlagScope.js.map +1 -0
  128. package/dist/botlit/providers/workspaceFlagKeys.d.ts +18 -0
  129. package/dist/botlit/providers/workspaceFlagKeys.js +8 -0
  130. package/dist/botlit/providers/workspaceFlagKeys.js.map +1 -0
  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,13 +1,12 @@
1
1
  import { useTr as e } from "../../shared/hooks/useTr.js";
2
2
  import { Card as t, CardContent as n, CardDescription as r, CardHeader as i, CardTitle as a } from "./Card.js";
3
3
  import { Button as o } from "./Button.js";
4
- import { BOTMANOR_PERMISSIONS as s } from "../permissions/botmanorPermissions.js";
5
- import { BotmanorPermissionGate as c } from "../permissions/useBotmanorPermissions.js";
6
- import { Badge as l } from "./Badge.js";
7
- import { useAgentApprovalActions as u, useAgentApprovalRequests as d, useAgentApprovalSettings as f } from "../hooks/useAgentApprovals.js";
8
- import { useBotlit as p } from "../providers/BotlitProvider.js";
9
- import { formatRelativeTime as m } from "../utils/formatters.js";
10
- import "../permissions/index.js";
4
+ import { Badge as s } from "./Badge.js";
5
+ import { useAgentApprovalActions as c, useAgentApprovalRequests as l, useAgentApprovalSettings as u } from "../hooks/useAgentApprovals.js";
6
+ import { useBotlit as d } from "../providers/BotlitProvider.js";
7
+ import { formatRelativeTime as f } from "../utils/formatters.js";
8
+ import { BOTMANOR_PERMISSIONS as p } from "../permissions/botmanorPermissions.js";
9
+ import { BotmanorPermissionGate as m } from "../permissions/useBotmanorPermissions.js";
11
10
  import { useState as h } from "react";
12
11
  import { Dialog as g, DialogContent as _, DialogDescription as v, DialogFooter as y, DialogHeader as b, DialogTitle as x, Textarea as S } from "@burdenoff/fe-libs/ui";
13
12
  import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
@@ -68,7 +67,7 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
68
67
  ] })
69
68
  });
70
69
  }, P = ({ agentId: g, agentStatus: _, onChanged: v }) => {
71
- let y = e(), { currentUser: b } = p(), x = f(), S = d({ agentId: g }), { run: P, pending: F } = u(), [I, L] = h(null), R = x.data?.requireActivationApproval === !0, z = S.data.find((e) => e.status === "PENDING") ?? null, B = S.data.filter((e) => e.status !== "PENDING").slice(0, 10), V = z !== null && z.requestedById === b?.id, H = (e) => e && e === b?.id ? y("botlit.agentApproval.you", "you") : e ?? "—", U = async (e) => {
70
+ let y = e(), { currentUser: b } = d(), x = u(), S = l({ agentId: g }), { run: P, pending: F } = c(), [I, L] = h(null), R = x.data?.requireActivationApproval === !0, z = S.data.find((e) => e.status === "PENDING") ?? null, B = S.data.filter((e) => e.status !== "PENDING").slice(0, 10), V = z !== null && z.requestedById === b?.id, H = (e) => e && e === b?.id ? y("botlit.agentApproval.you", "you") : e ?? "—", U = async (e) => {
72
71
  if (I) try {
73
72
  I.kind === "request" ? (await P({
74
73
  kind: "request",
@@ -106,13 +105,13 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
106
105
  children: [
107
106
  /* @__PURE__ */ w(k, { size: 18 }),
108
107
  y("botlit.agentApproval.title", "Activation approval"),
109
- /* @__PURE__ */ w(l, {
108
+ /* @__PURE__ */ w(s, {
110
109
  variant: R ? "warning" : "outline",
111
110
  children: R ? y("botlit.agentApproval.required", "Required in this workspace") : y("botlit.agentApproval.optional", "Optional")
112
111
  })
113
112
  ]
114
- }), /* @__PURE__ */ w(r, { children: R ? y("botlit.agentApproval.descriptionRequired", "This workspace requires a reviewer to approve an agent before it goes live or before a new version is published.") : y("botlit.agentApproval.descriptionOptional", "You can ask a reviewer to check this agent before it goes live. A workspace admin can make review mandatory on the Approvals page.") })] }), !z && _ !== "ARCHIVED" && /* @__PURE__ */ w(c, {
115
- permission: s.AGENT_UPDATE,
113
+ }), /* @__PURE__ */ w(r, { children: R ? y("botlit.agentApproval.descriptionRequired", "This workspace requires a reviewer to approve an agent before it goes live or before a new version is published.") : y("botlit.agentApproval.descriptionOptional", "You can ask a reviewer to check this agent before it goes live. A workspace admin can make review mandatory on the Approvals page.") })] }), !z && _ !== "ARCHIVED" && /* @__PURE__ */ w(m, {
114
+ permission: p.AGENT_UPDATE,
116
115
  children: /* @__PURE__ */ w(o, {
117
116
  leftIcon: /* @__PURE__ */ w(O, { size: 16 }),
118
117
  onClick: () => L({ kind: "request" }),
@@ -130,7 +129,7 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
130
129
  children: [
131
130
  /* @__PURE__ */ T("div", {
132
131
  className: "flex items-center gap-2 flex-wrap",
133
- children: [/* @__PURE__ */ w(l, {
132
+ children: [/* @__PURE__ */ w(s, {
134
133
  variant: "warning",
135
134
  children: z.status
136
135
  }), /* @__PURE__ */ T("span", {
@@ -140,7 +139,7 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
140
139
  " ",
141
140
  H(z.requestedById),
142
141
  " ",
143
- m(z.createdAt)
142
+ f(z.createdAt)
144
143
  ]
145
144
  })]
146
145
  }),
@@ -154,8 +153,8 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
154
153
  }),
155
154
  /* @__PURE__ */ w("div", {
156
155
  className: "flex gap-2 flex-wrap",
157
- children: V ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(c, {
158
- permission: s.AGENT_UPDATE,
156
+ children: V ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(m, {
157
+ permission: p.AGENT_UPDATE,
159
158
  children: /* @__PURE__ */ w(o, {
160
159
  variant: "outline",
161
160
  size: "sm",
@@ -163,15 +162,15 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
163
162
  onClick: () => void W(z),
164
163
  children: y("botlit.agentApproval.cancelAction", "Cancel request")
165
164
  })
166
- }), z.isStale && /* @__PURE__ */ w(c, {
167
- permission: s.AGENT_UPDATE,
165
+ }), z.isStale && /* @__PURE__ */ w(m, {
166
+ permission: p.AGENT_UPDATE,
168
167
  children: /* @__PURE__ */ w(o, {
169
168
  size: "sm",
170
169
  onClick: () => L({ kind: "request" }),
171
170
  children: y("botlit.agentApproval.resubmitAction", "Submit new request")
172
171
  })
173
- })] }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(c, {
174
- permission: s.AGENT_APPROVE,
172
+ })] }) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(m, {
173
+ permission: p.AGENT_APPROVE,
175
174
  children: /* @__PURE__ */ w(o, {
176
175
  size: "sm",
177
176
  leftIcon: /* @__PURE__ */ w(D, { size: 14 }),
@@ -182,8 +181,8 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
182
181
  }),
183
182
  children: y("botlit.agentApproval.approveAction", "Approve")
184
183
  })
185
- }), /* @__PURE__ */ w(c, {
186
- permission: s.AGENT_APPROVE,
184
+ }), /* @__PURE__ */ w(m, {
185
+ permission: p.AGENT_APPROVE,
187
186
  children: /* @__PURE__ */ w(o, {
188
187
  size: "sm",
189
188
  variant: "destructive",
@@ -210,7 +209,7 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
210
209
  className: "p-3 border border-border-subtle rounded-lg text-sm space-y-1",
211
210
  children: [/* @__PURE__ */ T("div", {
212
211
  className: "flex items-center gap-2 flex-wrap",
213
- children: [/* @__PURE__ */ w(l, {
212
+ children: [/* @__PURE__ */ w(s, {
214
213
  variant: M(e.status),
215
214
  children: e.status
216
215
  }), /* @__PURE__ */ T("span", {
@@ -220,7 +219,7 @@ var N = ({ kind: t, loading: n, onClose: r, onConfirm: i }) => {
220
219
  " ",
221
220
  H(e.reviewerId),
222
221
  " ",
223
- e.decidedAt ? m(e.decidedAt) : ""
222
+ e.decidedAt ? f(e.decidedAt) : ""
224
223
  ]
225
224
  })]
226
225
  }), e.decisionReason && /* @__PURE__ */ w("p", {
@@ -1 +1 @@
1
- {"version":3,"file":"AgentApprovalPanel.js","names":["_Fragment","Fragment$1","approvalStatusVariant","status","ApprovalDecisionDialog","t","useTr","text","setText","useState","reasonRequired","kind","copy","current","Dialog","open","onClose","DialogContent","DialogHeader","DialogTitle","DialogDescription","Textarea","event","DialogFooter","Button","loading","onConfirm","AgentApprovalPanel","useBotlit","settings","useAgentApprovalSettings","requests","useAgentApprovalRequests","useAgentApprovalActions","dialog","setDialog","required","request","history","isRequester","currentUser","who","id","confirm","run","toast","onChanged","err","cancel","Card","CardHeader","CardTitle","ShieldCheck","Badge","CardDescription","agentStatus","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Send","CardContent","formatRelativeTime","AlertTriangle","pending","CheckCircle2","XCircle"],"sources":["../../../src/botlit/components/AgentApprovalPanel.tsx"],"sourcesContent":["/**\n * Agent Activation Approval Panel (BOFF-9682)\n * @module botlit/components\n *\n * Reviewer gate on the agent detail page. Builders request activation (the\n * request pins the agent's current config); reviewers with\n * `botmanor-agent:approve` approve it, which publishes the draft and takes the\n * agent live, or reject it with a reason. The requester cannot decide their\n * own request, and a request whose agent changed afterwards is flagged stale\n * and cannot be approved.\n */\n\nimport { useState, type FC } from 'react';\nimport { AlertTriangle, CheckCircle2, ShieldCheck, Send, XCircle } from 'lucide-react';\nimport { toast } from 'sonner';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { Button } from './Button';\nimport { Badge } from './Badge';\nimport {\n useAgentApprovalActions,\n useAgentApprovalRequests,\n useAgentApprovalSettings,\n type AgentApprovalRequestRecord,\n type AgentApprovalStatus,\n} from '../hooks/useAgentApprovals';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\nexport function approvalStatusVariant(\n status: AgentApprovalStatus\n): 'warning' | 'success' | 'destructive' | 'outline' {\n if (status === 'PENDING') return 'warning';\n if (status === 'APPROVED') return 'success';\n if (status === 'REJECTED') return 'destructive';\n return 'outline';\n}\n\ntype DecisionKind = 'request' | 'approve' | 'reject';\n\ninterface DecisionDialogProps {\n kind: DecisionKind | null;\n loading: boolean;\n onClose: () => void;\n onConfirm: (text: string) => Promise<void>;\n}\n\n/** Note / reason dialog shared by the detail panel and the approvals page. */\nexport const ApprovalDecisionDialog: FC<DecisionDialogProps> = ({\n kind,\n loading,\n onClose,\n onConfirm,\n}) => {\n const t = useTr();\n const [text, setText] = useState('');\n const reasonRequired = kind === 'reject';\n\n const copy: Record<DecisionKind, { title: string; description: string; confirm: string }> = {\n request: {\n title: t('botlit.agentApproval.dialog.request.title', 'Request activation'),\n description: t(\n 'botlit.agentApproval.dialog.request.description',\n \"A reviewer will check the agent's current prompt, model, tools and limits before it goes live. Changing the agent afterwards makes this request stale.\"\n ),\n confirm: t('botlit.agentApproval.dialog.request.confirm', 'Submit for review'),\n },\n approve: {\n title: t('botlit.agentApproval.dialog.approve.title', 'Approve and go live'),\n description: t(\n 'botlit.agentApproval.dialog.approve.description',\n \"Approving publishes the agent's draft and makes it ACTIVE immediately.\"\n ),\n confirm: t('botlit.agentApproval.dialog.approve.confirm', 'Approve'),\n },\n reject: {\n title: t('botlit.agentApproval.dialog.reject.title', 'Reject activation'),\n description: t(\n 'botlit.agentApproval.dialog.reject.description',\n 'Tell the requester what needs to change. The agent stays as it is.'\n ),\n confirm: t('botlit.agentApproval.dialog.reject.confirm', 'Reject'),\n },\n };\n const current = kind ? copy[kind] : null;\n\n return (\n <Dialog\n open={kind !== null}\n onOpenChange={(open) => {\n if (!open) {\n setText('');\n onClose();\n }\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{current?.title}</DialogTitle>\n <DialogDescription>{current?.description}</DialogDescription>\n </DialogHeader>\n <Textarea\n aria-label={\n kind === 'request'\n ? t('botlit.agentApproval.dialog.noteLabel', 'Note for the reviewer')\n : t('botlit.agentApproval.dialog.reasonLabel', 'Reason')\n }\n value={text}\n maxLength={2000}\n onChange={(event) => setText(event.target.value)}\n placeholder={\n kind === 'request'\n ? t('botlit.agentApproval.dialog.notePlaceholder', 'What changed and why (optional)')\n : reasonRequired\n ? t('botlit.agentApproval.dialog.reasonRequiredPlaceholder', 'Reason (required)')\n : t('botlit.agentApproval.dialog.reasonPlaceholder', 'Reason (optional)')\n }\n rows={4}\n />\n <DialogFooter>\n <Button\n variant=\"outline\"\n onClick={() => {\n setText('');\n onClose();\n }}\n >\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button\n variant={kind === 'reject' ? 'destructive' : 'default'}\n isLoading={loading}\n disabled={reasonRequired && text.trim().length === 0}\n onClick={async () => {\n await onConfirm(text);\n setText('');\n }}\n >\n {current?.confirm}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n};\n\ninterface AgentApprovalPanelProps {\n agentId: string;\n agentStatus: string;\n /** Called after a decision that changes the agent so the page can refetch it. */\n onChanged?: () => void;\n}\n\nexport const AgentApprovalPanel: FC<AgentApprovalPanelProps> = ({\n agentId,\n agentStatus,\n onChanged,\n}) => {\n const t = useTr();\n const { currentUser } = useBotlit();\n const settings = useAgentApprovalSettings();\n const requests = useAgentApprovalRequests({ agentId });\n const { run, pending } = useAgentApprovalActions();\n const [dialog, setDialog] = useState<{\n kind: DecisionKind;\n request?: AgentApprovalRequestRecord;\n } | null>(null);\n\n const required = settings.data?.requireActivationApproval === true;\n const open = requests.data.find((request) => request.status === 'PENDING') ?? null;\n const history = requests.data.filter((request) => request.status !== 'PENDING').slice(0, 10);\n const isRequester = open !== null && open.requestedById === currentUser?.id;\n\n const who = (id?: string | null): string =>\n id && id === currentUser?.id ? t('botlit.agentApproval.you', 'you') : (id ?? '—');\n\n const confirm = async (text: string): Promise<void> => {\n if (!dialog) return;\n try {\n if (dialog.kind === 'request') {\n await run({ kind: 'request', agentId, note: text });\n toast.success(t('botlit.agentApproval.toast.requested', 'Activation requested'));\n } else if (dialog.kind === 'approve' && dialog.request) {\n await run({ kind: 'approve', id: dialog.request.id, reason: text });\n toast.success(t('botlit.agentApproval.toast.approved', 'Approved — the agent is live'));\n onChanged?.();\n } else if (dialog.kind === 'reject' && dialog.request) {\n await run({ kind: 'reject', id: dialog.request.id, reason: text });\n toast.success(t('botlit.agentApproval.toast.rejected', 'Activation rejected'));\n }\n setDialog(null);\n await requests.refetch();\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.agentApproval.toast.error', 'Approval action failed')\n );\n }\n };\n\n const cancel = async (request: AgentApprovalRequestRecord): Promise<void> => {\n try {\n await run({ kind: 'cancel', id: request.id });\n toast.success(t('botlit.agentApproval.toast.cancelled', 'Request cancelled'));\n await requests.refetch();\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.agentApproval.toast.error', 'Approval action failed')\n );\n }\n };\n\n return (\n <Card data-testid=\"agent-approval-panel\">\n <CardHeader className=\"flex flex-row items-start justify-between gap-4\">\n <div>\n <CardTitle className=\"flex items-center gap-2\">\n <ShieldCheck size={18} />\n {t('botlit.agentApproval.title', 'Activation approval')}\n <Badge variant={required ? 'warning' : 'outline'}>\n {required\n ? t('botlit.agentApproval.required', 'Required in this workspace')\n : t('botlit.agentApproval.optional', 'Optional')}\n </Badge>\n </CardTitle>\n <CardDescription>\n {required\n ? t(\n 'botlit.agentApproval.descriptionRequired',\n 'This workspace requires a reviewer to approve an agent before it goes live or before a new version is published.'\n )\n : t(\n 'botlit.agentApproval.descriptionOptional',\n 'You can ask a reviewer to check this agent before it goes live. A workspace admin can make review mandatory on the Approvals page.'\n )}\n </CardDescription>\n </div>\n {!open && agentStatus !== 'ARCHIVED' && (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_UPDATE}>\n <Button leftIcon={<Send size={16} />} onClick={() => setDialog({ kind: 'request' })}>\n {t('botlit.agentApproval.requestAction', 'Request activation')}\n </Button>\n </BotmanorPermissionGate>\n )}\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {requests.loading && requests.data.length === 0 ? (\n <div className=\"h-20 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : null}\n\n {open && (\n <div\n className=\"p-4 border border-status-warning-border bg-bg-sunken rounded-lg space-y-2\"\n data-testid=\"agent-approval-pending\"\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <Badge variant=\"warning\">{open.status}</Badge>\n <span className=\"text-sm text-text-secondary\">\n {t('botlit.agentApproval.requestedBy', 'Requested by')} {who(open.requestedById)}{' '}\n {formatRelativeTime(open.createdAt)}\n </span>\n </div>\n {open.requestNote && <p className=\"text-sm break-words\">{open.requestNote}</p>}\n {open.isStale && (\n <p className=\"flex items-center gap-2 text-sm text-status-warning-text\">\n <AlertTriangle size={14} />\n {t(\n 'botlit.agentApproval.stale',\n 'The agent changed after this request. Submit a new request so the reviewer sees the current configuration.'\n )}\n </p>\n )}\n <div className=\"flex gap-2 flex-wrap\">\n {isRequester ? (\n <>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_UPDATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n isLoading={pending === 'cancel'}\n onClick={() => void cancel(open)}\n >\n {t('botlit.agentApproval.cancelAction', 'Cancel request')}\n </Button>\n </BotmanorPermissionGate>\n {open.isStale && (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_UPDATE}>\n <Button size=\"sm\" onClick={() => setDialog({ kind: 'request' })}>\n {t('botlit.agentApproval.resubmitAction', 'Submit new request')}\n </Button>\n </BotmanorPermissionGate>\n )}\n </>\n ) : (\n <>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n leftIcon={<CheckCircle2 size={14} />}\n disabled={open.isStale}\n onClick={() => setDialog({ kind: 'approve', request: open })}\n >\n {t('botlit.agentApproval.approveAction', '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({ kind: 'reject', request: open })}\n >\n {t('botlit.agentApproval.rejectAction', 'Reject')}\n </Button>\n </BotmanorPermissionGate>\n </>\n )}\n </div>\n </div>\n )}\n\n {history.length > 0 && (\n <div className=\"space-y-2\">\n <p className=\"text-sm font-medium\">\n {t('botlit.agentApproval.history', 'Decision history')}\n </p>\n <ul className=\"space-y-2\" data-testid=\"agent-approval-history\">\n {history.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 <Badge variant={approvalStatusVariant(request.status)}>{request.status}</Badge>\n <span className=\"text-text-secondary\">\n {t('botlit.agentApproval.decidedBy', 'by')} {who(request.reviewerId)}{' '}\n {request.decidedAt ? formatRelativeTime(request.decidedAt) : ''}\n </span>\n </div>\n {request.decisionReason && (\n <p className=\"break-words\">{request.decisionReason}</p>\n )}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {!open && history.length === 0 && !requests.loading && (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.agentApproval.empty', 'No activation requests for this agent yet.')}\n </p>\n )}\n </CardContent>\n\n <ApprovalDecisionDialog\n kind={dialog?.kind ?? null}\n loading={pending !== null}\n onClose={() => setDialog(null)}\n onConfirm={confirm}\n />\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,SAAgBE,EACd,GACmD;CAInD,OAHIC,MA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AU;UAAhB,UAAA;WACGhC,EAAE,kCAAkC,IAAI;WAAE;WAAEoC,EAAIJ,EAAQ,UAAU;WAAG;WACrEA,EAAQ,YAAYuB,EAAmBvB,EAAQ,SAAS,IAAI;UACzD;SACH,CAAA,CAAA;QACJ,CAAA,GAAAA,EAAQ,kBACP,kBAAC,KAAD;SAAG,WAAU;SAAe,UAAAA,EAAQ;QAAkB,CAAA,CAEtD;OAbG,GAAAA,EAAQ,EAaX,CACL;MACC,CAAA,CACD;;KAGN,CAACtB,KAAQuB,EAAQ,WAAW,KAAK,CAACP,EAAS,WAC1C,kBAAC,KAAD;MAAG,WAAU;MACV,UAAA1B,EAAE,8BAA8B,4CAA4C;KAC5E,CAAA;IAEM;;GAEb,kBAACD,GAAD;IACE,MAAM8B,GAAQ,QAAQ;IACtB,SAAS4B,MAAY;IACrB,eAAe3B,EAAU,IAAI;IAC7B,WAAWQ;GACZ,CAAA;EACG;;AAEV"}
1
+ {"version":3,"file":"AgentApprovalPanel.js","names":["_Fragment","Fragment$1","approvalStatusVariant","status","ApprovalDecisionDialog","t","useTr","text","setText","useState","reasonRequired","kind","copy","current","Dialog","open","onClose","DialogContent","DialogHeader","DialogTitle","DialogDescription","Textarea","event","DialogFooter","Button","loading","onConfirm","AgentApprovalPanel","useBotlit","settings","useAgentApprovalSettings","requests","useAgentApprovalRequests","useAgentApprovalActions","dialog","setDialog","required","request","history","isRequester","currentUser","who","id","confirm","run","toast","onChanged","err","cancel","Card","CardHeader","CardTitle","ShieldCheck","Badge","CardDescription","agentStatus","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","Send","CardContent","formatRelativeTime","AlertTriangle","pending","CheckCircle2","XCircle"],"sources":["../../../src/botlit/components/AgentApprovalPanel.tsx"],"sourcesContent":["/**\n * Agent Activation Approval Panel (BOFF-9682)\n * @module botlit/components\n *\n * Reviewer gate on the agent detail page. Builders request activation (the\n * request pins the agent's current config); reviewers with\n * `botmanor-agent:approve` approve it, which publishes the draft and takes the\n * agent live, or reject it with a reason. The requester cannot decide their\n * own request, and a request whose agent changed afterwards is flagged stale\n * and cannot be approved.\n */\n\nimport { useState, type FC } from 'react';\nimport { AlertTriangle, CheckCircle2, ShieldCheck, Send, XCircle } from 'lucide-react';\nimport { toast } from 'sonner';\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from './Card';\nimport { Button } from './Button';\nimport { Badge } from './Badge';\nimport {\n useAgentApprovalActions,\n useAgentApprovalRequests,\n useAgentApprovalSettings,\n type AgentApprovalRequestRecord,\n type AgentApprovalStatus,\n} from '../hooks/useAgentApprovals';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\nexport function approvalStatusVariant(\n status: AgentApprovalStatus\n): 'warning' | 'success' | 'destructive' | 'outline' {\n if (status === 'PENDING') return 'warning';\n if (status === 'APPROVED') return 'success';\n if (status === 'REJECTED') return 'destructive';\n return 'outline';\n}\n\ntype DecisionKind = 'request' | 'approve' | 'reject';\n\ninterface DecisionDialogProps {\n kind: DecisionKind | null;\n loading: boolean;\n onClose: () => void;\n onConfirm: (text: string) => Promise<void>;\n}\n\n/** Note / reason dialog shared by the detail panel and the approvals page. */\nexport const ApprovalDecisionDialog: FC<DecisionDialogProps> = ({\n kind,\n loading,\n onClose,\n onConfirm,\n}) => {\n const t = useTr();\n const [text, setText] = useState('');\n const reasonRequired = kind === 'reject';\n\n const copy: Record<DecisionKind, { title: string; description: string; confirm: string }> = {\n request: {\n title: t('botlit.agentApproval.dialog.request.title', 'Request activation'),\n description: t(\n 'botlit.agentApproval.dialog.request.description',\n \"A reviewer will check the agent's current prompt, model, tools and limits before it goes live. Changing the agent afterwards makes this request stale.\"\n ),\n confirm: t('botlit.agentApproval.dialog.request.confirm', 'Submit for review'),\n },\n approve: {\n title: t('botlit.agentApproval.dialog.approve.title', 'Approve and go live'),\n description: t(\n 'botlit.agentApproval.dialog.approve.description',\n \"Approving publishes the agent's draft and makes it ACTIVE immediately.\"\n ),\n confirm: t('botlit.agentApproval.dialog.approve.confirm', 'Approve'),\n },\n reject: {\n title: t('botlit.agentApproval.dialog.reject.title', 'Reject activation'),\n description: t(\n 'botlit.agentApproval.dialog.reject.description',\n 'Tell the requester what needs to change. The agent stays as it is.'\n ),\n confirm: t('botlit.agentApproval.dialog.reject.confirm', 'Reject'),\n },\n };\n const current = kind ? copy[kind] : null;\n\n return (\n <Dialog\n open={kind !== null}\n onOpenChange={(open) => {\n if (!open) {\n setText('');\n onClose();\n }\n }}\n >\n <DialogContent>\n <DialogHeader>\n <DialogTitle>{current?.title}</DialogTitle>\n <DialogDescription>{current?.description}</DialogDescription>\n </DialogHeader>\n <Textarea\n aria-label={\n kind === 'request'\n ? t('botlit.agentApproval.dialog.noteLabel', 'Note for the reviewer')\n : t('botlit.agentApproval.dialog.reasonLabel', 'Reason')\n }\n value={text}\n maxLength={2000}\n onChange={(event) => setText(event.target.value)}\n placeholder={\n kind === 'request'\n ? t('botlit.agentApproval.dialog.notePlaceholder', 'What changed and why (optional)')\n : reasonRequired\n ? t('botlit.agentApproval.dialog.reasonRequiredPlaceholder', 'Reason (required)')\n : t('botlit.agentApproval.dialog.reasonPlaceholder', 'Reason (optional)')\n }\n rows={4}\n />\n <DialogFooter>\n <Button\n variant=\"outline\"\n onClick={() => {\n setText('');\n onClose();\n }}\n >\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button\n variant={kind === 'reject' ? 'destructive' : 'default'}\n isLoading={loading}\n disabled={reasonRequired && text.trim().length === 0}\n onClick={async () => {\n await onConfirm(text);\n setText('');\n }}\n >\n {current?.confirm}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n};\n\ninterface AgentApprovalPanelProps {\n agentId: string;\n agentStatus: string;\n /** Called after a decision that changes the agent so the page can refetch it. */\n onChanged?: () => void;\n}\n\nexport const AgentApprovalPanel: FC<AgentApprovalPanelProps> = ({\n agentId,\n agentStatus,\n onChanged,\n}) => {\n const t = useTr();\n const { currentUser } = useBotlit();\n const settings = useAgentApprovalSettings();\n const requests = useAgentApprovalRequests({ agentId });\n const { run, pending } = useAgentApprovalActions();\n const [dialog, setDialog] = useState<{\n kind: DecisionKind;\n request?: AgentApprovalRequestRecord;\n } | null>(null);\n\n const required = settings.data?.requireActivationApproval === true;\n const open = requests.data.find((request) => request.status === 'PENDING') ?? null;\n const history = requests.data.filter((request) => request.status !== 'PENDING').slice(0, 10);\n const isRequester = open !== null && open.requestedById === currentUser?.id;\n\n const who = (id?: string | null): string =>\n id && id === currentUser?.id ? t('botlit.agentApproval.you', 'you') : (id ?? '—');\n\n const confirm = async (text: string): Promise<void> => {\n if (!dialog) return;\n try {\n if (dialog.kind === 'request') {\n await run({ kind: 'request', agentId, note: text });\n toast.success(t('botlit.agentApproval.toast.requested', 'Activation requested'));\n } else if (dialog.kind === 'approve' && dialog.request) {\n await run({ kind: 'approve', id: dialog.request.id, reason: text });\n toast.success(t('botlit.agentApproval.toast.approved', 'Approved — the agent is live'));\n onChanged?.();\n } else if (dialog.kind === 'reject' && dialog.request) {\n await run({ kind: 'reject', id: dialog.request.id, reason: text });\n toast.success(t('botlit.agentApproval.toast.rejected', 'Activation rejected'));\n }\n setDialog(null);\n await requests.refetch();\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.agentApproval.toast.error', 'Approval action failed')\n );\n }\n };\n\n const cancel = async (request: AgentApprovalRequestRecord): Promise<void> => {\n try {\n await run({ kind: 'cancel', id: request.id });\n toast.success(t('botlit.agentApproval.toast.cancelled', 'Request cancelled'));\n await requests.refetch();\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.agentApproval.toast.error', 'Approval action failed')\n );\n }\n };\n\n return (\n <Card data-testid=\"agent-approval-panel\">\n <CardHeader className=\"flex flex-row items-start justify-between gap-4\">\n <div>\n <CardTitle className=\"flex items-center gap-2\">\n <ShieldCheck size={18} />\n {t('botlit.agentApproval.title', 'Activation approval')}\n <Badge variant={required ? 'warning' : 'outline'}>\n {required\n ? t('botlit.agentApproval.required', 'Required in this workspace')\n : t('botlit.agentApproval.optional', 'Optional')}\n </Badge>\n </CardTitle>\n <CardDescription>\n {required\n ? t(\n 'botlit.agentApproval.descriptionRequired',\n 'This workspace requires a reviewer to approve an agent before it goes live or before a new version is published.'\n )\n : t(\n 'botlit.agentApproval.descriptionOptional',\n 'You can ask a reviewer to check this agent before it goes live. A workspace admin can make review mandatory on the Approvals page.'\n )}\n </CardDescription>\n </div>\n {!open && agentStatus !== 'ARCHIVED' && (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_UPDATE}>\n <Button leftIcon={<Send size={16} />} onClick={() => setDialog({ kind: 'request' })}>\n {t('botlit.agentApproval.requestAction', 'Request activation')}\n </Button>\n </BotmanorPermissionGate>\n )}\n </CardHeader>\n <CardContent className=\"space-y-4\">\n {requests.loading && requests.data.length === 0 ? (\n <div className=\"h-20 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : null}\n\n {open && (\n <div\n className=\"p-4 border border-status-warning-border bg-bg-sunken rounded-lg space-y-2\"\n data-testid=\"agent-approval-pending\"\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <Badge variant=\"warning\">{open.status}</Badge>\n <span className=\"text-sm text-text-secondary\">\n {t('botlit.agentApproval.requestedBy', 'Requested by')} {who(open.requestedById)}{' '}\n {formatRelativeTime(open.createdAt)}\n </span>\n </div>\n {open.requestNote && <p className=\"text-sm break-words\">{open.requestNote}</p>}\n {open.isStale && (\n <p className=\"flex items-center gap-2 text-sm text-status-warning-text\">\n <AlertTriangle size={14} />\n {t(\n 'botlit.agentApproval.stale',\n 'The agent changed after this request. Submit a new request so the reviewer sees the current configuration.'\n )}\n </p>\n )}\n <div className=\"flex gap-2 flex-wrap\">\n {isRequester ? (\n <>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_UPDATE}>\n <Button\n variant=\"outline\"\n size=\"sm\"\n isLoading={pending === 'cancel'}\n onClick={() => void cancel(open)}\n >\n {t('botlit.agentApproval.cancelAction', 'Cancel request')}\n </Button>\n </BotmanorPermissionGate>\n {open.isStale && (\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_UPDATE}>\n <Button size=\"sm\" onClick={() => setDialog({ kind: 'request' })}>\n {t('botlit.agentApproval.resubmitAction', 'Submit new request')}\n </Button>\n </BotmanorPermissionGate>\n )}\n </>\n ) : (\n <>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n leftIcon={<CheckCircle2 size={14} />}\n disabled={open.isStale}\n onClick={() => setDialog({ kind: 'approve', request: open })}\n >\n {t('botlit.agentApproval.approveAction', '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({ kind: 'reject', request: open })}\n >\n {t('botlit.agentApproval.rejectAction', 'Reject')}\n </Button>\n </BotmanorPermissionGate>\n </>\n )}\n </div>\n </div>\n )}\n\n {history.length > 0 && (\n <div className=\"space-y-2\">\n <p className=\"text-sm font-medium\">\n {t('botlit.agentApproval.history', 'Decision history')}\n </p>\n <ul className=\"space-y-2\" data-testid=\"agent-approval-history\">\n {history.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 <Badge variant={approvalStatusVariant(request.status)}>{request.status}</Badge>\n <span className=\"text-text-secondary\">\n {t('botlit.agentApproval.decidedBy', 'by')} {who(request.reviewerId)}{' '}\n {request.decidedAt ? formatRelativeTime(request.decidedAt) : ''}\n </span>\n </div>\n {request.decisionReason && (\n <p className=\"break-words\">{request.decisionReason}</p>\n )}\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {!open && history.length === 0 && !requests.loading && (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.agentApproval.empty', 'No activation requests for this agent yet.')}\n </p>\n )}\n </CardContent>\n\n <ApprovalDecisionDialog\n kind={dialog?.kind ?? null}\n loading={pending !== null}\n onClose={() => setDialog(null)}\n onConfirm={confirm}\n />\n </Card>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,SAAgBE,EACd,GACmD;CAInD,OAHIC,MAAW,YAAkB,YAC7BA,MAAW,aAAmB,YAC9BA,MAAW,aAAmB,gBAC3B;AACT;AAYA,IAAaC,KAAmD,EAC9D,SACA,YACA,YACA,mBACI;CACJ,IAAMC,IAAIC,EAAM,GACV,CAACC,GAAMC,KAAWC,EAAS,EAAE,GAC7BC,IAAiBC,MAAS,UAE1BC,IAAsF;EAC1F,SAAS;GACP,OAAOP,EAAE,6CAA6C,oBAAoB;GAC1E,aAAaA,EACX,mDACA,wJACF;GACA,SAASA,EAAE,+CAA+C,mBAAmB;EAC/E;EACA,SAAS;GACP,OAAOA,EAAE,6CAA6C,qBAAqB;GAC3E,aAAaA,EACX,mDACA,wEACF;GACA,SAASA,EAAE,+CAA+C,SAAS;EACrE;EACA,QAAQ;GACN,OAAOA,EAAE,4CAA4C,mBAAmB;GACxE,aAAaA,EACX,kDACA,oEACF;GACA,SAASA,EAAE,8CAA8C,QAAQ;EACnE;CACF,GACMQ,IAAUF,IAAOC,EAAKD,KAAQ;CAEpC,OACE,kBAACG,GAAD;EACE,MAAMH,MAAS;EACf,eAAe,MAAS;GACtB,AAAKI,MACHP,EAAQ,EAAE,GACVQ,EAAQ;EAEZ;EAEA,UAAA,kBAACC,GAAD,EAAA,UAAA;GACE,kBAACC,GAAD,EAAA,UA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EAAA,CAAA;OAED,CAAA;MACF;;KAGNiC,EAAQ,SAAS,KAChB,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,KAAD;OAAG,WAAU;OACV,UAAAjC,EAAE,gCAAgC,kBAAkB;MACpD,CAAA,GACH,kBAAC,MAAD;OAAI,WAAU;OAAY,eAAY;OACnC,UAAAiC,EAAQ,KAAK,MACZ,kBAAC,MAAD;QAEE,WAAU;QAFZ,UAAA,CAIE,kBAAC,OAAD;SAAK,WAAU;SAAf,UAAA,CACE,kBAACe,GAAD;UAAO,SAASnD,EAAsBmC,EAAQ,MAAM;UAAI,UAAAA,EAAQ;SAAc,CAAA,GAC9E,kBAAC,QAAD;UAAM,WAAU;UAAhB,UAAA;WACGhC,EAAE,kCAAkC,IAAI;WAAE;WAAEoC,EAAIJ,EAAQ,UAAU;WAAG;WACrEA,EAAQ,YAAYuB,EAAmBvB,EAAQ,SAAS,IAAI;UACzD;SACH,CAAA,CAAA;QACJ,CAAA,GAAAA,EAAQ,kBACP,kBAAC,KAAD;SAAG,WAAU;SAAe,UAAAA,EAAQ;QAAkB,CAAA,CAEtD;OAbG,GAAAA,EAAQ,EAaX,CACL;MACC,CAAA,CACD;;KAGN,CAACtB,KAAQuB,EAAQ,WAAW,KAAK,CAACP,EAAS,WAC1C,kBAAC,KAAD;MAAG,WAAU;MACV,UAAA1B,EAAE,8BAA8B,4CAA4C;KAC5E,CAAA;IAEM;;GAEb,kBAACD,GAAD;IACE,MAAM8B,GAAQ,QAAQ;IACtB,SAAS4B,MAAY;IACrB,eAAe3B,EAAU,IAAI;IAC7B,WAAWQ;GACZ,CAAA;EACG;;AAEV"}
@@ -1,21 +1,19 @@
1
1
  import { Card as e, CardContent as t, CardDescription as n, CardHeader as r, CardTitle as i } from "./Card.js";
2
- import { BOTMANOR_PERMISSIONS as a } from "../permissions/botmanorPermissions.js";
3
- import { useBotmanorCan as o } from "../permissions/useBotmanorPermissions.js";
4
- import { Button as s } from "./Button.js";
5
- import { Input as c } from "./Input.js";
6
- import { Badge as l } from "./Badge.js";
7
- import "../hooks/index.js";
8
- import { graphqlErrorMessage as u } from "../utils/errors.js";
9
- import { useRetrievalProfiles as d } from "../hooks/useRetrievalProfiles.js";
10
- import { useSkills as ee } from "../hooks/useSkills.js";
11
- import { promptTemplateVariables as f, usePromptTemplate as p, usePromptTemplates as m } from "../hooks/usePromptTemplates.js";
12
- import { useAgentBindings as h, useSetAgentBindings as g } from "../hooks/useAgentBindings.js";
13
- import { typedVariableValue as _ } from "../utils/promptVariables.js";
14
- import "../permissions/index.js";
15
- import { useEffect as v, useMemo as y, useState as b } from "react";
16
- import { ThemedSelect as x } from "@burdenoff/fe-libs/ui";
17
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
18
- import { ArrowDown as w, ArrowUp as te, Layers as T } from "lucide-react";
2
+ import { Button as a } from "./Button.js";
3
+ import { Input as o } from "./Input.js";
4
+ import { Badge as s } from "./Badge.js";
5
+ import { promptTemplateVariables as c, usePromptTemplate as l, usePromptTemplates as u } from "../hooks/usePromptTemplates.js";
6
+ import { useAgentBindings as d, useSetAgentBindings as ee } from "../hooks/useAgentBindings.js";
7
+ import { useRetrievalProfiles as te } from "../hooks/useRetrievalProfiles.js";
8
+ import { useSkills as f } from "../hooks/useSkills.js";
9
+ import { graphqlErrorMessage as p } from "../utils/errors.js";
10
+ import { typedVariableValue as m } from "../utils/promptVariables.js";
11
+ import { BOTMANOR_PERMISSIONS as h } from "../permissions/botmanorPermissions.js";
12
+ import { useBotmanorCan as g } from "../permissions/useBotmanorPermissions.js";
13
+ import { useEffect as _, useMemo as v, useState as y } from "react";
14
+ import { ThemedSelect as b } from "@burdenoff/fe-libs/ui";
15
+ import { jsx as x, jsxs as S } from "react/jsx-runtime";
16
+ import { ArrowDown as C, ArrowUp as w, Layers as T } from "lucide-react";
19
17
  import { toast as E } from "sonner";
20
18
  // src/botlit/components/AgentBindingsPanel.tsx
21
19
  var D = "h-10 w-full rounded-md border border-border-default bg-bg-surface px-3 text-sm";
@@ -35,15 +33,15 @@ function k(e) {
35
33
  };
36
34
  }
37
35
  var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
38
- let M = o(), [N, P] = b(!1), F = M(a.AGENT_UPDATE), I = h(j), L = F && !N && !!I.data && !I.loading, R = m(), z = ee(), B = d(), { save: V } = g(j), [H, U] = b(() => k(null)), W = p(H.promptTemplateId || void 0), G = W.data && W.data.id === H.promptTemplateId ? W.data : null, K = !!H.promptTemplateId && !W.loading && !!W.data && W.data?.id !== H.promptTemplateId, { refetch: q } = W;
39
- v(() => {
36
+ let M = g(), [N, P] = y(!1), F = M(h.AGENT_UPDATE), I = d(j), L = F && !N && !!I.data && !I.loading, R = u(), z = f(), B = te(), { save: V } = ee(j), [H, U] = y(() => k(null)), W = l(H.promptTemplateId || void 0), G = W.data && W.data.id === H.promptTemplateId ? W.data : null, K = !!H.promptTemplateId && !W.loading && !!W.data && W.data?.id !== H.promptTemplateId, { refetch: q } = W;
37
+ _(() => {
40
38
  K && q();
41
39
  }, [K, q]);
42
40
  let J = !!I.data && (!H.promptTemplateId || G !== null && !W.loading) && !I.loading && !I.error && !R.loading && !R.error && !z.loading && !z.error && !B.loading && !B.error;
43
- v(() => {
41
+ _(() => {
44
42
  U(k(I.data));
45
43
  }, [I.data]);
46
- let Y = y(() => G ? f(G) : [], [G]), X = I.data?.retrievalProfile, Z = H.retrievalProfileId ? B.data.find((e) => e.id === H.retrievalProfileId) ?? (X?.retrievalProfileId === H.retrievalProfileId ? X : null) : null, ne = y(() => new Map(z.data.map((e) => [e.id, e])), [z.data]), Q = z.data.filter((e) => A(e.status) && !H.skillIds.includes(e.id)), $ = (e, t) => {
44
+ let Y = v(() => G ? c(G) : [], [G]), X = I.data?.retrievalProfile, Z = H.retrievalProfileId ? B.data.find((e) => e.id === H.retrievalProfileId) ?? (X?.retrievalProfileId === H.retrievalProfileId ? X : null) : null, ne = v(() => new Map(z.data.map((e) => [e.id, e])), [z.data]), Q = z.data.filter((e) => A(e.status) && !H.skillIds.includes(e.id)), $ = (e, t) => {
47
45
  let n = [...H.skillIds], r = e + t;
48
46
  r < 0 || r >= n.length || ([n[e], n[r]] = [n[r], n[e]], U({
49
47
  ...H,
@@ -53,7 +51,7 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
53
51
  let e = I.data?.promptTemplate?.promptTemplateId ?? "", t = H.promptTemplateId !== e, n = t ? {} : O(I.data), r = {};
54
52
  for (let e of Y) {
55
53
  let t = H.variables[e.name] ?? "";
56
- !H.edited.includes(e.name) && e.name in n ? r[e.name] = n[e.name] : t !== "" && (r[e.name] = _(e.type, t));
54
+ !H.edited.includes(e.name) && e.name in n ? r[e.name] = n[e.name] : t !== "" && (r[e.name] = m(e.type, t));
57
55
  }
58
56
  let i = !!H.promptTemplateId && (t || H.edited.length > 0);
59
57
  P(!0);
@@ -65,27 +63,27 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
65
63
  retrievalProfileId: H.retrievalProfileId || null
66
64
  }), E.success("Agent bindings saved"), await I.refetch();
67
65
  } catch (e) {
68
- E.error(u(e, "Failed to save the agent bindings"));
66
+ E.error(p(e, "Failed to save the agent bindings"));
69
67
  } finally {
70
68
  P(!1);
71
69
  }
72
70
  };
73
- return /* @__PURE__ */ C(e, { children: [/* @__PURE__ */ C(r, { children: [/* @__PURE__ */ C(i, {
71
+ return /* @__PURE__ */ S(e, { children: [/* @__PURE__ */ S(r, { children: [/* @__PURE__ */ S(i, {
74
72
  className: "flex items-center gap-2",
75
- children: [/* @__PURE__ */ S(T, { size: 18 }), "Prompt template, skills & retrieval"]
76
- }), /* @__PURE__ */ S(n, { children: "Every run of this agent starts from the bound prompt template, adds the agent's own system prompt and the skills below, and searches its knowledge with the retrieval profile." })] }), /* @__PURE__ */ C(t, {
73
+ children: [/* @__PURE__ */ x(T, { size: 18 }), "Prompt template, skills & retrieval"]
74
+ }), /* @__PURE__ */ x(n, { children: "Every run of this agent starts from the bound prompt template, adds the agent's own system prompt and the skills below, and searches its knowledge with the retrieval profile." })] }), /* @__PURE__ */ S(t, {
77
75
  className: "space-y-6",
78
76
  children: [
79
- I.error && /* @__PURE__ */ S("p", {
77
+ I.error && /* @__PURE__ */ x("p", {
80
78
  role: "alert",
81
79
  className: "text-sm text-status-error-text",
82
- children: u(I.error, "Failed to load the agent bindings")
80
+ children: p(I.error, "Failed to load the agent bindings")
83
81
  }),
84
- /* @__PURE__ */ C("section", {
82
+ /* @__PURE__ */ S("section", {
85
83
  className: "space-y-3",
86
- children: [/* @__PURE__ */ C("label", {
84
+ children: [/* @__PURE__ */ S("label", {
87
85
  className: "grid gap-2 text-sm font-medium",
88
- children: ["Prompt template", /* @__PURE__ */ C(x, {
86
+ children: ["Prompt template", /* @__PURE__ */ S(b, {
89
87
  "aria-label": "Prompt template",
90
88
  className: D,
91
89
  value: H.promptTemplateId,
@@ -97,11 +95,11 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
97
95
  edited: []
98
96
  }),
99
97
  children: [
100
- /* @__PURE__ */ S("option", {
98
+ /* @__PURE__ */ x("option", {
101
99
  value: "",
102
100
  children: "No prompt template"
103
101
  }),
104
- G && !R.data.some((e) => e.id === G.id) && /* @__PURE__ */ C("option", {
102
+ G && !R.data.some((e) => e.id === G.id) && /* @__PURE__ */ S("option", {
105
103
  value: G.id,
106
104
  children: [
107
105
  G.name,
@@ -109,7 +107,7 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
109
107
  G.version
110
108
  ]
111
109
  }),
112
- R.data.filter((e) => A(e.status) || e.id === H.promptTemplateId).map((e) => /* @__PURE__ */ C("option", {
110
+ R.data.filter((e) => A(e.status) || e.id === H.promptTemplateId).map((e) => /* @__PURE__ */ S("option", {
113
111
  value: e.id,
114
112
  children: [
115
113
  e.name,
@@ -119,14 +117,14 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
119
117
  }, e.id))
120
118
  ]
121
119
  })]
122
- }), Y.length > 0 && /* @__PURE__ */ S("div", {
120
+ }), Y.length > 0 && /* @__PURE__ */ x("div", {
123
121
  className: "grid gap-3 sm:grid-cols-2",
124
- children: Y.map((e) => /* @__PURE__ */ C("label", {
122
+ children: Y.map((e) => /* @__PURE__ */ S("label", {
125
123
  className: "grid gap-1 text-sm",
126
- children: [/* @__PURE__ */ C("span", { children: [`{{${e.name}}}`, e.required && /* @__PURE__ */ S("span", {
124
+ children: [/* @__PURE__ */ S("span", { children: [`{{${e.name}}}`, e.required && /* @__PURE__ */ x("span", {
127
125
  className: "ml-1 text-status-error-text",
128
126
  children: "*"
129
- })] }), /* @__PURE__ */ S(c, {
127
+ })] }), /* @__PURE__ */ x(o, {
130
128
  "aria-label": `Variable ${e.name}`,
131
129
  disabled: !L,
132
130
  placeholder: typeof e.defaultValue == "string" ? `Default: ${e.defaultValue}` : e.description ?? e.type,
@@ -143,55 +141,55 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
143
141
  }, e.name))
144
142
  })]
145
143
  }),
146
- /* @__PURE__ */ C("section", {
144
+ /* @__PURE__ */ S("section", {
147
145
  className: "space-y-3",
148
146
  children: [
149
- /* @__PURE__ */ S("p", {
147
+ /* @__PURE__ */ x("p", {
150
148
  className: "text-sm font-medium",
151
149
  children: "Skills"
152
150
  }),
153
- H.skillIds.length === 0 ? /* @__PURE__ */ S("p", {
151
+ H.skillIds.length === 0 ? /* @__PURE__ */ x("p", {
154
152
  className: "text-sm text-text-secondary",
155
153
  children: "No skills attached."
156
- }) : /* @__PURE__ */ S("ol", {
154
+ }) : /* @__PURE__ */ x("ol", {
157
155
  className: "space-y-2",
158
156
  children: H.skillIds.map((e, t) => {
159
157
  let n = ne.get(e);
160
- return /* @__PURE__ */ C("li", {
158
+ return /* @__PURE__ */ S("li", {
161
159
  className: "flex items-center gap-3 rounded-lg border border-border-subtle p-3",
162
160
  children: [
163
- /* @__PURE__ */ C(l, {
161
+ /* @__PURE__ */ S(s, {
164
162
  variant: "outline",
165
163
  children: ["#", t + 1]
166
164
  }),
167
- /* @__PURE__ */ C("div", {
165
+ /* @__PURE__ */ S("div", {
168
166
  className: "min-w-0 flex-1",
169
- children: [/* @__PURE__ */ S("p", {
167
+ children: [/* @__PURE__ */ x("p", {
170
168
  className: "truncate text-sm font-medium",
171
169
  children: n?.name ?? I.data?.skills.find((t) => t.skillId === e)?.name ?? e
172
- }), n?.description && /* @__PURE__ */ S("p", {
170
+ }), n?.description && /* @__PURE__ */ x("p", {
173
171
  className: "truncate text-xs text-text-secondary",
174
172
  children: n.description
175
173
  })]
176
174
  }),
177
- L && /* @__PURE__ */ C("div", {
175
+ L && /* @__PURE__ */ S("div", {
178
176
  className: "flex items-center gap-1",
179
177
  children: [
180
- /* @__PURE__ */ S(s, {
178
+ /* @__PURE__ */ x(a, {
181
179
  size: "sm",
182
180
  variant: "ghost",
183
181
  "aria-label": "Move skill up",
184
182
  onClick: () => $(t, -1),
185
- children: /* @__PURE__ */ S(te, { size: 14 })
183
+ children: /* @__PURE__ */ x(w, { size: 14 })
186
184
  }),
187
- /* @__PURE__ */ S(s, {
185
+ /* @__PURE__ */ x(a, {
188
186
  size: "sm",
189
187
  variant: "ghost",
190
188
  "aria-label": "Move skill down",
191
189
  onClick: () => $(t, 1),
192
- children: /* @__PURE__ */ S(w, { size: 14 })
190
+ children: /* @__PURE__ */ x(C, { size: 14 })
193
191
  }),
194
- /* @__PURE__ */ S(s, {
192
+ /* @__PURE__ */ x(a, {
195
193
  size: "sm",
196
194
  variant: "outline",
197
195
  onClick: () => U({
@@ -206,7 +204,7 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
206
204
  }, e);
207
205
  })
208
206
  }),
209
- L && Q.length > 0 && /* @__PURE__ */ C(x, {
207
+ L && Q.length > 0 && /* @__PURE__ */ S(b, {
210
208
  "aria-label": "Add skill",
211
209
  className: D,
212
210
  value: "",
@@ -214,21 +212,21 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
214
212
  ...H,
215
213
  skillIds: [...H.skillIds, e.target.value]
216
214
  }),
217
- children: [/* @__PURE__ */ S("option", {
215
+ children: [/* @__PURE__ */ x("option", {
218
216
  value: "",
219
217
  children: "Add a skill…"
220
- }), Q.map((e) => /* @__PURE__ */ S("option", {
218
+ }), Q.map((e) => /* @__PURE__ */ x("option", {
221
219
  value: e.id,
222
220
  children: e.name
223
221
  }, e.id))]
224
222
  })
225
223
  ]
226
224
  }),
227
- /* @__PURE__ */ C("section", {
225
+ /* @__PURE__ */ S("section", {
228
226
  className: "space-y-2",
229
- children: [/* @__PURE__ */ C("label", {
227
+ children: [/* @__PURE__ */ S("label", {
230
228
  className: "grid gap-2 text-sm font-medium",
231
- children: ["Retrieval profile", /* @__PURE__ */ C(x, {
229
+ children: ["Retrieval profile", /* @__PURE__ */ S(b, {
232
230
  "aria-label": "Retrieval profile",
233
231
  className: D,
234
232
  value: H.retrievalProfileId,
@@ -238,11 +236,11 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
238
236
  retrievalProfileId: e.target.value
239
237
  }),
240
238
  children: [
241
- /* @__PURE__ */ S("option", {
239
+ /* @__PURE__ */ x("option", {
242
240
  value: "",
243
241
  children: "Default retrieval (vector, top 5)"
244
242
  }),
245
- I.data?.retrievalProfile && !B.data.some((e) => e.id === I.data?.retrievalProfile?.retrievalProfileId) && /* @__PURE__ */ C("option", {
243
+ I.data?.retrievalProfile && !B.data.some((e) => e.id === I.data?.retrievalProfile?.retrievalProfileId) && /* @__PURE__ */ S("option", {
246
244
  value: I.data.retrievalProfile.retrievalProfileId,
247
245
  children: [
248
246
  I.data.retrievalProfile.name,
@@ -254,7 +252,7 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
254
252
  I.data.retrievalProfile.topK
255
253
  ]
256
254
  }),
257
- B.data.filter((e) => A(e.status) || e.id === H.retrievalProfileId).map((e) => /* @__PURE__ */ C("option", {
255
+ B.data.filter((e) => A(e.status) || e.id === H.retrievalProfileId).map((e) => /* @__PURE__ */ S("option", {
258
256
  value: e.id,
259
257
  children: [
260
258
  e.name,
@@ -266,7 +264,7 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
266
264
  }, e.id))
267
265
  ]
268
266
  })]
269
- }), Z && /* @__PURE__ */ C("p", {
267
+ }), Z && /* @__PURE__ */ S("p", {
270
268
  className: "text-xs text-text-secondary",
271
269
  children: [
272
270
  Z.strategyMode,
@@ -278,21 +276,21 @@ var A = (e) => e !== "ARCHIVED", j = ({ agentId: j }) => {
278
276
  ]
279
277
  })]
280
278
  }),
281
- F && /* @__PURE__ */ S("div", {
279
+ F && /* @__PURE__ */ x("div", {
282
280
  className: "flex justify-end",
283
- children: /* @__PURE__ */ S(s, {
281
+ children: /* @__PURE__ */ x(a, {
284
282
  onClick: () => void re(),
285
283
  isLoading: N,
286
284
  disabled: !J || N,
287
285
  children: "Save bindings"
288
286
  })
289
287
  }),
290
- I.data && /* @__PURE__ */ C("section", {
288
+ I.data && /* @__PURE__ */ S("section", {
291
289
  className: "space-y-2",
292
- children: [/* @__PURE__ */ S("p", {
290
+ children: [/* @__PURE__ */ x("p", {
293
291
  className: "text-sm font-medium",
294
292
  children: "Effective system prompt"
295
- }), /* @__PURE__ */ S("pre", {
293
+ }), /* @__PURE__ */ x("pre", {
296
294
  "data-testid": "effective-system-prompt",
297
295
  className: "max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-bg-sunken p-4 font-mono text-sm",
298
296
  children: I.data.effectiveSystemPrompt