@paperclipai/server 2026.905.0-canary.0 → 2026.905.0-canary.2
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/build-info.json +1 -1
- package/package.json +18 -18
- package/ui-dist/assets/{AgentDetail.production-D1A0R30C.js → AgentDetail.production-D79ivlSm.js} +1 -1
- package/ui-dist/assets/{Agents.production-Cr0iViym.js → Agents.production-Z1rvhPxq.js} +2 -2
- package/ui-dist/assets/{AuditFeed.production-aTPg8e1s.js → AuditFeed.production-BIggihG-.js} +1 -1
- package/ui-dist/assets/{CompanyActivity.production-C1_BRsKo.js → CompanyActivity.production-Cj2ImXXT.js} +1 -1
- package/ui-dist/assets/{CompanyExport-DvDHxiuO.js → CompanyExport-BoRNWNgK.js} +1 -1
- package/ui-dist/assets/{CompanySkills.production-Fq7UjewY.js → CompanySkills.production-DB3F_EDs.js} +1 -1
- package/ui-dist/assets/{Costs.production-nkSPholQ.js → Costs.production-BIY-LGbP.js} +1 -1
- package/ui-dist/assets/{OrgChart.production-BclAMg73.js → OrgChart.production-CZzd85mu.js} +1 -1
- package/ui-dist/assets/{RoutineDetail.production-CG0CUU_u.js → RoutineDetail.production-DSQlyo0h.js} +1 -1
- package/ui-dist/assets/{Routines.production-CtQuJd4_.js → Routines.production-ozoJQ7Tk.js} +1 -1
- package/ui-dist/assets/{index-wPK2Q9gC.js → index-BaG1tZj1.js} +125 -125
- package/ui-dist/assets/index-D3zUW2Jn.css +1 -0
- package/ui-dist/index.html +2 -2
- package/ui-dist/sw.js +1 -1
- package/ui-dist/assets/index-Ckxx5vDE.css +0 -1
package/dist/build-info.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paperclipai/server",
|
|
3
|
-
"version": "2026.905.0-canary.
|
|
3
|
+
"version": "2026.905.0-canary.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://github.com/paperclipai/paperclip",
|
|
6
6
|
"bugs": {
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@aws-sdk/client-s3": "^3.1122.0",
|
|
40
40
|
"@opentelemetry/api": "^1.9.0",
|
|
41
|
-
"@paperclipai/adapter-claude-local": "2026.905.0-canary.
|
|
42
|
-
"@paperclipai/adapter-codex-local": "2026.905.0-canary.
|
|
43
|
-
"@paperclipai/adapter-cursor-cloud": "2026.905.0-canary.
|
|
44
|
-
"@paperclipai/adapter-cursor-local": "2026.905.0-canary.
|
|
45
|
-
"@paperclipai/adapter-gemini-local": "2026.905.0-canary.
|
|
46
|
-
"@paperclipai/adapter-grok-local": "2026.905.0-canary.
|
|
47
|
-
"@paperclipai/adapter-kimi-local": "2026.905.0-canary.
|
|
48
|
-
"@paperclipai/adapter-openclaw-gateway": "2026.905.0-canary.
|
|
49
|
-
"@paperclipai/adapter-opencode-local": "2026.905.0-canary.
|
|
50
|
-
"@paperclipai/adapter-pi-local": "2026.905.0-canary.
|
|
51
|
-
"@paperclipai/adapter-utils": "2026.905.0-canary.
|
|
52
|
-
"@paperclipai/db": "2026.905.0-canary.
|
|
53
|
-
"@paperclipai/hermes-paperclip-adapter": "2026.905.0-canary.
|
|
54
|
-
"@paperclipai/plugin-sdk": "2026.905.0-canary.
|
|
55
|
-
"@paperclipai/shared": "2026.905.0-canary.
|
|
56
|
-
"@paperclipai/skills-catalog": "2026.905.0-canary.
|
|
41
|
+
"@paperclipai/adapter-claude-local": "2026.905.0-canary.2",
|
|
42
|
+
"@paperclipai/adapter-codex-local": "2026.905.0-canary.2",
|
|
43
|
+
"@paperclipai/adapter-cursor-cloud": "2026.905.0-canary.2",
|
|
44
|
+
"@paperclipai/adapter-cursor-local": "2026.905.0-canary.2",
|
|
45
|
+
"@paperclipai/adapter-gemini-local": "2026.905.0-canary.2",
|
|
46
|
+
"@paperclipai/adapter-grok-local": "2026.905.0-canary.2",
|
|
47
|
+
"@paperclipai/adapter-kimi-local": "2026.905.0-canary.2",
|
|
48
|
+
"@paperclipai/adapter-openclaw-gateway": "2026.905.0-canary.2",
|
|
49
|
+
"@paperclipai/adapter-opencode-local": "2026.905.0-canary.2",
|
|
50
|
+
"@paperclipai/adapter-pi-local": "2026.905.0-canary.2",
|
|
51
|
+
"@paperclipai/adapter-utils": "2026.905.0-canary.2",
|
|
52
|
+
"@paperclipai/db": "2026.905.0-canary.2",
|
|
53
|
+
"@paperclipai/hermes-paperclip-adapter": "2026.905.0-canary.2",
|
|
54
|
+
"@paperclipai/plugin-sdk": "2026.905.0-canary.2",
|
|
55
|
+
"@paperclipai/shared": "2026.905.0-canary.2",
|
|
56
|
+
"@paperclipai/skills-catalog": "2026.905.0-canary.2",
|
|
57
57
|
"@vercel/connect": "0.6.1",
|
|
58
58
|
"acpx": "0.13.1",
|
|
59
59
|
"ajv": "^8.20.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"acpx"
|
|
82
82
|
],
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@paperclipai/paperclip-runner": "2026.905.0-canary.
|
|
84
|
+
"@paperclipai/paperclip-runner": "2026.905.0-canary.2",
|
|
85
85
|
"@types/express": "^5.0.0",
|
|
86
86
|
"@types/express-serve-static-core": "^5.1.3",
|
|
87
87
|
"@types/jsdom": "^30.0.0",
|
package/ui-dist/assets/{AgentDetail.production-D1A0R30C.js → AgentDetail.production-D79ivlSm.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as St}from"./rolldown-runtime-BQ-vy_Pv.js";import{An as Y,B as Ut,E as Ge,M as Ee,S as ce,T as Wt,Tn as Ct,U as At,fr as Vt,g as lt,jn as H,lr as Me,q as f,ur as Jt,vt as Gt,z as Ke}from"./createLucideIcon-JUO5qdpL.js";import{B as dt,o as et,r as Yt,rt as Xt,st as ct,t as Fe}from"./router-Dr6qx_6q.js";import{T as Zt,d as es,h as ts,o as ss,s as ns,w as rs,x as as}from"./IssueRecoveryActionCard-i5qDYsKa.js";import{_ as Et,v as It,y as Rt}from"./recovery-display-DKT_Bqf8.js";import{f as Qe,h as He,m as is,p as Ue}from"./checkbox-Bhf00Qhn.js";import{a as nt}from"./label-IDJ0nBXZ.js";import{o as os,t as ls}from"./MarkdownEditor-dns9I8bB.js";import{t as ds}from"./tabs-B-hJilg9.js";import{F as cs,N as us,Q as ms,at as xs,it as fs,j as hs,rt as gs,ut as ps}from"./proposal-review-DinROeYt.js";import{g as bs,v as Ye,y as ys}from"./StatusIcon-CeMClGJ9.js";import{p as vs,t as $e}from"./CopyText-CuFpZ9d_.js";import{n as js,r as Ns,s as Ft}from"./BreadcrumbContext-D3CAiFzt.js";import{t as ws}from"./chevron-down-CqCCAew2.js";import{t as tt}from"./chevron-right-BFXkqip_.js";import{i as rt,t as ks}from"./InlineBanner-C4MQkh4l.js";import{A as Ss,t as $}from"./button-DWgQnsK-.js";import{a as Cs}from"./agent-icons-DvoCe7FN.js";import{n as As,r as Ve,t as Es}from"./clipboard-BCz9EG42.js";import{t as Is}from"./MarkdownBody-CGVDfzLB.js";import{n as Rs}from"./key-round-gDAuHlTR.js";import{t as X}from"./agents-yMBk3d4f.js";import{t as ke}from"./heartbeats-DfIQjGVE.js";import{t as gt}from"./rotate-ccw-Cb9U93yr.js";import{t as pt}from"./triangle-alert-DEq939Ib.js";import{t as ut}from"./badge-CxX1YhiF.js";import{i as Tt}from"./ToastContext-Dmfqh1in.js";import{t as Je}from"./input-DjyO-oZf.js";import{n as Fs,t as Ts}from"./AgentIconPicker-B6761LdM.js";import{i as Xe}from"./StatusBadge-DJIFeD5T.js";import{n as ye,t as Ps}from"./PageSkeleton-DYqd8XzH.js";import{$n as Ls,An as _s,At as qs,Bt as Ks,Ct as bt,Dt as Ms,Et as Ds,Ft as Bs,Gt as $s,Hn as Os,Ht as zs,In as Qs,Jn as _e,Jt as at,Kn as Pt,Kt as Hs,Mn as Us,Mt as Ws,Nn as Vs,Pt as Js,Qn as Gs,Qt as Ys,Rn as Xs,St as Zs,Tt as Be,Un as en,Ut as tn,Vn as sn,Wn as nn,Wt as rn,Yn as mt,Yt as an,Zt as on,bt as ln,hr as dn,in as cn,jt as Lt,kt as un,rn as mn,vt as xn,wt as it,xt as fn,yt,zt as hn}from"./index-
|
|
1
|
+
import{i as St}from"./rolldown-runtime-BQ-vy_Pv.js";import{An as Y,B as Ut,E as Ge,M as Ee,S as ce,T as Wt,Tn as Ct,U as At,fr as Vt,g as lt,jn as H,lr as Me,q as f,ur as Jt,vt as Gt,z as Ke}from"./createLucideIcon-JUO5qdpL.js";import{B as dt,o as et,r as Yt,rt as Xt,st as ct,t as Fe}from"./router-Dr6qx_6q.js";import{T as Zt,d as es,h as ts,o as ss,s as ns,w as rs,x as as}from"./IssueRecoveryActionCard-i5qDYsKa.js";import{_ as Et,v as It,y as Rt}from"./recovery-display-DKT_Bqf8.js";import{f as Qe,h as He,m as is,p as Ue}from"./checkbox-Bhf00Qhn.js";import{a as nt}from"./label-IDJ0nBXZ.js";import{o as os,t as ls}from"./MarkdownEditor-dns9I8bB.js";import{t as ds}from"./tabs-B-hJilg9.js";import{F as cs,N as us,Q as ms,at as xs,it as fs,j as hs,rt as gs,ut as ps}from"./proposal-review-DinROeYt.js";import{g as bs,v as Ye,y as ys}from"./StatusIcon-CeMClGJ9.js";import{p as vs,t as $e}from"./CopyText-CuFpZ9d_.js";import{n as js,r as Ns,s as Ft}from"./BreadcrumbContext-D3CAiFzt.js";import{t as ws}from"./chevron-down-CqCCAew2.js";import{t as tt}from"./chevron-right-BFXkqip_.js";import{i as rt,t as ks}from"./InlineBanner-C4MQkh4l.js";import{A as Ss,t as $}from"./button-DWgQnsK-.js";import{a as Cs}from"./agent-icons-DvoCe7FN.js";import{n as As,r as Ve,t as Es}from"./clipboard-BCz9EG42.js";import{t as Is}from"./MarkdownBody-CGVDfzLB.js";import{n as Rs}from"./key-round-gDAuHlTR.js";import{t as X}from"./agents-yMBk3d4f.js";import{t as ke}from"./heartbeats-DfIQjGVE.js";import{t as gt}from"./rotate-ccw-Cb9U93yr.js";import{t as pt}from"./triangle-alert-DEq939Ib.js";import{t as ut}from"./badge-CxX1YhiF.js";import{i as Tt}from"./ToastContext-Dmfqh1in.js";import{t as Je}from"./input-DjyO-oZf.js";import{n as Fs,t as Ts}from"./AgentIconPicker-B6761LdM.js";import{i as Xe}from"./StatusBadge-DJIFeD5T.js";import{n as ye,t as Ps}from"./PageSkeleton-DYqd8XzH.js";import{$n as Ls,An as _s,At as qs,Bt as Ks,Ct as bt,Dt as Ms,Et as Ds,Ft as Bs,Gt as $s,Hn as Os,Ht as zs,In as Qs,Jn as _e,Jt as at,Kn as Pt,Kt as Hs,Mn as Us,Mt as Ws,Nn as Vs,Pt as Js,Qn as Gs,Qt as Ys,Rn as Xs,St as Zs,Tt as Be,Un as en,Ut as tn,Vn as sn,Wn as nn,Wt as rn,Yn as mt,Yt as an,Zt as on,bt as ln,hr as dn,in as cn,jt as Lt,kt as un,rn as mn,vt as xn,wt as it,xt as fn,yt,zt as hn}from"./index-BaG1tZj1.js";import{t as gn}from"./AuditFeed.production-BIggihG-.js";var i=St(Vt(),1),e=St(Jt(),1),_t={succeeded:{icon:Ft,color:"text-green-600 dark:text-green-400"},failed:{icon:ys,color:"text-red-600 dark:text-red-400"},running:{icon:As,color:"text-blue-600 dark:text-blue-400"},queued:{icon:Ye,color:"text-yellow-600 dark:text-yellow-400"},scheduled_retry:{icon:Ye,color:"text-sky-600 dark:text-sky-400"},timed_out:{icon:Gs,color:"text-orange-600 dark:text-orange-400"},cancelled:{icon:Ls,color:"text-neutral-500 dark:text-neutral-400"}},vt=256e3,qt="***REDACTED***",pn=/(api[-_]?key|access[-_]?token|auth(?:_?token)?|authorization|bearer|secret|passwd|password|credential|jwt|private[-_]?key|cookie|connectionstring)/i,bn=/(^command$|^cmd$|command[-_]?line|resolved[-_]?command|PAPERCLIP_RESOLVED_COMMAND)/i,yn=/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/;function vn(t){return t.orgChainHealth?.fullChain.map(s=>`${s.name}${s.status!=="active"&&s.status!=="idle"?` (${s.status})`:""}`).join(" -> ")??t.name}function je(t,s){return fs(t,{enabled:s})}function qe(t,s){return xs(t,{enabled:s})}function Kt(t,s){return je(gs(t,qt),s)}function jn(t,s){return pn.test(t)?!0:typeof s!="string"?!1:yn.test(s)}function Nn(t,s,r){if(typeof s=="object"&&s!==null&&!Array.isArray(s)&&s.type==="secret_ref")return"***SECRET_REF***";if(jn(t,s))return qt;if(s==null)return"";if(typeof s=="string"&&bn.test(t))return Kt(s,r);if(typeof s=="string")return je(s,r);try{return JSON.stringify(qe(s,r))}catch{return je(String(s),r)}}function wn(t){return t.toLowerCase().endsWith(".md")}function kn(t){const s=t.detail?.markdown??t.summary?.markdown;return typeof s=="boolean"?s:wn(t.selectedPath)}function Sn(t,s){const r=Te(t);if(!r)return"<unable-to-parse>";const l=Object.keys(r);return l.length===0?"<empty>":l.sort().map(c=>`${c}=${Nn(c,r[c],s)}`).join(`
|
|
2
2
|
`)}var Mt={timer:"Timer",assignment:"Assignment",on_demand:"On-demand",automation:"Automation"},jt=32;function Dt(t){return t===window}function Cn(t){const s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"||s==="overlay"}function An(t){let s=t?.parentElement??null;for(;s;){if(Cn(s))return s;s=s.parentElement}return window}function We(t){if(Dt(t)){const r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),l=window.scrollY+window.innerHeight;return{scrollHeight:r,distanceFromBottom:Math.max(0,r-l)}}const s=t.scrollTop+t.clientHeight;return{scrollHeight:t.scrollHeight,distanceFromBottom:Math.max(0,t.scrollHeight-s)}}function Nt(t,s="auto"){if(Dt(t)){const r=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);window.scrollTo({top:r,behavior:s});return}t.scrollTo({top:t.scrollHeight,behavior:s})}var En=[{value:"dashboard",label:"Dashboard"},{value:"instructions",label:"Instructions"},{value:"skills",label:"Skills"},{value:"configuration",label:"Configuration"},{value:"secrets",label:"Secrets"},{value:"tools",label:"Tools"},{value:"runs",label:"Runs"},{value:"audit",label:"Audit"},{value:"budget",label:"Budget"}];function In(t,s=r=>typeof window>"u"||window.confirm(r)){return!t||s("Discard unsaved agent configuration changes?")}function Rn(t,s){if(typeof t!="number"||typeof s!="number")return null;const r=t-s;return r===0?null:r}function Fn(t,s,r){const l=Rn(s.index,r);return l===null?(t.pushState(s.state,"",s.url),!1):(t.go(l),!0)}function Tn(t){return t==="instructions"||t==="prompts"?"instructions":t==="configure"||t==="configuration"?"configuration":t==="secrets"?"secrets":t==="skills"?"skills":t==="tools"?"tools":t==="budget"?"budget":t==="audit"?"audit":t==="runs"?t:"dashboard"}function ot(t,...s){if(!t)return 0;for(const r of s){const l=t[r];if(typeof l=="number"&&Number.isFinite(l))return l}return 0}function Pn(t,s){if(t.size!==s.size)return!1;for(const r of t)if(!s.has(r))return!1;return!0}function Ze(t){const s=t.usageJson??null,r=t.resultJson??null,l=ot(s,"inputTokens","input_tokens"),c=ot(s,"outputTokens","output_tokens"),g=ot(s,"cachedInputTokens","cached_input_tokens","cache_read_input_tokens"),p=Ut(s,r),n=L(s?.provider)??null,b=L(s?.model)??null;return{input:l,output:c,cached:g,cost:p,totalTokens:l+c,provider:n,model:b}}function Te(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function L(t){if(typeof t!="string")return null;const s=t.trim();return s.length>0?s:null}function Ln(t,s){const r=L(t.message);if(!r)return null;const l=L(t.phase);return{ts:L(t.updatedAt)??s,stream:"system",chunk:l?`[${l}] ${r}`:r}}function _n(t){return`${t.ts}\0${t.stream}\0${t.chunk}`}function qn(t){return t==="running"}function Kn(t){return t==="queued"?5e3:t==="running"?15e3:!1}function Mn({payload:t,censorUsernameInLogs:s}){const r=[typeof t.command=="string"?t.command:null,...Array.isArray(t.commandArgs)?t.commandArgs.filter(g=>typeof g=="string"):[]].filter(g=>!!g).join(" "),l=r?Kt(r,s):"",c=l.length>0||Array.isArray(t.commandNotes)&&t.commandNotes.length>0||t.prompt!==void 0||t.context!==void 0||t.env!==void 0;return(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-background/60 p-3 space-y-2",children:[(0,e.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Invocation"}),typeof t.adapterType=="string"&&(0,e.jsxs)("div",{className:"text-xs",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Adapter: "}),t.adapterType]}),typeof t.cwd=="string"&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Working dir: "}),(0,e.jsx)("span",{className:"font-mono",children:t.cwd})]}),c&&(0,e.jsxs)(Et,{children:[(0,e.jsxs)(Rt,{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors group",children:[(0,e.jsx)(tt,{className:"h-3 w-3 transition-transform group-data-[state=open]:rotate-90"}),"Details"]}),(0,e.jsxs)(It,{className:"pt-2 space-y-2",children:[l&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Command: "}),(0,e.jsx)("span",{className:"font-mono",children:l})]}),Array.isArray(t.commandNotes)&&t.commandNotes.length>0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Command notes"}),(0,e.jsx)("ul",{className:"list-disc pl-5 space-y-1",children:t.commandNotes.filter(g=>typeof g=="string"&&g.trim().length>0).map((g,p)=>(0,e.jsx)("li",{className:"text-xs break-all font-mono",children:g},`${p}-${g}`))})]}),t.prompt!==void 0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Prompt"}),(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap",children:typeof t.prompt=="string"?je(t.prompt,s):JSON.stringify(qe(t.prompt,s),null,2)})]}),t.context!==void 0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Context"}),(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap",children:JSON.stringify(qe(t.context,s),null,2)})]}),t.env!==void 0&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Environment"}),(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-2 text-xs overflow-x-auto whitespace-pre-wrap font-mono",children:Sn(t.env,s)})]})]})]})]})}function Dn(t){const s=[];for(const r of t.split(`
|
|
3
3
|
`)){const l=r.trim();if(l)try{const c=JSON.parse(l),g=c.stream==="stderr"||c.stream==="system"?c.stream:"stdout",p=typeof c.chunk=="string"?c.chunk:"",n=typeof c.ts=="string"?c.ts:new Date().toISOString();if(!p)continue;s.push({ts:n,stream:g,chunk:p})}catch{}}return s}function Bn(t){switch(t){case"worktree_prepare":return"Worktree setup";case"workspace_config_freshness":return"Config freshness";case"workspace_provision":return"Provision";case"workspace_teardown":return"Teardown";case"worktree_cleanup":return"Worktree cleanup";default:return t}}function $n(t){switch(t){case"succeeded":return"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-300";case"failed":return"border-red-500/20 bg-red-500/10 text-red-700 dark:text-red-300";case"running":return"border-blue-500/20 bg-blue-500/10 text-blue-700 dark:text-blue-300";case"skipped":return"border-yellow-500/20 bg-yellow-500/10 text-yellow-700 dark:text-yellow-300";default:return"border-border bg-muted/40 text-muted-foreground"}}function On({status:t}){return(0,e.jsx)(ut,{variant:"outline",className:ce("text-(length:--text-micro) capitalize",$n(t)),children:t.replace("_"," ")})}function zn({operation:t,censorUsernameInLogs:s}){const[r,l]=(0,i.useState)(!1),{data:c,isLoading:g,error:p}=H({queryKey:["workspace-operation-log",t.id],queryFn:()=>ke.workspaceOperationLog(t.id),enabled:r&&!!t.logRef,refetchInterval:r&&t.status==="running"?2e3:!1}),n=(0,i.useMemo)(()=>c?.content?Dn(c.content):[],[c?.content]);return(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("button",{type:"button",className:"text-(length:--text-micro) text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:()=>l(b=>!b),children:r?"Hide full log":"Show full log"}),r&&(0,e.jsxs)("div",{className:"rounded-md border border-border bg-background/70 p-2",children:[g&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Loading log..."}),p&&(0,e.jsx)("div",{className:"text-xs text-destructive",children:p instanceof Error?p.message:"Failed to load workspace operation log"}),!g&&!p&&n.length===0&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"No persisted log lines."}),n.length>0&&(0,e.jsx)("div",{className:"max-h-64 overflow-y-auto rounded bg-neutral-100 p-2 font-mono text-xs dark:bg-neutral-950",children:n.map((b,y)=>(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)("span",{className:"shrink-0 text-neutral-500",children:new Date(b.ts).toLocaleTimeString("en-US",{hour12:!1})}),(0,e.jsxs)("span",{className:ce("shrink-0 w-14",b.stream==="stderr"?"text-red-600 dark:text-red-300":b.stream==="system"?"text-blue-600 dark:text-blue-300":"text-muted-foreground"),children:["[",b.stream,"]"]}),(0,e.jsx)("span",{className:"whitespace-pre-wrap break-all",children:je(b.chunk,s)})]},`${b.ts}-${y}`))})]})]})}function Qn({operations:t,censorUsernameInLogs:s}){return t.length===0?null:(0,e.jsxs)("div",{className:"rounded-lg border border-border bg-background/60 p-3 space-y-3",children:[(0,e.jsxs)("div",{className:"text-xs font-medium text-muted-foreground",children:["Workspace (",t.length,")"]}),(0,e.jsx)("div",{className:"space-y-3",children:t.map(r=>{const l=Te(r.metadata);return(0,e.jsxs)("div",{className:"rounded-md border border-border/70 bg-background/70 p-3 space-y-2",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("div",{className:"text-sm font-medium",children:Bn(r.phase)}),(0,e.jsx)(On,{status:r.status}),(0,e.jsxs)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:[Ke(r.startedAt),r.finishedAt&&` to ${Ke(r.finishedAt)}`]})]}),r.command&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Command: "}),(0,e.jsx)("span",{className:"font-mono",children:r.command})]}),r.cwd&&(0,e.jsxs)("div",{className:"text-xs break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Working dir: "}),(0,e.jsx)("span",{className:"font-mono",children:r.cwd})]}),(L(l?.branchName)||L(l?.baseRef)||L(l?.worktreePath)||L(l?.repoRoot)||L(l?.cleanupAction))&&(0,e.jsxs)("div",{className:"grid gap-1 text-xs sm:grid-cols-2",children:[L(l?.branchName)&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Branch: "}),(0,e.jsx)("span",{className:"font-mono",children:l?.branchName})]}),L(l?.baseRef)&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Base ref: "}),(0,e.jsx)("span",{className:"font-mono",children:l?.baseRef})]}),L(l?.worktreePath)&&(0,e.jsxs)("div",{className:"break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Worktree: "}),(0,e.jsx)("span",{className:"font-mono",children:l?.worktreePath})]}),L(l?.repoRoot)&&(0,e.jsxs)("div",{className:"break-all",children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Repo root: "}),(0,e.jsx)("span",{className:"font-mono",children:l?.repoRoot})]}),L(l?.cleanupAction)&&(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:"Cleanup: "}),(0,e.jsx)("span",{className:"font-mono",children:l?.cleanupAction})]})]}),typeof l?.created=="boolean"&&(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:l.created?"Created by this run":"Reused existing workspace"}),r.stderrExcerpt&&r.stderrExcerpt.trim()&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-1 text-xs text-red-700 dark:text-red-300",children:"stderr excerpt"}),(0,e.jsx)("pre",{className:"rounded-md bg-red-50 p-2 text-xs whitespace-pre-wrap break-all text-red-800 dark:bg-neutral-950 dark:text-red-100",children:je(r.stderrExcerpt,s)})]}),r.stdoutExcerpt&&r.stdoutExcerpt.trim()&&(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"mb-1 text-xs text-muted-foreground",children:"stdout excerpt"}),(0,e.jsx)("pre",{className:"rounded-md bg-neutral-100 p-2 text-xs whitespace-pre-wrap break-all dark:bg-neutral-950",children:je(r.stdoutExcerpt,s)})]}),r.logRef&&(0,e.jsx)(zn,{operation:r,censorUsernameInLogs:s})]},r.id)})})]})}function _r(){const{companyPrefix:t,agentId:s,tab:r,runId:l}=ct(),{companies:c,selectedCompanyId:g,setSelectedCompanyId:p}=At(),{closePanel:n}=Us(),{setBreadcrumbs:b}=js(),y=Me(),C=et(),[E,F]=(0,i.useState)(null),[O,I]=(0,i.useState)(()=>new Set),m=l?"runs":Tn(r??null),P=m==="dashboard",z=P||m==="runs"||!!l,[M,v]=(0,i.useState)(!1),[V,oe]=(0,i.useState)(!1),te=(0,i.useRef)(null),re=(0,i.useRef)(null),{isMobile:ee}=mt(),k=s??"",J=(0,i.useMemo)(()=>{if(!t)return null;const o=t.toUpperCase();return c.find(K=>K.issuePrefix.toUpperCase()===o)?.id??null},[c,t])??g??void 0,se=k.length>0&&(Gt(k)||!!J),G=(0,i.useCallback)(o=>{te.current=o},[]),ae=(0,i.useCallback)(o=>{re.current=o},[]),T=(0,i.useCallback)(()=>In(M),[M]),{data:a,isLoading:ge,error:ie}=H({queryKey:[...f.agents.detail(k),J??null],queryFn:()=>X.get(k,J),enabled:se}),h=a?.companyId??g,j=a?lt(a):k,Q=a?.id??k,R=a?.id??null,U=nn(h),d=en(h),w=R?Os(U.data,"agent",R):"joined",{data:B}=H({queryKey:f.instance.experimentalSettings,queryFn:()=>Pt.getExperimental(),enabled:!!h}),fe=B?.enableBuiltInAgents===!0,{data:ue}=H({queryKey:f.builtInAgents.list(h),queryFn:()=>_e.list(h),enabled:!!h&&fe}),D=fe?ue?.find(o=>o.agentId===R)??null:null,Se=D?D.definition.featureKeys.map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(", "):"",_=(0,i.useCallback)(()=>{y.invalidateQueries({queryKey:f.builtInAgents.list(h)}),R&&y.invalidateQueries({queryKey:f.agents.detail(R)}),y.invalidateQueries({queryKey:f.agents.detail(k)})},[y,h,R,k]),he=Y({mutationFn:()=>_e.reset(h,D.definition.key),onSuccess:_}),[x,A]=(0,i.useState)(!1),S=Y({mutationFn:o=>_e.reset(h,D.definition.key,[o]),onSuccess:_,onError:o=>{F(o instanceof Error?o.message:"Failed to update bundle resource")}}),ne=Y({mutationFn:o=>_e.runRoutine(h,D.definition.key,o),onSuccess:_,onError:o=>{F(o instanceof Error?o.message:"Failed to run built-in routine")}}),me=Y({mutationFn:o=>_e.enableRoutineSchedule(h,D.definition.key,o),onSuccess:_,onError:o=>{F(o instanceof Error?o.message:"Failed to enable routine schedule")}}),pe=Y({mutationFn:o=>_e.disableRoutineSchedule(h,D.definition.key,o),onSuccess:_,onError:o=>{F(o instanceof Error?o.message:"Failed to disable routine schedule")}}),le=ne.isPending?"run":me.isPending?"enable":pe.isPending?"disable":null,{data:Ce}=H({queryKey:f.agents.runtimeState(R??k),queryFn:()=>X.runtimeState(R,h??void 0),enabled:!!R&&P}),{data:W}=H({queryKey:f.heartbeats(h,a?.id??void 0),queryFn:()=>ke.list(h,a?.id??void 0),enabled:!!h&&!!a?.id&&z}),{data:Z}=H({queryKey:[...f.issues.list(h),"participant-agent",R??"__none__"],queryFn:()=>dt.list(h,{participantAgentId:R}),enabled:!!h&&!!R&&P}),{data:Ie}=H({queryKey:f.agents.list(h),queryFn:()=>X.list(h),enabled:!!h&&P}),{data:ve}=H({queryKey:f.budgets.overview(h??"__none__"),queryFn:()=>yt.overview(h),enabled:!!h,refetchInterval:3e4,staleTime:5e3}),be=(Z??[]).sort((o,K)=>new Date(K.updatedAt).getTime()-new Date(o.updatedAt).getTime());(Ie??[]).find(o=>o.id===a?.reportsTo),(Ie??[]).filter(o=>o.reportsTo===a?.id&&o.status!=="terminated");const Pe=(0,i.useMemo)(()=>{const o=ve?.policies.find(we=>we.scopeType==="agent"&&we.scopeId===(a?.id??k));if(o)return o;const K=a?.budgetMonthlyCents??0,Ne=a?.spentMonthlyCents??0;return{policyId:"",companyId:h??"",scopeType:"agent",scopeId:a?.id??k,scopeName:a?.name??"Agent",metric:"billed_cents",windowKind:"calendar_month_utc",amount:K,observedAmount:Ne,remainingAmount:Math.max(0,K-Ne),utilizationPercent:K>0?Number((Ne/K*100).toFixed(2)):0,warnPercent:80,hardStopEnabled:!0,notifyEnabled:!0,isActive:K>0,status:K>0&&Ne>=K?"hard_stop":"ok",paused:a?.status==="paused",pauseReason:a?.pauseReason??null,windowStart:new Date,windowEnd:new Date}},[a,ve?.policies,h,k]),Ae=(0,i.useMemo)(()=>(W??[]).find(o=>o.status==="running"||o.status==="queued")??null,[W]);(0,i.useEffect)(()=>{if(!a)return;if(l){k!==j&&C(`/agents/${j}/runs/${l}`,{replace:!0});return}const o=m==="instructions"?"instructions":m==="configuration"?"configuration":m==="secrets"?"secrets":m==="skills"?"skills":m==="tools"?"tools":m==="runs"?"runs":m==="audit"?"audit":m==="budget"?"budget":"dashboard";if(k!==j||r!==o){C(`/agents/${j}/${o}`,{replace:!0});return}},[a,k,j,l,r,m,C]),(0,i.useEffect)(()=>{!a?.companyId||a.companyId===g||p(a.companyId,{source:"route_sync"})},[a?.companyId,g,p]);const Re=Y({mutationFn:async o=>{if(!Q)return Promise.reject(new Error("No agent reference"));if(o==="approve")return X.approve(Q,h??void 0)},onSuccess:()=>{F(null),y.invalidateQueries({queryKey:f.agents.detail(k)}),y.invalidateQueries({queryKey:f.agents.detail(Q)}),y.invalidateQueries({queryKey:f.agents.runtimeState(Q)}),y.invalidateQueries({queryKey:f.agents.taskSessions(Q)}),h&&(y.invalidateQueries({queryKey:f.agents.list(h)}),a?.id&&y.invalidateQueries({queryKey:f.heartbeats(h,a.id)}))},onError:o=>{F(o instanceof Error?o.message:"Action failed")}}),u=Y({mutationFn:o=>yt.upsertPolicy(h,{scopeType:"agent",scopeId:a?.id??k,amount:o,windowKind:"calendar_month_utc"}),onSuccess:()=>{h&&(y.invalidateQueries({queryKey:f.budgets.overview(h)}),y.invalidateQueries({queryKey:f.agents.detail(k)}),y.invalidateQueries({queryKey:f.agents.detail(Q)}),y.invalidateQueries({queryKey:f.agents.list(h)}),y.invalidateQueries({queryKey:f.dashboard(h)}))}}),N=Y({mutationFn:o=>X.update(Q,{icon:o},h??void 0),onSuccess:()=>{y.invalidateQueries({queryKey:f.agents.detail(k)}),y.invalidateQueries({queryKey:f.agents.detail(Q)}),h&&y.invalidateQueries({queryKey:f.agents.list(h)})}}),q=Y({mutationFn:o=>X.updatePermissions(Q,o,h??void 0),onSuccess:()=>{F(null),y.invalidateQueries({queryKey:f.agents.detail(k)}),y.invalidateQueries({queryKey:f.agents.detail(Q)}),h&&y.invalidateQueries({queryKey:f.agents.list(h)})},onError:o=>{F(o instanceof Error?o.message:"Failed to update permissions")}});if((0,i.useEffect)(()=>{const o=[{label:"Agents",href:"/agents"}],K=a?.name??k??"Agent";m==="dashboard"&&!l?o.push({label:K}):(o.push({label:K,href:`/agents/${j}/dashboard`}),l?(o.push({label:"Runs",href:`/agents/${j}/runs`}),o.push({label:`Run ${l.slice(0,8)}`})):m==="instructions"?o.push({label:"Instructions"}):m==="configuration"?o.push({label:"Configuration"}):m==="secrets"?o.push({label:"Secrets"}):m==="tools"?o.push({label:"Tools"}):m==="runs"?o.push({label:"Runs"}):m==="budget"?o.push({label:"Budget"}):o.push({label:"Dashboard"})),b(o)},[b,a,k,j,m,l]),(0,i.useEffect)(()=>(n(),()=>n()),[n]),(0,i.useEffect)(()=>{!R||w!=="joined"||I(o=>{if(!o.has(R))return o;const K=new Set(o);return K.delete(R),K})},[R,w]),Xt((0,i.useCallback)(o=>{M&&(o.preventDefault(),o.returnValue="")},[M])),(0,i.useEffect)(()=>{if(!M)return;function o(K){if(K.defaultPrevented||K.button!==0||K.altKey||K.ctrlKey||K.metaKey||K.shiftKey)return;const Ne=K.target;if(!(Ne instanceof Element))return;const we=Ne.closest("a[href]");if(!(we instanceof HTMLAnchorElement)||we.target&&we.target!=="_self")return;const Oe=new URL(we.href,window.location.href),ze=new URL(window.location.href);Oe.origin===ze.origin&&(Oe.pathname===ze.pathname&&Oe.search===ze.search&&Oe.hash===ze.hash||T()||(K.preventDefault(),K.stopPropagation()))}return document.addEventListener("click",o,!0),()=>document.removeEventListener("click",o,!0)},[M,T]),(0,i.useEffect)(()=>{if(!M)return;const o={index:window.history.state?.idx,state:window.history.state,url:window.location.href};let K=!1;function Ne(we){if(K){K=!1;return}T()||(we.stopImmediatePropagation(),K=Fn(window.history,o,we.state?.idx))}return window.addEventListener("popstate",Ne,!0),()=>window.removeEventListener("popstate",Ne,!0)},[M,T]),ge)return(0,e.jsx)(Ps,{variant:"detail"});if(ie)return(0,e.jsx)("p",{className:"text-sm text-destructive",children:ie.message});if(!a)return null;if(!l&&!r)return(0,e.jsx)(Yt,{to:`/agents/${j}/dashboard`,replace:!0});const de=a.status==="pending_approval",xe=a.orgChainHealth?.status==="invalid_org_chain",Le=xe?null:a.orgChainHealth?.escalationWarning??null,De=(m==="configuration"||m==="instructions"||m==="secrets")&&(M||V),st=w==="left"&&!O.has(a.id),xt=d.isPending&&d.variables?.resourceType==="agent"&&d.variables.resourceId===a.id,Qt=sn(U.data,"agent",a.id),Ht=xt&&d.variables?.starred!==void 0,ft=xt&&d.variables?.starred===void 0;function ht(o){o===m||!T()||C(`/agents/${j}/${o}`)}return(0,e.jsxs)("div",{className:ce("space-y-6",ee&&De&&"pb-24"),children:[st?(0,e.jsxs)("div",{className:"flex items-center gap-3 border border-yellow-300/35 bg-yellow-300/10 px-3 py-2 text-sm text-yellow-900 dark:text-yellow-100",children:[(0,e.jsx)("p",{className:"min-w-0 flex-1",children:"You left this agent. It no longer appears in your sidebar."}),(0,e.jsx)($s,{compact:!0,state:"left",pending:ft,pendingState:ft?d.variables?.state:null,resourceName:a.name,onJoin:()=>d.mutate({resourceType:"agent",resourceId:a.id,resourceName:a.name,state:"joined"}),onLeave:()=>d.mutate({resourceType:"agent",resourceId:a.id,resourceName:a.name,state:"left"})}),(0,e.jsx)("button",{type:"button",className:"h-6 w-6 shrink-0 text-yellow-900/70 hover:text-yellow-900 dark:text-yellow-100/70 dark:hover:text-yellow-100","aria-label":"Dismiss agent membership notice",onClick:()=>I(o=>new Set(o).add(a.id)),children:"×"})]}):null,Le?(0,e.jsxs)("div",{className:"flex items-start gap-3 border border-amber-300/35 bg-amber-300/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-100",children:[(0,e.jsx)(pt,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium",children:"Escalation path is paused"}),(0,e.jsx)("p",{className:"text-amber-900/90 dark:text-amber-100/90",children:Le})]})]}):null,xe?(0,e.jsxs)("div",{className:"flex items-start gap-3 border border-amber-300/35 bg-amber-300/10 px-3 py-2 text-sm text-amber-900 dark:text-amber-100",children:[(0,e.jsx)(pt,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsx)("p",{className:"font-medium",children:"Invalid reporting chain"}),(0,e.jsxs)("p",{className:"text-amber-900/90 dark:text-amber-100/90",children:[a.name," cannot accept tasks or start runs until its reporting chain is repaired."]}),(0,e.jsx)("p",{className:"break-words font-mono text-xs text-amber-900/80 dark:text-amber-100/80",children:vn(a)}),a.orgChainHealth?.repairGuidance?(0,e.jsx)("p",{className:"text-amber-900/85 dark:text-amber-100/85",children:a.orgChainHealth.repairGuidance}):(0,e.jsx)("p",{className:"text-amber-900/85 dark:text-amber-100/85",children:"Assign this agent to an active manager/root, or explicitly pause or terminate the affected agent/subtree."})]})]}):null,(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,e.jsx)(Fs,{value:a.icon,onChange:o=>N.mutate(o),children:(0,e.jsx)("button",{className:"shrink-0 flex items-center justify-center h-12 w-12 rounded-lg bg-accent hover:bg-accent/80 transition-colors",children:(0,e.jsx)(Ts,{icon:a.icon,className:"h-6 w-6"})})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("div",{className:"flex items-center gap-2",children:(0,e.jsx)("h2",{className:"text-2xl font-bold truncate",children:a.name})}),(0,e.jsxs)("p",{className:"text-sm text-muted-foreground truncate",children:[ms[a.role]??a.role,a.title?` - ${a.title}`:""]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,e.jsx)(Xs,{size:"button",starred:Qt,pending:Ht,resourceName:a.name,onToggle:o=>d.mutate({resourceType:"agent",resourceId:a.id,resourceName:a.name,starred:o})}),(0,e.jsx)(Hs,{agent:a,companyId:h,assignLabel:"Assign Task",runLabel:"Run Heartbeat",actionsDisabled:Re.isPending,workActionsDisabled:xe,workActionsDisabledReason:"Repair this agent's reporting chain before assigning tasks or starting runs",hasPendingNavigationChanges:M,onBeforeNavigate:T,onActionError:F,onTerminateSuccess:()=>C("/agents/all",{replace:!0}),hideTerminate:!!D,pauseConfirm:D?{title:`Pause the ${D.definition.displayName}?`,description:(0,e.jsxs)(e.Fragment,{children:[Se," depends on this agent. While paused,"," ",Se.toLowerCase()," generation is skipped and the"," ",Se," page shows a warning."]})}:void 0,children:Ae&&(0,e.jsxs)(Fe,{to:`/agents/${j}/runs/${Ae.id}`,className:"sm:hidden flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",children:[(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,e.jsx)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:"Live"})]})})]})]}),D&&(0,e.jsxs)(ks,{tone:"info",title:"Built-in agent",actions:(0,e.jsx)($,{variant:"outline",size:"sm",onClick:()=>he.mutate(),disabled:he.isPending,children:he.isPending?"Resetting…":"Reset to defaults"}),children:["Ships with Paperclip and powers ",(0,e.jsx)("strong",{children:Se}),". Configure it like any agent — model, instructions, budget. It can be paused but not deleted; pausing it pauses ",Se,"."]}),D?.definition.bundle&&(0,e.jsx)(zs,{state:D,agentRef:j,onConfigure:()=>A(!0),onResetResource:o=>S.mutate(o),onRunRoutine:o=>ne.mutate(o),onEnableSchedule:o=>me.mutate(o),onDisableSchedule:o=>pe.mutate(o),resettingResource:S.isPending?S.variables??null:null,routineActionPending:le}),D&&h&&(0,e.jsx)(Ks,{companyId:h,state:D,open:x,onOpenChange:A,onConfigured:()=>{A(!1),_()}}),!l&&(0,e.jsx)(ds,{value:m,onValueChange:ht,children:(0,e.jsx)(Vs,{items:En,value:m,onValueChange:ht})}),E&&(0,e.jsx)("p",{className:"text-sm text-destructive",children:E}),de&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-md border border-amber-300/60 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-400/40 dark:bg-amber-950/30 dark:text-amber-200",children:[(0,e.jsx)("span",{children:"This agent is pending board approval and cannot be invoked yet."}),(0,e.jsxs)($,{variant:"outline",size:"sm",onClick:()=>Re.mutate("approve"),disabled:Re.isPending,children:[(0,e.jsx)(Ft,{className:"h-3.5 w-3.5 sm:mr-1"}),(0,e.jsx)("span",{children:"Approve agent"})]})]}),!ee&&De&&(0,e.jsx)("div",{className:"fixed bottom-6 right-6 z-30",children:(0,e.jsxs)("div",{className:"flex items-center gap-2 bg-background/90 backdrop-blur-sm border border-border rounded-lg px-3 py-1.5 shadow-lg",children:[(0,e.jsx)($,{variant:"ghost",size:"sm",onClick:()=>re.current?.(),disabled:V,children:"Cancel"}),(0,e.jsx)($,{size:"sm",onClick:()=>te.current?.(),disabled:V,children:V?"Saving…":"Save"})]})}),ee&&De&&(0,e.jsx)("div",{className:"fixed inset-x-0 bottom-0 z-30 border-t border-border bg-background/95 backdrop-blur-sm",children:(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2 px-3 py-2",style:{paddingBottom:"max(env(safe-area-inset-bottom), 0.5rem)"},children:[(0,e.jsx)($,{variant:"ghost",size:"sm",onClick:()=>re.current?.(),disabled:V,children:"Cancel"}),(0,e.jsx)($,{size:"sm",onClick:()=>te.current?.(),disabled:V,children:V?"Saving…":"Save"})]})}),m==="dashboard"&&(0,e.jsx)(Wn,{agent:a,runs:W??[],assignedIssues:be,runtimeState:Ce,agentId:a.id,agentRouteId:j}),m==="instructions"&&(0,e.jsx)(Gn,{agent:a,companyId:h??void 0,onDirtyChange:v,onSaveActionChange:G,onCancelActionChange:ae,onSavingChange:oe}),m==="configuration"&&(0,e.jsx)(Jn,{agent:a,agentId:a.id,companyId:h??void 0,onDirtyChange:v,onSaveActionChange:G,onCancelActionChange:ae,onSavingChange:oe,updatePermissions:q}),m==="secrets"&&(0,e.jsx)("div",{className:"max-w-3xl",children:(0,e.jsx)(Ot,{agent:a,companyId:h??void 0,onDirtyChange:v,onSaveActionChange:G,onCancelActionChange:ae,onSavingChange:oe,updatePermissions:q,content:"secrets"})}),m==="skills"&&(0,e.jsx)(tn,{agent:a,companyId:h??void 0}),m==="tools"&&h&&(0,e.jsx)(Ds,{agent:a,companyId:h}),m==="runs"&&(0,e.jsx)(Xn,{runs:W??[],companyId:h,agentId:a.id,agentRouteId:j,selectedRunId:l??null,adapterType:a.adapterType,adapterConfig:a.adapterConfig}),m==="audit"&&h?(0,e.jsx)(gn,{companyId:h,lockedAgentId:a.id,hideHeader:!0}):null,m==="budget"&&h?(0,e.jsx)("div",{className:"max-w-3xl",children:(0,e.jsx)(xn,{summary:Pe,isSaving:u.isPending,onSave:o=>u.mutate(o),variant:"plain"})}):null]})}function Bt(t){const s=t.contextSnapshot,r=s?.issueId??s?.taskId;return r?String(r):void 0}function Hn(t,s,r){const l=Bt(t),c=l?r.get(l):void 0,g=`/agents/${s}/runs/${t.id}`;return{task:c,runHref:g,rowHref:c?`/issues/${c.identifier??c.id}`:g}}function Un({runs:t,agentId:s,issuesById:r}){const l=(0,i.useMemo)(()=>[...t].sort((P,z)=>new Date(z.createdAt).getTime()-new Date(P.createdAt).getTime()),[t]),c=l.find(P=>P.status==="running"||P.status==="queued")??l[0],g=c?Bt(c):void 0,p=!!g&&!r.has(g),{data:n}=H({queryKey:f.issues.detail(g??"__none__"),queryFn:()=>dt.get(g),enabled:p,staleTime:3e4}),b=c?c.resultJson?String(c.resultJson.summary??c.resultJson.result??""):c.error??"":"",y=(0,i.useMemo)(()=>{if(!b)return"";const P=b.replace(/^#{1,6}\s+/gm,"").split(`
|
|
4
4
|
`).map(v=>v.trim()).filter(v=>v.length>0&&!v.startsWith("---")&&!v.startsWith("|")&&!v.startsWith("```")&&!/^[-*>]/.test(v)&&!/^\d+\./.test(v)),z=[];let M=0;for(const v of P){if(z.length>=3||M+v.length>280)break;z.push(v),M+=v.length}return z.join(" ")},[b]);if(!c)return null;const C=c.status==="running"||c.status==="queued",{task:E,runHref:F,rowHref:O}=Hn(c,s,n&&g?new Map(r).set(g,{id:n.id,title:n.title,status:n.status,identifier:n.identifier}):r),I=_t[c.status]??{icon:Ye,color:"text-neutral-400"},m=I.icon;return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("div",{className:"flex w-full items-center justify-between",children:(0,e.jsx)(Fe,{to:F,className:"no-underline",children:(0,e.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-medium transition-colors hover:text-foreground",children:[C&&(0,e.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,e.jsx)("span",{children:C?"Live Run":"Latest Run"}),(0,e.jsxs)("span",{className:"font-mono text-xs font-normal text-muted-foreground",children:["· ",c.id.slice(0,8)]})]})})}),(0,e.jsxs)(Fe,{to:O,className:ce("block border rounded-lg p-4 space-y-2 w-full no-underline transition-colors hover:bg-muted/50 cursor-pointer",C?"border-blue-500/30 shadow-(--shadow-extract-14)":"border-border"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(m,{className:ce("h-3.5 w-3.5",I.color,c.status==="running"&&"animate-spin")}),(0,e.jsx)(Xe,{status:c.status}),E?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Ns,{status:E.status,size:"sm"}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:E.identifier??E.id.slice(0,8)}),(0,e.jsx)("span",{className:"truncate text-xs",children:E.title})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:c.id.slice(0,8)}),(0,e.jsx)(ut,{variant:"ghost",className:ce("px-1.5 text-(length:--text-nano)",c.invocationSource==="timer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300":c.invocationSource==="assignment"?"bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300":c.invocationSource==="on_demand"?"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300":"bg-muted text-muted-foreground"),children:Mt[c.invocationSource]??c.invocationSource})]}),(0,e.jsx)("span",{className:"ml-auto text-xs text-muted-foreground",children:Ke(c.createdAt)})]}),y&&(0,e.jsx)("div",{className:"overflow-hidden max-h-16",children:(0,e.jsx)(Is,{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:y})})]})]})}function Wn({agent:t,runs:s,assignedIssues:r,runtimeState:l,agentId:c,agentRouteId:g}){const p=(0,i.useMemo)(()=>{const n=new Map;for(const b of r)n.set(b.id,b);return n},[r]);return(0,e.jsxs)("div",{className:"space-y-8",children:[(0,e.jsx)(Un,{runs:s,agentId:g,issuesById:p}),(0,e.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,e.jsx)(at,{title:"Run Activity",subtitle:"Last 14 days",children:(0,e.jsx)(on,{runs:s})}),!1,(0,e.jsx)(at,{title:"Tasks by Status",subtitle:"Last 14 days",children:(0,e.jsx)(an,{issues:r})}),(0,e.jsx)(at,{title:"Success Rate",subtitle:"Last 14 days",children:(0,e.jsx)(Ys,{runs:s})})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Recent Tasks"}),(0,e.jsx)(Fe,{to:`/issues?participantAgentId=${c}`,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"See All →"})]}),r.length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No recent tasks."}):(0,e.jsxs)("div",{className:"border border-border rounded-lg",children:[r.slice(0,10).map(n=>(0,e.jsx)(rn,{identifier:n.identifier??n.id.slice(0,8),title:n.title,to:`/issues/${n.identifier??n.id}`,trailing:(0,e.jsx)(Xe,{status:n.status})},n.id)),r.length>10&&(0,e.jsxs)("div",{className:"px-3 py-2 text-xs text-muted-foreground text-center border-t border-border",children:["+",r.length-10," more tasks"]})]})]}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:"Costs"}),(0,e.jsx)(Vn,{runtimeState:l,runs:s})]})]})}function Vn({runtimeState:t,runs:s}){const r=s.filter(l=>{const c=Ze(l);return c.cost>0||c.input>0||c.output>0||c.cached>0}).sort((l,c)=>new Date(c.createdAt).getTime()-new Date(l.createdAt).getTime());return(0,e.jsxs)("div",{className:"space-y-4",children:[t&&(0,e.jsx)("div",{className:"border border-border rounded-lg p-4",children:(0,e.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 tabular-nums",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground block",children:"Input tokens"}),(0,e.jsx)("span",{className:"text-lg font-semibold",children:Ee(t.totalInputTokens)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground block",children:"Output tokens"}),(0,e.jsx)("span",{className:"text-lg font-semibold",children:Ee(t.totalOutputTokens)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground block",children:"Cached tokens"}),(0,e.jsx)("span",{className:"text-lg font-semibold",children:Ee(t.totalCachedInputTokens)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground block",children:"Total cost"}),(0,e.jsx)("span",{className:"text-lg font-semibold",children:Wt(t.totalCostCents)})]})]})}),r.length>0&&(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-hidden",children:(0,e.jsxs)("table",{className:"w-full text-xs",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-border bg-accent/20",children:[(0,e.jsx)("th",{scope:"col",className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Date"}),(0,e.jsx)("th",{scope:"col",className:"text-left px-3 py-2 font-medium text-muted-foreground",children:"Run"}),(0,e.jsx)("th",{scope:"col",className:"text-right px-3 py-2 font-medium text-muted-foreground",children:"Input"}),(0,e.jsx)("th",{scope:"col",className:"text-right px-3 py-2 font-medium text-muted-foreground",children:"Output"}),(0,e.jsx)("th",{scope:"col",className:"text-right px-3 py-2 font-medium text-muted-foreground",children:"Cost"})]})}),(0,e.jsx)("tbody",{children:r.slice(0,10).map(l=>{const c=Ze(l);return(0,e.jsxs)("tr",{className:"border-b border-border last:border-b-0",children:[(0,e.jsx)("td",{className:"px-3 py-2",children:Ge(l.createdAt)}),(0,e.jsx)("td",{className:"px-3 py-2 font-mono",children:l.id.slice(0,8)}),(0,e.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:Ee(c.input)}),(0,e.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:Ee(c.output)}),(0,e.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:c.cost>0?`$${c.cost.toFixed(4)}`:"-"})]},l.id)})})]})})]})}function $t(t,s,r,l,c){const g=lt(r),p=lt(l);return p===g?!1:(t.removeQueries({queryKey:f.agents.detail(g)}),s(`/agents/${p}/${c}`,{replace:!0}),!0)}function Jn({agent:t,agentId:s,companyId:r,onDirtyChange:l,onSaveActionChange:c,onCancelActionChange:g,onSavingChange:p,updatePermissions:n}){const b=Me(),y=et(),{tab:C}=ct(),[E,F]=(0,i.useState)(!1),{data:O}=H({queryKey:f.agents.configRevisions(t.id),queryFn:()=>X.listConfigRevisions(t.id,r)}),I=Y({mutationFn:m=>X.rollbackConfigRevision(t.id,m,r),onSuccess:m=>{b.invalidateQueries({queryKey:f.agents.detail(t.id)}),b.invalidateQueries({queryKey:f.agents.configRevisions(t.id)}),$t(b,y,t,m,C??"configuration")||b.invalidateQueries({queryKey:f.agents.detail(t.urlKey)})}});return(0,e.jsxs)("div",{className:"max-w-3xl space-y-6",children:[(0,e.jsx)(Ot,{agent:t,onDirtyChange:l,onSaveActionChange:c,onCancelActionChange:g,onSavingChange:p,updatePermissions:n,companyId:r,hidePromptTemplate:!0,hideInstructionsFile:!0}),(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-medium mb-3",children:"API Keys"}),(0,e.jsx)(er,{agentId:s,companyId:r})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("button",{className:"flex items-center gap-2 text-sm font-medium hover:text-foreground transition-colors",onClick:()=>F(m=>!m),children:[E?(0,e.jsx)(ws,{className:"h-3.5 w-3.5 text-muted-foreground"}):(0,e.jsx)(tt,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Configuration Revisions",(0,e.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:O?.length??0})]}),E&&(0,e.jsx)("div",{className:"mt-3",children:(O??[]).length===0?(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No configuration revisions yet."}):(0,e.jsx)("div",{className:"space-y-2",children:(O??[]).slice(0,10).map(m=>(0,e.jsxs)("div",{className:"border border-border/70 rounded-md p-3 space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"font-mono",children:m.id.slice(0,8)}),(0,e.jsx)("span",{className:"mx-1",children:"·"}),(0,e.jsx)("span",{children:Ge(m.createdAt)}),(0,e.jsx)("span",{className:"mx-1",children:"·"}),(0,e.jsx)("span",{children:m.source})]}),(0,e.jsx)($,{size:"sm",variant:"outline",className:"h-7 px-2.5 text-xs",onClick:()=>I.mutate(m.id),disabled:I.isPending,children:"Restore"})]}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Changed:"," ",m.changedKeys.length>0?m.changedKeys.join(", "):"no tracked changes"]})]},m.id))})})]})]})}function Ot({agent:t,companyId:s,onDirtyChange:r,onSaveActionChange:l,onCancelActionChange:c,onSavingChange:g,updatePermissions:p,hidePromptTemplate:n,hideInstructionsFile:b,content:y="configuration"}){const C=Me(),E=et(),{tab:F}=ct(),{pushToast:O}=Tt(),[I,m]=(0,i.useState)(!1),P=(0,i.useRef)(t),{data:z}=H({queryKey:s?f.agents.adapterModels(s,t.adapterType):["agents","none","adapter-models",t.adapterType],queryFn:()=>X.adapterModels(s,t.adapterType),enabled:!!s&&y==="configuration"}),M=ts(t.permissions)==="low_trust_review",{data:v,isLoading:V}=H({queryKey:s?f.projects.list(s):["projects","__low-trust-disabled"],queryFn:()=>bs.list(s),enabled:!!(s&&M)&&y==="configuration"}),{data:oe,isLoading:te}=H({queryKey:s?[...f.issues.list(s),"low-trust-boundary-candidates"]:["issues","__low-trust-disabled"],queryFn:()=>dt.list(s,{limit:100,sortField:"updated",sortDir:"desc"}),enabled:!!(s&&M)&&y==="configuration"}),re=Y({mutationFn:a=>X.update(t.id,a,s),onMutate:()=>{m(!0)},onSuccess:a=>{C.invalidateQueries({queryKey:f.agents.detail(t.id)}),C.invalidateQueries({queryKey:f.agents.configRevisions(t.id)}),C.invalidateQueries({queryKey:f.agents.list(t.companyId)}),$t(C,E,t,a,F??y)||C.invalidateQueries({queryKey:f.agents.detail(t.urlKey)}),O({title:"Agent saved",tone:"success"})},onError:a=>{m(!1);const ge=a instanceof Ct||a instanceof Error?a.message:"Could not save agent";O({title:"Save failed",body:ge,tone:"error"})}});(0,i.useEffect)(()=>{I&&t!==P.current&&m(!1),P.current=t},[t,I]);const ee=re.isPending||I;(0,i.useEffect)(()=>{g(ee)},[g,ee]);const k=!!t.permissions?.canCreateAgents,J=t.permissions?.canCreateSkills!==!1,se=!!t.access?.canAssignTasks,G=t.access?.taskAssignSource??"none",ae=t.role==="ceo"||k,T=G==="ceo_role"?"Enabled automatically for CEO agents.":G==="agent_creator"?"Enabled automatically while this agent can create new agents.":G==="explicit_grant"?"Enabled via explicit company permission grant.":G==="simple_default"?"Enabled by simple company-wide task assignment defaults.":"Disabled unless explicitly granted.";return(0,e.jsxs)("div",{className:"space-y-6",children:[(0,e.jsx)(mn,{mode:"edit",agent:t,onSave:a=>re.mutateAsync(a),isSaving:ee,adapterModels:z,onDirtyChange:r,onSaveActionChange:l,onCancelActionChange:c,hideInlineSave:!0,hidePromptTemplate:n,hideInstructionsFile:b,content:y,sectionLayout:"cards"}),y==="configuration"?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Saved adapter config affects the next run. Active runs keep the config they started with, and config changes may start a fresh adapter session."}):null,y==="configuration"?(0,e.jsx)(hn,{permissions:t.permissions,disabled:p.isPending,companyId:s,projectCandidates:(v??[]).map(a=>({id:a.id,label:a.name})),issueCandidates:(oe??[]).map(a=>({id:a.id,label:`${a.identifier??a.id.slice(0,8)} · ${a.title}`})),candidatesLoading:V||te,onChange:a=>p.mutate({canCreateAgents:k,canCreateSkills:J,canAssignTasks:se,...es(a,a.trustPreset==="low_trust_review"?"low_trust_review":"standard")})}):null,y==="configuration"?(0,e.jsxs)("div",{children:[(0,e.jsx)("h3",{className:"text-sm font-medium mb-3",children:"Permissions"}),(0,e.jsxs)("div",{className:"border border-border rounded-lg p-4 space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{children:"Can create new agents"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Lets this agent create or hire agents. This also grants task assignment authority."})]}),(0,e.jsx)(nt,{checked:k,onCheckedChange:()=>p.mutate({canCreateAgents:!k,canCreateSkills:J,canAssignTasks:k?se:!0}),disabled:p.isPending})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{children:"Can create/import skills"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Lets this agent install, import, create, and scan company skills without creating agents."})]}),(0,e.jsx)(nt,{checked:J,onCheckedChange:()=>p.mutate({canCreateAgents:k,canCreateSkills:!J,canAssignTasks:se}),disabled:p.isPending})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between gap-4 text-sm",children:[(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("div",{children:"Can assign tasks"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:T})]}),(0,e.jsx)(nt,{checked:se,onCheckedChange:()=>p.mutate({canCreateAgents:k,canCreateSkills:J,canAssignTasks:!se}),disabled:p.isPending||ae})]})]})]}):null]})}function Gn({agent:t,companyId:s,onDirtyChange:r,onSaveActionChange:l,onCancelActionChange:c,onSavingChange:g}){const p=Me(),{selectedCompanyId:n}=At(),{isMobile:b}=mt(),[y,C]=(0,i.useState)("AGENTS.md"),[E,F]=(0,i.useState)(!1),[O,I]=(0,i.useState)(null),[m,P]=(0,i.useState)(null),[z,M]=(0,i.useState)(""),[v,V]=(0,i.useState)(!1),[oe,te]=(0,i.useState)([]),[re,ee]=(0,i.useState)(new Set),[k,J]=(0,i.useState)(260),[se,G]=(0,i.useState)(null),ae=(0,i.useRef)(null),[T,a]=(0,i.useState)(!1),ge=(0,i.useRef)(null),ie=(0,i.useRef)(null);(0,i.useEffect)(()=>{C("AGENTS.md"),F(!1),I(null),P(null),M(""),V(!1),te([]),ee(new Set),a(!1),ge.current=null,ie.current=null},[t.id]);const h=cn()(t.adapterType).supportsInstructionsBundle,{data:j,isLoading:Q}=H({queryKey:f.agents.instructionsBundle(t.id),queryFn:()=>X.instructionsBundle(t.id,s),enabled:!!(s&&h)}),R=j?.mode??"managed",U=R==="managed"?j?.managedRootPath??j?.rootPath??"":j?.rootPath??"",d=m?.mode??R,w=m?.entryFile??j?.entryFile??"AGENTS.md",B=m?.rootPath??U,fe=(0,i.useMemo)(()=>j?.files.map(u=>u.path)??[],[j]),ue=!!(j&&d===R&&w===j.entryFile&&B===U),D=(0,i.useMemo)(()=>ue?[...new Set([w,...fe,...oe])]:[w,...oe],[ue,w,fe,oe]),Se=(0,i.useMemo)(()=>Bs(Object.fromEntries(D.map(u=>[u,""]))),[D]),_=y||w,he=ue&&fe.includes(_),x=j?.files.find(u=>u.path===_)??null,{data:A,isLoading:S}=H({queryKey:f.agents.instructionsFile(t.id,_),queryFn:()=>X.instructionsFile(t.id,_,s),enabled:!!(s&&h&&he)}),ne=Y({mutationFn:u=>X.updateInstructionsBundle(t.id,u,s),onMutate:()=>a(!0),onSuccess:()=>{p.invalidateQueries({queryKey:f.agents.instructionsBundle(t.id)}),p.invalidateQueries({queryKey:f.agents.detail(t.id)}),p.invalidateQueries({queryKey:f.agents.detail(t.urlKey)})},onError:()=>a(!1)}),me=Y({mutationFn:u=>X.saveInstructionsFile(t.id,u,s),onMutate:()=>a(!0),onSuccess:(u,N)=>{te(q=>q.filter(de=>de!==N.path)),p.invalidateQueries({queryKey:f.agents.instructionsBundle(t.id)}),p.invalidateQueries({queryKey:f.agents.instructionsFile(t.id,N.path)}),p.invalidateQueries({queryKey:f.agents.detail(t.id)}),p.invalidateQueries({queryKey:f.agents.detail(t.urlKey)})},onError:()=>a(!1)}),pe=Y({mutationFn:u=>X.deleteInstructionsFile(t.id,u,s),onMutate:()=>a(!0),onSuccess:(u,N)=>{p.invalidateQueries({queryKey:f.agents.instructionsBundle(t.id)}),p.removeQueries({queryKey:f.agents.instructionsFile(t.id,N)}),p.invalidateQueries({queryKey:f.agents.detail(t.id)}),p.invalidateQueries({queryKey:f.agents.detail(t.urlKey)})},onError:()=>a(!1)}),le=Y({mutationFn:async({file:u,namespace:N})=>{if(!n)throw new Error("Select a company to upload images");return _s.uploadImage(n,u,N)}});(0,i.useEffect)(()=>{if(!j)return;if(!ue){y!==w&&C(w);return}const u=j.files.map(N=>N.path);if(u.length===0){y!==j.entryFile&&C(j.entryFile);return}!u.includes(y)&&y!==w&&!oe.includes(y)&&C(u.includes(j.entryFile)?j.entryFile:u[0])},[j,ue,w,oe,y]),(0,i.useEffect)(()=>{const u=new Set;for(const N of D){const q=N.split("/");let de="";for(let xe=0;xe<q.length-1;xe++)de=de?`${de}/${q[xe]}`:q[xe],u.add(de)}ee(N=>Pn(N,u)?N:u)},[D]),(0,i.useEffect)(()=>{if(b){G(null);return}const u=ae.current;if(!u||(G(u.getBoundingClientRect().width),typeof ResizeObserver>"u"))return;const q=new ResizeObserver(de=>{const xe=de[0];xe&&G(xe.contentRect.width)});return q.observe(u),()=>q.disconnect()},[Q,b,D.length]),(0,i.useEffect)(()=>{const u=he&&A?`${A.path}:${A.content}`:`draft:${d}:${B}:${_}`;if(T){a(!1),P(null),I(null),ge.current=u;return}ge.current!==u&&(I(null),ge.current=u)},[T,d,B,A,he,_]),(0,i.useEffect)(()=>{j&&P(u=>u||{mode:R,rootPath:U,entryFile:j.entryFile})},[j,R,U]),(0,i.useEffect)(()=>{!j||d!=="external"||(ie.current={rootPath:B,entryFile:w,selectedFile:_})},[j,w,d,B,_]);const Ce=he?A?.content??"":"",W=O??Ce,Z=kn({selectedFileExists:he,selectedPath:_,detail:A,summary:x}),Ie=!!(m&&(m.mode!==R||m.rootPath!==U||m.entryFile!==(j?.entryFile??"AGENTS.md"))),ve=O!==null&&O!==Ce,be=Ie||ve,Pe=ne.isPending||me.isPending||pe.isPending||T;(0,i.useEffect)(()=>{g(Pe)},[g,Pe]),(0,i.useEffect)(()=>{r(be)},[r,be]),(0,i.useEffect)(()=>{l(be?()=>{(async()=>{const N=!!j?.legacyPromptTemplateActive||!!j?.legacyBootstrapPromptTemplateActive;Ie&&m&&await ne.mutateAsync({mode:m.mode,rootPath:m.mode==="external"?m.rootPath:null,entryFile:m.entryFile}),ve&&await me.mutateAsync({path:_,content:W,clearLegacyPromptTemplate:N})})().catch(()=>{})}:null)},[j,Ie,m,W,ve,be,l,me,_,ne]),(0,i.useEffect)(()=>{c(be?()=>{I(null),j&&P({mode:R,rootPath:U,entryFile:j.entryFile})}:null)},[j,be,c,R,U]);const Ae=(0,i.useCallback)(u=>{u.preventDefault();const N=u.clientX,q=k,de=Le=>{const De=Le.clientX-N,st=Math.max(180,Math.min(500,q+De));J(st)},xe=()=>{document.removeEventListener("mousemove",de),document.removeEventListener("mouseup",xe),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",de),document.addEventListener("mouseup",xe),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[k]),Re=!b&&se!==null&&se>=k+520;return h?Q&&!j?(0,e.jsx)(Yn,{}):(0,e.jsxs)("div",{className:"space-y-6",children:[(j?.warnings??[]).length>0&&(0,e.jsx)("div",{className:"space-y-2",children:(j?.warnings??[]).map(u=>(0,e.jsx)("div",{className:"rounded-md border border-sky-500/25 bg-sky-500/10 px-3 py-2 text-xs text-sky-900 dark:text-sky-100",children:u},u))}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Saved instructions affect the next run. Active runs keep the instructions they started with, and instruction changes may start a fresh adapter session."}),(0,e.jsxs)(Et,{defaultOpen:d==="external",children:[(0,e.jsxs)(Rt,{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors group",children:[(0,e.jsx)(tt,{className:"h-3 w-3 transition-transform group-data-[state=open]:rotate-90"}),"Advanced"]}),(0,e.jsx)(It,{className:"pt-4 pb-6",children:(0,e.jsx)(is,{children:(0,e.jsxs)("div",{className:"grid gap-x-6 gap-y-4 md:grid-cols-(--gtc-18)",children:[(0,e.jsxs)("label",{className:"space-y-1.5 min-w-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:["Mode",(0,e.jsxs)(Qe,{children:[(0,e.jsx)(He,{asChild:!0,children:(0,e.jsx)(rt,{className:"h-3 w-3 text-muted-foreground cursor-help"})}),(0,e.jsx)(Ue,{side:"right",sideOffset:4,children:"Managed: Paperclip stores and serves the instructions bundle. External: you provide a path on disk where the instructions live."})]})]}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)($,{type:"button",size:"sm",variant:d==="managed"?"default":"outline",onClick:()=>{d==="external"&&(ie.current={rootPath:B,entryFile:w,selectedFile:_});const u=w||"AGENTS.md";P({mode:"managed",rootPath:j?.managedRootPath??B,entryFile:u}),C(u)},children:"Managed"}),(0,e.jsx)($,{type:"button",size:"sm",variant:d==="external"?"default":"outline",onClick:()=>{const u=ie.current,N=u?.entryFile??w??"AGENTS.md";P({mode:"external",rootPath:u?.rootPath??(j?.mode==="external"?j.rootPath??"":""),entryFile:N}),C(u?.selectedFile??N)},children:"External"})]})]}),(0,e.jsxs)("label",{className:"space-y-1.5 min-w-0",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:["Root path",(0,e.jsxs)(Qe,{children:[(0,e.jsx)(He,{asChild:!0,children:(0,e.jsx)(rt,{className:"h-3 w-3 text-muted-foreground cursor-help"})}),(0,e.jsx)(Ue,{side:"right",sideOffset:4,children:"The absolute directory on disk where the instructions bundle lives. In managed mode this is set by Paperclip automatically."})]})]}),d==="managed"?(0,e.jsxs)("div",{className:"flex items-center gap-1.5 font-mono text-xs text-muted-foreground pt-1.5",children:[(0,e.jsx)("span",{className:"min-w-0 truncate",title:B||void 0,children:B||"(managed)"}),B&&(0,e.jsx)($e,{text:B,className:"shrink-0",children:(0,e.jsx)(Ve,{className:"h-3.5 w-3.5"})})]}):(0,e.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,e.jsx)(Je,{value:B,onChange:u=>{const N=u.target.value;ie.current={rootPath:N,entryFile:w,selectedFile:_},P({mode:"external",rootPath:N,entryFile:w})},className:"font-mono text-sm",placeholder:"/absolute/path/to/agent/prompts"}),B&&(0,e.jsx)($e,{text:B,className:"shrink-0",children:(0,e.jsx)(Ve,{className:"h-3.5 w-3.5"})})]})]}),(0,e.jsxs)("label",{className:"space-y-1.5",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground flex items-center gap-1",children:["Entry file",(0,e.jsxs)(Qe,{children:[(0,e.jsx)(He,{asChild:!0,children:(0,e.jsx)(rt,{className:"h-3 w-3 text-muted-foreground cursor-help"})}),(0,e.jsx)(Ue,{side:"right",sideOffset:4,children:"The main file the agent reads first when loading instructions. Defaults to AGENTS.md."})]})]}),(0,e.jsx)(Je,{value:w,onChange:u=>{const N=u.target.value||"AGENTS.md",q=_===w?N:_;d==="external"&&(ie.current={rootPath:B,entryFile:N,selectedFile:q}),_===w&&C(N),P({mode:d,rootPath:B,entryFile:N})},className:"font-mono text-sm"})]})]})})})]}),(0,e.jsxs)("div",{ref:ae,className:"grid min-w-0 gap-3",style:Re?{gridTemplateColumns:`${k}px 0.5rem minmax(0, 1fr)`}:void 0,children:[(0,e.jsxs)("div",{className:ce("min-w-0 w-full border border-border rounded-lg p-3 space-y-3",b&&E&&"block",b&&!E&&"hidden"),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)("h4",{className:"text-sm font-medium",children:"Files"}),(0,e.jsxs)("div",{className:"flex items-center gap-1",children:[!v&&(0,e.jsx)($,{type:"button",size:"icon",variant:"outline",className:"h-7 w-7",onClick:()=>V(!0),children:"+"}),b&&(0,e.jsx)($,{type:"button",size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>F(!1),children:"✕"})]})]}),v&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(Je,{value:z,onChange:u=>M(u.target.value),placeholder:"TOOLS.md",className:"font-mono text-sm",autoFocus:!0,onKeyDown:u=>{u.key==="Escape"&&(V(!1),M(""))}}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)($,{type:"button",size:"sm",variant:"default",className:"flex-1",disabled:!z.trim()||z.includes(".."),onClick:()=>{const u=z.trim();!u||u.includes("..")||(te(N=>N.includes(u)?N:[...N,u]),C(u),I(""),M(""),V(!1))},children:"Create"}),(0,e.jsx)($,{type:"button",size:"sm",variant:"outline",className:"flex-1",onClick:()=>{V(!1),M("")},children:"Cancel"})]})]}),(0,e.jsx)(Js,{nodes:Se,selectedFile:_,expandedDirs:re,checkedFiles:new Set,onToggleDir:u=>ee(N=>{const q=new Set(N);return q.has(u)?q.delete(u):q.add(u),q}),onSelectFile:u=>{C(u),fe.includes(u)||I(""),b&&F(!1)},onToggleCheck:()=>{},showCheckboxes:!1,wrapLabels:!0,renderFileExtra:u=>{const N=j?.files.find(q=>q.path===u.path);return N?N.deprecated?(0,e.jsxs)(Qe,{children:[(0,e.jsx)(He,{asChild:!0,children:(0,e.jsx)("span",{className:"ml-3 shrink-0 rounded border border-amber-500/40 bg-amber-500/10 text-amber-800 dark:text-amber-200 px-1.5 py-0.5 text-(length:--text-nano) uppercase tracking-wide cursor-help",children:"virtual file"})}),(0,e.jsx)(Ue,{side:"right",sideOffset:4,children:"Legacy inline prompt — this deprecated virtual file preserves the old promptTemplate content"})]}):(0,e.jsx)("span",{className:"ml-3 shrink-0 rounded border border-border text-muted-foreground px-1.5 py-0.5 text-(length:--text-nano) uppercase tracking-wide",children:N.isEntryFile?"entry":`${N.size}b`}):null}})]}),Re&&(0,e.jsx)("div",{className:"w-1 cursor-col-resize rounded transition-colors hover:bg-border active:bg-primary/50",onMouseDown:Ae}),(0,e.jsxs)("div",{className:ce("min-w-0 w-full overflow-hidden border border-border rounded-lg p-4 space-y-3",b&&E&&"hidden"),children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[b&&(0,e.jsx)($,{type:"button",size:"icon",variant:"outline",className:"h-7 w-7 shrink-0",onClick:()=>F(!0),children:(0,e.jsx)(Rs,{className:"h-3.5 w-3.5"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h4",{className:"text-sm font-medium font-mono truncate",children:_}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:he?x?.deprecated?"Deprecated virtual file":`${A?.language??"text"} file`:"New file in this bundle"})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[!S&&(0,e.jsx)($e,{text:W,ariaLabel:"Copy instructions file as markdown",title:"Copy as markdown",copiedLabel:"Copied",className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-border text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,e.jsx)(Ve,{className:"h-3.5 w-3.5"})}),he&&!x?.deprecated&&_!==w&&(0,e.jsx)($,{type:"button",size:"sm",variant:"outline",onClick:()=>{confirm(`Delete ${_}?`)&&pe.mutate(_,{onSuccess:()=>{C(w),I(null)}})},disabled:pe.isPending,children:"Delete"})]})]}),he&&S&&!A?(0,e.jsx)(zt,{}):Z?(0,e.jsx)(ls,{value:W,onChange:u=>I(u??""),placeholder:"# Agent instructions",className:"min-w-0 overflow-hidden",contentClassName:"min-h-(--sz-420px) max-w-full break-words text-sm leading-7",imageUploadHandler:async u=>{const N=`agents/${t.id}/instructions/${_.replaceAll("/","-")}`;return(await le.mutateAsync({file:u,namespace:N})).contentPath}},_):(0,e.jsx)("textarea",{value:W,onChange:u=>I(u.target.value),className:"min-h-(--sz-420px) w-full min-w-0 rounded-md border border-border bg-transparent px-3 py-2 font-mono text-sm outline-none",placeholder:"File contents"})]})]})]}):(0,e.jsx)("div",{className:"max-w-3xl",children:(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"Instructions bundles are only available for local adapters."})})}function Yn(){return(0,e.jsxs)("div",{className:"max-w-5xl space-y-4",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-border p-4 space-y-4",children:[(0,e.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(ye,{className:"h-4 w-40"}),(0,e.jsx)(ye,{className:"h-4 w-(--sz-30rem) max-w-full"})]}),(0,e.jsx)(ye,{className:"h-4 w-16"})]}),(0,e.jsx)("div",{className:"grid gap-3 md:grid-cols-3",children:Array.from({length:3}).map((t,s)=>(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(ye,{className:"h-3 w-20"}),(0,e.jsx)(ye,{className:"h-10 w-full"})]},s))})]}),(0,e.jsxs)("div",{className:"grid gap-4 lg:grid-cols-(--gtc-19)",children:[(0,e.jsxs)("div",{className:"rounded-lg border border-border p-3 space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsx)(ye,{className:"h-4 w-12"}),(0,e.jsx)(ye,{className:"h-8 w-16"})]}),(0,e.jsx)(ye,{className:"h-10 w-full"}),(0,e.jsx)("div",{className:"space-y-2",children:Array.from({length:5}).map((t,s)=>(0,e.jsx)(ye,{className:"h-9 w-full rounded-none"},s))})]}),(0,e.jsxs)("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)(ye,{className:"h-4 w-48"}),(0,e.jsx)(ye,{className:"h-3 w-28"})]}),(0,e.jsx)(zt,{})]})]})]})}function zt(){return(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(ye,{className:"h-10 w-full"}),(0,e.jsx)(ye,{className:"h-(--sz-420px) w-full"})]})}function wt({run:t,isSelected:s,agentId:r}){const l=_t[t.status]??{icon:Ye,color:"text-neutral-400"},c=l.icon,g=Ze(t),p=t.resultJson?String(t.resultJson.summary??t.resultJson.result??""):t.error??"",n=Lt(t.resultJson);return(0,e.jsxs)(Fe,{to:s?`/agents/${r}/runs`:`/agents/${r}/runs/${t.id}`,className:ce("flex flex-col gap-1 w-full px-3 py-2.5 text-left border-b border-border last:border-b-0 transition-colors no-underline text-inherit",s?"bg-accent/40":"hover:bg-accent/20"),children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(c,{className:ce("h-3.5 w-3.5 shrink-0",l.color,t.status==="running"&&"animate-spin")}),(0,e.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:t.id.slice(0,8)}),(0,e.jsx)(ut,{variant:"ghost",className:ce("px-1.5 text-(length:--text-nano)",t.invocationSource==="timer"?"bg-blue-100 text-blue-700 dark:bg-blue-900/50 dark:text-blue-300":t.invocationSource==="assignment"?"bg-violet-100 text-violet-700 dark:bg-violet-900/50 dark:text-violet-300":t.invocationSource==="on_demand"?"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/50 dark:text-cyan-300":"bg-muted text-muted-foreground"),children:Mt[t.invocationSource]??t.invocationSource}),n?(0,e.jsx)(un,{showIcon:!1,className:"shrink-0 text-(length:--text-nano) py-0"}):null,(0,e.jsx)("span",{className:"ml-auto text-(length:--text-micro) text-muted-foreground shrink-0",children:Ke(t.createdAt)})]}),p&&(0,e.jsx)("span",{className:"text-xs text-muted-foreground truncate pl-5.5",children:p.slice(0,60)}),(g.totalTokens>0||g.cost>0)&&(0,e.jsxs)("div",{className:"flex items-center gap-2 pl-5.5 text-(length:--text-micro) text-muted-foreground tabular-nums",children:[g.totalTokens>0&&(0,e.jsxs)("span",{children:[Ee(g.totalTokens)," tok"]}),g.cost>0&&(0,e.jsxs)("span",{children:["$",g.cost.toFixed(3)]})]})]})}function Xn({runs:t,companyId:s,agentId:r,agentRouteId:l,selectedRunId:c,adapterType:g,adapterConfig:p}){const{isMobile:n}=mt();if(t.length===0)return(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:"No runs yet."});const b=[...t].sort((E,F)=>new Date(F.createdAt).getTime()-new Date(E.createdAt).getTime()),y=n?c:c??b[0]?.id??null,C=b.find(E=>E.id===y)??null;return n?C?(0,e.jsxs)("div",{className:"space-y-3 min-w-0 overflow-x-hidden",children:[(0,e.jsxs)(Fe,{to:`/agents/${l}/runs`,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors no-underline",children:[(0,e.jsx)(vs,{className:"h-3.5 w-3.5"}),"Back to runs"]}),(0,e.jsx)(kt,{run:C,agentRouteId:l,adapterType:g,adapterConfig:p},C.id)]}):(0,e.jsx)("div",{className:"border border-border rounded-lg overflow-x-hidden",children:b.map(E=>(0,e.jsx)(wt,{run:E,isSelected:!1,agentId:l},E.id))}):(0,e.jsxs)("div",{className:"flex gap-0",children:[(0,e.jsx)("div",{className:ce("shrink-0 border border-border rounded-lg",C?"w-72":"w-full"),children:(0,e.jsx)("div",{className:"sticky top-4 overflow-y-auto",style:{maxHeight:"calc(100vh - 2rem)"},children:b.map(E=>(0,e.jsx)(wt,{run:E,isSelected:E.id===y,agentId:l},E.id))})}),C&&(0,e.jsx)("div",{className:"flex-1 min-w-0 pl-4",children:(0,e.jsx)(kt,{run:C,agentRouteId:l,adapterType:g,adapterConfig:p},C.id)})]})}function kt({run:t,agentRouteId:s,adapterType:r,adapterConfig:l}){const c=Me(),g=et(),{data:p}=H({queryKey:f.runDetail(t.id),queryFn:()=>ke.get(t.id),enabled:!!t.id,refetchInterval:d=>Kn((d.state.data??t).status)}),n=p??t,b=Ze(n),{data:y}=H({queryKey:f.access.companyUserDirectory(n.companyId),queryFn:()=>Qs.listUserDirectory(n.companyId),enabled:!!(n.companyId&&n.responsibleUserId),retry:!1}),C=(0,i.useMemo)(()=>{if(!n.responsibleUserId)return null;const d=y?.users.find(w=>w.principalId===n.responsibleUserId);return d?.user?.name??d?.user?.email??null},[n.responsibleUserId,y]),E=rs(n.errorCode)?n.errorCode:null,[F,O]=(0,i.useState)(!1),[I,m]=(0,i.useState)(null);(0,i.useEffect)(()=>{m(null)},[n.id]);const P=Y({mutationFn:()=>ke.cancel(n.id),onSuccess:()=>{c.invalidateQueries({queryKey:f.heartbeats(n.companyId,n.agentId)})}}),z=n.errorCode==="process_lost"&&n.status==="failed",M=(0,i.useMemo)(()=>{const d={resumeFromRunId:n.id},w=Te(n.contextSnapshot);if(!w)return d;const B=L(w.issueId),fe=L(w.taskId),ue=L(w.taskKey),D=L(w.wakeCommentId)??L(w.commentId);return B&&(d.issueId=B),fe&&(d.taskId=fe),ue&&(d.taskKey=ue),D&&(d.commentId=D),d},[n.contextSnapshot,n.id]),v=Y({mutationFn:async()=>{const d=await X.wakeup(n.agentId,{source:"on_demand",triggerDetail:"manual",reason:"resume_process_lost_run",payload:M},n.companyId);if(!("id"in d))throw new Error(d.message??"Resume request was skipped.");return d},onSuccess:d=>{c.invalidateQueries({queryKey:f.heartbeats(n.companyId,n.agentId)}),g(`/agents/${s}/runs/${d.id}`)}}),V=n.status==="failed"||n.status==="timed_out",oe=(0,i.useMemo)(()=>{const d={},w=Te(n.contextSnapshot);if(!w)return d;const B=L(w.issueId),fe=L(w.taskId),ue=L(w.taskKey);return B&&(d.issueId=B),fe&&(d.taskId=fe),ue&&(d.taskKey=ue),d},[n.contextSnapshot]),te=Y({mutationFn:async()=>{const d=await X.wakeup(n.agentId,{source:"on_demand",triggerDetail:"manual",reason:"retry_failed_run",payload:oe},n.companyId);if(!("id"in d))throw new Error(d.message??"Retry was skipped.");return d},onSuccess:d=>{c.invalidateQueries({queryKey:f.heartbeats(n.companyId,n.agentId)}),g(`/agents/${s}/runs/${d.id}`)}}),{data:re}=H({queryKey:f.runIssues(n.id),queryFn:()=>os.issuesForRun(n.id)}),ee=(0,i.useMemo)(()=>Array.from(new Set((re??[]).map(d=>d.issueId))),[re]),k=Y({mutationFn:async()=>ee.length===0?0:(await Promise.all(ee.map(d=>X.resetSession(n.agentId,d,n.companyId))),ee.length),onSuccess:()=>{c.invalidateQueries({queryKey:f.agents.runtimeState(n.agentId)}),c.invalidateQueries({queryKey:f.agents.taskSessions(n.agentId)}),c.invalidateQueries({queryKey:f.runIssues(n.id)})}}),J=Y({mutationFn:()=>X.loginWithClaude(n.agentId,n.companyId),onSuccess:d=>{m(d)}}),se=n.status==="running"&&!!n.startedAt&&!n.finishedAt,[G,ae]=(0,i.useState)(()=>n.startedAt?Math.max(0,Math.round((Date.now()-new Date(n.startedAt).getTime())/1e3)):0);(0,i.useEffect)(()=>{if(!se||!n.startedAt)return;const d=new Date(n.startedAt).getTime();ae(Math.max(0,Math.round((Date.now()-d)/1e3)));const w=setInterval(()=>{ae(Math.max(0,Math.round((Date.now()-d)/1e3)))},1e3);return()=>clearInterval(w)},[se,n.startedAt]);const T={hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},a=n.startedAt?new Date(n.startedAt).toLocaleTimeString("en-US",T):null,ge=n.finishedAt?new Date(n.finishedAt).toLocaleTimeString("en-US",T):null,ie=(n.startedAt&&n.finishedAt?Math.round((new Date(n.finishedAt).getTime()-new Date(n.startedAt).getTime())/1e3):null)??(se?G:null),h=b.input>0||b.output>0||b.cached>0||b.cost>0,j=!!(n.sessionIdBefore||n.sessionIdAfter),Q=n.sessionIdBefore&&n.sessionIdAfter&&n.sessionIdBefore!==n.sessionIdAfter;n.sessionIdAfter||n.sessionIdBefore;const R=n.exitCode!==null&&n.exitCode!==0,U=ns(n);return(0,e.jsxs)("div",{className:"space-y-4 min-w-0",children:[(0,e.jsx)(ln,{run:n}),(0,e.jsxs)("div",{className:"border border-border rounded-lg overflow-hidden",children:[(0,e.jsxs)("div",{className:"flex flex-col sm:flex-row",children:[(0,e.jsxs)("div",{className:"flex-1 p-4 space-y-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Xe,{status:n.status}),(n.status==="running"||n.status==="queued")&&(0,e.jsx)($,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive text-xs h-6 px-2",onClick:()=>P.mutate(),disabled:P.isPending,children:P.isPending?"Cancelling…":"Cancel"}),z&&(0,e.jsxs)($,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:()=>v.mutate(),disabled:v.isPending,children:[(0,e.jsx)(gt,{className:"h-3.5 w-3.5 mr-1"}),v.isPending?"Resuming…":"Resume"]}),V&&!z&&(0,e.jsxs)($,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:()=>te.mutate(),disabled:te.isPending,children:[(0,e.jsx)(gt,{className:"h-3.5 w-3.5 mr-1"}),te.isPending?"Retrying…":"Retry"]})]}),(()=>{const d=b.provider??L(l?.provider),w=b.model??L(l?.model);return!r&&!d&&!w?null:(0,e.jsxs)("div",{className:"text-(length:--text-micro) text-muted-foreground font-mono flex items-center gap-1.5 flex-wrap",children:[r&&(0,e.jsx)("span",{className:"bg-muted rounded px-1.5 py-0.5 text-(length:--text-nano) font-medium uppercase tracking-wide",children:r.replace(/_/g," ")}),d&&w&&(0,e.jsxs)("span",{children:[d,"/",w]}),!d&&w&&(0,e.jsx)("span",{children:w})]})})(),n.responsibleUserId&&(0,e.jsxs)("div",{"data-testid":"run-detail-on-behalf-of",className:"text-xs text-muted-foreground",children:["On behalf of"," ",(0,e.jsx)("span",{className:"text-foreground",children:C??Zt(null)})]}),v.isError&&(0,e.jsx)("div",{className:"text-xs text-destructive",children:v.error instanceof Error?v.error.message:"Failed to resume run"}),te.isError&&(0,e.jsx)("div",{className:"text-xs text-destructive",children:te.error instanceof Error?te.error.message:"Failed to retry run"}),a&&(0,e.jsxs)("div",{className:"space-y-0.5",children:[(0,e.jsxs)("div",{className:"text-sm font-mono",children:[a,ge&&(0,e.jsx)("span",{className:"text-muted-foreground",children:" → "}),ge]}),(0,e.jsxs)("div",{className:"text-(length:--text-micro) text-muted-foreground",children:[Ke(n.startedAt),n.finishedAt&&(0,e.jsxs)(e.Fragment,{children:[" → ",Ke(n.finishedAt)]})]}),ie!==null&&(0,e.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Duration: ",ie>=60?`${Math.floor(ie/60)}m ${ie%60}s`:`${ie}s`]})]}),n.error&&(0,e.jsxs)("div",{className:"text-xs",children:[(0,e.jsx)("span",{className:"text-red-600 dark:text-red-400",children:n.error}),n.errorCode&&(0,e.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",n.errorCode,")"]})]}),n.errorCode==="claude_auth_required"&&r==="claude_local"&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)($,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>J.mutate(),disabled:J.isPending,children:J.isPending?"Running claude login...":"Login to Claude Code"}),J.isError&&(0,e.jsx)("p",{className:"text-xs text-destructive",children:J.error instanceof Error?J.error.message:"Failed to run Claude login"}),I?.loginUrl&&(0,e.jsxs)("p",{className:"text-xs",children:["Login URL:",(0,e.jsx)("a",{href:I.loginUrl,className:"text-blue-600 underline underline-offset-2 ml-1 break-all dark:text-blue-400",target:"_blank",rel:"noreferrer",children:I.loginUrl})]}),I&&(0,e.jsxs)(e.Fragment,{children:[!!I.stdout&&(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-foreground overflow-x-auto whitespace-pre-wrap",children:I.stdout}),!!I.stderr&&(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-red-700 dark:text-red-300 overflow-x-auto whitespace-pre-wrap",children:I.stderr})]})]}),E&&(0,e.jsx)(fn,{code:E,userName:C}),R&&(0,e.jsxs)("div",{className:"text-xs text-red-600 dark:text-red-400",children:["Exit code ",n.exitCode,n.signal&&(0,e.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(signal: ",n.signal,")"]})]}),U&&(0,e.jsxs)("div",{className:"rounded-md border border-border/70 bg-accent/20 px-3 py-2 text-xs leading-5",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:ce("rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",U.tone),children:U.badgeLabel}),U.retryOfRunId?(0,e.jsx)(Fe,{to:`/agents/${s}/runs/${U.retryOfRunId}`,className:"font-mono text-foreground hover:underline",children:U.retryOfRunId.slice(0,8)}):null]}),U.detail?(0,e.jsx)("p",{className:"mt-2 text-muted-foreground",children:U.detail}):null,U.secondary?(0,e.jsx)("p",{className:"text-muted-foreground",children:U.secondary}):null]})]}),h&&(0,e.jsxs)("div",{className:"border-t sm:border-t-0 sm:border-l border-border p-4 grid grid-cols-2 gap-x-4 sm:gap-x-8 gap-y-3 content-center tabular-nums",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Input"}),(0,e.jsx)("div",{className:"text-sm font-medium font-mono",children:Ee(b.input)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Output"}),(0,e.jsx)("div",{className:"text-sm font-medium font-mono",children:Ee(b.output)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Cached"}),(0,e.jsx)("div",{className:"text-sm font-medium font-mono",children:Ee(b.cached)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{className:"text-xs text-muted-foreground",children:"Cost"}),(0,e.jsx)("div",{className:"text-sm font-medium font-mono",children:b.cost>0?`$${b.cost.toFixed(4)}`:"-"})]})]})]}),j&&(0,e.jsxs)("div",{className:"border-t border-border",children:[(0,e.jsxs)("button",{className:"flex items-center gap-1.5 w-full px-4 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>O(d=>!d),children:[(0,e.jsx)(tt,{className:ce("h-3 w-3 transition-transform",F&&"rotate-90")}),"Session",Q&&(0,e.jsx)("span",{className:"text-yellow-400 ml-1",children:"(changed)"})]}),F&&(0,e.jsxs)("div",{className:"px-4 pb-3 space-y-1 text-xs",children:[n.sessionIdBefore&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground w-12",children:Q?"Before":"ID"}),(0,e.jsx)($e,{text:n.sessionIdBefore,className:"font-mono"})]}),Q&&n.sessionIdAfter&&(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-muted-foreground w-12",children:"After"}),(0,e.jsx)($e,{text:n.sessionIdAfter,className:"font-mono"})]}),ee.length>0&&(0,e.jsxs)("div",{className:"pt-1",children:[(0,e.jsx)("button",{type:"button",className:"text-(length:--text-micro) text-muted-foreground underline underline-offset-2 hover:text-foreground disabled:opacity-60",disabled:k.isPending,onClick:()=>{const d=ee.length;window.confirm(`Clear session for ${d} issue${d===1?"":"s"} touched by this run?`)&&k.mutate()},children:k.isPending?"clearing session...":"clear session for these tasks"}),k.isError&&(0,e.jsx)("p",{className:"text-(length:--text-micro) text-destructive mt-1",children:k.error instanceof Error?k.error.message:"Failed to clear sessions"})]})]})]})]}),re&&re.length>0&&(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("span",{className:"text-xs font-medium text-muted-foreground",children:["Tasks Touched (",re.length,")"]}),(0,e.jsx)("div",{className:"border border-border rounded-lg divide-y divide-border",children:re.map(d=>(0,e.jsxs)(Fe,{to:`/issues/${d.identifier??d.issueId}`,className:"flex items-center justify-between w-full px-3 py-2 text-xs hover:bg-accent/20 transition-colors text-left no-underline text-inherit",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,e.jsx)(Xe,{status:d.status}),(0,e.jsx)("span",{className:"truncate",children:d.title})]}),(0,e.jsx)("span",{className:"font-mono text-muted-foreground shrink-0 ml-2",children:d.identifier??d.issueId.slice(0,8)})]},d.issueId))})]}),n.stderrExcerpt&&(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-red-600 dark:text-red-400",children:"stderr"}),(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-red-700 dark:text-red-300 overflow-x-auto whitespace-pre-wrap",children:n.stderrExcerpt})]}),n.stdoutExcerpt&&!n.logRef&&(0,e.jsxs)("div",{className:"space-y-1",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"stdout"}),(0,e.jsx)("pre",{className:"bg-neutral-100 dark:bg-neutral-950 rounded-md p-3 text-xs font-mono text-foreground overflow-x-auto whitespace-pre-wrap",children:n.stdoutExcerpt})]}),(()=>{const d=Lt(n.resultJson);return!d||n.status==="failed"||n.status==="timed_out"?null:(0,e.jsx)(qs,{fold:d,finalizedAt:n.finishedAt})})(),(0,e.jsx)(Zn,{run:n,adapterType:r}),(0,e.jsx)(Ws,{})]})}function Zn({run:t,adapterType:s}){const[r,l]=(0,i.useState)([]),[c,g]=(0,i.useState)([]),[p,n]=(0,i.useState)(!0),[b,y]=(0,i.useState)(!!t.logRef),[C,E]=(0,i.useState)(null),[F,O]=(0,i.useState)(0),[I,m]=(0,i.useState)(!1),[P,z]=(0,i.useState)(!1),[M,v]=(0,i.useState)(!1),[V,oe]=(0,i.useState)(!1),[te,re]=(0,i.useState)("nice"),ee=(0,i.useRef)(null),k=(0,i.useRef)(""),J=(0,i.useRef)(new Set),se=(0,i.useRef)(null),G=(0,i.useRef)(!1),ae=(0,i.useRef)({scrollHeight:0,distanceFromBottom:Number.POSITIVE_INFINITY}),T=t.status==="running"||t.status==="queued",a=qn(t.status),{data:ge=[]}=H({queryKey:f.runWorkspaceOperations(t.id),queryFn:()=>ke.workspaceOperations(t.id),refetchInterval:T?2e3:!1});function ie(x){return x instanceof Ct&&x.status===404}function h(x,A=!1){if(!x&&!A)return;const S=`${k.current}${x}`.split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{i as le}from"./rolldown-runtime-BQ-vy_Pv.js";import{S as F,U as Le,_ as oe,fr as Pe,g as z,jn as j,nn as ke,q as N,ur as qe,z as Me}from"./createLucideIcon-JUO5qdpL.js";import{t as Re}from"./preload-helper-BATLnrmA.js";import{it as Be,o as Fe,t as ce}from"./router-Dr6qx_6q.js";import{P as ne,S as $e}from"./zap-RUrW_UgS.js";import{t as Ke}from"./tabs-B-hJilg9.js";import{n as De}from"./BreadcrumbContext-D3CAiFzt.js";import{A as Oe,t as U}from"./button-DWgQnsK-.js";import{t as ae}from"./agents-yMBk3d4f.js";import{n as ze}from"./adapter-display-registry-Bk0UWNp2.js";import{i as Ue,t as Ve}from"./heartbeats-DfIQjGVE.js";import{t as ue}from"./triangle-alert-DEq939Ib.js";import{n as de,t as V}from"./StatusBadge-DJIFeD5T.js";import{t as He}from"./PageSkeleton-DYqd8XzH.js";import{Bn as Ge,Gt as me,Hn as H,Jn as Qe,Kn as Je,Kt as We,Nn as Ye,Rn as pe,Un as Xe,Vn as ge,Wn as Ze,Wt as et,Yn as tt,an as st,fr as nt,hn as re,on as ie,qn as xe,zn as at}from"./index-wPK2Q9gC.js";var p=le(Pe(),1),t=le(qe(),1),fe=ke,rt=(0,p.lazy)(()=>Re(()=>import("./index-wPK2Q9gC.js").then(e=>e.Vt).then(e=>({default:e.ConfigureBuiltInAgentModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),it=["all","active","paused","error","builtin"],lt=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"},{value:"builtin",label:"Built-in"}];function ot(e){return it.includes(e)}var Q={label:"Local",detail:"Paperclip host",title:"Local - Paperclip host"},he={label:"—",detail:"Loading environment",title:"Loading environment"},ve=new Set(["terminated","pending_approval"]);function be(e,n){return n==="all"?!0:n==="active"?e==="active"||e==="running"||e==="idle":n==="paused"?e==="paused":n==="error"?e==="error":!0}function ct(e,n,r){return e.filter(a=>ve.has(a.status)?!1:n==="builtin"?r.has(a.id):be(a.status,n)).sort((a,i)=>a.name.localeCompare(i.name))}function ut(e){const n=e.adapterConfig?.model;if(typeof n!="string")return null;const r=n.trim();return r.length>0?r:null}function dt(e){return e==="ssh"?"SSH":e.charAt(0).toUpperCase()+e.slice(1)}function mt(e,n){const r=typeof e.config.provider=="string"?e.config.provider.trim():"";return r?n?.sandboxProviders?.[r]?.displayName??r:"Sandbox"}function pt(e,n){const r=st(e)?"Managed by Paperclip":e.driver==="sandbox"?`${mt(e,n)} sandbox provider`:e.driver==="local"?"Paperclip host":dt(e.driver);return{label:e.name,detail:r,title:`${e.name} - ${r}`}}function gt(e){return{label:"Unknown environment",detail:e.slice(0,8),title:`Unknown environment - ${e}`}}function xt(e,n,r,a){const i=e.defaultEnvironmentId??r;if(!i)return Q;const g=n.get(i);return g?pt(g,a):gt(i)}function je(e,n,r){return e.reduce((a,i)=>{const g=je(i.reports,n,r);return ve.has(i.status)?(a.push(...g),a):(((n==="builtin"?r.has(i.id):be(i.status,n))||g.length>0)&&a.push({...i,reports:g}),a)},[]).sort((a,i)=>a.name.localeCompare(i.name))}function Lt(){const{selectedCompanyId:e}=Le(),{openNewAgent:n}=Ue(),{setBreadcrumbs:r}=De(),a=Fe(),i=Be(),{isMobile:g}=tt(),C=i.pathname.split("/").pop()??"all",h=ot(C)?C:"all",[S,d]=(0,p.useState)("org"),A=g,m=A?"list":S,{data:l}=j({queryKey:N.instance.settings,queryFn:()=>Je.get(),enabled:!!e}),u=l?.experimental.enableBuiltInAgents===!0,f=h==="builtin"&&!u?"all":h,$=(0,p.useMemo)(()=>lt.filter(s=>s.value!=="builtin"||u),[u]),{data:_}=j({queryKey:N.builtInAgents.list(e),queryFn:()=>Qe.list(e),enabled:!!e&&u}),v=(0,p.useMemo)(()=>{const s=new Map;if(!u)return s;for(const o of _??[])o.agentId&&s.set(o.agentId,o);return s},[_,u]),k=(0,p.useMemo)(()=>new Set(v.keys()),[v]),[y,E]=(0,p.useState)(null),{data:c,isLoading:we,error:J}=j({queryKey:N.agents.list(e),queryFn:()=>ae.list(e),enabled:!!e}),{data:T}=j({queryKey:N.org(e),queryFn:()=>ae.org(e),enabled:!!e&&m==="org"}),q=l?.experimental.enableEnvironments===!0,{data:L}=j({queryKey:N.environments.list(e),queryFn:()=>ie.list(e),enabled:!!e&&q}),{data:W}=j({queryKey:N.environments.capabilities(e),queryFn:()=>ie.capabilities(e),enabled:!!e&&q}),Y=[...N.liveRuns(e),"agents-page"],K=Ge({companyId:e,resourceKey:"live-runs:agents-page",queryKey:Y,enabled:!!e,refetchInterval:15e3,leaderOnly:!0}),{data:D,dataUpdatedAt:Ie}=j({queryKey:Y,queryFn:()=>Ve.liveRunsForCompany(e),enabled:K.enabled,refetchInterval:K.refetchInterval});at(K,D,Ie);const M=Ze(e),x=Xe(e),R=(0,p.useMemo)(()=>{const s=new Map;for(const o of D??[]){if(o.status!=="running"&&o.status!=="queued")continue;const P=s.get(o.agentId);if(P){P.liveCount+=1;continue}s.set(o.agentId,{runId:o.id,liveCount:1})}return s},[D]),Ce=(0,p.useMemo)(()=>{const s=new Map;for(const o of c??[])s.set(o.id,o);return s},[c]),X=(0,p.useMemo)(()=>{const s=new Map;for(const o of L??[])s.set(o.id,o);return s},[L]),Z=(0,p.useMemo)(()=>{const s=new Map;for(const o of c??[])s.set(o.id,xt(o,X,l?.defaultEnvironmentId??null,W));return s},[c,X,W,l?.defaultEnvironmentId]);if((0,p.useEffect)(()=>{r([{label:"Agents"}])},[r]),(0,p.useEffect)(()=>{e&&h==="builtin"&&l&&!u&&a("/agents/all",{replace:!0})},[u,l,a,h,e]),!e)return(0,t.jsx)(re,{icon:ne,message:"Select a company to view agents."});if(we)return(0,t.jsx)(He,{variant:"list"});const w=ct(c??[],f,k),O=je(T??[],f,k),ee=q&&L===void 0,te=q&&(L===void 0||L.length>1),Se=s=>ee?he:Z.get(s)??Q,Ae=s=>{const o=s.orgChainHealth?.status==="invalid_org_chain",P=x.isPending&&x.variables?.resourceType==="agent"&&x.variables.resourceId===s.id,_e=P&&x.variables?.starred!==void 0,se=P&&x.variables?.starred===void 0,Ee=ge(M.data,"agent",s.id),I=v.get(s.id),Te=I?.status==="needs_setup"||I?.status==="pending_approval",B=I&&Te?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(xe,{status:I.status}),I.status==="needs_setup"&&(0,t.jsx)("span",{onClick:b=>{b.preventDefault(),b.stopPropagation()},children:(0,t.jsx)(U,{size:"xs",variant:"outline",onClick:()=>E(I),children:"Set up"})})]}):null;return(0,t.jsx)(et,{title:s.name,titleClassName:"flex-1 xl:flex-none xl:w-56",titleTextClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitleClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitle:`${fe[s.role]??s.role}${s.title?` - ${s.title}`:""}`,to:oe(s),className:F("group",s.pausedAt&&f!=="paused"?"opacity-50":"",H(M.data,"agent",s.id)==="left"?"sm:text-foreground/55":""),leading:o?(0,t.jsx)(ue,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(de,{status:s.status}),secondaryRow:B?(0,t.jsx)("div",{className:"xl:hidden flex flex-wrap items-center gap-1.5",children:B}):void 0,meta:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[B&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-1.5",children:B}),(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(ye,{agent:s,environment:Se(s.id),showEnvironment:te})})]}),metaSpacerClassName:"hidden xl:block",trailing:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[R.has(s.id)&&(0,t.jsx)(G,{agentRef:z(s),runId:R.get(s.id).runId,liveCount:R.get(s.id).liveCount}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(V,{status:s.status})}),(0,t.jsx)("div",{onClick:b=>{b.preventDefault(),b.stopPropagation()},children:(0,t.jsx)(We,{agent:s,companyId:e,runLabel:"Run Heartbeat",showStatus:!1})}),(0,t.jsx)(pe,{size:"row",starred:Ee,pending:_e,resourceName:s.name,onToggle:b=>x.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,starred:b})})]}),(0,t.jsx)(me,{state:H(M.data,"agent",s.id),pending:se,pendingState:se?x.variables?.state??null:null,resourceName:s.name,onJoin:()=>x.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"joined"}),onLeave:()=>x.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"left"})})]})},s.id)};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(Ke,{value:f,onValueChange:s=>a(`/agents/${s}`),children:(0,t.jsx)(Ye,{items:$,value:f,onValueChange:s=>a(`/agents/${s}`)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!A&&(0,t.jsxs)("div",{className:"flex items-center border border-border",role:"group","aria-label":"View mode",children:[(0,t.jsx)("button",{className:F("p-1.5 transition-colors",m==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:()=>d("list"),title:"List view","aria-label":"List view","aria-pressed":m==="list",children:(0,t.jsx)(nt,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{className:F("p-1.5 transition-colors",m==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:()=>d("org"),title:"Org chart view","aria-label":"Org chart view","aria-pressed":m==="org",children:(0,t.jsx)($e,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)(U,{size:"sm",variant:"outline",onClick:n,children:[(0,t.jsx)(Oe,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.length," agent",w.length!==1?"s":""]}),J&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:J.message}),c&&c.length===0&&(0,t.jsx)(re,{icon:ne,message:"Create your first agent to get started.",action:"New Agent",onAction:n}),m==="list"&&w.length>0&&(0,t.jsx)("div",{children:w.map(Ae)}),m==="list"&&c&&c.length>0&&w.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),m==="org"&&O.length>0&&(0,t.jsx)("div",{className:"py-1",children:O.map(s=>(0,t.jsx)(Ne,{node:s,depth:0,agentMap:Ce,liveRunByAgent:R,environmentByAgentId:Z,environmentDataLoading:ee,showEnvironment:te,tab:f,memberships:M.data,membershipMutation:x,builtInByAgentId:v,onConfigureBuiltIn:E},s.id))}),m==="org"&&T&&T.length>0&&O.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),m==="org"&&T&&T.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."}),y&&e&&(0,t.jsx)(p.Suspense,{fallback:null,children:(0,t.jsx)(rt,{companyId:e,state:y,open:y!==null,onOpenChange:s=>{s||E(null)}})})]})}function Ne({node:e,depth:n,agentMap:r,liveRunByAgent:a,environmentByAgentId:i,environmentDataLoading:g,showEnvironment:C,tab:h,memberships:S,membershipMutation:d,builtInByAgentId:A,onConfigureBuiltIn:m}){const l=r.get(e.id),u=A.get(e.id),f=u?.status==="needs_setup"||u?.status==="pending_approval",$=!!(l&&l.orgChainHealth?.status==="invalid_org_chain"),_=H(S,"agent",e.id),v=d.isPending&&d.variables?.resourceType==="agent"&&d.variables.resourceId===e.id,k=v&&d.variables?.starred!==void 0,y=v&&d.variables?.starred===void 0,E=ge(S,"agent",e.id);return(0,t.jsxs)("div",{style:{paddingLeft:n*24},children:[(0,t.jsxs)(ce,{to:l?oe(l):`/agents/${e.id}`,className:F("group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50 transition-colors w-full text-left no-underline text-inherit",l?.pausedAt&&h!=="paused"&&"opacity-50",_==="left"&&"sm:text-foreground/55"),children:[$?(0,t.jsx)(ue,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(de,{status:e.status}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"min-w-(--sz-7rem) truncate",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:[fe[e.role]??e.role,l?.title?` - ${l.title}`:""]})]}),u&&f&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(xe,{status:u.status}),u.status==="needs_setup"&&(0,t.jsx)("span",{onClick:c=>{c.preventDefault(),c.stopPropagation()},children:(0,t.jsx)(U,{size:"xs",variant:"outline",onClick:()=>m(u),children:"Set up"})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,t.jsx)("span",{className:"sm:hidden",children:a.has(e.id)?(0,t.jsx)(G,{agentRef:l?z(l):e.id,runId:a.get(e.id).runId,liveCount:a.get(e.id).liveCount}):(0,t.jsx)(V,{status:e.status})}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[a.has(e.id)&&(0,t.jsx)(G,{agentRef:l?z(l):e.id,runId:a.get(e.id).runId,liveCount:a.get(e.id).liveCount}),l&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(ye,{agent:l,environment:g?he:i.get(l.id)??Q,showEnvironment:C})}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(V,{status:e.status})})]}),(0,t.jsx)(me,{state:_,pending:y,pendingState:y?d.variables?.state:null,resourceName:e.name,onJoin:()=>d.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"joined"}),onLeave:()=>d.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"left"})}),(0,t.jsx)("div",{className:"hidden sm:flex items-center gap-3",children:(0,t.jsx)(pe,{size:"row",starred:E,pending:k,resourceName:e.name,onToggle:c=>d.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,starred:c})})})]})]}),e.reports&&e.reports.length>0&&(0,t.jsx)("div",{className:"border-l border-border ml-4",children:e.reports.map(c=>(0,t.jsx)(Ne,{node:c,depth:n+1,agentMap:r,liveRunByAgent:a,environmentByAgentId:i,environmentDataLoading:g,showEnvironment:C,tab:h,memberships:S,membershipMutation:d,builtInByAgentId:A,onConfigureBuiltIn:m},c.id))})]})}function ye({agent:e,environment:n,showEnvironment:r}){const a=ut(e),i=ze(e.adapterType);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:a??void 0,children:a??"—"}),(0,t.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground/70",title:i,children:i})]}),r&&(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:n.title,children:n.label}),(0,t.jsx)("div",{className:"truncate text-(length:--text-micro) text-muted-foreground/70",children:n.detail})]}),(0,t.jsx)("span",{className:"w-24 whitespace-nowrap text-right text-xs text-muted-foreground",children:e.lastHeartbeatAt?Me(e.lastHeartbeatAt):"—"})]})}function G({agentRef:e,runId:n,liveCount:r}){return(0,t.jsxs)(ce,{to:`/agents/${e}/runs/${n}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:a=>a.stopPropagation(),children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:["Live",r>1?` (${r})`:""]})]})}export{Lt as Agents};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BaG1tZj1.js","assets/rolldown-runtime-BQ-vy_Pv.js","assets/createLucideIcon-JUO5qdpL.js","assets/preload-helper-BATLnrmA.js","assets/router-Dr6qx_6q.js","assets/zap-RUrW_UgS.js","assets/BreadcrumbContext-D3CAiFzt.js","assets/button-DWgQnsK-.js","assets/agents-yMBk3d4f.js","assets/useQueries-DIf1clRN.js","assets/mention-chips-D8B6eEdr.js","assets/agent-icons-DvoCe7FN.js","assets/IssueRecoveryActionCard-i5qDYsKa.js","assets/recovery-display-DKT_Bqf8.js","assets/StatusIcon-CeMClGJ9.js","assets/clipboard-BCz9EG42.js","assets/key-round-gDAuHlTR.js","assets/octagon-alert-DsC0f8JM.js","assets/refresh-cw-DV-bSEwh.js","assets/triangle-alert-DEq939Ib.js","assets/checkbox-Bhf00Qhn.js","assets/dist-DxnSUuQs.js","assets/dist-G5LcQvNw.js","assets/MarkdownEditor-dns9I8bB.js","assets/dist-zTfCxzzX.js","assets/AgentIconPicker-B6761LdM.js","assets/input-DjyO-oZf.js","assets/dist-CQw_dTZw.js","assets/dist-gF1wAews.js","assets/check-BjBG4-fn.js","assets/chevron-right-BFXkqip_.js","assets/label-IDJ0nBXZ.js","assets/badge-CxX1YhiF.js","assets/alert-dialog-BE-LIUv_.js","assets/tabs-B-hJilg9.js","assets/proposal-review-DinROeYt.js","assets/chevron-down-CqCCAew2.js","assets/InlineBanner-C4MQkh4l.js","assets/trash-2-BEPrNbsT.js","assets/adapter-display-registry-Bk0UWNp2.js","assets/rotate-ccw-Cb9U93yr.js","assets/shield-alert-Dz2_CCm7.js","assets/ToastContext-Dmfqh1in.js","assets/CopyText-CuFpZ9d_.js","assets/circle-pause-KT5tfLvH.js","assets/external-link-DsqjvF7j.js","assets/MarkdownBody-CGVDfzLB.js","assets/sheet-CbxOKHRQ.js","assets/pause-DO_JBZWF.js","assets/heartbeats-DfIQjGVE.js","assets/StatusBadge-DJIFeD5T.js","assets/PageSkeleton-DYqd8XzH.js","assets/index-D3zUW2Jn.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as le}from"./rolldown-runtime-BQ-vy_Pv.js";import{S as F,U as Le,_ as oe,fr as Pe,g as z,jn as j,nn as ke,q as N,ur as qe,z as Me}from"./createLucideIcon-JUO5qdpL.js";import{t as Re}from"./preload-helper-BATLnrmA.js";import{it as Be,o as Fe,t as ce}from"./router-Dr6qx_6q.js";import{P as ne,S as $e}from"./zap-RUrW_UgS.js";import{t as Ke}from"./tabs-B-hJilg9.js";import{n as De}from"./BreadcrumbContext-D3CAiFzt.js";import{A as Oe,t as U}from"./button-DWgQnsK-.js";import{t as ae}from"./agents-yMBk3d4f.js";import{n as ze}from"./adapter-display-registry-Bk0UWNp2.js";import{i as Ue,t as Ve}from"./heartbeats-DfIQjGVE.js";import{t as ue}from"./triangle-alert-DEq939Ib.js";import{n as de,t as V}from"./StatusBadge-DJIFeD5T.js";import{t as He}from"./PageSkeleton-DYqd8XzH.js";import{Bn as Ge,Gt as me,Hn as H,Jn as Qe,Kn as Je,Kt as We,Nn as Ye,Rn as pe,Un as Xe,Vn as ge,Wn as Ze,Wt as et,Yn as tt,an as st,fr as nt,hn as re,on as ie,qn as xe,zn as at}from"./index-BaG1tZj1.js";var p=le(Pe(),1),t=le(qe(),1),fe=ke,rt=(0,p.lazy)(()=>Re(()=>import("./index-BaG1tZj1.js").then(e=>e.Vt).then(e=>({default:e.ConfigureBuiltInAgentModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52]))),it=["all","active","paused","error","builtin"],lt=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"},{value:"builtin",label:"Built-in"}];function ot(e){return it.includes(e)}var Q={label:"Local",detail:"Paperclip host",title:"Local - Paperclip host"},he={label:"—",detail:"Loading environment",title:"Loading environment"},ve=new Set(["terminated","pending_approval"]);function be(e,n){return n==="all"?!0:n==="active"?e==="active"||e==="running"||e==="idle":n==="paused"?e==="paused":n==="error"?e==="error":!0}function ct(e,n,r){return e.filter(a=>ve.has(a.status)?!1:n==="builtin"?r.has(a.id):be(a.status,n)).sort((a,i)=>a.name.localeCompare(i.name))}function ut(e){const n=e.adapterConfig?.model;if(typeof n!="string")return null;const r=n.trim();return r.length>0?r:null}function dt(e){return e==="ssh"?"SSH":e.charAt(0).toUpperCase()+e.slice(1)}function mt(e,n){const r=typeof e.config.provider=="string"?e.config.provider.trim():"";return r?n?.sandboxProviders?.[r]?.displayName??r:"Sandbox"}function pt(e,n){const r=st(e)?"Managed by Paperclip":e.driver==="sandbox"?`${mt(e,n)} sandbox provider`:e.driver==="local"?"Paperclip host":dt(e.driver);return{label:e.name,detail:r,title:`${e.name} - ${r}`}}function gt(e){return{label:"Unknown environment",detail:e.slice(0,8),title:`Unknown environment - ${e}`}}function xt(e,n,r,a){const i=e.defaultEnvironmentId??r;if(!i)return Q;const g=n.get(i);return g?pt(g,a):gt(i)}function je(e,n,r){return e.reduce((a,i)=>{const g=je(i.reports,n,r);return ve.has(i.status)?(a.push(...g),a):(((n==="builtin"?r.has(i.id):be(i.status,n))||g.length>0)&&a.push({...i,reports:g}),a)},[]).sort((a,i)=>a.name.localeCompare(i.name))}function Lt(){const{selectedCompanyId:e}=Le(),{openNewAgent:n}=Ue(),{setBreadcrumbs:r}=De(),a=Fe(),i=Be(),{isMobile:g}=tt(),C=i.pathname.split("/").pop()??"all",h=ot(C)?C:"all",[S,d]=(0,p.useState)("org"),A=g,m=A?"list":S,{data:l}=j({queryKey:N.instance.settings,queryFn:()=>Je.get(),enabled:!!e}),u=l?.experimental.enableBuiltInAgents===!0,f=h==="builtin"&&!u?"all":h,$=(0,p.useMemo)(()=>lt.filter(s=>s.value!=="builtin"||u),[u]),{data:_}=j({queryKey:N.builtInAgents.list(e),queryFn:()=>Qe.list(e),enabled:!!e&&u}),v=(0,p.useMemo)(()=>{const s=new Map;if(!u)return s;for(const o of _??[])o.agentId&&s.set(o.agentId,o);return s},[_,u]),k=(0,p.useMemo)(()=>new Set(v.keys()),[v]),[y,E]=(0,p.useState)(null),{data:c,isLoading:we,error:J}=j({queryKey:N.agents.list(e),queryFn:()=>ae.list(e),enabled:!!e}),{data:T}=j({queryKey:N.org(e),queryFn:()=>ae.org(e),enabled:!!e&&m==="org"}),q=l?.experimental.enableEnvironments===!0,{data:L}=j({queryKey:N.environments.list(e),queryFn:()=>ie.list(e),enabled:!!e&&q}),{data:W}=j({queryKey:N.environments.capabilities(e),queryFn:()=>ie.capabilities(e),enabled:!!e&&q}),Y=[...N.liveRuns(e),"agents-page"],K=Ge({companyId:e,resourceKey:"live-runs:agents-page",queryKey:Y,enabled:!!e,refetchInterval:15e3,leaderOnly:!0}),{data:D,dataUpdatedAt:Ie}=j({queryKey:Y,queryFn:()=>Ve.liveRunsForCompany(e),enabled:K.enabled,refetchInterval:K.refetchInterval});at(K,D,Ie);const M=Ze(e),x=Xe(e),R=(0,p.useMemo)(()=>{const s=new Map;for(const o of D??[]){if(o.status!=="running"&&o.status!=="queued")continue;const P=s.get(o.agentId);if(P){P.liveCount+=1;continue}s.set(o.agentId,{runId:o.id,liveCount:1})}return s},[D]),Ce=(0,p.useMemo)(()=>{const s=new Map;for(const o of c??[])s.set(o.id,o);return s},[c]),X=(0,p.useMemo)(()=>{const s=new Map;for(const o of L??[])s.set(o.id,o);return s},[L]),Z=(0,p.useMemo)(()=>{const s=new Map;for(const o of c??[])s.set(o.id,xt(o,X,l?.defaultEnvironmentId??null,W));return s},[c,X,W,l?.defaultEnvironmentId]);if((0,p.useEffect)(()=>{r([{label:"Agents"}])},[r]),(0,p.useEffect)(()=>{e&&h==="builtin"&&l&&!u&&a("/agents/all",{replace:!0})},[u,l,a,h,e]),!e)return(0,t.jsx)(re,{icon:ne,message:"Select a company to view agents."});if(we)return(0,t.jsx)(He,{variant:"list"});const w=ct(c??[],f,k),O=je(T??[],f,k),ee=q&&L===void 0,te=q&&(L===void 0||L.length>1),Se=s=>ee?he:Z.get(s)??Q,Ae=s=>{const o=s.orgChainHealth?.status==="invalid_org_chain",P=x.isPending&&x.variables?.resourceType==="agent"&&x.variables.resourceId===s.id,_e=P&&x.variables?.starred!==void 0,se=P&&x.variables?.starred===void 0,Ee=ge(M.data,"agent",s.id),I=v.get(s.id),Te=I?.status==="needs_setup"||I?.status==="pending_approval",B=I&&Te?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(xe,{status:I.status}),I.status==="needs_setup"&&(0,t.jsx)("span",{onClick:b=>{b.preventDefault(),b.stopPropagation()},children:(0,t.jsx)(U,{size:"xs",variant:"outline",onClick:()=>E(I),children:"Set up"})})]}):null;return(0,t.jsx)(et,{title:s.name,titleClassName:"flex-1 xl:flex-none xl:w-56",titleTextClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitleClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitle:`${fe[s.role]??s.role}${s.title?` - ${s.title}`:""}`,to:oe(s),className:F("group",s.pausedAt&&f!=="paused"?"opacity-50":"",H(M.data,"agent",s.id)==="left"?"sm:text-foreground/55":""),leading:o?(0,t.jsx)(ue,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(de,{status:s.status}),secondaryRow:B?(0,t.jsx)("div",{className:"xl:hidden flex flex-wrap items-center gap-1.5",children:B}):void 0,meta:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[B&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-1.5",children:B}),(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(ye,{agent:s,environment:Se(s.id),showEnvironment:te})})]}),metaSpacerClassName:"hidden xl:block",trailing:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[R.has(s.id)&&(0,t.jsx)(G,{agentRef:z(s),runId:R.get(s.id).runId,liveCount:R.get(s.id).liveCount}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(V,{status:s.status})}),(0,t.jsx)("div",{onClick:b=>{b.preventDefault(),b.stopPropagation()},children:(0,t.jsx)(We,{agent:s,companyId:e,runLabel:"Run Heartbeat",showStatus:!1})}),(0,t.jsx)(pe,{size:"row",starred:Ee,pending:_e,resourceName:s.name,onToggle:b=>x.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,starred:b})})]}),(0,t.jsx)(me,{state:H(M.data,"agent",s.id),pending:se,pendingState:se?x.variables?.state??null:null,resourceName:s.name,onJoin:()=>x.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"joined"}),onLeave:()=>x.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"left"})})]})},s.id)};return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(Ke,{value:f,onValueChange:s=>a(`/agents/${s}`),children:(0,t.jsx)(Ye,{items:$,value:f,onValueChange:s=>a(`/agents/${s}`)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!A&&(0,t.jsxs)("div",{className:"flex items-center border border-border",role:"group","aria-label":"View mode",children:[(0,t.jsx)("button",{className:F("p-1.5 transition-colors",m==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:()=>d("list"),title:"List view","aria-label":"List view","aria-pressed":m==="list",children:(0,t.jsx)(nt,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{className:F("p-1.5 transition-colors",m==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:()=>d("org"),title:"Org chart view","aria-label":"Org chart view","aria-pressed":m==="org",children:(0,t.jsx)($e,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)(U,{size:"sm",variant:"outline",onClick:n,children:[(0,t.jsx)(Oe,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.length," agent",w.length!==1?"s":""]}),J&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:J.message}),c&&c.length===0&&(0,t.jsx)(re,{icon:ne,message:"Create your first agent to get started.",action:"New Agent",onAction:n}),m==="list"&&w.length>0&&(0,t.jsx)("div",{children:w.map(Ae)}),m==="list"&&c&&c.length>0&&w.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),m==="org"&&O.length>0&&(0,t.jsx)("div",{className:"py-1",children:O.map(s=>(0,t.jsx)(Ne,{node:s,depth:0,agentMap:Ce,liveRunByAgent:R,environmentByAgentId:Z,environmentDataLoading:ee,showEnvironment:te,tab:f,memberships:M.data,membershipMutation:x,builtInByAgentId:v,onConfigureBuiltIn:E},s.id))}),m==="org"&&T&&T.length>0&&O.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),m==="org"&&T&&T.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."}),y&&e&&(0,t.jsx)(p.Suspense,{fallback:null,children:(0,t.jsx)(rt,{companyId:e,state:y,open:y!==null,onOpenChange:s=>{s||E(null)}})})]})}function Ne({node:e,depth:n,agentMap:r,liveRunByAgent:a,environmentByAgentId:i,environmentDataLoading:g,showEnvironment:C,tab:h,memberships:S,membershipMutation:d,builtInByAgentId:A,onConfigureBuiltIn:m}){const l=r.get(e.id),u=A.get(e.id),f=u?.status==="needs_setup"||u?.status==="pending_approval",$=!!(l&&l.orgChainHealth?.status==="invalid_org_chain"),_=H(S,"agent",e.id),v=d.isPending&&d.variables?.resourceType==="agent"&&d.variables.resourceId===e.id,k=v&&d.variables?.starred!==void 0,y=v&&d.variables?.starred===void 0,E=ge(S,"agent",e.id);return(0,t.jsxs)("div",{style:{paddingLeft:n*24},children:[(0,t.jsxs)(ce,{to:l?oe(l):`/agents/${e.id}`,className:F("group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50 transition-colors w-full text-left no-underline text-inherit",l?.pausedAt&&h!=="paused"&&"opacity-50",_==="left"&&"sm:text-foreground/55"),children:[$?(0,t.jsx)(ue,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(de,{status:e.status}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"min-w-(--sz-7rem) truncate",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:[fe[e.role]??e.role,l?.title?` - ${l.title}`:""]})]}),u&&f&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(xe,{status:u.status}),u.status==="needs_setup"&&(0,t.jsx)("span",{onClick:c=>{c.preventDefault(),c.stopPropagation()},children:(0,t.jsx)(U,{size:"xs",variant:"outline",onClick:()=>m(u),children:"Set up"})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,t.jsx)("span",{className:"sm:hidden",children:a.has(e.id)?(0,t.jsx)(G,{agentRef:l?z(l):e.id,runId:a.get(e.id).runId,liveCount:a.get(e.id).liveCount}):(0,t.jsx)(V,{status:e.status})}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[a.has(e.id)&&(0,t.jsx)(G,{agentRef:l?z(l):e.id,runId:a.get(e.id).runId,liveCount:a.get(e.id).liveCount}),l&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(ye,{agent:l,environment:g?he:i.get(l.id)??Q,showEnvironment:C})}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(V,{status:e.status})})]}),(0,t.jsx)(me,{state:_,pending:y,pendingState:y?d.variables?.state:null,resourceName:e.name,onJoin:()=>d.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"joined"}),onLeave:()=>d.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"left"})}),(0,t.jsx)("div",{className:"hidden sm:flex items-center gap-3",children:(0,t.jsx)(pe,{size:"row",starred:E,pending:k,resourceName:e.name,onToggle:c=>d.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,starred:c})})})]})]}),e.reports&&e.reports.length>0&&(0,t.jsx)("div",{className:"border-l border-border ml-4",children:e.reports.map(c=>(0,t.jsx)(Ne,{node:c,depth:n+1,agentMap:r,liveRunByAgent:a,environmentByAgentId:i,environmentDataLoading:g,showEnvironment:C,tab:h,memberships:S,membershipMutation:d,builtInByAgentId:A,onConfigureBuiltIn:m},c.id))})]})}function ye({agent:e,environment:n,showEnvironment:r}){const a=ut(e),i=ze(e.adapterType);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:a??void 0,children:a??"—"}),(0,t.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground/70",title:i,children:i})]}),r&&(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:n.title,children:n.label}),(0,t.jsx)("div",{className:"truncate text-(length:--text-micro) text-muted-foreground/70",children:n.detail})]}),(0,t.jsx)("span",{className:"w-24 whitespace-nowrap text-right text-xs text-muted-foreground",children:e.lastHeartbeatAt?Me(e.lastHeartbeatAt):"—"})]})}function G({agentRef:e,runId:n,liveCount:r}){return(0,t.jsxs)(ce,{to:`/agents/${e}/runs/${n}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:a=>a.stopPropagation(),children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:["Live",r>1?` (${r})`:""]})]})}export{Lt as Agents};
|
package/ui-dist/assets/{AuditFeed.production-aTPg8e1s.js → AuditFeed.production-BIggihG-.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as ae}from"./rolldown-runtime-BQ-vy_Pv.js";import{S as me,Tn as J,fr as xe,jn as W,q as G,ur as pe,z as he}from"./createLucideIcon-JUO5qdpL.js";import{t as ne}from"./router-Dr6qx_6q.js";import{i as X,r as ge,t as fe}from"./tabs-B-hJilg9.js";import{t as T}from"./button-DWgQnsK-.js";import{t as ve}from"./agents-yMBk3d4f.js";import{t as ye}from"./shield-alert-Dz2_CCm7.js";import{i as je}from"./ToastContext-Dmfqh1in.js";import{t as ee}from"./input-DjyO-oZf.js";import{t as be}from"./AgentIconPicker-B6761LdM.js";import{Ar as Ne,In as we,On as Te,Ot as te,_n as v,cn as D,dn as F,jn as se,ln as f,nn as Ae,sn as L,tr as Se,un as R,vn as y,yr as Ce}from"./index-wPK2Q9gC.js";var l=ae(xe(),1),e=ae(pe(),1),Ee=50,n="__all",Ie=[{value:n,label:"All actions"},{value:"issue.",label:"Tasks"},{value:"agent.",label:"Agents"},{value:"heartbeat.",label:"Runs"},{value:"approval.",label:"Approvals"},{value:"project.",label:"Projects"},{value:"goal.",label:"Goals"},{value:"tool_gateway.",label:"Tools"},{value:"cost.",label:"Costs"},{value:"company.",label:"Company"}],Ue=[{value:n,label:"All entities"},{value:"issue",label:"Task"},{value:"agent",label:"Agent"},{value:"project",label:"Project"},{value:"goal",label:"Goal"},{value:"company",label:"Company"}];function Pe(t){if(!t)return;const a=new Date(`${t}T00:00:00.000Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}function _e(t){if(!t)return;const a=new Date(`${t}T23:59:59.999Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}function De({record:t,agentMap:a,userProfileMap:c}){const u=t.agentId??(t.actorType==="agent"?t.actorId:null),o=u?a.get(u):null;if(o)return(0,e.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",title:o.name,children:[(0,e.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,e.jsx)(be,{icon:o.icon,className:"h-3 w-3"})}),(0,e.jsx)("span",{className:"truncate font-medium text-foreground",children:o.name})]});if(t.actorType==="user"&&t.actorId){const d=c.get(t.actorId);return(0,e.jsx)(se,{name:d?.label??"User",avatarUrl:d?.image??null,size:"sm",className:"font-medium text-foreground"})}const h=t.actorType==="plugin"?"Plugin":t.actorType==="agent"?"Agent":t.actorType==="user"?"User":"System";return(0,e.jsx)(se,{name:h,size:"sm",className:"font-medium text-foreground"})}function Fe({record:t}){const{issue:a,document:c}=t.entity,u=a?.identifier??a?.id??null;return u?(0,e.jsx)(ne,{to:`/issues/${u}`,className:"font-medium text-primary hover:underline",children:a?.identifier?`${a.identifier}${a.title?` · ${a.title}`:""}`:"the task"}):c?(0,e.jsx)("span",{className:"font-medium text-foreground",children:c.key}):(0,e.jsx)("span",{className:"text-muted-foreground",children:t.entityType})}function Le({record:t,agentMap:a,userProfileMap:c}){const u=Ae(t.action,t.details,{agentMap:a,userProfileMap:c}),o=t.responsibleUserId?c.get(t.responsibleUserId):null,h=!!(t.responsibleUserId&&!(t.actorType==="user"&&t.actorId===t.responsibleUserId)),d=o?.label??(t.responsibleUserId?"a user":null),g=t.entity.comment?.excerpt?.trim(),x=t.entity.issue&&t.entity.document?t.entity.document.key:null;return(0,e.jsx)("li",{className:"px-4 py-3 text-sm",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-foreground",children:[(0,e.jsx)(De,{record:t,agentMap:a,userProfileMap:c}),(0,e.jsx)("span",{className:"text-muted-foreground",children:u}),(0,e.jsx)(Fe,{record:t})]}),g?(0,e.jsxs)("p",{className:"line-clamp-2 border-l-2 border-border pl-2 text-muted-foreground",children:["“",g,"”"]}):null,x?(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Document ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:x})]}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[h&&d?(0,e.jsxs)("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5",children:["on behalf of ",d]}):null,t.runId&&t.agentId?(0,e.jsx)(ne,{to:`/agents/${t.agentId}/runs/${t.runId}`,className:"text-primary hover:underline",children:"View run"}):null,(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro) opacity-70",children:t.action})]})]}),(0,e.jsx)("time",{className:"shrink-0 whitespace-nowrap text-xs text-muted-foreground",dateTime:t.createdAt,title:new Date(t.createdAt).toLocaleString(),children:he(t.createdAt)})]})})}function Re(){return(0,e.jsx)(v,{children:(0,e.jsxs)(y,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(ye,{className:"h-10 w-10 text-muted-foreground/50"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Agent audit is a Paperclip Enterprise view"}),(0,e.jsxs)("p",{className:"mx-auto mt-1 max-w-md text-sm text-muted-foreground",children:["The agent audit log gives you a searchable, exportable record of everything your agents did — every comment, task change, approval, and run — with the responsible person for each action. Ask an administrator to grant you the"," ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:"audit:view_agent_actions"})," ","permission to view it."]})]})]})})}function Ze({companyId:t,lockedAgentId:a,hideHeader:c,mode:u,onModeChange:o}){const{pushToast:h}=je(),[d,g]=(0,l.useState)(n),[x,k]=(0,l.useState)(n),[A,q]=(0,l.useState)(n),[S,B]=(0,l.useState)(n),[C,V]=(0,l.useState)(""),[E,$]=(0,l.useState)(""),[Y,Z]=(0,l.useState)(!1),[I,Q]=(0,l.useState)(!1),O=W({queryKey:G.agents.list(t),queryFn:()=>ve.list(t)}),z=W({queryKey:G.access.companyUserDirectory(t),queryFn:()=>we.listUserDirectory(t),retry:!1}),ie=(0,l.useMemo)(()=>new Map((O.data??[]).map(s=>[s.id,s])),[O.data]),re=(0,l.useMemo)(()=>Te(z.data?.users),[z.data]),p=a?"agents":u??"all",r={actorScope:p,agentId:a??(d===n?void 0:d),responsibleUserId:x===n?void 0:x,action:A===n?void 0:A,entityType:S===n?void 0:S,from:Pe(C),to:_e(E)},j=!!(!a&&d!==n||x!==n||A!==n||S!==n||C||E),i=Ne({queryKey:G.audit.agentActions(t,{actorScope:r.actorScope,agentId:r.agentId,responsibleUserId:r.responsibleUserId,action:r.action,entityType:r.entityType,from:r.from,to:r.to}),queryFn:({pageParam:s})=>te.listAgentActions(t,{...r,limit:Ee,cursor:s??void 0}),initialPageParam:null,getNextPageParam:s=>s.nextCursor??void 0,retry:(s,m)=>!(m instanceof J&&m.status===403)&&s<2}),M=i.error instanceof J&&i.error.status===403,U=i.data?.pages.some(s=>s.accessTier==="basic")??!1,le=i.data?.pages.some(s=>s.accessTier==="full")??!1,K=(0,l.useMemo)(()=>{const s=i.data?.pages??[];return(U?s.filter(m=>m.accessTier!=="full"):s).flatMap(m=>m.items)},[i.data,U]),P=U?"basic":i.data?.pages[0]?.accessTier,b=U&&le,oe=a?!0:P==="full",ce=!!(b&&I&&!i.isFetching),_=!!(!a&&!ce&&(M&&j||b)),N=!!(M&&!a&&p==="agents"&&o),de=!!(!a&&o&&!N&&(p==="agents"||P==="full"));(0,l.useEffect)(()=>{N&&o?.("all")},[N,o]),(0,l.useEffect)(()=>{!a&&(P==="basic"||_)&&(g(n),k(n),q(n),B(n),V(""),$(""))},[P,b,a,_]),(0,l.useEffect)(()=>{if(!b){I&&Q(!1);return}I||(Q(!0),i.refetch())},[I,i,b]);const H=()=>{g(n),k(n),q(n),B(n),V(""),$("")},ue=async()=>{Z(!0);try{const s=await te.exportAgentActionsCsv(t,{actorScope:r.actorScope,agentId:r.agentId,responsibleUserId:r.responsibleUserId,action:r.action,entityType:r.entityType,from:r.from,to:r.to}),m=URL.createObjectURL(s),w=document.createElement("a");w.href=m,w.download=`${p==="agents"?"agent-audit":"activity"}-${t}.csv`,document.body.appendChild(w),w.click(),w.remove(),window.setTimeout(()=>URL.revokeObjectURL(m),5e3),h({title:"Audit exported",body:"Your CSV download has started.",tone:"success"})}catch(s){h({title:"Export failed",body:s instanceof Error?s.message:"Could not export the audit log.",tone:"error"})}finally{Z(!1)}};return M&&!_&&!N?(0,e.jsx)(Re,{}):(0,e.jsxs)("div",{className:"space-y-4",children:[c?null:(0,e.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Activity"}),(0,e.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:p==="agents"?"Every recorded agent action, newest first — with the responsible person and run behind each one.":"Everything happening in your company, newest first — people, agents, and the system. Each line is one recorded action."})]})}),de?(0,e.jsx)(fe,{value:p,onValueChange:s=>o?.(s),children:(0,e.jsxs)(ge,{"aria-label":"Activity scope",children:[(0,e.jsx)(X,{value:"all",children:"All activity"}),(0,e.jsx)(X,{value:"agents",children:"Agent actions"})]})}):null,oe?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a?null:(0,e.jsxs)(L,{value:d,onValueChange:g,children:[(0,e.jsx)(R,{className:"w-40",children:(0,e.jsx)(F,{placeholder:"Agent"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(f,{value:n,children:"All agents"}),(O.data??[]).map(s=>(0,e.jsx)(f,{value:s.id,children:s.name},s.id))]})]}),(0,e.jsxs)(L,{value:x,onValueChange:k,children:[(0,e.jsx)(R,{className:"w-52",children:(0,e.jsx)(F,{placeholder:"Responsible user"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(f,{value:n,children:"All responsible users"}),(z.data?.users??[]).map(s=>(0,e.jsx)(f,{value:s.principalId,children:s.user?.name??s.user?.email??s.principalId.slice(0,8)},s.principalId))]})]}),(0,e.jsxs)(L,{value:A,onValueChange:q,children:[(0,e.jsx)(R,{className:"w-36",children:(0,e.jsx)(F,{placeholder:"Action"})}),(0,e.jsx)(D,{children:Ie.map(s=>(0,e.jsx)(f,{value:s.value,children:s.label},s.value))})]}),(0,e.jsxs)(L,{value:S,onValueChange:B,children:[(0,e.jsx)(R,{className:"w-36",children:(0,e.jsx)(F,{placeholder:"Entity"})}),(0,e.jsx)(D,{children:Ue.map(s=>(0,e.jsx)(f,{value:s.value,children:s.label},s.value))})]}),(0,e.jsx)(ee,{type:"date","aria-label":"From date",value:C,max:E||void 0,onChange:s=>V(s.target.value),className:"w-36"}),(0,e.jsx)(ee,{type:"date","aria-label":"To date",value:E,min:C||void 0,onChange:s=>$(s.target.value),className:"w-36"}),j?(0,e.jsx)(T,{variant:"ghost",size:"sm",onClick:H,children:"Clear filters"}):null,(0,e.jsxs)(T,{variant:"outline",size:"sm",className:"ml-auto",onClick:ue,disabled:Y||i.isLoading||K.length===0,children:[(0,e.jsx)(Ce,{className:"mr-1.5 h-4 w-4"}),Y?"Exporting…":"Export CSV"]})]}):null,_||N?(0,e.jsx)(v,{children:(0,e.jsx)(y,{className:"py-14 text-center text-sm text-muted-foreground",children:"Refreshing audit access…"})}):i.isLoading?(0,e.jsx)(v,{children:(0,e.jsx)(y,{className:"py-14 text-center text-sm text-muted-foreground",children:"Loading…"})}):i.error?(0,e.jsx)(v,{children:(0,e.jsxs)(y,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:i.error instanceof Error?i.error.message:"Failed to load the audit log."}),(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:()=>i.refetch(),children:"Try again"})]})}):K.length===0?(0,e.jsx)(v,{children:(0,e.jsxs)(y,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(Se,{className:"h-10 w-10 text-muted-foreground/40"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:j?"No actions match these filters":"Nothing here yet"}),(0,e.jsx)("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:j?"Try a wider date range or different filters.":p==="agents"?"As soon as your agents start doing things, their actions show up here.":"As soon as anyone in your company does something, it shows up here."})]}),j?(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:H,children:"Clear filters"}):null]})}):(0,e.jsx)(v,{children:(0,e.jsx)(y,{className:"px-0 py-0",children:(0,e.jsx)("ul",{className:me("divide-y divide-border"),children:K.map(s=>(0,e.jsx)(Le,{record:s,agentMap:ie,userProfileMap:re},s.id))})})}),i.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center",children:(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:()=>i.fetchNextPage(),disabled:i.isFetchingNextPage,children:i.isFetchingNextPage?"Loading…":"Load more"})}):null,(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Recorded by Paperclip — entries can't be edited. Sensitive values are never stored."})]})}export{Ze as t};
|
|
1
|
+
import{i as ae}from"./rolldown-runtime-BQ-vy_Pv.js";import{S as me,Tn as J,fr as xe,jn as W,q as G,ur as pe,z as he}from"./createLucideIcon-JUO5qdpL.js";import{t as ne}from"./router-Dr6qx_6q.js";import{i as X,r as ge,t as fe}from"./tabs-B-hJilg9.js";import{t as T}from"./button-DWgQnsK-.js";import{t as ve}from"./agents-yMBk3d4f.js";import{t as ye}from"./shield-alert-Dz2_CCm7.js";import{i as je}from"./ToastContext-Dmfqh1in.js";import{t as ee}from"./input-DjyO-oZf.js";import{t as be}from"./AgentIconPicker-B6761LdM.js";import{Ar as Ne,In as we,On as Te,Ot as te,_n as v,cn as D,dn as F,jn as se,ln as f,nn as Ae,sn as L,tr as Se,un as R,vn as y,yr as Ce}from"./index-BaG1tZj1.js";var l=ae(xe(),1),e=ae(pe(),1),Ee=50,n="__all",Ie=[{value:n,label:"All actions"},{value:"issue.",label:"Tasks"},{value:"agent.",label:"Agents"},{value:"heartbeat.",label:"Runs"},{value:"approval.",label:"Approvals"},{value:"project.",label:"Projects"},{value:"goal.",label:"Goals"},{value:"tool_gateway.",label:"Tools"},{value:"cost.",label:"Costs"},{value:"company.",label:"Company"}],Ue=[{value:n,label:"All entities"},{value:"issue",label:"Task"},{value:"agent",label:"Agent"},{value:"project",label:"Project"},{value:"goal",label:"Goal"},{value:"company",label:"Company"}];function Pe(t){if(!t)return;const a=new Date(`${t}T00:00:00.000Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}function _e(t){if(!t)return;const a=new Date(`${t}T23:59:59.999Z`);return Number.isNaN(a.getTime())?void 0:a.toISOString()}function De({record:t,agentMap:a,userProfileMap:c}){const u=t.agentId??(t.actorType==="agent"?t.actorId:null),o=u?a.get(u):null;if(o)return(0,e.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",title:o.name,children:[(0,e.jsx)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,e.jsx)(be,{icon:o.icon,className:"h-3 w-3"})}),(0,e.jsx)("span",{className:"truncate font-medium text-foreground",children:o.name})]});if(t.actorType==="user"&&t.actorId){const d=c.get(t.actorId);return(0,e.jsx)(se,{name:d?.label??"User",avatarUrl:d?.image??null,size:"sm",className:"font-medium text-foreground"})}const h=t.actorType==="plugin"?"Plugin":t.actorType==="agent"?"Agent":t.actorType==="user"?"User":"System";return(0,e.jsx)(se,{name:h,size:"sm",className:"font-medium text-foreground"})}function Fe({record:t}){const{issue:a,document:c}=t.entity,u=a?.identifier??a?.id??null;return u?(0,e.jsx)(ne,{to:`/issues/${u}`,className:"font-medium text-primary hover:underline",children:a?.identifier?`${a.identifier}${a.title?` · ${a.title}`:""}`:"the task"}):c?(0,e.jsx)("span",{className:"font-medium text-foreground",children:c.key}):(0,e.jsx)("span",{className:"text-muted-foreground",children:t.entityType})}function Le({record:t,agentMap:a,userProfileMap:c}){const u=Ae(t.action,t.details,{agentMap:a,userProfileMap:c}),o=t.responsibleUserId?c.get(t.responsibleUserId):null,h=!!(t.responsibleUserId&&!(t.actorType==="user"&&t.actorId===t.responsibleUserId)),d=o?.label??(t.responsibleUserId?"a user":null),g=t.entity.comment?.excerpt?.trim(),x=t.entity.issue&&t.entity.document?t.entity.document.key:null;return(0,e.jsx)("li",{className:"px-4 py-3 text-sm",children:(0,e.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 text-foreground",children:[(0,e.jsx)(De,{record:t,agentMap:a,userProfileMap:c}),(0,e.jsx)("span",{className:"text-muted-foreground",children:u}),(0,e.jsx)(Fe,{record:t})]}),g?(0,e.jsxs)("p",{className:"line-clamp-2 border-l-2 border-border pl-2 text-muted-foreground",children:["“",g,"”"]}):null,x?(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Document ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:x})]}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[h&&d?(0,e.jsxs)("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5",children:["on behalf of ",d]}):null,t.runId&&t.agentId?(0,e.jsx)(ne,{to:`/agents/${t.agentId}/runs/${t.runId}`,className:"text-primary hover:underline",children:"View run"}):null,(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro) opacity-70",children:t.action})]})]}),(0,e.jsx)("time",{className:"shrink-0 whitespace-nowrap text-xs text-muted-foreground",dateTime:t.createdAt,title:new Date(t.createdAt).toLocaleString(),children:he(t.createdAt)})]})})}function Re(){return(0,e.jsx)(v,{children:(0,e.jsxs)(y,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(ye,{className:"h-10 w-10 text-muted-foreground/50"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Agent audit is a Paperclip Enterprise view"}),(0,e.jsxs)("p",{className:"mx-auto mt-1 max-w-md text-sm text-muted-foreground",children:["The agent audit log gives you a searchable, exportable record of everything your agents did — every comment, task change, approval, and run — with the responsible person for each action. Ask an administrator to grant you the"," ",(0,e.jsx)("span",{className:"font-mono text-(length:--text-micro)",children:"audit:view_agent_actions"})," ","permission to view it."]})]})]})})}function Ze({companyId:t,lockedAgentId:a,hideHeader:c,mode:u,onModeChange:o}){const{pushToast:h}=je(),[d,g]=(0,l.useState)(n),[x,k]=(0,l.useState)(n),[A,q]=(0,l.useState)(n),[S,B]=(0,l.useState)(n),[C,V]=(0,l.useState)(""),[E,$]=(0,l.useState)(""),[Y,Z]=(0,l.useState)(!1),[I,Q]=(0,l.useState)(!1),O=W({queryKey:G.agents.list(t),queryFn:()=>ve.list(t)}),z=W({queryKey:G.access.companyUserDirectory(t),queryFn:()=>we.listUserDirectory(t),retry:!1}),ie=(0,l.useMemo)(()=>new Map((O.data??[]).map(s=>[s.id,s])),[O.data]),re=(0,l.useMemo)(()=>Te(z.data?.users),[z.data]),p=a?"agents":u??"all",r={actorScope:p,agentId:a??(d===n?void 0:d),responsibleUserId:x===n?void 0:x,action:A===n?void 0:A,entityType:S===n?void 0:S,from:Pe(C),to:_e(E)},j=!!(!a&&d!==n||x!==n||A!==n||S!==n||C||E),i=Ne({queryKey:G.audit.agentActions(t,{actorScope:r.actorScope,agentId:r.agentId,responsibleUserId:r.responsibleUserId,action:r.action,entityType:r.entityType,from:r.from,to:r.to}),queryFn:({pageParam:s})=>te.listAgentActions(t,{...r,limit:Ee,cursor:s??void 0}),initialPageParam:null,getNextPageParam:s=>s.nextCursor??void 0,retry:(s,m)=>!(m instanceof J&&m.status===403)&&s<2}),M=i.error instanceof J&&i.error.status===403,U=i.data?.pages.some(s=>s.accessTier==="basic")??!1,le=i.data?.pages.some(s=>s.accessTier==="full")??!1,K=(0,l.useMemo)(()=>{const s=i.data?.pages??[];return(U?s.filter(m=>m.accessTier!=="full"):s).flatMap(m=>m.items)},[i.data,U]),P=U?"basic":i.data?.pages[0]?.accessTier,b=U&&le,oe=a?!0:P==="full",ce=!!(b&&I&&!i.isFetching),_=!!(!a&&!ce&&(M&&j||b)),N=!!(M&&!a&&p==="agents"&&o),de=!!(!a&&o&&!N&&(p==="agents"||P==="full"));(0,l.useEffect)(()=>{N&&o?.("all")},[N,o]),(0,l.useEffect)(()=>{!a&&(P==="basic"||_)&&(g(n),k(n),q(n),B(n),V(""),$(""))},[P,b,a,_]),(0,l.useEffect)(()=>{if(!b){I&&Q(!1);return}I||(Q(!0),i.refetch())},[I,i,b]);const H=()=>{g(n),k(n),q(n),B(n),V(""),$("")},ue=async()=>{Z(!0);try{const s=await te.exportAgentActionsCsv(t,{actorScope:r.actorScope,agentId:r.agentId,responsibleUserId:r.responsibleUserId,action:r.action,entityType:r.entityType,from:r.from,to:r.to}),m=URL.createObjectURL(s),w=document.createElement("a");w.href=m,w.download=`${p==="agents"?"agent-audit":"activity"}-${t}.csv`,document.body.appendChild(w),w.click(),w.remove(),window.setTimeout(()=>URL.revokeObjectURL(m),5e3),h({title:"Audit exported",body:"Your CSV download has started.",tone:"success"})}catch(s){h({title:"Export failed",body:s instanceof Error?s.message:"Could not export the audit log.",tone:"error"})}finally{Z(!1)}};return M&&!_&&!N?(0,e.jsx)(Re,{}):(0,e.jsxs)("div",{className:"space-y-4",children:[c?null:(0,e.jsx)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("h1",{className:"text-lg font-semibold text-foreground",children:"Activity"}),(0,e.jsx)("p",{className:"mt-1 max-w-2xl text-sm text-muted-foreground",children:p==="agents"?"Every recorded agent action, newest first — with the responsible person and run behind each one.":"Everything happening in your company, newest first — people, agents, and the system. Each line is one recorded action."})]})}),de?(0,e.jsx)(fe,{value:p,onValueChange:s=>o?.(s),children:(0,e.jsxs)(ge,{"aria-label":"Activity scope",children:[(0,e.jsx)(X,{value:"all",children:"All activity"}),(0,e.jsx)(X,{value:"agents",children:"Agent actions"})]})}):null,oe?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a?null:(0,e.jsxs)(L,{value:d,onValueChange:g,children:[(0,e.jsx)(R,{className:"w-40",children:(0,e.jsx)(F,{placeholder:"Agent"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(f,{value:n,children:"All agents"}),(O.data??[]).map(s=>(0,e.jsx)(f,{value:s.id,children:s.name},s.id))]})]}),(0,e.jsxs)(L,{value:x,onValueChange:k,children:[(0,e.jsx)(R,{className:"w-52",children:(0,e.jsx)(F,{placeholder:"Responsible user"})}),(0,e.jsxs)(D,{children:[(0,e.jsx)(f,{value:n,children:"All responsible users"}),(z.data?.users??[]).map(s=>(0,e.jsx)(f,{value:s.principalId,children:s.user?.name??s.user?.email??s.principalId.slice(0,8)},s.principalId))]})]}),(0,e.jsxs)(L,{value:A,onValueChange:q,children:[(0,e.jsx)(R,{className:"w-36",children:(0,e.jsx)(F,{placeholder:"Action"})}),(0,e.jsx)(D,{children:Ie.map(s=>(0,e.jsx)(f,{value:s.value,children:s.label},s.value))})]}),(0,e.jsxs)(L,{value:S,onValueChange:B,children:[(0,e.jsx)(R,{className:"w-36",children:(0,e.jsx)(F,{placeholder:"Entity"})}),(0,e.jsx)(D,{children:Ue.map(s=>(0,e.jsx)(f,{value:s.value,children:s.label},s.value))})]}),(0,e.jsx)(ee,{type:"date","aria-label":"From date",value:C,max:E||void 0,onChange:s=>V(s.target.value),className:"w-36"}),(0,e.jsx)(ee,{type:"date","aria-label":"To date",value:E,min:C||void 0,onChange:s=>$(s.target.value),className:"w-36"}),j?(0,e.jsx)(T,{variant:"ghost",size:"sm",onClick:H,children:"Clear filters"}):null,(0,e.jsxs)(T,{variant:"outline",size:"sm",className:"ml-auto",onClick:ue,disabled:Y||i.isLoading||K.length===0,children:[(0,e.jsx)(Ce,{className:"mr-1.5 h-4 w-4"}),Y?"Exporting…":"Export CSV"]})]}):null,_||N?(0,e.jsx)(v,{children:(0,e.jsx)(y,{className:"py-14 text-center text-sm text-muted-foreground",children:"Refreshing audit access…"})}):i.isLoading?(0,e.jsx)(v,{children:(0,e.jsx)(y,{className:"py-14 text-center text-sm text-muted-foreground",children:"Loading…"})}):i.error?(0,e.jsx)(v,{children:(0,e.jsxs)(y,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:i.error instanceof Error?i.error.message:"Failed to load the audit log."}),(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:()=>i.refetch(),children:"Try again"})]})}):K.length===0?(0,e.jsx)(v,{children:(0,e.jsxs)(y,{className:"flex flex-col items-center gap-3 py-14 text-center",children:[(0,e.jsx)(Se,{className:"h-10 w-10 text-muted-foreground/40"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-medium text-foreground",children:j?"No actions match these filters":"Nothing here yet"}),(0,e.jsx)("p",{className:"mt-1 max-w-md text-sm text-muted-foreground",children:j?"Try a wider date range or different filters.":p==="agents"?"As soon as your agents start doing things, their actions show up here.":"As soon as anyone in your company does something, it shows up here."})]}),j?(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:H,children:"Clear filters"}):null]})}):(0,e.jsx)(v,{children:(0,e.jsx)(y,{className:"px-0 py-0",children:(0,e.jsx)("ul",{className:me("divide-y divide-border"),children:K.map(s=>(0,e.jsx)(Le,{record:s,agentMap:ie,userProfileMap:re},s.id))})})}),i.hasNextPage?(0,e.jsx)("div",{className:"flex justify-center",children:(0,e.jsx)(T,{variant:"outline",size:"sm",onClick:()=>i.fetchNextPage(),disabled:i.isFetchingNextPage,children:i.isFetchingNextPage?"Loading…":"Load more"})}):null,(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:"Recorded by Paperclip — entries can't be edited. Sensitive values are never stored."})]})}export{Ze as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as m}from"./rolldown-runtime-BQ-vy_Pv.js";import{U as d,fr as l,ur as f}from"./createLucideIcon-JUO5qdpL.js";import{ct as y}from"./router-Dr6qx_6q.js";import{n as g}from"./BreadcrumbContext-D3CAiFzt.js";import{hn as h,nr as C}from"./index-
|
|
1
|
+
import{i as m}from"./rolldown-runtime-BQ-vy_Pv.js";import{U as d,fr as l,ur as f}from"./createLucideIcon-JUO5qdpL.js";import{ct as y}from"./router-Dr6qx_6q.js";import{n as g}from"./BreadcrumbContext-D3CAiFzt.js";import{hn as h,nr as C}from"./index-BaG1tZj1.js";import{t as _}from"./AuditFeed.production-BIggihG-.js";var s=m(l(),1),o=m(f(),1);function w(){const{selectedCompanyId:t}=d(),{setBreadcrumbs:a}=g(),[n,r]=y(),c=n.get("mode")==="agents"?"agents":"all";(0,s.useEffect)(()=>{a([{label:"Activity"}])},[a]);const i=(0,s.useCallback)(u=>{r(p=>{const e=new URLSearchParams(p);return u==="agents"?e.set("mode","agents"):e.delete("mode"),e},{replace:!0})},[r]);return t?(0,o.jsx)(_,{companyId:t,mode:c,onModeChange:i}):(0,o.jsx)(h,{icon:C,message:"Select a company to view activity."})}export{w as CompanyActivity};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as be}from"./rolldown-runtime-BQ-vy_Pv.js";import{$ as Be,An as de,J as ze,S as se,U as De,fr as _e,jn as Z,q as G,ur as Ue,wn as ee,yt as We}from"./createLucideIcon-JUO5qdpL.js";import{it as qe,o as Ke,p as Ye}from"./router-Dr6qx_6q.js";import{Z as Ze}from"./mention-chips-D8B6eEdr.js";import{l as Ge,p as B}from"./zap-RUrW_UgS.js";import{g as Xe}from"./StatusIcon-CeMClGJ9.js";import{n as He}from"./BreadcrumbContext-D3CAiFzt.js";import{t as X}from"./button-DWgQnsK-.js";import{n as Je}from"./clipboard-BCz9EG42.js";import{t as pe}from"./MarkdownBody-CGVDfzLB.js";import{t as Ve}from"./agents-yMBk3d4f.js";import{t as fe}from"./rotate-ccw-Cb9U93yr.js";import{i as Qe}from"./ToastContext-Dmfqh1in.js";import{t as et}from"./PageSkeleton-DYqd8XzH.js";import{Ft as me,Gn as tt,It as st,Ln as nt,Lt as rt,Nt as ot,Pt as it,Rt as at,a as ct,gn as lt,hn as z,i as ut,n as dt,r as pt,t as we,yr as ft}from"./index-
|
|
1
|
+
import{i as be}from"./rolldown-runtime-BQ-vy_Pv.js";import{$ as Be,An as de,J as ze,S as se,U as De,fr as _e,jn as Z,q as G,ur as Ue,wn as ee,yt as We}from"./createLucideIcon-JUO5qdpL.js";import{it as qe,o as Ke,p as Ye}from"./router-Dr6qx_6q.js";import{Z as Ze}from"./mention-chips-D8B6eEdr.js";import{l as Ge,p as B}from"./zap-RUrW_UgS.js";import{g as Xe}from"./StatusIcon-CeMClGJ9.js";import{n as He}from"./BreadcrumbContext-D3CAiFzt.js";import{t as X}from"./button-DWgQnsK-.js";import{n as Je}from"./clipboard-BCz9EG42.js";import{t as pe}from"./MarkdownBody-CGVDfzLB.js";import{t as Ve}from"./agents-yMBk3d4f.js";import{t as fe}from"./rotate-ccw-Cb9U93yr.js";import{i as Qe}from"./ToastContext-Dmfqh1in.js";import{t as et}from"./PageSkeleton-DYqd8XzH.js";import{Ft as me,Gn as tt,It as st,Ln as nt,Lt as rt,Nt as ot,Pt as it,Rt as at,a as ct,gn as lt,hn as z,i as ut,n as dt,r as pt,t as we,yr as ft}from"./index-BaG1tZj1.js";var m=be(_e(),1),mt=["agents","projects","skills","routines","tasks","attachments"],ht={agents:"Agents",projects:"Projects",skills:"Skills",routines:"Routines",tasks:"Tasks",attachments:"Attachments"};function gt(){return{agents:!0,projects:!0,skills:!0,routines:!0,tasks:!0,attachments:!0}}function je(e){return e.tasks||e.routines}function ye(e){const o=new Set;for(const i of e){if(!i.recurring)continue;const n=i.path.trim();if(!n)continue;o.add(n);const r=n.lastIndexOf("/");r>=0&&o.add(`${n.slice(0,r+1)}`)}return o}function xt(e,o){for(const i of o)if(e===i||e.startsWith(i))return!0;return!1}function bt(e){const o=new Set,i=new Set;for(const n of e)for(const r of n.attachments??[]){const c=r.sha256.trim().toLowerCase();c&&(n.recurring?o:i).add(c)}return{recurring:o,oneOff:i}}var wt=new Set(["agents","projects","skills","routines","tasks"]);function jt(e){const o=new Map;for(const i of e){const n=i.sha256.trim().toLowerCase();if(!n)continue;const r=o.get(n)??new Set,c=i.ownedBy&&i.ownedBy.length>0?i.ownedBy:["always"];for(const d of c)r.add(d);o.set(n,r)}return o}function yt(e,o){for(const i of e)if(!wt.has(i)||o[i])return!0;return!1}function ve(e,o){return e.startsWith("agents/")?"agents":e.startsWith("projects/")?"projects":e.startsWith("skills/")?"skills":e.startsWith("tasks/")?xt(e,o)?"routines":"tasks":e.startsWith("blobs/")?"attachments":null}function vt(e,o){const i=ye(o),n={agents:0,projects:0,skills:0,routines:0,tasks:0,attachments:0};for(const r of e){const c=ve(r,i);c&&(n[c]+=1)}return n}function kt(e){const{filePaths:o,issues:i,categories:n}=e,r=ye(i),c=bt(i),d=jt(e.embeddedAssets??[]),p=n.attachments&&je(n),h=new Set;for(const l of o){const x=ve(l,r);if(x===null){h.add(l);continue}if(x==="attachments"){const a=l.slice(6).trim().toLowerCase(),g=d.get(a);if(g&&yt(g,n)){h.add(l);continue}if(!p)continue;const w=c.recurring.has(a),j=c.oneOff.has(a);!w&&!j?g||h.add(l):(j&&n.tasks||w&&n.routines)&&h.add(l);continue}n[x]&&h.add(l)}return h}function ke(e,o){if(!o.has(e))return o.add(e),e;let i=2;for(;;){const n=`${e}-${i}`;if(!o.has(n))return o.add(n),n;i+=1}}function St(e){const o=new Set,i=new Map,n=[...e].sort((r,c)=>r.name.localeCompare(c.name));for(const r of n){const c=We(r.name)??"agent";i.set(r.id,ke(c,o))}return i}function Ct(e){const o=new Set,i=new Map,n=[...e].sort((r,c)=>r.name.localeCompare(c.name));for(const r of n){const c=Be(r.name,r.name);i.set(r.id,ke(c,o))}return i}function Et(e){const o=St(e.agents),i=Ct(e.projects),n={agents:e.orderedAgents.map(r=>o.get(r.id)).filter(r=>!!r),projects:e.orderedProjects.map(r=>i.get(r.id)).filter(r=>!!r)};return n.agents.length>0||n.projects.length>0?n:void 0}var t=be(Ue(),1);function Se(e){const o=new Set,i=new Set,n=new Set;for(const r of e){const c=r.match(/^agents\/([^/]+)\//);c&&o.add(c[1]);const d=r.match(/^projects\/([^/]+)\//);d&&i.add(d[1]);const p=r.match(/^tasks\/([^/]+)\//);p&&n.add(p[1])}return{agents:o,projects:i,tasks:n,routines:new Set(n)}}function Nt(e,o){const i=Se(o),n=e.split(`
|
|
2
2
|
`),r=[],c=new Set(["agents","projects","tasks","routines"]),d=new Set(["agents","projects"]);let p=null,h=null,l=!0,x=null,a=null,g=[],w=null,j=[];function R(){a!==null&&g.length>0&&(j.push(a),j.push(...g)),a=null,g=[]}function E(){R(),w!==null&&j.length>0&&(r.push(w),r.push(...j)),w=null,j=[]}for(const b of n){const _=b.match(/^([a-zA-Z_][\w-]*):\s*(.*)$/);if(_&&!b.startsWith(" ")){E(),h=null,l=!0;const C=_[0].split(":")[0];if(c.has(C)){p=C,w=b;continue}else if(C==="sidebar"){p=C,x=null,w=b;continue}else{p=null,r.push(b);continue}}if(p==="sidebar"){const C=b.match(/^ ([\w-]+):\s*$/);if(C&&!b.startsWith(" ")){R();const N=C[1];x=N&&d.has(N)?N:null,a=x?b:null;continue}const T=b.match(/^ - ["']?([^"'\n]+)["']?\s*$/);if(T&&x){const N=T[1],U=i[x];N&&U.has(N)&&g.push(b);continue}if(x){g.push(b);continue}}if(p&&c.has(p)){const C=b.match(/^ ([\w][\w-]*):\s*(.*)$/);if(C&&!b.startsWith(" ")){const T=C[1];h=T,l=i[p].has(T),l&&j.push(b);continue}if(h!==null){l&&j.push(b);continue}j.push(b);continue}r.push(b)}E();let S=r.join(`
|
|
3
3
|
`);const D=S.match(/^\s{2}logoPath:\s*["']?([^"'\n]+)["']?\s*$/m);return D&&!o.has(D[1])&&(S=S.replace(/^\s{2}logoPath:\s*["']?([^"'\n]+)["']?\s*\n?/m,"")),S}function Ce(e,o){if(!o)return e;const i=o.toLowerCase();return e.map(n=>{if(n.kind==="file")return n.name.toLowerCase().includes(i)||n.path.toLowerCase().includes(i)?n:null;const r=Ce(n.children,o);return r.length>0?{...n,children:r}:null}).filter(n=>n!==null)}function At(e,o){const i=new Set,n=o.toLowerCase();function r(c,d){if(c.kind==="file"){if(c.name.toLowerCase().includes(n)||c.path.toLowerCase().includes(n))for(const p of d)i.add(p)}else for(const p of c.children)r(p,[...d,c.path])}for(const c of e)r(c,[]);return i}var he=10;function Pt(e,o,i,n){let r=0,c=0;return{nodes:e.map(d=>{if(d.kind==="dir"&&d.name==="tasks"){r=d.children.length;const p=[],h=[],l=i.toLowerCase();for(const g of d.children){const w=st([g],"file"),j=n!==null&&w.has(n),R=i&&(g.name.toLowerCase().includes(l)||g.path.toLowerCase().includes(l)||[...w].some(E=>E.toLowerCase().includes(l)));j||R?p.push(g):h.push(g)}const x=Math.max(0,o-p.length),a=[...p,...h.slice(0,x)];return c=a.length,{...d,children:a}}return d}),totalTaskChildren:r,visibleTaskChildren:c}}function Ee(e,o,i){const n={};for(const r of Object.keys(e))o.has(r)&&(n[r]=i[r]??e[r]);return n}function Rt(e,o,i){const n=Ee(e.files,o,i),r=ut(n,e.rootPath),c=new ArrayBuffer(r.byteLength);new Uint8Array(c).set(r);const d=new Blob([c],{type:"application/zip"}),p=URL.createObjectURL(d),h=document.createElement("a");h.href=p,h.download=`${e.rootPath}.zip`,document.body.appendChild(h),h.click(),h.remove(),window.setTimeout(()=>URL.revokeObjectURL(p),1e3)}function Tt({data:e,onSkillClick:o}){return(0,t.jsx)("div",{className:"rounded-md border border-border bg-accent/20 px-4 py-3 mb-4",children:(0,t.jsx)("dl",{className:"grid grid-cols-(--gtc-5) gap-x-4 gap-y-1.5 text-sm",children:Object.entries(e).map(([i,n])=>(0,t.jsxs)("div",{className:"contents",children:[(0,t.jsx)("dt",{className:"text-muted-foreground whitespace-nowrap py-0.5",children:ot[i]??i}),(0,t.jsx)("dd",{className:"py-0.5",children:Array.isArray(n)?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(r=>(0,t.jsx)("button",{type:"button",className:se("inline-flex items-center rounded-md border border-border bg-background px-2 py-0.5 text-xs",i==="skills"&&o&&"cursor-pointer hover:bg-accent/50 hover:border-foreground/30 transition-colors"),onClick:()=>i==="skills"&&o?.(r),children:r},r))}):(0,t.jsx)("span",{children:n})})]},i))})})}var Lt={ceo:"CEO",cto:"CTO",cmo:"CMO",cfo:"CFO",coo:"COO",vp:"VP",manager:"Manager",engineer:"Engineer",agent:"Agent"};function Ot(e,o,i,n){const r=Se(o),c=e.agents.filter(a=>r.agents.has(a.slug)),d=e.projects.filter(a=>r.projects.has(a.slug)),p=e.issues.filter(a=>r.tasks.has(a.slug)),h=e.skills.filter(a=>[...o].some(g=>g.startsWith(`skills/${a.key}/`)||g.startsWith("skills/")&&g.includes(`/${a.slug}/`))),l=[];l.push(`# ${i}`),l.push(""),n&&(l.push(`> ${n}`),l.push("")),c.length>0&&(l.push(""),l.push("")),l.push("## What's Inside"),l.push(""),l.push("This is an [Agent Company](https://paperclip.ing) package."),l.push("");const x=[];if(c.length>0&&x.push(["Agents",c.length]),d.length>0&&x.push(["Projects",d.length]),h.length>0&&x.push(["Skills",h.length]),p.length>0&&x.push(["Tasks",p.length]),x.length>0){l.push("| Content | Count |"),l.push("|---------|-------|");for(const[a,g]of x)l.push(`| ${a} | ${g} |`);l.push("")}if(c.length>0){l.push("### Agents"),l.push(""),l.push("| Agent | Role | Reports To |"),l.push("|-------|------|------------|");for(const a of c){const g=Lt[a.role]??a.role,w=a.reportsToSlug??"—";l.push(`| ${a.name} | ${g} | ${w} |`)}l.push("")}if(d.length>0){l.push("### Projects"),l.push("");for(const a of d){const g=a.description?` — ${a.description}`:"";l.push(`- **${a.name}**${g}`)}l.push("")}return l.push("## Getting Started"),l.push(""),l.push("```bash"),l.push("npx paperclipai company import this-github-url-or-folder"),l.push("```"),l.push(""),l.push("See [Paperclip](https://paperclip.ing) for more information."),l.push(""),l.push("---"),l.push(`Exported from [Paperclip](https://paperclip.ing) on ${new Date().toISOString().split("T")[0]}`),l.push(""),l.join(`
|
|
4
4
|
`)}function Mt(e){const{src:o,selectedFile:i,allFiles:n,orgChartPreviewUrl:r}=e;if(/^(?:https?:|data:)/i.test(o))return null;if(o.replace(/^\.\//,"")==="images/org-chart.png"&&r)return r;const c=(i.includes("/")?i.slice(0,i.lastIndexOf("/")+1):"")+o,d=n[c]??n[o];return d?we(c in n?c:o,d):null}function Ft({selectedFile:e,content:o,allFiles:i,orgChartPreviewUrl:n,onSkillClick:r}){if(!e||o===null)return(0,t.jsx)(z,{icon:B,message:"Select a file to preview its contents."});const c=dt(o),d=e.endsWith(".md")&&c!==null,p=d&&c?at(c):null,h=pt(e,o)?we(e,o):null,l=d?x=>Mt({src:x,selectedFile:e,allFiles:i,orgChartPreviewUrl:n}):void 0;return(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"border-b border-border px-5 py-3",children:(0,t.jsx)("div",{className:"truncate font-mono text-sm",children:e})}),(0,t.jsx)("div",{className:"min-h-(--sz-560px) px-5 py-5",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Tt,{data:p.data,onSkillClick:r}),p.body.trim()&&(0,t.jsx)(pe,{resolveImageSrc:l,softBreaks:!1,linkIssueReferences:!1,children:p.body})]}):d?(0,t.jsx)(pe,{resolveImageSrc:l,softBreaks:!1,linkIssueReferences:!1,children:c??""}):h?(0,t.jsx)("div",{className:"flex min-h-(--sz-520px) items-center justify-center rounded-lg border border-border bg-accent/10 p-6",children:(0,t.jsx)("img",{src:h,alt:e,className:"max-h-(--sz-480px) max-w-full object-contain"})}):c!==null?(0,t.jsx)("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words border-0 bg-transparent p-0 font-mono text-sm text-foreground",children:(0,t.jsx)("code",{children:c})}):(0,t.jsx)("div",{className:"rounded-lg border border-border bg-accent/10 px-4 py-3 text-sm text-muted-foreground",children:"Binary asset preview is not available for this file type."})})]})}function ge(e){const o="/company/export/files/",i=Ye(e),n=i.indexOf(o);return n===-1?null:decodeURIComponent(i.slice(n+22))||null}function xe(e){const o=e.split("/").slice(0,-1),i=[];let n="";for(const r of o)n=n?`${n}/${r}`:r,i.push(n);return i}function It(e){return(e instanceof DOMException||e instanceof Error)&&e.name==="AbortError"}function te(e){return e instanceof Error?e.message:"Failed to load export data."}function Vt(){const{selectedCompanyId:e,selectedCompany:o}=De(),{setBreadcrumbs:i}=He(),{pushToast:n}=Qe(),r=Ke(),c=qe(),d=(0,m.useRef)(ge(c.pathname)),{data:p}=Z({queryKey:G.auth.session,queryFn:()=>ze.getSession()}),{data:h=[]}=Z({queryKey:G.agents.list(e),queryFn:()=>Ve.list(e),enabled:!!e}),{data:l=[]}=Z({queryKey:G.projects.list(e),queryFn:()=>Xe.list(e),enabled:!!e}),{data:x}=Z({queryKey:G.companies.exportFidelity(e),queryFn:()=>ee.exportFidelity(e),enabled:!!e}),[a,g]=(0,m.useState)(null),[w,j]=(0,m.useState)(null),[R,E]=(0,m.useState)(new Set),[S,D]=(0,m.useState)(()=>({...gt(),tasks:!1,routines:!1,attachments:!1})),[b,_]=(0,m.useState)(""),[C,T]=(0,m.useState)(he),[N,U]=(0,m.useState)(!1),W=(0,m.useRef)(null),F=(0,m.useRef)(null),O=(0,m.useRef)(0),ne=(0,m.useRef)(null),re=p?.user?.id??p?.session?.userId??null,H=(0,m.useMemo)(()=>h.filter(s=>s.status!=="terminated"),[h]),J=(0,m.useMemo)(()=>l,[l]),{orderedAgents:oe}=tt({agents:H,companyId:e,userId:re}),{orderedProjects:ie}=nt({projects:J,companyId:e,userId:re}),ae=(0,m.useMemo)(()=>Et({agents:H,orderedAgents:oe,projects:J,orderedProjects:ie}),[oe,ie,H,J]),V=S.tasks||S.routines,Q=(0,m.useCallback)((s,u=!1)=>{j(s),s?r(`/company/export/files/${encodeURI(s)}`,{replace:u}):r("/company/export",{replace:u})},[r]);(0,m.useEffect)(()=>{if(!a)return;const s=ge(c.pathname);s&&s in a.files&&s!==w?(j(s),E(u=>{const f=new Set(u);for(const y of xe(s))f.add(y);return f})):!s&&w&&j(null)},[c.pathname,a]),(0,m.useEffect)(()=>{i([{label:o?.name??"Organization",href:"/dashboard"},{label:"Settings",href:"/company/settings"},{label:"Export"}])},[o?.name,i]);const A=de({mutationFn:({includeIssues:s,includeSkills:u,signal:f})=>ee.exportPreview(e,{include:{company:!0,agents:!0,projects:!0,issues:s,skills:u},sidebarOrder:ae},{signal:f}),onSuccess:(s,u)=>{if(u.requestId!==O.current)return;g(s);const f=me(s.files),y=new Set;for(const v of f)v.kind==="dir"&&v.name!=="tasks"&&y.add(v.path);const k=d.current;if(k&&k in s.files){j(k);const v=xe(k);E(new Set([...y,...v]))}else{const v="README.md"in s.files?"README.md":Object.keys(s.files)[0];v&&Q(v,!0),E(y)}},onError:(s,u)=>{u.requestId!==O.current||It(s)||n({tone:"error",title:"Export failed",body:te(s)})}});function M(){if(!e)return;F.current?.abort();const s=new AbortController,u=O.current+1;O.current=u,F.current=s,U(!1),A.mutate({includeIssues:V,includeSkills:S.skills,requestId:u,signal:s.signal})}const q=de({mutationFn:()=>ee.exportBundle(e,{include:{company:!0,agents:!0,projects:!0,issues:V,skills:S.skills},selectedFiles:Array.from(P).sort(),sidebarOrder:ae}),onSuccess:s=>{const u=new Set(Object.keys(s.files));Rt(s,u,s.files),n({tone:"success",title:"Export downloaded",body:`${u.size} file${u.size===1?"":"s"} exported as ${s.rootPath}.zip`})},onError:s=>{n({tone:"error",title:"Export failed",body:s instanceof Error?s.message:"Failed to build export package."})}});(0,m.useEffect)(()=>{e&&(ne.current!==e&&(ne.current=e,g(null),j(null)),M())},[e,V,S.skills]),(0,m.useEffect)(()=>()=>{O.current+=1,F.current?.abort()},[]);const L=(0,m.useMemo)(()=>a?me(a.files):[],[a]),P=(0,m.useMemo)(()=>a?kt({filePaths:Object.keys(a.files),issues:a.manifest.issues,categories:S,embeddedAssets:a.manifest.embeddedAssets??[]}):new Set,[a,S]),Ne=(0,m.useMemo)(()=>a?vt(Object.keys(a.files),a.manifest.issues):null,[a]),{displayTree:Ae,totalTaskChildren:ce,visibleTaskChildren:le}=(0,m.useMemo)(()=>{let s=L;b&&(s=Ce(s,b));const u=Pt(s,C,b,w);return{displayTree:u.nodes,totalTaskChildren:u.totalTaskChildren,visibleTaskChildren:u.visibleTaskChildren}},[L,b,C,w]),Pe=(0,m.useMemo)(()=>{const s={};function u(f){if(f.kind==="file"){const k=P.has(f.path);return k||(s[f.path]="muted"),k}let y=!1;for(const k of f.children)u(k)&&(y=!0);return y||(s[f.path]="muted"),y}for(const f of L)u(f);return s},[L,P]),K=(0,m.useMemo)(()=>{if(!a)return{};const s={...a.files},u=a.paperclipExtensionPath;if(u&&typeof a.files[u]=="string"&&(s[u]=Nt(a.files[u],P)),typeof a.files["README.md"]=="string"){const f=a.manifest.company?.name??o?.name??"Company",y=a.manifest.company?.description??null;s["README.md"]=Ot(a.manifest,P,f,y)}return s},[a,P,o?.name]),Re=(0,m.useMemo)(()=>a?ct(Ee(a.files,P,K),a.rootPath):0,[a,P,K]),ue=(0,m.useMemo)(()=>rt(L),[L]),I=P.size,$=(0,m.useMemo)(()=>a?a.warnings.filter(s=>!/terminated agent/i.test(s)):[],[a]);function Te(s){E(u=>{const f=new Set(u);return f.has(s)?f.delete(s):f.add(s),f})}function Le(s){D(u=>({...u,[s]:!u[s]}))}function Oe(s){const u=b.length>0,f=s.length>0;if(f&&!u&&(W.current=new Set(R)),_(s),f){const y=At(L,s);E(k=>{const v=new Set(k);for(const Y of y)v.add(Y);return v})}else u&&W.current&&(E(W.current),W.current=null)}function Me(s){if(!a)return;const u=a.manifest.skills.find(f=>f.key===s||f.slug===s)?.path??`skills/${s}/SKILL.md`;u in a.files&&(Q(u),E(f=>{const y=new Set(f);y.add("skills");const k=u.split("/").slice(0,-1);let v="";for(const Y of k)v=v?`${v}/${Y}`:Y,y.add(v);return y}))}function Fe(){!a||P.size===0||q.isPending||q.mutate()}function Ie(){O.current+=1,F.current?.abort(),F.current=null,A.reset(),U(!0)}if(!e)return(0,t.jsx)(z,{icon:B,message:"Select an organization to export."});if(A.isPending&&!a)return(0,t.jsx)(et,{variant:"detail"});if(N&&!a)return(0,t.jsx)(z,{icon:B,title:"Export preview cancelled",message:"The preview request was cancelled. Your export settings are unchanged.",action:"Retry preview",onAction:M,hideActionIcon:!0});if(A.isError&&!a)return(0,t.jsx)(z,{icon:B,title:"Export preview failed",message:te(A.error),description:"Retry the preview. You do not need to reload this page.",action:"Retry preview",onAction:M,hideActionIcon:!0});if(!a)return(0,t.jsx)(z,{icon:B,title:"Export preview unavailable",message:"No export preview is loaded.",action:"Load preview",onAction:M,hideActionIcon:!0});const $e=w?K[w]??null:null;return(0,t.jsxs)("div",{className:"max-w-6xl",children:[(0,t.jsx)("div",{className:"sticky top-0 z-10 border-b border-border bg-background px-5 py-3",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[(0,t.jsxs)("span",{className:"font-medium",children:[o?.name??"Organization"," export"]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:["Exporting ",I.toLocaleString()," of ",ue.toLocaleString()," file",ue===1?"":"s",I>0&&` (~${lt(Re)})`]}),$.length>0&&(0,t.jsxs)("span",{className:"text-amber-500",children:[$.length," warning",$.length===1?"":"s"]})]}),(0,t.jsxs)(X,{size:"sm",onClick:Fe,disabled:I===0||q.isPending||A.isPending||A.isError||N,children:[(0,t.jsx)(ft,{className:"mr-1.5 h-3.5 w-3.5"}),q.isPending?"Building export...":`Export ${I.toLocaleString()} file${I===1?"":"s"}`]})]})}),$.length>0&&(0,t.jsx)("div",{className:"mx-5 mt-3 rounded-md border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:$.map(s=>(0,t.jsx)("div",{className:"text-xs text-amber-500",children:s},s))}),x&&x.warnings.length>0&&(0,t.jsxs)("div",{className:"mx-5 mt-3 rounded-md border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:[(0,t.jsx)("h3",{className:"mb-1.5 text-xs font-medium",children:"Not included in this export"}),x.warnings.map(s=>(0,t.jsx)("div",{className:se("text-xs",s.severity==="blocker"?"font-medium text-destructive":"text-amber-500"),children:s.message},s.code))]}),(0,t.jsxs)("div",{className:"grid gap-4 xl:h-(--sz-calc-30) xl:grid-cols-(--gtc-25) xl:gap-0",children:[(0,t.jsxs)("aside",{className:"flex max-h-(--sz-24rem) flex-col overflow-hidden border-b border-border xl:max-h-none xl:border-b-0 xl:border-r",children:[(0,t.jsx)("div",{className:"border-b border-border px-4 py-3 shrink-0",children:(0,t.jsx)("h2",{className:"text-base font-semibold",children:"Package files"})}),(0,t.jsxs)("div",{className:"border-b border-border px-4 py-3 shrink-0",children:[(0,t.jsx)("h3",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"What to include"}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",role:"group","aria-label":"What to include",children:mt.map(s=>{const u=s==="attachments"&&!je(S),f=S[s]&&!u,y=Ne?.[s]??0,k=a.manifest.includes.issues||s!=="tasks"&&s!=="routines"&&s!=="attachments";return(0,t.jsxs)("label",{className:se("flex items-center gap-2 text-sm",u?"cursor-not-allowed opacity-50":"cursor-pointer"),title:u?"Attachments travel with tasks and routines; re-enable one of them to include attachments.":void 0,children:[(0,t.jsx)("input",{type:"checkbox",checked:f,disabled:u,onChange:()=>Le(s),className:"accent-foreground","data-export-category":s}),(0,t.jsx)("span",{className:"min-w-0 truncate",children:ht[s]}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:k?y.toLocaleString():"—"})]},s)})}),(0,t.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Task and routine history is opt-in because it can be large."})]}),(0,t.jsx)("div",{className:"border-b border-border px-3 py-2 shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border px-2 py-1",children:[(0,t.jsx)(Ge,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("input",{type:"text",value:b,onChange:s=>Oe(s.target.value),placeholder:"Search files...",className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground","data-page-search-target":"true"})]})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,t.jsx)(it,{nodes:Ae,selectedFile:w,expandedDirs:R,onToggleDir:Te,onSelectFile:Q,fileTones:Pe,showCheckboxes:!1,wrapLabels:!1}),ce>le&&!b&&(0,t.jsx)("div",{className:"px-4 py-2",children:(0,t.jsxs)("button",{type:"button",onClick:()=>T(s=>s+he),className:"w-full rounded-md border border-border px-3 py-1.5 text-xs text-muted-foreground hover:bg-accent/30 hover:text-foreground transition-colors",children:["Show more tasks (",le," of ",ce,")"]})})]})]}),(0,t.jsxs)("div",{className:"relative min-w-0 overflow-y-auto xl:pl-6",children:[(0,t.jsx)(Ft,{selectedFile:w,content:$e,allFiles:K,orgChartPreviewUrl:`/api/companies/${encodeURIComponent(e)}/org.svg`,onSkillClick:Me}),A.isPending?(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex min-h-(--sz-520px) items-center justify-center bg-background/90 px-6 text-center",role:"status","aria-live":"polite","aria-busy":"true","data-export-preview-state":"loading",children:(0,t.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3",children:[(0,t.jsx)(Je,{className:"h-6 w-6 animate-spin text-muted-foreground"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Updating export preview…"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large task histories can take a minute. You can untick Tasks or cancel this update."})]}),(0,t.jsxs)(X,{type:"button",variant:"outline",size:"sm",onClick:Ie,children:[(0,t.jsx)(Ze,{}),"Cancel update"]})]})}):N?(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex min-h-(--sz-520px) items-center justify-center bg-background/90 px-6 text-center","data-export-preview-state":"cancelled",children:(0,t.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Preview update cancelled"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"The previous preview remains available. Retry when you are ready."})]}),(0,t.jsxs)(X,{type:"button",variant:"outline",size:"sm",onClick:M,children:[(0,t.jsx)(fe,{}),"Retry preview"]})]})}):A.isError?(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex min-h-(--sz-520px) items-center justify-center bg-background/90 px-6 text-center",role:"alert","data-export-preview-state":"error",children:(0,t.jsxs)("div",{className:"flex max-w-md flex-col items-center gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-destructive",children:"Export preview failed"}),(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:te(A.error)})]}),(0,t.jsxs)(X,{type:"button",variant:"outline",size:"sm",onClick:M,children:[(0,t.jsx)(fe,{}),"Retry preview"]})]})}):null]})]})]})}export{Vt as CompanyExport};
|
package/ui-dist/assets/{CompanySkills.production-Fq7UjewY.js → CompanySkills.production-DB3F_EDs.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as jn}from"./rolldown-runtime-BQ-vy_Pv.js";import{An as W,S as K,U as pr,fr as gr,jn as me,lr as fr,q as g,ur as br,z as jr}from"./createLucideIcon-JUO5qdpL.js";import{ct as vr,o as yr,st as kr,t as Ze}from"./router-Dr6qx_6q.js";import{Z as Nr}from"./mention-chips-D8B6eEdr.js";import{N as he,g as wr,l as Sr,o as vn,x as Cr}from"./zap-RUrW_UgS.js";import{C as Fr,O as Ds,S as Is,a as gs,c as fs,f as qe,g as Ls,h as Me,n as bt,o as Ts,p as Re,r as bs,s as jt,t as Ir,u as js,v as Bs,x as mt,y as Ps}from"./checkbox-Bhf00Qhn.js";import{c as Dr,i as z,t as Lr}from"./MarkdownEditor-dns9I8bB.js";import{i as Es,r as yn,t as kn}from"./tabs-B-hJilg9.js";import{m as Nn}from"./StatusIcon-CeMClGJ9.js";import{a as Br,d as wn,f as Pr,i as xt,l as Er,n as Ct,o as Qs,r as Tr,s as ht,t as Ar,u as Sn}from"./CopyText-CuFpZ9d_.js";import{n as Kr}from"./BreadcrumbContext-D3CAiFzt.js";import{t as Cn}from"./check-BjBG4-fn.js";import{t as hs}from"./chevron-down-CqCCAew2.js";import{t as Fn}from"./chevron-right-BFXkqip_.js";import{i as qr,n as pt}from"./InlineBanner-C4MQkh4l.js";import{A as vt,t as y}from"./button-DWgQnsK-.js";import{a as Mr}from"./agent-icons-DvoCe7FN.js";import{r as In,t as Rr}from"./clipboard-BCz9EG42.js";import{n as $r,t as zr}from"./trash-2-BEPrNbsT.js";import{t as ps}from"./external-link-DsqjvF7j.js";import{b as _r,t as yt,y as Ft}from"./MarkdownBody-CGVDfzLB.js";import{n as It}from"./key-round-gDAuHlTR.js";import{l as Dn,u as Ur}from"./sheet-CbxOKHRQ.js";import{n as Dt,t as Hs}from"./agents-yMBk3d4f.js";import{t as kt}from"./pause-DO_JBZWF.js";import{t as Gs}from"./refresh-cw-DV-bSEwh.js";import{t as Ln}from"./triangle-alert-DEq939Ib.js";import{t as ae}from"./badge-CxX1YhiF.js";import{i as Or}from"./ToastContext-Dmfqh1in.js";import{t as Ke}from"./input-DjyO-oZf.js";import{t as tn}from"./AgentIconPicker-B6761LdM.js";import{t as De}from"./PageSkeleton-DYqd8XzH.js";import{$ as Vr,$t as Bn,Cr as Nt,J as Qr,Sr as Hr,X as Gr,Xn as Wr,Y as Yr,Z as Xr,_ as Zr,_r as Pn,ar as Jr,at as ea,c as sa,cr as ta,ct as na,d as ra,dt as Ye,er as aa,et as la,f as As,fn as ia,g as oa,gr as vs,h as da,hn as Xe,ht as xe,in as ca,l as ua,lt as En,m as Tn,mr as ma,nr as An,nt as xa,o as ha,ot as pa,p as gt,pr as ga,q as fa,rt as ba,s as ja,sr as va,st as ya,tt as ka,u as Na,ut as nn,vr as Kn,wr as rn,yr as wt}from"./index-
|
|
1
|
+
import{i as jn}from"./rolldown-runtime-BQ-vy_Pv.js";import{An as W,S as K,U as pr,fr as gr,jn as me,lr as fr,q as g,ur as br,z as jr}from"./createLucideIcon-JUO5qdpL.js";import{ct as vr,o as yr,st as kr,t as Ze}from"./router-Dr6qx_6q.js";import{Z as Nr}from"./mention-chips-D8B6eEdr.js";import{N as he,g as wr,l as Sr,o as vn,x as Cr}from"./zap-RUrW_UgS.js";import{C as Fr,O as Ds,S as Is,a as gs,c as fs,f as qe,g as Ls,h as Me,n as bt,o as Ts,p as Re,r as bs,s as jt,t as Ir,u as js,v as Bs,x as mt,y as Ps}from"./checkbox-Bhf00Qhn.js";import{c as Dr,i as z,t as Lr}from"./MarkdownEditor-dns9I8bB.js";import{i as Es,r as yn,t as kn}from"./tabs-B-hJilg9.js";import{m as Nn}from"./StatusIcon-CeMClGJ9.js";import{a as Br,d as wn,f as Pr,i as xt,l as Er,n as Ct,o as Qs,r as Tr,s as ht,t as Ar,u as Sn}from"./CopyText-CuFpZ9d_.js";import{n as Kr}from"./BreadcrumbContext-D3CAiFzt.js";import{t as Cn}from"./check-BjBG4-fn.js";import{t as hs}from"./chevron-down-CqCCAew2.js";import{t as Fn}from"./chevron-right-BFXkqip_.js";import{i as qr,n as pt}from"./InlineBanner-C4MQkh4l.js";import{A as vt,t as y}from"./button-DWgQnsK-.js";import{a as Mr}from"./agent-icons-DvoCe7FN.js";import{r as In,t as Rr}from"./clipboard-BCz9EG42.js";import{n as $r,t as zr}from"./trash-2-BEPrNbsT.js";import{t as ps}from"./external-link-DsqjvF7j.js";import{b as _r,t as yt,y as Ft}from"./MarkdownBody-CGVDfzLB.js";import{n as It}from"./key-round-gDAuHlTR.js";import{l as Dn,u as Ur}from"./sheet-CbxOKHRQ.js";import{n as Dt,t as Hs}from"./agents-yMBk3d4f.js";import{t as kt}from"./pause-DO_JBZWF.js";import{t as Gs}from"./refresh-cw-DV-bSEwh.js";import{t as Ln}from"./triangle-alert-DEq939Ib.js";import{t as ae}from"./badge-CxX1YhiF.js";import{i as Or}from"./ToastContext-Dmfqh1in.js";import{t as Ke}from"./input-DjyO-oZf.js";import{t as tn}from"./AgentIconPicker-B6761LdM.js";import{t as De}from"./PageSkeleton-DYqd8XzH.js";import{$ as Vr,$t as Bn,Cr as Nt,J as Qr,Sr as Hr,X as Gr,Xn as Wr,Y as Yr,Z as Xr,_ as Zr,_r as Pn,ar as Jr,at as ea,c as sa,cr as ta,ct as na,d as ra,dt as Ye,er as aa,et as la,f as As,fn as ia,g as oa,gr as vs,h as da,hn as Xe,ht as xe,in as ca,l as ua,lt as En,m as Tn,mr as ma,nr as An,nt as xa,o as ha,ot as pa,p as gt,pr as ga,q as fa,rt as ba,s as ja,sr as va,st as ya,tt as ka,u as Na,ut as nn,vr as Kn,wr as rn,yr as wt}from"./index-BaG1tZj1.js";var o=jn(gr(),1),e=jn(br(),1),an=16,ln=24,on="min-h-9";function dn(t){return(0,e.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",...t,children:(0,e.jsx)("path",{d:"M12 4 21 19H3z"})})}function qn(t){const a=t.replace(/\r\n/g,`
|
|
2
2
|
`);if(!a.startsWith(`---
|
|
3
3
|
`))return a.trim();const r=a.indexOf(`
|
|
4
4
|
---
|