local-operator-ui 0.25.16 → 0.25.18
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 +341 -26
- package/out/renderer/assets/{_basePickBy-DBhtDEGA.js → _basePickBy-Dqo9Svot.js} +1 -1
- package/out/renderer/assets/{_baseUniq-B5WxfAdh.js → _baseUniq-Bqq4bH3r.js} +1 -1
- package/out/renderer/assets/{agent-details-page-CseZi6cR.js → agent-details-page-D5Xaqf5E.js} +1 -1
- package/out/renderer/assets/{agent-hub-page-_t-x78D_.js → agent-hub-page-Crnga1Hx.js} +1 -1
- package/out/renderer/assets/{agents-page-B6vQMI_R.js → agents-page-CXeZLL0h.js} +2 -2
- package/out/renderer/assets/{arc-Dcd3HzRZ.js → arc-ErJh4afL.js} +1 -1
- package/out/renderer/assets/{architectureDiagram-IEHRJDOE-CXwTTKVn.js → architectureDiagram-IEHRJDOE-CqPUhWwU.js} +1 -1
- package/out/renderer/assets/{blockDiagram-JOT3LUYC-dW5gyGl7.js → blockDiagram-JOT3LUYC-DGzBuOTu.js} +1 -1
- package/out/renderer/assets/browser-page-CV4u_doL.js +1 -0
- package/out/renderer/assets/{c4Diagram-VJAJSXHY-B1fPOy-n.js → c4Diagram-VJAJSXHY-BtVyEvMI.js} +1 -1
- package/out/renderer/assets/channel-B-RyHHam.js +1 -0
- package/out/renderer/assets/{chunk-4BMEZGHF-BjkEbeJq.js → chunk-4BMEZGHF-qHL7gFMz.js} +1 -1
- package/out/renderer/assets/{chunk-A2AXSNBT-CNdgDk-3.js → chunk-A2AXSNBT-CZdwXrGh.js} +1 -1
- package/out/renderer/assets/{chunk-AEK57VVT-DlvJjW1D.js → chunk-AEK57VVT-D3ygkjPx.js} +1 -1
- package/out/renderer/assets/{chunk-D6G4REZN-DUrFmr72.js → chunk-D6G4REZN-Cptud7N8.js} +1 -1
- package/out/renderer/assets/{chunk-RZ5BOZE2-DVV9SVAw.js → chunk-RZ5BOZE2-BW_-DH47.js} +1 -1
- package/out/renderer/assets/{chunk-XZIHB7SX-D5KVgy3I.js → chunk-XZIHB7SX-DVBP-wVb.js} +1 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-_YNlHCSJ.js +1 -0
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-_YNlHCSJ.js +1 -0
- package/out/renderer/assets/clone-CG632oKz.js +1 -0
- package/out/renderer/assets/{compact-pagination-FBuuRrOa.js → compact-pagination-DZcKP76l.js} +1 -1
- package/out/renderer/assets/{dagre-OKDRZEBW-U2nObwi2.js → dagre-OKDRZEBW-DmDP5q7x.js} +1 -1
- package/out/renderer/assets/{diagram-SSKATNLV-qATRbhkK.js → diagram-SSKATNLV-DXDXZp0c.js} +1 -1
- package/out/renderer/assets/{diagram-VNBRO52H-BPEwatJH.js → diagram-VNBRO52H-BADpsVut.js} +1 -1
- package/out/renderer/assets/{erDiagram-Q7BY3M3F-Bx5nxisD.js → erDiagram-Q7BY3M3F-S1vauM_p.js} +1 -1
- package/out/renderer/assets/{flowDiagram-4HSFHLVR-Do8frrTh.js → flowDiagram-4HSFHLVR-TVPZdl6u.js} +1 -1
- package/out/renderer/assets/{ganttDiagram-APWFNJXF-C_-yHBuP.js → ganttDiagram-APWFNJXF-DnrsPlnD.js} +1 -1
- package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DXTe6Uqo.js → gitGraphDiagram-7IBYFJ6S-yCY1XLln.js} +1 -1
- package/out/renderer/assets/{graph-BPMdi6cQ.js → graph-BxjT2eQO.js} +1 -1
- package/out/renderer/assets/icon-BKAmSt8B.css +1 -0
- package/out/renderer/assets/{index-CV6OexwP.js → index-DkR2IOFW.js} +367 -366
- package/out/renderer/assets/{index-DlEE2Mhu.js → index-DoRFtjYI.js} +1 -1
- package/out/renderer/assets/{index-fXOo37XI.js → index-tkj2FVUw.js} +1 -1
- package/out/renderer/assets/{infoDiagram-PH2N3AL5-7Bdo1-DK.js → infoDiagram-PH2N3AL5-D177FnZ4.js} +1 -1
- package/out/renderer/assets/{installer-Db9wXNQc.js → installer-DGvvq3Hw.js} +1 -1
- package/out/renderer/assets/{journeyDiagram-U35MCT3I-C_YNwAiC.js → journeyDiagram-U35MCT3I-GPGRSxRB.js} +1 -1
- package/out/renderer/assets/{kanban-definition-NDS4AKOZ-DwyjTS65.js → kanban-definition-NDS4AKOZ-BBqB4T4f.js} +1 -1
- package/out/renderer/assets/{layout-Dt9rFxLo.js → layout-CNsK6zbV.js} +1 -1
- package/out/renderer/assets/{legacy-agents-page-Ck7g4g5h.js → legacy-agents-page-C7hRXtYl.js} +1 -1
- package/out/renderer/assets/{mermaid.core-CTF22veB.js → mermaid.core-kFbnNRih.js} +5 -5
- package/out/renderer/assets/{mindmap-definition-ALO5MXBD-hIcrIbqg.js → mindmap-definition-ALO5MXBD-nj6Nb3_d.js} +1 -1
- package/out/renderer/assets/{page-header-CNu3r7Wl.js → page-header-h3oV19Xt.js} +1 -1
- package/out/renderer/assets/{parseISO-D7fb4zbb.js → parseISO-CJS8mOux.js} +1 -1
- package/out/renderer/assets/{pieDiagram-IB7DONF6-CgQ8RSTq.js → pieDiagram-IB7DONF6-Bnz5mDF1.js} +1 -1
- package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-D0u3ugSa.js → quadrantDiagram-7GDLP6J5-CccK4eoR.js} +1 -1
- package/out/renderer/assets/{radar-MK3ICKWK-D4NPS1yb.js → radar-MK3ICKWK-CSKEMsQ0.js} +1 -1
- package/out/renderer/assets/{radient-auth-buttons-6mbpShIM.js → radient-auth-buttons-BkKxA_iN.js} +1 -1
- package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CzyA0VGV.js → requirementDiagram-KVF5MWMF-CB_BCBB3.js} +1 -1
- package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-Bu3OPb5q.js → sankeyDiagram-QLVOVGJD-C_kUAgD4.js} +1 -1
- package/out/renderer/assets/{schedules-page-Z26BnqzA.js → schedules-page-Cg_9vR8_.js} +1 -1
- package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-C1Wt7DUe.js → sequenceDiagram-X6HHIX6F-DMVr-l3j.js} +1 -1
- package/out/renderer/assets/{settings-page-Ds1_qi2y.js → settings-page-BVf3GbZe.js} +22 -22
- package/out/renderer/assets/{stateDiagram-DGXRK772-D_Odl8sh.js → stateDiagram-DGXRK772-3fvxQXpG.js} +1 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-DILZ7L7Q.js +1 -0
- package/out/renderer/assets/{timeline-definition-BDJGKUSR-BlShpjPx.js → timeline-definition-BDJGKUSR-Cqc-O64D.js} +1 -1
- package/out/renderer/assets/{use-agent-like-mutation-DwD0kyhJ.js → use-agent-like-mutation-Da0zEmNH.js} +1 -1
- package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CGVDywr7.js → xychartDiagram-VJFVF3MP-DXGJHnXo.js} +1 -1
- package/out/renderer/index.html +3 -3
- package/out/renderer/installer.html +3 -3
- package/package.json +2 -2
- package/out/renderer/assets/browser-page-CbsSO9cU.js +0 -1
- package/out/renderer/assets/channel-CNQYu0Z5.js +0 -1
- package/out/renderer/assets/classDiagram-GIVACNV2-i38CMqFy.js +0 -1
- package/out/renderer/assets/classDiagram-v2-COTLJTTW-i38CMqFy.js +0 -1
- package/out/renderer/assets/clone-DyOOGQU7.js +0 -1
- package/out/renderer/assets/icon-C3z02Ja7.css +0 -1
- package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-nORq9nsg.js +0 -1
- /package/out/renderer/assets/{icon-KrVT-csH.js → icon-BIH0o0-h.js} +0 -0
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as B,r as i,j as e,B as C,S as X,J as st,g as Re,u as Me,I as ae,T as Ie,K as at,M as nt,N as rt,O as it,Q as Le,c as J,A as K,X as Tt,v as Ne,L as de,U as Rt,V as ot,y as Mt,F as It,Y as Lt,Z as Ft,i as zt,f as lt}from"./icon-BIH0o0-h.js";import{bH as Pt,bI as Ue,bJ as $e,bK as Ot,bj as Dt,g as ye,bk as ct,bl as ze,ar as dt,f as ut,ac as Ut,as as $t,bL as qt,bM as Bt,bN as Ht,bO as Vt,bP as mt,a3 as Kt,bQ as Yt,bR as me,bS as Pe,bT as ht,aK as Gt,bU as qe,bV as pt,bW as Qt,bp as xt,b as ft,d as gt,j as ge,bX as vt,bY as Wt,bZ as Ce,ay as Zt,az as yt,b_ as jt,b$ as ve,aN as Jt,c0 as bt,c1 as Xt,P as es,i as be,c2 as ts,c3 as ss,c4 as _e,c5 as kt,c6 as as,c7 as ns,c8 as wt,c9 as rs,ca as is,cb as os,cc as ls,aa as cs,cd as Nt,aM as Ct,ce as ds,cf as us,cg as ms,aw as hs,ch as St,by as Fe,bs as ps,ci as xs,cj as fs,bn as gs,ck as vs,cl as ys,cm as js,bf as Be,cn as bs,br as He,co as ks,cp as ws,bt as Ns,bu as Cs,bq as Ae,cq as Ss,cr as _s,cs as As,ct as Es,cu as Ts,cv as Rs,cw as Ms}from"./index-DkR2IOFW.js";import{P as Is}from"./page-header-h3oV19Xt.js";import{S as V,I as Oe,a as G,R as Ls,N as Fs}from"./radient-auth-buttons-BkKxA_iN.js";import{a as zs,H as Ps,p as Ee}from"./parseISO-CJS8mOux.js";/**
|
|
2
2
|
* @license lucide-react v0.507.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const Os=[["path",{d:"M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2",key:"57tc96"}]],Ds=B("audio-waveform",Os);/**
|
|
7
7
|
* @license lucide-react v0.507.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Us=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],$s=B("chart-line",Us);/**
|
|
12
12
|
* @license lucide-react v0.507.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const qs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],Bs=B("circle-plus",qs);/**
|
|
17
17
|
* @license lucide-react v0.507.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Hs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]],_t=B("contrast",Hs);/**
|
|
22
22
|
* @license lucide-react v0.507.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const Vs=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Ks=B("credit-card",Vs);/**
|
|
27
27
|
* @license lucide-react v0.507.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const Ys=[["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"}]],Gs=B("flame",Ys);/**
|
|
32
32
|
* @license lucide-react v0.507.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const Qs=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],Ws=B("hexagon",Qs);/**
|
|
37
37
|
* @license lucide-react v0.507.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const Zs=[["path",{d:"M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z",key:"nnexq3"}],["path",{d:"M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12",key:"mt58a7"}]],Js=B("leaf",Zs);/**
|
|
42
42
|
* @license lucide-react v0.507.0 - ISC
|
|
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 Xs=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ea=B("lock",Xs);/**
|
|
47
47
|
* @license lucide-react v0.507.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const ta=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],sa=B("moon",ta);/**
|
|
52
52
|
* @license lucide-react v0.507.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const aa=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],na=B("mountain",aa);/**
|
|
57
57
|
* @license lucide-react v0.507.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const ra=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],ia=B("plug-zap",ra);/**
|
|
62
62
|
* @license lucide-react v0.507.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const oa=[["path",{d:"m12.5 17-.5-1-.5 1h1z",key:"3me087"}],["path",{d:"M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z",key:"1o5pge"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}]],la=B("skull",oa);/**
|
|
67
67
|
* @license lucide-react v0.507.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const ca=[["path",{d:"m10 20-1.25-2.5L6 18",key:"18frcb"}],["path",{d:"M10 4 8.75 6.5 6 6",key:"7mghy3"}],["path",{d:"m14 20 1.25-2.5L18 18",key:"1chtki"}],["path",{d:"m14 4 1.25 2.5L18 6",key:"1b4wsy"}],["path",{d:"m17 21-3-6h-4",key:"15hhxa"}],["path",{d:"m17 3-3 6 1.5 3",key:"11697g"}],["path",{d:"M2 12h6.5L10 9",key:"kv9z4n"}],["path",{d:"m20 10-1.5 2 1.5 2",key:"1swlpi"}],["path",{d:"M22 12h-6.5L14 15",key:"1mxi28"}],["path",{d:"m4 10 1.5 2L4 14",key:"k9enpj"}],["path",{d:"m7 21 3-6-1.5-3",key:"j8hb9u"}],["path",{d:"m7 3 3 6h4",key:"1otusx"}]],da=B("snowflake",ca);/**
|
|
72
72
|
* @license lucide-react v0.507.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const ua=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],ma=B("sun",ua);/**
|
|
77
77
|
* @license lucide-react v0.507.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const ha=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],pa=B("undo-2",ha);/**
|
|
82
82
|
* @license lucide-react v0.507.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const pa=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],xa=H("zap",pa),fa=()=>{const t="https://local-operator.com/download",[a,s]=i.useState(!1),[r,n]=i.useState(!1),[d,l]=i.useState(null),[u,m]=i.useState("info"),[p,c]=i.useState(null),[y,S]=i.useState(null),h=i.useRef(!1),j=i.useRef(!1),_=i.useRef(0),E=i.useRef(!1),R=i.useCallback((T,A)=>{j.current=!1,l(T),m(A),n(!0)},[]),q=i.useCallback(T=>{j.current=!0,l(T),m("success"),n(!0)},[]),g=i.useCallback(()=>{j.current&&(j.current=!1,n(!1),l(null))},[]),{clearDeferredUpdate:O}=zt();i.useEffect(()=>{const T=window.api.updater.onUpdateError($=>{if(!h.current)return;const ee=["ENOENT: no such file or directory, open","Could not get code signature for running application","Cannot find latest.yml"].some(f=>$.includes(f));$.includes("manually")?(c({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),j.current=!1,l(null),m("warning"),n(!0)):ee||R($,"danger")}),A=window.api.updater.onBackendUpdateDevMode($=>{h.current&&R($,"info")}),v=()=>{E.current=!0,g()},P=window.api.updater.onUpdateAvailable(v),b=window.api.updater.onUpdateNpxAvailable(v),W=window.api.updater.onBackendUpdateAvailable(v);return()=>{T(),A(),P(),b(),W()}},[g,R]),i.useEffect(()=>{let T=!1;const A=()=>{window.api.updater.getLastInstallAttempt().then(P=>{T||S(P)}).catch(()=>{})};A();const v=window.api.updater.onUpdateInstallFailed(()=>A());return()=>{T=!0,v()}},[]);const M=async()=>{const T=++_.current;g(),E.current=!1;try{s(!0),h.current=!0,O($e.UI),O($e.BACKEND);const A=await window.api.updater.checkForAllUpdates({manual:!0});if(T!==_.current)return;A?.affirmation&&!E.current?q(A.affirmation):g()}catch(A){if(T!==_.current)return;R(`Error checking for updates: ${A instanceof Error?A.message:String(A)}`,"danger")}finally{T===_.current&&s(!1),setTimeout(()=>{h.current=!1},2e3)}},U=()=>{j.current=!1,n(!1),l(null)};return e.jsxs(e.Fragment,{children:[y&&e.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[e.jsxs("p",{className:"text-body-sm text-ink",children:["The last update to version ",y.targetVersion," didn't finish",y.attempts>1?` (${y.attempts} attempts)`:"",". Version ",y.runningVersion," is running."]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:["Detected"," ",y.detectedAt?new Date(y.detectedAt).toLocaleString():"at an unknown time",". ",y.detail]}),e.jsx(C,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(t),children:"Download a fresh copy"})]}),e.jsxs(C,{variant:"outline",onClick:()=>void M(),disabled:a,children:[a?e.jsx(X,{size:"sm"}):null,a?"Checking...":"Check for updates"]}),p&&e.jsxs(Ue,{open:r,autoHideDuration:1e4,onClose:U,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:p.message}),p.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:p.command})]}),d&&e.jsx(Ue,{open:r,autoHideDuration:6e3,onClose:U,variant:u,children:d})]})},ke=["system-prompt"],ga=()=>{const{shouldEnableQuery:t}=Ot();return ye({enabled:t({bypassInternetCheck:!0}),queryKey:ke,queryFn:async()=>{try{const s=await ct(Pe.baseUrl).config.getSystemPrompt();if(s===null)return null;if(s.status>=400)throw new Error(s.message||"Failed to fetch system prompt");return s.result}catch(a){const s=a instanceof Error?a.message:"An unknown error occurred while fetching system prompt";throw dt(s),a}},refetchOnWindowFocus:!1,staleTime:5e3})},va=()=>{const t=ut(),a=ct(Pe.baseUrl);return Dt({mutationFn:async s=>{try{const r=await a.config.updateSystemPrompt(s);if(r.status>=400)throw new Error(r.message||"Failed to update system prompt");return r.result}catch(r){const n=r instanceof Error?r.message:"An unknown error occurred while updating system prompt";throw dt(n),r}},onSuccess:async s=>{await t.invalidateQueries({queryKey:ke,refetchType:"none"}),t.setQueryData(ke,r=>r&&{...r,...s}),await t.refetchQueries({queryKey:ke,type:"all"}),Ut("System prompt updated")},onError:s=>{console.error("Error updating system prompt:",s)}})},ya=({value:t,label:a,description:s,onChange:r,icon:n,isSaving:d=!1})=>{const[l,u]=i.useState(t),m=i.useId(),p=`${m}-label`,c=`${m}-description`,y=async S=>{if(!d){u(S);try{await r(S)}catch(h){u(!S),console.error("Error toggling setting:",h)}}};return e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:p,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[n&&e.jsx(n,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),a]}),s&&e.jsx("p",{id:c,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:s})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:d?e.jsx(X,{size:"md",label:`Saving ${a}`}):e.jsx(st,{checked:l,onCheckedChange:y,"aria-labelledby":p,"aria-describedby":s?c:void 0})})]})};var ja=$t({chartName:"LineChart",GraphicalChild:mt,axisComponents:[{axisType:"xAxis",AxisComp:qt},{axisType:"yAxis",AxisComp:Bt}],formatAxisMap:Ht});function Ve(t,a){const s=Vt(t,a?.in);if(!Kt(s))throw new RangeError("Invalid time value");const r=me(s.getDate(),2),n=me(s.getMonth()+1,2),d=s.getFullYear(),l=me(s.getHours(),2),u=me(s.getMinutes(),2),m=me(s.getSeconds(),2);let p="",c="";const y=s.getTimezoneOffset();if(y!==0){const S=Math.abs(y),h=me(Math.trunc(S/60),2),j=me(S%60,2);c=`${y<0?"+":"-"}${h}:${j}`}else c="Z";return`${d}-${n}-${r}T${l}:${u}:${m}${p}${c}`}function ba(t,a,s){return Fs(t,-30,s)}const ka=["radient","creditBalance"],wa=t=>{const{user:a,isAuthenticated:s}=ze(),r=a?.account?.tenant_id,n=s&&!!r&&t?.enabled;return ye({queryKey:[ka,r],queryFn:async()=>{if(!r)throw new Error("Tenant ID not available");const d=await ht({operation:"credits",tenantId:r});if(!d||typeof d.balance!="number")throw new Error("Invalid credit balance response format");return d},enabled:n,staleTime:5*60*1e3,refetchOnWindowFocus:!0})};function Na(t,a){const[s,r]=i.useState(!1);return i.useEffect(()=>{if(!t){r(!1);return}const n=setTimeout(()=>r(!0),a);return()=>clearTimeout(n)},[t,a]),s}const Ca=["radient","usageRollup"],Sa=(t,a)=>{const{user:s,isAuthenticated:r}=ze(),n=s?.account?.tenant_id,d=r&&!!n&&a?.enabled;return ye({queryKey:[...Ca,n,t],queryFn:async()=>{if(!n)throw new Error("Tenant ID not available");const l={};for(const[m,p]of Object.entries(t))p!=null&&(l[m]=String(p));const u=await ht({operation:"usage",tenantId:n,query:l});if(!u)throw new Error("Invalid usage rollup response format");return u},enabled:d,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},_a=()=>e.jsx(fa,{}),Aa=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},Ea=()=>{const[t,a]=i.useState("Loading..."),[s,r]=i.useState({value:"Loading...",detail:null,degraded:!1}),[n,d]=i.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});i.useEffect(()=>{let u=!0;const m=h=>{if(!u)return;const j=Aa(h.url);if(h.state==="connecting"){r({value:"Loading...",detail:null,degraded:!1});return}if(h.state==="detached"){r({value:"Not connected",detail:h.detail||null,degraded:!1});return}if(h.state==="wedged"){r({value:"Not attached",detail:h.detail||null,degraded:!1});return}const _=h.version||"Version unknown";r({value:j?`${_} · ${j}`:_,detail:h.detail||null,degraded:h.state==="degraded"})};let p=!1;const c=window.api?.backend?.onStatusChange(h=>{p=!0,m(h)}),y=async()=>{try{const[h,j]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);u&&(a(h),d(j))}catch(h){console.error("Error fetching app information:",h)}},S=async()=>{try{const h=window.api?.backend;if(h){const E=await h.getStatus();p||m(E);return}const j=await qe.healthCheck(Pe.baseUrl),_=qe.getServerVersion(j);u&&r({value:_,detail:null,degraded:!1})}catch(h){console.error("Error fetching server version:",h),u&&r({value:"Unavailable",detail:null,degraded:!1})}};return y(),S(),()=>{u=!1,c?.()}},[]);const l=(u,m,p,c={})=>e.jsx(Q,{label:e.jsx(Re,{content:p,children:e.jsxs("span",{className:"inline-flex cursor-help items-center gap-1.5",children:[e.jsx(Me,{size:12,className:"shrink-0"}),u]})}),valueClassName:c.valueClassName,value:e.jsxs(e.Fragment,{children:[c.valueTooltip?e.jsx(Re,{content:c.valueTooltip,children:e.jsx("span",{"data-backend-version":c.valueHoverTarget?"":void 0,className:"cursor-help",children:m})}):m,c.statusNote?e.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:c.statusNote}):null]})});return e.jsx(V,{title:"Application updates and info",icon:Yt,description:"Check for updates and view information about your Local Operator installation.",dataTourTag:"settings-app-updates-section",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(Oe,{children:[l("Application version",t,"The version of the Local Operator user interface application."),l("Server version",s.value,"The version of the Local Operator API server backend, and the address of the daemon it was read from.",{valueTooltip:s.detail,valueHoverTarget:!0,statusNote:s.degraded?"Not answering":void 0,valueClassName:s.degraded?"text-ink-muted":void 0}),l("Platform",`${n.platform} (${n.arch})`,"The operating system and architecture your application is running on."),l("Node.js version",n.nodeVersion,"The JavaScript runtime environment version."),l("Electron version",n.electronVersion,"The framework version enabling this desktop application.")]}),e.jsx(_a,{})]})})},Ta={hosting:"core",model_name:"core",model_effort:"core","providers.openai.use_max_context_window":"advanced","providers.openai.api":"advanced","providers.anthropic.cache_ttl_1h_min_context_tokens":"advanced","providers.openrouter.provider_affinity":"advanced","providers.openrouter.sort":"advanced","providers.openrouter.order":"advanced","providers.openrouter.only":"advanced","providers.openrouter.ignore":"advanced","providers.openrouter.allow_fallbacks":"advanced","providers.openrouter.require_parameters":"advanced","providers.openrouter.data_collection":"advanced","providers.openrouter.zdr":"advanced","providers.openrouter.enforce_distillable_text":"advanced","providers.openrouter.quantizations":"advanced","providers.openrouter.max_price":"advanced","providers.openrouter.preferred_min_throughput":"advanced","providers.openrouter.preferred_max_latency":"advanced","retry.enabled":"core","retry.maxRetries":"advanced","retry.baseDelayMs":"advanced","retry.connectivityMaxRetries":"advanced","retry.connectivityBackoffCapMs":"advanced","retry.modelFallback":"advanced","retry.usageAwareFallback":"advanced","retry.usageAwareAccountPick":"advanced","retry.usageReservePercent":"advanced","retry.fallbackChains":"advanced","tui.theme":"advanced","display.shimmer":"advanced","display.comfortable_rows":"advanced","display.nerd_icons":"advanced","display.heading_markers":"advanced","display.terminal_title":"advanced","display.images":"advanced","display.notifications":"core","display.notification_session_name":"advanced","display.time_format":"advanced","display.dock":"advanced","tui.sidebar_visible":"advanced","tui.sidebar_position":"advanced","keymap.new_session":"advanced","keymap.resume":"advanced",tool_approval_mode:"core",auto_save_conversation:"core","session.cleanup.enabled":"core","session.cleanup.max_sessions":"advanced","session.cleanup.max_inactive_days":"advanced","session.cleanup.max_total_bytes":"advanced","session.cleanup.remove_empty":"advanced","runtime.background_on_resume":"advanced","runtime.unattended_gate_timeout":"advanced","subagents.max_running":"advanced","subagents.model_choice":"advanced","subagents.models.lo":"advanced","subagents.models.med":"advanced","subagents.models.hi":"advanced","fork.mode":"core","fork.cmux_placement":"advanced","compaction.enabled":"core","compaction.strategy":"advanced","compaction.threshold_percent":"advanced","compaction.threshold_tokens":"advanced","compaction.keep_recent_tokens":"advanced","compaction.auto_continue":"advanced","compaction.mid_turn_enabled":"advanced","compaction.wire_bytes_budget":"advanced","compaction.wire_bytes_trigger":"advanced","web_search.enabled":"core","web_fetch.enabled":"core","web_search.strategy":"advanced","web_search.providers":"advanced","web_search.timeout_seconds":"advanced","web_search.searxng_endpoint":"advanced","web_search.deepseek_evidence":"advanced","web_search.read_enabled":"advanced","web_fetch.timeout_seconds":"advanced","web_fetch.max_bytes":"advanced","web_fetch.max_redirects":"advanced","web_fetch.cache_ttl_seconds":"advanced","web_fetch.allow_private":"advanced","web_fetch.render_backend":"advanced","web_fetch.enrich":"advanced","web_fetch.max_attempts":"advanced","web_fetch.blocked_retry":"advanced","bash.shell":"advanced","providers.lmstudio.base_url":"advanced","providers.lmstudio.models":"advanced","providers.ollama.base_url":"advanced","providers.ollama.models":"advanced","providers.vllm.base_url":"advanced","providers.vllm.models":"advanced","providers.llamacpp.base_url":"advanced","providers.llamacpp.models":"advanced","providers.openai-compatible.base_url":"advanced","providers.openai-compatible.models":"advanced",conversation_length:"advanced",detail_length:"advanced",max_learnings_history:"advanced","desktop.launch_command":"advanced"},Ra={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function he(t){return t.tier==="core"||t.tier==="advanced"?t.tier:Ta[t.key]??Ra[t.section]??"advanced"}function Ma(t){return t.length===0?!1:t.filter(s=>he(s)==="core").length*2>=t.length}function Ia(t,a,s){return a?{layout:null,filter:t?[]:[...s]}:{layout:{opened:t?[...s]:[],closed:t?[]:[...s]},filter:[]}}const At="__cascade__";function xe(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function ce(t){return{value:t.kind==="list"?(t.value??[]).join(`
|
|
86
|
+
*/const xa=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],fa=B("zap",xa),ga=()=>{const t="https://local-operator.com/download",[a,s]=i.useState(!1),[r,n]=i.useState(!1),[d,l]=i.useState(null),[u,m]=i.useState("info"),[p,c]=i.useState(null),[y,S]=i.useState(null),h=i.useRef(!1),j=i.useRef(!1),_=i.useRef(0),A=i.useRef(!1),R=i.useCallback((E,T)=>{j.current=!1,l(E),m(T),n(!0)},[]),$=i.useCallback(E=>{j.current=!0,l(E),m("success"),n(!0)},[]),g=i.useCallback(()=>{j.current&&(j.current=!1,n(!1),l(null))},[]),{clearDeferredUpdate:O}=Pt();i.useEffect(()=>{const E=window.api.updater.onUpdateError(H=>{h.current&&H.includes("manually")&&(c({message:"The server is installed outside the app, so use the tool you installed it with - uv, pipx or pip.",command:""}),j.current=!1,l(null),m("warning"),n(!0))}),T=window.api.updater.onBackendUpdateDevMode(H=>{h.current&&R(H,"info")}),v=()=>{A.current=!0,g()},z=window.api.updater.onUpdateAvailable(v),b=window.api.updater.onUpdateNpxAvailable(v),Q=window.api.updater.onBackendUpdateAvailable(v);return()=>{E(),T(),z(),b(),Q()}},[g,R]),i.useEffect(()=>{let E=!1;const T=()=>{window.api.updater.getLastInstallAttempt().then(z=>{E||S(z)}).catch(()=>{})};T();const v=window.api.updater.onUpdateInstallFailed(()=>T());return()=>{E=!0,v()}},[]);const M=async()=>{const E=++_.current;g(),A.current=!1;try{s(!0),h.current=!0,O($e.UI),O($e.BACKEND);const T=await window.api.updater.checkForAllUpdates({manual:!0});if(E!==_.current)return;T?.affirmation&&!A.current?$(T.affirmation):g()}catch(T){if(E!==_.current)return;console.warn(`Update check failed; the app-level alert owns the report: ${Ot(T)}`)}finally{E===_.current&&s(!1),setTimeout(()=>{h.current=!1},2e3)}},U=()=>{j.current=!1,n(!1),l(null)};return e.jsxs(e.Fragment,{children:[y&&e.jsxs("div",{className:"mb-3 rounded-sm bg-sunken p-3",children:[e.jsxs("p",{className:"text-body-sm text-ink",children:["The last update to version ",y.targetVersion," didn't finish",y.attempts>1?` (${y.attempts} attempts)`:"",". Version ",y.runningVersion," is running."]}),e.jsxs("p",{className:"mt-1 text-meta text-ink-dim",children:["Detected"," ",y.detectedAt?new Date(y.detectedAt).toLocaleString():"at an unknown time",". ",y.detail]}),e.jsx(C,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>void window.api.openExternal(t),children:"Download a fresh copy"})]}),e.jsxs(C,{variant:"outline",onClick:()=>void M(),disabled:a,children:[a?e.jsx(X,{size:"sm"}):null,a?"Checking...":"Check for updates"]}),p&&e.jsxs(Ue,{open:r,autoHideDuration:1e4,onClose:U,variant:"warning",children:[e.jsx("p",{className:"text-body-sm",children:p.message}),p.command&&e.jsx("code",{className:"mt-2 block rounded-sm bg-sunken p-2 text-mono-sm text-ink",children:p.command})]}),d&&u!=="danger"&&e.jsx(Ue,{open:r,autoHideDuration:6e3,onClose:U,variant:u,children:d})]})},ke=["system-prompt"],va=()=>{const{shouldEnableQuery:t}=Dt();return ye({enabled:t({bypassInternetCheck:!0}),queryKey:ke,queryFn:async()=>{try{const s=await ct(ze.baseUrl).config.getSystemPrompt();if(s===null)return null;if(s.status>=400)throw new Error(s.message||"Failed to fetch system prompt");return s.result}catch(a){const s=a instanceof Error?a.message:"An unknown error occurred while fetching system prompt";throw dt(s),a}},refetchOnWindowFocus:!1,staleTime:5e3})},ya=()=>{const t=ut(),a=ct(ze.baseUrl);return Ut({mutationFn:async s=>{try{const r=await a.config.updateSystemPrompt(s);if(r.status>=400)throw new Error(r.message||"Failed to update system prompt");return r.result}catch(r){const n=r instanceof Error?r.message:"An unknown error occurred while updating system prompt";throw dt(n),r}},onSuccess:async s=>{await t.invalidateQueries({queryKey:ke,refetchType:"none"}),t.setQueryData(ke,r=>r&&{...r,...s}),await t.refetchQueries({queryKey:ke,type:"all"}),$t("System prompt updated")},onError:s=>{console.error("Error updating system prompt:",s)}})},ja=({value:t,label:a,description:s,onChange:r,icon:n,isSaving:d=!1})=>{const[l,u]=i.useState(t),m=i.useId(),p=`${m}-label`,c=`${m}-description`,y=async S=>{if(!d){u(S);try{await r(S)}catch(h){u(!S),console.error("Error toggling setting:",h)}}};return e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{id:p,className:"flex min-h-6 items-center gap-2 text-body text-ink",children:[n&&e.jsx(n,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim"}),a]}),s&&e.jsx("p",{id:c,className:"mt-0.5 max-w-2xl text-body-sm text-ink-muted",children:s})]}),e.jsx("div",{className:"flex h-6 shrink-0 items-center",children:d?e.jsx(X,{size:"md",label:`Saving ${a}`}):e.jsx(st,{checked:l,onCheckedChange:y,"aria-labelledby":p,"aria-describedby":s?c:void 0})})]})};var ba=qt({chartName:"LineChart",GraphicalChild:mt,axisComponents:[{axisType:"xAxis",AxisComp:Bt},{axisType:"yAxis",AxisComp:Ht}],formatAxisMap:Vt});function Ve(t,a){const s=Kt(t,a?.in);if(!Yt(s))throw new RangeError("Invalid time value");const r=me(s.getDate(),2),n=me(s.getMonth()+1,2),d=s.getFullYear(),l=me(s.getHours(),2),u=me(s.getMinutes(),2),m=me(s.getSeconds(),2);let p="",c="";const y=s.getTimezoneOffset();if(y!==0){const S=Math.abs(y),h=me(Math.trunc(S/60),2),j=me(S%60,2);c=`${y<0?"+":"-"}${h}:${j}`}else c="Z";return`${d}-${n}-${r}T${l}:${u}:${m}${p}${c}`}function ka(t,a,s){return zs(t,-30,s)}const wa=["radient","creditBalance"],Na=t=>{const{user:a,isAuthenticated:s}=Pe(),r=a?.account?.tenant_id,n=s&&!!r&&t?.enabled;return ye({queryKey:[wa,r],queryFn:async()=>{if(!r)throw new Error("Tenant ID not available");const d=await ht({operation:"credits",tenantId:r});if(!d||typeof d.balance!="number")throw new Error("Invalid credit balance response format");return d},enabled:n,staleTime:5*60*1e3,refetchOnWindowFocus:!0})};function Ca(t,a){const[s,r]=i.useState(!1);return i.useEffect(()=>{if(!t){r(!1);return}const n=setTimeout(()=>r(!0),a);return()=>clearTimeout(n)},[t,a]),s}const Sa=["radient","usageRollup"],_a=(t,a)=>{const{user:s,isAuthenticated:r}=Pe(),n=s?.account?.tenant_id,d=r&&!!n&&a?.enabled;return ye({queryKey:[...Sa,n,t],queryFn:async()=>{if(!n)throw new Error("Tenant ID not available");const l={};for(const[m,p]of Object.entries(t))p!=null&&(l[m]=String(p));const u=await ht({operation:"usage",tenantId:n,query:l});if(!u)throw new Error("Invalid usage rollup response format");return u},enabled:d,staleTime:5*60*1e3,refetchOnWindowFocus:!0})},Aa=()=>e.jsx(ga,{}),Ea=t=>{if(!t)return null;try{return new URL(t).host}catch{return null}},Ta=()=>{const[t,a]=i.useState("Loading..."),[s,r]=i.useState({value:"Loading...",detail:null,degraded:!1}),[n,d]=i.useState({platform:"Loading...",arch:"...",nodeVersion:"Loading...",electronVersion:"Loading...",chromeVersion:"Loading..."});i.useEffect(()=>{let u=!0;const m=h=>{if(!u)return;const j=Ea(h.url);if(h.state==="connecting"){r({value:"Loading...",detail:null,degraded:!1});return}if(h.state==="detached"){r({value:"Not connected",detail:h.detail||null,degraded:!1});return}if(h.state==="wedged"){r({value:"Not attached",detail:h.detail||null,degraded:!1});return}const _=h.version||"Version unknown";r({value:j?`${_} · ${j}`:_,detail:h.detail||null,degraded:h.state==="degraded"})};let p=!1;const c=window.api?.backend?.onStatusChange(h=>{p=!0,m(h)}),y=async()=>{try{const[h,j]=await Promise.all([window.api.systemInfo.getAppVersion(),window.api.systemInfo.getPlatformInfo()]);u&&(a(h),d(j))}catch(h){console.error("Error fetching app information:",h)}},S=async()=>{try{const h=window.api?.backend;if(h){const A=await h.getStatus();p||m(A);return}const j=await qe.healthCheck(ze.baseUrl),_=qe.getServerVersion(j);u&&r({value:_,detail:null,degraded:!1})}catch(h){console.error("Error fetching server version:",h),u&&r({value:"Unavailable",detail:null,degraded:!1})}};return y(),S(),()=>{u=!1,c?.()}},[]);const l=(u,m,p,c={})=>e.jsx(G,{label:e.jsx(Re,{content:p,children:e.jsxs("span",{className:"inline-flex cursor-help items-center gap-1.5",children:[e.jsx(Me,{size:12,className:"shrink-0"}),u]})}),valueClassName:c.valueClassName,value:e.jsxs(e.Fragment,{children:[c.valueTooltip?e.jsx(Re,{content:c.valueTooltip,children:e.jsx("span",{"data-backend-version":c.valueHoverTarget?"":void 0,className:"cursor-help",children:m})}):m,c.statusNote?e.jsx("span",{className:"mt-0.5 block text-meta text-ink-dim",children:c.statusNote}):null]})});return e.jsx(V,{title:"Application updates and info",icon:Gt,description:"Check for updates and view information about your Local Operator installation.",dataTourTag:"settings-app-updates-section",children:e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs(Oe,{children:[l("Application version",t,"The version of the Local Operator user interface application."),l("Server version",s.value,"The version of the Local Operator API server backend, and the address of the daemon it was read from.",{valueTooltip:s.detail,valueHoverTarget:!0,statusNote:s.degraded?"Not answering":void 0,valueClassName:s.degraded?"text-ink-muted":void 0}),l("Platform",`${n.platform} (${n.arch})`,"The operating system and architecture your application is running on."),l("Node.js version",n.nodeVersion,"The JavaScript runtime environment version."),l("Electron version",n.electronVersion,"The framework version enabling this desktop application.")]}),e.jsx(Aa,{})]})})},Ra={hosting:"core",model_name:"core",model_effort:"core","providers.openai.use_max_context_window":"advanced","providers.openai.api":"advanced","providers.anthropic.cache_ttl_1h_min_context_tokens":"advanced","providers.openrouter.provider_affinity":"advanced","providers.openrouter.sort":"advanced","providers.openrouter.order":"advanced","providers.openrouter.only":"advanced","providers.openrouter.ignore":"advanced","providers.openrouter.allow_fallbacks":"advanced","providers.openrouter.require_parameters":"advanced","providers.openrouter.data_collection":"advanced","providers.openrouter.zdr":"advanced","providers.openrouter.enforce_distillable_text":"advanced","providers.openrouter.quantizations":"advanced","providers.openrouter.max_price":"advanced","providers.openrouter.preferred_min_throughput":"advanced","providers.openrouter.preferred_max_latency":"advanced","retry.enabled":"core","retry.maxRetries":"advanced","retry.baseDelayMs":"advanced","retry.connectivityMaxRetries":"advanced","retry.connectivityBackoffCapMs":"advanced","retry.modelFallback":"advanced","retry.usageAwareFallback":"advanced","retry.usageAwareAccountPick":"advanced","retry.usageReservePercent":"advanced","retry.fallbackChains":"advanced","tui.theme":"advanced","display.shimmer":"advanced","display.comfortable_rows":"advanced","display.nerd_icons":"advanced","display.heading_markers":"advanced","display.terminal_title":"advanced","display.images":"advanced","display.notifications":"core","display.notification_session_name":"advanced","display.time_format":"advanced","display.dock":"advanced","tui.sidebar_visible":"advanced","tui.sidebar_position":"advanced","keymap.new_session":"advanced","keymap.resume":"advanced",tool_approval_mode:"core",auto_save_conversation:"core","session.cleanup.enabled":"core","session.cleanup.max_sessions":"advanced","session.cleanup.max_inactive_days":"advanced","session.cleanup.max_total_bytes":"advanced","session.cleanup.remove_empty":"advanced","runtime.background_on_resume":"advanced","runtime.unattended_gate_timeout":"advanced","subagents.max_running":"advanced","subagents.model_choice":"advanced","subagents.models.lo":"advanced","subagents.models.med":"advanced","subagents.models.hi":"advanced","fork.mode":"core","fork.cmux_placement":"advanced","compaction.enabled":"core","compaction.strategy":"advanced","compaction.threshold_percent":"advanced","compaction.threshold_tokens":"advanced","compaction.keep_recent_tokens":"advanced","compaction.auto_continue":"advanced","compaction.mid_turn_enabled":"advanced","compaction.wire_bytes_budget":"advanced","compaction.wire_bytes_trigger":"advanced","web_search.enabled":"core","web_fetch.enabled":"core","web_search.strategy":"advanced","web_search.providers":"advanced","web_search.timeout_seconds":"advanced","web_search.searxng_endpoint":"advanced","web_search.deepseek_evidence":"advanced","web_search.read_enabled":"advanced","web_fetch.timeout_seconds":"advanced","web_fetch.max_bytes":"advanced","web_fetch.max_redirects":"advanced","web_fetch.cache_ttl_seconds":"advanced","web_fetch.allow_private":"advanced","web_fetch.render_backend":"advanced","web_fetch.enrich":"advanced","web_fetch.max_attempts":"advanced","web_fetch.blocked_retry":"advanced","bash.shell":"advanced","providers.lmstudio.base_url":"advanced","providers.lmstudio.models":"advanced","providers.ollama.base_url":"advanced","providers.ollama.models":"advanced","providers.vllm.base_url":"advanced","providers.vllm.models":"advanced","providers.llamacpp.base_url":"advanced","providers.llamacpp.models":"advanced","providers.openai-compatible.base_url":"advanced","providers.openai-compatible.models":"advanced",conversation_length:"advanced",detail_length:"advanced",max_learnings_history:"advanced","desktop.launch_command":"advanced"},Ma={model:"core",approvals:"core",web_tools:"core",desktop:"advanced"};function he(t){return t.tier==="core"||t.tier==="advanced"?t.tier:Ra[t.key]??Ma[t.section]??"advanced"}function Ia(t){return t.length===0?!1:t.filter(s=>he(s)==="core").length*2>=t.length}function La(t,a,s){return a?{layout:null,filter:t?[]:[...s]}:{layout:{opened:t?[...s]:[],closed:t?[]:[...s]},filter:[]}}const At="__cascade__";function xe(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function ce(t){return{value:t.kind==="list"?(t.value??[]).join(`
|
|
87
87
|
`):t.kind==="cascade"?At:xe(t.value),cascadeBase:null}}function we(t,a){return a.cascadeBase!==null?!0:t.kind==="cascade"?a.value!==At:t.kind==="list"?a.value!==t.value?.join(`
|
|
88
|
-
`):a.value!==xe(t.value)}function
|
|
89
|
-
`).map(n=>n.trim()).filter(Boolean);break;case"cascade":{if(!a.cascadeBase)return{ok:!1,error:"Nothing has been edited yet."};const n={};for(const[d,l]of Object.entries(a.cascadeBase))n[d]=l;s=n,r=t.value??void 0;break}default:t.empty_unsets&&a.value.trim()===""?s=null:s=a.value}return{ok:!0,request:{op:"settings.edit",key:t.key,value:s,...r?{base:r}:{}}}}const Ke={bool:"w-9",int:"w-28",float:"w-28",enum:"w-64",text:"w-96",hotkey:"w-56",list:"w-full min-w-0",cascade:"w-full min-w-0",readonly:"w-40"};function
|
|
88
|
+
`):a.value!==xe(t.value)}function Fa(t,a){let s=null,r;switch(t.kind){case"bool":s=a.value==="true";break;case"int":{const n=Number.parseInt(a.value,10);if(Number.isNaN(n))return{ok:!1,error:"Enter a whole number."};s=n;break}case"float":{const n=Number.parseFloat(a.value);if(!Number.isFinite(n))return{ok:!1,error:"Enter a finite number."};s=n;break}case"enum":{const n=t.choices.find(d=>xe(d.value)===a.value);s=n?n.value:a.value;break}case"list":s=a.value.split(`
|
|
89
|
+
`).map(n=>n.trim()).filter(Boolean);break;case"cascade":{if(!a.cascadeBase)return{ok:!1,error:"Nothing has been edited yet."};const n={};for(const[d,l]of Object.entries(a.cascadeBase))n[d]=l;s=n,r=t.value??void 0;break}default:t.empty_unsets&&a.value.trim()===""?s=null:s=a.value}return{ok:!0,request:{op:"settings.edit",key:t.key,value:s,...r?{base:r}:{}}}}const Ke={bool:"w-9",int:"w-28",float:"w-28",enum:"w-64",text:"w-96",hotkey:"w-56",list:"w-full min-w-0",cascade:"w-full min-w-0",readonly:"w-40"};function za(t){return Ke[t]??Ke.text}const Pa={" ":"space",Spacebar:"space",Escape:"escape",Esc:"escape",Enter:"enter",Tab:"tab",Backspace:"backspace",Delete:"delete",ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",Home:"home",End:"end",PageUp:"pageup",PageDown:"pagedown"},Oa=new Set(["Control","Shift","Alt","Meta","AltGraph"]),Da=new Set(["Escape","Esc","Enter"]);function Ua(t){if(Oa.has(t.key)||t.nativeEvent.isComposing)return"";const a=[];t.ctrlKey&&a.push("ctrl"),t.altKey&&a.push("alt"),t.shiftKey&&a.push("shift"),t.metaKey&&a.push("meta");const s=Pa[t.key]??t.key.toLowerCase();return s?[...a,s].join("+"):""}const $a=({value:t,label:a,disabled:s,onChange:r})=>e.jsxs("span",{className:"flex w-full flex-col gap-0.5",children:[e.jsx(ae,{readOnly:!0,value:t,disabled:s,"aria-label":`${a}: press the key you want`,className:"font-mono text-body-sm",onKeyDown:n=>{if(Da.has(n.key)){n.currentTarget.blur();return}const d=Ua(n);d&&(n.preventDefault(),r(d))}}),e.jsx("span",{className:"text-meta text-ink-dim",children:"Press the keys you want; Esc cancels."})]}),qa=({setting:t,value:a,chains:s,disabled:r=!1,onValueChange:n,onChainsChange:d})=>{switch(t.kind){case"bool":return e.jsx(st,{checked:a==="true",disabled:r,onCheckedChange:l=>n(l?"true":"false"),"aria-label":t.label});case"enum":return e.jsxs(at,{value:a,disabled:r,onValueChange:n,children:[e.jsx(nt,{"aria-label":t.label,className:"w-full",children:e.jsx(rt,{})}),e.jsx(it,{children:t.choices.map(l=>e.jsx(Le,{value:xe(l.value),title:l.description||void 0,children:l.label},xe(l.value)))})]});case"int":case"float":return e.jsx(ae,{type:"number",value:a,disabled:r,min:t.minimum??void 0,max:t.maximum??void 0,step:t.kind==="int"?1:"any",onChange:l=>n(l.target.value),"aria-label":t.label});case"hotkey":return e.jsx($a,{value:a,label:t.label,disabled:r,onChange:n});case"list":return e.jsx(Ie,{value:a,disabled:r,rows:Math.min(6,t.members.length+2),onChange:l=>n(l.target.value),"aria-label":t.label,placeholder:t.placeholder,className:"font-mono text-body-sm"});case"cascade":{const l=s??t.value??{};return e.jsxs("div",{className:"flex flex-col gap-3",children:[Object.entries(l).map(([u,m])=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-mono text-meta text-ink-dim",children:u}),e.jsx(Ie,{value:m.join(`
|
|
90
90
|
`),disabled:r,rows:Math.max(2,m.length+1),onChange:p=>d?.({...l,[u]:p.target.value.split(`
|
|
91
|
-
`).map(c=>c.trim()).filter(Boolean)}),"aria-label":`${t.label}: ${u}`,className:"font-mono text-body-sm"})]},u)),e.jsx("p",{className:"text-meta text-ink-dim",children:"One hop per line, as provider/model (effort). An empty chain moves to the next provider."})]})}default:return e.jsx(ne,{value:a,disabled:r,onChange:l=>n(l.target.value),"aria-label":t.label,placeholder:t.placeholder})}},Et=({className:t})=>e.jsx("span",{role:"img","aria-label":"Changed from the default",title:"Changed from the default",className:J("size-1.5 shrink-0 rounded-full bg-accent",t)}),qa=({title:t,rowCount:a,advancedCount:s,scope:r,modified:n,onOpenChange:d,defaultOpen:l=!1})=>e.jsx("div",{"data-section-header":t,className:"flex w-full flex-col",children:e.jsx(pt,{defaultOpen:l,onOpenChange:d,triggerClassName:"text-ink hover:bg-elevated hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-10 py-0",className:"w-full",summary:e.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-heading text-ink",children:t}),a>0&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a===1?"1 setting":`${a} settings`}),r&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:r}),s>0&&e.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[s," advanced"]})]}),n&&e.jsx(Et,{className:"ml-auto"})]})})}),Ba="size-3.5 shrink-0",Ha=({setting:t,draft:a,tier:s,gate:r,saving:n,error:d,onDraftChange:l,onSave:u,onReset:m})=>{const p=!!(r&&!r.on),c=we(t,a),y=n||p,S=t.kind==="list"||t.kind==="cascade",h=e.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"truncate text-body-sm text-ink",children:t.label}),t.kind==="readonly"&&e.jsx("span",{className:"text-meta text-ink-dim",children:"Read-only"}),t.warning&&e.jsx("span",{className:"text-meta text-danger",children:t.warning})]}),j=p&&r&&e.jsxs("p",{className:"text-meta text-ink-dim",children:["Needs ",r.label," on. Nothing here is saved while it is off."]});return e.jsx("div",{"data-setting-key":t.key,"data-tier":s,className:"border-b border-hairline",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-x-4 gap-y-1 px-1 py-2.5",children:[e.jsxs("div",{className:J("flex min-w-44 flex-col gap-0.5",S?"shrink-0 basis-2/5":"flex-1"),children:[s==="advanced"&&t.help?e.jsx(pt,{summary:h,triggerClassName:"min-h-5 py-0 px-0 text-body-sm text-ink hover:text-ink",chevronClassName:"text-ink-dim",summaryAlign:"firstLine",rowClassName:"min-h-5 py-0",className:"w-full",children:e.jsx("span",{className:"text-meta text-ink-dim",children:t.help})}):e.jsxs("span",{className:"flex min-h-5 items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:Ba}),h]}),s==="core"&&t.help&&e.jsx("p",{className:"ml-5 text-meta text-ink-dim",children:t.help}),j]}),e.jsxs("div",{className:J("flex shrink-0 items-center gap-2 self-center",S&&"min-w-0 flex-1 items-start"),children:[(!t.is_default||c)&&e.jsx(Et,{}),!t.is_default&&t.kind!=="readonly"&&e.jsxs(C,{variant:"ghost",size:"sm",disabled:y,onClick:m,"aria-label":`Use default for ${t.label}`,children:[e.jsx(ha,{"aria-hidden":"true"}),"Use default"]}),c&&e.jsx(C,{variant:"primary",size:"sm",disabled:y,onClick:u,children:n?"Saving":"Save"}),e.jsx("div",{className:Fa(t.kind),"data-setting-control":"",children:t.redacted?e.jsx("span",{className:"text-meta text-ink-dim",children:"Set in the credential manager: this value carries inline credentials or query parameters."}):t.kind==="readonly"?e.jsx("span",{className:"text-body-sm text-ink-muted",children:xe(t.value)||"Not set"}):e.jsx($a,{setting:t,value:a.value,chains:a.cascadeBase??void 0,disabled:y,onValueChange:_=>l({...a,value:_}),onChainsChange:_=>l({...a,cascadeBase:_})})})]}),d&&e.jsx(K,{variant:"danger",role:"alert",className:"w-full",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:d}),e.jsxs(C,{variant:"secondary",size:"sm",disabled:n,onClick:u,children:[e.jsx(Gt,{"aria-hidden":"true"}),"Retry"]})]})})]})})},Va="w-full max-w-[400px]",Ka=({query:t,onQueryChange:a,matchCount:s,matchSections:r,coreCount:n,advancedCount:d,modifiedCount:l,modifiedOnly:u,onModifiedOnlyChange:m,showAdvanced:p,onShowAdvancedChange:c,onExpandAll:y,onCollapseAll:S,unsavedCount:h,savingAll:j,onSaveAll:_,onDiscardAll:E})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:J("relative",Va),children:[e.jsx(xt,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),e.jsx(ne,{value:t,onChange:R=>a(R.target.value),onKeyDown:R=>{R.key==="Escape"&&t&&a("")},placeholder:"Search settings by name, description or key","aria-label":"Search settings",className:"pl-9"}),t&&e.jsx(C,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>a(""),"aria-label":"Clear search",children:e.jsx(Tt,{"aria-hidden":"true"})})]}),e.jsxs("fieldset",{className:"m-0 border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Settings filters"}),e.jsxs("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:[e.jsxs(C,{variant:"ghost",size:"sm","aria-pressed":u,onClick:()=>m(!u),className:J(u&&"bg-surface text-ink hover:bg-surface"),children:["Modified",e.jsx(Ne,{variant:"neutral",children:l})]}),e.jsx(C,{variant:"ghost",size:"sm","aria-pressed":p,onClick:()=>c(!p),className:J(p&&"bg-surface text-ink hover:bg-surface"),children:"Show advanced"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-meta text-ink-dim",children:h===1?"1 unsaved change":`${h} unsaved changes`}),e.jsx(C,{variant:"primary",size:"sm",disabled:j,onClick:_,children:j?"Saving":"Save all"}),e.jsx(C,{variant:"ghost",size:"sm",disabled:j,onClick:E,children:"Discard all"})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:y,children:"Expand all"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:S,children:"Collapse all"})]})]}),e.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:s!==null?`${s} ${s===1?"result":"results"} in ${r} ${r===1?"section":"sections"}`:u?`${l} modified ${l===1?"setting":"settings"}`:p?`${d} advanced settings shown — Expand all to see them`:`${n} core settings, ${d} advanced`})]}),Ya={all:["desktop","settings"]},Ga={live:"Takes effect immediately","new launch":"Takes effect the next time the app starts","new sessions":"Takes effect for new conversations"},Qa=40,pe=t=>t.toLowerCase().replace(/[-_.]/g," "),Wa=({focusKey:t,initialFilter:a=""})=>{const s=ft(),r=gt(s.data,"settings"),[n,d]=i.useState(a),[l,u]=i.useState(!1),[m,p]=i.useState(!1),[c,y]=i.useState({}),[S,h]=i.useState({}),[j,_]=i.useState({}),[E,R]=i.useState(!1),[q,g]=i.useState(new Set),[O,M]=i.useState(new Set),[U,T]=i.useState(new Set),A=i.useRef(null),v=i.useRef(null),P=ye({queryKey:Ya.all,queryFn:()=>ge({op:"settings.list"}),enabled:r,staleTime:1e4}),b=P.data;i.useEffect(()=>{b&&y(o=>{let x=!1;const k={...o};for(const N of b.settings){const F=o[N.key];if(!F){k[N.key]=ce(N),x=!0;continue}if(we(N,F))continue;const I=ce(N);(I.value!==F.value||I.cascadeBase!==F.cascadeBase)&&(k[N.key]=I,x=!0)}return x?k:o})},[b]);const W=i.useCallback(o=>!o.is_default||we(o,c[o.key]??ce(o)),[c]),$=i.useMemo(()=>{if(!b)return[];const o=pe(n.trim()),x=o.length>0||m;return b.settings.filter(k=>!x&&he(k)==="advanced"&&!l||m&&!W(k)?!1:o?pe([k.label,k.help,k.key,k.section,k.warning??""].join(" ")).includes(o):!0)},[b,n,l,m,W]),Y=n.trim().length>0||m,ee=i.useMemo(()=>b?.sections??[],[b]),f=i.useCallback(o=>(b?.settings??[]).filter(x=>x.section===o),[b]),G=o=>$.filter(x=>x.section===o),re=o=>q.has(o)?!0:O.has(o)?!1:Ma(f(o)),Z=(o,x)=>{g(k=>{const N=new Set(k);return x?N.add(o):N.delete(o),N}),M(k=>{const N=new Set(k);return x?N.delete(o):N.add(o),N})},w=(o,x)=>{T(k=>{const N=new Set(k);return x?N.delete(o):N.add(o),N})},z=o=>{const x=ee.filter(N=>o||G(N.name).length>0).map(N=>N.name),k=Ia(o,Y,x);k.layout&&(g(new Set(k.layout.opened)),M(new Set(k.layout.closed))),T(new Set(k.filter))};i.useEffect(()=>{n.trim()||T(new Set)},[n]);const L=i.useCallback(o=>{const x=o.gated_by;if(!x||!b)return null;const k=b.settings.find(N=>N.key===x);return{key:x,label:k?.label??x,on:k?.value===!0||k?.value==="true"}},[b]),B=i.useCallback((o,x)=>h(k=>({...k,[o]:x})),[]),D=i.useCallback((o,x)=>_(k=>({...k,[o]:x})),[]),te=i.useCallback(async o=>{const x=c[o.key];if(!x)return!1;const k=La(o,x);if(!k.ok)return D(o.key,k.error),!1;B(o.key,!0),D(o.key,null);try{await ge(k.request),B(o.key,!1);const F=(await P.refetch()).data?.settings.find(I=>I.key===o.key);return F&&y(I=>{const fe=I[o.key];return fe&&fe.value===x.value&&fe.cascadeBase===x.cascadeBase?{...I,[o.key]:ce(F)}:I}),!0}catch(N){return B(o.key,!1),D(o.key,N instanceof Error?N.message:"The setting could not be saved."),!1}},[c,P,B,D]),se=i.useCallback(async o=>{B(o.key,!0),D(o.key,null);try{await ge({op:"settings.reset",key:o.key}),y(x=>({...x,[o.key]:ce({...o,value:o.default,is_default:!0})})),B(o.key,!1),await P.refetch()}catch(x){B(o.key,!1),D(o.key,x instanceof Error?x.message:"The setting could not be reset.")}},[P,B,D]),ue=i.useMemo(()=>(b?.settings??[]).filter(o=>we(o,c[o.key]??ce(o))),[b,c]),ie=async()=>{R(!0);for(const o of ue)await te(o);R(!1)},ae=()=>{b&&(y(o=>{const x={...o};for(const k of b.settings)x[k.key]=ce(k);return x}),_({}))};i.useEffect(()=>{if(!t||!b||A.current===t)return;const o=b.settings.find(N=>N.key===t);if(!o)return;A.current=t,he(o)==="advanced"&&u(!0);const x=pe(n.trim());!x||pe([o.label,o.help,o.key,o.section].join(" ")).includes(x)||d(""),p(!1),g(N=>new Set(N).add(o.section)),M(N=>{const F=new Set(N);return F.delete(o.section),F})},[t,b,n]);const le=i.useMemo(()=>{if(!t||!b)return!1;const o=b.settings.find(k=>k.key===t);if(!o||he(o)==="advanced"&&!l)return!1;const x=pe(n.trim());return x?pe([o.label,o.help,o.key,o.section].join(" ")).includes(x):!0},[t,b,n,l]);if(i.useEffect(()=>{if(!le||!t||v.current===t)return;let o=0,x=0;const k=()=>{const N=document.querySelector(`[data-setting-key="${CSS.escape(t)}"]`),F=N?.querySelector('[data-setting-control] :is(input, textarea, select, button[role="switch"], button)')??N;if(F){F===N&&(F.tabIndex=-1),F.focus(),F.scrollIntoView({block:"center"}),v.current=t;return}x+=1,x<Qa&&(o=requestAnimationFrame(k))};return o=requestAnimationFrame(k),()=>cancelAnimationFrame(o)},[le,t]),s.data&&!r)return e.jsx(K,{variant:"warning",children:"Searchable settings need a newer Local Operator server. Update the server and restart the app to manage these settings here."});if(P.isLoading||s.isLoading)return e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading settings"})});const oe=(s.data?null:s.error)??P.error;if(oe||!b){const o=s.isFetching||P.isFetching;return e.jsx(K,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:vt("Your settings could not be loaded.",oe)}),e.jsx(C,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{s.isError?s.refetch():P.refetch()},disabled:o,children:o?"Retrying":"Retry"})]})})}const je=b.settings.reduce((o,x)=>(o[he(x)]+=1,o),{core:0,advanced:0}),Se=new Set($.map(o=>o.section)).size;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ka,{query:n,onQueryChange:d,matchCount:n.trim()?$.length:null,matchSections:Se,coreCount:je.core,advancedCount:je.advanced,modifiedCount:b.settings.filter(W).length,modifiedOnly:m,onModifiedOnlyChange:p,showAdvanced:l,onShowAdvancedChange:u,onExpandAll:()=>z(!0),onCollapseAll:()=>z(!1),unsavedCount:ue.length,savingAll:E,onSaveAll:()=>void ie(),onDiscardAll:ae}),Y&&$.length===0&&e.jsx("div",{className:"flex flex-col items-center py-6 text-center",children:e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No settings match this search. Clear the search field to see every setting again."})}),e.jsx("div",{className:"flex flex-col gap-1",children:ee.map(o=>{const x=G(o.name),k=f(o.name),N=Y?0:k.filter(I=>he(I)==="advanced").length;if(Y&&x.length===0)return null;const F=Y?x.length>0&&!U.has(o.name):re(o.name);return e.jsxs("section",{"data-settings-section":o.name,"data-open":F,className:"flex flex-col",children:[e.jsx(qa,{title:o.title,rowCount:x.length,advancedCount:N,scope:Ga[o.scope],modified:k.some(W),defaultOpen:F,onOpenChange:I=>Y?w(o.name,I):Z(o.name,I)},`${o.name}:${F?"open":"closed"}`),e.jsxs("div",{hidden:!F,className:"flex flex-col pb-3",children:[o.description&&e.jsx("p",{className:"px-1 pb-1 text-meta text-ink-dim",children:o.description}),x.length===0?e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:N>0?"Advanced settings are hidden here.":"Nothing in this section matches."}),N>0&&e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>u(!0),children:["Show ",N," advanced"]})]}):x.map(I=>e.jsx(Ha,{setting:I,draft:c[I.key]??ce(I),tier:he(I),gate:L(I),saving:!!S[I.key],error:j[I.key]??null,onDraftChange:fe=>y(De=>({...De,[I.key]:fe})),onSave:()=>void te(I),onReset:()=>void se(I)},I.key))]})]},o.name)})})]})},Ye=({credentialKey:t,isConfigured:a=!1,onEdit:s,onClear:r,onAdd:n})=>{const d=Qt(t),l=a?Xs:Ce;return e.jsxs("div",{className:"flex flex-col rounded-md p-3 transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-body font-medium text-ink",children:[e.jsx(l,{className:"size-3.5 shrink-0 text-ink-dim"}),d.name]}),e.jsx("p",{className:"mt-1 break-all text-mono-sm text-ink-dim",children:t}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:d.description})]}),e.jsx("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>s?.(t),children:[e.jsx(Wt,{}),"Update"]}),e.jsxs(C,{variant:"ghost",size:"sm",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:()=>r?.(t),children:[e.jsx(yt,{}),"Clear"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>n?.(t),children:[e.jsx(Ce,{}),"Configure"]}),d.url&&e.jsx(Re,{content:`Get your ${d.name} key`,children:e.jsx(C,{variant:"ghost",size:"icon-sm",asChild:!0,children:e.jsx("a",{href:d.url,target:"_blank",rel:"noopener noreferrer","aria-label":`Get your ${d.name} key`,children:e.jsx(jt,{})})})})]})})]})},Te="_custom_",Ge="credential-custom-key",Qe="credential-custom-key-error",We="credential-type",Ze="credential-type-help",Je="credential-value",Xe="credential-value-help",et=({open:t,onClose:a,onSave:s,initialKey:r="",existingKeys:n,isSaving:d,isEditMode:l})=>{const[u,m]=i.useState(r),[p,c]=i.useState(""),[y,S]=i.useState(""),[h,j]=i.useState(!1);i.useEffect(()=>{if(t){const v=ve.some(b=>b.key===r),P=!l&&r&&!v;m(v?r:""),c(""),S(P?r:""),j(P||l&&!v)}},[t,r,l]);const _=()=>{let v="";if(l?v=r:v=h?y.trim():u,!v){console.error("No key provided for credential");return}if(!p.trim()){console.error("No value provided for credential");return}s({key:v,value:p})},E=v=>n.includes(v)&&v!==r,R=E(y),q=l?!0:h?y.trim()!==""&&!R:u!==""&&!E(u),g=p.trim()!=="",O=q&&g&&!d,M=ve.find(v=>v.key===u),U=!!M&&!h,T=l?"Update credential":"Add new credential",A=e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"secondary",onClick:a,children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:_,disabled:!O,children:[d&&e.jsx(X,{size:"sm",className:"border-t-on-accent"}),d?"Saving...":"Save"]})]});return e.jsx(Zt,{open:t,onClose:a,title:T,actions:A,maxWidth:"sm",fullWidth:!0,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[l?e.jsx(Q,{label:"Credential key",value:e.jsx("span",{className:"text-mono-sm",children:r})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:We,children:"Credential type"}),e.jsxs(at,{value:h?Te:u,onValueChange:v=>{v===Te?(j(!0),m("")):(j(!1),m(v),S(""))},children:[e.jsx(nt,{id:We,"aria-describedby":U?Ze:void 0,children:e.jsx(rt,{placeholder:"Select a credential type"})}),e.jsxs(it,{children:[ve.filter(v=>!v.internal).map(v=>e.jsxs(Le,{value:v.key,disabled:E(v.key),children:[v.name,E(v.key)&&" (configured)"]},v.key)),e.jsx(Le,{value:Te,children:"Custom credential"})]})]}),U&&M&&e.jsxs("div",{id:Ze,className:"flex flex-col items-start gap-1",children:[e.jsx("p",{className:"text-meta text-ink-dim",children:M.description}),M.url&&e.jsxs("a",{href:M.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent text-meta underline-offset-4 hover:text-accent-hover hover:underline",children:["Get your ",M.name," key"]})]})]}),h&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:Ge,children:"Custom credential key"}),e.jsx(ne,{id:Ge,value:y,onChange:v=>S(v.target.value),"aria-invalid":R||void 0,"aria-describedby":R?Qe:void 0,required:!0,autoFocus:!0}),R&&e.jsx("p",{id:Qe,className:"text-danger text-meta",children:"This credential already exists"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:Je,children:"Credential value"}),e.jsx(ne,{id:Je,type:"password",value:p,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&O&&_()},"aria-describedby":l?Xe:void 0,required:!0,autoFocus:l,placeholder:"Enter the credential value or API key"}),l&&e.jsxs("p",{id:Xe,className:"text-ink-dim text-meta",children:["Enter the new value for ",r]})]})]})})},tt=({title:t,description:a,children:s,isEmpty:r=!1,emptyStateType:n="noCredentials"})=>e.jsxs("section",{children:[e.jsx("h3",{className:"text-body font-medium text-ink",children:t}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:a}),e.jsx(Rt,{variant:"surface",padding:"sm",className:"mt-3",children:r?e.jsx(Za,{type:n}):e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-2",children:s})})]}),Za=({type:t,className:a})=>{const s=t==="noCredentials",r=s?Ce:ot;return e.jsxs("div",{className:J("flex flex-col items-center px-4 py-8 text-center",a),children:[e.jsx(r,{size:20,className:"text-ink-dim","aria-hidden":!0}),e.jsx("p",{className:"mt-3 text-body font-medium text-ink",children:s?"No credentials configured":"All available credentials configured"}),e.jsx("p",{className:"mt-1 max-w-sm text-body-sm text-ink-muted",children:s?"You haven't set up any API credentials yet. Add credentials from the available options or add a custom one.":"You've configured all the common API credentials. You can still add custom credentials if needed."})]})},Ja=()=>{const{data:t,isLoading:a,error:s,refetch:r}=bt(),n=Jt(),[d,l]=i.useState(!1),[u,m]=i.useState(!1),[p,c]=i.useState(null),y=g=>{c(g),l(!0)},S=(g=null)=>{c(g),m(!0)},h=()=>{l(!1),m(!1),c(null)},j=async g=>{try{await n.mutateAsync(g),h(),await r()}catch(O){console.error("Error saving credential:",O)}},_=async g=>{try{await n.mutateAsync({key:g,value:""}),await r()}catch(O){console.error("Error clearing credential:",O)}},E=i.useMemo(()=>t?.keys?.filter(g=>!ve.find(O=>O.key===g)?.internal)??[],[t]),R=i.useMemo(()=>ve.filter(g=>!E.includes(g.key)&&!g.internal),[E]),q=()=>a?e.jsx("div",{className:"flex min-h-40 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading credentials"})}):s||!t?e.jsxs(K,{variant:"danger",role:"alert",children:[e.jsx(Mt,{children:"Could not load credentials"}),e.jsx(It,{children:s instanceof Error?s.message:"The server did not say why. Check that Local Operator is running, then reopen this page."})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{title:"Configured credentials",description:"These API credentials are currently configured and available for use.",isEmpty:E.length===0,emptyStateType:"noCredentials",children:E.map(g=>e.jsx(Ye,{credentialKey:g,isConfigured:!0,onEdit:y,onClear:_},g))}),e.jsx(tt,{title:"Available credentials",description:"These are common API credentials you can configure to enhance functionality.",isEmpty:R.length===0,emptyStateType:"allConfigured",children:R.map(g=>e.jsx(Ye,{credentialKey:g.key,isConfigured:!1,onAdd:()=>S(g.key)},g.key))}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>S(null),children:[e.jsx(Xt,{}),"Add custom credential"]})}),d&&e.jsx(et,{open:d,onClose:h,onSave:j,initialKey:p||"",existingKeys:E,isSaving:n.isPending,isEditMode:!0}),u&&e.jsx(et,{open:u,onClose:h,onSave:j,initialKey:p||"",existingKeys:E,isSaving:n.isPending,isEditMode:!1})]});return e.jsx("div",{className:"flex flex-col gap-6",children:q()})},Xa=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function en(t){if(!t)return null;const a=t.split("\\").join("/").split("/").filter(Boolean);for(const[s,r]of Xa)if(!(a.length<s.length)&&a.slice(-s.length).join("/")===s.join("/"))return r;return null}const tn={list:"status",add:"add",remove:"remove",reload:"reload",connect:"reconnect",probe:"probe",disconnect:"disconnect",login:"grant",logout:"disconnect",reauth:"grant",status:"status",cancel:"cancel"},sn=(t,a)=>{const s=t?.trim();if(!s)return null;const r=is(s,a);return r.kind==="auth"?{kind:"matched",name:r.name,unresolved:null}:{kind:"miss",asked:s}},an=t=>t.reduce((a,s)=>a?(s.updated_at??0)>(a.updated_at??0)?s:a:s,null),nn=({sessionId:t,onAdded:a})=>{const[s,r]=i.useState(""),[n,d]=i.useState("command"),[l,u]=i.useState(""),[m,p]=i.useState(""),[c,y]=i.useState(""),[S,h]=i.useState("global"),[j,_]=i.useState(null),[E,R]=i.useState(!1),q=async()=>{R(!0),_(null);try{await ge({op:"mcp.control",sessionId:t,control:{action:"add",name:s,scope:S,...n==="command"?{command:l,args:m.split(`
|
|
92
|
-
`).map(g=>g.trim()).filter(Boolean)}:{url:c}}}),r(""),u(""),p(""),y(""),a()}catch(g){_(kt("add",g,!1))}finally{R(!1)}};return e.jsxs("form",{className:"flex flex-col gap-3 rounded-md border border-control bg-surface p-4",onSubmit:g=>{g.preventDefault(),q()},children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-name",children:"Name"}),e.jsx(ne,{id:"mcp-add-name",value:s,onChange:g=>r(g.target.value),required:!0})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Server transport"}),e.jsx(C,{type:"button",variant:n==="command"?"secondary":"ghost",size:"sm",onClick:()=>d("command"),children:"Local command"}),e.jsx(C,{type:"button",variant:n==="url"?"secondary":"ghost",size:"sm",onClick:()=>d("url"),children:"Remote URL"})]}),n==="command"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-command",children:"Command"}),e.jsx(ne,{id:"mcp-add-command",value:l,onChange:g=>u(g.target.value),className:"font-mono",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-args",children:"Arguments, one per line"}),e.jsx("textarea",{id:"mcp-add-args",value:m,onChange:g=>p(g.target.value),rows:2,className:"rounded-sm border border-control bg-surface p-2 font-mono text-body-sm text-ink"})]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-url",children:"URL"}),e.jsx(ne,{id:"mcp-add-url",type:"url",value:c,onChange:g=>y(g.target.value),className:"font-mono",required:!0}),e.jsx("p",{className:"text-meta text-ink-dim",children:"No inline credentials or query parameters; secrets are referenced from the credential manager."})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Configuration scope"}),e.jsx(C,{type:"button",variant:S==="global"?"secondary":"ghost",size:"sm",onClick:()=>h("global"),children:"Global"}),e.jsx(C,{type:"button",variant:S==="project"?"secondary":"ghost",size:"sm",onClick:()=>h("project"),children:"This project"})]}),j&&e.jsxs(K,{variant:"danger",children:[e.jsx("p",{children:j.message}),j.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:j.detail,children:j.detail}):null]}),e.jsx("div",{children:e.jsxs(C,{type:"submit",variant:"primary",size:"sm",disabled:E||!s||!(n==="command"?l:c),children:[E?e.jsx(X,{size:"sm"}):null,"Add server"]})})]})},rn=({sessionId:t,sectionRef:a,highlightServer:s})=>{const r=ft(),n=gt(r.data,"mcp"),d=ut(),l=be(f=>f.sessions),u=be(f=>f.fetchSessions),m=be(f=>f.loading),p=i.useMemo(()=>t?null:an(l),[t,l]),c=t??p?.session_id,[y,S]=i.useState(null),[h,j]=i.useState(null),[_,E]=i.useState(!1),[R,q]=i.useState(null),g=es({sessionId:c}),[O,M]=i.useState("");i.useEffect(()=>{t||!n||l.length>0||u()},[t,n,l.length,u]);const U=ye({queryKey:_e.list(c??""),queryFn:()=>{if(!c)throw new Error("No conversation selected.");return os(c)},enabled:n&&!!c,staleTime:1e4}),T=ts(U.data),A=i.useMemo(()=>sn(s,T.map(f=>f.name)),[s,T]),v=A?.kind==="matched"?A.name:null,P=i.useRef(null),b=i.useRef(null),W=O.trim().toLowerCase(),$=i.useMemo(()=>W?T.filter(f=>f.name.toLowerCase().includes(W)):T,[T,W]);i.useEffect(()=>{!v||b.current===v||!O||M("")},[v,O]),i.useEffect(()=>{v&&b.current!==v&&$.some(f=>f.name===v)&&(b.current=v,P.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[v,$]);const Y=i.useCallback(()=>{c&&d.invalidateQueries({queryKey:_e.list(c)})},[d,c]),ee=i.useCallback(async(f,G,re={})=>{if(c){j(null);try{await ge({op:"mcp.control",sessionId:c,control:{action:f,name:G,...re}}),Y()}catch(Z){const w=d.getQueryData(_e.list(c));j(kt(tn[f],Z,ss(w?.operations)))}}},[d,c,Y]);return n?c?e.jsx(V,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts. A connected server is a working transport; the account behind it may still need its own sign-in.",sectionRef:a,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[h&&e.jsxs(K,{variant:"danger",children:[e.jsx("p",{children:h.message}),h.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:h.detail,children:h.detail}):null]}),p&&e.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Showing MCP servers for"," ",p.title?.trim()||p.session_id.slice(0,6),", your most recent conversation. Open a conversation to see its own list."]}),U.isLoading&&e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading MCP servers"})}),U.isError&&e.jsx(K,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"MCP servers could not be loaded."}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>void U.refetch(),children:"Retry"})]})}),T.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx(xt,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx(ne,{value:O,onChange:f=>M(f.target.value),placeholder:"Search MCP servers","aria-label":"Search MCP servers",className:"pl-9"})]}),A?.kind==="miss"&&T.length>0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`No MCP server matches "${A.asked}".`}),A?.kind==="matched"&&A.unresolved&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`Showing "${A.name}" — "${A.unresolved}" is not one of your servers.`}),U.isSuccess&&T.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers configured yet. Add one below."}),T.length>0&&$.length===0&&e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers match this search."}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>M(""),children:"Clear search"})]}),$.length>0&&e.jsx("ul",{className:"flex flex-col gap-2",children:$.map(f=>{const G=f.status==="connected",re=f.name===v,Z=f.owned_scope,w=f.transport==="http"&&f.transport_oauth_supported!==!1,z=en(f.source);return e.jsxs("li",{ref:re?P:void 0,className:J("flex flex-col gap-2 rounded-md border border-control bg-surface p-3",re&&"border-accent bg-elevated"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:f.name}),Z&&e.jsx(Ne,{variant:"outline",children:Z==="project"?"This project":"Global"}),f.transport&&e.jsx("span",{className:"text-meta text-ink-dim",children:f.transport})]}),e.jsx(Ne,{variant:G?"success":f.status==="connecting"?"info":f.status==="auth-required"?"warning":"neutral",children:f.status??"unknown"})]}),typeof f.tool_count=="number"&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[f.tool_count," tools available"]}),f.status==="auth-required"&&!w&&e.jsx("p",{className:"text-meta text-ink-dim",children:f.setup?.text?"This server needs credentials local-operator cannot collect. Copy the setup prompt to have an agent walk you through it.":"This server needs credentials local-operator cannot collect."}),!Z&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[z?`Imported from ${z}.`:"Imported from a configuration local-operator does not write."," ",f.source?e.jsxs(e.Fragment,{children:["Remove it in"," ",e.jsx("span",{className:"font-mono text-mono-sm text-ink-dim",children:as(f.source)}),"."]}):e.jsx(e.Fragment,{children:"Remove it wherever it is defined."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[G?e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>{S(null),ee("disconnect",f.name,{confirmed:!0})},children:[e.jsx(wt,{"aria-hidden":"true"}),"Disconnect"]}):e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>void ee("connect",f.name),children:[e.jsx(ra,{"aria-hidden":"true"}),"Connect"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>void ee("reload",f.name),children:[e.jsx(Lt,{"aria-hidden":"true"}),"Reload"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{const L=ns(U.data?.servers??[]).find(B=>B.name===f.name);L&&q({row:L,sessionId:c})},children:"Sign in"}),f.setup?.text?e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(f.setup?.text??"").catch(()=>{})},children:"Copy setup prompt"}):null,Z?y===f.name?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-body-sm text-ink",children:["Remove ",f.name,"?"]}),e.jsx(C,{variant:"danger",size:"sm",onClick:()=>{S(null),ee("remove",f.name,{confirmed:!0,scope:Z})},children:"Confirm removal"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>S(null),children:"Keep"})]}):e.jsxs(C,{variant:"ghost",size:"sm",className:"text-danger",onClick:()=>S(f.name),children:[e.jsx(yt,{"aria-hidden":"true"}),"Remove"]}):null]})]},f.name)})}),R?.sessionId===c?e.jsx(rs,{row:R.row,remedy:g,onClose:()=>q(null)},c):null,_?e.jsx(nn,{sessionId:c,onAdded:()=>{E(!1),Y()}}):e.jsx("div",{children:e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>E(!0),"data-tour-tag":"mcp-add-server",children:"Add server"})})]})}):e.jsx(V,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:a,children:m?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading MCP servers"})}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Open a conversation to manage its MCP servers."})}):e.jsx(V,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:a,children:e.jsx(K,{variant:"warning",children:"Integration management needs a newer Local Operator backend. Update the backend and restart the app to manage MCP servers here."})})},on=({onAfterCredentialUpdate:t})=>{const{isAuthenticated:a,user:s,isLoading:r,error:n,signOut:d}=ls(),l=Nt(c=>c.isSigningOut),u=i.useCallback(async()=>{try{await d()}catch(c){console.error("Error signing out:",c)}},[d]),m=i.useMemo(()=>{if(!a||!s?.radientUser)return null;const{account:c,identity:y}=s.radientUser;return e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(Q,{label:"Status",value:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Connected",e.jsx(Ne,{variant:"success",className:"capitalize",children:c.status})]})}),e.jsx(Q,{label:"Name",value:c.name||"Not provided"}),e.jsx(Q,{label:"Email",value:c.email}),e.jsx(Q,{label:"Account ID",value:e.jsx("span",{className:"text-mono-sm",children:c.id})}),e.jsx(Q,{label:"Tenant ID",value:e.jsx("span",{className:"text-mono-sm",children:c.tenant_id})}),e.jsx(Q,{label:"Provider",value:e.jsx("span",{className:"capitalize",children:y.provider})}),e.jsx(Q,{label:"Created",value:Ct(c.created_at)})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Need to sign out or switch accounts?"}),e.jsxs(C,{variant:"danger",className:"mt-3",onClick:u,children:[e.jsx(cs,{}),"Sign out from Radient"]})]})]})},[a,s?.radientUser,u]),p=i.useMemo(()=>a&&s?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"You are not currently signed in to Radient. 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."}),e.jsx("div",{className:"mt-6",children:e.jsx(Is,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]}),[a,s,t]);return r||l?e.jsx("div",{className:"flex min-h-36 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading account"})}):a&&s?.radientUser?m:e.jsxs("div",{className:"flex flex-col gap-4",children:[n&&e.jsxs(K,{variant:"danger",children:["Error checking account status:"," ",n instanceof Error?n.message:String(n)]}),p]})};function ln({metric:t,data:a}){return e.jsx(ds,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:t==="credits"?"credits":"tokens",srSummary:`${t==="credits"?"Credits consumed":"Tokens used"} over the last 30 days, plotted per day across ${a.length} days.`,xTickFormatter:s=>s,yTickFormatter:s=>t==="credits"?`$${s.toFixed(2)}`:us(s),children:e.jsx(ja,{data:a,children:e.jsx(mt,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:t==="credits"?"Credits consumed":"Tokens used"})})})}const cn=()=>{const{data:t,isLoading:a,error:s,refetch:r}=ga(),n=va(),[d,l]=i.useState(""),[u,m]=i.useState(!1);i.useEffect(()=>{l(t?.content??""),m(!1)},[t]);const p=j=>{const _=j.target.value;l(_),m(_!==(t?.content??""))},c=async()=>{if(!(!u||n.isPending))try{const j={content:d};await n.mutateAsync(j),await r(),m(!1)}catch(j){console.error("Error updating system prompt:",j)}},y=()=>{l(t?.content??""),m(!1)},S=n.isPending,h=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:"app-system-prompt",children:"Instructions"}),e.jsx(Ie,{id:"app-system-prompt",name:"systemPrompt",value:d,onChange:p,placeholder:"Enter instructions for how all agents should behave and respond to your requests...",className:"min-h-50"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(C,{variant:"primary",onClick:c,disabled:!u||S,children:[S?e.jsx(X,{size:"sm"}):e.jsx(ms,{}),S?"Saving...":"Save changes"]}),e.jsx(C,{onClick:y,disabled:!u||S,children:"Cancel"})]}),t?.last_modified&&e.jsxs("p",{className:"text-ink-dim text-meta",children:["Last modified:"," ",e.jsx("span",{className:"font-mono text-mono-sm",children:St(t.last_modified)})]})]});return e.jsx(V,{title:"System prompt",icon:Ls,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:a?e.jsx("div",{className:"flex min-h-50 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading system prompt"})}):s?e.jsxs(K,{variant:"danger",children:["Failed to load system prompt:"," ",s instanceof Error?s.message:"Unknown error"]}):h()})},dn={localOperatorDark:ta,localOperatorLight:ua,radient:Qs,dracula:oa,dune:Ys,sage:Zs,monokai:Pt,tokyoNight:aa,iceberg:ca,neon:xa,obsidian:_t,synth:Os},un=({id:t})=>e.jsxs("div",{"data-theme":t,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[e.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1.5",children:[e.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:e.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),e.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),e.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between p-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-sm bg-surface p-2",children:[e.jsx("span",{className:"h-1.5 w-3/5 rounded-xs bg-ink"}),e.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"}),e.jsx("span",{className:"h-1 w-4/5 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-3 w-9 rounded-xs bg-accent"}),e.jsx("span",{className:"h-3 w-6 rounded-xs border border-control"})]})]})]}),mn=({id:t,name:a,description:s,isSelected:r,onSelect:n})=>{const d=dn[t];return e.jsxs("button",{type:"button","aria-pressed":r,onClick:n,className:J("flex flex-col gap-2 rounded-lg p-2 text-left transition-colors duration-fast ease-out-quart",r?"bg-accent-wash":"hover:bg-surface"),children:[e.jsx("span",{className:J("block aspect-16/10 overflow-hidden rounded-md border transition-colors duration-fast ease-out-quart",r?"border-accent":"border-hairline"),children:e.jsx(un,{id:t})}),e.jsxs("span",{className:"flex items-center gap-2 px-1",children:[e.jsx(d,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),e.jsx("span",{className:J("min-w-0 flex-1 truncate text-body-sm text-ink",r&&"font-medium"),children:a}),r&&e.jsx(ot,{size:14,className:"shrink-0 text-accent","aria-hidden":"true"})]}),e.jsx("span",{className:"px-1 pb-1 text-meta text-ink-muted",children:s})]})},hn=()=>{const{themeName:t,setTheme:a}=Fe(),s=i.useMemo(()=>{const r=Object.values(Ft);return[{label:"Dark",items:r.filter(n=>n.theme.palette.mode==="dark")},{label:"Light",items:r.filter(n=>n.theme.palette.mode==="light")}].filter(n=>n.items.length>0)},[]);return e.jsx("div",{className:"flex flex-col gap-6",children:s.map(r=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:r.label}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2",children:r.items.map(({id:n,name:d,description:l})=>e.jsx(mn,{id:n,name:d,description:l,isSelected:n===t,onSelect:()=>a(n)},n))})]},r.label))})},pn=()=>{const{data:t,isLoading:a,error:s}=wa({enabled:!0});return e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[e.jsx(Vs,{size:16,className:"shrink-0 text-ink-dim"}),"Radient Pass"]}),a&&e.jsx(lt,{className:"h-6 w-36"}),s&&e.jsxs(K,{variant:"warning",children:["Could not load your credit balance. ",s.message]}),t&&!a&&!s&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:["Available credits"," ",e.jsx("span",{className:"font-medium text-ink",children:t.balance.toFixed(2)})]}),e.jsx(C,{variant:"secondary",size:"sm",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(qs,{}),"Add credits"]})})]})]})},xn=[{id:"credits",label:"Credits"},{id:"tokens",label:"Tokens"}],fn=()=>{const[t,a]=i.useState("credits"),s=i.useMemo(()=>{const u=new Date,m=ba(u);return{start_date:Ve(m),end_date:Ve(u),rollup:"daily"}},[]),{data:r,isLoading:n,error:d}=Sa(s,{enabled:!0}),l=i.useMemo(()=>r?.data_points?[...r.data_points].sort((m,p)=>Ee(m.timestamp).getTime()-Ee(p.timestamp).getTime()).map(m=>({bucket:Es(Ts(Ee(m.timestamp),"yyyy-MM-dd")),value:t==="credits"?Number.parseFloat(m.total_cost.toFixed(2)):m.total_tokens})):[],[r,t]);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Us,{size:16,className:"shrink-0 text-ink-dim"}),"Usage (last 30 days)"]}),e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Usage metric"}),e.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:xn.map(({id:u,label:m})=>e.jsx(C,{variant:"ghost",size:"sm","aria-pressed":t===u,onClick:()=>a(u),className:J(t===u&&"bg-surface text-ink hover:bg-surface"),children:m},u))})]})]}),n&&e.jsx(lt,{className:"h-62 w-full"}),d&&e.jsxs(K,{variant:"warning",children:["Could not load your usage data. ",d.message]}),!n&&!d&&r&&l.length>0&&e.jsx(ln,{metric:t,data:l}),!n&&!d&&(!r||l.length===0)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No usage recorded in the last 30 days."})]})},gn=()=>e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Rs,{size:16,className:"shrink-0 text-ink-dim"}),"Radient account"]}),e.jsx(C,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:["Go to Radient console",e.jsx(jt,{})]})})]}),wn=()=>{const t=Fe(w=>w.showAgentReasoning),a=Fe(w=>w.setShowAgentReasoning),{data:s,isLoading:r,isFetching:n,error:d,refetch:l}=hs(),u=ps(),[m,p]=i.useState(null),c=Nt(),{isAuthenticated:y,isLoading:S}=ze(),h=be(w=>w.activeSessionId),[j,_]=i.useState("general"),[E,R]=i.useState(!1),q=i.useRef(null),g=i.useRef(null),{startTour:O}=xs(),M=fs(),{data:U,refetch:T}=bt(),{refreshModels:A}=gs(),v=i.useMemo(()=>U?.keys?[...U.keys].sort():[],[U?.keys]),P=i.useRef({keys:"",hosting:void 0});i.useEffect(()=>{const w=v.join(","),z=s?.values?.hosting;(P.current.keys!==w||P.current.hosting!==z)&&(P.current={keys:w,hosting:z},A().catch(L=>{console.error("Failed to refresh models after credentials or hosting change:",L)}))},[v,s?.values?.hosting,A]);const b=i.useRef({general:i.useRef(null),radient:i.useRef(null),integrations:i.useRef(null),appearance:i.useRef(null),credentials:i.useRef(null),providers:i.useRef(null),backend:i.useRef(null),updates:i.useRef(null)}).current,W=i.useMemo(()=>new URLSearchParams(M.search).get("setting"),[M.search]),$=i.useMemo(()=>new URLSearchParams(M.search).get("filter")??"",[M.search]),Y=i.useMemo(()=>new URLSearchParams(M.search).get("mcp")??void 0,[M.search]),ee=i.useMemo(()=>new URLSearchParams(M.search).get("provider"),[M.search]),f=i.useCallback(w=>{_(w),R(!0);const z=b[w],L=g.current;if(z?.current&&L){const D=z.current.getBoundingClientRect().top-L.getBoundingClientRect().top;L.scrollHeight>L.clientHeight?L.scrollTo({top:Math.max(0,L.scrollTop+D-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,z.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout(q.current??void 0),q.current=setTimeout(()=>{R(!1),q.current=null},800)}else R(!1)},[b]);i.useEffect(()=>{const w=setTimeout(()=>{const z=g.current;if(!z)return;const L=()=>{if(E)return;const B=z.getBoundingClientRect(),D=B.height;let te="",se=0;for(const[ue,ie]of Object.entries(b))if(ie.current){const ae=ie.current.getBoundingClientRect(),le=B.top,oe=ae.top-le,je=ae.bottom-le,Se=ae.height,o=Math.max(0,oe),x=Math.min(D,je),N=Math.max(0,x-o)/Se,F=N+(oe<D*.3?.1:0);F>se&&N>.1&&(se=F,te=ue)}te&&te!==j&&_(te)};return L(),z.addEventListener("scroll",L,{passive:!0}),()=>{z.removeEventListener("scroll",L),clearTimeout(q.current??void 0)}},100);return()=>clearTimeout(w)},[b,j,E]),i.useEffect(()=>{const w=new URLSearchParams(M.search),z=w.get("section"),L=w.get("setting")?"backend":z,B=L?b[L]:void 0;if(!L||!B)return;let D=!1,te=Number.NaN,se=0;const ue=window.setTimeout(()=>{D||(D=!0,ae.disconnect(),f(L))},2e3),ie=()=>{if(D)return;const le=B.current;if(!le){se=requestAnimationFrame(ie);return}const oe=Math.round(le.getBoundingClientRect().top+window.scrollY);if(oe===te&&oe>0){D=!0,ae.disconnect(),window.clearTimeout(ue),f(L);return}te=oe,se=requestAnimationFrame(ie)},ae=new ResizeObserver(()=>{D||(cancelAnimationFrame(se),se=requestAnimationFrame(ie))});return g.current&&ae.observe(g.current),se=requestAnimationFrame(ie),()=>{D=!0,cancelAnimationFrame(se),ae.disconnect(),window.clearTimeout(ue)}},[M.search,b,f]);const G=async(w,z)=>{p(w);try{await u.mutateAsync({[w]:z}),await l()}catch(L){console.error(`Error updating ${w}:`,L)}finally{p(null)}},re=r||S,Z=Na(re,4e3);return d?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(K,{variant:"warning",className:"w-full max-w-xl",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:vt("Your settings could not be loaded.",d)}),e.jsx(C,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void l(),disabled:n,children:n?"Retrying":"Retry"})]})})}):re?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(X,{size:"lg",label:Z?void 0:"Loading settings"}),Z&&e.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."})]}):s?e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-canvas",children:[e.jsx("div",{className:"w-12 shrink-0 overflow-y-auto border-r border-hairline min-[1040px]:w-55",children:e.jsx(vs,{activeSection:j,onSelectSection:f,sections:ys})}),e.jsx("div",{ref:g,"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:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(Ms,{title:"Settings",icon:Be}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:b.general,className:"flex flex-col gap-8",children:[e.jsx(V,{title:"User profile",icon:js,description:`Your user profile information displayed in the application. This information is not provided to the agents. ${y?"These details are provided through your Radient account.":""}`,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(He,{value:c.profile.name,label:"Display name",placeholder:"Enter your name...",isSaving:m==="user_name",onSave:async w=>{p("user_name");try{c.updateName(w)}finally{p(null)}},readOnly:y}),e.jsx(He,{value:c.profile.email,label:"Email address",placeholder:"Enter your email...",isSaving:m==="user_email",onSave:async w=>{p("user_email");try{c.updateEmail(w)}finally{p(null)}},readOnly:y})]})}),e.jsx(V,{title:"Application tour",description:"Missed the application onboarding tour or want a refresher? Start it again here.",children:e.jsxs(C,{variant:"secondary",onClick:()=>{O({forceModalCompleted:!0})},children:[e.jsx(bs,{}),"Take the tour"]})}),e.jsx(V,{title:"Model settings",icon:ks,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:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ws,{value:s.values.hosting,isSaving:m==="hosting",onSave:w=>G("hosting",w),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:"No hosting providers available. Add one in API credentials, in the list on the left."}),e.jsx(Ns,{value:s.values.model_name,hostingId:s.values.hosting,isSaving:m==="model_name",onSave:w=>G("model_name",w),allowCustom:!0,allowDefault:!1}),e.jsx(K,{variant:"neutral",icon:e.jsx(Me,{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, add credentials or sign in to Radient."})]})}),e.jsx(cn,{}),e.jsx(V,{title:"History settings",icon:Ps,description:"Configure how much conversation history is retained and displayed. These are tools to help balance cost and performance by controlling the amount of data used by the agents.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ae,{value:s.values.conversation_length,label:"Maximum conversation history",description:"Number of messages to keep in conversation history for context. More messages will make the agents have longer memory but more expensive to run. Recommended: 100",min:10,max:500,step:10,unit:"msgs",icon:Cs,isSaving:m==="conversation_length",onChange:w=>G("conversation_length",w)}),e.jsx(Ae,{value:s.values.detail_length,label:"Detail view length",description:"Maximum number of messages to show in the detailed conversation view. Messages beyond this limit will be summarized. Shortening this will decrease costs but some important details could get lost from earlier messages. Recommended: 15",min:10,max:500,step:5,unit:"msgs",icon:Ss,isSaving:m==="detail_length",onChange:w=>G("detail_length",w)}),e.jsx(Ae,{value:s.values.max_learnings_history,label:"Maximum learnings history",description:"Agents note down specific insights and key learnings in memory which persist beyond the maximum conversation history and summarization. This setting controls the maximum number of learning items to retain. More items will make the agents acquire a longer history of knowledge from your conversations but more expensive to run. Recommended: 50",min:10,max:200,step:10,unit:"notes",icon:_s,isSaving:m==="max_learnings_history",onChange:w=>G("max_learnings_history",w)})]})}),e.jsx(V,{title:"Configuration information",icon:Me,description:"System information about the current configuration.",children:e.jsxs(Oe,{children:[e.jsx(Q,{label:"Version",value:e.jsx("span",{className:"text-mono-sm",children:s.version})}),e.jsx(Q,{label:"Created",value:Ct(s.metadata.created_at)}),e.jsx(Q,{label:"Last modified",value:St(s.metadata.last_modified)}),e.jsx(Q,{label:"Description",value:s.metadata.description||"No description available"})]})})]}),e.jsx(V,{title:"Appearance",icon:_t,description:"Customize the look and feel of Local Operator",sectionRef:b.appearance,dataTourTag:"settings-appearance-section",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(hn,{}),e.jsx(ya,{value:t,label:"Show agent reasoning",description:"Adds the agent's Reasoning and Thinking rows to conversations. They stay closed until you open one.",onChange:async w=>a(w)})]})}),e.jsx(V,{title:"Radient account",titleComponent:e.jsx(gn,{}),description:"Manage your Radient account, Radient Pass details, and credits.",sectionRef:b.radient,dataTourTag:"settings-radient-account-section",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(on,{onAfterCredentialUpdate:()=>{A(),T()}}),y&&e.jsxs(e.Fragment,{children:[e.jsx(pn,{}),e.jsx(fn,{})]})]})}),e.jsx(V,{title:"Providers",icon:wt,description:"Model providers, how you sign in to each, and which are connected.",sectionRef:b.providers,children:e.jsx(As,{initialProviderId:ee})}),e.jsx(V,{title:"Backend settings",icon:Be,description:"Every setting the backend registry owns, searchable, with typed editors and scopes.",sectionRef:b.backend,children:e.jsx(Wa,{focusKey:W,initialFilter:$})}),e.jsx(rn,{sessionId:h??void 0,sectionRef:b.integrations,highlightServer:Y}),e.jsx(V,{title:"API credentials",icon:Ce,description:"Manage your API keys for various services and integrations",sectionRef:b.credentials,dataTourTag:"settings-api-credentials-section",children:e.jsx(Ja,{})}),e.jsx("div",{ref:b.updates,children:e.jsx(Ea,{})})]})]})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(K,{variant:"warning",className:"w-full max-w-xl",children:"Your settings could not be loaded."})})};export{wn as SettingsPage};
|
|
91
|
+
`).map(c=>c.trim()).filter(Boolean)}),"aria-label":`${t.label}: ${u}`,className:"font-mono text-body-sm"})]},u)),e.jsx("p",{className:"text-meta text-ink-dim",children:"One hop per line, as provider/model (effort). An empty chain moves to the next provider."})]})}default:return e.jsx(ae,{value:a,disabled:r,onChange:l=>n(l.target.value),"aria-label":t.label,placeholder:t.placeholder})}},Et=({className:t})=>e.jsx("span",{role:"img","aria-label":"Changed from the default",title:"Changed from the default",className:J("size-1.5 shrink-0 rounded-full bg-accent",t)}),Ba=({title:t,rowCount:a,advancedCount:s,scope:r,modified:n,onOpenChange:d,defaultOpen:l=!1})=>e.jsx("div",{"data-section-header":t,className:"flex w-full flex-col",children:e.jsx(pt,{defaultOpen:l,onOpenChange:d,triggerClassName:"text-ink hover:bg-elevated hover:text-ink",chevronClassName:"text-ink-dim",rowClassName:"min-h-10 py-0",className:"w-full",summary:e.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-heading text-ink",children:t}),a>0&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a===1?"1 setting":`${a} settings`}),r&&e.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:r}),s>0&&e.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[s," advanced"]})]}),n&&e.jsx(Et,{className:"ml-auto"})]})})}),Ha="size-3.5 shrink-0",Va=({setting:t,draft:a,tier:s,gate:r,saving:n,error:d,onDraftChange:l,onSave:u,onReset:m})=>{const p=!!(r&&!r.on),c=we(t,a),y=n||p,S=t.kind==="list"||t.kind==="cascade",h=e.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx("span",{className:"truncate text-body-sm text-ink",children:t.label}),t.kind==="readonly"&&e.jsx("span",{className:"text-meta text-ink-dim",children:"Read-only"}),t.warning&&e.jsx("span",{className:"text-meta text-danger",children:t.warning})]}),j=p&&r&&e.jsxs("p",{className:"text-meta text-ink-dim",children:["Needs ",r.label," on. Nothing here is saved while it is off."]});return e.jsx("div",{"data-setting-key":t.key,"data-tier":s,className:"border-b border-hairline",children:e.jsxs("div",{className:"flex flex-wrap items-start gap-x-4 gap-y-1 px-1 py-2.5",children:[e.jsxs("div",{className:J("flex min-w-44 flex-col gap-0.5",S?"shrink-0 basis-2/5":"flex-1"),children:[s==="advanced"&&t.help?e.jsx(pt,{summary:h,triggerClassName:"min-h-5 py-0 px-0 text-body-sm text-ink hover:text-ink",chevronClassName:"text-ink-dim",summaryAlign:"firstLine",rowClassName:"min-h-5 py-0",className:"w-full",children:e.jsx("span",{className:"text-meta text-ink-dim",children:t.help})}):e.jsxs("span",{className:"flex min-h-5 items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,className:Ha}),h]}),s==="core"&&t.help&&e.jsx("p",{className:"ml-5 text-meta text-ink-dim",children:t.help}),j]}),e.jsxs("div",{className:J("flex shrink-0 items-center gap-2 self-center",S&&"min-w-0 flex-1 items-start"),children:[(!t.is_default||c)&&e.jsx(Et,{}),!t.is_default&&t.kind!=="readonly"&&e.jsxs(C,{variant:"ghost",size:"sm",disabled:y,onClick:m,"aria-label":`Use default for ${t.label}`,children:[e.jsx(pa,{"aria-hidden":"true"}),"Use default"]}),c&&e.jsx(C,{variant:"primary",size:"sm",disabled:y,onClick:u,children:n?"Saving":"Save"}),e.jsx("div",{className:za(t.kind),"data-setting-control":"",children:t.redacted?e.jsx("span",{className:"text-meta text-ink-dim",children:"Set in the credential manager: this value carries inline credentials or query parameters."}):t.kind==="readonly"?e.jsx("span",{className:"text-body-sm text-ink-muted",children:xe(t.value)||"Not set"}):e.jsx(qa,{setting:t,value:a.value,chains:a.cascadeBase??void 0,disabled:y,onValueChange:_=>l({...a,value:_}),onChainsChange:_=>l({...a,cascadeBase:_})})})]}),d&&e.jsx(K,{variant:"danger",role:"alert",className:"w-full",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:d}),e.jsxs(C,{variant:"secondary",size:"sm",disabled:n,onClick:u,children:[e.jsx(Qt,{"aria-hidden":"true"}),"Retry"]})]})})]})})},Ka="w-full max-w-[400px]",Ya=({query:t,onQueryChange:a,matchCount:s,matchSections:r,coreCount:n,advancedCount:d,modifiedCount:l,modifiedOnly:u,onModifiedOnlyChange:m,showAdvanced:p,onShowAdvancedChange:c,onExpandAll:y,onCollapseAll:S,unsavedCount:h,savingAll:j,onSaveAll:_,onDiscardAll:A})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:J("relative",Ka),children:[e.jsx(xt,{size:16,className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-ink-dim","aria-hidden":"true"}),e.jsx(ae,{value:t,onChange:R=>a(R.target.value),onKeyDown:R=>{R.key==="Escape"&&t&&a("")},placeholder:"Search settings by name, description or key","aria-label":"Search settings",className:"pl-9"}),t&&e.jsx(C,{variant:"ghost",size:"icon-sm",className:"absolute top-1/2 right-1 -translate-y-1/2",onClick:()=>a(""),"aria-label":"Clear search",children:e.jsx(Tt,{"aria-hidden":"true"})})]}),e.jsxs("fieldset",{className:"m-0 border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Settings filters"}),e.jsxs("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:[e.jsxs(C,{variant:"ghost",size:"sm","aria-pressed":u,onClick:()=>m(!u),className:J(u&&"bg-surface text-ink hover:bg-surface"),children:["Modified",e.jsx(Ne,{variant:"neutral",children:l})]}),e.jsx(C,{variant:"ghost",size:"sm","aria-pressed":p,onClick:()=>c(!p),className:J(p&&"bg-surface text-ink hover:bg-surface"),children:"Show advanced"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[h>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-meta text-ink-dim",children:h===1?"1 unsaved change":`${h} unsaved changes`}),e.jsx(C,{variant:"primary",size:"sm",disabled:j,onClick:_,children:j?"Saving":"Save all"}),e.jsx(C,{variant:"ghost",size:"sm",disabled:j,onClick:A,children:"Discard all"})]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:y,children:"Expand all"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:S,children:"Collapse all"})]})]}),e.jsx("p",{className:"text-meta text-ink-dim","aria-live":"polite",children:s!==null?`${s} ${s===1?"result":"results"} in ${r} ${r===1?"section":"sections"}`:u?`${l} modified ${l===1?"setting":"settings"}`:p?`${d} advanced settings shown — Expand all to see them`:`${n} core settings, ${d} advanced`})]}),Ga={all:["desktop","settings"]},Qa={live:"Takes effect immediately","new launch":"Takes effect the next time the app starts","new sessions":"Takes effect for new conversations"},Wa=40,pe=t=>t.toLowerCase().replace(/[-_.]/g," "),Za=({focusKey:t,initialFilter:a=""})=>{const s=ft(),r=gt(s.data,"settings"),[n,d]=i.useState(a),[l,u]=i.useState(!1),[m,p]=i.useState(!1),[c,y]=i.useState({}),[S,h]=i.useState({}),[j,_]=i.useState({}),[A,R]=i.useState(!1),[$,g]=i.useState(new Set),[O,M]=i.useState(new Set),[U,E]=i.useState(new Set),T=i.useRef(null),v=i.useRef(null),z=ye({queryKey:Ga.all,queryFn:()=>ge({op:"settings.list"}),enabled:r,staleTime:1e4}),b=z.data;i.useEffect(()=>{b&&y(o=>{let x=!1;const k={...o};for(const N of b.settings){const F=o[N.key];if(!F){k[N.key]=ce(N),x=!0;continue}if(we(N,F))continue;const I=ce(N);(I.value!==F.value||I.cascadeBase!==F.cascadeBase)&&(k[N.key]=I,x=!0)}return x?k:o})},[b]);const Q=i.useCallback(o=>!o.is_default||we(o,c[o.key]??ce(o)),[c]),H=i.useMemo(()=>{if(!b)return[];const o=pe(n.trim()),x=o.length>0||m;return b.settings.filter(k=>!x&&he(k)==="advanced"&&!l||m&&!Q(k)?!1:o?pe([k.label,k.help,k.key,k.section,k.warning??""].join(" ")).includes(o):!0)},[b,n,l,m,Q]),W=n.trim().length>0||m,ne=i.useMemo(()=>b?.sections??[],[b]),f=i.useCallback(o=>(b?.settings??[]).filter(x=>x.section===o),[b]),Y=o=>H.filter(x=>x.section===o),re=o=>$.has(o)?!0:O.has(o)?!1:Ia(f(o)),Z=(o,x)=>{g(k=>{const N=new Set(k);return x?N.add(o):N.delete(o),N}),M(k=>{const N=new Set(k);return x?N.delete(o):N.add(o),N})},w=(o,x)=>{E(k=>{const N=new Set(k);return x?N.delete(o):N.add(o),N})},P=o=>{const x=ne.filter(N=>o||Y(N.name).length>0).map(N=>N.name),k=La(o,W,x);k.layout&&(g(new Set(k.layout.opened)),M(new Set(k.layout.closed))),E(new Set(k.filter))};i.useEffect(()=>{n.trim()||E(new Set)},[n]);const L=i.useCallback(o=>{const x=o.gated_by;if(!x||!b)return null;const k=b.settings.find(N=>N.key===x);return{key:x,label:k?.label??x,on:k?.value===!0||k?.value==="true"}},[b]),q=i.useCallback((o,x)=>h(k=>({...k,[o]:x})),[]),D=i.useCallback((o,x)=>_(k=>({...k,[o]:x})),[]),ee=i.useCallback(async o=>{const x=c[o.key];if(!x)return!1;const k=Fa(o,x);if(!k.ok)return D(o.key,k.error),!1;q(o.key,!0),D(o.key,null);try{await ge(k.request),q(o.key,!1);const F=(await z.refetch()).data?.settings.find(I=>I.key===o.key);return F&&y(I=>{const fe=I[o.key];return fe&&fe.value===x.value&&fe.cascadeBase===x.cascadeBase?{...I,[o.key]:ce(F)}:I}),!0}catch(N){return q(o.key,!1),D(o.key,N instanceof Error?N.message:"The setting could not be saved."),!1}},[c,z,q,D]),te=i.useCallback(async o=>{q(o.key,!0),D(o.key,null);try{await ge({op:"settings.reset",key:o.key}),y(x=>({...x,[o.key]:ce({...o,value:o.default,is_default:!0})})),q(o.key,!1),await z.refetch()}catch(x){q(o.key,!1),D(o.key,x instanceof Error?x.message:"The setting could not be reset.")}},[z,q,D]),ue=i.useMemo(()=>(b?.settings??[]).filter(o=>we(o,c[o.key]??ce(o))),[b,c]),ie=async()=>{R(!0);for(const o of ue)await ee(o);R(!1)},se=()=>{b&&(y(o=>{const x={...o};for(const k of b.settings)x[k.key]=ce(k);return x}),_({}))};i.useEffect(()=>{if(!t||!b||T.current===t)return;const o=b.settings.find(N=>N.key===t);if(!o)return;T.current=t,he(o)==="advanced"&&u(!0);const x=pe(n.trim());!x||pe([o.label,o.help,o.key,o.section].join(" ")).includes(x)||d(""),p(!1),g(N=>new Set(N).add(o.section)),M(N=>{const F=new Set(N);return F.delete(o.section),F})},[t,b,n]);const le=i.useMemo(()=>{if(!t||!b)return!1;const o=b.settings.find(k=>k.key===t);if(!o||he(o)==="advanced"&&!l)return!1;const x=pe(n.trim());return x?pe([o.label,o.help,o.key,o.section].join(" ")).includes(x):!0},[t,b,n,l]);if(i.useEffect(()=>{if(!le||!t||v.current===t)return;let o=0,x=0;const k=()=>{const N=document.querySelector(`[data-setting-key="${CSS.escape(t)}"]`),F=N?.querySelector('[data-setting-control] :is(input, textarea, select, button[role="switch"], button)')??N;if(F){F===N&&(F.tabIndex=-1),F.focus(),F.scrollIntoView({block:"center"}),v.current=t;return}x+=1,x<Wa&&(o=requestAnimationFrame(k))};return o=requestAnimationFrame(k),()=>cancelAnimationFrame(o)},[le,t]),s.data&&!r)return e.jsx(K,{variant:"warning",children:"Searchable settings need a newer Local Operator server. Update the server and restart the app to manage these settings here."});if(z.isLoading||s.isLoading)return e.jsx("div",{className:"flex h-40 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading settings"})});const oe=(s.data?null:s.error)??z.error;if(oe||!b){const o=s.isFetching||z.isFetching;return e.jsx(K,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:vt("Your settings could not be loaded.",oe)}),e.jsx(C,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>{s.isError?s.refetch():z.refetch()},disabled:o,children:o?"Retrying":"Retry"})]})})}const je=b.settings.reduce((o,x)=>(o[he(x)]+=1,o),{core:0,advanced:0}),Se=new Set(H.map(o=>o.section)).size;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ya,{query:n,onQueryChange:d,matchCount:n.trim()?H.length:null,matchSections:Se,coreCount:je.core,advancedCount:je.advanced,modifiedCount:b.settings.filter(Q).length,modifiedOnly:m,onModifiedOnlyChange:p,showAdvanced:l,onShowAdvancedChange:u,onExpandAll:()=>P(!0),onCollapseAll:()=>P(!1),unsavedCount:ue.length,savingAll:A,onSaveAll:()=>void ie(),onDiscardAll:se}),W&&H.length===0&&e.jsx("div",{className:"flex flex-col items-center py-6 text-center",children:e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No settings match this search. Clear the search field to see every setting again."})}),e.jsx("div",{className:"flex flex-col gap-1",children:ne.map(o=>{const x=Y(o.name),k=f(o.name),N=W?0:k.filter(I=>he(I)==="advanced").length;if(W&&x.length===0)return null;const F=W?x.length>0&&!U.has(o.name):re(o.name);return e.jsxs("section",{"data-settings-section":o.name,"data-open":F,className:"flex flex-col",children:[e.jsx(Ba,{title:o.title,rowCount:x.length,advancedCount:N,scope:Qa[o.scope],modified:k.some(Q),defaultOpen:F,onOpenChange:I=>W?w(o.name,I):Z(o.name,I)},`${o.name}:${F?"open":"closed"}`),e.jsxs("div",{hidden:!F,className:"flex flex-col pb-3",children:[o.description&&e.jsx("p",{className:"px-1 pb-1 text-meta text-ink-dim",children:o.description}),x.length===0?e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:N>0?"Advanced settings are hidden here.":"Nothing in this section matches."}),N>0&&e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>u(!0),children:["Show ",N," advanced"]})]}):x.map(I=>e.jsx(Va,{setting:I,draft:c[I.key]??ce(I),tier:he(I),gate:L(I),saving:!!S[I.key],error:j[I.key]??null,onDraftChange:fe=>y(De=>({...De,[I.key]:fe})),onSave:()=>void ee(I),onReset:()=>void te(I)},I.key))]})]},o.name)})})]})},Ye=({credentialKey:t,isConfigured:a=!1,onEdit:s,onClear:r,onAdd:n})=>{const d=Wt(t),l=a?ea:Ce;return e.jsxs("div",{className:"flex flex-col rounded-md p-3 transition-colors duration-fast ease-out-quart hover:bg-elevated",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-body font-medium text-ink",children:[e.jsx(l,{className:"size-3.5 shrink-0 text-ink-dim"}),d.name]}),e.jsx("p",{className:"mt-1 break-all text-mono-sm text-ink-dim",children:t}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:d.description})]}),e.jsx("div",{className:"mt-auto flex flex-wrap items-center justify-end gap-2 pt-4",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>s?.(t),children:[e.jsx(Zt,{}),"Update"]}),e.jsxs(C,{variant:"ghost",size:"sm",className:"text-danger hover:bg-danger-wash hover:text-danger",onClick:()=>r?.(t),children:[e.jsx(yt,{}),"Clear"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>n?.(t),children:[e.jsx(Ce,{}),"Configure"]}),d.url&&e.jsx(Re,{content:`Get your ${d.name} key`,children:e.jsx(C,{variant:"ghost",size:"icon-sm",asChild:!0,children:e.jsx("a",{href:d.url,target:"_blank",rel:"noopener noreferrer","aria-label":`Get your ${d.name} key`,children:e.jsx(jt,{})})})})]})})]})},Te="_custom_",Ge="credential-custom-key",Qe="credential-custom-key-error",We="credential-type",Ze="credential-type-help",Je="credential-value",Xe="credential-value-help",et=({open:t,onClose:a,onSave:s,initialKey:r="",existingKeys:n,isSaving:d,isEditMode:l})=>{const[u,m]=i.useState(r),[p,c]=i.useState(""),[y,S]=i.useState(""),[h,j]=i.useState(!1);i.useEffect(()=>{if(t){const v=ve.some(b=>b.key===r),z=!l&&r&&!v;m(v?r:""),c(""),S(z?r:""),j(z||l&&!v)}},[t,r,l]);const _=()=>{let v="";if(l?v=r:v=h?y.trim():u,!v){console.error("No key provided for credential");return}if(!p.trim()){console.error("No value provided for credential");return}s({key:v,value:p})},A=v=>n.includes(v)&&v!==r,R=A(y),$=l?!0:h?y.trim()!==""&&!R:u!==""&&!A(u),g=p.trim()!=="",O=$&&g&&!d,M=ve.find(v=>v.key===u),U=!!M&&!h,E=l?"Update credential":"Add new credential",T=e.jsxs(e.Fragment,{children:[e.jsx(C,{variant:"secondary",onClick:a,children:"Cancel"}),e.jsxs(C,{variant:"primary",onClick:_,disabled:!O,children:[d&&e.jsx(X,{size:"sm",className:"border-t-on-accent"}),d?"Saving...":"Save"]})]});return e.jsx(Jt,{open:t,onClose:a,title:E,actions:T,maxWidth:"sm",fullWidth:!0,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[l?e.jsx(G,{label:"Credential key",value:e.jsx("span",{className:"text-mono-sm",children:r})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:We,children:"Credential type"}),e.jsxs(at,{value:h?Te:u,onValueChange:v=>{v===Te?(j(!0),m("")):(j(!1),m(v),S(""))},children:[e.jsx(nt,{id:We,"aria-describedby":U?Ze:void 0,children:e.jsx(rt,{placeholder:"Select a credential type"})}),e.jsxs(it,{children:[ve.filter(v=>!v.internal).map(v=>e.jsxs(Le,{value:v.key,disabled:A(v.key),children:[v.name,A(v.key)&&" (configured)"]},v.key)),e.jsx(Le,{value:Te,children:"Custom credential"})]})]}),U&&M&&e.jsxs("div",{id:Ze,className:"flex flex-col items-start gap-1",children:[e.jsx("p",{className:"text-meta text-ink-dim",children:M.description}),M.url&&e.jsxs("a",{href:M.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent text-meta underline-offset-4 hover:text-accent-hover hover:underline",children:["Get your ",M.name," key"]})]})]}),h&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:Ge,children:"Custom credential key"}),e.jsx(ae,{id:Ge,value:y,onChange:v=>S(v.target.value),"aria-invalid":R||void 0,"aria-describedby":R?Qe:void 0,required:!0,autoFocus:!0}),R&&e.jsx("p",{id:Qe,className:"text-danger text-meta",children:"This credential already exists"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:Je,children:"Credential value"}),e.jsx(ae,{id:Je,type:"password",value:p,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&O&&_()},"aria-describedby":l?Xe:void 0,required:!0,autoFocus:l,placeholder:"Enter the credential value or API key"}),l&&e.jsxs("p",{id:Xe,className:"text-ink-dim text-meta",children:["Enter the new value for ",r]})]})]})})},tt=({title:t,description:a,children:s,isEmpty:r=!1,emptyStateType:n="noCredentials"})=>e.jsxs("section",{children:[e.jsx("h3",{className:"text-body font-medium text-ink",children:t}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:a}),e.jsx(Rt,{variant:"surface",padding:"sm",className:"mt-3",children:r?e.jsx(Ja,{type:n}):e.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-2",children:s})})]}),Ja=({type:t,className:a})=>{const s=t==="noCredentials",r=s?Ce:ot;return e.jsxs("div",{className:J("flex flex-col items-center px-4 py-8 text-center",a),children:[e.jsx(r,{size:20,className:"text-ink-dim","aria-hidden":!0}),e.jsx("p",{className:"mt-3 text-body font-medium text-ink",children:s?"No credentials configured":"All available credentials configured"}),e.jsx("p",{className:"mt-1 max-w-sm text-body-sm text-ink-muted",children:s?"You haven't set up any API credentials yet. Add credentials from the available options or add a custom one.":"You've configured all the common API credentials. You can still add custom credentials if needed."})]})},Xa=()=>{const{data:t,isLoading:a,error:s,refetch:r}=bt(),n=Xt(),[d,l]=i.useState(!1),[u,m]=i.useState(!1),[p,c]=i.useState(null),y=g=>{c(g),l(!0)},S=(g=null)=>{c(g),m(!0)},h=()=>{l(!1),m(!1),c(null)},j=async g=>{try{await n.mutateAsync(g),h(),await r()}catch(O){console.error("Error saving credential:",O)}},_=async g=>{try{await n.mutateAsync({key:g,value:""}),await r()}catch(O){console.error("Error clearing credential:",O)}},A=i.useMemo(()=>t?.keys?.filter(g=>!ve.find(O=>O.key===g)?.internal)??[],[t]),R=i.useMemo(()=>ve.filter(g=>!A.includes(g.key)&&!g.internal),[A]),$=()=>a?e.jsx("div",{className:"flex min-h-40 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading credentials"})}):s||!t?e.jsxs(K,{variant:"danger",role:"alert",children:[e.jsx(Mt,{children:"Could not load credentials"}),e.jsx(It,{children:s instanceof Error?s.message:"The server did not say why. Check that Local Operator is running, then reopen this page."})]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{title:"Configured credentials",description:"These API credentials are currently configured and available for use.",isEmpty:A.length===0,emptyStateType:"noCredentials",children:A.map(g=>e.jsx(Ye,{credentialKey:g,isConfigured:!0,onEdit:y,onClear:_},g))}),e.jsx(tt,{title:"Available credentials",description:"These are common API credentials you can configure to enhance functionality.",isEmpty:R.length===0,emptyStateType:"allConfigured",children:R.map(g=>e.jsx(Ye,{credentialKey:g.key,isConfigured:!1,onAdd:()=>S(g.key)},g.key))}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>S(null),children:[e.jsx(es,{}),"Add custom credential"]})}),d&&e.jsx(et,{open:d,onClose:h,onSave:j,initialKey:p||"",existingKeys:A,isSaving:n.isPending,isEditMode:!0}),u&&e.jsx(et,{open:u,onClose:h,onSave:j,initialKey:p||"",existingKeys:A,isSaving:n.isPending,isEditMode:!1})]});return e.jsx("div",{className:"flex flex-col gap-6",children:$()})},en=[[[".claude.json"],"Claude Code"],[[".claude",".mcp.json"],"Claude Code"],[[".cursor","mcp.json"],"Cursor"],[[".vscode","mcp.json"],"VS Code"],[[".codex","config.toml"],"Codex CLI"]];function tn(t){if(!t)return null;const a=t.split("\\").join("/").split("/").filter(Boolean);for(const[s,r]of en)if(!(a.length<s.length)&&a.slice(-s.length).join("/")===s.join("/"))return r;return null}const sn={list:"status",add:"add",remove:"remove",reload:"reload",connect:"reconnect",probe:"probe",disconnect:"disconnect",login:"grant",logout:"disconnect",reauth:"grant",status:"status",cancel:"cancel"},an=(t,a)=>{const s=t?.trim();if(!s)return null;const r=os(s,a);return r.kind==="auth"?{kind:"matched",name:r.name,unresolved:null}:{kind:"miss",asked:s}},nn=t=>t.reduce((a,s)=>a?(s.updated_at??0)>(a.updated_at??0)?s:a:s,null),rn=({sessionId:t,onAdded:a})=>{const[s,r]=i.useState(""),[n,d]=i.useState("command"),[l,u]=i.useState(""),[m,p]=i.useState(""),[c,y]=i.useState(""),[S,h]=i.useState("global"),[j,_]=i.useState(null),[A,R]=i.useState(!1),$=async()=>{R(!0),_(null);try{await ge({op:"mcp.control",sessionId:t,control:{action:"add",name:s,scope:S,...n==="command"?{command:l,args:m.split(`
|
|
92
|
+
`).map(g=>g.trim()).filter(Boolean)}:{url:c}}}),r(""),u(""),p(""),y(""),a()}catch(g){_(kt("add",g,!1))}finally{R(!1)}};return e.jsxs("form",{className:"flex flex-col gap-3 rounded-md border border-control bg-surface p-4",onSubmit:g=>{g.preventDefault(),$()},children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-name",children:"Name"}),e.jsx(ae,{id:"mcp-add-name",value:s,onChange:g=>r(g.target.value),required:!0})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Server transport"}),e.jsx(C,{type:"button",variant:n==="command"?"secondary":"ghost",size:"sm",onClick:()=>d("command"),children:"Local command"}),e.jsx(C,{type:"button",variant:n==="url"?"secondary":"ghost",size:"sm",onClick:()=>d("url"),children:"Remote URL"})]}),n==="command"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-command",children:"Command"}),e.jsx(ae,{id:"mcp-add-command",value:l,onChange:g=>u(g.target.value),className:"font-mono",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-args",children:"Arguments, one per line"}),e.jsx("textarea",{id:"mcp-add-args",value:m,onChange:g=>p(g.target.value),rows:2,className:"rounded-sm border border-control bg-surface p-2 font-mono text-body-sm text-ink"})]})]}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(de,{htmlFor:"mcp-add-url",children:"URL"}),e.jsx(ae,{id:"mcp-add-url",type:"url",value:c,onChange:g=>y(g.target.value),className:"font-mono",required:!0}),e.jsx("p",{className:"text-meta text-ink-dim",children:"No inline credentials or query parameters; secrets are referenced from the credential manager."})]}),e.jsxs("fieldset",{className:"flex gap-2",children:[e.jsx("legend",{className:"sr-only",children:"Configuration scope"}),e.jsx(C,{type:"button",variant:S==="global"?"secondary":"ghost",size:"sm",onClick:()=>h("global"),children:"Global"}),e.jsx(C,{type:"button",variant:S==="project"?"secondary":"ghost",size:"sm",onClick:()=>h("project"),children:"This project"})]}),j&&e.jsxs(K,{variant:"danger",children:[e.jsx("p",{children:j.message}),j.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:j.detail,children:j.detail}):null]}),e.jsx("div",{children:e.jsxs(C,{type:"submit",variant:"primary",size:"sm",disabled:A||!s||!(n==="command"?l:c),children:[A?e.jsx(X,{size:"sm"}):null,"Add server"]})})]})},on=({sessionId:t,sectionRef:a,highlightServer:s})=>{const r=ft(),n=gt(r.data,"mcp"),d=ut(),l=be(f=>f.sessions),u=be(f=>f.fetchSessions),m=be(f=>f.loading),p=i.useMemo(()=>t?null:nn(l),[t,l]),c=t??p?.session_id,[y,S]=i.useState(null),[h,j]=i.useState(null),[_,A]=i.useState(!1),[R,$]=i.useState(null),g=ts({sessionId:c}),[O,M]=i.useState("");i.useEffect(()=>{t||!n||l.length>0||u()},[t,n,l.length,u]);const U=ye({queryKey:_e.list(c??""),queryFn:()=>{if(!c)throw new Error("No conversation selected.");return ls(c)},enabled:n&&!!c,staleTime:1e4}),E=ss(U.data),T=i.useMemo(()=>an(s,E.map(f=>f.name)),[s,E]),v=T?.kind==="matched"?T.name:null,z=i.useRef(null),b=i.useRef(null),Q=O.trim().toLowerCase(),H=i.useMemo(()=>Q?E.filter(f=>f.name.toLowerCase().includes(Q)):E,[E,Q]);i.useEffect(()=>{!v||b.current===v||!O||M("")},[v,O]),i.useEffect(()=>{v&&b.current!==v&&H.some(f=>f.name===v)&&(b.current=v,z.current?.scrollIntoView({block:"center",behavior:"smooth"}))},[v,H]);const W=i.useCallback(()=>{c&&d.invalidateQueries({queryKey:_e.list(c)})},[d,c]),ne=i.useCallback(async(f,Y,re={})=>{if(c){j(null);try{await ge({op:"mcp.control",sessionId:c,control:{action:f,name:Y,...re}}),W()}catch(Z){const w=d.getQueryData(_e.list(c));j(kt(sn[f],Z,as(w?.operations)))}}},[d,c,W]);return n?c?e.jsx(V,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts. A connected server is a working transport; the account behind it may still need its own sign-in.",sectionRef:a,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[h&&e.jsxs(K,{variant:"danger",children:[e.jsx("p",{children:h.message}),h.detail?e.jsx("p",{className:"font-mono text-ink-dim text-mono-sm",title:h.detail,children:h.detail}):null]}),p&&e.jsxs("p",{className:"text-body-sm text-ink-muted",children:["Showing MCP servers for"," ",p.title?.trim()||p.session_id.slice(0,6),", your most recent conversation. Open a conversation to see its own list."]}),U.isLoading&&e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading MCP servers"})}),U.isError&&e.jsx(K,{variant:"warning",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:"MCP servers could not be loaded."}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>void U.refetch(),children:"Retry"})]})}),E.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx(xt,{"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-dim"}),e.jsx(ae,{value:O,onChange:f=>M(f.target.value),placeholder:"Search MCP servers","aria-label":"Search MCP servers",className:"pl-9"})]}),T?.kind==="miss"&&E.length>0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`No MCP server matches "${T.asked}".`}),T?.kind==="matched"&&T.unresolved&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:`Showing "${T.name}" — "${T.unresolved}" is not one of your servers.`}),U.isSuccess&&E.length===0&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers configured yet. Add one below."}),E.length>0&&H.length===0&&e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No MCP servers match this search."}),e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>M(""),children:"Clear search"})]}),H.length>0&&e.jsx("ul",{className:"flex flex-col gap-2",children:H.map(f=>{const Y=f.status==="connected",re=f.name===v,Z=f.owned_scope,w=f.transport==="http"&&f.transport_oauth_supported!==!1,P=tn(f.source);return e.jsxs("li",{ref:re?z:void 0,className:J("flex flex-col gap-2 rounded-md border border-control bg-surface p-3",re&&"border-accent bg-elevated"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-body text-ink",children:f.name}),Z&&e.jsx(Ne,{variant:"outline",children:Z==="project"?"This project":"Global"}),f.transport&&e.jsx("span",{className:"text-meta text-ink-dim",children:f.transport})]}),e.jsx(Ne,{variant:Y?"success":f.status==="connecting"?"info":f.status==="auth-required"?"warning":"neutral",children:f.status??"unknown"})]}),typeof f.tool_count=="number"&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[f.tool_count," tools available"]}),f.status==="auth-required"&&!w&&e.jsx("p",{className:"text-meta text-ink-dim",children:f.setup?.text?"This server needs credentials local-operator cannot collect. Copy the setup prompt to have an agent walk you through it.":"This server needs credentials local-operator cannot collect."}),!Z&&e.jsxs("p",{className:"text-meta text-ink-dim",children:[P?`Imported from ${P}.`:"Imported from a configuration local-operator does not write."," ",f.source?e.jsxs(e.Fragment,{children:["Remove it in"," ",e.jsx("span",{className:"font-mono text-mono-sm text-ink-dim",children:ns(f.source)}),"."]}):e.jsx(e.Fragment,{children:"Remove it wherever it is defined."})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[Y?e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>{S(null),ne("disconnect",f.name,{confirmed:!0})},children:[e.jsx(wt,{"aria-hidden":"true"}),"Disconnect"]}):e.jsxs(C,{variant:"secondary",size:"sm",onClick:()=>void ne("connect",f.name),children:[e.jsx(ia,{"aria-hidden":"true"}),"Connect"]}),e.jsxs(C,{variant:"ghost",size:"sm",onClick:()=>void ne("reload",f.name),children:[e.jsx(Lt,{"aria-hidden":"true"}),"Reload"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{const L=rs(U.data?.servers??[]).find(q=>q.name===f.name);L&&$({row:L,sessionId:c})},children:"Sign in"}),f.setup?.text?e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{navigator.clipboard.writeText(f.setup?.text??"").catch(()=>{})},children:"Copy setup prompt"}):null,Z?y===f.name?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-body-sm text-ink",children:["Remove ",f.name,"?"]}),e.jsx(C,{variant:"danger",size:"sm",onClick:()=>{S(null),ne("remove",f.name,{confirmed:!0,scope:Z})},children:"Confirm removal"}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>S(null),children:"Keep"})]}):e.jsxs(C,{variant:"ghost",size:"sm",className:"text-danger",onClick:()=>S(f.name),children:[e.jsx(yt,{"aria-hidden":"true"}),"Remove"]}):null]})]},f.name)})}),R?.sessionId===c?e.jsx(is,{row:R.row,remedy:g,onClose:()=>$(null)},c):null,_?e.jsx(rn,{sessionId:c,onAdded:()=>{A(!1),W()}}):e.jsx("div",{children:e.jsx(C,{variant:"secondary",size:"sm",onClick:()=>A(!0),"data-tour-tag":"mcp-add-server",children:"Add server"})})]})}):e.jsx(V,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:a,children:m?e.jsx("div",{className:"flex h-24 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading MCP servers"})}):e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Open a conversation to manage its MCP servers."})}):e.jsx(V,{title:"Integrations",description:"MCP servers connect agents to your tools and accounts.",sectionRef:a,children:e.jsx(K,{variant:"warning",children:"Integration management needs a newer Local Operator backend. Update the backend and restart the app to manage MCP servers here."})})},ln=({onAfterCredentialUpdate:t})=>{const{isAuthenticated:a,user:s,isLoading:r,error:n,signOut:d}=cs(),l=Nt(c=>c.isSigningOut),u=i.useCallback(async()=>{try{await d()}catch(c){console.error("Error signing out:",c)}},[d]),m=i.useMemo(()=>{if(!a||!s?.radientUser)return null;const{account:c,identity:y}=s.radientUser;return e.jsxs(e.Fragment,{children:[e.jsxs(Oe,{children:[e.jsx(G,{label:"Status",value:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Connected",e.jsx(Ne,{variant:"success",className:"capitalize",children:c.status})]})}),e.jsx(G,{label:"Name",value:c.name||"Not provided"}),e.jsx(G,{label:"Email",value:c.email}),e.jsx(G,{label:"Account ID",value:e.jsx("span",{className:"text-mono-sm",children:c.id})}),e.jsx(G,{label:"Tenant ID",value:e.jsx("span",{className:"text-mono-sm",children:c.tenant_id})}),e.jsx(G,{label:"Provider",value:e.jsx("span",{className:"capitalize",children:y.provider})}),e.jsx(G,{label:"Created",value:Ct(c.created_at)})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"Need to sign out or switch accounts?"}),e.jsxs(C,{variant:"danger",className:"mt-3",onClick:u,children:[e.jsx(ds,{}),"Sign out from Radient"]})]})]})},[a,s?.radientUser,u]),p=i.useMemo(()=>a&&s?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-body-sm text-ink-muted",children:"You are not currently signed in to Radient. 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."}),e.jsx("div",{className:"mt-6",children:e.jsx(Ls,{titleText:"",onAfterCredentialUpdate:t,descriptionText:"",onSignInSuccess:()=>{}})})]}),[a,s,t]);return r||l?e.jsx("div",{className:"flex min-h-36 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading account"})}):a&&s?.radientUser?m:e.jsxs("div",{className:"flex flex-col gap-4",children:[n&&e.jsxs(K,{variant:"danger",children:["Error checking account status:"," ",n instanceof Error?n.message:String(n)]}),p]})};function cn({metric:t,data:a}){return e.jsx(us,{title:"",heightClassName:"h-62",yAxisWidth:48,unit:t==="credits"?"credits":"tokens",srSummary:`${t==="credits"?"Credits consumed":"Tokens used"} over the last 30 days, plotted per day across ${a.length} days.`,xTickFormatter:s=>s,yTickFormatter:s=>t==="credits"?`$${s.toFixed(2)}`:ms(s),children:e.jsx(ba,{data:a,children:e.jsx(mt,{type:"monotone",dataKey:"value",strokeWidth:2,dot:!1,activeDot:{r:4,strokeWidth:0},name:t==="credits"?"Credits consumed":"Tokens used"})})})}const dn=()=>{const{data:t,isLoading:a,error:s,refetch:r}=va(),n=ya(),[d,l]=i.useState(""),[u,m]=i.useState(!1);i.useEffect(()=>{l(t?.content??""),m(!1)},[t]);const p=j=>{const _=j.target.value;l(_),m(_!==(t?.content??""))},c=async()=>{if(!(!u||n.isPending))try{const j={content:d};await n.mutateAsync(j),await r(),m(!1)}catch(j){console.error("Error updating system prompt:",j)}},y=()=>{l(t?.content??""),m(!1)},S=n.isPending,h=()=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(de,{htmlFor:"app-system-prompt",children:"Instructions"}),e.jsx(Ie,{id:"app-system-prompt",name:"systemPrompt",value:d,onChange:p,placeholder:"Enter instructions for how all agents should behave and respond to your requests...",className:"min-h-50"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(C,{variant:"primary",onClick:c,disabled:!u||S,children:[S?e.jsx(X,{size:"sm"}):e.jsx(hs,{}),S?"Saving...":"Save changes"]}),e.jsx(C,{onClick:y,disabled:!u||S,children:"Cancel"})]}),t?.last_modified&&e.jsxs("p",{className:"text-ink-dim text-meta",children:["Last modified:"," ",e.jsx("span",{className:"font-mono text-mono-sm",children:St(t.last_modified)})]})]});return e.jsx(V,{title:"System prompt",icon:Fs,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:a?e.jsx("div",{className:"flex min-h-50 items-center justify-center",children:e.jsx(X,{size:"lg",label:"Loading system prompt"})}):s?e.jsxs(K,{variant:"danger",children:["Failed to load system prompt:"," ",s instanceof Error?s.message:"Unknown error"]}):h()})},un={localOperatorDark:sa,localOperatorLight:ma,radient:Ws,dracula:la,dune:Gs,sage:Js,monokai:zt,tokyoNight:na,iceberg:da,neon:fa,obsidian:_t,synth:Ds},mn=({id:t})=>e.jsxs("div",{"data-theme":t,"aria-hidden":"true",className:"flex h-full bg-canvas",children:[e.jsxs("div",{className:"flex w-1/4 flex-col gap-1 bg-sunken p-1.5",children:[e.jsx("span",{className:"flex h-2.5 items-center rounded-xs bg-accent-wash px-1",children:e.jsx("span",{className:"h-1 w-full rounded-xs bg-accent"})}),e.jsx("span",{className:"mx-1 h-1 w-2/3 rounded-xs bg-ink-dim"}),e.jsx("span",{className:"mx-1 h-1 w-1/2 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex flex-1 flex-col justify-between p-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-sm bg-surface p-2",children:[e.jsx("span",{className:"h-1.5 w-3/5 rounded-xs bg-ink"}),e.jsx("span",{className:"h-1 w-full rounded-xs bg-ink-dim"}),e.jsx("span",{className:"h-1 w-4/5 rounded-xs bg-ink-dim"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-3 w-9 rounded-xs bg-accent"}),e.jsx("span",{className:"h-3 w-6 rounded-xs border border-control"})]})]})]}),hn=({id:t,name:a,description:s,isSelected:r,onSelect:n})=>{const d=un[t];return e.jsxs("button",{type:"button","aria-pressed":r,onClick:n,className:J("flex flex-col gap-2 rounded-lg p-2 text-left transition-colors duration-fast ease-out-quart",r?"bg-accent-wash":"hover:bg-surface"),children:[e.jsx("span",{className:J("block aspect-16/10 overflow-hidden rounded-md border transition-colors duration-fast ease-out-quart",r?"border-accent":"border-hairline"),children:e.jsx(mn,{id:t})}),e.jsxs("span",{className:"flex items-center gap-2 px-1",children:[e.jsx(d,{size:14,className:"shrink-0 text-ink-dim","aria-hidden":"true"}),e.jsx("span",{className:J("min-w-0 flex-1 truncate text-body-sm text-ink",r&&"font-medium"),children:a}),r&&e.jsx(ot,{size:14,className:"shrink-0 text-accent","aria-hidden":"true"})]}),e.jsx("span",{className:"px-1 pb-1 text-meta text-ink-muted",children:s})]})},pn=()=>{const{themeName:t,setTheme:a}=Fe(),s=i.useMemo(()=>{const r=Object.values(Ft);return[{label:"Dark",items:r.filter(n=>n.theme.palette.mode==="dark")},{label:"Light",items:r.filter(n=>n.theme.palette.mode==="light")}].filter(n=>n.items.length>0)},[]);return e.jsx("div",{className:"flex flex-col gap-6",children:s.map(r=>e.jsxs("div",{children:[e.jsx("h3",{className:"px-1 pb-2 text-meta text-ink-dim",children:r.label}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-2",children:r.items.map(({id:n,name:d,description:l})=>e.jsx(hn,{id:n,name:d,description:l,isSelected:n===t,onSelect:()=>a(n)},n))})]},r.label))})},xn=()=>{const{data:t,isLoading:a,error:s}=Na({enabled:!0});return e.jsxs("div",{children:[e.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-heading text-ink",children:[e.jsx(Ks,{size:16,className:"shrink-0 text-ink-dim"}),"Radient Pass"]}),a&&e.jsx(lt,{className:"h-6 w-36"}),s&&e.jsxs(K,{variant:"warning",children:["Could not load your credit balance. ",s.message]}),t&&!a&&!s&&e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("p",{className:"flex-1 text-body-sm text-ink-muted",children:["Available credits"," ",e.jsx("span",{className:"font-medium text-ink",children:t.balance.toFixed(2)})]}),e.jsx(C,{variant:"secondary",size:"sm",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com/dashboard/billing",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Bs,{}),"Add credits"]})})]})]})},fn=[{id:"credits",label:"Credits"},{id:"tokens",label:"Tokens"}],gn=()=>{const[t,a]=i.useState("credits"),s=i.useMemo(()=>{const u=new Date,m=ka(u);return{start_date:Ve(m),end_date:Ve(u),rollup:"daily"}},[]),{data:r,isLoading:n,error:d}=_a(s,{enabled:!0}),l=i.useMemo(()=>r?.data_points?[...r.data_points].sort((m,p)=>Ee(m.timestamp).getTime()-Ee(p.timestamp).getTime()).map(m=>({bucket:Ts(Rs(Ee(m.timestamp),"yyyy-MM-dd")),value:t==="credits"?Number.parseFloat(m.total_cost.toFixed(2)):m.total_tokens})):[],[r,t]);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx($s,{size:16,className:"shrink-0 text-ink-dim"}),"Usage (last 30 days)"]}),e.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[e.jsx("legend",{className:"sr-only",children:"Usage metric"}),e.jsx("div",{className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:fn.map(({id:u,label:m})=>e.jsx(C,{variant:"ghost",size:"sm","aria-pressed":t===u,onClick:()=>a(u),className:J(t===u&&"bg-surface text-ink hover:bg-surface"),children:m},u))})]})]}),n&&e.jsx(lt,{className:"h-62 w-full"}),d&&e.jsxs(K,{variant:"warning",children:["Could not load your usage data. ",d.message]}),!n&&!d&&r&&l.length>0&&e.jsx(cn,{metric:t,data:l}),!n&&!d&&(!r||l.length===0)&&e.jsx("p",{className:"text-body-sm text-ink-muted",children:"No usage recorded in the last 30 days."})]})},vn=()=>e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Ms,{size:16,className:"shrink-0 text-ink-dim"}),"Radient account"]}),e.jsx(C,{variant:"secondary",size:"sm",className:"self-start sm:self-center",asChild:!0,children:e.jsxs("a",{href:"https://console.radienthq.com",target:"_blank",rel:"noopener noreferrer",children:["Go to Radient console",e.jsx(jt,{})]})})]}),Nn=()=>{const t=Fe(w=>w.showAgentReasoning),a=Fe(w=>w.setShowAgentReasoning),{data:s,isLoading:r,isFetching:n,error:d,refetch:l}=ps(),u=xs(),[m,p]=i.useState(null),c=Nt(),{isAuthenticated:y,isLoading:S}=Pe(),h=be(w=>w.activeSessionId),[j,_]=i.useState("general"),[A,R]=i.useState(!1),$=i.useRef(null),g=i.useRef(null),{startTour:O}=fs(),M=gs(),{data:U,refetch:E}=bt(),{refreshModels:T}=vs(),v=i.useMemo(()=>U?.keys?[...U.keys].sort():[],[U?.keys]),z=i.useRef({keys:"",hosting:void 0});i.useEffect(()=>{const w=v.join(","),P=s?.values?.hosting;(z.current.keys!==w||z.current.hosting!==P)&&(z.current={keys:w,hosting:P},T().catch(L=>{console.error("Failed to refresh models after credentials or hosting change:",L)}))},[v,s?.values?.hosting,T]);const b=i.useRef({general:i.useRef(null),radient:i.useRef(null),integrations:i.useRef(null),appearance:i.useRef(null),credentials:i.useRef(null),providers:i.useRef(null),backend:i.useRef(null),updates:i.useRef(null)}).current,Q=i.useMemo(()=>new URLSearchParams(M.search).get("setting"),[M.search]),H=i.useMemo(()=>new URLSearchParams(M.search).get("filter")??"",[M.search]),W=i.useMemo(()=>new URLSearchParams(M.search).get("mcp")??void 0,[M.search]),ne=i.useMemo(()=>new URLSearchParams(M.search).get("provider"),[M.search]),f=i.useCallback(w=>{_(w),R(!0);const P=b[w],L=g.current;if(P?.current&&L){const D=P.current.getBoundingClientRect().top-L.getBoundingClientRect().top;L.scrollHeight>L.clientHeight?L.scrollTo({top:Math.max(0,L.scrollTop+D-80),behavior:"smooth"}):window.scrollTo({top:Math.max(0,P.current.getBoundingClientRect().top+window.scrollY-80),behavior:"smooth"}),clearTimeout($.current??void 0),$.current=setTimeout(()=>{R(!1),$.current=null},800)}else R(!1)},[b]);i.useEffect(()=>{const w=setTimeout(()=>{const P=g.current;if(!P)return;const L=()=>{if(A)return;const q=P.getBoundingClientRect(),D=q.height;let ee="",te=0;for(const[ue,ie]of Object.entries(b))if(ie.current){const se=ie.current.getBoundingClientRect(),le=q.top,oe=se.top-le,je=se.bottom-le,Se=se.height,o=Math.max(0,oe),x=Math.min(D,je),N=Math.max(0,x-o)/Se,F=N+(oe<D*.3?.1:0);F>te&&N>.1&&(te=F,ee=ue)}ee&&ee!==j&&_(ee)};return L(),P.addEventListener("scroll",L,{passive:!0}),()=>{P.removeEventListener("scroll",L),clearTimeout($.current??void 0)}},100);return()=>clearTimeout(w)},[b,j,A]),i.useEffect(()=>{const w=new URLSearchParams(M.search),P=w.get("section"),L=w.get("setting")?"backend":P,q=L?b[L]:void 0;if(!L||!q)return;let D=!1,ee=Number.NaN,te=0;const ue=window.setTimeout(()=>{D||(D=!0,se.disconnect(),f(L))},2e3),ie=()=>{if(D)return;const le=q.current;if(!le){te=requestAnimationFrame(ie);return}const oe=Math.round(le.getBoundingClientRect().top+window.scrollY);if(oe===ee&&oe>0){D=!0,se.disconnect(),window.clearTimeout(ue),f(L);return}ee=oe,te=requestAnimationFrame(ie)},se=new ResizeObserver(()=>{D||(cancelAnimationFrame(te),te=requestAnimationFrame(ie))});return g.current&&se.observe(g.current),te=requestAnimationFrame(ie),()=>{D=!0,cancelAnimationFrame(te),se.disconnect(),window.clearTimeout(ue)}},[M.search,b,f]);const Y=async(w,P)=>{p(w);try{await u.mutateAsync({[w]:P}),await l()}catch(L){console.error(`Error updating ${w}:`,L)}finally{p(null)}},re=r||S,Z=Ca(re,4e3);return d?e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(K,{variant:"warning",className:"w-full max-w-xl",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:vt("Your settings could not be loaded.",d)}),e.jsx(C,{variant:"secondary",size:"sm",className:"shrink-0",onClick:()=>void l(),disabled:n,children:n?"Retrying":"Retry"})]})})}):re?e.jsxs("div",{role:"status",className:"flex h-full w-full flex-col items-center justify-center gap-3 bg-canvas",children:[e.jsx(X,{size:"lg",label:Z?void 0:"Loading settings"}),Z&&e.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."})]}):s?e.jsxs("div",{className:"flex h-full w-full overflow-hidden bg-canvas",children:[e.jsx("div",{className:"w-12 shrink-0 overflow-y-auto border-r border-hairline min-[1040px]:w-55",children:e.jsx(ys,{activeSection:j,onSelectSection:f,sections:js})}),e.jsx("div",{ref:g,"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:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(Is,{title:"Settings",icon:Be}),e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsxs("div",{ref:b.general,className:"flex flex-col gap-8",children:[e.jsx(V,{title:"User profile",icon:bs,description:`Your user profile information displayed in the application. This information is not provided to the agents. ${y?"These details are provided through your Radient account.":""}`,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(He,{value:c.profile.name,label:"Display name",placeholder:"Enter your name...",isSaving:m==="user_name",onSave:async w=>{p("user_name");try{c.updateName(w)}finally{p(null)}},readOnly:y}),e.jsx(He,{value:c.profile.email,label:"Email address",placeholder:"Enter your email...",isSaving:m==="user_email",onSave:async w=>{p("user_email");try{c.updateEmail(w)}finally{p(null)}},readOnly:y})]})}),e.jsx(V,{title:"Application tour",description:"Missed the application onboarding tour or want a refresher? Start it again here.",children:e.jsxs(C,{variant:"secondary",onClick:()=>{O({forceModalCompleted:!0})},children:[e.jsx(ks,{}),"Take the tour"]})}),e.jsx(V,{title:"Model settings",icon:ws,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:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ns,{value:s.values.hosting,isSaving:m==="hosting",onSave:w=>Y("hosting",w),filterByCredentials:!0,allowCustom:!0,allowDefault:!1,emptyHelperText:"No hosting providers available. Add one in API credentials, in the list on the left."}),e.jsx(Cs,{value:s.values.model_name,hostingId:s.values.hosting,isSaving:m==="model_name",onSave:w=>Y("model_name",w),allowCustom:!0,allowDefault:!1}),e.jsx(K,{variant:"neutral",icon:e.jsx(Me,{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, add credentials or sign in to Radient."})]})}),e.jsx(dn,{}),e.jsx(V,{title:"History settings",icon:Ps,description:"Configure how much conversation history is retained and displayed. These are tools to help balance cost and performance by controlling the amount of data used by the agents.",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ae,{value:s.values.conversation_length,label:"Maximum conversation history",description:"Number of messages to keep in conversation history for context. More messages will make the agents have longer memory but more expensive to run. Recommended: 100",min:10,max:500,step:10,unit:"msgs",icon:Ss,isSaving:m==="conversation_length",onChange:w=>Y("conversation_length",w)}),e.jsx(Ae,{value:s.values.detail_length,label:"Detail view length",description:"Maximum number of messages to show in the detailed conversation view. Messages beyond this limit will be summarized. Shortening this will decrease costs but some important details could get lost from earlier messages. Recommended: 15",min:10,max:500,step:5,unit:"msgs",icon:_s,isSaving:m==="detail_length",onChange:w=>Y("detail_length",w)}),e.jsx(Ae,{value:s.values.max_learnings_history,label:"Maximum learnings history",description:"Agents note down specific insights and key learnings in memory which persist beyond the maximum conversation history and summarization. This setting controls the maximum number of learning items to retain. More items will make the agents acquire a longer history of knowledge from your conversations but more expensive to run. Recommended: 50",min:10,max:200,step:10,unit:"notes",icon:As,isSaving:m==="max_learnings_history",onChange:w=>Y("max_learnings_history",w)})]})}),e.jsx(V,{title:"Configuration information",icon:Me,description:"System information about the current configuration.",children:e.jsxs(Oe,{children:[e.jsx(G,{label:"Version",value:e.jsx("span",{className:"text-mono-sm",children:s.version})}),e.jsx(G,{label:"Created",value:Ct(s.metadata.created_at)}),e.jsx(G,{label:"Last modified",value:St(s.metadata.last_modified)}),e.jsx(G,{label:"Description",value:s.metadata.description||"No description available"})]})})]}),e.jsx(V,{title:"Appearance",icon:_t,description:"Customize the look and feel of Local Operator",sectionRef:b.appearance,dataTourTag:"settings-appearance-section",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(pn,{}),e.jsx(ja,{value:t,label:"Show agent reasoning",description:"Adds the agent's Reasoning and Thinking rows to conversations. They stay closed until you open one.",onChange:async w=>a(w)})]})}),e.jsx(V,{title:"Radient account",titleComponent:e.jsx(vn,{}),description:"Manage your Radient account, Radient Pass details, and credits.",sectionRef:b.radient,dataTourTag:"settings-radient-account-section",children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx(ln,{onAfterCredentialUpdate:()=>{T(),E()}}),y&&e.jsxs(e.Fragment,{children:[e.jsx(xn,{}),e.jsx(gn,{})]})]})}),e.jsx(V,{title:"Providers",icon:wt,description:"Model providers, how you sign in to each, and which are connected.",sectionRef:b.providers,children:e.jsx(Es,{initialProviderId:ne})}),e.jsx(V,{title:"Backend settings",icon:Be,description:"Every setting the backend registry owns, searchable, with typed editors and scopes.",sectionRef:b.backend,children:e.jsx(Za,{focusKey:Q,initialFilter:H})}),e.jsx(on,{sessionId:h??void 0,sectionRef:b.integrations,highlightServer:W}),e.jsx(V,{title:"API credentials",icon:Ce,description:"Manage your API keys for various services and integrations",sectionRef:b.credentials,dataTourTag:"settings-api-credentials-section",children:e.jsx(Xa,{})}),e.jsx("div",{ref:b.updates,children:e.jsx(Ta,{})})]})]})})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-canvas p-6",children:e.jsx(K,{variant:"warning",className:"w-full max-w-xl",children:"Your settings could not be loaded."})})};export{Nn as SettingsPage};
|