@burdenoff/microfe-botmanor 2026.1201.2 → 2026.1201.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botlit/BotmanorRootInner.js +2 -1
- package/dist/botlit/BotmanorRootInner.js.map +1 -1
- package/dist/botlit/components/StewardApprovalsInbox.d.ts +4 -0
- package/dist/botlit/components/StewardApprovalsInbox.js +419 -0
- package/dist/botlit/components/StewardApprovalsInbox.js.map +1 -0
- package/dist/botlit/hooks/useToolApprovals.d.ts +38 -5
- package/dist/botlit/hooks/useToolApprovals.js +50 -31
- package/dist/botlit/hooks/useToolApprovals.js.map +1 -1
- package/dist/botlit/pages/ToolApprovalsPage.js +125 -106
- package/dist/botlit/pages/ToolApprovalsPage.js.map +1 -1
- package/dist/botlit/permissions/botmanorPermissions.d.ts +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
- package/dist/botlit/utils/stewardApprovals.d.ts +80 -0
- package/dist/botlit/utils/stewardApprovals.js +90 -0
- package/dist/botlit/utils/stewardApprovals.js.map +1 -0
- package/dist/generated/global-types.d.ts +7580 -811
- package/dist/generated/global-types.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +9369 -61
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolApprovalsPage.js","names":["toolApprovalStatusVariant","status","argumentsText","value","ApprovalRequestDetails","t","useTr","request","Badge","reason","ToolApprovalsPage","useBotlit","pending","useToolApprovals","all","useDecideToolApproval","dialog","setDialog","useState","note","setNote","decided","who","id","currentUser","close","submitDecision","decide","toast","err","PageLayout","Button","navigateTo","ArrowLeft","PagePurpose","ShieldAlert","Card","CardHeader","CardTitle","CardContent","ErrorState","formatRelativeTime","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","CheckCircle2","pendingId","XCircle","ResponsiveDialog","open","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Textarea","event","ResponsiveDialogFooter"],"sources":["../../../src/botlit/pages/ToolApprovalsPage.tsx"],"sourcesContent":["/**\n * Tool Approvals Page (BOFF-15360)\n * @module botlit/pages\n *\n * Approver queue for tool calls a TOOL policy holds for a human decision:\n * which agent wants to run which tool, with what arguments, why it needs\n * approval and when the request expires. Approving runs the call and the\n * agent posts its answer in the original conversation; denying (with a\n * reason) tells the user it was not run. Recent decisions show how each\n * resumed call ended.\n */\n\nimport { useState, type FC } from 'react';\nimport { ArrowLeft, CheckCircle2, ShieldAlert, XCircle } from 'lucide-react';\nimport { toast } from 'sonner';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n PagePurpose,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardContent, CardHeader, CardTitle } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport {\n useDecideToolApproval,\n useToolApprovals,\n type ToolApprovalRecord,\n type ToolApprovalStatus,\n} from '../hooks/useToolApprovals';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { BOTMANOR_PERMISSIONS, BotmanorPermissionGate } from '../permissions';\n\nexport function toolApprovalStatusVariant(\n status: ToolApprovalStatus\n): 'warning' | 'success' | 'destructive' | 'outline' {\n if (status === 'PENDING') return 'warning';\n if (status === 'APPROVED') return 'success';\n if (status === 'DENIED') return 'destructive';\n return 'outline';\n}\n\nfunction argumentsText(value: unknown): string {\n try {\n return JSON.stringify(value ?? {}, null, 2);\n } catch {\n return String(value);\n }\n}\n\nconst ApprovalRequestDetails: FC<{ request: ToolApprovalRecord }> = ({ request }) => {\n const t = useTr();\n return (\n <div className=\"space-y-2 text-sm\">\n {request.userMessage && (\n <p className=\"break-words\">\n <span className=\"text-text-secondary\">\n {t('botlit.toolApprovals.userAsked', 'User asked:')}{' '}\n </span>\n {request.userMessage}\n </p>\n )}\n <div className=\"flex flex-wrap gap-1\">\n {request.reasons.map((reason) => (\n <Badge key={reason} variant=\"outline\">\n {reason}\n </Badge>\n ))}\n </div>\n <pre className=\"text-xs bg-bg-sunken rounded-md p-2 overflow-x-auto max-h-48 whitespace-pre-wrap break-all\">\n {argumentsText(request.arguments)}\n </pre>\n </div>\n );\n};\n\nexport const ToolApprovalsPage: FC = () => {\n const t = useTr();\n const { navigateTo, currentUser } = useBotlit();\n const pending = useToolApprovals({ status: 'PENDING' });\n const all = useToolApprovals({});\n const { decide, pendingId } = useDecideToolApproval();\n const [dialog, setDialog] = useState<{\n decision: 'APPROVE' | 'DENY';\n request: ToolApprovalRecord;\n } | null>(null);\n const [note, setNote] = useState('');\n\n const decided = all.data.filter((request) => request.status !== 'PENDING').slice(0, 20);\n const who = (id?: string | null): string =>\n id && id === currentUser?.id ? t('botlit.toolApprovals.you', 'you') : (id ?? '—');\n\n const close = (): void => {\n setDialog(null);\n setNote('');\n };\n\n const submitDecision = async (): Promise<void> => {\n if (!dialog) return;\n try {\n await decide(dialog.request.id, dialog.decision, note);\n toast.success(\n dialog.decision === 'APPROVE'\n ? t(\n 'botlit.toolApprovals.toast.approved',\n 'Approved — the tool is running and the agent will answer in the conversation'\n )\n : t('botlit.toolApprovals.toast.denied', 'Denied — the user is told it was not run')\n );\n close();\n await Promise.all([pending.refetch(), all.refetch()]);\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.toolApprovals.toast.error', 'Could not record the decision')\n );\n }\n };\n\n return (\n <PageLayout\n title={\n <div className=\"flex items-center gap-3\">\n <Button variant=\"ghost\" size=\"icon\" onClick={() => navigateTo('policies')}>\n <ArrowLeft size={20} />\n </Button>\n <span>{t('botlit.toolApprovals.title', 'Tool approvals')}</span>\n </div>\n }\n description={t(\n 'botlit.toolApprovals.description',\n 'Approve or deny risky tool calls your TOOL policies hold for a human'\n )}\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<ShieldAlert size={18} />}>\n {t(\n 'botlit.toolApprovals.purpose',\n 'When a TOOL policy marks a tool, an MCP server or a risk level as needing approval, the agent does not run the call. It tells the user the call is waiting, and the request appears here. Approving runs the call and the agent posts its answer in the same conversation. Denying tells the user it was not run. Requests expire at the time shown.'\n )}\n </PagePurpose>\n\n <Card>\n <CardHeader>\n <CardTitle>\n {t('botlit.toolApprovals.pending.title', 'Waiting for a decision')}\n </CardTitle>\n </CardHeader>\n <CardContent>\n {pending.error ? (\n <ErrorState\n resource={t('botlit.toolApprovals.resource', 'tool approvals')}\n error={pending.error}\n onRetry={() => void pending.refetch()}\n />\n ) : pending.loading && pending.data.length === 0 ? (\n <div className=\"h-24 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : pending.data.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.toolApprovals.pending.empty', 'No tool calls are waiting for approval.')}\n </p>\n ) : (\n <ul className=\"space-y-3\" data-testid=\"tool-approvals-pending\">\n {pending.data.map((request) => (\n <li\n key={request.id}\n className=\"p-4 border border-border-subtle rounded-lg space-y-3\"\n data-testid={`tool-approval-${request.id}`}\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <button\n type=\"button\"\n className=\"font-medium text-primary hover:underline\"\n onClick={() => navigateTo(`agents/${request.agentId}`)}\n >\n {request.agentName ?? request.agentId}\n </button>\n <span className=\"text-sm\">\n {t('botlit.toolApprovals.wantsToRun', 'wants to run')}{' '}\n <code className=\"font-mono\">{request.toolName}</code>{' '}\n {t('botlit.toolApprovals.on', 'on')} {request.connectionName}\n </span>\n <Badge variant={request.riskLevel === 'HIGH' ? 'destructive' : 'warning'}>\n {request.riskLevel}\n </Badge>\n {request.mode === 'REQUESTER' && (\n <Badge variant=\"outline\">\n {t('botlit.toolApprovals.requesterMode', 'Requester confirms')}\n </Badge>\n )}\n </div>\n <p className=\"text-xs text-text-secondary\">\n {t('botlit.toolApprovals.requested', 'Requested')}{' '}\n {formatRelativeTime(request.createdAt)} ·{' '}\n {t('botlit.toolApprovals.expires', 'expires')}{' '}\n {formatRelativeTime(request.expiresAt)}\n </p>\n <ApprovalRequestDetails request={request} />\n <div className=\"flex gap-2\">\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n leftIcon={<CheckCircle2 size={14} />}\n isLoading={pendingId === request.id && dialog?.decision === 'APPROVE'}\n onClick={() => setDialog({ decision: 'APPROVE', request })}\n >\n {t('botlit.toolApprovals.approve', 'Approve')}\n </Button>\n </BotmanorPermissionGate>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n variant=\"destructive\"\n leftIcon={<XCircle size={14} />}\n onClick={() => setDialog({ decision: 'DENY', request })}\n >\n {t('botlit.toolApprovals.deny', 'Deny')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n\n <Card>\n <CardHeader>\n <CardTitle>{t('botlit.toolApprovals.history.title', 'Recent decisions')}</CardTitle>\n </CardHeader>\n <CardContent>\n {all.error ? (\n <ErrorState\n resource={t('botlit.toolApprovals.resource', 'tool approvals')}\n error={all.error}\n onRetry={() => void all.refetch()}\n />\n ) : all.loading && decided.length === 0 ? (\n <div className=\"h-16 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : decided.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.toolApprovals.history.empty', 'No decisions yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\" data-testid=\"tool-approvals-history\">\n {decided.map((request) => (\n <li\n key={request.id}\n className=\"p-3 border border-border-subtle rounded-lg text-sm space-y-1\"\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className=\"font-medium\">{request.agentName ?? request.agentId}</span>\n <code className=\"font-mono\">{request.toolName}</code>\n <Badge variant={toolApprovalStatusVariant(request.status)}>\n {request.status}\n </Badge>\n {request.resumeStatus && (\n <Badge\n variant={request.resumeStatus === 'FAILED' ? 'destructive' : 'outline'}\n >\n {t('botlit.toolApprovals.run', 'Run')}: {request.resumeStatus}\n </Badge>\n )}\n <span className=\"text-text-secondary\">\n {t('botlit.toolApprovals.by', 'by')} {who(request.deciderId)}{' '}\n {request.decidedAt ? formatRelativeTime(request.decidedAt) : ''}\n </span>\n </div>\n {request.decisionNote && <p className=\"break-words\">{request.decisionNote}</p>}\n {request.resumeError && (\n <p className=\"break-words text-status-error-text\">{request.resumeError}</p>\n )}\n {request.resumeExecutionId && (\n <button\n type=\"button\"\n className=\"text-primary hover:underline\"\n onClick={() => navigateTo(`executions/${request.resumeExecutionId}`)}\n >\n {t('botlit.toolApprovals.viewRun', 'View the resumed run')}\n </button>\n )}\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n </div>\n\n <ResponsiveDialog\n open={dialog !== null}\n onOpenChange={(open) => {\n if (!open) close();\n }}\n >\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {dialog?.decision === 'APPROVE'\n ? t('botlit.toolApprovals.dialog.approveTitle', 'Approve and run this tool call')\n : t('botlit.toolApprovals.dialog.denyTitle', 'Deny this tool call')}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {dialog?.decision === 'APPROVE'\n ? t(\n 'botlit.toolApprovals.dialog.approveDescription',\n 'The tool runs now with the arguments shown, and the agent posts its answer in the conversation.'\n )\n : t(\n 'botlit.toolApprovals.dialog.denyDescription',\n 'The tool is not run. The user is told the request was declined, with your reason.'\n )}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n {dialog && <ApprovalRequestDetails request={dialog.request} />}\n <Textarea\n aria-label={t('botlit.toolApprovals.dialog.noteLabel', 'Reason')}\n value={note}\n maxLength={2000}\n onChange={(event) => setNote(event.target.value)}\n placeholder={\n dialog?.decision === 'DENY'\n ? t('botlit.toolApprovals.dialog.reasonRequired', 'Reason (required)')\n : t('botlit.toolApprovals.dialog.reasonOptional', 'Note (optional)')\n }\n rows={3}\n />\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={close}>\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button\n variant={dialog?.decision === 'DENY' ? 'destructive' : 'default'}\n isLoading={pendingId !== null}\n disabled={dialog?.decision === 'DENY' && note.trim().length === 0}\n onClick={() => void submitDecision()}\n >\n {dialog?.decision === 'APPROVE'\n ? t('botlit.toolApprovals.approve', 'Approve')\n : t('botlit.toolApprovals.deny', 'Deny')}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,SAAgBA,EACd,GACmD;CAInD,OAHIC,MAAW,YAAkB,YAC7BA,MAAW,aAAmB,YAC9BA,MAAW,WAAiB,gBACzB;AACT;AAEA,SAASC,EAAc,GAAwB;CAC7C,IAAI;EACF,OAAO,KAAK,UAAUC,KAAS,CAAC,GAAG,MAAM,CAAC;CAC5C,QAAQ;EACN,OAAO,OAAOA,CAAK;CACrB;AACF;AAEA,IAAMC,KAA+D,EAAE,iBAAc;CACnF,IAAMC,IAAIC,EAAM;CAChB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACGC,EAAQ,eACP,kBAAC,KAAD;IAAG,WAAU;IAAb,UAAA,CACE,kBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACGF,EAAE,kCAAkC,aAAa,GAAG,GACjD;IACL,CAAA,GAAAE,EAAQ,WACR;;GAEL,kBAAC,OAAD;IAAK,WAAU;IACZ,UAAAA,EAAQ,QAAQ,KAAK,MACpB,kBAACC,GAAD;KAAoB,SAAQ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AAC,CAAC,WAAW;KAChE,eAAe,KAAKO,EAAe;KAElC,UAAAV,GAAQ,aAAa,YAClBX,EAAE,gCAAgC,SAAS,IAC3CA,EAAE,6BAA6B,MAAM;IACnC,CAAA,CACc,EAAA,CAAA;GACD,EAAA,CAAA;EACT,CAAA,CACR;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"ToolApprovalsPage.js","names":["EmptyState","EmptyState$1","toolApprovalStatusVariant","status","argumentsText","value","ApprovalRequestDetails","t","useTr","request","Badge","reason","AgentToolApprovalsView","useBotlit","pending","useToolApprovals","all","useDecideToolApproval","dialog","setDialog","useState","note","setNote","decided","who","id","currentUser","close","submitDecision","decide","toast","err","PageLayout","Button","navigateTo","ArrowLeft","PagePurpose","ShieldAlert","Card","CardHeader","CardTitle","CardContent","ErrorState","formatRelativeTime","BotmanorPermissionGate","BOTMANOR_PERMISSIONS","CheckCircle2","pendingId","XCircle","ResponsiveDialog","open","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Textarea","event","ResponsiveDialogFooter","StewardToolApprovalsView","read","useBotmanorPermissionDecision","StewardApprovalsInbox","agentId","ToolApprovalsPage","useFeatureFlag"],"sources":["../../../src/botlit/pages/ToolApprovalsPage.tsx"],"sourcesContent":["/**\n * Tool Approvals Page (BOFF-15360)\n * @module botlit/pages\n *\n * Approver queue for tool calls a TOOL policy holds for a human decision:\n * which agent wants to run which tool, with what arguments, why it needs\n * approval and when the request expires. Approving runs the call and the\n * agent posts its answer in the original conversation; denying (with a\n * reason) tells the user it was not run. Recent decisions show how each\n * resumed call ended.\n */\n\nimport { useState, type FC } from 'react';\nimport { ArrowLeft, CheckCircle2, ShieldAlert, XCircle } from 'lucide-react';\nimport { toast } from 'sonner';\nimport { useFeatureFlag } from '@burdenoff/fe-libs/shared/feature-flags';\nimport {\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n PagePurpose,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { Card, CardContent, CardHeader, CardTitle } from '../components/Card';\nimport { Button } from '../components/Button';\nimport { Badge } from '../components/Badge';\nimport { ErrorState } from '../components/ErrorState';\nimport { EmptyState } from '../components/EmptyState';\nimport { StewardApprovalsInbox } from '../components/StewardApprovalsInbox';\nimport {\n useDecideToolApproval,\n useToolApprovals,\n type ToolApprovalRecord,\n type ToolApprovalStatus,\n} from '../hooks/useToolApprovals';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { formatRelativeTime } from '../utils/formatters';\nimport {\n BOTMANOR_PERMISSIONS,\n BotmanorPermissionGate,\n useBotmanorPermissionDecision,\n} from '../permissions';\n\nexport function toolApprovalStatusVariant(\n status: ToolApprovalStatus\n): 'warning' | 'success' | 'destructive' | 'outline' {\n if (status === 'PENDING') return 'warning';\n if (status === 'APPROVED') return 'success';\n if (status === 'DENIED') return 'destructive';\n return 'outline';\n}\n\nfunction argumentsText(value: unknown): string {\n try {\n return JSON.stringify(value ?? {}, null, 2);\n } catch {\n return String(value);\n }\n}\n\nconst ApprovalRequestDetails: FC<{ request: ToolApprovalRecord }> = ({ request }) => {\n const t = useTr();\n return (\n <div className=\"space-y-2 text-sm\">\n {request.userMessage && (\n <p className=\"break-words\">\n <span className=\"text-text-secondary\">\n {t('botlit.toolApprovals.userAsked', 'User asked:')}{' '}\n </span>\n {request.userMessage}\n </p>\n )}\n <div className=\"flex flex-wrap gap-1\">\n {request.reasons.map((reason) => (\n <Badge key={reason} variant=\"outline\">\n {reason}\n </Badge>\n ))}\n </div>\n <pre className=\"text-xs bg-bg-sunken rounded-md p-2 overflow-x-auto max-h-48 whitespace-pre-wrap break-all\">\n {argumentsText(request.arguments)}\n </pre>\n </div>\n );\n};\n\n/** The queue of tool calls from agent chats, as before Stewards (flag off). */\nconst AgentToolApprovalsView: FC = () => {\n const t = useTr();\n const { navigateTo, currentUser } = useBotlit();\n // Steward requests belong to the Steward inbox; keep them out while the flag is off.\n const pending = useToolApprovals({ status: 'PENDING', source: 'AGENT_CHAT' });\n const all = useToolApprovals({ source: 'AGENT_CHAT' });\n const { decide, pendingId } = useDecideToolApproval();\n const [dialog, setDialog] = useState<{\n decision: 'APPROVE' | 'DENY';\n request: ToolApprovalRecord;\n } | null>(null);\n const [note, setNote] = useState('');\n\n const decided = all.data.filter((request) => request.status !== 'PENDING').slice(0, 20);\n const who = (id?: string | null): string =>\n id && id === currentUser?.id ? t('botlit.toolApprovals.you', 'you') : (id ?? '—');\n\n const close = (): void => {\n setDialog(null);\n setNote('');\n };\n\n const submitDecision = async (): Promise<void> => {\n if (!dialog) return;\n try {\n await decide(dialog.request.id, dialog.decision, note);\n toast.success(\n dialog.decision === 'APPROVE'\n ? t(\n 'botlit.toolApprovals.toast.approved',\n 'Approved — the tool is running and the agent will answer in the conversation'\n )\n : t('botlit.toolApprovals.toast.denied', 'Denied — the user is told it was not run')\n );\n close();\n await Promise.all([pending.refetch(), all.refetch()]);\n } catch (err: unknown) {\n toast.error(\n err instanceof Error\n ? err.message\n : t('botlit.toolApprovals.toast.error', 'Could not record the decision')\n );\n }\n };\n\n return (\n <PageLayout\n title={\n <div className=\"flex items-center gap-3\">\n <Button variant=\"ghost\" size=\"icon\" onClick={() => navigateTo('policies')}>\n <ArrowLeft size={20} />\n </Button>\n <span>{t('botlit.toolApprovals.title', 'Tool approvals')}</span>\n </div>\n }\n description={t(\n 'botlit.toolApprovals.description',\n 'Approve or deny risky tool calls your TOOL policies hold for a human'\n )}\n >\n <div className=\"space-y-6\">\n <PagePurpose icon={<ShieldAlert size={18} />}>\n {t(\n 'botlit.toolApprovals.purpose',\n 'When a TOOL policy marks a tool, an MCP server or a risk level as needing approval, the agent does not run the call. It tells the user the call is waiting, and the request appears here. Approving runs the call and the agent posts its answer in the same conversation. Denying tells the user it was not run. Requests expire at the time shown.'\n )}\n </PagePurpose>\n\n <Card>\n <CardHeader>\n <CardTitle>\n {t('botlit.toolApprovals.pending.title', 'Waiting for a decision')}\n </CardTitle>\n </CardHeader>\n <CardContent>\n {pending.error ? (\n <ErrorState\n resource={t('botlit.toolApprovals.resource', 'tool approvals')}\n error={pending.error}\n onRetry={() => void pending.refetch()}\n />\n ) : pending.loading && pending.data.length === 0 ? (\n <div className=\"h-24 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : pending.data.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.toolApprovals.pending.empty', 'No tool calls are waiting for approval.')}\n </p>\n ) : (\n <ul className=\"space-y-3\" data-testid=\"tool-approvals-pending\">\n {pending.data.map((request) => (\n <li\n key={request.id}\n className=\"p-4 border border-border-subtle rounded-lg space-y-3\"\n data-testid={`tool-approval-${request.id}`}\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <button\n type=\"button\"\n className=\"font-medium text-primary hover:underline\"\n onClick={() => navigateTo(`agents/${request.agentId}`)}\n >\n {request.agentName ?? request.agentId}\n </button>\n <span className=\"text-sm\">\n {t('botlit.toolApprovals.wantsToRun', 'wants to run')}{' '}\n <code className=\"font-mono\">{request.toolName}</code>{' '}\n {t('botlit.toolApprovals.on', 'on')} {request.connectionName}\n </span>\n <Badge variant={request.riskLevel === 'HIGH' ? 'destructive' : 'warning'}>\n {request.riskLevel}\n </Badge>\n {request.mode === 'REQUESTER' && (\n <Badge variant=\"outline\">\n {t('botlit.toolApprovals.requesterMode', 'Requester confirms')}\n </Badge>\n )}\n </div>\n <p className=\"text-xs text-text-secondary\">\n {t('botlit.toolApprovals.requested', 'Requested')}{' '}\n {formatRelativeTime(request.createdAt)} ·{' '}\n {t('botlit.toolApprovals.expires', 'expires')}{' '}\n {formatRelativeTime(request.expiresAt)}\n </p>\n <ApprovalRequestDetails request={request} />\n <div className=\"flex gap-2\">\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n leftIcon={<CheckCircle2 size={14} />}\n isLoading={pendingId === request.id && dialog?.decision === 'APPROVE'}\n onClick={() => setDialog({ decision: 'APPROVE', request })}\n >\n {t('botlit.toolApprovals.approve', 'Approve')}\n </Button>\n </BotmanorPermissionGate>\n <BotmanorPermissionGate permission={BOTMANOR_PERMISSIONS.AGENT_APPROVE}>\n <Button\n size=\"sm\"\n variant=\"destructive\"\n leftIcon={<XCircle size={14} />}\n onClick={() => setDialog({ decision: 'DENY', request })}\n >\n {t('botlit.toolApprovals.deny', 'Deny')}\n </Button>\n </BotmanorPermissionGate>\n </div>\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n\n <Card>\n <CardHeader>\n <CardTitle>{t('botlit.toolApprovals.history.title', 'Recent decisions')}</CardTitle>\n </CardHeader>\n <CardContent>\n {all.error ? (\n <ErrorState\n resource={t('botlit.toolApprovals.resource', 'tool approvals')}\n error={all.error}\n onRetry={() => void all.refetch()}\n />\n ) : all.loading && decided.length === 0 ? (\n <div className=\"h-16 bg-bg-sunken motion-safe:animate-vc-shimmer rounded-lg\" />\n ) : decided.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('botlit.toolApprovals.history.empty', 'No decisions yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\" data-testid=\"tool-approvals-history\">\n {decided.map((request) => (\n <li\n key={request.id}\n className=\"p-3 border border-border-subtle rounded-lg text-sm space-y-1\"\n >\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className=\"font-medium\">{request.agentName ?? request.agentId}</span>\n <code className=\"font-mono\">{request.toolName}</code>\n <Badge variant={toolApprovalStatusVariant(request.status)}>\n {request.status}\n </Badge>\n {request.resumeStatus && (\n <Badge\n variant={request.resumeStatus === 'FAILED' ? 'destructive' : 'outline'}\n >\n {t('botlit.toolApprovals.run', 'Run')}: {request.resumeStatus}\n </Badge>\n )}\n <span className=\"text-text-secondary\">\n {t('botlit.toolApprovals.by', 'by')} {who(request.deciderId)}{' '}\n {request.decidedAt ? formatRelativeTime(request.decidedAt) : ''}\n </span>\n </div>\n {request.decisionNote && <p className=\"break-words\">{request.decisionNote}</p>}\n {request.resumeError && (\n <p className=\"break-words text-status-error-text\">{request.resumeError}</p>\n )}\n {request.resumeExecutionId && (\n <button\n type=\"button\"\n className=\"text-primary hover:underline\"\n onClick={() => navigateTo(`executions/${request.resumeExecutionId}`)}\n >\n {t('botlit.toolApprovals.viewRun', 'View the resumed run')}\n </button>\n )}\n </li>\n ))}\n </ul>\n )}\n </CardContent>\n </Card>\n </div>\n\n <ResponsiveDialog\n open={dialog !== null}\n onOpenChange={(open) => {\n if (!open) close();\n }}\n >\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {dialog?.decision === 'APPROVE'\n ? t('botlit.toolApprovals.dialog.approveTitle', 'Approve and run this tool call')\n : t('botlit.toolApprovals.dialog.denyTitle', 'Deny this tool call')}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {dialog?.decision === 'APPROVE'\n ? t(\n 'botlit.toolApprovals.dialog.approveDescription',\n 'The tool runs now with the arguments shown, and the agent posts its answer in the conversation.'\n )\n : t(\n 'botlit.toolApprovals.dialog.denyDescription',\n 'The tool is not run. The user is told the request was declined, with your reason.'\n )}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n {dialog && <ApprovalRequestDetails request={dialog.request} />}\n <Textarea\n aria-label={t('botlit.toolApprovals.dialog.noteLabel', 'Reason')}\n value={note}\n maxLength={2000}\n onChange={(event) => setNote(event.target.value)}\n placeholder={\n dialog?.decision === 'DENY'\n ? t('botlit.toolApprovals.dialog.reasonRequired', 'Reason (required)')\n : t('botlit.toolApprovals.dialog.reasonOptional', 'Note (optional)')\n }\n rows={3}\n />\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={close}>\n {t('botlit.common.cancel', 'Cancel')}\n </Button>\n <Button\n variant={dialog?.decision === 'DENY' ? 'destructive' : 'default'}\n isLoading={pendingId !== null}\n disabled={dialog?.decision === 'DENY' && note.trim().length === 0}\n onClick={() => void submitDecision()}\n >\n {dialog?.decision === 'APPROVE'\n ? t('botlit.toolApprovals.approve', 'Approve')\n : t('botlit.toolApprovals.deny', 'Deny')}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n </PageLayout>\n );\n};\n\n/** Steward-aware inbox (flag `botmanor.stewards`), gated on `botmanor-policy:read`. */\nconst StewardToolApprovalsView: FC = () => {\n const t = useTr();\n const { navigateTo } = useBotlit();\n const read = useBotmanorPermissionDecision(BOTMANOR_PERMISSIONS.POLICY_READ);\n\n return (\n <PageLayout\n title={t('botlit.stewardApprovals.title', 'Approvals')}\n description={t(\n 'botlit.stewardApprovals.description',\n 'Tool calls waiting for a person, from agent chats and stewards.'\n )}\n >\n {read === 'allowed' ? (\n <StewardApprovalsInbox onOpenAgent={(agentId) => navigateTo(`agents/${agentId}`)} />\n ) : read === 'denied' ? (\n <div data-testid=\"approvals-forbidden\">\n <EmptyState\n title={t('botlit.stewardApprovals.noAccess.title', 'You cannot view approvals')}\n description={t(\n 'botlit.stewardApprovals.noAccess.description',\n 'Ask a workspace admin for access to tool approvals.'\n )}\n />\n </div>\n ) : (\n <div className=\"h-48 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\" />\n )}\n </PageLayout>\n );\n};\n\nexport const ToolApprovalsPage: FC = () => {\n const stewardsEnabled = useFeatureFlag('botmanor.stewards', false);\n return stewardsEnabled ? <StewardToolApprovalsView /> : <AgentToolApprovalsView />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgBE,EACd,GACmD;CAInD,OAHIC,MAAW,YAAkB,YAC7BA,MAAW,aAAmB,YAC9BA,MAAW,WAAiB,gBACzB;AACT;AAEA,SAASC,EAAc,GAAwB;CAC7C,IAAI;EACF,OAAO,KAAK,UAAUC,KAAS,CAAC,GAAG,MAAM,CAAC;CAC5C,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9C,GAAD,CAAyB,CAAA"}
|
|
@@ -63,6 +63,7 @@ export declare const BOTMANOR_PERMISSIONS: {
|
|
|
63
63
|
readonly CHANNEL_DELETE: "botmanor-channel:delete";
|
|
64
64
|
readonly CHANNEL_MESSAGE_CREATE: "botmanor-channel-message:create";
|
|
65
65
|
readonly CHANNEL_MESSAGE_EXECUTE: "botmanor-channel-message:execute";
|
|
66
|
+
readonly POLICY_READ: "botmanor-policy:read";
|
|
66
67
|
readonly POLICY_CREATE: "botmanor-policy:create";
|
|
67
68
|
readonly POLICY_UPDATE: "botmanor-policy:update";
|
|
68
69
|
readonly POLICY_DELETE: "botmanor-policy:delete";
|
|
@@ -50,6 +50,7 @@ var e = {
|
|
|
50
50
|
CHANNEL_DELETE: "botmanor-channel:delete",
|
|
51
51
|
CHANNEL_MESSAGE_CREATE: "botmanor-channel-message:create",
|
|
52
52
|
CHANNEL_MESSAGE_EXECUTE: "botmanor-channel-message:execute",
|
|
53
|
+
POLICY_READ: "botmanor-policy:read",
|
|
53
54
|
POLICY_CREATE: "botmanor-policy:create",
|
|
54
55
|
POLICY_UPDATE: "botmanor-policy:update",
|
|
55
56
|
POLICY_DELETE: "botmanor-policy:delete",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"botmanorPermissions.js","names":["BOTMANOR_PERMISSIONS"],"sources":["../../../src/botlit/permissions/botmanorPermissions.ts"],"sourcesContent":["/**\n * BotManor permission catalogue\n * @module botlit/permissions\n *\n * The `resource:action` pairs the BotManor UI checks before it offers a write\n * control. Every pair mirrors the `@rbac(resource, action)` directive on the\n * wspace-botmanor-svc mutation that the control calls, so the UI hides exactly\n * what the gateway would refuse. The gateway stays the only enforcement point:\n * hiding a button never grants or denies anything, it only stops a member from\n * attempting an action the gateway will answer with FORBIDDEN.\n *\n * Keep this file in step with the service schema. When a mutation's directive\n * changes, change the pair here and the control that calls it.\n */\n\nexport const BOTMANOR_PERMISSIONS = {\n // Read permissions the dashboard checks before it queries a list. They mirror\n // the `@rbac` read pairs the shell's sidebar uses (`botlit-app` navPermissions).\n APP_READ: 'botmanor-app:read',\n AGENT_READ: 'botmanor-agent:read',\n CHANNEL_MESSAGE_READ: 'botmanor-channel-message:read',\n // Run stats and live run updates (getDailyUsageStats, botmanorExecutionUpdated)\n EXECUTION_READ: 'botmanor-execution:read',\n\n // Bot apps — createBotApp / updateBotApp / deleteBotApp / publishBotAppVersion /\n // rollbackBotAppVersion\n APP_CREATE: 'botmanor-app:create',\n APP_UPDATE: 'botmanor-app:update',\n APP_DELETE: 'botmanor-app:delete',\n APP_PUBLISH: 'botmanor-app:publish',\n APP_ROLLBACK: 'botmanor-app:rollback',\n\n // Agents behind an app — createAppAgent / updateAppAgent / deleteAppAgent\n APP_AGENT_CREATE: 'botmanor-app-agent:create',\n APP_AGENT_UPDATE: 'botmanor-app-agent:update',\n APP_AGENT_DELETE: 'botmanor-app-agent:delete',\n\n // Agents — createBotmanorAgent / updateBotmanorAgent / deleteBotmanorAgent /\n // publishAgentVersion / rollbackAgentVersion / chatWithAgent /\n // approve|rejectBotmanorAgentActivation / updateBotmanorAgentApprovalSettings /\n // configureAssistantRuntime / publishAssistantWebsite / configureAssistantChannel\n AGENT_CREATE: 'botmanor-agent:create',\n AGENT_UPDATE: 'botmanor-agent:update',\n AGENT_DELETE: 'botmanor-agent:delete',\n AGENT_PUBLISH: 'botmanor-agent:publish',\n AGENT_ROLLBACK: 'botmanor-agent:rollback',\n AGENT_EXECUTE: 'botmanor-agent:execute',\n AGENT_APPROVE: 'botmanor-agent:approve',\n\n // Supervisor runs and schedule changes use the AI prediction update permission.\n AI_PREDICTION_UPDATE: 'botmanor-ai-prediction:update',\n\n // Knowledge bases — createKnowledgeBase / addKnowledgeDocument /\n // updateKnowledgeBase / deleteKnowledgeBase / removeKnowledgeDocument /\n // rebuildKnowledgeBaseIndex / queueKnowledgeSource / retry*\n KNOWLEDGE_CREATE: 'botmanor-knowledge-base:create',\n KNOWLEDGE_UPDATE: 'botmanor-knowledge-base:update',\n KNOWLEDGE_DELETE: 'botmanor-knowledge-base:delete',\n KNOWLEDGE_MANAGE: 'botmanor-knowledge-base:manage',\n\n // Retrieval profiles\n RETRIEVAL_PROFILE_CREATE: 'botmanor-retrieval-profile:create',\n RETRIEVAL_PROFILE_UPDATE: 'botmanor-retrieval-profile:update',\n RETRIEVAL_PROFILE_DELETE: 'botmanor-retrieval-profile:delete',\n\n // MCP servers — create/update/deleteMCPConnection, updateMCPTool,\n // testMCPConnection, refreshMCPTools / refreshMCPResources / callMCPTool\n MCP_CREATE: 'botmanor-mcp:create',\n MCP_UPDATE: 'botmanor-mcp:update',\n MCP_DELETE: 'botmanor-mcp:delete',\n MCP_TEST: 'botmanor-mcp:test',\n MCP_EXECUTE: 'botmanor-mcp:execute',\n\n // LLM providers and models — create/update/delete*, testLlmConnection\n LLM_READ: 'botmanor-llm:read',\n LLM_CREATE: 'botmanor-llm:create',\n LLM_UPDATE: 'botmanor-llm:update',\n LLM_DELETE: 'botmanor-llm:delete',\n LLM_TEST: 'botmanor-llm:test',\n\n // A2A — create/update/deleteA2AConnection, sendA2AMessage, delegateA2ATask\n A2A_CREATE: 'botmanor-a2a:create',\n A2A_UPDATE: 'botmanor-a2a:update',\n A2A_DELETE: 'botmanor-a2a:delete',\n A2A_SEND: 'botmanor-a2a:send',\n A2A_EXECUTE: 'botmanor-a2a:execute',\n\n // A2A registry (the external agents the Registry page lists) —\n // create/update/deleteA2ARegistryEntry\n A2A_REGISTRY_CREATE: 'botmanor-a2a-registry:create',\n A2A_REGISTRY_UPDATE: 'botmanor-a2a-registry:update',\n A2A_REGISTRY_DELETE: 'botmanor-a2a-registry:delete',\n\n // Channels — connectors and routes\n CHANNEL_CREATE: 'botmanor-channel:create',\n CHANNEL_UPDATE: 'botmanor-channel:update',\n CHANNEL_DELETE: 'botmanor-channel:delete',\n // sendChannelMessage is :create, handleChannelMessage is :execute\n CHANNEL_MESSAGE_CREATE: 'botmanor-channel-message:create',\n CHANNEL_MESSAGE_EXECUTE: 'botmanor-channel-message:execute',\n\n // Policies\n POLICY_CREATE: 'botmanor-policy:create',\n POLICY_UPDATE: 'botmanor-policy:update',\n POLICY_DELETE: 'botmanor-policy:delete',\n\n // Skills\n SKILL_CREATE: 'botmanor-skill:create',\n SKILL_UPDATE: 'botmanor-skill:update',\n SKILL_DELETE: 'botmanor-skill:delete',\n\n // Prompt templates — create/duplicate share :create; renderPromptTemplate is :execute\n PROMPT_TEMPLATE_CREATE: 'botmanor-prompt-template:create',\n PROMPT_TEMPLATE_UPDATE: 'botmanor-prompt-template:update',\n PROMPT_TEMPLATE_DELETE: 'botmanor-prompt-template:delete',\n PROMPT_TEMPLATE_EXECUTE: 'botmanor-prompt-template:execute',\n\n // Executions — createExecution / triggerBotmanorBoundWorkflow are :create,\n // runExecution / updateExecutionStatus are :update\n EXECUTION_CREATE: 'botmanor-execution:create',\n EXECUTION_UPDATE: 'botmanor-execution:update',\n\n // Buckets\n BUCKET_CREATE: 'botmanor-bucket:create',\n BUCKET_UPDATE: 'botmanor-bucket:update',\n BUCKET_DELETE: 'botmanor-bucket:delete',\n\n // Store — installPackage / forkInstalledPackage are :create,\n // updateInstalledPackage :update, uninstallPackage :delete\n STORE_CREATE: 'botmanor-store:create',\n STORE_UPDATE: 'botmanor-store:update',\n STORE_DELETE: 'botmanor-store:delete',\n\n // Agent and app templates\n TEMPLATE_CREATE: 'botmanor-template:create',\n TEMPLATE_UPDATE: 'botmanor-template:update',\n TEMPLATE_DELETE: 'botmanor-template:delete',\n} as const;\n\nexport type BotmanorPermission = (typeof BOTMANOR_PERMISSIONS)[keyof typeof BOTMANOR_PERMISSIONS];\n"],"mappings":";AAeA,IAAaA,IAAuB;CAGlC,UAAU;CACV,YAAY;CACZ,sBAAsB;CAEtB,gBAAgB;CAIhB,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,cAAc;CAGd,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAMlB,cAAc;CACd,cAAc;CACd,cAAc;CACd,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,eAAe;CAGf,sBAAsB;CAKtB,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAGlB,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;CAI1B,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CAGb,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CAGV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CAIb,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CAGrB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAEhB,wBAAwB;CACxB,yBAAyB;
|
|
1
|
+
{"version":3,"file":"botmanorPermissions.js","names":["BOTMANOR_PERMISSIONS"],"sources":["../../../src/botlit/permissions/botmanorPermissions.ts"],"sourcesContent":["/**\n * BotManor permission catalogue\n * @module botlit/permissions\n *\n * The `resource:action` pairs the BotManor UI checks before it offers a write\n * control. Every pair mirrors the `@rbac(resource, action)` directive on the\n * wspace-botmanor-svc mutation that the control calls, so the UI hides exactly\n * what the gateway would refuse. The gateway stays the only enforcement point:\n * hiding a button never grants or denies anything, it only stops a member from\n * attempting an action the gateway will answer with FORBIDDEN.\n *\n * Keep this file in step with the service schema. When a mutation's directive\n * changes, change the pair here and the control that calls it.\n */\n\nexport const BOTMANOR_PERMISSIONS = {\n // Read permissions the dashboard checks before it queries a list. They mirror\n // the `@rbac` read pairs the shell's sidebar uses (`botlit-app` navPermissions).\n APP_READ: 'botmanor-app:read',\n AGENT_READ: 'botmanor-agent:read',\n CHANNEL_MESSAGE_READ: 'botmanor-channel-message:read',\n // Run stats and live run updates (getDailyUsageStats, botmanorExecutionUpdated)\n EXECUTION_READ: 'botmanor-execution:read',\n\n // Bot apps — createBotApp / updateBotApp / deleteBotApp / publishBotAppVersion /\n // rollbackBotAppVersion\n APP_CREATE: 'botmanor-app:create',\n APP_UPDATE: 'botmanor-app:update',\n APP_DELETE: 'botmanor-app:delete',\n APP_PUBLISH: 'botmanor-app:publish',\n APP_ROLLBACK: 'botmanor-app:rollback',\n\n // Agents behind an app — createAppAgent / updateAppAgent / deleteAppAgent\n APP_AGENT_CREATE: 'botmanor-app-agent:create',\n APP_AGENT_UPDATE: 'botmanor-app-agent:update',\n APP_AGENT_DELETE: 'botmanor-app-agent:delete',\n\n // Agents — createBotmanorAgent / updateBotmanorAgent / deleteBotmanorAgent /\n // publishAgentVersion / rollbackAgentVersion / chatWithAgent /\n // approve|rejectBotmanorAgentActivation / updateBotmanorAgentApprovalSettings /\n // configureAssistantRuntime / publishAssistantWebsite / configureAssistantChannel\n AGENT_CREATE: 'botmanor-agent:create',\n AGENT_UPDATE: 'botmanor-agent:update',\n AGENT_DELETE: 'botmanor-agent:delete',\n AGENT_PUBLISH: 'botmanor-agent:publish',\n AGENT_ROLLBACK: 'botmanor-agent:rollback',\n AGENT_EXECUTE: 'botmanor-agent:execute',\n AGENT_APPROVE: 'botmanor-agent:approve',\n\n // Supervisor runs and schedule changes use the AI prediction update permission.\n AI_PREDICTION_UPDATE: 'botmanor-ai-prediction:update',\n\n // Knowledge bases — createKnowledgeBase / addKnowledgeDocument /\n // updateKnowledgeBase / deleteKnowledgeBase / removeKnowledgeDocument /\n // rebuildKnowledgeBaseIndex / queueKnowledgeSource / retry*\n KNOWLEDGE_CREATE: 'botmanor-knowledge-base:create',\n KNOWLEDGE_UPDATE: 'botmanor-knowledge-base:update',\n KNOWLEDGE_DELETE: 'botmanor-knowledge-base:delete',\n KNOWLEDGE_MANAGE: 'botmanor-knowledge-base:manage',\n\n // Retrieval profiles\n RETRIEVAL_PROFILE_CREATE: 'botmanor-retrieval-profile:create',\n RETRIEVAL_PROFILE_UPDATE: 'botmanor-retrieval-profile:update',\n RETRIEVAL_PROFILE_DELETE: 'botmanor-retrieval-profile:delete',\n\n // MCP servers — create/update/deleteMCPConnection, updateMCPTool,\n // testMCPConnection, refreshMCPTools / refreshMCPResources / callMCPTool\n MCP_CREATE: 'botmanor-mcp:create',\n MCP_UPDATE: 'botmanor-mcp:update',\n MCP_DELETE: 'botmanor-mcp:delete',\n MCP_TEST: 'botmanor-mcp:test',\n MCP_EXECUTE: 'botmanor-mcp:execute',\n\n // LLM providers and models — create/update/delete*, testLlmConnection\n LLM_READ: 'botmanor-llm:read',\n LLM_CREATE: 'botmanor-llm:create',\n LLM_UPDATE: 'botmanor-llm:update',\n LLM_DELETE: 'botmanor-llm:delete',\n LLM_TEST: 'botmanor-llm:test',\n\n // A2A — create/update/deleteA2AConnection, sendA2AMessage, delegateA2ATask\n A2A_CREATE: 'botmanor-a2a:create',\n A2A_UPDATE: 'botmanor-a2a:update',\n A2A_DELETE: 'botmanor-a2a:delete',\n A2A_SEND: 'botmanor-a2a:send',\n A2A_EXECUTE: 'botmanor-a2a:execute',\n\n // A2A registry (the external agents the Registry page lists) —\n // create/update/deleteA2ARegistryEntry\n A2A_REGISTRY_CREATE: 'botmanor-a2a-registry:create',\n A2A_REGISTRY_UPDATE: 'botmanor-a2a-registry:update',\n A2A_REGISTRY_DELETE: 'botmanor-a2a-registry:delete',\n\n // Channels — connectors and routes\n CHANNEL_CREATE: 'botmanor-channel:create',\n CHANNEL_UPDATE: 'botmanor-channel:update',\n CHANNEL_DELETE: 'botmanor-channel:delete',\n // sendChannelMessage is :create, handleChannelMessage is :execute\n CHANNEL_MESSAGE_CREATE: 'botmanor-channel-message:create',\n CHANNEL_MESSAGE_EXECUTE: 'botmanor-channel-message:execute',\n\n // Policies\n // Tool approvals inbox reads (listBotmanorToolApprovals / getBotmanorToolApproval)\n POLICY_READ: 'botmanor-policy:read',\n POLICY_CREATE: 'botmanor-policy:create',\n POLICY_UPDATE: 'botmanor-policy:update',\n POLICY_DELETE: 'botmanor-policy:delete',\n\n // Skills\n SKILL_CREATE: 'botmanor-skill:create',\n SKILL_UPDATE: 'botmanor-skill:update',\n SKILL_DELETE: 'botmanor-skill:delete',\n\n // Prompt templates — create/duplicate share :create; renderPromptTemplate is :execute\n PROMPT_TEMPLATE_CREATE: 'botmanor-prompt-template:create',\n PROMPT_TEMPLATE_UPDATE: 'botmanor-prompt-template:update',\n PROMPT_TEMPLATE_DELETE: 'botmanor-prompt-template:delete',\n PROMPT_TEMPLATE_EXECUTE: 'botmanor-prompt-template:execute',\n\n // Executions — createExecution / triggerBotmanorBoundWorkflow are :create,\n // runExecution / updateExecutionStatus are :update\n EXECUTION_CREATE: 'botmanor-execution:create',\n EXECUTION_UPDATE: 'botmanor-execution:update',\n\n // Buckets\n BUCKET_CREATE: 'botmanor-bucket:create',\n BUCKET_UPDATE: 'botmanor-bucket:update',\n BUCKET_DELETE: 'botmanor-bucket:delete',\n\n // Store — installPackage / forkInstalledPackage are :create,\n // updateInstalledPackage :update, uninstallPackage :delete\n STORE_CREATE: 'botmanor-store:create',\n STORE_UPDATE: 'botmanor-store:update',\n STORE_DELETE: 'botmanor-store:delete',\n\n // Agent and app templates\n TEMPLATE_CREATE: 'botmanor-template:create',\n TEMPLATE_UPDATE: 'botmanor-template:update',\n TEMPLATE_DELETE: 'botmanor-template:delete',\n} as const;\n\nexport type BotmanorPermission = (typeof BOTMANOR_PERMISSIONS)[keyof typeof BOTMANOR_PERMISSIONS];\n"],"mappings":";AAeA,IAAaA,IAAuB;CAGlC,UAAU;CACV,YAAY;CACZ,sBAAsB;CAEtB,gBAAgB;CAIhB,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,cAAc;CAGd,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAMlB,cAAc;CACd,cAAc;CACd,cAAc;CACd,eAAe;CACf,gBAAgB;CAChB,eAAe;CACf,eAAe;CAGf,sBAAsB;CAKtB,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAClB,kBAAkB;CAGlB,0BAA0B;CAC1B,0BAA0B;CAC1B,0BAA0B;CAI1B,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CAGb,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CAGV,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,aAAa;CAIb,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CAGrB,gBAAgB;CAChB,gBAAgB;CAChB,gBAAgB;CAEhB,wBAAwB;CACxB,yBAAyB;CAIzB,aAAa;CACb,eAAe;CACf,eAAe;CACf,eAAe;CAGf,cAAc;CACd,cAAc;CACd,cAAc;CAGd,wBAAwB;CACxB,wBAAwB;CACxB,wBAAwB;CACxB,yBAAyB;CAIzB,kBAAkB;CAClB,kBAAkB;CAGlB,eAAe;CACf,eAAe;CACf,eAAe;CAIf,cAAc;CACd,cAAc;CACd,cAAc;CAGd,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;AACnB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Steward approval helpers (BOFF-16146 C3.3)
|
|
3
|
+
* @module botlit/utils
|
|
4
|
+
*
|
|
5
|
+
* Pure logic behind the Steward side of the approvals inbox: which approval
|
|
6
|
+
* scopes a reviewer may be offered for a request, how scopes read in plain
|
|
7
|
+
* words, and which fixed defaults can never become a standing rule. The service
|
|
8
|
+
* enforces every one of these rules again in `decideBotmanorToolApproval`; the
|
|
9
|
+
* UI only avoids offering a choice the service would refuse.
|
|
10
|
+
*/
|
|
11
|
+
export type ApprovalScope = 'ONCE' | 'RUN' | 'DUTY' | 'TIME_LIMITED' | 'STANDING';
|
|
12
|
+
/** Scopes in the order a reviewer sees them, narrowest first. */
|
|
13
|
+
export declare const APPROVAL_SCOPES: readonly ApprovalScope[];
|
|
14
|
+
/** Days a rule created by a scope lasts (the service sets these). */
|
|
15
|
+
export declare const RULE_SCOPE_DAYS: Readonly<Partial<Record<ApprovalScope, number>>>;
|
|
16
|
+
/** Fixed defaults: calls that always go to a person. */
|
|
17
|
+
export declare const FIXED_DEFAULT_KINDS: readonly ["password-change", "security-setting-change", "payment-entry", "read-one-time-code", "external-message"];
|
|
18
|
+
export interface ScopeSubject {
|
|
19
|
+
/** `STEWARD` for a steward's call, `AGENT_CHAT` for a chat agent's. */
|
|
20
|
+
source?: string | null;
|
|
21
|
+
fixedDefault?: string | null;
|
|
22
|
+
purpose?: string | null;
|
|
23
|
+
riskLevel?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export declare function isRuleScope(scope: ApprovalScope): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* True when the call is a fixed default that can never be waived by a rule.
|
|
28
|
+
* An external message that names a purpose is the one exception: the owner can
|
|
29
|
+
* grant a rule that names that exact recipient and purpose.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isNonWaivable(subject: ScopeSubject): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The scopes a reviewer may pick for a request. Chat-agent requests have no
|
|
34
|
+
* scope at all (an empty list). Non-waivable fixed defaults offer ONCE and RUN
|
|
35
|
+
* only, never a duty, time-limited or standing rule. STANDING is withheld from
|
|
36
|
+
* HIGH-risk (destructive) calls, as the service refuses it there.
|
|
37
|
+
*/
|
|
38
|
+
export declare function availableScopes(subject: ScopeSubject): ApprovalScope[];
|
|
39
|
+
/** The scope to preselect: what the steward asked for when it is still allowed, else ONCE. */
|
|
40
|
+
export declare function defaultScope(subject: ScopeSubject, requested?: string | null): ApprovalScope;
|
|
41
|
+
/** Human readable fixed-default names; the key is the service's `fixedDefault` value. */
|
|
42
|
+
export declare const FIXED_DEFAULT_LABELS: Readonly<Record<string, string>>;
|
|
43
|
+
export declare function fixedDefaultLabel(kind: string): string;
|
|
44
|
+
/** Short sha256 prefix for display, e.g. `sha256:3be1a07c…`. */
|
|
45
|
+
export declare function shortHash(hash?: string | null): string | null;
|
|
46
|
+
/** The note a DENY decision needs; approving needs none. */
|
|
47
|
+
export declare function decisionNeedsNote(decision: 'APPROVE' | 'DENY', note: string): boolean;
|
|
48
|
+
export interface SourceCounts {
|
|
49
|
+
all: number;
|
|
50
|
+
agentChat: number;
|
|
51
|
+
steward: number;
|
|
52
|
+
}
|
|
53
|
+
export declare function countBySource(rows: ReadonlyArray<{
|
|
54
|
+
source?: string | null;
|
|
55
|
+
}>): SourceCounts;
|
|
56
|
+
export interface ArgumentLine {
|
|
57
|
+
key: string;
|
|
58
|
+
value: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The call's arguments as `key: value` lines for the preview. Long values are
|
|
62
|
+
* cut with their length shown, so a reviewer sees the shape without a wall of
|
|
63
|
+
* text. The text is always rendered as text, never as markup.
|
|
64
|
+
*/
|
|
65
|
+
export declare function argumentLines(args: unknown): ArgumentLine[];
|
|
66
|
+
/** Distinct stewards among the rows, for the steward filter (agent name labels them). */
|
|
67
|
+
export declare function stewardOptions(rows: ReadonlyArray<{
|
|
68
|
+
source?: string | null;
|
|
69
|
+
stewardId?: string | null;
|
|
70
|
+
agentName?: string | null;
|
|
71
|
+
agentId: string;
|
|
72
|
+
}>): Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Time left until a request expires, in the compact form the inbox shows:
|
|
78
|
+
* `41 min`, `2 h 05 min`, `3 d`. Returns `expired` once the time has passed.
|
|
79
|
+
*/
|
|
80
|
+
export declare function timeLeft(expiresAt: string, now?: number): string;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/botlit/utils/stewardApprovals.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"ONCE",
|
|
4
|
+
"RUN",
|
|
5
|
+
"DUTY",
|
|
6
|
+
"TIME_LIMITED",
|
|
7
|
+
"STANDING"
|
|
8
|
+
], t = /* @__PURE__ */ new Set([
|
|
9
|
+
"DUTY",
|
|
10
|
+
"TIME_LIMITED",
|
|
11
|
+
"STANDING"
|
|
12
|
+
]), n = {
|
|
13
|
+
TIME_LIMITED: 7,
|
|
14
|
+
STANDING: 90
|
|
15
|
+
};
|
|
16
|
+
function r(e) {
|
|
17
|
+
return t.has(e);
|
|
18
|
+
}
|
|
19
|
+
function i(e) {
|
|
20
|
+
return e.fixedDefault ? e.fixedDefault !== "external-message" || !e.purpose?.trim() : !1;
|
|
21
|
+
}
|
|
22
|
+
function a(t) {
|
|
23
|
+
return t.source === "STEWARD" ? t.fixedDefault && i(t) ? e.filter((e) => !r(e)) : e.filter((e) => e !== "STANDING" || t.riskLevel !== "HIGH") : [];
|
|
24
|
+
}
|
|
25
|
+
function o(e, t) {
|
|
26
|
+
return a(e).find((e) => e === t) ?? "ONCE";
|
|
27
|
+
}
|
|
28
|
+
var s = {
|
|
29
|
+
"password-change": "Password change",
|
|
30
|
+
"security-setting-change": "Security setting change",
|
|
31
|
+
"payment-entry": "Payment entry",
|
|
32
|
+
"read-one-time-code": "One-time code read",
|
|
33
|
+
"external-message": "Message outside the workspace"
|
|
34
|
+
};
|
|
35
|
+
function c(e) {
|
|
36
|
+
return s[e] ?? e;
|
|
37
|
+
}
|
|
38
|
+
function l(e) {
|
|
39
|
+
return e ? `sha256:${e.slice(0, 8)}…` : null;
|
|
40
|
+
}
|
|
41
|
+
function u(e, t) {
|
|
42
|
+
return e === "DENY" && t.trim().length === 0;
|
|
43
|
+
}
|
|
44
|
+
function d(e) {
|
|
45
|
+
let t = e.filter((e) => e.source === "STEWARD").length;
|
|
46
|
+
return {
|
|
47
|
+
all: e.length,
|
|
48
|
+
steward: t,
|
|
49
|
+
agentChat: e.length - t
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
var f = 160;
|
|
53
|
+
function p(e) {
|
|
54
|
+
if (typeof e == "string") return e.length > f ? `${e.slice(0, f)}… (${e.length} chars)` : e;
|
|
55
|
+
try {
|
|
56
|
+
let t = JSON.stringify(e);
|
|
57
|
+
return t === void 0 ? String(e) : t.length > f ? `${t.slice(0, f)}… (${t.length} chars)` : t;
|
|
58
|
+
} catch {
|
|
59
|
+
return String(e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function m(e) {
|
|
63
|
+
return typeof e != "object" || !e || Array.isArray(e) ? e == null ? [] : [{
|
|
64
|
+
key: "arguments",
|
|
65
|
+
value: p(e)
|
|
66
|
+
}] : Object.entries(e).map(([e, t]) => ({
|
|
67
|
+
key: e,
|
|
68
|
+
value: p(t)
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
function h(e) {
|
|
72
|
+
let t = /* @__PURE__ */ new Map();
|
|
73
|
+
for (let n of e) n.source === "STEWARD" && n.stewardId && !t.has(n.stewardId) && t.set(n.stewardId, n.agentName ?? n.agentId);
|
|
74
|
+
return [...t].map(([e, t]) => ({
|
|
75
|
+
id: e,
|
|
76
|
+
label: t
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
function g(e, t = Date.now()) {
|
|
80
|
+
let n = new Date(e).getTime() - t;
|
|
81
|
+
if (Number.isNaN(n)) return "";
|
|
82
|
+
if (n <= 0) return "expired";
|
|
83
|
+
let r = Math.max(1, Math.round(n / 6e4));
|
|
84
|
+
if (r < 60) return `${r} min`;
|
|
85
|
+
let i = Math.floor(r / 60);
|
|
86
|
+
return i < 24 ? `${i} h ${String(r % 60).padStart(2, "0")} min` : `${Math.floor(i / 24)} d`;
|
|
87
|
+
}
|
|
88
|
+
export { e as APPROVAL_SCOPES, s as FIXED_DEFAULT_LABELS, n as RULE_SCOPE_DAYS, m as argumentLines, a as availableScopes, d as countBySource, u as decisionNeedsNote, o as defaultScope, c as fixedDefaultLabel, i as isNonWaivable, r as isRuleScope, l as shortHash, h as stewardOptions, g as timeLeft };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=stewardApprovals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stewardApprovals.js","names":["APPROVAL_SCOPES","RULE_SCOPES","RULE_SCOPE_DAYS","isRuleScope","scope","isNonWaivable","subject","availableScopes","defaultScope","requested","FIXED_DEFAULT_LABELS","fixedDefaultLabel","kind","shortHash","hash","decisionNeedsNote","decision","note","countBySource","steward","rows","row","MAX_ARGUMENT_CHARS","argumentValue","value","text","argumentLines","args","key","stewardOptions","seen","id","label","timeLeft","ms","expiresAt","now","minutes","hours"],"sources":["../../../src/botlit/utils/stewardApprovals.ts"],"sourcesContent":["/**\n * Steward approval helpers (BOFF-16146 C3.3)\n * @module botlit/utils\n *\n * Pure logic behind the Steward side of the approvals inbox: which approval\n * scopes a reviewer may be offered for a request, how scopes read in plain\n * words, and which fixed defaults can never become a standing rule. The service\n * enforces every one of these rules again in `decideBotmanorToolApproval`; the\n * UI only avoids offering a choice the service would refuse.\n */\n\nexport type ApprovalScope = 'ONCE' | 'RUN' | 'DUTY' | 'TIME_LIMITED' | 'STANDING';\n\n/** Scopes in the order a reviewer sees them, narrowest first. */\nexport const APPROVAL_SCOPES: readonly ApprovalScope[] = [\n 'ONCE',\n 'RUN',\n 'DUTY',\n 'TIME_LIMITED',\n 'STANDING',\n];\n\n/** Scopes that create a standing approval rule instead of covering one run. */\nconst RULE_SCOPES: ReadonlySet<ApprovalScope> = new Set(['DUTY', 'TIME_LIMITED', 'STANDING']);\n\n/** Days a rule created by a scope lasts (the service sets these). */\nexport const RULE_SCOPE_DAYS: Readonly<Partial<Record<ApprovalScope, number>>> = {\n TIME_LIMITED: 7,\n STANDING: 90,\n};\n\n/** Fixed defaults: calls that always go to a person. */\nexport const FIXED_DEFAULT_KINDS = [\n 'password-change',\n 'security-setting-change',\n 'payment-entry',\n 'read-one-time-code',\n 'external-message',\n] as const;\n\nexport interface ScopeSubject {\n /** `STEWARD` for a steward's call, `AGENT_CHAT` for a chat agent's. */\n source?: string | null;\n fixedDefault?: string | null;\n purpose?: string | null;\n riskLevel?: string | null;\n}\n\nexport function isRuleScope(scope: ApprovalScope): boolean {\n return RULE_SCOPES.has(scope);\n}\n\n/**\n * True when the call is a fixed default that can never be waived by a rule.\n * An external message that names a purpose is the one exception: the owner can\n * grant a rule that names that exact recipient and purpose.\n */\nexport function isNonWaivable(subject: ScopeSubject): boolean {\n if (!subject.fixedDefault) return false;\n if (subject.fixedDefault === 'external-message') return !subject.purpose?.trim();\n return true;\n}\n\n/**\n * The scopes a reviewer may pick for a request. Chat-agent requests have no\n * scope at all (an empty list). Non-waivable fixed defaults offer ONCE and RUN\n * only, never a duty, time-limited or standing rule. STANDING is withheld from\n * HIGH-risk (destructive) calls, as the service refuses it there.\n */\nexport function availableScopes(subject: ScopeSubject): ApprovalScope[] {\n if (subject.source !== 'STEWARD') return [];\n if (subject.fixedDefault && isNonWaivable(subject)) {\n return APPROVAL_SCOPES.filter((scope) => !isRuleScope(scope));\n }\n return APPROVAL_SCOPES.filter((scope) => !(scope === 'STANDING' && subject.riskLevel === 'HIGH'));\n}\n\n/** The scope to preselect: what the steward asked for when it is still allowed, else ONCE. */\nexport function defaultScope(subject: ScopeSubject, requested?: string | null): ApprovalScope {\n const allowed = availableScopes(subject);\n const match = allowed.find((scope) => scope === requested);\n return match ?? 'ONCE';\n}\n\n/** Human readable fixed-default names; the key is the service's `fixedDefault` value. */\nexport const FIXED_DEFAULT_LABELS: Readonly<Record<string, string>> = {\n 'password-change': 'Password change',\n 'security-setting-change': 'Security setting change',\n 'payment-entry': 'Payment entry',\n 'read-one-time-code': 'One-time code read',\n 'external-message': 'Message outside the workspace',\n};\n\nexport function fixedDefaultLabel(kind: string): string {\n return FIXED_DEFAULT_LABELS[kind] ?? kind;\n}\n\n/** Short sha256 prefix for display, e.g. `sha256:3be1a07c…`. */\nexport function shortHash(hash?: string | null): string | null {\n if (!hash) return null;\n return `sha256:${hash.slice(0, 8)}…`;\n}\n\n/** The note a DENY decision needs; approving needs none. */\nexport function decisionNeedsNote(decision: 'APPROVE' | 'DENY', note: string): boolean {\n return decision === 'DENY' && note.trim().length === 0;\n}\n\nexport interface SourceCounts {\n all: number;\n agentChat: number;\n steward: number;\n}\n\nexport function countBySource(rows: ReadonlyArray<{ source?: string | null }>): SourceCounts {\n const steward = rows.filter((row) => row.source === 'STEWARD').length;\n return { all: rows.length, steward, agentChat: rows.length - steward };\n}\n\nexport interface ArgumentLine {\n key: string;\n value: string;\n}\n\nconst MAX_ARGUMENT_CHARS = 160;\n\nfunction argumentValue(value: unknown): string {\n if (typeof value === 'string') {\n return value.length > MAX_ARGUMENT_CHARS\n ? `${value.slice(0, MAX_ARGUMENT_CHARS)}… (${value.length} chars)`\n : value;\n }\n try {\n const text = JSON.stringify(value);\n if (text === undefined) return String(value);\n return text.length > MAX_ARGUMENT_CHARS\n ? `${text.slice(0, MAX_ARGUMENT_CHARS)}… (${text.length} chars)`\n : text;\n } catch {\n return String(value);\n }\n}\n\n/**\n * The call's arguments as `key: value` lines for the preview. Long values are\n * cut with their length shown, so a reviewer sees the shape without a wall of\n * text. The text is always rendered as text, never as markup.\n */\nexport function argumentLines(args: unknown): ArgumentLine[] {\n if (args === null || typeof args !== 'object' || Array.isArray(args)) {\n return args === undefined || args === null\n ? []\n : [{ key: 'arguments', value: argumentValue(args) }];\n }\n return Object.entries(args as Record<string, unknown>).map(([key, value]) => ({\n key,\n value: argumentValue(value),\n }));\n}\n\n/** Distinct stewards among the rows, for the steward filter (agent name labels them). */\nexport function stewardOptions(\n rows: ReadonlyArray<{\n source?: string | null;\n stewardId?: string | null;\n agentName?: string | null;\n agentId: string;\n }>\n): Array<{ id: string; label: string }> {\n const seen = new Map<string, string>();\n for (const row of rows) {\n if (row.source !== 'STEWARD' || !row.stewardId || seen.has(row.stewardId)) continue;\n seen.set(row.stewardId, row.agentName ?? row.agentId);\n }\n return [...seen].map(([id, label]) => ({ id, label }));\n}\n\n/**\n * Time left until a request expires, in the compact form the inbox shows:\n * `41 min`, `2 h 05 min`, `3 d`. Returns `expired` once the time has passed.\n */\nexport function timeLeft(expiresAt: string, now: number = Date.now()): string {\n const ms = new Date(expiresAt).getTime() - now;\n if (Number.isNaN(ms)) return '';\n if (ms <= 0) return 'expired';\n const minutes = Math.max(1, Math.round(ms / 60_000));\n if (minutes < 60) return `${minutes} min`;\n const hours = Math.floor(minutes / 60);\n if (hours < 24) return `${hours} h ${String(minutes % 60).padStart(2, '0')} min`;\n return `${Math.floor(hours / 24)} d`;\n}\n"],"mappings":";AAcA,IAAaA,IAA4C;CACvD;CACA;CACA;CACA;CACA;AACF,GAGMC,oBAA0C,IAAI,IAAI;CAAC;CAAQ;CAAgB;AAAU,CAAC,GAG/EC,IAAoE;CAC/E,cAAc;CACd,UAAU;AACZ;AAmBA,SAAgBC,EAAY,GAA+B;CACzD,OAAOF,EAAY,IAAIG,CAAK;AAC9B;AAOA,SAAgBC,EAAc,GAAgC;CAG5D,OAFKC,EAAQ,eACTA,EAAQ,iBAAiB,sBAA2B,CAACA,EAAQ,SAAS,KAAK,IAD7C;AAGpC;AAQA,SAAgBC,EAAgB,GAAwC;CAKtE,OAJID,EAAQ,WAAW,YACnBA,EAAQ,gBAAgBD,EAAcC,CAAO,IACxCN,EAAgB,QAAQ,MAAU,CAACG,EAAYC,CAAK,CAAC,IAEvDJ,EAAgB,QAAQ,MAAYI,MAAU,cAAcE,EAAQ,cAAc,MAAO,IAJvD,CAAC;AAK5C;AAGA,SAAgBE,EAAa,GAAuB,GAA0C;CAG5F,OAFgBD,EAAgBD,CAClB,CAAA,CAAQ,MAAM,MAAUF,MAAUK,CACzC,KAAS;AAClB;AAGA,IAAaC,IAAyD;CACpE,mBAAmB;CACnB,2BAA2B;CAC3B,iBAAiB;CACjB,sBAAsB;CACtB,oBAAoB;AACtB;AAEA,SAAgBC,EAAkB,GAAsB;CACtD,OAAOD,EAAqBE,MAASA;AACvC;AAGA,SAAgBC,EAAU,GAAqC;CAE7D,OADKC,IACE,UAAUA,EAAK,MAAM,GAAG,CAAC,EAAE,KADhB;AAEpB;AAGA,SAAgBC,EAAkB,GAA8B,GAAuB;CACrF,OAAOC,MAAa,UAAUC,EAAK,KAAK,CAAC,CAAC,WAAW;AACvD;AAQA,SAAgBC,EAAc,GAA+D;CAC3F,IAAMC,IAAUC,EAAK,QAAQ,MAAQC,EAAI,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