local-operator-ui 0.32.1 → 0.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/main/index.js +27 -0
- package/out/preload/index.js +34 -0
- package/out/renderer/assets/{_basePickBy-DN1soX-A.js → _basePickBy-B8Qlf7Er.js} +1 -1
- package/out/renderer/assets/{_baseUniq-RMmELqQ5.js → _baseUniq-Dsdryz8Q.js} +1 -1
- package/out/renderer/assets/{agent-details-page-COT3PIN2.js → agent-details-page-D3M6i4Zf.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-C-es-mk1.js → agent-hub-page-4mSQ6ykI.js} +1 -1
- package/out/renderer/assets/{agents-page-o7n6ecG3.js → agents-page-_DauTxks.js} +3 -3
- package/out/renderer/assets/{arc-DS8xQWUs.js → arc-DIKk33c1.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-B7sJdcPR.js → architectureDiagram-IEHRJDOE-D_iXTZhU.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-CEZT1uDD.js → blockDiagram-JOT3LUYC-CFQBvLl2.js} +1 -1
- package/out/renderer/assets/{book-open-BAj696yM.js → book-open-Dm0X0_nl.js} +1 -1
- package/out/renderer/assets/browser-page-COd60oBu.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-BCo8np7p.js → browser-webauthn-prompt-CCnbkKBw.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-DBVjyCLA.js → c4Diagram-VJAJSXHY-hSZ61XP8.js} +1 -1
- package/out/renderer/assets/channel-CEa21TjA.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-BxNCkNoW.js → chunk-4BMEZGHF-ByvUxlwL.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-Lfamso1B.js → chunk-A2AXSNBT-C7I3LSLt.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-DWGVRKaK.js → chunk-AEK57VVT-DlcbhveB.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-Cd-lqD91.js → chunk-D6G4REZN-Vr6-1rCd.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-DgyoVs1v.js → chunk-RZ5BOZE2-Ce1S3X33.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-BFhFEYpa.js → chunk-XZIHB7SX-CpwBuqyP.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BclaHtGg.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BclaHtGg.js +1 -0
- package/out/renderer/assets/clone-CEOncWhu.js +1 -0
- package/out/renderer/assets/{console-mirror-CwJYzF72.js → console-mirror-CFdbeNFe.js} +1 -1
- package/out/renderer/assets/{consoleCapture-C9Olow9O.js → consoleCapture-P6eV1Isn.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-OV-zVDW5.js → conversation-input-sync-ztF2uENp.js} +241 -236
- package/out/renderer/assets/{dagre-OKDRZEBW-BOxi2j1A.js → dagre-OKDRZEBW-CFuwTnbl.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-B8l7c4p0.js → diagram-SSKATNLV-eW1-TMoM.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-NKSUB35T.js → diagram-VNBRO52H-COtG874c.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-a6r09WA_.js → erDiagram-Q7BY3M3F-DCpuAzid.js} +1 -1
- package/out/renderer/assets/{error-boundary-CSpbAh09.js → error-boundary-Chq_L-1d.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-BFiGMf_k.js → flowDiagram-4HSFHLVR-D0OpPVjR.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-CYB2B_gT.js → ganttDiagram-APWFNJXF-uZoJ5M51.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DbM7Polm.js → gitGraphDiagram-7IBYFJ6S-dEbJyobF.js} +1 -1
- package/out/renderer/assets/{graph-rfU03juW.js → graph-Bf2xoA4c.js} +1 -1
- package/out/renderer/assets/index-2LU4Cd3s.js +789 -0
- package/out/renderer/assets/{index-UUV473dx.js → index-CNArcL7T.js} +1 -1
- package/out/renderer/assets/index-CUrucNe7.css +1 -0
- package/out/renderer/assets/{index-Csj4v8y7.js → index-DtU-En7k.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-ClJ7U04k.js → infoDiagram-PH2N3AL5-BhEM5meY.js} +1 -1
- package/out/renderer/assets/{installer-CuFSLnbh.js → installer-DuK5l8cx.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BtpUbwn1.js → journeyDiagram-U35MCT3I-HXNpm8Jj.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-C6fCkxuY.js → kanban-definition-NDS4AKOZ-BAtAUqHM.js} +1 -1
- package/out/renderer/assets/{layout-R6hKYsWC.js → layout-CpstO-oE.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-ObLsHUbL.js → legacy-agents-page-DCOC8Tle.js} +1 -1
- package/out/renderer/assets/{mermaid.core-B4zmbJ1v.js → mermaid.core-DmRnOx5f.js} +5 -5
- package/out/renderer/assets/mesh-page-Xh_-o655.js +1 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-B14Q-tDI.js → mindmap-definition-ALO5MXBD-BoIsKamK.js} +1 -1
- package/out/renderer/assets/{mini-DmjYYgQ7.js → mini-Jvr5I_Rk.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-Bl-JDkP1.js → org-surface-gate-CVVzZd9o.js} +1 -1
- package/out/renderer/assets/{page-header-CtaLB27K.js → page-header-DuslXJJm.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-C4F14e7c.js → pieDiagram-IB7DONF6-CfH05_IM.js} +1 -1
- package/out/renderer/assets/{projects-page-IWQ_wrd0.js → projects-page-BGGVrY3C.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Do8zaQAE.js → quadrantDiagram-7GDLP6J5-CAYKVWdZ.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-CksLvXCz.js → radar-MK3ICKWK-CiWFQ2gN.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-UbGqgyO-.js → radient-auth-buttons-DDa7dmwu.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-hacvWToD.js → requirementDiagram-KVF5MWMF-DiB5rNkI.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-BZUs-8o3.js → sankeyDiagram-QLVOVGJD-ZBkoa531.js} +1 -1
- package/out/renderer/assets/{schedules-page-BCltJWXt.js → schedules-page-D29ivDk1.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-2Y2WNAUb.js → sequenceDiagram-X6HHIX6F-BIfJ5ZAM.js} +1 -1
- package/out/renderer/assets/{settings-page-WTysblMK.js → settings-page-DFBspqht.js} +1 -1
- package/out/renderer/assets/{settings-section-4FpgfOx3.js → settings-section-BYsjs9LS.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-BMTZfz59.js → stateDiagram-DGXRK772-DPnXecEL.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-w326tl_e.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-DwYOqPRG.js → timeline-definition-BDJGKUSR-B-Kq_ROU.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-BcI6fr9b.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-BeXUxQ99.js → use-download-agent-mutation-CDNzydiw.js} +1 -1
- package/out/renderer/assets/{use-memberships-query-BCYb4zy-.js → use-memberships-query-CX0l7_F8.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BgB8Xy4z.js → xychartDiagram-VJFVF3MP-CEzW9qk7.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +7 -7
- package/out/renderer/installer.html +4 -4
- package/out/renderer/mini.html +6 -6
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-D4sBd0oc.js +0 -1
- package/out/renderer/assets/channel-C3VXp7A-.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-CvXgJ-UO.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-CvXgJ-UO.js +0 -1
- package/out/renderer/assets/clone-CvVESMNe.js +0 -1
- package/out/renderer/assets/index-BiiXZuiA.css +0 -1
- package/out/renderer/assets/index-C6Rz44O3.js +0 -789
- package/out/renderer/assets/mesh-page-W2mFLFyL.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-yS7nmQDd.js +0 -1
- package/out/renderer/assets/ui-preferences-store-C8Rl4euY.js +0 -1
- /package/out/renderer/assets/{index-D3AKz4S0.js → index-DkZDDEqx.js} +0 -0
package/out/main/index.js
CHANGED
|
@@ -1800,6 +1800,25 @@ const desktopRequestUnion = zod.z.discriminatedUnion("op", [
|
|
|
1800
1800
|
zod.z.object({ op: zod.z.literal("approvals.list") }).strict(),
|
|
1801
1801
|
zod.z.object({ op: zod.z.literal("approvals.approve"), approvalId }).strict(),
|
|
1802
1802
|
zod.z.object({ op: zod.z.literal("approvals.deny"), approvalId }).strict(),
|
|
1803
|
+
/*
|
|
1804
|
+
* THE FLEET ASKS READ (`GET /v1/desktop/asks`), the cross-session companion of
|
|
1805
|
+
* the per-session queue the canonical frame carries. A GET with no parameters
|
|
1806
|
+
* at all: the route answers from the DERIVED ask index under the config dir,
|
|
1807
|
+
* so it needs no session id and no `cwd` — the rows name their own conversation
|
|
1808
|
+
* (`session_id`, `cwd` are the frozen `PendingAsk` shape plus those two keys).
|
|
1809
|
+
*
|
|
1810
|
+
* IT IS A SEPARATE OP FROM THE SESSION QUEUE, deliberately. The session's asks
|
|
1811
|
+
* arrive on its own canonical stream (the frontend state's `asks`), which is
|
|
1812
|
+
* scoped to the conversation being watched and is therefore silent about every
|
|
1813
|
+
* other conversation by construction; "what is waiting across the whole app" is
|
|
1814
|
+
* a question no per-session frame can answer, which is why the drawer's other
|
|
1815
|
+
* scope needs its own read rather than a widened filter on that one.
|
|
1816
|
+
*
|
|
1817
|
+
* THE ANSWER IS A LIST OF RAW ROWS rather than a modelled shape, matching the
|
|
1818
|
+
* route's own reasoning: the rows ARE the frozen `PendingAsk` wire shape, and
|
|
1819
|
+
* re-declaring their fields here would be a third copy of §4 to keep in step.
|
|
1820
|
+
*/
|
|
1821
|
+
zod.z.object({ op: zod.z.literal("asks.list") }).strict(),
|
|
1803
1822
|
/*
|
|
1804
1823
|
* The Projects surface (`/v1/desktop/projects*`), APPENDED to the union
|
|
1805
1824
|
* rather than inserted beside the other catalogue ops: the backend serves
|
|
@@ -2299,6 +2318,14 @@ function desktopEndpoint(request) {
|
|
|
2299
2318
|
return { path: "/v1/desktop/peers", method: "GET" };
|
|
2300
2319
|
case "networks.list":
|
|
2301
2320
|
return { path: "/v1/desktop/networks", method: "GET" };
|
|
2321
|
+
/*
|
|
2322
|
+
* The fleet read, and the path is the DESKTOP plane's rather than the relay's
|
|
2323
|
+
* (`/api/asks`): the two answer the same rows today, but this client reaches
|
|
2324
|
+
* the daemon it is paired with, not the phone relay, and the desktop route is
|
|
2325
|
+
* the one behind this app's own bearer.
|
|
2326
|
+
*/
|
|
2327
|
+
case "asks.list":
|
|
2328
|
+
return { path: "/v1/desktop/asks", method: "GET" };
|
|
2302
2329
|
/*
|
|
2303
2330
|
* THE THREE MESH WRITES. Each path segment is `encodeURIComponent`ed even
|
|
2304
2331
|
* though `meshId` already refuses `/`, `.` and `%`: the schema is this
|
package/out/preload/index.js
CHANGED
|
@@ -427,6 +427,40 @@ const api = {
|
|
|
427
427
|
// Add methods to open files and URLs
|
|
428
428
|
openFile: (filePath) => electron.ipcRenderer.invoke("open-file", filePath),
|
|
429
429
|
readFile: (filePath, encoding) => electron.ipcRenderer.invoke("read-file", filePath, encoding),
|
|
430
|
+
/**
|
|
431
|
+
* The filesystem path behind a `File` the OS handed the renderer.
|
|
432
|
+
*
|
|
433
|
+
* WHY THIS LIVES IN THE PRELOAD. Electron 44 removed the `File.path`
|
|
434
|
+
* augmentation that used to carry it, and its replacement,
|
|
435
|
+
* `webUtils.getPathForFile`, has to be called from a context that can import
|
|
436
|
+
* `electron` - which context isolation deliberately keeps out of the renderer.
|
|
437
|
+
* The `File` travels across the bridge as an argument, which is the shape
|
|
438
|
+
* Electron's own documentation for this API shows (`webUtils` -> "If you want
|
|
439
|
+
* to call this API from a renderer process with context isolation enabled,
|
|
440
|
+
* place the API call in your preload script and expose it using the
|
|
441
|
+
* contextBridge API").
|
|
442
|
+
*
|
|
443
|
+
* WHY THE RENDERER ASKS AT ALL: the composer's attach button already stores a
|
|
444
|
+
* real path for everything it adds, and the send reads that path's bytes in main
|
|
445
|
+
* (`encodeImageAttachments` -> `api.readFile`). A dropped file expressed as a
|
|
446
|
+
* data URL instead would be a second kind of attachment - one whose base64 copy
|
|
447
|
+
* is written into the persisted draft store, which is where a large image turns
|
|
448
|
+
* into a localStorage quota problem the path form simply does not have.
|
|
449
|
+
*
|
|
450
|
+
* NEVER THROWS, and that is the interface rather than defensiveness: the
|
|
451
|
+
* underlying call throws for an argument that is not a `File` and answers `""`
|
|
452
|
+
* for one that was constructed in JS rather than backed by a file on disk (a
|
|
453
|
+
* file dragged out of another page). Both are "this file has no path" for a
|
|
454
|
+
* caller, so both come back as an empty string and the drop handler falls back
|
|
455
|
+
* to reading the bytes.
|
|
456
|
+
*/
|
|
457
|
+
getPathForFile: (file) => {
|
|
458
|
+
try {
|
|
459
|
+
return electron.webUtils.getPathForFile(file);
|
|
460
|
+
} catch {
|
|
461
|
+
return "";
|
|
462
|
+
}
|
|
463
|
+
},
|
|
430
464
|
/**
|
|
431
465
|
* Bytes for the in-app viewers. No encoding: a PDF is not text, and base64
|
|
432
466
|
* would inflate it by a third on both sides of the boundary.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o,c as b,g as v,k as O,h as P,j as p,l as w,m as A,n as x,t as c,o as N}from"./_baseUniq-
|
|
1
|
+
import{e as o,c as b,g as v,k as O,h as P,j as p,l as w,m as A,n as x,t as c,o as N}from"./_baseUniq-Dsdryz8Q.js";import{as as g,aa as y,at as E,au as F,av as M,aw as I,ax as _,ay as $,az as B,aA as T}from"./mermaid.core-DmRnOx5f.js";var S=/\s/;function z(n){for(var r=n.length;r--&&S.test(n.charAt(r)););return r}var G=/^\s+/;function H(n){return n&&n.slice(0,z(n)+1).replace(G,"")}var m=NaN,L=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,q=/^0o[0-7]+$/i,C=parseInt;function K(n){if(typeof n=="number")return n;if(o(n))return m;if(g(n)){var r=typeof n.valueOf=="function"?n.valueOf():n;n=g(r)?r+"":r}if(typeof n!="string")return n===0?n:+n;n=H(n);var t=R.test(n);return t||q.test(n)?C(n.slice(2),t?2:8):L.test(n)?m:+n}var W=1/0,X=17976931348623157e292;function Y(n){if(!n)return n===0?n:0;if(n=K(n),n===W||n===-1/0){var r=n<0?-1:1;return r*X}return n===n?n:0}function D(n){var r=Y(n),t=r%1;return r===r?t?r-t:r:0}function fn(n){var r=n==null?0:n.length;return r?b(n):[]}var l=Object.prototype,J=l.hasOwnProperty,dn=y(function(n,r){n=Object(n);var t=-1,e=r.length,a=e>2?r[2]:void 0;for(a&&E(r[0],r[1],a)&&(e=1);++t<e;)for(var f=r[t],i=F(f),s=-1,d=i.length;++s<d;){var u=i[s],h=n[u];(h===void 0||M(h,l[u])&&!J.call(n,u))&&(n[u]=f[u])}return n});function un(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}function Q(n){return function(r,t,e){var a=Object(r);if(!I(r)){var f=v(t);r=O(r),t=function(s){return f(a[s],s,a)}}var i=n(r,t,e);return i>-1?a[f?r[i]:i]:void 0}}var U=Math.max;function Z(n,r,t){var e=n==null?0:n.length;if(!e)return-1;var a=t==null?0:D(t);return a<0&&(a=U(e+a,0)),P(n,v(r),a)}var hn=Q(Z);function V(n,r){var t=-1,e=I(n)?Array(n.length):[];return p(n,function(a,f,i){e[++t]=r(a,f,i)}),e}function gn(n,r){var t=_(n)?w:V;return t(n,v(r))}var j=Object.prototype,k=j.hasOwnProperty;function nn(n,r){return n!=null&&k.call(n,r)}function vn(n,r){return n!=null&&A(n,r,nn)}function rn(n,r){return n<r}function tn(n,r,t){for(var e=-1,a=n.length;++e<a;){var f=n[e],i=r(f);if(i!=null&&(s===void 0?i===i&&!o(i):t(i,s)))var s=i,d=f}return d}function mn(n){return n&&n.length?tn(n,$,rn):void 0}function an(n,r,t,e){if(!g(n))return n;r=x(r,n);for(var a=-1,f=r.length,i=f-1,s=n;s!=null&&++a<f;){var d=c(r[a]),u=t;if(d==="__proto__"||d==="constructor"||d==="prototype")return n;if(a!=i){var h=s[d];u=void 0,u===void 0&&(u=g(h)?h:B(r[a+1])?[]:{})}T(s,d,u),s=s[d]}return n}function on(n,r,t){for(var e=-1,a=r.length,f={};++e<a;){var i=r[e],s=N(n,i);t(s,i)&&an(f,x(i,n),s)}return f}export{rn as a,tn as b,V as c,on as d,mn as e,fn as f,hn as g,vn as h,dn as i,D as j,un as l,gn as m,Y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aH as S,aI as Rn,ax as T,aJ as w,aK as xn,aL as Mn,aw as sn,aM as mn,aN as un,aO as x,au as U,aP as Cn,aQ as on,aR as Fn,aS as E,aF as gn,aT as R,as as ln,aU as Dn,aV as D,aW as Gn,aX as Un,aY as _,aA as Nn,aZ as Bn,av as Kn,a_ as X,a$ as Hn,b0 as jn,az as Yn,ay as cn,aD as Zn,b1 as m}from"./mermaid.core-B4zmbJ1v.js";var qn="[object Symbol]";function N(n){return typeof n=="symbol"||S(n)&&Rn(n)==qn}function dn(n,r){for(var e=-1,t=n==null?0:n.length,a=Array(t);++e<t;)a[e]=r(n[e],e,n);return a}var J=w?w.prototype:void 0,Q=J?J.toString:void 0;function pn(n){if(typeof n=="string")return n;if(T(n))return dn(n,pn)+"";if(N(n))return Q?Q.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Xn(){}function An(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Jn(n,r,e,t){for(var a=n.length,i=e+-1;++i<a;)if(r(n[i],i,n))return i;return-1}function Qn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,a=n.length;++t<a;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Jn(n,Qn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):Mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||N(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,ar=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,a,i){r.push(a?i.replace(ir,"$1"):t||e)}),r});function fr(n){return n==null?"":pn(n)}function yn(n,r){return T(n)?n:B(n,r)?[n]:ar(fr(n))}function M(n){if(typeof n=="string"||N(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function bn(n,r){r=yn(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[M(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:bn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,a=n.length;++e<t;)n[a+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,a){var i=-1,f=n.length;for(e||(e=ur),a||(a=[]);++i<f;){var s=n[i];e(s)?K(a,s):t||(a[a.length]=s)}return a}function or(n,r,e,t){var a=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++a]);++a<i;)e=r(e,n[a],a,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,U(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,a=0,i=[];++e<t;){var f=n[e];r(f,e,n)&&(i[a++]=f)}return i}function hn(){return[]}var cr=Object.prototype,dr=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,H=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return dr.call(n,r)}))}:hn;function pr(n,r){return x(n,H(n),r)}var Ar=Object.getOwnPropertySymbols,wn=Ar?function(n){for(var r=[];n;)K(r,H(n)),n=Cn(n);return r}:hn;function yr(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,H)}function br(n){return On(n,U,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Ir="[object Date]",Pr="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",Mr="[object Symbol]",mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Ur="[object Int16Array]",Nr="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",jr="[object Uint32Array]";function Yr(n,r,e){var t=n.constructor;switch(r){case mr:return on(n);case Er:case Ir:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Ur:case Nr:case Br:case Kr:case Hr:case jr:return Fn(n,e);case Pr:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case Mr:return Sr(n)}}var Zr="[object Map]";function qr(n){return S(n)&&E(n)==Zr}var nn=R&&R.isMap,Xr=nn?gn(nn):qr,Jr="[object Set]";function Qr(n){return S(n)&&E(n)==Jr}var rn=R&&R.isSet,Wr=rn?gn(rn):Qr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",ae="[object Map]",fe="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",de="[object DataView]",pe="[object Float32Array]",Ae="[object Float64Array]",ye="[object Int8Array]",be="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[de]=g[re]=g[ee]=g[pe]=g[Ae]=g[ye]=g[be]=g[Te]=g[ae]=g[fe]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,a,i){var f,s=r&zr,u=r&Vr,d=r&kr;if(f!==void 0)return f;if(!ln(n))return n;var l=T(n);if(l){if(f=wr(n),!s)return Dn(n,f)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!a){if(f=u||c?{}:Un(n),!s)return u?yr(n,lr(f,n)):pr(n,gr(f,n))}else{if(!g[o])return a?n:{};f=Yr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,f),Wr(n)?n.forEach(function(p){f.add(C(p,r,e,p,n,i))}):Xr(n)&&n.forEach(function(p,A){f.set(A,C(p,r,e,A,n,i))});var y=d?u?br:G:u?U:$,b=l?void 0:y(n);return An(b||n,function(p,A){b&&(A=p,p=n[A]),Nn(f,A,C(p,r,e,A,n,i))}),f}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function I(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}I.prototype.add=I.prototype.push=Se;I.prototype.has=Ee;function Ie(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Pe=1,ve=2;function In(n,r,e,t,a,i){var f=e&Pe,s=n.length,u=r.length;if(s!=u&&!(f&&u>s))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var o=-1,c=!0,h=e&ve?new I:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var y=n[o],b=r[o];if(t)var p=f?t(b,y,o,r,n,i):t(y,b,o,n,r,i);if(p!==void 0){if(p)continue;c=!1;break}if(h){if(!Ie(r,function(A,O){if(!En(h,O)&&(y===A||a(y,A,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(y===b||a(y,b,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,a){e[++r]=[a,t]}),e}function j(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,Me="[object Boolean]",me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ue="[object Set]",Ne="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",He="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function je(n,r,e,t,a,i,f){switch(e){case He:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new X(n),new X(r)));case Me:case me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ne:return n==r+"";case Fe:var s=Le;case Ue:var u=tℜif(s||(s=j),n.size!=r.size&&!u)return!1;var d=f.get(n);if(d)return d==r;t|=xe,f.set(n,r);var l=In(s(n),s(r),t,a,i,f);return f.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var Ye=1,Ze=Object.prototype,qe=Ze.hasOwnProperty;function Xe(n,r,e,t,a,i){var f=e&Ye,s=G(n),u=s.length,d=G(r),l=d.length;if(u!=l&&!f)return!1;for(var o=u;o--;){var c=s[o];if(!(f?c in r:qe.call(r,c)))return!1}var h=i.get(n),y=i.get(r);if(h&&y)return h==r&&y==n;var b=!0;i.set(n,r),i.set(r,n);for(var p=f;++o<u;){c=s[o];var A=n[c],O=r[c];if(t)var q=f?t(O,A,c,r,n,i):t(A,O,c,n,r,i);if(!(q===void 0?A===O||a(A,O,e,t,i):q)){b=!1;break}p||(p=c=="constructor")}if(b&&!p){var P=n.constructor,v=r.constructor;P!=v&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof v=="function"&&v instanceof v)&&(b=!1)}return i.delete(n),i.delete(r),b}var Je=1,tn="[object Arguments]",an="[object Array]",L="[object Object]",Qe=Object.prototype,fn=Qe.hasOwnProperty;function We(n,r,e,t,a,i){var f=T(n),s=T(r),u=f?an:E(n),d=s?an:E(r);u=u==tn?L:u,d=d==tn?L:d;var l=u==L,o=d==L,c=u==d;if(c&&D(n)){if(!D(r))return!1;f=!0,l=!1}if(c&&!l)return i||(i=new _),f||Hn(n)?In(n,r,e,t,a,i):je(n,r,u,e,t,a,i);if(!(e&Je)){var h=l&&fn.call(n,"__wrapped__"),y=o&&fn.call(r,"__wrapped__");if(h||y){var b=h?n.value():n,p=y?r.value():r;return i||(i=new _),a(b,p,e,t,i)}}return c?(i||(i=new _),Xe(n,r,e,t,a,i)):!1}function Y(n,r,e,t,a){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,Y,a)}var ze=1,Ve=2;function ke(n,r,e,t){var a=e.length,i=a;if(n==null)return!i;for(n=Object(n);a--;){var f=e[a];if(f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++a<i;){f=e[a];var s=f[0],u=n[s],d=f[1];if(f[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?Y(d,u,ze|Ve,t,l):o))return!1}}return!0}function Pn(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],a=n[t];r[e]=[t,a,Pn(a)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=yn(r,n);for(var t=-1,a=r.length,i=!1;++t<a;){var f=M(r[t]);if(!(i=n!=null&&e(n,f)))break;n=n[f]}return i||++t!=a?i:(a=n==null?0:n.length,!!a&&jn(a)&&Yn(f,a)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var at=1,ft=2;function st(n,r){return B(n)&&Pn(r)?vn(M(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):Y(r,t,at|ft)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return bn(r,n)}}function gt(n){return B(n)?ut(M(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Zn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var a=e.length,i=-1,f=Object(e);++i<a&&t(f[i],i,f)!==!1;);return e}}var Z=ct(lt);function dt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?An:Z;return e(n,dt(r))}function pt(n,r){var e=[];return Z(n,function(t,a,i){r(t,a,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:pt;return e(n,Ln(r))}function At(n,r){return dn(r,function(e){return n[e]})}function St(n){return n==null?[]:At(n,$(n))}function Et(n){return n===void 0}function yt(n,r,e,t,a){return a(n,function(i,f,s){e=t?(t=!1,i):r(e,i,f,s)}),e}function It(n,r,e){var t=T(n)?or:yt,a=arguments.length<3;return t(n,Ln(r),e,a,Z)}var bt=1/0,Tt=m&&1/j(new m([,-0]))[1]==bt?function(n){return new m(n)}:Xn,ht=200;function Pt(n,r,e){var t=-1,a=Vn,i=n.length,f=!0,s=[],u=s;if(i>=ht){var d=r?null:Tt(n);if(d)return j(d);f=!1,a=En,u=new I}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,f&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else a(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,pt as B,Ie as C,Xn as D,I as S,Pt as a,C as b,Ot as c,$t as d,N as e,_t as f,Ln as g,Jn as h,Et as i,Z as j,$ as k,dn as l,tt as m,yn as n,bn as o,dt as p,lt as q,It as r,it as s,M as t,fr as u,St as v,Vn as w,En as x,zn as y,br as z};
|
|
1
|
+
import{aH as S,aI as Rn,ax as T,aJ as w,aK as xn,aL as Mn,aw as sn,aM as mn,aN as un,aO as x,au as U,aP as Cn,aQ as on,aR as Fn,aS as E,aF as gn,aT as R,as as ln,aU as Dn,aV as D,aW as Gn,aX as Un,aY as _,aA as Nn,aZ as Bn,av as Kn,a_ as X,a$ as Hn,b0 as jn,az as Yn,ay as cn,aD as Zn,b1 as m}from"./mermaid.core-DmRnOx5f.js";var qn="[object Symbol]";function N(n){return typeof n=="symbol"||S(n)&&Rn(n)==qn}function dn(n,r){for(var e=-1,t=n==null?0:n.length,a=Array(t);++e<t;)a[e]=r(n[e],e,n);return a}var J=w?w.prototype:void 0,Q=J?J.toString:void 0;function pn(n){if(typeof n=="string")return n;if(T(n))return dn(n,pn)+"";if(N(n))return Q?Q.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Xn(){}function An(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Jn(n,r,e,t){for(var a=n.length,i=e+-1;++i<a;)if(r(n[i],i,n))return i;return-1}function Qn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,a=n.length;++t<a;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Jn(n,Qn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):Mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||N(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,ar=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,a,i){r.push(a?i.replace(ir,"$1"):t||e)}),r});function fr(n){return n==null?"":pn(n)}function yn(n,r){return T(n)?n:B(n,r)?[n]:ar(fr(n))}function M(n){if(typeof n=="string"||N(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function bn(n,r){r=yn(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[M(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:bn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,a=n.length;++e<t;)n[a+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,a){var i=-1,f=n.length;for(e||(e=ur),a||(a=[]);++i<f;){var s=n[i];e(s)?K(a,s):t||(a[a.length]=s)}return a}function or(n,r,e,t){var a=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++a]);++a<i;)e=r(e,n[a],a,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,U(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,a=0,i=[];++e<t;){var f=n[e];r(f,e,n)&&(i[a++]=f)}return i}function hn(){return[]}var cr=Object.prototype,dr=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,H=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return dr.call(n,r)}))}:hn;function pr(n,r){return x(n,H(n),r)}var Ar=Object.getOwnPropertySymbols,wn=Ar?function(n){for(var r=[];n;)K(r,H(n)),n=Cn(n);return r}:hn;function yr(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,H)}function br(n){return On(n,U,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Ir="[object Date]",Pr="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",Mr="[object Symbol]",mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Ur="[object Int16Array]",Nr="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",jr="[object Uint32Array]";function Yr(n,r,e){var t=n.constructor;switch(r){case mr:return on(n);case Er:case Ir:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Ur:case Nr:case Br:case Kr:case Hr:case jr:return Fn(n,e);case Pr:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case Mr:return Sr(n)}}var Zr="[object Map]";function qr(n){return S(n)&&E(n)==Zr}var nn=R&&R.isMap,Xr=nn?gn(nn):qr,Jr="[object Set]";function Qr(n){return S(n)&&E(n)==Jr}var rn=R&&R.isSet,Wr=rn?gn(rn):Qr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",ae="[object Map]",fe="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",de="[object DataView]",pe="[object Float32Array]",Ae="[object Float64Array]",ye="[object Int8Array]",be="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[de]=g[re]=g[ee]=g[pe]=g[Ae]=g[ye]=g[be]=g[Te]=g[ae]=g[fe]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,a,i){var f,s=r&zr,u=r&Vr,d=r&kr;if(f!==void 0)return f;if(!ln(n))return n;var l=T(n);if(l){if(f=wr(n),!s)return Dn(n,f)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!a){if(f=u||c?{}:Un(n),!s)return u?yr(n,lr(f,n)):pr(n,gr(f,n))}else{if(!g[o])return a?n:{};f=Yr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,f),Wr(n)?n.forEach(function(p){f.add(C(p,r,e,p,n,i))}):Xr(n)&&n.forEach(function(p,A){f.set(A,C(p,r,e,A,n,i))});var y=d?u?br:G:u?U:$,b=l?void 0:y(n);return An(b||n,function(p,A){b&&(A=p,p=n[A]),Nn(f,A,C(p,r,e,A,n,i))}),f}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function I(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}I.prototype.add=I.prototype.push=Se;I.prototype.has=Ee;function Ie(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Pe=1,ve=2;function In(n,r,e,t,a,i){var f=e&Pe,s=n.length,u=r.length;if(s!=u&&!(f&&u>s))return!1;var d=i.get(n),l=i.get(r);if(d&&l)return d==r&&l==n;var o=-1,c=!0,h=e&ve?new I:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var y=n[o],b=r[o];if(t)var p=f?t(b,y,o,r,n,i):t(y,b,o,n,r,i);if(p!==void 0){if(p)continue;c=!1;break}if(h){if(!Ie(r,function(A,O){if(!En(h,O)&&(y===A||a(y,A,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(y===b||a(y,b,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,a){e[++r]=[a,t]}),e}function j(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,Me="[object Boolean]",me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ue="[object Set]",Ne="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",He="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function je(n,r,e,t,a,i,f){switch(e){case He:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new X(n),new X(r)));case Me:case me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ne:return n==r+"";case Fe:var s=Le;case Ue:var u=tℜif(s||(s=j),n.size!=r.size&&!u)return!1;var d=f.get(n);if(d)return d==r;t|=xe,f.set(n,r);var l=In(s(n),s(r),t,a,i,f);return f.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var Ye=1,Ze=Object.prototype,qe=Ze.hasOwnProperty;function Xe(n,r,e,t,a,i){var f=e&Ye,s=G(n),u=s.length,d=G(r),l=d.length;if(u!=l&&!f)return!1;for(var o=u;o--;){var c=s[o];if(!(f?c in r:qe.call(r,c)))return!1}var h=i.get(n),y=i.get(r);if(h&&y)return h==r&&y==n;var b=!0;i.set(n,r),i.set(r,n);for(var p=f;++o<u;){c=s[o];var A=n[c],O=r[c];if(t)var q=f?t(O,A,c,r,n,i):t(A,O,c,n,r,i);if(!(q===void 0?A===O||a(A,O,e,t,i):q)){b=!1;break}p||(p=c=="constructor")}if(b&&!p){var P=n.constructor,v=r.constructor;P!=v&&"constructor"in n&&"constructor"in r&&!(typeof P=="function"&&P instanceof P&&typeof v=="function"&&v instanceof v)&&(b=!1)}return i.delete(n),i.delete(r),b}var Je=1,tn="[object Arguments]",an="[object Array]",L="[object Object]",Qe=Object.prototype,fn=Qe.hasOwnProperty;function We(n,r,e,t,a,i){var f=T(n),s=T(r),u=f?an:E(n),d=s?an:E(r);u=u==tn?L:u,d=d==tn?L:d;var l=u==L,o=d==L,c=u==d;if(c&&D(n)){if(!D(r))return!1;f=!0,l=!1}if(c&&!l)return i||(i=new _),f||Hn(n)?In(n,r,e,t,a,i):je(n,r,u,e,t,a,i);if(!(e&Je)){var h=l&&fn.call(n,"__wrapped__"),y=o&&fn.call(r,"__wrapped__");if(h||y){var b=h?n.value():n,p=y?r.value():r;return i||(i=new _),a(b,p,e,t,i)}}return c?(i||(i=new _),Xe(n,r,e,t,a,i)):!1}function Y(n,r,e,t,a){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,Y,a)}var ze=1,Ve=2;function ke(n,r,e,t){var a=e.length,i=a;if(n==null)return!i;for(n=Object(n);a--;){var f=e[a];if(f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++a<i;){f=e[a];var s=f[0],u=n[s],d=f[1];if(f[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?Y(d,u,ze|Ve,t,l):o))return!1}}return!0}function Pn(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],a=n[t];r[e]=[t,a,Pn(a)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=yn(r,n);for(var t=-1,a=r.length,i=!1;++t<a;){var f=M(r[t]);if(!(i=n!=null&&e(n,f)))break;n=n[f]}return i||++t!=a?i:(a=n==null?0:n.length,!!a&&jn(a)&&Yn(f,a)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var at=1,ft=2;function st(n,r){return B(n)&&Pn(r)?vn(M(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):Y(r,t,at|ft)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return bn(r,n)}}function gt(n){return B(n)?ut(M(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Zn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var a=e.length,i=-1,f=Object(e);++i<a&&t(f[i],i,f)!==!1;);return e}}var Z=ct(lt);function dt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?An:Z;return e(n,dt(r))}function pt(n,r){var e=[];return Z(n,function(t,a,i){r(t,a,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:pt;return e(n,Ln(r))}function At(n,r){return dn(r,function(e){return n[e]})}function St(n){return n==null?[]:At(n,$(n))}function Et(n){return n===void 0}function yt(n,r,e,t,a){return a(n,function(i,f,s){e=t?(t=!1,i):r(e,i,f,s)}),e}function It(n,r,e){var t=T(n)?or:yt,a=arguments.length<3;return t(n,Ln(r),e,a,Z)}var bt=1/0,Tt=m&&1/j(new m([,-0]))[1]==bt?function(n){return new m(n)}:Xn,ht=200;function Pt(n,r,e){var t=-1,a=Vn,i=n.length,f=!0,s=[],u=s;if(i>=ht){var d=r?null:Tt(n);if(d)return j(d);f=!1,a=En,u=new I}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,f&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else a(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,pt as B,Ie as C,Xn as D,I as S,Pt as a,C as b,Ot as c,$t as d,N as e,_t as f,Ln as g,Jn as h,Et as i,Z as j,$ as k,dn as l,tt as m,yn as n,bn as o,dt as p,lt as q,It as r,it as s,M as t,fr as u,St as v,Vn as w,En as x,zn as y,br as z};
|
package/out/renderer/assets/{agent-details-page-COT3PIN2.js → agent-details-page-D3M6i4Zf.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as E,j as e,c as Z}from"./index-
|
|
1
|
+
import{r as E,j as e,c as Z}from"./index-DkZDDEqx.js";import{l as ue,c as he,u as xe,d as ge,g as je,i as fe,a as pe,b as ye,e as ve}from"./use-memberships-query-CX0l7_F8.js";import{aG as ne,u as I,aM as b,aN as K,ax as Y,aO as O,aP as ie,aQ as re,aR as we,ay as be,aS as Ce,aT as J,aw as Ne,aU as Ae,aV as ke}from"./conversation-input-sync-ztF2uENp.js";import{c as Se,L as De,T as ee,B as l,S as z,a as oe,b as M,d as L,e as v,X as Te,f as w,A as te,g as se,h as ae}from"./error-boundary-Chq_L-1d.js";import{f as W,u as Ee,i as Fe,a as _e,b as Pe,c as qe,O as Me,H as Le,A as ze}from"./use-download-agent-mutation-CDNzydiw.js";import{S as Ie,a as Ke,A as Oe,b as Qe,c as Ue}from"./index-2LU4Cd3s.js";import"./ui-preferences-store-BcI6fr9b.js";import"./en-US-BcB1DWxG.js";import"./book-open-Dm0X0_nl.js";import"./console-mirror-CFdbeNFe.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,j as e,c as C}from"./index-
|
|
1
|
+
import{r,j as e,c as C}from"./index-DkZDDEqx.js";import{aQ as De,aM as xe,aS as Re,aG as ms,aH as hs,u as xs,aN as gs,be as fs,aO as ps,a8 as _e,bf as bs,az as js,ay as Be,b3 as vs,bg as Ns,a as ys,bh as ws,aZ as ks,bi as Ts}from"./conversation-input-sync-ztF2uENp.js";import{P as Cs}from"./page-header-DuslXJJm.js";import{c as Ue,f as Q,B as f,e as x,r as Ss,A as J,g as ee,h as se,z as Rs,F as _s,G as As,H as Ps,I as Os,s as Ae,t as Pe,u as Oe,v as Ee,w as ze}from"./error-boundary-Chq_L-1d.js";import{e as Es,f as zs,p as Is,P as Ms,b as Fs,h as Ls}from"./use-memberships-query-CX0l7_F8.js";import{O as $s,A as Ds,f as Bs,H as Us,a as Vs,b as Hs,c as qs,d as Ve,C as Ys,e as Qs,u as Ws,i as Gs}from"./use-download-agent-mutation-CDNzydiw.js";import{c as Zs,at as Xs,as as Ks,au as Js,av as et}from"./index-2LU4Cd3s.js";import{R as st}from"./radient-auth-buttons-DDa7dmwu.js";import{o as He,u as tt,a as at,b as nt}from"./org-surface-gate-CVVzZd9o.js";import{f as it}from"./format-CZUObkkr.js";import"./ui-preferences-store-BcI6fr9b.js";import"./en-US-BcB1DWxG.js";import"./book-open-Dm0X0_nl.js";import"./console-mirror-CFdbeNFe.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-
|
|
2
|
-
import{ao as _e,a$ as yt,as as vt,b0 as kt,a as et,u as wt,b1 as Nt,X as V,b2 as Pe,aO as me,d as ce,aA as Te,ab as St,ac as Ct,ae as Et,S as It,aQ as tt,ah as st,b3 as nt,ax as ke,b4 as at,b5 as At,aR as Tt,b6 as Rt,b7 as $t,b8 as Dt,b9 as Be,ba as Lt,aG as Ft,bb as _t,bc as Ot,bd as Mt}from"./conversation-input-sync-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./legacy-agents-page-DCOC8Tle.js","./index-DkZDDEqx.js","./index-CUrucNe7.css","./conversation-input-sync-ztF2uENp.js","./ui-preferences-store-BcI6fr9b.js","./error-boundary-Chq_L-1d.js","./conversation-input-sync-CIGg7Rga.css","./page-header-DuslXJJm.js","./index-2LU4Cd3s.js","./console-mirror-CFdbeNFe.js","./console-mirror-DOrYoP_4.css","./index-DHKnfVbX.css","./settings-section-BYsjs9LS.js","./use-memberships-query-CX0l7_F8.js","./org-surface-gate-CVVzZd9o.js","./radient-auth-buttons-DDa7dmwu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{ao as _e,a$ as yt,as as vt,b0 as kt,a as et,u as wt,b1 as Nt,X as V,b2 as Pe,aO as me,d as ce,aA as Te,ab as St,ac as Ct,ae as Et,S as It,aQ as tt,ah as st,b3 as nt,ax as ke,b4 as at,b5 as At,aR as Tt,b6 as Rt,b7 as $t,b8 as Dt,b9 as Be,ba as Lt,aG as Ft,bb as _t,bc as Ot,bd as Mt}from"./conversation-input-sync-ztF2uENp.js";import{r as o,j as e,c as Z}from"./index-DkZDDEqx.js";import{ag as Ut,ah as Pt,ai as Bt,aj as qt,ak as zt,al as Wt,am as Ht,an as Kt,ao as Gt,ap as it,aq as Vt,ar as Jt,b as Yt,as as rt,A as Qt}from"./index-2LU4Cd3s.js";import{c as Xt,j as O,B as N,q as Zt,r as es,e as de,A as se,g as ne,h as ae,I as he,s as ot,t as lt,u as ct,v as dt,w as we,x as Ee,y as Ne,T as Le,M as ts,z as ss,F as ns,G as qe}from"./error-boundary-Chq_L-1d.js";import{C as as,c as is}from"./ui-preferences-store-BcI6fr9b.js";import"./console-mirror-CFdbeNFe.js";/**
|
|
3
3
|
* @license lucide-react v0.507.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const rs=[["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"}]],os=Xt("log-in",rs),ls=[],ze="config-composer-note",We="Configure agents by conversation",cs=["A reviewer that only reads code","Add the coder twice to release-crew","A team called shipping with a manager and two coders"],ds={idle:"bg-ink-dim",running:"bg-accent",stopping:"bg-warning",done:"bg-success",stopped:"bg-ink-muted",error:"bg-danger"};function us({status:t,pulse:s}){return e.jsx("span",{"aria-hidden":"true",className:Z("size-2 shrink-0 rounded-full",ds[t]??"bg-ink-dim",s&&"animate-pulse")})}function ms({run:t}){return t.activity.length===0?e.jsx("p",{className:"text-meta text-ink-muted",children:"Nothing to show yet — the run has not called a tool."}):e.jsx("ul",{className:"max-h-48 space-y-1 overflow-y-auto",children:t.activity.map((s,n)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-body-sm",children:[e.jsx("span",{className:"text-ink-dim tabular-nums",children:new Date(s.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),e.jsx("span",{className:"text-ink",children:s.verb})]},`${s.ts}:${s.verb}:${n}`))})}function He({run:t,onDismiss:s}){const[n,a]=o.useState(!1),i=o.useRef(null),l=t.status==="running"||t.status==="stopping";o.useEffect(()=>{if(!l)return;const h=g=>{g.key!=="Escape"||g.defaultPrevented||document.querySelector('[role="alertdialog"], [role="dialog"]')||i.current?.focus()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[l]);const u=t.status==="running"?t.step??"Working on your request":t.status==="stopping"?"Stopping":t.status==="done"?t.results.length>0?"Finished":"Finished without changing anything":t.status==="stopped"?"Stopped":t.status==="error"?t.canRetry?"Stopped with an error":"Finished with an error":"";return e.jsxs("div",{className:"border-hairline border-b pb-2","data-testid":"config-run-strip",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx(us,{status:t.status,pulse:l}),e.jsx("span",{"aria-live":"polite",className:"text-body-sm text-ink",children:u}),(l||t.status==="stopped"||t.status==="done")&&t.elapsed!=="0s"?e.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:t.elapsed}):null,t.touched.length>0?e.jsx(O,{variant:"neutral",children:t.touched.length===1?"1 definition":`${t.touched.length} definitions`}):null,e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[t.activity.length>0?e.jsxs(N,{variant:"ghost",size:"sm","aria-expanded":n,onClick:()=>a(h=>!h),children:[n?e.jsx(Zt,{className:"size-3.5"}):e.jsx(es,{className:"size-3.5"}),"Watch"]}):null,l?e.jsxs(N,{ref:i,variant:"secondary",size:"sm",disabled:t.status==="stopping",onClick:()=>void t.stop(),children:[e.jsx(kt,{className:"size-3.5"}),t.status==="stopping"?"Stopping…":"Stop"]}):e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s?s():t.dismiss(),children:"Dismiss"})]})]}),t.attached?e.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:"Another configuration run was already going, so this page attached to it. Your request was not sent — it is still in the box."}):null,t.stopError?e.jsxs("div",{className:"mt-2 border-danger-border border-t pt-2","data-testid":"config-stop-refused",children:[e.jsx("p",{className:"text-body-sm text-danger",children:"The stop did not take — the run is still going."}),e.jsx("p",{className:"mt-0.5 text-meta text-ink-muted",children:t.stopError})]}):null,n?e.jsx("div",{className:"mt-2 border-hairline border-t pt-2",children:e.jsx(ms,{run:t})}):null,t.status==="stopped"?e.jsxs("div",{className:"mt-2 space-y-1 border-hairline border-t pt-2 text-body-sm",children:[e.jsx("p",{className:"text-ink",children:t.results.length>0?"Stopped. Changes it had already made were kept.":"Stopped. Nothing had been changed yet."}),t.results.length>0?e.jsx("ul",{className:"space-y-0.5",children:t.results.map(h=>e.jsxs("li",{className:"text-ink-muted",children:[h.created?"Created ":"Changed ",e.jsx("span",{className:"text-ink",children:h.target.name})]},`${h.target.kind}:${h.target.name}`))}):null]}):null,t.status==="done"?e.jsx(hs,{run:t}):null,t.status==="error"&&t.error?e.jsxs("div",{className:"mt-2 border-danger-border border-t pt-2",children:[e.jsx("p",{className:"text-body-sm text-danger",children:t.error}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[t.canRetry?e.jsx(N,{variant:"secondary",size:"sm","data-testid":"config-retry",disabled:t.starting,onClick:()=>void t.retry(),children:t.starting?"Sending…":"Retry"}):null,e.jsx("p",{className:"text-meta text-ink-muted",children:"Nothing else was changed by this run."})]})]}):null]})}function hs({run:t}){return t.results.length===0?e.jsxs("div",{className:"mt-2 border-hairline border-t pt-2 text-body-sm",children:[e.jsx("p",{className:"text-ink-muted",children:"The run answered without changing any agent or team."}),t.answer?e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-ink",children:t.answer}):null,t.topic?e.jsxs("p",{className:"mt-1 text-meta text-ink-muted",children:["You asked: ",t.topic]}):null]}):e.jsxs("div",{className:"mt-2 space-y-1 border-hairline border-t pt-2",children:[e.jsx("ul",{className:"space-y-1 text-body-sm",children:t.results.map(s=>e.jsxs("li",{children:[e.jsxs("span",{className:"text-ink",children:[s.created?"Created ":"Updated ",s.target.name]}),e.jsxs("span",{className:"text-ink-muted",children:[" (",s.target.kind,")"]}),s.changes.length>0?e.jsxs("span",{className:"text-ink-muted",children:[": ",s.changes.map(n=>n.label).join(", ")]}):s.created?null:e.jsx("span",{className:"text-ink-muted",children:": its settings changed. The list does not show instructions, so open it to see what was written."})]},`${s.target.kind}:${s.target.name}`))}),t.answer?e.jsx("p",{className:"whitespace-pre-wrap text-body-sm text-ink-muted",children:t.answer}):null]})}const je="agents-config",fs=t=>`Change the ${t.kind} ${t.name}: `;function Re(t,s,n){t.setAbout(s);const a=_e.getState();a.getCurrentInput(je)||a.setComposerText(je,n)}function gs(t){const s=_e.getState();s.getCurrentInput(je).trim()===fs(t).trim()&&s.setComposerText(je,"")}function ut({run:t,hero:s=!1,blockedReason:n,about:a,onClearAbout:i,onStripHeightChange:l}){const u=o.useRef(null),h=o.useRef(null),g=yt(),c=je,r=T=>_e.getState().setCurrentInput(c,T),y=o.useCallback(T=>{if(h.current?.disconnect(),h.current=null,!l)return;if(!T){l(0);return}const $=()=>l(T.getBoundingClientRect().height);if($(),typeof ResizeObserver>"u")return;const D=new ResizeObserver($);D.observe(T),h.current=D},[l]),v=t.status==="running"||t.status==="stopping",j=!t.enabled||!!n,b=n||(v?"Working on your request…":t.enabled?void 0:We),C=a?`Change ${a.name}…`:t.enabled?"Describe what you want…":We,p=a?`${a.kind}:${a.name}`:null;o.useEffect(()=>{p&&u.current?.focusInput()},[p]);const k=()=>{t.dismiss(),u.current?.focusInput()},R=()=>{i(),u.current?.focusInput()};return e.jsxs("div",{className:Z("relative rounded-md border border-hairline bg-surface p-3",s&&"shadow-none"),"data-testid":"config-composer",children:[e.jsx("div",{className:"sr-only",id:"config-composer-label",children:"Ask for an agent or team change"}),t.enabled&&t.status!=="idle"?s?e.jsx(He,{run:t,onDismiss:k}):e.jsx("div",{ref:y,className:"absolute inset-x-0 bottom-full rounded-t-md border-hairline border bg-canvas p-3",children:e.jsx(He,{run:t,onDismiss:k})}):null,a?e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs(O,{variant:"accent","data-testid":"config-composer-about",children:["About ",a.kind," ",a.name]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:R,children:"Clear"})]}):null,e.jsx(vt,{ref:u,conversationId:c,messages:ls,isLoading:!1,transcriptless:!0,placeholderOverride:C,sessionStatus:t.frontend?{frontend:t.frontend}:void 0,recordingProbe:g,hostNotice:{id:ze,blocksInput:!t.enabled||!!n||v,placeholder:b,node:e.jsx("p",{id:ze,"data-testid":"config-composer-note",className:"mb-2 text-meta text-ink-muted",children:t.enabled?"Runs in the background. This does not appear in your conversation.":t.disabledReason})},onSendMessage:(T,$)=>t.start(T,a,$)}),t.enabled?e.jsx("div",{className:Z("mt-2 flex flex-wrap gap-1.5",as,t.enabled&&!a&&!v?"":"invisible"),children:cs.map(T=>e.jsx(N,{variant:"outline",size:"sm",disabled:j,onClick:()=>{r(T),u.current?.focusInput()},children:T},T))}):null]})}const Ke=(t,s)=>t.kind===s.kind&&t.name===s.name;function ps(t){return`${t.kind}:${t.name}`}const z=is(t=>({sessionId:null,status:"idle",topic:"",images:[],about:null,error:null,stopError:null,unsent:!1,startedAt:null,settledAt:null,touched:[],results:[],answer:"",marks:[],before:null,setAbout:s=>t({about:s}),adopt:(s,n,a,i=[])=>t({sessionId:s,status:"running",topic:n,images:i,error:null,stopError:null,startedAt:Date.now(),settledAt:null,touched:[],results:[],answer:"",before:a,unsent:!1}),noteTouched:s=>t(n=>n.touched.some(a=>Ke(a,s))?n:{touched:[...n.touched,s]}),stopping:()=>t(s=>s.status==="running"?{status:"stopping",stopError:null}:s),stopFailed:s=>t({status:"running",stopError:s}),settle:(s,n,a)=>t(()=>({status:n,settledAt:Date.now(),results:s,answer:a,marks:s.map(i=>({...i.target,created:i.created})),sessionId:null,images:[],stopError:null,before:null,unsent:!1})),fail:s=>t({status:"error",error:s,unsent:!1,stopError:null}),failUnsent:s=>t({status:"error",error:s,unsent:!0,stopError:null}),dismiss:()=>t({status:"idle",sessionId:null,error:null,stopError:null,unsent:!1,topic:"",images:[],touched:[],results:[],answer:"",marks:[],startedAt:null,settledAt:null,before:null}),clearMark:s=>t(n=>({marks:n.marks.filter(a=>!Ke(a,s))}))})),xs=/Value error,\s*([\s\S]*?)\s*\[type=/,bs=/^\d+ validation errors? for \S+[\s\S]*?\n\s*/i,js=/\s*\[type=[^\]]*\][\s\S]*$/m,ys=/\s*For further information visit \S+/g,vs=/'([^']+)' already exists/,ks=/cannot contain spaces or path separators/i,ws=/effort tier '([^']+)' is unavailable/i,Ns=/team name must be/i,Ss=/manager '([^']+)'/i,Cs=/(?:member|role) '([^']+)' (?:is not|does not)/i,Es=/depth|cycle|circular/i,Is=/instructions/i,As=/description/i;function Ts(t){const s=t.match(xs);return s?.[1]?s[1].trim():t.replace(bs,"").replace(js,"").replace(ys,"").trim()}function ye(t){const s=Ts(t),n=s.match(vs);if(n)return{message:`An agent called “${n[1]}” already exists. Choose another name, or open the existing one to change it.`,field:"name"};if(ks.test(s))return{message:"Names cannot contain spaces or slashes.",field:"name"};const a=s.match(ws);if(a)return{message:`“${a[1]}” is not a configured effort tier. Use inherit, or add the tier in Settings.`,field:"effort"};if(s.match(Ns))return{message:"A team name is 1-64 characters.",field:"name"};const l=s.match(Ss);if(l)return{message:`“${l[1]}” is not an agent or a team on this machine.`,field:"manager"};const u=s.match(Cs);return u?{message:`“${u[1]}” is not an agent or a team on this machine.`,field:"members"}:Es.test(s)?{message:"That team would nest too deeply, or would contain itself. Check its members.",field:"members"}:Is.test(s)?{message:s,field:"instructions"}:As.test(s)?{message:s,field:"description"}:{message:s,field:null}}function Rs(t,s){const n=new Set(s),a=`${t}-copy`;if(!n.has(a))return a;for(let i=2;i<100;i+=1){const l=`${a}-${i}`;if(!n.has(l))return l}return a}function Ie(t){return t.action_class==="proactive"?"proactive":"reactive"}const $s={proactive:"Proactive"},Ds={proactive:"It may message you on its own: after sending you something it waits a few minutes for a reply, nudges again with growing gaps for a fixed number of tries, then waits for you — and it may also wake on its own schedule.",reactive:"It replies when you write to it. It does not nudge you, and it does not wake on its own schedule."},Ls={proactive:"Turning this off stops the nudging and the scheduled wakes. It still replies when you write to it.",reactive:"Turning this on lets it write first: it will wait a few minutes for your reply, nudge you again up to a fixed number of tries, and it may wake on its own schedule. It still replies when you write to it."},Fs="This one ships with the app and has no copy of its own yet, so switching installs it first — the same agent and the same instructions, now editable — and then sets its class.";function _s(t,s){const n=[];return t.source==="builtin"&&n.push({op:"profiles.install",name:t.name}),n.push({op:"profiles.update",name:t.name,fields:{action_class:s}}),n}async function Os(t,s,n,a=()=>crypto.randomUUID()){if(Ie(t)===s)return null;let i=null;const l=_s(t,s);for(let u=0;u<l.length;u+=1){const h=l[u];try{i=await n(h,a())}catch(g){throw new mt(g,l.slice(0,u))}}return i}class mt extends Error{completed;constructor(s,n){super(s instanceof Error?s.message:String(s)),this.name="ClassSwitchError",this.completed=n}}function Ms(t,s){const n=t instanceof Error&&t.message?t.message:"The backend sent no reason for it. Try the switch again.",a=ye(n).message;return s.some(i=>i.op==="profiles.install")?`${a} The install did land, so the agent is editable now.`:a}const Us=new Set(["agent","team"]);function Ps(t){const s=typeof t.args?.op=="string"?t.args.op:null,n=typeof t.args?.name=="string"?t.args.name:null,a=t.toolName==="team"?"team":"agent",i=n?{kind:a,name:n}:null,l=t.phase==="done"&&!t.isError&&!t.notRunReason&&!t.neverSent,u=h=>({writes:h&&l});switch(s){case"create":return{verb:n?`Creating ${a} ${n}`:`Creating a ${a}`,target:i,...u(!0)};case"update":return{verb:n?`Updating ${a} ${n}`:`Updating a ${a}`,target:i,...u(!0)};case"install":return{verb:n?`Installing ${n}`:"Installing an agent",target:i,...u(!0)};case"list":case"search":case"show":return{verb:n?`Reading ${n}`:`Reading ${a}s`,target:i,...u(!1)};default:return{verb:t.phase==="running"?`Working on ${a}s`:`Checked ${a}s`,target:i,...u(!0)}}}const Bs={description:"description",kind:"kind",tools:"tools",effort:"effort tier",delegate:"delegation",action_class:"class",manager:"manager",members:"members",instructions:"instructions"};function qs(t){return{description:t.description??"",kind:t.kind,tools:t.tools&&t.tools.length>0?[...t.tools].sort().join(","):"*",effort:t.effort??"inherit",delegate:String(!!t.delegate),action_class:Ie(t)}}function zs(t){return{description:t.description??"",manager:t.manager??"",members:(t.members??[]).map(s=>`${s.kind}:${s.role}x${s.count}`).sort().join(",")}}function Ge(t,s){return{agents:Object.fromEntries((t??[]).map(n=>[n.name,qs(n)])),teams:Object.fromEntries((s??[]).map(n=>[n.name,zs(n)]))}}function Ws(t,s){if(t===s)return"tools";const n=h=>h==="*"?null:new Set(h.split(",")),a=n(t),i=n(s);if(i===null)return"tools widened to every tool";if(a===null)return"tools narrowed to a list";const l=[...i].filter(h=>!a.has(h)),u=[...a].filter(h=>!i.has(h));return l.length&&!u.length?l.length===1?`tool added: ${l[0]}`:`${l.length} tools added`:u.length&&!l.length?u.length===1?`tool removed: ${u[0]}`:`${u.length} tools removed`:"tools changed"}function Hs(t,s,n){if(t==="tools")return Ws(s,n);if(t==="delegate")return n==="true"?"delegation turned on":"delegation turned off";if(t==="action_class")return n==="proactive"?"class changed to proactive":"class changed to reactive — proactive messaging stopped";if(t==="members"){const a=i=>i?i.split(",").length:0;return`members changed (${a(s)} to ${a(n)})`}return`${Bs[t]??t} changed`}function Ks(t,s,n){const a=[],i=new Set;for(const l of n){const u=`${l.kind}:${l.name}`;if(i.has(u))continue;i.add(u);const h=t[l.kind==="agent"?"agents":"teams"][l.name],g=s[l.kind==="agent"?"agents":"teams"][l.name];if(!g)continue;if(!h){a.push({target:l,created:!0,changes:[]});continue}const c=[];for(const r of Object.keys(g))g[r]!==h[r]&&c.push({label:Hs(r,h[r],g[r]),before:h[r],after:g[r]});a.push({target:l,created:!1,changes:c})}for(const[l,u]of[["agent",s.agents],["team",s.teams]])for(const h of Object.keys(u))i.has(`${l}:${h}`)||(l==="agent"?t.agents[h]:t.teams[h])||a.push({target:{kind:l,name:h},created:!0,changes:[]});return a}function Gs(t){return ce(t,"agents_config")&&ce(t,"session_interrupt")&&ce(t,"profile_catalogue")&&ce(t,"team_catalogue")}function Vs(t){if(!(t instanceof It)||t.status!==409)return null;const n=t.detail?.session_id;return typeof n=="string"&&n.length>0?n:null}function Js(t,s){const[n,a]=o.useState(()=>Date.now());return o.useEffect(()=>{if(!t||!s)return;const i=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(i)},[t,s]),t?Math.max(0,n-t):0}function Ys(t){const s=Math.floor(t/1e3);return s<60?`${s}s`:`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`}function Ve(t){for(let s=(t?.length??0)-1;s>=0;s-=1){const n=t?.[s];if(n?.kind==="assistant"&&n.text?.trim())return n.text.trim()}return""}function Qs(t){const n=t?.payload?.frontend;if(!n||typeof n!="object")return null;const a=n.streaming;if(typeof a=="boolean")return a;const i=n.snapshot?.streaming;return typeof i=="boolean"?i:null}function Xs(){const t=et(),s=Gs(t.data),n=wt(),a=z(),[i,l]=o.useState(!1),[u,h]=o.useState(!1),g=o.useRef(!1),c=a.status==="running"||a.status==="stopping",r=Nt(a.sessionId??void 0,!!a.sessionId),y=o.useMemo(()=>Ve(r.transcript?.records),[r.transcript?.records]);Ut(a.sessionId??void 0,r.subscriptionId);const v=r.transcript?.records,j=o.useRef(v);o.useEffect(()=>{j.current=v},[v]);const b=o.useMemo(()=>(r.transcript?.records??[]).filter(E=>E.kind==="tool"&&Us.has(E.toolName)).map(E=>({...Ps({toolName:E.toolName,args:E.args??null,phase:E.phase,ts:E.ts,isError:E.isError,notRunReason:E.notRunReason,neverSent:E.neverSent}),ts:E.ts})),[r.transcript]);o.useEffect(()=>{if(c)for(const x of b)x.target&&x.writes&&a.noteTouched(x.target)},[b,c,a]);const C=c&&b.length>0?b[b.length-1].verb:null,p=Ys(Js(a.startedAt,c)),k=o.useCallback(async(x,E="")=>{if(g.current)return;g.current=!0;const L=a.before;let I=[];try{const[U,_]=await Promise.all([V({op:"profiles.list"}),V({op:"teams.list"})]);L&&(I=Ks(L,Ge(U.profiles,_.teams),a.touched))}catch{z.getState().fail("The run finished, but the agents and teams lists could not be read to describe what changed."),Pe(n);return}if(Pe(n),z.getState().settle(I,x,E),x==="done"&&I.length>0){const U=I.filter(_=>_.created).length;me(U>0?`Configuration run finished: ${I.length} definition${I.length===1?"":"s"} changed.`:`Configuration run finished: ${I.length} definition${I.length===1?"":"s"} updated.`)}},[n,a.before,a.touched]);o.useEffect(()=>{if(c){if(r.failure){z.getState().fail(r.failure.statement);return}g.current||r.frontend&&(r.frontend.streaming||r.turnsCompleted!==0&&k(a.status==="stopping"?"stopped":"done",y))}},[c,y,r.failure,r.frontend,r.turnsCompleted,a.status,k]),o.useEffect(()=>{const x=a.sessionId;if(!c||!x)return;let E=!1;const L=async()=>{if(!(E||g.current))try{const _=await V({op:"sessions.get",sessionId:x});if(E||g.current||Qs(_)!==!1)return;const H=Ve(j.current);if(!H)return;k(z.getState().status==="stopping"?"stopped":"done",H)}catch{}},I=setTimeout(()=>void L(),400),U=setInterval(()=>void L(),4e3);return()=>{E=!0,clearTimeout(I),clearInterval(U)}},[c,a.sessionId,k]);const R=async(x,E,L=[])=>{if(i||!x.trim()&&L.length===0)return!1;l(!0),h(!1),g.current=!1;const I=Ge(n.getQueryData(["desktop","profiles"]),n.getQueryData(["desktop","teams"])),U=E?`About the ${E.kind} “${E.name}”: ${x.trim()}`:x.trim(),{images:_,unreadable:H,overflow:q}=await St(L,U),X=Ct(H);if(X)return z.getState().fail(X),!1;const P=Et(q);if(P)return z.getState().fail(P),!1;try{let W;try{W=(await V({op:"sessions.create",requestId:crypto.randomUUID(),purpose:"agents-config"})).session_id}catch(K){const J=Vs(K);if(J)return h(!0),a.adopt(J,x.trim(),I,_),!1;throw K}return a.adopt(W,U,I,_),await T(W,U,_),!0}catch(W){const K=z.getState().sessionId;return z.getState().failUnsent(Te(W,K?"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{l(!1)}},T=async(x,E,L=[])=>{await V({op:"sessions.message",sessionId:x,requestId:crypto.randomUUID(),text:E,...L.length>0?{images:L}:{}})},$=async()=>{const x=z.getState();if(!(i||!x.unsent||!x.sessionId||!x.topic&&x.images.length===0)){l(!0);try{await T(x.sessionId,x.topic,x.images),a.adopt(x.sessionId,x.topic,x.before),g.current=!1}catch(E){z.getState().failUnsent(Te(E,"The request could not be sent. It is still in the box."))}finally{l(!1)}}},D=async()=>{const x=z.getState().sessionId;if(x){a.stopping();try{await Pt(x,crypto.randomUUID())}catch(E){z.getState().stopFailed(Te(E,"The run did not acknowledge the request."))}}},w=s?null:t.isLoading?"Connecting to the backend…":t.error?"The backend could not be reached, so the composer is unavailable for now.":"Ask for a change needs a newer backend. Update Local Operator to configure agents by conversation.";return{enabled:s,disabledReason:w,status:a.status,sessionId:a.sessionId,frontend:r.frontend,topic:a.topic,error:a.error,stopError:a.stopError,about:a.about,setAbout:a.setAbout,touched:a.touched,results:a.results,answer:a.answer,step:C,elapsed:p,activity:b,start:R,stop:D,retry:$,canRetry:a.unsent&&!!a.sessionId,dismiss:a.dismiss,starting:i,attached:u}}function F({title:t,description:s,actions:n,children:a,className:i}){return e.jsxs("section",{className:Z("space-y-2 border-hairline border-t pt-4 first:border-t-0 first:pt-0",i),children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[e.jsx("h3",{className:"text-heading",children:t}),n]}),s?e.jsx("p",{className:"text-meta text-ink-muted",children:s}):null,a]})}function ue({text:t,empty:s="Nothing here yet.",mono:n=!1}){const[a,i]=o.useState(!1),[l,u]=o.useState(!1),h=o.useRef(null);return o.useEffect(()=>{if(a)return;const g=h.current;g&&u(!!t&&g.scrollHeight>g.clientHeight+1)},[t,a]),t.trim()?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{ref:h,tabIndex:0,"aria-label":"The full text",className:Z("whitespace-pre-wrap rounded-sm border border-hairline bg-surface px-3 py-2 text-body-sm text-ink",!a&&"max-h-64 overflow-y-auto",n&&"font-mono text-meta"),children:t}),l?e.jsx(N,{variant:"link",size:"sm",onClick:()=>i(g=>!g),children:a?"Show less":"Show all"}):null]}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:s})}function ht({source:t,appearance:s="chip"}){const n=t==="builtin"?"Built-in":t==="installed"?"Installed":"Custom";return s==="text"?e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n}):e.jsx(O,{variant:"neutral",children:n})}function ft(t,s){o.useEffect(()=>{if(!s)return;const n=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s,t])}function Oe({dirty:t,pending:s,onSave:n,onCancel:a,saveLabel:i="Save changes",pendingLabel:l="Saving…",dirtyHint:u,submit:h,confirming:g,onConfirmingChange:c}){const[r,y]=o.useState(!1),v=o.useRef(null),j=o.useRef(null),b=g!==void 0,C=b?g:r;o.useEffect(()=>{C&&j.current?.focus()},[C]);const p=k=>{b||y(k),c?.(k)};return o.useEffect(()=>{t||(b||y(!1),c?.(!1))},[t,b,c]),e.jsxs("div",{"data-testid":"edit-footer",className:"sticky bottom-0 z-10 -mx-6 mt-6 flex flex-wrap items-center gap-2 border-hairline border-t bg-canvas px-6 py-3",children:[e.jsx(N,{ref:v,type:h?"submit":void 0,variant:"primary",onClick:h?void 0:n,disabled:s,children:s?l:i}),C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:u??"Discard your unsaved changes?"}),e.jsx(N,{variant:"danger",onClick:a,children:"Discard changes"}),e.jsx(N,{ref:j,variant:"ghost",onClick:()=>{p(!1),v.current?.focus()},children:"Keep editing"})]}):e.jsx(N,{variant:"ghost",onClick:()=>t?p(!0):a(),disabled:s,children:"Cancel"}),t&&!C?e.jsx("span",{className:"text-meta text-ink-muted",children:"Unsaved changes"}):null]})}let Fe=!1;function gt(){Fe=!0}function pt(){const t=Fe;return Fe=!1,t}function Zs({rows:t=6}){return e.jsx("div",{className:"space-y-1","aria-hidden":"true",children:en.slice(0,t).map(s=>e.jsx(de,{className:"h-11 w-full"},s))})}const en=["a","b","c","d","e","f","g","h"];function Je(){return e.jsxs("div",{className:"max-w-3xl space-y-6","aria-hidden":"true",children:[e.jsx(de,{className:"h-7 w-64"}),e.jsx(de,{className:"h-5 w-40"}),e.jsx(de,{className:"h-28 w-full"}),e.jsx(de,{className:"h-24 w-full"})]})}function Ye({title:t,what:s,meaning:n,onRetry:a,retrying:i=!1}){return e.jsxs("div",{role:"alert",className:"max-w-xl space-y-2",children:[e.jsx("h2",{className:"text-heading",children:t}),e.jsx("p",{className:"text-body-sm text-ink",children:s}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:n}),e.jsx(N,{variant:"secondary",onClick:a,disabled:i,children:i?"Retrying…":"Retry"})]})}function ee({label:t,htmlFor:s,error:n}){return e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("label",{htmlFor:s,className:"text-body-sm text-ink-muted",children:t}),n?e.jsx("span",{className:"text-meta text-danger",role:"alert",children:n}):null]})}const tn=/^[A-Za-z0-9_.:-]{1,128}$/;function te(t){return{description:t.description??"",instructions:t.instructions??"",tools:t.tools&&t.tools.length>0?[...t.tools]:null,effort:t.effort??"inherit",delegate:t.delegate??!1}}function sn(t,s){const n={};return s.description!==t.description&&(n.description=s.description),s.instructions!==t.instructions&&(n.instructions=s.instructions),JSON.stringify(s.tools)!==JSON.stringify(t.tools)&&(n.tools=s.tools??[]),s.effort!==t.effort&&(n.effort=s.effort),s.delegate!==t.delegate&&(n.delegate=s.delegate),n}function nn({profile:t}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(ht,{source:t.source}),t.divergent_fields?.length?e.jsx(O,{variant:"warning",children:"Modified"}):null,t.kind==="specialist"?e.jsx(O,{variant:"neutral",children:"Specialist"}):null,t.delegate?e.jsx(O,{variant:"neutral",children:"Delegates"}):null,t.tools&&t.tools.length>0?e.jsx(O,{variant:"neutral",children:t.tools.length===1?"1 tool":`${t.tools.length} tools`}):null]})}const an=5e3;let $e=null;function rn({profile:t,displayedName:s,notice:n,onNotice:a,onChanged:i}){const l=Ie(t),[u,h]=o.useState(null),[g,c]=o.useState(!1),r=o.useRef(null),y=o.useId();o.useEffect(()=>{u!==null&&l===u&&h(null)},[l,u]),o.useEffect(()=>{const b=$e;!b||b.name!==t.name||($e=null,!(Date.now()-b.at>an)&&r.current?.focus())},[t.name]);const v=u??l,j=async b=>{if(!(g||b===v)){$e={name:t.name,at:Date.now()},a(null),h(b),c(!0);try{await Os(t,b,(C,p)=>C.op==="profiles.install"?V({op:"profiles.install",name:C.name,requestId:p}):V({op:"profiles.update",name:C.name,requestId:p,fields:C.fields??{}})),i(t.name),me(b==="proactive"?`${s} is now proactive — it may message you on its own.`:`${s} is now reactive — proactive messaging stopped.`)}catch(C){h(null);const p=C instanceof mt?C.completed:[],k=Ms(C,p);a(k),ke(k),i(t.name)}finally{c(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{ref:r,checked:v==="proactive","aria-disabled":g,"aria-labelledby":y,"data-testid":"agent-class-switch",className:"after:absolute after:inset-0 after:content-['']",onCheckedChange:b=>void j(b?"proactive":"reactive")}),e.jsx("span",{id:y,className:"text-ink",children:"Can message me on its own"}),e.jsx("span",{"aria-live":"polite",className:"text-ink-muted",children:g?"Switching…":v==="proactive"?"On":"Off"})]}),e.jsx("p",{className:"text-body-sm text-ink",children:Ds[v]}),e.jsx("p",{className:"text-meta text-ink-muted",children:Ls[v]}),t.source==="builtin"?e.jsx("p",{className:"text-meta text-ink-muted",children:Fs}):null,n?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"agent-class-error",children:[e.jsx(ne,{children:"The switch did not go through"}),e.jsx(ae,{children:n})]}):null]})}function xt({tools:t,onChange:s,error:n}){const[a,i]=o.useState(""),[l,u]=o.useState(null),h=o.useId(),g=()=>{const c=a.trim();if(c){if(!tn.test(c)){u("Tool names are letters, digits, dot, underscore, dash or colon.");return}if(t?.includes(c)){u("That tool is already listed.");return}u(null),i(""),s([...t??[],c])}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{checked:t===null,onCheckedChange:c=>s(c?null:[]),"aria-label":"Give this agent every tool"}),e.jsx("span",{children:"All tools"})]}),t===null?e.jsx("p",{className:"text-meta text-ink-muted",children:"This agent may use whatever the session offers."}):e.jsxs(e.Fragment,{children:[t.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1.5",children:t.map(c=>e.jsx("li",{children:e.jsxs(O,{variant:"outline",children:[c,e.jsx(N,{variant:"ghost",size:"sm","aria-label":`Remove ${c}`,onClick:()=>s(t.filter(r=>r!==c)),className:"ml-1 h-4 px-1",children:"×"})]})},c))}):e.jsx("p",{className:"text-meta text-ink-muted",children:"No tools yet. Add one below, or turn on All tools."}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(ee,{label:"Add a tool",htmlFor:h,error:l??n}),e.jsx(he,{id:h,value:a,inputSize:"md",placeholder:"Tool name","aria-invalid":!!(l??n),onChange:c=>{i(c.target.value),u(null)},onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),g())}})]}),e.jsx(N,{variant:"secondary",onClick:g,disabled:!a.trim(),children:"Add"})]})]})]})}function on({profile:t,displayedName:s,classNotice:n,onClassNotice:a,teams:i,effortTiers:l,askEnabled:u,onSaved:h,onDuplicate:g,onOpenTeam:c,onAskAgent:r,onDirtyChange:y}){const[v,j]=o.useState(!1),[b,C]=o.useState(()=>te(t)),[p,k]=o.useState(()=>te(t)),[R,T]=o.useState(!1),[$,D]=o.useState(null),[w,x]=o.useState(null),[E,L]=o.useState(!1),[I,U]=o.useState(!1),[_,H]=o.useState(!1),q=o.useRef(null),X=tt(),P=JSON.stringify(p)!==JSON.stringify(b);o.useEffect(()=>(y?.(v&&P),()=>y?.(!1)),[y,v,P]),o.useEffect(()=>{pt()&&requestAnimationFrame(()=>q.current?.focus())},[]),o.useEffect(()=>{if(v&&P)return;const f=te(t);C(f),k(f)},[t,v,P]),o.useEffect(()=>{if(!v){U(!1);return}const f=te(t);U(P&&JSON.stringify(f)!==JSON.stringify(b))},[t,v,P,b]);const W=()=>{j(!1),D(null),x(null),L(!1),H(!1);const f=te(t);C(f),k(f)};ft(()=>{if(_){H(!1);return}P?H(!0):W()},v);const J=async f=>{if(f?.preventDefault(),R)return;const A=sn(b,p);if(Object.keys(A).length===0){W();return}if(typeof A.instructions=="string"&&!A.instructions.trim()){D("Give the agent instructions."),x("instructions");return}T(!0),D(null),x(null);try{const G=await V({op:"profiles.update",name:t.name,requestId:crypto.randomUUID(),fields:A});j(!1),L(!1);const Y=te(G);C(Y),k(Y),h(G.name),me(`Saved ${G.name}.`),requestAnimationFrame(()=>q.current?.focus())}catch(G){const Y=ye(G instanceof Error?G.message:"The agent could not be saved.");D(Y.message),x(Y.field);const re=G?.status,fe=typeof re=="number"&&re!==408&&re>=400&&re<500;L(!fe),fe||ke("The save could not be confirmed. Check whether it was applied before retrying.")}finally{T(!1)}},d=async()=>{if(!R){T(!0),D(null);try{const f=await V({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()}),A=te(f);C(A),k(A),h(f.name),me(`Installed ${f.name}. It can be edited now.`),requestAnimationFrame(()=>q.current?.focus())}catch(f){const A=ye(f instanceof Error?f.message:"The agent could not be installed.");D(A.message),ke(A.message)}finally{T(!1)}}},S=(i??[]).filter(f=>f.manager===t.name||(f.members??[]).some(A=>A.role===t.name)),B=t.source==="builtin";return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("h2",{ref:q,tabIndex:-1,className:"text-title focus:outline-none",children:s}),e.jsx(nn,{profile:t})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"primary",onClick:()=>{st.getState().stageDraft({kind:"agent",name:t.name}),X("/chat")},children:"New chat"}),B?e.jsxs(N,{variant:"secondary",onClick:d,disabled:R,children:[e.jsx(os,{className:"size-4"}),R?"Installing…":"Install to edit"]}):e.jsx(N,{variant:"secondary",onClick:()=>{j(!0),D(null),x(null)},children:"Edit"}),e.jsx(N,{variant:"ghost",onClick:()=>g(t),children:"Duplicate as new agent"}),u?e.jsx(N,{variant:"ghost",onClick:()=>r(`Change the agent ${t.name}: `),children:"Ask for a change"}):null]})]}),B?e.jsxs(se,{variant:"info",children:[e.jsx(ne,{children:"Built-in agent"}),e.jsx(ae,{children:"This one ships with the app and cannot be edited in place. Install it to get an editable copy, or duplicate it as a new agent."})]}):null,I?e.jsxs(se,{variant:"warning","data-testid":"agent-conflict",children:[e.jsx(ne,{children:"This changed while you were editing"}),e.jsxs(ae,{children:[e.jsx("span",{className:"block",children:"Something else — a configuration run, or another window — wrote to this agent after you opened it. Your edits are kept; saving writes only the fields you changed."}),e.jsx(N,{variant:"secondary",size:"sm",className:"mt-2",onClick:W,children:"Reload the saved version"})]})]}):null,E?e.jsxs(se,{variant:"danger","data-testid":"agent-unconfirmed",children:[e.jsx(ne,{children:"The last save was not confirmed"}),e.jsx(ae,{children:"The backend did not answer, so the write may or may not have landed. Check the agent below, then edit again."})]}):null,$&&!w?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"agent-save-error",children:[e.jsx(ne,{children:"That did not save"}),e.jsx(ae,{children:$})]}):null]}),e.jsx("form",{noValidate:!0,onSubmit:f=>{f.preventDefault(),J(f)},className:"space-y-6",children:v?e.jsxs(e.Fragment,{children:[e.jsx(Se,{title:"When to use it",description:"One sentence the model reads to decide when this agent is the right one.",label:"When to use this agent",value:p.description,error:w==="description"?$:null,onChange:f=>k(A=>({...A,description:f}))}),e.jsx(Se,{title:"Instructions",description:"What the agent is told to do. This is the agent's whole behaviour.",label:"Instructions",value:p.instructions,rows:12,required:!0,error:w==="instructions"?$:null,onChange:f=>k(A=>({...A,instructions:f}))}),e.jsx(F,{title:"Tools",children:e.jsx(xt,{tools:p.tools,error:w==="tools"?$:null,onChange:f=>k(A=>({...A,tools:f}))})}),e.jsx(F,{title:"Delegation and effort",description:"Whether this agent may hand work to subagents, and which effort tier it runs at.",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{checked:p.delegate,onCheckedChange:f=>k(A=>({...A,delegate:f})),"aria-label":"May delegate to subagents"}),e.jsx("span",{children:"May delegate to subagents"})]}),e.jsxs("div",{className:"max-w-sm space-y-1",children:[e.jsx(ee,{label:"Effort tier",htmlFor:"agent-effort",error:w==="effort"?$:null}),e.jsx(Ne,{ariaLabel:"Effort tier",showLabel:!1,placeholder:"Choose an effort tier",busyLabel:"Loading effort tiers",options:["inherit",...l].map(f=>({id:f,name:f,description:f==="inherit"?"Use the session's own effort":void 0})),selected:{id:p.effort,name:p.effort},onSelect:f=>k(A=>({...A,effort:f.id})),helperText:"Tiers come from the backend's subagent model settings."})]})]})}),e.jsx(Oe,{submit:!0,confirming:_,onConfirmingChange:H,dirty:P,pending:R,onSave:()=>void J(),onCancel:W,saveLabel:"Save changes",dirtyHint:"Discard your unsaved changes to this agent?"})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{title:"When to use it",children:e.jsx(ue,{text:t.description||"",empty:"No description yet — add one so a model knows when to pick this agent."})}),e.jsx(F,{title:"Instructions",children:e.jsx(ue,{text:t.instructions??t.packaged_instructions??"",empty:"No instructions yet."})}),e.jsx(F,{title:"Tools",children:t.tools&&t.tools.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1.5",children:t.tools.map(f=>e.jsx("li",{children:e.jsx(O,{variant:"outline",children:f})},f))}):e.jsx(O,{variant:"neutral",children:"All tools"})}),e.jsxs(F,{title:"Delegation and effort",children:[e.jsx("p",{className:"text-body-sm text-ink",children:t.delegate?"May hand work to subagents.":"Does its own work; it does not delegate."}),e.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Effort tier: ",t.effort??"inherit"]})]}),e.jsx(F,{title:"Messaging",description:"Reactive agents only reply. Proactive agents may also message you first.",children:e.jsx(rn,{profile:t,displayedName:s,notice:n,onNotice:a,onChanged:h})}),e.jsx(F,{title:"Used by",description:"Teams that name this agent as a manager or a member.",children:S.length>0?e.jsx("ul",{className:"flex flex-wrap gap-x-3 gap-y-1",children:S.map(f=>e.jsx("li",{children:e.jsx(N,{variant:"link",onClick:()=>c(f.name),children:f.name})},f.id))}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No team uses it yet."})}),e.jsxs(F,{title:"Where it came from",description:t.source==="builtin"?"Shipped with the app.":t.source==="installed"?"Installed from a packaged starter.":"Created on this machine.",children:[e.jsxs("dl",{className:"space-y-1 text-body-sm",children:[t.seed_origin?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"text-ink-muted",children:"Source"}),e.jsx("dd",{className:"text-ink",children:t.seed_origin})]}):null,t.divergent_fields?.length?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"text-ink-muted",children:"Changed from the packaged copy"}),e.jsx("dd",{className:"text-ink",children:t.divergent_fields.join(", ")})]}):null]}),t.packaged_instructions&&t.divergent_fields?.length?e.jsx(nt,{summary:"Compare with the packaged instructions",className:"mt-2",children:e.jsx(ue,{text:t.packaged_instructions,mono:!0})}):null]})]})})]})}function Se({title:t,description:s,label:n,value:a,onChange:i,rows:l,required:u,error:h,fieldRef:g}){const c=o.useId();return e.jsxs(F,{title:t,description:s,children:[e.jsx(ee,{label:n,htmlFor:c,error:h}),l?e.jsx(Le,{id:c,ref:g,value:a,rows:l,required:u,"aria-invalid":!!h,className:Z("min-h-0"),onChange:r=>i(r.target.value)}):e.jsx(he,{id:c,value:a,"aria-invalid":!!h,onChange:r=>i(r.target.value)})]})}function ln({initial:t,takenNames:s,effortTiers:n,onDirtyChange:a,onSaved:i,onCancel:l}){const[u,h]=o.useState(()=>t?Rs(t.name,s):""),[g,c]=o.useState(t?.kind??"role"),[r,y]=o.useState(()=>t?{...te(t),description:t.description??""}:{description:"",instructions:"",tools:null,effort:"inherit",delegate:!1}),[v,j]=o.useState(!1),[b,C]=o.useState(null),[p,k]=o.useState(null),R=o.useRef(null),T=o.useRef(null);o.useEffect(()=>(a?.(!!(u.trim()||r.instructions.trim())),()=>a?.(!1)),[a,u,r.instructions]),o.useEffect(()=>{R.current?.focus(),R.current?.select()},[]);const $=async w=>{if(w?.preventDefault(),!v){if(!u.trim()){C("Give the agent a name."),k("name"),R.current?.focus();return}if(/[\\/\s]/.test(u.trim())){C("Names cannot contain spaces or slashes."),k("name"),R.current?.focus();return}if(s.includes(u.trim())){C(`An agent called “${u.trim()}” already exists. Choose another name, or open the existing one to change it.`),k("name"),R.current?.focus();return}if(!r.instructions.trim()){C("Give the agent instructions."),k("instructions"),T.current?.focus();return}j(!0),C(null),k(null);try{const x=await V({op:"profiles.create",requestId:crypto.randomUUID(),name:u.trim(),fields:{kind:g,description:r.description,instructions:r.instructions,tools:r.tools??[],effort:r.effort,delegate:r.delegate}});me(`Created ${x.name}.`),gt(),i(x.name)}catch(x){const E=ye(x instanceof Error?x.message:"The agent could not be created.");C(E.message),k(E.field)}finally{j(!1)}}},D=t?"Duplicate as a new agent":"New agent";return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h2",{className:"text-title",children:D}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:t?`A copy of ${t.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."})]}),b&&!p?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"agent-create-error",children:[e.jsx(ne,{children:"That did not save"}),e.jsx(ae,{children:b})]}):null,e.jsxs("form",{noValidate:!0,onSubmit:w=>{w.preventDefault(),$(w)},className:"space-y-6",children:[e.jsx(F,{title:"Name and role",children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ee,{label:"Name",htmlFor:"agent-create-name",error:p==="name"?b:null}),e.jsx(he,{id:"agent-create-name",ref:R,value:u,required:!0,"aria-invalid":p==="name",onChange:w=>h(w.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ee,{label:"How it works with others",htmlFor:"agent-create-kind"}),e.jsxs(ot,{value:g,onValueChange:w=>c(w),children:[e.jsx(lt,{id:"agent-create-kind",children:e.jsx(ct,{})}),e.jsxs(dt,{children:[e.jsx(we,{value:"role",children:"You can chat with it directly"}),e.jsx(we,{value:"specialist",children:"Other agents can call on it"})]})]})]})]})}),e.jsx(Se,{title:"When to use it",description:"One sentence the model reads to decide when this agent is the right one.",label:"When to use this agent",value:r.description,error:p==="description"?b:null,onChange:w=>y(x=>({...x,description:w}))}),e.jsx(Se,{title:"Instructions",description:"What the agent is told to do. This is the agent's whole behaviour.",label:"Instructions",value:r.instructions,rows:12,required:!0,fieldRef:T,error:p==="instructions"?b:null,onChange:w=>y(x=>({...x,instructions:w}))}),e.jsx(F,{title:"Delegation and effort",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{checked:r.delegate,onCheckedChange:w=>y(x=>({...x,delegate:w})),"aria-label":"May delegate to subagents"}),e.jsx("span",{children:"May delegate to subagents"})]}),e.jsxs("div",{className:"max-w-sm space-y-1",children:[e.jsx(ee,{label:"Effort tier",htmlFor:"agent-create-effort"}),e.jsx(Ne,{ariaLabel:"Effort tier",showLabel:!1,busyLabel:"Loading effort tiers",placeholder:"Choose an effort tier",options:["inherit",...n].map(w=>({id:w,name:w,description:w==="inherit"?"Use the session's own effort":"A tier configured in Settings"})),selected:{id:r.effort,name:r.effort},onSelect:w=>y(x=>({...x,effort:w.id}))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:"Tools"}),e.jsx(xt,{tools:r.tools,error:p==="tools"?b:null,onChange:w=>y(x=>({...x,tools:w}))})]})]})}),e.jsx(Oe,{submit:!0,dirty:!!(u.trim()||r.instructions),pending:v,saveLabel:t?"Create the copy":"Create agent",pendingLabel:"Creating…",dirtyHint:"Discard this new agent?",onSave:()=>void $(),onCancel:l})]})]})}const Ce=t=>t==null?"":typeof t=="string"?t:JSON.stringify(t,null,2),cn={available:"border-hairline",updating:"border-hairline",applied:"border-hairline",review:"border-warning-border",failed:"border-danger-border"};function dn(t){const s=[];for(const n of t??[])for(const a of n.fields??[])for(const i of a.regions??[])(i.provenance==="unresolved"||Ce(i.local)!==Ce(i.remote))&&s.push({field:a.field,region:i});return s}function un({regions:t}){return t.length?e.jsx("ul",{className:"space-y-3","data-testid":"hub-update-preview",children:t.map(({field:s,region:n},a)=>e.jsxs("li",{className:"space-y-1 text-meta",children:[e.jsx("p",{className:"font-medium text-ink",children:n.heading||n.name||s}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-ink-muted",children:"Yours"}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:Ce(n.local)||"(nothing)"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-ink-muted",children:"The hub's"}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:Ce(n.remote)||"(nothing)"})]})]})]},`${s}:${n.id??a}`))}):e.jsx("p",{className:"text-meta text-ink-muted",children:"No differences to show: the hub's version matches yours."})}function mn({kind:t,name:s,enabled:n}){const a=Bt(n),i=qt(),[l,u]=o.useState(null),h=Wt(t,s),g=zt(a.data).get(h),c=Ht(g),r=i.notes[h],y=i.pending.has(h);if(!g||!c)return r?e.jsx("section",{"data-testid":"hub-update-panel","aria-label":"Hub update",className:"mb-6 max-w-3xl rounded-md border border-hairline p-3 text-body-sm",children:e.jsx("p",{role:r.tone==="error"?"alert":"status",className:r.tone==="error"?"text-danger":"text-ink",children:r.message})}):null;const v=c.kind==="review",j=g.classification==="baseline-unknown",b=p=>({prefer:p,acknowledgeUnknownBaseline:j}),C=async()=>{const p=await i.applyItem(t,s,{...b(),dryRun:!0});u(p??[])};return e.jsxs("section",{"data-testid":"hub-update-panel","aria-label":"Hub update",className:Z("mb-6 max-w-3xl space-y-2 rounded-md border p-3 text-body-sm",cn[c.kind]),children:[e.jsxs("p",{className:"flex items-start gap-2 text-ink",children:[e.jsx(Kt,{mark:c,className:"mt-0.5"}),e.jsx("span",{className:Z(c.kind==="failed"&&"text-danger"),children:Gt(g,c)})]}),v&&j&&e.jsx("p",{className:"text-meta text-ink-muted",children:"Nothing records what you changed on this device. Either choice adds the hub's additions and deletes nothing of yours; where the two versions differ, your choice decides which wording stays."}),v&&!j&&e.jsx("p",{className:"text-meta text-ink-muted",children:"Where the two versions differ, your choice decides which wording stays. Everything else is merged, and your current version is saved as a backup first."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.kind==="available"&&e.jsx(N,{size:"sm",variant:"outline","aria-disabled":y||void 0,onClick:()=>!y&&void i.applyItem(t,s),children:y?"Updating…":"Update from the hub"}),c.kind==="failed"&&c.retryable&&e.jsx(N,{size:"sm",variant:"outline","aria-disabled":y||void 0,onClick:()=>!y&&void i.retryItem(t,s),children:y?"Retrying…":"Retry"}),v&&e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"sm",variant:"outline","aria-disabled":y||void 0,onClick:()=>!y&&void C(),children:y&&!l?"Loading…":"Preview the differences"}),e.jsx(N,{size:"sm",variant:"ghost","aria-disabled":y||void 0,onClick:()=>!y&&void i.applyItem(t,s,b("local")),children:"Keep mine where they differ"}),e.jsx(N,{size:"sm",variant:"ghost","aria-disabled":y||void 0,onClick:()=>!y&&void i.applyItem(t,s,b("remote")),children:"Use the hub's where they differ"})]})]}),l&&v&&e.jsx(un,{regions:dn(l)}),r&&e.jsx("p",{role:r.tone==="error"?"alert":"status",className:r.tone==="error"?"text-meta text-danger":"text-meta text-ink-muted",children:r.message})]})}function be(t){return{description:t?.description??"",manager:t?.manager??"manager",members:(t?.members??[]).map(s=>({...s,key:crypto.randomUUID()})),instructions:t?.instructions??"",project:t?.project??""}}function hn(t,s){const n={};return s.description!==t.description&&(n.description=s.description),s.manager!==t.manager&&(n.manager=s.manager),JSON.stringify(s.members.map(({key:a,...i})=>i))!==JSON.stringify(t.members.map(({key:a,...i})=>i))&&(n.members=s.members.map(({key:a,...i})=>i)),s.instructions!==t.instructions&&(n.instructions=s.instructions),s.project!==t.project&&(n.project=s.project),n}function Qe(t,s,n){return(t.kind==="agent"?(s??[]).map(i=>i.name):(n??[]).map(i=>i.name)).includes(t.role)}function Xe({team:t,agents:s,teams:n,askEnabled:a,onSaved:i,onCancelCreate:l,onOpenAgent:u,onAskAgent:h,onDirtyChange:g}){const c=!t,[r,y]=o.useState(c),[v,j]=o.useState(t?.name??""),[b,C]=o.useState(()=>be(t)),[p,k]=o.useState(()=>be(t)),[R,T]=o.useState(!1),[$,D]=o.useState(null),[w,x]=o.useState(null),[E,L]=o.useState(!1),I=o.useRef(null),U=o.useRef(null),_=o.useRef(null);o.useEffect(()=>{pt()&&requestAnimationFrame(()=>I.current?.focus())},[]);const H=tt(),q=c?!!(v.trim()||p.description||p.members.length):JSON.stringify(p)!==JSON.stringify(b);o.useEffect(()=>(g?.((c||r)&&q),()=>g?.(!1)),[g,c,r,q]),o.useEffect(()=>{if(r&&q)return;const d=be(t);C(d),k(d)},[t,r,q]);const X=()=>{if(c){l?.();return}y(!1),D(null),x(null),L(!1);const d=be(t);C(d),k(d)};ft(()=>{if(E){L(!1);return}q?L(!0):X()},r);const W=async d=>{if(d?.preventDefault(),!R){if(c&&!v.trim()){D("Give the team a name."),x("name"),_.current?.focus();return}if(c&&/[\\/\s]/.test(v.trim())){D("Names cannot contain spaces or slashes."),x("name"),_.current?.focus();return}if(c&&(n??[]).some(S=>S.name===v.trim())){D(`A team called “${v.trim()}” already exists. Open it to change it, or choose another name.`),x("name"),_.current?.focus();return}if(c&&!p.instructions.trim()){D("Give the team instructions."),x("instructions"),U.current?.focus();return}T(!0),D(null),x(null);try{const S=t?await V({op:"teams.update",name:t.name,requestId:crypto.randomUUID(),fields:hn(b,p)}):await V({op:"teams.create",requestId:crypto.randomUUID(),fields:{name:v,description:p.description,manager:p.manager,members:p.members.map(({key:f,...A})=>A),instructions:p.instructions,project:p.project}}),B=be(S);C(B),k(B),y(!1),i(S.name),me(`${c?"Created":"Saved"} ${S.name}.`),c&>(),requestAnimationFrame(()=>I.current?.focus())}catch(S){const B=ye(S instanceof Error?S.message:"The team could not be saved.");D(B.message),x(B.field),ke(B.message)}finally{T(!1)}}},K=(d,S)=>k(B=>({...B,members:B.members.map((f,A)=>A===d?{...f,...S}:f)})),J=(p.members.length?p.members:t?.members??[]).reduce((d,S)=>d+(S.count||1),0);return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("h2",{ref:I,tabIndex:-1,className:"text-title focus:outline-none",children:t?at(t):"New team"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(O,{variant:"neutral",children:J===1?"1 agent":`${J} agents`}),p.members.some(d=>d.kind==="team")?e.jsx(O,{variant:"neutral",children:"Includes a team"}):null]})]}),t?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"primary",onClick:()=>{st.getState().stageDraft({kind:"team",name:t.name}),H("/chat")},children:"New team chat"}),r?null:e.jsx(N,{variant:"secondary",onClick:()=>y(!0),children:"Edit"}),a?e.jsx(N,{variant:"ghost",onClick:()=>h(`Change the team ${t.name}: `),children:"Ask for a change"}):null]}):null]}),$&&!w?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"team-save-error",children:[e.jsx(ne,{children:"That did not save"}),e.jsx(ae,{children:$})]}):null]}),e.jsx("form",{noValidate:!0,onSubmit:d=>{d.preventDefault(),W(d)},className:"space-y-6",children:c||r?e.jsxs(e.Fragment,{children:[c?e.jsxs(F,{title:"Name",description:"How you and your chats will refer to this team.",children:[e.jsx(ee,{label:"Team name",htmlFor:"team-name",error:w==="name"?$:null}),e.jsx(he,{ref:_,id:"team-name","data-testid":"team-name-input",value:v,required:!0,maxLength:64,autoFocus:!0,"aria-invalid":w==="name",onChange:d=>j(d.target.value)})]}):null,e.jsx(F,{title:"Manager",description:"The agent that leads the chat and decides who works on what.",children:e.jsxs("div",{className:"max-w-md space-y-2",children:[e.jsx(ee,{label:"Manager agent",htmlFor:"team-manager",error:w==="manager"?$:null}),e.jsx(Ne,{ariaLabel:"Manager agent",showLabel:!1,placeholder:"Choose a manager",busyLabel:"Loading agents",options:le(s,n),selected:le(s,n).find(d=>d.id===p.manager)??null,onSelect:d=>k(S=>({...S,manager:d.id})),onCustomSubmit:d=>k(S=>({...S,manager:d})),listNotice:"Agents and teams on this machine"}),le(s,n).some(d=>d.id===p.manager)?null:e.jsxs(O,{variant:"warning","data-testid":"team-manager-missing",children:["Not found: ",p.manager]})]})}),e.jsx(F,{title:"Members",description:"Who the manager can delegate to, and how many of each.",children:e.jsxs("div",{className:"space-y-2",children:[p.members.map((d,S)=>{const B=!Qe(d,s,n);return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"w-56",children:e.jsx(Ne,{ariaLabel:`Member ${S+1}`,showLabel:!1,placeholder:"Choose an agent or team",busyLabel:"Loading agents",options:[...le(s,n).filter(f=>d.kind==="team"?f.group==="Teams":f.group==="Agents")],selected:le(s,n).find(f=>f.id===d.role)??null,onSelect:f=>K(S,{role:f.id,kind:f.group==="Teams"?"team":"agent"}),onCustomSubmit:f=>K(S,{role:f})})}),e.jsxs(ot,{value:d.kind,onValueChange:f=>K(S,{kind:f}),children:[e.jsx(lt,{"aria-label":`Member ${S+1} kind`,className:"w-32",children:e.jsx(ct,{})}),e.jsxs(dt,{children:[e.jsx(we,{value:"agent",children:"Agent"}),e.jsx(we,{value:"team",children:"Team"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(N,{variant:"secondary",size:"icon-sm","aria-label":`One fewer ${d.role}`,disabled:d.count<=1,onClick:()=>K(S,{count:d.count-1}),children:e.jsx(ts,{"aria-hidden":"true"})}),e.jsx("span",{className:"min-w-6 text-center text-body-sm tabular-nums","aria-label":`${d.count} of ${d.role}`,children:d.count}),e.jsx(N,{variant:"secondary",size:"icon-sm","aria-label":`One more ${d.role}`,disabled:d.count>=16,onClick:()=>K(S,{count:d.count+1}),children:e.jsx(it,{"aria-hidden":"true"})})]}),e.jsx(N,{variant:"ghost",onClick:()=>k(f=>({...f,members:f.members.filter((A,G)=>G!==S)})),children:"Remove"}),B?e.jsxs(O,{variant:"warning",children:["Not found: ",d.role]}):null]},d.key)}),e.jsx(N,{variant:"secondary",onClick:()=>k(d=>({...d,members:[...d.members,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]})),children:"Add member"})]})}),e.jsxs(F,{title:"Description",children:[e.jsx(ee,{label:"What this team is for",htmlFor:"team-description",error:w==="description"?$:null}),e.jsx(he,{id:"team-description",value:p.description,onChange:d=>k(S=>({...S,description:d.target.value}))})]}),e.jsxs(F,{title:"Collaboration instructions",children:[w==="instructions"?e.jsx("p",{className:"text-meta text-danger",role:"alert","data-testid":"team-instructions-error",children:$}):null,e.jsx(Le,{ref:U,"aria-label":"Collaboration instructions","aria-invalid":w==="instructions",className:"min-h-36",maxLength:8e3,value:p.instructions,onChange:d=>k(S=>({...S,instructions:d.target.value}))})]}),e.jsx(F,{title:"Project brief",children:e.jsx(Le,{"aria-label":"Project brief",className:"min-h-36",maxLength:8e3,value:p.project,onChange:d=>k(S=>({...S,project:d.target.value}))})}),e.jsx(Oe,{submit:!0,confirming:E,onConfirmingChange:L,dirty:q,pending:R,saveLabel:c?"Create team":"Save changes",pendingLabel:c?"Creating…":"Saving…",dirtyHint:"Discard this team?",onSave:()=>void W(),onCancel:X})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{title:"Manager",description:"The agent that leads the chat.",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"link",onClick:()=>u(p.manager),children:p.manager}),le(s,n).some(d=>d.id===p.manager)?null:e.jsx(O,{variant:"warning","data-testid":"team-manager-missing",children:"Not found"})]})}),e.jsx(F,{title:"Members",children:e.jsx("ul",{className:"space-y-1",children:(t?.members??[]).map(d=>e.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-body-sm",children:[e.jsx("span",{className:"text-ink",children:d.role}),e.jsx(O,{variant:"neutral",children:d.kind==="team"?"Team":"Agent"}),e.jsx("span",{className:"text-ink-muted",children:d.count===1?"×1":`×${d.count}`}),Qe(d,s,n)?null:e.jsx(O,{variant:"warning","data-testid":"team-member-missing",children:"Not found"})]},`${d.kind}:${d.role}`))})}),e.jsx(F,{title:"What it is for",children:e.jsx(ue,{text:t?.description??"",empty:"No description yet."})}),t?.instructions?e.jsx(F,{title:"Collaboration instructions",children:e.jsx(ue,{text:t.instructions})}):null,t?.project?e.jsx(nt,{summary:"Project brief",children:e.jsx(ue,{text:t.project})}):null]})})]})}function le(t,s){return[...(t??[]).map(n=>({id:n.name,name:n.name,description:n.description,group:"Agents"})),...(s??[]).map(n=>({id:n.name,name:n.name,description:n.description,group:"Teams"}))]}const fn=o.lazy(()=>Mt(()=>import("./legacy-agents-page-ObLsHUbL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),Ze=/^subagents\.models\.([^.]+)$/,gn=["lo","med","hi"],De={all:"All",custom:"Custom",installed:"Installed",builtin:"Built-in"},ve=t=>{const s=JSON.stringify(t)??"";let n=5381;for(let a=0;a<s.length;a+=1)n=(n*33^s.charCodeAt(a))>>>0;return`${s.length}.${n.toString(36)}`};function Cn(){const t=At("surface"),{agentId:s}=Tt(),[n,a]=Rt(),i=n.get("kind")==="team"||n.get("create")==="team",l=n.has("create"),u=n.get("name"),h=n.get("duplicate"),g=et(),c=ce(g.data,i?"team_catalogue":"profile_catalogue"),r=$t(c),y=Dt(c),v=c&&!!u&&!l,j=Be(i?null:u,v),b=Lt(i?u:null,v),C=Be(i?null:h,!!h),[p,k]=o.useState(""),[R,T]=o.useState("all"),[$,D]=o.useState(null),[w,x]=o.useState(null),[E,L]=o.useState(0),I=Xs(),U=z(m=>m.marks),_=z(m=>m.clearMark),H=Ft({queryKey:["desktop","settings","effort-tiers"],enabled:c,queryFn:()=>V({op:"settings.list"}),staleTime:6e4}),q=o.useMemo(()=>(H.data?.settings??[]).filter(m=>{const M=m.key.match(Ze)?.[1];return!M||!gn.includes(M)?!1:typeof m.value=="string"&&m.value.trim().length>0}).map(m=>m.key.match(Ze)?.[1]).filter(m=>!!m),[H.data]),X=Vt(),P=o.useCallback(m=>Jt(m,X),[X]),W=o.useMemo(()=>bn(r.data,p,R,P),[r.data,p,R,P]),K=o.useMemo(()=>jn(y.data,p),[y.data,p]),J=i?K:W,d=u??null,[S,B]=o.useState(null);S!==null&&S.name!==d&&B(null);const f=o.useCallback(m=>{const M=new URLSearchParams;(m.kind??(i?"team":"agent"))==="team"&&M.set("kind","team"),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),D(null),a(M)},[i,a]),A=`${i?"team":"agent"}:${l??""}:${d??""}`,G=o.useCallback(m=>x(m?A:null),[A]),Y=w!==null&&w===A,[re,fe]=o.useState(!1),ge=`${i?"team":"agent"}:${d??""}`,ie=i?b.data?ve(b.data):null:j.data?ve(j.data):null,oe=o.useRef({identity:ge,content:ie});o.useEffect(()=>{if(oe.current.identity!==ge){oe.current={identity:ge,content:ie},fe(!1);return}if(ie===null||oe.current.content===null){oe.current={identity:ge,content:ie};return}oe.current.content!==ie&&(oe.current.content=ie,Y&&fe(!0))},[ge,ie,Y]);const Me=(m,M)=>e.jsxs(e.Fragment,{children:[e.jsx(mn,{kind:m,name:M,enabled:ce(g.data,"hub_updates")}),re&&e.jsx("output",{className:"mb-6 block max-w-3xl rounded-md border border-warning-border px-3 py-2 text-meta text-ink-muted",children:"The hub updated this definition while you were editing, and the form below now shows the merged version. Edits you had not saved were replaced."})]}),Q=o.useCallback(m=>{if(Y){D(m);return}f(m)},[Y,f]);o.useEffect(()=>{const m=M=>{M.key!=="Escape"||M.defaultPrevented||window.matchMedia("(max-width: 999px)").matches&&(!d&&!l||(M.preventDefault(),Q({name:null})))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[Q,d,l]),o.useEffect(()=>{const M=z.getState().about;if(!M)return;const Ue=i?"team":"agent";d&&M.kind===Ue&&M.name===d||(I.setAbout(null),gs(M))},[d,i,I]),o.useEffect(()=>{d&&_({kind:i?"team":"agent",name:d})},[d,i,_]);const pe=()=>{r.refetch(),y.refetch(),j.refetch(),b.refetch()};if(s)return e.jsx(o.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(fn,{})});const Ae=i?b.error:j.error,xe=i?y.error:r.error,bt=c&&!xe&&!l&&!d,jt=i?b.isLoading:j.isLoading;return e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{ref:t,"data-open":d?"true":void 0,className:"flex w-72 shrink-0 flex-col gap-3 bg-surface p-4 max-[999px]:data-[open=true]:hidden",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsx(ss,{value:i?"team":"agent",onValueChange:m=>Q({kind:m,name:null}),children:e.jsxs(ns,{"aria-label":"Browse definitions by type",className:"w-full",children:[e.jsxs(qe,{value:"agent",className:"flex-1","data-testid":"agents-tab",children:[e.jsx(Yt,{className:"size-3.5"}),"Agents",r.data?e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:r.data.length}):null]}),e.jsxs(qe,{value:"team",className:"flex-1","data-testid":"teams-tab",children:[e.jsx(_t,{className:"size-3.5"}),"Teams",y.data?e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:y.data.length}):null]})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(Ot,{"aria-hidden":"true",className:"pointer-events-none absolute top-2 left-2 size-4 text-ink-dim"}),e.jsx(he,{className:"pl-8",type:"search","aria-label":"Search agents and teams",placeholder:i?"Search teams":"Search agents",value:p,onChange:m=>k(m.target.value)})]}),!i&&r.data?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{"aria-hidden":"true",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Show definitions owned by"}),e.jsx("div",{className:"flex flex-wrap gap-0.5 rounded-md bg-sunken p-0.5",children:Object.keys(De).map(m=>e.jsx(N,{variant:"ghost",size:"sm","aria-pressed":R===m,onClick:()=>T(m),className:Z(R===m&&rt),children:De[m]},m))})]})]}):null,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe?null:!r.data&&!y.data?e.jsx(Zs,{}):J.length===0?e.jsx("p",{className:"px-1 py-2 text-body-sm text-ink-muted",children:p?`Nothing matches “${p}”.`:i?"No teams yet. Ask for one below, or add one by hand.":R==="all"?"No agents yet. Ask for one below, or add one by hand.":`No ${De[R].toLowerCase()} agents.`}):e.jsx(xn,{rows:J,name:l?null:d,teamMode:i,printName:P,marked:new Map(U.map(m=>[ps(m),m.created])),onOpen:m=>Q({name:m})})}),e.jsxs(N,{variant:"secondary",disabled:!c,onClick:()=>Q({create:i?"team":"agent"}),children:[e.jsx(it,{className:"size-4"}),i?"Add team manually":"Add agent manually"]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[d||l?e.jsx("div",{className:"flex shrink-0 items-center border-hairline border-b px-4 py-2 min-[1000px]:hidden",children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:()=>Q({name:null}),children:[e.jsx(Qt,{className:"size-4"}),"Back to the list"]})}):null,e.jsx("div",{"data-agents-pane":!0,className:"min-h-0 flex-1 overflow-auto p-6 pb-0",style:E>0?{paddingBottom:E+16}:void 0,children:c?xe?e.jsx(Ye,{title:i?"Teams could not be read":"Agents could not be read",what:xe instanceof Error?xe.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:pe,retrying:r.isFetching||y.isFetching}):d&&jt?e.jsx(Je,{}):d&&Ae?e.jsx(Ye,{title:i?`“${d}” could not be read`:`“${d}” could not be read`,what:Ae instanceof Error?Ae.message:"The request did not complete.",meaning:"The definition may have been removed, or the backend refused the read.",onRetry:()=>{j.refetch(),b.refetch()},retrying:j.isFetching||b.isFetching}):l&&i?e.jsx(Xe,{agents:r.data,teams:y.data,askEnabled:I.enabled,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onCancelCreate:()=>f({name:null}),onOpenAgent:m=>Q({kind:"agent",name:m}),onAskAgent:m=>{Re(I,{kind:"team",name:u??""},m)}},"team:create"):l&&h&&C.isLoading?e.jsx(Je,{}):l?e.jsx(ln,{initial:C.data??null,takenNames:(r.data??[]).map(m=>m.name),effortTiers:q,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onCancel:()=>f({name:null})},"agent:create"):i&&b.data?e.jsxs(e.Fragment,{children:[Me("team",b.data.name),e.jsx(Xe,{team:b.data,agents:r.data,teams:y.data,askEnabled:I.enabled,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onOpenAgent:m=>Q({kind:"agent",name:m}),onAskAgent:m=>{Re(I,{kind:"team",name:b.data?.name??""},m)}},`team:${b.data.name}:${ve(b.data)}`)]}):!i&&j.data?e.jsxs(e.Fragment,{children:[Me("agent",j.data.name),e.jsx(on,{profile:j.data,displayedName:P(j.data.name),classNotice:S?.name===j.data.name?S.copy:null,onClassNotice:m=>B(m?{name:j.data.name,copy:m}:null),teams:y.data,effortTiers:q,askEnabled:I.enabled,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onDuplicate:m=>Q({create:"agent",duplicate:m.name}),onOpenTeam:m=>Q({kind:"team",name:m}),onAskAgent:m=>{Re(I,{kind:"agent",name:j.data?.name??""},m)}},`agent:${j.data.name}:${j.data.source}:${ve(j.data)}`)]}):d?e.jsx(de,{className:"h-6 w-40"}):e.jsx(pn,{teamMode:i,run:I,onAddManually:()=>Q({create:i?"team":"agent"})}):e.jsxs(se,{variant:g.isLoading?"neutral":"warning",className:"max-w-xl",children:[e.jsx(ne,{children:g.isLoading?"Connecting to the backend":g.error?"The backend could not be reached":"Reusable agents need a newer backend"}),e.jsx(ae,{children:g.isLoading?"Loading what this backend can do…":g.error?g.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."})]})}),$?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-hairline border-t bg-surface px-4 py-3",role:"alertdialog","aria-label":"Discard your unsaved changes?",children:[e.jsx("span",{className:"text-body-sm text-ink",children:i?"Discard your unsaved changes to this team?":"Discard your unsaved changes to this agent?"}),e.jsx(N,{variant:"danger",onClick:()=>{x(null),f($)},children:"Discard changes"}),e.jsx(N,{variant:"ghost",onClick:()=>D(null),children:"Keep editing"})]}):null,bt?null:e.jsx("div",{className:"shrink-0 border-hairline border-t bg-canvas p-4",children:e.jsx(ut,{run:I,about:I.about,onClearAbout:()=>I.setAbout(null),onStripHeightChange:L,blockedReason:Y?"Finish or cancel your edit first.":null})})]})]})}function pn({teamMode:t,run:s,onAddManually:n}){return e.jsxs("div",{className:"max-w-xl space-y-4",children:[e.jsx("h2",{className:"text-title",children:t?"Ask for a team":"Ask for an agent"}),e.jsx("p",{className:"text-body text-ink-muted",children:t?"A team has one agent that leads the chat and members it can hand work to. Describe what you want and a configuration run sets it up.":"An agent is a reusable set of instructions you can start a chat with, or let other agents call on. Describe what you want and a configuration run sets it up."}),e.jsx(ut,{run:s,hero:!0,about:s.about,onClearAbout:()=>s.setAbout(null)}),e.jsx(N,{variant:"ghost",onClick:n,children:t?"Or add a team by hand":"Or add an agent by hand"})]})}function xn({rows:t,name:s,teamMode:n,marked:a,printName:i,onOpen:l}){const u=o.useRef(new Map),[h,g]=o.useState(s),c=(r,y)=>{const v=t.findIndex(b=>b.name===r);if(v<0)return;const j=t[Math.min(t.length-1,Math.max(0,v+y))];j&&(g(j.name),u.current.get(j.name)?.focus())};return e.jsx("ul",{"aria-label":n?"Teams":"Agents",className:"space-y-1",children:t.map(r=>{const y="source"in r,v=a.get(`${n?"team":"agent"}:${r.name}`);return e.jsx("li",{children:e.jsxs("button",{ref:j=>{j?u.current.set(r.name,j):u.current.delete(r.name)},type:"button","aria-current":r.name===s?"true":void 0,tabIndex:r.name===(h??t[0]?.name)?0:-1,"data-testid":`roster-row-${r.name}`,className:Z("flex min-h-11 w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left hover:bg-row-hover",r.name===s&&rt),onFocus:()=>g(r.name),onClick:()=>l(r.name),onKeyDown:j=>{j.key==="ArrowDown"?(j.preventDefault(),c(r.name,1)):j.key==="ArrowUp"?(j.preventDefault(),c(r.name,-1)):j.key==="Home"?(j.preventDefault(),c(r.name,-t.length)):j.key==="End"&&(j.preventDefault(),c(r.name,t.length))},children:[e.jsxs("span",{className:"flex w-full items-center gap-2",children:[e.jsx("span",{className:"truncate text-body-sm text-ink",children:"members"in r?at(r):i(r.name)}),y?e.jsx(ht,{source:r.source,appearance:"text"}):null,v!==void 0?e.jsx(O,{variant:"attention","data-testid":"roster-row-updated",children:v?"New":"Updated"}):null]}),e.jsxs("span",{className:"flex w-full flex-wrap items-center gap-1.5",children:["members"in r?e.jsx(O,{variant:"neutral",children:r.members.length===1?"1 member":`${r.members.length} members`}):null,y&&Ie(r)==="proactive"?e.jsx(O,{variant:"neutral","data-testid":"roster-row-proactive",children:$s.proactive}):null,r.description?e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:r.description}):null]})]})},r.name)})})}function bn(t,s,n,a){const i=s.trim().toLowerCase();return(t??[]).filter(l=>n==="builtin"&&l.source!=="builtin"||n==="installed"&&l.source!=="installed"||n==="custom"&&l.source!=="custom"?!1:i?a(l.name).toLowerCase().includes(i)||l.name.toLowerCase().includes(i)||(l.description??"").toLowerCase().includes(i):!0)}function jn(t,s){const n=s.trim().toLowerCase();return(t??[]).filter(a=>!n||a.name.toLowerCase().includes(n)||(a.label??"").toLowerCase().includes(n)||(a.description??"").toLowerCase().includes(n))}export{Cn as AgentsPage};
|
|
7
|
+
*/const rs=[["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"}]],os=Xt("log-in",rs),ls=[],ze="config-composer-note",We="Configure agents by conversation",cs=["A reviewer that only reads code","Add the coder twice to release-crew","A team called shipping with a manager and two coders"],ds={idle:"bg-ink-dim",running:"bg-accent",stopping:"bg-warning",done:"bg-success",stopped:"bg-ink-muted",error:"bg-danger"};function us({status:t,pulse:s}){return e.jsx("span",{"aria-hidden":"true",className:Z("size-2 shrink-0 rounded-full",ds[t]??"bg-ink-dim",s&&"animate-pulse")})}function ms({run:t}){return t.activity.length===0?e.jsx("p",{className:"text-meta text-ink-muted",children:"Nothing to show yet — the run has not called a tool."}):e.jsx("ul",{className:"max-h-48 space-y-1 overflow-y-auto",children:t.activity.map((s,n)=>e.jsxs("li",{className:"flex items-baseline gap-2 text-body-sm",children:[e.jsx("span",{className:"text-ink-dim tabular-nums",children:new Date(s.ts).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}),e.jsx("span",{className:"text-ink",children:s.verb})]},`${s.ts}:${s.verb}:${n}`))})}function He({run:t,onDismiss:s}){const[n,a]=o.useState(!1),i=o.useRef(null),l=t.status==="running"||t.status==="stopping";o.useEffect(()=>{if(!l)return;const h=g=>{g.key!=="Escape"||g.defaultPrevented||document.querySelector('[role="alertdialog"], [role="dialog"]')||i.current?.focus()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[l]);const u=t.status==="running"?t.step??"Working on your request":t.status==="stopping"?"Stopping":t.status==="done"?t.results.length>0?"Finished":"Finished without changing anything":t.status==="stopped"?"Stopped":t.status==="error"?t.canRetry?"Stopped with an error":"Finished with an error":"";return e.jsxs("div",{className:"border-hairline border-b pb-2","data-testid":"config-run-strip",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx(us,{status:t.status,pulse:l}),e.jsx("span",{"aria-live":"polite",className:"text-body-sm text-ink",children:u}),(l||t.status==="stopped"||t.status==="done")&&t.elapsed!=="0s"?e.jsx("span",{className:"text-meta text-ink-muted tabular-nums",children:t.elapsed}):null,t.touched.length>0?e.jsx(O,{variant:"neutral",children:t.touched.length===1?"1 definition":`${t.touched.length} definitions`}):null,e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[t.activity.length>0?e.jsxs(N,{variant:"ghost",size:"sm","aria-expanded":n,onClick:()=>a(h=>!h),children:[n?e.jsx(Zt,{className:"size-3.5"}):e.jsx(es,{className:"size-3.5"}),"Watch"]}):null,l?e.jsxs(N,{ref:i,variant:"secondary",size:"sm",disabled:t.status==="stopping",onClick:()=>void t.stop(),children:[e.jsx(kt,{className:"size-3.5"}),t.status==="stopping"?"Stopping…":"Stop"]}):e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s?s():t.dismiss(),children:"Dismiss"})]})]}),t.attached?e.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:"Another configuration run was already going, so this page attached to it. Your request was not sent — it is still in the box."}):null,t.stopError?e.jsxs("div",{className:"mt-2 border-danger-border border-t pt-2","data-testid":"config-stop-refused",children:[e.jsx("p",{className:"text-body-sm text-danger",children:"The stop did not take — the run is still going."}),e.jsx("p",{className:"mt-0.5 text-meta text-ink-muted",children:t.stopError})]}):null,n?e.jsx("div",{className:"mt-2 border-hairline border-t pt-2",children:e.jsx(ms,{run:t})}):null,t.status==="stopped"?e.jsxs("div",{className:"mt-2 space-y-1 border-hairline border-t pt-2 text-body-sm",children:[e.jsx("p",{className:"text-ink",children:t.results.length>0?"Stopped. Changes it had already made were kept.":"Stopped. Nothing had been changed yet."}),t.results.length>0?e.jsx("ul",{className:"space-y-0.5",children:t.results.map(h=>e.jsxs("li",{className:"text-ink-muted",children:[h.created?"Created ":"Changed ",e.jsx("span",{className:"text-ink",children:h.target.name})]},`${h.target.kind}:${h.target.name}`))}):null]}):null,t.status==="done"?e.jsx(hs,{run:t}):null,t.status==="error"&&t.error?e.jsxs("div",{className:"mt-2 border-danger-border border-t pt-2",children:[e.jsx("p",{className:"text-body-sm text-danger",children:t.error}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[t.canRetry?e.jsx(N,{variant:"secondary",size:"sm","data-testid":"config-retry",disabled:t.starting,onClick:()=>void t.retry(),children:t.starting?"Sending…":"Retry"}):null,e.jsx("p",{className:"text-meta text-ink-muted",children:"Nothing else was changed by this run."})]})]}):null]})}function hs({run:t}){return t.results.length===0?e.jsxs("div",{className:"mt-2 border-hairline border-t pt-2 text-body-sm",children:[e.jsx("p",{className:"text-ink-muted",children:"The run answered without changing any agent or team."}),t.answer?e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-ink",children:t.answer}):null,t.topic?e.jsxs("p",{className:"mt-1 text-meta text-ink-muted",children:["You asked: ",t.topic]}):null]}):e.jsxs("div",{className:"mt-2 space-y-1 border-hairline border-t pt-2",children:[e.jsx("ul",{className:"space-y-1 text-body-sm",children:t.results.map(s=>e.jsxs("li",{children:[e.jsxs("span",{className:"text-ink",children:[s.created?"Created ":"Updated ",s.target.name]}),e.jsxs("span",{className:"text-ink-muted",children:[" (",s.target.kind,")"]}),s.changes.length>0?e.jsxs("span",{className:"text-ink-muted",children:[": ",s.changes.map(n=>n.label).join(", ")]}):s.created?null:e.jsx("span",{className:"text-ink-muted",children:": its settings changed. The list does not show instructions, so open it to see what was written."})]},`${s.target.kind}:${s.target.name}`))}),t.answer?e.jsx("p",{className:"whitespace-pre-wrap text-body-sm text-ink-muted",children:t.answer}):null]})}const je="agents-config",fs=t=>`Change the ${t.kind} ${t.name}: `;function Re(t,s,n){t.setAbout(s);const a=_e.getState();a.getCurrentInput(je)||a.setComposerText(je,n)}function gs(t){const s=_e.getState();s.getCurrentInput(je).trim()===fs(t).trim()&&s.setComposerText(je,"")}function ut({run:t,hero:s=!1,blockedReason:n,about:a,onClearAbout:i,onStripHeightChange:l}){const u=o.useRef(null),h=o.useRef(null),g=yt(),c=je,r=T=>_e.getState().setCurrentInput(c,T),y=o.useCallback(T=>{if(h.current?.disconnect(),h.current=null,!l)return;if(!T){l(0);return}const $=()=>l(T.getBoundingClientRect().height);if($(),typeof ResizeObserver>"u")return;const D=new ResizeObserver($);D.observe(T),h.current=D},[l]),v=t.status==="running"||t.status==="stopping",j=!t.enabled||!!n,b=n||(v?"Working on your request…":t.enabled?void 0:We),C=a?`Change ${a.name}…`:t.enabled?"Describe what you want…":We,p=a?`${a.kind}:${a.name}`:null;o.useEffect(()=>{p&&u.current?.focusInput()},[p]);const k=()=>{t.dismiss(),u.current?.focusInput()},R=()=>{i(),u.current?.focusInput()};return e.jsxs("div",{className:Z("relative rounded-md border border-hairline bg-surface p-3",s&&"shadow-none"),"data-testid":"config-composer",children:[e.jsx("div",{className:"sr-only",id:"config-composer-label",children:"Ask for an agent or team change"}),t.enabled&&t.status!=="idle"?s?e.jsx(He,{run:t,onDismiss:k}):e.jsx("div",{ref:y,className:"absolute inset-x-0 bottom-full rounded-t-md border-hairline border bg-canvas p-3",children:e.jsx(He,{run:t,onDismiss:k})}):null,a?e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsxs(O,{variant:"accent","data-testid":"config-composer-about",children:["About ",a.kind," ",a.name]}),e.jsx(N,{variant:"ghost",size:"sm",onClick:R,children:"Clear"})]}):null,e.jsx(vt,{ref:u,conversationId:c,messages:ls,isLoading:!1,transcriptless:!0,placeholderOverride:C,sessionStatus:t.frontend?{frontend:t.frontend}:void 0,recordingProbe:g,hostNotice:{id:ze,blocksInput:!t.enabled||!!n||v,placeholder:b,node:e.jsx("p",{id:ze,"data-testid":"config-composer-note",className:"mb-2 text-meta text-ink-muted",children:t.enabled?"Runs in the background. This does not appear in your conversation.":t.disabledReason})},onSendMessage:(T,$)=>t.start(T,a,$)}),t.enabled?e.jsx("div",{className:Z("mt-2 flex flex-wrap gap-1.5",as,t.enabled&&!a&&!v?"":"invisible"),children:cs.map(T=>e.jsx(N,{variant:"outline",size:"sm",disabled:j,onClick:()=>{r(T),u.current?.focusInput()},children:T},T))}):null]})}const Ke=(t,s)=>t.kind===s.kind&&t.name===s.name;function ps(t){return`${t.kind}:${t.name}`}const z=is(t=>({sessionId:null,status:"idle",topic:"",images:[],about:null,error:null,stopError:null,unsent:!1,startedAt:null,settledAt:null,touched:[],results:[],answer:"",marks:[],before:null,setAbout:s=>t({about:s}),adopt:(s,n,a,i=[])=>t({sessionId:s,status:"running",topic:n,images:i,error:null,stopError:null,startedAt:Date.now(),settledAt:null,touched:[],results:[],answer:"",before:a,unsent:!1}),noteTouched:s=>t(n=>n.touched.some(a=>Ke(a,s))?n:{touched:[...n.touched,s]}),stopping:()=>t(s=>s.status==="running"?{status:"stopping",stopError:null}:s),stopFailed:s=>t({status:"running",stopError:s}),settle:(s,n,a)=>t(()=>({status:n,settledAt:Date.now(),results:s,answer:a,marks:s.map(i=>({...i.target,created:i.created})),sessionId:null,images:[],stopError:null,before:null,unsent:!1})),fail:s=>t({status:"error",error:s,unsent:!1,stopError:null}),failUnsent:s=>t({status:"error",error:s,unsent:!0,stopError:null}),dismiss:()=>t({status:"idle",sessionId:null,error:null,stopError:null,unsent:!1,topic:"",images:[],touched:[],results:[],answer:"",marks:[],startedAt:null,settledAt:null,before:null}),clearMark:s=>t(n=>({marks:n.marks.filter(a=>!Ke(a,s))}))})),xs=/Value error,\s*([\s\S]*?)\s*\[type=/,bs=/^\d+ validation errors? for \S+[\s\S]*?\n\s*/i,js=/\s*\[type=[^\]]*\][\s\S]*$/m,ys=/\s*For further information visit \S+/g,vs=/'([^']+)' already exists/,ks=/cannot contain spaces or path separators/i,ws=/effort tier '([^']+)' is unavailable/i,Ns=/team name must be/i,Ss=/manager '([^']+)'/i,Cs=/(?:member|role) '([^']+)' (?:is not|does not)/i,Es=/depth|cycle|circular/i,Is=/instructions/i,As=/description/i;function Ts(t){const s=t.match(xs);return s?.[1]?s[1].trim():t.replace(bs,"").replace(js,"").replace(ys,"").trim()}function ye(t){const s=Ts(t),n=s.match(vs);if(n)return{message:`An agent called “${n[1]}” already exists. Choose another name, or open the existing one to change it.`,field:"name"};if(ks.test(s))return{message:"Names cannot contain spaces or slashes.",field:"name"};const a=s.match(ws);if(a)return{message:`“${a[1]}” is not a configured effort tier. Use inherit, or add the tier in Settings.`,field:"effort"};if(s.match(Ns))return{message:"A team name is 1-64 characters.",field:"name"};const l=s.match(Ss);if(l)return{message:`“${l[1]}” is not an agent or a team on this machine.`,field:"manager"};const u=s.match(Cs);return u?{message:`“${u[1]}” is not an agent or a team on this machine.`,field:"members"}:Es.test(s)?{message:"That team would nest too deeply, or would contain itself. Check its members.",field:"members"}:Is.test(s)?{message:s,field:"instructions"}:As.test(s)?{message:s,field:"description"}:{message:s,field:null}}function Rs(t,s){const n=new Set(s),a=`${t}-copy`;if(!n.has(a))return a;for(let i=2;i<100;i+=1){const l=`${a}-${i}`;if(!n.has(l))return l}return a}function Ie(t){return t.action_class==="proactive"?"proactive":"reactive"}const $s={proactive:"Proactive"},Ds={proactive:"It may message you on its own: after sending you something it waits a few minutes for a reply, nudges again with growing gaps for a fixed number of tries, then waits for you — and it may also wake on its own schedule.",reactive:"It replies when you write to it. It does not nudge you, and it does not wake on its own schedule."},Ls={proactive:"Turning this off stops the nudging and the scheduled wakes. It still replies when you write to it.",reactive:"Turning this on lets it write first: it will wait a few minutes for your reply, nudge you again up to a fixed number of tries, and it may wake on its own schedule. It still replies when you write to it."},Fs="This one ships with the app and has no copy of its own yet, so switching installs it first — the same agent and the same instructions, now editable — and then sets its class.";function _s(t,s){const n=[];return t.source==="builtin"&&n.push({op:"profiles.install",name:t.name}),n.push({op:"profiles.update",name:t.name,fields:{action_class:s}}),n}async function Os(t,s,n,a=()=>crypto.randomUUID()){if(Ie(t)===s)return null;let i=null;const l=_s(t,s);for(let u=0;u<l.length;u+=1){const h=l[u];try{i=await n(h,a())}catch(g){throw new mt(g,l.slice(0,u))}}return i}class mt extends Error{completed;constructor(s,n){super(s instanceof Error?s.message:String(s)),this.name="ClassSwitchError",this.completed=n}}function Ms(t,s){const n=t instanceof Error&&t.message?t.message:"The backend sent no reason for it. Try the switch again.",a=ye(n).message;return s.some(i=>i.op==="profiles.install")?`${a} The install did land, so the agent is editable now.`:a}const Us=new Set(["agent","team"]);function Ps(t){const s=typeof t.args?.op=="string"?t.args.op:null,n=typeof t.args?.name=="string"?t.args.name:null,a=t.toolName==="team"?"team":"agent",i=n?{kind:a,name:n}:null,l=t.phase==="done"&&!t.isError&&!t.notRunReason&&!t.neverSent,u=h=>({writes:h&&l});switch(s){case"create":return{verb:n?`Creating ${a} ${n}`:`Creating a ${a}`,target:i,...u(!0)};case"update":return{verb:n?`Updating ${a} ${n}`:`Updating a ${a}`,target:i,...u(!0)};case"install":return{verb:n?`Installing ${n}`:"Installing an agent",target:i,...u(!0)};case"list":case"search":case"show":return{verb:n?`Reading ${n}`:`Reading ${a}s`,target:i,...u(!1)};default:return{verb:t.phase==="running"?`Working on ${a}s`:`Checked ${a}s`,target:i,...u(!0)}}}const Bs={description:"description",kind:"kind",tools:"tools",effort:"effort tier",delegate:"delegation",action_class:"class",manager:"manager",members:"members",instructions:"instructions"};function qs(t){return{description:t.description??"",kind:t.kind,tools:t.tools&&t.tools.length>0?[...t.tools].sort().join(","):"*",effort:t.effort??"inherit",delegate:String(!!t.delegate),action_class:Ie(t)}}function zs(t){return{description:t.description??"",manager:t.manager??"",members:(t.members??[]).map(s=>`${s.kind}:${s.role}x${s.count}`).sort().join(",")}}function Ge(t,s){return{agents:Object.fromEntries((t??[]).map(n=>[n.name,qs(n)])),teams:Object.fromEntries((s??[]).map(n=>[n.name,zs(n)]))}}function Ws(t,s){if(t===s)return"tools";const n=h=>h==="*"?null:new Set(h.split(",")),a=n(t),i=n(s);if(i===null)return"tools widened to every tool";if(a===null)return"tools narrowed to a list";const l=[...i].filter(h=>!a.has(h)),u=[...a].filter(h=>!i.has(h));return l.length&&!u.length?l.length===1?`tool added: ${l[0]}`:`${l.length} tools added`:u.length&&!l.length?u.length===1?`tool removed: ${u[0]}`:`${u.length} tools removed`:"tools changed"}function Hs(t,s,n){if(t==="tools")return Ws(s,n);if(t==="delegate")return n==="true"?"delegation turned on":"delegation turned off";if(t==="action_class")return n==="proactive"?"class changed to proactive":"class changed to reactive — proactive messaging stopped";if(t==="members"){const a=i=>i?i.split(",").length:0;return`members changed (${a(s)} to ${a(n)})`}return`${Bs[t]??t} changed`}function Ks(t,s,n){const a=[],i=new Set;for(const l of n){const u=`${l.kind}:${l.name}`;if(i.has(u))continue;i.add(u);const h=t[l.kind==="agent"?"agents":"teams"][l.name],g=s[l.kind==="agent"?"agents":"teams"][l.name];if(!g)continue;if(!h){a.push({target:l,created:!0,changes:[]});continue}const c=[];for(const r of Object.keys(g))g[r]!==h[r]&&c.push({label:Hs(r,h[r],g[r]),before:h[r],after:g[r]});a.push({target:l,created:!1,changes:c})}for(const[l,u]of[["agent",s.agents],["team",s.teams]])for(const h of Object.keys(u))i.has(`${l}:${h}`)||(l==="agent"?t.agents[h]:t.teams[h])||a.push({target:{kind:l,name:h},created:!0,changes:[]});return a}function Gs(t){return ce(t,"agents_config")&&ce(t,"session_interrupt")&&ce(t,"profile_catalogue")&&ce(t,"team_catalogue")}function Vs(t){if(!(t instanceof It)||t.status!==409)return null;const n=t.detail?.session_id;return typeof n=="string"&&n.length>0?n:null}function Js(t,s){const[n,a]=o.useState(()=>Date.now());return o.useEffect(()=>{if(!t||!s)return;const i=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(i)},[t,s]),t?Math.max(0,n-t):0}function Ys(t){const s=Math.floor(t/1e3);return s<60?`${s}s`:`${Math.floor(s/60)}m ${String(s%60).padStart(2,"0")}s`}function Ve(t){for(let s=(t?.length??0)-1;s>=0;s-=1){const n=t?.[s];if(n?.kind==="assistant"&&n.text?.trim())return n.text.trim()}return""}function Qs(t){const n=t?.payload?.frontend;if(!n||typeof n!="object")return null;const a=n.streaming;if(typeof a=="boolean")return a;const i=n.snapshot?.streaming;return typeof i=="boolean"?i:null}function Xs(){const t=et(),s=Gs(t.data),n=wt(),a=z(),[i,l]=o.useState(!1),[u,h]=o.useState(!1),g=o.useRef(!1),c=a.status==="running"||a.status==="stopping",r=Nt(a.sessionId??void 0,!!a.sessionId),y=o.useMemo(()=>Ve(r.transcript?.records),[r.transcript?.records]);Ut(a.sessionId??void 0,r.subscriptionId);const v=r.transcript?.records,j=o.useRef(v);o.useEffect(()=>{j.current=v},[v]);const b=o.useMemo(()=>(r.transcript?.records??[]).filter(E=>E.kind==="tool"&&Us.has(E.toolName)).map(E=>({...Ps({toolName:E.toolName,args:E.args??null,phase:E.phase,ts:E.ts,isError:E.isError,notRunReason:E.notRunReason,neverSent:E.neverSent}),ts:E.ts})),[r.transcript]);o.useEffect(()=>{if(c)for(const x of b)x.target&&x.writes&&a.noteTouched(x.target)},[b,c,a]);const C=c&&b.length>0?b[b.length-1].verb:null,p=Ys(Js(a.startedAt,c)),k=o.useCallback(async(x,E="")=>{if(g.current)return;g.current=!0;const L=a.before;let I=[];try{const[U,_]=await Promise.all([V({op:"profiles.list"}),V({op:"teams.list"})]);L&&(I=Ks(L,Ge(U.profiles,_.teams),a.touched))}catch{z.getState().fail("The run finished, but the agents and teams lists could not be read to describe what changed."),Pe(n);return}if(Pe(n),z.getState().settle(I,x,E),x==="done"&&I.length>0){const U=I.filter(_=>_.created).length;me(U>0?`Configuration run finished: ${I.length} definition${I.length===1?"":"s"} changed.`:`Configuration run finished: ${I.length} definition${I.length===1?"":"s"} updated.`)}},[n,a.before,a.touched]);o.useEffect(()=>{if(c){if(r.failure){z.getState().fail(r.failure.statement);return}g.current||r.frontend&&(r.frontend.streaming||r.turnsCompleted!==0&&k(a.status==="stopping"?"stopped":"done",y))}},[c,y,r.failure,r.frontend,r.turnsCompleted,a.status,k]),o.useEffect(()=>{const x=a.sessionId;if(!c||!x)return;let E=!1;const L=async()=>{if(!(E||g.current))try{const _=await V({op:"sessions.get",sessionId:x});if(E||g.current||Qs(_)!==!1)return;const H=Ve(j.current);if(!H)return;k(z.getState().status==="stopping"?"stopped":"done",H)}catch{}},I=setTimeout(()=>void L(),400),U=setInterval(()=>void L(),4e3);return()=>{E=!0,clearTimeout(I),clearInterval(U)}},[c,a.sessionId,k]);const R=async(x,E,L=[])=>{if(i||!x.trim()&&L.length===0)return!1;l(!0),h(!1),g.current=!1;const I=Ge(n.getQueryData(["desktop","profiles"]),n.getQueryData(["desktop","teams"])),U=E?`About the ${E.kind} “${E.name}”: ${x.trim()}`:x.trim(),{images:_,unreadable:H,overflow:q}=await St(L,U),X=Ct(H);if(X)return z.getState().fail(X),!1;const P=Et(q);if(P)return z.getState().fail(P),!1;try{let W;try{W=(await V({op:"sessions.create",requestId:crypto.randomUUID(),purpose:"agents-config"})).session_id}catch(K){const J=Vs(K);if(J)return h(!0),a.adopt(J,x.trim(),I,_),!1;throw K}return a.adopt(W,U,I,_),await T(W,U,_),!0}catch(W){const K=z.getState().sessionId;return z.getState().failUnsent(Te(W,K?"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{l(!1)}},T=async(x,E,L=[])=>{await V({op:"sessions.message",sessionId:x,requestId:crypto.randomUUID(),text:E,...L.length>0?{images:L}:{}})},$=async()=>{const x=z.getState();if(!(i||!x.unsent||!x.sessionId||!x.topic&&x.images.length===0)){l(!0);try{await T(x.sessionId,x.topic,x.images),a.adopt(x.sessionId,x.topic,x.before),g.current=!1}catch(E){z.getState().failUnsent(Te(E,"The request could not be sent. It is still in the box."))}finally{l(!1)}}},D=async()=>{const x=z.getState().sessionId;if(x){a.stopping();try{await Pt(x,crypto.randomUUID())}catch(E){z.getState().stopFailed(Te(E,"The run did not acknowledge the request."))}}},w=s?null:t.isLoading?"Connecting to the backend…":t.error?"The backend could not be reached, so the composer is unavailable for now.":"Ask for a change needs a newer backend. Update Local Operator to configure agents by conversation.";return{enabled:s,disabledReason:w,status:a.status,sessionId:a.sessionId,frontend:r.frontend,topic:a.topic,error:a.error,stopError:a.stopError,about:a.about,setAbout:a.setAbout,touched:a.touched,results:a.results,answer:a.answer,step:C,elapsed:p,activity:b,start:R,stop:D,retry:$,canRetry:a.unsent&&!!a.sessionId,dismiss:a.dismiss,starting:i,attached:u}}function F({title:t,description:s,actions:n,children:a,className:i}){return e.jsxs("section",{className:Z("space-y-2 border-hairline border-t pt-4 first:border-t-0 first:pt-0",i),children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[e.jsx("h3",{className:"text-heading",children:t}),n]}),s?e.jsx("p",{className:"text-meta text-ink-muted",children:s}):null,a]})}function ue({text:t,empty:s="Nothing here yet.",mono:n=!1}){const[a,i]=o.useState(!1),[l,u]=o.useState(!1),h=o.useRef(null);return o.useEffect(()=>{if(a)return;const g=h.current;g&&u(!!t&&g.scrollHeight>g.clientHeight+1)},[t,a]),t.trim()?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{ref:h,tabIndex:0,"aria-label":"The full text",className:Z("whitespace-pre-wrap rounded-sm border border-hairline bg-surface px-3 py-2 text-body-sm text-ink",!a&&"max-h-64 overflow-y-auto",n&&"font-mono text-meta"),children:t}),l?e.jsx(N,{variant:"link",size:"sm",onClick:()=>i(g=>!g),children:a?"Show less":"Show all"}):null]}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:s})}function ht({source:t,appearance:s="chip"}){const n=t==="builtin"?"Built-in":t==="installed"?"Installed":"Custom";return s==="text"?e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n}):e.jsx(O,{variant:"neutral",children:n})}function ft(t,s){o.useEffect(()=>{if(!s)return;const n=a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),t())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[s,t])}function Oe({dirty:t,pending:s,onSave:n,onCancel:a,saveLabel:i="Save changes",pendingLabel:l="Saving…",dirtyHint:u,submit:h,confirming:g,onConfirmingChange:c}){const[r,y]=o.useState(!1),v=o.useRef(null),j=o.useRef(null),b=g!==void 0,C=b?g:r;o.useEffect(()=>{C&&j.current?.focus()},[C]);const p=k=>{b||y(k),c?.(k)};return o.useEffect(()=>{t||(b||y(!1),c?.(!1))},[t,b,c]),e.jsxs("div",{"data-testid":"edit-footer",className:"sticky bottom-0 z-10 -mx-6 mt-6 flex flex-wrap items-center gap-2 border-hairline border-t bg-canvas px-6 py-3",children:[e.jsx(N,{ref:v,type:h?"submit":void 0,variant:"primary",onClick:h?void 0:n,disabled:s,children:s?l:i}),C?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:u??"Discard your unsaved changes?"}),e.jsx(N,{variant:"danger",onClick:a,children:"Discard changes"}),e.jsx(N,{ref:j,variant:"ghost",onClick:()=>{p(!1),v.current?.focus()},children:"Keep editing"})]}):e.jsx(N,{variant:"ghost",onClick:()=>t?p(!0):a(),disabled:s,children:"Cancel"}),t&&!C?e.jsx("span",{className:"text-meta text-ink-muted",children:"Unsaved changes"}):null]})}let Fe=!1;function gt(){Fe=!0}function pt(){const t=Fe;return Fe=!1,t}function Zs({rows:t=6}){return e.jsx("div",{className:"space-y-1","aria-hidden":"true",children:en.slice(0,t).map(s=>e.jsx(de,{className:"h-11 w-full"},s))})}const en=["a","b","c","d","e","f","g","h"];function Je(){return e.jsxs("div",{className:"max-w-3xl space-y-6","aria-hidden":"true",children:[e.jsx(de,{className:"h-7 w-64"}),e.jsx(de,{className:"h-5 w-40"}),e.jsx(de,{className:"h-28 w-full"}),e.jsx(de,{className:"h-24 w-full"})]})}function Ye({title:t,what:s,meaning:n,onRetry:a,retrying:i=!1}){return e.jsxs("div",{role:"alert",className:"max-w-xl space-y-2",children:[e.jsx("h2",{className:"text-heading",children:t}),e.jsx("p",{className:"text-body-sm text-ink",children:s}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:n}),e.jsx(N,{variant:"secondary",onClick:a,disabled:i,children:i?"Retrying…":"Retry"})]})}function ee({label:t,htmlFor:s,error:n}){return e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("label",{htmlFor:s,className:"text-body-sm text-ink-muted",children:t}),n?e.jsx("span",{className:"text-meta text-danger",role:"alert",children:n}):null]})}const tn=/^[A-Za-z0-9_.:-]{1,128}$/;function te(t){return{description:t.description??"",instructions:t.instructions??"",tools:t.tools&&t.tools.length>0?[...t.tools]:null,effort:t.effort??"inherit",delegate:t.delegate??!1}}function sn(t,s){const n={};return s.description!==t.description&&(n.description=s.description),s.instructions!==t.instructions&&(n.instructions=s.instructions),JSON.stringify(s.tools)!==JSON.stringify(t.tools)&&(n.tools=s.tools??[]),s.effort!==t.effort&&(n.effort=s.effort),s.delegate!==t.delegate&&(n.delegate=s.delegate),n}function nn({profile:t}){return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(ht,{source:t.source}),t.divergent_fields?.length?e.jsx(O,{variant:"warning",children:"Modified"}):null,t.kind==="specialist"?e.jsx(O,{variant:"neutral",children:"Specialist"}):null,t.delegate?e.jsx(O,{variant:"neutral",children:"Delegates"}):null,t.tools&&t.tools.length>0?e.jsx(O,{variant:"neutral",children:t.tools.length===1?"1 tool":`${t.tools.length} tools`}):null]})}const an=5e3;let $e=null;function rn({profile:t,displayedName:s,notice:n,onNotice:a,onChanged:i}){const l=Ie(t),[u,h]=o.useState(null),[g,c]=o.useState(!1),r=o.useRef(null),y=o.useId();o.useEffect(()=>{u!==null&&l===u&&h(null)},[l,u]),o.useEffect(()=>{const b=$e;!b||b.name!==t.name||($e=null,!(Date.now()-b.at>an)&&r.current?.focus())},[t.name]);const v=u??l,j=async b=>{if(!(g||b===v)){$e={name:t.name,at:Date.now()},a(null),h(b),c(!0);try{await Os(t,b,(C,p)=>C.op==="profiles.install"?V({op:"profiles.install",name:C.name,requestId:p}):V({op:"profiles.update",name:C.name,requestId:p,fields:C.fields??{}})),i(t.name),me(b==="proactive"?`${s} is now proactive — it may message you on its own.`:`${s} is now reactive — proactive messaging stopped.`)}catch(C){h(null);const p=C instanceof mt?C.completed:[],k=Ms(C,p);a(k),ke(k),i(t.name)}finally{c(!1)}}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{ref:r,checked:v==="proactive","aria-disabled":g,"aria-labelledby":y,"data-testid":"agent-class-switch",className:"after:absolute after:inset-0 after:content-['']",onCheckedChange:b=>void j(b?"proactive":"reactive")}),e.jsx("span",{id:y,className:"text-ink",children:"Can message me on its own"}),e.jsx("span",{"aria-live":"polite",className:"text-ink-muted",children:g?"Switching…":v==="proactive"?"On":"Off"})]}),e.jsx("p",{className:"text-body-sm text-ink",children:Ds[v]}),e.jsx("p",{className:"text-meta text-ink-muted",children:Ls[v]}),t.source==="builtin"?e.jsx("p",{className:"text-meta text-ink-muted",children:Fs}):null,n?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"agent-class-error",children:[e.jsx(ne,{children:"The switch did not go through"}),e.jsx(ae,{children:n})]}):null]})}function xt({tools:t,onChange:s,error:n}){const[a,i]=o.useState(""),[l,u]=o.useState(null),h=o.useId(),g=()=>{const c=a.trim();if(c){if(!tn.test(c)){u("Tool names are letters, digits, dot, underscore, dash or colon.");return}if(t?.includes(c)){u("That tool is already listed.");return}u(null),i(""),s([...t??[],c])}};return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{checked:t===null,onCheckedChange:c=>s(c?null:[]),"aria-label":"Give this agent every tool"}),e.jsx("span",{children:"All tools"})]}),t===null?e.jsx("p",{className:"text-meta text-ink-muted",children:"This agent may use whatever the session offers."}):e.jsxs(e.Fragment,{children:[t.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1.5",children:t.map(c=>e.jsx("li",{children:e.jsxs(O,{variant:"outline",children:[c,e.jsx(N,{variant:"ghost",size:"sm","aria-label":`Remove ${c}`,onClick:()=>s(t.filter(r=>r!==c)),className:"ml-1 h-4 px-1",children:"×"})]})},c))}):e.jsx("p",{className:"text-meta text-ink-muted",children:"No tools yet. Add one below, or turn on All tools."}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(ee,{label:"Add a tool",htmlFor:h,error:l??n}),e.jsx(he,{id:h,value:a,inputSize:"md",placeholder:"Tool name","aria-invalid":!!(l??n),onChange:c=>{i(c.target.value),u(null)},onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),g())}})]}),e.jsx(N,{variant:"secondary",onClick:g,disabled:!a.trim(),children:"Add"})]})]})]})}function on({profile:t,displayedName:s,classNotice:n,onClassNotice:a,teams:i,effortTiers:l,askEnabled:u,onSaved:h,onDuplicate:g,onOpenTeam:c,onAskAgent:r,onDirtyChange:y}){const[v,j]=o.useState(!1),[b,C]=o.useState(()=>te(t)),[p,k]=o.useState(()=>te(t)),[R,T]=o.useState(!1),[$,D]=o.useState(null),[w,x]=o.useState(null),[E,L]=o.useState(!1),[I,U]=o.useState(!1),[_,H]=o.useState(!1),q=o.useRef(null),X=tt(),P=JSON.stringify(p)!==JSON.stringify(b);o.useEffect(()=>(y?.(v&&P),()=>y?.(!1)),[y,v,P]),o.useEffect(()=>{pt()&&requestAnimationFrame(()=>q.current?.focus())},[]),o.useEffect(()=>{if(v&&P)return;const f=te(t);C(f),k(f)},[t,v,P]),o.useEffect(()=>{if(!v){U(!1);return}const f=te(t);U(P&&JSON.stringify(f)!==JSON.stringify(b))},[t,v,P,b]);const W=()=>{j(!1),D(null),x(null),L(!1),H(!1);const f=te(t);C(f),k(f)};ft(()=>{if(_){H(!1);return}P?H(!0):W()},v);const J=async f=>{if(f?.preventDefault(),R)return;const A=sn(b,p);if(Object.keys(A).length===0){W();return}if(typeof A.instructions=="string"&&!A.instructions.trim()){D("Give the agent instructions."),x("instructions");return}T(!0),D(null),x(null);try{const G=await V({op:"profiles.update",name:t.name,requestId:crypto.randomUUID(),fields:A});j(!1),L(!1);const Y=te(G);C(Y),k(Y),h(G.name),me(`Saved ${G.name}.`),requestAnimationFrame(()=>q.current?.focus())}catch(G){const Y=ye(G instanceof Error?G.message:"The agent could not be saved.");D(Y.message),x(Y.field);const re=G?.status,fe=typeof re=="number"&&re!==408&&re>=400&&re<500;L(!fe),fe||ke("The save could not be confirmed. Check whether it was applied before retrying.")}finally{T(!1)}},d=async()=>{if(!R){T(!0),D(null);try{const f=await V({op:"profiles.install",name:t.name,requestId:crypto.randomUUID()}),A=te(f);C(A),k(A),h(f.name),me(`Installed ${f.name}. It can be edited now.`),requestAnimationFrame(()=>q.current?.focus())}catch(f){const A=ye(f instanceof Error?f.message:"The agent could not be installed.");D(A.message),ke(A.message)}finally{T(!1)}}},S=(i??[]).filter(f=>f.manager===t.name||(f.members??[]).some(A=>A.role===t.name)),B=t.source==="builtin";return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("h2",{ref:q,tabIndex:-1,className:"text-title focus:outline-none",children:s}),e.jsx(nn,{profile:t})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"primary",onClick:()=>{st.getState().stageDraft({kind:"agent",name:t.name}),X("/chat")},children:"New chat"}),B?e.jsxs(N,{variant:"secondary",onClick:d,disabled:R,children:[e.jsx(os,{className:"size-4"}),R?"Installing…":"Install to edit"]}):e.jsx(N,{variant:"secondary",onClick:()=>{j(!0),D(null),x(null)},children:"Edit"}),e.jsx(N,{variant:"ghost",onClick:()=>g(t),children:"Duplicate as new agent"}),u?e.jsx(N,{variant:"ghost",onClick:()=>r(`Change the agent ${t.name}: `),children:"Ask for a change"}):null]})]}),B?e.jsxs(se,{variant:"info",children:[e.jsx(ne,{children:"Built-in agent"}),e.jsx(ae,{children:"This one ships with the app and cannot be edited in place. Install it to get an editable copy, or duplicate it as a new agent."})]}):null,I?e.jsxs(se,{variant:"warning","data-testid":"agent-conflict",children:[e.jsx(ne,{children:"This changed while you were editing"}),e.jsxs(ae,{children:[e.jsx("span",{className:"block",children:"Something else — a configuration run, or another window — wrote to this agent after you opened it. Your edits are kept; saving writes only the fields you changed."}),e.jsx(N,{variant:"secondary",size:"sm",className:"mt-2",onClick:W,children:"Reload the saved version"})]})]}):null,E?e.jsxs(se,{variant:"danger","data-testid":"agent-unconfirmed",children:[e.jsx(ne,{children:"The last save was not confirmed"}),e.jsx(ae,{children:"The backend did not answer, so the write may or may not have landed. Check the agent below, then edit again."})]}):null,$&&!w?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"agent-save-error",children:[e.jsx(ne,{children:"That did not save"}),e.jsx(ae,{children:$})]}):null]}),e.jsx("form",{noValidate:!0,onSubmit:f=>{f.preventDefault(),J(f)},className:"space-y-6",children:v?e.jsxs(e.Fragment,{children:[e.jsx(Se,{title:"When to use it",description:"One sentence the model reads to decide when this agent is the right one.",label:"When to use this agent",value:p.description,error:w==="description"?$:null,onChange:f=>k(A=>({...A,description:f}))}),e.jsx(Se,{title:"Instructions",description:"What the agent is told to do. This is the agent's whole behaviour.",label:"Instructions",value:p.instructions,rows:12,required:!0,error:w==="instructions"?$:null,onChange:f=>k(A=>({...A,instructions:f}))}),e.jsx(F,{title:"Tools",children:e.jsx(xt,{tools:p.tools,error:w==="tools"?$:null,onChange:f=>k(A=>({...A,tools:f}))})}),e.jsx(F,{title:"Delegation and effort",description:"Whether this agent may hand work to subagents, and which effort tier it runs at.",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{checked:p.delegate,onCheckedChange:f=>k(A=>({...A,delegate:f})),"aria-label":"May delegate to subagents"}),e.jsx("span",{children:"May delegate to subagents"})]}),e.jsxs("div",{className:"max-w-sm space-y-1",children:[e.jsx(ee,{label:"Effort tier",htmlFor:"agent-effort",error:w==="effort"?$:null}),e.jsx(Ne,{ariaLabel:"Effort tier",showLabel:!1,placeholder:"Choose an effort tier",busyLabel:"Loading effort tiers",options:["inherit",...l].map(f=>({id:f,name:f,description:f==="inherit"?"Use the session's own effort":void 0})),selected:{id:p.effort,name:p.effort},onSelect:f=>k(A=>({...A,effort:f.id})),helperText:"Tiers come from the backend's subagent model settings."})]})]})}),e.jsx(Oe,{submit:!0,confirming:_,onConfirmingChange:H,dirty:P,pending:R,onSave:()=>void J(),onCancel:W,saveLabel:"Save changes",dirtyHint:"Discard your unsaved changes to this agent?"})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{title:"When to use it",children:e.jsx(ue,{text:t.description||"",empty:"No description yet — add one so a model knows when to pick this agent."})}),e.jsx(F,{title:"Instructions",children:e.jsx(ue,{text:t.instructions??t.packaged_instructions??"",empty:"No instructions yet."})}),e.jsx(F,{title:"Tools",children:t.tools&&t.tools.length>0?e.jsx("ul",{className:"flex flex-wrap gap-1.5",children:t.tools.map(f=>e.jsx("li",{children:e.jsx(O,{variant:"outline",children:f})},f))}):e.jsx(O,{variant:"neutral",children:"All tools"})}),e.jsxs(F,{title:"Delegation and effort",children:[e.jsx("p",{className:"text-body-sm text-ink",children:t.delegate?"May hand work to subagents.":"Does its own work; it does not delegate."}),e.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Effort tier: ",t.effort??"inherit"]})]}),e.jsx(F,{title:"Messaging",description:"Reactive agents only reply. Proactive agents may also message you first.",children:e.jsx(rn,{profile:t,displayedName:s,notice:n,onNotice:a,onChanged:h})}),e.jsx(F,{title:"Used by",description:"Teams that name this agent as a manager or a member.",children:S.length>0?e.jsx("ul",{className:"flex flex-wrap gap-x-3 gap-y-1",children:S.map(f=>e.jsx("li",{children:e.jsx(N,{variant:"link",onClick:()=>c(f.name),children:f.name})},f.id))}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No team uses it yet."})}),e.jsxs(F,{title:"Where it came from",description:t.source==="builtin"?"Shipped with the app.":t.source==="installed"?"Installed from a packaged starter.":"Created on this machine.",children:[e.jsxs("dl",{className:"space-y-1 text-body-sm",children:[t.seed_origin?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"text-ink-muted",children:"Source"}),e.jsx("dd",{className:"text-ink",children:t.seed_origin})]}):null,t.divergent_fields?.length?e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"text-ink-muted",children:"Changed from the packaged copy"}),e.jsx("dd",{className:"text-ink",children:t.divergent_fields.join(", ")})]}):null]}),t.packaged_instructions&&t.divergent_fields?.length?e.jsx(nt,{summary:"Compare with the packaged instructions",className:"mt-2",children:e.jsx(ue,{text:t.packaged_instructions,mono:!0})}):null]})]})})]})}function Se({title:t,description:s,label:n,value:a,onChange:i,rows:l,required:u,error:h,fieldRef:g}){const c=o.useId();return e.jsxs(F,{title:t,description:s,children:[e.jsx(ee,{label:n,htmlFor:c,error:h}),l?e.jsx(Le,{id:c,ref:g,value:a,rows:l,required:u,"aria-invalid":!!h,className:Z("min-h-0"),onChange:r=>i(r.target.value)}):e.jsx(he,{id:c,value:a,"aria-invalid":!!h,onChange:r=>i(r.target.value)})]})}function ln({initial:t,takenNames:s,effortTiers:n,onDirtyChange:a,onSaved:i,onCancel:l}){const[u,h]=o.useState(()=>t?Rs(t.name,s):""),[g,c]=o.useState(t?.kind??"role"),[r,y]=o.useState(()=>t?{...te(t),description:t.description??""}:{description:"",instructions:"",tools:null,effort:"inherit",delegate:!1}),[v,j]=o.useState(!1),[b,C]=o.useState(null),[p,k]=o.useState(null),R=o.useRef(null),T=o.useRef(null);o.useEffect(()=>(a?.(!!(u.trim()||r.instructions.trim())),()=>a?.(!1)),[a,u,r.instructions]),o.useEffect(()=>{R.current?.focus(),R.current?.select()},[]);const $=async w=>{if(w?.preventDefault(),!v){if(!u.trim()){C("Give the agent a name."),k("name"),R.current?.focus();return}if(/[\\/\s]/.test(u.trim())){C("Names cannot contain spaces or slashes."),k("name"),R.current?.focus();return}if(s.includes(u.trim())){C(`An agent called “${u.trim()}” already exists. Choose another name, or open the existing one to change it.`),k("name"),R.current?.focus();return}if(!r.instructions.trim()){C("Give the agent instructions."),k("instructions"),T.current?.focus();return}j(!0),C(null),k(null);try{const x=await V({op:"profiles.create",requestId:crypto.randomUUID(),name:u.trim(),fields:{kind:g,description:r.description,instructions:r.instructions,tools:r.tools??[],effort:r.effort,delegate:r.delegate}});me(`Created ${x.name}.`),gt(),i(x.name)}catch(x){const E=ye(x instanceof Error?x.message:"The agent could not be created.");C(E.message),k(E.field)}finally{j(!1)}}},D=t?"Duplicate as a new agent":"New agent";return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{className:"space-y-2",children:[e.jsx("h2",{className:"text-title",children:D}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:t?`A copy of ${t.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."})]}),b&&!p?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"agent-create-error",children:[e.jsx(ne,{children:"That did not save"}),e.jsx(ae,{children:b})]}):null,e.jsxs("form",{noValidate:!0,onSubmit:w=>{w.preventDefault(),$(w)},className:"space-y-6",children:[e.jsx(F,{title:"Name and role",children:e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(ee,{label:"Name",htmlFor:"agent-create-name",error:p==="name"?b:null}),e.jsx(he,{id:"agent-create-name",ref:R,value:u,required:!0,"aria-invalid":p==="name",onChange:w=>h(w.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ee,{label:"How it works with others",htmlFor:"agent-create-kind"}),e.jsxs(ot,{value:g,onValueChange:w=>c(w),children:[e.jsx(lt,{id:"agent-create-kind",children:e.jsx(ct,{})}),e.jsxs(dt,{children:[e.jsx(we,{value:"role",children:"You can chat with it directly"}),e.jsx(we,{value:"specialist",children:"Other agents can call on it"})]})]})]})]})}),e.jsx(Se,{title:"When to use it",description:"One sentence the model reads to decide when this agent is the right one.",label:"When to use this agent",value:r.description,error:p==="description"?b:null,onChange:w=>y(x=>({...x,description:w}))}),e.jsx(Se,{title:"Instructions",description:"What the agent is told to do. This is the agent's whole behaviour.",label:"Instructions",value:r.instructions,rows:12,required:!0,fieldRef:T,error:p==="instructions"?b:null,onChange:w=>y(x=>({...x,instructions:w}))}),e.jsx(F,{title:"Delegation and effort",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[e.jsx(Ee,{checked:r.delegate,onCheckedChange:w=>y(x=>({...x,delegate:w})),"aria-label":"May delegate to subagents"}),e.jsx("span",{children:"May delegate to subagents"})]}),e.jsxs("div",{className:"max-w-sm space-y-1",children:[e.jsx(ee,{label:"Effort tier",htmlFor:"agent-create-effort"}),e.jsx(Ne,{ariaLabel:"Effort tier",showLabel:!1,busyLabel:"Loading effort tiers",placeholder:"Choose an effort tier",options:["inherit",...n].map(w=>({id:w,name:w,description:w==="inherit"?"Use the session's own effort":"A tier configured in Settings"})),selected:{id:r.effort,name:r.effort},onSelect:w=>y(x=>({...x,effort:w.id}))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-body-sm text-ink-muted",children:"Tools"}),e.jsx(xt,{tools:r.tools,error:p==="tools"?b:null,onChange:w=>y(x=>({...x,tools:w}))})]})]})}),e.jsx(Oe,{submit:!0,dirty:!!(u.trim()||r.instructions),pending:v,saveLabel:t?"Create the copy":"Create agent",pendingLabel:"Creating…",dirtyHint:"Discard this new agent?",onSave:()=>void $(),onCancel:l})]})]})}const Ce=t=>t==null?"":typeof t=="string"?t:JSON.stringify(t,null,2),cn={available:"border-hairline",updating:"border-hairline",applied:"border-hairline",review:"border-warning-border",failed:"border-danger-border"};function dn(t){const s=[];for(const n of t??[])for(const a of n.fields??[])for(const i of a.regions??[])(i.provenance==="unresolved"||Ce(i.local)!==Ce(i.remote))&&s.push({field:a.field,region:i});return s}function un({regions:t}){return t.length?e.jsx("ul",{className:"space-y-3","data-testid":"hub-update-preview",children:t.map(({field:s,region:n},a)=>e.jsxs("li",{className:"space-y-1 text-meta",children:[e.jsx("p",{className:"font-medium text-ink",children:n.heading||n.name||s}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-ink-muted",children:"Yours"}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:Ce(n.local)||"(nothing)"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-ink-muted",children:"The hub's"}),e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:Ce(n.remote)||"(nothing)"})]})]})]},`${s}:${n.id??a}`))}):e.jsx("p",{className:"text-meta text-ink-muted",children:"No differences to show: the hub's version matches yours."})}function mn({kind:t,name:s,enabled:n}){const a=Bt(n),i=qt(),[l,u]=o.useState(null),h=Wt(t,s),g=zt(a.data).get(h),c=Ht(g),r=i.notes[h],y=i.pending.has(h);if(!g||!c)return r?e.jsx("section",{"data-testid":"hub-update-panel","aria-label":"Hub update",className:"mb-6 max-w-3xl rounded-md border border-hairline p-3 text-body-sm",children:e.jsx("p",{role:r.tone==="error"?"alert":"status",className:r.tone==="error"?"text-danger":"text-ink",children:r.message})}):null;const v=c.kind==="review",j=g.classification==="baseline-unknown",b=p=>({prefer:p,acknowledgeUnknownBaseline:j}),C=async()=>{const p=await i.applyItem(t,s,{...b(),dryRun:!0});u(p??[])};return e.jsxs("section",{"data-testid":"hub-update-panel","aria-label":"Hub update",className:Z("mb-6 max-w-3xl space-y-2 rounded-md border p-3 text-body-sm",cn[c.kind]),children:[e.jsxs("p",{className:"flex items-start gap-2 text-ink",children:[e.jsx(Kt,{mark:c,className:"mt-0.5"}),e.jsx("span",{className:Z(c.kind==="failed"&&"text-danger"),children:Gt(g,c)})]}),v&&j&&e.jsx("p",{className:"text-meta text-ink-muted",children:"Nothing records what you changed on this device. Either choice adds the hub's additions and deletes nothing of yours; where the two versions differ, your choice decides which wording stays."}),v&&!j&&e.jsx("p",{className:"text-meta text-ink-muted",children:"Where the two versions differ, your choice decides which wording stays. Everything else is merged, and your current version is saved as a backup first."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.kind==="available"&&e.jsx(N,{size:"sm",variant:"outline","aria-disabled":y||void 0,onClick:()=>!y&&void i.applyItem(t,s),children:y?"Updating…":"Update from the hub"}),c.kind==="failed"&&c.retryable&&e.jsx(N,{size:"sm",variant:"outline","aria-disabled":y||void 0,onClick:()=>!y&&void i.retryItem(t,s),children:y?"Retrying…":"Retry"}),v&&e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"sm",variant:"outline","aria-disabled":y||void 0,onClick:()=>!y&&void C(),children:y&&!l?"Loading…":"Preview the differences"}),e.jsx(N,{size:"sm",variant:"ghost","aria-disabled":y||void 0,onClick:()=>!y&&void i.applyItem(t,s,b("local")),children:"Keep mine where they differ"}),e.jsx(N,{size:"sm",variant:"ghost","aria-disabled":y||void 0,onClick:()=>!y&&void i.applyItem(t,s,b("remote")),children:"Use the hub's where they differ"})]})]}),l&&v&&e.jsx(un,{regions:dn(l)}),r&&e.jsx("p",{role:r.tone==="error"?"alert":"status",className:r.tone==="error"?"text-meta text-danger":"text-meta text-ink-muted",children:r.message})]})}function be(t){return{description:t?.description??"",manager:t?.manager??"manager",members:(t?.members??[]).map(s=>({...s,key:crypto.randomUUID()})),instructions:t?.instructions??"",project:t?.project??""}}function hn(t,s){const n={};return s.description!==t.description&&(n.description=s.description),s.manager!==t.manager&&(n.manager=s.manager),JSON.stringify(s.members.map(({key:a,...i})=>i))!==JSON.stringify(t.members.map(({key:a,...i})=>i))&&(n.members=s.members.map(({key:a,...i})=>i)),s.instructions!==t.instructions&&(n.instructions=s.instructions),s.project!==t.project&&(n.project=s.project),n}function Qe(t,s,n){return(t.kind==="agent"?(s??[]).map(i=>i.name):(n??[]).map(i=>i.name)).includes(t.role)}function Xe({team:t,agents:s,teams:n,askEnabled:a,onSaved:i,onCancelCreate:l,onOpenAgent:u,onAskAgent:h,onDirtyChange:g}){const c=!t,[r,y]=o.useState(c),[v,j]=o.useState(t?.name??""),[b,C]=o.useState(()=>be(t)),[p,k]=o.useState(()=>be(t)),[R,T]=o.useState(!1),[$,D]=o.useState(null),[w,x]=o.useState(null),[E,L]=o.useState(!1),I=o.useRef(null),U=o.useRef(null),_=o.useRef(null);o.useEffect(()=>{pt()&&requestAnimationFrame(()=>I.current?.focus())},[]);const H=tt(),q=c?!!(v.trim()||p.description||p.members.length):JSON.stringify(p)!==JSON.stringify(b);o.useEffect(()=>(g?.((c||r)&&q),()=>g?.(!1)),[g,c,r,q]),o.useEffect(()=>{if(r&&q)return;const d=be(t);C(d),k(d)},[t,r,q]);const X=()=>{if(c){l?.();return}y(!1),D(null),x(null),L(!1);const d=be(t);C(d),k(d)};ft(()=>{if(E){L(!1);return}q?L(!0):X()},r);const W=async d=>{if(d?.preventDefault(),!R){if(c&&!v.trim()){D("Give the team a name."),x("name"),_.current?.focus();return}if(c&&/[\\/\s]/.test(v.trim())){D("Names cannot contain spaces or slashes."),x("name"),_.current?.focus();return}if(c&&(n??[]).some(S=>S.name===v.trim())){D(`A team called “${v.trim()}” already exists. Open it to change it, or choose another name.`),x("name"),_.current?.focus();return}if(c&&!p.instructions.trim()){D("Give the team instructions."),x("instructions"),U.current?.focus();return}T(!0),D(null),x(null);try{const S=t?await V({op:"teams.update",name:t.name,requestId:crypto.randomUUID(),fields:hn(b,p)}):await V({op:"teams.create",requestId:crypto.randomUUID(),fields:{name:v,description:p.description,manager:p.manager,members:p.members.map(({key:f,...A})=>A),instructions:p.instructions,project:p.project}}),B=be(S);C(B),k(B),y(!1),i(S.name),me(`${c?"Created":"Saved"} ${S.name}.`),c&>(),requestAnimationFrame(()=>I.current?.focus())}catch(S){const B=ye(S instanceof Error?S.message:"The team could not be saved.");D(B.message),x(B.field),ke(B.message)}finally{T(!1)}}},K=(d,S)=>k(B=>({...B,members:B.members.map((f,A)=>A===d?{...f,...S}:f)})),J=(p.members.length?p.members:t?.members??[]).reduce((d,S)=>d+(S.count||1),0);return e.jsxs("div",{className:"max-w-3xl space-y-6",children:[e.jsxs("header",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("h2",{ref:I,tabIndex:-1,className:"text-title focus:outline-none",children:t?at(t):"New team"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx(O,{variant:"neutral",children:J===1?"1 agent":`${J} agents`}),p.members.some(d=>d.kind==="team")?e.jsx(O,{variant:"neutral",children:"Includes a team"}):null]})]}),t?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"primary",onClick:()=>{st.getState().stageDraft({kind:"team",name:t.name}),H("/chat")},children:"New team chat"}),r?null:e.jsx(N,{variant:"secondary",onClick:()=>y(!0),children:"Edit"}),a?e.jsx(N,{variant:"ghost",onClick:()=>h(`Change the team ${t.name}: `),children:"Ask for a change"}):null]}):null]}),$&&!w?e.jsxs(se,{variant:"danger",role:"alert","data-testid":"team-save-error",children:[e.jsx(ne,{children:"That did not save"}),e.jsx(ae,{children:$})]}):null]}),e.jsx("form",{noValidate:!0,onSubmit:d=>{d.preventDefault(),W(d)},className:"space-y-6",children:c||r?e.jsxs(e.Fragment,{children:[c?e.jsxs(F,{title:"Name",description:"How you and your chats will refer to this team.",children:[e.jsx(ee,{label:"Team name",htmlFor:"team-name",error:w==="name"?$:null}),e.jsx(he,{ref:_,id:"team-name","data-testid":"team-name-input",value:v,required:!0,maxLength:64,autoFocus:!0,"aria-invalid":w==="name",onChange:d=>j(d.target.value)})]}):null,e.jsx(F,{title:"Manager",description:"The agent that leads the chat and decides who works on what.",children:e.jsxs("div",{className:"max-w-md space-y-2",children:[e.jsx(ee,{label:"Manager agent",htmlFor:"team-manager",error:w==="manager"?$:null}),e.jsx(Ne,{ariaLabel:"Manager agent",showLabel:!1,placeholder:"Choose a manager",busyLabel:"Loading agents",options:le(s,n),selected:le(s,n).find(d=>d.id===p.manager)??null,onSelect:d=>k(S=>({...S,manager:d.id})),onCustomSubmit:d=>k(S=>({...S,manager:d})),listNotice:"Agents and teams on this machine"}),le(s,n).some(d=>d.id===p.manager)?null:e.jsxs(O,{variant:"warning","data-testid":"team-manager-missing",children:["Not found: ",p.manager]})]})}),e.jsx(F,{title:"Members",description:"Who the manager can delegate to, and how many of each.",children:e.jsxs("div",{className:"space-y-2",children:[p.members.map((d,S)=>{const B=!Qe(d,s,n);return e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"w-56",children:e.jsx(Ne,{ariaLabel:`Member ${S+1}`,showLabel:!1,placeholder:"Choose an agent or team",busyLabel:"Loading agents",options:[...le(s,n).filter(f=>d.kind==="team"?f.group==="Teams":f.group==="Agents")],selected:le(s,n).find(f=>f.id===d.role)??null,onSelect:f=>K(S,{role:f.id,kind:f.group==="Teams"?"team":"agent"}),onCustomSubmit:f=>K(S,{role:f})})}),e.jsxs(ot,{value:d.kind,onValueChange:f=>K(S,{kind:f}),children:[e.jsx(lt,{"aria-label":`Member ${S+1} kind`,className:"w-32",children:e.jsx(ct,{})}),e.jsxs(dt,{children:[e.jsx(we,{value:"agent",children:"Agent"}),e.jsx(we,{value:"team",children:"Team"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(N,{variant:"secondary",size:"icon-sm","aria-label":`One fewer ${d.role}`,disabled:d.count<=1,onClick:()=>K(S,{count:d.count-1}),children:e.jsx(ts,{"aria-hidden":"true"})}),e.jsx("span",{className:"min-w-6 text-center text-body-sm tabular-nums","aria-label":`${d.count} of ${d.role}`,children:d.count}),e.jsx(N,{variant:"secondary",size:"icon-sm","aria-label":`One more ${d.role}`,disabled:d.count>=16,onClick:()=>K(S,{count:d.count+1}),children:e.jsx(it,{"aria-hidden":"true"})})]}),e.jsx(N,{variant:"ghost",onClick:()=>k(f=>({...f,members:f.members.filter((A,G)=>G!==S)})),children:"Remove"}),B?e.jsxs(O,{variant:"warning",children:["Not found: ",d.role]}):null]},d.key)}),e.jsx(N,{variant:"secondary",onClick:()=>k(d=>({...d,members:[...d.members,{role:"",count:1,kind:"agent",key:crypto.randomUUID()}]})),children:"Add member"})]})}),e.jsxs(F,{title:"Description",children:[e.jsx(ee,{label:"What this team is for",htmlFor:"team-description",error:w==="description"?$:null}),e.jsx(he,{id:"team-description",value:p.description,onChange:d=>k(S=>({...S,description:d.target.value}))})]}),e.jsxs(F,{title:"Collaboration instructions",children:[w==="instructions"?e.jsx("p",{className:"text-meta text-danger",role:"alert","data-testid":"team-instructions-error",children:$}):null,e.jsx(Le,{ref:U,"aria-label":"Collaboration instructions","aria-invalid":w==="instructions",className:"min-h-36",maxLength:8e3,value:p.instructions,onChange:d=>k(S=>({...S,instructions:d.target.value}))})]}),e.jsx(F,{title:"Project brief",children:e.jsx(Le,{"aria-label":"Project brief",className:"min-h-36",maxLength:8e3,value:p.project,onChange:d=>k(S=>({...S,project:d.target.value}))})}),e.jsx(Oe,{submit:!0,confirming:E,onConfirmingChange:L,dirty:q,pending:R,saveLabel:c?"Create team":"Save changes",pendingLabel:c?"Creating…":"Saving…",dirtyHint:"Discard this team?",onSave:()=>void W(),onCancel:X})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{title:"Manager",description:"The agent that leads the chat.",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(N,{variant:"link",onClick:()=>u(p.manager),children:p.manager}),le(s,n).some(d=>d.id===p.manager)?null:e.jsx(O,{variant:"warning","data-testid":"team-manager-missing",children:"Not found"})]})}),e.jsx(F,{title:"Members",children:e.jsx("ul",{className:"space-y-1",children:(t?.members??[]).map(d=>e.jsxs("li",{className:"flex flex-wrap items-center gap-2 text-body-sm",children:[e.jsx("span",{className:"text-ink",children:d.role}),e.jsx(O,{variant:"neutral",children:d.kind==="team"?"Team":"Agent"}),e.jsx("span",{className:"text-ink-muted",children:d.count===1?"×1":`×${d.count}`}),Qe(d,s,n)?null:e.jsx(O,{variant:"warning","data-testid":"team-member-missing",children:"Not found"})]},`${d.kind}:${d.role}`))})}),e.jsx(F,{title:"What it is for",children:e.jsx(ue,{text:t?.description??"",empty:"No description yet."})}),t?.instructions?e.jsx(F,{title:"Collaboration instructions",children:e.jsx(ue,{text:t.instructions})}):null,t?.project?e.jsx(nt,{summary:"Project brief",children:e.jsx(ue,{text:t.project})}):null]})})]})}function le(t,s){return[...(t??[]).map(n=>({id:n.name,name:n.name,description:n.description,group:"Agents"})),...(s??[]).map(n=>({id:n.name,name:n.name,description:n.description,group:"Teams"}))]}const fn=o.lazy(()=>Mt(()=>import("./legacy-agents-page-DCOC8Tle.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url).then(t=>({default:t.LegacyAgentsPage}))),Ze=/^subagents\.models\.([^.]+)$/,gn=["lo","med","hi"],De={all:"All",custom:"Custom",installed:"Installed",builtin:"Built-in"},ve=t=>{const s=JSON.stringify(t)??"";let n=5381;for(let a=0;a<s.length;a+=1)n=(n*33^s.charCodeAt(a))>>>0;return`${s.length}.${n.toString(36)}`};function Cn(){const t=At("surface"),{agentId:s}=Tt(),[n,a]=Rt(),i=n.get("kind")==="team"||n.get("create")==="team",l=n.has("create"),u=n.get("name"),h=n.get("duplicate"),g=et(),c=ce(g.data,i?"team_catalogue":"profile_catalogue"),r=$t(c),y=Dt(c),v=c&&!!u&&!l,j=Be(i?null:u,v),b=Lt(i?u:null,v),C=Be(i?null:h,!!h),[p,k]=o.useState(""),[R,T]=o.useState("all"),[$,D]=o.useState(null),[w,x]=o.useState(null),[E,L]=o.useState(0),I=Xs(),U=z(m=>m.marks),_=z(m=>m.clearMark),H=Ft({queryKey:["desktop","settings","effort-tiers"],enabled:c,queryFn:()=>V({op:"settings.list"}),staleTime:6e4}),q=o.useMemo(()=>(H.data?.settings??[]).filter(m=>{const M=m.key.match(Ze)?.[1];return!M||!gn.includes(M)?!1:typeof m.value=="string"&&m.value.trim().length>0}).map(m=>m.key.match(Ze)?.[1]).filter(m=>!!m),[H.data]),X=Vt(),P=o.useCallback(m=>Jt(m,X),[X]),W=o.useMemo(()=>bn(r.data,p,R,P),[r.data,p,R,P]),K=o.useMemo(()=>jn(y.data,p),[y.data,p]),J=i?K:W,d=u??null,[S,B]=o.useState(null);S!==null&&S.name!==d&&B(null);const f=o.useCallback(m=>{const M=new URLSearchParams;(m.kind??(i?"team":"agent"))==="team"&&M.set("kind","team"),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),D(null),a(M)},[i,a]),A=`${i?"team":"agent"}:${l??""}:${d??""}`,G=o.useCallback(m=>x(m?A:null),[A]),Y=w!==null&&w===A,[re,fe]=o.useState(!1),ge=`${i?"team":"agent"}:${d??""}`,ie=i?b.data?ve(b.data):null:j.data?ve(j.data):null,oe=o.useRef({identity:ge,content:ie});o.useEffect(()=>{if(oe.current.identity!==ge){oe.current={identity:ge,content:ie},fe(!1);return}if(ie===null||oe.current.content===null){oe.current={identity:ge,content:ie};return}oe.current.content!==ie&&(oe.current.content=ie,Y&&fe(!0))},[ge,ie,Y]);const Me=(m,M)=>e.jsxs(e.Fragment,{children:[e.jsx(mn,{kind:m,name:M,enabled:ce(g.data,"hub_updates")}),re&&e.jsx("output",{className:"mb-6 block max-w-3xl rounded-md border border-warning-border px-3 py-2 text-meta text-ink-muted",children:"The hub updated this definition while you were editing, and the form below now shows the merged version. Edits you had not saved were replaced."})]}),Q=o.useCallback(m=>{if(Y){D(m);return}f(m)},[Y,f]);o.useEffect(()=>{const m=M=>{M.key!=="Escape"||M.defaultPrevented||window.matchMedia("(max-width: 999px)").matches&&(!d&&!l||(M.preventDefault(),Q({name:null})))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[Q,d,l]),o.useEffect(()=>{const M=z.getState().about;if(!M)return;const Ue=i?"team":"agent";d&&M.kind===Ue&&M.name===d||(I.setAbout(null),gs(M))},[d,i,I]),o.useEffect(()=>{d&&_({kind:i?"team":"agent",name:d})},[d,i,_]);const pe=()=>{r.refetch(),y.refetch(),j.refetch(),b.refetch()};if(s)return e.jsx(o.Suspense,{fallback:e.jsx("p",{className:"p-6 text-body",children:"Loading saved agent…"}),children:e.jsx(fn,{})});const Ae=i?b.error:j.error,xe=i?y.error:r.error,bt=c&&!xe&&!l&&!d,jt=i?b.isLoading:j.isLoading;return e.jsxs("div",{className:"flex h-full min-h-0 bg-canvas text-ink",children:[e.jsxs("aside",{ref:t,"data-open":d?"true":void 0,className:"flex w-72 shrink-0 flex-col gap-3 bg-surface p-4 max-[999px]:data-[open=true]:hidden",children:[e.jsx("h1",{className:"text-heading",children:"Agents and teams"}),e.jsx(ss,{value:i?"team":"agent",onValueChange:m=>Q({kind:m,name:null}),children:e.jsxs(ns,{"aria-label":"Browse definitions by type",className:"w-full",children:[e.jsxs(qe,{value:"agent",className:"flex-1","data-testid":"agents-tab",children:[e.jsx(Yt,{className:"size-3.5"}),"Agents",r.data?e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:r.data.length}):null]}),e.jsxs(qe,{value:"team",className:"flex-1","data-testid":"teams-tab",children:[e.jsx(_t,{className:"size-3.5"}),"Teams",y.data?e.jsx("span",{className:"min-w-[2ch] font-normal text-ink-dim tabular-nums",children:y.data.length}):null]})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(Ot,{"aria-hidden":"true",className:"pointer-events-none absolute top-2 left-2 size-4 text-ink-dim"}),e.jsx(he,{className:"pl-8",type:"search","aria-label":"Search agents and teams",placeholder:i?"Search teams":"Search agents",value:p,onChange:m=>k(m.target.value)})]}),!i&&r.data?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{"aria-hidden":"true",className:"text-meta text-ink-muted",children:"Showing"}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Show definitions owned by"}),e.jsx("div",{className:"flex flex-wrap gap-0.5 rounded-md bg-sunken p-0.5",children:Object.keys(De).map(m=>e.jsx(N,{variant:"ghost",size:"sm","aria-pressed":R===m,onClick:()=>T(m),className:Z(R===m&&rt),children:De[m]},m))})]})]}):null,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe?null:!r.data&&!y.data?e.jsx(Zs,{}):J.length===0?e.jsx("p",{className:"px-1 py-2 text-body-sm text-ink-muted",children:p?`Nothing matches “${p}”.`:i?"No teams yet. Ask for one below, or add one by hand.":R==="all"?"No agents yet. Ask for one below, or add one by hand.":`No ${De[R].toLowerCase()} agents.`}):e.jsx(xn,{rows:J,name:l?null:d,teamMode:i,printName:P,marked:new Map(U.map(m=>[ps(m),m.created])),onOpen:m=>Q({name:m})})}),e.jsxs(N,{variant:"secondary",disabled:!c,onClick:()=>Q({create:i?"team":"agent"}),children:[e.jsx(it,{className:"size-4"}),i?"Add team manually":"Add agent manually"]})]}),e.jsxs("main",{className:"flex min-w-0 flex-1 flex-col",children:[d||l?e.jsx("div",{className:"flex shrink-0 items-center border-hairline border-b px-4 py-2 min-[1000px]:hidden",children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:()=>Q({name:null}),children:[e.jsx(Qt,{className:"size-4"}),"Back to the list"]})}):null,e.jsx("div",{"data-agents-pane":!0,className:"min-h-0 flex-1 overflow-auto p-6 pb-0",style:E>0?{paddingBottom:E+16}:void 0,children:c?xe?e.jsx(Ye,{title:i?"Teams could not be read":"Agents could not be read",what:xe instanceof Error?xe.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:pe,retrying:r.isFetching||y.isFetching}):d&&jt?e.jsx(Je,{}):d&&Ae?e.jsx(Ye,{title:i?`“${d}” could not be read`:`“${d}” could not be read`,what:Ae instanceof Error?Ae.message:"The request did not complete.",meaning:"The definition may have been removed, or the backend refused the read.",onRetry:()=>{j.refetch(),b.refetch()},retrying:j.isFetching||b.isFetching}):l&&i?e.jsx(Xe,{agents:r.data,teams:y.data,askEnabled:I.enabled,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onCancelCreate:()=>f({name:null}),onOpenAgent:m=>Q({kind:"agent",name:m}),onAskAgent:m=>{Re(I,{kind:"team",name:u??""},m)}},"team:create"):l&&h&&C.isLoading?e.jsx(Je,{}):l?e.jsx(ln,{initial:C.data??null,takenNames:(r.data??[]).map(m=>m.name),effortTiers:q,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onCancel:()=>f({name:null})},"agent:create"):i&&b.data?e.jsxs(e.Fragment,{children:[Me("team",b.data.name),e.jsx(Xe,{team:b.data,agents:r.data,teams:y.data,askEnabled:I.enabled,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onOpenAgent:m=>Q({kind:"agent",name:m}),onAskAgent:m=>{Re(I,{kind:"team",name:b.data?.name??""},m)}},`team:${b.data.name}:${ve(b.data)}`)]}):!i&&j.data?e.jsxs(e.Fragment,{children:[Me("agent",j.data.name),e.jsx(on,{profile:j.data,displayedName:P(j.data.name),classNotice:S?.name===j.data.name?S.copy:null,onClassNotice:m=>B(m?{name:j.data.name,copy:m}:null),teams:y.data,effortTiers:q,askEnabled:I.enabled,onDirtyChange:G,onSaved:m=>{pe(),f({name:m})},onDuplicate:m=>Q({create:"agent",duplicate:m.name}),onOpenTeam:m=>Q({kind:"team",name:m}),onAskAgent:m=>{Re(I,{kind:"agent",name:j.data?.name??""},m)}},`agent:${j.data.name}:${j.data.source}:${ve(j.data)}`)]}):d?e.jsx(de,{className:"h-6 w-40"}):e.jsx(pn,{teamMode:i,run:I,onAddManually:()=>Q({create:i?"team":"agent"})}):e.jsxs(se,{variant:g.isLoading?"neutral":"warning",className:"max-w-xl",children:[e.jsx(ne,{children:g.isLoading?"Connecting to the backend":g.error?"The backend could not be reached":"Reusable agents need a newer backend"}),e.jsx(ae,{children:g.isLoading?"Loading what this backend can do…":g.error?g.error.message:"Update the backend to manage reusable agents and teams. Saved chats are unchanged."})]})}),$?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-hairline border-t bg-surface px-4 py-3",role:"alertdialog","aria-label":"Discard your unsaved changes?",children:[e.jsx("span",{className:"text-body-sm text-ink",children:i?"Discard your unsaved changes to this team?":"Discard your unsaved changes to this agent?"}),e.jsx(N,{variant:"danger",onClick:()=>{x(null),f($)},children:"Discard changes"}),e.jsx(N,{variant:"ghost",onClick:()=>D(null),children:"Keep editing"})]}):null,bt?null:e.jsx("div",{className:"shrink-0 border-hairline border-t bg-canvas p-4",children:e.jsx(ut,{run:I,about:I.about,onClearAbout:()=>I.setAbout(null),onStripHeightChange:L,blockedReason:Y?"Finish or cancel your edit first.":null})})]})]})}function pn({teamMode:t,run:s,onAddManually:n}){return e.jsxs("div",{className:"max-w-xl space-y-4",children:[e.jsx("h2",{className:"text-title",children:t?"Ask for a team":"Ask for an agent"}),e.jsx("p",{className:"text-body text-ink-muted",children:t?"A team has one agent that leads the chat and members it can hand work to. Describe what you want and a configuration run sets it up.":"An agent is a reusable set of instructions you can start a chat with, or let other agents call on. Describe what you want and a configuration run sets it up."}),e.jsx(ut,{run:s,hero:!0,about:s.about,onClearAbout:()=>s.setAbout(null)}),e.jsx(N,{variant:"ghost",onClick:n,children:t?"Or add a team by hand":"Or add an agent by hand"})]})}function xn({rows:t,name:s,teamMode:n,marked:a,printName:i,onOpen:l}){const u=o.useRef(new Map),[h,g]=o.useState(s),c=(r,y)=>{const v=t.findIndex(b=>b.name===r);if(v<0)return;const j=t[Math.min(t.length-1,Math.max(0,v+y))];j&&(g(j.name),u.current.get(j.name)?.focus())};return e.jsx("ul",{"aria-label":n?"Teams":"Agents",className:"space-y-1",children:t.map(r=>{const y="source"in r,v=a.get(`${n?"team":"agent"}:${r.name}`);return e.jsx("li",{children:e.jsxs("button",{ref:j=>{j?u.current.set(r.name,j):u.current.delete(r.name)},type:"button","aria-current":r.name===s?"true":void 0,tabIndex:r.name===(h??t[0]?.name)?0:-1,"data-testid":`roster-row-${r.name}`,className:Z("flex min-h-11 w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left hover:bg-row-hover",r.name===s&&rt),onFocus:()=>g(r.name),onClick:()=>l(r.name),onKeyDown:j=>{j.key==="ArrowDown"?(j.preventDefault(),c(r.name,1)):j.key==="ArrowUp"?(j.preventDefault(),c(r.name,-1)):j.key==="Home"?(j.preventDefault(),c(r.name,-t.length)):j.key==="End"&&(j.preventDefault(),c(r.name,t.length))},children:[e.jsxs("span",{className:"flex w-full items-center gap-2",children:[e.jsx("span",{className:"truncate text-body-sm text-ink",children:"members"in r?at(r):i(r.name)}),y?e.jsx(ht,{source:r.source,appearance:"text"}):null,v!==void 0?e.jsx(O,{variant:"attention","data-testid":"roster-row-updated",children:v?"New":"Updated"}):null]}),e.jsxs("span",{className:"flex w-full flex-wrap items-center gap-1.5",children:["members"in r?e.jsx(O,{variant:"neutral",children:r.members.length===1?"1 member":`${r.members.length} members`}):null,y&&Ie(r)==="proactive"?e.jsx(O,{variant:"neutral","data-testid":"roster-row-proactive",children:$s.proactive}):null,r.description?e.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:r.description}):null]})]})},r.name)})})}function bn(t,s,n,a){const i=s.trim().toLowerCase();return(t??[]).filter(l=>n==="builtin"&&l.source!=="builtin"||n==="installed"&&l.source!=="installed"||n==="custom"&&l.source!=="custom"?!1:i?a(l.name).toLowerCase().includes(i)||l.name.toLowerCase().includes(i)||(l.description??"").toLowerCase().includes(i):!0)}function jn(t,s){const n=s.trim().toLowerCase();return(t??[]).filter(a=>!n||a.name.toLowerCase().includes(n)||(a.label??"").toLowerCase().includes(n)||(a.description??"").toLowerCase().includes(n))}export{Cn as AgentsPage};
|