local-operator-ui 0.36.8 → 0.37.0
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 +2046 -19
- package/out/preload/index.js +34 -2
- package/out/renderer/assets/{_basePickBy-D11ygq2l.js → _basePickBy-Ccz_FVoP.js} +1 -1
- package/out/renderer/assets/{_baseUniq-_Pf0yG1r.js → _baseUniq-i6vGpLRc.js} +1 -1
- package/out/renderer/assets/{agent-details-page-LU973LFV.js → agent-details-page-Vg5HG_l0.js} +2 -2
- package/out/renderer/assets/{agent-hub-page-DegTVxlE.js → agent-hub-page-K4pCiyVg.js} +1 -1
- package/out/renderer/assets/{agents-page-B6Y-wB7u.js → agents-page-DO-dA64a.js} +3 -3
- package/out/renderer/assets/{arc-BedtwWh_.js → arc-B4AUWIOq.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DyIP0L4b.js → architectureDiagram-IEHRJDOE-B6S5IVGr.js} +1 -1
- package/out/renderer/assets/{arrow-up-BD8jieeb.js → arrow-up-BQ3q9CbG.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-w5b-ZzdW.js → blockDiagram-JOT3LUYC-LpW3K6pq.js} +1 -1
- package/out/renderer/assets/{book-open-DxzLWerU.js → book-open-1KhbTE6j.js} +1 -1
- package/out/renderer/assets/browser-page-C2PcMomi.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-CbE9FFZv.js → browser-webauthn-prompt-DW_0ckOh.js} +1 -1
- package/out/renderer/assets/{building-2-DtOQfBQY.js → building-2-B-r5qz8T.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-CnSFoHWb.js → c4Diagram-VJAJSXHY-CAqRIAIW.js} +1 -1
- package/out/renderer/assets/channel-C3p9uq-y.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-CY0scau5.js → chunk-4BMEZGHF-xA1Nsxex.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-B_cWmZiK.js → chunk-A2AXSNBT-CUDzamID.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-BRm1a_Ub.js → chunk-AEK57VVT-DlMRhXPR.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-CmZT-cQT.js → chunk-D6G4REZN-VcBIri9Q.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-Cwg1etHt.js → chunk-RZ5BOZE2-CCsj9xK4.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-a-OtMrnF.js → chunk-XZIHB7SX-CKTgVOcT.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-E64bGPOA.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-E64bGPOA.js +1 -0
- package/out/renderer/assets/clone-Cp6fbpqM.js +1 -0
- package/out/renderer/assets/{console-mirror-wrjuOlK5.js → console-mirror-rnDJat8Q.js} +1 -1
- package/out/renderer/assets/{consoleCapture-CGsX86Ez.js → consoleCapture-BDAHhWI6.js} +1 -1
- package/out/renderer/assets/{conversation-input-sync-qFePp_gf.js → conversation-input-sync-DkdrIqiD.js} +277 -277
- package/out/renderer/assets/{dagre-OKDRZEBW-ujAbOxN1.js → dagre-OKDRZEBW-BLJ3cLu1.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-BGt8bOqa.js → diagram-SSKATNLV-BH0p-5Dv.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-DGmIp--B.js → diagram-VNBRO52H-B82m2-a7.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-Czgf2xtG.js → erDiagram-Q7BY3M3F-B49jRhsr.js} +1 -1
- package/out/renderer/assets/{error-boundary-CIO9VaTx.js → error-boundary-2fpGTHTH.js} +2 -2
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-BSuzI5ul.js → flowDiagram-4HSFHLVR-OEuTrGbc.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-DjjvFPP9.js → ganttDiagram-APWFNJXF-WrHus6zK.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-qgMylPGx.js → gitGraphDiagram-7IBYFJ6S-sdpNtvIC.js} +1 -1
- package/out/renderer/assets/{graph-C_PIARec.js → graph-CPx4Z3cH.js} +1 -1
- package/out/renderer/assets/{hash-BTR-wmLC.js → hash-MswM3CQT.js} +1 -1
- package/out/renderer/assets/index-Bt4e_nGt.js +57 -0
- package/out/renderer/assets/index-CXF8GwAZ.js +825 -0
- package/out/renderer/assets/index-Ct_f1nHS.css +1 -0
- package/out/renderer/assets/{index-B5ZsvNme.js → index-D0ZcaKHz.js} +1 -1
- package/out/renderer/assets/{index-B9Z9fABA.js → index-bD-9hTJ5.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-CXhZsMAw.js → infoDiagram-PH2N3AL5-CgbaZe5Z.js} +1 -1
- package/out/renderer/assets/{installer-DsBvKWJk.js → installer-GzNnUma-.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-BfRBfFPi.js → journeyDiagram-U35MCT3I-CIWLEQby.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BjBPm0Wp.js → kanban-definition-NDS4AKOZ-ORj0JKQO.js} +1 -1
- package/out/renderer/assets/{layout-CxH8v5Lh.js → layout-5wBU4YOj.js} +1 -1
- package/out/renderer/assets/legacy-agents-page-ou1Xp1az.js +33 -0
- package/out/renderer/assets/library-page-BloF_iPE.js +157 -0
- package/out/renderer/assets/{mermaid.core-Bx5BMQp8.js → mermaid.core-bCTq7TEV.js} +5 -5
- package/out/renderer/assets/{mesh-page-DXuH0pWs.js → mesh-page-IaVtAjU1.js} +1 -1
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Cnp-gOUf.js → mindmap-definition-ALO5MXBD-Ddhl_xII.js} +1 -1
- package/out/renderer/assets/{mini-Cxcx9-Gz.js → mini-CwNeJTk5.js} +1 -1
- package/out/renderer/assets/{notebook-pen-pmBcBtK5.js → notebook-pen-BY9EwH-7.js} +1 -1
- package/out/renderer/assets/{org-access-BBS-iiGY.js → org-access-c2-UvVYd.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-B9JbfoNw.js → org-surface-gate-B-MS3UYv.js} +1 -1
- package/out/renderer/assets/{page-header-D3rux4P9.js → page-header-CD8VERYn.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-BXGlHMJD.js → pieDiagram-IB7DONF6-STqRBD1R.js} +1 -1
- package/out/renderer/assets/projects-page-EY7aplWJ.js +45 -0
- package/out/renderer/assets/{publication-validation-Dent7Wyb.js → publication-validation-cVu_vGjF.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-DTE1LofJ.js → quadrantDiagram-7GDLP6J5-D93w-jxI.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-C5aiTbpi.js → radar-MK3ICKWK-Dh3CwqLm.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CD4FRlt9.js → radient-auth-buttons-BuUoxJkL.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B-kbiFxO.js → requirementDiagram-KVF5MWMF-pKCmrqyl.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-8mSg8Gx1.js → sankeyDiagram-QLVOVGJD-Dv2syjv2.js} +1 -1
- package/out/renderer/assets/{schedules-page-M0NGG3zh.js → schedules-page-DJ7BtTi7.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-Ctz7PqiC.js → sequenceDiagram-X6HHIX6F-D14uGazi.js} +1 -1
- package/out/renderer/assets/{settings-page-Cy2SAtSh.js → settings-page-BPkUfxJX.js} +7 -7
- package/out/renderer/assets/smartart-uE0Bdv7c.js +1 -0
- package/out/renderer/assets/{stateDiagram-DGXRK772-x8oSqtIw.js → stateDiagram-DGXRK772-CTKP8UrZ.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-C1y1no_O.js +1 -0
- package/out/renderer/assets/team-bridge-page-ClnOkizZ.js +11 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-DZ5836tF.js → timeline-definition-BDJGKUSR-bs2AK5mP.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-B5lixHt9.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-Bgwi0JGB.js → use-download-agent-mutation-B3IkEPEZ.js} +3 -3
- package/out/renderer/assets/{use-session-snapshot-DQs7iPEs.js → use-session-snapshot-BKx6oLGB.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CQNe5VvP.js → xychartDiagram-VJFVF3MP-B8vPLffn.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 +7 -7
- package/package.json +3 -2
- package/out/renderer/assets/browser-page-Bm5bblrV.js +0 -1
- package/out/renderer/assets/channel-BJPW3C83.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BjlJ_E71.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BjlJ_E71.js +0 -1
- package/out/renderer/assets/clone-BuzQaJVT.js +0 -1
- package/out/renderer/assets/index-BSn66J9q.js +0 -57
- package/out/renderer/assets/index-BzHpKJoz.css +0 -1
- package/out/renderer/assets/index-U5qrTe4P.js +0 -824
- package/out/renderer/assets/legacy-agents-page-CiirOdbB.js +0 -33
- package/out/renderer/assets/library-page-CH3E7s4_.js +0 -157
- package/out/renderer/assets/projects-page-DjaYWghP.js +0 -40
- package/out/renderer/assets/smartart-DmOeXeJs.js +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CUVgaWvm.js +0 -1
- package/out/renderer/assets/tags-input-chips-BAP2XNbQ.js +0 -1
- package/out/renderer/assets/team-bridge-page-CYehSZqj.js +0 -11
- package/out/renderer/assets/ui-preferences-store-oc99NgQT.js +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,t as s,c as Y}from"./index-BSn66J9q.js";import{b_ as Ze,aQ as vt,bQ as wt,b$ as Nt,$ as et,u as tt,af as Ue,ag as X,aO as at,aP as Ct,c0 as St,a2 as ce,aK as It,c1 as Pt,aV as ne,aW as fe,a1 as st,bO as Dt,c2 as Lt,aU as Et,bU as Ee,aR as ze,a as Tt,c as Ot,bW as Ut,b7 as zt,bK as Rt,Y as qt,X as $t,aN as nt,ap as it,bJ as Mt,aI as Bt}from"./conversation-input-sync-qFePp_gf.js";import{P as Ht}from"./page-header-D3rux4P9.js";import{c as re,u as U,i as rt,j as ot,a as T,k as lt,l as G,J as ct,S as ut,y as H,I as dt,q as Wt,a4 as je,L as ye,B as Qt,X as Vt,a5 as Kt,a6 as At,a7 as Gt,A as _e,z as Se,E as le,K as Yt,M as Ft,N as Jt,O as Xt,P as Ie,C as Zt,a8 as ea,v as ta,w as aa}from"./error-boundary-CIO9VaTx.js";import{bx as sa,by as mt,bz as Te,bA as Oe,bB as na,bC as Ae,bD as ia,bE as ra,a as oa,bF as se,bG as ie,bH as la,bI as ca,bJ as ua,bK as da,bL as Pe,bM as ma,bq as ha,bN as pa,y as Re,bO as ht,bd as ga,aX as xa,A as ba,aZ as fa,b4 as ya,bP as pt,bQ as _a,bR as gt,bg as ja,bS as ka,bT as Ge}from"./index-U5qrTe4P.js";import{T as va}from"./tags-input-chips-BAP2XNbQ.js";import{N as wa}from"./notebook-pen-pmBcBtK5.js";import{e as Na,g as Ca,i as Sa,u as Ia}from"./ui-preferences-store-oc99NgQT.js";import{n as De,u as Pa,a as Da,H as La,p as Ea}from"./org-access-BBS-iiGY.js";import{o as Ta,a as Oa}from"./org-surface-gate-B9JbfoNw.js";import{R as Ye}from"./radient-auth-buttons-CD4FRlt9.js";import{c as Ua,i as za,d as Ra,e as qa,t as $a,p as Fe,P as Je}from"./publication-validation-Dent7Wyb.js";import"./console-mirror-wrjuOlK5.js";/**
|
|
2
|
-
* @license lucide-react v0.507.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Ma=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ba=re("ellipsis-vertical",Ma);/**
|
|
7
|
-
* @license lucide-react v0.507.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ha=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],Xe=re("file-input",Ha);/**
|
|
12
|
-
* @license lucide-react v0.507.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Wa=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],Qa=re("file-output",Wa);/**
|
|
17
|
-
* @license lucide-react v0.507.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Va=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Ka=re("git-branch",Va);/**
|
|
22
|
-
* @license lucide-react v0.507.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Aa=[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]],Ga=re("id-card",Aa);/**
|
|
27
|
-
* @license lucide-react v0.507.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Ya=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]],Fa=re("import",Ya),Ja=({agentId:t,agentName:n,onAgentDeleted:a,buttonSx:i={},isAgentsPage:r=!1,onViewAgentSettings:l,onChatWithAgent:u,onExportAgent:x,onClearConversation:h,onUploadAgentToHub:k})=>{U();const[j,b]=o.useState(!1),[c,d]=o.useState(!1),[y,f]=o.useState(!1),v=o.useRef(!1),S=sa(),{clearAgentFromAllPages:I}=Ze(),P=async()=>{try{await S.mutateAsync(t),I(t),a?.(t)}catch(C){console.error("Failed to delete agent:",C)}finally{d(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(rt,{open:j,onOpenChange:b,modal:!1,children:[e.jsx(ot,{asChild:!0,children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.dialogs.menu.accessible"),"data-tour-tag":"agent-options-button",onClick:C=>{C.stopPropagation(),C.detail===0&&b(L=>!L)},style:i,children:e.jsx(Ba,{"aria-hidden":"true"})})}),e.jsxs(lt,{align:"end",className:"min-w-45",onClick:C=>C.stopPropagation(),onInteractOutside:C=>{const L=C.detail.originalEvent.target;L instanceof Element&&L.closest(".shepherd-element")&&C.preventDefault()},onCloseAutoFocus:C=>{v.current&&(v.current=!1,C.preventDefault())},children:[r&&u&&e.jsxs(G,{onSelect:u,children:[e.jsx(mt,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.chat")})]}),!r&&l&&e.jsxs(G,{"data-tour-tag":"view-agent-settings-menu-item",onSelect:l,children:[e.jsx(Te,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.settings")})]}),x&&e.jsxs(G,{onSelect:x,children:[e.jsx(Qa,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.export")})]}),k&&e.jsxs(G,{"data-tour-tag":"upload-to-hub-menu-item",onSelect:k,children:[e.jsx(Oe,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.upload")})]}),h&&e.jsxs(G,{className:"text-warning data-[highlighted]:bg-warning-wash",onSelect:()=>{v.current=!0,f(!0)},children:[e.jsx(na,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.clear")})]}),e.jsxs(G,{destructive:!0,onSelect:()=>{v.current=!0,d(!0)},children:[e.jsx(vt,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.delete")})]})]})]}),e.jsx(Ae,{open:c,title:s("ui.agents.dialogs.delete.title"),message:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-body text-ink",children:s("ui.agents.dialogs.delete.question",{name:n})}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:s("ui.agents.dialogs.delete.warning")})]}),confirmText:s("ui.agents.dialogs.delete.confirm"),cancelText:s("ui.agents.dialogs.delete.cancel"),isDangerous:!0,onConfirm:P,onCancel:()=>d(!1)}),e.jsx(Ae,{open:y,title:s("ui.agents.dialogs.clear.title"),message:s("ui.agents.dialogs.clear.warning"),confirmText:s("ui.agents.dialogs.clear.confirm"),cancelText:s("ui.agents.dialogs.clear.cancel"),isDangerous:!0,onConfirm:()=>{h?.(),f(!1)},onCancel:()=>f(!1)})]})},Xa=({page:t,count:n,onChange:a})=>{U();const i=()=>{t>1&&a(t-1)},r=()=>{t<n&&a(t+1)};return n<=1?null:e.jsxs("div",{className:"sticky bottom-0 left-0 right-0 z-10 flex min-h-13 items-center justify-between border-t border-hairline bg-surface px-4 py-2",children:[e.jsx(T,{variant:"ghost",size:"icon-sm",onClick:i,disabled:t<=1,"aria-label":s("ui.common.forms.compact_pagination.previous_page"),children:e.jsx(wt,{})}),e.jsx("span",{className:"select-none text-meta text-ink-dim",children:s("ui.common.forms.pagination.position",{page:String(t),count:String(n)})}),e.jsx(T,{variant:"ghost",size:"icon-sm",onClick:r,disabled:t>=n,"aria-label":s("ui.common.forms.compact_pagination.next_page"),children:e.jsx(ct,{})})]})},xt=t=>["agent-system-prompt",t],bt=t=>{const{shouldEnableQuery:n}=Nt();return et({enabled:n({bypassInternetCheck:!0})&&!!t,queryKey:xt(t),queryFn:async()=>{try{const i=await Ue(X.baseUrl).agents.getAgentSystemPrompt(t);if(i.status>=400)throw new Error(i.message||"Failed to fetch agent system prompt");return i.result?.system_prompt||""}catch(a){const i=a instanceof Error?a.message:"An unknown error occurred while fetching agent system prompt";throw ce(i),a}},refetchOnWindowFocus:!1,staleTime:5e3})},Za=t=>{const n=tt(),a=Ue(X.baseUrl);return at({mutationFn:async i=>{const r=St(i);if(r)throw ce(r),new Error(r);try{const l=await a.agents.updateAgentSystemPrompt(t,i);if(l.status>=400)throw new Error(l.message||"Failed to update agent system prompt");return l}catch(l){const u=l instanceof Error?l.message:"An unknown error occurred while updating agent system prompt";throw ce(u),l}},onSuccess:async()=>{await n.invalidateQueries({queryKey:xt(t)}),Ct("Agent system prompt updated")},onError:i=>{console.error("Error updating agent system prompt:",i)}})},es=()=>{const[t,n]=It(),a=Pt(),i=()=>{const l=t.get("page");return l?Number.parseInt(l,10):1},r=l=>{const u=new URLSearchParams(t);l===1?u.delete("page"):u.set("page",l.toString()),n(u)};return{page:i(),setPage:r,isView:l=>a.pathname.startsWith(`/${l}`)}},ts=({open:t,onClose:n,onAgentImported:a})=>{U();const[i,r]=o.useState(null),[l,u]=o.useState(!1),[x,h]=o.useState(null),k=o.useRef(null),j=ia(),b=o.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u(!0)},[]),c=o.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u(!1)},[]),d=o.useCallback(_=>{_.preventDefault(),_.stopPropagation()},[]),y=o.useCallback(_=>_.name.toLowerCase().endsWith(".zip")?(h(null),!0):(h("ui.agents.dialogs.import.invalid_zip"),!1),[]),f=o.useCallback(_=>{if(_.preventDefault(),_.stopPropagation(),u(!1),_.dataTransfer.files&&_.dataTransfer.files.length>0){const E=_.dataTransfer.files[0];y(E)&&r(E)}},[y]),v=o.useCallback(_=>{if(_.target.files&&_.target.files.length>0){const E=_.target.files[0];y(E)&&r(E)}},[y]),S=o.useCallback(()=>{k.current?.click()},[]),I=async()=>{if(i)try{const _=await j.mutateAsync(i);r(null),h(null),a&&_&&a(_.id),n()}catch(_){console.error("Failed to import agent:",_)}},P=()=>{r(null),h(null),n()},C=j.isPending,L=C||!i,g=e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:19,className:"text-accent","aria-hidden":"true"}),s("ui.agents.dialogs.import.title")]}),w=e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:P,disabled:C,children:s("ui.agents.dialogs.import.cancel")}),e.jsx(fe,{onClick:I,disabled:L,startIcon:C?e.jsx(ut,{}):null,children:s("ui.agents.dialogs.import.submit")})]});return e.jsxs(st,{open:t,onClose:P,title:g,actions:w,maxWidth:"sm",children:[e.jsx("p",{className:"mb-4 text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.intro")}),e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx("input",{ref:k,type:"file",accept:".zip",onChange:v,disabled:C,className:"hidden"}),e.jsx("button",{type:"button",onClick:S,onDragEnter:b,onDragLeave:c,onDragOver:d,onDrop:f,disabled:C,className:Y("cursor-pointer rounded-lg border-2 border-control border-dashed bg-surface p-4 text-center","transition-colors duration-base ease-out-quart","hover:bg-accent-wash","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",l&&"border-accent bg-accent-wash"),children:i?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:i.name}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.replace_file")})]}):e.jsxs(e.Fragment,{children:[e.jsx(ra,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:s("ui.agents.dialogs.import.drop_file")}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.choose_file")})]})}),x&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:s(x)})]})]})},as=({title:t,searchQuery:n,onSearchChange:a,onNewAgentClick:i,searchPlaceholder:r="Search agents",newAgentTooltip:l="Create a new agent",onImportAgentClick:u,importAgentTooltip:x="Import an agent from a ZIP file"})=>e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsx("h2",{className:"truncate text-heading text-ink",children:t}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[u&&e.jsx(H,{content:x,children:e.jsx(T,{variant:"ghost",size:"icon",onClick:u,"aria-label":"Import agent",children:e.jsx(Fa,{"aria-hidden":"true"})})}),e.jsx(H,{content:l,children:e.jsx(T,{variant:"primary",size:"icon",onClick:i,"aria-label":"New agent","data-tour-tag":"create-new-agent-button",children:e.jsx(oa,{"aria-hidden":"true"})})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{size:16,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim"}),e.jsx(dt,{type:"search",inputSize:"lg",placeholder:r,value:n,onChange:h=>a(h.target.value),"aria-label":r,className:"pl-9"})]})]}),N={temperature:.2,top_p:.9,top_k:40,max_tokens:4096,frequency_penalty:0,presence_penalty:0,seed:42},A=({label:t,description:n,defaultLabel:a,onSet:i})=>(U(),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-body-sm text-ink",children:t}),e.jsx("span",{className:"text-meta text-ink-dim",children:s("ui.agents.settings.chat.not_set_yet")})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-dim",children:n})]}),e.jsx(T,{variant:"secondary",size:"sm",className:"shrink-0",onClick:i,children:s("ui.agents.settings.chat.set_to_default",{value:String(a)})})]})),Le=({title:t,children:n})=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h3",{className:"text-body-sm font-semibold text-ink-muted",children:t}),n]}),ss=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:i,refetchAgent:r,initialSelectedAgentId:l})=>{U();const[u,x]=o.useState(t);o.useEffect(()=>{x(t)},[t]);const[h,k]=o.useState(!1),j=o.useId(),b=h?Wt:ct;return e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>k(!h),"aria-expanded":h,"aria-controls":j,className:"group flex items-center gap-2 py-1 text-left text-heading text-ink",children:[e.jsx(b,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink"}),s("ui.agents.settings.chat.advanced_chat_settings")]}),e.jsx(H,{content:s("ui.agents.settings.chat.advanced_settings_to_change_how_the_agent"),children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.chat.about_advanced_chat_settings"),children:e.jsx(je,{})})})]}),h&&e.jsxs("div",{id:j,className:"mt-3",children:[e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.chat.set_custom_values_for_any_of_these")}),e.jsxs("div",{className:"mt-6 flex flex-col gap-8",children:[e.jsxs(Le,{title:s("ui.agents.settings.chat.sampling"),children:[u.temperature===null?e.jsx(A,{label:s("ui.agents.settings.chat.temperature"),description:s("ui.agents.settings.chat.controls_randomness_in_responses_0_0_1"),defaultLabel:N.temperature,onSet:async()=>{a("temperature");try{const c={temperature:N.temperature};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,temperature:N.temperature})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.temperature??N.temperature,label:s("ui.agents.settings.chat.temperature"),description:s("ui.agents.settings.chat.controls_randomness_in_responses_0_0_1"),min:0,max:1,step:.01,isSaving:n==="temperature",onChange:async c=>{a("temperature");try{const d={temperature:c};await i.mutateAsync({agentId:t.id,update:d}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),u.top_p===null?e.jsx(A,{label:s("ui.agents.settings.chat.top_p"),description:s("ui.agents.settings.chat.controls_cumulative_probability_of_tokens_to_sample"),defaultLabel:N.top_p,onSet:async()=>{a("top_p");try{const c={top_p:N.top_p};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,top_p:N.top_p})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.top_p??N.top_p,label:s("ui.agents.settings.chat.top_p"),description:s("ui.agents.settings.chat.controls_cumulative_probability_of_tokens_to_sample"),min:0,max:1,step:.01,isSaving:n==="top_p",onChange:async c=>{a("top_p");try{const d={top_p:c};await i.mutateAsync({agentId:t.id,update:d}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),u.top_k===null?e.jsx(A,{label:s("ui.agents.settings.chat.top_k"),description:s("ui.agents.settings.chat.limits_tokens_to_sample_from_at_each"),defaultLabel:N.top_k,onSet:async()=>{a("top_k");try{const c={top_k:N.top_k};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,top_k:N.top_k})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.top_k??N.top_k,label:s("ui.agents.settings.chat.top_k"),description:s("ui.agents.settings.chat.limits_tokens_to_sample_from_at_each"),min:1,max:100,step:1,isSaving:n==="top_k",onChange:async c=>{a("top_k");try{const d={top_k:c};await i.mutateAsync({agentId:t.id,update:d}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),u.seed===null?e.jsx(A,{label:s("ui.agents.settings.chat.seed"),description:s("ui.agents.settings.chat.random_number_seed_for_deterministic_generation"),defaultLabel:N.seed,onSet:async()=>{a("seed");try{const c={seed:N.seed};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,seed:N.seed})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(ie,{value:u.seed?.toString()||"",label:s("ui.agents.settings.chat.seed"),placeholder:s("ui.agents.settings.chat.random_number_seed_for_deterministic_generation_detail"),icon:e.jsx(Te,{size:16}),isSaving:n==="seed",onSave:async c=>{a("seed");try{const d=c.trim()?Number.parseInt(c,10):void 0;if(c.trim()&&Number.isNaN(d)){ce(s("ui.agents.settings.chat.error.invalid_seed"));return}const y={seed:d};await i.mutateAsync({agentId:t.id,update:y}),t.id===l&&r&&await r()}catch{}finally{a(null)}}})]}),e.jsxs(Le,{title:s("ui.agents.settings.chat.repetition"),children:[u.frequency_penalty===null?e.jsx(A,{label:s("ui.agents.settings.chat.frequency_penalty"),description:s("ui.agents.settings.chat.reduces_repetition_by_lowering_likelihood_of_repeated"),defaultLabel:N.frequency_penalty,onSet:async()=>{a("frequency_penalty");try{const c={frequency_penalty:N.frequency_penalty};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,frequency_penalty:N.frequency_penalty})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.frequency_penalty??N.frequency_penalty,label:s("ui.agents.settings.chat.frequency_penalty"),description:s("ui.agents.settings.chat.reduces_repetition_by_lowering_likelihood_of_repeated"),min:-2,max:2,step:.01,isSaving:n==="frequency_penalty",onChange:async c=>{a("frequency_penalty");try{const d={frequency_penalty:c};await i.mutateAsync({agentId:t.id,update:d}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),u.presence_penalty===null?e.jsx(A,{label:s("ui.agents.settings.chat.presence_penalty"),description:s("ui.agents.settings.chat.increases_diversity_by_lowering_likelihood_of_prompt"),defaultLabel:N.presence_penalty,onSet:async()=>{a("presence_penalty");try{const c={presence_penalty:N.presence_penalty};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,presence_penalty:N.presence_penalty})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.presence_penalty??N.presence_penalty,label:s("ui.agents.settings.chat.presence_penalty"),description:s("ui.agents.settings.chat.increases_diversity_by_lowering_likelihood_of_prompt"),min:-2,max:2,step:.01,isSaving:n==="presence_penalty",onChange:async c=>{a("presence_penalty");try{const d={presence_penalty:c};await i.mutateAsync({agentId:t.id,update:d}),t.id===l&&r&&await r()}catch{}finally{a(null)}}})]}),e.jsxs(Le,{title:s("ui.agents.settings.chat.length_and_stopping"),children:[u.max_tokens===null?e.jsx(A,{label:s("ui.agents.settings.chat.max_tokens"),description:s("ui.agents.settings.chat.maximum_tokens_to_generate_in_response"),defaultLabel:N.max_tokens,onSet:async()=>{a("max_tokens");try{const c={max_tokens:N.max_tokens};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,max_tokens:N.max_tokens})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(se,{value:u.max_tokens??N.max_tokens,label:s("ui.agents.settings.chat.max_tokens"),description:s("ui.agents.settings.chat.maximum_tokens_to_generate_in_response"),min:1,max:8192,step:1,isSaving:n==="max_tokens",onChange:async c=>{a("max_tokens");try{const d={max_tokens:c};await i.mutateAsync({agentId:t.id,update:d}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),u.stop===null?e.jsx(A,{label:s("ui.agents.settings.chat.stop_sequences"),description:s("ui.agents.settings.chat.sequences_that_will_cause_the_model_to"),defaultLabel:s("ui.agents.settings.chat.empty"),onSet:async()=>{a("stop");try{const c={stop:[]};await i.mutateAsync({agentId:t.id,update:c}),x(d=>({...d,stop:[]})),t.id===l&&r&&await r()}catch{}finally{a(null)}}}):e.jsx(ie,{value:u.stop?.join(`
|
|
32
|
-
`)||"",label:s("ui.agents.settings.chat.stop_sequences"),placeholder:s("ui.agents.settings.chat.enter_stop_sequences_one_per_line"),icon:e.jsx(Te,{size:16}),multiline:!0,rows:3,isSaving:n==="stop",onSave:async c=>{a("stop");try{const d=c.split(`
|
|
33
|
-
`).map(f=>f.trim()).filter(f=>f.length>0),y={stop:d.length>0?d:void 0};await i.mutateAsync({agentId:t.id,update:y}),t.id===l&&r&&await r()}catch{}finally{a(null)}}})]})]})]})]})},ft=["investment","accounting","healthcare","legal","software","security","role_play","personal_assistance","education","marketing","sales","research","analysis","management","social_media","other"],xe=Object.fromEntries(ft.map(t=>[t,t.split("_").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")])),ns=({value:t,label:n,onChange:a,placeholder:i="Add category...",disabled:r=!1,icon:l})=>{const[u,x]=o.useState(""),[h,k]=o.useState(!1),[j,b]=o.useState(0),c=o.useRef(null),d=o.useRef([]),y=o.useId(),f=o.useId(),v=o.useMemo(()=>{const g=u.trim().toLowerCase();return ft.filter(w=>!t.includes(w)&&(!g||xe[w].toLowerCase().includes(g)))},[t,u]);o.useEffect(()=>{h&&d.current[j]?.scrollIntoView({block:"nearest"})},[j,h]);const S=g=>{t.includes(g)||a([...t,g]),x(""),k(!1),b(0),c.current?.focus()},I=g=>{x(g.target.value),b(0),k(!0)},P=g=>{const w=v.length;switch(g.key){case"ArrowDown":if(g.preventDefault(),w===0)break;h?b((j+1)%w):(b(0),k(!0));break;case"ArrowUp":if(g.preventDefault(),w===0)break;h?b((j-1+w)%w):(b(w-1),k(!0));break;case"Enter":h&&v[j]&&(g.preventDefault(),S(v[j]));break;case"Escape":h&&(g.preventDefault(),k(!1));break;case"Home":h&&(g.preventDefault(),b(0));break;case"End":h&&(g.preventDefault(),b(v.length-1));break}},C=g=>{a(t.filter(w=>w!==g)),b(0)},L=h&&v[j]?`${f}-option-${j}`:void 0;return e.jsxs("div",{children:[e.jsxs(ye,{htmlFor:y,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[l,n]}),e.jsxs("div",{className:Y("flex min-h-11 flex-wrap items-center gap-2 rounded-sm border border-control bg-surface p-2","has-[input:focus-visible]:outline-solid has-[input:focus-visible]:outline-2","has-[input:focus-visible]:outline-accent has-[input:focus-visible]:outline-offset-2",r&&"border-hairline bg-sunken"),children:[t.map(g=>e.jsxs(Qt,{className:"gap-1 pr-1 text-ink",children:[xe[g]||g,e.jsx("button",{type:"button","aria-label":`Remove category ${xe[g]||g}`,disabled:r,onClick:()=>C(g),className:Y("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(Vt,{})})]},g)),e.jsxs(Kt,{open:h,onOpenChange:k,children:[e.jsx(At,{asChild:!0,children:e.jsx("input",{id:y,ref:c,type:"text",role:"combobox","aria-expanded":h,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":L,autoComplete:"off",value:u,placeholder:i,disabled:r,"aria-label":n,onChange:I,onKeyDown:P,onClick:()=>{v.length>0&&k(!0)},className:Y("min-w-20 flex-1 bg-transparent px-1 py-0.5 outline-none","text-body-sm text-ink placeholder:text-ink-dim","disabled:text-ink-disabled disabled:placeholder:text-ink-disabled")})}),e.jsx(Gt,{align:"start",sideOffset:4,onOpenAutoFocus:g=>g.preventDefault(),className:"max-h-60 w-(--radix-popover-trigger-width) overflow-y-auto p-1",children:e.jsx("div",{id:f,role:"listbox","aria-label":n,children:v.map((g,w)=>e.jsx("div",{id:`${f}-option-${w}`,ref:_=>{d.current[w]=_},role:"option","aria-selected":w===j,onMouseDown:_=>{_.preventDefault()},onMouseEnter:()=>b(w),onClick:()=>S(g),className:Y("cursor-pointer rounded-sm px-3 py-1.5 font-medium text-body-sm",w===j?"bg-accent-wash":void 0,"text-ink"),children:xe[g]||g},g))})})]})]}),t.length===0&&e.jsx("span",{className:"mt-1 ml-1 block text-ink-dim text-meta",children:"No categories selected"})]})},is=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:i,refetchAgent:r,initialSelectedAgentId:l})=>{U();const{data:u,isLoading:x}=Lt(),[h,k]=o.useState("");o.useEffect(()=>{!x&&u?.values?k(t.hosting||u.values.hosting||""):x||k(t.hosting||"")},[t,u,x]);const[j,b]=o.useState(!1),[c,d]=o.useState(!1);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ie,{value:t.name,label:s("ui.agents.settings.general.agent_name"),placeholder:s("ui.agents.settings.general.enter_agent_name"),isSaving:n==="name",onSave:async y=>{if(!y.trim()){ce(s("ui.agents.settings.general.error.empty_name"));return}a("name");try{const f={name:y};await i.mutateAsync({agentId:t.id,update:f}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{"data-tour-tag":"agent-settings-hosting-select",children:e.jsx(la,{value:t.hosting||(u?.values.hosting??""),isSaving:n==="hosting",onSave:async y=>{a("hosting"),k(y);try{const f={hosting:y,model:""};await i.mutateAsync({agentId:t.id,update:f}),t.id===l&&r&&await r()}catch{k(t.hosting||"")}finally{a(null)}},filterByCredentials:!0,allowDefault:!0},`hosting-select-${t.id}-${t.hosting||(u?.values.hosting??"default")}`)}),e.jsx("div",{"data-tour-tag":"agent-settings-model-select",children:h?e.jsx(ca,{value:t.hosting?t.model||"":t.model||(u?.values.model_name??""),hostingId:h,isSaving:n==="model",allowDefault:!0,onSave:async y=>{a("model");try{const f={model:y};await i.mutateAsync({agentId:t.id,update:f}),t.id===l&&r&&await r()}catch{}finally{a(null)}}},`model-select-${t.id}-${h}-${t.model||(!t.hosting&&u?.values.model_name?u.values.model_name:"default")}`):e.jsxs("div",{className:"relative",children:[e.jsx(H,{content:s("ui.agents.settings.general.select_a_hosting_provider_first_and_then"),children:e.jsxs("div",{className:"mb-1.5 flex w-fit items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(ua,{size:16,"aria-hidden":"true"}),s("ui.agents.settings.general.model")]})}),e.jsx("div",{className:"flex h-8 w-full items-center rounded-sm border border-control bg-surface px-3",children:e.jsx("span",{className:"truncate text-body-sm text-ink-disabled",children:s("ui.agents.settings.general.select_a_hosting_provider_first")})})]})})]}),e.jsxs("h2",{className:"mt-4 flex items-center gap-2 text-heading text-ink",children:[e.jsx(je,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.general.agent_information")]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ie,{value:t.description||"",label:s("ui.agents.settings.general.description"),placeholder:s("ui.agents.settings.general.enter_agent_description"),multiline:!0,rows:3,isSaving:n==="description",onSave:async y=>{a("description");try{const f={description:y};await i.mutateAsync({agentId:t.id,update:f}),t.id===l&&r&&await r()}catch{}finally{a(null)}}}),e.jsx(va,{value:t.tags||[],label:s("ui.agents.settings.general.tags"),placeholder:s("ui.agents.settings.general.add_tag"),disabled:j,onChange:async y=>{if(!(Array.isArray(t.tags)&&y.length===t.tags.length&&y.every((f,v)=>f===t.tags?.[v]))){b(!0);try{const f={tags:y};await i.mutateAsync({agentId:t.id,update:f}),t.id===l&&r&&await r()}catch{}finally{b(!1)}}}}),e.jsx(ns,{value:t.categories||[],label:s("ui.agents.settings.general.categories"),placeholder:s("ui.agents.settings.general.add_category"),disabled:c,onChange:async y=>{if(!(Array.isArray(t.categories)&&y.length===t.categories.length&&y.every((f,v)=>f===t.categories?.[v]))){d(!0);try{const f={categories:y};await i.mutateAsync({agentId:t.id,update:f}),t.id===l&&r&&await r()}catch{}finally{d(!1)}}}}),e.jsxs(da,{children:[e.jsx(Pe,{label:e.jsxs(e.Fragment,{children:[e.jsx(Ga,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.id")]}),value:e.jsx("span",{className:"font-mono text-mono-sm",children:t.id})}),e.jsx(Pe,{label:e.jsxs(e.Fragment,{children:[e.jsx(ma,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.created")]}),value:Et(t.created_date)}),e.jsx(Pe,{label:e.jsxs(e.Fragment,{children:[e.jsx(Ka,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.version")]}),value:t.version})]})]})]})},rs=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:i,refetchAgent:r,initialSelectedAgentId:l})=>(U(),e.jsxs("div",{"data-tour-tag":"agent-settings-security",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(ha,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.security.security_instructions"),e.jsx(H,{content:s("ui.agents.settings.security.security_instructions_that_guide_the_agent_s"),children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.security.about_security_instructions"),children:e.jsx(je,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.security.this_prompt_is_directed_to_the_ai")}),e.jsx("div",{className:"mt-4",children:e.jsx(ie,{value:t.security_prompt||"",label:"",placeholder:s("ui.agents.settings.security.enter_instructions_for_the_security_agent"),multiline:!0,rows:6,isSaving:n==="security_prompt",onSave:async u=>{a("security_prompt");try{const x={security_prompt:u};await i.mutateAsync({agentId:t.id,update:x}),t.id===l&&r&&await r()}catch{}finally{a(null)}}})})]})),os=({selectedAgent:t,savingField:n,setSavingField:a,refetchAgent:i,initialSelectedAgentId:r})=>{U();const{data:l,isLoading:u}=bt(t.id),x=Za(t.id),[h,k]=o.useState("");return o.useEffect(()=>{l!==void 0&&k(l)},[l]),e.jsxs("div",{"data-tour-tag":"agent-settings-system-prompt",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(wa,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.system_prompt.agent_instructions"),e.jsx(H,{content:s("ui.agents.settings.system_prompt.system_instructions_that_define_the_agent_s"),children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.system_prompt.about_agent_instructions"),children:e.jsx(je,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.system_prompt.define_the_agent_s_role_personality_or")}),e.jsx("div",{className:"mt-4",children:e.jsx(ie,{value:h,label:"",placeholder:u?s("ui.agents.settings.system_prompt.loading_system_prompt"):s("ui.agents.settings.system_prompt.enter_instructions_for_the_agent"),multiline:!0,rows:6,isSaving:n==="system_prompt",onSave:async j=>{a("system_prompt");try{await x.mutateAsync(j),t.id===r&&i&&await i()}finally{a(null)}}})})]})},ls=({selectedAgent:t,refetchAgent:n,initialSelectedAgentId:a})=>{U();const[i,r]=o.useState(null),l=pa();return e.jsx("div",{"data-tour-tag":"agent-settings-details-paper",className:"h-full overflow-hidden",children:t?e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(is,{selectedAgent:t,savingField:i,setSavingField:r,updateAgentMutation:l,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(os,{selectedAgent:t,savingField:i,setSavingField:r,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(rs,{selectedAgent:t,savingField:i,setSavingField:r,updateAgentMutation:l,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(ss,{selectedAgent:t,savingField:i,setSavingField:r,updateAgentMutation:l,refetchAgent:n,initialSelectedAgentId:a})]})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-8 text-center",children:[e.jsx(Re,{size:48,className:"text-ink-dim","aria-hidden":"true"}),e.jsx("h2",{className:"text-heading text-ink",children:s("ui.agents.settings.agent.no_agent_selected")}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:s("ui.agents.settings.agent.select_an_agent_from_the_list_on")})]})})},qe=Na()(Ca(t=>({listings:{},remember:(n,a)=>{t(i=>({listings:{...i.listings,[n]:a}}))},forget:n=>{t(a=>{if(!(n in a.listings))return a;const i={...a.listings};return delete i[n],{listings:i}})}}),{name:"published-listings-storage"})),cs=t=>qe(n=>t?n.listings[t]??null:null),us=400,ds=2,ms=t=>[...t].length>=ds;function hs(t){if(!t)return{state:"unknown",builtinName:null};if(t.available)return{state:"available",builtinName:null};const n=t.details?.builtin_name??null;return t.code==="name_taken"?{state:"taken",builtinName:null}:t.code==="name_reserved_builtin"?{state:"reserved",builtinName:n}:{state:"unknown",builtinName:null}}const ps=(t,n)=>{const a=t.trim(),i=ht(a,us),r=n&&i===a&&ms(i)&&Sa(i),l=et({queryKey:["agent-name-availability",i],enabled:r,queryFn:async()=>(await Ee.getAgentNameAvailability(X.baseUrl,i)).result,retry:!1,staleTime:15e3,refetchOnWindowFocus:!1});return!r||l.isPending?{state:r?"checking":"idle",builtinName:null}:l.isError?{state:"unknown",builtinName:null}:hs(l.data)},gs=()=>{const t=tt();return at({mutationFn:async({agentId:n,document:a,hubAgentId:i,target:r,policy:l})=>{if(!X.baseUrl)throw new Error("Local Operator API URL is not configured.");return i?Ee.republishAgentInstructionSet(X.baseUrl,n,i,a,r,l):Ee.publishAgentInstructionSet(X.baseUrl,n,a,r,l)},onSuccess:(n,a)=>{const i=n.result;i?.agent_id&&!a.target&&qe.getState().remember(a.agentId,{hubAgentId:i.agent_id,name:i.name,publishedAt:new Date().toISOString()}),i?.local_link_receipt&&t.invalidateQueries({queryKey:ga}),a.target?Ua(t,a.target.tenantId):za(t)},onError:n=>{console.error("Publishing an agent to the hub failed:",n)}})},be="public",yt=({open:t,onClose:n,agent:a,isAuthenticated:i,onSignInSuccess:r,onPublished:l})=>{const[u,x]=o.useState(!1),[h,k]=o.useState(""),[j,b]=o.useState(null),[c,d]=o.useState(null),[y,f]=o.useState(!1),v=o.useRef(null),S=o.useRef(null),I=ze(),P=gs();U();const[C,L]=o.useState(De),g=o.useRef(null),w=o.useRef({open:!1,id:null}),_=cs(a?.id??null),E=Tt(),z=Ot(E.data,"hub_links"),W=xa(t&&z),ke=Ut(),ue=zt(E.data,"radient_org"),ve=Oa(ue),de=i?Ta(ue,ke??null):null,{memberships:F,isError:we}=ba({enabled:t&&i&&ve}),Z=o.useMemo(()=>Pa(F),[F]),J=o.useMemo(()=>Da(F),[F]),[$,me]=o.useState(be),p=$!==be,O=(W.data?.links??[]).filter(m=>m.kind==="agent"&&m.local_id===a?.id),D=O.find(m=>m.visibility===(p?"org":"public")&&m.tenant_id===(p?$:null)),M=O.find(m=>m.link_id!==D?.link_id),V=W.data?.unresolved.some(m=>m.kind==="agent"&&m.local_id===a?.id),B=Z.find(m=>m.tenant_id===$),he=p?B?.tenant_name?s("ui.hub.links.source_private",{organization:B.tenant_name}):s("ui.hub.links.source_unavailable"):s("ui.hub.links.source_public"),oe=Z.find(m=>m.tenant_id===$)?.tenant_name||"this organization",pe=o.useId(),ge=o.useId(),{data:$e}=bt(t&&a?a.id:""),{data:Me}=Rt(t);o.useEffect(()=>{t&&(!w.current.open||w.current.id!==(a?.id??null))&&k(a?.name??""),w.current={open:t,id:a?.id??null}},[t,a?.id,a?.name]),o.useEffect(()=>{t||(x(!1),b(null),d(null),f(!1),me(be),L(De()),g.current=null)},[t]);const _t=o.useMemo(()=>(Me??[]).filter(m=>m.source==="builtin").map(m=>m.name),[Me]),Be=Ra(h,_t),He=ps(h,t&&i),ee=o.useMemo(()=>{const m=qa({name:h,description:a?.description??"",instructions:$e??null,tools:$a(a?.tags)});return Be&&m.unshift({field:"name",message:Fe({code:"name_reserved_builtin",message:""},{name:h,hubAgentId:null}).body}),m},[h,a?.description,a?.tags,$e,Be]),R=j?Fe(j,{name:h,hubAgentId:_?.hubAgentId??null}):null,te=P.isPending,Ne=async m=>{if(!a||te||ee.length>0||p&&!B)return;b(null);const q=m?.asNewListing?null:D?.hub_id??(p?null:_?.hubAgentId??null),Qe=!!q;if(!(z&&(!W.isSuccess||M||V)))try{const K={name:h.trim()},Ve=JSON.stringify({agent:a.id,document:K,hubAgentId:q,target:$,policy:D?null:C}),Ce=g.current?.tuple===Ve?g.current:{tuple:Ve,id:crypto.randomUUID()};g.current=Ce;const ae=(await P.mutateAsync({agentId:a.id,document:K,hubAgentId:q,...z?{policy:D?{requestId:Ce.id,...D.remote_revision&&Qe?{expectedRemoteRevision:D.remote_revision}:{}}:{requestId:Ce.id,...C}}:{},target:p?{visibility:"org",tenantId:$}:void 0})).result,Ke={name:ae?.name??h.trim(),hubAgentId:ae?.agent_id??null,republished:Qe,orgName:p?oe:null,localPolicies:ae?.local_link_receipt?Ea(ae)?"complete":"pending":z?"pending":null};d(Ke),ae&&l?.(ae,Ke.republished)}catch(K){b($t(K)?{code:K.code,message:K.message,details:K.details}:{message:qt(K,"The agent could not be published. Try again.")})}},We=m=>{switch(m){case"focus-name":b(null),requestAnimationFrame(()=>{v.current?.focus(),v.current?.select()});break;case"update-listing":{const q=j?.details?.existing_agent_id??_?.hubAgentId;q&&(n(),I(`/agent-hub/${q}`));break}case"install-builtin":{const q=j?.details?.builtin_name??He.builtinName;q&&(n(),I(`/agents?kind=agent&name=${encodeURIComponent(q)}`));break}case"edit-instructions":case"edit-agent":a&&(n(),I(`/agents/${a.id}`));break;case"publish-as-new":a&&qe.getState().forget(a.id),Ne({asNewListing:!0});break;case"sign-in":f(!0);break;case"refresh-hub":n(),I("/agent-hub");break;case"retry":Ne();break}},Q=a?.name??"",jt=c?c.orgName?`Published "${Q}" to ${c.orgName}`:c.republished?`Updated the Agent hub listing for "${Q}"`:`Published "${Q}" to the Agent hub`:p?`Publish "${Q}" to ${oe}?`:_?`Update the Agent hub listing for "${Q}"?`:`Publish "${Q}" to the Agent hub?`;o.useLayoutEffect(()=>{!j&&!c||S.current?.focus()},[j,c]);const kt=c?e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Close"}),c.hubAgentId&&e.jsx(fe,{onClick:()=>{n(),I(`/agent-hub/${c.hubAgentId}`)},children:"Open the listing"})]}):R?e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Close"}),R.actions.map((m,q)=>q===0?e.jsx(fe,{onClick:()=>We(m),disabled:te,children:Je[m]},m):e.jsx(ne,{onClick:()=>We(m),disabled:te,children:Je[m]},m))]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Cancel"}),ee.some(m=>m.field!=="name")&&e.jsx(ne,{onClick:()=>{a&&(n(),I(`/agents/${a.id}`))},children:"Edit the agent"}),i&&e.jsx(fe,{"data-testid":"publish-submit",onClick:()=>void Ne(),disabled:p&&!B||!u||ee.length>0||!h.trim()||te||z&&(!W.isSuccess||!!M||!!V),children:te?"Publishing…":_&&!p?"Update listing":"Publish"})]});return e.jsx(st,{open:t,onClose:n,title:jt,maxWidth:"sm",fullWidth:!0,actions:kt,dataTourTag:"upload-agent-dialog",dialogProps:{className:"outline-none"},children:e.jsxs("div",{ref:S,tabIndex:j||c?-1:void 0,className:Y("flex flex-col gap-4",(j||c)&&"outline-none"),children:[i?c?e.jsxs(_e,{variant:"success","aria-live":"polite",children:[e.jsx(Se,{children:c.orgName?`Published to ${c.orgName}`:c.republished?"Listing updated":"Published to the hub"}),e.jsx(le,{children:c.orgName?`"${c.name}" is in ${c.orgName}'s shared agents as an instruction set. Its members can read and install it; nobody outside the organization can.`:c.republished?`The hub now holds the current instruction set of "${c.name}".`:`"${c.name}" is on the hub as an instruction set. Anyone can read and install it.`}),e.jsx(le,{className:"text-ink-muted",children:"Nothing else left this machine: no conversation, no execution history, no memory, no plan and no machine-specific configuration."})]}):R&&j?e.jsxs(_e,{variant:R.variant,role:"alert",children:[e.jsx(Se,{children:R.headline}),e.jsx(le,{children:R.body}),R.note&&e.jsx(le,{className:"text-ink-muted",children:R.note})]}):null:e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx("p",{className:"text-body text-ink",children:"You need to be signed in to Radient to publish agents to the Agent hub."}),e.jsx(Ye,{titleText:"Sign in to continue",descriptionText:"",onSignInSuccess:r})]}),R&&y&&e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx("p",{className:"text-body text-ink",children:"Sign in to Radient again to replace the credential the hub refused."}),e.jsx(Ye,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{f(!1),b(null),r?.()}})]}),c?.localPolicies==="pending"&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.skills.policy_pending")}),!c&&z&&e.jsx("div",{className:"flex flex-col gap-3",children:W.isLoading?e.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.loading")}):W.error?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.links.load_failed")}):M?e.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.subscriptions.source_separation",{currentSource:fa(M),newSource:he})}):V?e.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.links.source_unavailable")}):D?e.jsx(ya,{link:D}):e.jsx(La,{value:C,onChange:L,source:he,item:h||Q,visibility:p?"org":"public",organization:p?oe:null,destinationKey:`${$}:${a?.id??""}`,canEnableAutoPush:!1,disabled:te||!W.isSuccess})}),!c&&!R&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-body text-ink",children:p?`You are about to publish this agent's instruction set into ${oe}, where only its members can read and install it. What is published is what describes the agent:`:"You are about to publish this agent's instruction set to the public Agent hub. What is published is what describes the agent:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5 text-body text-ink-muted",children:[e.jsx("li",{children:"Its name and description"}),e.jsx("li",{children:"Its instructions"}),e.jsx("li",{children:"Its tool surface, effort and delegation, when it has them"})]}),e.jsx("p",{className:"text-body text-ink",children:p?`Nothing else leaves this machine: no conversation, no execution history, no memory or learnings, no plan, and no machine-specific configuration. ${oe}'s members can read and install what you publish; nobody outside it can.`:"Nothing else leaves this machine: no conversation, no execution history, no memory or learnings, no plan, and no machine-specific configuration. Anyone can read and install what you publish."}),Z.length>0||J.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ye,{htmlFor:`${pe}-target`,children:"Publish to"}),e.jsxs(Yt,{value:$,onValueChange:m=>{me(m),L(De()),g.current=null},children:[e.jsx(Ft,{id:`${pe}-target`,className:"w-full","data-testid":"publish-target",children:e.jsx(Jt,{})}),e.jsxs(Xt,{children:[e.jsx(Ie,{value:be,children:"Public hub"}),Z.map(m=>e.jsx(Ie,{value:m.tenant_id,children:m.tenant_name||"Organization"},m.tenant_id)),J.map(m=>e.jsxs(Ie,{value:m.tenant_id,disabled:!0,children:[m.tenant_name||"Organization"," (upgrade needed)"]},m.tenant_id))]})]}),e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-hint",children:J.length>0?`Sharing agents inside an organization is part of the Team plan. An owner of ${J.length===1?J[0].tenant_name||"this organization":"any of the organizations marked above"} can activate it in the Radient console.`:"Public hub publications are readable by anyone. An organization's agents are readable by its members only."})]}):de?e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-unavailable",children:de}):we?e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-failed",children:"Your organizations could not be read, so this publishes to the public hub. Try again in a moment to publish into an organization."}):null,ee.length>0&&e.jsxs(_e,{variant:"danger",children:[e.jsx(Se,{children:"This agent cannot be published yet"}),e.jsx("ul",{className:"list-disc space-y-1 pl-5",children:ee.map(m=>e.jsx("li",{children:m.message},`${m.field}:${m.message}`))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ye,{htmlFor:ge,children:"Name on the hub"}),e.jsx(dt,{id:ge,ref:v,value:h,onChange:m=>k(m.target.value),autoComplete:"off",spellCheck:!1,"aria-invalid":ee.some(m=>m.field==="name"),"aria-describedby":`${ge}-hint`}),e.jsx("p",{id:`${ge}-hint`,className:"text-meta text-ink-muted",children:'No "/", "\\" or ":". Up to 128 characters.'}),!p&&xs(He)]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-5 shrink-0 items-center",children:e.jsx(Zt,{id:pe,name:"termsAgreement","data-testid":"publish-consent",checked:u,onCheckedChange:m=>x(m===!0)})}),e.jsxs(ye,{htmlFor:pe,className:"block font-normal text-body text-ink",children:["I confirm that I have read and agree to the"," ",e.jsx("a",{href:"https://radienthq.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline-offset-4 hover:text-accent-hover hover:underline",children:"terms and conditions"})," ","and that this agent does not contain malicious content or violate usage policies."]})]})]}),(c||R)&&Q&&e.jsxs("p",{className:"text-meta text-ink-muted",children:["Agent: ",Q]})]})})},xs=t=>{switch(t.state){case"checking":return e.jsx("p",{className:"text-meta text-ink-muted",children:"Checking whether this name is free…"});case"available":return e.jsx("p",{className:"text-meta text-ink-muted",children:"This name looks free."});case"taken":return e.jsx("p",{className:"text-meta text-ink",children:"This name is already published on the hub."});case"reserved":return e.jsx("p",{className:"text-meta text-ink-muted",children:t.builtinName?`The hub reserves "${t.builtinName}" for one of its built-in agents.`:"The hub reserves this name for one of its built-in agents."});default:return null}},bs=1200,fs=({agent:t,isSelected:n,onSelectAgent:a,onChatWithAgent:i,onExportAgent:r,onAgentDeleted:l,onUploadAgentToHub:u})=>{U();const x=t.description||s("ui.agents.navigation.sidebar.no_description");return e.jsxs("li",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:()=>a(t),"aria-current":n?"true":void 0,"data-tour-tag":"agent-list-item-button",className:Y("flex w-full items-center gap-2 rounded-sm py-1.5 pr-9 pl-2 text-left","transition-colors duration-fast ease-out-quart",n?ja:"hover:bg-row-hover"),children:[e.jsx(ta,{className:"size-8 shrink-0",children:e.jsx(aa,{className:"border border-control bg-sunken",children:e.jsx(Re,{size:16,"aria-hidden":!0})})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx(H,{content:t.name,side:"top",align:"start",children:e.jsx("span",{className:"block truncate font-medium text-body-sm text-ink",children:t.name})}),e.jsx(H,{content:x,side:"bottom",align:"start",children:e.jsx("span",{className:"block truncate text-meta text-ink-dim",children:x})})]})]}),e.jsx("div",{className:Y("pointer-events-none absolute top-0 right-1 flex h-full items-center","opacity-0 transition-opacity duration-fast ease-out-quart","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),children:e.jsx(H,{content:s("ui.agents.navigation.sidebar.options"),children:e.jsx("span",{children:e.jsx(Ja,{agentId:t.id,agentName:t.name,isAgentsPage:!0,onAgentDeleted:()=>l(t.id),onChatWithAgent:()=>i(t),onExportAgent:()=>r(t.id),onUploadAgentToHub:()=>u(t),buttonSx:{width:24,height:24,borderRadius:"6px",display:"flex",justifyContent:"center",alignItems:"center"}})})})})]})},ys=(t,n)=>t.isSelected===n.isSelected&&t.agent.id===n.agent.id&&t.agent.name===n.agent.name&&t.agent.description===n.agent.description&&t.onSelectAgent===n.onSelectAgent&&t.onChatWithAgent===n.onChatWithAgent&&t.onExportAgent===n.onExportAgent&&t.onAgentDeleted===n.onAgentDeleted&&t.onUploadAgentToHub===n.onUploadAgentToHub,_s=o.memo(fs,ys),js=({selectedAgentId:t,onSelectAgent:n})=>{const a=ze();U();const[i,r]=o.useState(""),l=Ia(p=>p.openCreateAgentDialog),u=ht(i.trim(),250),[x,h]=o.useState(!1),k=50,[j,b]=o.useState(!1),[c,d]=o.useState(null),{isAuthenticated:y}=nt(),f=o.useMemo(()=>Ue(X.baseUrl),[]),v=pt(),{page:S,setPage:I}=es(),{data:P,isLoading:C,isError:L,refetch:g}=_a(S,k,0,u||void 0,"created_date","desc"),w=P?.agents||[],_=P?.total||0,{data:E}=gt(t&&!w.find(p=>p.id===t)?t:void 0),z=o.useMemo(()=>{const p=[...w];return E&&!p.find(O=>O.id===E.id)&&p.push(E),p.sort((O,D)=>new Date(D.created_date).getTime()-new Date(O.created_date).getTime()),p},[w,E]),W=o.useCallback(p=>{I(p)},[I]),ke=o.useCallback(p=>{n(p)},[n]),ue=o.useCallback(()=>{h(!0)},[]),ve=o.useCallback(()=>{h(!1)},[]),de=o.useCallback(async p=>{try{const O=await v.mutateAsync(p),D=z.find(he=>he.id===p),M=D?D.name.replace(/\s+/g,"-").toLowerCase():p,V=URL.createObjectURL(O),B=document.createElement("a");B.href=V,B.download=`${M}-export.zip`,document.body.appendChild(B),B.click(),URL.revokeObjectURL(V),document.body.removeChild(B)}catch(O){console.error("Failed to export agent:",O)}},[z,v]),F=o.useCallback(p=>{d(p),b(!0)},[]),we=o.useCallback(()=>{b(!1),d(null)},[]),Z=o.useCallback(async p=>{try{const D=((await g()).data?.agents||[]).find(V=>V.id===p);if(D){n(D);return}const M=await f.agents.getAgent(p);M.status<400&&M.result&&n(M.result)}catch(O){console.error("Error selecting newly created agent:",O)}},[n,g,f]),J=o.useCallback(p=>{it.getState().stageDraft({kind:"agent",name:p.name}),a("/chat")},[a]),$=o.useCallback(p=>{g(),a("/agents")},[t,g,a]),me=o.useCallback(p=>{F(p)},[F]);return e.jsxs("div",{"data-glass-region":"page-sidebar",className:"flex h-full w-full flex-col overflow-hidden bg-surface",children:[e.jsx(as,{title:s("ui.agents.navigation.sidebar.title"),searchQuery:i,onSearchChange:p=>r(p),onNewAgentClick:l,onImportAgentClick:ue,importAgentTooltip:s("ui.agents.navigation.sidebar.import_hint")}),C?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(ut,{size:"lg",label:s("ui.agents.navigation.sidebar.loading")})}):L?e.jsxs(_e,{variant:"danger",role:"alert",className:"m-4 w-auto",children:[e.jsx(le,{children:s("ui.agents.navigation.sidebar.error")}),e.jsx(T,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>g(),children:s("ui.agents.navigation.sidebar.retry")})]}):z.length===0&&!C?e.jsx("p",{className:"p-6 text-center text-body-sm text-ink-muted",children:i?s("ui.agents.navigation.sidebar.search_empty"):s("ui.agents.navigation.sidebar.empty")}):e.jsx(ea,{delayDuration:bs,skipDelayDuration:0,children:e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-2",children:z.map(p=>e.jsx(_s,{agent:p,isSelected:t===p.id||E?.id===p.id,onSelectAgent:ke,onChatWithAgent:J,onExportAgent:de,onAgentDeleted:$,onUploadAgentToHub:me},p.id))})}),e.jsx(ts,{open:x,onClose:ve,onAgentImported:Z}),_>0&&e.jsx(Xa,{page:S,count:Math.max(1,Math.ceil(_/k)),onChange:W}),e.jsx(yt,{open:j,onClose:we,agent:c,isAuthenticated:y})]})},ks=o.memo(js),Rs=()=>{U();const t=Mt("surface"),{agentId:n,navigateToAgent:a}=ka(),i=ze(),{isAuthenticated:r}=nt(),[l,u]=o.useState(!1),x=pt(),{setLastAgentsPageAgentId:h,getLastAgentId:k}=Ze(),j=n||k("agents"),{data:b,refetch:c}=gt(j||void 0);o.useEffect(()=>{n&&h(n)},[n,h]);const d=async()=>{if(b)try{const S=await x.mutateAsync(b.id),I=URL.createObjectURL(S),P=document.createElement("a");P.href=I,P.download=`${b.name.replace(/\s+/g,"-").toLowerCase()}-lo-agent.zip`,document.body.appendChild(P),P.click(),URL.revokeObjectURL(I),document.body.removeChild(P)}catch(S){console.error("Failed to export agent:",S)}},y=()=>{u(!0)},f=()=>{u(!1)},v=S=>{h(S.id),a(S.id,"agents")};return e.jsxs("div",{"data-glass-split":"",className:"flex h-full w-full overflow-hidden",children:[e.jsx("div",{ref:t,className:"h-full w-70 shrink-0",children:e.jsx(ks,{selectedAgentId:b?.id,onSelectAgent:v})}),e.jsx("div",{"data-glass-region":"canvas-content",className:"h-full grow overflow-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-8 p-4 sm:p-6 lg:p-8",children:[e.jsx("div",{className:"mx-auto w-full max-w-4xl",children:e.jsx(Ht,{title:s("ui.agents.navigation.legacy.title"),icon:Re,subtitle:s("ui.agents.navigation.legacy.subtitle"),children:b&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(rt,{children:[e.jsx(ot,{asChild:!0,children:e.jsx(T,{"data-tour-tag":"upload-to-hub-header-button",variant:"secondary",size:"icon","aria-label":s("ui.agents.navigation.legacy.more_actions"),className:"@min-[400px]:hidden",children:e.jsx(Bt,{"aria-hidden":"true"})})}),e.jsxs(lt,{align:"end",className:"min-w-45",children:[e.jsxs(G,{disabled:x.isPending,onSelect:d,children:[e.jsx(Ge,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.navigation.legacy.export")})]}),e.jsxs(G,{onSelect:y,children:[e.jsx(Oe,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.navigation.legacy.upload")})]})]})]}),e.jsxs(T,{variant:"secondary",onClick:d,disabled:x.isPending,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(Ge,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.export")]}),e.jsxs(T,{"data-tour-tag":"upload-to-hub-header-button","data-tour-action":"open-upload-dialog",variant:"secondary",onClick:y,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(Oe,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.upload")]}),e.jsx(H,{content:s("ui.agents.navigation.legacy.chat_named",{name:b.name||s("ui.agents.navigation.legacy.unnamed_agent")}),children:e.jsxs(T,{variant:"primary",onClick:()=>{it.getState().stageDraft({kind:"agent",name:b.name}),i("/chat")},children:[e.jsx(mt,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.chat")]})})]})})}),e.jsx("div",{className:"min-h-0 grow overflow-hidden",children:e.jsx(ls,{selectedAgent:b??null,refetchAgent:c,initialSelectedAgentId:n})})]})}),b&&e.jsx(yt,{open:l,onClose:f,agent:b,isAuthenticated:r})]})};export{Rs as LegacyAgentsPage};
|