local-operator-ui 0.15.2 → 0.17.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.
Files changed (74) hide show
  1. package/out/main/index.js +199 -29
  2. package/out/preload/index.js +6 -0
  3. package/out/renderer/assets/{_basePickBy-CefSvQ3Q.js → _basePickBy-BJr_fQtB.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-DlDqTbuA.js → _baseUniq-CYir-14_.js} +1 -1
  5. package/out/renderer/assets/{agent-details-page-BCuUg55n.js → agent-details-page-D6PQzszA.js} +7 -2
  6. package/out/renderer/assets/{agent-hub-page-BqCCuxo-.js → agent-hub-page-BU8BMGm-.js} +3 -3
  7. package/out/renderer/assets/agents-page-3jWcFYcZ.js +2 -0
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CUlo4ACF.js → architectureDiagram-IEHRJDOE-CCErX8Tf.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-nU3IOM88.js → blockDiagram-JOT3LUYC-CUvjtfSj.js} +1 -1
  10. package/out/renderer/assets/{c4Diagram-VJAJSXHY-MT0nxa4-.js → c4Diagram-VJAJSXHY-VeJwMCKK.js} +1 -1
  11. package/out/renderer/assets/channel-BtWQQlRJ.js +1 -0
  12. package/out/renderer/assets/{chunk-4BMEZGHF-CXkPsNEi.js → chunk-4BMEZGHF-3Bq4xtvZ.js} +1 -1
  13. package/out/renderer/assets/{chunk-A2AXSNBT-DiTT6jkA.js → chunk-A2AXSNBT-B3y7xV7i.js} +1 -1
  14. package/out/renderer/assets/{chunk-AEK57VVT-CIZ7-t01.js → chunk-AEK57VVT-EVfEpH4f.js} +1 -1
  15. package/out/renderer/assets/{chunk-D6G4REZN-BIKuFzEX.js → chunk-D6G4REZN-DMvU3WoU.js} +1 -1
  16. package/out/renderer/assets/{chunk-RZ5BOZE2-byZRPh67.js → chunk-RZ5BOZE2-IvUVaxD4.js} +1 -1
  17. package/out/renderer/assets/{chunk-XZIHB7SX-BM-t-ERh.js → chunk-XZIHB7SX-qRGLrBmi.js} +1 -1
  18. package/out/renderer/assets/classDiagram-GIVACNV2-C298zC-3.js +1 -0
  19. package/out/renderer/assets/classDiagram-v2-COTLJTTW-C298zC-3.js +1 -0
  20. package/out/renderer/assets/clone-dCQCshht.js +1 -0
  21. package/out/renderer/assets/compact-pagination-C9MHaQh8.js +1 -0
  22. package/out/renderer/assets/{dagre-OKDRZEBW-DU9huU8P.js → dagre-OKDRZEBW-mkOM0foV.js} +1 -1
  23. package/out/renderer/assets/{diagram-SSKATNLV-C6KmXMQc.js → diagram-SSKATNLV-nPhdvd43.js} +1 -1
  24. package/out/renderer/assets/{diagram-VNBRO52H-B2c-8R3S.js → diagram-VNBRO52H-DwSuRePG.js} +1 -1
  25. package/out/renderer/assets/{erDiagram-Q7BY3M3F-D6QA70K4.js → erDiagram-Q7BY3M3F-H_hDC8d0.js} +1 -1
  26. package/out/renderer/assets/{flowDiagram-4HSFHLVR-Dk0lRNK2.js → flowDiagram-4HSFHLVR-COn1sttR.js} +1 -1
  27. package/out/renderer/assets/{ganttDiagram-APWFNJXF-BevHed3v.js → ganttDiagram-APWFNJXF-DbxYzA4C.js} +1 -1
  28. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-CmOfsj5i.js → gitGraphDiagram-7IBYFJ6S-GJA88tpY.js} +1 -1
  29. package/out/renderer/assets/{graph-CUJVKfm_.js → graph-CDkZGsbw.js} +1 -1
  30. package/out/renderer/assets/{icon-BIaTDBQz.js → icon-D9xnujmI.js} +32 -27
  31. package/out/renderer/assets/icon-DM6KYqqV.css +1 -0
  32. package/out/renderer/assets/{index-DZnGa8Vt.js → index-CVSo1eIn.js} +317 -314
  33. package/out/renderer/assets/{index-Eh3n7DJx.js → index-Coj74S4F.js} +1 -1
  34. package/out/renderer/assets/{index-8mt-yi7u.js → index-DyRL2cJn.js} +1 -1
  35. package/out/renderer/assets/index-aW0Bo_1a.css +1 -0
  36. package/out/renderer/assets/{infoDiagram-PH2N3AL5-DWdIO3pN.js → infoDiagram-PH2N3AL5-DCDmAfuD.js} +1 -1
  37. package/out/renderer/assets/installer-JsKFFZ0N.js +16 -0
  38. package/out/renderer/assets/{journeyDiagram-U35MCT3I-BNOCDq91.js → journeyDiagram-U35MCT3I-D5zuKm0h.js} +1 -1
  39. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CIVzZzmM.js → kanban-definition-NDS4AKOZ-D28NqnN2.js} +1 -1
  40. package/out/renderer/assets/{layout-zNSVRDKv.js → layout-B__Skqp8.js} +1 -1
  41. package/out/renderer/assets/legacy-agents-page-d_nYp_Kx.js +43 -0
  42. package/out/renderer/assets/{mermaid.core-CFY9BM3R.js → mermaid.core-BHfHBA6R.js} +5 -5
  43. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-yS5L1WQ2.js → mindmap-definition-ALO5MXBD-DKRrQTAb.js} +1 -1
  44. package/out/renderer/assets/{page-header-GWjqQg3-.js → page-header-JYwkpfbT.js} +1 -1
  45. package/out/renderer/assets/{parseISO-DIyaQXAe.js → parseISO-D2eiqdi5.js} +2 -2
  46. package/out/renderer/assets/{pieDiagram-IB7DONF6-BPWYAs8_.js → pieDiagram-IB7DONF6-B1BtzilZ.js} +1 -1
  47. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-B82PFOoq.js → quadrantDiagram-7GDLP6J5-2ZnW_kzE.js} +1 -1
  48. package/out/renderer/assets/{radar-MK3ICKWK-Z4U7o29x.js → radar-MK3ICKWK-BxdSoZJX.js} +1 -1
  49. package/out/renderer/assets/radient-auth-buttons-Bi1-KXYI.js +6 -0
  50. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BwhazqTR.js → requirementDiagram-KVF5MWMF-6W-9ZOiF.js} +1 -1
  51. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-Cg4M6UvE.js → sankeyDiagram-QLVOVGJD-DsCO-xHN.js} +1 -1
  52. package/out/renderer/assets/{schedules-page-ChiypWrp.js → schedules-page-BGkrdg_o.js} +1 -1
  53. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-hTniLZHQ.js → sequenceDiagram-X6HHIX6F-DTsOsVHj.js} +1 -1
  54. package/out/renderer/assets/{settings-page-CKzoAptg.js → settings-page-UqW8Dofa.js} +2 -2
  55. package/out/renderer/assets/{square-pen-sK57wlY1.js → square-pen-DOIqaj9i.js} +2 -2
  56. package/out/renderer/assets/{stateDiagram-DGXRK772-DI0pBdbL.js → stateDiagram-DGXRK772-Hgu5z66Y.js} +1 -1
  57. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-BrBwSEFe.js +1 -0
  58. package/out/renderer/assets/{timeline-definition-BDJGKUSR-t0KbQhGu.js → timeline-definition-BDJGKUSR-BkaQadIG.js} +1 -1
  59. package/out/renderer/assets/use-agent-like-mutation-BSrvgpki.js +1 -0
  60. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-BQjVqv5u.js → xychartDiagram-VJFVF3MP-DuWwCccB.js} +1 -1
  61. package/out/renderer/index.html +21 -6
  62. package/out/renderer/installer.html +3 -3
  63. package/package.json +2 -2
  64. package/out/renderer/assets/agents-page-DG4vCZu3.js +0 -18
  65. package/out/renderer/assets/channel-CCadi6VR.js +0 -1
  66. package/out/renderer/assets/classDiagram-GIVACNV2-Bkvtrmw4.js +0 -1
  67. package/out/renderer/assets/classDiagram-v2-COTLJTTW-Bkvtrmw4.js +0 -1
  68. package/out/renderer/assets/clone-DTDvO4Il.js +0 -1
  69. package/out/renderer/assets/icon-CtRkDz9c.css +0 -1
  70. package/out/renderer/assets/index-DikLkf3S.css +0 -1
  71. package/out/renderer/assets/installer-DYZ22Cfq.js +0 -21
  72. package/out/renderer/assets/settings-section-yqdH5CNp.js +0 -6
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CG5hsBHO.js +0 -1
  74. package/out/renderer/assets/use-agent-like-mutation-C_nJtNuz.js +0 -1
@@ -0,0 +1,43 @@
1
+ import{a as R,r as l,j as e,n as ce,o as de,B as D,p as ue,q as O,c as P,S as pe,g as T,I as Me,s as ze,C as $e,t as Q,L as F,u as me,X as he,P as Ve,v as He,w as Be,A as xe,x as We,y as Ke,z as Ge,F as Qe,d as Ye,e as Ze}from"./icon-D9xnujmI.js";import{P as Je}from"./page-header-JYwkpfbT.js";import{as as Xe,at as fe,au as ye,av as X,aw as A,ax as Ae,a8 as Fe,ay as oe,az as et,g as tt,f as at,aA as ee,aB as te,M as st,a2 as nt,aC as it,a1 as B,a as ot,aD as rt,aE as lt,al as ge,am as ct,an as dt,P as be,aF as ut,aG as M,aH as z,aI as pt,aJ as mt,aK as ht,aL as xt,ak as ft,aM as yt,aN as gt,B as ae,h as je,aO as bt,aP as jt,J as ke,aQ as we,aR as kt,aS as ve,aT as wt,aU as vt,aV as Ct,aW as re}from"./index-CVSo1eIn.js";import{I as Nt,a as Z,N as _t,R as Dt}from"./radient-auth-buttons-Bi1-KXYI.js";import{C as It}from"./compact-pagination-C9MHaQh8.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 St=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Et=R("calendar",St);/**
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 Pt=[["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"}]],Tt=R("ellipsis-vertical",Pt);/**
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 Lt=[["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"}]],le=R("file-input",Lt);/**
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 Ut=[["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"}]],qt=R("file-output",Ut);/**
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 Ot=[["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"}]],Rt=R("git-branch",Ot);/**
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 Mt=[["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"}]],zt=R("id-card",Mt);/**
32
+ * @license lucide-react v0.507.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const $t=[["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"}]],Vt=R("import",$t);/**
37
+ * @license lucide-react v0.507.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Ht=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],Bt=R("upload",Ht),Wt=({agentId:t,agentName:i,onAgentDeleted:a,buttonSx:n={},isAgentsPage:s=!1,onViewAgentSettings:o,onChatWithAgent:r,onExportAgent:h,onClearConversation:p,onUploadAgentToHub:y})=>{const[b,j]=l.useState(!1),[d,c]=l.useState(!1),[u,f]=l.useState(!1),N=l.useRef(!1),I=Xe(),{clearAgentFromAllPages:S}=fe(),E=async()=>{try{await I.mutateAsync(t),S(t),a?.(t)}catch(C){console.error("Failed to delete agent:",C)}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(ce,{open:b,onOpenChange:j,modal:!1,children:[e.jsx(de,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"agent options","data-tour-tag":"agent-options-button",onClick:C=>{C.stopPropagation(),C.detail===0&&j(k=>!k)},style:n,children:e.jsx(Tt,{"aria-hidden":"true"})})}),e.jsxs(ue,{align:"end",className:"min-w-45",onClick:C=>C.stopPropagation(),onInteractOutside:C=>{const k=C.detail.originalEvent.target;k instanceof Element&&k.closest(".shepherd-element")&&C.preventDefault()},onCloseAutoFocus:C=>{N.current&&(N.current=!1,C.preventDefault())},children:[s&&r&&e.jsxs(O,{onSelect:r,children:[e.jsx(ye,{"aria-hidden":"true"}),e.jsx("span",{children:"Chat with agent"})]}),!s&&o&&e.jsxs(O,{"data-tour-tag":"view-agent-settings-menu-item",onSelect:o,children:[e.jsx(X,{"aria-hidden":"true"}),e.jsx("span",{children:"View agent settings"})]}),h&&e.jsxs(O,{onSelect:h,children:[e.jsx(qt,{"aria-hidden":"true"}),e.jsx("span",{children:"Export agent"})]}),y&&e.jsxs(O,{"data-tour-tag":"upload-to-hub-menu-item",onSelect:y,children:[e.jsx(A,{"aria-hidden":"true"}),e.jsx("span",{children:"Upload to hub"})]}),p&&e.jsxs(O,{className:"text-warning data-[highlighted]:bg-warning-wash",onSelect:()=>{N.current=!0,f(!0)},children:[e.jsx(Ae,{"aria-hidden":"true"}),e.jsx("span",{children:"Clear conversation"})]}),e.jsxs(O,{destructive:!0,onSelect:()=>{N.current=!0,c(!0)},children:[e.jsx(Fe,{"aria-hidden":"true"}),e.jsx("span",{children:"Delete agent"})]})]})]}),e.jsx(oe,{open:d,title:"Delete agent",message:e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-body text-ink",children:['Are you sure you want to delete the agent "',i,'"?']}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:"This action cannot be undone. All conversations with this agent will be permanently deleted."})]}),confirmText:"Delete",cancelText:"Cancel",isDangerous:!0,onConfirm:E,onCancel:()=>c(!1)}),e.jsx(oe,{open:u,title:"Clear this conversation?",message:"Every message in it is deleted from this computer, and there is no undo. The agent itself is not affected.",confirmText:"Clear",cancelText:"Cancel",isDangerous:!0,onConfirm:()=>{p?.(),f(!1)},onCancel:()=>f(!1)})]})},Ce=t=>["agent-system-prompt",t],Kt=t=>{const{shouldEnableQuery:i}=et();return tt({enabled:i({bypassInternetCheck:!0})&&!!t,queryKey:Ce(t),queryFn:async()=>{try{const n=await ee(te.baseUrl).agents.getAgentSystemPrompt(t);if(n.status>=400)throw new Error(n.message||"Failed to fetch agent system prompt");return n.result?.system_prompt||""}catch(a){const n=a instanceof Error?a.message:"An unknown error occurred while fetching agent system prompt";throw B(n),a}},refetchOnWindowFocus:!1,staleTime:5e3})},Gt=t=>{const i=at(),a=ee(te.baseUrl);return st({mutationFn:async n=>{const s=it(n);if(s)throw B(s),new Error(s);try{const o=await a.agents.updateAgentSystemPrompt(t,n);if(o.status>=400)throw new Error(o.message||"Failed to update agent system prompt");return o}catch(o){const r=o instanceof Error?o.message:"An unknown error occurred while updating agent system prompt";throw B(r),o}},onSuccess:async()=>{await i.invalidateQueries({queryKey:Ce(t)}),nt("Agent system prompt updated")},onError:n=>{console.error("Error updating agent system prompt:",n)}})},Qt=()=>{const[t,i]=ot(),a=rt(),n=()=>{const o=t.get("page");return o?Number.parseInt(o,10):1},s=o=>{const r=new URLSearchParams(t);o===1?r.delete("page"):r.set("page",o.toString()),i(r)};return{page:n(),setPage:s,isView:o=>a.pathname.startsWith(`/${o}`)}},Yt=({open:t,onClose:i,onAgentImported:a})=>{const[n,s]=l.useState(null),[o,r]=l.useState(!1),[h,p]=l.useState(null),y=l.useRef(null),b=lt(),j=l.useCallback(g=>{g.preventDefault(),g.stopPropagation(),r(!0)},[]),d=l.useCallback(g=>{g.preventDefault(),g.stopPropagation(),r(!1)},[]),c=l.useCallback(g=>{g.preventDefault(),g.stopPropagation()},[]),u=l.useCallback(g=>g.name.toLowerCase().endsWith(".zip")?(p(null),!0):(p("Only ZIP files are supported"),!1),[]),f=l.useCallback(g=>{if(g.preventDefault(),g.stopPropagation(),r(!1),g.dataTransfer.files&&g.dataTransfer.files.length>0){const L=g.dataTransfer.files[0];u(L)&&s(L)}},[u]),N=l.useCallback(g=>{if(g.target.files&&g.target.files.length>0){const L=g.target.files[0];u(L)&&s(L)}},[u]),I=l.useCallback(()=>{y.current?.click()},[]),S=async()=>{if(n)try{const g=await b.mutateAsync(n);s(null),p(null),a&&g&&a(g.id),i()}catch(g){console.error("Failed to import agent:",g)}},E=()=>{s(null),p(null),i()},C=b.isPending,k=C||!n,m=e.jsxs(e.Fragment,{children:[e.jsx(le,{size:19,className:"text-accent","aria-hidden":"true"}),"Import agent"]}),w=e.jsxs(e.Fragment,{children:[e.jsx(ct,{onClick:E,disabled:C,children:"Cancel"}),e.jsx(dt,{onClick:S,disabled:k,startIcon:C?e.jsx(pe,{}):null,children:"Import agent"})]});return e.jsxs(ge,{open:t,onClose:E,title:m,actions:w,maxWidth:"sm",children:[e.jsx("p",{className:"mb-4 text-body-sm text-ink-muted",children:"Import an agent from a ZIP file exported from Local Operator. The file should contain an agent.yml file."}),e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx("input",{ref:y,type:"file",accept:".zip",onChange:N,disabled:C,className:"hidden"}),e.jsx("button",{type:"button",onClick:I,onDragEnter:j,onDragLeave:d,onDragOver:c,onDrop:f,disabled:C,className:P("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",o&&"border-accent bg-accent-wash"),children:n?e.jsxs(e.Fragment,{children:[e.jsx(le,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:n.name}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Click or drag to replace"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bt,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:"Drag and drop a ZIP file here"}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:"or click to select a file"})]})}),h&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:h})]})]})},Zt=({title:t,searchQuery:i,onSearchChange:a,onNewAgentClick:n,searchPlaceholder:s="Search agents",newAgentTooltip:o="Create a new agent",onImportAgentClick:r,importAgentTooltip:h="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:[r&&e.jsx(T,{content:h,children:e.jsx(D,{variant:"ghost",size:"icon",onClick:r,"aria-label":"Import agent",children:e.jsx(Vt,{"aria-hidden":"true"})})}),e.jsx(T,{content:o,children:e.jsx(D,{variant:"primary",size:"icon",onClick:n,"aria-label":"New agent","data-tour-tag":"create-new-agent-button",children:e.jsx(be,{"aria-hidden":"true"})})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ut,{size:16,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim"}),e.jsx(Me,{type:"search",inputSize:"lg",placeholder:s,value:i,onChange:p=>a(p.target.value),"aria-label":s,className:"pl-9"})]})]}),v={temperature:.2,top_p:.9,top_k:40,max_tokens:4096,frequency_penalty:0,presence_penalty:0,seed:42},q=({label:t,description:i,defaultLabel:a,onSet:n})=>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:"Not set yet"})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-dim",children:i})]}),e.jsxs(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:n,children:["Set to default (",a,")"]})]}),J=({title:t,children:i})=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h3",{className:"text-body-sm font-semibold text-ink-muted",children:t}),i]}),Jt=({selectedAgent:t,savingField:i,setSavingField:a,updateAgentMutation:n,refetchAgent:s,initialSelectedAgentId:o})=>{const[r,h]=l.useState(t);l.useEffect(()=>{h(t)},[t]);const[p,y]=l.useState(!1),b=l.useId(),j=p?ze:$e;return e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>y(!p),"aria-expanded":p,"aria-controls":b,className:"group flex items-center gap-2 py-1 text-left text-heading text-ink",children:[e.jsx(j,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink"}),"Advanced chat settings"]}),e.jsx(T,{content:"Advanced settings to change how the agent generates responses",children:e.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"About advanced chat settings",children:e.jsx(Q,{})})})]}),p&&e.jsxs("div",{id:b,className:"mt-3",children:[e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:"Set custom values for any of these options. Anything left unset uses a default optimized from user testing."}),e.jsxs("div",{className:"mt-6 flex flex-col gap-8",children:[e.jsxs(J,{title:"Sampling",children:[r.temperature===null?e.jsx(q,{label:"Temperature",description:"Controls randomness in responses (0.0-1.0). Higher values make output more random.",defaultLabel:v.temperature,onSet:async()=>{a("temperature");try{const d={temperature:v.temperature};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,temperature:v.temperature})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(M,{value:r.temperature??v.temperature,label:"Temperature",description:"Controls randomness in responses (0.0-1.0). Higher values make output more random.",min:0,max:1,step:.01,isSaving:i==="temperature",onChange:async d=>{a("temperature");try{const c={temperature:d};await n.mutateAsync({agentId:t.id,update:c}),t.id===o&&s&&await s()}catch{}finally{a(null)}}}),r.top_p===null?e.jsx(q,{label:"Top P",description:"Controls cumulative probability of tokens to sample from (0.0-1.0).",defaultLabel:v.top_p,onSet:async()=>{a("top_p");try{const d={top_p:v.top_p};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,top_p:v.top_p})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(M,{value:r.top_p??v.top_p,label:"Top P",description:"Controls cumulative probability of tokens to sample from (0.0-1.0).",min:0,max:1,step:.01,isSaving:i==="top_p",onChange:async d=>{a("top_p");try{const c={top_p:d};await n.mutateAsync({agentId:t.id,update:c}),t.id===o&&s&&await s()}catch{}finally{a(null)}}}),r.top_k===null?e.jsx(q,{label:"Top K",description:"Limits tokens to sample from at each step.",defaultLabel:v.top_k,onSet:async()=>{a("top_k");try{const d={top_k:v.top_k};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,top_k:v.top_k})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(M,{value:r.top_k??v.top_k,label:"Top K",description:"Limits tokens to sample from at each step.",min:1,max:100,step:1,isSaving:i==="top_k",onChange:async d=>{a("top_k");try{const c={top_k:d};await n.mutateAsync({agentId:t.id,update:c}),t.id===o&&s&&await s()}catch{}finally{a(null)}}}),r.seed===null?e.jsx(q,{label:"Seed",description:"Random number seed for deterministic generation.",defaultLabel:v.seed,onSet:async()=>{a("seed");try{const d={seed:v.seed};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,seed:v.seed})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(z,{value:r.seed?.toString()||"",label:"Seed",placeholder:"Random number seed for deterministic generation",icon:e.jsx(X,{size:16}),isSaving:i==="seed",onSave:async d=>{a("seed");try{const c=d.trim()?Number.parseInt(d,10):void 0;if(d.trim()&&Number.isNaN(c)){B("Seed must be a valid number");return}const u={seed:c};await n.mutateAsync({agentId:t.id,update:u}),t.id===o&&s&&await s()}catch{}finally{a(null)}}})]}),e.jsxs(J,{title:"Repetition",children:[r.frequency_penalty===null?e.jsx(q,{label:"Frequency penalty",description:"Reduces repetition by lowering likelihood of repeated tokens (-2.0 to 2.0).",defaultLabel:v.frequency_penalty,onSet:async()=>{a("frequency_penalty");try{const d={frequency_penalty:v.frequency_penalty};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,frequency_penalty:v.frequency_penalty})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(M,{value:r.frequency_penalty??v.frequency_penalty,label:"Frequency penalty",description:"Reduces repetition by lowering likelihood of repeated tokens (-2.0 to 2.0).",min:-2,max:2,step:.01,isSaving:i==="frequency_penalty",onChange:async d=>{a("frequency_penalty");try{const c={frequency_penalty:d};await n.mutateAsync({agentId:t.id,update:c}),t.id===o&&s&&await s()}catch{}finally{a(null)}}}),r.presence_penalty===null?e.jsx(q,{label:"Presence penalty",description:"Increases diversity by lowering likelihood of prompt tokens (-2.0 to 2.0).",defaultLabel:v.presence_penalty,onSet:async()=>{a("presence_penalty");try{const d={presence_penalty:v.presence_penalty};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,presence_penalty:v.presence_penalty})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(M,{value:r.presence_penalty??v.presence_penalty,label:"Presence penalty",description:"Increases diversity by lowering likelihood of prompt tokens (-2.0 to 2.0).",min:-2,max:2,step:.01,isSaving:i==="presence_penalty",onChange:async d=>{a("presence_penalty");try{const c={presence_penalty:d};await n.mutateAsync({agentId:t.id,update:c}),t.id===o&&s&&await s()}catch{}finally{a(null)}}})]}),e.jsxs(J,{title:"Length and stopping",children:[r.max_tokens===null?e.jsx(q,{label:"Max tokens",description:"Maximum tokens to generate in response.",defaultLabel:v.max_tokens,onSet:async()=>{a("max_tokens");try{const d={max_tokens:v.max_tokens};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,max_tokens:v.max_tokens})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(M,{value:r.max_tokens??v.max_tokens,label:"Max tokens",description:"Maximum tokens to generate in response.",min:1,max:8192,step:1,isSaving:i==="max_tokens",onChange:async d=>{a("max_tokens");try{const c={max_tokens:d};await n.mutateAsync({agentId:t.id,update:c}),t.id===o&&s&&await s()}catch{}finally{a(null)}}}),r.stop===null?e.jsx(q,{label:"Stop sequences",description:"Sequences that will cause the model to stop generating text.",defaultLabel:"empty",onSet:async()=>{a("stop");try{const d={stop:[]};await n.mutateAsync({agentId:t.id,update:d}),h(c=>({...c,stop:[]})),t.id===o&&s&&await s()}catch{}finally{a(null)}}}):e.jsx(z,{value:r.stop?.join(`
42
+ `)||"",label:"Stop sequences",placeholder:"Enter stop sequences (one per line)...",icon:e.jsx(X,{size:16}),multiline:!0,rows:3,isSaving:i==="stop",onSave:async d=>{a("stop");try{const c=d.split(`
43
+ `).map(f=>f.trim()).filter(f=>f.length>0),u={stop:c.length>0?c:void 0};await n.mutateAsync({agentId:t.id,update:u}),t.id===o&&s&&await s()}catch{}finally{a(null)}}})]})]})]})]})},Ne=["investment","accounting","healthcare","legal","software","security","role_play","personal_assistance","education","marketing","sales","research","analysis","management","social_media","other"],G=Object.fromEntries(Ne.map(t=>[t,t.split("_").map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" ")])),Xt=({value:t,label:i,onChange:a,placeholder:n="Add category...",disabled:s=!1,icon:o})=>{const[r,h]=l.useState(""),[p,y]=l.useState(!1),[b,j]=l.useState(0),d=l.useRef(null),c=l.useRef([]),u=l.useId(),f=l.useId(),N=l.useMemo(()=>{const m=r.trim().toLowerCase();return Ne.filter(w=>!t.includes(w)&&(!m||G[w].toLowerCase().includes(m)))},[t,r]);l.useEffect(()=>{p&&c.current[b]?.scrollIntoView({block:"nearest"})},[b,p]);const I=m=>{t.includes(m)||a([...t,m]),h(""),y(!1),j(0),d.current?.focus()},S=m=>{h(m.target.value),j(0),y(!0)},E=m=>{const w=N.length;switch(m.key){case"ArrowDown":if(m.preventDefault(),w===0)break;p?j((b+1)%w):(j(0),y(!0));break;case"ArrowUp":if(m.preventDefault(),w===0)break;p?j((b-1+w)%w):(j(w-1),y(!0));break;case"Enter":p&&N[b]&&(m.preventDefault(),I(N[b]));break;case"Escape":p&&(m.preventDefault(),y(!1));break;case"Home":p&&(m.preventDefault(),j(0));break;case"End":p&&(m.preventDefault(),j(N.length-1));break}},C=m=>{a(t.filter(w=>w!==m)),j(0)},k=p&&N[b]?`${f}-option-${b}`:void 0;return e.jsxs("div",{children:[e.jsxs(F,{htmlFor:u,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[o,i]}),e.jsxs("div",{className:P("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",s&&"border-hairline bg-sunken"),children:[t.map(m=>e.jsxs(me,{className:"gap-1 pr-1 text-ink",children:[G[m]||m,e.jsx("button",{type:"button","aria-label":`Remove category ${G[m]||m}`,disabled:s,onClick:()=>C(m),className:P("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(he,{})})]},m)),e.jsxs(Ve,{open:p,onOpenChange:y,children:[e.jsx(He,{asChild:!0,children:e.jsx("input",{id:u,ref:d,type:"text",role:"combobox","aria-expanded":p,"aria-controls":f,"aria-autocomplete":"list","aria-activedescendant":k,autoComplete:"off",value:r,placeholder:n,disabled:s,"aria-label":i,onChange:S,onKeyDown:E,onClick:()=>{N.length>0&&y(!0)},className:P("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(Be,{align:"start",sideOffset:4,onOpenAutoFocus:m=>m.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":i,children:N.map((m,w)=>e.jsx("div",{id:`${f}-option-${w}`,ref:g=>{c.current[w]=g},role:"option","aria-selected":w===b,onMouseDown:g=>{g.preventDefault()},onMouseEnter:()=>j(w),onClick:()=>I(m),className:P("cursor-pointer rounded-sm px-3 py-1.5 font-medium text-body-sm",w===b?"bg-accent-wash":void 0,"text-ink"),children:G[m]||m},m))})})]})]}),t.length===0&&e.jsx("span",{className:"mt-1 ml-1 block text-ink-dim text-meta",children:"No categories selected"})]})},At=({value:t,label:i,onChange:a,placeholder:n="Add tag...",disabled:s=!1,icon:o})=>{const[r,h]=l.useState(""),p=l.useRef(null),y=l.useId(),b=u=>{h(u.target.value)},j=()=>{const u=r.trim().toLowerCase();u&&!t.includes(u)&&a([...t,u]),h("")},d=u=>{u.key==="Enter"&&r.trim()?(u.preventDefault(),j()):u.key==="Backspace"&&!r&&t.length>0&&a(t.slice(0,-1))},c=u=>{a(t.filter(f=>f!==u))};return e.jsxs("div",{children:[e.jsxs(F,{htmlFor:y,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[o,i]}),e.jsxs("div",{className:P("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",s&&"border-hairline bg-sunken"),children:[t.map(u=>e.jsxs(me,{className:"gap-1 pr-1 text-ink",children:[u,e.jsx("button",{type:"button","aria-label":`Remove tag ${u}`,disabled:s,onClick:()=>c(u),className:P("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(he,{})})]},u)),e.jsx("input",{id:y,ref:p,type:"text",value:r,onChange:b,onKeyDown:d,placeholder:n,disabled:s,"aria-label":i,className:P("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")}),r.trim()&&e.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"Add tag",disabled:s,onClick:()=>{j(),p.current?.focus()},className:"text-accent hover:text-accent",children:e.jsx(be,{})})]}),t.length===0&&!r&&e.jsx("span",{className:"mt-1 ml-1 block text-ink-dim text-meta",children:"No tags added"})]})},Ft=({selectedAgent:t,savingField:i,setSavingField:a,updateAgentMutation:n,refetchAgent:s,initialSelectedAgentId:o})=>{const{data:r,isLoading:h}=pt(),[p,y]=l.useState("");l.useEffect(()=>{!h&&r?.values?y(t.hosting||r.values.hosting||""):h||y(t.hosting||"")},[t,r,h]);const[b,j]=l.useState(!1),[d,c]=l.useState(!1);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(z,{value:t.name,label:"Agent name",placeholder:"Enter agent name...",isSaving:i==="name",onSave:async u=>{if(!u.trim()){B("Agent name cannot be empty");return}a("name");try{const f={name:u};await n.mutateAsync({agentId:t.id,update:f}),t.id===o&&s&&await s()}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(mt,{value:t.hosting||(r?.values.hosting??""),isSaving:i==="hosting",onSave:async u=>{a("hosting"),y(u);try{const f={hosting:u,model:""};await n.mutateAsync({agentId:t.id,update:f}),t.id===o&&s&&await s()}catch{y(t.hosting||"")}finally{a(null)}},filterByCredentials:!0,allowDefault:!0},`hosting-select-${t.id}-${t.hosting||(r?.values.hosting??"default")}`)}),e.jsx("div",{"data-tour-tag":"agent-settings-model-select",children:p?e.jsx(ht,{value:t.hosting?t.model||"":t.model||(r?.values.model_name??""),hostingId:p,isSaving:i==="model",allowDefault:!0,onSave:async u=>{a("model");try{const f={model:u};await n.mutateAsync({agentId:t.id,update:f}),t.id===o&&s&&await s()}catch{}finally{a(null)}}},`model-select-${t.id}-${p}-${t.model||(!t.hosting&&r?.values.model_name?r.values.model_name:"default")}`):e.jsxs("div",{className:"relative",children:[e.jsx(T,{content:"Select a hosting provider first, and then select the AI model that you want to use. Each model has different capabilities and costs. Recommended: Automatic",children:e.jsxs("div",{className:"mb-1.5 flex w-fit items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(xt,{size:16,"aria-hidden":"true"}),"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:"Select a hosting provider first..."})})]})})]}),e.jsxs("h2",{className:"mt-4 flex items-center gap-2 text-heading text-ink",children:[e.jsx(Q,{size:16,className:"shrink-0 text-ink-dim"}),"Agent information"]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(z,{value:t.description||"",label:"Description",placeholder:"Enter agent description...",multiline:!0,rows:3,isSaving:i==="description",onSave:async u=>{a("description");try{const f={description:u};await n.mutateAsync({agentId:t.id,update:f}),t.id===o&&s&&await s()}catch{}finally{a(null)}}}),e.jsx(At,{value:t.tags||[],label:"Tags",placeholder:"Add tag...",disabled:b,onChange:async u=>{if(!(Array.isArray(t.tags)&&u.length===t.tags.length&&u.every((f,N)=>f===t.tags?.[N]))){j(!0);try{const f={tags:u};await n.mutateAsync({agentId:t.id,update:f}),t.id===o&&s&&await s()}catch{}finally{j(!1)}}}}),e.jsx(Xt,{value:t.categories||[],label:"Categories",placeholder:"Add category...",disabled:d,onChange:async u=>{if(!(Array.isArray(t.categories)&&u.length===t.categories.length&&u.every((f,N)=>f===t.categories?.[N]))){c(!0);try{const f={categories:u};await n.mutateAsync({agentId:t.id,update:f}),t.id===o&&s&&await s()}catch{}finally{c(!1)}}}}),e.jsxs(Nt,{children:[e.jsx(Z,{label:e.jsxs(e.Fragment,{children:[e.jsx(zt,{size:12,"aria-hidden":"true"}),"ID"]}),value:e.jsx("span",{className:"font-mono text-mono-sm",children:t.id})}),e.jsx(Z,{label:e.jsxs(e.Fragment,{children:[e.jsx(Et,{size:12,"aria-hidden":"true"}),"Created"]}),value:ft(t.created_date)}),e.jsx(Z,{label:e.jsxs(e.Fragment,{children:[e.jsx(Rt,{size:12,"aria-hidden":"true"}),"Version"]}),value:t.version})]})]})]})},ea=({selectedAgent:t,savingField:i,setSavingField:a,updateAgentMutation:n,refetchAgent:s,initialSelectedAgentId:o})=>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(yt,{size:16,className:"shrink-0 text-ink-dim"}),"Security instructions",e.jsx(T,{content:`Security instructions that guide the agent's behavior and limitations. This is the "system prompt" for the security agent.`,children:e.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"About security instructions",children:e.jsx(Q,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:`This prompt is directed to the AI security reviewer. It helps the reviewer decide whether to block or allow actions based on safety. Write as if talking to another agent that is watching this agent (eg. "Allow all git operations", "Don't let the agent access drive files in the restricted folder"). Update this to allow the agent to perform actions if you are getting frequent security blocks.`}),e.jsx("div",{className:"mt-4",children:e.jsx(z,{value:t.security_prompt||"",label:"",placeholder:"Enter instructions for the security agent...",multiline:!0,rows:6,isSaving:i==="security_prompt",onSave:async r=>{a("security_prompt");try{const h={security_prompt:r};await n.mutateAsync({agentId:t.id,update:h}),t.id===o&&s&&await s()}catch{}finally{a(null)}}})})]}),ta=({selectedAgent:t,savingField:i,setSavingField:a,refetchAgent:n,initialSelectedAgentId:s})=>{const{data:o,isLoading:r}=Kt(t.id),h=Gt(t.id),[p,y]=l.useState("");return l.useEffect(()=>{o!==void 0&&y(o)},[o]),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(_t,{size:16,className:"shrink-0 text-ink-dim"}),"Agent instructions",e.jsx(T,{content:`System instructions that define the agent's behavior and capabilities. This is the agent's "system prompt".`,children:e.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"About agent instructions",children:e.jsx(Q,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:`Define the agent's role, personality, or provide context. Write as if talking to the agent (e.g., "You are an expert researcher") and/or about yourself (e.g., "My name is John").`}),e.jsx("div",{className:"mt-4",children:e.jsx(z,{value:p,label:"",placeholder:r?"Loading system prompt...":"Enter instructions for the agent...",multiline:!0,rows:6,isSaving:i==="system_prompt",onSave:async b=>{a("system_prompt");try{await h.mutateAsync(b),t.id===s&&n&&await n()}finally{a(null)}}})})]})},aa=({selectedAgent:t,refetchAgent:i,initialSelectedAgentId:a})=>{const[n,s]=l.useState(null),o=gt();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(Ft,{selectedAgent:t,savingField:n,setSavingField:s,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:a}),e.jsx(ta,{selectedAgent:t,savingField:n,setSavingField:s,refetchAgent:i,initialSelectedAgentId:a}),e.jsx(ea,{selectedAgent:t,savingField:n,setSavingField:s,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:a}),e.jsx(Jt,{selectedAgent:t,savingField:n,setSavingField:s,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:a})]})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-8 text-center",children:[e.jsx(ae,{size:48,className:"text-ink-dim","aria-hidden":"true"}),e.jsx("h2",{className:"text-heading text-ink",children:"No agent selected"}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:"Select an agent from the list on the left to view its configuration and details."})]})})},_e=({open:t,onClose:i,agentName:a,isAuthenticated:n,onConfirmUpload:s,onSignInSuccess:o,validationIssues:r=[]})=>{const[h,p]=l.useState(!1),y=l.useId(),b=d=>{p(d===!0)},j=()=>{h&&n&&r.length===0&&s()};return l.useEffect(()=>{t||p(!1)},[t]),e.jsx(ge,{open:t,onClose:i,title:`Upload "${a}" to Agent hub?`,maxWidth:"sm",fullWidth:!0,dataTourTag:"upload-agent-dialog",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[r.length>0&&e.jsxs(xe,{variant:"danger",children:[e.jsx(We,{children:"Agent is missing required fields"}),e.jsx("ul",{className:"list-disc space-y-1 pl-5",children:r.map(d=>e.jsx("li",{children:d},d))})]}),n?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-body text-ink",children:["You are about to upload the agent"," ",e.jsx("span",{className:"font-semibold",children:a})," to the public Agent hub. This will include:"]}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5 text-body text-ink-muted",children:[e.jsx("li",{children:"Agent configuration and settings"}),e.jsx("li",{children:"Conversation history"}),e.jsx("li",{children:"Execution history"}),e.jsx("li",{children:"Learnings and memory"}),e.jsx("li",{children:"Current plan (if any)"})]}),e.jsx("p",{className:"text-body text-ink",children:"This information will be publicly visible and downloadable by other users. Please ensure you are not uploading sensitive or private information."}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-5 shrink-0 items-center",children:e.jsx(Ke,{id:y,name:"termsAgreement",checked:h,onCheckedChange:b})}),e.jsxs(F,{htmlFor:y,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."]})]})]}):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 upload agents to the Agent hub."}),e.jsx(Dt,{titleText:"Sign in to continue",descriptionText:"",onSignInSuccess:o})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(D,{variant:"secondary",onClick:i,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Cancel"}),n&&e.jsx(D,{variant:"primary",onClick:j,disabled:!h||r.length>0,children:"Confirm upload"})]})]})})},sa=1200,na=({agent:t,isSelected:i,onSelectAgent:a,onChatWithAgent:n,onExportAgent:s,onAgentDeleted:o,onUploadAgentToHub:r})=>{const h=t.description||"No description";return e.jsxs("li",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:()=>a(t),"aria-current":i?"true":void 0,"data-tour-tag":"agent-list-item-button",className:P("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",i?"bg-accent-wash":"hover:bg-elevated"),children:[e.jsx(Ye,{className:"size-8 shrink-0",children:e.jsx(Ze,{children:e.jsx(ae,{size:16,"aria-hidden":!0})})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx(T,{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(T,{content:h,side:"bottom",align:"start",children:e.jsx("span",{className:"block truncate text-meta text-ink-dim",children:h})})]})]}),e.jsx("div",{className:P("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(T,{content:"Agent options",children:e.jsx("span",{children:e.jsx(Wt,{agentId:t.id,agentName:t.name,isAgentsPage:!0,onAgentDeleted:()=>o(t.id),onChatWithAgent:()=>n(t.id),onExportAgent:()=>s(t.id),onUploadAgentToHub:()=>r(t),buttonSx:{width:24,height:24,borderRadius:"6px",display:"flex",justifyContent:"center",alignItems:"center"}})})})})]})},ia=(t,i)=>t.isSelected===i.isSelected&&t.agent.id===i.agent.id&&t.agent.name===i.agent.name&&t.agent.description===i.agent.description&&t.onSelectAgent===i.onSelectAgent&&t.onChatWithAgent===i.onChatWithAgent&&t.onExportAgent===i.onExportAgent&&t.onAgentDeleted===i.onAgentDeleted&&t.onUploadAgentToHub===i.onUploadAgentToHub,oa=l.memo(na,ia),ra=({selectedAgentId:t,onSelectAgent:i})=>{const a=je(),[n,s]=l.useState(""),o=bt(x=>x.openCreateAgentDialog),r=jt(n.trim(),250),[h,p]=l.useState(!1),y=50,[b,j]=l.useState(!1),[d,c]=l.useState(null),[u,f]=l.useState([]),{isAuthenticated:N}=ke(),I=l.useMemo(()=>ee(te.baseUrl),[]),S=we(),{page:E,setPage:C}=Qt(),{data:k,isLoading:m,isError:w,refetch:g}=kt(E,y,0,r||void 0,"created_date","desc"),L=k?.agents||[],se=k?.total||0,{data:$}=ve(t&&!L.find(x=>x.id===t)?t:void 0),W=l.useMemo(()=>{const x=[...L];return $&&!x.find(_=>_.id===$.id)&&x.push($),x.sort((_,U)=>new Date(U.created_date).getTime()-new Date(_.created_date).getTime()),x},[L,$]),De=l.useCallback(x=>{C(x)},[C]),Ie=l.useCallback(x=>{i(x)},[i]),Se=l.useCallback(()=>{p(!0)},[]),Ee=l.useCallback(()=>{p(!1)},[]),Pe=l.useCallback(async x=>{try{const _=await S.mutateAsync(x),U=W.find(Re=>Re.id===x),V=U?U.name.replace(/\s+/g,"-").toLowerCase():x,K=URL.createObjectURL(_),H=document.createElement("a");H.href=K,H.download=`${V}-export.zip`,document.body.appendChild(H),H.click(),URL.revokeObjectURL(K),document.body.removeChild(H)}catch(_){console.error("Failed to export agent:",_)}},[W,S]),ne=l.useCallback(x=>{if(!x)return["No agent selected."];const _=[];return(!x.name||x.name.trim()==="")&&_.push("Name is required."),(!x.description||x.description.trim()==="")&&_.push("Description is required."),x.categories&&x.categories.length>0||_.push("At least one category is required."),_},[]),ie=l.useCallback(x=>{c(x),f(ne(x)),j(!0)},[ne]),Y=l.useCallback(()=>{j(!1),c(null),f([])},[]),Te=l.useCallback(()=>{Y()},[Y]),Le=l.useCallback(async x=>{try{const U=((await g()).data?.agents||[]).find(K=>K.id===x);if(U){i(U);return}const V=await I.agents.getAgent(x);V.status<400&&V.result&&i(V.result)}catch(_){console.error("Error selecting newly created agent:",_)}},[i,g,I]),Ue=l.useCallback(x=>{a(`/chat/${x}`)},[a]),qe=l.useCallback(x=>{g(),a("/agents")},[t,g,a]),Oe=l.useCallback(x=>{ie(x)},[ie]);return e.jsxs("div",{className:"flex h-full w-full flex-col overflow-hidden border-hairline border-r bg-surface",children:[e.jsx(Zt,{title:"Agents",searchQuery:n,onSearchChange:x=>s(x),onNewAgentClick:o,onImportAgentClick:Se,importAgentTooltip:"Import an agent from a ZIP file"}),m?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(pe,{size:"lg",label:"Loading agents"})}):w?e.jsxs(xe,{variant:"danger",role:"alert",className:"m-4 w-auto",children:[e.jsx(Ge,{children:"Failed to load agents. Please try again."}),e.jsx(D,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>g(),children:"Retry"})]}):W.length===0&&!m?e.jsx("p",{className:"p-6 text-center text-body-sm text-ink-muted",children:n?"No agents match your search":"No agents found"}):e.jsx(Qe,{delayDuration:sa,skipDelayDuration:0,children:e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-2",children:W.map(x=>e.jsx(oa,{agent:x,isSelected:t===x.id||$?.id===x.id,onSelectAgent:Ie,onChatWithAgent:Ue,onExportAgent:Pe,onAgentDeleted:qe,onUploadAgentToHub:Oe},x.id))})}),e.jsx(Yt,{open:h,onClose:Ee,onAgentImported:Le}),se>0&&e.jsx(It,{page:E,count:Math.max(1,Math.ceil(se/y)),onChange:De}),e.jsx(_e,{open:b,onClose:Y,agentName:d?.name||"",isAuthenticated:N,onConfirmUpload:Te,validationIssues:u})]})},la=l.memo(ra),ha=()=>{const{agentId:t,navigateToAgent:i}=wt(),a=je(),{isAuthenticated:n}=ke(),[s,o]=l.useState(!1),[r,h]=l.useState([]),p=we(),y=vt(),{setLastAgentsPageAgentId:b,getLastAgentId:j}=fe(),d=t||j("agents"),{data:c,refetch:u}=ve(d||void 0);l.useEffect(()=>{t&&b(t)},[t,b]);const f=async()=>{if(c)try{const k=await p.mutateAsync(c.id),m=URL.createObjectURL(k),w=document.createElement("a");w.href=m,w.download=`${c.name.replace(/\s+/g,"-").toLowerCase()}-lo-agent.zip`,document.body.appendChild(w),w.click(),URL.revokeObjectURL(m),document.body.removeChild(w)}catch(k){console.error("Failed to export agent:",k)}},N=k=>{if(!k)return["No agent selected."];const m=[];return(!k.name||k.name.trim()==="")&&m.push("Name is required."),(!k.description||k.description.trim()==="")&&m.push("Description is required."),k.categories&&k.categories.length>0||m.push("At least one category is required."),m},I=()=>{const k=N(c??null);h(k),o(!0)},S=()=>{o(!1),h([])},E=()=>{!c||!n||(y.mutateAsync(c.id),S())},C=k=>{b(k.id),i(k.id,"agents")};return e.jsxs("div",{className:"flex h-full w-full overflow-hidden",children:[e.jsx("div",{className:"h-full w-70 shrink-0",children:e.jsx(la,{selectedAgentId:c?.id,onSelectAgent:C})}),e.jsx("div",{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(Je,{title:"Agent management",icon:ae,subtitle:"View, configure and manage your agents",children:c&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(ce,{children:[e.jsx(de,{asChild:!0,children:e.jsx(D,{"data-tour-tag":"upload-to-hub-header-button",variant:"secondary",size:"icon","aria-label":"More agent actions",className:"@min-[400px]:hidden",children:e.jsx(Ct,{"aria-hidden":"true"})})}),e.jsxs(ue,{align:"end",className:"min-w-45",children:[e.jsxs(O,{disabled:p.isPending,onSelect:f,children:[e.jsx(re,{"aria-hidden":"true"}),e.jsx("span",{children:"Export"})]}),e.jsxs(O,{disabled:y.isPending,onSelect:I,children:[e.jsx(A,{"aria-hidden":"true"}),e.jsx("span",{children:y.isPending?"Uploading...":"Upload to hub"})]})]})]}),e.jsxs(D,{variant:"secondary",onClick:f,disabled:p.isPending,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(re,{"aria-hidden":"true"}),"Export"]}),e.jsxs(D,{"data-tour-tag":"upload-to-hub-header-button","data-tour-action":"open-upload-dialog",variant:"secondary",onClick:I,disabled:y.isPending,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(A,{"aria-hidden":"true"}),y.isPending?"Uploading...":"Upload to hub"]}),e.jsx(T,{content:`Chat with ${c.name||"this agent"}`,children:e.jsxs(D,{variant:"primary",onClick:()=>a(`/chat/${c.id}`),children:[e.jsx(ye,{"aria-hidden":"true"}),"Chat"]})})]})})}),e.jsx("div",{className:"min-h-0 grow overflow-hidden",children:e.jsx(aa,{selectedAgent:c??null,refetchAgent:u,initialSelectedAgentId:t})})]})}),c&&e.jsx(_e,{open:s,onClose:S,agentName:c?.name??"",isAuthenticated:n,onConfirmUpload:E,validationIssues:r})]})};export{ha as LegacyAgentsPage};