limixbot 0.3.22 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/assets/{ActivityPanel-ChjWicVw.js → ActivityPanel-BjjmX49M.js} +1 -1
  2. package/dist/assets/App-BWtQhGWp.js +242 -0
  3. package/dist/assets/{AppEventEditor-NdlNZYiU.js → AppEventEditor-Bq1-MGxi.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-DKIuZdV6.js → BotSettingsDialog-CVlvG4Rb.js} +4 -4
  5. package/dist/assets/{BrowserPanel-DjEwiL31.js → BrowserPanel-CPLcno_m.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-1DLRt4N9.js → BrowserProfilesManager-D9JsCp1k.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-C0DMYGOm.js → CloudAddDialog-DcmN7A5a.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-Dk8NcRrf.js → ComputerFilesPane-Bjx6TGmM.js} +1 -1
  9. package/dist/assets/{ComputerPanel-DoVcLtW7.js → ComputerPanel-C9Xx4Ifs.js} +2 -2
  10. package/dist/assets/{DataPanel-C0Fx7K2G.js → DataPanel-IfpQCi3b.js} +1 -1
  11. package/dist/assets/{DesktopViewer-DTBmRKHz.js → DesktopViewer-RjjUUlrQ.js} +1 -1
  12. package/dist/assets/{FilesView-D5s67U7H.js → FilesView-D_0GwHAN.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-itIjM39_.js → GrokMoveDialog-CUie-0en.js} +1 -1
  14. package/dist/assets/{InspectorPanel-NMTlN3H-.js → InspectorPanel-BuFL6wWf.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-O3skmvQm.js → KeyboardShortcutsModal-uOhXagTA.js} +1 -1
  16. package/dist/assets/{LiveDesktop-CO9mKNtY.js → LiveDesktop-BwpZa-Ri.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-BLrh4g6E.js → LocalVmWorkspace-CousHKOb.js} +1 -1
  18. package/dist/assets/{MacLocalControl-DyhXTfbp.js → MacLocalControl-BKDzplO2.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-CyJn1rQP.js → MarkdownFilePreview-CCwc1Tek.js} +1 -1
  20. package/dist/assets/{MenuMotion-CobYpP7L.js → MenuMotion-CSgaJLc2.js} +1 -1
  21. package/dist/assets/NewBotDialog-BtvoCpqN.js +1 -0
  22. package/dist/assets/{PhoneAppDialog-D_CgApJp.js → PhoneAppDialog-C1hIwyT8.js} +1 -1
  23. package/dist/assets/{PlacesRail-CUntVv3u.js → PlacesRail-PP97GpM6.js} +1 -1
  24. package/dist/assets/{PluginsPanel-C2bbrSB3.js → PluginsPanel-DpUEC1zc.js} +1 -1
  25. package/dist/assets/{ProIntroduction-8BVPIU2J.js → ProIntroduction-C-7uexIW.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-JMsDeyDs.js → RemoteAgentSettingsPanel-DtofJtgF.js} +1 -1
  27. package/dist/assets/{RoomPanel-BcFX5BFK.js → RoomPanel-CHbgQ0xd.js} +1 -1
  28. package/dist/assets/{RoutinesPage-BZhG-dR9.js → RoutinesPage-ZdFTYQc-.js} +2 -2
  29. package/dist/assets/SettingsModal-Cdz3bEYZ.js +15 -0
  30. package/dist/assets/{ShareTeamDialog-Cf4VzjYH.js → ShareTeamDialog-CNu6Kwet.js} +1 -1
  31. package/dist/assets/{SignedInSites-31u9pN2b.js → SignedInSites-CyWcDbLW.js} +1 -1
  32. package/dist/assets/TeamLibraryPanel-DMhdlaSH.js +1 -0
  33. package/dist/assets/{TeamMapPage-BrrWMFul.js → TeamMapPage-C2PnNdil.js} +1 -1
  34. package/dist/assets/{TriggersPage-GuMhNUuU.js → TriggersPage-B_br6xBZ.js} +1 -1
  35. package/dist/assets/{VisibilitySection-C6eVm1Hd.js → VisibilitySection-DH0WrBCn.js} +1 -1
  36. package/dist/assets/{WebhookTrigger-BGm39FBT.js → WebhookTrigger-BASBoMb_.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-9NWPGzbE.js → WorksOnGrid-CboITAAs.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-DEyDkr0Q.js → abnfDiagram-YUKMZFIV-CJ69o_vp.js} +1 -1
  39. package/dist/assets/{activity-CbpNb0MQ.js → activity-BdRjGS2C.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-CGTtcA9N.js → architectureDiagram-47P4ROYG-BH57AmKC.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-DT9DFOL_.js → blockDiagram-E7TT5TSB-D3ebMs_o.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-DpERK75F.js → c4Diagram-CRA5TL53-6TrdcGZR.js} +1 -1
  43. package/dist/assets/{calendar-days-DE6WL-x2.js → calendar-days-DiMBTH2e.js} +1 -1
  44. package/dist/assets/channel-k2J2GMwv.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-wHwpVFi3.js → chunk-2Q5K7J3B-BemwHdji.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-CfqwqtdU.js → chunk-5VM5RSS4-CQZbLBld.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-BRxQFxT-.js → chunk-7TKQ45FW-Dy6EXFTX.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-Ca3w_5Wz.js → chunk-AW2ZBBNX-BbKGGyK8.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-CO8Syt2Z.js → chunk-FVRAUYC3-DHqUalc2.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-Cnx9DnWv.js → chunk-HTAEGDNF-B66Vjlwq.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-DefKEriK.js → chunk-JWPE2WC7-DrtdT6L3.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-B6WWWz_R.js → chunk-KQW6MTUR-t7RW8fFT.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-BFU1-B3X.js → chunk-XXDRQBXY-CntyS42N.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-BePCpZI3.js → classDiagram-v2-K4WV4PDN-KlNCgeTt.js} +1 -1
  55. package/dist/assets/{coins-D1fhjgas.js → coins-BHKpT34i.js} +1 -1
  56. package/dist/assets/{core-GxNVTB-X.js → core-DEy6KDLR.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-D8emtvin.js → cose-bilkent-JH36ORCC-C_cXoOGT.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-DUEsfFVq.js → cynefin-EF2NZ3EQ-DGuwW5zt.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-duonepNA.js → cynefinDiagram-3GCD6N5R-qMzxXkVk.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-D4NywFNB.js → dagre-W4DXFKR2-Q-osY3Yi.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-cjiJTdiH.js → diagram-2UJZ2QOL-DyVJSBOF.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-D6M8A9DS.js → diagram-OVF4WLC6-C5qBFdpm.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-CVAzAz2N.js → diagram-PFPMY2P6-C1PW3U2P.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-DLvfYJwO.js → diagram-UMYRVEAY-D2pa0Mzi.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-D8qCH--0.js → diagram-YEKJPTXX-BIzOA1li.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-s55SHvTR.js → diagram-ZIFT7M5P-B1UL3O8m.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-B93cNJNn.js → ebnfDiagram-VR2GEFS7-Cxu-kU8s.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-BsJqO8aU.js → elk-IJKZMXRS-DJS39Bm9.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-BXF1G3Js.js → erDiagram-O2IAPWRE-Cb31BS5L.js} +1 -1
  70. package/dist/assets/{file-up-Cg2kYQkd.js → file-up-DWGlVRGP.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-BKjjYwz9.js → flowDiagram-OXPTDLAJ-BaPTzS6m.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-DhtZJtPm.js → ganttDiagram-R7TSEDQI-B_Lr-26i.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-BfRlcF5z.js → gitGraphDiagram-XJZIOB7I-UHyDFX6a.js} +1 -1
  74. package/dist/assets/{import-name-B8g_Hj2F.js → import-name-Cxwtm5XO.js} +1 -1
  75. package/dist/assets/{index-B8LCAG4-.js → index-BME9PdWM.js} +1 -1
  76. package/dist/assets/{index-LBC94myy.js → index-BSrb6nsc.js} +2 -2
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-CywmYwco.js → infoDiagram-5W2HQ5XZ-B7ovBJYA.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-DpXXqau5.js → ishikawaDiagram-K3B6WC7H-BYS-TlrF.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-D1uMWGbz.js → journeyDiagram-COXZFDF6-jJxKYEtT.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-Bz0zjqQs.js → kanban-definition-P3RFRI5V-DyiFYaIK.js} +1 -1
  81. package/dist/assets/{mcp-servers-C_F4MXjY.js → mcp-servers-DXFuhTlS.js} +1 -1
  82. package/dist/assets/{mermaid.core-Dnv6mcJ4.js → mermaid.core-D3YJgsiB.js} +4 -4
  83. package/dist/assets/{mindmap-definition-LZFPQGKD-CFEkTgom.js → mindmap-definition-LZFPQGKD-DnbWodUY.js} +1 -1
  84. package/dist/assets/{minimize-o-OFVasg.js → minimize-Af1aU3Tz.js} +1 -1
  85. package/dist/assets/{monitor-7oLB-7rZ.js → monitor-DuYHWIyw.js} +1 -1
  86. package/dist/assets/{new-bot-CFOYR98I.js → new-bot-TwOnvVO1.js} +1 -1
  87. package/dist/assets/{org-library-TYYMsAm5.js → org-library-BLD6YHcM.js} +1 -1
  88. package/dist/assets/{package-format-CrrPupM8.js → package-format-72bbOy2w.js} +1 -1
  89. package/dist/assets/{pegDiagram-BGZESJAR-DKt4SMwc.js → pegDiagram-BGZESJAR-CcOuP6zx.js} +1 -1
  90. package/dist/assets/{pieDiagram-CAPJLFHJ-B9taKUge.js → pieDiagram-CAPJLFHJ-DhCU7Sfy.js} +1 -1
  91. package/dist/assets/{quadrantDiagram-GDMTTRAM-DQjB7Jbz.js → quadrantDiagram-GDMTTRAM-7OziX26h.js} +1 -1
  92. package/dist/assets/{rail-BBdJiVR1.js → rail-DI2iZJYt.js} +1 -1
  93. package/dist/assets/{railroadDiagram-SM67HX2B-DQOivC56.js → railroadDiagram-SM67HX2B-rg44R4U2.js} +1 -1
  94. package/dist/assets/{remote-desktop-panel-BmwpQiDu.js → remote-desktop-panel-BPKKvcHT.js} +1 -1
  95. package/dist/assets/{requirementDiagram-X7JNWC4A-BLgwXDEl.js → requirementDiagram-X7JNWC4A-DFNvg72O.js} +1 -1
  96. package/dist/assets/{sankeyDiagram-UM26HJRW-g2GlJNjj.js → sankeyDiagram-UM26HJRW-CUOrQF2i.js} +1 -1
  97. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-_08U7Ixl.js → sequenceDiagram-ZO4K6R2Y-4HKsH1wt.js} +1 -1
  98. package/dist/assets/{sizeCapture-INFHLROL-DZPfU3_U.js → sizeCapture-INFHLROL-BEXQDTx-.js} +1 -1
  99. package/dist/assets/{stateDiagram-v2-TBUQTH76-PXBjCkxd.js → stateDiagram-v2-TBUQTH76-BYBLUqiy.js} +1 -1
  100. package/dist/assets/{styles-BHtUK2qB.js → styles-C2_XZv1s.js} +1 -1
  101. package/dist/assets/styles-Di_mG4l3.css +1 -0
  102. package/dist/assets/{swimlanes-N4OXWK64-q1MhehBF.js → swimlanes-N4OXWK64-D-bp8wWN.js} +1 -1
  103. package/dist/assets/swimlanesDiagram-K3J5GTZL-DTQBdgKt.js +8 -0
  104. package/dist/assets/{team-share-xt--eeM_.js → team-share-Dpu1nJNz.js} +1 -1
  105. package/dist/assets/{timeline-definition-YOQAKGHF-UBKh0GG-.js → timeline-definition-YOQAKGHF-CtLFkcud.js} +1 -1
  106. package/dist/assets/{usecaseDiagram-VIAY4XPW-CccLioTT.js → usecaseDiagram-VIAY4XPW-AWOhUKvG.js} +1 -1
  107. package/dist/assets/{vennDiagram-BLWOH2XV-3Q39wQgE.js → vennDiagram-BLWOH2XV-C_OYDBvp.js} +1 -1
  108. package/dist/assets/{vi-CVDyZGky.js → vi-P4zxF4j0.js} +1 -1
  109. package/dist/assets/{wardleyDiagram-YMQ3BMBF-DtgEYK7j.js → wardleyDiagram-YMQ3BMBF-CdxMh8tE.js} +1 -1
  110. package/dist/assets/{xychartDiagram-TAQBALBS-DLTmsflK.js → xychartDiagram-TAQBALBS-BL2spC5z.js} +1 -1
  111. package/dist/index.html +3 -3
  112. package/dist/rail.html +5 -5
  113. package/dist-server/index.js +1591 -1578
  114. package/dist-server/package.json +1 -1
  115. package/dist-server/server/index.js +1 -1
  116. package/dist-server/server/initial-greeting.js +4 -0
  117. package/dist-server/server/limix-bot-library.js +178 -0
  118. package/dist-server/server/limix-skill-hub.js +6 -8
  119. package/dist-server/server/routes/bot-skills.js +6 -0
  120. package/dist-server/server/routes/teams.js +1 -1
  121. package/package.json +1 -1
  122. package/dist/assets/App-D-SXyZXT.js +0 -242
  123. package/dist/assets/NewBotDialog-coMM5O6x.js +0 -1
  124. package/dist/assets/SettingsModal-CWtO0RWS.js +0 -11
  125. package/dist/assets/TeamLibraryPanel-Bzvx_MlH.js +0 -1
  126. package/dist/assets/channel-CETDvzTH.js +0 -1
  127. package/dist/assets/styles-B9SGxFnK.css +0 -1
  128. package/dist/assets/swimlanesDiagram-K3J5GTZL-pLYSpGVX.js +0 -8
@@ -1,16 +1,16 @@
1
- import{c as Ce,t as s,b as ee,av as Is,j as e,i as Ae,a9 as xe,a as O,r as x,S as Bt,ac as Dt,X as Ft}from"./styles-BHtUK2qB.js";import{fg as As,fh as Ls,a2 as Ve,by as Ms,di as $t,w as Ts,fi as Bs,fj as Ds,K as zt,fk as Fs,R as Ht,eu as $s,x as zs,fl as st,bt as at,fm as _t,n as se,u as B,fn as Hs,ah as Ye,F as Ut,A as Kt,S as nt,ad as Pe,T as qt,W as _s,fo as Us,fp as Ks,fq as qs,fr as Ws,fs as Vs,ft as rt,fu as Ys,fv as Gs,fw as Js,fx as Qs,b9 as Xs,fy as Zs,fz as ea,fA as ta,I as sa,fB as je,bP as Ge,fC as aa,aI as L,aO as X,ed as na,dK as ra,fD as ia,aJ as He,cp as la,dZ as oa,d_ as ca,fE as da,fF as Wt,fG as Vt,fH as ua,fI as ma,fJ as pa,fK as xa,dN as _e,ar as it,fL as Le,fM as ha,fN as we,av as fa,fO as Yt,fP as lt,ak as Ue,fQ as ga,fR as ya,fS as va,fT as Gt,fU as ba,fV as ka,fW as ja,fX as wa,fY as Q,aX as te,aZ as J,fZ as Na,f_ as Sa,f$ as Ca,d5 as Pa,d as Oa,G as Ea,d3 as Jt,aj as Ra,g0 as W,aW as ce,g1 as de,g2 as Ia,dp as Aa,g3 as Oe,aY as re,g4 as La,g5 as Ma,g6 as Ta,eh as Ba,g7 as ot,g8 as Da,g9 as Fa,ga as $a,gb as za,gc as Ha,gd as _a,aC as Ua,ge as Qt,gf as Ka,gg as qa,gh as Wa,gi as Va,gj as Ya,gk as Ga,gl as Ja,gm as Qa,gn as Xa,go as Za,gp as en,gq as tn,gr as Je,k as sn,B as Ke,gs as an,gt as nn,gu as rn,gv as ln,bY as on,gw as Xt,J as ct,eY as cn,gx as dt,gy as dn,gz as un,cM as ut,bw as mn,d2 as pn,gA as xn,gB as Zt,gC as be,gD as mt,gE as hn,aM as Me,d$ as fn,gF as gn,aR as yn,C as vn,cq as bn,gG as kn,gH as jn,gI as wn,aT as Nn}from"./App-D-SXyZXT.js";import{z as es,d as ye,a1 as Ne,a2 as Sn,a3 as Cn,a4 as pt,a5 as Te,a6 as Pn,a7 as On,a8 as En,a9 as Rn,aa as In,ab as xt,ac as An,ad as Ln,L as Mn,N as Tn,B as qe,P as Ee,r as Bn,ae as Dn,a0 as Fn,u as ts}from"./PlacesRail-CUntVv3u.js";import{C as $n}from"./coins-D1fhjgas.js";import{C as ge,a as zn}from"./MenuMotion-CobYpP7L.js";import{b as Z,m as ss,i as We,f as Qe,c as pe,d as ht,e as Se,o as Hn,g as _n,h as oe,n as Be,t as as,s as Xe,j as ns,k as Un,l as Kn,p as qn,r as rs,q as Wn,u as Vn,w as Yn,x as is,y as ls,z as ft,B as Gn,C as os,R as gt,D as Jn,E as Qn,F as Xn,G as Zn,H as er,J as tr,O as sr,K as ar,L as cs,N as yt,V as nr,P as rr,M as ir,A as lr,a as or,S as cr,I as dr}from"./VisibilitySection-C6eVm1Hd.js";import{s as ur,r as mr,a as pr,R as xr}from"./ComputerFilesPane-Dk8NcRrf.js";import{M as vt}from"./monitor-7oLB-7rZ.js";import{a as ds,m as us,b as hr,c as fr}from"./mcp-servers-C_F4MXjY.js";import{R as gr}from"./RoutinesPage-BZhG-dR9.js";import{S as yr}from"./SignedInSites-31u9pN2b.js";import"./index-LBC94myy.js";import"./org-library-TYYMsAm5.js";import"./package-format-CrrPupM8.js";import"./WorksOnGrid-9NWPGzbE.js";import"./ProIntroduction-8BVPIU2J.js";import"./remote-desktop-DDRRx8uY.js";const vr=[["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"}]],br=Ce("calendar-plus",vr);const kr=[["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"}]],jr=Ce("library",kr);const wr=[["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"}]],ms=Ce("slack",wr);const Nr=[["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"}]],Sr=Ce("tag",Nr),Cr=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:As,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:Ls,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ms,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:Ve,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Ms,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:$t,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:jr,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Ts,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:Bs,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:Ds,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:zt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Fs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Ht,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:$s,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:$n,keywords:["tokens","cost","billing"]}],bt={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 Pr(t,a=ee()){if(!t||a==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const n=t.lastRun;if(n&&!Object.hasOwn(bt,n.status))return null;try{return[s("botOverview.routine.line",{schedule:zs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:st(t.nextRunAt)})]:[],...n?[s(bt[n.status],{time:st(n.at)})]:[]].join(" ")}catch{return null}}const kt={"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"},jt={"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 wt(t,a){return!a||a.map(n=>n||"General").join(", ")!==t?t:a.map(n=>n||s("botAccess.teams.general")).join(", ")}const Nt=t=>Object.hasOwn(jt,t)?s(jt[t]):t,St=(t,a,n)=>Number(t)===1?a:n,Or=[{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],a)=>({departments:wt(t,a)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>St(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])=>St(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],a)=>({teams:wt(t,a)})}],Er=t=>ee()!=="en"&&Object.hasOwn(Is[ee()]??{},t);function Rr(t,a){for(const n of Or){const l=n.line.exec(t);if(!l)continue;const r=n.key(l);return Er(r)?s(r,n.params(l,a)):t}return null}function De(t,a){if(Object.hasOwn(kt,t))return s(kt[t]);const n=Rr(t,a);if(n!==null)return n;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 r=ee()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(r)return s("botOverview.line.computerNotOnCloud",{preference:Nt(r[1])});const i=/^Computer preference: (.+)\.$/.exec(t);if(i)return s("botOverview.line.computer",{preference:Nt(i[1])});const c=/^Works in (.+)\.$/.exec(t);if(c)return s("botOverview.line.folder",{folder:c[1]});const d=/^Knows how to (.+)\.$/.exec(t);if(d)return s("botOverview.line.skill",{skill:d[1]});const o=/^Listens for “(.+)” webhooks\.$/.exec(t);return o?s("botOverview.line.webhook",{name:o[1]}):t}const Ct={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 Ir(t,a=ee()){const n=/^(\w+): /.exec(t)?.[1];return a==="en"||!n||!Object.hasOwn(Ct,n)?t:`${s(Ct[n])}: ${t.slice(n.length+2)}`}function Ar({data:t,error:a,open:n,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":n,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(Ae()),tokens:t.approxTokens.toLocaleString(Ae())}):s("botOverview.promptPreview")}),e.jsx(xe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",n&&"rotate-180")})]}),n&&!t&&a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),n&&!t&&!a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),n&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(r=>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:r.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:r.bytes.toLocaleString(Ae())})})]}),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:r.text})]},r.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function Lr({overview:t,refreshError:a,prompt:n,promptError:l,onOpen:r,onSetup:i}){const[c,d]=x.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const u=(t.setup??[]).filter(h=>!h.done),m=(h,b)=>s(`botOverview.setup.${h}`)||b;return e.jsxs("div",{className:"flex flex-col gap-4",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),u.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:u.map(h=>e.jsx("li",{children:h.section?e.jsxs("button",{type:"button",onClick:()=>r(h.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(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:m(h.id,h.label)}),e.jsx(ge,{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(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:m(h.id,h.label)})]})},h.id))}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:i,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(Ve,{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:()=>r("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((h,b)=>e.jsx("li",{children:Pr(t.doesRoutines?.[b])??De(h)},b))})]}),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((h,b)=>e.jsx("li",{children:De(h,t.managedSections)},b))})]}),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((h,b)=>e.jsx("li",{children:De(h,t.managedSections)},b))})]}),e.jsx(Ar,{data:n,error:l,open:c,onToggle:()=>d(h=>!h)}),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:()=>r("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ge,{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((h,b)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Ir(h.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",_t(h.at)]})]},b))})]})]})}function Mr({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(es,{size:14,"aria-hidden":"true"})]})]})}function Tr(t){if(!t||typeof t!="object")return null;const{available:a,managementUrl:n}=t;if(a!==!0||typeof n!="string")return null;try{return new URL(n).protocol==="https:"?n:null}catch{return null}}function ps(t){const[a,n]=x.useState(null);return x.useEffect(()=>{const l=new AbortController;return se(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(r=>{l.signal.aborted||n({botId:t,url:Tr(r)})}).catch(()=>{l.signal.aborted||n({botId:t,url:null})}),()=>l.abort()},[t]),a?.botId===t?a.url:null}const ne="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Fe="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 xs(t){const a=[],n=(r,i,c)=>{r&&a.push(s(r===1?i:c,{count:r}))};n(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),n(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),n(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),n(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=a.length?a.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Br(t,a){const n=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?a:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=Wn(t.path),r=t.path===Z?l:t.path===Vn?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),i=c=>s(c===1?"memory.journal.line.one":"memory.journal.line.many",{count:c});return t.kind==="created"?s("memory.journal.created",{who:n,topic:r,detail:t.added?s("memory.journal.withLines",{lines:i(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:n,topic:r}):t.added&&!t.removed?s("memory.journal.added",{who:n,lines:i(t.added),topic:r}):t.removed&&!t.added?s("memory.journal.removed",{who:n,lines:i(t.removed),topic:r}):s("memory.journal.rewrote",{who:n,lines:i(Math.max(t.added,t.removed)),topic:r})}function hs({changed:t,stale:a,busy:n,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(a?"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(r=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:r},r))})]}),e.jsx("button",{type:"button",className:O(ne,"mt-3"),disabled:n,onClick:l,children:s("memory.lendingReviewed")})]})}function Dr({bot:t,active:a=!0,onToggle:n}){const{capabilities:l}=ye(),[r,i]=x.useState(null),[c,d]=x.useState(null),[o,u]=x.useState(null),[m,h]=x.useState(null),[b,f]=x.useState(null),[v,j]=x.useState(null),[k,y]=x.useState(null),[N,S]=x.useState(!1),[E,M]=x.useState(null),[F,T]=x.useState(""),[I,z]=x.useState(null),[A,p]=x.useState(!1),[R,D]=x.useState(null),[H,_]=x.useState(!1),[G,Y]=x.useState(!1),{state:U,dispatch:g}=B(),$=Hs(U.config),[ie,ue]=x.useState(!1),[he,C]=x.useState(""),K=async w=>{const[P,Re,Rs]=await Promise.all([Qe(t.id),pe(t.id),ht(t.id).catch(()=>null)]);if(i(P),D(P.lendingReview??null),d(Re),z(Rs),w){const Ie=await Se(t.id,w);u({path:Ie.path,text:Ie.text,hash:Ie.hash,dirty:!1,readOnly:w.startsWith("memory/log/")})}};x.useEffect(()=>{if(!a)return;let w=!1;j(null);const P=o?.dirty===!0;return K(P?void 0:o?.path??Z).catch(Re=>{w||j(ae(Re))}),()=>{w=!0}},[a,t.id]);const V=async w=>{j(null),h(null);try{const P=await Se(t.id,w);u({path:P.path,text:P.text,hash:P.hash,dirty:!1,readOnly:w.startsWith("memory/log/")})}catch(P){j(ae(P))}},q=async w=>{if(o){S(!0),j(null);try{const P=await Xe(t.id,o.path,o.text,w);if(!P.ok){h({path:o.path,current:P.current,currentHash:P.currentHash});return}h(null),f(null),u({...o,text:P.doc.text,hash:P.doc.hash,dirty:!1}),i(P.overview),d(await pe(t.id))}catch(P){j(ae(P))}finally{S(!1)}}},le=()=>{!m||!o||(f(o.text),u({...o,text:m.current,hash:m.currentHash,dirty:!1}),h(null))},ve=async w=>{if(window.confirm(s("memory.confirmDelete",{name:w.name}))){j(null);try{const{overview:P}=await ns(t.id,w.path);i(P),d(await pe(t.id)),o?.path===w.path&&u(null)}catch(P){j(ae(P))}}},et=async()=>{const w=Un(F);if(!w){j(s("memory.topicNameError"));return}T(""),await V(`memory/${w}`),u(P=>P&&{...P,dirty:!0,text:P.text||Fr(w)})},Ss=async w=>{M(w.id),j(null);try{const P=await rs(t.id,w.id);i(P.overview),d(await pe(t.id)),o?.path===w.path&&!o.dirty&&u({...o,text:P.text,hash:P.hash}),y(s("memory.restored",{path:w.path}))}catch(P){j(ae(P))}finally{M(null)}},tt=async w=>{j(null),y(null);try{await Hn(t.id,w)}catch(P){j(ae(P))}},Cs=()=>{const w=t.memoryUpkeep===!1;g({type:"updateBot",botId:t.id,patch:{memoryUpkeep:w}}),z(P=>P&&{...P,enabled:w})},Ps=async()=>{if(!ie){ue(!0),C("");try{const w=await se("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!$}})});g({type:"configStatus",config:w})}catch(w){C(w instanceof Error?w.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},Os=async()=>{p(!0),j(null),y(null);try{const{report:w,overview:P}=await as(t.id);i(P),d(await pe(t.id)),z(await ht(t.id)),o&&!o.dirty&&await V(o.path),y(`${xs(w)}.${w.note?` ${w.note}`:""}`)}catch(w){j(ae(w))}finally{p(!1)}},Es=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:w=>n(w.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")}),r&&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:r.workspacePath,children:Ye(r.workspacePath,Es)}),e.jsx("button",{type:"button",className:ne,onClick:()=>{tt("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(ne,"inline-flex items-center gap-1.5"),onClick:()=>{tt("folder")},children:[e.jsx(Ut,{size:14}),s("memory.showFileManager")]})]})]}),R&&e.jsx(hs,{changed:R.changed,stale:H,busy:G,onReviewed:()=>{Y(!0),ss(t.id,R.token).then(()=>{D(null),_(!1)}).catch(w=>{if(w instanceof Kt&&w.status===409)return _(!0),K();j(ae(w))}).finally(()=>Y(!1))}}),r&&e.jsx(zr,{index:r.index}),t.memoryEnabled!==!1&&e.jsx($r,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:Cs,onTidy:()=>{Os()},rooms:{enabled:$,saving:ie,error:he,onToggle:()=>{Ps()}}}),o&&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:o.path}),o.path!==Z&&e.jsx("button",{type:"button",className:Fe,onClick:()=>{V(Z)},children:s("memory.backToIndex")})]}),m&&e.jsx(fs,{botName:t.name,busy:N,onReload:le,onOverwrite:()=>{q(m.currentHash)}}),e.jsx("textarea",{className:O(We,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:o.text,readOnly:o.readOnly,placeholder:o.path===Z?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":o.path===Z?s("memory.botMemory"):s("memory.fileLabel",{path:o.path}),onChange:w=>u({...o,text:w.target.value,dirty:!0})}),o.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:()=>{q(o.hash)},disabled:N||!o.dirty,className:ne,children:N?s("memory.saving"):s("memory.save")}),o.dirty&&e.jsx("button",{type:"button",className:Fe,disabled:N,onClick:()=>{V(o.path)},children:s("memory.discard")})]}),b!==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:b}),e.jsx("button",{type:"button",className:O(Fe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]})]}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Ot,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:r.topics,selected:o?.path,onOpen:w=>{V(w.path)},onDelete:w=>{ve(w)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(We,"py-1.5 text-[13px]"),value:F,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:w=>T(w.target.value),onKeyDown:w=>{w.key==="Enter"&&et()}}),e.jsx("button",{type:"button",className:ne,disabled:!F.trim(),onClick:()=>{et()},children:s("memory.newTopic")})]}),r.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Ot,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:r.logs,selected:o?.path,onOpen:w=>{V(w.path)},onDelete:w=>{ve(w)}})})]}),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(Ze,{rows:c,botName:t.name,reverting:E,onRevert:w=>{Ss(w)}})})]}),k&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:k}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function Fr(t){return`---
1
+ import{c as Ce,t as s,b as ee,av as Is,j as e,i as Le,a9 as xe,a as O,r as x,S as Bt,ac as Dt,X as Ft}from"./styles-C2_XZv1s.js";import{ff as Ls,fg as As,a2 as Ve,by as Ms,dh as $t,w as Ts,fh as Bs,fi as Ds,K as zt,fj as Fs,R as Ht,et as $s,x as zs,fk as st,bt as at,fl as _t,n as se,u as B,fm as Hs,ah as Ye,F as Ut,A as Kt,S as nt,ad as Pe,T as qt,W as _s,fn as Us,fo as Ks,fp as qs,fq as Ws,fr as Vs,fs as rt,ft as Ys,fu as Js,fv as Gs,fw as Xs,b9 as Qs,fx as Zs,fy as ea,fz as ta,I as sa,fA as je,bO as Je,fB as aa,aI as A,aO as Q,ec as na,dJ as ra,fC as ia,aJ as He,co as la,dY as oa,dZ as ca,fD as da,fE as Wt,fF as Vt,fG as ua,fH as ma,fI as pa,fJ as xa,dM as _e,ar as it,fK as Ae,fL as ha,fM as we,av as fa,fN as Yt,fO as lt,ak as Ue,fP as ga,fQ as ya,fR as va,fS as Jt,fT as ba,fU as ka,fV as ja,fW as wa,fX as X,aX as te,aZ as G,fY as Na,fZ as Sa,f_ as Ca,d4 as Pa,d as Oa,G as Ea,d2 as Gt,aj as Ra,f$ as W,aW as ce,g0 as de,g1 as Ia,dn as La,g2 as Oe,aY as re,g3 as Aa,g4 as Ma,g5 as Ta,eg as Ba,g6 as ot,g7 as Da,g8 as Fa,g9 as $a,ga as za,gb as Ha,gc as _a,aC as Ua,gd as Xt,ge as Ka,gf as qa,gg as Wa,gh as Va,gi as Ya,gj as Ja,gk as Ga,gl as Xa,gm as Qa,gn as Za,go as en,gp as tn,gq as Ge,k as sn,B as Ke,gr as an,gs as nn,gt as rn,gu as ln,bX as on,gv as Qt,J as ct,eX as cn,gw as dt,gx as dn,gy as un,cL as ut,bw as mn,d1 as pn,gz as xn,gA as Zt,gB as be,gC as mt,gD as hn,aM as Me,d_ as fn,gE as gn,aR as yn,C as vn,cp as bn,gF as kn,gG as jn,gH as wn,aT as Nn}from"./App-BWtQhGWp.js";import{z as es,d as ye,a1 as Ne,a2 as Sn,a3 as Cn,a4 as pt,a5 as Te,a6 as Pn,a7 as On,a8 as En,a9 as Rn,aa as In,ab as xt,ac as Ln,ad as An,L as Mn,N as Tn,B as qe,P as Ee,r as Bn,ae as Dn,a0 as Fn,u as ts}from"./PlacesRail-PP97GpM6.js";import{C as $n}from"./coins-BHKpT34i.js";import{C as ge,a as zn}from"./MenuMotion-CSgaJLc2.js";import{b as Z,m as ss,i as We,f as Xe,c as pe,d as ht,e as Se,o as Hn,g as _n,h as oe,n as Be,t as as,s as Qe,j as ns,k as Un,l as Kn,p as qn,r as rs,q as Wn,u as Vn,w as Yn,x as is,y as ls,z as ft,B as Jn,C as os,R as gt,D as Gn,E as Xn,F as Qn,G as Zn,H as er,J as tr,O as sr,K as ar,L as cs,N as yt,V as nr,P as rr,M as ir,A as lr,a as or,S as cr,I as dr}from"./VisibilitySection-DH0WrBCn.js";import{s as ur,r as mr,a as pr,R as xr}from"./ComputerFilesPane-Bjx6TGmM.js";import{M as vt}from"./monitor-DuYHWIyw.js";import{a as ds,m as us,b as hr,c as fr}from"./mcp-servers-DXFuhTlS.js";import{R as gr}from"./RoutinesPage-ZdFTYQc-.js";import{S as yr}from"./SignedInSites-CyWcDbLW.js";import"./index-BSrb6nsc.js";import"./org-library-BLD6YHcM.js";import"./package-format-72bbOy2w.js";import"./WorksOnGrid-CboITAAs.js";import"./ProIntroduction-C-7uexIW.js";import"./remote-desktop-DDRRx8uY.js";const vr=[["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"}]],br=Ce("calendar-plus",vr);const kr=[["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"}]],jr=Ce("library",kr);const wr=[["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"}]],ms=Ce("slack",wr);const Nr=[["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"}]],Sr=Ce("tag",Nr),Cr=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:Ls,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:As,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ms,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:Ve,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Ms,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:$t,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:jr,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Ts,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:Bs,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:Ds,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:zt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Fs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Ht,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:$s,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:$n,keywords:["tokens","cost","billing"]}],bt={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 Pr(t,a=ee()){if(!t||a==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const n=t.lastRun;if(n&&!Object.hasOwn(bt,n.status))return null;try{return[s("botOverview.routine.line",{schedule:zs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:st(t.nextRunAt)})]:[],...n?[s(bt[n.status],{time:st(n.at)})]:[]].join(" ")}catch{return null}}const kt={"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"},jt={"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 wt(t,a){return!a||a.map(n=>n||"General").join(", ")!==t?t:a.map(n=>n||s("botAccess.teams.general")).join(", ")}const Nt=t=>Object.hasOwn(jt,t)?s(jt[t]):t,St=(t,a,n)=>Number(t)===1?a:n,Or=[{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],a)=>({departments:wt(t,a)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>St(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])=>St(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],a)=>({teams:wt(t,a)})}],Er=t=>ee()!=="en"&&Object.hasOwn(Is[ee()]??{},t);function Rr(t,a){for(const n of Or){const l=n.line.exec(t);if(!l)continue;const r=n.key(l);return Er(r)?s(r,n.params(l,a)):t}return null}function De(t,a){if(Object.hasOwn(kt,t))return s(kt[t]);const n=Rr(t,a);if(n!==null)return n;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 r=ee()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(r)return s("botOverview.line.computerNotOnCloud",{preference:Nt(r[1])});const i=/^Computer preference: (.+)\.$/.exec(t);if(i)return s("botOverview.line.computer",{preference:Nt(i[1])});const c=/^Works in (.+)\.$/.exec(t);if(c)return s("botOverview.line.folder",{folder:c[1]});const d=/^Knows how to (.+)\.$/.exec(t);if(d)return s("botOverview.line.skill",{skill:d[1]});const o=/^Listens for “(.+)” webhooks\.$/.exec(t);return o?s("botOverview.line.webhook",{name:o[1]}):t}const Ct={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 Ir(t,a=ee()){const n=/^(\w+): /.exec(t)?.[1];return a==="en"||!n||!Object.hasOwn(Ct,n)?t:`${s(Ct[n])}: ${t.slice(n.length+2)}`}function Lr({data:t,error:a,open:n,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":n,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(Le()),tokens:t.approxTokens.toLocaleString(Le())}):s("botOverview.promptPreview")}),e.jsx(xe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",n&&"rotate-180")})]}),n&&!t&&a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),n&&!t&&!a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),n&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(r=>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:r.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:r.bytes.toLocaleString(Le())})})]}),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:r.text})]},r.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function Ar({overview:t,refreshError:a,prompt:n,promptError:l,onOpen:r,onSetup:i}){const[c,d]=x.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const u=(t.setup??[]).filter(h=>!h.done),m=(h,b)=>s(`botOverview.setup.${h}`)||b;return e.jsxs("div",{className:"flex flex-col gap-4",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),u.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:u.map(h=>e.jsx("li",{children:h.section?e.jsxs("button",{type:"button",onClick:()=>r(h.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(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:m(h.id,h.label)}),e.jsx(ge,{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(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:m(h.id,h.label)})]})},h.id))}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:i,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(Ve,{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:()=>r("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((h,b)=>e.jsx("li",{children:Pr(t.doesRoutines?.[b])??De(h)},b))})]}),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((h,b)=>e.jsx("li",{children:De(h,t.managedSections)},b))})]}),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((h,b)=>e.jsx("li",{children:De(h,t.managedSections)},b))})]}),e.jsx(Lr,{data:n,error:l,open:c,onToggle:()=>d(h=>!h)}),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:()=>r("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ge,{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((h,b)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Ir(h.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",_t(h.at)]})]},b))})]})]})}function Mr({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(es,{size:14,"aria-hidden":"true"})]})]})}function Tr(t){if(!t||typeof t!="object")return null;const{available:a,managementUrl:n}=t;if(a!==!0||typeof n!="string")return null;try{return new URL(n).protocol==="https:"?n:null}catch{return null}}function ps(t){const[a,n]=x.useState(null);return x.useEffect(()=>{const l=new AbortController;return se(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(r=>{l.signal.aborted||n({botId:t,url:Tr(r)})}).catch(()=>{l.signal.aborted||n({botId:t,url:null})}),()=>l.abort()},[t]),a?.botId===t?a.url:null}const ne="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Fe="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 xs(t){const a=[],n=(r,i,c)=>{r&&a.push(s(r===1?i:c,{count:r}))};n(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),n(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),n(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),n(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=a.length?a.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Br(t,a){const n=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?a:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=Wn(t.path),r=t.path===Z?l:t.path===Vn?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),i=c=>s(c===1?"memory.journal.line.one":"memory.journal.line.many",{count:c});return t.kind==="created"?s("memory.journal.created",{who:n,topic:r,detail:t.added?s("memory.journal.withLines",{lines:i(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:n,topic:r}):t.added&&!t.removed?s("memory.journal.added",{who:n,lines:i(t.added),topic:r}):t.removed&&!t.added?s("memory.journal.removed",{who:n,lines:i(t.removed),topic:r}):s("memory.journal.rewrote",{who:n,lines:i(Math.max(t.added,t.removed)),topic:r})}function hs({changed:t,stale:a,busy:n,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(a?"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(r=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:r},r))})]}),e.jsx("button",{type:"button",className:O(ne,"mt-3"),disabled:n,onClick:l,children:s("memory.lendingReviewed")})]})}function Dr({bot:t,active:a=!0,onToggle:n}){const{capabilities:l}=ye(),[r,i]=x.useState(null),[c,d]=x.useState(null),[o,u]=x.useState(null),[m,h]=x.useState(null),[b,f]=x.useState(null),[v,j]=x.useState(null),[k,y]=x.useState(null),[N,S]=x.useState(!1),[E,M]=x.useState(null),[F,T]=x.useState(""),[I,z]=x.useState(null),[L,p]=x.useState(!1),[R,D]=x.useState(null),[H,_]=x.useState(!1),[J,Y]=x.useState(!1),{state:U,dispatch:g}=B(),$=Hs(U.config),[ie,ue]=x.useState(!1),[he,C]=x.useState(""),K=async w=>{const[P,Re,Rs]=await Promise.all([Xe(t.id),pe(t.id),ht(t.id).catch(()=>null)]);if(i(P),D(P.lendingReview??null),d(Re),z(Rs),w){const Ie=await Se(t.id,w);u({path:Ie.path,text:Ie.text,hash:Ie.hash,dirty:!1,readOnly:w.startsWith("memory/log/")})}};x.useEffect(()=>{if(!a)return;let w=!1;j(null);const P=o?.dirty===!0;return K(P?void 0:o?.path??Z).catch(Re=>{w||j(ae(Re))}),()=>{w=!0}},[a,t.id]);const V=async w=>{j(null),h(null);try{const P=await Se(t.id,w);u({path:P.path,text:P.text,hash:P.hash,dirty:!1,readOnly:w.startsWith("memory/log/")})}catch(P){j(ae(P))}},q=async w=>{if(o){S(!0),j(null);try{const P=await Qe(t.id,o.path,o.text,w);if(!P.ok){h({path:o.path,current:P.current,currentHash:P.currentHash});return}h(null),f(null),u({...o,text:P.doc.text,hash:P.doc.hash,dirty:!1}),i(P.overview),d(await pe(t.id))}catch(P){j(ae(P))}finally{S(!1)}}},le=()=>{!m||!o||(f(o.text),u({...o,text:m.current,hash:m.currentHash,dirty:!1}),h(null))},ve=async w=>{if(window.confirm(s("memory.confirmDelete",{name:w.name}))){j(null);try{const{overview:P}=await ns(t.id,w.path);i(P),d(await pe(t.id)),o?.path===w.path&&u(null)}catch(P){j(ae(P))}}},et=async()=>{const w=Un(F);if(!w){j(s("memory.topicNameError"));return}T(""),await V(`memory/${w}`),u(P=>P&&{...P,dirty:!0,text:P.text||Fr(w)})},Ss=async w=>{M(w.id),j(null);try{const P=await rs(t.id,w.id);i(P.overview),d(await pe(t.id)),o?.path===w.path&&!o.dirty&&u({...o,text:P.text,hash:P.hash}),y(s("memory.restored",{path:w.path}))}catch(P){j(ae(P))}finally{M(null)}},tt=async w=>{j(null),y(null);try{await Hn(t.id,w)}catch(P){j(ae(P))}},Cs=()=>{const w=t.memoryUpkeep===!1;g({type:"updateBot",botId:t.id,patch:{memoryUpkeep:w}}),z(P=>P&&{...P,enabled:w})},Ps=async()=>{if(!ie){ue(!0),C("");try{const w=await se("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!$}})});g({type:"configStatus",config:w})}catch(w){C(w instanceof Error?w.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},Os=async()=>{p(!0),j(null),y(null);try{const{report:w,overview:P}=await as(t.id);i(P),d(await pe(t.id)),z(await ht(t.id)),o&&!o.dirty&&await V(o.path),y(`${xs(w)}.${w.note?` ${w.note}`:""}`)}catch(w){j(ae(w))}finally{p(!1)}},Es=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:w=>n(w.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")}),r&&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:r.workspacePath,children:Ye(r.workspacePath,Es)}),e.jsx("button",{type:"button",className:ne,onClick:()=>{tt("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(ne,"inline-flex items-center gap-1.5"),onClick:()=>{tt("folder")},children:[e.jsx(Ut,{size:14}),s("memory.showFileManager")]})]})]}),R&&e.jsx(hs,{changed:R.changed,stale:H,busy:J,onReviewed:()=>{Y(!0),ss(t.id,R.token).then(()=>{D(null),_(!1)}).catch(w=>{if(w instanceof Kt&&w.status===409)return _(!0),K();j(ae(w))}).finally(()=>Y(!1))}}),r&&e.jsx(zr,{index:r.index}),t.memoryEnabled!==!1&&e.jsx($r,{enabled:t.memoryUpkeep!==!1,status:I,tidying:L,onToggle:Cs,onTidy:()=>{Os()},rooms:{enabled:$,saving:ie,error:he,onToggle:()=>{Ps()}}}),o&&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:o.path}),o.path!==Z&&e.jsx("button",{type:"button",className:Fe,onClick:()=>{V(Z)},children:s("memory.backToIndex")})]}),m&&e.jsx(fs,{botName:t.name,busy:N,onReload:le,onOverwrite:()=>{q(m.currentHash)}}),e.jsx("textarea",{className:O(We,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:o.text,readOnly:o.readOnly,placeholder:o.path===Z?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":o.path===Z?s("memory.botMemory"):s("memory.fileLabel",{path:o.path}),onChange:w=>u({...o,text:w.target.value,dirty:!0})}),o.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:()=>{q(o.hash)},disabled:N||!o.dirty,className:ne,children:N?s("memory.saving"):s("memory.save")}),o.dirty&&e.jsx("button",{type:"button",className:Fe,disabled:N,onClick:()=>{V(o.path)},children:s("memory.discard")})]}),b!==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:b}),e.jsx("button",{type:"button",className:O(Fe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]})]}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Ot,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:r.topics,selected:o?.path,onOpen:w=>{V(w.path)},onDelete:w=>{ve(w)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(We,"py-1.5 text-[13px]"),value:F,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:w=>T(w.target.value),onKeyDown:w=>{w.key==="Enter"&&et()}}),e.jsx("button",{type:"button",className:ne,disabled:!F.trim(),onClick:()=>{et()},children:s("memory.newTopic")})]}),r.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Ot,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:r.logs,selected:o?.path,onOpen:w=>{V(w.path)},onDelete:w=>{ve(w)}})})]}),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(Ze,{rows:c,botName:t.name,reverting:E,onRevert:w=>{Ss(w)}})})]}),k&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:k}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function Fr(t){return`---
2
2
  title: ${t.replace(/\.md$/,"")}
3
3
  description:
4
4
  aliases: []
5
5
  ---
6
6
 
7
- `}function $r({enabled:t,status:a,tidying:n,onToggle:l,onTidy:r,rooms:i}){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(nt,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&i&&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")}),a&&!a.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),i.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:i.error})]}),e.jsx(nt,{checked:i.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:i.saving,onClick:i.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&a&&!a.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:ne,disabled:n,onClick:r,children:n?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[a?.lastTidy?s("memory.upkeep.lastTidy",{time:Ne(a.lastTidy.at,ee()),summary:xs(a.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),a?.lastCapture&&Be(a.lastCapture)?` ${s(Be(a.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:Be(a.lastCapture),time:Ne(a.lastCapture.at,ee())})}`:""]})]})]})}function zr({index:t}){const a=_n(t),n=a.level==="over"?"bg-danger":a.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",a.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]",a.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes)})})]}),e.jsx(Pt,{label:s("memory.capacity.lines"),share:a.lineShare,fill:n}),e.jsx(Pt,{label:s("memory.capacity.size"),share:a.byteShare,fill:n}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",a.level==="over"?"text-danger":"text-ink-secondary"),children:a.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})}),a.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})})]})}function Pt({label:t,share:a,fill:n}){const l=`${Math.min(100,Math.round(a*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(a*100)),children:e.jsx("div",{className:O("h-full rounded-full",n),style:{width:l}})})]})}function fs({botName:t,busy:a,onReload:n,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:ne,disabled:a,onClick:n,children:s("memory.reload")}),e.jsx("button",{type:"button",className:ne,disabled:a,onClick:l,children:s("memory.overwrite")})]})]})}function Ot({title:t,hint:a,files:n,selected:l,onOpen:r,onDelete:i}){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:a}),n.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:n.map(c=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===c.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>r(c),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:c.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[oe(c.bytes)," · ",Ne(c.modifiedAt,ee())]})]}),e.jsx("button",{type:"button",onClick:()=>i(c),"aria-label":s("memory.deleteFile",{name:c.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(qt,{size:14})})]},c.path))})]})}function Ze({rows:t,botName:a,reverting:n,onRevert:l,now:r=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(i=>{const c=Kn(i),d=qn(i);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:Br(i,a)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Ne(i.at,ee(),r)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:d?s(d,i.threadTitle?{title:i.threadTitle}:void 0):c})]})]}),i.canRevert?e.jsxs("button",{type:"button",disabled:n!==null,onClick:()=>l(i),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(_s,{size:12}),n===i.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:i.revertUnavailableReason,children:s("memory.cantUndo")})]}),i.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",i.added," −",i.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:i.diff})]})]},i.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Hr({bot:t,rows:a,refreshError:n,onRollback:l,rollingBack:r}){if(!a)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(a.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const i=[...a].sort((c,d)=>d.at-c.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),i.map(c=>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:_t(c.at)})," · ",e.jsxs("span",{children:[c.actor," via ",c.via]})," · ",e.jsx("span",{children:c.summary})]}),c.field==="soul"&&c.canRestore===!0&&e.jsx("button",{type:"button",disabled:r,onClick:()=>l(c.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")})]}),c.field==="soul"&&c.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:c.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${c.id}`))]})}function _r({bot:t,bare:a=!1}){const{state:n,dispatch:l}=B(),r=Us(t),i=n.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return r.turns===0?e.jsx("div",{className:O(a?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:a?void 0:"rounded-xl bg-card p-4",children:[!a&&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(ge,{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]",!a&&"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:r.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:Ks(r)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:Vs(r),children:qs(Ws(r))})]}),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:rt(r.costUsd)?Ys(r.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:rt(r.costUsd)?s("usage.costLine",{caption:Gs(i?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Ur=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Kr=["circle","rounded","square"],qr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},Wr={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"},Vr=t=>{const a=Wr[t];return a?s(a):t};function Yr({bot:t,activeState:a,onPatch:n,onClose:l}){const r=Js(t,n),{fileRef:i,crop:c,uploading:d,generating:o,busy:u,error:m,upload:h,removeImage:b,generate:f}=r,v=c!=="mascot"&&!!t.avatarUrl,[j,k]=x.useState(v?"upload":"bot"),y=x.useRef(null);x.useEffect(()=>{y.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const N=p=>n(c==="mascot"?p:{...p,avatarCrop:"mascot"}),S=t.mascotBody??"cursor",E=Sn(),M=Cn(t.mascotBody,t.color,E),[F,T]=x.useState(()=>!!E||pt(S)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=E&&M!==S&&pt(M)?Te(M):null,z=(p,R)=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":!v&&S===p,"aria-label":s("mascot.useBody",{name:R}),title:R,onClick:()=>N({mascotBody:p}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&S===p?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Tn,{color:t.color,faceColor:t.mascotFaceColor,bodyId:p,size:40,animated:!1,trackPointer:!1})},p),A=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,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:y,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Ur.map(([p,R])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===p,"data-avatar-tab":p,onClick:()=>k(p),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===p?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(R)},p)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:u,onClick:()=>n(Qs),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:Pn.map(p=>z(p,Te(p)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:Xs.map(p=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":t.color===p,"aria-label":s("mascot.useColor",{color:Rn(p)}),title:s(En[p]),onClick:()=>N({color:p}),className:O("size-6 rounded-full disabled:opacity-50",t.color===p&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:On(p)}},p))}),e.jsx(Yn,{bot:t,disabled:u,onPatch:N}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":F,onClick:()=>T(p=>!p),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(xe,{size:13,"aria-hidden":"true",className:O("transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[In.map(p=>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:xt(p)}),p===E&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:xt(p)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":p,children:An[p].bodies.map(R=>z(R,Te(R)))})]},p)),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")}),Ln.map(p=>e.jsx("button",{type:"button",disabled:u,"data-avatar-face":p,"aria-pressed":a===p,onClick:()=>N({mascotExpression:p}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",a===p?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:Vr(p)},p))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(Zs,{botLabel:t.title||t.name,disabled:d,generating:o,onGenerate:f})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(ea,{busy:u,onUpload:p=>{h(p)}}),v&&e.jsx(ta,{bot:t,disabled:u,onPatch:n}),e.jsx("input",{ref:i,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:p=>{h(p.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:u,onClick:()=>i.current?.click(),onDragOver:p=>p.preventDefault(),onDrop:p=>{p.preventDefault(),h(p.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:[d?e.jsx(Mn,{size:22,className:"animate-spin"}):e.jsx(sa,{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(je,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?c:null,onChange:p=>n({avatarCrop:p}),options:Kr.map(p=>({value:p,label:s(qr[p]),disabled:u||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:b,disabled:u,"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(qt,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),m&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:m})]})]})}const Gr=()=>s("place.off");function gs(t){const{dispatch:a}=B();return(n="computer")=>{ra(t.id,n),a({type:"toggleSettings",open:!1}),a({type:"toggleComputer",open:!0})}}function Jr(t,a){const[n,l]=x.useState(null);return x.useEffect(()=>{if(!a)return;let r=!1;return se(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(i=>{r||l({botId:t.id,count:i.sites?.length??0})}).catch(()=>{}),()=>{r=!0}},[t.id,a]),n?.botId===t.id?n.count:null}function ys(t){const{state:a}=B(),{capabilities:n}=ye(),l=n.host?.platform??"other",r=ia(t),i=t.computer??"auto",c=a.config?.browserEngine?.myChrome===!0&&(a.config?.browserProfiles??[]).some(f=>f.id===t.browserProfile&&f.browser==="chrome"),d=f=>f==="browser"&&c?s("settings.profiles.myChrome"):ca(f,l),o=f=>{const{view:v,reachable:j}=r[f];return{value:f,label:d(f),disabled:!j,hint:!j||oa(v)?v.line:void 0}},u=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...r.local.policy?[o("local")]:[],...r.browser.policy||i==="browser"?[o("browser")]:[],...r.cloud.policy?[o("cloud")]:[],...r.vm.policy||i==="vm"?[o("vm")]:[],...i==="off"?[{value:i,label:Gr(),disabled:!0}]:[]],m=t.tasks?.find(f=>f.threadId===t.threadId)?.surface,h=m&&m!==i?d(m):null,b=u.find(f=>f.value===i)?.label??(i==="auto"||i==="off"?void 0:d(i));return{options:u,current:i,currentLabel:b,usingNow:h}}function Qr({bot:t,derived:a}){const{dispatch:n}=B(),{options:l,current:r,usingNow:i}=ys(t),[c,d]=x.useState(null),{patch:o,approvalMode:u}=a,m=h=>{if(!(h===r||h==="off")){if(h==="local"&&u==="auto"){d({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}o(h==="browser"?{computer:"browser",browser:!0}:{computer:h==="auto"?null:h})}};return e.jsxs(e.Fragment,{children:[e.jsx(L,{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(h=>e.jsx(He,{"data-panel-choice":h.value,title:h.label,hint:h.hint,checked:r===h.value,disabled:h.disabled,onClick:()=>m(h.value)},h.value))})}),i&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:i})}),e.jsx(la,{open:c!==null,onCancel:()=>d(null),onConfirm:()=>{const h=c;d(null),h&&n({type:"updateBot",botId:h.botId,patch:h.patch})}})]})}function Xr({bot:t,derived:a,onOpen:n}){const l=gs(t),r=Ge(),{browserEnabled:i}=a,c=Jr(t,i&&t.computer!=="off"&&r!==!1),{currentLabel:d,usingNow:o}=ys(t),u=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(b=>b.kind==="screen"&&(b.hasImage||b.png)),h=m?aa({threadId:t.threadId,messageId:m.id},m.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")}: ${u}`,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:[h?e.jsx("img",{src:h,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(qe,{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(qe,{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(vt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:u}),e.jsxs(L,{anchor:"where",children:[e.jsx(X,{"data-panel-page":"where",icon:vt,title:s("computer.simple.whereWorks",{name:t.name}),hint:o?s("computer.simple.usingNow",{place:o}):void 0,value:d,onClick:()=>n("where")}),e.jsx(X,{"data-panel-page":"browser",icon:na,title:s("settings.sites.title"),value:c??void 0,onClick:()=>n("browser")})]})]})}const Zr=3,Et="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",ei=8,ti=200,me=new Map,$e=new Set,Rt=t=>`${t.threadId}@${Gt(t)}`;function si(t,a){const[,n]=x.useState(0),r=a.filter(d=>d.threadId!==t.threadId).map(Rt).filter(d=>!me.has(d)&&!$e.has(d)).join(",");x.useEffect(()=>{if(r)for(const d of r.split(",")){$e.add(d);const o=d.slice(0,d.lastIndexOf("@"));se(`/api/threads/${encodeURIComponent(o)}/messages?limit=${ei}`,{background:!0}).then(u=>{me.set(d,Ue({messages:u.messages??[],activeLeafId:u.activeLeafId??void 0})),me.size>ti&&me.delete(me.keys().next().value),n(m=>m+1)}).catch(()=>{}).finally(()=>$e.delete(d))}},[r]);const i=Ue(t),c=new Map(a.map(d=>[d.threadId,Rt(d)]));return d=>d===t.threadId?i:me.get(c.get(d)??"")}function ai({bot:t}){const{state:a,dispatch:n}=B(),l=da(),r=!Wt(Vt,!0),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,m]=x.useState(!1),[h,b]=x.useState(!1),f=ua(a.config),v=x.useMemo(()=>{const{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:ue,onPin:he,onArchive:C}=ma(t.id,n,f);return{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:ue,onPin:he,onArchive:C}},[t.id,n,f]),j=pa(t),k=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],y=(j?xa({...t,tasks:k},j):k).filter(g=>!g.routineRunId).map(g=>{const $=_e(t,g.threadId);return{...g,busy:$.busy,activity:$.activity,waitingForTeammates:$.waitingForTeammates,turnStartedAt:$.turnStartedAt??void 0,queued:!!a.pendingQueued[g.threadId]?.length}}),N=it(y.filter(g=>!Le(g)||g.threadId===t.threadId)),S=it(y.filter(g=>Le(g)&&g.threadId!==t.threadId)),E=i.trim(),M=N.filter((g,$)=>$<Zr||g.threadId===t.threadId),F=si(t,[...E||u?N:M,...h?S:[]]),T=g=>{const $=F(g);return $?ga(_e(t,g),$,a.instances,!1):void 0},I=ha(N,E),z=E?[...I,...N.filter(g=>!I.includes(g)&&T(g.threadId)?.toLowerCase().includes(E.toLowerCase()))]:N,A=E?z:u?N:M,p=N.length-M.length,R=t.projects?.find(g=>g.id===t.tasks?.find($=>$.threadId===t.threadId)?.projectId),D=()=>{r&&n({type:"toggleSettings",open:!1})},H=g=>{g.threadId!==t.threadId&&ba(n,t,g.threadId,!1),D()},_=()=>{n({type:"newTask",botId:t.id,...R?{projectId:R.id}:{}}),D()},G=()=>{c(""),o(!1)},Y=N.length>=2||d||N.some(g=>g.threadId===t.threadId&&Le(g)),U=g=>e.jsx("div",{role:"listitem","data-conversation":g.threadId,children:e.jsx(ya,{panel:!0,preview:T(g.threadId),task:g,ownerId:t.id,current:g.threadId===t.threadId,folders:t.projects,now:va(Gt(g),l),locale:ee(),onSelect:H,...v})},g.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(we,{action:Y&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":d,onClick:()=>d?G():o(!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",d&&"bg-ink/[0.06] text-ink"),children:e.jsx(Bt,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",Y&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:_,className:O(Yt,"flex-1"),children:[e.jsx(fa,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&d&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:i,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),G())},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"}),Y&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",Et),children:A.map(U)}),Y&&E&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:E})}),Y&&!E&&p>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":u,onClick:()=>m(g=>!g),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:[u?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,"aria-hidden":"true"}),u?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:p})]}),!E&&S.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":h,onClick:()=>b(g=>!g),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:[h?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:S.length})]}),!E&&h&&S.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:S.length}),className:O("flex flex-col gap-px",Et),children:S.map(U)})]})}function ni({bot:t}){const{dispatch:a}=B();return Dt()||!t.defaultBot?null:e.jsx(L,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:ka.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>a({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 ri=["find","start-fresh","usage","activity","inspector"];function ii({item:t}){const a=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(J,"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",!a&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",a?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ge,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function li({bot:t,derived:a,onOpen:n}){const{items:l}=ja(t),{dispatch:r}=B(),i=a.botRoutines.filter(d=>d.enabled).length,c=ri.flatMap(d=>l.filter(o=>o.key===d));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(J,"rounded-[8px]"),children:e.jsx(wa,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(Q,{icon:Ve}),e.jsx(te,{title:s("model.simple.model")})]})})})}),e.jsx(ai,{bot:t}),e.jsx(ni,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(we,{children:s("botPanel.section.conversation")}),c.map(d=>e.jsx(ii,{item:d},d.key))]}),a.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(we,{action:e.jsx(Na,{"data-panel-automations":"",onClick:()=>r({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:()=>n("routines"),className:O(Yt,"w-full"),children:[e.jsx(br,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(L,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(X,{"data-panel-page":"routines",icon:Sa,title:s("botSettings.simple.routines"),value:i>0?s("botPanel.routinesOn",{count:i}):s("botPanel.none"),onClick:()=>n("routines")})})]})}const vs=/^\s*[-*]\s+(.+?)\s*$/;function oi(t){return t.split(`
7
+ `}function $r({enabled:t,status:a,tidying:n,onToggle:l,onTidy:r,rooms:i}){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(nt,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&i&&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")}),a&&!a.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),i.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:i.error})]}),e.jsx(nt,{checked:i.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:i.saving,onClick:i.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&a&&!a.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:ne,disabled:n,onClick:r,children:n?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[a?.lastTidy?s("memory.upkeep.lastTidy",{time:Ne(a.lastTidy.at,ee()),summary:xs(a.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),a?.lastCapture&&Be(a.lastCapture)?` ${s(Be(a.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:Be(a.lastCapture),time:Ne(a.lastCapture.at,ee())})}`:""]})]})]})}function zr({index:t}){const a=_n(t),n=a.level==="over"?"bg-danger":a.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",a.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]",a.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes)})})]}),e.jsx(Pt,{label:s("memory.capacity.lines"),share:a.lineShare,fill:n}),e.jsx(Pt,{label:s("memory.capacity.size"),share:a.byteShare,fill:n}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",a.level==="over"?"text-danger":"text-ink-secondary"),children:a.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})}),a.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})})]})}function Pt({label:t,share:a,fill:n}){const l=`${Math.min(100,Math.round(a*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(a*100)),children:e.jsx("div",{className:O("h-full rounded-full",n),style:{width:l}})})]})}function fs({botName:t,busy:a,onReload:n,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:ne,disabled:a,onClick:n,children:s("memory.reload")}),e.jsx("button",{type:"button",className:ne,disabled:a,onClick:l,children:s("memory.overwrite")})]})]})}function Ot({title:t,hint:a,files:n,selected:l,onOpen:r,onDelete:i}){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:a}),n.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:n.map(c=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===c.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>r(c),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:c.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[oe(c.bytes)," · ",Ne(c.modifiedAt,ee())]})]}),e.jsx("button",{type:"button",onClick:()=>i(c),"aria-label":s("memory.deleteFile",{name:c.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(qt,{size:14})})]},c.path))})]})}function Ze({rows:t,botName:a,reverting:n,onRevert:l,now:r=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(i=>{const c=Kn(i),d=qn(i);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:Br(i,a)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Ne(i.at,ee(),r)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:d?s(d,i.threadTitle?{title:i.threadTitle}:void 0):c})]})]}),i.canRevert?e.jsxs("button",{type:"button",disabled:n!==null,onClick:()=>l(i),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(_s,{size:12}),n===i.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:i.revertUnavailableReason,children:s("memory.cantUndo")})]}),i.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",i.added," −",i.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:i.diff})]})]},i.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Hr({bot:t,rows:a,refreshError:n,onRollback:l,rollingBack:r}){if(!a)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(a.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const i=[...a].sort((c,d)=>d.at-c.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),i.map(c=>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:_t(c.at)})," · ",e.jsxs("span",{children:[c.actor," via ",c.via]})," · ",e.jsx("span",{children:c.summary})]}),c.field==="soul"&&c.canRestore===!0&&e.jsx("button",{type:"button",disabled:r,onClick:()=>l(c.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")})]}),c.field==="soul"&&c.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:c.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${c.id}`))]})}function _r({bot:t,bare:a=!1}){const{state:n,dispatch:l}=B(),r=Us(t),i=n.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return r.turns===0?e.jsx("div",{className:O(a?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:a?void 0:"rounded-xl bg-card p-4",children:[!a&&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(ge,{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]",!a&&"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:r.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:Ks(r)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:Vs(r),children:qs(Ws(r))})]}),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:rt(r.costUsd)?Ys(r.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:rt(r.costUsd)?s("usage.costLine",{caption:Js(i?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Ur=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Kr=["circle","rounded","square"],qr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},Wr={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"},Vr=t=>{const a=Wr[t];return a?s(a):t};function Yr({bot:t,activeState:a,onPatch:n,onClose:l}){const r=Gs(t,n),{fileRef:i,crop:c,uploading:d,generating:o,busy:u,error:m,upload:h,removeImage:b,generate:f}=r,v=c!=="mascot"&&!!t.avatarUrl,[j,k]=x.useState(v?"upload":"bot"),y=x.useRef(null);x.useEffect(()=>{y.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const N=p=>n(c==="mascot"?p:{...p,avatarCrop:"mascot"}),S=t.mascotBody??"cursor",E=Sn(),M=Cn(t.mascotBody,t.color,E),[F,T]=x.useState(()=>!!E||pt(S)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=E&&M!==S&&pt(M)?Te(M):null,z=(p,R)=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":!v&&S===p,"aria-label":s("mascot.useBody",{name:R}),title:R,onClick:()=>N({mascotBody:p}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&S===p?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Tn,{color:t.color,faceColor:t.mascotFaceColor,bodyId:p,size:40,animated:!1,trackPointer:!1})},p),L=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,onKeyDown:L,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:y,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Ur.map(([p,R])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===p,"data-avatar-tab":p,onClick:()=>k(p),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===p?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(R)},p)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:u,onClick:()=>n(Xs),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:Pn.map(p=>z(p,Te(p)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:Qs.map(p=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":t.color===p,"aria-label":s("mascot.useColor",{color:Rn(p)}),title:s(En[p]),onClick:()=>N({color:p}),className:O("size-6 rounded-full disabled:opacity-50",t.color===p&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:On(p)}},p))}),e.jsx(Yn,{bot:t,disabled:u,onPatch:N}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":F,onClick:()=>T(p=>!p),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(xe,{size:13,"aria-hidden":"true",className:O("transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[In.map(p=>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:xt(p)}),p===E&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:xt(p)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":p,children:Ln[p].bodies.map(R=>z(R,Te(R)))})]},p)),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")}),An.map(p=>e.jsx("button",{type:"button",disabled:u,"data-avatar-face":p,"aria-pressed":a===p,onClick:()=>N({mascotExpression:p}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",a===p?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:Vr(p)},p))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(Zs,{botLabel:t.title||t.name,disabled:d,generating:o,onGenerate:f})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(ea,{busy:u,onUpload:p=>{h(p)}}),v&&e.jsx(ta,{bot:t,disabled:u,onPatch:n}),e.jsx("input",{ref:i,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:p=>{h(p.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:u,onClick:()=>i.current?.click(),onDragOver:p=>p.preventDefault(),onDrop:p=>{p.preventDefault(),h(p.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:[d?e.jsx(Mn,{size:22,className:"animate-spin"}):e.jsx(sa,{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(je,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?c:null,onChange:p=>n({avatarCrop:p}),options:Kr.map(p=>({value:p,label:s(qr[p]),disabled:u||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:b,disabled:u,"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(qt,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),m&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:m})]})]})}const Jr=()=>s("place.off");function gs(t){const{dispatch:a}=B();return(n="computer")=>{ra(t.id,n),a({type:"toggleSettings",open:!1}),a({type:"toggleComputer",open:!0})}}function Gr(t,a){const[n,l]=x.useState(null);return x.useEffect(()=>{if(!a)return;let r=!1;return se(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(i=>{r||l({botId:t.id,count:i.sites?.length??0})}).catch(()=>{}),()=>{r=!0}},[t.id,a]),n?.botId===t.id?n.count:null}function ys(t){const{state:a}=B(),{capabilities:n}=ye(),l=n.host?.platform??"other",r=ia(t),i=t.computer??"auto",c=a.config?.browserEngine?.myChrome===!0&&(a.config?.browserProfiles??[]).some(f=>f.id===t.browserProfile&&f.browser==="chrome"),d=f=>f==="browser"&&c?s("settings.profiles.myChrome"):ca(f,l),o=f=>{const{view:v,reachable:j}=r[f];return{value:f,label:d(f),disabled:!j,hint:!j||oa(v)?v.line:void 0}},u=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...r.local.policy?[o("local")]:[],...r.browser.policy||i==="browser"?[o("browser")]:[],...r.cloud.policy?[o("cloud")]:[],...r.vm.policy||i==="vm"?[o("vm")]:[],...i==="off"?[{value:i,label:Jr(),disabled:!0}]:[]],m=t.tasks?.find(f=>f.threadId===t.threadId)?.surface,h=m&&m!==i?d(m):null,b=u.find(f=>f.value===i)?.label??(i==="auto"||i==="off"?void 0:d(i));return{options:u,current:i,currentLabel:b,usingNow:h}}function Xr({bot:t,derived:a}){const{dispatch:n}=B(),{options:l,current:r,usingNow:i}=ys(t),[c,d]=x.useState(null),{patch:o,approvalMode:u}=a,m=h=>{if(!(h===r||h==="off")){if(h==="local"&&u==="auto"){d({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}o(h==="browser"?{computer:"browser",browser:!0}:{computer:h==="auto"?null:h})}};return e.jsxs(e.Fragment,{children:[e.jsx(A,{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(h=>e.jsx(He,{"data-panel-choice":h.value,title:h.label,hint:h.hint,checked:r===h.value,disabled:h.disabled,onClick:()=>m(h.value)},h.value))})}),i&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:i})}),e.jsx(la,{open:c!==null,onCancel:()=>d(null),onConfirm:()=>{const h=c;d(null),h&&n({type:"updateBot",botId:h.botId,patch:h.patch})}})]})}function Qr({bot:t,derived:a,onOpen:n}){const l=gs(t),r=Je(),{browserEnabled:i}=a,c=Gr(t,i&&t.computer!=="off"&&r!==!1),{currentLabel:d,usingNow:o}=ys(t),u=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(b=>b.kind==="screen"&&(b.hasImage||b.png)),h=m?aa({threadId:t.threadId,messageId:m.id},m.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")}: ${u}`,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:[h?e.jsx("img",{src:h,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(qe,{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(qe,{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(vt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:u}),e.jsxs(A,{anchor:"where",children:[e.jsx(Q,{"data-panel-page":"where",icon:vt,title:s("computer.simple.whereWorks",{name:t.name}),hint:o?s("computer.simple.usingNow",{place:o}):void 0,value:d,onClick:()=>n("where")}),e.jsx(Q,{"data-panel-page":"browser",icon:na,title:s("settings.sites.title"),value:c??void 0,onClick:()=>n("browser")})]})]})}const Zr=3,Et="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",ei=8,ti=200,me=new Map,$e=new Set,Rt=t=>`${t.threadId}@${Jt(t)}`;function si(t,a){const[,n]=x.useState(0),r=a.filter(d=>d.threadId!==t.threadId).map(Rt).filter(d=>!me.has(d)&&!$e.has(d)).join(",");x.useEffect(()=>{if(r)for(const d of r.split(",")){$e.add(d);const o=d.slice(0,d.lastIndexOf("@"));se(`/api/threads/${encodeURIComponent(o)}/messages?limit=${ei}`,{background:!0}).then(u=>{me.set(d,Ue({messages:u.messages??[],activeLeafId:u.activeLeafId??void 0})),me.size>ti&&me.delete(me.keys().next().value),n(m=>m+1)}).catch(()=>{}).finally(()=>$e.delete(d))}},[r]);const i=Ue(t),c=new Map(a.map(d=>[d.threadId,Rt(d)]));return d=>d===t.threadId?i:me.get(c.get(d)??"")}function ai({bot:t}){const{state:a,dispatch:n}=B(),l=da(),r=!Wt(Vt,!0),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,m]=x.useState(!1),[h,b]=x.useState(!1),f=ua(a.config),v=x.useMemo(()=>{const{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:ue,onPin:he,onArchive:C}=ma(t.id,n,f);return{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:ue,onPin:he,onArchive:C}},[t.id,n,f]),j=pa(t),k=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],y=(j?xa({...t,tasks:k},j):k).filter(g=>!g.routineRunId).map(g=>{const $=_e(t,g.threadId);return{...g,busy:$.busy,activity:$.activity,waitingForTeammates:$.waitingForTeammates,turnStartedAt:$.turnStartedAt??void 0,queued:!!a.pendingQueued[g.threadId]?.length}}),N=it(y.filter(g=>!Ae(g)||g.threadId===t.threadId)),S=it(y.filter(g=>Ae(g)&&g.threadId!==t.threadId)),E=i.trim(),M=N.filter((g,$)=>$<Zr||g.threadId===t.threadId),F=si(t,[...E||u?N:M,...h?S:[]]),T=g=>{const $=F(g);return $?ga(_e(t,g),$,a.instances,!1):void 0},I=ha(N,E),z=E?[...I,...N.filter(g=>!I.includes(g)&&T(g.threadId)?.toLowerCase().includes(E.toLowerCase()))]:N,L=E?z:u?N:M,p=N.length-M.length,R=t.projects?.find(g=>g.id===t.tasks?.find($=>$.threadId===t.threadId)?.projectId),D=()=>{r&&n({type:"toggleSettings",open:!1})},H=g=>{g.threadId!==t.threadId&&ba(n,t,g.threadId,!1),D()},_=()=>{n({type:"newTask",botId:t.id,...R?{projectId:R.id}:{}}),D()},J=()=>{c(""),o(!1)},Y=N.length>=2||d||N.some(g=>g.threadId===t.threadId&&Ae(g)),U=g=>e.jsx("div",{role:"listitem","data-conversation":g.threadId,children:e.jsx(ya,{panel:!0,preview:T(g.threadId),task:g,ownerId:t.id,current:g.threadId===t.threadId,folders:t.projects,now:va(Jt(g),l),locale:ee(),onSelect:H,...v})},g.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(we,{action:Y&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":d,onClick:()=>d?J():o(!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",d&&"bg-ink/[0.06] text-ink"),children:e.jsx(Bt,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",Y&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:_,className:O(Yt,"flex-1"),children:[e.jsx(fa,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&d&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:i,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),J())},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"}),Y&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",Et),children:L.map(U)}),Y&&E&&L.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:E})}),Y&&!E&&p>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":u,onClick:()=>m(g=>!g),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:[u?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,"aria-hidden":"true"}),u?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:p})]}),!E&&S.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":h,onClick:()=>b(g=>!g),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:[h?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:S.length})]}),!E&&h&&S.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:S.length}),className:O("flex flex-col gap-px",Et),children:S.map(U)})]})}function ni({bot:t}){const{dispatch:a}=B();return Dt()||!t.defaultBot?null:e.jsx(A,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:ka.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>a({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 ri=["find","start-fresh","usage","activity","inspector"];function ii({item:t}){const a=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(G,"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",!a&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",a?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ge,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function li({bot:t,derived:a,onOpen:n}){const{items:l}=ja(t),{dispatch:r}=B(),i=a.botRoutines.filter(d=>d.enabled).length,c=ri.flatMap(d=>l.filter(o=>o.key===d));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(G,"rounded-[8px]"),children:e.jsx(wa,{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:Ve}),e.jsx(te,{title:s("model.simple.model")})]})})})}),e.jsx(ai,{bot:t}),e.jsx(ni,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(we,{children:s("botPanel.section.conversation")}),c.map(d=>e.jsx(ii,{item:d},d.key))]}),a.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(we,{action:e.jsx(Na,{"data-panel-automations":"",onClick:()=>r({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:()=>n("routines"),className:O(Yt,"w-full"),children:[e.jsx(br,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(A,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(Q,{"data-panel-page":"routines",icon:Sa,title:s("botSettings.simple.routines"),value:i>0?s("botPanel.routinesOn",{count:i}):s("botPanel.none"),onClick:()=>n("routines")})})]})}const vs=/^\s*[-*]\s+(.+?)\s*$/;function oi(t){return t.split(`
8
8
  `).flatMap((a,n)=>{const l=vs.exec(a)?.[1];return l?[{line:n,text:l}]:[]})}function ci(t,a){const n=t.split(`
9
9
  `);return vs.test(n[a]??"")?(n.splice(a,1),n.join(`
10
10
  `)):t}function di(t,a){const n=t.replace(/\s+$/,""),l=`- ${a.trim().replace(/\s*\n\s*/g," ")}`;return n?`${n}
11
11
  ${l}
12
12
  `:`${l}
13
13
  `}function bs(t){return t.flatMap(a=>{const n=oi(a.text).map(r=>({path:a.path,...r}));if(n.length||a.path===Z)return n;const l=a.text.split(`
14
- `).map(r=>r.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:a.path,line:null,text:l}]:[]})}async function ui(t,a){if(!a)return[await Se(t,Z)];const n=await Qe(t,!0);return Promise.all([Z,...n.topics.map(l=>l.path)].map(l=>Se(t,l,!0)))}function ks(t){const a=!!B().state.config?.team,[n,l]=x.useState({botId:t.id,docs:null,error:!1}),r=t.memoryEnabled!==!1,i=async(o,u)=>{try{const m=await ui(o,a);u?.()||l({botId:o,docs:m,error:!1})}catch{u?.()||l({botId:o,docs:null,error:!0})}},c=!!t.busy;x.useEffect(()=>{if(!r)return;let o=!1;return i(t.id,()=>o),()=>{o=!0}},[t.id,r,c,a]);const d=n.botId===t.id;return{docs:d?n.docs:null,error:d&&n.error,mine:a,setDoc:o=>l(u=>({botId:t.id,docs:(u.botId===t.id?u.docs??[]:[]).map(m=>m.path===o.path?o:m),error:!1})),reload:()=>i(t.id)}}function mi(t,a=Ue(t)){const n=[],l=[],r=new Set;for(const u of[...a].reverse()){const m=u.publishedPage;m?.state==="live"&&m.url&&!r.has(m.url)&&(r.add(m.url),n.push({messageId:u.id,title:m.title||m.url,url:m.url})),u.kind==="app"&&u.app?.doc&&l.push({messageId:u.id,title:u.app.title})}const i=ur(t),c=[],d=new Set;for(const u of i.values())d.has(u.file.path)||(d.add(u.file.path),c.push(u));const o=mr(t).filter(u=>!i.has(u));return{pages:n,apps:l,shared:c,unshared:o}}const pi=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function js({bot:t,onOpen:a}){const{dispatch:n}=B(),{capabilities:l}=ye(),r=Ca(),i=!Wt(Vt,!0),c=is(t),d=ks(t),{pages:o,apps:u,shared:m,unshared:h}=x.useMemo(()=>mi(t),[t]),b=y=>{n({type:"focusMessage",threadId:t.threadId,messageId:y}),i&&n({type:"toggleSettings",open:!1})},f=c.skills.filter(ls).length,v=d.docs?bs(d.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?d.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}),k=e.jsxs(L,{anchor:"keeps",children:[e.jsx(X,{"data-panel-page":"memory",icon:$t,title:s("botPanel.memoryRow"),value:j,onClick:()=>a("memory")}),e.jsx(X,{"data-panel-page":"skills",icon:Pa,title:s("botSettings.simple.skills"),value:c.loading?void 0:f>0?f:s("botPanel.none"),onClick:()=>a("skills")}),e.jsx(X,{"data-panel-page":"folder",icon:Oa,title:s("computer.files.folder"),value:t.cwd?Ye(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>a("folder")})]});return o.length+u.length+m.length+h.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")}),k]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[o.length>0&&e.jsx(L,{label:s("botPanel.library.pages"),anchor:"pages",children:o.map(y=>e.jsx(X,{"data-panel-row":"page",icon:Ea,title:e.jsx("span",{className:"block truncate",children:y.title}),hint:e.jsx("span",{className:"block truncate",children:y.url}),onClick:()=>r(y.url)},y.url))}),u.length>0&&e.jsx(L,{label:s("botPanel.library.apps"),anchor:"apps",children:u.map(y=>e.jsx(X,{"data-panel-row":"app",icon:Jt,title:e.jsx("span",{className:"block truncate",children:y.title}),onClick:()=>b(y.messageId)},y.messageId))}),m.length+h.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(we,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[m.map(y=>e.jsx("li",{className:"min-w-0",children:e.jsx(Ra,{file:y.file,message:y.message,linked:y.file.linked,className:"w-full max-w-none"})},`${y.message.messageId}:${y.file.path}`)),h.map(y=>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(Pe,{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:pi(y)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},y))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),k]})}function xi({bot:t,browserEnabled:a,onOpenBrowser:n}){const{state:l}=B(),r=Ge(),i=t.browserProfile??"",c=(l.config?.browserProfiles??[]).find(m=>m.id===i),d=i==="guest",o=c?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,u=i&&!d?l.bots.filter(m=>m.browserProfile===i).map(m=>m.name):[t.name];return e.jsx(L,{anchor:"logins",children:a?d?e.jsx(W,{children:s("settings.profiles.temporaryHint")}):o?e.jsx(W,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[r!==!1&&(i===""||c)&&e.jsx(ce,{children:e.jsx(yr,{bare:!0,target:{bot:t.id},sharedBy:u,disabled:!!t.busy},`${t.id}:${i}`)}),e.jsx(W,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(de,{"data-panel-action":"add-login",icon:Ee,onClick:n,children:s("botSettings.simple.addLogin")})]}):e.jsx(W,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const hi=5,fi={instanceId:"",model:""},ws=(t,a)=>`${t}\0${a}`,gi=new Set;function It({bot:t,current:a,exclude:n,onPick:l,label:r,title:i,buttonRef:c,className:d,children:o,...u}){const{state:m,dispatch:h,refreshInstances:b,refreshModels:f}=B(),[v,j]=x.useState(!1),[k,y]=x.useState(""),[N,S]=x.useState(()=>new Set),[E,M]=x.useState(!1),[F,T]=x.useState(null),[I,z]=x.useState(null),A=x.useRef(null),p=c??A,R=x.useRef(null),D=x.useRef(null),H=x.useRef(!1),_=x.useId(),G=zn(v),Y=x.useRef({contains:C=>[p.current,R.current].some(K=>K?.contains(C))});Ba(v,Y,()=>j(!1)),x.useLayoutEffect(()=>{if(!v)return;const C=K=>{if(K?.type==="scroll"&&K.target instanceof Node&&R.current?.contains(K.target))return;const V=p.current?.getBoundingClientRect(),q=R.current;!V||!q||z(le=>$a(V,{width:ot,height:q.offsetHeight},{width:window.innerWidth,height:window.innerHeight},le??void 0))};return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[v,p]),x.useEffect(()=>{if(!v||!I||!H.current)return;H.current=!1;const C=R.current;(C?.querySelector("[data-menu-search]")??C?.querySelector("[data-current-model]")??C?.querySelector("[data-menu-row]:not(:disabled)")??C)?.focus({preventScroll:!0})},[v,I]);const U=C=>{j(!1),C&&p.current?.focus({preventScroll:!0})},g=()=>{y(""),S(new Set),z(null),H.current=!0,j(!0),M(!0),b().catch(()=>{}).finally(()=>M(!1))},$=C=>{F||(T(C.instanceId),f(C.instanceId).catch(()=>{}).finally(()=>T(null)))},ie=()=>{U(!1),h({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const C=Ha(m.instances,a?.instanceId).flatMap(q=>{const le=q.models.options.filter(ve=>!n.has(ws(q.instanceId,ve.id)));return le.length===q.models.options.length?[q]:le.length?[{...q,models:{...q.models,options:le}}]:[]}),K=_a({instances:m.instances,listed:C,selection:a??fi,bot:{name:t.name,selection:t.modelSelection},query:k,expanded:N,probing:gi,loading:E,refreshing:F}),V=K.groups.map(q=>q.instance.instanceId===t.modelSelection.instanceId?{...q,note:s("botPanel.backups.sameAccount")}:q);return{...K,groups:V,...a?{}:{current:null}}},he=C=>{if(!(C.nativeEvent.isComposing||C.defaultPrevented)){if(C.key!=="Escape")return za(C,{query:k,typed:D,close:()=>U(!0)});C.preventDefault(),C.stopPropagation(),k?y(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:p,type:"button",...u,"aria-label":r,title:i,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?_:void 0,onClick:()=>v?U(!1):g(),onKeyDown:C=>{C.key==="Escape"&&v?(C.preventDefault(),C.stopPropagation(),U(!1)):(C.key==="ArrowDown"||C.key==="ArrowUp")&&!v&&(C.preventDefault(),g())},className:d,children:o}),G.shown&&Bn.createPortal(e.jsx("div",{ref:R,id:_,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...G.exitProps,onKeyDown:he,onPointerMove:Da,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??ot,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",G.className),children:e.jsx(Fa,{menu:ue(),query:k,bot:t,botModel:{label:"",title:""},idPrefix:_,onQuery:y,onPick:(C,K)=>{C.policy||(l({instanceId:C.instanceId,model:K}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:C=>S(K=>{const V=new Set(K);return V.delete(C.instanceId)||V.add(C.instanceId),V}),onSetUp:ie,onCheckAgain:$,onManage:ie})}),document.body)]})}function yi({bot:t,onChange:a}){const{state:n}=B(),l=t.fallback??[],r=x.useRef(null),i=d=>new Set([t.modelSelection,...l.filter((o,u)=>u!==d)].map(o=>ws(o.instanceId,o.model))),c=d=>{const o=n.instances.find(h=>h.instanceId===d.instanceId),u=o?.models.options.find(h=>h.id===d.model),m=La(o,d.model);return{instance:o,name:m,short:o&&u?Ma(u.label,Ta(o)):m}};return e.jsx(L,{anchor:"backups",children:e.jsxs(ce,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Ia}),e.jsx(te,{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((d,o)=>{const{instance:u,name:m,short:h}=c(d);return e.jsxs("li",{"data-backup":d.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:o+1}),e.jsxs(It,{bot:t,current:d,exclude:i(o),onPick:b=>a(l.map((f,v)=>v===o?b:f)),label:s("botPanel.backups.row",{position:o+1,model:m}),title:u?`${u.displayName} · ${m}`:m,"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:[u?e.jsx(Aa,{instance:u,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:h}),!u&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(xe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Oe,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{a(l.filter((b,f)=>f!==o)),r.current?.focus({preventScroll:!0})}})]},o)})}),l.length<hi&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(It,{bot:t,current:null,exclude:i(null),onPick:d=>a([...l,d]),label:s("model.fallback.add"),buttonRef:r,"data-panel-action":"backup-add",className:O(re,"aria-expanded:bg-raised-hover"),children:[e.jsx(Ee,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function vi({bot:t}){const{dispatch:a}=B(),[n,l]=x.useState(!1),[r,i]=x.useState(!1),[c,d]=x.useState(0),o=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(x.useEffect(()=>{if(!o)return;let m=!0;return se(`/api/bots/${t.id}/system-prompt`).then(h=>{m&&l(h.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,o,c]),!o||!n)return null;const u=async()=>{i(!0);try{await as(t.id)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{i(!1),d(m=>m+1)}};return e.jsx(L,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:J,children:[e.jsx(Q,{icon:Ua}),e.jsx(te,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:r,onClick:()=>{u()},className:re,children:r?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const bi=5;function ki({bot:t}){const{dispatch:a,flushBotPatches:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),d=x.useCallback(()=>ft(t.id).then(u=>r(u.rows.slice(0,bi)),()=>{}),[t.id]);if(x.useEffect(()=>{d()},[d,t.soul]),!l.length)return null;const o=async u=>{if(!i){c(u.id);try{await n(t.id);const{revision:m}=await ft(t.id);await Gn(t.id,u.id,m)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("botOverview.undoFailed")})}finally{c(null),await d()}}};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(Ze,{rows:l,botName:t.name,reverting:i,onRevert:u=>{o(u)}})]})}const ze={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 ji({bot:t,derived:a,onOpen:n,editingInstructions:l=!1,onEditInstructions:r}){const{state:i,dispatch:c,flushBotPatches:d}=B(),{capabilities:o,ready:u}=ye(),m=Qt(t),{servers:h}=ds(),b=Ka(_e(t)),f=qa(),v=ps(t.id),j=os(),[k,y]=x.useState(null),{patch:N,approvalMode:S,engine:E}=a,M=t.name,F=()=>{k!==null&&k.trim()!==t.title.trim()&&N({title:k.trim()}),y(null)},T=E?.driverKind==="antigravityAgent"&&S==="auto"?"ask":S,I=[{value:"ask",label:ze.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:ze.full(),tooltip:s("botSettings.simple.fullHint")},...T==="ask"||T==="full"?[]:[{value:T,label:ze[T](),disabled:!0,tooltip:T==="custom"?s("botPanel.acts.customHint"):void 0}]],z=g=>{g===S||g!=="ask"&&g!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:g,applyToAllThreads:!0}})},A=!u||Wa(o,i.config),p=nn(f,{turnsHere:A,canLive:!0}),R=A?null:Va(o,!!Ga()?.speechStart,Ya(i.config)),D=Ja.map(g=>({value:g.id,label:s(g.label),disabled:g.id==="turns"&&R!==null,tooltip:g.id==="turns"&&R?`${R.label}. ${R.reason}`:g.id==="live"?s("call.mode.liveHint"):Qa("turns")})),H=Xa.map(g=>({value:g,label:s(gt[g][0]),tooltip:s(gt[g][1])})),_=()=>{const g=!t.notifications;g&&rn(),N({notifications:g})},G=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...m.apps.filter(g=>g.scope!==null).map(g=>g.label),...h?us(h,t.mcpServers,t.id).map(g=>g.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(Jn,{bot:t}),e.jsx(L,{anchor:"instructions",children:Y?e.jsxs(ce,{"data-panel-row":"soul",children:[e.jsx(Qn,{bot:t,onPatch:N,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:M})}}),e.jsx(ki,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{d(t.id),r?.(!1)},className:re,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:()=>r?.(!0),className:O(J,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(Q,{icon:Pe}),e.jsx(te,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:Xn(t.soul??"")||s("botPanel.instructionsHint",{name:M})})}),e.jsx(ge,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(vi,{bot:t}),e.jsx(L,{anchor:"approval",children:e.jsxs(ce,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:zt}),e.jsx(te,{title:s("botSettings.simple.beforeActs",{name:M}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:M}),value:T,onChange:z,options:I})}),b.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(Za,{choice:b.choice})})]}),G.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")}),G.map(g=>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:g}),e.jsx(Oe,{"data-panel-action":`always-allow:${g}`,label:s("botAccess.always.remove",{entry:g}),onClick:()=>N({alwaysAllow:G.filter($=>$!==g)})})]},g))]})]})}),e.jsx(yi,{bot:t,onChange:g=>N({fallback:g})}),e.jsx(L,{anchor:"call",children:e.jsxs(ce,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Dn}),e.jsx(te,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-call-mode",label:s("call.mode.menu"),value:p,onChange:en,options:D})})]})}),e.jsxs(L,{anchor:"replies",children:[e.jsxs(ce,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:tn}),e.jsx(te,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:g=>N({replyStyle:g}),options:H})})]}),e.jsx(Je,{"data-panel-row":"notifications",icon:sn,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:_})]}),e.jsxs(L,{anchor:"uses",children:[e.jsx(X,{"data-panel-page":"apps",icon:Jt,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>n?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(J,"cursor-text"),children:[e.jsx(Q,{icon:Sr}),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:k??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ke.title,onChange:g=>y(g.target.value),onBlur:F,onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),g.currentTarget.blur()):g.key==="Escape"&&k!==null&&(g.preventDefault(),g.stopPropagation(),y(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(J,"hover:bg-ink/[0.03]"),children:[e.jsx(Q,{icon:ms}),e.jsx(te,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(es,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(X,{"data-panel-page":"visibility",icon:Ht,title:s("botSettings.visibility.title"),value:Zn(t.visibility),onClick:()=>n?.("visibility")})]}),e.jsx(er,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(an,{bot:t}),b.dialogs]})}const wi=5;function Ni({bot:t,onChanged:a}){const{dispatch:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),[d,o]=x.useState(null),u=x.useCallback(async()=>{const[f,v]=await Promise.all([Qe(t.id),pe(t.id)]);c(j=>f.lendingReview?{value:f.lendingReview,stale:j?.stale??!1}:null),r(v.slice(0,wi))},[t.id]);x.useEffect(()=>{u().catch(()=>{})},[u,t.busy]);const m=f=>n({type:"error",message:f instanceof Error&&f.message?f.message:s("common.tryAgain")}),h=async f=>{o(f.id);try{await rs(t.id,f.id),await a()}catch(v){m(v)}finally{o(null),await u().catch(()=>{})}},b=async f=>{o("review");try{await ss(t.id,f.value.token),c(null)}catch(v){v instanceof Kt&&v.status===409?(c({...f,stale:!0}),await u().catch(()=>{})):m(v)}finally{o(null)}};return e.jsxs(e.Fragment,{children:[i&&e.jsx(hs,{changed:i.value.changed,stale:i.stale,busy:d!==null,onReviewed:()=>{b(i)}}),e.jsx(L,{children:e.jsx(Je,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>n({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(L,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(Ze,{rows:l,botName:t.name,reverting:d,onRevert:f=>{h(f)}})})})]})}const Si="flex flex-col gap-3",At="https://www.skills.sh";function fe(t,a){return t instanceof Error&&t.message?t.message:a}function Ci({bot:t,derived:a}){const{dispatch:n}=B(),l=Qt(t),{servers:r,error:i}=ds(),{patch:c,canUseConnectedApps:d}=a,o=r?hr(r,t.id):[],u=new Set(us(o,t.mcpServers,t.id).map(f=>f.name)),m=f=>{const v=un(t,l.connectedSlugs,f.slug,f.scope===null);Object.keys(v).length>0&&c(v)},h=f=>{t.busy||i||c({mcpServers:fr(o,t.mcpServers,f)})},b=d?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(L,{children:[b&&e.jsx(W,{children:b}),d&&l.apps.map(f=>e.jsxs("div",{"data-simple-app":f.slug,className:J,children:[e.jsx(cn,{card:f.card,className:"size-7 shrink-0"},`${f.card.logo}:${f.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:f.label}),e.jsx(dt,{color:t.color,checked:f.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.label}),disabled:!!t.busy,onClick:()=>m(f),className:"disabled:cursor-not-allowed"})]},f.slug))]}),(o.length>0||i)&&e.jsxs(L,{label:s("connectors.tab.mcp"),children:[i&&e.jsx(W,{children:s("botAccess.mcpRefreshError")}),o.map(f=>e.jsxs("div",{"data-simple-mcp":f.name,className:J,children:[e.jsx(Q,{icon:Fn}),e.jsx(te,{title:e.jsx("span",{className:"block truncate",children:f.name}),hint:f.enabled?f.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(dt,{color:t.color,checked:u.has(f.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.name}),disabled:!f.enabled||!!t.busy||i,onClick:()=>h(f.name),className:"disabled:cursor-not-allowed"})]},f.name))]}),e.jsx(L,{children:e.jsx(de,{"data-panel-link":"add-app",icon:Ee,onClick:()=>dn(n,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Pi({bot:t,derived:a}){const{state:n,dispatch:l}=B(),[r,i]=x.useState(()=>a.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(pr,{routines:a.botRoutines,runs:n.routineRuns,pausedBots:n.config?.pausedBots,loading:n.routinesLoadState==="loading"&&a.botRoutines.length===0,error:n.routinesLoadState==="error",onOpen:i,onLogs:c=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>l({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(L,{children:e.jsx(de,{"data-panel-action":"new-routine",icon:Ee,onClick:()=>i("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})}),r&&e.jsx(gr,{routine:r==="new"?void 0:r,bots:[t],lockedBotId:t.id,onClose:()=>i(null)},t.id)]})}function Oi({bot:t}){const a=ks(t),[n,l]=x.useState(""),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),m=t.memoryEnabled!==!1,h=a.docs?bs(a.docs):null,b=a.docs?.find(y=>y.path===Z)??null;x.useEffect(()=>i(null),[t.id,m]);const f=async y=>{if(c)return!1;d(!0),u(null);try{return await y()}catch(N){return u(fe(N,s("botPanel.library.memoryError"))),!1}finally{d(!1)}},v=(y,N)=>f(async()=>{const S=await Xe(t.id,y.path,N,y.exists?y.hash:void 0,a.mine);return S.ok?(a.setDoc(S.doc),!0):(await a.reload(),u(s("memory.conflict.title",{name:t.name})),!1)}),j=y=>{const N=a.docs?.find(S=>S.path===y.path);N&&(y.line!==null?v(N,ci(N.text,y.line)):f(async()=>(await ns(t.id,N.path,a.mine),await a.reload(),!0)))},k=async()=>{!b||!n.trim()||await v(b,di(b.text,n))&&l("")};return m&&r?.botId===t.id?e.jsx(Ei,{bot:t,doc:r.doc,mine:a.mine,onDone:y=>{y&&a.setDoc(y),i(null),u(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[m?a.error?e.jsx(W,{tone:"warn",children:s("botPanel.library.memoryError")}):h===null?e.jsx(W,{children:s("common.checking")}):h.length===0?e.jsx(W,{children:s("botPanel.memory.empty")}):h.map(y=>e.jsxs("div",{"data-memory-note":y.line??y.path,className:J,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:y.text}),e.jsx(Oe,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>j(y)})]},`${y.path}:${y.line}:${y.text}`)):e.jsx(W,{children:s("botPanel.library.memoryOff",{name:t.name})}),o&&e.jsx(W,{tone:"warn",children:o})]}),m&&e.jsxs(L,{children:[e.jsx(Xt,{"data-panel-form":"memory-add",value:n,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:c||b===null,onChange:l,onSubmit:()=>{k()}}),b&&e.jsx(de,{"data-panel-link":"memory-text",icon:Pe,onClick:()=>i({botId:t.id,doc:b}),children:s("botPanel.memory.editText")})]}),m&&!a.mine&&e.jsx(Ni,{bot:t,onChanged:a.reload})]})}function Ei({bot:t,doc:a,mine:n,onDone:l}){const[r,i]=x.useState({text:a.text,hash:a.hash}),[c,d]=x.useState(a.text),[o,u]=x.useState(null),[m,h]=x.useState(null),[b,f]=x.useState(!1),[v,j]=x.useState(null),k=x.useRef(!0);x.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const y=async S=>{f(!0),j(null);try{const E=await Xe(t.id,a.path,c,S,n);if(!k.current)return;E.ok?l(E.doc):u({current:E.current,currentHash:E.currentHash})}catch(E){j(fe(E,s("botPanel.library.memoryError")))}finally{f(!1)}},N=()=>{o&&(h(S=>S===null||S===c?c:`${S}
14
+ `).map(r=>r.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:a.path,line:null,text:l}]:[]})}async function ui(t,a){if(!a)return[await Se(t,Z)];const n=await Xe(t,!0);return Promise.all([Z,...n.topics.map(l=>l.path)].map(l=>Se(t,l,!0)))}function ks(t){const a=!!B().state.config?.team,[n,l]=x.useState({botId:t.id,docs:null,error:!1}),r=t.memoryEnabled!==!1,i=async(o,u)=>{try{const m=await ui(o,a);u?.()||l({botId:o,docs:m,error:!1})}catch{u?.()||l({botId:o,docs:null,error:!0})}},c=!!t.busy;x.useEffect(()=>{if(!r)return;let o=!1;return i(t.id,()=>o),()=>{o=!0}},[t.id,r,c,a]);const d=n.botId===t.id;return{docs:d?n.docs:null,error:d&&n.error,mine:a,setDoc:o=>l(u=>({botId:t.id,docs:(u.botId===t.id?u.docs??[]:[]).map(m=>m.path===o.path?o:m),error:!1})),reload:()=>i(t.id)}}function mi(t,a=Ue(t)){const n=[],l=[],r=new Set;for(const u of[...a].reverse()){const m=u.publishedPage;m?.state==="live"&&m.url&&!r.has(m.url)&&(r.add(m.url),n.push({messageId:u.id,title:m.title||m.url,url:m.url})),u.kind==="app"&&u.app?.doc&&l.push({messageId:u.id,title:u.app.title})}const i=ur(t),c=[],d=new Set;for(const u of i.values())d.has(u.file.path)||(d.add(u.file.path),c.push(u));const o=mr(t).filter(u=>!i.has(u));return{pages:n,apps:l,shared:c,unshared:o}}const pi=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function js({bot:t,onOpen:a}){const{dispatch:n}=B(),{capabilities:l}=ye(),r=Ca(),i=!Wt(Vt,!0),c=is(t),d=ks(t),{pages:o,apps:u,shared:m,unshared:h}=x.useMemo(()=>mi(t),[t]),b=y=>{n({type:"focusMessage",threadId:t.threadId,messageId:y}),i&&n({type:"toggleSettings",open:!1})},f=c.skills.filter(ls).length,v=d.docs?bs(d.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?d.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}),k=e.jsxs(A,{anchor:"keeps",children:[e.jsx(Q,{"data-panel-page":"memory",icon:$t,title:s("botPanel.memoryRow"),value:j,onClick:()=>a("memory")}),e.jsx(Q,{"data-panel-page":"skills",icon:Pa,title:s("botSettings.simple.skills"),value:c.loading?void 0:f>0?f:s("botPanel.none"),onClick:()=>a("skills")}),e.jsx(Q,{"data-panel-page":"folder",icon:Oa,title:s("computer.files.folder"),value:t.cwd?Ye(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>a("folder")})]});return o.length+u.length+m.length+h.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")}),k]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[o.length>0&&e.jsx(A,{label:s("botPanel.library.pages"),anchor:"pages",children:o.map(y=>e.jsx(Q,{"data-panel-row":"page",icon:Ea,title:e.jsx("span",{className:"block truncate",children:y.title}),hint:e.jsx("span",{className:"block truncate",children:y.url}),onClick:()=>r(y.url)},y.url))}),u.length>0&&e.jsx(A,{label:s("botPanel.library.apps"),anchor:"apps",children:u.map(y=>e.jsx(Q,{"data-panel-row":"app",icon:Gt,title:e.jsx("span",{className:"block truncate",children:y.title}),onClick:()=>b(y.messageId)},y.messageId))}),m.length+h.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(we,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[m.map(y=>e.jsx("li",{className:"min-w-0",children:e.jsx(Ra,{file:y.file,message:y.message,linked:y.file.linked,className:"w-full max-w-none"})},`${y.message.messageId}:${y.file.path}`)),h.map(y=>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(Pe,{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:pi(y)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},y))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),k]})}function xi({bot:t,browserEnabled:a,onOpenBrowser:n}){const{state:l}=B(),r=Je(),i=t.browserProfile??"",c=(l.config?.browserProfiles??[]).find(m=>m.id===i),d=i==="guest",o=c?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,u=i&&!d?l.bots.filter(m=>m.browserProfile===i).map(m=>m.name):[t.name];return e.jsx(A,{anchor:"logins",children:a?d?e.jsx(W,{children:s("settings.profiles.temporaryHint")}):o?e.jsx(W,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[r!==!1&&(i===""||c)&&e.jsx(ce,{children:e.jsx(yr,{bare:!0,target:{bot:t.id},sharedBy:u,disabled:!!t.busy},`${t.id}:${i}`)}),e.jsx(W,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(de,{"data-panel-action":"add-login",icon:Ee,onClick:n,children:s("botSettings.simple.addLogin")})]}):e.jsx(W,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const hi=5,fi={instanceId:"",model:""},ws=(t,a)=>`${t}\0${a}`,gi=new Set;function It({bot:t,current:a,exclude:n,onPick:l,label:r,title:i,buttonRef:c,className:d,children:o,...u}){const{state:m,dispatch:h,refreshInstances:b,refreshModels:f}=B(),[v,j]=x.useState(!1),[k,y]=x.useState(""),[N,S]=x.useState(()=>new Set),[E,M]=x.useState(!1),[F,T]=x.useState(null),[I,z]=x.useState(null),L=x.useRef(null),p=c??L,R=x.useRef(null),D=x.useRef(null),H=x.useRef(!1),_=x.useId(),J=zn(v),Y=x.useRef({contains:C=>[p.current,R.current].some(K=>K?.contains(C))});Ba(v,Y,()=>j(!1)),x.useLayoutEffect(()=>{if(!v)return;const C=K=>{if(K?.type==="scroll"&&K.target instanceof Node&&R.current?.contains(K.target))return;const V=p.current?.getBoundingClientRect(),q=R.current;!V||!q||z(le=>$a(V,{width:ot,height:q.offsetHeight},{width:window.innerWidth,height:window.innerHeight},le??void 0))};return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[v,p]),x.useEffect(()=>{if(!v||!I||!H.current)return;H.current=!1;const C=R.current;(C?.querySelector("[data-menu-search]")??C?.querySelector("[data-current-model]")??C?.querySelector("[data-menu-row]:not(:disabled)")??C)?.focus({preventScroll:!0})},[v,I]);const U=C=>{j(!1),C&&p.current?.focus({preventScroll:!0})},g=()=>{y(""),S(new Set),z(null),H.current=!0,j(!0),M(!0),b().catch(()=>{}).finally(()=>M(!1))},$=C=>{F||(T(C.instanceId),f(C.instanceId).catch(()=>{}).finally(()=>T(null)))},ie=()=>{U(!1),h({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const C=Ha(m.instances,a?.instanceId).flatMap(q=>{const le=q.models.options.filter(ve=>!n.has(ws(q.instanceId,ve.id)));return le.length===q.models.options.length?[q]:le.length?[{...q,models:{...q.models,options:le}}]:[]}),K=_a({instances:m.instances,listed:C,selection:a??fi,bot:{name:t.name,selection:t.modelSelection},query:k,expanded:N,probing:gi,loading:E,refreshing:F}),V=K.groups.map(q=>q.instance.instanceId===t.modelSelection.instanceId?{...q,note:s("botPanel.backups.sameAccount")}:q);return{...K,groups:V,...a?{}:{current:null}}},he=C=>{if(!(C.nativeEvent.isComposing||C.defaultPrevented)){if(C.key!=="Escape")return za(C,{query:k,typed:D,close:()=>U(!0)});C.preventDefault(),C.stopPropagation(),k?y(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:p,type:"button",...u,"aria-label":r,title:i,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?_:void 0,onClick:()=>v?U(!1):g(),onKeyDown:C=>{C.key==="Escape"&&v?(C.preventDefault(),C.stopPropagation(),U(!1)):(C.key==="ArrowDown"||C.key==="ArrowUp")&&!v&&(C.preventDefault(),g())},className:d,children:o}),J.shown&&Bn.createPortal(e.jsx("div",{ref:R,id:_,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...J.exitProps,onKeyDown:he,onPointerMove:Da,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??ot,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",J.className),children:e.jsx(Fa,{menu:ue(),query:k,bot:t,botModel:{label:"",title:""},idPrefix:_,onQuery:y,onPick:(C,K)=>{C.policy||(l({instanceId:C.instanceId,model:K}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:C=>S(K=>{const V=new Set(K);return V.delete(C.instanceId)||V.add(C.instanceId),V}),onSetUp:ie,onCheckAgain:$,onManage:ie})}),document.body)]})}function yi({bot:t,onChange:a}){const{state:n}=B(),l=t.fallback??[],r=x.useRef(null),i=d=>new Set([t.modelSelection,...l.filter((o,u)=>u!==d)].map(o=>ws(o.instanceId,o.model))),c=d=>{const o=n.instances.find(h=>h.instanceId===d.instanceId),u=o?.models.options.find(h=>h.id===d.model),m=Aa(o,d.model);return{instance:o,name:m,short:o&&u?Ma(u.label,Ta(o)):m}};return e.jsx(A,{anchor:"backups",children:e.jsxs(ce,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Ia}),e.jsx(te,{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((d,o)=>{const{instance:u,name:m,short:h}=c(d);return e.jsxs("li",{"data-backup":d.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:o+1}),e.jsxs(It,{bot:t,current:d,exclude:i(o),onPick:b=>a(l.map((f,v)=>v===o?b:f)),label:s("botPanel.backups.row",{position:o+1,model:m}),title:u?`${u.displayName} · ${m}`:m,"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:[u?e.jsx(La,{instance:u,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:h}),!u&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(xe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Oe,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{a(l.filter((b,f)=>f!==o)),r.current?.focus({preventScroll:!0})}})]},o)})}),l.length<hi&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(It,{bot:t,current:null,exclude:i(null),onPick:d=>a([...l,d]),label:s("model.fallback.add"),buttonRef:r,"data-panel-action":"backup-add",className:O(re,"aria-expanded:bg-raised-hover"),children:[e.jsx(Ee,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function vi({bot:t}){const{dispatch:a}=B(),[n,l]=x.useState(!1),[r,i]=x.useState(!1),[c,d]=x.useState(0),o=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(x.useEffect(()=>{if(!o)return;let m=!0;return se(`/api/bots/${t.id}/system-prompt`).then(h=>{m&&l(h.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,o,c]),!o||!n)return null;const u=async()=>{i(!0);try{await as(t.id)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{i(!1),d(m=>m+1)}};return e.jsx(A,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:G,children:[e.jsx(X,{icon:Ua}),e.jsx(te,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:r,onClick:()=>{u()},className:re,children:r?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const bi=5;function ki({bot:t}){const{dispatch:a,flushBotPatches:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),d=x.useCallback(()=>ft(t.id).then(u=>r(u.rows.slice(0,bi)),()=>{}),[t.id]);if(x.useEffect(()=>{d()},[d,t.soul]),!l.length)return null;const o=async u=>{if(!i){c(u.id);try{await n(t.id);const{revision:m}=await ft(t.id);await Jn(t.id,u.id,m)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("botOverview.undoFailed")})}finally{c(null),await d()}}};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(Ze,{rows:l,botName:t.name,reverting:i,onRevert:u=>{o(u)}})]})}const ze={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 ji({bot:t,derived:a,onOpen:n,editingInstructions:l=!1,onEditInstructions:r}){const{state:i,dispatch:c,flushBotPatches:d}=B(),{capabilities:o,ready:u}=ye(),m=Xt(t),{servers:h}=ds(),b=Ka(_e(t)),f=qa(),v=ps(t.id),j=os(),[k,y]=x.useState(null),{patch:N,approvalMode:S,engine:E}=a,M=t.name,F=()=>{k!==null&&k.trim()!==t.title.trim()&&N({title:k.trim()}),y(null)},T=E?.driverKind==="antigravityAgent"&&S==="auto"?"ask":S,I=[{value:"ask",label:ze.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:ze.full(),tooltip:s("botSettings.simple.fullHint")},...T==="ask"||T==="full"?[]:[{value:T,label:ze[T](),disabled:!0,tooltip:T==="custom"?s("botPanel.acts.customHint"):void 0}]],z=g=>{g===S||g!=="ask"&&g!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:g,applyToAllThreads:!0}})},L=!u||Wa(o,i.config),p=nn(f,{turnsHere:L,canLive:!0}),R=L?null:Va(o,!!Ja()?.speechStart,Ya(i.config)),D=Ga.map(g=>({value:g.id,label:s(g.label),disabled:g.id==="turns"&&R!==null,tooltip:g.id==="turns"&&R?`${R.label}. ${R.reason}`:g.id==="live"?s("call.mode.liveHint"):Xa("turns")})),H=Qa.map(g=>({value:g,label:s(gt[g][0]),tooltip:s(gt[g][1])})),_=()=>{const g=!t.notifications;g&&rn(),N({notifications:g})},J=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...m.apps.filter(g=>g.scope!==null).map(g=>g.label),...h?us(h,t.mcpServers,t.id).map(g=>g.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(Gn,{bot:t}),e.jsx(A,{anchor:"instructions",children:Y?e.jsxs(ce,{"data-panel-row":"soul",children:[e.jsx(Xn,{bot:t,onPatch:N,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:M})}}),e.jsx(ki,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{d(t.id),r?.(!1)},className:re,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:()=>r?.(!0),className:O(G,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Pe}),e.jsx(te,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:Qn(t.soul??"")||s("botPanel.instructionsHint",{name:M})})}),e.jsx(ge,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(vi,{bot:t}),e.jsx(A,{anchor:"approval",children:e.jsxs(ce,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:zt}),e.jsx(te,{title:s("botSettings.simple.beforeActs",{name:M}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:M}),value:T,onChange:z,options:I})}),b.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(Za,{choice:b.choice})})]}),J.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")}),J.map(g=>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:g}),e.jsx(Oe,{"data-panel-action":`always-allow:${g}`,label:s("botAccess.always.remove",{entry:g}),onClick:()=>N({alwaysAllow:J.filter($=>$!==g)})})]},g))]})]})}),e.jsx(yi,{bot:t,onChange:g=>N({fallback:g})}),e.jsx(A,{anchor:"call",children:e.jsxs(ce,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Dn}),e.jsx(te,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-call-mode",label:s("call.mode.menu"),value:p,onChange:en,options:D})})]})}),e.jsxs(A,{anchor:"replies",children:[e.jsxs(ce,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:tn}),e.jsx(te,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:g=>N({replyStyle:g}),options:H})})]}),e.jsx(Ge,{"data-panel-row":"notifications",icon:sn,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:_})]}),e.jsxs(A,{anchor:"uses",children:[e.jsx(Q,{"data-panel-page":"apps",icon:Gt,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>n?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(G,"cursor-text"),children:[e.jsx(X,{icon:Sr}),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:k??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ke.title,onChange:g=>y(g.target.value),onBlur:F,onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),g.currentTarget.blur()):g.key==="Escape"&&k!==null&&(g.preventDefault(),g.stopPropagation(),y(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(G,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:ms}),e.jsx(te,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(es,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(Q,{"data-panel-page":"visibility",icon:Ht,title:s("botSettings.visibility.title"),value:Zn(t.visibility),onClick:()=>n?.("visibility")})]}),e.jsx(er,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(an,{bot:t}),b.dialogs]})}const wi=5;function Ni({bot:t,onChanged:a}){const{dispatch:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),[d,o]=x.useState(null),u=x.useCallback(async()=>{const[f,v]=await Promise.all([Xe(t.id),pe(t.id)]);c(j=>f.lendingReview?{value:f.lendingReview,stale:j?.stale??!1}:null),r(v.slice(0,wi))},[t.id]);x.useEffect(()=>{u().catch(()=>{})},[u,t.busy]);const m=f=>n({type:"error",message:f instanceof Error&&f.message?f.message:s("common.tryAgain")}),h=async f=>{o(f.id);try{await rs(t.id,f.id),await a()}catch(v){m(v)}finally{o(null),await u().catch(()=>{})}},b=async f=>{o("review");try{await ss(t.id,f.value.token),c(null)}catch(v){v instanceof Kt&&v.status===409?(c({...f,stale:!0}),await u().catch(()=>{})):m(v)}finally{o(null)}};return e.jsxs(e.Fragment,{children:[i&&e.jsx(hs,{changed:i.value.changed,stale:i.stale,busy:d!==null,onReviewed:()=>{b(i)}}),e.jsx(A,{children:e.jsx(Ge,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>n({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(A,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(Ze,{rows:l,botName:t.name,reverting:d,onRevert:f=>{h(f)}})})})]})}const Si="flex flex-col gap-3",Lt="https://www.skills.sh";function fe(t,a){return t instanceof Error&&t.message?t.message:a}function Ci({bot:t,derived:a}){const{dispatch:n}=B(),l=Xt(t),{servers:r,error:i}=ds(),{patch:c,canUseConnectedApps:d}=a,o=r?hr(r,t.id):[],u=new Set(us(o,t.mcpServers,t.id).map(f=>f.name)),m=f=>{const v=un(t,l.connectedSlugs,f.slug,f.scope===null);Object.keys(v).length>0&&c(v)},h=f=>{t.busy||i||c({mcpServers:fr(o,t.mcpServers,f)})},b=d?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(A,{children:[b&&e.jsx(W,{children:b}),d&&l.apps.map(f=>e.jsxs("div",{"data-simple-app":f.slug,className:G,children:[e.jsx(cn,{card:f.card,className:"size-7 shrink-0"},`${f.card.logo}:${f.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:f.label}),e.jsx(dt,{color:t.color,checked:f.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.label}),disabled:!!t.busy,onClick:()=>m(f),className:"disabled:cursor-not-allowed"})]},f.slug))]}),(o.length>0||i)&&e.jsxs(A,{label:s("connectors.tab.mcp"),children:[i&&e.jsx(W,{children:s("botAccess.mcpRefreshError")}),o.map(f=>e.jsxs("div",{"data-simple-mcp":f.name,className:G,children:[e.jsx(X,{icon:Fn}),e.jsx(te,{title:e.jsx("span",{className:"block truncate",children:f.name}),hint:f.enabled?f.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(dt,{color:t.color,checked:u.has(f.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.name}),disabled:!f.enabled||!!t.busy||i,onClick:()=>h(f.name),className:"disabled:cursor-not-allowed"})]},f.name))]}),e.jsx(A,{children:e.jsx(de,{"data-panel-link":"add-app",icon:Ee,onClick:()=>dn(n,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Pi({bot:t,derived:a}){const{state:n,dispatch:l}=B(),[r,i]=x.useState(()=>a.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(pr,{routines:a.botRoutines,runs:n.routineRuns,pausedBots:n.config?.pausedBots,loading:n.routinesLoadState==="loading"&&a.botRoutines.length===0,error:n.routinesLoadState==="error",onOpen:i,onLogs:c=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>l({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(A,{children:e.jsx(de,{"data-panel-action":"new-routine",icon:Ee,onClick:()=>i("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})}),r&&e.jsx(gr,{routine:r==="new"?void 0:r,bots:[t],lockedBotId:t.id,onClose:()=>i(null)},t.id)]})}function Oi({bot:t}){const a=ks(t),[n,l]=x.useState(""),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),m=t.memoryEnabled!==!1,h=a.docs?bs(a.docs):null,b=a.docs?.find(y=>y.path===Z)??null;x.useEffect(()=>i(null),[t.id,m]);const f=async y=>{if(c)return!1;d(!0),u(null);try{return await y()}catch(N){return u(fe(N,s("botPanel.library.memoryError"))),!1}finally{d(!1)}},v=(y,N)=>f(async()=>{const S=await Qe(t.id,y.path,N,y.exists?y.hash:void 0,a.mine);return S.ok?(a.setDoc(S.doc),!0):(await a.reload(),u(s("memory.conflict.title",{name:t.name})),!1)}),j=y=>{const N=a.docs?.find(S=>S.path===y.path);N&&(y.line!==null?v(N,ci(N.text,y.line)):f(async()=>(await ns(t.id,N.path,a.mine),await a.reload(),!0)))},k=async()=>{!b||!n.trim()||await v(b,di(b.text,n))&&l("")};return m&&r?.botId===t.id?e.jsx(Ei,{bot:t,doc:r.doc,mine:a.mine,onDone:y=>{y&&a.setDoc(y),i(null),u(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[m?a.error?e.jsx(W,{tone:"warn",children:s("botPanel.library.memoryError")}):h===null?e.jsx(W,{children:s("common.checking")}):h.length===0?e.jsx(W,{children:s("botPanel.memory.empty")}):h.map(y=>e.jsxs("div",{"data-memory-note":y.line??y.path,className:G,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:y.text}),e.jsx(Oe,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>j(y)})]},`${y.path}:${y.line}:${y.text}`)):e.jsx(W,{children:s("botPanel.library.memoryOff",{name:t.name})}),o&&e.jsx(W,{tone:"warn",children:o})]}),m&&e.jsxs(A,{children:[e.jsx(Qt,{"data-panel-form":"memory-add",value:n,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:c||b===null,onChange:l,onSubmit:()=>{k()}}),b&&e.jsx(de,{"data-panel-link":"memory-text",icon:Pe,onClick:()=>i({botId:t.id,doc:b}),children:s("botPanel.memory.editText")})]}),m&&!a.mine&&e.jsx(Ni,{bot:t,onChanged:a.reload})]})}function Ei({bot:t,doc:a,mine:n,onDone:l}){const[r,i]=x.useState({text:a.text,hash:a.hash}),[c,d]=x.useState(a.text),[o,u]=x.useState(null),[m,h]=x.useState(null),[b,f]=x.useState(!1),[v,j]=x.useState(null),k=x.useRef(!0);x.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const y=async S=>{f(!0),j(null);try{const E=await Qe(t.id,a.path,c,S,n);if(!k.current)return;E.ok?l(E.doc):u({current:E.current,currentHash:E.currentHash})}catch(E){j(fe(E,s("botPanel.library.memoryError")))}finally{f(!1)}},N=()=>{o&&(h(S=>S===null||S===c?c:`${S}
15
15
 
16
- ${c}`),i({text:o.current,hash:o.currentHash}),d(o.current),u(null))};return e.jsx(L,{children:e.jsxs(ce,{"data-panel-row":"memory-text",children:[o&&e.jsx(fs,{botName:t.name,busy:b,onReload:N,onOverwrite:()=>{y(o.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(We,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:b,onChange:S=>d(S.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),m!==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:m}),e.jsx("button",{type:"button",className:O(re,"mt-1"),onClick:()=>h(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:b,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:re,disabled:b||c===r.text,onClick:()=>{y(r.hash)},children:b?s("memory.saving"):s("memory.save")})]})]})})}function Ri({bot:t}){const{request:a}=ln(),{state:n,dispatch:l}=B(),r=is(t),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,m]=x.useState([]),h=on(n.config),b=async k=>{if(!r.working&&window.confirm(s(k.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:k.name}))){r.setWorking(k.name),r.setError("");try{await a(`/api/bots/${t.id}/skills/${encodeURIComponent(k.name)}`,{method:"DELETE"}),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.removeFailed")))}finally{r.setWorking("")}}},f=async()=>{const k=i.trim();if(!(!k||d)){o(!0),r.setError(""),m([]);try{const y=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:k})});m(yt(y.imported??[])),c(""),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.importFailed")))}finally{o(!1)}}},v=async()=>{const k=await window.ogb?.pickFolder?.();if(!(!k||d)){o(!0),r.setError(""),m([]);try{const y=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${k}`})});m(yt(y.imported??[])),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.importFailed")))}finally{o(!1)}}},j=()=>{if(h){l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"});return}ct(At)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[r.loading?e.jsx(W,{children:s("skills.loading")}):r.skills.length===0?e.jsx(W,{children:s("botSettings.simple.noSkills")}):r.skills.map(k=>e.jsx(Je,{"data-panel-row":`skill:${k.name}`,title:k.name,hint:k.description||k.source,label:s("botSettings.simple.skillToggle",{name:k.name}),color:t.color,checked:ls(k),disabled:!!r.working,onChange:()=>{r.toggle(k)},extra:k.origin==="imported"||k.origin==="native"?void 0:e.jsx(Oe,{"data-panel-action":`remove-skill:${k.name}`,label:s("botPanel.skills.remove",{name:k.name}),disabled:!!r.working,onClick:()=>{b(k)}})},k.name)),r.error&&!r.reviewing&&e.jsx(W,{tone:"warn",children:r.error})]}),e.jsx(sr,{bot:t,onAdded:()=>{r.refresh()}}),e.jsxs(L,{children:[e.jsx(Xt,{"data-panel-form":"skill-import",value:i,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:d?s("skills.import.importing"):s("common.add"),disabled:d,onChange:c,onSubmit:()=>{f()}}),u.map(k=>e.jsx(W,{children:k},k)),e.jsx(de,{"data-panel-link":"skills-sh",onClick:()=>{ct(At)},children:s("botPanel.skills.skillsSh")}),e.jsx(de,{"data-panel-link":"browse-skills",onClick:j,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(de,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),r.reviewing&&e.jsx(ar,{skill:r.reviewing.skill,text:r.reviewing.text,error:r.error,working:r.working===r.reviewing.skill.name,onCancel:()=>r.setReviewing(null),onEnable:()=>{r.enableReviewed()}})]})}function Ii({bot:t}){const{capabilities:a}=ye(),n=a.host?.homeDir,{draft:l,setDraft:r,error:i,saving:c,canPick:d,save:o,pick:u}=tr(t),[m,h]=x.useState(!1),b=!!t.cwd||m,f=()=>{if(d){u();return}h(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[e.jsx(He,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!b,disabled:c,onClick:()=>{h(!1),t.cwd&&o(null)}}),e.jsx(He,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:b,disabled:c,onClick:()=>{t.cwd||f()}})]}),b&&e.jsxs(L,{children:[d?e.jsxs("div",{className:J,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?Ye(t.cwd,n):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:c,onClick:()=>{u()},className:re,children:[e.jsx(Ut,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:J,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&o(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>r(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:c||l===null,className:re,children:s("botAccess.folder.save")})]}),i&&e.jsx(W,{tone:"warn",children:i})]})]})}function Ai({bot:t,derived:a}){const n=gs(t);return e.jsx(xi,{bot:t,browserEnabled:a.browserEnabled,onOpenBrowser:()=>n("browser")})}function Li({bot:t}){return os()?e.jsx(cs,{bot:t}):null}function Mi({page:t,onOpen:a,editingInstructions:n,onEditInstructions:l,...r}){switch(t){case"settings":return e.jsx(ji,{...r,onOpen:a,editingInstructions:n,onEditInstructions:l});case"where":return e.jsx(Qr,{...r});case"apps":return e.jsx(Ci,{...r});case"routines":return e.jsx(Pi,{...r});case"visibility":return e.jsx(Li,{...r});case"memory":return e.jsx(Oi,{...r});case"skills":return e.jsx(Ri,{...r});case"folder":return e.jsx(Ii,{...r});case"browser":return e.jsx(Ai,{...r})}}const Lt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Mt(t){const[a,n]=x.useState(null),l=x.useRef(!1),r=x.useRef(!1),i=x.useRef(null);x.useEffect(()=>{a!==null||!r.current||(r.current=!1,i.current?.focus())},[a]);const c=m=>{l.current=!1,n(m)},d=()=>{a!==null&&t(a),n(null)};return{draft:a,setDraft:n,start:c,onKeyDown:m=>{if(pn(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),l.current=!0,r.current=!0,d()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l.current=!0,r.current=!0,n(null))},onBlur:()=>{l.current||d()},buttonRef:i}}function Ti({bot:t,activeState:a,patch:n,editorOpen:l,onToggleEditor:r}){const i=Mt(o=>{const u=o.trim();u&&u!==t.name&&n({name:u})}),c=Mt(o=>{const u=o.trim();u!==t.title.trim()&&n({title:u})}),d=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:r,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(qe,{bot:t,size:64,state:a}),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(ut,{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(mn,{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:i.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ke.name,value:i.draft,onChange:o=>i.setDraft(o.target.value),onKeyDown:i.onKeyDown,onBlur:i.onBlur,className:O(Lt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:i.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>i.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(ut,{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"})]})})}),c.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Ke.title,value:c.draft,onChange:o=>c.setDraft(o.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:O(Lt,"mt-[3px] w-[200px] max-w-full text-[13px]")}):d&&e.jsx("button",{ref:c.buttonRef,type:"button","data-panel-label":!0,onClick:()=>c.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:d})]})}function ke(t,a){return t?Zt(t,a):{tab:"details"}}function Bi({bot:t,derived:a,linkedSection:n,onClose:l}){const{dragProps:r}=ts(),i=xn(),[c,d]=x.useState(()=>ke(n,i).tab),[o,u]=x.useState(()=>{const p=ke(n,i).page;return p?[p]:[]}),[m,h]=x.useState(()=>ke(n,i).anchor??null),[b,f]=x.useState(!1),[v,j]=x.useState(()=>!!ke(n,i).editInstructions),k=x.useRef(null),y=x.useRef(null),N=o.at(-1)??null,S=()=>k.current?.scrollTo({top:0}),E=p=>{d(p.tab),u(p.page?[p.page]:[]),h(p.anchor??null),f(!1),j(!!p.editInstructions),S()},M=p=>E({tab:p}),F=p=>{u(R=>[...R,p]),f(!1),S()},T=()=>{f(!1),y.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{u(p=>p.slice(0,-1)),S()};x.useEffect(()=>{n&&E(Zt(n,i))},[n,i]),x.useEffect(()=>{m&&(k.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),h(null))},[m,N,c]);const z=p=>{if(p.key!=="Escape"||p.defaultPrevented)return;const R=p.target,D=typeof R?.closest=="function"?R.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(D&&!D.contains(p.currentTarget)&&D!==y.current&&!y.current?.contains(D))){if(b)T();else if(o.length>0)I();else return;p.preventDefault(),p.stopPropagation()}},A=o.length>1?s(be[o[o.length-2]].title,{name:t.name}):s(mt[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:z,children:[e.jsxs("div",{...r,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(hn,{bot:t,className:Me}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":N==="settings"?"page":void 0,onClick:()=>E({tab:"details",page:"settings"}),className:Me,children:e.jsx(fn,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:Me,children:e.jsx(Ft,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:k,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:N===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:y,children:[e.jsx(Ti,{bot:t,activeState:a.activeState,patch:a.patch,editorOpen:b,onToggleEditor:()=>f(p=>!p)}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:T}),e.jsx(Yr,{bot:t,activeState:a.activeState,onPatch:a.patch,onClose:T})]})]}),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:gn.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===p,"data-panel-tab":p,onClick:()=>M(p),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===p?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(mt[p])},p))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(li,{bot:t,derived:a,onOpen:F}),c==="library"&&e.jsx(js,{bot:t,onOpen:F}),c==="computer"&&e.jsx(Xr,{bot:t,derived:a,onOpen:F})]})]}):e.jsxs("div",{"data-panel-page-view":N,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(yn,{back:A,title:s(be[N].title,{name:t.name}),intro:be[N].intro?s(be[N].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Si),children:e.jsx(Mi,{page:N,bot:t,derived:a,onOpen:F,editingInstructions:v,onEditInstructions:j})})]})})]})}function Di(t,a){const{state:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),[m,h]=x.useState(!1),b=x.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]),f=a.followEdits??!0,v=f?b:null,j=f?n.routines:null,k=f?n.webhooks:null;return x.useEffect(()=>{if(!a.overview&&!a.prompt)return;let y=!1;return(async()=>(await l(t.id),!y&&(a.overview&&se(`/api/bots/${t.id}/overview`).then(S=>{y||(i(S),d(!1))}).catch(()=>{y||d(!0)}),a.prompt&&se(`/api/bots/${t.id}/system-prompt`).then(S=>{y||(u(S),h(!1))}).catch(()=>{y||h(!0)}))))(),()=>{y=!0}},[t.id,a.overview,a.prompt,v,j,k,l]),{overview:r,overviewError:c,prompt:o,promptError:m}}function Fi(t,a){const{dispatch:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),m=x.useRef(0),[h,b]=x.useState(!1),[f,v]=x.useState(null),j=x.useCallback(()=>{const N=++m.current;return d(!1),l(t.id).then(()=>se(`/api/bots/${t.id}/history?limit=100`)).then(S=>{N===m.current&&(i(S.rows),u(S.revision))}).catch(()=>{N===m.current&&d(!0)})},[t.id,l]);return x.useEffect(()=>{if(a)return j(),()=>{m.current++}},[a,j]),{rows:r,error:c,revision:o,rollingBack:h,rollbackTarget:f,setRollbackTarget:v,rollback:async N=>{if(!h){v(null),b(!0);try{await l(t.id),await se(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(N)})}catch(S){n({type:"error",message:S instanceof Error?S.message:s("botOverview.undoFailed")})}finally{await j(),b(!1)}}},requestRollback:N=>{o&&v({id:N,expectedRevision:o})}}}function $i({history:t,returnFocusRef:a}){const{rollbackTarget:n,setRollbackTarget:l,rollback:r}=t;return e.jsx(vn,{open:n!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:a,onCancel:()=>l(null),onConfirm:()=>{n&&r(n)}})}const zi={memory:"memory",skills:"skills",folder:"access"},Ns=t=>t.labelKey?s(t.labelKey):t.label;function Tt(t,a){return a?[t.label,Ns(t),...t.keywords].some(n=>n.toLowerCase().includes(a)):!0}function nl({bot:t,overlay:a=!1}){const{state:n,dispatch:l}=B(),r=n.botSettingsSection,i=bn(t),c=x.useRef(null),{dragProps:d}=ts(),[o,u]=x.useState(""),m=!n.botSettingsExpandAccordion,h=o.trim().toLowerCase(),f=!Dt(),v=!m&&!n.botSettingsExpandRemembered?r:null,j=ps(t.id),k=Ge(),y=kn(),N=Cr.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&k===!0&&!y),S=N.filter(A=>Tt(A,h)),{overview:E,overviewError:M,prompt:F,promptError:T}=Di(t,{overview:r==="overview"&&!f,prompt:r==="overview"&&!f}),I=Fi(t,r==="history"&&!f);x.useEffect(()=>{if(!m){if(h){u("");return}c.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[m,r,h]),x.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,p=c.current;p?.focus();const R=D=>{const H=p?.querySelector('[role="dialog"], [role="alertdialog"]');H&&H.getClientRects().length>0||p&&D.target instanceof Node&&!p.contains(D.target)||D.key==="Escape"&&!D.defaultPrevented&&(D.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),A?.focus()}},[l]);const z=A=>{switch(A){case"overview":return E===null&&M?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Lr,{overview:E,refreshError:E!==null&&M,prompt:F,promptError:T,onOpen:p=>l({type:"toggleSettings",open:!0,section:p}),onSetup:i.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(dr,{bot:t,patch:i.patch,activeState:i.activeState,mascotMotion:i.mascotMotion});case"soul":return e.jsx(cr,{bot:t,patch:i.patch});case"slack":return j?e.jsx(Mr,{managementUrl:j}):null;case"skills":return e.jsx(or,{bot:t});case"memory":return e.jsx(Dr,{bot:t,active:!m&&r==="memory",onToggle:p=>i.patch({memoryEnabled:p})});case"library":return e.jsx(js,{bot:t,onOpen:p=>l({type:"toggleSettings",open:!0,section:zi[p]??"overview"})});case"routines":return e.jsx(xr,{bot:t,routines:i.botRoutines,runs:n.routineRuns});case"access":return e.jsx(lr,{bot:t,derived:i});case"model":return e.jsx(ir,{bot:t});case"permissions":return e.jsx(rr,{bot:t,derived:i});case"voice":return e.jsx(nr,{bot:t,derived:i});case"visibility":return e.jsx(cs,{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(Hr,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(_r,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:f?jn:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Nn(a,f),children:f?e.jsx(Bi,{bot:t,derived:i,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...d,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(wn,{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(Ft,{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(Bt,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:o,onChange:A=>{u(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),o?u(""):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:[S.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:o.trim()})}),N.map(A=>{const{id:p,icon:R}=A,D=Ns(A),H=Tt(A,h);if(!H&&p!=="memory")return null;const _=!m&&r===p;return e.jsxs("div",{"data-bot-settings-section":p,className:"border-b border-hairline/30",hidden:!H,children:[e.jsxs("button",{type:"button",onClick:()=>{if(r===p&&!m){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:p})},"aria-expanded":_,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",_?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(R,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:D}),e.jsx(xe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",_&&"rotate-180")})]}),p==="memory"?e.jsx("div",{hidden:!_,className:"px-4 pb-4 pt-1",children:z("memory")}):_&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:z(p)})]},p)})]})]})}),e.jsx($i,{history:I,returnFocusRef:c})]})}export{nl as BotSettingsDialog};
16
+ ${c}`),i({text:o.current,hash:o.currentHash}),d(o.current),u(null))};return e.jsx(A,{children:e.jsxs(ce,{"data-panel-row":"memory-text",children:[o&&e.jsx(fs,{botName:t.name,busy:b,onReload:N,onOverwrite:()=>{y(o.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(We,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:b,onChange:S=>d(S.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),m!==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:m}),e.jsx("button",{type:"button",className:O(re,"mt-1"),onClick:()=>h(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:b,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:re,disabled:b||c===r.text,onClick:()=>{y(r.hash)},children:b?s("memory.saving"):s("memory.save")})]})]})})}function Ri({bot:t}){const{request:a}=ln(),{state:n,dispatch:l}=B(),r=is(t),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,m]=x.useState([]),h=on(n.config),b=async k=>{if(!r.working&&window.confirm(s(k.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:k.name}))){r.setWorking(k.name),r.setError("");try{await a(`/api/bots/${t.id}/skills/${encodeURIComponent(k.name)}`,{method:"DELETE"}),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.removeFailed")))}finally{r.setWorking("")}}},f=async()=>{const k=i.trim();if(!(!k||d)){o(!0),r.setError(""),m([]);try{const y=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:k})});m(yt(y.imported??[])),c(""),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.importFailed")))}finally{o(!1)}}},v=async()=>{const k=await window.ogb?.pickFolder?.();if(!(!k||d)){o(!0),r.setError(""),m([]);try{const y=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${k}`})});m(yt(y.imported??[])),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.importFailed")))}finally{o(!1)}}},j=()=>{if(h){l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"});return}ct(Lt)};return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[r.loading?e.jsx(W,{children:s("skills.loading")}):r.skills.length===0?e.jsx(W,{children:s("botSettings.simple.noSkills")}):r.skills.map(k=>e.jsx(Ge,{"data-panel-row":`skill:${k.name}`,title:k.name,hint:k.description||k.source,label:s("botSettings.simple.skillToggle",{name:k.name}),color:t.color,checked:ls(k),disabled:!!r.working,onChange:()=>{r.toggle(k)},extra:k.origin==="imported"||k.origin==="native"?void 0:e.jsx(Oe,{"data-panel-action":`remove-skill:${k.name}`,label:s("botPanel.skills.remove",{name:k.name}),disabled:!!r.working,onClick:()=>{b(k)}})},k.name)),r.error&&!r.reviewing&&e.jsx(W,{tone:"warn",children:r.error})]}),e.jsx(sr,{bot:t,onAdded:()=>{r.refresh()}}),e.jsxs(A,{children:[e.jsx(Qt,{"data-panel-form":"skill-import",value:i,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:d?s("skills.import.importing"):s("common.add"),disabled:d,onChange:c,onSubmit:()=>{f()}}),u.map(k=>e.jsx(W,{children:k},k)),e.jsx(de,{"data-panel-link":"skills-sh",onClick:()=>{ct(Lt)},children:s("botPanel.skills.skillsSh")}),e.jsx(de,{"data-panel-link":"browse-skills",onClick:j,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(de,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),r.reviewing&&e.jsx(ar,{skill:r.reviewing.skill,text:r.reviewing.text,error:r.error,working:r.working===r.reviewing.skill.name,onCancel:()=>r.setReviewing(null),onEnable:()=>{r.enableReviewed()}})]})}function Ii({bot:t}){const{capabilities:a}=ye(),n=a.host?.homeDir,{draft:l,setDraft:r,error:i,saving:c,canPick:d,save:o,pick:u}=tr(t),[m,h]=x.useState(!1),b=!!t.cwd||m,f=()=>{if(d){u();return}h(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsx(He,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!b,disabled:c,onClick:()=>{h(!1),t.cwd&&o(null)}}),e.jsx(He,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:b,disabled:c,onClick:()=>{t.cwd||f()}})]}),b&&e.jsxs(A,{children:[d?e.jsxs("div",{className:G,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?Ye(t.cwd,n):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:c,onClick:()=>{u()},className:re,children:[e.jsx(Ut,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:G,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&o(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>r(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:c||l===null,className:re,children:s("botAccess.folder.save")})]}),i&&e.jsx(W,{tone:"warn",children:i})]})]})}function Li({bot:t,derived:a}){const n=gs(t);return e.jsx(xi,{bot:t,browserEnabled:a.browserEnabled,onOpenBrowser:()=>n("browser")})}function Ai({bot:t}){return os()?e.jsx(cs,{bot:t}):null}function Mi({page:t,onOpen:a,editingInstructions:n,onEditInstructions:l,...r}){switch(t){case"settings":return e.jsx(ji,{...r,onOpen:a,editingInstructions:n,onEditInstructions:l});case"where":return e.jsx(Xr,{...r});case"apps":return e.jsx(Ci,{...r});case"routines":return e.jsx(Pi,{...r});case"visibility":return e.jsx(Ai,{...r});case"memory":return e.jsx(Oi,{...r});case"skills":return e.jsx(Ri,{...r});case"folder":return e.jsx(Ii,{...r});case"browser":return e.jsx(Li,{...r})}}const At="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Mt(t){const[a,n]=x.useState(null),l=x.useRef(!1),r=x.useRef(!1),i=x.useRef(null);x.useEffect(()=>{a!==null||!r.current||(r.current=!1,i.current?.focus())},[a]);const c=m=>{l.current=!1,n(m)},d=()=>{a!==null&&t(a),n(null)};return{draft:a,setDraft:n,start:c,onKeyDown:m=>{if(pn(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),l.current=!0,r.current=!0,d()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l.current=!0,r.current=!0,n(null))},onBlur:()=>{l.current||d()},buttonRef:i}}function Ti({bot:t,activeState:a,patch:n,editorOpen:l,onToggleEditor:r}){const i=Mt(o=>{const u=o.trim();u&&u!==t.name&&n({name:u})}),c=Mt(o=>{const u=o.trim();u!==t.title.trim()&&n({title:u})}),d=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:r,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(qe,{bot:t,size:64,state:a}),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(ut,{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(mn,{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:i.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ke.name,value:i.draft,onChange:o=>i.setDraft(o.target.value),onKeyDown:i.onKeyDown,onBlur:i.onBlur,className:O(At,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:i.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>i.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(ut,{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"})]})})}),c.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Ke.title,value:c.draft,onChange:o=>c.setDraft(o.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:O(At,"mt-[3px] w-[200px] max-w-full text-[13px]")}):d&&e.jsx("button",{ref:c.buttonRef,type:"button","data-panel-label":!0,onClick:()=>c.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:d})]})}function ke(t,a){return t?Zt(t,a):{tab:"details"}}function Bi({bot:t,derived:a,linkedSection:n,onClose:l}){const{dragProps:r}=ts(),i=xn(),[c,d]=x.useState(()=>ke(n,i).tab),[o,u]=x.useState(()=>{const p=ke(n,i).page;return p?[p]:[]}),[m,h]=x.useState(()=>ke(n,i).anchor??null),[b,f]=x.useState(!1),[v,j]=x.useState(()=>!!ke(n,i).editInstructions),k=x.useRef(null),y=x.useRef(null),N=o.at(-1)??null,S=()=>k.current?.scrollTo({top:0}),E=p=>{d(p.tab),u(p.page?[p.page]:[]),h(p.anchor??null),f(!1),j(!!p.editInstructions),S()},M=p=>E({tab:p}),F=p=>{u(R=>[...R,p]),f(!1),S()},T=()=>{f(!1),y.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{u(p=>p.slice(0,-1)),S()};x.useEffect(()=>{n&&E(Zt(n,i))},[n,i]),x.useEffect(()=>{m&&(k.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),h(null))},[m,N,c]);const z=p=>{if(p.key!=="Escape"||p.defaultPrevented)return;const R=p.target,D=typeof R?.closest=="function"?R.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(D&&!D.contains(p.currentTarget)&&D!==y.current&&!y.current?.contains(D))){if(b)T();else if(o.length>0)I();else return;p.preventDefault(),p.stopPropagation()}},L=o.length>1?s(be[o[o.length-2]].title,{name:t.name}):s(mt[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:z,children:[e.jsxs("div",{...r,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(hn,{bot:t,className:Me}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":N==="settings"?"page":void 0,onClick:()=>E({tab:"details",page:"settings"}),className:Me,children:e.jsx(fn,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:Me,children:e.jsx(Ft,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:k,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:N===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:y,children:[e.jsx(Ti,{bot:t,activeState:a.activeState,patch:a.patch,editorOpen:b,onToggleEditor:()=>f(p=>!p)}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:T}),e.jsx(Yr,{bot:t,activeState:a.activeState,onPatch:a.patch,onClose:T})]})]}),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:gn.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===p,"data-panel-tab":p,onClick:()=>M(p),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===p?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(mt[p])},p))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(li,{bot:t,derived:a,onOpen:F}),c==="library"&&e.jsx(js,{bot:t,onOpen:F}),c==="computer"&&e.jsx(Qr,{bot:t,derived:a,onOpen:F})]})]}):e.jsxs("div",{"data-panel-page-view":N,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(yn,{back:L,title:s(be[N].title,{name:t.name}),intro:be[N].intro?s(be[N].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Si),children:e.jsx(Mi,{page:N,bot:t,derived:a,onOpen:F,editingInstructions:v,onEditInstructions:j})})]})})]})}function Di(t,a){const{state:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),[m,h]=x.useState(!1),b=x.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]),f=a.followEdits??!0,v=f?b:null,j=f?n.routines:null,k=f?n.webhooks:null;return x.useEffect(()=>{if(!a.overview&&!a.prompt)return;let y=!1;return(async()=>(await l(t.id),!y&&(a.overview&&se(`/api/bots/${t.id}/overview`).then(S=>{y||(i(S),d(!1))}).catch(()=>{y||d(!0)}),a.prompt&&se(`/api/bots/${t.id}/system-prompt`).then(S=>{y||(u(S),h(!1))}).catch(()=>{y||h(!0)}))))(),()=>{y=!0}},[t.id,a.overview,a.prompt,v,j,k,l]),{overview:r,overviewError:c,prompt:o,promptError:m}}function Fi(t,a){const{dispatch:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),m=x.useRef(0),[h,b]=x.useState(!1),[f,v]=x.useState(null),j=x.useCallback(()=>{const N=++m.current;return d(!1),l(t.id).then(()=>se(`/api/bots/${t.id}/history?limit=100`)).then(S=>{N===m.current&&(i(S.rows),u(S.revision))}).catch(()=>{N===m.current&&d(!0)})},[t.id,l]);return x.useEffect(()=>{if(a)return j(),()=>{m.current++}},[a,j]),{rows:r,error:c,revision:o,rollingBack:h,rollbackTarget:f,setRollbackTarget:v,rollback:async N=>{if(!h){v(null),b(!0);try{await l(t.id),await se(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(N)})}catch(S){n({type:"error",message:S instanceof Error?S.message:s("botOverview.undoFailed")})}finally{await j(),b(!1)}}},requestRollback:N=>{o&&v({id:N,expectedRevision:o})}}}function $i({history:t,returnFocusRef:a}){const{rollbackTarget:n,setRollbackTarget:l,rollback:r}=t;return e.jsx(vn,{open:n!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:a,onCancel:()=>l(null),onConfirm:()=>{n&&r(n)}})}const zi={memory:"memory",skills:"skills",folder:"access"},Ns=t=>t.labelKey?s(t.labelKey):t.label;function Tt(t,a){return a?[t.label,Ns(t),...t.keywords].some(n=>n.toLowerCase().includes(a)):!0}function nl({bot:t,overlay:a=!1}){const{state:n,dispatch:l}=B(),r=n.botSettingsSection,i=bn(t),c=x.useRef(null),{dragProps:d}=ts(),[o,u]=x.useState(""),m=!n.botSettingsExpandAccordion,h=o.trim().toLowerCase(),f=!Dt(),v=!m&&!n.botSettingsExpandRemembered?r:null,j=ps(t.id),k=Je(),y=kn(),N=Cr.filter(L=>L.id!=="slack"||j!==null).filter(L=>L.id!=="visibility"||!window.ogb&&k===!0&&!y),S=N.filter(L=>Tt(L,h)),{overview:E,overviewError:M,prompt:F,promptError:T}=Di(t,{overview:r==="overview"&&!f,prompt:r==="overview"&&!f}),I=Fi(t,r==="history"&&!f);x.useEffect(()=>{if(!m){if(h){u("");return}c.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[m,r,h]),x.useEffect(()=>{const L=document.activeElement instanceof HTMLElement?document.activeElement:null,p=c.current;p?.focus();const R=D=>{const H=p?.querySelector('[role="dialog"], [role="alertdialog"]');H&&H.getClientRects().length>0||p&&D.target instanceof Node&&!p.contains(D.target)||D.key==="Escape"&&!D.defaultPrevented&&(D.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),L?.focus()}},[l]);const z=L=>{switch(L){case"overview":return E===null&&M?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Ar,{overview:E,refreshError:E!==null&&M,prompt:F,promptError:T,onOpen:p=>l({type:"toggleSettings",open:!0,section:p}),onSetup:i.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(dr,{bot:t,patch:i.patch,activeState:i.activeState,mascotMotion:i.mascotMotion});case"soul":return e.jsx(cr,{bot:t,patch:i.patch});case"slack":return j?e.jsx(Mr,{managementUrl:j}):null;case"skills":return e.jsx(or,{bot:t});case"memory":return e.jsx(Dr,{bot:t,active:!m&&r==="memory",onToggle:p=>i.patch({memoryEnabled:p})});case"library":return e.jsx(js,{bot:t,onOpen:p=>l({type:"toggleSettings",open:!0,section:zi[p]??"overview"})});case"routines":return e.jsx(xr,{bot:t,routines:i.botRoutines,runs:n.routineRuns});case"access":return e.jsx(lr,{bot:t,derived:i});case"model":return e.jsx(ir,{bot:t});case"permissions":return e.jsx(rr,{bot:t,derived:i});case"voice":return e.jsx(nr,{bot:t,derived:i});case"visibility":return e.jsx(cs,{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(Hr,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(_r,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:f?jn:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Nn(a,f),children:f?e.jsx(Bi,{bot:t,derived:i,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...d,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(wn,{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(Ft,{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(Bt,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:o,onChange:L=>{u(L.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:L=>{L.key==="Escape"&&(L.stopPropagation(),o?u(""):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:[S.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:o.trim()})}),N.map(L=>{const{id:p,icon:R}=L,D=Ns(L),H=Tt(L,h);if(!H&&p!=="memory")return null;const _=!m&&r===p;return e.jsxs("div",{"data-bot-settings-section":p,className:"border-b border-hairline/30",hidden:!H,children:[e.jsxs("button",{type:"button",onClick:()=>{if(r===p&&!m){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:p})},"aria-expanded":_,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",_?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(R,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:D}),e.jsx(xe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",_&&"rotate-180")})]}),p==="memory"?e.jsx("div",{hidden:!_,className:"px-4 pb-4 pt-1",children:z("memory")}):_&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:z(p)})]},p)})]})]})}),e.jsx($i,{history:I,returnFocusRef:c})]})}export{nl as BotSettingsDialog};