limixbot 0.3.48 → 0.3.49

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 (175) hide show
  1. package/dist/assets/{ActivityPanel-XlvWcNh9.js → ActivityPanel-DOLj6vdX.js} +1 -1
  2. package/dist/assets/{App-ChCSOxIp.js → App-D81V4ldd.js} +111 -111
  3. package/dist/assets/{AppEventEditor-BVUu_Lcx.js → AppEventEditor-ab3UR4LS.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-D_cLgiH4.js +16 -0
  5. package/dist/assets/{BrowserPanel-BCIfyKnn.js → BrowserPanel-BMzs1O8G.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-DbgSvM0f.js → BrowserProfilesManager-DOVv9QX0.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-Dl9Oshym.js → CloudAddDialog-DrhnkBjW.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-Cgj-gSm4.js → ComputerFilesPane-CN8QMnw3.js} +1 -1
  9. package/dist/assets/{ComputerPanel-CWt6-5YN.js → ComputerPanel-CaIt9MKD.js} +2 -2
  10. package/dist/assets/{DataPanel-S3D8uZov.js → DataPanel-BNVcp6of.js} +1 -1
  11. package/dist/assets/{DesktopViewer-D1ZJW3yu.js → DesktopViewer-DFhYwHIq.js} +1 -1
  12. package/dist/assets/{FilesView-DUUdJ-mW.js → FilesView-DW9SCyV-.js} +1 -1
  13. package/dist/assets/{GrokMoveDialog-DgUr2ErY.js → GrokMoveDialog-mHb6IcFC.js} +1 -1
  14. package/dist/assets/{InspectorPanel-D0oeNabp.js → InspectorPanel-Ce4_qW9h.js} +1 -1
  15. package/dist/assets/{KeyboardShortcutsModal-DDjFDnGN.js → KeyboardShortcutsModal-CLNFMSjb.js} +1 -1
  16. package/dist/assets/{LiveDesktop-CqifRkl1.js → LiveDesktop-BjRurHnb.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-BQbtgJKn.js → LocalVmWorkspace-CqsCtYlw.js} +1 -1
  18. package/dist/assets/{MacLocalControl-CfV-X14C.js → MacLocalControl-CKBC29SJ.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-X0MehVrM.js → MarkdownFilePreview-Dmulebe8.js} +1 -1
  20. package/dist/assets/{MenuMotion-BNVn5GSt.js → MenuMotion-CtV49YrJ.js} +1 -1
  21. package/dist/assets/{NewBotDialog-_J5mh-JV.js → NewBotDialog-D9rstuqs.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-C5EDNXE1.js → PhoneAppDialog-CaCKkATB.js} +1 -1
  23. package/dist/assets/{PlacesRail-CIHIyPoQ.js → PlacesRail-COZEZH0n.js} +1 -1
  24. package/dist/assets/{PluginsPanel-Uf4xxYLo.js → PluginsPanel-DYY_IXSa.js} +1 -1
  25. package/dist/assets/{ProIntroduction-C1ZjYkae.js → ProIntroduction-DfpCTBHe.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-C2ii1ptH.js → RemoteAgentSettingsPanel-OSSdthdZ.js} +1 -1
  27. package/dist/assets/{RoomPanel-rpY6VUWk.js → RoomPanel-BQA73L-t.js} +1 -1
  28. package/dist/assets/{RoutinesPage-D3s9tF-X.js → RoutinesPage-CXOMn_kl.js} +1 -1
  29. package/dist/assets/{SettingsModal-BGxaTJg5.js → SettingsModal-BsiCQwg6.js} +1 -1
  30. package/dist/assets/{ShareTeamDialog-BcXftoRN.js → ShareTeamDialog-IqLImhjS.js} +1 -1
  31. package/dist/assets/{SignedInSites-BGTefeLy.js → SignedInSites-BpHOfApd.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-BGrOgQek.js → TeamLibraryPanel-4ktTFM-N.js} +1 -1
  33. package/dist/assets/{TeamMapPage-C6S7_ma-.js → TeamMapPage-9nuEqxdk.js} +1 -1
  34. package/dist/assets/{TriggersPage-CtgQCp6P.js → TriggersPage-CS8Xxzuy.js} +1 -1
  35. package/dist/assets/VisibilitySection-DNZ4sulC.js +22 -0
  36. package/dist/assets/{WebhookTrigger-DwY5yBvw.js → WebhookTrigger-CwZdLciz.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-BQiI1n3L.js → WorksOnGrid-CYzp7YXl.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-E5u2FY-u.js → abnfDiagram-YUKMZFIV-DmWI1Mtg.js} +1 -1
  39. package/dist/assets/{activity-CBC39k-I.js → activity-WfPBvs3Z.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-HbRi9-3s.js → architectureDiagram-47P4ROYG-rzc3-Q0w.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-BvbJQxRJ.js → blockDiagram-E7TT5TSB-VPDyKlQ7.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-6XQ7PCr5.js → c4Diagram-CRA5TL53-C9OGckku.js} +1 -1
  43. package/dist/assets/{calendar-days-uVdUhtRr.js → calendar-days-W4JHp6-m.js} +1 -1
  44. package/dist/assets/channel-DAFePtOr.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-KKy_GF1y.js → chunk-2Q5K7J3B-EpYkwMC8.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-CAqDmDHS.js → chunk-5VM5RSS4-DyJEI8X6.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-Y_lWu8VB.js → chunk-7TKQ45FW-CJvVxQ2I.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-BO3PAeWa.js → chunk-AW2ZBBNX-s78zNrhy.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-BEy6ZFro.js → chunk-FVRAUYC3-CUPjaz9e.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF-ge9hH-_c.js → chunk-HTAEGDNF-BhuM2dxl.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-D_lI4aTU.js → chunk-JWPE2WC7-DAj1UgJ8.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-DPMJ2vJV.js → chunk-KQW6MTUR-BgfdtkJI.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-C4mYjNRr.js → chunk-XXDRQBXY-Vak43p0S.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-DlGliqAX.js → classDiagram-v2-K4WV4PDN-Cjvbs86l.js} +1 -1
  55. package/dist/assets/{coins-C5bat6u2.js → coins-B1tpScHw.js} +1 -1
  56. package/dist/assets/{core-BIk0hYPX.js → core-CmGeFi0y.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-DVNjr33T.js → cose-bilkent-JH36ORCC-BEekB3gO.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-B6NBBGhM.js → cynefin-EF2NZ3EQ-D3g3_jPk.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-xdyPjX9I.js → cynefinDiagram-3GCD6N5R-13xmjXZj.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-Cj9fToJq.js → dagre-W4DXFKR2-CHAV8s2t.js} +1 -1
  61. package/dist/assets/de-CJcRve_J.js +8 -0
  62. package/dist/assets/{diagram-2UJZ2QOL-FQ9YmfPr.js → diagram-2UJZ2QOL-DgwdzZN7.js} +1 -1
  63. package/dist/assets/{diagram-OVF4WLC6-DjjDmsSv.js → diagram-OVF4WLC6-DobmWwa_.js} +1 -1
  64. package/dist/assets/{diagram-PFPMY2P6-DMa8rvdp.js → diagram-PFPMY2P6-CWjTVc0N.js} +1 -1
  65. package/dist/assets/{diagram-UMYRVEAY-BzFwDQTx.js → diagram-UMYRVEAY-CAruZkhk.js} +1 -1
  66. package/dist/assets/{diagram-YEKJPTXX-D2oM-7uQ.js → diagram-YEKJPTXX-Bcs89mQN.js} +1 -1
  67. package/dist/assets/{diagram-ZIFT7M5P-BDIMPZpL.js → diagram-ZIFT7M5P-Dz-O18tl.js} +1 -1
  68. package/dist/assets/{ebnfDiagram-VR2GEFS7-5YsbZGCa.js → ebnfDiagram-VR2GEFS7-CJX4rMIs.js} +1 -1
  69. package/dist/assets/{elk-IJKZMXRS-DSZEAjKl.js → elk-IJKZMXRS-Byop6FtW.js} +1 -1
  70. package/dist/assets/{erDiagram-O2IAPWRE-BeXzxJfj.js → erDiagram-O2IAPWRE-ChpLnNCF.js} +1 -1
  71. package/dist/assets/es-DL-LT7LK.js +6 -0
  72. package/dist/assets/{file-up-pts79DW9.js → file-up-G3qWGpEB.js} +1 -1
  73. package/dist/assets/{flowDiagram-OXPTDLAJ-D05KXhfA.js → flowDiagram-OXPTDLAJ-CWWhkNOE.js} +1 -1
  74. package/dist/assets/fr-Cqgsh6FT.js +8 -0
  75. package/dist/assets/{ganttDiagram-R7TSEDQI-9IKnYcFv.js → ganttDiagram-R7TSEDQI-DMXicWgq.js} +1 -1
  76. package/dist/assets/{gitGraphDiagram-XJZIOB7I-De1Fj8FH.js → gitGraphDiagram-XJZIOB7I-CpiCnPUQ.js} +1 -1
  77. package/dist/assets/hi-DRlAa-mm.js +1 -0
  78. package/dist/assets/{import-name-BfYhMg1y.js → import-name-bz0My-IU.js} +1 -1
  79. package/dist/assets/{index-up1CA0zX.js → index-D_0hmaNc.js} +2 -2
  80. package/dist/assets/{index-PhXpx5mv.js → index-arIlKsXK.js} +1 -1
  81. package/dist/assets/{infoDiagram-5W2HQ5XZ-BB9tseML.js → infoDiagram-5W2HQ5XZ-BU9zbv9f.js} +1 -1
  82. package/dist/assets/{ishikawaDiagram-K3B6WC7H-zQATL5V8.js → ishikawaDiagram-K3B6WC7H-KEjUVvmG.js} +1 -1
  83. package/dist/assets/it-BapR4fyG.js +13 -0
  84. package/dist/assets/ja-rH-EVVS5.js +13 -0
  85. package/dist/assets/{journeyDiagram-COXZFDF6-DWl-s77q.js → journeyDiagram-COXZFDF6-DGU1V_40.js} +1 -1
  86. package/dist/assets/{kanban-definition-P3RFRI5V-0gNFYf4b.js → kanban-definition-P3RFRI5V-weJ2OFB2.js} +1 -1
  87. package/dist/assets/ko-DXzDBiEb.js +13 -0
  88. package/dist/assets/{mcp-servers-CkHO2yG6.js → mcp-servers-DJbj8A-F.js} +1 -1
  89. package/dist/assets/{mermaid.core-aRNMQk5-.js → mermaid.core-DhSRukyE.js} +4 -4
  90. package/dist/assets/{mindmap-definition-LZFPQGKD-Bof3P1eD.js → mindmap-definition-LZFPQGKD-DKKO0DWj.js} +1 -1
  91. package/dist/assets/{minimize-B2-pCESw.js → minimize-C16JX5N8.js} +1 -1
  92. package/dist/assets/{monitor-ET_fUXyt.js → monitor-Bben4nuu.js} +1 -1
  93. package/dist/assets/{new-bot-D-yMiT7M.js → new-bot-Dr5oueeD.js} +1 -1
  94. package/dist/assets/{org-library-D_E7GVek.js → org-library-kDl9eWm6.js} +1 -1
  95. package/dist/assets/{package-format-B5SXvrHy.js → package-format-DigdVa67.js} +1 -1
  96. package/dist/assets/{pegDiagram-BGZESJAR-DDlKwD4R.js → pegDiagram-BGZESJAR-CNNprTkt.js} +1 -1
  97. package/dist/assets/{pieDiagram-CAPJLFHJ-DtwDw9NT.js → pieDiagram-CAPJLFHJ-pS8U8zdK.js} +1 -1
  98. package/dist/assets/pl-BV7GtmiM.js +13 -0
  99. package/dist/assets/pt-br-Dr9a700a.js +13 -0
  100. package/dist/assets/{quadrantDiagram-GDMTTRAM-CDeSRO7Z.js → quadrantDiagram-GDMTTRAM-CLk_fr2j.js} +1 -1
  101. package/dist/assets/{rail-DdyH9Fje.js → rail-CpM5o3ti.js} +1 -1
  102. package/dist/assets/{railroadDiagram-SM67HX2B-DJAwC8qS.js → railroadDiagram-SM67HX2B-DH8VPMJG.js} +1 -1
  103. package/dist/assets/{remote-desktop-panel-DN2__781.js → remote-desktop-panel-B0yyDRuX.js} +1 -1
  104. package/dist/assets/{requirementDiagram-X7JNWC4A-WsM1ryr2.js → requirementDiagram-X7JNWC4A-CoHRI7dx.js} +1 -1
  105. package/dist/assets/ru-DSSPfQyi.js +13 -0
  106. package/dist/assets/{sankeyDiagram-UM26HJRW-BaRMQhWI.js → sankeyDiagram-UM26HJRW-2zcVfvWw.js} +1 -1
  107. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-BaxysqoC.js → sequenceDiagram-ZO4K6R2Y-B0d21eid.js} +1 -1
  108. package/dist/assets/{sizeCapture-INFHLROL-BI5Y1n1O.js → sizeCapture-INFHLROL-CcYkvoh7.js} +1 -1
  109. package/dist/assets/{stateDiagram-v2-TBUQTH76-DqD0Wnx3.js → stateDiagram-v2-TBUQTH76-B5EilR72.js} +1 -1
  110. package/dist/assets/{styles-CxbuKpLq.js → styles-Cbtcp5Re.js} +2 -2
  111. package/dist/assets/styles-rYmbSF4Y.css +1 -0
  112. package/dist/assets/{swimlanes-N4OXWK64-pCvU3flP.js → swimlanes-N4OXWK64-xM7mNll9.js} +1 -1
  113. package/dist/assets/swimlanesDiagram-K3J5GTZL-CnVwW_RC.js +8 -0
  114. package/dist/assets/{team-share-C-EjLBgR.js → team-share-Bp69YR8I.js} +1 -1
  115. package/dist/assets/{timeline-definition-YOQAKGHF-BEpkjZWs.js → timeline-definition-YOQAKGHF-DM6SmhCQ.js} +1 -1
  116. package/dist/assets/tr-DJNxAMAd.js +6 -0
  117. package/dist/assets/uk-SbiO0vE9.js +1 -0
  118. package/dist/assets/{usecaseDiagram-VIAY4XPW-DUBT_yZ3.js → usecaseDiagram-VIAY4XPW-DiUdGN3G.js} +1 -1
  119. package/dist/assets/{vennDiagram-BLWOH2XV-CxArldGE.js → vennDiagram-BLWOH2XV-DrtmNBp4.js} +1 -1
  120. package/dist/assets/{vi-BYSU3aaD.js → vi-vTat5qyz.js} +1 -1
  121. package/dist/assets/{wardleyDiagram-YMQ3BMBF-BQIk4Vh2.js → wardleyDiagram-YMQ3BMBF-D7jihWm5.js} +1 -1
  122. package/dist/assets/{xychartDiagram-TAQBALBS-BcBrHX_m.js → xychartDiagram-TAQBALBS-BCk-D9Uj.js} +1 -1
  123. package/dist/assets/zh-Ce8h_nYy.js +13 -0
  124. package/dist/assets/zh-tw-DXbqGzsI.js +13 -0
  125. package/dist/index.html +3 -3
  126. package/dist/rail.html +5 -5
  127. package/dist-server/container-mcp.js +2 -2
  128. package/dist-server/drivers/agents-proxy.js +92 -89
  129. package/dist-server/index.js +1614 -1568
  130. package/dist-server/openmausbot.js +561 -632
  131. package/dist-server/package.json +1 -1
  132. package/dist-server/pair-cli.js +65 -62
  133. package/dist-server/server/activity.js +1 -0
  134. package/dist-server/server/chief-of-staff.js +3 -2
  135. package/dist-server/server/container-computer.js +31 -4
  136. package/dist-server/server/default-bot.js +2 -2
  137. package/dist-server/server/drivers/agents-call.js +3 -0
  138. package/dist-server/server/drivers/agents-catalog.js +16 -6
  139. package/dist-server/server/index.js +76 -15
  140. package/dist-server/server/limix-assistant-name.js +18 -0
  141. package/dist-server/server/limix-channel-identity.js +1 -0
  142. package/dist-server/server/limix-channel-media.js +1 -0
  143. package/dist-server/server/limix-desktop-resources.js +26 -0
  144. package/dist-server/server/limix-diagnose.js +41 -0
  145. package/dist-server/server/limix-gateway-sidecar.js +23 -0
  146. package/dist-server/server/limix-managed-grant.js +110 -0
  147. package/dist-server/server/limix-team-desktop.js +32 -0
  148. package/dist-server/server/routes/bot-messages.js +2 -2
  149. package/dist-server/server/routes/bot-patch.js +24 -0
  150. package/dist-server/server/routes/internal-chief-team.js +15 -5
  151. package/dist-server/server/team-setup-requests.js +60 -5
  152. package/dist-server/shared/default-bot.js +3 -1
  153. package/dist-server/shared/new-bot-defaults.js +1 -0
  154. package/dist-server/shared/ready-bots.js +331 -0
  155. package/dist-server/vps-container-mcp.js +8 -8
  156. package/package.json +1 -1
  157. package/dist/assets/BotSettingsDialog-DITlFmzw.js +0 -16
  158. package/dist/assets/VisibilitySection-CLj2_C44.js +0 -22
  159. package/dist/assets/channel-CeBX8eSw.js +0 -1
  160. package/dist/assets/de-BZ9nuzrz.js +0 -8
  161. package/dist/assets/es-BxLq0ePd.js +0 -6
  162. package/dist/assets/fr-BoXnQ5F8.js +0 -8
  163. package/dist/assets/hi-CcIxinfW.js +0 -1
  164. package/dist/assets/it-I6t2VEkh.js +0 -13
  165. package/dist/assets/ja-XTlk5V47.js +0 -13
  166. package/dist/assets/ko-BplWTKGd.js +0 -13
  167. package/dist/assets/pl-Bv2R8H4r.js +0 -13
  168. package/dist/assets/pt-br-CM02ONwa.js +0 -15
  169. package/dist/assets/ru-CJcyvxC6.js +0 -13
  170. package/dist/assets/styles-3v-vHlNV.css +0 -1
  171. package/dist/assets/swimlanesDiagram-K3J5GTZL-Bt5R1mJd.js +0 -8
  172. package/dist/assets/tr-CTl25e95.js +0 -6
  173. package/dist/assets/uk-B_psMXqm.js +0 -1
  174. package/dist/assets/zh-BPHbGe7C.js +0 -13
  175. package/dist/assets/zh-tw-BMYbS8NC.js +0 -15
@@ -124,7 +124,7 @@ liveness,PROBE_TIMEOUT_MS,options.env),onDead:()=>{process.stderr.write(`${optio
124
124
  e starts on the next call
125
125
  `),stopping&&detach()}};function watchChild(proc){proc.on("error",error62=>{if(process.stderr.write(`could not connect to ${options.label}: ${error62.message}
126
126
  `),respawn){childLost(proc);return}process.exitCode=1,watchdog?.stop(),children.close(),detach()}),proc.on("close",(code,signal)=>{if(respawn){childLost(proc);return}signal&&process.stderr.write(`${options.label} connection ended with ${signal}
127
- `),process.exitCode=process.exitCode??code??1,watchdog?.stop(),children.close(),detach()})}watchChild(child);for(let signal of["SIGTERM","SIGINT"])process.on(signal,()=>{stopping=!0,childGone&&process.exit(0),child.kill(signal)})}import{execFile as execFile2}from"node:child_process";import{join as join7,resolve as resolve4}from"node:path";import{promisify}from"node:util";import{readFileSync as readFileSync3,mkdirSync,existsSync as existsSync3,renameSync}from"node:fs";import{mkdtempSync}from"node:fs";import{homedir as homedir2,tmpdir,userInfo}from"node:os";import{join as join4}from"node:path";var home;function dataHome(){if(home!==void 0)return home;let real=homedir2();return home=process.env.VITEST!==void 0&&real===userInfo().homedir?mkdtempSync(join4(tmpdir(),"omb-test-home-")):real,home}import{join as join5}from"node:path";var external_exports={};__export(external_exports,{$brand:()=>$brand,$input:()=>$input,$output:()=>$output,INVALID:()=>INVALID,NEVER:()=>NEVER,TimePrecision:()=>TimePrecision,ZodAny:()=>ZodAny,ZodArray:()=>ZodArray,ZodBase64:()=>ZodBase64,ZodBase64URL:()=>ZodBase64URL,ZodBigInt:()=>ZodBigInt,ZodBigIntFormat:()=>ZodBigIntFormat,ZodBoolean:()=>ZodBoolean,ZodCIDRv4:()=>ZodCIDRv4,ZodCIDRv6:()=>ZodCIDRv6,ZodCUID:()=>ZodCUID,ZodCUID2:()=>ZodCUID2,ZodCatch:()=>ZodCatch,ZodCodec:()=>ZodCodec,ZodCompileAsyncError:()=>ZodCompileAsyncError,
127
+ `),process.exitCode=process.exitCode??code??1,watchdog?.stop(),children.close(),detach()})}watchChild(child);for(let signal of["SIGTERM","SIGINT"])process.on(signal,()=>{stopping=!0,childGone&&process.exit(0),child.kill(signal)})}import{execFile as execFile2}from"node:child_process";import{basename as basename3,dirname as dirname4,join as join7,resolve as resolve4}from"node:path";import{promisify}from"node:util";import{readFileSync as readFileSync3,mkdirSync,existsSync as existsSync3,renameSync}from"node:fs";import{mkdtempSync}from"node:fs";import{homedir as homedir2,tmpdir,userInfo}from"node:os";import{join as join4}from"node:path";var home;function dataHome(){if(home!==void 0)return home;let real=homedir2();return home=process.env.VITEST!==void 0&&real===userInfo().homedir?mkdtempSync(join4(tmpdir(),"omb-test-home-")):real,home}import{join as join5}from"node:path";var external_exports={};__export(external_exports,{$brand:()=>$brand,$input:()=>$input,$output:()=>$output,INVALID:()=>INVALID,NEVER:()=>NEVER,TimePrecision:()=>TimePrecision,ZodAny:()=>ZodAny,ZodArray:()=>ZodArray,ZodBase64:()=>ZodBase64,ZodBase64URL:()=>ZodBase64URL,ZodBigInt:()=>ZodBigInt,ZodBigIntFormat:()=>ZodBigIntFormat,ZodBoolean:()=>ZodBoolean,ZodCIDRv4:()=>ZodCIDRv4,ZodCIDRv6:()=>ZodCIDRv6,ZodCUID:()=>ZodCUID,ZodCUID2:()=>ZodCUID2,ZodCatch:()=>ZodCatch,ZodCodec:()=>ZodCodec,ZodCompileAsyncError:()=>ZodCompileAsyncError,
128
128
  ZodCompileUnsupportedError:()=>ZodCompileUnsupportedError,ZodCreditCard:()=>ZodCreditCard,ZodCustom:()=>ZodCustom,ZodCustomStringFormat:()=>ZodCustomStringFormat,ZodDate:()=>ZodDate,ZodDefault:()=>ZodDefault,ZodDiscriminatedUnion:()=>ZodDiscriminatedUnion,ZodE164:()=>ZodE164,ZodEmail:()=>ZodEmail,ZodEmoji:()=>ZodEmoji,ZodEnum:()=>ZodEnum,ZodError:()=>ZodError,ZodExactOptional:()=>ZodExactOptional,ZodFile:()=>ZodFile,ZodFirstPartyTypeKind:()=>ZodFirstPartyTypeKind,ZodFunction:()=>ZodFunction,ZodGUID:()=>ZodGUID,
129
129
  ZodIBAN:()=>ZodIBAN,ZodIPv4:()=>ZodIPv4,ZodIPv6:()=>ZodIPv6,ZodISODate:()=>ZodISODate,ZodISODateTime:()=>ZodISODateTime,ZodISODuration:()=>ZodISODuration,ZodISOTime:()=>ZodISOTime,ZodInstanceOf:()=>ZodInstanceOf,ZodIntersection:()=>ZodIntersection,ZodIssueCode:()=>ZodIssueCode,ZodJWT:()=>ZodJWT,ZodKSUID:()=>ZodKSUID,ZodLazy:()=>ZodLazy,ZodLiteral:()=>ZodLiteral,ZodMAC:()=>ZodMAC,ZodMap:()=>ZodMap,ZodNaN:()=>ZodNaN,ZodNanoID:()=>ZodNanoID,ZodNever:()=>ZodNever,ZodNonOptional:()=>ZodNonOptional,ZodNull:()=>ZodNull,
130
130
  ZodNullable:()=>ZodNullable,ZodNumber:()=>ZodNumber,ZodNumberFormat:()=>ZodNumberFormat,ZodObject:()=>ZodObject,ZodOptional:()=>ZodOptional,ZodPipe:()=>ZodPipe,ZodPrefault:()=>ZodPrefault,ZodPreprocess:()=>ZodPreprocess,ZodPromise:()=>ZodPromise,ZodReadonly:()=>ZodReadonly,ZodRealError:()=>ZodRealError,ZodRecord:()=>ZodRecord,ZodSet:()=>ZodSet,ZodString:()=>ZodString,ZodStringFormat:()=>ZodStringFormat,ZodSuccess:()=>ZodSuccess,ZodSymbol:()=>ZodSymbol,ZodTemplateLiteral:()=>ZodTemplateLiteral,ZodTransform:()=>ZodTransform,
@@ -1506,7 +1506,7 @@ record(external_exports.string(),external_exports.json());function parseStoredCo
1506
1506
  " = "$uid:$gid" ] || { echo "cua did not take uid $uid gid $gid" >&2; exit 1; }',"fi",`exec ${SUPERVISORD}`].join(`
1507
1507
  `);import{existsSync as existsSync4}from"node:fs";import{dirname as dirname3,join as join6}from"node:path";import{fileURLToPath}from"node:url";var SERVER_ROOT=dirname3(fileURLToPath(import.meta.url));function resolveProxy(relative5){let source=join6(SERVER_ROOT,`${relative5}.ts`);return existsSync4(source)?source:join6(SERVER_ROOT,`${relative5}.js`)}var SPAWNED_PROXIES={harnessMcp:resolveProxy("harness-mcp-proxy"),localComputer:resolveProxy("local-computer-proxy"),permission:resolveProxy("permissio\
1508
1508
  n-proxy"),containerMcp:resolveProxy("container-mcp"),vpsContainerMcp:resolveProxy("vps-container-mcp"),agents:resolveProxy("drivers/agents-proxy"),dweb:resolveProxy("drivers/dweb-proxy"),connectors:resolveProxy("connector-proxy"),mcpGate:resolveProxy("mcp-gate"),mcpRemote:resolveProxy("mcp-remote-proxy"),phone:resolveProxy("drivers/phone-proxy"),chatgptPlanToken:resolveProxy("drivers/chatgpt-plan-token-command"),hook:resolveProxy("hooks/omb-hook"),piMcpExtension:resolveProxy("drivers/pi-mcp-exte\
1509
- nsion")};var run=promisify(execFile2);var CUA_DRIVER_VERSION="0.37.0",BASE_IMAGE_REPOSITORY="docker.io/trycua/xfce-cua",BASE_IMAGE_DIGEST="sha256:274eb636f5cf3fc58f705916ee72b7a701270b3877369d08533a385c5325be9b",BASE_IMAGE=`${BASE_IMAGE_REPOSITORY}@${BASE_IMAGE_DIGEST}`,IMAGE_REPOSITORY="localhost/limixbot/cua-local-vm",IMAGE_LAYER_VERSION="9";var IMAGE=`${IMAGE_REPOSITORY}:driver-${CUA_DRIVER_VERSION}-v${IMAGE_LAYER_VERSION}`,CONTAINER="limixbot-computer";var VM_WORKSPACE_DIR=join7(DATA_DIR,"vm-home");var DISPLAY=":1",CUA_SOCKET="/run/user/1000/limixbot-cua.sock",CUA_EXECUTABLE="/usr/local/libexec/limixbot/cua-driver";function cuaExecArgs(args2,options={}){return["exec",...options.interactive?["-i"]:[],"-u","cua","-e","HOME=/home/cua","-e",`DISPLAY=${DISPLAY}`,"-e","CUA_DRIVER_INSTALL_CHANNEL=python_package","-e","CUA_DRIVER_RS_TELEMETRY_ENABLED=0",options.container??CONTAINER,CUA_EXECUTABLE,...args2]}var containerMcpPath=SPAWNED_PROXIES.containerMcp;import{randomBytes as randomBytes2}from"node:crypto";import{closeSync as closeSync2,existsSync as existsSync6,mkdirSync as mkdirSync2,openSync as openSync2,rmSync as rmSync2,statSync as statSync4,writeFileSync}from"node:fs";import{dirname as dirname4,join as join10,resolve as resolve5}from"node:path";import{join as join8}from"node:path";function npmEnginesPrefix(dataDir){return join8(dataDir,"tools","npm")}function antigravityRuntimesRoot(dataDir){return join8(dataDir,"tools","antigravity-acp")}function standaloneEnginesRoot(dataDir){return join8(dataDir,"tools","standalone")}function engineInstallRoots(dataDir){return[npmEnginesPrefix(dataDir),antigravityRuntimesRoot(dataDir),standaloneEnginesRoot(dataDir)]}function bridgedCommand(tools,bridges,command,args2,relay){if(!bridges.length&&!relay)return{command,args:[...args2]};if(tools.socat&&!relay){let lines=bridges.map(bridge=>`${shellWord(tools.socat)} TCP4-LISTEN:${bridge.port},bind=127.0.0.1,reuseaddr,fork UNIX-CONNECT:${shellWord(inBoxSocket(bridge.name))} </dev/null >/dev/null 2>&1 &`),first=bridges[0],wait=`n=0; until ${shellWord(tools.socat)} -u OPEN:/dev/null TCP4:127.0.0.1:${first.port},connect-timeout=0.2 2>/dev/null || [ "$n" -ge 100 ]; d\
1509
+ nsion")};var run=promisify(execFile2);var CUA_DRIVER_VERSION="0.37.0",BASE_IMAGE_REPOSITORY="docker.io/trycua/xfce-cua",BASE_IMAGE_DIGEST="sha256:274eb636f5cf3fc58f705916ee72b7a701270b3877369d08533a385c5325be9b",BASE_IMAGE=`${BASE_IMAGE_REPOSITORY}@${BASE_IMAGE_DIGEST}`,IMAGE_REPOSITORY="localhost/limixbot/cua-local-vm",IMAGE_LAYER_VERSION="9";var IMAGE=`${IMAGE_REPOSITORY}:driver-${CUA_DRIVER_VERSION}-v${IMAGE_LAYER_VERSION}`,CONTAINER="limixbot-computer";var VM_WORKSPACE_DIR=join7(DATA_DIR,"vm-home");var DISPLAY=":1",CUA_SOCKET="/run/user/1000/limixbot-cua.sock",CUA_EXECUTABLE="/usr/local/libexec/limixbot/cua-driver";var TEAM_FOLDERS_DIR=join7(DATA_DIR,"vm-teams");function cuaExecArgs(args2,options={}){return["exec",...options.interactive?["-i"]:[],"-u","cua","-e","HOME=/home/cua","-e",`DISPLAY=${DISPLAY}`,"-e","CUA_DRIVER_INSTALL_CHANNEL=python_package","-e","CUA_DRIVER_RS_TELEMETRY_ENABLED=0",options.container??CONTAINER,CUA_EXECUTABLE,...args2]}var containerMcpPath=SPAWNED_PROXIES.containerMcp;import{randomBytes as randomBytes2}from"node:crypto";import{closeSync as closeSync2,existsSync as existsSync6,mkdirSync as mkdirSync2,openSync as openSync2,rmSync as rmSync2,statSync as statSync4,writeFileSync}from"node:fs";import{dirname as dirname5,join as join10,resolve as resolve5}from"node:path";import{join as join8}from"node:path";function npmEnginesPrefix(dataDir){return join8(dataDir,"tools","npm")}function antigravityRuntimesRoot(dataDir){return join8(dataDir,"tools","antigravity-acp")}function standaloneEnginesRoot(dataDir){return join8(dataDir,"tools","standalone")}function engineInstallRoots(dataDir){return[npmEnginesPrefix(dataDir),antigravityRuntimesRoot(dataDir),standaloneEnginesRoot(dataDir)]}function bridgedCommand(tools,bridges,command,args2,relay){if(!bridges.length&&!relay)return{command,args:[...args2]};if(tools.socat&&!relay){let lines=bridges.map(bridge=>`${shellWord(tools.socat)} TCP4-LISTEN:${bridge.port},bind=127.0.0.1,reuseaddr,fork UNIX-CONNECT:${shellWord(inBoxSocket(bridge.name))} </dev/null >/dev/null 2>&1 &`),first=bridges[0],wait=`n=0; until ${shellWord(tools.socat)} -u OPEN:/dev/null TCP4:127.0.0.1:${first.port},connect-timeout=0.2 2>/dev/null || [ "$n" -ge 100 ]; d\
1510
1510
  o n=$((n+1)); sleep 0.01; done`;return{command:"/bin/sh",args:["-c",[...lines,wait,'exec "$0" "$@"'].join(`
1511
1511
  `),command,...args2]}}return{command:tools.node,args:[tools.bridgeScript,...bridges.map(bridge=>`--bridge=${bridge.port}=${inBoxSocket(bridge.name)}`),...relay?[`--relay=${relay}`]:[],"--",command,...args2]}}function shellWord(value){return`'${value.replaceAll("'","'\\''")}'`}import{createHash,randomBytes,timingSafeEqual}from"node:crypto";import{createServer,request as httpRequest}from"node:http";import{request as httpsRequest}from"node:https";function refusedCallAnswer(server,sentCredentials,body){let frame;try{frame=JSON.parse(body)}catch{return null}let{id,method}=frame&&typeof frame=="object"&&!Array.isArray(frame)?frame:{};if(method!=="tools/call"||typeof id!="string"&&typeof id!="number")return null;let text=sentCredentials?`The MCP server "${server}" refused the sign-in or key it was sent (HTTP 401), so nothing ran. Don't retry. If it signs in, call mcp_server with action sign_in and name ${server}, then end your turn; otherwis\
1512
1512
  e tell the person to update its key in Apps, MCP servers.`:`The MCP server "${server}" needs a sign-in before its tools work, and nobody has signed in (HTTP 401), so nothing ran. Don't retry. Call mcp_server with action sign_in and name ${server}, then end your turn; if you can't, tell the person to sign in to ${server} in Apps, MCP servers.`;return JSON.stringify({jsonrpc:"2.0",id,result:{content:[{type:"text",text}],isError:!0}})}var BROKER_TOKEN_PREFIX="omb_t0_",BROKER_PROCESS_TTL_MS=1440*6e4,BROKER_THREAD_TTL_MS=1440*6e4,MAX_TOKENS=1e4,CREDENTIAL_HEADERS=new Set(["authorization","x-api-key","x-goog-api-key","proxy-authorization","cookie"]),HOP_BY_HOP=new Set(["connection","keep-alive","transfer-encoding","te","trailer","upgrade","proxy-connection","host"]),TOKEN=/^omb_t0_[a-f0-9]{48}$/,GRANT=/^[a-z][a-z0-9_-]{0,63}$/;function brokerUrl(port,token,grant){return`http://127.0.0.1:${port}/b/${token}/${grant}`}function upstreamUrl(upstream,path,query){
@@ -1574,7 +1574,7 @@ resolve5(request.home??this.options.setup.home)).filter(dir=>!(env.PATH??"").spl
1574
1574
  request.relay?inBoxSocket(RELAY_SOCKET_NAME):void 0,inner=bridgedCommand(this.options.bridge,bridges,request.command,request.args,relay),brokered=this.broker(env,plan,request);try{let vouched=(request.allowEnv??[]).filter(name=>/(?:KEY|TOKEN|SECRET)$/.test(name)&&brokered.env[name]!==void 0&&brokered.env[name]===request.env[name]),unbrokered=[...new Set([...brokered.unbrokered,...vouched])];return seccomp&&extraFds.push(openSync2(seccomp,"r")),{command:this.options.bwrap,args:[...bwrapArgs(plan),
1575
1575
  "--",inner.command,...inner.args],env:brokered.env,plan,token:brokered.token,release:brokered.release,unbrokered,extraFds}}catch(error62){for(let fd of extraFds)try{closeSync2(fd)}catch{}throw brokered.release(),error62}}broker(env,plan,request){let broker=this.options.broker;if(!broker||plan.net!=="isolated")return{env,token:null,release:()=>{},unbrokered:[]};let ids=request.cwd?taskWorkspaceIds(request.cwd,this.options.setup.dataDir):null,threadId=request.botThreads?null:ids?.threadId??null,minted=broker.
1576
1576
  mintForProcess({botId:plan.botId,threadId,grants:{}}),rewrite=brokerRewrite(env,minted.token,broker.port);if(broker.revoke(minted.token),!Object.keys(rewrite.grants).length)return{env,token:null,release:()=>{},unbrokered:rewrite.unbrokered};let granted=broker.mintForProcess({botId:plan.botId,threadId,grants:rewrite.grants}),again=brokerRewrite(env,granted.token,broker.port);return{env:again.env,token:granted.token,release:()=>broker.revoke(granted.token),unbrokered:again.unbrokered}}};function writeSeccompFile(dir){
1577
- if(!seccompSupported())return null;let file2=join10(dir,"seccomp.bpf");return writeFileSync(file2,seccompBytes(),{mode:384}),file2}function flyApiPrivate(stat2=statSync4){try{return(stat2("/.fly").mode&63)===0}catch{return!0}}function defaultCodeRoots(){let roots=[dirname4(SERVER_ROOT)],node2=dirname4(dirname4(process.execPath));return roots.some(root=>node2.startsWith(root))||roots.push(node2),roots}var BotBox=class{detection={box:"off",reason:"not-cloud",tools:null};runner=null;egress=null;harness=null;credentials=null;seccompFile=null;checks=null;boxed=0;unbrokered=new Set;started=null;async start(options){
1577
+ if(!seccompSupported())return null;let file2=join10(dir,"seccomp.bpf");return writeFileSync(file2,seccompBytes(),{mode:384}),file2}function flyApiPrivate(stat2=statSync4){try{return(stat2("/.fly").mode&63)===0}catch{return!0}}function defaultCodeRoots(){let roots=[dirname5(SERVER_ROOT)],node2=dirname5(dirname5(process.execPath));return roots.some(root=>node2.startsWith(root))||roots.push(node2),roots}var BotBox=class{detection={box:"off",reason:"not-cloud",tools:null};runner=null;egress=null;harness=null;credentials=null;seccompFile=null;checks=null;boxed=0;unbrokered=new Set;started=null;async start(options){
1578
1578
  this.started=options;let env=options.env??process.env;this.detection=(options.detect??(e=>detectBox({env:e})))(env);let log=options.log??(line=>console.log(line));if(this.detection.box!=="bwrap"||!this.detection.tools)return log(`bot box: off (${this.detection.reason})`),this.detection;let dir=join10(options.dataDir,"box");mkdirSync2(dir,{recursive:!0,mode:448});let egressSocket=join10(dir,"egress.sock"),harnessSocket=join10(dir,"harness.sock"),brokerSocket=join10(dir,"broker.sock");for(let socket of[
1579
1579
  egressSocket,harnessSocket,brokerSocket])rmSync2(socket,{force:!0});this.egress=await openBoxEgressGate({socketPath:egressSocket}),this.harness=await openHarnessGate({socketPath:harnessSocket,port:options.port}),this.credentials=await openCredentialBroker({socketPath:brokerSocket}),this.seccompFile=writeSeccompFile(dir);let bridges=[{name:"egress",port:BOX_EGRESS_PORT,socket:egressSocket},{name:"harness",port:options.port,socket:harnessSocket},{name:"broker",port:BOX_BROKER_PORT,socket:brokerSocket}];
1580
1580
  return this.runner=new BoxRunner({bwrap:this.detection.tools.bwrap,bridge:{socat:this.detection.tools.socat,bridgeScript:BOX_BRIDGE_SCRIPT,node:process.execPath},setup:{dataDir:options.dataDir,home:options.home,codeRoots:options.codeRoots??defaultCodeRoots(),engineRoots:options.engineRoots??engineInstallRoots(options.dataDir),bridges},denyEnv:options.denyEnv,seccompFile:this.seccompFile,broker:{port:BOX_BROKER_PORT,mintForProcess:this.credentials.mintForProcess,revoke:this.credentials.revoke}}),
@@ -1588,16 +1588,16 @@ dataDir);try{return readdirSync3(root).filter(name=>HOME_KEY.test(name)).map(nam
1588
1588
  rok",shared:["auth.json","config.toml"]},{env:"KIMI_CODE_HOME",home:".kimi-code",shared:["credentials/kimi-code.json",KIMI_AI_SIGN_IN,"config.toml"]},{env:"DSH_HOME",home:".dsh",shared:[".credentials.yaml",".env"]},{env:"FACTORY_HOME_OVERRIDE",home:"",shared:[".factory/auth.v2.file",".factory/auth.v2.keyring",".factory/settings.json"]},{env:"XDG_CONFIG_HOME",home:".config",shared:["muse/auth.json"]},{env:"XDG_DATA_HOME",home:".local/share",shared:["opencode/auth.json"]},{home:".gemini",shared:["\
1589
1589
  oauth_creds.json","google_accounts.json","settings.json"]},{home:".pi/agent",shared:["auth.json"]}],OTHER_FOLDER_ENV=["HERMES_HOME","OPENCODE_HOME","XDG_STATE_HOME","XDG_CACHE_HOME"],short=text=>createHash3("sha256").update(text).digest("hex").slice(0,12);function homedSpawn(env,input2){let dataDir=resolve6(input2.dataDir),home2=resolve6(input2.home),given=env.HOME&&isAbsolute3(env.HOME)?resolve6(env.HOME):null,realHome=given&&!under(given,engineHomesRoot(dataDir))?given:resolve6(input2.serverHome),
1590
1590
  out={...env,HOME:home2},folders=[],moved=(variable,value)=>{let path=resolve6(value);return under(path,home2)?path:under(path,realHome)&&!under(path,dataDir)?join11(home2,relative2(realHome,path)):join11(home2,MOVED_FOLDERS,`${variable}-${short(path)}`)},variables=[...new Set([...ENGINE_FOLDERS.flatMap(folder=>folder.env?[folder.env]:[]),...OTHER_FOLDER_ENV])];for(let variable of variables){let value=env[variable];!value||!isAbsolute3(value)||(out[variable]=moved(variable,value),folders.push(out[variable]))}
1591
- let shared=[];for(let folder of ENGINE_FOLDERS){let named=folder.env?env[folder.env]:void 0,set2=named!==void 0&&isAbsolute3(named),source=set2?resolve6(named):join11(realHome,folder.home),target=set2?out[folder.env]:join11(home2,folder.home);if(!under(source,engineHomesRoot(dataDir)))for(let file2 of folder.shared){let entry={source:join11(source,file2),target:join11(target,file2)};shared.some(known=>known.target===entry.target)||shared.push(entry)}}return{env:out,home:home2,folders,shared}}import{cpSync,existsSync as existsSync7,lstatSync,mkdirSync as mkdirSync3,readdirSync as readdirSync4,renameSync as renameSync2,rmSync as rmSync3,writeFileSync as writeFileSync2}from"node:fs";import{basename as basename3,dirname as dirname5,isAbsolute as isAbsolute4,join as join12,relative as relative3}from"node:path";var MARKER=".migrated",DAY_MS=864e5,SESSION_ID=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;function claudeProjectSlug(cwd){return cwd.replace(/[^a-zA-Z0-9]/g,"-")}var ENGINE_STATE=[{variable:"CLAUDE_CONFIG_DIR",home:".claude",sessions:["projects","file-history","session-env","todos","debug"],private:["history.jsonl","shell-snapshots","plans","paste-cache"]},{variable:"CODEX_HOME",home:".codex",sessions:["sessions","archived_sessions"],private:["history.jsonl","log","shell_sna\
1592
- pshots"]}];function moveEntry(from,to){mkdirSync3(dirname5(to),{recursive:!0,mode:448});try{renameSync2(from,to)}catch(error62){if(error62.code!=="EXDEV")throw error62;cpSync(from,to,{recursive:!0,preserveTimestamps:!0}),rmSync3(from,{recursive:!0,force:!0})}}function entries(dir){try{return readdirSync4(dir)}catch{return[]}}function walk2(dir,depth=0){if(depth>6)return[];let found=[];for(let name of entries(dir)){let path=join12(dir,name),stats;try{stats=lstatSync(path)}catch{continue}stats.isDirectory()?
1591
+ let shared=[];for(let folder of ENGINE_FOLDERS){let named=folder.env?env[folder.env]:void 0,set2=named!==void 0&&isAbsolute3(named),source=set2?resolve6(named):join11(realHome,folder.home),target=set2?out[folder.env]:join11(home2,folder.home);if(!under(source,engineHomesRoot(dataDir)))for(let file2 of folder.shared){let entry={source:join11(source,file2),target:join11(target,file2)};shared.some(known=>known.target===entry.target)||shared.push(entry)}}return{env:out,home:home2,folders,shared}}import{cpSync,existsSync as existsSync7,lstatSync,mkdirSync as mkdirSync3,readdirSync as readdirSync4,renameSync as renameSync2,rmSync as rmSync3,writeFileSync as writeFileSync2}from"node:fs";import{basename as basename4,dirname as dirname6,isAbsolute as isAbsolute4,join as join12,relative as relative3}from"node:path";var MARKER=".migrated",DAY_MS=864e5,SESSION_ID=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;function claudeProjectSlug(cwd){return cwd.replace(/[^a-zA-Z0-9]/g,"-")}var ENGINE_STATE=[{variable:"CLAUDE_CONFIG_DIR",home:".claude",sessions:["projects","file-history","session-env","todos","debug"],private:["history.jsonl","shell-snapshots","plans","paste-cache"]},{variable:"CODEX_HOME",home:".codex",sessions:["sessions","archived_sessions"],private:["history.jsonl","log","shell_sna\
1592
+ pshots"]}];function moveEntry(from,to){mkdirSync3(dirname6(to),{recursive:!0,mode:448});try{renameSync2(from,to)}catch(error62){if(error62.code!=="EXDEV")throw error62;cpSync(from,to,{recursive:!0,preserveTimestamps:!0}),rmSync3(from,{recursive:!0,force:!0})}}function entries(dir){try{return readdirSync4(dir)}catch{return[]}}function walk2(dir,depth=0){if(depth>6)return[];let found=[];for(let name of entries(dir)){let path=join12(dir,name),stats;try{stats=lstatSync(path)}catch{continue}stats.isDirectory()?
1593
1593
  found.push(...walk2(path,depth+1)):found.push(path)}return found}function sweepHeld(dataDir,now=Date.now()){let held=join12(engineHomesRoot(dataDir),HELD_DIR),swept=0;for(let name of entries(held)){let at=Number(name);!Number.isSafeInteger(at)||now-at<HELD_DAYS*DAY_MS||(rmSync3(join12(held,name),{recursive:!0,force:!0}),swept++)}return swept}function migrateEngineHomes(input2){let now=input2.now??Date.now(),root=engineHomesRoot(input2.dataDir),swept=sweepHeld(input2.dataDir,now);if(existsSync7(join12(
1594
1594
  root,MARKER)))return{ran:!1,moved:0,held:0,swept};mkdirSync3(root,{recursive:!0,mode:448});let bySession=new Map,bySlug=new Map;for(let thread of input2.threads()){for(let cursor of thread.cursors)typeof cursor=="string"&&cursor&&bySession.set(cursor.toLowerCase(),thread.threadId);if(thread.cwd){let slug=claudeProjectSlug(thread.cwd);bySlug.set(slug,bySlug.has(slug)&&bySlug.get(slug)!==thread.threadId?null:thread.threadId)}}let heldRoot=join12(root,HELD_DIR,String(now)),moved=0,held=0,hold=(from,serverFolder,home2)=>{
1595
1595
  moveEntry(from,join12(heldRoot,home2,relative3(serverFolder,from))),held++};for(let engine of ENGINE_STATE){let named=input2.env[engine.variable],serverFolder=named&&isAbsolute4(named)?named:join12(input2.serverHome,engine.home),folderIn=audience=>{let home2=audienceHome(input2.dataDir,audience);return homedSpawn(input2.env,{dataDir:input2.dataDir,serverHome:input2.serverHome,home:home2}).env[engine.variable]??join12(home2,engine.home)},place=(from,threadId)=>{if(!threadId)return hold(from,serverFolder,
1596
1596
  engine.home);let to=join12(folderIn(input2.audienceOf(threadId)),relative3(serverFolder,from));if(existsSync7(to))return hold(from,serverFolder,engine.home);moveEntry(from,to),moved++};for(let sessions of engine.sessions){let dir=join12(serverFolder,sessions);if(sessions==="projects")for(let slug of entries(dir)){let project=join12(dir,slug);for(let name of entries(project)){let id=SESSION_ID.exec(name)?.[0]?.toLowerCase();place(join12(project,name),(id&&bySession.get(id))??bySlug.get(slug)??void 0)}
1597
- entries(project).length||rmSync3(project,{recursive:!0,force:!0})}else if(engine.variable==="CODEX_HOME")for(let file2 of walk2(dir)){let id=SESSION_ID.exec(basename3(file2))?.[0]?.toLowerCase();place(file2,id?bySession.get(id):void 0)}else for(let name of entries(dir)){let id=SESSION_ID.exec(name)?.[0]?.toLowerCase();place(join12(dir,name),id?bySession.get(id):void 0)}}for(let name of engine.private){let path=join12(serverFolder,name);existsSync7(path)&&hold(path,serverFolder,engine.home)}}return writeFileSync2(
1597
+ entries(project).length||rmSync3(project,{recursive:!0,force:!0})}else if(engine.variable==="CODEX_HOME")for(let file2 of walk2(dir)){let id=SESSION_ID.exec(basename4(file2))?.[0]?.toLowerCase();place(file2,id?bySession.get(id):void 0)}else for(let name of entries(dir)){let id=SESSION_ID.exec(name)?.[0]?.toLowerCase();place(join12(dir,name),id?bySession.get(id):void 0)}}for(let name of engine.private){let path=join12(serverFolder,name);existsSync7(path)&&hold(path,serverFolder,engine.home)}}return writeFileSync2(
1598
1598
  join12(root,MARKER),`${JSON.stringify({at:now,moved,held})}
1599
- `,{mode:384}),{ran:!0,moved,held,swept}}import{closeSync as closeSync3,fstatSync,ftruncateSync,lstatSync as lstatSync2,mkdirSync as mkdirSync4,openSync as openSync3,readFileSync as readFileSync5,renameSync as renameSync3,rmSync as rmSync4,statSync as statSync5,utimesSync,writeFileSync as writeFileSync3}from"node:fs";import{basename as basename4,dirname as dirname6,join as join13}from"node:path";var SETTLED_MS2=2e3,stat=(path,follow)=>{try{return follow?statSync5(path):lstatSync2(path)}catch{return null}},whole=(path,bytes)=>{if(!path.
1600
- endsWith(".json"))return bytes.length>0;try{return JSON.parse(bytes.toString("utf8")),!0}catch{return!1}};function copyInto(target,bytes,from){mkdirSync4(dirname6(target),{recursive:!0,mode:448});let temporary=join13(dirname6(target),`.${basename4(target)}.${process.pid}.omb`);writeFileSync3(temporary,bytes,{mode:384}),utimesSync(temporary,from.atime,from.mtime),renameSync3(temporary,target)}function writeInPlace(source,bytes,from){let fd=openSync3(source,"r+");try{if(!fstatSync(fd).isFile())return;
1599
+ `,{mode:384}),{ran:!0,moved,held,swept}}import{closeSync as closeSync3,fstatSync,ftruncateSync,lstatSync as lstatSync2,mkdirSync as mkdirSync4,openSync as openSync3,readFileSync as readFileSync5,renameSync as renameSync3,rmSync as rmSync4,statSync as statSync5,utimesSync,writeFileSync as writeFileSync3}from"node:fs";import{basename as basename5,dirname as dirname7,join as join13}from"node:path";var SETTLED_MS2=2e3,stat=(path,follow)=>{try{return follow?statSync5(path):lstatSync2(path)}catch{return null}},whole=(path,bytes)=>{if(!path.
1600
+ endsWith(".json"))return bytes.length>0;try{return JSON.parse(bytes.toString("utf8")),!0}catch{return!1}};function copyInto(target,bytes,from){mkdirSync4(dirname7(target),{recursive:!0,mode:448});let temporary=join13(dirname7(target),`.${basename5(target)}.${process.pid}.omb`);writeFileSync3(temporary,bytes,{mode:384}),utimesSync(temporary,from.atime,from.mtime),renameSync3(temporary,target)}function writeInPlace(source,bytes,from){let fd=openSync3(source,"r+");try{if(!fstatSync(fd).isFile())return;
1601
1601
  writeFileSync3(fd,bytes),ftruncateSync(fd,bytes.length)}finally{closeSync3(fd)}utimesSync(source,from.atime,from.mtime)}function newerCopy(path,team,now){let copy=stat(path,!1);if(!copy?.isFile()||Math.floor(copy.mtimeMs)<=Math.floor(team.mtimeMs)||now-copy.mtimeMs<SETTLED_MS2)return null;let bytes=readFileSync5(path);return whole(path,bytes)?{bytes,stats:copy}:null}function syncSignIn(file2,peers=[],now=Date.now()){let team=stat(file2.source,!0),copy=stat(file2.target,!1);if(copy&&!copy.isFile()&&
1602
1602
  (rmSync4(file2.target,{recursive:!0,force:!0}),copy=null),!team?.isFile())return copy?(rmSync4(file2.target,{force:!0}),"removed"):"same";let taken="same",newest=[file2.target,...peers].map(path=>newerCopy(path,team,now)).filter(found=>found!==null).sort((a,b2)=>b2.stats.mtimeMs-a.stats.mtimeMs)[0];newest&&(writeInPlace(file2.source,newest.bytes,newest.stats),team=stat(file2.source,!0),taken="taken back");let at=stats=>Math.floor(stats.mtimeMs);if(copy&&at(copy)>at(team)&&now-copy.mtimeMs<SETTLED_MS2)
1603
1603
  return taken;let bytes=readFileSync5(file2.source);return copy&&at(copy)===at(team)&&copy.size===team.size&&readFileSync5(file2.target).equals(bytes)?taken:(copyInto(file2.target,bytes,team),taken==="same"?"copied":taken)}function syncSignIns(files,peers=()=>[],now=Date.now()){for(let file2 of files)try{syncSignIn(file2,peers(file2.target),now)}catch{}}var EngineHomes=class{#setup=null;#migration=null;#thread=new AsyncLocalStorage2;start(setup){this.#setup={...setup,serverHome:setup.serverHome??homedir3()},this.#migration=null}stop(){this.#setup=null}active(){return this.#setup!==null}within(threadId,start){return this.#setup?this.#thread.run(threadId,start):start()}scope(){let threadId=this.#setup?this.#thread.getStore():void 0;return threadId===void 0?null:audienceHomeKey(this.#setup.audienceOf(threadId))}migrate(){let setup=this.#setup;if(!setup)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limixbot",
3
- "version": "0.3.48",
3
+ "version": "0.3.49",
4
4
  "description": "Run the Limix Bot server anywhere and pair your devices to it (Leox ৹ Limix AI)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,16 +0,0 @@
1
- import{c as Ee,t as s,b as te,av as Ds,j as e,i as Te,a9 as he,a as E,r as x,S as Je,ac as Kt,X as Qe,f as lt}from"./styles-CxbuKpLq.js";import{fg as $s,fh as Fs,a2 as Xe,by as zs,di as Ut,w as Hs,fi as _s,fj as Ks,K as qt,fk as Us,R as Wt,eu as qs,x as Ws,fl as ot,bt as ct,fm as Vt,n as ae,u as D,fn as Vs,ah as Ze,F as Yt,A as Gt,S as dt,ad as Re,T as Jt,W as Ys,fo as Gs,fp as Js,fq as Qs,fr as Xs,fs as Zs,ft as mt,fu as ea,fv as ta,fw as sa,fx as aa,b9 as na,fy as ra,fz as ia,fA as la,I as oa,fB as Ne,bP as et,fC as ca,aI as A,aO as Z,ed as da,dK as ma,fD as pa,aJ as Ue,cp as ua,dZ as xa,d_ as ha,fE as fa,fF as Qt,fG as Xt,fH as ga,fI as ya,fJ as ba,fK as va,dN as qe,ar as pt,fL as Me,fM as ka,fN as Ce,av as ja,fO as Zt,fP as ut,ak as We,fQ as wa,fR as Na,fS as Sa,fT as es,fU as Ca,fV as Pa,fW as Oa,fX as Ea,fY as X,aX as se,aZ as Q,fZ as Ra,f_ as Ia,f$ as La,d5 as Aa,d as Ta,G as Ma,d3 as ts,aj as Ba,g0 as V,aW as de,g1 as me,bB as M,g2 as Da,dp as $a,g3 as Ie,aY as ie,g4 as Fa,g5 as za,g6 as Ha,eh as _a,g7 as xt,g8 as Ka,g9 as Ua,ga as qa,gb as Wa,gc as Va,gd as Ya,aC as Ga,ge as ss,gf as Ja,gg as Qa,gh as Xa,gi as Za,gj as en,gk as tn,gl as sn,gm as an,gn as nn,go as rn,gp as ln,gq as on,gr as tt,k as cn,B as Ve,gs as dn,gt as mn,gu as pn,gv as un,bY as xn,gw as as,J as ht,eY as hn,gx as ft,gy as fn,gz as gn,cM as gt,bw as yn,d2 as bn,gA as vn,gB as ns,gC as je,gD as yt,gE as kn,aM as Be,d$ as jn,gF as wn,aR as Nn,C as Sn,cq as Cn,gG as Pn,gH as On,gI as En,aT as Rn}from"./App-ChCSOxIp.js";import{z as rs,d as be,a1 as Pe,a2 as In,a3 as Ln,a4 as bt,a5 as De,a6 as An,a7 as Tn,a8 as Mn,a9 as Bn,aa as Dn,ab as vt,ac as $n,ad as Fn,L as Se,N as zn,B as Ye,P as ve,r as is,ae as Hn,a0 as _n,u as ls}from"./PlacesRail-CIHIyPoQ.js";import{C as Kn}from"./coins-C5bat6u2.js";import{C as ye,a as Un}from"./MenuMotion-BNVn5GSt.js";import{b as ee,m as os,i as Ge,f as st,c as xe,d as kt,e as Oe,o as qn,g as Wn,h as ce,n as $e,t as cs,s as at,j as ds,k as Vn,l as Yn,p as Gn,r as ms,q as Jn,u as Qn,w as Xn,x as ps,y as us,z as jt,B as Zn,C as xs,R as wt,D as er,E as tr,F as sr,G as ar,H as nr,J as rr,O as ir,K as lr,L as hs,N as Nt,V as or,P as cr,M as dr,A as mr,a as pr,S as ur,I as xr}from"./VisibilitySection-CLj2_C44.js";import{s as hr,r as fr,a as gr,R as yr}from"./ComputerFilesPane-Cgj-gSm4.js";import{M as St}from"./monitor-ET_fUXyt.js";import{a as fs,m as gs,b as br,c as vr}from"./mcp-servers-CkHO2yG6.js";import{R as kr}from"./RoutinesPage-D3s9tF-X.js";import{S as jr}from"./SignedInSites-BGTefeLy.js";import"./index-up1CA0zX.js";import"./org-library-D_E7GVek.js";import"./package-format-B5SXvrHy.js";import"./WorksOnGrid-BQiI1n3L.js";import"./ProIntroduction-C1ZjYkae.js";import"./remote-desktop-DDRRx8uY.js";const wr=[["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"}]],Nr=Ee("calendar-plus",wr);const Sr=[["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"}]],Cr=Ee("library",Sr);const Pr=[["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"}]],ys=Ee("slack",Pr);const Or=[["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"}]],Er=Ee("tag",Or),Rr=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:$s,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:Fs,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ys,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:Xe,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:zs,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Ut,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Cr,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Hs,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:_s,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:Ks,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:qt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Us,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Wt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:qs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Kn,keywords:["tokens","cost","billing"]}],Ct={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 Ir(t,a=te()){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(Ct,n.status))return null;try{return[s("botOverview.routine.line",{schedule:Ws(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:ot(t.nextRunAt)})]:[],...n?[s(Ct[n.status],{time:ot(n.at)})]:[]].join(" ")}catch{return null}}const Pt={"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"},Ot={"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 Et(t,a){return!a||a.map(n=>n||"General").join(", ")!==t?t:a.map(n=>n||s("botAccess.teams.general")).join(", ")}const Rt=t=>Object.hasOwn(Ot,t)?s(Ot[t]):t,It=(t,a,n)=>Number(t)===1?a:n,Lr=[{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:Et(t,a)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>It(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])=>It(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:Et(t,a)})}],Ar=t=>te()!=="en"&&Object.hasOwn(Ds[te()]??{},t);function Tr(t,a){for(const n of Lr){const i=n.line.exec(t);if(!i)continue;const r=n.key(i);return Ar(r)?s(r,n.params(i,a)):t}return null}function Fe(t,a){if(Object.hasOwn(Pt,t))return s(Pt[t]);const n=Tr(t,a);if(n!==null)return n;const i=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(i)return s(i[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(i[1]),apps:i[2]});const r=te()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(r)return s("botOverview.line.computerNotOnCloud",{preference:Rt(r[1])});const l=/^Computer preference: (.+)\.$/.exec(t);if(l)return s("botOverview.line.computer",{preference:Rt(l[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 Lt={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 Mr(t,a=te()){const n=/^(\w+): /.exec(t)?.[1];return a==="en"||!n||!Object.hasOwn(Lt,n)?t:`${s(Lt[n])}: ${t.slice(n.length+2)}`}function Br({data:t,error:a,open:n,onToggle:i}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:i,"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(Te()),tokens:t.approxTokens.toLocaleString(Te())}):s("botOverview.promptPreview")}),e.jsx(he,{size:16,className:E("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(Te())})})]}),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 Dr({overview:t,refreshError:a,prompt:n,promptError:i,onOpen:r,onSetup:l}){const[c,d]=x.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const p=(t.setup??[]).filter(f=>!f.done),m=(f,k)=>s(`botOverview.setup.${f}`)||k;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")}),p.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:p.map(f=>e.jsx("li",{children:f.section?e.jsxs("button",{type:"button",onClick:()=>r(f.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(ct,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:m(f.id,f.label)}),e.jsx(ye,{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(ct,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:m(f.id,f.label)})]})},f.id))}),l&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:l,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(Xe,{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((f,k)=>e.jsx("li",{children:Ir(t.doesRoutines?.[k])??Fe(f)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((f,k)=>e.jsx("li",{children:Fe(f,t.managedSections)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((f,k)=>e.jsx("li",{children:Fe(f,t.managedSections)},k))})]}),e.jsx(Br,{data:n,error:i,open:c,onToggle:()=>d(f=>!f)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>r("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ye,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((f,k)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Mr(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Vt(f.at)]})]},k))})]})]})}function $r({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(rs,{size:14,"aria-hidden":"true"})]})]})}function Fr(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 bs(t){const[a,n]=x.useState(null);return x.useEffect(()=>{const i=new AbortController;return ae(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:i.signal,timeoutMs:1e4}).then(r=>{i.signal.aborted||n({botId:t,url:Fr(r)})}).catch(()=>{i.signal.aborted||n({botId:t,url:null})}),()=>i.abort()},[t]),a?.botId===t?a.url:null}const re="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",ze="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ne=t=>t instanceof Error?t.message:String(t);function vs(t){const a=[],n=(r,l,c)=>{r&&a.push(s(r===1?l: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 i=a.length?a.join(", "):s("memory.upkeep.summary.none");return i.charAt(0).toUpperCase()+i.slice(1)}function zr(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"),i=Jn(t.path),r=t.path===ee?i:t.path===Qn?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:i}):s("memory.journal.topic",{file:i}),l=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:l(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:n,topic:r}):t.added&&!t.removed?s("memory.journal.added",{who:n,lines:l(t.added),topic:r}):t.removed&&!t.added?s("memory.journal.removed",{who:n,lines:l(t.removed),topic:r}):s("memory.journal.rewrote",{who:n,lines:l(Math.max(t.added,t.removed)),topic:r})}function ks({changed:t,stale:a,busy:n,onReviewed:i}){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:E(re,"mt-3"),disabled:n,onClick:i,children:s("memory.lendingReviewed")})]})}function Hr({bot:t,active:a=!0,onToggle:n}){const{capabilities:i}=be(),[r,l]=x.useState(null),[c,d]=x.useState(null),[o,p]=x.useState(null),[m,f]=x.useState(null),[k,g]=x.useState(null),[v,j]=x.useState(null),[P,b]=x.useState(null),[w,u]=x.useState(!1),[S,T]=x.useState(null),[F,B]=x.useState(""),[I,H]=x.useState(null),[L,h]=x.useState(!1),[R,$]=x.useState(null),[_,K]=x.useState(!1),[J,G]=x.useState(!1),{state:U,dispatch:y}=D(),z=Vs(U.config),[le,pe]=x.useState(!1),[fe,C]=x.useState(""),q=async N=>{const[O,Le,Bs]=await Promise.all([st(t.id),xe(t.id),kt(t.id).catch(()=>null)]);if(l(O),$(O.lendingReview??null),d(Le),H(Bs),N){const Ae=await Oe(t.id,N);p({path:Ae.path,text:Ae.text,hash:Ae.hash,dirty:!1,readOnly:N.startsWith("memory/log/")})}};x.useEffect(()=>{if(!a)return;let N=!1;j(null);const O=o?.dirty===!0;return q(O?void 0:o?.path??ee).catch(Le=>{N||j(ne(Le))}),()=>{N=!0}},[a,t.id]);const Y=async N=>{j(null),f(null);try{const O=await Oe(t.id,N);p({path:O.path,text:O.text,hash:O.hash,dirty:!1,readOnly:N.startsWith("memory/log/")})}catch(O){j(ne(O))}},W=async N=>{if(o){u(!0),j(null);try{const O=await at(t.id,o.path,o.text,N);if(!O.ok){f({path:o.path,current:O.current,currentHash:O.currentHash});return}f(null),g(null),p({...o,text:O.doc.text,hash:O.doc.hash,dirty:!1}),l(O.overview),d(await xe(t.id))}catch(O){j(ne(O))}finally{u(!1)}}},oe=()=>{!m||!o||(g(o.text),p({...o,text:m.current,hash:m.currentHash,dirty:!1}),f(null))},ke=async N=>{if(window.confirm(s("memory.confirmDelete",{name:N.name}))){j(null);try{const{overview:O}=await ds(t.id,N.path);l(O),d(await xe(t.id)),o?.path===N.path&&p(null)}catch(O){j(ne(O))}}},rt=async()=>{const N=Vn(F);if(!N){j(s("memory.topicNameError"));return}B(""),await Y(`memory/${N}`),p(O=>O&&{...O,dirty:!0,text:O.text||_r(N)})},Is=async N=>{T(N.id),j(null);try{const O=await ms(t.id,N.id);l(O.overview),d(await xe(t.id)),o?.path===N.path&&!o.dirty&&p({...o,text:O.text,hash:O.hash}),b(s("memory.restored",{path:N.path}))}catch(O){j(ne(O))}finally{T(null)}},it=async N=>{j(null),b(null);try{await qn(t.id,N)}catch(O){j(ne(O))}},Ls=()=>{const N=t.memoryUpkeep===!1;y({type:"updateBot",botId:t.id,patch:{memoryUpkeep:N}}),H(O=>O&&{...O,enabled:N})},As=async()=>{if(!le){pe(!0),C("");try{const N=await ae("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!z}})});y({type:"configStatus",config:N})}catch(N){C(N instanceof Error?N.message:s("memory.learnFromRooms.error"))}finally{pe(!1)}}},Ts=async()=>{h(!0),j(null),b(null);try{const{report:N,overview:O}=await cs(t.id);l(O),d(await xe(t.id)),H(await kt(t.id)),o&&!o.dirty&&await Y(o.path),b(`${vs(N)}.${N.note?` ${N.note}`:""}`)}catch(N){j(ne(N))}finally{h(!1)}},Ms=i.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:N=>n(N.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:Ze(r.workspacePath,Ms)}),e.jsx("button",{type:"button",className:re,onClick:()=>{it("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:E(re,"inline-flex items-center gap-1.5"),onClick:()=>{it("folder")},children:[e.jsx(Yt,{size:14}),s("memory.showFileManager")]})]})]}),R&&e.jsx(ks,{changed:R.changed,stale:_,busy:J,onReviewed:()=>{G(!0),os(t.id,R.token).then(()=>{$(null),K(!1)}).catch(N=>{if(N instanceof Gt&&N.status===409)return K(!0),q();j(ne(N))}).finally(()=>G(!1))}}),r&&e.jsx(Ur,{index:r.index}),t.memoryEnabled!==!1&&e.jsx(Kr,{enabled:t.memoryUpkeep!==!1,status:I,tidying:L,onToggle:Ls,onTidy:()=>{Ts()},rooms:{enabled:z,saving:le,error:fe,onToggle:()=>{As()}}}),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!==ee&&e.jsx("button",{type:"button",className:ze,onClick:()=>{Y(ee)},children:s("memory.backToIndex")})]}),m&&e.jsx(js,{botName:t.name,busy:w,onReload:oe,onOverwrite:()=>{W(m.currentHash)}}),e.jsx("textarea",{className:E(Ge,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:o.text,readOnly:o.readOnly,placeholder:o.path===ee?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":o.path===ee?s("memory.botMemory"):s("memory.fileLabel",{path:o.path}),onChange:N=>p({...o,text:N.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:()=>{W(o.hash)},disabled:w||!o.dirty,className:re,children:w?s("memory.saving"):s("memory.save")}),o.dirty&&e.jsx("button",{type:"button",className:ze,disabled:w,onClick:()=>{Y(o.path)},children:s("memory.discard")})]}),k!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:k}),e.jsx("button",{type:"button",className:E(ze,"mt-1"),onClick:()=>g(null),children:s("memory.dismissDraft")})]})]}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Tt,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:r.topics,selected:o?.path,onOpen:N=>{Y(N.path)},onDelete:N=>{ke(N)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:E(Ge,"py-1.5 text-[13px]"),value:F,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:N=>B(N.target.value),onKeyDown:N=>{N.key==="Enter"&&rt()}}),e.jsx("button",{type:"button",className:re,disabled:!F.trim(),onClick:()=>{rt()},children:s("memory.newTopic")})]}),r.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Tt,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:r.logs,selected:o?.path,onOpen:N=>{Y(N.path)},onDelete:N=>{ke(N)}})})]}),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(nt,{rows:c,botName:t.name,reverting:S,onRevert:N=>{Is(N)}})})]}),P&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:P}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function _r(t){return`---
2
- title: ${t.replace(/\.md$/,"")}
3
- description:
4
- aliases: []
5
- ---
6
-
7
- `}function Kr({enabled:t,status:a,tidying:n,onToggle:i,onTidy:r,rooms:l}){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(dt,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:i})]}),t&&l&&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")}),l.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:l.error})]}),e.jsx(dt,{checked:l.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:l.saving,onClick:l.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:re,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:Pe(a.lastTidy.at,te()),summary:vs(a.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),a?.lastCapture&&$e(a.lastCapture)?` ${s($e(a.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:$e(a.lastCapture),time:Pe(a.lastCapture.at,te())})}`:""]})]})]})}function Ur({index:t}){const a=Wn(t),n=a.level==="over"?"bg-danger":a.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:E("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:E("text-[12px]",a.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:ce(t.bytes),maxBytes:ce(t.maxBytes)})})]}),e.jsx(At,{label:s("memory.capacity.lines"),share:a.lineShare,fill:n}),e.jsx(At,{label:s("memory.capacity.size"),share:a.byteShare,fill:n}),e.jsx("p",{className:E("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:ce(t.bytes),maxBytes:ce(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:ce(t.bytes),maxBytes:ce(t.maxBytes),maxLoaded:t.maxLines})})]})}function At({label:t,share:a,fill:n}){const i=`${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:E("h-full rounded-full",n),style:{width:i}})})]})}function js({botName:t,busy:a,onReload:n,onOverwrite:i}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:a,onClick:n,children:s("memory.reload")}),e.jsx("button",{type:"button",className:re,disabled:a,onClick:i,children:s("memory.overwrite")})]})]})}function Tt({title:t,hint:a,files:n,selected:i,onOpen:r,onDelete:l}){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:E("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",i===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(Re,{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:[ce(c.bytes)," · ",Pe(c.modifiedAt,te())]})]}),e.jsx("button",{type:"button",onClick:()=>l(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(Jt,{size:14})})]},c.path))})]})}function nt({rows:t,botName:a,reverting:n,onRevert:i,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(l=>{const c=Yn(l),d=Gn(l);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:zr(l,a)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Pe(l.at,te(),r)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:d?s(d,l.threadTitle?{title:l.threadTitle}:void 0):c})]})]}),l.canRevert?e.jsxs("button",{type:"button",disabled:n!==null,onClick:()=>i(l),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(Ys,{size:12}),n===l.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:l.revertUnavailableReason,children:s("memory.cantUndo")})]}),l.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",l.added," −",l.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:l.diff})]})]},l.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function qr({bot:t,rows:a,refreshError:n,onRollback:i,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 l=[...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")}),l.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:Vt(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:()=>i(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 Wr({bot:t,bare:a=!1}){const{state:n,dispatch:i}=D(),r=Gs(t),l=n.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return r.turns===0?e.jsx("div",{className:E(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:()=>i({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ye,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:E("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:Js(r)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:Zs(r),children:Qs(Xs(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:mt(r.costUsd)?ea(r.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:mt(r.costUsd)?s("usage.costLine",{caption:ta(l?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Vr=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Yr=["circle","rounded","square"],Gr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},Jr={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"},Qr=t=>{const a=Jr[t];return a?s(a):t};function Xr({bot:t,activeState:a,onPatch:n,onClose:i}){const r=sa(t,n),{fileRef:l,crop:c,uploading:d,generating:o,busy:p,error:m,upload:f,removeImage:k,generate:g}=r,v=c!=="mascot"&&!!t.avatarUrl,[j,P]=x.useState(v?"upload":"bot"),b=x.useRef(null);x.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=h=>n(c==="mascot"?h:{...h,avatarCrop:"mascot"}),u=t.mascotBody??"cursor",S=In(),T=Ln(t.mascotBody,t.color,S),[F,B]=x.useState(()=>!!S||bt(u)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=S&&T!==u&&bt(T)?De(T):null,H=(h,R)=>e.jsx("button",{type:"button",disabled:p,"aria-pressed":!v&&u===h,"aria-label":s("mascot.useBody",{name:R}),title:R,onClick:()=>w({mascotBody:h}),className:E("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&u===h?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(zn,{color:t.color,faceColor:t.mascotFaceColor,bodyId:h,size:40,animated:!1,trackPointer:!1})},h),L=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),i())};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:b,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Vr.map(([h,R])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===h,"data-avatar-tab":h,onClick:()=>P(h),className:E("rounded-lg px-[11px] py-[5px] text-[13px]",j===h?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(R)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:p,onClick:()=>n(aa),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:An.map(h=>H(h,De(h)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:na.map(h=>e.jsx("button",{type:"button",disabled:p,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:Bn(h)}),title:s(Mn[h]),onClick:()=>w({color:h}),className:E("size-6 rounded-full disabled:opacity-50",t.color===h&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:Tn(h)}},h))}),e.jsx(Xn,{bot:t,disabled:p,onPatch:w}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":F,onClick:()=>B(h=>!h),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(he,{size:13,"aria-hidden":"true",className:E("transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[Dn.map(h=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-1 pb-1.5 pt-2 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:vt(h)}),h===S&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:vt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:$n[h].bodies.map(R=>H(R,De(R)))})]},h)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),Fn.map(h=>e.jsx("button",{type:"button",disabled:p,"data-avatar-face":h,"aria-pressed":a===h,onClick:()=>w({mascotExpression:h}),className:E("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",a===h?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:Qr(h)},h))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(ra,{botLabel:t.title||t.name,disabled:d,generating:o,onGenerate:g})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(ia,{busy:p,onUpload:h=>{f(h)}}),v&&e.jsx(la,{bot:t,disabled:p,onPatch:n}),e.jsx("input",{ref:l,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:h=>{f(h.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:p,onClick:()=>l.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),f(h.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[d?e.jsx(Se,{size:22,className:"animate-spin"}):e.jsx(oa,{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(Ne,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?c:null,onChange:h=>n({avatarCrop:h}),options:Yr.map(h=>({value:h,label:s(Gr[h]),disabled:p||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:p,"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(Jt,{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 Zr=()=>s("place.off");function ws(t){const{dispatch:a}=D();return(n="computer")=>{ma(t.id,n),a({type:"toggleSettings",open:!1}),a({type:"toggleComputer",open:!0})}}function ei(t,a){const[n,i]=x.useState(null);return x.useEffect(()=>{if(!a)return;let r=!1;return ae(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(l=>{r||i({botId:t.id,count:l.sites?.length??0})}).catch(()=>{}),()=>{r=!0}},[t.id,a]),n?.botId===t.id?n.count:null}function Ns(t){const{state:a}=D(),{capabilities:n}=be(),i=n.host?.platform??"other",r=pa(t),l=t.computer??"auto",c=a.config?.browserEngine?.myChrome===!0&&(a.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),d=g=>g==="browser"&&c?s("settings.profiles.myChrome"):ha(g,i),o=g=>{const{view:v,reachable:j}=r[g];return{value:g,label:d(g),disabled:!j,hint:!j||xa(v)?v.line:void 0}},p=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...r.local.policy?[o("local")]:[],...r.browser.policy||l==="browser"?[o("browser")]:[],...r.cloud.policy?[o("cloud")]:[],...r.vm.policy||l==="vm"?[o("vm")]:[],...l==="off"?[{value:l,label:Zr(),disabled:!0}]:[]],m=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=m&&m!==l?d(m):null,k=p.find(g=>g.value===l)?.label??(l==="auto"||l==="off"?void 0:d(l));return{options:p,current:l,currentLabel:k,usingNow:f}}function ti({bot:t,derived:a}){const{dispatch:n}=D(),{options:i,current:r,usingNow:l}=Ns(t),[c,d]=x.useState(null),{patch:o,approvalMode:p}=a,m=f=>{if(!(f===r||f==="off")){if(f==="local"&&p==="auto"){d({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}o(f==="browser"?{computer:"browser",browser:!0}:{computer:f==="auto"?null:f})}};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:i.map(f=>e.jsx(Ue,{"data-panel-choice":f.value,title:f.label,hint:f.hint,checked:r===f.value,disabled:f.disabled,onClick:()=>m(f.value)},f.value))})}),l&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:l})}),e.jsx(ua,{open:c!==null,onCancel:()=>d(null),onConfirm:()=>{const f=c;d(null),f&&n({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function si({bot:t,derived:a,onOpen:n}){const i=ws(t),r=et(),{browserEnabled:l}=a,c=ei(t,l&&t.computer!=="off"&&r!==!1),{currentLabel:d,usingNow:o}=Ns(t),p=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),f=m?ca({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")}: ${p}`,onClick:()=>i(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[f?e.jsx("img",{src:f,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(Ye,{bot:t,size:52,animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] text-ink-secondary",children:s("botPanel.screen.working")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-60",children:e.jsx(Ye,{bot:t,size:44,state:"sleeping",animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] font-medium text-ink",children:s("botPanel.screen.resting")})]}),e.jsxs("span",{"aria-hidden":"true",className:"absolute bottom-2.5 right-2.5 flex h-7 items-center gap-1.5 rounded-full border border-ink/10 bg-panel/80 px-2.5 text-[12px] text-ink opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100",children:[e.jsx(St,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:p}),e.jsxs(A,{anchor:"where",children:[e.jsx(Z,{"data-panel-page":"where",icon:St,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(Z,{"data-panel-page":"browser",icon:da,title:s("settings.sites.title"),value:c??void 0,onClick:()=>n("browser")})]})]})}const ai=3,Mt="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",ni=8,ri=200,ue=new Map,He=new Set,Bt=t=>`${t.threadId}@${es(t)}`;function ii(t,a){const[,n]=x.useState(0),r=a.filter(d=>d.threadId!==t.threadId).map(Bt).filter(d=>!ue.has(d)&&!He.has(d)).join(",");x.useEffect(()=>{if(r)for(const d of r.split(",")){He.add(d);const o=d.slice(0,d.lastIndexOf("@"));ae(`/api/threads/${encodeURIComponent(o)}/messages?limit=${ni}`,{background:!0}).then(p=>{ue.set(d,We({messages:p.messages??[],activeLeafId:p.activeLeafId??void 0})),ue.size>ri&&ue.delete(ue.keys().next().value),n(m=>m+1)}).catch(()=>{}).finally(()=>He.delete(d))}},[r]);const l=We(t),c=new Map(a.map(d=>[d.threadId,Bt(d)]));return d=>d===t.threadId?l:ue.get(c.get(d)??"")}function li({bot:t}){const{state:a,dispatch:n}=D(),i=fa(),r=!Qt(Xt,!0),[l,c]=x.useState(""),[d,o]=x.useState(!1),[p,m]=x.useState(!1),[f,k]=x.useState(!1),g=ga(a.config),v=x.useMemo(()=>{const{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:pe,onPin:fe,onArchive:C}=ya(t.id,n,g);return{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:pe,onPin:fe,onArchive:C}},[t.id,n,g]),j=ba(t),P=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],b=(j?va({...t,tasks:P},j):P).filter(y=>!y.routineRunId).map(y=>{const z=qe(t,y.threadId);return{...y,busy:z.busy,activity:z.activity,waitingForTeammates:z.waitingForTeammates,turnStartedAt:z.turnStartedAt??void 0,queued:!!a.pendingQueued[y.threadId]?.length}}),w=pt(b.filter(y=>!Me(y)||y.threadId===t.threadId)),u=pt(b.filter(y=>Me(y)&&y.threadId!==t.threadId)),S=l.trim(),T=w.filter((y,z)=>z<ai||y.threadId===t.threadId),F=ii(t,[...S||p?w:T,...f?u:[]]),B=y=>{const z=F(y);return z?wa(qe(t,y),z,a.instances,!1):void 0},I=ka(w,S),H=S?[...I,...w.filter(y=>!I.includes(y)&&B(y.threadId)?.toLowerCase().includes(S.toLowerCase()))]:w,L=S?H:p?w:T,h=w.length-T.length,R=t.projects?.find(y=>y.id===t.tasks?.find(z=>z.threadId===t.threadId)?.projectId),$=()=>{r&&n({type:"toggleSettings",open:!1})},_=y=>{y.threadId!==t.threadId&&Ca(n,t,y.threadId,!1),$()},K=()=>{n({type:"newTask",botId:t.id,...R?{projectId:R.id}:{}}),$()},J=()=>{c(""),o(!1)},G=w.length>=2||d||w.some(y=>y.threadId===t.threadId&&Me(y)),U=y=>e.jsx("div",{role:"listitem","data-conversation":y.threadId,children:e.jsx(Na,{panel:!0,preview:B(y.threadId),task:y,ownerId:t.id,current:y.threadId===t.threadId,folders:t.projects,now:Sa(es(y),i),locale:te(),onSelect:_,...v})},y.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(Ce,{action:G&&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:E("-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(Je,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:E("flex items-center gap-2",G&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:K,className:E(Zt,"flex-1"),children:[e.jsx(ja,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),G&&d&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:l,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.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"}),G&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:E("flex flex-col gap-px",Mt),children:L.map(U)}),G&&S&&L.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:S})}),G&&!S&&h>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":p,onClick:()=>m(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[p?e.jsx(ut,{size:14,"aria-hidden":"true"}):e.jsx(he,{size:14,"aria-hidden":"true"}),p?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:h})]}),!S&&u.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":f,onClick:()=>k(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[f?e.jsx(ut,{size:14,"aria-hidden":"true"}):e.jsx(he,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:u.length})]}),!S&&f&&u.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:u.length}),className:E("flex flex-col gap-px",Mt),children:u.map(U)})]})}function oi({bot:t}){const{dispatch:a}=D();return Kt()||!t.defaultBot?null:e.jsx(A,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:Pa.map(i=>e.jsx("button",{type:"button","data-panel-ask":i,onClick:()=>a({type:"send",botId:t.id,text:s(i),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(i)})},i))})}const ci=["find","start-fresh","usage","activity","inspector"];function di({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:E(Q,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:E("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:E("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(ye,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function mi({bot:t,derived:a,onOpen:n}){const{items:i}=Oa(t),{dispatch:r}=D(),l=a.botRoutines.filter(d=>d.enabled).length,c=ci.flatMap(d=>i.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:E(Q,"rounded-[8px]"),children:e.jsx(Ea,{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:Xe}),e.jsx(se,{title:s("model.simple.model")})]})})})}),e.jsx(li,{bot:t}),e.jsx(oi,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Ce,{children:s("botPanel.section.conversation")}),c.map(d=>e.jsx(di,{item:d},d.key))]}),a.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(Ce,{action:e.jsx(Ra,{"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:E(Zt,"w-full"),children:[e.jsx(Nr,{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(Z,{"data-panel-page":"routines",icon:Ia,title:s("botSettings.simple.routines"),value:l>0?s("botPanel.routinesOn",{count:l}):s("botPanel.none"),onClick:()=>n("routines")})})]})}const Ss=/^\s*[-*]\s+(.+?)\s*$/;function pi(t){return t.split(`
8
- `).flatMap((a,n)=>{const i=Ss.exec(a)?.[1];return i?[{line:n,text:i}]:[]})}function ui(t,a){const n=t.split(`
9
- `);return Ss.test(n[a]??"")?(n.splice(a,1),n.join(`
10
- `)):t}function xi(t,a){const n=t.replace(/\s+$/,""),i=`- ${a.trim().replace(/\s*\n\s*/g," ")}`;return n?`${n}
11
- ${i}
12
- `:`${i}
13
- `}function Cs(t){return t.flatMap(a=>{const n=pi(a.text).map(r=>({path:a.path,...r}));if(n.length||a.path===ee)return n;const i=a.text.split(`
14
- `).map(r=>r.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return i?[{path:a.path,line:null,text:i}]:[]})}async function hi(t,a){if(!a)return[await Oe(t,ee)];const n=await st(t,!0);return Promise.all([ee,...n.topics.map(i=>i.path)].map(i=>Oe(t,i,!0)))}function Ps(t){const a=!!D().state.config?.team,[n,i]=x.useState({botId:t.id,docs:null,error:!1}),r=t.memoryEnabled!==!1,l=async(o,p)=>{try{const m=await hi(o,a);p?.()||i({botId:o,docs:m,error:!1})}catch{p?.()||i({botId:o,docs:null,error:!0})}},c=!!t.busy;x.useEffect(()=>{if(!r)return;let o=!1;return l(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=>i(p=>({botId:t.id,docs:(p.botId===t.id?p.docs??[]:[]).map(m=>m.path===o.path?o:m),error:!1})),reload:()=>l(t.id)}}function fi(t,a=We(t)){const n=[],i=[],r=new Set;for(const p of[...a].reverse()){const m=p.publishedPage;m?.state==="live"&&m.url&&!r.has(m.url)&&(r.add(m.url),n.push({messageId:p.id,title:m.title||m.url,url:m.url})),p.kind==="app"&&p.app?.doc&&i.push({messageId:p.id,title:p.app.title})}const l=hr(t),c=[],d=new Set;for(const p of l.values())d.has(p.file.path)||(d.add(p.file.path),c.push(p));const o=fr(t).filter(p=>!l.has(p));return{pages:n,apps:i,shared:c,unshared:o}}const gi=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Os({bot:t,onOpen:a}){const{dispatch:n}=D(),{capabilities:i}=be(),r=La(),l=!Qt(Xt,!0),c=ps(t),d=Ps(t),{pages:o,apps:p,shared:m,unshared:f}=x.useMemo(()=>fi(t),[t]),k=b=>{n({type:"focusMessage",threadId:t.threadId,messageId:b}),l&&n({type:"toggleSettings",open:!1})},g=c.skills.filter(us).length,v=d.docs?Cs(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}),P=e.jsxs(A,{anchor:"keeps",children:[e.jsx(Z,{"data-panel-page":"memory",icon:Ut,title:s("botPanel.memoryRow"),value:j,onClick:()=>a("memory")}),e.jsx(Z,{"data-panel-page":"skills",icon:Aa,title:s("botSettings.simple.skills"),value:c.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>a("skills")}),e.jsx(Z,{"data-panel-page":"folder",icon:Ta,title:s("computer.files.folder"),value:t.cwd?Ze(t.cwd,i.host?.homeDir):s("botPanel.folder.private"),onClick:()=>a("folder")})]});return o.length+p.length+m.length+f.length===0?e.jsxs("div",{"data-panel-tabpanel":"library",children:[e.jsx("p",{"data-panel-empty":"library",className:"px-3 py-7 text-center text-[13px] leading-[18px] text-ink-tertiary",children:s("botPanel.library.empty")}),P]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[o.length>0&&e.jsx(A,{label:s("botPanel.library.pages"),anchor:"pages",children:o.map(b=>e.jsx(Z,{"data-panel-row":"page",icon:Ma,title:e.jsx("span",{className:"block truncate",children:b.title}),hint:e.jsx("span",{className:"block truncate",children:b.url}),onClick:()=>r(b.url)},b.url))}),p.length>0&&e.jsx(A,{label:s("botPanel.library.apps"),anchor:"apps",children:p.map(b=>e.jsx(Z,{"data-panel-row":"app",icon:ts,title:e.jsx("span",{className:"block truncate",children:b.title}),onClick:()=>k(b.messageId)},b.messageId))}),m.length+f.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(Ce,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[m.map(b=>e.jsx("li",{className:"min-w-0",children:e.jsx(Ba,{file:b.file,message:b.message,linked:b.file.linked,className:"w-full max-w-none"})},`${b.message.messageId}:${b.file.path}`)),f.map(b=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Re,{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:gi(b)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},b))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),P]})}function yi({bot:t,browserEnabled:a,onOpenBrowser:n}){const{state:i}=D(),r=et(),l=t.browserProfile??"",c=(i.config?.browserProfiles??[]).find(m=>m.id===l),d=l==="guest",o=c?.browser==="chrome"&&i.config?.browserEngine?.myChrome===!0,p=l&&!d?i.bots.filter(m=>m.browserProfile===l).map(m=>m.name):[t.name];return e.jsx(A,{anchor:"logins",children:a?d?e.jsx(V,{children:s("settings.profiles.temporaryHint")}):o?e.jsx(V,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[r!==!1&&(l===""||c)&&e.jsx(de,{children:e.jsx(jr,{bare:!0,target:{bot:t.id},sharedBy:p,disabled:!!t.busy},`${t.id}:${l}`)}),e.jsx(V,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(me,{"data-panel-action":"add-login",icon:ve,onClick:n,children:s("botSettings.simple.addLogin")})]}):e.jsx(V,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const bi=[["all",()=>M("Tất cả","All")],["added",()=>M("Bot đang có","On this bot")],["more",()=>M("Chưa thêm","Not added")]],vi=t=>({bundled:M("Có sẵn","Built in"),library:M("Đã tải về","Downloaded"),imported:M("Từ máy tính","From this computer")})[t],_e="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-hairline/60 bg-raised px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50";async function Dt(t,a){const n=await fetch(t,a===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)}),i=await n.json().catch(()=>({}));if(!n.ok)throw new Error(i.error??M(`Lỗi ${n.status}`,`Error ${n.status}`));return i.skills??[]}function ki({botId:t,botName:a,onClose:n,onOpenSettings:i}){const[r,l]=x.useState(null),[c,d]=x.useState(""),[o,p]=x.useState("all"),[m,f]=x.useState(""),[k,g]=x.useState(""),v=`/api/limix/skill-store/${encodeURIComponent(t)}`;x.useEffect(()=>{let u=!1;return Dt(v).then(S=>{u||l(S)}).catch(S=>{u||(l([]),g(S.message))}),()=>{u=!0}},[v]),x.useEffect(()=>{const u=S=>{S.key==="Escape"&&n()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n]);const j=x.useMemo(()=>{const u=c.trim().toLowerCase();return(r??[]).filter(S=>(o==="all"||(o==="added"?S.added:!S.added))&&(!u||`${S.name} ${S.description}`.toLowerCase().includes(u)))},[r,c,o]),P=async(u,S)=>{if(!m){f(u.name),g("");try{l(await Dt(v,{name:u.name,kind:u.kind,add:S}))}catch(T){g(T instanceof Error?T.message:M("Không đổi được kĩ năng này.","Couldn't change this skill."))}finally{f("")}}},b=(r??[]).filter(u=>u.added).length,w=e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:u=>u.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"limix-skill-store-title",className:"flex max-h-full w-full max-w-[640px] flex-col rounded-2xl border border-hairline/50 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pb-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"limix-skill-store-title",className:"text-[17px] font-semibold text-ink",children:M("Kho Kĩ Năng (Skills)","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:M(`Chọn kĩ năng riêng cho ${a}. Chỉ những kĩ năng được thêm mới nằm trong lời nhắc của bot, nên bot không bị quá tải. Gõ /tên-kĩ-năng trong chat để gọi.`,`Pick skills just for ${a}. Only added skills go into the bot's prompt, so it never gets overloaded. Type /skill-name in chat to call one.`)})]}),e.jsx("button",{type:"button",onClick:n,"aria-label":M("Đóng","Close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(Qe,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 pb-3",children:[e.jsxs("label",{className:"flex min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsx(Je,{size:14,className:"text-ink-tertiary"}),e.jsx("input",{value:c,onChange:u=>d(u.target.value),placeholder:M("Tìm kĩ năng…","Search skills…"),"aria-label":M("Tìm kĩ năng","Search skills"),className:"w-full bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":M("Lọc kĩ năng","Filter skills"),children:bi.map(([u,S])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":o===u,onClick:()=>p(u),className:`rounded-lg px-2.5 py-1.5 text-[13px] ${o===u?"bg-raised text-ink":"text-ink-secondary hover:bg-raised"}`,children:[S(),u==="added"&&r?` ${b}`:""]},u))})]}),k&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:k}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:r===null?e.jsxs("p",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(Se,{size:14,className:"animate-spin"}),M("Đang tải kho…","Loading the store…")]}):j.length===0?e.jsx("p",{className:"py-6 text-[13px] text-ink-secondary",children:r.length===0?M("Kho chưa có kĩ năng nào.","The store has no skills yet."):M("Không có kĩ năng khớp.","No matching skills.")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline/40 rounded-xl border border-hairline/40",children:j.map(u=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[13px] text-ink",children:u.name}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:u.core?M("Kĩ năng gốc","Core skill"):vi(u.kind)}),u.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[u.warnings," ",M("cảnh báo","warnings")]})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] leading-relaxed text-ink-secondary",children:u.description})]}),u.core?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(lt,{size:14}),M("Luôn bật","Always on")]}):u.added?e.jsxs("button",{type:"button",className:_e,disabled:!!m,onClick:()=>{P(u,!1)},"aria-label":M(`Bỏ ${u.name} khỏi bot`,`Remove ${u.name} from this bot`),children:[m===u.name?e.jsx(Se,{size:14,className:"animate-spin"}):e.jsx(lt,{size:14}),M("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:_e,disabled:!!m||!u.ready,onClick:()=>{P(u,!0)},"aria-label":M(`Thêm ${u.name} cho bot`,`Add ${u.name} to this bot`),children:[m===u.name?e.jsx(Se,{size:14,className:"animate-spin"}):e.jsx(ve,{size:14}),M("Thêm","Add")]})]},`${u.kind}:${u.name}`))})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 pb-5 pt-3",children:[e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:M('Bấm "Đã thêm" để bỏ kĩ năng khỏi bot này.','Press "Added" to remove a skill from this bot.')}),e.jsx("button",{type:"button",className:_e,onClick:i,children:M("Tải thêm kĩ năng","Get more skills")})]})]})});return typeof document>"u"?w:is.createPortal(w,document.body)}const ji=5,wi={instanceId:"",model:""},Es=(t,a)=>`${t}\0${a}`,Ni=new Set;function $t({bot:t,current:a,exclude:n,onPick:i,label:r,title:l,buttonRef:c,className:d,children:o,...p}){const{state:m,dispatch:f,refreshInstances:k,refreshModels:g}=D(),[v,j]=x.useState(!1),[P,b]=x.useState(""),[w,u]=x.useState(()=>new Set),[S,T]=x.useState(!1),[F,B]=x.useState(null),[I,H]=x.useState(null),L=x.useRef(null),h=c??L,R=x.useRef(null),$=x.useRef(null),_=x.useRef(!1),K=x.useId(),J=Un(v),G=x.useRef({contains:C=>[h.current,R.current].some(q=>q?.contains(C))});_a(v,G,()=>j(!1)),x.useLayoutEffect(()=>{if(!v)return;const C=q=>{if(q?.type==="scroll"&&q.target instanceof Node&&R.current?.contains(q.target))return;const Y=h.current?.getBoundingClientRect(),W=R.current;!Y||!W||H(oe=>qa(Y,{width:xt,height:W.offsetHeight},{width:window.innerWidth,height:window.innerHeight},oe??void 0))};return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[v,h]),x.useEffect(()=>{if(!v||!I||!_.current)return;_.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&&h.current?.focus({preventScroll:!0})},y=()=>{b(""),u(new Set),H(null),_.current=!0,j(!0),T(!0),k().catch(()=>{}).finally(()=>T(!1))},z=C=>{F||(B(C.instanceId),g(C.instanceId).catch(()=>{}).finally(()=>B(null)))},le=()=>{U(!1),f({type:"toggleAppSettings",open:!0,section:"engines"})},pe=()=>{const C=Va(m.instances,a?.instanceId).flatMap(W=>{const oe=W.models.options.filter(ke=>!n.has(Es(W.instanceId,ke.id)));return oe.length===W.models.options.length?[W]:oe.length?[{...W,models:{...W.models,options:oe}}]:[]}),q=Ya({instances:m.instances,listed:C,selection:a??wi,bot:{name:t.name,selection:t.modelSelection},query:P,expanded:w,probing:Ni,loading:S,refreshing:F}),Y=q.groups.map(W=>W.instance.instanceId===t.modelSelection.instanceId?{...W,note:s("botPanel.backups.sameAccount")}:W);return{...q,groups:Y,...a?{}:{current:null}}},fe=C=>{if(!(C.nativeEvent.isComposing||C.defaultPrevented)){if(C.key!=="Escape")return Wa(C,{query:P,typed:$,close:()=>U(!0)});C.preventDefault(),C.stopPropagation(),P?b(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...p,"aria-label":r,title:l,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?K:void 0,onClick:()=>v?U(!1):y(),onKeyDown:C=>{C.key==="Escape"&&v?(C.preventDefault(),C.stopPropagation(),U(!1)):(C.key==="ArrowDown"||C.key==="ArrowUp")&&!v&&(C.preventDefault(),y())},className:d,children:o}),J.shown&&is.createPortal(e.jsx("div",{ref:R,id:K,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...J.exitProps,onKeyDown:fe,onPointerMove:Ka,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??xt,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:E("menu-surface z-[80] flex flex-col overflow-hidden",J.className),children:e.jsx(Ua,{menu:pe(),query:P,bot:t,botModel:{label:"",title:""},idPrefix:K,onQuery:b,onPick:(C,q)=>{C.policy||(i({instanceId:C.instanceId,model:q}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:C=>u(q=>{const Y=new Set(q);return Y.delete(C.instanceId)||Y.add(C.instanceId),Y}),onSetUp:le,onCheckAgain:z,onManage:le})}),document.body)]})}function Si({bot:t,onChange:a}){const{state:n}=D(),i=t.fallback??[],r=x.useRef(null),l=d=>new Set([t.modelSelection,...i.filter((o,p)=>p!==d)].map(o=>Es(o.instanceId,o.model))),c=d=>{const o=n.instances.find(f=>f.instanceId===d.instanceId),p=o?.models.options.find(f=>f.id===d.model),m=Fa(o,d.model);return{instance:o,name:m,short:o&&p?za(p.label,Ha(o)):m}};return e.jsx(A,{anchor:"backups",children:e.jsxs(de,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Da}),e.jsx(se,{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})}),i.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:i.map((d,o)=>{const{instance:p,name:m,short:f}=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($t,{bot:t,current:d,exclude:l(o),onPick:k=>a(i.map((g,v)=>v===o?k:g)),label:s("botPanel.backups.row",{position:o+1,model:m}),title:p?`${p.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:[p?e.jsx($a,{instance:p,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),!p&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(he,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Ie,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{a(i.filter((k,g)=>g!==o)),r.current?.focus({preventScroll:!0})}})]},o)})}),i.length<ji&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs($t,{bot:t,current:null,exclude:l(null),onPick:d=>a([...i,d]),label:s("model.fallback.add"),buttonRef:r,"data-panel-action":"backup-add",className:E(ie,"aria-expanded:bg-raised-hover"),children:[e.jsx(ve,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Ci({bot:t}){const{dispatch:a}=D(),[n,i]=x.useState(!1),[r,l]=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 ae(`/api/bots/${t.id}/system-prompt`).then(f=>{m&&i(f.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,o,c]),!o||!n)return null;const p=async()=>{l(!0);try{await cs(t.id)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{l(!1),d(m=>m+1)}};return e.jsx(A,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Q,children:[e.jsx(X,{icon:Ga}),e.jsx(se,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:r,onClick:()=>{p()},className:ie,children:r?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Pi=5;function Oi({bot:t}){const{dispatch:a,flushBotPatches:n}=D(),[i,r]=x.useState([]),[l,c]=x.useState(null),d=x.useCallback(()=>jt(t.id).then(p=>r(p.rows.slice(0,Pi)),()=>{}),[t.id]);if(x.useEffect(()=>{d()},[d,t.soul]),!i.length)return null;const o=async p=>{if(!l){c(p.id);try{await n(t.id);const{revision:m}=await jt(t.id);await Zn(t.id,p.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(nt,{rows:i,botName:t.name,reverting:l,onRevert:p=>{o(p)}})]})}const Ke={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 Ei({bot:t,derived:a,onOpen:n,editingInstructions:i=!1,onEditInstructions:r}){const{state:l,dispatch:c,flushBotPatches:d}=D(),{capabilities:o,ready:p}=be(),m=ss(t),{servers:f}=fs(),k=Ja(qe(t)),g=Qa(),v=bs(t.id),j=xs(),[P,b]=x.useState(null),{patch:w,approvalMode:u,engine:S}=a,T=t.name,F=()=>{P!==null&&P.trim()!==t.title.trim()&&w({title:P.trim()}),b(null)},B=S?.driverKind==="antigravityAgent"&&u==="auto"?"ask":u,I=[{value:"ask",label:Ke.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:Ke.full(),tooltip:s("botSettings.simple.fullHint")},...B==="ask"||B==="full"?[]:[{value:B,label:Ke[B](),disabled:!0,tooltip:B==="custom"?s("botPanel.acts.customHint"):void 0}]],H=y=>{y===u||y!=="ask"&&y!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:y,applyToAllThreads:!0}})},L=!p||Xa(o,l.config),h=mn(g,{turnsHere:L,canLive:!0}),R=L?null:Za(o,!!tn()?.speechStart,en(l.config)),$=sn.map(y=>({value:y.id,label:s(y.label),disabled:y.id==="turns"&&R!==null,tooltip:y.id==="turns"&&R?`${R.label}. ${R.reason}`:y.id==="live"?s("call.mode.liveHint"):an("turns")})),_=nn.map(y=>({value:y,label:s(wt[y][0]),tooltip:s(wt[y][1])})),K=()=>{const y=!t.notifications;y&&pn(),w({notifications:y})},J=t.alwaysAllow??[],G=i||!!t.soulDrift,U=[...m.apps.filter(y=>y.scope!==null).map(y=>y.label),...f?gs(f,t.mcpServers,t.id).map(y=>y.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(er,{bot:t}),e.jsx(A,{anchor:"instructions",children:G?e.jsxs(de,{"data-panel-row":"soul",children:[e.jsx(tr,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:T})}}),e.jsx(Oi,{bot:t}),i&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{d(t.id),r?.(!1)},className:ie,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:E(Q,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Re}),e.jsx(se,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:sr(t.soul??"")||s("botPanel.instructionsHint",{name:T})})}),e.jsx(ye,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Ci,{bot:t}),e.jsx(A,{anchor:"approval",children:e.jsxs(de,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:qt}),e.jsx(se,{title:s("botSettings.simple.beforeActs",{name:T}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Ne,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:T}),value:B,onChange:H,options:I})}),k.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(rn,{choice:k.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(y=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:y}),e.jsx(Ie,{"data-panel-action":`always-allow:${y}`,label:s("botAccess.always.remove",{entry:y}),onClick:()=>w({alwaysAllow:J.filter(z=>z!==y)})})]},y))]})]})}),e.jsx(Si,{bot:t,onChange:y=>w({fallback:y})}),e.jsx(A,{anchor:"call",children:e.jsxs(de,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Hn}),e.jsx(se,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Ne,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:ln,options:$})})]})}),e.jsxs(A,{anchor:"replies",children:[e.jsxs(de,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:on}),e.jsx(se,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Ne,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:y=>w({replyStyle:y}),options:_})})]}),e.jsx(tt,{"data-panel-row":"notifications",icon:cn,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:K})]}),e.jsxs(A,{anchor:"uses",children:[e.jsx(Z,{"data-panel-page":"apps",icon:ts,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>n?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:E(Q,"cursor-text"),children:[e.jsx(X,{icon:Er}),e.jsx("span",{className:"shrink-0 text-[14px] font-medium text-ink",children:s("botSettings.simple.job")}),e.jsx("input",{"data-panel-job":!0,value:P??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ve.title,onChange:y=>b(y.target.value),onBlur:F,onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),y.currentTarget.blur()):y.key==="Escape"&&P!==null&&(y.preventDefault(),y.stopPropagation(),b(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),v&&e.jsxs("a",{"data-panel-row":"slack",href:v,target:"_blank",rel:"noopener noreferrer",className:E(Q,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:ys}),e.jsx(se,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(rs,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(Z,{"data-panel-page":"visibility",icon:Wt,title:s("botSettings.visibility.title"),value:ar(t.visibility),onClick:()=>n?.("visibility")})]}),e.jsx(nr,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(dn,{bot:t}),k.dialogs]})}const Ri=5;function Ii({bot:t,onChanged:a}){const{dispatch:n}=D(),[i,r]=x.useState([]),[l,c]=x.useState(null),[d,o]=x.useState(null),p=x.useCallback(async()=>{const[g,v]=await Promise.all([st(t.id),xe(t.id)]);c(j=>g.lendingReview?{value:g.lendingReview,stale:j?.stale??!1}:null),r(v.slice(0,Ri))},[t.id]);x.useEffect(()=>{p().catch(()=>{})},[p,t.busy]);const m=g=>n({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{o(g.id);try{await ms(t.id,g.id),await a()}catch(v){m(v)}finally{o(null),await p().catch(()=>{})}},k=async g=>{o("review");try{await os(t.id,g.value.token),c(null)}catch(v){v instanceof Gt&&v.status===409?(c({...g,stale:!0}),await p().catch(()=>{})):m(v)}finally{o(null)}};return e.jsxs(e.Fragment,{children:[l&&e.jsx(ks,{changed:l.value.changed,stale:l.stale,busy:d!==null,onReviewed:()=>{k(l)}}),e.jsx(A,{children:e.jsx(tt,{"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}})})}),i.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(nt,{rows:i,botName:t.name,reverting:d,onRevert:g=>{f(g)}})})})]})}const Li="flex flex-col gap-3",Ft="https://www.skills.sh";function ge(t,a){return t instanceof Error&&t.message?t.message:a}function Ai({bot:t,derived:a}){const{dispatch:n}=D(),i=ss(t),{servers:r,error:l}=fs(),{patch:c,canUseConnectedApps:d}=a,o=r?br(r,t.id):[],p=new Set(gs(o,t.mcpServers,t.id).map(g=>g.name)),m=g=>{const v=gn(t,i.connectedSlugs,g.slug,g.scope===null);Object.keys(v).length>0&&c(v)},f=g=>{t.busy||l||c({mcpServers:vr(o,t.mcpServers,g)})},k=d?i.phase==="loading"?s("common.checking"):i.phase==="unknown"?s("botSettings.simple.appsUnknown"):i.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:[k&&e.jsx(V,{children:k}),d&&i.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Q,children:[e.jsx(hn,{card:g.card,className:"size-7 shrink-0"},`${g.card.logo}:${g.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:g.label}),e.jsx(ft,{color:t.color,checked:g.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.label}),disabled:!!t.busy,onClick:()=>m(g),className:"disabled:cursor-not-allowed"})]},g.slug))]}),(o.length>0||l)&&e.jsxs(A,{label:s("connectors.tab.mcp"),children:[l&&e.jsx(V,{children:s("botAccess.mcpRefreshError")}),o.map(g=>e.jsxs("div",{"data-simple-mcp":g.name,className:Q,children:[e.jsx(X,{icon:_n}),e.jsx(se,{title:e.jsx("span",{className:"block truncate",children:g.name}),hint:g.enabled?g.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(ft,{color:t.color,checked:p.has(g.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.name}),disabled:!g.enabled||!!t.busy||l,onClick:()=>f(g.name),className:"disabled:cursor-not-allowed"})]},g.name))]}),e.jsx(A,{children:e.jsx(me,{"data-panel-link":"add-app",icon:ve,onClick:()=>fn(n,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Ti({bot:t,derived:a}){const{state:n,dispatch:i}=D(),[r,l]=x.useState(()=>a.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(gr,{routines:a.botRoutines,runs:n.routineRuns,pausedBots:n.config?.pausedBots,loading:n.routinesLoadState==="loading"&&a.botRoutines.length===0,error:n.routinesLoadState==="error",onOpen:l,onLogs:c=>i({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>i({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(A,{children:e.jsx(me,{"data-panel-action":"new-routine",icon:ve,onClick:()=>l("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(kr,{routine:r==="new"?void 0:r,bots:[t],lockedBotId:t.id,onClose:()=>l(null)},t.id)]})}function Mi({bot:t}){const a=Ps(t),[n,i]=x.useState(""),[r,l]=x.useState(null),[c,d]=x.useState(!1),[o,p]=x.useState(null),m=t.memoryEnabled!==!1,f=a.docs?Cs(a.docs):null,k=a.docs?.find(b=>b.path===ee)??null;x.useEffect(()=>l(null),[t.id,m]);const g=async b=>{if(c)return!1;d(!0),p(null);try{return await b()}catch(w){return p(ge(w,s("botPanel.library.memoryError"))),!1}finally{d(!1)}},v=(b,w)=>g(async()=>{const u=await at(t.id,b.path,w,b.exists?b.hash:void 0,a.mine);return u.ok?(a.setDoc(u.doc),!0):(await a.reload(),p(s("memory.conflict.title",{name:t.name})),!1)}),j=b=>{const w=a.docs?.find(u=>u.path===b.path);w&&(b.line!==null?v(w,ui(w.text,b.line)):g(async()=>(await ds(t.id,w.path,a.mine),await a.reload(),!0)))},P=async()=>{!k||!n.trim()||await v(k,xi(k.text,n))&&i("")};return m&&r?.botId===t.id?e.jsx(Bi,{bot:t,doc:r.doc,mine:a.mine,onDone:b=>{b&&a.setDoc(b),l(null),p(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[m?a.error?e.jsx(V,{tone:"warn",children:s("botPanel.library.memoryError")}):f===null?e.jsx(V,{children:s("common.checking")}):f.length===0?e.jsx(V,{children:s("botPanel.memory.empty")}):f.map(b=>e.jsxs("div",{"data-memory-note":b.line??b.path,className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:b.text}),e.jsx(Ie,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>j(b)})]},`${b.path}:${b.line}:${b.text}`)):e.jsx(V,{children:s("botPanel.library.memoryOff",{name:t.name})}),o&&e.jsx(V,{tone:"warn",children:o})]}),m&&e.jsxs(A,{children:[e.jsx(as,{"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||k===null,onChange:i,onSubmit:()=>{P()}}),k&&e.jsx(me,{"data-panel-link":"memory-text",icon:Re,onClick:()=>l({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),m&&!a.mine&&e.jsx(Ii,{bot:t,onChanged:a.reload})]})}function Bi({bot:t,doc:a,mine:n,onDone:i}){const[r,l]=x.useState({text:a.text,hash:a.hash}),[c,d]=x.useState(a.text),[o,p]=x.useState(null),[m,f]=x.useState(null),[k,g]=x.useState(!1),[v,j]=x.useState(null),P=x.useRef(!0);x.useEffect(()=>(P.current=!0,()=>{P.current=!1}),[]);const b=async u=>{g(!0),j(null);try{const S=await at(t.id,a.path,c,u,n);if(!P.current)return;S.ok?i(S.doc):p({current:S.current,currentHash:S.currentHash})}catch(S){j(ge(S,s("botPanel.library.memoryError")))}finally{g(!1)}},w=()=>{o&&(f(u=>u===null||u===c?c:`${u}
15
-
16
- ${c}`),l({text:o.current,hash:o.currentHash}),d(o.current),p(null))};return e.jsx(A,{children:e.jsxs(de,{"data-panel-row":"memory-text",children:[o&&e.jsx(js,{botName:t.name,busy:k,onReload:w,onOverwrite:()=>{b(o.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:E(Ge,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:u=>d(u.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:E(ie,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:ie,disabled:k,onClick:()=>i(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:ie,disabled:k||c===r.text,onClick:()=>{b(r.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Di({bot:t}){const{request:a}=un(),{state:n,dispatch:i}=D(),r=ps(t),[l,c]=x.useState(""),[d,o]=x.useState(!1),[p,m]=x.useState([]),f=xn(n.config),k=async u=>{if(!r.working&&window.confirm(s(u.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:u.name}))){r.setWorking(u.name),r.setError("");try{await a(`/api/bots/${t.id}/skills/${encodeURIComponent(u.name)}`,{method:"DELETE"}),await r.refresh()}catch(S){r.setError(ge(S,s("botPanel.skills.removeFailed")))}finally{r.setWorking("")}}},g=async()=>{const u=l.trim();if(!(!u||d)){o(!0),r.setError(""),m([]);try{const S=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:u})});m(Nt(S.imported??[])),c(""),await r.refresh()}catch(S){r.setError(ge(S,s("botPanel.skills.importFailed")))}finally{o(!1)}}},v=async()=>{const u=await window.ogb?.pickFolder?.();if(!(!u||d)){o(!0),r.setError(""),m([]);try{const S=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${u}`})});m(Nt(S.imported??[])),await r.refresh()}catch(S){r.setError(ge(S,s("botPanel.skills.importFailed")))}finally{o(!1)}}},[j,P]=x.useState(!1),b=()=>{P(!1),i({type:"toggleSettings",open:!1}),i({type:"toggleAppSettings",open:!0,section:"skills"})},w=()=>{if(f){P(!0);return}ht(Ft)};return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[r.loading?e.jsx(V,{children:s("skills.loading")}):r.skills.length===0?e.jsx(V,{children:s("botSettings.simple.noSkills")}):r.skills.map(u=>e.jsx(tt,{"data-panel-row":`skill:${u.name}`,title:u.name,hint:u.description||u.source,label:s("botSettings.simple.skillToggle",{name:u.name}),color:t.color,checked:us(u),disabled:!!r.working||u.core===!0,onChange:()=>{r.toggle(u)},extra:u.origin==="imported"||u.origin==="native"||u.origin==="bundled"?void 0:e.jsx(Ie,{"data-panel-action":`remove-skill:${u.name}`,label:s("botPanel.skills.remove",{name:u.name}),disabled:!!r.working,onClick:()=>{k(u)}})},u.name)),r.error&&!r.reviewing&&e.jsx(V,{tone:"warn",children:r.error})]}),e.jsx(ir,{bot:t,onAdded:()=>{r.refresh()}}),e.jsxs(A,{children:[e.jsx(as,{"data-panel-form":"skill-import",value:l,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:d?s("skills.import.importing"):s("common.add"),disabled:d,onChange:c,onSubmit:()=>{g()}}),p.map(u=>e.jsx(V,{children:u},u)),e.jsx(me,{"data-panel-link":"skills-sh",onClick:()=>{ht(Ft)},children:s("botPanel.skills.skillsSh")}),e.jsx(me,{"data-panel-link":"browse-skills",onClick:w,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(me,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),j&&e.jsx(ki,{botId:t.id,botName:t.name,onOpenSettings:b,onClose:()=>{P(!1),r.refresh()}}),r.reviewing&&e.jsx(lr,{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 $i({bot:t}){const{capabilities:a}=be(),n=a.host?.homeDir,{draft:i,setDraft:r,error:l,saving:c,canPick:d,save:o,pick:p}=rr(t),[m,f]=x.useState(!1),k=!!t.cwd||m,g=()=>{if(d){p();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsx(Ue,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:c,onClick:()=>{f(!1),t.cwd&&o(null)}}),e.jsx(Ue,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:k,disabled:c,onClick:()=>{t.cwd||g()}})]}),k&&e.jsxs(A,{children:[d?e.jsxs("div",{className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?Ze(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:()=>{p()},className:ie,children:[e.jsx(Yt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:Q,onSubmit:v=>{v.preventDefault();const j=(i??t.cwd??"").trim();j&&o(j)},children:[e.jsx("input",{value:i??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||i===null,className:ie,children:s("botAccess.folder.save")})]}),l&&e.jsx(V,{tone:"warn",children:l})]})]})}function Fi({bot:t,derived:a}){const n=ws(t);return e.jsx(yi,{bot:t,browserEnabled:a.browserEnabled,onOpenBrowser:()=>n("browser")})}function zi({bot:t}){return xs()?e.jsx(hs,{bot:t}):null}function Hi({page:t,onOpen:a,editingInstructions:n,onEditInstructions:i,...r}){switch(t){case"settings":return e.jsx(Ei,{...r,onOpen:a,editingInstructions:n,onEditInstructions:i});case"where":return e.jsx(ti,{...r});case"apps":return e.jsx(Ai,{...r});case"routines":return e.jsx(Ti,{...r});case"visibility":return e.jsx(zi,{...r});case"memory":return e.jsx(Mi,{...r});case"skills":return e.jsx(Di,{...r});case"folder":return e.jsx($i,{...r});case"browser":return e.jsx(Fi,{...r})}}const zt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Ht(t){const[a,n]=x.useState(null),i=x.useRef(!1),r=x.useRef(!1),l=x.useRef(null);x.useEffect(()=>{a!==null||!r.current||(r.current=!1,l.current?.focus())},[a]);const c=m=>{i.current=!1,n(m)},d=()=>{a!==null&&t(a),n(null)};return{draft:a,setDraft:n,start:c,onKeyDown:m=>{if(bn(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),i.current=!0,r.current=!0,d()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),i.current=!0,r.current=!0,n(null))},onBlur:()=>{i.current||d()},buttonRef:l}}function _i({bot:t,activeState:a,patch:n,editorOpen:i,onToggleEditor:r}){const l=Ht(o=>{const p=o.trim();p&&p!==t.name&&n({name:p})}),c=Ht(o=>{const p=o.trim();p!==t.title.trim()&&n({title:p})}),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":i,onClick:r,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(Ye,{bot:t,size:64,state: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(gt,{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(yn,{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:l.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ve.name,value:l.draft,onChange:o=>l.setDraft(o.target.value),onKeyDown:l.onKeyDown,onBlur:l.onBlur,className:E(zt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:l.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>l.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(gt,{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:Ve.title,value:c.draft,onChange:o=>c.setDraft(o.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:E(zt,"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 we(t,a){return t?ns(t,a):{tab:"details"}}function Ki({bot:t,derived:a,linkedSection:n,onClose:i}){const{dragProps:r}=ls(),l=vn(),[c,d]=x.useState(()=>we(n,l).tab),[o,p]=x.useState(()=>{const h=we(n,l).page;return h?[h]:[]}),[m,f]=x.useState(()=>we(n,l).anchor??null),[k,g]=x.useState(!1),[v,j]=x.useState(()=>!!we(n,l).editInstructions),P=x.useRef(null),b=x.useRef(null),w=o.at(-1)??null,u=()=>P.current?.scrollTo({top:0}),S=h=>{d(h.tab),p(h.page?[h.page]:[]),f(h.anchor??null),g(!1),j(!!h.editInstructions),u()},T=h=>S({tab:h}),F=h=>{p(R=>[...R,h]),g(!1),u()},B=()=>{g(!1),b.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{p(h=>h.slice(0,-1)),u()};x.useEffect(()=>{n&&S(ns(n,l))},[n,l]),x.useEffect(()=>{m&&(P.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),f(null))},[m,w,c]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const R=h.target,$=typeof R?.closest=="function"?R.closest('[role="dialog"], [role="alertdialog"]'):null;if(!($&&!$.contains(h.currentTarget)&&$!==b.current&&!b.current?.contains($))){if(k)B();else if(o.length>0)I();else return;h.preventDefault(),h.stopPropagation()}},L=o.length>1?s(je[o[o.length-2]].title,{name:t.name}):s(yt[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:H,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(kn,{bot:t,className:Be}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":w==="settings"?"page":void 0,onClick:()=>S({tab:"details",page:"settings"}),className:Be,children:e.jsx(jn,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:i,"aria-label":s("botSettings.simple.close"),className:Be,children:e.jsx(Qe,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:P,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:w===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:b,children:[e.jsx(_i,{bot:t,activeState:a.activeState,patch:a.patch,editorOpen:k,onToggleEditor:()=>g(h=>!h)}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:B}),e.jsx(Xr,{bot:t,activeState:a.activeState,onPatch:a.patch,onClose:B})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:wn.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===h,"data-panel-tab":h,onClick:()=>T(h),className:E("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(yt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(mi,{bot:t,derived:a,onOpen:F}),c==="library"&&e.jsx(Os,{bot:t,onOpen:F}),c==="computer"&&e.jsx(si,{bot:t,derived:a,onOpen:F})]})]}):e.jsxs("div",{"data-panel-page-view":w,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(Nn,{back:L,title:s(je[w].title,{name:t.name}),intro:je[w].intro?s(je[w].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:E("mt-4",Li),children:e.jsx(Hi,{page:w,bot:t,derived:a,onOpen:F,editingInstructions:v,onEditInstructions:j})})]})})]})}function Ui(t,a){const{state:n,flushBotPatches:i}=D(),[r,l]=x.useState(null),[c,d]=x.useState(!1),[o,p]=x.useState(null),[m,f]=x.useState(!1),k=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]),g=a.followEdits??!0,v=g?k:null,j=g?n.routines:null,P=g?n.webhooks:null;return x.useEffect(()=>{if(!a.overview&&!a.prompt)return;let b=!1;return(async()=>(await i(t.id),!b&&(a.overview&&ae(`/api/bots/${t.id}/overview`).then(u=>{b||(l(u),d(!1))}).catch(()=>{b||d(!0)}),a.prompt&&ae(`/api/bots/${t.id}/system-prompt`).then(u=>{b||(p(u),f(!1))}).catch(()=>{b||f(!0)}))))(),()=>{b=!0}},[t.id,a.overview,a.prompt,v,j,P,i]),{overview:r,overviewError:c,prompt:o,promptError:m}}function qi(t,a){const{dispatch:n,flushBotPatches:i}=D(),[r,l]=x.useState(null),[c,d]=x.useState(!1),[o,p]=x.useState(null),m=x.useRef(0),[f,k]=x.useState(!1),[g,v]=x.useState(null),j=x.useCallback(()=>{const w=++m.current;return d(!1),i(t.id).then(()=>ae(`/api/bots/${t.id}/history?limit=100`)).then(u=>{w===m.current&&(l(u.rows),p(u.revision))}).catch(()=>{w===m.current&&d(!0)})},[t.id,i]);return x.useEffect(()=>{if(a)return j(),()=>{m.current++}},[a,j]),{rows:r,error:c,revision:o,rollingBack:f,rollbackTarget:g,setRollbackTarget:v,rollback:async w=>{if(!f){v(null),k(!0);try{await i(t.id),await ae(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(w)})}catch(u){n({type:"error",message:u instanceof Error?u.message:s("botOverview.undoFailed")})}finally{await j(),k(!1)}}},requestRollback:w=>{o&&v({id:w,expectedRevision:o})}}}function Wi({history:t,returnFocusRef:a}){const{rollbackTarget:n,setRollbackTarget:i,rollback:r}=t;return e.jsx(Sn,{open:n!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:a,onCancel:()=>i(null),onConfirm:()=>{n&&r(n)}})}const Vi={memory:"memory",skills:"skills",folder:"access"},Rs=t=>t.labelKey?s(t.labelKey):t.label;function _t(t,a){return a?[t.label,Rs(t),...t.keywords].some(n=>n.toLowerCase().includes(a)):!0}function ml({bot:t,overlay:a=!1}){const{state:n,dispatch:i}=D(),r=n.botSettingsSection,l=Cn(t),c=x.useRef(null),{dragProps:d}=ls(),[o,p]=x.useState(""),m=!n.botSettingsExpandAccordion,f=o.trim().toLowerCase(),g=!Kt(),v=!m&&!n.botSettingsExpandRemembered?r:null,j=bs(t.id),P=et(),b=Pn(),w=Rr.filter(L=>L.id!=="slack"||j!==null).filter(L=>L.id!=="visibility"||!window.ogb&&P===!0&&!b),u=w.filter(L=>_t(L,f)),{overview:S,overviewError:T,prompt:F,promptError:B}=Ui(t,{overview:r==="overview"&&!g,prompt:r==="overview"&&!g}),I=qi(t,r==="history"&&!g);x.useEffect(()=>{if(!m){if(f){p("");return}c.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[m,r,f]),x.useEffect(()=>{const L=document.activeElement instanceof HTMLElement?document.activeElement:null,h=c.current;h?.focus();const R=$=>{const _=h?.querySelector('[role="dialog"], [role="alertdialog"]');_&&_.getClientRects().length>0||h&&$.target instanceof Node&&!h.contains($.target)||$.key==="Escape"&&!$.defaultPrevented&&($.preventDefault(),i({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),L?.focus()}},[i]);const H=L=>{switch(L){case"overview":return S===null&&T?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Dr,{overview:S,refreshError:S!==null&&T,prompt:F,promptError:B,onOpen:h=>i({type:"toggleSettings",open:!0,section:h}),onSetup:l.canCoordinate&&!t.busy?()=>{i({type:"toggleSettings",open:!1}),i({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(xr,{bot:t,patch:l.patch,activeState:l.activeState,mascotMotion:l.mascotMotion});case"soul":return e.jsx(ur,{bot:t,patch:l.patch});case"slack":return j?e.jsx($r,{managementUrl:j}):null;case"skills":return e.jsx(pr,{bot:t});case"memory":return e.jsx(Hr,{bot:t,active:!m&&r==="memory",onToggle:h=>l.patch({memoryEnabled:h})});case"library":return e.jsx(Os,{bot:t,onOpen:h=>i({type:"toggleSettings",open:!0,section:Vi[h]??"overview"})});case"routines":return e.jsx(yr,{bot:t,routines:l.botRoutines,runs:n.routineRuns});case"access":return e.jsx(mr,{bot:t,derived:l});case"model":return e.jsx(dr,{bot:t});case"permissions":return e.jsx(cr,{bot:t,derived:l});case"voice":return e.jsx(or,{bot:t,derived:l});case"visibility":return e.jsx(hs,{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(qr,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(Wr,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:g?On:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Rn(a,g),children:g?e.jsx(Ki,{bot:t,derived:l,linkedSection:v,onClose:()=>i({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(En,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>i({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(Qe,{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(Je,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:o,onChange:L=>{p(L.target.value),i({type:"toggleSettings",open:!0})},onKeyDown:L=>{L.key==="Escape"&&(L.stopPropagation(),o?p(""):i({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:[u.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:o.trim()})}),w.map(L=>{const{id:h,icon:R}=L,$=Rs(L),_=_t(L,f);if(!_&&h!=="memory")return null;const K=!m&&r===h;return e.jsxs("div",{"data-bot-settings-section":h,className:"border-b border-hairline/30",hidden:!_,children:[e.jsxs("button",{type:"button",onClick:()=>{if(r===h&&!m){i({type:"toggleSettings",open:!0});return}i({type:"toggleSettings",open:!0,section:h})},"aria-expanded":K,className:E("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",K?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(R,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:$}),e.jsx(he,{size:16,className:E("shrink-0 text-ink-secondary transition-transform",K&&"rotate-180")})]}),h==="memory"?e.jsx("div",{hidden:!K,className:"px-4 pb-4 pt-1",children:H("memory")}):K&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:H(h)})]},h)})]})]})}),e.jsx(Wi,{history:I,returnFocusRef:c})]})}export{ml as BotSettingsDialog};