diff --git a/.github/workflows/build-p2p.yml b/.github/workflows/build-p2p.yml index e448555..62d1053 100644 --- a/.github/workflows/build-p2p.yml +++ b/.github/workflows/build-p2p.yml @@ -35,6 +35,15 @@ jobs: go-version-file: go.mod cache: true + - uses: actions/setup-node@v4 + with: + node-version: "20" + cache: npm + cache-dependency-path: web/package-lock.json + + - name: Build web bundle + run: cd web && npm ci && npm run build + - name: Build env: BUILD_TAG: ${{ matrix.tag }} diff --git a/.gitignore b/.gitignore index 5ca43a1..8ba924c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ data/ # Web UI web/node_modules/ web/dist/ +internal/web/dist/ # IDE .idea/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2936d5c..8c6a94a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,6 +33,8 @@ cd web && npm run build ``` Include a clear summary, verification notes, and screenshots for user-facing dashboard changes. +The generated dashboard bundle under `internal/web/dist` is ignored; do not +commit anything from that directory. ## Project Rules diff --git a/Makefile b/Makefile index c1f2d76..ae4c679 100644 --- a/Makefile +++ b/Makefile @@ -142,7 +142,7 @@ secret: ./bin/mcplexer secret put $(SCOPE) $(KEY) $(VALUE) clean: - rm -rf bin/ web/dist/ + rm -rf bin/ web/dist/ internal/web/dist/ uninstall: -./bin/mcplexer daemon stop 2>/dev/null @@ -162,7 +162,7 @@ worktrees-gc-yes: @bash scripts/worktrees-gc.sh --yes # Cross-compile Go for all platforms -go-build-platforms: +go-build-platforms: web-build GOOS=darwin GOARCH=arm64 go build -tags p2p -ldflags "$(GO_LDFLAGS)" -o bin/darwin/arm64/mcplexer ./cmd/mcplexer GOOS=darwin GOARCH=amd64 go build -tags p2p -ldflags "$(GO_LDFLAGS)" -o bin/darwin/amd64/mcplexer ./cmd/mcplexer GOOS=linux GOARCH=amd64 go build -tags p2p -ldflags "$(GO_LDFLAGS)" -o bin/linux/amd64/mcplexer ./cmd/mcplexer diff --git a/Taskfile.yml b/Taskfile.yml index c6adc1e..6e0a154 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -221,7 +221,7 @@ tasks: clean: desc: Remove build artifacts cmds: - - rm -rf bin/ web/dist/ + - rm -rf bin/ web/dist/ internal/web/dist/ uninstall: desc: Stop the daemon and remove installed binaries @@ -253,6 +253,7 @@ tasks: go-build-platforms: desc: Cross-compile Go binaries for common platforms cmds: + - task: web-build - GOOS=darwin GOARCH=arm64 go build -o bin/darwin/arm64/mcplexer ./cmd/mcplexer - GOOS=darwin GOARCH=amd64 go build -o bin/darwin/amd64/mcplexer ./cmd/mcplexer - GOOS=linux GOARCH=amd64 go build -o bin/linux/amd64/mcplexer ./cmd/mcplexer diff --git a/internal/api/router.go b/internal/api/router.go index 5b0128e..1989372 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -1007,6 +1007,9 @@ func NewRouter(deps RouterDeps) http.Handler { // session cookie when an HTML document is served so that subsequent API // fetches from the SPA carry authentication automatically. distFS, err := fs.Sub(web.StaticFiles, "dist") + if err == nil { + _, err = fs.Stat(distFS, "index.html") + } if err == nil { spaHandler := spaFallback(distFS, http.FileServerFS(distFS), deps.APIToken) mux.Handle("/", spaHandler) diff --git a/internal/web/dist/assets/ApprovalsPage-Diz3qyC2.js b/internal/web/dist/assets/ApprovalsPage-Diz3qyC2.js deleted file mode 100644 index d09bd21..0000000 --- a/internal/web/dist/assets/ApprovalsPage-Diz3qyC2.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{It as n,ft as r,in as i,on as a}from"./client-CaIRceNv.js";import{t as o}from"./createLucideIcon-WB390fY6.js";import{t as s}from"./calendar-clock-Z37rBeGY.js";import{t as c}from"./chevron-right-CyhRDGe7.js";import{t as l}from"./list-checks-B0hSiAul.js";import{$n as u,Br as d,C as f,Cr as p,D as m,E as h,Fn as g,Ft as _,Gn as v,Hn as y,It as ee,Ln as b,S as x,Sr as S,T as te,Vn as C,Wn as w,_ as ne,cr as re,jr as T,n as ie,sr as E,t as D,w as O,y as k,yr as A}from"./index-BDLzoIgt.js";import{t as j}from"./empty-state-B9mtYx_X.js";import{a as M,i as N,n as ae,o as P,r as F,t as oe}from"./table-2N0Q-yAm.js";import{i as I,o as L}from"./task-utils-BkVzAeUR.js";var se=o(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),R=o(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),z=e(t(),1),B=a(),V={mcp:{label:`mcp`,Icon:u},shell:{label:`shell`,Icon:C},schedule:{label:`schedule`,Icon:s},network:{label:`network`,Icon:re},sanitizer:{label:`sanitizer`,Icon:v}};function H(e){return V[e||`mcp`]??V.mcp}var U={skill_share:{label:`skill share`,Icon:y},memory_share:{label:`memory share`,Icon:p},task_offer:{label:`task offer`,Icon:l},mesh_direct:{label:`mesh message`,Icon:R},mesh_grant_consent:{label:`scope grant`,Icon:E}};function W(e){return e?U[e]??{label:e.replace(/_/g,` `),Icon:E}:null}function G(e){return e.kind?e.summary||W(e.kind)?.label||e.kind:e.tool_name||`(unnamed call)`}function K({status:e}){switch(e){case`approved`:return(0,B.jsx)(k,{tone:`success`,children:`approved`});case`denied`:return(0,B.jsx)(k,{tone:`critical`,children:`denied`});case`timeout`:return(0,B.jsx)(k,{tone:`warn`,children:`timeout`});case`cancelled`:return(0,B.jsx)(k,{tone:`muted`,children:`cancelled`});case`pending`:return(0,B.jsx)(k,{tone:`warn`,children:`pending`});default:return(0,B.jsx)(k,{tone:`muted`,children:e})}}function q({approverType:e,approverSessionID:t}){if(e===`afk-policy`&&t.startsWith(`rule:`)){let e=t.slice(5);return(0,B.jsxs)(k,{tone:`info`,className:`font-mono lowercase tracking-normal`,title:`Auto-approved by rule ${e}`,children:[(0,B.jsx)(se,{className:`h-2.5 w-2.5`}),`rule:`,e.slice(0,8)]})}return e===`afk-policy`?(0,B.jsx)(k,{tone:`info`,children:`auto-rule`}):e===`dashboard`?(0,B.jsx)(k,{tone:`success`,children:`human`}):t===`dangerous-mode`?(0,B.jsx)(k,{tone:`critical`,children:`dangerous-mode`}):e?(0,B.jsx)(k,{tone:`muted`,children:e}):(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}function ce(e){if(!e.resolved_at)return``;let t=new Date(e.resolved_at).getTime()-new Date(e.created_at).getTime();if(!Number.isFinite(t)||t<0)return``;let n=Math.round(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60),i=n%60;return i?`${r}m ${i}s`:`${r}m`}function J(e,t,n){let r=(n-new Date(e).getTime())/1e3,i=Math.max(0,t-r);if(i<=0)return`expired`;let a=Math.floor(i/60),o=Math.floor(i%60);return a>0?`${a}m ${o}s`:`${o}s`}function le(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Y(e,t){let[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(!1);async function s(i){if(!i&&!r.trim()){T.error(`A reason is required when denying`);return}o(!0);try{await n(e,{approved:i,reason:r}),T.success(i?`Approved`:`Denied`),t()}catch(e){T.error(e instanceof Error?e.message:`Failed to resolve`)}finally{o(!1)}}return{reason:r,setReason:i,resolving:a,resolve:s}}function X({approval:e,onResolved:t,now:n,highlighted:r,registerRef:a,onOpenDetail:o}){let{reason:s,setReason:c,resolving:l,resolve:u}=Y(e.id,t),d=J(e.created_at,e.timeout_sec,n),f=d===`expired`,p=H(e.surface),m=W(e.kind);return(0,B.jsx)(D,{ref:t=>a?.(e.id,t),className:i(`border-amber-500/40 bg-amber-500/[0.03] transition-shadow`,r&&`ring-2 ring-amber-400/80 ring-offset-2 ring-offset-background`),children:(0,B.jsxs)(ie,{className:`space-y-3 pt-5`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:o,"data-testid":`approval-detail-${e.id}`,className:`-m-1 block w-full space-y-2 p-1 text-left transition-colors hover:bg-amber-500/[0.04]`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,B.jsx)(`div`,{className:`break-all font-mono text-sm text-accent-foreground`,children:G(e)}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono uppercase tracking-wider`,children:[(0,B.jsx)(p.Icon,{className:`h-2.5 w-2.5`}),p.label]}),m&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono uppercase tracking-wider`,children:[(0,B.jsx)(m.Icon,{className:`h-2.5 w-2.5`}),m.label]}),(0,B.jsxs)(`span`,{children:[`· `,e.request_client_type||`unknown`]})]})]}),(0,B.jsxs)(`div`,{className:i(`flex shrink-0 items-center gap-1.5 text-xs tabular-nums`,f?`text-destructive`:`text-amber-500`),children:[(0,B.jsx)(A,{className:`h-3 w-3`}),d]})]}),(0,B.jsx)(`p`,{className:`line-clamp-2 bg-amber-500/[0.06] p-2 text-sm leading-relaxed text-foreground/90`,children:e.justification||e.summary||`No justification provided`})]}),(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(_,{placeholder:`Reason (required for deny)`,value:s,onChange:e=>c(e.target.value),className:`text-sm`,"data-testid":`approval-reason-${e.id}`,"aria-label":`Approval reason`}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsxs)(g,{size:`sm`,variant:`success`,onClick:()=>u(!0),disabled:l||f,className:`flex-1`,"data-testid":`approval-approve-${e.id}`,children:[(0,B.jsx)(S,{className:`mr-1 h-3.5 w-3.5`}),`Approve`]}),(0,B.jsxs)(g,{size:`sm`,variant:`outline`,onClick:()=>u(!1),disabled:l||f,className:`border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive`,"data-testid":`approval-deny-${e.id}`,children:[(0,B.jsx)(b,{className:`mr-1 h-3.5 w-3.5`}),`Deny`]})]})]})]})})}var ue=[`all`,`approved`,`denied`,`timeout`,`cancelled`];function de(e){return[...e].sort((e,t)=>{let n=new Date(e.resolved_at||e.created_at).getTime();return new Date(t.resolved_at||t.created_at).getTime()-n})}function fe({items:e,onOpenDetail:t}){let[n,r]=(0,z.useState)(`all`),a=(0,z.useMemo)(()=>{let t={};for(let n of e)t[n.status]=(t[n.status]??0)+1;return t},[e]),o=(0,z.useMemo)(()=>{let t=de(e);return n===`all`?t:t.filter(e=>e.status===n)},[e,n]);return(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`History`}),(0,B.jsx)(`div`,{className:`flex items-center gap-1 text-xs`,children:ue.map(t=>{let o=t===`all`?e.length:a[t]??0;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(t),className:i(`px-2 py-1 font-mono lowercase tracking-wide transition-colors`,n===t?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`),children:[t,(0,B.jsx)(`span`,{className:`ml-1 tabular-nums text-muted-foreground/70`,children:o})]},t)})})]}),(0,B.jsx)(`div`,{className:`border border-border`,children:(0,B.jsxs)(oe,{children:[(0,B.jsx)(M,{children:(0,B.jsxs)(P,{className:`border-border hover:bg-transparent`,children:[(0,B.jsx)(N,{className:`w-[7rem]`,children:`When`}),(0,B.jsx)(N,{children:`Request`}),(0,B.jsx)(N,{className:`hidden w-[8rem] sm:table-cell`,children:`Surface`}),(0,B.jsx)(N,{className:`w-[7rem]`,children:`Outcome`}),(0,B.jsx)(N,{className:`hidden w-[10rem] md:table-cell`,children:`By`}),(0,B.jsx)(N,{className:`w-8`})]})}),(0,B.jsx)(ae,{children:o.map(e=>{let n=H(e.surface),r=e.resolved_at||e.created_at;return(0,B.jsxs)(P,{onClick:()=>t(e),className:`group cursor-pointer border-border/40 hover:bg-muted/40`,children:[(0,B.jsx)(F,{className:`whitespace-nowrap font-mono text-xs text-muted-foreground`,title:I(r),children:L(r)}),(0,B.jsx)(F,{children:(0,B.jsx)(`div`,{className:`max-w-[22rem] truncate font-mono text-sm text-accent-foreground`,title:G(e),children:G(e)})}),(0,B.jsx)(F,{className:`hidden sm:table-cell`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-xs uppercase tracking-wider text-muted-foreground`,children:[(0,B.jsx)(n.Icon,{className:`h-2.5 w-2.5`}),n.label]})}),(0,B.jsx)(F,{children:(0,B.jsx)(K,{status:e.status})}),(0,B.jsx)(F,{className:`hidden md:table-cell`,children:(0,B.jsx)(q,{approverType:e.approver_type,approverSessionID:e.approver_session_id})}),(0,B.jsx)(F,{className:`text-muted-foreground/40 group-hover:text-muted-foreground`,children:(0,B.jsx)(c,{className:`h-4 w-4`})})]},e.id)})})]})})]})}function Z({label:e,children:t}){return(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),t]})}function Q({label:e,value:t,mono:n,title:r}){return t?(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 text-sm`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 text-right`,children:[(0,B.jsx)(`span`,{className:i(`truncate`,n&&`font-mono text-xs`),title:r??t,children:t}),n&&(0,B.jsx)(ne,{value:t,className:`shrink-0`})]})]}):null}function pe({approval:e,now:t,onOpenChange:n,onResolved:r}){return(0,B.jsx)(f,{open:!!e,onOpenChange:n,children:(0,B.jsx)(O,{side:`right`,className:`w-full gap-0 sm:max-w-xl`,children:e&&(0,B.jsx)(me,{approval:e,now:t,onResolved:r})})})}function me({approval:e,now:t,onResolved:n}){let r=H(e.surface),a=W(e.kind),o=e.status===`pending`,s=J(e.created_at,e.timeout_sec,t),c=s===`expired`,{reason:l,setReason:u,resolving:d,resolve:f}=Y(e.id,n);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(h,{className:`border-b border-border`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pr-8`,children:[(0,B.jsx)(K,{status:e.status}),(0,B.jsx)($,{label:r.label,Icon:r.Icon}),a&&(0,B.jsx)($,{label:a.label,Icon:a.Icon})]}),(0,B.jsx)(m,{className:`break-all font-mono text-base`,children:G(e)}),(0,B.jsxs)(te,{children:[`Requested by `,e.request_client_type||`unknown`,e.request_model?` · ${e.request_model}`:``]})]}),(0,B.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto p-4`,children:[o&&(0,B.jsxs)(`div`,{className:i(`flex items-center gap-2 border px-3 py-2 text-sm tabular-nums`,c?`border-destructive/40 bg-destructive/10 text-destructive`:`border-amber-500/40 bg-amber-500/10 text-amber-300`),children:[(0,B.jsx)(A,{className:`h-3.5 w-3.5 shrink-0`}),c?`Window expired`:`${s} left to decide`]}),(0,B.jsxs)(Z,{label:`Request`,children:[(0,B.jsx)(Q,{label:`Workspace`,value:e.workspace_name||e.workspace_id,title:e.workspace_id}),(0,B.jsx)(Q,{label:`Originating`,value:e.originating_workspace,mono:!0}),(0,B.jsx)(Q,{label:`Surface`,value:r.label}),(0,B.jsx)(Q,{label:`Route rule`,value:e.route_rule_id,mono:!0}),(0,B.jsx)(Q,{label:`Downstream`,value:e.downstream_server_id,mono:!0}),(0,B.jsx)(Q,{label:`Auth scope`,value:e.auth_scope_id,mono:!0}),(0,B.jsx)(Q,{label:`Requested`,value:L(e.created_at),title:I(e.created_at)})]}),e.justification&&(0,B.jsx)(Z,{label:`Justification`,children:(0,B.jsx)(`p`,{className:`bg-muted/40 p-3 text-sm leading-relaxed`,children:e.justification})}),e.kind&&e.summary&&(0,B.jsx)(Z,{label:`Summary`,children:(0,B.jsx)(`p`,{className:`bg-muted/40 p-3 text-sm leading-relaxed`,children:e.summary})}),e.arguments&&e.arguments!==`{}`&&(0,B.jsx)(Z,{label:`Arguments`,children:(0,B.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words bg-muted/40 p-3 font-mono text-xs`,children:le(e.arguments)})}),!o&&(0,B.jsxs)(Z,{label:`What happened`,children:[(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Outcome`}),(0,B.jsx)(K,{status:e.status})]}),(0,B.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 text-sm`,children:[(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:`Resolved by`}),(0,B.jsx)(q,{approverType:e.approver_type,approverSessionID:e.approver_session_id})]}),(0,B.jsx)(Q,{label:`Waited`,value:ce(e)}),(0,B.jsx)(Q,{label:`Resolved`,value:e.resolved_at?L(e.resolved_at):null,title:e.resolved_at?I(e.resolved_at):void 0}),e.resolution&&(0,B.jsx)(`p`,{className:`mt-1 bg-muted/40 p-3 text-sm leading-relaxed`,children:e.resolution})]})]}),o&&(0,B.jsxs)(`div`,{className:`space-y-2 border-t border-border p-4`,children:[(0,B.jsx)(_,{placeholder:`Reason (required for deny)`,value:l,onChange:e=>u(e.target.value),className:`text-sm`,"aria-label":`Approval reason`}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsxs)(g,{size:`sm`,variant:`success`,onClick:()=>f(!0),disabled:d||c,className:`flex-1`,children:[(0,B.jsx)(S,{className:`mr-1 h-3.5 w-3.5`}),`Approve`]}),(0,B.jsxs)(g,{size:`sm`,variant:`outline`,onClick:()=>f(!1),disabled:d||c,className:`border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive`,children:[(0,B.jsx)(b,{className:`mr-1 h-3.5 w-3.5`}),`Deny`]})]})]})]})}function $({label:e,Icon:t}){return(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-border bg-muted/40 px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[(0,B.jsx)(t,{className:`h-2.5 w-2.5`}),e]})}function he(){let[e,t]=(0,z.useState)(()=>Date.now());return(0,z.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function ge(){let{pending:e,connected:t}=ee(),n=he(),{data:i,refetch:a}=x((0,z.useCallback)(()=>r(`pending`),[])),{data:o,refetch:s}=x((0,z.useCallback)(()=>r(`resolved`),[])),[c,l]=(0,z.useState)(null),u=(0,z.useMemo)(()=>{let t=new Set,n=[];for(let r of[...e,...i??[]])t.has(r.id)||(t.add(r.id),n.push(r));return n},[e,i]),f=(0,z.useCallback)(()=>{l(null),a(),s()},[a,s]),[p,m]=d(),h=p.get(`selected`),[g,_]=(0,z.useState)(null),v=(0,z.useRef)(new Map),y=(0,z.useCallback)((e,t)=>{t?v.current.set(e,t):v.current.delete(e)},[]);return(0,z.useEffect)(()=>{if(!h)return;_(h);let e=0,t=()=>{let n=v.current.get(h);if(n){n.scrollIntoView({behavior:`smooth`,block:`center`});return}++e<=20&&requestAnimationFrame(t)};requestAnimationFrame(t);let n=setTimeout(()=>{m(e=>{let t=new URLSearchParams(e);return t.delete(`selected`),t},{replace:!0})},200),r=setTimeout(()=>_(null),3500);return()=>{clearTimeout(n),clearTimeout(r)}},[h,m]),(0,B.jsxs)(`div`,{className:`space-y-8`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Approvals`}),t?(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-emerald-400`,children:[(0,B.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,B.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75`}),(0,B.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full bg-emerald-500`})]}),`Live`]}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Connecting...`})]}),u.length>0?(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsxs)(`h2`,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:[`Pending (`,u.length,`)`]}),(0,B.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:u.map(e=>(0,B.jsx)(X,{approval:e,onResolved:f,now:n,highlighted:g===e.id,registerRef:y,onOpenDetail:()=>l(e)},e.id))})]}):(0,B.jsx)(j,{icon:(0,B.jsx)(w,{className:`h-8 w-8`}),title:`No pending approvals`,testid:`approvals-empty`,description:(0,B.jsx)(B.Fragment,{children:`When an agent tries to use a tool that requires your permission, it shows up here as a pending request. You can approve or deny each one before it runs.`})}),(o?.length??0)>0&&(0,B.jsx)(fe,{items:o??[],onOpenDetail:l}),(0,B.jsx)(pe,{approval:c,now:n,onOpenChange:e=>!e&&l(null),onResolved:f})]})}export{ge as ApprovalsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/AuditDetailDialog-CIIIkhsj.js b/internal/web/dist/assets/AuditDetailDialog-CIIIkhsj.js deleted file mode 100644 index e96be28..0000000 --- a/internal/web/dist/assets/AuditDetailDialog-CIIIkhsj.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./createLucideIcon-WB390fY6.js";import{t as a}from"./arrow-down-BlDh7bya.js";import{t as o}from"./arrow-up-CWTnU2zx.js";import{t as s}from"./cpu-DpW4CSHk.js";import{t as c}from"./funnel-BvqzDyhp.js";import{t as l}from"./route-CMSYmLBM.js";import{t as u}from"./sse-backoff-CEavbS-d.js";import{C as d,D as f,E as p,Fn as m,In as ee,Mr as h,Nr as g,Pr as _,Rr as v,_ as y,ar as b,ir as x,pr as S,sr as C,ur as te,w as ne,wr as w,y as T}from"./index-BDLzoIgt.js";import{t as E}from"./TaskRef-D6QBTHtc.js";var D=i(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]),O=i(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),k=i(`scan-search`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m16 16-1.9-1.9`,key:`1dq9hf`}]]),A=i(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),j=e(t(),1),M=200;function N(e){let[t,n]=(0,j.useState)([]),[r,i]=(0,j.useState)(!1),a=(0,j.useRef)(0),o=(0,j.useRef)(null),s=(0,j.useCallback)(()=>n([]),[]);return(0,j.useEffect)(()=>{let t=!1,r;function s(){if(t)return;let c=new URLSearchParams;e.workspace_id&&c.set(`workspace_id`,e.workspace_id),e.tool_name&&c.set(`tool_name`,e.tool_name),e.status&&c.set(`status`,e.status),e.execution_id&&c.set(`execution_id`,e.execution_id),e.session_id&&c.set(`session_id`,e.session_id);let l=c.toString(),d=`/api/v1/audit/stream${l?`?${l}`:``}`,f=new EventSource(d);o.current=f,f.onopen=()=>{t||(i(!0),a.current=0)},f.onmessage=e=>{if(!t)try{let t=JSON.parse(e.data);n(e=>[t,...e].slice(0,M))}catch{}},f.onerror=()=>{if(t)return;f.close(),o.current=null,i(!1);let e=u(a.current);a.current++,r=setTimeout(s,e)}}return s(),()=>{t=!0,clearTimeout(r),o.current?.close(),o.current=null,i(!1)}},[e.workspace_id,e.tool_name,e.status,e.execution_id,e.session_id]),{records:t,connected:r,clear:s}}function P(e){return e===`success`||e===`ok`?`success`:e===`blocked`?`blocked`:`error`}function F(e){return P(e)===`success`}function I(e){switch(e){case`secret.list`:return{op:`enumerate`,label:`Enumeration`,tone:`info`,blurb:`Listed the key names in this scope. No secret value was decrypted, read, or returned.`};case`secret.read`:return{op:`decrypt`,label:`Decryption`,tone:`notice`,blurb:`A stored secret was decrypted and substituted into a downstream call. The plaintext never enters an agent context or the audit log.`};case`secret.write`:return{op:`store`,label:`Stored secret`,tone:`notice`,blurb:`A secret value was written to this scope.`};case`secret.delete`:return{op:`delete`,label:`Deleted secret`,tone:`neutral`,blurb:`A secret key was removed from this scope.`};default:return null}}function L(e){return e.actor_kind===`secrets`||e.client_type===`secrets`}var R=r();function z(e){return F(e.status)?``:e.error_message?.includes(`denied`)?`blocked`:e.error_message===`no matching route`?`no route`:e.error_message||e.error_code||`error`}var B={info:`border-sky-500/40 bg-sky-500/10 text-sky-300`,notice:`border-amber-500/40 bg-amber-500/10 text-amber-300`,neutral:`border-border bg-muted/40 text-muted-foreground`};function V({toolName:e,className:t}){let r=I(e);if(!r)return null;let i=r.op===`enumerate`?k:r.op===`decrypt`?S:C;return(0,R.jsxs)(`span`,{title:r.blurb,className:n(`inline-flex items-center gap-1 rounded-sm border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider align-middle`,B[r.tone],t),children:[(0,R.jsx)(i,{className:`h-2.5 w-2.5`}),r.label]})}function H(e){let t=e.split(` -`).find(e=>e.trim().length>0)??e;return t.length>80?t.slice(0,77)+`…`:t}function U({record:e}){let t=z(e);if(!t)return null;let r=t===`blocked`,i=r||t===`no route`?t:H(t);return(0,R.jsx)(`span`,{className:n(`inline-block max-w-full truncate rounded-sm border px-2 py-0.5 text-xs font-medium align-middle`,r?`border-amber-500/40 text-amber-500`:`border-destructive/40 text-destructive`),title:t,children:i})}function W({record:e,onClose:t,wsName:r,asName:i,onPrev:c,onNext:u,hasPrev:T,hasNext:M}){let N=v();if((0,j.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||((e.key===`j`||e.key===`ArrowDown`)&&u&&M?(e.preventDefault(),u()):(e.key===`k`||e.key===`ArrowUp`)&&c&&T&&(e.preventDefault(),c()))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,c,u,T,M]),!e)return null;let F=e.status,V=z(e),H=P(F)!==`success`,U=e.workspace_name||(e.workspace_id?r(e.workspace_id):``),W=Object.keys(e.params_redacted??{}),Z=I(e.tool_name),Q=L(e),$=e.auth_scope_id?i(e.auth_scope_id):``;return(0,R.jsx)(d,{open:!!e,onOpenChange:e=>!e&&t(),children:(0,R.jsxs)(ne,{side:`right`,className:`flex w-full flex-col gap-0 p-0 sm:max-w-[min(720px,92vw)]`,children:[(0,R.jsxs)(p,{className:`space-y-3 border-b border-border/60 p-5 pr-12`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(q,{status:F}),V&&(0,R.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,title:V,children:V}),(0,R.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:(0,R.jsx)(ie,{value:e.timestamp})})]}),(0,R.jsxs)(f,{className:`flex min-w-0 items-start gap-2 font-mono text-base font-semibold leading-snug break-all`,children:[(0,R.jsx)(`span`,{className:`min-w-0`,children:e.tool_name}),(0,R.jsx)(y,{value:e.tool_name,className:`-mt-0.5 shrink-0`})]}),U&&(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`in `,U]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[Z&&(0,R.jsxs)(`div`,{className:n(`mb-1 flex gap-3 rounded-md border p-3`,B[Z.tone]),children:[(0,R.jsx)(`div`,{className:`pt-0.5`,children:Z.op===`enumerate`?(0,R.jsx)(k,{className:`h-4 w-4`}):Z.op===`decrypt`?(0,R.jsx)(S,{className:`h-4 w-4`}):(0,R.jsx)(C,{className:`h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-semibold`,children:[Z.label,Z.op===`enumerate`&&(0,R.jsx)(`span`,{className:`ml-1.5 font-normal opacity-80`,children:`— key names only, no value read`})]}),(0,R.jsx)(`p`,{className:`text-xs leading-relaxed opacity-90`,children:Z.blurb}),$&&(0,R.jsxs)(`p`,{className:`text-xs opacity-90`,children:[`Scope:`,` `,(0,R.jsx)(`span`,{className:`font-mono font-medium`,children:$})]})]})]}),H&&(0,R.jsxs)(G,{label:`Outcome`,accent:F===`blocked`?`amber`:`destructive`,children:[e.error_code&&(0,R.jsx)(K,{label:`Code`,children:(0,R.jsx)(`code`,{className:`font-mono text-xs text-accent-foreground break-all`,children:e.error_code})}),e.error_message&&(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Message`}),(0,R.jsx)(y,{value:e.error_message})]}),(0,R.jsx)(re,{message:e.error_message})]})]}),(e.actor_kind||e.actor_id||e.correlation_id||Q)&&(0,R.jsxs)(G,{label:`Who / Actor`,children:[e.actor_kind&&(0,R.jsxs)(K,{label:`Actor`,icon:(0,R.jsx)(A,{className:`h-3 w-3`}),children:[(0,R.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:e.actor_kind}),e.actor_id&&e.actor_id!==e.auth_scope_id&&(0,R.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground break-all`,children:e.actor_id})]}),e.correlation_id?(0,R.jsxs)(K,{label:`Correlation`,icon:(0,R.jsx)(x,{className:`h-3 w-3`}),children:[(0,R.jsx)(`span`,{className:`font-mono text-xs text-foreground break-all`,children:e.correlation_id}),(0,R.jsx)(y,{value:e.correlation_id})]}):Q&&(0,R.jsx)(K,{label:`Correlation`,icon:(0,R.jsx)(x,{className:`h-3 w-3`}),children:(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`none recorded for this row`})}),Q&&(0,R.jsxs)(`p`,{className:`rounded-md border border-border/50 bg-muted/30 p-2.5 text-xs leading-relaxed text-muted-foreground`,children:[`Emitted by the gateway's secret resolver — attributed to the auth\xA0scope it touched`,$&&(0,R.jsxs)(R.Fragment,{children:[` `,`(`,(0,R.jsx)(`span`,{className:`font-mono text-foreground`,children:$}),`)`]}),`, not to the agent that triggered it.`,` `,e.correlation_id?`The triggering agent or worker shares the correlation id above.`:`No correlation id was recorded here — find the trigger by matching the timestamp and scope against the session / worker activity around this time.`]})]}),(0,R.jsxs)(G,{label:`Call`,children:[(0,R.jsx)(K,{label:`Subpath`,children:(0,R.jsx)(`code`,{className:`font-mono text-xs text-accent-foreground break-all`,children:e.subpath||`-`})}),(0,R.jsxs)(K,{label:`When`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{className:`text-foreground`,children:new Date(e.timestamp).toLocaleString()}),(0,R.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.timestamp})]}),(0,R.jsx)(y,{value:e.timestamp,className:`ml-2`})]})]}),(0,R.jsxs)(G,{label:`Context`,children:[e.session_id&&(0,R.jsxs)(K,{label:`Session`,children:[(0,R.jsx)(Y,{value:e.session_id,accent:`cyan`,icon:(0,R.jsx)(O,{className:`h-3 w-3`})}),(0,R.jsx)(J,{label:`Filter`,onClick:()=>{t(),N(`/audit?session_id=${e.session_id}`)}})]}),e.execution_id&&(0,R.jsxs)(K,{label:`Execution`,children:[(0,R.jsx)(Y,{value:e.execution_id,accent:`violet`,icon:(0,R.jsx)(b,{className:`h-3 w-3`})}),(0,R.jsx)(J,{label:`Filter`,onClick:()=>{t(),N(`/audit?execution_id=${e.execution_id}`)}})]}),e.client_type&&(0,R.jsx)(K,{label:`Harness`,icon:(0,R.jsx)(w,{className:`h-3 w-3`}),children:(0,R.jsx)(`span`,{className:`font-mono text-xs text-foreground break-all`,children:e.client_type})}),e.model&&e.model!==e.client_type&&(0,R.jsx)(K,{label:`Model`,icon:(0,R.jsx)(s,{className:`h-3 w-3`}),children:(0,R.jsx)(`span`,{className:`font-mono text-xs text-foreground break-all`,children:e.model})})]}),(0,R.jsxs)(G,{label:`Routing`,children:[(0,R.jsxs)(K,{label:`Rule`,icon:(0,R.jsx)(l,{className:`h-3 w-3`}),children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`break-words text-sm text-foreground`,children:e.route_rule_summary??e.route_rule_id??`-`}),e.route_rule_summary&&e.route_rule_id&&(0,R.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground break-all`,children:e.route_rule_id})]}),e.route_rule_id&&(0,R.jsx)(y,{value:e.route_rule_id})]}),(0,R.jsxs)(K,{label:`Downstream`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`div`,{className:`break-words text-sm text-foreground`,children:e.downstream_server_name??e.downstream_server_id??`-`}),e.downstream_server_name&&e.downstream_server_id&&(0,R.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground break-all`,children:e.downstream_server_id})]}),e.downstream_server_id&&(0,R.jsx)(y,{value:e.downstream_server_id})]}),(0,R.jsx)(K,{label:`Auth scope`,children:(0,R.jsx)(`span`,{className:`break-words text-sm text-foreground`,children:e.auth_scope_id?i(e.auth_scope_id):`-`})})]}),(0,R.jsx)(G,{label:`Performance`,children:(0,R.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,R.jsx)(X,{icon:(0,R.jsx)(ee,{className:`h-3 w-3`}),label:`Latency`,value:`${e.latency_ms} ms`,tone:ae(e.latency_ms)}),(0,R.jsx)(X,{icon:(0,R.jsx)(D,{className:`h-3 w-3`}),label:`Response`,value:oe(e.response_size),tone:`neutral`}),(0,R.jsx)(X,{icon:(0,R.jsx)(te,{className:`h-3 w-3`}),label:`Cache`,value:e.cache_hit?`hit`:`miss`,tone:e.cache_hit?`success`:`neutral`})]})}),W.length>0&&(0,R.jsx)(G,{label:`Redacted params`,action:(0,R.jsx)(y,{value:JSON.stringify(e.params_redacted,null,2)}),children:(0,R.jsx)(`pre`,{className:`max-h-[28rem] overflow-auto rounded-md border border-border bg-background/60 p-3 font-mono text-xs leading-relaxed text-accent-foreground`,children:(0,R.jsx)(E,{text:JSON.stringify(e.params_redacted,null,2),workspaceId:e.workspace_id})})}),(0,R.jsx)(G,{label:`Identity`,defaultMuted:!0,children:(0,R.jsxs)(K,{label:`Record ID`,children:[(0,R.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground break-all`,children:e.id}),(0,R.jsx)(y,{value:e.id})]})})]}),(c||u)&&(0,R.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border/60 bg-background/40 px-5 py-3 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsxs)(h,{children:[(0,R.jsx)(_,{asChild:!0,children:(0,R.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,disabled:!T,onClick:()=>c?.(),"data-testid":`audit-detail-prev`,"aria-label":`Previous record`,children:[(0,R.jsx)(o,{className:`h-3 w-3`}),`Prev`]})}),(0,R.jsx)(g,{children:`k or ↑`})]}),(0,R.jsxs)(h,{children:[(0,R.jsx)(_,{asChild:!0,children:(0,R.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,disabled:!M,onClick:()=>u?.(),"data-testid":`audit-detail-next`,"aria-label":`Next record`,children:[(0,R.jsx)(a,{className:`h-3 w-3`}),`Next`]})}),(0,R.jsx)(g,{children:`j or ↓`})]})]}),(0,R.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`esc to close`})]})]})})}function G({label:e,children:t,accent:r,defaultMuted:i,action:a}){return(0,R.jsxs)(`section`,{className:`border-b border-border/30 py-4 first:pt-1 last:border-b-0`,children:[(0,R.jsxs)(`div`,{className:`mb-2.5 flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:n(`text-[10px] font-semibold uppercase tracking-[0.12em]`,r===`destructive`?`text-destructive`:r===`amber`?`text-amber-500`:i?`text-muted-foreground/60`:`text-muted-foreground`),children:e}),a]}),(0,R.jsx)(`div`,{className:`space-y-2.5`,children:t})]})}function K({label:e,children:t,icon:n}){return(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center gap-1 pt-0.5 text-xs text-muted-foreground`,children:[n,(0,R.jsx)(`span`,{children:e})]}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:t})]})}function q({status:e}){return(0,R.jsx)(T,{variant:`outline`,className:n(`font-mono uppercase tracking-wider`,{success:`border-emerald-500/40 bg-emerald-500/10 text-emerald-400`,error:`border-destructive/40 bg-destructive/10 text-destructive`,blocked:`border-amber-500/40 bg-amber-500/10 text-amber-500`}[P(e)]),children:e})}function J({label:e,onClick:t}){return(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex shrink-0 items-center gap-1 rounded border border-dashed border-border px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground`,children:[(0,R.jsx)(c,{className:`h-2.5 w-2.5`}),e]})}function Y({value:e,accent:t,icon:r}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,R.jsxs)(`span`,{className:n(`flex items-center gap-1 font-mono text-xs break-all`,t===`cyan`?`text-cyan-400`:`text-violet-400`),children:[r,e]}),(0,R.jsx)(y,{value:e})]})}function X({icon:e,label:t,value:r,tone:i}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md border border-border/40 bg-background/40 px-3 py-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:[e,t]}),(0,R.jsx)(`div`,{className:n(`font-mono text-sm tabular-nums`,i===`success`?`text-emerald-400`:i===`warn`?`text-amber-500`:i===`error`?`text-destructive`:`text-foreground`),children:r})]})}function re({message:e}){return(0,R.jsx)(`pre`,{className:`max-h-[20rem] overflow-auto whitespace-pre-wrap break-words rounded-md border border-destructive/30 bg-destructive/5 p-3 font-mono text-xs leading-relaxed text-foreground`,children:(0,R.jsx)(E,{text:(0,j.useMemo)(()=>Z(e),[e])??e})})}function ie({value:e}){return(0,R.jsxs)(h,{children:[(0,R.jsx)(_,{asChild:!0,children:(0,R.jsx)(`span`,{children:(0,j.useMemo)(()=>Q(e),[e])})}),(0,R.jsx)(g,{children:new Date(e).toLocaleString()})]})}function Z(e){let t=e.trim();if(!t||t[0]!==`{`&&t[0]!==`[`)return null;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return null}}function Q(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return e;let n=Date.now()-t,r=Math.abs(n),i=n<0?`in `:``,a=n<0?``:` ago`,o=Math.round(r/1e3);if(o<5)return`just now`;if(o<60)return`${i}${o}s${a}`;let s=Math.round(o/60);if(s<60)return`${i}${s}m${a}`;let c=Math.round(s/60);if(c<24)return`${i}${c}h${a}`;let l=Math.round(c/24);if(l<30)return`${i}${l}d${a}`;let u=Math.round(l/30);return u<12?`${i}${u}mo${a}`:`${i}${Math.round(u/12)}y${a}`}function ae(e){return e<100?`success`:e<1e3?`neutral`:e<3e3?`warn`:`error`}function oe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}export{F as a,O as c,I as i,U as n,P as o,V as r,N as s,W as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/AuditPage-kXFcF4K1.js b/internal/web/dist/assets/AuditPage-kXFcF4K1.js deleted file mode 100644 index 88496bc..0000000 --- a/internal/web/dist/assets/AuditPage-kXFcF4K1.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,Mt as r,in as i,on as a,pt as o}from"./client-CaIRceNv.js";import{n as s,o as c,r as l,t as u}from"./dropdown-menu-iCiwbrNR.js";import{t as d}from"./createLucideIcon-WB390fY6.js";import{t as f}from"./chevron-right-CyhRDGe7.js";import{t as p}from"./funnel-BvqzDyhp.js";import{c as m,i as ee,n as te,o as ne,r as re,s as ie,t as h}from"./AuditDetailDialog-CIIIkhsj.js";import{Br as g,Fn as _,Ft as v,Ln as y,Mr as b,Nr as x,Pr as S,S as C,Sr as w,Zn as ae,ar as T,n as E,t as D,wr as oe,y as O,yr as k}from"./index-BDLzoIgt.js";import{a as A,i as j,n as M,o as N,r as P,t as F}from"./table-2N0Q-yAm.js";var I=d(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),L=e(t(),1),R=a(),z=25;function B(e){let t=e.client_type??``,n=e.model??``;return n&&t&&n.startsWith(t+`/`)&&(n=n.slice(t.length+1)),n===t?``:n}function V(){let[e,t]=g(),[i,a]=(0,L.useState)(()=>{let t=e.get(`execution_id`),n=e.get(`session_id`),r=e.get(`status`),i=e.get(`workspace_id`),a=e.get(`tool_name`);return{limit:z,offset:0,...t?{execution_id:t}:{},...n?{session_id:n}:{},...r===`success`||r===`error`?{status:r}:{},...i?{workspace_id:i}:{},...a?{tool_name:a}:{}}});(0,L.useEffect)(()=>{t(e=>{let t=new URLSearchParams(e),n=(e,n)=>{n?t.set(e,n):t.delete(e)};return n(`execution_id`,i.execution_id),n(`session_id`,i.session_id),n(`status`,i.status),n(`workspace_id`,i.workspace_id),n(`tool_name`,i.tool_name),t},{replace:!0})},[i.execution_id,i.session_id,i.status,i.workspace_id,i.tool_name,t]);let{data:s}=C((0,L.useCallback)(()=>n(),[])),{data:c}=C((0,L.useCallback)(()=>o(),[])),l=e=>s?.find(t=>t.id===e)?.name??e,u=e=>c?.find(t=>t.id===e)?.name??e,{records:d,connected:p,clear:v}=ie((0,L.useMemo)(()=>({workspace_id:i.workspace_id,tool_name:i.tool_name,status:i.status,execution_id:i.execution_id,session_id:i.session_id}),[i.workspace_id,i.tool_name,i.status,i.execution_id,i.session_id])),{data:w,loading:k,error:V}=C((0,L.useCallback)(()=>r(i),[i])),H=Math.floor((i.offset??0)/z)+1,U=w?Math.ceil(w.total/z):0,W=H===1,G=(0,L.useMemo)(()=>w?.data??[],[w]),K=(0,L.useMemo)(()=>{if(!W)return[];let e=new Set(G.map(e=>e.id));return d.filter(t=>!e.has(t.id))},[G,d,W]),q=(0,L.useMemo)(()=>[...K,...G],[K,G]),J=e.get(`selected`),[Y,X]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(!J){X(null);return}if(q.some(e=>e.id===J)){X(null);return}let e=!1;return r({id:J,limit:1}).then(t=>{e||X(t.data?.[0]??null)}).catch(()=>{e||X(null)}),()=>{e=!0}},[J,q]);let Z=(0,L.useMemo)(()=>J?q.find(e=>e.id===J)??Y:null,[J,q,Y]),Q=(0,L.useCallback)(e=>{t(t=>{let n=new URLSearchParams(t);return e?n.set(`selected`,e.id):n.delete(`selected`),n},{replace:!0})},[t]),$=Z?q.findIndex(e=>e.id===Z.id):-1,le=$>0,ue=$>=0&&${$>0&&Q(q[$-1])},[$,q,Q]),fe=(0,L.useCallback)(()=>{$>=0&&$0&&(0,R.jsx)(_,{variant:`ghost`,size:`sm`,onClick:v,"data-testid":`audit-clear-live`,children:`Clear live`}),(0,R.jsx)(`div`,{className:`flex items-center gap-2 text-sm`,children:p?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`relative flex h-2.5 w-2.5`,children:[(0,R.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75`}),(0,R.jsx)(`span`,{className:`relative inline-flex h-2.5 w-2.5 rounded-full bg-emerald-500`})]}),(0,R.jsx)(`span`,{className:`text-emerald-400`,children:`Live`})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full bg-muted-foreground/40`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Connecting...`})]})})]})]}),(i.execution_id||i.session_id)&&(0,R.jsx)(D,{children:(0,R.jsxs)(E,{className:`flex flex-wrap items-center gap-3 pt-6`,children:[i.session_id&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(m,{className:`h-4 w-4 text-cyan-400`}),(0,R.jsxs)(`span`,{className:`text-sm`,children:[`Session`,` `,(0,R.jsx)(`code`,{className:`rounded bg-cyan-500/10 px-1.5 py-0.5 font-mono text-xs text-cyan-400`,children:i.session_id.slice(0,8)})]}),(0,R.jsx)(_,{variant:`ghost`,size:`sm`,className:`h-7 gap-1 text-xs`,"aria-label":`Clear session filter`,"data-testid":`audit-clear-session`,onClick:()=>a(e=>({...e,session_id:void 0,offset:0})),children:(0,R.jsx)(y,{className:`h-3 w-3`})})]}),i.execution_id&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(T,{className:`h-4 w-4 text-violet-400`}),(0,R.jsxs)(`span`,{className:`text-sm`,children:[`Execution`,` `,(0,R.jsx)(`code`,{className:`rounded bg-violet-500/10 px-1.5 py-0.5 font-mono text-xs text-violet-400`,children:i.execution_id.slice(0,8)})]}),(0,R.jsx)(_,{variant:`ghost`,size:`sm`,className:`h-7 gap-1 text-xs`,"aria-label":`Clear execution filter`,"data-testid":`audit-clear-execution`,onClick:()=>a(e=>({...e,execution_id:void 0,offset:0})),children:(0,R.jsx)(y,{className:`h-3 w-3`})})]}),(0,R.jsx)(_,{variant:`ghost`,size:`sm`,className:`ml-auto h-7 gap-1 text-xs`,"data-testid":`audit-clear-all`,onClick:()=>a(e=>({...e,execution_id:void 0,session_id:void 0,offset:0})),children:`Clear all`})]})}),(0,R.jsx)(ce,{filter:i,setFilter:a,workspaces:s??[]}),(0,R.jsx)(D,{children:(0,R.jsxs)(E,{className:`pt-6`,children:[k&&!w&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,R.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading...`]}),V&&(0,R.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,V]}),(0,R.jsxs)(F,{className:`table-fixed`,children:[(0,R.jsxs)(`colgroup`,{children:[(0,R.jsx)(`col`,{className:`w-[7rem]`}),(0,R.jsx)(`col`,{className:`w-[18rem]`}),(0,R.jsx)(`col`,{className:`hidden md:table-column w-[10rem]`}),(0,R.jsx)(`col`,{className:`hidden lg:table-column w-[8rem]`}),(0,R.jsx)(`col`,{className:`hidden lg:table-column w-[9rem]`}),(0,R.jsx)(`col`,{className:`w-[6rem]`}),(0,R.jsx)(`col`,{}),(0,R.jsx)(`col`,{className:`hidden lg:table-column w-[5rem]`}),(0,R.jsx)(`col`,{className:`hidden lg:table-column w-[8rem]`}),(0,R.jsx)(`col`,{className:`hidden sm:table-column w-[5rem]`})]}),(0,R.jsx)(A,{children:(0,R.jsxs)(N,{className:`border-border/50 hover:bg-transparent`,children:[(0,R.jsx)(j,{children:`Timestamp`}),(0,R.jsx)(j,{children:`Tool`}),(0,R.jsx)(j,{className:`hidden md:table-cell`,children:`Workspace`}),(0,R.jsx)(j,{className:`hidden lg:table-cell`,children:`Session`}),(0,R.jsx)(j,{className:`hidden lg:table-cell`,children:`Client`}),(0,R.jsx)(j,{children:`Status`}),(0,R.jsx)(j,{children:`Reason`}),(0,R.jsx)(j,{className:`hidden lg:table-cell`,children:`Cache`}),(0,R.jsx)(j,{className:`hidden lg:table-cell`,children:`Group`}),(0,R.jsx)(j,{className:`hidden sm:table-cell text-right`,children:`Latency`})]})}),(0,R.jsx)(M,{children:q.length===0&&!k?(0,R.jsx)(N,{children:(0,R.jsx)(P,{colSpan:10,className:`h-32`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground`,children:[(0,R.jsx)(ae,{className:`mb-2 h-8 w-8 text-muted-foreground/50`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`Waiting for events...`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`New audit records will appear here in real-time`})]})})}):q.map((e,t)=>{let n=tQ(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Q(e))},children:[(0,R.jsx)(P,{className:`whitespace-nowrap font-mono text-xs text-muted-foreground`,children:(0,R.jsxs)(b,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsx)(`span`,{children:new Date(e.timestamp).toLocaleTimeString()})}),(0,R.jsx)(x,{children:new Date(e.timestamp).toLocaleString()})]})}),(0,R.jsxs)(P,{children:[(0,R.jsx)(`div`,{className:`max-w-[20rem] truncate font-mono text-sm text-accent-foreground`,title:e.tool_name,children:e.tool_name}),ee(e.tool_name)&&(0,R.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[(0,R.jsx)(re,{toolName:e.tool_name}),e.auth_scope_id&&(0,R.jsx)(`span`,{className:`truncate text-[11px] text-muted-foreground`,title:u(e.auth_scope_id),children:u(e.auth_scope_id)})]})]}),(0,R.jsx)(P,{className:`hidden md:table-cell text-muted-foreground`,children:(0,R.jsx)(`div`,{className:`max-w-[10rem] truncate`,children:e.workspace_name||(e.workspace_id?l(e.workspace_id):`-`)})}),(0,R.jsx)(P,{className:`hidden lg:table-cell`,children:e.session_id&&(0,R.jsxs)(b,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsxs)(O,{variant:`outline`,className:`cursor-pointer border-cyan-500/40 text-cyan-400 hover:bg-cyan-500/10`,onClick:t=>{t.stopPropagation(),a(t=>({...t,session_id:e.session_id,offset:0}))},children:[(0,R.jsx)(m,{className:`mr-1 h-3 w-3`}),e.session_id.slice(0,8)]})}),(0,R.jsx)(x,{children:`View all calls in this session`})]})}),(0,R.jsx)(P,{className:`hidden lg:table-cell`,children:e.client_type?(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-foreground`,title:e.client_type,children:[(0,R.jsx)(oe,{className:`h-3 w-3 shrink-0 opacity-60`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.client_type})]}),B(e)&&(0,R.jsx)(`div`,{className:`mt-0.5 truncate pl-4 font-mono text-[10px] text-muted-foreground/70`,title:e.model,children:B(e)})]}):(0,R.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,R.jsx)(P,{children:(()=>{let t=ne(e.status);return(0,R.jsx)(O,{variant:t===`success`?`secondary`:t===`blocked`?`outline`:`destructive`,className:t===`blocked`?`border-amber-500/40 text-amber-500`:``,children:e.status})})()}),(0,R.jsx)(P,{className:`align-top`,children:(0,R.jsx)(te,{record:e})}),(0,R.jsx)(P,{className:`hidden lg:table-cell`,children:e.cache_hit&&(0,R.jsx)(O,{variant:`outline`,className:`border-blue-500/40 text-blue-400`,children:`cached`})}),(0,R.jsx)(P,{className:`hidden lg:table-cell`,children:e.execution_id&&(0,R.jsxs)(b,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsxs)(O,{variant:`outline`,className:`cursor-pointer border-violet-500/40 text-violet-400 hover:bg-violet-500/10`,onClick:t=>{t.stopPropagation(),a(t=>({...t,execution_id:e.execution_id,offset:0}))},children:[(0,R.jsx)(T,{className:`mr-1 h-3 w-3`}),e.execution_id.slice(0,8)]})}),(0,R.jsx)(x,{children:`View all calls in this execution`})]})}),(0,R.jsxs)(P,{className:`hidden sm:table-cell text-right font-mono text-sm text-muted-foreground`,children:[e.latency_ms,`ms`]})]},e.id)})})]}),w&&(0,R.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[w.total,` total records`]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsxs)(b,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsx)(_,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Previous page`,"data-testid":`audit-page-prev`,disabled:H<=1,onClick:()=>a(e=>({...e,offset:Math.max(0,(e.offset??0)-z)})),children:(0,R.jsx)(I,{className:`h-4 w-4`})})}),(0,R.jsx)(x,{children:`Previous page`})]}),(0,R.jsx)(se,{page:H,total:Math.max(1,U),onJump:e=>a(t=>({...t,offset:Math.max(0,(e-1)*z)}))}),(0,R.jsxs)(b,{children:[(0,R.jsx)(S,{asChild:!0,children:(0,R.jsx)(_,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Next page`,"data-testid":`audit-page-next`,disabled:H>=U,onClick:()=>a(e=>({...e,offset:(e.offset??0)+z})),children:(0,R.jsx)(f,{className:`h-4 w-4`})})}),(0,R.jsx)(x,{children:`Next page`})]})]})]})]})}),(0,R.jsx)(h,{record:Z,onClose:()=>Q(null),wsName:l,asName:u,onPrev:de,onNext:fe,hasPrev:le,hasNext:ue})]})}function se({page:e,total:t,onJump:n}){let[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(String(e)),s=(0,L.useRef)(null);(0,L.useEffect)(()=>{r||o(String(e))},[e,r]),(0,L.useEffect)(()=>{r&&s.current?.select()},[r]);function c(){let r=parseInt(a,10);if(Number.isFinite(r)){let i=Math.max(1,Math.min(t,r));i!==e&&n(i)}i(!1)}return r?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 bg-secondary px-2 py-1 font-mono text-xs tabular-nums`,children:[(0,R.jsx)(`input`,{ref:s,value:a,onChange:e=>o(e.target.value.replace(/[^0-9]/g,``)),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),c()):t.key===`Escape`&&(t.preventDefault(),i(!1),o(String(e)))},onBlur:c,inputMode:`numeric`,"data-testid":`audit-page-jump-input`,"aria-label":`Page number`,className:`w-10 border-0 bg-transparent p-0 text-center font-mono text-xs tabular-nums outline-none focus:outline-none focus-visible:ring-0 focus-visible:ring-offset-0`}),(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/ `,t]})]}):(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),"data-testid":`audit-page-jump`,className:`bg-secondary px-3 py-1 font-mono text-xs font-medium tabular-nums transition-colors hover:bg-secondary/80`,title:`Jump to page`,"aria-label":`Page ${e} of ${t}. Click to jump.`,children:[e,` / `,t]})}function ce({filter:e,setFilter:t,workspaces:n}){let r=e.workspace_id?n.find(t=>t.id===e.workspace_id)?.name??e.workspace_id:null,i=e=>t(t=>({...t,...e,offset:0}));return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`mr-1 inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:[(0,R.jsx)(p,{className:`h-3 w-3`}),`Filters`]}),(0,R.jsx)(U,{workspaces:n,value:e.workspace_id??null,label:r,onSet:e=>i({workspace_id:e??void 0})}),(0,R.jsx)(W,{value:e.status??null,onSet:e=>i({status:e??void 0})}),(0,R.jsx)(G,{value:e.tool_name??null,onSet:e=>i({tool_name:e??void 0})}),(0,R.jsx)(K,{after:e.after??null,before:e.before??null,onSet:(e,t)=>i({after:e??void 0,before:t??void 0})}),(e.workspace_id||e.status||e.tool_name||e.after||e.before)&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>i({workspace_id:void 0,status:void 0,tool_name:void 0,after:void 0,before:void 0}),"data-testid":`audit-filter-clear-all`,className:`ml-1 text-[11px] text-muted-foreground hover:text-foreground`,children:`Clear filters`})]})}function H({active:e,testId:t,children:n,onClear:r}){return(0,R.jsxs)(`span`,{"data-testid":t,className:i(`inline-flex items-center gap-1 border px-2 py-1 text-[12px] font-mono transition-colors`,e?`border-primary/40 bg-primary/5 text-foreground`:`border-dashed border-border text-muted-foreground hover:border-border/80 hover:text-foreground`),children:[n,e&&r&&(0,R.jsx)(`button`,{type:`button`,"aria-label":`Clear filter`,onClick:e=>{e.stopPropagation(),r()},className:`ml-0.5 -mr-0.5 text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(y,{className:`h-3 w-3`})})]})}function U({workspaces:e,value:t,label:n,onSet:r}){let a=t!==null;return(0,R.jsxs)(u,{children:[(0,R.jsx)(c,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,children:(0,R.jsx)(H,{active:a,testId:`audit-filter-workspace`,onClear:()=>r(null),children:a?(0,R.jsxs)(R.Fragment,{children:[`in `,(0,R.jsx)(`span`,{className:`text-primary`,children:n})]}):`+ Workspace`})})}),(0,R.jsxs)(s,{align:`start`,className:`min-w-[12rem]`,children:[(0,R.jsx)(l,{onClick:()=>r(null),children:(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`All workspaces`})}),e.map(e=>(0,R.jsxs)(l,{onClick:()=>r(e.id),children:[(0,R.jsx)(w,{className:i(`mr-2 h-3 w-3`,t===e.id?`opacity-100`:`opacity-0`)}),e.name]},e.id))]})]})}function W({value:e,onSet:t}){let n=e!==null;return(0,R.jsxs)(u,{children:[(0,R.jsx)(c,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,children:(0,R.jsx)(H,{active:n,testId:`audit-filter-status`,onClear:()=>t(null),children:n?(0,R.jsxs)(R.Fragment,{children:[`status `,(0,R.jsx)(`span`,{className:`text-primary`,children:e})]}):`+ Status`})})}),(0,R.jsx)(s,{align:`start`,children:[`success`,`error`,`blocked`].map(n=>(0,R.jsxs)(l,{onClick:()=>t(n),children:[(0,R.jsx)(w,{className:i(`mr-2 h-3 w-3`,e===n?`opacity-100`:`opacity-0`)}),(0,R.jsx)(`span`,{className:`capitalize`,children:n})]},n))})]})}function G({value:e,onSet:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(``),o=(0,L.useRef)(null),s=e!==null;return(0,L.useEffect)(()=>{n&&o.current?.focus()},[n]),n?(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-primary/40 bg-primary/5 px-2 py-1 font-mono text-[12px]`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`tool =`}),(0,R.jsx)(v,{ref:o,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(t(i.trim()||null),r(!1)):e.key===`Escape`&&(r(!1),a(``))},onBlur:()=>{t(i.trim()||null),r(!1)},className:`h-5 w-32 border-0 bg-transparent px-0 py-0 font-mono text-[12px] focus-visible:ring-0`,"data-testid":`audit-filter-tool-input`,"aria-label":`Filter by tool name`,placeholder:`name…`})]}):(0,R.jsx)(`button`,{type:`button`,onClick:()=>{a(e??``),r(!0)},children:(0,R.jsx)(H,{active:s,testId:`audit-filter-tool`,onClear:()=>t(null),children:s?(0,R.jsxs)(R.Fragment,{children:[`tool `,(0,R.jsx)(`span`,{className:`text-primary`,children:e})]}):`+ Tool name`})})}function K({after:e,before:t,onSet:n}){let r=e!==null||t!==null,[i,a]=(0,L.useState)(!1);function o(e){if(e===null){n(null,null);return}n(d(new Date(new Date().getTime()-e*36e5)),null)}function d(e){let t=e=>String(e).padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`}function f(){return r?e&&!t?`since ${p(e)}`:!e&&t?`until ${p(t)}`:`${p(e)} → ${p(t)}`:`+ Time`}function p(e){try{return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return e}}return i?(0,R.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5 border border-primary/40 bg-primary/5 px-2 py-1 font-mono text-[12px]`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`time:`}),(0,R.jsx)(v,{type:`datetime-local`,value:e??``,onChange:e=>n(e.target.value||null,t),className:`h-6 w-44 border-0 bg-transparent px-0 py-0 font-mono text-[11px] focus-visible:ring-0`,"data-testid":`audit-filter-after`,"aria-label":`Filter from time`}),(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,R.jsx)(v,{type:`datetime-local`,value:t??``,onChange:t=>n(e,t.target.value||null),className:`h-6 w-44 border-0 bg-transparent px-0 py-0 font-mono text-[11px] focus-visible:ring-0`,"data-testid":`audit-filter-before`,"aria-label":`Filter to time`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`text-muted-foreground hover:text-foreground`,"aria-label":`Close time picker`,children:(0,R.jsx)(y,{className:`h-3 w-3`})})]}):(0,R.jsxs)(u,{children:[(0,R.jsx)(c,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,children:(0,R.jsxs)(H,{active:r,testId:`audit-filter-time`,onClear:()=>n(null,null),children:[(0,R.jsx)(k,{className:`h-3 w-3 opacity-60`}),f()]})})}),(0,R.jsxs)(s,{align:`start`,className:`min-w-[10rem]`,children:[(0,R.jsx)(l,{onClick:()=>o(1),children:`Last hour`}),(0,R.jsx)(l,{onClick:()=>o(24),children:`Last 24h`}),(0,R.jsx)(l,{onClick:()=>o(168),children:`Last 7d`}),(0,R.jsx)(l,{onClick:()=>o(null),children:`All time`}),(0,R.jsx)(l,{onClick:()=>a(!0),children:`Custom…`})]})]})}export{V as AuditPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/BackupsPage-C7FQ2DLV.js b/internal/web/dist/assets/BackupsPage-C7FQ2DLV.js deleted file mode 100644 index 27ec7e7..0000000 --- a/internal/web/dist/assets/BackupsPage-C7FQ2DLV.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Lt as n,b as r,i,mt as a,on as o,u as s}from"./client-CaIRceNv.js";import{Bn as c,Fn as l,Ft as u,Qn as d,S as f,Yn as p,hr as m,j as h,jr as g,kr as _,n as v,nr as y,t as b,y as x}from"./index-BDLzoIgt.js";var S=e(t(),1),C=o();function w(){let{data:e,loading:t,error:i,refetch:o}=f((0,S.useCallback)(()=>a(),[])),[c,p]=(0,S.useState)(!1),[m,x]=(0,S.useState)(``),[w,E]=(0,S.useState)(null),[D,O]=(0,S.useState)(!1),[k,A]=(0,S.useState)(null);async function j(){p(!0);try{let e=await s(m||void 0);x(``),g.success(`Backup created: ${e.id}`),o()}catch(e){g.error(e instanceof Error?e.message:`Failed to create backup`)}finally{p(!1)}}async function M(){if(w){O(!0);try{let e=await n(w.id);g.success(`Restored from ${e.restored_from}. Pre-restore snapshot: ${e.pre_restore_snapshot_id}. Restart MCPlexer to apply.`,{duration:12e3}),E(null),o()}catch(e){g.error(e instanceof Error?e.message:`Restore failed`)}finally{O(!1)}}}async function N(){if(k)try{await r(k.id),g.success(`Backup deleted`),A(null),o()}catch(e){g.error(e instanceof Error?e.message:`Delete failed`)}}return(0,C.jsxs)(`div`,{className:`space-y-5 max-w-4xl`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Backup & Restore`}),(0,C.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Snapshot the live config (SQLite DB + secrets + skills) before risky changes. Restore rolls everything back; an automatic pre-restore snapshot is taken so you can always undo. Agents can use`,` `,(0,C.jsx)(`span`,{className:`font-mono text-xs`,children:`mcplexer__create_backup`}),` /`,` `,(0,C.jsx)(`span`,{className:`font-mono text-xs`,children:`restore_backup`}),` for the same flow.`]})]}),(0,C.jsx)(b,{children:(0,C.jsxs)(v,{className:`flex flex-col gap-3 p-4 sm:flex-row sm:items-end`,children:[(0,C.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,C.jsx)(`label`,{htmlFor:`backup-note`,className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Note (optional)`}),(0,C.jsx)(u,{id:`backup-note`,placeholder:`e.g. before adding GitHub server`,value:m,onChange:e=>x(e.target.value),"data-testid":`backup-note`})]}),(0,C.jsxs)(l,{onClick:j,disabled:c,"data-testid":`backup-create`,children:[c?(0,C.jsx)(y,{className:`mr-2 h-4 w-4 animate-spin`}):(0,C.jsx)(d,{className:`mr-2 h-4 w-4`}),`Create backup`]})]})}),t&&!e&&(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,C.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading backups...`]}),i&&(0,C.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,i]}),e&&e.length===0&&(0,C.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-lg border border-dashed py-12 text-center`,children:[(0,C.jsx)(_,{className:`mb-2 h-8 w-8 text-muted-foreground/40`}),(0,C.jsx)(`h3`,{className:`text-sm font-semibold`,children:`No backups yet`}),(0,C.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-muted-foreground`,children:`Create one before making config changes you might want to roll back.`})]}),e&&e.length>0&&(0,C.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,C.jsx)(T,{mf:e,onRestore:()=>E(e),onDelete:()=>A(e)},e.id))}),(0,C.jsx)(h,{open:!!w,onOpenChange:e=>!e&&E(null),title:`Restore ${w?.id??``}?`,description:`A pre-restore snapshot will be created automatically before this runs, so you can always roll back. After restore, restart MCPlexer to pick up the new state.`,confirmLabel:D?`Restoring…`:`Restore`,onConfirm:M}),(0,C.jsx)(h,{open:!!k,onOpenChange:e=>!e&&A(null),title:`Delete backup`,description:`Are you sure you want to delete "${k?.id}"?`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:N})]})}function T({mf:e,onRestore:t,onDelete:n}){return(0,C.jsx)(b,{children:(0,C.jsxs)(v,{className:`flex flex-wrap items-center gap-3 p-3`,children:[(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-sm`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:e.id}),e.pre_restore_of&&(0,C.jsxs)(x,{variant:`outline`,className:`text-[10px]`,children:[`pre-restore of `,e.pre_restore_of]}),e.includes_secrets&&(0,C.jsx)(x,{variant:`secondary`,className:`text-[10px]`,children:`includes secrets`}),e.includes_skills&&(0,C.jsx)(x,{variant:`secondary`,className:`text-[10px]`,children:`includes skills`})]}),(0,C.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:new Date(e.created_at).toLocaleString()}),(0,C.jsx)(`span`,{children:E(e.size_bytes)}),e.mcplexer_version&&(0,C.jsxs)(`span`,{children:[`v`,e.mcplexer_version]}),e.note&&(0,C.jsxs)(`span`,{className:`italic`,children:[`"`,e.note,`"`]})]})]}),(0,C.jsxs)(`div`,{className:`flex gap-1`,children:[(0,C.jsx)(`a`,{href:i(e.id),download:`${e.id}.tar.gz`,"data-testid":`backup-download-${e.id}`,children:(0,C.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Download`,children:(0,C.jsx)(m,{className:`h-4 w-4`})})}),(0,C.jsxs)(l,{variant:`ghost`,size:`sm`,className:`h-8 gap-1 text-xs`,onClick:t,"data-testid":`backup-restore-${e.id}`,children:[(0,C.jsx)(p,{className:`h-3.5 w-3.5`}),`Restore`]}),(0,C.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive`,onClick:n,"aria-label":`Delete`,"data-testid":`backup-delete-${e.id}`,children:(0,C.jsx)(c,{className:`h-4 w-4`})})]})]})})}function E(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}export{w as BackupsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/BrainBrowserPage-DWmDha4V.js b/internal/web/dist/assets/BrainBrowserPage-DWmDha4V.js deleted file mode 100644 index f14e7f2..0000000 --- a/internal/web/dist/assets/BrainBrowserPage-DWmDha4V.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r,t as i}from"./client-CaIRceNv.js";import{i as a,r as o,t as s}from"./tabs-Q9rOz2uL.js";import{n as c,t as l}from"./toggle-group-CwLNIqWC.js";import{t as u}from"./chevron-right-CyhRDGe7.js";import{t as d}from"./info-C1fwy83I.js";import{t as f}from"./save-Baaykonc.js";import{$t as p,Br as m,C as h,Cr as g,D as _,E as v,Fn as y,Ft as b,Gt as x,Jt as S,Kt as C,Ln as w,Mn as T,Mr as E,Nn as D,Nr as O,On as k,Pr as A,Pt as j,Qn as M,Qt as N,Rr as ee,S as P,Wt as te,Xn as ne,Xt as re,Yt as ie,Zt as ae,_ as F,d as I,en as L,f as R,fr as z,in as B,jn as V,jr as H,kn as oe,m as U,n as se,nn as ce,nr as le,p as W,qt as ue,rn as de,t as G,tn as fe,u as pe,v as me,w as he,y as K,zn as q,zr as ge,zt as _e}from"./index-BDLzoIgt.js";import{t as ve}from"./empty-state-B9mtYx_X.js";var J=e(t(),1),Y=r();function ye(e){return e?{title:e.title??``,status:e.status??``,priority:e.priority??``,tags:(e.tags??[]).map(e=>`#${e}`).join(` `),pinned:e.pinned?`true`:`false`}:{}}function be(e){return e?{name:e.name??``,kind:e.kind??``,tags:(e.tags??[]).map(e=>`#${e}`).join(` `),pinned:e.pinned?`true`:`false`}:{}}function xe({detail:e,kind:t,mine:n,open:r,onResolve:i,onReload:a,onCancel:o}){let s=t===`task`?e.on_disk_task:e.on_disk_memory,c=t===`task`?ye(n):be(n),l=t===`task`?ye(s):be(s),u=(0,J.useMemo)(()=>Array.from(new Set([...Object.keys(c),...Object.keys(l)])).map(e=>({field:e,mine:c[e]??``,theirs:l[e]??``,same:(c[e]??``)===(l[e]??``)})),[e,n]),[d,f]=(0,J.useState)(()=>{let e={};for(let t of u)e[t.field]=t.same?`mine`:`theirs`;return e}),[p,m]=(0,J.useState)(!1),g=(0,J.useMemo)(()=>t===`task`?n.description!==s?.description:n.content!==s?.content,[t,n,s]),[b,x]=(0,J.useState)(`mine`);function S(){let e={...s??n};for(let t of u)d[t.field]===`mine`&&we(e,t.field,n);if(!g||b===`mine`){let r=n;t===`task`?e.description=r.description:e.content=r.content}return e}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(k,{open:r,onOpenChange:e=>!e&&o(),children:(0,Y.jsxs)(oe,{className:`max-w-2xl rounded-none`,children:[(0,Y.jsx)(T,{children:(0,Y.jsxs)(D,{className:`flex items-center gap-2 text-base`,children:[(0,Y.jsx)(q,{className:`h-4 w-4 text-amber-300`}),`This record changed on disk while you were editing`,(0,Y.jsxs)(K,{tone:`warn`,className:`ml-2 rounded-none font-mono text-[10px]`,children:[`writer: `,e.writer]})]})}),(0,Y.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b text-left text-xs text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`field`}),(0,Y.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`YOURS`}),(0,Y.jsx)(`th`,{className:`py-1.5 pr-3 font-medium`,children:`ON DISK`}),(0,Y.jsx)(`th`,{className:`py-1.5 font-medium`})]})}),(0,Y.jsx)(`tbody`,{className:`divide-y`,children:u.map(e=>(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-xs`,children:e.field}),(0,Y.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-xs`,children:e.mine||`-`}),(0,Y.jsx)(`td`,{className:`py-1.5 pr-3 font-mono text-xs`,children:e.theirs||`-`}),(0,Y.jsx)(`td`,{className:`py-1.5`,children:e.same?(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`(same)`}):(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t=>({...t,[e.field]:`mine`})),className:X(d[e.field]===`mine`),children:`keep mine`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t=>({...t,[e.field]:`theirs`})),className:X(d[e.field]===`theirs`),children:`take theirs`})]})})]},e.field))})]}),g&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-t pt-2 text-xs text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[t===`task`?`Description`:`Content`,` (prose) differs - choose which body the merge keeps.`]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x(`mine`),className:X(b===`mine`),children:`keep mine`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x(`theirs`),className:X(b===`theirs`),children:`take theirs`})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(!0),className:`flex items-center gap-1 text-primary hover:underline`,children:[(0,Y.jsx)(z,{className:`h-3 w-3`}),` open both in file view`]})]})]}),(0,Y.jsxs)(V,{className:`gap-2`,children:[(0,Y.jsx)(y,{variant:`outline`,size:`sm`,className:`rounded-none`,onClick:a,children:`take all theirs & re-edit`}),(0,Y.jsx)(y,{size:`sm`,className:`rounded-none`,onClick:()=>i(S(),e.on_disk_hash),children:`apply merge`}),(0,Y.jsx)(y,{variant:`ghost`,size:`sm`,className:`rounded-none`,onClick:o,children:`cancel`})]})]})}),(0,Y.jsx)(h,{open:p,onOpenChange:m,children:(0,Y.jsxs)(he,{side:`right`,className:`w-[640px] max-w-[90vw] rounded-none sm:max-w-[640px]`,children:[(0,Y.jsx)(v,{children:(0,Y.jsx)(_,{className:`font-mono text-xs`,children:e.path})}),(0,Y.jsxs)(`div`,{className:`grid h-full grid-rows-2 gap-2 overflow-hidden pt-3`,children:[(0,Y.jsx)(Se,{label:`YOURS (your draft body)`,text:Ce(t,n)}),(0,Y.jsx)(Se,{label:`ON DISK (their body)`,text:Ce(t,s)})]})]})})]})}function Se({label:e,text:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,Y.jsx)(`div`,{className:`mb-1 text-[10px] uppercase tracking-wide text-muted-foreground`,children:e}),(0,Y.jsx)(`pre`,{className:`flex-1 overflow-auto whitespace-pre-wrap border bg-muted/30 p-2 font-mono text-xs`,children:t||`(empty)`})]})}function Ce(e,t){return t?e===`task`?t.description??``:t.content??``:``}function we(e,t,n){let r=n;switch(t){case`title`:e.title=r.title;break;case`status`:e.status=r.status;break;case`priority`:e.priority=r.priority;break;case`name`:e.name=r.name;break;case`kind`:e.kind=r.kind;break;case`tags`:e.tags=r.tags;break;case`pinned`:e.pinned=r.pinned;break}}function X(e){return`rounded-none border px-1.5 py-0.5 text-[10px] transition-colors `+(e?`border-primary bg-primary/10 text-primary`:`border-input text-muted-foreground hover:bg-muted/60`)}function Te({tags:e,onChange:t,workspace:n,ariaLabelledBy:r}){let[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(``),u=(0,J.useId)(),d=(0,J.useRef)(null);function f(n){let r=n.trim().replace(/^#/,``).replace(/,$/,``).trim();r&&!e.includes(r)&&t([...e,r]),a(``),s(!1)}function p(e){f(e.id)}function m(n){n.key===`,`?(n.preventDefault(),f(i)):n.key===`Backspace`&&i===``&&e.length>0&&t(e.slice(0,-1))}return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border border-input p-1.5`,children:[e.map(n=>(0,Y.jsxs)(K,{tone:`mono`,className:`gap-1 text-[10px] lowercase tracking-normal`,children:[`#`,n,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e!==n)),className:`hover:text-destructive`,"aria-label":`Remove tag ${n}`,children:(0,Y.jsx)(w,{className:`h-3 w-3`})})]},n)),(0,Y.jsx)(b,{ref:d,value:i,onChange:e=>{a(e.target.value),s(e.target.value.trim()!==``)},onKeyDown:m,onFocus:()=>s(i.trim()!==``),onBlur:()=>window.setTimeout(()=>s(!1),120),role:`combobox`,"aria-expanded":o,"aria-autocomplete":`list`,"aria-controls":o?u:void 0,"aria-activedescendant":o&&c?c:void 0,"aria-labelledby":r,placeholder:e.length===0?`add tags… #`:``,className:`h-6 flex-1 border-0 px-1 font-mono text-xs shadow-none focus-visible:ring-0`})]}),(0,Y.jsx)(_e,{open:o,query:i.replace(/^#/,``),mode:`tag`,workspace:n,listboxId:u,onActiveDescendant:l,onSelect:p,onClose:()=>s(!1)})]})}function Ee({refs:e,onChange:t,placeholder:n,workspace:r,ariaLabelledBy:i}){let[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(``),d=(0,J.useId)(),f=(0,J.useRef)(null);function p(n){let r=n.trim().replace(/^\[\[/,``).replace(/\]\]$/,``).trim();r&&!e.includes(r)&&t([...e,r]),o(``),c(!1)}async function m(e){if(e.create){try{let t=await te(`task`,e.id,r??``);t.id&&(p(t.id),H.success(`Created stub "${e.id}" and linked it.`))}catch{H.error(`Could not create the linked record.`)}return}p(e.id)}function h(n){n.key===`,`?(n.preventDefault(),p(a)):n.key===`Backspace`&&a===``&&e.length>0&&t(e.slice(0,-1))}return(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border border-input p-1.5`,children:[e.map(n=>(0,Y.jsxs)(K,{tone:`mono`,className:`gap-1 text-[10px] lowercase tracking-normal`,children:[`[[`,n,`]]`,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>e!==n)),className:`hover:text-destructive`,"aria-label":`Remove ref ${n}`,children:(0,Y.jsx)(w,{className:`h-3 w-3`})})]},n)),(0,Y.jsx)(b,{ref:f,value:a,onChange:e=>{o(e.target.value),c(e.target.value.trim()!==``)},onKeyDown:h,onFocus:()=>c(a.trim()!==``),onBlur:()=>{window.setTimeout(()=>c(!1),120)},role:`combobox`,"aria-expanded":s,"aria-autocomplete":`list`,"aria-controls":s?d:void 0,"aria-activedescendant":s&&l?l:void 0,"aria-labelledby":i,placeholder:e.length===0?n??`link a record… [[`:``,className:`h-6 flex-1 border-0 px-1 font-mono text-xs shadow-none focus-visible:ring-0`})]}),(0,Y.jsx)(_e,{open:s,query:a.replace(/^\[\[/,``),mode:`ref`,workspace:r,listboxId:d,onActiveDescendant:u,onSelect:m,onClose:()=>c(!1)})]})}var De=250,Oe=1500,ke=8;function Ae({field:e,workspace:t,value:n,caret:r}){let[i,a]=(0,J.useState)({ghost:``,inFlight:!1,profile:null,degraded:!1}),o=(0,J.useRef)(null),s=(0,J.useRef)(null),c=(0,J.useRef)(null),l=(0,J.useRef)(``),u=(0,J.useCallback)(()=>{o.current?.abort(),o.current=null,c.current&&clearTimeout(c.current),c.current=null},[]),d=(0,J.useCallback)(()=>{u(),a(e=>({...e,ghost:``,inFlight:!1}))},[u]);return(0,J.useEffect)(()=>{s.current&&clearTimeout(s.current);let d=r>=n.length;if(i.degraded||!d||n.trim().length({...e,ghost:``}));return}return s.current=setTimeout(()=>{u();let r=new AbortController;o.current=r,l.current=n;let i=``,s=!1;c.current=setTimeout(()=>{s||r.abort()},Oe),a(e=>({...e,inFlight:!0})),de({context:n,field:e,workspace:t},e=>{s=!0,c.current&&=(clearTimeout(c.current),null),i+=e,l.current===n&&a(e=>({...e,ghost:i}))},r.signal).then(({profile:e,degraded:t})=>{c.current&&clearTimeout(c.current),l.current===n&&a(n=>({...n,inFlight:!1,profile:e??n.profile,degraded:t||n.degraded,ghost:i}))}).catch(e=>{e?.name!==`AbortError`&&a(e=>({...e,inFlight:!1,ghost:``}))})},De),()=>{s.current&&clearTimeout(s.current)}},[n,r,e,t,i.degraded]),(0,J.useEffect)(()=>()=>u(),[u]),{...i,clear:d,cancel:u}}function je(e){if(!e)return 0;let t=0;for(;t{c?.({ghost:p,inFlight:m,profile:h,degraded:g})},[m,h,g]);let v=p!==``&&u>=e.length,y=(0,J.useCallback)(()=>{p&&(t(e+p),_(),queueMicrotask(()=>{let t=f.current;if(t){let n=(e+p).length;t.setSelectionRange(n,n),d(n)}}))},[p,e,t,_]),b=(0,J.useCallback)(()=>{if(!p)return;let n=je(p),r=p.slice(0,n);t(e+r),queueMicrotask(()=>{let t=f.current;if(t){let n=(e+r).length;t.setSelectionRange(n,n),d(n)}})},[p,e,t]),x=(0,J.useCallback)(t=>{if(v){if(t.key===`Tab`){t.preventDefault(),y();return}if(t.key===`ArrowRight`&&u>=e.length){t.preventDefault(),b();return}if(t.key===`Escape`){t.preventDefault(),_();return}(t.key.length===1||t.key===`Backspace`||t.key===`Enter`)&&_()}},[v,u,e,y,b,_]),S=(0,J.useCallback)(()=>{let e=f.current;e&&d(e.selectionEnd??e.value.length)},[]),C=n(`relative z-10 w-full resize-none border bg-transparent px-3 py-2 text-sm outline-none rounded-none`,`border-input focus-visible:border-ring`,l?`min-h-[220px] font-mono`:``,a);return(0,Y.jsxs)(`div`,{className:`relative`,children:[v&&(0,Y.jsxs)(`div`,{"aria-hidden":!0,className:n(`pointer-events-none absolute inset-0 z-0 overflow-hidden whitespace-pre-wrap break-words border border-transparent px-3 py-2 text-sm`,l?`font-mono`:``),children:[(0,Y.jsx)(`span`,{className:`text-transparent`,children:e}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/45`,children:p})]}),l?(0,Y.jsx)(`textarea`,{ref:f,id:s,className:C,value:e,placeholder:o,onChange:e=>{t(e.target.value),d(e.target.selectionEnd??e.target.value.length)},onKeyDown:x,onKeyUp:S,onClick:S,onSelect:S,onBlur:_}):(0,Y.jsx)(`input`,{ref:f,id:s,className:n(C,`h-9`),value:e,placeholder:o,onChange:e=>{t(e.target.value),d(e.target.selectionEnd??e.target.value.length)},onKeyDown:x,onKeyUp:S,onClick:S,onSelect:S,onBlur:_})]})}function Fe(e,t){return e&&e.field===t?e:void 0}function Ie(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,10)}function Le(e){if(!e)return;let t=new Date(`${e}T00:00:00Z`);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function Re(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ze(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()}function Be(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16).replace(`T`,` `)}function Ve({value:e,onChange:t,ariaLabelledBy:n}){return(0,Y.jsxs)(pe,{value:e?.session_id?`kept:${e.session_id}`:e?.origin_kind?`local`:`unassigned`,onValueChange:e=>{e===`unassigned`?t(void 0):e===`local`&&t({origin_kind:`local`})},children:[(0,Y.jsx)(W,{className:`rounded-none`,"aria-labelledby":n,children:(0,Y.jsx)(U,{})}),(0,Y.jsxs)(I,{children:[(0,Y.jsx)(R,{value:`unassigned`,children:`unassigned`}),(0,Y.jsx)(R,{value:`local`,children:`local (this session)`}),e?.session_id&&(0,Y.jsx)(R,{value:`kept:${e.session_id}`,children:(0,Y.jsxs)(`span`,{className:`font-mono text-xs`,children:[e.origin_kind??`agent`,` · `,e.session_id]})})]})]})}function He({id:e,source:t,created:n,updated:r}){return!e&&!t?.kind&&!n&&!r?null:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-border pb-2 text-[10px] text-muted-foreground`,children:[e&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`font-mono`,children:e}),(0,Y.jsx)(F,{value:e})]}),t?.kind&&(0,Y.jsxs)(`span`,{children:[`source`,` `,(0,Y.jsxs)(`span`,{className:`font-mono`,children:[t.kind,t.session_id?` · ${t.session_id}`:``]})]}),n&&(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`created `,Be(n)]}),r&&(0,Y.jsxs)(`span`,{className:`font-mono`,children:[`updated `,Be(r)]})]})}function Ue({pinned:e,onChange:t}){return(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(me,{checked:e,onCheckedChange:e=>t(!!e)}),`Pinned`]})}function Z({label:e,error:t,children:n}){let r=(0,J.useId)(),i=(0,J.useId)();return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(j,{id:i,htmlFor:r,className:`text-xs text-muted-foreground`,children:e}),typeof n==`function`?n({controlId:r,labelId:i}):n,t&&(0,Y.jsxs)(`p`,{className:`text-xs text-red-300`,children:[t.message,t.allowed&&t.allowed.length>0&&(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[` allowed: `,t.allowed.join(` · `)]})]})]})}function We(e){let t=e.trim().replace(/,$/,``).trim();if(!t)return null;let n=t.split(`:`).map(e=>e.trim());if(n.length===1)return{kind:`entity`,id:n[0]};let[r,i,a]=n;return!r||!i?null:a?{kind:r,id:i,role:a}:{kind:r,id:i}}function Q(e){return`${e.kind}${e.id}${e.role??``}`}function Ge(e){return e.role?`${e.kind}:${e.id}:${e.role}`:`${e.kind}:${e.id}`}function Ke({entities:e,onChange:t,ariaLabelledBy:n}){let[r,i]=(0,J.useState)(``);function a(){let n=We(r);n&&!e.some(e=>Q(e)===Q(n))&&t([...e,n]),i(``)}function o(n){n.key===`Enter`||n.key===`,`?(n.preventDefault(),a()):n.key===`Backspace`&&r===``&&e.length>0&&t(e.slice(0,-1))}return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border border-input p-1.5`,children:[e.map(n=>(0,Y.jsxs)(K,{tone:`mono`,className:`gap-1 text-[10px] lowercase tracking-normal`,children:[Ge(n),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter(e=>Q(e)!==Q(n))),className:`hover:text-destructive`,"aria-label":`Remove entity ${Ge(n)}`,children:(0,Y.jsx)(w,{className:`h-3 w-3`})})]},Q(n))),(0,Y.jsx)(b,{value:r,onChange:e=>i(e.target.value),onKeyDown:o,onBlur:a,"aria-labelledby":n,placeholder:e.length===0?`kind:id (e.g. person:max) …`:``,className:`h-6 flex-1 border-0 px-1 shadow-none focus-visible:ring-0`})]})}function qe({rec:e,err:t,onChange:n,onGhostState:r}){let i=(e.kind||`note`)===`fact`;return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(Z,{label:i?`Fact name`:`Title`,error:Fe(t,`name`),children:({controlId:t})=>(0,Y.jsx)(b,{id:t,className:`h-auto border-0 border-b border-border bg-transparent px-0 py-1 text-xl font-semibold focus-visible:ring-0 focus-visible:border-primary`,placeholder:i?`Name this fact`:`Untitled note`,value:e.name,onChange:t=>n({...e,name:t.target.value})})}),(0,Y.jsx)(Z,{label:i?`What is true`:`Write`,children:({controlId:t})=>(0,Y.jsx)(Ne,{id:t,value:e.content,onChange:t=>n({...e,content:t}),field:`content`,workspace:e.workspace,onState:r})}),(0,Y.jsxs)(`div`,{className:`space-y-3 border-t border-border pt-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/60`,children:`Details`}),(0,Y.jsx)(Z,{label:`Tags`,children:({labelId:t})=>(0,Y.jsx)(Te,{tags:e.tags??[],onChange:t=>n({...e,tags:t}),workspace:e.workspace,ariaLabelledBy:t})}),(0,Y.jsx)(Z,{label:`Linked to`,children:({labelId:t})=>(0,Y.jsx)(Ke,{entities:e.entities??[],onChange:t=>n({...e,entities:t}),ariaLabelledBy:t})}),(0,Y.jsx)(Z,{label:`Type`,children:({labelId:t})=>(0,Y.jsxs)(l,{type:`single`,value:e.kind||`note`,onValueChange:t=>t&&n({...e,kind:t}),variant:`outline`,"aria-labelledby":t,children:[(0,Y.jsx)(c,{value:`note`,className:`rounded-none text-xs`,children:`Note`}),(0,Y.jsx)(c,{value:`fact`,className:`rounded-none text-xs`,children:`Fact`})]})}),i&&(0,Y.jsx)(Z,{label:`Valid from`,children:({controlId:t})=>(0,Y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Y.jsx)(b,{id:t,type:`datetime-local`,disabled:!e.t_valid_start,value:Re(e.t_valid_start),onChange:t=>n({...e,t_valid_start:ze(t.target.value)})}),(0,Y.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Y.jsx)(me,{checked:!e.t_valid_start,onCheckedChange:t=>n({...e,t_valid_start:t?void 0:new Date().toISOString()})}),`Currently valid (valid from now)`]})]})}),(0,Y.jsx)(Ue,{pinned:e.pinned,onChange:t=>n({...e,pinned:t})})]}),(0,Y.jsx)(He,{id:e.id,source:e.source,created:e.created_at,updated:e.updated_at})]})}var Je=[``,`low`,`med`,`high`];function Ye({rec:e,vocab:t,err:n,onChange:r,onGhostState:i}){let a=(0,J.useMemo)(()=>{let n=new Set(t);return e.status&&n.add(e.status),Array.from(n)},[t,e.status]),o=e.status!==``&&t.length>0&&!t.includes(e.status);return(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(He,{id:e.id,source:e.source,created:e.created_at,updated:e.updated_at}),(0,Y.jsx)(Z,{label:`Title`,children:({controlId:t})=>(0,Y.jsx)(b,{id:t,value:e.title,onChange:t=>r({...e,title:t.target.value})})}),(0,Y.jsx)(Z,{label:`Status`,error:Fe(n,`status`),children:({controlId:t,labelId:n})=>a.length>0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l,{type:`single`,value:e.status,onValueChange:t=>t&&r({...e,status:t}),variant:`outline`,"aria-labelledby":n,children:a.map(e=>(0,Y.jsx)(c,{value:e,className:`rounded-none font-mono text-xs`,children:e},e))}),o&&(0,Y.jsx)(`p`,{className:`text-xs text-amber-300`,children:`current value off-vocab`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(b,{id:t,value:e.status,onChange:t=>r({...e,status:t.target.value}),placeholder:`open / doing / review / done`}),o&&(0,Y.jsx)(`p`,{className:`text-xs text-amber-300`,children:`current value off-vocab`})]})}),(0,Y.jsx)(Z,{label:`Priority`,children:({labelId:t})=>(0,Y.jsx)(l,{type:`single`,value:e.priority??``,onValueChange:t=>r({...e,priority:t}),variant:`outline`,"aria-labelledby":t,children:Je.map(e=>(0,Y.jsx)(c,{value:e,className:`rounded-none font-mono text-xs`,children:e||`none`},e||`none`))})}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Y.jsx)(Z,{label:`Due date`,children:({controlId:t})=>(0,Y.jsx)(b,{id:t,type:`date`,value:Ie(e.due_at),onChange:t=>r({...e,due_at:Le(t.target.value)})})}),(0,Y.jsx)(Z,{label:`Assignee`,children:({labelId:t})=>(0,Y.jsx)(Ve,{value:e.assignee,onChange:t=>r({...e,assignee:t}),ariaLabelledBy:t})})]}),(0,Y.jsx)(Z,{label:`Tags`,children:({labelId:t})=>(0,Y.jsx)(Te,{tags:e.tags??[],onChange:t=>r({...e,tags:t}),workspace:e.workspace,ariaLabelledBy:t})}),(0,Y.jsx)(Z,{label:`Composes (child records)`,children:({labelId:t})=>(0,Y.jsx)(Ee,{refs:e.composes??[],onChange:t=>r({...e,composes:t}),workspace:e.workspace,ariaLabelledBy:t})}),(0,Y.jsx)(Ue,{pinned:e.pinned,onChange:t=>r({...e,pinned:t})}),(0,Y.jsx)(Z,{label:`Description (Markdown)`,children:({controlId:t})=>(0,Y.jsx)(Ne,{id:t,value:e.description,onChange:t=>r({...e,description:t}),field:`description`,workspace:e.workspace,onState:i})})]})}function Xe({message:e,field:t,allowed:n,onFix:r}){let i=n&&n.length>0?n[0]:void 0,a=!!(t&&i&&r);return(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border border-red-500/40 bg-red-500/10 p-2 text-sm`,children:[(0,Y.jsx)(q,{className:`mt-0.5 h-4 w-4 shrink-0 text-red-300`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`font-medium text-red-300`,children:`not indexed: your agent cannot see this record yet`}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e}),n&&n.length>0&&(0,Y.jsxs)(`div`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground/80`,children:[`allowed: `,n.join(` · `)]})]}),a&&(0,Y.jsxs)(y,{size:`sm`,variant:`outline`,className:`h-7 shrink-0 rounded-none font-mono text-xs`,onClick:()=>r(t,i),children:[`fix → set "`,i,`"`]})]})}function Ze({path:e,raw:t,savedHint:n}){let[r,i]=(0,J.useState)(!1);return e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border pt-2 font-mono text-xs text-muted-foreground`,children:[(0,Y.jsx)(d,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:`this is exactly what your agent reads`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`text-primary hover:underline`,children:`open as file`}),n&&(0,Y.jsx)(`span`,{className:`ml-auto text-muted-foreground/70`,children:n})]}),(0,Y.jsx)(h,{open:r,onOpenChange:i,children:(0,Y.jsxs)(he,{side:`right`,className:`w-[640px] max-w-[90vw] rounded-none sm:max-w-[640px]`,children:[(0,Y.jsx)(v,{children:(0,Y.jsxs)(_,{className:`flex items-center gap-2 font-mono text-xs`,children:[(0,Y.jsx)(z,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),` `,e]})}),(0,Y.jsx)(`p`,{className:`px-1 pt-2 text-xs text-muted-foreground`,children:`this is exactly what your agent reads`}),(0,Y.jsx)(`pre`,{className:`mt-2 h-[calc(100%-4rem)] overflow-auto whitespace-pre-wrap border border-border bg-muted/30 p-2 font-mono text-xs`,children:t||`(raw .md not loaded; open from the record list)`})]})})]}):null}function Qe({profile:e,inFlight:t}){return e?(0,Y.jsxs)(E,{children:[(0,Y.jsx)(A,{asChild:!0,children:(0,Y.jsxs)(`span`,{className:`relative inline-flex select-none items-center gap-1 px-1 py-0.5 font-mono text-[11px] text-muted-foreground`,"aria-live":`polite`,children:[t&&(0,Y.jsx)(`span`,{className:`animate-shimmer pointer-events-none absolute inset-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`relative`,children:[`model · `,e]}),t&&(0,Y.jsx)(`span`,{className:`sr-only`,children:`suggestion loading`})]})}),(0,Y.jsx)(O,{side:`bottom`,className:`font-mono text-xs`,children:t?`${e} · generating`:`model profile: ${e}`})]}):null}var $e=2;function et({candidates:e,onSave:t,onDismiss:n,onNever:r,pulse:i=!0}){let[a,o]=(0,J.useState)(!1);if(e.length===0)return null;let s=a?e:e.slice(0,$e),c=e.length-s.length;return(0,Y.jsxs)(`aside`,{className:`w-full space-y-2`,"aria-label":`Memory suggestions`,children:[s.map((e,a)=>(0,Y.jsx)(tt,{candidate:e,pulse:i&&a===0,onSave:()=>t(e),onDismiss:()=>n(e),onNever:()=>r(e)},e.content_hash)),!a&&c>0&&(0,Y.jsxs)(`button`,{type:`button`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,onClick:()=>o(!0),children:[`+ `,c,` more`]})]})}function tt({candidate:e,pulse:t,onSave:n,onDismiss:r,onNever:i}){let[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{className:`animate-[audit-in_0.45s_ease-out] border border-border bg-card p-3`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`save as memory?`}),t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`animate-pulse-slow inline-block h-2 w-2 bg-primary motion-reduce:animate-none`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`a memory suggestion is waiting for you`})]})]}),(0,Y.jsx)(`p`,{className:`mb-2 text-sm`,children:e.text}),(0,Y.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(K,{tone:`mono`,className:`text-[10px]`,children:e.kind}),(e.tags??[]).map(e=>(0,Y.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[`#`,e]},e)),(e.refs??[]).map(e=>(0,Y.jsxs)(`span`,{className:`font-mono text-[11px] text-primary`,children:[`[[`,e,`]]`]},e))]}),(0,Y.jsxs)(`button`,{type:`button`,className:`mb-2 flex items-center gap-0.5 font-mono text-[11px] text-muted-foreground hover:text-foreground`,onClick:()=>o(e=>!e),"aria-expanded":a,children:[(0,Y.jsx)(u,{className:`h-3 w-3 transition-transform ${a?`rotate-90`:``}`,"aria-hidden":!0}),`why?`]}),a&&(0,Y.jsxs)(`div`,{className:`mb-2 border border-border bg-background p-2 font-mono text-[11px] text-muted-foreground`,children:[`signal: `,e.signal]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(y,{size:`sm`,className:`rounded-none`,onClick:n,children:`save memory`}),(0,Y.jsx)(y,{size:`sm`,variant:`ghost`,className:`rounded-none`,onClick:r,children:`not now`}),(0,Y.jsx)(y,{size:`sm`,variant:`ghost`,className:`rounded-none text-muted-foreground`,onClick:i,children:`never`})]})]})}function nt({nudge:e,onApply:t,onDismiss:n}){return(0,Y.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`animate-[audit-in_0.45s_ease-out] flex items-center gap-2 border border-amber-500/40 bg-amber-500/10 px-2.5 py-1.5 text-xs text-amber-300`,children:[(0,Y.jsxs)(`span`,{className:`relative inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center`,"aria-hidden":!0,children:[(0,Y.jsx)(`span`,{className:`absolute inset-0 animate-pulse-slow bg-amber-400/30 motion-reduce:animate-none`}),(0,Y.jsx)(q,{className:`relative h-3.5 w-3.5`})]}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.message}),(0,Y.jsx)(y,{size:`sm`,variant:`ghost`,className:`h-6 rounded-none px-2 text-amber-200 hover:bg-amber-500/20 hover:text-amber-100`,onClick:()=>t(e),children:`apply`}),(0,Y.jsx)(y,{size:`sm`,variant:`ghost`,className:`h-6 rounded-none px-2 text-muted-foreground`,onClick:()=>n(e),"aria-label":`dismiss suggestion`,children:`dismiss`})]})}var rt={"missing-acceptance-criteria":70,"link-related-memory":60,"entity-extraction":50,"auto-tag":40},it=100;function at(e){return rt[e]??10}function ot(e){let t=null,n=-1;for(let r of e){let e=at(r.kind);e>n&&(t=r,n=e)}return t}function st(e,t){let n=ot(t),r=e.length>0;return!r&&!n?{owner:`none`,nudge:null}:n?r?{owner:it>=at(n.kind)?`memory`:`guidance`,nudge:n}:{owner:`guidance`,nudge:n}:{owner:`memory`,nudge:null}}function ct(e){if(e instanceof i)try{let t=JSON.parse(e.body);return{message:t.error??e.message,field:t.field,allowed:t.allowed,conflict:t.conflict,detail:t.detail}}catch{return{message:e.body||e.message}}return{message:e instanceof Error?e.message:`Save failed`}}function lt({kind:e,initial:t,onSaved:n,onCancel:r}){let[i,a]=(0,J.useState)(dt(e,t)),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),[p,m]=(0,J.useState)([]),[h,g]=(0,J.useState)({ghost:``,inFlight:!1,profile:null,degraded:!1}),[_,v]=(0,J.useState)([]),b=(0,J.useRef)(null),[S,w]=(0,J.useState)([]),[T,E]=(0,J.useState)(new Set),D=(0,J.useRef)(null);(0,J.useEffect)(()=>{l(null),d(null),w([]),E(new Set),a(dt(e,t))},[e,t]);let O=i.kind===`task`?i.rec.workspace:i.rec.workspace??``;(0,J.useEffect)(()=>{if(i.kind!==`task`||!O){m([]);return}let e=!1;return N(O).then(t=>{e||m(t.map(e=>e.status_text))}).catch(()=>{e||m([])}),()=>{e=!0}},[i.kind,O]);let k=i.kind===`task`?i.rec.description:i.rec.content,A=i.kind===`task`?i.rec.title:i.rec.name;(0,J.useEffect)(()=>{if(!k||k.trim().length<40){v([]);return}let e=setTimeout(()=>{b.current?.abort();let e=new AbortController;b.current=e,C({record_id:i.rec.id,title:A,body:k,workspace:O||void 0},e.signal).then(({candidates:e})=>v(e)).catch(e=>{e?.name!==`AbortError`&&v([])})},1200);return()=>clearTimeout(e)},[k,A,O,i.rec.id]);let j=i.kind===`task`?i.rec.status:``,M=i.rec.tags??[];(0,J.useEffect)(()=>{if(!k||k.trim().length<12){w([]);return}let e=setTimeout(()=>{D.current?.abort();let e=new AbortController;D.current=e,x({record_id:i.rec.id,title:A,body:k,status:j,tags:M,workspace:O||void 0},e.signal).then(({nudges:e})=>w(e.filter(e=>!T.has(e.kind)))).catch(e=>{e?.name!==`AbortError`&&w([])})},1200);return()=>clearTimeout(e)},[k,A,j,M.join(`,`),O,i.rec.id,T]);function ee(e){a(t=>{if(t.kind===`task`){let n={...t.rec};if(e.apply.add_tag&&!n.tags.includes(e.apply.add_tag)&&(n.tags=[...n.tags,e.apply.add_tag]),e.apply.insert_ref){let t=n.composes??[];t.includes(e.apply.insert_ref)||(n.composes=[...t,e.apply.insert_ref])}return e.apply.append_body&&(n.description=(n.description??``)+e.apply.append_body),{kind:`task`,rec:n}}let n={...t.rec};if(e.apply.add_tag&&!n.tags.includes(e.apply.add_tag)&&(n.tags=[...n.tags,e.apply.add_tag]),e.apply.insert_ref){let t=n.entities??[];t.some(t=>t.id===e.apply.insert_ref)||(n.entities=[...t,{kind:`memory`,id:e.apply.insert_ref}])}return e.apply.append_body&&(n.content=(n.content??``)+e.apply.append_body),{kind:`memory`,rec:n}}),w(t=>t.filter(t=>t.kind!==e.kind)),E(t=>new Set(t).add(e.kind))}function P(e){w(t=>t.filter(t=>t.kind!==e.kind)),E(t=>new Set(t).add(e.kind))}async function te(e){try{await fe({id:``,kind:e.kind===`fact`?`fact`:`note`,name:ut(e.text),workspace:O||void 0,tags:e.tags??[],pinned:!1,content:e.text,entities:(e.refs??[]).map(e=>({kind:`task`,id:e}))}),H.success(`Saved to your facts.`),v(t=>t.filter(t=>t.content_hash!==e.content_hash))}catch(e){H.error(ct(e).message)}}function ne(e){v(t=>t.filter(t=>t.content_hash!==e.content_hash))}async function re(e){if(v(t=>t.filter(t=>t.content_hash!==e.content_hash)),i.rec.id)try{await B(i.rec.id,e.content_hash)}catch{}}async function ie(e,t){s(!0),l(null),d(null);try{if(i.kind===`task`){let r={...e??i.rec};r.if_hash=t??r.on_disk_hash;let a=await ce(r);H.success(`Task saved.`),n(a)}else{let r={...e??i.rec};r.if_hash=t??r.on_disk_hash;let a=await fe(r);H.success(`${i.rec.kind===`fact`?`Fact`:`Note`} saved.`),n(a)}}catch(e){let t=ct(e);t.conflict&&t.detail?d(t.detail):t.conflict?(l(t),H.error(`Edit conflicted. Saved to a .conflict sidecar.`)):(l(t),H.error(t.field?`${t.field}: ${t.message}`:t.message))}finally{s(!1)}}function ae(e,t){a(n=>n.kind===`task`?{kind:`task`,rec:{...n.rec,[e]:t}}:{kind:`memory`,rec:{...n.rec,[e]:t}}),l(t=>t&&t.field===e?null:t)}let F=!i.rec.id,I=i.kind===`task`?`task`:i.kind===`memory`&&i.rec.kind===`fact`?`fact`:`note`,L=i.rec.validation_error?{message:i.rec.validation_error,field:i.rec.validation_field,allowed:p.length>0?p:void 0}:null,R=c?.field?{field:c.field,message:c.message,allowed:c.allowed}:L,z=st(_,S),V=z.nudge;return(0,Y.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[F?`New`:`Edit`,` `,I]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Qe,{profile:h.profile,inFlight:h.inFlight}),(0,Y.jsx)(K,{tone:`mono`,className:`text-xs`,children:i.rec.id||`unsaved`})]})]}),L&&(0,Y.jsx)(Xe,{message:L.message,field:L.field,allowed:L.allowed,onFix:ae}),!L&&c?.field&&c.allowed&&c.allowed.length>0&&(0,Y.jsx)(Xe,{message:c.message,field:c.field,allowed:c.allowed,onFix:ae}),c&&!c.field&&(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 border border-amber-500/40 bg-amber-500/10 p-2 text-sm text-amber-300`,children:[(0,Y.jsx)(q,{className:`mt-0.5 h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:c.message})]}),i.kind===`task`?(0,Y.jsx)(Ye,{rec:i.rec,vocab:p,err:R,onChange:e=>a({kind:`task`,rec:e}),onGhostState:g}):(0,Y.jsx)(qe,{rec:i.rec,err:R,onChange:e=>a({kind:`memory`,rec:e}),onGhostState:g}),V&&(0,Y.jsx)(nt,{nudge:V,onApply:ee,onDismiss:P}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,Y.jsxs)(y,{className:`rounded-none`,onClick:()=>ie(),disabled:o,children:[o?(0,Y.jsx)(le,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,Y.jsx)(f,{className:`mr-1.5 h-4 w-4`}),`Save`]}),(0,Y.jsx)(y,{variant:`ghost`,className:`rounded-none`,onClick:r,disabled:o,children:`Cancel`})]}),(0,Y.jsx)(Ze,{path:i.rec.path,raw:i.rec.raw,savedHint:i.rec.id?`saved · indexed`:void 0}),u&&(0,Y.jsx)(xe,{detail:u,kind:i.kind,mine:i.rec,open:!!u,onResolve:(e,t)=>ie(e,t),onReload:()=>{let e=i.kind===`task`?u.on_disk_task:u.on_disk_memory;if(e){let t={...e,on_disk_hash:u.on_disk_hash};a(i.kind===`task`?{kind:`task`,rec:t}:{kind:`memory`,rec:t})}d(null)},onCancel:()=>d(null)})]}),_.length>0&&(0,Y.jsx)(`div`,{className:`w-72 shrink-0`,children:(0,Y.jsx)(et,{candidates:_,pulse:z.owner===`memory`,onSave:te,onDismiss:ne,onNever:re})})]})}function ut(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,``).trim().split(/\s+/).slice(0,6).join(`-`)||`memory-${Date.now()}`}function dt(e,t){return e===`task`?{kind:`task`,rec:{...t}}:{kind:`memory`,rec:{...t}}}function ft({onNew:e}){return(0,Y.jsx)(ve,{testid:`brain-tasks-empty`,title:`Nothing to do here yet.`,description:(0,Y.jsx)(Y.Fragment,{children:`Tasks track work in this space. You and your agents add them, move them along, and check them off together.`}),action:(0,Y.jsx)(ht,{label:`New task`,onClick:e})})}function pt({onNew:e}){return(0,Y.jsx)(ve,{testid:`brain-memories-empty`,title:`No facts here yet.`,description:(0,Y.jsx)(Y.Fragment,{children:`Facts are the things worth remembering: how something works, a decision and why you made it, a preference. Your agents recall them automatically, and the brain will quietly suggest some as you write.`}),action:(0,Y.jsx)(ht,{label:`New fact`,onClick:e})})}function mt({onNew:e}){return(0,Y.jsx)(ve,{testid:`brain-notes-empty`,title:`No notes yet.`,description:(0,Y.jsx)(Y.Fragment,{children:`Notes are where you write things down: meeting notes, how-tos, anything you want to keep. Write freely. Your agents can read every word.`}),action:(0,Y.jsx)(ht,{label:`New note`,onClick:e})})}function ht({label:e,onClick:t}){return(0,Y.jsxs)(y,{size:`sm`,variant:`outline`,className:`rounded-none`,onClick:t,children:[(0,Y.jsx)(M,{className:`mr-1.5 h-3.5 w-3.5`}),` `,e]})}var gt=[`open`,`doing`,`review`,`done`],_t={high:`high`,med:`warn`,low:`info`};function vt(e){return e&&_t[e]||`none`}function yt({tasks:e,memories:t,notes:n,activeTab:r,statusFilter:i,selectedId:a,onStatusFilter:o,onSelect:s,onNew:c}){let l=(0,J.useMemo)(()=>i?e.filter(e=>e.status===i):e,[e,i]),u=(0,J.useMemo)(()=>e.filter(e=>e.status===`open`).length,[e]),d=(0,J.useMemo)(()=>e.filter(e=>e.status===`doing`).length,[e]);return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[r===`tasks`&&(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[(0,Y.jsx)(bt,{active:i,onChange:o}),(0,Y.jsxs)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:[u,` open · `,d,` doing`]})]}),(0,Y.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[r===`tasks`&&(0,Y.jsx)(St,{tasks:l,selectedId:a,onSelect:s,onNew:c}),r===`memory`&&(0,Y.jsx)(Ct,{rows:t,kindLabel:`memories`,selectedId:a,onSelect:s,onNew:c}),r===`notes`&&(0,Y.jsx)(Ct,{rows:n,kindLabel:`notes`,selectedId:a,onSelect:s,onNew:c})]})]})}function bt({active:e,onChange:t}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 font-mono text-[11px]`,children:[(0,Y.jsx)(xt,{label:`all`,on:e===null,onClick:()=>t(null)}),gt.map((n,r)=>(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/40`,"aria-hidden":!0,children:r===0?``:`▸`}),(0,Y.jsx)(xt,{label:n,on:e===n,onClick:()=>t(n)})]},n))]})}function xt({label:e,on:t,onClick:r}){return(0,Y.jsx)(`button`,{type:`button`,onClick:r,"aria-pressed":t,className:n(`px-1.5 py-0.5 transition-colors`,t?`text-primary`:`text-muted-foreground hover:text-foreground`),children:e})}function St({tasks:e,selectedId:t,onSelect:n,onNew:r}){return e.length===0?(0,Y.jsx)(ft,{onNew:r}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border`,children:e.map(e=>(0,Y.jsxs)(wt,{id:e.id,live:!!e.live_lease,flagged:!!e.validation_error,active:t===e.id,onClick:()=>n(`task`,e.id),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.title||`(untitled)`}),e.pinned&&(0,Y.jsx)(K,{tone:`mono`,className:`text-[9px]`,children:`pinned`})]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,Y.jsx)(K,{tone:`mono`,className:`text-[9px]`,children:e.status}),e.priority&&(0,Y.jsx)(K,{tone:vt(e.priority),className:`text-[9px]`,children:e.priority}),e.tags?.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[`#`,e]},e)),e.index_source&&(0,Y.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground/70`,children:e.index_source})]})]},e.id))})}function Ct({rows:e,kindLabel:t,selectedId:n,onSelect:r,onNew:i}){return e.length===0?t===`memories`?(0,Y.jsx)(pt,{onNew:i}):(0,Y.jsx)(mt,{onNew:i}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border`,children:e.map(e=>(0,Y.jsxs)(wt,{id:e.id,live:!1,flagged:!!e.validation_error,active:n===e.id,onClick:()=>r(`memory`,e.id),children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,children:e.name||`(unnamed)`}),e.pinned&&(0,Y.jsx)(K,{tone:`mono`,className:`text-[9px]`,children:`pinned`})]}),(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,Y.jsx)(K,{tone:`mono`,className:`text-[9px]`,children:e.kind}),e.tags?.slice(0,3).map(e=>(0,Y.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[`#`,e]},e)),e.index_source&&(0,Y.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground/70`,children:e.index_source})]})]},e.id))})}function wt({id:e,live:t,flagged:r,active:i,onClick:a,children:o}){return(0,Y.jsxs)(`li`,{className:`group/row relative`,children:[t&&(0,Y.jsx)(`span`,{className:`animate-shimmer pointer-events-none absolute inset-0 opacity-30`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,Y.jsxs)(`button`,{type:`button`,onClick:a,"aria-label":t?`agent active on this record`:void 0,className:n(`min-w-0 flex-1 px-3 py-2 text-left transition-colors hover:bg-muted/60`,i?`bg-muted`:``),children:[o,(0,Y.jsxs)(`div`,{className:`mt-1 flex items-center gap-1.5`,children:[r&&(0,Y.jsxs)(E,{children:[(0,Y.jsx)(A,{asChild:!0,children:(0,Y.jsx)(`span`,{className:`animate-pulse-slow inline-block h-1.5 w-1.5 bg-red-400/90`,"aria-label":`not indexed: your agent cannot see this record yet`})}),(0,Y.jsx)(O,{children:`not indexed: your agent cannot see this record yet`})]}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-[10px] text-muted-foreground/70`,children:e})]})]}),e&&(0,Y.jsx)(`div`,{className:`flex items-center px-1 opacity-0 transition-opacity group-hover/row:opacity-100`,children:(0,Y.jsx)(F,{value:e})})]})]})}function Tt({clients:e,workspaces:t,client:n,workspace:r,source:i,onClient:a,onWorkspace:o,onSource:s}){let d=(0,J.useMemo)(()=>n?t.filter(e=>e.parent_id===n):t,[n,t]),f=(0,J.useMemo)(()=>t.find(e=>e.id===r)??null,[t,r]);(0,J.useEffect)(()=>{d.length!==0&&(!r||!d.some(e=>e.id===r))&&o(d[0].id)},[d,r,o]);let p=i??f?.source??`central`;return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm`,children:[e.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`client`}),(0,Y.jsxs)(pe,{value:n??`__all__`,onValueChange:e=>a(e===`__all__`?null:e),children:[(0,Y.jsx)(W,{className:`h-8 w-[180px] rounded-none`,children:(0,Y.jsx)(U,{})}),(0,Y.jsxs)(I,{children:[(0,Y.jsx)(R,{value:`__all__`,children:`all clients`}),e.map(e=>(0,Y.jsxs)(R,{value:e.id,children:[e.display_name,(0,Y.jsx)(`span`,{className:`ml-1 font-mono text-[10px] text-muted-foreground`,children:e.workspace_count})]},e.id))]})]}),(0,Y.jsx)(u,{className:`h-3.5 w-3.5 text-muted-foreground/50`,"aria-hidden":!0})]}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`workspace`}),(0,Y.jsxs)(pe,{value:r??``,onValueChange:o,children:[(0,Y.jsx)(W,{className:`h-8 w-[200px] rounded-none`,children:(0,Y.jsx)(U,{placeholder:`select workspace`})}),(0,Y.jsx)(I,{children:d.map(e=>(0,Y.jsxs)(R,{value:e.id,children:[e.display_name,(0,Y.jsxs)(`span`,{className:`ml-1 font-mono text-[10px] text-muted-foreground`,children:[e.task_count,`t · `,e.memory_count,`m`]})]},e.id))})]}),(0,Y.jsx)(u,{className:`h-3.5 w-3.5 text-muted-foreground/50`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`source`}),(0,Y.jsxs)(l,{type:`single`,value:p,onValueChange:e=>e&&s(e),variant:`outline`,children:[(0,Y.jsx)(c,{value:`central`,className:`h-8 rounded-none font-mono text-xs`,children:`central`}),(0,Y.jsx)(c,{value:`repo`,className:`h-8 rounded-none font-mono text-xs`,children:`repo`})]})]})}function Et({scope:e,className:t}){return e?(0,Y.jsxs)(`div`,{className:n(`border-t border-border px-3 py-1.5 font-mono text-[11px] text-muted-foreground`,t),children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/70`,children:`scope:`}),` `,e]}):null}var $=`bg-muted/60 animate-pulse-slow`;function Dt({rows:e=6}){return(0,Y.jsx)(`ul`,{className:`divide-y divide-border`,"aria-hidden":!0,children:Array.from({length:e}).map((e,t)=>(0,Y.jsxs)(`li`,{className:`px-3 py-2`,children:[(0,Y.jsx)(`div`,{className:`h-4 w-[60%] ${$}`}),(0,Y.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,Y.jsx)(`div`,{className:`h-3 w-12 ${$}`}),(0,Y.jsx)(`div`,{className:`h-3 w-10 ${$}`}),(0,Y.jsx)(`div`,{className:`h-3 w-14 ${$}`})]}),(0,Y.jsx)(`div`,{className:`mt-1.5 h-2.5 w-[40%] ${$}`})]},t))})}function Ot(){return(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border px-3 py-2`,"aria-hidden":!0,children:[(0,Y.jsx)(`div`,{className:`h-3 w-10 ${$}`}),(0,Y.jsx)(`div`,{className:`h-8 w-[180px] ${$}`}),(0,Y.jsx)(`div`,{className:`h-3 w-16 ${$}`}),(0,Y.jsx)(`div`,{className:`h-8 w-[200px] ${$}`}),(0,Y.jsx)(`div`,{className:`h-3 w-12 ${$}`}),(0,Y.jsx)(`div`,{className:`h-8 w-32 ${$}`})]})}function kt(){return(0,Y.jsxs)(G,{className:`overflow-hidden rounded-none`,children:[(0,Y.jsx)(Ot,{}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-[minmax(320px,420px)_1fr]`,children:[(0,Y.jsx)(`div`,{className:`min-h-[60vh] border-r border-border`,children:(0,Y.jsx)(Dt,{})}),(0,Y.jsx)(`div`,{className:`p-4`})]})]})}function At({error:e}){return(0,Y.jsx)(G,{className:`rounded-none`,children:(0,Y.jsx)(se,{className:`py-8 text-center text-sm text-muted-foreground`,children:e.includes(`not enabled`)||e.includes(`503`)?`The Brain is disabled. Enable MCPLEXER_BRAIN_ENABLED and run brain_init + brain_import first.`:`Error: ${e}`})})}function jt(){return(0,Y.jsx)(G,{className:`rounded-none`,children:(0,Y.jsxs)(se,{className:`py-8 text-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(K,{tone:`muted`,className:`mb-2`,children:`empty index`}),(0,Y.jsx)(`div`,{children:`No workspaces in the brain index yet. Run brain_init + brain_import first.`})]})})}function Mt(e){return e instanceof Error?e.message:`Unknown error`}function Nt(e,t){return e?t?e.filter(e=>(e.tags??[]).includes(t)):e:[]}function Pt({workspace:e,source:t,activeTab:n,refreshKey:r,tag:i}){let[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[m,h]=(0,J.useState)(null);(0,J.useEffect)(()=>{o(null),c(null),u(null),h(null)},[e,t]),(0,J.useEffect)(()=>{if(!e)return;let r=!0,i=n;f(i),h(null);let a=t??void 0;return(i===`tasks`?L(e,{source:a}).then(e=>{r&&o(e)}):p(e,{source:a,memoryKind:i===`memory`?`fact`:`note`}).then(e=>{r&&(i===`memory`?c(e):u(e))})).catch(e=>{r&&h(Mt(e))}).finally(()=>{r&&f(null)}),()=>{r=!1}},[e,t,n,r]);let g=(0,J.useMemo)(()=>Nt(a,i),[a,i]),_=(0,J.useMemo)(()=>Nt(s,i),[s,i]),v=(0,J.useMemo)(()=>Nt(l,i),[l,i]),y=n===`tasks`?a!==null:n===`memory`?s!==null:l!==null;return{tasks:g,memories:_,notes:v,allMemories:[..._,...v],listLoading:!!e&&!y&&d===n,error:m}}function Ft(e){return{id:``,workspace:e,title:``,status:`open`,tags:[],pinned:!1,description:``}}function It(e,t){return{id:``,kind:t,name:``,workspace:e,tags:[],pinned:!1,content:``}}function Lt(e){return e===`memory`?`memory`:e===`tasks`?`tasks`:`notes`}function Rt(){let e=ee(),t=ge(),[n,r]=m(),i=n.get(`new`),c=n.get(`ws`),l=n.get(`tag`),{data:u,loading:d,error:f}=P((0,J.useCallback)(()=>ue(),[])),{data:p,loading:h,error:_,refetch:v}=P((0,J.useCallback)(()=>ae(),[])),[b,x]=(0,J.useState)(null),[C,T]=(0,J.useState)(t.ws??null),[E,D]=(0,J.useState)(null),[O,k]=(0,J.useState)(Lt(t.kind)),[A,j]=(0,J.useState)(null),[M,N]=(0,J.useState)(null),[te,F]=(0,J.useState)(0),I=d||h;(0,J.useEffect)(()=>{C===null&&p&&p.length>0&&T(t.ws??p[0].id)},[C,p,t.ws]);let{tasks:L,memories:R,notes:z,allMemories:B,listLoading:V,error:H}=Pt({workspace:C,source:E,activeTab:O,refreshKey:te,tag:l}),oe=f||_||H,{data:U}=P((0,J.useCallback)(()=>C?ie(C):Promise.resolve({scope:``}),[C]));(0,J.useEffect)(()=>{if(!t.id||!t.kind)return;let e=t.kind===`memory`||t.kind===`notes`?`memory`:`task`;(e===`task`?re(t.id):S(t.id)).then(t=>N(e===`task`?{kind:`task`,rec:t}:{kind:`memory`,rec:t})).catch(()=>{})},[t.id,t.kind]),(0,J.useEffect)(()=>{c&&(T(c),N(null),r(e=>(e.delete(`ws`),e),{replace:!0}))},[c,r]),(0,J.useEffect)(()=>{!i||!C||(i===`task`?(k(`tasks`),N({kind:`task`,rec:Ft(C)})):(k(`memory`),N({kind:`memory`,rec:It(C,`fact`)})),r(e=>(e.delete(`new`),e),{replace:!0}))},[i,C,r]);let se=M?M.rec.id||`__new__`:null,ce=(0,J.useCallback)((t,n)=>{(t===`task`?re(n):S(n)).then(r=>{N(t===`task`?{kind:`task`,rec:r}:{kind:`memory`,rec:r}),C&&e(`/brain/browse/${encodeURIComponent(C)}/${t===`task`?`tasks`:`memory`}/${encodeURIComponent(n)}`)}).catch(()=>{if(t===`task`){let e=(L??[]).find(e=>e.id===n);e&&N({kind:`task`,rec:e})}else{let e=(B??[]).find(e=>e.id===n);e&&N({kind:`memory`,rec:e})}})},[L,B,C,e]);function le(){C&&N(O===`tasks`?{kind:`task`,rec:Ft(C)}:{kind:`memory`,rec:It(C,O===`notes`?`note`:`fact`)})}function W(e){F(e=>e+1),v();let t=M?.kind??`task`;e.id?ce(t,e.id):N(null)}let de=(0,J.useMemo)(()=>M?M.rec:null,[M]);return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold`,children:[(0,Y.jsx)(g,{className:`h-6 w-6`}),` Brain`]}),(0,Y.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:`Git-backed knowledge base for the selected workspace. Notes carry context, facts feed recall, and tasks track work your agents can act on. Edit directly or let agents curate; the index syncs automatically.`})]}),(0,Y.jsxs)(y,{variant:`outline`,size:`sm`,className:`rounded-none`,onClick:()=>v(),children:[(0,Y.jsx)(ne,{className:`mr-1.5 h-3.5 w-3.5`}),` Refresh`]})]}),I&&!p&&(0,Y.jsx)(kt,{}),oe&&(0,Y.jsx)(At,{error:oe}),p&&p.length>0&&(0,Y.jsxs)(G,{className:`overflow-hidden rounded-none`,children:[(0,Y.jsx)(Tt,{clients:u??[],workspaces:p,client:b,workspace:C,source:E,onClient:e=>{x(e),N(null)},onWorkspace:e=>{T(e),N(null)},onSource:e=>D(e)}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-[minmax(320px,420px)_1fr]`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-[60vh] flex-col border-r border-border`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[(0,Y.jsx)(s,{value:O,onValueChange:e=>k(e),children:(0,Y.jsxs)(o,{variant:`line`,children:[(0,Y.jsx)(a,{value:`notes`,children:`Notes`}),(0,Y.jsx)(a,{value:`memory`,children:`Facts`}),(0,Y.jsx)(a,{value:`tasks`,children:`Tasks`})]})}),l&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>(e.delete(`tag`),e),{replace:!0}),className:`flex items-center gap-1 border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground hover:text-foreground`,"aria-label":`Clear tag filter ${l}`,children:[`#`,l,(0,Y.jsx)(w,{className:`h-3 w-3`})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1`,children:V?(0,Y.jsx)(Dt,{}):(0,Y.jsx)(yt,{tasks:L,memories:R,notes:z,activeTab:O,statusFilter:A,selectedId:M&&M.rec.id?M.rec.id:null,onStatusFilter:j,onSelect:ce,onNew:le})}),(0,Y.jsx)(Et,{scope:U?.scope??``})]}),(0,Y.jsx)(`div`,{className:`p-4`,children:de&&M?(0,Y.jsx)(lt,{kind:M.kind,initial:de,onSaved:W,onCancel:()=>N(null)},se??`new`):(0,Y.jsxs)(`div`,{className:`flex h-full min-h-[200px] flex-col items-center justify-center gap-1 text-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(g,{className:`mb-1 h-7 w-7 text-muted-foreground/40`}),(0,Y.jsx)(`span`,{children:`Pick something on the left to read or edit.`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:`Or start a new one with the + button.`})]})})]})]}),p&&p.length===0&&(0,Y.jsx)(jt,{})]})}export{Rt as BrainBrowserPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/BrainStatusPage-IIn0Ufcf.js b/internal/web/dist/assets/BrainStatusPage-IIn0Ufcf.js deleted file mode 100644 index f966aa9..0000000 --- a/internal/web/dist/assets/BrainStatusPage-IIn0Ufcf.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{t as r}from"./cloud-upload-RBqzNp3t.js";import{Bt as i,Cr as a,Fn as o,Ht as s,S as c,Ut as l,Vt as u,Xn as d,br as f,jr as p,lr as m,mr as h,n as g,nr as _,t as v,y,zn as b}from"./index-BDLzoIgt.js";var x=e(t(),1),S=n();function C(){let{data:e,loading:t,error:n,refetch:C}=c((0,x.useCallback)(()=>i(),[])),{data:w,refetch:T}=c((0,x.useCallback)(()=>u(),[])),[E,D]=(0,x.useState)(!1),[O,k]=(0,x.useState)(!1),[A,j]=(0,x.useState)(null);async function M(){D(!0);try{(await s()).conflict?p.error(`Push hit a rebase conflict — resolve in VSCode, commit, then push again.`,{duration:12e3}):p.success(`Brain pushed to origin.`),C()}catch(e){p.error(e instanceof Error?e.message:`Push failed`)}finally{D(!1)}}async function N(){k(!0);try{let e=await l();j(e),e.ok?p.success(`Verified ${e.files_checked} files — no drift.`):p.warning(`Found ${e.drifts.length} drift(s) across ${e.files_checked} files.`),T()}catch(e){p.error(e instanceof Error?e.message:`Verify failed`)}finally{k(!1)}}let P=e?.dir?`vscode://file/${e.dir}`:void 0;return(0,S.jsxs)(`div`,{className:`max-w-4xl space-y-5`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold`,children:[(0,S.jsx)(a,{className:`h-6 w-6`}),` Brain`]}),(0,S.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`The git-backed, Markdown-canonical state repository. Tasks, memories, workspace config and skills live as editable `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`.md`}),` files that the gateway indexes into SQLite. Commits happen automatically on idle; push is manual (deploy-hygiene). Agents use`,` `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`mcplexer__brain_init`}),` /`,` `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`brain_import`}),` /`,` `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`brain_status`}),` for the same flow.`]})]}),t&&!e&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,S.jsx)(_,{className:`h-4 w-4 animate-spin`}),` Loading brain status...`]}),n&&(0,S.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,n]}),e&&!e.enabled&&(0,S.jsx)(v,{children:(0,S.jsxs)(g,{className:`flex flex-col items-center justify-center py-10 text-center`,children:[(0,S.jsx)(a,{className:`mb-2 h-8 w-8 text-muted-foreground/40`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Brain is disabled`}),(0,S.jsxs)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:[`Enable it with `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`MCPLEXER_BRAIN_ENABLED=1`}),` (or settings.brain_enabled), restart the daemon, then run`,` `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`mcplexer__brain_init`}),` +`,` `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`brain_import`}),` from a terminal under`,` `,(0,S.jsx)(`span`,{className:`font-mono text-xs`,children:`~/.mcplexer`}),`.`]})]})}),e&&e.enabled&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(v,{children:(0,S.jsxs)(g,{className:`space-y-3 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(m,{className:`h-4 w-4 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`text-sm font-medium`,children:`Repository`})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(o,{variant:`outline`,size:`sm`,onClick:()=>C(),children:[(0,S.jsx)(d,{className:`mr-1.5 h-3.5 w-3.5`}),` Refresh`]}),P&&(0,S.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,S.jsxs)(`a`,{href:P,children:[(0,S.jsx)(h,{className:`mr-1.5 h-3.5 w-3.5`}),` Open in VSCode`]})})]})]}),(0,S.jsx)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:e.dir}),e.git_error&&(0,S.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`git: `,e.git_error]}),e.git&&(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.git.initialized?(0,S.jsx)(y,{variant:`outline`,tone:`mono`,children:e.git.branch||`detached`}):(0,S.jsx)(y,{variant:`outline`,children:`not initialised`}),e.git.dirty?(0,S.jsx)(y,{variant:`outline`,tone:`warn`,children:`uncommitted changes`}):(0,S.jsx)(y,{variant:`outline`,tone:`success`,children:`clean`}),e.git.has_upstream&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(y,{variant:`outline`,tone:`info`,children:[`↑ `,e.git.ahead,` ahead`]}),(0,S.jsxs)(y,{variant:`outline`,tone:`info`,children:[`↓ `,e.git.behind,` behind`]})]}),!e.git.has_remote&&(0,S.jsx)(y,{variant:`outline`,children:`no remote`})]}),e.git?.last_commit&&(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last commit: `,(0,S.jsx)(`span`,{className:`font-mono`,children:e.git.last_commit})]}),(0,S.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,S.jsxs)(o,{size:`sm`,onClick:M,disabled:E||!e.git?.has_remote,title:e.git?.has_remote?`Pull --rebase --autostash, then push`:`No remote configured`,children:[E?(0,S.jsx)(_,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,S.jsx)(r,{className:`mr-1.5 h-3.5 w-3.5`}),`Push`]}),(0,S.jsxs)(o,{size:`sm`,variant:`outline`,onClick:N,disabled:O,children:[O?(0,S.jsx)(_,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,S.jsx)(d,{className:`mr-1.5 h-3.5 w-3.5`}),`Verify (check drift)`]})]})]})}),A&&(0,S.jsx)(v,{children:(0,S.jsxs)(g,{className:`space-y-2 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[A.ok?(0,S.jsx)(f,{className:`h-4 w-4 text-emerald-500`}):(0,S.jsx)(b,{className:`h-4 w-4 text-amber-500`}),`Verify — `,A.files_checked,` files checked`]}),A.ok?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Index faithfully reflects the files. No drift.`}):(0,S.jsx)(`ul`,{className:`space-y-1 text-xs`,children:A.drifts.map((e,t)=>(0,S.jsxs)(`li`,{className:`font-mono`,children:[(0,S.jsx)(y,{variant:`outline`,className:`mr-1.5`,children:e.kind}),e.path,e.detail?` — ${e.detail}`:``]},t))})]})}),(0,S.jsx)(v,{children:(0,S.jsxs)(g,{className:`space-y-2 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,S.jsx)(b,{className:`h-4 w-4 text-muted-foreground`}),`Validation errors`,e.error_count>0&&(0,S.jsx)(y,{variant:`destructive`,children:e.error_count})]}),!w||w.length===0?(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No files failed validation. A file that fails frontmatter validation is NOT indexed (an index that lies is worse than a missing record).`}):(0,S.jsx)(`ul`,{className:`space-y-1.5`,children:w.map(e=>(0,S.jsxs)(`li`,{className:`rounded border border-destructive/30 bg-destructive/5 p-2 text-xs`,children:[(0,S.jsx)(`span`,{className:`font-mono`,children:e.path}),(0,S.jsxs)(`div`,{className:`mt-0.5 text-muted-foreground`,children:[e.field?`${e.field}: `:``,e.reason]})]},e.id))})]})})]})]})}export{C as BrainStatusPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ConfigPage-BWoHdHHz.js b/internal/web/dist/assets/ConfigPage-BWoHdHHz.js deleted file mode 100644 index 16e6beb..0000000 --- a/internal/web/dist/assets/ConfigPage-BWoHdHHz.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{$t as n,A as r,C as i,Et as a,F as o,G as s,Pt as c,Qt as l,S as u,T as d,Xt as f,a as p,an as m,bt as h,et as g,gt as _,ht as v,in as y,jt as b,l as ee,m as te,n as x,nn as S,on as C,p as w,pt as T,q as E,xt as ne,y as D,yt as O,zt as k}from"./client-CaIRceNv.js";import{t as re}from"./createLucideIcon-WB390fY6.js";import{t as A}from"./chevron-right-CyhRDGe7.js";import{n as ie,t as j}from"./scope-label-D4K1COuM.js";import{t as M}from"./info-C1fwy83I.js";import{t as N}from"./pencil-Dy4EC74G.js";import{t as ae}from"./save-Baaykonc.js";import{An as oe,Bn as P,Br as F,Fn as I,Fr as se,Ft as L,Ir as R,Jn as ce,Kn as le,Ln as z,Lr as ue,Mn as de,Mr as B,Nn as fe,Nr as V,On as pe,Pr as H,Pt as U,Qn as W,S as G,Sr as me,Wn as he,Yn as ge,_r as _e,d as ve,f as K,h as ye,i as be,j as xe,jn as Se,jr as q,kn as Ce,m as we,mr as Te,n as Ee,nr as De,or as Oe,p as ke,pr as Ae,qn as je,r as Me,sr as Ne,t as Pe,tr as Fe,u as Ie,v as Le,xr as Re,y as J,yr as ze}from"./index-BDLzoIgt.js";import{a as Be,i as Y,n as Ve,o as X,r as Z,t as He}from"./table-2N0Q-yAm.js";import{t as Ue}from"./textarea-BiOhexhg.js";var We=re(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),Q=e(t(),1),$=C(),Ge={name:``,priority:100,workspace_id:``,path_glob:`**`,tool_match:[],scope_policy:{},downstream_server_id:``,auth_scope_id:``,policy:`allow`,log_level:`info`,approval_mode:`none`,approval_timeout:300};function Ke(e,t){return e.find(e=>e.id===t)?.tool_namespace===`github`}function qe(e){return Object.values(e).reduce((e,t)=>e+t.length,0)}function Je({open:e,onClose:t,form:n,setForm:r,onSave:i,saving:a,editing:o,workspaces:s,downstreams:c,authScopes:l,saveError:u}){let[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),ee=n.path_glob!==`**`||n.tool_match.length>0,te=qe(n.scope_policy)>0,x=Ke(c,n.downstream_server_id);(0,Q.useEffect)(()=>{e&&(g(``),v(``),b(``),f(n.path_glob!==`**`||n.tool_match.length>0),m(qe(n.scope_policy)>0))},[o,e]);function S(){let e=h.trim();e&&(r(t=>({...t,tool_match:[...t.tool_match,e]})),g(``))}function C(e){r(t=>({...t,tool_match:t.tool_match.filter((t,n)=>n!==e)}))}function w(e,t){let n=t.trim();n&&r(t=>{let r=t.scope_policy[e]??[];return r.includes(n)?t:{...t,scope_policy:{...t.scope_policy,[e]:[...r,n]}}})}function T(e,t){r(n=>{let r=(n.scope_policy[e]??[]).filter((e,n)=>n!==t),i={...n.scope_policy};return r.length===0?delete i[e]:i[e]=r,{...n,scope_policy:i}})}return(0,$.jsx)(pe,{open:e,onOpenChange:()=>t(),children:(0,$.jsxs)(Ce,{children:[(0,$.jsxs)(de,{children:[(0,$.jsx)(fe,{children:o?`Edit Route`:`Add Route`}),(0,$.jsx)(oe,{children:`A route connects a server to a workspace. When an agent's tool call matches, this rule decides which server handles it and what credentials to use.`})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Name (optional)`}),(0,$.jsx)(L,{value:n.name,onChange:e=>r(t=>({...t,name:e.target.value})),placeholder:`e.g. GitHub allow-all`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Workspace`}),(0,$.jsxs)(Ie,{value:n.workspace_id,onValueChange:e=>r(t=>({...t,workspace_id:e})),children:[(0,$.jsx)(ke,{children:(0,$.jsx)(we,{placeholder:`Select workspace...`})}),(0,$.jsx)(ve,{children:s.map(e=>(0,$.jsx)(K,{value:e.id,children:e.name},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground ${n.policy===`deny`?`opacity-50`:``}`,children:`Downstream Server`}),(0,$.jsxs)(Ie,{value:n.downstream_server_id,onValueChange:e=>r(t=>({...t,downstream_server_id:e})),disabled:n.policy===`deny`,children:[(0,$.jsx)(ke,{children:(0,$.jsx)(we,{placeholder:n.policy===`deny`?`N/A for deny rules`:`Select server...`})}),(0,$.jsx)(ve,{children:c.map(e=>(0,$.jsx)(K,{value:e.id,children:e.name},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground ${n.policy===`deny`?`opacity-50`:``}`,children:`Auth Scope`}),(0,$.jsxs)(Ie,{value:n.auth_scope_id||`none`,onValueChange:e=>r(t=>({...t,auth_scope_id:e===`none`?``:e})),disabled:n.policy===`deny`,children:[(0,$.jsx)(ke,{children:(0,$.jsx)(we,{placeholder:n.policy===`deny`?`N/A for deny rules`:`None`})}),(0,$.jsxs)(ve,{children:[(0,$.jsx)(K,{value:`none`,children:`None`}),l.map(e=>(0,$.jsx)(K,{value:e.id,children:(0,$.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{children:j(e)}),j(e)!==e.name&&(0,$.jsx)(`code`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:e.name})]})},e.id))]})]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Policy`}),(0,$.jsxs)(Ie,{value:n.policy,onValueChange:e=>{let t=e;if(t===`deny`){r(e=>({...e,policy:t,downstream_server_id:``,auth_scope_id:``}));return}r(e=>({...e,policy:t}))},children:[(0,$.jsx)(ke,{children:(0,$.jsx)(we,{})}),(0,$.jsxs)(ve,{children:[(0,$.jsx)(K,{value:`allow`,children:`Allow`}),(0,$.jsx)(K,{value:`deny`,children:`Deny`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Priority`}),(0,$.jsx)(L,{type:`number`,value:n.priority,onChange:e=>r(t=>({...t,priority:Number(e.target.value)}))})]})]}),n.policy===`allow`&&(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Approval`}),(0,$.jsxs)(Ie,{value:n.approval_mode,onValueChange:e=>r(t=>({...t,approval_mode:e})),children:[(0,$.jsx)(ke,{className:`w-48`,children:(0,$.jsx)(we,{})}),(0,$.jsxs)(ve,{children:[(0,$.jsx)(K,{value:`none`,children:`None`}),(0,$.jsx)(K,{value:`write`,children:`Write only (destructive)`}),(0,$.jsx)(K,{value:`all`,children:`All tool calls`})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground/60`,children:[n.approval_mode===`none`&&`Tool calls execute without approval.`,n.approval_mode===`write`&&`Read-only tools execute freely; write or destructive tools require approval.`,n.approval_mode===`all`&&`Every tool call requires approval before execution.`]})]}),n.approval_mode!==`none`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Timeout (seconds)`}),(0,$.jsx)(L,{type:`number`,min:10,value:n.approval_timeout,onChange:e=>r(t=>({...t,approval_timeout:Number(e.target.value)})),className:`w-32`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`How long to wait for approval before auto-denying the call.`})]})]}),n.policy===`allow`&&n.downstream_server_id&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>m(e=>!e),children:[p?(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}):(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),`Scope Policy`,!p&&!te&&(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:`unrestricted`}),!p&&te&&(0,$.jsxs)(J,{variant:`secondary`,className:`ml-1 text-[10px] px-1.5 py-0`,children:[qe(n.scope_policy),` constraint`,qe(n.scope_policy)===1?``:`s`]})]}),p&&(0,$.jsx)(`div`,{className:`space-y-4 rounded-md border border-border/50 p-3`,children:x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Allowed Organisations`}),(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:(n.scope_policy.org??[]).map((e,t)=>(0,$.jsxs)(J,{variant:`outline`,className:`gap-1 font-mono text-xs`,children:[e,(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 hover:text-destructive`,onClick:()=>T(`org`,t),children:(0,$.jsx)(z,{className:`h-3 w-3`})})]},`org-${e}-${t}`))}),(0,$.jsx)(L,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(`org`,_),v(``))},className:`font-mono text-sm`,placeholder:`acme-corp (press Enter to add)`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Allowed Repositories`}),(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:(n.scope_policy.repo??[]).map((e,t)=>(0,$.jsxs)(J,{variant:`outline`,className:`gap-1 font-mono text-xs`,children:[e,(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 hover:text-destructive`,onClick:()=>T(`repo`,t),children:(0,$.jsx)(z,{className:`h-3 w-3`})})]},`repo-${e}-${t}`))}),(0,$.jsx)(L,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(`repo`,y),b(``))},className:`font-mono text-sm`,placeholder:`acme-corp/api (press Enter to add)`})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`Leave blank to allow all. When set, tool calls targeting repos or orgs not in these lists will be blocked.`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground/60`,children:[`Scope policy restricts which resources this route can access. Format:`,` `,(0,$.jsx)(`code`,{className:`font-mono`,children:`{"resource_type": ["allowed_value"]}`})]}),(0,$.jsx)(`textarea`,{className:`w-full rounded-md border border-border bg-background p-2 font-mono text-sm`,rows:4,value:JSON.stringify(n.scope_policy,null,2),onChange:e=>{try{let t=JSON.parse(e.target.value);r(e=>({...e,scope_policy:t}))}catch{}},placeholder:`{"channel": ["#engineering"]}`})]})})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>f(e=>!e),children:[d?(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}):(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),`Advanced matching`,!d&&!ee&&(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:`all files, all tools`})]}),d&&(0,$.jsxs)(`div`,{className:`space-y-4 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`File pattern`}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:n.path_glob,onChange:e=>r(t=>({...t,path_glob:e.target.value})),placeholder:`**`}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground/60`,children:[`Restrict this route to specific files. Default `,(0,$.jsx)(`code`,{className:`font-mono`,children:`**`}),` `,`matches everything.`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Tool filter`}),(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:n.tool_match.map((e,t)=>(0,$.jsxs)(J,{variant:`outline`,className:`gap-1 font-mono text-xs`,children:[e,(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 hover:text-destructive`,onClick:()=>C(t),children:(0,$.jsx)(z,{className:`h-3 w-3`})})]},`${e}-${t}`))}),(0,$.jsx)(L,{value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())},className:`font-mono text-sm`,placeholder:`github__* (press Enter to add)`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`Leave blank to match every tool in the workspace.`})]})]})]}),u&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:u}),(0,$.jsxs)(Se,{children:[(0,$.jsx)(I,{variant:`outline`,onClick:t,"data-testid":`route-cancel`,children:`Cancel`}),(0,$.jsx)(I,{onClick:i,"data-testid":`route-save`,disabled:a||!n.workspace_id||n.policy===`allow`&&!n.downstream_server_id,children:a?`Saving...`:`Save`})]})]})})}function Ye({open:e,onClose:t,workspace:n,downstreams:r,enabledDownstreamIds:i,onSuccess:a}){let[o,s]=(0,Q.useState)(new Set),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(100),[h,g]=(0,Q.useState)(`none`),_=r.filter(e=>!e.disabled);function v(e){s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function y(){if(o.size!==0){l(!0);try{let e=Array.from(o).map(e=>{let t=r.find(t=>t.id===e);return{name:`${n.name} → ${t?.name??e}`,priority:f,workspace_id:n.id,path_glob:`**`,tool_match:[],scope_policy:{},downstream_server_id:e,auth_scope_id:``,policy:`allow`,log_level:`info`,approval_mode:h,approval_timeout:300}});await p(e),q.success(`Enabled ${e.length} server${e.length>1?`s`:``}`),s(new Set),a(),t()}catch(e){q.error(e instanceof Error?e.message:`Failed to create routes`)}finally{l(!1)}}}return(0,Q.useEffect)(()=>{e&&(s(new Set),m(100),g(`none`),d(!1))},[e]),(0,$.jsx)(pe,{open:e,onOpenChange:()=>t(),children:(0,$.jsxs)(Ce,{className:`max-w-md`,children:[(0,$.jsx)(de,{children:(0,$.jsxs)(fe,{children:[`Enable Servers for `,n.name]})}),(0,$.jsx)(`div`,{className:`space-y-3 max-h-[50vh] overflow-y-auto pr-1`,children:_.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No downstream servers available.`}):_.map(e=>{let t=i.has(e.id);return(0,$.jsxs)(`label`,{className:`flex items-center gap-3 rounded-md border border-border/50 p-3 cursor-pointer hover:bg-muted/30 transition-colors`,children:[(0,$.jsx)(Le,{checked:t||o.has(e.id),disabled:t,onCheckedChange:()=>v(e.id)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium truncate`,children:e.name}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.tool_namespace})]}),t&&(0,$.jsx)(J,{variant:`outline`,className:`text-xs shrink-0`,children:`already enabled`})]},e.id)})}),(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors`,onClick:()=>d(!u),children:[u?(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}):(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),`Defaults`]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Priority`}),(0,$.jsx)(L,{type:`number`,value:f,onChange:e=>m(Number(e.target.value)),className:`w-32`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Approval`}),(0,$.jsxs)(Ie,{value:h,onValueChange:e=>g(e),children:[(0,$.jsx)(ke,{className:`w-48`,children:(0,$.jsx)(we,{})}),(0,$.jsxs)(ve,{children:[(0,$.jsx)(K,{value:`none`,children:`None`}),(0,$.jsx)(K,{value:`write`,children:`Write only (destructive)`}),(0,$.jsx)(K,{value:`all`,children:`All tool calls`})]})]})]})]}),(0,$.jsxs)(Se,{children:[(0,$.jsx)(I,{variant:`outline`,onClick:t,children:`Cancel`}),(0,$.jsx)(I,{onClick:y,disabled:c||o.size===0,children:c?`Saving...`:`Enable ${o.size} server${o.size===1?``:`s`}`})]})]})})}var Xe=5;function Ze({workspace:e,rules:t,expanded:n,onToggle:r,onEnableServers:i,onAddRule:a,onEditRule:o,onDeleteRule:s,downstreams:c,authScopes:l,highlightRouteId:u,highlightWorkspace:d}){let f=e=>c.find(t=>t.id===e)?.name??e,p=e=>l.find(t=>t.id===e)?.name??e,m=[...new Set(t.map(e=>e.downstream_server_id).filter(Boolean))];return(0,$.jsxs)(Pe,{"data-route-workspace-id":e.id,className:y(`transition-shadow`,d&&`ring-2 ring-amber-400/80 ring-offset-2 ring-offset-background`),children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-muted/30 transition-colors`,onClick:r,children:[n?(0,$.jsx)(Re,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):(0,$.jsx)(A,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-semibold truncate`,children:e.name}),(0,$.jsxs)(J,{variant:`secondary`,className:`text-xs shrink-0`,children:[t.length,` rule`,t.length===1?``:`s`]})]}),!n&&m.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[m.slice(0,Xe).map(e=>(0,$.jsx)(J,{variant:`outline`,className:`text-xs text-green-400 border-green-500/30`,children:f(e)},e)),m.length>Xe&&(0,$.jsxs)(J,{variant:`outline`,className:`text-xs text-muted-foreground`,children:[`+`,m.length-Xe,` more`]})]})]}),(0,$.jsxs)(I,{variant:`outline`,size:`sm`,className:`shrink-0`,onClick:e=>{e.stopPropagation(),i()},children:[(0,$.jsx)(le,{className:`mr-1.5 h-3.5 w-3.5`}),`Enable Servers`]})]}),n&&(0,$.jsx)(Ee,{className:`pt-0 pb-4 px-4`,children:t.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,$.jsx)(le,{className:`mb-2 h-8 w-8 text-muted-foreground/50`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No route rules`}),(0,$.jsx)(`button`,{onClick:i,className:`text-xs text-primary hover:underline`,children:`Click Enable Servers to get started`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(He,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(X,{className:`border-border/50 hover:bg-transparent`,children:[(0,$.jsx)(Y,{className:`hidden sm:table-cell`,children:`Priority`}),(0,$.jsx)(Y,{children:`Name`}),(0,$.jsx)(Y,{className:`hidden md:table-cell`,children:`Path Glob`}),(0,$.jsx)(Y,{className:`hidden lg:table-cell`,children:`Downstream`}),(0,$.jsx)(Y,{className:`hidden lg:table-cell`,children:`Auth Scope`}),(0,$.jsx)(Y,{className:`hidden lg:table-cell`,children:`Approval`}),(0,$.jsx)(Y,{children:`Policy`}),(0,$.jsx)(Y,{className:`w-24`,children:`Actions`})]})}),(0,$.jsx)(Ve,{children:t.map(e=>(0,$.jsxs)(X,{"data-route-id":e.id,className:`border-border/30 hover:bg-muted/30 `+(u===e.id?`ring-2 ring-amber-400/80 ring-offset-2 ring-offset-background`:``),children:[(0,$.jsx)(Z,{className:`hidden sm:table-cell font-mono text-sm text-muted-foreground`,children:e.priority}),(0,$.jsx)(Z,{className:`text-sm`,children:e.name||(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`—`})}),(0,$.jsx)(Z,{className:`hidden md:table-cell`,children:(0,$.jsx)(`div`,{className:`max-w-[14rem] truncate font-mono text-xs text-accent-foreground`,title:e.path_glob,children:e.path_glob})}),(0,$.jsx)(Z,{className:`hidden lg:table-cell`,children:(0,$.jsx)(`div`,{className:`max-w-[14rem] truncate`,title:f(e.downstream_server_id),children:f(e.downstream_server_id)})}),(0,$.jsx)(Z,{className:`hidden lg:table-cell text-muted-foreground`,children:(0,$.jsx)(`div`,{className:`max-w-[14rem] truncate`,title:e.auth_scope_id?p(e.auth_scope_id):void 0,children:e.auth_scope_id?p(e.auth_scope_id):`-`})}),(0,$.jsx)(Z,{className:`hidden lg:table-cell`,children:e.approval_mode===`all`?(0,$.jsxs)(J,{variant:`outline`,className:`gap-1 text-amber-400 border-amber-500/30`,children:[(0,$.jsx)(he,{className:`h-3 w-3`}),`all`]}):e.approval_mode===`write`?(0,$.jsxs)(J,{variant:`outline`,className:`gap-1 text-yellow-500 border-yellow-500/30`,children:[(0,$.jsx)(he,{className:`h-3 w-3`}),`write only`]}):(0,$.jsx)(`span`,{className:`text-muted-foreground/40`,children:`-`})}),(0,$.jsx)(Z,{children:(0,$.jsx)(J,{variant:e.policy===`allow`?`secondary`:`destructive`,children:e.policy})}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Edit route ${e.name||`rule`}`,onClick:()=>o(e),children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Edit`})]}),(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Delete route ${e.name||`rule`}`,onClick:()=>s(e),children:(0,$.jsx)(P,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Delete`})]})]})})]},e.id))})]}),(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsxs)(I,{variant:`ghost`,size:`sm`,onClick:a,children:[(0,$.jsx)(W,{className:`mr-1.5 h-3.5 w-3.5`}),`Add Rule`]})})]})})]})}function Qe(){let{data:e,loading:t,error:r,refetch:s}=G((0,Q.useCallback)(()=>h(),[])),{data:c}=G((0,Q.useCallback)(()=>a(),[])),{data:l}=G((0,Q.useCallback)(()=>_(),[])),{data:u}=G((0,Q.useCallback)(()=>T(),[])),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(Ge),[y,b]=(0,Q.useState)(!1),[ee,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,E]=(0,Q.useState)(null),[ne,D]=(0,Q.useState)(new Set),[O,k]=F(),[re,A]=(0,Q.useState)(null),[ie,j]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=O.get(`route`),n=O.get(`workspace`);if(!t&&!n)return;let r=null,i=null;if(t){if(!e)return;let n=e.find(e=>e.id===t);if(!n)return;r=t,i=n.workspace_id}else if(n){if(!c||!c.some(e=>e.id===n))return;i=n}if(!i)return;D(e=>{if(e.has(i))return e;let t=new Set(e);return t.add(i),t}),A(r),j(i);let a=setTimeout(()=>{let e=r?`[data-route-id="${r}"]`:`[data-route-workspace-id="${i}"]`;document.querySelector(e)?.scrollIntoView({behavior:`smooth`,block:`center`})},50),o=setTimeout(()=>{k(e=>{let t=new URLSearchParams(e);return t.delete(`route`),t.delete(`workspace`),t},{replace:!0})},200),s=setTimeout(()=>{A(null),j(null)},3500);return()=>{clearTimeout(a),clearTimeout(o),clearTimeout(s)}},[O,k,e,c]);let[M,N]=(0,Q.useState)(!1);async function ae(){N(!0);try{await o(`all`),q.success(`Routes reloaded — changes are live for new tool calls`),s()}catch(e){q.error(e instanceof Error?e.message:`Failed to reload routes`)}finally{N(!1)}}let oe=(0,Q.useMemo)(()=>{if(!c||!e)return[];let t=new Map;for(let n of e){let e=t.get(n.workspace_id)??[];e.push(n),t.set(n.workspace_id,e)}let n=c.map(e=>{let n=t.get(e.id)??[];return{workspace:e,rules:n,enabledDownstreamIds:new Set(n.map(e=>e.downstream_server_id).filter(Boolean))}});return n.sort((e,t)=>e.rules.length>0&&t.rules.length===0?-1:e.rules.length===0&&t.rules.length>0?1:e.workspace.name.localeCompare(t.workspace.name)),n},[c,e]);function P(e){D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function se(e){m(null),v({...Ge,workspace_id:e??``}),x(null),f(!0)}function L(e){m(e);let t=Array.isArray(e.tool_match)?e.tool_match:[],n=t.length===1&&t[0]===`*`?[]:t;v({name:e.name||``,priority:e.priority,workspace_id:e.workspace_id,path_glob:e.path_glob||`**`,tool_match:n,scope_policy:e.scope_policy??{},downstream_server_id:e.downstream_server_id,auth_scope_id:e.auth_scope_id,policy:e.policy,log_level:e.log_level,approval_mode:e.approval_mode??`none`,approval_timeout:e.approval_timeout??300}),x(null),f(!0)}async function R(){b(!0),x(null);try{p?await n(p.id,g):await te(g),f(!1),q.success(p?`Route updated`:`Route created`),s()}catch(e){x(e instanceof Error?e.message:`Failed to save route rule`)}finally{b(!1)}}async function le(){if(S)try{await i(S.id),C(null),q.success(`Route deleted`),s()}catch(e){q.error(e instanceof Error?e.message:`Failed to delete route rule`)}}return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Route Rules`}),(0,$.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Each rule says: for this workspace, when a tool matches these patterns, use this server and credential. Rules are evaluated by priority; first match wins.`})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsxs)(I,{variant:`outline`,onClick:ae,disabled:M,"data-testid":`route-reload`,title:`Apply route changes immediately (normally cached until restart)`,children:[(0,$.jsx)(ce,{className:`mr-2 h-4 w-4 ${M?`animate-spin`:``}`}),M?`Reloading…`:`Reload`]})}),t&&!e&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading...`]}),r&&(0,$.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,r]}),oe.length>0&&(0,$.jsx)(`div`,{className:`space-y-3`,children:oe.map(e=>(0,$.jsx)(Ze,{workspace:e.workspace,rules:e.rules,expanded:ne.has(e.workspace.id),onToggle:()=>P(e.workspace.id),onEnableServers:()=>E(e.workspace),onAddRule:()=>se(e.workspace.id),onEditRule:L,onDeleteRule:C,downstreams:l??[],authScopes:u??[],highlightRouteId:re,highlightWorkspace:ie===e.workspace.id},e.workspace.id))}),c&&e&&oe.length===0&&(0,$.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`text-sm`,children:`No route rules configured yet.`}),(0,$.jsx)(`p`,{className:`text-xs mt-1`,children:`Create a workspace, then add a route to connect a server to it.`})]}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(I,{onClick:()=>se(),"data-testid":`route-add`,children:[(0,$.jsx)(W,{className:`mr-2 h-4 w-4`}),`Add Route`]})}),(0,$.jsx)(Je,{open:d,onClose:()=>f(!1),form:g,setForm:v,onSave:R,saving:y,editing:!!p,workspaces:c??[],downstreams:l??[],authScopes:u??[],saveError:ee}),w&&(0,$.jsx)(Ye,{open:!!w,onClose:()=>E(null),workspace:w,downstreams:l??[],enabledDownstreamIds:oe.find(e=>e.workspace.id===w.id)?.enabledDownstreamIds??new Set,onSuccess:s}),(0,$.jsx)(xe,{open:!!S,onOpenChange:e=>!e&&C(null),title:`Delete route rule`,description:`Are you sure you want to delete this route rule?`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:le})]})}var $e=[{value:`env`,label:`Environment Variables`,description:`Inject encrypted values into stdio servers as env vars.`},{value:`header`,label:`HTTP Headers`,description:`Attach encrypted headers like Authorization or X-API-Key.`},{value:`hawk`,label:`Hawk`,description:`Sign HTTP requests with HAWK_ID and HAWK_KEY.`},{value:`oauth2`,label:`OAuth 2.0`,description:`Store a provider and authenticate with an OAuth flow.`}],et=[{value:`bearer`,label:`Authorization Bearer`,description:`The common Authorization: Bearer pattern.`},{value:`apiKey`,label:`API Key Header`,description:`A named header such as X-API-Key: .`},{value:`custom`,label:`Custom Header`,description:`Any header name, with an optional value prefix.`}];function tt(e){return e.trim()?`•`.repeat(Math.max(6,Math.min(e.trim().length,12))):`••••••`}function nt(e,t,n,r){let i=n.trim(),a=e===`bearer`?`Authorization`:t.trim(),o=e===`bearer`?`Bearer `:e===`custom`?r:``,s=i?`${o}${i}`:``,c=i?`${o}${tt(i)}`:``;return{key:a,value:s,preview:a&&c?`${a}: ${c}`:``}}function rt({step:e,title:t,description:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(J,{variant:`outline`,className:`text-[10px] font-mono`,children:[`step `,e]}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:t})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})]})}function it({keys:e,onDelete:t}){return e.length===0?(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border/60 bg-muted/20 px-4 py-3 text-sm text-muted-foreground`,children:`Nothing stored yet.`}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e}),(0,$.jsx)(J,{variant:`outline`,className:`shrink-0 text-[10px] text-emerald-600 border-emerald-500/30`,children:`stored`})]}),(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 hover:bg-destructive/10 hover:text-destructive`,onClick:()=>t(e),children:(0,$.jsx)(P,{className:`h-3 w-3`})})]},e))})}var at={name:``,display_name:``,type:`env`,oauth_provider_id:``,redaction_hints:[]};function ot({open:e,onClose:t,form:n,setForm:r,onSave:i,saving:a,editing:o,editingId:s,envFields:c,providers:l,saveError:u}){let[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)({}),[ee,te]=(0,Q.useState)({}),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),[k,re]=(0,Q.useState)(`bearer`),[j,M]=(0,Q.useState)(`Authorization`),[N,ae]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(`Bearer `),[R,ce]=(0,Q.useState)(!1),le=n.type===`env`||n.type===`client_credentials`||n.type===`hawk`,z=le||n.type===`header`||n.type===`hawk`,ue=o&&le&&c&&c.length>0,B=(0,Q.useMemo)(()=>new Set((c??[]).map(e=>e.key)),[c]),V=(0,Q.useMemo)(()=>g.filter(e=>!B.has(e)),[B,g]),H=(0,Q.useMemo)(()=>nt(k,j,N,P),[k,j,P,N]),W=(0,Q.useCallback)(async()=>{if(!(!s||!z))try{_((await ne(s)).keys)}catch{_([])}},[s,z]);(0,Q.useEffect)(()=>{e&&o&&W()},[e,o,W]),(0,Q.useEffect)(()=>{e&&(p(``),h((n.redaction_hints??[]).length>0),y({}),te({}),S(``),w(``),E(!1),re(`bearer`),M(`Authorization`),ae(``),F(`Bearer `),ce(!1))},[e]),(0,Q.useEffect)(()=>{!e||n.type!==`header`||(re(`bearer`),M(`Authorization`),ae(``),F(`Bearer `),ce(!1))},[e,n.type]);function G(e){if(re(e),e===`bearer`){M(`Authorization`),F(`Bearer `);return}if(e===`apiKey`){F(``),M(e=>{let t=e.trim();return!t||t===`Authorization`?`X-API-Key`:e});return}F(e=>e===`Bearer `?``:e),M(e=>e===`Authorization`?``:e)}async function me(e){let t=v[e];if(!(!s||!t?.trim())){O(!0);try{await b(s,e,t.trim()),q.success(`Saved`),y(t=>({...t,[e]:``})),W()}catch(e){q.error(e instanceof Error?e.message:`Failed to save`)}finally{O(!1)}}}async function he(){if(!s||!c)return;let e=c.filter(e=>v[e.key]?.trim());if(e.length!==0){O(!0);try{for(let t of e)await b(s,t.key,v[t.key].trim());q.success(`Credentials saved`),y({}),W()}catch(e){q.error(e instanceof Error?e.message:`Failed to save`)}finally{O(!1)}}}async function ge(){if(!(!s||!x.trim()||!C.trim())){O(!0);try{await b(s,x.trim(),C.trim()),q.success(`Secret "${x.trim()}" saved`),S(``),w(``),E(!1),W()}catch(e){q.error(e instanceof Error?e.message:`Failed to save secret`)}finally{O(!1)}}}async function _e(){if(!(!s||!H.key||!H.value)){O(!0);try{await b(s,H.key,H.value),q.success(`Header "${H.key}" saved`),ae(``),ce(!1),k===`custom`&&F(``),W()}catch(e){q.error(e instanceof Error?e.message:`Failed to save header`)}finally{O(!1)}}}async function ye(e){if(s)try{await d(s,e),q.success(`Secret "${e}" removed`),W()}catch(e){q.error(e instanceof Error?e.message:`Failed to delete secret`)}}function be(){let e=f.trim();e&&(r(t=>({...t,redaction_hints:t.redaction_hints.includes(e)?t.redaction_hints:[...t.redaction_hints,e]})),p(``))}function xe(e){r(t=>({...t,redaction_hints:(t.redaction_hints??[]).filter((t,n)=>n!==e)}))}let Te=!!n.name.trim()&&(n.type!==`oauth2`||!!n.oauth_provider_id.trim());return(0,$.jsx)(pe,{open:e,onOpenChange:()=>t(),children:(0,$.jsxs)(Ce,{className:`max-w-2xl`,children:[(0,$.jsxs)(de,{children:[(0,$.jsx)(fe,{children:o?`Edit Credential`:`Add Credential`}),(0,$.jsx)(oe,{children:`Define how MCPlexer should authenticate, then manage the encrypted secret material in the same place.`})]}),(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`space-y-4 rounded-md border border-border/50 p-4`,children:[(0,$.jsx)(rt,{step:`1`,title:`Credential definition`,description:`Pick the auth model first. Header and env credentials become usable as soon as you add secret material.`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Display name`}),(0,$.jsx)(L,{value:n.display_name,onChange:e=>r(t=>({...t,display_name:e.target.value})),placeholder:`e.g. ClickUp or Linear`}),(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Shown in the credentials list and route picker. Leave blank to use a tidied version of the slug below.`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(U,{className:`text-xs text-muted-foreground`,children:[`Slug`,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-muted-foreground/70`,children:`stable handle for route + secret wiring`})]}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:n.name,onChange:e=>r(t=>({...t,name:e.target.value})),placeholder:`e.g. github_headers or openai_api_key`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Type`}),(0,$.jsx)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:$e.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`rounded-md border px-3 py-3 text-left transition-colors ${n.type===e.value?`border-primary bg-primary/5`:`border-border/50 hover:border-border hover:bg-muted/40`}`,onClick:()=>r(t=>({...t,type:e.value,oauth_provider_id:e.value===`oauth2`?t.oauth_provider_id:``})),children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.description})]},e.value))})]}),z&&!o&&(0,$.jsx)(`div`,{className:`rounded-md border border-primary/20 bg-primary/5 px-3 py-2 text-sm text-muted-foreground`,children:`Save this credential definition first. The dialog stays open so you can add encrypted secret values immediately after.`}),n.type===`oauth2`&&(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`OAuth Provider`}),(0,$.jsxs)(Ie,{value:n.oauth_provider_id,onValueChange:e=>r(t=>({...t,oauth_provider_id:e})),children:[(0,$.jsx)(ke,{children:(0,$.jsx)(we,{placeholder:`Select a provider...`})}),(0,$.jsx)(ve,{children:l.map(e=>(0,$.jsx)(K,{value:e.id,children:e.name},e.id))})]})]}),!o&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Need a provider first? Use`,` `,(0,$.jsx)(se,{to:`/setup`,className:`text-primary hover:underline`,onClick:t,children:`Quick Setup`}),` `,`for template-based OAuth configuration.`]})]}),(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>h(e=>!e),children:[m?(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}):(0,$.jsx)(A,{className:`h-3.5 w-3.5`}),`Advanced redaction hints`,!m&&(n.redaction_hints??[]).length>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[n.redaction_hints.length,` configured`]})]}),m&&(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add match patterns for sensitive values that should always be redacted in audit logs.`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(n.redaction_hints??[]).map((e,t)=>(0,$.jsxs)(J,{variant:`outline`,className:`cursor-pointer font-mono text-xs hover:bg-destructive/10 hover:text-destructive`,onClick:()=>xe(t),children:[e,` x`]},`${e}-${t}`))}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{className:`font-mono text-sm`,placeholder:`e.g. *token*`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),be())}}),(0,$.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:be,children:`Add`})]})]})]}),z&&(0,$.jsxs)(`section`,{className:`space-y-4 rounded-md border border-border/50 p-4`,children:[(0,$.jsx)(rt,{step:`2`,title:`Secret material`,description:s?`Values are encrypted at rest. After saving, you only see the key names so you can rotate or remove them safely.`:`Save the credential definition first, then add the encrypted secret values here.`}),s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-border/50 bg-muted/30 px-3 py-2`,children:[(0,$.jsxs)(J,{variant:`outline`,className:`font-mono text-xs`,children:[g.length,` stored`]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.type===`header`?`Headers are injected into every request to the downstream HTTP server.`:n.type===`hawk`?`HAWK_ID and HAWK_KEY are used to sign each outbound HTTP request.`:`Values are injected into the downstream process environment.`})]}),le&&ue&&c&&(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`space-y-3`,children:c.map(e=>{let t=g.includes(e.key),n=ee[e.key]??!1;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(U,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(J,{variant:`outline`,className:`font-mono text-[10px]`,children:e.key}),t&&(0,$.jsx)(J,{variant:`outline`,className:`text-[10px] text-emerald-600 border-emerald-500/30`,children:`stored`})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`pr-8 font-mono text-sm`,type:e.secret&&!n?`password`:`text`,value:v[e.key]??``,onChange:t=>y(n=>({...n,[e.key]:t.target.value})),placeholder:t?`Enter a new value to rotate it`:`Enter ${e.label.toLowerCase()}`,onKeyDown:t=>t.key===`Enter`&&me(e.key)}),e.secret&&(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>te(t=>({...t,[e.key]:!n})),children:n?(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]},e.key)})}),(0,$.jsx)(I,{size:`sm`,onClick:he,disabled:D||!c.some(e=>v[e.key]?.trim()),children:D?`Saving...`:`Save Credentials`}),(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:`Additional environment variables`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use this when the built-in fields are not enough.`})]}),V.length>0&&(0,$.jsx)(it,{keys:V,onDelete:ye}),(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Variable name`}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:x,onChange:e=>S(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``)),placeholder:`EXTRA_API_KEY`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Value`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`pr-8 font-mono text-sm`,type:T?`text`:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`sk-...`,onKeyDown:e=>e.key===`Enter`&&ge()}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>E(e=>!e),children:T?(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]})]}),(0,$.jsx)(I,{size:`sm`,variant:`outline`,onClick:ge,disabled:D||!x.trim()||!C.trim(),children:D?`Saving...`:`Add Variable`})]})]}),le&&!ue&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(it,{keys:g,onDelete:ye}),(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:n.type===`hawk`?`Add Hawk credential`:`Add environment variable`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.type===`hawk`?`Store HAWK_ID and HAWK_KEY. HAWK_ALGORITHM is optional and defaults to sha256.`:`Variable names are normalized to uppercase to match common MCP server expectations.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Variable name`}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:x,onChange:e=>S(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``)),placeholder:`API_KEY`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Value`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`pr-8 font-mono text-sm`,type:T?`text`:`password`,value:C,onChange:e=>w(e.target.value),placeholder:`sk-...`,onKeyDown:e=>e.key===`Enter`&&ge()}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>E(e=>!e),children:T?(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]})]}),(0,$.jsx)(I,{size:`sm`,variant:`outline`,onClick:ge,disabled:D||!x.trim()||!C.trim(),children:D?`Saving...`:`Add Variable`})]})]}),n.type===`header`&&(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(it,{keys:g,onDelete:ye}),(0,$.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border/50 p-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:`Add header`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose a common auth pattern or drop down to a custom header when you need full control.`})]}),(0,$.jsx)(`div`,{className:`grid gap-2 md:grid-cols-3`,children:et.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`rounded-md border px-3 py-3 text-left transition-colors ${k===e.value?`border-primary bg-primary/5`:`border-border/50 hover:border-border hover:bg-muted/40`}`,onClick:()=>G(e.value),children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.description})]},e.value))}),k===`bearer`&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Header`}),(0,$.jsx)(L,{value:`Authorization`,disabled:!0,className:`font-mono text-sm`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Bearer token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`pr-8 font-mono text-sm`,type:R?`text`:`password`,value:N,onChange:e=>ae(e.target.value),placeholder:`sk-...`,onKeyDown:e=>e.key===`Enter`&&_e()}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>ce(e=>!e),children:R?(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]})]}),k===`apiKey`&&(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Header name`}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:j,onChange:e=>M(e.target.value),placeholder:`X-API-Key`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Header value`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`pr-8 font-mono text-sm`,type:R?`text`:`password`,value:N,onChange:e=>ae(e.target.value),placeholder:`sk-...`,onKeyDown:e=>e.key===`Enter`&&_e()}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>ce(e=>!e),children:R?(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]})]}),k===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Header name`}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:j,onChange:e=>M(e.target.value),placeholder:`Authorization`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Optional prefix`}),(0,$.jsx)(L,{className:`font-mono text-sm`,value:P,onChange:e=>F(e.target.value),placeholder:`Token `})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(U,{className:`text-[11px] text-muted-foreground`,children:`Header value`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(L,{className:`pr-8 font-mono text-sm`,type:R?`text`:`password`,value:N,onChange:e=>ae(e.target.value),placeholder:`your-secret`,onKeyDown:e=>e.key===`Enter`&&_e()}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>ce(e=>!e),children:R?(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}):(0,$.jsx)(Ae,{className:`h-3.5 w-3.5`})})]})]})]}),(0,$.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/30 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Preview`}),(0,$.jsx)(`code`,{className:`mt-1 block text-xs text-foreground`,children:H.preview||`Header-Name: ••••••`})]}),(0,$.jsx)(I,{size:`sm`,variant:`outline`,onClick:_e,disabled:D||!H.key||!H.value,children:D?`Saving...`:g.includes(H.key)?`Replace Header`:`Add Header`})]})]})]}):(0,$.jsx)(`div`,{className:`rounded-md border border-dashed border-border/60 bg-muted/20 px-4 py-5 text-sm text-muted-foreground`,children:`Save this credential definition first, then come straight back here to add the encrypted secret values.`})]})]}),u&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:u}),(0,$.jsxs)(Se,{children:[(0,$.jsx)(I,{variant:`outline`,onClick:t,children:`Cancel`}),(0,$.jsx)(I,{onClick:i,disabled:a||!Te,children:a?`Saving...`:o?`Save Changes`:`Save Definition`})]})]})})}function st(){let{data:e,loading:t,error:n,refetch:r}=G((0,Q.useCallback)(()=>T(),[])),{data:i}=G((0,Q.useCallback)(()=>O(),[])),[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(at),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(null),[y,b]=F(),[te,x]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=y.get(`credential`);if(!e)return;x(e);let t=setTimeout(()=>{document.querySelector(`[data-credential-id="${e}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})},50),n=setTimeout(()=>{b(e=>{let t=new URLSearchParams(e);return t.delete(`credential`),t},{replace:!0})},200),r=setTimeout(()=>x(null),3500);return()=>{clearTimeout(t),clearTimeout(n),clearTimeout(r)}},[y,b]);function S(){l(null),d(at),g(null),o(!0)}function C(e){l(e),d({name:e.name,display_name:e.display_name??``,type:e.type,oauth_provider_id:e.oauth_provider_id??``,redaction_hints:[...e.redaction_hints??[]]}),g(null),o(!0)}async function w(){m(!0),g(null);try{if(c)await f(c.id,u),o(!1),q.success(`Credential updated`);else{let e=await ee(u);e.type===`env`||e.type===`header`||e.type===`hawk`||e.type===`client_credentials`?(l(e),q.success(`Credential created — add your secrets below`)):(o(!1),q.success(`Credential created`))}r()}catch(e){g(e instanceof Error?e.message:`Failed to save credential`)}finally{m(!1)}}async function E(){if(_)try{await D(_.id),v(null),q.success(`Credential deleted`),r()}catch(e){q.error(e instanceof Error?e.message:`Failed to delete credential`)}}function ne(e){l(null),d({name:`${j(e)}_copy`,display_name:e.display_name?`${e.display_name} (copy)`:``,type:e.type,oauth_provider_id:e.oauth_provider_id??``,redaction_hints:[...e.redaction_hints??[]]}),o(!0)}async function re(e){try{let{authorize_url:t}=await s(e);ye(t)}catch(e){q.error(e instanceof Error?e.message:`Failed to start authentication`)}}async function A(e){try{await k(e),q.success(`Token revoked`),r()}catch(e){q.error(e instanceof Error?e.message:`Failed to revoke token`)}}return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Reusable auth material for downstream servers: environment variables for stdio servers, HTTP headers for remote servers, or OAuth sessions for supported integrations.`}),(0,$.jsxs)(I,{onClick:S,"data-testid":`auth-scope-add`,children:[(0,$.jsx)(W,{className:`mr-2 h-4 w-4`}),`Add Credential`]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground`,"data-testid":`credentials-legend`,children:[(0,$.jsx)(`span`,{className:`font-semibold uppercase tracking-wider`,children:`Status`}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`}),`Connected`,(0,$.jsx)(`span`,{className:`text-muted-foreground/50`,children:`— OAuth session valid`})]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-sky-500`}),`Configured`,(0,$.jsx)(`span`,{className:`text-muted-foreground/50`,children:`— env / header set`})]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500`}),`Needs Setup`,(0,$.jsx)(`span`,{className:`text-muted-foreground/50`,children:`— action required`})]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/50`}),`Not Connected`,(0,$.jsx)(`span`,{className:`text-muted-foreground/50`,children:`— OAuth not authorized`})]})]}),(0,$.jsx)(Pe,{children:(0,$.jsxs)(Ee,{className:`pt-6`,children:[t&&!e&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading...`]}),n&&(0,$.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,n]}),e&&(0,$.jsxs)(He,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(X,{className:`border-border/50 hover:bg-transparent`,children:[(0,$.jsx)(Y,{children:`Name`}),(0,$.jsx)(Y,{children:`Type`}),(0,$.jsx)(Y,{className:`hidden sm:table-cell`,children:`Status`}),(0,$.jsx)(Y,{className:`hidden md:table-cell`,children:`Redaction Hints`}),(0,$.jsx)(Y,{children:`Actions`})]})}),(0,$.jsx)(Ve,{children:e.length===0?(0,$.jsx)(X,{children:(0,$.jsx)(Z,{colSpan:5,className:`h-32`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(Fe,{className:`mb-2 h-8 w-8 text-muted-foreground/50`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No credentials configured`}),(0,$.jsx)(`button`,{onClick:S,className:`text-xs text-primary hover:underline`,children:`Add a credential to get started`})]})})}):e.map(e=>(0,$.jsxs)(X,{"data-credential-id":e.id,className:`border-border/30 hover:bg-muted/30 `+(te===e.id?`ring-2 ring-amber-400/80 ring-offset-2 ring-offset-background`:``),children:[(0,$.jsx)(Z,{className:`font-medium`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{"data-testid":`auth-scope-name-${e.id}`,children:j(e)}),j(e)!==e.name&&(0,$.jsx)(`code`,{className:`font-mono text-[10px] text-muted-foreground/70`,"data-testid":`auth-scope-slug-${e.id}`,children:e.name})]})}),(0,$.jsx)(Z,{children:(0,$.jsx)(J,{variant:`outline`,className:`font-mono text-xs`,children:e.type})}),(0,$.jsx)(Z,{className:`hidden sm:table-cell`,children:e.type===`oauth2`?(0,$.jsx)(ct,{scopeId:e.id}):e.type===`env`||e.type===`header`||e.type===`hawk`||e.type===`client_credentials`?(0,$.jsx)(J,{variant:`outline`,className:`text-xs ${e.has_secrets?`bg-emerald-500/10 text-emerald-600 border-emerald-500/20`:`bg-amber-500/10 text-amber-600 border-amber-500/20`}`,children:e.has_secrets?`Configured`:`Needs Setup`}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`-`})}),(0,$.jsx)(Z,{className:`hidden md:table-cell`,children:(e.redaction_hints??[]).length>0?(0,$.jsx)(`div`,{className:`flex max-w-[12rem] flex-wrap gap-1 overflow-hidden max-h-12`,children:(e.redaction_hints??[]).map(e=>(0,$.jsx)(J,{variant:`secondary`,className:`font-mono text-xs`,children:e},e))}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`-`})}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,"aria-label":`Duplicate ${j(e)}`,"data-testid":`auth-scope-duplicate-${e.id}`,onClick:()=>ne(e),children:(0,$.jsx)(_e,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Duplicate`})]}),(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,"aria-label":`Edit ${j(e)}`,"data-testid":`auth-scope-edit-${e.id}`,onClick:()=>C(e),children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Edit`})]}),(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Delete ${j(e)}`,"data-testid":`auth-scope-delete-${e.id}`,onClick:()=>v(e),children:(0,$.jsx)(P,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Delete`})]}),(e.type===`env`||e.type===`header`||e.type===`hawk`||e.type===`client_credentials`)&&(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 ${e.has_secrets?`text-emerald-600 hover:bg-emerald-500/10`:`text-amber-600 hover:bg-amber-500/10`}`,"aria-label":e.has_secrets?`Manage secrets for ${j(e)}`:`Add secrets for ${j(e)}`,"data-testid":`auth-scope-key-${e.id}`,onClick:()=>C(e),children:(0,$.jsx)(Oe,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:e.has_secrets?`Manage Secret Material`:`Add Secret Material`})]}),e.type===`oauth2`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-primary hover:bg-primary/10`,"aria-label":`Authenticate ${j(e)}`,"data-testid":`auth-scope-authenticate-${e.id}`,onClick:()=>re(e.id),children:(0,$.jsx)(Te,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Authenticate`})]}),(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 hover:bg-amber-500/10 hover:text-amber-600`,"aria-label":`Revoke token for ${j(e)}`,"data-testid":`auth-scope-revoke-${e.id}`,onClick:()=>A(e.id),children:(0,$.jsx)(We,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Revoke Token`})]})]})]})})]},e.id))})]})]})}),(0,$.jsx)(ot,{open:a,onClose:()=>o(!1),form:u,setForm:d,onSave:w,saving:p,editing:!!c,editingId:c?.id,envFields:c?.env_fields,providers:i??[],saveError:h}),(0,$.jsx)(xe,{open:!!_,onOpenChange:e=>!e&&v(null),title:`Delete credential`,description:`Are you sure you want to delete "${_?.name}"?`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:E})]})}function ct({scopeId:e}){let{data:t}=G((0,Q.useCallback)(()=>E(e),[e]));if(!t)return(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`...`});let n={valid:`bg-emerald-500/10 text-emerald-600 border-emerald-500/20`,expired:`bg-yellow-500/10 text-yellow-600 border-yellow-500/20`,refresh_needed:`bg-yellow-500/10 text-yellow-600 border-yellow-500/20`,not_configured:`bg-muted text-muted-foreground border-border`},r=``;switch(t.status){case`valid`:r=t.expires_at?`Connected \u2014 ${m(t.expires_at)} left`:`Connected`;break;case`expired`:r=`Expired`;break;case`refresh_needed`:r=`Needs Refresh`;break;default:r=`Not Connected`}return(0,$.jsx)(J,{variant:`outline`,className:`text-xs ${n[t.status]??n.not_configured}`,children:r})}var lt={name:``,template_id:``,authorize_url:``,token_url:``,client_id:``,client_secret:``,scopes:[],use_pkce:!0};function ut(){let{data:e,loading:t,error:n,refetch:r}=G((0,Q.useCallback)(()=>O(),[])),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(null),[c,d]=(0,Q.useState)(lt),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null);function v(){s(null),d(lt),h(null),a(!0)}function y(e){s(e),d({name:e.name,template_id:e.template_id??``,authorize_url:e.authorize_url,token_url:e.token_url,client_id:e.client_id,client_secret:``,scopes:[...e.scopes??[]],use_pkce:e.use_pkce}),h(null),a(!0)}async function b(){p(!0),h(null);try{if(o){let e={...c};c.client_secret||delete e.client_secret,await l(o.id,e)}else await w(c);a(!1),q.success(o?`Provider updated`:`Provider created`),r()}catch(e){h(e instanceof Error?e.message:`Failed to save OAuth provider`)}finally{p(!1)}}async function ee(){if(g)try{await u(g.id),_(null),q.success(`Provider deleted`),r()}catch(e){q.error(e instanceof Error?e.message:`Failed to delete OAuth provider`)}}return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsxs)(I,{onClick:v,"data-testid":`oauth-provider-add`,children:[(0,$.jsx)(W,{className:`mr-2 h-4 w-4`}),`Add OAuth Provider`]})}),(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-border/60 bg-muted/30 px-4 py-3`,children:[(0,$.jsx)(M,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`OAuth providers are typically managed automatically through`,` `,(0,$.jsx)(se,{to:`/setup`,className:`text-primary hover:underline`,children:`Add a Tool Server`}),`. Edit these only if you need custom OAuth configurations.`]})]}),(0,$.jsx)(Pe,{children:(0,$.jsxs)(Ee,{className:`pt-6`,children:[t&&!e&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading...`]}),n&&(0,$.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,n]}),e&&(0,$.jsxs)(He,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(X,{className:`border-border/50 hover:bg-transparent`,children:[(0,$.jsx)(Y,{children:`Name`}),(0,$.jsx)(Y,{className:`hidden md:table-cell`,children:`Token URL`}),(0,$.jsx)(Y,{className:`hidden sm:table-cell`,children:`Client ID`}),(0,$.jsx)(Y,{className:`hidden sm:table-cell`,children:`PKCE`}),(0,$.jsx)(Y,{className:`w-24`,children:`Actions`})]})}),(0,$.jsx)(Ve,{children:e.length===0?(0,$.jsx)(X,{children:(0,$.jsx)(Z,{colSpan:5,className:`h-32`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(Ne,{className:`mb-2 h-8 w-8 text-muted-foreground/50`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No OAuth providers configured`}),(0,$.jsx)(`button`,{onClick:v,className:`text-xs text-primary hover:underline`,children:`Add an OAuth provider to get started`})]})})}):e.map(e=>(0,$.jsxs)(X,{className:`border-border/30 hover:bg-muted/30`,children:[(0,$.jsx)(Z,{className:`font-medium`,children:e.name}),(0,$.jsx)(Z,{className:`hidden md:table-cell`,children:(0,$.jsx)(`div`,{className:`max-w-[20rem] truncate font-mono text-xs text-muted-foreground`,title:e.token_url,children:e.token_url})}),(0,$.jsx)(Z,{className:`hidden sm:table-cell`,children:(0,$.jsx)(`div`,{className:`max-w-[14rem] truncate font-mono text-xs`,title:e.client_id,children:e.client_id})}),(0,$.jsx)(Z,{className:`hidden sm:table-cell`,children:e.use_pkce?(0,$.jsx)(J,{variant:`outline`,className:`text-xs`,children:`PKCE`}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`-`})}),(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Edit ${e.name}`,"data-testid":`oauth-provider-edit-${e.id}`,onClick:()=>y(e),children:(0,$.jsx)(N,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Edit`})]}),(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Delete ${e.name}`,"data-testid":`oauth-provider-delete-${e.id}`,onClick:()=>_(e),children:(0,$.jsx)(P,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(V,{children:`Delete`})]})]})})]},e.id))})]})]})}),(0,$.jsx)(dt,{open:i,onClose:()=>a(!1),form:c,setForm:d,onSave:b,saving:f,editing:!!o,saveError:m}),(0,$.jsx)(xe,{open:!!g,onOpenChange:e=>!e&&_(null),title:`Delete OAuth provider`,description:`Are you sure you want to delete "${g?.name}"?`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:ee})]})}function dt({open:e,onClose:t,form:n,setForm:i,onSave:a,saving:o,editing:s,saveError:c}){let[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null);async function _(){if(d){m(!0),g(null);try{let e=await r(d);i(t=>({...t,authorize_url:e.authorize_url,token_url:e.token_url,scopes:e.scopes??[],use_pkce:e.use_pkce}))}catch(e){g(e instanceof Error?e.message:`Discovery failed`)}finally{m(!1)}}}function v(){l&&(i(e=>({...e,scopes:[...e.scopes,l]})),u(``))}function y(e){i(t=>({...t,scopes:t.scopes.filter((t,n)=>n!==e)}))}return(0,$.jsx)(pe,{open:e,onOpenChange:()=>t(),children:(0,$.jsxs)(Ce,{children:[(0,$.jsx)(de,{children:(0,$.jsx)(fe,{children:s?`Edit OAuth Provider`:`Add OAuth Provider`})}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[!s&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`OpenID Connect Discovery`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{placeholder:`https://accounts.google.com`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),_())}}),(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{asChild:!0,children:(0,$.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:_,disabled:p||!d,children:p?(0,$.jsx)(De,{className:`h-4 w-4 animate-spin`}):(0,$.jsx)(je,{className:`h-4 w-4`})})}),(0,$.jsx)(V,{children:`Discover endpoints`})]})]}),h&&(0,$.jsx)(`p`,{className:`text-xs text-destructive`,children:h}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`Enter an issuer URL to auto-fill endpoints and scopes`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Name`}),(0,$.jsx)(L,{value:n.name,onChange:e=>i(t=>({...t,name:e.target.value}))})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Authorize URL`}),(0,$.jsx)(L,{value:n.authorize_url,onChange:e=>i(t=>({...t,authorize_url:e.target.value})),placeholder:`https://provider.com/oauth/authorize`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Token URL`}),(0,$.jsx)(L,{value:n.token_url,onChange:e=>i(t=>({...t,token_url:e.target.value})),placeholder:`https://provider.com/oauth/token`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Client ID`}),(0,$.jsx)(L,{value:n.client_id,onChange:e=>i(t=>({...t,client_id:e.target.value}))})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(U,{className:`text-xs text-muted-foreground`,children:[`Client Secret `,s&&`(leave blank to keep existing)`]}),(0,$.jsx)(L,{type:`password`,value:n.client_secret,onChange:e=>i(t=>({...t,client_secret:e.target.value})),placeholder:s?`••••••••`:``})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(U,{className:`text-xs text-muted-foreground`,children:`Scopes`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:n.scopes.map((e,t)=>(0,$.jsxs)(J,{variant:`outline`,className:`cursor-pointer font-mono text-xs hover:bg-destructive/10 hover:text-destructive`,onClick:()=>y(t),children:[e,` x`]},t))}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(L,{className:`font-mono text-sm`,placeholder:`e.g. read:user`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),v())}}),(0,$.jsx)(I,{type:`button`,variant:`outline`,size:`sm`,onClick:v,children:`Add`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`use_pkce`,checked:n.use_pkce,onChange:e=>i(t=>({...t,use_pkce:e.target.checked})),className:`h-4 w-4 rounded border-border`}),(0,$.jsx)(U,{htmlFor:`use_pkce`,className:`text-sm`,children:`Use PKCE (Proof Key for Code Exchange)`})]})]}),c&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,children:c}),(0,$.jsxs)(Se,{children:[(0,$.jsx)(I,{variant:`outline`,onClick:t,"data-testid":`oauth-provider-cancel`,children:`Cancel`}),(0,$.jsx)(I,{onClick:a,disabled:o||!n.name||!n.authorize_url||!n.token_url||!n.client_id,"data-testid":`oauth-provider-save`,children:o?`Saving...`:`Save`})]})]})})}function ft(){let{data:e,loading:t,refetch:n}=G((0,Q.useCallback)(()=>g(),[])),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(i({...e.settings,tool_description_overrides:e.settings.tool_description_overrides??{}}),c(!1))},[e]);function l(e,t){i(n=>{if(!n)return n;let r={...n.tool_description_overrides};return t===``?delete r[e]:r[e]=t,{...n,tool_description_overrides:r}}),c(!0)}function u(e){l(e,``)}async function d(){if(r){o(!0);try{await S(r),c(!1),q.success(`Description overrides saved`),n()}catch(e){let t=e instanceof Error?e.message:`Failed to save`;q.error(t)}finally{o(!1)}}}if(t||!r||!e)return(0,$.jsx)(Pe,{children:(0,$.jsx)(Ee,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(De,{className:`h-5 w-5 animate-spin text-muted-foreground`})})});let f=e.builtin_tool_defaults,p=Object.keys(f).sort();return(0,$.jsxs)(Pe,{children:[(0,$.jsxs)(Me,{className:`flex flex-row items-center justify-between`,children:[(0,$.jsx)(be,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Built-in Tool Description Overrides`}),(0,$.jsxs)(I,{size:`sm`,onClick:d,disabled:a||!s,"data-testid":`builtin-overrides-save`,children:[a?(0,$.jsx)(De,{className:`mr-2 h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(ae,{className:`mr-2 h-3.5 w-3.5`}),`Save`]})]}),(0,$.jsxs)(Ee,{className:`space-y-5`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Override the descriptions shown to MCP clients for each built-in mcpx / mesh tool. Clear a field to reset to the default. These travel with your config so changes are stable across restarts.`}),p.map(e=>{let t=f[e],n=r.tool_description_overrides?.[e]??``,i=n!==``&&n!==t;return(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{className:`font-mono text-xs`,children:e}),i&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e),"aria-label":`Reset ${e} to default`,"data-testid":`builtin-overrides-reset-${e}`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,title:`Reset to default`,children:[(0,$.jsx)(ge,{className:`h-3 w-3`}),`Reset`]})]}),(0,$.jsx)(Ue,{value:n||t,onChange:t=>l(e,t.target.value),className:`min-h-[60px] font-mono text-xs ${i?`border-primary/40 bg-primary/5`:``}`,rows:2})]},e)})]})]})}function pt(e){return new Date(e).toLocaleString()}function mt(e){switch(e){case`active`:return(0,$.jsx)(J,{className:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`,children:`active`});case`pending`:return(0,$.jsxs)(J,{variant:`secondary`,children:[(0,$.jsx)(ze,{className:`h-3 w-3 mr-1`}),`pending`]});case`rejected`:return(0,$.jsx)(J,{variant:`destructive`,children:`rejected`});case`superseded`:return(0,$.jsx)(J,{variant:`outline`,className:`text-muted-foreground`,children:`superseded`});default:return(0,$.jsx)(J,{variant:`outline`,children:e})}}function ht(e){switch(e){case`model`:return(0,$.jsx)(J,{variant:`outline`,className:`text-blue-400 border-blue-500/30`,children:`model`});case`manual`:return(0,$.jsx)(J,{variant:`outline`,className:`text-amber-400 border-amber-500/30`,children:`manual`});case`original`:return(0,$.jsx)(J,{variant:`outline`,className:`text-muted-foreground`,children:`original`});default:return(0,$.jsx)(J,{variant:`outline`,children:e})}}function gt({version:e,onResolved:t}){let[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!1);async function o(){a(!0);try{await x(e.id,n),q.success(`Accepted description for ${e.tool_name}`),t()}catch(e){q.error(e instanceof Error?e.message:`Failed to accept`)}finally{a(!1)}}async function s(){if(!n.trim()){q.error(`A review note is required when rejecting`);return}a(!0);try{await c(e.id,n),q.success(`Rejected suggestion for ${e.tool_name}`),t()}catch(e){q.error(e instanceof Error?e.message:`Failed to reject`)}finally{a(!1)}}return(0,$.jsx)(Pe,{className:`border-primary/30`,children:(0,$.jsxs)(Ee,{className:`pt-5 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,$.jsx)(`div`,{className:`font-mono text-sm text-accent-foreground break-all`,children:e.tool_name}),(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Suggested by `,e.model||`unknown model`,` `,`·`,` `,pt(e.created_at)]})]}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:ht(e.source)})]}),(0,$.jsxs)(`div`,{className:`rounded-md bg-muted/50 p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Proposed Description`}),(0,$.jsx)(`div`,{className:`text-sm whitespace-pre-wrap`,children:e.description})]}),e.rationale&&(0,$.jsxs)(`div`,{className:`rounded-md bg-blue-500/5 border border-blue-500/20 p-3`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-blue-400 mb-1`,children:`Rationale`}),(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.rationale})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,$.jsx)(L,{placeholder:`Review note (required for rejection)`,value:n,onChange:e=>r(e.target.value),className:`flex-1 h-8 text-sm`,"data-testid":`description-review-note-${e.id}`,"aria-label":`Review note`}),(0,$.jsxs)(I,{size:`sm`,onClick:o,disabled:i,className:`gap-1.5`,"data-testid":`description-accept-${e.id}`,children:[(0,$.jsx)(me,{className:`h-3.5 w-3.5`}),` Accept`]}),(0,$.jsxs)(I,{size:`sm`,variant:`destructive`,onClick:s,disabled:i,className:`gap-1.5`,"data-testid":`description-reject-${e.id}`,children:[(0,$.jsx)(z,{className:`h-3.5 w-3.5`}),` Reject`]})]})]})})}function _t({versions:e,onRollback:t}){let[n,r]=(0,Q.useState)(null);async function i(e){r(e);try{await x(e,`Rolled back from dashboard`),q.success(`Rolled back successfully`),t()}catch(e){q.error(e instanceof Error?e.message:`Failed to rollback`)}finally{r(null)}}return(0,$.jsxs)(He,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(X,{children:[(0,$.jsx)(Y,{children:`Tool`}),(0,$.jsx)(Y,{children:`Source`}),(0,$.jsx)(Y,{children:`Status`}),(0,$.jsx)(Y,{children:`Model`}),(0,$.jsx)(Y,{children:`Date`}),(0,$.jsx)(Y,{className:`w-10`})]})}),(0,$.jsxs)(Ve,{children:[e.map(e=>(0,$.jsxs)(X,{children:[(0,$.jsx)(Z,{className:`font-mono text-xs`,children:e.tool_name}),(0,$.jsx)(Z,{children:ht(e.source)}),(0,$.jsx)(Z,{children:mt(e.status)}),(0,$.jsx)(Z,{className:`text-xs text-muted-foreground`,children:e.model||`-`}),(0,$.jsx)(Z,{className:`text-xs text-muted-foreground`,children:pt(e.created_at)}),(0,$.jsx)(Z,{children:(e.status===`superseded`||e.status===`rejected`)&&(0,$.jsxs)(I,{size:`sm`,variant:`ghost`,className:`h-7 gap-1 text-xs`,disabled:n===e.id,"data-testid":`description-restore-${e.id}`,"aria-label":`Restore description for ${e.tool_name}`,onClick:()=>i(e.id),children:[(0,$.jsx)(ge,{className:`h-3 w-3`}),` Restore`]})})]},e.id)),e.length===0&&(0,$.jsx)(X,{children:(0,$.jsx)(Z,{colSpan:6,className:`text-center text-muted-foreground py-8`,children:`No description versions yet`})})]})]})}var vt=[``,`active`,`pending`,`superseded`,`rejected`];function yt(){let[e,t]=F(),[n,r]=(0,Q.useState)(()=>{let t=e.get(`status`)??``;return vt.includes(t)?t:``});(0,Q.useEffect)(()=>{let r=new URLSearchParams(e);n?r.set(`status`,n):r.delete(`status`),r.toString()!==e.toString()&&t(r,{replace:!0})},[n,e,t]);let i=(0,Q.useCallback)(()=>v({status:`pending`,limit:50}),[]),a=(0,Q.useCallback)(()=>v({status:n||void 0,limit:100}),[n]),{data:o,refetch:s}=G(i),{data:c,refetch:l}=G(a),u=o?.data??[],d=c?.data??[];function f(){s(),l()}return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Review AI-suggested description improvements and override the descriptions shown to MCP clients for built-in tools.`}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h2`,{className:`text-sm font-medium text-muted-foreground`,children:[`Pending Review (`,u.length,`)`]}),u.map(e=>(0,$.jsx)(gt,{version:e,onResolved:f},e.id))]}),(0,$.jsxs)(Pe,{children:[(0,$.jsx)(Me,{className:`pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(be,{className:`text-base`,children:`Version History`}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:[``,`active`,`pending`,`superseded`,`rejected`].map(e=>(0,$.jsx)(I,{size:`sm`,variant:n===e?`default`:`outline`,className:`h-7 text-xs`,"data-testid":`description-filter-${e||`all`}`,onClick:()=>r(e),children:e||`All`},e))})]})}),(0,$.jsx)(Ee,{className:`pt-0`,children:(0,$.jsx)(_t,{versions:d,onRollback:f})})]}),(0,$.jsx)(ft,{})]})}var bt={servers:`/workspaces`,routes:`/workspaces`,workspaces:`/workspaces/manage`,credentials:`/advanced/credentials`,oauth:`/advanced/oauth-providers`,descriptions:`/advanced/descriptions`};function xt(e,t){let n=e===`routes`&&t.has(`route`)?`/advanced/routes`:bt[e];if(!n)return null;let r=new URLSearchParams(t);if(r.delete(`tab`),r.delete(`sub`),e===`servers`){let e=r.get(`server`);e&&!r.has(`focus_server`)&&r.set(`focus_server`,e),r.delete(`server`)}let i=r.toString();return i?`${n}?${i}`:n}var St=[{id:`credentials`,label:`Credentials`},{id:`oauth-providers`,label:`OAuth Providers`},{id:`routes`,label:`Routes`},{id:`descriptions`,label:`Descriptions`}],Ct=`credentials`;function wt(e){let t=e.split(`/`).filter(Boolean).pop()??``,n=St.find(e=>e.id===t);return n?n.id:Ct}function Tt(){let[e]=F(),t=e.get(`tab`),n=ue(),r=t?xt(t,e):null;return r?(0,$.jsx)(R,{to:r,replace:!0}):(0,$.jsx)(Et,{tab:wt(n.pathname)})}function Et({tab:e}){let t=(0,Q.useCallback)(e=>`/advanced/${e}`,[]);return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsx)(`div`,{className:`flex items-end justify-between border-b border-border`,children:(0,$.jsx)(`nav`,{role:`tablist`,"aria-label":`Advanced configuration sections`,className:`flex flex-nowrap items-center gap-x-1 overflow-x-auto pb-1`,children:St.map(n=>{let r=n.id===e;return(0,$.jsxs)(se,{to:t(n.id),role:`tab`,"aria-selected":r,"data-testid":`config-tab-${n.id}`,className:y(`relative -mb-px px-3 py-2 text-[13px] font-medium tracking-wide transition-colors`,r?`text-foreground`:`text-muted-foreground hover:text-foreground`),children:[n.label,(0,$.jsx)(`span`,{"aria-hidden":!0,className:y(`pointer-events-none absolute inset-x-2 bottom-0 h-[2px] transition-colors`,r?`bg-primary`:`bg-transparent`)})]},n.id)})})}),(0,$.jsxs)(`div`,{children:[e===`credentials`&&(0,$.jsx)(st,{}),e===`oauth-providers`&&(0,$.jsx)(ut,{}),e===`routes`&&(0,$.jsx)(Qe,{}),e===`descriptions`&&(0,$.jsx)(yt,{})]})]})}export{Tt as ConfigPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ConnectionsPage-BWNiOJ8h.js b/internal/web/dist/assets/ConnectionsPage-BWNiOJ8h.js deleted file mode 100644 index 65b5225..0000000 --- a/internal/web/dist/assets/ConnectionsPage-BWNiOJ8h.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{$t as n,C as r,Et as i,G as a,bt as o,gt as s,jt as c,l,m as u,on as d,pt as f,yt as p}from"./client-CaIRceNv.js";import{t as m}from"./createLucideIcon-WB390fY6.js";import{n as h,t as g}from"./scope-label-D4K1COuM.js";import{t as _}from"./network-CrANvqlb.js";import{t as v}from"./route-CMSYmLBM.js";import{$n as y,Bn as b,Br as x,C as S,D as C,E as w,Fn as T,Fr as E,Ft as D,Mr as O,Nr as k,Pr as A,Pt as j,Qn as M,S as N,T as P,Un as F,ar as I,br as L,d as R,f as z,h as B,jr as V,m as H,mr as ee,nr as U,p as W,pr as G,qn as te,sr as ne,u as K,w as q,y as J,zn as re}from"./index-BDLzoIgt.js";var ie=m(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Y=e(t(),1);function ae(e,t){return t&&t.transport===`http`?e.filter(e=>e.type!==`env`):e}function oe(e){if(!e)return`Configure the route between this server and workspace.`;switch(e.kind){case`connected`:return`Route is live. Pick a different credential or remove it below.`;case`needs-auth`:return`Route exists but the credential needs setup.`;case`add`:return`No route yet. Pick a credential (or none) and click Connect.`;case`disabled`:return`Route is set to deny. Save to switch to allow, or remove it.`}}var X=d();function se(e){return e&&e.transport===`http`?`header`:`env`}function ce(e,t){return`${e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_|_$/g,``)}_${t}`}function le(e){return{key:`Authorization`,value:e.trim()?`Bearer ${e.trim()}`:``}}function ue({envKey:e,setEnvKey:t,envValue:n,setEnvValue:r,showValue:i,setShowValue:a}){return(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Variable name`}),(0,X.jsx)(D,{className:`font-mono text-sm`,value:e,onChange:e=>t(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,``)),placeholder:`API_KEY`,autoComplete:`off`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Value`}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(D,{className:`pr-8 font-mono text-sm`,type:i?`text`:`password`,value:n,onChange:e=>r(e.target.value),placeholder:`sk-...`,autoComplete:`off`}),(0,X.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":i?`Hide secret value`:`Show secret value`,onClick:()=>a(!i),children:i?(0,X.jsx)(h,{className:`h-3.5 w-3.5`}):(0,X.jsx)(G,{className:`h-3.5 w-3.5`})})]})]})]})}function de({token:e,setToken:t,showToken:n,setShowToken:r}){return(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Bearer token / API key`}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(D,{className:`pr-8 font-mono text-sm`,type:n?`text`:`password`,value:e,onChange:e=>t(e.target.value),placeholder:`sk-...`,autoComplete:`off`}),(0,X.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>r(!n),children:n?(0,X.jsx)(h,{className:`h-3.5 w-3.5`}):(0,X.jsx)(G,{className:`h-3.5 w-3.5`})})]}),(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Stored as`,` `,(0,X.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono`,children:`Authorization: Bearer `})]})]})}function fe({server:e,providers:t,onCreated:n,onCancel:r,triggerLabel:i=`+ Create new credential`}){let[a,o]=(0,Y.useState)(!1),[s,u]=(0,Y.useState)(!1),d=(0,Y.useMemo)(()=>se(e),[e]),f=(0,Y.useMemo)(()=>e?ce(e.name,d):`new_${d}_credential`,[e,d]),[p,m]=(0,Y.useState)(f),h=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let t=e?.id??null;t!==h.current&&(h.current=t,m(e?ce(e.name,d):`new_${d}_credential`))},[e,d]);let[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(``),[w,E]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(``),A=(0,Y.useMemo)(()=>p.trim()?d===`env`?!!g.trim()&&!!v.trim():d===`header`?!!S.trim():d===`oauth2`?!!O.trim():!1:!1,[d,p,g,v,S,O]);function M(){a?(r(),o(!1)):(_(``),y(``),x(!1),C(``),E(!1),k(``),m(f),o(!0))}let N=(0,Y.useCallback)(async()=>{if(!(!A||s)){u(!0);try{let e=await l({name:p.trim(),display_name:``,type:d,oauth_provider_id:d===`oauth2`?O:``,redaction_hints:[]});if(d===`env`)await c(e.id,g.trim(),v.trim());else if(d===`header`){let{key:t,value:n}=le(S);await c(e.id,t,n)}V.success(`Credential "${e.name}" created`),o(!1),n(e)}catch(e){V.error(e instanceof Error?e.message:`Failed to create credential`)}finally{u(!1)}}},[A,s,p,d,O,g,v,S,n]);return a?(0,X.jsxs)(`div`,{className:`mt-2 space-y-4 rounded-md border border-border/60 bg-muted/10 px-4 py-4`,"data-testid":`inline-credential-create-form`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:`New credential`}),(0,X.jsx)(J,{variant:`outline`,className:`font-mono text-[10px]`,children:d})]}),(0,X.jsx)(`button`,{type:`button`,onClick:M,className:`text-xs text-muted-foreground hover:text-foreground`,children:`Cancel`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Slug`}),(0,X.jsx)(D,{className:`font-mono text-sm`,value:p,onChange:e=>m(e.target.value),placeholder:`e.g. github_headers`,autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Stable identifier used in route wiring.`})]}),d===`env`&&(0,X.jsx)(ue,{envKey:g,setEnvKey:_,envValue:v,setEnvValue:y,showValue:b,setShowValue:x}),d===`header`&&(0,X.jsx)(de,{token:S,setToken:C,showToken:w,setShowToken:E}),d===`oauth2`&&(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`OAuth provider`}),t.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth providers configured. Set one up via Quick Setup first.`}):(0,X.jsxs)(K,{value:O,onValueChange:k,children:[(0,X.jsx)(W,{"data-testid":`inline-credential-oauth-provider`,children:(0,X.jsx)(H,{placeholder:`Select a provider...`})}),(0,X.jsx)(R,{children:t.map(e=>(0,X.jsx)(z,{value:e.id,children:e.name},e.id))})]}),(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`After creating, use the Authenticate button to complete the OAuth flow.`})]}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(T,{variant:`ghost`,size:`sm`,onClick:M,disabled:s,children:`Cancel`}),(0,X.jsx)(T,{size:`sm`,onClick:N,disabled:!A||s,"data-testid":`inline-credential-create-save`,children:s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}),`Creating...`]}):`Create credential`})]})]}):(0,X.jsx)(`button`,{type:`button`,onClick:M,className:`inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`inline-credential-create-trigger`,children:i})}var Z=`__none__`;function pe({open:e,server:t,workspace:i,state:o,route:s,scopes:c,onClose:l,onChanged:d}){let[f,m]=(0,Y.useState)(Z),[h,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(!1),[x,E]=(0,Y.useState)([]);(0,Y.useEffect)(()=>{e&&p().then(E).catch(()=>E([]))},[e]),(0,Y.useEffect)(()=>{e&&m(s?.auth_scope_id?s.auth_scope_id:Z)},[e,s?.auth_scope_id,t?.id,i?.id]);let D=(0,Y.useMemo)(()=>ae(c,t),[c,t]),O=(0,Y.useMemo)(()=>c.find(e=>e.id===f)??null,[c,f]),k=(0,Y.useCallback)(async()=>{if(!(!t||!i)){_(!0);try{s?(await n(s.id,{auth_scope_id:f===Z?``:f}),V.success(`Route updated`)):(await u({name:`${i.name} → ${t.name}`,priority:100,workspace_id:i.id,path_glob:`**`,tool_match:[`${t.tool_namespace}__*`],scope_policy:{},downstream_server_id:t.id,auth_scope_id:f===Z?``:f,policy:`allow`,log_level:`info`,approval_mode:`write`,approval_timeout:0}),V.success(`Connected ${t.name} → ${i.name}`)),d(),l()}catch(e){V.error(e instanceof Error?e.message:`Failed to save route`)}finally{_(!1)}}},[t,i,s,f,d,l]),A=(0,Y.useCallback)(async()=>{if(s){y(!0);try{await r(s.id),V.success(`Route removed`),d(),l()}catch(e){V.error(e instanceof Error?e.message:`Failed to remove route`)}finally{y(!1)}}},[s,d,l]),M=(0,Y.useCallback)(async()=>{if(!(!O||O.type!==`oauth2`))try{let{authorize_url:e}=await a(O.id);B(e)}catch(e){V.error(e instanceof Error?e.message:`Failed to start auth`)}},[O]),N=(0,Y.useCallback)(()=>{O&&(window.location.href=`/advanced/credentials?credential=${O.id}`)},[O]),F=(0,Y.useCallback)(e=>{m(e.id),d()},[d]),I=t&&i?`${t.name} → ${i.name}`:`Connection`,L=oe(o);return(0,X.jsx)(S,{open:e,onOpenChange:e=>!e&&l(),children:(0,X.jsxs)(q,{className:`w-full max-w-md sm:max-w-lg`,children:[(0,X.jsxs)(w,{children:[(0,X.jsx)(C,{children:I}),(0,X.jsx)(P,{children:L})]}),(0,X.jsxs)(`div`,{className:`mt-6 space-y-5 px-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Server`}),(0,X.jsx)(J,{variant:`outline`,className:`font-mono text-xs`,children:t?.name??`—`})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Workspace`}),(0,X.jsx)(J,{variant:`outline`,className:`font-mono text-xs`,children:i?.name??`—`})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(j,{className:`text-xs text-muted-foreground`,children:`Credential`}),(0,X.jsxs)(K,{value:f,onValueChange:m,children:[(0,X.jsx)(W,{"data-testid":`connection-drawer-scope`,children:(0,X.jsx)(H,{placeholder:`Pick credentials...`})}),(0,X.jsxs)(R,{children:[(0,X.jsx)(z,{value:Z,children:`None (no auth required)`}),D.map(e=>(0,X.jsx)(z,{value:e.id,children:g(e)},e.id))]})]}),(0,X.jsx)(fe,{server:t,providers:x,onCreated:F,onCancel:()=>{}})]}),O&&O.type===`oauth2`&&(0,X.jsx)(`div`,{className:`rounded-md border border-border/40 bg-muted/20 px-3 py-2.5 text-sm`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`OAuth session`}),(0,X.jsxs)(T,{variant:`outline`,size:`sm`,onClick:M,"data-testid":`connection-drawer-authenticate`,children:[(0,X.jsx)(ee,{className:`mr-1.5 h-3 w-3`}),`Authenticate`]})]})}),O&&(O.type===`env`||O.type===`header`||O.type===`hawk`||O.type===`client_credentials`)&&!O.has_secrets&&(0,X.jsx)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 px-3 py-2.5 text-sm`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`text-amber-700`,children:`No secrets stored yet`}),(0,X.jsx)(T,{variant:`outline`,size:`sm`,onClick:N,"data-testid":`connection-drawer-add-secrets`,children:`Add secrets`})]})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2`,children:[(0,X.jsx)(`div`,{children:s&&(0,X.jsxs)(T,{variant:`ghost`,size:`sm`,className:`text-destructive hover:bg-destructive/10`,onClick:A,disabled:v,"data-testid":`connection-drawer-delete`,children:[(0,X.jsx)(b,{className:`mr-1.5 h-3 w-3`}),v?`Removing...`:`Remove route`]})}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(T,{variant:`ghost`,onClick:l,disabled:h,children:`Cancel`}),(0,X.jsx)(T,{onClick:k,disabled:h||!t||!i,"data-testid":`connection-drawer-save`,children:h?`Saving...`:s?`Save changes`:`Connect`})]})]})]})]})})}function Q(e,t){return`${e}::${t}`}function me(e){let t=new Map;for(let n of e)t.set(Q(n.downstream_server_id,n.workspace_id),n);return t}function he(e,t){let n=new Map(t.map(e=>[e.id,e])),r=new Map;for(let[t,i]of e){if(i.policy===`deny`){r.set(t,{kind:`disabled`,routeId:i.id});continue}if(!i.auth_scope_id){r.set(t,{kind:`connected`,routeId:i.id});continue}let e=n.get(i.auth_scope_id);if(!e){r.set(t,{kind:`needs-auth`,hint:`scope deleted`,routeId:i.id});continue}if(Te(e)){r.set(t,{kind:`needs-auth`,hint:`no secrets`,routeId:i.id});continue}r.set(t,{kind:`connected`,routeId:i.id})}return r}function ge(e,t,n,r){return e.map(e=>{let i=0,a=0,o=0,s=0;for(let c of t){let t=Q(c.id,e.id),l=r.get(t)??{kind:`add`};n.has(t)?l.kind===`connected`?i+=1:l.kind===`needs-auth`?a+=1:l.kind===`disabled`&&(o+=1):s+=1}return{workspace:e,connected:i,needsAuth:a,disabled:o,available:s}})}function _e(e,t,n,r,i){let a=new Map(i.map(e=>[e.id,e]));return t.map(t=>{let i=Q(t.id,e.id),o=n.get(i)??null,s=o?.auth_scope_id?a.get(o.auth_scope_id)??null:null;return{server:t,workspace:e,route:o,scope:s,state:r.get(i)??{kind:`add`},searchText:[t.name,t.tool_namespace,t.transport,o?.name,o?.path_glob,o?.tool_match.join(` `),s?.display_name,s?.name,s?.type].filter(Boolean).join(` `).toLowerCase()}}).sort(xe)}function ve(e,t,n){let r=n.trim().toLowerCase();return e.filter(e=>t===`connected`&&e.state.kind!==`connected`||t===`needs-auth`&&e.state.kind!==`needs-auth`||t===`available`&&e.route?!1:r?e.searchText.includes(r):!0)}function ye(e){return e.reduce((e,t)=>(e.all+=1,t.route?t.state.kind===`connected`?e.connected+=1:t.state.kind===`needs-auth`&&(e.needsAuth+=1):e.available+=1,e),{all:0,connected:0,needsAuth:0,available:0})}function be(e,t,n,r,i,a){if(!e)return null;let o=Se(e,n);if(!o)return null;let s=r.find(e=>e.id===t||e.name===t)??Ce(o.id,r,i);if(!s)return null;let c=Q(o.id,s.id);return{server:o,workspace:s,state:a.get(c)??{kind:`add`},route:i.get(c)??null}}function xe(e,t){let n=we(e)-we(t);return n===0?e.server.name.localeCompare(t.server.name):n}function Se(e,t){return t.find(t=>t.id===e)??t.find(t=>t.name===e)??null}function Ce(e,t,n){for(let r of t)if(n.has(Q(e,r.id)))return r;return null}function we(e){return e.state.kind===`needs-auth`?0:e.state.kind===`connected`?1:e.state.kind===`disabled`?2:3}function Te(e){return(e.type===`env`||e.type===`header`||e.type===`hawk`||e.type===`client_credentials`)&&!e.has_secrets}function Ee({summaries:e,selectedWorkspaceId:t,onSelect:n}){return(0,X.jsxs)(`aside`,{className:`min-w-0 rounded-md border border-border/50 bg-card/30`,children:[(0,X.jsx)(`div`,{className:`border-b border-border/50 px-3 py-2`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,X.jsx)(I,{className:`h-4 w-4 text-muted-foreground`}),`Workspaces`]})}),(0,X.jsx)(`div`,{className:`max-h-[70vh] overflow-auto p-1.5`,children:e.map(e=>{let r=e.workspace.id===t;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e.workspace.id),"aria-pressed":r,className:`mb-1 w-full min-w-0 rounded-md border px-3 py-2 text-left transition-colors last:mb-0 `+(r?`border-primary/50 bg-primary/10 text-foreground`:`border-transparent text-muted-foreground hover:border-border/60 hover:bg-muted/30 hover:text-foreground`),"data-testid":`connections-workspace-${e.workspace.id}`,children:[(0,X.jsxs)(O,{children:[(0,X.jsx)(A,{asChild:!0,children:(0,X.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.workspace.name})}),(0,X.jsx)(k,{side:`right`,className:`max-w-xs font-mono text-xs`,children:e.workspace.root_path})]}),(0,X.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(y,{className:`h-3 w-3 text-emerald-500`}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.connected})]}),e.needsAuth>0&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-500`,children:[(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.needsAuth}),(0,X.jsx)(`span`,{children:`need creds`})]}),e.available>0&&(0,X.jsxs)(`span`,{className:`tabular-nums opacity-50`,children:[`+`,e.available]})]})]},e.workspace.id)})})]})}function De({workspace:e,summary:t}){return(0,X.jsx)(`div`,{className:`rounded-md border border-border/50 bg-card/30 px-4 py-3`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,X.jsx)(_,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`h2`,{className:`truncate text-lg font-semibold`,children:e.name}),(0,X.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-muted-foreground/50 sm:inline`,title:e.root_path,children:e.root_path})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsxs)(J,{variant:`outline`,tone:e.default_policy===`allow`?`success`:`muted`,children:[`default `,e.default_policy]}),(0,X.jsxs)(J,{variant:`outline`,tone:`success`,children:[t?.connected??0,` usable`]}),t&&t.needsAuth>0&&(0,X.jsxs)(J,{variant:`outline`,tone:`warn`,children:[t.needsAuth,` need creds`]}),t&&t.available>0&&(0,X.jsxs)(J,{variant:`outline`,tone:`muted`,children:[t.available,` available`]}),(0,X.jsx)(T,{variant:`outline`,size:`sm`,asChild:!0,className:`h-7`,children:(0,X.jsxs)(E,{to:`/workspaces/manage?workspace=${e.id}`,children:[(0,X.jsx)(ie,{className:`mr-1.5 h-3.5 w-3.5`}),`Edit`]})})]})]})})}function $({title:e,rows:t,onOpen:n}){return(0,X.jsxs)(`section`,{className:`rounded-md border border-border/50 bg-card/20`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3 py-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.length})]}),(0,X.jsx)(`div`,{className:`divide-y divide-border/50`,children:t.map(e=>(0,X.jsx)(Oe,{row:e,onOpen:()=>n(e)},e.server.id))})]})}function Oe({row:e,onOpen:t}){return(0,X.jsxs)(`button`,{type:`button`,onClick:t,className:`grid w-full min-w-0 items-center gap-2 px-3 py-3 text-left transition-colors hover:bg-muted/30 focus:outline-none focus:ring-1 focus:ring-primary/60 md:grid-cols-[1fr_auto]`,"aria-label":`${e.server.name}: ${je(e.state.kind)}`,"data-testid":`connection-cell-${e.server.id}-${e.workspace.id}`,"data-state-kind":e.state.kind,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(ke,{kind:e.state.kind}),(0,X.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.server.name}),(0,X.jsx)(J,{variant:`outline`,tone:Ne(e.state.kind),className:`text-[10px] px-1.5`,children:je(e.state.kind)})]}),(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{className:`font-mono text-muted-foreground/70`,children:[e.server.tool_namespace,`__*`]}),(0,X.jsx)(`span`,{className:`text-muted-foreground/40 select-none`,children:`·`}),(0,X.jsx)(`span`,{children:e.server.transport}),e.state.kind!==`add`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/40 select-none`,children:`·`}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(ne,{className:`h-3 w-3 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate`,children:Ae(e)})]})]})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[e.route&&(0,X.jsx)(`span`,{className:`hidden truncate font-mono text-xs text-muted-foreground/60 lg:inline`,children:e.route.path_glob}),(0,X.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-sm border border-border/60 px-2 py-1 text-xs text-foreground hover:border-primary/40 hover:bg-primary/5`,children:Me(e.state.kind)})]})]})}function ke({kind:e}){let t=`h-4 w-4 shrink-0`;switch(e){case`connected`:return(0,X.jsx)(L,{className:`${t} text-emerald-500`});case`needs-auth`:return(0,X.jsx)(re,{className:`${t} text-amber-500`});case`disabled`:return(0,X.jsx)(F,{className:`${t} text-muted-foreground`});case`add`:return(0,X.jsx)(M,{className:`${t} text-muted-foreground`})}}function Ae(e){return e.route?e.route.auth_scope_id?e.scope?g(e.scope):`Missing credential`:`No credential required`:`Choose during connect`}function je(e){switch(e){case`connected`:return`Connected`;case`needs-auth`:return`Needs auth`;case`disabled`:return`Disabled`;case`add`:return`Available`}}function Me(e){switch(e){case`connected`:return`Edit`;case`needs-auth`:return`Fix auth`;case`disabled`:return`Review`;case`add`:return`Connect`}}function Ne(e){return e===`connected`?`success`:e===`needs-auth`?`warn`:`muted`}function Pe({counts:e,filter:t,onChange:n}){return(0,X.jsx)(`div`,{className:`flex flex-nowrap items-center gap-1.5 overflow-x-auto pb-1`,"data-testid":`connections-filter-chips`,children:[{key:`all`,label:`All servers`,count:e.all},{key:`connected`,label:`Connected`,count:e.connected},{key:`needs-auth`,label:`Needs auth`,count:e.needsAuth},{key:`available`,label:`Not connected`,count:e.available}].map(e=>{let r=t===e.key;return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e.key),className:`inline-flex shrink-0 items-center gap-1.5 border px-2.5 py-1 text-xs transition-colors `+(r?`border-primary/60 bg-primary/10 text-primary`:`border-border bg-card/40 text-muted-foreground hover:text-foreground`),"data-testid":`connections-filter-${e.key}`,children:[(0,X.jsx)(`span`,{children:e.label}),(0,X.jsxs)(`span`,{className:r?`text-primary`:`text-muted-foreground/60`,children:[`(`,e.count,`)`]})]},e.key)})})}function Fe({icon:e,title:t,body:n,action:r}){return(0,X.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-md border border-dashed border-border/60 bg-muted/20 px-4 py-12 text-center sm:px-6`,children:[(0,X.jsx)(`div`,{className:`mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-md border border-border/50 text-muted-foreground`,children:e}),(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:t}),(0,X.jsx)(`p`,{className:`mx-auto mt-1 max-w-full text-wrap break-words text-xs leading-relaxed text-muted-foreground sm:max-w-md`,children:n}),(0,X.jsx)(`div`,{className:`mt-4`,children:r})]})}function Ie({query:e,filter:t}){let n=e?`No servers match your search. Try a different name or credential.`:`No servers match the ${ze(t)} filter in this workspace.`;return(0,X.jsxs)(`div`,{className:`rounded-md border border-dashed border-border/60 bg-muted/20 px-6 py-10 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Nothing to show`}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n})]})}function Le({message:e,onRetry:t}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(T,{size:`sm`,variant:`ghost`,onClick:t,children:`Retry`})]})}function Re(){return(0,X.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[18rem_1fr]`,children:[(0,X.jsx)(`div`,{className:`h-72 animate-pulse rounded-md bg-muted`}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`div`,{className:`h-20 animate-pulse rounded-md bg-muted`}),(0,X.jsx)(`div`,{className:`h-10 animate-pulse rounded-md bg-muted`}),(0,X.jsx)(`div`,{className:`h-64 animate-pulse rounded-md bg-muted`})]})]})}function ze(e){switch(e){case`all`:return`all`;case`connected`:return`connected`;case`needs-auth`:return`needs auth`;case`available`:return`available`}}function Be({workspaces:e,serverCount:t,summaries:n,selectedWorkspace:r,rows:i,visibleRows:a,counts:o,filter:s,query:c,loading:l,error:u,onRetry:d,onSelectWorkspace:f,onFilterChange:p,onQueryChange:m,onOpenConnection:h}){if(l&&(t===0||e.length===0))return(0,X.jsx)(Re,{});if(t===0)return(0,X.jsx)(Ue,{});if(e.length===0)return(0,X.jsx)(We,{});if(!r)return null;let g=a.filter(e=>e.state.kind===`needs-auth`),_=a.filter(e=>e.route&&e.state.kind!==`needs-auth`),v=a.filter(e=>!e.route),y=n.find(e=>e.workspace.id===r.id);return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[u&&(0,X.jsx)(Le,{message:u,onRetry:d}),(0,X.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[18rem_1fr]`,children:[(0,X.jsx)(Ee,{summaries:n,selectedWorkspaceId:r.id,onSelect:f}),(0,X.jsxs)(`section`,{className:`min-w-0 space-y-4`,children:[(0,X.jsx)(De,{workspace:r,summary:y}),(0,X.jsx)(Ve,{query:c,filter:s,counts:o,onQueryChange:m,onFilterChange:p}),(0,X.jsx)(He,{rows:i,visibleRows:a,attentionRows:g,attachedRows:_,availableRows:v,query:c,filter:s,onOpenConnection:h})]})]})]})}function Ve({query:e,filter:t,counts:n,onQueryChange:r,onFilterChange:i}){return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-center md:justify-between`,children:[(0,X.jsxs)(`div`,{className:`relative min-w-64 flex-1 md:max-w-md`,children:[(0,X.jsx)(te,{className:`pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground/70`}),(0,X.jsx)(D,{value:e,onChange:e=>r(e.target.value),placeholder:`Search servers, credentials, namespaces`,className:`pl-8`,"data-testid":`connections-search`})]}),(0,X.jsx)(Pe,{counts:n,filter:t,onChange:i})]})}function He({rows:e,visibleRows:t,attentionRows:n,attachedRows:r,availableRows:i,query:a,filter:o,onOpenConnection:s}){return t.length===0?(0,X.jsx)(Ie,{query:a,filter:o}):(0,X.jsxs)(`div`,{className:`space-y-4`,children:[n.length>0&&(0,X.jsx)($,{title:`Needs Attention`,rows:n,onOpen:s}),r.length>0&&(0,X.jsx)($,{title:`Configured In This Workspace`,rows:r,onOpen:s}),i.length>0&&(0,X.jsx)($,{title:e.some(e=>e.route)?`Available To Connect`:`Available Servers`,rows:i,onOpen:s})]})}function Ue(){return(0,X.jsx)(Fe,{icon:(0,X.jsx)(y,{className:`h-7 w-7`}),title:`No servers configured`,body:`Add a server first, then connect it to workspaces where agents should use it.`,action:(0,X.jsx)(T,{asChild:!0,children:(0,X.jsxs)(E,{to:`/setup`,children:[(0,X.jsx)(M,{className:`mr-1.5 h-4 w-4`}),`Add server`]})})})}function We(){return(0,X.jsx)(Fe,{icon:(0,X.jsx)(I,{className:`h-7 w-7`}),title:`No workspaces yet`,body:`Create a workspace so each project has a clear service boundary.`,action:(0,X.jsx)(T,{asChild:!0,children:(0,X.jsxs)(E,{to:`/workspaces/manage`,children:[(0,X.jsx)(M,{className:`mr-1.5 h-4 w-4`}),`New workspace`]})})})}function Ge(){let e=(0,Y.useCallback)(()=>s(),[]),t=(0,Y.useCallback)(()=>i(),[]),n=(0,Y.useCallback)(()=>o(),[]),r=(0,Y.useCallback)(()=>f(),[]),{data:a,loading:c,error:l,refetch:u}=N(e),{data:d,loading:p,error:m,refetch:h}=N(t),{data:g,loading:_,error:y,refetch:b}=N(n),{data:S,loading:C,error:w,refetch:D}=N(r),[O,k]=x(),[A,j]=(0,Y.useState)(null),[P,F]=(0,Y.useState)(()=>O.get(`focus_workspace`)),[I,L]=(0,Y.useState)(``),[R,z]=(0,Y.useState)(`all`),B=(0,Y.useMemo)(()=>(a??[]).filter(e=>!e.disabled),[a]),V=(0,Y.useMemo)(()=>me(g??[]),[g]),H=(0,Y.useMemo)(()=>he(V,S??[]),[V,S]),ee=(0,Y.useMemo)(()=>ge(d??[],B,V,H),[d,B,V,H]),U=(0,Y.useMemo)(()=>d?.length?d.find(e=>e.id===P)??d[0]:null,[d,P]),W=(0,Y.useMemo)(()=>U?_e(U,B,V,H,S??[]):[],[U,B,V,H,S]),G=(0,Y.useMemo)(()=>ve(W,R,I),[W,R,I]),te=(0,Y.useMemo)(()=>ye(W),[W]),ne=c||p||_||C,K=[l,m,y,w].filter(Boolean).join(` -`);(0,Y.useEffect)(()=>{if(!d?.length){F(null);return}(!P||!d.some(e=>e.id===P))&&F(d[0].id)},[d,P]);let q=O.get(`focus_server`)??O.get(`server`),J=O.get(`focus_workspace`)??O.get(`workspace`);(0,Y.useEffect)(()=>{if(!q&&!J||!a||!d||!g||!S)return;J&&d.some(e=>e.id===J)&&F(J);let e=be(q,J,B,d,V,H);e&&q&&(F(e.workspace.id),j(e)),k(e=>{let t=new URLSearchParams(e);return t.delete(`focus_server`),t.delete(`focus_workspace`),t.delete(`server`),t.delete(`workspace`),t.delete(`action`),t},{replace:!0})},[q,J,a,d,g,S,B,V,H,k]);let re=(0,Y.useCallback)(e=>{let{server:t,workspace:n,state:r,route:i}=e;j({server:t,workspace:n,state:r,route:i})},[]),ae=(0,Y.useCallback)(()=>j(null),[]),oe=(0,Y.useCallback)(()=>{b(),D(),u(),h()},[b,D,u,h]),se=(0,Y.useCallback)(()=>{b(),D(),u(),h()},[b,D,u,h]);return(0,X.jsxs)(`div`,{className:`space-y-5`,children:[(0,X.jsxs)(`header`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Workspaces`}),(0,X.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Each workspace scopes which servers, credentials, and tools an agent can reach. Pick a workspace to see its permissions and connections.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(T,{variant:`outline`,asChild:!0,children:(0,X.jsxs)(E,{to:`/advanced/routes`,children:[(0,X.jsx)(v,{className:`mr-1.5 h-4 w-4`}),`Edit routes`]})}),(0,X.jsx)(T,{variant:`outline`,asChild:!0,children:(0,X.jsxs)(E,{to:`/workspaces/manage`,children:[(0,X.jsx)(ie,{className:`mr-1.5 h-4 w-4`}),`Manage workspaces`]})}),(0,X.jsx)(T,{asChild:!0,children:(0,X.jsxs)(E,{to:`/setup`,children:[(0,X.jsx)(M,{className:`mr-1.5 h-4 w-4`}),`Add server`]})})]})]}),(0,X.jsx)(Be,{workspaces:d??[],serverCount:B.length,summaries:ee,selectedWorkspace:U,rows:W,visibleRows:G,counts:te,filter:R,query:I,loading:ne,error:K||null,onRetry:se,onSelectWorkspace:F,onFilterChange:z,onQueryChange:L,onOpenConnection:re}),(0,X.jsx)(pe,{open:A!==null,server:A?.server??null,workspace:A?.workspace??null,state:A?.state??null,route:A?.route??null,scopes:S??[],onClose:ae,onChanged:oe})]})}export{Ge as ConnectionsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/CreateMCP-C1MoexMP.js b/internal/web/dist/assets/CreateMCP-C1MoexMP.js deleted file mode 100644 index b8e7cc5..0000000 --- a/internal/web/dist/assets/CreateMCP-C1MoexMP.js +++ /dev/null @@ -1,6 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Bt as n,Dt as r,Ot as i,gt as a,on as o,s}from"./client-CaIRceNv.js";import{t as c}from"./play-YbzkBfB8.js";import{Dr as l,Fn as u,Fr as d,Ft as f,Or as p,Pt as m,S as h,Wn as g,a as _,br as v,c as y,d as b,f as x,g as S,jr as C,l as w,m as T,mr as E,nr as D,o as O,p as k,s as A,u as j}from"./index-BDLzoIgt.js";var M=e(t(),1),N=o();function P(e){let[t,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=e.authSpec.grant_type??`authorization_code`,s=!!e.authSpec.use_pkce,c=(e.authSpec.scopes??[]).join(` `),[l,d]=(0,M.useState)(``);function p(t){e.setAuthSpec({...e.authSpec,...t})}async function m(){r(!0),a(null);try{let t=await n({auth_scope_name:e.authScopeName,parent_server:e.parentServer,auth_url:e.authSpec.auth_url??``,token_url:e.authSpec.token_url??``,scopes:e.authSpec.scopes??[],client_id:e.authSpec.client_id??``,client_secret:l||void 0,use_pkce:s,grant_type:o});e.setOAuthResult(t),p({kind:`oauth2`})}catch(e){a(e instanceof Error?e.message:`oauth setup failed`)}finally{r(!1)}}return(0,N.jsxs)(`div`,{className:`space-y-4`,children:[e.authSpec.kind===`oauth2_pending`&&(0,N.jsxs)(`div`,{className:`rounded border border-amber-500/40 bg-amber-500/10 p-3 text-sm`,children:[`OpenAPI import flagged this as an OAuth2 flow. Fill in the fields below and click`,(0,N.jsx)(`span`,{className:`mx-1 font-semibold`,children:`Test OAuth`}),`to finish setup.`]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsx)(F,{label:`Auth scope name`,children:(0,N.jsx)(f,{value:e.authScopeName,onChange:t=>e.setAuthScopeName(t.target.value),placeholder:`weatherco`})}),(0,N.jsx)(F,{label:`Grant type`,children:(0,N.jsxs)(j,{value:o,onValueChange:e=>p({grant_type:e}),children:[(0,N.jsx)(k,{children:(0,N.jsx)(T,{})}),(0,N.jsxs)(b,{children:[(0,N.jsx)(x,{value:`authorization_code`,children:`Authorization code (PKCE)`}),(0,N.jsx)(x,{value:`client_credentials`,children:`Client credentials`})]})]})})]}),(0,N.jsx)(F,{label:`Authorization URL`,children:(0,N.jsx)(f,{value:e.authSpec.auth_url??``,onChange:e=>p({auth_url:e.target.value}),placeholder:`https://auth.example.com/oauth/authorize`,disabled:o===`client_credentials`})}),(0,N.jsx)(F,{label:`Token URL`,children:(0,N.jsx)(f,{value:e.authSpec.token_url??``,onChange:e=>p({token_url:e.target.value}),placeholder:`https://auth.example.com/oauth/token`})}),(0,N.jsx)(F,{label:`Scopes (space-separated)`,children:(0,N.jsx)(f,{value:c,onChange:e=>p({scopes:e.target.value.split(/\s+/).filter(Boolean)}),placeholder:`read write`})}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsx)(F,{label:`Client ID`,children:(0,N.jsx)(f,{value:e.authSpec.client_id??``,onChange:e=>p({client_id:e.target.value}),placeholder:s?`(public client — optional)`:`client_xxx`})}),(0,N.jsx)(F,{label:o===`client_credentials`?`Client secret (required)`:`Client secret (optional with PKCE)`,children:(0,N.jsx)(f,{type:`password`,value:l,onChange:e=>d(e.target.value),placeholder:`••••••••`})})]}),(0,N.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>p({use_pkce:e.target.checked}),disabled:o===`client_credentials`}),`Use PKCE (S256) — recommended for public clients`]}),(0,N.jsx)(F,{label:`Redirect URL (read-only)`,children:(0,N.jsx)(f,{value:e.redirectURL,readOnly:!0,className:`font-mono text-xs`})}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsxs)(u,{onClick:m,disabled:t||!e.authScopeName||!e.authSpec.token_url,children:[t?(0,N.jsx)(D,{className:`mr-1 h-4 w-4 animate-spin`}):(0,N.jsx)(g,{className:`mr-1 h-4 w-4`}),`Test OAuth`]}),e.oauthResult?.authorize_url&&(0,N.jsxs)(`a`,{href:e.oauthResult.authorize_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-primary hover:underline`,children:[`Authorize in browser `,(0,N.jsx)(E,{className:`h-3 w-3`})]})]}),i&&(0,N.jsx)(`p`,{className:`text-sm text-red-500`,children:i}),e.oauthResult&&(0,N.jsxs)(`div`,{className:`rounded border bg-muted p-3 text-xs`,children:[(0,N.jsx)(`div`,{className:`font-semibold`,children:e.oauthResult.message}),e.oauthResult.human_approval_required&&(0,N.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`Open the authorize link in a new tab. After you grant access the auth scope is ready to use.`})]})]})}function F({label:e,children:t}){return(0,N.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,N.jsx)(m,{children:e}),t]})}function I({spec:e,authScopeID:t}){let[n,r]=(0,M.useState)(e.endpoints[0]?.name??``),a=(0,M.useMemo)(()=>e.endpoints.find(e=>e.name===n),[e.endpoints,n]),[o,s]=(0,M.useState)({}),[l,d]=(0,M.useState)(null),[p,h]=(0,M.useState)(!1),[g,_]=(0,M.useState)(null);function v(e,t){s(n=>({...n,[e]:t}))}async function y(){if(a){h(!0),_(null);try{let r={};for(let e of a.params??[]){let t=o[e.name];t===void 0||t===``||(r[e.name]=B(t,e.type))}d(await i({spec:e,endpoint:n,args:r,auth_scope_id:t}))}catch(e){_(e instanceof Error?e.message:`preview call failed`)}finally{h(!1)}}}return e.endpoints.length===0?(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Add at least one endpoint to test.`}):(0,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsx)(`div`,{className:`rounded border border-amber-500/40 bg-amber-500/10 p-3 text-xs`,children:`Test responses are not saved. Sensitive headers (Authorization, Cookie, X-API-Key) and JSON keys containing token/secret/password are redacted before display.`}),(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,N.jsx)(z,{label:`Endpoint`,children:(0,N.jsxs)(j,{value:n,onValueChange:r,children:[(0,N.jsx)(k,{children:(0,N.jsx)(T,{})}),(0,N.jsx)(b,{children:e.endpoints.map(e=>(0,N.jsxs)(x,{value:e.name,children:[e.method,` `,e.name,` (`,e.path,`)`]},e.name))})]})}),(0,N.jsx)(`div`,{className:`flex items-end justify-end`,children:(0,N.jsxs)(u,{onClick:y,disabled:p||!a,children:[p?(0,N.jsx)(D,{className:`mr-1 h-4 w-4 animate-spin`}):(0,N.jsx)(c,{className:`mr-1 h-4 w-4`}),`Try it`]})})]}),a&&(0,N.jsxs)(`div`,{className:`space-y-2 rounded border p-3`,children:[(0,N.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[a.method,` `,e.base_url,a.path]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(a.params??[]).map(e=>(0,N.jsxs)(`div`,{className:`grid grid-cols-12 items-center gap-2 text-xs`,children:[(0,N.jsxs)(m,{className:`col-span-3`,children:[e.name,e.required&&(0,N.jsx)(`span`,{className:`text-red-500`,children:`*`})]}),(0,N.jsxs)(`span`,{className:`col-span-2 text-muted-foreground`,children:[e.type,` / `,e.in]}),(0,N.jsx)(f,{className:`col-span-7`,value:o[e.name]??``,onChange:t=>v(e.name,t.target.value),placeholder:e.description})]},e.name)),(a.params??[]).length===0&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This endpoint takes no parameters.`})]})]}),g&&(0,N.jsx)(`p`,{className:`text-sm text-red-500`,children:g}),l&&(0,N.jsx)(L,{result:l})]})}function L({result:e}){return(0,N.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`div`,{className:`font-semibold`,children:`Request`}),(0,N.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded border bg-muted p-2`,children:[e.request.method,` `,e.request.url,R(e.request.headers),e.request.body?` - -`+e.request.body:``]})]}),(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsxs)(`div`,{className:`font-semibold`,children:[`Response — HTTP `,e.status]}),(0,N.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded border bg-muted p-2`,children:[R(e.response.headers),e.response.body?` - -`+e.response.body:``]})]})]})}function R(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(` -`)}function z({label:e,children:t}){return(0,N.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,N.jsx)(m,{children:e}),t]})}function B(e,t){switch(t){case`integer`:{let t=parseInt(e,10);return Number.isNaN(t)?e:t}case`number`:{let t=parseFloat(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`||e===`1`;default:return e}}var V=[{id:`basics`,label:`Basics`},{id:`auth`,label:`Auth`},{id:`oauth`,label:`OAuth`},{id:`endpoints`,label:`Endpoints`},{id:`test`,label:`Test`},{id:`review`,label:`Review`}];function H(e){return e===`oauth2`||e===`oauth2_pending`?V:V.filter(e=>e.id!==`oauth`)}function U(){let[e,t]=(0,M.useState)(`basics`),[n,i]=(0,M.useState)(``),[o,c]=(0,M.useState)(``),[f,m]=(0,M.useState)(``),[g,b]=(0,M.useState)(``),[x,T]=(0,M.useState)(`bearer`),[E,k]=(0,M.useState)(`Authorization`),[j,F]=(0,M.useState)(`api_key`),[L,R]=(0,M.useState)([w()]),[z,B]=(0,M.useState)(``),[V,U]=(0,M.useState)(!1),[W,G]=(0,M.useState)({kind:`oauth2`,grant_type:`authorization_code`,use_pkce:!0,scopes:[]}),[K,q]=(0,M.useState)(``),[J,Y]=(0,M.useState)(null),{data:X}=h((0,M.useCallback)(()=>a(),[])),Z=(0,M.useMemo)(()=>H(x),[x]),Q=(0,M.useMemo)(()=>{let t=Z.findIndex(t=>t.id===e);return Z.slice(0,t).map(e=>e.id)},[Z,e]),$=(0,M.useCallback)(()=>{let e=x===`oauth2`||x===`oauth2_pending`?{...W,kind:x}:{kind:x,...x===`api_key_header`?{header_name:E}:{},...x===`api_key_query`?{query_name:j}:{}};return{name:n.trim(),description:o.trim(),base_url:f.trim(),parent_server:g.trim(),auth:e,...K?{auth_scope:K}:{},endpoints:L}},[n,o,f,g,x,E,j,L,W,K]);(0,M.useEffect)(()=>{if(e!==`review`)return;let t=!1;return r($()).then(e=>{t||B(e.yaml)}).catch(e=>{t||B(`# preview failed: ${e.message}`)}),()=>{t=!0}},[e,$]);function ee(){let n=Z.findIndex(t=>t.id===e);nt.id===e);n>0&&t(Z[n-1].id)}async function ne(){U(!0);try{let e=await s($());C.success(`Created ${e.name} with ${e.tools.length} tool(s).`),t(`basics`),i(``),c(``),m(``),b(``),T(`bearer`),R([w()]),B(``),G({kind:`oauth2`,grant_type:`authorization_code`,use_pkce:!0,scopes:[]}),q(``),Y(null)}catch(e){let t=e instanceof Error?e.message:`create failed`;C.error(t)}finally{U(!1)}}return(0,N.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,N.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Create Custom MCP`}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Build an HTTP-based MCP addon with custom endpoints and auth.`})]}),(0,N.jsx)(u,{variant:`ghost`,asChild:!0,children:(0,N.jsxs)(d,{to:`/`,children:[(0,N.jsx)(p,{className:`mr-1.5 h-4 w-4`}),` Back`]})})]}),(0,N.jsx)(S,{steps:Z,currentStep:e,completedSteps:Q}),e===`basics`&&(0,N.jsx)(O,{name:n,setName:i,description:o,setDescription:c,baseURL:f,setBaseURL:m,parentServer:g,setParentServer:b,downstreams:X??[]}),e===`auth`&&(0,N.jsx)(_,{authKind:x,setAuthKind:T,headerName:E,setHeaderName:k,queryName:j,setQueryName:F}),e===`oauth`&&(0,N.jsx)(P,{authSpec:W,setAuthSpec:G,authScopeName:K,setAuthScopeName:q,parentServer:g,redirectURL:`${window.location.origin}/api/v1/oauth/callback`,oauthResult:J,setOAuthResult:Y}),e===`endpoints`&&(0,N.jsx)(A,{endpoints:L,setEndpoints:R}),e===`test`&&(0,N.jsx)(I,{spec:$(),authScopeID:J?.auth_scope?.id}),e===`review`&&(0,N.jsx)(y,{yaml:z}),(0,N.jsxs)(`div`,{className:`flex justify-between border-t border-border pt-4`,children:[(0,N.jsxs)(u,{variant:`ghost`,onClick:te,disabled:e===Z[0]?.id,children:[(0,N.jsx)(p,{className:`mr-1 h-4 w-4`}),` Back`]}),e===`review`?(0,N.jsxs)(u,{onClick:ne,disabled:V,children:[V?(0,N.jsx)(D,{className:`mr-1 h-4 w-4 animate-spin`}):(0,N.jsx)(v,{className:`mr-1 h-4 w-4`}),`Create`]}):(0,N.jsxs)(u,{onClick:ee,children:[`Next `,(0,N.jsx)(l,{className:`ml-1 h-4 w-4`})]})]})]})}export{U as CreateMCPPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/DashboardPage-Bgs2hZX0.js b/internal/web/dist/assets/DashboardPage-Bgs2hZX0.js deleted file mode 100644 index 4f38558..0000000 --- a/internal/web/dist/assets/DashboardPage-Bgs2hZX0.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,L as r,St as i,W as a,bt as o,gt as s,in as c,on as l,pt as u}from"./client-CaIRceNv.js";import{n as d,t as f}from"./toggle-group-CwLNIqWC.js";import{t as p}from"./createLucideIcon-WB390fY6.js";import{t as m}from"./chevron-right-CyhRDGe7.js";import{t as h}from"./database-DUeGtnBt.js";import{a as g,r as _,s as ee}from"./AuditDetailDialog-CIIIkhsj.js";import{t as v}from"./inbox-ClSTJaEn.js";import{t as y}from"./list-checks-B0hSiAul.js";import{t as te}from"./wifi-off-wjnWavsP.js";import{t as b}from"./workflow-COO0Sn-w.js";import{Ar as x,Br as ne,Cr as re,Er as ie,Fr as S,It as ae,Kn as oe,Lt as se,Mr as C,Nr as ce,Pr as w,Rr as T,S as E,V as D,Wn as O,Z as le,Zn as k,br as A,fr as ue,ft as de,i as j,n as M,pt as N,r as P,sr as F,t as I,tr as fe,wr as pe,x as me,xr as he,y as L,yn as ge,zn as R}from"./index-BDLzoIgt.js";import{a as z,i as B,n as V,o as H,r as U,t as W}from"./table-2N0Q-yAm.js";import{t as _e}from"./use-tasks-stream-BfVVn1xh.js";var ve=p(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),G=e(t(),1);function K(e,t){let n=(0,G.useRef)(e);(0,G.useEffect)(()=>{n.current=e},[e]),(0,G.useEffect)(()=>{if(t===null)return;let e=setInterval(()=>n.current(),t);return()=>clearInterval(e)},[t])}function ye(){let e=(0,G.useCallback)(()=>s(),[]),t=(0,G.useCallback)(()=>n(),[]),r=(0,G.useCallback)(()=>o(),[]),i=(0,G.useCallback)(()=>u(),[]),{data:a,loading:c}=E(e),{data:l,loading:d}=E(t),{data:f,loading:p}=E(r),{data:m,loading:h}=E(i),g=c||d||p||h;return{serversNeedingCreds:(0,G.useMemo)(()=>{if(!a||!f||!m)return[];let e=new Map(m.map(e=>[e.id,e])),t=new Set;for(let n of f){if(!n.auth_scope_id)continue;let r=e.get(n.auth_scope_id);if(!r){t.add(n.downstream_server_id);continue}(r.type===`env`||r.type===`header`||r.type===`hawk`||r.type===`client_credentials`)&&!r.has_secrets&&t.add(n.downstream_server_id)}return a.filter(e=>!e.disabled&&t.has(e.id))},[a,f,m]),workspacesWithoutRoutes:(0,G.useMemo)(()=>{if(!l||!f)return[];let e=new Set(f.map(e=>e.workspace_id));return l.filter(t=>!e.has(t.id))},[l,f]),loading:g}}var q=l();function be(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60),i=n%60;return r<24?`${r}h ${i}m`:`${Math.floor(r/24)}d ${r%24}h`}var xe={idle:`text-foreground`,live:`text-emerald-400`,info:`text-sky-300`,warn:`text-amber-300`,critical:`text-red-300`},Se={idle:`border-border hover:border-border/80`,live:`border-emerald-500/30 hover:border-emerald-500/50`,info:`border-sky-500/30 hover:border-sky-500/50`,warn:`border-amber-500/40 hover:border-amber-500/60`,critical:`border-red-500/40 hover:border-red-500/60`};function Ce({items:e}){return(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6`,"data-testid":`dash-vitals-strip`,children:e.map(e=>(0,q.jsx)(we,{item:e},e.label))})}function we({item:e}){let t=e.tone??`idle`;return(0,q.jsxs)(S,{to:e.href,"data-testid":e.testid??`dash-vital-${e.label.toLowerCase().replace(/\s+/g,`-`)}`,title:e.detail??e.label,className:c(`group block border bg-card/40 px-3 py-2.5 transition-colors`,`focus-visible:outline-none focus-visible:border-primary/60`,Se[t]),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),t===`warn`||t===`critical`?(0,q.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[(0,q.jsx)(`span`,{className:c(`absolute inline-flex h-full w-full animate-pulse-slow rounded-full opacity-70`,t===`critical`?`bg-red-400`:`bg-amber-400`)}),(0,q.jsx)(`span`,{className:c(`relative inline-flex h-1.5 w-1.5 rounded-full`,t===`critical`?`bg-red-400`:`bg-amber-400`)})]}):t===`live`?(0,q.jsx)(`span`,{className:`inline-flex h-1.5 w-1.5 rounded-full bg-emerald-400`}):null]}),(0,q.jsx)(`div`,{className:c(`mt-1.5 font-mono text-2xl font-semibold leading-none tabular-nums`,xe[t]),children:e.value}),e.detail&&(0,q.jsx)(`div`,{className:`mt-1 truncate text-[10.5px] text-muted-foreground/80`,children:e.detail})]})}var Te={critical:0,warn:1,info:2},Ee={critical:`border-red-500/40`,warn:`border-amber-500/40`,info:`border-sky-500/30`},J={critical:`text-red-300`,warn:`text-amber-300`,info:`text-sky-300`};function De({input:e}){let t=Oe(e);return(0,q.jsxs)(`section`,{"data-testid":`dash-attention`,className:`border border-border bg-card/40`,children:[(0,q.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border/60 px-4 py-2`,children:[(0,q.jsx)(`h2`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Needs your attention`}),(0,q.jsx)(`span`,{className:`font-mono text-[11px] tabular-nums text-muted-foreground`,children:t.length===0?`clear`:t.length})]}),t.length===0?(0,q.jsx)(Ae,{}):(0,q.jsx)(ke,{items:t})]})}function Oe(e){let t=[];e.pendingApprovals>0&&t.push({key:`tool-approvals`,tone:`critical`,icon:(0,q.jsx)(O,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:e.pendingApprovals}),` tool-call approval`,e.pendingApprovals===1?``:`s`,` waiting`]}),to:`/approvals`,cta:`Review`}),e.pendingWorkerApprovals>0&&t.push({key:`worker-approvals`,tone:`warn`,icon:(0,q.jsx)(b,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:e.pendingWorkerApprovals}),` worker run`,e.pendingWorkerApprovals===1?``:`s`,` waiting for approval`]}),to:`/worker-approvals`,cta:`Review`}),e.unhealthyWorkers>0&&t.push({key:`unhealthy-workers`,tone:`warn`,icon:(0,q.jsx)(R,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:e.unhealthyWorkers}),` worker`,e.unhealthyWorkers===1?``:`s`,` auto-paused or failing`]}),to:`/workers`,cta:`Inspect`}),e.offlinePeers>0&&t.push({key:`offline-peers`,tone:`warn`,icon:(0,q.jsx)(te,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:e.offlinePeers}),` paired peer`,e.offlinePeers===1?``:`s`,` offline`]}),to:`/pairing`,cta:`Pairing`}),e.pendingMemoryOffers>0&&t.push({key:`memory-offers`,tone:`info`,icon:(0,q.jsx)(v,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:e.pendingMemoryOffers}),` memory offer`,e.pendingMemoryOffers===1?``:`s`,` from peers awaiting review`]}),to:`/memory/shared`,cta:`Review`}),e.expiringSecrets>0&&t.push({key:`expiring-secrets`,tone:`warn`,icon:(0,q.jsx)(F,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:e.expiringSecrets}),` credential`,e.expiringSecrets===1?``:`s`,` expiring soon`]}),to:`/config`,cta:`Rotate`});let n=e.serversNeedingCreds?.length??0;if(n>0){let r=e.serversNeedingCreds,i=n===1?`/workspaces?focus_server=${r[0].id}&action=fix-auth`:`/workspaces`;t.push({key:`servers-need-creds`,tone:`warn`,icon:(0,q.jsx)(fe,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:n}),` server`,n===1?``:`s`,` need`,n===1?`s`:``,` credentials`]}),to:i,cta:`Fix`})}let r=e.workspacesWithoutRoutes?.length??0;if(r>0){let n=e.workspacesWithoutRoutes,i=r===1?`/workspaces?focus_workspace=${n[0].id}&action=add-server`:`/workspaces`;t.push({key:`workspaces-no-routes`,tone:`info`,icon:(0,q.jsx)(ve,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:r}),` workspace`,r===1?``:`s`,` `,r===1?`has`:`have`,` no routes`]}),to:i,cta:`Wire up`})}let i=e.unreviewedDelegations??0;return i>0&&t.push({key:`unreviewed-delegations`,tone:`warn`,icon:(0,q.jsx)(b,{className:`h-3.5 w-3.5`}),label:(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`strong`,{className:`font-medium`,children:i}),` delegation`,i===1?``:`s`,` waiting for review`]}),to:`/delegations`,cta:`Review`}),t.sort((e,t)=>Te[e.tone]-Te[t.tone]),t}function ke({items:e}){return(0,q.jsx)(`ul`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(S,{to:e.to,"data-testid":`dash-attention-${e.key}`,className:`group flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-accent/20`,children:[(0,q.jsx)(`span`,{className:c(`shrink-0`,J[e.tone]),children:e.icon}),(0,q.jsx)(`span`,{className:c(`flex-1 text-[13px] leading-snug`,J[e.tone]),children:e.label}),(0,q.jsxs)(`span`,{className:c(`inline-flex shrink-0 items-center border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition-colors`,Ee[e.tone],J[e.tone],`group-hover:bg-accent/30`),children:[e.cta,` ›`]})]})},e.key))})}function Ae(){return(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 px-4 py-3 text-[13px] text-muted-foreground`,children:[(0,q.jsx)(A,{className:`h-3.5 w-3.5 text-emerald-500/70`}),(0,q.jsx)(`span`,{children:`All clear. Nothing is blocked on you right now.`})]})}var je=[{key:`all`,label:`all`},{key:`tools`,label:`tools`},{key:`signal`,label:`signal`},{key:`errors`,label:`errors`}];function Me({audit:e,signal:t,connected:n,wsName:r}){let[i,a]=(0,G.useState)(`all`),o=(0,G.useMemo)(()=>Be(e,t),[e,t]),s=(0,G.useMemo)(()=>Ve(o,i).slice(0,40),[o,i]);return(0,q.jsxs)(`section`,{"data-testid":`dash-right-now`,className:`border border-border bg-card/30`,children:[(0,q.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border/60 px-4 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,q.jsx)(`h2`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Right now`}),(0,q.jsx)(Ne,{connected:n})]}),(0,q.jsx)(Pe,{filter:i,onSet:a})]}),s.length===0?(0,q.jsx)(ze,{filter:i}):(0,q.jsx)(`ul`,{className:`max-h-[480px] divide-y divide-border/30 overflow-y-auto`,children:s.map(e=>(0,q.jsx)(Fe,{row:e,wsName:r},`${e.kind}:${e.id}`))})]})}function Ne({connected:e}){return e?(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-wider text-emerald-400`,children:[(0,q.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[(0,q.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75`}),(0,q.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-500`})]}),`live`]}):(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:[(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground/40`}),`connecting`]})}function Pe({filter:e,onSet:t}){return(0,q.jsx)(`div`,{className:`flex items-center gap-1`,children:je.map(n=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(n.key),"data-testid":`dash-feed-filter-${n.key}`,className:c(`border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition-colors`,e===n.key?`border-primary/40 bg-primary/5 text-foreground`:`border-dashed border-border text-muted-foreground/80 hover:border-border/80 hover:text-foreground`),children:n.label},n.key))})}function Fe({row:e,wsName:t}){return e.kind===`audit`?(0,q.jsx)(Ie,{record:e.record,wsName:t}):(0,q.jsx)(Le,{event:e.event})}function Ie({record:e,wsName:t}){let n=!g(e.status);return(0,q.jsxs)(`li`,{"data-testid":`dash-feed-audit-${e.id}`,className:`grid grid-cols-[5rem_1fr_auto] items-center gap-3 px-4 py-2 hover:bg-accent/15`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[10.5px] tabular-nums text-muted-foreground/70`,children:He(e.timestamp)}),(0,q.jsxs)(S,{to:`/audit?selected=${e.id}`,className:`group flex min-w-0 items-center gap-2`,title:e.tool_name,children:[(0,q.jsx)(ue,{className:c(`h-3.5 w-3.5 shrink-0`,n?`text-red-400`:`text-muted-foreground/60`)}),(0,q.jsx)(`span`,{className:`truncate font-mono text-[12px] text-foreground group-hover:text-primary`,children:e.tool_name}),(0,q.jsx)(_,{toolName:e.tool_name,className:`shrink-0`}),e.workspace_id&&(0,q.jsxs)(`span`,{className:`hidden truncate text-[11px] text-muted-foreground/70 lg:inline`,children:[`· `,e.workspace_name||t(e.workspace_id)]})]}),(0,q.jsx)(`span`,{className:`flex items-center gap-2`,children:n?(0,q.jsx)(L,{tone:e.status===`blocked`?`warn`:`critical`,variant:`outline`,className:`text-[10px]`,children:e.status}):(0,q.jsxs)(`span`,{className:`font-mono text-[10.5px] tabular-nums text-muted-foreground/70`,children:[e.latency_ms,`ms`]})})]})}function Le({event:e}){let t=e.link||Ue(e);return(0,q.jsxs)(`li`,{"data-testid":`dash-feed-signal-${e.message_id}`,className:`grid grid-cols-[5rem_1fr_auto] items-center gap-3 px-4 py-2 hover:bg-accent/15`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[10.5px] tabular-nums text-muted-foreground/70`,children:He(e.created_at)}),(0,q.jsxs)(S,{to:t,className:`group flex min-w-0 items-center gap-2`,title:e.title,children:[(0,q.jsx)(Re,{event:e}),(0,q.jsx)(`span`,{className:`truncate text-[12px] text-foreground group-hover:text-primary`,children:e.title}),e.agent_name&&(0,q.jsxs)(`span`,{className:`hidden truncate text-[11px] text-muted-foreground/70 lg:inline`,children:[`· `,e.agent_name]})]}),(0,q.jsx)(L,{tone:We(e.priority),variant:`outline`,className:`text-[10px]`,children:e.kind||e.source||`signal`})]})}function Re({event:e}){let t=e.kind||e.source,n=c(`h-3.5 w-3.5 shrink-0`,Ge(e.priority));return t?.includes(`approval`)?(0,q.jsx)(O,{className:n}):t?.includes(`mesh`)||e.source===`mesh`?(0,q.jsx)(k,{className:n}):(0,q.jsx)(ie,{className:n})}function ze({filter:e}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-1 px-4 py-8 text-center text-muted-foreground`,children:[(0,q.jsx)(x,{className:`h-5 w-5 text-muted-foreground/40`}),(0,q.jsx)(`p`,{className:`text-[12px]`,children:e===`all`?`Nothing happening yet. New tool calls and signals will tail here.`:`No ${e} events in this window.`})]})}function Be(e,t){let n=[...e.map(e=>({id:e.id,ts:new Date(e.timestamp).getTime(),kind:`audit`,record:e})),...t.map(e=>({id:`${e.id}:${e.message_id}`,ts:new Date(e.created_at).getTime(),kind:`signal`,event:e}))];return n.sort((e,t)=>t.ts-e.ts),n}function Ve(e,t){return t===`all`?e:t===`tools`?e.filter(e=>e.kind===`audit`):t===`signal`?e.filter(e=>e.kind===`signal`):e.filter(e=>e.kind===`audit`&&!g(e.record.status))}function He(e){try{return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return``}}function Ue(e){let t=e.kind||e.source;return t?.includes(`approval`)?`/approvals`:t?.startsWith(`memory`)?`/memory`:e.source===`mesh`||t?.includes(`mesh`)?`/mesh${e.message_id?`?msg=${e.message_id}`:``}`:`/signals`}function We(e){return e===`critical`?`critical`:e===`high`?`high`:e===`normal`?`info`:`muted`}function Ge(e){return e===`critical`?`text-red-400`:e===`high`?`text-orange-400`:e===`normal`?`text-sky-400`:`text-muted-foreground/60`}var Ke=15e3;function qe({workers:e,signals:t}){return(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,q.jsx)(Xe,{}),(0,q.jsx)(et,{workers:e}),(0,q.jsx)(rt,{}),(0,q.jsx)(at,{signals:t})]})}function Y({icon:e,title:t,href:n,children:r,testid:i}){return(0,q.jsxs)(`section`,{"data-testid":i,className:`border border-border bg-card/40`,children:[(0,q.jsx)(`header`,{className:`flex items-center justify-between border-b border-border/60 px-3 py-2`,children:(0,q.jsxs)(S,{to:n,className:`group inline-flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground/70 group-hover:text-foreground`,children:e}),t,(0,q.jsx)(`span`,{className:`text-muted-foreground/40 transition-colors group-hover:text-primary`,children:`›`})]})}),(0,q.jsx)(`ul`,{className:`divide-y divide-border/30`,children:r})]})}function X({message:e}){return(0,q.jsx)(`li`,{className:`px-3 py-2.5 text-[11.5px] text-muted-foreground/70`,children:e})}function Je({message:e}){return(0,q.jsxs)(`li`,{className:`px-3 py-2.5 text-[11.5px] text-red-400/80`,children:[(0,q.jsx)(`span`,{className:`font-mono`,children:`×`}),` `,e]})}function Ye(){return(0,q.jsx)(`li`,{className:`px-3 py-2.5 text-[11.5px] text-muted-foreground/40`,children:`Loading…`})}function Xe(){let{data:e,loading:t,error:n,refetch:r}=E((0,G.useCallback)(()=>D(6),[]));K(r,Ke),_e({onEvent:r});let i=e?.tasks??[];return(0,q.jsx)(Y,{icon:(0,q.jsx)(y,{className:`h-3.5 w-3.5`}),title:`Recent tasks`,href:`/tasks`,testid:`dash-recent-tasks`,children:t&&i.length===0?(0,q.jsx)(Ye,{}):n?(0,q.jsx)(Je,{message:`Failed to load. Will retry.`}):i.length===0?(0,q.jsx)(X,{message:`No tasks yet. Create one in /tasks to track work.`}):i.map(e=>(0,q.jsx)(Ze,{task:e},e.id))})}function Ze({task:e}){let t=Qe(e.status),n=$e(e.last_event,e.status);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(S,{to:`/tasks/${encodeURIComponent(e.id)}?workspace=${encodeURIComponent(e.workspace_id)}`,className:`group flex items-center gap-2 px-3 py-2 hover:bg-accent/15`,children:[(0,q.jsx)(`span`,{className:c(`h-1.5 w-1.5 shrink-0 rounded-full`,t.dot)}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] text-foreground group-hover:text-primary`,children:e.title}),n&&(0,q.jsx)(`span`,{className:c(`hidden shrink-0 font-mono text-[10px] uppercase tracking-wider lg:inline`,t.text),children:n}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:Z(e.updated_at)})]})})}function Qe(e){let t=e.toLowerCase();return t===`doing`||t===`in_progress`||t===`in-progress`||t===`working`?{dot:`bg-emerald-400 animate-pulse-slow`,text:`text-emerald-400`}:t===`review`||t===`in_review`?{dot:`bg-amber-400/80`,text:`text-amber-300`}:t===`blocked`||t===`stuck`?{dot:`bg-red-500`,text:`text-red-300`}:t===`done`||t===`closed`||t===`completed`?{dot:`bg-emerald-500/40`,text:`text-muted-foreground`}:t===`cancelled`||t===`canceled`||t===`wontfix`||t===`wont_fix`?{dot:`bg-muted-foreground/30`,text:`text-muted-foreground/70`}:t===`open`||t===`todo`||t===`backlog`?{dot:`bg-sky-400/80`,text:`text-sky-300`}:{dot:`bg-muted-foreground/40`,text:`text-muted-foreground/70`}}function $e(e,t){switch(e){case`status_changed`:return t;case`created`:return`new`;case`assigned`:return`assigned`;case`unassigned`:return`unassigned`;case`closed`:return`closed`;case`reopened`:return`reopened`;case`work_context_updated`:return`context`;case`lease_expired`:return`idle`;case`composed`:return`composed`;case`decomposed`:return`decomposed`;case``:return t;default:return e}}function et({workers:e}){let t=[...e].filter(e=>e.last_run_at).sort((e,t)=>new Date(t.last_run_at??0).getTime()-new Date(e.last_run_at??0).getTime()).slice(0,5);return(0,q.jsx)(Y,{icon:(0,q.jsx)(pe,{className:`h-3.5 w-3.5`}),title:`Recent worker runs`,href:`/workers`,testid:`dash-recent-workers`,children:t.length===0?(0,q.jsx)(X,{message:`No worker runs yet. Schedule one or run-now from /workers.`}):t.map(e=>(0,q.jsx)(tt,{worker:e},e.id))})}function tt({worker:e}){let t=e.last_run_status||`idle`,n=nt(t);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(S,{to:`/workers/${e.id}`,className:`group flex items-center gap-2 px-3 py-2 hover:bg-accent/15`,children:[(0,q.jsx)(`span`,{className:c(`h-1.5 w-1.5 shrink-0 rounded-full`,n.dot)}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] text-foreground group-hover:text-primary`,children:e.name}),(0,q.jsx)(`span`,{className:c(`shrink-0 font-mono text-[10px] uppercase tracking-wider`,n.text),children:t}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.last_run_at?Z(e.last_run_at):`—`})]})})}function nt(e){return e===`running`?{dot:`bg-emerald-400 animate-pulse-slow`,text:`text-emerald-400`}:e===`success`?{dot:`bg-emerald-500/70`,text:`text-muted-foreground`}:e===`failure`||e===`cap_exceeded`||e===`rejected`?{dot:`bg-red-500`,text:`text-red-300`}:e===`awaiting_approval`?{dot:`bg-amber-500`,text:`text-amber-300`}:e===`paused`?{dot:`bg-muted-foreground/40`,text:`text-muted-foreground`}:{dot:`bg-muted-foreground/40`,text:`text-muted-foreground/70`}}function rt(){let{data:e,loading:t,error:n,refetch:r}=E((0,G.useCallback)(()=>N(6),[]));K(r,Ke);let{events:i}=se(),a=i.find(e=>e.source===`memory`||(e.kind||``).startsWith(`memory`))?.id;st(a==null?void 0:String(a),r);let o=e?.memories??[];return(0,q.jsx)(Y,{icon:(0,q.jsx)(re,{className:`h-3.5 w-3.5`}),title:`Just learned`,href:`/memory/all`,testid:`dash-recent-memories`,children:t&&o.length===0?(0,q.jsx)(Ye,{}):n?(0,q.jsx)(Je,{message:`Failed to load. Will retry.`}):o.length===0?(0,q.jsx)(X,{message:`No memories yet. Open /memory to learn how to fill this in.`}):o.map(e=>(0,q.jsx)(it,{memory:e},e.id))})}function it({memory:e}){let[t,n]=(0,G.useState)(!1),r=e.body.length>e.summary.length,i=e.kind===`fact`?`bg-sky-400/80`:`bg-violet-400/80`;return(0,q.jsx)(`li`,{className:`group`,children:(0,q.jsxs)(`div`,{className:`px-3 py-2 hover:bg-accent/15`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:c(`h-1.5 w-1.5 shrink-0 rounded-full`,i)}),(0,q.jsx)(S,{to:`/memory/all?selected=${e.id}`,className:`min-w-0 flex-1 truncate text-[12px] text-foreground group-hover:text-primary`,title:e.name,children:e.summary||e.name}),r&&(0,q.jsx)(`button`,{type:`button`,"aria-label":t?`Collapse memory`:`Expand memory`,"aria-expanded":t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(e=>!e)},className:`shrink-0 text-muted-foreground/60 transition-colors hover:text-foreground`,children:t?(0,q.jsx)(he,{className:`h-3.5 w-3.5`}):(0,q.jsx)(m,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:Z(e.created_at)})]}),(0,q.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 pl-3.5 text-[10.5px] text-muted-foreground/70`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.agent_display||e.source_kind}),(0,q.jsx)(`span`,{className:`text-muted-foreground/30`,children:`·`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.scope_label})]}),t&&(0,q.jsx)(`pre`,{className:`mt-2 ml-3.5 max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded border border-border/40 bg-background/40 px-2 py-1.5 text-[11px] text-muted-foreground`,children:e.body})]})})}function at({signals:e}){let t=e.filter(e=>e.source===`mesh`||(e.kind||``).includes(`mesh`)).slice(0,5);return(0,q.jsx)(Y,{icon:(0,q.jsx)(k,{className:`h-3.5 w-3.5`}),title:`Recent mesh signals`,href:`/mesh`,testid:`dash-recent-mesh`,children:t.length===0?(0,q.jsx)(X,{message:`No mesh chatter yet. Connect a peer in /pairing to start.`}):t.map(e=>(0,q.jsx)(ot,{event:e},`${e.id}-${e.message_id}`))})}function ot({event:e}){return(0,q.jsx)(`li`,{children:(0,q.jsxs)(S,{to:`/mesh?msg=${e.message_id}`,className:`group flex items-center gap-2 px-3 py-2 hover:bg-accent/15`,children:[(0,q.jsx)(`span`,{className:c(`h-1.5 w-1.5 shrink-0 rounded-full`,e.priority===`critical`?`bg-red-400`:e.priority===`high`?`bg-orange-400`:`bg-emerald-400/80`)}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] text-foreground group-hover:text-primary`,children:e.title}),e.agent_name&&(0,q.jsx)(`span`,{className:`hidden shrink-0 truncate text-[10.5px] text-muted-foreground/70 lg:inline`,children:e.agent_name}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:Z(e.created_at)})]})})}function st(e,t){let n=(0,G.useRef)(e);(0,G.useEffect)(()=>{e&&n.current!==e&&(n.current=e,t())},[e,t])}function Z(e){let t=Date.now()-new Date(e).getTime();if(t<6e4)return`now`;let n=Math.floor(t/6e4);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function ct({entries:e}){if(e.length===0)return null;let t=e[0]?.count??1;return(0,q.jsxs)(I,{className:`border-destructive/30`,children:[(0,q.jsx)(P,{children:(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-destructive`,children:`Error Breakdown`})}),(0,q.jsx)(M,{className:`space-y-2`,children:e.map(e=>{let n=e.error_type===`blocked`;return(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,q.jsx)(`span`,{className:`truncate min-w-0 font-mono`,title:e.group_key,children:e.group_key}),(0,q.jsx)(L,{variant:`outline`,className:`shrink-0 text-[10px] px-1.5 py-0 ${n?`border-amber-500/40 text-amber-500`:`border-destructive/40 text-destructive`}`,children:n?`blocked`:`error`})]}),(0,q.jsx)(`span`,{className:`font-mono ${n?`text-amber-500`:`text-destructive`}`,children:e.count})]}),(0,q.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-muted`,children:(0,q.jsx)(`div`,{className:`h-full rounded-full ${n?`bg-amber-500/60`:`bg-destructive/60`}`,style:{width:`${e.count/t*100}%`}})})]},`${e.group_key}-${e.error_type}`)})})]})}function lt({metrics:e}){return e.pending_count+e.approved_count+e.denied_count+e.timed_out_count===0?null:(0,q.jsxs)(I,{children:[(0,q.jsx)(P,{children:(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Approval Metrics`})}),(0,q.jsxs)(M,{children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Pending`}),(0,q.jsx)(`div`,{className:`text-lg font-bold text-amber-400`,children:e.pending_count})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Approved`}),(0,q.jsx)(`div`,{className:`text-lg font-bold text-chart-2`,children:e.approved_count})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Denied`}),(0,q.jsx)(`div`,{className:`text-lg font-bold text-destructive`,children:e.denied_count})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Timed Out`}),(0,q.jsx)(`div`,{className:`text-lg font-bold text-muted-foreground`,children:e.timed_out_count})]})]}),e.avg_wait_ms>0&&(0,q.jsxs)(`div`,{className:`mt-3 border-t border-border/50 pt-3 text-xs text-muted-foreground`,children:[`Avg. wait: `,(0,q.jsxs)(`span`,{className:`font-mono`,children:[(e.avg_wait_ms/1e3).toFixed(1),`s`]})]})]})]})}function ut({stats:e,auditStats:t}){let n=e.tool_call,r=n.hits+n.misses,i=r>0?(n.hits/r*100).toFixed(1):`0.0`,a=t?t.success_count:0,o=t?t.blocked_count:0,s=t?t.error_count:0;return(0,q.jsxs)(I,{children:[(0,q.jsx)(P,{children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Cache & Routing`}),(0,q.jsxs)(`span`,{className:`text-xs font-mono text-muted-foreground`,children:[i,`% cache hit rate`]})]})}),(0,q.jsxs)(M,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(h,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{className:`uppercase tracking-wider`,children:`Tool Call Cache`})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Hits`}),(0,q.jsx)(`div`,{className:`font-mono font-medium text-chart-2`,children:n.hits})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Misses`}),(0,q.jsx)(`div`,{className:`font-mono font-medium`,children:n.misses})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Entries`}),(0,q.jsx)(`div`,{className:`font-mono font-medium`,children:n.entries})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Hit %`}),(0,q.jsx)(`div`,{className:`font-mono font-medium text-chart-2`,children:n.hit_rate>0?`${(n.hit_rate*100).toFixed(0)}%`:`-`})]})]})]}),(0,q.jsxs)(`div`,{className:`space-y-2 border-t border-border/50 pt-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(x,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{className:`uppercase tracking-wider`,children:`Route Decisions`})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-xs`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Allowed`}),(0,q.jsx)(`div`,{className:`font-mono font-medium text-chart-2`,children:a})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Blocked`}),(0,q.jsx)(`div`,{className:`font-mono font-medium text-amber-400`,children:o})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Errors`}),(0,q.jsx)(`div`,{className:`font-mono font-medium text-destructive`,children:s})]})]})]})]})]})}function dt(e){return e<5?`text-chart-2`:e<20?`text-amber-400`:`text-destructive`}function ft({entries:e}){return(0,q.jsxs)(I,{children:[(0,q.jsx)(P,{children:(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Tool Leaderboard`})}),(0,q.jsx)(M,{children:e.length===0?(0,q.jsx)(`div`,{className:`py-6 text-center text-xs text-muted-foreground/60`,children:`No tool calls in this period`}):(0,q.jsxs)(W,{children:[(0,q.jsx)(z,{children:(0,q.jsxs)(H,{className:`border-border/50 hover:bg-transparent`,children:[(0,q.jsx)(B,{children:`Tool`}),(0,q.jsx)(B,{className:`text-right`,children:`Calls`}),(0,q.jsx)(B,{className:`text-right`,children:`Errors`}),(0,q.jsx)(B,{className:`text-right`,children:`Error %`}),(0,q.jsx)(B,{className:`hidden sm:table-cell text-right`,children:`Avg Lat.`}),(0,q.jsx)(B,{className:`hidden md:table-cell text-right`,children:`P95 Lat.`})]})}),(0,q.jsx)(V,{children:e.map(e=>(0,q.jsxs)(H,{className:`border-border/30`,children:[(0,q.jsxs)(U,{children:[(0,q.jsx)(`div`,{className:`max-w-[20rem] truncate font-mono text-sm`,title:e.tool_name,children:e.tool_name}),e.server_name&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.server_name})]}),(0,q.jsx)(U,{className:`text-right font-mono text-sm`,children:e.call_count}),(0,q.jsx)(U,{className:`text-right font-mono text-sm`,children:e.error_count}),(0,q.jsxs)(U,{className:`text-right font-mono text-sm ${dt(e.error_rate)}`,children:[e.error_rate.toFixed(1),`%`]}),(0,q.jsxs)(U,{className:`hidden sm:table-cell text-right font-mono text-sm text-muted-foreground`,children:[Math.round(e.avg_latency_ms),`ms`]}),(0,q.jsxs)(U,{className:`hidden md:table-cell text-right font-mono text-sm text-muted-foreground`,children:[e.p95_latency_ms,`ms`]})]},e.tool_name))})]})})]})}function pt(e){return e<5?`text-chart-2`:e<20?`text-amber-400`:`text-destructive`}function mt(e,t){return t===`stopped`?`border-destructive/50`:t===`external`?`border-border/50`:e.error_rate>25?`border-destructive/50`:e.error_rate>10?`border-amber-500/50`:`border-chart-2/50`}function ht({entries:e,downstreams:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),o=new Map(t.map(e=>[e.server_id,e])),s=new Map(t.map(e=>[e.server_id,e.state])),c=new Map(e.map(e=>[e.server_id,e])),l=[...new Set([...t.map(e=>e.server_id),...e.map(e=>e.server_id)])],u=l.filter(e=>o.get(e)?.disabled),d=l.filter(e=>!o.get(e)?.disabled),f=d.filter(e=>{let t=c.get(e),n=s.get(e)??`unknown`;return t&&t.call_count>0||n!==`stopped`&&n!==`external`}),p=d.filter(e=>!f.includes(e)),m=e=>{let n=c.get(e),r=s.get(e)??`unknown`,i=t.find(t=>t.server_id===e),a=n?.server_name??i?.server_id??e,o=r===`disabled`;return(0,q.jsxs)(`div`,{className:`rounded-lg border-2 ${o?`border-border/30`:n?mt(n,r):`border-border/50`} bg-card p-4 space-y-2 ${o?`opacity-50`:``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(`span`,{className:`text-sm font-medium truncate min-w-0`,title:a,children:a}),(0,q.jsx)(L,{variant:r===`stopped`?`destructive`:r===`disabled`||r===`external`?`outline`:`secondary`,children:r})]}),!o&&n&&n.call_count>0?(0,q.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-xs`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Calls`}),(0,q.jsx)(`div`,{className:`font-mono font-medium`,children:n.call_count})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Error %`}),(0,q.jsxs)(`div`,{className:`font-mono font-medium ${pt(n.error_rate)}`,children:[n.error_rate.toFixed(1),`%`]})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-muted-foreground`,children:`Avg Lat.`}),(0,q.jsxs)(`div`,{className:`font-mono font-medium`,children:[Math.round(n.avg_latency_ms),`ms`]})]})]}):o?null:(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No calls in period`})]},e)},h=(e,t,n,r)=>(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`button`,{onClick:()=>r(!n),className:`text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n?`Hide`:`Show`,` `,e.length,` `,t,` server`,e.length===1?``:`s`,(0,q.jsx)(`span`,{className:`ml-1`,children:n?`▲`:`▼`})]}),n&&(0,q.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:e.map(m)})]});return(0,q.jsxs)(I,{children:[(0,q.jsx)(P,{children:(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Server Health`})}),(0,q.jsxs)(M,{className:`space-y-3`,children:[f.length===0&&p.length===0&&u.length===0&&(0,q.jsx)(`div`,{className:`py-6 text-center text-xs text-muted-foreground/60`,children:`No servers configured`}),f.length>0&&(0,q.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:f.map(m)}),p.length>0&&h(p,`idle`,n,r),u.length>0&&h(u,`disabled`,i,a)]})]})}function gt({sessions:e,wsName:t}){let n=T(),r=e.slice(0,10),i=e.length-r.length;return(0,q.jsxs)(I,{children:[(0,q.jsx)(P,{children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Active Sessions`}),(0,q.jsxs)(`span`,{className:`text-xs text-muted-foreground font-mono`,children:[e.length,` total`]})]})}),(0,q.jsx)(M,{children:e.length===0?(0,q.jsx)(`div`,{className:`py-6 text-center text-xs text-muted-foreground/60`,children:`No active sessions`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(W,{children:[(0,q.jsx)(z,{children:(0,q.jsxs)(H,{className:`border-border/50 hover:bg-transparent`,children:[(0,q.jsx)(B,{children:`Session`}),(0,q.jsx)(B,{children:`Client`}),(0,q.jsx)(B,{className:`hidden sm:table-cell`,children:`Workspace`}),(0,q.jsx)(B,{className:`hidden md:table-cell text-right`,children:`PID`}),(0,q.jsx)(B,{className:`text-right`,children:`Connected`})]})}),(0,q.jsx)(V,{children:r.map(e=>(0,q.jsxs)(H,{className:`border-border/30`,children:[(0,q.jsx)(U,{children:(0,q.jsxs)(C,{children:[(0,q.jsx)(w,{asChild:!0,children:(0,q.jsx)(`button`,{className:`font-mono text-xs text-cyan-400 hover:text-cyan-300 hover:underline`,onClick:()=>n(`/audit?session_id=${e.id}`),children:e.id.slice(0,8)})}),(0,q.jsx)(ce,{children:`View audit log for this session`})]})}),(0,q.jsxs)(U,{className:`text-sm text-muted-foreground`,children:[e.client_type,e.model_hint?(0,q.jsxs)(`span`,{className:`ml-1 text-xs text-muted-foreground/60`,children:[`(`,e.model_hint,`)`]}):null]}),(0,q.jsx)(U,{className:`hidden sm:table-cell text-sm text-muted-foreground`,children:e.workspace_id?t(e.workspace_id):`-`}),(0,q.jsx)(U,{className:`hidden md:table-cell text-right font-mono text-xs text-muted-foreground`,children:e.client_pid??`-`}),(0,q.jsx)(U,{className:`text-right font-mono text-sm text-muted-foreground`,children:be(e.connected_at)})]},e.id))})]}),i>0&&(0,q.jsxs)(`div`,{className:`mt-2 text-center text-xs text-muted-foreground`,children:[`+`,i,` more session`,i===1?``:`s`]})]})})]})}function _t({entries:e}){return(0,q.jsxs)(I,{children:[(0,q.jsx)(P,{children:(0,q.jsx)(j,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Route Hits`})}),(0,q.jsx)(M,{children:e.length===0?(0,q.jsx)(`div`,{className:`py-6 text-center text-xs text-muted-foreground/60`,children:`No route hits in this period`}):(0,q.jsxs)(W,{children:[(0,q.jsx)(z,{children:(0,q.jsxs)(H,{className:`border-border/50 hover:bg-transparent`,children:[(0,q.jsx)(B,{children:`Rule`}),(0,q.jsx)(B,{className:`text-right`,children:`Hits`}),(0,q.jsx)(B,{className:`text-right`,children:`Errors`})]})}),(0,q.jsx)(V,{children:e.map(e=>(0,q.jsxs)(H,{className:`border-border/30`,children:[(0,q.jsxs)(U,{children:[(0,q.jsx)(`div`,{className:`font-mono text-sm`,children:e.rule_name||e.path_glob||e.route_rule_id}),e.rule_name&&e.path_glob&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground font-mono`,children:e.path_glob})]}),(0,q.jsx)(U,{className:`text-right font-mono text-sm`,children:e.hit_count}),(0,q.jsx)(U,{className:`text-right font-mono text-sm text-destructive`,children:e.error_count>0?e.error_count:`-`})]},e.route_rule_id))})]})})]})}var vt={timeout:0,error:1,slow:2,ok:3},yt={ok:`ok`,slow:`slow`,timeout:`timeout`,error:`error`},bt={ok:`text-emerald-400 border-emerald-500/30 bg-emerald-500/[0.04]`,slow:`text-amber-400 border-amber-500/40 bg-amber-500/[0.05]`,timeout:`text-destructive border-destructive/40 bg-destructive/[0.05]`,error:`text-destructive border-destructive/40 bg-destructive/[0.05]`};function xt({timings:e}){if(e.length===0)return null;let t=[...e].sort((e,t)=>{let n=vt[e.status]-vt[t.status];return n===0?t.elapsed_ms-e.elapsed_ms:n}),n=t.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{ok:0,slow:0,timeout:0,error:0});return(0,q.jsxs)(`section`,{children:[(0,q.jsxs)(`header`,{className:`mb-2 flex items-baseline justify-between`,children:[(0,q.jsx)(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-muted-foreground/70`,children:`Server performance`}),(0,q.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground/60 tabular-nums`,children:wt(n)})]}),(0,q.jsx)(`div`,{className:`border border-border bg-card/30`,children:(0,q.jsx)(`ul`,{className:`divide-y divide-border/40`,children:t.map(e=>(0,q.jsx)(St,{timing:e},e.server_id))})}),(0,q.jsxs)(`p`,{className:`mt-2 text-[10.5px] leading-relaxed text-muted-foreground/60`,children:[`Snapshot from the most recent catalog refresh. `,(0,q.jsx)(`span`,{className:`text-amber-400`,children:`Slow`}),` = took longer than 3s but still inside the per-server budget. `,(0,q.jsx)(`span`,{className:`text-destructive`,children:`Timeout`}),` means the server was skipped that round — bump `,(0,q.jsx)(`code`,{className:`text-foreground/70`,children:`PerServerListToolsTimeout`}),` if it chronically misses.`]})]})}function St({timing:e}){return(0,q.jsx)(`li`,{children:(0,q.jsxs)(S,{to:`/workspaces?focus_server=${encodeURIComponent(e.server_id)}`,"data-testid":`server-perf-row-${e.server_id}`,className:`flex items-center gap-3 px-3 py-2 font-mono text-[12px] transition-colors hover:bg-muted/30`,children:[(0,q.jsx)(`span`,{className:c(`inline-flex w-[68px] shrink-0 items-center justify-center border px-1.5 py-px text-[10px] uppercase tracking-wider`,bt[e.status]),children:yt[e.status]}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.server_name}),(0,q.jsx)(`span`,{className:`shrink-0 tabular-nums text-muted-foreground`,children:Ct(e.elapsed_ms)})]})})}function Ct(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e}ms`}function wt(e){let t=[];return e.timeout>0&&t.push(`${e.timeout} timeout`),e.error>0&&t.push(`${e.error} error`),e.slow>0&&t.push(`${e.slow} slow`),e.ok>0&&t.push(`${e.ok} ok`),t.join(` · `)}function Tt({data:e,sessions:t,wsName:n}){let r=e.approval_metrics&&e.approval_metrics.pending_count+e.approval_metrics.approved_count+e.approval_metrics.denied_count+e.approval_metrics.timed_out_count>0,i=(e.error_breakdown??[]).length>0;return(0,q.jsxs)(`details`,{"data-testid":`dash-trends`,className:`group border border-border bg-card/20`,children:[(0,q.jsxs)(`summary`,{className:`flex cursor-pointer items-center justify-between border-b border-border/60 px-4 py-2 hover:bg-accent/15`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Trends, throughput & server health`}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground/60 group-open:hidden`,children:`show`}),(0,q.jsx)(`span`,{className:`hidden font-mono text-[10px] uppercase tracking-wider text-muted-foreground/60 group-open:inline`,children:`hide`})]}),(0,q.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,q.jsx)(xt,{timings:e.server_timings??[]}),(0,q.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,q.jsx)(gt,{sessions:t,wsName:n}),(0,q.jsx)(ut,{stats:e.cache_stats??{tool_call:{hits:0,misses:0,evictions:0,entries:0,hit_rate:0},route_resolution:{hits:0,misses:0,evictions:0,entries:0,hit_rate:0}},auditStats:e.stats})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 ${i?`lg:grid-cols-2`:``}`,children:[(0,q.jsx)(ft,{entries:e.tool_leaderboard??[]}),i&&(0,q.jsx)(ct,{entries:e.error_breakdown??[]})]}),(0,q.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,q.jsx)(ht,{entries:e.server_health??[],downstreams:e.active_downstreams??[]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(_t,{entries:e.route_hit_map??[]}),r&&e.approval_metrics&&(0,q.jsx)(lt,{metrics:e.approval_metrics})]})]})]})]})}function Et({state:e,range:t,setRange:n,ranges:r}){return(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Dashboard`}),(0,q.jsx)(Dt,{state:e})]}),(0,q.jsx)(f,{type:`single`,value:t,onValueChange:e=>{e&&n(e)},variant:`outline`,size:`sm`,"aria-label":`Dashboard time range`,children:r.map(e=>(0,q.jsx)(d,{value:e,className:`font-mono text-xs`,"data-testid":`dash-range-${e}`,children:e},e))})]})}function Dt({state:e}){let t={quiet:{label:`quiet`,cls:`border-border text-muted-foreground`,dot:`bg-muted-foreground/50`},busy:{label:`live`,cls:`border-emerald-500/40 text-emerald-400`,dot:`bg-emerald-500`},trouble:{label:`attention`,cls:`border-amber-500/40 text-amber-400`,dot:`bg-amber-500`}}[e];return(0,q.jsxs)(`span`,{"data-testid":`dash-state-${e}`,className:`inline-flex items-center gap-1.5 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider ${t.cls}`,children:[(0,q.jsx)(`span`,{className:`inline-flex h-1.5 w-1.5 rounded-full ${t.dot}`}),t.label]})}function Ot(){return(0,q.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-6 py-8`,children:[(0,q.jsxs)(`div`,{className:`space-y-2 text-center`,children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Welcome to MCPlexer`}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`One MCP gateway for your local AI tools. Connect a client, then choose which integrations each workspace can use.`})]}),(0,q.jsx)(me,{variant:`hero`}),(0,q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,q.jsxs)(S,{to:`/harness-setup`,"data-testid":`first-run-install`,className:`group flex flex-col gap-1 border border-border bg-card p-4 transition-colors hover:border-primary/40 hover:bg-card/80`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(x,{className:`h-4 w-4 text-primary`}),(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:`1. Set up an AI harness`})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Claude Code, Cursor, Codex, OpenCode, Gemini, MiMoCode, and Pi - auto-detected where possible.`})]}),(0,q.jsxs)(S,{to:`/setup`,"data-testid":`first-run-setup`,className:`group flex flex-col gap-1 border border-border bg-card p-4 transition-colors hover:border-primary/40 hover:bg-card/80`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(oe,{className:`h-4 w-4 text-primary`}),(0,q.jsx)(`span`,{className:`text-sm font-medium`,children:`2. Add an integration`})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Pick from the catalog: ClickUp, Linear, Postgres, GitHub, and more.`})]})]})]})}function kt({onRetry:e}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,q.jsx)(x,{className:`h-3.5 w-3.5 animate-pulse-slow`}),`Loading dashboard...`]}),(0,q.jsx)(jt,{onRetry:e,testid:`dash-loading-retry`,tone:`muted`})]})}function At({message:e,onRetry:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,q.jsxs)(`p`,{className:`font-mono text-sm text-destructive`,children:[`Error: `,e]}),(0,q.jsx)(jt,{onRetry:t,testid:`dash-error-retry`,tone:`destructive`})]})}function jt({onRetry:e,testid:t,tone:n}){return(0,q.jsx)(`button`,{type:`button`,onClick:e,"data-testid":t,className:`border px-2.5 py-1 font-mono text-[11px] uppercase tracking-wider transition-colors ${n===`destructive`?`border-destructive/40 bg-destructive/5 text-destructive hover:bg-destructive/10`:`border-border bg-card/40 text-muted-foreground hover:border-border/80 hover:text-foreground`}`,children:`retry`})}var Q=[`1h`,`6h`,`24h`,`7d`],$=3e4;function Mt(){let[e,t]=ne(),[o,s]=(0,G.useState)(()=>Nt(e));(0,G.useEffect)(()=>{let n=e.get(`range`);if(o===`1h`&&!n||n===o)return;let r=new URLSearchParams(e);o===`1h`?r.delete(`range`):r.set(`range`,o),t(r,{replace:!0})},[o,e,t]);let{data:c,loading:l,error:d,refetch:f}=E((0,G.useCallback)(()=>r(o),[o])),{data:p}=E((0,G.useCallback)(()=>n(),[])),{data:m}=E((0,G.useCallback)(()=>u(),[])),h=e=>p?.find(t=>t.id===e)?.name??e,g=e=>m?.find(t=>t.id===e)?.name??e,{data:_,refetch:v}=E((0,G.useCallback)(()=>ge(),[])),{data:y,refetch:te}=E((0,G.useCallback)(()=>le(),[])),{data:b,refetch:x}=E((0,G.useCallback)(()=>de({pending_only:!0}),[])),{data:re,refetch:ie}=E((0,G.useCallback)(()=>i({mode:`all`}),[])),{data:S,refetch:oe}=E((0,G.useCallback)(()=>a(),[])),{records:C,connected:ce}=ee({}),{pending:w}=ae(),{events:T}=se(),{serversNeedingCreds:D,workspacesWithoutRoutes:O}=ye();K(f,1e4),K(v,$),K(oe,$),K(te,$),K(x,$),K(ie,6e4);let k=(0,G.useMemo)(()=>{let e=c?.recent_calls??[],t=new Set(C.map(e=>e.id)),n=[...C,...e.filter(e=>!t.has(e.id))];return n.sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),n.slice(0,50)},[C,c?.recent_calls]),A=c?.active_session_list??[];if(l&&!c)return(0,q.jsx)(kt,{onRetry:f});if(d&&!c)return(0,q.jsx)(At,{message:d,onRetry:f});if(!c)return null;let ue=(c.active_downstreams??[]).length,j=c.stats?.total_requests??0,M=O.length>0,N=D.length>0;if(j===0&&(ue===0||M||N))return(0,q.jsx)(Ot,{});let P=(y?.facts??0)+(y?.notes??0),F=_?.filter(e=>{let t=e.last_run_status;return t===`failure`||t===`cap_exceeded`||t===`rejected`}).length??0,I=_?.filter(e=>e.last_run_status===`running`).length??0,fe=S?.agents?.length??0,pe=c.peers_online??0,me=c.peers_total??0,he=Math.max(0,me-pe),L=c.stats&&c.stats.total_requests>0?(c.stats.error_count??0)/c.stats.total_requests*100:0,R=c?.unreviewed_delegations??0,z=w.length>0||F>0||(c.stats?.blocked_count??0)>0||L>=5||R>0,B=A.length>0||k.length>0||j>0,V=z?`trouble`:B?`busy`:`quiet`,H=Pt({sessions:A.length,meshAgents:fe,runningWorkers:I,pendingApprovals:w.length,totalMemories:P,skillCount:re?.length??0});return(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsx)(Et,{state:V,range:o,setRange:s,ranges:Q}),(0,q.jsx)(Ce,{items:H}),(0,q.jsx)(De,{input:{pendingApprovals:w.length,pendingWorkerApprovals:_?.filter(e=>e.last_run_status===`awaiting_approval`).length??0,unhealthyWorkers:F,offlinePeers:he,pendingMemoryOffers:b?.length??0,expiringSecrets:0,serversNeedingCreds:D,workspacesWithoutRoutes:O,unreviewedDelegations:R}}),(0,q.jsx)(Me,{audit:k.slice(0,30),signal:T.slice(0,40),connected:ce,wsName:h}),(0,q.jsx)(qe,{workers:_??[],signals:T}),(0,q.jsx)(Tt,{data:c,sessions:A,wsName:h,asName:g})]})}function Nt(e){let t=e.get(`range`);return t&&Q.includes(t)?t:`1h`}function Pt(e){return[{label:`Live sessions`,value:e.sessions,detail:e.sessions>0?`agents talking to the gateway`:`no sessions`,href:`/audit`,tone:e.sessions>0?`live`:`idle`},{label:`Mesh agents`,value:e.meshAgents,detail:e.meshAgents>0?`connected across local + peers`:`no agents`,href:`/mesh`,tone:e.meshAgents>0?`live`:`idle`},{label:`Workers running`,value:e.runningWorkers,detail:e.runningWorkers>0?`chewing tokens right now`:`all idle`,href:`/workers`,tone:e.runningWorkers>0?`live`:`idle`},{label:`Pending approvals`,value:e.pendingApprovals,detail:e.pendingApprovals>0?`waiting on your decision`:`all cleared`,href:`/approvals`,tone:e.pendingApprovals===0?`idle`:e.pendingApprovals>3?`critical`:`warn`},{label:`Memories`,value:e.totalMemories,detail:e.totalMemories>0?`persistent facts + notes`:`not learning yet`,href:`/memory`,tone:e.totalMemories>0?`info`:`idle`},{label:`Skills`,value:e.skillCount,detail:e.skillCount>0?`recipes in the shared library`:`no skills published`,href:`/skills`,tone:e.skillCount>0?`info`:`idle`}]}export{Mt as DashboardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/DelegationsPage-C93JHZkX.js b/internal/web/dist/assets/DelegationsPage-C93JHZkX.js deleted file mode 100644 index 2cf96f9..0000000 --- a/internal/web/dist/assets/DelegationsPage-C93JHZkX.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,et as r,in as i,nn as a,on as o,pt as s,vt as c}from"./client-CaIRceNv.js";import{t as l}from"./createLucideIcon-WB390fY6.js";import{t as u}from"./chevron-right-CyhRDGe7.js";import{t as d}from"./play-YbzkBfB8.js";import{t as f}from"./square-BOz_C5qq.js";import{t as p}from"./star-CkF1s_Xa.js";import{Ar as m,Cn as h,Dt as g,Fn as _,Fr as v,Ft as y,Mt as b,Pt as x,Qn as S,Rt as ee,S as C,br as w,d as T,f as E,hn as te,jr as D,jt as ne,lr as re,m as O,mn as ie,n as k,nr as ae,on as oe,p as A,qn as se,sn as ce,t as le,u as j,ur as M,v as ue,wr as de,xr as fe,y as N,yr as pe,zn as P}from"./index-BDLzoIgt.js";import{t as me}from"./markdown-BxN4l9DE.js";import{t as he}from"./textarea-BiOhexhg.js";import{t as F}from"./WorkerLiveTail-WfoppFSb.js";var ge=l(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),I=e(t(),1),L=o(),_e={workspaceID:``,objective:``,handoff:``,name:``,taskID:``,taskKind:``,workerMode:`execute`,reviewRequired:!0,modelSelectionMode:`single`,modelCandidateIndex:0,modelCandidatesJSON:``,modelProfileID:``,modelProvider:`opencode_cli`,modelID:`minimax/MiniMax-M3`,modelEndpointURL:``,secretScopeID:``,parallelism:1,parentModel:``,parentInputTokens:0,parentOutputTokens:0,parentCostUSD:0,baselineTokensEstimate:0,baselineCostUSD:0,maxToolCalls:80,maxWallClockSeconds:3600,maxOutputTokens:0},R=[{value:`opencode_cli`,label:`OpenCode CLI`},{value:`mimo_cli`,label:`Xiaomi MiMo CLI`},{value:`claude_cli`,label:`Claude CLI`},{value:`grok_cli`,label:`xAI Grok CLI`},{value:`gemini_cli`,label:`Google Gemini CLI`},{value:`codex_cli`,label:`OpenAI Codex CLI`},{value:`pi_cli`,label:`Pi CLI`},{value:`openai_compat`,label:`OpenAI compatible`},{value:`anthropic`,label:`Anthropic API`},{value:`openai`,label:`OpenAI API`}],z=[{key:`1h`,label:`1h`,ms:3600*1e3},{key:`12h`,label:`12h`,ms:720*60*1e3},{key:`24h`,label:`24h`,ms:1440*60*1e3},{key:`7d`,label:`7d`,ms:10080*60*1e3},{key:`all`,label:`All`}];function ve(){let[e,t]=(0,I.useState)(_e),[i,o]=(0,I.useState)(!1),[l,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(`all`),[m,h]=(0,I.useState)(`12h`),[g,y]=(0,I.useState)(``),{data:b}=C((0,I.useCallback)(()=>n(),[])),{data:x}=C((0,I.useCallback)(()=>c(),[])),{data:S}=C((0,I.useCallback)(()=>s(),[])),{data:w,refetch:T}=C((0,I.useCallback)(()=>r(),[])),E=w?.settings?.delegation_disabled_providers??{};(0,I.useEffect)(()=>{e.secretScopeID||!S?.length||t(e=>({...e,secretScopeID:S[0].id}))},[e.secretScopeID,S]);let ne=(0,I.useMemo)(()=>x?.find(t=>t.id===e.modelProfileID)??null,[x,e.modelProfileID]),O=ne?.known_models??[],{data:k,loading:oe,error:A,refetch:se}=C((0,I.useCallback)(()=>te({workspaceId:e.workspaceID||void 0,limit:200}),[e.workspaceID])),{data:le,refetch:j}=C((0,I.useCallback)(()=>ie({workspaceId:e.workspaceID||void 0,taskKind:e.taskKind.trim()||void 0,limit:20}),[e.workspaceID,e.taskKind])),M=(0,I.useCallback)(()=>{se(),j()},[se,j]);(0,I.useEffect)(()=>{let e=!1,t=ee(`workers`,()=>{e||(e=!0,window.setTimeout(()=>{e=!1,M()},250))}),n;n&&window.clearInterval(n),n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState===`visible`&&M()},6e4);let r=()=>{document.visibilityState===`visible`&&M()};return document.addEventListener(`visibilitychange`,r),()=>{t(),n&&window.clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[M]);let[ue,de]=(0,I.useState)(!1);async function pe(e,t){if(!w?.settings)return;let n={...w.settings.delegation_disabled_providers??{},[e]:t},r={};for(let[e,t]of Object.entries(n))t&&(r[e]=!0);de(!0);try{await a({...w.settings,delegation_disabled_providers:r}),await T(),await j()}catch(e){D.error(e instanceof Error?e.message:`Failed to update provider switches`)}finally{de(!1)}}function P(e,n){t(t=>({...t,[e]:n}))}function me(e){let n=x?.find(t=>t.id===e);t(t=>({...t,modelProfileID:e===`__manual__`?``:e,...n?{modelProvider:n.provider,modelEndpointURL:n.endpoint_url||``,secretScopeID:n.secret_scope_id||t.secretScopeID,modelID:n.known_models?.[0]||t.modelID}:{}}))}async function he(){if(!e.workspaceID){D.error(`Choose a workspace`);return}if(!e.objective.trim()){D.error(`Objective is required`);return}let n=e.modelCandidatesJSON.trim().length>0;if(e.modelSelectionMode!==`capacity`&&!n&&!e.modelProfileID&&(!e.modelProvider||!e.modelID.trim())){D.error(`Choose a model profile or provider/model`);return}let r;try{r=gt(e.modelCandidatesJSON)}catch(e){D.error(e instanceof Error?e.message:`Candidate models are invalid`);return}o(!0);try{let n=await ce({workspace_id:e.workspaceID,objective:e.objective.trim(),handoff:e.handoff.trim()||void 0,name:e.name.trim()||void 0,task_id:e.taskID.trim()||void 0,task_kind:e.taskKind.trim()||void 0,worker_mode:e.workerMode,review_required:e.reviewRequired,model_profile_id:e.modelProfileID||void 0,model_provider:e.modelProvider,model_id:e.modelID.trim(),model_endpoint_url:e.modelEndpointURL.trim()||void 0,secret_scope_id:e.secretScopeID||void 0,model_selection_mode:e.modelSelectionMode,model_candidate_index:e.modelCandidateIndex||void 0,model_candidates:r,parallelism:e.parallelism,parent_model:e.parentModel.trim()||void 0,parent_input_tokens:$(e.parentInputTokens),parent_output_tokens:$(e.parentOutputTokens),parent_cost_usd:$(e.parentCostUSD),baseline_tokens_estimate:$(e.baselineTokensEstimate),baseline_cost_usd:$(e.baselineCostUSD),max_tool_calls:$(e.maxToolCalls),max_wall_clock_seconds:$(e.maxWallClockSeconds),max_output_tokens:$(e.maxOutputTokens)});D.success(`Delegated to ${n.dispatches.length} worker context${n.dispatches.length===1?``:`s`}`),t(e=>({...e,objective:``,handoff:``,taskID:``,name:``,modelCandidatesJSON:``})),M()}catch(e){D.error(e instanceof Error?e.message:`Delegation failed`)}finally{o(!1)}}let F=(0,I.useMemo)(()=>We(k??[],m),[k,m]),ge=(0,I.useMemo)(()=>(k??[]).filter($e),[k]),R=(0,I.useMemo)(()=>Ge(F.filter(e=>!$e(e)),g),[F,g]),z=(0,I.useMemo)(()=>Ue(F),[F]),ve=(0,I.useMemo)(()=>rt(F),[F]),Ce=(0,I.useMemo)(()=>Je(R),[R]),we=(0,I.useMemo)(()=>Je(F),[F]),B=(0,I.useMemo)(()=>Ye(R,f),[R,f]),Ee=(0,I.useMemo)(()=>Xe(B,f),[B,f]),[V,Oe]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`space-y-5`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold tracking-tight`,children:[(0,L.jsx)(re,{className:`h-6 w-6`}),` Delegations`]}),(0,L.jsxs)(`p`,{className:`mt-1 max-w-3xl text-sm text-muted-foreground`,children:[`One-shot worker runs spawned from a parent session. For scheduled automation, use`,` `,(0,L.jsx)(v,{to:`/workers`,className:`underline hover:text-foreground`,children:`Workers`}),`.`]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(_,{variant:`outline`,asChild:!0,children:(0,L.jsx)(v,{to:`/delegations/models`,children:`Model ranks`})}),(0,L.jsx)(_,{variant:`outline`,asChild:!0,children:(0,L.jsx)(v,{to:`/model-providers`,children:`Model profiles`})})]})]}),(0,L.jsx)(ye,{liveCount:ge.length,periodCounts:we,historicalCounts:Ce,summary:z,period:m,filteredCount:B.length,totalHistoricalCount:R.length,periodTotalCount:F.length,filter:f,onFilterChange:p}),(0,L.jsx)(De,{rows:ge,onReviewed:M}),A&&(0,L.jsx)(`div`,{className:`border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:A}),(0,L.jsx)(be,{counts:Ce,filter:f,filteredCount:B.length,totalCount:R.length,period:m,query:g,onFilterChange:p,onPeriodChange:h,onQueryChange:y}),oe&&!k?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(ae,{className:`h-4 w-4 animate-spin`}),` Loading delegations...`]}):k&&k.length>0?(0,L.jsxs)(`div`,{className:`space-y-3`,children:[B.length===0&&(0,L.jsx)(`div`,{className:`border border-border bg-card/40 p-5 text-sm text-muted-foreground`,children:`No historical runs match these filters.`}),Ee.map(e=>(0,L.jsx)(xe,{title:e.title,count:e.rows.length,children:e.rows.map(e=>(0,L.jsx)(Fe,{delegation:e,onReviewed:M},e.id))},e.key))]}):(0,L.jsx)(`div`,{className:`border border-border bg-card/40 p-5 text-sm text-muted-foreground`,children:(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,L.jsx)(re,{className:`h-8 w-8 text-muted-foreground/60`}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`font-medium text-foreground`,children:`No delegated runs yet`}),(0,L.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`Delegations are one-shot worker contexts spawned on demand from a parent session. Each run executes a single objective and returns results for review.`}),(0,L.jsxs)(`p`,{className:`max-w-md text-[11px] text-muted-foreground/70`,children:[`For durable automation on a schedule, use`,` `,(0,L.jsx)(v,{to:`/workers`,className:`underline hover:text-foreground`,children:`Workers`}),`.`]})]})]})}),(0,L.jsx)(Se,{open:l,onOpenChange:d,form:e,set:P,disabledProviders:E,profiles:x??[],scopes:S??[],workspaces:b??[],selectedProfile:ne,modelSuggestions:O,applyProfile:me,submitting:i,onSubmit:he}),(0,L.jsxs)(`section`,{className:`border border-border bg-card/30`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>Oe(!V),"aria-expanded":V,className:`flex w-full items-center justify-between gap-3 px-4 py-2.5 text-left transition-colors hover:bg-card/50`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[V?(0,L.jsx)(fe,{className:`h-4 w-4 shrink-0 text-muted-foreground`}):(0,L.jsx)(u,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-semibold`,children:`Advanced`}),(0,L.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:`Provider switches, model performance, and capacity routing.`})]})]}),(0,L.jsx)(N,{variant:`outline`,className:`shrink-0 text-[10px] uppercase`,children:V?`open`:`collapsed`})]}),V&&(0,L.jsxs)(`div`,{className:`space-y-4 border-t border-border/50 p-4`,children:[(0,L.jsx)(Ne,{disabled:E,onToggle:pe,saving:ue}),(0,L.jsx)(Te,{summary:z,capacityRows:le??[],modelRank:ve,period:m})]})]})]})}function ye({liveCount:e,periodCounts:t,historicalCounts:n,summary:r,period:a,filteredCount:o,totalHistoricalCount:s,periodTotalCount:c,filter:l,onFilterChange:u}){let d=r.baselineKnown||r.costBaselineKnown;return(0,L.jsxs)(`section`,{className:`border border-border bg-card/40 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[{key:`live`,label:`Live`,count:e,accent:e>0?`live`:void 0},{key:`attention`,label:`Attention`,count:t.attention,accent:t.attention>0?`warn`:void 0,filterKey:`attention`},{key:`needs_review`,label:`Needs review`,count:t.needsReview,accent:t.needsReview>0?`warn`:void 0,filterKey:`needs_review`},{key:`success`,label:`Success`,count:t.success,accent:`good`,filterKey:`success`},{key:`failure`,label:`Failure`,count:t.failure,filterKey:`failure`},{key:`reviewed`,label:`Reviewed`,count:t.reviewed,filterKey:`reviewed`}].map(t=>{let n=t.filterKey?l===t.filterKey:!1,r=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:t.label}),(0,L.jsx)(`span`,{className:i(`font-mono text-sm font-semibold tabular-nums`,t.accent===`live`&&`text-sky-300`,t.accent===`warn`&&`text-amber-300`,t.accent===`good`&&`text-emerald-300`),children:t.count})]});if(!t.filterKey)return(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 border border-border/60 bg-background/50 px-2 py-1`,children:[e>0&&(0,L.jsx)(m,{className:`h-3 w-3 text-sky-300`}),r]},t.key);let a=t.filterKey;return(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(a),"aria-pressed":n,className:i(`flex items-center gap-1.5 border px-2 py-1 text-left transition-colors`,n?`border-primary/50 bg-primary/10`:`border-border/60 bg-background/50 hover:bg-background/80`),children:r},t.key)})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[`Frontier avoided`,` `,(0,L.jsx)(`span`,{className:`font-mono font-medium text-foreground`,children:d?Z(r.frontierAvoided):`—`})]}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[`Cost saved`,` `,(0,L.jsx)(`span`,{className:i(`font-mono font-medium`,r.costBaselineKnown&&r.costSaved>=0?`text-emerald-300`:`text-foreground`),children:r.costBaselineKnown?ft(r.costSaved):`—`})]}),(0,L.jsxs)(`span`,{className:`tabular-nums`,children:[`Worker tokens `,(0,L.jsx)(`span`,{className:`font-mono font-medium text-foreground`,children:X(r.workerTokens)})]})]})]}),(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 border-t border-border/40 pt-2 text-[10px] text-muted-foreground`,children:[(0,L.jsxs)(`span`,{children:[(0,L.jsx)(N,{variant:`outline`,className:`mr-1.5 text-[9px] uppercase`,children:nt(a)}),c,` in period · `,o,`/`,s,` history shown`,n.needsReview>0&&l!==`needs_review`&&(0,L.jsxs)(`span`,{className:`ml-2 text-amber-300`,children:[n.needsReview,` awaiting review in history`]})]}),(0,L.jsx)(`button`,{type:`button`,className:`text-primary hover:underline`,onClick:()=>u(`all`),children:`Reset filters`})]})]})}function be({counts:e,filter:t,filteredCount:n,totalCount:r,period:i,query:a,onFilterChange:o,onPeriodChange:s,onQueryChange:c}){let l=[{key:`all`,label:`All`,count:e.all},{key:`attention`,label:`Attention`,count:e.attention},{key:`needs_review`,label:`Needs review`,count:e.needsReview},{key:`success`,label:`Success`,count:e.success},{key:`failure`,label:`Failure`,count:e.failure},{key:`interrupted`,label:`Interrupted`,count:e.interrupted},{key:`cancelled`,label:`Cancelled`,count:e.cancelled},{key:`reviewed`,label:`Reviewed`,count:e.reviewed}];return(0,L.jsxs)(`section`,{className:`space-y-2 border border-border bg-card/30 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`h2`,{className:`text-[12px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[`History · `,n,`/`,r]}),(0,L.jsxs)(`div`,{className:`relative w-full min-w-48 sm:w-64`,children:[(0,L.jsx)(se,{className:`pointer-events-none absolute left-2 top-2 h-3.5 w-3.5 text-muted-foreground`}),(0,L.jsx)(y,{value:a,onChange:e=>c(e.target.value),className:`h-8 pl-7 text-xs`,placeholder:`Search objective, ids, model, output...`})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[z.map(e=>(0,L.jsxs)(_,{type:`button`,size:`xs`,variant:i===e.key?`default`:`outline`,"aria-pressed":i===e.key,onClick:()=>s(e.key),className:`h-6 gap-1 px-2 tabular-nums`,children:[(0,L.jsx)(pe,{className:`h-3 w-3`}),e.label]},e.key)),(0,L.jsx)(`span`,{className:`mx-1 hidden h-4 w-px bg-border/60 sm:inline`,"aria-hidden":`true`}),l.map(e=>(0,L.jsxs)(_,{type:`button`,size:`xs`,variant:t===e.key?`default`:`outline`,"aria-pressed":t===e.key,onClick:()=>o(e.key),className:`h-6 px-2 tabular-nums`,children:[e.label,(0,L.jsx)(`span`,{className:`font-mono text-[9px] opacity-75`,children:e.count})]},e.key))]})]})}function xe({title:e,count:t,children:n}){return t===0?null:(0,L.jsxs)(`section`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border border-border/60 bg-background/50 px-3 py-2`,children:[(0,L.jsx)(`h2`,{className:`text-[12px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,L.jsx)(N,{variant:`outline`,className:`font-mono text-[10px]`,children:t})]}),(0,L.jsx)(`div`,{className:`space-y-1.5`,children:n})]})}function Se({open:e,onOpenChange:t,...n}){return(0,L.jsxs)(`section`,{className:`border border-border bg-card/30`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),"aria-expanded":e,className:`flex w-full items-center justify-between gap-3 px-4 py-2.5 text-left transition-colors hover:bg-card/50`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(e?fe:u,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block text-sm font-semibold`,children:`Add delegation`}),(0,L.jsx)(`span`,{className:`block truncate text-[11px] text-muted-foreground`,children:`Spawn worker contexts only when you need to run a new comparison.`})]})]}),(0,L.jsx)(N,{variant:`outline`,className:`shrink-0 text-[10px] uppercase`,children:e?`open`:`collapsed`})]}),e&&(0,L.jsx)(`div`,{className:`border-t border-border/50 p-3`,children:(0,L.jsx)(Ce,{...n})})]})}function Ce({form:e,set:t,disabledProviders:n,profiles:r,scopes:i,workspaces:a,selectedProfile:o,modelSuggestions:s,applyProfile:c,submitting:l,onSubmit:u}){let d=Ae(n,{provider:e.modelProvider,modelID:e.modelID,endpoint:e.modelEndpointURL,label:o?.name}),f=o?Ae(n,{provider:o.provider,modelID:o.known_models?.[0]||e.modelID,endpoint:o.endpoint_url,label:o.name}):``,p=ke(n),m=e.modelSelectionMode!==`capacity`&&!!(d||f);return(0,L.jsx)(le,{children:(0,L.jsxs)(k,{className:`space-y-4 p-4`,children:[p.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border border-amber-500/30 bg-amber-500/5 px-3 py-2 text-xs text-amber-200`,children:[(0,L.jsx)(P,{className:`h-4 w-4 shrink-0`}),(0,L.jsx)(`span`,{children:`Routing disabled:`}),p.map(e=>(0,L.jsx)(N,{variant:`outline`,className:`border-amber-500/40 text-[10px] uppercase text-amber-200`,children:e},e)),(0,L.jsx)(`span`,{className:`text-amber-100/70`,children:`Capacity mode will skip these groups; explicit selections are blocked below.`})]}),m&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:[(0,L.jsx)(P,{className:`h-4 w-4 shrink-0`}),(0,L.jsxs)(`span`,{children:[f||d,`. Pick an enabled route or re-enable the group in Delegation provider switches.`]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-[1.2fr_0.8fr]`,children:[(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(U,{label:`Objective`,children:(0,L.jsx)(he,{value:e.objective,onChange:e=>t(`objective`,e.target.value),className:`min-h-24`,placeholder:`Implement the feature slice, inspect the files, run focused tests, and return a concise handoff.`})}),(0,L.jsx)(U,{label:`Handoff Packet`,children:(0,L.jsx)(he,{value:e.handoff,onChange:e=>t(`handoff`,e.target.value),className:`min-h-28`,placeholder:`Relevant files, constraints, acceptance criteria, and what the worker should avoid re-reading.`})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,L.jsx)(U,{label:`Workspace`,children:(0,L.jsxs)(j,{value:e.workspaceID||`__all__`,onValueChange:e=>t(`workspaceID`,e===`__all__`?``:e),children:[(0,L.jsx)(A,{className:`w-full`,children:(0,L.jsx)(O,{placeholder:`Workspace`})}),(0,L.jsxs)(T,{children:[(0,L.jsx)(E,{value:`__all__`,children:`All workspaces`}),a.map(e=>(0,L.jsx)(E,{value:e.id,children:e.name},e.id))]})]})}),(0,L.jsxs)(U,{label:`Model Profile`,children:[(0,L.jsxs)(j,{value:e.modelProfileID||`__manual__`,onValueChange:c,children:[(0,L.jsx)(A,{className:`w-full`,children:(0,L.jsx)(O,{placeholder:`Manual`})}),(0,L.jsxs)(T,{children:[(0,L.jsx)(E,{value:`__manual__`,children:`Manual`}),r.map(e=>(0,L.jsx)(E,{value:e.id,children:e.name},e.id))]})]}),f&&(0,L.jsx)(`p`,{className:`text-[10px] text-destructive`,children:f})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsxs)(U,{label:`Provider`,children:[(0,L.jsxs)(j,{value:e.modelProvider,onValueChange:e=>t(`modelProvider`,e),children:[(0,L.jsx)(A,{className:`w-full`,children:(0,L.jsx)(O,{})}),(0,L.jsx)(T,{children:R.map(e=>(0,L.jsxs)(E,{value:e.value,children:[e.label,Ae(n,{provider:e.value})?` (off)`:``]},e.value))})]}),d&&(0,L.jsx)(`p`,{className:`text-[10px] text-destructive`,children:d})]}),(0,L.jsx)(U,{label:`Parallel`,children:(0,L.jsx)(y,{type:`number`,min:1,max:20,value:e.parallelism,onChange:e=>t(`parallelism`,ht(e.target.value,1,20))})})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsx)(U,{label:`Selection`,children:(0,L.jsxs)(j,{value:e.modelSelectionMode,onValueChange:e=>t(`modelSelectionMode`,e),children:[(0,L.jsx)(A,{className:`w-full`,children:(0,L.jsx)(O,{})}),(0,L.jsxs)(T,{children:[(0,L.jsx)(E,{value:`single`,children:`Single`}),(0,L.jsx)(E,{value:`ranked`,children:`Ranked`}),(0,L.jsx)(E,{value:`random`,children:`Random`}),(0,L.jsx)(E,{value:`side_by_side`,children:`Side by side`}),(0,L.jsx)(E,{value:`capacity`,children:`Capacity`})]})]})}),(0,L.jsx)(U,{label:`Candidate #`,children:(0,L.jsx)(y,{type:`number`,min:0,max:19,value:e.modelCandidateIndex,onChange:e=>t(`modelCandidateIndex`,ht(e.target.value,0,19))})})]}),(0,L.jsxs)(U,{label:`Model`,children:[(0,L.jsx)(y,{value:e.modelID,onChange:e=>t(`modelID`,e.target.value),className:d?`border-destructive/60`:void 0,list:`delegation-models`,placeholder:o?o.known_models?.[0]:`minimax/MiniMax-M3`}),(0,L.jsx)(`datalist`,{id:`delegation-models`,children:s.map(e=>(0,L.jsx)(`option`,{value:e},e))})]}),(0,L.jsx)(U,{label:`Candidate Models`,children:(0,L.jsx)(he,{value:e.modelCandidatesJSON,onChange:e=>t(`modelCandidatesJSON`,e.target.value),className:`min-h-20 font-mono text-[11px]`,placeholder:`[{"model_provider":"opencode_cli","model_id":"minimax/MiniMax-M3","capability_tags":["coding"]}]`})}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsx)(U,{label:`Mode`,children:(0,L.jsxs)(j,{value:e.workerMode,onValueChange:e=>t(`workerMode`,e),children:[(0,L.jsx)(A,{className:`w-full`,children:(0,L.jsx)(O,{})}),(0,L.jsxs)(T,{children:[(0,L.jsx)(E,{value:`execute`,children:`Execute`}),(0,L.jsx)(E,{value:`review`,children:`Review`})]})]})}),(0,L.jsx)(U,{label:`Parent Review`,children:(0,L.jsxs)(`label`,{className:`flex h-10 items-center gap-2 rounded-md border border-input bg-background px-3 text-xs text-muted-foreground`,children:[(0,L.jsx)(ue,{checked:e.reviewRequired,onCheckedChange:e=>t(`reviewRequired`,!!e)}),`Required`]})})]}),(0,L.jsx)(U,{label:`Secret Scope`,children:(0,L.jsxs)(j,{value:e.secretScopeID||`__none__`,onValueChange:e=>t(`secretScopeID`,e===`__none__`?``:e),children:[(0,L.jsx)(A,{className:`w-full`,children:(0,L.jsx)(O,{placeholder:`Scope`})}),(0,L.jsxs)(T,{children:[(0,L.jsx)(E,{value:`__none__`,children:`None`}),i.map(e=>(0,L.jsx)(E,{value:e.id,children:e.display_name||e.name||e.id},e.id))]})]})})]})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-4`,children:[(0,L.jsx)(W,{label:`Parent In`,value:e.parentInputTokens,onChange:e=>t(`parentInputTokens`,e)}),(0,L.jsx)(W,{label:`Parent Out`,value:e.parentOutputTokens,onChange:e=>t(`parentOutputTokens`,e)}),(0,L.jsx)(W,{label:`Frontier Tokens`,value:e.baselineTokensEstimate,onChange:e=>t(`baselineTokensEstimate`,e)}),(0,L.jsx)(W,{label:`Frontier Cost`,value:e.baselineCostUSD,step:`0.01`,onChange:e=>t(`baselineCostUSD`,e)}),(0,L.jsx)(U,{label:`Parent Model`,children:(0,L.jsx)(y,{value:e.parentModel,onChange:e=>t(`parentModel`,e.target.value),placeholder:`opus / gpt-5`})}),(0,L.jsx)(U,{label:`Task ID`,children:(0,L.jsx)(y,{value:e.taskID,onChange:e=>t(`taskID`,e.target.value),placeholder:`task id`})}),(0,L.jsx)(U,{label:`Task Kind`,children:(0,L.jsx)(y,{value:e.taskKind,onChange:e=>t(`taskKind`,e.target.value),placeholder:`coding / review / visual`})}),(0,L.jsx)(W,{label:`Tool Calls`,value:e.maxToolCalls,onChange:e=>t(`maxToolCalls`,e)}),(0,L.jsx)(W,{label:`Wall Seconds`,value:e.maxWallClockSeconds,onChange:e=>t(`maxWallClockSeconds`,e)})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsxs)(_,{onClick:u,disabled:l||m,children:[l?(0,L.jsx)(ae,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,L.jsx)(S,{className:`mr-1.5 h-4 w-4`}),`Delegate`]})})]})})}function we({summary:e}){let t=e.baselineKnown||e.costBaselineKnown;return(0,L.jsxs)(`div`,{className:i(`grid grid-cols-2 gap-3`,(e.frontierQuotaBurned>0?8:7)<=7?`lg:grid-cols-7`:`lg:grid-cols-8`),children:[(0,L.jsx)(G,{label:`Parent Actual`,value:e.parentKnown?X(e.parentTokens):`unknown`,title:`Optional parent-client usage telemetry. Some parent clients do not report this reliably.`}),(0,L.jsx)(G,{label:`Worker Tokens`,value:X(e.workerTokens),accent:e.workerTokens>0?`live`:void 0}),(0,L.jsx)(G,{label:`Frontier Avoided`,value:t?Z(e.frontierAvoided):`needs estimate`,accent:e.frontierAvoided>0?`good`:void 0,title:`Estimated expensive parent-model tokens avoided for delegated work. This comes from the baseline estimate, not parent actual tokens.`}),(0,L.jsx)(G,{label:`Worker Token Delta`,value:e.baselineKnown?Z(e.workerTokenDelta):`unknown`,accent:e.baselineKnown?e.workerTokenDelta>=0?`good`:`warn`:void 0,title:`Frontier tokens avoided minus worker tokens. Useful for context/noise, but cost saved is the business metric.`}),(0,L.jsx)(G,{label:`Cost Saved`,value:e.costBaselineKnown?ft(e.costSaved):`unknown`,accent:e.costBaselineKnown?e.costSaved>=0?`good`:`warn`:void 0}),(0,L.jsx)(G,{label:`Real $ Spent`,value:Q(e.realDollarsSpent),title:`Out-of-pocket cash (OpenRouter/metered only). Excludes subscription quota usage.`}),(0,L.jsx)(G,{label:`Frontier Quota Preserved`,value:X(e.frontierQuotaPreserved),accent:e.frontierQuotaPreserved>0?`good`:void 0,title:`Frontier (Claude) subscription tokens kept off the plan by delegating to cheaper workers.`}),e.frontierQuotaBurned>0&&(0,L.jsx)(G,{label:`Frontier Quota Burned`,value:X(e.frontierQuotaBurned),accent:`burn`,title:`Claude subscription tokens spent running Opus-as-worker. This is waste — frontier quota consumed by workers instead of the parent.`})]})}function B(e){let t=new Map,n=new Map;for(let r of e){let e=r.model_key||`${r.model_provider}/${r.model_id}`;n.set(e,(n.get(e)||0)+1);let i=t.get(e);(!i||r.available&&!i.available||r.capacity_score>i.capacity_score)&&t.set(e,{...r})}return Array.from(t.values()).map(e=>({...e,duplicate_count:n.get(e.model_key||`${e.model_provider}/${e.model_id}`)||1})).sort((e,t)=>e.available===t.available?e.capacity_score===t.capacity_score?e.model_key.localeCompare(t.model_key):t.capacity_score-e.capacity_score:e.available?-1:1).map((e,t)=>({...e,rank:t+1}))}function Te({summary:e,capacityRows:t,modelRank:n,period:r}){let i=B(t).slice(0,5),a=n.slice(0,5);return(0,L.jsxs)(`section`,{className:`space-y-3 border border-border bg-card/30 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold`,children:[(0,L.jsx)(M,{className:`h-4 w-4`}),` Model performance`]}),(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Period ROI, reviewed model rank, and current capacity at a glance.`})]}),(0,L.jsx)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:nt(r)})]}),(0,L.jsx)(we,{summary:e}),(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,L.jsxs)(`div`,{className:`border border-border/60 bg-background/50`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 px-3 py-2`,children:[(0,L.jsx)(`h3`,{className:`text-[12px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Reviewed rank`}),(0,L.jsxs)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:[a.length,` shown`]})]}),a.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-muted-foreground`,children:`Review completed delegations to rank models.`}):(0,L.jsx)(`div`,{className:`divide-y divide-border/40`,children:a.map((e,t)=>(0,L.jsx)(Ee,{row:e,rank:t+1},e.modelKey))})]}),(0,L.jsxs)(`div`,{className:`border border-border/60 bg-background/50`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 px-3 py-2`,children:[(0,L.jsx)(`h3`,{className:`text-[12px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Current router`}),(0,L.jsxs)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:[i.filter(e=>e.available).length,` available`]})]}),i.length===0?(0,L.jsx)(`div`,{className:`px-3 py-4 text-sm text-muted-foreground`,children:`No capacity rows for the current workspace/task kind.`}):(0,L.jsx)(`div`,{className:`divide-y divide-border/40`,children:i.map(e=>(0,L.jsx)(V,{row:e},`${e.model_profile_id||e.model_key}-${e.rank}`))})]})]})]})}function Ee({row:e,rank:t}){let n=e.success+e.failure,r=n?e.success/n:0;return(0,L.jsxs)(`div`,{className:`grid gap-2 px-3 py-2.5 sm:grid-cols-[2rem_minmax(0,1fr)_4.5rem_4.5rem_4.5rem] sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`font-mono text-[12px] text-muted-foreground`,children:[`#`,t]}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`truncate text-[12px] font-medium`,children:e.modelID||e.modelKey}),(0,L.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.modelProvider||`provider`}),(0,L.jsxs)(`div`,{className:`mt-1 grid grid-cols-2 gap-1.5`,children:[(0,L.jsx)(Pe,{label:`quality`,value:e.avgScore/100,known:e.reviewCount>0}),(0,L.jsx)(Pe,{label:`reliability`,value:r,known:n>0})]})]}),(0,L.jsx)(K,{label:`score`,value:e.reviewCount?`${Math.round(e.avgScore)}`:`new`}),(0,L.jsx)(K,{label:`success`,value:n?`${Math.round(r*100)}%`:`new`}),(0,L.jsx)(K,{label:`cost`,value:Q(e.costUSD)})]})}function V({row:e}){return(0,L.jsxs)(`div`,{className:`grid gap-2 px-3 py-2.5 sm:grid-cols-[2rem_minmax(0,1fr)_4.5rem_4.5rem_4.5rem] sm:items-center`,children:[(0,L.jsxs)(`div`,{className:`font-mono text-[12px] text-muted-foreground`,children:[`#`,e.rank]}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate text-[12px] font-medium`,children:e.model_id||e.model_key}),(0,L.jsx)(N,{variant:`outline`,className:e.available?`border-emerald-500/40 text-emerald-300`:`border-red-500/40 text-red-300`,children:e.available?`available`:`off`}),e.running>0&&(0,L.jsxs)(N,{variant:`outline`,className:`border-sky-500/40 text-sky-300`,children:[(0,L.jsx)(m,{className:`mr-1 h-3 w-3`}),e.running]}),e.duplicate_count&&e.duplicate_count>1&&(0,L.jsxs)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:[e.duplicate_count,` routes`]})]}),(0,L.jsxs)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:[e.label?`${e.label} · `:``,e.model_provider]}),e.unavailable_reason&&(0,L.jsx)(`div`,{className:`mt-1 line-clamp-1 text-[10px] text-destructive`,children:e.unavailable_reason})]}),(0,L.jsx)(K,{label:`score`,value:`${Math.round(e.capacity_score)}`}),(0,L.jsx)(K,{label:`reviews`,value:e.review_count?`${Math.round(e.review_score)}`:`new`}),(0,L.jsx)(K,{label:`time`,value:dt(e.avg_duration_ms)})]})}function De({rows:e,onReviewed:t}){return(0,L.jsxs)(`section`,{className:`space-y-2 border border-border bg-card/30 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`h2`,{className:`flex items-center gap-1.5 text-[12px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,L.jsx)(m,{className:`h-3.5 w-3.5 text-sky-300`}),` Live running`]}),(0,L.jsxs)(N,{variant:`outline`,className:i(`text-[10px] uppercase`,e.length>0&&`border-sky-500/40 text-sky-300`),children:[e.length,` active`]})]}),e.length===0?(0,L.jsx)(`div`,{className:`border border-border/60 bg-background/50 px-3 py-2 text-xs text-muted-foreground`,children:`No delegated runs are currently active.`}):(0,L.jsx)(`div`,{className:`space-y-1.5`,children:e.map(e=>(0,L.jsx)(Fe,{delegation:e,onReviewed:t,defaultExpanded:!0},e.id))})]})}var Oe=[{key:`opencode`,label:`OpenCode`,hint:`opencode_cli (MiniMax/GLM/others via opencode)`},{key:`local`,label:`Local models`,hint:`Loopback / LM Studio / Ollama compatible routes`},{key:`minimax`,label:`MiniMax`,hint:`minimax/* model ids`},{key:`openrouter`,label:`OpenRouter`,hint:`openrouter endpoints or profiles`},{key:`claude`,label:`Claude`,hint:`Anthropic/Claude API, CLI, or routed Claude models`},{key:`grok`,label:`Grok`,hint:`grok_cli`},{key:`mimo`,label:`MiMo`,hint:`mimo_cli / xiaomi/mimo model ids`},{key:`pi`,label:`Pi`,hint:`pi_cli / Pi harness routes`}];function ke(e){return Object.keys(e).filter(t=>e[t]).sort()}function Ae(e,t){let n=je(t),r=Array.from(n).find(t=>e[t]);return r?`Disabled by ${Me(r)} switch`:``}function je(e){let t=new Set,n=(e.provider||``).trim().toLowerCase(),r=(e.modelID||``).trim().toLowerCase(),i=(e.endpoint||``).trim().toLowerCase(),a=(e.label||``).trim().toLowerCase();return n&&t.add(n),(n===`opencode_cli`||n===`opencode`)&&t.add(`opencode`),(n===`claude_cli`||n===`anthropic`||n===`claude`)&&t.add(`claude`),(n===`grok_cli`||n===`grok`)&&t.add(`grok`),(n===`mimo_cli`||n===`mimo`)&&t.add(`mimo`),(n===`pi_cli`||n===`pi`)&&t.add(`pi`),(r.includes(`claude`)||r.includes(`anthropic/`)||i.includes(`anthropic`)||a.includes(`claude`)||a.includes(`anthropic`))&&t.add(`claude`),(r.includes(`minimax`)||i.includes(`minimax`)||a.includes(`minimax`))&&t.add(`minimax`),(r.includes(`openrouter`)||i.includes(`openrouter`)||a.includes(`openrouter`))&&t.add(`openrouter`),(i.includes(`localhost`)||i.includes(`127.0.0.1`)||i.includes(`[::1]`)||i.includes(`0.0.0.0`)||r.includes(`lmstudio`)||i.includes(`lmstudio`)||a.includes(`lmstudio`)||r.includes(`lm studio`)||i.includes(`lm studio`)||a.includes(`lm studio`)||r.includes(`ollama`)||i.includes(`ollama`)||a.includes(`ollama`))&&t.add(`local`),(r.includes(`mimo`)||i.includes(`mimo`)||a.includes(`mimo`)||i.includes(`xiaomi`)||a.includes(`xiaomi`))&&t.add(`mimo`),(r.includes(`pi_cli`)||i.includes(`pi_cli`)||a.includes(`pi cli`)||a.includes(`pi.dev`)||a.includes(`pi harness`))&&t.add(`pi`),t}function Me(e){return Oe.find(t=>t.key===e)?.label||e}function Ne({disabled:e,onToggle:t,saving:n}){let r=ke(e);return(0,L.jsxs)(`section`,{className:`space-y-3 border border-border bg-card/30 p-4`,"data-testid":`delegation-options-panel`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Delegation options`}),(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Provider and subscription routes for future worker selection.`})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(N,{variant:`outline`,className:i(`text-[10px] uppercase`,r.length>0&&`border-amber-500/40 text-amber-300`),children:r.length===0?`all enabled`:`${r.length} off`}),n&&(0,L.jsx)(N,{variant:`outline`,className:`text-[10px]`,children:`saving...`})]})]}),(0,L.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-5`,children:Oe.map(r=>{let a=!!e[r.key],o=!a;return(0,L.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":o,onClick:()=>t(r.key,!a),className:i(`flex min-h-16 items-center gap-3 border px-3 py-2 text-left text-xs transition`,a?`border-destructive/40 bg-destructive/5 text-destructive`:`border-emerald-500/40 bg-emerald-500/5 text-emerald-200 hover:bg-emerald-500/10`,n&&`opacity-60`),title:r.hint,disabled:n,"data-testid":`delegation-provider-switch-${r.key}`,"data-state":o?`checked`:`unchecked`,children:[(0,L.jsx)(`span`,{className:i(`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-border transition-colors`,o?`bg-emerald-500/70`:`bg-muted`),"aria-hidden":`true`,children:(0,L.jsx)(`span`,{className:i(`inline-block h-3.5 w-3.5 rounded-full bg-background shadow transition-transform`,o?`translate-x-4`:`translate-x-1`)})}),(0,L.jsxs)(`span`,{className:`min-w-0`,children:[(0,L.jsx)(`span`,{className:`block truncate font-medium`,children:r.label}),(0,L.jsx)(`span`,{className:`block truncate font-mono text-[10px] opacity-70`,children:o?`enabled`:`disabled`})]})]},r.key)})})]})}function Pe({label:e,value:t,known:n=!0}){let r=Math.max(0,Math.min(100,Math.round(t*100)));return(0,L.jsxs)(`div`,{title:n?`${e}: ${r}%`:`${e}: not measured yet`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[8px] uppercase tracking-wider text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:e}),!n&&(0,L.jsx)(`span`,{className:`text-muted-foreground/50`,children:`n/a`})]}),(0,L.jsx)(`div`,{className:i(`h-1.5 overflow-hidden rounded-full`,n?`bg-muted/60`:`border border-dashed border-border/70`),children:n&&(0,L.jsx)(`div`,{className:i(`h-full rounded-full`,r>=80?`bg-emerald-400`:r>=50?`bg-amber-400`:`bg-red-400`),style:{width:`${r}%`}})})]})}function Fe({delegation:e,onReviewed:t,defaultExpanded:n=!1}){let[r,a]=(0,I.useState)(n),[o,s]=(0,I.useState)(!1),c=e.aggregate,l=ct(c),d=lt(c),f=c.parent_tokens_known||c.parent_tokens>0,m=c.savings_confidence===`estimated`||c.baseline_tokens>0||c.baseline_cost_usd>0,h=!!e.review?.reviewed,y=q(e),b=$e(e),x=Ie(e),S=c.baseline_cost_usd>0&&!c.cost_all_missing?ft(c.estimated_cost_saved_usd):`—`,ee=h&&typeof e.review?.score==`number`?`${e.review.score}`:y?`pending`:`—`;function C(){a(!0),s(!0)}function T(){a(e=>(e&&s(!1),!e))}return(0,L.jsxs)(`div`,{className:i(`border border-border bg-card/40`,b&&`border-sky-500/30`,y&&!h&&!b&&`border-amber-500/25`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-2.5 py-2 sm:gap-3`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:T,"aria-expanded":r,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-sm border border-border/60 text-muted-foreground hover:bg-background/60`,title:r?`Collapse`:`Expand details`,children:r?(0,L.jsx)(fe,{className:`h-3.5 w-3.5`}):(0,L.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(N,{variant:`outline`,className:i(`shrink-0 text-[10px]`,ut(e.status)),children:e.status}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1 basis-[12rem]`,children:[(0,L.jsx)(`p`,{className:`line-clamp-1 text-[13px] font-medium leading-tight`,children:e.objective}),(0,L.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:g(e.updated_at)}),(0,L.jsx)(`span`,{className:`truncate`,children:x}),(0,L.jsxs)(`span`,{children:[c.workers,` worker`,c.workers===1?``:`s`]}),e.task_kind&&(0,L.jsx)(`span`,{className:`uppercase`,children:e.task_kind})]})]}),(0,L.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-3 sm:flex`,children:[(0,L.jsx)(H,{label:`avoided`,value:m?Z(l):`—`,accent:l>0?`good`:void 0}),(0,L.jsx)(H,{label:`saved`,value:S,accent:c.baseline_cost_usd>0&&!c.cost_all_missing&&c.estimated_cost_saved_usd>=0?`good`:void 0}),(0,L.jsx)(H,{label:`tokens`,value:X(c.total_tokens)}),(0,L.jsx)(H,{label:`score`,value:ee,accent:h&&(e.review?.score??0)>=80?`good`:y?`warn`:void 0})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[y&&!h&&(0,L.jsxs)(_,{type:`button`,size:`xs`,variant:`default`,className:`h-6 px-2`,onClick:C,children:[(0,L.jsx)(p,{className:`mr-1 h-3 w-3`}),`Review`]}),h&&(0,L.jsxs)(N,{variant:`outline`,className:`h-6 border-emerald-500/40 text-[10px] text-emerald-300`,children:[(0,L.jsx)(w,{className:`mr-1 h-3 w-3`}),e.review?.score,`/100`]}),(0,L.jsxs)(_,{type:`button`,size:`xs`,variant:`outline`,className:`h-6 px-2`,onClick:T,children:[(0,L.jsx)(ge,{className:`mr-1 h-3 w-3`}),r?`Hide`:`Details`]})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-t border-border/30 px-2.5 py-1.5 text-[10px] text-muted-foreground sm:hidden`,children:[(0,L.jsx)(H,{label:`avoided`,value:m?Z(l):`—`,compact:!0}),(0,L.jsx)(H,{label:`saved`,value:S,compact:!0}),(0,L.jsx)(H,{label:`tokens`,value:X(c.total_tokens),compact:!0}),(0,L.jsx)(H,{label:`score`,value:ee,compact:!0})]}),r&&(0,L.jsxs)(`div`,{className:`space-y-3 border-t border-border/50 px-3 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:e.worker_mode||`execute`}),e.model_selection_mode&&(0,L.jsx)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:e.model_selection_mode.replace(/_/g,` `)}),e.review_required&&!h&&(0,L.jsx)(N,{variant:`outline`,className:`border-amber-500/40 text-[10px] uppercase text-amber-300`,children:`review required`}),(0,L.jsx)(N,{variant:`outline`,className:i(`text-[10px] uppercase`,m?`border-emerald-500/40 text-emerald-300`:`border-amber-500/40 text-amber-300`),children:m?`savings estimate`:`savings unknown`}),(0,L.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.id}),e.task_id&&(0,L.jsx)(v,{to:e.workspace_id?`/tasks/${encodeURIComponent(e.task_id)}?workspace=${encodeURIComponent(e.workspace_id)}`:`/tasks/${encodeURIComponent(e.task_id)}`,className:`font-mono text-[10px] text-primary hover:underline`,children:e.task_id})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 md:grid-cols-6`,children:[(0,L.jsx)(G,{label:`Parent Actual`,value:f?X(c.parent_tokens):`unknown`,title:`Optional parent-client usage telemetry. Some parent clients do not report this reliably.`}),(0,L.jsx)(G,{label:`Worker Tokens`,value:X(c.total_tokens)}),(0,L.jsx)(G,{label:`Frontier Avoided`,value:m?Z(l):`needs estimate`,accent:l>0?`good`:void 0}),(0,L.jsx)(G,{label:`Worker Delta`,value:m?Z(d):`unknown`,accent:m?d>=0?`good`:`warn`:void 0}),(0,L.jsx)(G,{label:`Worker Cost`,value:Q(c.cost_usd)}),(0,L.jsx)(G,{label:`Cost Saved`,value:S===`—`?`unknown`:S,accent:c.baseline_cost_usd>0&&!c.cost_all_missing?c.estimated_cost_saved_usd>=0?`good`:`warn`:void 0})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5 md:grid-cols-5`,children:[(0,L.jsx)(G,{label:`Real $ Spent`,value:Q(c.real_dollars_spent||0)}),(0,L.jsx)(G,{label:`Real Cost Saved`,value:ft(c.real_cost_saved_usd||0),accent:(c.real_cost_saved_usd??0)>=0?`good`:`warn`}),(0,L.jsx)(G,{label:`Quota by Bucket`,value:pt(c.quota_tokens_by_bucket)}),(c.frontier_quota_burned??0)>0?(0,L.jsx)(G,{label:`Frontier Quota Burned`,value:X(c.frontier_quota_burned??0),accent:`burn`}):(0,L.jsx)(G,{label:`Frontier Quota Preserved`,value:X(c.frontier_quota_preserved||0),accent:(c.frontier_quota_preserved||0)>0?`good`:void 0})]}),(0,L.jsx)(Le,{delegation:e,onRunSettled:t}),(o||h)&&(0,L.jsxs)(`div`,{children:[!o&&h?(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`mb-2 text-[11px] text-muted-foreground hover:text-foreground`,children:`Show review notes`}):null,o&&(0,L.jsx)(ze,{delegation:e,onReviewed:t})]}),y&&!h&&!o&&(0,L.jsx)(`div`,{className:`flex justify-end border-t border-border/40 pt-2`,children:(0,L.jsxs)(_,{type:`button`,size:`sm`,variant:`outline`,onClick:C,children:[(0,L.jsx)(p,{className:`mr-1.5 h-3.5 w-3.5`}),`Open review form`]})})]})]})}function Ie(e){let t=e.model_stats?.length?e.model_stats:it(e);if(t.length===0)return`no model`;if(t.length===1)return b(t[0].model_provider,t[0].model_id);let n=t[0];return`${b(n.model_provider,n.model_id)} +${t.length-1}`}function H({label:e,value:t,accent:n,compact:r}){return(0,L.jsxs)(`div`,{className:i(`tabular-nums`,r?`flex items-center gap-1`:`text-right`),children:[(0,L.jsx)(`span`,{className:i(`font-mono font-medium`,r?`text-[11px]`:`text-[12px]`,n===`good`&&`text-emerald-300`,n===`warn`&&`text-amber-300`),children:t}),(0,L.jsx)(`span`,{className:i(`uppercase tracking-wider text-muted-foreground`,r?`text-[8px]`:`text-[9px]`),children:e})]})}function Le({delegation:e,onRunSettled:t}){let n=e.aggregate.parent_tokens_known||e.aggregate.parent_tokens>0;return(0,L.jsxs)(`div`,{className:`border border-border/60 bg-background/50`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-[1.2rem_1fr] gap-3 border-b border-border/40 px-3 py-2`,children:[(0,L.jsx)(re,{className:`mt-0.5 h-4 w-4 text-primary`}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`text-[12px] font-medium`,children:`Parent context`}),(0,L.jsx)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:e.review_required?`review gated`:`review optional`}),e.parent.model&&(0,L.jsx)(N,{variant:`outline`,children:e.parent.model}),e.parent.context_id&&(0,L.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:e.parent.context_id})]}),(0,L.jsxs)(`div`,{className:`mt-1 grid grid-cols-2 gap-2 text-[11px] text-muted-foreground sm:grid-cols-4`,children:[(0,L.jsx)(`span`,{children:n?`${X(e.parent.input_tokens||0)} in`:`parent tokens unknown`}),(0,L.jsx)(`span`,{children:n?`${X(e.parent.output_tokens||0)} out`:`usage not reported`}),(0,L.jsx)(`span`,{children:Q(e.parent.cost_usd||0)}),(0,L.jsxs)(`span`,{children:[e.parallel_total,` child context`,e.parallel_total===1?``:`s`]})]})]})]}),(0,L.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.workers.map(e=>(0,L.jsx)(Re,{row:e,onRunSettled:t},e.worker.id))})]})}function Re({row:e,onRunSettled:t}){let n=e.latest_run,r=n?.status===`running`,i=n?.status||`dispatched`,a=n?.output_text?.replace(/\s+/g,` `).trim()||``,[o,s]=(0,I.useState)(!1);async function c(e){if(e.preventDefault(),e.stopPropagation(),!(!r||!n||o)&&window.confirm(`Hard stop this delegated run? This kills the model subprocess immediately.`)){s(!0);try{await oe(n.id),D.success(`Hard stop requested`),t()}catch(e){let t=e instanceof Error?e.message:String(e||``);t.includes(`409`)||t.includes(`not cancellable`)?D.info(`Run already finished`):t.includes(`404`)?D.error(`Run not found`):D.error(`Failed to hard-stop run`)}finally{s(!1)}}}return(0,L.jsxs)(`div`,{className:`grid grid-cols-[1.2rem_1fr] gap-3 px-3 py-2.5`,children:[(0,L.jsx)(`div`,{className:`pt-0.5`,children:r?(0,L.jsx)(ae,{className:`h-4 w-4 animate-spin text-sky-300`}):i===`success`?(0,L.jsx)(w,{className:`h-4 w-4 text-emerald-300`}):i===`failure`||i===`cap_exceeded`?(0,L.jsx)(P,{className:`h-4 w-4 text-red-300`}):i===`interrupted`?(0,L.jsx)(P,{className:`h-4 w-4 text-amber-300`}):(0,L.jsx)(de,{className:`h-4 w-4 text-muted-foreground`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(N,{variant:`outline`,className:ne(i),children:i}),(0,L.jsx)(v,{to:`/workers/${e.worker.id}`,className:`truncate text-[12px] font-medium hover:underline`,children:e.worker.name}),(0,L.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground`,children:[e.parallel_index,`/`,e.parallel_total]}),r&&n&&(0,L.jsxs)(_,{size:`sm`,variant:`destructive`,className:`h-5 px-1.5 text-[10px]`,disabled:o,onClick:c,"data-testid":`delegation-hard-stop-${n.id}`,children:[o?(0,L.jsx)(ae,{className:`mr-1 h-3 w-3 animate-spin`}):(0,L.jsx)(f,{className:`mr-1 h-3 w-3`}),o?`Stopping…`:`Hard stop`]})]}),(0,L.jsxs)(`div`,{className:`mt-1 grid grid-cols-2 gap-2 text-[11px] text-muted-foreground md:grid-cols-5`,children:[(0,L.jsx)(`span`,{children:b(e.worker.model_provider,e.worker.model_id)}),(0,L.jsxs)(`span`,{children:[X((n?.input_tokens||0)+(n?.output_tokens||0)),` tokens`]}),(0,L.jsx)(`span`,{children:Q(n?.cost_usd||0)}),(0,L.jsxs)(`span`,{children:[n?.tool_calls_count||0,` tool calls`,n?.tool_calls_cap_scope===`cli_audit`?` (cli)`:``]}),(0,L.jsx)(`span`,{children:n?.started_at?g(n.started_at):`waiting`})]}),n?.deliverable_status===`spend_no_commit`&&(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-amber-300`,children:`Spent tokens/cost with no branch or commit reported — review before accepting.`}),n?.deliverable_status===`failed_no_output`&&(0,L.jsx)(`p`,{className:`mt-1 text-[11px] text-red-300`,children:`Failed with no usable output — operational failure, not a model-quality signal.`}),n?.deliverable_status===`success_with_output`&&(n.deliverable_branch||n.deliverable_commit)&&(0,L.jsxs)(`p`,{className:`mt-1 font-mono text-[10px] text-emerald-300/90`,children:[n.deliverable_branch?`branch ${n.deliverable_branch}`:``,n.deliverable_branch&&n.deliverable_commit?` · `:``,n.deliverable_commit?`commit ${n.deliverable_commit.slice(0,12)}`:``]}),a&&(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] text-muted-foreground/80`,children:a}),n?.error&&(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 text-[11px] text-destructive`,children:n.error}),n&&r&&(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(F,{liveRun:n,onRunSettled:t})})]})]})}function ze({delegation:e,onReviewed:t}){let n=!!e.review?.reviewed,[r,a]=(0,I.useState)(n?e.review?.score??80:80),[o,s]=(0,I.useState)(e.review?.notes||``),[c,l]=(0,I.useState)(_t(e.review?.scores)),[u,f]=(0,I.useState)({}),[m,g]=(0,I.useState)(!1),v=e.model_stats?.length?e.model_stats:it(e);(0,I.useEffect)(()=>{a(e.review?.reviewed?e.review?.score??80:80),s(e.review?.notes||``),l(_t(e.review?.scores)),f({})},[e.id,e.review?.reviewed,e.review?.score,e.review?.notes,e.review?.scores]);async function b(){g(!0);try{let n=vt(c),i=yt(u);await h(e.id,{workspace_id:e.workspace_id,score:r,notes:o,task_kind:e.task_kind||void 0,scores:Object.keys(n).length?n:void 0,model_scores:i.length?i:void 0}),D.success(`Delegation reviewed`),t()}catch(e){D.error(e instanceof Error?e.message:`Review failed`)}finally{g(!1)}}return n?(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border/40 pt-3 md:grid-cols-[10rem_1fr]`,children:[(0,L.jsx)(U,{label:`Score`,children:(0,L.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-md border border-border/60 bg-background/60 px-3`,children:[(0,L.jsx)(p,{className:i(`h-4 w-4`,r>=80?`text-emerald-300`:r>=50?`text-amber-300`:`text-red-300`)}),(0,L.jsxs)(`span`,{className:`font-mono text-sm font-semibold tabular-nums`,children:[r,`/100`]})]})}),(0,L.jsx)(U,{label:`Review Notes`,children:(0,L.jsxs)(`div`,{className:`max-h-72 overflow-auto rounded-md border border-border/60 bg-background/60 p-3 text-sm`,children:[e.review?.notes?(0,L.jsx)(me,{source:e.review.notes}):(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No review notes recorded.`}),e.review?.scores&&Object.keys(e.review.scores).length>0&&(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:Object.entries(e.review.scores).map(([e,t])=>(0,L.jsxs)(N,{variant:`outline`,className:`text-[10px] uppercase`,children:[e,`: `,t]},e))})]})})]}):(0,L.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 border-t border-border/40 pt-3 md:grid-cols-[10rem_1fr_auto]`,children:[(0,L.jsx)(U,{label:`Score`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(p,{className:i(`h-4 w-4`,r>=80?`text-emerald-300`:r>=50?`text-amber-300`:`text-red-300`)}),(0,L.jsx)(y,{type:`number`,min:0,max:100,value:r,onChange:e=>a(ht(e.target.value,0,100))})]})}),(0,L.jsx)(U,{label:`Review Notes`,children:(0,L.jsx)(he,{value:o,onChange:e=>s(e.target.value),className:`min-h-20`,placeholder:e.review_required?`Required: correctness, gaps, and whether this saved parent context.`:`Correctness, gaps, and whether this saved parent context.`})}),(0,L.jsxs)(`div`,{className:`md:col-span-3`,children:[(0,L.jsx)(Ve,{values:c,onChange:l}),v.length>1&&(0,L.jsx)(He,{stats:v,values:u,onChange:f})]}),(0,L.jsx)(`div`,{className:`flex items-end`,children:(0,L.jsxs)(_,{variant:`outline`,onClick:b,disabled:m,children:[m?(0,L.jsx)(ae,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,L.jsx)(d,{className:`mr-1.5 h-4 w-4`}),`Save review`]})})]})}var Be=[`coding`,`review`,`architecture`,`tool_calling`,`visual`];function Ve({values:e,onChange:t}){return(0,L.jsx)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 md:grid-cols-5`,children:Be.map(n=>(0,L.jsx)(U,{label:n.replace(/_/g,` `),children:(0,L.jsx)(y,{type:`number`,min:0,max:100,value:e[n]??``,onChange:r=>t({...e,[n]:r.target.value})})},n))})}function He({stats:e,values:t,onChange:n}){return(0,L.jsx)(`div`,{className:`mb-3 grid grid-cols-1 gap-2 md:grid-cols-2`,children:e.map(e=>(0,L.jsx)(U,{label:e.model_id||e.model_key,children:(0,L.jsx)(y,{type:`number`,min:0,max:100,value:t[e.model_key]??``,onChange:r=>n({...t,[e.model_key]:r.target.value})})},e.model_key))})}function U({label:e,children:t}){return(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(x,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:e}),t]})}function W({label:e,value:t,onChange:n,step:r=`1`}){return(0,L.jsx)(U,{label:e,children:(0,L.jsx)(y,{type:`number`,min:0,step:r,value:t,onChange:e=>n(mt(e.target.value))})})}function G({label:e,value:t,accent:n,title:r}){return(0,L.jsxs)(`div`,{className:`border border-border bg-card/40 px-3 py-2`,title:r,children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),(0,L.jsx)(`div`,{className:i(`mt-1 font-mono text-[16px] font-semibold tabular-nums`,n===`good`&&`text-emerald-300`,n===`warn`&&`text-amber-300`,n===`live`&&`text-sky-300`,n===`burn`&&`text-red-400`),children:t})]})}function K({label:e,value:t}){return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-mono text-[13px] tabular-nums`,children:t}),(0,L.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-muted-foreground`,children:e})]})}function Ue(e){return e.reduce((e,t)=>(e.parentTokens+=t.aggregate.parent_tokens||0,(t.aggregate.parent_tokens_known||t.aggregate.parent_tokens>0)&&(e.parentKnown=!0),(t.aggregate.baseline_tokens||0)>0&&(e.baselineKnown=!0),(t.aggregate.baseline_cost_usd||0)>0&&(e.costBaselineKnown=!0),e.workerTokens+=t.aggregate.total_tokens||0,e.frontierAvoided+=ct(t.aggregate),e.workerTokenDelta+=lt(t.aggregate),e.costSaved+=t.aggregate.estimated_cost_saved_usd||0,e.realDollarsSpent+=t.aggregate.real_dollars_spent||0,e.frontierQuotaPreserved+=t.aggregate.frontier_quota_preserved||0,e.frontierQuotaBurned+=t.aggregate.frontier_quota_burned||0,e),{parentTokens:0,parentKnown:!1,baselineKnown:!1,costBaselineKnown:!1,workerTokens:0,frontierAvoided:0,workerTokenDelta:0,costSaved:0,realDollarsSpent:0,frontierQuotaPreserved:0,frontierQuotaBurned:0})}function We(e,t){let n=z.find(e=>e.key===t);if(!n?.ms)return e;let r=Date.now()-n.ms;return e.filter(e=>Ke(e)>=r)}function Ge(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>qe(e).includes(n)):e}function Ke(e){let t=[e.created_at,e.updated_at,e.review?.reviewed_at,...e.workers.flatMap(e=>[e.latest_run?.started_at,e.latest_run?.finished_at,e.worker.updated_at,e.worker.created_at])].map(e=>e?Date.parse(e):NaN).filter(e=>Number.isFinite(e));return t.length?Math.max(...t):0}function qe(e){return[e.id,e.objective,e.handoff,e.task_id,e.task_kind,e.status,e.review?.outcome,e.review?.notes,...e.model_stats?.flatMap(e=>[e.model_key,e.model_provider,e.model_id])??[],...e.workers.flatMap(e=>[e.worker.id,e.worker.name,e.worker.model_provider,e.worker.model_id,e.latest_run?.id,e.latest_run?.status,e.latest_run?.model_provider,e.latest_run?.model_id,e.latest_run?.output_text,e.latest_run?.error])].filter(Boolean).join(` `).toLowerCase()}function Je(e){return e.reduce((e,t)=>(e.all+=1,Qe(t)&&(e.attention+=1),q(t)&&(e.needsReview+=1),et(t)&&(e.success+=1),J(t)&&(e.failure+=1),Y(t)&&(e.interrupted+=1),tt(t)&&(e.cancelled+=1),t.review?.reviewed&&(e.reviewed+=1),e),{all:0,attention:0,needsReview:0,success:0,failure:0,interrupted:0,cancelled:0,reviewed:0})}function Ye(e,t){switch(t){case`attention`:return e.filter(Qe);case`needs_review`:return e.filter(q);case`success`:return e.filter(et);case`failure`:return e.filter(J);case`interrupted`:return e.filter(Y);case`cancelled`:return e.filter(tt);case`reviewed`:return e.filter(e=>!!e.review?.reviewed);default:return e}}function Xe(e,t){if(t!==`all`&&t!==`attention`)return[{key:t,title:Ze(t),rows:e}];let n=e.filter(q),r=e.filter(e=>!q(e)&&J(e)),i=e.filter(e=>!q(e)&&!J(e)&&Y(e)),a=e.filter(e=>!q(e)&&!J(e)&&!Y(e)&&tt(e)),o=e.filter(e=>!q(e)&&!J(e)&&!Y(e)&&!tt(e));return[{key:`needs_review`,title:`Needs parent review`,rows:n},{key:`failure`,title:`Failed or partial`,rows:r},{key:`interrupted`,title:`Interrupted by daemon restart`,rows:i},{key:`cancelled`,title:`Cancelled`,rows:a},{key:`completed`,title:`Completed history`,rows:o}].filter(e=>e.rows.length>0)}function Ze(e){switch(e){case`attention`:return`Attention`;case`needs_review`:return`Needs parent review`;case`success`:return`Success`;case`failure`:return`Failed or partial`;case`interrupted`:return`Interrupted`;case`cancelled`:return`Cancelled`;case`reviewed`:return`Reviewed`;default:return`All delegations`}}function Qe(e){return q(e)||J(e)||Y(e)}function q(e){return e.status===`needs_review`||!!(e.review_required&&!e.review?.reviewed)}function $e(e){return e.status===`running`||(e.aggregate?.running||0)>0}function et(e){return e.status===`success`}function J(e){return e.status===`failure`||e.status===`partial`||(e.aggregate?.failure||0)>0}function tt(e){return e.status===`cancelled`}function Y(e){return e.status===`interrupted`||(e.aggregate?.interrupted||0)>0}function nt(e){return z.find(t=>t.key===e)?.label??e}function rt(e){let t=new Map;for(let n of e){let e=n.model_stats?.length?n.model_stats:it(n);for(let r of e){let e=r.model_key||`${r.model_provider}/${r.model_id}`,i=t.get(e)??{modelKey:e,modelProvider:r.model_provider,modelID:r.model_id,runs:0,success:0,failure:0,running:0,totalTokens:0,costUSD:0,unknownCostRuns:0,durationMS:0,unknownDurationMS:0,avgDurationMS:0,costKnown:!1,reviewCount:0,avgScore:0,successRate:0,capabilityScores:{},scoreTotal:0,capabilityTotals:{},capabilityCounts:{}};i.runs+=r.runs||0,i.success+=r.success||0,i.failure+=r.failure||0,i.running+=r.running||0,i.totalTokens+=r.total_tokens||0,i.costUSD+=r.cost_usd||0,i.unknownCostRuns+=r.unknown_cost_runs||0,i.durationMS+=r.duration_ms||0,i.unknownDurationMS+=r.unknown_duration_ms||0,(r.review_count||0)>0?(i.reviewCount+=r.review_count||0,i.scoreTotal+=(r.review_score||0)*(r.review_count||0),ot(i,r.capability_scores)):n.review?.reviewed&&typeof n.review.score==`number`&&(i.reviewCount+=1,i.scoreTotal+=n.review.score,ot(i,n.review.scores)),t.set(e,i)}}return Array.from(t.values()).map(e=>{let t=Math.max(0,e.runs-e.unknownCostRuns),n=Math.max(0,e.success-e.unknownCostRuns),r=Math.max(0,e.durationMS-e.unknownDurationMS);return{...e,avgScore:e.reviewCount?e.scoreTotal/e.reviewCount:0,successRate:t?n/t:0,avgDurationMS:t?Math.round(r/t):0,costKnown:t>0,capabilityScores:st(e.capabilityTotals,e.capabilityCounts)}}).filter(e=>e.reviewCount>0||e.runs>0).sort((e,t)=>t.avgScore===e.avgScore?t.reviewCount===e.reviewCount?t.successRate===e.successRate?e.costKnown&&t.costKnown&&e.costUSD!==t.costUSD?e.costUSD-t.costUSD:e.avgDurationMS-t.avgDurationMS:t.successRate-e.successRate:t.reviewCount-e.reviewCount:t.avgScore-e.avgScore)}function it(e){let t=new Map;for(let n of e.workers){let r=n.latest_run,i=r?.model_provider||n.worker.model_provider,a=r?.model_id||n.worker.model_id,o=`${i}/${a}`,s=t.get(o)??{model_provider:i,model_id:a,model_key:o,runs:0,success:0,failure:0,running:0,cancelled:0,interrupted:0,input_tokens:0,output_tokens:0,total_tokens:0,cost_usd:0,unknown_cost_runs:0,duration_ms:0,avg_duration_ms:0,unknown_duration_ms:0,review_count:0,review_score:0,worker_ids:[]};if(s.worker_ids=[...s.worker_ids||[],n.worker.id],r){if(r.status===`cancelled`){s.cancelled=(s.cancelled||0)+1;continue}if(r.status===`interrupted`){s.interrupted=(s.interrupted||0)+1;continue}s.runs+=1,r.status===`success`&&(s.success+=1),[`failure`,`cap_exceeded`,`paused`,`rejected`].includes(r.status)&&(s.failure+=1),[`running`,`awaiting_approval`].includes(r.status)&&(s.running+=1),s.input_tokens+=r.input_tokens||0,s.output_tokens+=r.output_tokens||0,s.total_tokens+=(r.input_tokens||0)+(r.output_tokens||0),s.cost_usd+=r.cost_usd||0,s.duration_ms+=r.duration_ms||0,(r.accounting_missing||at(r))&&(s.unknown_cost_runs=(s.unknown_cost_runs||0)+1,s.unknown_duration_ms=(s.unknown_duration_ms||0)+(r.duration_ms||0))}e.review?.reviewed&&typeof e.review.score==`number`&&(s.review_count=1,s.review_score=e.review.score,s.task_kind=e.review.task_kind||e.task_kind,s.capability_scores=e.review.scores),t.set(o,s)}return Array.from(t.values()).map(e=>({...e,avg_duration_ms:e.runs&&e.runs>(e.unknown_cost_runs||0)?Math.round((e.duration_ms-(e.unknown_duration_ms||0))/(e.runs-(e.unknown_cost_runs||0))):0}))}function at(e){return e?e.status===`success`&&!e.input_tokens&&!e.output_tokens&&!e.cost_usd:!1}function ot(e,t){if(t)for(let[n,r]of Object.entries(t))Number.isFinite(r)&&(e.capabilityTotals[n]=(e.capabilityTotals[n]||0)+r,e.capabilityCounts[n]=(e.capabilityCounts[n]||0)+1)}function st(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t[r]||0;e>0&&(n[r]=i/e)}return n}function ct(e){return e.frontier_tokens_avoided??e.estimated_parent_tokens_saved??0}function lt(e){return e.worker_token_delta??e.net_tokens_delta??0}function ut(e){return ne(e===`success`?`success`:e===`running`?`running`:e===`partial`?`partial`:e===`interrupted`?`paused`:e===`needs_review`||e===`failure`?`failure`:`paused`)}function X(e){return e?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}m`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}function Z(e){return e?`${e>0?`+`:``}${X(e)}`:`0`}function Q(e){return`$${(e||0).toFixed(4)}`}function dt(e){return e?e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`:`0s`}function ft(e){return`${e>=0?`+`:`-`}$${Math.abs(e||0).toFixed(4)}`}function pt(e){return!e||Object.keys(e).length===0?`none`:Object.entries(e).filter(([,e])=>(e||0)>0).map(([e,t])=>`${e}: ${X(t)}`).join(` · `)||`none`}function mt(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function ht(e,t,n){let r=Math.round(mt(e));return Math.min(n,Math.max(t,r))}function $(e){return e>0?e:void 0}function gt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Candidate models must be a JSON array`);return n.map((e,t)=>{if(!e||typeof e!=`object`)throw Error(`Candidate ${t} must be an object`);let n=e;if(!n.model_profile_id&&(!n.model_provider||!n.model_id))throw Error(`Candidate ${t} needs a profile or provider/model`);return n})}function _t(e){return Object.fromEntries(Be.map(t=>[t,typeof e?.[t]==`number`?String(e[t]):``]))}function vt(e){let t={};for(let[n,r]of Object.entries(e))r.trim()&&(t[n]=ht(r,0,100));return t}function yt(e){return Object.entries(e).filter(([,e])=>e.trim()!==``).map(([e,t])=>({model_key:e,score:ht(t,0,100)}))}export{ve as DelegationsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/DryRunPage-Beu-_yJs.js b/internal/web/dist/assets/DryRunPage-Beu-_yJs.js deleted file mode 100644 index b3d32ce..0000000 --- a/internal/web/dist/assets/DryRunPage-Beu-_yJs.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,M as r,gt as i,j as a,on as o}from"./client-CaIRceNv.js";import{t as s}from"./play-YbzkBfB8.js";import{Fn as c,Ft as l,Mr as u,Nr as d,Pr as f,Pt as p,S as m,Vn as h,d as g,f as _,i as v,m as y,n as b,nr as x,p as S,qn as C,r as w,t as T,u as E,y as D}from"./index-BDLzoIgt.js";var O=e(t(),1),k=o();function A(e){let t=e.capabilities_cache;if(!t||typeof t!=`object`)return[];let n=t.tools;return Array.isArray(n)?n.map(e=>({name:e.name,description:e.description??``,inputSchema:e.inputSchema})):[]}function j(){let[e,t]=(0,O.useState)(``),[o,D]=(0,O.useState)(``),[j,M]=(0,O.useState)(``),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(null),[R,z]=(0,O.useState)(null),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(!1),{data:W}=m((0,O.useCallback)(()=>n(),[])),{data:G,refetch:K}=m((0,O.useCallback)(()=>i(),[])),q=(0,O.useMemo)(()=>G?.find(e=>e.id===j)??null,[G,j]),J=(0,O.useMemo)(()=>q?A(q):[],[q]),Y=q?.tool_namespace??``;function X(e){M(e),F(``)}function Z(e){F(Y?`${Y}__${e}`:e)}async function Q(){if(j){U(!0),z(null);try{await a(j),await K(),F(``)}catch(e){z(e instanceof Error?e.message:`Discovery failed`)}finally{U(!1)}}}async function $(t){t.preventDefault(),z(null),L(null),V(!0);try{L(await r({workspace_id:e,subpath:o,tool_name:P}))}catch(e){z(e instanceof Error?e.message:`Unknown error`)}finally{V(!1)}}return(0,k.jsxs)(`div`,{className:`space-y-6`,children:[(0,k.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Dry Run Simulator`}),(0,k.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[(0,k.jsxs)(T,{children:[(0,k.jsx)(w,{children:(0,k.jsx)(v,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Simulate a Tool Call`})}),(0,k.jsx)(b,{children:(0,k.jsxs)(`form`,{onSubmit:$,className:`space-y-4`,children:[(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(p,{className:`text-xs text-muted-foreground`,children:`Workspace`}),(0,k.jsxs)(E,{value:e,onValueChange:t,children:[(0,k.jsx)(S,{children:(0,k.jsx)(y,{placeholder:`Select workspace...`})}),(0,k.jsx)(g,{children:W?.map(e=>(0,k.jsx)(_,{value:e.id,children:e.name},e.id))})]})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(p,{className:`text-xs text-muted-foreground`,children:`Subpath`}),(0,k.jsx)(l,{placeholder:`/src/components`,value:o,onChange:e=>D(e.target.value)})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(p,{className:`text-xs text-muted-foreground`,children:`Downstream Server`}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsxs)(E,{value:j,onValueChange:X,children:[(0,k.jsx)(S,{className:`flex-1`,children:(0,k.jsx)(y,{placeholder:`Select server...`})}),(0,k.jsx)(g,{children:G?.map(e=>(0,k.jsxs)(_,{value:e.id,children:[e.name,` `,(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.tool_namespace,`)`]})]},e.id))})]}),(0,k.jsxs)(u,{children:[(0,k.jsx)(f,{asChild:!0,children:(0,k.jsx)(c,{type:`button`,variant:`outline`,size:`icon`,"aria-label":`Discover tools from server`,"data-testid":`dryrun-discover`,disabled:!j||H,onClick:Q,children:H?(0,k.jsx)(x,{className:`h-4 w-4 animate-spin`}):(0,k.jsx)(C,{className:`h-4 w-4`})})}),(0,k.jsx)(d,{children:`Discover tools from server`})]})]})]}),(0,k.jsxs)(`div`,{className:`space-y-2`,children:[(0,k.jsx)(p,{className:`text-xs text-muted-foreground`,children:`Tool`}),J.length>0?(0,k.jsxs)(E,{value:P?P.replace(`${Y}__`,``):``,onValueChange:Z,children:[(0,k.jsx)(S,{className:`w-full min-w-0 font-mono text-sm`,children:(0,k.jsx)(y,{placeholder:`Select tool...`})}),(0,k.jsx)(g,{position:`popper`,sideOffset:4,className:`max-h-72`,children:J.map(e=>(0,k.jsx)(_,{value:e.name,children:(0,k.jsxs)(`span`,{className:`truncate`,children:[(0,k.jsx)(`span`,{className:`font-mono text-sm`,children:e.name}),e.description&&(0,k.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.description.slice(0,60),e.description.length>60?`...`:``]})]})},e.name))})]}):(0,k.jsx)(l,{className:`font-mono text-sm`,placeholder:j?`No cached tools — run a search first`:`Select a server above, or type manually`,value:P,onChange:e=>F(e.target.value)}),P&&(0,k.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[`Namespaced: `,P]})]}),(0,k.jsxs)(c,{type:`submit`,disabled:B||!e||!P,className:`w-full`,"data-testid":`dryrun-submit`,children:[(0,k.jsx)(s,{className:`mr-2 h-4 w-4`}),B?`Simulating...`:`Simulate`]})]})})]}),(0,k.jsxs)(`div`,{className:`space-y-6`,children:[R&&(0,k.jsx)(T,{className:`border-destructive/50`,children:(0,k.jsx)(b,{className:`pt-6`,children:(0,k.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:R})})}),I?(0,k.jsx)(N,{result:I}):(0,k.jsx)(T,{className:`border-dashed`,children:(0,k.jsx)(b,{className:`pt-6`,children:(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:[(0,k.jsx)(h,{className:`mb-3 h-8 w-8 text-muted-foreground/50`}),(0,k.jsxs)(`p`,{className:`font-mono text-sm`,children:[(0,k.jsx)(`span`,{className:`text-primary`,children:`>`}),` awaiting simulation`,(0,k.jsx)(`span`,{className:`ml-0.5 inline-block w-1.5 animate-pulse bg-primary/70`,children:`\xA0`})]}),(0,k.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground/60`,children:`Select a server and tool, then hit Simulate`})]})})})]})]})]})}function M({status:e}){switch(e){case`valid`:return(0,k.jsx)(D,{className:`bg-emerald-500/15 text-emerald-600 text-xs border-0`,children:`Connected`});case`expired`:case`refresh_needed`:return(0,k.jsx)(D,{variant:`outline`,className:`text-xs text-amber-600 border-amber-300`,children:`Expired`});case`none`:return(0,k.jsx)(D,{variant:`outline`,className:`text-xs text-muted-foreground`,children:`Not Connected`});default:return null}}function N({result:e}){let t=e.policy;return(0,k.jsxs)(T,{children:[(0,k.jsx)(w,{children:(0,k.jsxs)(v,{className:`flex items-center gap-3 text-sm`,children:[`Result`,(0,k.jsx)(D,{variant:`outline`,className:t===`allow`?`bg-chart-2/15 text-chart-2 border-chart-2/30`:t===`deny`?`bg-destructive/15 text-destructive border-destructive/30`:`bg-chart-4/15 text-chart-4 border-chart-4/30`,children:e.matched?t:`no match`})]})}),(0,k.jsxs)(b,{className:`space-y-4 text-sm`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Matched Rule`}),e.matched_rule?(0,k.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border bg-background p-3 font-mono text-xs`,children:[(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`id:`}),` `,(0,k.jsx)(`span`,{className:`text-accent-foreground`,children:e.matched_rule.id})]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`priority:`}),` `,e.matched_rule.priority]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`path_glob:`}),` `,(0,k.jsx)(`span`,{className:`text-accent-foreground`,children:e.matched_rule.path_glob})]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`policy:`}),` `,e.matched_rule.policy]})]}):(0,k.jsx)(`p`,{className:`text-muted-foreground/60`,children:e.matched?`Denied by rule`:`No matching rule found`})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Downstream Server`}),e.downstream_server?(0,k.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border bg-background p-3 font-mono text-xs`,children:[(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`name:`}),` `,e.downstream_server.name]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`transport:`}),` `,e.downstream_server.transport]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`namespace:`}),` `,(0,k.jsx)(`span`,{className:`text-accent-foreground`,children:e.downstream_server.tool_namespace})]})]}):(0,k.jsx)(`p`,{className:`text-muted-foreground/60`,children:`None`})]}),e.auth_scope&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`Auth Scope`}),(0,k.jsxs)(`div`,{className:`space-y-1 rounded-md border border-border bg-background p-3 font-mono text-xs`,children:[(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`name:`}),` `,(0,k.jsx)(`span`,{className:`text-accent-foreground`,children:e.auth_scope.name})]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`id:`}),` `,(0,k.jsx)(`span`,{className:`text-accent-foreground`,children:e.auth_scope.id})]}),(0,k.jsxs)(`p`,{children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`type:`}),` `,e.auth_scope.type]}),e.auth_scope.type===`oauth2`&&(0,k.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`oauth:`}),` `,(0,k.jsx)(M,{status:e.auth_scope.oauth_status})]})]})]}),(e.candidate_rules??[]).length>0&&(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h4`,{className:`mb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:[`Candidate Rules (`,e.candidate_rules.length,`)`]}),(0,k.jsx)(`div`,{className:`space-y-1 font-mono text-xs`,children:e.candidate_rules.map(t=>(0,k.jsxs)(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${e.matched_rule?.id===t.id?`bg-chart-2/10 text-chart-2`:`text-muted-foreground`}`,children:[(0,k.jsx)(`span`,{className:`w-6 text-right`,children:t.priority}),(0,k.jsx)(`span`,{children:t.id}),(0,k.jsx)(D,{variant:`outline`,className:`ml-auto text-[10px] px-1 py-0`,children:t.policy})]},t.id))})]})]})]})}export{j as DryRunPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/GuardsOverviewPage-3nURQaKi.js b/internal/web/dist/assets/GuardsOverviewPage-3nURQaKi.js deleted file mode 100644 index 171ad73..0000000 --- a/internal/web/dist/assets/GuardsOverviewPage-3nURQaKi.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{B as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./box-C_5urXbw.js";import{t as a}from"./calendar-clock-Z37rBeGY.js";import{t as o}from"./chevron-right-CyhRDGe7.js";import{t as s}from"./funnel-BvqzDyhp.js";import{Ar as c,Fr as l,Gn as u,S as d,Vn as f,i as p,n as m,nr as h,r as g,t as _,y as v}from"./index-BDLzoIgt.js";var y=e(t(),1),b=r();function x(){let{data:e,loading:t,error:r}=d((0,y.useCallback)(()=>n(),[]));return(0,b.jsxs)(`div`,{className:`space-y-5 max-w-5xl`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Guards`}),(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`The five enforcement layers that gate what your agents can do. Each Guard has its own toggles and an audit trail; this page is the at-a-glance dashboard.`})]}),t&&!e?(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,b.jsx)(h,{className:`h-4 w-4 animate-spin`}),` Loading Guards status…`]}):r?(0,b.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:r}):e?(0,b.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:[(0,b.jsx)(C,{data:e}),(0,b.jsx)(w,{data:e}),(0,b.jsx)(T,{data:e}),(0,b.jsx)(E,{data:e}),(0,b.jsx)(D,{data:e})]}):null]})}function S({to:e,icon:t,title:n,children:r}){return(0,b.jsx)(l,{to:e,className:`group`,children:(0,b.jsxs)(_,{className:`h-full transition-colors hover:border-primary/40`,children:[(0,b.jsxs)(g,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,b.jsxs)(p,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground group-hover:text-primary`,children:t}),n]}),(0,b.jsx)(o,{className:`h-4 w-4 text-muted-foreground/40 transition-colors group-hover:text-primary`})]}),(0,b.jsx)(m,{children:r})]})})}function C({data:e}){let{hooks_installed_count:t,hooks_total_clients:n,recent_denied_count_24h:r}=e.shell;return(0,b.jsxs)(S,{to:`/guards/shell`,icon:(0,b.jsx)(f,{className:`h-4 w-4`}),title:`Shell Guard`,children:[(0,b.jsxs)(`div`,{className:`text-2xl font-semibold`,children:[t,(0,b.jsxs)(`span`,{className:`text-base font-normal text-muted-foreground`,children:[`/`,n]})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`cooperative hooks installed`}),r>0&&(0,b.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs text-amber-600`,children:[(0,b.jsx)(u,{className:`h-3 w-3`}),r,` denied in last 24h`]})]})}function w({data:e}){let{denylist_size:t,detected_count_24h:n,envelope_always:r}=e.sanitizer;return(0,b.jsxs)(S,{to:`/guards/sanitizer`,icon:(0,b.jsx)(s,{className:`h-4 w-4`}),title:`Sanitizer Guard`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold`,children:n}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`injection patterns matched (24h)`}),(0,b.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[(0,b.jsxs)(v,{variant:`secondary`,className:`text-[10px]`,children:[t,` denylist rules`]}),r&&(0,b.jsx)(v,{className:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30 text-[10px]`,children:`always envelope`})]})]})}function T({data:e}){let{jobs_total:t,jobs_ran_24h:n}=e.schedule;return(0,b.jsxs)(S,{to:`/guards/schedule`,icon:(0,b.jsx)(a,{className:`h-4 w-4`}),title:`Schedule Guard`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold`,children:t}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`jobs scheduled`}),(0,b.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,b.jsx)(c,{className:`h-3 w-3`}),n,` ran in last 24h`]})]})}function E({data:e}){let{driver:t,unsupported_os:n}=e.sandbox,r=e.sandbox.clients??[],a=r.filter(e=>e.enabled).length;return(0,b.jsxs)(S,{to:`/guards/sandbox`,icon:(0,b.jsx)(i,{className:`h-4 w-4`}),title:`Sandbox Guard`,children:[(0,b.jsxs)(`div`,{className:`text-2xl font-semibold`,children:[a,(0,b.jsxs)(`span`,{className:`text-base font-normal text-muted-foreground`,children:[`/`,r.length]})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`clients sandboxed`}),(0,b.jsx)(`div`,{className:`mt-2`,children:n?(0,b.jsx)(v,{variant:`outline`,className:`text-[10px] text-muted-foreground`,children:`unsupported OS`}):t?(0,b.jsx)(v,{variant:`secondary`,className:`font-mono text-[10px]`,children:t}):(0,b.jsx)(v,{variant:`outline`,className:`text-[10px] text-muted-foreground`,children:`no driver`})})]})}function D({data:e}){let{downstream_count:t,route_count:n}=e.mcp;return(0,b.jsxs)(S,{to:`/workspaces`,icon:(0,b.jsx)(o,{className:`h-4 w-4`}),title:`MCP Guard`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold`,children:t}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`downstream servers`}),(0,b.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[n,` active routes`]})]})}export{x as GuardsOverviewPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/LinkedWorkspacesPage-Dj4_-qpn.js b/internal/web/dist/assets/LinkedWorkspacesPage-Dj4_-qpn.js deleted file mode 100644 index b6000bd..0000000 --- a/internal/web/dist/assets/LinkedWorkspacesPage-Dj4_-qpn.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Kt as n,O as r,Tt as i,_ as a,on as o}from"./client-CaIRceNv.js";import{Bn as s,Fn as c,Ft as l,Mn as u,Mr as d,Nn as f,Nr as p,On as m,Pr as h,Pt as g,Qn as _,S as v,ir as y,j as b,jn as x,jr as S,kn as C,n as w,t as T}from"./index-BDLzoIgt.js";import{a as E,i as D,n as O,o as k,r as A,t as j}from"./table-2N0Q-yAm.js";var M=e(t(),1),N=o(),P={peer_id:``,local_workspace:``,remote_workspace_id:``,remote_workspace_name:``};function F(){let{data:e,loading:t,error:n,refetch:o}=v((0,M.useCallback)(()=>i(),[])),[l,u]=(0,M.useState)(!1),[f,m]=(0,M.useState)(P),[g,x]=(0,M.useState)(!1),[C,F]=(0,M.useState)(null),[L,R]=(0,M.useState)(null);function z(){m(P),F(null),u(!0)}async function B(){x(!0),F(null);try{let e=await a({peer_id:f.peer_id,local_workspace:f.local_workspace,remote_workspace_id:f.remote_workspace_id,remote_workspace_name:f.remote_workspace_name||void 0});u(!1),S.success(`Workspace linked`,{description:e.scope_grant_warning?e.scope_grant_warning:`Granted scope: ${e.granted_scope}`}),o()}catch(e){F(e instanceof Error?e.message:`Failed to link workspace`)}finally{x(!1)}}async function V(){if(L)try{await r(L.peer_id,L.remote_workspace_id),R(null),S.success(`Workspace unlinked`),o()}catch(e){S.error(e instanceof Error?e.message:`Failed to unlink workspace`)}}function H(e){return e.length<=16?e:`${e.slice(0,8)}…${e.slice(-6)}`}return(0,N.jsxs)(`div`,{className:`space-y-6`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,N.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Linked workspaces keep a workspace in sync across paired machines — tasks created here replicate to the linked peer's workspace.`}),(0,N.jsxs)(c,{onClick:z,"data-testid":`workspace-link-add`,children:[(0,N.jsx)(_,{className:`mr-2 h-4 w-4`}),`Link workspace`]})]}),(0,N.jsx)(T,{children:(0,N.jsxs)(w,{className:`pt-6`,children:[t&&!e&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,N.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading...`]}),n&&(0,N.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,n]}),e&&(0,N.jsxs)(j,{children:[(0,N.jsx)(E,{children:(0,N.jsxs)(k,{className:`border-border/50 hover:bg-transparent`,children:[(0,N.jsx)(D,{children:`Local Workspace`}),(0,N.jsx)(D,{children:`→ Peer`}),(0,N.jsx)(D,{children:`Remote Workspace`}),(0,N.jsx)(D,{className:`hidden lg:table-cell`,children:`Established By`}),(0,N.jsx)(D,{className:`w-24`,children:`Actions`})]})}),(0,N.jsx)(O,{children:e.length===0?(0,N.jsx)(k,{children:(0,N.jsx)(A,{colSpan:5,className:`h-32`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground`,children:[(0,N.jsx)(y,{className:`mb-2 h-8 w-8 text-muted-foreground/50`}),(0,N.jsx)(`p`,{className:`text-sm`,children:`No linked workspaces`}),(0,N.jsx)(`button`,{onClick:z,className:`text-xs text-primary hover:underline`,children:`Link a workspace to a paired peer`})]})})}):e.map(e=>(0,N.jsxs)(k,{className:`border-border/30 hover:bg-muted/30`,children:[(0,N.jsx)(A,{className:`font-medium`,children:e.local_workspace_name||e.local_workspace_id}),(0,N.jsx)(A,{children:(0,N.jsx)(`span`,{className:`font-mono text-xs text-accent-foreground`,title:e.peer_id,children:H(e.peer_id)})}),(0,N.jsx)(A,{children:e.remote_workspace_name||e.remote_workspace_id}),(0,N.jsx)(A,{className:`hidden lg:table-cell`,children:(0,N.jsx)(`span`,{className:`text-muted-foreground`,children:e.link_established_by||`-`})}),(0,N.jsx)(A,{children:(0,N.jsx)(`div`,{className:`flex gap-1`,children:(0,N.jsxs)(d,{children:[(0,N.jsx)(h,{asChild:!0,children:(0,N.jsx)(c,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Unlink workspace`,"data-testid":`workspace-link-delete-${e.peer_id}-${e.remote_workspace_id}`,onClick:()=>R(e),children:(0,N.jsx)(s,{className:`h-3.5 w-3.5`})})}),(0,N.jsx)(p,{children:`Unlink`})]})})})]},`${e.peer_id}:${e.remote_workspace_id}`))})]})]})}),(0,N.jsx)(I,{open:l,onClose:()=>u(!1),form:f,setForm:m,onSave:B,saving:g,saveError:C}),(0,N.jsx)(b,{open:!!L,onOpenChange:e=>!e&&R(null),title:`Unlink workspace`,description:`Stop replicating tasks to "${L?.remote_workspace_name||L?.remote_workspace_id}" on the linked peer?`,confirmLabel:`Unlink`,variant:`destructive`,onConfirm:V})]})}function I({open:e,onClose:t,form:r,setForm:i,onSave:a,saving:o,saveError:s}){let{data:d}=v((0,M.useCallback)(()=>n(),[])),p=d?.suggestions??[];function h(e){i({peer_id:e.peer_id,local_workspace:e.local_workspace_id,remote_workspace_id:e.remote_workspace_id,remote_workspace_name:e.remote_workspace_name??``})}return(0,N.jsx)(m,{open:e,onOpenChange:()=>t(),children:(0,N.jsxs)(C,{children:[(0,N.jsx)(u,{children:(0,N.jsx)(f,{children:`Link workspace`})}),(0,N.jsxs)(`div`,{className:`space-y-4`,children:[p.length>0&&(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(g,{className:`text-xs text-muted-foreground`,children:`Suggestions`}),(0,N.jsx)(`div`,{className:`space-y-1`,children:p.map(e=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>h(e),"data-testid":`workspace-link-suggestion-${e.peer_id}-${e.remote_workspace_id}`,className:`flex w-full items-center justify-between gap-2 rounded-md border border-border/50 bg-card/40 px-3 py-2 text-left text-xs transition-colors hover:border-border hover:bg-muted/40`,children:[(0,N.jsxs)(`span`,{className:`truncate font-medium`,children:[e.local_workspace_name||e.local_workspace_id,(0,N.jsx)(`span`,{className:`mx-1 text-muted-foreground`,children:`→`}),e.remote_workspace_name||e.remote_workspace_id]}),(0,N.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground`,children:e.peer_id.length<=16?e.peer_id:`${e.peer_id.slice(0,8)}…`})]},`${e.peer_id}:${e.remote_workspace_id}`))})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(g,{className:`text-xs text-muted-foreground`,children:`Peer ID`}),(0,N.jsx)(l,{className:`font-mono text-sm`,value:r.peer_id,onChange:e=>i(t=>({...t,peer_id:e.target.value})),placeholder:`12D3Koo…`})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(g,{className:`text-xs text-muted-foreground`,children:`Local workspace (id or name)`}),(0,N.jsx)(l,{value:r.local_workspace,onChange:e=>i(t=>({...t,local_workspace:e.target.value})),placeholder:`my-workspace`})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(g,{className:`text-xs text-muted-foreground`,children:`Remote workspace id`}),(0,N.jsx)(l,{className:`font-mono text-sm`,value:r.remote_workspace_id,onChange:e=>i(t=>({...t,remote_workspace_id:e.target.value}))})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(g,{className:`text-xs text-muted-foreground`,children:`Remote workspace name (optional)`}),(0,N.jsx)(l,{value:r.remote_workspace_name,onChange:e=>i(t=>({...t,remote_workspace_name:e.target.value}))})]})]}),s&&(0,N.jsx)(`p`,{className:`text-sm text-destructive`,children:s}),(0,N.jsxs)(x,{children:[(0,N.jsx)(c,{variant:`outline`,onClick:t,"data-testid":`workspace-link-cancel`,children:`Cancel`}),(0,N.jsx)(c,{onClick:a,disabled:o||!r.peer_id||!r.local_workspace||!r.remote_workspace_id,"data-testid":`workspace-link-save`,children:o?`Linking...`:`Link`})]})]})})}export{F as LinkedWorkspacesPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryAboutPage-DPXH1c-Z.js b/internal/web/dist/assets/MemoryAboutPage-DPXH1c-Z.js deleted file mode 100644 index de9d962..0000000 --- a/internal/web/dist/assets/MemoryAboutPage-DPXH1c-Z.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{Br as r,Cr as i,Fr as a,Or as o,bt as s,gt as c,jr as l,n as u,ot as d,t as f,vt as p,y as m,zr as h}from"./index-BDLzoIgt.js";import{i as g}from"./use-memory-ChVIui7-.js";import{t as _}from"./MemoryDetailDrawer-BzR9JTNt.js";import{n as v,t as y}from"./MemoryTable-B1nJtXoa.js";var b=e(t(),1),x=n(),S=250,C=200;function w(){let{entityKind:e=``,entityId:t=``}=h(),[n,w]=r(),[T,E]=(0,b.useState)(``),[D,O]=(0,b.useState)(``),[k,A]=(0,b.useState)(null),[j,M]=(0,b.useState)(!0),[N,P]=(0,b.useState)(null),[F,I]=(0,b.useState)(null),[L,R]=(0,b.useState)(null),z=g();(0,b.useEffect)(()=>{if(!e||!t)return;let n=!1;return c(e,t,10).then(e=>{n||I(e)}).catch(()=>{n||I([])}),s(e,t,10).then(e=>{n||R(e)}).catch(()=>{n||R([])}),()=>{n=!0}},[e,t]),(0,b.useEffect)(()=>{let e=setTimeout(()=>O(T.trim()),T?S:0);return()=>clearTimeout(e)},[T]),(0,b.useEffect)(()=>{let n=!1;return M(!0),P(null),p({query:D,limit:C,entities:[{kind:e,id:t}]}).then(e=>{n||A(e.map(e=>e.entry))}).catch(e=>{n||(P(e instanceof Error?e.message:`Recall failed`),A([]))}).finally(()=>{n||M(!1)}),()=>{n=!0}},[e,t,D]);let B=(0,b.useMemo)(()=>k??[],[k]),V=n.get(`selected`),[H,U]=(0,b.useState)(null);(0,b.useEffect)(()=>{if(!V){U(null);return}if(B.some(e=>e.id===V)){U(null);return}let e=!1;return d(V).then(t=>{e||U(t)}).catch(()=>{e||U(null)}),()=>{e=!0}},[V,B]);let W=(0,b.useMemo)(()=>V?B.find(e=>e.id===V)??H:null,[V,B,H]),G=(0,b.useCallback)(e=>{w(t=>{let n=new URLSearchParams(t);return e?n.set(`selected`,e.id):n.delete(`selected`),n},{replace:!0})},[w]),K=W?B.findIndex(e=>e.id===W.id):-1,q=K>0,J=K>=0&&Kt?.filter(t=>t.id!==e)??null)}catch(e){l.error(e instanceof Error?e.message:`Invalidate failed`)}}async function X(e){try{await z.delete(e),l.success(`Memory deleted`),A(t=>t?.filter(t=>t.id!==e)??null)}catch(e){l.error(e instanceof Error?e.message:`Delete failed`)}}return(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(a,{to:`/memory`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,x.jsx)(o,{className:`h-3 w-3`}),`Memory`]}),(0,x.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(i,{className:`h-5 w-5 text-primary`}),(0,x.jsxs)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:[`About this `,e||`entity`]}),(0,x.jsxs)(m,{variant:`outline`,tone:`muted`,className:`font-mono text-[10px]`,children:[e,`:`,t]})]}),(0,x.jsxs)(`span`,{className:`font-mono text-[11px] tabular-nums text-muted-foreground`,children:[B.length,` memor`,B.length===1?`y`:`ies`]})]}),(0,x.jsx)(v,{value:T,onChange:E,onSubmit:()=>O(T.trim()),onClear:()=>{E(``),O(``)},searching:j,hitCount:D?B.length:null}),F&&F.length>0||L&&L.length>0?(0,x.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[F&&F.length>0&&(0,x.jsx)(f,{children:(0,x.jsxs)(u,{className:`space-y-2 pt-4`,children:[(0,x.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Related entities`}),(0,x.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Co-link with this entity in shared memories.`}),(0,x.jsx)(`ul`,{className:`space-y-1`,children:F.map(e=>(0,x.jsxs)(`li`,{className:`flex items-center justify-between text-[12px]`,children:[(0,x.jsxs)(a,{to:`/memory/about/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}`,className:`inline-flex items-center gap-1.5 hover:text-primary`,children:[(0,x.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-muted-foreground`,children:e.kind}),(0,x.jsx)(`span`,{className:`font-mono`,children:e.id})]}),(0,x.jsxs)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:[e.shared_count,`×`]})]},`${e.kind}:${e.id}`))})]})}),L&&L.length>0&&(0,x.jsx)(f,{children:(0,x.jsxs)(u,{className:`space-y-2 pt-4`,children:[(0,x.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Semantically adjacent`}),(0,x.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Entities surfaced via vec-neighbours of these memories.`}),(0,x.jsx)(`ul`,{className:`space-y-1`,children:L.map(e=>(0,x.jsxs)(`li`,{className:`flex items-center justify-between text-[12px]`,children:[(0,x.jsxs)(a,{to:`/memory/about/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}`,className:`inline-flex items-center gap-1.5 hover:text-primary`,children:[(0,x.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-muted-foreground`,children:e.kind}),(0,x.jsx)(`span`,{className:`font-mono`,children:e.id})]}),(0,x.jsxs)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground/70`,children:[`~`,e.shared_count]})]},`${e.kind}:${e.id}`))})]})})]}):null,(0,x.jsx)(f,{children:(0,x.jsxs)(u,{className:`pt-6`,children:[j&&!k&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,x.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading…`]}),N&&(0,x.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,N]}),!j&&B.length===0&&(0,x.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No memories about `,e,`:`,t,` yet. Link existing memories via the detail drawer, or save new ones with`,` `,(0,x.jsx)(`code`,{className:`font-mono text-foreground/80`,children:`memory__save`}),` `,`passing`,` `,(0,x.jsxs)(`code`,{className:`font-mono text-foreground/80`,children:[`entities=[`,`{kind:"${e}", id:"${t}"}`,`]`]}),`.`]}),B.length>0&&(0,x.jsx)(y,{rows:B,loading:j,selectedId:W?.id,onSelect:G,hasQuery:!!D})]})}),(0,x.jsx)(_,{entry:W,onClose:()=>G(null),onPrev:()=>{q&&G(B[K-1])},onNext:()=>{J&&G(B[K+1])},hasPrev:q,hasNext:J,onInvalidate:Y,onDelete:X})]})}export{w as MemoryAboutPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryActivityPage-FmJja-G3.js b/internal/web/dist/assets/MemoryActivityPage-FmJja-G3.js deleted file mode 100644 index 48e2fe0..0000000 --- a/internal/web/dist/assets/MemoryActivityPage-FmJja-G3.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./arrow-up-right-RRuYfAwZ.js";import{t as a}from"./funnel-BvqzDyhp.js";import{Cr as o,Dn as s,Fn as c,Fr as l,Lt as u,Xn as d,n as f,t as p,y as m,zn as h}from"./index-BDLzoIgt.js";import{t as g}from"./empty-state-B9mtYx_X.js";import{r as _,t as v}from"./memory-utils-B0WiuphN.js";var y=e(t(),1),b=r(),x=100,S=[{key:`all`,label:`All`},{key:`written`,label:`Written`},{key:`offered`,label:`Offered`},{key:`consolidated`,label:`Consolidated`}];function C(e,t){if(t===`all`)return!0;let n=(e.kind||``).toLowerCase();return t===`written`?n.includes(`writ`)||n.includes(`saved`)||n.includes(`created`)||n.includes(`invalidat`)||n.includes(`pin`):t===`offered`?n.includes(`offer`)||n.includes(`shar`):t===`consolidated`?n.includes(`consolidat`):!0}function w(e){return e.filter(e=>v(e.kind,e.source))}function T(){let[e,t]=(0,y.useState)([]),[r,i]=(0,y.useState)(0),[l,m]=(0,y.useState)([void 0]),[_,T]=(0,y.useState)(!0),[D,O]=(0,y.useState)(null),[k,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(`all`),P=(0,y.useCallback)(async(e,n)=>{T(!0),O(null);try{let r=await s({source:`memory`,limit:x,before:e});t(w(r.notifications));let a=r.notifications.map(e=>e.id).filter(e=>e>0),o=a.length?Math.min(...a):void 0;j(r.notifications.length{let r=t.slice(0,n+1);return r[n]=e,o!==void 0&&(r[n+1]=o),r})}catch(e){O(e instanceof Error?e.message:`Failed to load activity`)}finally{T(!1)}},[]);(0,y.useEffect)(()=>(P(void 0,0).finally(()=>{}),()=>{}),[P]);let{events:F}=u(),I=(0,y.useMemo)(()=>{let e=F.find(e=>v(e.kind,e.source));return e?e.message_id:``},[F]);(0,y.useEffect)(()=>{I&&r===0&&t(e=>{let t=new Set(e.map(e=>e.message_id)),n=w(F).filter(e=>!t.has(e.message_id));return n.length?[...n,...e].slice(0,x):e})},[I,F,r]);let L=(0,y.useMemo)(()=>e.filter(e=>C(e,M)),[e,M]),R=(0,y.useMemo)(()=>A(L),[L]),z=l[r+1],B=!k&&z!==void 0,V=r>0;return(0,b.jsxs)(`div`,{className:`space-y-6`,children:[(0,b.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,b.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-2xl font-semibold tracking-tight`,children:[(0,b.jsx)(o,{className:`h-5 w-5 text-primary`}),`Memory activity`]}),(0,b.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Every memory your gateway has written, shared, or consolidated, newest first. New events appear live as agents learn.`})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,b.jsxs)(`span`,{className:`mr-1 inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:[(0,b.jsx)(a,{className:`h-3 w-3`}),`Filter`]}),S.map(e=>(0,b.jsx)(`button`,{type:`button`,onClick:()=>N(e.key),className:n(`inline-flex items-center border px-2.5 py-1 font-mono text-[12px] transition-colors`,M===e.key?`border-primary/40 bg-primary/5 text-foreground`:`border-dashed border-border text-muted-foreground hover:border-border/80 hover:text-foreground`),children:e.label},e.key))]}),(0,b.jsx)(p,{children:(0,b.jsx)(f,{className:`p-0`,children:_?(0,b.jsxs)(`div`,{className:`flex items-center gap-2 p-6 text-sm text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}),`Loading activity…`]}):D&&e.length===0?(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-6`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2.5 text-sm`,children:[(0,b.jsx)(h,{className:`h-4 w-4 shrink-0 text-destructive`}),(0,b.jsx)(`span`,{className:`text-foreground`,children:`Could not load activity`}),(0,b.jsx)(`span`,{className:`font-mono text-[11px] text-muted-foreground`,children:D})]}),(0,b.jsx)(c,{variant:`ghost`,size:`sm`,onClick:()=>P(void 0,0),children:`Retry`})]}):L.length===0?(0,b.jsx)(g,{icon:(0,b.jsx)(o,{className:`h-7 w-7`}),title:e.length===0?`No memory activity yet`:`No ${M} events in the loaded history`,description:e.length===0?`When an agent writes a memory, accepts a peer offer, or runs a consolidation pass, it will appear here.`:`Switch filters or move to an older page to keep exploring.`,density:`card`,testid:`memory-activity-empty`}):(0,b.jsx)(`div`,{className:`divide-y divide-border/30`,children:R.map(e=>(0,b.jsxs)(`section`,{children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border/40 bg-card/95 px-4 py-1.5 backdrop-blur`,children:[(0,b.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,b.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.rows.length})]}),(0,b.jsx)(`ul`,{className:`divide-y divide-border/20`,children:e.rows.map(e=>(0,b.jsx)(E,{event:e},`${e.id}-${e.message_id}`))})]},e.label))})})}),!_&&(e.length>0||r>0)&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2 pb-2`,children:[(0,b.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>P(l[r-1],r-1),disabled:!V||_,"data-testid":`memory-activity-newer`,children:`Newer`}),(0,b.jsxs)(`span`,{className:`min-w-20 text-center font-mono text-[11px] tabular-nums text-muted-foreground/70`,children:[`Page `,r+1]}),k&&!B?(0,b.jsx)(`span`,{className:`text-[11px] text-muted-foreground/60`,children:`Beginning of recorded activity`}):(0,b.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>{z!==void 0&&P(z,r+1)},disabled:!B||_,"data-testid":`memory-activity-older`,children:`Older`})]})]})}function E({event:e}){let t=(0,b.jsxs)(`div`,{className:`flex items-start gap-3 px-4 py-2.5 transition-colors hover:bg-muted/20`,children:[(0,b.jsx)(`span`,{className:n(`mt-1.5 inline-flex h-1.5 w-1.5 shrink-0 rounded-full`,e.priority===`critical`?`bg-red-400`:e.priority===`high`?`bg-orange-400`:`bg-emerald-400/80`)}),(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:e.title}),(0,b.jsx)(m,{variant:`outline`,tone:`muted`,className:`shrink-0 font-mono text-[9px] uppercase`,children:D(e.kind)}),e.link&&(0,b.jsx)(i,{className:`h-3 w-3 shrink-0 text-muted-foreground/40`})]}),e.body&&(0,b.jsx)(`p`,{className:`mt-0.5 truncate text-[11.5px] text-muted-foreground/90`,children:e.body})]}),(0,b.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:_(e.created_at)})]});return e.link?(0,b.jsx)(`li`,{children:(0,b.jsx)(l,{to:e.link,className:`block`,children:t})}):(0,b.jsx)(`li`,{children:t})}function D(e){return e&&e.replace(/^memory[._]/i,``).replace(/_/g,` `)||`event`}function O(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function k(e){let t=new Date(e);if(!Number.isFinite(t.getTime()))return`Unknown`;let n=Math.round((O(new Date)-O(t))/864e5);return n<=0?`Today`:n===1?`Yesterday`:n<7?t.toLocaleDateString(void 0,{weekday:`long`}):t.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function A(e){let t=[],n=null;for(let r of e){let e=k(r.created_at);(!n||n.label!==e)&&(n={label:e,rows:[]},t.push(n)),n.rows.push(r)}return t}export{T as MemoryActivityPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryConsolidationPage-BxBOgRKY.js b/internal/web/dist/assets/MemoryConsolidationPage-BxBOgRKY.js deleted file mode 100644 index 9767be9..0000000 --- a/internal/web/dist/assets/MemoryConsolidationPage-BxBOgRKY.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./createLucideIcon-WB390fY6.js";import{t as a}from"./play-YbzkBfB8.js";import{t as o}from"./workflow-COO0Sn-w.js";import{Fn as s,Fr as c,Or as l,_t as u,ar as d,at as f,cr as p,jr as m,n as h,nr as g,nt as _,t as v,tt as y,y as b,yr as x}from"./index-BDLzoIgt.js";var S=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),C=e(t(),1),w=r();function T(){let[e,t]=(0,C.useState)([]),[r,i]=(0,C.useState)(!0),[a,s]=(0,C.useState)({}),d=(0,C.useCallback)(async()=>{i(!0);try{let e=await n();t(await Promise.all(e.map(async e=>{try{return{workspace:e,status:await f(e.id),loading:!1}}catch{return{workspace:e,status:null,loading:!1}}})))}catch(e){m.error(`Failed to load workspaces: `+String(e))}finally{i(!1)}},[]);(0,C.useEffect)(()=>{d()},[d]);let b=(e,t)=>s(n=>({...n,[e]:t})),x=async e=>{b(e,`pause`);try{await y(e),m.success(`Consolidator paused for this workspace`),await d()}catch(e){m.error(`Pause failed: `+String(e))}finally{b(e,``)}},S=async e=>{b(e,`resume`);try{await _({workspace_id:e}),m.success(`Consolidator resumed`),await d()}catch(e){m.error(`Resume failed: `+String(e))}finally{b(e,``)}},T=async e=>{b(e,`run`);try{let t=await u(e);m.success(`Run queued (run_id ${t.run_id.slice(0,12)}…)`),await d()}catch(e){m.error(`Run failed: `+String(e))}finally{b(e,``)}};return(0,w.jsxs)(`div`,{className:`space-y-5`,children:[(0,w.jsxs)(c,{to:`/memory`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(l,{className:`h-3 w-3`}),`Memory`]}),(0,w.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,w.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,w.jsx)(o,{className:`h-5 w-5 text-primary`}),`Consolidation`]}),(0,w.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Auto-installed in every workspace. Each scheduled run does TWO scope-preserving passes — one against global memory, one against the workspace — so consolidated notes are written back to the same scope as their sources. Pinned memories are never touched.`})]}),(0,w.jsx)(v,{children:(0,w.jsx)(h,{className:`space-y-3 p-5`,children:(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(p,{className:`h-3.5 w-3.5`}),(0,w.jsx)(`span`,{children:`Global memory is consolidated automatically by every workspace's consolidator — there is no separate global toggle. Pausing one workspace doesn't stop another from consolidating global memory.`})]})})}),r&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(g,{className:`h-4 w-4 animate-spin`}),`Loading workspace consolidators…`]}),!r&&e.length===0&&(0,w.jsx)(v,{children:(0,w.jsx)(h,{className:`p-6 text-center text-sm text-muted-foreground`,children:`No workspaces yet. Once you have at least one workspace and an api_key auth scope, the consolidator will install itself on the next daemon restart.`})}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:e.map(e=>(0,w.jsx)(E,{row:e,busy:a[e.workspace.id]||``,onPause:()=>x(e.workspace.id),onResume:()=>S(e.workspace.id),onRunNow:()=>T(e.workspace.id)},e.workspace.id))}),(0,w.jsx)(v,{children:(0,w.jsxs)(h,{className:`p-6`,children:[(0,w.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`What each run does (per workspace)`}),(0,w.jsxs)(`ul`,{className:`mt-3 grid grid-cols-1 gap-2 text-[12.5px] text-muted-foreground/90 md:grid-cols-2`,children:[(0,w.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(`span`,{className:`mt-1 inline-flex h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-400/80`}),(0,w.jsxs)(`span`,{children:[`Pass 1: `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`memory__list(scope:"global_only")`}),` `,`— cluster + consolidate → write back with`,` `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`scope:"global"`}),`.`]})]}),(0,w.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(`span`,{className:`mt-1 inline-flex h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-400/80`}),(0,w.jsxs)(`span`,{children:[`Pass 2: `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`memory__list(scope:"workspace_only")`}),` `,`— same clustering, write back with`,` `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`scope:"workspace"`}),`.`]})]}),(0,w.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(`span`,{className:`mt-1 inline-flex h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-400/80`}),(0,w.jsxs)(`span`,{children:[`Original notes are`,` `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`memory__invalidate`}),`d, pointing at the consolidated note — never deleted.`]})]}),(0,w.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,w.jsx)(`span`,{className:`mt-1 inline-flex h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-400/80`}),(0,w.jsxs)(`span`,{children:[`Skips pinned memories and`,` `,(0,w.jsx)(`span`,{className:`font-mono text-foreground/80`,children:`kind=fact`}),` rows — only consolidates notes.`]})]})]})]})})]})}function E({row:e,busy:t,onPause:n,onResume:r,onRunNow:i}){let{workspace:o,status:l}=e,u=l?.installed?l.enabled?`success`:`warn`:`muted`,f=l?l.installed?l.enabled?`Enabled`:`Paused`:`Not installed yet`:`—`,p=O(l);return(0,w.jsx)(v,{children:(0,w.jsxs)(h,{className:`space-y-3 p-5`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:o.name||o.id}),(0,w.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground/60`,children:o.id})]}),(0,w.jsx)(b,{variant:`outline`,tone:u,className:`text-[10px] uppercase tracking-wider`,children:f})]}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 border-t border-border/40 pt-3`,children:[(0,w.jsx)(D,{icon:(0,w.jsx)(d,{className:`h-3.5 w-3.5`}),label:`Recent runs`,value:l?.recent_runs?String(l.recent_runs):`—`}),(0,w.jsx)(D,{icon:(0,w.jsx)(x,{className:`h-3.5 w-3.5`}),label:`Last run`,value:p.value,hint:p.hint})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border/40 pt-3`,children:[l?.installed&&l.enabled&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(s,{size:`sm`,onClick:i,disabled:t!==``,children:[t===`run`?(0,w.jsx)(g,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,w.jsx)(a,{className:`mr-1.5 h-3.5 w-3.5`}),`Run now`]}),(0,w.jsx)(s,{size:`sm`,variant:`ghost`,onClick:n,disabled:t!==``,children:`Pause`})]}),l?.installed&&!l.enabled&&(0,w.jsxs)(s,{size:`sm`,onClick:r,disabled:t!==``,children:[t===`resume`?(0,w.jsx)(g,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,w.jsx)(S,{className:`mr-1.5 h-3.5 w-3.5`}),`Resume`]}),!l?.installed&&(0,w.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Daemon will auto-install on next boot when an api_key auth scope exists.`}),l?.worker_id&&(0,w.jsx)(c,{to:`/workers/${l.worker_id}`,className:`ml-auto text-[11px] text-muted-foreground hover:text-foreground`,children:`Tune →`})]})]})})}function D({icon:e,label:t,value:n,hint:r}){return(0,w.jsxs)(`div`,{className:`border border-border bg-card/40 px-2.5 py-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:[e,t]}),(0,w.jsx)(`div`,{className:`mt-0.5 font-mono text-base tabular-nums text-muted-foreground/80`,children:n}),r&&(0,w.jsx)(`div`,{className:`text-[9px] text-muted-foreground/60`,children:r})]})}function O(e){if(!e||!e.last_run_at)return{value:`never`,hint:`awaiting first pass`};let t=new Date(e.last_run_at),n=Date.now()-t.getTime();return n<6e4?{value:`just now`,hint:t.toISOString()}:n<36e5?{value:`${Math.floor(n/6e4)}m ago`,hint:t.toISOString()}:n<864e5?{value:`${Math.floor(n/36e5)}h ago`,hint:t.toISOString()}:{value:`${Math.floor(n/864e5)}d ago`,hint:t.toISOString()}}export{T as MemoryConsolidationPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryDetailDrawer-BzR9JTNt.js b/internal/web/dist/assets/MemoryDetailDrawer-BzR9JTNt.js deleted file mode 100644 index f5c7ef3..0000000 --- a/internal/web/dist/assets/MemoryDetailDrawer-BzR9JTNt.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./arrow-down-BlDh7bya.js";import{t as a}from"./arrow-up-CWTnU2zx.js";import{t as o}from"./chevron-right-CyhRDGe7.js";import{t as s}from"./pin-off-CPMgqeYV.js";import{t as c}from"./pin-C0Q-Achd.js";import{Bn as l,C as u,D as d,E as f,Fn as p,Fr as m,Gn as h,Ln as g,Mr as _,Nr as v,Pr as y,_ as b,dt as x,ht as S,j as C,jr as w,nr as T,w as E,xr as D,xt as O}from"./index-BDLzoIgt.js";import{n as k,t as A}from"./markdown-BxN4l9DE.js";import{i as ee,r as te,t as j}from"./memory-primitives-C7gBVkiY.js";import{i as M,n as N,r as P}from"./memory-utils-B0WiuphN.js";var F=e(t(),1),I=r();function L({label:e,children:t,defaultMuted:r}){return(0,I.jsxs)(`section`,{className:`border-b border-border/30 py-4 last:border-b-0`,children:[(0,I.jsx)(`h3`,{className:n(`mb-2.5 text-[10px] font-semibold uppercase tracking-[0.12em]`,r?`text-muted-foreground/60`:`text-muted-foreground`),children:e}),(0,I.jsx)(`div`,{className:`space-y-2.5`,children:t})]})}function R({label:e,children:t}){return(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`flex w-28 shrink-0 items-center gap-1 pt-0.5 text-xs text-muted-foreground`,children:(0,I.jsx)(`span`,{children:e})}),(0,I.jsx)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:t})]})}function z({entry:e,busy:t,onTogglePin:n,onInvalidate:r,onDelete:i}){let a=!!e.t_valid_end;return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/30 pb-4`,children:[(0,I.jsxs)(_,{children:[(0,I.jsx)(y,{asChild:!0,children:(0,I.jsxs)(p,{variant:`outline`,size:`sm`,disabled:!n||t===`pin`,onClick:n,className:`gap-1.5`,"data-testid":`memory-detail-pin`,children:[t===`pin`?(0,I.jsx)(T,{className:`h-3.5 w-3.5 animate-spin`}):e.pinned?(0,I.jsx)(s,{className:`h-3.5 w-3.5`}):(0,I.jsx)(c,{className:`h-3.5 w-3.5`}),e.pinned?`Unpin`:`Pin`]})}),(0,I.jsx)(v,{children:n?`Mark this memory as pinned`:`Pin endpoint not wired yet`})]}),(0,I.jsxs)(p,{variant:`outline`,size:`sm`,disabled:!r||a||t!==null,onClick:r,className:`gap-1.5 border-amber-500/30 text-amber-300 hover:bg-amber-500/5`,"data-testid":`memory-detail-invalidate`,children:[(0,I.jsx)(h,{className:`h-3.5 w-3.5`}),`Invalidate`]}),(0,I.jsxs)(p,{variant:`outline`,size:`sm`,disabled:!i||t!==null,onClick:i,className:`gap-1.5 border-destructive/30 text-destructive hover:bg-destructive/5`,"data-testid":`memory-detail-delete`,children:[(0,I.jsx)(l,{className:`h-3.5 w-3.5`}),`Delete`]})]})}function B({onPrev:e,onNext:t,hasPrev:n,hasNext:r}){return!e&&!t?null:(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border/60 bg-background/40 px-5 py-3 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsxs)(_,{children:[(0,I.jsx)(y,{asChild:!0,children:(0,I.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,disabled:!n,onClick:()=>e?.(),"data-testid":`memory-detail-prev`,children:[(0,I.jsx)(a,{className:`h-3 w-3`}),`Prev`]})}),(0,I.jsx)(v,{children:`k or ↑`})]}),(0,I.jsxs)(_,{children:[(0,I.jsx)(y,{asChild:!0,children:(0,I.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 gap-1 px-2 text-xs`,disabled:!r,onClick:()=>t?.(),"data-testid":`memory-detail-next`,children:[(0,I.jsx)(i,{className:`h-3 w-3`}),`Next`]})}),(0,I.jsx)(v,{children:`j or ↓`})]})]}),(0,I.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`esc to close`})]})}function V({entry:e,open:t,onToggle:n}){return e.source_session_id||e.source_peer_id||e.source_tool_call_id||e.origin_peer_id||e.worker_id||e.run_id?(0,I.jsxs)(`section`,{className:`border-b border-border/30 py-4 last:border-b-0`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:n,className:`flex w-full items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.12em] text-muted-foreground transition-colors hover:text-foreground`,"data-testid":`memory-detail-provenance-toggle`,children:[t?(0,I.jsx)(D,{className:`h-3 w-3`}):(0,I.jsx)(o,{className:`h-3 w-3`}),`Provenance`]}),t&&(0,I.jsxs)(`div`,{className:`mt-2.5 space-y-2.5`,children:[e.source_session_id&&(0,I.jsxs)(R,{label:`Session`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-cyan-300 break-all`,children:e.source_session_id}),(0,I.jsx)(b,{value:e.source_session_id})]}),e.source_tool_call_id&&(0,I.jsxs)(R,{label:`Tool call`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-violet-300 break-all`,children:e.source_tool_call_id}),(0,I.jsx)(b,{value:e.source_tool_call_id})]}),e.source_peer_id&&(0,I.jsxs)(R,{label:`Source peer`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-emerald-300 break-all`,children:e.source_peer_id}),(0,I.jsx)(b,{value:e.source_peer_id})]}),e.origin_peer_id&&(0,I.jsxs)(R,{label:`Origin peer`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-emerald-300 break-all`,children:e.origin_peer_id}),(0,I.jsx)(b,{value:e.origin_peer_id})]}),e.worker_id&&(0,I.jsxs)(R,{label:`Worker`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-foreground break-all`,children:e.worker_id}),(0,I.jsx)(b,{value:e.worker_id})]}),e.run_id&&(0,I.jsxs)(R,{label:`Run`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-foreground break-all`,children:e.run_id}),(0,I.jsx)(b,{value:e.run_id})]})]})]}):null}function H({entry:e,onClose:t,onPrev:n,onNext:r,hasPrev:i,hasNext:a,onInvalidate:o,onDelete:s,onTogglePin:l}){let[p,h]=(0,F.useState)(null),[T,D]=(0,F.useState)(!1),[H,U]=(0,F.useState)(!1),[W,G]=(0,F.useState)(!1),[K,q]=(0,F.useState)(null),[J,Y]=(0,F.useState)(null),[X,Z]=(0,F.useState)(null);if((0,F.useEffect)(()=>{if(!e){Z(null);return}let t=!1;return S(e.id,8).then(e=>{t||Z(e)}).catch(()=>{t||Z([])}),()=>{t=!0}},[e?.id]),(0,F.useEffect)(()=>{if(!e){q(null);return}let t=!1;return x(e.id).then(e=>{t||q(e)}).catch(()=>{t||q([])}),()=>{t=!0}},[e?.id]),(0,F.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)||((e.key===`j`||e.key===`ArrowDown`)&&r&&a?(e.preventDefault(),r()):(e.key===`k`||e.key===`ArrowUp`)&&n&&i&&(e.preventDefault(),n()))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n,r,i,a]),!e)return null;let Q=N(e.tags),ne=M(e),re=!!e.t_valid_end,$=k(e.content||``);async function ie(){if(o){h(`invalidate`);try{await o(e.id),U(!1),t()}finally{h(null)}}}async function ae(){if(s){h(`delete`);try{await s(e.id),D(!1),t()}finally{h(null)}}}async function oe(){if(l){h(`pin`);try{await l(e.id,!e.pinned)}finally{h(null)}}}async function se(t){if(e){Y(`${t.entity_kind}|${t.entity_id}|${t.role}`);try{await O(e.id,{kind:t.entity_kind,id:t.entity_id,role:t.role}),q(e=>e?.filter(e=>e.id!==t.id)??null)}catch(e){w.error(e instanceof Error?e.message:`Unlink failed`)}finally{Y(null)}}}return(0,I.jsxs)(u,{open:!!e,onOpenChange:e=>!e&&t(),children:[(0,I.jsxs)(E,{side:`right`,className:`flex w-full flex-col gap-0 p-0 sm:max-w-[min(760px,94vw)]`,children:[(0,I.jsxs)(f,{className:`space-y-3 border-b border-border/60 p-5 pr-12`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(j,{kind:e.kind}),(0,I.jsx)(te,{scope:ne}),(0,I.jsx)(ee,{source:e.source_kind}),e.pinned&&(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-amber-300`,children:[(0,I.jsx)(c,{className:`h-3 w-3`}),` pinned`]}),re&&(0,I.jsx)(`span`,{className:`inline-flex items-center gap-1 border border-muted-foreground/40 bg-muted/40 px-1.5 py-0.5 text-[10px] uppercase tracking-wider text-muted-foreground`,children:`invalidated`}),(0,I.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:(0,I.jsxs)(_,{children:[(0,I.jsx)(y,{asChild:!0,children:(0,I.jsx)(`span`,{children:P(e.created_at)})}),(0,I.jsx)(v,{children:new Date(e.created_at).toLocaleString()})]})})]}),(0,I.jsxs)(d,{className:`flex min-w-0 items-start gap-2 font-mono text-base font-semibold leading-snug break-all`,children:[(0,I.jsx)(`span`,{className:`min-w-0`,children:e.name}),(0,I.jsx)(b,{value:e.name,className:`-mt-0.5 shrink-0`})]}),Q.length>0&&(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:Q.map(e=>(0,I.jsx)(`span`,{className:`inline-flex items-center border border-border bg-muted/30 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:e},e))})]}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4`,children:[(0,I.jsx)(z,{entry:e,busy:p,onTogglePin:l?oe:void 0,onInvalidate:o?()=>U(!0):void 0,onDelete:s?()=>D(!0):void 0}),(0,I.jsx)(L,{label:`Content`,children:$?(0,I.jsx)(A,{source:$}):(0,I.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`empty`})}),X&&X.length>0&&(0,I.jsx)(L,{label:`You might also remember`,defaultMuted:!0,children:(0,I.jsx)(`ul`,{className:`space-y-1.5`,children:X.map(e=>(0,I.jsxs)(`li`,{className:`text-[12px]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>{let t=new URL(window.location.href);t.searchParams.set(`selected`,e.memory_id),window.history.replaceState(null,``,t.toString()),window.dispatchEvent(new PopStateEvent(`popstate`))},className:`group flex w-full items-center justify-between gap-2 text-left hover:text-primary`,children:[(0,I.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-muted-foreground`,children:e.source.replace(`_`,` `)}),(0,I.jsx)(`span`,{className:`font-mono truncate`,children:e.name})]}),(0,I.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:e.score.toFixed(2)})]}),(0,I.jsx)(`div`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:e.reason})]},e.memory_id))})}),K&&K.length>0&&(0,I.jsxs)(L,{label:`About`,children:[(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:K.map(e=>{let t=J===`${e.entity_kind}|${e.entity_id}|${e.role}`;return(0,I.jsxs)(`span`,{className:`group inline-flex items-center gap-1 border border-border bg-card/60 pl-1.5 pr-0.5 py-0.5 text-[11px]`,title:`role: ${e.role}`,children:[(0,I.jsxs)(m,{to:`/memory/about/${encodeURIComponent(e.entity_kind)}/${encodeURIComponent(e.entity_id)}`,className:`inline-flex items-center gap-1.5 hover:text-primary`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-muted-foreground`,children:e.entity_kind}),(0,I.jsx)(`span`,{className:`font-mono text-foreground`,children:e.entity_id})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>se(e),disabled:t,className:`ml-0.5 inline-flex h-4 w-4 items-center justify-center text-muted-foreground/50 hover:text-destructive disabled:opacity-30`,"aria-label":`Unlink ${e.entity_kind}:${e.entity_id}`,children:(0,I.jsx)(g,{className:`h-3 w-3`})})]},e.id)})}),(0,I.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground/70`,children:`Click a chip to see every memory linked to that entity.`})]}),(0,I.jsxs)(L,{label:`Identity`,defaultMuted:!0,children:[(0,I.jsxs)(R,{label:`ID`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-muted-foreground break-all`,children:e.id}),(0,I.jsx)(b,{value:e.id})]}),e.workspace_id&&(0,I.jsx)(R,{label:`Workspace`,children:(0,I.jsx)(`code`,{className:`font-mono text-xs text-foreground break-all`,children:e.workspace_id})}),e.user_id&&(0,I.jsx)(R,{label:`User`,children:(0,I.jsx)(`code`,{className:`font-mono text-xs text-foreground break-all`,children:e.user_id})})]}),(0,I.jsxs)(L,{label:`Lifecycle`,children:[(0,I.jsx)(R,{label:`Created`,children:(0,I.jsx)(`span`,{className:`text-xs text-foreground`,children:new Date(e.created_at).toLocaleString()})}),(0,I.jsx)(R,{label:`Updated`,children:(0,I.jsx)(`span`,{className:`text-xs text-foreground`,children:new Date(e.updated_at).toLocaleString()})}),(0,I.jsx)(R,{label:`Valid from`,children:(0,I.jsx)(`span`,{className:`text-xs text-foreground`,children:new Date(e.t_valid_start).toLocaleString()})}),e.t_valid_end&&(0,I.jsx)(R,{label:`Invalidated`,children:(0,I.jsx)(`span`,{className:`text-xs text-amber-300`,children:new Date(e.t_valid_end).toLocaleString()})}),e.invalidated_by&&(0,I.jsxs)(R,{label:`Superseded by`,children:[(0,I.jsx)(`code`,{className:`font-mono text-xs text-foreground break-all`,children:e.invalidated_by}),(0,I.jsx)(b,{value:e.invalidated_by})]})]}),(0,I.jsx)(V,{entry:e,open:W,onToggle:()=>G(e=>!e)})]}),(0,I.jsx)(B,{onPrev:n,onNext:r,hasPrev:i,hasNext:a})]}),(0,I.jsx)(C,{open:H,onOpenChange:U,title:`Invalidate this memory?`,description:`It will be hidden from agents and search results by default, but the row stays in the bi-temporal trail. Use forget-by-source if you need a hard delete.`,confirmLabel:`Invalidate`,onConfirm:ie,variant:`default`}),(0,I.jsx)(C,{open:T,onOpenChange:D,title:`Soft-delete this memory?`,description:`Sets deleted_at, hiding it from all surfaces. The row is retained for the bi-temporal trail.`,confirmLabel:`Delete`,onConfirm:ae,variant:`destructive`})]})}export{H as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryEntityGraphPage-C4ZTGQF7.js b/internal/web/dist/assets/MemoryEntityGraphPage-C4ZTGQF7.js deleted file mode 100644 index f3da2be..0000000 --- a/internal/web/dist/assets/MemoryEntityGraphPage-C4ZTGQF7.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{t as r}from"./network-CrANvqlb.js";import{Fr as i,Or as a,Rr as o,n as s,rt as c,t as l}from"./index-BDLzoIgt.js";import{t as u}from"./MemoryGraphCanvas-C1QtLEIq.js";var d=e(t(),1),f=n();function p(e){let t=new Map,n=new Map;return{graph:{nodes:e.nodes.map(e=>{let r=`${e.kind}:${e.id}`;return t.set(r,e.kind),n.set(r,e.id),{id:r,title:`${e.kind}:${e.id}`,kind:e.kind,tags:[],created_at:e.last_linked_at,size:e.memory_count,pinned:!1}}),edges:e.edges.map(e=>({source:e.source,target:e.target,weight:e.weight,reason:`co_tag`})),truncated:e.truncated,node_cap:e.node_cap},kindByNodeID:t,idByNodeID:n}}function m(){let e=o(),[t,n]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(!0),[v,y]=(0,d.useState)(1);(0,d.useEffect)(()=>{let e=!1;return _(!0),c({node_cap:200,min_weight:v}).then(t=>{e||n(t)}).catch(t=>{e||(h(t instanceof Error?t.message:`Load failed`),n(null))}).finally(()=>{e||_(!1)}),()=>{e=!0}},[v]);let b=(0,d.useMemo)(()=>t?p(t):null,[t]),x=(0,d.useCallback)(t=>{if(!b)return;let n=b.kindByNodeID.get(t),r=b.idByNodeID.get(t);!n||!r||e(`/memory/about/${encodeURIComponent(n)}/${encodeURIComponent(r)}`)},[b,e]);return(0,f.jsxs)(`div`,{className:`flex h-full flex-col space-y-4`,children:[(0,f.jsxs)(i,{to:`/memory`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,f.jsx)(a,{className:`h-3 w-3`}),`Memory`]}),(0,f.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,f.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,f.jsx)(r,{className:`h-5 w-5 text-primary`}),`Entity graph`]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-4 font-mono text-[11px] text-muted-foreground`,children:[(0,f.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,f.jsx)(`span`,{children:`min weight`}),(0,f.jsx)(`input`,{type:`number`,min:0,max:20,value:v,onChange:e=>y(Number(e.target.value)||0),className:`w-14 border border-border bg-background/60 px-1.5 py-0.5 text-foreground`})]}),t&&(0,f.jsxs)(`span`,{className:`tabular-nums`,children:[t.nodes.length,` nodes · `,t.edges.length,` edges`,t.truncated&&` · capped`]})]})]}),(0,f.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Each node is an entity that at least one memory is about. Edges connect entities that co-link in the same memory; edge weight = number of shared memories. Click a node to pivot into "everything about ⟨that entity⟩".`}),(0,f.jsx)(l,{className:`flex-1 overflow-hidden`,children:(0,f.jsxs)(s,{className:`h-full p-0`,children:[g&&!t&&(0,f.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-muted-foreground`,children:[(0,f.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading graph…`]}),m&&(0,f.jsxs)(`div`,{className:`flex h-full items-center justify-center text-destructive`,children:[`Error: `,m]}),!g&&t&&t.nodes.length===0&&(0,f.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[`No entities linked to memories yet. Save memories with`,` `,(0,f.jsxs)(`code`,{className:`mx-1 font-mono text-foreground/80`,children:[`entities=[`,`{kind, id}`,`]`]}),` `,`to populate this view.`]}),b&&b.graph.nodes.length>0&&(0,f.jsx)(u,{graph:b.graph,onSelect:x})]})})]})}export{m as MemoryEntityGraphPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryGraphCanvas-C1QtLEIq.js b/internal/web/dist/assets/MemoryGraphCanvas-C1QtLEIq.js deleted file mode 100644 index 337ed25..0000000 --- a/internal/web/dist/assets/MemoryGraphCanvas-C1QtLEIq.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";var r=e(t(),1),i=300,a=.992,o=60,s=.05,c=-200,l=.02,u=.85;function d(e){let{nodes:t,edges:n,width:d,height:f}=e,[p,m]=(0,r.useState)({}),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)({x:0,y:0,k:1}),y=(0,r.useRef)({}),b=(0,r.useRef)({}),x=(0,r.useRef)(new Set),S=(0,r.useRef)(null),C=(0,r.useRef)(null),w=(0,r.useRef)(1),T=(0,r.useRef)(0),E=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e={},n={};t.forEach((t,r)=>{let i=y.current[t.id];if(i){e[t.id]=i,n[t.id]=b.current[t.id]??{vx:0,vy:0};return}let a=r*.5,o=20+Math.sqrt(r)*8;e[t.id]={x:d/2+Math.cos(a)*o,y:f/2+Math.sin(a)*o},n[t.id]={vx:0,vy:0}}),y.current=e,b.current=n,w.current=1,T.current=0,m(e)},[t,f,d]),(0,r.useEffect)(()=>{if(t.length===0)return;let e=t.length>1500,r=()=>{let t=w.current,p=y.current,h=b.current,g=x.current,_=d/2,v=f/2;for(let e in p){if(g.has(e))continue;let n=p[e],r=h[e];r.vx+=(_-n.x)*l*t,r.vy+=(v-n.y)*l*t}if(!e){let e=Object.keys(p);for(let n=0;ni&&(w.current*=a),m({...p}),w.current>.01||S.current?E.current=requestAnimationFrame(r):E.current=null};return E.current=requestAnimationFrame(r),()=>{E.current&&cancelAnimationFrame(E.current),E.current=null}},[t,n,d,f]);let D=(0,r.useCallback)((e,t,n)=>({x:(e-n.left-_.x)/_.k,y:(t-n.top-_.y)/_.k}),[_]),O=(0,r.useCallback)((e,t)=>{e.stopPropagation();let n=e.currentTarget;n.setPointerCapture?.(e.pointerId);let r=n.ownerSVGElement;if(!r)return;let i=r.getBoundingClientRect(),a=D(e.clientX,e.clientY,i),o=y.current[t];o&&(x.current.add(t),S.current={id:t,offsetX:o.x-a.x,offsetY:o.y-a.y},w.current=Math.max(w.current,.6))},[D]),k=(0,r.useCallback)(e=>{if(S.current){let t=e.currentTarget.getBoundingClientRect(),n=D(e.clientX,e.clientY,t),{id:r,offsetX:i,offsetY:a}=S.current,o=y.current[r];o&&(o.x=n.x+i,o.y=n.y+a);return}if(C.current){let t=e.clientX-C.current.x,n=e.clientY-C.current.y;C.current={x:e.clientX,y:e.clientY},v(e=>({...e,x:e.x+t,y:e.y+n}))}},[D]),A=(0,r.useCallback)(()=>{S.current&&=(x.current.delete(S.current.id),null),C.current=null},[]),j=(0,r.useCallback)(e=>{(e.target.tagName===`svg`||e.target.tagName===`g`)&&(C.current={x:e.clientX,y:e.clientY})},[]),M=(0,r.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;v(t=>{let i=e.deltaY<0?1.1:1/1.1,a=Math.max(.2,Math.min(4,t.k*i));return{x:n-(n-t.x)*(a/t.k),y:r-(r-t.y)*(a/t.k),k:a}})},[]);return(0,r.useMemo)(()=>({positions:p,hoveredId:h,setHoveredId:g,transform:_,onPointerDown:O,onPointerMove:k,onPointerUp:A,onWheel:M,onCanvasDown:j}),[p,h,_,O,k,A,M,j])}var f=n(),p={fact:`#38bdf8`,note:`#a78bfa`},m=`#94a3b8`;function h(e){return p[e.kind]??m}function g({graph:e,onSelect:t}){let n=(0,r.useRef)(null),[i,a]=(0,r.useState)({width:800,height:560});(0,r.useEffect)(()=>{if(!n.current)return;let e=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:r}=t.contentRect;a({width:Math.max(360,n),height:Math.max(360,r)})});return e.observe(n.current),()=>e.disconnect()},[]);let{positions:o,onPointerDown:s,onPointerMove:c,onPointerUp:l,hoveredId:u,setHoveredId:p,transform:m,onWheel:g,onCanvasDown:x}=d({nodes:e.nodes,edges:e.edges,width:i.width,height:i.height}),S=(0,r.useMemo)(()=>e.nodes.find(e=>e.id===u)??null,[u,e.nodes]);return(0,f.jsxs)(`div`,{ref:n,className:`relative h-[560px] w-full select-none overflow-hidden bg-gradient-to-br from-background to-muted/30`,children:[(0,f.jsx)(`svg`,{width:i.width,height:i.height,onMouseDown:x,onWheel:g,onPointerMove:c,onPointerUp:l,onPointerLeave:l,style:{cursor:`grab`},children:(0,f.jsxs)(`g`,{transform:`translate(${m.x},${m.y}) scale(${m.k})`,children:[e.edges.map((e,t)=>(0,f.jsx)(y,{edge:e,positions:o,hoveredId:u},t)),e.nodes.map(e=>{let n=o[e.id];if(!n)return null;let r=_(e),i=u===e.id;return(0,f.jsxs)(`g`,{transform:`translate(${n.x},${n.y})`,onPointerDown:t=>s(t,e.id),onMouseEnter:()=>p(e.id),onMouseLeave:()=>p(null),onClick:n=>{n.stopPropagation(),t(e.id)},style:{cursor:`pointer`},children:[e.pinned&&(0,f.jsx)(`circle`,{r:r+3,fill:`none`,stroke:h(e),strokeOpacity:.35,strokeWidth:1}),(0,f.jsx)(`circle`,{r,fill:h(e),fillOpacity:i?1:.85,stroke:i?`#fff`:`rgba(255,255,255,0.15)`,strokeWidth:i?1.5:.5}),(i||r>=6)&&(0,f.jsx)(`text`,{x:r+4,y:3,fontSize:10,fontFamily:`ui-monospace,SFMono-Regular,monospace`,fill:`currentColor`,opacity:i?.95:.55,style:{pointerEvents:`none`},children:v(e.title,40)})]},e.id)})]})}),S&&(0,f.jsx)(b,{node:S})]})}function _(e){let t=3+Math.log2(1+e.size)*1.6;return Math.min(11,t)}function v(e,t){return e.length<=t?e:e.slice(0,t-1)+`…`}function y({edge:e,positions:t,hoveredId:n}){let r=t[e.source],i=t[e.target];if(!r||!i)return null;let a=e.reason===`wikilink`,o=n&&n!==e.source&&n!==e.target;return(0,f.jsx)(`line`,{x1:r.x,y1:r.y,x2:i.x,y2:i.y,stroke:a?`#38bdf8`:`currentColor`,strokeOpacity:o?.05:a?.55:.15+e.weight*.2,strokeWidth:a?1.2:.6+e.weight*.8})}function b({node:e}){return(0,f.jsxs)(`div`,{className:`pointer-events-none absolute right-3 top-3 max-w-[260px] border border-border bg-background/95 p-2 text-xs shadow-md backdrop-blur`,children:[(0,f.jsx)(`div`,{className:`font-semibold leading-tight`,children:e.title}),(0,f.jsxs)(`div`,{className:`mt-0.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[e.kind,` · `,e.size,` link`,e.size===1?``:`s`]}),e.tags&&e.tags.length>0&&(0,f.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-0.5`,children:e.tags.slice(0,6).map(e=>(0,f.jsx)(`span`,{className:`border border-border/60 px-1 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e},e))})]})}export{g as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryLandingPage-BClOIAjh.js b/internal/web/dist/assets/MemoryLandingPage-BClOIAjh.js deleted file mode 100644 index f5933d7..0000000 --- a/internal/web/dist/assets/MemoryLandingPage-BClOIAjh.js +++ /dev/null @@ -1,7 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./createLucideIcon-WB390fY6.js";import{t as a}from"./arrow-up-right-RRuYfAwZ.js";import{t as o}from"./cpu-DpW4CSHk.js";import{t as s}from"./inbox-ClSTJaEn.js";import{t as c}from"./network-CrANvqlb.js";import{t as l}from"./workflow-COO0Sn-w.js";import{Cr as u,Fr as d,Hn as f,Lt as p,Tr as m,Vn as h,_ as g,lt as _,n as v,t as y,y as b,zn as x}from"./index-BDLzoIgt.js";import{t as S}from"./empty-state-B9mtYx_X.js";import{a as ee,n as C,o as w,t as T}from"./use-memory-ChVIui7-.js";import{r as E,t as D}from"./memory-utils-B0WiuphN.js";var te=i(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ne=i(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),O=i(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),k=i(`snowflake`,[[`path`,{d:`m10 20-1.25-2.5L6 18`,key:`18frcb`}],[`path`,{d:`M10 4 8.75 6.5 6 6`,key:`7mghy3`}],[`path`,{d:`m14 20 1.25-2.5L18 18`,key:`1chtki`}],[`path`,{d:`m14 4 1.25 2.5L18 6`,key:`1b4wsy`}],[`path`,{d:`m17 21-3-6h-4`,key:`15hhxa`}],[`path`,{d:`m17 3-3 6 1.5 3`,key:`11697g`}],[`path`,{d:`M2 12h6.5L10 9`,key:`kv9z4n`}],[`path`,{d:`m20 10-1.5 2 1.5 2`,key:`1swlpi`}],[`path`,{d:`M22 12h-6.5L14 15`,key:`1mxi28`}],[`path`,{d:`m4 10 1.5 2L4 14`,key:`k9enpj`}],[`path`,{d:`m7 21 3-6-1.5-3`,key:`j8hb9u`}],[`path`,{d:`m7 3 3 6h4`,key:`1otusx`}]]),A=e(t(),1),j=r();function M({icon:e,label:t,value:r,detail:i,href:o,dim:s,accent:c}){return(0,j.jsxs)(d,{to:o,className:n(`group block border border-border bg-card/40 px-4 py-3.5 transition-colors`,`hover:border-border/80 hover:bg-card focus-visible:outline-none focus-visible:border-primary/60`),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t]}),(0,j.jsx)(a,{className:`h-3 w-3 opacity-0 transition-opacity group-hover:opacity-100`})]}),(0,j.jsx)(`div`,{className:n(`mt-2 font-mono text-3xl font-semibold tracking-tight tabular-nums`,s?`text-muted-foreground/70`:`text-foreground`,c===`awaiting`&&`text-amber-300`),children:r}),(0,j.jsxs)(`div`,{className:n(`mt-1 flex items-center gap-1.5 text-[11px]`,c===`awaiting`?`text-amber-300/80`:`text-muted-foreground`),children:[c===`awaiting`&&(0,j.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[(0,j.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-pulse-slow rounded-full bg-amber-400/60`}),(0,j.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]}),i]})]})}function N({events:e}){return(0,j.jsx)(y,{className:`overflow-hidden`,children:(0,j.jsxs)(v,{className:`space-y-3 p-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(f,{className:`h-4 w-4 text-primary`}),(0,j.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Live activity`})]}),(0,j.jsxs)(d,{to:`/memory/activity`,className:`inline-flex items-center gap-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70 transition-colors hover:text-foreground`,children:[`Full timeline`,(0,j.jsx)(a,{className:`h-3 w-3`})]})]}),e.length===0?(0,j.jsx)(S,{icon:(0,j.jsx)(u,{className:`h-7 w-7`}),title:`Nothing learned yet`,description:`When an agent writes a memory, accepts a peer offer, or completes a consolidation pass, you will see it here in real-time.`,density:`card`,testid:`memory-activity-empty`}):(0,j.jsx)(`ul`,{className:`divide-y divide-border/30 border border-border/40 bg-background/40`,children:e.map(e=>(0,j.jsx)(P,{event:e},`${e.id}-${e.message_id}`))})]})})}function P({event:e}){let t=F(e.kind),r=(0,j.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-muted/20`,children:[(0,j.jsx)(`span`,{className:n(`mt-1 inline-flex h-1.5 w-1.5 shrink-0 rounded-full`,e.priority===`critical`?`bg-red-400`:e.priority===`high`?`bg-orange-400`:`bg-emerald-400/80`)}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium text-foreground`,children:e.title}),(0,j.jsx)(b,{variant:`outline`,tone:`muted`,className:`font-mono text-[9px] uppercase`,children:t}),e.link&&(0,j.jsx)(a,{className:`h-3 w-3 shrink-0 text-muted-foreground/40`})]}),e.body&&(0,j.jsx)(`p`,{className:`mt-0.5 truncate text-[11.5px] text-muted-foreground/90`,children:e.body})]}),(0,j.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:E(e.created_at)})]});return e.link?(0,j.jsx)(`li`,{children:(0,j.jsx)(d,{to:e.link,className:`block`,children:r})}):(0,j.jsx)(`li`,{children:r})}function F(e){return e&&e.replace(/^memory[._]/i,``).replace(/_/g,` `)||`event`}function I(){let e=`@~/.mcplexer/memory-exports/global.md`;return(0,j.jsx)(y,{className:`flex flex-col`,children:(0,j.jsxs)(v,{className:`flex flex-1 flex-col gap-3 p-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Harness integration`}),(0,j.jsxs)(`p`,{className:`mt-2 text-[12px] leading-relaxed text-muted-foreground/90`,children:[`Wire your memories into every agent session. Add this line to your `,(0,j.jsx)(`code`,{className:`font-mono text-foreground/80`,children:`CLAUDE.md`}),` or equivalent harness config and the gateway will keep an up-to-date markdown export pinned for the agent to read on every turn.`]})]}),(0,j.jsxs)(`div`,{className:`group/import flex items-stretch border border-border bg-background/60`,children:[(0,j.jsx)(`code`,{className:`flex-1 truncate px-3 py-2.5 font-mono text-[12.5px] text-emerald-300`,children:e}),(0,j.jsx)(g,{value:e,className:`self-stretch px-2 text-muted-foreground`})]}),(0,j.jsxs)(`p`,{className:`mt-auto text-[11px] text-muted-foreground/60`,children:[`Tip: workspace-scoped memories export to `,(0,j.jsx)(`span`,{className:`font-mono`,children:`workspace-.md`}),` if you want narrower context per project.`]})]})})}function L({to:e,title:t,body:r,accent:i}){return(0,j.jsxs)(d,{to:e,className:n(`group flex flex-col gap-1 border border-border bg-card/40 px-4 py-3 transition-colors`,`hover:border-border/80 hover:bg-card`,i&&`border-amber-500/40`),children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsx)(`span`,{className:n(`text-[13px] font-semibold`,i?`text-amber-300`:`text-foreground`),children:t}),(0,j.jsx)(a,{className:`h-3.5 w-3.5 text-muted-foreground/50 transition-colors group-hover:text-foreground`})]}),(0,j.jsx)(`p`,{className:`text-[11.5px] leading-relaxed text-muted-foreground`,children:r})]})}function R(){let{data:e,loading:t,error:r,refetch:i}=w(),{events:a}=p(),o=(0,A.useMemo)(()=>{let e=a.find(e=>D(e.kind,e.source));return e?e.message_id:``},[a]);if((0,A.useEffect)(()=>{o&&i()},[o,i]),r&&!e)return(0,j.jsx)(z,{message:r,onRetry:i});let s=e??{brain_age_days:0,brain_age_born_at:null,total_memories:0,total_bytes:0,pages_equivalent:0,type_mix:{},recency_buckets:{fresh:0,warm:0,cold:0,dormant:0},writes_per_day_30d:[],network_reach:{shared_memory_count:0,peer_count:0},top_tags:[],decay_pressure:0};return(0,j.jsxs)(`section`,{"aria-label":`Brain stats`,className:n(`grid grid-cols-1 gap-3 border border-border bg-card/30 p-4 transition-opacity md:grid-cols-2 lg:grid-cols-6`,t&&!e?`opacity-70`:`opacity-100`),children:[(0,j.jsx)(B,{stats:s}),(0,j.jsx)(V,{stats:s}),(0,j.jsx)(H,{mix:s.type_mix}),(0,j.jsx)(U,{series:s.writes_per_day_30d}),(0,j.jsx)(W,{buckets:s.recency_buckets}),(0,j.jsx)(G,{stats:s}),s.top_tags.length>0&&(0,j.jsx)(K,{tags:s.top_tags,className:`md:col-span-2 lg:col-span-6`})]})}function z({message:e,onRetry:t}){return(0,j.jsxs)(`section`,{"aria-label":`Brain stats`,className:`flex items-center justify-between gap-3 border border-destructive/40 bg-destructive/5 p-4`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,j.jsx)(x,{className:`h-4 w-4 shrink-0 text-destructive`}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-[13px] font-semibold text-foreground`,children:`Could not load brain stats`}),(0,j.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,title:e,children:e})]})]}),(0,j.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 border border-border px-2.5 py-1 text-[11px] font-medium text-foreground transition-colors hover:bg-card`,children:`Retry`})]})}function B({stats:e}){let t=e.brain_age_born_at?new Date(e.brain_age_born_at):null,n=t?t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}):`—`;return(0,j.jsx)(q,{icon:(0,j.jsx)(u,{className:`h-4 w-4`}),label:`Brain age`,value:e.brain_age_days>0?`${e.brain_age_days}d`:`—`,detail:t?`born ${n}`:`no memories yet`})}function V({stats:e}){let t=Math.round(e.pages_equivalent);return(0,j.jsx)(q,{icon:(0,j.jsx)(m,{className:`h-4 w-4`}),label:`Memories`,value:e.total_memories.toLocaleString(),detail:t>0?`${Q(e.total_bytes)} · ~${t.toLocaleString()} pages`:Q(e.total_bytes)})}function H({mix:e}){let t=(0,A.useMemo)(()=>{let t=Object.entries(e).map(([e,t])=>({kind:e,count:t}));return t.sort((e,t)=>t.count-e.count),t},[e]),n=t.reduce((e,t)=>e+t.count,0);return(0,j.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-3`,children:[(0,j.jsx)(X,{entries:t,size:48}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Type mix`}),t.length===0?(0,j.jsx)(`div`,{className:`mt-1 font-mono text-sm text-muted-foreground/60`,children:`—`}):(0,j.jsx)(`ul`,{className:`mt-1 space-y-0.5`,children:t.slice(0,3).map(e=>(0,j.jsxs)(`li`,{className:`flex items-center gap-2 font-mono text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full`,style:{backgroundColor:Z(e.kind)}}),(0,j.jsx)(`span`,{className:`truncate`,children:e.kind}),(0,j.jsx)(`span`,{className:`ml-auto tabular-nums text-foreground/80`,children:e.count}),(0,j.jsx)(`span`,{className:`tabular-nums text-muted-foreground/50`,children:n>0?`${Math.round(e.count/n*100)}%`:``})]},e.kind))})]})]})}function U({series:e}){let t=e.slice(-7).reduce((e,t)=>e+t.count,0),r=t-e.slice(-14,-7).reduce((e,t)=>e+t.count,0),i=r===0?`·`:r>0?`+${r}`:`${r}`;return(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-3 py-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,j.jsx)(o,{className:`h-3.5 w-3.5`}),`30-day writes`]}),(0,j.jsx)(`span`,{className:n(`font-mono text-[10px]`,r>0?`text-emerald-400`:r<0?`text-rose-400/80`:`text-muted-foreground/60`),children:i})]}),(0,j.jsx)(Y,{points:e}),(0,j.jsxs)(`div`,{className:`font-mono text-[11px] text-muted-foreground tabular-nums`,children:[t,` this week`]})]})}function W({buckets:e}){let t=e.fresh+e.warm+e.cold+e.dormant,n=[{key:`fresh`,count:e.fresh,color:`#34d399`,label:`≤7d`},{key:`warm`,count:e.warm,color:`#fbbf24`,label:`≤30d`},{key:`cold`,count:e.cold,color:`#60a5fa`,label:`≤180d`},{key:`dormant`,count:e.dormant,color:`#64748b`,label:`>180d`}];return(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-3 py-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,j.jsx)(O,{className:`h-3.5 w-3.5`}),`Recency`]}),(0,j.jsx)(`div`,{className:`flex h-1.5 w-full overflow-hidden border border-border/40 bg-background/40`,role:`img`,"aria-label":`Recency: fresh ${e.fresh}, warm ${e.warm}, cold ${e.cold}, dormant ${e.dormant}`,children:t===0?(0,j.jsx)(`div`,{className:`flex-1 bg-muted/30`}):n.map(e=>(0,j.jsx)(`div`,{className:`h-full`,style:{width:`${e.count/t*100}%`,backgroundColor:e.color},title:`${e.key} ${e.label}: ${e.count}`},e.key))}),(0,j.jsx)(`ul`,{className:`grid grid-cols-2 gap-x-3 gap-y-0.5 font-mono text-[10.5px] text-muted-foreground`,children:n.map(e=>(0,j.jsxs)(`li`,{className:`flex items-center gap-1.5`,children:[(0,j.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{backgroundColor:e.color}}),(0,j.jsx)(`span`,{className:`truncate`,children:e.label}),(0,j.jsx)(`span`,{className:`ml-auto tabular-nums text-foreground/80`,children:e.count})]},e.key))})]})}function G({stats:e}){let t=e.network_reach.peer_count,n=e.network_reach.shared_memory_count,r=e.decay_pressure;return(0,j.jsxs)(`div`,{className:`flex flex-col gap-3 px-3 py-3`,children:[(0,j.jsx)(J,{icon:(0,j.jsx)(c,{className:`h-3.5 w-3.5`}),label:`Network reach`,value:t>0?`${t} peer${t===1?``:`s`}`:`—`,detail:n>0?`${n} shared memor${n===1?`y`:`ies`}`:`local only`}),(0,j.jsx)(J,{icon:r>0?(0,j.jsx)(ne,{className:`h-3.5 w-3.5 text-amber-400/80`}):(0,j.jsx)(k,{className:`h-3.5 w-3.5`}),label:`Decay pressure`,value:r>0?r.toLocaleString():`0`,detail:r>0?`overdue for review (>180d, unpinned)`:`all current`,href:r>0?`/memory/all?stale=1`:void 0,accent:r>0?`warn`:void 0})]})}function K({tags:e,className:t}){return(0,j.jsxs)(`div`,{className:n(`flex flex-wrap items-center gap-2 border-t border-border/40 pt-3`,t),children:[(0,j.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Top tags`}),(0,j.jsx)(`ul`,{className:`flex flex-wrap items-center gap-1.5`,children:e.map(e=>(0,j.jsxs)(`li`,{className:`inline-flex items-center gap-1.5 border border-border/60 bg-background/40 px-2 py-0.5 font-mono text-[10.5px]`,children:[(0,j.jsx)(`span`,{className:`text-foreground/90`,children:e.tag}),(0,j.jsx)(`span`,{className:`tabular-nums text-muted-foreground`,children:e.count})]},e.tag))})]})}function q({icon:e,label:t,value:r,detail:i,href:o,accent:s}){let c=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t]}),o&&(0,j.jsx)(a,{className:`h-3 w-3 opacity-0 transition-opacity group-hover:opacity-100`})]}),(0,j.jsx)(`div`,{className:n(`mt-1.5 font-mono text-[26px] font-semibold leading-none tracking-tight tabular-nums`,s===`warn`?`text-amber-300`:`text-foreground`),children:r}),i&&(0,j.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-muted-foreground`,children:i})]});return o?(0,j.jsx)(d,{to:o,className:`group block px-3 py-3 transition-colors hover:bg-card/60`,children:c}):(0,j.jsx)(`div`,{className:`px-3 py-3`,children:c})}function J({icon:e,label:t,value:r,detail:i,href:a,accent:o}){let s=(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`inline-flex h-6 w-6 shrink-0 items-center justify-center border border-border/40 bg-background/40 text-muted-foreground`,children:e}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`div`,{className:`text-[10px] uppercase tracking-[0.14em] text-muted-foreground/80`,children:t}),(0,j.jsx)(`div`,{className:n(`font-mono text-[15px] font-semibold leading-tight tabular-nums`,o===`warn`?`text-amber-300`:`text-foreground`),children:r}),i&&(0,j.jsx)(`div`,{className:`text-[10.5px] leading-snug text-muted-foreground/80`,children:i})]})]});return a?(0,j.jsx)(d,{to:a,className:`block transition-colors hover:opacity-90`,children:s}):s}function Y({points:e}){if(e.length===0)return(0,j.jsx)(`div`,{className:`h-7 bg-muted/20`});let t=Math.max(1,...e.map(e=>e.count)),n=e.length>1?140/(e.length-1):0,r=e.map((e,r)=>{let i=r*n,a=28-e.count/t*26-1;return`${r===0?`M`:`L`}${i.toFixed(1)},${a.toFixed(1)}`}).join(` `),i=`${r} L${140 .toFixed(1)},28 L0,28 Z`,a=e.length-1,o=e[a],s=a*n,c=28-o.count/t*26-1;return(0,j.jsxs)(`svg`,{width:`100%`,height:28,viewBox:`0 0 140 28`,preserveAspectRatio:`none`,className:`block`,role:`img`,"aria-label":`30-day write activity sparkline`,children:[(0,j.jsx)(`path`,{d:i,fill:`currentColor`,className:`text-primary/15`}),(0,j.jsx)(`path`,{d:r,fill:`none`,stroke:`currentColor`,strokeWidth:1.25,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-primary/90`}),(0,j.jsx)(`circle`,{cx:s,cy:c,r:1.6,fill:`currentColor`,className:`text-primary`})]})}function X({entries:e,size:t}){let n=e.reduce((e,t)=>e+t.count,0),r=t/2-4,i=t/2,a=t/2;if(n===0)return(0,j.jsx)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,"aria-hidden":!0,children:(0,j.jsx)(`circle`,{cx:i,cy:a,r,fill:`none`,stroke:`currentColor`,strokeWidth:3,className:`text-muted/40`})});let o=e.map((t,n)=>e.slice(0,n).reduce((e,t)=>e+t.count,0));return(0,j.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,role:`img`,"aria-label":`Memory type distribution`,children:[(0,j.jsx)(`circle`,{cx:i,cy:a,r,fill:`none`,stroke:`currentColor`,strokeWidth:3,className:`text-muted/30`}),e.map((e,t)=>{let s=e.count/n*(2*Math.PI*r),c=2*Math.PI*r-s,l=o[t]/n*360-90;return(0,j.jsx)(`circle`,{cx:i,cy:a,r,fill:`none`,stroke:Z(e.kind),strokeWidth:3,strokeDasharray:`${s} ${c}`,transform:`rotate(${l} ${i} ${a})`},e.kind)}),(0,j.jsx)(`text`,{x:i,y:a+3,textAnchor:`middle`,className:`fill-foreground font-mono`,style:{fontSize:10},children:n})]})}function Z(e){switch(e){case`fact`:return`#60a5fa`;case`note`:return`#a78bfa`;case`preference`:return`#34d399`;case`context`:return`#fbbf24`;case`decision`:return`#f472b6`;default:{let t=[`#94a3b8`,`#22d3ee`,`#fb7185`,`#facc15`,`#4ade80`],n=0;for(let t=0;t>>0;return t[n%t.length]}}}function Q(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var re=`@~/.mcplexer/memory-exports/global.md`,ie=`{ - "kind": "fact", - "name": "Project deploy gate", - "content": "Never deploy a dirty working tree; HEAD must equal origin/main." -}`;function ae(){let e=`curl -X POST ${typeof window<`u`?window.location.origin:`http://localhost:3333`}/api/v1/memory \\ - -H 'Content-Type: application/json' \\ - -d '${ie.replace(/\n/g,` `)}'`;return(0,j.jsx)(y,{children:(0,j.jsxs)(v,{className:`space-y-5 p-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(f,{className:`h-4 w-4 text-primary`}),(0,j.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Getting started`}),(0,j.jsx)(`span`,{className:`ml-auto font-mono text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:`3 steps`})]}),(0,j.jsx)($,{number:1,icon:(0,j.jsx)(u,{className:`h-3.5 w-3.5`}),title:`Wire it into your harness`,body:`Add this @import line to your CLAUDE.md or equivalent harness config so every agent session sees your gateway's memories on every turn.`,snippet:re,language:`markdown`}),(0,j.jsx)($,{number:2,icon:(0,j.jsx)(h,{className:`h-3.5 w-3.5`}),title:`Write your first memory`,body:(0,j.jsxs)(j.Fragment,{children:[`Run this from any terminal. The same shape ships through`,` `,(0,j.jsx)(`code`,{className:`font-mono text-foreground/80`,children:`memory__write_memory`}),` `,`when an agent learns something worth keeping.`]}),snippet:e,language:`bash`}),(0,j.jsx)($,{number:3,icon:(0,j.jsx)(te,{className:`h-3.5 w-3.5`}),title:`Run the consolidator`,body:(0,j.jsxs)(j.Fragment,{children:[`The consolidator worker rolls up duplicates, summarises long notes, and earmarks pin candidates. Configure + enable it from`,` `,(0,j.jsx)(d,{to:`/memory/consolidation`,className:`text-primary hover:underline`,children:`Consolidation`}),` `,`once you have a handful of memories.`]})})]})})}function $({number:e,icon:t,title:n,body:r,snippet:i,language:a}){return(0,j.jsxs)(`div`,{className:`flex gap-3`,children:[(0,j.jsx)(`span`,{className:`mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center border border-border bg-card/60 font-mono text-[10px] tabular-nums text-muted-foreground`,children:e}),(0,j.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:`text-primary/70`,children:t}),(0,j.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:n}),a&&(0,j.jsx)(b,{variant:`outline`,tone:`mono`,className:`font-mono text-[9px]`,children:a})]}),(0,j.jsx)(`p`,{className:`text-[11.5px] leading-relaxed text-muted-foreground`,children:r}),i&&(0,j.jsxs)(`div`,{className:`group/snippet flex items-stretch border border-border bg-background/60`,children:[(0,j.jsx)(`pre`,{className:`flex-1 overflow-x-auto whitespace-pre px-3 py-2 font-mono text-[11.5px] text-emerald-300`,children:i}),(0,j.jsx)(g,{value:i,className:`self-stretch px-2 text-muted-foreground`})]})]})]})}var oe=8;function se(){let[e,t]=(0,A.useState)(null),[n,r]=(0,A.useState)(null);return(0,A.useEffect)(()=>{let e=!1;return _({limit:oe}).then(n=>{e||t(n)}).catch(n=>{e||(r(n instanceof Error?n.message:`Load failed`),t([]))}),()=>{e=!0}},[]),(0,j.jsx)(y,{className:`overflow-hidden`,children:(0,j.jsxs)(v,{className:`space-y-3 p-4`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(f,{className:`h-4 w-4 text-primary`}),(0,j.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Top entities`})]}),(0,j.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:`by memory count`})]}),n&&(0,j.jsxs)(`p`,{className:`text-destructive text-xs`,children:[`Error: `,n]}),e&&e.length===0&&!n&&(0,j.jsx)(S,{icon:(0,j.jsx)(f,{className:`h-7 w-7`}),title:`No entities yet`,description:`When a memory is saved with entities=[{kind,id}] — e.g. linked to a task, person, place, or peer — it shows up here. The consolidator can also extract entity links from notes if you enable that pass.`,density:`card`,testid:`memory-top-entities-empty`}),e&&e.length>0&&(0,j.jsx)(`ul`,{className:`divide-y divide-border/30 border border-border/40 bg-background/40`,children:e.map(e=>(0,j.jsxs)(`li`,{className:`group flex items-center justify-between px-3 py-2.5`,children:[(0,j.jsxs)(d,{to:`/memory/about/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}`,className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,j.jsx)(b,{variant:`outline`,tone:`muted`,className:`font-mono text-[9px] uppercase`,children:e.kind}),(0,j.jsx)(`span`,{className:`truncate text-[13px] font-medium text-foreground group-hover:text-primary`,children:e.id})]}),(0,j.jsxs)(`div`,{className:`ml-3 flex shrink-0 items-center gap-3`,children:[(0,j.jsxs)(`span`,{className:`font-mono text-[11px] tabular-nums text-muted-foreground`,children:[e.memory_count,(0,j.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[` `,`memor`,e.memory_count===1?`y`:`ies`]})]}),(0,j.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:E(e.last_linked_at)}),(0,j.jsx)(a,{className:`h-3 w-3 text-muted-foreground/40 transition-colors group-hover:text-foreground`})]})]},`${e.kind}:${e.id}`))})]})})}function ce(){let{data:e}=C(),{data:t}=ee({pending_only:!0}),{data:n}=T(),{events:r}=p(),i=(0,A.useMemo)(()=>r.filter(e=>D(e.kind,e.source)).slice(0,15),[r]),a=(e?.facts??0)+(e?.notes??0),o=t?.length??0,c=n?n.lastRunAt?`${n.lastRunStatus??`done`} · ${n.enabled}/${n.total} enabled`:n.enabled>0?`enabled · no runs yet`:`not enabled`:`loading…`;return(0,j.jsxs)(`div`,{className:`space-y-6`,children:[(0,j.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,j.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-2xl font-semibold tracking-tight`,children:[(0,j.jsx)(m,{className:`h-5 w-5 text-primary`}),`Memory`]}),(0,j.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Persistent, cross-harness facts and notes your agents have learned. Survives session boundaries, model swaps, even machines — share with paired peers, pull into any MCP-compatible harness.`})]}),(0,j.jsx)(R,{}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,j.jsx)(M,{icon:(0,j.jsx)(l,{className:`h-4 w-4`}),label:`Last consolidation`,value:n?.lastRunAt?E(n.lastRunAt):`—`,detail:c,dim:!n?.lastRunAt,href:`/memory/consolidation`}),(0,j.jsx)(M,{icon:(0,j.jsx)(s,{className:`h-4 w-4`}),label:`Incoming offers`,value:String(o),detail:o>0?`awaiting your review`:`all caught up`,accent:o>0?`awaiting`:`idle`,href:`/memory/shared`})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,j.jsx)(`div`,{className:`lg:col-span-2`,children:a===0?(0,j.jsx)(ae,{}):(0,j.jsx)(N,{events:i})}),(0,j.jsx)(I,{})]}),a>0&&(0,j.jsx)(se,{}),(0,j.jsx)(L,{to:`/memory/all`,title:`Browse all memories`,body:`Search, filter, and inspect every fact and note; pin what matters or invalidate anything stale.`})]})}export{ce as MemoryLandingPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryListPage-CD7dTJ6c.js b/internal/web/dist/assets/MemoryListPage-CD7dTJ6c.js deleted file mode 100644 index cd63f09..0000000 --- a/internal/web/dist/assets/MemoryListPage-CD7dTJ6c.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{n as i,o as a,r as o,t as s}from"./dropdown-menu-iCiwbrNR.js";import{t as c}from"./funnel-BvqzDyhp.js";import{t as l}from"./network-CrANvqlb.js";import{Br as u,Cr as d,Fr as f,Ln as p,Or as m,Sr as h,jr as g,n as _,ot as v,t as y,vt as ee}from"./index-BDLzoIgt.js";import{i as te,r as ne}from"./use-memory-ChVIui7-.js";import{i as b,n as x}from"./memory-utils-B0WiuphN.js";import{t as S}from"./MemoryDetailDrawer-BzR9JTNt.js";import{n as C,t as w}from"./MemoryTable-B1nJtXoa.js";var T=e(t(),1),E=r();function D(e){let{scope:t,onScope:n,kind:r,onKind:i,selectedTags:a,availableTags:o,onToggleTag:s,onClearTags:l,includeInvalid:u,onToggleInvalid:d,staleOnly:f,onToggleStale:p}=e,m=t!==`all`||r!==`all`||a.length>0||u||f;return(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,E.jsxs)(`span`,{className:`mr-1 inline-flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:[(0,E.jsx)(c,{className:`h-3 w-3`}),`Filters`]}),(0,E.jsx)(k,{value:t,onSet:n}),(0,E.jsx)(A,{value:r,onSet:i}),(0,E.jsx)(j,{selected:a,available:o,onToggle:s,onClear:l}),(0,E.jsx)(M,{on:u,onToggle:d}),(0,E.jsx)(N,{on:f,onToggle:p}),m&&(0,E.jsx)(`button`,{type:`button`,onClick:()=>{n(`all`),i(`all`),l(),u&&d(),f&&p()},"data-testid":`memory-filters-clear`,className:`ml-1 text-[11px] text-muted-foreground hover:text-foreground`,children:`Clear filters`})]})}function O({active:e,children:t,testid:r,onClear:i}){return(0,E.jsxs)(`span`,{"data-testid":r,className:n(`inline-flex items-center gap-1 border px-2 py-1 font-mono text-[12px] transition-colors`,e?`border-primary/40 bg-primary/5 text-foreground`:`border-dashed border-border text-muted-foreground hover:border-border/80 hover:text-foreground`),children:[t,e&&i&&(0,E.jsx)(`button`,{type:`button`,"aria-label":`Clear filter`,onClick:e=>{e.stopPropagation(),i()},className:`ml-0.5 -mr-0.5 text-muted-foreground hover:text-foreground`,children:(0,E.jsx)(p,{className:`h-3 w-3`})})]})}function k({value:e,onSet:t}){let r=e!==`all`;return(0,E.jsxs)(s,{children:[(0,E.jsx)(a,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,"data-testid":`memory-filter-scope`,children:(0,E.jsx)(O,{active:r,onClear:()=>t(`all`),children:r?(0,E.jsxs)(E.Fragment,{children:[`scope = `,(0,E.jsx)(`span`,{className:`text-primary`,children:e})]}):`+ Scope`})})}),(0,E.jsx)(i,{align:`start`,children:[`all`,`workspace`,`global`,`peer`].map(r=>(0,E.jsxs)(o,{onClick:()=>t(r),children:[(0,E.jsx)(h,{className:n(`mr-2 h-3 w-3`,e===r?`opacity-100`:`opacity-0`)}),(0,E.jsx)(`span`,{className:`capitalize`,children:r})]},r))})]})}function A({value:e,onSet:t}){let r=e!==`all`;return(0,E.jsxs)(s,{children:[(0,E.jsx)(a,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,"data-testid":`memory-filter-kind`,children:(0,E.jsx)(O,{active:r,onClear:()=>t(`all`),children:r?(0,E.jsxs)(E.Fragment,{children:[`kind = `,(0,E.jsx)(`span`,{className:`text-primary`,children:e})]}):`+ Kind`})})}),(0,E.jsx)(i,{align:`start`,children:[`all`,`fact`,`note`].map(r=>(0,E.jsxs)(o,{onClick:()=>t(r),children:[(0,E.jsx)(h,{className:n(`mr-2 h-3 w-3`,e===r?`opacity-100`:`opacity-0`)}),(0,E.jsx)(`span`,{className:`capitalize`,children:r})]},r))})]})}function j({selected:e,available:t,onToggle:r,onClear:c}){let l=e.length>0,u=l?e.length===1?`tag = ${e[0]}`:`tags = ${e.length}`:`+ Tag`;return(0,E.jsxs)(s,{children:[(0,E.jsx)(a,{asChild:!0,children:(0,E.jsx)(`button`,{type:`button`,"data-testid":`memory-filter-tag`,children:(0,E.jsx)(O,{active:l,onClear:c,children:l?(0,E.jsx)(`span`,{className:`text-primary`,children:u}):u})})}),(0,E.jsxs)(i,{align:`start`,className:`max-h-[260px] min-w-[12rem] overflow-y-auto`,children:[t.length===0&&(0,E.jsx)(o,{disabled:!0,children:(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:`No tags in current view`})}),t.map(t=>(0,E.jsxs)(o,{onSelect:e=>{e.preventDefault(),r(t)},children:[(0,E.jsx)(h,{className:n(`mr-2 h-3 w-3`,e.includes(t)?`opacity-100`:`opacity-0`)}),(0,E.jsx)(`span`,{className:`font-mono text-[12px]`,children:t})]},t))]})]})}function M({on:e,onToggle:t}){return(0,E.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`memory-filter-invalid`,children:(0,E.jsx)(O,{active:e,onClear:e?t:void 0,children:e?(0,E.jsx)(`span`,{className:`text-primary`,children:`+ invalidated rows`}):`Hide invalidated`})})}function N({on:e,onToggle:t}){return(0,E.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`memory-filter-stale`,children:(0,E.jsx)(O,{active:e,onClear:e?t:void 0,children:e?(0,E.jsx)(`span`,{className:`text-primary`,children:`stale · needs review`}):`+ Stale`})})}var P=200,F=250,I=4320*60*60*1e3;function L(e){if(e.pinned||e.t_valid_end)return!1;let t=new Date(e.updated_at).getTime();return Number.isFinite(t)&&Date.now()-t>I}function R(){let[e,t]=u(),[n,r]=(0,T.useState)(`all`),[i,a]=(0,T.useState)(`all`),[o,s]=(0,T.useState)([]),[c,p]=(0,T.useState)(!1),[h,O]=(0,T.useState)(()=>e.get(`stale`)===`1`);(0,T.useEffect)(()=>{O(e.get(`stale`)===`1`)},[e]);let[k,A]=(0,T.useState)(``),[j,M]=(0,T.useState)(``),[N,I]=(0,T.useState)(null),[R,z]=(0,T.useState)(!1);(0,T.useEffect)(()=>{let e=setTimeout(()=>M(k.trim()),k?F:0);return()=>clearTimeout(e)},[k]),(0,T.useEffect)(()=>{let e=!1;return j?(queueMicrotask(()=>{e||(z(!0),ee({query:j,kind:i===`all`?void 0:i,tags:o.length>0?o:void 0,include_invalid:c,limit:100}).then(t=>{e||I(t.map(e=>e.entry))}).catch(t=>{e||(g.error(t instanceof Error?t.message:`Search failed`),I([]))}).finally(()=>{e||z(!1)}))}),()=>{e=!0}):(queueMicrotask(()=>{e||(I(null),z(!1))}),()=>{e=!0})},[j,i,o,c]);let{data:B,loading:V,error:H,refetch:U}=ne((0,T.useMemo)(()=>({kind:i===`all`?void 0:i,limit:P,include_invalid:c}),[i,c])),W=te(),G=(0,T.useMemo)(()=>(j?N??[]:B??[]).filter(e=>{let t=b(e);return!(n!==`all`&&t!==n)}).filter(e=>!h||L(e)).filter(e=>{if(o.length===0)return!0;let t=x(e.tags);return o.every(e=>t.includes(e))}),[j,N,B,n,h,o]),re=(0,T.useMemo)(()=>{let e=(j?N??[]:B??[]).filter(e=>{let t=b(e);return!(n!==`all`&&t!==n||h&&!L(e))}),t=new Set;for(let n of e)for(let e of x(n.tags))t.add(e);return Array.from(t).sort()},[j,N,B,n,h]),K=e.get(`selected`)??e.get(`id`),[q,J]=(0,T.useState)(null);(0,T.useEffect)(()=>{if(!K){J(null);return}if(G.some(e=>e.id===K)){J(null);return}let e=!1;return v(K).then(t=>{e||J(t)}).catch(()=>{e||J(null)}),()=>{e=!0}},[K,G]);let Y=(0,T.useMemo)(()=>K?G.find(e=>e.id===K)??q:null,[K,G,q]),X=(0,T.useCallback)(e=>{t(t=>{let n=new URLSearchParams(t);return e?(n.set(`selected`,e.id),n.delete(`id`)):(n.delete(`selected`),n.delete(`id`)),n},{replace:!0})},[t]),Z=Y?G.findIndex(e=>e.id===Y.id):-1,Q=Z>0,$=Z>=0&&Zt.includes(e)?t.filter(t=>t!==e):[...t,e])}function ae(){t(e=>{let t=new URLSearchParams(e);return h?t.delete(`stale`):t.set(`stale`,`1`),t},{replace:!0})}async function oe(e){try{await W.invalidate(e),g.success(`Memory invalidated`),U()}catch(e){g.error(e instanceof Error?e.message:`Invalidate failed`)}}async function se(e){try{await W.delete(e),g.success(`Memory deleted`),U()}catch(e){g.error(e instanceof Error?e.message:`Delete failed`)}}async function ce(e,t){try{await W.setPinned(e,t),g.success(t?`Memory pinned`:`Memory unpinned`),U()}catch(e){g.error(e instanceof Error?e.message:`Pin update failed`)}}return(0,E.jsxs)(`div`,{className:`space-y-5`,children:[(0,E.jsxs)(f,{to:`/memory`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(m,{className:`h-3 w-3`}),`Memory`]}),(0,E.jsxs)(`header`,{className:`flex items-center justify-between`,children:[(0,E.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,E.jsx)(d,{className:`h-5 w-5 text-primary`}),`All memories`]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,E.jsxs)(f,{to:`/memory/graph`,className:`inline-flex items-center gap-1 border border-border px-2 py-1 font-mono text-[11px] text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground`,children:[(0,E.jsx)(l,{className:`h-3 w-3`}),`Graph view`]}),(0,E.jsxs)(`span`,{className:`font-mono text-[11px] tabular-nums text-muted-foreground`,children:[G.length,` shown`]})]})]}),(0,E.jsx)(C,{value:k,onChange:A,onSubmit:()=>M(k.trim()),onClear:()=>{A(``),M(``)},searching:R,hitCount:N?N.length:null}),(0,E.jsx)(D,{scope:n,onScope:r,kind:i,onKind:a,selectedTags:o,availableTags:re,onToggleTag:ie,onClearTags:()=>s([]),includeInvalid:c,onToggleInvalid:()=>p(e=>!e),staleOnly:h,onToggleStale:ae}),(0,E.jsx)(y,{children:(0,E.jsxs)(_,{className:`pt-6`,children:[V&&!B&&(0,E.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,E.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading…`]}),H&&(0,E.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,H]}),(0,E.jsx)(w,{rows:G,loading:V,selectedId:Y?.id,onSelect:X,hasQuery:!!j})]})}),(0,E.jsx)(S,{entry:Y,onClose:()=>X(null),onPrev:()=>{Q&&X(G[Z-1])},onNext:()=>{$&&X(G[Z+1])},hasPrev:Q,hasNext:$,onInvalidate:oe,onDelete:se,onTogglePin:ce})]})}export{R as MemoryListPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryOffersPage-BJi7VuVy.js b/internal/web/dist/assets/MemoryOffersPage-BJi7VuVy.js deleted file mode 100644 index 55afb5f..0000000 --- a/internal/web/dist/assets/MemoryOffersPage-BJi7VuVy.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{i,n as a,r as o,t as s}from"./tabs-Q9rOz2uL.js";import{t as c}from"./circle-x--B2BKH4R.js";import{t as l}from"./inbox-ClSTJaEn.js";import{n as u,t as d}from"./users-Bsr8fkGR.js";import{t as f}from"./share-2-Da_vtMGy.js";import{Fn as p,Fr as m,Hn as h,Lt as g,Or as _,Q as v,br as y,jr as b,n as x,nr as S,t as C}from"./index-BDLzoIgt.js";import{t as w}from"./empty-state-B9mtYx_X.js";import{a as T,i as E}from"./use-memory-ChVIui7-.js";import{a as D,t as O}from"./memory-primitives-C7gBVkiY.js";import{n as k,r as A}from"./memory-utils-B0WiuphN.js";var j=e(t(),1),M=r();function N({offer:e,onChange:t}){let n=E(),[r,i]=(0,j.useState)(null);async function a(){i(`accept`);try{let r=await v({name:e.name,kind:e.kind,content:e.preview||e.description||``,tags:k(e.tags),metadata:{imported_from_peer_id:e.peer_id,imported_from_peer_name:e.peer_name,remote_id:e.remote_id,embed_model:e.embed_model}});await n.acceptOffer(e.id,r.id),b.success(`Accepted offer from ${e.peer_name||`peer`}`),t()}catch(e){b.error(e instanceof Error?e.message:`Accept failed`)}finally{i(null)}}async function o(){i(`decline`);try{await n.declineOffer(e.id),b.success(`Offer declined`),t()}catch(e){b.error(e instanceof Error?e.message:`Decline failed`)}finally{i(null)}}let s=e.peer_name||`unknown peer`,l=e.peer_id.slice(0,10)+`…`+e.peer_id.slice(-4),u=e.preview||e.description||``,d=k(e.tags);return(0,M.jsx)(C,{className:`overflow-hidden border-emerald-500/20`,"data-testid":`memory-offer-${e.id}`,children:(0,M.jsxs)(x,{className:`space-y-3 p-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(O,{kind:e.kind}),(0,M.jsxs)(`span`,{className:`truncate text-[11px] font-medium text-emerald-300`,children:[`from `,s]})]}),(0,M.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-muted-foreground/70`,title:e.peer_id,children:l})]}),(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground`,children:A(e.received_at)})]}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(`p`,{className:`break-all font-mono text-[13px] font-medium text-foreground`,children:e.name}),u&&(0,M.jsx)(`p`,{className:`line-clamp-3 text-[12.5px] leading-relaxed text-muted-foreground/90`,children:u})]}),d.length>0&&(0,M.jsx)(D,{tags:d,max:6}),(0,M.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/30 pt-3`,children:[(0,M.jsxs)(p,{variant:`outline`,size:`sm`,disabled:r!==null,onClick:o,className:`gap-1.5 border-destructive/30 text-destructive hover:bg-destructive/5`,"data-testid":`memory-offer-${e.id}-decline`,children:[r===`decline`?(0,M.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(c,{className:`h-3.5 w-3.5`}),`Decline`]}),(0,M.jsxs)(p,{variant:`default`,size:`sm`,disabled:r!==null,onClick:a,className:`gap-1.5`,"data-testid":`memory-offer-${e.id}-accept`,children:[r===`accept`?(0,M.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(y,{className:`h-3.5 w-3.5`}),`Accept`]})]})]})})}function P(){let{data:e,refetch:t}=T({pending_only:!1,limit:100}),{events:n}=g(),r=n[0]?.id;(0,j.useEffect)(()=>{r&&t()},[r,t]);let c=(0,j.useMemo)(()=>(e??[]).filter(e=>!e.accepted_at&&!e.declined_at),[e]),d=(0,j.useMemo)(()=>(e??[]).filter(e=>e.accepted_at||e.declined_at).slice(0,20),[e]);return(0,M.jsxs)(`div`,{className:`space-y-5`,children:[(0,M.jsxs)(m,{to:`/memory`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,M.jsx)(_,{className:`h-3 w-3`}),`Memory`]}),(0,M.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,M.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,M.jsx)(f,{className:`h-5 w-5 text-primary`}),`Shared memories`]}),(0,M.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Memories your paired peers have offered to share, and memories you have offered to them. Accept to pull the full content into your local store.`})]}),(0,M.jsxs)(s,{defaultValue:`incoming`,className:`w-full`,children:[(0,M.jsxs)(o,{variant:`line`,className:`border-b border-border`,children:[(0,M.jsxs)(i,{value:`incoming`,"data-testid":`memory-offers-tab-incoming`,children:[(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),`Incoming`,c.length>0&&(0,M.jsx)(`span`,{className:`ml-1.5 inline-flex h-4 min-w-4 items-center justify-center rounded-sm bg-emerald-500/20 px-1 font-mono text-[10px] text-emerald-300`,children:c.length})]}),(0,M.jsxs)(i,{value:`outgoing`,"data-testid":`memory-offers-tab-outgoing`,children:[(0,M.jsx)(u,{className:`h-3.5 w-3.5`}),`Outgoing`]}),(0,M.jsxs)(i,{value:`history`,"data-testid":`memory-offers-tab-history`,children:[(0,M.jsx)(h,{className:`h-3.5 w-3.5`}),`History`]})]}),(0,M.jsx)(a,{value:`incoming`,className:`space-y-3 pt-5`,children:(0,M.jsx)(F,{offers:c,onChange:t})}),(0,M.jsx)(a,{value:`outgoing`,className:`pt-5`,children:(0,M.jsx)(w,{icon:(0,M.jsx)(u,{className:`h-7 w-7`}),title:`Outgoing offers — coming soon`,description:`The mesh layer will let you offer any local memory to a paired peer with a single click. Track delivery + acceptance status here.`,density:`card`,testid:`memory-offers-outgoing-empty`})}),(0,M.jsx)(a,{value:`history`,className:`space-y-2 pt-5`,children:(0,M.jsx)(I,{offers:d})})]})]})}function F({offers:e,onChange:t}){return e.length===0?(0,M.jsx)(w,{icon:(0,M.jsx)(d,{className:`h-7 w-7`}),title:`No incoming offers`,description:`When a paired peer shares a memory, it lands here. You stay in control — the gateway never pulls remote content without your explicit accept.`,density:`card`,testid:`memory-offers-incoming-empty`}):(0,M.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:e.map(e=>(0,M.jsx)(N,{offer:e,onChange:t},e.id))})}function I({offers:e}){return e.length===0?(0,M.jsx)(w,{title:`No offer history yet`,description:`Once you accept or decline offers, they will appear here for reference.`,density:`card`}):(0,M.jsx)(`ul`,{className:`divide-y divide-border/40 border border-border/40 bg-background/40`,children:e.map(e=>{let t=!!e.accepted_at;return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5`,"data-testid":`memory-offer-history-${e.id}`,children:[(0,M.jsx)(`span`,{className:n(`inline-flex h-1.5 w-1.5 shrink-0 rounded-full`,t?`bg-emerald-400`:`bg-muted-foreground/40`)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate font-mono text-[12.5px] text-foreground`,children:e.name}),(0,M.jsx)(`span`,{className:n(`font-mono text-[9px] uppercase tracking-wider`,t?`text-emerald-300/80`:`text-muted-foreground/60`),children:t?`accepted`:`declined`})]}),(0,M.jsxs)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:[`from `,e.peer_name||`unknown`,` ·`,` `,A(e.accepted_at||e.declined_at||e.received_at)]})]})]},e.id)})})}export{P as MemoryOffersPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryTable-B1nJtXoa.js b/internal/web/dist/assets/MemoryTable-B1nJtXoa.js deleted file mode 100644 index 5811324..0000000 --- a/internal/web/dist/assets/MemoryTable-B1nJtXoa.js +++ /dev/null @@ -1 +0,0 @@ -import{in as e,on as t}from"./client-CaIRceNv.js";import{t as n}from"./corner-down-left-DusgzzkI.js";import{Cr as r,Ln as i,Mr as a,Nr as o,Pr as s,nr as c,qn as l}from"./index-BDLzoIgt.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./table-2N0Q-yAm.js";import{a as g,i as _,n as v,r as y,t as b}from"./memory-primitives-C7gBVkiY.js";import{i as x,n as S,r as C}from"./memory-utils-B0WiuphN.js";var w=t();function T({value:t,onChange:r,onSubmit:a,onClear:o,searching:s,hitCount:u}){let d=!s&&t.trim().length>0;return(0,w.jsxs)(`div`,{className:e(`group/search flex items-stretch border border-border bg-card transition-colors`,`focus-within:border-primary/60`),children:[(0,w.jsx)(`div`,{className:`flex items-center pl-4 pr-3 text-muted-foreground/70 transition-colors group-focus-within/search:text-primary`,children:(0,w.jsx)(l,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,w.jsx)(`input`,{value:t,placeholder:`Search memories: agent name, tag, context…`,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),a()),e.key===`Escape`&&(e.preventDefault(),o())},className:e(`h-12 min-w-0 flex-1 border-0 bg-transparent p-0 pr-3 text-[15px] text-foreground placeholder:text-muted-foreground/60`,`outline-none focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0`),"data-testid":`memory-search`,"aria-label":`Search memories`}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-3 text-[11px] text-muted-foreground/80`,children:[u!==null&&(0,w.jsxs)(`span`,{className:`uppercase tracking-wider`,children:[u,` match`,u===1?``:`es`]}),t&&(0,w.jsx)(`button`,{type:`button`,onClick:o,className:`grid h-7 w-7 place-items-center text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:ring-0 focus-visible:ring-offset-0`,"aria-label":`Clear search`,"data-testid":`memory-search-clear`,children:(0,w.jsx)(i,{className:`h-3.5 w-3.5`})})]}),(0,w.jsxs)(`button`,{type:`button`,onClick:a,disabled:!d,className:e(`flex shrink-0 items-center gap-2 self-stretch border-l border-border px-4`,`text-[11px] uppercase tracking-wider transition-colors`,`focus-visible:ring-0 focus-visible:ring-offset-0`,d?`text-primary/90 hover:bg-primary/10 hover:text-primary`:`cursor-not-allowed text-muted-foreground/40`),"aria-label":`Run search`,children:[s?(0,w.jsx)(c,{className:`h-3.5 w-3.5 animate-spin`}):(0,w.jsx)(n,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),(0,w.jsx)(`span`,{className:`font-semibold`,children:`Search`})]})]})}function E({rows:e,loading:t,selectedId:n,onSelect:i,hasQuery:a}){return(0,w.jsxs)(h,{className:`table-fixed`,children:[(0,w.jsxs)(`colgroup`,{children:[(0,w.jsx)(`col`,{className:`w-[7rem]`}),(0,w.jsx)(`col`,{className:`w-[16rem]`}),(0,w.jsx)(`col`,{className:`hidden md:table-column w-[5rem]`}),(0,w.jsx)(`col`,{className:`hidden md:table-column w-[6rem]`}),(0,w.jsx)(`col`,{className:`hidden lg:table-column w-[6rem]`}),(0,w.jsx)(`col`,{className:`hidden lg:table-column w-[12rem]`}),(0,w.jsx)(`col`,{})]}),(0,w.jsx)(u,{children:(0,w.jsxs)(p,{className:`border-border/50 hover:bg-transparent`,children:[(0,w.jsx)(d,{children:`Time`}),(0,w.jsx)(d,{children:`Name`}),(0,w.jsx)(d,{className:`hidden md:table-cell`,children:`Kind`}),(0,w.jsx)(d,{className:`hidden md:table-cell`,children:`Scope`}),(0,w.jsx)(d,{className:`hidden lg:table-cell`,children:`Source`}),(0,w.jsx)(d,{className:`hidden lg:table-cell`,children:`Tags`}),(0,w.jsx)(d,{children:`Preview`})]})}),(0,w.jsx)(f,{children:e.length===0&&!t?(0,w.jsx)(p,{children:(0,w.jsx)(m,{colSpan:7,className:`h-40`,children:(0,w.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground`,children:[(0,w.jsx)(r,{className:`mb-2 h-7 w-7 text-muted-foreground/40`}),(0,w.jsx)(`p`,{className:`text-sm`,children:`No memories match this view`}),(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:a?`Try a different query, or relax your filters.`:`Once an agent writes a memory, it will appear here.`})]})})}):e.map(e=>(0,w.jsx)(D,{entry:e,selected:n===e.id,onSelect:()=>i(e)},e.id))})]})}function D({entry:t,selected:n,onSelect:r}){return(0,w.jsxs)(p,{className:e(`cursor-pointer border-border/30 hover:bg-muted/30`,!!t.t_valid_end&&`opacity-50`,n&&`bg-primary/5`),onClick:r,"data-testid":`memory-row-${t.id}`,children:[(0,w.jsx)(m,{className:`whitespace-nowrap font-mono text-[11px] text-muted-foreground`,children:(0,w.jsxs)(a,{children:[(0,w.jsx)(s,{asChild:!0,children:(0,w.jsx)(`span`,{children:C(t.created_at)})}),(0,w.jsx)(o,{children:new Date(t.created_at).toLocaleString()})]})}),(0,w.jsx)(m,{children:(0,w.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,w.jsx)(`span`,{className:`truncate font-mono text-[13px] text-foreground`,title:t.name,children:t.name}),t.pinned&&(0,w.jsx)(`span`,{className:`font-mono text-[9px] uppercase tracking-wider text-amber-300/90`,children:`pinned`})]})}),(0,w.jsx)(m,{className:`hidden md:table-cell`,children:(0,w.jsx)(b,{kind:t.kind})}),(0,w.jsx)(m,{className:`hidden md:table-cell`,children:(0,w.jsx)(y,{scope:x(t)})}),(0,w.jsx)(m,{className:`hidden lg:table-cell`,children:(0,w.jsx)(_,{source:t.source_kind})}),(0,w.jsx)(m,{className:`hidden lg:table-cell`,children:(0,w.jsx)(g,{tags:S(t.tags),max:3})}),(0,w.jsx)(m,{children:(0,w.jsx)(v,{content:t.content})})]})}export{T as n,E as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/MemoryVisualisationPage-MS_Hkrlz.js b/internal/web/dist/assets/MemoryVisualisationPage-MS_Hkrlz.js deleted file mode 100644 index 749b34e..0000000 --- a/internal/web/dist/assets/MemoryVisualisationPage-MS_Hkrlz.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{Br as r,Cr as i,Fr as a,Or as o,Xn as s,jr as c,n as l,ot as u,st as d,t as f}from"./index-BDLzoIgt.js";import{i as p}from"./use-memory-ChVIui7-.js";import{t as m}from"./MemoryDetailDrawer-BzR9JTNt.js";import{t as h}from"./MemoryGraphCanvas-C1QtLEIq.js";var g=e(t(),1),_=n(),v=`#38bdf8`,y=`#a78bfa`;function b(){let[e,t]=r(),[n,b]=(0,g.useState)(null),[S,C]=(0,g.useState)(!0),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)(`all`),[O,k]=(0,g.useState)(!1),A=(0,g.useCallback)(()=>{C(!0),T(null),d({include_invalid:O}).then(e=>b(e)).catch(e=>T(e instanceof Error?e.message:`Failed`)).finally(()=>C(!1))},[O]);(0,g.useEffect)(()=>{A()},[A]);let j=(0,g.useMemo)(()=>{if(!n)return null;if(E===`all`)return n;let e=new Set(n.nodes.filter(e=>e.kind===E).map(e=>e.id));return{...n,nodes:n.nodes.filter(t=>e.has(t.id)),edges:n.edges.filter(t=>e.has(t.source)&&e.has(t.target))}},[n,E]),M=e.get(`selected`),[N,P]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!M){P(null);return}let e=!1;return u(M).then(t=>{e||P(t)}).catch(()=>{e||P(null)}),()=>{e=!0}},[M]);let F=(0,g.useCallback)(e=>{t(t=>{let n=new URLSearchParams(t);return e?n.set(`selected`,e):n.delete(`selected`),n},{replace:!0})},[t]),I=p();async function L(e){try{await I.invalidate(e),c.success(`Memory invalidated`),A()}catch(e){c.error(e instanceof Error?e.message:`Invalidate failed`)}}async function R(e){try{await I.delete(e),c.success(`Memory deleted`),A()}catch(e){c.error(e instanceof Error?e.message:`Delete failed`)}}return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(a,{to:`/memory`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,_.jsx)(o,{className:`h-3 w-3`}),`Memory`]}),(0,_.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,_.jsx)(i,{className:`h-5 w-5 text-primary`}),`Memory graph`]}),(0,_.jsxs)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:[`Force-directed view of every memory your gateway has learned. Edges link memories sharing tags (dim) or with explicit`,` `,(0,_.jsx)(`code`,{className:`font-mono text-foreground/80`,children:`[[wikilinks]]`}),` `,`(bright). Hover for details, click to open.`]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:A,className:`inline-flex items-center gap-1.5 border border-border px-2.5 py-1.5 font-mono text-[11px] text-muted-foreground hover:border-primary/40 hover:text-foreground`,children:[(0,_.jsx)(s,{className:S?`h-3 w-3 animate-spin`:`h-3 w-3`}),`Refresh`]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,_.jsx)(x,{active:E===`all`,onClick:()=>D(`all`),label:`All kinds`}),(0,_.jsx)(x,{active:E===`fact`,onClick:()=>D(`fact`),label:`Facts`,color:v}),(0,_.jsx)(x,{active:E===`note`,onClick:()=>D(`note`),label:`Notes`,color:y}),(0,_.jsx)(x,{active:O,onClick:()=>k(e=>!e),label:O?`+ invalidated`:`Hide invalidated`}),j&&(0,_.jsxs)(`span`,{className:`ml-auto font-mono text-[11px] tabular-nums text-muted-foreground`,children:[j.nodes.length,` nodes · `,j.edges.length,` edges`,j.truncated&&(0,_.jsxs)(`span`,{className:`ml-2 text-amber-500`,children:[`(truncated to `,j.node_cap,`)`]})]})]}),(0,_.jsx)(f,{children:(0,_.jsxs)(l,{className:`p-0`,children:[S&&!n&&(0,_.jsxs)(`div`,{className:`flex h-[560px] items-center justify-center text-sm text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`mr-2 h-2 w-2 animate-pulse rounded-full bg-primary/60`}),`Building graph…`]}),w&&(0,_.jsxs)(`div`,{className:`flex h-[560px] items-center justify-center text-sm text-destructive`,children:[`Error: `,w]}),j&&j.nodes.length===0&&!S&&!w&&(0,_.jsxs)(`div`,{className:`flex h-[560px] flex-col items-center justify-center gap-2 text-center text-sm text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-8 w-8 opacity-30`}),(0,_.jsx)(`p`,{children:`No memories yet — your brain is empty.`})]}),j&&j.nodes.length>0&&(0,_.jsx)(h,{graph:j,onSelect:F})]})}),(0,_.jsx)(m,{entry:N,onClose:()=>F(null),onInvalidate:L,onDelete:R})]})}function x({active:e,onClick:t,label:n,color:r}){return(0,_.jsxs)(`button`,{type:`button`,onClick:t,className:`inline-flex items-center gap-1 border px-2 py-1 font-mono text-[11px] transition-colors `+(e?`border-primary/40 bg-primary/5 text-foreground`:`border-dashed border-border text-muted-foreground hover:border-border/80 hover:text-foreground`),children:[r&&(0,_.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full`,style:{background:r}}),n]})}export{b as MemoryVisualisationPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/MeshPage-DGYv8IHR.js b/internal/web/dist/assets/MeshPage-DGYv8IHR.js deleted file mode 100644 index 5f5f9ac..0000000 --- a/internal/web/dist/assets/MeshPage-DGYv8IHR.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{I as n,W as r,X as i,Y as a,et as o,in as s,on as c,z as l}from"./client-CaIRceNv.js";import{t as u}from"./createLucideIcon-WB390fY6.js";import{t as d}from"./chevron-right-CyhRDGe7.js";import{t as f}from"./folder-DHzynzTC.js";import{t as p}from"./network-CrANvqlb.js";import{Br as m,Fn as h,Fr as g,Ft as _,Jn as v,Ln as y,S as b,Sr as x,Zn as ee,_r as te,i as S,mr as ne,n as C,nr as re,qn as w,r as T,t as E,xr as D,y as O,zn as k}from"./index-BDLzoIgt.js";import{t as A}from"./empty-state-B9mtYx_X.js";import{r as j}from"./api-C7pu_Aru.js";import{t as M}from"./Pill-Dpb0OZxB.js";import{t as N}from"./markdown-BxN4l9DE.js";var P=u(`crosshair`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]),F=u(`file-lock`,[[`path`,{d:`M4 9.8V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3`,key:`1432pc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 17v-2a2 2 0 0 0-4 0v2`,key:`168m41`}],[`rect`,{width:`8`,height:`5`,x:`3`,y:`17`,rx:`1`,key:`o8vfew`}]]),I=e(t(),1),L=c();function ie(){let{data:e}=b((0,I.useCallback)(()=>a(),[])),{data:t}=b((0,I.useCallback)(()=>o(),[])),n=t?.settings?.display_name??``,[r,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(null),[u,f]=(0,I.useState)({}),[m,h]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{if(!r)return;let e=!1,t=async()=>{h(!0);try{let[t,n]=await Promise.all([i(),j(`/peers`).catch(()=>null)]);if(e)return;l(t?.peers??[]);let r={};for(let e of n?.peers??[])e.display_name&&(r[e.peer_id]=e.display_name);f(r)}finally{e||h(!1)}};t();let n=setInterval(()=>void t(),5e3);return()=>{e=!0,clearInterval(n)}},[r]),e?(0,L.jsxs)(E,{children:[(0,L.jsx)(T,{className:`cursor-pointer select-none`,onClick:()=>s(e=>!e),children:(0,L.jsxs)(S,{className:`flex items-center gap-2 text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:[r?(0,L.jsx)(D,{className:`h-4 w-4`}):(0,L.jsx)(d,{className:`h-4 w-4`}),(0,L.jsx)(p,{className:`h-4 w-4`}),`P2P Debug`,` `,(0,L.jsxs)(`span`,{"data-testid":`p2p-debug-local-name`,children:[`(`,n||e.peer_id.slice(0,12)+`...`,`)`]})]})}),r&&(0,L.jsxs)(C,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Listen addrs: `,(0,L.jsx)(`span`,{className:`font-mono`,children:e.multiaddrs.length}),m&&(0,L.jsx)(`span`,{className:`ml-2`,children:`refreshing...`})]}),c===null?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading...`}):c.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No active peers`}):(0,L.jsx)(`ul`,{className:`space-y-1`,children:c.map(e=>(0,L.jsx)(B,{peer:e,displayName:u[e.peer]},e.peer))})]})]}):null}var R={direct:`bg-emerald-500/10 text-emerald-500 border-emerald-500/20`,"hole-punched":`bg-blue-500/10 text-blue-500 border-blue-500/20`,"via-relay":`bg-amber-500/10 text-amber-500 border-amber-500/20`,none:`bg-muted text-muted-foreground border-border`},z={direct:`Direct`,"hole-punched":`Hole-punched`,"via-relay":`Via relay`,none:`No conn`};function B({peer:e,displayName:t}){let n=R[e.mode]??R.none,r=z[e.mode]??e.mode;return(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded border border-border/40 bg-muted/30 px-3 py-1.5`,"data-testid":`p2p-debug-peer-${e.peer}`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[t&&(0,L.jsx)(`span`,{className:`text-xs font-medium`,"data-testid":`p2p-debug-peer-name-${e.peer}`,children:t}),(0,L.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground truncate`,children:e.peer})]}),(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md border px-2 py-0.5 text-[10px] font-medium ${n}`,children:r})]})}var V=`bg-emerald-500/10 text-emerald-600 border-emerald-500/30`,H=`bg-muted text-muted-foreground border-border`,U=`peer:`;function W(e,t){if(!e.startsWith(`peer:`))return e;let n=e.slice(5),r=t?.[n];return r?`${U}${r}`:n.length>10?`${U}${n.slice(-10)}`:e}function G({origin:e,peerNames:t}){let n=!e||e===`local`,r=n?`local`:W(e,t);return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] font-medium ${n?V:H}`,"data-testid":n?`agent-origin-local`:`agent-origin-peer`,title:e||`local`,children:r})}function K(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function q(e){return!!e&&e.startsWith(`peer:`)}var ae=2,oe=10;function se(e){let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);return ti(m):void 0,testId:`agent-workspace-${e.session_id}`})]}),d&&(0,L.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] text-muted-foreground`,title:d,children:d}),e.status&&(0,L.jsx)(`div`,{className:`mt-0.5 truncate text-[11px] italic text-muted-foreground/80`,title:e.status,"data-testid":`agent-status-${e.session_id}`,children:e.status})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[(0,L.jsx)(ue,{agent:e,disabled:!p}),(0,L.jsx)(`span`,{className:`whitespace-nowrap text-[11px] text-muted-foreground tabular-nums`,children:K(e.last_seen_at)})]})]})}function ue({agent:e,disabled:t}){let[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(null),c=q(e.origin),l=c?ne:P,u=async()=>{if(!(t||r)){i(!0),o(null);try{await n(e.session_id)}catch(e){o(e instanceof Error?e.message:String(e)),setTimeout(()=>o(null),5e3)}finally{i(!1)}}},d=t?`No tmux locator — this agent didn't register from inside a tmux pane`:a?`Focus failed: ${a}`:c?`Open SSH — spawns a new local tmux window connected to this peer`:`Focus — switch your tmux to this agent's pane`;return(0,L.jsx)(`button`,{type:`button`,onClick:u,disabled:t||r,title:d,className:s(`inline-flex h-6 w-6 items-center justify-center rounded transition-colors`,t?`cursor-not-allowed text-muted-foreground/30`:c?`text-muted-foreground hover:bg-amber-500/10 hover:text-amber-600 dark:hover:text-amber-400`:`text-muted-foreground hover:bg-emerald-500/10 hover:text-emerald-600 dark:hover:text-emerald-400`,a&&`text-rose-500 hover:text-rose-500`),"data-testid":`agent-focus-${e.session_id}`,"aria-label":d,children:(0,L.jsx)(l,{className:s(`h-3.5 w-3.5`,r&&`animate-pulse`)})})}var de=60*1e3,fe=300*1e3;function pe({agents:e}){let[t,n]=(0,I.useState)([]),[r,a]=(0,I.useState)({}),o=(0,I.useCallback)(async()=>{let[t,r]=await Promise.all([i().catch(()=>null),j(`/peers`).catch(()=>null)]);if(t===null||r===null){n([]);return}n(X(r.peers??[],t.peers??[],e))},[e]);(0,I.useEffect)(()=>{o();let e=setInterval(()=>void o(),1e4);return()=>clearInterval(e)},[o]),(0,I.useEffect)(()=>{let e=Date.now();a(n=>{let r={...n},i=new Set;for(let n of t)i.add(n.peer_id),r[n.peer_id]===void 0&&(r[n.peer_id]=e);for(let e of Object.keys(r))i.has(e)||delete r[e];return r})},[t]);let s=Date.now(),c=t.filter(e=>{let t=r[e.peer_id];return t!==void 0&&s-t>=de});if(c.length===0)return null;let l=c.filter(e=>e.tier===`offline`),u=c.filter(e=>e.tier!==`offline`);return(0,L.jsxs)(`div`,{className:`space-y-2`,children:[l.length>0&&(0,L.jsx)(`div`,{role:`alert`,"data-testid":`mesh-disconnected-peers-banner`,className:`rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-700 dark:text-amber-300`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(k,{className:`mt-0.5 h-4 w-4 flex-none`,"aria-hidden":!0}),(0,L.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,L.jsx)(`p`,{className:`font-medium`,children:me(l)}),(0,L.jsxs)(`p`,{className:`text-xs opacity-80`,children:[(0,L.jsx)(g,{to:`/pairing`,className:`underline hover:no-underline`,children:`Open Paired Devices`}),` `,`to inspect pairing state. The reconnector is searching.`]})]})]})}),u.length>0&&(0,L.jsx)(`div`,{role:`status`,"data-testid":`mesh-reconnecting-peers-banner`,className:`rounded-lg border border-muted-foreground/20 bg-muted/40 px-4 py-2 text-xs text-muted-foreground`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(v,{className:`h-3.5 w-3.5 animate-spin-slow`,"aria-hidden":!0}),(0,L.jsx)(`span`,{children:he(u)})]})})]})}function me(e){if(e.length===1){let t=e[0],n=t.ageMin===1/0?``:` for ${ge(t.ageMin)}`;return`No connection to ${Y(t)}${n}.`}let t=e.map(Y).join(`, `);return`No connection to ${e.length} paired peers (${t}).`}function he(e){return`Reconnecting to ${e.map(Y).join(`, `)}.`}function ge(e){return e<60?`${e}m`:`${Math.floor(e/60)}h${e%60}m`}function Y(e){return e.display_name||`peer:${e.peer_id.slice(-10)}`}function X(e,t,n){let r=new Map;for(let e of t)r.set(e.peer,e.mode);let i=new Set;for(let e of n)e.origin&&e.origin.startsWith(`peer:`)&&i.add(e.origin.slice(U.length));let a=Date.now(),o=[];for(let t of e){if(t.revoked_at)continue;let e=r.get(t.peer_id)??``;if(e!==``&&e!==`none`||i.has(t.peer_id))continue;let n=t.last_seen?Math.floor((a-new Date(t.last_seen).getTime())/6e4):1/0,s;s=t.last_seen?n*6e4Se(e,r),[e,r]),o=a.reduce((e,t)=>e+t.agents.length,0);return(0,L.jsxs)(E,{children:[(0,L.jsx)(T,{children:(0,L.jsxs)(S,{className:`flex items-center justify-between text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:r?`Agents · ${r}`:`Active Agents`}),(0,L.jsx)(`span`,{className:`font-mono text-[11px] tabular-nums`,children:o})]})}),(0,L.jsx)(C,{className:`pt-0`,children:o===0?(0,L.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r?`No agents in workspace "${r}".`:`No agents connected. Open Claude Code or OpenCode to populate.`}):a.map(e=>(0,L.jsx)(be,{group:e,peerNames:t,peerModes:n,workspaceFilter:r,onWorkspaceClick:i},e.key))})]})}function be({group:e,peerNames:t,peerModes:n,workspaceFilter:r,onWorkspaceClick:i}){return(0,L.jsxs)(`div`,{className:`mb-4 last:mb-0`,children:[(0,L.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-6 mb-1 flex items-center gap-2 bg-card/95 px-6 py-1.5 backdrop-blur supports-[backdrop-filter]:bg-card/80`,children:[e.key===Z?(0,L.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/60`,children:e.label}):(0,L.jsx)(`button`,{type:`button`,onClick:()=>i(e.label),className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground`,"data-testid":`workspace-group-header-${e.label}`,title:r===e.label?`Clear filter`:`Filter to ${e.label}`,children:e.label}),(0,L.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.agents.length})]}),e.agents.map(e=>{let a=e.origin?.startsWith(`peer:`)?e.origin.slice(U.length):``;return(0,L.jsx)(le,{agent:e,peerNames:t,peerConnected:a?_e(a,n):!0,workspaceFilter:r,onWorkspaceClick:i},e.session_id)})]})}var xe={fresh:0,idle:1,stale:2};function Se(e,t){let n=new Map;for(let r of e){let e=r.workspace_name||r.workspace_id||``;if(t&&e!==t)continue;let i=e||Z,a=e||ve,o=n.get(i);o||(o={key:i,label:a,agents:[]},n.set(i,o)),o.agents.push(r)}for(let e of n.values())e.agents.sort((e,t)=>{let n=xe[Q(e.last_seen_at)]??99,r=xe[Q(t.last_seen_at)]??99;return n===r?new Date(t.last_seen_at).getTime()-new Date(e.last_seen_at).getTime():n-r});return[...n.values()].sort((e,t)=>{if(e.key===Z)return 1;if(t.key===Z)return-1;let n=e.agents.filter(e=>Q(e.last_seen_at)===`fresh`).length,r=t.agents.filter(e=>Q(e.last_seen_at)===`fresh`).length;return n===r?e.label.localeCompare(t.label):r-n})}function Q(e){let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);return t<2?`fresh`:t<10?`idle`:`stale`}function Ce({agents:e,liveMessages:t,peerCount:n,offlinePeerCount:r}){let i=e.filter(e=>!e.origin||e.origin===`local`).length,a=e.filter(e=>e.origin?.startsWith(U)).length;return(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,"data-testid":`mesh-status-strip`,children:[(0,L.jsx)($,{label:e.length===1?`agent`:`agents`,value:e.length,sublabel:`${i} local · ${a} remote`}),(0,L.jsx)(we,{}),(0,L.jsx)($,{label:t===1?`message live`:`messages live`,value:t}),n!==null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(we,{}),(0,L.jsx)($,{label:n===1?`paired peer`:`paired peers`,value:n,sublabel:r>0?(0,L.jsxs)(g,{to:`/pairing`,className:`text-amber-600 hover:underline dark:text-amber-400`,children:[r,` offline`]}):void 0})]})]})}function $({label:e,value:t,sublabel:n}){return(0,L.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{className:s(`text-base font-semibold tabular-nums leading-none`,t===0?`text-muted-foreground/60`:`text-foreground`),children:t}),(0,L.jsx)(`span`,{className:`text-xs`,children:e}),n?(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground/80`,children:[`(`,n,`)`]}):null]})}function we(){return(0,L.jsx)(`span`,{className:`text-muted-foreground/30`,"aria-hidden":!0,children:`·`})}function Te(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean):[]}function Ee({priority:e}){return(0,L.jsx)(O,{variant:`outline`,tone:e===`critical`?`critical`:e===`high`?`high`:e===`normal`?`info`:`muted`,className:`text-[10px]`,children:e})}function De({kind:e}){return(0,L.jsx)(O,{variant:`outline`,tone:`mono`,className:`text-[10px]`,children:e})}var Oe=({message:e,highlighted:t,rowRef:n,onTagClick:r,activeTag:i,workspaceFilter:a,onWorkspaceClick:o})=>{let[c,l]=(0,I.useState)(!1),u=(0,I.useCallback)(async()=>{try{await navigator.clipboard.writeText(e.content),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[e.content]),d=Te(e.tags),p=e.workspace_name;return(0,L.jsxs)(`div`,{ref:n,"data-message-id":e.id,className:s(`py-3 border-b border-border/40 last:border-0 group transition-colors duration-700`,t&&`bg-primary/10 ring-1 ring-primary/40 rounded-md -mx-2 px-2`),children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-1`,children:[(0,L.jsx)(Ee,{priority:e.priority}),(0,L.jsx)(De,{kind:e.kind}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`from `,(0,L.jsx)(`span`,{className:`font-medium text-foreground`,children:e.agent_name||`unknown`})]}),p&&(0,L.jsx)(M,{icon:f,label:p,title:a===p?`Clear workspace filter (${p})`:e.workspace_path?`Filter to workspace: ${p} (${e.workspace_path})`:`Filter to workspace: ${p}`,active:a===p,tone:`workspace`,maxLabelCh:16,onClick:o?()=>o(p):void 0,testId:`message-workspace-${e.id}`}),(0,L.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:K(e.created_at)}),(0,L.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 transition-opacity group-hover:opacity-100`,onClick:u,"aria-label":`Copy message content`,"data-testid":`mesh-message-copy-${e.id}`,title:c?`Copied`:`Copy content`,children:c?(0,L.jsx)(x,{className:`h-3.5 w-3.5 text-emerald-500`}):(0,L.jsx)(te,{className:`h-3.5 w-3.5`})})]}),(0,L.jsx)(N,{source:e.content,className:`text-sm leading-relaxed`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1.5`,children:[d.map(e=>{let t=i===e;return(0,L.jsx)(M,{label:`#${e}`,active:t,tone:`muted`,maxLabelCh:20,onClick:()=>r?.(e),title:t?`Clear filter for "${e}"`:`Filter by "${e}"`,testId:`mesh-message-tag-${e}`},e)}),e.reply_count>0&&(0,L.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.reply_count,` `,e.reply_count===1?`reply`:`replies`]}),(0,L.jsx)(`span`,{className:`ml-auto font-mono text-[10px] text-muted-foreground/60`,children:e.id.slice(0,10)})]})]})};function ke(e){if(e<=0)return`expired`;if(e<60)return`${e}s`;let t=Math.floor(e/60);return t<60?`${t}m`:`${Math.floor(t/60)}h${t%60}m`}function Ae({claim:e}){let t=e.claimer_display_name||e.claimer_user_id||(e.claimer_peer_id?`peer:${e.claimer_peer_id.slice(-10)}`:`unknown`);return(0,L.jsxs)(`div`,{className:`py-3 border-b border-border/40 last:border-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,L.jsx)(F,{className:`h-3.5 w-3.5 text-amber-500`}),(0,L.jsx)(`span`,{className:`text-sm font-medium`,children:t}),(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`on `,(0,L.jsxs)(`span`,{className:`font-mono`,children:[e.repo,`@`,e.branch]})]}),(0,L.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:[ke(e.seconds_remaining),` left`]})]}),e.intent&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1.5 italic`,children:e.intent}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.paths.map(e=>(0,L.jsx)(`span`,{className:`font-mono text-[10px] bg-muted px-1.5 py-0.5 rounded border border-border`,children:e},e))})]})}function je({messages:e,highlightId:t,registerRow:n,workspaceFilter:r,onWorkspaceClick:i}){let[a,o]=(0,I.useState)(``),s=a.startsWith(`#`)?a.slice(1).trim():``,c=(0,I.useCallback)(e=>{o(t=>t===`#${e}`?``:`#${e}`)},[]),l=(0,I.useMemo)(()=>[...e].sort((e,t)=>{let n=new Date(e.created_at).getTime();return new Date(t.created_at).getTime()-n}),[e]),u=(0,I.useMemo)(()=>{let e=r?l.filter(e=>{let t=e.workspace_name||``;return t===``||t===r}):l,t=a.trim().toLowerCase();if(!t)return e;if(t.startsWith(`#`)){let n=t.slice(1);return e.filter(e=>Te(e.tags).some(e=>e.toLowerCase()===n))}return e.filter(e=>((e.content||``)+` `+(e.agent_name||``)+` `+(e.tags||``)+` `+(e.kind||``)+` `+(e.priority||``)+` `+(e.workspace_name||``)+` `+(e.workspace_path||``)+` `+e.id).toLowerCase().includes(t))},[l,a,r]);return(0,L.jsxs)(E,{children:[(0,L.jsxs)(T,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(S,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Recent Messages`}),(0,L.jsx)(`span`,{className:`font-mono text-[11px] tabular-nums text-muted-foreground`,children:a?`${u.length} / ${e.length}`:e.length})]}),(0,L.jsxs)(`div`,{className:`relative`,children:[(0,L.jsx)(w,{className:`pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,L.jsx)(_,{value:a,onChange:e=>o(e.target.value),placeholder:`Search content, sender, workspace, tags, kind, id… (or click a #tag)`,className:`pl-8`,"data-testid":`mesh-messages-search`})]})]}),(0,L.jsx)(C,{children:e.length===0?(0,L.jsx)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:`No messages yet`}):u.length===0?(0,L.jsxs)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:[`No messages match "`,a,`".`]}):u.map(e=>(0,L.jsx)(Oe,{message:e,highlighted:e.id===t,rowRef:t=>n(e.id,t),onTagClick:c,activeTag:s,workspaceFilter:r,onWorkspaceClick:i},e.id))})]})}function Me(){return(0,L.jsx)(A,{testid:`mesh-disabled`,icon:(0,L.jsx)(ee,{className:`h-10 w-10`}),title:`Agent Mesh is disabled`,description:(0,L.jsxs)(L.Fragment,{children:[`Enable inter-agent messaging in`,` `,(0,L.jsx)(g,{to:`/settings`,className:`text-primary hover:underline`,"data-testid":`mesh-enable-link`,children:`Settings`}),` `,`to let agents coordinate work across sessions. Requires a restart after enabling.`]})})}function Ne(){let{data:e,loading:t}=b((0,I.useCallback)(()=>o(),[])),n=e?.settings?.mesh_enabled??!1,{data:a,loading:s,refetch:c}=b((0,I.useCallback)(()=>r(),[])),{data:u,refetch:d}=b((0,I.useCallback)(()=>l(),[])),[p,h]=m(),g=p.get(`msg`),[_,v]=(0,I.useState)(null),x=(0,I.useRef)(new Map),ee=(0,I.useCallback)((e,t)=>{t?x.current.set(e,t):x.current.delete(e)},[]);(0,I.useEffect)(()=>{if(!g)return;v(g);let e=()=>{let e=x.current.get(g);return e?(e.scrollIntoView({behavior:`smooth`,block:`center`}),!0):!1},t=0,n=()=>{e()||++t>20||requestAnimationFrame(n)};requestAnimationFrame(n);let r=setTimeout(()=>{h(e=>{let t=new URLSearchParams(e);return t.delete(`msg`),t},{replace:!0})},200),i=setTimeout(()=>v(null),3500);return()=>{clearTimeout(r),clearTimeout(i)}},[g,h]);let te=p.get(`queue`)===`1`,ne=(0,I.useCallback)(()=>{h(e=>{let t=new URLSearchParams(e);return t.delete(`queue`),t},{replace:!0})},[h]),[w,D]=(0,I.useState)({}),[O,k]=(0,I.useState)([]);(0,I.useEffect)(()=>{if(!n)return;let e=async()=>{let e=await j(`/peers`).catch(()=>null);if(!e)return;let t={};for(let n of e.peers??[])n.display_name&&(t[n.peer_id]=n.display_name);D(t)},t=async()=>{let e=await i().catch(()=>null);e&&k(e.peers??[])};e(),t();let r=setInterval(()=>void e(),3e4),a=setInterval(()=>void t(),1e4);return()=>{clearInterval(r),clearInterval(a)}},[n]);let[,A]=(0,I.useState)(0);(0,I.useEffect)(()=>{if(!n)return;let e=setInterval(()=>{c(),d(),A(e=>e+1)},1e4);return()=>clearInterval(e)},[n,c,d]);let N=a??{agents:[],messages:[],live_messages:0},P=N.agents??[],R=N.messages??[],z=u?.claims??[],B=p.get(`workspace`)??``,V=(0,I.useCallback)(e=>{h(t=>{let n=new URLSearchParams(t);return e?n.set(`workspace`,e):n.delete(`workspace`),n},{replace:!0})},[h]),H=(0,I.useCallback)(e=>V(e===B?``:e),[B,V]),U=(0,I.useMemo)(()=>O.length===0&&Object.keys(w).length===0?0:X(Object.entries(w).map(([e,t])=>({peer_id:e,display_name:t,paired_at:``,trust_level:0,scopes:[]})),O,P).length,[w,O,P]);if(t)return(0,L.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,L.jsx)(re,{className:`h-6 w-6 animate-spin text-muted-foreground`})});if(!n)return(0,L.jsx)(Me,{});let W=Object.keys(w).length||null,G=B?z.filter(e=>e.repo===B||e.branch===B):z,K=p.get(`debug`)===`1`;return(0,L.jsxs)(`div`,{className:`space-y-5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Agent Mesh`}),s&&(0,L.jsx)(re,{className:`h-4 w-4 animate-spin text-muted-foreground`})]}),(0,L.jsx)(Ce,{agents:P,liveMessages:N.live_messages,peerCount:W,offlinePeerCount:U})]}),(0,L.jsx)(pe,{agents:P}),te&&(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-amber-500/30 bg-amber-500/10 p-3 text-sm`,children:[(0,L.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,L.jsx)(`div`,{className:`font-medium text-amber-300`,children:`Message queued for offline peer`}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`A mesh message could not be delivered immediately. It is parked in the outbound queue and will deliver when the peer reconnects.`})]}),(0,L.jsx)(`button`,{type:`button`,onClick:ne,className:`inline-flex h-5 items-center gap-0.5 rounded px-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Dismiss`,children:(0,L.jsx)(y,{className:`h-3 w-3`})})]}),B&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`Filtered to workspace`}),(0,L.jsx)(M,{icon:f,label:B,tone:`brand`,active:!0,maxLabelCh:24,onClick:()=>V(``),title:`Clear workspace filter`,testId:`workspace-filter-chip`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>V(``),className:`inline-flex h-5 items-center gap-0.5 rounded px-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Clear filter`,children:[(0,L.jsx)(y,{className:`h-3 w-3`}),(0,L.jsx)(`span`,{children:`clear`})]})]}),(0,L.jsx)(ye,{agents:P,peerNames:w,peerModes:O,workspaceFilter:B,onWorkspaceClick:H}),(0,L.jsx)(je,{messages:R,highlightId:_,registerRow:ee,workspaceFilter:B,onWorkspaceClick:H}),(G.length>0||B)&&(0,L.jsxs)(E,{children:[(0,L.jsx)(T,{children:(0,L.jsxs)(S,{className:`flex items-center gap-2 text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,L.jsx)(F,{className:`h-4 w-4`}),(0,L.jsx)(`span`,{children:`File Claims`}),(0,L.jsx)(`span`,{className:`font-mono text-[11px] tabular-nums text-muted-foreground/60`,children:G.length})]})}),(0,L.jsx)(C,{children:G.length===0?(0,L.jsxs)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:[`No active claims`,B?` in ${B}`:``,`.`]}):G.map(e=>(0,L.jsx)(Ae,{claim:e},e.claim_id))})]}),K&&(0,L.jsx)(ie,{})]})}export{Ne as MeshPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ModelLeaderboardPage-TWXixXQS.js b/internal/web/dist/assets/ModelLeaderboardPage-TWXixXQS.js deleted file mode 100644 index ec2b06d..0000000 --- a/internal/web/dist/assets/ModelLeaderboardPage-TWXixXQS.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{in as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./circle-x--B2BKH4R.js";import{Ar as a,Fn as o,Fr as s,S as c,Xn as l,br as u,i as d,mn as f,n as p,nr as m,r as h,t as g,ur as _,y as v}from"./index-BDLzoIgt.js";import{t as y}from"./empty-state-B9mtYx_X.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./table-2N0Q-yAm.js";var E=e(t(),1),D=r(),O=[{key:`all`,label:`All`},{key:`coding`,label:`Coding`},{key:`review`,label:`Review`},{key:`architecture`,label:`Architecture`},{key:`tool_calling`,label:`Tools`},{key:`visual`,label:`Visual`}];function k(){let[e,t]=(0,E.useState)(`all`),{data:n,loading:r,error:i,refetch:u}=c((0,E.useCallback)(()=>f({taskKind:e===`all`?void 0:e,limit:100}),[e])),v=(0,E.useMemo)(()=>N(n??[]),[n]),w=(0,E.useMemo)(()=>P(v),[v]);return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold`,children:[(0,D.jsx)(_,{className:`h-6 w-6`}),` Model leaderboard`]}),(0,D.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm text-muted-foreground`,children:`Delegation model ranking from reviewed runs, operational success, active load, speed, and cost.`})]}),(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,D.jsx)(o,{variant:`outline`,size:`sm`,asChild:!0,children:(0,D.jsx)(s,{to:`/delegations`,children:`Open delegations`})}),(0,D.jsxs)(o,{variant:`ghost`,size:`sm`,onClick:u,disabled:r,children:[r?(0,D.jsx)(m,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,D.jsx)(l,{className:`mr-1.5 h-4 w-4`}),`Refresh`]})]})]}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,role:`tablist`,"aria-label":`Task kind`,children:O.map(n=>(0,D.jsx)(o,{type:`button`,variant:e===n.key?`default`:`outline`,size:`sm`,onClick:()=>t(n.key),"aria-pressed":e===n.key,className:`h-8`,children:n.label},n.key))}),i&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:[(0,D.jsx)(`span`,{children:i}),(0,D.jsx)(o,{size:`sm`,variant:`ghost`,onClick:u,children:`Retry`})]}),r&&!n?(0,D.jsxs)(`div`,{className:`flex items-center gap-2 border border-border bg-card/50 p-4 text-sm text-muted-foreground`,children:[(0,D.jsx)(m,{className:`h-4 w-4 animate-spin`}),` Loading model ranks...`]}):v.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(A,{summary:w}),(0,D.jsxs)(g,{children:[(0,D.jsx)(h,{className:`pb-3`,children:(0,D.jsxs)(d,{className:`flex items-center gap-2 text-base`,children:[(0,D.jsx)(a,{className:`h-4 w-4`}),` Ranked models`]})}),(0,D.jsx)(p,{className:`p-0`,children:(0,D.jsxs)(T,{children:[(0,D.jsx)(b,{children:(0,D.jsxs)(C,{children:[(0,D.jsx)(x,{className:`w-14 text-right`,children:`Rank`}),(0,D.jsx)(x,{children:`Model`}),(0,D.jsx)(x,{className:`text-right`,children:`Capacity`}),(0,D.jsx)(x,{className:`text-right`,children:`Runs`}),(0,D.jsx)(x,{className:`text-right`,children:`Ops success`}),(0,D.jsx)(x,{className:`text-right`,children:`Review`}),(0,D.jsx)(x,{className:`text-right`,children:`Avg time`}),(0,D.jsx)(x,{className:`text-right`,children:`Cost`}),(0,D.jsx)(x,{children:`Status`})]})}),(0,D.jsx)(S,{children:v.map((e,t)=>(0,D.jsx)(M,{row:e,rank:t+1},e.model_key||`${e.model_provider}/${e.model_id}`))})]})})]})]}):(0,D.jsx)(y,{icon:(0,D.jsx)(_,{className:`h-10 w-10`}),title:`No model rank data yet`,description:`Review completed delegations to give the leaderboard evidence.`,action:(0,D.jsx)(o,{asChild:!0,children:(0,D.jsx)(s,{to:`/delegations`,children:`Review delegations`})})})]})}function A({summary:e}){return(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-4`,children:[(0,D.jsx)(j,{label:`Models`,value:String(e.models)}),(0,D.jsx)(j,{label:`Runs`,value:z(e.runs)}),(0,D.jsx)(j,{label:`Available`,value:String(e.available)}),(0,D.jsx)(j,{label:`Reviewed`,value:String(e.reviewed)})]})}function j({label:e,value:t}){return(0,D.jsxs)(`div`,{className:`border border-border bg-card/50 px-3 py-2`,children:[(0,D.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,D.jsx)(`div`,{className:`mt-1 font-mono text-lg tabular-nums`,children:t})]})}function M({row:e,rank:t}){let r=e.operational_success_rate??e.success_rate,a=e.label||e.model_id,o=e.model_key||`${e.model_provider}/${e.model_id}`;return(0,D.jsxs)(C,{children:[(0,D.jsx)(w,{className:`text-right font-mono text-xs text-muted-foreground`,children:t}),(0,D.jsx)(w,{children:(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`div`,{className:`truncate text-sm font-medium`,children:a}),(0,D.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:o}),e.capability_tags&&e.capability_tags.length>0?(0,D.jsx)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:e.capability_tags.slice(0,4).map(e=>(0,D.jsx)(v,{variant:`outline`,className:`rounded-sm px-1.5 py-0 text-[10px]`,children:e},e))}):null]})}),(0,D.jsx)(w,{className:`text-right font-mono text-sm tabular-nums`,children:F(e.capacity_score)}),(0,D.jsxs)(w,{className:`text-right font-mono text-sm tabular-nums`,children:[z(e.runs),e.running>0?(0,D.jsxs)(`span`,{className:`ml-1 text-sky-300`,children:[`+`,e.running]}):null]}),(0,D.jsx)(w,{className:`text-right`,children:(0,D.jsx)(`span`,{className:n(`font-mono text-sm tabular-nums`,r>=.9?`text-emerald-300`:r<.65?`text-amber-300`:``),children:I(r)})}),(0,D.jsxs)(w,{className:`text-right`,children:[(0,D.jsx)(`div`,{className:`font-mono text-sm tabular-nums`,children:e.review_count?F(e.review_score):`-`}),e.review_count>0?(0,D.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[e.review_count,` reviews`]}):null]}),(0,D.jsx)(w,{className:`text-right font-mono text-sm tabular-nums`,children:L(e.avg_duration_ms)}),(0,D.jsx)(w,{className:`text-right font-mono text-sm tabular-nums`,children:R(e.cost_usd)}),(0,D.jsxs)(w,{children:[(0,D.jsxs)(v,{variant:e.available?`default`:`secondary`,className:`rounded-sm`,children:[e.available?(0,D.jsx)(u,{className:`mr-1 h-3 w-3`}):(0,D.jsx)(i,{className:`mr-1 h-3 w-3`}),e.available?`ready`:`blocked`]}),!e.available&&e.unavailable_reason?(0,D.jsx)(`div`,{className:`mt-1 max-w-48 truncate text-[11px] text-muted-foreground`,title:e.unavailable_reason,children:e.unavailable_reason}):null]})]})}function N(e){return[...e].sort((e,t)=>e.available===t.available?e.rank&&t.rank&&e.rank!==t.rank?e.rank-t.rank:t.capacity_score===e.capacity_score?t.review_score===e.review_score?t.runs-e.runs:t.review_score-e.review_score:t.capacity_score-e.capacity_score:e.available?-1:1)}function P(e){return e.reduce((e,t)=>(e.models+=1,e.runs+=t.runs||0,t.available&&(e.available+=1),t.review_count>0&&(e.reviewed+=1),e),{models:0,runs:0,available:0,reviewed:0})}function F(e){return Number.isFinite(e)?e>=10?e.toFixed(0):e.toFixed(1):`0`}function I(e){return!Number.isFinite(e)||e<=0?`-`:`${Math.round(e*100)}%`}function L(e){return e?e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`:`-`}function R(e){return e?`$${e.toFixed(4)}`:`$0`}function z(e){return e?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}m`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}export{k as ModelLeaderboardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ModelProvidersPage-Bryuhzzp.js b/internal/web/dist/assets/ModelProvidersPage-Bryuhzzp.js deleted file mode 100644 index ec80d96..0000000 --- a/internal/web/dist/assets/ModelProvidersPage-Bryuhzzp.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Gt as n,J as r,Wt as i,Zt as a,f as o,jt as s,l as c,on as l,qt as u,vt as d,x as f}from"./client-CaIRceNv.js";import{t as p}from"./circle-x--B2BKH4R.js";import{t as m}from"./pencil-Dy4EC74G.js";import{t as h}from"./play-YbzkBfB8.js";import{t as g}from"./square-BOz_C5qq.js";import{An as _,Bn as v,Fn as y,Ft as b,In as x,Mn as S,Mr as C,Nn as w,Nr as T,On as E,Pr as D,Pt as O,Qn as k,S as A,Vn as j,br as M,hr as N,i as P,jn as F,jr as I,kn as L,n as R,nr as z,r as B,t as V,y as H}from"./index-BDLzoIgt.js";import{u as U}from"./model-catalog-Cn8r6otb.js";var W=e(t(),1),G=l(),K=[{value:`anthropic`,label:`Anthropic`,hint:`Direct Messages API. Your API key, billed per-token.`,needsEndpoint:!1,needsKey:!0},{value:`openai`,label:`OpenAI`,hint:`Direct Chat Completions API.`,needsEndpoint:!1,needsKey:!0},{value:`openai_compat`,label:`OpenAI-compatible`,hint:`OpenRouter, Together, Groq, vLLM, Ollama. Pick by endpoint.`,needsEndpoint:!0,endpointHint:`https://openrouter.ai/api/v1`,needsKey:!0},{value:`claude_cli`,label:`Claude CLI`,hint:`Subprocess. Uses your Claude subscription, not an API key.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`claude (blank = use $PATH)`,needsKey:!1},{value:`opencode_cli`,label:`OpenCode CLI`,hint:`Attached CLI. Prefer the local OpenCode server for concurrent Minimax, GLM/Z.ai, OpenRouter, and local runs.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`http://127.0.0.1:4096`,needsKey:!1},{value:`grok_cli`,label:`xAI Grok CLI`,hint:`Subprocess. Uses your Grok CLI login or XAI_API_KEY.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`grok (blank = use $PATH)`,needsKey:!1},{value:`mimo_cli`,label:`Xiaomi MiMo CLI`,hint:`Subprocess. Uses your native MiMo CLI login.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`mimo (blank = use $PATH), or http://127.0.0.1:4096`,needsKey:!1},{value:`gemini_cli`,label:`Google Gemini CLI`,hint:`Subprocess. Uses GEMINI_API_KEY or your local Gemini CLI auth.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`gemini (blank = use $PATH)`,needsKey:!1},{value:`codex_cli`,label:`OpenAI Codex CLI`,hint:`Subprocess. Needs OPENAI_API_KEY set in environment.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`codex (blank = use $PATH)`,needsKey:!1},{value:`pi_cli`,label:`Pi CLI`,hint:`Subprocess. Uses the host Pi coding harness; model ids resolve from ~/.pi/agent/models.json.`,needsEndpoint:!0,endpointRequired:!1,endpointHint:`pi (blank = use $PATH)`,needsKey:!1}];function q(){let{data:e,refetch:t,loading:n}=A((0,W.useCallback)(()=>d(),[])),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Model Providers`}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Set up your model provider once, then pick a model when creating a worker.`})]}),(0,G.jsxs)(y,{onClick:()=>o(!0),"data-testid":`model-profile-new`,children:[(0,G.jsx)(k,{className:`mr-1.5 h-4 w-4`}),`New provider`]})]}),(0,G.jsx)(X,{onProfileChanged:()=>t()}),(0,G.jsx)($,{}),(0,G.jsxs)(V,{children:[(0,G.jsx)(B,{children:(0,G.jsx)(P,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Providers`})}),(0,G.jsxs)(R,{className:`space-y-2`,children:[n&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,G.jsx)(z,{className:`h-3 w-3 animate-spin`}),`Loading providers...`]}),!n&&(e??[]).length===0&&(0,G.jsxs)(`div`,{className:`rounded-md border border-dashed border-border px-4 py-8 text-center text-sm text-muted-foreground`,children:[`No providers yet. Click `,(0,G.jsx)(`strong`,{children:`New provider`}),` to add one.`]}),(e??[]).map(e=>(0,G.jsx)(J,{profile:e,onEdit:()=>i(e),onDeleted:()=>t()},e.id))]})]}),a&&(0,G.jsx)(Y,{mode:`create`,onClose:()=>o(!1),onSaved:()=>{o(!1),t()}}),r&&(0,G.jsx)(Y,{mode:`edit`,profile:r,onClose:()=>i(null),onSaved:()=>{i(null),t()}})]})}function J({profile:e,onEdit:t,onDeleted:n}){let[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(null),s=K.find(t=>t.value===e.provider);async function c(){i(!0),o(null);try{let t=await u(e.id);o({ok:t.ok,ms:t.latency_ms,err:t.error})}catch(e){o({ok:!1,ms:0,err:e instanceof Error?e.message:String(e)})}finally{i(!1)}}async function l(){if(confirm(`Delete provider "${e.name}"? Workers using it will fall back to inline config.`))try{await f(e.id),I.success(`Deleted "${e.name}"`),n()}catch(e){I.error(e instanceof Error?e.message:`Delete failed`)}}return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border/40 bg-background/40 px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,G.jsx)(H,{variant:`outline`,className:`font-mono uppercase text-[10px]`,children:s?.label??e.provider}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:e.name}),e.builtin&&(0,G.jsx)(H,{variant:`outline`,className:`text-[10px] uppercase tracking-wider`,children:`built-in`})]}),(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e.known_models.length,` model`,e.known_models.length===1?``:`s`,e.endpoint_url&&(0,G.jsxs)(G.Fragment,{children:[` · `,(0,G.jsx)(`code`,{className:`font-mono`,children:e.endpoint_url})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-mono ${a.ok?`text-emerald-400`:`text-destructive`}`,title:a.err,children:[a.ok?(0,G.jsx)(M,{className:`h-3 w-3`}):(0,G.jsx)(p,{className:`h-3 w-3`}),a.ok?`${a.ms}ms`:`failed`]}),(0,G.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:c,disabled:r,"aria-label":`Test provider`,children:[r?(0,G.jsx)(z,{className:`h-3 w-3 animate-spin`}):(0,G.jsx)(x,{className:`h-3 w-3`}),(0,G.jsx)(`span`,{className:`ml-1 text-xs`,children:`Test`})]}),(0,G.jsx)(y,{variant:`ghost`,size:`sm`,onClick:t,disabled:e.builtin,"aria-label":`Edit provider`,children:(0,G.jsx)(m,{className:`h-3 w-3`})}),(0,G.jsx)(y,{variant:`ghost`,size:`sm`,onClick:l,disabled:e.builtin,"aria-label":`Delete provider`,children:(0,G.jsx)(v,{className:`h-3 w-3`})})]})]})}function Y({mode:e,profile:t,onClose:n,onSaved:r}){let[i,l]=(0,W.useState)(t?.name??``),[u,d]=(0,W.useState)(t?.provider??`anthropic`),[f,p]=(0,W.useState)(t?.endpoint_url??``),[m,h]=(0,W.useState)(``),[g,v]=(0,W.useState)(!1),x=K.find(e=>e.value===u);async function C(){if(!i.trim()){I.error(`Name is required`);return}if((x.endpointRequired??x.needsEndpoint)&&!f.trim()){I.error(`Endpoint URL or binary path is required for this provider`);return}v(!0);try{let n=t?.secret_scope_id;x.needsKey&&m.trim()&&(n||=(await c({name:`model-key-${Q(i)}`,display_name:``,type:`env`,oauth_provider_id:``,redaction_hints:[]})).id,await s(n,`api_key`,m.trim()));let l={name:i.trim(),provider:u,endpoint_url:f.trim(),secret_scope_id:n,known_models:t?.known_models??U(u)};e===`create`?(await o(l),I.success(`Created "${i}"`)):(await a(t.id,l),I.success(`Updated "${i}"`)),r()}catch(e){I.error(e instanceof Error?e.message:`Save failed`)}finally{v(!1)}}return(0,G.jsx)(E,{open:!0,onOpenChange:e=>!e&&n(),children:(0,G.jsxs)(L,{className:`sm:max-w-md`,children:[(0,G.jsxs)(S,{children:[(0,G.jsx)(w,{children:e===`create`?`New provider`:`Edit ${t?.name}`}),(0,G.jsx)(_,{children:`Set up a model provider once, then reference it from any worker.`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(O,{className:`text-xs`,children:`Name`}),(0,G.jsx)(b,{value:i,onChange:e=>l(e.target.value),placeholder:`My Anthropic key`,autoFocus:!0})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(O,{className:`text-xs`,children:`Provider`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:K.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(e.value),className:`rounded-md border px-3 py-2 text-left transition-colors ${u===e.value?`border-primary/60 bg-primary/5`:`border-border hover:border-border/80`}`,children:[(0,G.jsx)(`div`,{className:`text-xs font-semibold`,children:e.label}),(0,G.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground leading-snug`,children:e.hint})]},e.value))})]}),x.needsEndpoint&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(O,{className:`text-xs`,children:`Endpoint`}),(0,G.jsx)(b,{value:f,onChange:e=>p(e.target.value),placeholder:x.endpointHint})]}),x.needsKey&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(O,{className:`text-xs`,children:[`API key `,e===`edit`&&`(leave blank to keep existing)`]}),(0,G.jsx)(b,{type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:`sk-…`,autoComplete:`off`})]})]}),(0,G.jsxs)(F,{children:[(0,G.jsx)(y,{variant:`ghost`,onClick:n,disabled:g,children:`Cancel`}),(0,G.jsxs)(y,{onClick:C,disabled:g,children:[g?(0,G.jsx)(z,{className:`mr-1.5 h-3 w-3 animate-spin`}):null,e===`create`?`Create`:`Save`]})]})]})})}function X({onProfileChanged:e}){let{data:t,refetch:a}=A((0,W.useCallback)(()=>r(),[])),[o,s]=(0,W.useState)(!1);(0,W.useEffect)(()=>{if(!t?.running)return;let e=setInterval(()=>a(),5e3);return()=>clearInterval(e)},[t?.running,a]);async function c(){s(!0);try{await i(),await a(),e(),I.success(`OpenCode running`)}catch(e){I.error(e instanceof Error?e.message:`Start failed`)}finally{s(!1)}}async function l(){s(!0);try{await n(),await a(),I.success(`OpenCode stopped`)}catch(e){I.error(e instanceof Error?e.message:`Stop failed`)}finally{s(!1)}}let u=t;return(0,G.jsxs)(V,{children:[(0,G.jsx)(B,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(P,{className:`flex items-center gap-2 text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,G.jsx)(j,{className:`h-3 w-3`}),`OpenCode runtime`]}),(0,G.jsx)(Z,{status:u})]})}),(0,G.jsxs)(R,{children:[!u&&(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Checking environment...`}),u&&!u.installed&&(0,G.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,G.jsxs)(`p`,{className:`text-muted-foreground`,children:[`MCPlexer couldn't find the `,(0,G.jsx)(`code`,{className:`font-mono`,children:`opencode`}),` binary. The macOS launchd daemon runs with a stripped-down `,(0,G.jsx)(`code`,{children:`$PATH`}),`, so even an installed opencode is invisible unless it's in one of the probed locations.`]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3 text-xs`,children:[(0,G.jsx)(`p`,{className:`mb-1.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Probed automatically`}),(0,G.jsxs)(`ul`,{className:`space-y-0.5 font-mono text-[11px] text-muted-foreground`,children:[(0,G.jsx)(`li`,{children:`$PATH lookup`}),(0,G.jsx)(`li`,{children:`~/.opencode/bin/opencode`}),(0,G.jsx)(`li`,{children:`~/.local/bin/opencode`}),(0,G.jsx)(`li`,{children:`~/bin/opencode`}),(0,G.jsx)(`li`,{children:`/opt/homebrew/bin/opencode`}),(0,G.jsx)(`li`,{children:`/usr/local/bin/opencode`})]})]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3 text-xs leading-relaxed`,children:[(0,G.jsx)(`p`,{className:`font-medium text-foreground`,children:`Already have opencode installed?`}),(0,G.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Point the daemon at the binary by adding`,` `,(0,G.jsx)(`code`,{className:`font-mono`,children:`MCPLEXER_OPENCODE_PATH`}),` to`,` `,(0,G.jsx)(`code`,{className:`font-mono`,children:`~/Library/LaunchAgents/com.mcplexer.daemon.plist`}),` `,`under `,(0,G.jsx)(`code`,{className:`font-mono`,children:`EnvironmentVariables`}),`, then run:`]}),(0,G.jsx)(`pre`,{className:`mt-2 overflow-auto rounded bg-background p-2 font-mono text-[10px] text-accent-foreground`,children:`launchctl kickstart -k gui/$UID/com.mcplexer.daemon`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(y,{variant:`outline`,size:`sm`,onClick:()=>a(),children:`Re-check`}),(0,G.jsxs)(C,{children:[(0,G.jsx)(D,{asChild:!0,children:(0,G.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>window.open(`https://github.com/sst/opencode`,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(N,{className:`mr-1.5 h-3 w-3`}),`Install OpenCode`]})}),(0,G.jsx)(T,{children:`Opens the OpenCode install docs`})]})]})]}),u&&u.installed&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-1.5 text-xs`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Binary`}),(0,G.jsx)(`dd`,{className:`font-mono text-foreground break-all`,children:u.binary_path||`opencode (on $PATH)`})]}),u.version&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Version`}),(0,G.jsx)(`dd`,{className:`font-mono text-foreground`,children:u.version})]}),u.port&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Endpoint`}),(0,G.jsxs)(`dd`,{className:`font-mono text-foreground`,children:[`http://127.0.0.1:`,u.port]})]}),u.last_error&&(0,G.jsxs)(`div`,{className:`col-span-2`,children:[(0,G.jsx)(`dt`,{className:`text-destructive text-muted-foreground`,children:`Last error`}),(0,G.jsx)(`dd`,{className:`font-mono text-destructive`,children:u.last_error})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u.running?(0,G.jsxs)(y,{variant:`outline`,size:`sm`,onClick:l,disabled:o,children:[(0,G.jsx)(g,{className:`mr-1.5 h-3 w-3`}),`Stop`]}):(0,G.jsxs)(y,{size:`sm`,onClick:c,disabled:o,children:[o?(0,G.jsx)(z,{className:`mr-1.5 h-3 w-3 animate-spin`}):(0,G.jsx)(h,{className:`mr-1.5 h-3 w-3`}),`Start server`]}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`opencode_cli model profiles should use this endpoint so workers attach through one server.`})]})]})]})]})}function Z({status:e}){return e?e.installed?e.running?(0,G.jsx)(H,{variant:`outline`,className:`border-emerald-500/40 text-emerald-400 text-[10px] uppercase`,children:`running`}):(0,G.jsx)(H,{variant:`outline`,className:`text-[10px] uppercase`,children:`stopped`}):(0,G.jsx)(H,{variant:`outline`,className:`text-[10px] uppercase text-muted-foreground`,children:`not installed`}):(0,G.jsx)(H,{variant:`outline`,className:`text-[10px] uppercase`,children:`checking`})}function Q(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40)||`profile`}function $(){let[e,t]=(0,W.useState)(!1);return(0,G.jsxs)(V,{children:[(0,G.jsx)(B,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),className:`flex w-full items-center justify-between text-left`,children:[(0,G.jsxs)(P,{className:`flex items-center gap-2 text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,G.jsx)(x,{className:`h-3 w-3`}),`Provider caveats`]}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e?`Hide`:`Show`})]})}),e&&(0,G.jsx)(R,{children:(0,G.jsxs)(`div`,{className:`space-y-3 text-xs leading-relaxed`,children:[(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3`,children:[(0,G.jsx)(`p`,{className:`font-semibold text-foreground`,children:`grok_cli`}),(0,G.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`Headless JSON mode may omit usage/cost fields. When absent, mcplexer records token counts and cost as zero rather than inventing values. This means delegation ROI panels will show $0 for Grok runs even when tokens were consumed.`})]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3`,children:[(0,G.jsx)(`p`,{className:`font-semibold text-foreground`,children:`mimo_cli`}),(0,G.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`For parallel workers, prefer a local OpenCode server URL (e.g.`,` `,(0,G.jsx)(`code`,{className:`font-mono`,children:`http://127.0.0.1:4096`}),`) so concurrent runs attach through one long-lived backend instead of each spawning a separate process. HTTP URLs are passed to `,(0,G.jsx)(`code`,{className:`font-mono`,children:`mimo run --attach`}),`.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3`,children:[(0,G.jsx)(`p`,{className:`font-semibold text-foreground`,children:`codex_cli`}),(0,G.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Requires `,(0,G.jsx)(`code`,{className:`font-mono`,children:`OPENAI_API_KEY`}),` to be set in the daemon's environment. The key is read by the `,(0,G.jsx)(`code`,{className:`font-mono`,children:`codex`}),` `,`binary itself — mcplexer never stores or transmits it. Ensure the launchd plist or systemd unit exports the variable.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3`,children:[(0,G.jsx)(`p`,{className:`font-semibold text-foreground`,children:`pi_cli`}),(0,G.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Pi resolves model ids from `,(0,G.jsx)(`code`,{className:`font-mono`,children:`~/.pi/agent/models.json`}),`. Treat local aliases as exploratory until they have parent review scores; delegation capacity ranking applies an extra penalty to unreviewed Pi routes.`]})]}),(0,G.jsxs)(`div`,{className:`rounded-md border border-border/40 bg-background/40 p-3`,children:[(0,G.jsx)(`p`,{className:`font-semibold text-foreground`,children:`opencode_cli`}),(0,G.jsxs)(`p`,{className:`mt-1 text-muted-foreground`,children:[`Requires a running OpenCode server for`,` `,(0,G.jsx)(`code`,{className:`font-mono`,children:`--attach`}),` mode. The managed server (started from the OpenCode runtime card above) auto-restarts on crash, but mid-run session errors are retried automatically by the adapter. For parallel workers, always use server mode — direct CLI invocations contend over the local session DB.`]})]})]})})]})}export{q as ModelProvidersPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ModelRanksPage-DaKByZxq.js b/internal/web/dist/assets/ModelRanksPage-DaKByZxq.js deleted file mode 100644 index 71bd2d6..0000000 --- a/internal/web/dist/assets/ModelRanksPage-DaKByZxq.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./createLucideIcon-WB390fY6.js";import{t as a}from"./circle-x--B2BKH4R.js";import{t as o}from"./database-DUeGtnBt.js";import{t as s}from"./route-CMSYmLBM.js";import{t as c}from"./star-CkF1s_Xa.js";import{Ar as l,Br as u,Fn as d,Fr as ee,Ft as f,Or as te,S as p,Xn as ne,br as m,hn as re,mn as ie,nr as h,qn as g,ur as ae,wr as _,y as v,zn as y}from"./index-BDLzoIgt.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./table-2N0Q-yAm.js";var E=i(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),D=e(t(),1),O=[{key:`1h`,label:`1h`,ms:3600*1e3},{key:`12h`,label:`12h`,ms:720*60*1e3},{key:`24h`,label:`24h`,ms:1440*60*1e3},{key:`7d`,label:`7d`,ms:10080*60*1e3},{key:`all`,label:`All`}];function k(e){return O.find(t=>t.key===e)?.label??e}function A(e,t){let n=O.find(e=>e.key===t);if(!n?.ms)return e;let r=Date.now()-n.ms;return e.filter(e=>L(e)>=r)}function j(e){let t=new Map,n=new Map;for(let r of e){let e=I(r);n.set(e,(n.get(e)||0)+1);let i=t.get(e);(!i||r.available&&!i.available||r.capacity_score>i.capacity_score)&&t.set(e,{...r})}return Array.from(t.values()).map(e=>{let t=I(e);return{...e,duplicate_count:n.get(t)||1}}).sort((e,t)=>e.available===t.available?e.capacity_score===t.capacity_score?I(e).localeCompare(I(t)):t.capacity_score-e.capacity_score:e.available?-1:1).map((e,t)=>({...e,rank:t+1}))}function M(e){let t=new Map;for(let n of e){let e=n.model_stats?.length?n.model_stats:oe(n);for(let r of e){let e=r.model_key||`${r.model_provider}/${r.model_id}`,i=t.get(e)??{modelKey:e,modelProvider:r.model_provider,modelID:r.model_id,runs:0,success:0,failure:0,running:0,totalTokens:0,costUSD:0,unknownCostRuns:0,durationMS:0,unknownDurationMS:0,avgDurationMS:0,costKnown:!1,reviewCount:0,avgScore:0,successRate:0,capabilityScores:{},scoreTotal:0,capabilityTotals:{},capabilityCounts:{}};i.runs+=r.runs||0,i.success+=r.success||0,i.failure+=r.failure||0,i.running+=r.running||0,i.totalTokens+=r.total_tokens||0,i.costUSD+=r.cost_usd||0,i.unknownCostRuns+=r.unknown_cost_runs||0,i.durationMS+=r.duration_ms||0,i.unknownDurationMS+=r.unknown_duration_ms||0,(r.review_count||0)>0?(i.reviewCount+=r.review_count||0,i.scoreTotal+=(r.review_score||0)*(r.review_count||0),R(i,r.capability_scores)):n.review?.reviewed&&typeof n.review.score==`number`&&(i.reviewCount+=1,i.scoreTotal+=n.review.score,R(i,n.review.scores)),t.set(e,i)}}return Array.from(t.values()).map(e=>{let t=Math.max(0,e.runs-e.unknownCostRuns),n=Math.max(0,e.success-e.unknownCostRuns),r=Math.max(0,e.durationMS-e.unknownDurationMS);return{...e,avgScore:e.reviewCount?e.scoreTotal/e.reviewCount:0,successRate:t?n/t:0,avgDurationMS:t?Math.round(r/t):0,costKnown:t>0,capabilityScores:z(e.capabilityTotals,e.capabilityCounts)}}).filter(e=>e.reviewCount>0||e.runs>0).sort((e,t)=>t.avgScore===e.avgScore?t.reviewCount===e.reviewCount?t.successRate===e.successRate?e.costKnown&&t.costKnown&&e.costUSD!==t.costUSD?e.costUSD-t.costUSD:e.avgDurationMS-t.avgDurationMS:t.successRate-e.successRate:t.reviewCount-e.reviewCount:t.avgScore-e.avgScore)}function N(e){return e?Math.abs(e)>=1e6?`${(e/1e6).toFixed(1)}m`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:String(e):`0`}function P(e){return`$${(e||0).toFixed(4)}`}function F(e){return e?e<1e3?`${e}ms`:e<6e4?`${Math.round(e/1e3)}s`:`${Math.round(e/6e4)}m`:`0s`}function I(e){return e.model_key||`${e.model_provider}/${e.model_id}`}function L(e){let t=[e.created_at,e.updated_at,e.review?.reviewed_at,...e.workers.flatMap(e=>[e.latest_run?.started_at,e.latest_run?.finished_at,e.worker.updated_at,e.worker.created_at])].map(e=>e?Date.parse(e):NaN).filter(e=>Number.isFinite(e));return t.length?Math.max(...t):0}function oe(e){let t=new Map;for(let n of e.workers){let r=n.latest_run,i=r?.model_provider||n.worker.model_provider,a=r?.model_id||n.worker.model_id,o=`${i}/${a}`,s=t.get(o)??{model_provider:i,model_id:a,model_key:o,runs:0,success:0,failure:0,running:0,input_tokens:0,output_tokens:0,total_tokens:0,cost_usd:0,unknown_cost_runs:0,duration_ms:0,avg_duration_ms:0,unknown_duration_ms:0,review_count:0,review_score:0,worker_ids:[]};s.worker_ids=[...s.worker_ids||[],n.worker.id],r&&(s.runs+=1,r.status===`success`&&(s.success+=1),[`failure`,`cap_exceeded`,`paused`,`rejected`].includes(r.status)&&(s.failure+=1),[`running`,`awaiting_approval`].includes(r.status)&&(s.running+=1),s.input_tokens+=r.input_tokens||0,s.output_tokens+=r.output_tokens||0,s.total_tokens+=(r.input_tokens||0)+(r.output_tokens||0),s.cost_usd+=r.cost_usd||0,s.duration_ms+=r.duration_ms||0,(r.accounting_missing||se(r))&&(s.unknown_cost_runs=(s.unknown_cost_runs||0)+1,s.unknown_duration_ms=(s.unknown_duration_ms||0)+(r.duration_ms||0))),e.review?.reviewed&&typeof e.review.score==`number`&&(s.review_count=1,s.review_score=e.review.score,s.task_kind=e.review.task_kind||e.task_kind,s.capability_scores=e.review.scores),t.set(o,s)}return Array.from(t.values()).map(e=>({...e,avg_duration_ms:e.runs&&e.runs>(e.unknown_cost_runs||0)?Math.round((e.duration_ms-(e.unknown_duration_ms||0))/(e.runs-(e.unknown_cost_runs||0))):0}))}function se(e){return e?e.status===`success`&&!e.input_tokens&&!e.output_tokens&&!e.cost_usd:!1}function R(e,t){if(t)for(let[n,r]of Object.entries(t))Number.isFinite(r)&&(e.capabilityTotals[n]=(e.capabilityTotals[n]||0)+r,e.capabilityCounts[n]=(e.capabilityCounts[n]||0)+1)}function z(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t[r]||0;e>0&&(n[r]=i/e)}return n}var B=r(),V=[`coding`,`review`,`architecture`,`research`,`tool_calling`];function H(){let[e,t]=u(),[r,i]=(0,D.useState)(``),a=e.get(`workspace_id`)||``,o=e.get(`task_kind`)||``,s=Se(e.get(`period`)),{data:c,loading:l}=p((0,D.useCallback)(()=>n(),[])),{data:f,loading:m,error:g,refetch:_}=p((0,D.useCallback)(()=>ie({workspaceId:a||void 0,taskKind:o.trim()||void 0,limit:200}),[a,o])),{data:v,loading:y,error:b,refetch:x}=p((0,D.useCallback)(()=>re({workspaceId:a||void 0,limit:500}),[a])),S=(0,D.useMemo)(()=>ge(v??[],o),[v,o]),C=(0,D.useMemo)(()=>A(S,s),[S,s]),w=(0,D.useMemo)(()=>M(C),[C]),T=(0,D.useMemo)(()=>j(f??[]),[f]),E=(0,D.useMemo)(()=>Q(v??[],o),[v,o]),O=(0,D.useMemo)(()=>_e(T,r),[T,r]),k=(0,D.useMemo)(()=>ve(w,r),[w,r]),N=(0,D.useMemo)(()=>he(T,w),[T,w]);function P(n,r){let i=new URLSearchParams(e);r?i.set(n,r):i.delete(n),t(i)}function F(){_(),x()}let I=m||y,L=xe(c??[],a);return(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(d,{variant:`ghost`,size:`sm`,className:`mb-2 rounded-none px-0`,asChild:!0,children:(0,B.jsxs)(ee,{to:`/delegations`,children:[(0,B.jsx)(te,{className:`mr-1.5 h-4 w-4`}),`Delegations`]})}),(0,B.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold tracking-tight`,children:[(0,B.jsx)(ae,{className:`h-6 w-6`}),` Model ranks`]}),(0,B.jsx)(`p`,{className:`mt-1 max-w-3xl text-sm text-muted-foreground`,children:`Current router capacity beside reviewed delegation performance for the selected workspace and task kind.`})]}),(0,B.jsxs)(d,{variant:`outline`,size:`sm`,className:`rounded-none`,onClick:F,disabled:I,children:[I?(0,B.jsx)(h,{className:`mr-1.5 h-4 w-4 animate-spin`}):(0,B.jsx)(ne,{className:`mr-1.5 h-4 w-4`}),`Refresh`]})]}),(0,B.jsx)(U,{workspaces:c??[],workspacesLoading:l,workspaceID:a,taskKind:o,taskKindOptions:E,period:s,modelQuery:r,onWorkspaceChange:e=>P(`workspace_id`,e),onTaskKindChange:e=>P(`task_kind`,e),onPeriodChange:e=>P(`period`,e),onModelQueryChange:i}),(g||b)&&(0,B.jsxs)(`section`,{className:`flex items-start justify-between gap-3 border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[g&&(0,B.jsxs)(`div`,{children:[`Router rank failed: `,g]}),b&&(0,B.jsxs)(`div`,{children:[`Reviewed rank failed: `,b]})]}),(0,B.jsx)(d,{size:`sm`,variant:`ghost`,className:`rounded-none`,onClick:F,children:`Retry`})]}),(0,B.jsx)(W,{summary:N,workspaceName:L,period:s,taskKind:o}),(0,B.jsx)(K,{}),(0,B.jsx)(ce,{rows:O,loading:m&&!f}),(0,B.jsx)(ue,{rows:k,loading:y&&!v,period:s})]})}function U({workspaces:e,workspacesLoading:t,workspaceID:n,taskKind:r,taskKindOptions:i,period:a,modelQuery:o,onWorkspaceChange:s,onTaskKindChange:c,onPeriodChange:l,onModelQueryChange:u}){return(0,B.jsxs)(`section`,{className:`border border-border bg-card/25 p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,B.jsx)(E,{className:`h-3.5 w-3.5`}),`Filters`]}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-3 xl:grid-cols-[minmax(14rem,1.1fr)_minmax(14rem,1.3fr)_8rem_minmax(14rem,1fr)]`,children:[(0,B.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Workspace`}),(0,B.jsxs)(`select`,{className:`h-9 w-full rounded-none border border-input bg-background px-3 text-sm outline-none focus:border-primary`,value:n,onChange:e=>s(e.target.value),disabled:t,children:[(0,B.jsx)(`option`,{value:``,children:`All workspaces`}),e.map(e=>(0,B.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))]})]}),(0,B.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Task kind`}),(0,B.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,B.jsx)(f,{className:`h-9 rounded-none`,value:r,placeholder:`All task kinds`,onChange:e=>c(e.target.value)}),r&&(0,B.jsx)(d,{variant:`outline`,size:`sm`,className:`h-9 rounded-none`,onClick:()=>c(``),children:`Clear`})]})]}),(0,B.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Review window`}),(0,B.jsx)(`select`,{className:`h-9 w-full rounded-none border border-input bg-background px-3 text-sm outline-none focus:border-primary`,value:a,onChange:e=>l(e.target.value),children:O.map(e=>(0,B.jsx)(`option`,{value:e.key,children:e.label},e.key))})]}),(0,B.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:`Search models`}),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(g,{className:`pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,B.jsx)(f,{className:`h-9 rounded-none pl-8`,value:o,placeholder:`Provider, model, tag`,onChange:e=>u(e.target.value)})]})]})]}),i.length>0&&(0,B.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(0,B.jsx)(d,{variant:r?`outline`:`secondary`,size:`sm`,className:`h-7 rounded-none px-2 text-[11px]`,onClick:()=>c(``),children:`All`}),i.map(e=>(0,B.jsx)(d,{variant:r===e?`secondary`:`outline`,size:`sm`,className:`h-7 rounded-none px-2 font-mono text-[11px]`,onClick:()=>c(e),children:e},e))]})]})}function W({summary:e,workspaceName:t,period:n,taskKind:r}){return(0,B.jsxs)(`section`,{className:`grid gap-px border border-border bg-border md:grid-cols-5`,children:[(0,B.jsx)(G,{icon:(0,B.jsx)(s,{className:`h-4 w-4`}),label:`Router candidates`,value:`${e.routerModels}`,detail:`${e.availableModels} available`}),(0,B.jsx)(G,{icon:(0,B.jsx)(c,{className:`h-4 w-4`}),label:`Reviewed models`,value:`${e.reviewedModels}`,detail:`${e.reviewCount} reviews`}),(0,B.jsx)(G,{icon:(0,B.jsx)(m,{className:`h-4 w-4`}),label:`Known reliability`,value:`${e.knownSuccessRate}%`,detail:e.accountingGaps?`${e.accountingGaps} usage gaps`:`usage known`}),(0,B.jsx)(G,{icon:(0,B.jsx)(l,{className:`h-4 w-4`}),label:`Live workers`,value:`${e.running}`,detail:e.operationalFailures?`${e.operationalFailures} launch failures`:`no launch failures`}),(0,B.jsx)(G,{icon:(0,B.jsx)(o,{className:`h-4 w-4`}),label:t,value:k(n),detail:r?`task: ${r}`:`all task kinds`})]})}function G({icon:e,label:t,value:n,detail:r}){return(0,B.jsxs)(`div`,{className:`min-w-0 bg-background p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground`,children:[e,(0,B.jsx)(`span`,{className:`truncate`,children:t})]}),(0,B.jsx)(`div`,{className:`mt-2 font-mono text-xl font-semibold tabular-nums`,children:n}),(0,B.jsx)(`div`,{className:`mt-1 truncate text-[11px] text-muted-foreground`,children:r})]})}function K(){return(0,B.jsxs)(`section`,{className:`border border-border bg-card/20 p-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,B.jsx)(o,{className:`h-3.5 w-3.5`}),`Rank basis`]}),(0,B.jsxs)(`div`,{className:`mt-3 grid gap-2 text-sm text-muted-foreground lg:grid-cols-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Router rank`}),` uses registered candidates, availability, capability fit, reviewed score, reliability, cost, and duration.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Reviewed rank`}),` uses completed delegation reviews in the selected window, then review volume, success rate, cost, and duration.`]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`span`,{className:`font-medium text-foreground`,children:`Accounting flags`}),` separate missing usage telemetry from genuine failure so zero-cost rows do not look free by accident.`]})]})]})}function ce({rows:e,loading:t}){return(0,B.jsxs)(`section`,{className:`border border-border bg-card/20`,children:[(0,B.jsx)(q,{icon:(0,B.jsx)(s,{className:`h-4 w-4`}),title:`Current router rank`,detail:`What capacity mode can select now.`,count:e.length,loading:t}),(0,B.jsxs)(T,{children:[(0,B.jsx)(b,{children:(0,B.jsxs)(C,{children:[(0,B.jsx)(x,{className:`w-12`,children:`Rank`}),(0,B.jsx)(x,{children:`Model`}),(0,B.jsx)(x,{className:`w-32`,children:`Status`}),(0,B.jsx)(x,{className:`w-36`,children:`Capacity`}),(0,B.jsx)(x,{className:`w-32`,children:`Review`}),(0,B.jsx)(x,{className:`w-36`,children:`Reliability`}),(0,B.jsx)(x,{className:`w-24 text-right`,children:`Runs`}),(0,B.jsx)(x,{className:`w-28 text-right`,children:`Cost`}),(0,B.jsx)(x,{className:`w-24 text-right`,children:`Latency`}),(0,B.jsx)(x,{className:`min-w-52`,children:`Signals`})]})}),(0,B.jsx)(S,{children:t?(0,B.jsx)(X,{colSpan:10,label:`Loading router rank`}):e.length===0?(0,B.jsx)(Z,{colSpan:10,label:`No model capacity rows match the current filters.`}):e.map(e=>(0,B.jsx)(le,{row:e},`${e.model_profile_id||e.model_key}-${e.rank}`))})]})]})}function le({row:e}){let t=e.accounting_known!==!1;return(0,B.jsxs)(C,{children:[(0,B.jsxs)(w,{className:`font-mono text-xs text-muted-foreground`,children:[`#`,e.rank]}),(0,B.jsx)(w,{children:(0,B.jsx)(J,{provider:e.model_provider,modelID:e.model_id,modelKey:e.model_key,label:e.label,tags:e.capability_tags})}),(0,B.jsx)(w,{children:(0,B.jsx)(fe,{row:e})}),(0,B.jsx)(w,{children:(0,B.jsx)(Y,{value:e.capacity_score,label:Math.round(e.capacity_score).toString()})}),(0,B.jsx)(w,{children:e.review_count?(0,B.jsx)(Y,{value:e.review_score,label:`${Math.round(e.review_score)} / ${e.review_count}`}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`new`})}),(0,B.jsx)(w,{children:(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`div`,{className:`font-mono text-xs tabular-nums`,children:e.runs?t?$(e.success_rate):`usage gap`:`new`}),(0,B.jsxs)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:[e.success,` success, `,e.failure,` fail`]})]})}),(0,B.jsxs)(w,{className:`text-right font-mono text-xs tabular-nums`,children:[(0,B.jsx)(`div`,{children:e.runs}),e.running>0&&(0,B.jsxs)(`div`,{className:`text-sky-300`,children:[e.running,` running`]})]}),(0,B.jsx)(w,{className:`text-right font-mono text-xs tabular-nums`,children:t||!e.runs?P(e.cost_usd):`unknown`}),(0,B.jsx)(w,{className:`text-right font-mono text-xs tabular-nums`,children:F(e.avg_duration_ms)}),(0,B.jsx)(w,{children:(0,B.jsx)(pe,{row:e})})]})}function ue({rows:e,loading:t,period:n}){return(0,B.jsxs)(`section`,{className:`border border-border bg-card/20`,children:[(0,B.jsx)(q,{icon:(0,B.jsx)(c,{className:`h-4 w-4`}),title:`Reviewed performance rank`,detail:`Completed delegation reviews in ${k(n)}.`,count:e.length,loading:t}),(0,B.jsxs)(T,{children:[(0,B.jsx)(b,{children:(0,B.jsxs)(C,{children:[(0,B.jsx)(x,{className:`w-12`,children:`Rank`}),(0,B.jsx)(x,{children:`Model`}),(0,B.jsx)(x,{className:`w-36`,children:`Score`}),(0,B.jsx)(x,{className:`w-24 text-right`,children:`Reviews`}),(0,B.jsx)(x,{className:`w-32`,children:`Success`}),(0,B.jsx)(x,{className:`w-24 text-right`,children:`Runs`}),(0,B.jsx)(x,{className:`w-28 text-right`,children:`Tokens`}),(0,B.jsx)(x,{className:`w-28 text-right`,children:`Cost`}),(0,B.jsx)(x,{className:`w-24 text-right`,children:`Latency`}),(0,B.jsx)(x,{className:`min-w-56`,children:`Capability scores`})]})}),(0,B.jsx)(S,{children:t?(0,B.jsx)(X,{colSpan:10,label:`Loading reviewed rank`}):e.length===0?(0,B.jsx)(Z,{colSpan:10,label:`No reviewed delegation data matches the current filters.`}):e.map((e,t)=>(0,B.jsx)(de,{row:e,rank:t+1},e.modelKey))})]})]})}function de({row:e,rank:t}){return(0,B.jsxs)(C,{children:[(0,B.jsxs)(w,{className:`font-mono text-xs text-muted-foreground`,children:[`#`,t]}),(0,B.jsx)(w,{children:(0,B.jsx)(J,{provider:e.modelProvider,modelID:e.modelID,modelKey:e.modelKey})}),(0,B.jsx)(w,{children:e.reviewCount?(0,B.jsx)(Y,{value:e.avgScore,label:`${Math.round(e.avgScore)}`}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`new`})}),(0,B.jsx)(w,{className:`text-right font-mono text-xs tabular-nums`,children:e.reviewCount}),(0,B.jsxs)(w,{children:[(0,B.jsx)(`div`,{className:`font-mono text-xs tabular-nums`,children:e.runs?$(e.successRate):`new`}),e.failure>0&&(0,B.jsxs)(`div`,{className:`text-[10px] uppercase tracking-wider text-red-300`,children:[e.failure,` fail`]})]}),(0,B.jsxs)(w,{className:`text-right font-mono text-xs tabular-nums`,children:[(0,B.jsx)(`div`,{children:e.runs}),e.running>0&&(0,B.jsxs)(`div`,{className:`text-sky-300`,children:[e.running,` running`]})]}),(0,B.jsx)(w,{className:`text-right font-mono text-xs tabular-nums`,children:N(e.totalTokens)}),(0,B.jsx)(w,{className:`text-right font-mono text-xs tabular-nums`,children:e.costKnown||!e.runs?P(e.costUSD):`unknown`}),(0,B.jsx)(w,{className:`text-right font-mono text-xs tabular-nums`,children:F(e.avgDurationMS)}),(0,B.jsx)(w,{children:(0,B.jsx)(me,{scores:e.capabilityScores})})]})}function q({icon:e,title:t,detail:n,count:r,loading:i}){return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold`,children:[e,t]}),(0,B.jsx)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:n})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,B.jsx)(h,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,B.jsxs)(v,{variant:`outline`,className:`text-[10px] uppercase`,children:[r,` rows`]})]})]})}function J({provider:e,modelID:t,modelKey:n,label:r,tags:i}){return(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`truncate text-sm font-medium`,children:t||n}),r&&(0,B.jsx)(v,{variant:`outline`,className:`max-w-48 truncate text-[10px] uppercase`,children:r})]}),(0,B.jsx)(`div`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:e||`provider`}),i&&i.length>0&&(0,B.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[i.slice(0,4).map(e=>(0,B.jsx)(v,{variant:`outline`,className:`font-mono text-[10px] text-muted-foreground`,children:e},e)),i.length>4&&(0,B.jsxs)(v,{variant:`outline`,className:`font-mono text-[10px] text-muted-foreground`,children:[`+`,i.length-4]})]})]})}function fe({row:e}){return e.available?(0,B.jsxs)(v,{variant:`outline`,className:`border-emerald-500/40 text-emerald-300`,children:[(0,B.jsx)(m,{className:`mr-1 h-3 w-3`}),`available`]}):(0,B.jsxs)(v,{variant:`outline`,className:`border-red-500/40 text-red-300`,children:[(0,B.jsx)(a,{className:`mr-1 h-3 w-3`}),`off`]})}function pe({row:e}){let t=[];return e.unavailable_reason&&t.push((0,B.jsxs)(v,{variant:`outline`,className:`max-w-72 truncate border-red-500/40 text-red-300`,children:[(0,B.jsx)(y,{className:`mr-1 h-3 w-3`}),e.unavailable_reason]},`unavailable`)),e.accounting_known===!1&&e.runs>0&&t.push((0,B.jsxs)(v,{variant:`outline`,className:`border-amber-500/40 text-amber-300`,children:[(0,B.jsx)(o,{className:`mr-1 h-3 w-3`}),`usage missing`]},`accounting`)),(e.operational_failures||0)>0&&t.push((0,B.jsxs)(v,{variant:`outline`,className:`border-red-500/40 text-red-300`,children:[(0,B.jsx)(y,{className:`mr-1 h-3 w-3`}),e.operational_failures,` launch fail`]},`ops`)),e.running>0&&t.push((0,B.jsxs)(v,{variant:`outline`,className:`border-sky-500/40 text-sky-300`,children:[(0,B.jsx)(l,{className:`mr-1 h-3 w-3`}),e.running,` live`]},`running`)),e.duplicate_count&&e.duplicate_count>1&&t.push((0,B.jsxs)(v,{variant:`outline`,className:`text-[10px] uppercase`,children:[e.duplicate_count,` routes`]},`routes`)),t.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`clear`})}function Y({value:e,label:t}){let n=Ce(e,0,100);return(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`div`,{className:`font-mono text-xs tabular-nums`,children:t}),(0,B.jsx)(`div`,{className:`h-1.5 w-24 bg-muted`,children:(0,B.jsx)(`div`,{className:`h-full bg-primary/70`,style:{width:`${n}%`}})})]})}function me({scores:e}){let t=Object.entries(e).filter(([,e])=>Number.isFinite(e)).sort((e,t)=>t[1]-e[1]).slice(0,4);return t.length?(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(([e,t])=>(0,B.jsxs)(v,{variant:`outline`,className:`font-mono text-[10px]`,children:[e,`: `,Math.round(t)]},e))}):(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`none recorded`})}function X({colSpan:e,label:t}){return(0,B.jsx)(C,{children:(0,B.jsxs)(w,{colSpan:e,className:`py-8 text-center text-sm text-muted-foreground`,children:[(0,B.jsx)(h,{className:`mr-2 inline h-4 w-4 animate-spin`}),t]})})}function Z({colSpan:e,label:t}){return(0,B.jsx)(C,{children:(0,B.jsxs)(w,{colSpan:e,className:`py-8 text-center text-sm text-muted-foreground`,children:[(0,B.jsx)(_,{className:`mr-2 inline h-4 w-4`}),t]})})}function he(e,t){let n=e.filter(e=>e.runs>0&&e.accounting_known!==!1),r=n.reduce((e,t)=>e+t.success,0),i=n.reduce((e,t)=>e+t.runs,0);return{routerModels:e.length,availableModels:e.filter(e=>e.available).length,reviewedModels:t.filter(e=>e.reviewCount>0).length,reviewCount:t.reduce((e,t)=>e+t.reviewCount,0),running:e.reduce((e,t)=>e+t.running,0),accountingGaps:e.filter(e=>e.runs>0&&e.accounting_known===!1).length,operationalFailures:e.reduce((e,t)=>e+(t.operational_failures||0),0),knownSuccessRate:i?Math.round(r/i*100):0}}function ge(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>(e.task_kind||e.review?.task_kind||``).trim().toLowerCase()===n):e}function Q(e,t){let n=new Set(V);for(let t of e){let e=(t.task_kind||t.review?.task_kind||``).trim();e&&n.add(e)}return t.trim()&&n.add(t.trim()),Array.from(n).sort((e,t)=>e.localeCompare(t))}function _e(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>ye(e).includes(n)):e}function ve(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>be(e).includes(n)):e}function ye(e){return[e.label,e.model_provider,e.model_id,e.model_key,e.unavailable_reason,...e.capability_tags||[],...e.input_modalities||[],...e.output_modalities||[]].filter(Boolean).join(` `).toLowerCase()}function be(e){return[e.modelProvider,e.modelID,e.modelKey,...Object.keys(e.capabilityScores||{})].filter(Boolean).join(` `).toLowerCase()}function xe(e,t){return t?e.find(e=>e.id===t)?.name||t:`All workspaces`}function Se(e){return O.some(t=>t.key===e)?e:`12h`}function $(e){return Number.isFinite(e)?`${Math.round(e*100)}%`:`0%`}function Ce(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}export{H as ModelRanksPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/Pairing-BuhVbyNU.js b/internal/web/dist/assets/Pairing-BuhVbyNU.js deleted file mode 100644 index 58baa77..0000000 --- a/internal/web/dist/assets/Pairing-BuhVbyNU.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{it as n,on as r,wt as i}from"./client-CaIRceNv.js";import{t as a}from"./createLucideIcon-WB390fY6.js";import{$n as o,An as s,Bn as c,Br as l,Fn as u,Ft as d,Ln as f,Mn as p,Nn as m,On as h,Pn as g,Pt as _,Sr as v,Un as y,_ as b,_r as x,i as S,jn as C,jr as w,kn as T,n as E,nr as D,r as O,t as k,y as A}from"./index-BDLzoIgt.js";import{n as j,r as M,t as N}from"./api-C7pu_Aru.js";import{t as P}from"./textarea-BiOhexhg.js";var F=a(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]),I=e(t(),1),L=r();function R({onComplete:e}){let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(null),[a,c]=(0,I.useState)(!1),[l,d]=(0,I.useState)(!1),[,f]=(0,I.useState)(Date.now());(0,I.useEffect)(()=>{if(!t)return;let e=setInterval(()=>f(Date.now()),1e3);return()=>clearInterval(e)},[t]);let _=(0,I.useCallback)(async()=>{c(!0);try{i(await M(`/pair/start`,{method:`POST`}))}catch(e){w.error(`Pair start failed: ${e.message}`),n(!1)}finally{c(!1)}},[]);(0,I.useEffect)(()=>{t&&!r&&_(),t||(i(null),d(!1))},[t,r,_]);let y=(0,I.useCallback)(async()=>{if(r)try{await navigator.clipboard.writeText(r.qr_payload),d(!0),w.success(`Pairing payload copied`),setTimeout(()=>d(!1),2e3)}catch{w.error(`Copy failed — select and copy manually`)}},[r]);return(0,L.jsxs)(h,{open:t,onOpenChange:n,children:[(0,L.jsx)(g,{asChild:!0,children:(0,L.jsxs)(u,{"data-testid":`pair-show-code-btn`,children:[(0,L.jsx)(o,{className:`mr-2 h-4 w-4`}),`Pair this device`]})}),(0,L.jsxs)(T,{className:`sm:max-w-lg`,children:[(0,L.jsxs)(p,{children:[(0,L.jsx)(m,{children:`Pair a new device`}),(0,L.jsx)(s,{children:`Copy the payload, paste it on the other device, then type the 6-digit code there. The code expires in 5 minutes.`})]}),a&&(0,L.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,L.jsx)(D,{className:`h-6 w-6 animate-spin text-muted-foreground`})}),r&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-5 py-2`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border bg-muted/40 px-6 py-5 text-center`,children:[(0,L.jsx)(`div`,{"data-testid":`pair-code`,className:`font-mono text-5xl font-semibold tracking-[0.4em] pl-[0.4em] text-foreground tabular-nums`,children:r.code}),(0,L.jsxs)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:[`expires in `,N(r.expires_at)]})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground`,children:`Pairing payload`}),(0,L.jsx)(u,{variant:`ghost`,size:`sm`,onClick:y,"data-testid":`pair-payload-copy`,className:`h-7 gap-1.5 text-xs`,children:l?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(v,{className:`h-3.5 w-3.5`}),` Copied`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(x,{className:`h-3.5 w-3.5`}),` Copy`]})})]}),(0,L.jsx)(`code`,{"data-testid":`pair-payload-text`,className:`block w-full select-all rounded border bg-muted px-3 py-2 font-mono text-[11px] leading-relaxed break-all`,children:r.qr_payload}),(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Paste this into the other device's "Enter code" dialog.`})]})]}),(0,L.jsx)(C,{children:(0,L.jsx)(u,{variant:`outline`,"data-testid":`pair-show-done`,onClick:()=>{n(!1),e()},children:`Done`})})]})]})}function z(e){let t=e.trim();if(!t.toLowerCase().startsWith(`mcplexer://pair/`))return null;let n;try{n=new URL(t)}catch{return null}let r=n.pathname.split(`/`).filter(Boolean)[0];if(!r||!/^\d{6}$/.test(r))return null;let i=n.searchParams.get(`peer`)??void 0;return i?{code:r,peer_id:i,user_id:n.searchParams.get(`u`)??void 0,display_name:n.searchParams.get(`n`)??void 0}:null}function B(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n=t,r=typeof n.code==`string`?n.code:void 0,i=typeof n.peer_id==`string`?n.peer_id:void 0,a=typeof n.user_id==`string`?n.user_id:void 0,o=typeof n.display_name==`string`?n.display_name:void 0;return i?{code:r,peer_id:i,user_id:a,display_name:o}:null}function V(e){return z(e)??B(e)}function H({onComplete:e,initialPayload:t=``,autoOpen:n=!1}){let[r,i]=(0,I.useState)(n),[a,c]=(0,I.useState)(``),[l,f]=(0,I.useState)(t),[v,y]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!t)return;f(t),i(!0);let e=V(t);e?.code&&c(e.code)},[t]);let b=(0,I.useCallback)(async()=>{let t=V(l);if(!t){w.error(`Paste the pairing payload or a mcplexer:// URL from the other device`);return}let n=(a||t.code||``).trim();if(!t.peer_id||n.length!==6){w.error(`Need a 6-digit code and a peer ID`);return}y(!0);try{await M(`/pair/complete`,{method:`POST`,body:JSON.stringify({code:n,peer_id:t.peer_id,display_name:t.display_name??``,...t.user_id?{user_id:t.user_id}:{}})}),w.success(`Device paired`),i(!1),c(``),f(``),e()}catch(e){w.error(`Pair failed: ${e.message}`)}finally{y(!1)}},[a,l,e]);return(0,L.jsxs)(h,{open:r,onOpenChange:i,children:[(0,L.jsx)(g,{asChild:!0,children:(0,L.jsxs)(u,{variant:`outline`,"data-testid":`pair-enter-code-btn`,children:[(0,L.jsx)(o,{className:`mr-2 h-4 w-4`}),`Enter code`]})}),(0,L.jsxs)(T,{className:`sm:max-w-lg`,children:[(0,L.jsxs)(p,{children:[(0,L.jsx)(m,{children:`Pair with another device`}),(0,L.jsx)(s,{children:`Paste the payload from the other device's pairing dialog, then type its 6-digit code below.`})]}),(0,L.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(_,{htmlFor:`qr-payload`,className:`text-xs font-medium text-muted-foreground`,children:`Pairing payload`}),(0,L.jsx)(P,{id:`qr-payload`,"data-testid":`pair-payload-input`,rows:4,className:`font-mono text-[11px] leading-relaxed`,placeholder:`{"code":"…","peer_id":"…"}`,value:l,onChange:e=>f(e.target.value),autoFocus:!0})]}),(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(_,{htmlFor:`pair-code`,className:`text-xs font-medium text-muted-foreground`,children:`6-digit code`}),(0,L.jsx)(d,{id:`pair-code`,inputMode:`numeric`,maxLength:6,placeholder:`123456`,className:`mx-auto block w-full max-w-[14rem] text-center font-mono text-2xl tracking-[0.25em] pl-[0.25em] tabular-nums h-14`,value:a,onChange:e=>c(e.target.value.replace(/\D/g,``))})]})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(u,{variant:`outline`,onClick:()=>i(!1),"data-testid":`pair-enter-cancel`,children:`Cancel`}),(0,L.jsxs)(u,{onClick:b,disabled:v,"data-testid":`pair-submit-btn`,children:[v&&(0,L.jsx)(D,{className:`mr-2 h-4 w-4 animate-spin`}),`Pair`]})]})]})]})}var U={direct:{label:`On LAN`,variant:`default`,title:`Connected directly over the local network (mDNS-discovered)`},"hole-punched":{label:`Hole-punched`,variant:`secondary`,title:`Connected over the Internet via DCUtR NAT traversal`},relay:{label:`Relayed`,variant:`outline`,title:`Connected via a libp2p circuit-v2 relay (slowest path)`}};function W({mode:e,className:t}){if(!e)return null;let n=U[e];return n?(0,L.jsx)(A,{variant:n.variant,className:t,title:n.title,children:n.label}):null}var G={connected:{label:`Connected`,className:`bg-emerald-500/10 text-emerald-600 border-emerald-500/30`},searching_dht:{label:`Searching`,className:`bg-amber-500/10 text-amber-600 border-amber-500/30`},dial_failed:{label:`Dial failed`,className:`bg-red-500/10 text-red-600 border-red-500/30`},not_found_in_dht:{label:`Not found`,className:`bg-amber-500/10 text-amber-600 border-amber-500/30`},dht_unavailable:{label:`DHT off`,className:`bg-muted text-muted-foreground border-border`}};function K(e){let t=Date.now()-new Date(e).getTime();if(Number.isNaN(t))return e;let n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function q({state:e,lastAttemptAt:t,lastError:n,className:r}){if(!e)return null;let i=G[e];if(!i)return null;let a=[i.label];t&&a.push(`last try ${K(t)}`),n&&a.push(n);let o=a.join(` · `);return(0,L.jsx)(A,{variant:`outline`,className:`${i.className} ${r??``}`,title:o,"data-testid":`reconnect-badge-${e}`,children:i.label})}var J=`mcplexer:pairing:getting-started:dismissed`;function Y(e){return e.length>8?e.slice(-8):e}function X({onDismiss:e}){let[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(!0),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(``),[l,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{let e=!0;return M(`/identity`).then(t=>{e&&n(t.peer_id)}).catch(t=>{e&&o(t instanceof Error?t.message:String(t))}).finally(()=>{e&&i(!1)}),()=>{e=!1}},[]);let g=(0,I.useCallback)(async()=>{let e=s.trim();if(!e){w.error(`Paste the remote peer ID first`);return}p(!0),h(null);try{let t=await M(`/pair/start`,{method:`POST`});await M(`/pair/complete`,{method:`POST`,body:JSON.stringify({code:t.code,peer_id:e})}),h({ok:!0,msg:`Pairing initiated. Check the remote machine to confirm.`}),w.success(`Pairing request sent`)}catch(e){let t=e instanceof Error?e.message:String(e);h({ok:!1,msg:t}),w.error(`Pair failed: ${t}`)}finally{p(!1)}},[s]);return(0,L.jsxs)(k,{className:`border-dashed`,children:[(0,L.jsxs)(O,{className:`flex flex-row items-start justify-between space-y-0`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(S,{className:`text-base`,children:`Getting started`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Connect another machine to this MCPlexer instance.`})]}),(0,L.jsx)(u,{variant:`ghost`,size:`icon-xs`,onClick:e,"aria-label":`Dismiss getting started`,className:`text-muted-foreground hover:text-foreground shrink-0`,children:(0,L.jsx)(f,{className:`h-4 w-4`})})]}),(0,L.jsxs)(E,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`This machine`}),r&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-3 text-sm text-muted-foreground`,children:[(0,L.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Loading peer ID...`]}),a&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-3 text-sm text-destructive`,children:[(0,L.jsx)(y,{className:`h-4 w-4`}),a]}),t&&(0,L.jsxs)(`div`,{className:`flex items-center gap-3 rounded border bg-muted/40 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1`,children:`Peer ID`}),(0,L.jsx)(`div`,{className:`font-mono text-lg font-semibold tracking-wide break-all select-all`,"data-testid":`self-peer-id`,children:t})]}),(0,L.jsx)(b,{value:t,className:`shrink-0`})]})]}),(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:`Connect another machine`}),(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(A,{variant:`outline`,tone:`mono`,className:`shrink-0 mt-0.5`,children:`1`}),(0,L.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:`Install mcplexer on the other machine`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded border bg-muted/40 px-3 py-2`,children:[(0,L.jsx)(`code`,{className:`font-mono text-xs flex-1 select-all`,children:`make install`}),(0,L.jsx)(b,{value:`make install`})]})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(A,{variant:`outline`,tone:`mono`,className:`shrink-0 mt-0.5`,children:`2`}),(0,L.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:`Run the pairing command`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded border bg-muted/40 px-3 py-2`,children:[(0,L.jsx)(`code`,{className:`font-mono text-xs flex-1 select-all`,children:`mcplexer pair`}),(0,L.jsx)(b,{value:`mcplexer pair`})]})]})]}),(0,L.jsxs)(`div`,{className:`flex gap-3`,children:[(0,L.jsx)(A,{variant:`outline`,tone:`mono`,className:`shrink-0 mt-0.5`,children:`3`}),(0,L.jsxs)(`div`,{className:`space-y-1.5 min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:`Paste the remote peer ID here`}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(d,{placeholder:`12D3KooW...`,value:s,onChange:e=>c(e.target.value),className:`font-mono text-xs`,"data-testid":`pairing-remote-peer-input`}),(0,L.jsxs)(u,{onClick:g,disabled:l||!s.trim(),"data-testid":`pairing-remote-peer-submit`,size:`sm`,children:[l&&(0,L.jsx)(D,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}),`Pair`]})]}),m&&(0,L.jsx)(`div`,{className:`text-xs ${m.ok?`text-emerald-500`:`text-destructive`}`,"data-testid":`pairing-remote-peer-result`,children:m.msg})]})]})]})]}),(0,L.jsx)(`div`,{className:`rounded border border-dashed bg-muted/20 px-4 py-3 text-xs text-muted-foreground`,children:`You can also use the 6-digit code flow below: click "Pair this device" to show a code, then enter it on the other machine.`})]})]})}function Z({peer:e,collides:t,onRevoke:n}){let r=!!e.revoked_at,[i,a]=(0,I.useState)(e.connection_mode??null),[o,s]=(0,I.useState)({state:e.reconnect_state,lastAttemptAt:e.last_dial_attempt_at,lastError:e.last_dial_error});(0,I.useEffect)(()=>{if(r)return;let t=!0,n=()=>{M(`/peers/${encodeURIComponent(e.peer_id)}/status`).then(e=>{t&&(a((e.connection_mode===`none`?``:e.connection_mode)??null),s({state:e.reconnect_state,lastAttemptAt:e.last_dial_attempt_at,lastError:e.last_dial_error}))}).catch(()=>{})};n();let i=setInterval(n,1e4);return()=>{t=!1,clearInterval(i)}},[e.peer_id,r]);let l=Y(e.peer_id),d=e.display_name||`peer-${l}`,f=t&&!!e.display_name;return(0,L.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/40 py-3 last:border-0`,"data-testid":`peer-row-${e.peer_id}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium ${r?`text-muted-foreground line-through`:``}`,children:[(0,L.jsxs)(`span`,{className:`truncate`,"data-testid":`peer-display-name-${e.peer_id}`,children:[d,f&&(0,L.jsxs)(`span`,{className:`ml-1.5 font-mono text-xs text-muted-foreground`,children:[`(`,l.slice(-3),`…)`]})]}),!r&&(0,L.jsx)(W,{mode:i,className:`text-[10px]`}),!r&&(0,L.jsx)(q,{state:o.state,lastAttemptAt:o.lastAttemptAt,lastError:o.lastError,className:`text-[10px]`})]}),(0,L.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`peer-`,l,` · paired `,j(e.paired_at),` · last seen `,j(e.last_seen),o.lastAttemptAt&&(0,L.jsxs)(L.Fragment,{children:[` · last try `,j(o.lastAttemptAt)]}),r&&` · revoked`]})]}),!r&&(0,L.jsxs)(u,{variant:`ghost`,size:`sm`,onClick:n,"data-testid":`peer-revoke-${e.peer_id}`,"aria-label":`Revoke ${d}`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive`,children:[(0,L.jsx)(c,{className:`mr-1.5 h-3.5 w-3.5`}),`Revoke`]})]})}function Q(){let[e,t]=(0,I.useState)([]),[r,a]=(0,I.useState)([]),[o,s]=(0,I.useState)(!0),[c,u]=(0,I.useState)(!0),[d,f]=(0,I.useState)(null),[p,m]=(0,I.useState)(null),[h,g]=l(),[_,v]=(0,I.useState)(()=>localStorage.getItem(J)===`1`),b=(0,I.useMemo)(()=>h.get(`paste`)??``,[h]);(0,I.useEffect)(()=>{if(!b)return;let e=new URLSearchParams(h);e.delete(`paste`),g(e,{replace:!0})},[b,h,g]);let x=(0,I.useCallback)(async()=>{s(!0),f(null);try{t((await M(`/peers`)).peers??[])}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}},[]),C=(0,I.useCallback)(async()=>{u(!0),m(null);try{let e=await i();a(await Promise.all((e.users??[]).map(e=>n(e.user_id))))}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}},[]);(0,I.useEffect)(()=>{x()},[x]),(0,I.useEffect)(()=>{C()},[C]);let T=(0,I.useCallback)(async e=>{try{await M(`/peers/${encodeURIComponent(e)}`,{method:`DELETE`}),w.success(`Peer revoked`),await x()}catch(e){w.error(`Revoke failed: ${e instanceof Error?e.message:String(e)}`)}},[x]),A=(0,I.useCallback)(()=>{v(!0),localStorage.setItem(J,`1`)},[]),j=!o&&!d&&e.length===0&&!_;return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Paired devices`}),(0,L.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Link other MCPlexer devices with a 6-digit code. No ports, IPs, or peer IDs to manage.`})]}),j&&(0,L.jsx)(X,{onDismiss:A}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(R,{onComplete:()=>{x()}}),(0,L.jsx)(H,{onComplete:()=>{x()},initialPayload:b,autoOpen:!!b})]}),(0,L.jsxs)(k,{children:[(0,L.jsx)(O,{children:(0,L.jsx)(S,{className:`text-base`,children:`Trusted peers`})}),(0,L.jsxs)(E,{children:[o&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,L.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Loading peers...`]}),d&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-destructive`,children:[(0,L.jsx)(y,{className:`h-4 w-4`}),d]}),!o&&!d&&e.length===0&&(0,L.jsx)(`p`,{className:`py-6 text-sm text-muted-foreground`,children:`No paired devices yet. Tap "Pair this device" above to start.`}),!o&&(()=>{let t={};for(let n of e)!n.revoked_at&&n.display_name&&(t[n.display_name]=(t[n.display_name]??0)+1);return e.map(e=>(0,L.jsx)(Z,{peer:e,collides:(t[e.display_name]??0)>1,onRevoke:()=>T(e.peer_id)},e.peer_id))})()]})]}),(0,L.jsxs)(k,{children:[(0,L.jsx)(O,{children:(0,L.jsx)(S,{className:`text-base`,children:`Human identities`})}),(0,L.jsxs)(E,{children:[c&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-muted-foreground`,children:[(0,L.jsx)(D,{className:`h-4 w-4 animate-spin`}),`Loading identities...`]}),p&&(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-destructive`,children:[(0,L.jsx)(y,{className:`h-4 w-4`}),p]}),!c&&!p&&r.length===0&&(0,L.jsx)(`p`,{className:`py-6 text-sm text-muted-foreground`,children:`No human identities recorded yet. Pair another device to link an owner.`}),!c&&!p&&r.length>0&&(0,L.jsx)(`div`,{className:`divide-y divide-border/40`,children:r.map(e=>(0,L.jsxs)(`div`,{className:`py-3`,"data-testid":`user-row-${e.user_id}`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,L.jsx)(F,{className:`h-4 w-4 text-muted-foreground`}),(0,L.jsx)(`span`,{children:e.display_name||e.user_id}),e.is_self&&(0,L.jsx)(`span`,{className:`rounded border border-primary/30 bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:`this device`})]}),(0,L.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.peers.length===0?`No linked devices`:e.peers.map(e=>e.display_name||`peer-${Y(e.peer_id)}`).join(`, `)}),(0,L.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground/70`,children:e.user_id})]},e.user_id))})]})]})]})}export{Q as PairingPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/Pill-Dpb0OZxB.js b/internal/web/dist/assets/Pill-Dpb0OZxB.js deleted file mode 100644 index eab2587..0000000 --- a/internal/web/dist/assets/Pill-Dpb0OZxB.js +++ /dev/null @@ -1 +0,0 @@ -import{in as e,on as t}from"./client-CaIRceNv.js";var n=t();function r(e){return`onClick`in e&&typeof e.onClick==`function`}var i={muted:{static:`border-border bg-muted text-muted-foreground`,interactive:`border-border bg-muted/60 text-muted-foreground hover:border-primary/40 hover:bg-primary/10 hover:text-foreground`,active:`border-primary/40 bg-primary/15 text-foreground`},brand:{static:`border-primary/30 bg-primary/10 text-foreground`,interactive:`border-primary/30 bg-primary/10 text-foreground hover:border-primary/50 hover:bg-primary/15`,active:`border-primary/50 bg-primary/20 text-foreground`},local:{static:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`,interactive:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 hover:bg-emerald-500/15`,active:`border-emerald-500/50 bg-emerald-500/20 text-emerald-700 dark:text-emerald-200`},peer:{static:`border-border bg-muted text-muted-foreground`,interactive:`border-border bg-muted text-muted-foreground hover:border-primary/40 hover:bg-primary/10 hover:text-foreground`,active:`border-primary/40 bg-primary/15 text-foreground`},workspace:{static:`border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300`,interactive:`border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300 hover:border-sky-500/50 hover:bg-sky-500/15`,active:`border-sky-500/60 bg-sky-500/20 text-sky-800 dark:text-sky-200`}};function a(t){let a=t.icon,o=t.tone??`muted`,s=t.maxLabelCh??16,c=i[o],l=r(t),u=(0,n.jsxs)(n.Fragment,{children:[a?(0,n.jsx)(a,{className:`h-2.5 w-2.5 shrink-0`,"aria-hidden":!0}):null,(0,n.jsx)(`span`,{className:`truncate`,style:{maxWidth:`${s}ch`},children:t.label})]}),d=e(`inline-flex items-center gap-1 rounded-sm border px-1.5 py-px text-[11px] font-medium leading-4 transition-colors`);return l?(0,n.jsx)(`button`,{type:`button`,onClick:t.onClick,title:t.title,"aria-label":t.ariaLabel??t.title,"aria-pressed":t.active,"data-testid":t.testId,className:e(d,t.active?c.active:c.interactive,`cursor-pointer`),children:u}):(0,n.jsx)(`span`,{title:t.title,"data-testid":t.testId,className:e(d,t.active?c.active:c.static),children:u})}export{a as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/SandboxGuardPage-B5sBsAM3.js b/internal/web/dist/assets/SandboxGuardPage-B5sBsAM3.js deleted file mode 100644 index 5c27168..0000000 --- a/internal/web/dist/assets/SandboxGuardPage-B5sBsAM3.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{N as n,Z as r,en as i,k as a,on as o}from"./client-CaIRceNv.js";import{t as s}from"./box-C_5urXbw.js";import{Fn as c,Fr as l,Or as u,S as d,jr as f,n as p,nr as m,t as h,y as g}from"./index-BDLzoIgt.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./table-2N0Q-yAm.js";var C=e(t(),1),w=o();function T(){let{data:e,loading:t,error:o,refetch:T}=d((0,C.useCallback)(()=>r(),[])),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(!1);async function A(){if(e){k(!0);try{let t=!e.downstreams_enabled;await i(t),f.success(t?`Sandboxing downstream MCP servers`:`Sandbox disabled`),T()}catch(e){f.error(e instanceof Error?e.message:`Toggle failed`)}finally{k(!1)}}}async function j(e){D(e.id);try{e.enabled?(await a(e.id),f.success(`Sandbox disabled for ${e.name}`)):(await n(e.id),f.success(`Sandbox enabled for ${e.name}`)),T()}catch(e){f.error(e instanceof Error?e.message:`Toggle failed`)}finally{D(null)}}let M=e?.driver===`sandbox-exec`?`sandbox-exec (macOS)`:e?.driver===`bwrap`?`bwrap (Linux)`:e?.driver===`unshare`?`unshare (Linux fallback)`:e?.driver||`unavailable`;return(0,w.jsxs)(`div`,{className:`space-y-5 max-w-5xl`,children:[(0,w.jsxs)(l,{to:`/guards`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(u,{className:`h-3 w-3`}),`Guards`]}),(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,w.jsx)(s,{className:`h-6 w-6`}),` Sandbox Guard`]}),(0,w.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Runs AI clients inside an OS-level sandbox so shell commands they escape from MCPlexer can't damage the host. macOS uses sandbox-exec; Linux uses bubblewrap with an unshare fallback.`})]}),t&&!e?(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(m,{className:`h-4 w-4 animate-spin`}),` Loading sandbox status…`]}):o?(0,w.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:o}):e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{children:(0,w.jsxs)(p,{className:`flex items-center justify-between gap-4 p-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium`,children:`Sandbox driver`}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Auto-selected from what's available on this host.`}),e.driver===`sandbox-exec`&&(0,w.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:`Sandbox is currently macOS-only on this host.`})]}),e.unsupported_os?(0,w.jsx)(g,{variant:`outline`,className:`text-muted-foreground`,children:`unsupported OS`}):(0,w.jsx)(g,{variant:`secondary`,className:`font-mono text-[10px]`,children:M})]})}),(0,w.jsx)(h,{children:(0,w.jsxs)(p,{className:`p-4 space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium`,children:`Sandbox downstream MCP server processes`}),(0,w.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`Wraps every spawned MCP server in sandbox-exec so credential paths (`,(0,w.jsx)(`code`,{className:`font-mono text-[10px]`,children:`~/.ssh`}),`,`,` `,(0,w.jsx)(`code`,{className:`font-mono text-[10px]`,children:`~/.aws`}),`,`,` `,(0,w.jsx)(`code`,{className:`font-mono text-[10px]`,children:`~/.docker/config.json`}),`) are inaccessible. Some servers legitimately need filesystem access — start narrow.`]})]}),(0,w.jsxs)(c,{size:`sm`,variant:e.downstreams_enabled?`outline`:`default`,disabled:O||e.unsupported_os,onClick:A,"data-testid":`sandbox-downstreams-toggle`,children:[O&&(0,w.jsx)(m,{className:`mr-1.5 h-3 w-3 animate-spin`}),e.downstreams_enabled?`Disable`:`Enable`]})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:`Active:`}),(0,w.jsx)(`span`,{className:e.downstreams_enabled?`font-mono text-emerald-400`:`font-mono text-muted-foreground`,children:e.active_description})]})]})}),(0,w.jsxs)(`section`,{className:`space-y-2`,children:[(0,w.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-muted-foreground`,children:`Per-client tracking`}),(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground -mt-1`,children:`Records the per-client sandbox intent. Real wrapping is global (above); per-client enforcement lands when M2.5 ships shim binaries.`}),(0,w.jsx)(h,{children:(0,w.jsx)(p,{className:`p-0`,children:e.clients.length===0?(0,w.jsx)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,children:`No installed clients tracked yet. Wire one via the Shell Guard first.`}):(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{children:`Client`}),(0,w.jsx)(v,{children:`Sandbox`}),(0,w.jsx)(v,{className:`text-right`,children:`Action`})]})}),(0,w.jsx)(y,{children:e.clients.map(t=>(0,w.jsxs)(b,{children:[(0,w.jsxs)(x,{children:[(0,w.jsx)(`div`,{className:`font-medium`,children:t.name||t.id}),(0,w.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:t.id})]}),(0,w.jsx)(x,{children:t.enabled?(0,w.jsx)(g,{className:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30 text-[10px]`,children:`enabled`}):(0,w.jsx)(g,{variant:`outline`,className:`text-[10px] text-muted-foreground`,children:`disabled`})}),(0,w.jsx)(x,{className:`text-right`,children:(0,w.jsxs)(c,{size:`sm`,variant:t.enabled?`outline`:`default`,disabled:E===t.id||e.unsupported_os,onClick:()=>j(t),"data-testid":`sandbox-toggle-${t.id}`,children:[E===t.id&&(0,w.jsx)(m,{className:`mr-1.5 h-3 w-3 animate-spin`}),t.enabled?`Disable`:`Enable`]})})]},t.id))})]})})})]})]}):null]})}export{T as SandboxGuardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/SanitizerGuardPage-Dr_TIdvl.js b/internal/web/dist/assets/SanitizerGuardPage-Dr_TIdvl.js deleted file mode 100644 index 970f4b6..0000000 --- a/internal/web/dist/assets/SanitizerGuardPage-Dr_TIdvl.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Q as n,on as r,tn as i}from"./client-CaIRceNv.js";import{t as a}from"./funnel-BvqzDyhp.js";import{Fn as o,Fr as s,Or as c,S as l,jr as u,n as d,nr as f,t as p,y as m}from"./index-BDLzoIgt.js";var h=e(t(),1),g=r();function _(){let{data:e,loading:t,error:r,refetch:_}=l((0,h.useCallback)(()=>n(),[])),[v,y]=(0,h.useState)(!1);async function b(e){y(!0);try{await i(e),u.success(e?`Envelope-always enabled`:`Envelope-always disabled`),_()}catch(e){u.error(e instanceof Error?e.message:`Update failed`)}finally{y(!1)}}return(0,g.jsxs)(`div`,{className:`space-y-5 max-w-5xl`,children:[(0,g.jsxs)(s,{to:`/guards`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,g.jsx)(c,{className:`h-3 w-3`}),`Guards`]}),(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,g.jsx)(a,{className:`h-6 w-6`}),` Sanitizer Guard`]}),(0,g.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Scans tool results for prompt-injection markers (denylist) and wraps untrusted content in envelopes so downstream models treat it as data, not instructions.`})]}),t&&!e?(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,g.jsx)(f,{className:`h-4 w-4 animate-spin`}),` Loading sanitizer…`]}):r?(0,g.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:r}):e?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(p,{children:(0,g.jsxs)(d,{className:`flex items-center justify-between gap-4 p-4`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-sm font-medium`,children:`Always envelope`}),(0,g.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Wrap every tool result regardless of match. Strongest setting; costs a few extra tokens per call.`}),(0,g.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:`Persisted in settings — survives daemon restart; takes effect on the next tool result.`})]}),(0,g.jsxs)(o,{variant:e.envelope_always?`default`:`outline`,disabled:v,onClick:()=>b(!e.envelope_always),"data-testid":`sanitizer-envelope-toggle`,children:[v&&(0,g.jsx)(f,{className:`mr-2 h-3 w-3 animate-spin`}),e.envelope_always?`On`:`Off`]})]})}),(0,g.jsxs)(`section`,{className:`space-y-2`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-muted-foreground`,children:`Denylist rules`}),(0,g.jsx)(p,{children:(0,g.jsx)(d,{className:`p-4`,children:e.denylist.length===0?(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No rules loaded.`}):(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.denylist.map(e=>(0,g.jsx)(m,{variant:`secondary`,className:`font-mono text-[10px]`,children:e},e))})})})]}),(0,g.jsxs)(`section`,{className:`space-y-2`,children:[(0,g.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-muted-foreground`,children:`Recent injection events`}),(0,g.jsx)(p,{children:(0,g.jsx)(d,{className:`p-6 text-center text-sm text-muted-foreground`,children:e.recent_events.length===0?`No injection events recorded. New matches will appear here.`:`${e.recent_events.length} events`})})]})]}):null]})}export{_ as SanitizerGuardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ScheduleGuardPage-ED5ZN-wc.js b/internal/web/dist/assets/ScheduleGuardPage-ED5ZN-wc.js deleted file mode 100644 index 3089a86..0000000 --- a/internal/web/dist/assets/ScheduleGuardPage-ED5ZN-wc.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{$ as n,Vt as r,h as i,on as a,w as o}from"./client-CaIRceNv.js";import{t as s}from"./calendar-clock-Z37rBeGY.js";import{t as c}from"./play-YbzkBfB8.js";import{An as l,Bn as u,Fn as d,Fr as f,Ft as p,Mn as m,Nn as h,On as g,Or as _,Pn as v,Pt as y,Qn as b,S as x,jn as S,jr as C,kn as w,n as T,nr as E,t as D,y as O}from"./index-BDLzoIgt.js";import{a as k,i as A,n as j,o as M,r as N,t as P}from"./table-2N0Q-yAm.js";var F=e(t(),1),I=a();function L(){let{data:e,loading:t,error:i,refetch:a}=x((0,F.useCallback)(()=>n(),[])),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(!1);async function p(e){l(e);try{await r(e),C.success(`Job triggered`),a()}catch(e){C.error(e instanceof Error?e.message:`Run failed`)}finally{l(null)}}async function m(e){l(e);try{await o(e),C.success(`Job deleted`),a()}catch(e){C.error(e instanceof Error?e.message:`Delete failed`)}finally{l(null)}}return(0,I.jsxs)(`div`,{className:`space-y-5 max-w-5xl`,children:[(0,I.jsxs)(f,{to:`/guards`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,I.jsx)(_,{className:`h-3 w-3`}),`Guards`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,I.jsx)(s,{className:`h-6 w-6`}),` Schedule Guard`]}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Runs cron- and interval-triggered jobs through the same approval pipeline as agent calls. Jobs marked "survive daemon down" get promoted to launchd / systemd timers.`})]}),(0,I.jsx)(z,{open:u,onOpenChange:d,onCreated:a})]}),t&&!e?(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,I.jsx)(E,{className:`h-4 w-4 animate-spin`}),` Loading schedule…`]}):i?(0,I.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:i}):e?(0,I.jsx)(D,{children:(0,I.jsx)(T,{className:`p-0`,children:e.jobs.length===0?(0,I.jsxs)(`div`,{className:`p-6 text-center text-sm text-muted-foreground`,children:[`No scheduled jobs yet. Use "New job" above or invoke`,` `,(0,I.jsx)(`span`,{className:`font-mono`,children:`mcplexer__schedule_create`}),` from an agent.`]}):(0,I.jsxs)(P,{children:[(0,I.jsx)(k,{children:(0,I.jsxs)(M,{children:[(0,I.jsx)(A,{children:`Name`}),(0,I.jsx)(A,{children:`Kind`}),(0,I.jsx)(A,{children:`Spec`}),(0,I.jsx)(A,{children:`Next run`}),(0,I.jsx)(A,{children:`Last status`}),(0,I.jsx)(A,{className:`text-right`,children:`Actions`})]})}),(0,I.jsx)(j,{children:e.jobs.map(e=>(0,I.jsx)(R,{job:e,busy:c===e.id,onRun:()=>p(e.id),onDelete:()=>m(e.id)},e.id))})]})})}):null]})}function R({job:e,busy:t,onRun:n,onDelete:r}){return(0,I.jsxs)(M,{children:[(0,I.jsxs)(N,{children:[(0,I.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,I.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:e.id})]}),(0,I.jsx)(N,{children:(0,I.jsx)(O,{variant:`secondary`,className:`text-[10px]`,children:e.kind})}),(0,I.jsx)(N,{className:`font-mono text-xs`,children:e.spec}),(0,I.jsx)(N,{className:`text-xs text-muted-foreground`,children:e.next_run_at?new Date(e.next_run_at).toLocaleString():`—`}),(0,I.jsx)(N,{children:e.last_status?(0,I.jsx)(O,{className:e.last_status===`success`?`bg-emerald-500/10 text-emerald-400 border-emerald-500/30 text-[10px]`:e.last_status===`failure`?`bg-destructive/10 text-destructive border-destructive/30 text-[10px]`:`text-[10px]`,children:e.last_status}):(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`never`})}),(0,I.jsx)(N,{className:`text-right`,children:(0,I.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,I.jsx)(d,{size:`sm`,variant:`ghost`,disabled:t,onClick:n,"data-testid":`schedule-run-${e.id}`,title:`Run now`,children:t?(0,I.jsx)(E,{className:`h-3 w-3 animate-spin`}):(0,I.jsx)(c,{className:`h-3 w-3`})}),(0,I.jsx)(d,{size:`sm`,variant:`ghost`,disabled:t,onClick:r,"data-testid":`schedule-delete-${e.id}`,title:`Delete`,children:(0,I.jsx)(u,{className:`h-3 w-3`})})]})})]})}function z({open:e,onOpenChange:t,onCreated:n}){let[r,a]=(0,F.useState)(``),[o,s]=(0,F.useState)(`cron`),[c,u]=(0,F.useState)(``),[f,_]=(0,F.useState)(``),[x,T]=(0,F.useState)(!1);async function D(){if(!r.trim()||!o.trim()||!f.trim()){C.error(`Name, kind, and command are required`);return}T(!0);try{await i({name:r,kind:o,spec:c,command:f}),C.success(`Job created`),a(``),u(``),_(``),t(!1),n()}catch(e){C.error(e instanceof Error?e.message:`Create failed`)}finally{T(!1)}}return(0,I.jsxs)(g,{open:e,onOpenChange:t,children:[(0,I.jsx)(v,{asChild:!0,children:(0,I.jsxs)(d,{"data-testid":`schedule-new`,children:[(0,I.jsx)(b,{className:`mr-1.5 h-4 w-4`}),` New job`]})}),(0,I.jsxs)(w,{children:[(0,I.jsxs)(m,{children:[(0,I.jsx)(h,{children:`New scheduled job`}),(0,I.jsx)(l,{children:`Define a recurring task. Cron spec uses standard five-field syntax; interval uses a Go duration like "5m" or "1h30m".`})]}),(0,I.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(y,{htmlFor:`job-name`,children:`Name`}),(0,I.jsx)(p,{id:`job-name`,value:r,onChange:e=>a(e.target.value),placeholder:`nightly backup`,"data-testid":`schedule-new-name`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(y,{htmlFor:`job-kind`,children:`Kind`}),(0,I.jsx)(p,{id:`job-kind`,value:o,onChange:e=>s(e.target.value),placeholder:`cron | interval | file_watch | git_hook`,"data-testid":`schedule-new-kind`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(y,{htmlFor:`job-spec`,children:`Spec`}),(0,I.jsx)(p,{id:`job-spec`,value:c,onChange:e=>u(e.target.value),placeholder:`0 3 * * *`,"data-testid":`schedule-new-spec`})]}),(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(y,{htmlFor:`job-command`,children:`Command`}),(0,I.jsx)(p,{id:`job-command`,value:f,onChange:e=>_(e.target.value),placeholder:`/path/to/script.sh`,"data-testid":`schedule-new-command`})]})]}),(0,I.jsxs)(S,{children:[(0,I.jsx)(d,{variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,I.jsxs)(d,{onClick:D,disabled:x,"data-testid":`schedule-new-create`,children:[x&&(0,I.jsx)(E,{className:`mr-2 h-4 w-4 animate-spin`}),`Create`]})]})]})]})}export{L as ScheduleGuardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/SettingsPage-D8ep4DBs.js b/internal/web/dist/assets/SettingsPage-D8ep4DBs.js deleted file mode 100644 index cb4ae73..0000000 --- a/internal/web/dist/assets/SettingsPage-D8ep4DBs.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Ft as n,H as r,Rt as i,et as a,nn as o,on as s}from"./client-CaIRceNv.js";import{n as c,t as l}from"./toggle-group-CwLNIqWC.js";import{t as u}from"./pencil-Dy4EC74G.js";import{t as d}from"./refresh-ccw-Bixqs6dz.js";import{t as f}from"./save-Baaykonc.js";import{Fn as p,Fr as m,Ft as h,Pt as g,S as _,br as v,cr as y,d as b,dr as x,f as S,fr as C,i as w,jr as T,m as E,n as D,nr as O,p as k,r as A,t as j,u as M}from"./index-BDLzoIgt.js";var N=e(t(),1);function P(){return n(`/agent-rules/status`)}function F(){return n(`/agent-rules/sync`,{method:`POST`})}var I=s(),L=`mcplexer-settings-view`;function R(){let{data:e,loading:t}=_((0,N.useCallback)(()=>a(),[])),{data:n}=_((0,N.useCallback)(()=>r().catch(()=>null),[])),[s,v]=(0,N.useState)(null),[R,B]=(0,N.useState)(!1),[V,H]=(0,N.useState)(!1),[U,W]=(0,N.useState)(()=>localStorage.getItem(L)===`advanced`?`advanced`:`basic`),[G,K]=(0,N.useState)(null),[q,J]=(0,N.useState)(!1),Y=(0,N.useCallback)(async()=>{try{K(await P())}catch{K(null)}},[]);(0,N.useEffect)(()=>{Y()},[Y]);async function X(){J(!0);try{let e=await F();e.changed?T.success(`Agent rules synced to v${e.version}`):T.info(`Agent rules already at v${e.version}`),await Y()}catch(e){let t=e instanceof Error?e.message:`Sync failed`;T.error(t)}finally{J(!1)}}async function Z(e,t){try{await i(e)}catch(e){T.error(e instanceof Error?e.message:`Failed to open ${t}`)}}(0,N.useEffect)(()=>{e&&(v({...e.settings,slim_surface:e.settings.slim_surface??!0,code_mode_max_output_bytes:e.settings.code_mode_max_output_bytes??24*1024,mesh_receive_max_results:e.settings.mesh_receive_max_results??20,mesh_receive_preview_bytes:e.settings.mesh_receive_preview_bytes??512,mesh_send_max_content_bytes:e.settings.mesh_send_max_content_bytes??64*1024,tool_description_overrides:e.settings.tool_description_overrides??{},remote_skill_server_url:e.settings.remote_skill_server_url??``}),H(!1))},[e]);function Q(e){v(t=>t&&{...t,...e}),H(!0)}async function $(){if(s){B(!0);try{await o(s),H(!1),T.success(`Settings saved`)}catch(e){let t=e instanceof Error?e.message:`Failed to save`;T.error(t)}finally{B(!1)}}}return t||!s||!e?(0,I.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,I.jsx)(O,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Settings`}),(0,I.jsxs)(l,{type:`single`,value:U,onValueChange:e=>{e&&(W(e),localStorage.setItem(L,e))},variant:`outline`,size:`sm`,"data-testid":`settings-view-toggle`,children:[(0,I.jsx)(c,{value:`basic`,"data-testid":`settings-view-basic`,children:`Basic`}),(0,I.jsx)(c,{value:`advanced`,"data-testid":`settings-view-advanced`,children:`Advanced`})]})]}),(0,I.jsxs)(p,{onClick:$,disabled:R||!V,"data-testid":`settings-save`,children:[R?(0,I.jsx)(O,{className:`mr-2 h-4 w-4 animate-spin`}):(0,I.jsx)(f,{className:`mr-2 h-4 w-4`}),`Save`]})]}),(0,I.jsxs)(`div`,{className:`space-y-6`,children:[(0,I.jsxs)(`div`,{className:`space-y-6`,children:[n&&(0,I.jsxs)(j,{"data-testid":`daemon-card`,children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Daemon`})}),(0,I.jsxs)(D,{className:`space-y-3`,children:[(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Mode`}),(0,I.jsxs)(`span`,{className:`col-span-2 font-mono`,children:[n.mode,n.system?.p2p_enabled?` · p2p`:``]}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Version`}),(0,I.jsx)(`span`,{className:`col-span-2 font-mono`,children:n.version}),n.system?.http_addr&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`HTTP`}),(0,I.jsx)(`span`,{className:`col-span-2 font-mono`,children:n.system.http_addr})]}),n.system?.socket_path&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Socket`}),(0,I.jsx)(`span`,{className:`col-span-2 truncate font-mono`,children:n.system.socket_path})]}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Uptime`}),(0,I.jsxs)(`span`,{className:`col-span-2 font-mono`,children:[Math.floor(n.uptime_seconds/60),` min`]})]}),(0,I.jsxs)(`div`,{className:`border-t pt-3 space-y-2`,children:[n.system?.data_dir&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>Z(`data_dir`,`data dir`),"data-testid":`settings-reveal-data-dir`,className:`flex w-full items-center gap-2 rounded-md border border-border/50 px-3 py-2 text-left text-xs hover:bg-muted/50`,children:[(0,I.jsx)(x,{className:`h-4 w-4 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:`Data folder`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:n.system.data_dir})]})]}),n.system?.config_file&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>Z(`config_file`,`config file`),"data-testid":`settings-reveal-config-file`,className:`flex w-full items-center gap-2 rounded-md border border-border/50 px-3 py-2 text-left text-xs hover:bg-muted/50`,children:[(0,I.jsx)(C,{className:`h-4 w-4 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:`mcplexer.yaml`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:n.system.config_file})]})]}),n.system?.log_path&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>Z(`log_path`,`log file`),"data-testid":`settings-reveal-log`,className:`flex w-full items-center gap-2 rounded-md border border-border/50 px-3 py-2 text-left text-xs hover:bg-muted/50`,children:[(0,I.jsx)(C,{className:`h-4 w-4 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:`Log file`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:n.system.log_path})]})]}),n.system?.addons_dir&&(0,I.jsxs)(`button`,{type:`button`,onClick:()=>Z(`addons_dir`,`addons dir`),"data-testid":`settings-reveal-addons-dir`,className:`flex w-full items-center gap-2 rounded-md border border-border/50 px-3 py-2 text-left text-xs hover:bg-muted/50`,children:[(0,I.jsx)(x,{className:`h-4 w-4 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:`Addons folder`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-muted-foreground`,children:n.system.addons_dir})]})]})]})]})]}),G&&(0,I.jsxs)(j,{"data-testid":`agent-rules-card`,children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Agent rules`})}),(0,I.jsxs)(D,{className:`space-y-3`,children:[(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Marker-bounded mcplexer block in`,` `,(0,I.jsx)(`span`,{className:`font-mono`,children:G.path}),`. Tells every Claude / OpenCode session on this machine that mcplexer is wired up and which tool families it offers.`]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,I.jsx)(z,{status:G}),(0,I.jsxs)(p,{onClick:X,disabled:q||G.present&&G.up_to_date,variant:G.present?`outline`:`default`,size:`sm`,"data-testid":`agent-rules-sync`,children:[q?(0,I.jsx)(O,{className:`mr-2 h-4 w-4 animate-spin`}):(0,I.jsx)(d,{className:`mr-2 h-4 w-4`}),G.present?`Sync`:`Install`]})]})]})]}),(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`This Device`})}),(0,I.jsx)(D,{className:`space-y-4`,children:(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{htmlFor:`device-display-name`,children:`Display name`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Shown to paired devices and on cross-machine mesh messages (e.g. "dev-mbp"). Letters, numbers, and . _ - only. Renaming broadcasts the new name to paired peers.`}),(0,I.jsx)(h,{id:`device-display-name`,"data-testid":`settings-display-name`,value:s.display_name??``,maxLength:50,onChange:e=>Q({display_name:e.target.value}),className:`max-w-sm`,placeholder:`dev-mbp`})]})})]}),U===`advanced`&&(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Skills Hub`})}),(0,I.jsx)(D,{className:`space-y-4`,children:(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{htmlFor:`remote-skill-server`,children:`Remote skills server`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`DNS name or URL for the shared registry. Used only when you choose a remote skill action.`}),(0,I.jsxs)(`div`,{className:`flex max-w-xl items-center gap-2`,children:[(0,I.jsx)(y,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,I.jsx)(h,{id:`remote-skill-server`,"data-testid":`settings-remote-skill-server`,value:s.remote_skill_server_url??``,onChange:e=>Q({remote_skill_server_url:e.target.value}),placeholder:`shared-skills`})]})]})})]}),U===`advanced`&&(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Tool Display`})}),(0,I.jsxs)(D,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(g,{children:`Slim advertised tool surface`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Keeps tools/list to discovery and batching entrypoints; use search_tools to find the rest.`})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s.slim_surface,"aria-label":`Slim advertised tool surface`,"data-testid":`settings-toggle-slim-surface`,onClick:()=>Q({slim_surface:!s.slim_surface}),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${s.slim_surface?`bg-primary`:`bg-muted`}`,children:(0,I.jsx)(`span`,{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${s.slim_surface?`translate-x-5`:`translate-x-0`}`})})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t pt-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(g,{children:`Minify tool schemas (slim tools)`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Strips property descriptions from schemas to save context window`})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s.slim_tools,"aria-label":`Minify tool schemas`,"data-testid":`settings-toggle-slim-tools`,onClick:()=>Q({slim_tools:!s.slim_tools}),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${s.slim_tools?`bg-primary`:`bg-muted`}`,children:(0,I.jsx)(`span`,{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${s.slim_tools?`translate-x-5`:`translate-x-0`}`})})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t pt-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(g,{children:`Compact tool responses`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Compresses verbose JSON tool responses into a token-efficient format. Prunes empty fields and converts arrays to columnar layout.`})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s.compact_responses,"aria-label":`Compact tool responses`,"data-testid":`settings-toggle-compact-responses`,onClick:()=>Q({compact_responses:!s.compact_responses}),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${s.compact_responses?`bg-primary`:`bg-muted`}`,children:(0,I.jsx)(`span`,{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${s.compact_responses?`translate-x-5`:`translate-x-0`}`})})]})]})]}),U===`advanced`&&(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Code Execution`})}),(0,I.jsxs)(D,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{children:`Execution timeout (seconds)`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Maximum time a code execution can run before being killed (1-120)`}),(0,I.jsx)(h,{type:`number`,min:1,max:120,value:s.code_mode_timeout_sec,onChange:e=>Q({code_mode_timeout_sec:parseInt(e.target.value,10)||30}),className:`w-32`})]}),(0,I.jsxs)(`div`,{className:`space-y-2 border-t pt-4`,children:[(0,I.jsx)(g,{children:`Captured output cap (bytes)`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Maximum print/console output returned by code mode (1024-262144).`}),(0,I.jsx)(h,{type:`number`,min:1024,max:262144,step:1024,value:s.code_mode_max_output_bytes,onChange:e=>Q({code_mode_max_output_bytes:parseInt(e.target.value,10)||24*1024}),className:`w-40`})]})]})]}),(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Inter-Agent Communication`})}),(0,I.jsxs)(D,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(g,{children:`Agent Mesh`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable inter-agent messaging. When enabled, agents can send and receive messages to coordinate work across sessions. Requires restart.`})]}),(0,I.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s.mesh_enabled,"aria-label":`Agent Mesh enabled`,"data-testid":`settings-toggle-mesh-enabled`,onClick:()=>Q({mesh_enabled:!s.mesh_enabled}),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${s.mesh_enabled?`bg-primary`:`bg-muted`}`,children:(0,I.jsx)(`span`,{className:`pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform ${s.mesh_enabled?`translate-x-5`:`translate-x-0`}`})})]}),U===`advanced`&&(0,I.jsxs)(`div`,{className:`grid gap-4 border-t pt-4 sm:grid-cols-3`,children:[(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{children:`Receive results`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Default and maximum messages returned (1-50).`}),(0,I.jsx)(h,{type:`number`,min:1,max:50,value:s.mesh_receive_max_results,onChange:e=>Q({mesh_receive_max_results:parseInt(e.target.value,10)||20}),className:`w-28`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{children:`Preview bytes`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Per-message receive preview cap (64-2048).`}),(0,I.jsx)(h,{type:`number`,min:64,max:2048,step:64,value:s.mesh_receive_preview_bytes,onChange:e=>Q({mesh_receive_preview_bytes:parseInt(e.target.value,10)||512}),className:`w-32`})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{children:`Send bytes`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Maximum mesh message body size (1024-65536).`}),(0,I.jsx)(h,{type:`number`,min:1024,max:65536,step:1024,value:s.mesh_send_max_content_bytes,onChange:e=>Q({mesh_send_max_content_bytes:parseInt(e.target.value,10)||64*1024}),className:`w-36`})]})]})]})]}),U===`advanced`&&(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Caching`})}),(0,I.jsx)(D,{className:`space-y-4`,children:(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{children:`Tools list cache TTL (seconds)`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`How often tools/list re-queries downstream servers (0-300)`}),(0,I.jsx)(h,{type:`number`,min:0,max:300,value:s.tools_cache_ttl_sec,onChange:e=>Q({tools_cache_ttl_sec:parseInt(e.target.value,10)||0}),className:`w-32`})]})})]}),(0,I.jsxs)(j,{children:[(0,I.jsx)(A,{children:(0,I.jsx)(w,{className:`text-sm font-medium uppercase tracking-wider text-muted-foreground`,children:`Logging`})}),(0,I.jsx)(D,{className:`space-y-4`,children:(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsx)(g,{children:`Log level`}),(0,I.jsxs)(M,{value:s.log_level,onValueChange:e=>Q({log_level:e}),children:[(0,I.jsx)(k,{className:`w-40`,children:(0,I.jsx)(E,{})}),(0,I.jsxs)(b,{children:[(0,I.jsx)(S,{value:`debug`,children:`debug`}),(0,I.jsx)(S,{value:`info`,children:`info`}),(0,I.jsx)(S,{value:`warn`,children:`warn`}),(0,I.jsx)(S,{value:`error`,children:`error`})]})]})]})})]})]}),U===`advanced`&&(0,I.jsxs)(m,{to:`/descriptions`,"data-testid":`settings-link-descriptions`,className:`group flex items-center gap-3 rounded-md border border-border/50 px-4 py-3 text-sm transition-colors hover:border-primary/40 hover:bg-card/80`,children:[(0,I.jsx)(u,{className:`h-4 w-4 text-muted-foreground group-hover:text-primary`}),(0,I.jsxs)(`div`,{className:`flex-1`,children:[(0,I.jsx)(`div`,{className:`font-medium`,children:`Built-in tool description overrides`}),(0,I.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Moved to Tool Descriptions →`})]})]})]})]})}function z({status:e}){return e.present?e.up_to_date?(0,I.jsxs)(`span`,{"data-testid":`agent-rules-state`,className:`inline-flex items-center gap-1.5 rounded-full bg-emerald-500/10 px-2.5 py-1 text-xs font-medium text-emerald-600 dark:text-emerald-400`,children:[(0,I.jsx)(v,{className:`h-3.5 w-3.5`}),`Synced (v`,e.current_version,`)`]}):(0,I.jsxs)(`span`,{"data-testid":`agent-rules-state`,className:`inline-flex items-center gap-1.5 rounded-full bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-400`,children:[`Out of date — installed v`,e.current_version,`, latest v`,e.latest_version]}):(0,I.jsxs)(`span`,{"data-testid":`agent-rules-state`,className:`inline-flex items-center gap-1.5 rounded-full bg-amber-500/10 px-2.5 py-1 text-xs font-medium text-amber-600 dark:text-amber-400`,children:[`Not installed (latest v`,e.latest_version,`)`]})}export{R as SettingsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/ShellGuardPage-MUqtxJ3c.js b/internal/web/dist/assets/ShellGuardPage-MUqtxJ3c.js deleted file mode 100644 index 9f6115a..0000000 --- a/internal/web/dist/assets/ShellGuardPage-MUqtxJ3c.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Yt as n,c as r,dt as i,lt as a,on as o,tt as s,v as c}from"./client-CaIRceNv.js";import{Bn as l,Fn as u,Fr as d,Ft as f,Or as p,S as m,Vn as h,jr as g,n as _,nr as v,t as y,y as b,zn as x}from"./index-BDLzoIgt.js";import{a as S,i as C,n as w,o as T,r as E,t as D}from"./table-2N0Q-yAm.js";var O=e(t(),1),k=o(),A=new Set([`claude_code`]);function j(e){return e.some(e=>e.hooks_installed&&e.hooks_drifted)}function M(){let{data:e,loading:t,error:r,refetch:i}=m((0,O.useCallback)(()=>s(),[])),[o,c]=(0,O.useState)(null);async function l(e){c(e);try{let t=await a(e);g.success(t.installed?`Hooks installed`:`Already installed`),i()}catch(e){g.error(e instanceof Error?e.message:`Install failed`)}finally{c(null)}}async function u(e){c(e);try{await n(e),g.success(`Hooks removed`),i()}catch(e){g.error(e instanceof Error?e.message:`Uninstall failed`)}finally{c(null)}}return(0,k.jsxs)(`div`,{className:`space-y-5 max-w-5xl`,children:[(0,k.jsxs)(d,{to:`/guards`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,k.jsx)(p,{className:`h-3 w-3`}),`Guards`]}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,k.jsx)(h,{className:`h-6 w-6`}),` Shell Guard`]}),(0,k.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Intercepts shell commands AI clients try to run, validates them, and gates them behind a human-in-the-loop approval. Today this covers Claude Code's PreToolUse Bash hook; other clients land in M1-F+.`})]}),t&&!e?(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,k.jsx)(v,{className:`h-4 w-4 animate-spin`}),` Loading shell guard…`]}):r?(0,k.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:r}):e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(y,{children:(0,k.jsxs)(_,{className:`flex items-center justify-between gap-4 p-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-sm font-medium`,children:`Cooperative mode`}),(0,k.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:j(e.clients)?`Hook drifted — settings.json no longer references mcplexer. Re-install below to repair.`:`Install the curl hook into client config so commands route through MCPlexer.`})]}),(0,k.jsx)(b,{className:j(e.clients)?`bg-rose-500/10 text-rose-400 border-rose-500/30`:e.hooks_enabled?`bg-emerald-500/10 text-emerald-400 border-emerald-500/30`:`bg-muted text-muted-foreground`,"data-testid":`shell-mode-badge`,children:j(e.clients)?`drifted`:e.hooks_enabled?`active`:`inactive`})]})}),(0,k.jsxs)(`section`,{className:`space-y-2`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-muted-foreground`,children:`Clients`}),(0,k.jsx)(y,{children:(0,k.jsx)(_,{className:`p-0`,children:(0,k.jsxs)(D,{children:[(0,k.jsx)(S,{children:(0,k.jsxs)(T,{children:[(0,k.jsx)(C,{children:`Client`}),(0,k.jsx)(C,{children:`Detected`}),(0,k.jsx)(C,{children:`Hook`}),(0,k.jsx)(C,{className:`text-right`,children:`Action`})]})}),(0,k.jsxs)(w,{children:[e.clients.map(e=>(0,k.jsx)(F,{client:e,busy:o===e.id,onInstall:()=>l(e.id),onUninstall:()=>u(e.id)},e.id)),e.clients.length===0&&(0,k.jsx)(T,{children:(0,k.jsx)(E,{colSpan:4,className:`text-center text-sm text-muted-foreground`,children:`No MCP clients detected on this machine.`})})]})]})})})]}),(0,k.jsx)(P,{}),(0,k.jsxs)(`section`,{className:`space-y-2`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-muted-foreground`,children:`Recent shell approvals`}),e.recent_approvals.length===0?(0,k.jsx)(y,{children:(0,k.jsx)(_,{className:`p-6 text-center text-sm text-muted-foreground`,children:`No pending shell approvals. New requests will appear here.`})}):(0,k.jsx)(y,{children:(0,k.jsx)(_,{className:`p-0`,children:(0,k.jsxs)(D,{children:[(0,k.jsx)(S,{children:(0,k.jsxs)(T,{children:[(0,k.jsx)(C,{children:`Tool`}),(0,k.jsx)(C,{children:`Session`}),(0,k.jsx)(C,{children:`Status`}),(0,k.jsx)(C,{children:`Created`})]})}),(0,k.jsx)(w,{children:e.recent_approvals.map(e=>(0,k.jsxs)(T,{children:[(0,k.jsx)(E,{className:`font-mono text-xs`,children:e.tool_name}),(0,k.jsx)(E,{className:`font-mono text-xs`,children:e.request_session_id||`—`}),(0,k.jsx)(E,{children:(0,k.jsx)(b,{variant:`secondary`,className:`text-[10px]`,children:e.status})}),(0,k.jsx)(E,{className:`text-xs text-muted-foreground`,children:new Date(e.created_at).toLocaleTimeString()})]},e.id))})]})})})]})]}):null]})}function N(e){return e.surface===`shell`&&e.pattern===`*`&&e.decision===`allow`}function P(){let[e,t]=(0,O.useState)([]),[n,a]=(0,O.useState)(!0),[o,s]=(0,O.useState)(``),[d,p]=(0,O.useState)(``),[m,h]=(0,O.useState)(`allow`),[A,j]=(0,O.useState)(100),[M,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(!1),z=(0,O.useCallback)(async()=>{a(!0);try{t((await i(`shell`)).rules??[])}catch(e){g.error(e instanceof Error?e.message:`Failed to load rules`)}finally{a(!1)}},[]);(0,O.useEffect)(()=>{z()},[z]);async function B(e){if(e.preventDefault(),!o.trim()){g.error(`Pattern required (e.g. shell:git or shell:*)`);return}P(!0);try{await r({surface:`shell`,pattern:o.trim(),directory:d.trim(),ai_session_id:``,decision:m,priority:A,created_by:`dashboard`,allow_metachars:m===`allow`?L:!1}),s(``),p(``),R(!1),g.success(`Rule added — ${m} ${o.trim()}`),z()}catch(e){g.error(e instanceof Error?e.message:`Create failed`)}finally{P(!1)}}async function V(e){try{await c(e),g.success(`Rule removed`),z()}catch(e){g.error(e instanceof Error?e.message:`Delete failed`)}}async function H(){I(!0);try{await r({surface:`shell`,pattern:`*`,directory:``,ai_session_id:``,decision:`allow`,priority:999,created_by:`ui-allow-all`,allow_metachars:!0}),g.success(`Allow-all rule installed — every shell command now auto-approves and audits.`),z()}catch(e){g.error(e instanceof Error?e.message:`Failed to install allow-all rule`)}finally{I(!1)}}let U=e.find(N);return(0,k.jsxs)(`section`,{className:`space-y-2`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-muted-foreground`,children:`Auto-approve rules`}),(0,k.jsx)(y,{children:(0,k.jsxs)(_,{className:`space-y-4 p-4`,children:[(0,k.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Tool-name patterns whose approvals are auto-decided after a 5s grace period. Use `,(0,k.jsx)(`code`,{className:`font-mono`,children:`shell:git`}),` to match git commands, `,(0,k.jsx)(`code`,{className:`font-mono`,children:`shell:*`}),` for anything. Restrict to one project by setting Directory.`]}),U&&(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-amber-500/40 bg-amber-500/[0.06] px-3 py-2`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-400`,children:[(0,k.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),(0,k.jsxs)(`span`,{children:[(0,k.jsx)(`span`,{className:`font-semibold`,children:`Wildcard active`}),` — every shell command is auto-approved and audited (rule ID:`,` `,(0,k.jsx)(`span`,{className:`font-mono`,children:U.id}),U.allow_metachars?(0,k.jsxs)(k.Fragment,{children:[`; `,(0,k.jsx)(`span`,{className:`font-mono`,children:`allow_metachars=on`}),` so multi-step commands (`,(0,k.jsx)(`code`,{className:`font-mono`,children:`|`}),`, `,(0,k.jsx)(`code`,{className:`font-mono`,children:`;`}),`, `,(0,k.jsx)(`code`,{className:`font-mono`,children:`&`}),`) flow through`]}):(0,k.jsxs)(k.Fragment,{children:[`; `,(0,k.jsx)(`span`,{className:`font-mono`,children:`allow_metachars=off`}),` — pipes / semicolons / ampersands are still cheap-blocked. Re-install via the button below or PATCH the rule to turn this on`]}),`). Audit rows show `,(0,k.jsxs)(`span`,{className:`font-mono`,children:[`approver_session_id = rule:`,U.id]}),`.`]})]}),(0,k.jsx)(u,{variant:`outline`,size:`sm`,className:`shrink-0 border-amber-500/40 text-amber-400 hover:bg-amber-500/10 hover:text-amber-300`,onClick:()=>V(U.id),"data-testid":`allow-all-remove`,children:`Remove`})]}),!U&&!n&&(0,k.jsxs)(u,{variant:`outline`,size:`sm`,disabled:F,onClick:H,className:`border-amber-500/40 bg-amber-500/[0.06] text-amber-400 hover:bg-amber-500/10 hover:text-amber-300`,"data-testid":`allow-all-install`,children:[F?(0,k.jsx)(v,{className:`mr-1.5 h-3 w-3 animate-spin`}):(0,k.jsx)(x,{className:`mr-1.5 h-3 w-3`}),`Allow + audit everything (skip approval prompts)`]}),(0,k.jsxs)(`form`,{onSubmit:B,className:`space-y-2`,children:[(0,k.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[1fr_1fr_120px_80px_auto]`,children:[(0,k.jsx)(f,{placeholder:`Pattern (shell:ls)`,value:o,onChange:e=>s(e.target.value),"data-testid":`rule-pattern`}),(0,k.jsx)(f,{placeholder:`Directory (optional)`,value:d,onChange:e=>p(e.target.value)}),(0,k.jsxs)(`select`,{className:`h-9 rounded-md border border-input bg-background px-2 text-sm`,value:m,onChange:e=>h(e.target.value),"data-testid":`rule-decision`,children:[(0,k.jsx)(`option`,{value:`allow`,children:`allow`}),(0,k.jsx)(`option`,{value:`deny`,children:`deny`})]}),(0,k.jsx)(f,{type:`number`,value:A,onChange:e=>j(Number(e.target.value)||100),title:`Priority — lower wins`}),(0,k.jsxs)(u,{type:`submit`,size:`sm`,disabled:M,"data-testid":`rule-add`,children:[M&&(0,k.jsx)(v,{className:`mr-1.5 h-3 w-3 animate-spin`}),`+ Rule`]})]}),m===`allow`&&(0,k.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:L,onChange:e=>R(e.target.checked),className:`h-3.5 w-3.5 rounded border-input`,"data-testid":`rule-allow-metachars`}),(0,k.jsxs)(`span`,{children:[`Allow shell metacharacters (`,(0,k.jsx)(`code`,{className:`font-mono`,children:`;|&`}),` backtick, newlines) — needed for multi-step commands like `,(0,k.jsx)(`code`,{className:`font-mono`,children:`ssh host 'a | b'`}),` or`,(0,k.jsx)(`code`,{className:`font-mono`,children:` cmd 2>&1`}),`. Off by default; opt in per rule.`]})]})]}),n?(0,k.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,k.jsx)(v,{className:`h-3 w-3 animate-spin`}),` Loading rules…`]}):e.length===0?(0,k.jsx)(`div`,{className:`rounded-md border border-dashed border-border/60 p-4 text-center text-xs text-muted-foreground`,children:`No rules — every shell command will wait for human approval.`}):(0,k.jsxs)(D,{children:[(0,k.jsx)(S,{children:(0,k.jsxs)(T,{children:[(0,k.jsx)(C,{children:`Pattern`}),(0,k.jsx)(C,{children:`Directory`}),(0,k.jsx)(C,{children:`Decision`}),(0,k.jsx)(C,{className:`text-right`,children:`Priority`}),(0,k.jsx)(C,{className:`text-right`,children:`Hits`}),(0,k.jsx)(C,{className:`text-right`,children:`—`})]})}),(0,k.jsx)(w,{children:e.map(e=>(0,k.jsxs)(T,{"data-testid":`rule-row-${e.id}`,children:[(0,k.jsx)(E,{className:`font-mono text-xs`,children:e.pattern||`*`}),(0,k.jsx)(E,{className:`font-mono text-xs`,children:e.directory||(0,k.jsx)(`span`,{className:`text-muted-foreground`,children:`any`})}),(0,k.jsx)(E,{children:(0,k.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(b,{className:e.decision===`allow`?`bg-emerald-500/10 text-emerald-400 border-emerald-500/30 text-[10px]`:e.decision===`deny`?`bg-rose-500/10 text-rose-400 border-rose-500/30 text-[10px]`:`text-[10px]`,children:e.decision}),e.allow_metachars&&(0,k.jsx)(b,{title:"This rule bypasses the metachar cheap-block: `;|&` backtick newlines flow through to approval",className:`bg-amber-500/10 text-amber-400 border-amber-500/30 text-[10px] font-mono`,children:`metachars`})]})}),(0,k.jsx)(E,{className:`text-right text-xs`,children:e.priority}),(0,k.jsx)(E,{className:`text-right text-xs text-muted-foreground`,children:e.hit_count}),(0,k.jsx)(E,{className:`text-right`,children:(0,k.jsx)(u,{variant:`ghost`,size:`sm`,onClick:()=>V(e.id),"data-testid":`rule-delete-${e.id}`,children:(0,k.jsx)(l,{className:`h-3 w-3`})})})]},e.id))})]})]})})]})}function F({client:e,busy:t,onInstall:n,onUninstall:r}){let i=A.has(e.id),a=!!(e.hooks_installed&&e.hooks_drifted);return(0,k.jsxs)(T,{"data-testid":`shell-client-${e.id}`,children:[(0,k.jsxs)(E,{children:[(0,k.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,k.jsx)(`div`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:e.id})]}),(0,k.jsx)(E,{children:e.detected?(0,k.jsx)(b,{variant:`secondary`,className:`text-[10px]`,children:`detected`}):(0,k.jsx)(b,{variant:`outline`,className:`text-[10px] text-muted-foreground`,children:`not found`})}),(0,k.jsx)(E,{children:a?(0,k.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,k.jsxs)(b,{className:`bg-rose-500/10 text-rose-400 border-rose-500/30 text-[10px] w-fit`,"data-testid":`shell-drift-${e.id}`,title:e.hooks_drift_error?`Drift detected: ${e.hooks_drift_error}`:`Drift detected — settings.json no longer references mcplexer`,children:[(0,k.jsx)(x,{className:`mr-1 h-3 w-3`}),`drifted`]}),(0,k.jsx)(`span`,{className:`text-[10px] text-rose-400/80`,children:e.hooks_drift_error?`parse error: ${e.hooks_drift_error}`:`re-install to repair`})]}):e.hooks_installed?(0,k.jsx)(b,{className:`bg-emerald-500/10 text-emerald-400 border-emerald-500/30 text-[10px]`,children:`installed`}):(0,k.jsx)(b,{variant:`outline`,className:`text-[10px] text-muted-foreground`,children:`pending`})}),(0,k.jsx)(E,{className:`text-right`,children:i?a?(0,k.jsxs)(u,{size:`sm`,variant:`outline`,className:`border-rose-500/40 text-rose-400 hover:bg-rose-500/10 hover:text-rose-300`,disabled:t,onClick:n,"data-testid":`shell-repair-${e.id}`,children:[t&&(0,k.jsx)(v,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Re-install`]}):e.hooks_installed?(0,k.jsxs)(u,{variant:`outline`,size:`sm`,disabled:t,onClick:r,"data-testid":`shell-uninstall-${e.id}`,children:[t&&(0,k.jsx)(v,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Uninstall`]}):(0,k.jsxs)(u,{size:`sm`,disabled:t||!e.detected,onClick:n,"data-testid":`shell-install-${e.id}`,children:[t&&(0,k.jsx)(v,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Install`]}):(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`soon`})})]})}export{M as ShellGuardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/SignalsPage-9RMRNAIt.js b/internal/web/dist/assets/SignalsPage-9RMRNAIt.js deleted file mode 100644 index e7c48b8..0000000 --- a/internal/web/dist/assets/SignalsPage-9RMRNAIt.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{A as r,Br as i,Lt as a,O as o,k as s}from"./index-BDLzoIgt.js";var c=e(t(),1),l=n(),u=[`all`,`mesh`,`approval`,`system`,`secret`,`task`,`worker`];function d(){let[e,t]=i(),{events:n,filteredEvents:s,counts:d,filter:m,setFilter:h,unreadCount:g,loaded:_,markRead:v,markAllRead:y,openLink:b}=a();(0,c.useEffect)(()=>{let t=e.get(`filter`);t&&u.includes(t)&&t!==m&&h(t)},[e,m,h]);function x(n){h(n);let r=new URLSearchParams(e);n===`all`?r.delete(`filter`):r.set(`filter`,n),t(r,{replace:!0})}let S=e.get(`unread`)!==`false`,C=S?s.filter(e=>!e.read_at):s,w=(0,c.useRef)(null),T=(0,c.useRef)(-1);(0,c.useEffect)(()=>{function e(e){if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)){if(e.key===`j`||e.key===`ArrowDown`)e.preventDefault(),T.current=Math.min(C.length-1,T.current+1),p(w.current,T.current);else if(e.key===`k`||e.key===`ArrowUp`)e.preventDefault(),T.current=Math.max(0,T.current-1),p(w.current,T.current);else if(e.key===`Enter`){let t=C[T.current];if(!t)return;e.preventDefault(),t.read_at||v(t.id),b(t.link)}else if(e.key===`r`){let t=C[T.current];if(!t)return;e.preventDefault(),t.read_at||v(t.id)}else if(e.key===`R`)e.preventDefault(),y();else if(e.key>=`1`&&e.key<=`5`){e.preventDefault();let t=parseInt(e.key,10)-1;t>=0&&twindow.removeEventListener(`keydown`,e)},[C,v,y,b]),(0,c.useEffect)(()=>{T.current=-1},[m,S]);function E(){let n=new URLSearchParams(e);S?n.set(`unread`,`false`):n.delete(`unread`),t(n,{replace:!0})}return(0,l.jsxs)(`div`,{className:`space-y-4 font-mono`,children:[(0,l.jsxs)(`header`,{className:`flex items-end justify-between gap-6`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Notifications`}),(0,l.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:`Events from your agents, tools, and peers.`})]}),(0,l.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,l.jsx)(`button`,{type:`button`,onClick:E,"data-testid":`signals-toggle-unread`,className:`border px-2.5 py-1 font-mono text-[11px] uppercase tracking-wider transition-colors ${S?`border-primary/60 bg-primary/5 text-foreground`:`border-border text-muted-foreground hover:text-foreground`}`,children:S?`unread only ✓`:`unread only`}),g>0&&(0,l.jsx)(`button`,{type:`button`,onClick:()=>void y(),"data-testid":`signals-mark-all-read`,className:`border border-border px-2.5 py-1 font-mono text-[11px] uppercase tracking-wider text-muted-foreground transition-colors hover:text-foreground`,children:`mark all read`})]})]}),(0,l.jsx)(r,{filter:m,counts:d,onChange:x}),(0,l.jsx)(`div`,{className:`border border-border bg-card/30`,children:_?C.length===0?S&&s.length>0?(0,l.jsxs)(`div`,{className:`px-4 py-10 text-center font-mono text-[12px] text-muted-foreground`,children:[`Nothing unread under`,` `,(0,l.jsx)(`code`,{className:`text-foreground/80`,children:m}),`. Toggle "unread only" off to see read events.`]}):(0,l.jsx)(o,{filter:m}):(0,l.jsx)(`div`,{ref:w,children:f(C,{onMarkRead:e=>void v(e),onOpen:e=>{e.read_at||v(e.id),b(e.link)}})}):(0,l.jsx)(`div`,{className:`px-4 py-10 text-center font-mono text-[12px] text-muted-foreground/70`,children:(0,l.jsx)(`span`,{className:`animate-pulse`,children:`loading signal…`})})}),(0,l.jsxs)(`p`,{className:`text-[10.5px] text-muted-foreground/60`,children:[`Shown: `,(0,l.jsx)(`span`,{className:`tabular-nums text-foreground/80`,children:C.length}),` of`,` `,(0,l.jsx)(`span`,{className:`tabular-nums text-foreground/80`,children:n.length}),` · keyboard:`,` `,(0,l.jsx)(`code`,{className:`text-foreground/70`,children:`j k`}),` nav,`,` `,(0,l.jsx)(`code`,{className:`text-foreground/70`,children:`↵`}),` open,`,` `,(0,l.jsx)(`code`,{className:`text-foreground/70`,children:`r`}),` mark read,`,` `,(0,l.jsx)(`code`,{className:`text-foreground/70`,children:`R`}),` mark all,`,` `,(0,l.jsx)(`code`,{className:`text-foreground/70`,children:`1–5`}),` filter.`]})]})}function f(e,t){let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r.getTime()-24*3600*1e3),a=[{label:`Today`,rows:[]},{label:`Yesterday`,rows:[]},{label:`Earlier`,rows:[]}];for(let t of e){let e=new Date(t.created_at).getTime();e>=r.getTime()?a[0].rows.push(t):e>=i.getTime()?a[1].rows.push(t):a[2].rows.push(t)}let o=0;return a.filter(e=>e.rows.length>0).map(e=>(0,l.jsxs)(`section`,{className:`border-b border-border/40 last:border-0`,children:[(0,l.jsx)(`div`,{className:`px-3 pb-1.5 pt-3 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/60`,children:e.label}),e.rows.map(e=>(0,l.jsx)(s,{evt:e,dataIndex:o++,onMarkRead:t.onMarkRead,onOpen:t.onOpen},`${e.message_id}-${e.id}`))]},e.label))}function p(e,t){if(!e)return;let n=e.querySelector(`[data-signal-index="${t}"]`);n&&(n.focus(),n.scrollIntoView({block:`nearest`}))}export{d as SignalsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/SkillCompositionGraph-CVzFdDCZ.js b/internal/web/dist/assets/SkillCompositionGraph-CVzFdDCZ.js deleted file mode 100644 index a196e66..0000000 --- a/internal/web/dist/assets/SkillCompositionGraph-CVzFdDCZ.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Ft as n,on as r}from"./client-CaIRceNv.js";import{t as i}from"./network-CrANvqlb.js";import{t as a}from"./refresh-ccw-Bixqs6dz.js";import{Fn as o,Fr as s,Hn as c,S as l,n as u,nr as d,t as f}from"./index-BDLzoIgt.js";import{t as p}from"./empty-state-B9mtYx_X.js";var m=e(t(),1);function h(e){return n(`/skills/graph${e?`?window_days=${e}`:``}`)}var g=280,_=.992,v=110,y=.08,b=-260,x=.018,S=.84;function C(e){let{nodes:t,edges:n,width:r,height:i}=e,[a,o]=(0,m.useState)({}),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)({x:0,y:0,k:1}),d=(0,m.useRef)({}),f=(0,m.useRef)({}),p=(0,m.useRef)(new Set),h=(0,m.useRef)(null),C=(0,m.useRef)(null),w=(0,m.useRef)(1),T=(0,m.useRef)(0),E=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e={},n={};t.forEach((t,a)=>{let o=d.current[t.name];if(o){e[t.name]=o,n[t.name]=f.current[t.name]??{vx:0,vy:0};return}let s=a*.55,c=30+Math.sqrt(a)*12;e[t.name]={x:r/2+Math.cos(s)*c,y:i/2+Math.sin(s)*c},n[t.name]={vx:0,vy:0}}),d.current=e,f.current=n,w.current=1,T.current=0,o(e)},[t,r,i]),(0,m.useEffect)(()=>{if(t.length===0)return;let e=t.length>1500,a=()=>{let t=w.current,s=d.current,c=f.current,l=p.current,u=r/2,m=i/2;for(let e in s){if(l.has(e))continue;let n=s[e],r=c[e];r.vx+=(u-n.x)*x*t,r.vy+=(m-n.y)*x*t}if(!e){let e=Object.keys(s);for(let n=0;ng&&(w.current*=_),o({...s}),w.current>.01||h.current?E.current=requestAnimationFrame(a):E.current=null};return E.current=requestAnimationFrame(a),()=>{E.current&&cancelAnimationFrame(E.current),E.current=null}},[t,n,r,i]);let D=(0,m.useCallback)((e,t,n)=>({x:(e-n.left-l.x)/l.k,y:(t-n.top-l.y)/l.k}),[l]),O=(0,m.useCallback)((e,t)=>{e.stopPropagation();let n=e.currentTarget;n.setPointerCapture?.(e.pointerId);let r=n.ownerSVGElement;if(!r)return;let i=r.getBoundingClientRect(),a=D(e.clientX,e.clientY,i),o=d.current[t];o&&(p.current.add(t),h.current={id:t,offsetX:o.x-a.x,offsetY:o.y-a.y},w.current=Math.max(w.current,.6))},[D]),k=(0,m.useCallback)(e=>{if(h.current){let t=e.currentTarget.getBoundingClientRect(),n=D(e.clientX,e.clientY,t),{id:r,offsetX:i,offsetY:a}=h.current,o=d.current[r];o&&(o.x=n.x+i,o.y=n.y+a);return}if(C.current){let t=e.clientX-C.current.x,n=e.clientY-C.current.y;C.current={x:e.clientX,y:e.clientY},u(e=>({...e,x:e.x+t,y:e.y+n}))}},[D]),A=(0,m.useCallback)(()=>{h.current&&=(p.current.delete(h.current.id),null),C.current=null},[]),j=(0,m.useCallback)(e=>{let t=e.target.tagName;(t===`svg`||t===`g`)&&(C.current={x:e.clientX,y:e.clientY})},[]),M=(0,m.useCallback)(e=>{let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;u(t=>{let i=e.deltaY<0?1.1:1/1.1,a=Math.max(.2,Math.min(4,t.k*i));return{x:n-(n-t.x)*(a/t.k),y:r-(r-t.y)*(a/t.k),k:a}})},[]);return(0,m.useMemo)(()=>({positions:a,hoveredId:s,setHoveredId:c,transform:l,onPointerDown:O,onPointerMove:k,onPointerUp:A,onWheel:M,onCanvasDown:j}),[a,s,l,O,k,A,M,j])}var w=r();function T({edge:e,positions:t,hoveredId:n}){let r=t[e.from],i=t[e.to];if(!r||!i)return null;let a=n&&n!==e.from&&n!==e.to;return(0,w.jsx)(`line`,{x1:r.x,y1:r.y,x2:i.x,y2:i.y,stroke:A(e.artifact_type),strokeOpacity:a?.08:.55,strokeWidth:1.2,markerEnd:`url(#arrowhead)`,children:(0,w.jsx)(`title`,{children:`${e.from} → ${e.to} (${e.artifact_type})`})})}function E({node:e}){return(0,w.jsxs)(`div`,{className:`pointer-events-none absolute right-3 top-3 max-w-[300px] border border-border bg-background/95 p-3 text-xs shadow-md backdrop-blur`,children:[(0,w.jsx)(`div`,{className:`font-semibold leading-tight`,children:e.name}),(0,w.jsxs)(`div`,{className:`mt-0.5 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`v`,e.version]}),e.description&&(0,w.jsx)(`p`,{className:`mt-2 leading-snug text-muted-foreground`,children:e.description}),e.produces&&e.produces.length>0&&(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-emerald-500/80`,children:`produces`}),(0,w.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-foreground/80`,children:e.produces.join(`, `)})]}),e.consumes&&e.consumes.length>0&&(0,w.jsxs)(`div`,{className:`mt-1.5`,children:[(0,w.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-sky-500/80`,children:`consumes`}),(0,w.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-foreground/80`,children:e.consumes.join(`, `)})]}),e.stats_summary&&e.stats_summary.invocations>0&&(0,w.jsxs)(`div`,{className:`mt-2 border-t border-border/40 pt-2 font-mono text-[10px] text-muted-foreground`,children:[e.stats_summary.invocations,` runs ·`,` `,Math.round(e.stats_summary.success_rate*100),`% success`]})]})}function D({graph:e}){let t=(0,m.useMemo)(()=>{let t=new Set;for(let n of e.edges)t.add(n.artifact_type);return Array.from(t).sort()},[e.edges]);return t.length===0?null:(0,w.jsx)(f,{children:(0,w.jsxs)(u,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-5 py-3`,children:[(0,w.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:`artifact types`}),t.map(e=>(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`span`,{className:`inline-block h-0.5 w-6`,style:{background:A(e)}}),(0,w.jsx)(`code`,{className:`font-mono text-[11px] text-foreground/80`,children:e})]},e))]})})}function O(e){let t=(e.produces?.length??0)+(e.consumes?.length??0);return Math.min(11,4+Math.log2(1+t)*1.8)}function k(e){let t=e.stats_summary;return!t||t.invocations===0?`#94a3b8`:t.success_rate>=.9?`#10b981`:t.success_rate>=.6?`#f59e0b`:`#ef4444`}function A(e){let t=5381;for(let n=0;nh(),[]));return(0,w.jsxs)(`div`,{className:`space-y-6`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`flex items-center gap-3 text-2xl font-bold tracking-tight`,children:[(0,w.jsx)(i,{className:`h-5 w-5 text-primary/70`}),`Composition graph`]}),(0,w.jsxs)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:[`Skills wired together via their`,` `,(0,w.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`produces:`}),` +`,` `,(0,w.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`consumes:`}),` manifest fields. Edges show "A's output type matches B's input type" — the runner can chain along them automatically. Cycles are allowed.`]})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,w.jsx)(s,{to:`/skills`,children:(0,w.jsxs)(o,{variant:`ghost`,size:`sm`,children:[(0,w.jsx)(c,{className:`mr-1.5 h-3 w-3`}),`Library`]})}),(0,w.jsxs)(o,{variant:`ghost`,size:`sm`,onClick:r,children:[(0,w.jsx)(a,{className:`mr-1.5 h-3 w-3`}),`Refresh`]})]})]}),n&&(0,w.jsx)(`p`,{className:`border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:n}),t&&!e&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}),`Reading the registry…`]}),e&&(e.graph.nodes.length===0?(0,w.jsx)(M,{}):(0,w.jsx)(N,{graph:e.graph})),e&&e.graph.nodes.length>0&&(0,w.jsx)(D,{graph:e.graph})]})}function M(){return(0,w.jsx)(p,{icon:(0,w.jsx)(i,{className:`h-6 w-6`}),title:`No skills to graph yet`,description:(0,w.jsxs)(w.Fragment,{children:[`Publish a skill with`,` `,(0,w.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`produces:`}),` or`,` `,(0,w.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`consumes:`}),` in its frontmatter and it'll appear here.`]})})}function N({graph:e}){let t=(0,m.useRef)(null),[n,r]=(0,m.useState)({width:900,height:600});(0,m.useEffect)(()=>{if(!t.current)return;let e=new ResizeObserver(e=>{let t=e[0];if(!t)return;let{width:n,height:i}=t.contentRect;r({width:Math.max(360,n),height:Math.max(360,i)})});return e.observe(t.current),()=>e.disconnect()},[]);let{positions:i,hoveredId:a,setHoveredId:o,transform:s,onPointerDown:c,onPointerMove:l,onPointerUp:d,onWheel:p,onCanvasDown:h}=C({nodes:e.nodes,edges:e.edges,width:n.width,height:n.height}),g=(0,m.useMemo)(()=>e.nodes.find(e=>e.name===a)??null,[a,e.nodes]);return(0,w.jsx)(f,{children:(0,w.jsx)(u,{className:`p-0`,children:(0,w.jsxs)(`div`,{ref:t,className:`relative h-[600px] w-full select-none overflow-hidden bg-gradient-to-br from-background to-muted/30`,children:[(0,w.jsxs)(`svg`,{width:n.width,height:n.height,onMouseDown:h,onWheel:p,onPointerMove:l,onPointerUp:d,onPointerLeave:d,style:{cursor:`grab`},children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`marker`,{id:`arrowhead`,markerWidth:`6`,markerHeight:`6`,refX:`9`,refY:`3`,orient:`auto`,markerUnits:`strokeWidth`,children:(0,w.jsx)(`path`,{d:`M0,0 L0,6 L6,3 z`,fill:`currentColor`})})}),(0,w.jsxs)(`g`,{transform:`translate(${s.x},${s.y}) scale(${s.k})`,children:[e.edges.map((e,t)=>(0,w.jsx)(T,{edge:e,positions:i,hoveredId:a},`${e.from}->${e.to}@${e.artifact_type}-${t}`)),e.nodes.map(e=>{let t=i[e.name];if(!t)return null;let n=O(e),r=a===e.name;return(0,w.jsxs)(`g`,{transform:`translate(${t.x},${t.y})`,onPointerDown:t=>c(t,e.name),onMouseEnter:()=>o(e.name),onMouseLeave:()=>o(null),style:{cursor:`pointer`},children:[(0,w.jsx)(`circle`,{r:n,fill:k(e),fillOpacity:r?1:.85,stroke:r?`#fff`:`rgba(255,255,255,0.15)`,strokeWidth:r?1.5:.5}),(r||n>=7)&&(0,w.jsx)(`text`,{x:n+4,y:3,fontSize:10,fontFamily:`ui-monospace,SFMono-Regular,monospace`,fill:`currentColor`,opacity:r?.95:.65,style:{pointerEvents:`none`},children:e.name})]},e.name)})]})]}),g&&(0,w.jsx)(E,{node:g})]})})})}export{j as SkillCompositionGraph}; \ No newline at end of file diff --git a/internal/web/dist/assets/SkillRegistryPage-GJcDC2PD.js b/internal/web/dist/assets/SkillRegistryPage-GJcDC2PD.js deleted file mode 100644 index 3cd27a8..0000000 --- a/internal/web/dist/assets/SkillRegistryPage-GJcDC2PD.js +++ /dev/null @@ -1,7 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{At as n,Ct as r,E as i,Et as a,Ft as o,H as s,Ht as c,St as l,Ut as u,_t as d,in as f,nt as p,on as m,ot as ee,rt as h}from"./client-CaIRceNv.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./dropdown-menu-iCiwbrNR.js";import{t as S}from"./createLucideIcon-WB390fY6.js";import{t as C}from"./chevron-right-CyhRDGe7.js";import{t as te}from"./corner-down-left-DusgzzkI.js";import{t as w}from"./folder-DHzynzTC.js";import{n as T,t as E}from"./tag-kY6Y-EYi.js";import{t as ne}from"./network-CrANvqlb.js";import{t as re}from"./wifi-off-wjnWavsP.js";import{Ar as ie,Bn as D,Fn as O,Fr as ae,Ft as k,Hn as A,Kn as oe,Ln as j,Mn as M,Nn as N,On as P,Qn as se,Rn as ce,S as F,Sr as le,Xn as I,b as ue,br as L,cr as R,er as z,fr as de,i as B,j as fe,jn as V,jr as H,kn as U,n as W,nr as G,qn as pe,r as K,t as q,v as me,xr as J,y as Y,yr as he,zn as ge}from"./index-BDLzoIgt.js";import{t as _e}from"./empty-state-B9mtYx_X.js";import{n as ve,t as ye}from"./markdown-BxN4l9DE.js";import{t as be}from"./textarea-BiOhexhg.js";var xe=S(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Se=S(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Ce=S(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),X=e(t(),1),Z=m();function we({value:e,onChange:t,onSubmit:n,searching:r,hits:i,onClear:a}){let o=!r&&e.trim().length>0;return(0,Z.jsxs)(`div`,{className:f(`group/search flex items-stretch border border-border bg-card transition-colors`,`focus-within:border-primary/60`),children:[(0,Z.jsx)(`div`,{className:`flex items-center pl-3 pr-2 text-muted-foreground/70 transition-colors group-focus-within/search:text-primary sm:pl-4 sm:pr-3`,children:(0,Z.jsx)(pe,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,Z.jsx)(`input`,{value:e,placeholder:`Ask in plain English...`,onChange:e=>t(e.target.value),onKeyDown:t=>{t.key===`Enter`&&n(e),t.key===`Escape`&&a()},className:f(`h-11 min-w-0 flex-1 border-0 bg-transparent p-0 pr-2 text-[15px] text-foreground placeholder:text-muted-foreground/60 sm:h-12 sm:pr-3`,`outline-none focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0`),"data-testid":`skill-search`,"aria-label":`Ask the skills registry`}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pr-2 text-[11px] text-muted-foreground/80 sm:gap-2 sm:pr-3`,children:[i&&(0,Z.jsxs)(`span`,{className:`hidden uppercase tracking-wider sm:inline`,children:[i.length,` match`,i.length===1?``:`es`]}),e&&(0,Z.jsx)(`button`,{type:`button`,onClick:a,className:`grid h-7 w-7 place-items-center text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:ring-0 focus-visible:ring-offset-0`,"aria-label":`Clear search`,children:(0,Z.jsx)(j,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>n(e),disabled:!o,className:f(`flex shrink-0 items-center gap-2 self-stretch border-l border-border px-3 sm:px-4`,`text-[11px] uppercase tracking-wider transition-colors`,`focus-visible:ring-0 focus-visible:ring-offset-0`,o?`text-primary/90 hover:bg-primary/10 hover:text-primary`:`cursor-not-allowed text-muted-foreground/40`),"aria-label":`Run search`,children:[r?(0,Z.jsx)(G,{className:`h-3.5 w-3.5 animate-spin`}):(0,Z.jsx)(te,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`hidden font-semibold sm:inline`,children:`Ask`})]})]})}function Te({value:e,onChange:t,workspaces:n}){let r=De(e,n),i=Oe(e);return(0,Z.jsxs)(x,{children:[(0,Z.jsxs)(y,{className:f(`inline-flex items-center gap-2 border border-border bg-transparent px-2.5 py-1 text-[12px] text-foreground/90 transition-colors`,`hover:border-muted-foreground hover:bg-accent/20 data-[state=open]:border-primary/60 data-[state=open]:bg-accent/30`),"data-testid":`scope-trigger`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/70 uppercase text-[10px] tracking-wider`,children:`Workspace`}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-foreground`,children:[i,r]}),(0,Z.jsx)(J,{className:`ml-0.5 h-3 w-3 text-muted-foreground/60`})]}),(0,Z.jsxs)(v,{align:`start`,className:`min-w-[14rem]`,children:[(0,Z.jsx)(_,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`Synthetic`}),(0,Z.jsx)(Ee,{active:e.mode===`all`,icon:(0,Z.jsx)(T,{className:`h-3.5 w-3.5`}),label:`All scopes`,hint:`Every skill visible to admin`,onSelect:()=>t({mode:`all`}),testid:`scope-all`}),(0,Z.jsx)(Ee,{active:e.mode===`global`,icon:(0,Z.jsx)(R,{className:`h-3.5 w-3.5`}),label:`Shared`,hint:`Workspace-independent`,onSelect:()=>t({mode:`global`}),testid:`scope-global`}),n.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g,{}),(0,Z.jsx)(_,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`Workspaces`}),n.map(n=>(0,Z.jsx)(Ee,{active:e.mode===`workspace`&&e.workspaceId===n.id,icon:(0,Z.jsx)(w,{className:`h-3.5 w-3.5`}),label:n.name,onSelect:()=>t({mode:`workspace`,workspaceId:n.id}),testid:`scope-ws-${n.id.slice(0,8)}`},n.id))]}),(0,Z.jsx)(g,{}),(0,Z.jsxs)(`p`,{className:`px-2 py-1.5 text-[10px] leading-relaxed text-muted-foreground/70`,children:[`Agents publish with`,` `,(0,Z.jsx)(`code`,{className:`text-foreground/80`,children:`scope: workspace`}),` to pin a skill, else it lands shared.`]})]})]})}function Ee({active:e,icon:t,label:n,hint:r,onSelect:i,testid:a}){return(0,Z.jsxs)(b,{onSelect:i,"data-testid":a,className:f(`flex items-center gap-2 text-[12px]`,e&&`bg-accent/40 text-foreground`),children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/80`,children:t}),(0,Z.jsx)(`span`,{className:`flex-1 truncate`,children:n}),r&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:r}),e&&(0,Z.jsx)(le,{className:`h-3 w-3 text-primary`})]})}function De(e,t){return e.mode===`all`?`All scopes`:e.mode===`global`?`Shared`:t.find(t=>t.id===e.workspaceId)?.name??`Workspace`}function Oe(e){return e.mode===`all`?(0,Z.jsx)(T,{className:`h-3.5 w-3.5 text-muted-foreground/70`}):e.mode===`global`?(0,Z.jsx)(R,{className:`h-3.5 w-3.5 text-muted-foreground/70`}):(0,Z.jsx)(w,{className:`h-3.5 w-3.5 text-muted-foreground/70`})}var ke=`uncategorized`;function Ae(e){let t=e.metadata?.category;return typeof t==`string`?t.trim().toLowerCase()||`uncategorized`:ke}function je(e){let t=new Map;for(let n of e){let e=Ae(n),r=t.get(e);r?r.push(n):t.set(e,[n])}let n=Array.from(t.entries()).map(([e,t])=>({category:e,entries:t}));return n.sort((e,t)=>e.category===`uncategorized`?1:t.category===`uncategorized`?-1:e.category.localeCompare(t.category)),n}function Me(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.trim().toLowerCase();n&&t.set(n,(t.get(n)??0)+1)}let n=Array.from(t.entries()).map(([e,t])=>({tag:e,count:t}));return n.sort((e,t)=>t.count-e.count||e.tag.localeCompare(t.tag)),n}function Ne(e,t){if(t.size===0)return!0;let n=new Set((e.tags??[]).map(e=>e.trim().toLowerCase()));for(let e of t)if(!n.has(e))return!1;return!0}function Pe({rows:e,selectedName:t,searchHits:n,collapsed:r,groupCategories:i=!0,onToggleCategory:a,onSelect:o,onVersions:s,onDelete:c}){let l=(0,X.useMemo)(()=>n?new Map(n.map(e=>[e.name,e.score])):null,[n]),u=(0,X.useMemo)(()=>l?Math.max(...Array.from(l.values()),.001):0,[l]);if(e.length===0&&n)return(0,Z.jsx)(q,{children:(0,Z.jsx)(W,{className:`px-4 py-10 text-center text-sm text-muted-foreground`,children:`Nothing matched. Try a different phrasing, or browse the catalog by clearing the search.`})});let d=!n&&i?je(e):[],f=d.length>1?d:null;return(0,Z.jsx)(q,{className:`overflow-hidden`,children:(0,Z.jsx)(W,{className:`p-0`,children:f?(0,Z.jsx)(`ul`,{className:`divide-y divide-border/40`,children:f.map(e=>(0,Z.jsx)(Fe,{category:e.category,entries:e.entries,collapsed:r.has(e.category),onToggle:()=>a(e.category),selectedName:t,hitMap:l,maxScore:u,onSelect:o,onVersions:s,onDelete:c},e.category))}):(0,Z.jsx)(`ul`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Ie,{entry:e,active:t===e.name,score:l?.get(e.name),scoreMax:u,onSelect:()=>o(e.name),onVersions:()=>s(e.name),onDelete:()=>c(e)})},e.id))})})})}function Fe({category:e,entries:t,collapsed:n,onToggle:r,selectedName:i,hitMap:a,maxScore:o,onSelect:s,onVersions:c,onDelete:l}){let u=e===`uncategorized`?`uncategorized`:e;return(0,Z.jsxs)(`li`,{children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:`flex w-full items-center gap-2 px-4 py-2 text-left text-[11px] uppercase tracking-wider text-muted-foreground/80 transition-colors hover:bg-accent/15`,"aria-expanded":!n,"data-testid":`category-${e}`,children:[n?(0,Z.jsx)(C,{className:`h-3 w-3 text-muted-foreground/60`}):(0,Z.jsx)(J,{className:`h-3 w-3 text-muted-foreground/60`}),(0,Z.jsx)(`span`,{className:`font-medium text-foreground/80`,children:u}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/50`,children:t.length})]}),!n&&(0,Z.jsx)(`ul`,{className:`divide-y divide-border/40`,children:t.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(Ie,{entry:e,active:i===e.name,score:a?.get(e.name),scoreMax:o,onSelect:()=>s(e.name),onVersions:()=>c(e.name),onDelete:()=>l(e)})},e.id))})]})}function Ie({entry:e,active:t,score:n,scoreMax:r,onSelect:i,onVersions:a,onDelete:o}){let s=e.tags??[];return(0,Z.jsxs)(`div`,{className:f(`group flex w-full items-stretch border-l-2 transition-colors`,t?`border-l-primary bg-accent/45`:`border-l-transparent hover:bg-accent/20`),"data-testid":`skill-row-${e.name}`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-start gap-3 px-3 py-3 text-left`,"aria-current":t?`true`:void 0,children:(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-[13px] font-semibold text-foreground`,children:e.name}),(0,Z.jsxs)(`span`,{className:`shrink-0 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`v`,e.version]}),e.workspace_id?(0,Z.jsxs)(`span`,{className:`shrink-0 inline-flex items-center gap-1 text-[10px] uppercase tracking-wider text-primary/80`,children:[(0,Z.jsx)(w,{className:`h-2.5 w-2.5`}),`ws`]}):(0,Z.jsxs)(`span`,{className:`shrink-0 inline-flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:[(0,Z.jsx)(R,{className:`h-2.5 w-2.5`}),`global`]}),(e.source_type===`path`||e.source_type===`bundle`||e.bundle_sha256)&&(0,Z.jsxs)(`span`,{className:f(`shrink-0 inline-flex items-center gap-1 border px-1 py-px text-[9px] uppercase tracking-wider`,e.bundle_sha256?`border-emerald-500/30 bg-emerald-500/5 text-emerald-300/90`:`border-border/60 text-muted-foreground`),title:e.bundle_sha256?`tar.gz bundle attached — sha256 ${e.bundle_sha256.slice(0,12)}…`:`sidecar files (path source)`,children:[(0,Z.jsx)(z,{className:`h-2.5 w-2.5`}),e.bundle_sha256?`bundle`:`path`]})]}),(0,Z.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-relaxed text-muted-foreground`,children:e.description}),s.length>0&&(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[s.slice(0,6).map(e=>(0,Z.jsxs)(`span`,{className:`text-[9px] text-muted-foreground/70`,children:[`#`,e]},e)),s.length>6&&(0,Z.jsxs)(`span`,{className:`text-[9px] text-muted-foreground/50`,children:[`+`,s.length-6]})]}),e.author&&e.author!==`system`&&(0,Z.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground/60`,children:[`by `,e.author]})]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-1 px-2 py-3`,children:[n!==void 0&&(0,Z.jsx)(Re,{score:n,max:r}),(0,Z.jsx)(Le,{label:`Versions`,onClick:a,children:(0,Z.jsx)(Se,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(Le,{label:`Delete`,destructive:!0,onClick:o,children:(0,Z.jsx)(D,{className:`h-3.5 w-3.5`})})]})]})}function Le({children:e,label:t,destructive:n,onClick:r}){return(0,Z.jsx)(`button`,{type:`button`,onClick:r,"aria-label":t,title:t,className:f(`grid h-7 w-7 place-items-center text-muted-foreground transition-colors`,n?`hover:text-destructive`:`hover:text-foreground`),children:e})}function Re({score:e,max:t}){let n=Math.max(1,Math.round(e/t*5));return(0,Z.jsx)(`span`,{className:`mr-1 flex items-center gap-0.5`,title:`Relevance score ${e.toFixed(3)}`,"aria-label":`Score ${e.toFixed(2)}`,children:Array.from({length:5}).map((e,t)=>(0,Z.jsx)(`span`,{className:f(`h-1 w-1 transition-colors`,t(0,Z.jsxs)(`div`,{className:`animate-pulse px-4 py-3`,children:[(0,Z.jsx)(`div`,{className:`h-3.5 w-2/5 bg-muted/40`}),(0,Z.jsx)(`div`,{className:`mt-2 h-3 w-full bg-muted/30`}),(0,Z.jsx)(`div`,{className:`mt-1 h-3 w-2/3 bg-muted/20`})]},t))})})})}function Be(e,t){let n=t?`?window_days=${t}`:``;return o(`/skills/${encodeURIComponent(e)}/stats${n}`)}function Ve({name:e,embedded:t=!1}){let{data:n,loading:r,error:i}=F((0,X.useCallback)(()=>Be(e),[e]));if(r&&!n)return(0,Z.jsx)(Q,{embedded:t,children:`Loading reputation...`});if(i)return(0,Z.jsxs)(Q,{embedded:t,className:`text-destructive`,children:[`Failed to load reputation: `,i]});if(!n)return null;let a=n.stats;return a.invocations===0?(0,Z.jsx)(Q,{embedded:t,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(ie,{className:`h-3 w-3`}),`No runs in the last `,a.window_days,` day`,a.window_days===1?``:`s`]})}):(0,Z.jsxs)(Q,{embedded:t,className:`block`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[`Reputation · `,a.window_days,`d`]}),a.last_run_at&&(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/70`,children:[`last run `,Ge(a.last_run_at)]})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,Z.jsx)($,{icon:(0,Z.jsx)(ie,{className:`h-3 w-3`}),label:`Invocations`,value:String(a.invocations)}),(0,Z.jsx)($,{icon:(0,Z.jsx)(L,{className:`h-3 w-3`}),label:`Success`,value:He(a.success_rate),tone:We(a.success_rate)}),(0,Z.jsx)($,{icon:(0,Z.jsx)(he,{className:`h-3 w-3`}),label:`p95`,value:Ue(a.p95_duration_ms)}),(0,Z.jsx)($,{icon:(0,Z.jsx)(ce,{className:`h-3 w-3`}),label:`p50`,value:Ue(a.p50_duration_ms)})]}),a.top_tools_used.length>0&&(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`top tools`}),a.top_tools_used.slice(0,5).map(e=>(0,Z.jsxs)(`span`,{className:`border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,title:`${e.count} call${e.count===1?``:`s`}`,children:[e.name,(0,Z.jsx)(`span`,{className:`ml-1 text-muted-foreground/60`,children:e.count})]},e.name))]})]})}function Q({embedded:e,className:t,children:n}){let r=f(`px-5 py-3 text-xs text-muted-foreground`,e&&`border-t border-border/60 bg-muted/15`,t);return e?(0,Z.jsx)(`div`,{className:r,children:n}):(0,Z.jsx)(q,{children:(0,Z.jsx)(W,{className:r,children:n})})}function $({icon:e,label:t,value:n,tone:r}){return(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:[e,(0,Z.jsx)(`span`,{children:t})]}),(0,Z.jsx)(`div`,{className:`tabular-nums text-base font-semibold ${r===`good`?`text-emerald-500`:r===`warn`?`text-amber-500`:r===`bad`?`text-destructive`:`text-foreground`}`,children:n})]})}function He(e){return Number.isFinite(e)?`${Math.round(e*100)}%`:`—`}function Ue(e){return e===0?`—`:e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function We(e){return e>=.9?`good`:e>=.6?`warn`:`bad`}function Ge(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return e;let n=Date.now()-t,r=Math.floor(n/864e5);if(r>0)return`${r}d ago`;let i=Math.floor(n/36e5);if(i>0)return`${i}h ago`;let a=Math.floor(n/6e4);return a>0?`${a}m ago`:`just now`}function Ke({name:e,onTagSet:t,onVersions:n,onDelete:r}){let{data:i,loading:a,error:o,refetch:s}=F((0,X.useCallback)(()=>e?p(e):Promise.resolve(null),[e]));async function c(){if(i)try{await u(i.name,`@stable`,i.version),H.success(`@stable now points to ${i.name}@${i.version}`),t(),s()}catch(e){H.error(e instanceof Error?e.message:`Set tag failed`)}}if(!e)return(0,Z.jsx)(q,{children:(0,Z.jsx)(W,{className:`grid min-h-[400px] place-items-center px-6 py-10 text-center`,children:(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(A,{className:`mx-auto h-5 w-5 text-muted-foreground/40`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a skill to read it. Or ask the registry above.`})]})})});if(a&&!i)return(0,Z.jsx)(q,{children:(0,Z.jsxs)(W,{className:`flex items-center gap-2 px-4 py-6 text-sm text-muted-foreground`,children:[(0,Z.jsx)(G,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]})});if(o)return(0,Z.jsx)(q,{children:(0,Z.jsx)(W,{className:`px-4 py-6 text-sm text-destructive`,children:o})});if(!i)return null;let l=ve(i.body),d=qe(i);return(0,Z.jsx)(q,{"data-testid":`skill-detail`,className:`overflow-hidden py-0`,children:(0,Z.jsxs)(W,{className:`p-0`,children:[(0,Z.jsxs)(`div`,{className:`border-b border-border px-5 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Z.jsxs)(Y,{variant:`outline`,tone:`mono`,children:[`v`,i.version]}),(0,Z.jsxs)(Y,{variant:`outline`,tone:i.workspace_id?`info`:`muted`,title:i.workspace_id?`Workspace ${i.workspace_id}`:`Global`,children:[i.workspace_id?(0,Z.jsx)(w,{className:`h-3 w-3`}):(0,Z.jsx)(R,{className:`h-3 w-3`}),i.workspace_id?`workspace`:`global`]}),d&&(0,Z.jsxs)(Y,{variant:`outline`,tone:i.bundle_sha256?`success`:`muted`,title:i.source_path||void 0,children:[(0,Z.jsx)(z,{className:`h-3 w-3`}),d]})]}),(0,Z.jsx)(`h2`,{className:`mt-3 break-words text-xl font-semibold tracking-tight text-foreground`,children:i.name}),i.description&&(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-3 max-w-3xl text-sm leading-relaxed text-muted-foreground`,children:i.description})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[n&&(0,Z.jsxs)(O,{variant:`outline`,size:`sm`,onClick:()=>n(i.name),children:[(0,Z.jsx)(Se,{className:`h-3.5 w-3.5`}),`Versions`]}),(0,Z.jsxs)(O,{variant:`outline`,size:`sm`,onClick:c,children:[(0,Z.jsx)(E,{className:`h-3.5 w-3.5`}),`Pin @stable`]}),r&&(0,Z.jsxs)(O,{variant:`ghost`,size:`sm`,className:`text-destructive hover:text-destructive`,onClick:()=>r(i),children:[(0,Z.jsx)(D,{className:`h-3.5 w-3.5`}),`Delete`]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground sm:gap-x-4`,children:[i.author&&(0,Z.jsxs)(`span`,{children:[`Author: `,(0,Z.jsx)(`span`,{className:`text-foreground/80`,children:i.author})]}),(0,Z.jsxs)(`span`,{children:[`Published:`,` `,(0,Z.jsx)(`span`,{className:`text-foreground/80`,children:new Date(i.published_at).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})})]}),i.content_hash&&(0,Z.jsxs)(`span`,{children:[`Hash: `,(0,Z.jsx)(`code`,{className:`text-foreground/80`,children:i.content_hash.slice(0,8)})]}),i.tags&&i.tags.length>0&&(0,Z.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1`,children:[`Tags:`,i.tags.map(e=>(0,Z.jsx)(`span`,{className:`border border-border px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:e},e))]})]})]}),i.source_path&&(0,Z.jsxs)(`div`,{className:`border-b border-border/40 bg-muted/15 px-5 py-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground/60`,children:`Source path: `}),(0,Z.jsx)(`code`,{className:`break-all text-foreground/80`,children:i.source_path})]}),(0,Z.jsx)(`div`,{className:`border-t border-border/60 px-5 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsx)(de,{className:`h-3.5 w-3.5`}),`Instructions`]})}),(0,Z.jsx)(`div`,{className:`max-w-[82ch] px-6 pb-7`,children:l?(0,Z.jsx)(ye,{source:l}):(0,Z.jsx)(`p`,{className:`py-6 text-sm text-muted-foreground`,children:`No SKILL.md body is available for this version.`})}),(0,Z.jsx)(Ve,{name:i.name,embedded:!0})]})})}function qe(e){return e.bundle_sha256?`bundle`:e.source_type===`path`?`path`:e.source_type===`inline`?`inline`:e.source_type===`git`?`git`:``}function Je({open:e,onOpenChange:t,onPublished:r,serverMode:i=!1}){let[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(`--- -name: my-skill -description: Use when the user wants ... ---- - -# My skill -`),[l,u]=(0,X.useState)(!1);async function d(){if(!(!a.trim()||!s.trim())){u(!0);try{let e=await n({name:a.trim(),body:s});e.action===`deduped`?H.info(`No change — content matched existing v${e.version}.`):H.success(`Published ${e.name}@${e.version}`),r()}catch(e){H.error(e instanceof Error?e.message:`Publish failed`)}finally{u(!1)}}}return(0,Z.jsx)(P,{open:e,onOpenChange:t,children:(0,Z.jsxs)(U,{className:`max-w-3xl sm:max-w-3xl`,children:[(0,Z.jsx)(M,{children:(0,Z.jsx)(N,{children:i?`New global skill`:`New skill`})}),(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(Ye,{label:`Name`,children:(0,Z.jsx)(k,{value:a,onChange:e=>o(e.target.value),placeholder:`my-skill (must match the frontmatter name)`})}),(0,Z.jsx)(Ye,{label:`SKILL.md`,children:(0,Z.jsx)(be,{value:s,onChange:e=>c(e.target.value),className:`min-h-[280px] text-[12.5px] leading-relaxed`})}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:i?`This writes to the central repository only after you press Publish.`:(0,Z.jsxs)(Z.Fragment,{children:[`Lead the description with `,(0,Z.jsx)(`span`,{className:`text-foreground/80`,children:`"Use when…"`}),`. That phrase is the retrieval key when agents ask the registry by intent.`]})})]}),(0,Z.jsxs)(V,{children:[(0,Z.jsx)(O,{variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,Z.jsxs)(O,{onClick:d,disabled:l,children:[l?(0,Z.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}):null,`Publish`]})]})]})})}function Ye({label:e,children:t}){return(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`label`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:e}),t]})}function Xe({name:e,onOpenChange:t,onTagSet:n}){let[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),{data:c,loading:l}=F((0,X.useCallback)(()=>e?r(e):Promise.resolve([]),[e]));async function d(t){if(e)try{await u(e,`@stable`,t),H.success(`@stable → ${e}@${t}`),n()}catch(e){H.error(e instanceof Error?e.message:`Tag failed`)}}async function f(t,n){if(e){s(!0);try{a(await h(e,t,n))}catch(e){H.error(e instanceof Error?e.message:`Diff failed`),a(null)}finally{s(!1)}}}function p(e){e||a(null),t(e)}return(0,Z.jsx)(P,{open:!!e,onOpenChange:p,children:(0,Z.jsxs)(U,{className:`max-w-2xl sm:max-w-2xl`,children:[(0,Z.jsx)(M,{children:(0,Z.jsxs)(N,{children:[e,` — version history`]})}),l&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(G,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}),(0,Z.jsx)(`ul`,{className:`max-h-[320px] divide-y divide-border/40 overflow-auto`,children:c?.map((e,t)=>{let n=c[t+1];return(0,Z.jsxs)(`li`,{className:`flex items-start gap-3 px-1 py-3`,children:[(0,Z.jsxs)(`span`,{className:`mt-1 shrink-0 text-[11px] uppercase tracking-wider text-muted-foreground`,children:[`v`,e.version]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`line-clamp-2 text-[13px] text-foreground/90`,children:e.description}),(0,Z.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-muted-foreground/70`,children:[new Date(e.published_at).toLocaleString(),` · `,e.author||`anonymous`,e.parent_version!=null&&(0,Z.jsxs)(Z.Fragment,{children:[` · parent v`,e.parent_version]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-1`,children:[n&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>f(n.version,e.version),className:`border border-transparent px-2 py-1 text-[11px] uppercase tracking-wider text-muted-foreground transition-colors hover:border-border hover:text-foreground`,children:[`Diff v`,n.version]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>d(e.version),className:`border border-transparent px-2 py-1 text-[11px] uppercase tracking-wider text-muted-foreground transition-colors hover:border-border hover:text-foreground`,children:`Pin @stable`})]})]},e.id)})}),(o||i)&&(0,Z.jsxs)(`div`,{className:`space-y-2 border border-border/60 bg-muted/20 p-3`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:i?`Diff v${i.old_version} → v${i.new_version}`:`Loading diff…`}),o&&(0,Z.jsx)(G,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),i?.body_diff&&(0,Z.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap text-[11px] leading-relaxed text-foreground/85`,children:i.body_diff}),i&&!i.body_diff&&!i.frontmatter_diff&&(0,Z.jsx)(`p`,{className:`text-[12px] text-muted-foreground`,children:`No textual changes.`}),i?.tree&&i.tree.length>0&&(0,Z.jsx)(`ul`,{className:`space-y-0.5 text-[11px] text-muted-foreground`,children:i.tree.map(e=>(0,Z.jsxs)(`li`,{children:[e.status,e.path?`: ${e.path}`:``]},`${e.status}-${e.path}`))})]}),(0,Z.jsx)(V,{children:(0,Z.jsx)(O,{variant:`ghost`,onClick:()=>p(!1),children:`Close`})})]})})}var Ze=7;function Qe({entries:e,selected:t,onToggle:n,onClear:r}){let i=(0,X.useMemo)(()=>Me(e),[e]);if(i.length===0)return null;let a=i.slice(0,Ze),o=i.slice(Ze);return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,Z.jsx)(`span`,{className:`mr-1 text-muted-foreground/60 uppercase tracking-wider`,children:`Tags`}),a.map(({tag:e,count:r})=>(0,Z.jsx)($e,{tag:e,count:r,active:t.has(e),onToggle:()=>n(e)},e)),o.length>0&&(0,Z.jsx)(et,{items:o,selected:t,onToggle:n}),t.size>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:r,className:`ml-1 text-[10px] text-muted-foreground/70 underline-offset-2 hover:text-foreground hover:underline`,"data-testid":`tag-clear`,children:[`clear (`,t.size,`)`]})]})}function $e({tag:e,count:t,active:n,onToggle:r}){return(0,Z.jsxs)(`button`,{type:`button`,onClick:r,"data-testid":`tag-${e}`,className:f(`inline-flex items-center gap-1 border px-2 py-0.5 transition-colors`,n?`border-primary/60 bg-accent/40 text-foreground`:`border-border text-muted-foreground hover:border-muted-foreground hover:text-foreground`),children:[(0,Z.jsxs)(`span`,{children:[`#`,e]}),(0,Z.jsx)(`span`,{className:`text-[9px] text-muted-foreground/60`,children:t}),n&&(0,Z.jsx)(j,{className:`h-2.5 w-2.5 text-foreground/70`})]})}function et({items:e,selected:t,onToggle:n}){let[r,i]=(0,X.useState)(!1),a=e.filter(e=>t.has(e.tag)).length;return(0,Z.jsxs)(x,{open:r,onOpenChange:i,children:[(0,Z.jsxs)(y,{className:f(`inline-flex items-center gap-1 border border-dashed border-border px-2 py-0.5 text-[11px] text-muted-foreground transition-colors`,`hover:border-muted-foreground hover:text-foreground`,a>0&&`border-primary/40 text-foreground`),"data-testid":`tag-overflow`,children:[(0,Z.jsx)(`span`,{children:`··more`}),a>0&&(0,Z.jsxs)(`span`,{className:`text-[9px] text-primary/80`,children:[`+`,a]}),(0,Z.jsx)(J,{className:`h-2.5 w-2.5`})]}),(0,Z.jsx)(v,{align:`start`,className:`max-h-64 min-w-[12rem] overflow-y-auto`,children:e.map(({tag:e,count:r})=>(0,Z.jsxs)(b,{onSelect:t=>{t.preventDefault(),n(e)},className:f(`flex items-center gap-2 text-[11px]`,t.has(e)&&`bg-accent/40 text-foreground`),children:[(0,Z.jsxs)(`span`,{className:`flex-1`,children:[`#`,e]}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:r})]},e))})]})}function tt({onImported:e}){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!0),[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)(new Set),[l,u]=(0,X.useState)(!1),[p,m]=(0,X.useState)(!1),h=(0,X.useCallback)(async()=>{i(!0),o(null);try{let e=await d();n(e);let t=new Set;for(let n of e.skills)n.status===`new`&&t.add(n.path);c(t)}catch(e){o(e instanceof Error?e.message:`Failed to discover local skills`)}finally{i(!1)}},[]);(0,X.useEffect)(()=>{h()},[h]);let g=(0,X.useMemo)(()=>t?.skills.filter(e=>e.status===`new`||e.status===`version-conflict`)??[],[t]),_=(0,X.useMemo)(()=>{let e={new:0,duplicate:0,"version-conflict":0,unparseable:0};for(let n of t?.skills??[])e[n.status]=(e[n.status]??0)+1;return e},[t]);if(r&&!t)return(0,Z.jsx)(it,{});if(a)return(0,Z.jsx)(at,{error:a,onRetry:h});if(!t||t.skills.length===0)return null;if(g.length===0&&_.unparseable===0)return(0,Z.jsx)(ot,{path:t.path});async function v(){if(s.size===0)return;u(!0);let n=0,r=0;for(let e of s){let i=t?.skills.find(t=>t.path===e);if(i)try{let e=await ee({name:i.name||i.dir,source_dir:i.path,overwrite:i.status===`version-conflict`});e.action===`failed`?(r++,H.error(`${i.name}: ${e.error??`import failed`}`)):n++}catch(e){r++,H.error(`${i.name}: ${e instanceof Error?e.message:`request failed`}`)}}u(!1),n>0&&H.success(`Imported ${n} skill${n===1?``:`s`}`),r>0&&n>0&&H.error(`Failed to import ${r} skill${r===1?``:`s`}`),c(new Set),await h(),e?.()}function y(e,t){c(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}function b(e){if(!e){c(new Set);return}c(new Set(g.map(e=>e.path)))}return(0,Z.jsxs)(q,{"data-testid":`local-skills-migration-tile`,className:`py-0`,children:[(0,Z.jsxs)(K,{className:`flex flex-row items-center justify-between gap-4 space-y-0 py-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`flex min-w-0 flex-1 items-start gap-3 text-left`,"aria-expanded":p,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 text-muted-foreground`,children:p?(0,Z.jsx)(J,{className:`h-4 w-4`}):(0,Z.jsx)(C,{className:`h-4 w-4`})}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsxs)(B,{className:`flex items-center gap-2 text-base`,children:[(0,Z.jsx)(xe,{className:`h-4 w-4 text-primary`}),`Local skills not in registry`]}),(0,Z.jsxs)(`span`,{className:`mt-1 block truncate text-sm text-muted-foreground`,children:[g.length,` importable skill`,g.length===1?``:`s`,` under`,` `,(0,Z.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:t.path}),_.unparseable>0?`; ${_.unparseable} need attention`:``]})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Z.jsx)(O,{size:`sm`,onClick:v,disabled:s.size===0||l,"data-testid":`import-selected`,children:l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(G,{className:`mr-2 h-3.5 w-3.5 animate-spin`}),`Importing`]}):(0,Z.jsxs)(Z.Fragment,{children:[`Import selected (`,s.size,`)`]})}),(0,Z.jsx)(O,{variant:`outline`,size:`sm`,onClick:()=>void h(),disabled:r||l,"aria-label":`Refresh local skills`,children:(0,Z.jsx)(I,{className:f(`h-3.5 w-3.5`,r&&`animate-spin`)})})]})]}),p&&(0,Z.jsxs)(W,{className:`space-y-3 pb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-border/60 pb-2`,children:[(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(me,{checked:s.size>0&&s.size===g.length,onCheckedChange:e=>b(!!e),"aria-label":`Select all importable`,disabled:g.length===0}),(0,Z.jsx)(`span`,{children:`Select all importable`})]}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Imported skills move to `,(0,Z.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`.migrated/`}),`.`]})]}),(0,Z.jsx)(`ul`,{className:`max-h-80 space-y-1.5 overflow-y-auto pr-1`,children:t.skills.map(e=>(0,Z.jsx)(nt,{skill:e,checked:s.has(e.path),onToggle:t=>y(e.path,t)},e.path))})]})]})}function nt({skill:e,checked:t,onToggle:n}){let r=e.status===`new`||e.status===`version-conflict`;return(0,Z.jsxs)(`li`,{className:f(`flex items-center justify-between gap-3 rounded-sm border border-transparent px-2 py-1.5`,r?`hover:border-border/60 hover:bg-muted/40`:`opacity-70`),"data-testid":`local-skill-row`,children:[(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-3 cursor-pointer`,children:[(0,Z.jsx)(me,{checked:t,onCheckedChange:e=>n(!!e),disabled:!r,"aria-label":`Select ${e.name||e.dir}`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name||e.dir}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.description||e.parse_error||e.path})]})]}),(0,Z.jsx)(rt,{status:e.status,version:e.registry_version})]})}function rt({status:e,version:t}){switch(e){case`new`:return(0,Z.jsx)(Y,{variant:`default`,className:`text-[10px] uppercase tracking-wide`,children:`new`});case`duplicate`:return(0,Z.jsxs)(Y,{variant:`secondary`,className:`text-[10px] uppercase tracking-wide`,children:[`in registry v`,t]});case`version-conflict`:return(0,Z.jsxs)(Y,{variant:`outline`,className:`text-[10px] uppercase tracking-wide text-amber-600`,children:[`conflict v`,t]});case`unparseable`:return(0,Z.jsx)(Y,{variant:`destructive`,className:`text-[10px] uppercase tracking-wide`,children:`unparseable`})}}function it(){return(0,Z.jsx)(q,{children:(0,Z.jsx)(K,{children:(0,Z.jsxs)(B,{className:`flex items-center gap-2 text-base text-muted-foreground`,children:[(0,Z.jsx)(G,{className:`h-4 w-4 animate-spin`}),`Discovering local skills…`]})})})}function at({error:e,onRetry:t}){return(0,Z.jsx)(q,{className:`border-destructive/40 bg-destructive/5`,children:(0,Z.jsxs)(K,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(B,{className:`flex items-center gap-2 text-base text-destructive`,children:[(0,Z.jsx)(ge,{className:`h-4 w-4`}),`Could not list local skills`]}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]}),(0,Z.jsxs)(O,{variant:`outline`,size:`sm`,onClick:t,children:[(0,Z.jsx)(I,{className:`mr-2 h-3.5 w-3.5`}),`Retry`]})]})})}function ot({path:e}){return(0,Z.jsx)(q,{className:`border-emerald-500/30 bg-emerald-500/5`,children:(0,Z.jsxs)(K,{className:`flex flex-row items-center gap-3 space-y-0 py-3`,children:[(0,Z.jsx)(L,{className:`h-4 w-4 text-emerald-600`}),(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`All local skills under`,` `,(0,Z.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:e}),` are in the registry.`]})]})})}var st=`mcplexer:skills:collapsedCategories`;function ct(){let[e,t]=(0,X.useState)({mode:`all`}),{data:n,loading:r,error:o,refetch:u}=F((0,X.useCallback)(()=>l(e),[e])),{data:d}=F((0,X.useCallback)(()=>a(),[])),{data:p}=F((0,X.useCallback)(()=>s().catch(()=>null),[])),m=ue(p?.system),[ee,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),[te,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!1),[ie,D]=(0,X.useState)(null),[k,A]=(0,X.useState)(null),[j,M]=(0,X.useState)(()=>new Set),[N,P]=(0,X.useState)(()=>{if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(st);if(!e)return new Set;let t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`)):new Set}catch{return new Set}});(0,X.useEffect)(()=>{if(!(typeof window>`u`))try{window.localStorage.setItem(st,JSON.stringify(Array.from(N)))}catch{}},[N]),(0,X.useEffect)(()=>{!S&&n&&n.length>0&&C(n[0].name)},[n,S]);let ce=(0,X.useMemo)(()=>{if(!n)return[];let e=n.filter(e=>Ne(e,j));if(!g)return e;let t=new Map(g.map((e,t)=>[e.name,t]));return e.filter(e=>t.has(e.name)).sort((e,n)=>(t.get(e.name)??0)-(t.get(n.name)??0))},[n,g,j]);async function le(e){if(!e.trim()){_(null),x(null);return}y(!0),x(null);try{let t=await c(e,20);_(t),t.length>0&&C(t[0].name)}catch(e){let t=e instanceof Error?e.message:`Search failed`;x(t),H.error(t)}finally{y(!1)}}async function I(){if(k)try{await i(k.name,k.version),H.success(`Deleted ${k.name}@${k.version}`),S===k.name&&C(null),A(null),u()}catch(e){H.error(e instanceof Error?e.message:`Delete failed`)}}function L(e){M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function R(e){P(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function de(e){C(e),w(!0)}let B=n?.filter(e=>!!e.bundle_sha256).length??0,V=n?.length??0,U=g&&g.length===0,W=!!o,pe=b&&b.includes(`embedder`),K=o&&(o.includes(`fetch`)||o.includes(`network`));return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:m?`Skills Repository`:`Skills Library`}),V>0&&(0,Z.jsxs)(`div`,{"data-testid":`skills-header-stats`,className:`mt-2 flex flex-wrap items-center gap-2 text-[11px] uppercase tracking-wider text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[V,` skills`]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground/40`,children:`/`}),(0,Z.jsxs)(`span`,{title:`Skills with tar.gz sidecars attached`,className:f(`inline-flex items-center gap-1 font-mono tabular-nums`,B>0?`text-foreground/70`:`text-muted-foreground/50`),children:[(0,Z.jsx)(z,{className:`h-3 w-3`}),B,` with files`]})]}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:m?(0,Z.jsx)(Z.Fragment,{children:`Global, workspace-agnostic skills for local MCPlexer instances to search and pull. Publishing here is an explicit repository action.`}):(0,Z.jsxs)(Z.Fragment,{children:[`A library of `,(0,Z.jsx)(`span`,{className:`text-foreground`,children:`how to do X`}),` recipes that any agent can ask for, read, and add to. Same surface as`,` `,(0,Z.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`mcpx__skill_search`}),`.`]})})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-end gap-2`,children:[(0,Z.jsx)(ae,{to:`/skills/graph`,children:(0,Z.jsxs)(O,{variant:`ghost`,size:`sm`,children:[(0,Z.jsx)(ne,{className:`mr-1.5 h-3 w-3`}),`Graph`]})}),(0,Z.jsxs)(O,{onClick:()=>E(!0),"data-testid":`skill-publish`,children:[(0,Z.jsx)(se,{className:`mr-2 h-4 w-4`}),m?`New global skill`:`New skill`]})]})]}),!m&&(0,Z.jsx)(tt,{onImported:u}),(0,Z.jsx)(we,{value:ee,onChange:h,onSubmit:le,searching:v,hits:g,onClear:()=>{h(``),_(null),x(null)}}),pe&&(0,Z.jsx)(dt,{icon:(0,Z.jsx)(Ce,{className:`h-4 w-4`}),title:`Semantic search unavailable`,description:`The embedding model is not configured or unreachable. Falling back to lexical search. Try simpler keyword queries.`}),K&&(0,Z.jsx)(dt,{icon:(0,Z.jsx)(re,{className:`h-4 w-4`}),title:`Connection lost`,description:`Cannot reach the gateway. Showing cached data if available.`}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[!m&&(0,Z.jsx)(Te,{value:e,onChange:t,workspaces:d??[]}),(0,Z.jsx)(Qe,{entries:n??[],selected:j,onToggle:L,onClear:()=>M(new Set)})]}),W&&!K&&(0,Z.jsx)(`div`,{className:`border border-destructive/40 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(oe,{className:`h-4 w-4 shrink-0`}),(0,Z.jsxs)(`span`,{children:[`API error: `,o]})]})}),r&&!n&&(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Z.jsx)(G,{className:`h-3.5 w-3.5 animate-spin`}),`Reading the registry…`]}),(0,Z.jsx)(ze,{count:8})]}),n&&n.length===0&&!U&&(0,Z.jsx)(ut,{serverMode:m,onPublish:()=>E(!0)}),n&&n.length>0&&(0,Z.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[minmax(0,400px)_minmax(0,1fr)]`,children:[(0,Z.jsxs)(`section`,{className:`min-w-0 space-y-3`,"aria-label":`Skill catalog`,children:[(0,Z.jsx)(lt,{visibleCount:ce.length,totalCount:V,searchActive:!!g,selectedTags:j.size,serverMode:m}),(0,Z.jsx)(Pe,{rows:ce,selectedName:S,searchHits:g,collapsed:N,groupCategories:!m,onToggleCategory:R,onSelect:de,onVersions:D,onDelete:A})]}),(0,Z.jsx)(`aside`,{className:`hidden min-w-0 lg:block`,"aria-label":`Skill viewer`,children:(0,Z.jsx)(`div`,{className:`sticky top-16 max-h-[calc(100vh-5rem)] overflow-y-auto`,children:(0,Z.jsx)(Ke,{name:S,onTagSet:u,onVersions:D,onDelete:A})})})]}),te&&S&&n&&n.length>0&&(0,Z.jsx)(`div`,{className:`lg:hidden`,children:(0,Z.jsx)(ft,{name:S,onTagSet:u,onVersions:D,onDelete:A,onClose:()=>w(!1)})}),(0,Z.jsx)(Je,{open:T,onOpenChange:E,serverMode:m,onPublished:()=>{E(!1),u()}}),(0,Z.jsx)(Xe,{name:ie,onOpenChange:e=>!e&&D(null),onTagSet:u}),(0,Z.jsx)(fe,{open:!!k,onOpenChange:e=>!e&&A(null),title:`Delete ${k?.name}@${k?.version}?`,description:`Soft-delete this version. Other versions are kept; the next-highest active version becomes the head.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:I})]})}function lt({visibleCount:e,totalCount:t,searchActive:n,selectedTags:r,serverMode:i}){return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border border-border/70 bg-card/40 px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:i?`Repository catalog`:`Catalog`}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-sm text-foreground`,children:n||r>0?`${e} of ${t} skills`:`${t} skills`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[n&&(0,Z.jsx)(`span`,{children:`search ranked`}),r>0&&(0,Z.jsxs)(`span`,{children:[r,` tag filter`,r===1?``:`s`]})]})]})}function ut({serverMode:e,onPublish:t}){return(0,Z.jsx)(_e,{testid:`skills-empty`,icon:(0,Z.jsx)(A,{className:`h-6 w-6`}),title:e?`No global skills yet`:`No skills yet`,description:e?(0,Z.jsx)(Z.Fragment,{children:`Publish a global skill here when you want the central repository to own it.`}):(0,Z.jsxs)(Z.Fragment,{children:[`Skills are `,(0,Z.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`SKILL.md`}),` recipes that teach an agent how to do one specific task. Publish your first one, or have an agent call`,` `,(0,Z.jsx)(`code`,{className:`text-[11px] text-foreground/80`,children:`mcpx__skill_publish`}),`.`]}),action:(0,Z.jsxs)(O,{onClick:t,"data-testid":`skill-publish-empty`,children:[(0,Z.jsx)(se,{className:`mr-2 h-4 w-4`}),e?`Publish global skill`:`Publish a skill`]})})}function dt({icon:e,title:t,description:n}){return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 border border-amber-500/30 bg-amber-500/5 px-4 py-3`,children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0 text-amber-500`,children:e}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:n})]})]})}function ft({name:e,onTagSet:t,onVersions:n,onDelete:r,onClose:i}){return(0,Z.jsxs)(`div`,{className:`fixed inset-x-0 bottom-0 top-[calc(3rem+env(safe-area-inset-top))] z-40 flex flex-col overflow-hidden border-t border-border bg-background lg:hidden`,children:[(0,Z.jsxs)(`div`,{className:`sticky top-0 z-10 flex shrink-0 items-center gap-3 border-b border-border bg-background/95 px-4 py-2 backdrop-blur-sm`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),(0,Z.jsx)(`button`,{type:`button`,onClick:i,className:`grid h-8 w-8 shrink-0 place-items-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,"aria-label":`Close detail`,children:(0,Z.jsx)(j,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 pb-[calc(1rem+env(safe-area-inset-bottom))]`,children:(0,Z.jsx)(Ke,{name:e,onTagSet:t,onVersions:n,onDelete:r})})]})}export{ct as SkillRegistryPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/TaskDetailPage-BxO7mb6P.js b/internal/web/dist/assets/TaskDetailPage-BxO7mb6P.js deleted file mode 100644 index aa2017c..0000000 --- a/internal/web/dist/assets/TaskDetailPage-BxO7mb6P.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,Ft as r,in as i,on as a,r as o}from"./client-CaIRceNv.js";import{t as s}from"./createLucideIcon-WB390fY6.js";import{t as c}from"./arrow-up-CWTnU2zx.js";import{t as l}from"./chevron-right-CyhRDGe7.js";import{i as u,n as ee,r as d,t as te}from"./TaskEditDialog-CkXGM0xr.js";import{t as f}from"./cloud-upload-RBqzNp3t.js";import{t as p}from"./message-square-DS3HSgxP.js";import{t as m}from"./network-CrANvqlb.js";import{t as ne}from"./pencil-Dy4EC74G.js";import{t as re}from"./pin-off-CPMgqeYV.js";import{t as ie}from"./pin-C0Q-Achd.js";import{t as ae}from"./workflow-COO0Sn-w.js";import{An as h,Bn as oe,Br as se,Fn as g,Fr as _,Ft as v,H as ce,J as y,K as b,L as le,Lr as ue,Mn as x,N as de,Nn as S,On as C,Or as fe,P as pe,Pt as w,Qn as T,R as me,Rr as he,S as E,Y as ge,_ as D,br as _e,fr as ve,hr as O,j as ye,jn as be,jr as k,kn as A,lr as j,mr as M,n as xe,nr as N,q as Se,t as Ce,y as P,z as we,zn as Te,zr as Ee}from"./index-BDLzoIgt.js";import{a as De,c as Oe,d as ke,f as F,h as Ae,i as I,l as je,m as Me,n as Ne,o as L,p as Pe,r as Fe,s as Ie,t as Le}from"./task-utils-BkVzAeUR.js";import{n as Re}from"./TaskRef-D6QBTHtc.js";import{t as ze}from"./use-tasks-stream-BfVVn1xh.js";import{t as Be}from"./markdown-BxN4l9DE.js";import{t as Ve}from"./textarea-BiOhexhg.js";var He=s(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Ue=s(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),We=s(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),Ge=s(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),Ke=s(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),qe=s(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),Je=s(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),R=e(t(),1),z=a();function B(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean).pop()??``;if(/^\d+$/.test(t))return`PR #${t}`;if(t)return t}catch{}return`PR`}function V(e){return e.length<=6?e:e.slice(-6)}function H(e){return e.length<=8?e:e.slice(0,8)}function U(e){return e.length<=8?e:e.slice(0,8)}function Ye({task:e,onUpdate:t}){let n=b(e.meta),r=n.worktree||n.branch||n.pr||n.commits||n.peer||n.session||n.linear||n.mesh_thread,[i,a]=(0,R.useState)(!1);return(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,z.jsx)(`h2`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Work context`}),(0,z.jsx)(g,{variant:`ghost`,size:`sm`,className:`h-6 px-1.5 text-[10px]`,onClick:()=>a(!0),children:r?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ne,{className:`h-3 w-3`}),`Edit`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(T,{className:`h-3 w-3`}),`Add`]})})]}),r?(0,z.jsxs)(`ul`,{className:`space-y-1.5 text-xs`,children:[n.pr?(0,z.jsx)(W,{icon:(0,z.jsx)(M,{className:`h-3 w-3`}),children:(0,z.jsx)(`a`,{href:n.pr,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-primary hover:underline`,title:n.pr,children:B(n.pr)})}):null,n.branch?(0,z.jsxs)(W,{icon:(0,z.jsx)(j,{className:`h-3 w-3`}),children:[(0,z.jsx)(`span`,{className:`font-mono`,children:n.branch}),(0,z.jsx)(D,{value:`git checkout ${n.branch}`,className:`ml-1 h-5 w-5`})]}):null,n.worktree?(0,z.jsxs)(W,{icon:(0,z.jsx)(ae,{className:`h-3 w-3`}),children:[(0,z.jsx)(`span`,{className:`truncate font-mono`,title:n.worktree,children:n.worktree}),(0,z.jsx)(D,{value:n.worktree,className:`ml-1 h-5 w-5`})]}):null,n.commits?(0,z.jsx)(W,{icon:(0,z.jsx)(He,{className:`h-3 w-3`}),children:(0,z.jsx)(`span`,{className:`font-mono`,title:n.commits,children:n.commits})}):null,n.peer?(0,z.jsx)(W,{icon:(0,z.jsx)(m,{className:`h-3 w-3`}),children:(0,z.jsxs)(_,{to:`/peers/${encodeURIComponent(n.peer)}`,className:`font-mono text-primary hover:underline`,title:n.peer,children:[`peer:`,V(n.peer)]})}):null,n.session?(0,z.jsx)(W,{icon:(0,z.jsx)(We,{className:`h-3 w-3`}),children:(0,z.jsx)(`span`,{className:`font-mono`,title:n.session,children:H(n.session)})}):null,n.linear?(0,z.jsx)(W,{icon:(0,z.jsx)(qe,{className:`h-3 w-3`}),children:(0,z.jsx)(`a`,{href:`https://linear.app/ticket/${encodeURIComponent(n.linear)}`,target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-primary hover:underline`,children:n.linear})}):null,n.mesh_thread?(0,z.jsx)(W,{icon:(0,z.jsx)(p,{className:`h-3 w-3`}),children:(0,z.jsxs)(_,{to:`/mesh?thread=${encodeURIComponent(n.mesh_thread)}`,className:`font-mono text-primary hover:underline`,title:n.mesh_thread,children:[`thread:`,U(n.mesh_thread)]})}):null]}):(0,z.jsx)(`p`,{className:`text-[11px] text-muted-foreground/60`,children:`No work-context set. Use the Add button to point at a branch, PR, peer, or thread.`}),(0,z.jsx)(G,{open:i,onOpenChange:a,task:e,initial:n,onSaved:()=>{a(!1),t()}})]})}function W({icon:e,children:t}){return(0,z.jsxs)(`li`,{className:`flex items-center gap-1.5 border border-border bg-card/40 px-2 py-1`,children:[(0,z.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e}),(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t})]})}function G({open:e,onOpenChange:t,task:n,initial:r,onSaved:i}){let[a,o]=(0,R.useState)(r),[s,c]=(0,R.useState)(!1);return(0,R.useEffect)(()=>{e&&o(r)},[e,r]),(0,z.jsx)(C,{open:e,onOpenChange:t,children:(0,z.jsxs)(A,{className:`max-w-md`,children:[(0,z.jsxs)(x,{children:[(0,z.jsx)(S,{children:`Work context`}),(0,z.jsx)(h,{children:`Point this task at the branch, PR, peer, or mesh thread where the work actually lives. Empty fields clear the existing value.`})]}),(0,z.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,z.jsx)(K,{label:`Branch`,placeholder:`feat/x`,children:(0,z.jsx)(v,{value:a.branch??``,onChange:e=>o({...a,branch:e.target.value}),placeholder:`feat/x`})}),(0,z.jsx)(K,{label:`PR URL`,placeholder:`https://github.com/owner/repo/pull/42`,children:(0,z.jsx)(v,{value:a.pr??``,onChange:e=>o({...a,pr:e.target.value}),placeholder:`https://github.com/owner/repo/pull/42`})}),(0,z.jsx)(K,{label:`Worktree`,placeholder:`/abs/path/to/worktree`,children:(0,z.jsx)(v,{value:a.worktree??``,onChange:e=>o({...a,worktree:e.target.value}),placeholder:`/abs/path/to/worktree`})}),(0,z.jsx)(K,{label:`Commits`,placeholder:`abc1234..def5678`,children:(0,z.jsx)(v,{value:a.commits??``,onChange:e=>o({...a,commits:e.target.value}),placeholder:`abc1234..def5678`})}),(0,z.jsx)(K,{label:`Linear`,placeholder:`ENG-123`,children:(0,z.jsx)(v,{value:a.linear??``,onChange:e=>o({...a,linear:e.target.value}),placeholder:`ENG-123`})}),(0,z.jsx)(K,{label:`Peer`,placeholder:`libp2p peer id (46-52 chars)`,children:(0,z.jsx)(v,{value:a.peer??``,onChange:e=>o({...a,peer:e.target.value}),placeholder:`QmYwAPJzv5...`})}),(0,z.jsx)(K,{label:`Session`,placeholder:`session id`,children:(0,z.jsx)(v,{value:a.session??``,onChange:e=>o({...a,session:e.target.value}),placeholder:`dashboard-9f9f`})}),(0,z.jsx)(K,{label:`Mesh thread`,placeholder:`thread root id`,children:(0,z.jsx)(v,{value:a.mesh_thread??``,onChange:e=>o({...a,mesh_thread:e.target.value}),placeholder:`01THREADROOT`})})]}),(0,z.jsxs)(be,{children:[(0,z.jsx)(g,{variant:`ghost`,onClick:()=>t(!1),disabled:s,children:`Cancel`}),(0,z.jsxs)(g,{onClick:async()=>{c(!0);try{await y(n.workspace_id,n.id,{worktree:a.worktree??``,branch:a.branch??``,pr:a.pr??``,commits:a.commits??``,peer:a.peer??``,session:a.session??``,linear:a.linear??``,mesh_thread:a.mesh_thread??``}),k.success(`Work context updated`),i()}catch(e){k.error(e instanceof Error?e.message:`Update failed`)}finally{c(!1)}},disabled:s,children:[s?(0,z.jsx)(N,{className:`h-3 w-3 animate-spin`}):null,`Save`]})]})]})})}function K({label:e,children:t}){return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(w,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:e}),t]})}function q(e){return r(`/tasks/${encodeURIComponent(e)}/attachments`)}async function J(e,t,n){let r=new FormData;r.append(`file`,t,t.name);let i={};n&&(i.Authorization=`Bearer ${n}`);let a=await fetch(o(`/tasks/${encodeURIComponent(e)}/attachments`),{method:`POST`,body:r,headers:i,credentials:`same-origin`});if(!a.ok){let e=await a.text();throw Error(`upload failed: ${a.status} ${e}`)}return await a.json()}function Y(e){return o(`/attachments/${encodeURIComponent(e)}`)}function Xe(e){return r(`/attachments/${encodeURIComponent(e)}`,{method:`DELETE`})}function Ze(e){return e<1e3?`${e} B`:e<1e6?`${(e/1e3).toFixed(1)} KB`:e<1e9?`${(e/1e6).toFixed(1)} MB`:`${(e/1e9).toFixed(2)} GB`}function Qe({taskId:e}){let[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(!1),ee=(0,R.useRef)(null),d=(0,R.useCallback)(async()=>{i(!0);try{n(await q(e))}catch(e){k.error(`Failed to load attachments: `+String(e))}finally{i(!1)}},[e]);(0,R.useEffect)(()=>{d()},[d]);let te=(0,R.useCallback)(async t=>{let n=Array.from(t);if(n.length!==0){o(!0);try{for(let t of n)await J(e,t);k.success(n.length===1?`Attached ${n[0].name}`:`Attached ${n.length} files`),await d()}catch(e){k.error(`Upload failed: `+String(e))}finally{o(!1)}}},[e,d]);return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:(0,z.jsxs)(`h3`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70`,children:[(0,z.jsx)(Ke,{className:`mr-1 inline h-3 w-3`}),`Attachments `,t.length>0&&(0,z.jsxs)(`span`,{className:`ml-1 text-muted-foreground/60`,children:[`(`,t.length,`)`]})]})}),r&&t.length===0?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground/70`,children:[(0,z.jsx)(N,{className:`h-3 w-3 animate-spin`}),`loading…`]}):(0,z.jsxs)(z.Fragment,{children:[t.length>0&&(0,z.jsx)(`ul`,{className:`mb-3 space-y-1.5`,children:t.map(e=>(0,z.jsx)(X,{row:e,onDelete:()=>c(e)},e.id))}),(0,z.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),u(!0)},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0&&te(e.dataTransfer.files)},className:`flex flex-col items-center justify-center gap-1.5 rounded-sm border border-dashed px-3 py-4 text-[11px] text-muted-foreground/70 transition-colors `+(l?`border-primary bg-primary/5`:`border-border/60 hover:border-border`),"data-testid":`task-attachments-dropzone`,children:[(0,z.jsx)(f,{className:`h-4 w-4`}),a?(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(N,{className:`h-3 w-3 animate-spin`}),` uploading…`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{children:`Drag files here, or`}),(0,z.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>ee.current?.click(),"data-testid":`task-attachments-pick`,children:`pick a file`})]}),(0,z.jsx)(`input`,{ref:ee,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&(te(e.target.files),e.target.value=``)}})]})]}),s&&(0,z.jsx)(ye,{open:!0,onOpenChange:e=>{e||c(null)},title:`Remove attachment`,description:`Remove ${s.filename||s.id}? The on-disk blob is preserved for the audit trail; only the index row is soft-deleted.`,confirmLabel:`Remove`,variant:`destructive`,onConfirm:async()=>{if(s)try{await Xe(s.id),k.success(`Removed attachment`),c(null),await d()}catch(e){k.error(`Delete failed: `+String(e))}}})]})}function X({row:e,onDelete:t}){let n=e.mime_type.startsWith(`image/`);return(0,z.jsxs)(`li`,{className:`group flex items-center gap-2 rounded-sm border border-border/60 bg-card/30 px-2 py-1.5 text-[12px]`,children:[n?(0,z.jsx)(`img`,{src:Y(e.id),alt:e.filename,className:`h-8 w-8 shrink-0 rounded-sm object-cover`,loading:`lazy`}):(0,z.jsx)(n?Ge:ve,{className:`h-4 w-4 shrink-0 text-muted-foreground/70`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate font-medium`,title:e.filename,children:e.filename||e.id}),(0,z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/60`,children:[Ze(e.size_bytes),` · `,e.mime_type||`unknown`,` ·`,` `,new Date(e.created_at).toLocaleString()]})]}),(0,z.jsx)(`a`,{href:Y(e.id),download:e.filename||e.id,className:`rounded-sm p-1 text-muted-foreground/70 opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100`,title:`Download`,"aria-label":`Download attachment ${e.filename||e.id}`,"data-testid":`task-attachment-download`,children:(0,z.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(`button`,{onClick:t,className:`rounded-sm p-1 text-muted-foreground/70 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100`,title:`Remove`,"aria-label":`Remove attachment ${e.filename||e.id}`,"data-testid":`task-attachment-delete`,children:(0,z.jsx)(oe,{className:`h-3.5 w-3.5`})})]})}function $e(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}var et=`mcplexer.dashboardSessionId`;function Z(){if(typeof window>`u`)return`dashboard`;try{let e=window.sessionStorage.getItem(et);if(e)return e;let t=`dashboard-${crypto.randomUUID().slice(0,8)}`;return window.sessionStorage.setItem(et,t),t}catch{return`dashboard`}}function tt(){let{id:e=``}=Ee(),t=he(),r=ue(),[a]=se(),o=a.get(`workspace`)??``,[s,f]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(!(typeof r.state==`object`&&r.state!==null&&r.state.pulse===!0))return;f(!0),t(r.pathname+r.search,{replace:!0,state:null});let e=window.setTimeout(()=>f(!1),2400);return()=>window.clearTimeout(e)},[r.state,r.pathname,r.search,t]);let{data:p}=E((0,R.useCallback)(()=>n(),[])),{data:m,loading:ae,error:h,refetch:v}=E((0,R.useCallback)(()=>!o||!e?Promise.resolve(null):me(o,e),[o,e])),y=Ae(3e4),{vocab:b}=d(o||null),x=ee(),{data:S,refetch:C}=E((0,R.useCallback)(()=>!o||!e?Promise.resolve([]):ce(o,e,200),[o,e]));ze({workspaceId:o||void 0,disabled:!o||!e,onEvent:t=>{if((t.task?.id??t.note?.task_id)===e){if(t.kind===`task_note_appended`){C();return}v(),C()}}}),(0,R.useEffect)(()=>{if(!m||!o||m.assignee_user_id)return;let e=Z();if(m.assignee_session_id!==e||m.closed_at)return;let t=!1,n=()=>{we(o,m.id,e).catch(()=>{})};n();let r=window.setInterval(()=>{t||n()},6e4);return()=>{t=!0,window.clearInterval(r)}},[m,o]);let[w,T]=(0,R.useState)(null),[ve,O]=(0,R.useState)(!1),[be,A]=(0,R.useState)(!1),[j,M]=(0,R.useState)(``),He=(0,R.useCallback)(async()=>{if(m){T(`claim`);try{await pe(m.workspace_id,m.id,{session_id:Z()}),k.success(`Claimed`),v()}catch(e){k.error(e instanceof Error?e.message:`Claim failed`)}finally{T(null)}}},[m,v]),We=(0,R.useCallback)(async()=>{if(m){T(`pin`);try{await ge(m.workspace_id,m.id,{pinned:!m.pinned}),v()}catch(e){k.error(e instanceof Error?e.message:`Pin failed`)}finally{T(null)}}},[m,v]),Ge=(0,R.useCallback)(async()=>{if(m){T(`terminal`);try{await ge(m.workspace_id,m.id,{terminal:!m.closed_at}),k.success(m.closed_at?`Reopened`:`Closed`),v()}catch(e){k.error(e instanceof Error?e.message:`Update failed`)}finally{T(null)}}},[m,v]),Ke=(0,R.useCallback)(async()=>{if(m){T(`delete`);try{await le(m.workspace_id,m.id),k.success(`Deleted`),t(`/tasks`)}catch(e){k.error(e instanceof Error?e.message:`Delete failed`),T(null)}}},[m,t]),qe=(0,R.useCallback)(async()=>{if(!(!m||!j.trim())){T(`note`);try{await de(m.workspace_id,m.id,{body:j,author_kind:`user`}),M(``),C()}catch(e){k.error(e instanceof Error?e.message:`Append failed`)}finally{T(null)}}},[m,j,C]);if(!o)return(0,z.jsx)(Ce,{children:(0,z.jsxs)(xe,{className:`py-8 text-center text-sm text-muted-foreground`,children:[`A task URL needs a workspace id. `,(0,z.jsx)(_,{to:`/tasks`,className:`text-primary hover:underline`,children:`Back to all tasks`}),`.`]})});if(ae&&!m)return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsx)(N,{className:`h-4 w-4 animate-spin`}),`loading task `,F(e),`…`]});if(h||!m)return(0,z.jsx)(Ce,{children:(0,z.jsxs)(xe,{className:`space-y-3 py-8 text-center text-sm`,children:[(0,z.jsx)(`p`,{className:`text-destructive`,children:h??`Task not found`}),(0,z.jsxs)(_,{to:`/tasks`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,z.jsx)(fe,{className:`h-3.5 w-3.5`}),`All tasks`]})]})});let B=ke(m.priority),V=Pe(m.status,!!m.closed_at),H=Fe(m.due_at??null,m.closed_at??null),U=Se(m.meta,`composes`),W=Se(m.meta,`composed_by`),G=m.status_history??[],K=p?.find(e=>e.id===m.workspace_id)?.name??F(m.workspace_id),q=Me(G,y),J=Ne(G,y),Y=je(m.status,m.assignee_session_id,m.closed_at,x.ready?x.sessionIds:null,b),Xe=Z(),Ze=m.assignee_session_id===Xe,X=Ie(m);return(0,z.jsxs)(`div`,{className:`space-y-5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,z.jsxs)(_,{to:`/tasks`,className:`inline-flex items-center gap-1 hover:text-foreground`,children:[(0,z.jsx)(fe,{className:`h-3.5 w-3.5`}),`Tasks`]}),(0,z.jsx)(l,{className:`h-3.5 w-3.5`}),(0,z.jsx)(_,{to:`/tasks/all?workspace=${encodeURIComponent(m.workspace_id)}`,className:`hover:text-foreground`,children:K}),(0,z.jsx)(l,{className:`h-3.5 w-3.5`}),(0,z.jsx)(`span`,{className:`font-mono text-xs`,children:F(m.id)}),(0,z.jsx)(D,{value:m.id,className:`h-5 w-5`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:We,disabled:w===`pin`,children:[m.pinned?(0,z.jsx)(re,{className:`h-4 w-4`}):(0,z.jsx)(ie,{className:`h-4 w-4`}),m.pinned?`Unpin`:`Pin`]}),!m.assignee_session_id&&!m.assignee_user_id?(0,z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:He,disabled:w===`claim`,children:[w===`claim`?(0,z.jsx)(N,{className:`h-4 w-4 animate-spin`}):(0,z.jsx)(Ue,{className:`h-4 w-4`}),`Claim`]}):null,(0,z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:Ge,disabled:w===`terminal`,children:[m.closed_at?(0,z.jsx)(Je,{className:`h-4 w-4`}):(0,z.jsx)(_e,{className:`h-4 w-4`}),m.closed_at?`Reopen`:`Close`]}),(0,z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:()=>O(!0),children:[(0,z.jsx)(ne,{className:`h-4 w-4`}),`Edit`]}),(0,z.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:()=>A(!0),className:`text-destructive hover:text-destructive`,children:[(0,z.jsx)(oe,{className:`h-4 w-4`}),`Delete`]})]})]}),Y.state===`abandoned`&&!m.closed_at?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm text-amber-200`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,z.jsx)(Te,{className:`h-4 w-4`}),(0,z.jsxs)(`span`,{children:[`Assignee `,(0,z.jsx)(`span`,{className:`font-mono`,children:m.assignee_session_id?.slice(0,8)??`—`}),` is no longer on the mesh — task abandoned.`]})]}),(0,z.jsxs)(g,{size:`sm`,variant:`ghost`,onClick:He,disabled:w===`claim`,children:[w===`claim`?(0,z.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,z.jsx)(Ue,{className:`h-3.5 w-3.5`}),`Reclaim`]})]}):null,(0,z.jsxs)(`header`,{className:i(`space-y-2 border border-border bg-card/40 p-4 transition-colors duration-700`,s&&`bg-primary/10 ring-1 ring-primary/40`),children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,z.jsx)(`span`,{className:i(`mt-1 inline-block h-2.5 w-2.5 shrink-0 rounded-full`,B.dot),title:`priority: ${m.priority}`}),(0,z.jsx)(`h1`,{className:i(`text-xl font-semibold tracking-tight`,m.closed_at?`line-through opacity-70`:``),children:m.title}),(0,z.jsxs)(P,{variant:`outline`,tone:V.tone,className:i(`text-[11px]`,V.mono?`font-mono`:``),children:[m.status,Oe(m.status,b)&&q>0?(0,z.jsxs)(`span`,{className:`ml-1 font-mono text-foreground/60`,children:[`· `,De(q)]}):null]}),(0,z.jsx)(P,{variant:`outline`,tone:B.tone,className:`text-[11px]`,children:m.priority}),Ze?(0,z.jsxs)(P,{variant:`outline`,tone:`info`,className:`text-[11px]`,children:[(0,z.jsx)(u,{className:`h-3 w-3 fill-primary text-primary`}),`you`]}):null,X?(0,z.jsxs)(P,{variant:`outline`,tone:`info`,className:`text-[11px]`,children:[(0,z.jsx)(`span`,{className:`mr-0.5 font-mono text-[11px]`,children:`@`}),`human`]}):null,m.pinned?(0,z.jsxs)(P,{variant:`outline`,tone:`warn`,className:`text-[11px]`,children:[(0,z.jsx)(ie,{className:`h-3 w-3`}),`pinned`]}):null]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,z.jsx)($,{label:`assignee`,value:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[X?(0,z.jsx)(`span`,{className:`text-[10px] text-primary/80`,children:`@`}):(0,z.jsx)(u,{className:i(`h-2 w-2`,m.assignee_session_id||m.assignee_peer_id?`fill-primary/80 text-primary/80`:`text-muted-foreground/40`)}),(0,z.jsx)(`span`,{className:i(X&&`text-primary/90`),children:X?`human:${m.assignee_user_id}`:Le(m)})]})}),H.label?(0,z.jsx)($,{label:`due`,value:(0,z.jsx)(`span`,{className:i(`font-mono`,H.state===`overdue`?`text-red-400`:H.state===`soon`?`text-amber-300`:``),title:I(m.due_at),children:H.label})}):null,(0,z.jsx)($,{label:`created`,value:(0,z.jsx)(`span`,{title:I(m.created_at),children:L(m.created_at)})}),(0,z.jsx)($,{label:`updated`,value:(0,z.jsx)(`span`,{title:I(m.updated_at),children:L(m.updated_at)})}),J>0?(0,z.jsx)($,{label:`worked`,value:(0,z.jsx)(`span`,{className:`font-mono`,title:`Cumulative time the task spent in a working status`,children:De(J)})}):null,(0,z.jsx)($,{label:`source`,value:(0,z.jsx)(`span`,{className:`font-mono uppercase tracking-wider`,children:m.source_kind})}),m.origin_peer_id?(0,z.jsx)($,{label:`from peer`,value:(0,z.jsx)(`span`,{className:`font-mono`,children:m.origin_peer_id.slice(-6)})}):null]}),(m.tags??[]).length>0?(0,z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(m.tags??[]).map(e=>(0,z.jsx)(_,{to:`/tasks?tag=${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 border border-border bg-muted/30 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground hover:border-primary/40 hover:text-foreground`,children:e},e))}):null]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-[1fr_320px]`,children:[(0,z.jsxs)(`div`,{className:`space-y-5 min-w-0`,children:[(0,z.jsxs)(`section`,{children:[(0,z.jsx)(Q,{children:`Description`}),(0,z.jsx)(`div`,{className:`border border-border bg-card/40 p-4`,children:m.description?(0,z.jsx)(Be,{source:m.description,workspaceId:m.workspace_id}):(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`No description.`})})]}),(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(Q,{children:[`Notes `,(0,z.jsxs)(`span`,{className:`font-mono text-[10px] text-muted-foreground/60`,children:[`(`,S?.length??0,`)`]})]}),(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsxs)(`div`,{className:`border border-border bg-card/40 p-3`,children:[(0,z.jsx)(Ve,{value:j,onChange:e=>M(e.target.value),rows:2,placeholder:`append a note (visible to anyone with workspace access)…`,className:`resize-y`}),(0,z.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,z.jsx)(`span`,{children:`Notes are append-only and audited.`}),(0,z.jsxs)(g,{size:`sm`,onClick:qe,disabled:w===`note`||!j.trim(),children:[w===`note`?(0,z.jsx)(N,{className:`h-3 w-3 animate-spin`}):(0,z.jsx)(c,{className:`h-3 w-3`}),`Post`]})]})]}),(S??[]).length===0?(0,z.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground/60`,children:`No notes yet.`}):(0,z.jsx)(`ul`,{className:`space-y-2`,children:(S??[]).map(e=>(0,z.jsx)(nt,{note:e,workspaceId:m.workspace_id},e.id))})]})]})]}),(0,z.jsxs)(`aside`,{className:`space-y-5`,children:[(0,z.jsxs)(`section`,{children:[(0,z.jsx)(Q,{children:`Status history`}),(0,z.jsxs)(`ol`,{className:`relative space-y-2 border-l border-border pl-4`,children:[[...G].reverse().map((e,t)=>(0,z.jsxs)(`li`,{className:`relative`,children:[(0,z.jsx)(`span`,{className:`absolute -left-[19px] top-1.5 inline-block h-2 w-2 rounded-full bg-primary/70`}),(0,z.jsxs)(`div`,{className:`text-xs`,children:[(0,z.jsx)(`span`,{className:`font-mono uppercase tracking-wider text-muted-foreground`,children:e.evt}),e.from||e.to?(0,z.jsxs)(`span`,{className:`ml-1 text-muted-foreground/80`,children:[e.from?(0,z.jsx)(`span`,{className:`font-mono`,children:e.from}):null,e.from&&e.to?(0,z.jsx)(`span`,{className:`mx-1 opacity-50`,children:`→`}):null,e.to?(0,z.jsx)(`span`,{className:`font-mono text-foreground`,children:e.to}):null]}):null]}),(0,z.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/70`,title:I(e.at),children:[L(e.at),e.by_session?(0,z.jsxs)(`span`,{className:`ml-1 font-mono`,children:[`· `,e.by_session.slice(0,8)]}):null,e.by_peer?(0,z.jsxs)(`span`,{className:`ml-1 font-mono`,children:[`· peer:`,e.by_peer.slice(-4)]}):null]})]},t)),G.length===0?(0,z.jsx)(`li`,{className:`text-[11px] text-muted-foreground/60`,children:`No events yet.`}):null]})]}),(0,z.jsx)(Ye,{task:m,onUpdate:v}),(0,z.jsx)(Qe,{taskId:m.id}),W.length>0||U.length>0?(0,z.jsxs)(`section`,{children:[(0,z.jsx)(Q,{children:`Composition`}),(0,z.jsxs)(`div`,{className:`space-y-3 text-xs`,children:[W.length>0?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:`part of`}),(0,z.jsx)(`ul`,{className:`space-y-1`,children:W.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsx)(Re,{id:e,workspaceId:m.workspace_id,variant:`inline`})},e))})]}):null,U.length>0?(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:`epic of`}),(0,z.jsx)(`ul`,{className:`space-y-1`,children:U.map(e=>(0,z.jsx)(`li`,{children:(0,z.jsx)(Re,{id:e,workspaceId:m.workspace_id,variant:`inline`})},e))})]}):null]})]}):null,m.meta?(0,z.jsxs)(`section`,{children:[(0,z.jsx)(Q,{children:`Meta`}),(0,z.jsx)(`pre`,{className:`border border-border bg-card/40 p-2 font-mono text-[10px] text-muted-foreground/80 overflow-x-auto whitespace-pre-wrap`,children:$e(m.meta)})]}):null]})]}),(0,z.jsx)(te,{mode:`edit`,task:m,open:ve,onOpenChange:O,workspaces:p??[],onSaved:e=>{k.success(`Saved`),v(),e.workspace_id!==o&&t(`/tasks/${encodeURIComponent(e.id)}?workspace=${encodeURIComponent(e.workspace_id)}`,{replace:!0})}}),(0,z.jsx)(ye,{open:be,onOpenChange:A,title:`Delete this task?`,description:`Soft-delete ${F(m.id)}. The row stays in the DB with deleted_at set so the audit trail survives; this is reversible (an admin can call task__update with deleted_at=null via the gateway's admin MCP tools).`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:Ke})]})}function Q({children:e}){return(0,z.jsx)(`h2`,{className:`mb-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e})}function $({label:e,value:t}){return(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:e}),t]})}function nt({note:e,workspaceId:t}){return(0,z.jsxs)(`li`,{className:`border border-border bg-card/40 p-3`,children:[(0,z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-[10px] text-muted-foreground/70`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono uppercase tracking-wider`,children:e.author_kind??`agent`}),e.author_session_id?(0,z.jsxs)(`span`,{className:`font-mono`,children:[`· `,e.author_session_id.slice(0,8)]}):null]}),(0,z.jsx)(`span`,{title:I(e.created_at),children:L(e.created_at)})]}),(0,z.jsx)(Be,{source:e.body,workspaceId:t})]})}export{tt as TaskDetailPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/TaskEditDialog-CkXGM0xr.js b/internal/web/dist/assets/TaskEditDialog-CkXGM0xr.js deleted file mode 100644 index e3ecb16..0000000 --- a/internal/web/dist/assets/TaskEditDialog-CkXGM0xr.js +++ /dev/null @@ -1,3 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{W as n,in as r,on as i}from"./client-CaIRceNv.js";import{t as a}from"./createLucideIcon-WB390fY6.js";import{An as o,F as s,Fn as c,Ft as l,Ln as u,Mn as d,Nn as f,On as p,Pt as m,Qn as h,S as g,W as _,Y as v,jn as y,jr as b,kn as x,nr as S}from"./index-BDLzoIgt.js";import{t as C}from"./textarea-BiOhexhg.js";var w=a(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),T=e(t(),1),E=new Map;function D(e){let t=e??``,{data:n,loading:r,error:i,refetch:a}=g((0,T.useCallback)(async()=>t?_(t):[],[t]));return{vocab:(0,T.useMemo)(()=>{if(!n||n.length===0)return E;let e=new Map;for(let t of n)t.status_text&&e.set(t.status_text,t.kind??`open`);return e},[n]),raw:n??[],loading:r,error:i,refetch:a}}var O=300*1e3,k=3e4;function A(){let{data:e,refetch:t}=g((0,T.useCallback)(()=>n(),[])),[r,i]=(0,T.useState)(0);return(0,T.useEffect)(()=>{let e=setInterval(()=>{t(),i(e=>e+1)},k);return()=>clearInterval(e)},[t]),(0,T.useMemo)(()=>{if(!e)return{sessionIds:new Set,ready:!1};let t=Date.now(),n=new Set;for(let r of e.agents??[]){let e=new Date(r.last_seen_at).getTime();Number.isNaN(e)||t-e<=O&&n.add(r.session_id)}return{sessionIds:n,ready:!0}},[e,r])}var j=i(),M=[{id:`low`,label:`Low`},{id:`normal`,label:`Normal`},{id:`high`,label:`High`},{id:`critical`,label:`Critical`}];function N(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function P(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()}function F(e){return e.assignee_user_id?e.assignee_user_id:e.assignee_peer_id&&e.assignee_session_id?`${e.assignee_peer_id}:${e.assignee_session_id}`:e.assignee_session_id||e.assignee_peer_id||``}function I(e){let t=e.trim();if(!t)return;if(t.startsWith(`user:`))return{user_id:t.slice(5).trim()};let n=t.indexOf(`:`);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();return{peer_id:e||void 0,session_id:r||void 0}}return{session_id:t}}function L(e){let t=e.mode===`edit`,n=(0,T.useMemo)(()=>t?{workspaceId:e.task.workspace_id,title:e.task.title,description:e.task.description??``,status:e.task.status,priority:e.task.priority||`normal`,dueAtLocal:N(e.task.due_at),tags:e.task.tags??[],meta:e.task.meta??``,assignee:F(e.task),composeInto:``}:{workspaceId:e.defaultWorkspaceId??``,title:``,description:``,status:`open`,priority:`normal`,dueAtLocal:``,tags:[],meta:``,assignee:e.initialAssignee??``,composeInto:e.composeInto??``},[e,t]),[i,a]=(0,T.useState)(n.workspaceId),[m,g]=(0,T.useState)(n.title),[_,w]=(0,T.useState)(n.description),[E,D]=(0,T.useState)(n.status),[O,k]=(0,T.useState)(n.priority),[A,L]=(0,T.useState)(n.dueAtLocal),[z,B]=(0,T.useState)(``),[V,H]=(0,T.useState)(n.tags),[U,W]=(0,T.useState)(n.meta),[G,K]=(0,T.useState)(t&&e.task.assignee_user_id?`user`:t&&e.task.assignee_session_id?`session`:`none`),[q,J]=(0,T.useState)(n.assignee),[Y,X]=(0,T.useState)(n.composeInto),[Z,Q]=(0,T.useState)(!1);(0,T.useEffect)(()=>{e.open&&(a(n.workspaceId),g(n.title),w(n.description),D(n.status),k(n.priority),L(n.dueAtLocal),B(``),H(n.tags),W(n.meta),J(n.assignee),X(n.composeInto),K(t&&e.task.assignee_user_id?`user`:t&&e.task.assignee_session_id?`session`:`none`))},[e.open,n]);function $(){let e=z.trim();e&&(V.includes(e)||H([...V,e]),B(``))}async function ee(n){if(n.preventDefault(),!i){b.error(`workspace is required`);return}if(!m.trim()){b.error(`title is required`);return}Q(!0);try{if(t){let t={};m!==e.task.title&&(t.title=m),_!==(e.task.description??``)&&(t.description=_),E!==e.task.status&&(t.status=E),O!==e.task.priority&&(t.priority=O);let n=P(A);n!==(e.task.due_at??null)&&(t.due_at=n);let r=(e.task.tags??[]).join(` -`);if(V.join(` -`)!==r&&(t.tags=V),U!==(e.task.meta??``)&&(t.meta=U),G===`none`&&(e.task.assignee_session_id||e.task.assignee_peer_id||e.task.assignee_user_id))t.clear=[...t.clear??[],`assignee`];else if(G===`user`){let n=q.trim();e.task.assignee_user_id!==n&&(n?t.assignee={user_id:n}:t.clear=[...t.clear??[],`assignee`])}else if(G===`session`){let n=F(e.task);if(q.trim()!==n){let e=I(q);e?t.assignee=e:t.clear=[...t.clear??[],`assignee`]}}let i=await v(e.task.workspace_id,e.task.id,t);e.onSaved(i)}else{let t={workspace_id:i,title:m,description:_||void 0,status:E||void 0,priority:O,due_at:P(A),tags:V,meta:U||void 0,compose_into:Y||void 0};G===`user`&&q.trim()?t.assignee={user_id:q.trim()}:G===`session`&&q.trim()&&(t.assignee=I(q));let n=await s(t);e.onSaved(n)}e.onOpenChange(!1)}catch(e){b.error(e instanceof Error?e.message:`Save failed`)}finally{Q(!1)}}return(0,j.jsx)(p,{open:e.open,onOpenChange:e.onOpenChange,children:(0,j.jsx)(x,{className:`max-h-[90vh] overflow-y-auto sm:max-w-2xl`,children:(0,j.jsxs)(`form`,{onSubmit:ee,className:`space-y-4`,children:[(0,j.jsxs)(d,{children:[(0,j.jsx)(f,{children:t?`Edit task`:`New task`}),(0,j.jsx)(o,{children:t?`Patch existing fields. The status_history audit will record this change.`:`Create an operational task in a workspace. Agents will see it via task__list.`})]}),t?null:(0,j.jsx)(R,{label:`Workspace`,hint:`Required. Tasks are scoped per workspace.`,children:(0,j.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`h-8 w-full border border-border bg-background px-2 text-sm`,required:!0,children:[(0,j.jsx)(`option`,{value:``,children:`— select workspace —`}),e.workspaces.map(e=>(0,j.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,j.jsx)(R,{label:`Title`,hint:`One line. Imperative voice plays best.`,children:(0,j.jsx)(l,{value:m,onChange:e=>g(e.target.value),autoFocus:!0,required:!0,placeholder:`Patch the audit redaction for peer IDs`})}),(0,j.jsx)(R,{label:`Description`,hint:`Markdown-ish; rendered as preformatted text on the detail page.`,children:(0,j.jsx)(C,{value:_,onChange:e=>w(e.target.value),rows:4,placeholder:`What needs doing, and any pointers for an agent who picks it up.`})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,j.jsxs)(R,{label:`Status`,hint:`Freeform. Workspace vocabulary appears as suggestions.`,children:[(0,j.jsx)(l,{value:E,onChange:e=>D(e.target.value),placeholder:`open`,list:`task-status-suggestions`,className:`font-mono text-sm`}),(0,j.jsx)(`datalist`,{id:`task-status-suggestions`,children:[`open`,`doing`,`blocked`,`review`,`done`,`cancelled`].map(e=>(0,j.jsx)(`option`,{value:e},e))})]}),(0,j.jsx)(R,{label:`Priority`,children:(0,j.jsx)(`div`,{className:`inline-flex border border-border`,children:M.map(e=>(0,j.jsx)(`button`,{type:`button`,onClick:()=>k(e.id),className:r(`border-r border-border px-3 py-1 text-xs last:border-r-0`,O===e.id?`bg-accent text-accent-foreground`:`bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:e.label},e.id))})})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,j.jsx)(R,{label:`Due`,hint:`Local timezone; stored as RFC3339.`,children:(0,j.jsx)(`input`,{type:`datetime-local`,value:A,onChange:e=>L(e.target.value),className:`h-8 w-full border border-border bg-background px-2 text-sm`})}),(0,j.jsx)(R,{label:`Assignee`,hint:G===`user`?`Human user id (from the users surface). Routes to a person, not an agent.`:`Session id or peer:session. Blank = unassigned.`,children:(0,j.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,j.jsx)(`div`,{className:`inline-flex border border-border`,children:[{id:`none`,label:`unassigned`},{id:`session`,label:`session`},{id:`user`,label:`human`}].map(e=>(0,j.jsx)(`button`,{type:`button`,onClick:()=>K(e.id),className:r(`border-r border-border px-2.5 py-1 text-[11px] font-mono last:border-r-0`,G===e.id?`bg-accent text-accent-foreground`:`bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:e.label},e.id))}),G===`none`?null:(0,j.jsx)(l,{value:q,onChange:e=>J(e.target.value),placeholder:G===`user`?`user_xxx`:`sess_xxx or peer:sess_xxx`,className:`font-mono text-sm`})]})})]}),(0,j.jsx)(R,{label:`Tags`,hint:`Press Enter or comma to commit. Used in filters.`,children:(0,j.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border border-border bg-background px-2 py-1.5`,children:[V.map(e=>(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-border bg-muted/30 px-1.5 py-0.5 font-mono text-[11px]`,children:[e,(0,j.jsx)(`button`,{type:`button`,onClick:()=>H(V.filter(t=>t!==e)),"aria-label":`remove ${e}`,children:(0,j.jsx)(u,{className:`h-3 w-3`})})]},e)),(0,j.jsx)(`input`,{value:z,onChange:e=>B(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),$()):e.key===`Backspace`&&!z&&V.length&&H(V.slice(0,-1))},onBlur:$,className:`min-w-[120px] flex-1 bg-transparent text-sm outline-none`,placeholder:V.length===0?`add tag…`:``})]})}),t?null:(0,j.jsx)(R,{label:`Compose into (parent epic)`,hint:`Optional task id (full ULID). Adds this task to that parent's composes list.`,children:(0,j.jsx)(l,{value:Y,onChange:e=>X(e.target.value),placeholder:`01HXX...`,className:`font-mono text-sm`})}),(0,j.jsx)(R,{label:`Meta`,hint:`Frontmatter-style. composes / composed_by lines are read by the UI.`,children:(0,j.jsx)(C,{value:U,onChange:e=>W(e.target.value),rows:3,placeholder:`composes: task:abc, task:def`,className:`font-mono text-xs`})}),(0,j.jsxs)(y,{children:[(0,j.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>e.onOpenChange(!1),disabled:Z,children:`Cancel`}),(0,j.jsxs)(c,{type:`submit`,disabled:Z,children:[Z?(0,j.jsx)(S,{className:`h-4 w-4 animate-spin`}):t?null:(0,j.jsx)(h,{className:`h-4 w-4`}),t?`Save changes`:`Create task`]})]})]})})})}function R({label:e,hint:t,children:n}){return(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,j.jsx)(m,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),t?(0,j.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:t}):null]}),n]})}export{w as i,A as n,D as r,L as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/TaskOffersPage-Cv61jjJt.js b/internal/web/dist/assets/TaskOffersPage-Cv61jjJt.js deleted file mode 100644 index 729a86c..0000000 --- a/internal/web/dist/assets/TaskOffersPage-Cv61jjJt.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,in as r,on as i,t as a}from"./client-CaIRceNv.js";import{i as o,n as s,r as c,t as l}from"./tabs-Q9rOz2uL.js";import{t as u}from"./circle-x--B2BKH4R.js";import{t as d}from"./inbox-ClSTJaEn.js";import{n as f,t as p}from"./users-Bsr8fkGR.js";import{t as m}from"./share-2-Da_vtMGy.js";import{Fn as h,Fr as g,Gn as _,Hn as v,I as y,Lr as b,M as x,Or as S,Rr as C,S as w,U as T,br as E,d as D,f as O,jr as k,m as A,n as j,nr as M,p as N,t as P,u as F,y as I}from"./index-BDLzoIgt.js";import{t as L}from"./empty-state-B9mtYx_X.js";import{t as R}from"./use-tasks-stream-BfVVn1xh.js";var z=e(t(),1),B=i();function V(e){return e.length<=14?e:`${e.slice(0,10)}…${e.slice(-4)}`}function H(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function U({offer:e,workspaces:t,onChange:n}){let[i,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(!1),[l,d]=(0,z.useState)(``);async function f(t){o(`accept`);try{let r=await x(e.id,t);k.success(`Accepted "${r.title}"`),c(!1),n()}catch(e){e instanceof a&&e.status===428?c(!0):k.error(e instanceof Error?e.message:`Accept failed`)}finally{o(null)}}async function p(){o(`decline`);try{await y(e.id),k.success(`Offer declined`),n()}catch(e){k.error(e instanceof Error?e.message:`Decline failed`)}finally{o(null)}}let m=Array.isArray(e.tags)?e.tags:[],g=e.remote_workspace_name||e.remote_workspace_id,v=e.description_preview?.trim()||e.meta_preview?.trim()||``;return(0,B.jsx)(P,{className:r(`overflow-hidden border-sky-500/25`,e.is_direct_assign&&`border-amber-500/40`),"data-testid":`task-offer-${e.id}`,children:(0,B.jsxs)(j,{className:`space-y-3 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.is_direct_assign?(0,B.jsxs)(I,{variant:`outline`,tone:`muted`,className:`gap-1 border-amber-500/30 text-amber-300`,children:[(0,B.jsx)(_,{className:`h-3 w-3`}),`direct assign`]}):(0,B.jsx)(I,{variant:`outline`,tone:`muted`,children:`offer`}),e.status_preview&&(0,B.jsx)(I,{variant:`outline`,tone:`muted`,className:`font-mono text-[10px] uppercase`,children:e.status_preview}),e.priority_preview&&e.priority_preview!==`normal`&&(0,B.jsx)(I,{variant:`outline`,tone:`muted`,className:`font-mono text-[10px] uppercase`,children:e.priority_preview})]}),(0,B.jsxs)(`p`,{className:`font-mono text-[10.5px] text-muted-foreground/70`,title:e.from_peer_id,children:[`from `,(0,B.jsx)(`span`,{className:`text-foreground/70`,children:V(e.from_peer_id)}),g&&(0,B.jsxs)(B.Fragment,{children:[` · `,`workspace `,(0,B.jsx)(`span`,{className:`text-foreground/70`,children:g})]})]})]}),(0,B.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/70`,children:H(e.envelope_created_at||e.created_at)})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(`p`,{className:`break-words font-mono text-[13px] font-medium text-foreground`,children:e.title}),v&&(0,B.jsx)(`p`,{className:`line-clamp-3 whitespace-pre-wrap text-[12.5px] leading-relaxed text-muted-foreground/90`,children:v})]}),m.length>0&&(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[m.slice(0,6).map(e=>(0,B.jsx)(I,{variant:`outline`,tone:`muted`,className:`font-mono text-[10px]`,children:e},e)),m.length>6&&(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:[`+`,m.length-6]})]}),s&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-amber-500/30 bg-amber-500/5 p-3`,children:[(0,B.jsx)(`p`,{className:`text-[11.5px] leading-relaxed text-amber-200/90`,children:`First offer from this peer/workspace pair — pick the local workspace it should land in. The choice is remembered for future offers from the same source.`}),(0,B.jsxs)(F,{value:l,onValueChange:d,children:[(0,B.jsx)(N,{className:`h-8 text-[12px]`,children:(0,B.jsx)(A,{placeholder:`Choose local workspace…`})}),(0,B.jsx)(D,{children:t.map(e=>(0,B.jsx)(O,{value:e.id,children:e.name},e.id))})]}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,B.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>c(!1),disabled:i!==null,children:`Cancel`}),(0,B.jsxs)(h,{size:`sm`,disabled:i!==null||!l,onClick:()=>void f(l),children:[i===`accept`?(0,B.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(E,{className:`h-3.5 w-3.5`}),`Accept into workspace`]})]})]}),!s&&(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border/30 pt-3`,children:[(0,B.jsxs)(h,{variant:`outline`,size:`sm`,disabled:i!==null,onClick:p,className:`gap-1.5 border-destructive/30 text-destructive hover:bg-destructive/5`,"data-testid":`task-offer-${e.id}-decline`,children:[i===`decline`?(0,B.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(u,{className:`h-3.5 w-3.5`}),`Decline`]}),(0,B.jsxs)(h,{variant:`default`,size:`sm`,disabled:i!==null,onClick:()=>void f(void 0),className:`gap-1.5`,"data-testid":`task-offer-${e.id}-accept`,children:[i===`accept`?(0,B.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(E,{className:`h-3.5 w-3.5`}),`Accept`]})]})]})})}function W({offer:e}){let t=!!e.accepted_at,n=V(e.from_peer_id),i=e.accepted_at||e.declined_at||e.created_at,a=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:r(`inline-flex h-1.5 w-1.5 shrink-0 rounded-full`,t?`bg-emerald-400`:`bg-muted-foreground/40`)}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:e.title}),(0,B.jsx)(`span`,{className:r(`font-mono text-[9px] uppercase tracking-wider`,t?`text-emerald-300/80`:`text-muted-foreground/60`),children:t?`accepted`:`declined`})]}),(0,B.jsxs)(`p`,{className:`text-[10.5px] text-muted-foreground/70`,children:[`from `,n,` · `,H(i),e.declined_reason?` · ${e.declined_reason}`:``]})]})]});return t&&e.task_id&&e.workspace_id?(0,B.jsx)(g,{to:`/tasks/${encodeURIComponent(e.task_id)}?workspace=${encodeURIComponent(e.workspace_id)}`,className:`flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/30`,"data-testid":`task-offer-history-${e.id}`,children:a}):(0,B.jsx)(`div`,{className:`flex items-center gap-3 px-4 py-2.5`,"data-testid":`task-offer-history-${e.id}`,children:a})}function G(){let{data:e,refetch:t}=w((0,z.useCallback)(()=>T({limit:200}),[])),{data:i}=w((0,z.useCallback)(()=>n(),[]));R({onEvent:()=>{t()}}),(0,z.useEffect)(()=>{let e=window.setInterval(t,3e4);return()=>window.clearInterval(e)},[t]);let a=b(),u=C(),[h,_]=(0,z.useState)(null);(0,z.useEffect)(()=>{let e=typeof a.state==`object`&&a.state!==null?a.state.pulseOfferId:void 0;if(!e)return;_(e);let t=0,n=()=>{let r=document.querySelector(`[data-offer-id="${e}"]`);if(r){r.scrollIntoView({behavior:`smooth`,block:`center`});return}++t>20||requestAnimationFrame(n)};requestAnimationFrame(n),u(a.pathname+a.search,{replace:!0,state:null});let r=window.setTimeout(()=>_(null),2400);return()=>window.clearTimeout(r)},[a.state,a.pathname,a.search,u]);let y=(0,z.useMemo)(()=>e??[],[e]),x=(0,z.useMemo)(()=>y.filter(e=>e.direction===`incoming`&&e.state===`pending`),[y]),E=(0,z.useMemo)(()=>y.filter(e=>e.direction===`outgoing`&&e.state===`pending`),[y]),D=(0,z.useMemo)(()=>y.filter(e=>e.state!==`pending`).sort((e,t)=>{let n=new Date(e.accepted_at||e.declined_at||e.created_at).getTime();return new Date(t.accepted_at||t.declined_at||t.created_at).getTime()-n}).slice(0,40),[y]);return(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsxs)(g,{to:`/tasks`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,B.jsx)(S,{className:`h-3 w-3`}),`Tasks`]}),(0,B.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,B.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-semibold tracking-tight`,children:[(0,B.jsx)(m,{className:`h-5 w-5 text-primary`}),`Shared tasks`]}),(0,B.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Tasks your paired peers have offered to share, and tasks you have offered to them. Accept to pull the full payload into your local store; the daemon remembers which local workspace each peer maps to after the first accept.`})]}),(0,B.jsxs)(l,{defaultValue:`incoming`,className:`w-full`,children:[(0,B.jsxs)(c,{variant:`line`,className:`border-b border-border`,children:[(0,B.jsxs)(o,{value:`incoming`,"data-testid":`task-offers-tab-incoming`,children:[(0,B.jsx)(d,{className:`h-3.5 w-3.5`}),`Incoming`,x.length>0&&(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex h-4 min-w-4 items-center justify-center rounded-sm bg-sky-500/20 px-1 font-mono text-[10px] text-sky-300`,children:x.length})]}),(0,B.jsxs)(o,{value:`outgoing`,"data-testid":`task-offers-tab-outgoing`,children:[(0,B.jsx)(f,{className:`h-3.5 w-3.5`}),`Outgoing`,E.length>0&&(0,B.jsx)(`span`,{className:`ml-1.5 inline-flex h-4 min-w-4 items-center justify-center rounded-sm bg-muted px-1 font-mono text-[10px] text-muted-foreground`,children:E.length})]}),(0,B.jsxs)(o,{value:`history`,"data-testid":`task-offers-tab-history`,children:[(0,B.jsx)(v,{className:`h-3.5 w-3.5`}),`History`]})]}),(0,B.jsx)(s,{value:`incoming`,className:`space-y-3 pt-5`,children:x.length===0?(0,B.jsx)(L,{icon:(0,B.jsx)(p,{className:`h-7 w-7`}),title:`No incoming offers`,description:`When a paired peer offers you a task, it lands here. The gateway never pulls the full payload until you explicitly accept.`,density:`card`,testid:`task-offers-incoming-empty`}):(0,B.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:x.map(e=>(0,B.jsx)(`div`,{"data-offer-id":e.id,className:r(`transition-shadow duration-700`,h===e.id&&`ring-1 ring-primary/50 shadow-[0_0_0_4px_hsl(205_95%_55%/0.08)]`),children:(0,B.jsx)(U,{offer:e,workspaces:i??[],onChange:t})},e.id))})}),(0,B.jsx)(s,{value:`outgoing`,className:`space-y-3 pt-5`,children:E.length===0?(0,B.jsx)(L,{icon:(0,B.jsx)(f,{className:`h-7 w-7`}),title:`No outgoing offers`,description:`Use task__offer / task__assign_remote from an agent to share a task with a paired peer. Pending offers will appear here until the peer accepts, declines, or the envelope expires.`,density:`card`,testid:`task-offers-outgoing-empty`}):(0,B.jsx)(`ul`,{className:`divide-y divide-border/40 border border-border/40 bg-background/40`,children:E.map(e=>(0,B.jsx)(`li`,{"data-offer-id":e.id,className:r(`transition-colors duration-700`,h===e.id&&`bg-primary/10 ring-1 ring-primary/40`),children:(0,B.jsx)(W,{offer:e})},e.id))})}),(0,B.jsx)(s,{value:`history`,className:`space-y-2 pt-5`,children:D.length===0?(0,B.jsx)(L,{title:`No offer history yet`,description:`Once you accept or decline offers, or peers respond to yours, they will appear here for reference.`,density:`card`}):(0,B.jsx)(`ul`,{className:`divide-y divide-border/40 border border-border/40 bg-background/40`,children:D.map(e=>(0,B.jsx)(`li`,{"data-offer-id":e.id,className:r(`transition-colors duration-700`,h===e.id&&`bg-primary/10 ring-1 ring-primary/40`),children:(0,B.jsx)(W,{offer:e})},e.id))})})]})]})}export{G as TaskOffersPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/TaskRef-D6QBTHtc.js b/internal/web/dist/assets/TaskRef-D6QBTHtc.js deleted file mode 100644 index f7353e5..0000000 --- a/internal/web/dist/assets/TaskRef-D6QBTHtc.js +++ /dev/null @@ -1 +0,0 @@ -import{in as e,on as t}from"./client-CaIRceNv.js";import{Fr as n,_ as r,rr as i}from"./index-BDLzoIgt.js";import{f as a,u as o}from"./task-utils-BkVzAeUR.js";var s=t();function c({id:t,workspaceId:o,variant:c=`chip`,showCopy:l,title:u,className:d}){if(!t)return null;let f=o?`/tasks/${encodeURIComponent(t)}?workspace=${encodeURIComponent(o)}`:`/tasks?focus=${encodeURIComponent(t)}`;return c===`plain`?(0,s.jsx)(n,{to:f,title:u??`Open task ${t}`,className:e(`font-mono text-[11px] text-primary hover:underline`,d),children:a(t)}):c===`inline`?(0,s.jsxs)(n,{to:f,title:u??`Open task ${t}`,className:e(`inline-flex items-baseline gap-1 px-1 font-mono text-[11px] text-primary hover:underline`,d),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(i,{className:`h-3 w-3 self-center`}),a(t)]}):(0,s.jsxs)(`span`,{className:e(`inline-flex items-center gap-1`,d),children:[(0,s.jsxs)(n,{to:f,title:u??`Open task ${t}`,className:`inline-flex items-center gap-1.5 border border-border bg-muted/40 px-2 py-0.5 font-mono text-[11px] uppercase tracking-wider text-muted-foreground hover:border-primary/60 hover:text-foreground`,children:[(0,s.jsx)(i,{className:`h-3 w-3`}),a(t)]}),l?(0,s.jsx)(r,{value:t,className:`h-5 w-5`}):null]})}function l({text:e,workspaceId:t,className:n}){return(0,s.jsx)(`span`,{className:n,children:o(e,{workspaceId:t})})}export{c as n,l as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/TasksLandingPage-CLK7Y5Ki.js b/internal/web/dist/assets/TasksLandingPage-CLK7Y5Ki.js deleted file mode 100644 index 9bb7023..0000000 --- a/internal/web/dist/assets/TasksLandingPage-CLK7Y5Ki.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,in as r,on as i}from"./client-CaIRceNv.js";import{t as a}from"./arrow-up-right-RRuYfAwZ.js";import{t as o}from"./folder-DHzynzTC.js";import{t as s}from"./inbox-ClSTJaEn.js";import{Ar as c,Br as l,Fr as u,G as d,Ir as f,S as p,U as m,n as h,rr as g,t as _,y as v}from"./index-BDLzoIgt.js";import{t as y}from"./empty-state-B9mtYx_X.js";import{c as b,d as x,f as S,o as C,p as w}from"./task-utils-BkVzAeUR.js";import{t as T}from"./use-tasks-stream-BfVVn1xh.js";import{t as E}from"./Pill-Dpb0OZxB.js";var D=e(t(),1),O=`mcplexer.tasks.recent_activity`,k=50;function A(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(O);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.slice(0,k):[]}catch{return[]}}function j(e){if(!(typeof window>`u`))try{window.localStorage.setItem(O,JSON.stringify(e))}catch{}}function M(e){let t=e.task?.id??e.offer?.id??e.note?.id??``;return`${e.kind}:${t}:${e.at}`}function N(){let[e,t]=(0,D.useState)(()=>A());return(0,D.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{e.key===O&&t(A())};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{events:e,push:(0,D.useCallback)(e=>{t(t=>{let n=M(e),r=[e,...t.filter(e=>M(e)!==n)].slice(0,k);return j(r),r})},[])}}var P=50;function F(e,t=P){let n=[];for(let t of e)for(let e of t.status_history??[])!e.at||!e.evt||n.push(te(t,e));return n.sort(V).slice(0,t)}function ee(e,t,n=P){let r=new Set(t.map(B)),i=new Set,a=[];for(let n of[...e,...t]){let e=L(n);if(!e.history&&r.has(B(e)))continue;let t=z(e);i.has(t)||(i.add(t),a.push(e))}return a.sort(V).slice(0,n)}function te(e,t){return{kind:I(t.evt),workspace_id:e.workspace_id,task:e,history:t,at:t.at}}function I(e){switch(e){case`created`:return`task_created`;case`deleted`:return`task_deleted`;default:return`task_updated`}}function L(e){if(e.history||!e.task?.status_history?.length)return e;let t=R(e.task.status_history,e.at);return t?{...e,history:t}:e}function R(e,t){let n=Date.parse(t),r;for(let t of e)t.at&&((!r||H(t.at)>=H(r.at))&&(r=t),Number.isFinite(n)&&Math.abs(H(t.at)-n)<=1e3&&(r=t));return r}function z(e){return`${B(e)}:${e.history?.evt??``}`}function B(e){let t=e.task?.id??e.offer?.id??e.note?.id??``;return`${e.kind}:${t}:${e.at}`}function V(e,t){return H(t.at)-H(e.at)}function H(e){let t=Date.parse(e);return Number.isFinite(t)?t:0}function U(e,t){switch(e.evt){case`created`:return{verb:`created`,tone:`info`};case`status_changed`:return{verb:e.to?`moved to ${e.to}`:`status changed`,tone:W(e.to||t?.status)};case`closed`:return{verb:`closed`,tone:`success`};case`reopened`:return{verb:`reopened`,tone:`info`};case`assigned`:return{verb:`assigned`,tone:`success`};case`unassigned`:return{verb:`unassigned`,tone:`muted`};case`work_context_updated`:return{verb:`context updated`,tone:`muted`};case`lease_expired`:return{verb:`lease expired`,tone:`warn`};case`composed`:return{verb:`composed`,tone:`info`};case`decomposed`:return{verb:`decomposed`,tone:`muted`};case`received_gossip`:return{verb:`received`,tone:`info`};case``:return null;default:return{verb:e.evt.replace(/_/g,` `),tone:`muted`}}}function W(e){let t=(e||``).toLowerCase();return t===`done`||t===`closed`||t===`completed`?`success`:t===`blocked`||t===`stuck`?`warn`:t===`cancelled`||t===`canceled`||t===`wontfix`?`muted`:t===`doing`||t===`in_progress`||t===`in-progress`||t===`working`?`success`:`info`}var G=i();function K({icon:e,label:t,value:n,detail:i,href:o,dim:s,accent:c}){return(0,G.jsxs)(u,{to:o,className:r(`group block border border-border bg-card/40 px-4 py-3.5 transition-colors`,`hover:border-border/80 hover:bg-card focus-visible:border-primary/60 focus-visible:outline-none`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t]}),(0,G.jsx)(a,{className:`h-3 w-3 opacity-0 transition-opacity group-hover:opacity-100`})]}),(0,G.jsx)(`div`,{className:r(`mt-2 font-mono text-3xl font-semibold tabular-nums tracking-tight`,s?`text-muted-foreground/70`:`text-foreground`,c===`awaiting`&&`text-amber-300`,c===`live`&&`text-emerald-300`),children:n}),(0,G.jsxs)(`div`,{className:r(`mt-1 flex items-center gap-1.5 text-[11px]`,c===`awaiting`&&`text-amber-300/80`,c===`live`&&`text-emerald-300/80`,(!c||c===`idle`)&&`text-muted-foreground`),children:[c===`awaiting`&&(0,G.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[(0,G.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-pulse-slow rounded-full bg-amber-400/60`}),(0,G.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]}),c===`live`&&(0,G.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[(0,G.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-pulse-slow rounded-full bg-emerald-400/60`}),(0,G.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-emerald-400`})]}),i]})]})}function q({to:e,title:t,body:n,accent:i}){return(0,G.jsxs)(u,{to:e,className:r(`group flex flex-col gap-1 border border-border bg-card/40 px-4 py-3 transition-colors`,`hover:border-border/80 hover:bg-card`,i&&`border-sky-500/40`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:r(`text-[13px] font-semibold`,i?`text-sky-300`:`text-foreground`),children:t}),(0,G.jsx)(a,{className:`h-3.5 w-3.5 text-muted-foreground/50 transition-colors group-hover:text-foreground`})]}),(0,G.jsx)(`p`,{className:`text-[11.5px] leading-relaxed text-muted-foreground`,children:n})]})}function J({events:e,workspaceNameByID:t,liveCount:n=0}){return(0,G.jsx)(_,{className:`overflow-hidden`,children:(0,G.jsxs)(h,{className:`space-y-3 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-[13px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Live activity`}),e.length>0?(0,G.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:[e.length,` event`,e.length===1?``:`s`]}):null]}),e.length===0?(0,G.jsx)(y,{icon:(0,G.jsx)(g,{className:`h-7 w-7`}),title:`No task events yet`,description:`When an agent creates, claims, or closes a task, or a paired peer offers you one, you'll see it here in real-time.`,density:`card`,testid:`tasks-activity-empty`}):(0,G.jsx)(`ul`,{className:`divide-y divide-border/30 border border-border/40 bg-background/40`,children:e.map((e,r)=>(0,G.jsx)(ie,{event:e,workspaceName:e.workspace_id?t[e.workspace_id]:void 0,isLive:r(0,G.jsx)(`li`,{children:(0,G.jsxs)(u,{to:`/tasks/all?workspace=${encodeURIComponent(e.id)}`,className:`flex items-center justify-between gap-3 px-3 py-2.5 transition-colors hover:bg-muted/30`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-[12.5px] text-foreground`,children:e.name}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,G.jsx)(Q,{label:`open`,value:e.open}),e.doing>0&&(0,G.jsx)(Q,{label:`doing`,value:e.doing,accent:`live`}),e.blocked>0&&(0,G.jsx)(Q,{label:`blocked`,value:e.blocked,accent:`warn`})]})]})},e.id))})]})})}function Q({label:e,value:t,accent:n}){return(0,G.jsxs)(`span`,{className:r(`inline-flex items-center gap-1 font-mono text-[11px] tabular-nums`,n===`live`&&`text-emerald-300`,n===`warn`&&`text-amber-300`,!n&&`text-muted-foreground`),children:[(0,G.jsx)(`span`,{className:`font-semibold`,children:t}),(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-wider opacity-70`,children:e})]})}function oe(e,t){let n=new Map;for(let r of e){if(r.closed_at)continue;let e=r.workspace_id;if(!e)continue;let i=n.get(e);i||(i={id:e,name:t[e]||e.slice(0,8),open:0,doing:0,blocked:0},n.set(e,i)),i.open+=1,(r.status||``).toLowerCase()===`blocked`?i.blocked+=1:b(r.status)&&(i.doing+=1)}return Array.from(n.values()).sort((e,t)=>t.open-e.open)}function $({task:e}){let t=x(e.priority),n=w(e.status,!!e.closed_at);return(0,G.jsxs)(u,{to:`/tasks/${encodeURIComponent(e.id)}?workspace=${encodeURIComponent(e.workspace_id)}`,className:`flex items-start gap-2.5 px-3 py-2 transition-colors hover:bg-muted/30`,children:[(0,G.jsx)(`span`,{className:r(`mt-1.5 inline-flex h-2 w-2 shrink-0 rounded-full`,t.dot)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate text-[12.5px] font-medium text-foreground`,children:e.title}),(0,G.jsxs)(`p`,{className:`truncate text-[10.5px] text-muted-foreground/80`,children:[e.status,` · `,S(e.id)]})]}),(0,G.jsx)(v,{variant:`outline`,tone:n.tone,className:`font-mono text-[9px] uppercase`,children:e.priority})]})}var se=5;function ce(){let[e]=l();return e.get(`focus`)?(0,G.jsx)(f,{to:`/tasks/all?${e.toString()}`,replace:!0}):(0,G.jsx)(le,{})}function le(){let{data:e,refetch:t}=p((0,D.useCallback)(()=>d({state:`all`,limit:500}),[])),{data:r}=p((0,D.useCallback)(()=>n(),[])),{data:i,refetch:a}=p((0,D.useCallback)(()=>m({direction:`incoming`,state:`pending`,limit:100}),[])),{events:o,push:l}=N(),[u,f]=(0,D.useState)(0);T({onEvent:e=>{l(e),f(e=>Math.min(e+1,50)),t(),a()}}),(0,D.useEffect)(()=>{let e=window.setInterval(()=>{t(),a()},3e4);return()=>window.clearInterval(e)},[t,a]);let h=(0,D.useMemo)(()=>{let e={};for(let t of r??[])e[t.id]=t.name;return e},[r]),_=(0,D.useMemo)(()=>e??[],[e]),v=(0,D.useMemo)(()=>F(_),[_]),y=(0,D.useMemo)(()=>ee(o,v),[o,v]),x=(0,D.useMemo)(()=>_.filter(e=>!e.closed_at),[_]),S=(0,D.useMemo)(()=>x.filter(e=>b(e.status)),[x]),C=(0,D.useMemo)(()=>{let e={critical:0,high:1,normal:2,low:3};return[...x].sort((t,n)=>{let r=e[t.priority]??9,i=e[n.priority]??9;return r===i?(n.updated_at||``).localeCompare(t.updated_at||``):r-i}).slice(0,se)},[x]),w=i?.length??0,E=x.length,O=S.length;return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-2xl font-semibold tracking-tight`,children:[(0,G.jsx)(g,{className:`h-5 w-5 text-primary`}),`Tasks`]}),(0,G.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`Operational work items per workspace. Agents create them as they plan, claim them as they work, and close them as they ship. You triage what matters; the rest stays out of the way.`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-3`,children:[(0,G.jsx)(K,{icon:(0,G.jsx)(g,{className:`h-4 w-4`}),label:`Open`,value:String(E),detail:E===0?`nothing in flight`:`${E} task${E===1?``:`s`} on the board`,href:`/tasks/all`}),(0,G.jsx)(K,{icon:(0,G.jsx)(c,{className:`h-4 w-4`}),label:`Doing now`,value:String(O),detail:O>0?`agents actively working`:`no agents busy`,accent:O>0?`live`:`idle`,href:`/tasks/all?status=doing`}),(0,G.jsx)(K,{icon:(0,G.jsx)(s,{className:`h-4 w-4`}),label:`Incoming offers`,value:String(w),detail:w>0?`awaiting your review`:`all caught up`,accent:w>0?`awaiting`:`idle`,href:`/tasks/offers`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,G.jsx)(`div`,{className:`lg:col-span-2`,children:(0,G.jsx)(J,{events:y,workspaceNameByID:h,liveCount:u})}),(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,G.jsxs)(`div`,{className:`border border-border bg-card/40`,children:[(0,G.jsx)(`div`,{className:`border-b border-border/40 px-3 py-2`,children:(0,G.jsx)(`h2`,{className:`text-[12px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:`Next up`})}),C.length===0?(0,G.jsx)(`p`,{className:`px-3 py-4 text-[12px] text-muted-foreground`,children:`Nothing open right now.`}):(0,G.jsx)(`ul`,{className:`divide-y divide-border/30`,children:C.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)($,{task:e})},e.id))})]})})]}),(0,G.jsx)(ae,{tasks:x,workspaceNameByID:h}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-3`,children:[(0,G.jsx)(q,{to:`/tasks/all`,title:`Browse all tasks`,body:`Search, filter, bulk-act on every task across every workspace.`}),(0,G.jsx)(q,{to:`/tasks/offers`,title:`Shared tasks`,body:w>0?`${w} peer offer${w===1?``:`s`} awaiting review`:`Tasks offered by paired peers land here.`,accent:w>0}),(0,G.jsx)(q,{to:`/tasks/all?tag=milestone`,title:`Milestones`,body:`Epics with a due date and a children rollup — the burndown view.`})]})]})}export{ce as TasksLandingPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/TasksListPage-CoUEBKQM.js b/internal/web/dist/assets/TasksListPage-CoUEBKQM.js deleted file mode 100644 index de08669..0000000 --- a/internal/web/dist/assets/TasksListPage-CoUEBKQM.js +++ /dev/null @@ -1,5 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{c as t,f as n,i as r,l as i,n as a,o,r as s,s as c}from"./recharts-V3eOq3uM.js";import{Et as l,in as u,on as d}from"./client-CaIRceNv.js";import{t as f}from"./createLucideIcon-WB390fY6.js";import{t as p}from"./chevron-right-CyhRDGe7.js";import{i as m,n as h,r as g,t as _}from"./TaskEditDialog-CkXGM0xr.js";import{n as v,t as y}from"./tag-kY6Y-EYi.js";import{t as ee}from"./pin-C0Q-Achd.js";import{B as te,Bn as b,Br as x,Fn as S,Fr as C,Ft as w,G as T,L as E,Ln as D,Qn as ne,Rr as re,S as O,Y as ie,br as ae,d as k,f as A,jr as j,m as M,nr as N,p as P,q as F,qn as I,rr as oe,u as L,v as se,xr as R,y as z}from"./index-BDLzoIgt.js";import{t as ce}from"./empty-state-B9mtYx_X.js";import{a as B,c as le,d as ue,f as de,h as fe,i as V,l as pe,m as me,o as H,p as U,r as W,s as G,t as he}from"./task-utils-BkVzAeUR.js";import{t as ge}from"./use-tasks-stream-BfVVn1xh.js";var _e=f(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),K=f(`rows-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M21 9H3`,key:`1338ky`}],[`path`,{d:`M21 15H3`,key:`9uk58r`}]]),q=e(n(),1),J=d();function ve({milestone:e}){let n=re(),l=e,d=l.task.due_at??void 0,f=H(d),p=V(d),m=(0,q.useMemo)(()=>ye(l),[l]),h=l.total_children,g=l.closed_children,_=l.days_remaining<0,v=h>0&&g>=h,y=`/tasks/${encodeURIComponent(l.task.id)}?workspace=${encodeURIComponent(l.task.workspace_id)}`,ee=`/tasks?focus=${encodeURIComponent(l.task.id)}&workspace=${encodeURIComponent(l.task.workspace_id)}`;return(0,J.jsxs)(`article`,{className:u(`flex h-44 w-72 shrink-0 flex-col border bg-card/40`,v?`border-border/60`:_?`border-red-500/40`:`border-border`),children:[(0,J.jsxs)(`header`,{className:`flex items-start justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(C,{to:y,className:`block truncate text-sm font-semibold hover:underline`,title:l.task.title,children:l.task.title}),(0,J.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,J.jsxs)(`span`,{title:`due ${p}`,className:u(`font-mono`,_&&!v?`text-red-400`:``),children:[_&&!v?`overdue · `:`due · `,f]}),(0,J.jsx)(`span`,{children:`·`}),(0,J.jsx)(`span`,{className:`font-mono`,children:l.days_remaining===0?`today`:`${Math.abs(l.days_remaining)}d ${l.days_remaining<0?`past`:`left`}`})]})]}),(0,J.jsxs)(z,{variant:`outline`,tone:v?`success`:_?`critical`:`info`,className:`font-mono text-[10px]`,children:[g,` / `,h]})]}),(0,J.jsx)(`button`,{onClick:()=>n(ee),className:`group relative h-full w-full select-none focus:outline-none focus-visible:bg-muted/30`,"aria-label":`View children of ${l.task.title}`,children:m.length>0?(0,J.jsx)(i,{width:`100%`,height:`100%`,children:(0,J.jsxs)(a,{data:m,margin:{top:12,right:10,bottom:6,left:10},children:[(0,J.jsx)(r,{dataKey:`date`,hide:!0}),(0,J.jsx)(s,{hide:!0,domain:[0,h]}),(0,J.jsx)(c,{y:0,stroke:`currentColor`,strokeOpacity:.15}),(0,J.jsx)(o,{type:`linear`,dataKey:`ideal`,stroke:`currentColor`,strokeOpacity:.4,strokeDasharray:`3 3`,strokeWidth:1,dot:!1,isAnimationActive:!1}),(0,J.jsx)(o,{type:`monotone`,dataKey:`open`,stroke:`#22d3ee`,strokeWidth:1.8,dot:!1,isAnimationActive:!1}),(0,J.jsx)(t,{cursor:{stroke:`currentColor`,strokeOpacity:.1},contentStyle:{background:`rgba(0,0,0,0.85)`,border:`1px solid rgba(255,255,255,0.08)`,borderRadius:0,fontSize:10,padding:`4px 6px`},formatter:(e,t)=>[String(e),t===`open`?`open`:`ideal`],labelFormatter:e=>String(e)})]})}):(0,J.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-[10px] text-muted-foreground/70`,children:`no children yet`})})]})}function ye(e){let t=e.burndown_points;if(!t||t.length===0)return[];let n=e.total_children,r=t.length-1;return t.map((e,t)=>({date:e.date,open:e.children_open,ideal:r===0?n:Math.max(0,n-n*t/r)}))}function be({milestones:e}){return!e||e.length===0?null:(0,J.jsxs)(`section`,{className:`border border-border bg-card/30`,children:[(0,J.jsxs)(`header`,{className:`flex items-center justify-between border-b border-border bg-card px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(_e,{className:`h-3.5 w-3.5 text-cyan-400`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:`Milestones`}),(0,J.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:e.length})]}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`click a tile to focus its children`})]}),(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsx)(`div`,{className:`flex gap-3 p-3`,children:e.map(e=>(0,J.jsx)(ve,{milestone:e},e.task.id))})})]})}function Y({text:e,query:t,className:n}){if(!t||!e)return(0,J.jsx)(J.Fragment,{children:e});let r=t.split(/\s+/).map(e=>e.trim()).filter(e=>e.length>=2);if(r.length===0)return(0,J.jsx)(J.Fragment,{children:e});let i=RegExp(`(${r.map(X).join(`|`)})`,`gi`),a=RegExp(`^(?:${r.map(X).join(`|`)})$`,`i`);return(0,J.jsx)(`span`,{className:n,children:e.split(i).map((e,t)=>a.test(e)?(0,J.jsx)(`mark`,{className:`bg-primary/20 px-0.5 text-foreground`,children:e},t):(0,J.jsx)(q.Fragment,{children:e},t))})}function X(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function xe({value:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`inline-flex border border-border`,children:[(0,J.jsxs)(`button`,{onClick:()=>t(`flat`),title:`Flat list — one row per task`,className:u(`inline-flex items-center gap-1 border-r border-border px-2 py-1 text-xs`,e===`flat`?`bg-accent text-accent-foreground`:`bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,J.jsx)(K,{className:`h-3 w-3`}),`Flat`]}),(0,J.jsxs)(`button`,{onClick:()=>t(`tree`),title:`Tree — children indent under their parent epic`,className:u(`inline-flex items-center gap-1 px-2 py-1 text-xs`,e===`tree`?`bg-accent text-accent-foreground`:`bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,J.jsx)(v,{className:`h-3 w-3`}),`Tree`]})]})}function Se({count:e,busy:t,onClear:n,onClose:r,onDelete:i}){return(0,J.jsx)(`div`,{className:`fixed inset-x-0 bottom-4 z-30 flex justify-center px-3`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border border-border bg-card px-3 py-2 shadow-[0_4px_24px_-12px_rgba(0,0,0,0.6)]`,children:[(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,J.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` selected`]}),(0,J.jsx)(`span`,{className:`mx-1 text-border`,children:`·`}),(0,J.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:r,disabled:t,children:[t?(0,J.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,J.jsx)(ae,{className:`h-3.5 w-3.5`}),`Close`]}),(0,J.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:i,disabled:t,className:`text-destructive hover:text-destructive`,children:[(0,J.jsx)(b,{className:`h-3.5 w-3.5`}),`Delete`]}),(0,J.jsx)(`span`,{className:`mx-1 text-border`,children:`·`}),(0,J.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:n,disabled:t,children:[(0,J.jsx)(D,{className:`h-3.5 w-3.5`}),`Clear`]})]})})}function Ce(){return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Tasks are emitted by agents (or you) via the gateway. The minimal call from any agent connected to MCPlexer:`}),(0,J.jsx)(`pre`,{className:`mx-auto inline-block overflow-x-auto border border-border bg-muted/40 px-3 py-2 text-left font-mono text-[12px] leading-relaxed text-foreground/90`,children:(0,J.jsx)(`code`,{children:`task__create({ - title: "Patch the audit redaction for peer IDs", - priority: "high", - tags: ["security"] -})`})}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Or hit the New task button — same code path, just a form.`})]})}function we(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var Te=200,Z=`mcplexer.tasksList.collapsed`,Q=`mcplexer.tasksList.view`;function Ee(){if(typeof window>`u`)return new Set;try{let e=window.localStorage.getItem(Z);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}function De(e){typeof window>`u`||window.localStorage.setItem(Z,JSON.stringify(Array.from(e)))}function Oe(){return typeof window>`u`?`flat`:window.localStorage.getItem(Q)||`flat`}function ke(e){typeof window>`u`||window.localStorage.setItem(Q,e)}function Ae(){let e=re(),[t,n]=x(),r=t.get(`workspace`)??``,i=t.get(`state`)||`open`,a=t.get(`status`)??``,o=t.get(`priority`)||`all`,s=t.get(`assignee`)??``,c=t.get(`human`)===`1`,u=t.get(`tag`)??``,d=t.get(`focus`)??``,f=t.get(`sort`)||`updated`,[p,m]=(0,q.useState)(t.get(`q`)??``),[v,y]=(0,q.useState)(t.get(`q`)??``),ee=fe(3e4),[b,C]=(0,q.useState)(!1),[w,ae]=(0,q.useState)(()=>Ee()),[k,A]=(0,q.useState)(()=>Oe()),[M,N]=(0,q.useState)(()=>new Set),[P,F]=(0,q.useState)(!1);(0,q.useEffect)(()=>{let e=setTimeout(()=>y(p.trim()),p?Te:0);return()=>clearTimeout(e)},[p]),(0,q.useEffect)(()=>{let e=e=>{let t=e.target;if(!(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)&&e.key!==`Escape`))if(e.key===`/`){let t=document.querySelector(`input[placeholder^="search title"]`);t&&(e.preventDefault(),t.focus(),t.select())}else e.key===`c`?(e.preventDefault(),C(!0)):e.key===`Escape`&&(M.size>0&&N(new Set),t?.blur?.())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[M.size]),(0,q.useEffect)(()=>{let e=new URLSearchParams(t);v?e.set(`q`,v):e.delete(`q`),e.toString()!==t.toString()&&n(e,{replace:!0})},[v,t,n]);let{data:I}=O((0,q.useCallback)(()=>l(),[])),{data:L,loading:se,error:R,refetch:z}=O((0,q.useCallback)(()=>{let e,t,n;return s===`unassigned`||(s===`human`?n=`human`:s?.startsWith(`user:`)?(t=s.slice(5),n=`human`):s&&(e=s)),T({workspace_id:r||void 0,state:i===`all`?void 0:i,status:a||void 0,tag:u||void 0,assignee_session_id:e,assignee_user_id:t,assignee_origin_kind:n??(c?`human`:void 0),q:v||void 0,limit:500})},[r,i,a,u,s,c,v])),{vocab:B}=g(r||null),le=h(),ue=I?.length===1?I[0].id:``,V=r||ue,{data:pe,refetch:me}=O((0,q.useCallback)(()=>V?te(V):Promise.resolve([]),[V]));ge({workspaceId:r||void 0,onEvent:()=>{z(),me()}}),(0,q.useEffect)(()=>{if(!d||!L)return;let t=L.find(e=>e.id===d);t&&e(`/tasks/${encodeURIComponent(t.id)}?workspace=${encodeURIComponent(t.workspace_id)}`,{replace:!0})},[d,L,e]);let H=(0,q.useMemo)(()=>{let e={};for(let t of I??[])e[t.id]=t.name;return e},[I]),U=(0,q.useMemo)(()=>{let e=L??[];return o!==`all`&&(e=e.filter(e=>e.priority===o)),s===`unassigned`&&(e=e.filter(e=>!e.assignee_session_id&&!e.assignee_peer_id&&!e.assignee_user_id)),e},[L,o,s]),W=(0,q.useMemo)(()=>{let e=new Set;for(let t of U)for(let n of t.tags??[])e.add(n);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[U]),G=(0,q.useMemo)(()=>{let e=new Map;for(let t of U){let n=t.assignee_session_id?.trim();if(n){let r=n;e.has(r)||e.set(r,{sess:r,label:he(t),kind:`session`})}let r=t.assignee_user_id?.trim();if(r){let t=`user:${r}`;e.has(t)||e.set(t,{sess:t,label:`@${r}`,kind:`user`})}}return Array.from(e.values()).sort((e,t)=>e.label.localeCompare(t.label))},[U]),_e=(0,q.useMemo)(()=>je(U,H,f,k),[U,H,f,k]),K=U.length,ve=(0,q.useMemo)(()=>U.filter(e=>!e.closed_at).length,[U]),ye=(0,q.useCallback)(e=>{ae(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),De(n),n})},[]),Y=(0,q.useCallback)(e=>{A(e),ke(e)},[]),X=(0,q.useCallback)((e,r)=>{let i=new URLSearchParams(t);r===null||r===``?i.delete(e):i.set(e,r),n(i,{replace:!0})},[t,n]),Z=(0,q.useCallback)(()=>{n(new URLSearchParams,{replace:!0}),m(``),y(``),N(new Set)},[n]),Q=r||o!==`all`||s||c||u||v||i!==`open`||a||f!==`updated`,Ae=(0,q.useCallback)(e=>{N(t=>we(t,e))},[]),$=(0,q.useCallback)(()=>N(new Set),[]),Me=(0,q.useCallback)(async()=>{if(M.size!==0){F(!0);try{let e=Array.from(M),t=new Map((L??[]).map(e=>[e.id,e.workspace_id]));await Promise.all(e.map(e=>{let n=t.get(e);return n?ie(n,e,{terminal:!0}):Promise.resolve()})),j.success(`Closed ${e.length} task${e.length===1?``:`s`}`),$(),z()}catch(e){j.error(e instanceof Error?e.message:`Bulk close failed`)}finally{F(!1)}}},[M,L,$,z]),Ue=(0,q.useCallback)(async()=>{if(M.size!==0){F(!0);try{let e=Array.from(M),t=new Map((L??[]).map(e=>[e.id,e.workspace_id]));await Promise.all(e.map(e=>{let n=t.get(e);return n?E(n,e):Promise.resolve()})),j.success(`Deleted ${e.length} task${e.length===1?``:`s`}`),$(),z()}catch(e){j.error(e instanceof Error?e.message:`Bulk delete failed`)}finally{F(!1)}}},[M,L,$,z]);return(0,J.jsxs)(`div`,{className:`space-y-5`,children:[(0,J.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold tracking-tight`,children:[(0,J.jsx)(oe,{className:`h-6 w-6`}),` Tasks`]}),(0,J.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:`Every task across your workspaces. Filter by state, priority, assignee, or tag — agents create and claim, you triage what needs your eye.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(xe,{value:k,onChange:Y}),(0,J.jsxs)(S,{onClick:()=>C(!0),size:`sm`,children:[(0,J.jsx)(ne,{className:`h-4 w-4`}),`New task`]})]})]}),(0,J.jsxs)(`div`,{className:`border border-border bg-card/40`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border px-3 py-2`,children:[(0,J.jsx)(Ne,{value:p,onChange:m}),(0,J.jsx)(Pe,{value:i,onChange:e=>X(`state`,e)}),(0,J.jsx)(Fe,{value:a,vocab:B,onChange:e=>X(`status`,e)}),(0,J.jsx)(Ie,{value:o,onChange:e=>X(`priority`,e===`all`?null:e)}),I&&I.length>1?(0,J.jsx)(Le,{value:r,workspaces:I.map(e=>({id:e.id,name:e.name})),onChange:e=>X(`workspace`,e)}):null,(0,J.jsx)(Re,{value:f,onChange:e=>X(`sort`,e===`updated`?null:e)}),Q?(0,J.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:Z,className:`h-8 text-xs`,children:[(0,J.jsx)(D,{className:`h-3 w-3`}),`Clear`]}):null,(0,J.jsx)(Ve,{value:c,onChange:e=>X(`human`,e?`1`:null)}),(0,J.jsx)(`div`,{className:`ml-auto text-[11px] text-muted-foreground`,children:se&&!L?`loading…`:`${ve} open / ${K} shown`})]}),u||s||c||W.length>0||G.length>0?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-3 py-2 text-xs`,children:[(0,J.jsx)(Be,{value:s,options:G,onChange:e=>X(`assignee`,e)}),(0,J.jsx)(ze,{value:u,options:W,onChange:e=>X(`tag`,e)})]}):null]}),R?(0,J.jsx)(`div`,{className:`border border-destructive/50 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:R}):null,(0,J.jsx)(be,{milestones:pe}),!se&&K===0?(0,J.jsx)(ce,{icon:(0,J.jsx)(oe,{className:`h-10 w-10 text-muted-foreground`}),title:Q?`No tasks match these filters`:`No tasks yet`,description:Q?(0,J.jsx)(`button`,{onClick:Z,className:`text-primary hover:underline`,children:`Clear all filters`}):(0,J.jsx)(Ce,{}),action:Q?null:(0,J.jsxs)(S,{onClick:()=>C(!0),size:`sm`,children:[(0,J.jsx)(ne,{className:`h-4 w-4`}),`Create the first task`]})}):(0,J.jsx)(`div`,{className:`space-y-4`,children:_e.map(e=>(0,J.jsx)(He,{groupId:e.id,label:e.label,tasks:e.tasks,collapsed:w.has(e.id),onToggleCollapsed:()=>ye(e.id),onTagClick:e=>X(`tag`,e),onAssigneeClick:e=>X(`assignee`,e),viewMode:k,searchQuery:v,selected:M,onToggleSelected:Ae,now:ee,statusVocab:B,activeAgents:le},e.id))}),M.size>0?(0,J.jsx)(Se,{count:M.size,busy:P,onClear:$,onClose:Me,onDelete:Ue}):null,(0,J.jsx)(_,{mode:`create`,open:b,onOpenChange:C,workspaces:I??[],defaultWorkspaceId:r||(I?.[0]?.id??``),onSaved:t=>{j.success(`Created ${de(t.id)}`),z(),e(`/tasks/${encodeURIComponent(t.id)}?workspace=${encodeURIComponent(t.workspace_id)}`)}})]})}function je(e,t,n,r){let i=new Map;for(let t of e){let e=t.workspace_id||`__no_ws__`,n=i.get(e);n||(n=[],i.set(e,n)),n.push(t)}let a=[];for(let[e,o]of i){let i=[...o].sort(Me(n)),s=r===`tree`?$(i):i.map(e=>({task:e,children:[],depth:0}));a.push({id:e,label:t[e]??(e===`__no_ws__`?`No workspace`:e.slice(0,8)),tasks:s})}return a.sort((e,t)=>e.label.localeCompare(t.label)),a}function $(e){let t=new Map;for(let n of e)t.set(n.id,n);let n=new Map,r=new Set;for(let i of e){let e=F(i.meta,`composed_by`);for(let a of e){if(!t.has(a))continue;let e=n.get(a)??[];e.push(i.id),n.set(a,e),r.add(i.id)}}let i=(e,r,a)=>{if(a.has(e.id))return{task:e,children:[],depth:r};let o=new Set(a);return o.add(e.id),{task:e,children:(n.get(e.id)??[]).map(e=>t.get(e)).filter(e=>!!e).map(e=>i(e,r+1,o)),depth:r}},a=[];for(let t of e)r.has(t.id)||a.push(i(t,0,new Set));return a}function Me(e){let t={critical:0,high:1,normal:2,low:3};return(n,r)=>{if(!!n.pinned!=!!r.pinned)return n.pinned?-1:1;switch(e){case`created`:return new Date(r.created_at).getTime()-new Date(n.created_at).getTime();case`due`:return(n.due_at?new Date(n.due_at).getTime():1/0)-(r.due_at?new Date(r.due_at).getTime():1/0);case`priority`:return(t[n.priority]??99)-(t[r.priority]??99);case`status`:return n.status.localeCompare(r.status);default:return new Date(r.updated_at).getTime()-new Date(n.updated_at).getTime()}}}function Ne({value:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`relative w-64`,children:[(0,J.jsx)(I,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,J.jsx)(w,{value:e,onChange:e=>t(e.target.value),placeholder:`search title + body + id`,className:`h-8 pl-7 font-mono text-xs`})]})}function Pe({value:e,onChange:t}){return(0,J.jsx)(`div`,{className:`inline-flex border border-border`,children:[{id:`open`,label:`Open`},{id:`closed`,label:`Closed`},{id:`all`,label:`All`}].map(n=>(0,J.jsx)(`button`,{onClick:()=>t(n.id),className:u(`border-r border-border px-2.5 py-1 text-xs last:border-r-0`,e===n.id?`bg-accent text-accent-foreground`:`bg-transparent text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:n.label},n.id))})}function Fe({value:e,vocab:t,onChange:n}){let r=[`open`,`doing`,`blocked`,`review`,`done`,`cancelled`],i=t?Object.keys(t):[],a=Array.from(new Set([...r,...i,...e?[e]:[]]));return(0,J.jsxs)(L,{value:e||`all`,onValueChange:e=>n(e===`all`?null:e),children:[(0,J.jsx)(P,{size:`sm`,className:`h-8 text-xs`,children:(0,J.jsx)(M,{placeholder:`All status`})}),(0,J.jsxs)(k,{children:[(0,J.jsx)(A,{value:`all`,children:`All status`}),a.map(e=>(0,J.jsx)(A,{value:e,children:e},e))]})]})}function Ie({value:e,onChange:t}){return(0,J.jsxs)(L,{value:e,onValueChange:e=>t(e),children:[(0,J.jsx)(P,{size:`sm`,className:`h-8 text-xs`,children:(0,J.jsx)(M,{placeholder:`All priority`})}),(0,J.jsxs)(k,{children:[(0,J.jsx)(A,{value:`all`,children:`All priority`}),(0,J.jsx)(A,{value:`critical`,children:`Critical`}),(0,J.jsx)(A,{value:`high`,children:`High`}),(0,J.jsx)(A,{value:`normal`,children:`Normal`}),(0,J.jsx)(A,{value:`low`,children:`Low`})]})]})}function Le({value:e,workspaces:t,onChange:n}){return(0,J.jsxs)(L,{value:e||`__all__`,onValueChange:e=>n(e===`__all__`?``:e),children:[(0,J.jsx)(P,{size:`sm`,className:`h-8 text-xs`,children:(0,J.jsx)(M,{placeholder:`All workspaces`})}),(0,J.jsxs)(k,{children:[(0,J.jsx)(A,{value:`__all__`,children:`All workspaces`}),t.map(e=>(0,J.jsx)(A,{value:e.id,children:e.name},e.id))]})]})}function Re({value:e,onChange:t}){return(0,J.jsxs)(L,{value:e,onValueChange:e=>t(e),children:[(0,J.jsx)(P,{size:`sm`,className:`h-8 text-xs`,children:(0,J.jsx)(M,{placeholder:`Sort`})}),(0,J.jsxs)(k,{children:[(0,J.jsx)(A,{value:`updated`,children:`Updated · newest`}),(0,J.jsx)(A,{value:`created`,children:`Created · newest`}),(0,J.jsx)(A,{value:`due`,children:`Due · soonest`}),(0,J.jsx)(A,{value:`priority`,children:`Priority`}),(0,J.jsx)(A,{value:`status`,children:`Status`})]})]})}function ze({value:e,options:t,onChange:n}){return!e&&t.length===0?null:e?(0,J.jsxs)(`button`,{onClick:()=>n(null),className:`inline-flex items-center gap-1 border border-border bg-muted/40 px-2 py-0.5 font-mono text-[11px] hover:border-destructive/60`,children:[(0,J.jsx)(y,{className:`h-3 w-3`}),e,(0,J.jsx)(D,{className:`h-3 w-3`})]}):(0,J.jsxs)(L,{value:`__none__`,onValueChange:e=>n(e===`__none__`?null:e),children:[(0,J.jsxs)(P,{size:`sm`,className:`h-7 text-[11px] font-mono text-muted-foreground/80`,children:[(0,J.jsx)(y,{className:`h-3 w-3`}),(0,J.jsx)(M,{placeholder:`tag`})]}),(0,J.jsxs)(k,{children:[(0,J.jsx)(A,{value:`__none__`,children:`any tag`}),t.map(e=>(0,J.jsx)(A,{value:e,className:`font-mono`,children:e},e))]})]})}function Be({value:e,options:t,onChange:n}){return!e&&t.length===0?null:e?(0,J.jsxs)(`button`,{onClick:()=>n(null),className:`inline-flex items-center gap-1 border border-border bg-muted/40 px-2 py-0.5 font-mono text-[11px] hover:border-destructive/60`,children:[`assignee:`,e===`unassigned`?`unassigned`:e===`human`?`human`:e.startsWith(`user:`)?e:e.slice(0,8),(0,J.jsx)(D,{className:`h-3 w-3`})]}):(0,J.jsxs)(L,{value:`__none__`,onValueChange:e=>n(e===`__none__`?null:e),children:[(0,J.jsxs)(P,{size:`sm`,className:`h-7 text-[11px] font-mono text-muted-foreground/80`,children:[(0,J.jsx)(m,{className:`h-2 w-2`}),(0,J.jsx)(M,{placeholder:`assignee`})]}),(0,J.jsxs)(k,{children:[(0,J.jsx)(A,{value:`__none__`,children:`anyone`}),(0,J.jsx)(A,{value:`unassigned`,className:`font-mono`,children:`unassigned`}),(0,J.jsx)(A,{value:`human`,className:`font-mono`,children:`human (any)`}),t.map(e=>(0,J.jsx)(A,{value:e.sess,className:`font-mono`,children:e.label},e.sess))]})]})}function Ve({value:e,onChange:t}){return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),title:`Show only tasks assigned to a human user`,className:u(`inline-flex h-8 items-center gap-1 border px-2 text-[11px] font-mono transition-colors`,e?`border-primary/60 bg-primary/15 text-primary`:`border-border text-muted-foreground hover:border-primary/40 hover:text-foreground`),children:[(0,J.jsx)(m,{className:u(`h-2 w-2`,e?`fill-primary text-primary`:`text-muted-foreground/60`)}),`human`]})}function He({groupId:e,label:t,tasks:n,collapsed:r,onToggleCollapsed:i,onTagClick:a,onAssigneeClick:o,viewMode:s,searchQuery:c,selected:l,onToggleSelected:u,now:d,statusVocab:f,activeAgents:m}){let h=(e=>{let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};for(let t of e)n(t);return t})(n),g=h.filter(e=>!e.task.closed_at).length,_=h.length-g;return(0,J.jsxs)(`section`,{className:`border border-border bg-card/30`,children:[(0,J.jsxs)(`button`,{onClick:i,className:`flex w-full items-center justify-between border-b border-border bg-card px-3 py-2 text-left hover:bg-card/80`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r?(0,J.jsx)(p,{className:`h-3.5 w-3.5`}):(0,J.jsx)(R,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{className:`text-sm font-semibold`,children:t}),(0,J.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground`,children:e.slice(0,8)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-muted-foreground`,children:[g>0?(0,J.jsxs)(`span`,{className:`text-emerald-400`,children:[g,` open`]}):null,g>0&&_>0?(0,J.jsx)(`span`,{children:`·`}):null,_>0?(0,J.jsxs)(`span`,{children:[_,` closed`]}):null,h.length===0?(0,J.jsx)(`span`,{children:`empty`}):null]})]}),r?null:(0,J.jsx)(`ul`,{className:`divide-y divide-border`,children:h.map(e=>(0,J.jsx)(Ue,{task:e.task,depth:s===`tree`?e.depth:0,hasChildren:e.children.length>0,onTagClick:a,onAssigneeClick:o,searchQuery:c,selected:l.has(e.task.id),onToggleSelected:()=>u(e.task.id),now:d,statusVocab:f,activeAgents:m},e.task.id))})]})}function Ue({task:e,depth:t,hasChildren:n,onTagClick:r,onAssigneeClick:i,searchQuery:a,selected:o,onToggleSelected:s,now:c,statusVocab:l,activeAgents:d}){let f=ue(e.priority),p=U(e.status,!!e.closed_at),m=W(e.due_at??null,e.closed_at??null),h=e.tags??[],g=F(e.meta,`composes`),_=F(e.meta,`composed_by`),v=g.length>0||n,te=_.length>0,b=he(e),x=!!e.assignee_session_id||!!e.assignee_peer_id||!!e.assignee_user_id,S=G(e),w=`/tasks/${encodeURIComponent(e.id)}?workspace=${encodeURIComponent(e.workspace_id)}`,T=pe(e.status,e.assignee_session_id,e.closed_at,d.ready?d.sessionIds:null,l),E=le(e.status,l)?me(e.status_history??null,c):0,D=x?S?`idle`:T.state===`abandoned`?`abandoned`:T.state===`live`?`live`:`idle`:`unassigned`;return(0,J.jsx)(`li`,{className:u(`group relative`,o?`bg-accent/30`:``),children:(0,J.jsxs)(`div`,{className:`flex items-stretch gap-2 px-3 py-2.5 transition-colors hover:bg-muted/40`,children:[(0,J.jsx)(`div`,{className:u(`flex w-4 shrink-0 items-center justify-center self-center`,o?`opacity-100`:`opacity-0 group-hover:opacity-100`),onClick:e=>e.stopPropagation(),children:(0,J.jsx)(se,{checked:o,onCheckedChange:s,"aria-label":`Select ${e.title}`})}),t>0?(0,J.jsxs)(`div`,{className:`flex shrink-0 self-stretch`,"aria-hidden":!0,children:[Array.from({length:t-1}).map((e,t)=>(0,J.jsx)(`span`,{className:`w-8 border-l border-border/40`},t)),(0,J.jsx)(`span`,{className:`relative w-8 border-l border-border/40`,children:(0,J.jsx)(`span`,{className:`absolute left-0 top-1/2 h-px w-6 bg-border/40`})})]}):null,(0,J.jsx)(`div`,{className:`flex w-3 shrink-0 items-center justify-center self-center`,title:`priority: ${e.priority}`,children:(0,J.jsx)(`span`,{className:u(`h-2 w-2 rounded-full`,f.dot)})}),(0,J.jsxs)(C,{to:w,className:u(`flex min-w-0 flex-1 items-stretch gap-3`,e.closed_at?`opacity-60`:``),children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[e.pinned?(0,J.jsx)(ee,{className:`h-3 w-3 text-amber-400`}):null,(0,J.jsx)(`span`,{className:u(`truncate text-sm font-medium`,e.closed_at?`line-through`:``),children:(0,J.jsx)(Y,{text:e.title,query:a})}),(0,J.jsxs)(z,{variant:`outline`,tone:p.tone,className:u(`text-[10px]`,p.mono?`font-mono`:``),children:[e.status,E>0?(0,J.jsxs)(`span`,{className:`ml-1 font-mono opacity-70`,children:[`· `,B(E)]}):null]}),D===`abandoned`?(0,J.jsx)(z,{variant:`outline`,tone:`warn`,className:`text-[10px]`,children:`agent gone`}):null,v?(0,J.jsxs)(z,{variant:`outline`,tone:`info`,className:`text-[10px]`,children:[`epic · `,g.length]}):null,te?(0,J.jsx)(z,{variant:`outline`,tone:`muted`,className:`text-[10px]`,children:`child`}):null,h.slice(0,3).map(e=>(0,J.jsxs)(`button`,{onClick:t=>{t.preventDefault(),r(e)},className:`inline-flex items-center gap-1 border border-border bg-muted/30 px-1.5 py-px text-[10px] text-muted-foreground hover:border-primary/40 hover:text-foreground`,children:[(0,J.jsx)(y,{className:`h-2.5 w-2.5`}),(0,J.jsx)(Y,{text:e,query:a})]},e)),h.length>3?(0,J.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`+`,h.length-3]}):null]}),e.description?(0,J.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-xs text-muted-foreground`,children:(0,J.jsx)(Y,{text:e.description,query:a})}):null]}),(0,J.jsx)(`div`,{className:`flex w-36 shrink-0 items-center justify-end self-center`,children:(0,J.jsxs)(`button`,{onClick:t=>{x&&(t.preventDefault(),e.assignee_user_id?i(`user:${e.assignee_user_id}`):e.assignee_session_id&&i(e.assignee_session_id))},className:u(`inline-flex items-center gap-1.5 font-mono text-[11px]`,x?`text-foreground hover:underline`:`text-muted-foreground/60`,S&&`text-primary/90`),title:Ke(D,x,e.assignee_session_id,e.assignee_user_id),children:[S?(0,J.jsx)(Ge,{}):(0,J.jsx)(We,{state:D}),b]})}),(0,J.jsxs)(`div`,{className:`hidden w-32 shrink-0 flex-col items-end justify-center text-right text-[11px] md:flex`,children:[m.label?(0,J.jsxs)(`span`,{className:u(`font-mono`,m.state===`overdue`?`text-red-400`:m.state===`soon`?`text-amber-300`:`text-muted-foreground`),title:`due ${V(e.due_at??void 0)}`,children:[m.state===`overdue`?`overdue · `:`due · `,m.label]}):null,(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,title:`updated ${V(e.updated_at)}`,children:H(e.updated_at)})]}),(0,J.jsx)(`div`,{className:`hidden w-20 shrink-0 items-center justify-end self-center lg:flex`,children:(0,J.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:de(e.id)})})]})]})})}function We({state:e}){switch(e){case`live`:return(0,J.jsxs)(`span`,{className:`relative inline-flex h-2 w-2 items-center justify-center`,children:[(0,J.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-pulse-slow rounded-full bg-primary/60`}),(0,J.jsx)(`span`,{className:`relative inline-flex h-1.5 w-1.5 rounded-full bg-primary`})]});case`doing`:return(0,J.jsx)(m,{className:`h-2 w-2 fill-primary/80 text-primary/80`});case`abandoned`:return(0,J.jsx)(m,{className:`h-2 w-2 fill-amber-500/70 text-amber-500/70`});case`idle`:return(0,J.jsx)(m,{className:`h-2 w-2 text-primary/60`});default:return(0,J.jsx)(m,{className:`h-2 w-2 text-muted-foreground/40`})}}function Ge(){return(0,J.jsx)(`span`,{className:`inline-flex h-2 w-2 items-center justify-center text-[10px] text-primary/80`,"aria-hidden":!0,children:`@`})}function Ke(e,t,n,r){if(!t)return`Unassigned — anyone can claim`;if(r)return`Assigned to human @${r}`;let i=n?`session ${n.slice(0,8)}`:`an agent`;switch(e){case`live`:return`${i} just touched this — actively engaged`;case`doing`:return`${i} claimed this and is working on it`;case`abandoned`:return`${i} hasn't touched this in >5m — anyone may reclaim`;case`idle`:return`${i} owns this task`;default:return`Unassigned`}}export{Ae as TasksListPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkerApprovalsCard-ore9enWj.js b/internal/web/dist/assets/WorkerApprovalsCard-ore9enWj.js deleted file mode 100644 index 5077a53..0000000 --- a/internal/web/dist/assets/WorkerApprovalsCard-ore9enWj.js +++ /dev/null @@ -1,4 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{t as r}from"./chevron-right-CyhRDGe7.js";import{Fn as i,Ln as a,Sr as o,an as s,i as c,jr as l,n as u,nr as d,r as f,t as p,xn as m,xr as h}from"./index-BDLzoIgt.js";var g=e(t(),1),_=n();function v({approvals:e,onResolved:t}){return e.length===0?null:(0,_.jsxs)(p,{className:`border-amber-400/40 bg-amber-50/20 dark:bg-amber-950/10`,children:[(0,_.jsxs)(f,{children:[(0,_.jsxs)(c,{className:`text-base`,children:[`Pending approvals`,(0,_.jsx)(`span`,{className:`ml-2 rounded-full bg-amber-500/20 px-2 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,children:e.length})]}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This worker stopped mid-run before a write-class tool. Approving will fire a new run with the tool pre-cleared.`})]}),(0,_.jsx)(u,{className:`space-y-3`,children:e.map(e=>(0,_.jsx)(b,{approval:e,onResolved:t},e.id))})]})}var y=3;function b({approval:e,onResolved:t}){let[n,c]=(0,g.useState)(null),[u,f]=(0,g.useState)(!1),{preview:p,full:v,hasMore:b}=(0,g.useMemo)(()=>{let t=x(e.tool_input),n=t.split(` -`);return{full:t,preview:n.slice(0,y).join(` -`),hasMore:n.length>y}},[e.tool_input]);async function S(n){c(n);try{if(n===`approve`){let t=await s(e.id);l.success(t.resumed_run_id?`Approved; new run ${t.resumed_run_id} dispatched`:`Approved`)}else await m(e.id),l.success(`Rejected; run marked rejected`);t()}catch(e){l.error(e instanceof Error?e.message:`${n} failed`)}finally{c(null)}}return(0,_.jsxs)(`div`,{className:`rounded-md border border-amber-400/30 bg-background/60 p-3 text-sm`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`rounded-md bg-amber-500/15 px-1.5 py-0.5 font-mono text-[11px] text-amber-700 dark:text-amber-300`,children:e.tool_name}),(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:[`run `,e.run_id]})]}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.reason})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(i,{size:`sm`,onClick:()=>S(`approve`),disabled:n!==null,"data-testid":`worker-approval-approve`,children:[n===`approve`?(0,_.jsx)(d,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,_.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5`}),`Approve & resume`]}),(0,_.jsxs)(i,{size:`sm`,variant:`outline`,onClick:()=>S(`reject`),disabled:n!==null,className:`text-destructive hover:bg-destructive/10`,"data-testid":`worker-approval-reject`,children:[n===`reject`?(0,_.jsx)(d,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,_.jsx)(a,{className:`mr-1.5 h-3.5 w-3.5`}),`Reject`]})]})]}),v&&v!==`(empty)`&&(0,_.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,_.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:`Tool input`}),(0,_.jsxs)(`pre`,{className:`rounded-md border border-border/60 bg-background/80 p-2 font-mono text-[10px] whitespace-pre-wrap`,children:[u?v:p,!u&&b&&(0,_.jsx)(`span`,{className:`text-muted-foreground/60`,children:` - …`})]}),b&&(0,_.jsxs)(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground/70 hover:text-foreground`,children:[u?(0,_.jsx)(h,{className:`h-3 w-3`}):(0,_.jsx)(r,{className:`h-3 w-3`}),u?`Collapse`:`Expand full input`]})]})]})}function x(e){if(!e)return`(empty)`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}export{v as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkerApprovalsPage-BzrxOctD.js b/internal/web/dist/assets/WorkerApprovalsPage-BzrxOctD.js deleted file mode 100644 index 7a01904..0000000 --- a/internal/web/dist/assets/WorkerApprovalsPage-BzrxOctD.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{Br as r,Dt as i,Fr as a,Ln as o,S as s,Sr as c,_n as l,i as u,n as d,nr as f,r as p,t as m,y as h,yn as g}from"./index-BDLzoIgt.js";import{t as _}from"./WorkerApprovalsCard-ore9enWj.js";var v=e(t(),1),y=n();function b(){let[e,t]=r(),n=e.get(`run_id`),{data:i,loading:a,error:c,refetch:u}=s((0,v.useCallback)(()=>l({status:`pending`}),[])),{data:d}=s((0,v.useCallback)(()=>g(),[])),p=(0,v.useMemo)(()=>{let e=new Map;for(let t of d??[])e.set(t.id,t.name);return e},[d]),m=(0,v.useCallback)(()=>{t(e=>{let t=new URLSearchParams(e);return t.delete(`run_id`),t},{replace:!0})},[t]),{data:h}=s((0,v.useCallback)(()=>l({status:`approved`,limit:25}),[])),{data:_}=s((0,v.useCallback)(()=>l({status:`rejected`,limit:25}),[])),b=(0,v.useMemo)(()=>x(h??[],_??[]),[h,_]);if(a&&!i)return(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(f,{className:`h-4 w-4 animate-spin`}),` Loading approvals…`]});if(c&&!i)return(0,y.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:c});let w=i??[],E=n?w.filter(e=>e.run_id===n):w;return(0,y.jsxs)(`div`,{className:`space-y-5 max-w-4xl`,children:[(0,y.jsxs)(`header`,{children:[(0,y.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Worker approvals`}),(0,y.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Pending propose-mode write-tool dispatches across every worker. Approving fires a new run with the tool pre-cleared.`})]}),n&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs`,children:[(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:`Filtered to run`}),(0,y.jsx)(`code`,{className:`truncate font-mono text-foreground`,title:n,children:n}),(0,y.jsxs)(`button`,{type:`button`,onClick:m,className:`ml-auto inline-flex h-5 items-center gap-0.5 rounded px-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Clear filter`,children:[(0,y.jsx)(o,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{children:`clear`})]})]}),E.length===0?(0,y.jsx)(S,{recap:b,workerNameById:p}):(0,y.jsx)(T,{approvals:E,onResolved:u,workerNameById:p}),E.length>0&&b.items.length>0&&(0,y.jsx)(C,{recap:b,workerNameById:p})]})}function x(e,t){let n=Date.now()-1440*60*1e3,r=e=>e.decided_at&&new Date(e.decided_at).getTime()>=n,i=e.filter(r),a=t.filter(r),o=[...i,...a].sort((e,t)=>{let n=e.decided_at?new Date(e.decided_at).getTime():0;return(t.decided_at?new Date(t.decided_at).getTime():0)-n});return{approved:i.length,rejected:a.length,items:o.slice(0,5)}}function S({recap:e,workerNameById:t}){return e.items.length===0?(0,y.jsxs)(m,{children:[(0,y.jsx)(p,{children:(0,y.jsx)(u,{className:`text-base`,children:`All caught up`})}),(0,y.jsx)(d,{className:`text-sm text-muted-foreground`,children:`No pending approvals. Workers in propose mode stop here when they try to call a write-class tool; you'll see them listed in real time once an approval lands.`})]}):(0,y.jsxs)(m,{children:[(0,y.jsxs)(p,{className:`space-y-1`,children:[(0,y.jsx)(u,{className:`text-base`,children:`All caught up`}),(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Last 24h:`,` `,(0,y.jsxs)(`span`,{className:`font-medium text-emerald-400`,children:[e.approved,` approved`]}),` · `,(0,y.jsxs)(`span`,{className:`font-medium text-destructive`,children:[e.rejected,` rejected`]})]})]}),(0,y.jsx)(d,{children:(0,y.jsx)(w,{items:e.items,workerNameById:t})})]})}function C({recap:e,workerNameById:t}){return(0,y.jsxs)(m,{className:`border-border/60`,children:[(0,y.jsx)(p,{children:(0,y.jsxs)(u,{className:`text-sm text-muted-foreground`,children:[`Recently resolved`,(0,y.jsxs)(`span`,{className:`ml-2 text-[10px] font-normal`,children:[e.approved,` approved · `,e.rejected,` rejected (last 24h)`]})]})}),(0,y.jsx)(d,{children:(0,y.jsx)(w,{items:e.items,workerNameById:t})})]})}function w({items:e,workerNameById:t}){return(0,y.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,y.jsxs)(`li`,{className:`flex items-center gap-3 py-2 text-xs`,children:[e.status===`approved`?(0,y.jsx)(c,{className:`h-3.5 w-3.5 shrink-0 text-emerald-400`}):(0,y.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-destructive`}),(0,y.jsx)(h,{variant:`outline`,className:`font-mono text-[10px]`,children:e.tool_name}),(0,y.jsx)(a,{to:`/workers/${encodeURIComponent(e.worker_id)}`,className:`truncate text-muted-foreground hover:text-foreground`,children:t.get(e.worker_id)??`worker ${e.worker_id}`}),(0,y.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground/60`,children:i(e.decided_at)})]},e.id))})}function T({approvals:e,onResolved:t,workerNameById:n}){let r=new Map;for(let t of e){let e=r.get(t.worker_id)??[];e.push(t),r.set(t.worker_id,e)}return(0,y.jsx)(`div`,{className:`space-y-4`,children:Array.from(r.entries()).map(([e,r])=>(0,y.jsxs)(`section`,{className:`space-y-2`,children:[(0,y.jsxs)(a,{to:`/workers/${encodeURIComponent(e)}`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,children:[n.get(e)??`Worker ${e}`,` →`]}),(0,y.jsx)(_,{approvals:r,onResolved:t})]},e))})}export{b as WorkerApprovalsPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkerCostDashboardPage-DZZrzIFA.js b/internal/web/dist/assets/WorkerCostDashboardPage-DZZrzIFA.js deleted file mode 100644 index 911c957..0000000 --- a/internal/web/dist/assets/WorkerCostDashboardPage-DZZrzIFA.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,f as n,l as r,t as i}from"./recharts-V3eOq3uM.js";import{on as a}from"./client-CaIRceNv.js";import{Fn as o,Fr as s,S as c,fn as l,gr as u,i as d,n as f,nr as p,pn as m,r as h,t as g,wr as _,yn as v}from"./index-BDLzoIgt.js";import{t as y}from"./empty-state-B9mtYx_X.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./table-2N0Q-yAm.js";var E=e(n(),1),D=a();function O(){let{data:e,loading:t,error:n,refetch:r}=c((0,E.useCallback)(()=>m({days:30}),[])),{data:i}=c((0,E.useCallback)(()=>v(),[])),[a,l]=(0,E.useState)(`mtd`),[d,h]=(0,E.useState)(`desc`),w=(0,E.useMemo)(()=>e?R(e.workers,a,d):[],[e,a,d]),O=(0,E.useMemo)(()=>A(e?.workers??[],i??[]),[e,i]);function M(e){a===e?h(d===`asc`?`desc`:`asc`):(l(e),h(e===`name`?`asc`:`desc`))}return(0,D.jsxs)(`div`,{className:`space-y-5`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h1`,{className:`flex items-center gap-2 text-2xl font-bold tracking-tight`,children:[(0,D.jsx)(u,{className:`h-6 w-6`}),` Worker cost`]}),(0,D.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:`Workspace-wide spend across every Worker. Updated when runs finalise — the daemon doesn't poll model APIs for billing.`})]}),(0,D.jsxs)(o,{variant:`ghost`,size:`sm`,onClick:r,disabled:t,children:[t?(0,D.jsx)(p,{className:`mr-1.5 h-4 w-4 animate-spin`}):null,`Refresh`]})]}),n&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:[(0,D.jsx)(`span`,{children:n}),(0,D.jsx)(o,{size:`sm`,variant:`ghost`,onClick:r,children:`Retry`})]}),e&&(0,D.jsx)(k,{totalMTD:e.total_mtd_usd,workers:i??[]}),t&&!e?(0,D.jsx)(N,{}):e?(0,D.jsx)(j,{totalMTD:e.total_mtd_usd,totalWindow:e.total_window_usd,totalRuns:e.total_runs_30d,days:e.days,breakdown:O}):null,e&&e.workers.length===0?(0,D.jsx)(y,{icon:(0,D.jsx)(_,{className:`h-10 w-10`}),title:`No worker activity in the last 30 days`,description:`Once your Workers run, their spend shows up here.`,action:(0,D.jsx)(o,{asChild:!0,children:(0,D.jsx)(s,{to:`/workers`,children:`Manage workers`})})}):null,w.length>0?(0,D.jsx)(g,{children:(0,D.jsx)(f,{className:`p-0`,children:(0,D.jsxs)(T,{children:[(0,D.jsx)(b,{children:(0,D.jsxs)(C,{children:[(0,D.jsx)(x,{children:(0,D.jsx)(P,{label:`Worker`,active:a===`name`,dir:d,onClick:()=>M(`name`)})}),(0,D.jsx)(x,{className:`text-right`,children:(0,D.jsx)(P,{label:`MTD spend`,active:a===`mtd`,dir:d,onClick:()=>M(`mtd`)})}),(0,D.jsx)(x,{className:`text-right`,children:(0,D.jsx)(P,{label:`30-day runs`,active:a===`runs`,dir:d,onClick:()=>M(`runs`)})}),(0,D.jsx)(x,{className:`w-48`,children:`Trend`})]})}),(0,D.jsx)(S,{children:w.map(e=>(0,D.jsx)(F,{row:e,workers:i??[]},e.worker_id))})]})})}):null]})}function k({totalMTD:e,workers:t}){let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),1),i=new Date(n.getFullYear(),n.getMonth()+1,1),a=Math.min(100,(n.getTime()-r.getTime())/(i.getTime()-r.getTime())*100),o=a>0?e*100/a:e,s=o>0?Math.min(100,e/o*100):0;return(0,D.jsxs)(`div`,{className:`space-y-1.5`,"data-testid":`workers-month-progress`,children:[(0,D.jsxs)(`div`,{className:`flex items-baseline justify-between text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:[(0,D.jsx)(`span`,{children:`Month progress`}),(0,D.jsxs)(`span`,{className:`text-foreground font-mono normal-case`,children:[`$`,e.toFixed(4),` spent · `,Math.round(a),`% of month elapsed`]})]}),(0,D.jsxs)(`div`,{className:`relative h-2 w-full overflow-hidden bg-muted`,children:[(0,D.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-muted-foreground/30`,style:{width:`${a}%`},"aria-label":`elapsed`}),(0,D.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-gradient-to-r from-primary/60 to-primary/30`,style:{width:`${s}%`},"aria-label":`spent`})]})]})}function A(e,t){let n=new Map(t.map(e=>[e.id,e.model_provider||`unknown`])),r=new Map;for(let t of e){let e=n.get(t.worker_id)??`unknown`;r.set(e,(r.get(e)??0)+t.month_to_date_usd)}return Array.from(r.entries()).map(([e,t])=>({provider:e,cost:t})).filter(e=>e.cost>0).sort((e,t)=>t.cost-e.cost)}function j({totalMTD:e,totalWindow:t,totalRuns:n,days:r,breakdown:i}){return(0,D.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:[(0,D.jsxs)(g,{children:[(0,D.jsx)(h,{className:`pb-1`,children:(0,D.jsx)(d,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:`Workspace MTD`})}),(0,D.jsxs)(f,{children:[(0,D.jsxs)(`div`,{className:`font-mono text-3xl font-bold text-foreground`,children:[`$`,e.toFixed(4)]}),i.length>0&&(0,D.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,D.jsx)(M,{breakdown:i,total:e}),(0,D.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted-foreground/80`,children:i.map(e=>(0,D.jsxs)(`span`,{className:`font-mono`,children:[`$`,e.cost.toFixed(2),` `,e.provider]},e.provider))})]})]})]}),(0,D.jsxs)(g,{children:[(0,D.jsx)(h,{className:`pb-1`,children:(0,D.jsxs)(d,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:[`Last `,r,` days`]})}),(0,D.jsx)(f,{children:(0,D.jsxs)(`div`,{className:`font-mono text-3xl font-bold text-foreground`,children:[`$`,t.toFixed(4)]})})]}),(0,D.jsxs)(g,{children:[(0,D.jsx)(h,{className:`pb-1`,children:(0,D.jsxs)(d,{className:`text-xs uppercase tracking-wide text-muted-foreground`,children:[`Runs (`,r,`d)`]})}),(0,D.jsx)(f,{children:(0,D.jsx)(`div`,{className:`font-mono text-3xl font-bold text-foreground`,children:n})})]})]})}function M({breakdown:e,total:t}){if(t<=0)return null;let n={anthropic:`bg-amber-500/70`,openai:`bg-emerald-500/70`,openai_compat:`bg-purple-500/70`,claude_cli:`bg-sky-500/70`,opencode_cli:`bg-violet-500/70`,grok_cli:`bg-teal-500/70`,mimo_cli:`bg-rose-500/70`,unknown:`bg-muted-foreground/40`};return(0,D.jsx)(`div`,{className:`flex h-1.5 w-full overflow-hidden bg-muted`,children:e.map(e=>(0,D.jsx)(`span`,{className:n[e.provider]??`bg-muted-foreground/40`,style:{width:`${e.cost/t*100}%`},title:`${e.provider}: $${e.cost.toFixed(4)}`},e.provider))})}function N(){return(0,D.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(g,{children:(0,D.jsxs)(f,{className:`p-4`,children:[(0,D.jsx)(`div`,{className:`mb-2 h-3 w-24 animate-pulse bg-muted`}),(0,D.jsx)(`div`,{className:`h-8 w-32 animate-pulse bg-muted`})]})},t))})}function P({label:e,active:t,dir:n,onClick:r}){return(0,D.jsxs)(`button`,{type:`button`,onClick:r,className:`inline-flex items-center gap-1 text-xs font-medium uppercase tracking-wide ${t?`text-foreground`:`text-muted-foreground`}`,children:[e,t?(0,D.jsx)(`span`,{"aria-hidden":!0,children:n===`asc`?`▲`:`▼`}):null]})}function F({row:e,workers:t}){let[n,r]=(0,E.useState)(null);return t.find(t=>t.id===e.worker_id)&&n===null&&l(e.worker_id).then(e=>r(e.worker.max_monthly_cost_usd)).catch(()=>r(0)),(0,D.jsxs)(C,{children:[(0,D.jsx)(w,{className:`font-medium`,children:(0,D.jsx)(s,{to:`/workers/${e.worker_id}`,className:`hover:underline`,children:e.worker_name})}),(0,D.jsxs)(w,{className:`text-right font-mono`,children:[(0,D.jsxs)(`div`,{children:[`$`,e.month_to_date_usd.toFixed(4)]}),n!==null&&n>0&&(0,D.jsx)(I,{mtd:e.month_to_date_usd,cap:n})]}),(0,D.jsx)(w,{className:`text-right font-mono text-muted-foreground`,children:e.run_count_30d}),(0,D.jsx)(w,{className:`w-48`,children:(0,D.jsx)(L,{data:e.daily_costs})})]})}function I({mtd:e,cap:t}){let n=Math.min(100,e/t*100);return(0,D.jsxs)(`div`,{className:`mt-1 flex items-center justify-end gap-2`,children:[(0,D.jsx)(`div`,{className:`h-1 w-20 overflow-hidden bg-muted`,children:(0,D.jsx)(`div`,{className:n>=90?`bg-destructive`:n>=75?`bg-amber-500`:`bg-emerald-500/70`,style:{width:`${n}%`,height:`100%`}})}),(0,D.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground/70`,children:[`/ $`,t.toFixed(0)]})]})}function L({data:e}){let n=(0,E.useId)().replace(/[^A-Za-z0-9_-]/g,`-`)+`-row-cost-fill`;return e.some(e=>e.cost_usd>0)?(0,D.jsx)(`div`,{className:`h-10`,children:(0,D.jsx)(r,{width:`100%`,height:`100%`,children:(0,D.jsxs)(i,{data:e,margin:{top:2,right:4,bottom:2,left:4},children:[(0,D.jsx)(`defs`,{children:(0,D.jsxs)(`linearGradient`,{id:n,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:`currentColor`,stopOpacity:.35}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:`currentColor`,stopOpacity:0})]})}),(0,D.jsx)(t,{type:`monotone`,dataKey:`cost_usd`,stroke:`currentColor`,strokeWidth:1.5,fill:`url(#${n})`,className:`text-primary`})]})})}):(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground/60`,children:`no spend`})}function R(e,t,n){let r=[...e];return r.sort((e,r)=>{let i=0;return i=t===`name`?e.worker_name.localeCompare(r.worker_name):t===`mtd`?e.month_to_date_usd-r.month_to_date_usd:e.run_count_30d-r.run_count_30d,n===`asc`?i:-i}),r}export{O as WorkerCostDashboardPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkerDetailPage-B_5gmtcO.js b/internal/web/dist/assets/WorkerDetailPage-B_5gmtcO.js deleted file mode 100644 index db467da..0000000 --- a/internal/web/dist/assets/WorkerDetailPage-B_5gmtcO.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,c as n,f as r,i,l as a,r as o,t as s}from"./recharts-V3eOq3uM.js";import{Ft as c,W as l,in as u,on as d}from"./client-CaIRceNv.js";import{t as f}from"./createLucideIcon-WB390fY6.js";import{t as p}from"./calendar-clock-Z37rBeGY.js";import{t as m}from"./chevron-right-CyhRDGe7.js";import{r as h,t as g}from"./WorkersListPage-Cj-R7WbZ.js";import{t as _}from"./pencil-Dy4EC74G.js";import{t as v}from"./play-YbzkBfB8.js";import{t as y}from"./share-2-Da_vtMGy.js";import{t as b}from"./square-BOz_C5qq.js";import{At as x,Bn as S,Ct as ee,Dt as te,En as ne,Er as re,Fn as C,Fr as w,Ft as T,Gn as ie,Ln as ae,Mt as E,Or as oe,Pt as D,Qn as O,Rr as se,S as k,Sn as ce,Tt as le,_ as ue,_n as de,bn as fe,dn as pe,fn as me,gr as he,i as A,j as ge,jr as j,jt as M,kt as _e,ln as ve,n as N,nr as P,on as ye,r as F,t as I,un as be,vn as xe,wn as Se,wr as Ce,xr as L,y as R,zr as we}from"./index-BDLzoIgt.js";import{t as Te}from"./TaskRef-D6QBTHtc.js";import{r as Ee}from"./api-C7pu_Aru.js";import{n as z,r as De,t as Oe}from"./WorkerLiveTail-WfoppFSb.js";import{t as ke}from"./WorkerApprovalsCard-ore9enWj.js";var Ae=f(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),je=f(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),B=e(r(),1);function Me(e,t=`latest`){return c(`/worker-templates/${encodeURIComponent(e)}/${encodeURIComponent(typeof t==`number`?String(t):t)}`)}function Ne(e,t){return c(`/workers/${encodeURIComponent(e)}/publish`,{method:`POST`,body:JSON.stringify(t??{})})}var V=d(),H=80;function Pe({run:e,onCancelled:t}){let n=e.status===`running`,{run:r,liveTranscript:i}=De(e.worker_id,e.id,{enabled:n}),a=r??e,[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),d=a.finished_at?new Date(a.finished_at):null,f=new Date(a.started_at),p=a.duration_ms>0?`${(a.duration_ms/1e3).toFixed(2)}s`:null,m=a.status===`running`,h=z(a.input_tokens,500),g=z(a.output_tokens,500),_=z(a.cost_usd,500);async function v(){if(!(!m||c)&&window.confirm(`Hard stop this run? This immediately cancels the model subprocess and marks the run as cancelled. It cannot be undone.`)){l(!0);try{await ye(a.id),j.success(`Hard stop requested — run will terminate shortly`),t?.()}catch(e){let t=e instanceof Error?e.message:String(e||`cancel failed`);t.includes(`409`)||t.includes(`already finished`)||t.includes(`not cancellable`)?j.info(`Run already finished; not cancellable`):t.includes(`404`)||t.includes(`not found`)?j.error(`Run not found`):j.error(`Failed to cancel run: ${t}`)}finally{l(!1)}}}return(0,V.jsxs)(`div`,{className:`rounded-md border border-border bg-card/40 p-3 text-sm`,"data-testid":`worker-run-card-${a.id}`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,V.jsxs)(R,{variant:`outline`,className:M(a.status),children:[m?(0,V.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):null,a.status]}),(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:te(a.started_at)}),p&&(0,V.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`· `,p]}),m&&(0,V.jsxs)(C,{size:`sm`,variant:`destructive`,className:`h-6 px-2 text-[10px]`,disabled:c,onClick:v,title:`Hard stop: immediately cancel the live model run and kill any subprocess`,"data-testid":`worker-run-hard-stop-${a.id}`,children:[c?(0,V.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):(0,V.jsx)(b,{className:`mr-1 h-3 w-3`}),c?`Stopping…`:`Hard stop`]}),(0,V.jsx)(`span`,{className:`ml-auto truncate font-mono text-[10px] text-muted-foreground/70`,title:a.id,children:a.id})]}),(0,V.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-x-4 gap-y-1 text-xs sm:grid-cols-4`,children:[(0,V.jsx)(U,{label:`Model`,value:E(a.model_provider,a.model_id)}),(0,V.jsx)(U,{label:`Tokens`,value:`${Math.round(h).toLocaleString()} in / ${Math.round(g).toLocaleString()} out`,live:m}),(0,V.jsx)(U,{label:`Cost`,value:`$${_.toFixed(4)}`,live:m}),(0,V.jsx)(U,{label:`Tool calls`,value:String(a.tool_calls_count),live:m,hint:a.tool_calls_count_source===`derived`?`Derived from audit_records — CLI adapters (claude_cli / opencode_cli / grok_cli / mimo_cli) dispatch tools via their own MCP connection. max_tool_calls is enforced via cli_audit counting at finalize, not the gateway loop.`:void 0})]}),a.tool_calls_cap_exceeded&&(0,V.jsxs)(`div`,{className:`mt-2 rounded-md border border-amber-500/30 bg-amber-500/10 px-2.5 py-1.5 text-[11px] text-amber-200`,children:[`Tool-call cap exceeded`,a.tool_calls_cap_scope===`cli_audit`?` (CLI audit count)`:``]}),a.deliverable_status&&a.deliverable_status!==`unknown`&&(0,V.jsxs)(`div`,{className:u(`mt-2 rounded-md border px-2.5 py-1.5 text-[11px]`,a.deliverable_status===`success_with_output`?`border-emerald-500/30 bg-emerald-500/10 text-emerald-200`:a.deliverable_status===`spend_no_commit`?`border-amber-500/30 bg-amber-500/10 text-amber-200`:`border-red-500/30 bg-red-500/10 text-red-200`),children:[`Deliverable: `,a.deliverable_status.replaceAll(`_`,` `),a.deliverable_branch?` · branch ${a.deliverable_branch}`:``,a.deliverable_commit?` · ${a.deliverable_commit.slice(0,12)}`:``]}),a.status===`awaiting_approval`&&(0,V.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/10 p-2.5 text-xs text-amber-300`,children:[(0,V.jsx)(ie,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,V.jsxs)(`div`,{children:[`This run is paused awaiting your approval — see the`,` `,(0,V.jsx)(w,{to:`/worker-approvals?run_id=${encodeURIComponent(a.id)}`,className:`underline underline-offset-2 hover:text-amber-200`,children:`Approvals panel`}),`.`]})]}),a.error&&(0,V.jsx)(`div`,{className:`mt-3 rounded-md border border-destructive/30 bg-destructive/5 p-2.5 text-xs text-destructive whitespace-pre-wrap`,children:a.error}),(0,V.jsx)(Fe,{open:o,setOpen:s,output:m&&!a.output_text?i:a.output_text,live:m&&!a.output_text}),d&&(0,V.jsxs)(`div`,{className:`mt-2 text-[10px] text-muted-foreground/60`,children:[`started `,f.toLocaleString(),` · finished `,d.toLocaleString()]})]})}function Fe({open:e,setOpen:t,output:n,live:r}){let i=n.slice(0,H).replace(/\s+/g,` `).trim(),a=n.length,o=(a/1024).toFixed(1),s=a>H,c=r?`live output`:`output`;return(0,V.jsxs)(`div`,{className:`mt-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,children:[e?(0,V.jsx)(L,{className:`h-3 w-3`}):(0,V.jsx)(m,{className:`h-3 w-3`}),e?`Hide ${c}`:s?`Show ${c} (${a<1024?`${a}b`:`${o}kb`})`:`Show ${c}`]}),!e&&i&&(0,V.jsxs)(`span`,{className:`ml-2 truncate text-[11px] text-muted-foreground/70`,children:[i,s?`…`:``]}),e&&(0,V.jsx)(`div`,{className:`mt-2 max-h-72 overflow-auto border p-3 font-mono text-[11px] whitespace-pre-wrap ${r?`border-sky-500/30 bg-sky-500/5`:`border-border/60 bg-background/60`}`,children:n?(0,V.jsx)(Te,{text:n}):(0,V.jsx)(`span`,{className:`text-muted-foreground/70`,children:r?`(waiting for first token…)`:`(no output captured)`})})]})}function U({label:e,value:t,live:n,hint:r}){return(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:[(0,V.jsx)(`span`,{children:e}),r&&(0,V.jsx)(`span`,{className:`cursor-help font-mono text-[9px] text-muted-foreground/70 underline decoration-dotted`,title:r,"aria-label":r,children:`?`})]}),(0,V.jsx)(`div`,{className:`font-mono text-xs ${n?`text-sky-300`:`text-foreground`}`,children:t})]})}function Ie({runs:e,compact:r=!1}){let{series:c,total:l}=(0,B.useMemo)(()=>Le(e,30),[e]),u=l>0,d=(0,B.useId)().replace(/[^A-Za-z0-9_-]/g,`-`)+`-cost-fill`;return r?u?(0,V.jsx)(`div`,{className:`h-10`,children:(0,V.jsx)(a,{width:`100%`,height:`100%`,children:(0,V.jsxs)(s,{data:c,margin:{top:2,right:4,bottom:2,left:4},children:[(0,V.jsx)(`defs`,{children:(0,V.jsxs)(`linearGradient`,{id:d,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,V.jsx)(`stop`,{offset:`0%`,stopColor:`currentColor`,stopOpacity:.35}),(0,V.jsx)(`stop`,{offset:`100%`,stopColor:`currentColor`,stopOpacity:0})]})}),(0,V.jsx)(t,{type:`monotone`,dataKey:`cost`,stroke:`currentColor`,strokeWidth:1.5,fill:`url(#${d})`,className:`text-primary`})]})})}):(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground/60`,children:`no spend`}):(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`Total · last 30 days`}),(0,V.jsxs)(`div`,{className:`font-mono text-lg text-foreground`,children:[`$`,l.toFixed(4)]})]}),(0,V.jsxs)(`div`,{className:`text-[10px] text-muted-foreground/60`,children:[e.length,` run`,e.length===1?``:`s`,` included`]})]}),u?(0,V.jsx)(`div`,{className:`mt-3 h-32`,children:(0,V.jsx)(a,{width:`100%`,height:`100%`,children:(0,V.jsxs)(s,{data:c,margin:{top:4,right:8,bottom:0,left:0},children:[(0,V.jsx)(`defs`,{children:(0,V.jsxs)(`linearGradient`,{id:d,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,V.jsx)(`stop`,{offset:`0%`,stopColor:`currentColor`,stopOpacity:.4}),(0,V.jsx)(`stop`,{offset:`100%`,stopColor:`currentColor`,stopOpacity:0})]})}),(0,V.jsx)(i,{dataKey:`day`,tick:{fontSize:10},interval:`preserveStartEnd`,stroke:`currentColor`,opacity:.4}),(0,V.jsx)(o,{tick:{fontSize:10},width:48,stroke:`currentColor`,opacity:.4,tickFormatter:e=>e<1?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}),(0,V.jsx)(n,{contentStyle:{background:`rgba(0,0,0,0.8)`,border:`1px solid rgba(255,255,255,0.1)`,fontSize:11},formatter:e=>[`$${Number(e??0).toFixed(4)}`,`cost`]}),(0,V.jsx)(t,{type:`monotone`,dataKey:`cost`,stroke:`currentColor`,strokeWidth:1.5,fill:`url(#${d})`,className:`text-primary`})]})})}):(0,V.jsx)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:`No billable runs in the last 30 days.`})]})}function Le(e,t){let n=new Map,r=new Date;for(let e=t-1;e>=0;e--){let t=new Date(r);t.setDate(r.getDate()-e),n.set(W(t),0)}let i=0;for(let t of e){let e=t.finished_at??t.started_at;if(!e)continue;let r=W(new Date(e));if(!n.has(r))continue;let a=t.cost_usd||0;n.set(r,(n.get(r)??0)+a),i+=a}return{series:Array.from(n.entries()).map(([e,t])=>({day:e.slice(5),cost:t})),total:i}}function W(e){return`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`}function Re({worker:e}){return(0,V.jsxs)(`dl`,{className:`grid grid-cols-1 gap-x-6 gap-y-3 text-xs sm:grid-cols-2`,children:[(0,V.jsx)(K,{label:`Provider`,children:E(e.model_provider,e.model_id)}),(0,V.jsx)(K,{label:`Endpoint`,children:e.model_endpoint_url||`—`}),(0,V.jsx)(K,{label:`Secret scope`,children:e.secret_scope_id||`—`}),(0,V.jsx)(K,{label:`Skill`,children:e.skill_name?`${e.skill_name}${e.skill_version?`@${e.skill_version}`:``}`:`—`}),(0,V.jsxs)(K,{label:`Schedule`,children:[(0,V.jsx)(`div`,{children:ee(e.schedule_spec)}),(0,V.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground/70`,children:e.schedule_spec})]}),(0,V.jsx)(K,{label:`Exec mode`,children:e.exec_mode}),(0,V.jsx)(K,{label:`Concurrency policy`,children:e.concurrency_policy}),(0,V.jsx)(K,{label:`Workspace`,children:e.workspace_id}),(0,V.jsx)(K,{label:`Prompt template`,wide:!0,children:(0,V.jsx)(q,{children:e.prompt_template||`(empty)`})}),(0,V.jsx)(K,{label:`Parameters`,wide:!0,children:(0,V.jsx)(q,{children:J(e.parameters_json)})}),(0,V.jsx)(K,{label:`Tool allowlist`,wide:!0,children:(0,V.jsx)(q,{children:J(e.tool_allowlist_json)})}),(0,V.jsx)(K,{label:`Output channels`,wide:!0,children:(0,V.jsx)(q,{children:J(e.output_channels_json)})}),(0,V.jsx)(K,{label:`Max input tokens`,children:G(e.max_input_tokens,`no cap`)}),(0,V.jsx)(K,{label:`Max output tokens`,children:G(e.max_output_tokens,`default (4096)`)}),(0,V.jsx)(K,{label:`Max tool calls`,children:G(e.max_tool_calls,`default (50)`)}),(0,V.jsx)(K,{label:`Max wall-clock seconds`,children:G(e.max_wall_clock_seconds,`default (300)`)}),(0,V.jsx)(K,{label:`Max monthly cost (USD)`,children:e.max_monthly_cost_usd>0?`$${e.max_monthly_cost_usd.toFixed(2)}`:`no cap`}),(0,V.jsx)(K,{label:`Max consecutive failures`,children:G(e.max_consecutive_failures,`no auto-pause`)}),e.auto_paused_reason&&e.auto_paused_reason.trim()!==``&&(0,V.jsx)(K,{label:`Auto-paused reason`,wide:!0,children:(0,V.jsx)(`span`,{className:`text-destructive`,children:e.auto_paused_reason})})]})}function G(e,t){return e?String(e):t}function K({label:e,children:t,wide:n}){return(0,V.jsxs)(`div`,{className:n?`sm:col-span-2`:``,children:[(0,V.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/60`,children:e}),(0,V.jsx)(`dd`,{className:`mt-0.5 text-foreground`,children:t})]})}function q({children:e}){return(0,V.jsx)(`pre`,{className:`max-h-56 overflow-auto rounded-md border border-border/60 bg-background/60 p-2.5 font-mono text-[11px] whitespace-pre-wrap`,children:e})}function J(e){if(!e)return`(empty)`;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function ze({worker:e,runs:t}){let n=h(e.schedule_spec,Ve(t),e.enabled),r=(0,B.useMemo)(()=>Be(t),[t]),i=e.enabled&&le(e.schedule_spec);return(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-px overflow-hidden border border-border bg-border md:grid-cols-4`,"data-testid":`worker-vitals-strip`,children:[(0,V.jsx)(Y,{icon:(0,V.jsx)(p,{className:`h-4 w-4`}),label:e.enabled?i?`Fires on`:`Next run in`:`Status`,value:e.enabled?i?`Trigger`:n.humanCountdown:e.auto_paused_reason?`Auto-paused`:`Paused`,tone:e.enabled?`primary`:`muted`,sub:i?e.schedule_spec:e.enabled&&n.nextRunDate?n.nextRunDate.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):e.schedule_spec}),(0,V.jsx)(Y,{icon:(0,V.jsx)(Ae,{className:`h-4 w-4`}),label:`Runs today`,value:String(r.runsToday),sub:r.runsToday===0?`no runs yet`:`last: ${r.lastRunRelative}`}),(0,V.jsx)(Y,{icon:(0,V.jsx)(he,{className:`h-4 w-4`}),label:`$ today`,value:He(r.costToday),sub:`${r.costToday>0?`spent today`:`no spend yet`}`}),(0,V.jsx)(Y,{icon:(0,V.jsx)(je,{className:`h-4 w-4`}),label:`Success rate 7d`,value:r.totalLastWeek===0?`—`:`${Math.round(r.successLastWeek/r.totalLastWeek*100)}%`,sub:r.totalLastWeek===0?`no runs in last 7d`:`${r.successLastWeek}/${r.totalLastWeek} successful`,tone:r.totalLastWeek===0?`muted`:r.successLastWeek/r.totalLastWeek>=.9?`success`:r.successLastWeek/r.totalLastWeek>=.5?`warn`:`danger`})]})}function Y({icon:e,label:t,value:n,sub:r,tone:i=`muted`}){return(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 bg-card/60 p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:[(0,V.jsx)(`span`,{className:`text-muted-foreground/60`,children:e}),t]}),(0,V.jsx)(`div`,{className:`truncate font-mono text-2xl font-bold leading-none tabular-nums md:text-3xl ${i===`primary`?`text-primary`:i===`success`?`text-emerald-400`:i===`warn`?`text-amber-400`:i===`danger`?`text-destructive`:`text-foreground`}`,children:n}),r&&(0,V.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground/70`,children:r})]})}function Be(e){let t=x().getTime(),n=Date.now()-10080*60*1e3,r=0,i=0,a=0,o=0,s=0;for(let c of e){let e=new Date(c.started_at).getTime();Number.isNaN(e)||(e>s&&(s=e),e>=t&&(r++,i+=c.cost_usd||0),e>=n&&(c.status===`success`||c.status===`failure`||c.status===`cap_exceeded`||c.status===`rejected`)&&(o++,c.status===`success`&&a++))}return{runsToday:r,costToday:i,successLastWeek:a,totalLastWeek:o,lastRunRelative:s>0?Ue(Date.now()-s):`—`}}function Ve(e){let t;for(let n of e){let e=n.finished_at??n.started_at;e&&(!t||new Date(e).getTime()>new Date(t).getTime())&&(t=e)}return t}function He(e){return e<=0?`$0`:e<.01?`<$0.01`:e<100?`$${e.toFixed(2)}`:`$${Math.round(e)}`}function Ue(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}var X=[`finding`,`task`,`alert`,`question`,`result`,`event`,`reply`];function We(){let[e,t]=(0,B.useState)({peers:[],agents:[],tags:[],audiences:[],kinds:X,loading:!0});return(0,B.useEffect)(()=>{let e=!1;async function n(){try{let[n,r]=await Promise.all([l().catch(()=>null),Ee(`/peers`).catch(()=>null)]);if(e)return;let i=[{peerID:`self`,self:!0}];for(let e of r?.peers??[])e.peer_id&&i.push({peerID:e.peer_id,displayName:e.display_name||void 0});let a=new Map;for(let e of n?.agents??[])e.name&&(a.has(e.name)||a.set(e.name,{name:e.name,role:e.role,origin:e.origin}));let o=new Set,s=new Set([`*`]);for(let e of n?.messages??[]){if(e.tags)for(let t of e.tags.split(`,`)){let e=t.trim();e&&o.add(e)}e.audience&&e.audience!==`*`&&s.add(e.audience)}t({peers:i,agents:Array.from(a.values()).sort((e,t)=>e.name.localeCompare(t.name)),tags:Array.from(o).sort(),audiences:Array.from(s).sort(),kinds:X,loading:!1})}catch{e||t(e=>({...e,loading:!1}))}}n();let r=window.setInterval(()=>void n(),3e4);return()=>{e=!0,window.clearInterval(r)}},[]),e}function Ge(e){return e.self?`self (this machine)`:e.displayName?`${e.displayName} (${Z(e.peerID)})`:Z(e.peerID)}function Z(e){return e.length<=16?e:`${e.slice(0,8)}…${e.slice(-6)}`}function Ke({workerID:e,workerName:t}){let[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!0),[c,l]=(0,B.useState)(null),u=(0,B.useCallback)(async()=>{try{r(await xe(e)??[]),l(null)}catch(e){l(e.message)}finally{s(!1)}},[e]);(0,B.useEffect)(()=>{u()},[u]);let d=async t=>{try{await ve(e,t),j.success(`Mesh trigger created`),a(!1),await u()}catch(e){j.error(`Failed to create trigger: `+e.message)}},f=async t=>{try{await ne(e,t.id,{enabled:!t.enabled}),await u()}catch(e){j.error(`Failed to toggle: `+e.message)}},p=async t=>{if(confirm(`Delete this mesh trigger? It will stop firing immediately.`))try{await pe(e,t.id),j.success(`Trigger deleted`),await u()}catch(e){j.error(`Failed to delete: `+e.message)}};return(0,V.jsxs)(I,{children:[(0,V.jsxs)(F,{className:`flex flex-row items-center justify-between space-y-0 pb-3`,children:[(0,V.jsxs)(A,{className:`flex items-center gap-2 text-base`,children:[(0,V.jsx)(re,{className:`h-4 w-4`}),` Mesh triggers`,n.length>0&&(0,V.jsx)(R,{variant:`outline`,className:`font-mono text-[10px]`,children:n.length})]}),!i&&(0,V.jsxs)(C,{size:`sm`,variant:`outline`,onClick:()=>a(!0),children:[(0,V.jsx)(O,{className:`mr-1 h-3 w-3`}),` Add mesh trigger`]})]}),(0,V.jsx)(N,{className:`space-y-3`,children:o?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`}):c?(0,V.jsx)(`p`,{className:`text-sm text-destructive`,children:c}):(0,V.jsxs)(V.Fragment,{children:[i&&(0,V.jsx)(Je,{workerName:t,onCancel:()=>a(!1),onSubmit:d}),n.length===0&&!i?(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No mesh triggers configured. `,t,` only fires on its schedule.`]}):n.map(e=>(0,V.jsx)(Q,{trigger:e,onToggle:()=>f(e),onDelete:()=>p(e)},e.id))]})})]})}function Q({trigger:e,onToggle:t,onDelete:n}){return(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded border bg-muted/30 p-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:qe(e)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted-foreground`,children:[(0,V.jsxs)(`span`,{children:[`throttle `,e.throttle_seconds,`s`]}),(0,V.jsxs)(`span`,{children:[`max chain depth `,e.max_chain_depth]}),e.from_filters.length>0&&(0,V.jsxs)(`span`,{children:[e.from_filters.length,` source filter(s)`]})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(g,{enabled:e.enabled,busy:!1,onToggle:t}),(0,V.jsx)(C,{size:`icon`,variant:`ghost`,onClick:n,children:(0,V.jsx)(S,{className:`h-4 w-4 text-muted-foreground`})})]})]})}function qe(e){let t=[];if(e.kind_match&&t.push(`kind=${e.kind_match}`),e.tag_match&&t.push(`tags=${e.tag_match}`),e.audience_match&&e.audience_match!==`*`&&t.push(`audience=${e.audience_match}`),e.content_regex&&t.push(`content~${e.content_regex}`),e.from_filters.length>0){let n=e.from_filters.map(e=>e.peer_id||e.agent_name||e.role).filter(Boolean);n.length>0&&t.push(`from=${n.join(`|`)}`)}return t.length===0?`Fires on every mesh message`:`When mesh receives `+t.join(` AND `)}function Je({workerName:e,onCancel:t,onSubmit:n}){let r=We(),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)(``),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)([{}]),[m,h]=(0,B.useState)(60),[g,_]=(0,B.useState)(3),[v,y]=(0,B.useState)(!1),b=(e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,...t}:n))},x=e=>{p(t=>t.length<=1?[{}]:t.filter((t,n)=>n!==e))};return(0,V.jsxs)(`div`,{className:`space-y-3 border bg-background p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Configure when `,(0,V.jsx)(`span`,{className:`font-medium`,children:e}),` fires on incoming mesh messages. Suggestions are pulled from live mesh activity — type to filter or enter a new value.`]}),(0,V.jsx)(R,{variant:`outline`,tone:`info`,className:`shrink-0 text-[10px]`,children:`MCP-configurable`})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,V.jsx)($,{label:`Kind`,children:(0,V.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),className:`w-full border bg-background px-2 py-1 text-sm`,children:[(0,V.jsx)(`option`,{value:``,children:`any kind`}),r.kinds.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})}),(0,V.jsxs)($,{label:`Tags (comma-separated)`,children:[(0,V.jsx)(T,{list:`mesh-known-tags`,value:o,onChange:e=>s(e.target.value),placeholder:r.tags.length?`pick or type…`:`no tags seen yet`}),(0,V.jsx)(`datalist`,{id:`mesh-known-tags`,children:r.tags.map(e=>(0,V.jsx)(`option`,{value:e},e))})]}),(0,V.jsx)($,{label:`Audience`,children:(0,V.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),className:`w-full border bg-background px-2 py-1 text-sm`,children:[(0,V.jsx)(`option`,{value:``,children:`any audience`}),r.audiences.map(e=>(0,V.jsx)(`option`,{value:e,children:e===`*`?`* (broadcast)`:e},e))]})}),(0,V.jsx)($,{label:`Throttle (seconds)`,children:(0,V.jsx)(T,{type:`number`,min:1,value:m,onChange:e=>h(Number(e.target.value)||60)})}),(0,V.jsx)($,{label:`Max chain depth (1–10)`,children:(0,V.jsx)(T,{type:`number`,min:1,max:10,value:g,onChange:e=>_(Number(e.target.value)||3)})})]}),(0,V.jsxs)(`div`,{className:`space-y-2 border border-border/60 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(D,{className:`text-xs`,children:`From (sender filters)`}),(0,V.jsxs)(C,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(e=>[...e,{}]),disabled:v,children:[(0,V.jsx)(O,{className:`mr-1 h-3 w-3`}),` add filter`]})]}),(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Any one of the rows below admits the message (OR'd). Within a row, set the peer OR agent — leave the other blank.`}),f.map((e,t)=>(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-[1fr_1fr_auto]`,children:[(0,V.jsxs)(`select`,{value:e.peer_id??``,onChange:e=>b(t,{peer_id:e.target.value||void 0}),className:`w-full border bg-background px-2 py-1 text-sm`,children:[(0,V.jsx)(`option`,{value:``,children:`any peer`}),r.peers.map(e=>(0,V.jsx)(`option`,{value:e.peerID,children:Ge(e)},e.peerID))]}),(0,V.jsx)(T,{list:`mesh-known-agents`,value:e.agent_name??``,onChange:e=>b(t,{agent_name:e.target.value||void 0}),placeholder:`any agent`}),(0,V.jsx)(C,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>x(t),disabled:v,"aria-label":`remove filter`,children:(0,V.jsx)(ae,{className:`h-3.5 w-3.5 text-muted-foreground`})})]},t)),(0,V.jsx)(`datalist`,{id:`mesh-known-agents`,children:r.agents.map(e=>(0,V.jsx)(`option`,{value:e.name},e.name))})]}),(0,V.jsx)($,{label:`Content regex (optional)`,children:(0,V.jsx)(T,{value:u,onChange:e=>d(e.target.value),placeholder:`e.g. (?i)breach`})}),(0,V.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,V.jsx)(C,{variant:`ghost`,size:`sm`,onClick:t,disabled:v,children:`Cancel`}),(0,V.jsx)(C,{size:`sm`,onClick:async()=>{y(!0);try{let e={throttle_seconds:m,max_chain_depth:g};i&&(e.kind_match=i),o&&(e.tag_match=o),c&&c!==`*`&&(e.audience_match=c),u&&(e.content_regex=u);let t=f.map(e=>{let t={};return e.peer_id&&(t.peer_id=e.peer_id),e.agent_name&&(t.agent_name=e.agent_name),t}).filter(e=>e.peer_id||e.agent_name);t.length>0&&(e.from_filters=t),!e.kind_match&&!e.tag_match&&!e.audience_match&&!e.content_regex&&!e.from_filters&&(e.all_messages=!0),await n(e)}finally{y(!1)}},disabled:v,children:v?`Saving…`:`Create trigger`})]})]})}function $({label:e,children:t}){return(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(D,{className:`text-xs`,children:e}),t]})}function Ye(){let{id:e=``}=we(),t=se(),{data:n,loading:r,error:i,refetch:a}=k((0,B.useCallback)(()=>me(e),[e])),{data:o,refetch:s}=k((0,B.useCallback)(()=>de({status:`pending`}),[])),c=(0,B.useMemo)(()=>(o??[]).filter(t=>t.worker_id===e),[o,e]),l=(0,B.useCallback)(()=>{a(),s()},[a,s]),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!e)return;let t=window.setInterval(()=>a(),4e3);return()=>window.clearInterval(t)},[e,a]);async function m(){d(`publish`);try{let t=await Ne(e);j.success(`Published ${t.name}@v${t.version}`)}catch(e){j.error(e instanceof Error?e.message:`Publish failed`)}finally{d(null)}}async function h(e,t,n){d(e);try{await t(),j.success(n),a()}catch(e){j.error(e instanceof Error?e.message:`Action failed`)}finally{d(null)}}async function g(){d(`delete`);try{await be(e),j.success(`Worker deleted`),t(`/workers`)}catch(e){j.error(e instanceof Error?e.message:`Delete failed`),d(null)}}if(r&&!n)return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,V.jsx)(P,{className:`h-4 w-4 animate-spin`}),` Loading worker…`]});if(i&&!n)return(0,V.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:i});if(!n)return null;let _=n.worker,v=n.recent_runs.find(e=>e.status===`running`)??null;return(0,V.jsxs)(`div`,{className:`space-y-5 max-w-5xl`,children:[(0,V.jsx)(Xe,{worker:_,busy:u,onToggle:()=>h(`enable`,()=>_.enabled?fe(_.id):ce(_.id),_.enabled?`Worker paused`:`Worker resumed`),onRunNow:()=>h(`run`,()=>Se(_.id),`Run started for ${_.name}`),onPublish:m,onDelete:()=>p(!0)}),(0,V.jsx)(ze,{worker:_,runs:n.recent_runs}),v&&(0,V.jsx)(Oe,{liveRun:v}),(0,V.jsx)(tt,{worker:_}),(0,V.jsx)(et,{worker:_}),(0,V.jsx)(ke,{approvals:c,onResolved:l}),(0,V.jsx)(Ke,{workerID:_.id,workerName:_.name}),(0,V.jsx)(Ze,{runs:n.recent_runs}),(0,V.jsx)(Qe,{runs:n.recent_runs}),(0,V.jsx)($e,{worker:_}),(0,V.jsx)(ge,{open:f,onOpenChange:p,title:`Delete worker "${_.name}"?`,description:`This removes the worker config. Run history is preserved.`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:g})]})}function Xe({worker:e,busy:t,onToggle:n,onRunNow:r,onPublish:i,onDelete:a}){return(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(w,{to:`/workers`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,V.jsx)(oe,{className:`h-3 w-3`}),`Workers`]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h1`,{className:`text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,V.jsx)(Ce,{className:`h-6 w-6`}),` `,e.name]}),e.description&&(0,V.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:e.description}),(0,V.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,V.jsx)(R,{variant:`outline`,className:M(e.enabled?`success`:`paused`),children:e.enabled?`enabled`:`paused`}),(0,V.jsxs)(`span`,{className:`group inline-flex items-center gap-1 font-mono text-[10px] text-muted-foreground/70`,title:e.id,children:[_e(e.id),(0,V.jsx)(ue,{value:e.id,className:`h-4 w-4 opacity-0 transition-opacity group-hover:opacity-100`})]})]})]}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(g,{enabled:e.enabled,busy:t===`enable`,onToggle:n}),(0,V.jsxs)(C,{size:`sm`,variant:`outline`,disabled:!e.enabled||t!==null,onClick:r,"data-testid":`worker-detail-run-now`,children:[t===`run`?(0,V.jsx)(P,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,V.jsx)(v,{className:`mr-1.5 h-3.5 w-3.5`}),`Run now`]}),(0,V.jsx)(C,{size:`sm`,variant:`outline`,asChild:!0,children:(0,V.jsxs)(w,{to:`/workers/${e.id}/edit`,children:[(0,V.jsx)(_,{className:`mr-1.5 h-3.5 w-3.5`}),` Edit`]})}),(0,V.jsxs)(C,{size:`sm`,variant:`outline`,disabled:t!==null,onClick:i,"data-testid":`worker-detail-publish-template`,children:[t===`publish`?(0,V.jsx)(P,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,V.jsx)(y,{className:`mr-1.5 h-3.5 w-3.5`}),`Publish as template`]}),(0,V.jsxs)(C,{size:`sm`,variant:`ghost`,className:`text-destructive hover:bg-destructive/10`,onClick:a,"data-testid":`worker-detail-delete`,children:[(0,V.jsx)(S,{className:`mr-1.5 h-3.5 w-3.5`}),` Delete`]})]})]})]})}function Ze({runs:e}){let[t,n]=(0,B.useState)(!1);if(e.length===0)return(0,V.jsxs)(I,{children:[(0,V.jsx)(F,{children:(0,V.jsx)(A,{className:`text-base`,children:`Recent runs`})}),(0,V.jsx)(N,{children:(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs yet. Hit "Run now" above, or wait for the next scheduled tick.`})})]});let r=t?e:e.slice(0,10);return(0,V.jsxs)(I,{children:[(0,V.jsxs)(F,{className:`flex flex-row items-center justify-between`,children:[(0,V.jsx)(A,{className:`text-base`,children:`Recent runs`}),e.length>10&&(0,V.jsx)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`text-xs text-muted-foreground hover:text-foreground`,children:t?`Show first 10`:`Show all (${e.length})`})]}),(0,V.jsx)(N,{className:`space-y-3`,children:r.map(e=>(0,V.jsx)(Pe,{run:e},e.id))})]})}function Qe({runs:e}){return(0,V.jsxs)(I,{children:[(0,V.jsx)(F,{children:(0,V.jsx)(A,{className:`text-base text-muted-foreground`,children:`Cost`})}),(0,V.jsx)(N,{children:(0,V.jsx)(Ie,{runs:e})})]})}function $e({worker:e}){let[t,n]=(0,B.useState)(!1);return(0,V.jsxs)(I,{children:[(0,V.jsx)(F,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`flex w-full items-center gap-2 text-left`,children:[t?(0,V.jsx)(L,{className:`h-4 w-4`}):(0,V.jsx)(m,{className:`h-4 w-4`}),(0,V.jsx)(A,{className:`text-base text-muted-foreground`,children:`Configuration`}),(0,V.jsxs)(`span`,{className:`ml-2 text-[10px] text-muted-foreground/60`,children:[`click to `,t?`hide`:`expand`]})]})}),t&&(0,V.jsx)(N,{children:(0,V.jsx)(Re,{worker:e})})]})}function et({worker:e}){let[t,n]=(0,B.useState)(null);if((0,B.useEffect)(()=>{if(!e.source_template_name)return;let t=!1;return Me(e.source_template_name,`latest`).then(e=>{t||n(e.entry.version)}).catch(()=>{t||n(null)}),()=>{t=!0}},[e.source_template_name]),!e.source_template_name||t===null)return null;let r=e.source_template_version??0;return t<=r?null:(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-400/60 bg-amber-100/40 p-3 text-sm dark:bg-amber-950/40`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:`Template update available`}),(0,V.jsxs)(`div`,{className:`mt-0.5 text-muted-foreground`,children:[`This Worker was installed from`,` `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[e.source_template_name,`@v`,r]}),`. The registry now has`,` `,(0,V.jsxs)(`span`,{className:`font-mono font-medium`,children:[`v`,t]}),`. Re-publish the current configuration or install via MCP to pick up the changes.`]})]})}function tt({worker:e}){return!e.auto_paused_reason||e.auto_paused_reason.trim()===``?null:(0,V.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm`,children:[(0,V.jsx)(`div`,{className:`font-medium text-destructive`,children:`Auto-paused`}),(0,V.jsx)(`div`,{className:`mt-0.5 text-destructive/90`,children:e.auto_paused_reason})]})}export{Ye as WorkerDetailPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkerEditorPage-BdVkO0dj.js b/internal/web/dist/assets/WorkerEditorPage-BdVkO0dj.js deleted file mode 100644 index 96b1c3d..0000000 --- a/internal/web/dist/assets/WorkerEditorPage-BdVkO0dj.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{Et as n,St as r,jt as i,l as a,on as o,pt as s,vt as c}from"./client-CaIRceNv.js";import{i as l,n as u,r as d,t as f}from"./tabs-Q9rOz2uL.js";import{t as p}from"./createLucideIcon-WB390fY6.js";import{t as m}from"./arrow-down-BlDh7bya.js";import{t as h}from"./arrow-up-CWTnU2zx.js";import{t as g}from"./WorkersListPage-Cj-R7WbZ.js";import{t as _}from"./message-square-DS3HSgxP.js";import{t as v}from"./save-Baaykonc.js";import{An as y,Bn as b,Fn as x,Fr as S,Ft as C,In as w,Ln as T,Mn as E,Nn as ee,On as te,Pt as D,Qn as O,Rr as ne,S as k,Tn as re,Zn as ie,cn as ae,d as A,f as j,fn as oe,fr as se,gn as ce,i as M,jn as le,jr as N,kn as ue,m as P,n as F,nr as I,p as L,r as R,sr as de,t as z,u as B,v as V,vr as fe,wt as pe,y as me,yr as he,zr as ge}from"./index-BDLzoIgt.js";import{a as _e,c as ve,i as ye,l as be,n as xe,o as Se,r as Ce,s as we,t as Te}from"./model-catalog-Cn8r6otb.js";import{t as H}from"./textarea-BiOhexhg.js";var Ee=p(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),De=p(`github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),Oe=p(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),ke=p(`webhook`,[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]),U=e(t(),1);function Ae(){return{name:``,description:``,provider:`anthropic`,modelID:`claude-opus-4-7`,endpointURL:``,secretScopeID:``,skillRefs:[],promptTemplate:``,parametersJSON:`{}`,scheduleSpec:`0 * * * *`,toolAllowlistJSON:`[]`,outputChannels:[{type:`mesh`,priority:`normal`}],execMode:`propose`,concurrencyPolicy:`skip`,memoryScopeID:``,enabled:!0,workspaceID:``,workspaceAccess:[],maxInputTokens:``,maxOutputTokens:``,maxToolCalls:``,maxWallClockSeconds:``,maxMonthlyCostUSD:``,maxConsecutiveFailures:``}}function je(e){return{name:e.name,description:e.description,provider:e.model_provider,modelID:e.model_id,endpointURL:e.model_endpoint_url??``,secretScopeID:e.secret_scope_id,skillRefs:Ne(e),promptTemplate:e.prompt_template,parametersJSON:e.parameters_json||`{}`,scheduleSpec:e.schedule_spec,toolAllowlistJSON:e.tool_allowlist_json||`[]`,outputChannels:Ie(e.output_channels_json),execMode:e.exec_mode,concurrencyPolicy:e.concurrency_policy,memoryScopeID:e.memory_scope_id??``,enabled:e.enabled,workspaceID:e.workspace_id,workspaceAccess:Me(e),maxInputTokens:W(e.max_input_tokens),maxOutputTokens:W(e.max_output_tokens),maxToolCalls:W(e.max_tool_calls),maxWallClockSeconds:W(e.max_wall_clock_seconds),maxMonthlyCostUSD:W(e.max_monthly_cost_usd),maxConsecutiveFailures:W(e.max_consecutive_failures)}}function Me(e){return Array.isArray(e.workspace_access)&&e.workspace_access.length>0?K(e.workspace_id,e.workspace_access):[{workspace_id:e.workspace_id,access:`write`}]}function Ne(e){return Array.isArray(e.skill_refs)&&e.skill_refs.length>0?e.skill_refs.map(e=>({name:e.name,version:e.version??``})):e.skill_name&&e.skill_name.trim()!==``?[{name:e.skill_name,version:e.skill_version??``}]:[]}function W(e){return e?String(e):``}var Pe=[`mesh`,`file`,`webhook`,`slack_webhook`,`clickup_task`,`github_issue`];function Fe(e){return typeof e==`string`&&Pe.includes(e)}function Ie(e){if(!e)return[{type:`mesh`,priority:`normal`}];try{let t=JSON.parse(e);return!Array.isArray(t)||t.length===0?[{type:`mesh`,priority:`normal`}]:t.map(e=>Le(e)).filter(e=>e!==null)}catch{return[{type:`mesh`,priority:`normal`}]}}function Le(e){if(!e||typeof e!=`object`)return null;let t=e;if(!Fe(t.type))return null;let n={type:t.type};if((t.priority===`low`||t.priority===`normal`||t.priority===`high`||t.priority===`critical`)&&(n.priority=t.priority),(t.priority_on_fail===`low`||t.priority_on_fail===`normal`||t.priority_on_fail===`high`||t.priority_on_fail===`critical`)&&(n.priority_on_fail=t.priority_on_fail),typeof t.tags==`string`&&(n.tags=t.tags),typeof t.notify_user==`boolean`&&(n.notify_user=t.notify_user),typeof t.reply_to_trigger==`boolean`&&(n.reply_to_trigger=t.reply_to_trigger),typeof t.to_peer==`string`&&(n.to_peer=t.to_peer),typeof t.broadcast_peers==`boolean`&&(n.broadcast_peers=t.broadcast_peers),typeof t.path==`string`&&(n.path=t.path),(t.mode===`append`||t.mode===`overwrite`)&&(n.mode=t.mode),typeof t.url==`string`&&(n.url=t.url),typeof t.include_metadata==`boolean`&&(n.include_metadata=t.include_metadata),t.headers&&typeof t.headers==`object`){let e={};for(let[n,r]of Object.entries(t.headers))typeof r==`string`&&(e[n]=r);n.headers=e}return typeof t.channel==`string`&&(n.channel=t.channel),typeof t.prefix==`string`&&(n.prefix=t.prefix),typeof t.list_id==`string`&&(n.list_id=t.list_id),typeof t.name_prefix==`string`&&(n.name_prefix=t.name_prefix),typeof t.repo==`string`&&(n.repo=t.repo),typeof t.title_prefix==`string`&&(n.title_prefix=t.title_prefix),typeof t.secret_scope_id==`string`&&(n.secret_scope_id=t.secret_scope_id),n}function Re(e){if(!e.name.trim())return`Name is required`;if(!e.workspaceID.trim())return`Workspace is required`;let t=K(e.workspaceID,e.workspaceAccess);if(t.length===0)return`At least one workspace access grant is required`;let n=t.find(t=>t.workspace_id===e.workspaceID.trim());if(!n||n.access!==`write`)return`Preferred workspace requires write access`;if(!e.modelID.trim())return`Model ID is required`;if(!e.secretScopeID.trim())return`Secret scope is required`;if(!e.promptTemplate.trim())return`Prompt template is required`;if(!e.scheduleSpec.trim())return`Schedule is required`;if(e.parametersJSON.trim()!==``)try{JSON.parse(e.parametersJSON)}catch{return`Parameters: invalid JSON`}if(e.toolAllowlistJSON.trim()!==``)try{let t=JSON.parse(e.toolAllowlistJSON);if(!Array.isArray(t))return`Tool allowlist must be a JSON array`}catch{return`Tool allowlist: invalid JSON`}let r=Be(e.outputChannels);if(r)return r;let i=ze(e.skillRefs);if(i)return i;for(let[t,n]of Ve(e)){if(n.trim()===``)continue;let e=Number(n);if(!Number.isFinite(e)||e<0)return`${t}: must be a non-negative number`}return null}function ze(e){let t=new Set;for(let n=0;nr(t),className:`mt-1`}),(0,q.jsxs)(`div`,{className:`text-xs`,children:[(0,q.jsx)(`div`,{className:`font-medium text-foreground`,children:i}),(0,q.jsx)(`div`,{className:`text-muted-foreground/70`,children:a})]})]})}function Ke({refs:e,onChange:t,skills:n}){let r=(0,U.useId)(),i=(0,U.useMemo)(()=>qe(n),[n]);function a(n,r){t(e.map((e,t)=>t===n?{...e,...r}:e))}function o(n){t(e.filter((e,t)=>t!==n))}function s(n,r){let i=n+r;if(i<0||i>=e.length)return;let a=e.slice();[a[n],a[i]]=[a[i],a[n]],t(a)}function c(){t([...e,{name:``,version:``}])}return e.length===0?(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No skills selected — the worker will run against the model alone.`}),(0,q.jsxs)(x,{type:`button`,variant:`secondary`,size:`sm`,onClick:c,children:[(0,q.jsx)(O,{className:`mr-1 h-3.5 w-3.5`}),` Add skill`]}),(0,q.jsx)(`datalist`,{id:r,children:i.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.description?`${e.name} — ${e.description}`:e.name},e.name))})]}):(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Skills are joined in order (top → bottom) and prepended to the rendered prompt with a markdown separator.`}),(0,q.jsx)(`ol`,{className:`space-y-2`,children:e.map((t,n)=>(0,q.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border bg-card/40 px-2 py-1.5`,children:[(0,q.jsx)(`span`,{className:`w-5 text-center font-mono text-[10px] text-muted-foreground`,children:n+1}),(0,q.jsx)(C,{value:t.name,onChange:e=>a(n,{name:e.target.value}),placeholder:`skill-name`,list:r,autoComplete:`off`,className:`flex-1 font-mono text-xs`,"aria-label":`Skill ${n+1} name`}),(0,q.jsx)(C,{value:t.version??``,onChange:e=>a(n,{version:e.target.value}),placeholder:`latest`,className:`w-24 font-mono text-xs`,"aria-label":`Skill ${n+1} version`}),(0,q.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>s(n,-1),disabled:n===0,"aria-label":`Move up`,children:(0,q.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>s(n,1),disabled:n===e.length-1,"aria-label":`Move down`,children:(0,q.jsx)(m,{className:`h-3.5 w-3.5`})}),(0,q.jsx)(x,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>o(n),"aria-label":`Remove`,children:(0,q.jsx)(T,{className:`h-3.5 w-3.5`})})]},n))}),(0,q.jsxs)(x,{type:`button`,variant:`secondary`,size:`sm`,onClick:c,children:[(0,q.jsx)(O,{className:`mr-1 h-3.5 w-3.5`}),` Add skill`]}),(0,q.jsx)(`datalist`,{id:r,children:i.map(e=>(0,q.jsx)(`option`,{value:e.name,children:e.description?`${e.name} — ${e.description}`:e.name},e.name))})]})}function qe(e){if(!e)return[];let t=new Set,n=[];for(let r of e)t.has(r.name)||(t.add(r.name),n.push(r));return n}var Je=[{label:`Every 5m`,spec:`5m`,hint:`Every 5 minutes`},{label:`Hourly`,spec:`0 * * * *`,hint:`Top of every hour`},{label:`Every 6h`,spec:`0 */6 * * *`,hint:`4 times a day`},{label:`Daily 9am`,spec:`0 9 * * *`,hint:`Morning kickoff`},{label:`Weekdays 9am`,spec:`0 9 * * 1-5`,hint:`Mon–Fri, 9am`},{label:`Mon 9am`,spec:`0 9 * * 1`,hint:`Weekly digest`}];function Ye({value:e,onChange:t}){let[n,r]=(0,U.useState)(()=>nt(e)),[i,a]=(0,U.useState)(()=>it(e)),o=pe(e),s=e.trim().length>0&&o===null;return(0,U.useEffect)(()=>{if(n===`builder`){let n=at(i);n!==e&&t(n)}},[i,n]),(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(Xe,{mode:n,onChange:r}),n===`preset`&&(0,q.jsx)(Qe,{activeSpec:e,onPick:e=>t(e)}),n===`builder`&&(0,q.jsx)($e,{state:i,onChange:a}),n===`advanced`&&(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(C,{value:e,onChange:e=>t(e.target.value),placeholder:`0 * * * * or 5m`,className:`font-mono text-xs`,"data-testid":`worker-schedule`}),(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`5-field cron (`,(0,q.jsx)(`code`,{children:`min hr dom mon dow`}),`) or Go duration (`,(0,q.jsx)(`code`,{children:`5m`}),`, `,(0,q.jsx)(`code`,{children:`1h30m`}),`).`]})]}),(0,q.jsx)(tt,{spec:e,humanPreview:o,parseError:s})]})}function Xe({mode:e,onChange:t}){return(0,q.jsxs)(`div`,{className:`inline-flex rounded-md border border-border/60 bg-muted/30 p-0.5 text-xs`,children:[(0,q.jsx)(Ze,{active:e===`preset`,onClick:()=>t(`preset`),icon:(0,q.jsx)(w,{className:`h-3 w-3`}),label:`Presets`}),(0,q.jsx)(Ze,{active:e===`builder`,onClick:()=>t(`builder`),icon:(0,q.jsx)(he,{className:`h-3 w-3`}),label:`Builder`}),(0,q.jsx)(Ze,{active:e===`advanced`,onClick:()=>t(`advanced`),icon:(0,q.jsx)(fe,{className:`h-3 w-3`}),label:`Cron`})]})}function Ze({active:e,onClick:t,icon:n,label:r}){return(0,q.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-1.5 rounded px-2.5 py-1 transition-colors `+(e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[n,r]})}function Qe({activeSpec:e,onPick:t}){return(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5 sm:grid-cols-3`,children:Je.map(n=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>t(n.spec),className:`rounded border px-2.5 py-1.5 text-left text-xs transition-colors `+(n.spec===e?`border-primary bg-primary/10 text-foreground`:`border-border/60 bg-card/40 text-foreground hover:bg-card`),children:[(0,q.jsx)(`div`,{className:`font-medium`,children:n.label}),(0,q.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:n.hint})]},n.spec))})}function $e({state:e,onChange:t}){let n=e.unit===`days`;return(0,q.jsxs)(`div`,{className:`space-y-3 rounded border border-border/40 bg-muted/20 p-3`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`Every`}),(0,q.jsx)(C,{type:`number`,min:1,max:e.unit===`minutes`?59:e.unit===`hours`?23:365,value:e.every,onChange:n=>t({...e,every:ot(parseInt(n.target.value,10)||1,1,999)}),className:`h-7 w-16 text-xs`}),(0,q.jsxs)(`select`,{value:e.unit,onChange:n=>t({...e,unit:n.target.value}),className:`h-7 rounded border border-border/60 bg-background px-1.5 text-xs`,children:[(0,q.jsx)(`option`,{value:`minutes`,children:`minute(s)`}),(0,q.jsx)(`option`,{value:`hours`,children:`hour(s)`}),(0,q.jsx)(`option`,{value:`days`,children:`day(s)`})]})]}),n&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,q.jsx)(D,{className:`text-muted-foreground text-xs`,children:`at`}),(0,q.jsx)(et,{hour:e.hour,minute:e.minute,onChange:(n,r)=>t({...e,hour:n,minute:r})})]}),(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[n?(0,q.jsx)(Ee,{className:`inline h-3 w-3 mr-1`}):(0,q.jsx)(he,{className:`inline h-3 w-3 mr-1`}),`Generates: `,(0,q.jsx)(`code`,{className:`font-mono`,children:at(e)})]})]})}function et({hour:e,minute:t,onChange:n}){return(0,q.jsxs)(`div`,{className:`inline-flex items-center gap-1 rounded border border-border/60 bg-background px-2 py-1 font-mono text-xs`,children:[(0,q.jsx)(`input`,{type:`number`,min:0,max:23,value:String(e).padStart(2,`0`),onChange:e=>n(ot(parseInt(e.target.value,10)||0,0,23),t),className:`w-7 bg-transparent text-center outline-none`}),(0,q.jsx)(`span`,{children:`:`}),(0,q.jsx)(`input`,{type:`number`,min:0,max:59,value:String(t).padStart(2,`0`),onChange:t=>n(e,ot(parseInt(t.target.value,10)||0,0,59)),className:`w-7 bg-transparent text-center outline-none`})]})}function tt({spec:e,humanPreview:t,parseError:n}){return e.trim()?n?(0,q.jsxs)(`p`,{className:`rounded bg-amber-500/10 px-2 py-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[`⚠ Couldn't parse `,(0,q.jsx)(`code`,{className:`font-mono`,children:e}),`. The backend will reject this at save time.`]}):(0,q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Will fire: `,(0,q.jsx)(`span`,{className:`font-medium text-foreground`,children:t})]}):(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/70`,children:`Pick a preset above or switch to Builder for custom timing.`})}function nt(e){return!e.trim()||Je.some(t=>t.spec===e)?`preset`:rt(e)?`builder`:`advanced`}function rt(e){return/^(\d+m|\d+h|0 \d{1,2} \* \* \*|\*\/\d+ \* \* \* \*|0 \*\/\d+ \* \* \*|M \d+ \d+ \* \* \*)$/.test(e)}function it(e){let t={unit:`hours`,every:1,hour:9,minute:0};if(!e.trim())return t;let n=/^(\d+)(m|h)$/.exec(e);if(n)return{...t,unit:n[2]===`m`?`minutes`:`hours`,every:parseInt(n[1],10)};let r=/^\*\/(\d+) \* \* \* \*$/.exec(e);if(r)return{...t,unit:`minutes`,every:parseInt(r[1],10)};let i=/^0 \*\/(\d+) \* \* \*$/.exec(e);if(i)return{...t,unit:`hours`,every:parseInt(i[1],10)};let a=/^(\d+) (\d+) \* \* \*$/.exec(e);return a?{unit:`days`,every:1,hour:parseInt(a[2],10),minute:parseInt(a[1],10)}:t}function at(e){return e.unit===`minutes`?`${e.every}m`:e.unit===`hours`?`${e.every}h`:e.every===1?`${e.minute} ${e.hour} * * *`:`${e.minute} ${e.hour} */${e.every} * *`}function ot(e,t,n){return Math.min(Math.max(e,t),n)}var st=`https://openrouter.ai/api/v1`,ct=`http://127.0.0.1:4096`,X={anthropic:{storage:`anthropic`,label:`Anthropic (API key)`,description:`Direct Anthropic Messages API. Stable, expensive, top-quality.`,defaultModel:`claude-opus-4-7`,modelSuggestions:Te,modelPlaceholder:`claude-opus-4-7`,endpointEditable:!1},openai:{storage:`openai`,label:`OpenAI`,description:`Direct OpenAI Chat Completions API.`,defaultModel:`gpt-4o`,modelSuggestions:we,modelPlaceholder:`gpt-4o`,endpointEditable:!1},openrouter:{storage:`openai_compat`,label:`OpenRouter`,description:`One key, hundreds of models. OpenAI-compat over openrouter.ai.`,defaultEndpoint:st,defaultModel:`anthropic/claude-opus-4-7`,modelSuggestions:ve,modelPlaceholder:`anthropic/claude-opus-4-7`,endpointEditable:!0},opencode:{storage:`opencode_cli`,label:`OpenCode server (attached CLI)`,description:"Uses `opencode run --attach` against a locally-running server. Best path for concurrent MiniMax/GLM workers.",defaultEndpoint:ct,defaultModel:`minimax/MiniMax-M3`,modelSuggestions:[],modelPlaceholder:`pick from your OpenCode catalog`,endpointEditable:!0},openai_compat:{storage:`openai_compat`,label:`Custom OpenAI-compatible`,description:`Bring your own. Minimax, Ollama, Together, Groq, vLLM, etc.`,defaultModel:``,modelSuggestions:[],modelPlaceholder:`whatever your endpoint exposes`,endpointEditable:!0},claude_cli:{storage:`claude_cli`,label:`Claude CLI (subscription / Agent SDK)`,description:"Spawns `claude -p` as a subprocess. Uses your Claude subscription.",defaultModel:`sonnet`,modelSuggestions:xe,modelPlaceholder:`sonnet`,endpointEditable:!0},opencode_cli:{storage:`opencode_cli`,label:`OpenCode CLI (subscription, hundreds of models)`,description:"Spawns `opencode run` directly. For parallel workers, prefer OpenCode server mode so the CLI attaches to one long-lived backend.",defaultModel:`minimax/MiniMax-M3`,modelSuggestions:[],modelPlaceholder:`provider/model (e.g. minimax/MiniMax-M3)`,endpointEditable:!0},grok_cli:{storage:`grok_cli`,label:`xAI Grok CLI`,description:"Spawns `grok` in headless JSON mode. Uses your Grok CLI login or XAI_API_KEY.",defaultModel:`grok-build`,modelSuggestions:_e,modelPlaceholder:`grok-build`,endpointEditable:!0},mimo_cli:{storage:`mimo_cli`,label:`Xiaomi MiMo CLI`,description:"Spawns native `mimo --never-ask-questions run --pure --format json --dangerously-skip-permissions`. Uses your MiMo CLI login.",defaultModel:`xiaomi/mimo-v2.5`,modelSuggestions:Se,modelPlaceholder:`xiaomi/mimo-v2.5`,endpointEditable:!0},gemini_cli:{storage:`gemini_cli`,label:`Google Gemini CLI`,description:"Spawns `gemini` in non-interactive JSON mode. Uses GEMINI_API_KEY or your local Gemini CLI auth.",defaultModel:`gemini-2.5-pro`,modelSuggestions:ye,modelPlaceholder:`gemini-2.5-pro`,endpointEditable:!0},codex_cli:{storage:`codex_cli`,label:`OpenAI Codex CLI`,description:"Spawns `codex` in non-interactive mode. Requires OPENAI_API_KEY in the daemon environment.",defaultModel:`o3`,modelSuggestions:Ce,modelPlaceholder:`o3`,endpointEditable:!0},pi_cli:{storage:`pi_cli`,label:`Pi CLI`,description:`Spawns the Pi coding harness. The model id must match an alias in ~/.pi/agent/models.json.`,defaultModel:`qwen-local`,modelSuggestions:be,modelPlaceholder:`qwen-local`,endpointEditable:!0}};function lt(e,t){return e===`anthropic`?`anthropic`:e===`openai`?`openai`:e===`claude_cli`?`claude_cli`:e===`opencode_cli`&&/^https?:\/\//.test(t)?`opencode`:e===`opencode_cli`?`opencode_cli`:e===`grok_cli`?`grok_cli`:e===`mimo_cli`?`mimo_cli`:e===`gemini_cli`?`gemini_cli`:e===`codex_cli`?`codex_cli`:e===`pi_cli`?`pi_cli`:e===`openai_compat`&&t.includes(`openrouter.ai`)?`openrouter`:`openai_compat`}function ut({provider:e,modelID:t,endpointURL:n,onChange:r}){let i=lt(e,n),a=X[i],o=pt(i===`opencode`),{data:s}=k((0,U.useCallback)(()=>c(),[])),[l,u]=(0,U.useState)(``),d=((s??[]).find(e=>e.id===l)||null)?.known_models??[],f=d.length>0?{...a,modelSuggestions:d}:i===`opencode`&&o.length>0?{...a,modelSuggestions:o}:a;function p(e){let t=X[e];u(``),r({provider:t.storage,modelID:t.defaultModel??``,endpointURL:t.defaultEndpoint??``})}function m(e){if(u(e),!e)return;let t=(s??[]).find(t=>t.id===e);if(!t)return;let n=t.known_models[0]??``;r({provider:t.provider,modelID:n,endpointURL:t.endpoint_url,secretScopeID:t.secret_scope_id})}return(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(s??[]).length>0&&(0,q.jsxs)(Z,{label:`Saved profile`,htmlFor:`w-profile`,children:[(0,q.jsxs)(B,{value:l,onValueChange:m,children:[(0,q.jsx)(L,{className:`w-full`,"data-testid":`worker-profile`,children:(0,q.jsx)(P,{placeholder:`Pick a saved provider...`})}),(0,q.jsx)(A,{children:(s??[]).map(e=>(0,q.jsxs)(j,{value:e.id,children:[e.name,(0,q.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[e.provider,e.known_models.length>0?` · ${e.known_models.length} models`:``]})]},e.id))})]}),(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Sets up the fields below.`,` `,(0,q.jsx)(S,{to:`/model-providers`,className:`underline hover:text-foreground`,children:`Manage providers`})]})]}),(s??[]).length===0&&(0,q.jsxs)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-2 text-[11px] text-muted-foreground`,children:[`Tip: set up a provider once on`,` `,(0,q.jsx)(S,{to:`/model-providers`,className:`underline hover:text-foreground`,children:`Model providers`}),` `,`and reuse it across workers.`]}),(0,q.jsxs)(Z,{label:`Provider`,required:!0,children:[(0,q.jsxs)(B,{value:i,onValueChange:e=>p(e),children:[(0,q.jsx)(L,{className:`w-full`,"data-testid":`worker-provider`,children:(0,q.jsx)(P,{})}),(0,q.jsx)(A,{children:Object.keys(X).map(e=>(0,q.jsx)(j,{value:e,children:X[e].label},e))})]}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:f.description})]}),(0,q.jsxs)(Z,{label:`Model`,required:!0,htmlFor:`w-model-id`,children:[(0,q.jsx)(C,{id:`w-model-id`,value:t,onChange:t=>r({provider:e,modelID:t.target.value,endpointURL:n}),placeholder:f.modelPlaceholder,list:f.modelSuggestions.length>0?`models-${i}`:void 0,autoComplete:`off`,"data-testid":`worker-model-id`}),f.modelSuggestions.length>0&&(0,q.jsx)(`datalist`,{id:`models-${i}`,children:f.modelSuggestions.map(e=>(0,q.jsx)(`option`,{value:e},e))}),f.modelSuggestions.length>0?(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Start typing or pick from`,` `,(0,q.jsx)(`code`,{className:`font-mono`,children:f.modelSuggestions.slice(0,3).join(`, `)}),f.modelSuggestions.length>3?`, …`:``,`.`]}):(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Free-text — whatever model id your endpoint expects.`})]}),f.endpointEditable&&(0,q.jsxs)(Z,{label:ft(i),required:f.storage===`openai_compat`&&i!==`opencode`&&i!==`openrouter`,htmlFor:`w-endpoint`,children:[(0,q.jsx)(C,{id:`w-endpoint`,value:n,onChange:n=>r({provider:e,modelID:t,endpointURL:n.target.value}),placeholder:dt(i)}),i===`opencode`&&(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`MCPlexer starts the managed OpenCode server when needed; workers attach through the CLI at this URL.`}),i===`openrouter`&&(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Default OpenRouter API — leave as-is unless you proxy through your own host.`}),i===`claude_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`claude`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`.`]}),i===`opencode_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`opencode`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`.`]}),i===`grok_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`grok`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`.`]}),i===`mimo_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`mimo`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`. HTTP URLs are passed to `,(0,q.jsx)(`code`,{className:`font-mono`,children:`mimo run --attach`}),`.`]}),i===`gemini_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`gemini`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`.`]}),i===`codex_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`codex`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`. Requires `,(0,q.jsx)(`code`,{className:`font-mono`,children:`OPENAI_API_KEY`}),` in the daemon environment.`]}),i===`pi_cli`&&(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Leave blank to use whatever `,(0,q.jsx)(`code`,{className:`font-mono`,children:`pi`}),` is on `,(0,q.jsx)(`code`,{children:`$PATH`}),`. Models are resolved from `,(0,q.jsx)(`code`,{className:`font-mono`,children:`~/.pi/agent/models.json`}),`.`]})]})]})}function Z({label:e,required:t,htmlFor:n,children:r}){return(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(D,{htmlFor:n,className:`text-xs`,children:[e,t&&(0,q.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),r]})}function dt(e){switch(e){case`openrouter`:return st;case`opencode`:return ct;case`claude_cli`:return`claude (blank = use $PATH)`;case`grok_cli`:return`grok (blank = use $PATH)`;case`mimo_cli`:return`mimo (blank = use $PATH), or http://127.0.0.1:4096`;case`gemini_cli`:return`gemini (blank = use $PATH)`;case`codex_cli`:return`codex (blank = use $PATH)`;case`pi_cli`:return`pi (blank = use $PATH)`;case`opencode_cli`:return`opencode (blank = use $PATH)`;default:return`https://my-endpoint/v1`}}function ft(e){switch(e){case`mimo_cli`:return`Binary path / attach URL`;case`claude_cli`:case`opencode_cli`:case`grok_cli`:case`gemini_cli`:case`codex_cli`:case`pi_cli`:return`Binary path`;default:return`Endpoint URL`}}function pt(e){let[t,n]=(0,U.useState)([]);return(0,U.useEffect)(()=>{if(!e)return;let t=!1;return fetch(`/api/v1/opencode/models`).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let r=Array.isArray(e?.models)?e.models:[];r.length>0&&n(r)}).catch(()=>{}),()=>{t=!0}},[e]),t}var mt=[{id:`anthropic`,label:`Anthropic`,placeholder:`sk-ant-…`},{id:`openai`,label:`OpenAI`,placeholder:`sk-…`},{id:`openrouter`,label:`OpenRouter`,placeholder:`sk-or-v1-…`},{id:`minimax`,label:`Minimax`,placeholder:`eyJ…`},{id:`custom`,label:`Other`,placeholder:`paste your API key`}];function ht({open:e,onOpenChange:t,onCreated:n,defaultName:r}){let[o,s]=(0,U.useState)(r??``),[c,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(`anthropic`),[f,p]=(0,U.useState)(!1),m=mt.find(e=>e.id===u)?.placeholder??``;function h(){s(r??``),l(``),d(`anthropic`)}async function g(){let e=o.trim(),r=c.trim();if(!e){N.error(`Scope name is required`);return}if(!r){N.error(`API key is required`);return}let s=gt(e);p(!0);try{await a({id:s,name:e,display_name:``,type:`env`,oauth_provider_id:``,redaction_hints:[]}),await i(s,`api_key`,r),N.success(`Created ${e}`),n(s,e),h(),t(!1)}catch(e){N.error(e instanceof Error?e.message:`Failed to create scope`)}finally{p(!1)}}return(0,q.jsx)(te,{open:e,onOpenChange:t,children:(0,q.jsxs)(ue,{className:`sm:max-w-md`,children:[(0,q.jsxs)(E,{children:[(0,q.jsxs)(ee,{className:`flex items-center gap-2`,children:[(0,q.jsx)(de,{className:`h-4 w-4`}),` Paste a new API key`]}),(0,q.jsxs)(y,{children:[`Creates an env-type AuthScope and stores the value as `,(0,q.jsx)(`code`,{className:`text-[10px]`,children:`api_key`}),`. The Worker runner reads exactly this key name.`]})]}),(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(D,{htmlFor:`ak-provider`,className:`text-xs`,children:`Provider hint`}),(0,q.jsx)(`select`,{id:`ak-provider`,value:u,onChange:e=>d(e.target.value),className:`h-8 w-full rounded border border-border/60 bg-background px-2 text-xs`,children:mt.map(e=>(0,q.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(D,{htmlFor:`ak-name`,className:`text-xs`,children:`Scope name`}),(0,q.jsx)(C,{id:`ak-name`,value:o,onChange:e=>s(e.target.value),placeholder:`My Anthropic key`,"data-testid":`inline-secret-name`}),(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Stored as id `,(0,q.jsx)(`code`,{className:`font-mono`,children:gt(o||`my-key`)}),`.`]})]}),(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsx)(D,{htmlFor:`ak-key`,className:`text-xs`,children:`API key`}),(0,q.jsx)(C,{id:`ak-key`,type:`password`,value:c,onChange:e=>l(e.target.value),placeholder:m,"data-testid":`inline-secret-value`,className:`font-mono text-xs`}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Encrypted at rest with age. Never re-displayed after save.`})]})]}),(0,q.jsxs)(le,{children:[(0,q.jsx)(x,{variant:`ghost`,onClick:()=>t(!1),disabled:f,children:`Cancel`}),(0,q.jsxs)(x,{onClick:g,disabled:f,"data-testid":`inline-secret-save`,children:[f?(0,q.jsx)(I,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,`Save & select`]})]})]})})}function gt(e){return e.toLowerCase().trim().replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64)||`scope`}function _t({state:e,set:t,tools:n}){let[r,i]=(0,U.useState)(``),a=(0,U.useMemo)(()=>St(e.toolAllowlistJSON),[e.toolAllowlistJSON]),o=n??[],s=(0,U.useMemo)(()=>bt(o,r),[o,r]),c=(0,U.useMemo)(()=>Ct(s),[s]),l=e=>{t(`toolAllowlistJSON`,JSON.stringify([...e].sort()))},u=e=>{let t=new Set(a);t.has(e)?t.delete(e):t.add(e),l(t)},d=()=>l(Q(a,s.map(e=>e.name))),f=()=>l(Q(a,s.filter(e=>!e.write_class).map(e=>e.name))),p=()=>l(new Set),m=()=>l(xt(a,s.map(e=>e.name))),h=e=>l(Q(a,e)),g=e=>l(Q(a,e.filter(e=>!e.write_class).map(e=>e.name))),_=e=>l(xt(a,e)),v=o.length>0,y=e.toolAllowlistJSON.trim(),b=y===``||y===`[]`,S=(0,U.useMemo)(()=>o.filter(e=>a.has(e.name)&&e.write_class).length,[o,a]),w=s.length,T=(0,U.useMemo)(()=>s.filter(e=>!e.write_class).length,[s]),E=r.trim().length>0;return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Tools`})}),(0,q.jsxs)(F,{className:`space-y-3`,children:[!v&&(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`No downstream tools registered. Add a server in `,(0,q.jsx)(`strong`,{children:`Config`}),` `,`to expose tools to workers. An empty allowlist means the worker may not call any tool — fail-closed.`]}),v&&(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsx)(vt,{total:o.length,selected:a.size,writeCount:S,isEmpty:b}),(0,q.jsx)(C,{value:r,onChange:e=>i(e.target.value),placeholder:`Filter tools by name or description…`,className:`h-8 text-xs`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(x,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-xs`,onClick:d,disabled:w===0,children:E?`Select all visible (${w})`:`Select all (${w})`}),(0,q.jsx)(x,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 px-2 text-xs`,onClick:f,disabled:T===0,children:E?`Select read-only visible (${T})`:`Select read-only (${T})`}),E&&(0,q.jsx)(x,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:m,children:`Deselect visible`}),(0,q.jsx)(x,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 px-2 text-xs`,onClick:p,disabled:a.size===0,children:`Clear all`})]}),c.length===0&&r.length>0&&(0,q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`No tools match `,(0,q.jsx)(`code`,{className:`font-mono`,children:r}),`.`]}),c.map(e=>(0,q.jsx)(yt,{group:e,selected:a,onToggle:u,onSelectAll:()=>h(e.items.map(e=>e.name)),onSelectReadOnly:()=>g(e.items),onClear:()=>_(e.items.map(e=>e.name))},e.namespace))]}),!v&&(0,q.jsxs)(`details`,{className:`text-xs`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:`Allowlist JSON (advanced)`}),(0,q.jsx)(H,{rows:3,value:e.toolAllowlistJSON,onChange:e=>t(`toolAllowlistJSON`,e.target.value),placeholder:`["mesh__send", "github__list_issues"]`,className:`font-mono text-xs mt-1.5`}),(0,q.jsxs)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:[`Use `,(0,q.jsx)(`code`,{children:`namespace__tool`}),` qualified names; `,(0,q.jsx)(`code`,{children:`[]`}),` `,`means deny-everything (fail-closed); `,(0,q.jsx)(`code`,{children:`null`}),` means pass-through.`]})]})]})]})}function vt({total:e,selected:t,writeCount:n,isEmpty:r}){return r?(0,q.jsx)(`p`,{className:`rounded bg-amber-500/10 px-2 py-1.5 text-[11px] text-amber-700 dark:text-amber-300`,children:`⚠ Allowlist empty — worker is blocked from every tool. Use the buttons below to grant access.`}):(0,q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{className:`font-semibold text-foreground`,children:t}),` of `,e,` tools selected`,n>0&&(0,q.jsxs)(q.Fragment,{children:[` `,`· `,(0,q.jsxs)(`span`,{className:`font-medium text-amber-700 dark:text-amber-400`,children:[n,` write-class`]}),` (gated by propose-mode)`]})]})}function yt({group:e,selected:t,onToggle:n,onSelectAll:r,onSelectReadOnly:i,onClear:a}){let o=e.items.filter(e=>t.has(e.name)).length,s=e.items.filter(e=>!e.write_class).length,c=e.items.length-s,l=o===e.items.length&&e.items.length>0;return(0,q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[e.namespace||`global`,(0,q.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground/60 normal-case`,children:[`(`,o,`/`,e.items.length,c>0?` · ${c} write`:``,`)`]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-wide`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:r,disabled:l,className:`text-muted-foreground/70 hover:text-foreground disabled:opacity-40 disabled:cursor-default`,children:`All`}),(0,q.jsx)(`span`,{className:`text-muted-foreground/30`,children:`·`}),(0,q.jsxs)(`button`,{type:`button`,onClick:i,disabled:s===0,className:`text-muted-foreground/70 hover:text-foreground disabled:opacity-40 disabled:cursor-default`,children:[`Read (`,s,`)`]}),(0,q.jsx)(`span`,{className:`text-muted-foreground/30`,children:`·`}),(0,q.jsx)(`button`,{type:`button`,onClick:a,disabled:o===0,className:`text-muted-foreground/70 hover:text-foreground disabled:opacity-40 disabled:cursor-default`,children:`Clear`})]})]}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:e.items.map(e=>(0,q.jsxs)(`label`,{className:`flex items-start gap-2 rounded border border-border/60 bg-card/40 px-2 py-1.5 text-xs cursor-pointer hover:bg-card`,children:[(0,q.jsx)(V,{checked:t.has(e.name),onCheckedChange:()=>n(e.name),"aria-label":e.name,className:`mt-0.5`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 font-mono text-[11px]`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.name}),e.write_class&&(0,q.jsx)(me,{variant:`outline`,className:`px-1 py-0 text-[9px] uppercase border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-400`,title:`Write-class — gated by propose-mode unless pre-approved`,children:`write`})]}),e.description&&(0,q.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground line-clamp-2`,children:e.description})]})]},e.name))})]})}function bt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.description??``).toLowerCase().includes(n)):e}function Q(e,t){let n=new Set(e);for(let e of t)n.add(e);return n}function xt(e,t){let n=new Set(e);for(let e of t)n.delete(e);return n}function St(e){let t=e.trim();if(t===``||t===`null`)return new Set;try{let e=JSON.parse(t);return Array.isArray(e)?new Set(e.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function Ct(e){let t=new Map;for(let n of e){let e=n.namespace??``,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>({namespace:e,items:t.sort((e,t)=>e.name.localeCompare(t.name))})).sort((e,t)=>e.namespace.localeCompare(t.namespace))}function wt({state:e,set:t,workspaces:n}){let r=n=>{t(`workspaceID`,n),t(`workspaceAccess`,K(n,e.workspaceAccess))},i=(n,r)=>{let i=e.workspaceAccess.filter(e=>e.workspace_id!==n),a=r?[...i,{workspace_id:n,access:`read`}]:i;t(`workspaceAccess`,K(e.workspaceID,a))},a=(n,r)=>{let i=e.workspaceAccess.filter(e=>e.workspace_id!==n);t(`workspaceAccess`,K(e.workspaceID,[...i,{workspace_id:n,access:r}]))};return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Basics`})}),(0,q.jsxs)(F,{className:`space-y-3`,children:[(0,q.jsx)(J,{label:`Name`,htmlFor:`w-name`,required:!0,children:(0,q.jsx)(C,{id:`w-name`,value:e.name,onChange:e=>t(`name`,e.target.value),placeholder:`hourly-digest`,"data-testid":`worker-name`})}),(0,q.jsx)(J,{label:`Description`,htmlFor:`w-desc`,children:(0,q.jsx)(H,{id:`w-desc`,rows:2,value:e.description,onChange:e=>t(`description`,e.target.value),placeholder:`Summarises new mesh messages every hour.`})}),(0,q.jsxs)(J,{label:`Preferred workspace`,htmlFor:`w-workspace`,required:!0,children:[(0,q.jsxs)(B,{value:e.workspaceID,onValueChange:r,children:[(0,q.jsx)(L,{id:`w-workspace`,className:`w-full`,children:(0,q.jsx)(P,{placeholder:`Pick a workspace`})}),(0,q.jsx)(A,{children:n?.map(e=>(0,q.jsxs)(j,{value:e.id,children:[e.name,` `,(0,q.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`(`,e.id,`)`]})]},e.id))})]}),n&&n.length>1&&(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Defaulted to your first workspace — change above if this worker belongs elsewhere.`})]}),(0,q.jsx)(J,{label:`Workspace access`,htmlFor:`w-workspace-access`,children:(0,q.jsx)(`div`,{id:`w-workspace-access`,className:`space-y-1.5`,children:n?.map(t=>{let n=t.id===e.workspaceID,r=e.workspaceAccess.find(e=>e.workspace_id===t.id),o=n||!!r,s=n?`write`:r?.access??`read`;return(0,q.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_112px] items-center gap-2 border border-border/50 px-2 py-1.5 text-xs`,children:[(0,q.jsx)(V,{id:`w-access-${t.id}`,checked:o,disabled:n,onCheckedChange:e=>i(t.id,e===!0)}),(0,q.jsxs)(`label`,{htmlFor:`w-access-${t.id}`,className:`min-w-0`,children:[(0,q.jsx)(`span`,{className:`block truncate text-foreground`,children:t.name}),(0,q.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-muted-foreground/70`,children:t.id})]}),(0,q.jsxs)(B,{value:s,disabled:!o||n,onValueChange:e=>a(t.id,e),children:[(0,q.jsx)(L,{className:`h-8 w-full`,children:(0,q.jsx)(P,{})}),(0,q.jsxs)(A,{children:[(0,q.jsx)(j,{value:`read`,children:`Read`}),(0,q.jsx)(j,{value:`write`,children:`Write`})]})]})]},t.id)})})}),(0,q.jsx)(J,{label:`Enabled`,htmlFor:`w-enabled`,children:(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(g,{enabled:e.enabled,busy:!1,onToggle:()=>t(`enabled`,!e.enabled)}),(0,q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.enabled?`Scheduler will dispatch this worker.`:`Paused — scheduler skips it.`})]})})]})]})}function Tt({state:e,set:t,authScopes:n,onSecretCreated:r}){let[i,a]=(0,U.useState)(!1),o=(n?.length??0)>0;return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Model`})}),(0,q.jsxs)(F,{className:`space-y-3`,children:[(0,q.jsx)(ut,{provider:e.provider,modelID:e.modelID,endpointURL:e.endpointURL,onChange:({provider:e,modelID:n,endpointURL:r,secretScopeID:i})=>{t(`provider`,e),t(`modelID`,n),t(`endpointURL`,r),i!==void 0&&t(`secretScopeID`,i)}}),(0,q.jsxs)(J,{label:`Secret scope`,htmlFor:`w-scope`,required:!0,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(B,{value:e.secretScopeID,onValueChange:e=>t(`secretScopeID`,e),children:[(0,q.jsx)(L,{id:`w-scope`,className:`w-full flex-1`,children:(0,q.jsx)(P,{placeholder:o?`Auth scope holding the API key`:`No scopes yet — click "+ Paste new key"`})}),(0,q.jsx)(A,{children:n?.map(e=>(0,q.jsx)(j,{value:e.id,children:e.id},e.id))})]}),(0,q.jsxs)(x,{type:`button`,variant:`outline`,size:`sm`,className:`h-9 shrink-0 gap-1.5`,onClick:()=>a(!0),"data-testid":`add-secret-inline`,children:[(0,q.jsx)(O,{className:`h-3.5 w-3.5`}),`Paste new key`]})]}),(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Stores the key as `,(0,q.jsx)(`code`,{className:`font-mono`,children:`api_key`}),` in an age-encrypted auth scope — works for Anthropic, OpenAI, OpenRouter, Minimax, and any OpenAI-compatible endpoint.`]})]}),(0,q.jsx)(ht,{open:i,onOpenChange:a,defaultName:Et(e.provider),onCreated:e=>{t(`secretScopeID`,e),r?.(e)}})]})]})}function Et(e){switch(e){case`anthropic`:return`Anthropic`;case`openai`:return`OpenAI`;case`openai_compat`:return`OpenAI-compatible`;case`claude_cli`:return`Claude CLI`;case`opencode_cli`:return`OpenCode CLI`;case`grok_cli`:return`xAI Grok CLI`;case`mimo_cli`:return`Xiaomi MiMo CLI`;default:return``}}function Dt({state:e,set:t,skills:n}){return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Skills (optional)`})}),(0,q.jsxs)(F,{className:`space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Attach one or more Skills — their bodies are joined in order and prepended to the rendered prompt as the system context.`}),(0,q.jsx)(Ke,{refs:e.skillRefs,onChange:e=>t(`skillRefs`,e),skills:n}),(0,q.jsxs)(`details`,{className:`text-xs`,children:[(0,q.jsx)(`summary`,{className:`cursor-pointer text-muted-foreground hover:text-foreground`,children:`Advanced`}),(0,q.jsx)(`div`,{className:`mt-2.5`,children:(0,q.jsxs)(J,{label:`Memory scope`,htmlFor:`w-memory`,children:[(0,q.jsx)(C,{id:`w-memory`,value:e.memoryScopeID,onChange:e=>t(`memoryScopeID`,e.target.value),placeholder:`(none)`,autoComplete:`off`}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`Placeholder for the memory subsystem (not active yet).`})]})})]})]})]})}function Ot({state:e,set:t}){let n=kt(e.parametersJSON);return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Prompt & parameters`})}),(0,q.jsxs)(F,{className:`space-y-3`,children:[(0,q.jsxs)(J,{label:`Prompt template`,htmlFor:`w-prompt`,required:!0,children:[(0,q.jsx)(H,{id:`w-prompt`,rows:8,value:e.promptTemplate,onChange:e=>t(`promptTemplate`,e.target.value),placeholder:`Summarise the {since} window of mesh activity. Highlight critical signals.`,className:`font-mono text-xs`}),(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`Use `,(0,q.jsx)(`code`,{children:`{placeholder}`}),` tokens; they're rendered against the parameters JSON at run-time.`]})]}),(0,q.jsxs)(J,{label:`Parameters (JSON)`,htmlFor:`w-params`,children:[(0,q.jsx)(H,{id:`w-params`,rows:4,value:e.parametersJSON,onChange:e=>t(`parametersJSON`,e.target.value),onBlur:()=>{let n=e.parametersJSON.trim();if(n)try{let e=JSON.parse(n);e&&typeof e==`object`&&!Array.isArray(e)&&t(`parametersJSON`,JSON.stringify(e,null,2))}catch{}},placeholder:`{"since":"1h"}`,className:`font-mono text-xs`+(n?` border-destructive/60 focus-visible:ring-destructive/40`:``)}),n?(0,q.jsx)(`p`,{className:`text-[10px] text-destructive`,children:n}):(0,q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:[`JSON object. Auto-formats on blur. Empty `,(0,q.jsx)(`code`,{children:`{}`}),` is fine.`]})]})]})]})}function kt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?`Must be a JSON object (e.g. {"since":"1h"}), not an array or scalar.`:null}catch(e){return e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`}}function At({state:e,set:t}){return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Schedule`})}),(0,q.jsx)(F,{children:(0,q.jsx)(Ye,{value:e.scheduleSpec,onChange:e=>t(`scheduleSpec`,e)})})]})}function jt(e){switch(e){case`mesh`:return(0,q.jsx)(ie,{className:`h-3.5 w-3.5`});case`file`:return(0,q.jsx)(se,{className:`h-3.5 w-3.5`});case`webhook`:return(0,q.jsx)(ke,{className:`h-3.5 w-3.5`});case`slack_webhook`:return(0,q.jsx)(_,{className:`h-3.5 w-3.5`});case`clickup_task`:return(0,q.jsx)(Oe,{className:`h-3.5 w-3.5`});case`github_issue`:return(0,q.jsx)(De,{className:`h-3.5 w-3.5`})}}var Mt=[{value:`mesh`,label:`mesh`},{value:`file`,label:`file`},{value:`webhook`,label:`webhook`},{value:`slack_webhook`,label:`slack`},{value:`clickup_task`,label:`clickup`},{value:`github_issue`,label:`github`}];function Nt({channels:e,onChange:t}){function n(n,r){t(e.map((e,t)=>t===n?{...e,...r}:e))}function r(n){let r=e.filter((e,t)=>t!==n);t(r.length===0?[{type:`mesh`,priority:`normal`}]:r)}function i(){t([...e,{type:`mesh`,priority:`normal`}])}function a(n,r){t(e.map((e,t)=>t===n?Ut(r,e):e))}return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[e.map((e,t)=>(0,q.jsxs)(`div`,{className:`space-y-2 rounded-md border border-border/60 bg-background/40 p-2`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-flex h-9 w-9 items-center justify-center border border-border/60 bg-card/40 text-muted-foreground`,children:jt(e.type)}),(0,q.jsxs)(B,{value:e.type,onValueChange:e=>a(t,e),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(P,{placeholder:`Type`})}),(0,q.jsx)(A,{children:Mt.map(e=>(0,q.jsx)(j,{value:e.value,children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:jt(e.value)}),e.label]})},e.value))})]}),(0,q.jsx)(x,{type:`button`,variant:`ghost`,size:`sm`,className:`ml-auto text-muted-foreground`,onClick:()=>r(t),"data-testid":`output-channel-remove-${t}`,children:(0,q.jsx)(b,{className:`h-3.5 w-3.5`})})]}),(0,q.jsx)(Pt,{channel:e,onPatch:e=>n(t,e)})]},t)),(0,q.jsxs)(x,{type:`button`,size:`sm`,variant:`outline`,onClick:i,children:[(0,q.jsx)(O,{className:`mr-1.5 h-3.5 w-3.5`}),` Add channel`]})]})}function Pt({channel:e,onPatch:t}){switch(e.type){case`mesh`:return(0,q.jsx)(Ft,{channel:e,onPatch:t});case`file`:return(0,q.jsx)(Rt,{channel:e,onPatch:t});case`webhook`:return(0,q.jsx)(zt,{channel:e,onPatch:t});case`slack_webhook`:return(0,q.jsx)(Bt,{channel:e,onPatch:t});case`clickup_task`:return(0,q.jsx)(Vt,{channel:e,onPatch:t});case`github_issue`:return(0,q.jsx)(Ht,{channel:e,onPatch:t})}}function Ft({channel:e,onPatch:t}){return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Priority`}),(0,q.jsx)(It,{value:e.priority??`normal`,onChange:e=>t({priority:e})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Priority on failure`}),(0,q.jsx)(It,{value:e.priority_on_fail??``,allowEmpty:!0,onChange:e=>t({priority_on_fail:e})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Tags`}),(0,q.jsx)(C,{value:e.tags??``,onChange:e=>t({tags:e.target.value}),placeholder:`worker,telegram`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Peer target`}),(0,q.jsx)(C,{value:e.to_peer??``,onChange:e=>t({to_peer:e.target.value}),placeholder:`device-name`})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,q.jsx)(Lt,{label:`Notify user`,checked:!!e.notify_user,onCheckedChange:e=>t({notify_user:e})}),(0,q.jsx)(Lt,{label:`Reply to trigger`,checked:!!e.reply_to_trigger,onCheckedChange:e=>t({reply_to_trigger:e})}),(0,q.jsx)(Lt,{label:`Broadcast peers`,checked:!!e.broadcast_peers,onCheckedChange:e=>t({broadcast_peers:e})})]})]})}function It({value:e,allowEmpty:t=!1,onChange:n}){return(0,q.jsxs)(B,{value:e||`none`,onValueChange:e=>n(e===`none`?void 0:e),children:[(0,q.jsx)(L,{children:(0,q.jsx)(P,{placeholder:`Priority`})}),(0,q.jsxs)(A,{children:[t&&(0,q.jsx)(j,{value:`none`,children:`default`}),(0,q.jsx)(j,{value:`low`,children:`low`}),(0,q.jsx)(j,{value:`normal`,children:`normal`}),(0,q.jsx)(j,{value:`high`,children:`high`}),(0,q.jsx)(j,{value:`critical`,children:`critical`})]})]})}function Lt({label:e,checked:t,onCheckedChange:n}){return(0,q.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,q.jsx)(V,{checked:t,onCheckedChange:e=>n(e===!0)}),e]})}function Rt({channel:e,onPatch:t}){return(0,q.jsx)(C,{value:e.path??``,onChange:e=>t({path:e.target.value}),placeholder:`/path/to/output.md`})}function zt({channel:e,onPatch:t}){return(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(C,{value:e.url??``,onChange:e=>t({url:e.target.value}),placeholder:`https://example.com/hook`}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:!!e.include_metadata,onChange:e=>t({include_metadata:e.target.checked})}),`Include full run metadata in body`]})]})}function Bt({channel:e,onPatch:t}){return(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,q.jsxs)(`div`,{className:`col-span-2`,children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Incoming webhook URL`}),(0,q.jsx)(C,{value:e.url??``,onChange:e=>t({url:e.target.value}),placeholder:`https://hooks.slack.com/services/...`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Channel override`}),(0,q.jsx)(C,{value:e.channel??``,onChange:e=>t({channel:e.target.value}),placeholder:`#alerts`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Prefix`}),(0,q.jsx)(C,{value:e.prefix??``,onChange:e=>t({prefix:e.target.value}),placeholder:`[worker]`})]})]})}function Vt({channel:e,onPatch:t}){return(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`List ID`}),(0,q.jsx)(C,{value:e.list_id??``,onChange:e=>t({list_id:e.target.value}),placeholder:`9001...`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Secret scope (api_key)`}),(0,q.jsx)(C,{value:e.secret_scope_id??``,onChange:e=>t({secret_scope_id:e.target.value}),placeholder:`scope-id`})]}),(0,q.jsxs)(`div`,{className:`col-span-2`,children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Task name prefix`}),(0,q.jsx)(C,{value:e.name_prefix??``,onChange:e=>t({name_prefix:e.target.value}),placeholder:`[worker]`})]})]})}function Ht({channel:e,onPatch:t}){return(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Repo (owner/name)`}),(0,q.jsx)(C,{value:e.repo??``,onChange:e=>t({repo:e.target.value}),placeholder:`acme/widgets`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Secret scope (api_key)`}),(0,q.jsx)(C,{value:e.secret_scope_id??``,onChange:e=>t({secret_scope_id:e.target.value}),placeholder:`scope-id`})]}),(0,q.jsxs)(`div`,{className:`col-span-2`,children:[(0,q.jsx)(D,{className:`mb-1 text-xs`,children:`Issue title prefix`}),(0,q.jsx)(C,{value:e.title_prefix??``,onChange:e=>t({title_prefix:e.target.value}),placeholder:`[worker]`})]})]})}function Ut(e,t){switch(e){case`mesh`:return{type:e,priority:`normal`};case`file`:return{type:e,path:``};case`webhook`:return{type:e,url:``,include_metadata:!0};case`slack_webhook`:return{type:e,url:``};case`clickup_task`:return{type:e,list_id:``,secret_scope_id:``};case`github_issue`:return{type:e,repo:``,secret_scope_id:``}}}function Wt({state:e,set:t}){return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Output channels`})}),(0,q.jsx)(F,{children:(0,q.jsx)(Nt,{channels:e.outputChannels,onChange:e=>t(`outputChannels`,e)})})]})}function Gt({state:e,set:t}){return(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:(0,q.jsx)(M,{className:`text-base`,children:`Execution`})}),(0,q.jsxs)(F,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,q.jsx)(`legend`,{className:`text-xs uppercase tracking-wider text-muted-foreground/70`,children:`Mode`}),(0,q.jsx)(Y,{name:`execMode`,value:`propose`,current:e.execMode,onChange:e=>t(`execMode`,e),label:`Propose-first (default)`,hint:`Drafts output and posts to mesh; you approve before any side effect.`}),(0,q.jsx)(Y,{name:`execMode`,value:`autonomous`,current:e.execMode,onChange:e=>t(`execMode`,e),label:`Autonomous`,hint:`Executes tool calls directly, bounded by the tool allowlist.`})]}),(0,q.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,q.jsx)(`legend`,{className:`text-xs uppercase tracking-wider text-muted-foreground/70`,children:`Concurrency policy`}),(0,q.jsx)(Y,{name:`conc`,value:`skip`,current:e.concurrencyPolicy,onChange:e=>t(`concurrencyPolicy`,e),label:`Skip (default)`,hint:`Drop the tick when a run is already in flight.`}),(0,q.jsx)(Y,{name:`conc`,value:`queue`,current:e.concurrencyPolicy,onChange:e=>t(`concurrencyPolicy`,e),label:`Queue`,hint:`Run in parallel — audit-only, no serialisation guarantee.`})]})]})]})}function Kt({state:e,set:t}){return(0,q.jsxs)(z,{children:[(0,q.jsxs)(R,{children:[(0,q.jsx)(M,{className:`text-base`,children:`Safety limits`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Leave any field blank to use the runner default. 0 = "no cap" for monthly budget + consecutive-failure auto-pause.`})]}),(0,q.jsxs)(F,{className:`space-y-5`,children:[(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Per-run limits`}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:`Max input tokens`,id:`cap-input`,value:e.maxInputTokens,onChange:e=>t(`maxInputTokens`,e),placeholder:`default: no cap`}),(0,q.jsx)($,{label:`Max output tokens`,id:`cap-output`,value:e.maxOutputTokens,onChange:e=>t(`maxOutputTokens`,e),placeholder:`default: 4096`}),(0,q.jsx)($,{label:`Max tool calls`,id:`cap-tools`,value:e.maxToolCalls,onChange:e=>t(`maxToolCalls`,e),placeholder:`default: 50`}),(0,q.jsx)($,{label:`Max wall-clock seconds`,id:`cap-wall`,value:e.maxWallClockSeconds,onChange:e=>t(`maxWallClockSeconds`,e),placeholder:`default: 300`})]})]}),(0,q.jsxs)(`section`,{className:`space-y-3`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground/70`,children:`Budget + auto-pause`}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,q.jsx)($,{label:`Max monthly cost (USD)`,id:`cap-cost`,value:e.maxMonthlyCostUSD,onChange:e=>t(`maxMonthlyCostUSD`,e),placeholder:`0 = no cap`,step:`0.01`}),(0,q.jsx)($,{label:`Max consecutive failures`,id:`cap-streak`,value:e.maxConsecutiveFailures,onChange:e=>t(`maxConsecutiveFailures`,e),placeholder:`0 = no auto-pause`})]}),(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground/70`,children:`When either cap fires, the worker is paused automatically and a mesh alert lands in the Signal tray.`})]})]})]})}function $({label:e,id:t,value:n,onChange:r,placeholder:i,step:a}){return(0,q.jsx)(J,{label:e,htmlFor:t,children:(0,q.jsx)(C,{id:t,type:`number`,inputMode:`decimal`,min:`0`,step:a??`1`,value:n,onChange:e=>r(e.target.value),placeholder:i})})}function qt({state:e,set:t,workspaces:n,authScopes:r,tools:i,skills:a,onSecretCreated:o}){return(0,q.jsxs)(f,{defaultValue:`basics`,className:`w-full`,children:[(0,q.jsx)(`div`,{className:`sticky top-0 z-10 -mx-1 -mt-1 bg-background pb-1 pt-1`,children:(0,q.jsxs)(d,{className:`w-full flex-nowrap overflow-x-auto`,"data-testid":`worker-editor-tabs`,children:[(0,q.jsx)(l,{value:`basics`,"data-testid":`worker-editor-tab-basics`,children:`Basics`}),(0,q.jsx)(l,{value:`model`,"data-testid":`worker-editor-tab-model`,children:`Model`}),(0,q.jsx)(l,{value:`prompt`,"data-testid":`worker-editor-tab-prompt`,children:`Prompt`}),(0,q.jsx)(l,{value:`schedule`,"data-testid":`worker-editor-tab-schedule`,children:`Schedule`}),(0,q.jsx)(l,{value:`tools`,"data-testid":`worker-editor-tab-tools`,children:`Tools`}),(0,q.jsx)(l,{value:`output`,"data-testid":`worker-editor-tab-output`,children:`Output`}),(0,q.jsx)(l,{value:`execution`,"data-testid":`worker-editor-tab-execution`,children:`Execution`}),(0,q.jsx)(l,{value:`limits`,"data-testid":`worker-editor-tab-limits`,children:`Limits`}),(0,q.jsx)(l,{value:`skills`,"data-testid":`worker-editor-tab-skills`,children:`Skills`})]})}),(0,q.jsx)(u,{value:`basics`,children:(0,q.jsx)(wt,{state:e,set:t,workspaces:n})}),(0,q.jsx)(u,{value:`model`,children:(0,q.jsx)(Tt,{state:e,set:t,authScopes:r,onSecretCreated:o})}),(0,q.jsx)(u,{value:`prompt`,children:(0,q.jsx)(Ot,{state:e,set:t})}),(0,q.jsx)(u,{value:`schedule`,children:(0,q.jsx)(At,{state:e,set:t})}),(0,q.jsx)(u,{value:`tools`,children:(0,q.jsx)(_t,{state:e,set:t,tools:i})}),(0,q.jsx)(u,{value:`output`,children:(0,q.jsx)(Wt,{state:e,set:t})}),(0,q.jsx)(u,{value:`execution`,children:(0,q.jsx)(Gt,{state:e,set:t})}),(0,q.jsx)(u,{value:`limits`,children:(0,q.jsx)(Kt,{state:e,set:t})}),(0,q.jsx)(u,{value:`skills`,children:(0,q.jsx)(Dt,{state:e,set:t,skills:a})})]})}function Jt(){let{id:e}=ge(),t=!!e,i=ne(),{data:a,loading:o,error:c}=k((0,U.useCallback)(()=>e?oe(e):Promise.resolve(null),[e])),{data:l,refetch:u}=k((0,U.useCallback)(()=>s(),[])),{data:d}=k((0,U.useCallback)(()=>n(),[])),{data:f}=k((0,U.useCallback)(()=>ce(),[])),{data:p}=k((0,U.useCallback)(()=>r(),[])),[m,h]=(0,U.useState)(Ae),[g,_]=(0,U.useState)(!1),[y,b]=(0,U.useState)(!1);(0,U.useEffect)(()=>{!t&&d&&d.length>0&&!m.workspaceID&&h(e=>({...e,workspaceID:d[0].id,workspaceAccess:[{workspace_id:d[0].id,access:`write`}]}))},[t,d,m.workspaceID]),(0,U.useEffect)(()=>{t&&a?.worker&&!y&&(h(je(a.worker)),b(!0))},[t,a,y]);let C=(0,U.useCallback)((e,t)=>{h(n=>({...n,[e]:t}))},[]);async function w(){let n=Re(m);if(n){N.error(n);return}_(!0);try{if(t&&e)await re(e,Ge(m)),N.success(`Worker saved`),i(`/workers/${e}`);else{let e=await ae(Ue(m));N.success(`Worker "${e.name}" created`),i(`/workers/${e.id}`)}}catch(e){N.error(e instanceof Error?e.message:`Save failed`)}finally{_(!1)}}let T=d!==null&&l!==null&&f!==null,E=g||!T;return t&&o&&!a?(0,q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,q.jsx)(I,{className:`h-4 w-4 animate-spin`}),` Loading worker…`]}):t&&c?(0,q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:c}):(0,q.jsxs)(`div`,{className:`space-y-5 max-w-3xl`,children:[(0,q.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:t?`Edit ${m.name||`worker`}`:`New worker`}),(0,q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Define the agent's identity, model, schedule, and output sinks. Saved workers are runnable immediately when enabled.`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(x,{variant:`ghost`,asChild:!0,children:(0,q.jsx)(S,{to:t&&e?`/workers/${e}`:`/workers`,children:`Cancel`})}),(0,q.jsxs)(x,{onClick:w,disabled:E,"data-testid":`worker-save`,children:[g||!T?(0,q.jsx)(I,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(v,{className:`mr-1.5 h-3.5 w-3.5`}),T?`Save`:`Loading…`]})]})]}),(0,q.jsx)(qt,{state:m,set:C,workspaces:d,authScopes:l,tools:f,skills:p,onSecretCreated:()=>u()})]})}export{Jt as WorkerEditorPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkerLiveTail-WfoppFSb.js b/internal/web/dist/assets/WorkerLiveTail-WfoppFSb.js deleted file mode 100644 index 5573a06..0000000 --- a/internal/web/dist/assets/WorkerLiveTail-WfoppFSb.js +++ /dev/null @@ -1,3 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{Ar as r,Rn as i,St as a,jt as o,y as s}from"./index-BDLzoIgt.js";var c=e(t(),1),l=new Set([`success`,`failure`,`cap_exceeded`,`rejected`,`awaiting_approval`,`cancelled`]);function u(e,t,n){let[r,i]=(0,c.useState)({run:null,liveTranscript:``,liveToolCalls:[]}),a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{if(i({run:null,liveTranscript:``,liveToolCalls:[]}),!n.enabled||!e||!t)return;let r=`/api/v1/workers/${encodeURIComponent(e)}/runs/${encodeURIComponent(t)}/events`,o=new EventSource(r,{withCredentials:!0});return a.current=o,o.addEventListener(`status`,e=>{try{let t=JSON.parse(e.data);i(e=>({...e,run:t})),l.has(t.status)&&(o.close(),a.current=null)}catch{}}),o.addEventListener(`text_delta`,e=>{try{let t=JSON.parse(e.data);if(!t.text)return;i(e=>({...e,liveTranscript:e.liveTranscript?e.liveTranscript+` - -`+t.text:t.text??``}))}catch{}}),o.addEventListener(`tool_call`,e=>{try{let t=JSON.parse(e.data);if(!t.tool_name)return;i(e=>({...e,liveToolCalls:[...e.liveToolCalls,{iteration:t.iteration??0,name:t.tool_name??``,inputJSON:t.tool_input_json??``,allowed:t.tool_allowed??!0}]}))}catch{}}),o.addEventListener(`usage`,e=>{try{let t=JSON.parse(e.data);i(e=>e.run?{...e,run:{...e.run,input_tokens:t.input_tokens??e.run.input_tokens,output_tokens:t.output_tokens??e.run.output_tokens,cost_usd:t.cost_usd??e.run.cost_usd,tool_calls_count:t.tool_calls??e.run.tool_calls_count}}:e)}catch{}}),o.onerror=()=>{},()=>{o.close(),a.current=null}},[e,t,n.enabled]),r}function d(e,t=400){let[n,r]=(0,c.useState)(e),i=(0,c.useRef)(e),a=(0,c.useRef)(null),o=(0,c.useRef)(0);return(0,c.useEffect)(()=>{if(e===i.current)return;let s=n;i.current=e,o.current=performance.now();function c(n){let i=n-o.current,l=Math.min(1,i/t);r(s+(e-s)*f(l)),l<1?a.current=requestAnimationFrame(c):r(e)}return a.current=requestAnimationFrame(c),()=>{a.current!==null&&cancelAnimationFrame(a.current)}},[e,t]),n}function f(e){return 1-(1-e)**3}var p=n(),m=new Set([`success`,`failure`,`cap_exceeded`,`paused`,`rejected`,`awaiting_approval`]);function h({liveRun:e,onRunSettled:t}){let{run:n,liveTranscript:l,liveToolCalls:f}=u(e.worker_id,e.id,{enabled:e.status===`running`}),h=n??e,_=g(new Date(h.started_at).getTime()),v=d(h.input_tokens,600),y=d(h.output_tokens,600),b=d(h.cost_usd,600);return(0,c.useEffect)(()=>{!n||!m.has(n.status)||t?.()},[t,n?.id,n?.status]),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 border border-sky-500/30 bg-sky-500/5 p-3 text-sm`,"data-testid":`worker-live-tail`,children:[(0,p.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,p.jsxs)(s,{variant:`outline`,className:o(h.status),children:[(0,p.jsx)(r,{className:`mr-1 h-3 w-3`}),`live`]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,p.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`elapsed`}),(0,p.jsx)(`span`,{className:`font-mono text-sm font-medium text-sky-300`,children:a(_)})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,p.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`tokens`}),(0,p.jsxs)(`span`,{className:`font-mono text-sm text-foreground`,children:[Math.round(v).toLocaleString(),` in / `,Math.round(y).toLocaleString(),` out`]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,p.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`cost`}),(0,p.jsxs)(`span`,{className:`font-mono text-sm text-foreground`,children:[`$`,b.toFixed(4)]})]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,p.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`tool calls`}),(0,p.jsx)(`span`,{className:`font-mono text-sm text-foreground`,children:h.tool_calls_count}),h.tool_calls_count_source===`derived`&&(0,p.jsx)(`span`,{className:`cursor-help font-mono text-[9px] text-muted-foreground/70 underline decoration-dotted`,title:`Derived from audit_records — adapter family (claude_cli / opencode_cli / grok_cli / mimo_cli) does not yet report tool_use events natively. Real tool calls happen out-of-band via the child CLI's own MCP connection back to the gateway.`,"aria-label":`tool_calls_count derived from audit_records`,children:`?`})]}),(0,p.jsxs)(`div`,{className:`ml-auto truncate font-mono text-[10px] text-muted-foreground/70`,children:[`run `,h.id]})]}),(l||f.length>0)&&(0,p.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[l&&(0,p.jsxs)(`div`,{className:`flex max-h-40 flex-col overflow-hidden border border-border/40 bg-background/40`,children:[(0,p.jsx)(`div`,{className:`border-b border-border/40 bg-muted/30 px-2 py-1 text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:`assistant`}),(0,p.jsx)(`pre`,{className:`flex-1 overflow-auto whitespace-pre-wrap break-words p-2 text-xs leading-relaxed text-foreground/90`,children:l})]}),f.length>0&&(0,p.jsxs)(`div`,{className:`flex max-h-40 flex-col overflow-hidden border border-border/40 bg-background/40`,children:[(0,p.jsxs)(`div`,{className:`border-b border-border/40 bg-muted/30 px-2 py-1 text-[10px] uppercase tracking-wider text-muted-foreground/70`,children:[`tool calls (`,f.length,`)`]}),(0,p.jsx)(`ul`,{className:`flex-1 overflow-auto p-2 text-xs`,children:f.map((e,t)=>(0,p.jsxs)(`li`,{className:`flex items-start gap-1.5 py-0.5 font-mono`,children:[(0,p.jsx)(i,{className:`mt-0.5 h-3 w-3 shrink-0 ${e.allowed?`text-sky-400`:`text-destructive`}`}),(0,p.jsx)(`span`,{className:e.allowed?`text-foreground/90`:`text-destructive line-through`,children:e.name}),e.inputJSON&&(0,p.jsx)(`span`,{className:`truncate text-muted-foreground/70`,children:e.inputJSON})]},`${e.iteration}-${t}`))})]})]})]})}function g(e){let[t,n]=(0,c.useState)(()=>Date.now());return(0,c.useEffect)(()=>{let e=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(e)},[]),Math.max(0,t-e)}export{d as n,u as r,h as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkersListPage-Cj-R7WbZ.js b/internal/web/dist/assets/WorkersListPage-Cj-R7WbZ.js deleted file mode 100644 index dfa507c..0000000 --- a/internal/web/dist/assets/WorkersListPage-Cj-R7WbZ.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{f as n}from"./recharts-V3eOq3uM.js";import{Et as r,on as i}from"./client-CaIRceNv.js";import{t as a}from"./createLucideIcon-WB390fY6.js";import{t as o}from"./play-YbzkBfB8.js";import{Ar as s,Ct as c,Dt as l,Et as u,Fn as d,Fr as f,Ft as p,Mt as m,Nt as ee,Ot as h,Qn as g,Rr as _,S as v,Sn as te,Tt as y,ar as b,bn as ne,jr as x,jt as S,lr as C,n as w,nr as T,qn as E,t as D,wn as O,wr as k,y as A,zn as j}from"./index-BDLzoIgt.js";import{a as M,i as N,n as P,o as F,r as I,t as L}from"./table-2N0Q-yAm.js";var R=a(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),z=t(n(),1),B={humanCountdown:`Paused`,nextRunDate:null};function V(e,t,n=!0){let[r,i]=(0,z.useState)(()=>u(e,t));return(0,z.useEffect)(()=>{if(!n)return;let r=window.setInterval(()=>{i(u(e,t))},1e3);return()=>window.clearInterval(r)},[e,t,n]),n?r:B}var H=i();function re({rows:e,configuredRows:t,ephemeralRows:n,connected:r,lastEventAt:i,lastRefreshAt:a}){let o=h(e),c=n.filter(e=>e.last_run_status===`running`).length,l=W(e);return(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-4`,"data-testid":`workers-realtime-summary`,children:[{label:`configured`,value:t.length,detail:`scheduled or triggerable workers`},{label:`ephemeral`,value:n.length,detail:`${c} live delegation context${c===1?``:`s`}`},{label:`running`,value:o,detail:`runner status stream`},{label:`attention`,value:l,detail:`failed or waiting on approval`}].map(e=>(0,H.jsx)(D,{children:(0,H.jsxs)(w,{className:`p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`div`,{className:`text-[11px] font-semibold uppercase text-muted-foreground`,children:e.label}),e.label===`running`&&(0,H.jsxs)(A,{variant:`outline`,className:r?`border-sky-500/40 text-sky-300`:`border-border text-muted-foreground`,children:[(0,H.jsx)(s,{className:`mr-1 h-3 w-3`}),r?`live`:`offline`]}),e.label===`attention`&&l>0&&(0,H.jsx)(j,{className:`h-4 w-4 text-amber-300`})]}),(0,H.jsx)(`div`,{className:`mt-2 text-2xl font-semibold tabular-nums`,children:e.value}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail}),e.label===`running`&&(0,H.jsx)(`div`,{className:`mt-1 font-mono text-[10px] text-muted-foreground/70`,children:G(i,a)})]})},e.label))})}function U({rows:e,total:t}){let n=e.slice(0,8),r=e.length-n.length;return(0,H.jsxs)(`section`,{className:`space-y-2`,"data-testid":`workers-ephemeral-panel`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-1`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground`,children:[(0,H.jsx)(C,{className:`h-4 w-4 text-sky-300`}),` Ephemeral delegation workers`]}),(0,H.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:`One-shot worker contexts created from the Delegations page.`})]}),(0,H.jsx)(d,{variant:`outline`,size:`sm`,asChild:!0,children:(0,H.jsx)(f,{to:`/delegations`,children:`Open delegation ledger`})})]}),(0,H.jsx)(D,{children:(0,H.jsx)(w,{className:`p-0`,children:(0,H.jsxs)(L,{children:[(0,H.jsx)(M,{children:(0,H.jsxs)(F,{children:[(0,H.jsx)(N,{children:`Delegation`}),(0,H.jsx)(N,{children:`Model`}),(0,H.jsx)(N,{children:`Status`}),(0,H.jsx)(N,{children:`Updated`})]})}),(0,H.jsx)(P,{children:n.map(e=>(0,H.jsxs)(F,{children:[(0,H.jsxs)(I,{className:`align-top`,children:[(0,H.jsx)(f,{to:`/delegations`,className:`font-medium hover:underline`,children:e.delegation_objective||e.name}),(0,H.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap gap-1.5 text-[10px] text-muted-foreground/70`,children:[(0,H.jsx)(`span`,{className:`truncate font-mono`,title:e.delegation_id||e.id,children:e.delegation_id||e.id}),e.delegation_task_id&&(0,H.jsxs)(`span`,{children:[`task `,e.delegation_task_id]}),e.delegation_worker_mode&&(0,H.jsx)(`span`,{children:e.delegation_worker_mode})]})]}),(0,H.jsx)(I,{className:`align-top font-mono text-xs text-muted-foreground`,children:m(e.model_provider,e.model_id)}),(0,H.jsx)(I,{className:`align-top`,children:(0,H.jsx)(A,{variant:`outline`,className:S(e.last_run_status),children:e.last_run_status||`dispatched`})}),(0,H.jsx)(I,{className:`align-top text-xs text-muted-foreground`,children:l(e.last_run_at||e.created_at)})]},e.id))})]})})}),r>0&&(0,H.jsxs)(`div`,{className:`px-1 text-xs text-muted-foreground`,children:[`Showing `,n.length,` of `,t,` delegation workers. Open the ledger for full context trees.`]})]})}function W(e){return e.filter(e=>e.last_run_status===`failure`||e.last_run_status===`cap_exceeded`||e.last_run_status===`rejected`||e.last_run_status===`awaiting_approval`).length}function G(e,t){let n=e??t;return n?`${e?`event`:`snapshot`} ${l(new Date(n).toISOString())}`:`waiting for first snapshot`}var K=e({EnableSwitch:()=>$,WorkersListPage:()=>ae}),q=`mcplexer.workersList.groupBy`,J=`__ungrouped__`,Y=`No workspace`;function ie(){if(typeof window>`u`)return`auto`;let e=window.localStorage.getItem(q);return e===`workspace`||e===`flat`?e:`auto`}function ae(){let e=(0,z.useCallback)(()=>r(),[]),{rows:t,loading:n,error:i,refetch:a,connected:o,lastEventAt:s,lastRefreshAt:c}=ee(),{data:l}=v(e),[u,m]=(0,z.useState)(null),[h,_]=(0,z.useState)(`all`),[y,b]=(0,z.useState)(``),[S,w]=(0,z.useState)(()=>ie());async function T(e,t,n){m(e);try{await t(),x.success(n),a()}catch(e){x.error(e instanceof Error?e.message:`Action failed`)}finally{m(null)}}async function D(e){let t=!e.enabled;await T(e.id,()=>t?te(e.id):ne(e.id),t?`Worker resumed`:`Worker paused`)}async function A(e){await T(e.id,()=>O(e.id),`Run started for ${e.name}`)}let j=(0,z.useMemo)(()=>t.filter(e=>!e.ephemeral),[t]),M=(0,z.useMemo)(()=>se(t.filter(e=>e.ephemeral)),[t]),N=(0,z.useMemo)(()=>X(j,y),[j,y]),P=(0,z.useMemo)(()=>X(M,y),[M,y]),F=(0,z.useMemo)(()=>ue(N),[N]),I=(0,z.useMemo)(()=>de(N,h),[N,h]),L=(0,z.useMemo)(()=>{let e=new Set;for(let t of j)e.add(t.workspace_id||``);return e.size},[j]),R=S===`auto`?L>1?`workspace`:`flat`:S,B=(0,z.useMemo)(()=>{let e={};for(let t of l??[])e[t.id]=t.name;return e},[l]),V=(0,z.useMemo)(()=>oe(I,B),[I,B]),W=(0,z.useCallback)(e=>{w(e),typeof window<`u`&&window.localStorage.setItem(q,e)},[]);return(0,z.useEffect)(()=>{},[S,L]),(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`h1`,{className:`text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,H.jsx)(k,{className:`h-6 w-6`}),` Workers`]}),(0,H.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm text-muted-foreground`,children:`Scheduled agents that run on a timer. Delegations are one-shot runs spawned on demand from a parent session.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(d,{variant:`outline`,asChild:!0,"data-testid":`workers-delegations`,children:(0,H.jsxs)(f,{to:`/delegations`,children:[(0,H.jsx)(C,{className:`mr-1.5 h-4 w-4`}),` Delegations`]})}),(0,H.jsx)(d,{asChild:!0,"data-testid":`workers-new`,children:(0,H.jsxs)(f,{to:`/workers/new`,children:[(0,H.jsx)(g,{className:`mr-1.5 h-4 w-4`}),` New worker`]})})]})]}),(0,H.jsx)(re,{rows:t,configuredRows:j,ephemeralRows:M,connected:o,lastEventAt:s,lastRefreshAt:c}),i&&(0,H.jsx)(pe,{message:i,onRetry:a}),t.length>0&&(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`relative min-w-64 flex-1 sm:max-w-sm`,children:[(0,H.jsx)(E,{className:`pointer-events-none absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground/70`}),(0,H.jsx)(p,{value:y,onChange:e=>b(e.target.value),placeholder:`Search scheduled workers and one-shot runs`,className:`pl-8`,"data-testid":`workers-search`})]}),(0,H.jsx)(fe,{filter:h,setFilter:_,counts:F}),L>1&&(0,H.jsx)(ce,{mode:R,setMode:W})]}),P.length>0&&(0,H.jsx)(U,{rows:P,total:M.length}),n&&t.length===0?(0,H.jsx)(he,{}):j.length===0?(0,H.jsx)(me,{}):R===`workspace`?(0,H.jsx)(le,{groups:V,busyID:u,onToggle:D,onRunNow:A}):(0,H.jsx)(ge,{rows:I,busyID:u,onToggle:D,onRunNow:A,workspaceNameByID:B,showWorkspace:L>1})]})}function oe(e,t){let n=new Map;for(let r of e){let e=r.workspace_id||``,i=t[e]||e||Y,a=e||J,o=n.get(a);o||(o={key:a,label:i,rows:[]},n.set(a,o)),o.rows.push(r)}for(let e of n.values())e.rows.sort((e,t)=>{if(e.enabled!==t.enabled)return e.enabled?-1:1;let n=e.last_run_at?new Date(e.last_run_at).getTime():0,r=t.last_run_at?new Date(t.last_run_at).getTime():0;return n===r?e.name.localeCompare(t.name):r-n});return[...n.values()].sort((e,t)=>e.key===J?1:t.key===J?-1:e.rows.length===t.rows.length?e.label.localeCompare(t.label):t.rows.length-e.rows.length)}function X(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.name,e.id,e.model_provider,e.model_id,e.schedule_spec,e.workspace_id,e.delegation_id,e.delegation_objective,e.delegation_task_id,e.delegation_task_kind,e.delegation_worker_mode].filter(Boolean).join(` `).toLowerCase().includes(n)):e}function se(e){return[...e].sort((e,t)=>{let n=+(e.last_run_status===`running`),r=+(t.last_run_status===`running`);if(n!==r)return r-n;let i=Z(e),a=Z(t);return i===a?e.name.localeCompare(t.name):a-i})}function Z(e){let t=e.last_run_at||e.created_at,n=t?new Date(t).getTime():0;return Number.isNaN(n)?0:n}function ce({mode:e,setMode:t}){let n=(n,r,i)=>{let a=e===n;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>t(n),"aria-pressed":a,className:`inline-flex items-center gap-1.5 border px-2.5 py-1 text-xs transition-colors `+(a?`border-primary/60 bg-primary/10 text-primary`:`border-border bg-card/40 text-muted-foreground hover:text-foreground`),"data-testid":`workers-group-${n}`,title:n===`workspace`?`Group by workspace`:`Flat list`,children:[(0,H.jsx)(i,{className:`h-3 w-3`}),(0,H.jsx)(`span`,{children:r})]},n)};return(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,"data-testid":`workers-group-toggle`,children:[n(`workspace`,`Grouped`,b),n(`flat`,`Flat`,R)]})}function le({groups:e,busyID:t,onToggle:n,onRunNow:r}){return e.length===0?(0,H.jsx)(D,{children:(0,H.jsx)(w,{className:`py-8 text-center text-sm text-muted-foreground`,children:`No workers match the current filter.`})}):(0,H.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,H.jsxs)(`section`,{"data-testid":`workers-group-${e.key}`,children:[(0,H.jsxs)(`div`,{className:`mb-1.5 flex items-baseline gap-2 px-1`,children:[(0,H.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider `+(e.key===J?`text-muted-foreground/60`:`text-muted-foreground`),children:e.label}),(0,H.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.rows.length})]}),(0,H.jsx)(D,{children:(0,H.jsx)(w,{className:`p-0`,children:(0,H.jsxs)(L,{children:[(0,H.jsx)(M,{children:(0,H.jsxs)(F,{children:[(0,H.jsx)(N,{className:`w-2/5`,children:`Name`}),(0,H.jsx)(N,{children:`Model`}),(0,H.jsx)(N,{children:`Schedule`}),(0,H.jsx)(N,{children:`Last run`}),(0,H.jsx)(N,{children:`Enabled`}),(0,H.jsx)(N,{className:`text-right`,children:`Actions`})]})}),(0,H.jsx)(P,{children:e.rows.map(e=>(0,H.jsx)(Q,{row:e,busy:t===e.id,onToggle:()=>n(e),onRunNow:()=>r(e)},e.id))})]})})})]},e.key))})}function ue(e){let t={all:e.length,running:0,failed:0,paused:0,never:0};for(let n of e)n.last_run_status===`running`&&t.running++,(n.last_run_status===`failure`||n.last_run_status===`cap_exceeded`||n.last_run_status===`rejected`)&&t.failed++,n.enabled||t.paused++,n.last_run_status||t.never++;return t}function de(e,t){switch(t){case`running`:return e.filter(e=>e.last_run_status===`running`);case`failed`:return e.filter(e=>e.last_run_status===`failure`||e.last_run_status===`cap_exceeded`||e.last_run_status===`rejected`);case`paused`:return e.filter(e=>!e.enabled);case`never`:return e.filter(e=>!e.last_run_status);default:return e}}function fe({filter:e,setFilter:t,counts:n}){return(0,H.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`workers-filter-chips`,children:[{key:`all`,label:`All`,n:n.all},{key:`running`,label:`Running`,n:n.running},{key:`failed`,label:`Failed`,n:n.failed},{key:`paused`,label:`Paused`,n:n.paused},{key:`never`,label:`Never run`,n:n.never}].map(n=>{let r=e===n.key;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>t(n.key),className:`inline-flex items-center gap-1.5 border px-2.5 py-1 text-xs transition-colors `+(r?`border-primary/60 bg-primary/10 text-primary`:`border-border bg-card/40 text-muted-foreground hover:text-foreground`),"data-testid":`workers-filter-${n.key}`,children:[(0,H.jsx)(`span`,{children:n.label}),(0,H.jsxs)(`span`,{className:r?`text-primary`:`text-muted-foreground/60`,children:[`(`,n.n,`)`]})]},n.key)})})}function pe({message:e,onRetry:t}){return(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive`,children:[(0,H.jsx)(`span`,{children:e}),(0,H.jsx)(d,{size:`sm`,variant:`ghost`,onClick:t,children:`Retry`})]})}function me(){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(D,{children:(0,H.jsx)(w,{className:`p-0`,children:(0,H.jsxs)(L,{children:[(0,H.jsx)(M,{children:(0,H.jsxs)(F,{children:[(0,H.jsx)(N,{className:`w-2/5`,children:`Name`}),(0,H.jsx)(N,{children:`Schedule`}),(0,H.jsx)(N,{children:`Status`}),(0,H.jsx)(N,{className:`text-right`,children:`Actions`})]})}),(0,H.jsx)(P,{children:[{name:`telegram-responder`,desc:`Reply to inbound Telegram messages`,schedule:`on mesh trigger`},{name:`slack-status-notify`,desc:`Daily mcplexer digest to Slack`,schedule:`daily 09:00`},{name:`cost-watcher`,desc:`Page on cap-approaching workers`,schedule:`@hourly`}].map(e=>(0,H.jsxs)(F,{className:`pointer-events-none opacity-30`,children:[(0,H.jsxs)(I,{children:[(0,H.jsx)(`div`,{className:`font-medium text-foreground`,children:e.name}),(0,H.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.desc})]}),(0,H.jsx)(I,{className:`text-xs text-muted-foreground`,children:e.schedule}),(0,H.jsx)(I,{children:(0,H.jsx)(A,{variant:`outline`,className:S(`paused`),children:`not installed`})}),(0,H.jsx)(I,{className:`text-right`,children:(0,H.jsx)(o,{className:`ml-auto h-3 w-3 text-muted-foreground`})})]},e.name))})]})})}),(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,"data-testid":`workers-empty`,children:[(0,H.jsx)(k,{className:`h-8 w-8 text-muted-foreground/60`}),(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No scheduled workers yet`}),(0,H.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`Workers are durable agents that wake on a schedule, run a prompt against the tools you allow, and route the result to the mesh, a file, or a webhook. Pair one with a Skill for repeatable behaviour.`}),(0,H.jsxs)(`p`,{className:`max-w-md text-[11px] text-muted-foreground/70`,children:[`Delegations are one-shot runs spawned from a parent context. Open`,` `,(0,H.jsx)(f,{to:`/delegations`,className:`underline hover:text-foreground`,children:`Delegations`}),` `,`when you want to review ad hoc worker runs.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,H.jsx)(d,{asChild:!0,children:(0,H.jsxs)(f,{to:`/workers/new`,children:[(0,H.jsx)(g,{className:`mr-1.5 h-4 w-4`}),` New worker`]})}),(0,H.jsx)(d,{variant:`outline`,asChild:!0,children:(0,H.jsxs)(f,{to:`/delegations`,children:[(0,H.jsx)(C,{className:`mr-1.5 h-4 w-4`}),` Delegations`]})})]})]})]})}function he(){return(0,H.jsx)(D,{children:(0,H.jsx)(w,{className:`p-0`,children:(0,H.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:4}).map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-4 px-4 py-4`,children:[(0,H.jsx)(`div`,{className:`h-4 w-1/4 animate-pulse bg-muted`}),(0,H.jsx)(`div`,{className:`h-4 w-1/5 animate-pulse bg-muted`}),(0,H.jsx)(`div`,{className:`h-4 w-1/6 animate-pulse bg-muted`}),(0,H.jsx)(`div`,{className:`h-4 w-12 animate-pulse bg-muted ml-auto`})]},t))})})})}function ge({rows:e,busyID:t,onToggle:n,onRunNow:r,workspaceNameByID:i,showWorkspace:a}){return(0,H.jsx)(D,{children:(0,H.jsx)(w,{className:`p-0`,children:(0,H.jsxs)(L,{children:[(0,H.jsx)(M,{children:(0,H.jsxs)(F,{children:[(0,H.jsx)(N,{className:`w-2/5`,children:`Name`}),(0,H.jsx)(N,{children:`Model`}),(0,H.jsx)(N,{children:`Schedule`}),(0,H.jsx)(N,{children:`Last run`}),(0,H.jsx)(N,{children:`Enabled`}),(0,H.jsx)(N,{className:`text-right`,children:`Actions`})]})}),(0,H.jsx)(P,{children:e.map(e=>(0,H.jsx)(Q,{row:e,busy:t===e.id,onToggle:()=>n(e),onRunNow:()=>r(e),workspaceLabel:a&&(i?.[e.workspace_id]||e.workspace_id)||``},e.id))})]})})})}function Q({row:e,busy:t,onToggle:n,onRunNow:r,workspaceLabel:i}){let a=_(),s=V(e.schedule_spec,e.last_run_at,e.enabled);return(0,H.jsxs)(F,{tabIndex:0,className:`cursor-pointer hover:bg-muted/30 focus:outline-none focus:ring-1 focus:ring-primary/60`,onClick:()=>a(`/workers/${e.id}`),onKeyDown:n=>{n.key===`Enter`&&a(`/workers/${e.id}`),(n.key===`r`||n.key===`R`)&&e.enabled&&!t&&(n.preventDefault(),r())},"data-testid":`worker-row-${e.id}`,children:[(0,H.jsxs)(I,{className:`align-top`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:e.name}),i&&(0,H.jsx)(`span`,{className:`rounded-sm border border-border/60 bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wide text-muted-foreground`,title:`Workspace: ${i}`,children:i})]}),(0,H.jsx)(`div`,{className:`mt-0.5 font-mono text-[10px] text-muted-foreground/70`,children:e.id})]}),(0,H.jsx)(I,{className:`align-top text-xs font-mono text-muted-foreground`,children:m(e.model_provider,e.model_id)}),(0,H.jsxs)(I,{className:`align-top text-xs`,children:[(0,H.jsx)(`div`,{className:`text-foreground`,children:c(e.schedule_spec)}),(0,H.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground/70`,children:e.enabled?y(e.schedule_spec)?e.schedule_spec:s.nextRunDate?`next in ${s.humanCountdown}`:e.schedule_spec:`paused`})]}),(0,H.jsxs)(I,{className:`align-top`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(A,{variant:`outline`,className:S(e.last_run_status),children:e.last_run_status||`never`})}),(0,H.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground/70`,children:l(e.last_run_at)})]}),(0,H.jsx)(I,{className:`align-top`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)($,{enabled:e.enabled,busy:t,onToggle:n})}),(0,H.jsx)(I,{className:`text-right align-top`,onClick:e=>e.stopPropagation(),children:(0,H.jsx)(d,{size:`sm`,variant:`ghost`,disabled:t||!e.enabled,onClick:r,"data-testid":`worker-run-now-${e.id}`,title:e.enabled?`Run now (R)`:`Resume to enable run-now`,children:t?(0,H.jsx)(T,{className:`h-3 w-3 animate-spin`}):(0,H.jsx)(o,{className:`h-3 w-3`})})})]})}function $({enabled:e,busy:t,onToggle:n}){return(0,H.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,disabled:t,onClick:n,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-border transition-colors `+(e?`bg-emerald-500/70`:`bg-muted`)+(t?` opacity-60`:``),"data-testid":`worker-enable-switch`,"data-state":e?`checked`:`unchecked`,children:(0,H.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow transition-transform `+(e?`translate-x-4`:`translate-x-1`)})})}export{K as n,V as r,$ as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/WorkspacesPage-cB7mcsGf.js b/internal/web/dist/assets/WorkspacesPage-cB7mcsGf.js deleted file mode 100644 index 4cd3758..0000000 --- a/internal/web/dist/assets/WorkspacesPage-cB7mcsGf.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{D as n,Et as r,g as i,on as a,rn as o}from"./client-CaIRceNv.js";import{t as s}from"./pencil-Dy4EC74G.js";import{t as c}from"./route-CMSYmLBM.js";import{Bn as l,Br as u,Fn as d,Fr as f,Ft as p,Mn as m,Mr as h,Nn as g,Nr as _,On as v,Or as y,Pr as b,Pt as x,Qn as S,S as C,d as w,dr as T,f as E,j as D,jn as O,jr as k,kn as A,m as j,n as M,p as N,t as P,u as F,y as I}from"./index-BDLzoIgt.js";import{a as L,i as R,n as z,o as B,r as V,t as H}from"./table-2N0Q-yAm.js";var U=e(t(),1),W=a(),G={name:``,root_path:``,default_policy:`allow`,tags:{}};function K(){let{data:e,loading:t,error:a,refetch:p}=C((0,U.useCallback)(()=>r(),[])),[m,g]=(0,U.useState)(!1),[v,x]=(0,U.useState)(null),[w,E]=(0,U.useState)(G),[O,A]=(0,U.useState)(!1),[j,N]=(0,U.useState)(null),[F,I]=(0,U.useState)(null),[K,X]=u(),[Z,Q]=(0,U.useState)(null);(0,U.useEffect)(()=>{let e=K.get(`workspace`);if(!e)return;Q(e);let t=setTimeout(()=>{document.querySelector(`[data-workspace-id="${e}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})},50),n=setTimeout(()=>{X(e=>{let t=new URLSearchParams(e);return t.delete(`workspace`),t},{replace:!0})},200),r=setTimeout(()=>Q(null),3500);return()=>{clearTimeout(t),clearTimeout(n),clearTimeout(r)}},[K,X]);function $(){x(null),E(G),N(null),g(!0)}function ee(e){x(e),E({name:e.name,root_path:e.root_path,default_policy:e.default_policy,tags:{...e.tags}}),N(null),g(!0)}async function te(){A(!0),N(null);try{v?await o(v.id,w):await i(w),g(!1),k.success(v?`Workspace updated`:`Workspace created`),p()}catch(e){N(e instanceof Error?e.message:`Failed to save workspace`)}finally{A(!1)}}async function ne(){if(F)try{await n(F.id),I(null),k.success(`Workspace deleted`),p()}catch(e){k.error(e instanceof Error?e.message:`Failed to delete workspace`)}}return(0,W.jsxs)(`div`,{className:`space-y-6`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(d,{variant:`ghost`,size:`sm`,asChild:!0,className:`-ml-2 h-8`,children:(0,W.jsxs)(f,{to:`/workspaces`,children:[(0,W.jsx)(y,{className:`mr-1.5 h-4 w-4`}),`Workspaces`]})}),(0,W.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Workspace Settings`})]}),(0,W.jsx)(d,{variant:`outline`,asChild:!0,children:(0,W.jsxs)(f,{to:`/advanced/routes`,children:[(0,W.jsx)(c,{className:`mr-1.5 h-4 w-4`}),`Edit routes`]})})]}),(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,W.jsx)(`p`,{className:`max-w-2xl text-sm text-muted-foreground`,children:`A workspace is a directory tree paired with a default route policy. Routes match incoming tool calls against the workspace's root path; the default policy decides what happens when no rule matches.`}),(0,W.jsxs)(d,{onClick:$,"data-testid":`workspace-add`,children:[(0,W.jsx)(S,{className:`mr-2 h-4 w-4`}),`Add Workspace`]})]}),(0,W.jsx)(P,{children:(0,W.jsxs)(M,{className:`pt-6`,children:[t&&!e&&(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,W.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-primary/60`}),`Loading...`]}),a&&(0,W.jsxs)(`p`,{className:`text-destructive`,children:[`Error: `,a]}),e&&(0,W.jsxs)(H,{children:[(0,W.jsx)(L,{children:(0,W.jsxs)(B,{className:`border-border/50 hover:bg-transparent`,children:[(0,W.jsx)(R,{children:`Name`}),(0,W.jsx)(R,{className:`hidden sm:table-cell`,children:`Root Path`}),(0,W.jsx)(R,{children:`Default Policy`}),(0,W.jsx)(R,{className:`hidden lg:table-cell`,children:`Tags`}),(0,W.jsx)(R,{className:`w-32`,children:`Actions`})]})}),(0,W.jsx)(z,{children:e.length===0?(0,W.jsx)(B,{children:(0,W.jsx)(V,{colSpan:5,className:`h-32`,children:(0,W.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground`,children:[(0,W.jsx)(T,{className:`mb-2 h-8 w-8 text-muted-foreground/50`}),(0,W.jsx)(`p`,{className:`text-sm`,children:`No workspaces configured`}),(0,W.jsx)(`button`,{onClick:$,className:`text-xs text-primary hover:underline`,children:`Add a workspace to get started`})]})})}):e.map(e=>(0,W.jsxs)(B,{"data-workspace-id":e.id,className:`border-border/30 hover:bg-muted/30 `+(Z===e.id?`ring-2 ring-amber-400/80 ring-offset-2 ring-offset-background`:``),children:[(0,W.jsx)(V,{className:`font-medium`,children:e.name}),(0,W.jsx)(V,{className:`hidden sm:table-cell`,children:(0,W.jsx)(`div`,{className:`max-w-[22rem] truncate font-mono text-xs text-accent-foreground`,title:e.root_path,children:e.root_path})}),(0,W.jsx)(V,{children:(0,W.jsx)(q,{policy:e.default_policy})}),(0,W.jsx)(V,{className:`hidden lg:table-cell`,children:(0,W.jsx)(J,{tags:e.tags})}),(0,W.jsx)(V,{children:(0,W.jsxs)(`div`,{className:`flex gap-1`,children:[(0,W.jsxs)(h,{children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(d,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Edit routes for ${e.name}`,"data-testid":`workspace-routes-${e.id}`,asChild:!0,children:(0,W.jsx)(f,{to:`/advanced/routes?workspace=${encodeURIComponent(e.id)}`,children:(0,W.jsx)(c,{className:`h-3.5 w-3.5`})})})}),(0,W.jsx)(_,{children:`Routes`})]}),(0,W.jsxs)(h,{children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(d,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0`,"aria-label":`Edit ${e.name}`,"data-testid":`workspace-edit-${e.id}`,onClick:()=>ee(e),children:(0,W.jsx)(s,{className:`h-3.5 w-3.5`})})}),(0,W.jsx)(_,{children:`Edit`})]}),(0,W.jsxs)(h,{children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(d,{variant:`ghost`,size:`sm`,className:`h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive`,"aria-label":`Delete ${e.name}`,"data-testid":`workspace-delete-${e.id}`,onClick:()=>I(e),children:(0,W.jsx)(l,{className:`h-3.5 w-3.5`})})}),(0,W.jsx)(_,{children:`Delete`})]})]})})]},e.id))})]})]})}),(0,W.jsx)(Y,{open:m,onClose:()=>g(!1),form:w,setForm:E,onSave:te,saving:O,editing:!!v,saveError:j}),(0,W.jsx)(D,{open:!!F,onOpenChange:e=>!e&&I(null),title:`Delete workspace`,description:`Are you sure you want to delete "${F?.name}"?`,confirmLabel:`Delete`,variant:`destructive`,onConfirm:ne})]})}function q({policy:e}){return(0,W.jsx)(I,{variant:e===`allow`?`secondary`:`destructive`,children:e})}function J({tags:e}){let t=Object.entries(e??{});return t.length===0?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`-`}):(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(([e,t])=>(0,W.jsxs)(I,{variant:`outline`,className:`font-mono text-xs`,children:[e,`=`,t]},e))})}function Y({open:e,onClose:t,form:n,setForm:r,onSave:i,saving:a,editing:o,saveError:s}){let[c,l]=(0,U.useState)(``),[u,f]=(0,U.useState)(``);function h(){c&&(r(e=>({...e,tags:{...e.tags,[c]:u}})),l(``),f(``))}function _(e){r(t=>{let n={...t.tags};return delete n[e],{...t,tags:n}})}return(0,W.jsx)(v,{open:e,onOpenChange:()=>t(),children:(0,W.jsxs)(A,{children:[(0,W.jsx)(m,{children:(0,W.jsx)(g,{children:o?`Edit Workspace`:`Add Workspace`})}),(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(x,{className:`text-xs text-muted-foreground`,children:`Name`}),(0,W.jsx)(p,{value:n.name,onChange:e=>r(t=>({...t,name:e.target.value}))})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(x,{className:`text-xs text-muted-foreground`,children:`Root Path`}),(0,W.jsx)(p,{className:`font-mono text-sm`,value:n.root_path,onChange:e=>r(t=>({...t,root_path:e.target.value})),placeholder:`/path/to/workspace`})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(x,{className:`text-xs text-muted-foreground`,children:`Default Policy`}),(0,W.jsxs)(F,{value:n.default_policy,onValueChange:e=>r(t=>({...t,default_policy:e})),children:[(0,W.jsx)(N,{children:(0,W.jsx)(j,{})}),(0,W.jsxs)(w,{children:[(0,W.jsx)(E,{value:`allow`,children:`Allow`}),(0,W.jsx)(E,{value:`deny`,children:`Deny`})]})]})]}),(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(x,{className:`text-xs text-muted-foreground`,children:`Tags`}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:Object.entries(n.tags).map(([e,t])=>(0,W.jsxs)(I,{variant:`outline`,role:`button`,tabIndex:0,"aria-label":`Remove tag ${e}=${t}`,className:`cursor-pointer font-mono text-xs hover:bg-destructive/10 hover:text-destructive focus-visible:ring-1 focus-visible:ring-destructive`,onClick:()=>_(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),_(e))},children:[e,`=`,t,` x`]},e))}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(p,{placeholder:`Key`,value:c,onChange:e=>l(e.target.value),className:`flex-1`}),(0,W.jsx)(p,{placeholder:`Value`,value:u,onChange:e=>f(e.target.value),className:`flex-1`}),(0,W.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:h,children:`Add`})]})]})]}),s&&(0,W.jsx)(`p`,{className:`text-sm text-destructive`,children:s}),(0,W.jsxs)(O,{children:[(0,W.jsx)(d,{variant:`outline`,onClick:t,"data-testid":`workspace-cancel`,children:`Cancel`}),(0,W.jsx)(d,{onClick:i,disabled:a||!n.name,"data-testid":`workspace-save`,children:a?`Saving...`:`Save`})]})]})})}export{K as WorkspacesPage}; \ No newline at end of file diff --git a/internal/web/dist/assets/api-C7pu_Aru.js b/internal/web/dist/assets/api-C7pu_Aru.js deleted file mode 100644 index bb91d2c..0000000 --- a/internal/web/dist/assets/api-C7pu_Aru.js +++ /dev/null @@ -1 +0,0 @@ -var e=`/api/p2p`;async function t(t,n){let r=await fetch(`${e}${t}`,{headers:{"Content-Type":`application/json`},...n});if(!r.ok){let e=await r.text();throw Error(e||`request failed: ${r.status}`)}if(r.status!==204)return r.json()}function n(e){if(!e)return`never`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function r(e){let t=new Date(e).getTime()-Date.now();return t<=0?`expired`:`${Math.floor(t/6e4)}m ${Math.floor(t%6e4/1e3)}s`}export{n,t as r,r as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/arrow-down-BlDh7bya.js b/internal/web/dist/assets/arrow-down-BlDh7bya.js deleted file mode 100644 index 15b552e..0000000 --- a/internal/web/dist/assets/arrow-down-BlDh7bya.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/arrow-up-CWTnU2zx.js b/internal/web/dist/assets/arrow-up-CWTnU2zx.js deleted file mode 100644 index 304737e..0000000 --- a/internal/web/dist/assets/arrow-up-CWTnU2zx.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/arrow-up-right-RRuYfAwZ.js b/internal/web/dist/assets/arrow-up-right-RRuYfAwZ.js deleted file mode 100644 index 382d738..0000000 --- a/internal/web/dist/assets/arrow-up-right-RRuYfAwZ.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/box-C_5urXbw.js b/internal/web/dist/assets/box-C_5urXbw.js deleted file mode 100644 index 1d23c08..0000000 --- a/internal/web/dist/assets/box-C_5urXbw.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/calendar-clock-Z37rBeGY.js b/internal/web/dist/assets/calendar-clock-Z37rBeGY.js deleted file mode 100644 index 5ce78f2..0000000 --- a/internal/web/dist/assets/calendar-clock-Z37rBeGY.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/chevron-right-CyhRDGe7.js b/internal/web/dist/assets/chevron-right-CyhRDGe7.js deleted file mode 100644 index 5182f43..0000000 --- a/internal/web/dist/assets/chevron-right-CyhRDGe7.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/circle-x--B2BKH4R.js b/internal/web/dist/assets/circle-x--B2BKH4R.js deleted file mode 100644 index 2b27d89..0000000 --- a/internal/web/dist/assets/circle-x--B2BKH4R.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/client-CaIRceNv.js b/internal/web/dist/assets/client-CaIRceNv.js deleted file mode 100644 index 6d60785..0000000 --- a/internal/web/dist/assets/client-CaIRceNv.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./rolldown-runtime-QTnfLwEv.js";import{u as t}from"./recharts-V3eOq3uM.js";var n=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),r=e(((e,t)=>{t.exports=n()})),i=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t({classGroupId:e,validator:t}),o=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),s=`-`,c=[],l=`arbitrary..`,u=e=>{let t=ee(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return f(e);let n=e.split(s);return d(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],a=n[e];return t?a?i(a,t):t:a||c}return n[e]||c}}},d=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=d(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(s):e.slice(t).join(s),c=a.length;for(let e=0;ee.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?l+r:void 0})(),ee=e=>{let{theme:t,classGroups:n}=e;return p(n,t)},p=(e,t)=>{let n=o();for(let r in e){let i=e[r];m(i,n,r,t)}return n},m=(e,t,n,r)=>{let i=e.length;for(let a=0;a{if(typeof e==`string`){g(e,t,n);return}if(typeof e==`function`){te(e,t,n,r);return}_(e,t,n,r)},g=(e,t,n)=>{let r=e===``?t:v(t,e);r.classGroupId=n},te=(e,t,n,r)=>{if(y(e)){m(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(a(n,e))},_=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e{let n=e,r=t.split(s),i=r.length;for(let e=0;e`isThemeGetter`in e&&e.isThemeGetter===!0,b=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},x=`!`,S=`:`,C=[],ne=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),re=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;si?a-i:void 0;return ne(t,l,c,u)};if(t){let e=t+S,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):ne(C,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},w=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},ie=e=>({cache:b(e.cacheSize),parseClassName:re(e),sortModifiers:w(e),...u(e)}),T=/\s+/,E=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(T),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:ee}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let p=!!ee,m=r(p?f.substring(0,ee):f);if(!m){if(!p){c=t+(c.length>0?` `+c:c);continue}if(m=r(f),!m){c=t+(c.length>0?` `+c:c);continue}p=!1}let h=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),g=d?h+x:h,te=g+m;if(o.indexOf(te)>-1)continue;o.push(te);let _=i(m,p);for(let e=0;e<_.length;++e){let t=_[e];o.push(g+t)}c=t+(c.length>0?` `+c:c)}return c},D=(...e)=>{let t=0,n,r,i=``;for(;t{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r{let n,r,i,a,o=o=>(n=ie(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=E(e,n);return i(e,a),a};return a=o,(...e)=>a(D(...e))},ae=[],A=e=>{let t=t=>t[e]||ae;return t.isThemeGetter=!0,t},j=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,M=/^\((?:(\w[\w-]*):)?(.+)\)$/i,N=/^\d+\/\d+$/,P=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,F=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,I=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,oe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,L=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,R=e=>N.test(e),z=e=>!!e&&!Number.isNaN(Number(e)),B=e=>!!e&&Number.isInteger(Number(e)),se=e=>e.endsWith(`%`)&&z(e.slice(0,-1)),V=e=>P.test(e),ce=()=>!0,le=e=>F.test(e)&&!I.test(e),H=()=>!1,U=e=>oe.test(e),W=e=>L.test(e),ue=e=>!G(e)&&!J(e),de=e=>Z(e,xe,H),G=e=>j.test(e),K=e=>Z(e,Se,le),fe=e=>Z(e,Ce,z),pe=e=>Z(e,ye,H),me=e=>Z(e,be,W),q=e=>Z(e,Te,U),J=e=>M.test(e),Y=e=>Q(e,Se),he=e=>Q(e,we),ge=e=>Q(e,ye),_e=e=>Q(e,xe),ve=e=>Q(e,be),X=e=>Q(e,Te,!0),Z=(e,t,n)=>{let r=j.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Q=(e,t,n=!1)=>{let r=M.exec(e);return r?r[1]?t(r[1]):n:!1},ye=e=>e===`position`||e===`percentage`,be=e=>e===`image`||e===`url`,xe=e=>e===`length`||e===`size`||e===`bg-size`,Se=e=>e===`length`,Ce=e=>e===`number`,we=e=>e===`family-name`,Te=e=>e===`shadow`,Ee=k(()=>{let e=A(`color`),t=A(`font`),n=A(`text`),r=A(`font-weight`),i=A(`tracking`),a=A(`leading`),o=A(`breakpoint`),s=A(`container`),c=A(`spacing`),l=A(`radius`),u=A(`shadow`),d=A(`inset-shadow`),f=A(`text-shadow`),ee=A(`drop-shadow`),p=A(`blur`),m=A(`perspective`),h=A(`aspect`),g=A(`ease`),te=A(`animate`),_=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],v=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],y=()=>[...v(),J,G],b=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],x=()=>[`auto`,`contain`,`none`],S=()=>[J,G,c],C=()=>[R,`full`,`auto`,...S()],ne=()=>[B,`none`,`subgrid`,J,G],re=()=>[`auto`,{span:[`full`,B,J,G]},B,J,G],w=()=>[B,`auto`,J,G],ie=()=>[`auto`,`min`,`max`,`fr`,J,G],T=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],E=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],D=()=>[`auto`,...S()],O=()=>[R,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...S()],k=()=>[e,J,G],ae=()=>[...v(),ge,pe,{position:[J,G]}],j=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],M=()=>[`auto`,`cover`,`contain`,_e,de,{size:[J,G]}],N=()=>[se,Y,K],P=()=>[``,`none`,`full`,l,J,G],F=()=>[``,z,Y,K],I=()=>[`solid`,`dashed`,`dotted`,`double`],oe=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],L=()=>[z,se,ge,pe],le=()=>[``,`none`,p,J,G],H=()=>[`none`,z,J,G],U=()=>[`none`,z,J,G],W=()=>[z,J,G],Z=()=>[R,`full`,...S()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[V],breakpoint:[V],color:[ce],container:[V],"drop-shadow":[V],ease:[`in`,`out`,`in-out`],font:[ue],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[V],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[V],shadow:[V],spacing:[`px`,z],text:[V],"text-shadow":[V],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,R,G,J,h]}],container:[`container`],columns:[{columns:[z,G,J,s]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:y()}],overflow:[{overflow:b()}],"overflow-x":[{"overflow-x":b()}],"overflow-y":[{"overflow-y":b()}],overscroll:[{overscroll:x()}],"overscroll-x":[{"overscroll-x":x()}],"overscroll-y":[{"overscroll-y":x()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{start:C()}],end:[{end:C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[B,`auto`,J,G]}],basis:[{basis:[R,`full`,`auto`,s,...S()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[z,R,`auto`,`initial`,`none`,G]}],grow:[{grow:[``,z,J,G]}],shrink:[{shrink:[``,z,J,G]}],order:[{order:[B,`first`,`last`,`none`,J,G]}],"grid-cols":[{"grid-cols":ne()}],"col-start-end":[{col:re()}],"col-start":[{"col-start":w()}],"col-end":[{"col-end":w()}],"grid-rows":[{"grid-rows":ne()}],"row-start-end":[{row:re()}],"row-start":[{"row-start":w()}],"row-end":[{"row-end":w()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...T(),`normal`]}],"justify-items":[{"justify-items":[...E(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...E()]}],"align-content":[{content:[`normal`,...T()]}],"align-items":[{items:[...E(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...E(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":T()}],"place-items":[{"place-items":[...E(),`baseline`]}],"place-self":[{"place-self":[`auto`,...E()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":S()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":S()}],"space-y-reverse":[`space-y-reverse`],size:[{size:O()}],w:[{w:[s,`screen`,...O()]}],"min-w":[{"min-w":[s,`screen`,`none`,...O()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...O()]}],h:[{h:[`screen`,`lh`,...O()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...O()]}],"max-h":[{"max-h":[`screen`,`lh`,...O()]}],"font-size":[{text:[`base`,n,Y,K]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,J,fe]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,se,G]}],"font-family":[{font:[he,G,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,J,G]}],"line-clamp":[{"line-clamp":[z,`none`,J,fe]}],leading:[{leading:[a,...S()]}],"list-image":[{"list-image":[`none`,J,G]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,J,G]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:k()}],"text-color":[{text:k()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...I(),`wavy`]}],"text-decoration-thickness":[{decoration:[z,`from-font`,`auto`,J,K]}],"text-decoration-color":[{decoration:k()}],"underline-offset":[{"underline-offset":[z,`auto`,J,G]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:S()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,J,G]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,J,G]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ae()}],"bg-repeat":[{bg:j()}],"bg-size":[{bg:M()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},B,J,G],radial:[``,J,G],conic:[B,J,G]},ve,me]}],"bg-color":[{bg:k()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:k()}],"gradient-via":[{via:k()}],"gradient-to":[{to:k()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":F()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...I(),`hidden`,`none`]}],"divide-style":[{divide:[...I(),`hidden`,`none`]}],"border-color":[{border:k()}],"border-color-x":[{"border-x":k()}],"border-color-y":[{"border-y":k()}],"border-color-s":[{"border-s":k()}],"border-color-e":[{"border-e":k()}],"border-color-t":[{"border-t":k()}],"border-color-r":[{"border-r":k()}],"border-color-b":[{"border-b":k()}],"border-color-l":[{"border-l":k()}],"divide-color":[{divide:k()}],"outline-style":[{outline:[...I(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[z,J,G]}],"outline-w":[{outline:[``,z,Y,K]}],"outline-color":[{outline:k()}],shadow:[{shadow:[``,`none`,u,X,q]}],"shadow-color":[{shadow:k()}],"inset-shadow":[{"inset-shadow":[`none`,d,X,q]}],"inset-shadow-color":[{"inset-shadow":k()}],"ring-w":[{ring:F()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:k()}],"ring-offset-w":[{"ring-offset":[z,K]}],"ring-offset-color":[{"ring-offset":k()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":k()}],"text-shadow":[{"text-shadow":[`none`,f,X,q]}],"text-shadow-color":[{"text-shadow":k()}],opacity:[{opacity:[z,J,G]}],"mix-blend":[{"mix-blend":[...oe(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":oe()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[z]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":k()}],"mask-image-linear-to-color":[{"mask-linear-to":k()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":k()}],"mask-image-t-to-color":[{"mask-t-to":k()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":k()}],"mask-image-r-to-color":[{"mask-r-to":k()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":k()}],"mask-image-b-to-color":[{"mask-b-to":k()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":k()}],"mask-image-l-to-color":[{"mask-l-to":k()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":k()}],"mask-image-x-to-color":[{"mask-x-to":k()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":k()}],"mask-image-y-to-color":[{"mask-y-to":k()}],"mask-image-radial":[{"mask-radial":[J,G]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":k()}],"mask-image-radial-to-color":[{"mask-radial-to":k()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[z]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":k()}],"mask-image-conic-to-color":[{"mask-conic-to":k()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ae()}],"mask-repeat":[{mask:j()}],"mask-size":[{mask:M()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,J,G]}],filter:[{filter:[``,`none`,J,G]}],blur:[{blur:le()}],brightness:[{brightness:[z,J,G]}],contrast:[{contrast:[z,J,G]}],"drop-shadow":[{"drop-shadow":[``,`none`,ee,X,q]}],"drop-shadow-color":[{"drop-shadow":k()}],grayscale:[{grayscale:[``,z,J,G]}],"hue-rotate":[{"hue-rotate":[z,J,G]}],invert:[{invert:[``,z,J,G]}],saturate:[{saturate:[z,J,G]}],sepia:[{sepia:[``,z,J,G]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,J,G]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[z,J,G]}],"backdrop-contrast":[{"backdrop-contrast":[z,J,G]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,z,J,G]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[z,J,G]}],"backdrop-invert":[{"backdrop-invert":[``,z,J,G]}],"backdrop-opacity":[{"backdrop-opacity":[z,J,G]}],"backdrop-saturate":[{"backdrop-saturate":[z,J,G]}],"backdrop-sepia":[{"backdrop-sepia":[``,z,J,G]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,J,G]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[z,`initial`,J,G]}],ease:[{ease:[`linear`,`initial`,g,J,G]}],delay:[{delay:[z,J,G]}],animate:[{animate:[`none`,te,J,G]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[m,J,G]}],"perspective-origin":[{"perspective-origin":y()}],rotate:[{rotate:H()}],"rotate-x":[{"rotate-x":H()}],"rotate-y":[{"rotate-y":H()}],"rotate-z":[{"rotate-z":H()}],scale:[{scale:U()}],"scale-x":[{"scale-x":U()}],"scale-y":[{"scale-y":U()}],"scale-z":[{"scale-z":U()}],"scale-3d":[`scale-3d`],skew:[{skew:W()}],"skew-x":[{"skew-x":W()}],"skew-y":[{"skew-y":W()}],transform:[{transform:[J,G,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:y()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:Z()}],"translate-x":[{"translate-x":Z()}],"translate-y":[{"translate-y":Z()}],"translate-z":[{"translate-z":Z()}],"translate-none":[`translate-none`],accent:[{accent:k()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:k()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,J,G]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,J,G]}],fill:[{fill:[`none`,...k()]}],"stroke-w":[{stroke:[z,Y,K,fe]}],stroke:[{stroke:[`none`,...k()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function De(...e){return Ee(t(e))}function Oe(e){let t=new Date(e).getTime()-Date.now();if(t<0)return`expired`;let n=Math.floor(t/(1e3*60*60*24));if(n>1)return`${n}d`;let r=Math.floor(t/(1e3*60*60));return r>0?`${r}h`:`soon`}var ke=`/api/v1`,Ae=3e4;function je(e){return`${ke}${e}`}var Me=class extends Error{status;body;constructor(e,t){super(`API error ${e}: ${t}`),this.name=`ApiClientError`,this.status=e,this.body=t}};function Ne(e,t){if(e<=0)return t??void 0;let n=AbortSignal.timeout(e);return t?typeof AbortSignal.any==`function`?AbortSignal.any([t,n]):t:n}async function $(e,t,n){let r=Ne(n?.timeoutMs??Ae,t?.signal),i=await fetch(`${ke}${e}`,{headers:{"Content-Type":`application/json`},...t,...r?{signal:r}:{}});if(!i.ok){let e=await i.text();throw new Me(i.status,e)}if(i.status!==204)return i.json()}function Pe(){return $(`/workspaces`)}function Fe(e){return $(`/workspaces`,{method:`POST`,body:JSON.stringify(e)})}function Ie(e,t){return $(`/workspaces/${e}`,{method:`PUT`,body:JSON.stringify(t)})}function Le(e){return $(`/workspaces/${e}`,{method:`DELETE`})}function Re(){return $(`/workspace-links`)}function ze(e){return $(`/workspace-links`,{method:`POST`,body:JSON.stringify(e)})}function Be(e,t){return $(`/workspace-links?${new URLSearchParams({peer_id:e,remote_workspace_id:t}).toString()}`,{method:`DELETE`})}function Ve(){return $(`/workspace-links/suggest`)}function He(){return $(`/users`)}function Ue(e){return $(`/users/${encodeURIComponent(e)}`)}function We(){return $(`/auth-scopes`)}function Ge(e){return $(`/auth-scopes`,{method:`POST`,body:JSON.stringify(e)})}function Ke(e,t){return $(`/auth-scopes/${e}`,{method:`PUT`,body:JSON.stringify(t)})}function qe(e){return $(`/auth-scopes/${e}`,{method:`DELETE`})}function Je(e){return $(`/auth-scopes/${e}/secrets`)}function Ye(e,t,n){return $(`/auth-scopes/${e}/secrets`,{method:`PUT`,body:JSON.stringify({key:t,value:n})})}function Xe(e,t){return $(`/auth-scopes/${e}/secrets/${encodeURIComponent(t)}`,{method:`DELETE`})}function Ze(){return $(`/oauth-providers`)}function Qe(e){return $(`/oauth-providers`,{method:`POST`,body:JSON.stringify(e)})}function $e(e,t){return $(`/oauth-providers/${e}`,{method:`PUT`,body:JSON.stringify(t)})}function et(e){return $(`/oauth-providers/${e}`,{method:`DELETE`})}function tt(e){return $(`/oauth-providers/discover`,{method:`POST`,body:JSON.stringify({issuer_url:e})})}function nt(e){return $(`/auth-scopes/${e}/oauth/authorize`)}function rt(e){return $(`/auth-scopes/${e}/oauth/status`)}function it(e){return $(`/auth-scopes/${e}/oauth/revoke`,{method:`POST`})}function at(){return $(`/catalog`)}function ot(){return $(`/downstreams`)}function st(e){return $(`/downstreams`,{method:`POST`,body:JSON.stringify(e)})}function ct(){return $(`/routes`)}function lt(e){return $(`/routes`,{method:`POST`,body:JSON.stringify(e)})}function ut(e,t){return $(`/routes/${e}`,{method:`PUT`,body:JSON.stringify(t)})}function dt(e){return $(`/routes/${e}`,{method:`DELETE`})}function ft(e){return $(`/routes/bulk`,{method:`POST`,body:JSON.stringify(e)})}function pt(e){let t=new URLSearchParams;return e.id&&t.set(`id`,e.id),e.workspace_id&&t.set(`workspace_id`,e.workspace_id),e.tool_name&&t.set(`tool_name`,e.tool_name),e.status&&t.set(`status`,e.status),e.execution_id&&t.set(`execution_id`,e.execution_id),e.session_id&&t.set(`session_id`,e.session_id),e.after&&t.set(`after`,e.after),e.before&&t.set(`before`,e.before),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset)),$(`/audit?${t.toString()}`)}function mt(e){return $(`/dashboard${e?`?range=${e}`:``}`)}function ht(e){return $(`/downstreams/${e}/discover`,{method:`POST`},{timeoutMs:12e4})}function gt(e,t){return $(`/downstreams/${e}/connect`,{method:`POST`,body:JSON.stringify(t)},{timeoutMs:12e4})}function _t(e){return $(`/downstreams/${e}/oauth-status`)}function vt(e){return $(`/downstreams/${e}/oauth-capabilities`)}function yt(e){let t=new URLSearchParams;e&&t.set(`status`,e);let n=t.toString();return $(`/approvals${n?`?${n}`:``}`)}function bt(e,t){return $(`/approvals/${e}/resolve`,{method:`POST`,body:JSON.stringify(t)})}function xt(e){return $(`/dry-run`,{method:`POST`,body:JSON.stringify(e)})}function St(){return $(`/mcp-install/status`)}function Ct(e){return $(`/mcp-install/${e}/install`,{method:`POST`})}function wt(e){return $(`/mcp-install/${e}/uninstall`,{method:`POST`})}function Tt(e){return $(`/mcp-install/${e}/preview`)}function Et(e=`all`){return $(`/cache/flush`,{method:`POST`,body:JSON.stringify({layer:e})})}function Dt(){return $(`/health`)}function Ot(e){return $(`/system/reveal`,{method:`POST`,body:JSON.stringify({target:e})})}function kt(e=`data_dir`){return $(`/system/launch-terminal`,{method:`POST`,body:JSON.stringify({target:e})})}function At(){return $(`/settings`)}function jt(e){return $(`/settings`,{method:`PUT`,body:JSON.stringify(e)})}function Mt(e={}){let t=new URLSearchParams;e.tool_name&&t.set(`tool_name`,e.tool_name),e.status&&t.set(`status`,e.status),e.source&&t.set(`source`,e.source),e.limit&&t.set(`limit`,String(e.limit)),e.offset&&t.set(`offset`,String(e.offset));let n=t.toString();return $(`/descriptions${n?`?${n}`:``}`)}function Nt(e,t){return $(`/descriptions/${e}/accept`,{method:`POST`,body:JSON.stringify({review_note:t||``})})}function Pt(e,t){return $(`/descriptions/${e}/reject`,{method:`POST`,body:JSON.stringify({review_note:t})})}function Ft(){return $(`/mesh/status`)}function It(e){return $(`/mesh/agents/${encodeURIComponent(e)}/focus`,{method:`POST`})}function Lt(e){let t=new URLSearchParams;return e?.repo&&t.set(`repo`,e.repo),e?.branch&&t.set(`branch`,e.branch),e?.path&&t.set(`path`,e.path),e?.claimer&&t.set(`claimer`,e.claimer),$(`/claims${t.toString()?`?${t.toString()}`:``}`)}function Rt(e){return $(`/addons/preview`,{method:`POST`,body:JSON.stringify(e)})}function zt(e){return $(`/addons`,{method:`POST`,body:JSON.stringify(e)})}function Bt(e){return $(`/addons/import-openapi`,{method:`POST`,body:JSON.stringify(e)},{timeoutMs:9e4})}function Vt(e){return $(`/addons/oauth-setup`,{method:`POST`,body:JSON.stringify(e)},{timeoutMs:9e4})}function Ht(e){return $(`/addons/preview-call`,{method:`POST`,body:JSON.stringify(e)},{timeoutMs:9e4})}async function Ut(e){let t=await fetch(`/api${e}`,{signal:AbortSignal.timeout(Ae)});if(t.status===501||t.status===404)return null;if(!t.ok)throw new Me(t.status,await t.text());return t.json()}function Wt(){return Ut(`/p2p/identity`)}function Gt(){return Ut(`/p2p/peers`)}function Kt(){return $(`/backups`)}function qt(e){return $(`/backups`,{method:`POST`,body:JSON.stringify({note:e??``})},{timeoutMs:18e4})}function Jt(e){return $(`/backups/${encodeURIComponent(e)}/restore`,{method:`POST`},{timeoutMs:18e4})}function Yt(e){return $(`/backups/${encodeURIComponent(e)}`,{method:`DELETE`})}function Xt(e){return`${ke}/backups/${encodeURIComponent(e)}/download`}function Zt(e){return!e||e.mode===`all`?``:e.mode===`global`?`?scope=global`:`?scope=workspace&workspace_id=${encodeURIComponent(e.workspaceId)}`}function Qt(e){return $(`/skill-registry${Zt(e)}`)}function $t(e,t=10){return $(`/skill-registry/search?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)}function en(e,t){let n=new URLSearchParams;t!=null&&t!==`latest`&&n.set(`version`,String(t));let r=n.toString();return $(`/skill-registry/${encodeURIComponent(e)}${r?`?`+r:``}`)}function tn(e){return $(`/skill-registry/${encodeURIComponent(e)}/versions`)}function nn(e,t,n){let r=new URLSearchParams;t!=null&&r.set(`old_version`,String(t)),n!=null&&r.set(`new_version`,String(n));let i=r.toString();return $(`/skill-registry/${encodeURIComponent(e)}/diff${i?`?${i}`:``}`)}function rn(e){return $(`/skill-registry`,{method:`POST`,body:JSON.stringify(e)})}function an(e,t){let n=t?`?version=${t}`:``;return $(`/skill-registry/${encodeURIComponent(e)}${n}`,{method:`DELETE`})}function on(e,t,n){return $(`/skill-registry/${encodeURIComponent(e)}/tags`,{method:`POST`,body:JSON.stringify({tag:t,version:n})})}function sn(e){let t=new URLSearchParams;e&&t.set(`source`,e);let n=t.toString();return $(`/skills/local-unpublished${n?`?`+n:``}`)}function cn(e){return $(`/skills/import`,{method:`POST`,body:JSON.stringify(e)})}function ln(){return $(`/guards`)}function un(){return $(`/guards/shell`)}function dn(e){return $(`/guards/shell/clients/${encodeURIComponent(e)}/install_hooks`,{method:`POST`})}function fn(e){return $(`/guards/shell/clients/${encodeURIComponent(e)}/uninstall_hooks`,{method:`POST`})}function pn(e){return $(`/approval-rules${e?`?surface=${encodeURIComponent(e)}`:``}`)}function mn(e){return $(`/approval-rules`,{method:`POST`,body:JSON.stringify(e)})}function hn(e){return $(`/approval-rules/${encodeURIComponent(e)}`,{method:`DELETE`})}function gn(){return $(`/guards/sanitizer`)}function _n(e){return $(`/guards/sanitizer`,{method:`PUT`,body:JSON.stringify({envelope_always:e})})}function vn(){return $(`/guards/schedule`)}function yn(e){return $(`/guards/schedule`,{method:`POST`,body:JSON.stringify(e)})}function bn(e){return $(`/guards/schedule/${encodeURIComponent(e)}/run`,{method:`POST`})}function xn(e){return $(`/guards/schedule/${encodeURIComponent(e)}`,{method:`DELETE`})}function Sn(){return $(`/guards/sandbox`)}function Cn(e){return $(`/guards/sandbox/clients/${encodeURIComponent(e)}/enable`,{method:`POST`})}function wn(e){return $(`/guards/sandbox/clients/${encodeURIComponent(e)}/disable`,{method:`POST`})}function Tn(e){return $(`/guards/sandbox`,{method:`PUT`,body:JSON.stringify({downstreams_enabled:e})})}function En(){return $(`/model-profiles`)}function Dn(e){return $(`/model-profiles`,{method:`POST`,body:JSON.stringify(e)})}function On(e,t){return $(`/model-profiles/${encodeURIComponent(e)}`,{method:`PUT`,body:JSON.stringify(t)})}function kn(e){return $(`/model-profiles/${encodeURIComponent(e)}`,{method:`DELETE`})}function An(e){return $(`/model-profiles/${encodeURIComponent(e)}/test`,{method:`POST`},{timeoutMs:9e4})}function jn(){return $(`/opencode/status`)}function Mn(){return $(`/opencode/start`,{method:`POST`},{timeoutMs:9e4})}function Nn(){return $(`/opencode/stop`,{method:`POST`},{timeoutMs:9e4})}function Pn(){return $(`/setup/status`)}function Fn(e){return $(`/setup/install`,{method:`POST`,body:JSON.stringify({harness:e})})}function In(e){return $(`/setup/recheck`,{method:`POST`,body:JSON.stringify({harness:e})})}export{vn as $,ut as $t,tt as A,rn as At,ln as B,Vt as Bt,dt as C,tn as Ct,Le as D,Rt as Dt,an as E,Pe as Et,Et as F,$ as Ft,nt as G,Nn as Gt,Dt as H,$t as Ht,It as I,bt as It,jn as J,wt as Jt,vt as K,Ve as Kt,mt as L,Jt as Lt,xt as M,pt as Mt,Cn as N,In as Nt,Be as O,Ht as Ot,at as P,Pt,gn as Q,$e as Qt,_t as R,Ot as Rt,et as S,Qt as St,Xe as T,Re as Tt,St as U,on as Ut,Pn as V,bn as Vt,Ft as W,Mn as Wt,Gt as X,Ke as Xt,Wt as Y,fn as Yt,Sn as Z,On as Zt,ze as _,sn as _t,ft as a,Oe as an,Bt as at,Yt as b,ct as bt,mn as c,Ct as ct,st as d,pn as dt,Tn as en,At as et,Dn as f,yt as ft,Fe as g,ot as gt,yn as h,Mt as ht,Xt as i,De as in,Ue as it,ht as j,Ye as jt,wn as k,Tt as kt,Ge as l,dn as lt,lt as m,Kt as mt,Nt as n,jt as nn,en as nt,gt as o,r as on,cn as ot,Qe as p,We as pt,rt as q,An as qt,je as r,Ie as rn,nn as rt,zt as s,Fn as st,Me as t,_n as tn,un as tt,qt as u,kt as ut,hn as v,En as vt,xn as w,He as wt,kn as x,Je as xt,qe as y,Ze as yt,Lt as z,it as zt}; \ No newline at end of file diff --git a/internal/web/dist/assets/cloud-upload-RBqzNp3t.js b/internal/web/dist/assets/cloud-upload-RBqzNp3t.js deleted file mode 100644 index b8de543..0000000 --- a/internal/web/dist/assets/cloud-upload-RBqzNp3t.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/corner-down-left-DusgzzkI.js b/internal/web/dist/assets/corner-down-left-DusgzzkI.js deleted file mode 100644 index 1406881..0000000 --- a/internal/web/dist/assets/corner-down-left-DusgzzkI.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/cpu-DpW4CSHk.js b/internal/web/dist/assets/cpu-DpW4CSHk.js deleted file mode 100644 index 109358d..0000000 --- a/internal/web/dist/assets/cpu-DpW4CSHk.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/createLucideIcon-WB390fY6.js b/internal/web/dist/assets/createLucideIcon-WB390fY6.js deleted file mode 100644 index d451530..0000000 --- a/internal/web/dist/assets/createLucideIcon-WB390fY6.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";var n=e(t()),r=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),i=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),a=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),o=e=>{let t=a(e);return t.charAt(0).toUpperCase()+t.slice(1)},s={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},c=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},l=(0,n.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:i=2,absoluteStrokeWidth:a,className:o=``,children:l,iconNode:u,...d},f)=>(0,n.createElement)(`svg`,{ref:f,...s,width:t,height:t,stroke:e,strokeWidth:a?Number(i)*24/Number(t):i,className:r(`lucide`,o),...!l&&!c(d)&&{"aria-hidden":`true`},...d},[...u.map(([e,t])=>(0,n.createElement)(e,t)),...Array.isArray(l)?l:[l]])),u=(e,t)=>{let a=(0,n.forwardRef)(({className:a,...s},c)=>(0,n.createElement)(l,{ref:c,iconNode:t,className:r(`lucide-${i(o(e))}`,`lucide-${e}`,a),...s}));return a.displayName=o(e),a};export{u as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/database-DUeGtnBt.js b/internal/web/dist/assets/database-DUeGtnBt.js deleted file mode 100644 index f93528e..0000000 --- a/internal/web/dist/assets/database-DUeGtnBt.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist--QlMmz49.js b/internal/web/dist/assets/dist--QlMmz49.js deleted file mode 100644 index c3a0dbb..0000000 --- a/internal/web/dist/assets/dist--QlMmz49.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{o as n}from"./dist-CMymZiQ9.js";import{i as r}from"./dist-BH9Ihpd_.js";var i=e(t(),1);function a(e,t){return i.useReducer((e,n)=>t[e][n]??e,e)}var o=e=>{let{present:t,children:r}=e,a=s(t),o=typeof r==`function`?r({present:a.isPresent}):i.Children.only(r),c=n(a.ref,l(o));return typeof r==`function`||a.isPresent?i.cloneElement(o,{ref:c}):null};o.displayName=`Presence`;function s(e){let[t,n]=i.useState(),o=i.useRef(null),s=i.useRef(e),l=i.useRef(`none`),[u,d]=a(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return i.useEffect(()=>{let e=c(o.current);l.current=u===`mounted`?e:`none`},[u]),r(()=>{let t=o.current,n=s.current;if(n!==e){let r=l.current,i=c(t);e?d(`MOUNT`):i===`none`||t?.display===`none`?d(`UNMOUNT`):d(n&&r!==i?`ANIMATION_OUT`:`UNMOUNT`),s.current=e}},[e,d]),r(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,r=r=>{let i=c(o.current).includes(CSS.escape(r.animationName));if(r.target===t&&i&&(d(`ANIMATION_END`),!s.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},i=e=>{e.target===t&&(l.current=c(o.current))};return t.addEventListener(`animationstart`,i),t.addEventListener(`animationcancel`,r),t.addEventListener(`animationend`,r),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,i),t.removeEventListener(`animationcancel`,r),t.removeEventListener(`animationend`,r)}}else d(`ANIMATION_END`)},[t,d]),{isPresent:[`mounted`,`unmountSuspended`].includes(u),ref:i.useCallback(e=>{o.current=e?getComputedStyle(e):null,n(e)},[])}}function c(e){return e?.animationName||`none`}function l(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}export{o as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-B0VJ9haL.js b/internal/web/dist/assets/dist-B0VJ9haL.js deleted file mode 100644 index a62743d..0000000 --- a/internal/web/dist/assets/dist-B0VJ9haL.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./recharts-V3eOq3uM.js";import{o as r}from"./dist-CMymZiQ9.js";import{on as i}from"./client-CaIRceNv.js";import{c as a,i as o,s,t as c}from"./dist-BH9Ihpd_.js";var l=e(t(),1),u=i(),d=e(n(),1);function f(e){let[t,n]=d.useState(void 0);return o(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var p=[`top`,`right`,`bottom`,`left`],m=Math.min,h=Math.max,g=Math.round,_=Math.floor,v=e=>({x:e,y:e}),y={left:`right`,right:`left`,bottom:`top`,top:`bottom`},b={start:`end`,end:`start`};function x(e,t,n){return h(e,m(t,n))}function S(e,t){return typeof e==`function`?e(t):e}function C(e){return e.split(`-`)[0]}function w(e){return e.split(`-`)[1]}function T(e){return e===`x`?`y`:`x`}function E(e){return e===`y`?`height`:`width`}var D=new Set([`top`,`bottom`]);function O(e){return D.has(C(e))?`y`:`x`}function k(e){return T(O(e))}function A(e,t,n){n===void 0&&(n=!1);let r=w(e),i=k(e),a=E(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=z(o)),[o,z(o)]}function j(e){let t=z(e);return[M(e),t,M(t)]}function M(e){return e.replace(/start|end/g,e=>b[e])}var N=[`left`,`right`],P=[`right`,`left`],F=[`top`,`bottom`],I=[`bottom`,`top`];function L(e,t,n){switch(e){case`top`:case`bottom`:return n?t?P:N:t?N:P;case`left`:case`right`:return t?F:I;default:return[]}}function R(e,t,n,r){let i=w(e),a=L(C(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(M)))),a}function z(e){return e.replace(/left|right|bottom|top/g,e=>y[e])}function B(e){return{top:0,right:0,bottom:0,left:0,...e}}function V(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:B(e)}function H(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ee(e,t,n){let{reference:r,floating:i}=e,a=O(t),o=k(t),s=E(o),c=C(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(w(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function te(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=S(t,e),p=V(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=H(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=H(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ne=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=a.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ee(l,r,c),f=r,p={},m=0;for(let n=0;n({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=S(e,t)||{};if(l==null)return{};let d=V(u),f={x:n,y:r},p=k(i),h=E(p),g=await o.getDimensions(l),_=p===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,C=a.reference[h]+a.reference[p]-f[p]-a.floating[h],T=f[p]-a.reference[p],D=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),O=D?D[b]:0;(!O||!await(o.isElement==null?void 0:o.isElement(D)))&&(O=s.floating[b]||a.floating[h]);let A=C/2-T/2,j=O/2-g[h]/2-1,M=m(d[v],j),N=m(d[y],j),P=M,F=O-g[h]-N,I=O/2-g[h]/2+A,L=x(P,I,F),R=!c.arrow&&w(i)!=null&&I!==L&&a.reference[h]/2-(Ie<=0)){let e=(i.flip?.index||0)+1,t=w[e];if(t&&(!(u===`alignment`&&_!==O(t))||D.every(e=>O(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:D},reset:{placement:t}};let n=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=D.filter(e=>{if(x){let t=O(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ae(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function oe(e){return p.some(t=>e[t]>=0)}var se=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=S(e,t);switch(i){case`referenceHidden`:{let e=ae(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:oe(e)}}}case`escaped`:{let e=ae(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:oe(e)}}}default:return{}}}}},ce=new Set([`left`,`top`]);async function le(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=C(n),s=w(n),c=O(n)===`y`,l=ce.has(o)?-1:1,u=a&&c?-1:1,d=S(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ue=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await le(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},de=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=S(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=O(C(i)),p=T(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=x(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=x(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},fe=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=S(e,t),u={x:n,y:r},d=O(i),f=T(d),p=u[f],m=u[d],h=S(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;pn&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ce.has(C(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);mr&&(m=r)}return{[f]:p,[d]:m}}}},pe=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=S(e,t),u=await o.detectOverflow(t,l),d=C(i),f=w(i),p=O(i)===`y`,{width:g,height:_}=a.floating,v,y;d===`top`||d===`bottom`?(v=d,y=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(y=d,v=f===`end`?`top`:`bottom`);let b=_-u.top-u.bottom,x=g-u.left-u.right,T=m(_-u[v],b),E=m(g-u[y],x),D=!t.middlewareData.shift,k=T,A=E;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=b),D&&!f){let e=h(u.left,0),t=h(u.right,0),n=h(u.top,0),r=h(u.bottom,0);p?A=g-2*(e!==0||t!==0?e+t:h(u.left,u.right)):k=_-2*(n!==0||r!==0?n+r:h(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});let j=await o.getDimensions(s.floating);return g!==j.width||_!==j.height?{reset:{rects:!0}}:{}}}};function me(){return typeof window<`u`}function U(e){return he(e)?(e.nodeName||``).toLowerCase():`#document`}function W(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function G(e){return((he(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function he(e){return me()?e instanceof Node||e instanceof W(e).Node:!1}function K(e){return me()?e instanceof Element||e instanceof W(e).Element:!1}function q(e){return me()?e instanceof HTMLElement||e instanceof W(e).HTMLElement:!1}function ge(e){return!me()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof W(e).ShadowRoot}var _e=new Set([`inline`,`contents`]);function J(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=X(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!_e.has(i)}var ve=new Set([`table`,`td`,`th`]);function ye(e){return ve.has(U(e))}var be=[`:popover-open`,`:modal`];function xe(e){return be.some(t=>{try{return e.matches(t)}catch{return!1}})}var Se=[`transform`,`translate`,`scale`,`rotate`,`perspective`],Ce=[`transform`,`translate`,`scale`,`rotate`,`perspective`,`filter`],we=[`paint`,`layout`,`strict`,`content`];function Te(e){let t=De(),n=K(e)?X(e):e;return Se.some(e=>n[e]?n[e]!==`none`:!1)||(n.containerType?n.containerType!==`normal`:!1)||!t&&(n.backdropFilter?n.backdropFilter!==`none`:!1)||!t&&(n.filter?n.filter!==`none`:!1)||Ce.some(e=>(n.willChange||``).includes(e))||we.some(e=>(n.contain||``).includes(e))}function Ee(e){let t=Z(e);for(;q(t)&&!Y(t);){if(Te(t))return t;if(xe(t))return null;t=Z(t)}return null}function De(){return typeof CSS>`u`||!CSS.supports?!1:CSS.supports(`-webkit-backdrop-filter`,`none`)}var Oe=new Set([`html`,`body`,`#document`]);function Y(e){return Oe.has(U(e))}function X(e){return W(e).getComputedStyle(e)}function ke(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Z(e){if(U(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ge(e)&&e.host||G(e);return ge(t)?t.host:t}function Ae(e){let t=Z(e);return Y(t)?e.ownerDocument?e.ownerDocument.body:e.body:q(t)&&J(t)?t:Ae(t)}function je(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Ae(e),i=r===e.ownerDocument?.body,a=W(r);if(i){let e=Me(a);return t.concat(a,a.visualViewport||[],J(r)?r:[],e&&n?je(e):[])}return t.concat(r,je(r,[],n))}function Me(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ne(e){let t=X(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=q(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=g(n)!==a||g(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Pe(e){return K(e)?e:e.contextElement}function Q(e){let t=Pe(e);if(!q(t))return v(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ne(t),o=(a?g(n.width):n.width)/r,s=(a?g(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Fe=v(0);function Ie(e){let t=W(e);return!De()||!t.visualViewport?Fe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Le(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==W(e)?!1:t}function $(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Pe(e),o=v(1);t&&(r?K(r)&&(o=Q(r)):o=Q(e));let s=Le(a,n,r)?Ie(a):v(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=W(a),t=r&&K(r)?W(r):r,n=e,i=Me(n);for(;i&&r&&t!==n;){let e=Q(i),t=i.getBoundingClientRect(),r=X(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=W(i),i=Me(n)}}return H({width:u,height:d,x:c,y:l})}function Re(e,t){let n=ke(e).scrollLeft;return t?t.left+n:$(G(e)).left+n}function ze(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Re(e,n),y:n.top+t.scrollTop}}function Be(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=G(r),s=t?xe(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=v(1),u=v(0),d=q(r);if((d||!d&&!a)&&((U(r)!==`body`||J(o))&&(c=ke(r)),q(r))){let e=$(r);l=Q(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?ze(o,c):v(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ve(e){return Array.from(e.getClientRects())}function He(e){let t=G(e),n=ke(e),r=e.ownerDocument.body,i=h(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=h(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Re(e),s=-n.scrollTop;return X(r).direction===`rtl`&&(o+=h(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Ue=25;function We(e,t){let n=W(e),r=G(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=De();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Re(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Ue&&(a-=o)}else l<=Ue&&(a+=l);return{width:a,height:o,x:s,y:c}}var Ge=new Set([`absolute`,`fixed`]);function Ke(e,t){let n=$(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=q(e)?Q(e):v(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function qe(e,t,n){let r;if(t===`viewport`)r=We(e,n);else if(t===`document`)r=He(G(e));else if(K(t))r=Ke(t,n);else{let n=Ie(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return H(r)}function Je(e,t){let n=Z(e);return n===t||!K(n)||Y(n)?!1:X(n).position===`fixed`||Je(n,t)}function Ye(e,t){let n=t.get(e);if(n)return n;let r=je(e,[],!1).filter(e=>K(e)&&U(e)!==`body`),i=null,a=X(e).position===`fixed`,o=a?Z(e):e;for(;K(o)&&!Y(o);){let t=X(o),n=Te(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&Ge.has(i.position)||J(o)&&!n&&Je(e,o))?r=r.filter(e=>e!==o):i=t,o=Z(o)}return t.set(e,r),r}function Xe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?xe(t)?[]:Ye(t,this._c):[].concat(n),r],o=a[0],s=a.reduce((e,n)=>{let r=qe(t,n,i);return e.top=h(r.top,e.top),e.right=m(r.right,e.right),e.bottom=m(r.bottom,e.bottom),e.left=h(r.left,e.left),e},qe(t,o,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}}function Ze(e){let{width:t,height:n}=Ne(e);return{width:t,height:n}}function Qe(e,t,n){let r=q(t),i=G(t),a=n===`fixed`,o=$(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=v(0);function l(){c.x=Re(i)}if(r||!r&&!a)if((U(t)!==`body`||J(i))&&(s=ke(t)),r){let e=$(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?ze(i,s):v(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function $e(e){return X(e).position===`static`}function et(e,t){if(!q(e)||X(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return G(e)===n&&(n=n.ownerDocument.body),n}function tt(e,t){let n=W(e);if(xe(e))return n;if(!q(e)){let t=Z(e);for(;t&&!Y(t);){if(K(t)&&!$e(t))return t;t=Z(t)}return n}let r=et(e,t);for(;r&&ye(r)&&$e(r);)r=et(r,t);return r&&Y(r)&&$e(r)&&!Te(r)?n:r||Ee(e)||n}var nt=async function(e){let t=this.getOffsetParent||tt,n=this.getDimensions,r=await n(e.floating);return{reference:Qe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function rt(e){return X(e).direction===`rtl`}var it={convertOffsetParentRelativeRectToViewportRelativeRect:Be,getDocumentElement:G,getClippingRect:Xe,getOffsetParent:tt,getElementRects:nt,getClientRects:Ve,getDimensions:Ze,getScale:Q,isElement:K,isRTL:rt};function at(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ot(e,t){let n=null,r,i=G(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let g=_(d),v=_(i.clientWidth-(u+f)),y=_(i.clientHeight-(d+p)),b=_(u),x={rootMargin:-g+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:h(0,m(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!at(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function st(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Pe(e),u=i||a?[...l?je(l):[],...je(t)]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?ot(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),p.observe(t));let m,h=c?$(e):null;c&&g();function g(){let t=$(e);h&&!at(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ct=ue,lt=de,ut=ie,dt=pe,ft=se,pt=re,mt=fe,ht=(e,t,n)=>{let r=new Map,i={platform:it,...n},a={...i.platform,_c:r};return ne(e,t,{...i,platform:a})},gt=typeof document<`u`?d.useLayoutEffect:function(){};function _t(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!_t(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!_t(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function vt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function yt(e,t){let n=vt(e);return Math.round(t*n)/n}function bt(e){let t=d.useRef(e);return gt(()=>{t.current=e}),t}function xt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:u}=e,[f,p]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=d.useState(r);_t(m,r)||h(r);let[g,_]=d.useState(null),[v,y]=d.useState(null),b=d.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=d.useCallback(e=>{e!==T.current&&(T.current=e,y(e))},[]),S=a||g,C=o||v,w=d.useRef(null),T=d.useRef(null),E=d.useRef(f),D=c!=null,O=bt(c),k=bt(i),A=bt(u),j=d.useCallback(()=>{if(!w.current||!T.current)return;let e={placement:t,strategy:n,middleware:m};k.current&&(e.platform=k.current),ht(w.current,T.current,e).then(e=>{let t={...e,isPositioned:A.current!==!1};M.current&&!_t(E.current,t)&&(E.current=t,l.flushSync(()=>{p(t)}))})},[m,t,n,k,A]);gt(()=>{u===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,p(e=>({...e,isPositioned:!1})))},[u]);let M=d.useRef(!1);gt(()=>(M.current=!0,()=>{M.current=!1}),[]),gt(()=>{if(S&&(w.current=S),C&&(T.current=C),S&&C){if(O.current)return O.current(S,C,j);j()}},[S,C,j,O,D]);let N=d.useMemo(()=>({reference:w,floating:T,setReference:b,setFloating:x}),[b,x]),P=d.useMemo(()=>({reference:S,floating:C}),[S,C]),F=d.useMemo(()=>{let e={position:n,left:0,top:0};if(!P.floating)return e;let t=yt(P.floating,f.x),r=yt(P.floating,f.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...vt(P.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,P.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:j,refs:N,elements:P,floatingStyles:F}),[f,j,N,P,F])}var St=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:pt({element:r.current,padding:i}).fn(n):r?pt({element:r,padding:i}).fn(n):{}}}},Ct=(e,t)=>({...ct(e),options:[e,t]}),wt=(e,t)=>({...lt(e),options:[e,t]}),Tt=(e,t)=>({...mt(e),options:[e,t]}),Et=(e,t)=>({...ut(e),options:[e,t]}),Dt=(e,t)=>({...dt(e),options:[e,t]}),Ot=(e,t)=>({...ft(e),options:[e,t]}),kt=(e,t)=>({...St(e),options:[e,t]}),At=`Arrow`,jt=d.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...o}=e;return(0,u.jsx)(a.svg,{...o,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,u.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});jt.displayName=At;var Mt=jt,Nt=`Popper`,[Pt,Ft]=s(Nt),[It,Lt]=Pt(Nt),Rt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=d.useState(null);return(0,u.jsx)(It,{scope:t,anchor:r,onAnchorChange:i,children:n})};Rt.displayName=Nt;var zt=`PopperAnchor`,Bt=d.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:i,...o}=e,s=Lt(zt,n),c=d.useRef(null),l=r(t,c),f=d.useRef(null);return d.useEffect(()=>{let e=f.current;f.current=i?.current||c.current,e!==f.current&&s.onAnchorChange(f.current)}),i?null:(0,u.jsx)(a.div,{...o,ref:l})});Bt.displayName=zt;var Vt=`PopperContent`,[Ht,Ut]=Pt(Vt),Wt=d.forwardRef((e,t)=>{let{__scopePopper:n,side:i=`bottom`,sideOffset:s=0,align:l=`center`,alignOffset:p=0,arrowPadding:m=0,avoidCollisions:h=!0,collisionBoundary:g=[],collisionPadding:_=0,sticky:v=`partial`,hideWhenDetached:y=!1,updatePositionStrategy:b=`optimized`,onPlaced:x,...S}=e,C=Lt(Vt,n),[w,T]=d.useState(null),E=r(t,e=>T(e)),[D,O]=d.useState(null),k=f(D),A=k?.width??0,j=k?.height??0,M=i+(l===`center`?``:`-`+l),N=typeof _==`number`?_:{top:0,right:0,bottom:0,left:0,..._},P=Array.isArray(g)?g:[g],F=P.length>0,I={padding:N,boundary:P.filter(Jt),altBoundary:F},{refs:L,floatingStyles:R,placement:z,isPositioned:B,middlewareData:V}=xt({strategy:`fixed`,placement:M,whileElementsMounted:(...e)=>st(...e,{animationFrame:b===`always`}),elements:{reference:C.anchor},middleware:[Ct({mainAxis:s+j,alignmentAxis:p}),h&&wt({mainAxis:!0,crossAxis:!1,limiter:v===`partial`?Tt():void 0,...I}),h&&Et({...I}),Dt({...I,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),D&&kt({element:D,padding:m}),Yt({arrowWidth:A,arrowHeight:j}),y&&Ot({strategy:`referenceHidden`,...I})]}),[H,ee]=Xt(z),te=c(x);o(()=>{B&&te?.()},[B,te]);let ne=V.arrow?.x,re=V.arrow?.y,ie=V.arrow?.centerOffset!==0,[ae,oe]=d.useState();return o(()=>{w&&oe(window.getComputedStyle(w).zIndex)},[w]),(0,u.jsx)(`div`,{ref:L.setFloating,"data-radix-popper-content-wrapper":``,style:{...R,transform:B?R.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(` `),...V.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,u.jsx)(Ht,{scope:n,placedSide:H,onArrowChange:O,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,u.jsx)(a.div,{"data-side":H,"data-align":ee,...S,ref:E,style:{...S.style,animation:B?void 0:`none`}})})})});Wt.displayName=Vt;var Gt=`PopperArrow`,Kt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},qt=d.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ut(Gt,n),a=Kt[i.placedSide];return(0,u.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,u.jsx)(Mt,{...r,ref:t,style:{...r.style,display:`block`}})})});qt.displayName=Gt;function Jt(e){return e!==null}var Yt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Xt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Xt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Zt=Rt,Qt=Bt,$t=Wt,en=qt;export{Ft as a,Zt as i,en as n,f as o,$t as r,Qt as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-BH9Ihpd_.js b/internal/web/dist/assets/dist-BH9Ihpd_.js deleted file mode 100644 index 48bafb2..0000000 --- a/internal/web/dist/assets/dist-BH9Ihpd_.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./recharts-V3eOq3uM.js";import{r}from"./dist-CMymZiQ9.js";import{on as i}from"./client-CaIRceNv.js";var a=e(n(),1),o=e(t(),1),s=i(),c=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=r(`Primitive.${t}`),i=a.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,s.jsx)(o,{...a,ref:r})});return i.displayName=`Primitive.${t}`,{...e,[t]:i}},{});function l(e,t){e&&o.flushSync(()=>e.dispatchEvent(t))}function u(e,t){let n=a.createContext(t),r=e=>{let{children:t,...r}=e,i=a.useMemo(()=>r,Object.values(r));return(0,s.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=a.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function d(e,t=[]){let n=[];function r(t,r){let i=a.createContext(r),o=n.length;n=[...n,r];let c=t=>{let{scope:n,children:r,...c}=t,l=n?.[e]?.[o]||i,u=a.useMemo(()=>c,Object.values(c));return(0,s.jsx)(l.Provider,{value:u,children:r})};c.displayName=t+`Provider`;function l(n,s){let c=s?.[e]?.[o]||i,l=a.useContext(c);if(l)return l;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[c,l]}let i=()=>{let t=n.map(e=>a.createContext(e));return function(n){let r=n?.[e]||t;return a.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,f(i,...t)]}function f(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function p(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var m=globalThis?.document?a.useLayoutEffect:()=>{},h=a.useInsertionEffect||m;function g({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,o,s]=_({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:i;{let t=a.useRef(e!==void 0);a.useEffect(()=>{let e=t.current;e!==c&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${c?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=c},[c,r])}return[l,a.useCallback(t=>{if(c){let n=v(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[c,e,o,s])]}function _({defaultProp:e,onChange:t}){let[n,r]=a.useState(e),i=a.useRef(n),o=a.useRef(t);return h(()=>{o.current=t},[t]),a.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}function v(e){return typeof e==`function`}var y=a.useId||(()=>void 0),b=0;function x(e){let[t,n]=a.useState(y());return m(()=>{e||n(e=>e??String(b++))},[e]),e||(t?`radix-${t}`:``)}function S(e){let t=a.useRef(e);return a.useEffect(()=>{t.current=e}),a.useMemo(()=>(...e)=>t.current?.(...e),[])}export{p as a,c,m as i,l,x as n,u as o,g as r,d as s,S as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-CMymZiQ9.js b/internal/web/dist/assets/dist-CMymZiQ9.js deleted file mode 100644 index 64de95e..0000000 --- a/internal/web/dist/assets/dist-CMymZiQ9.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t,u as n}from"./recharts-V3eOq3uM.js";import{on as r}from"./client-CaIRceNv.js";var i=e(t(),1);function a(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function o(...e){return t=>{let n=!1,r=e.map(e=>{let r=a(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t{let{children:r,...a}=e,o=i.Children.toArray(r),s=o.find(m);if(s){let e=s.props.children,r=o.map(t=>t===s?i.Children.count(e)>1?i.Children.only(null):i.isValidElement(e)?e.props.children:null:t);return(0,c.jsx)(t,{...a,ref:n,children:i.isValidElement(e)?i.cloneElement(e,void 0,r):null})}return(0,c.jsx)(t,{...a,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var u=l(`Slot`);function d(e){let t=i.forwardRef((e,t)=>{let{children:n,...r}=e;if(i.isValidElement(n)){let e=g(n),a=h(r,n.props);return n.type!==i.Fragment&&(a.ref=t?o(t,e):e),i.cloneElement(n,a)}return i.Children.count(n)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var f=Symbol(`radix.slottable`);function p(e){let t=({children:e})=>(0,c.jsx)(c.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=f,t}function m(e){return i.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===f}function h(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function g(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var _=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,v=n,y=(e,t)=>n=>{if(t?.variants==null)return v(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=_(t)||_(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return v(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)};export{o as a,p as i,u as n,s as o,l as r,y as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-CQlkROh-.js b/internal/web/dist/assets/dist-CQlkROh-.js deleted file mode 100644 index 0136e72..0000000 --- a/internal/web/dist/assets/dist-CQlkROh-.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{o as n}from"./dist-CMymZiQ9.js";import{on as r}from"./client-CaIRceNv.js";import{a as i,c as a,n as o,r as s,s as c,t as l}from"./dist-BH9Ihpd_.js";import{n as u,t as d}from"./dist-La6s7hND.js";var f=e(t(),1),p=r(),m=`rovingFocusGroup.onEntryFocus`,h={bubbles:!1,cancelable:!0},g=`RovingFocusGroup`,[_,v,y]=u(g),[b,x]=c(g,[y]),[S,C]=b(g),w=f.forwardRef((e,t)=>(0,p.jsx)(_.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,p.jsx)(_.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,p.jsx)(T,{...e,ref:t})})}));w.displayName=g;var T=f.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:r,orientation:o,loop:c=!1,dir:u,currentTabStopId:_,defaultCurrentTabStopId:y,onCurrentTabStopIdChange:b,onEntryFocus:x,preventScrollOnEntryFocus:C=!1,...w}=e,T=f.useRef(null),E=n(t,T),D=d(u),[O,k]=s({prop:_,defaultProp:y??null,onChange:b,caller:g}),[A,M]=f.useState(!1),N=l(x),P=v(r),F=f.useRef(!1),[I,L]=f.useState(0);return f.useEffect(()=>{let e=T.current;if(e)return e.addEventListener(m,N),()=>e.removeEventListener(m,N)},[N]),(0,p.jsx)(S,{scope:r,orientation:o,dir:D,loop:c,currentTabStopId:O,onItemFocus:f.useCallback(e=>k(e),[k]),onItemShiftTab:f.useCallback(()=>M(!0),[]),onFocusableItemAdd:f.useCallback(()=>L(e=>e+1),[]),onFocusableItemRemove:f.useCallback(()=>L(e=>e-1),[]),children:(0,p.jsx)(a.div,{tabIndex:A||I===0?-1:0,"data-orientation":o,...w,ref:E,style:{outline:`none`,...e.style},onMouseDown:i(e.onMouseDown,()=>{F.current=!0}),onFocus:i(e.onFocus,e=>{let t=!F.current;if(e.target===e.currentTarget&&t&&!A){let t=new CustomEvent(m,h);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=P().filter(e=>e.focusable);j([e.find(e=>e.active),e.find(e=>e.id===O),...e].filter(Boolean).map(e=>e.ref.current),C)}}F.current=!1}),onBlur:i(e.onBlur,()=>M(!1))})})}),E=`RovingFocusGroupItem`,D=f.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:s=!1,tabStopId:c,children:l,...u}=e,d=o(),m=c||d,h=C(E,n),g=h.currentTabStopId===m,y=v(n),{onFocusableItemAdd:b,onFocusableItemRemove:x,currentTabStopId:S}=h;return f.useEffect(()=>{if(r)return b(),()=>x()},[r,b,x]),(0,p.jsx)(_.ItemSlot,{scope:n,id:m,focusable:r,active:s,children:(0,p.jsx)(a.span,{tabIndex:g?0:-1,"data-orientation":h.orientation,...u,ref:t,onMouseDown:i(e.onMouseDown,e=>{r?h.onItemFocus(m):e.preventDefault()}),onFocus:i(e.onFocus,()=>h.onItemFocus(m)),onKeyDown:i(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){h.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=A(e,h.orientation,h.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=y().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=h.loop?M(n,r+1):n.slice(r+1)}setTimeout(()=>j(n))}}),children:typeof l==`function`?l({isCurrentTabStop:g,hasTabStop:S!=null}):l})})});D.displayName=E;var O={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function k(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function A(e,t,n){let r=k(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return O[r]}function j(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function M(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var N=w,P=D;export{N as n,x as r,P as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-La6s7hND.js b/internal/web/dist/assets/dist-La6s7hND.js deleted file mode 100644 index 4f0b50a..0000000 --- a/internal/web/dist/assets/dist-La6s7hND.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{o as n,r}from"./dist-CMymZiQ9.js";import{on as i}from"./client-CaIRceNv.js";import{s as a}from"./dist-BH9Ihpd_.js";var o=e(t(),1),s=i();function c(e){let t=e+`CollectionProvider`,[i,c]=a(t),[l,u]=i(t,{collectionRef:{current:null},itemMap:new Map}),d=e=>{let{scope:t,children:n}=e,r=o.useRef(null),i=o.useRef(new Map).current;return(0,s.jsx)(l,{scope:t,itemMap:i,collectionRef:r,children:n})};d.displayName=t;let f=e+`CollectionSlot`,p=r(f),m=o.forwardRef((e,t)=>{let{scope:r,children:i}=e;return(0,s.jsx)(p,{ref:n(t,u(f,r).collectionRef),children:i})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=r(h),v=o.forwardRef((e,t)=>{let{scope:r,children:i,...a}=e,c=o.useRef(null),l=n(t,c),d=u(h,r);return o.useEffect(()=>(d.itemMap.set(c,{ref:c,...a}),()=>void d.itemMap.delete(c))),(0,s.jsx)(_,{[g]:``,ref:l,children:i})});v.displayName=h;function y(t){let n=u(e+`CollectionConsumer`,t);return o.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:d,Slot:m,ItemSlot:v},y,c]}var l=o.createContext(void 0);function u(e){let t=o.useContext(l);return e||t||`ltr`}export{c as n,u as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-fSR-p5Cs.js b/internal/web/dist/assets/dist-fSR-p5Cs.js deleted file mode 100644 index a6b64f9..0000000 --- a/internal/web/dist/assets/dist-fSR-p5Cs.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";var n=e(t(),1);function r(e){let t=n.useRef({value:e,previous:e});return n.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}export{r as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dist-vH0vUzvx.js b/internal/web/dist/assets/dist-vH0vUzvx.js deleted file mode 100644 index 113bbc3..0000000 --- a/internal/web/dist/assets/dist-vH0vUzvx.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{on as n}from"./client-CaIRceNv.js";import{c as r}from"./dist-BH9Ihpd_.js";var i=e(t(),1),a=n(),o=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),s=`VisuallyHidden`,c=i.forwardRef((e,t)=>(0,a.jsx)(r.span,{...e,ref:t,style:{...o,...e.style}}));c.displayName=s;var l=c;export{o as n,l as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/dropdown-menu-iCiwbrNR.js b/internal/web/dist/assets/dropdown-menu-iCiwbrNR.js deleted file mode 100644 index eb9e41b..0000000 --- a/internal/web/dist/assets/dropdown-menu-iCiwbrNR.js +++ /dev/null @@ -1 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{f as t}from"./recharts-V3eOq3uM.js";import{a as n,o as r,r as i}from"./dist-CMymZiQ9.js";import{in as a,on as o}from"./client-CaIRceNv.js";import{a as s,c,l,n as u,r as d,s as f,t as p}from"./dist-BH9Ihpd_.js";import{n as m,t as h}from"./dist-La6s7hND.js";import{t as g}from"./dist--QlMmz49.js";import{a as ee,i as _,n as te,o as ne,r as re,t as v}from"./es2015-DXlrlJR9.js";import{a as y,i as b,n as ie,r as ae,t as x}from"./dist-B0VJ9haL.js";import{n as oe,r as S,t as C}from"./dist-CQlkROh-.js";var w=e(t(),1),T=o(),E=[`Enter`,` `],se=[`ArrowDown`,`PageUp`,`Home`],ce=[`ArrowUp`,`PageDown`,`End`],le=[...se,...ce],D={ltr:[...E,`ArrowRight`],rtl:[...E,`ArrowLeft`]},O={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},k=`Menu`,[A,ue,j]=m(k),[M,N]=f(k,[j,y,S]),P=y(),de=S(),[F,I]=M(k),[fe,L]=M(k),R=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=P(t),[c,l]=w.useState(null),u=w.useRef(!1),d=p(a),f=h(i);return w.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,T.jsx)(b,{...s,children:(0,T.jsx)(F,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,T.jsx)(fe,{scope:t,onClose:w.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};R.displayName=k;var pe=`MenuAnchor`,z=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=P(n);return(0,T.jsx)(x,{...i,...r,ref:t})});z.displayName=pe;var B=`MenuPortal`,[me,he]=M(B,{forceMount:void 0}),ge=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=I(B,t);return(0,T.jsx)(me,{scope:t,forceMount:n,children:(0,T.jsx)(g,{present:n||a.open,children:(0,T.jsx)(_,{asChild:!0,container:i,children:r})})})};ge.displayName=B;var V=`MenuContent`,[_e,H]=M(V),ve=w.forwardRef((e,t)=>{let n=he(V,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=I(V,e.__scopeMenu),o=L(V,e.__scopeMenu);return(0,T.jsx)(A.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(g,{present:r||a.open,children:(0,T.jsx)(A.Slot,{scope:e.__scopeMenu,children:o.modal?(0,T.jsx)(ye,{...i,ref:t}):(0,T.jsx)(be,{...i,ref:t})})})})}),ye=w.forwardRef((e,t)=>{let n=I(V,e.__scopeMenu),i=w.useRef(null),a=r(t,i);return w.useEffect(()=>{let e=i.current;if(e)return v(e)},[]),(0,T.jsx)(U,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:s(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),be=w.forwardRef((e,t)=>{let n=I(V,e.__scopeMenu);return(0,T.jsx)(U,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),xe=i(`MenuContent.ScrollLock`),U=w.forwardRef((e,t)=>{let{__scopeMenu:n,loop:i=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:c,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:h,disableOutsideScroll:g,..._}=e,v=I(V,n),y=L(V,n),b=P(n),ie=de(n),x=ue(n),[S,C]=w.useState(null),E=w.useRef(null),se=r(t,E,v.onContentChange),D=w.useRef(0),O=w.useRef(``),k=w.useRef(0),A=w.useRef(null),j=w.useRef(`right`),M=w.useRef(0),N=g?te:w.Fragment,F=g?{as:xe,allowPinchZoom:!0}:void 0,fe=e=>{let t=O.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Qe(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){O.current=t,window.clearTimeout(D.current),t!==``&&(D.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};w.useEffect(()=>()=>window.clearTimeout(D.current),[]),re();let R=w.useCallback(e=>j.current===A.current?.side&&et(e,A.current?.area),[]);return(0,T.jsx)(_e,{scope:n,searchRef:O,onItemEnter:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:w.useCallback(e=>{R(e)||(E.current?.focus(),C(null))},[R]),onTriggerLeave:w.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:k,onPointerGraceIntentChange:w.useCallback(e=>{A.current=e},[]),children:(0,T.jsx)(N,{...F,children:(0,T.jsx)(ee,{asChild:!0,trapped:a,onMountAutoFocus:s(o,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:c,children:(0,T.jsx)(ne,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:m,onDismiss:h,children:(0,T.jsx)(oe,{asChild:!0,...ie,dir:y.dir,orientation:`vertical`,loop:i,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:s(u,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,T.jsx)(ae,{role:`menu`,"aria-orientation":`vertical`,"data-state":Je(v.open),"data-radix-menu-content":``,dir:y.dir,...b,..._,ref:se,style:{outline:`none`,..._.style},onKeyDown:s(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&fe(e.key));let i=E.current;if(e.target!==i||!le.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);ce.includes(e.key)&&a.reverse(),Xe(a)}),onBlur:s(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(D.current),O.current=``)}),onPointerMove:s(e.onPointerMove,Z(e=>{let t=e.target,n=M.current!==e.clientX;e.currentTarget.contains(t)&&n&&(j.current=e.clientX>M.current?`right`:`left`,M.current=e.clientX)}))})})})})})})});ve.displayName=V;var Se=`MenuGroup`,W=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`group`,...r,ref:t})});W.displayName=Se;var Ce=`MenuLabel`,we=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{...r,ref:t})});we.displayName=Ce;var G=`MenuItem`,Te=`menu.itemSelect`,K=w.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:i,...a}=e,o=w.useRef(null),c=L(G,e.__scopeMenu),u=H(G,e.__scopeMenu),d=r(t,o),f=w.useRef(!1),p=()=>{let e=o.current;if(!n&&e){let t=new CustomEvent(Te,{bubbles:!0,cancelable:!0});e.addEventListener(Te,e=>i?.(e),{once:!0}),l(e,t),t.defaultPrevented?f.current=!1:c.onClose()}};return(0,T.jsx)(Ee,{...a,ref:d,disabled:n,onClick:s(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),f.current=!0},onPointerUp:s(e.onPointerUp,e=>{f.current||e.currentTarget?.click()}),onKeyDown:s(e.onKeyDown,e=>{let t=u.searchRef.current!==``;n||t&&e.key===` `||E.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});K.displayName=G;var Ee=w.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:i=!1,textValue:a,...o}=e,l=H(G,n),u=de(n),d=w.useRef(null),f=r(t,d),[p,m]=w.useState(!1),[h,g]=w.useState(``);return w.useEffect(()=>{let e=d.current;e&&g((e.textContent??``).trim())},[o.children]),(0,T.jsx)(A.ItemSlot,{scope:n,disabled:i,textValue:a??h,children:(0,T.jsx)(C,{asChild:!0,...u,focusable:!i,children:(0,T.jsx)(c.div,{role:`menuitem`,"data-highlighted":p?``:void 0,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,...o,ref:f,onPointerMove:s(e.onPointerMove,Z(e=>{i?l.onItemLeave(e):(l.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:s(e.onPointerLeave,Z(e=>l.onItemLeave(e))),onFocus:s(e.onFocus,()=>m(!0)),onBlur:s(e.onBlur,()=>m(!1))})})})}),De=`MenuCheckboxItem`,Oe=w.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,T.jsx)(Fe,{scope:e.__scopeMenu,checked:n,children:(0,T.jsx)(K,{role:`menuitemcheckbox`,"aria-checked":X(n)?`mixed`:n,...i,ref:t,"data-state":Ye(n),onSelect:s(i.onSelect,()=>r?.(X(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Oe.displayName=De;var ke=`MenuRadioGroup`,[Ae,je]=M(ke,{value:void 0,onValueChange:()=>{}}),Me=w.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=p(r);return(0,T.jsx)(Ae,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,T.jsx)(W,{...i,ref:t})})});Me.displayName=ke;var Ne=`MenuRadioItem`,Pe=w.forwardRef((e,t)=>{let{value:n,...r}=e,i=je(Ne,e.__scopeMenu),a=n===i.value;return(0,T.jsx)(Fe,{scope:e.__scopeMenu,checked:a,children:(0,T.jsx)(K,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ye(a),onSelect:s(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});Pe.displayName=Ne;var q=`MenuItemIndicator`,[Fe,Ie]=M(q,{checked:!1}),Le=w.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Ie(q,n);return(0,T.jsx)(g,{present:r||X(a.checked)||a.checked===!0,children:(0,T.jsx)(c.span,{...i,ref:t,"data-state":Ye(a.checked)})})});Le.displayName=q;var Re=`MenuSeparator`,ze=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,T.jsx)(c.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});ze.displayName=Re;var Be=`MenuArrow`,Ve=w.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=P(n);return(0,T.jsx)(ie,{...i,...r,ref:t})});Ve.displayName=Be;var J=`MenuSub`,[He,Ue]=M(J),We=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=I(J,t),o=P(t),[s,c]=w.useState(null),[l,d]=w.useState(null),f=p(i);return w.useEffect(()=>(a.open===!1&&f(!1),()=>f(!1)),[a.open,f]),(0,T.jsx)(b,{...o,children:(0,T.jsx)(F,{scope:t,open:r,onOpenChange:f,content:l,onContentChange:d,children:(0,T.jsx)(He,{scope:t,contentId:u(),triggerId:u(),trigger:s,onTriggerChange:c,children:n})})})};We.displayName=J;var Y=`MenuSubTrigger`,Ge=w.forwardRef((e,t)=>{let r=I(Y,e.__scopeMenu),i=L(Y,e.__scopeMenu),a=Ue(Y,e.__scopeMenu),o=H(Y,e.__scopeMenu),c=w.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=o,d={__scopeMenu:e.__scopeMenu},f=w.useCallback(()=>{c.current&&window.clearTimeout(c.current),c.current=null},[]);return w.useEffect(()=>f,[f]),w.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),u(null)}},[l,u]),(0,T.jsx)(z,{asChild:!0,...d,children:(0,T.jsx)(Ee,{id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":r.open,"aria-controls":a.contentId,"data-state":Je(r.open),...e,ref:n(t,a.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:s(e.onPointerMove,Z(t=>{o.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!r.open&&!c.current&&(o.onPointerGraceIntentChange(null),c.current=window.setTimeout(()=>{r.onOpenChange(!0),f()},100))})),onPointerLeave:s(e.onPointerLeave,Z(e=>{f();let t=r.content?.getBoundingClientRect();if(t){let n=r.content?.dataset.side,i=n===`right`,a=i?-5:5,s=t[i?`left`:`right`],c=t[i?`right`:`left`];o.onPointerGraceIntentChange({area:[{x:e.clientX+a,y:e.clientY},{x:s,y:t.top},{x:c,y:t.top},{x:c,y:t.bottom},{x:s,y:t.bottom}],side:n}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:s(e.onKeyDown,t=>{let n=o.searchRef.current!==``;e.disabled||n&&t.key===` `||D[i.dir].includes(t.key)&&(r.onOpenChange(!0),r.content?.focus(),t.preventDefault())})})})});Ge.displayName=Y;var Ke=`MenuSubContent`,qe=w.forwardRef((e,t)=>{let n=he(V,e.__scopeMenu),{forceMount:i=n.forceMount,...a}=e,o=I(V,e.__scopeMenu),c=L(V,e.__scopeMenu),l=Ue(Ke,e.__scopeMenu),u=w.useRef(null),d=r(t,u);return(0,T.jsx)(A.Provider,{scope:e.__scopeMenu,children:(0,T.jsx)(g,{present:i||o.open,children:(0,T.jsx)(A.Slot,{scope:e.__scopeMenu,children:(0,T.jsx)(U,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:`start`,side:c.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{c.isUsingKeyboardRef.current&&u.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:s(e.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:s(e.onEscapeKeyDown,e=>{c.onClose(),e.preventDefault()}),onKeyDown:s(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=O[c.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});qe.displayName=Ke;function Je(e){return e?`open`:`closed`}function X(e){return e===`indeterminate`}function Ye(e){return X(e)?`indeterminate`:e?`checked`:`unchecked`}function Xe(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ze(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Qe(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ze(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function $e(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;er!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function et(e,t){return t?$e({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var tt=R,nt=z,rt=ge,it=ve,at=W,ot=we,st=K,ct=Oe,lt=Me,ut=Pe,dt=Le,ft=ze,pt=Ve,mt=Ge,ht=qe,Q=`DropdownMenu`,[gt,_t]=f(Q,[N]),$=N(),[vt,yt]=gt(Q),bt=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$(t),l=w.useRef(null),[f,p]=d({prop:i,defaultProp:a??!1,onChange:o,caller:Q});return(0,T.jsx)(vt,{scope:t,triggerId:u(),triggerRef:l,contentId:u(),open:f,onOpenChange:p,onOpenToggle:w.useCallback(()=>p(e=>!e),[p]),modal:s,children:(0,T.jsx)(tt,{...c,open:f,onOpenChange:p,dir:r,modal:s,children:n})})};bt.displayName=Q;var xt=`DropdownMenuTrigger`,St=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:r,disabled:i=!1,...a}=e,o=yt(xt,r),l=$(r);return(0,T.jsx)(nt,{asChild:!0,...l,children:(0,T.jsx)(c.button,{type:`button`,id:o.triggerId,"aria-haspopup":`menu`,"aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:n(t,o.triggerRef),onPointerDown:s(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:s(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&o.onOpenToggle(),e.key===`ArrowDown`&&o.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});St.displayName=xt;var Ct=`DropdownMenuPortal`,wt=e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,T.jsx)(rt,{...r,...n})};wt.displayName=Ct;var Tt=`DropdownMenuContent`,Et=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=yt(Tt,n),a=$(n),o=w.useRef(!1);return(0,T.jsx)(it,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:s(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:s(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Et.displayName=Tt;var Dt=`DropdownMenuGroup`,Ot=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(at,{...i,...r,ref:t})});Ot.displayName=Dt;var kt=`DropdownMenuLabel`,At=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(ot,{...i,...r,ref:t})});At.displayName=kt;var jt=`DropdownMenuItem`,Mt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(st,{...i,...r,ref:t})});Mt.displayName=jt;var Nt=`DropdownMenuCheckboxItem`,Pt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(ct,{...i,...r,ref:t})});Pt.displayName=Nt;var Ft=`DropdownMenuRadioGroup`,It=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(lt,{...i,...r,ref:t})});It.displayName=Ft;var Lt=`DropdownMenuRadioItem`,Rt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(ut,{...i,...r,ref:t})});Rt.displayName=Lt;var zt=`DropdownMenuItemIndicator`,Bt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(dt,{...i,...r,ref:t})});Bt.displayName=zt;var Vt=`DropdownMenuSeparator`,Ht=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(ft,{...i,...r,ref:t})});Ht.displayName=Vt;var Ut=`DropdownMenuArrow`,Wt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(pt,{...i,...r,ref:t})});Wt.displayName=Ut;var Gt=`DropdownMenuSubTrigger`,Kt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(mt,{...i,...r,ref:t})});Kt.displayName=Gt;var qt=`DropdownMenuSubContent`,Jt=w.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,T.jsx)(ht,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Jt.displayName=qt;var Yt=bt,Xt=St,Zt=wt,Qt=Et,$t=At,en=Mt,tn=Ht;function nn({...e}){return(0,T.jsx)(Yt,{"data-slot":`dropdown-menu`,...e})}function rn({...e}){return(0,T.jsx)(Xt,{"data-slot":`dropdown-menu-trigger`,...e})}function an({className:e,sideOffset:t=4,...n}){return(0,T.jsx)(Zt,{children:(0,T.jsx)(Qt,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:a(`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto border p-1`,e),...n})})}function on({className:e,inset:t,variant:n=`default`,...r}){return(0,T.jsx)(en,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:a(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...r})}function sn({className:e,inset:t,...n}){return(0,T.jsx)($t,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:a(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function cn({className:e,...t}){return(0,T.jsx)(tn,{"data-slot":`dropdown-menu-separator`,className:a(`bg-border -mx-1 my-1 h-px`,e),...t})}export{cn as a,sn as i,an as n,rn as o,on as r,nn as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/empty-state-B9mtYx_X.js b/internal/web/dist/assets/empty-state-B9mtYx_X.js deleted file mode 100644 index e045c58..0000000 --- a/internal/web/dist/assets/empty-state-B9mtYx_X.js +++ /dev/null @@ -1 +0,0 @@ -import{in as e,on as t}from"./client-CaIRceNv.js";var n=t();function r({icon:t,title:r,description:i,action:a,density:o=`card`,className:s,testid:c}){return(0,n.jsxs)(`div`,{"data-testid":c,className:e(`flex flex-col items-center justify-center text-center`,o===`card`?`border border-dashed border-border bg-card/30 px-6 py-12`:`px-3 py-6`,s),children:[t&&(0,n.jsx)(`div`,{className:`mb-3 text-muted-foreground/40`,"aria-hidden":!0,children:t}),(0,n.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r}),i&&(0,n.jsx)(`div`,{className:`mt-1.5 max-w-md text-xs leading-relaxed text-muted-foreground`,children:i}),a&&(0,n.jsx)(`div`,{className:`mt-4`,children:a})]})}export{r as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/es2015-DXlrlJR9.js b/internal/web/dist/assets/es2015-DXlrlJR9.js deleted file mode 100644 index 815d1a9..0000000 --- a/internal/web/dist/assets/es2015-DXlrlJR9.js +++ /dev/null @@ -1,41 +0,0 @@ -import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{d as t,f as n}from"./recharts-V3eOq3uM.js";import{o as r}from"./dist-CMymZiQ9.js";import{on as i}from"./client-CaIRceNv.js";import{a,c as o,i as s,l as c,t as l}from"./dist-BH9Ihpd_.js";var u=e(n(),1);function d(e,t=globalThis?.document){let n=l(e);u.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var f=i(),p=`DismissableLayer`,m=`dismissableLayer.update`,h=`dismissableLayer.pointerDownOutside`,g=`dismissableLayer.focusOutside`,_,v=u.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),y=u.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:c,onInteractOutside:l,onDismiss:p,...h}=e,g=u.useContext(v),[y,b]=u.useState(null),x=y?.ownerDocument??globalThis?.document,[,T]=u.useState({}),E=r(t,e=>b(e)),D=Array.from(g.layers),[O]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),ee=D.indexOf(O),k=y?D.indexOf(y):-1,te=g.layersWithOutsidePointerEventsDisabled.size>0,A=k>=ee,j=S(e=>{let t=e.target,n=[...g.branches].some(e=>e.contains(t));!A||n||(s?.(e),l?.(e),e.defaultPrevented||p?.())},x),M=C(e=>{let t=e.target;[...g.branches].some(e=>e.contains(t))||(c?.(e),l?.(e),e.defaultPrevented||p?.())},x);return d(e=>{k===g.layers.size-1&&(i?.(e),!e.defaultPrevented&&p&&(e.preventDefault(),p()))},x),u.useEffect(()=>{if(y)return n&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(_=x.body.style.pointerEvents,x.body.style.pointerEvents=`none`),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),w(),()=>{n&&g.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=_)}},[y,x,n,g]),u.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),w())},[y,g]),u.useEffect(()=>{let e=()=>T({});return document.addEventListener(m,e),()=>document.removeEventListener(m,e)},[]),(0,f.jsx)(o.div,{...h,ref:E,style:{pointerEvents:te?A?`auto`:`none`:void 0,...e.style},onFocusCapture:a(e.onFocusCapture,M.onFocusCapture),onBlurCapture:a(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:a(e.onPointerDownCapture,j.onPointerDownCapture)})});y.displayName=p;var b=`DismissableLayerBranch`,x=u.forwardRef((e,t)=>{let n=u.useContext(v),i=u.useRef(null),a=r(t,i);return u.useEffect(()=>{let e=i.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,f.jsx)(o.div,{...e,ref:a})});x.displayName=b;function S(e,t=globalThis?.document){let n=l(e),r=u.useRef(!1),i=u.useRef(()=>{});return u.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){T(h,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function C(e,t=globalThis?.document){let n=l(e),r=u.useRef(!1);return u.useEffect(()=>{let e=e=>{e.target&&!r.current&&T(g,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function w(){let e=new CustomEvent(m);document.dispatchEvent(e)}function T(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?c(i,a):i.dispatchEvent(a)}var E=`focusScope.autoFocusOnMount`,D=`focusScope.autoFocusOnUnmount`,O={bubbles:!1,cancelable:!0},ee=`FocusScope`,k=u.forwardRef((e,t)=>{let{loop:n=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:s,...c}=e,[d,p]=u.useState(null),m=l(a),h=l(s),g=u.useRef(null),_=r(t,e=>p(e)),v=u.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;u.useEffect(()=>{if(i){let e=function(e){if(v.paused||!d)return;let t=e.target;d.contains(t)?g.current=t:N(g.current,{select:!0})},t=function(e){if(v.paused||!d)return;let t=e.relatedTarget;t!==null&&(d.contains(t)||N(g.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&N(d)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return d&&r.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[i,d,v.paused]),u.useEffect(()=>{if(d){ie.add(v);let e=document.activeElement;if(!d.contains(e)){let t=new CustomEvent(E,O);d.addEventListener(E,m),d.dispatchEvent(t),t.defaultPrevented||(te(se(j(d)),{select:!0}),document.activeElement===e&&N(d))}return()=>{d.removeEventListener(E,m),setTimeout(()=>{let t=new CustomEvent(D,O);d.addEventListener(D,h),d.dispatchEvent(t),t.defaultPrevented||N(e??document.body,{select:!0}),d.removeEventListener(D,h),ie.remove(v)},0)}}},[d,m,h,v]);let y=u.useCallback(e=>{if(!n&&!i||v.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){let t=e.currentTarget,[i,a]=A(t);i&&a?!e.shiftKey&&r===a?(e.preventDefault(),n&&N(i,{select:!0})):e.shiftKey&&r===i&&(e.preventDefault(),n&&N(a,{select:!0})):r===t&&e.preventDefault()}},[n,i,v.paused]);return(0,f.jsx)(o.div,{tabIndex:-1,...c,ref:_,onKeyDown:y})});k.displayName=ee;function te(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(N(r,{select:t}),document.activeElement!==n)return}function A(e){let t=j(e);return[M(t,e),M(t.reverse(),e)]}function j(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function M(e,t){for(let n of e)if(!ne(n,{upTo:t}))return n}function ne(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function re(e){return e instanceof HTMLInputElement&&`select`in e}function N(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&re(e)&&t&&e.select()}}var ie=ae();function ae(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=oe(e,t),e.unshift(t)},remove(t){e=oe(e,t),e[0]?.resume()}}}function oe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function se(e){return e.filter(e=>e.tagName!==`A`)}var ce=e(t(),1),le=`Portal`,ue=u.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=u.useState(!1);s(()=>a(!0),[]);let c=n||i&&globalThis?.document?.body;return c?ce.createPortal((0,f.jsx)(o.div,{...r,ref:t}),c):null});ue.displayName=le;var P=0;function de(){u.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??fe()),document.body.insertAdjacentElement(`beforeend`,e[1]??fe()),P++,()=>{P===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),P--}},[])}function fe(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var F=function(){return F=Object.assign||function(e){for(var t,n=1,r=arguments.length;n`u`)return Pe;var t=Fe(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Le=Ne(),U=`data-scroll-locked`,Re=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),` - .${me} { - overflow: hidden ${r}; - padding-right: ${s}px ${r}; - } - body[${U}] { - overflow: hidden ${r}; - overscroll-behavior: contain; - ${[t&&`position: relative ${r};`,n===`margin`&&` - padding-left: ${i}px; - padding-top: ${a}px; - padding-right: ${o}px; - margin-left:0; - margin-top:0; - margin-right: ${s}px ${r}; - `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)} - } - - .${L} { - right: ${s}px ${r}; - } - - .${R} { - margin-right: ${s}px ${r}; - } - - .${L} .${L} { - right: 0 ${r}; - } - - .${R} .${R} { - margin-right: 0 ${r}; - } - - body[${U}] { - ${he}: ${s}px; - } -`},ze=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Be=function(){u.useEffect(function(){return document.body.setAttribute(U,(ze()+1).toString()),function(){var e=ze()-1;e<=0?document.body.removeAttribute(U):document.body.setAttribute(U,e.toString())}},[])},Ve=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Be();var a=u.useMemo(function(){return Ie(i)},[i]);return u.createElement(Le,{styles:Re(a,!t,i,n?``:`!important`)})},W=!1;if(typeof window<`u`)try{var G=Object.defineProperty({},"passive",{get:function(){return W=!0,!0}});window.addEventListener(`test`,G,G),window.removeEventListener(`test`,G,G)}catch{W=!1}var K=W?{passive:!1}:!1,He=function(e){return e.tagName===`TEXTAREA`},Ue=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!He(e)&&n[t]===`visible`)},We=function(e){return Ue(e,`overflowY`)},Ge=function(e){return Ue(e,`overflowX`)},Ke=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Ye(e,r)){var i=Xe(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},qe=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Je=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Ye=function(e,t){return e===`v`?We(t):Ge(t)},Xe=function(e,t){return e===`v`?qe(t):Je(t)},Ze=function(e,t){return e===`h`&&t===`rtl`?-1:1},Qe=function(e,t,n,r,i){var a=Ze(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Xe(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Ye(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},q=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},J=function(e){return[e.deltaX,e.deltaY]},$e=function(e){return e&&`current`in e?e.current:e},et=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tt=function(e){return` - .block-interactivity-${e} {pointer-events: none;} - .allow-interactivity-${e} {pointer-events: all;} -`},nt=0,Y=[];function rt(e){var t=u.useRef([]),n=u.useRef([0,0]),r=u.useRef(),i=u.useState(nt++)[0],a=u.useState(Ne)[0],o=u.useRef(e);u.useEffect(function(){o.current=e},[e]),u.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=pe([e.lockRef.current],(e.shards||[]).map($e),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=u.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=q(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Ke(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Ke(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Qe(h,t,e,h===`h`?s:c,!0)},[]),c=u.useCallback(function(e){var n=e;if(!(!Y.length||Y[Y.length-1]!==a)){var r=`deltaY`in n?J(n):q(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&et(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map($e).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=u.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:it(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),d=u.useCallback(function(e){n.current=q(e),r.current=void 0},[]),f=u.useCallback(function(t){l(t.type,J(t),t.target,s(t,e.lockRef.current))},[]),p=u.useCallback(function(t){l(t.type,q(t),t.target,s(t,e.lockRef.current))},[]);u.useEffect(function(){return Y.push(a),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener(`wheel`,c,K),document.addEventListener(`touchmove`,c,K),document.addEventListener(`touchstart`,d,K),function(){Y=Y.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,K),document.removeEventListener(`touchmove`,c,K),document.removeEventListener(`touchstart`,d,K)}},[]);var m=e.removeScrollBar,h=e.inert;return u.createElement(u.Fragment,null,h?u.createElement(a,{styles:tt(i)}):null,m?u.createElement(Ve,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function it(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var at=we(Te,rt),ot=u.forwardRef(function(e,t){return u.createElement(V,F({},e,{ref:t,sideCar:at}))});ot.classNames=V.classNames;var st=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},X=new WeakMap,Z=new WeakMap,Q={},$=0,ct=function(e){return e&&(e.host||ct(e.parentNode))},lt=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=ct(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ut=function(e,t,n,r){var i=lt(t,Array.isArray(e)?e:[e]);Q[n]||(Q[n]=new WeakMap);var a=Q[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(X.get(e)||0)+1,l=(a.get(e)||0)+1;X.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Z.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),$++,function(){o.forEach(function(e){var t=X.get(e)-1,i=a.get(e)-1;X.set(e,t),a.set(e,i),t||(Z.has(e)||e.removeAttribute(r),Z.delete(e)),i||e.removeAttribute(n)}),$--,$||(X=new WeakMap,X=new WeakMap,Z=new WeakMap,Q={})}},dt=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||st(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ut(r,i,n,`aria-hidden`)):function(){return null}};export{k as a,ue as i,ot as n,y as o,de as r,dt as t}; \ No newline at end of file diff --git a/internal/web/dist/assets/folder-DHzynzTC.js b/internal/web/dist/assets/folder-DHzynzTC.js deleted file mode 100644 index 4a32eb6..0000000 --- a/internal/web/dist/assets/folder-DHzynzTC.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/funnel-BvqzDyhp.js b/internal/web/dist/assets/funnel-BvqzDyhp.js deleted file mode 100644 index 73df949..0000000 --- a/internal/web/dist/assets/funnel-BvqzDyhp.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/inbox-ClSTJaEn.js b/internal/web/dist/assets/inbox-ClSTJaEn.js deleted file mode 100644 index 53b5668..0000000 --- a/internal/web/dist/assets/inbox-ClSTJaEn.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./createLucideIcon-WB390fY6.js";var t=e(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]);export{t}; \ No newline at end of file diff --git a/internal/web/dist/assets/index-BDLzoIgt.js b/internal/web/dist/assets/index-BDLzoIgt.js deleted file mode 100644 index 5aebdb2..0000000 --- a/internal/web/dist/assets/index-BDLzoIgt.js +++ /dev/null @@ -1,32 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-Bgs2hZX0.js","assets/rolldown-runtime-QTnfLwEv.js","assets/toggle-group-CwLNIqWC.js","assets/dist-BH9Ihpd_.js","assets/dist-CMymZiQ9.js","assets/recharts-V3eOq3uM.js","assets/client-CaIRceNv.js","assets/dist-La6s7hND.js","assets/dist-CQlkROh-.js","assets/createLucideIcon-WB390fY6.js","assets/chevron-right-CyhRDGe7.js","assets/database-DUeGtnBt.js","assets/AuditDetailDialog-CIIIkhsj.js","assets/arrow-down-BlDh7bya.js","assets/arrow-up-CWTnU2zx.js","assets/cpu-DpW4CSHk.js","assets/funnel-BvqzDyhp.js","assets/route-CMSYmLBM.js","assets/sse-backoff-CEavbS-d.js","assets/TaskRef-D6QBTHtc.js","assets/task-utils-BkVzAeUR.js","assets/inbox-ClSTJaEn.js","assets/list-checks-B0hSiAul.js","assets/wifi-off-wjnWavsP.js","assets/workflow-COO0Sn-w.js","assets/table-2N0Q-yAm.js","assets/use-tasks-stream-BfVVn1xh.js","assets/AuditPage-kXFcF4K1.js","assets/dropdown-menu-iCiwbrNR.js","assets/dist-B0VJ9haL.js","assets/es2015-DXlrlJR9.js","assets/dist--QlMmz49.js","assets/ConfigPage-BWoHdHHz.js","assets/scope-label-D4K1COuM.js","assets/info-C1fwy83I.js","assets/pencil-Dy4EC74G.js","assets/save-Baaykonc.js","assets/textarea-BiOhexhg.js","assets/WorkspacesPage-cB7mcsGf.js","assets/LinkedWorkspacesPage-Dj4_-qpn.js","assets/DryRunPage-Beu-_yJs.js","assets/play-YbzkBfB8.js","assets/CreateMCP-C1MoexMP.js","assets/ConnectionsPage-BWNiOJ8h.js","assets/network-CrANvqlb.js","assets/ApprovalsPage-Diz3qyC2.js","assets/calendar-clock-Z37rBeGY.js","assets/empty-state-B9mtYx_X.js","assets/SettingsPage-D8ep4DBs.js","assets/refresh-ccw-Bixqs6dz.js","assets/MeshPage-DGYv8IHR.js","assets/markdown-BxN4l9DE.js","assets/folder-DHzynzTC.js","assets/Pill-Dpb0OZxB.js","assets/api-C7pu_Aru.js","assets/Pairing-BuhVbyNU.js","assets/BackupsPage-C7FQ2DLV.js","assets/BrainStatusPage-IIn0Ufcf.js","assets/cloud-upload-RBqzNp3t.js","assets/BrainBrowserPage-DWmDha4V.js","assets/tabs-Q9rOz2uL.js","assets/SkillRegistryPage-GJcDC2PD.js","assets/corner-down-left-DusgzzkI.js","assets/tag-kY6Y-EYi.js","assets/SkillCompositionGraph-CVzFdDCZ.js","assets/SignalsPage-9RMRNAIt.js","assets/GuardsOverviewPage-3nURQaKi.js","assets/box-C_5urXbw.js","assets/ShellGuardPage-MUqtxJ3c.js","assets/SanitizerGuardPage-Dr_TIdvl.js","assets/ScheduleGuardPage-ED5ZN-wc.js","assets/SandboxGuardPage-B5sBsAM3.js","assets/WorkersListPage-Cj-R7WbZ.js","assets/DelegationsPage-C93JHZkX.js","assets/square-BOz_C5qq.js","assets/star-CkF1s_Xa.js","assets/WorkerLiveTail-WfoppFSb.js","assets/ModelRanksPage-DaKByZxq.js","assets/circle-x--B2BKH4R.js","assets/WorkerDetailPage-B_5gmtcO.js","assets/share-2-Da_vtMGy.js","assets/WorkerApprovalsCard-ore9enWj.js","assets/WorkerEditorPage-BdVkO0dj.js","assets/message-square-DS3HSgxP.js","assets/model-catalog-Cn8r6otb.js","assets/WorkerApprovalsPage-BzrxOctD.js","assets/WorkerCostDashboardPage-DZZrzIFA.js","assets/ModelLeaderboardPage-TWXixXQS.js","assets/ModelProvidersPage-Bryuhzzp.js","assets/MemoryLandingPage-BClOIAjh.js","assets/arrow-up-right-RRuYfAwZ.js","assets/use-memory-ChVIui7-.js","assets/memory-utils-B0WiuphN.js","assets/MemoryListPage-CD7dTJ6c.js","assets/MemoryDetailDrawer-BzR9JTNt.js","assets/pin-off-CPMgqeYV.js","assets/pin-C0Q-Achd.js","assets/memory-primitives-C7gBVkiY.js","assets/MemoryTable-B1nJtXoa.js","assets/MemoryOffersPage-BJi7VuVy.js","assets/users-Bsr8fkGR.js","assets/MemoryConsolidationPage-BxBOgRKY.js","assets/MemoryActivityPage-FmJja-G3.js","assets/MemoryVisualisationPage-MS_Hkrlz.js","assets/MemoryGraphCanvas-C1QtLEIq.js","assets/MemoryAboutPage-DPXH1c-Z.js","assets/MemoryEntityGraphPage-C4ZTGQF7.js","assets/TasksListPage-CoUEBKQM.js","assets/TaskEditDialog-CkXGM0xr.js","assets/TaskDetailPage-BxO7mb6P.js","assets/TaskOffersPage-Cv61jjJt.js","assets/TasksLandingPage-CLK7Y5Ki.js"])))=>i.map(i=>d[i]); -import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{d as n,f as r}from"./recharts-V3eOq3uM.js";import{i,n as a,o,r as s,t as c}from"./dist-CMymZiQ9.js";import{Et as l,Ft as u,H as d,Jt as f,K as p,L as m,Nt as h,P as g,R as _,Rt as v,U as y,V as b,an as x,at as S,bt as C,ct as ee,d as te,et as ne,ft as re,gt as ie,in as w,kt as T,m as ae,nn as oe,o as se,on as ce,pt as E,r as D,s as le,st as ue,ut as de}from"./client-CaIRceNv.js";import{a as O,c as k,i as A,n as fe,o as pe,r as me,s as he,t as ge}from"./dist-BH9Ihpd_.js";import{n as _e,t as j}from"./dist-vH0vUzvx.js";import{n as ve,t as ye}from"./dist-La6s7hND.js";import{t as be}from"./dist--QlMmz49.js";import{a as xe,i as Se,n as Ce,o as we,r as Te,t as Ee}from"./es2015-DXlrlJR9.js";import{t as De}from"./dist-fSR-p5Cs.js";import{a as Oe,i as ke,n as Ae,o as je,r as Me,t as Ne}from"./dist-B0VJ9haL.js";import{t as M}from"./createLucideIcon-WB390fY6.js";import{t as Pe}from"./sse-backoff-CEavbS-d.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Fe=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,ie());else{var t=n(l);t!==null&&ae(x,t.startTime-e)}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-tet&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ae(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ie():S=!1}}}var ie;if(typeof y==`function`)ie=function(){y(re)};else if(typeof MessageChannel<`u`){var w=new MessageChannel,T=w.port2;w.port1.onmessage=re,ie=function(){T.postMessage(null)}}else ie=function(){_(re,0)};function ae(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ae(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ie()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Ie=t(((e,t)=>{t.exports=Fe()})),Le=t((e=>{var t=Ie(),i=r(),a=n();function o(e){var t=`https://react.dev/errors/`+e;if(1de||(e.current=ue[de],ue[de]=null,de--)}function A(e,t){de++,ue[de]=e.current,e.current=t}var fe=O(null),pe=O(null),me=O(null),he=O(null);function ge(e,t){switch(A(me,t),A(pe,e),A(fe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}k(fe),A(fe,e)}function _e(){k(fe),k(pe),k(me)}function j(e){e.memoizedState!==null&&A(he,e);var t=fe.current,n=Hd(t,e.type);t!==n&&(A(pe,e),A(fe,n))}function ve(e){pe.current===e&&(k(fe),k(pe)),he.current===e&&(k(he),Qf._currentValue=le)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Se=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?xe(n):``}function we(e,t){switch(e.tag){case 26:case 27:case 5:return xe(e.type);case 16:return xe(`Lazy`);case 13:return e.child!==t&&t!==null?xe(`Suspense Fallback`):xe(`Suspense`);case 19:return xe(`SuspenseList`);case 0:case 15:return Ce(e.type,!1);case 11:return Ce(e.type.render,!1);case 1:return Ce(e.type,!0);case 31:return xe(`Activity`);default:return``}}function Te(e){try{var t=``,n=null;do t+=we(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var Ee=Object.prototype.hasOwnProperty,De=t.unstable_scheduleCallback,Oe=t.unstable_cancelCallback,ke=t.unstable_shouldYield,Ae=t.unstable_requestPaint,je=t.unstable_now,Me=t.unstable_getCurrentPriorityLevel,Ne=t.unstable_ImmediatePriority,M=t.unstable_UserBlockingPriority,Pe=t.unstable_NormalPriority,Fe=t.unstable_LowPriority,Le=t.unstable_IdlePriority,Re=t.log,N=t.unstable_setDisableYieldValue,ze=null,Be=null;function Ve(e){if(typeof Re==`function`&&N(e),Be&&typeof Be.setStrictMode==`function`)try{Be.setStrictMode(ze,e)}catch{}}var He=Math.clz32?Math.clz32:We,Ue=Math.log,P=Math.LN2;function We(e){return e>>>=0,e===0?32:31-(Ue(e)/P|0)|0}var Ge=256,Ke=262144,F=4194304;function qe(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Je(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=qe(n))):i=qe(o):i=qe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=qe(n))):i=qe(o)):i=qe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ye(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Xe(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ze(){var e=F;return F<<=1,!(F&62914560)&&(F=4194304),e}function Qe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function $e(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function et(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),pn=!1;if(fn)try{var mn={};Object.defineProperty(mn,"passive",{get:function(){pn=!0}}),window.addEventListener(`test`,mn,mn),window.removeEventListener(`test`,mn,mn)}catch{pn=!1}var hn=null,gn=null,_n=null;function vn(){if(_n)return _n;var e,t=gn,n=t.length,r,i=`value`in hn?hn.value:hn.textContent,a=i.length;for(e=0;e=Yn),Qn=` `,$n=!1;function er(e,t){switch(e){case`keyup`:return qn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function tr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var nr=!1;function rr(e,t){switch(e){case`compositionend`:return tr(t);case`keypress`:return t.which===32?($n=!0,Qn):null;case`textInput`:return e=t.data,e===Qn&&$n?null:e;default:return null}}function ir(e,t){if(nr)return e===`compositionend`||!Jn&&er(e,t)?(e=vn(),_n=gn=hn=null,nr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Er(n)}}function Or(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Or(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function kr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=zt(e.document)}return t}function Ar(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var jr=fn&&`documentMode`in document&&11>=document.documentMode,Mr=null,Nr=null,Pr=null,Fr=!1;function Ir(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Fr||Mr==null||Mr!==zt(r)||(r=Mr,`selectionStart`in r&&Ar(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Pr&&Tr(Pr,r)||(Pr=r,r=Ed(Nr,`onSelect`),0>=o,i-=o,Di=1<<32-He(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),R&&ki(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),R&&ki(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return R&&ki(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),R&&ki(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===v&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case g:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===v){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===re&&ka(l)===r.type){n(e,r.sibling),c=i(r,a.props),Ia(c,a),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}a.type===v?(c=mi(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=pi(a.type,a.key,a.props,null,e.mode,c),Ia(c,a),c.return=e,e=c)}return s(e);case _:a:{for(l=a.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=_i(a,e.mode,c),c.return=e,e=c}return s(e);case re:return a=ka(a),b(e,r,a,c)}if(ce(a))return h(e,r,a,c);if(ae(a)){if(l=ae(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),y(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,Fa(a),c);if(a.$$typeof===S)return b(e,r,ra(e,a),c);La(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=hi(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Pa=0;var i=b(e,t,n,r);return Na=null,i}catch(t){if(t===Ca||t===Ta)throw t;var a=li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var za=Ra(!0),Ba=Ra(!1),Va=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ua(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Wa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ga(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=oi(e),ai(e,null,n),t}return ni(e,r,t,n),oi(e)}function Ka(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,nt(e,n)}}function qa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ja=!1;function Ya(){if(Ja){var e=ma;if(e!==null)throw e}}function Xa(e,t,n,r){Ja=!1;var i=e.updateQueue;Va=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(J&f)===f:(r&f)===f){f!==0&&f===pa&&(Ja=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Va=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Kl|=o,e.lanes=o,e.memoizedState=d}}function Za(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function Qa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=E.T,s={};E.T=s,Ls(e,!1,t,n);try{var c=i(),l=E.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Is(e,t,_a(c,r),mu(e)):Is(e,t,r,mu(e))}catch(n){Is(e,t,{then:function(){},status:`rejected`,reason:n},mu())}finally{D.p=a,o!==null&&s.types!==null&&(o.types=s.types),E.T=o}}function Es(){}function Ds(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Os(e).queue;Ts(e,i,t,le,n===null?Es:function(){return ks(e),n(r)})}function Os(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:le,baseState:le,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:le},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ks(e){var t=Os(e);t.next===null&&(t=e.alternate.memoizedState),Is(e,t.next.queue,{},mu())}function As(){return na(Qf)}function js(){return No().memoizedState}function Ms(){return No().memoizedState}function Ns(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=mu();e=Wa(n);var r=Ga(t,e,n);r!==null&&(gu(r,t,n),Ka(r,t,n)),t={cache:la()},e.payload=t;return}t=t.return}}function Ps(e,t,n){var r=mu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Rs(e)?zs(t,n):(n=ri(e,t,n,r),n!==null&&(gu(n,e,r),Bs(n,t,r)))}function Fs(e,t,n){Is(e,t,n,mu())}function Is(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rs(e))zs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,wr(s,o))return ni(e,t,i,0),K===null&&ti(),!1}catch{}if(n=ri(e,t,i,r),n!==null)return gu(n,e,r),Bs(n,t,r),!0}return!1}function Ls(e,t,n,r){if(r={lane:2,revertLane:dd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Rs(e)){if(t)throw Error(o(479))}else t=ri(e,n,r,2),t!==null&&gu(t,e,2)}function Rs(e){var t=e.alternate;return e===z||t!==null&&t===z}function zs(e,t){_o=go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Bs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,nt(e,n)}}var Vs={readContext:na,use:Io,useCallback:Co,useContext:Co,useEffect:Co,useImperativeHandle:Co,useLayoutEffect:Co,useInsertionEffect:Co,useMemo:Co,useReducer:Co,useRef:Co,useState:Co,useDebugValue:Co,useDeferredValue:Co,useTransition:Co,useSyncExternalStore:Co,useId:Co,useHostTransitionStatus:Co,useFormState:Co,useActionState:Co,useOptimistic:Co,useMemoCache:Co,useCacheRefresh:Co};Vs.useEffectEvent=Co;var Hs={readContext:na,use:Io,useCallback:function(e,t){return Mo().memoizedState=[e,t===void 0?null:t],e},useContext:na,useEffect:fs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),us(4194308,4,vs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return us(4194308,4,e,t)},useInsertionEffect:function(e,t){us(4,2,e,t)},useMemo:function(e,t){var n=Mo();t=t===void 0?null:t;var r=e();if(vo){Ve(!0);try{e()}finally{Ve(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Mo();if(n!==void 0){var i=n(t);if(vo){Ve(!0);try{n(t)}finally{Ve(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ps.bind(null,z,e),[r.memoizedState,e]},useRef:function(e){var t=Mo();return e={current:e},t.memoizedState=e},useState:function(e){e=Jo(e);var t=e.queue,n=Fs.bind(null,z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:bs,useDeferredValue:function(e,t){return Cs(Mo(),e,t)},useTransition:function(){var e=Jo(!1);return e=Ts.bind(null,z,e.queue,!0,!1),Mo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=z,i=Mo();if(R){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),K===null)throw Error(o(349));J&127||Uo(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,fs(Go.bind(null,r,a,e),[e]),r.flags|=2048,cs(9,{destroy:void 0},Wo.bind(null,r,a,n,t),null),n},useId:function(){var e=Mo(),t=K.identifierPrefix;if(R){var n=Oi,r=Di;n=(r&~(1<<32-He(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=yo++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[lt]=t,a[ut]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(Pd(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Pc(t)}}return U(t),Fc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Pc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=me.current,Hi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Pi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[lt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Md(e.nodeValue,n)),e||zi(t,!0)}else e=Bd(e).createTextNode(r),e[lt]=t,t.stateNode=e}return U(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Hi(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[lt]=t}else Ui(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;U(t),e=!1}else n=Wi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(uo(t),t):(uo(t),null);if(t.flags&128)throw Error(o(558))}return U(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Hi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[lt]=t}else Ui(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;U(t),i=!1}else i=Wi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(uo(t),t):(uo(t),null)}return uo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Lc(t,t.updateQueue),U(t),null);case 4:return _e(),e===null&&Sd(t.stateNode.containerInfo),U(t),null;case 10:return Xi(t.type),U(t),null;case 19:if(k(fo),r=t.memoizedState,r===null)return U(t),null;if(i=(t.flags&128)!=0,a=r.rendering,a===null)if(i)Rc(r,!1);else{if(Gl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=po(e),a!==null){for(t.flags|=128,Rc(r,!1),e=a.updateQueue,t.updateQueue=e,Lc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)fi(n,e),n=n.sibling;return A(fo,fo.current&1|2),R&&ki(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&je()>nu&&(t.flags|=128,i=!0,Rc(r,!1),t.lanes=4194304)}else{if(!i)if(e=po(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Lc(t,e),Rc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!R)return U(t),null}else 2*je()-r.renderingStartTime>nu&&n!==536870912&&(t.flags|=128,i=!0,Rc(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(U(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=je(),e.sibling=null,n=fo.current,A(fo,i?n&1|2:n&1),R&&ki(t,r.treeForkCount),e);case 22:case 23:return uo(t),ro(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(U(t),t.subtreeFlags&6&&(t.flags|=8192)):U(t),n=t.updateQueue,n!==null&&Lc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&k(ya),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Xi(ca),U(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Bc(e,t){switch(Mi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Xi(ca),_e(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ve(t),null;case 31:if(t.memoizedState!==null){if(uo(t),t.alternate===null)throw Error(o(340));Ui()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(uo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Ui()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return k(fo),null;case 4:return _e(),null;case 10:return Xi(t.type),null;case 22:case 23:return uo(t),ro(),e!==null&&k(ya),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Xi(ca),null;case 25:return null;default:return null}}function Vc(e,t){switch(Mi(t),t.tag){case 3:Xi(ca),_e();break;case 26:case 27:case 5:ve(t);break;case 4:_e();break;case 31:t.memoizedState!==null&&uo(t);break;case 13:uo(t);break;case 19:k(fo);break;case 10:Xi(t.type);break;case 22:case 23:uo(t),ro(),e!==null&&k(ya);break;case 24:Xi(ca)}}function Hc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Uc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function Wc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Qa(t,n)}catch(t){Z(e,e.return,t)}}}function Gc(e,t,n){n.props=Ys(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Kc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function qc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}function Jc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Z(e,e.return,t)}}function Yc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[ut]=t}catch(t){Z(e,e.return,t)}}function Xc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Zc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Xc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=nn));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Qc(e,t,n),e=e.sibling;e!==null;)Qc(e,t,n),e=e.sibling}function $c(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for($c(e,t,n),e=e.sibling;e!==null;)$c(e,t,n),e=e.sibling}function el(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[lt]=e,t[ut]=n}catch(t){Z(e,e.return,t)}}var tl=!1,nl=!1,rl=!1,il=typeof WeakSet==`function`?WeakSet:Set,al=null;function ol(e,t){if(e=e.containerInfo,Rd=sp,e=kr(e),Ar(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==a||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===a&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,al=t;al!==null;)if(t=al,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,al=e;else for(;al!==null;){switch(t=al,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(a,r,n),a[lt]=e,St(a),r=a;break a;case`link`:var s=Vf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=Dr(s,h),v=Dr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,E.T=null,n=uu,uu=null;var a=ou,s=cu;if(au=0,su=ou=null,cu=0,G&6)throw Error(o(331));var c=G;if(G|=4,Fl(a.current),Ol(a,a.current,s,n),G=c,id(0,!1),Be&&typeof Be.onPostCommitFiberRoot==`function`)try{Be.onPostCommitFiberRoot(ze,a)}catch{}return!0}finally{D.p=i,E.T=r,Vu(e,t)}}function Wu(e,t,n){t=yi(n,t),t=tc(e.stateNode,t,2),e=Ga(e,t,2),e!==null&&($e(e,2),rd(e))}function Z(e,t,n){if(e.tag===3)Wu(e,e,n);else for(;t!==null;){if(t.tag===3){Wu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(iu===null||!iu.has(r))){e=yi(n,e),n=nc(2),r=Ga(t,n,2),r!==null&&(rc(n,r,t,e),$e(r,2),rd(r));break}}t=t.return}}function Gu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new zl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ul=!0,i.add(n),e=Ku.bind(null,e,t,n),t.then(e,e))}function Ku(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,K===e&&(J&n)===n&&(Gl===4||Gl===3&&(J&62914560)===J&&300>je()-eu?!(G&2)&&Cu(e,0):Jl|=n,Xl===J&&(Xl=0)),rd(e)}function qu(e,t){t===0&&(t=Ze()),e=ii(e,t),e!==null&&($e(e,t),rd(e))}function Ju(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qu(e,n)}function Yu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),qu(e,n)}function Xu(e,t){return De(e,t)}var Zu=null,Qu=null,$u=!1,ed=!1,td=!1,nd=0;function rd(e){e!==Qu&&e.next===null&&(Qu===null?Zu=Qu=e:Qu=Qu.next=e),ed=!0,$u||($u=!0,ud())}function id(e,t){if(!td&&ed){td=!0;do for(var n=!1,r=Zu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-He(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ld(r,a))}else a=J,a=Je(r,r===K?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ye(r,a)||(n=!0,ld(r,a));r=r.next}while(n);td=!1}}function ad(){od()}function od(){ed=$u=!1;var e=0;nd!==0&&Gd()&&(e=nd);for(var t=je(),n=null,r=Zu;r!==null;){var i=r.next,a=sd(r,t);a===0?(r.next=null,n===null?Zu=i:n.next=i,i===null&&(Qu=n)):(n=r,(e!==0||a&3)&&(ed=!0)),r=i}au!==0&&au!==5||id(e,!1),nd!==0&&(nd=0)}function sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Vt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),St(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Vt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Vt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Vt(n.imageSizes)+`"]`)):i+=`[href="`+Vt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),St(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Vt(r)+`"][href="`+Vt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),St(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=xt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);St(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=xt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),St(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=xt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),St(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=me.current)?gf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=xt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var a=xt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(jf(e)))&&!a._p&&(s.instance=a,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),a||Nf(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=xt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Af(e){return`href="`+Vt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),St(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Vt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Vt(n.href)+`"]`);if(r)return t.instance=r,St(r),r;var i=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),St(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var a=e.querySelector(jf(i));if(a)return t.state.loading|=4,t.instance=a,St(a),a;r=Mf(n),(i=mf.get(i))&&Rf(r,i),a=(e.ownerDocument||e).createElement(`link`),St(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(a,`link`,r),t.state.loading|=4,Lf(a,n.precedence,e),t.instance=a;case`script`:return a=Pf(n.src),(i=e.querySelector(Ff(a)))?(t.instance=i,St(i),i):(r=n,(i=mf.get(a))&&(r=m({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),St(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,St(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),St(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Le()})),N=e(r(),1),ze=Re(),Be=e(n(),1),Ve=`modulepreload`,He=function(e){return`/`+e},Ue={},P=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=He(t,n),t in Ue)return;Ue[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Ve,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},We=`popstate`;function Ge(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Ke(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Xe(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Ze(t)}return $e(t,n,null,e)}function F(e,t){if(e===!1||e==null)throw Error(t)}function qe(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Je(){return Math.random().toString(36).substring(2,10)}function Ye(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Xe(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?Qe(t):t,state:n,key:t&&t.key||r||Je(),mask:i}}function Ze({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function Qe(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function $e(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=Ge(e)?e:Xe(h.location,e,t);n&&n(r,e),l=u()+1;let d=Ye(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=Ge(e)?e:Xe(h.location,e,t);n&&n(r,e),l=u();let i=Ye(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return et(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(We,d),c=e,()=>{i.removeEventListener(We,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function et(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),F(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Ze(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}function tt(e,t,n=`/`){return nt(e,t,n,!1)}function nt(e,t,n,r,i){let a=xt((typeof t==`string`?Qe(t):t).pathname||`/`,n);if(a==null)return null;let o=i??it(e),s=null,c=bt(a);for(let e=0;s==null&&e{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;F(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=At([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(F(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),at(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:ht(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ot(e.path))a(e,t,!0,n)}),t}function ot(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ot(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function st(e){e.sort((e,t)=>e.score===t.score?gt(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ct=/^:[\w-]+$/,lt=3,ut=2,dt=1,ft=10,pt=-2,mt=e=>e===`*`;function ht(e,t){let n=e.split(`/`),r=n.length;return n.some(mt)&&(r+=pt),t&&(r+=ut),n.filter(e=>!mt(e)).reduce((e,t)=>e+(ct.test(t)?lt:t===``?dt:ft),r)}function gt(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function _t(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function yt(e,t=!1,n=!0){qe(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function bt(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return qe(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function xt(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var St=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Ct(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?Qe(e):e,a;return n?(n=kt(n),a=n.startsWith(`/`)?wt(n.substring(1),`/`):wt(n,t)):a=t,{pathname:a,search:Nt(r),hash:Pt(i)}}function wt(e,t){let n=jt(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Tt(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Et(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Dt(e){let t=Et(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Ot(e,t,n,r=!1){let i;typeof e==`string`?i=Qe(e):(i={...e},F(!i.pathname||!i.pathname.includes(`?`),Tt(`?`,`pathname`,`search`,i)),F(!i.pathname||!i.pathname.includes(`#`),Tt(`#`,`pathname`,`hash`,i)),F(!i.search||!i.search.includes(`#`),Tt(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Ct(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var kt=e=>e.replace(/\/\/+/g,`/`),At=e=>kt(e.join(`/`)),jt=e=>e.replace(/\/+$/,``),Mt=e=>jt(e).replace(/^\/*/,`/`),Nt=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Pt=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ft=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function It(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Lt(e){return At(e.map(e=>e.route.path).filter(Boolean))||`/`}var Rt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function zt(e,t){let n=e;if(typeof n!=`string`||!St.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Rt)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=xt(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{qe(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Bt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Bt);var Vt=[`GET`,...Bt];new Set(Vt);var Ht=N.createContext(null);Ht.displayName=`DataRouter`;var Ut=N.createContext(null);Ut.displayName=`DataRouterState`;var Wt=N.createContext(!1);function Gt(){return N.useContext(Wt)}var Kt=N.createContext({isTransitioning:!1});Kt.displayName=`ViewTransition`;var qt=N.createContext(new Map);qt.displayName=`Fetchers`;var Jt=N.createContext(null);Jt.displayName=`Await`;var Yt=N.createContext(null);Yt.displayName=`Navigation`;var Xt=N.createContext(null);Xt.displayName=`Location`;var Zt=N.createContext({outlet:null,matches:[],isDataRoute:!1});Zt.displayName=`Route`;var Qt=N.createContext(null);Qt.displayName=`RouteError`;var $t=`REACT_ROUTER_ERROR`,en=`REDIRECT`,tn=`ROUTE_ERROR_RESPONSE`;function nn(e){if(e.startsWith(`${$t}:${en}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function rn(e){if(e.startsWith(`${$t}:${tn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ft(t.status,t.statusText,t.data)}catch{}}function an(e,{relative:t}={}){F(on(),`useHref() may be used only in the context of a component.`);let{basename:n,navigator:r}=N.useContext(Yt),{hash:i,pathname:a,search:o}=pn(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:At([n,a])),r.createHref({pathname:s,search:o,hash:i})}function on(){return N.useContext(Xt)!=null}function sn(){return F(on(),`useLocation() may be used only in the context of a component.`),N.useContext(Xt).location}var cn=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function ln(e){N.useContext(Yt).static||N.useLayoutEffect(e)}function un(){let{isDataRoute:e}=N.useContext(Zt);return e?Mn():dn()}function dn(){F(on(),`useNavigate() may be used only in the context of a component.`);let e=N.useContext(Ht),{basename:t,navigator:n}=N.useContext(Yt),{matches:r}=N.useContext(Zt),{pathname:i}=sn(),a=JSON.stringify(Dt(r)),o=N.useRef(!1);return ln(()=>{o.current=!0}),N.useCallback((r,s={})=>{if(qe(o.current,cn),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Ot(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:At([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}N.createContext(null);function fn(){let{matches:e}=N.useContext(Zt);return e[e.length-1]?.params??{}}function pn(e,{relative:t}={}){let{matches:n}=N.useContext(Zt),{pathname:r}=sn(),i=JSON.stringify(Dt(n));return N.useMemo(()=>Ot(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function mn(e,t){return hn(e,t)}function hn(e,t,n){F(on(),`useRoutes() may be used only in the context of a component.`);let{navigator:r}=N.useContext(Yt),{matches:i}=N.useContext(Zt),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;Pn(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant (or called \`useRoutes()\`) at "${s}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. - -Please change the parent to .`)}let u=sn(),d;if(t){let e=typeof t==`string`?Qe(t):t;F(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):tt(e,{pathname:p});qe(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),qe(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let h=Sn(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:At([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:At([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?N.createElement(Xt.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function gn(){let e=jn(),t=It(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=N.createElement(N.Fragment,null,N.createElement(`p`,null,`💿 Hey developer 👋`),N.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,N.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,N.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),N.createElement(N.Fragment,null,N.createElement(`h2`,null,`Unexpected Application Error!`),N.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?N.createElement(`pre`,{style:i},n):null,o)}var _n=N.createElement(gn,null),vn=class extends N.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=rn(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:N.createElement(Zt.Provider,{value:this.props.routeContext},N.createElement(Qt.Provider,{value:e,children:this.props.component}));return this.context?N.createElement(bn,{error:e},t):t}};vn.contextType=Wt;var yn=new WeakMap;function bn({children:e,error:t}){let{basename:n}=N.useContext(Yt);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=nn(t.digest);if(e){let r=yn.get(t);if(r)throw r;let i=zt(e.location,n);if(Rt&&!yn.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw yn.set(t,n),n}return N.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function xn({routeContext:e,match:t,children:n}){let r=N.useContext(Ht);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),N.createElement(Zt.Provider,{value:e},n)}function Sn(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);F(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Lt(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||_n,o&&(s<0&&c===0?(Pn(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?N.createElement(n.route.Component,null):n.route.element?n.route.element:e,N.createElement(xn,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?N.createElement(vn,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function Cn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wn(e){let t=N.useContext(Ht);return F(t,Cn(e)),t}function Tn(e){let t=N.useContext(Ut);return F(t,Cn(e)),t}function En(e){let t=N.useContext(Zt);return F(t,Cn(e)),t}function Dn(e){let t=En(e),n=t.matches[t.matches.length-1];return F(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function On(){return Dn(`useRouteId`)}function kn(){let e=Tn(`useNavigation`);return N.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function An(){let{matches:e,loaderData:t}=Tn(`useMatches`);return N.useMemo(()=>e.map(e=>rt(e,t)),[e,t])}function jn(){let e=N.useContext(Qt),t=Tn(`useRouteError`),n=Dn(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Mn(){let{router:e}=wn(`useNavigate`),t=Dn(`useNavigate`),n=N.useRef(!1);return ln(()=>{n.current=!0}),N.useCallback(async(r,i={})=>{qe(n.current,cn),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Nn={};function Pn(e,t,n){!t&&!Nn[e]&&(Nn[e]=!0,qe(!1,n))}N.memo(Fn);function Fn({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return hn(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function In({to:e,replace:t,state:n,relative:r}){F(on(),` may be used only in the context of a component.`);let{static:i}=N.useContext(Yt);qe(!i,` must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.`);let{matches:a}=N.useContext(Zt),{pathname:o}=sn(),s=un(),c=Ot(e,Dt(a),o,r===`path`),l=JSON.stringify(c);return N.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function I(e){F(!1,`A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .`)}function Ln({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){F(!on(),`You cannot render a inside another . You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=N.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=Qe(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=N.useMemo(()=>{let e=xt(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return qe(h!=null,` is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the won't render anything.`),h==null?null:N.createElement(Yt.Provider,{value:c},N.createElement(Xt.Provider,{children:t,value:h}))}function Rn({children:e,location:t}){return mn(zn(e),t)}N.Component;function zn(e,t=[]){let n=[];return N.Children.forEach(e,(e,r)=>{if(!N.isValidElement(e))return;let i=[...t,r];if(e.type===N.Fragment){n.push.apply(n,zn(e.props.children,i));return}F(e.type===I,`[${typeof e.type==`string`?e.type:e.type.name}] is not a component. All component children of must be a or `),F(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=zn(e.props.children,i)),n.push(a)}),n}var Bn=`get`,Vn=`application/x-www-form-urlencoded`;function Hn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Un(e){return Hn(e)&&e.tagName.toLowerCase()===`button`}function Wn(e){return Hn(e)&&e.tagName.toLowerCase()===`form`}function Gn(e){return Hn(e)&&e.tagName.toLowerCase()===`input`}function Kn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function qn(e,t){return e.button===0&&(!t||t===`_self`)&&!Kn(e)}function Jn(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Yn(e,t){let n=Jn(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Xn=null;function Zn(){if(Xn===null)try{new FormData(document.createElement(`form`),0),Xn=!1}catch{Xn=!0}return Xn}var Qn=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function $n(e){return e!=null&&!Qn.has(e)?(qe(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Vn}"`),null):e}function er(e,t){let n,r,i,a,o;if(Wn(e)){let o=e.getAttribute(`action`);r=o?xt(o,t):null,n=e.getAttribute(`method`)||Bn,i=$n(e.getAttribute(`enctype`))||Vn,a=new FormData(e)}else if(Un(e)||Gn(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a - +
+
+ +

Workspace Routing

+

+ Route rules decide which server and credential handle matching tool + calls in each workspace. Rules are evaluated by priority; first + match wins. +

+
+
+ + + +
+
{loading && !routes && (
@@ -288,13 +305,6 @@ export function RoutesPage() {
)} -
- -
- setDialogOpen(false)} diff --git a/web/src/pages/config/WorkspacesPage.tsx b/web/src/pages/config/WorkspacesPage.tsx index 6a34839..9693fa0 100644 --- a/web/src/pages/config/WorkspacesPage.tsx +++ b/web/src/pages/config/WorkspacesPage.tsx @@ -160,9 +160,9 @@ export function WorkspacesPage() {

Workspace Settings

@@ -247,7 +247,7 @@ export function WorkspacesPage() { data-testid={`workspace-routes-${w.id}`} asChild > - +