local-operator-ui 0.45.3 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +5908 -3125
- package/out/preload/index.js +30 -1
- package/out/renderer/assets/{_basePickBy-D2mJrcmc.js → _basePickBy-Cj0fEIOH.js} +1 -1
- package/out/renderer/assets/{_baseUniq-CxwrVbCU.js → _baseUniq-Cz-33liX.js} +1 -1
- package/out/renderer/assets/addressOverlayList-AR8aOeNw.js +1 -0
- package/out/renderer/assets/{addressOverlayList-B7X6o95l.css → addressOverlayList-Csi0NFuY.css} +1 -1
- package/out/renderer/assets/agent-details-page-B_RY1sJD.js +6 -0
- package/out/renderer/assets/agent-hub-page-PLff8S61.js +6 -0
- package/out/renderer/assets/agents-page-DjxNEBlZ.js +14 -0
- package/out/renderer/assets/{approvalsOverlay-CX3DxhSv.css → approvalsOverlay-BgfK3IlB.css} +1 -1
- package/out/renderer/assets/approvalsOverlay-D8l6Tw61.js +1 -0
- package/out/renderer/assets/{arc-Bm2OoQ4-.js → arc-BoGkGb9O.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-BoPMn2Mo.js → architectureDiagram-IEHRJDOE-DIk417XV.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-DxKZonYG.js → blockDiagram-JOT3LUYC-CnvuT-yC.js} +1 -1
- package/out/renderer/assets/{book-open-ByRqB3UN.js → book-open-C3_WLj7w.js} +1 -1
- package/out/renderer/assets/browser-page-CWu1j6RM.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-DwGQwTu8.js → browser-webauthn-prompt-Du6obwHK.js} +1 -1
- package/out/renderer/assets/{building-2-Dy6C7045.js → building-2-CLOF900G.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DgSuLDm0.js → c4Diagram-VJAJSXHY-BVhES_2B.js} +1 -1
- package/out/renderer/assets/channel-CJkPlu3m.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-Bb4vaZIp.js → chunk-4BMEZGHF-DgE_mqR9.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-p7_pHJVS.js → chunk-A2AXSNBT-D08EB0eQ.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-ClZWEudC.js → chunk-AEK57VVT-BDtiHBHO.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-BtRUAAer.js → chunk-D6G4REZN-B7aVznI0.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-B6FiCA8P.js → chunk-RZ5BOZE2-BKygjVB2.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-iubhBv37.js → chunk-XZIHB7SX-WCJjYEMM.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-qpQhrrhz.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-qpQhrrhz.js +1 -0
- package/out/renderer/assets/clone-Dg8l-jy4.js +1 -0
- package/out/renderer/assets/{console-mirror-DtPKRnoQ.js → console-mirror-DeqlFqxb.js} +1 -1
- package/out/renderer/assets/{consoleCapture-C497gKx7.js → consoleCapture-CQlGEG3v.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-CczYmRpD.js → conversation-input-sync-Cqe7zy7f.js} +261 -255
- package/out/renderer/assets/{dagre-OKDRZEBW-CMCYOxv5.js → dagre-OKDRZEBW-CVWKP4bn.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-GbrQ1DgQ.js → diagram-SSKATNLV-BC-K6ofw.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-fTF3Mw0c.js → diagram-VNBRO52H-Cb3_NzRb.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-vp92kU8p.js → erDiagram-Q7BY3M3F-BbKSqMZd.js} +1 -1
- package/out/renderer/assets/{error-boundary-BgUrwH7u.js → error-boundary-D9GOvskD.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-DQDsWb6f.js → flowDiagram-4HSFHLVR-Cpli-q1Q.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-BvG5lCVD.js → ganttDiagram-APWFNJXF-i6JdfeW8.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BtRj6YUh.js → gitGraphDiagram-7IBYFJ6S-CPPfXcNo.js} +1 -1
- package/out/renderer/assets/{graph-D5b7-Ozr.js → graph-DN2ItNYX.js} +1 -1
- package/out/renderer/assets/{hash-CrEjZX-2.js → hash-BIJpkSWf.js} +1 -1
- package/out/renderer/assets/{heart-8rDtUc1Z.js → heart-D2NQaIZG.js} +1 -1
- package/out/renderer/assets/index-AFJQ1QjL.js +821 -0
- package/out/renderer/assets/index-B64TRZpD.css +1 -0
- package/out/renderer/assets/{index-DEnBt0Qi.js → index-BMMKLQIt.js} +1 -1
- package/out/renderer/assets/{index-BVf3_vkI.js → index-Cc73tz3D.js} +1 -1
- package/out/renderer/assets/{index-BQ-anM-O.js → index-CcuBo9nT.js} +1 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-DhvQOOVe.js +2 -0
- package/out/renderer/assets/{installer-CDeSFlYF.js → installer-DFfS2SVK.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-DVqe6k_G.js → journeyDiagram-U35MCT3I-BRkHsPvh.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-xs0tGUWm.js → kanban-definition-NDS4AKOZ-CMiqan9t.js} +1 -1
- package/out/renderer/assets/{layout-BXhptE7W.js → layout-Z7uXh1qn.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-CAu2ymNc.js → legacy-agents-page-BHBgHvV3.js} +8 -8
- package/out/renderer/assets/{library-page-Z3gULDyp.js → library-page-EGjIy1i-.js} +3 -3
- package/out/renderer/assets/{mermaid.core-Dkk1pdj8.js → mermaid.core-IQK_8xGt.js} +5 -5
- package/out/renderer/assets/{mesh-page-DPKNd40g.js → mesh-page-Bc9ilTD0.js} +1 -1
- package/out/renderer/assets/messages-BHHYgmiq.js +27 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-CFGVlmoc.js → mindmap-definition-ALO5MXBD-CI_JdH5p.js} +1 -1
- package/out/renderer/assets/{mini-AvkMQUn7.js → mini-gBq8umUW.js} +1 -1
- package/out/renderer/assets/{notebook-pen-LANPWMJy.js → notebook-pen-DRDufegP.js} +1 -1
- package/out/renderer/assets/{notifications-page-CylLvSdk.js → notifications-page-Bu5qf7Fp.js} +1 -1
- package/out/renderer/assets/{org-access-MX0xjFWR.js → org-access-Ds8FeuE9.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-BtvmKKbu.js → org-surface-gate-DBqmiY3f.js} +1 -1
- package/out/renderer/assets/{page-header-FV16p5uV.js → page-header-CcfnNa21.js} +1 -1
- package/out/renderer/assets/path-utils-CEoNIn5y.js +62 -0
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BSjrs9cA.js → pieDiagram-IB7DONF6-CZPP2edW.js} +1 -1
- package/out/renderer/assets/{project-markdown-DMOUmU9x.js → project-markdown-CD_uBmTI.js} +1 -1
- package/out/renderer/assets/{projects-page-BR99VLsd.js → projects-page-DFUD33vh.js} +5 -5
- package/out/renderer/assets/{publication-validation-BRAIkrkM.js → publication-validation-DGR8lqu1.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-CImVcS_C.js → quadrantDiagram-7GDLP6J5-CJeiyx_t.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-DoLVtIkR.js → radar-MK3ICKWK-lTUr66ub.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-DNj7RTGb.js → radient-auth-buttons-DkoyJ9mK.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CTGcN8fW.js → requirementDiagram-KVF5MWMF-BZyNKL7q.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-BW8957-i.js → sankeyDiagram-QLVOVGJD-YGTZYJF4.js} +1 -1
- package/out/renderer/assets/{schedules-page-CUdpU-8C.js → schedules-page-C4TSKd4h.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-DrVKNinq.js → sequenceDiagram-X6HHIX6F-BA4KFDyE.js} +1 -1
- package/out/renderer/assets/{settings-page-BMHScWEQ.js → settings-page-BP9Gt9PN.js} +1 -1
- package/out/renderer/assets/{smartart-mqgXLYJa.js → smartart-MrgQ4iBs.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-DSx047Sl.js → stateDiagram-DGXRK772-DxbUUQKF.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BcSdZSDe.js +1 -0
- package/out/renderer/assets/team-bridge-page-Y8GmEvgr.js +21 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-Crl7bGz-.js → timeline-definition-BDJGKUSR-BsEl_rbb.js} +1 -1
- package/out/renderer/assets/{use-default-on-banner-5Do2jUFB.js → use-default-on-banner-8zeoWhwA.js} +1 -1
- package/out/renderer/assets/use-download-agent-mutation-A5L-m_C-.js +56 -0
- package/out/renderer/assets/{use-session-snapshot-BKrw3TC-.js → use-session-snapshot-DQWB2js_.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DS7OvQRJ.js → xychartDiagram-VJFVF3MP-uv2av9fE.js} +1 -1
- package/out/renderer/browser-address-overlay-list.html +2 -2
- package/out/renderer/browser-approvals-overlay.html +23 -21
- package/out/renderer/console-capture.html +6 -6
- package/out/renderer/index.html +8 -8
- package/out/renderer/installer.html +5 -5
- package/out/renderer/mini.html +8 -8
- package/package.json +2 -2
- package/out/renderer/assets/addressOverlayList-SGt8bawf.js +0 -1
- package/out/renderer/assets/agent-details-page-DW2BcdCd.js +0 -6
- package/out/renderer/assets/agent-hub-page-DtelG6Z1.js +0 -6
- package/out/renderer/assets/agents-page-BEpaWqiq.js +0 -14
- package/out/renderer/assets/approvalsOverlay-eLrF8rTc.js +0 -1
- package/out/renderer/assets/browser-page-CUGb_34H.js +0 -1
- package/out/renderer/assets/channel-WrJnktqu.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-kOcXvj0Y.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-kOcXvj0Y.js +0 -1
- package/out/renderer/assets/clone-BxCrdsII.js +0 -1
- package/out/renderer/assets/index-D-WE-3AE.js +0 -820
- package/out/renderer/assets/index-N87yPCeX.css +0 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-QGroqdpX.js +0 -2
- package/out/renderer/assets/messages-CSKtFcP6.js +0 -27
- package/out/renderer/assets/path-utils-CyEhREK0.js +0 -58
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BVcdQug2.js +0 -1
- package/out/renderer/assets/team-bridge-page-_zokvRE7.js +0 -21
- package/out/renderer/assets/use-download-agent-mutation-BuozrL1A.js +0 -56
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-BHBgHvV3.js","./index-BMMKLQIt.js","./messages-BHHYgmiq.js","./index-B64TRZpD.css","./page-header-CcfnNa21.js","./error-boundary-D9GOvskD.js","./index-AFJQ1QjL.js","./path-utils-CEoNIn5y.js","./conversation-input-sync-Cqe7zy7f.js","./conversation-input-sync-Dp97JwKx.css","./console-mirror-DeqlFqxb.js","./console-mirror-DOrYoP_4.css","./index-DHKnfVbX.css","./notebook-pen-DRDufegP.js","./org-access-Ds8FeuE9.js","./org-surface-gate-DBqmiY3f.js","./radient-auth-buttons-DkoyJ9mK.js","./publication-validation-DGR8lqu1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bQ as vn,aj as _n,bR as Qe,bS as Ts,bT as Dt,bU as Nn,bV as jt,aZ as Ne,aa as wn,ab as Sn,ac as En,ad as Cn,ba as tt,aA as $s,bh as Ge,W as rt,b9 as Ot,aK as Ds,a7 as Rn,bW as In,bX as Ln,bY as An,bZ as Os,b_ as Fn,b$ as Tn,c0 as ts,c1 as $n,c2 as Dn,c3 as On,bJ as Pn,c4 as Mn}from"./conversation-input-sync-Cqe7zy7f.js";import{r,j as t,c as W}from"./index-BMMKLQIt.js";import{aU as Bn,aV as qn,D as Un,aQ as Pt,x as zn,z as Hn,O as Ps,s as Ms,aW as Kn,aO as ft,aX as Wn,aN as Rt,aY as It,aZ as Vn,a_ as Gn,a$ as ss,aR as Bs,b0 as Yn,Q as Mt,aM as ot,b1 as qs,b2 as Jn,b3 as Qn,t as Zn,A as Xn}from"./index-AFJQ1QjL.js";import{y as ct,q as Bt,a as gt,c as ee,i as ht,a3 as ea,a4 as ta,u as pt,a5 as sa,d as le,h as Be,G as ut,r as na,a6 as aa,B as qt,a2 as ia,A as la}from"./path-utils-CEoNIn5y.js";import{c as ra,u as Z,B as C,l as oa,J as ca,g as Me,j as ke,A as pe,a as xe,x as je,K as qe,Q as st,R as nt,U as at,V as it,W as Ie,Y as xt,Z as dt,D as Us,d as zs,e as Hs,f as Ks,T as Lt,o as Ut,p as zt,y as Ht,q as Kt,z as Wt,i as ua,F as Vt,_ as da,$ as yt,a0 as vt,a1 as Te,a2 as _e,a3 as _t,a4 as ve,M as ma,N as fa,O as ga}from"./error-boundary-D9GOvskD.js";import{t as s,a as ha}from"./messages-BHHYgmiq.js";import{k as pa,x as Ws,c as xa,S as Vs,l as ba,n as Nt,H as ka,p as ja,o as ya}from"./org-access-Ds8FeuE9.js";import{P as va}from"./project-markdown-CD_uBmTI.js";import"./console-mirror-DeqlFqxb.js";/**
|
|
3
|
+
* @license lucide-react v0.507.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const _a=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],Na=ra("log-in",_a),wa=[],Ve="config-composer-note",ns=()=>s("ui.agents.config.disabled_gate"),Sa=["ui.agents.config.examples.reads_code","ui.agents.config.examples.add_twice","ui.agents.config.examples.team_shipping"],Ea={idle:"bg-ink-dim",running:"bg-accent",stopping:"bg-warning",done:"bg-success",stopped:"bg-ink-muted",error:"bg-danger"};function Ca({status:e,pulse:n}){return t.jsx("span",{"aria-hidden":"true",className:W("size-2 shrink-0 rounded-full",Ea[e]??"bg-ink-dim",n&&"animate-pulse")})}function Ra({run:e}){return Z(),e.activity.length===0?t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.config.activity.empty")}):t.jsx("ul",{className:"space-y-1",children:e.activity.map((n,a)=>t.jsxs("li",{className:"flex items-baseline gap-2 text-body-sm",children:[t.jsx("span",{className:"text-ink-dim tabular-nums",children:new Date(n.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),t.jsx("span",{className:"text-ink",children:n.verb})]},`${n.ts}:${n.verb}:${a}`))})}const as="-mr-2",Ia="max-h-[clamp(3.5rem,10vh,5.5rem)]";function La(){const e=r.useRef(null),[n,a]=r.useState(!1);return r.useEffect(()=>{const l=e.current;if(!l)return;const i=()=>a(l.scrollHeight>l.clientHeight+1);i();const o=new ResizeObserver(i);return o.observe(l),()=>o.disconnect()}),{ref:e,overflowing:n}}function Aa({children:e}){const{ref:n,overflowing:a}=La();return t.jsx("div",{ref:n,tabIndex:a?0:void 0,role:a?"region":void 0,"aria-label":a?s("ui.agents.config.run_details_region"):void 0,"data-lo-region-cue":a?"":void 0,className:W("mb-2 overflow-y-auto empty:hidden",Ia),children:e})}const Fa="mb-1 flex min-h-7 items-center gap-3",is=e=>s("ui.agents.config.definitions",{count:e});function Ta({run:e,about:n,skill:a=!1,blockedReason:l,hasDraft:i,onClearAbout:o,onDismiss:u}){Z();const[h,v]=r.useState(!1),f=r.useRef(null),g=e.status==="running"||e.status==="stopping",c=e.enabled&&e.status!=="idle",w=!!l&&i&&!c,d=!!l&&i&&c&&!g,x=r.useRef(null);r.useEffect(()=>{if(e.status!=="error"||!e.turnFailed)return;const E=document.activeElement,k=x.current?.closest('[data-testid="config-composer"]');(!E||E===document.body||k?.contains(E))&&x.current?.focus({preventScroll:!0})},[e.status,e.turnFailed]),r.useEffect(()=>{if(!g)return;const E=k=>{k.key!=="Escape"||k.defaultPrevented||document.querySelector('[role="alertdialog"], [role="dialog"]')||f.current?.focus()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[g]);const N=e.status==="running"?e.step??"Working on your request":e.status==="stopping"?"Stopping":e.status==="done"?e.results.length>0?"Finished":"Finished without changing anything":e.status==="stopped"?"Stopped":e.status==="error"?e.turnFailed?s("ui.agents.config.state.did_not_finish"):e.canRetry?"Stopped with an error":"Finished with an error":"";return t.jsxs("div",{className:Qe,"data-testid":c?"config-run-strip":void 0,children:[t.jsxs("div",{className:Fa,children:[c?t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t.jsx(Ca,{status:e.status,pulse:g}),t.jsxs("span",{"aria-live":"polite",className:"min-w-0 truncate text-body-sm text-ink",children:[N,e.status==="done"&&e.touched.length>0?t.jsxs("span",{className:"sr-only",children:[". ",s("ui.agents.config.result.configured")," ",is(e.touched.length)]}):null]}),(g||e.status==="stopped"||e.status==="done")&&e.elapsed!=="0s"?t.jsx("span",{className:"shrink-0 text-meta text-ink-muted tabular-nums",children:e.elapsed}):null,e.touched.length>0?t.jsxs("span",{"aria-hidden":e.status==="done"?!0:void 0,className:"shrink-0 text-meta text-ink-muted",children:[t.jsxs("span",{className:"sr-only",children:[s("ui.agents.config.result.configured")," "]}),is(e.touched.length)]}):null]}):null,e.enabled&&!d?t.jsxs(t.Fragment,{children:[w?null:t.jsx("span",{id:l?void 0:Ve,"data-testid":l?void 0:"config-composer-note",className:c?"sr-only":"min-w-0 flex-1 truncate text-meta text-ink-dim",children:s("ui.agents.config.background_only")}),l?t.jsx("span",{id:Ve,"data-testid":"config-composer-note",className:w?"min-w-0 flex-1 truncate text-meta text-ink-dim":"sr-only",children:l}):null]}):t.jsx("span",{className:"flex-1","aria-hidden":"true"}),t.jsxs("div",{className:"ms-auto flex shrink-0 items-center gap-1",children:[n?t.jsxs(t.Fragment,{children:[t.jsx("span",{"data-testid":"config-composer-about",title:ls(n,a),className:"max-w-56 truncate text-meta text-ink-muted",children:ls(n,a)}),a?null:t.jsx(C,{variant:"ghost",size:"sm",className:c?void 0:as,onClick:o,children:s("ui.agents.config.action.clear")})]}):null,c&&e.activity.length>0?t.jsxs(C,{variant:"ghost",size:"sm","aria-expanded":h,onClick:()=>v(E=>!E),children:[h?t.jsx(oa,{className:"size-3.5"}):t.jsx(ca,{className:"size-3.5 rtl:-scale-x-100"}),s("ui.agents.config.action.watch")]}):null,c?g?t.jsxs(C,{ref:f,variant:"secondary",size:"sm",disabled:e.status==="stopping",onClick:()=>void e.stop(),children:[t.jsx(Nn,{className:"size-3.5"}),e.status==="stopping"?s("ui.agents.config.state.stopping"):s("ui.agents.config.action.stop")]}):t.jsx(C,{variant:"ghost",size:"sm",className:as,onClick:u,children:s("ui.agents.config.action.dismiss")}):null]})]}),e.enabled?null:t.jsx("p",{id:Ve,"data-testid":"config-composer-note",className:"mb-2 text-meta text-ink-dim",children:e.disabledReason}),d?t.jsx("p",{id:Ve,"data-testid":"config-composer-note",className:"mb-2 text-meta text-ink-muted",children:l}):null,c?t.jsxs(Aa,{children:[e.attached?t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:s("ui.agents.config.status.attached")}):null,e.stopError?t.jsxs("div",{className:"mt-2 border-danger-border border-t pt-2","data-testid":"config-stop-refused",children:[t.jsx("p",{className:"text-body-sm text-danger",children:s("ui.agents.config.error.stop_refused")}),t.jsx("p",{className:"mt-0.5 text-meta text-ink-muted",children:e.stopError})]}):null,h?t.jsx("div",{className:"mt-2 border-hairline border-t pt-2",children:t.jsx(Ra,{run:e})}):null,e.status==="stopped"?t.jsxs("div",{className:"mt-2 space-y-1 border-hairline border-t pt-2 text-body-sm",children:[t.jsx("p",{className:"text-ink",children:e.results.length>0?s("ui.agents.config.stopped.kept"):s("ui.agents.config.stopped.nothing")}),e.results.length>0?t.jsx("ul",{className:"space-y-0.5",children:e.results.map(E=>t.jsxs("li",{className:"text-ink-muted",children:[E.created?s("ui.agents.config.result.created"):s("ui.agents.config.result.changed")," ",t.jsx("span",{className:"text-ink",children:E.target.name})]},`${E.target.kind}:${E.target.name}`))}):null]}):null,e.status==="done"?t.jsx($a,{run:e,skill:a}):null,e.status==="error"&&e.error?t.jsx("div",{className:"mt-2 border-danger-border border-t pt-2",children:t.jsx("p",{className:"text-body-sm text-danger",children:e.error})}):null]}):null,c&&e.status==="error"&&e.error?t.jsxs("div",{className:"mb-2.5 flex items-center gap-2",children:[e.canRetry?t.jsx(C,{ref:x,variant:"secondary",size:"sm","data-testid":"config-retry",disabled:e.starting,onClick:()=>void e.retry(),children:e.starting?s("ui.agents.config.state.sending"):s("ui.agents.config.action.retry")}):null,t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.config.summary.nothing_else")})]}):null]})}function ls(e,n){return n||e.kind==="skill"?s("ui.agents.skills.composer.about",{name:e.name}):s("ui.agents.config.about",{kind:Gs(e),name:e.name})}function Gs(e){switch(e.kind){case"skill":return s("ui.agents.skills.composer.kind");case"team":return s("ui.agents.config.kind.team");case"agent":return s("ui.agents.config.kind.agent")}}function $a({run:e,skill:n=!1}){return Z(),e.results.length===0?t.jsxs("div",{className:"mt-2 border-hairline border-t pt-2 text-body-sm",children:[t.jsx("p",{className:"text-ink-muted",children:n?s("ui.agents.skills.composer.no_changes"):s("ui.agents.config.summary.no_changes")}),e.answer?t.jsx("p",{className:"mt-1 whitespace-pre-wrap text-ink",children:e.answer}):null,e.topic?t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:s("ui.agents.config.summary.you_asked",{topic:e.topic})}):null]}):t.jsxs("div",{className:"mt-2 space-y-1 border-hairline border-t pt-2",children:[t.jsx("ul",{className:"space-y-1 text-body-sm",children:e.results.map(a=>t.jsxs("li",{children:[t.jsx("span",{className:"text-ink",children:a.created?s("ui.agents.config.summary.created",{name:a.target.name}):s("ui.agents.config.summary.updated",{name:a.target.name})}),t.jsxs("span",{className:"text-ink-muted",children:[" (",Gs(a.target),")"]}),a.changes.length>0?t.jsxs("span",{className:"text-ink-muted",children:[": ",a.changes.map(l=>l.label).join(", ")]}):a.created?null:t.jsxs("span",{className:"text-ink-muted",children:[": ",a.target.kind==="skill"?s("ui.agents.skills.composer.changed_below"):s("ui.agents.config.summary.hidden_changes")]})]},`${a.target.kind}:${a.target.name}`))}),e.answer?t.jsx("p",{className:"whitespace-pre-wrap text-body-sm text-ink-muted",children:e.answer}):null]})}const Ue="agents-config",Ys=e=>`Change the ${e.kind} ${e.name}: `;function Xe(e,n,a){e.setAbout(n);const l=ct.getState();l.getCurrentInput(Ue)||l.setComposerText(Ue,a)}function Da(e){const n=ct.getState();n.getCurrentInput(Ue).trim()===Ys(e).trim()&&n.setComposerText(Ue,"")}function Js({run:e,hero:n=!1,blockedReason:a,about:l,onClearAbout:i,skill:o=!1,focusToken:u=0}){Z();const h=r.useRef(null),v=vn(),f=Bt(j=>j.cwd),g=gt(),c=e.frontend===null&&e.status==="idle"&&f.length>0&&ee(g.data,"draft_preview"),w=ht({...ea({cwd:f,model:null},ee(g.data,"draft_fast")),enabled:c}),d=Ue,x=j=>ct.getState().setCurrentInput(d,j),N=e.status==="running"||e.status==="stopping",E=!e.enabled||!!a,k=ct(j=>(j.inputByConversation[Ue]?.currentInput??"").trim().length>0),b=a||(N?"Working on your request…":e.enabled?void 0:ns()),S=l?o?s("ui.agents.skills.composer.placeholder",{name:l.name}):s("ui.agents.config.placeholder.about",{name:l.name}):e.enabled?n?s("ui.agents.config.placeholder.hero"):s("ui.agents.config.placeholder.docked"):ns(),L=l?`${l.kind}:${l.name}`:null;r.useEffect(()=>{!L||o||h.current?.focusInput()},[L,o]),r.useEffect(()=>{u>0&&h.current?.focusInput()},[u]);const F=()=>{e.dismiss(),h.current?.focusInput()},p=()=>{i(),h.current?.focusInput()};return t.jsxs("div",{"data-testid":"config-composer",children:[t.jsx("div",{className:"sr-only",id:"config-composer-label",children:o?s("ui.agents.skills.composer.label"):s("ui.agents.config.composer.label")}),t.jsx(_n,{ref:h,autoFocus:!(e.status==="error"&&e.turnFailed&&e.canRetry),conversationId:d,messages:wa,isLoading:!1,transcriptless:!0,placeholderOverride:S,sessionStatus:e.frontend?{frontend:e.frontend,costChannels:ee(g.data,"cost_channels")}:w.data?{frontend:w.data.snapshot,draft:!0,costChannels:ee(g.data,"cost_channels")}:void 0,recordingProbe:v,hostNotice:{id:Ve,blocksInput:!e.enabled||!!a||N,placeholder:b,statedByNode:k,node:t.jsx(Ta,{run:e,about:l,skill:o,blockedReason:a,hasDraft:k,onClearAbout:p,onDismiss:F})},onSendMessage:(j,P)=>e.start(j,l,P)}),n&&e.enabled?t.jsx("div",{className:W(Dt,Ts),children:t.jsx("div",{className:W(Qe,"mt-2 flex flex-col items-start gap-0.5",!l&&!N?"":"invisible"),children:Sa.map(j=>t.jsx(C,{variant:"ghost",size:"sm",className:"-ml-2 h-auto max-w-full justify-start whitespace-normal break-words px-2 py-1 text-start text-body-sm text-ink-muted hover:bg-elevated hover:text-ink disabled:text-ink-disabled disabled:hover:bg-transparent",disabled:E,onClick:()=>{x(s(j)),h.current?.focusInput()},children:s(j)},j))})}):null]})}const rs=(e,n)=>e.kind===n.kind&&e.name===n.name;function os(e){return`${e.kind}:${e.name}`}const ie=ta(e=>({sessionId:null,status:"idle",topic:"",prompt:"",turnFailed:!1,images:[],files:[],about:null,error:null,stopError:null,unsent:!1,startedAt:null,settledAt:null,touched:[],results:[],answer:"",marks:[],before:null,setAbout:n=>e({about:n}),adopt:(n,a,l,i=[],o=[],u=a)=>e({sessionId:n,status:"running",topic:u,prompt:a,turnFailed:!1,images:i,files:o,error:null,stopError:null,startedAt:Date.now(),settledAt:null,touched:[],results:[],answer:"",before:l,unsent:!1}),noteTouched:n=>e(a=>a.touched.some(l=>rs(l,n))?a:{touched:[...a.touched,n]}),stopping:()=>e(n=>n.status==="running"?{status:"stopping",stopError:null}:n),stopFailed:n=>e({status:"running",stopError:n}),settle:(n,a,l)=>e(()=>({status:a,settledAt:Date.now(),results:n,answer:l,marks:n.map(i=>({...i.target,created:i.created})),sessionId:null,images:[],files:[],stopError:null,before:null,unsent:!1})),fail:n=>e({status:"error",error:n,unsent:!1,stopError:null}),failUnsent:n=>e({status:"error",error:n,unsent:!0,stopError:null}),failTurn:n=>e({status:"error",error:n,unsent:!0,turnFailed:!0,stopError:null,settledAt:Date.now()}),dismiss:()=>e({status:"idle",sessionId:null,error:null,stopError:null,unsent:!1,topic:"",prompt:"",turnFailed:!1,images:[],files:[],touched:[],results:[],answer:"",marks:[],startedAt:null,settledAt:null,before:null}),clearMark:n=>e(a=>({marks:a.marks.filter(l=>!rs(l,n))}))})),Oa=/Value error,\s*([\s\S]*?)\s*\[type=/,Pa=/^\d+ validation errors? for \S+[\s\S]*?\n\s*/i,Ma=/\s*\[type=[^\]]*\][\s\S]*$/m,Ba=/\s*For further information visit \S+/g,qa=/'([^']+)' already exists/,Ua=/cannot contain spaces or path separators/i,za=/effort tier '([^']+)' is unavailable/i,Ha=/team name must be/i,Ka=/manager '([^']+)'/i,Wa=/(?:member|role) '([^']+)' (?:is not|does not)/i,Va=/depth|cycle|circular/i,Ga=/instructions/i,Ya=/description/i;function Ja(e){const n=e.match(Oa);return n?.[1]?n[1].trim():e.replace(Pa,"").replace(Ma,"").replace(Ba,"").trim()}function Ye(e){const n=Ja(e),a=n.match(qa);if(a)return{message:s("ui.agents.refusals.name_taken",{name:a[1]}),field:"name"};if(Ua.test(n))return{message:s("ui.agents.refusals.name_grammar"),field:"name"};const l=n.match(za);if(l)return{message:s("ui.agents.refusals.effort_unavailable",{tier:l[1]}),field:"effort"};if(n.match(Ha))return{message:s("ui.agents.refusals.team_name_bound"),field:"name"};const o=n.match(Ka);if(o)return{message:s("ui.agents.refusals.missing_manager",{name:o[1]}),field:"manager"};const u=n.match(Wa);return u?{message:s("ui.agents.refusals.missing_member",{name:u[1]}),field:"members"}:Va.test(n)?{message:s("ui.agents.refusals.team_nesting"),field:"members"}:Ga.test(n)?{message:n,field:"instructions"}:Ya.test(n)?{message:n,field:"description"}:{message:n,field:null}}function Qa(e,n){const a=new Set(n),l=`${e}-copy`;if(!a.has(l))return l;for(let i=2;i<100;i+=1){const o=`${l}-${i}`;if(!a.has(o))return o}return l}function Ze(e){return e.action_class==="proactive"?"proactive":"reactive"}const Qs={get proactive(){return s("ui.agents.refusals.class.label.proactive")}},Za={get proactive(){return s("ui.agents.refusals.class.meaning.proactive")},get reactive(){return s("ui.agents.refusals.class.meaning.reactive")}},Xa={get proactive(){return s("ui.agents.refusals.class.effect.proactive")},get reactive(){return s("ui.agents.refusals.class.effect.reactive")}};let Zs=s("ui.agents.refusals.class.install_disclosure");ha(()=>{Zs=s("ui.agents.refusals.class.install_disclosure")});function ei(e,n){const a=[];return e.source==="builtin"&&a.push({op:"profiles.install",name:e.name}),a.push({op:"profiles.update",name:e.name,fields:{action_class:n}}),a}async function ti(e,n,a,l=()=>crypto.randomUUID()){if(Ze(e)===n)return null;let i=null;const o=ei(e,n);for(let u=0;u<o.length;u+=1){const h=o[u];try{i=await a(h,l())}catch(v){throw new Xs(v,o.slice(0,u))}}return i}class Xs extends Error{completed;constructor(n,a){super(n instanceof Error?n.message:String(n)),this.name="ClassSwitchError",this.completed=a}}function si(e,n){const a=e instanceof Error&&e.message?e.message:s("ui.agents.refusals.class.error.no_reason"),l=Ye(a).message;return n.some(i=>i.op==="profiles.install")?s("ui.agents.refusals.class.error.install_landed",{reason:l}):l}const ni=new Set(["agent","team","skill"]);function ai(e){const n=typeof e.args?.op=="string"?e.args.op:null,a=typeof e.args?.name=="string"?e.args.name:null,l=e.toolName==="team"?"team":e.toolName==="skill"?"skill":"agent",i=a?{kind:l,name:a}:null,o=e.phase==="done"&&!e.isError&&!e.notRunReason&&!e.neverSent,u=h=>({writes:h&&o});switch(n){case"create":return{verb:a?`Creating ${l} ${a}`:`Creating a ${l}`,target:i,...u(!0)};case"update":return{verb:a?`Updating ${l} ${a}`:`Updating a ${l}`,target:i,...u(!0)};case"edit":return{verb:a?`Editing ${l} ${a}`:`Editing a ${l}`,target:i,...u(!0)};case"install":return{verb:a?`Installing ${a}`:"Installing an agent",target:i,...u(!0)};case"list":case"search":case"show":return{verb:a?`Reading ${a}`:`Reading ${l}s`,target:i,...u(!1)};default:return{verb:e.phase==="running"?`Working on ${l}s`:`Checked ${l}s`,target:i,...u(!0)}}}function ii(e){return e?Object.fromEntries(e.map(n=>[n.name,{description:n.description??"",fingerprint:n.fingerprint??""}])):null}const li={description:"description",kind:"kind",tools:"tools",effort:"effort tier",delegate:"delegation",action_class:"class",manager:"manager",members:"members",instructions:"instructions"};function ri(e){return{description:e.description??"",kind:e.kind,tools:e.tools&&e.tools.length>0?[...e.tools].sort().join(","):"*",effort:e.effort??"inherit",delegate:String(!!e.delegate),action_class:Ze(e)}}function oi(e){return{description:e.description??"",manager:e.manager??"",members:(e.members??[]).map(n=>`${n.kind}:${n.role}x${n.count}`).sort().join(",")}}function cs(e,n){return{agents:Object.fromEntries((e??[]).map(a=>[a.name,ri(a)])),teams:Object.fromEntries((n??[]).map(a=>[a.name,oi(a)]))}}function ci(e,n){if(e===n)return"tools";const a=h=>h==="*"?null:new Set(h.split(",")),l=a(e),i=a(n);if(i===null)return"tools widened to every tool";if(l===null)return"tools narrowed to a list";const o=[...i].filter(h=>!l.has(h)),u=[...l].filter(h=>!i.has(h));return o.length&&!u.length?o.length===1?`tool added: ${o[0]}`:`${o.length} tools added`:u.length&&!o.length?u.length===1?`tool removed: ${u[0]}`:`${u.length} tools removed`:"tools changed"}function ui(e,n,a){if(e==="tools")return ci(n,a);if(e==="fingerprint")return"instructions changed";if(e==="delegate")return a==="true"?"delegation turned on":"delegation turned off";if(e==="action_class")return a==="proactive"?"class changed to proactive":"class changed to reactive — proactive messaging stopped";if(e==="members"){const l=i=>i?i.split(",").length:0;return`members changed (${l(n)} to ${l(a)})`}return`${li[e]??e} changed`}function et(e,n){return n==="agent"?e.agents:n==="team"?e.teams:e.skills??null}function di(e,n,a){const l=[],i=new Set;for(const o of a){const u=`${o.kind}:${o.name}`;if(i.has(u))continue;i.add(u);const h=et(e,o.kind),v=et(n,o.kind);if(!h||!v){l.push({target:o,created:!1,changes:[]});continue}const f=h[o.name],g=v[o.name];if(!g)continue;if(!f){l.push({target:o,created:!0,changes:[]});continue}const c=[];for(const w of Object.keys(g))g[w]!==f[w]&&c.push({label:ui(w,f[w],g[w]),before:f[w],after:g[w]});l.push({target:o,created:!1,changes:c})}for(const o of["agent","team","skill"]){const u=et(n,o),h=et(e,o);if(!(!u||!h))for(const v of Object.keys(u))i.has(`${o}:${v}`)||h[v]||l.push({target:{kind:o,name:v},created:!0,changes:[]})}return l}function en(e){return ee(e,"agents_config")&&ee(e,"session_interrupt")&&ee(e,"profile_catalogue")&&ee(e,"team_catalogue")}function tn(e){return en(e)&&ee(e,"agents_config_skills")&&ee(e,"skill_library")}async function us(e){if(!e)return null;try{const n=await le({op:"skills.list"});return ii(n?.data?.skills??null)}catch{return null}}function mi(e){if(!(e instanceof ut)||e.status!==409)return null;const a=e.detail?.session_id;return typeof a=="string"&&a.length>0?a:null}function fi(e,n){const[a,l]=r.useState(()=>Date.now());return r.useEffect(()=>{if(!e||!n)return;const i=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(i)},[e,n]),e?Math.max(0,a-e):0}function gi(e){const n=Math.floor(e/1e3);return n<60?`${n}s`:`${Math.floor(n/60)}m ${String(n%60).padStart(2,"0")}s`}function ds(e){for(let n=(e?.length??0)-1;n>=0;n-=1){const a=e?.[n];if(a?.kind==="assistant"&&a.text?.trim())return a.text.trim()}return""}function hi(e,n){const a=e.trim();if(!n)return a;const l=`Change the ${n.kind} ${n.name}:`;return a.startsWith(l)&&a.slice(l.length).trim()||a}function ms(e,n){if(n<=0)return!0;if(!e)return!1;for(let a=Math.max(0,n);a<e.length;a+=1)if(e[a]?.kind==="user")return!0;return!1}function fs(e){if(!e)return null;let n=0;for(let l=e.length-1;l>=0;l-=1)if(e[l]?.kind==="user"){n=l+1;break}let a=null;for(let l=n;l<e.length;l+=1){const i=e[l];i?.kind==="custom"&&i.level==="error"?a=i.headline?.trim()||gs():i?.kind==="assistant"&&(i.error===!0||i.stopReason==="error")?a=gs():i?.kind==="assistant"&&i.text?.trim()&&i.error!==!0&&(a=null)}return a}const gs=()=>s("ui.agents.config.error.turn_failed");function pi(e){const a=e?.payload?.frontend;if(!a||typeof a!="object")return null;const l=a.streaming;if(typeof l=="boolean")return l;const i=a.snapshot?.streaming;return typeof i=="boolean"?i:null}function xi(){const e=gt(),n=en(e.data),a=tn(e.data),l=pt(),i=ie(),[o,u]=r.useState(!1),[h,v]=r.useState(!1),f=r.useRef(!1),g=r.useRef(0),c=r.useRef(0),w=i.status==="running"||i.status==="stopping",d=sa(i.sessionId??void 0,!!i.sessionId),x=r.useMemo(()=>ds(d.transcript?.records),[d.transcript?.records]);Bn(i.sessionId??void 0,d.subscriptionId);const N=d.transcript?.records,E=r.useRef(N);r.useEffect(()=>{E.current=N},[N]);const k=r.useMemo(()=>(d.transcript?.records??[]).filter(A=>A.kind==="tool"&&ni.has(A.toolName)).map(A=>({...ai({toolName:A.toolName,args:A.args??null,phase:A.phase,ts:A.ts,isError:A.isError,notRunReason:A.notRunReason,neverSent:A.neverSent}),ts:A.ts})),[d.transcript]);r.useEffect(()=>{if(w)for(const y of k)y.target&&y.writes&&i.noteTouched(y.target)},[k,w,i]);const b=w&&k.length>0?k[k.length-1].verb:null,S=gi(fi(i.startedAt,w)),L=r.useCallback(async(y,A="")=>{if(f.current)return;f.current=!0;const U=y==="done"?fs(E.current?.slice(g.current)):null;if(U){jt(l),ie.getState().failTurn(U);return}const H=i.before;let Y=[];try{const[Q,K,ae]=await Promise.all([le({op:"profiles.list"}),le({op:"teams.list"}),us(a)]);H&&(Y=di(H,{...cs(Q.profiles,K.teams),skills:ae},i.touched))}catch{ie.getState().fail("The run finished, but the agents and teams lists could not be read to describe what changed."),jt(l);return}if(jt(l),ie.getState().settle(Y,y,A),y==="done"&&Y.length>0){const Q=Y.filter(K=>K.created).length;Ne(Q>0?s("ui.notices.agents.config_run_changed",{count:Y.length}):s("ui.notices.agents.config_run_updated",{count:Y.length}))}},[l,i.before,i.touched,a]);r.useEffect(()=>{if(w){if(d.failure){ie.getState().fail(d.failure.statement);return}f.current||d.frontend&&(d.frontend.streaming||d.turnsCompleted<=c.current||ms(E.current,g.current)&&L(i.status==="stopping"?"stopped":"done",x))}},[w,x,d.failure,d.frontend,d.turnsCompleted,i.status,L]),r.useEffect(()=>{const y=i.sessionId;if(!w||!y)return;let A=!1;const U=async()=>{if(!(A||f.current))try{const Q=await le({op:"sessions.get",sessionId:y});if(A||f.current||pi(Q)!==!1)return;const K=E.current;if(!ms(K,g.current))return;const ae=K?.slice(g.current),q=ds(ae);if(!q&&!fs(ae))return;L(ie.getState().status==="stopping"?"stopped":"done",q)}catch{}},H=setTimeout(()=>void U(),400),Y=setInterval(()=>void U(),4e3);return()=>{A=!0,clearTimeout(H),clearInterval(Y)}},[w,i.sessionId,L]);const F=async(y,A,U=[])=>{if(o||!y.trim()&&U.length===0)return!1;u(!0),v(!1),f.current=!1,g.current=0,c.current=0;const H={...cs(l.getQueryData(["desktop","profiles"]),l.getQueryData(["desktop","teams"])),skills:await us(a)},Y=A?`About the ${A.kind} “${A.name}”: ${y.trim()}`:y.trim(),{images:Q,files:K,failures:ae,overflow:q,fileOverflow:me}=await wn(U,Y),z=Sn(ae);if(z)return ie.getState().fail(z),!1;const oe=En(q);if(oe)return ie.getState().fail(oe),!1;const X=Cn(me);if(X)return ie.getState().fail(X),!1;try{let J;try{J=(await le({op:"sessions.create",requestId:crypto.randomUUID(),purpose:"agents-config"})).session_id}catch(te){const R=mi(te);if(R)return v(!0),i.adopt(R,y.trim(),H,Q,K),!1;throw te}return i.adopt(J,Y,H,Q,K,hi(y,A)),await p(J,Y,Q,K),!0}catch(J){const te=ie.getState().sessionId;return ie.getState().failUnsent(Be(J,te?"The run was set up, but your request could not be sent. It is still in the box — send it again when the backend is reachable.":"The configuration run could not be started. Your request is still here.")),!1}finally{u(!1)}},p=async(y,A,U=[],H=[])=>{await le({op:"sessions.message",sessionId:y,requestId:crypto.randomUUID(),text:A,...U.length>0?{images:U}:{},...H.length>0?{files:H}:{}})},j=async()=>{const y=ie.getState();if(!(o||!y.unsent||!y.sessionId||!y.prompt&&y.images.length===0)){u(!0),g.current=E.current?.length??0,c.current=d.turnsCompleted;try{await p(y.sessionId,y.prompt,y.images,y.files),i.adopt(y.sessionId,y.prompt,y.before,y.images,y.files,y.topic),f.current=!1}catch(A){ie.getState().failUnsent(Be(A,"The request could not be sent. It is still in the box."))}finally{u(!1)}}},P=async()=>{const y=ie.getState().sessionId;if(y){i.stopping();try{await qn(y,crypto.randomUUID())}catch(A){ie.getState().stopFailed(Be(A,"The run did not acknowledge the request."))}}},D=n?null:e.isLoading?"Connecting to the backend…":e.error?s("ui.agents.config.banner.unavailable"):"Ask for a change needs a newer backend. Update Local Operator to configure agents by conversation.";return{enabled:n,disabledReason:D,status:i.status,sessionId:i.sessionId,frontend:d.frontend,topic:i.topic,error:i.error,stopError:i.stopError,about:i.about,setAbout:i.setAbout,touched:i.touched,results:i.results,answer:i.answer,step:b,elapsed:S,activity:k,start:F,stop:P,retry:j,canRetry:i.unsent&&!!i.sessionId,turnFailed:i.turnFailed,dismiss:i.dismiss,starting:o,attached:h}}function bi(e){return JSON.stringify(e.agent_id?["agent","id",e.agent_id]:["agent","source",e.source,e.name])}function ki(e){return JSON.stringify(e.id?["team","id",e.id]:["team","local",e.name])}const ji=["builtin","hub","local","external","project"];function yi(e){return ji.includes(e??"")?e:null}function sn(e){return{name:e.name,description:e.description??"",source:yi(e.source),linkId:e.link_id??null,installed:e.installed!==!1,fingerprint:e.fingerprint??null,form:e.form==="document"||e.form==="bundle"?e.form:null,editable:e.editable===!0}}function vi(e){return e.map(sn).sort((n,a)=>n.name.localeCompare(a.name))}function _i(e,n,a,l){if(e.source!=="hub")return null;const i=e.linkId?n?.find(u=>u.kind==="skill"&&u.link_id===e.linkId):void 0,o=i?a.get(Un("skill",i.name)):void 0;return{state:pa(i,o,l),link:i,update:o}}function Ni(e,n,a){const l=n.trim().toLowerCase();return l?e.filter(i=>i.name.toLowerCase().includes(l)||i.description.toLowerCase().includes(l)||a(i.source).toLowerCase().includes(l)):[...e]}function wi(e,n){return n?n.body_in_detail?typeof e!="string"||typeof n.body_length!="number"?null:e.slice(0,n.body_length):typeof n.body=="string"?n.body:null:null}const Si=/^(---[ \t]*\r?\n)(?:([\s\S]*?)\r?\n)?(---[ \t]*(?:\r?\n|$))/,Ei=/^(?:[ \t]*\r?\n)*/,hs=/^[ \t]+\S/,ps=/^[ \t]*$/,Ci=/\r?\n/,Ri=/[\u007f-\u009f]/g,Ii=/(\r?\n)/;function nn(e){const n=Si.exec(e);if(!n)return{meta:null,text:e,head:"",tail:"",gap:""};const a=n[1],l=n[2]??"",i=n[0].slice(a.length+l.length),o=e.slice(n[0].length),u=Ei.exec(o)?.[0]??"";return{meta:l,text:o.slice(u.length),head:a,tail:i,gap:u}}function an(e,n){const a=e.findIndex(i=>new RegExp(`^${n}[ \\t]*:`).test(i));if(a<0)return null;let l=a+1;for(;l<e.length;){const i=e[l];if(hs.test(i)){l+=1;continue}if(ps.test(i)){const o=e.slice(l).findIndex(u=>!ps.test(u));if(o>0&&hs.test(e[l+o])){l+=o;continue}}break}return[a,l]}function Li(e){if(e===null)return null;const n=e.split(Ci),a=new Set;for(const i of["name","description"]){const o=an(n,i);if(o)for(let u=o[0];u<o[1];u+=1)a.add(u)}const l=n.filter((i,o)=>!a.has(o)).join(`
|
|
8
|
+
`).trim();return l||null}function wt(e){return JSON.stringify(e).replace(Ri,n=>`\\u${n.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Ai(e,n,a,l){const i=nn(e);if(i.meta===null){if(a===null)return l;const d=l.includes(`\r
|
|
9
|
+
`)?`\r
|
|
10
|
+
`:`
|
|
11
|
+
`;return`---${d}name: ${wt(n)}${d}description: ${wt(a.trim())}${d}---${d}${d}${l}`}if(a===null)return`${i.head}${i.meta}${i.tail}${i.gap}${l}`;const o=`description: ${wt(a.trim())}`,u=i.head.endsWith(`\r
|
|
12
|
+
`)?`\r
|
|
13
|
+
`:`
|
|
14
|
+
`,h=i.meta===""?[]:i.meta.split(Ii),v=h.filter((d,x)=>x%2===0),f=h.filter((d,x)=>x%2===1),g=an(v,"description");if(g){const[d,x]=g;v.splice(d,x-d,o),f.splice(d,Math.max(0,x-1-d))}else v.length>0&&f.push(u),v.push(o);const c=v.map((d,x)=>d+(x<f.length?f[x]:"")).join(""),w=i.meta===""?`${u}${i.tail}`:i.tail;return`${i.head}${c}${w}${i.gap}${l}`}function xs(e,n){return e.installed?e.editable?Math.max(n?.files_total??0,n?.files?.length??0)>0?{kind:"ask",reason:"files"}:n?.body_truncated?{kind:"ask",reason:"truncated"}:{kind:"edit"}:e.form==="bundle"?{kind:"read-only",reason:"bundle",copy:!1}:e.source==="builtin"||e.source==="external"||e.source==="project"?{kind:"read-only",reason:e.source,copy:!0}:{kind:"read-only",reason:"unknown",copy:!1}:{kind:"not-installed"}}function Fi(e,n){return e?n?n.installed?n.editable?null:"read-only":"not-installed":"none":"backend"}const Ti=["all","local","hub","builtin"];function $i(e,n){return n==="all"?[...e]:e.filter(a=>a.source===n)}const Di=new Set(["local-only","both-changed"]);function ln(e){const n=e?.link?.push?.classification;return typeof n=="string"?Di.has(n):!1}function Oi(e,n,a){return n?a==="failed"?"failed":e.installed?a==="available"?"available":a==="applied"?"applied":ln(n)?"modified":n.state.kind==="manual"?"updates-off":n.state.kind==="not-present"?"unlinked":null:"not-installed":null}function Pi(e,n){if(!e.installed)return"not-installed";if(e.source==="builtin"||e.source==="external"||e.source==="project")return"read-only";if(e.source!=="hub"||!n)return null;switch(n.state.kind){case"unknown":return"hub-unknown";case"not-present":return"unlinked";case"manual":return"updates-off";case"update":return n.state.link.policy.subscribe?"following":"updates-off";case"subscribed":case"detached":return"not-installed";default:return"following"}}const Gt=["desktop","skills","library"];async function rn(e){const n=await le({op:"skills.list",...e?{name:e}:{}}),a=aa.safeParse(n?.data);if(!a.success)throw new Error("skills-library-invalid");return a.data}function Mi(e){return ht({queryKey:Gt,enabled:e,queryFn:()=>rn(),staleTime:1e4,retry:na})}function Bi(e,n){return ht({queryKey:[...Gt,e],enabled:n&&!!e,queryFn:()=>rn(e??void 0),staleTime:1e4,retry:!1})}function qi(e){const n=Mi(e.enabled),a=Pt(e.enabled&&e.linksEnabled),l=zn(e.enabled&&e.updatesEnabled),i=r.useMemo(()=>vi(n.data?.skills??[]),[n.data]),o=r.useMemo(()=>Hn(l.data),[l.data]),u=e.linksEnabled&&!a.isLoading&&!a.error,h=Hi(),v=r.useCallback(f=>{const g=_i(f,a.data?.links,o,u);return!g?.link||!f.installed||!zi(g.link)||g.link.push?.classification==="both-changed"?g:{...g,link:{...g.link,push:{...g.link.push,classification:"local-only"}}}},[a.data,o,u,h]);return{library:n,cards:i,join:v,inventoryReady:u,linksFailed:!!a.error}}const on=new Map,At=new Set;let cn=0;function Ui(e){on.set(e,Date.now()),cn+=1;for(const n of At)n()}function zi(e){if(!e)return!1;const n=on.get(e.link_id);return n===void 0?!1:!((e.push?.last_checked_at?Date.parse(e.push.last_checked_at):Number.NaN)>n)}function Hi(){return r.useSyncExternalStore(e=>(At.add(e),()=>At.delete(e)),()=>cn)}function Ki(){const e=pt(),n=r.useCallback(()=>{e.invalidateQueries({queryKey:Gt}),e.invalidateQueries({queryKey:Ps})},[e]),a=tt({retry:0,mutationFn:o=>le({op:"skills.create",requestId:crypto.randomUUID(),name:o,copyFrom:o}),onSettled:n}),l=tt({retry:0,mutationFn:o=>le({op:"skills.update",requestId:crypto.randomUUID(),name:o.name,expectedFingerprint:o.expectedFingerprint,files:[{path:"SKILL.md",content:o.skillMd}]}),onSuccess:(o,u)=>{u.linkId&&Ui(u.linkId)},onSettled:n}),i=tt({retry:0,mutationFn:o=>le({op:"skills.remove",requestId:crypto.randomUUID(),name:o.name,discardLocalChanges:o.discardLocalChanges}),onSettled:n});return{copy:a,update:l,remove:i}}function G({title:e,description:n,actions:a,children:l,className:i}){return t.jsxs("section",{className:W("space-y-2",i),children:[t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[t.jsx("h3",{className:"text-heading",children:e}),a]}),n?t.jsx("p",{className:"text-meta text-ink-muted",children:n}):null,l]})}const Yt="min-h-6",Jt="h-[calc(var(--text-title)*var(--text-title--line-height))]";function we({text:e,empty:n="Nothing here yet.",mono:a=!1,showAllLabel:l,showLessLabel:i,breakLongTokens:o=!1,markdown:u=!1}){const[h,v]=r.useState(!1),[f,g]=r.useState(!1),c=r.useRef(null);Z();const w=i??s("ui.agents.detail.read.show_less"),d=l??s("ui.agents.detail.read.show_all");return r.useEffect(()=>{if(h)return;const x=c.current;if(!x)return;const N=()=>g(!!e&&x.scrollHeight>x.clientHeight+1);N();const E=new ResizeObserver(N);return E.observe(x),()=>E.disconnect()},[e,h]),e.trim()?t.jsxs("div",{className:W(o&&"min-w-0"),children:[t.jsx("div",{ref:c,"data-break-long-tokens":o?"true":void 0,"data-read-markdown":u?"true":void 0,className:W("text-body text-ink",u?!h&&"max-h-[10lh] overflow-hidden":"whitespace-pre-wrap",!u&&!h&&"line-clamp-10",a&&"font-mono text-meta",o&&"min-w-0 break-words [overflow-wrap:anywhere]"),children:u?t.jsx(va,{children:e}):e}),f?t.jsx(C,{variant:"link",size:"sm",className:W("mt-px -mb-[3px]",Yt),"aria-expanded":h,onClick:()=>v(x=>!x),children:h?w:d}):null]}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:n})}function Wi({source:e,appearance:n="chip"}){const a=un(e);return n==="text"?t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a}):t.jsx(ke,{variant:"neutral",children:a})}function un(e){return e==="builtin"?s("ui.agents.pages.scope.builtin"):e==="installed"?s("ui.agents.pages.scope.installed"):s("ui.agents.pages.scope.custom")}let Qt=!1,dn=null;function bs(e,n){Qt=e,dn=e?n??null:null}function Zt(e,n){r.useEffect(()=>{if(!n)return;const a=l=>{l.key!=="Escape"||l.defaultPrevented||Qt||(l.preventDefault(),e())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n,e])}function bt({dirty:e,pending:n,onSave:a,onCancel:l,saveLabel:i=s("ui.agents.detail.action.save_changes"),pendingLabel:o=s("ui.agents.detail.action.saving"),dirtyHint:u,submit:h,confirming:v,onConfirmingChange:f}){Z();const[g,c]=r.useState(!1),w=r.useRef(null),d=r.useRef(null),x=v!==void 0,N=x?v:g,E=r.useRef(!1);r.useEffect(()=>{N?d.current?.focus():E.current&&document.activeElement===document.body&&w.current?.focus(),E.current=N},[N]);const k=r.useRef(null);r.useEffect(()=>{const S=k.current,L=S?.closest("[data-agents-pane]");if(!S||!L)return;const F=()=>L.style.setProperty("--lo-pane-footer-h",`${S.getBoundingClientRect().height}px`);F();const p=new ResizeObserver(F);return p.observe(S),()=>{p.disconnect(),L.style.removeProperty("--lo-pane-footer-h")}},[]);const b=S=>{x||c(S),f?.(S)};return r.useEffect(()=>{e||(x||c(!1),f?.(!1))},[e,x,f]),t.jsxs("div",{ref:k,"data-testid":"edit-footer","data-lo-pane-footer":!0,className:"sticky bottom-0 z-10 flex flex-wrap items-center gap-2 border-hairline border-t bg-canvas py-3",children:[t.jsx(C,{ref:w,type:h?"submit":void 0,variant:"primary",onClick:h?void 0:a,disabled:n,children:n?o:i}),N?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-body-sm text-ink-muted",children:u??s("ui.agents.detail.action.discard_question")}),t.jsx(C,{variant:"danger",onClick:l,children:s("ui.agents.detail.action.discard_changes")}),t.jsx(C,{ref:d,variant:"ghost",onClick:()=>{b(!1),w.current?.focus()},children:s("ui.agents.detail.action.keep_editing")})]}):t.jsx(C,{variant:"ghost",onClick:()=>{Qt&&dn?.(),e?b(!0):l()},disabled:n,children:s("ui.common.actions.cancel")}),e&&!N?t.jsx("span",{className:"ms-auto text-meta text-ink-dim",children:s("ui.agents.detail.action.unsaved_changes")}):null]})}let Ft=!1;function mn(){Ft=!0}function fn(){const e=Ft;return Ft=!1,e}function gn({rows:e=6}){return t.jsx("div",{className:"space-y-1","aria-hidden":"true",children:Vi.slice(0,e).map(n=>t.jsx(Me,{className:"h-12 w-full"},n))})}const Vi=["a","b","c","d","e","f","g","h"];function mt(){return t.jsxs("div",{className:"space-y-8","aria-hidden":"true",children:[t.jsx(Me,{className:"h-7 w-64"}),t.jsx(Me,{className:"h-5 w-40"}),t.jsx(Me,{className:"h-28 w-full"}),t.jsx(Me,{className:"h-24 w-full"})]})}function lt({title:e,what:n,meaning:a,onRetry:l,retrying:i=!1,retryLabel:o="Retry",retryingLabel:u="Retrying…"}){return t.jsxs("div",{role:"alert",className:"max-w-xl space-y-2",children:[t.jsx("h2",{className:"text-heading",children:e}),t.jsx("p",{className:"text-body-sm text-ink",children:n}),t.jsx("p",{className:"text-body-sm text-ink-muted",children:a}),t.jsx(C,{variant:"secondary",onClick:l,disabled:i,children:i?u:o})]})}function Se({label:e,htmlFor:n,error:a}){return t.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[t.jsx("label",{htmlFor:n,className:"text-body-sm text-ink-muted",children:e}),a?t.jsx("span",{className:"text-meta text-danger",role:"alert",children:a}):null]})}const Gi=/^[A-Za-z0-9_.:-]{1,128}$/;function Re(e){return{description:e.description??"",instructions:e.instructions??"",tools:e.tools&&e.tools.length>0?[...e.tools]:null,effort:e.effort??"inherit",delegate:e.delegate??!1}}function Yi(e,n){const a={};return n.description!==e.description&&(a.description=n.description),n.instructions!==e.instructions&&(a.instructions=n.instructions),JSON.stringify(n.tools)!==JSON.stringify(e.tools)&&(a.tools=n.tools??[]),n.effort!==e.effort&&(a.effort=n.effort),n.delegate!==e.delegate&&(a.delegate=n.delegate),a}function Ji({profile:e}){Z();const n=[un(e.source),Ze(e)==="proactive"?Qs.proactive:null,e.delegate?s("ui.agents.detail.meta.delegates"):null,e.kind==="specialist"?"Specialist":null].filter(Boolean);return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:n.join(" · ")}),e.divergent_fields?.length?t.jsx(ke,{variant:"warning",children:s("ui.agents.detail.badge.modified")}):null]})}const Qi=5e3;let St=null;function Zi({profile:e,displayedName:n,notice:a,onNotice:l,onChanged:i}){Z();const o=Ze(e),[u,h]=r.useState(null),[v,f]=r.useState(!1),g=r.useRef(null),c=r.useId();r.useEffect(()=>{u!==null&&o===u&&h(null)},[o,u]),r.useEffect(()=>{const x=St;!x||x.name!==e.name||(St=null,!(Date.now()-x.at>Qi)&&g.current?.focus())},[e.name]);const w=u??o,d=async x=>{if(!(v||x===w)){St={name:e.name,at:Date.now()},l(null),h(x),f(!0);try{await ti(e,x,(N,E)=>N.op==="profiles.install"?le({op:"profiles.install",name:N.name,requestId:E}):le({op:"profiles.update",name:N.name,requestId:E,fields:N.fields??{}})),i(e.name),Ne(x==="proactive"?s("ui.notices.agents.proactive",{name:n}):s("ui.notices.agents.reactive",{name:n}))}catch(N){h(null);const E=N instanceof Xs?N.completed:[],k=si(N,E);l(k),rt(k),i(e.name)}finally{f(!1)}}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex items-center gap-2 text-body-sm",children:[t.jsx(xt,{ref:g,checked:w==="proactive","aria-disabled":v,"aria-labelledby":c,"data-testid":"agent-class-switch",className:"after:absolute after:inset-0 after:content-['']",onCheckedChange:x=>void d(x?"proactive":"reactive")}),t.jsx("span",{id:c,className:"text-ink",children:s("ui.agents.detail.class.label")}),t.jsx("span",{"aria-live":"polite",className:"text-ink-muted",children:v?"Switching…":w==="proactive"?"On":"Off"})]}),t.jsx("p",{className:"text-body-sm text-ink",children:Za[w]}),t.jsx("p",{className:"text-meta text-ink-muted",children:Xa[w]}),e.source==="builtin"?t.jsx("p",{className:"text-meta text-ink-muted",children:Zs}):null,a?t.jsxs(pe,{variant:"danger",role:"alert","data-testid":"agent-class-error",children:[t.jsx(xe,{children:s("ui.agents.detail.class.error_title")}),t.jsx(je,{children:a})]}):null]})}function hn({tools:e,onChange:n,error:a}){Z();const[l,i]=r.useState(""),[o,u]=r.useState(null),h=r.useId(),v=()=>{const f=l.trim();if(f){if(!Gi.test(f)){u("Tool names are letters, digits, dot, underscore, dash or colon.");return}if(e?.includes(f)){u("That tool is already listed.");return}u(null),i(""),n([...e??[],f])}};return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(xt,{checked:e===null,onCheckedChange:f=>n(f?null:[]),"aria-label":s("ui.agents.detail.tools.every_tool_aria")}),t.jsx("span",{children:s("ui.agents.detail.tools.all_label")})]}),e===null?t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.detail.tools.may_use_any")}):t.jsxs(t.Fragment,{children:[e.length>0?t.jsx("ul",{className:"flex flex-wrap gap-1.5",children:e.map(f=>t.jsx("li",{children:t.jsxs(ke,{variant:"outline",children:[f,t.jsx(C,{variant:"ghost",size:"sm","aria-label":`Remove ${f}`,onClick:()=>n(e.filter(g=>g!==f)),className:"ms-1 h-4 px-1",children:"×"})]})},f))}):t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.detail.tools.empty")}),t.jsxs("div",{className:"flex items-end gap-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx(Se,{label:"Add a tool",htmlFor:h,error:o??a}),t.jsx(qe,{id:h,value:l,inputSize:"md",placeholder:s("ui.agents.detail.tools.placeholder"),"aria-invalid":!!(o??a),onChange:f=>{i(f.target.value),u(null)},onKeyDown:f=>{f.key==="Enter"&&(f.preventDefault(),v())}})]}),t.jsx(C,{variant:"secondary",onClick:v,disabled:!l.trim(),children:s("ui.agents.detail.tools.add")})]})]})]})}function Xi({profile:e,displayedName:n,classNotice:a,onClassNotice:l,teams:i,effortTiers:o,askEnabled:u,onSaved:h,onDuplicate:v,onOpenTeam:f,onAskAgent:g,onDirtyChange:c,belowHeader:w}){Z();const[d,x]=r.useState(!1),[N,E]=r.useState(()=>Re(e)),[k,b]=r.useState(()=>Re(e)),[S,L]=r.useState(!1),[F,p]=r.useState(null),[j,P]=r.useState(null),[D,y]=r.useState(!1),[A,U]=r.useState(!1),[H,Y]=r.useState(!1),Q=r.useRef(null),K=r.useRef(e.definition_revision),ae=qt(),q=JSON.stringify(k)!==JSON.stringify(N);r.useEffect(()=>(c?.(d&&q),()=>c?.(!1)),[c,d,q]),r.useEffect(()=>{fn()&&requestAnimationFrame(()=>Q.current?.focus())},[]),r.useEffect(()=>{if(d&&q)return;const R=Re(e);E(R),b(R)},[e,d,q]),r.useEffect(()=>{if(!d){U(!1);return}const R=Re(e);U(q&&JSON.stringify(R)!==JSON.stringify(N))},[e,d,q,N]);const me=()=>{x(!1),p(null),P(null),y(!1),Y(!1);const R=Re(e);E(R),b(R),K.current=e.definition_revision};Zt(()=>{if(H){Y(!1);return}q?Y(!0):me()},d);const oe=async R=>{if(R?.preventDefault(),S)return;const B=Yi(N,k);if(Object.keys(B).length===0){me();return}if(typeof B.instructions=="string"&&!B.instructions.trim()){p("Give the agent instructions."),P("instructions");return}L(!0),p(null),P(null);try{const ce=await le({op:"profiles.update",name:e.name,requestId:crypto.randomUUID(),fields:B,expectedDefinitionRevision:K.current});x(!1),y(!1);const re=Re(ce);E(re),b(re),K.current=ce.definition_revision,h(ce.name),Ne(s("ui.notices.agents.saved",{name:ce.name})),requestAnimationFrame(()=>Q.current?.focus())}catch(ce){const re=Ye(ce instanceof Error?ce.message:"The agent could not be saved.");p(re.message),P(re.field);const fe=ce?.status;if(ce?.code==="local-concurrent-edit"){U(!0),L(!1);return}const T=typeof fe=="number"&&fe!==408&&fe>=400&&fe<500;y(!T),T||rt(s("ui.notices.agents.save_unconfirmed"))}finally{L(!1)}},X=async()=>{if(!S){L(!0),p(null);try{const R=await le({op:"profiles.install",name:e.name,requestId:crypto.randomUUID()}),B=Re(R);E(B),b(B),h(R.name),Ne(s("ui.notices.agents.installed",{name:R.name})),requestAnimationFrame(()=>Q.current?.focus())}catch(R){const B=Ye(R instanceof Error?R.message:"The agent could not be installed.");p(B.message),rt(B.message)}finally{L(!1)}}},J=(i??[]).filter(R=>R.manager===e.name||(R.members??[]).some(B=>B.role===e.name)),te=e.source==="builtin";return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("header",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[t.jsxs("div",{className:"min-w-0 flex-[1_1_16rem] space-y-1",children:[t.jsx("h2",{ref:Q,tabIndex:-1,title:n,className:"truncate text-title focus:outline-none",children:n}),t.jsx(Ji,{profile:e})]}),d?null:t.jsxs("div",{className:W("flex shrink-0 items-center gap-2",Jt),children:[t.jsx(C,{variant:"primary",onClick:()=>{Bt.getState().stageDraft({kind:"agent",name:e.name}),ae("/chat")},children:s("ui.agents.detail.action.new_chat")}),te?t.jsxs(C,{variant:"secondary",onClick:X,disabled:S,children:[t.jsx(Na,{className:"size-4"}),S?"Installing…":"Install to edit"]}):t.jsx(C,{variant:"secondary",onClick:()=>{x(!0),p(null),P(null),K.current=e.definition_revision},children:s("ui.agents.detail.action.edit")}),u?t.jsx(C,{variant:"ghost",onClick:()=>g(`Change the agent ${e.name}: `),children:s("ui.agents.detail.action.ask_change")}):null,t.jsxs(Us,{children:[t.jsx(zs,{asChild:!0,children:t.jsx(C,{variant:"ghost",size:"icon","aria-label":s("ui.agents.detail.action.more_actions"),className:"-mr-2",children:t.jsx($s,{"aria-hidden":"true"})})}),t.jsx(Hs,{align:"end",children:t.jsx(Ks,{onSelect:()=>v(e),children:s("ui.agents.detail.action.duplicate")})})]})]})]}),te?t.jsxs(pe,{variant:"info",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.builtin_title")}),t.jsx(je,{children:s("ui.agents.detail.alert.builtin_body")})]}):null,A?t.jsxs(pe,{variant:"warning","data-testid":"agent-conflict",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.conflict_title")}),t.jsxs(je,{children:[t.jsx("span",{className:"block",children:s("ui.agents.detail.alert.conflict_body")}),t.jsx(C,{variant:"secondary",size:"sm",className:"mt-2",onClick:me,children:s("ui.agents.detail.alert.conflict_reload")})]})]}):null,D?t.jsxs(pe,{variant:"danger","data-testid":"agent-unconfirmed",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.unconfirmed_title")}),t.jsx(je,{children:s("ui.agents.detail.alert.unconfirmed_body")})]}):null,F&&!j?t.jsxs(pe,{variant:"danger",role:"alert","data-testid":"agent-save-error",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.save_failed_title")}),t.jsx(je,{children:F})]}):null]}),w,t.jsx("form",{noValidate:!0,onSubmit:R=>{R.preventDefault(),oe(R)},className:"space-y-8",children:d?t.jsxs(t.Fragment,{children:[t.jsx(ze,{title:s("ui.agents.detail.section.when_to_use"),description:"One sentence the model reads to decide when this agent is the right one.",label:"When to use this agent",value:k.description,error:j==="description"?F:null,onChange:R=>b(B=>({...B,description:R}))}),t.jsx(ze,{title:s("ui.agents.detail.section.instructions"),description:"What the agent is told to do. This is the agent's whole behaviour.",label:"Instructions",value:k.instructions,rows:12,required:!0,error:j==="instructions"?F:null,onChange:R=>b(B=>({...B,instructions:R}))}),t.jsx(G,{title:s("ui.agents.detail.section.tools"),children:t.jsx(hn,{tools:k.tools,error:j==="tools"?F:null,onChange:R=>b(B=>({...B,tools:R}))})}),t.jsx(G,{title:s("ui.agents.detail.section.delegation"),description:"Whether this agent may hand work to subagents, and which effort tier it runs at.",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(xt,{checked:k.delegate,onCheckedChange:R=>b(B=>({...B,delegate:R})),"aria-label":s("ui.agents.detail.delegate.aria")}),t.jsx("span",{children:s("ui.agents.detail.delegate.label")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Se,{label:"Effort tier",htmlFor:"agent-effort",error:j==="effort"?F:null}),t.jsx(dt,{ariaLabel:"Effort tier",showLabel:!1,placeholder:s("ui.agents.detail.field.effort_placeholder"),busyLabel:"Loading effort tiers",options:["inherit",...o].map(R=>({id:R,name:R,description:R==="inherit"?"Use the session's own effort":void 0})),selected:{id:k.effort,name:k.effort},onSelect:R=>b(B=>({...B,effort:R.id})),helperText:"Tiers come from the backend's subagent model settings."})]})]})}),t.jsx(bt,{submit:!0,confirming:H,onConfirmingChange:Y,dirty:q,pending:S,onSave:()=>void oe(),onCancel:me,saveLabel:"Save changes",dirtyHint:"Discard your unsaved changes to this agent?"})]}):t.jsxs(t.Fragment,{children:[t.jsx(G,{title:s("ui.agents.detail.section.when_to_use"),children:t.jsx(we,{text:e.description||"",empty:"No description yet — add one so a model knows when to pick this agent."})}),t.jsx(G,{title:s("ui.agents.detail.section.instructions"),children:t.jsx(we,{text:e.instructions??e.packaged_instructions??"",empty:"No instructions yet."})}),t.jsx(G,{title:s("ui.agents.detail.section.tools"),children:e.tools&&e.tools.length>0?t.jsx("ul",{className:"flex flex-wrap gap-1.5",children:e.tools.map(R=>t.jsx("li",{children:t.jsx(ke,{variant:"outline",children:R})},R))}):t.jsx(ke,{variant:"neutral",children:s("ui.agents.detail.tools.all_label")})}),t.jsxs(G,{title:s("ui.agents.detail.section.delegation"),children:[t.jsx("p",{className:"text-body-sm text-ink",children:e.delegate?"May hand work to subagents.":"Does its own work; it does not delegate."}),t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[s("ui.agents.detail.read.effort_label")," ",e.effort??"inherit"]}),e.effort&&J.length?t.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.models.pin_reach",{count:J.length,teams:J.map(R=>R.name).join(", ")})}):null]}),t.jsx(G,{title:s("ui.agents.detail.section.messaging"),description:"Reactive agents only reply. Proactive agents may also message you first.",children:t.jsx(Zi,{profile:e,displayedName:n,notice:a,onNotice:l,onChanged:h})}),t.jsx(G,{title:s("ui.agents.detail.section.used_by"),description:"Teams that name this agent as a manager or a member.",children:J.length>0?t.jsx("ul",{className:"flex flex-wrap gap-x-3 gap-y-1",children:J.map(R=>t.jsx("li",{children:t.jsx(C,{variant:"link",className:W("-my-0.5",Yt),onClick:()=>f(R.name),children:R.name})},R.id))}):t.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.detail.empty.used_by")})}),t.jsxs(G,{title:s("ui.agents.detail.section.origin"),description:e.source==="builtin"?"Shipped with the app.":e.source==="installed"?"Installed from a packaged starter.":"Created on this machine.",children:[t.jsxs("dl",{className:"space-y-1 text-body-sm",children:[e.seed_origin?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"text-ink-muted",children:s("ui.agents.detail.origin.source")}),t.jsx("dd",{className:"text-ink",children:e.seed_origin})]}):null,e.divergent_fields?.length?t.jsxs("div",{className:"flex gap-2",children:[t.jsx("dt",{className:"text-ink-muted",children:s("ui.agents.detail.origin.changed")}),t.jsx("dd",{className:"text-ink",children:e.divergent_fields.join(", ")})]}):null]}),e.packaged_instructions&&e.divergent_fields?.length?t.jsx(Ge,{summary:"Compare with the packaged instructions",className:"mt-2",children:t.jsx(we,{text:e.packaged_instructions,mono:!0})}):null]})]})})]})}function ze({title:e,description:n,label:a,value:l,onChange:i,rows:o,required:u,error:h,fieldRef:v}){const f=r.useId();return t.jsxs(G,{title:e,description:n,children:[t.jsx(Se,{label:a,htmlFor:f,error:h}),o?t.jsx(Lt,{id:f,ref:v,value:l,rows:o,required:u,"aria-invalid":!!h,className:W("min-h-0"),onChange:g=>i(g.target.value)}):t.jsx(qe,{id:f,value:l,"aria-invalid":!!h,onChange:g=>i(g.target.value)})]})}function el({initial:e,takenNames:n,effortTiers:a,onDirtyChange:l,onSaved:i,onCancel:o}){Z();const[u,h]=r.useState(()=>e?Qa(e.name,n):""),[v,f]=r.useState(e?.kind??"role"),[g,c]=r.useState(()=>e?{...Re(e),description:e.description??""}:{description:"",instructions:"",tools:null,effort:"inherit",delegate:!1}),[w,d]=r.useState(!1),[x,N]=r.useState(null),[E,k]=r.useState(null),b=r.useRef(null),S=r.useRef(null);r.useEffect(()=>(l?.(!!(u.trim()||g.instructions.trim())),()=>l?.(!1)),[l,u,g.instructions]),r.useEffect(()=>{b.current?.focus(),b.current?.select()},[]);const L=async p=>{if(p?.preventDefault(),!w){if(!u.trim()){N("Give the agent a name."),k("name"),b.current?.focus();return}if(/[\\/\s]/.test(u.trim())){N("Names cannot contain spaces or slashes."),k("name"),b.current?.focus();return}if(n.includes(u.trim())){N(`An agent called “${u.trim()}” already exists. Choose another name, or open the existing one to change it.`),k("name"),b.current?.focus();return}if(!g.instructions.trim()){N("Give the agent instructions."),k("instructions"),S.current?.focus();return}d(!0),N(null),k(null);try{const j=await le({op:"profiles.create",requestId:crypto.randomUUID(),name:u.trim(),fields:{kind:v,description:g.description,instructions:g.instructions,tools:g.tools??[],effort:g.effort,delegate:g.delegate}});Ne(s("ui.notices.agents.created_named",{name:j.name})),mn(),i(j.name)}catch(j){const P=Ye(j instanceof Error?j.message:"The agent could not be created.");N(P.message),k(P.field)}finally{d(!1)}}},F=e?"Duplicate as a new agent":"New agent";return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("header",{className:"space-y-2",children:[t.jsx("h2",{className:"text-title",children:F}),t.jsx("p",{className:"text-body-sm text-ink-muted",children:e?`A copy of ${e.name}. It is a separate agent: changing it does not change the original.`:"Reusable instructions shared by agent commands, subagents and teams. Chats stay separate."})]}),x&&!E?t.jsxs(pe,{variant:"danger",role:"alert","data-testid":"agent-create-error",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.save_failed_title")}),t.jsx(je,{children:x})]}):null,t.jsxs("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),L(p)},className:"space-y-8",children:[t.jsx(G,{title:s("ui.agents.detail.section.name_role"),children:t.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx(Se,{label:"Name",htmlFor:"agent-create-name",error:E==="name"?x:null}),t.jsx(qe,{id:"agent-create-name",ref:b,value:u,required:!0,"aria-invalid":E==="name",onChange:p=>h(p.target.value)})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Se,{label:"How it works with others",htmlFor:"agent-create-kind"}),t.jsxs(st,{value:v,onValueChange:p=>f(p),children:[t.jsx(nt,{id:"agent-create-kind",children:t.jsx(at,{})}),t.jsxs(it,{children:[t.jsx(Ie,{value:"role",children:s("ui.agents.detail.kind.role")}),t.jsx(Ie,{value:"specialist",children:s("ui.agents.detail.kind.specialist")})]})]})]})]})}),t.jsx(ze,{title:s("ui.agents.detail.section.when_to_use"),description:"One sentence the model reads to decide when this agent is the right one.",label:"When to use this agent",value:g.description,error:E==="description"?x:null,onChange:p=>c(j=>({...j,description:p}))}),t.jsx(ze,{title:s("ui.agents.detail.section.instructions"),description:"What the agent is told to do. This is the agent's whole behaviour.",label:"Instructions",value:g.instructions,rows:12,required:!0,fieldRef:S,error:E==="instructions"?x:null,onChange:p=>c(j=>({...j,instructions:p}))}),t.jsx(G,{title:s("ui.agents.detail.section.delegation"),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(xt,{checked:g.delegate,onCheckedChange:p=>c(j=>({...j,delegate:p})),"aria-label":s("ui.agents.detail.delegate.aria")}),t.jsx("span",{children:s("ui.agents.detail.delegate.label")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx(Se,{label:"Effort tier",htmlFor:"agent-create-effort"}),t.jsx(dt,{ariaLabel:"Effort tier",showLabel:!1,busyLabel:"Loading effort tiers",placeholder:s("ui.agents.detail.field.effort_placeholder"),options:["inherit",...a].map(p=>({id:p,name:p,description:p==="inherit"?"Use the session's own effort":"A tier configured in Settings"})),selected:{id:g.effort,name:g.effort},onSelect:p=>c(j=>({...j,effort:p.id}))})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("span",{className:"text-body-sm text-ink-muted",children:s("ui.agents.detail.section.tools")}),t.jsx(hn,{tools:g.tools,error:E==="tools"?x:null,onChange:p=>c(j=>({...j,tools:p}))})]})]})}),t.jsx(bt,{submit:!0,dirty:!!(u.trim()||g.instructions),pending:w,saveLabel:e?"Create the copy":"Create agent",pendingLabel:"Creating…",dirtyHint:"Discard this new agent?",onSave:()=>void L(),onCancel:o})]})]})}function pn(e,n,a=Date.now()){const l=Date.parse(e.expires_at);return e.local_fingerprint.length>0&&e.proposal_fingerprint.length>0&&e.link_id===n.link_id&&(e.direction==="push"||e.remote_fingerprint.length>0)&&e.proposal.kind===n.kind&&e.hub_source===n.hub_source&&e.visibility===n.visibility&&e.tenant_id===n.tenant_id&&e.expected_policy_revision===n.policy.revision&&e.expected_remote_revision===n.remote_revision&&Number.isFinite(l)&&l>a}function ks(e,n,a=Date.now()){return e.can_confirm&&e.preview_receipt.length>0&&pn(e,n,a)}const Et=e=>Number.isFinite(Date.parse(e))?In(new Date(e)):s("ui.hub.status.unknown"),tl=e=>[e.pull.state,e.push.state].some(n=>["checking","merging","applying","pushing"].includes(n));function sl({link:e}){Z();const n=Vn(e.link_id),a=ft(e),l=Gn(e),[i,o]=r.useState(null),[u,h]=r.useState(null),[v,f]=r.useState(null),[g,c]=r.useState(!1),[w,d]=r.useState(!1),x=r.useRef(null),N=r.useId(),E=n.isPending||tl(e),k=!ss(e.baseline_state),b=i??u;r.useEffect(()=>{b&&!pn(b,e)&&(o(null),h(null),d(!0))},[e,b]),r.useEffect(()=>{if(!b)return;const p=Date.parse(b.expires_at)-Date.now(),j=setTimeout(()=>{o(null),h(null),d(!0)},Math.max(0,Math.min(p,2147483647)));return()=>clearTimeout(j)},[b]);const S=p=>{E||(p.action==="preview"&&d(!1),n.mutate(p,{onSuccess:j=>{if(p.action==="preview")o(j.preview?.direction==="push"?j.preview:null);else if(p.action==="apply"&&p.preview){const P=j.preview?.direction==="pull"?j.preview:null;h(P),f(JSON.stringify(j.reports,null,2)),c(P?.choices.acknowledge_unknown_baseline??!1)}else o(null),h(null)},onError:j=>{j instanceof ut&&["publication-preview-changed","application-preview-changed","remote-revision-changed"].includes(j.code??"")&&(o(null),h(null),d(!0))}}))},L=()=>{n.isPending||(o(null),h(null))},F=p=>s(p==="pull"?"ui.hub.links.direction_pull":"ui.hub.links.direction_push");return t.jsxs("section",{className:"flex min-w-0 flex-col gap-4 py-4","data-hub-link":e.link_id,children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"break-words text-heading text-ink",children:a}),t.jsx("p",{className:"break-words text-meta text-ink-muted",children:e.name}),t.jsx("p",{className:"break-all text-meta text-ink-dim",children:s("ui.hub.links.source_address",{address:e.hub_source})})]}),t.jsx(Bs,{link:e}),t.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:["pull","push"].map(p=>{const j=e[p];return t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1","data-hub-direction":p,children:[t.jsx("h4",{className:"text-body-sm text-ink",children:F(p)}),t.jsx("p",{className:W("text-body-sm",j.state==="failed"?"text-danger":j.state==="available"?"text-accent":"text-ink-muted"),children:Yn(j)}),j.error_class&&t.jsx("p",{className:"text-meta text-warning",children:Rt(j.error_class)}),j.last_checked_at&&t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.status.last_checked",{time:Et(j.last_checked_at)})}),j.last_success_at&&t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.last_success",{time:Et(j.last_success_at)})}),j.next_retry_at&&t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.status.next_retry",{time:Et(j.next_retry_at)})}),j.model_used&&t.jsx("p",{className:"break-words text-meta text-ink-muted",children:s("ui.hub.links.actual_model",{model:j.model_used})}),j.operation_id&&t.jsx("p",{className:"break-all text-meta text-ink-dim",children:s("ui.hub.status.receipt",{operation:j.operation_id})}),l[p].retryable&&(p==="pull"||e.policy.auto_push)&&t.jsx(C,{variant:"outline",size:"sm",disabled:E||!n.canWrite,onClick:()=>S({action:"retry",linkId:e.link_id,direction:p}),children:s("ui.hub.links.retry")})]},p)})}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(C,{variant:"outline",size:"sm",disabled:E||!n.canWrite,onClick:()=>S({action:"check",linkId:e.link_id}),children:s("ui.hub.subscriptions.check")}),t.jsx(C,{variant:"outline",size:"sm",disabled:E||!n.canWrite||e.kind==="skill"&&Mt(e)==="absent",onClick:()=>S({action:"apply",linkId:e.link_id,preview:!0}),children:s("ui.hub.links.preview_pull")}),t.jsx(C,{variant:"outline",size:"sm",disabled:E||!n.canWrite||!e.remote_revision||!ss(e.baseline_state)||e.visibility==="org"&&!e.tenant_name,onClick:()=>S({action:"preview",linkId:e.link_id}),children:s("ui.hub.subscriptions.preview_publish")})]}),w&&t.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.links.preview_changed")}),n.error&&t.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:n.error instanceof It?n.error.message:s("ui.hub.links.action_failed",{direction:F(n.variables?.action==="preview"||n.variables?.action==="confirm"?"push":"pull"),item:e.name,source:a})}),n.data?.reports.filter(p=>p.link_id===e.link_id).map((p,j)=>t.jsx("output",{className:"text-meta text-ink-muted",children:s("ui.hub.links.action_result",{direction:F(p.direction),item:e.name,source:a,outcome:p.outcome})},`${p.operation_id??p.direction}-${j}`)),t.jsx(Ut,{open:i!==null||u!==null,onOpenChange:p=>{p||L()},children:t.jsxs(zt,{className:"max-w-3xl",closeDisabled:n.isPending,onOpenAutoFocus:p=>{p.preventDefault(),x.current?.focus()},onEscapeKeyDown:p=>{n.isPending&&p.preventDefault()},children:[t.jsxs(Ht,{children:[t.jsx(Kt,{children:i?s("ui.hub.links.preview_payload",{source:a}):s("ui.hub.links.preview_pull")}),t.jsx(Wt,{children:i||!k?s("ui.hub.subscriptions.enable_safety"):s("ui.hub.links.unknown_baseline")})]}),t.jsx("pre",{className:"max-h-[50vh] overflow-auto whitespace-pre-wrap break-words rounded-md bg-sunken p-3 text-mono-sm text-ink",children:JSON.stringify(b?.proposal,null,2)}),b?.warnings.length?t.jsxs("div",{children:[t.jsx("h4",{className:"text-body-sm text-ink",children:s("ui.hub.links.preview_warnings")}),b.warnings.map((p,j)=>t.jsx("p",{className:"break-words text-body-sm text-warning",children:p},`${j}-${p}`))]}):null,b?.reason&&t.jsx("p",{className:"text-body-sm text-warning",children:Rt(b.reason)}),u&&v&&t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words bg-sunken p-3 text-mono-sm text-ink",children:v}),u&&k&&t.jsxs("label",{htmlFor:N,className:"flex items-start gap-2 text-body-sm text-ink",children:[t.jsx(ua,{id:N,checked:g,onCheckedChange:p=>c(p===!0)}),s("ui.hub.links.acknowledge_baseline")]}),n.error&&t.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:n.error instanceof It?n.error.message:s("ui.hub.links.action_failed",{direction:F(i?"push":"pull"),item:e.name,source:a})}),t.jsxs(Vt,{children:[t.jsx(C,{ref:x,variant:"outline",disabled:n.isPending,onClick:L,children:s("ui.hub.subscriptions.cancel")}),i?t.jsx(C,{disabled:n.isPending||!n.canWrite||!ks(i,e),onClick:()=>S({action:"confirm",linkId:e.link_id,previewReceipt:i.preview_receipt}),children:s("ui.hub.links.confirm_publish")}):t.jsxs(t.Fragment,{children:[["local","remote"].map(p=>t.jsx(C,{variant:"outline",disabled:n.isPending||!n.canWrite||k&&!g,onClick:()=>S({action:"apply",linkId:e.link_id,preview:!0,prefer:p,acknowledgeUnknownBaseline:k&&g}),children:s(p==="local"?"ui.hub.links.prefer_local":"ui.hub.links.prefer_remote")},p)),t.jsx(C,{disabled:n.isPending||!n.canWrite||!u||!ks(u,e)||u.choices.acknowledge_unknown_baseline!==g||u.choices.replace!==null||u.choices.confirm_replace,onClick:()=>{u&&S({action:"apply",linkId:e.link_id,previewReceipt:u.preview_receipt,confirmApply:!0,prefer:u.choices.prefer??void 0,acknowledgeUnknownBaseline:u.choices.acknowledge_unknown_baseline})},children:s("ui.hub.subscriptions.pull")})]})]})]})})]})}function nl({row:e,source:n,organizations:a,isAuthenticated:l,onSignIn:i,initialOpen:o,onResolved:u}){Z();const[h,v]=r.useState(o??!1),[f,g]=r.useState(""),c=Wn(u),w=r.useRef(null),d=r.useRef(null),x=r.useRef(!1);r.useEffect(()=>{h?w.current?.focus():x.current&&(x.current=!1,d.current?.focus())},[h]);const N=f!=="public"&&f!=="",E=N?a.find(S=>S.tenant_id===f):null,b=f!==""&&(!N||!!E)&&(N||f==="public");return t.jsxs("section",{className:"flex min-w-0 flex-col gap-3","data-hub-source-unresolved":e.local_id,children:[t.jsx(pe,{variant:"warning",className:"p-4",children:t.jsxs("div",{className:"flex flex-col gap-3",children:[c.upgradeMessage&&t.jsx("output",{className:"block text-meta text-warning","data-hub-core-upgrade":!0,children:c.upgradeMessage}),t.jsx(xe,{"data-hub-unresolved-label":!0,children:s("ui.hub.links.source_not_confirmed")}),t.jsx("h3",{className:"break-words text-body-sm font-medium text-ink",children:e.name}),t.jsx("p",{className:"text-body-sm text-ink",children:s("ui.hub.links.unresolved_what",{item:e.name})}),t.jsx("p",{className:"text-body-sm text-ink",children:s("ui.hub.links.unresolved_why",{item:e.name})}),t.jsx("p",{className:"text-body-sm text-ink",children:s("ui.hub.links.unresolved_next")}),t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.source_address",{address:n})}),t.jsx("p",{className:"break-all text-mono-sm text-ink-muted",children:s("ui.hub.links.hub_id",{address:e.hub_id})}),t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.resolve_irreversible")}),h?null:t.jsx(C,{ref:d,variant:"primary",size:"sm",className:"self-start",onClick:()=>v(!0),children:s("ui.hub.links.resolve_action")})]})}),h?t.jsxs("div",{ref:w,tabIndex:-1,className:"flex flex-col gap-2 outline-none",children:[t.jsx("h4",{className:"text-body-sm text-ink",children:s("ui.hub.links.resolve_title")}),t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.resolve_description",{item:e.name})}),l?t.jsxs("label",{className:"text-body-sm text-ink",children:[s("ui.hub.links.scope_label"),t.jsxs("select",{className:"mt-1 w-full rounded-md border border-control bg-surface px-2 py-1 text-body-sm text-ink",value:f,disabled:c.isPending,onChange:S=>g(S.target.value),children:[t.jsx("option",{value:"",disabled:!0,children:s("ui.hub.links.scope_placeholder")}),t.jsx("option",{value:"public",children:s("ui.hub.links.scope_public")}),a.map(S=>t.jsx("option",{value:S.tenant_id,children:s("ui.hub.links.scope_private",{organization:S.tenant_name})},S.tenant_id))]})]}):t.jsx(C,{variant:"outline",onClick:i,children:s("ui.hub.links.sign_in_to_publish")}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(C,{variant:"outline",disabled:c.isPending,onClick:()=>{x.current=!0,v(!1)},children:s("ui.hub.subscriptions.cancel")}),t.jsx(C,{disabled:c.isPending||!c.canWrite||!b,onClick:()=>c.mutate({kind:e.kind,localId:e.local_id,name:e.name,hubSource:n,visibility:N?"org":"public",tenantId:N?E?.tenant_id??null:null}),children:c.isPending?s("ui.hub.links.resolve_action_confirming"):c.isSuccess?s("ui.hub.links.resolve_action_done"):s("ui.hub.links.resolve_action_confirm")})]}),!b&&!c.isPending&&l?t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.scope_required")}):null,c.error?t.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:c.error instanceof It?c.error.message:c.error instanceof ut&&c.error.code==="origin-conflict"?s("ui.hub.links.resolve_conflict"):c.error instanceof ut&&c.error.code?Rt(c.error.code):s("ui.hub.links.resolve_failed_generic")}):null]}):null]})}function al({enabled:e,kind:n,name:a,localId:l}){Z();const i=Pt(e),{isAuthenticated:o}=Ot(),u=qt(),[h]=Ds(),v=h.get("resolve"),f=v!==null,{memberships:g}=Ms({enabled:e&&o}),c=Ws(g).map(y=>({tenant_id:y.tenant_id,tenant_name:y.tenant_name})),w=Rn.radientBaseUrl;if(!e)return null;const d=n&&a?Kn(i.data,n,l,a):i.data?.links.filter(y=>!n||y.kind===n)??[],x=(i.data?.unresolved??[]).filter(y=>(!n||y.kind===n)&&(!a||(l?y.local_id===l:y.name===a))),N=y=>s(y?"ui.hub.subscriptions.configured_on":"ui.hub.subscriptions.configured_off"),E=y=>{const A=d[0]?y(d[0]):!1;return d.every(U=>y(U)===A)},k=y=>E(y)?N(y(d[0])):s("ui.hub.links.mixed"),b=(()=>{if(d.length===0)return"";const y=d[0],A=d.length>1?` · ${s("ui.hub.links.sources_count",{count:d.length})}`:"";return`${ft(y)}${A} · ${s("ui.hub.subscriptions.subscribe")} ${k(U=>U.policy.subscribe)} · ${s("ui.hub.subscriptions.auto_push")} ${k(U=>U.policy.auto_push)}`})(),S=d.some(y=>[y.pull.state,y.push.state].some(A=>A==="available"||A==="failed")),L=r.useRef(null),[F,p]=r.useState(!1);r.useEffect(()=>{!F||d.length===0||(L.current?.querySelector("button[aria-expanded]")?.focus(),p(!1))},[F,d]);const[j,P]=r.useState(S),D=r.useRef(S);return r.useEffect(()=>{S&&!D.current&&P(!0),D.current=S},[S]),i.isLoading?null:i.error&&!i.data?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:s("ui.hub.links.load_failed")}),t.jsx(C,{variant:"outline",size:"sm",onClick:()=>void i.refetch(),children:s("ui.hub.links.retry")})]}):d.length===0&&x.length===0?null:t.jsxs("div",{ref:L,className:"flex min-w-0 flex-col gap-3","data-hub-links-panel":!0,children:[x.map(y=>t.jsx(nl,{row:y,source:w,organizations:c,isAuthenticated:o,onSignIn:()=>u("/settings"),initialOpen:f,onResolved:()=>p(!0)},`${y.kind}:${y.local_id}:${v}`)),d.length>0?t.jsxs(Ge,{open:j,onOpenChange:P,summary:`${s("ui.hub.links.title")} · ${b}`,className:"min-w-0",children:[t.jsx("div",{className:"divide-y divide-hairline",children:d.map(y=>t.jsx(sl,{link:y},y.link_id))}),i.error&&i.data&&t.jsx("p",{role:"alert",className:"text-meta text-warning",children:s("ui.hub.links.load_failed")})]}):null]})}const il={builtin:"ui.agents.skills.source.builtin",hub:"ui.agents.skills.source.hub",local:"ui.agents.skills.source.local",external:"ui.agents.skills.source.external",project:"ui.agents.skills.source.project"},ll={builtin:"ui.agents.skills.where.builtin",hub:"ui.agents.skills.where.hub",local:"ui.agents.skills.where.local",external:"ui.agents.skills.where.external",project:"ui.agents.skills.where.project"};function Xt(e){return s(e?il[e]:"ui.agents.skills.source.unknown")}const js={failed:{key:"ui.agents.skills.hub.update_failed",ink:"text-danger"},available:{key:"ui.hub.skills.update_available",ink:"text-accent"},applied:{key:"ui.hub.skills.update_applied",ink:"text-success"},modified:{key:"ui.agents.detail.badge.modified",ink:"text-warning"},"not-installed":{key:"ui.agents.skills.state.not_installed",ink:"text-ink"},"updates-off":{key:"ui.agents.skills.state.updates_off",ink:"text-ink"},unlinked:{key:"ui.agents.skills.hub.unlinked",ink:"text-ink"}},rl=new Set(["failed","available","applied"]),ol={following:"ui.agents.skills.state.following","updates-off":"ui.agents.skills.state.updates_off","not-installed":"ui.agents.skills.state.not_installed","hub-unknown":"ui.agents.skills.state.hub_unknown",unlinked:"ui.agents.skills.hub.unlinked","read-only":"ui.agents.skills.state.read_only"},cl={all:"ui.agents.pages.scope.all",local:"ui.agents.skills.scope.local",hub:"ui.agents.skills.scope.hub",builtin:"ui.agents.skills.scope.builtin"},ul={local:"ui.agents.skills.empty.local",hub:"ui.agents.skills.empty.hub",builtin:"ui.agents.skills.empty.builtin"};function xn(e){return e?ba(e.state,e.update,e.link?Mt(e.link)==="present":!1):null}function dl({cards:e,selected:n,join:a,marked:l,onOpen:i}){Z();const o=r.useRef(new Map),[u,h]=r.useState(n),v=(f,g)=>{const c=e.findIndex(d=>d.name===f);if(c<0)return;const w=e[Math.min(e.length-1,Math.max(0,c+g))];w&&(h(w.name),o.current.get(w.name)?.focus())};return t.jsx("ul",{"aria-label":s("ui.agents.skills.list_aria"),className:"space-y-0.5","data-skills-roster":!0,children:e.map(f=>{const g=a(f),c=xn(g),w=Oi(f,g,c?.kind??null),d=l?.get(`skill:${f.name}`);return t.jsx("li",{children:t.jsxs("button",{ref:x=>{x?o.current.set(f.name,x):o.current.delete(f.name)},type:"button","aria-current":f.name===n?"true":void 0,tabIndex:f.name===(u??e[0]?.name)?0:-1,"data-testid":`skill-row-${f.name}`,"data-skill-source":f.source??"unknown","data-skill-state":w??void 0,"data-skill-installed":f.installed?"true":"false",title:f.description?`${f.name} - ${f.description}`:f.name,className:W("flex min-h-12 w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-start hover:bg-row-hover",f.name===n&&ot),onFocus:()=>h(f.name),onClick:()=>i(f.name),onKeyDown:x=>{x.key==="ArrowDown"?(x.preventDefault(),v(f.name,1)):x.key==="ArrowUp"?(x.preventDefault(),v(f.name,-1)):x.key==="Home"?(x.preventDefault(),v(f.name,-e.length)):x.key==="End"&&(x.preventDefault(),v(f.name,e.length))},children:[t.jsxs("span",{className:"flex w-full items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:f.name}),d!==void 0?t.jsx(ke,{variant:"attention","data-testid":"skill-row-updated",children:s(d?"ui.agents.skills.badge.new":"ui.agents.skills.badge.updated")}):null,t.jsx("span",{className:"ms-auto max-w-[45%] shrink-0 truncate text-meta text-ink-dim","data-testid":"skill-row-source",children:Xt(f.source)})]}),t.jsxs("span",{className:"block min-h-lh w-full min-w-0 truncate text-meta text-ink-muted","data-testid":"skill-row-line2",children:[w?t.jsxs("span",{"data-testid":"skill-row-state",children:[c&&rl.has(w)?t.jsx(Vs,{mark:c,labels:bn,className:"inline-flex align-middle"}):t.jsx("span",{className:js[w].ink,children:s(js[w].key)}),t.jsx("span",{className:"text-ink-dim",children:" · "})]}):null,f.description?f.description:t.jsx("span",{className:"text-ink-dim",children:s("ui.agents.detail.no_description")})]})]})},f.name)})})}function ml({loading:e,failed:n,cards:a,total:l,search:i,scope:o="all",selected:u,join:h,marked:v,onOpen:f}){return Z(),n?null:e?t.jsx(gn,{}):a.length===0?t.jsx("p",{className:"px-1 py-2 text-body-sm text-ink-muted","data-testid":"skills-empty","data-skills-empty":l===0?"none":i.trim()?"no-match":"scope",children:l===0?s("ui.agents.skills.empty.none"):i.trim()?s("ui.agents.skills.empty.search",{query:i}):o!=="all"?s(ul[o]):s("ui.agents.skills.empty.none")}):t.jsx(dl,{cards:a,selected:u,join:h,marked:v,onOpen:f})}const bn={failed:"ui.agents.skills.hub.update_failed",review:"ui.agents.skills.hub.needs_review"};function kn(e,n){const a=r.useRef(!1),l=r.useRef(!1),i=r.useRef(null);return r.useEffect(()=>{if(a.current){if(n){l.current=!0;return}l.current&&(l.current=!1,a.current=!1,e&&requestAnimationFrame(()=>{const o=document.activeElement;if(!(!o||o===document.body||!!i.current?.contains(o)))return;const h=i.current?.querySelector("button");h&&!h.disabled&&h.focus()}))}},[e,n]),{holder:i,onPress:()=>{a.current=!0}}}function ys(e){return e<1e3?s("ui.agents.skills.detail.file_bytes",{count:e}):Ln(e)}const vs={builtin:["ui.agents.skills.alert.builtin_title","ui.agents.skills.alert.builtin_body"],external:["ui.agents.skills.alert.external_title","ui.agents.skills.alert.external_body"],project:["ui.agents.skills.alert.project_title","ui.agents.skills.alert.project_body"],bundle:["ui.agents.skills.alert.bundle_title","ui.agents.skills.alert.bundle_body"]};function fl(e,n,a,l){if(e.kind!=="read-only"||e.reason==="unknown")return null;if(e.reason==="bundle")return a?["ui.agents.skills.alert.too_large_title","ui.agents.skills.alert.too_large_body"]:n.source==="hub"?vs.bundle:["ui.agents.skills.alert.bundle_title","ui.agents.skills.alert.bundle_local_body"];const[i,o]=vs[e.reason];return l?[i,o]:[i,hl[e.reason]]}function gl(e,n){return{requestId:n,remoteId:e.hub_id,scope:e.visibility==="org"&&e.tenant_id?{visibility:"org",tenantId:e.tenant_id,organization:e.tenant_name}:{visibility:"public",tenantId:null,organization:null},alias:e.name,subscribe:e.policy.subscribe,autoPush:e.policy.auto_push,consent:!1}}const hl={builtin:"ui.agents.skills.alert.builtin_body_no_copy",external:"ui.agents.skills.alert.external_body_no_copy",project:"ui.agents.skills.alert.project_body_no_copy"};function pl(e,n){const a=s("ui.agents.publication.subject.name",{name:n.trim()}),l=xl(e);return l===404?s("ui.agents.publication.pull.not_found",{subject:a}):l===401||l===403?s("ui.agents.publication.pull.sign_in_refused",{subject:a}):l===409?Tt(e)?.startsWith("bundle-")?s("ui.agents.publication.pull.refused_download",{subject:a}):s("ui.agents.skills.error.download_failed_body"):l===422?s("ui.agents.publication.pull.refused_download",{subject:a}):l===429?s("ui.agents.publication.pull.busy",{subject:a}):s("ui.agents.skills.error.download_failed_body")}function Tt(e){const n=e?.code;return typeof n=="string"?n:null}function xl(e){const n=e?.status;return typeof n=="number"?n:null}function bl({name:e,card:n,join:a,detail:l,onRetry:i,writesEnabled:o=!1,askEnabled:u=!1,onAsk:h,belowHeader:v,onDirtyChange:f,onRemoved:g,hubSignedIn:c=!1,downloadEnabled:w=!1}){Z();const d=r.useRef(null),x=kn(!!l.error,l.isFetching),N=Ki(),E=xa({retry:0});r.useEffect(()=>{const $=document.activeElement,m=!$||$===document.body,M=window.matchMedia("(max-width: 999px)").matches;(m||M&&$?.closest("[data-skills-roster]"))&&requestAnimationFrame(()=>d.current?.focus())},[]);const k=l.data?.skill_detail??null,b=n??(k?sn(k):null),S=wi(l.data?.detail,k),L=S===null?null:nn(S),F=()=>({description:(k?k.description:b?.description)??"",instructions:L?.text??""}),[p,j]=r.useState(!1),[P,D]=r.useState(F),[y,A]=r.useState(F),[U,H]=r.useState(!1),[Y,Q]=r.useState(!1),K=r.useRef(null),[ae,q]=r.useState(null),[me,z]=r.useState("write"),oe=r.useRef(!1),[X,J]=r.useState(null),te=y.description!==P.description||y.instructions!==P.instructions,R=`${(k?k.description:b?.description)??""}\0${L?.text??""}`;r.useEffect(()=>{if(p)return;const $=F();D($),A($)},[R,p,te]),r.useEffect(()=>(f?.(p&&te),()=>f?.(!1)),[f,p,te]);const B=()=>{j(!1),H(!1),Q(!1),q(null);const $=F();D($),A($)};if(Zt(()=>{if(U){H(!1);return}te?H(!0):B()},p),l.error)return t.jsx("div",{ref:x.holder,children:t.jsx(lt,{title:s("ui.agents.skills.error.detail_title",{name:e}),what:l.error.message,meaning:s("ui.agents.skills.error.detail_meaning"),onRetry:()=>{x.onPress(),i()},retrying:l.isFetching,retryLabel:s("ui.common.actions.retry"),retryingLabel:s("ui.agents.skills.retrying")})});if(!b)return l.isLoading?t.jsx(mt,{}):null;const re=a(b),fe=xn(re),ge=ln(re),T=Pi(b,re),be=k?.files??[],Ee=k?.files_total??be.length,ue=re?.link?.local_path??null,_=!!k&&!l.isLoading,I=xs(b,k),se=o&&I.kind==="edit"&&S!==null&&!!k?.fingerprint,V=se&&!l.isFetching,O=u&&(I.kind==="edit"||I.kind==="ask")&&!!h,$e=o&&I.kind==="read-only"&&I.copy,he=b.source==="hub"&&!b.installed&&re?.link&&Mt(re.link)==="absent"?re.link:null,de=w&&he!==null,He=o&&b.installed&&(b.source==="local"||b.source==="hub")&&I.kind!=="not-installed",ye=b.source==="hub",Le=Li(L?.meta??null),Ce=fl(I,b,!!k?.body_truncated,$e),De=_&&I.kind==="ask"&&o?s(I.reason==="files"?O?"ui.agents.skills.detail.edit_by_asking":"ui.agents.skills.detail.edit_off_files":O?"ui.agents.skills.detail.edit_by_asking_truncated":"ui.agents.skills.detail.edit_off_truncated"):null,Ae=async()=>{if(!(!he||!c||E.isPending||oe.current)){oe.current=!0,q(null),z("download");try{if(!(await E.mutateAsync(gl(he,crypto.randomUUID()))).reports?.some(m=>m.applied||m.outcome==="unchanged")){q(s("ui.hub.skills.pull_failed"));return}Ne(s("ui.hub.skills.installed_alias",{item:he.name,source:ft(he)})),requestAnimationFrame(()=>d.current?.focus())}catch($){q(pl($,he.name))}finally{oe.current=!1}}},Oe=async()=>{const $=K.current;if(!(N.update.isPending||$===null)){if(!te){B();return}if(k?.fingerprint!==$.fingerprint||xs(b,k).kind!=="edit"){Q(!0);return}q(null),z("write");try{await N.update.mutateAsync({name:b.name,linkId:b.source==="hub"?b.linkId:null,expectedFingerprint:$.fingerprint,skillMd:Ai($.body,b.name,y.description===P.description?null:y.description,y.instructions)}),j(!1),H(!1),D(y),Ne(s("ui.agents.skills.notice.saved",{name:b.name})),requestAnimationFrame(()=>d.current?.focus())}catch(m){if(Tt(m)==="skill_stale"){Q(!0);return}q(Be(m,s("ui.agents.skills.error.write_fallback")))}}},Fe=async()=>{q(null),z("write");try{await N.copy.mutateAsync(b.name),Ne(s("ui.agents.skills.notice.copied",{name:b.name}))}catch($){q(Be($,s("ui.agents.skills.error.write_fallback")))}},Ke=async $=>{q(null),z("write");try{await N.remove.mutateAsync({name:b.name,discardLocalChanges:$}),J(null),g?.(b.name,ye)}catch(m){if(!$&&Tt(m)==="skill_local_changes_unpublished"){J("unpublished");return}J(null),q(Be(m,s("ui.agents.skills.error.write_fallback")))}};return t.jsxs("div",{className:"space-y-8","data-testid":"skill-detail","data-skill":b.name,"data-skill-editability":_?I.kind:void 0,children:[t.jsxs("header",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[t.jsxs("div",{className:"min-w-0 flex-[1_1_16rem] space-y-1",children:[t.jsx("h2",{ref:d,tabIndex:-1,className:"truncate text-title focus:outline-none",title:b.name,children:b.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("p",{className:"text-body-sm text-ink-muted","data-testid":"skill-meta",children:[Xt(b.source),T?s(ol[T]):null].filter(Boolean).join(" · ")}),b.installed?t.jsx(Vs,{mark:fe,labels:bn}):null,ge&&b.installed&&fe?.kind!=="review"?t.jsx(ke,{variant:"warning","data-testid":"skill-modified",children:s("ui.agents.detail.badge.modified")}):null]}),ye&&(se||O)?t.jsx("p",{className:"text-meta text-ink-muted","data-testid":"skill-hub-local-note",children:s("ui.agents.skills.detail.hub_local_note")}):null]}),p||!_?null:t.jsx(kl,{editOffered:se,editReady:V,canAsk:O,canCopy:$e,canRemove:He,canDownload:de,downloadReady:c,downloading:E.isPending,linked:ye,copying:N.copy.isPending,onDownload:()=>void Ae(),onEdit:()=>{if(!V||S===null||!k?.fingerprint)return;K.current={fingerprint:k.fingerprint,body:S};const $=F();D($),A($),j(!0),q(null),Q(!1)},onAsk:()=>h?.(b.name),onCopy:()=>void Fe(),onRemove:()=>J("ask")})]}),De&&!p?t.jsx("p",{className:"text-meta text-ink-muted","data-testid":"skill-edit-reason",children:De}):null,de&&!c?t.jsx("p",{className:"text-meta text-ink-muted","data-testid":"skill-download-reason",children:s("ui.agents.skills.detail.download_signed_out")}):null,Ce&&_?t.jsxs(pe,{variant:"info","data-testid":"skill-read-only",children:[t.jsx(xe,{children:s(Ce[0])}),t.jsx(je,{children:s(Ce[1])})]}):null,Y?t.jsxs(pe,{variant:"warning","data-testid":"skill-conflict",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.conflict_title")}),t.jsxs(je,{children:[t.jsx("span",{className:"block",children:s("ui.agents.skills.alert.conflict_body")}),t.jsx(C,{variant:"secondary",size:"sm",className:"mt-2",onClick:B,children:s("ui.agents.detail.alert.conflict_reload")})]})]}):null,ae?t.jsxs(pe,{variant:"danger",role:"alert","data-testid":"skill-write-error",children:[t.jsx(xe,{children:s(me==="download"?"ui.agents.skills.error.download_failed_title":"ui.agents.detail.alert.save_failed_title")}),t.jsx(je,{children:ae})]}):null]}),v,p?t.jsxs("form",{noValidate:!0,className:"space-y-8",onSubmit:$=>{$.preventDefault(),Oe()},children:[t.jsx(ze,{title:s("ui.agents.detail.section.when_to_use"),description:s("ui.agents.skills.edit.description_help"),label:s("ui.agents.skills.edit.description_label"),value:y.description,onChange:$=>A(m=>({...m,description:$}))}),t.jsx(ze,{title:s("ui.agents.detail.section.instructions"),description:s("ui.agents.skills.edit.instructions_help"),label:s("ui.agents.detail.section.instructions"),value:y.instructions,rows:12,onChange:$=>A(m=>({...m,instructions:$}))}),t.jsx(bt,{submit:!0,confirming:U,onConfirmingChange:H,dirty:te,pending:N.update.isPending,onSave:()=>void Oe(),onCancel:B,dirtyHint:s("ui.agents.detail.action.discard_question")})]}):t.jsxs(t.Fragment,{children:[t.jsx(G,{title:s("ui.agents.detail.section.when_to_use"),children:t.jsx(we,{text:b.description,empty:s("ui.agents.detail.no_description"),showAllLabel:s("ui.agents.skills.detail.show_all"),showLessLabel:s("ui.agents.skills.detail.show_less"),breakLongTokens:!0})}),t.jsx(G,{title:s("ui.agents.detail.section.instructions"),children:l.isLoading?t.jsx("div",{"aria-hidden":"true",children:t.jsx(mt,{})}):L!==null?t.jsxs(t.Fragment,{children:[k?.body_truncated?t.jsx("p",{className:"text-meta text-warning","data-testid":"skill-body-truncated",children:s("ui.agents.skills.detail.body_truncated",{size:ys(k.body_bytes??0)})}):null,t.jsx("div",{"data-testid":"skill-instructions",children:t.jsx(we,{text:L.text,markdown:!0,showAllLabel:s("ui.agents.skills.detail.show_all"),showLessLabel:s("ui.agents.skills.detail.show_less"),breakLongTokens:!0})})]}):t.jsx("p",{className:"text-body-sm text-ink-muted","data-testid":"skill-no-body",children:s(b.installed?"ui.agents.skills.detail.body_unavailable":"ui.agents.skills.detail.body_not_installed")})}),l.isLoading?null:t.jsxs(G,{title:s("ui.agents.skills.detail.section.files"),description:be.length>0?s("ui.agents.skills.detail.files_count",{count:Ee}):void 0,children:[be.length===0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.skills.detail.files_none")}):t.jsx("ul",{className:"space-y-1","data-testid":"skill-files",children:be.map($=>t.jsx("li",{children:t.jsx(Ge,{summary:t.jsxs("span",{className:"flex min-w-0 items-baseline gap-2",children:[t.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:$.path}),t.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:ys($.size??0)})]}),children:$.preview?t.jsxs("section",{"aria-label":s("ui.agents.skills.detail.preview_aria",{path:$.path}),children:[$.preview_truncated?t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.skills.detail.preview_truncated")}):null,t.jsx(we,{text:$.preview,mono:!0,showAllLabel:s("ui.agents.skills.detail.show_all"),showLessLabel:s("ui.agents.skills.detail.show_less"),breakLongTokens:!0})]}):t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.skills.detail.preview_none")})})},$.path))}),k?.files_truncated?t.jsx("p",{className:"text-meta text-warning","data-testid":"skill-files-truncated",children:s("ui.agents.skills.detail.files_truncated_of",{shown:be.length,total:Ee})}):null]}),t.jsx("div",{"data-testid":"skill-details",children:t.jsx(Ge,{summary:t.jsx("span",{className:"text-heading",children:s("ui.agents.skills.detail.section.details")}),children:t.jsxs("dl",{className:"mt-2 grid grid-cols-[max-content_1fr] gap-x-4 gap-y-2 text-body-sm",children:[t.jsx("dt",{className:"text-ink-muted",children:s("ui.agents.skills.detail.location_label")}),t.jsxs("dd",{className:"min-w-0 space-y-1 text-ink",children:[t.jsx("p",{children:s(b.source?ll[b.source]:"ui.agents.skills.where.unknown")}),ue?t.jsx("p",{className:"break-all font-mono text-meta text-ink-muted","data-testid":"skill-local-path",children:s("ui.hub.skills.local_path",{path:ue})}):null,ye&&re?.state.kind==="not-present"?t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.skills.hub.unlinked_help")}):null]}),t.jsx("dt",{className:"text-ink-muted",children:s("ui.agents.skills.detail.form_label")}),t.jsx("dd",{className:"text-ink","data-testid":"skill-form",children:b.form?s(b.form==="bundle"?"ui.agents.skills.detail.form.bundle":"ui.agents.skills.detail.form.document"):s("ui.agents.skills.detail.form.unknown")}),t.jsx("dt",{className:"text-ink-muted",children:s("ui.agents.skills.detail.fingerprint")}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-meta text-ink-muted","data-testid":"skill-fingerprint",children:b.fingerprint??s("ui.agents.skills.detail.fingerprint_none")}),Le?t.jsxs(t.Fragment,{children:[t.jsx("dt",{className:"text-ink-muted",children:s("ui.agents.skills.detail.front_matter_label")}),t.jsx("dd",{className:"min-w-0 whitespace-pre-wrap break-all font-mono text-meta text-ink-muted","data-testid":"skill-front-matter",children:Le})]}):null]})})})]}),t.jsx(Ut,{open:X!==null,onOpenChange:$=>{$||J(null)},children:t.jsxs(zt,{className:"sm:max-w-md",children:[t.jsxs(Ht,{children:[t.jsx(Kt,{children:X==="unpublished"?s("ui.agents.skills.remove.unpublished_title"):ye?s("ui.hub.skills.unpull_title",{item:b.name}):s("ui.agents.skills.remove.title",{name:b.name})}),t.jsx(Wt,{children:X==="unpublished"?s("ui.agents.skills.remove.unpublished_body"):ye?s("ui.hub.skills.unpull_body"):s("ui.agents.skills.remove.body")})]}),t.jsxs(Vt,{children:[t.jsx(C,{variant:"outline",onClick:()=>J(null),children:s("ui.hub.subscriptions.cancel")}),t.jsx(C,{variant:"danger","data-testid":"skill-remove-confirm",disabled:N.remove.isPending,onClick:()=>void Ke(X==="unpublished"),children:X==="unpublished"?s("ui.agents.skills.remove.discard_confirm"):s("ui.agents.skills.action.remove_confirm")})]})]})})]})}function kl({editOffered:e,editReady:n,canAsk:a,canCopy:l,canRemove:i,canDownload:o,downloadReady:u,downloading:h,linked:v,copying:f,onEdit:g,onAsk:c,onCopy:w,onRemove:d,onDownload:x}){return!e&&!a&&!l&&!i&&!o?null:t.jsxs("div",{className:W("flex shrink-0 items-center gap-2",Jt),"data-testid":"skill-actions",children:[e?t.jsx(C,{variant:"secondary",onClick:g,disabled:!n,"data-testid":"skill-edit",children:s("ui.agents.detail.action.edit")}):null,o?t.jsx(C,{variant:"secondary",onClick:x,disabled:!u||h,"data-testid":"skill-download",children:s("ui.hub.skills.download")}):null,l?t.jsx(C,{variant:"secondary",onClick:w,disabled:f,"data-testid":"skill-copy",children:f?s("ui.agents.skills.action.copying"):s("ui.agents.skills.action.copy")}):null,a?t.jsx(C,{variant:e?"ghost":"secondary",onClick:c,"data-testid":"skill-ask",children:s("ui.agents.detail.action.ask_change")}):null,i?t.jsxs(Us,{children:[t.jsx(zs,{asChild:!0,children:t.jsx(C,{variant:"ghost",size:"icon","aria-label":s("ui.agents.detail.action.more_actions"),className:"-mr-2","data-testid":"skill-more",children:t.jsx($s,{"aria-hidden":"true"})})}),t.jsx(Hs,{align:"end",children:t.jsx(Ks,{onSelect:d,children:v?s("ui.hub.skills.unpull"):s("ui.agents.skills.action.remove")})})]}):null]})}const jl=["lo","med","hi"],yl=["auto","none","minimal","low","medium","high","xhigh","max"],Je="inherit";function _s(e){return e??Je}function vl(e){return e===Je?null:e}function _l(e){return e===Je?null:e}function Nl(e,n){return{...e,...n.tier===void 0?{}:{tier:vl(n.tier)},...n.effort===void 0?{}:{effort:_l(n.effort)}}}function $t(e){const{tier:n,effort:a,key:l,...i}=e;return JSON.stringify({...i,...n?{tier:n}:{},...a?{effort:a}:{}})}function wl(e,n){const a=`${n.kind}\0${n.role.toLocaleLowerCase()}`;return(e?.members??[]).find(l=>`${l.kind}\0${l.role.toLocaleLowerCase()}`===a)??null}const Sl={team:"ui.agents.models.source.team",row:"ui.agents.models.source.row",none:"ui.agents.models.source.none"},El={team:"ui.agents.models.source.team",tier:"ui.agents.models.source.tier",model_default:"ui.agents.models.source.model_default"},jn=e=>Sl[e],Cl=e=>El[e];function Rl(e){return e.isSuccess?"available":e.isError&&Il(e.error)?"unavailable":"absent"}function Il(e){return ia(e)!=="outdated"}function Ll({team:e}){Z();const n=r.useId(),a=gt(),{isAuthenticated:l}=Ot(),i=ee(a.data,"hub_links"),[o,u]=r.useState(!1),[h,v]=r.useState(null),[f,g]=r.useState(Nt),c=r.useRef(null),w=r.useRef(null),d=Pt(i),x=Ms({enabled:o&&l&&ee(a.data,"radient_org")}),N=Ws(x.memberships),E=h?N.find(D=>D.tenant_id===h):null,k=h?E?.tenant_name?s("ui.hub.links.source_private",{organization:E.tenant_name}):s("ui.hub.links.source_unavailable"):s("ui.hub.links.source_public"),b=(d.data?.links??[]).filter(D=>D.kind==="team"&&D.local_id===e.id),S=b.find(D=>D.visibility===(h?"org":"public")&&D.tenant_id===h),L=b.find(D=>D.link_id!==S?.link_id),F=d.data?.unresolved.some(D=>D.kind==="team"&&D.local_id===e.id),p=pt(),j=tt({mutationFn:async()=>{if(!l||S||!i||!d.isSuccess||L||F||h&&!E)throw new Error("hub-team-destination-not-ready");const D=JSON.stringify({id:e.id,target:h,policy:S?null:f}),y=c.current?.tuple===D?c.current:{tuple:D,id:crypto.randomUUID()};return c.current=y,le({op:"team.publish",teamId:e.id,requestId:y.id,...h?{visibility:"org",tenantId:h}:{},...S?{}:f})},onSuccess:()=>{p.invalidateQueries({queryKey:Ps})}});if(!i||!o&&(b.length>0||F))return null;const P=!l||!d.isSuccess||!!S||!!L||!!F||!!h&&!E;return t.jsxs(t.Fragment,{children:[t.jsx(C,{variant:"outline",disabled:!l||!d.isSuccess,onClick:()=>{u(!0),v(null),g(Nt()),c.current=null,j.reset()},children:s("ui.hub.subscriptions.preview_publish")}),t.jsx(Ut,{open:o,onOpenChange:D=>{j.isPending||u(D)},children:t.jsxs(zt,{onOpenAutoFocus:D=>{D.preventDefault(),w.current?.focus()},children:[t.jsxs(Ht,{children:[t.jsx(Kt,{children:s("ui.hub.subscriptions.preview_publish")}),t.jsx(Wt,{children:s("ui.hub.skills.initial_policy_description")})]}),t.jsx("label",{htmlFor:`${n}-target`,className:"text-body-sm text-ink",children:k}),t.jsxs("select",{id:`${n}-target`,disabled:j.isPending||j.isSuccess,value:h??"",className:"rounded-md border border-control bg-surface px-3 py-2 text-body-sm text-ink",onChange:D=>{v(D.target.value||null),g(Nt()),c.current=null},children:[t.jsx("option",{value:"",children:s("ui.hub.links.source_public")}),N.map(D=>t.jsx("option",{value:D.tenant_id,children:D.tenant_name},D.tenant_id))]}),L?t.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.subscriptions.source_separation",{currentSource:ft(L),newSource:k})}):F?t.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.links.source_unavailable")}):S?t.jsx(Bs,{link:S}):t.jsx(ka,{value:f,onChange:g,source:k,item:e.name,visibility:h?"org":"public",organization:E?.tenant_name??null,destinationKey:`${e.id}:${h??"public"}`,canEnableAutoPush:!1,disabled:P||j.isPending||j.isSuccess}),d.error&&t.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.links.load_failed")}),j.error&&t.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:s("ui.hub.links.action_failed",{direction:s("ui.hub.links.direction_push"),item:e.name,source:k})}),j.isSuccess&&t.jsx("output",{className:"text-body-sm text-ink",children:ja(j.data)?s("ui.hub.links.published",{item:e.name,source:k}):s("ui.hub.skills.policy_pending")}),t.jsxs(Vt,{children:[t.jsx(C,{ref:w,variant:"outline",disabled:j.isPending,onClick:()=>u(!1),children:s("ui.hub.subscriptions.cancel")}),t.jsx(C,{disabled:P||j.isPending||j.isSuccess,onClick:()=>j.mutate(),children:s("ui.hub.links.confirm_publish")})]})]})})]})}function We(e){return{description:e?.description??"",manager:e?.manager??"manager",members:(e?.members??[]).map(n=>({...n,count:es(n),key:crypto.randomUUID()})),instructions:e?.instructions??"",project:e?.project??""}}function Al(e,n){const a={};return n.description!==e.description&&(a.description=n.description),n.manager!==e.manager&&(a.manager=n.manager),JSON.stringify(n.members.map($t))!==JSON.stringify(e.members.map($t))&&(a.members=n.members.map(({key:l,...i})=>i)),n.instructions!==e.instructions&&(a.instructions=n.instructions),n.project!==e.project&&(a.project=n.project),a}function Ns(e,n,a){return(e.kind==="agent"?(n??[]).map(i=>i.name):(a??[]).map(i=>i.name)).includes(e.role)}function Fl(e){return(e??[]).reduce((n,a)=>n+es(a),0)}function es(e){return e.count||1}function yn(e){return s("ui.agents.teams.member_count",{count:Fl(e)})}function ws(e){const n=e.tier.value?s("ui.agents.models.reading.tier_layer",{tier:e.tier.value,source:s(jn(e.tier.source))}):null;return e.model.value?{value:e.model.value,layer:n}:e.available?{value:s("ui.agents.models.reading.session_model"),layer:n}:{value:s("ui.agents.models.reading.not_resolved"),layer:n}}function Ss(e){const{requested:n,value:a,source:l}=e.effort,i=s(Cl(l));return n==="auto"?{value:s("ui.agents.models.reading.effort_auto"),layer:s("ui.agents.models.source.model_default")}:a&&n&&a!==n?{value:s("ui.agents.models.reading.effort_clamped",{requested:n,value:a}),layer:i}:a?{value:a,layer:i}:{value:s("ui.agents.models.reading.effort_default"),layer:l==="model_default"?null:i}}function Tl(e){return e.tier.value?s(jn(e.tier.source)):null}function Es(e,n,a){return e.layer?s(a,{value:e.value,layer:e.layer}):s(n,{value:e.value})}function Cs(e){return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"block truncate text-body-sm text-ink",title:e.value,children:e.value}),e.layer?t.jsx("span",{className:"block truncate text-meta text-ink-dim",title:e.layer,children:e.layer}):null]})}function Rs(e){return JSON.stringify({...e,members:e.members.map($t)})}function Is(){return t.jsxs("colgroup",{children:[t.jsx("col",{}),t.jsx("col",{className:"w-24"}),t.jsx("col",{className:"w-16"})]})}function Ls({team:e,agents:n,teams:a,askEnabled:l,onSaved:i,onCancelCreate:o,onOpenAgent:u,onAskAgent:h,onDirtyChange:v,belowHeader:f}){Z();const g=!e,[c,w]=r.useState(g),[d,x]=r.useState(e?.name??""),[N,E]=r.useState(()=>We(e)),[k,b]=r.useState(()=>We(e)),[S,L]=r.useState(!1),[F,p]=r.useState(null),[j,P]=r.useState(null),[D,y]=r.useState(!1),[A,U]=r.useState(!1),H=r.useRef(e?.definition_revision),Y=r.useRef(null),Q=r.useRef(null),K=r.useRef(null),ae=r.useRef(null),q=r.useRef(!1);r.useEffect(()=>{fn()&&requestAnimationFrame(()=>Y.current?.focus())},[]);const me=qt();Z();const z=pt(),oe=e?.name??a?.[0]?.name??null,X=An(oe,!!oe),J=Rl(X),te=J==="available",R=X.data&&X.data.team===e?.name?X.data:null,B=g?!!(d.trim()||k.description||k.members.length):Rs(k)!==Rs(N);r.useEffect(()=>(v?.((g||c)&&B),()=>v?.(!1)),[v,g,c,B]),r.useEffect(()=>{if(c&&B)return;const _=We(e);E(_),b(_)},[e,c,B]),r.useEffect(()=>{if(!q.current)return;q.current=!1;const _=ae.current;typeof _?.scrollIntoView=="function"&&_.scrollIntoView({block:"nearest"})});const ce=()=>{if(g){o?.();return}w(!1),p(null),P(null),y(!1),H.current=e?.definition_revision;const _=We(e);E(_),b(_)};Zt(()=>{if(D){y(!1);return}B?y(!0):ce()},c);const fe=async _=>{if(_?.preventDefault(),!S){if(g&&!d.trim()){p("Give the team a name."),P("name"),K.current?.focus();return}if(g&&/[\\/\s]/.test(d.trim())){p("Names cannot contain spaces or slashes."),P("name"),K.current?.focus();return}if(g&&(a??[]).some(I=>I.name===d.trim())){p(`A team called “${d.trim()}” already exists. Open it to change it, or choose another name.`),P("name"),K.current?.focus();return}if(g&&!k.instructions.trim()){p("Give the team instructions."),P("instructions"),Q.current?.focus();return}L(!0),p(null),P(null);try{const I=e?await le({op:"teams.update",name:e.name,requestId:crypto.randomUUID(),fields:Al(N,k),expectedDefinitionRevision:H.current}):await le({op:"teams.create",requestId:crypto.randomUUID(),fields:{name:d,description:k.description,manager:k.manager,members:k.members.map(({key:V,...O})=>O),instructions:k.instructions,project:k.project}}),se=We(I);E(se),b(se),U(!1),H.current=I.definition_revision,w(!1),i(I.name),X.refetch(),z.invalidateQueries({queryKey:["desktop","team"]}),Ne(g?s("ui.notices.agents.created_named",{name:I.name}):s("ui.notices.agents.saved",{name:I.name})),g&&mn(),requestAnimationFrame(()=>Y.current?.focus())}catch(I){if(I?.code==="local-concurrent-edit"){U(!0),p(null),P(null);return}const V=Ye(I instanceof Error?I.message:"The team could not be saved.");p(V.message),P(V.field),rt(V.message)}finally{L(!1)}}},ge=(_,I)=>b(se=>({...se,members:se.members.map((V,O)=>O===_?{...V,...I}:V)})),T=(_,I)=>b(se=>({...se,members:se.members.map((V,O)=>O===_?Nl(V,I):V)})),be=k.members.length?k.members:e?.members,Ee=e?Os(e):"New team",ue=k.members.some(_=>_.kind==="team");return t.jsxs("div",{className:"space-y-8",children:[t.jsxs("header",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[t.jsxs("div",{className:"min-w-0 flex-[1_1_16rem] space-y-1",children:[t.jsx("h2",{ref:Y,tabIndex:-1,title:Ee,className:"truncate text-title focus:outline-none",children:Ee}),e?t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[yn(be),ue?" · Includes a team":""]}):null]}),e&&!c?t.jsxs("div",{className:W("flex shrink-0 items-center gap-2",Jt,l&&"-mr-3"),children:[t.jsx(C,{variant:"primary",onClick:()=>{Bt.getState().stageDraft({kind:"team",name:e.name}),me("/chat")},children:s("ui.agents.teams.action.new_chat")}),t.jsx(Ll,{team:e}),t.jsx(C,{variant:"secondary",onClick:()=>{H.current=e.definition_revision,w(!0)},children:s("ui.agents.detail.action.edit")}),l?t.jsx(C,{variant:"ghost",onClick:()=>h(`Change the team ${e.name}: `),children:s("ui.agents.detail.action.ask_change")}):null]}):null]}),F&&!j?t.jsxs(pe,{variant:"danger",role:"alert","data-testid":"team-save-error",children:[t.jsx(xe,{children:s("ui.agents.detail.alert.save_failed_title")}),t.jsx(je,{children:F})]}):null]}),f,c&&A?t.jsxs(pe,{variant:"warning","data-testid":"team-conflict",children:[t.jsx(xe,{children:s("ui.hub.conflict.title")}),t.jsxs(je,{children:[t.jsx("span",{className:"block",children:s("ui.hub.conflict.body")}),t.jsx(C,{variant:"secondary",size:"sm",className:"mt-2",onClick:ce,children:s("ui.hub.conflict.reload")})]})]}):null,t.jsx("form",{noValidate:!0,onSubmit:_=>{_.preventDefault(),fe(_)},className:"space-y-8",children:g||c?t.jsxs(t.Fragment,{children:[g?t.jsxs(G,{title:s("ui.agents.detail.field.name"),description:"How you and your chats will refer to this team.",children:[t.jsx(Se,{label:"Team name",htmlFor:"team-name",error:j==="name"?F:null}),t.jsx(qe,{ref:K,id:"team-name","data-testid":"team-name-input",value:d,required:!0,maxLength:64,autoFocus:!0,"aria-invalid":j==="name",onChange:_=>x(_.target.value)})]}):null,t.jsx(G,{title:s("ui.agents.teams.section.manager"),description:"The agent that leads the chat and decides who works on what.",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx(Se,{label:"Manager agent",htmlFor:"team-manager",error:j==="manager"?F:null}),t.jsx(dt,{ariaLabel:"Manager agent",showLabel:!1,placeholder:s("ui.agents.teams.field.manager_placeholder"),busyLabel:"Loading agents",options:Pe(n,a),selected:Pe(n,a).find(_=>_.id===k.manager)??null,onSelect:_=>b(I=>({...I,manager:_.id})),onCustomSubmit:_=>b(I=>({...I,manager:_})),listNotice:"Agents and teams on this machine"}),Pe(n,a).some(_=>_.id===k.manager)?null:t.jsx(ke,{variant:"warning","data-testid":"team-manager-missing",children:s("ui.agents.teams.empty.not_found_name",{name:k.manager})})]})}),t.jsxs(G,{title:s("ui.agents.teams.section.members"),description:"Who the manager can delegate to, how many of each, and the model each runs on.",children:[t.jsx("p",{"data-testid":"team-override-scope",className:"text-meta text-ink-muted",children:s("ui.agents.models.override.scope_hint")}),g&&!oe?t.jsx("p",{"data-testid":"team-override-no-probe",className:"text-meta text-ink-muted",children:s("ui.agents.models.reading.no_probe_hint")}):null,J==="unavailable"?t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("p",{className:"text-meta text-danger",children:s("ui.agents.models.reading.read_failed")}),t.jsx(C,{variant:"ghost",size:"sm",onClick:()=>void X.refetch(),children:s("ui.agents.models.reading.try_again")})]}):null,t.jsxs("div",{className:"space-y-4",children:[k.members.map((_,I)=>{const se=!Ns(_,n,a),V=wl(R??void 0,_);return t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_8rem_auto_auto] items-center gap-x-2 gap-y-1",children:[t.jsx("div",{className:"min-w-0",children:t.jsx(dt,{ariaLabel:`Member ${I+1}`,showLabel:!1,placeholder:s("ui.agents.teams.field.member_placeholder"),busyLabel:"Loading agents",options:[...Pe(n,a).filter(O=>_.kind==="team"?O.group==="Teams":O.group==="Agents")],selected:Pe(n,a).find(O=>O.id===_.role)??null,onSelect:O=>ge(I,{role:O.id,kind:O.group==="Teams"?"team":"agent"}),onCustomSubmit:O=>ge(I,{role:O})})}),t.jsxs(st,{value:_.kind,onValueChange:O=>ge(I,{kind:O}),children:[t.jsx(nt,{"aria-label":`Member ${I+1} kind`,className:"w-full",children:t.jsx(at,{})}),t.jsxs(it,{children:[t.jsx(Ie,{value:"agent",children:s("ui.agents.teams.kind.agent")}),t.jsx(Ie,{value:"team",children:s("ui.agents.teams.kind.team")})]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(C,{variant:"secondary",size:"icon-sm","aria-label":`One fewer ${_.role}`,disabled:_.count<=1,onClick:()=>ge(I,{count:_.count-1}),children:t.jsx(da,{"aria-hidden":"true"})}),t.jsx("span",{className:"min-w-6 text-center text-body-sm tabular-nums","aria-label":`${_.count} of ${_.role}`,children:_.count}),t.jsx(C,{variant:"secondary",size:"icon-sm","aria-label":`One more ${_.role}`,disabled:_.count>=16,onClick:()=>ge(I,{count:_.count+1}),children:t.jsx(qs,{"aria-hidden":"true"})})]}),t.jsx(C,{variant:"ghost",onClick:()=>b(O=>({...O,members:O.members.filter(($e,he)=>he!==I)})),children:s("ui.agents.teams.action.remove")}),se?t.jsx(ke,{variant:"warning",className:"col-span-full w-fit",children:s("ui.agents.teams.empty.not_found_name",{name:_.role})}):null,te?t.jsxs("div",{className:"col-span-full grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] items-end gap-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[t.jsx("span",{className:"text-meta text-ink-dim",children:s("ui.agents.models.override.tier_field")}),t.jsxs(st,{value:_s(_.tier),onValueChange:O=>T(I,{tier:O}),children:[t.jsx(nt,{"aria-label":s("ui.agents.models.override.tier_label",{member:_.role||`Member ${I+1}`}),className:"w-full",children:t.jsx(at,{})}),t.jsxs(it,{children:[t.jsx(Ie,{value:Je,children:s("ui.agents.models.override.inherit_tier")}),jl.map(O=>t.jsx(Ie,{value:O,children:O},O))]})]})]}),t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[t.jsx("span",{className:"text-meta text-ink-dim",children:s("ui.agents.models.override.effort_field")}),t.jsxs(st,{value:_s(_.effort),onValueChange:O=>T(I,{effort:O}),children:[t.jsx(nt,{"aria-label":s("ui.agents.models.override.effort_label",{member:_.role||`Member ${I+1}`}),className:"w-full",children:t.jsx(at,{})}),t.jsxs(it,{children:[t.jsx(Ie,{value:Je,children:s("ui.agents.models.override.inherit_effort")}),yl.map(O=>t.jsx(Ie,{value:O,children:O==="auto"?s("ui.agents.models.override.auto"):O},O))]})]})]})]}):null,V?t.jsxs("div",{className:"col-span-full flex flex-wrap items-baseline gap-x-3 gap-y-1 text-meta",children:[t.jsx("span",{className:"text-ink-dim",children:s("ui.agents.models.reading.saved_label")}),t.jsx("span",{className:"text-ink-muted",children:Es({value:ws(V).value,layer:Tl(V)},"ui.agents.models.reading.model_cell","ui.agents.models.reading.model_cell_layer")}),t.jsx("span",{className:"text-ink-muted",children:Es(Ss(V),"ui.agents.models.reading.effort_cell","ui.agents.models.reading.effort_cell_layer")})]}):null,V&&!V.available?t.jsxs("div",{className:"col-span-full",children:[t.jsx("p",{"data-testid":"team-member-unavailable",className:"text-meta text-danger",children:s("ui.agents.models.reading.unavailable_editor",{member:V.role||`Member ${I+1}`,reason:V.reason})}),t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.models.reading.unavailable_hint")})]}):null]},_.key)}),t.jsx(C,{ref:ae,variant:"secondary",onClick:()=>{q.current=!0,b(_=>({..._,members:[..._.members,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]}))},children:s("ui.agents.teams.action.add_member")})]})]}),t.jsxs(G,{title:s("ui.agents.teams.section.description"),children:[t.jsx(Se,{label:"What this team is for",htmlFor:"team-description",error:j==="description"?F:null}),t.jsx(qe,{id:"team-description",value:k.description,onChange:_=>b(I=>({...I,description:_.target.value}))})]}),t.jsxs(G,{title:s("ui.agents.teams.section.collaboration"),children:[j==="instructions"?t.jsx("p",{className:"text-meta text-danger",role:"alert","data-testid":"team-instructions-error",children:F}):null,t.jsx(Lt,{ref:Q,"aria-label":s("ui.agents.teams.action.collaboration_aria"),"aria-invalid":j==="instructions",className:"min-h-36",maxLength:8e3,value:k.instructions,onChange:_=>b(I=>({...I,instructions:_.target.value}))})]}),t.jsx(G,{title:s("ui.agents.teams.section.project_brief"),children:t.jsx(Lt,{"aria-label":s("ui.agents.teams.action.project_brief_aria"),className:"min-h-36",maxLength:8e3,value:k.project,onChange:_=>b(I=>({...I,project:_.target.value}))})}),t.jsx(bt,{submit:!0,confirming:D,onConfirmingChange:y,dirty:B,pending:S,saveLabel:g?"Create team":"Save changes",pendingLabel:g?"Creating…":"Saving…",dirtyHint:"Discard this team?",onSave:()=>void fe(),onCancel:ce})]}):t.jsxs(t.Fragment,{children:[t.jsx(G,{title:s("ui.agents.teams.section.manager"),children:t.jsxs(yt,{className:"table-fixed","aria-label":s("ui.agents.teams.field.manager_aria"),children:[t.jsx(Is,{}),t.jsx(vt,{className:"sr-only",children:t.jsxs(Te,{children:[t.jsx(_e,{children:s("ui.agents.teams.col.member")}),t.jsx(_e,{children:s("ui.agents.teams.col.type")}),t.jsx(_e,{children:s("ui.agents.teams.col.count")})]})}),t.jsx(_t,{children:t.jsxs(Te,{className:"border-0",children:[t.jsx(ve,{className:"px-0 py-2",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(C,{variant:"link",className:W("-my-0.5 min-w-0 justify-start truncate",Yt),onClick:()=>u(k.manager),children:k.manager}),Pe(n,a).some(_=>_.id===k.manager)?null:t.jsx(ke,{variant:"warning","data-testid":"team-manager-missing",children:s("ui.agents.teams.empty.not_found")})]})}),t.jsx(ve,{className:"px-2 py-2 text-ink-dim text-meta",children:s("ui.agents.teams.kind.agent")}),t.jsx(ve,{})]})})]})}),t.jsxs(G,{title:s("ui.agents.teams.section.members"),children:[t.jsxs(yt,{className:"table-fixed","aria-label":s("ui.agents.teams.section.members_aria"),children:[t.jsx(Is,{}),t.jsx(vt,{className:"sr-only",children:t.jsxs(Te,{children:[t.jsx(_e,{children:s("ui.agents.teams.col.member")}),t.jsx(_e,{children:s("ui.agents.teams.col.type")}),t.jsx(_e,{children:s("ui.agents.teams.col.count")})]})}),t.jsx(_t,{children:(e?.members??[]).map(_=>t.jsxs(Te,{className:"last:border-0",children:[t.jsx(ve,{className:"px-0 py-2 text-ink",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate",children:_.role}),Ns(_,n,a)?null:t.jsx(ke,{variant:"warning","data-testid":"team-member-missing",children:s("ui.agents.teams.empty.not_found")})]})}),t.jsx(ve,{className:"px-2 py-2 text-ink-dim text-meta",children:_.kind==="team"?"Team":"Agent"}),t.jsx(ve,{className:"px-0 py-2 text-right text-ink-muted tabular-nums",children:`×${es(_)}`})]},`${_.kind}:${_.role}`))})]}),J==="unavailable"?t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("p",{className:"text-meta text-danger",children:s("ui.agents.models.reading.read_failed")}),t.jsx(C,{variant:"ghost",size:"sm",onClick:()=>void X.refetch(),children:s("ui.agents.models.reading.try_again")})]}):null]}),te&&R?.members.length?t.jsxs(G,{title:s("ui.agents.models.reading.title"),description:s("ui.agents.models.reading.description"),children:[t.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.agents.models.override.scope_hint")}),X.isFetching?t.jsx("p",{"data-testid":"team-effective-refreshing",className:"text-meta text-ink-dim",children:s("ui.agents.models.reading.refreshing")}):null,t.jsxs(yt,{className:W("table-fixed",X.isFetching&&"opacity-60"),"aria-label":s("ui.agents.models.reading.title"),children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-24"}),t.jsx("col",{}),t.jsx("col",{className:"w-32"})]}),t.jsx(vt,{children:t.jsxs(Te,{children:[t.jsx(_e,{className:"px-0",children:s("ui.agents.models.reading.member_col")}),t.jsx(_e,{className:"px-2",children:s("ui.agents.models.reading.model_col")}),t.jsx(_e,{className:"px-0",children:s("ui.agents.models.reading.effort_col")})]})}),t.jsx(_t,{children:R.members.map(_=>t.jsxs(r.Fragment,{children:[t.jsxs(Te,{className:_.available?"last:border-0":"border-0",children:[t.jsx(ve,{className:"px-0 py-2",children:t.jsx("span",{className:"block truncate text-body-sm text-ink",title:_.role,children:_.role})}),t.jsx(ve,{className:"px-2 py-2",children:Cs(ws(_))}),t.jsx(ve,{className:"px-0 py-2",children:Cs(Ss(_))})]}),_.available?null:t.jsx(Te,{className:"last:border-0",children:t.jsxs(ve,{colSpan:3,className:"px-0 pb-2",children:[t.jsx("span",{"data-testid":"team-effective-unavailable",className:"block text-meta text-danger",children:s("ui.agents.models.reading.unavailable",{member:_.role,reason:_.reason})}),t.jsx("span",{className:"block text-meta text-ink-muted",children:s("ui.agents.models.reading.unavailable_hint")})]})})]},`${_.kind}:${_.role}`))})]})]}):null,t.jsx(G,{title:s("ui.agents.teams.section.what_for"),children:t.jsx(we,{text:e?.description??"",empty:"No description yet."})}),e?.instructions?t.jsx(G,{title:s("ui.agents.teams.section.collaboration"),children:t.jsx(we,{text:e.instructions})}):null,e?.project?t.jsx(Ge,{summary:"Project brief",children:t.jsx(we,{text:e.project})}):null]})})]})}function Pe(e,n){return[...(e??[]).map(a=>({id:a.name,name:a.name,description:a.description,group:"Agents"})),...(n??[]).map(a=>({id:a.name,name:a.name,description:a.description,group:"Teams"}))]}const $l=r.lazy(()=>Mn(()=>import("./legacy-agents-page-BHBgHvV3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]),import.meta.url).then(e=>({default:e.LegacyAgentsPage}))),As=/^subagents\.models\.([^.]+)$/,Dl=["lo","med","hi"],Ol={backend:"ui.agents.skills.composer.gate_backend",none:"ui.agents.skills.composer.gate_none","not-installed":"ui.agents.skills.composer.gate_not_installed","read-only":"ui.agents.skills.composer.gate_read_only"},Fs={all:"ui.agents.pages.scope.all",custom:"ui.agents.pages.scope.custom",installed:"ui.agents.pages.scope.installed",builtin:"ui.agents.pages.scope.builtin"},Pl={all:"ui.agents.pages.empty.agents",custom:"ui.agents.pages.empty.custom",installed:"ui.agents.pages.empty.installed",builtin:"ui.agents.pages.empty.builtin"};function Ml(e){return!e||e.getAttribute("role")!=="tab"||e.getAttribute("aria-selected")==="true"?e:e.closest('[role="tablist"]')?.querySelector('[role="tab"][aria-selected="true"]')??null}function tr(){Z();const{agentId:e}=la(),[n,a]=Ds(),l=n.get("kind")==="skill",i=n.get("kind")==="team"||n.get("create")==="team",o=n.has("create"),u=n.get("name"),h=n.get("duplicate"),v=gt(),{isAuthenticated:f}=Ot(),g=ee(v.data,"skill_library"),c=l&&g&&!o,w=ee(v.data,i?"team_catalogue":"profile_catalogue"),d=Fn(w),x=Tn(w),N=qi({enabled:g,linksEnabled:ee(v.data,"hub_links"),updatesEnabled:ee(v.data,"hub_updates")}),E=kn(!!N.library.error,N.library.isFetching),k=Bi(c?n.get("name"):null,g),b=w&&!!u&&!o&&!l,S=ts(i?null:u,b),L=$n(i?u:null,b),F=ts(i?null:h,!!h),[p,j]=r.useState(""),[P,D]=r.useState("all"),[y,A]=r.useState("all"),U=ee(v.data,"skill_write"),H=tn(v.data),[Y,Q]=r.useState(0),[K,ae]=r.useState(null),[q,me]=r.useState(null),z=xi(),oe=ie(m=>m.marks),X=ie(m=>m.clearMark),J=ht({queryKey:["desktop","settings","effort-tiers"],enabled:w,queryFn:()=>le({op:"settings.list"}),staleTime:6e4}),te=r.useMemo(()=>(J.data?.settings??[]).filter(m=>{const M=m.key.match(As)?.[1];return!M||!Dl.includes(M)?!1:typeof m.value=="string"&&m.value.trim().length>0}).map(m=>m.key.match(As)?.[1]).filter(m=>!!m),[J.data]),R=Jn(),B=r.useCallback(m=>Qn(m,R),[R]),ce=r.useMemo(()=>Hl(d.data,p,P,B),[d.data,p,P,B]),re=r.useMemo(()=>Kl(x.data,p),[x.data,p]),fe=i?re:ce,ge=Ni($i(N.cards,y),p,Xt),T=l&&!g?null:u??null,[be,Ee]=r.useState(null);be!==null&&be.name!==T&&Ee(null);const ue=r.useCallback(m=>{const M=new URLSearchParams,ne=m.kind??(c?"skill":i?"team":"agent");ne==="team"&&M.set("kind","team"),ne==="skill"&&M.set("kind","skill"),m.name&&M.set("name",m.name),m.create!==null&&m.create!==void 0&&M.set("create",m.create),m.duplicate&&M.set("duplicate",m.duplicate),ae(null),a(M)},[i,c,a]),_=`${c?"skill":i?"team":"agent"}:${o??""}:${T??""}`,I=r.useCallback(m=>me(m?_:null),[_]),se=q!==null&&q===_,V=(m,M,ne,kt=!0)=>t.jsxs(t.Fragment,{children:[t.jsx(al,{kind:m,name:M,localId:ne,enabled:ee(v.data,"hub_links")}),m==="skill"&&(!kt||ee(v.data,"hub_links"))?null:t.jsx(ya,{kind:m,name:M,enabled:ee(v.data,"hub_updates")&&!ee(v.data,"hub_links")})]}),O=r.useRef(null),$e=r.useRef(null),he=r.useRef(null),de=r.useCallback(m=>{if(se){const M=$e.current,ne=document.activeElement;O.current=M?.isConnected&&M.closest("form")?M:ne instanceof HTMLElement?ne:null,ae(m);return}ue(m)},[se,ue]),He=r.useCallback(()=>{ae(null);const m=O.current;requestAnimationFrame(()=>{const M=Ml(m);M?.isConnected&&M.focus()})},[]),ye=K!==null;r.useEffect(()=>{if(!ye)return;bs(!0,()=>ae(null)),he.current?.focus();const m=requestAnimationFrame(()=>{const ne=he.current?.closest('[role="alertdialog"]');ne&&!ne.contains(document.activeElement)&&he.current?.focus()}),M=ne=>{ne.key!=="Escape"||ne.defaultPrevented||(ne.preventDefault(),He())};return window.addEventListener("keydown",M),()=>{cancelAnimationFrame(m),window.removeEventListener("keydown",M),bs(!1)}},[ye,He]),r.useEffect(()=>{const m=M=>{M.key!=="Escape"||M.defaultPrevented||window.matchMedia("(max-width: 999px)").matches&&(!T&&!o||se||ye||(M.preventDefault(),de({name:null})))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[de,T,o,se,ye]),r.useEffect(()=>{const M=ie.getState().about;if(!M)return;const ne=c?"skill":i?"team":"agent";T&&M.kind===ne&&M.name===T||(z.setAbout(null),Da(M))},[T,i,c,z]);const Le=c&&T?N.cards.find(m=>m.name===T)??null:null,Ce=Fi(H,Le);r.useEffect(()=>{if(!c||!T||Ce!==null)return;const m=ie.getState().about;m?.kind==="skill"&&m.name===T||z.setAbout({kind:"skill",name:T})},[c,T,Ce,z]),r.useEffect(()=>{T&&X({kind:c?"skill":i?"team":"agent",name:T})},[T,i,c,X]);const De=r.useRef(null);r.useEffect(()=>{const m=De.current;De.current=c?T:null,!(!c||T||!m)&&requestAnimationFrame(()=>{const M=document.activeElement;M&&M!==document.body||[...document.querySelectorAll("[data-testid]")].find(ne=>ne.dataset.testid===`skill-row-${m}`)?.focus()})},[c,T]);const Ae=()=>{d.refetch(),x.refetch(),T&&(i?L.refetch():S.refetch())};if(e)return t.jsx(r.Suspense,{fallback:t.jsx("p",{className:"p-6 text-body",children:s("ui.agents.pages.loading_saved")}),children:t.jsx($l,{})});const Oe=i?L.error:S.error,Fe=i?x.error:d.error,Ke=!c&&w&&!Fe&&!o&&!T,$=i?L.isLoading:S.isLoading;return t.jsxs("div",{"data-glass-region":"canvas","data-glass-split":"",className:"panel-flush flex min-h-0 flex-1 bg-canvas text-ink",children:[t.jsxs("aside",{"data-open":T?"true":void 0,"data-glass-region":"page-sidebar",className:"panel-top-pad flex w-72 shrink-0 flex-col gap-3 bg-surface px-4 pb-4 max-[999px]:data-[open=true]:hidden",children:[t.jsx("h1",{className:"pt-4 text-heading",children:s("ui.agents.pages.heading")}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(ma,{value:c?"skill":i?"team":"agent",onValueChange:m=>de({kind:m,name:null}),children:t.jsxs(fa,{"aria-label":s("ui.agents.pages.browse_aria"),className:"w-full",children:[t.jsx(Ct,{value:"agent",testId:"agents-tab",icon:t.jsx(Zn,{className:"size-3.5"}),label:s("ui.agents.pages.tab.agents"),count:d.data?.length??null,compact:g}),t.jsx(Ct,{value:"team",testId:"teams-tab",icon:t.jsx(Dn,{className:"size-3.5"}),label:s("ui.agents.pages.tab.teams"),count:x.data?.length??null,compact:g}),g?t.jsx(Ct,{value:"skill",testId:"skills-tab",noPanel:!0,compact:!0,icon:t.jsx(On,{className:"size-3.5"}),label:s("ui.agents.skills.tab"),count:N.library.data?N.cards.length:null}):null]})}),t.jsxs("div",{className:"relative",children:[t.jsx(Pn,{"aria-hidden":"true",className:"pointer-events-none absolute top-2 start-2 size-4 text-ink-dim"}),t.jsx(qe,{className:"ps-8",type:"search","aria-label":c?s("ui.agents.skills.search_aria"):s("ui.agents.pages.search_aria"),placeholder:c?s("ui.agents.skills.search"):i?s("ui.agents.pages.search.teams"):s("ui.agents.pages.search.agents"),value:p,onChange:m=>j(m.target.value)})]}),!i&&!c&&d.data?t.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:s("ui.agents.pages.scope_legend")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Object.keys(Fs).map(m=>t.jsx(C,{variant:"ghost",size:"sm","aria-pressed":P===m,onClick:()=>D(m),className:W("flex-1",P===m&&ot),children:s(Fs[m])},m))})]}):null,c&&N.library.data?t.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:s("ui.agents.skills.scope_legend")}),t.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Ti.map(m=>t.jsx(C,{variant:"ghost",size:"sm","aria-pressed":y===m,"data-testid":`skills-scope-${m}`,onClick:()=>A(m),className:W("flex-1",y===m&&ot),children:s(cl[m])},m))})]}):null]}),t.jsx("div",{"data-lo-pane-edge-cues":!0,className:"min-h-0 flex-1 overflow-y-auto",children:c?t.jsx(ml,{loading:N.library.isLoading,failed:!!N.library.error,cards:ge,total:N.cards.length,search:p,scope:y,selected:T,join:N.join,marked:new Map(oe.map(m=>[os(m),m.created])),onOpen:m=>de({name:m})}):Fe?null:!d.data&&!x.data?t.jsx(gn,{}):fe.length===0?t.jsx("p",{className:"px-1 py-2 text-body-sm text-ink-muted",children:p?s("ui.agents.pages.empty.search",{query:p}):i?s("ui.agents.pages.empty.teams"):s(Pl[P])}):t.jsx(zl,{rows:fe,name:o?null:T,teamMode:i,printName:B,marked:new Map(oe.map(m=>[os(m),m.created])),onOpen:m=>de({name:m})})}),t.jsx(ql,{teamMode:i,className:W(c&&"hidden"),disabled:!w,onClick:()=>de({create:i?"team":"agent"})})]}),t.jsxs("main",{"data-glass-region":"canvas-content",className:"panel-top-pad flex min-w-0 flex-1 flex-col",children:[T||o?t.jsx("div",{className:"flex shrink-0 items-center border-hairline border-b px-4 py-2 min-[1000px]:hidden",children:t.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>de({name:null}),children:[t.jsx(Xn,{className:"size-4"}),s("ui.agents.pages.back_to_list")]})}):null,t.jsx("div",{"data-agents-pane":!0,onFocus:m=>{m.target instanceof HTMLElement&&($e.current=m.target)},"data-lo-pane-edge-cues":!0,className:W("min-h-0 flex-1 overflow-auto",Ke?void 0:"px-4 pt-6 [scroll-padding-bottom:calc(var(--lo-pane-footer-h)+var(--lo-pane-footer-cue-h)+4px)] [scrollbar-gutter:stable_both-edges]"),children:Ke?t.jsx(Bl,{teamMode:i,run:z,onAddManually:()=>de({create:i?"team":"agent"})}):t.jsx("div",{className:Dt,children:t.jsx("div",{className:Qe,children:c?N.library.error?t.jsx("div",{ref:E.holder,children:t.jsx(lt,{title:s("ui.agents.skills.error.title"),what:N.library.error instanceof Error&&N.library.error.message?N.library.error.message:s("ui.agents.skills.error.what_fallback"),meaning:s("ui.agents.skills.error.meaning"),onRetry:()=>{E.onPress(),N.library.refetch()},retrying:N.library.isFetching,retryLabel:s("ui.common.actions.retry"),retryingLabel:s("ui.agents.skills.retrying")})}):T?t.jsx(bl,{name:T,card:Le,join:N.join,detail:k,onRetry:()=>void k.refetch(),writesEnabled:U,askEnabled:H,onDirtyChange:I,belowHeader:Le?.source==="hub"?V("skill",T,void 0,Le.installed):void 0,onAsk:m=>{Xe(z,{kind:"skill",name:m},Ys({kind:"skill",name:m})),Q(M=>M+1)},hubSignedIn:f,downloadEnabled:ee(v.data,"hub_skills"),onRemoved:(m,M)=>{if(M){requestAnimationFrame(()=>document.querySelector('[data-testid="skill-detail"] h2')?.focus());return}const ne=ge.findIndex(kt=>kt.name===m);De.current=ge[ne+1]?.name??ge[ne-1]?.name??null,ue({name:null})}},T):N.library.isLoading||N.cards.length===0?null:t.jsx("p",{className:"text-body-sm text-ink-muted","data-testid":"skills-select-prompt",children:U?s("ui.agents.skills.select_prompt_editable"):s("ui.agents.skills.select_prompt")}):w?Fe?t.jsx(lt,{title:i?"Teams could not be read":"Agents could not be read",what:Fe instanceof Error?Fe.message:"The request did not complete.",meaning:"Nothing is lost. This is a read that failed — the backend answered an error, which is different from the backend being out of date.",onRetry:Ae,retrying:d.isFetching||x.isFetching}):T&&$?t.jsx(mt,{}):T&&Oe?t.jsx(lt,{title:i?`“${T}” could not be read`:`“${T}” could not be read`,what:Oe instanceof Error?Oe.message:"The request did not complete.",meaning:"The definition may have been removed, or the backend refused the read.",onRetry:()=>{S.refetch(),L.refetch()},retrying:S.isFetching||L.isFetching}):o&&i?t.jsx(Ls,{agents:d.data,teams:x.data,askEnabled:z.enabled,onDirtyChange:I,onSaved:m=>{Ae(),ue({name:m})},onCancelCreate:()=>ue({name:null}),onOpenAgent:m=>de({kind:"agent",name:m}),onAskAgent:m=>{Xe(z,{kind:"team",name:u??""},m)}},"team:create"):o&&h&&F.isLoading?t.jsx(mt,{}):o?t.jsx(el,{initial:F.data??null,takenNames:(d.data??[]).map(m=>m.name),effortTiers:te,onDirtyChange:I,onSaved:m=>{Ae(),ue({name:m})},onCancel:()=>ue({name:null})},"agent:create"):i&&L.data?t.jsx(Ls,{team:L.data,agents:d.data,teams:x.data,askEnabled:z.enabled,onDirtyChange:I,belowHeader:V("team",L.data.name,L.data.id),onSaved:m=>{Ae(),ue({name:m})},onOpenAgent:m=>de({kind:"agent",name:m}),onAskAgent:m=>{Xe(z,{kind:"team",name:L.data?.name??""},m)}},ki(L.data)):!i&&S.data?t.jsx(Xi,{profile:S.data,displayedName:B(S.data.name),classNotice:be?.name===S.data.name?be.copy:null,onClassNotice:m=>Ee(m?{name:S.data.name,copy:m}:null),teams:x.data,effortTiers:te,askEnabled:z.enabled,onDirtyChange:I,belowHeader:V("agent",S.data.name,S.data.agent_id??void 0),onSaved:m=>{Ae(),ue({name:m})},onDuplicate:m=>de({create:"agent",duplicate:m.name}),onOpenTeam:m=>de({kind:"team",name:m}),onAskAgent:m=>{Xe(z,{kind:"agent",name:S.data?.name??""},m)}},bi(S.data)):T?t.jsx(Me,{className:"h-6 w-40"}):null:t.jsxs(pe,{variant:v.isLoading?"neutral":"warning",className:"max-w-xl",children:[t.jsx(xe,{children:v.isLoading?"Connecting to the backend":v.error?"The backend could not be reached":"Reusable agents need a newer backend"}),t.jsx(je,{children:v.isLoading?"Loading what this backend can do…":v.error?v.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."})]})})})}),K?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-hairline border-t bg-surface px-4 py-3",role:"alertdialog","aria-label":s("ui.agents.detail.action.discard_question"),children:[t.jsx("span",{className:"text-body-sm text-ink",children:i?s("ui.agents.pages.discard_bar.team"):s("ui.agents.pages.discard_bar.agent")}),t.jsx(C,{variant:"danger",onClick:()=>{me(null),ue(K)},children:s("ui.agents.detail.action.discard_changes")}),t.jsx(C,{ref:he,variant:"ghost",onClick:He,children:s("ui.agents.detail.action.keep_editing")})]}):null,Ke?null:t.jsx("div",{className:"shrink-0 bg-canvas",children:t.jsx(Js,{run:z,about:c?z.about?.kind==="skill"?z.about:null:z.about,onClearAbout:()=>z.setAbout(null),skill:c,focusToken:c?Y:0,blockedReason:se?"Finish or cancel your edit first.":c&&Ce!==null?s(Ol[Ce]):null})})]})]})}function Ct({value:e,testId:n,icon:a,label:l,count:i,compact:o,noPanel:u=!1}){return t.jsxs(ga,{value:e,"data-testid":n,...u?{"aria-controls":void 0}:{},title:i===null?l:`${l} ${i}`,className:W("min-w-0",o?"flex-auto px-2":"flex-1"),children:[o?null:a,t.jsx("span",{className:"min-w-0 truncate","data-testid":`${n}-label`,children:l}),i===null?null:t.jsx("span",{className:W("min-w-[2ch] font-normal text-ink-dim tabular-nums",o&&"sr-only"),children:i})]})}function Bl({teamMode:e,run:n,onAddManually:a}){Z();const l=W(Dt,Ts);return t.jsxs("div",{className:"flex min-h-full flex-col justify-center space-y-4 pb-12",children:[t.jsx("div",{className:l,children:t.jsx(Ul,{teamMode:e})}),t.jsx(Js,{run:n,hero:!0,about:n.about,onClearAbout:()=>n.setAbout(null)}),t.jsx("div",{className:l,children:t.jsx("div",{className:Qe,children:t.jsx(C,{variant:"ghost",className:"-ml-3",onClick:a,children:e?s("ui.agents.pages.ask.manual_team"):s("ui.agents.pages.ask.manual_agent")})})})]})}function ql({teamMode:e,className:n,disabled:a,onClick:l}){return Z(),t.jsxs(C,{variant:"ghost",className:W("w-full justify-start",n),disabled:a,onClick:l,children:[t.jsx(qs,{className:"size-4"}),e?s("ui.agents.pages.add_manual.team"):s("ui.agents.pages.add_manual.agent")]})}function Ul({teamMode:e}){return Z(),t.jsxs("div",{className:W(Qe,"space-y-2"),children:[t.jsx("h2",{className:"text-title",children:e?s("ui.agents.pages.ask.heading_team"):s("ui.agents.pages.ask.heading_agent")}),t.jsx("p",{className:"text-body text-ink-muted",children:e?s("ui.agents.pages.ask.body_team"):s("ui.agents.pages.ask.body_agent")})]})}function zl({rows:e,name:n,teamMode:a,marked:l,printName:i,onOpen:o}){const u=r.useRef(new Map),[h,v]=r.useState(n),f=c=>"members"in c?Os(c):i(c.name),g=(c,w)=>{const d=e.findIndex(N=>N.name===c);if(d<0)return;const x=e[Math.min(e.length-1,Math.max(0,d+w))];x&&(v(x.name),u.current.get(x.name)?.focus())};return t.jsx("ul",{"aria-label":a?"Teams":"Agents",className:"space-y-0.5",children:e.map(c=>{const w="source"in c,d=l.get(`${a?"team":"agent"}:${c.name}`);return t.jsx("li",{children:t.jsxs("button",{ref:x=>{x?u.current.set(c.name,x):u.current.delete(c.name)},type:"button","aria-current":c.name===n?"true":void 0,tabIndex:c.name===(h??e[0]?.name)?0:-1,"data-testid":`roster-row-${c.name}`,title:c.description?`${f(c)} - ${c.description}`:f(c),className:W("flex min-h-12 w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-start hover:bg-row-hover",c.name===n&&ot),onFocus:()=>v(c.name),onClick:()=>o(c.name),onKeyDown:x=>{x.key==="ArrowDown"?(x.preventDefault(),g(c.name,1)):x.key==="ArrowUp"?(x.preventDefault(),g(c.name,-1)):x.key==="Home"?(x.preventDefault(),g(c.name,-e.length)):x.key==="End"&&(x.preventDefault(),g(c.name,e.length))},children:[t.jsxs("span",{className:"flex w-full items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink",children:f(c)}),d!==void 0?t.jsx(ke,{variant:"attention","data-testid":"roster-row-updated",children:d?"New":"Updated"}):null,t.jsx("span",{className:"ms-auto shrink-0 text-meta text-ink-dim tabular-nums",children:"members"in c?yn(c.members):t.jsx(Wi,{source:c.source,appearance:"text"})})]}),t.jsxs("span",{className:"flex min-h-lh w-full items-baseline text-meta text-ink-muted",children:[w&&Ze(c)==="proactive"?t.jsxs("span",{className:"me-1 shrink-0","data-testid":"roster-row-proactive",children:[t.jsx("span",{className:"text-ink",children:Qs.proactive}),t.jsx("span",{className:"text-ink-dim",children:" ·"})]}):null,c.description?t.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.description}):t.jsx("span",{className:"min-w-0 flex-1 truncate text-ink-dim",children:s("ui.agents.detail.no_description")})]})]})},c.name)})})}function Hl(e,n,a,l){const i=n.trim().toLowerCase();return(e??[]).filter(o=>a==="builtin"&&o.source!=="builtin"||a==="installed"&&o.source!=="installed"||a==="custom"&&o.source!=="custom"?!1:i?l(o.name).toLowerCase().includes(i)||o.name.toLowerCase().includes(i)||(o.description??"").toLowerCase().includes(i):!0)}function Kl(e,n){const a=n.trim().toLowerCase();return(e??[]).filter(l=>!a||l.name.toLowerCase().includes(a)||(l.label??"").toLowerCase().includes(a)||(l.description??"").toLowerCase().includes(a))}export{ql as AddManuallyButton,tr as AgentsPage,Ul as AskPaneCopy};
|