local-operator-ui 0.31.26 → 0.31.27
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 +143 -3
- package/out/renderer/assets/{_basePickBy-D0wlCvva.js → _basePickBy-oM-LmypH.js} +1 -1
- package/out/renderer/assets/{_baseUniq-DPa_8DrG.js → _baseUniq-CfyEpPZd.js} +1 -1
- package/out/renderer/assets/{agent-details-page-CrARDEtK.js → agent-details-page-DIBks4X5.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-tj8FYJ7M.js → agent-hub-page-oV4gEqC4.js} +2 -2
- package/out/renderer/assets/agents-page-CZrNPorc.js +7 -0
- package/out/renderer/assets/aida-control-CQx1CGx-.js +50 -0
- package/out/renderer/assets/{arc-BG4bHuQI.js → arc-DXJiD7SC.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CkYkkIY9.js → architectureDiagram-IEHRJDOE-VHM5BLyo.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-D0DwK5Ey.js → blockDiagram-JOT3LUYC-Cn1dvDZU.js} +1 -1
- package/out/renderer/assets/{book-open-DeQc_I6g.js → book-open-P6KBj9Du.js} +1 -1
- package/out/renderer/assets/browser-page-D6eiItUp.js +1 -0
- package/out/renderer/assets/{browser-webauthn-prompt-CYou_6QY.js → browser-webauthn-prompt-CByfVm08.js} +1 -1
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-CubzqfYr.js → c4Diagram-VJAJSXHY-B8F1XGHT.js} +1 -1
- package/out/renderer/assets/channel-DZQWNfux.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-AysrzODh.js → chunk-4BMEZGHF-CVoXO2u6.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-DfDo-OSy.js → chunk-A2AXSNBT-LFo0s6P7.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-5xgHbFtp.js → chunk-AEK57VVT-B8s36YJo.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-pYCMpQiN.js → chunk-D6G4REZN-BKkRpyOx.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-C5bWxzka.js → chunk-RZ5BOZE2-qoB87AlE.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-B4wB3iEG.js → chunk-XZIHB7SX-BACgoEDe.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-jw9F6ZK-.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-jw9F6ZK-.js +1 -0
- package/out/renderer/assets/clone-DzWAH3PE.js +1 -0
- package/out/renderer/assets/{console-mirror-45f9-7QH.js → console-mirror-fXJ5fMxl.js} +1 -1
- package/out/renderer/assets/{consoleCapture-GiahzrSM.js → consoleCapture-Df4uIOqu.js} +1 -1
- package/out/renderer/assets/{dagre-OKDRZEBW-CBRdPb8k.js → dagre-OKDRZEBW-CLMw1D7m.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-DyGZgIL1.js → diagram-SSKATNLV-plMydQ5N.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-Con45RzE.js → diagram-VNBRO52H-BptPse7H.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-Cpuc-IVT.js → erDiagram-Q7BY3M3F-CGjlhqbg.js} +1 -1
- package/out/renderer/assets/{error-boundary-CdtTgj_c.js → error-boundary-D3Um1PIl.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-CsO4ubSn.js → flowDiagram-4HSFHLVR-rb1I18B8.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-LYPPAOmY.js → ganttDiagram-APWFNJXF-D-bSpERZ.js} +3 -3
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BO_dix1Z.js → gitGraphDiagram-7IBYFJ6S-DDJQIXgd.js} +1 -1
- package/out/renderer/assets/{graph-uBeiISg2.js → graph-BkNT14na.js} +1 -1
- package/out/renderer/assets/{index-Bi4c5ZZH.js → index-BXamXVGw.js} +1 -1
- package/out/renderer/assets/{index-COUHPq03.js → index-D3ICBbhi.js} +514 -405
- package/out/renderer/assets/{index-CIj3B-eB.js → index-DHcQTmYa.js} +1 -1
- package/out/renderer/assets/index-DuUnXH9L.css +1 -0
- package/out/renderer/assets/{index-Dn3kYWFt.js → index-_dbvHdgc.js} +9 -9
- package/out/renderer/assets/infoDiagram-PH2N3AL5-Bg2dnJEw.js +2 -0
- package/out/renderer/assets/{installer-zpOWwoWQ.js → installer-D-IQpqXR.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-B6AH0Dcn.js → journeyDiagram-U35MCT3I-B5bji5kb.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-C7dciPrH.js → kanban-definition-NDS4AKOZ-BGi8PMEB.js} +1 -1
- package/out/renderer/assets/{layout-hxpgEDIm.js → layout-D3rwe0Wt.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-C6kd3fjG.js → legacy-agents-page-DnpWTuf8.js} +4 -4
- package/out/renderer/assets/{mermaid.core-CC8CflzC.js → mermaid.core-CHiYins7.js} +5 -5
- package/out/renderer/assets/mesh-page-B2_ZtHTQ.js +1 -0
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-BWI1IBWM.js → mindmap-definition-ALO5MXBD-BwO55Ck2.js} +1 -1
- package/out/renderer/assets/{mini-Dtj-bCUA.js → mini-D7VYY0xP.js} +1 -1
- package/out/renderer/assets/{org-surface-gate-CjPxDSXP.js → org-surface-gate-Da1VmZbG.js} +1 -1
- package/out/renderer/assets/{page-header-Dt6h8jvu.js → page-header-B3kbzqCp.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-DNymJR3P.js → pieDiagram-IB7DONF6-j0i7dQ2D.js} +1 -1
- package/out/renderer/assets/{projects-page-C3N6NYIX.js → projects-page-f-tkHojn.js} +9 -9
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-bRmQaOWY.js → quadrantDiagram-7GDLP6J5-BZkLgvoE.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-B1I3333M.js → radar-MK3ICKWK-QB0E4nFC.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-CCXHTNWU.js → radient-auth-buttons-2wnsv7f6.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B29w6CHz.js → requirementDiagram-KVF5MWMF-Cb1rqfe3.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-BNv_qf23.js → sankeyDiagram-QLVOVGJD-ST_5m9Zy.js} +1 -1
- package/out/renderer/assets/{schedules-page-CXz63fN5.js → schedules-page-DnHKOQij.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-D7gyUvnw.js → sequenceDiagram-X6HHIX6F-Bh-yCDC0.js} +1 -1
- package/out/renderer/assets/{settings-page-CsCf63si.js → settings-page-D1dF4GZE.js} +8 -8
- package/out/renderer/assets/{settings-section-DMXSpP_D.js → settings-section-C9etJXA9.js} +1 -1
- package/out/renderer/assets/{stateDiagram-DGXRK772-Dd3BswSO.js → stateDiagram-DGXRK772-D6MGh56o.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Dvv5Bcoz.js +1 -0
- package/out/renderer/assets/{textarea-DsHM-W2p.js → textarea-DeXGhzIK.js} +2 -2
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-MePOCWzB.js → timeline-definition-BDJGKUSR-pgK_gxyk.js} +1 -1
- package/out/renderer/assets/ui-preferences-store-BLiDaCIL.js +1 -0
- package/out/renderer/assets/{use-download-agent-mutation-BNAfnIa9.js → use-download-agent-mutation-CXw_g4Rv.js} +3 -3
- package/out/renderer/assets/{use-memberships-query-PWqngUAl.js → use-memberships-query-BGPQ6jDl.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-heZP1JY-.js → xychartDiagram-VJFVF3MP-CYYxIZAM.js} +1 -1
- package/out/renderer/console-capture.html +5 -5
- package/out/renderer/index.html +8 -8
- package/out/renderer/installer.html +5 -5
- package/out/renderer/mini.html +6 -6
- package/package.json +3 -3
- package/out/renderer/assets/agents-page-CbQN_5wE.js +0 -7
- package/out/renderer/assets/aida-control-BuMafqCb.js +0 -50
- package/out/renderer/assets/browser-page-CIhGr6vl.js +0 -1
- package/out/renderer/assets/channel-B-eIVFbM.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-BN6aG5Qf.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-BN6aG5Qf.js +0 -1
- package/out/renderer/assets/clone-C3CHGd7j.js +0 -1
- package/out/renderer/assets/index-D8ujEXbz.css +0 -1
- package/out/renderer/assets/infoDiagram-PH2N3AL5-BqRYyG2a.js +0 -2
- package/out/renderer/assets/mesh-page-M4Y20e0t.js +0 -2
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D9cOpOSm.js +0 -1
- package/out/renderer/assets/ui-preferences-store-BmAT9G_p.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as t,c as oe,t as Cn}from"./index-
|
|
1
|
+
import{r as i,j as t,c as oe,t as Cn}from"./index-_dbvHdgc.js";import{cA as Wt,cB as Mn,cC as st,cD as An,cE as St,cF as he,cG as Rn,b$ as Tn,c0 as Zt,U as Qt,_ as En,$ as Ln,cH as In,cI as On,cJ as Fn,cK as Dn,cL as Jt,cM as mt,cN as Xt,cO as Ue,cP as $n,a8 as Un,cQ as Ct,cR as zn,cS as Pn,T as en,aa as at,ab as ot,aE as Hn,cT as Kn,cU as rt,cV as it,cW as Bn,a3 as Vn,b8 as Mt,bg as Gn,cX as tn,cY as qn,cZ as Yn,c_ as Wn,Z as Zn,c$ as nn,a9 as sn,d0 as Qn,d1 as an,d2 as Jn,d3 as Xn,d4 as es,a0 as ts,d5 as on,ca as ns,d6 as ss,d7 as as,d8 as os,b9 as rs,c7 as is,bo as cs,d9 as ls,da as ds,c2 as us,db as ms,dc as hs,dd as fs,de as ps,bX as At,bQ as gs,c6 as Rt,df as ys,c8 as xs,c9 as ks,dg as vs,dh as bs,di as ws,dj as js,dk as _s}from"./index-D3ICBbhi.js";import{B as Se,f as ht,u as rn,D as ft,a6 as Ns,h as be,a as Ss,d as Tt,j as He,a7 as Cs,a8 as Ms}from"./aida-control-CQx1CGx-.js";import{P as As}from"./page-header-B3kbzqCp.js";import{c as y,B as D,S as re,x as Rs,s as Ts,t as Es,u as Ls,v as Is,w as Os,g as Te,H as Ge,L as fe,I as Ce,z as Et,E as Lt,F as ze,Z as It,a as cn,N as Fs,D as Ds,k as $s,l as Us,n as zs,o as Ot,T as Ps,A as le,p as Hs,O as Ks,C as Bs,f as ln}from"./textarea-DeXGhzIK.js";import{u as ct}from"./ui-preferences-store-BLiDaCIL.js";import{S as se,I as pt,a as ae,N as Vs}from"./settings-section-C9etJXA9.js";import{R as Gs}from"./radient-auth-buttons-2wnsv7f6.js";import{B as qs}from"./book-open-P6KBj9Du.js";import{a as Ys,p as Je}from"./parseISO-CZfAC2_J.js";import{i as Ws,a as ve,f as Zs}from"./format-CZUObkkr.js";import{t as Qs}from"./en-US-BcB1DWxG.js";import"./error-boundary-D3Um1PIl.js";import"./console-mirror-fXJ5fMxl.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -43,7 +43,7 @@ import{r as i,j as t,c as oe,t as Cn}from"./index-Dn3kYWFt.js";import{ci as Wt,c
|
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const fa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],pa=y("circle-play",fa);/**
|
|
47
47
|
* @license lucide-react v0.507.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
@@ -113,12 +113,12 @@ import{r as i,j as t,c as oe,t as Cn}from"./index-Dn3kYWFt.js";import{ci as Wt,c
|
|
|
113
113
|
*
|
|
114
114
|
* This source code is licensed under the ISC license.
|
|
115
115
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const Pa=[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]],
|
|
116
|
+
*/const Pa=[["path",{d:"M6.5 12c.94-3.46 4.94-6 8.5-6 3.56 0 6.06 2.54 7 6-.94 3.47-3.44 6-7 6s-7.56-2.53-8.5-6Z",key:"15baut"}],["path",{d:"M18 12v.5",key:"18hhni"}],["path",{d:"M16 17.93a9.77 9.77 0 0 1 0-11.86",key:"16dt7o"}],["path",{d:"M7 10.67C7 8 5.58 5.97 2.73 5.5c-1 1.5-1 5 .23 6.5-1.24 1.5-1.24 5-.23 6.5C5.58 18.03 7 16 7 13.33",key:"l9di03"}],["path",{d:"M10.46 7.26C10.2 5.88 9.17 4.24 8 3h5.8a2 2 0 0 1 1.98 1.67l.23 1.4",key:"1kjonw"}],["path",{d:"m16.01 17.93-.23 1.4A2 2 0 0 1 13.8 21H9.5a5.96 5.96 0 0 0 1.49-3.98",key:"1zlm23"}]],Ha=y("fish",Pa);/**
|
|
117
117
|
* @license lucide-react v0.507.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const Ka=[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]],Ba=y("flame",Ka);/**
|
|
122
122
|
* @license lucide-react v0.507.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
@@ -178,7 +178,7 @@ import{r as i,j as t,c as oe,t as Cn}from"./index-Dn3kYWFt.js";import{ci as Wt,c
|
|
|
178
178
|
*
|
|
179
179
|
* This source code is licensed under the ISC license.
|
|
180
180
|
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const
|
|
181
|
+
*/const fo=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9",key:"4ay0iu"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}]],po=y("moon-star",fo);/**
|
|
182
182
|
* @license lucide-react v0.507.0 - ISC
|
|
183
183
|
*
|
|
184
184
|
* This source code is licensed under the ISC license.
|
|
@@ -248,7 +248,7 @@ import{r as i,j as t,c as oe,t as Cn}from"./index-Dn3kYWFt.js";import{ci as Wt,c
|
|
|
248
248
|
*
|
|
249
249
|
* This source code is licensed under the ISC license.
|
|
250
250
|
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const
|
|
251
|
+
*/const Ho=[["path",{d:"M3.5 21 14 3",key:"1szst5"}],["path",{d:"M20.5 21 10 3",key:"1310c3"}],["path",{d:"M15.5 21 12 15l-3.5 6",key:"1ddtfw"}],["path",{d:"M2 21h20",key:"1nyx9w"}]],Ko=y("tent",Ho);/**
|
|
252
252
|
* @license lucide-react v0.507.0 - ISC
|
|
253
253
|
*
|
|
254
254
|
* This source code is licensed under the ISC license.
|
|
@@ -288,5 +288,5 @@ import{r as i,j as t,c as oe,t as Cn}from"./index-Dn3kYWFt.js";import{ci as Wt,c
|
|
|
288
288
|
*
|
|
289
289
|
* This source code is licensed under the ISC license.
|
|
290
290
|
* See the LICENSE file in the root directory of this source tree.
|
|
291
|
-
*/const ar=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],or=y("wind",ar),rr=({appVersion:e=null,slowWaitHintMs:s})=>{const n="https://local-operator.com/download",[a,o]=i.useState(!1),r=Wt(a,s??Mn),[u,d]=i.useState(!1),[c,m]=i.useState(null),[g,b]=i.useState("info"),[k,p]=i.useState(null),[x,L]=i.useState(null),S=e?.trim()?e.trim():null,H=i.useRef(!1),_=st(A=>A.openDetail),$=i.useRef(!1),I=i.useRef(0),M=i.useRef(!1),N=i.useCallback((A,T)=>{$.current=!1,m(A),b(T),d(!0)},[]),G=i.useCallback(A=>{$.current=!0,m(A),b("success"),d(!0)},[]),P=i.useCallback(()=>{$.current&&($.current=!1,d(!1),m(null))},[]),{clearDeferredUpdate:q}=An();i.useEffect(()=>{const A=window.api.updater.onUpdateError(R=>{H.current&&R.includes("manually")&&(p({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),$.current=!1,m(null),b("warning"),d(!0))}),T=window.api.updater.onBackendUpdateDevMode(R=>{H.current&&N(R,"info")}),V=()=>{M.current=!0,P()},z=window.api.updater.onUpdateAvailable(V),O=window.api.updater.onUpdateNpxAvailable(V),ee=window.api.updater.onBackendUpdateAvailable(V);return()=>{A(),T(),z(),O(),ee()}},[P,N]),i.useEffect(()=>{let A=!1;const T=()=>{window.api.updater.getLastInstallAttempt().then(z=>{A||L(z)}).catch(()=>{})};T();const V=window.api.updater.onUpdateInstallFailed(()=>T());return()=>{A=!0,V()}},[]);const K=async()=>{const A=++I.current;P(),M.current=!1;try{o(!0),H.current=!0,q(he.UI),q(he.BACKEND);const T=await window.api.updater.checkForAllUpdates({manual:!0});if(A!==I.current)return;T.app==="available"&&_(he.UI),T.server==="available"&&_(he.BACKEND),T?.affirmation&&!M.current?G(T.affirmation):P()}catch(T){if(A!==I.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Rn(T)}`)}finally{A===I.current&&o(!1),setTimeout(()=>{H.current=!1},2e3)}},X=()=>{$.current=!1,d(!1),m(null)};return t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[t.jsxs("p",{className:"text-body-sm text-ink",children:["The last update to version ",x.targetVersion," didn't finish",x.attempts>1?` (${x.attempts} attempts)`:"",".",S?` Version ${S} is running.`:null]}),t.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:["Detected"," ",x.detectedAt?new Date(x.detectedAt).toLocaleString():"at an unknown time",". ",x.detail]}),t.jsx(D,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(n),children:"Download a fresh copy"})]}),t.jsxs(D,{variant:"outline",onClick:()=>void K(),disabled:a,children:[a?t.jsx(re,{size:"sm"}):null,a?"Checking...":"Check for updates"]}),r&&t.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:"Still checking. A slow or stalled connection can hold this for about a minute and a half - the app stops waiting on its own."}),k&&t.jsxs(St,{open:u,autoHideDuration:1e4,onClose:X,variant:"warning",children:[t.jsx("p",{className:"text-body-sm",children:k.message}),k.command&&t.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:k.command})]}),c&&g!=="danger"&&t.jsx(St,{open:u,autoHideDuration:6e3,onClose:X,variant:g,children:c})]})},He=["system-prompt"],ir=()=>{const{shouldEnableQuery:e}=Tn();return Se({enabled:e({bypassInternetCheck:!0}),queryKey:He,queryFn:async()=>{try{const n=await Zt(ht.baseUrl).config.getSystemPrompt();if(n===null)return null;if(n.status>=400)throw new Error(n.message||"Failed to fetch system prompt");return n.result}catch(s){const n=s instanceof Error?s.message:"An unknown error occurred while fetching system prompt";throw Qt(n),s}},refetchOnWindowFocus:!1,staleTime:5e3})},cr=()=>{const e=rn(),s=Zt(ht.baseUrl);return En({mutationFn:async n=>{try{const a=await s.config.updateSystemPrompt(n);if(a.status>=400)throw new Error(a.message||"Failed to update system prompt");return a.result}catch(a){const o=a instanceof Error?a.message:"An unknown error occurred while updating system prompt";throw Qt(o),a}},onSuccess:async n=>{await e.invalidateQueries({queryKey:He,refetchType:"none"}),e.setQueryData(He,a=>a&&{...a,...n}),await e.refetchQueries({queryKey:He,type:"all"}),Ln("System prompt updated")},onError:n=>{console.error("Error updating system prompt:",n)}})},lr=({value:e,label:s,description:n,onChange:a,icon:o,isSaving:r=!1})=>{const[u,d]=i.useState(e),c=i.useId(),m=`${c}-label`,g=`${c}-description`,b=async k=>{if(!r){d(k);try{await a(k)}catch(p){d(!k),console.error("Error toggling setting:",p)}}};return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{id:m,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[o&&t.jsx(o,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),s]}),n&&t.jsx("p",{id:g,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:r?t.jsx(re,{size:"md",label:`Saving ${s}`}):t.jsx(Rs,{checked:u,onCheckedChange:b,"aria-labelledby":m,"aria-describedby":n?g:void 0})})]})};function Ft(e,s){const n=Qs(e,s?.in);if(!Ws(n))throw new RangeError("Invalid time value");const a=ve(n.getDate(),2),o=ve(n.getMonth()+1,2),r=n.getFullYear(),u=ve(n.getHours(),2),d=ve(n.getMinutes(),2),c=ve(n.getSeconds(),2);let m="",g="";const b=n.getTimezoneOffset();if(b!==0){const k=Math.abs(b),p=ve(Math.trunc(k/60),2),x=ve(k%60,2);g=`${b<0?"+":"-"}${p}:${x}`}else g="Z";return`${r}-${o}-${a}T${u}:${d}:${c}${m}${g}`}function dr(e,s,n){return Ys(e,-30,n)}var ur=In({chartName:"LineChart",GraphicalChild:Jt,axisComponents:[{axisType:"xAxis",AxisComp:On},{axisType:"yAxis",AxisComp:Fn}],formatAxisMap:Dn});const mr=["radient","creditBalance"],hr=e=>{const{user:s,isAuthenticated:n}=mt(),a=s?.account?.tenant_id,o=n&&!!a&&e?.enabled;return Se({queryKey:[mr,a],queryFn:async()=>{if(!a)throw new Error("Tenant ID not available");const r=await Xt({operation:"credits",tenantId:a});if(!r||typeof r.balance!="number")throw new Error("Invalid credit balance response format");return r},enabled:o,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},pr=["radient","usageRollup"],fr=(e,s)=>{const{user:n,isAuthenticated:a}=mt(),o=n?.account?.tenant_id,r=a&&!!o&&s?.enabled;return Se({queryKey:[...pr,o,e],queryFn:async()=>{if(!o)throw new Error("Tenant ID not available");const u={};for(const[c,m]of Object.entries(e))m!=null&&(u[c]=String(m));const d=await Xt({operation:"usage",tenantId:o,query:u});if(!d)throw new Error("Invalid usage rollup response format");return d},enabled:r,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Dt={[he.UI]:"Application updates",[he.BACKEND]:"Server updates"},$t=({type:e})=>{const s=st(a=>a.followed[e]),n=st(a=>a.setFollowedSegment);return t.jsxs("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-6",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-body-sm text-ink",children:Dt[e]}),t.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:Ue[s].description})]}),t.jsxs(Ts,{value:s,onValueChange:a=>n(e,a),children:[t.jsx(Es,{"aria-label":`${Dt[e]}: ${Ue[s].label}`,className:"w-full sm:w-56","data-followed-segment":e,children:t.jsx(Ls,{})}),t.jsx(Is,{children:$n.map(a=>t.jsx(Os,{value:a,title:Ue[a].description,children:Ue[a].label},a))})]})]})},gr=()=>t.jsxs("div",{className:oe("flex flex-col gap-3"),children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-heading text-ink",children:"Update notifications"}),t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:"How much of a version change shows the update notice at the bottom of the window. A check you run yourself always reports what it finds."})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx($t,{type:he.UI}),t.jsx($t,{type:he.BACKEND})]})]}),yr=({appVersion:e})=>t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(gr,{}),t.jsx(rr,{appVersion:e})]}),xr=e=>{if(!e)return null;try{return new URL(e).host}catch{return null}},kr=()=>{const[e,s]=i.useState(null),[n,a]=i.useState({value:"Loading...",detail:null,degraded:!1}),[o,r]=i.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});i.useEffect(()=>{let d=!0;const c=p=>{if(!d)return;const x=xr(p.url);if(p.state==="connecting"){a({value:"Loading...",detail:null,degraded:!1});return}if(p.state==="detached"){a({value:"Not connected",detail:p.detail||null,degraded:!1});return}if(p.state==="wedged"){a({value:"Not attached",detail:p.detail||null,degraded:!1});return}const L=p.version||"Version unknown";a({value:x?`${L} · ${x}`:L,detail:p.detail||null,degraded:p.state==="degraded"})};let m=!1;const g=window.api?.backend?.onStatusChange(p=>{m=!0,c(p)}),b=async()=>{try{const[p,x]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);d&&(s(p),r(x))}catch(p){console.error("Error fetching app information:",p)}},k=async()=>{try{const p=window.api?.backend;if(p){const S=await p.getStatus();m||c(S);return}const x=await Ct.healthCheck(ht.baseUrl),L=Ct.getServerVersion(x);d&&a({value:L,detail:null,degraded:!1})}catch(p){console.error("Error fetching server version:",p),d&&a({value:"Unavailable",detail:null,degraded:!1})}};return b(),k(),()=>{d=!1,g?.()}},[]);const u=(d,c,m,g={})=>t.jsx(ae,{label:t.jsx(Te,{content:m,children:t.jsxs("span",{className:"inline-flex cursor-help items-center gap-1.5",children:[t.jsx(Ge,{size:12,className:"shrink-0"}),d]})}),valueClassName:g.valueClassName,value:t.jsxs(t.Fragment,{children:[g.valueTooltip?t.jsx(Te,{content:g.valueTooltip,children:t.jsx("span",{"data-backend-version":g.valueHoverTarget?"":void 0,className:"cursor-help",children:c})}):c,g.statusNote?t.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:g.statusNote}):null]})});return t.jsx(se,{title:"Application updates and info",icon:Un,description:"Check for updates and view information about your Local Operator installation.",dataTourTag:"settings-app-updates-section",children:t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs(ft,{children:[u("Application version",e??"Loading...","The version of the Local Operator user interface application."),u("Server version",n.value,"The version of the Local Operator API server backend, and the address of the daemon it was read from.",{valueTooltip:n.detail,valueHoverTarget:!0,statusNote:n.degraded?"Not answering":void 0,valueClassName:n.degraded?"text-ink-muted":void 0}),u("Platform",`${o.platform} (${o.arch})`,"The operating system and architecture your application is running on."),u("Node.js version",o.nodeVersion,"The JavaScript runtime environment version."),u("Electron version",o.electronVersion,"The framework version enabling this desktop application.")]}),t.jsx(yr,{appVersion:e})]})})},vr=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function un(e){if(!e)return null;const s=e.split("\\").join("/").split("/").filter(Boolean);for(const[n,a]of vr)if(!(s.length<n.length)&&s.slice(-n.length).join("/")===n.join("/"))return a;return null}const Be=e=>`${e} ${e===1?"tool":"tools"}`,br=e=>`${e} ${e===1?"integration":"integrations"}`,wr=["connected","needs_sign_in","not_started","connecting","error"],mn=e=>wr.includes(e),Me=(e,s)=>[...s].filter(n=>n.name===e&&n.status==="running").sort((n,a)=>a.created_at-n.created_at)[0]??null,jr={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},_r=1e12,Nr=1e9,Sr=60*60*1e3,hn=(e,s=Date.now())=>{if(typeof e!="number"||!Number.isFinite(e))return null;const n=e>=_r?e:e<Nr?null:e*1e3;return n===null||n>s+Sr?null:Math.min(n,s)},we=(e,s)=>e?.[s]??jr,Le=(e,s,n)=>Ar(e,s)??n?.lastDecisive??null,Cr=e=>({id:e.id,name:e.name,action:e.action,status:e.status,created_at:e.created_at,credential_removed:e.credential_removed,...e.message?{message:e.message}:{}}),gt=(e,s)=>e.status==="not_started"&&typeof e.tool_count=="number"&&(s.connectedAt!==null||e.status_basis==="stored"&&e.tool_count_basis==="last_seen"),Mr=(e,s)=>[...s].filter(n=>n.name===e).sort((n,a)=>a.created_at-n.created_at)[0]??null,Ar=(e,s)=>Mr(e,s.filter(n=>n.status!=="cancelled")),qe=e=>e.actions.includes("set_key")||e.actions.includes("add_key");function Rr(e,s){const n=Math.max(0,Math.round((e-s)/1e3));if(n<60)return"just now";const a=Math.round(n/60);if(a<60)return`${a} min ago`;const o=Math.round(a/60);return o<24?`${o} h ago`:`${Math.round(o/24)} d ago`}function Xe(e){if(!e)return null;const s=e.trim();if(!s||/^\/\w/.test(s)||/\/mcp\s+\w+/.test(s))return null;let n=s;for(let a=0;a<3;a+=1){const o=n.replace(/^(?:connection (?:closed|error|refused)|error|closed|failed)\s*:\s*/i,"").trim();if(o===n)break;n=o}return n=n.replace(/\s*\(\s*\d{3}\s*\)/g,"").replace(/\s+([.,;])/g,"$1").replace(/\s{2,}/g," ").trim(),n||null}function Tr(e,s=[],n,a=Date.now()){const o=we(n,e.name),r=Me(e.name,s);if(r){if(r.action==="login"||r.action==="reauth")return{label:"Signing in…",tone:"info",detail:null,busy:!0};if(r.action==="logout")return{label:"Signing out…",tone:"info",detail:null,busy:!0}}if(!mn(e.status))return{label:"Status unavailable",tone:"neutral",detail:null,busy:!1};const u=Le(e.name,s,o),d=Ye(u)&&e.status!=="connected",c=gt(e,o),m=kt(u)&&e.status!=="connected",g=(u?.action==="login"||u?.action==="reauth")&&u.status==="failed";if(o.disconnectedAt!==null)return{label:"Not connected",tone:"neutral",detail:null,busy:!1};switch(e.status){case"connected":return{label:typeof e.tool_count=="number"?`Connected · ${Be(e.tool_count)}`:"Connected",tone:"success",detail:null,busy:!1};case"connecting":return{label:"Connecting…",tone:"info",detail:null,busy:!0};case"needs_sign_in":return{label:e.auth.kind==="api_key"||Re(e,s,o)?"Needs a key":"Needs sign-in",tone:"warning",detail:Xe(e.status_reason),busy:!1};case"error":return{label:"Couldn't start",tone:"danger",detail:Xe(e.status_reason)??"No reason was given.",busy:!1};default:if(d)return{label:"Signed out",tone:"warning",detail:null,busy:!1};if(m)return{label:"Sign-out didn't finish",tone:"warning",detail:"The sign-in is still saved.",busy:!1};if(Re(e,s,o))return{label:"Needs a key",tone:"warning",detail:null,busy:!1};if(g)return{label:"Sign-in didn't finish",tone:"warning",detail:null,busy:!1};if(o.needsSignIn)return{label:e.auth.kind==="api_key"||Re(e,s,o)?"Needs a key":"Needs sign-in",tone:"warning",detail:Xe(e.status_reason),busy:!1};if(e.status_basis==="stored"&&c&&o.disconnectedAt===null){const b=o.connectedAt??hn(e.last_seen_at,a);return{label:b!==null?`Worked ${Rr(a,b)} · ${Be(e.tool_count)}`:`Worked earlier · ${Be(e.tool_count)}`,tone:"success",detail:null,busy:!1}}return e.status_basis==="live"?{label:"Not connected",tone:"neutral",detail:null,busy:!1}:{label:"Ready",tone:"neutral",detail:null,busy:!1}}}const pn=e=>e===1?"Replace the saved key":"Replace saved keys",Er=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Lr(e,s){const n=e?.trim()??"";if(!n)return null;if(s)return n;const a=n.replace(Er,"").trim();return a?/\.$/.test(a)?a:`${a}.`:n}const Ir="Nothing is wrong. It starts when a chat uses it.",Or="Not running in this chat.",Fr=e=>e.transport==="local_command"?"Local command":"Remote URL";function fn(e){switch(e.source.kind){case"local-operator":case"project-mcp-json":return null;case"claude-code":return"Claude Code";case"cursor":return"Cursor";case"vscode":return"VS Code";case"codex":return"Codex CLI";default:return un(e.source.path)}}function Dr(e,s){const n=[Fr(e)];e.status!=="connected"&&e.tool_count_basis==="last_seen"&&typeof e.tool_count=="number"&&n.push(`${Be(e.tool_count)} when last checked`),s&&n.push(e.scope==="project"?"This project":"Global");const a=fn(e);return a?n.push(`Imported from ${a}`):e.source.editable||n.push("Imported from a project file"),n}const yt=(e,s)=>s.disconnectedAt!==null?"not_started":e.status;function xt(e,s=[],n){const a=we(n,e.name),o=Me(e.name,s);if(o)return o.action==="login"||o.action==="reauth"?{kind:"sign_in",label:"Continue sign-in"}:null;const r=g=>e.actions.includes(g),u=qe(e),d=Re(e,s,a);if(!mn(e.status))return r("test")?{kind:"test",label:"Check again"}:null;const c=Le(e.name,s,a),m=c?.status==="failed"&&Ie(c);switch(yt(e,a)){case"connected":case"connecting":return null;case"needs_sign_in":return d?{kind:"set_key",label:"Add key"}:r("sign_in")?{kind:"sign_in",label:"Sign in"}:u?{kind:"set_key",label:"Add key"}:r("reauth")?{kind:"reauth",label:"Sign in again"}:{kind:"fix",label:"Fix"};case"error":return r("connect")?{kind:"connect",label:"Reconnect"}:r("test")?{kind:"test",label:"Retry"}:{kind:"fix",label:"Fix"};default:{if(Ye(c)&&r("sign_in"))return{kind:"sign_in",label:"Sign in"};if(kt(c)&&r("sign_out"))return{kind:"sign_out",label:"Sign out again"};if(a.disconnectedAt!==null&&r("connect"))return{kind:"connect",label:"Connect"};if(a.needsSignIn){if(d&&u)return{kind:"set_key",label:"Add key"};if(r("sign_in"))return{kind:"sign_in",label:"Sign in"}}return d&&u?{kind:"set_key",label:"Add key"}:m&&r("sign_in")?{kind:"sign_in",label:"Try again"}:gt(e,a)&&!r("connect")?null:r("connect")?{kind:"connect",label:"Connect",...a.connectedAt===null&&e.status_basis!=="live"?{variant:"ghost"}:{}}:r("test")&&e.tool_count===null&&e.tool_count_basis===null?{kind:"test",label:"Test",variant:"ghost"}:null}}}const Ie=e=>e.action==="login"||e.action==="reauth",Ye=e=>!!(e&&e.action==="logout"&&e.status==="complete"),kt=e=>!!(e&&e.action==="logout"&&e.status!=="running"&&e.status!=="complete"),gn=/no oauth authorization server/i;function Re(e,s,n){if(!qe(e))return!1;const a=Le(e.name,s,n);return a&&Ie(a)&&a.status==="failed"&&gn.test(a.message??"")?!0:n.needsKey}function $r(e,s=[],n){const a=xt(e,s,n)?.kind,o=yt(e,we(n,e.name)),r=c=>e.actions.includes(c),u=[],d=Me(e.name,s);if(d&&u.push({kind:"cancel",label:"Cancel"}),!d&&r("test")&&a!=="test"&&u.push({kind:"test",label:"Test connection"}),r("connect")&&a!=="connect"&&o!=="connected"&&u.push({kind:"connect",label:"Reconnect"}),!d&&r("sign_in")&&a!=="sign_in"&&o!=="connected"&&u.push({kind:"sign_in",label:"Sign in"}),r("reload")&&u.push({kind:"reload",label:"Reload"}),!d&&r("reauth")&&a!=="reauth"&&u.push({kind:"reauth",label:"Sign in again"}),qe(e)&&a!=="set_key"&&u.push({kind:"set_key",label:e.auth.secret_refs.length>0?"Update key":"Add key"}),r("sign_out")&&u.push({kind:"sign_out",label:"Sign out"}),r("disconnect")&&o==="connected"&&u.push({kind:"disconnect",label:"Disconnect"}),r("copy_setup")&&e.setup_prompt&&u.push({kind:"copy_setup",label:"Copy setup prompt"}),a!=="fix"&&u.push({kind:"open_config",label:"Open config file"}),r("remove"))u.push({kind:"remove",label:"Remove",destructive:!0});else if(!e.source.editable){const c=fn(e);u.push({kind:"remove_elsewhere",label:c?`Remove in ${c}`:"Remove in its own file",hint:c?`Defined in ${c}'s config. Remove it there.`:"Defined in a file this app doesn't write. Remove it there."})}return u}const Ur={attention:"Needs attention",connected:"Connected",ready:"Available"};function yn(e,s=[],n){const a=we(n,e.name),o=Me(e.name,s),r=yt(e,a);if(o&&a.pinnedGroup&&a.pinnedOperationId===o.id)return a.pinnedGroup;if(r==="needs_sign_in"||r==="error")return"attention";const u=Le(e.name,s,a);return Ye(u)&&r!=="connected"||kt(u)&&r!=="connected"?"attention":a.disconnectedAt!==null?"ready":Re(e,s,a)||a.needsSignIn&&r!=="connected"||u?.status==="failed"&&Ie(u)&&r!=="connected"?"attention":r==="connected"||e.status_basis==="stored"&>(e,a)?"connected":o&&o.action!=="test"?"attention":"ready"}function zr(e,s=[],n){return["attention","connected","ready"].map(o=>({id:o,title:Ur[o],rows:e.filter(r=>yn(r,s,n)===o)})).filter(o=>o.rows.length>0)}function Pr(e,s,n=Date.now()){if(!s)return e??{};const a={};for(const o of s.servers){const r=we(e,o.name),u=Me(o.name,s.operations),d=Le(o.name,s.operations,r),c=Ye(d),m=o.status==="connected"&&(o.status_basis==="probe"||o.status_basis==="live"),g=r.holdUntil!==null&&n<r.holdUntil,b=!g&&!c&&r.connectedAt===null&&o.status_basis==="stored"&&o.tool_count_basis==="last_seen"?hn(o.last_seen_at,n):null,k=!c,p=d?.status==="failed"&&Ie(d)&&gn.test(d.message??""),x={connectedAt:m&&!g?n:b!==null?b:k?r.connectedAt:null,connectedToolCount:m&&!g||b!==null?o.tool_count??r.connectedToolCount:k?r.connectedToolCount:null,settledGroup:r.settledGroup,pinnedGroup:u&&r.pinnedOperationId===u.id?r.pinnedGroup:u?r.settledGroup:null,pinnedOperationId:u?u.id:null,needsKey:m?!1:r.needsKey||p,needsSignIn:m||c?!1:r.needsSignIn||o.status==="needs_sign_in",disconnectedAt:m&&!g?null:r.disconnectedAt,holdUntil:g?r.holdUntil:null,lastDecisive:d?Cr(d):null};u||(x.settledGroup=yn(o,s.operations,{...a,[o.name]:x})),a[o.name]=x}return a}const Kr=(e,s)=>e!==null&&s===e,lt="local-operator.settings.integrations.row-memory",xn=(e,s)=>`${e}#${s}`;function Hr(e,s){const n={};if(!s)return n;for(const a of s.servers){const o=e[a.name];o&&(n[xn(a.source.path,a.name)]=o)}return n}function Br(e,s,n){if(!s)return e;let a=null;for(const o of s.servers){if(Object.prototype.hasOwnProperty.call(e,o.name))continue;const r=qr(n[xn(o.source.path,o.name)]);r&&(a=a??{...e},a[o.name]=r)}return a??e}const Vr=["attention","connected","ready"],kn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),vt=e=>typeof e=="number"&&Number.isFinite(e)?e:null,Ut=e=>Vr.includes(e)?e:null,et=e=>{const s=vt(e);return s!==null&&s>=1e12?s:null};function Gr(e){if(!kn(e)||typeof e.id!="string"||typeof e.name!="string")return null;const s=e.action,n=e.status;return s!=="login"&&s!=="logout"&&s!=="reauth"&&s!=="test"||n!=="running"&&n!=="complete"&&n!=="cancelled"&&n!=="failed"?null:{id:e.id,name:e.name,action:s,status:n,created_at:vt(e.created_at)??0,credential_removed:e.credential_removed===!0,...typeof e.message=="string"?{message:e.message}:{}}}function qr(e){if(!kn(e))return null;const s=et(e.connectedAt),n=et(e.disconnectedAt),a=e.needsKey===!0,o=e.needsSignIn===!0,r=Gr(e.lastDecisive);return s===null&&n===null&&!a&&!o&&!r?null:{connectedAt:s,connectedToolCount:vt(e.connectedToolCount),settledGroup:Ut(e.settledGroup),pinnedGroup:Ut(e.pinnedGroup),pinnedOperationId:typeof e.pinnedOperationId=="string"?e.pinnedOperationId:null,needsKey:a,needsSignIn:o,disconnectedAt:n,holdUntil:et(e.holdUntil),lastDecisive:r}}const vn=2e3,zt=8e3;function Yr(e){return e&&(e.servers.some(n=>n.status==="connecting")||e.operations.some(n=>n.status==="running"))?vn:!1}const Wr=/^[A-Za-z0-9_.:-]{1,100}$/,Zr=/:\/\//;function Qr(e,s){const n=e.trim();return n?Wr.test(n)?s.includes(n)?`An integration named ${n} already exists.`:null:"Use letters, numbers, dots, dashes, underscores or colons, with no spaces.":"Give it a name."}function Jr(e){const s=e.trim();if(!s)return"Enter the server's URL.";let n;try{n=new URL(s)}catch{return"Enter a full URL, like https://mcp.example.com/mcp."}return n.protocol!=="https:"&&n.protocol!=="http:"?"The URL must start with https:// or http://.":n.hostname?n.username||n.password?"Remove the username or password from the URL. Keys are added after it's saved.":n.search||n.hash?"Remove the ? or # part of the URL. Keys are added after it's saved.":Zr.test(s.slice(n.protocol.length+2))?"This looks like two URLs pasted together. Enter just one.":null:"The URL needs a host name."}const Xr=e=>e.split(`
|
|
292
|
-
`).map(s=>s.trim()).filter(Boolean);function dt(e,s){const n=!!e?.cold,a=(e?.servers??[]).map(o=>{const r=o.transport==="http",u=o.secret_refs??[],d=o.status==="connected"?"connected":o.status==="connecting"?"connecting":o.status==="auth-required"?"needs_sign_in":"not_started",c=[];d!=="connected"&&c.push("connect"),d==="connected"&&c.push("disconnect"),n||c.push("reload"),r&&o.transport_oauth_supported!==!1&&c.push("sign_in"),u.length>0&&c.push("set_key"),o.owned_scope&&c.push("remove"),o.setup?.text&&c.push("copy_setup");const m=un(o.source);return{id:o.name,name:o.name,scope:o.owned_scope??"global",project_cwd:null,source:{kind:ei(o.source,m,o.owned_scope),path:o.source??"",editable:o.owned_scope!==null,owned_scope:o.owned_scope},transport:r?"remote_url":"local_command",endpoint:{command:null,url:null,endpoint_redacted:!1},status:d,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:n?"stored":"live",auth:{kind:u.length?"api_key":r?"unknown":"none",signed_in:null,secret_refs:u.map(g=>({id:g.id,state:"missing"}))},tool_count:typeof o.tool_count=="number"?o.tool_count:null,tool_count_basis:typeof o.tool_count=="number"?"live":null,actions:c,setup_prompt:o.setup?.text??null}});return{cwd:"",project_scope_available:a.some(o=>o.source.owned_scope==="project"),global_path:"",project_path:null,status_source:n?"config":"live",session_id:s,servers:a,operations:(e?.operations??[]).map(o=>({...o}))}}const ei=(e,s,n)=>s==="Claude Code"?"claude-code":s==="Cursor"?"cursor":s==="VS Code"?"vscode":s==="Codex CLI"?"codex":n?"local-operator":e?"project-mcp-json":"local-operator",Pt={invalid_config:"That configuration isn't valid. Check the command or the URL, then try again.",operation_unavailable:"That sign-in or test isn't running any more. Try again.",exists:"An integration with this name already exists. Choose another name.",not_owned:"It's defined in another tool's config, so it can't be changed here. Edit it in that file.",project_scope_unavailable:"There's no separate project config here, so it can only be added globally.",unknown_server:"It no longer exists. The list has been refreshed.",oauth_unsupported:"It doesn't use browser sign-in.",grant_running:"A sign-in or test is already running. Wait for it to finish, or cancel it.",too_many_operations:"Too many sign-ins and tests are waiting. Try again in a moment.",write_failed:"The config file couldn't be written. Check that it isn't read-only.",mcp_starting:"Integrations are still starting. Try again in a moment.",mcp_control_refused:"The server refused it, so nothing was changed."},ti="The server refused it, so nothing was changed. Try again.";function Pe(e,s,n){if(s instanceof pt&&s.status===409){const a=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(Pt,s.code)?Pt[s.code]:ti;return`${zn[e]}. ${a}`}return Pn(e,s,n).message}const ni="New chats can use it right away. Open chats pick it up when you start a new chat or reload integrations there.",si="Most services give you a URL. Use Local command when their setup says npx or uvx.",ai=({existingNames:e,projectScopeAvailable:s,projectLabel:n,onSubmit:a,onCancel:o,initial:r})=>{const[u,d]=i.useState(r?.name??""),[c,m]=i.useState(r?.mode??"command"),[g,b]=i.useState(r?.command??""),[k,p]=i.useState(r?.args??""),[x,L]=i.useState(r?.url??""),[S,H]=i.useState("global"),[_,$]=i.useState(r?.touched?{name:!0,command:!0,url:!0}:{}),[I,M]=i.useState(!!r?.touched),[N,G]=i.useState(!1),[P,q]=i.useState(null),K=i.useRef(null),X=i.useRef(null),A=i.useRef(null);i.useEffect(()=>{K.current?.focus()},[]);const T=Qr(u,e),V=c==="command"&&!g.trim()?"Enter the command to run.":null,z=c==="url"?Jr(x):null,O=C=>I||_[C],ee=async C=>{if(C.preventDefault(),M(!0),T||V||z){T?K.current?.focus():V?X.current?.focus():A.current?.focus();return}G(!0),q(null);const Z=s?S:"global",Q=c==="command"?{name:u.trim(),scope:Z,mode:c,command:g.trim(),args:Xr(k)}:{name:u.trim(),scope:Z,mode:c,url:x.trim()},J=await a(Q);G(!1),q(J)},R=(C,Z,Q)=>Z&&O(Q)?t.jsx("p",{id:C,className:"text-body-sm text-danger",children:Z}):null,ie=C=>C.preventDefault();return t.jsxs("form",{noValidate:!0,"aria-label":"Add integration",className:"flex flex-col gap-4 rounded-lg bg-surface p-4",onSubmit:C=>void ee(C),onKeyDown:C=>{C.key==="Escape"&&(C.stopPropagation(),o())},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"integration-add-name",children:"Name"}),t.jsx(Ce,{ref:K,id:"integration-add-name",value:u,placeholder:"e.g. notion",autoComplete:"off","aria-invalid":!!(T&&O("name")),"aria-describedby":T&&O("name")?"integration-add-name-error":void 0,onChange:C=>d(C.target.value),onBlur:()=>$(C=>({...C,name:!0}))}),R("integration-add-name-error",T,"name")]}),t.jsxs(Et,{value:c,onValueChange:C=>m(C==="url"?"url":"command"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-transport-label",className:"font-medium text-body-sm text-ink",children:"How it runs"}),t.jsxs(Lt,{"aria-labelledby":"integration-add-transport-label",children:[t.jsx(ze,{value:"command","data-integration-transport":"command",children:"Local command"}),t.jsx(ze,{value:"url","data-integration-transport":"url",children:"Remote URL"})]}),t.jsx("p",{className:"text-ink-dim text-meta",children:si}),t.jsxs(It,{value:"command",className:"mt-0 flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"integration-add-command",children:"Command"}),t.jsx(Ce,{ref:X,id:"integration-add-command",value:g,placeholder:"e.g. npx",autoComplete:"off",className:"font-mono","aria-invalid":!!(V&&O("command")),"aria-describedby":V&&O("command")?"integration-add-command-error":void 0,onChange:C=>b(C.target.value),onBlur:()=>$(C=>({...C,command:!0}))}),R("integration-add-command-error",V,"command")]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs(pe,{htmlFor:"integration-add-args",children:["Arguments"," ",t.jsx("span",{className:"font-normal text-ink-dim",children:"(one per line)"})]}),t.jsx(cn,{id:"integration-add-args",value:k,rows:2,className:"font-mono",onChange:C=>p(C.target.value)})]})]}),t.jsx(It,{value:"url",className:"mt-0 flex flex-col gap-4",children:t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"integration-add-url",children:"URL"}),t.jsx(Ce,{ref:A,id:"integration-add-url",type:"url",value:x,placeholder:"https://mcp.example.com/mcp",autoComplete:"off",className:"font-mono","aria-invalid":!!(z&&O("url")),"aria-describedby":z&&O("url")?"integration-add-url-error":"integration-add-url-help",onChange:C=>L(C.target.value),onBlur:()=>$(C=>({...C,url:!0}))}),R("integration-add-url-error",z,"url")??t.jsx("p",{id:"integration-add-url-help",className:"text-ink-dim text-meta",children:"If it needs a sign-in or a key, you'll be asked after it's added."})]})})]}),s?t.jsxs(Et,{value:S,onValueChange:C=>H(C==="project"?"project":"global"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-scope-label",className:"font-medium text-body-sm text-ink",children:"Available in"}),t.jsxs(Lt,{"aria-labelledby":"integration-add-scope-label",children:[t.jsx(ze,{value:"global","data-integration-scope":"global",children:"All chats"}),t.jsx(ze,{value:"project","data-integration-scope":"project",children:"This project"})]}),n?t.jsx("p",{className:"text-ink-dim text-meta",children:S==="project"?`Only chats working in ${n}.`:"Every chat, in any folder."}):null]}):null,P?t.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:P}):null,t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("p",{className:oe("text-body-sm text-ink-dim"),children:ni}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(D,{type:"button",variant:"ghost",size:"md",onMouseDown:ie,onClick:o,children:"Cancel"}),t.jsxs(D,{type:"submit",variant:"primary",size:"md",disabled:N,onMouseDown:ie,children:[N?t.jsx(re,{size:"xs"}):null,"Add integration"]})]})]})]})},oi=4;function ri(e){return e.rowMoving?e.now+e.windowMs:Math.max(e.hold.until,e.lastMovingAt+e.windowMs)}function ii(e){return e.now>e.hold.until||e.hold.reanchors>=oi?"drop":e.hold.landedOn.isConnected&&(!e.candidate||e.candidate===e.hold.landedOn)?"settled":e.active&&e.active!==e.body&&e.active!==e.hold.landedOn?"drop":e.candidate?.isConnected?"restore":"drop"}function ci(e){const s=ri({hold:e.hold,now:e.now,windowMs:e.windowMs,rowMoving:e.rowMoving,lastMovingAt:e.lastMovingAt});if(e.now>s)return{hold:null,land:null};const n=e.hold.landedOn??null,a=e.candidate;if(!a)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:n},land:null};if(!n)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},land:a};const o=ii({hold:{until:s,reanchors:e.hold.reanchors,landedOn:n},candidate:a,active:e.active,body:e.body,now:e.now});if(o==="settled")return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:n},land:null};if(o==="drop")return{hold:null,land:null};const r=!n.isConnected;return{hold:{until:r?e.now+e.windowMs:s,reanchors:r?e.hold.reanchors+1:e.hold.reanchors,landedOn:a},land:a}}function li(e){const{row:s,target:n}=e;return!s||!n||typeof n.nodeType!="number"?!1:!s.contains(n)}const Kt=250;function Ht(e){return e?!e.disabled:!1}function di(e){return Ht(e.primary)?e.primary??null:Ht(e.overflow)?e.overflow??null:null}function ui(e){return e.verdict==="finished"?null:e.watchMs}const bn="key";function mi(e){const{name:s,keyless:n,freeName:a,names:o,values:r,replace:u,canReplace:d}=e;if(n){const c=ut(s,a);return{values:{[c]:(r[bn]??"").trim()},confirmedReplace:u&&d?[c]:[],header:a.trim()}}return{values:Object.fromEntries(o.map(c=>[c,(r[c]??"").trim()])),confirmedReplace:u&&d?o:[],header:void 0}}function ut(e,s){const n=Bt(e),a=Bt(s);if(!a)return"";const o=[n,a].filter(Boolean).join("_"),r=/^[A-Za-z_]/.test(o)?o:`K_${o}`;if(r.length<=tt)return r;const u=hi(n),d=tt-a.length-u.length-2,c=[n.slice(0,Math.max(d,0)),u,a].filter(Boolean).join("_");return c.length<=tt?c:c.slice(-128)}const tt=128,Bt=e=>e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),hi=e=>{let s=2166136261;for(let n=0;n<e.length;n+=1)s^=e.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s.toString(36).toUpperCase().slice(0,5)},pi=({name:e,keyNames:s,keyless:n=!1,savedKeys:a=[],saving:o,failure:r,onSave:u,onClose:d})=>{const[c,m]=i.useState({}),[g,b]=i.useState(!1),[k,p]=i.useState(""),x=n?[ut(e,k)]:[...s],L=n?[bn]:x,S=(n?ut(e,k).length>0:!0)&&L.every(_=>(c[_]??"").trim()),H=x.some(_=>a.includes(_));return t.jsx(en,{open:!0,onClose:d,maxWidth:"xs",title:n||s.length===1?`Add the key for ${e}`:`Add keys for ${e}`,actions:t.jsxs(t.Fragment,{children:[t.jsx(at,{onClick:d,children:"Cancel"}),t.jsx(ot,{disabled:!S||o,onClick:()=>{const _=mi({name:e,keyless:n,freeName:k,names:x,values:c,replace:g,canReplace:H});u(_.values,_.confirmedReplace,_.header)},children:o?"Saving…":"Save and test"})]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[t.jsx("p",{className:"-mx-1.5",children:n?"Keys are saved encrypted on this computer. This one is stored under a name derived from this integration, so no other server shares it.":"Keys are saved encrypted on this computer. Other integrations that use the same key name share it."}),n?t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:"integration-key-name",children:"The header this server wants the key in"}),t.jsx(Ce,{id:"integration-key-name",autoComplete:"off",placeholder:"e.g. Authorization or X-Api-Key",value:k,onChange:_=>p(_.target.value)}),t.jsx("p",{className:"-mx-1.5 text-ink-dim text-meta",children:"This server declares no key of its own, so Local Operator adds one to its config for you."})]}):null,L.filter(_=>n!==!0||_.trim().length>0).map(_=>t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(pe,{htmlFor:`integration-key-${_}`,className:"font-mono",children:n?"Key":_}),t.jsx(Ce,{id:`integration-key-${_}`,type:"password",autoComplete:"off",value:c[_]??"",onChange:$=>m(I=>({...I,[_]:$.target.value}))})]},_)),H?t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(Fs,{id:"integration-key-replace",checked:g,onCheckedChange:_=>b(_===!0)}),t.jsx(pe,{htmlFor:"integration-key-replace",className:"font-normal",children:pn(x.length)})]}):null,r?t.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:r}):null]})})},fi={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},gi={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"},Vt={Ready:Ir,"Not connected":Or},yi=({row:e,operations:s,memories:n,now:a,projectScopeAvailable:o,highlighted:r=!1,rowRef:u,primaryRef:d,overflowRef:c,pending:m,failure:g,confirm:b,onPrimary:k,onOverflow:p,onConfirm:x,onCancelConfirm:L})=>{const S=Tr(e,s,n,a),H=r&&S.tone==="danger"?"text-ink":gi[S.tone],_=xt(e,s,n),$=$r(e,s,n),I=Dr(e,o),M=$.findIndex(N=>N.kind==="remove"||N.kind==="remove_elsewhere");return t.jsxs("li",{ref:u,"data-integration":e.name,"data-status":e.status,className:oe("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",r&&"bg-row-selected"),onKeyDown:N=>{!b||N.key!=="Escape"||(N.stopPropagation(),L())},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:S.busy?t.jsx(re,{size:"xs"}):t.jsx("span",{"aria-hidden":"true","data-tone":S.tone,className:oe("size-2 rounded-full",fi[S.tone])})}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsx("span",{className:"truncate font-medium text-body text-ink",title:e.name,children:e.name}),t.jsx("span",{className:"truncate text-ink-dim text-meta",children:I.map((N,G)=>t.jsxs("span",{children:[G>0?" · ":null,N.startsWith("Imported from")&&e.source.path?t.jsx(Te,{content:Ns(e.source.path),children:t.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:N})}):N]},N))})]}),Vt[S.label]?t.jsx(Te,{content:Vt[S.label],children:t.jsx("span",{className:oe("shrink-0 text-body-sm",H),children:S.label})}):t.jsx("span",{className:oe("shrink-0 text-body-sm",H),children:S.label}),_?t.jsxs(D,{ref:d,variant:_.variant??"secondary",size:"sm","aria-label":`${_.label} ${e.name}`,disabled:m,"data-integration-action":_.kind,onClick:()=>k(_),children:[m?t.jsx(re,{size:"xs"}):null,_.label]}):null,t.jsxs(Ds,{children:[t.jsx($s,{asChild:!0,children:t.jsx(D,{ref:c,variant:"ghost",size:"icon-sm","aria-label":`More actions for ${e.name}`,disabled:m,children:t.jsx(Kn,{"aria-hidden":"true"})})}),t.jsx(Us,{align:"end",className:"min-w-48",children:$.map((N,G)=>t.jsx(xi,{item:N,separated:G===M&&G>0,onSelect:()=>p(N)},N.kind))})]})]}),S.detail?t.jsx("p",{className:oe("pl-7 text-body-sm",S.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:S.detail}):null,g?t.jsx("p",{className:oe("pl-7 text-body-sm",r?"text-ink":"text-danger"),role:"alert",children:g}):null,b?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-7",children:[t.jsx("span",{className:"text-body-sm text-ink",children:b.kind==="remove"?`Remove ${e.name}?`:`Sign out of ${e.name}?`}),t.jsx("span",{className:"text-body-sm text-ink-muted",children:b.kind==="remove"?`Agents in every chat lose access to ${e.name}.`:e.auth.kind==="oauth"?"The saved sign-in is removed too.":"Its saved credential is removed too."}),t.jsx(D,{variant:"danger",size:"sm",onClick:x,"data-integration-confirm":b.kind,children:b.kind==="remove"?"Remove":"Sign out"}),t.jsx(D,{variant:"ghost",size:"sm",onClick:L,children:"Keep"})]}):null]})},xi=({item:e,separated:s,onSelect:n})=>t.jsxs(t.Fragment,{children:[s?t.jsx(zs,{}):null,e.kind==="remove_elsewhere"?t.jsxs(Ot,{disabled:!0,className:"flex-col items-start gap-0.5",children:[t.jsx("span",{children:e.label}),t.jsx("span",{className:"text-meta text-ink-dim",children:e.hint})]}):t.jsx(Ot,{destructive:e.kind==="remove",onSelect:n,"data-integration-menu":e.kind,children:e.label})]});function ki(e,s,n){return!s||s.status==="running"?s?.browser_opened===!0?{message:`Your browser opened. Approve access to ${e} there, then come back here.`,tone:"progress",link:s.authorization_url??null}:s?.browser_opened===!1?{message:s.authorization_url?"Your browser didn't open. Open this link to approve access:":"Your browser didn't open, and no link was provided. Cancel and try again.",tone:"progress",link:s.authorization_url??null}:{message:`Waiting for you to approve access to ${e}…`,tone:"progress",link:s?.authorization_url??null}:s.status==="complete"?{message:`Signed in to ${e}. Agents can use it now.`,tone:"success",link:null}:s.status==="cancelled"?{message:"Sign-in cancelled.",tone:"failure",link:null,reason:null,nextStep:"Press Try again when you are ready."}:{message:"Sign-in didn't finish.",tone:"failure",link:null,reason:Lr(s.message,n)??"The server didn't say why.",nextStep:vi(s.message??null,n)}}function vi(e,s){const n=(e??"").toLowerCase();return n.includes("redirect")?s?"This server may not accept sign-ins from Local Operator. Check the server's settings, or add a key instead.":"This server may not accept sign-ins from Local Operator. Check the server's settings, then try again.":n.includes("no oauth")||n.includes("authorization server")?s?"This server doesn't publish a browser sign-in. Add its key instead.":"This server doesn't publish a browser sign-in. Check the server's settings, then try again.":n.includes("network")||n.includes("connect")?"Check the server's URL and your network, then try again.":"Check the server's settings, then try again."}function bi(e,s){return e.kind==="ready"?"ready":e.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const wi=({name:e,action:s,keyRoute:n,phase:a,onStart:o,onCancel:r,onOpenLink:u,onClose:d})=>{const c=a.kind==="running"?a.operation:null,m=a.kind==="running"?ki(e,c,n):null,g=a.kind==="starting"||a.kind==="running"&&m?.tone==="progress",b=m&&m.tone!=="progress",k=i.useRef(null),p=i.useRef(!1),x=bi(a,m);i.useEffect(()=>{if(!p.current){p.current=!0;return}x&&k.current?.focus()},[x]);const L=()=>d(m?.tone==="success"?"signed-in":"dismissed");return t.jsx(en,{open:!0,onClose:L,maxWidth:"xs",fullWidth:!0,title:`Sign in to ${e}`,dialogProps:{onOpenAutoFocus:S=>{S.preventDefault(),k.current?.focus()}},actions:t.jsxs(t.Fragment,{children:[g&&c?t.jsx(at,{ref:k,onClick:()=>r(c.id),children:"Cancel sign-in"}):t.jsx(at,{ref:a.kind==="ready"?void 0:k,onClick:L,children:m?.tone==="success"?"Done":"Close"}),a.kind==="ready"?t.jsx(ot,{ref:k,onClick:o,children:"Continue in browser"}):null,a.kind==="refused"||m?.tone==="failure"?t.jsx(ot,{ref:m?.tone==="failure"?k:void 0,onClick:o,children:"Try again"}):null]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted","aria-live":"polite",children:[a.kind==="ready"?t.jsxs("p",{className:"-mx-1.5",children:["Local Operator opens your browser so you can approve access to"," ",e,".",s==="reauth"?" This replaces the sign-in it has now.":""]}):null,a.kind==="starting"?t.jsxs("p",{className:"-mx-1.5 flex items-center gap-2",children:[t.jsx(re,{size:"xs"}),"Starting sign-in…"]}):null,m?t.jsxs("div",{className:"flex flex-col gap-1",role:b?"status":void 0,children:[t.jsxs("p",{className:(m.tone==="success","-mx-1.5 flex items-start gap-2 text-ink"),children:[m.tone==="progress"?t.jsx(re,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?t.jsx(Ps,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-danger"}):null,t.jsx("span",{children:m.message})]}),m.reason?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.reason}):null,m.nextStep?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.nextStep}):null]}):null,m?.link&&m.tone==="progress"?t.jsxs("div",{className:"flex flex-col items-start gap-1",children:[t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink-dim text-mono-sm",title:m.link,children:m.link}),t.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"Copy the sign-in link",title:"Copy the sign-in link",onClick:()=>{navigator.clipboard.writeText(m.link??"").then(()=>rt("Sign-in link copied.")).catch(()=>{})},children:t.jsx(Hn,{"aria-hidden":"true"})})]}),t.jsx(D,{variant:"link",size:"sm",onClick:()=>u(m.link??""),children:"Open the sign-in page"})]}):null,a.kind==="refused"?t.jsx("p",{className:"text-danger",role:"alert",children:a.message}):null]})})},ji={catalog:(e,s)=>["desktop","mcp-catalog",e??"",s??""],all:["desktop","mcp-catalog"]},_i=async(e,s)=>(await be({op:"mcp.catalog",...e?{cwd:e}:{},...s?{sessionId:s}:{}})).data,Ni=async(e,s)=>(await be({op:"mcp.catalog.control",...e?{cwd:e}:{},control:s})).data,Si=async(e,s,n,a,o)=>(await be({op:"mcp.catalog.credentials",...e?{cwd:e}:{},name:s,values:n,confirmedReplace:a,...o?{header:o}:{}})).data,Ci=e=>e.reduce((s,n)=>s?(n.updated_at??0)>(s.updated_at??0)?n:s:n,null),Mi=/^[A-Za-z]:[\\/]/,Ve=e=>{const s=e?.trim();return s&&(s.startsWith("/")||Mi.test(s))?s:null};function Ai(e){const o=e?.payload?.frontend?.snapshot?.cwd;return typeof o=="string"&&o.trim()?o:null}const Ee="local-operator.settings.integrations.last-cwd";function Ri(e,s,n=typeof localStorage>"u"?null:localStorage){const a=Ve(s);if(!(!e||!a||!n))try{const o=n.getItem(Ee),r=o?JSON.parse(o):{};if(r[e]===a)return;n.setItem(Ee,JSON.stringify({...r,[e]:a}))}catch{}}const wn=()=>typeof localStorage>"u"?null:localStorage;function jn(e=wn()){if(!e)return{};try{const s=e.getItem(lt);if(!s)return{};const n=JSON.parse(s);return!n||typeof n!="object"||Array.isArray(n)?{}:n}catch{return{}}}const Gt=256;function Ti(e,s=wn()){if(s)try{const n={...jn(s),...e},a=Object.keys(n);if(a.length>Gt){const o={};for(const r of a.slice(-Gt))o[r]=n[r];s.setItem(lt,JSON.stringify(o));return}s.setItem(lt,JSON.stringify(n))}catch{}}function qt(e,s,n){return e==="saved"?null:e==="replace_confirmation_required"?`A saved value already exists for this key. Tick “${pn(Object.keys(n).length)}” to overwrite it.`:e==="invalid_target"?"That header can't carry this key. It may already be set on the server, or belong to the transport - try a different header name. Nothing was saved.":`Not saved: ${(s.length?s:Object.keys(n)).join(", ")}. The encrypted store may be locked.`}function Ei(e,s=typeof localStorage>"u"?null:localStorage){if(!(!e||!s))try{const n=s.getItem(Ee);if(!n)return;const a=JSON.parse(n);if(!(e in a))return;const o={...a};delete o[e],s.setItem(Ee,JSON.stringify(o))}catch{}}const Li=e=>!!(e&&typeof e=="object"&&"code"in e&&e.code==="invalid_cwd"),Ii=(e,s)=>s!==null&&e===s?null:e;function Oi(e,s=typeof localStorage>"u"?null:localStorage){if(!e||!s)return null;try{const n=s.getItem(Ee);if(!n)return null;const o=JSON.parse(n)[e];return typeof o=="string"?o:null}catch{return null}}const Fi=e=>e.action==="disconnect"?"disconnected":"connected";function Di(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"connect":case"disconnect":case"reload":return null;case"test":return{action:"test",name:e.name};default:return{...e,confirmed:!0}}}function $i(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"test":case"connect":return{action:"connect",name:e.name};case"reload":return{action:"reload",name:e.name};case"add":return e;case"remove":return{...e,confirmed:!0};default:return{action:e.action,name:e.name,confirmed:!0}}}function Ui({sessionId:e}){const s=Ss(),n=Tt(s.data,"mcp_catalog"),a=Tt(s.data,"mcp"),o=n?"catalog":a?"session":null,[r,u]=i.useState(null),d=rn(),c=Ke(h=>h.sessions),m=Ke(h=>h.fetchSessions),g=Ke(h=>h.loading),b=i.useMemo(()=>c.find(h=>h.session_id===e)??null,[c,e]),k=i.useMemo(()=>o==="session"&&!e?Ci(c):null,[o,e,c]),p=o==="session"?e??k?.session_id??null:null;i.useEffect(()=>{o!=="session"||e||c.length>0||m(Cs)},[o,e,c.length,m]);const x=o==="catalog"?Ve(b?.cwd):null,L=o==="catalog"&&!!e&&x===null,S=Se({queryKey:["desktop","session-cwd",e??""],queryFn:()=>be({op:"sessions.get",sessionId:e??""}),enabled:L,staleTime:Number.POSITIVE_INFINITY,retry:!1}),H=L&&!S.isFetched,_=x??Ve(Ai(S.data))??(S.isFetched?Ve(Oi(e)):null),$=Ii(_,r),I=o==="catalog"?$:null,M=o==="catalog"?e??null:null,N=ji.catalog(I,M);i.useEffect(()=>{o!=="catalog"||!e||!I||Ri(e,I)},[o,e,I]);const G=i.useRef(0),[P,q]=i.useState(0),K=i.useRef(null),X=i.useCallback((h,w)=>{const v=Date.now()+zt;G.current=v,K.current={name:h,expect:w},q(v)},[]),A=i.useCallback(h=>Date.now()<G.current?vn:Yr(h),[]),T=Se({queryKey:N,queryFn:()=>_i(I,M),enabled:o==="catalog"&&!H,staleTime:1e4,refetchInterval:h=>A(h.state.data)}),V=Li(T.error);i.useEffect(()=>{!V||!_||r===_||(u(_),Ei(e))},[V,_,r,e]);const z=Se({queryKey:it.list(p??""),queryFn:()=>Bn(p??""),enabled:o==="session"&&!!p,staleTime:1e4,refetchInterval:h=>A(h.state.data?dt(h.state.data,p??""):void 0)}),O=i.useMemo(()=>{if(o==="catalog")return T.data;if(o==="session"&&z.data&&p)return dt(z.data,p)},[o,T.data,z.data,p]),ee=i.useCallback(()=>zi({queryClient:d,route:o,catalogKey:N,sessionId:p}),[o,N,d,p]);i.useEffect(()=>{if(!P)return;const h=K.current;if(!h)return;const w=O?.servers.find(U=>U.name===h.name);!w||!(h.expect==="connected"?w.status==="connected":w.status_basis==="live"&&w.status!=="connected")||(G.current=0,K.current=null,q(0))},[O,P]);const R=i.useRef({}),[ie,C]=i.useState(0),Z=i.useMemo(()=>(R.current=Pr(Br(R.current,O,jn()),O),R.current),[O,ie]),Q=i.useRef("");i.useEffect(()=>{const h=Hr(Z,O);if(!Object.keys(h).length)return;const w=JSON.stringify(h);w!==Q.current&&(Q.current=w,Ti(h))},[Z,O]);const J=i.useCallback(h=>{const w=we(R.current,h);w.needsKey||(R.current={...R.current,[h]:{...w,needsKey:!0}},C(v=>v+1))},[]),Y=i.useCallback(h=>{if(h.action!=="disconnect"&&h.action!=="connect"&&h.action!=="reload")return;const w=we(R.current,h.name),v=Date.now()+zt,U=h.action==="disconnect"?{...w,connectedAt:null,disconnectedAt:Date.now(),holdUntil:v}:{...w,disconnectedAt:null,holdUntil:v};R.current={...R.current,[h.name]:U},X(h.name,Fi(h)),C(F=>F+1)},[X]),W=i.useCallback(async h=>{if(o==="catalog"){const w=Di(h);if(!w)return null;try{const v=await Ni(I,w);return d.setQueryData(N,v),Y(h),v.operation?.id??null}catch(v){throw v instanceof pt&&v.status===409&&d.invalidateQueries({queryKey:N}),v}}if(o==="session"&&p){const w=await be({op:"mcp.control",sessionId:p,control:$i(h)});Y(h);const v=it.list(p),U=w?.data;return U&&"servers"in U&&Array.isArray(U.servers)?(d.setQueryData(v,U),null):(d.invalidateQueries({queryKey:v}),U&&"id"in U&&typeof U.id=="string"?U.id:null)}return null},[o,I,N,d,p,Y]),fe=i.useCallback(async h=>{if(o==="catalog"&&M&&(h.action==="connect"||h.action==="disconnect"||h.action==="reload")){try{await be({op:"mcp.control",sessionId:M,control:{action:h.action,name:h.name,...h.action==="disconnect"?{confirmed:!0}:{}}})}catch(w){throw d.invalidateQueries({queryKey:N}),w}return Y(h),await d.invalidateQueries({queryKey:N}),null}return W(h)},[o,M,d,N,W,Y]),je=i.useCallback(async(h,w,v,U)=>{if(o==="catalog"){const F=await Si(I,h,w,v,U);if(F.catalog&&d.setQueryData(N,F.catalog),F.code!=="saved")return{saved:!1,message:qt(F.code,F.failed_ids,w)};try{await W({action:"test",name:h})}catch{}return{saved:!0,message:null}}if(o==="session"&&p){const F=await be({op:"mcp.credentials.store",sessionId:p,name:h,values:w,confirmedReplace:v});if(F.data?.code!=="saved")return{saved:!1,message:qt(F.data?.code,F.data?.failed_ids??[],w)};try{await W({action:"connect",name:h})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[o,I,N,d,W,p]),de=o==="catalog"?T:z,ge=i.useCallback(()=>{de.refetch()},[de]);return{enabled:o!==null,route:o,sessionId:o==="catalog"?M:p,borrowed:k,noConversation:o==="session"&&!p&&!g,document:O,isLoading:s.isLoading||o==="catalog"&&(H||T.isLoading)||o==="session"&&(p?z.isLoading:g),isError:de.isError,folderUnavailable:Kr(r,_),refetch:ge,readDocument:ee,control:fe,storeKeys:je,memories:Z,markNeedsKey:J}}function zi(e){if(e.route==="catalog")return e.queryClient.getQueryData(e.catalogKey);if(e.route==="session"&&e.sessionId){const s=e.queryClient.getQueryData(it.list(e.sessionId));return s?dt(s,e.sessionId):void 0}}const Pi=(e,s)=>{const n=e?.trim();if(!n)return null;const a=Yn(n,s);return a.kind==="auth"?{kind:"matched",name:a.name,unresolved:null}:{kind:"miss",asked:n}},Ki=6,nt="Integrations",Hi="Let agents use your tools and accounts, like Notion, Linear or GitHub.",Bi={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},Vi=({sessionId:e,sectionRef:s,highlightServer:n})=>{const a=Ui({sessionId:e}),{document:o,control:r,readDocument:u}=a,d=Vn(),c=o?.servers??[],m=o?.operations??[],g=o?.project_scope_available??!1,[b,k]=i.useState(!1),[p,x]=i.useState(""),[L,S]=i.useState(null),[H,_]=i.useState({}),[$,I]=i.useState(null),[M,N]=i.useState(null),[G,P]=i.useState({kind:"ready"}),[q,K]=i.useState(null),[X,A]=i.useState(null),[T,V]=i.useState(!1),z=i.useRef({}),O=i.useRef({}),ee=i.useRef({}),R=i.useRef(0),ie=i.useRef(null),C=i.useRef(null),Z=i.useRef(null),[Q,J]=i.useState(null),[Y,W]=i.useState(null),[fe,je]=i.useState(null),de=i.useCallback(()=>{const l=Z.current;Z.current=null,N(null),K(null),window.setTimeout(()=>{l?.isConnected&&l.focus()},0)},[]),ge=i.useCallback(l=>{const f=window.document.activeElement;Z.current=f instanceof HTMLElement?f:null,N(l)},[]),h=i.useCallback((l,f)=>{W({name:l,waitForSignIn:f==="signed-in",until:Date.now()+Ae,reanchors:0}),de()},[de]),w=i.useMemo(()=>Pi(n,c.map(l=>l.name)),[n,c]),v=w?.kind==="matched"?w.name:null,U=i.useRef(null),F=i.useRef(null),te=p.trim().toLowerCase(),B=i.useMemo(()=>te?c.filter(l=>l.name.toLowerCase().includes(te)):c,[c,te]),_e=i.useMemo(()=>zr(B,m,a.memories),[B,m,a.memories]),ue=M?.kind==="sign_in"?c.find(l=>l.name===M.name)??null:null;i.useEffect(()=>{!v||F.current===v||!p||x("")},[v,p]),i.useEffect(()=>{!v||F.current===v||B.some(l=>l.name===v)&&(F.current=v,U.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[v,B]),i.useEffect(()=>{if(!q)return;const l=m.find(f=>f.id===q)??null;P({kind:"running",operation:l})},[m,q]);const ce=m.some(l=>l.status==="running"),ye=l=>{const f=window.document.activeElement;f&&f!==window.document.body&&f.isConnected||W({name:l,waitForSignIn:!1,until:Date.now()+Ae,reanchors:0})},ne=async(l,f,j)=>{S(l),_(({[l]:xe,...ke})=>ke);let E=null,me=!1;try{E=await j()}catch(xe){me=!0,_(ke=>({...ke,[l]:Pe(Bi[f]??"status",xe,ce)}))}finally{S(null),f!=="sign_out"&&(f!=="remove"||me)&&ye(l)}return{operationId:E,failed:me}},We=l=>c.find(f=>f.name===l),Oe=l=>{l.source.path&&Wn(l.source.path)},Ze=async(l,f)=>{P({kind:"starting"}),K(null);try{const j=await r({action:f,name:l});j?K(j):P({kind:"running",operation:null})}catch(j){j instanceof pt&&j.code==="oauth_unsupported"&&a.markNeedsKey(l),P({kind:"refused",message:Pe("grant",j,ce)})}},Fe=(l,f)=>{switch(f.kind){case"sign_in":case"reauth":{const j=m.find(E=>E.name===l.name&&E.status==="running");j&&Ie(j)?(P({kind:"running",operation:j}),K(j.id)):(P({kind:"ready"}),K(null)),ge({kind:"sign_in",name:l.name,action:f.kind==="reauth"?"reauth":"login"});return}case"set_key":A(null),ge({kind:"key",name:l.name,keyNames:l.auth.secret_refs.map(j=>j.id)});return;case"fix":Oe(l);return;case"sign_out":I({name:l.name,kind:"sign_out"});return;default:{const j=f.kind;ne(l.name,j,()=>r({action:j,name:l.name}))}}},bt=(l,f)=>{switch(f.kind){case"remove":case"sign_out":I({name:l.name,kind:f.kind});return;case"sign_in":case"reauth":case"set_key":Fe(l,{kind:f.kind,label:f.label});return;case"open_config":Oe(l);return;case"copy_setup":navigator.clipboard.writeText(l.setup_prompt??"").then(()=>rt("Setup steps copied. Paste them into a chat.")).catch(()=>{});return;case"cancel":{const j=m.find(E=>E.name===l.name&&E.status==="running");j&&ne(l.name,"cancel",()=>r({action:"cancel",operationId:j.id}));return}case"test":case"connect":case"disconnect":case"reload":{const j=f.kind;ne(l.name,j,()=>r({action:j,name:l.name}));return}default:return}},De=(l,f)=>{if(I(null),f==="remove"){const j=l.source.owned_scope;if(!j)return;const E=B.findIndex(me=>me.name===l.name);ne(l.name,"remove",()=>r({action:"remove",name:l.name,scope:j})).then(({operationId:me,failed:xe})=>{xe||me!==null||(rt(`Removed ${l.name}.`),E>=0&&je({index:E}))});return}ne(l.name,"sign_out",()=>r({action:"logout",name:l.name})).then(()=>{W({name:l.name,waitForSignIn:!1,until:Date.now()+Ae,reanchors:0})})},$e=async l=>{try{return await r({action:"add",name:l.name,scope:l.scope,...l.mode==="command"?{command:l.command,args:l.args}:{url:l.url}}),k(!1),J(l.name),null}catch(f){return Pe("add",f,!1)}},wt=t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-heading text-ink",children:nt}),t.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:Hi})]}),a.enabled&&c.length>0&&!b?t.jsxs(D,{ref:ie,variant:"secondary",size:"sm",onClick:()=>k(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(Mt,{"aria-hidden":"true"}),"Add integration"]}):null]});if(!a.enabled&&!a.isLoading)return t.jsx(se,{title:nt,titleComponent:wt,sectionRef:s,children:t.jsx(le,{variant:"warning",children:"Integrations need a newer Local Operator backend. Update it and restart the app to manage them here."})});const jt=t.jsx(ai,{existingNames:c.map(l=>l.name),projectScopeAvailable:g,projectLabel:o?.cwd?qi(o.cwd):null,onSubmit:$e,onCancel:()=>{k(!1),window.setTimeout(()=>ie.current?.focus(),0)}}),_t=M?We(M.name):void 0,_n=Object.entries(H).filter(([l])=>!c.some(f=>f.name===l)),Nn=l=>_(({[l]:f,...j})=>j);i.useEffect(()=>{if(!Q)return;const l=z.current[Q];if(!l){c.some(f=>f.name===Q)&&(O.current[Q]?.focus(),J(null));return}l.focus(),J(null)},[Q,c]),i.useEffect(()=>{if(!fe)return;const f=B[Math.min(fe.index,B.length-1)]??B.at(-1);if(f){const j=z.current[f.name]??O.current[f.name];if(!j)return;j.focus()}else ie.current?.focus();je(null)},[fe,B]);const Qe=i.useCallback((l,f)=>{const j=u()??o,E=j?.servers.find(Sn=>Sn.name===l.name),me=j?.operations??[],xe=E?E.status==="connecting"||Me(E.name,me)!==null:!1;xe&&E&&(R.current=f);const ke=E?xt(E,me,a.memories):null;if(E&&l.waitForSignIn&&(ke?.kind==="sign_in"||ke?.kind==="reauth"))return"kept";const Ne=ci({hold:l,now:f,windowMs:Ae,rowMoving:xe,lastMovingAt:R.current,candidate:E?di({primary:ke?z.current[E.name]:null,overflow:O.current[E.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!Ne.hold)return W(null),"finished";if(!Ne.land)return"kept";W({name:l.name,waitForSignIn:!1,until:Ne.hold.until,landedOn:Ne.land,reanchors:Ne.hold.reanchors});const Nt=Ne.land;return window.setTimeout(()=>{Nt.isConnected&&Nt.focus()},0),"landed"},[u,o,a.memories]);return i.useEffect(()=>{if(!Y)return;Qe(Y,Date.now());let l=0,f=!1;const j=()=>{if(f)return;const E=ui({verdict:Qe(Y,Date.now()),watchMs:Kt});E!==null&&(l=window.setTimeout(j,E))};return l=window.setTimeout(j,Kt),()=>{f=!0,window.clearTimeout(l)}},[Y,Qe]),i.useEffect(()=>{if(!Y)return;const l=f=>{li({target:f.target,row:ee.current[Y.name]})&&W(null)};return window.document.addEventListener("pointerdown",l,!0),()=>{window.document.removeEventListener("pointerdown",l,!0)}},[Y]),t.jsxs(se,{title:nt,titleComponent:wt,sectionRef:s,children:[t.jsxs("div",{className:"flex flex-col gap-4",children:[a.route==="session"&&a.borrowed?t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Showing the integrations for"," ",a.borrowed.title?.trim()||a.borrowed.session_id.slice(0,6),", your most recent chat."]}):null,a.noConversation?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Integrations can be managed here once a chat has started."}),t.jsx(D,{variant:"primary",size:"sm",onClick:()=>d("/chat"),children:"Start a chat"}),t.jsx("p",{className:"text-ink-dim text-meta",children:"Updating Local Operator removes this step."})]}):null,a.isLoading?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(re,{size:"lg",label:"Loading integrations"})}):null,a.folderUnavailable?t.jsx(le,{variant:"warning",children:t.jsx("span",{children:"This chat's folder no longer exists, so only global integrations are shown."})}):null,a.isError?t.jsx(le,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Integrations couldn't be loaded."}),t.jsx(D,{variant:"secondary",size:"sm",onClick:a.refetch,children:"Retry"})]})}):null,_n.map(([l,f])=>t.jsx(le,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:f}),t.jsx(D,{variant:"ghost",size:"sm",onClick:()=>Nn(l),children:"Dismiss"})]})},l)),b&&c.length>0?jt:null,c.length>=Ki?t.jsxs("div",{className:"relative",children:[t.jsx(Gn,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),t.jsx(Ce,{ref:C,value:p,onChange:l=>x(l.target.value),onKeyDown:l=>{l.key!=="Escape"||!p||(l.preventDefault(),x(""))},placeholder:`Search ${br(c.length)}`,"aria-label":"Search integrations",className:"pl-9"})]}):null,w?.kind==="miss"&&c.length>0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:`No integration matches "${w.asked}".`}):null,w?.kind==="matched"&&w.unresolved?t.jsx("p",{className:"text-body-sm text-ink-muted",children:`Showing "${w.name}" — "${w.unresolved}" is not one of your integrations.`}):null,o&&c.length===0&&!a.isLoading?b?jt:t.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[t.jsx(tn,{"aria-hidden":"true",className:"size-5 text-ink-muted"}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"text-heading text-ink",children:"No integrations yet"}),t.jsx("p",{className:"max-w-xl text-body-sm text-ink-muted",children:"Integrations let agents read and act in your other tools, like Notion or Linear. Add one with a command that runs on this computer, or a server's URL."})]}),t.jsxs(D,{variant:"primary",size:"md",onClick:()=>k(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(Mt,{"aria-hidden":"true"}),"Add integration"]})]}):null,c.length>0&&B.length===0?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No integrations match this search."}),t.jsx(D,{variant:"secondary",size:"sm",onClick:()=>{x(""),window.setTimeout(()=>{(C.current??ie.current)?.focus()},0)},children:"Clear search"})]}):null,_e.map(l=>t.jsxs("section",{"aria-labelledby":`integrations-group-${l.id}`,className:"flex flex-col gap-1.5",children:[t.jsxs("h3",{id:`integrations-group-${l.id}`,className:"px-1 text-ink-dim text-meta",children:[l.title," · ",l.rows.length]}),t.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:l.rows.map(f=>t.jsx(yi,{row:f,operations:m,memories:a.memories,projectScopeAvailable:g,highlighted:f.name===v,rowRef:j=>{ee.current[f.name]=j,f.name===v&&(U.current=j)},primaryRef:j=>{z.current[f.name]=j},overflowRef:j=>{O.current[f.name]=j},pending:L===f.name,failure:H[f.name]??null,confirm:$?.name===f.name?{kind:$.kind}:null,onPrimary:j=>Fe(f,j),onOverflow:j=>bt(f,j),onConfirm:()=>$&&De(f,$.kind),onCancelConfirm:()=>{I(null),window.setTimeout(()=>{O.current[f.name]?.focus()},0)}},f.id))})]},l.id))]}),M?.kind==="sign_in"?t.jsx(wi,{name:M.name,action:M.action,keyRoute:ue?qe(ue):!1,phase:G,onStart:()=>void Ze(M.name,M.action),onCancel:l=>void r({action:"cancel",operationId:l}).catch(()=>{}),onOpenLink:l=>void qn(l),onClose:l=>h(M.name,l)}):null,M?.kind==="key"?t.jsx(pi,{name:M.name,keyNames:M.keyNames.length?M.keyNames:_t?.auth.secret_refs.map(l=>l.id)??[],keyless:M.keyNames.length===0,savedKeys:_t?.auth.secret_refs.filter(l=>l.state==="encrypted").map(l=>l.id),saving:T,failure:X,onClose:de,onSave:(l,f,j)=>{V(!0),A(null),a.storeKeys(M.name,l,f,j).then(E=>{if(!E.saved){A(E.message);return}N(null),W({name:M.name,waitForSignIn:!1,until:Date.now()+Ae,reanchors:0})}).catch(E=>A(Pe("key",E,!1))).finally(()=>V(!1))}}):null]})},Ae=4e3,Gi=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,qi=e=>e.replace(Gi,"~"),Yi=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,Wi="https://console.radienthq.com/dashboard/verification",Zi=(e,s)=>e==="pending"?{sentence:`Verify your email to claim ${s}. Check your inbox for the link Radient sent.`,action:"Open verification page"}:e==="expired"?{sentence:`The link to claim ${s} has expired. Request a new one from the verification page.`,action:"Request a new link"}:{sentence:"No signup grant is attached to this account. Open the verification page to check the account.",action:"Open verification page"},Qi=({verification:e})=>{const{prices:s}=Jn(),n=e.grant_amount??s?.default_new_credits,{sentence:a,action:o}=Zi(e.signup_grant,Yi(n)),r=e.claim_url||Wi;return t.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[t.jsx(Ge,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink",children:a}),t.jsx(D,{variant:"secondary",size:"sm",onClick:()=>{window.api?.openExternal?window.api.openExternal(r):window.open(r,"_blank")},children:o})]})]})},Ji=({onAfterCredentialUpdate:e})=>{const{isAuthenticated:s,user:n,isLoading:a,accountRead:o,signOut:r}=Zn(),u=nn(b=>b.isSigningOut),d=i.useCallback(async()=>{try{await r()}catch(b){console.error("Error signing out:",b)}},[r]),c=i.useMemo(()=>{if(!s||!n?.radientUser)return null;const{account:b,identity:k,verification:p}=n.radientUser,x=p!=null&&!p.email_verified&&p.signup_grant!=="claimed";return t.jsxs(t.Fragment,{children:[t.jsxs(ft,{children:[t.jsx(ae,{label:"Status",value:t.jsxs("span",{className:"inline-flex items-center gap-2",children:["Connected",t.jsx(Ks,{variant:"success",className:"capitalize",children:b.status})]})}),t.jsx(ae,{label:"Name",value:b.name||"Not provided"}),t.jsx(ae,{label:"Email",value:b.email}),t.jsx(ae,{label:"Account ID",value:t.jsx("span",{className:"text-mono-sm",children:b.id})}),t.jsx(ae,{label:"Tenant ID",value:t.jsx("span",{className:"text-mono-sm",children:b.tenant_id})}),t.jsx(ae,{label:"Provider",value:t.jsx("span",{className:"capitalize",children:k.provider})}),t.jsx(ae,{label:"Created",value:sn(b.created_at)})]}),x&&p?t.jsx(Qi,{verification:p}):null,t.jsxs("div",{className:"mt-8",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Need to sign out or switch accounts?"}),t.jsxs(D,{variant:"danger",className:"mt-3",onClick:d,children:[t.jsx(Qn,{}),"Sign out from Radient"]})]})]})},[s,n?.radientUser,d]),m=i.useMemo(()=>o==="refused"?"Radient refused the sign-in this app is holding, so your account details could not be read. Signing in again below replaces it.":an(o)?"Your Radient account could not be read, so this app cannot show your account details.":"You are not currently signed in to Radient.",[o]),g=i.useMemo(()=>s&&n?null:t.jsxs("div",{children:[t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[m," Sign in to access your account details or sign up to get free credits and unified access to models, tools, and more with Radient Pass. Radient's automatic model router will automatically select the best model for your agents to balance cost and performance. It is often cheaper to use Radient Pass than to use single AI providers due to automatic cost optimization."]}),t.jsx("div",{className:"mt-6",children:t.jsx(Gs,{titleText:"",onAfterCredentialUpdate:e,descriptionText:"",onSignInSuccess:()=>{}})})]}),[s,n,m,e]);return a||u?t.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[t.jsx(re,{size:"lg",label:"Loading account"}),!u&&t.jsx("p",{className:"text-meta text-ink-dim",children:"Loading your Radient account details…"})]}):s&&n?.radientUser?c:t.jsx("div",{className:"flex flex-col gap-4",children:g})};function Xi({metric:e,data:s}){return t.jsx(Xn,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:e==="credits"?"credits":"tokens",srSummary:`${e==="credits"?"Credits consumed":"Tokens used"} over the last 30 days, plotted per day across ${s.length} days.`,xTickFormatter:n=>n,yTickFormatter:n=>e==="credits"?`$${n.toFixed(2)}`:es(n),children:t.jsx(ur,{data:s,children:t.jsx(Jt,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:e==="credits"?"Credits consumed":"Tokens used"})})})}const ec=()=>{const{data:e,isLoading:s,error:n,refetch:a}=ir(),o=cr(),[r,u]=i.useState(""),[d,c]=i.useState(!1);i.useEffect(()=>{u(e?.content??""),c(!1)},[e]);const m=x=>{const L=x.target.value;u(L),c(L!==(e?.content??""))},g=async()=>{if(!(!d||o.isPending))try{const x={content:r};await o.mutateAsync(x),await a(),c(!1)}catch(x){console.error("Error updating system prompt:",x)}},b=()=>{u(e?.content??""),c(!1)},k=o.isPending,p=()=>t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(pe,{htmlFor:"app-system-prompt",children:"Instructions"}),t.jsx(cn,{id:"app-system-prompt",name:"systemPrompt",value:r,onChange:m,placeholder:"Enter instructions for how all agents should behave and respond to your requests...",className:"min-h-50"})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs(D,{variant:"primary",onClick:g,disabled:!d||k,children:[k?t.jsx(re,{size:"sm"}):t.jsx(ts,{}),k?"Saving...":"Save changes"]}),t.jsx(D,{onClick:b,disabled:!d||k,children:"Cancel"})]}),e?.last_modified&&t.jsxs("p",{className:"text-ink-dim text-meta",children:["Last modified:"," ",t.jsx("span",{className:"font-mono text-mono-sm",children:on(e.last_modified)})]})]});return t.jsx(se,{title:"System prompt",icon:Vs,description:"Every Local Operator agent receives this prompt in addition to its own instructions, so it is the place for baseline expectations and for details you want every agent to know about you, such as your name, location, or preferences. It is sent to your selected hosting provider.",children:s?t.jsx("div",{className:"flex min-h-50 items-center justify-center",children:t.jsx(re,{size:"lg",label:"Loading system prompt"})}):n?t.jsxs(le,{variant:"danger",children:["Failed to load system prompt:"," ",n instanceof Error?n.message:"Unknown error"]}):p()})},tc=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],nc=e=>tc.includes(e),sc=e=>{const s=[];let n=0;for(const a of e){const o=Math.max(0,Math.floor(a.count)),r=Math.max(1,Math.floor(a.columns));for(let u=0;u<o;u+=r)s.push({start:n+u,count:Math.min(r,o-u)});n+=o}return s},ac=({index:e,key:s,groups:n})=>{const a=sc(n),o=a.reduce((r,u)=>r+u.count,0);if(!Number.isInteger(e)||e<0||e>=o)return e;switch(s){case"Home":return 0;case"End":return o-1;case"ArrowLeft":return Math.max(0,e-1);case"ArrowRight":return Math.min(o-1,e+1);case"ArrowUp":case"ArrowDown":{const r=a.findIndex(c=>e>=c.start&&e<c.start+c.count),u=a[r+(s==="ArrowDown"?1:-1)];if(!u)return e;const d=e-a[r].start;return u.start+Math.min(d,u.count-1)}default:return e}},oc={localOperatorDark:yo,localOperatorLight:Do,dracula:Ao,dune:Ba,sage:co,monokai:os,tokyoNight:bo,iceberg:To,radient:no,neon:as,obsidian:dn,synth:sa,catppuccinMocha:Aa,catppuccinLatte:ho,tokyoNightStorm:ba,gruvbox:ua,nord:or,oneDark:ta,solarizedDark:Oo,rosePine:Ya,rosePineMoon:fo,rosePineDawn:Ca,alucard:Za,gruvboxLight:Fa,tokyoNightDay:ko,oneLight:uo,catppuccinFrappe:Ia,catppuccinMacchiato:ao,palenight:ss,everforest:Qo,everforestLight:Wo,kanagawaWave:tr,kanagawaLotus:Ga,ayuDark:$a,ayuMirage:za,ayuLight:No,nightfox:ja,duskfox:Po,synthwave:jo,matrix:oa,tron:ka,cyberpunk:ns,vaporwave:qo,outrun:la,neonNoir:Xo,arcade:ro,forest:Vo,ocean:Ka,desert:Ho,autumn:sr,lavender:Lo,arctic:Na,rosewood:eo,solarizedLight:Uo,githubLight:Ja,paper:qs,linen:Co,highContrastLight:Xs,mintLight:ia},Yt="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",rc=({id:e})=>t.jsxs("div",{"data-theme":e,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[t.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[t.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:t.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),t.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),t.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[t.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[t.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),t.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),t.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),ic=({id:e,name:s,description:n,isSelected:a,isTabStop:o,onSelect:r,onFocusTile:u})=>{const d=oc[e];return t.jsx(Te,{side:"bottom",align:"start",content:n,children:t.jsxs("button",{type:"button","data-theme-tile":e,"aria-pressed":a,tabIndex:o?0:-1,onFocus:u,onClick:r,className:oe("relative flex flex-col gap-1.5 rounded-md p-1 text-left transition-colors duration-fast ease-out-quart",a?Yt:"hover:bg-surface"),children:[t.jsxs("span",{className:oe("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",a?"border-accent":"border-hairline"),children:[t.jsx(rc,{id:e}),a&&t.jsx("span",{className:oe("pointer-events-none absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full",Yt),children:t.jsx(Bs,{size:12,className:"text-accent","aria-hidden":"true"})})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(d,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},cc=e=>[...e.querySelectorAll("[data-theme-grid]")].map(s=>{const n=[...s.querySelectorAll("[data-theme-tile]")],a=n[0]?.getBoundingClientRect().top??0;return{count:n.length,columns:Math.max(1,n.filter(o=>Math.abs(o.getBoundingClientRect().top-a)<1).length)}}),lc=()=>{const{themeName:e,setTheme:s}=ct(),n=i.useMemo(()=>{const d=Object.values(Cn);return[{label:"Dark",items:d.filter(c=>c.theme.palette.mode==="dark")},{label:"Light",items:d.filter(c=>c.theme.palette.mode==="light")}].filter(c=>c.items.length>0)},[]),[a,o]=i.useState(null),r=i.useMemo(()=>{const d=n.flatMap(c=>c.items.map(m=>m.id));return a&&d.includes(a)?a:d.includes(e)?e:d[0]},[n,a,e]),u=d=>{if(!nc(d.key))return;const c=[...d.currentTarget.querySelectorAll("[data-theme-tile]")],m=c.indexOf(d.target);if(m<0)return;d.preventDefault();const g=ac({index:m,key:d.key,groups:cc(d.currentTarget)});g!==m&&c[g]?.focus()};return t.jsx(Hs,{children:t.jsx("div",{onKeyDown:u,className:"flex flex-col gap-6",children:n.map(d=>t.jsxs("div",{children:[t.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:d.label}),t.jsx("div",{"data-theme-grid":d.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:d.items.map(({id:c,name:m,description:g})=>t.jsx(ic,{id:c,name:m,description:g,isSelected:c===e,isTabStop:c===r,onSelect:()=>s(c),onFocusTile:()=>o(c)},c))})]},d.label))})})},dc=()=>{const{data:e,isLoading:s,error:n}=hr({enabled:!0});return t.jsxs("div",{children:[t.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[t.jsx(Ea,{size:16,className:"shrink-0 text-ink-dim"}),"Radient Pass"]}),s&&t.jsx(ln,{className:"h-6 w-36"}),n&&t.jsxs(le,{variant:"warning",children:["Could not load your credit balance. ",n.message]}),e&&!s&&!n&&t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[t.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:["Available credits"," ",t.jsx("span",{className:"font-medium text-ink",children:e.balance.toFixed(2)})]}),t.jsx(D,{variant:"secondary",size:"sm",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[t.jsx(ya,{}),"Add credits"]})})]})]})},uc=[{id:"credits",label:"Credits"},{id:"tokens",label:"Tokens"}],mc=()=>{const[e,s]=i.useState("credits"),n=i.useMemo(()=>{const d=new Date,c=dr(d);return{start_date:Ft(c),end_date:Ft(d),rollup:"daily"}},[]),{data:a,isLoading:o,error:r}=fr(n,{enabled:!0}),u=i.useMemo(()=>a?.data_points?[...a.data_points].sort((c,m)=>Je(c.timestamp).getTime()-Je(m.timestamp).getTime()).map(c=>({bucket:ws(Zs(Je(c.timestamp),"yyyy-MM-dd")),value:e==="credits"?Number.parseFloat(c.total_cost.toFixed(2)):c.total_tokens})):[],[a,e]);return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(ha,{size:16,className:"shrink-0 text-ink-dim"}),"Usage (last 30 days)"]}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Usage metric"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:uc.map(({id:d,label:c})=>t.jsx(D,{variant:"ghost",size:"sm","aria-pressed":e===d,onClick:()=>s(d),className:oe(e===d&&"bg-surface text-ink hover:bg-surface"),children:c},d))})]})]}),o&&t.jsx(ln,{className:"h-62 w-full"}),r&&t.jsxs(le,{variant:"warning",children:["Could not load your usage data. ",r.message]}),!o&&!r&&a&&u.length>0&&t.jsx(Xi,{metric:e,data:u}),!o&&!r&&(!a||u.length===0)&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No usage recorded in the last 30 days."})]})},hc=()=>t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(js,{size:16,className:"shrink-0 text-ink-dim"}),"Radient account"]}),t.jsx(D,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:["Go to Radient console",t.jsx(_s,{})]})})]}),Mc=()=>{const e=rs("elevated"),s=ct(h=>h.showAgentReasoning),n=ct(h=>h.setShowAgentReasoning),{data:a,isLoading:o,isFetching:r,error:u,refetch:d}=is(),c=cs(),{sentence:m,remedy:g}=Ms(c,"Your settings could not be loaded.",u),b=ls(),[k,p]=i.useState(null),x=nn(),{isAuthenticated:L,accountRead:S,isFetching:H,isRefreshing:_,refreshUser:$}=mt(),I=Ke(h=>h.activeSessionId),[M,N]=i.useState("general"),[G,P]=i.useState(!1),q=i.useRef(null),K=i.useRef(null),{startTour:X}=ds(),A=us(),{data:T,refetch:V}=ms(),{refreshModels:z}=hs(),O=i.useMemo(()=>T?.keys?[...T.keys].sort():[],[T?.keys]),ee=i.useRef({keys:"",hosting:void 0});i.useEffect(()=>{const h=O.join(","),w=a?.values?.hosting;(ee.current.keys!==h||ee.current.hosting!==w)&&(ee.current={keys:h,hosting:w},z().catch(v=>{console.error("Failed to refresh models after credentials or hosting change:",v)}))},[O,a?.values?.hosting,z]);const R=i.useRef({general:i.useRef(null),radient:i.useRef(null),integrations:i.useRef(null),appearance:i.useRef(null),providers:i.useRef(null),backend:i.useRef(null),updates:i.useRef(null)}).current,ie=i.useMemo(()=>new URLSearchParams(A.search).get("setting"),[A.search]),C=i.useMemo(()=>new URLSearchParams(A.search).get("filter")??"",[A.search]),Z=i.useMemo(()=>new URLSearchParams(A.search).get("mcp")??void 0,[A.search]),Q=i.useMemo(()=>new URLSearchParams(A.search).get("provider"),[A.search]),J=i.useCallback(h=>{N(h),P(!0);const w=R[h],v=K.current;if(w?.current&&v){const F=w.current.getBoundingClientRect().top-v.getBoundingClientRect().top;v.scrollHeight>v.clientHeight?v.scrollTo({top:Math.max(0,v.scrollTop+F-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,w.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(q.current??void 0),q.current=setTimeout(()=>{P(!1),q.current=null},800)}else P(!1)},[R]);i.useEffect(()=>{const h=setTimeout(()=>{const w=K.current;if(!w)return;const v=()=>{if(G)return;const U=w.getBoundingClientRect(),F=U.height;let te="",B=0;for(const[_e,ue]of Object.entries(R))if(ue.current){const ce=ue.current.getBoundingClientRect(),ye=U.top,ne=ce.top-ye,We=ce.bottom-ye,Oe=ce.height,Ze=Math.max(0,ne),Fe=Math.min(F,We),De=Math.max(0,Fe-Ze)/Oe,$e=De+(ne<F*.3?.1:0);$e>B&&De>.1&&(B=$e,te=_e)}te&&te!==M&&N(te)};return v(),w.addEventListener("scroll",v,{passive:!0}),()=>{w.removeEventListener("scroll",v),clearTimeout(q.current??void 0)}},100);return()=>clearTimeout(h)},[R,M,G]),i.useEffect(()=>{const h=new URLSearchParams(A.search),w=h.get("section"),v=h.get("setting")?"backend":w,U=v?R[v]:void 0;if(!v||!U)return;let F=!1,te=Number.NaN,B=0;const _e=window.setTimeout(()=>{F||(F=!0,ce.disconnect(),J(v))},2e3),ue=()=>{if(F)return;const ye=U.current;if(!ye){B=requestAnimationFrame(ue);return}const ne=Math.round(ye.getBoundingClientRect().top+window.scrollY);if(ne===te&&ne>0){F=!0,ce.disconnect(),window.clearTimeout(_e),J(v);return}te=ne,B=requestAnimationFrame(ue)},ce=new ResizeObserver(()=>{F||(cancelAnimationFrame(B),B=requestAnimationFrame(ue))});return K.current&&ce.observe(K.current),B=requestAnimationFrame(ue),()=>{F=!0,cancelAnimationFrame(B),ce.disconnect(),window.clearTimeout(_e)}},[A.search,R,J]);const Y=async(h,w)=>{p(h);try{await b.mutateAsync({[h]:w}),await d()}catch(v){console.error(`Error updating ${h}:`,v)}finally{p(null)}},W=o,fe=S==="checking",je=an(S),de=S==="ready"||S==="checking"||H,ge=Wt(W,4e3);return u?t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(le,{variant:"warning",className:"w-full max-w-xl",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:m}),g&&t.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void d(),disabled:r,children:r?"Retrying":"Retry"})]})})}):W?t.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[t.jsx(re,{size:"lg",label:ge?void 0:"Loading settings"}),ge&&t.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:"The Local Operator server is taking longer than usual to answer. If it does not respond, you will be able to retry from here."})]}):a?t.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-canvas",children:[t.jsx("div",{ref:e,className:"w-12 shrink-0 overflow-y-auto min-[1040px]:w-55",children:t.jsx(ps,{activeSection:M,onSelectSection:J,sections:fs})}),t.jsx("div",{ref:K,"data-settings-content":!0,"data-tour-tag":"settings-general-section",className:"flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[t.jsx(As,{title:"Settings",icon:At}),t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{ref:R.general,className:"flex flex-col gap-8",children:[t.jsxs(se,{title:"User profile",icon:gs,description:`Your user profile information displayed in the application. This information is not provided to the agents. ${L?"These details are provided through your Radient account.":""}`,children:[fe&&t.jsx("p",{className:"text-meta text-ink-dim",children:"Checking your Radient account…"}),je&&t.jsx(le,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{children:["Your Radient account could not be read, so the name and email below are placeholders rather than your account details.",S==="refused"?" Retry, or sign in to Radient again.":" Retry."]}),t.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>$(),disabled:_,children:_?"Retrying":"Retry"})]})}),t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(Rt,{value:x.profile.name,label:"Display name",placeholder:"Enter your name...",isSaving:k==="user_name",onSave:async h=>{p("user_name");try{x.updateName(h)}finally{p(null)}},readOnly:de}),t.jsx(Rt,{value:x.profile.email,label:"Email address",placeholder:"Enter your email...",isSaving:k==="user_email",onSave:async h=>{p("user_email");try{x.updateEmail(h)}finally{p(null)}},readOnly:de})]})]}),t.jsx(se,{title:"Application tour",description:"Missed the application onboarding tour or want a refresher? Start it again here.",children:t.jsxs(D,{variant:"secondary",onClick:()=>{X({forceModalCompleted:!0})},children:[t.jsx(fa,{}),"Take the tour"]})}),t.jsx(se,{id:"model-settings",title:"Model settings",icon:ys,description:"Configure the default AI model and hosting providers used for generating responses. This will be used for all agents that don't have a specific model or hosting provider configured. You can override these settings for individual agents in the agent settings.",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(xs,{value:a.values.hosting,isSaving:k==="hosting",onSave:h=>Y("hosting",h),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:"No hosting providers available. Sign in to a provider, or add a provider's API key below, under Providers."}),t.jsx(ks,{value:a.values.model_name,hostingId:a.values.hosting,isSaving:k==="model_name",onSave:h=>Y("model_name",h),allowCustom:!0,allowDefault:!1}),t.jsx(le,{variant:"neutral",icon:t.jsx(Ge,{className:"size-4","aria-hidden":"true"}),children:"You need a Radient account or your own API keys to reach cloud providers. If you don't see more hosting providers and models here, sign in to Radient, or add a provider's API key below, under Providers."})]})}),t.jsx(ec,{}),t.jsx(se,{title:"Configuration information",icon:Ge,description:"System information about the current configuration.",children:t.jsxs(ft,{children:[t.jsx(ae,{label:"Version",value:t.jsx("span",{className:"text-mono-sm",children:a.version})}),t.jsx(ae,{label:"Created",value:sn(a.metadata.created_at)}),t.jsx(ae,{label:"Last modified",value:on(a.metadata.last_modified)}),t.jsx(ae,{label:"Description",value:a.metadata.description||"No description available"})]})})]}),t.jsx(se,{title:"Appearance",icon:dn,description:"Customize the look and feel of Local Operator",sectionRef:R.appearance,dataTourTag:"settings-appearance-section",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(lc,{}),t.jsx(lr,{value:s,label:"Show agent reasoning",description:"Adds the agent's Reasoning and Thinking rows to conversations. They stay closed until you open one.",onChange:async h=>n(h)})]})}),t.jsx(se,{title:"Model providers",icon:tn,description:"Sign in to the services your agents think with. New chats use your default model.",sectionRef:R.providers,children:t.jsx(vs,{initialProviderId:Q,onChangeModel:()=>J("general")})}),t.jsx(Vi,{sessionId:I??void 0,sectionRef:R.integrations,highlightServer:Z}),t.jsx(se,{title:"Radient account",titleComponent:t.jsx(hc,{}),description:"Your Radient account, Radient Pass details and credits. To use Radient models, sign in under Model providers.",sectionRef:R.radient,dataTourTag:"settings-radient-account-section",children:t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsx(Ji,{onAfterCredentialUpdate:()=>{z(),V()}}),L&&t.jsxs(t.Fragment,{children:[t.jsx(dc,{}),t.jsx(mc,{})]})]})}),t.jsx(se,{title:"Backend settings",icon:At,description:"Every setting the backend registry owns, searchable, with typed editors and scopes.",sectionRef:R.backend,children:t.jsx(bs,{focusKey:ie,initialFilter:C})}),t.jsx("div",{ref:R.updates,children:t.jsx(kr,{})})]})]})})]}):t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(le,{variant:"warning",className:"w-full max-w-xl",children:"Your settings could not be loaded."})})};export{Mc as SettingsPage};
|
|
291
|
+
*/const ar=[["path",{d:"M12.8 19.6A2 2 0 1 0 14 16H2",key:"148xed"}],["path",{d:"M17.5 8a2.5 2.5 0 1 1 2 4H2",key:"1u4tom"}],["path",{d:"M9.8 4.4A2 2 0 1 1 11 8H2",key:"75valh"}]],or=y("wind",ar),rr=({appVersion:e=null,slowWaitHintMs:s})=>{const n="https://local-operator.com/download",[a,o]=i.useState(!1),r=Wt(a,s??Mn),[u,d]=i.useState(!1),[c,m]=i.useState(null),[g,b]=i.useState("info"),[k,f]=i.useState(null),[x,L]=i.useState(null),S=e?.trim()?e.trim():null,K=i.useRef(!1),_=st(A=>A.openDetail),$=i.useRef(!1),I=i.useRef(0),M=i.useRef(!1),N=i.useCallback((A,T)=>{$.current=!1,m(A),b(T),d(!0)},[]),G=i.useCallback(A=>{$.current=!0,m(A),b("success"),d(!0)},[]),P=i.useCallback(()=>{$.current&&($.current=!1,d(!1),m(null))},[]),{clearDeferredUpdate:q}=An();i.useEffect(()=>{const A=window.api.updater.onUpdateError(R=>{K.current&&R.includes("manually")&&(f({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),$.current=!1,m(null),b("warning"),d(!0))}),T=window.api.updater.onBackendUpdateDevMode(R=>{K.current&&N(R,"info")}),V=()=>{M.current=!0,P()},z=window.api.updater.onUpdateAvailable(V),O=window.api.updater.onUpdateNpxAvailable(V),ee=window.api.updater.onBackendUpdateAvailable(V);return()=>{A(),T(),z(),O(),ee()}},[P,N]),i.useEffect(()=>{let A=!1;const T=()=>{window.api.updater.getLastInstallAttempt().then(z=>{A||L(z)}).catch(()=>{})};T();const V=window.api.updater.onUpdateInstallFailed(()=>T());return()=>{A=!0,V()}},[]);const H=async()=>{const A=++I.current;P(),M.current=!1;try{o(!0),K.current=!0,q(he.UI),q(he.BACKEND);const T=await window.api.updater.checkForAllUpdates({manual:!0});if(A!==I.current)return;T.app==="available"&&_(he.UI),T.server==="available"&&_(he.BACKEND),T?.affirmation&&!M.current?G(T.affirmation):P()}catch(T){if(A!==I.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Rn(T)}`)}finally{A===I.current&&o(!1),setTimeout(()=>{K.current=!1},2e3)}},X=()=>{$.current=!1,d(!1),m(null)};return t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[t.jsxs("p",{className:"text-body-sm text-ink",children:["The last update to version ",x.targetVersion," didn't finish",x.attempts>1?` (${x.attempts} attempts)`:"",".",S?` Version ${S} is running.`:null]}),t.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:["Detected"," ",x.detectedAt?new Date(x.detectedAt).toLocaleString():"at an unknown time",". ",x.detail]}),t.jsx(D,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(n),children:"Download a fresh copy"})]}),t.jsxs(D,{variant:"outline",onClick:()=>void H(),disabled:a,children:[a?t.jsx(re,{size:"sm"}):null,a?"Checking...":"Check for updates"]}),r&&t.jsx("p",{className:"mt-2 text-meta text-ink-muted",children:"Still checking. A slow or stalled connection can hold this for about a minute and a half - the app stops waiting on its own."}),k&&t.jsxs(St,{open:u,autoHideDuration:1e4,onClose:X,variant:"warning",children:[t.jsx("p",{className:"text-body-sm",children:k.message}),k.command&&t.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:k.command})]}),c&&g!=="danger"&&t.jsx(St,{open:u,autoHideDuration:6e3,onClose:X,variant:g,children:c})]})},Ke=["system-prompt"],ir=()=>{const{shouldEnableQuery:e}=Tn();return Se({enabled:e({bypassInternetCheck:!0}),queryKey:Ke,queryFn:async()=>{try{const n=await Zt(ht.baseUrl).config.getSystemPrompt();if(n===null)return null;if(n.status>=400)throw new Error(n.message||"Failed to fetch system prompt");return n.result}catch(s){const n=s instanceof Error?s.message:"An unknown error occurred while fetching system prompt";throw Qt(n),s}},refetchOnWindowFocus:!1,staleTime:5e3})},cr=()=>{const e=rn(),s=Zt(ht.baseUrl);return En({mutationFn:async n=>{try{const a=await s.config.updateSystemPrompt(n);if(a.status>=400)throw new Error(a.message||"Failed to update system prompt");return a.result}catch(a){const o=a instanceof Error?a.message:"An unknown error occurred while updating system prompt";throw Qt(o),a}},onSuccess:async n=>{await e.invalidateQueries({queryKey:Ke,refetchType:"none"}),e.setQueryData(Ke,a=>a&&{...a,...n}),await e.refetchQueries({queryKey:Ke,type:"all"}),Ln("System prompt updated")},onError:n=>{console.error("Error updating system prompt:",n)}})},lr=({value:e,label:s,description:n,onChange:a,icon:o,isSaving:r=!1})=>{const[u,d]=i.useState(e),c=i.useId(),m=`${c}-label`,g=`${c}-description`,b=async k=>{if(!r){d(k);try{await a(k)}catch(f){d(!k),console.error("Error toggling setting:",f)}}};return t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("span",{id:m,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[o&&t.jsx(o,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),s]}),n&&t.jsx("p",{id:g,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:n})]}),t.jsx("div",{className:"flex h-6 shrink-0 items-center",children:r?t.jsx(re,{size:"md",label:`Saving ${s}`}):t.jsx(Rs,{checked:u,onCheckedChange:b,"aria-labelledby":m,"aria-describedby":n?g:void 0})})]})};function Ft(e,s){const n=Qs(e,s?.in);if(!Ws(n))throw new RangeError("Invalid time value");const a=ve(n.getDate(),2),o=ve(n.getMonth()+1,2),r=n.getFullYear(),u=ve(n.getHours(),2),d=ve(n.getMinutes(),2),c=ve(n.getSeconds(),2);let m="",g="";const b=n.getTimezoneOffset();if(b!==0){const k=Math.abs(b),f=ve(Math.trunc(k/60),2),x=ve(k%60,2);g=`${b<0?"+":"-"}${f}:${x}`}else g="Z";return`${r}-${o}-${a}T${u}:${d}:${c}${m}${g}`}function dr(e,s,n){return Ys(e,-30,n)}var ur=In({chartName:"LineChart",GraphicalChild:Jt,axisComponents:[{axisType:"xAxis",AxisComp:On},{axisType:"yAxis",AxisComp:Fn}],formatAxisMap:Dn});const mr=["radient","creditBalance"],hr=e=>{const{user:s,isAuthenticated:n}=mt(),a=s?.account?.tenant_id,o=n&&!!a&&e?.enabled;return Se({queryKey:[mr,a],queryFn:async()=>{if(!a)throw new Error("Tenant ID not available");const r=await Xt({operation:"credits",tenantId:a});if(!r||typeof r.balance!="number")throw new Error("Invalid credit balance response format");return r},enabled:o,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},fr=["radient","usageRollup"],pr=(e,s)=>{const{user:n,isAuthenticated:a}=mt(),o=n?.account?.tenant_id,r=a&&!!o&&s?.enabled;return Se({queryKey:[...fr,o,e],queryFn:async()=>{if(!o)throw new Error("Tenant ID not available");const u={};for(const[c,m]of Object.entries(e))m!=null&&(u[c]=String(m));const d=await Xt({operation:"usage",tenantId:o,query:u});if(!d)throw new Error("Invalid usage rollup response format");return d},enabled:r,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Dt={[he.UI]:"Application updates",[he.BACKEND]:"Server updates"},$t=({type:e})=>{const s=st(a=>a.followed[e]),n=st(a=>a.setFollowedSegment);return t.jsxs("div",{className:"flex flex-col gap-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-6",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-body-sm text-ink",children:Dt[e]}),t.jsx("div",{className:"mt-0.5 text-meta text-ink-muted",children:Ue[s].description})]}),t.jsxs(Ts,{value:s,onValueChange:a=>n(e,a),children:[t.jsx(Es,{"aria-label":`${Dt[e]}: ${Ue[s].label}`,className:"w-full sm:w-56","data-followed-segment":e,children:t.jsx(Ls,{})}),t.jsx(Is,{children:$n.map(a=>t.jsx(Os,{value:a,title:Ue[a].description,children:Ue[a].label},a))})]})]})},gr=()=>t.jsxs("div",{className:oe("flex flex-col gap-3"),children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-heading text-ink",children:"Update notifications"}),t.jsx("p",{className:"mt-1 text-meta text-ink-muted",children:"How much of a version change shows the update notice at the bottom of the window. A check you run yourself always reports what it finds."})]}),t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsx($t,{type:he.UI}),t.jsx($t,{type:he.BACKEND})]})]}),yr=({appVersion:e})=>t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsx(gr,{}),t.jsx(rr,{appVersion:e})]}),xr=e=>{if(!e)return null;try{return new URL(e).host}catch{return null}},kr=()=>{const[e,s]=i.useState(null),[n,a]=i.useState({value:"Loading...",detail:null,degraded:!1}),[o,r]=i.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});i.useEffect(()=>{let d=!0;const c=f=>{if(!d)return;const x=xr(f.url);if(f.state==="connecting"){a({value:"Loading...",detail:null,degraded:!1});return}if(f.state==="detached"){a({value:"Not connected",detail:f.detail||null,degraded:!1});return}if(f.state==="wedged"){a({value:"Not attached",detail:f.detail||null,degraded:!1});return}const L=f.version||"Version unknown";a({value:x?`${L} · ${x}`:L,detail:f.detail||null,degraded:f.state==="degraded"})};let m=!1;const g=window.api?.backend?.onStatusChange(f=>{m=!0,c(f)}),b=async()=>{try{const[f,x]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);d&&(s(f),r(x))}catch(f){console.error("Error fetching app information:",f)}},k=async()=>{try{const f=window.api?.backend;if(f){const S=await f.getStatus();m||c(S);return}const x=await Ct.healthCheck(ht.baseUrl),L=Ct.getServerVersion(x);d&&a({value:L,detail:null,degraded:!1})}catch(f){console.error("Error fetching server version:",f),d&&a({value:"Unavailable",detail:null,degraded:!1})}};return b(),k(),()=>{d=!1,g?.()}},[]);const u=(d,c,m,g={})=>t.jsx(ae,{label:t.jsx(Te,{content:m,children:t.jsxs("span",{className:"inline-flex cursor-help items-center gap-1.5",children:[t.jsx(Ge,{size:12,className:"shrink-0"}),d]})}),valueClassName:g.valueClassName,value:t.jsxs(t.Fragment,{children:[g.valueTooltip?t.jsx(Te,{content:g.valueTooltip,children:t.jsx("span",{"data-backend-version":g.valueHoverTarget?"":void 0,className:"cursor-help",children:c})}):c,g.statusNote?t.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:g.statusNote}):null]})});return t.jsx(se,{title:"Application updates and info",icon:Un,description:"Check for updates and view information about your Local Operator installation.",dataTourTag:"settings-app-updates-section",children:t.jsxs("div",{className:"flex flex-col gap-6",children:[t.jsxs(pt,{children:[u("Application version",e??"Loading...","The version of the Local Operator user interface application."),u("Server version",n.value,"The version of the Local Operator API server backend, and the address of the daemon it was read from.",{valueTooltip:n.detail,valueHoverTarget:!0,statusNote:n.degraded?"Not answering":void 0,valueClassName:n.degraded?"text-ink-muted":void 0}),u("Platform",`${o.platform} (${o.arch})`,"The operating system and architecture your application is running on."),u("Node.js version",o.nodeVersion,"The JavaScript runtime environment version."),u("Electron version",o.electronVersion,"The framework version enabling this desktop application.")]}),t.jsx(yr,{appVersion:e})]})})},vr=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function un(e){if(!e)return null;const s=e.split("\\").join("/").split("/").filter(Boolean);for(const[n,a]of vr)if(!(s.length<n.length)&&s.slice(-n.length).join("/")===n.join("/"))return a;return null}const Be=e=>`${e} ${e===1?"tool":"tools"}`,br=e=>`${e} ${e===1?"integration":"integrations"}`,wr=["connected","needs_sign_in","not_started","connecting","error"],mn=e=>wr.includes(e),Me=(e,s)=>[...s].filter(n=>n.name===e&&n.status==="running").sort((n,a)=>a.created_at-n.created_at)[0]??null,jr={connectedAt:null,connectedToolCount:null,settledGroup:null,pinnedGroup:null,pinnedOperationId:null,needsKey:!1,needsSignIn:!1,disconnectedAt:null,holdUntil:null,lastDecisive:null},_r=1e12,Nr=1e9,Sr=60*60*1e3,hn=(e,s=Date.now())=>{if(typeof e!="number"||!Number.isFinite(e))return null;const n=e>=_r?e:e<Nr?null:e*1e3;return n===null||n>s+Sr?null:Math.min(n,s)},we=(e,s)=>e?.[s]??jr,Le=(e,s,n)=>Ar(e,s)??n?.lastDecisive??null,Cr=e=>({id:e.id,name:e.name,action:e.action,status:e.status,created_at:e.created_at,credential_removed:e.credential_removed,...e.message?{message:e.message}:{}}),gt=(e,s)=>e.status==="not_started"&&typeof e.tool_count=="number"&&(s.connectedAt!==null||e.status_basis==="stored"&&e.tool_count_basis==="last_seen"),Mr=(e,s)=>[...s].filter(n=>n.name===e).sort((n,a)=>a.created_at-n.created_at)[0]??null,Ar=(e,s)=>Mr(e,s.filter(n=>n.status!=="cancelled")),qe=e=>e.actions.includes("set_key")||e.actions.includes("add_key");function Rr(e,s){const n=Math.max(0,Math.round((e-s)/1e3));if(n<60)return"just now";const a=Math.round(n/60);if(a<60)return`${a} min ago`;const o=Math.round(a/60);return o<24?`${o} h ago`:`${Math.round(o/24)} d ago`}function Xe(e){if(!e)return null;const s=e.trim();if(!s||/^\/\w/.test(s)||/\/mcp\s+\w+/.test(s))return null;let n=s;for(let a=0;a<3;a+=1){const o=n.replace(/^(?:connection (?:closed|error|refused)|error|closed|failed)\s*:\s*/i,"").trim();if(o===n)break;n=o}return n=n.replace(/\s*\(\s*\d{3}\s*\)/g,"").replace(/\s+([.,;])/g,"$1").replace(/\s{2,}/g," ").trim(),n||null}function Tr(e,s=[],n,a=Date.now()){const o=we(n,e.name),r=Me(e.name,s);if(r){if(r.action==="login"||r.action==="reauth")return{label:"Signing in…",tone:"info",detail:null,busy:!0};if(r.action==="logout")return{label:"Signing out…",tone:"info",detail:null,busy:!0}}if(!mn(e.status))return{label:"Status unavailable",tone:"neutral",detail:null,busy:!1};const u=Le(e.name,s,o),d=Ye(u)&&e.status!=="connected",c=gt(e,o),m=kt(u)&&e.status!=="connected",g=(u?.action==="login"||u?.action==="reauth")&&u.status==="failed";if(o.disconnectedAt!==null)return{label:"Not connected",tone:"neutral",detail:null,busy:!1};switch(e.status){case"connected":return{label:typeof e.tool_count=="number"?`Connected · ${Be(e.tool_count)}`:"Connected",tone:"success",detail:null,busy:!1};case"connecting":return{label:"Connecting…",tone:"info",detail:null,busy:!0};case"needs_sign_in":return{label:e.auth.kind==="api_key"||Re(e,s,o)?"Needs a key":"Needs sign-in",tone:"warning",detail:Xe(e.status_reason),busy:!1};case"error":return{label:"Couldn't start",tone:"danger",detail:Xe(e.status_reason)??"No reason was given.",busy:!1};default:if(d)return{label:"Signed out",tone:"warning",detail:null,busy:!1};if(m)return{label:"Sign-out didn't finish",tone:"warning",detail:"The sign-in is still saved.",busy:!1};if(Re(e,s,o))return{label:"Needs a key",tone:"warning",detail:null,busy:!1};if(g)return{label:"Sign-in didn't finish",tone:"warning",detail:null,busy:!1};if(o.needsSignIn)return{label:e.auth.kind==="api_key"||Re(e,s,o)?"Needs a key":"Needs sign-in",tone:"warning",detail:Xe(e.status_reason),busy:!1};if(e.status_basis==="stored"&&c&&o.disconnectedAt===null){const b=o.connectedAt??hn(e.last_seen_at,a);return{label:b!==null?`Worked ${Rr(a,b)} · ${Be(e.tool_count)}`:`Worked earlier · ${Be(e.tool_count)}`,tone:"success",detail:null,busy:!1}}return e.status_basis==="live"?{label:"Not connected",tone:"neutral",detail:null,busy:!1}:{label:"Ready",tone:"neutral",detail:null,busy:!1}}}const fn=e=>e===1?"Replace the saved key":"Replace saved keys",Er=/[,;]?\s*(?:or|and)?\s*add (?:its|a|the) key instead\.?\s*$/i;function Lr(e,s){const n=e?.trim()??"";if(!n)return null;if(s)return n;const a=n.replace(Er,"").trim();return a?/\.$/.test(a)?a:`${a}.`:n}const Ir="Nothing is wrong. It starts when a chat uses it.",Or="Not running in this chat.",Fr=e=>e.transport==="local_command"?"Local command":"Remote URL";function pn(e){switch(e.source.kind){case"local-operator":case"project-mcp-json":return null;case"claude-code":return"Claude Code";case"cursor":return"Cursor";case"vscode":return"VS Code";case"codex":return"Codex CLI";default:return un(e.source.path)}}function Dr(e,s){const n=[Fr(e)];e.status!=="connected"&&e.tool_count_basis==="last_seen"&&typeof e.tool_count=="number"&&n.push(`${Be(e.tool_count)} when last checked`),s&&n.push(e.scope==="project"?"This project":"Global");const a=pn(e);return a?n.push(`Imported from ${a}`):e.source.editable||n.push("Imported from a project file"),n}const yt=(e,s)=>s.disconnectedAt!==null?"not_started":e.status;function xt(e,s=[],n){const a=we(n,e.name),o=Me(e.name,s);if(o)return o.action==="login"||o.action==="reauth"?{kind:"sign_in",label:"Continue sign-in"}:null;const r=g=>e.actions.includes(g),u=qe(e),d=Re(e,s,a);if(!mn(e.status))return r("test")?{kind:"test",label:"Check again"}:null;const c=Le(e.name,s,a),m=c?.status==="failed"&&Ie(c);switch(yt(e,a)){case"connected":case"connecting":return null;case"needs_sign_in":return d?{kind:"set_key",label:"Add key"}:r("sign_in")?{kind:"sign_in",label:"Sign in"}:u?{kind:"set_key",label:"Add key"}:r("reauth")?{kind:"reauth",label:"Sign in again"}:{kind:"fix",label:"Fix"};case"error":return r("connect")?{kind:"connect",label:"Reconnect"}:r("test")?{kind:"test",label:"Retry"}:{kind:"fix",label:"Fix"};default:{if(Ye(c)&&r("sign_in"))return{kind:"sign_in",label:"Sign in"};if(kt(c)&&r("sign_out"))return{kind:"sign_out",label:"Sign out again"};if(a.disconnectedAt!==null&&r("connect"))return{kind:"connect",label:"Connect"};if(a.needsSignIn){if(d&&u)return{kind:"set_key",label:"Add key"};if(r("sign_in"))return{kind:"sign_in",label:"Sign in"}}return d&&u?{kind:"set_key",label:"Add key"}:m&&r("sign_in")?{kind:"sign_in",label:"Try again"}:gt(e,a)&&!r("connect")?null:r("connect")?{kind:"connect",label:"Connect",...a.connectedAt===null&&e.status_basis!=="live"?{variant:"ghost"}:{}}:r("test")&&e.tool_count===null&&e.tool_count_basis===null?{kind:"test",label:"Test",variant:"ghost"}:null}}}const Ie=e=>e.action==="login"||e.action==="reauth",Ye=e=>!!(e&&e.action==="logout"&&e.status==="complete"),kt=e=>!!(e&&e.action==="logout"&&e.status!=="running"&&e.status!=="complete"),gn=/no oauth authorization server/i;function Re(e,s,n){if(!qe(e))return!1;const a=Le(e.name,s,n);return a&&Ie(a)&&a.status==="failed"&&gn.test(a.message??"")?!0:n.needsKey}function $r(e,s=[],n){const a=xt(e,s,n)?.kind,o=yt(e,we(n,e.name)),r=c=>e.actions.includes(c),u=[],d=Me(e.name,s);if(d&&u.push({kind:"cancel",label:"Cancel"}),!d&&r("test")&&a!=="test"&&u.push({kind:"test",label:"Test connection"}),r("connect")&&a!=="connect"&&o!=="connected"&&u.push({kind:"connect",label:"Reconnect"}),!d&&r("sign_in")&&a!=="sign_in"&&o!=="connected"&&u.push({kind:"sign_in",label:"Sign in"}),r("reload")&&u.push({kind:"reload",label:"Reload"}),!d&&r("reauth")&&a!=="reauth"&&u.push({kind:"reauth",label:"Sign in again"}),qe(e)&&a!=="set_key"&&u.push({kind:"set_key",label:e.auth.secret_refs.length>0?"Update key":"Add key"}),r("sign_out")&&u.push({kind:"sign_out",label:"Sign out"}),r("disconnect")&&o==="connected"&&u.push({kind:"disconnect",label:"Disconnect"}),r("copy_setup")&&e.setup_prompt&&u.push({kind:"copy_setup",label:"Copy setup prompt"}),a!=="fix"&&u.push({kind:"open_config",label:"Open config file"}),r("remove"))u.push({kind:"remove",label:"Remove",destructive:!0});else if(!e.source.editable){const c=pn(e);u.push({kind:"remove_elsewhere",label:c?`Remove in ${c}`:"Remove in its own file",hint:c?`Defined in ${c}'s config. Remove it there.`:"Defined in a file this app doesn't write. Remove it there."})}return u}const Ur={attention:"Needs attention",connected:"Connected",ready:"Available"};function yn(e,s=[],n){const a=we(n,e.name),o=Me(e.name,s),r=yt(e,a);if(o&&a.pinnedGroup&&a.pinnedOperationId===o.id)return a.pinnedGroup;if(r==="needs_sign_in"||r==="error")return"attention";const u=Le(e.name,s,a);return Ye(u)&&r!=="connected"||kt(u)&&r!=="connected"?"attention":a.disconnectedAt!==null?"ready":Re(e,s,a)||a.needsSignIn&&r!=="connected"||u?.status==="failed"&&Ie(u)&&r!=="connected"?"attention":r==="connected"||e.status_basis==="stored"&>(e,a)?"connected":o&&o.action!=="test"?"attention":"ready"}function zr(e,s=[],n){return["attention","connected","ready"].map(o=>({id:o,title:Ur[o],rows:e.filter(r=>yn(r,s,n)===o)})).filter(o=>o.rows.length>0)}function Pr(e,s,n=Date.now()){if(!s)return e??{};const a={};for(const o of s.servers){const r=we(e,o.name),u=Me(o.name,s.operations),d=Le(o.name,s.operations,r),c=Ye(d),m=o.status==="connected"&&(o.status_basis==="probe"||o.status_basis==="live"),g=r.holdUntil!==null&&n<r.holdUntil,b=!g&&!c&&r.connectedAt===null&&o.status_basis==="stored"&&o.tool_count_basis==="last_seen"?hn(o.last_seen_at,n):null,k=!c,f=d?.status==="failed"&&Ie(d)&&gn.test(d.message??""),x={connectedAt:m&&!g?n:b!==null?b:k?r.connectedAt:null,connectedToolCount:m&&!g||b!==null?o.tool_count??r.connectedToolCount:k?r.connectedToolCount:null,settledGroup:r.settledGroup,pinnedGroup:u&&r.pinnedOperationId===u.id?r.pinnedGroup:u?r.settledGroup:null,pinnedOperationId:u?u.id:null,needsKey:m?!1:r.needsKey||f,needsSignIn:m||c?!1:r.needsSignIn||o.status==="needs_sign_in",disconnectedAt:m&&!g?null:r.disconnectedAt,holdUntil:g?r.holdUntil:null,lastDecisive:d?Cr(d):null};u||(x.settledGroup=yn(o,s.operations,{...a,[o.name]:x})),a[o.name]=x}return a}const Hr=(e,s)=>e!==null&&s===e,lt="local-operator.settings.integrations.row-memory",xn=(e,s)=>`${e}#${s}`;function Kr(e,s){const n={};if(!s)return n;for(const a of s.servers){const o=e[a.name];o&&(n[xn(a.source.path,a.name)]=o)}return n}function Br(e,s,n){if(!s)return e;let a=null;for(const o of s.servers){if(Object.prototype.hasOwnProperty.call(e,o.name))continue;const r=qr(n[xn(o.source.path,o.name)]);r&&(a=a??{...e},a[o.name]=r)}return a??e}const Vr=["attention","connected","ready"],kn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),vt=e=>typeof e=="number"&&Number.isFinite(e)?e:null,Ut=e=>Vr.includes(e)?e:null,et=e=>{const s=vt(e);return s!==null&&s>=1e12?s:null};function Gr(e){if(!kn(e)||typeof e.id!="string"||typeof e.name!="string")return null;const s=e.action,n=e.status;return s!=="login"&&s!=="logout"&&s!=="reauth"&&s!=="test"||n!=="running"&&n!=="complete"&&n!=="cancelled"&&n!=="failed"?null:{id:e.id,name:e.name,action:s,status:n,created_at:vt(e.created_at)??0,credential_removed:e.credential_removed===!0,...typeof e.message=="string"?{message:e.message}:{}}}function qr(e){if(!kn(e))return null;const s=et(e.connectedAt),n=et(e.disconnectedAt),a=e.needsKey===!0,o=e.needsSignIn===!0,r=Gr(e.lastDecisive);return s===null&&n===null&&!a&&!o&&!r?null:{connectedAt:s,connectedToolCount:vt(e.connectedToolCount),settledGroup:Ut(e.settledGroup),pinnedGroup:Ut(e.pinnedGroup),pinnedOperationId:typeof e.pinnedOperationId=="string"?e.pinnedOperationId:null,needsKey:a,needsSignIn:o,disconnectedAt:n,holdUntil:et(e.holdUntil),lastDecisive:r}}const vn=2e3,zt=8e3;function Yr(e){return e&&(e.servers.some(n=>n.status==="connecting")||e.operations.some(n=>n.status==="running"))?vn:!1}const Wr=/^[A-Za-z0-9_.:-]{1,100}$/,Zr=/:\/\//;function Qr(e,s){const n=e.trim();return n?Wr.test(n)?s.includes(n)?`An integration named ${n} already exists.`:null:"Use letters, numbers, dots, dashes, underscores or colons, with no spaces.":"Give it a name."}function Jr(e){const s=e.trim();if(!s)return"Enter the server's URL.";let n;try{n=new URL(s)}catch{return"Enter a full URL, like https://mcp.example.com/mcp."}return n.protocol!=="https:"&&n.protocol!=="http:"?"The URL must start with https:// or http://.":n.hostname?n.username||n.password?"Remove the username or password from the URL. Keys are added after it's saved.":n.search||n.hash?"Remove the ? or # part of the URL. Keys are added after it's saved.":Zr.test(s.slice(n.protocol.length+2))?"This looks like two URLs pasted together. Enter just one.":null:"The URL needs a host name."}const Xr=e=>e.split(`
|
|
292
|
+
`).map(s=>s.trim()).filter(Boolean);function dt(e,s){const n=!!e?.cold,a=(e?.servers??[]).map(o=>{const r=o.transport==="http",u=o.secret_refs??[],d=o.status==="connected"?"connected":o.status==="connecting"?"connecting":o.status==="auth-required"?"needs_sign_in":"not_started",c=[];d!=="connected"&&c.push("connect"),d==="connected"&&c.push("disconnect"),n||c.push("reload"),r&&o.transport_oauth_supported!==!1&&c.push("sign_in"),u.length>0&&c.push("set_key"),o.owned_scope&&c.push("remove"),o.setup?.text&&c.push("copy_setup");const m=un(o.source);return{id:o.name,name:o.name,scope:o.owned_scope??"global",project_cwd:null,source:{kind:ei(o.source,m,o.owned_scope),path:o.source??"",editable:o.owned_scope!==null,owned_scope:o.owned_scope},transport:r?"remote_url":"local_command",endpoint:{command:null,url:null,endpoint_redacted:!1},status:d,status_reason:null,status_observed_at:null,last_seen_at:null,status_basis:n?"stored":"live",auth:{kind:u.length?"api_key":r?"unknown":"none",signed_in:null,secret_refs:u.map(g=>({id:g.id,state:"missing"}))},tool_count:typeof o.tool_count=="number"?o.tool_count:null,tool_count_basis:typeof o.tool_count=="number"?"live":null,actions:c,setup_prompt:o.setup?.text??null}});return{cwd:"",project_scope_available:a.some(o=>o.source.owned_scope==="project"),global_path:"",project_path:null,status_source:n?"config":"live",session_id:s,servers:a,operations:(e?.operations??[]).map(o=>({...o}))}}const ei=(e,s,n)=>s==="Claude Code"?"claude-code":s==="Cursor"?"cursor":s==="VS Code"?"vscode":s==="Codex CLI"?"codex":n?"local-operator":e?"project-mcp-json":"local-operator",Pt={invalid_config:"That configuration isn't valid. Check the command or the URL, then try again.",operation_unavailable:"That sign-in or test isn't running any more. Try again.",exists:"An integration with this name already exists. Choose another name.",not_owned:"It's defined in another tool's config, so it can't be changed here. Edit it in that file.",project_scope_unavailable:"There's no separate project config here, so it can only be added globally.",unknown_server:"It no longer exists. The list has been refreshed.",oauth_unsupported:"It doesn't use browser sign-in.",grant_running:"A sign-in or test is already running. Wait for it to finish, or cancel it.",too_many_operations:"Too many sign-ins and tests are waiting. Try again in a moment.",write_failed:"The config file couldn't be written. Check that it isn't read-only.",mcp_starting:"Integrations are still starting. Try again in a moment.",mcp_control_refused:"The server refused it, so nothing was changed."},ti="The server refused it, so nothing was changed. Try again.";function Pe(e,s,n){if(s instanceof ft&&s.status===409){const a=typeof s.code=="string"&&Object.prototype.hasOwnProperty.call(Pt,s.code)?Pt[s.code]:ti;return`${zn[e]}. ${a}`}return Pn(e,s,n).message}const ni="New chats can use it right away. Open chats pick it up when you start a new chat or reload integrations there.",si="Most services give you a URL. Use Local command when their setup says npx or uvx.",ai=({existingNames:e,projectScopeAvailable:s,projectLabel:n,onSubmit:a,onCancel:o,initial:r})=>{const[u,d]=i.useState(r?.name??""),[c,m]=i.useState(r?.mode??"command"),[g,b]=i.useState(r?.command??""),[k,f]=i.useState(r?.args??""),[x,L]=i.useState(r?.url??""),[S,K]=i.useState("global"),[_,$]=i.useState(r?.touched?{name:!0,command:!0,url:!0}:{}),[I,M]=i.useState(!!r?.touched),[N,G]=i.useState(!1),[P,q]=i.useState(null),H=i.useRef(null),X=i.useRef(null),A=i.useRef(null);i.useEffect(()=>{H.current?.focus()},[]);const T=Qr(u,e),V=c==="command"&&!g.trim()?"Enter the command to run.":null,z=c==="url"?Jr(x):null,O=C=>I||_[C],ee=async C=>{if(C.preventDefault(),M(!0),T||V||z){T?H.current?.focus():V?X.current?.focus():A.current?.focus();return}G(!0),q(null);const Z=s?S:"global",Q=c==="command"?{name:u.trim(),scope:Z,mode:c,command:g.trim(),args:Xr(k)}:{name:u.trim(),scope:Z,mode:c,url:x.trim()},J=await a(Q);G(!1),q(J)},R=(C,Z,Q)=>Z&&O(Q)?t.jsx("p",{id:C,className:"text-body-sm text-danger",children:Z}):null,ie=C=>C.preventDefault();return t.jsxs("form",{noValidate:!0,"aria-label":"Add integration",className:"flex flex-col gap-4 rounded-lg bg-surface p-4",onSubmit:C=>void ee(C),onKeyDown:C=>{C.key==="Escape"&&(C.stopPropagation(),o())},children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(fe,{htmlFor:"integration-add-name",children:"Name"}),t.jsx(Ce,{ref:H,id:"integration-add-name",value:u,placeholder:"e.g. notion",autoComplete:"off","aria-invalid":!!(T&&O("name")),"aria-describedby":T&&O("name")?"integration-add-name-error":void 0,onChange:C=>d(C.target.value),onBlur:()=>$(C=>({...C,name:!0}))}),R("integration-add-name-error",T,"name")]}),t.jsxs(Et,{value:c,onValueChange:C=>m(C==="url"?"url":"command"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-transport-label",className:"font-medium text-body-sm text-ink",children:"How it runs"}),t.jsxs(Lt,{"aria-labelledby":"integration-add-transport-label",children:[t.jsx(ze,{value:"command","data-integration-transport":"command",children:"Local command"}),t.jsx(ze,{value:"url","data-integration-transport":"url",children:"Remote URL"})]}),t.jsx("p",{className:"text-ink-dim text-meta",children:si}),t.jsxs(It,{value:"command",className:"mt-0 flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(fe,{htmlFor:"integration-add-command",children:"Command"}),t.jsx(Ce,{ref:X,id:"integration-add-command",value:g,placeholder:"e.g. npx",autoComplete:"off",className:"font-mono","aria-invalid":!!(V&&O("command")),"aria-describedby":V&&O("command")?"integration-add-command-error":void 0,onChange:C=>b(C.target.value),onBlur:()=>$(C=>({...C,command:!0}))}),R("integration-add-command-error",V,"command")]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsxs(fe,{htmlFor:"integration-add-args",children:["Arguments"," ",t.jsx("span",{className:"font-normal text-ink-dim",children:"(one per line)"})]}),t.jsx(cn,{id:"integration-add-args",value:k,rows:2,className:"font-mono",onChange:C=>f(C.target.value)})]})]}),t.jsx(It,{value:"url",className:"mt-0 flex flex-col gap-4",children:t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(fe,{htmlFor:"integration-add-url",children:"URL"}),t.jsx(Ce,{ref:A,id:"integration-add-url",type:"url",value:x,placeholder:"https://mcp.example.com/mcp",autoComplete:"off",className:"font-mono","aria-invalid":!!(z&&O("url")),"aria-describedby":z&&O("url")?"integration-add-url-error":"integration-add-url-help",onChange:C=>L(C.target.value),onBlur:()=>$(C=>({...C,url:!0}))}),R("integration-add-url-error",z,"url")??t.jsx("p",{id:"integration-add-url-help",className:"text-ink-dim text-meta",children:"If it needs a sign-in or a key, you'll be asked after it's added."})]})})]}),s?t.jsxs(Et,{value:S,onValueChange:C=>K(C==="project"?"project":"global"),className:"flex flex-col gap-1.5",children:[t.jsx("span",{id:"integration-add-scope-label",className:"font-medium text-body-sm text-ink",children:"Available in"}),t.jsxs(Lt,{"aria-labelledby":"integration-add-scope-label",children:[t.jsx(ze,{value:"global","data-integration-scope":"global",children:"All chats"}),t.jsx(ze,{value:"project","data-integration-scope":"project",children:"This project"})]}),n?t.jsx("p",{className:"text-ink-dim text-meta",children:S==="project"?`Only chats working in ${n}.`:"Every chat, in any folder."}):null]}):null,P?t.jsx("p",{className:"text-body-sm text-danger",role:"alert",children:P}):null,t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsx("p",{className:oe("text-body-sm text-ink-dim"),children:ni}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(D,{type:"button",variant:"ghost",size:"md",onMouseDown:ie,onClick:o,children:"Cancel"}),t.jsxs(D,{type:"submit",variant:"primary",size:"md",disabled:N,onMouseDown:ie,children:[N?t.jsx(re,{size:"xs"}):null,"Add integration"]})]})]})]})},oi=4;function ri(e){return e.rowMoving?e.now+e.windowMs:Math.max(e.hold.until,e.lastMovingAt+e.windowMs)}function ii(e){return e.now>e.hold.until||e.hold.reanchors>=oi?"drop":e.hold.landedOn.isConnected&&(!e.candidate||e.candidate===e.hold.landedOn)?"settled":e.active&&e.active!==e.body&&e.active!==e.hold.landedOn?"drop":e.candidate?.isConnected?"restore":"drop"}function ci(e){const s=ri({hold:e.hold,now:e.now,windowMs:e.windowMs,rowMoving:e.rowMoving,lastMovingAt:e.lastMovingAt});if(e.now>s)return{hold:null,land:null};const n=e.hold.landedOn??null,a=e.candidate;if(!a)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:n},land:null};if(!n)return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:a},land:a};const o=ii({hold:{until:s,reanchors:e.hold.reanchors,landedOn:n},candidate:a,active:e.active,body:e.body,now:e.now});if(o==="settled")return{hold:{until:s,reanchors:e.hold.reanchors,landedOn:n},land:null};if(o==="drop")return{hold:null,land:null};const r=!n.isConnected;return{hold:{until:r?e.now+e.windowMs:s,reanchors:r?e.hold.reanchors+1:e.hold.reanchors,landedOn:a},land:a}}function li(e){const{row:s,target:n}=e;return!s||!n||typeof n.nodeType!="number"?!1:!s.contains(n)}const Ht=250;function Kt(e){return e?!e.disabled:!1}function di(e){return Kt(e.primary)?e.primary??null:Kt(e.overflow)?e.overflow??null:null}function ui(e){return e.verdict==="finished"?null:e.watchMs}const bn="key";function mi(e){const{name:s,keyless:n,freeName:a,names:o,values:r,replace:u,canReplace:d}=e;if(n){const c=ut(s,a);return{values:{[c]:(r[bn]??"").trim()},confirmedReplace:u&&d?[c]:[],header:a.trim()}}return{values:Object.fromEntries(o.map(c=>[c,(r[c]??"").trim()])),confirmedReplace:u&&d?o:[],header:void 0}}function ut(e,s){const n=Bt(e),a=Bt(s);if(!a)return"";const o=[n,a].filter(Boolean).join("_"),r=/^[A-Za-z_]/.test(o)?o:`K_${o}`;if(r.length<=tt)return r;const u=hi(n),d=tt-a.length-u.length-2,c=[n.slice(0,Math.max(d,0)),u,a].filter(Boolean).join("_");return c.length<=tt?c:c.slice(-128)}const tt=128,Bt=e=>e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,""),hi=e=>{let s=2166136261;for(let n=0;n<e.length;n+=1)s^=e.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s.toString(36).toUpperCase().slice(0,5)},fi=({name:e,keyNames:s,keyless:n=!1,savedKeys:a=[],saving:o,failure:r,onSave:u,onClose:d})=>{const[c,m]=i.useState({}),[g,b]=i.useState(!1),[k,f]=i.useState(""),x=n?[ut(e,k)]:[...s],L=n?[bn]:x,S=(n?ut(e,k).length>0:!0)&&L.every(_=>(c[_]??"").trim()),K=x.some(_=>a.includes(_));return t.jsx(en,{open:!0,onClose:d,maxWidth:"xs",title:n||s.length===1?`Add the key for ${e}`:`Add keys for ${e}`,actions:t.jsxs(t.Fragment,{children:[t.jsx(at,{onClick:d,children:"Cancel"}),t.jsx(ot,{disabled:!S||o,onClick:()=>{const _=mi({name:e,keyless:n,freeName:k,names:x,values:c,replace:g,canReplace:K});u(_.values,_.confirmedReplace,_.header)},children:o?"Saving…":"Save and test"})]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted",children:[t.jsx("p",{className:"-mx-1.5",children:n?"Keys are saved encrypted on this computer. This one is stored under a name derived from this integration, so no other server shares it.":"Keys are saved encrypted on this computer. Other integrations that use the same key name share it."}),n?t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(fe,{htmlFor:"integration-key-name",children:"The header this server wants the key in"}),t.jsx(Ce,{id:"integration-key-name",autoComplete:"off",placeholder:"e.g. Authorization or X-Api-Key",value:k,onChange:_=>f(_.target.value)}),t.jsx("p",{className:"-mx-1.5 text-ink-dim text-meta",children:"This server declares no key of its own, so Local Operator adds one to its config for you."})]}):null,L.filter(_=>n!==!0||_.trim().length>0).map(_=>t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(fe,{htmlFor:`integration-key-${_}`,className:"font-mono",children:n?"Key":_}),t.jsx(Ce,{id:`integration-key-${_}`,type:"password",autoComplete:"off",value:c[_]??"",onChange:$=>m(I=>({...I,[_]:$.target.value}))})]},_)),K?t.jsxs("div",{className:"flex items-center gap-2 text-body-sm",children:[t.jsx(Fs,{id:"integration-key-replace",checked:g,onCheckedChange:_=>b(_===!0)}),t.jsx(fe,{htmlFor:"integration-key-replace",className:"font-normal",children:fn(x.length)})]}):null,r?t.jsx("p",{className:"-mx-1.5 text-body-sm text-danger",role:"alert",children:r}):null]})})},pi={success:"bg-success",warning:"bg-warning",danger:"bg-danger",info:"bg-info",neutral:"bg-ink-dim"},gi={success:"text-ink-muted",warning:"text-warning",danger:"text-danger",info:"text-ink-muted",neutral:"text-ink-dim"},Vt={Ready:Ir,"Not connected":Or},yi=({row:e,operations:s,memories:n,now:a,projectScopeAvailable:o,highlighted:r=!1,rowRef:u,primaryRef:d,overflowRef:c,pending:m,failure:g,confirm:b,onPrimary:k,onOverflow:f,onConfirm:x,onCancelConfirm:L})=>{const S=Tr(e,s,n,a),K=r&&S.tone==="danger"?"text-ink":gi[S.tone],_=xt(e,s,n),$=$r(e,s,n),I=Dr(e,o),M=$.findIndex(N=>N.kind==="remove"||N.kind==="remove_elsewhere");return t.jsxs("li",{ref:u,"data-integration":e.name,"data-status":e.status,className:oe("flex min-h-14 flex-col justify-center gap-1 px-4 py-2.5",r&&"bg-row-selected"),onKeyDown:N=>{!b||N.key!=="Escape"||(N.stopPropagation(),L())},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:S.busy?t.jsx(re,{size:"xs"}):t.jsx("span",{"aria-hidden":"true","data-tone":S.tone,className:oe("size-2 rounded-full",pi[S.tone])})}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsx("span",{className:"truncate font-medium text-body text-ink",title:e.name,children:e.name}),t.jsx("span",{className:"truncate text-ink-dim text-meta",children:I.map((N,G)=>t.jsxs("span",{children:[G>0?" · ":null,N.startsWith("Imported from")&&e.source.path?t.jsx(Te,{content:Ns(e.source.path),children:t.jsx("span",{className:"underline decoration-dotted underline-offset-2",children:N})}):N]},N))})]}),Vt[S.label]?t.jsx(Te,{content:Vt[S.label],children:t.jsx("span",{className:oe("shrink-0 text-body-sm",K),children:S.label})}):t.jsx("span",{className:oe("shrink-0 text-body-sm",K),children:S.label}),_?t.jsxs(D,{ref:d,variant:_.variant??"secondary",size:"sm","aria-label":`${_.label} ${e.name}`,disabled:m,"data-integration-action":_.kind,onClick:()=>k(_),children:[m?t.jsx(re,{size:"xs"}):null,_.label]}):null,t.jsxs(Ds,{children:[t.jsx($s,{asChild:!0,children:t.jsx(D,{ref:c,variant:"ghost",size:"icon-sm","aria-label":`More actions for ${e.name}`,disabled:m,children:t.jsx(Hn,{"aria-hidden":"true"})})}),t.jsx(Us,{align:"end",className:"min-w-48",children:$.map((N,G)=>t.jsx(xi,{item:N,separated:G===M&&G>0,onSelect:()=>f(N)},N.kind))})]})]}),S.detail?t.jsx("p",{className:oe("pl-7 text-body-sm",S.tone==="danger"?"text-ink-muted":"text-ink-dim"),children:S.detail}):null,g?t.jsx("p",{className:oe("pl-7 text-body-sm",r?"text-ink":"text-danger"),role:"alert",children:g}):null,b?t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-7",children:[t.jsx("span",{className:"text-body-sm text-ink",children:b.kind==="remove"?`Remove ${e.name}?`:`Sign out of ${e.name}?`}),t.jsx("span",{className:"text-body-sm text-ink-muted",children:b.kind==="remove"?`Agents in every chat lose access to ${e.name}.`:e.auth.kind==="oauth"?"The saved sign-in is removed too.":"Its saved credential is removed too."}),t.jsx(D,{variant:"danger",size:"sm",onClick:x,"data-integration-confirm":b.kind,children:b.kind==="remove"?"Remove":"Sign out"}),t.jsx(D,{variant:"ghost",size:"sm",onClick:L,children:"Keep"})]}):null]})},xi=({item:e,separated:s,onSelect:n})=>t.jsxs(t.Fragment,{children:[s?t.jsx(zs,{}):null,e.kind==="remove_elsewhere"?t.jsxs(Ot,{disabled:!0,className:"flex-col items-start gap-0.5",children:[t.jsx("span",{children:e.label}),t.jsx("span",{className:"text-meta text-ink-dim",children:e.hint})]}):t.jsx(Ot,{destructive:e.kind==="remove",onSelect:n,"data-integration-menu":e.kind,children:e.label})]});function ki(e,s,n){return!s||s.status==="running"?s?.browser_opened===!0?{message:`Your browser opened. Approve access to ${e} there, then come back here.`,tone:"progress",link:s.authorization_url??null}:s?.browser_opened===!1?{message:s.authorization_url?"Your browser didn't open. Open this link to approve access:":"Your browser didn't open, and no link was provided. Cancel and try again.",tone:"progress",link:s.authorization_url??null}:{message:`Waiting for you to approve access to ${e}…`,tone:"progress",link:s?.authorization_url??null}:s.status==="complete"?{message:`Signed in to ${e}. Agents can use it now.`,tone:"success",link:null}:s.status==="cancelled"?{message:"Sign-in cancelled.",tone:"failure",link:null,reason:null,nextStep:"Press Try again when you are ready."}:{message:"Sign-in didn't finish.",tone:"failure",link:null,reason:Lr(s.message,n)??"The server didn't say why.",nextStep:vi(s.message??null,n)}}function vi(e,s){const n=(e??"").toLowerCase();return n.includes("redirect")?s?"This server may not accept sign-ins from Local Operator. Check the server's settings, or add a key instead.":"This server may not accept sign-ins from Local Operator. Check the server's settings, then try again.":n.includes("no oauth")||n.includes("authorization server")?s?"This server doesn't publish a browser sign-in. Add its key instead.":"This server doesn't publish a browser sign-in. Check the server's settings, then try again.":n.includes("network")||n.includes("connect")?"Check the server's URL and your network, then try again.":"Check the server's settings, then try again."}function bi(e,s){return e.kind==="ready"?"ready":e.kind==="running"&&s&&s.tone!=="progress"?s.tone==="success"?"success":"failure":"running"}const wi=({name:e,action:s,keyRoute:n,phase:a,onStart:o,onCancel:r,onOpenLink:u,onClose:d})=>{const c=a.kind==="running"?a.operation:null,m=a.kind==="running"?ki(e,c,n):null,g=a.kind==="starting"||a.kind==="running"&&m?.tone==="progress",b=m&&m.tone!=="progress",k=i.useRef(null),f=i.useRef(!1),x=bi(a,m);i.useEffect(()=>{if(!f.current){f.current=!0;return}x&&k.current?.focus()},[x]);const L=()=>d(m?.tone==="success"?"signed-in":"dismissed");return t.jsx(en,{open:!0,onClose:L,maxWidth:"xs",fullWidth:!0,title:`Sign in to ${e}`,dialogProps:{onOpenAutoFocus:S=>{S.preventDefault(),k.current?.focus()}},actions:t.jsxs(t.Fragment,{children:[g&&c?t.jsx(at,{ref:k,onClick:()=>r(c.id),children:"Cancel sign-in"}):t.jsx(at,{ref:a.kind==="ready"?void 0:k,onClick:L,children:m?.tone==="success"?"Done":"Close"}),a.kind==="ready"?t.jsx(ot,{ref:k,onClick:o,children:"Continue in browser"}):null,a.kind==="refused"||m?.tone==="failure"?t.jsx(ot,{ref:m?.tone==="failure"?k:void 0,onClick:o,children:"Try again"}):null]}),children:t.jsxs("div",{className:"flex flex-col gap-3 p-1.5 text-body text-ink-muted","aria-live":"polite",children:[a.kind==="ready"?t.jsxs("p",{className:"-mx-1.5",children:["Local Operator opens your browser so you can approve access to"," ",e,".",s==="reauth"?" This replaces the sign-in it has now.":""]}):null,a.kind==="starting"?t.jsxs("p",{className:"-mx-1.5 flex items-center gap-2",children:[t.jsx(re,{size:"xs"}),"Starting sign-in…"]}):null,m?t.jsxs("div",{className:"flex flex-col gap-1",role:b?"status":void 0,children:[t.jsxs("p",{className:(m.tone==="success","-mx-1.5 flex items-start gap-2 text-ink"),children:[m.tone==="progress"?t.jsx(re,{size:"xs",className:"mt-0.5"}):null,m.tone==="failure"?t.jsx(Ps,{"aria-hidden":"true",className:"mt-0.5 size-4 shrink-0 text-danger"}):null,t.jsx("span",{children:m.message})]}),m.reason?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.reason}):null,m.nextStep?t.jsx("p",{className:"-mx-1.5 text-ink-muted",children:m.nextStep}):null]}):null,m?.link&&m.tone==="progress"?t.jsxs("div",{className:"flex flex-col items-start gap-1",children:[t.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-ink-dim text-mono-sm",title:m.link,children:m.link}),t.jsx(D,{variant:"ghost",size:"icon-sm","aria-label":"Copy the sign-in link",title:"Copy the sign-in link",onClick:()=>{navigator.clipboard.writeText(m.link??"").then(()=>rt("Sign-in link copied.")).catch(()=>{})},children:t.jsx(Kn,{"aria-hidden":"true"})})]}),t.jsx(D,{variant:"link",size:"sm",onClick:()=>u(m.link??""),children:"Open the sign-in page"})]}):null,a.kind==="refused"?t.jsx("p",{className:"text-danger",role:"alert",children:a.message}):null]})})},ji={catalog:(e,s)=>["desktop","mcp-catalog",e??"",s??""],all:["desktop","mcp-catalog"]},_i=async(e,s)=>(await be({op:"mcp.catalog",...e?{cwd:e}:{},...s?{sessionId:s}:{}})).data,Ni=async(e,s)=>(await be({op:"mcp.catalog.control",...e?{cwd:e}:{},control:s})).data,Si=async(e,s,n,a,o)=>(await be({op:"mcp.catalog.credentials",...e?{cwd:e}:{},name:s,values:n,confirmedReplace:a,...o?{header:o}:{}})).data,Ci=e=>e.reduce((s,n)=>s?(n.updated_at??0)>(s.updated_at??0)?n:s:n,null),Mi=/^[A-Za-z]:[\\/]/,Ve=e=>{const s=e?.trim();return s&&(s.startsWith("/")||Mi.test(s))?s:null};function Ai(e){const o=e?.payload?.frontend?.snapshot?.cwd;return typeof o=="string"&&o.trim()?o:null}const Ee="local-operator.settings.integrations.last-cwd";function Ri(e,s,n=typeof localStorage>"u"?null:localStorage){const a=Ve(s);if(!(!e||!a||!n))try{const o=n.getItem(Ee),r=o?JSON.parse(o):{};if(r[e]===a)return;n.setItem(Ee,JSON.stringify({...r,[e]:a}))}catch{}}const wn=()=>typeof localStorage>"u"?null:localStorage;function jn(e=wn()){if(!e)return{};try{const s=e.getItem(lt);if(!s)return{};const n=JSON.parse(s);return!n||typeof n!="object"||Array.isArray(n)?{}:n}catch{return{}}}const Gt=256;function Ti(e,s=wn()){if(s)try{const n={...jn(s),...e},a=Object.keys(n);if(a.length>Gt){const o={};for(const r of a.slice(-Gt))o[r]=n[r];s.setItem(lt,JSON.stringify(o));return}s.setItem(lt,JSON.stringify(n))}catch{}}function qt(e,s,n){return e==="saved"?null:e==="replace_confirmation_required"?`A saved value already exists for this key. Tick “${fn(Object.keys(n).length)}” to overwrite it.`:e==="invalid_target"?"That header can't carry this key. It may already be set on the server, or belong to the transport - try a different header name. Nothing was saved.":`Not saved: ${(s.length?s:Object.keys(n)).join(", ")}. The encrypted store may be locked.`}function Ei(e,s=typeof localStorage>"u"?null:localStorage){if(!(!e||!s))try{const n=s.getItem(Ee);if(!n)return;const a=JSON.parse(n);if(!(e in a))return;const o={...a};delete o[e],s.setItem(Ee,JSON.stringify(o))}catch{}}const Li=e=>!!(e&&typeof e=="object"&&"code"in e&&e.code==="invalid_cwd"),Ii=(e,s)=>s!==null&&e===s?null:e;function Oi(e,s=typeof localStorage>"u"?null:localStorage){if(!e||!s)return null;try{const n=s.getItem(Ee);if(!n)return null;const o=JSON.parse(n)[e];return typeof o=="string"?o:null}catch{return null}}const Fi=e=>e.action==="disconnect"?"disconnected":"connected";function Di(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"connect":case"disconnect":case"reload":return null;case"test":return{action:"test",name:e.name};default:return{...e,confirmed:!0}}}function $i(e){switch(e.action){case"cancel":return{action:"cancel",operation_id:e.operationId};case"test":case"connect":return{action:"connect",name:e.name};case"reload":return{action:"reload",name:e.name};case"add":return e;case"remove":return{...e,confirmed:!0};default:return{action:e.action,name:e.name,confirmed:!0}}}function Ui({sessionId:e}){const s=Ss(),n=Tt(s.data,"mcp_catalog"),a=Tt(s.data,"mcp"),o=n?"catalog":a?"session":null,[r,u]=i.useState(null),d=rn(),c=He(h=>h.sessions),m=He(h=>h.fetchSessions),g=He(h=>h.loading),b=i.useMemo(()=>c.find(h=>h.session_id===e)??null,[c,e]),k=i.useMemo(()=>o==="session"&&!e?Ci(c):null,[o,e,c]),f=o==="session"?e??k?.session_id??null:null;i.useEffect(()=>{o!=="session"||e||c.length>0||m(Cs)},[o,e,c.length,m]);const x=o==="catalog"?Ve(b?.cwd):null,L=o==="catalog"&&!!e&&x===null,S=Se({queryKey:["desktop","session-cwd",e??""],queryFn:()=>be({op:"sessions.get",sessionId:e??""}),enabled:L,staleTime:Number.POSITIVE_INFINITY,retry:!1}),K=L&&!S.isFetched,_=x??Ve(Ai(S.data))??(S.isFetched?Ve(Oi(e)):null),$=Ii(_,r),I=o==="catalog"?$:null,M=o==="catalog"?e??null:null,N=ji.catalog(I,M);i.useEffect(()=>{o!=="catalog"||!e||!I||Ri(e,I)},[o,e,I]);const G=i.useRef(0),[P,q]=i.useState(0),H=i.useRef(null),X=i.useCallback((h,w)=>{const v=Date.now()+zt;G.current=v,H.current={name:h,expect:w},q(v)},[]),A=i.useCallback(h=>Date.now()<G.current?vn:Yr(h),[]),T=Se({queryKey:N,queryFn:()=>_i(I,M),enabled:o==="catalog"&&!K,staleTime:1e4,refetchInterval:h=>A(h.state.data)}),V=Li(T.error);i.useEffect(()=>{!V||!_||r===_||(u(_),Ei(e))},[V,_,r,e]);const z=Se({queryKey:it.list(f??""),queryFn:()=>Bn(f??""),enabled:o==="session"&&!!f,staleTime:1e4,refetchInterval:h=>A(h.state.data?dt(h.state.data,f??""):void 0)}),O=i.useMemo(()=>{if(o==="catalog")return T.data;if(o==="session"&&z.data&&f)return dt(z.data,f)},[o,T.data,z.data,f]),ee=i.useCallback(()=>zi({queryClient:d,route:o,catalogKey:N,sessionId:f}),[o,N,d,f]);i.useEffect(()=>{if(!P)return;const h=H.current;if(!h)return;const w=O?.servers.find(U=>U.name===h.name);!w||!(h.expect==="connected"?w.status==="connected":w.status_basis==="live"&&w.status!=="connected")||(G.current=0,H.current=null,q(0))},[O,P]);const R=i.useRef({}),[ie,C]=i.useState(0),Z=i.useMemo(()=>(R.current=Pr(Br(R.current,O,jn()),O),R.current),[O,ie]),Q=i.useRef("");i.useEffect(()=>{const h=Kr(Z,O);if(!Object.keys(h).length)return;const w=JSON.stringify(h);w!==Q.current&&(Q.current=w,Ti(h))},[Z,O]);const J=i.useCallback(h=>{const w=we(R.current,h);w.needsKey||(R.current={...R.current,[h]:{...w,needsKey:!0}},C(v=>v+1))},[]),Y=i.useCallback(h=>{if(h.action!=="disconnect"&&h.action!=="connect"&&h.action!=="reload")return;const w=we(R.current,h.name),v=Date.now()+zt,U=h.action==="disconnect"?{...w,connectedAt:null,disconnectedAt:Date.now(),holdUntil:v}:{...w,disconnectedAt:null,holdUntil:v};R.current={...R.current,[h.name]:U},X(h.name,Fi(h)),C(F=>F+1)},[X]),W=i.useCallback(async h=>{if(o==="catalog"){const w=Di(h);if(!w)return null;try{const v=await Ni(I,w);return d.setQueryData(N,v),Y(h),v.operation?.id??null}catch(v){throw v instanceof ft&&v.status===409&&d.invalidateQueries({queryKey:N}),v}}if(o==="session"&&f){const w=await be({op:"mcp.control",sessionId:f,control:$i(h)});Y(h);const v=it.list(f),U=w?.data;return U&&"servers"in U&&Array.isArray(U.servers)?(d.setQueryData(v,U),null):(d.invalidateQueries({queryKey:v}),U&&"id"in U&&typeof U.id=="string"?U.id:null)}return null},[o,I,N,d,f,Y]),pe=i.useCallback(async h=>{if(o==="catalog"&&M&&(h.action==="connect"||h.action==="disconnect"||h.action==="reload")){try{await be({op:"mcp.control",sessionId:M,control:{action:h.action,name:h.name,...h.action==="disconnect"?{confirmed:!0}:{}}})}catch(w){throw d.invalidateQueries({queryKey:N}),w}return Y(h),await d.invalidateQueries({queryKey:N}),null}return W(h)},[o,M,d,N,W,Y]),je=i.useCallback(async(h,w,v,U)=>{if(o==="catalog"){const F=await Si(I,h,w,v,U);if(F.catalog&&d.setQueryData(N,F.catalog),F.code!=="saved")return{saved:!1,message:qt(F.code,F.failed_ids,w)};try{await W({action:"test",name:h})}catch{}return{saved:!0,message:null}}if(o==="session"&&f){const F=await be({op:"mcp.credentials.store",sessionId:f,name:h,values:w,confirmedReplace:v});if(F.data?.code!=="saved")return{saved:!1,message:qt(F.data?.code,F.data?.failed_ids??[],w)};try{await W({action:"connect",name:h})}catch{}return{saved:!0,message:null}}return{saved:!1,message:null}},[o,I,N,d,W,f]),de=o==="catalog"?T:z,ge=i.useCallback(()=>{de.refetch()},[de]);return{enabled:o!==null,route:o,sessionId:o==="catalog"?M:f,borrowed:k,noConversation:o==="session"&&!f&&!g,document:O,isLoading:s.isLoading||o==="catalog"&&(K||T.isLoading)||o==="session"&&(f?z.isLoading:g),isError:de.isError,folderUnavailable:Hr(r,_),refetch:ge,readDocument:ee,control:pe,storeKeys:je,memories:Z,markNeedsKey:J}}function zi(e){if(e.route==="catalog")return e.queryClient.getQueryData(e.catalogKey);if(e.route==="session"&&e.sessionId){const s=e.queryClient.getQueryData(it.list(e.sessionId));return s?dt(s,e.sessionId):void 0}}const Pi=(e,s)=>{const n=e?.trim();if(!n)return null;const a=Yn(n,s);return a.kind==="auth"?{kind:"matched",name:a.name,unresolved:null}:{kind:"miss",asked:n}},Hi=6,nt="Integrations",Ki="Let agents use your tools and accounts, like Notion, Linear or GitHub.",Bi={test:"test",connect:"reconnect",disconnect:"disconnect",reload:"reload",remove:"remove",sign_out:"disconnect",cancel:"cancel",login:"grant",reauth:"grant"},Vi=({sessionId:e,sectionRef:s,highlightServer:n})=>{const a=Ui({sessionId:e}),{document:o,control:r,readDocument:u}=a,d=Vn(),c=o?.servers??[],m=o?.operations??[],g=o?.project_scope_available??!1,[b,k]=i.useState(!1),[f,x]=i.useState(""),[L,S]=i.useState(null),[K,_]=i.useState({}),[$,I]=i.useState(null),[M,N]=i.useState(null),[G,P]=i.useState({kind:"ready"}),[q,H]=i.useState(null),[X,A]=i.useState(null),[T,V]=i.useState(!1),z=i.useRef({}),O=i.useRef({}),ee=i.useRef({}),R=i.useRef(0),ie=i.useRef(null),C=i.useRef(null),Z=i.useRef(null),[Q,J]=i.useState(null),[Y,W]=i.useState(null),[pe,je]=i.useState(null),de=i.useCallback(()=>{const l=Z.current;Z.current=null,N(null),H(null),window.setTimeout(()=>{l?.isConnected&&l.focus()},0)},[]),ge=i.useCallback(l=>{const p=window.document.activeElement;Z.current=p instanceof HTMLElement?p:null,N(l)},[]),h=i.useCallback((l,p)=>{W({name:l,waitForSignIn:p==="signed-in",until:Date.now()+Ae,reanchors:0}),de()},[de]),w=i.useMemo(()=>Pi(n,c.map(l=>l.name)),[n,c]),v=w?.kind==="matched"?w.name:null,U=i.useRef(null),F=i.useRef(null),te=f.trim().toLowerCase(),B=i.useMemo(()=>te?c.filter(l=>l.name.toLowerCase().includes(te)):c,[c,te]),_e=i.useMemo(()=>zr(B,m,a.memories),[B,m,a.memories]),ue=M?.kind==="sign_in"?c.find(l=>l.name===M.name)??null:null;i.useEffect(()=>{!v||F.current===v||!f||x("")},[v,f]),i.useEffect(()=>{!v||F.current===v||B.some(l=>l.name===v)&&(F.current=v,U.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[v,B]),i.useEffect(()=>{if(!q)return;const l=m.find(p=>p.id===q)??null;P({kind:"running",operation:l})},[m,q]);const ce=m.some(l=>l.status==="running"),ye=l=>{const p=window.document.activeElement;p&&p!==window.document.body&&p.isConnected||W({name:l,waitForSignIn:!1,until:Date.now()+Ae,reanchors:0})},ne=async(l,p,j)=>{S(l),_(({[l]:xe,...ke})=>ke);let E=null,me=!1;try{E=await j()}catch(xe){me=!0,_(ke=>({...ke,[l]:Pe(Bi[p]??"status",xe,ce)}))}finally{S(null),p!=="sign_out"&&(p!=="remove"||me)&&ye(l)}return{operationId:E,failed:me}},We=l=>c.find(p=>p.name===l),Oe=l=>{l.source.path&&Wn(l.source.path)},Ze=async(l,p)=>{P({kind:"starting"}),H(null);try{const j=await r({action:p,name:l});j?H(j):P({kind:"running",operation:null})}catch(j){j instanceof ft&&j.code==="oauth_unsupported"&&a.markNeedsKey(l),P({kind:"refused",message:Pe("grant",j,ce)})}},Fe=(l,p)=>{switch(p.kind){case"sign_in":case"reauth":{const j=m.find(E=>E.name===l.name&&E.status==="running");j&&Ie(j)?(P({kind:"running",operation:j}),H(j.id)):(P({kind:"ready"}),H(null)),ge({kind:"sign_in",name:l.name,action:p.kind==="reauth"?"reauth":"login"});return}case"set_key":A(null),ge({kind:"key",name:l.name,keyNames:l.auth.secret_refs.map(j=>j.id)});return;case"fix":Oe(l);return;case"sign_out":I({name:l.name,kind:"sign_out"});return;default:{const j=p.kind;ne(l.name,j,()=>r({action:j,name:l.name}))}}},bt=(l,p)=>{switch(p.kind){case"remove":case"sign_out":I({name:l.name,kind:p.kind});return;case"sign_in":case"reauth":case"set_key":Fe(l,{kind:p.kind,label:p.label});return;case"open_config":Oe(l);return;case"copy_setup":navigator.clipboard.writeText(l.setup_prompt??"").then(()=>rt("Setup steps copied. Paste them into a chat.")).catch(()=>{});return;case"cancel":{const j=m.find(E=>E.name===l.name&&E.status==="running");j&&ne(l.name,"cancel",()=>r({action:"cancel",operationId:j.id}));return}case"test":case"connect":case"disconnect":case"reload":{const j=p.kind;ne(l.name,j,()=>r({action:j,name:l.name}));return}default:return}},De=(l,p)=>{if(I(null),p==="remove"){const j=l.source.owned_scope;if(!j)return;const E=B.findIndex(me=>me.name===l.name);ne(l.name,"remove",()=>r({action:"remove",name:l.name,scope:j})).then(({operationId:me,failed:xe})=>{xe||me!==null||(rt(`Removed ${l.name}.`),E>=0&&je({index:E}))});return}ne(l.name,"sign_out",()=>r({action:"logout",name:l.name})).then(()=>{W({name:l.name,waitForSignIn:!1,until:Date.now()+Ae,reanchors:0})})},$e=async l=>{try{return await r({action:"add",name:l.name,scope:l.scope,...l.mode==="command"?{command:l.command,args:l.args}:{url:l.url}}),k(!1),J(l.name),null}catch(p){return Pe("add",p,!1)}},wt=t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"text-heading text-ink",children:nt}),t.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:Ki})]}),a.enabled&&c.length>0&&!b?t.jsxs(D,{ref:ie,variant:"secondary",size:"sm",onClick:()=>k(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(Mt,{"aria-hidden":"true"}),"Add integration"]}):null]});if(!a.enabled&&!a.isLoading)return t.jsx(se,{title:nt,titleComponent:wt,sectionRef:s,children:t.jsx(le,{variant:"warning",children:"Integrations need a newer Local Operator backend. Update it and restart the app to manage them here."})});const jt=t.jsx(ai,{existingNames:c.map(l=>l.name),projectScopeAvailable:g,projectLabel:o?.cwd?qi(o.cwd):null,onSubmit:$e,onCancel:()=>{k(!1),window.setTimeout(()=>ie.current?.focus(),0)}}),_t=M?We(M.name):void 0,_n=Object.entries(K).filter(([l])=>!c.some(p=>p.name===l)),Nn=l=>_(({[l]:p,...j})=>j);i.useEffect(()=>{if(!Q)return;const l=z.current[Q];if(!l){c.some(p=>p.name===Q)&&(O.current[Q]?.focus(),J(null));return}l.focus(),J(null)},[Q,c]),i.useEffect(()=>{if(!pe)return;const p=B[Math.min(pe.index,B.length-1)]??B.at(-1);if(p){const j=z.current[p.name]??O.current[p.name];if(!j)return;j.focus()}else ie.current?.focus();je(null)},[pe,B]);const Qe=i.useCallback((l,p)=>{const j=u()??o,E=j?.servers.find(Sn=>Sn.name===l.name),me=j?.operations??[],xe=E?E.status==="connecting"||Me(E.name,me)!==null:!1;xe&&E&&(R.current=p);const ke=E?xt(E,me,a.memories):null;if(E&&l.waitForSignIn&&(ke?.kind==="sign_in"||ke?.kind==="reauth"))return"kept";const Ne=ci({hold:l,now:p,windowMs:Ae,rowMoving:xe,lastMovingAt:R.current,candidate:E?di({primary:ke?z.current[E.name]:null,overflow:O.current[E.name]}):void 0,active:window.document.activeElement,body:window.document.body});if(!Ne.hold)return W(null),"finished";if(!Ne.land)return"kept";W({name:l.name,waitForSignIn:!1,until:Ne.hold.until,landedOn:Ne.land,reanchors:Ne.hold.reanchors});const Nt=Ne.land;return window.setTimeout(()=>{Nt.isConnected&&Nt.focus()},0),"landed"},[u,o,a.memories]);return i.useEffect(()=>{if(!Y)return;Qe(Y,Date.now());let l=0,p=!1;const j=()=>{if(p)return;const E=ui({verdict:Qe(Y,Date.now()),watchMs:Ht});E!==null&&(l=window.setTimeout(j,E))};return l=window.setTimeout(j,Ht),()=>{p=!0,window.clearTimeout(l)}},[Y,Qe]),i.useEffect(()=>{if(!Y)return;const l=p=>{li({target:p.target,row:ee.current[Y.name]})&&W(null)};return window.document.addEventListener("pointerdown",l,!0),()=>{window.document.removeEventListener("pointerdown",l,!0)}},[Y]),t.jsxs(se,{title:nt,titleComponent:wt,sectionRef:s,children:[t.jsxs("div",{className:"flex flex-col gap-4",children:[a.route==="session"&&a.borrowed?t.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Showing the integrations for"," ",a.borrowed.title?.trim()||a.borrowed.session_id.slice(0,6),", your most recent chat."]}):null,a.noConversation?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Integrations can be managed here once a chat has started."}),t.jsx(D,{variant:"primary",size:"sm",onClick:()=>d("/chat"),children:"Start a chat"}),t.jsx("p",{className:"text-ink-dim text-meta",children:"Updating Local Operator removes this step."})]}):null,a.isLoading?t.jsx("div",{className:"flex h-24 items-center justify-center",children:t.jsx(re,{size:"lg",label:"Loading integrations"})}):null,a.folderUnavailable?t.jsx(le,{variant:"warning",children:t.jsx("span",{children:"This chat's folder no longer exists, so only global integrations are shown."})}):null,a.isError?t.jsx(le,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Integrations couldn't be loaded."}),t.jsx(D,{variant:"secondary",size:"sm",onClick:a.refetch,children:"Retry"})]})}):null,_n.map(([l,p])=>t.jsx(le,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:p}),t.jsx(D,{variant:"ghost",size:"sm",onClick:()=>Nn(l),children:"Dismiss"})]})},l)),b&&c.length>0?jt:null,c.length>=Hi?t.jsxs("div",{className:"relative",children:[t.jsx(Gn,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),t.jsx(Ce,{ref:C,value:f,onChange:l=>x(l.target.value),onKeyDown:l=>{l.key!=="Escape"||!f||(l.preventDefault(),x(""))},placeholder:`Search ${br(c.length)}`,"aria-label":"Search integrations",className:"pl-9"})]}):null,w?.kind==="miss"&&c.length>0?t.jsx("p",{className:"text-body-sm text-ink-muted",children:`No integration matches "${w.asked}".`}):null,w?.kind==="matched"&&w.unresolved?t.jsx("p",{className:"text-body-sm text-ink-muted",children:`Showing "${w.name}" — "${w.unresolved}" is not one of your integrations.`}):null,o&&c.length===0&&!a.isLoading?b?jt:t.jsxs("div",{className:"flex flex-col items-start gap-3 rounded-lg bg-surface p-6",children:[t.jsx(tn,{"aria-hidden":"true",className:"size-5 text-ink-muted"}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("h3",{className:"text-heading text-ink",children:"No integrations yet"}),t.jsx("p",{className:"max-w-xl text-body-sm text-ink-muted",children:"Integrations let agents read and act in your other tools, like Notion or Linear. Add one with a command that runs on this computer, or a server's URL."})]}),t.jsxs(D,{variant:"primary",size:"md",onClick:()=>k(!0),"data-tour-tag":"mcp-add-server",children:[t.jsx(Mt,{"aria-hidden":"true"}),"Add integration"]})]}):null,c.length>0&&B.length===0?t.jsxs("div",{className:"flex flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No integrations match this search."}),t.jsx(D,{variant:"secondary",size:"sm",onClick:()=>{x(""),window.setTimeout(()=>{(C.current??ie.current)?.focus()},0)},children:"Clear search"})]}):null,_e.map(l=>t.jsxs("section",{"aria-labelledby":`integrations-group-${l.id}`,className:"flex flex-col gap-1.5",children:[t.jsxs("h3",{id:`integrations-group-${l.id}`,className:"px-1 text-ink-dim text-meta",children:[l.title," · ",l.rows.length]}),t.jsx("ul",{className:"flex flex-col divide-y divide-hairline overflow-hidden rounded-lg bg-surface",children:l.rows.map(p=>t.jsx(yi,{row:p,operations:m,memories:a.memories,projectScopeAvailable:g,highlighted:p.name===v,rowRef:j=>{ee.current[p.name]=j,p.name===v&&(U.current=j)},primaryRef:j=>{z.current[p.name]=j},overflowRef:j=>{O.current[p.name]=j},pending:L===p.name,failure:K[p.name]??null,confirm:$?.name===p.name?{kind:$.kind}:null,onPrimary:j=>Fe(p,j),onOverflow:j=>bt(p,j),onConfirm:()=>$&&De(p,$.kind),onCancelConfirm:()=>{I(null),window.setTimeout(()=>{O.current[p.name]?.focus()},0)}},p.id))})]},l.id))]}),M?.kind==="sign_in"?t.jsx(wi,{name:M.name,action:M.action,keyRoute:ue?qe(ue):!1,phase:G,onStart:()=>void Ze(M.name,M.action),onCancel:l=>void r({action:"cancel",operationId:l}).catch(()=>{}),onOpenLink:l=>void qn(l),onClose:l=>h(M.name,l)}):null,M?.kind==="key"?t.jsx(fi,{name:M.name,keyNames:M.keyNames.length?M.keyNames:_t?.auth.secret_refs.map(l=>l.id)??[],keyless:M.keyNames.length===0,savedKeys:_t?.auth.secret_refs.filter(l=>l.state==="encrypted").map(l=>l.id),saving:T,failure:X,onClose:de,onSave:(l,p,j)=>{V(!0),A(null),a.storeKeys(M.name,l,p,j).then(E=>{if(!E.saved){A(E.message);return}N(null),W({name:M.name,waitForSignIn:!1,until:Date.now()+Ae,reanchors:0})}).catch(E=>A(Pe("key",E,!1))).finally(()=>V(!1))}}):null]})},Ae=4e3,Gi=/^\/(?:Users|home)\/[^/]+(?=\/|$)/,qi=e=>e.replace(Gi,"~"),Yi=e=>typeof e!="number"||!Number.isFinite(e)?"your free credits":`$${e.toFixed(2)} in free credits`,Wi="https://console.radienthq.com/dashboard/verification",Zi=(e,s)=>e==="pending"?{sentence:`Verify your email to claim ${s}. Check your inbox for the link Radient sent.`,action:"Open verification page"}:e==="expired"?{sentence:`The link to claim ${s} has expired. Request a new one from the verification page.`,action:"Request a new link"}:{sentence:"No signup grant is attached to this account. Open the verification page to check the account.",action:"Open verification page"},Qi=({verification:e})=>{const{prices:s}=Jn(),n=e.grant_amount??s?.default_new_credits,{sentence:a,action:o}=Zi(e.signup_grant,Yi(n)),r=e.claim_url||Wi;return t.jsxs("div",{className:"mt-8 flex items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[t.jsx(Ge,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),t.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-2",children:[t.jsx("p",{className:"text-body-sm text-ink",children:a}),t.jsx(D,{variant:"secondary",size:"sm",onClick:()=>{window.api?.openExternal?window.api.openExternal(r):window.open(r,"_blank")},children:o})]})]})},Ji=({onAfterCredentialUpdate:e})=>{const{isAuthenticated:s,user:n,isLoading:a,accountRead:o,signOut:r}=Zn(),u=nn(b=>b.isSigningOut),d=i.useCallback(async()=>{try{await r()}catch(b){console.error("Error signing out:",b)}},[r]),c=i.useMemo(()=>{if(!s||!n?.radientUser)return null;const{account:b,identity:k,verification:f}=n.radientUser,x=f!=null&&!f.email_verified&&f.signup_grant!=="claimed";return t.jsxs(t.Fragment,{children:[t.jsxs(pt,{children:[t.jsx(ae,{label:"Status",value:t.jsxs("span",{className:"inline-flex items-center gap-2",children:["Connected",t.jsx(Hs,{variant:"success",className:"capitalize",children:b.status})]})}),t.jsx(ae,{label:"Name",value:b.name||"Not provided"}),t.jsx(ae,{label:"Email",value:b.email}),t.jsx(ae,{label:"Account ID",value:t.jsx("span",{className:"text-mono-sm",children:b.id})}),t.jsx(ae,{label:"Tenant ID",value:t.jsx("span",{className:"text-mono-sm",children:b.tenant_id})}),t.jsx(ae,{label:"Provider",value:t.jsx("span",{className:"capitalize",children:k.provider})}),t.jsx(ae,{label:"Created",value:sn(b.created_at)})]}),x&&f?t.jsx(Qi,{verification:f}):null,t.jsxs("div",{className:"mt-8",children:[t.jsx("p",{className:"text-body-sm text-ink-muted",children:"Need to sign out or switch accounts?"}),t.jsxs(D,{variant:"danger",className:"mt-3",onClick:d,children:[t.jsx(Qn,{}),"Sign out from Radient"]})]})]})},[s,n?.radientUser,d]),m=i.useMemo(()=>o==="refused"?"Radient refused the sign-in this app is holding, so your account details could not be read. Signing in again below replaces it.":an(o)?"Your Radient account could not be read, so this app cannot show your account details.":"You are not currently signed in to Radient.",[o]),g=i.useMemo(()=>s&&n?null:t.jsxs("div",{children:[t.jsxs("p",{className:"text-body-sm text-ink-muted",children:[m," Sign in to access your account details or sign up to get free credits and unified access to models, tools, and more with Radient Pass. Radient's automatic model router will automatically select the best model for your agents to balance cost and performance. It is often cheaper to use Radient Pass than to use single AI providers due to automatic cost optimization."]}),t.jsx("div",{className:"mt-6",children:t.jsx(Gs,{titleText:"",onAfterCredentialUpdate:e,descriptionText:"",onSignInSuccess:()=>{}})})]}),[s,n,m,e]);return a||u?t.jsxs("div",{className:"flex min-h-36 flex-col items-center justify-center gap-3",children:[t.jsx(re,{size:"lg",label:"Loading account"}),!u&&t.jsx("p",{className:"text-meta text-ink-dim",children:"Loading your Radient account details…"})]}):s&&n?.radientUser?c:t.jsx("div",{className:"flex flex-col gap-4",children:g})};function Xi({metric:e,data:s}){return t.jsx(Xn,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:e==="credits"?"credits":"tokens",srSummary:`${e==="credits"?"Credits consumed":"Tokens used"} over the last 30 days, plotted per day across ${s.length} days.`,xTickFormatter:n=>n,yTickFormatter:n=>e==="credits"?`$${n.toFixed(2)}`:es(n),children:t.jsx(ur,{data:s,children:t.jsx(Jt,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:e==="credits"?"Credits consumed":"Tokens used"})})})}const ec=()=>{const{data:e,isLoading:s,error:n,refetch:a}=ir(),o=cr(),[r,u]=i.useState(""),[d,c]=i.useState(!1);i.useEffect(()=>{u(e?.content??""),c(!1)},[e]);const m=x=>{const L=x.target.value;u(L),c(L!==(e?.content??""))},g=async()=>{if(!(!d||o.isPending))try{const x={content:r};await o.mutateAsync(x),await a(),c(!1)}catch(x){console.error("Error updating system prompt:",x)}},b=()=>{u(e?.content??""),c(!1)},k=o.isPending,f=()=>t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(fe,{htmlFor:"app-system-prompt",children:"Instructions"}),t.jsx(cn,{id:"app-system-prompt",name:"systemPrompt",value:r,onChange:m,placeholder:"Enter instructions for how all agents should behave and respond to your requests...",className:"min-h-50"})]}),t.jsxs("div",{className:"flex gap-3",children:[t.jsxs(D,{variant:"primary",onClick:g,disabled:!d||k,children:[k?t.jsx(re,{size:"sm"}):t.jsx(ts,{}),k?"Saving...":"Save changes"]}),t.jsx(D,{onClick:b,disabled:!d||k,children:"Cancel"})]}),e?.last_modified&&t.jsxs("p",{className:"text-ink-dim text-meta",children:["Last modified:"," ",t.jsx("span",{className:"font-mono text-mono-sm",children:on(e.last_modified)})]})]});return t.jsx(se,{title:"System prompt",icon:Vs,description:"Every Local Operator agent receives this prompt in addition to its own instructions, so it is the place for baseline expectations and for details you want every agent to know about you, such as your name, location, or preferences. It is sent to your selected hosting provider.",children:s?t.jsx("div",{className:"flex min-h-50 items-center justify-center",children:t.jsx(re,{size:"lg",label:"Loading system prompt"})}):n?t.jsxs(le,{variant:"danger",children:["Failed to load system prompt:"," ",n instanceof Error?n.message:"Unknown error"]}):f()})},tc=["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"],nc=e=>tc.includes(e),sc=e=>{const s=[];let n=0;for(const a of e){const o=Math.max(0,Math.floor(a.count)),r=Math.max(1,Math.floor(a.columns));for(let u=0;u<o;u+=r)s.push({start:n+u,count:Math.min(r,o-u)});n+=o}return s},ac=({index:e,key:s,groups:n})=>{const a=sc(n),o=a.reduce((r,u)=>r+u.count,0);if(!Number.isInteger(e)||e<0||e>=o)return e;switch(s){case"Home":return 0;case"End":return o-1;case"ArrowLeft":return Math.max(0,e-1);case"ArrowRight":return Math.min(o-1,e+1);case"ArrowUp":case"ArrowDown":{const r=a.findIndex(c=>e>=c.start&&e<c.start+c.count),u=a[r+(s==="ArrowDown"?1:-1)];if(!u)return e;const d=e-a[r].start;return u.start+Math.min(d,u.count-1)}default:return e}},oc={localOperatorDark:yo,localOperatorLight:Do,dracula:Ao,dune:Ba,sage:co,monokai:os,tokyoNight:bo,iceberg:To,radient:no,neon:as,obsidian:dn,synth:sa,catppuccinMocha:Aa,catppuccinLatte:ho,tokyoNightStorm:ba,gruvbox:ua,nord:or,oneDark:ta,solarizedDark:Oo,rosePine:Ya,rosePineMoon:po,rosePineDawn:Ca,alucard:Za,gruvboxLight:Fa,tokyoNightDay:ko,oneLight:uo,catppuccinFrappe:Ia,catppuccinMacchiato:ao,palenight:ss,everforest:Qo,everforestLight:Wo,kanagawaWave:tr,kanagawaLotus:Ga,ayuDark:$a,ayuMirage:za,ayuLight:No,nightfox:ja,duskfox:Po,synthwave:jo,matrix:oa,tron:ka,cyberpunk:ns,vaporwave:qo,outrun:la,neonNoir:Xo,arcade:ro,forest:Vo,ocean:Ha,desert:Ko,autumn:sr,lavender:Lo,arctic:Na,rosewood:eo,solarizedLight:Uo,githubLight:Ja,paper:qs,linen:Co,highContrastLight:Xs,mintLight:ia},Yt="bg-[color-mix(in_srgb,var(--color-accent)_8%,var(--color-accent-wash))]",rc=({id:e})=>t.jsxs("div",{"data-theme":e,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[t.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1",children:[t.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:t.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),t.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),t.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex flex-1 flex-col justify-between p-1",children:[t.jsxs("div",{className:"flex flex-col gap-1 rounded-xs bg-surface p-1",children:[t.jsx("span",{className:"h-1 w-3/5 rounded-xs bg-ink"}),t.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"h-2.5 w-6 rounded-xs bg-elevated"}),t.jsx("span",{className:"h-2.5 w-5 rounded-xs bg-accent"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs bg-accent-alt"}),t.jsx("span",{className:"h-2.5 w-4 rounded-xs border border-control"})]})]})]}),ic=({id:e,name:s,description:n,isSelected:a,isTabStop:o,onSelect:r,onFocusTile:u})=>{const d=oc[e];return t.jsx(Te,{side:"bottom",align:"start",content:n,children:t.jsxs("button",{type:"button","data-theme-tile":e,"aria-pressed":a,tabIndex:o?0:-1,onFocus:u,onClick:r,className:oe("relative flex flex-col gap-1.5 rounded-md p-1 text-left transition-colors duration-fast ease-out-quart",a?Yt:"hover:bg-surface"),children:[t.jsxs("span",{className:oe("relative block h-10 overflow-hidden rounded-sm border transition-colors duration-fast ease-out-quart",a?"border-accent":"border-hairline"),children:[t.jsx(rc,{id:e}),a&&t.jsx("span",{className:oe("pointer-events-none absolute top-0.5 right-0.5 flex h-4 w-4 items-center justify-center rounded-full",Yt),children:t.jsx(Bs,{size:12,className:"text-accent","aria-hidden":"true"})})]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(d,{size:12,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink",children:s})]})]})})},cc=e=>[...e.querySelectorAll("[data-theme-grid]")].map(s=>{const n=[...s.querySelectorAll("[data-theme-tile]")],a=n[0]?.getBoundingClientRect().top??0;return{count:n.length,columns:Math.max(1,n.filter(o=>Math.abs(o.getBoundingClientRect().top-a)<1).length)}}),lc=()=>{const{themeName:e,setTheme:s}=ct(),n=i.useMemo(()=>{const d=Object.values(Cn);return[{label:"Dark",items:d.filter(c=>c.theme.palette.mode==="dark")},{label:"Light",items:d.filter(c=>c.theme.palette.mode==="light")}].filter(c=>c.items.length>0)},[]),[a,o]=i.useState(null),r=i.useMemo(()=>{const d=n.flatMap(c=>c.items.map(m=>m.id));return a&&d.includes(a)?a:d.includes(e)?e:d[0]},[n,a,e]),u=d=>{if(!nc(d.key))return;const c=[...d.currentTarget.querySelectorAll("[data-theme-tile]")],m=c.indexOf(d.target);if(m<0)return;d.preventDefault();const g=ac({index:m,key:d.key,groups:cc(d.currentTarget)});g!==m&&c[g]?.focus()};return t.jsx(Ks,{children:t.jsx("div",{onKeyDown:u,className:"flex flex-col gap-6",children:n.map(d=>t.jsxs("div",{children:[t.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:d.label}),t.jsx("div",{"data-theme-grid":d.label,className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2",children:d.items.map(({id:c,name:m,description:g})=>t.jsx(ic,{id:c,name:m,description:g,isSelected:c===e,isTabStop:c===r,onSelect:()=>s(c),onFocusTile:()=>o(c)},c))})]},d.label))})})},dc=()=>{const{data:e,isLoading:s,error:n}=hr({enabled:!0});return t.jsxs("div",{children:[t.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[t.jsx(Ea,{size:16,className:"shrink-0 text-ink-dim"}),"Radient Pass"]}),s&&t.jsx(ln,{className:"h-6 w-36"}),n&&t.jsxs(le,{variant:"warning",children:["Could not load your credit balance. ",n.message]}),e&&!s&&!n&&t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[t.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:["Available credits"," ",t.jsx("span",{className:"font-medium text-ink",children:e.balance.toFixed(2)})]}),t.jsx(D,{variant:"secondary",size:"sm",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[t.jsx(ya,{}),"Add credits"]})})]})]})},uc=[{id:"credits",label:"Credits"},{id:"tokens",label:"Tokens"}],mc=()=>{const[e,s]=i.useState("credits"),n=i.useMemo(()=>{const d=new Date,c=dr(d);return{start_date:Ft(c),end_date:Ft(d),rollup:"daily"}},[]),{data:a,isLoading:o,error:r}=pr(n,{enabled:!0}),u=i.useMemo(()=>a?.data_points?[...a.data_points].sort((c,m)=>Je(c.timestamp).getTime()-Je(m.timestamp).getTime()).map(c=>({bucket:ws(Zs(Je(c.timestamp),"yyyy-MM-dd")),value:e==="credits"?Number.parseFloat(c.total_cost.toFixed(2)):c.total_tokens})):[],[a,e]);return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(ha,{size:16,className:"shrink-0 text-ink-dim"}),"Usage (last 30 days)"]}),t.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[t.jsx("legend",{className:"sr-only",children:"Usage metric"}),t.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:uc.map(({id:d,label:c})=>t.jsx(D,{variant:"ghost",size:"sm","aria-pressed":e===d,onClick:()=>s(d),className:oe(e===d&&"bg-surface text-ink hover:bg-surface"),children:c},d))})]})]}),o&&t.jsx(ln,{className:"h-62 w-full"}),r&&t.jsxs(le,{variant:"warning",children:["Could not load your usage data. ",r.message]}),!o&&!r&&a&&u.length>0&&t.jsx(Xi,{metric:e,data:u}),!o&&!r&&(!a||u.length===0)&&t.jsx("p",{className:"text-body-sm text-ink-muted",children:"No usage recorded in the last 30 days."})]})},hc=()=>t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[t.jsx(js,{size:16,className:"shrink-0 text-ink-dim"}),"Radient account"]}),t.jsx(D,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:t.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:["Go to Radient console",t.jsx(_s,{})]})})]}),Mc=()=>{const e=rs("surface"),s=ct(h=>h.showAgentReasoning),n=ct(h=>h.setShowAgentReasoning),{data:a,isLoading:o,isFetching:r,error:u,refetch:d}=is(),c=cs(),{sentence:m,remedy:g}=Ms(c??null,"Your settings could not be loaded.",u),b=ls(),[k,f]=i.useState(null),x=nn(),{isAuthenticated:L,accountRead:S,isFetching:K,isRefreshing:_,refreshUser:$}=mt(),I=He(h=>h.activeSessionId),[M,N]=i.useState("general"),[G,P]=i.useState(!1),q=i.useRef(null),H=i.useRef(null),{startTour:X}=ds(),A=us(),{data:T,refetch:V}=ms(),{refreshModels:z}=hs(),O=i.useMemo(()=>T?.keys?[...T.keys].sort():[],[T?.keys]),ee=i.useRef({keys:"",hosting:void 0});i.useEffect(()=>{const h=O.join(","),w=a?.values?.hosting;(ee.current.keys!==h||ee.current.hosting!==w)&&(ee.current={keys:h,hosting:w},z().catch(v=>{console.error("Failed to refresh models after credentials or hosting change:",v)}))},[O,a?.values?.hosting,z]);const R=i.useRef({general:i.useRef(null),radient:i.useRef(null),integrations:i.useRef(null),appearance:i.useRef(null),providers:i.useRef(null),backend:i.useRef(null),updates:i.useRef(null)}).current,ie=i.useMemo(()=>new URLSearchParams(A.search).get("setting"),[A.search]),C=i.useMemo(()=>new URLSearchParams(A.search).get("filter")??"",[A.search]),Z=i.useMemo(()=>new URLSearchParams(A.search).get("mcp")??void 0,[A.search]),Q=i.useMemo(()=>new URLSearchParams(A.search).get("provider"),[A.search]),J=i.useCallback(h=>{N(h),P(!0);const w=R[h],v=H.current;if(w?.current&&v){const F=w.current.getBoundingClientRect().top-v.getBoundingClientRect().top;v.scrollHeight>v.clientHeight?v.scrollTo({top:Math.max(0,v.scrollTop+F-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,w.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(q.current??void 0),q.current=setTimeout(()=>{P(!1),q.current=null},800)}else P(!1)},[R]);i.useEffect(()=>{const h=setTimeout(()=>{const w=H.current;if(!w)return;const v=()=>{if(G)return;const U=w.getBoundingClientRect(),F=U.height;let te="",B=0;for(const[_e,ue]of Object.entries(R))if(ue.current){const ce=ue.current.getBoundingClientRect(),ye=U.top,ne=ce.top-ye,We=ce.bottom-ye,Oe=ce.height,Ze=Math.max(0,ne),Fe=Math.min(F,We),De=Math.max(0,Fe-Ze)/Oe,$e=De+(ne<F*.3?.1:0);$e>B&&De>.1&&(B=$e,te=_e)}te&&te!==M&&N(te)};return v(),w.addEventListener("scroll",v,{passive:!0}),()=>{w.removeEventListener("scroll",v),clearTimeout(q.current??void 0)}},100);return()=>clearTimeout(h)},[R,M,G]),i.useEffect(()=>{const h=new URLSearchParams(A.search),w=h.get("section"),v=h.get("setting")?"backend":w,U=v?R[v]:void 0;if(!v||!U)return;let F=!1,te=Number.NaN,B=0;const _e=window.setTimeout(()=>{F||(F=!0,ce.disconnect(),J(v))},2e3),ue=()=>{if(F)return;const ye=U.current;if(!ye){B=requestAnimationFrame(ue);return}const ne=Math.round(ye.getBoundingClientRect().top+window.scrollY);if(ne===te&&ne>0){F=!0,ce.disconnect(),window.clearTimeout(_e),J(v);return}te=ne,B=requestAnimationFrame(ue)},ce=new ResizeObserver(()=>{F||(cancelAnimationFrame(B),B=requestAnimationFrame(ue))});return H.current&&ce.observe(H.current),B=requestAnimationFrame(ue),()=>{F=!0,cancelAnimationFrame(B),ce.disconnect(),window.clearTimeout(_e)}},[A.search,R,J]);const Y=async(h,w)=>{f(h);try{await b.mutateAsync({[h]:w}),await d()}catch(v){console.error(`Error updating ${h}:`,v)}finally{f(null)}},W=o,pe=S==="checking",je=an(S),de=S==="ready"||S==="checking"||K,ge=Wt(W,4e3);return u?t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(le,{variant:"warning",className:"w-full max-w-xl",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:m}),g&&t.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void d(),disabled:r,children:r?"Retrying":"Retry"})]})})}):W?t.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[t.jsx(re,{size:"lg",label:ge?void 0:"Loading settings"}),ge&&t.jsx("p",{className:"max-w-sm text-center text-body-sm text-ink-muted",children:"The Local Operator server is taking longer than usual to answer. If it does not respond, you will be able to retry from here."})]}):a?t.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-canvas",children:[t.jsx("div",{ref:e,className:"w-12 shrink-0 overflow-y-auto min-[1040px]:w-55",children:t.jsx(fs,{activeSection:M,onSelectSection:J,sections:ps})}),t.jsx("div",{ref:H,"data-settings-content":!0,"data-tour-tag":"settings-general-section",className:"flex-1 overflow-y-auto overflow-x-hidden p-4 sm:p-6 md:p-8",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[t.jsx(As,{title:"Settings",icon:At}),t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsxs("div",{ref:R.general,className:"flex flex-col gap-8",children:[t.jsxs(se,{title:"User profile",icon:gs,description:`Your user profile information displayed in the application. This information is not provided to the agents. ${L?"These details are provided through your Radient account.":""}`,children:[pe&&t.jsx("p",{className:"text-meta text-ink-dim",children:"Checking your Radient account…"}),je&&t.jsx(le,{variant:"warning",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{children:["Your Radient account could not be read, so the name and email below are placeholders rather than your account details.",S==="refused"?" Retry, or sign in to Radient again.":" Retry."]}),t.jsx(D,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>$(),disabled:_,children:_?"Retrying":"Retry"})]})}),t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(Rt,{value:x.profile.name,label:"Display name",placeholder:"Enter your name...",isSaving:k==="user_name",onSave:async h=>{f("user_name");try{x.updateName(h)}finally{f(null)}},readOnly:de}),t.jsx(Rt,{value:x.profile.email,label:"Email address",placeholder:"Enter your email...",isSaving:k==="user_email",onSave:async h=>{f("user_email");try{x.updateEmail(h)}finally{f(null)}},readOnly:de})]})]}),t.jsx(se,{title:"Application tour",description:"Missed the application onboarding tour or want a refresher? Start it again here.",children:t.jsxs(D,{variant:"secondary",onClick:()=>{X({forceModalCompleted:!0})},children:[t.jsx(pa,{}),"Take the tour"]})}),t.jsx(se,{id:"model-settings",title:"Model settings",icon:ys,description:"Configure the default AI model and hosting providers used for generating responses. This will be used for all agents that don't have a specific model or hosting provider configured. You can override these settings for individual agents in the agent settings.",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(xs,{value:a.values.hosting,isSaving:k==="hosting",onSave:h=>Y("hosting",h),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:"No hosting providers available. Sign in to a provider, or add a provider's API key below, under Providers."}),t.jsx(ks,{value:a.values.model_name,hostingId:a.values.hosting,isSaving:k==="model_name",onSave:h=>Y("model_name",h),allowCustom:!0,allowDefault:!1}),t.jsx(le,{variant:"neutral",icon:t.jsx(Ge,{className:"size-4","aria-hidden":"true"}),children:"You need a Radient account or your own API keys to reach cloud providers. If you don't see more hosting providers and models here, sign in to Radient, or add a provider's API key below, under Providers."})]})}),t.jsx(ec,{}),t.jsx(se,{title:"Configuration information",icon:Ge,description:"System information about the current configuration.",children:t.jsxs(pt,{children:[t.jsx(ae,{label:"Version",value:t.jsx("span",{className:"text-mono-sm",children:a.version})}),t.jsx(ae,{label:"Created",value:sn(a.metadata.created_at)}),t.jsx(ae,{label:"Last modified",value:on(a.metadata.last_modified)}),t.jsx(ae,{label:"Description",value:a.metadata.description||"No description available"})]})})]}),t.jsx(se,{title:"Appearance",icon:dn,description:"Customize the look and feel of Local Operator",sectionRef:R.appearance,dataTourTag:"settings-appearance-section",children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(lc,{}),t.jsx(lr,{value:s,label:"Show agent reasoning",description:"Adds the agent's Reasoning and Thinking rows to conversations. They stay closed until you open one.",onChange:async h=>n(h)})]})}),t.jsx(se,{title:"Model providers",icon:tn,description:"Sign in to the services your agents think with. New chats use your default model.",sectionRef:R.providers,children:t.jsx(vs,{initialProviderId:Q,onChangeModel:()=>J("general")})}),t.jsx(Vi,{sessionId:I??void 0,sectionRef:R.integrations,highlightServer:Z}),t.jsx(se,{title:"Radient account",titleComponent:t.jsx(hc,{}),description:"Your Radient account, Radient Pass details and credits. To use Radient models, sign in under Model providers.",sectionRef:R.radient,dataTourTag:"settings-radient-account-section",children:t.jsxs("div",{className:"flex flex-col gap-8",children:[t.jsx(Ji,{onAfterCredentialUpdate:()=>{z(),V()}}),L&&t.jsxs(t.Fragment,{children:[t.jsx(dc,{}),t.jsx(mc,{})]})]})}),t.jsx(se,{title:"Backend settings",icon:At,description:"Every setting the backend registry owns, searchable, with typed editors and scopes.",sectionRef:R.backend,children:t.jsx(bs,{focusKey:ie,initialFilter:C})}),t.jsx("div",{ref:R.updates,children:t.jsx(kr,{})})]})]})})]}):t.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:t.jsx(le,{variant:"warning",className:"w-full max-w-xl",children:"Your settings could not be loaded."})})};export{Mc as SettingsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as r}from"./textarea-
|
|
1
|
+
import{c as r}from"./textarea-DeXGhzIK.js";import{j as e,c as i}from"./index-_dbvHdgc.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|