limixbot 0.3.94 → 0.3.95
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/dist/assets/{ActivityPanel-2Uv233L-.js → ActivityPanel-J4MVvG9f.js} +1 -1
- package/dist/assets/{App-x36HXaXk.js → App-By7OXckm.js} +97 -97
- package/dist/assets/{AppEventEditor-DBKUbaYn.js → AppEventEditor-DlBrDxH2.js} +1 -1
- package/dist/assets/{BotSettingsDialog-DqPzlGjL.js → BotSettingsDialog-VUff16QU.js} +7 -7
- package/dist/assets/{BrowserPanel-DgidHsOC.js → BrowserPanel-52tCZSFu.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-_AtQVsJG.js → BrowserProfilesManager-CwWAa9we.js} +1 -1
- package/dist/assets/{CloudAddDialog-C41Gk9oF.js → CloudAddDialog-MxHM9DWq.js} +1 -1
- package/dist/assets/{ComputerFilesPane-3IWnCxt_.js → ComputerFilesPane-DeBCTY4r.js} +1 -1
- package/dist/assets/{ComputerPanel-B3Cmq78b.js → ComputerPanel-CDz0nCiB.js} +2 -2
- package/dist/assets/{DataPanel-BKinQVdn.js → DataPanel-sFCPVF_d.js} +1 -1
- package/dist/assets/{DesktopViewer-CFD9jFiv.js → DesktopViewer-DQscVlPm.js} +1 -1
- package/dist/assets/{FilesView-LN7pBhGU.js → FilesView-DtfH4eUU.js} +1 -1
- package/dist/assets/{GrokMoveDialog-C-77lJ3M.js → GrokMoveDialog-Ck91Yjog.js} +1 -1
- package/dist/assets/{InspectorPanel-BQ236Bpi.js → InspectorPanel-B9WVkhoH.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-CqtGifvC.js → KeyboardShortcutsModal-BjP8ObLq.js} +1 -1
- package/dist/assets/{LiveDesktop-1diZmS5Q.js → LiveDesktop-FO5Nv55d.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-Byk31r_m.js → LocalVmWorkspace-H9q3ryou.js} +1 -1
- package/dist/assets/MacLocalControl-CNXLIFpC.js +1 -0
- package/dist/assets/{MarkdownFilePreview-B8opDuC0.js → MarkdownFilePreview-DLQfXRfv.js} +1 -1
- package/dist/assets/{MenuMotion-B8impuLz.js → MenuMotion-CSJvuULd.js} +1 -1
- package/dist/assets/{NewBotDialog-_5JxRNIE.js → NewBotDialog-BMLaFM51.js} +1 -1
- package/dist/assets/{PhoneAppDialog-D5oUvyea.js → PhoneAppDialog-BfqeOyj3.js} +1 -1
- package/dist/assets/{PlacesRail-CiZjMESo.js → PlacesRail-Brm8fsgF.js} +1 -1
- package/dist/assets/{PluginsPanel-C7SC_Z-v.js → PluginsPanel-CEvdrIDS.js} +1 -1
- package/dist/assets/{ProIntroduction-Cz7Ugz8r.js → ProIntroduction-CdSIm7BX.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-DutPlaXm.js → RemoteAgentSettingsPanel-DRGICAWQ.js} +1 -1
- package/dist/assets/{RoomPanel-DTaZi2sS.js → RoomPanel-FPYxHj7S.js} +1 -1
- package/dist/assets/{RoutinesPage-ChuBJMsA.js → RoutinesPage-By0ETsiY.js} +2 -2
- package/dist/assets/{SettingsModal-DI-8ogJ0.js → SettingsModal-B7-4LIKY.js} +1 -1
- package/dist/assets/{ShareTeamDialog-4AxslXRQ.js → ShareTeamDialog-BQmgxBYR.js} +1 -1
- package/dist/assets/{SignedInSites-BVCXgsGL.js → SignedInSites-C53EKMiS.js} +1 -1
- package/dist/assets/{TeamLibraryPanel-32Q163aI.js → TeamLibraryPanel-D9Ir2j-q.js} +1 -1
- package/dist/assets/{TeamMapPage-DdSr_Mh7.js → TeamMapPage-DmA7tkUO.js} +1 -1
- package/dist/assets/{TriggersPage-DE7sqwZ3.js → TriggersPage-B49GYrsw.js} +1 -1
- package/dist/assets/VisibilitySection-BNsg8oSc.js +22 -0
- package/dist/assets/{WebhookTrigger-BTpUm74C.js → WebhookTrigger-DN6vz6VS.js} +1 -1
- package/dist/assets/{WorksOnGrid-BR1AkGgh.js → WorksOnGrid-DN5T3LeT.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-BG6Zvjw9.js → abnfDiagram-YUKMZFIV-DoRttvLi.js} +1 -1
- package/dist/assets/{activity-DcfxEVjt.js → activity-B3X77eZy.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-DzW-Knse.js → architectureDiagram-47P4ROYG-DgyQiMsh.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-CGWgFPcE.js → blockDiagram-E7TT5TSB-XcIg_WyI.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-DQvJoyAb.js → c4Diagram-CRA5TL53-Cf9ULajr.js} +1 -1
- package/dist/assets/{calendar-days-B2-WzVnl.js → calendar-days-DJiC7d5N.js} +1 -1
- package/dist/assets/channel-Ca4bkL7d.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-YgXhQbEg.js → chunk-2Q5K7J3B-Ms6ewhuG.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-DZXnS20-.js → chunk-5VM5RSS4-3xKsBIQO.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-D95cf_zs.js → chunk-7TKQ45FW-V0vxoJnE.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-C5JK2WQa.js → chunk-AW2ZBBNX-CSEiSBYb.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-DKalCQBk.js → chunk-FVRAUYC3-BTLbEK9-.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-nvv7NQLW.js → chunk-HTAEGDNF-Cz7QJ3Vu.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CeTFjGtV.js → chunk-JWPE2WC7-Bb9eWA7f.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-DX3Gte27.js → chunk-KQW6MTUR-Ci1frzBO.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-BWJ5gzTu.js → chunk-XXDRQBXY-RuHXoQKx.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-YwtQSAjN.js → classDiagram-v2-K4WV4PDN-J7BPJfMB.js} +1 -1
- package/dist/assets/{coins-C3hB_B7K.js → coins-B9ZW_cYi.js} +1 -1
- package/dist/assets/{core-DwyEAsKw.js → core-CP1Uq40X.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-CPB7hBDW.js → cose-bilkent-JH36ORCC-Cp2H_H00.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-IkJHHknK.js → cynefin-EF2NZ3EQ-BkEGa1Go.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-Bhp5jvZS.js → cynefinDiagram-3GCD6N5R-CI_0J3Kc.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-DvLCU_XA.js → dagre-W4DXFKR2-BK91CYoV.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-DNzMPANw.js → diagram-2UJZ2QOL-Bewf9hsj.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-S2ksvDgW.js → diagram-OVF4WLC6--Vi2lAH7.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-BvFJTyyx.js → diagram-PFPMY2P6-BZ5WcdLX.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-BrcZut9_.js → diagram-UMYRVEAY-BcGF1ttG.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-B5qedD6e.js → diagram-YEKJPTXX-CjJyU38a.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-Rpb-FW8H.js → diagram-ZIFT7M5P-j8ATjVIf.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-DEdk5x8_.js → ebnfDiagram-VR2GEFS7-wffe5avE.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-Bdoe4TZr.js → elk-IJKZMXRS-aVpqTsmb.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-BNLT46ju.js → erDiagram-O2IAPWRE-DLZkqfEx.js} +1 -1
- package/dist/assets/{file-up-Bv2ScEV-.js → file-up-CfsCDs50.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-CNIynYbm.js → flowDiagram-OXPTDLAJ-BKwOwo3C.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-CM6wqlrH.js → ganttDiagram-R7TSEDQI-BPISnHdx.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-C6C9TcuE.js → gitGraphDiagram-XJZIOB7I-I0GFz5Z5.js} +1 -1
- package/dist/assets/{import-name-B-tlhBrM.js → import-name-nIGppkFT.js} +1 -1
- package/dist/assets/{index-DVxCxmdg.js → index-Cp9Q1abg.js} +3 -3
- package/dist/assets/{index-DcZpHpIH.js → index-YKem-EC5.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-BaaazITR.js → infoDiagram-5W2HQ5XZ-jbFQY5gZ.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-B9T0rgEI.js → ishikawaDiagram-K3B6WC7H-Cbc5ifR7.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-Bj_ml-q9.js → journeyDiagram-COXZFDF6-DDEkFqtm.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-DAkZtd0L.js → kanban-definition-P3RFRI5V-B5qwjjgl.js} +1 -1
- package/dist/assets/{mcp-servers-UkbCCVYK.js → mcp-servers-D0zqMiVQ.js} +1 -1
- package/dist/assets/{mermaid.core-BY1tmDJJ.js → mermaid.core-C8QKARvU.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-CWq5YQ9y.js → mindmap-definition-LZFPQGKD-Dp9jU6ZR.js} +1 -1
- package/dist/assets/{minimize-Bx-gtSNG.js → minimize-Mzlis2MZ.js} +1 -1
- package/dist/assets/{monitor-BRnjhHD0.js → monitor-CfU-FlLC.js} +1 -1
- package/dist/assets/{new-bot-BF9YhKLu.js → new-bot-BZiYbrb1.js} +1 -1
- package/dist/assets/{org-library-DGdb4nka.js → org-library-Dw4QxJnf.js} +1 -1
- package/dist/assets/{package-format-BQDuoJ7s.js → package-format-BL8wvrXA.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-BjSQZKNe.js → pegDiagram-BGZESJAR-5vlg2evF.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-C4ZJmod1.js → pieDiagram-CAPJLFHJ-CCNk6BH-.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-BZ6Z2dAs.js → quadrantDiagram-GDMTTRAM-BO6ugSLJ.js} +1 -1
- package/dist/assets/{rail-CiSLAPyO.js → rail-Od7EbgO9.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-CFW50Xlu.js → railroadDiagram-SM67HX2B-BAGy2Nfl.js} +1 -1
- package/dist/assets/{remote-desktop-panel-B1XXcgff.js → remote-desktop-panel-BQazVReg.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-v2F8Rq59.js → requirementDiagram-X7JNWC4A-CbFToNVc.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-BZ_P_XdP.js → sankeyDiagram-UM26HJRW-CMqdsq14.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-DWz7Zxb9.js → sequenceDiagram-ZO4K6R2Y-DGNYl5s6.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CuiIcpz8.js → sizeCapture-INFHLROL-D2kcKHXo.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76--O9KVxBy.js → stateDiagram-v2-TBUQTH76-BmO2PJUl.js} +1 -1
- package/dist/assets/{styles-f5xRqRwH.js → styles-Dw8zvKcg.js} +2 -2
- package/dist/assets/{swimlanes-N4OXWK64-DFXTVms3.js → swimlanes-N4OXWK64-BR_MNkDt.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-XduJM7vj.js +8 -0
- package/dist/assets/{team-share-BisuAXjl.js → team-share-T3rPEp5g.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-C3tqEUxG.js → timeline-definition-YOQAKGHF-Ci8w1eAi.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-CsKwy1_R.js → usecaseDiagram-VIAY4XPW-CYIUN2Kw.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-XVbCuZ_F.js → vennDiagram-BLWOH2XV-COZmFMUh.js} +1 -1
- package/dist/assets/{vi-B5CfHO2y.js → vi-CfrSoDHa.js} +1 -1
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-BMjs1e9T.js → wardleyDiagram-YMQ3BMBF-DG1WFIRz.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-C-rzqqSB.js → xychartDiagram-TAQBALBS-DENrfS9d.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/rail.html +4 -4
- package/dist-server/container-mcp.js +1 -1
- package/dist-server/index.js +1727 -1709
- package/dist-server/package.json +1 -1
- package/dist-server/server/container-computer.js +35 -7
- package/dist-server/server/desktop-updates.js +1 -1
- package/dist-server/server/index.js +35 -7
- package/dist-server/server/routes/vm-working-folder.js +98 -0
- package/dist-server/server/vm-working-folder.js +45 -0
- package/dist-server/server/workspace-backup.js +1 -0
- package/dist-server/vps-container-mcp.js +1 -1
- package/dist-server/workspace-backup.worker.js +5 -5
- package/package.json +1 -1
- package/dist/assets/MacLocalControl-O_QtCEuT.js +0 -1
- package/dist/assets/VisibilitySection-zsv4bW4L.js +0 -22
- package/dist/assets/channel-fCUMmeNn.js +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-DuglGVVz.js +0 -8
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import{c as Ie,t as s,b as se,aF as zs,j as e,i as $e,ae as fe,a as O,r as u,S as Xe,ah as Wt,X as et,f as dt}from"./styles-f5xRqRwH.js";import{fg as Hs,fh as _s,a2 as tt,bB as Ks,dj as Vt,w as Us,fi as qs,fj as Ws,K as Gt,fk as Vs,R as Zt,eu as Gs,x as Zs,fl as pt,bw as mt,fm as Jt,n as Z,u as $,fn as Js,ak as st,F as Yt,A as Qt,S as ye,ag as Ae,T as Xt,W as Ys,fo as Qs,fp as Xs,fq as en,fr as tn,fs as sn,ft as ut,fu as nn,fv as an,fw as rn,fx as on,bc as ln,fy as cn,fz as dn,fA as pn,I as mn,fB as Pe,bR as nt,fC as un,aL as M,aR as ee,ee as xn,dL as hn,fD as fn,aM as Ve,cq as gn,d_ as yn,d$ as bn,fE as vn,fF as es,fG as ts,fH as kn,fI as jn,fJ as wn,fK as Nn,dO as Ge,au as xt,fL as Fe,fM as Sn,fN as Ee,ay as Cn,fO as ss,fP as ht,an as Ze,fQ as Pn,fR as On,fS as En,fT as ns,fU as Rn,fV as Tn,fW as In,fX as An,fY as X,a_ as ne,b0 as Q,fZ as Mn,f_ as Ln,f$ as Bn,d6 as $n,d as Fn,G as Dn,d4 as as,am as zn,g0 as V,aZ as pe,g1 as me,a6 as N,g2 as Hn,dq as _n,g3 as Me,a$ as oe,g4 as Kn,g5 as Un,g6 as qn,ei as Wn,g7 as ft,g8 as Vn,g9 as Gn,ga as Zn,gb as Jn,gc as Yn,gd as Qn,aF as Xn,ge as is,gf as ea,gg as ta,gh as sa,gi as na,gj as aa,gk as ia,gl as ra,gm as oa,gn as la,go as ca,gp as da,gq as pa,gr as at,k as ma,B as Je,gs as ua,gt as xa,gu as ha,gv as fa,b_ as ga,gw as rs,J as gt,eY as ya,gx as yt,gy as ba,gz as va,cN as bt,bz as ka,d3 as ja,gA as wa,gB as os,gC as Se,gD as vt,gE as Na,aP as De,e0 as Sa,gF as Ca,aU as Pa,C as Oa,cr as Ea,gG as Ra,gH as Ta,gI as Ia,aW as Aa}from"./App-x36HXaXk.js";import{v as ls,d as je,a1 as Re,a2 as Ma,a3 as La,a4 as kt,a5 as ze,a6 as Ba,a7 as $a,a8 as Fa,a9 as Da,aa as za,ab as jt,ac as Ha,ad as _a,L as Oe,N as Ka,B as Ye,P as we,r as cs,ae as Ua,a0 as qa,u as ds}from"./PlacesRail-CiZjMESo.js";import{C as Wa}from"./coins-C3hB_B7K.js";import{C as ke,a as Va}from"./MenuMotion-B8impuLz.js";import{b as te,m as ps,i as Qe,f as it,c as he,d as wt,e as Te,o as Ga,g as Za,h as de,n as He,t as ms,s as rt,j as us,k as Ja,l as Ya,p as Qa,r as xs,q as Xa,u as ei,w as ti,x as hs,y as fs,z as Nt,B as si,C as gs,R as St,D as ni,E as ai,F as ii,G as ri,H as oi,J as li,O as ci,K as di,L as ys,N as Ct,V as pi,P as mi,M as ui,A as xi,a as hi,S as fi,I as gi}from"./VisibilitySection-zsv4bW4L.js";import{s as yi,r as bi,a as vi,R as ki}from"./ComputerFilesPane-3IWnCxt_.js";import{M as Pt}from"./monitor-BRnjhHD0.js";import{a as bs,m as vs,b as ji,c as wi}from"./mcp-servers-UkbCCVYK.js";import{R as Ni}from"./RoutinesPage-ChuBJMsA.js";import{S as Si}from"./SignedInSites-BVCXgsGL.js";import"./index-DVxCxmdg.js";import"./org-library-DGdb4nka.js";import"./package-format-BQDuoJ7s.js";import"./WorksOnGrid-BR1AkGgh.js";import"./ProIntroduction-Cz7Ugz8r.js";import"./remote-desktop-DDRRx8uY.js";const Ci=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],Pi=Ie("calendar-plus",Ci);const Oi=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Ei=Ie("library",Oi);const Ri=[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]],ks=Ie("slack",Ri);const Ti=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Ii=Ie("tag",Ti),Ai=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:Hs,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:_s,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ks,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:tt,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Ks,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Vt,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Ei,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Us,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:qs,keywords:["works on","computer","vm","cloud","vps","folder","workspace","browser","connected apps","composio","webhooks","always allow","grants","tool selection","tools","mcp","allow","exclude"]},{id:"model",label:"Model",labelKey:"botSettings.sections.model",icon:Ws,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:Gt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Vs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Zt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:Gs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Wa,keywords:["tokens","cost","billing"]}],Ot={completed:"botOverview.routine.last.completed",failed:"botOverview.routine.last.failed",missed:"botOverview.routine.last.missed",cancelled:"botOverview.routine.last.cancelled",running:"botOverview.routine.last.running",queued:"botOverview.routine.last.queued",waiting:"botOverview.routine.last.waiting"};function Mi(t,n=se()){if(!t||n==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const a=t.lastRun;if(a&&!Object.hasOwn(Ot,a.status))return null;try{return[s("botOverview.routine.line",{schedule:Zs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:pt(t.nextRunAt)})]:[],...a?[s(Ot[a.status],{time:pt(a.at)})]:[]].join(" ")}catch{return null}}const Et={"Works in its private workspace.":"botOverview.line.privateWorkspace","Has the built-in browser.":"botOverview.line.browser","Has no connected apps.":"botOverview.line.noApps","Won't act on a schedule.":"botOverview.line.noSchedule","Can talk to the other bot.":"botOverview.line.talksToOne","Talks only to the bots chosen for it.":"botOverview.line.talksToChosen","Cannot initiate contact with other bots.":"botOverview.line.noPeerContact","Command approvals use Ask mode; saved permissions and provider rules still apply.":"botOverview.line.askMode","Command approvals follow the provider's custom configuration.":"botOverview.line.customApprovals","Asks before contacting other bots.":"botOverview.line.asksPeers","Can't use a computer.":"botOverview.line.noComputer","Profile proposal cards require your approval.":"botOverview.line.profileApproval","Connected apps could not be checked.":"botOverview.line.appsUnchecked"},Rt={"Auto; availability is checked when a task starts":"botOverview.preference.auto","cloud computer":"botOverview.preference.cloud","Local VM":"botOverview.preference.vm","this computer":"botOverview.preference.local","browser only":"botOverview.preference.browser"};function Tt(t,n){return!n||n.map(a=>a||"General").join(", ")!==t?t:n.map(a=>a||s("botAccess.teams.general")).join(", ")}const It=t=>Object.hasOwn(Rt,t)?s(Rt[t]):t,At=(t,n,a)=>Number(t)===1?n:a,Li=[{line:/^Can talk to all (\d+) other bots, in any department\.$/,key:()=>"botOverview.line.talksToAll",params:([,t])=>({count:Number(t)})},{line:/^Also in charge of these departments: (.+)\.$/,key:()=>"botOverview.line.alsoInCharge",params:([,t],n)=>({departments:Tt(t,n)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>At(t,"botOverview.line.peersSectionOne","botOverview.line.peersSectionMany"),params:([,t])=>({count:Number(t)})},{line:/^Can talk to (\d+) other bots? in its allowed (?:teams|departments)\.$/,key:([,t])=>At(t,"botOverview.line.peersTeamsOne","botOverview.line.peersTeamsMany"),params:([,t])=>({count:Number(t)})},{line:/^Coordinates its (?:section|department) as Chief of Staff\.$/,key:()=>"botOverview.line.chief",params:()=>({role:s("sidebar.bot.chiefOfStaff")})},{line:/^May also coordinate these (?:teams|departments): (.+)\.$/,key:()=>"botOverview.line.alsoTeams",params:([,t],n)=>({teams:Tt(t,n)})}],Bi=t=>se()!=="en"&&Object.hasOwn(zs[se()]??{},t);function $i(t,n){for(const a of Li){const l=a.line.exec(t);if(!l)continue;const i=a.key(l);return Bi(i)?s(i,a.params(l,n)):t}return null}function _e(t,n){if(Object.hasOwn(Et,t))return s(Et[t]);const a=$i(t,n);if(a!==null)return a;const l=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(l)return s(l[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(l[1]),apps:l[2]});const i=se()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(i)return s("botOverview.line.computerNotOnCloud",{preference:It(i[1])});const o=/^Computer preference: (.+)\.$/.exec(t);if(o)return s("botOverview.line.computer",{preference:It(o[1])});const d=/^Works in (.+)\.$/.exec(t);if(d)return s("botOverview.line.folder",{folder:d[1]});const m=/^Knows how to (.+)\.$/.exec(t);if(m)return s("botOverview.line.skill",{skill:m[1]});const r=/^Listens for “(.+)” webhooks\.$/.exec(t);return r?s("botOverview.line.webhook",{name:r[1]}):t}const Mt={name:"approval.applied.field.name",title:"approval.applied.field.title",description:"approval.applied.field.description",soul:"approval.applied.field.soul",cwd:"approval.applied.field.cwd",notifications:"approval.applied.field.notifications",speakReplies:"approval.applied.field.speakReplies"};function Fi(t,n=se()){const a=/^(\w+): /.exec(t)?.[1];return n==="en"||!a||!Object.hasOwn(Mt,a)?t:`${s(Mt[a])}: ${t.slice(a.length+2)}`}function Di({data:t,error:n,open:a,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":a,className:"flex w-full items-center justify-between gap-3 text-left",children:[e.jsx("span",{className:"text-[15px] font-medium text-ink",children:t?s("botOverview.promptPreviewCount",{bytes:t.totalBytes.toLocaleString($e()),tokens:t.approxTokens.toLocaleString($e())}):s("botOverview.promptPreview")}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",a&&"rotate-180")})]}),a&&!t&&n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),a&&!t&&!n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),a&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(i=>e.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:i.bytes.toLocaleString($e())})})]}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:i.text})]},i.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function zi({overview:t,refreshError:n,prompt:a,promptError:l,onOpen:i,onSetup:o}){const[d,m]=u.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const c=(t.setup??[]).filter(f=>!f.done),p=(f,k)=>s(`botOverview.setup.${f}`)||k;return e.jsxs("div",{className:"flex flex-col gap-4",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),c.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botSetup.ideas")}),e.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:s("botSetup.optional")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:c.map(f=>e.jsx("li",{children:f.section?e.jsxs("button",{type:"button",onClick:()=>i(f.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:p(f.id,f.label)}),e.jsx(ke,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-secondary rtl:-scale-x-100"})]}):e.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:p(f.id,f.label)})]})},f.id))}),o&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(tt,{size:14})," ",s("botSetup.withBot")]}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("botSetup.help")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:t.who.name}),t.who.title&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:t.who.title}),t.who.blurb&&e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:t.who.blurb}),t.who.soulLead&&e.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:t.who.soulLead}),e.jsx("button",{type:"button",onClick:()=>i("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:s("botOverview.readAll")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.does")}),t.does.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.doesEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.does.map((f,k)=>e.jsx("li",{children:Mi(t.doesRoutines?.[k])??_e(f)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsx(Di,{data:a,error:l,open:d,onToggle:()=>m(f=>!f)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>i("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ke,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((f,k)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Fi(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Jt(f.at)]})]},k))})]})]})}function Hi({managementUrl:t}){return e.jsxs("div",{className:"flex flex-col gap-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx("p",{children:s("botSlack.body")}),e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-2 rounded-lg bg-control px-3 py-2 font-medium text-ink hover:bg-control/70",children:[s("botSlack.manage")," ",e.jsx(ls,{size:14,"aria-hidden":"true"})]})]})}function _i(t){if(!t||typeof t!="object")return null;const{available:n,managementUrl:a}=t;if(n!==!0||typeof a!="string")return null;try{return new URL(a).protocol==="https:"?a:null}catch{return null}}function js(t){const[n,a]=u.useState(null);return u.useEffect(()=>{const l=new AbortController;return Z(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(i=>{l.signal.aborted||a({botId:t,url:_i(i)})}).catch(()=>{l.signal.aborted||a({botId:t,url:null})}),()=>l.abort()},[t]),n?.botId===t?n.url:null}const re="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Ke="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ae=t=>t instanceof Error?t.message:String(t);function ws(t){const n=[],a=(i,o,d)=>{i&&n.push(s(i===1?o:d,{count:i}))};a(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),a(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),a(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),a(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=n.length?n.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Ki(t,n){const a=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?n:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=Xa(t.path),i=t.path===te?l:t.path===ei?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),o=d=>s(d===1?"memory.journal.line.one":"memory.journal.line.many",{count:d});return t.kind==="created"?s("memory.journal.created",{who:a,topic:i,detail:t.added?s("memory.journal.withLines",{lines:o(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:a,topic:i}):t.added&&!t.removed?s("memory.journal.added",{who:a,lines:o(t.added),topic:i}):t.removed&&!t.added?s("memory.journal.removed",{who:a,lines:o(t.removed),topic:i}):s("memory.journal.rewrote",{who:a,lines:o(Math.max(t.added,t.removed)),topic:i})}function Ns({changed:t,stale:n,busy:a,onReviewed:l}){return e.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s(n?"memory.lendingReviewStale":"memory.lendingReview")}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.lendingReviewChanged")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(i=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:i},i))})]}),e.jsx("button",{type:"button",className:O(re,"mt-3"),disabled:a,onClick:l,children:s("memory.lendingReviewed")})]})}function Ui({bot:t,active:n=!0,onToggle:a}){const{capabilities:l}=je(),[i,o]=u.useState(null),[d,m]=u.useState(null),[r,c]=u.useState(null),[p,f]=u.useState(null),[k,g]=u.useState(null),[v,j]=u.useState(null),[P,b]=u.useState(null),[w,x]=u.useState(!1),[C,L]=u.useState(null),[D,B]=u.useState(""),[I,H]=u.useState(null),[A,h]=u.useState(!1),[T,F]=u.useState(null),[_,K]=u.useState(!1),[Y,J]=u.useState(!1),{state:U,dispatch:y}=$(),z=Js(U.config),[le,ue]=u.useState(!1),[ge,E]=u.useState(""),q=async S=>{const[R,Le,Ds]=await Promise.all([it(t.id),he(t.id),wt(t.id).catch(()=>null)]);if(o(R),F(R.lendingReview??null),m(Le),H(Ds),S){const Be=await Te(t.id,S);c({path:Be.path,text:Be.text,hash:Be.hash,dirty:!1,readOnly:S.startsWith("memory/log/")})}};u.useEffect(()=>{if(!n)return;let S=!1;j(null);const R=r?.dirty===!0;return q(R?void 0:r?.path??te).catch(Le=>{S||j(ae(Le))}),()=>{S=!0}},[n,t.id]);const G=async S=>{j(null),f(null);try{const R=await Te(t.id,S);c({path:R.path,text:R.text,hash:R.hash,dirty:!1,readOnly:S.startsWith("memory/log/")})}catch(R){j(ae(R))}},W=async S=>{if(r){x(!0),j(null);try{const R=await rt(t.id,r.path,r.text,S);if(!R.ok){f({path:r.path,current:R.current,currentHash:R.currentHash});return}f(null),g(null),c({...r,text:R.doc.text,hash:R.doc.hash,dirty:!1}),o(R.overview),m(await he(t.id))}catch(R){j(ae(R))}finally{x(!1)}}},ce=()=>{!p||!r||(g(r.text),c({...r,text:p.current,hash:p.currentHash,dirty:!1}),f(null))},Ne=async S=>{if(window.confirm(s("memory.confirmDelete",{name:S.name}))){j(null);try{const{overview:R}=await us(t.id,S.path);o(R),m(await he(t.id)),r?.path===S.path&&c(null)}catch(R){j(ae(R))}}},lt=async()=>{const S=Ja(D);if(!S){j(s("memory.topicNameError"));return}B(""),await G(`memory/${S}`),c(R=>R&&{...R,dirty:!0,text:R.text||qi(S)})},Ms=async S=>{L(S.id),j(null);try{const R=await xs(t.id,S.id);o(R.overview),m(await he(t.id)),r?.path===S.path&&!r.dirty&&c({...r,text:R.text,hash:R.hash}),b(s("memory.restored",{path:S.path}))}catch(R){j(ae(R))}finally{L(null)}},ct=async S=>{j(null),b(null);try{await Ga(t.id,S)}catch(R){j(ae(R))}},Ls=()=>{const S=t.memoryUpkeep===!1;y({type:"updateBot",botId:t.id,patch:{memoryUpkeep:S}}),H(R=>R&&{...R,enabled:S})},Bs=async()=>{if(!le){ue(!0),E("");try{const S=await Z("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!z}})});y({type:"configStatus",config:S})}catch(S){E(S instanceof Error?S.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},$s=async()=>{h(!0),j(null),b(null);try{const{report:S,overview:R}=await ms(t.id);o(R),m(await he(t.id)),H(await wt(t.id)),r&&!r.dirty&&await G(r.path),b(`${ws(S)}.${S.note?` ${S.note}`:""}`)}catch(S){j(ae(S))}finally{h(!1)}},Fs=l.host.homeDir;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.title")}),e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.memoryEnabled!==!1,disabled:t.busy,onChange:S=>a(S.target.checked)}),s("memory.enable")]}),e.jsxs("p",{className:"mt-1 text-[13px] text-ink-secondary",children:[s("memory.enableHelp"),t.busy?` ${s("memory.busyHelp")}`:""]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.notesHelp")}),i&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:i.workspacePath,children:st(i.workspacePath,Fs)}),e.jsx("button",{type:"button",className:re,onClick:()=>{ct("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(re,"inline-flex items-center gap-1.5"),onClick:()=>{ct("folder")},children:[e.jsx(Yt,{size:14}),s("memory.showFileManager")]})]})]}),T&&e.jsx(Ns,{changed:T.changed,stale:_,busy:Y,onReviewed:()=>{J(!0),ps(t.id,T.token).then(()=>{F(null),K(!1)}).catch(S=>{if(S instanceof Qt&&S.status===409)return K(!0),q();j(ae(S))}).finally(()=>J(!1))}}),i&&e.jsx(Vi,{index:i.index}),t.memoryEnabled!==!1&&e.jsx(Wi,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:Ls,onTidy:()=>{$s()},rooms:{enabled:z,saving:le,error:ge,onToggle:()=>{Bs()}}}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:r.path}),r.path!==te&&e.jsx("button",{type:"button",className:Ke,onClick:()=>{G(te)},children:s("memory.backToIndex")})]}),p&&e.jsx(Ss,{botName:t.name,busy:w,onReload:ce,onOverwrite:()=>{W(p.currentHash)}}),e.jsx("textarea",{className:O(Qe,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:r.text,readOnly:r.readOnly,placeholder:r.path===te?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":r.path===te?s("memory.botMemory"):s("memory.fileLabel",{path:r.path}),onChange:S=>c({...r,text:S.target.value,dirty:!0})}),r.readOnly?e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.logsReadOnly")}):e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{W(r.hash)},disabled:w||!r.dirty,className:re,children:w?s("memory.saving"):s("memory.save")}),r.dirty&&e.jsx("button",{type:"button",className:Ke,disabled:w,onClick:()=>{G(r.path)},children:s("memory.discard")})]}),k!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:k}),e.jsx("button",{type:"button",className:O(Ke,"mt-1"),onClick:()=>g(null),children:s("memory.dismissDraft")})]})]}),i&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Bt,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:i.topics,selected:r?.path,onOpen:S=>{G(S.path)},onDelete:S=>{Ne(S)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(Qe,"py-1.5 text-[13px]"),value:D,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:S=>B(S.target.value),onKeyDown:S=>{S.key==="Enter"&<()}}),e.jsx("button",{type:"button",className:re,disabled:!D.trim(),onClick:()=>{lt()},children:s("memory.newTopic")})]}),i.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Bt,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:i.logs,selected:r?.path,onOpen:S=>{G(S.path)},onDelete:S=>{Ne(S)}})})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.changes")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.changesHelp")}),e.jsx("div",{className:"mt-3",children:e.jsx(ot,{rows:d,botName:t.name,reverting:C,onRevert:S=>{Ms(S)}})})]}),P&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:P}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function qi(t){return`---
|
|
1
|
+
import{c as Ie,t as s,b as se,aF as zs,j as e,i as $e,ae as fe,a as O,r as u,S as Xe,ah as Wt,X as et,f as dt}from"./styles-Dw8zvKcg.js";import{fg as Hs,fh as _s,a2 as tt,bB as Ks,dj as Vt,w as Us,fi as qs,fj as Ws,K as Gt,fk as Vs,R as Zt,eu as Gs,x as Zs,fl as pt,bw as mt,fm as Jt,n as Z,u as $,fn as Js,ak as st,F as Yt,A as Qt,S as ye,ag as Ae,T as Xt,W as Ys,fo as Qs,fp as Xs,fq as en,fr as tn,fs as sn,ft as ut,fu as nn,fv as an,fw as rn,fx as on,bc as ln,fy as cn,fz as dn,fA as pn,I as mn,fB as Pe,bR as nt,fC as un,aL as M,aR as ee,ee as xn,dL as hn,fD as fn,aM as Ve,cq as gn,d_ as yn,d$ as bn,fE as vn,fF as es,fG as ts,fH as kn,fI as jn,fJ as wn,fK as Nn,dO as Ge,au as xt,fL as Fe,fM as Sn,fN as Ee,ay as Cn,fO as ss,fP as ht,an as Ze,fQ as Pn,fR as On,fS as En,fT as ns,fU as Rn,fV as Tn,fW as In,fX as An,fY as X,a_ as ne,b0 as Q,fZ as Mn,f_ as Ln,f$ as Bn,d6 as $n,d as Fn,G as Dn,d4 as as,am as zn,g0 as V,aZ as pe,g1 as me,a6 as N,g2 as Hn,dq as _n,g3 as Me,a$ as oe,g4 as Kn,g5 as Un,g6 as qn,ei as Wn,g7 as ft,g8 as Vn,g9 as Gn,ga as Zn,gb as Jn,gc as Yn,gd as Qn,aF as Xn,ge as is,gf as ea,gg as ta,gh as sa,gi as na,gj as aa,gk as ia,gl as ra,gm as oa,gn as la,go as ca,gp as da,gq as pa,gr as at,k as ma,B as Je,gs as ua,gt as xa,gu as ha,gv as fa,gw as ga,b_ as ya,gx as rs,J as gt,eY as ba,gy as yt,gz as va,gA as ka,cN as bt,bz as ja,d3 as wa,gB as Na,gC as os,gD as Se,gE as vt,gF as Sa,aP as De,e0 as Ca,gG as Pa,aU as Oa,C as Ea,cr as Ra,gH as Ta,gI as Ia,gJ as Aa,aW as Ma}from"./App-By7OXckm.js";import{v as ls,d as je,a1 as Re,a2 as La,a3 as Ba,a4 as kt,a5 as ze,a6 as $a,a7 as Fa,a8 as Da,a9 as za,aa as Ha,ab as jt,ac as _a,ad as Ka,L as Oe,N as Ua,B as Ye,P as we,r as cs,ae as qa,a0 as Wa,u as ds}from"./PlacesRail-Brm8fsgF.js";import{C as Va}from"./coins-B9ZW_cYi.js";import{C as ke,a as Ga}from"./MenuMotion-CSJvuULd.js";import{b as te,m as ps,i as Qe,f as it,c as he,d as wt,e as Te,o as Za,g as Ja,h as de,n as He,t as ms,s as rt,j as us,k as Ya,l as Qa,p as Xa,r as xs,q as ei,u as ti,w as si,x as hs,y as fs,z as Nt,B as ni,C as gs,R as St,D as ai,E as ii,F as ri,G as oi,H as li,J as ci,O as di,K as pi,L as ys,N as Ct,V as mi,P as ui,M as xi,A as hi,a as fi,S as gi,I as yi}from"./VisibilitySection-BNsg8oSc.js";import{s as bi,r as vi,a as ki,R as ji}from"./ComputerFilesPane-DeBCTY4r.js";import{M as Pt}from"./monitor-CfU-FlLC.js";import{a as bs,m as vs,b as wi,c as Ni}from"./mcp-servers-D0zqMiVQ.js";import{R as Si}from"./RoutinesPage-By0ETsiY.js";import{S as Ci}from"./SignedInSites-C53EKMiS.js";import"./index-Cp9Q1abg.js";import"./org-library-Dw4QxJnf.js";import"./package-format-BL8wvrXA.js";import"./WorksOnGrid-DN5T3LeT.js";import"./ProIntroduction-CdSIm7BX.js";import"./remote-desktop-DDRRx8uY.js";const Pi=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],Oi=Ie("calendar-plus",Pi);const Ei=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Ri=Ie("library",Ei);const Ti=[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]],ks=Ie("slack",Ti);const Ii=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Ai=Ie("tag",Ii),Mi=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:Hs,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:_s,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ks,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:tt,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Ks,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Vt,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Ri,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Us,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:qs,keywords:["works on","computer","vm","cloud","vps","folder","workspace","browser","connected apps","composio","webhooks","always allow","grants","tool selection","tools","mcp","allow","exclude"]},{id:"model",label:"Model",labelKey:"botSettings.sections.model",icon:Ws,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:Gt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Vs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Zt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:Gs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Va,keywords:["tokens","cost","billing"]}],Ot={completed:"botOverview.routine.last.completed",failed:"botOverview.routine.last.failed",missed:"botOverview.routine.last.missed",cancelled:"botOverview.routine.last.cancelled",running:"botOverview.routine.last.running",queued:"botOverview.routine.last.queued",waiting:"botOverview.routine.last.waiting"};function Li(t,n=se()){if(!t||n==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const a=t.lastRun;if(a&&!Object.hasOwn(Ot,a.status))return null;try{return[s("botOverview.routine.line",{schedule:Zs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:pt(t.nextRunAt)})]:[],...a?[s(Ot[a.status],{time:pt(a.at)})]:[]].join(" ")}catch{return null}}const Et={"Works in its private workspace.":"botOverview.line.privateWorkspace","Has the built-in browser.":"botOverview.line.browser","Has no connected apps.":"botOverview.line.noApps","Won't act on a schedule.":"botOverview.line.noSchedule","Can talk to the other bot.":"botOverview.line.talksToOne","Talks only to the bots chosen for it.":"botOverview.line.talksToChosen","Cannot initiate contact with other bots.":"botOverview.line.noPeerContact","Command approvals use Ask mode; saved permissions and provider rules still apply.":"botOverview.line.askMode","Command approvals follow the provider's custom configuration.":"botOverview.line.customApprovals","Asks before contacting other bots.":"botOverview.line.asksPeers","Can't use a computer.":"botOverview.line.noComputer","Profile proposal cards require your approval.":"botOverview.line.profileApproval","Connected apps could not be checked.":"botOverview.line.appsUnchecked"},Rt={"Auto; availability is checked when a task starts":"botOverview.preference.auto","cloud computer":"botOverview.preference.cloud","Local VM":"botOverview.preference.vm","this computer":"botOverview.preference.local","browser only":"botOverview.preference.browser"};function Tt(t,n){return!n||n.map(a=>a||"General").join(", ")!==t?t:n.map(a=>a||s("botAccess.teams.general")).join(", ")}const It=t=>Object.hasOwn(Rt,t)?s(Rt[t]):t,At=(t,n,a)=>Number(t)===1?n:a,Bi=[{line:/^Can talk to all (\d+) other bots, in any department\.$/,key:()=>"botOverview.line.talksToAll",params:([,t])=>({count:Number(t)})},{line:/^Also in charge of these departments: (.+)\.$/,key:()=>"botOverview.line.alsoInCharge",params:([,t],n)=>({departments:Tt(t,n)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>At(t,"botOverview.line.peersSectionOne","botOverview.line.peersSectionMany"),params:([,t])=>({count:Number(t)})},{line:/^Can talk to (\d+) other bots? in its allowed (?:teams|departments)\.$/,key:([,t])=>At(t,"botOverview.line.peersTeamsOne","botOverview.line.peersTeamsMany"),params:([,t])=>({count:Number(t)})},{line:/^Coordinates its (?:section|department) as Chief of Staff\.$/,key:()=>"botOverview.line.chief",params:()=>({role:s("sidebar.bot.chiefOfStaff")})},{line:/^May also coordinate these (?:teams|departments): (.+)\.$/,key:()=>"botOverview.line.alsoTeams",params:([,t],n)=>({teams:Tt(t,n)})}],$i=t=>se()!=="en"&&Object.hasOwn(zs[se()]??{},t);function Fi(t,n){for(const a of Bi){const l=a.line.exec(t);if(!l)continue;const i=a.key(l);return $i(i)?s(i,a.params(l,n)):t}return null}function _e(t,n){if(Object.hasOwn(Et,t))return s(Et[t]);const a=Fi(t,n);if(a!==null)return a;const l=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(l)return s(l[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(l[1]),apps:l[2]});const i=se()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(i)return s("botOverview.line.computerNotOnCloud",{preference:It(i[1])});const o=/^Computer preference: (.+)\.$/.exec(t);if(o)return s("botOverview.line.computer",{preference:It(o[1])});const d=/^Works in (.+)\.$/.exec(t);if(d)return s("botOverview.line.folder",{folder:d[1]});const m=/^Knows how to (.+)\.$/.exec(t);if(m)return s("botOverview.line.skill",{skill:m[1]});const r=/^Listens for “(.+)” webhooks\.$/.exec(t);return r?s("botOverview.line.webhook",{name:r[1]}):t}const Mt={name:"approval.applied.field.name",title:"approval.applied.field.title",description:"approval.applied.field.description",soul:"approval.applied.field.soul",cwd:"approval.applied.field.cwd",notifications:"approval.applied.field.notifications",speakReplies:"approval.applied.field.speakReplies"};function Di(t,n=se()){const a=/^(\w+): /.exec(t)?.[1];return n==="en"||!a||!Object.hasOwn(Mt,a)?t:`${s(Mt[a])}: ${t.slice(a.length+2)}`}function zi({data:t,error:n,open:a,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":a,className:"flex w-full items-center justify-between gap-3 text-left",children:[e.jsx("span",{className:"text-[15px] font-medium text-ink",children:t?s("botOverview.promptPreviewCount",{bytes:t.totalBytes.toLocaleString($e()),tokens:t.approxTokens.toLocaleString($e())}):s("botOverview.promptPreview")}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",a&&"rotate-180")})]}),a&&!t&&n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),a&&!t&&!n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),a&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(i=>e.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:i.bytes.toLocaleString($e())})})]}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:i.text})]},i.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function Hi({overview:t,refreshError:n,prompt:a,promptError:l,onOpen:i,onSetup:o}){const[d,m]=u.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const c=(t.setup??[]).filter(f=>!f.done),p=(f,k)=>s(`botOverview.setup.${f}`)||k;return e.jsxs("div",{className:"flex flex-col gap-4",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),c.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botSetup.ideas")}),e.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:s("botSetup.optional")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:c.map(f=>e.jsx("li",{children:f.section?e.jsxs("button",{type:"button",onClick:()=>i(f.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:p(f.id,f.label)}),e.jsx(ke,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-secondary rtl:-scale-x-100"})]}):e.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:p(f.id,f.label)})]})},f.id))}),o&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(tt,{size:14})," ",s("botSetup.withBot")]}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("botSetup.help")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:t.who.name}),t.who.title&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:t.who.title}),t.who.blurb&&e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:t.who.blurb}),t.who.soulLead&&e.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:t.who.soulLead}),e.jsx("button",{type:"button",onClick:()=>i("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:s("botOverview.readAll")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.does")}),t.does.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.doesEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.does.map((f,k)=>e.jsx("li",{children:Li(t.doesRoutines?.[k])??_e(f)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsx(zi,{data:a,error:l,open:d,onToggle:()=>m(f=>!f)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>i("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ke,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((f,k)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Di(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Jt(f.at)]})]},k))})]})]})}function _i({managementUrl:t}){return e.jsxs("div",{className:"flex flex-col gap-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx("p",{children:s("botSlack.body")}),e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-2 rounded-lg bg-control px-3 py-2 font-medium text-ink hover:bg-control/70",children:[s("botSlack.manage")," ",e.jsx(ls,{size:14,"aria-hidden":"true"})]})]})}function Ki(t){if(!t||typeof t!="object")return null;const{available:n,managementUrl:a}=t;if(n!==!0||typeof a!="string")return null;try{return new URL(a).protocol==="https:"?a:null}catch{return null}}function js(t){const[n,a]=u.useState(null);return u.useEffect(()=>{const l=new AbortController;return Z(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(i=>{l.signal.aborted||a({botId:t,url:Ki(i)})}).catch(()=>{l.signal.aborted||a({botId:t,url:null})}),()=>l.abort()},[t]),n?.botId===t?n.url:null}const re="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Ke="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ae=t=>t instanceof Error?t.message:String(t);function ws(t){const n=[],a=(i,o,d)=>{i&&n.push(s(i===1?o:d,{count:i}))};a(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),a(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),a(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),a(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=n.length?n.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Ui(t,n){const a=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?n:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=ei(t.path),i=t.path===te?l:t.path===ti?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),o=d=>s(d===1?"memory.journal.line.one":"memory.journal.line.many",{count:d});return t.kind==="created"?s("memory.journal.created",{who:a,topic:i,detail:t.added?s("memory.journal.withLines",{lines:o(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:a,topic:i}):t.added&&!t.removed?s("memory.journal.added",{who:a,lines:o(t.added),topic:i}):t.removed&&!t.added?s("memory.journal.removed",{who:a,lines:o(t.removed),topic:i}):s("memory.journal.rewrote",{who:a,lines:o(Math.max(t.added,t.removed)),topic:i})}function Ns({changed:t,stale:n,busy:a,onReviewed:l}){return e.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s(n?"memory.lendingReviewStale":"memory.lendingReview")}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.lendingReviewChanged")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(i=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:i},i))})]}),e.jsx("button",{type:"button",className:O(re,"mt-3"),disabled:a,onClick:l,children:s("memory.lendingReviewed")})]})}function qi({bot:t,active:n=!0,onToggle:a}){const{capabilities:l}=je(),[i,o]=u.useState(null),[d,m]=u.useState(null),[r,c]=u.useState(null),[p,f]=u.useState(null),[k,g]=u.useState(null),[v,j]=u.useState(null),[P,b]=u.useState(null),[w,x]=u.useState(!1),[C,L]=u.useState(null),[D,B]=u.useState(""),[I,H]=u.useState(null),[A,h]=u.useState(!1),[T,F]=u.useState(null),[_,K]=u.useState(!1),[Y,J]=u.useState(!1),{state:U,dispatch:y}=$(),z=Js(U.config),[le,ue]=u.useState(!1),[ge,E]=u.useState(""),q=async S=>{const[R,Le,Ds]=await Promise.all([it(t.id),he(t.id),wt(t.id).catch(()=>null)]);if(o(R),F(R.lendingReview??null),m(Le),H(Ds),S){const Be=await Te(t.id,S);c({path:Be.path,text:Be.text,hash:Be.hash,dirty:!1,readOnly:S.startsWith("memory/log/")})}};u.useEffect(()=>{if(!n)return;let S=!1;j(null);const R=r?.dirty===!0;return q(R?void 0:r?.path??te).catch(Le=>{S||j(ae(Le))}),()=>{S=!0}},[n,t.id]);const G=async S=>{j(null),f(null);try{const R=await Te(t.id,S);c({path:R.path,text:R.text,hash:R.hash,dirty:!1,readOnly:S.startsWith("memory/log/")})}catch(R){j(ae(R))}},W=async S=>{if(r){x(!0),j(null);try{const R=await rt(t.id,r.path,r.text,S);if(!R.ok){f({path:r.path,current:R.current,currentHash:R.currentHash});return}f(null),g(null),c({...r,text:R.doc.text,hash:R.doc.hash,dirty:!1}),o(R.overview),m(await he(t.id))}catch(R){j(ae(R))}finally{x(!1)}}},ce=()=>{!p||!r||(g(r.text),c({...r,text:p.current,hash:p.currentHash,dirty:!1}),f(null))},Ne=async S=>{if(window.confirm(s("memory.confirmDelete",{name:S.name}))){j(null);try{const{overview:R}=await us(t.id,S.path);o(R),m(await he(t.id)),r?.path===S.path&&c(null)}catch(R){j(ae(R))}}},lt=async()=>{const S=Ya(D);if(!S){j(s("memory.topicNameError"));return}B(""),await G(`memory/${S}`),c(R=>R&&{...R,dirty:!0,text:R.text||Wi(S)})},Ms=async S=>{L(S.id),j(null);try{const R=await xs(t.id,S.id);o(R.overview),m(await he(t.id)),r?.path===S.path&&!r.dirty&&c({...r,text:R.text,hash:R.hash}),b(s("memory.restored",{path:S.path}))}catch(R){j(ae(R))}finally{L(null)}},ct=async S=>{j(null),b(null);try{await Za(t.id,S)}catch(R){j(ae(R))}},Ls=()=>{const S=t.memoryUpkeep===!1;y({type:"updateBot",botId:t.id,patch:{memoryUpkeep:S}}),H(R=>R&&{...R,enabled:S})},Bs=async()=>{if(!le){ue(!0),E("");try{const S=await Z("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!z}})});y({type:"configStatus",config:S})}catch(S){E(S instanceof Error?S.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},$s=async()=>{h(!0),j(null),b(null);try{const{report:S,overview:R}=await ms(t.id);o(R),m(await he(t.id)),H(await wt(t.id)),r&&!r.dirty&&await G(r.path),b(`${ws(S)}.${S.note?` ${S.note}`:""}`)}catch(S){j(ae(S))}finally{h(!1)}},Fs=l.host.homeDir;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.title")}),e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.memoryEnabled!==!1,disabled:t.busy,onChange:S=>a(S.target.checked)}),s("memory.enable")]}),e.jsxs("p",{className:"mt-1 text-[13px] text-ink-secondary",children:[s("memory.enableHelp"),t.busy?` ${s("memory.busyHelp")}`:""]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.notesHelp")}),i&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:i.workspacePath,children:st(i.workspacePath,Fs)}),e.jsx("button",{type:"button",className:re,onClick:()=>{ct("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(re,"inline-flex items-center gap-1.5"),onClick:()=>{ct("folder")},children:[e.jsx(Yt,{size:14}),s("memory.showFileManager")]})]})]}),T&&e.jsx(Ns,{changed:T.changed,stale:_,busy:Y,onReviewed:()=>{J(!0),ps(t.id,T.token).then(()=>{F(null),K(!1)}).catch(S=>{if(S instanceof Qt&&S.status===409)return K(!0),q();j(ae(S))}).finally(()=>J(!1))}}),i&&e.jsx(Gi,{index:i.index}),t.memoryEnabled!==!1&&e.jsx(Vi,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:Ls,onTidy:()=>{$s()},rooms:{enabled:z,saving:le,error:ge,onToggle:()=>{Bs()}}}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:r.path}),r.path!==te&&e.jsx("button",{type:"button",className:Ke,onClick:()=>{G(te)},children:s("memory.backToIndex")})]}),p&&e.jsx(Ss,{botName:t.name,busy:w,onReload:ce,onOverwrite:()=>{W(p.currentHash)}}),e.jsx("textarea",{className:O(Qe,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:r.text,readOnly:r.readOnly,placeholder:r.path===te?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":r.path===te?s("memory.botMemory"):s("memory.fileLabel",{path:r.path}),onChange:S=>c({...r,text:S.target.value,dirty:!0})}),r.readOnly?e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.logsReadOnly")}):e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{W(r.hash)},disabled:w||!r.dirty,className:re,children:w?s("memory.saving"):s("memory.save")}),r.dirty&&e.jsx("button",{type:"button",className:Ke,disabled:w,onClick:()=>{G(r.path)},children:s("memory.discard")})]}),k!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:k}),e.jsx("button",{type:"button",className:O(Ke,"mt-1"),onClick:()=>g(null),children:s("memory.dismissDraft")})]})]}),i&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Bt,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:i.topics,selected:r?.path,onOpen:S=>{G(S.path)},onDelete:S=>{Ne(S)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(Qe,"py-1.5 text-[13px]"),value:D,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:S=>B(S.target.value),onKeyDown:S=>{S.key==="Enter"&<()}}),e.jsx("button",{type:"button",className:re,disabled:!D.trim(),onClick:()=>{lt()},children:s("memory.newTopic")})]}),i.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Bt,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:i.logs,selected:r?.path,onOpen:S=>{G(S.path)},onDelete:S=>{Ne(S)}})})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.changes")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.changesHelp")}),e.jsx("div",{className:"mt-3",children:e.jsx(ot,{rows:d,botName:t.name,reverting:C,onRevert:S=>{Ms(S)}})})]}),P&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:P}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function Wi(t){return`---
|
|
2
2
|
title: ${t.replace(/\.md$/,"")}
|
|
3
3
|
description:
|
|
4
4
|
aliases: []
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
`}function Wi({enabled:t,status:n,tidying:a,onToggle:l,onTidy:i,rooms:o}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.upkeep.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.upkeep.help")})]}),e.jsx(ye,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&o&&e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:s("memory.learnFromRooms.title")}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.subtitle")}),n&&!n.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),o.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:o.error})]}),e.jsx(ye,{checked:o.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:o.saving,onClick:o.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&n&&!n.modelSteps&&e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.upkeep.noModelSteps")}),t&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",className:re,disabled:a,onClick:i,children:a?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[n?.lastTidy?s("memory.upkeep.lastTidy",{time:Re(n.lastTidy.at,se()),summary:ws(n.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),n?.lastCapture&&He(n.lastCapture)?` ${s(He(n.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:He(n.lastCapture),time:Re(n.lastCapture.at,se())})}`:""]})]})]})}function Vi({index:t}){const n=Za(t),a=n.level==="over"?"bg-danger":n.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",n.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[e.jsx("span",{className:"font-medium text-ink",children:s("memory.capacity.title")}),e.jsx("span",{className:O("text-[12px]",n.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes)})})]}),e.jsx(Lt,{label:s("memory.capacity.lines"),share:n.lineShare,fill:a}),e.jsx(Lt,{label:s("memory.capacity.size"),share:n.byteShare,fill:a}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",n.level==="over"?"text-danger":"text-ink-secondary"),children:n.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})}),n.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})})]})}function Lt({label:t,share:n,fill:a}){const l=`${Math.min(100,Math.round(n*100))}%`;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"w-10 shrink-0",children:t}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":s("memory.capacity.used",{label:t}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(n*100)),children:e.jsx("div",{className:O("h-full rounded-full",a),style:{width:l}})})]})}function Ss({botName:t,busy:n,onReload:a,onOverwrite:l}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:n,onClick:a,children:s("memory.reload")}),e.jsx("button",{type:"button",className:re,disabled:n,onClick:l,children:s("memory.overwrite")})]})]})}function Bt({title:t,hint:n,files:a,selected:l,onOpen:i,onDelete:o}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:t}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:n}),a.length===0?e.jsx("div",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.noneYet")}):e.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:a.map(d=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===d.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>i(d),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:d.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[de(d.bytes)," · ",Re(d.modifiedAt,se())]})]}),e.jsx("button",{type:"button",onClick:()=>o(d),"aria-label":s("memory.deleteFile",{name:d.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(Xt,{size:14})})]},d.path))})]})}function ot({rows:t,botName:n,reverting:a,onRevert:l,now:i=Date.now()}){return t?t.length===0?e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.noChanges")}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(o=>{const d=Ya(o),m=Qa(o);return e.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{children:Ki(o,n)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Re(o.at,se(),i)}),d&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:m?s(m,o.threadTitle?{title:o.threadTitle}:void 0):d})]})]}),o.canRevert?e.jsxs("button",{type:"button",disabled:a!==null,onClick:()=>l(o),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(Ys,{size:12}),a===o.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:o.revertUnavailableReason,children:s("memory.cantUndo")})]}),o.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",o.added," −",o.removed," · ",s("memory.showChanged")]}),e.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[12px] leading-relaxed text-ink",children:o.diff})]})]},o.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Gi({bot:t,rows:n,refreshError:a,onRollback:l,rollingBack:i}){if(!n)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(n.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const o=[...n].sort((d,m)=>m.at-d.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),o.map(d=>e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{className:"text-ink-secondary",children:Jt(d.at)})," · ",e.jsxs("span",{children:[d.actor," via ",d.via]})," · ",e.jsx("span",{children:d.summary})]}),d.field==="soul"&&d.canRestore===!0&&e.jsx("button",{type:"button",disabled:i,onClick:()=>l(d.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:s("history.undo")})]}),d.field==="soul"&&d.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:d.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${d.id}`))]})}function Zi({bot:t,bare:n=!1}){const{state:a,dispatch:l}=$(),i=Qs(t),o=a.instances.find(d=>d.instanceId===t.modelSelection.instanceId);return i.turns===0?e.jsx("div",{className:O(n?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:n?void 0:"rounded-xl bg-card p-4",children:[!n&&e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("usage.title")}),e.jsxs("button",{onClick:()=>l({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ke,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:O("grid grid-cols-3 gap-3 text-[13px]",!n&&"mt-3"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colTurns")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:i.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:Xs(i)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:sn(i),children:en(tn(i))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colCost")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:ut(i.costUsd)?nn(i.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ut(i.costUsd)?s("usage.costLine",{caption:an(o?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Ji=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Yi=["circle","rounded","square"],Qi={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},Xi={idle:"botPanel.face.idle",happy:"botPanel.face.happy",curious:"botPanel.face.curious",drowsy:"botPanel.face.drowsy",working:"botPanel.face.working",thinking:"botPanel.face.thinking",listening:"botPanel.face.listening",sleeping:"botPanel.face.sleeping",suspicious:"botPanel.face.suspicious",proud:"botPanel.face.proud"},er=t=>{const n=Xi[t];return n?s(n):t};function tr({bot:t,activeState:n,onPatch:a,onClose:l}){const i=rn(t,a),{fileRef:o,crop:d,uploading:m,generating:r,busy:c,error:p,upload:f,removeImage:k,generate:g}=i,v=d!=="mascot"&&!!t.avatarUrl,[j,P]=u.useState(v?"upload":"bot"),b=u.useRef(null);u.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=h=>a(d==="mascot"?h:{...h,avatarCrop:"mascot"}),x=t.mascotBody??"cursor",C=Ma(),L=La(t.mascotBody,t.color,C),[D,B]=u.useState(()=>!!C||kt(x)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=C&&L!==x&&kt(L)?ze(L):null,H=(h,T)=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":!v&&x===h,"aria-label":s("mascot.useBody",{name:T}),title:T,onClick:()=>w({mascotBody:h}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&x===h?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Ka,{color:t.color,faceColor:t.mascotFaceColor,bodyId:h,size:40,animated:!1,trackPointer:!1})},h),A=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,"data-look":"popover",onKeyDown:A,className:"popover-surface absolute inset-x-[-5px] top-[80px] z-30 overflow-hidden rounded-2xl border border-ink/[0.08] bg-menu text-left shadow-2xl shadow-black/50",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Ji.map(([h,T])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===h,"data-avatar-tab":h,onClick:()=>P(h),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===h?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(T)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:c,onClick:()=>a(on),className:"ml-auto rounded-lg px-[11px] py-[5px] text-[13px] text-ink-secondary hover:text-ink disabled:opacity-50",children:s("botPanel.avatar.reset")})]}),e.jsxs("div",{className:"p-3",children:[j==="bot"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Ba.map(h=>H(h,ze(h)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:ln.map(h=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:Da(h)}),title:s(Fa[h]),onClick:()=>w({color:h}),className:O("size-6 rounded-full disabled:opacity-50",t.color===h&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:$a(h)}},h))}),e.jsx(ti,{bot:t,disabled:c,onPatch:w}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":D,onClick:()=>B(h=>!h),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(fe,{size:13,"aria-hidden":"true",className:O("transition-transform",D&&"rotate-180")})]}),D&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[za.map(h=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-1 pb-1.5 pt-2 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:jt(h)}),h===C&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:jt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:Ha[h].bodies.map(T=>H(T,ze(T)))})]},h)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),_a.map(h=>e.jsx("button",{type:"button",disabled:c,"data-avatar-face":h,"aria-pressed":n===h,onClick:()=>w({mascotExpression:h}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",n===h?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:er(h)},h))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(cn,{botLabel:t.title||t.name,disabled:m,generating:r,onGenerate:g})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(dn,{busy:c,onUpload:h=>{f(h)}}),v&&e.jsx(pn,{bot:t,disabled:c,onPatch:a}),e.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:h=>{f(h.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:c,onClick:()=>o.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),f(h.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[m?e.jsx(Oe,{size:22,className:"animate-spin"}):e.jsx(mn,{size:22}),e.jsx("span",{children:s("botPanel.avatar.drop")}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:s("botPanel.avatar.types")})]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2.5",children:[e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:s("botPanel.avatar.shape")}),e.jsx(Pe,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?d:null,onChange:h=>a({avatarCrop:h}),options:Yi.map(h=>({value:h,label:s(Qi[h]),disabled:c||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:c,"aria-label":s("botIdentity.removeAvatar"),title:s("botPanel.avatar.remove"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:e.jsx(Xt,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),p&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:p})]})]})}const sr=()=>s("place.off");function Cs(t){const{dispatch:n}=$();return(a="computer")=>{hn(t.id,a),n({type:"toggleSettings",open:!1}),n({type:"toggleComputer",open:!0})}}function nr(t,n){const[a,l]=u.useState(null);return u.useEffect(()=>{if(!n)return;let i=!1;return Z(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(o=>{i||l({botId:t.id,count:o.sites?.length??0})}).catch(()=>{}),()=>{i=!0}},[t.id,n]),a?.botId===t.id?a.count:null}function Ps(t){const{state:n}=$(),{capabilities:a}=je(),l=a.host?.platform??"other",i=fn(t),o=t.computer??"auto",d=n.config?.browserEngine?.myChrome===!0&&(n.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),m=g=>g==="browser"&&d?s("settings.profiles.myChrome"):bn(g,l),r=g=>{const{view:v,reachable:j}=i[g];return{value:g,label:m(g),disabled:!j,hint:!j||yn(v)?v.line:void 0}},c=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...i.local.policy?[r("local")]:[],...i.browser.policy||o==="browser"?[r("browser")]:[],...i.cloud.policy?[r("cloud")]:[],...i.vm.policy||o==="vm"?[r("vm")]:[],...o==="off"?[{value:o,label:sr(),disabled:!0}]:[]],p=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=p&&p!==o?m(p):null,k=c.find(g=>g.value===o)?.label??(o==="auto"||o==="off"?void 0:m(o));return{options:c,current:o,currentLabel:k,usingNow:f}}function ar({bot:t,derived:n}){const{dispatch:a}=$(),{options:l,current:i,usingNow:o}=Ps(t),[d,m]=u.useState(null),{patch:r,approvalMode:c}=n,p=f=>{if(!(f===i||f==="off")){if(f==="local"&&c==="auto"){m({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}r(f==="browser"?{computer:"browser",browser:!0}:{computer:f==="auto"?null:f})}};return e.jsxs(e.Fragment,{children:[e.jsx(M,{children:e.jsx("div",{role:"radiogroup","aria-label":s("computer.simple.whereWorks",{name:t.name}),className:"flex flex-col divide-y divide-ink/[0.05]",children:l.map(f=>e.jsx(Ve,{"data-panel-choice":f.value,title:f.label,hint:f.hint,checked:i===f.value,disabled:f.disabled,onClick:()=>p(f.value)},f.value))})}),o&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:o})}),e.jsx(gn,{open:d!==null,onCancel:()=>m(null),onConfirm:()=>{const f=d;m(null),f&&a({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function ir({bot:t,derived:n,onOpen:a}){const l=Cs(t),i=nt(),{browserEnabled:o}=n,d=nr(t,o&&t.computer!=="off"&&i!==!1),{currentLabel:m,usingNow:r}=Ps(t),c=s("computer.screenOf",{name:t.name}),p=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),f=p?un({threadId:t.threadId,messageId:p.id},p.mime).src:null;return e.jsxs("div",{"data-panel-tabpanel":"computer",children:[e.jsxs("button",{type:"button","data-panel-action":"open-computer","aria-label":`${s("place.action.watch")}: ${c}`,onClick:()=>l(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[f?e.jsx("img",{src:f,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(Ye,{bot:t,size:52,animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] text-ink-secondary",children:s("botPanel.screen.working")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-60",children:e.jsx(Ye,{bot:t,size:44,state:"sleeping",animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] font-medium text-ink",children:s("botPanel.screen.resting")})]}),e.jsxs("span",{"aria-hidden":"true",className:"absolute bottom-2.5 right-2.5 flex h-7 items-center gap-1.5 rounded-full border border-ink/10 bg-panel/80 px-2.5 text-[12px] text-ink opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100",children:[e.jsx(Pt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:c}),e.jsxs(M,{anchor:"where",children:[e.jsx(ee,{"data-panel-page":"where",icon:Pt,title:s("computer.simple.whereWorks",{name:t.name}),hint:r?s("computer.simple.usingNow",{place:r}):void 0,value:m,onClick:()=>a("where")}),e.jsx(ee,{"data-panel-page":"browser",icon:xn,title:s("settings.sites.title"),value:d??void 0,onClick:()=>a("browser")})]})]})}const rr=3,$t="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",or=8,lr=200,xe=new Map,Ue=new Set,Ft=t=>`${t.threadId}@${ns(t)}`;function cr(t,n){const[,a]=u.useState(0),i=n.filter(m=>m.threadId!==t.threadId).map(Ft).filter(m=>!xe.has(m)&&!Ue.has(m)).join(",");u.useEffect(()=>{if(i)for(const m of i.split(",")){Ue.add(m);const r=m.slice(0,m.lastIndexOf("@"));Z(`/api/threads/${encodeURIComponent(r)}/messages?limit=${or}`,{background:!0}).then(c=>{xe.set(m,Ze({messages:c.messages??[],activeLeafId:c.activeLeafId??void 0})),xe.size>lr&&xe.delete(xe.keys().next().value),a(p=>p+1)}).catch(()=>{}).finally(()=>Ue.delete(m))}},[i]);const o=Ze(t),d=new Map(n.map(m=>[m.threadId,Ft(m)]));return m=>m===t.threadId?o:xe.get(d.get(m)??"")}function dr({bot:t}){const{state:n,dispatch:a}=$(),l=vn(),i=!es(ts,!0),[o,d]=u.useState(""),[m,r]=u.useState(!1),[c,p]=u.useState(!1),[f,k]=u.useState(!1),g=kn(n.config),v=u.useMemo(()=>{const{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}=jn(t.id,a,g);return{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}},[t.id,a,g]),j=wn(t),P=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],b=(j?Nn({...t,tasks:P},j):P).filter(y=>!y.routineRunId).map(y=>{const z=Ge(t,y.threadId);return{...y,busy:z.busy,activity:z.activity,waitingForTeammates:z.waitingForTeammates,turnStartedAt:z.turnStartedAt??void 0,queued:!!n.pendingQueued[y.threadId]?.length}}),w=xt(b.filter(y=>!Fe(y)||y.threadId===t.threadId)),x=xt(b.filter(y=>Fe(y)&&y.threadId!==t.threadId)),C=o.trim(),L=w.filter((y,z)=>z<rr||y.threadId===t.threadId),D=cr(t,[...C||c?w:L,...f?x:[]]),B=y=>{const z=D(y);return z?Pn(Ge(t,y),z,n.instances,!1):void 0},I=Sn(w,C),H=C?[...I,...w.filter(y=>!I.includes(y)&&B(y.threadId)?.toLowerCase().includes(C.toLowerCase()))]:w,A=C?H:c?w:L,h=w.length-L.length,T=t.projects?.find(y=>y.id===t.tasks?.find(z=>z.threadId===t.threadId)?.projectId),F=()=>{i&&a({type:"toggleSettings",open:!1})},_=y=>{y.threadId!==t.threadId&&Rn(a,t,y.threadId,!1),F()},K=()=>{a({type:"newTask",botId:t.id,...T?{projectId:T.id}:{}}),F()},Y=()=>{d(""),r(!1)},J=w.length>=2||m||w.some(y=>y.threadId===t.threadId&&Fe(y)),U=y=>e.jsx("div",{role:"listitem","data-conversation":y.threadId,children:e.jsx(On,{panel:!0,preview:B(y.threadId),task:y,ownerId:t.id,current:y.threadId===t.threadId,folders:t.projects,now:En(ns(y),l),locale:se(),onSelect:_,...v})},y.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(Ee,{action:J&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":m,onClick:()=>m?Y():r(!0),className:O("-me-1 flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink",m&&"bg-ink/[0.06] text-ink"),children:e.jsx(Xe,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",J&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:K,className:O(ss,"flex-1"),children:[e.jsx(Cn,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),J&&m&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:o,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),Y())},placeholder:s("botPanel.conversations.searchPlaceholder",{name:t.name}),"aria-label":s("botPanel.conversations.searchPlaceholder",{name:t.name}),className:"mb-1.5 w-full rounded-[8px] border border-hairline/60 bg-inset px-3 py-1.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-focus"}),J&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",$t),children:A.map(U)}),J&&C&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:C})}),J&&!C&&h>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":c,onClick:()=>p(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[c?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),c?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:h})]}),!C&&x.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":f,onClick:()=>k(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[f?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:x.length})]}),!C&&f&&x.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:x.length}),className:O("flex flex-col gap-px",$t),children:x.map(U)})]})}function pr({bot:t}){const{dispatch:n}=$();return Wt()||!t.defaultBot?null:e.jsx(M,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:Tn.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>n({type:"send",botId:t.id,text:s(l),threadId:t.threadId}),className:"flex h-9 w-full items-center px-3.5 text-left text-[14px] text-ink transition-colors hover:bg-ink/[0.03]",children:e.jsx("span",{className:"truncate",children:s(l)})},l))})}const mr=["find","start-fresh","usage","activity","inspector"];function ur({item:t}){const n=t.key==="usage";return e.jsxs("button",{type:"button","data-panel-item":t.key,disabled:t.disabled,title:t.title,"aria-pressed":t.active||void 0,onClick:t.onSelect,className:O(Q,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:O("min-w-0 truncate text-[14px] font-medium",!n&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",n?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ke,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function xr({bot:t,derived:n,onOpen:a}){const{items:l}=In(t),{dispatch:i}=$(),o=n.botRoutines.filter(m=>m.enabled).length,d=mr.flatMap(m=>l.filter(r=>r.key===m));return e.jsxs("div",{"data-panel-tabpanel":"details",children:[e.jsx("section",{"data-panel-card":"model",className:"pt-2",children:e.jsx("div",{"data-panel-row":"model",className:O(Q,"rounded-[8px]"),children:e.jsx(An,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(X,{icon:tt}),e.jsx(ne,{title:s("model.simple.model")})]})})})}),e.jsx(dr,{bot:t}),e.jsx(pr,{bot:t}),d.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Ee,{children:s("botPanel.section.conversation")}),d.map(m=>e.jsx(ur,{item:m},m.key))]}),n.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(Ee,{action:e.jsx(Mn,{"data-panel-automations":"",onClick:()=>i({type:"showRoutines",view:"list"}),children:s("sidebar.nav.automations")}),children:s("botSettings.simple.routines")}),e.jsxs("button",{type:"button","data-panel-page":"routines",title:s("botPanel.routines.emptyHint"),onClick:()=>a("routines"),className:O(ss,"w-full"),children:[e.jsx(Pi,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(M,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(ee,{"data-panel-page":"routines",icon:Ln,title:s("botSettings.simple.routines"),value:o>0?s("botPanel.routinesOn",{count:o}):s("botPanel.none"),onClick:()=>a("routines")})})]})}const Os=/^\s*[-*]\s+(.+?)\s*$/;function hr(t){return t.split(`
|
|
8
|
-
`).flatMap((n,a)=>{const l=Os.exec(n)?.[1];return l?[{line:a,text:l}]:[]})}function
|
|
7
|
+
`}function Vi({enabled:t,status:n,tidying:a,onToggle:l,onTidy:i,rooms:o}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.upkeep.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.upkeep.help")})]}),e.jsx(ye,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&o&&e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:s("memory.learnFromRooms.title")}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.subtitle")}),n&&!n.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),o.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:o.error})]}),e.jsx(ye,{checked:o.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:o.saving,onClick:o.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&n&&!n.modelSteps&&e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.upkeep.noModelSteps")}),t&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",className:re,disabled:a,onClick:i,children:a?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[n?.lastTidy?s("memory.upkeep.lastTidy",{time:Re(n.lastTidy.at,se()),summary:ws(n.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),n?.lastCapture&&He(n.lastCapture)?` ${s(He(n.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:He(n.lastCapture),time:Re(n.lastCapture.at,se())})}`:""]})]})]})}function Gi({index:t}){const n=Ja(t),a=n.level==="over"?"bg-danger":n.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",n.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[e.jsx("span",{className:"font-medium text-ink",children:s("memory.capacity.title")}),e.jsx("span",{className:O("text-[12px]",n.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes)})})]}),e.jsx(Lt,{label:s("memory.capacity.lines"),share:n.lineShare,fill:a}),e.jsx(Lt,{label:s("memory.capacity.size"),share:n.byteShare,fill:a}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",n.level==="over"?"text-danger":"text-ink-secondary"),children:n.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})}),n.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})})]})}function Lt({label:t,share:n,fill:a}){const l=`${Math.min(100,Math.round(n*100))}%`;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"w-10 shrink-0",children:t}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":s("memory.capacity.used",{label:t}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(n*100)),children:e.jsx("div",{className:O("h-full rounded-full",a),style:{width:l}})})]})}function Ss({botName:t,busy:n,onReload:a,onOverwrite:l}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:n,onClick:a,children:s("memory.reload")}),e.jsx("button",{type:"button",className:re,disabled:n,onClick:l,children:s("memory.overwrite")})]})]})}function Bt({title:t,hint:n,files:a,selected:l,onOpen:i,onDelete:o}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:t}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:n}),a.length===0?e.jsx("div",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.noneYet")}):e.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:a.map(d=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===d.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>i(d),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:d.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[de(d.bytes)," · ",Re(d.modifiedAt,se())]})]}),e.jsx("button",{type:"button",onClick:()=>o(d),"aria-label":s("memory.deleteFile",{name:d.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(Xt,{size:14})})]},d.path))})]})}function ot({rows:t,botName:n,reverting:a,onRevert:l,now:i=Date.now()}){return t?t.length===0?e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.noChanges")}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(o=>{const d=Qa(o),m=Xa(o);return e.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{children:Ui(o,n)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Re(o.at,se(),i)}),d&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:m?s(m,o.threadTitle?{title:o.threadTitle}:void 0):d})]})]}),o.canRevert?e.jsxs("button",{type:"button",disabled:a!==null,onClick:()=>l(o),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(Ys,{size:12}),a===o.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:o.revertUnavailableReason,children:s("memory.cantUndo")})]}),o.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",o.added," −",o.removed," · ",s("memory.showChanged")]}),e.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[12px] leading-relaxed text-ink",children:o.diff})]})]},o.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Zi({bot:t,rows:n,refreshError:a,onRollback:l,rollingBack:i}){if(!n)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(n.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const o=[...n].sort((d,m)=>m.at-d.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),o.map(d=>e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{className:"text-ink-secondary",children:Jt(d.at)})," · ",e.jsxs("span",{children:[d.actor," via ",d.via]})," · ",e.jsx("span",{children:d.summary})]}),d.field==="soul"&&d.canRestore===!0&&e.jsx("button",{type:"button",disabled:i,onClick:()=>l(d.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:s("history.undo")})]}),d.field==="soul"&&d.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:d.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${d.id}`))]})}function Ji({bot:t,bare:n=!1}){const{state:a,dispatch:l}=$(),i=Qs(t),o=a.instances.find(d=>d.instanceId===t.modelSelection.instanceId);return i.turns===0?e.jsx("div",{className:O(n?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:n?void 0:"rounded-xl bg-card p-4",children:[!n&&e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("usage.title")}),e.jsxs("button",{onClick:()=>l({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ke,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:O("grid grid-cols-3 gap-3 text-[13px]",!n&&"mt-3"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colTurns")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:i.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:Xs(i)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:sn(i),children:en(tn(i))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colCost")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:ut(i.costUsd)?nn(i.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ut(i.costUsd)?s("usage.costLine",{caption:an(o?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Yi=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Qi=["circle","rounded","square"],Xi={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},er={idle:"botPanel.face.idle",happy:"botPanel.face.happy",curious:"botPanel.face.curious",drowsy:"botPanel.face.drowsy",working:"botPanel.face.working",thinking:"botPanel.face.thinking",listening:"botPanel.face.listening",sleeping:"botPanel.face.sleeping",suspicious:"botPanel.face.suspicious",proud:"botPanel.face.proud"},tr=t=>{const n=er[t];return n?s(n):t};function sr({bot:t,activeState:n,onPatch:a,onClose:l}){const i=rn(t,a),{fileRef:o,crop:d,uploading:m,generating:r,busy:c,error:p,upload:f,removeImage:k,generate:g}=i,v=d!=="mascot"&&!!t.avatarUrl,[j,P]=u.useState(v?"upload":"bot"),b=u.useRef(null);u.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=h=>a(d==="mascot"?h:{...h,avatarCrop:"mascot"}),x=t.mascotBody??"cursor",C=La(),L=Ba(t.mascotBody,t.color,C),[D,B]=u.useState(()=>!!C||kt(x)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=C&&L!==x&&kt(L)?ze(L):null,H=(h,T)=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":!v&&x===h,"aria-label":s("mascot.useBody",{name:T}),title:T,onClick:()=>w({mascotBody:h}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&x===h?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Ua,{color:t.color,faceColor:t.mascotFaceColor,bodyId:h,size:40,animated:!1,trackPointer:!1})},h),A=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,"data-look":"popover",onKeyDown:A,className:"popover-surface absolute inset-x-[-5px] top-[80px] z-30 overflow-hidden rounded-2xl border border-ink/[0.08] bg-menu text-left shadow-2xl shadow-black/50",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Yi.map(([h,T])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===h,"data-avatar-tab":h,onClick:()=>P(h),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===h?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(T)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:c,onClick:()=>a(on),className:"ml-auto rounded-lg px-[11px] py-[5px] text-[13px] text-ink-secondary hover:text-ink disabled:opacity-50",children:s("botPanel.avatar.reset")})]}),e.jsxs("div",{className:"p-3",children:[j==="bot"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:$a.map(h=>H(h,ze(h)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:ln.map(h=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:za(h)}),title:s(Da[h]),onClick:()=>w({color:h}),className:O("size-6 rounded-full disabled:opacity-50",t.color===h&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:Fa(h)}},h))}),e.jsx(si,{bot:t,disabled:c,onPatch:w}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":D,onClick:()=>B(h=>!h),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(fe,{size:13,"aria-hidden":"true",className:O("transition-transform",D&&"rotate-180")})]}),D&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[Ha.map(h=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-1 pb-1.5 pt-2 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:jt(h)}),h===C&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:jt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:_a[h].bodies.map(T=>H(T,ze(T)))})]},h)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),Ka.map(h=>e.jsx("button",{type:"button",disabled:c,"data-avatar-face":h,"aria-pressed":n===h,onClick:()=>w({mascotExpression:h}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",n===h?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:tr(h)},h))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(cn,{botLabel:t.title||t.name,disabled:m,generating:r,onGenerate:g})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(dn,{busy:c,onUpload:h=>{f(h)}}),v&&e.jsx(pn,{bot:t,disabled:c,onPatch:a}),e.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:h=>{f(h.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:c,onClick:()=>o.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),f(h.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[m?e.jsx(Oe,{size:22,className:"animate-spin"}):e.jsx(mn,{size:22}),e.jsx("span",{children:s("botPanel.avatar.drop")}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:s("botPanel.avatar.types")})]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2.5",children:[e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:s("botPanel.avatar.shape")}),e.jsx(Pe,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?d:null,onChange:h=>a({avatarCrop:h}),options:Qi.map(h=>({value:h,label:s(Xi[h]),disabled:c||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:c,"aria-label":s("botIdentity.removeAvatar"),title:s("botPanel.avatar.remove"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:e.jsx(Xt,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),p&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:p})]})]})}const nr=()=>s("place.off");function Cs(t){const{dispatch:n}=$();return(a="computer")=>{hn(t.id,a),n({type:"toggleSettings",open:!1}),n({type:"toggleComputer",open:!0})}}function ar(t,n){const[a,l]=u.useState(null);return u.useEffect(()=>{if(!n)return;let i=!1;return Z(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(o=>{i||l({botId:t.id,count:o.sites?.length??0})}).catch(()=>{}),()=>{i=!0}},[t.id,n]),a?.botId===t.id?a.count:null}function Ps(t){const{state:n}=$(),{capabilities:a}=je(),l=a.host?.platform??"other",i=fn(t),o=t.computer??"auto",d=n.config?.browserEngine?.myChrome===!0&&(n.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),m=g=>g==="browser"&&d?s("settings.profiles.myChrome"):bn(g,l),r=g=>{const{view:v,reachable:j}=i[g];return{value:g,label:m(g),disabled:!j,hint:!j||yn(v)?v.line:void 0}},c=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...i.local.policy?[r("local")]:[],...i.browser.policy||o==="browser"?[r("browser")]:[],...i.cloud.policy?[r("cloud")]:[],...i.vm.policy||o==="vm"?[r("vm")]:[],...o==="off"?[{value:o,label:nr(),disabled:!0}]:[]],p=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=p&&p!==o?m(p):null,k=c.find(g=>g.value===o)?.label??(o==="auto"||o==="off"?void 0:m(o));return{options:c,current:o,currentLabel:k,usingNow:f}}function ir({bot:t,derived:n}){const{dispatch:a}=$(),{options:l,current:i,usingNow:o}=Ps(t),[d,m]=u.useState(null),{patch:r,approvalMode:c}=n,p=f=>{if(!(f===i||f==="off")){if(f==="local"&&c==="auto"){m({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}r(f==="browser"?{computer:"browser",browser:!0}:{computer:f==="auto"?null:f})}};return e.jsxs(e.Fragment,{children:[e.jsx(M,{children:e.jsx("div",{role:"radiogroup","aria-label":s("computer.simple.whereWorks",{name:t.name}),className:"flex flex-col divide-y divide-ink/[0.05]",children:l.map(f=>e.jsx(Ve,{"data-panel-choice":f.value,title:f.label,hint:f.hint,checked:i===f.value,disabled:f.disabled,onClick:()=>p(f.value)},f.value))})}),o&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:o})}),e.jsx(gn,{open:d!==null,onCancel:()=>m(null),onConfirm:()=>{const f=d;m(null),f&&a({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function rr({bot:t,derived:n,onOpen:a}){const l=Cs(t),i=nt(),{browserEnabled:o}=n,d=ar(t,o&&t.computer!=="off"&&i!==!1),{currentLabel:m,usingNow:r}=Ps(t),c=s("computer.screenOf",{name:t.name}),p=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),f=p?un({threadId:t.threadId,messageId:p.id},p.mime).src:null;return e.jsxs("div",{"data-panel-tabpanel":"computer",children:[e.jsxs("button",{type:"button","data-panel-action":"open-computer","aria-label":`${s("place.action.watch")}: ${c}`,onClick:()=>l(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[f?e.jsx("img",{src:f,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(Ye,{bot:t,size:52,animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] text-ink-secondary",children:s("botPanel.screen.working")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-60",children:e.jsx(Ye,{bot:t,size:44,state:"sleeping",animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] font-medium text-ink",children:s("botPanel.screen.resting")})]}),e.jsxs("span",{"aria-hidden":"true",className:"absolute bottom-2.5 right-2.5 flex h-7 items-center gap-1.5 rounded-full border border-ink/10 bg-panel/80 px-2.5 text-[12px] text-ink opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100",children:[e.jsx(Pt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:c}),e.jsxs(M,{anchor:"where",children:[e.jsx(ee,{"data-panel-page":"where",icon:Pt,title:s("computer.simple.whereWorks",{name:t.name}),hint:r?s("computer.simple.usingNow",{place:r}):void 0,value:m,onClick:()=>a("where")}),e.jsx(ee,{"data-panel-page":"browser",icon:xn,title:s("settings.sites.title"),value:d??void 0,onClick:()=>a("browser")})]})]})}const or=3,$t="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",lr=8,cr=200,xe=new Map,Ue=new Set,Ft=t=>`${t.threadId}@${ns(t)}`;function dr(t,n){const[,a]=u.useState(0),i=n.filter(m=>m.threadId!==t.threadId).map(Ft).filter(m=>!xe.has(m)&&!Ue.has(m)).join(",");u.useEffect(()=>{if(i)for(const m of i.split(",")){Ue.add(m);const r=m.slice(0,m.lastIndexOf("@"));Z(`/api/threads/${encodeURIComponent(r)}/messages?limit=${lr}`,{background:!0}).then(c=>{xe.set(m,Ze({messages:c.messages??[],activeLeafId:c.activeLeafId??void 0})),xe.size>cr&&xe.delete(xe.keys().next().value),a(p=>p+1)}).catch(()=>{}).finally(()=>Ue.delete(m))}},[i]);const o=Ze(t),d=new Map(n.map(m=>[m.threadId,Ft(m)]));return m=>m===t.threadId?o:xe.get(d.get(m)??"")}function pr({bot:t}){const{state:n,dispatch:a}=$(),l=vn(),i=!es(ts,!0),[o,d]=u.useState(""),[m,r]=u.useState(!1),[c,p]=u.useState(!1),[f,k]=u.useState(!1),g=kn(n.config),v=u.useMemo(()=>{const{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}=jn(t.id,a,g);return{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}},[t.id,a,g]),j=wn(t),P=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],b=(j?Nn({...t,tasks:P},j):P).filter(y=>!y.routineRunId).map(y=>{const z=Ge(t,y.threadId);return{...y,busy:z.busy,activity:z.activity,waitingForTeammates:z.waitingForTeammates,turnStartedAt:z.turnStartedAt??void 0,queued:!!n.pendingQueued[y.threadId]?.length}}),w=xt(b.filter(y=>!Fe(y)||y.threadId===t.threadId)),x=xt(b.filter(y=>Fe(y)&&y.threadId!==t.threadId)),C=o.trim(),L=w.filter((y,z)=>z<or||y.threadId===t.threadId),D=dr(t,[...C||c?w:L,...f?x:[]]),B=y=>{const z=D(y);return z?Pn(Ge(t,y),z,n.instances,!1):void 0},I=Sn(w,C),H=C?[...I,...w.filter(y=>!I.includes(y)&&B(y.threadId)?.toLowerCase().includes(C.toLowerCase()))]:w,A=C?H:c?w:L,h=w.length-L.length,T=t.projects?.find(y=>y.id===t.tasks?.find(z=>z.threadId===t.threadId)?.projectId),F=()=>{i&&a({type:"toggleSettings",open:!1})},_=y=>{y.threadId!==t.threadId&&Rn(a,t,y.threadId,!1),F()},K=()=>{a({type:"newTask",botId:t.id,...T?{projectId:T.id}:{}}),F()},Y=()=>{d(""),r(!1)},J=w.length>=2||m||w.some(y=>y.threadId===t.threadId&&Fe(y)),U=y=>e.jsx("div",{role:"listitem","data-conversation":y.threadId,children:e.jsx(On,{panel:!0,preview:B(y.threadId),task:y,ownerId:t.id,current:y.threadId===t.threadId,folders:t.projects,now:En(ns(y),l),locale:se(),onSelect:_,...v})},y.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(Ee,{action:J&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":m,onClick:()=>m?Y():r(!0),className:O("-me-1 flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink",m&&"bg-ink/[0.06] text-ink"),children:e.jsx(Xe,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",J&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:K,className:O(ss,"flex-1"),children:[e.jsx(Cn,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),J&&m&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:o,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),Y())},placeholder:s("botPanel.conversations.searchPlaceholder",{name:t.name}),"aria-label":s("botPanel.conversations.searchPlaceholder",{name:t.name}),className:"mb-1.5 w-full rounded-[8px] border border-hairline/60 bg-inset px-3 py-1.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-focus"}),J&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",$t),children:A.map(U)}),J&&C&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:C})}),J&&!C&&h>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":c,onClick:()=>p(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[c?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),c?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:h})]}),!C&&x.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":f,onClick:()=>k(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[f?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:x.length})]}),!C&&f&&x.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:x.length}),className:O("flex flex-col gap-px",$t),children:x.map(U)})]})}function mr({bot:t}){const{dispatch:n}=$();return Wt()||!t.defaultBot?null:e.jsx(M,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:Tn.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>n({type:"send",botId:t.id,text:s(l),threadId:t.threadId}),className:"flex h-9 w-full items-center px-3.5 text-left text-[14px] text-ink transition-colors hover:bg-ink/[0.03]",children:e.jsx("span",{className:"truncate",children:s(l)})},l))})}const ur=["find","start-fresh","usage","activity","inspector"];function xr({item:t}){const n=t.key==="usage";return e.jsxs("button",{type:"button","data-panel-item":t.key,disabled:t.disabled,title:t.title,"aria-pressed":t.active||void 0,onClick:t.onSelect,className:O(Q,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:O("min-w-0 truncate text-[14px] font-medium",!n&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",n?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ke,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function hr({bot:t,derived:n,onOpen:a}){const{items:l}=In(t),{dispatch:i}=$(),o=n.botRoutines.filter(m=>m.enabled).length,d=ur.flatMap(m=>l.filter(r=>r.key===m));return e.jsxs("div",{"data-panel-tabpanel":"details",children:[e.jsx("section",{"data-panel-card":"model",className:"pt-2",children:e.jsx("div",{"data-panel-row":"model",className:O(Q,"rounded-[8px]"),children:e.jsx(An,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(X,{icon:tt}),e.jsx(ne,{title:s("model.simple.model")})]})})})}),e.jsx(pr,{bot:t}),e.jsx(mr,{bot:t}),d.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Ee,{children:s("botPanel.section.conversation")}),d.map(m=>e.jsx(xr,{item:m},m.key))]}),n.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(Ee,{action:e.jsx(Mn,{"data-panel-automations":"",onClick:()=>i({type:"showRoutines",view:"list"}),children:s("sidebar.nav.automations")}),children:s("botSettings.simple.routines")}),e.jsxs("button",{type:"button","data-panel-page":"routines",title:s("botPanel.routines.emptyHint"),onClick:()=>a("routines"),className:O(ss,"w-full"),children:[e.jsx(Oi,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(M,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(ee,{"data-panel-page":"routines",icon:Ln,title:s("botSettings.simple.routines"),value:o>0?s("botPanel.routinesOn",{count:o}):s("botPanel.none"),onClick:()=>a("routines")})})]})}const Os=/^\s*[-*]\s+(.+?)\s*$/;function fr(t){return t.split(`
|
|
8
|
+
`).flatMap((n,a)=>{const l=Os.exec(n)?.[1];return l?[{line:a,text:l}]:[]})}function gr(t,n){const a=t.split(`
|
|
9
9
|
`);return Os.test(a[n]??"")?(a.splice(n,1),a.join(`
|
|
10
|
-
`)):t}function
|
|
10
|
+
`)):t}function yr(t,n){const a=t.replace(/\s+$/,""),l=`- ${n.trim().replace(/\s*\n\s*/g," ")}`;return a?`${a}
|
|
11
11
|
${l}
|
|
12
12
|
`:`${l}
|
|
13
|
-
`}function Es(t){return t.flatMap(n=>{const a=
|
|
14
|
-
`).map(i=>i.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:n.path,line:null,text:l}]:[]})}async function yr(t,n){if(!n)return[await Te(t,te)];const a=await it(t,!0);return Promise.all([te,...a.topics.map(l=>l.path)].map(l=>Te(t,l,!0)))}function Rs(t){const n=!!$().state.config?.team,[a,l]=u.useState({botId:t.id,docs:null,error:!1}),i=t.memoryEnabled!==!1,o=async(r,c)=>{try{const p=await yr(r,n);c?.()||l({botId:r,docs:p,error:!1})}catch{c?.()||l({botId:r,docs:null,error:!0})}},d=!!t.busy;u.useEffect(()=>{if(!i)return;let r=!1;return o(t.id,()=>r),()=>{r=!0}},[t.id,i,d,n]);const m=a.botId===t.id;return{docs:m?a.docs:null,error:m&&a.error,mine:n,setDoc:r=>l(c=>({botId:t.id,docs:(c.botId===t.id?c.docs??[]:[]).map(p=>p.path===r.path?r:p),error:!1})),reload:()=>o(t.id)}}function br(t,n=Ze(t)){const a=[],l=[],i=new Set;for(const c of[...n].reverse()){const p=c.publishedPage;p?.state==="live"&&p.url&&!i.has(p.url)&&(i.add(p.url),a.push({messageId:c.id,title:p.title||p.url,url:p.url})),c.kind==="app"&&c.app?.doc&&l.push({messageId:c.id,title:c.app.title})}const o=yi(t),d=[],m=new Set;for(const c of o.values())m.has(c.file.path)||(m.add(c.file.path),d.push(c));const r=bi(t).filter(c=>!o.has(c));return{pages:a,apps:l,shared:d,unshared:r}}const vr=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Ts({bot:t,onOpen:n}){const{dispatch:a}=$(),{capabilities:l}=je(),i=Bn(),o=!es(ts,!0),d=hs(t),m=Rs(t),{pages:r,apps:c,shared:p,unshared:f}=u.useMemo(()=>br(t),[t]),k=b=>{a({type:"focusMessage",threadId:t.threadId,messageId:b}),o&&a({type:"toggleSettings",open:!1})},g=d.skills.filter(fs).length,v=m.docs?Es(m.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?m.error?s("botPanel.memory.nothingYet"):void 0:v===0?s("botPanel.memory.nothingYet"):v===1?s("botPanel.memory.note"):s("botPanel.memory.notes",{count:v}),P=e.jsxs(M,{anchor:"keeps",children:[e.jsx(ee,{"data-panel-page":"memory",icon:Vt,title:s("botPanel.memoryRow"),value:j,onClick:()=>n("memory")}),e.jsx(ee,{"data-panel-page":"skills",icon:$n,title:s("botSettings.simple.skills"),value:d.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>n("skills")}),e.jsx(ee,{"data-panel-page":"folder",icon:Fn,title:s("computer.files.folder"),value:t.cwd?st(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>n("folder")})]});return r.length+c.length+p.length+f.length===0?e.jsxs("div",{"data-panel-tabpanel":"library",children:[e.jsx("p",{"data-panel-empty":"library",className:"px-3 py-7 text-center text-[13px] leading-[18px] text-ink-tertiary",children:s("botPanel.library.empty")}),P]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[r.length>0&&e.jsx(M,{label:s("botPanel.library.pages"),anchor:"pages",children:r.map(b=>e.jsx(ee,{"data-panel-row":"page",icon:Dn,title:e.jsx("span",{className:"block truncate",children:b.title}),hint:e.jsx("span",{className:"block truncate",children:b.url}),onClick:()=>i(b.url)},b.url))}),c.length>0&&e.jsx(M,{label:s("botPanel.library.apps"),anchor:"apps",children:c.map(b=>e.jsx(ee,{"data-panel-row":"app",icon:as,title:e.jsx("span",{className:"block truncate",children:b.title}),onClick:()=>k(b.messageId)},b.messageId))}),p.length+f.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(Ee,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[p.map(b=>e.jsx("li",{className:"min-w-0",children:e.jsx(zn,{file:b.file,message:b.message,linked:b.file.linked,className:"w-full max-w-none"})},`${b.message.messageId}:${b.file.path}`)),f.map(b=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:vr(b)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},b))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),P]})}function kr({bot:t,browserEnabled:n,onOpenBrowser:a}){const{state:l}=$(),i=nt(),o=t.browserProfile??"",d=(l.config?.browserProfiles??[]).find(p=>p.id===o),m=o==="guest",r=d?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,c=o&&!m?l.bots.filter(p=>p.browserProfile===o).map(p=>p.name):[t.name];return e.jsx(M,{anchor:"logins",children:n?m?e.jsx(V,{children:s("settings.profiles.temporaryHint")}):r?e.jsx(V,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[i!==!1&&(o===""||d)&&e.jsx(pe,{children:e.jsx(Si,{bare:!0,target:{bot:t.id},sharedBy:c,disabled:!!t.busy},`${t.id}:${o}`)}),e.jsx(V,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(me,{"data-panel-action":"add-login",icon:we,onClick:a,children:s("botSettings.simple.addLogin")})]}):e.jsx(V,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const jr=[["all",()=>N("Tất cả","All")],["added",()=>N("Bot đang có","On this bot")],["more",()=>N("Chưa thêm","Not added")]],wr=t=>({bundled:N("Có sẵn","Built in"),library:N("Đã tải về","Downloaded"),imported:N("Từ máy tính","From this computer")})[t],qe="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-hairline/60 bg-raised px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50";async function Dt(t,n){const a=await fetch(t,n===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)}),l=await a.json().catch(()=>({}));if(!a.ok)throw new Error(l.error??N(`Lỗi ${a.status}`,`Error ${a.status}`));return l.skills??[]}function Nr({botId:t,botName:n,onClose:a,onOpenSettings:l}){const[i,o]=u.useState(null),[d,m]=u.useState(""),[r,c]=u.useState("all"),[p,f]=u.useState(""),[k,g]=u.useState(""),v=`/api/limix/skill-store/${encodeURIComponent(t)}`;u.useEffect(()=>{let x=!1;return Dt(v).then(C=>{x||o(C)}).catch(C=>{x||(o([]),g(C.message))}),()=>{x=!0}},[v]),u.useEffect(()=>{const x=C=>{C.key==="Escape"&&a()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a]);const j=u.useMemo(()=>{const x=d.trim().toLowerCase();return(i??[]).filter(C=>(r==="all"||(r==="added"?C.added:!C.added))&&(!x||`${C.name} ${C.description}`.toLowerCase().includes(x)))},[i,d,r]),P=async(x,C)=>{if(!p){f(x.name),g("");try{o(await Dt(v,{name:x.name,kind:x.kind,add:C}))}catch(L){g(L instanceof Error?L.message:N("Không đổi được kĩ năng này.","Couldn't change this skill."))}finally{f("")}}},b=(i??[]).filter(x=>x.added).length,w=e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:x=>x.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"limix-skill-store-title",className:"flex max-h-full w-full max-w-[640px] flex-col rounded-2xl border border-hairline/50 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pb-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"limix-skill-store-title",className:"text-[17px] font-semibold text-ink",children:N("Kho Kĩ Năng (Skills)","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:N(`Chọn kĩ năng riêng cho ${n}. Chỉ những kĩ năng được thêm mới nằm trong lời nhắc của bot, nên bot không bị quá tải. Gõ /tên-kĩ-năng trong chat để gọi.`,`Pick skills just for ${n}. Only added skills go into the bot's prompt, so it never gets overloaded. Type /skill-name in chat to call one.`)})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":N("Đóng","Close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(et,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 pb-3",children:[e.jsxs("label",{className:"flex min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsx(Xe,{size:14,className:"text-ink-tertiary"}),e.jsx("input",{value:d,onChange:x=>m(x.target.value),placeholder:N("Tìm kĩ năng…","Search skills…"),"aria-label":N("Tìm kĩ năng","Search skills"),className:"w-full bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":N("Lọc kĩ năng","Filter skills"),children:jr.map(([x,C])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":r===x,onClick:()=>c(x),className:`rounded-lg px-2.5 py-1.5 text-[13px] ${r===x?"bg-raised text-ink":"text-ink-secondary hover:bg-raised"}`,children:[C(),x==="added"&&i?` ${b}`:""]},x))})]}),k&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:k}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:i===null?e.jsxs("p",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(Oe,{size:14,className:"animate-spin"}),N("Đang tải kho…","Loading the store…")]}):j.length===0?e.jsx("p",{className:"py-6 text-[13px] text-ink-secondary",children:i.length===0?N("Kho chưa có kĩ năng nào.","The store has no skills yet."):N("Không có kĩ năng khớp.","No matching skills.")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline/40 rounded-xl border border-hairline/40",children:j.map(x=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[13px] text-ink",children:x.name}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:x.core?N("Kĩ năng gốc","Core skill"):wr(x.kind)}),x.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[x.warnings," ",N("cảnh báo","warnings")]})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] leading-relaxed text-ink-secondary",children:x.description})]}),x.core?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(dt,{size:14}),N("Luôn bật","Always on")]}):x.added?e.jsxs("button",{type:"button",className:qe,disabled:!!p,onClick:()=>{P(x,!1)},"aria-label":N(`Bỏ ${x.name} khỏi bot`,`Remove ${x.name} from this bot`),children:[p===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(dt,{size:14}),N("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:qe,disabled:!!p||!x.ready,onClick:()=>{P(x,!0)},"aria-label":N(`Thêm ${x.name} cho bot`,`Add ${x.name} to this bot`),children:[p===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(we,{size:14}),N("Thêm","Add")]})]},`${x.kind}:${x.name}`))})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 pb-5 pt-3",children:[e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:N('Bấm "Đã thêm" để bỏ kĩ năng khỏi bot này.','Press "Added" to remove a skill from this bot.')}),e.jsx("button",{type:"button",className:qe,onClick:l,children:N("Tải thêm kĩ năng","Get more skills")})]})]})});return typeof document>"u"?w:cs.createPortal(w,document.body)}const be=()=>window.ogb?.limixMessenger,zt=[{kind:"telegram",label:"Telegram",placeholder:"123456789:AA…",howTo:()=>N("Tạo bot với @BotFather (lệnh /newbot), rồi dán token vào đây.","Make a bot with @BotFather (/newbot), then paste its token here."),where:t=>`@${t.username}`,linkFrom:t=>N(`Nhắn cho @${t.username}: `,`Send @${t.username}: `)},{kind:"discord",label:"Discord",placeholder:"MTA…",howTo:()=>N("Vào discord.com/developers → New Application → Bot → Reset Token, dán token vào đây. Mời bot vào server: OAuth2 → URL Generator → chọn bot và quyền Send Messages. Trong server, gọi bot bằng @tên-bot.","At discord.com/developers: New Application → Bot → Reset Token, paste it here. Invite it with OAuth2 → URL Generator (bot, Send Messages). In a server, call it with @its-name."),where:t=>`@${t.username}`,linkFrom:()=>N("Nhắn riêng cho bot trên Discord: ","Send the bot a direct message on Discord: ")},{kind:"zalo",label:"Zalo",howTo:()=>N("Quét mã QR bằng ứng dụng Zalo của tài khoản sẽ làm bot.","Scan the QR code with the Zalo app of the account that will be the bot."),note:()=>N("Nên dùng tài khoản Zalo phụ: đây là cách đăng nhập không chính thức (như Zalo Web), Zalo có thể khoá tài khoản. Mở Zalo Web bằng tài khoản này ở nơi khác sẽ ngắt bot.","Use a spare Zalo account: this sign-in is unofficial (like Zalo Web) and Zalo may lock the account. Opening Zalo Web with it elsewhere disconnects the bot."),where:t=>t.name||t.username||"Zalo",linkFrom:()=>N("Từ Zalo của bạn, nhắn cho tài khoản bot: ","From your own Zalo, message the bot's account: ")},{kind:"facebook",label:"Facebook Page",placeholder:"EAA…",howTo:()=>N("Dán Page Access Token: developers.facebook.com → tạo app → thêm Messenger → Access Tokens → chọn Page → Generate token.","Paste a Page access token: developers.facebook.com → create an app → add Messenger → Access Tokens → pick the Page → Generate token."),note:()=>N("Bot trả lời khách nhắn vào Page sau khoảng 10–20 giây. Muốn trả lời mọi khách, app Meta cần được duyệt quyền pages_messaging.","The bot answers people who message the Page within about 10–20 seconds. To answer everyone, the Meta app needs pages_messaging approved."),where:t=>t.name||"Page",linkFrom:()=>N("Từ Facebook cá nhân, nhắn cho Page: ","From your own Facebook, message the Page: ")},{kind:"messenger",label:"Messenger",howTo:()=>N("Đăng nhập Facebook trong cửa sổ của app (nhập cả mã PIN khôi phục tin nhắn nếu Facebook hỏi), rồi đóng cửa sổ. App giữ một cửa sổ Facebook ẩn, đọc tin mới và gõ câu trả lời.","Sign in to Facebook in the app's window (enter the chat-restore PIN if Facebook asks), then close it. The app keeps a hidden Facebook window that reads new messages and types the replies."),note:()=>N("Thử nghiệm, tài khoản cá nhân. Chỉ chạy khi app đang mở trên máy này. Nên dùng tài khoản phụ: Facebook không có cách chính thức cho tài khoản cá nhân và có thể khoá tài khoản. Ai nhắn cũng được trả lời ở chế độ an toàn.","Beta, personal accounts. Runs only while the app is open on this computer. Use a spare account: Facebook has no official way for personal accounts and may lock it. Everyone is answered in safe mode."),where:()=>N("tài khoản Facebook đã đăng nhập","the signed-in Facebook account"),linkFrom:()=>""}],ie="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50";function Sr({bot:t,className:n}){const[a,l]=u.useState("telegram"),[i,o]=u.useState({});u.useEffect(()=>{let r=!0;o({});for(const c of zt.filter(p=>p.kind!=="messenger"||be()))Z(`/api/bots/${t.id}/${c.kind}`).then(p=>{r&&o(f=>({...f,[c.kind]:p}))}).catch(()=>{});return()=>{r=!1}},[t.id]);const d=zt.filter(r=>r.kind!=="messenger"||be()),m=d.find(r=>r.kind===a);return e.jsxs("div",{className:O("rounded-xl bg-card p-4",n),"data-testid":"channels-card",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:N("Kênh chat","Chat channels")}),e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:N(`Cho ${t.name} trả lời tin nhắn ngoài app.`,`Let ${t.name} answer messages outside the app.`)}),e.jsx("div",{role:"tablist",className:"mt-3 flex flex-wrap gap-1.5",children:d.map(r=>{const c=i[r.kind];return e.jsxs("button",{type:"button",role:"tab","aria-selected":a===r.kind,onClick:()=>l(r.kind),"data-testid":`channel-tab-${r.kind}`,className:O("flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-[13px]",a===r.kind?"bg-control text-ink":"text-ink-secondary hover:bg-raised-hover"),children:[c?.connected&&e.jsx("span",{className:O("size-1.5 rounded-full",c.error?"bg-danger":c.enabled?"bg-success":"bg-ink-tertiary")}),r.label]},r.kind)})}),e.jsx(Cr,{bot:t,channel:m,view:i[a],onView:r=>o(c=>({...c,[a]:r}))},`${t.id}:${a}`)]})}function Cr({bot:t,channel:n,view:a,onView:l}){const i=`/api/bots/${t.id}/${n.kind}`,[o,d]=u.useState(""),[m,r]=u.useState(null),[c,p]=u.useState(!1),[f,k]=u.useState(null),g=!!(a?.login&&!a.login.error&&!a.connected);u.useEffect(()=>{if(!g)return;const P=setInterval(()=>{Z(i).then(l).catch(()=>{})},2e3);return()=>clearInterval(P)},[g,i,l]);const v=async P=>{p(!0),k(null);try{const{code:b,...w}=await P();l(w),b&&r(b)}catch(b){k(b instanceof Error?b.message:String(b))}finally{p(!1)}},j=(P,b="")=>v(()=>Z(`${i}${b}`,{method:"POST",body:JSON.stringify(P??{})}));return a?e.jsxs("div",{className:"mt-3 text-[13px]","data-testid":`channel-${n.kind}`,children:[!a.connected&&e.jsxs("div",{className:"flex flex-col gap-2 text-ink-secondary",children:[e.jsx("span",{children:n.howTo()}),n.note&&e.jsx("span",{className:"text-[12px]",children:n.note()}),n.placeholder?e.jsxs("form",{className:"flex gap-2",onSubmit:P=>{P.preventDefault(),o.trim()&&j({token:o.trim()}).then(()=>d(""))},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:o,onChange:P=>d(P.target.value),placeholder:n.placeholder,"aria-label":N(`Token ${n.label}`,`${n.label} token`),className:"min-w-0 flex-1 rounded-lg bg-inset px-3 py-1.5 font-mono text-[13px] text-ink outline-none","data-testid":`channel-token-${n.kind}`}),e.jsx("button",{type:"submit",disabled:c||!o.trim(),className:ie,"data-testid":`channel-connect-${n.kind}`,children:N("Kết nối","Connect")})]}):n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:c,onClick:()=>{v(async()=>await be().signIn(t.id))},"data-testid":"channel-signin-messenger",children:N("Mở cửa sổ đăng nhập Facebook","Open the Facebook sign-in window")}):e.jsx(Pr,{view:a,busy:c,start:()=>{j({},"/login")},cancel:()=>{v(()=>Z(`${i}/login`,{method:"DELETE"}))}})]}),a.connected&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsx("span",{children:N(`${t.name} trả lời tin nhắn gửi tới ${n.where(a)}.`,`${t.name} answers messages sent to ${n.where(a)}.`)}),e.jsx(ye,{"aria-label":N(`Bật ${n.label}`,`${n.label} on`),checked:a.enabled===!0,disabled:c,onClick:()=>{j({enabled:!a.enabled})},"data-testid":`channel-switch-${n.kind}`})]}),n.note&&(n.kind==="facebook"||n.kind==="messenger")&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:n.note()}),n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ie,"self-start"),onClick:()=>{be()?.show(t.id)},children:N("Mở cửa sổ Messenger của bot","Show the bot's Messenger window")}):a.owner?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-ink-secondary",children:[e.jsx("span",{children:N(`Chủ bot: ${a.owner}. Nhắn riêng ở đó như nhắn trong app, toàn quyền.`,`Owner: ${a.owner}. Direct messages there work as in the app, with full access.`)}),e.jsx("button",{type:"button",className:ie,disabled:c,onClick:()=>{j({},"/unlink")},children:N("Bỏ liên kết","Unlink")})]}):e.jsxs("div",{className:"flex flex-col gap-1.5 text-ink-secondary",children:[e.jsx("span",{children:N("Liên kết tài khoản của bạn để nhắn với bot như trong app:","Link your own account to talk to the bot as in the app:")}),m?e.jsxs("span",{className:"text-ink","data-testid":`channel-code-${n.kind}`,children:[n.linkFrom(a),e.jsxs("code",{className:"rounded bg-inset px-1.5 py-0.5 font-mono",children:["/link ",m]}),N(" (hết hạn sau 15 phút)"," (expires in 15 minutes)")]}):e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:c,onClick:()=>{j({},"/link")},"data-testid":`channel-link-${n.kind}`,children:N("Tạo mã liên kết","Make a link code")})]}),e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời cả người khác","Answer other people too"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:n.kind==="zalo"?N("Người khác có thể nhắn riêng cho bot với quyền khách.","Other people can message the bot privately as guests."):N("Người khác và nhóm nhắn được bot ở chế độ an toàn: không dùng công cụ, không thấy cuộc trò chuyện của bạn.","Others and groups can write to the bot in safe mode: no tools, none of your conversations.")})]}),e.jsx(ye,{"aria-label":N("Trả lời cả người khác","Answer other people too"),checked:a.access==="everyone",disabled:c,onClick:()=>{j({access:a.access==="everyone"?"owner":"everyone",...a.groupMentions!==void 0?{groupMentions:a.groupMentions}:{}})},"data-testid":`channel-everyone-${n.kind}`})]}),n.kind==="zalo"&&e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:N("Mọi thành viên đều có thể gọi bot. Bot trả lời trong nhóm với quyền khách, kể cả khi chủ bot gọi.","Anyone in the group can mention the bot. Group replies use guest access, including when the owner mentions it.")})]}),e.jsx(ye,{"aria-label":N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),checked:a.groupMentions??a.access==="everyone",disabled:c,onClick:()=>{j({groupMentions:!(a.groupMentions??a.access==="everyone")})},"data-testid":"channel-zalo-group-mentions"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",className:ie,disabled:c,onClick:()=>{v(async()=>{const P=await Z(i,{method:"DELETE"});return n.kind==="messenger"&&await be()?.signOut(t.id),P})},"data-testid":`channel-remove-${n.kind}`,children:N("Gỡ kết nối","Disconnect")})})]}),(f||a.error)&&e.jsx("div",{role:"alert",className:"mt-2 text-[13px] text-danger",children:f??a.error})]}):e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:"…"})}function Pr({view:t,busy:n,start:a,cancel:l}){const i=t.login;return!i||i.error?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[i?.error&&e.jsx("span",{className:"text-danger",children:i.error}),e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:n,onClick:a,"data-testid":"channel-qr-zalo",children:N("Tạo mã QR đăng nhập","Show a sign-in QR code")})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[i.qr?e.jsx("img",{src:i.qr,alt:N("Mã QR đăng nhập Zalo","Zalo sign-in QR code"),className:"size-44 rounded-lg bg-white p-1.5","data-testid":"channel-qr-image"}):e.jsx("div",{className:"flex size-44 items-center justify-center rounded-lg bg-inset",children:"…"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-ink",children:i.scanned?N(`${i.scanned} đã quét. Xác nhận đăng nhập trong ứng dụng Zalo.`,`${i.scanned} scanned it. Confirm the sign-in in the Zalo app.`):N("Mở Zalo trên điện thoại → biểu tượng quét mã → quét mã này.","Open Zalo on the phone → scan icon → scan this code.")}),e.jsx("button",{type:"button",className:O(ie,"self-start"),onClick:l,children:N("Huỷ","Cancel")})]})]})}const Or=5,Er={instanceId:"",model:""},Is=(t,n)=>`${t}\0${n}`,Rr=new Set;function Ht({bot:t,current:n,exclude:a,onPick:l,label:i,title:o,buttonRef:d,className:m,children:r,...c}){const{state:p,dispatch:f,refreshInstances:k,refreshModels:g}=$(),[v,j]=u.useState(!1),[P,b]=u.useState(""),[w,x]=u.useState(()=>new Set),[C,L]=u.useState(!1),[D,B]=u.useState(null),[I,H]=u.useState(null),A=u.useRef(null),h=d??A,T=u.useRef(null),F=u.useRef(null),_=u.useRef(!1),K=u.useId(),Y=Va(v),J=u.useRef({contains:E=>[h.current,T.current].some(q=>q?.contains(E))});Wn(v,J,()=>j(!1)),u.useLayoutEffect(()=>{if(!v)return;const E=q=>{if(q?.type==="scroll"&&q.target instanceof Node&&T.current?.contains(q.target))return;const G=h.current?.getBoundingClientRect(),W=T.current;!G||!W||H(ce=>Zn(G,{width:ft,height:W.offsetHeight},{width:window.innerWidth,height:window.innerHeight},ce??void 0))};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[v,h]),u.useEffect(()=>{if(!v||!I||!_.current)return;_.current=!1;const E=T.current;(E?.querySelector("[data-menu-search]")??E?.querySelector("[data-current-model]")??E?.querySelector("[data-menu-row]:not(:disabled)")??E)?.focus({preventScroll:!0})},[v,I]);const U=E=>{j(!1),E&&h.current?.focus({preventScroll:!0})},y=()=>{b(""),x(new Set),H(null),_.current=!0,j(!0),L(!0),k().catch(()=>{}).finally(()=>L(!1))},z=E=>{D||(B(E.instanceId),g(E.instanceId).catch(()=>{}).finally(()=>B(null)))},le=()=>{U(!1),f({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const E=Yn(p.instances,n?.instanceId).flatMap(W=>{const ce=W.models.options.filter(Ne=>!a.has(Is(W.instanceId,Ne.id)));return ce.length===W.models.options.length?[W]:ce.length?[{...W,models:{...W.models,options:ce}}]:[]}),q=Qn({instances:p.instances,listed:E,selection:n??Er,bot:{name:t.name,selection:t.modelSelection},query:P,expanded:w,probing:Rr,loading:C,refreshing:D}),G=q.groups.map(W=>W.instance.instanceId===t.modelSelection.instanceId?{...W,note:s("botPanel.backups.sameAccount")}:W);return{...q,groups:G,...n?{}:{current:null}}},ge=E=>{if(!(E.nativeEvent.isComposing||E.defaultPrevented)){if(E.key!=="Escape")return Jn(E,{query:P,typed:F,close:()=>U(!0)});E.preventDefault(),E.stopPropagation(),P?b(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...c,"aria-label":i,title:o,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?K:void 0,onClick:()=>v?U(!1):y(),onKeyDown:E=>{E.key==="Escape"&&v?(E.preventDefault(),E.stopPropagation(),U(!1)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&!v&&(E.preventDefault(),y())},className:m,children:r}),Y.shown&&cs.createPortal(e.jsx("div",{ref:T,id:K,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...Y.exitProps,onKeyDown:ge,onPointerMove:Vn,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??ft,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",Y.className),children:e.jsx(Gn,{menu:ue(),query:P,bot:t,botModel:{label:"",title:""},idPrefix:K,onQuery:b,onPick:(E,q)=>{E.policy||(l({instanceId:E.instanceId,model:q}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:E=>x(q=>{const G=new Set(q);return G.delete(E.instanceId)||G.add(E.instanceId),G}),onSetUp:le,onCheckAgain:z,onManage:le})}),document.body)]})}function Tr({bot:t,onChange:n}){const{state:a}=$(),l=t.fallback??[],i=u.useRef(null),o=m=>new Set([t.modelSelection,...l.filter((r,c)=>c!==m)].map(r=>Is(r.instanceId,r.model))),d=m=>{const r=a.instances.find(f=>f.instanceId===m.instanceId),c=r?.models.options.find(f=>f.id===m.model),p=Kn(r,m.model);return{instance:r,name:p,short:r&&c?Un(c.label,qn(r)):p}};return e.jsx(M,{anchor:"backups",children:e.jsxs(pe,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Hn}),e.jsx(ne,{title:s("botPanel.backups.title")})]}),e.jsx("p",{className:"-mt-1 pl-[38px] text-[13px] leading-[1.35] text-ink-secondary",children:s("botPanel.backups.hint",{name:t.name})}),l.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:l.map((m,r)=>{const{instance:c,name:p,short:f}=d(m);return e.jsxs("li",{"data-backup":m.instanceId,className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"w-3 shrink-0 text-[12px] tabular-nums text-ink-tertiary","aria-hidden":"true",children:r+1}),e.jsxs(Ht,{bot:t,current:m,exclude:o(r),onPick:k=>n(l.map((g,v)=>v===r?k:g)),label:s("botPanel.backups.row",{position:r+1,model:p}),title:c?`${c.displayName} · ${p}`:p,"data-panel-action":"backup-change",className:"group flex h-8 min-w-0 flex-1 items-center gap-2 rounded-[8px] bg-ink/[0.04] pl-2.5 pr-2 text-left text-[13px] text-ink hover:bg-ink/[0.07] aria-expanded:bg-ink/[0.08]",children:[c?e.jsx(_n,{instance:c,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),!c&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(fe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Me,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:p}),onClick:()=>{n(l.filter((k,g)=>g!==r)),i.current?.focus({preventScroll:!0})}})]},r)})}),l.length<Or&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(Ht,{bot:t,current:null,exclude:o(null),onPick:m=>n([...l,m]),label:s("model.fallback.add"),buttonRef:i,"data-panel-action":"backup-add",className:O(oe,"aria-expanded:bg-raised-hover"),children:[e.jsx(we,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Ir({bot:t}){const{dispatch:n}=$(),[a,l]=u.useState(!1),[i,o]=u.useState(!1),[d,m]=u.useState(0),r=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(u.useEffect(()=>{if(!r)return;let p=!0;return Z(`/api/bots/${t.id}/system-prompt`).then(f=>{p&&l(f.heavy===!0)},()=>{}),()=>{p=!1}},[t.id,r,d]),!r||!a)return null;const c=async()=>{o(!0);try{await ms(t.id)}catch(p){n({type:"error",message:p instanceof Error&&p.message?p.message:s("common.tryAgain")})}finally{o(!1),m(p=>p+1)}};return e.jsx(M,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Q,children:[e.jsx(X,{icon:Xn}),e.jsx(ne,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:i,onClick:()=>{c()},className:oe,children:i?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Ar=5;function Mr({bot:t}){const{dispatch:n,flushBotPatches:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),m=u.useCallback(()=>Nt(t.id).then(c=>i(c.rows.slice(0,Ar)),()=>{}),[t.id]);if(u.useEffect(()=>{m()},[m,t.soul]),!l.length)return null;const r=async c=>{if(!o){d(c.id);try{await a(t.id);const{revision:p}=await Nt(t.id);await si(t.id,c.id,p)}catch(p){n({type:"error",message:p instanceof Error&&p.message?p.message:s("botOverview.undoFailed")})}finally{d(null),await m()}}};return e.jsxs("div",{"data-panel-row":"soul-changes",className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("memory.changes")}),e.jsx(ot,{rows:l,botName:t.name,reverting:o,onRevert:c=>{r(c)}})]})}const We={ask:()=>s("botSettings.simple.ask"),full:()=>s("botSettings.simple.justDoIt"),auto:()=>s("botSettings.simple.decide"),edits:()=>s("approvalMode.edits.label"),custom:()=>s("botPanel.acts.custom")};function Lr({bot:t,derived:n,onOpen:a,editingInstructions:l=!1,onEditInstructions:i}){const{state:o,dispatch:d,flushBotPatches:m}=$(),{capabilities:r,ready:c}=je(),p=is(t),{servers:f}=bs(),k=ea(Ge(t)),g=ta(),v=js(t.id),j=gs(),[P,b]=u.useState(null),{patch:w,approvalMode:x,engine:C}=n,L=t.name,D=()=>{P!==null&&P.trim()!==t.title.trim()&&w({title:P.trim()}),b(null)},B=C?.driverKind==="antigravityAgent"&&x==="auto"?"ask":x,I=[{value:"ask",label:We.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:We.full(),tooltip:s("botSettings.simple.fullHint")},...B==="ask"||B==="full"?[]:[{value:B,label:We[B](),disabled:!0,tooltip:B==="custom"?s("botPanel.acts.customHint"):void 0}]],H=y=>{y===x||y!=="ask"&&y!=="full"||d({type:"updateBot",botId:t.id,patch:{approvalMode:y,applyToAllThreads:!0}})},A=!c||sa(r,o.config),h=xa(g,{turnsHere:A,canLive:!0}),T=A?null:na(r,!!ia()?.speechStart,aa(o.config)),F=ra.map(y=>({value:y.id,label:s(y.label),disabled:y.id==="turns"&&T!==null,tooltip:y.id==="turns"&&T?`${T.label}. ${T.reason}`:y.id==="live"?s("call.mode.liveHint"):oa("turns")})),_=la.map(y=>({value:y,label:s(St[y][0]),tooltip:s(St[y][1])})),K=()=>{const y=!t.notifications;y&&ha(),w({notifications:y})},Y=t.alwaysAllow??[],J=l||!!t.soulDrift,U=[...p.apps.filter(y=>y.scope!==null).map(y=>y.label),...f?vs(f,t.mcpServers,t.id).map(y=>y.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(ni,{bot:t}),e.jsx(M,{anchor:"instructions",children:J?e.jsxs(pe,{"data-panel-row":"soul",children:[e.jsx(ai,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:L})}}),e.jsx(Mr,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{m(t.id),i?.(!1)},className:oe,children:s("botSettings.simple.done")})})]}):e.jsxs("button",{type:"button","data-panel-edit":"soul","aria-label":`${s("botSettings.simple.edit")}: ${s("botSettings.simple.instructions")}`,onClick:()=>i?.(!0),className:O(Q,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Ae}),e.jsx(ne,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:ii(t.soul??"")||s("botPanel.instructionsHint",{name:L})})}),e.jsx(ke,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Ir,{bot:t}),e.jsx(M,{anchor:"approval",children:e.jsxs(pe,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Gt}),e.jsx(ne,{title:s("botSettings.simple.beforeActs",{name:L}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:L}),value:B,onChange:H,options:I})}),k.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(ca,{choice:k.choice})})]}),Y.length>0&&e.jsxs("div",{"data-panel-row":"always-allow",className:"flex min-w-0 flex-col gap-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botAccess.always.title")}),Y.map(y=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:y}),e.jsx(Me,{"data-panel-action":`always-allow:${y}`,label:s("botAccess.always.remove",{entry:y}),onClick:()=>w({alwaysAllow:Y.filter(z=>z!==y)})})]},y))]})]})}),e.jsx(Tr,{bot:t,onChange:y=>w({fallback:y})}),e.jsx(M,{anchor:"call",children:e.jsxs(pe,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Ua}),e.jsx(ne,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:da,options:F})})]})}),e.jsxs(M,{anchor:"replies",children:[e.jsxs(pe,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:pa}),e.jsx(ne,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:y=>w({replyStyle:y}),options:_})})]}),e.jsx(at,{"data-panel-row":"notifications",icon:ma,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:K})]}),e.jsxs(M,{anchor:"uses",children:[e.jsx(ee,{"data-panel-page":"apps",icon:as,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>a?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(Q,"cursor-text"),children:[e.jsx(X,{icon:Ii}),e.jsx("span",{className:"shrink-0 text-[14px] font-medium text-ink",children:s("botSettings.simple.job")}),e.jsx("input",{"data-panel-job":!0,value:P??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Je.title,onChange:y=>b(y.target.value),onBlur:D,onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),y.currentTarget.blur()):y.key==="Escape"&&P!==null&&(y.preventDefault(),y.stopPropagation(),b(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),v&&e.jsxs("a",{"data-panel-row":"slack",href:v,target:"_blank",rel:"noopener noreferrer",className:O(Q,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:ks}),e.jsx(ne,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(ls,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(ee,{"data-panel-page":"visibility",icon:Zt,title:s("botSettings.visibility.title"),value:ri(t.visibility),onClick:()=>a?.("visibility")})]}),t.yourAccess!=="view"&&!t.defaultBot&&e.jsx(Sr,{bot:t,className:"mt-3.5"}),e.jsx(oi,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(ua,{bot:t}),k.dialogs]})}const Br=5;function $r({bot:t,onChanged:n}){const{dispatch:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),[m,r]=u.useState(null),c=u.useCallback(async()=>{const[g,v]=await Promise.all([it(t.id),he(t.id)]);d(j=>g.lendingReview?{value:g.lendingReview,stale:j?.stale??!1}:null),i(v.slice(0,Br))},[t.id]);u.useEffect(()=>{c().catch(()=>{})},[c,t.busy]);const p=g=>a({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{r(g.id);try{await xs(t.id,g.id),await n()}catch(v){p(v)}finally{r(null),await c().catch(()=>{})}},k=async g=>{r("review");try{await ps(t.id,g.value.token),d(null)}catch(v){v instanceof Qt&&v.status===409?(d({...g,stale:!0}),await c().catch(()=>{})):p(v)}finally{r(null)}};return e.jsxs(e.Fragment,{children:[o&&e.jsx(Ns,{changed:o.value.changed,stale:o.stale,busy:m!==null,onReviewed:()=>{k(o)}}),e.jsx(M,{children:e.jsx(at,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>a({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(M,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(ot,{rows:l,botName:t.name,reverting:m,onRevert:g=>{f(g)}})})})]})}const Fr="flex flex-col gap-3",_t="https://www.skills.sh";function ve(t,n){return t instanceof Error&&t.message?t.message:n}function Dr({bot:t,derived:n}){const{dispatch:a}=$(),l=is(t),{servers:i,error:o}=bs(),{patch:d,canUseConnectedApps:m}=n,r=i?ji(i,t.id):[],c=new Set(vs(r,t.mcpServers,t.id).map(g=>g.name)),p=g=>{const v=va(t,l.connectedSlugs,g.slug,g.scope===null);Object.keys(v).length>0&&d(v)},f=g=>{t.busy||o||d({mcpServers:wi(r,t.mcpServers,g)})},k=m?l.phase==="loading"?s("common.checking"):l.phase==="unknown"?s("botSettings.simple.appsUnknown"):l.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[k&&e.jsx(V,{children:k}),m&&l.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Q,children:[e.jsx(ya,{card:g.card,className:"size-7 shrink-0"},`${g.card.logo}:${g.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:g.label}),e.jsx(yt,{color:t.color,checked:g.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.label}),disabled:!!t.busy,onClick:()=>p(g),className:"disabled:cursor-not-allowed"})]},g.slug))]}),(r.length>0||o)&&e.jsxs(M,{label:s("connectors.tab.mcp"),children:[o&&e.jsx(V,{children:s("botAccess.mcpRefreshError")}),r.map(g=>e.jsxs("div",{"data-simple-mcp":g.name,className:Q,children:[e.jsx(X,{icon:qa}),e.jsx(ne,{title:e.jsx("span",{className:"block truncate",children:g.name}),hint:g.enabled?g.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(yt,{color:t.color,checked:c.has(g.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.name}),disabled:!g.enabled||!!t.busy||o,onClick:()=>f(g.name),className:"disabled:cursor-not-allowed"})]},g.name))]}),e.jsx(M,{children:e.jsx(me,{"data-panel-link":"add-app",icon:we,onClick:()=>ba(a,t.id),children:s("botPanel.apps.connectAnother")})})]})}function zr({bot:t,derived:n}){const{state:a,dispatch:l}=$(),[i,o]=u.useState(()=>n.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(vi,{routines:n.botRoutines,runs:a.routineRuns,pausedBots:a.config?.pausedBots,heldBots:a.config?.heldBots,loading:a.routinesLoadState==="loading"&&n.botRoutines.length===0,error:a.routinesLoadState==="error",onOpen:o,onLogs:d=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:d.id}),onToggle:d=>l({type:"updateRoutine",routineId:d.id,patch:{enabled:!d.enabled}})}),e.jsx(M,{children:e.jsx(me,{"data-panel-action":"new-routine",icon:we,onClick:()=>o("new"),children:s("botPanel.routines.add")})}),e.jsx("p",{className:"mx-1 text-[13px] leading-normal text-ink-secondary",children:s("botPanel.routines.ask",{name:t.name})}),i&&e.jsx(Ni,{routine:i==="new"?void 0:i,bots:[t],lockedBotId:t.id,onClose:()=>o(null)},t.id)]})}function Hr({bot:t}){const n=Rs(t),[a,l]=u.useState(""),[i,o]=u.useState(null),[d,m]=u.useState(!1),[r,c]=u.useState(null),p=t.memoryEnabled!==!1,f=n.docs?Es(n.docs):null,k=n.docs?.find(b=>b.path===te)??null;u.useEffect(()=>o(null),[t.id,p]);const g=async b=>{if(d)return!1;m(!0),c(null);try{return await b()}catch(w){return c(ve(w,s("botPanel.library.memoryError"))),!1}finally{m(!1)}},v=(b,w)=>g(async()=>{const x=await rt(t.id,b.path,w,b.exists?b.hash:void 0,n.mine);return x.ok?(n.setDoc(x.doc),!0):(await n.reload(),c(s("memory.conflict.title",{name:t.name})),!1)}),j=b=>{const w=n.docs?.find(x=>x.path===b.path);w&&(b.line!==null?v(w,fr(w.text,b.line)):g(async()=>(await us(t.id,w.path,n.mine),await n.reload(),!0)))},P=async()=>{!k||!a.trim()||await v(k,gr(k.text,a))&&l("")};return p&&i?.botId===t.id?e.jsx(_r,{bot:t,doc:i.doc,mine:n.mine,onDone:b=>{b&&n.setDoc(b),o(null),c(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[p?n.error?e.jsx(V,{tone:"warn",children:s("botPanel.library.memoryError")}):f===null?e.jsx(V,{children:s("common.checking")}):f.length===0?e.jsx(V,{children:s("botPanel.memory.empty")}):f.map(b=>e.jsxs("div",{"data-memory-note":b.line??b.path,className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:b.text}),e.jsx(Me,{label:s("botPanel.memory.forget"),disabled:d,onClick:()=>j(b)})]},`${b.path}:${b.line}:${b.text}`)):e.jsx(V,{children:s("botPanel.library.memoryOff",{name:t.name})}),r&&e.jsx(V,{tone:"warn",children:r})]}),p&&e.jsxs(M,{children:[e.jsx(rs,{"data-panel-form":"memory-add",value:a,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:d||k===null,onChange:l,onSubmit:()=>{P()}}),k&&e.jsx(me,{"data-panel-link":"memory-text",icon:Ae,onClick:()=>o({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),p&&!n.mine&&e.jsx($r,{bot:t,onChanged:n.reload})]})}function _r({bot:t,doc:n,mine:a,onDone:l}){const[i,o]=u.useState({text:n.text,hash:n.hash}),[d,m]=u.useState(n.text),[r,c]=u.useState(null),[p,f]=u.useState(null),[k,g]=u.useState(!1),[v,j]=u.useState(null),P=u.useRef(!0);u.useEffect(()=>(P.current=!0,()=>{P.current=!1}),[]);const b=async x=>{g(!0),j(null);try{const C=await rt(t.id,n.path,d,x,a);if(!P.current)return;C.ok?l(C.doc):c({current:C.current,currentHash:C.currentHash})}catch(C){j(ve(C,s("botPanel.library.memoryError")))}finally{g(!1)}},w=()=>{r&&(f(x=>x===null||x===d?d:`${x}
|
|
13
|
+
`}function Es(t){return t.flatMap(n=>{const a=fr(n.text).map(i=>({path:n.path,...i}));if(a.length||n.path===te)return a;const l=n.text.split(`
|
|
14
|
+
`).map(i=>i.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:n.path,line:null,text:l}]:[]})}async function br(t,n){if(!n)return[await Te(t,te)];const a=await it(t,!0);return Promise.all([te,...a.topics.map(l=>l.path)].map(l=>Te(t,l,!0)))}function Rs(t){const n=!!$().state.config?.team,[a,l]=u.useState({botId:t.id,docs:null,error:!1}),i=t.memoryEnabled!==!1,o=async(r,c)=>{try{const p=await br(r,n);c?.()||l({botId:r,docs:p,error:!1})}catch{c?.()||l({botId:r,docs:null,error:!0})}},d=!!t.busy;u.useEffect(()=>{if(!i)return;let r=!1;return o(t.id,()=>r),()=>{r=!0}},[t.id,i,d,n]);const m=a.botId===t.id;return{docs:m?a.docs:null,error:m&&a.error,mine:n,setDoc:r=>l(c=>({botId:t.id,docs:(c.botId===t.id?c.docs??[]:[]).map(p=>p.path===r.path?r:p),error:!1})),reload:()=>o(t.id)}}function vr(t,n=Ze(t)){const a=[],l=[],i=new Set;for(const c of[...n].reverse()){const p=c.publishedPage;p?.state==="live"&&p.url&&!i.has(p.url)&&(i.add(p.url),a.push({messageId:c.id,title:p.title||p.url,url:p.url})),c.kind==="app"&&c.app?.doc&&l.push({messageId:c.id,title:c.app.title})}const o=bi(t),d=[],m=new Set;for(const c of o.values())m.has(c.file.path)||(m.add(c.file.path),d.push(c));const r=vi(t).filter(c=>!o.has(c));return{pages:a,apps:l,shared:d,unshared:r}}const kr=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Ts({bot:t,onOpen:n}){const{dispatch:a}=$(),{capabilities:l}=je(),i=Bn(),o=!es(ts,!0),d=hs(t),m=Rs(t),{pages:r,apps:c,shared:p,unshared:f}=u.useMemo(()=>vr(t),[t]),k=b=>{a({type:"focusMessage",threadId:t.threadId,messageId:b}),o&&a({type:"toggleSettings",open:!1})},g=d.skills.filter(fs).length,v=m.docs?Es(m.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?m.error?s("botPanel.memory.nothingYet"):void 0:v===0?s("botPanel.memory.nothingYet"):v===1?s("botPanel.memory.note"):s("botPanel.memory.notes",{count:v}),P=e.jsxs(M,{anchor:"keeps",children:[e.jsx(ee,{"data-panel-page":"memory",icon:Vt,title:s("botPanel.memoryRow"),value:j,onClick:()=>n("memory")}),e.jsx(ee,{"data-panel-page":"skills",icon:$n,title:s("botSettings.simple.skills"),value:d.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>n("skills")}),e.jsx(ee,{"data-panel-page":"folder",icon:Fn,title:s("computer.files.folder"),value:t.cwd?st(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>n("folder")})]});return r.length+c.length+p.length+f.length===0?e.jsxs("div",{"data-panel-tabpanel":"library",children:[e.jsx("p",{"data-panel-empty":"library",className:"px-3 py-7 text-center text-[13px] leading-[18px] text-ink-tertiary",children:s("botPanel.library.empty")}),P]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[r.length>0&&e.jsx(M,{label:s("botPanel.library.pages"),anchor:"pages",children:r.map(b=>e.jsx(ee,{"data-panel-row":"page",icon:Dn,title:e.jsx("span",{className:"block truncate",children:b.title}),hint:e.jsx("span",{className:"block truncate",children:b.url}),onClick:()=>i(b.url)},b.url))}),c.length>0&&e.jsx(M,{label:s("botPanel.library.apps"),anchor:"apps",children:c.map(b=>e.jsx(ee,{"data-panel-row":"app",icon:as,title:e.jsx("span",{className:"block truncate",children:b.title}),onClick:()=>k(b.messageId)},b.messageId))}),p.length+f.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(Ee,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[p.map(b=>e.jsx("li",{className:"min-w-0",children:e.jsx(zn,{file:b.file,message:b.message,linked:b.file.linked,className:"w-full max-w-none"})},`${b.message.messageId}:${b.file.path}`)),f.map(b=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:kr(b)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},b))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),P]})}function jr({bot:t,browserEnabled:n,onOpenBrowser:a}){const{state:l}=$(),i=nt(),o=t.browserProfile??"",d=(l.config?.browserProfiles??[]).find(p=>p.id===o),m=o==="guest",r=d?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,c=o&&!m?l.bots.filter(p=>p.browserProfile===o).map(p=>p.name):[t.name];return e.jsx(M,{anchor:"logins",children:n?m?e.jsx(V,{children:s("settings.profiles.temporaryHint")}):r?e.jsx(V,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[i!==!1&&(o===""||d)&&e.jsx(pe,{children:e.jsx(Ci,{bare:!0,target:{bot:t.id},sharedBy:c,disabled:!!t.busy},`${t.id}:${o}`)}),e.jsx(V,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(me,{"data-panel-action":"add-login",icon:we,onClick:a,children:s("botSettings.simple.addLogin")})]}):e.jsx(V,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const wr=[["all",()=>N("Tất cả","All")],["added",()=>N("Bot đang có","On this bot")],["more",()=>N("Chưa thêm","Not added")]],Nr=t=>({bundled:N("Có sẵn","Built in"),library:N("Đã tải về","Downloaded"),imported:N("Từ máy tính","From this computer")})[t],qe="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-hairline/60 bg-raised px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50";async function Dt(t,n){const a=await fetch(t,n===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)}),l=await a.json().catch(()=>({}));if(!a.ok)throw new Error(l.error??N(`Lỗi ${a.status}`,`Error ${a.status}`));return l.skills??[]}function Sr({botId:t,botName:n,onClose:a,onOpenSettings:l}){const[i,o]=u.useState(null),[d,m]=u.useState(""),[r,c]=u.useState("all"),[p,f]=u.useState(""),[k,g]=u.useState(""),v=`/api/limix/skill-store/${encodeURIComponent(t)}`;u.useEffect(()=>{let x=!1;return Dt(v).then(C=>{x||o(C)}).catch(C=>{x||(o([]),g(C.message))}),()=>{x=!0}},[v]),u.useEffect(()=>{const x=C=>{C.key==="Escape"&&a()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a]);const j=u.useMemo(()=>{const x=d.trim().toLowerCase();return(i??[]).filter(C=>(r==="all"||(r==="added"?C.added:!C.added))&&(!x||`${C.name} ${C.description}`.toLowerCase().includes(x)))},[i,d,r]),P=async(x,C)=>{if(!p){f(x.name),g("");try{o(await Dt(v,{name:x.name,kind:x.kind,add:C}))}catch(L){g(L instanceof Error?L.message:N("Không đổi được kĩ năng này.","Couldn't change this skill."))}finally{f("")}}},b=(i??[]).filter(x=>x.added).length,w=e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:x=>x.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"limix-skill-store-title",className:"flex max-h-full w-full max-w-[640px] flex-col rounded-2xl border border-hairline/50 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pb-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"limix-skill-store-title",className:"text-[17px] font-semibold text-ink",children:N("Kho Kĩ Năng (Skills)","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:N(`Chọn kĩ năng riêng cho ${n}. Chỉ những kĩ năng được thêm mới nằm trong lời nhắc của bot, nên bot không bị quá tải. Gõ /tên-kĩ-năng trong chat để gọi.`,`Pick skills just for ${n}. Only added skills go into the bot's prompt, so it never gets overloaded. Type /skill-name in chat to call one.`)})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":N("Đóng","Close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(et,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 pb-3",children:[e.jsxs("label",{className:"flex min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsx(Xe,{size:14,className:"text-ink-tertiary"}),e.jsx("input",{value:d,onChange:x=>m(x.target.value),placeholder:N("Tìm kĩ năng…","Search skills…"),"aria-label":N("Tìm kĩ năng","Search skills"),className:"w-full bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":N("Lọc kĩ năng","Filter skills"),children:wr.map(([x,C])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":r===x,onClick:()=>c(x),className:`rounded-lg px-2.5 py-1.5 text-[13px] ${r===x?"bg-raised text-ink":"text-ink-secondary hover:bg-raised"}`,children:[C(),x==="added"&&i?` ${b}`:""]},x))})]}),k&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:k}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:i===null?e.jsxs("p",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(Oe,{size:14,className:"animate-spin"}),N("Đang tải kho…","Loading the store…")]}):j.length===0?e.jsx("p",{className:"py-6 text-[13px] text-ink-secondary",children:i.length===0?N("Kho chưa có kĩ năng nào.","The store has no skills yet."):N("Không có kĩ năng khớp.","No matching skills.")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline/40 rounded-xl border border-hairline/40",children:j.map(x=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[13px] text-ink",children:x.name}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:x.core?N("Kĩ năng gốc","Core skill"):Nr(x.kind)}),x.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[x.warnings," ",N("cảnh báo","warnings")]})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] leading-relaxed text-ink-secondary",children:x.description})]}),x.core?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(dt,{size:14}),N("Luôn bật","Always on")]}):x.added?e.jsxs("button",{type:"button",className:qe,disabled:!!p,onClick:()=>{P(x,!1)},"aria-label":N(`Bỏ ${x.name} khỏi bot`,`Remove ${x.name} from this bot`),children:[p===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(dt,{size:14}),N("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:qe,disabled:!!p||!x.ready,onClick:()=>{P(x,!0)},"aria-label":N(`Thêm ${x.name} cho bot`,`Add ${x.name} to this bot`),children:[p===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(we,{size:14}),N("Thêm","Add")]})]},`${x.kind}:${x.name}`))})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 pb-5 pt-3",children:[e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:N('Bấm "Đã thêm" để bỏ kĩ năng khỏi bot này.','Press "Added" to remove a skill from this bot.')}),e.jsx("button",{type:"button",className:qe,onClick:l,children:N("Tải thêm kĩ năng","Get more skills")})]})]})});return typeof document>"u"?w:cs.createPortal(w,document.body)}const be=()=>window.ogb?.limixMessenger,zt=[{kind:"telegram",label:"Telegram",placeholder:"123456789:AA…",howTo:()=>N("Tạo bot với @BotFather (lệnh /newbot), rồi dán token vào đây.","Make a bot with @BotFather (/newbot), then paste its token here."),where:t=>`@${t.username}`,linkFrom:t=>N(`Nhắn cho @${t.username}: `,`Send @${t.username}: `)},{kind:"discord",label:"Discord",placeholder:"MTA…",howTo:()=>N("Vào discord.com/developers → New Application → Bot → Reset Token, dán token vào đây. Mời bot vào server: OAuth2 → URL Generator → chọn bot và quyền Send Messages. Trong server, gọi bot bằng @tên-bot.","At discord.com/developers: New Application → Bot → Reset Token, paste it here. Invite it with OAuth2 → URL Generator (bot, Send Messages). In a server, call it with @its-name."),where:t=>`@${t.username}`,linkFrom:()=>N("Nhắn riêng cho bot trên Discord: ","Send the bot a direct message on Discord: ")},{kind:"zalo",label:"Zalo",howTo:()=>N("Quét mã QR bằng ứng dụng Zalo của tài khoản sẽ làm bot.","Scan the QR code with the Zalo app of the account that will be the bot."),note:()=>N("Nên dùng tài khoản Zalo phụ: đây là cách đăng nhập không chính thức (như Zalo Web), Zalo có thể khoá tài khoản. Mở Zalo Web bằng tài khoản này ở nơi khác sẽ ngắt bot.","Use a spare Zalo account: this sign-in is unofficial (like Zalo Web) and Zalo may lock the account. Opening Zalo Web with it elsewhere disconnects the bot."),where:t=>t.name||t.username||"Zalo",linkFrom:()=>N("Từ Zalo của bạn, nhắn cho tài khoản bot: ","From your own Zalo, message the bot's account: ")},{kind:"facebook",label:"Facebook Page",placeholder:"EAA…",howTo:()=>N("Dán Page Access Token: developers.facebook.com → tạo app → thêm Messenger → Access Tokens → chọn Page → Generate token.","Paste a Page access token: developers.facebook.com → create an app → add Messenger → Access Tokens → pick the Page → Generate token."),note:()=>N("Bot trả lời khách nhắn vào Page sau khoảng 10–20 giây. Muốn trả lời mọi khách, app Meta cần được duyệt quyền pages_messaging.","The bot answers people who message the Page within about 10–20 seconds. To answer everyone, the Meta app needs pages_messaging approved."),where:t=>t.name||"Page",linkFrom:()=>N("Từ Facebook cá nhân, nhắn cho Page: ","From your own Facebook, message the Page: ")},{kind:"messenger",label:"Messenger",howTo:()=>N("Đăng nhập Facebook trong cửa sổ của app (nhập cả mã PIN khôi phục tin nhắn nếu Facebook hỏi), rồi đóng cửa sổ. App giữ một cửa sổ Facebook ẩn, đọc tin mới và gõ câu trả lời.","Sign in to Facebook in the app's window (enter the chat-restore PIN if Facebook asks), then close it. The app keeps a hidden Facebook window that reads new messages and types the replies."),note:()=>N("Thử nghiệm, tài khoản cá nhân. Chỉ chạy khi app đang mở trên máy này. Nên dùng tài khoản phụ: Facebook không có cách chính thức cho tài khoản cá nhân và có thể khoá tài khoản. Ai nhắn cũng được trả lời ở chế độ an toàn.","Beta, personal accounts. Runs only while the app is open on this computer. Use a spare account: Facebook has no official way for personal accounts and may lock it. Everyone is answered in safe mode."),where:()=>N("tài khoản Facebook đã đăng nhập","the signed-in Facebook account"),linkFrom:()=>""}],ie="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50";function Cr({bot:t,className:n}){const[a,l]=u.useState("telegram"),[i,o]=u.useState({});u.useEffect(()=>{let r=!0;o({});for(const c of zt.filter(p=>p.kind!=="messenger"||be()))Z(`/api/bots/${t.id}/${c.kind}`).then(p=>{r&&o(f=>({...f,[c.kind]:p}))}).catch(()=>{});return()=>{r=!1}},[t.id]);const d=zt.filter(r=>r.kind!=="messenger"||be()),m=d.find(r=>r.kind===a);return e.jsxs("div",{className:O("rounded-xl bg-card p-4",n),"data-testid":"channels-card",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:N("Kênh chat","Chat channels")}),e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:N(`Cho ${t.name} trả lời tin nhắn ngoài app.`,`Let ${t.name} answer messages outside the app.`)}),e.jsx("div",{role:"tablist",className:"mt-3 flex flex-wrap gap-1.5",children:d.map(r=>{const c=i[r.kind];return e.jsxs("button",{type:"button",role:"tab","aria-selected":a===r.kind,onClick:()=>l(r.kind),"data-testid":`channel-tab-${r.kind}`,className:O("flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-[13px]",a===r.kind?"bg-control text-ink":"text-ink-secondary hover:bg-raised-hover"),children:[c?.connected&&e.jsx("span",{className:O("size-1.5 rounded-full",c.error?"bg-danger":c.enabled?"bg-success":"bg-ink-tertiary")}),r.label]},r.kind)})}),e.jsx(Pr,{bot:t,channel:m,view:i[a],onView:r=>o(c=>({...c,[a]:r}))},`${t.id}:${a}`)]})}function Pr({bot:t,channel:n,view:a,onView:l}){const i=`/api/bots/${t.id}/${n.kind}`,[o,d]=u.useState(""),[m,r]=u.useState(null),[c,p]=u.useState(!1),[f,k]=u.useState(null),g=!!(a?.login&&!a.login.error&&!a.connected);u.useEffect(()=>{if(!g)return;const P=setInterval(()=>{Z(i).then(l).catch(()=>{})},2e3);return()=>clearInterval(P)},[g,i,l]);const v=async P=>{p(!0),k(null);try{const{code:b,...w}=await P();l(w),b&&r(b)}catch(b){k(b instanceof Error?b.message:String(b))}finally{p(!1)}},j=(P,b="")=>v(()=>Z(`${i}${b}`,{method:"POST",body:JSON.stringify(P??{})}));return a?e.jsxs("div",{className:"mt-3 text-[13px]","data-testid":`channel-${n.kind}`,children:[!a.connected&&e.jsxs("div",{className:"flex flex-col gap-2 text-ink-secondary",children:[e.jsx("span",{children:n.howTo()}),n.note&&e.jsx("span",{className:"text-[12px]",children:n.note()}),n.placeholder?e.jsxs("form",{className:"flex gap-2",onSubmit:P=>{P.preventDefault(),o.trim()&&j({token:o.trim()}).then(()=>d(""))},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:o,onChange:P=>d(P.target.value),placeholder:n.placeholder,"aria-label":N(`Token ${n.label}`,`${n.label} token`),className:"min-w-0 flex-1 rounded-lg bg-inset px-3 py-1.5 font-mono text-[13px] text-ink outline-none","data-testid":`channel-token-${n.kind}`}),e.jsx("button",{type:"submit",disabled:c||!o.trim(),className:ie,"data-testid":`channel-connect-${n.kind}`,children:N("Kết nối","Connect")})]}):n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:c,onClick:()=>{v(async()=>await be().signIn(t.id))},"data-testid":"channel-signin-messenger",children:N("Mở cửa sổ đăng nhập Facebook","Open the Facebook sign-in window")}):e.jsx(Or,{view:a,busy:c,start:()=>{j({},"/login")},cancel:()=>{v(()=>Z(`${i}/login`,{method:"DELETE"}))}})]}),a.connected&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsx("span",{children:N(`${t.name} trả lời tin nhắn gửi tới ${n.where(a)}.`,`${t.name} answers messages sent to ${n.where(a)}.`)}),e.jsx(ye,{"aria-label":N(`Bật ${n.label}`,`${n.label} on`),checked:a.enabled===!0,disabled:c,onClick:()=>{j({enabled:!a.enabled})},"data-testid":`channel-switch-${n.kind}`})]}),n.note&&(n.kind==="facebook"||n.kind==="messenger")&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:n.note()}),n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ie,"self-start"),onClick:()=>{be()?.show(t.id)},children:N("Mở cửa sổ Messenger của bot","Show the bot's Messenger window")}):a.owner?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-ink-secondary",children:[e.jsx("span",{children:N(`Chủ bot: ${a.owner}. Nhắn riêng ở đó như nhắn trong app, toàn quyền.`,`Owner: ${a.owner}. Direct messages there work as in the app, with full access.`)}),e.jsx("button",{type:"button",className:ie,disabled:c,onClick:()=>{j({},"/unlink")},children:N("Bỏ liên kết","Unlink")})]}):e.jsxs("div",{className:"flex flex-col gap-1.5 text-ink-secondary",children:[e.jsx("span",{children:N("Liên kết tài khoản của bạn để nhắn với bot như trong app:","Link your own account to talk to the bot as in the app:")}),m?e.jsxs("span",{className:"text-ink","data-testid":`channel-code-${n.kind}`,children:[n.linkFrom(a),e.jsxs("code",{className:"rounded bg-inset px-1.5 py-0.5 font-mono",children:["/link ",m]}),N(" (hết hạn sau 15 phút)"," (expires in 15 minutes)")]}):e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:c,onClick:()=>{j({},"/link")},"data-testid":`channel-link-${n.kind}`,children:N("Tạo mã liên kết","Make a link code")})]}),e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời cả người khác","Answer other people too"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:n.kind==="zalo"?N("Người khác có thể nhắn riêng cho bot với quyền khách.","Other people can message the bot privately as guests."):N("Người khác và nhóm nhắn được bot ở chế độ an toàn: không dùng công cụ, không thấy cuộc trò chuyện của bạn.","Others and groups can write to the bot in safe mode: no tools, none of your conversations.")})]}),e.jsx(ye,{"aria-label":N("Trả lời cả người khác","Answer other people too"),checked:a.access==="everyone",disabled:c,onClick:()=>{j({access:a.access==="everyone"?"owner":"everyone",...a.groupMentions!==void 0?{groupMentions:a.groupMentions}:{}})},"data-testid":`channel-everyone-${n.kind}`})]}),n.kind==="zalo"&&e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:N("Mọi thành viên đều có thể gọi bot. Bot trả lời trong nhóm với quyền khách, kể cả khi chủ bot gọi.","Anyone in the group can mention the bot. Group replies use guest access, including when the owner mentions it.")})]}),e.jsx(ye,{"aria-label":N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),checked:a.groupMentions??a.access==="everyone",disabled:c,onClick:()=>{j({groupMentions:!(a.groupMentions??a.access==="everyone")})},"data-testid":"channel-zalo-group-mentions"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",className:ie,disabled:c,onClick:()=>{v(async()=>{const P=await Z(i,{method:"DELETE"});return n.kind==="messenger"&&await be()?.signOut(t.id),P})},"data-testid":`channel-remove-${n.kind}`,children:N("Gỡ kết nối","Disconnect")})})]}),(f||a.error)&&e.jsx("div",{role:"alert",className:"mt-2 text-[13px] text-danger",children:f??a.error})]}):e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:"…"})}function Or({view:t,busy:n,start:a,cancel:l}){const i=t.login;return!i||i.error?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[i?.error&&e.jsx("span",{className:"text-danger",children:i.error}),e.jsx("button",{type:"button",className:O(ie,"self-start"),disabled:n,onClick:a,"data-testid":"channel-qr-zalo",children:N("Tạo mã QR đăng nhập","Show a sign-in QR code")})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[i.qr?e.jsx("img",{src:i.qr,alt:N("Mã QR đăng nhập Zalo","Zalo sign-in QR code"),className:"size-44 rounded-lg bg-white p-1.5","data-testid":"channel-qr-image"}):e.jsx("div",{className:"flex size-44 items-center justify-center rounded-lg bg-inset",children:"…"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-ink",children:i.scanned?N(`${i.scanned} đã quét. Xác nhận đăng nhập trong ứng dụng Zalo.`,`${i.scanned} scanned it. Confirm the sign-in in the Zalo app.`):N("Mở Zalo trên điện thoại → biểu tượng quét mã → quét mã này.","Open Zalo on the phone → scan icon → scan this code.")}),e.jsx("button",{type:"button",className:O(ie,"self-start"),onClick:l,children:N("Huỷ","Cancel")})]})]})}const Er=5,Rr={instanceId:"",model:""},Is=(t,n)=>`${t}\0${n}`,Tr=new Set;function Ht({bot:t,current:n,exclude:a,onPick:l,label:i,title:o,buttonRef:d,className:m,children:r,...c}){const{state:p,dispatch:f,refreshInstances:k,refreshModels:g}=$(),[v,j]=u.useState(!1),[P,b]=u.useState(""),[w,x]=u.useState(()=>new Set),[C,L]=u.useState(!1),[D,B]=u.useState(null),[I,H]=u.useState(null),A=u.useRef(null),h=d??A,T=u.useRef(null),F=u.useRef(null),_=u.useRef(!1),K=u.useId(),Y=Ga(v),J=u.useRef({contains:E=>[h.current,T.current].some(q=>q?.contains(E))});Wn(v,J,()=>j(!1)),u.useLayoutEffect(()=>{if(!v)return;const E=q=>{if(q?.type==="scroll"&&q.target instanceof Node&&T.current?.contains(q.target))return;const G=h.current?.getBoundingClientRect(),W=T.current;!G||!W||H(ce=>Zn(G,{width:ft,height:W.offsetHeight},{width:window.innerWidth,height:window.innerHeight},ce??void 0))};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[v,h]),u.useEffect(()=>{if(!v||!I||!_.current)return;_.current=!1;const E=T.current;(E?.querySelector("[data-menu-search]")??E?.querySelector("[data-current-model]")??E?.querySelector("[data-menu-row]:not(:disabled)")??E)?.focus({preventScroll:!0})},[v,I]);const U=E=>{j(!1),E&&h.current?.focus({preventScroll:!0})},y=()=>{b(""),x(new Set),H(null),_.current=!0,j(!0),L(!0),k().catch(()=>{}).finally(()=>L(!1))},z=E=>{D||(B(E.instanceId),g(E.instanceId).catch(()=>{}).finally(()=>B(null)))},le=()=>{U(!1),f({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const E=Yn(p.instances,n?.instanceId).flatMap(W=>{const ce=W.models.options.filter(Ne=>!a.has(Is(W.instanceId,Ne.id)));return ce.length===W.models.options.length?[W]:ce.length?[{...W,models:{...W.models,options:ce}}]:[]}),q=Qn({instances:p.instances,listed:E,selection:n??Rr,bot:{name:t.name,selection:t.modelSelection},query:P,expanded:w,probing:Tr,loading:C,refreshing:D}),G=q.groups.map(W=>W.instance.instanceId===t.modelSelection.instanceId?{...W,note:s("botPanel.backups.sameAccount")}:W);return{...q,groups:G,...n?{}:{current:null}}},ge=E=>{if(!(E.nativeEvent.isComposing||E.defaultPrevented)){if(E.key!=="Escape")return Jn(E,{query:P,typed:F,close:()=>U(!0)});E.preventDefault(),E.stopPropagation(),P?b(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...c,"aria-label":i,title:o,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?K:void 0,onClick:()=>v?U(!1):y(),onKeyDown:E=>{E.key==="Escape"&&v?(E.preventDefault(),E.stopPropagation(),U(!1)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&!v&&(E.preventDefault(),y())},className:m,children:r}),Y.shown&&cs.createPortal(e.jsx("div",{ref:T,id:K,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...Y.exitProps,onKeyDown:ge,onPointerMove:Vn,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??ft,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",Y.className),children:e.jsx(Gn,{menu:ue(),query:P,bot:t,botModel:{label:"",title:""},idPrefix:K,onQuery:b,onPick:(E,q)=>{E.policy||(l({instanceId:E.instanceId,model:q}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:E=>x(q=>{const G=new Set(q);return G.delete(E.instanceId)||G.add(E.instanceId),G}),onSetUp:le,onCheckAgain:z,onManage:le})}),document.body)]})}function Ir({bot:t,onChange:n}){const{state:a}=$(),l=t.fallback??[],i=u.useRef(null),o=m=>new Set([t.modelSelection,...l.filter((r,c)=>c!==m)].map(r=>Is(r.instanceId,r.model))),d=m=>{const r=a.instances.find(f=>f.instanceId===m.instanceId),c=r?.models.options.find(f=>f.id===m.model),p=Kn(r,m.model);return{instance:r,name:p,short:r&&c?Un(c.label,qn(r)):p}};return e.jsx(M,{anchor:"backups",children:e.jsxs(pe,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Hn}),e.jsx(ne,{title:s("botPanel.backups.title")})]}),e.jsx("p",{className:"-mt-1 pl-[38px] text-[13px] leading-[1.35] text-ink-secondary",children:s("botPanel.backups.hint",{name:t.name})}),l.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:l.map((m,r)=>{const{instance:c,name:p,short:f}=d(m);return e.jsxs("li",{"data-backup":m.instanceId,className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"w-3 shrink-0 text-[12px] tabular-nums text-ink-tertiary","aria-hidden":"true",children:r+1}),e.jsxs(Ht,{bot:t,current:m,exclude:o(r),onPick:k=>n(l.map((g,v)=>v===r?k:g)),label:s("botPanel.backups.row",{position:r+1,model:p}),title:c?`${c.displayName} · ${p}`:p,"data-panel-action":"backup-change",className:"group flex h-8 min-w-0 flex-1 items-center gap-2 rounded-[8px] bg-ink/[0.04] pl-2.5 pr-2 text-left text-[13px] text-ink hover:bg-ink/[0.07] aria-expanded:bg-ink/[0.08]",children:[c?e.jsx(_n,{instance:c,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),!c&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(fe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Me,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:p}),onClick:()=>{n(l.filter((k,g)=>g!==r)),i.current?.focus({preventScroll:!0})}})]},r)})}),l.length<Er&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(Ht,{bot:t,current:null,exclude:o(null),onPick:m=>n([...l,m]),label:s("model.fallback.add"),buttonRef:i,"data-panel-action":"backup-add",className:O(oe,"aria-expanded:bg-raised-hover"),children:[e.jsx(we,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Ar({bot:t}){const{dispatch:n}=$(),[a,l]=u.useState(!1),[i,o]=u.useState(!1),[d,m]=u.useState(0),r=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(u.useEffect(()=>{if(!r)return;let p=!0;return Z(`/api/bots/${t.id}/system-prompt`).then(f=>{p&&l(f.heavy===!0)},()=>{}),()=>{p=!1}},[t.id,r,d]),!r||!a)return null;const c=async()=>{o(!0);try{await ms(t.id)}catch(p){n({type:"error",message:p instanceof Error&&p.message?p.message:s("common.tryAgain")})}finally{o(!1),m(p=>p+1)}};return e.jsx(M,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Q,children:[e.jsx(X,{icon:Xn}),e.jsx(ne,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:i,onClick:()=>{c()},className:oe,children:i?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Mr=5;function Lr({bot:t}){const{dispatch:n,flushBotPatches:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),m=u.useCallback(()=>Nt(t.id).then(c=>i(c.rows.slice(0,Mr)),()=>{}),[t.id]);if(u.useEffect(()=>{m()},[m,t.soul]),!l.length)return null;const r=async c=>{if(!o){d(c.id);try{await a(t.id);const{revision:p}=await Nt(t.id);await ni(t.id,c.id,p)}catch(p){n({type:"error",message:p instanceof Error&&p.message?p.message:s("botOverview.undoFailed")})}finally{d(null),await m()}}};return e.jsxs("div",{"data-panel-row":"soul-changes",className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("memory.changes")}),e.jsx(ot,{rows:l,botName:t.name,reverting:o,onRevert:c=>{r(c)}})]})}const We={ask:()=>s("botSettings.simple.ask"),full:()=>s("botSettings.simple.justDoIt"),auto:()=>s("botSettings.simple.decide"),edits:()=>s("approvalMode.edits.label"),custom:()=>s("botPanel.acts.custom")};function Br({bot:t,derived:n,onOpen:a,editingInstructions:l=!1,onEditInstructions:i}){const{state:o,dispatch:d,flushBotPatches:m}=$(),{capabilities:r,ready:c}=je(),p=is(t),{servers:f}=bs(),k=ea(Ge(t)),g=ta(),v=js(t.id),j=gs(),[P,b]=u.useState(null),{patch:w,approvalMode:x,engine:C}=n,L=t.name,D=()=>{P!==null&&P.trim()!==t.title.trim()&&w({title:P.trim()}),b(null)},B=C?.driverKind==="antigravityAgent"&&x==="auto"?"ask":x,I=[{value:"ask",label:We.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:We.full(),tooltip:s("botSettings.simple.fullHint")},...B==="ask"||B==="full"?[]:[{value:B,label:We[B](),disabled:!0,tooltip:B==="custom"?s("botPanel.acts.customHint"):void 0}]],H=y=>{y===x||y!=="ask"&&y!=="full"||d({type:"updateBot",botId:t.id,patch:{approvalMode:y,applyToAllThreads:!0}})},A=!c||sa(r,o.config),h=xa(g,{turnsHere:A,canLive:!0}),T=A?null:na(r,!!ia()?.speechStart,aa(o.config)),F=ra.map(y=>({value:y.id,label:s(y.label),disabled:y.id==="turns"&&T!==null,tooltip:y.id==="turns"&&T?`${T.label}. ${T.reason}`:y.id==="live"?s("call.mode.liveHint"):oa("turns")})),_=la.map(y=>({value:y,label:s(St[y][0]),tooltip:s(St[y][1])})),K=()=>{const y=!t.notifications;y&&ha(),w({notifications:y})},Y=t.alwaysAllow??[],J=l||!!t.soulDrift,U=[...p.apps.filter(y=>y.scope!==null).map(y=>y.label),...f?vs(f,t.mcpServers,t.id).map(y=>y.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(ai,{bot:t}),e.jsx(M,{anchor:"instructions",children:J?e.jsxs(pe,{"data-panel-row":"soul",children:[e.jsx(ii,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:L})}}),e.jsx(Lr,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{m(t.id),i?.(!1)},className:oe,children:s("botSettings.simple.done")})})]}):e.jsxs("button",{type:"button","data-panel-edit":"soul","aria-label":`${s("botSettings.simple.edit")}: ${s("botSettings.simple.instructions")}`,onClick:()=>i?.(!0),className:O(Q,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Ae}),e.jsx(ne,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:ri(t.soul??"")||s("botPanel.instructionsHint",{name:L})})}),e.jsx(ke,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Ar,{bot:t}),e.jsx(M,{anchor:"approval",children:e.jsxs(pe,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Gt}),e.jsx(ne,{title:s("botSettings.simple.beforeActs",{name:L}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:L}),value:B,onChange:H,options:I})}),k.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(ca,{choice:k.choice})})]}),Y.length>0&&e.jsxs("div",{"data-panel-row":"always-allow",className:"flex min-w-0 flex-col gap-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botAccess.always.title")}),Y.map(y=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:y}),e.jsx(Me,{"data-panel-action":`always-allow:${y}`,label:s("botAccess.always.remove",{entry:y}),onClick:()=>w({alwaysAllow:Y.filter(z=>z!==y)})})]},y))]})]})}),e.jsx(Ir,{bot:t,onChange:y=>w({fallback:y})}),e.jsx(M,{anchor:"call",children:e.jsxs(pe,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:qa}),e.jsx(ne,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:da,options:F})})]})}),e.jsxs(M,{anchor:"replies",children:[e.jsxs(pe,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:pa}),e.jsx(ne,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:y=>w({replyStyle:y}),options:_})})]}),e.jsx(at,{"data-panel-row":"notifications",icon:ma,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:K})]}),e.jsxs(M,{anchor:"uses",children:[e.jsx(ee,{"data-panel-page":"apps",icon:as,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>a?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(Q,"cursor-text"),children:[e.jsx(X,{icon:Ai}),e.jsx("span",{className:"shrink-0 text-[14px] font-medium text-ink",children:s("botSettings.simple.job")}),e.jsx("input",{"data-panel-job":!0,value:P??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Je.title,onChange:y=>b(y.target.value),onBlur:D,onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),y.currentTarget.blur()):y.key==="Escape"&&P!==null&&(y.preventDefault(),y.stopPropagation(),b(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),v&&e.jsxs("a",{"data-panel-row":"slack",href:v,target:"_blank",rel:"noopener noreferrer",className:O(Q,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:ks}),e.jsx(ne,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(ls,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(ee,{"data-panel-page":"visibility",icon:Zt,title:s("botSettings.visibility.title"),value:oi(t.visibility),onClick:()=>a?.("visibility")})]}),t.yourAccess!=="view"&&!t.defaultBot&&e.jsx(Cr,{bot:t,className:"mt-3.5"}),e.jsx(li,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(ua,{bot:t}),k.dialogs]})}const $r=5;function Fr({bot:t,onChanged:n}){const{dispatch:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),[m,r]=u.useState(null),c=u.useCallback(async()=>{const[g,v]=await Promise.all([it(t.id),he(t.id)]);d(j=>g.lendingReview?{value:g.lendingReview,stale:j?.stale??!1}:null),i(v.slice(0,$r))},[t.id]);u.useEffect(()=>{c().catch(()=>{})},[c,t.busy]);const p=g=>a({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{r(g.id);try{await xs(t.id,g.id),await n()}catch(v){p(v)}finally{r(null),await c().catch(()=>{})}},k=async g=>{r("review");try{await ps(t.id,g.value.token),d(null)}catch(v){v instanceof Qt&&v.status===409?(d({...g,stale:!0}),await c().catch(()=>{})):p(v)}finally{r(null)}};return e.jsxs(e.Fragment,{children:[o&&e.jsx(Ns,{changed:o.value.changed,stale:o.stale,busy:m!==null,onReviewed:()=>{k(o)}}),e.jsx(M,{children:e.jsx(at,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>a({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(M,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(ot,{rows:l,botName:t.name,reverting:m,onRevert:g=>{f(g)}})})})]})}const Dr="flex flex-col gap-3",_t="https://www.skills.sh";function ve(t,n){return t instanceof Error&&t.message?t.message:n}function zr({bot:t,derived:n}){const{dispatch:a}=$(),l=is(t),{servers:i,error:o}=bs(),{patch:d,canUseConnectedApps:m}=n,r=i?wi(i,t.id):[],c=new Set(vs(r,t.mcpServers,t.id).map(g=>g.name)),p=g=>{const v=ka(t,l.connectedSlugs,g.slug,g.scope===null);Object.keys(v).length>0&&d(v)},f=g=>{t.busy||o||d({mcpServers:Ni(r,t.mcpServers,g)})},k=m?l.phase==="loading"?s("common.checking"):l.phase==="unknown"?s("botSettings.simple.appsUnknown"):l.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[k&&e.jsx(V,{children:k}),m&&l.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Q,children:[e.jsx(ba,{card:g.card,className:"size-7 shrink-0"},`${g.card.logo}:${g.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:g.label}),e.jsx(yt,{color:t.color,checked:g.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.label}),disabled:!!t.busy,onClick:()=>p(g),className:"disabled:cursor-not-allowed"})]},g.slug))]}),(r.length>0||o)&&e.jsxs(M,{label:s("connectors.tab.mcp"),children:[o&&e.jsx(V,{children:s("botAccess.mcpRefreshError")}),r.map(g=>e.jsxs("div",{"data-simple-mcp":g.name,className:Q,children:[e.jsx(X,{icon:Wa}),e.jsx(ne,{title:e.jsx("span",{className:"block truncate",children:g.name}),hint:g.enabled?g.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(yt,{color:t.color,checked:c.has(g.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.name}),disabled:!g.enabled||!!t.busy||o,onClick:()=>f(g.name),className:"disabled:cursor-not-allowed"})]},g.name))]}),e.jsx(M,{children:e.jsx(me,{"data-panel-link":"add-app",icon:we,onClick:()=>va(a,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Hr({bot:t,derived:n}){const{state:a,dispatch:l}=$(),[i,o]=u.useState(()=>n.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(ki,{routines:n.botRoutines,runs:a.routineRuns,pausedBots:a.config?.pausedBots,heldBots:a.config?.heldBots,loading:a.routinesLoadState==="loading"&&n.botRoutines.length===0,error:a.routinesLoadState==="error",onOpen:o,onLogs:d=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:d.id}),onToggle:d=>l({type:"updateRoutine",routineId:d.id,patch:{enabled:!d.enabled}})}),e.jsx(M,{children:e.jsx(me,{"data-panel-action":"new-routine",icon:we,onClick:()=>o("new"),children:s("botPanel.routines.add")})}),e.jsx("p",{className:"mx-1 text-[13px] leading-normal text-ink-secondary",children:s("botPanel.routines.ask",{name:t.name})}),i&&e.jsx(Si,{routine:i==="new"?void 0:i,bots:[t],lockedBotId:t.id,onClose:()=>o(null)},t.id)]})}function _r({bot:t}){const n=Rs(t),[a,l]=u.useState(""),[i,o]=u.useState(null),[d,m]=u.useState(!1),[r,c]=u.useState(null),p=t.memoryEnabled!==!1,f=n.docs?Es(n.docs):null,k=n.docs?.find(b=>b.path===te)??null;u.useEffect(()=>o(null),[t.id,p]);const g=async b=>{if(d)return!1;m(!0),c(null);try{return await b()}catch(w){return c(ve(w,s("botPanel.library.memoryError"))),!1}finally{m(!1)}},v=(b,w)=>g(async()=>{const x=await rt(t.id,b.path,w,b.exists?b.hash:void 0,n.mine);return x.ok?(n.setDoc(x.doc),!0):(await n.reload(),c(s("memory.conflict.title",{name:t.name})),!1)}),j=b=>{const w=n.docs?.find(x=>x.path===b.path);w&&(b.line!==null?v(w,gr(w.text,b.line)):g(async()=>(await us(t.id,w.path,n.mine),await n.reload(),!0)))},P=async()=>{!k||!a.trim()||await v(k,yr(k.text,a))&&l("")};return p&&i?.botId===t.id?e.jsx(Kr,{bot:t,doc:i.doc,mine:n.mine,onDone:b=>{b&&n.setDoc(b),o(null),c(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[p?n.error?e.jsx(V,{tone:"warn",children:s("botPanel.library.memoryError")}):f===null?e.jsx(V,{children:s("common.checking")}):f.length===0?e.jsx(V,{children:s("botPanel.memory.empty")}):f.map(b=>e.jsxs("div",{"data-memory-note":b.line??b.path,className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:b.text}),e.jsx(Me,{label:s("botPanel.memory.forget"),disabled:d,onClick:()=>j(b)})]},`${b.path}:${b.line}:${b.text}`)):e.jsx(V,{children:s("botPanel.library.memoryOff",{name:t.name})}),r&&e.jsx(V,{tone:"warn",children:r})]}),p&&e.jsxs(M,{children:[e.jsx(rs,{"data-panel-form":"memory-add",value:a,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:d||k===null,onChange:l,onSubmit:()=>{P()}}),k&&e.jsx(me,{"data-panel-link":"memory-text",icon:Ae,onClick:()=>o({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),p&&!n.mine&&e.jsx(Fr,{bot:t,onChanged:n.reload})]})}function Kr({bot:t,doc:n,mine:a,onDone:l}){const[i,o]=u.useState({text:n.text,hash:n.hash}),[d,m]=u.useState(n.text),[r,c]=u.useState(null),[p,f]=u.useState(null),[k,g]=u.useState(!1),[v,j]=u.useState(null),P=u.useRef(!0);u.useEffect(()=>(P.current=!0,()=>{P.current=!1}),[]);const b=async x=>{g(!0),j(null);try{const C=await rt(t.id,n.path,d,x,a);if(!P.current)return;C.ok?l(C.doc):c({current:C.current,currentHash:C.currentHash})}catch(C){j(ve(C,s("botPanel.library.memoryError")))}finally{g(!1)}},w=()=>{r&&(f(x=>x===null||x===d?d:`${x}
|
|
15
15
|
|
|
16
|
-
${d}`),o({text:r.current,hash:r.currentHash}),m(r.current),c(null))};return e.jsx(M,{children:e.jsxs(pe,{"data-panel-row":"memory-text",children:[r&&e.jsx(Ss,{botName:t.name,busy:k,onReload:w,onOverwrite:()=>{b(r.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(Qe,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:d,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:x=>m(x.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),p!==null&&e.jsxs("div",{"data-memory-draft":"",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:p}),e.jsx("button",{type:"button",className:O(oe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:oe,disabled:k,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:oe,disabled:k||d===i.text,onClick:()=>{b(i.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Kr({bot:t}){const{request:n}=fa(),{state:a,dispatch:l}=$(),i=hs(t),[o,d]=u.useState(""),[m,r]=u.useState(!1),[c,p]=u.useState([]),f=ga(a.config),k=async x=>{if(!i.working&&window.confirm(s(x.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:x.name}))){i.setWorking(x.name),i.setError("");try{await n(`/api/bots/${t.id}/skills/${encodeURIComponent(x.name)}`,{method:"DELETE"}),await i.refresh()}catch(C){i.setError(ve(C,s("botPanel.skills.removeFailed")))}finally{i.setWorking("")}}},g=async()=>{const x=o.trim();if(!(!x||m)){r(!0),i.setError(""),p([]);try{const C=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:x})});p(Ct(C.imported??[])),d(""),await i.refresh()}catch(C){i.setError(ve(C,s("botPanel.skills.importFailed")))}finally{r(!1)}}},v=async()=>{const x=await window.ogb?.pickFolder?.();if(!(!x||m)){r(!0),i.setError(""),p([]);try{const C=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${x}`})});p(Ct(C.imported??[])),await i.refresh()}catch(C){i.setError(ve(C,s("botPanel.skills.importFailed")))}finally{r(!1)}}},[j,P]=u.useState(!1),b=()=>{P(!1),l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"})},w=()=>{if(f){P(!0);return}gt(_t)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[i.loading?e.jsx(V,{children:s("skills.loading")}):i.skills.length===0?e.jsx(V,{children:s("botSettings.simple.noSkills")}):i.skills.map(x=>e.jsx(at,{"data-panel-row":`skill:${x.name}`,title:x.name,hint:x.description||x.source,label:s("botSettings.simple.skillToggle",{name:x.name}),color:t.color,checked:fs(x),disabled:!!i.working||x.core===!0,onChange:()=>{i.toggle(x)},extra:x.origin==="imported"||x.origin==="native"||x.origin==="bundled"?void 0:e.jsx(Me,{"data-panel-action":`remove-skill:${x.name}`,label:s("botPanel.skills.remove",{name:x.name}),disabled:!!i.working,onClick:()=>{k(x)}})},x.name)),i.error&&!i.reviewing&&e.jsx(V,{tone:"warn",children:i.error})]}),e.jsx(ci,{bot:t,onAdded:()=>{i.refresh()}}),e.jsxs(M,{children:[e.jsx(rs,{"data-panel-form":"skill-import",value:o,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:m?s("skills.import.importing"):s("common.add"),disabled:m,onChange:d,onSubmit:()=>{g()}}),c.map(x=>e.jsx(V,{children:x},x)),e.jsx(me,{"data-panel-link":"skills-sh",onClick:()=>{gt(_t)},children:s("botPanel.skills.skillsSh")}),e.jsx(me,{"data-panel-link":"browse-skills",onClick:w,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(me,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),j&&e.jsx(Nr,{botId:t.id,botName:t.name,onOpenSettings:b,onClose:()=>{P(!1),i.refresh()}}),i.reviewing&&e.jsx(di,{skill:i.reviewing.skill,text:i.reviewing.text,error:i.error,working:i.working===i.reviewing.skill.name,onCancel:()=>i.setReviewing(null),onEnable:()=>{i.enableReviewed()}})]})}function Ur({bot:t}){const{capabilities:n}=je(),a=n.host?.homeDir,{draft:l,setDraft:i,error:o,saving:d,canPick:m,save:r,pick:c}=li(t),[p,f]=u.useState(!1),k=!!t.cwd||p,g=()=>{if(m){c();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsx(Ve,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:d,onClick:()=>{f(!1),t.cwd&&r(null)}}),e.jsx(Ve,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:k,disabled:d,onClick:()=>{t.cwd||g()}})]}),k&&e.jsxs(M,{children:[m?e.jsxs("div",{className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?st(t.cwd,a):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:d,onClick:()=>{c()},className:oe,children:[e.jsx(Yt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:Q,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&r(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>i(v.target.value),className:"h-8 min-w-0 flex-1 rounded-lg border border-hairline bg-inset px-2.5 font-mono text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("button",{type:"submit",disabled:d||l===null,className:oe,children:s("botAccess.folder.save")})]}),o&&e.jsx(V,{tone:"warn",children:o})]})]})}function qr({bot:t,derived:n}){const a=Cs(t);return e.jsx(kr,{bot:t,browserEnabled:n.browserEnabled,onOpenBrowser:()=>a("browser")})}function Wr({bot:t}){return gs()?e.jsx(ys,{bot:t}):null}function Vr({page:t,onOpen:n,editingInstructions:a,onEditInstructions:l,...i}){switch(t){case"settings":return e.jsx(Lr,{...i,onOpen:n,editingInstructions:a,onEditInstructions:l});case"where":return e.jsx(ar,{...i});case"apps":return e.jsx(Dr,{...i});case"routines":return e.jsx(zr,{...i});case"visibility":return e.jsx(Wr,{...i});case"memory":return e.jsx(Hr,{...i});case"skills":return e.jsx(Kr,{...i});case"folder":return e.jsx(Ur,{...i});case"browser":return e.jsx(qr,{...i})}}const Kt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Ut(t){const[n,a]=u.useState(null),l=u.useRef(!1),i=u.useRef(!1),o=u.useRef(null);u.useEffect(()=>{n!==null||!i.current||(i.current=!1,o.current?.focus())},[n]);const d=p=>{l.current=!1,a(p)},m=()=>{n!==null&&t(n),a(null)};return{draft:n,setDraft:a,start:d,onKeyDown:p=>{if(ja(p.nativeEvent)){p.stopPropagation();return}p.key==="Enter"?(p.preventDefault(),l.current=!0,i.current=!0,m()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l.current=!0,i.current=!0,a(null))},onBlur:()=>{l.current||m()},buttonRef:o}}function Gr({bot:t,activeState:n,patch:a,editorOpen:l,onToggleEditor:i}){const o=Ut(r=>{const c=r.trim();c&&c!==t.name&&a({name:c})}),d=Ut(r=>{const c=r.trim();c!==t.title.trim()&&a({title:c})}),m=t.title.trim();return e.jsxs("div",{className:"group/hero flex flex-col items-center text-center",children:[e.jsxs("button",{type:"button","data-panel-avatar":!0,"aria-label":s("botPanel.avatar.edit"),"aria-expanded":l,onClick:i,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(Ye,{bot:t,size:64,state:n}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center rounded-[18px] bg-black/0 text-white opacity-0 transition-[opacity,background-color] group-hover:bg-black/40 group-hover:opacity-100 group-focus-visible:bg-black/40 group-focus-visible:opacity-100 group-focus-within:opacity-100 touch:opacity-100 motion-reduce:transition-none",children:e.jsx(bt,{size:20})}),t.chiefOfStaff&&e.jsxs("span",{"data-panel-chief":!0,title:s("chat.chiefOfStaff"),className:"absolute -bottom-0.5 -right-0.5 flex size-[22px] items-center justify-center rounded-full bg-accent text-accent-ink ring-[3px] ring-app",children:[e.jsx(ka,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:s("chat.chiefOfStaff")})]}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-[calc(100%+4px)] z-10 -translate-x-1/2 whitespace-nowrap rounded-md border border-hairline bg-menu px-[7px] py-0.5 text-[12px] text-ink opacity-0 transition-opacity group-hover:opacity-100",children:s("botPanel.avatar.edit")})]}),e.jsx("div",{"data-panel-name-row":!0,className:"mt-2 flex max-w-full items-center justify-center",children:e.jsx("h2",{id:"bot-settings-title",className:"flex min-w-0 justify-center",children:o.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Je.name,value:o.draft,onChange:r=>o.setDraft(r.target.value),onKeyDown:o.onKeyDown,onBlur:o.onBlur,className:O(Kt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:o.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>o.start(t.name),className:"group/name relative inline-flex max-w-full items-center rounded-[8px] px-1.5 text-[17px] font-medium leading-6 text-ink hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"min-w-0 truncate",children:t.name}),e.jsx(bt,{size:13,"aria-hidden":"true",className:"absolute -right-4 shrink-0 text-ink-tertiary opacity-0 transition-opacity group-hover/name:opacity-100 group-focus-visible/name:opacity-100 group-focus-within/name:opacity-100 touch:opacity-100"})]})})}),d.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Je.title,value:d.draft,onChange:r=>d.setDraft(r.target.value),onKeyDown:d.onKeyDown,onBlur:d.onBlur,className:O(Kt,"mt-[3px] w-[200px] max-w-full text-[13px]")}):m&&e.jsx("button",{ref:d.buttonRef,type:"button","data-panel-label":!0,onClick:()=>d.start(t.title),className:"mt-px max-w-full truncate rounded-md px-1.5 py-px text-[13px] text-ink-secondary hover:bg-ink/[0.04]",children:m})]})}function Ce(t,n){return t?os(t,n):{tab:"details"}}function Zr({bot:t,derived:n,linkedSection:a,onClose:l}){const{dragProps:i}=ds(),o=wa(),[d,m]=u.useState(()=>Ce(a,o).tab),[r,c]=u.useState(()=>{const h=Ce(a,o).page;return h?[h]:[]}),[p,f]=u.useState(()=>Ce(a,o).anchor??null),[k,g]=u.useState(!1),[v,j]=u.useState(()=>!!Ce(a,o).editInstructions),P=u.useRef(null),b=u.useRef(null),w=r.at(-1)??null,x=()=>P.current?.scrollTo({top:0}),C=h=>{m(h.tab),c(h.page?[h.page]:[]),f(h.anchor??null),g(!1),j(!!h.editInstructions),x()},L=h=>C({tab:h}),D=h=>{c(T=>[...T,h]),g(!1),x()},B=()=>{g(!1),b.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{c(h=>h.slice(0,-1)),x()};u.useEffect(()=>{a&&C(os(a,o))},[a,o]),u.useEffect(()=>{p&&(P.current?.querySelector(`[data-panel-card="${p}"]`)?.scrollIntoView({block:"start"}),f(null))},[p,w,d]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const T=h.target,F=typeof T?.closest=="function"?T.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(F&&!F.contains(h.currentTarget)&&F!==b.current&&!b.current?.contains(F))){if(k)B();else if(r.length>0)I();else return;h.preventDefault(),h.stopPropagation()}},A=r.length>1?s(Se[r[r.length-2]].title,{name:t.name}):s(vt[d]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:H,children:[e.jsxs("div",{...i,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(Na,{bot:t,className:De}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":w==="settings"?"page":void 0,onClick:()=>C({tab:"details",page:"settings"}),className:De,children:e.jsx(Sa,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:De,children:e.jsx(et,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:P,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:w===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:b,children:[e.jsx(Gr,{bot:t,activeState:n.activeState,patch:n.patch,editorOpen:k,onToggleEditor:()=>g(h=>!h)}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:B}),e.jsx(tr,{bot:t,activeState:n.activeState,onPatch:n.patch,onClose:B})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:Ca.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":d===h,"data-panel-tab":h,onClick:()=>L(h),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",d===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(vt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[d==="details"&&e.jsx(xr,{bot:t,derived:n,onOpen:D}),d==="library"&&e.jsx(Ts,{bot:t,onOpen:D}),d==="computer"&&e.jsx(ir,{bot:t,derived:n,onOpen:D})]})]}):e.jsxs("div",{"data-panel-page-view":w,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(Pa,{back:A,title:s(Se[w].title,{name:t.name}),intro:Se[w].intro?s(Se[w].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Fr),children:e.jsx(Vr,{page:w,bot:t,derived:n,onOpen:D,editingInstructions:v,onEditInstructions:j})})]})})]})}function Jr(t,n){const{state:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,m]=u.useState(!1),[r,c]=u.useState(null),[p,f]=u.useState(!1),k=u.useMemo(()=>JSON.stringify([t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),[t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),g=n.followEdits??!0,v=g?k:null,j=g?a.routines:null,P=g?a.webhooks:null;return u.useEffect(()=>{if(!n.overview&&!n.prompt)return;let b=!1;return(async()=>(await l(t.id),!b&&(n.overview&&Z(`/api/bots/${t.id}/overview`).then(x=>{b||(o(x),m(!1))}).catch(()=>{b||m(!0)}),n.prompt&&Z(`/api/bots/${t.id}/system-prompt`).then(x=>{b||(c(x),f(!1))}).catch(()=>{b||f(!0)}))))(),()=>{b=!0}},[t.id,n.overview,n.prompt,v,j,P,l]),{overview:i,overviewError:d,prompt:r,promptError:p}}function Yr(t,n){const{dispatch:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,m]=u.useState(!1),[r,c]=u.useState(null),p=u.useRef(0),[f,k]=u.useState(!1),[g,v]=u.useState(null),j=u.useCallback(()=>{const w=++p.current;return m(!1),l(t.id).then(()=>Z(`/api/bots/${t.id}/history?limit=100`)).then(x=>{w===p.current&&(o(x.rows),c(x.revision))}).catch(()=>{w===p.current&&m(!0)})},[t.id,l]);return u.useEffect(()=>{if(n)return j(),()=>{p.current++}},[n,j]),{rows:i,error:d,revision:r,rollingBack:f,rollbackTarget:g,setRollbackTarget:v,rollback:async w=>{if(!f){v(null),k(!0);try{await l(t.id),await Z(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(w)})}catch(x){a({type:"error",message:x instanceof Error?x.message:s("botOverview.undoFailed")})}finally{await j(),k(!1)}}},requestRollback:w=>{r&&v({id:w,expectedRevision:r})}}}function Qr({history:t,returnFocusRef:n}){const{rollbackTarget:a,setRollbackTarget:l,rollback:i}=t;return e.jsx(Oa,{open:a!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:n,onCancel:()=>l(null),onConfirm:()=>{a&&i(a)}})}const Xr={memory:"memory",skills:"skills",folder:"access"},As=t=>t.labelKey?s(t.labelKey):t.label;function qt(t,n){return n?[t.label,As(t),...t.keywords].some(a=>a.toLowerCase().includes(n)):!0}function yo({bot:t,overlay:n=!1}){const{state:a,dispatch:l}=$(),i=a.botSettingsSection,o=Ea(t),d=u.useRef(null),{dragProps:m}=ds(),[r,c]=u.useState(""),p=!a.botSettingsExpandAccordion,f=r.trim().toLowerCase(),g=!Wt(),v=!p&&!a.botSettingsExpandRemembered?i:null,j=js(t.id),P=nt(),b=Ra(),w=Ai.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&P===!0&&!b),x=w.filter(A=>qt(A,f)),{overview:C,overviewError:L,prompt:D,promptError:B}=Jr(t,{overview:i==="overview"&&!g,prompt:i==="overview"&&!g}),I=Yr(t,i==="history"&&!g);u.useEffect(()=>{if(!p){if(f){c("");return}d.current?.querySelector(`[data-bot-settings-section="${i}"]`)?.scrollIntoView({block:"nearest"})}},[p,i,f]),u.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,h=d.current;h?.focus();const T=F=>{const _=h?.querySelector('[role="dialog"], [role="alertdialog"]');_&&_.getClientRects().length>0||h&&F.target instanceof Node&&!h.contains(F.target)||F.key==="Escape"&&!F.defaultPrevented&&(F.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T),A?.focus()}},[l]);const H=A=>{switch(A){case"overview":return C===null&&L?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(zi,{overview:C,refreshError:C!==null&&L,prompt:D,promptError:B,onOpen:h=>l({type:"toggleSettings",open:!0,section:h}),onSetup:o.canCoordinate&&!t.busy?()=>{l({type:"toggleSettings",open:!1}),l({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(gi,{bot:t,patch:o.patch,activeState:o.activeState,mascotMotion:o.mascotMotion});case"soul":return e.jsx(fi,{bot:t,patch:o.patch});case"slack":return j?e.jsx(Hi,{managementUrl:j}):null;case"skills":return e.jsx(hi,{bot:t});case"memory":return e.jsx(Ui,{bot:t,active:!p&&i==="memory",onToggle:h=>o.patch({memoryEnabled:h})});case"library":return e.jsx(Ts,{bot:t,onOpen:h=>l({type:"toggleSettings",open:!0,section:Xr[h]??"overview"})});case"routines":return e.jsx(ki,{bot:t,routines:o.botRoutines,runs:a.routineRuns});case"access":return e.jsx(xi,{bot:t,derived:o});case"model":return e.jsx(ui,{bot:t});case"permissions":return e.jsx(mi,{bot:t,derived:o});case"voice":return e.jsx(pi,{bot:t,derived:o});case"visibility":return e.jsx(ys,{bot:t});case"history":return I.rows===null&&I.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(Gi,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(Zi,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:d,id:g?Ta:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Aa(n,g),children:g?e.jsx(Zr,{bot:t,derived:o,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...m,className:"flex shrink-0 items-center justify-between px-4 py-3",children:[e.jsx("span",{id:"bot-settings-title",className:"truncate text-[15px] font-semibold text-ink",children:t.name}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Ia,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>l({type:"toggleSettings",open:!1}),"aria-label":s("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(et,{size:18,className:"pointer-events-none"})})]})]}),e.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[e.jsx(Xe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:r,onChange:A=>{c(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),r?c(""):l({type:"toggleSettings",open:!1}))},placeholder:s("botSettings.search"),"aria-label":s("botSettings.searchAria"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[x.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:r.trim()})}),w.map(A=>{const{id:h,icon:T}=A,F=As(A),_=qt(A,f);if(!_&&h!=="memory")return null;const K=!p&&i===h;return e.jsxs("div",{"data-bot-settings-section":h,className:"border-b border-hairline/30",hidden:!_,children:[e.jsxs("button",{type:"button",onClick:()=>{if(i===h&&!p){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:h})},"aria-expanded":K,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",K?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(T,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",K&&"rotate-180")})]}),h==="memory"?e.jsx("div",{hidden:!K,className:"px-4 pb-4 pt-1",children:H("memory")}):K&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:H(h)})]},h)})]})]})}),e.jsx(Qr,{history:I,returnFocusRef:d})]})}export{yo as BotSettingsDialog};
|
|
16
|
+
${d}`),o({text:r.current,hash:r.currentHash}),m(r.current),c(null))};return e.jsx(M,{children:e.jsxs(pe,{"data-panel-row":"memory-text",children:[r&&e.jsx(Ss,{botName:t.name,busy:k,onReload:w,onOverwrite:()=>{b(r.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(Qe,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:d,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:x=>m(x.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),p!==null&&e.jsxs("div",{"data-memory-draft":"",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:p}),e.jsx("button",{type:"button",className:O(oe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:oe,disabled:k,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:oe,disabled:k||d===i.text,onClick:()=>{b(i.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Ur({bot:t}){const{request:n}=ga(),{state:a,dispatch:l}=$(),i=hs(t),[o,d]=u.useState(""),[m,r]=u.useState(!1),[c,p]=u.useState([]),f=ya(a.config),k=async x=>{if(!i.working&&window.confirm(s(x.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:x.name}))){i.setWorking(x.name),i.setError("");try{await n(`/api/bots/${t.id}/skills/${encodeURIComponent(x.name)}`,{method:"DELETE"}),await i.refresh()}catch(C){i.setError(ve(C,s("botPanel.skills.removeFailed")))}finally{i.setWorking("")}}},g=async()=>{const x=o.trim();if(!(!x||m)){r(!0),i.setError(""),p([]);try{const C=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:x})});p(Ct(C.imported??[])),d(""),await i.refresh()}catch(C){i.setError(ve(C,s("botPanel.skills.importFailed")))}finally{r(!1)}}},v=async()=>{const x=await window.ogb?.pickFolder?.();if(!(!x||m)){r(!0),i.setError(""),p([]);try{const C=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${x}`})});p(Ct(C.imported??[])),await i.refresh()}catch(C){i.setError(ve(C,s("botPanel.skills.importFailed")))}finally{r(!1)}}},[j,P]=u.useState(!1),b=()=>{P(!1),l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"})},w=()=>{if(f){P(!0);return}gt(_t)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[i.loading?e.jsx(V,{children:s("skills.loading")}):i.skills.length===0?e.jsx(V,{children:s("botSettings.simple.noSkills")}):i.skills.map(x=>e.jsx(at,{"data-panel-row":`skill:${x.name}`,title:x.name,hint:x.description||x.source,label:s("botSettings.simple.skillToggle",{name:x.name}),color:t.color,checked:fs(x),disabled:!!i.working||x.core===!0,onChange:()=>{i.toggle(x)},extra:x.origin==="imported"||x.origin==="native"||x.origin==="bundled"?void 0:e.jsx(Me,{"data-panel-action":`remove-skill:${x.name}`,label:s("botPanel.skills.remove",{name:x.name}),disabled:!!i.working,onClick:()=>{k(x)}})},x.name)),i.error&&!i.reviewing&&e.jsx(V,{tone:"warn",children:i.error})]}),e.jsx(di,{bot:t,onAdded:()=>{i.refresh()}}),e.jsxs(M,{children:[e.jsx(rs,{"data-panel-form":"skill-import",value:o,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:m?s("skills.import.importing"):s("common.add"),disabled:m,onChange:d,onSubmit:()=>{g()}}),c.map(x=>e.jsx(V,{children:x},x)),e.jsx(me,{"data-panel-link":"skills-sh",onClick:()=>{gt(_t)},children:s("botPanel.skills.skillsSh")}),e.jsx(me,{"data-panel-link":"browse-skills",onClick:w,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(me,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),j&&e.jsx(Sr,{botId:t.id,botName:t.name,onOpenSettings:b,onClose:()=>{P(!1),i.refresh()}}),i.reviewing&&e.jsx(pi,{skill:i.reviewing.skill,text:i.reviewing.text,error:i.error,working:i.working===i.reviewing.skill.name,onCancel:()=>i.setReviewing(null),onEnable:()=>{i.enableReviewed()}})]})}function qr({bot:t}){const{capabilities:n}=je(),a=n.host?.homeDir,{draft:l,setDraft:i,error:o,saving:d,canPick:m,save:r,pick:c}=ci(t),[p,f]=u.useState(!1),k=!!t.cwd||p,g=()=>{if(m){c();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsx(Ve,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:d,onClick:()=>{f(!1),t.cwd&&r(null)}}),e.jsx(Ve,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:k,disabled:d,onClick:()=>{t.cwd||g()}})]}),k&&e.jsxs(M,{children:[m?e.jsxs("div",{className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?st(t.cwd,a):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:d,onClick:()=>{c()},className:oe,children:[e.jsx(Yt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:Q,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&r(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>i(v.target.value),className:"h-8 min-w-0 flex-1 rounded-lg border border-hairline bg-inset px-2.5 font-mono text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("button",{type:"submit",disabled:d||l===null,className:oe,children:s("botAccess.folder.save")})]}),o&&e.jsx(V,{tone:"warn",children:o})]}),e.jsx(fa,{kind:"bots",id:t.id,folder:t.cwd})]})}function Wr({bot:t,derived:n}){const a=Cs(t);return e.jsx(jr,{bot:t,browserEnabled:n.browserEnabled,onOpenBrowser:()=>a("browser")})}function Vr({bot:t}){return gs()?e.jsx(ys,{bot:t}):null}function Gr({page:t,onOpen:n,editingInstructions:a,onEditInstructions:l,...i}){switch(t){case"settings":return e.jsx(Br,{...i,onOpen:n,editingInstructions:a,onEditInstructions:l});case"where":return e.jsx(ir,{...i});case"apps":return e.jsx(zr,{...i});case"routines":return e.jsx(Hr,{...i});case"visibility":return e.jsx(Vr,{...i});case"memory":return e.jsx(_r,{...i});case"skills":return e.jsx(Ur,{...i});case"folder":return e.jsx(qr,{...i});case"browser":return e.jsx(Wr,{...i})}}const Kt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Ut(t){const[n,a]=u.useState(null),l=u.useRef(!1),i=u.useRef(!1),o=u.useRef(null);u.useEffect(()=>{n!==null||!i.current||(i.current=!1,o.current?.focus())},[n]);const d=p=>{l.current=!1,a(p)},m=()=>{n!==null&&t(n),a(null)};return{draft:n,setDraft:a,start:d,onKeyDown:p=>{if(wa(p.nativeEvent)){p.stopPropagation();return}p.key==="Enter"?(p.preventDefault(),l.current=!0,i.current=!0,m()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l.current=!0,i.current=!0,a(null))},onBlur:()=>{l.current||m()},buttonRef:o}}function Zr({bot:t,activeState:n,patch:a,editorOpen:l,onToggleEditor:i}){const o=Ut(r=>{const c=r.trim();c&&c!==t.name&&a({name:c})}),d=Ut(r=>{const c=r.trim();c!==t.title.trim()&&a({title:c})}),m=t.title.trim();return e.jsxs("div",{className:"group/hero flex flex-col items-center text-center",children:[e.jsxs("button",{type:"button","data-panel-avatar":!0,"aria-label":s("botPanel.avatar.edit"),"aria-expanded":l,onClick:i,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(Ye,{bot:t,size:64,state:n}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center rounded-[18px] bg-black/0 text-white opacity-0 transition-[opacity,background-color] group-hover:bg-black/40 group-hover:opacity-100 group-focus-visible:bg-black/40 group-focus-visible:opacity-100 group-focus-within:opacity-100 touch:opacity-100 motion-reduce:transition-none",children:e.jsx(bt,{size:20})}),t.chiefOfStaff&&e.jsxs("span",{"data-panel-chief":!0,title:s("chat.chiefOfStaff"),className:"absolute -bottom-0.5 -right-0.5 flex size-[22px] items-center justify-center rounded-full bg-accent text-accent-ink ring-[3px] ring-app",children:[e.jsx(ja,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:s("chat.chiefOfStaff")})]}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-[calc(100%+4px)] z-10 -translate-x-1/2 whitespace-nowrap rounded-md border border-hairline bg-menu px-[7px] py-0.5 text-[12px] text-ink opacity-0 transition-opacity group-hover:opacity-100",children:s("botPanel.avatar.edit")})]}),e.jsx("div",{"data-panel-name-row":!0,className:"mt-2 flex max-w-full items-center justify-center",children:e.jsx("h2",{id:"bot-settings-title",className:"flex min-w-0 justify-center",children:o.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Je.name,value:o.draft,onChange:r=>o.setDraft(r.target.value),onKeyDown:o.onKeyDown,onBlur:o.onBlur,className:O(Kt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:o.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>o.start(t.name),className:"group/name relative inline-flex max-w-full items-center rounded-[8px] px-1.5 text-[17px] font-medium leading-6 text-ink hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"min-w-0 truncate",children:t.name}),e.jsx(bt,{size:13,"aria-hidden":"true",className:"absolute -right-4 shrink-0 text-ink-tertiary opacity-0 transition-opacity group-hover/name:opacity-100 group-focus-visible/name:opacity-100 group-focus-within/name:opacity-100 touch:opacity-100"})]})})}),d.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Je.title,value:d.draft,onChange:r=>d.setDraft(r.target.value),onKeyDown:d.onKeyDown,onBlur:d.onBlur,className:O(Kt,"mt-[3px] w-[200px] max-w-full text-[13px]")}):m&&e.jsx("button",{ref:d.buttonRef,type:"button","data-panel-label":!0,onClick:()=>d.start(t.title),className:"mt-px max-w-full truncate rounded-md px-1.5 py-px text-[13px] text-ink-secondary hover:bg-ink/[0.04]",children:m})]})}function Ce(t,n){return t?os(t,n):{tab:"details"}}function Jr({bot:t,derived:n,linkedSection:a,onClose:l}){const{dragProps:i}=ds(),o=Na(),[d,m]=u.useState(()=>Ce(a,o).tab),[r,c]=u.useState(()=>{const h=Ce(a,o).page;return h?[h]:[]}),[p,f]=u.useState(()=>Ce(a,o).anchor??null),[k,g]=u.useState(!1),[v,j]=u.useState(()=>!!Ce(a,o).editInstructions),P=u.useRef(null),b=u.useRef(null),w=r.at(-1)??null,x=()=>P.current?.scrollTo({top:0}),C=h=>{m(h.tab),c(h.page?[h.page]:[]),f(h.anchor??null),g(!1),j(!!h.editInstructions),x()},L=h=>C({tab:h}),D=h=>{c(T=>[...T,h]),g(!1),x()},B=()=>{g(!1),b.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{c(h=>h.slice(0,-1)),x()};u.useEffect(()=>{a&&C(os(a,o))},[a,o]),u.useEffect(()=>{p&&(P.current?.querySelector(`[data-panel-card="${p}"]`)?.scrollIntoView({block:"start"}),f(null))},[p,w,d]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const T=h.target,F=typeof T?.closest=="function"?T.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(F&&!F.contains(h.currentTarget)&&F!==b.current&&!b.current?.contains(F))){if(k)B();else if(r.length>0)I();else return;h.preventDefault(),h.stopPropagation()}},A=r.length>1?s(Se[r[r.length-2]].title,{name:t.name}):s(vt[d]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:H,children:[e.jsxs("div",{...i,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(Sa,{bot:t,className:De}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":w==="settings"?"page":void 0,onClick:()=>C({tab:"details",page:"settings"}),className:De,children:e.jsx(Ca,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:De,children:e.jsx(et,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:P,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:w===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:b,children:[e.jsx(Zr,{bot:t,activeState:n.activeState,patch:n.patch,editorOpen:k,onToggleEditor:()=>g(h=>!h)}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:B}),e.jsx(sr,{bot:t,activeState:n.activeState,onPatch:n.patch,onClose:B})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:Pa.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":d===h,"data-panel-tab":h,onClick:()=>L(h),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",d===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(vt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[d==="details"&&e.jsx(hr,{bot:t,derived:n,onOpen:D}),d==="library"&&e.jsx(Ts,{bot:t,onOpen:D}),d==="computer"&&e.jsx(rr,{bot:t,derived:n,onOpen:D})]})]}):e.jsxs("div",{"data-panel-page-view":w,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(Oa,{back:A,title:s(Se[w].title,{name:t.name}),intro:Se[w].intro?s(Se[w].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Dr),children:e.jsx(Gr,{page:w,bot:t,derived:n,onOpen:D,editingInstructions:v,onEditInstructions:j})})]})})]})}function Yr(t,n){const{state:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,m]=u.useState(!1),[r,c]=u.useState(null),[p,f]=u.useState(!1),k=u.useMemo(()=>JSON.stringify([t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),[t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),g=n.followEdits??!0,v=g?k:null,j=g?a.routines:null,P=g?a.webhooks:null;return u.useEffect(()=>{if(!n.overview&&!n.prompt)return;let b=!1;return(async()=>(await l(t.id),!b&&(n.overview&&Z(`/api/bots/${t.id}/overview`).then(x=>{b||(o(x),m(!1))}).catch(()=>{b||m(!0)}),n.prompt&&Z(`/api/bots/${t.id}/system-prompt`).then(x=>{b||(c(x),f(!1))}).catch(()=>{b||f(!0)}))))(),()=>{b=!0}},[t.id,n.overview,n.prompt,v,j,P,l]),{overview:i,overviewError:d,prompt:r,promptError:p}}function Qr(t,n){const{dispatch:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,m]=u.useState(!1),[r,c]=u.useState(null),p=u.useRef(0),[f,k]=u.useState(!1),[g,v]=u.useState(null),j=u.useCallback(()=>{const w=++p.current;return m(!1),l(t.id).then(()=>Z(`/api/bots/${t.id}/history?limit=100`)).then(x=>{w===p.current&&(o(x.rows),c(x.revision))}).catch(()=>{w===p.current&&m(!0)})},[t.id,l]);return u.useEffect(()=>{if(n)return j(),()=>{p.current++}},[n,j]),{rows:i,error:d,revision:r,rollingBack:f,rollbackTarget:g,setRollbackTarget:v,rollback:async w=>{if(!f){v(null),k(!0);try{await l(t.id),await Z(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(w)})}catch(x){a({type:"error",message:x instanceof Error?x.message:s("botOverview.undoFailed")})}finally{await j(),k(!1)}}},requestRollback:w=>{r&&v({id:w,expectedRevision:r})}}}function Xr({history:t,returnFocusRef:n}){const{rollbackTarget:a,setRollbackTarget:l,rollback:i}=t;return e.jsx(Ea,{open:a!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:n,onCancel:()=>l(null),onConfirm:()=>{a&&i(a)}})}const eo={memory:"memory",skills:"skills",folder:"access"},As=t=>t.labelKey?s(t.labelKey):t.label;function qt(t,n){return n?[t.label,As(t),...t.keywords].some(a=>a.toLowerCase().includes(n)):!0}function bo({bot:t,overlay:n=!1}){const{state:a,dispatch:l}=$(),i=a.botSettingsSection,o=Ra(t),d=u.useRef(null),{dragProps:m}=ds(),[r,c]=u.useState(""),p=!a.botSettingsExpandAccordion,f=r.trim().toLowerCase(),g=!Wt(),v=!p&&!a.botSettingsExpandRemembered?i:null,j=js(t.id),P=nt(),b=Ta(),w=Mi.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&P===!0&&!b),x=w.filter(A=>qt(A,f)),{overview:C,overviewError:L,prompt:D,promptError:B}=Yr(t,{overview:i==="overview"&&!g,prompt:i==="overview"&&!g}),I=Qr(t,i==="history"&&!g);u.useEffect(()=>{if(!p){if(f){c("");return}d.current?.querySelector(`[data-bot-settings-section="${i}"]`)?.scrollIntoView({block:"nearest"})}},[p,i,f]),u.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,h=d.current;h?.focus();const T=F=>{const _=h?.querySelector('[role="dialog"], [role="alertdialog"]');_&&_.getClientRects().length>0||h&&F.target instanceof Node&&!h.contains(F.target)||F.key==="Escape"&&!F.defaultPrevented&&(F.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T),A?.focus()}},[l]);const H=A=>{switch(A){case"overview":return C===null&&L?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Hi,{overview:C,refreshError:C!==null&&L,prompt:D,promptError:B,onOpen:h=>l({type:"toggleSettings",open:!0,section:h}),onSetup:o.canCoordinate&&!t.busy?()=>{l({type:"toggleSettings",open:!1}),l({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(yi,{bot:t,patch:o.patch,activeState:o.activeState,mascotMotion:o.mascotMotion});case"soul":return e.jsx(gi,{bot:t,patch:o.patch});case"slack":return j?e.jsx(_i,{managementUrl:j}):null;case"skills":return e.jsx(fi,{bot:t});case"memory":return e.jsx(qi,{bot:t,active:!p&&i==="memory",onToggle:h=>o.patch({memoryEnabled:h})});case"library":return e.jsx(Ts,{bot:t,onOpen:h=>l({type:"toggleSettings",open:!0,section:eo[h]??"overview"})});case"routines":return e.jsx(ji,{bot:t,routines:o.botRoutines,runs:a.routineRuns});case"access":return e.jsx(hi,{bot:t,derived:o});case"model":return e.jsx(xi,{bot:t});case"permissions":return e.jsx(ui,{bot:t,derived:o});case"voice":return e.jsx(mi,{bot:t,derived:o});case"visibility":return e.jsx(ys,{bot:t});case"history":return I.rows===null&&I.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(Zi,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(Ji,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:d,id:g?Ia:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Ma(n,g),children:g?e.jsx(Jr,{bot:t,derived:o,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...m,className:"flex shrink-0 items-center justify-between px-4 py-3",children:[e.jsx("span",{id:"bot-settings-title",className:"truncate text-[15px] font-semibold text-ink",children:t.name}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(Aa,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>l({type:"toggleSettings",open:!1}),"aria-label":s("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(et,{size:18,className:"pointer-events-none"})})]})]}),e.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[e.jsx(Xe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:r,onChange:A=>{c(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),r?c(""):l({type:"toggleSettings",open:!1}))},placeholder:s("botSettings.search"),"aria-label":s("botSettings.searchAria"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[x.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:r.trim()})}),w.map(A=>{const{id:h,icon:T}=A,F=As(A),_=qt(A,f);if(!_&&h!=="memory")return null;const K=!p&&i===h;return e.jsxs("div",{"data-bot-settings-section":h,className:"border-b border-hairline/30",hidden:!_,children:[e.jsxs("button",{type:"button",onClick:()=>{if(i===h&&!p){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:h})},"aria-expanded":K,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",K?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(T,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",K&&"rotate-180")})]}),h==="memory"?e.jsx("div",{hidden:!K,className:"px-4 pb-4 pt-1",children:H("memory")}):K&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:H(h)})]},h)})]})]})}),e.jsx(Xr,{history:I,returnFocusRef:d})]})}export{bo as BotSettingsDialog};
|