limixbot 0.3.129 → 0.3.131

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 (170) hide show
  1. package/dist/assets/{ActivityPanel-C092xjIk.js → ActivityPanel-DLm-v_Kg.js} +1 -1
  2. package/dist/assets/{App-CFt1bVwj.js → App-Co1EFoza.js} +134 -133
  3. package/dist/assets/{AppEventEditor-C00_DMLy.js → AppEventEditor-BdU7zTya.js} +1 -1
  4. package/dist/assets/BotSettingsDialog-DZbrG3Yu.js +16 -0
  5. package/dist/assets/BrowserPanel-BAmkHZNW.js +3 -0
  6. package/dist/assets/{BrowserProfilesManager-CIDDGvM_.js → BrowserProfilesManager-DL_IVvlO.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-bLdejHsc.js → CloudAddDialog-Cs6tRBOu.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-Ce9ODuX8.js → ComputerFilesPane-Bl6NnCOe.js} +1 -1
  9. package/dist/assets/{ComputerPanel-Dpekp0Z2.js → ComputerPanel-CzwDPKV_.js} +2 -2
  10. package/dist/assets/{DataPanel-i5mxANER.js → DataPanel-FEAZNWku.js} +1 -1
  11. package/dist/assets/{DesktopViewer-B9mw98xI.js → DesktopViewer-Cb9PL6v1.js} +1 -1
  12. package/dist/assets/{GrokMoveDialog-DYarhzxZ.js → GrokMoveDialog-Bp0mxIE8.js} +1 -1
  13. package/dist/assets/{InspectorPanel-D5ulGIOz.js → InspectorPanel-DJADxXPA.js} +1 -1
  14. package/dist/assets/{KeyboardShortcutsModal-BVDKAY0o.js → KeyboardShortcutsModal-CNiZBEA1.js} +1 -1
  15. package/dist/assets/{LimixResizeHandles-Jjthi0zS.js → LimixResizeHandles-nzE7n7jC.js} +1 -1
  16. package/dist/assets/{LiveDesktop-CFqHs50a.js → LiveDesktop-BvdjlV9Q.js} +1 -1
  17. package/dist/assets/{LocalVmWorkspace-DbB_ec11.js → LocalVmWorkspace-DmQTSD1_.js} +1 -1
  18. package/dist/assets/{MacLocalControl-DoWLhevV.js → MacLocalControl-WWFi-S9U.js} +1 -1
  19. package/dist/assets/{MarkdownFilePreview-CCaYi8EP.js → MarkdownFilePreview-BsGqiWI2.js} +1 -1
  20. package/dist/assets/{MenuMotion-DG5tk0i3.js → MenuMotion-owWIcamS.js} +1 -1
  21. package/dist/assets/{NewBotDialog-CWbeGI3M.js → NewBotDialog-sr2kfVv6.js} +1 -1
  22. package/dist/assets/{PhoneAppDialog-BErSSwmM.js → PhoneAppDialog-DC4JUrmh.js} +1 -1
  23. package/dist/assets/{PlacesRail-CAV7kW3Y.js → PlacesRail-BxdV2GDQ.js} +1 -1
  24. package/dist/assets/{PluginsPanel-BKQ4in_K.js → PluginsPanel-BMHhkTNZ.js} +5 -5
  25. package/dist/assets/{ProIntroduction-DgDPOYzn.js → ProIntroduction-CLLJ3Vgd.js} +1 -1
  26. package/dist/assets/{RemoteAgentSettingsPanel-BsD_TT_T.js → RemoteAgentSettingsPanel-DWTstMZc.js} +1 -1
  27. package/dist/assets/{RoomPanel-UR35p-lT.js → RoomPanel-DuE_Gpr5.js} +1 -1
  28. package/dist/assets/{RoutinesPage-Cims3t6g.js → RoutinesPage-CPo3eSc1.js} +2 -2
  29. package/dist/assets/{SettingsModal-2S8H2h_g.js → SettingsModal-BZzK-mss.js} +4 -4
  30. package/dist/assets/{ShareTeamDialog-org_7J0x.js → ShareTeamDialog-CDkcowQz.js} +1 -1
  31. package/dist/assets/{SignedInSites-Dp2PSLBK.js → SignedInSites-DLDJv-6U.js} +1 -1
  32. package/dist/assets/{TeamLibraryPanel-Ch-zZVWY.js → TeamLibraryPanel-X0NQqbX0.js} +1 -1
  33. package/dist/assets/{TeamMapPage-Ba7y1YPZ.js → TeamMapPage-C6K12Ejq.js} +1 -1
  34. package/dist/assets/{TriggersPage-qUNQ79Nb.js → TriggersPage-BAXbOt6i.js} +1 -1
  35. package/dist/assets/VisibilitySection-CC7rEV8o.js +22 -0
  36. package/dist/assets/{WebhookTrigger-DjYDUzGP.js → WebhookTrigger-cHV0kIQv.js} +1 -1
  37. package/dist/assets/{WorksOnGrid-wPPuMbjR.js → WorksOnGrid-DZ5DXYgb.js} +1 -1
  38. package/dist/assets/{abnfDiagram-YUKMZFIV-v0NjYm2N.js → abnfDiagram-YUKMZFIV-vvJbRPlq.js} +1 -1
  39. package/dist/assets/{activity-DONzM_Hr.js → activity-D26W1wR5.js} +1 -1
  40. package/dist/assets/{architectureDiagram-47P4ROYG-C9p47RSg.js → architectureDiagram-47P4ROYG-BxqUvVUX.js} +1 -1
  41. package/dist/assets/{blockDiagram-E7TT5TSB-BjCDCsDZ.js → blockDiagram-E7TT5TSB-DDe2YxQP.js} +1 -1
  42. package/dist/assets/{c4Diagram-CRA5TL53-BwcLeGrs.js → c4Diagram-CRA5TL53-OdUvGZP-.js} +1 -1
  43. package/dist/assets/{calendar-days-C0163EM9.js → calendar-days-OEtSVrLe.js} +1 -1
  44. package/dist/assets/channel-D_nJ6dC4.js +1 -0
  45. package/dist/assets/{chunk-2Q5K7J3B-DkMrEZ1P.js → chunk-2Q5K7J3B-DpnJlpzb.js} +1 -1
  46. package/dist/assets/{chunk-5VM5RSS4-BvT5jzrf.js → chunk-5VM5RSS4-C5UgOu8-.js} +1 -1
  47. package/dist/assets/{chunk-7TKQ45FW-BPY6DMgY.js → chunk-7TKQ45FW-Dv-gctKP.js} +1 -1
  48. package/dist/assets/{chunk-AW2ZBBNX-CA02FkCe.js → chunk-AW2ZBBNX-mehzuNgt.js} +1 -1
  49. package/dist/assets/{chunk-FVRAUYC3-DR_HIm4k.js → chunk-FVRAUYC3-6bArILty.js} +2 -2
  50. package/dist/assets/{chunk-HTAEGDNF--Q5YJ5qq.js → chunk-HTAEGDNF-0w6XIlls.js} +1 -1
  51. package/dist/assets/{chunk-JWPE2WC7-CdUxnp0z.js → chunk-JWPE2WC7-DaZro178.js} +1 -1
  52. package/dist/assets/{chunk-KQW6MTUR-CZ_kOJX4.js → chunk-KQW6MTUR-CqA51RiN.js} +1 -1
  53. package/dist/assets/{chunk-XXDRQBXY-Baw_LI4a.js → chunk-XXDRQBXY-DPZH_wOz.js} +1 -1
  54. package/dist/assets/{classDiagram-v2-K4WV4PDN-C3p6RSXv.js → classDiagram-v2-K4WV4PDN-Dgn2w_U2.js} +1 -1
  55. package/dist/assets/{coins-CRTGCu3d.js → coins-D0EwvaZf.js} +1 -1
  56. package/dist/assets/{core-C6iWxuTj.js → core-Lc3koHof.js} +1 -1
  57. package/dist/assets/{cose-bilkent-JH36ORCC-DexASxvw.js → cose-bilkent-JH36ORCC-B9lVmBnW.js} +1 -1
  58. package/dist/assets/{cynefin-EF2NZ3EQ-CnBYCH8E.js → cynefin-EF2NZ3EQ-BoirpSv2.js} +1 -1
  59. package/dist/assets/{cynefinDiagram-3GCD6N5R-BxlPVTxc.js → cynefinDiagram-3GCD6N5R-Cdmdj7_K.js} +1 -1
  60. package/dist/assets/{dagre-W4DXFKR2-DwHsGS35.js → dagre-W4DXFKR2-BFjlE582.js} +1 -1
  61. package/dist/assets/{diagram-2UJZ2QOL-BitCWJhQ.js → diagram-2UJZ2QOL-OsLSZez_.js} +1 -1
  62. package/dist/assets/{diagram-OVF4WLC6-DVq8AK9P.js → diagram-OVF4WLC6-CwDUdKBh.js} +1 -1
  63. package/dist/assets/{diagram-PFPMY2P6-B1CGGTYD.js → diagram-PFPMY2P6-BLtFTcT4.js} +1 -1
  64. package/dist/assets/{diagram-UMYRVEAY-BJOrT_fX.js → diagram-UMYRVEAY-BSLF9HqA.js} +1 -1
  65. package/dist/assets/{diagram-YEKJPTXX-CqTidMyp.js → diagram-YEKJPTXX-9rCjHXiY.js} +1 -1
  66. package/dist/assets/{diagram-ZIFT7M5P-BrETFWbJ.js → diagram-ZIFT7M5P-C4BY_KLT.js} +1 -1
  67. package/dist/assets/{ebnfDiagram-VR2GEFS7-odzlCiG_.js → ebnfDiagram-VR2GEFS7-AhQ5NsrM.js} +1 -1
  68. package/dist/assets/{elk-IJKZMXRS-DOqejjFU.js → elk-IJKZMXRS-UnH28E2R.js} +1 -1
  69. package/dist/assets/{erDiagram-O2IAPWRE-pus74-u1.js → erDiagram-O2IAPWRE-CO0nepRl.js} +1 -1
  70. package/dist/assets/{file-up-VlqNWssp.js → file-up-D-jXnd_Y.js} +1 -1
  71. package/dist/assets/{flowDiagram-OXPTDLAJ-BoR02YXy.js → flowDiagram-OXPTDLAJ-DdStYfx7.js} +1 -1
  72. package/dist/assets/{ganttDiagram-R7TSEDQI-DEWJjq9w.js → ganttDiagram-R7TSEDQI-DH8CA0Mt.js} +1 -1
  73. package/dist/assets/{gitGraphDiagram-XJZIOB7I-A0Ut1vzJ.js → gitGraphDiagram-XJZIOB7I-Ds4256L4.js} +1 -1
  74. package/dist/assets/{import-name-Dzn9IajS.js → import-name-CHPmMQSU.js} +1 -1
  75. package/dist/assets/{index-ByrnprY3.js → index-CFBg45ji.js} +1 -1
  76. package/dist/assets/{index-DoClz3zG.js → index-CGhQDBT_.js} +3 -3
  77. package/dist/assets/{infoDiagram-5W2HQ5XZ-IrI9xNS5.js → infoDiagram-5W2HQ5XZ-mNLO1zPg.js} +1 -1
  78. package/dist/assets/{ishikawaDiagram-K3B6WC7H-CcZaBkPV.js → ishikawaDiagram-K3B6WC7H-Daak_Ht_.js} +1 -1
  79. package/dist/assets/{journeyDiagram-COXZFDF6-Lhq1JIrG.js → journeyDiagram-COXZFDF6-U58GAPno.js} +1 -1
  80. package/dist/assets/{kanban-definition-P3RFRI5V-Dpnd1w1Z.js → kanban-definition-P3RFRI5V-CcRE6J9f.js} +1 -1
  81. package/dist/assets/{mermaid.core-CwYv1-pN.js → mermaid.core-QHRYQaNt.js} +4 -4
  82. package/dist/assets/{mindmap-definition-LZFPQGKD-BQu-1VuI.js → mindmap-definition-LZFPQGKD-CEyDomxS.js} +1 -1
  83. package/dist/assets/{minimize-BRtvUvR3.js → minimize-oQ71ZbVB.js} +1 -1
  84. package/dist/assets/{monitor-Gc_xwWHG.js → monitor-BmIglcrr.js} +1 -1
  85. package/dist/assets/{new-bot-CMIOaWIO.js → new-bot-tCPJjkMQ.js} +1 -1
  86. package/dist/assets/{org-library-CwIWLSKR.js → org-library-Dr5sX_Fu.js} +1 -1
  87. package/dist/assets/{package-format-C4Kbcf94.js → package-format-heZrOI7V.js} +1 -1
  88. package/dist/assets/{pegDiagram-BGZESJAR-C2kBJx8q.js → pegDiagram-BGZESJAR-CTxI-cP8.js} +1 -1
  89. package/dist/assets/{pieDiagram-CAPJLFHJ-3IGf8-rd.js → pieDiagram-CAPJLFHJ-B8DCNi6O.js} +1 -1
  90. package/dist/assets/{quadrantDiagram-GDMTTRAM-Ds0i1JJu.js → quadrantDiagram-GDMTTRAM-CWdpAW4W.js} +1 -1
  91. package/dist/assets/{rail-BxO9nJ7b.js → rail-WaxapGbo.js} +1 -1
  92. package/dist/assets/{railroadDiagram-SM67HX2B-C5HMZeLZ.js → railroadDiagram-SM67HX2B-BCY8OR1i.js} +1 -1
  93. package/dist/assets/{remote-desktop-panel-z23u6kyq.js → remote-desktop-panel-CRSqL4w9.js} +1 -1
  94. package/dist/assets/{requirementDiagram-X7JNWC4A-W7wEhXbS.js → requirementDiagram-X7JNWC4A-BcX43ufU.js} +1 -1
  95. package/dist/assets/{sankeyDiagram-UM26HJRW-BIIvZEMK.js → sankeyDiagram-UM26HJRW-C3YBTWo7.js} +1 -1
  96. package/dist/assets/{sequenceDiagram-ZO4K6R2Y-B6ZAapb0.js → sequenceDiagram-ZO4K6R2Y-CNLzalKN.js} +1 -1
  97. package/dist/assets/{sizeCapture-INFHLROL-CijBtoJ-.js → sizeCapture-INFHLROL-D55E_ZEd.js} +1 -1
  98. package/dist/assets/{stateDiagram-v2-TBUQTH76-gVAJTp58.js → stateDiagram-v2-TBUQTH76-CRDCsicX.js} +1 -1
  99. package/dist/assets/styles-Cr4TcnLq.css +1 -0
  100. package/dist/assets/{styles-Be5qq6WR.js → styles-D7SaLPZf.js} +2 -2
  101. package/dist/assets/{swimlanes-N4OXWK64-1T5CmmoT.js → swimlanes-N4OXWK64-Ah7OauuN.js} +1 -1
  102. package/dist/assets/swimlanesDiagram-K3J5GTZL-G_1ilp2C.js +8 -0
  103. package/dist/assets/{team-share-DZ71boDj.js → team-share-D3Hwdncm.js} +1 -1
  104. package/dist/assets/{timeline-definition-YOQAKGHF-b2WZ1F71.js → timeline-definition-YOQAKGHF-DV-V6CCB.js} +1 -1
  105. package/dist/assets/{usecaseDiagram-VIAY4XPW-DvPVm705.js → usecaseDiagram-VIAY4XPW-T9J5Wpir.js} +1 -1
  106. package/dist/assets/{vennDiagram-BLWOH2XV-BG-PWVxl.js → vennDiagram-BLWOH2XV-RqJjHEmQ.js} +1 -1
  107. package/dist/assets/{vi-DltOYiYl.js → vi-Bu86KxVI.js} +1 -1
  108. package/dist/assets/{wardleyDiagram-YMQ3BMBF-5xjAr3nW.js → wardleyDiagram-YMQ3BMBF-xZxQC8Rt.js} +1 -1
  109. package/dist/assets/{xychartDiagram-TAQBALBS-DgoVlD5n.js → xychartDiagram-TAQBALBS-BgPG2lil.js} +1 -1
  110. package/dist/index.html +3 -3
  111. package/dist/rail.html +6 -6
  112. package/dist-server/bot-box/box-check.js +6 -6
  113. package/dist-server/drivers/agents-proxy.js +50 -48
  114. package/dist-server/hybrid-plugin-gateway.js +1489 -0
  115. package/dist-server/index.js +5546 -5454
  116. package/dist-server/limixbot.js +517 -508
  117. package/dist-server/mcp-gate.js +76 -61
  118. package/dist-server/mcp-remote-proxy.js +26 -23
  119. package/dist-server/mcp-server.js +28 -25
  120. package/dist-server/package.json +1 -1
  121. package/dist-server/pair-cli.js +517 -508
  122. package/dist-server/scripts/mcp-server.js +30 -27
  123. package/dist-server/server/agents-turn.js +1 -0
  124. package/dist-server/server/auto-approve.js +2 -0
  125. package/dist-server/server/bot-box/env.js +2 -2
  126. package/dist-server/server/cli-usage.js +2 -2
  127. package/dist-server/server/drivers/acp/native-process-sampler.js +84 -0
  128. package/dist-server/server/drivers/acp/quiet-status.js +12 -3
  129. package/dist-server/server/drivers/agents-call.js +4 -0
  130. package/dist-server/server/drivers/agents-catalog-profile.js +1 -0
  131. package/dist-server/server/drivers/agents-catalog.js +16 -1
  132. package/dist-server/server/drivers/agents-mcp-env.js +1 -1
  133. package/dist-server/server/drivers/claude-elicitation.js +21 -9
  134. package/dist-server/server/drivers/elicited-consent.js +24 -0
  135. package/dist-server/server/headless/client.js +10 -9
  136. package/dist-server/server/headless/main.js +1 -1
  137. package/dist-server/server/hybrid-plugin-gateway.js +162 -0
  138. package/dist-server/server/hybrid-plugin-manifest.js +99 -0
  139. package/dist-server/server/index.js +41 -3
  140. package/dist-server/server/limix-native-path.js +8 -0
  141. package/dist-server/server/mcp-app-connections.js +58 -5
  142. package/dist-server/server/mcp-gate-tasks.js +75 -0
  143. package/dist-server/server/mcp-gate.js +81 -5
  144. package/dist-server/server/mcp-http.js +34 -6
  145. package/dist-server/server/mcp-native-response.js +112 -0
  146. package/dist-server/server/mcp-skills.js +263 -0
  147. package/dist-server/server/mcp-trim.js +15 -8
  148. package/dist-server/server/plugin-hub.js +259 -25
  149. package/dist-server/server/plugin-passages.js +16 -0
  150. package/dist-server/server/routes/plugin-mcp.js +118 -0
  151. package/dist-server/server/routes/plugin-studio.js +50 -0
  152. package/dist-server/server/side-jobs.js +1 -1
  153. package/dist-server/shared/plugin-hub.js +6 -2
  154. package/dist-server/vps-container-mcp.js +6 -6
  155. package/package.json +1 -1
  156. package/skills/limix-bot-factory/SKILL.md +2 -0
  157. package/skills/limix-bot-factory/assets/schemas/bot-spec.schema.json +14 -0
  158. package/skills/limix-bot-factory/references/integration-blueprint.md +1 -1
  159. package/skills/limix-bot-factory/references/vi.md +4 -0
  160. package/skills/limix-bot-factory/scripts/factorylib/cli.py +2 -1
  161. package/skills/limix-bot-factory/scripts/factorylib/core.py +19 -1
  162. package/skills/limix-bot-factory/scripts/factorylib/engine.py +10 -1
  163. package/skills/limix-bot-factory/scripts/mcp_server.py +3 -3
  164. package/dist/assets/BotSettingsDialog-81Yk4G56.js +0 -16
  165. package/dist/assets/BrowserPanel-BZiZr6JO.js +0 -3
  166. package/dist/assets/VisibilitySection-DdEr_5bZ.js +0 -22
  167. package/dist/assets/channel-BloV1v8U.js +0 -1
  168. package/dist/assets/mcp-servers-iT-sFJLT.js +0 -1
  169. package/dist/assets/styles-DiAFRlxu.css +0 -1
  170. package/dist/assets/swimlanesDiagram-K3J5GTZL-D0mOoyOD.js +0 -8
@@ -1552,12 +1552,12 @@ Connection: close\r
1552
1552
  Connection: close\r
1553
1553
  \r
1554
1554
  `)}),upstream.on("close",()=>client.destroy()),client.on("close",()=>upstream.destroy())}),new Promise((done,fail)=>{server.once("error",fail),server.listen(options.socketPath,()=>{server.off("error",fail),server.on("error",()=>{}),gate.close=()=>new Promise(closed=>{for(let socket of sockets)socket.destroy();server.close(()=>closed())}),done(gate)})})}var BOX_ENV_NAMES=new Set(["PATH","HOME","USER","LOGNAME","SHELL","HOSTNAME","PWD","LANG","LANGUAGE","TZ","TERM","COLORTERM","TMPDIR","NO_COLOR","FORCE_COLOR","CI","DEBUG","NODE_ENV","NODE_OPTIONS","NODE_EXTRA_CA_CERTS","NODE_USE_ENV_PROXY","SSL_CERT_FILE","SSL_CERT_DIR","CURL_CA_BUNDLE","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","XDG_CONFIG_HOME","XDG_DATA_HOME","XDG_CACHE_HOME","XDG_RUNTIME_DIR","DISPLAY","WAYLAND_DISPLAY","AGENT_BROWSER\
1555
- _EXECUTABLE_PATH","BROWSER","BASH_MAX_TIMEOUT_MS","ELECTRON_RUN_AS_NODE","PYTHONUNBUFFERED","PYTHONDONTWRITEBYTECODE","GIT_AUTHOR_NAME","GIT_AUTHOR_EMAIL","GIT_COMMITTER_NAME","GIT_COMMITTER_EMAIL"]),BOX_ENV_OMB_NAMES=new Set(["OMB_HARNESS_URL","OMB_BOT_ID","OMB_THREAD_ID","OMB_COMMS_TOKEN","OMB_EXTERNAL_RUNTIME","OMB_CHIEF_OF_STAFF","OMB_MAUSBOT","OMB_SKILL_AUTHORING_ENABLED","OMB_MEMORY_ENABLED","OMB_SHARED_COMPUTERS_ENABLED","OMB_VOICE_NOTES","OMB_X_RESEARCH","OMB_RESEARCH","OMB_TEAM_PEOPLE",
1556
- "OMB_COMPUTER_SELECTION","OMB_ROOM","OMB_IMAGE_GENERATION","OMB_MEETINGS","OMB_TOOLS_OFF","OMB_AGENTS_TOOL_BRIDGE","OMB_AGENTS_DEFER_TOOLS","OMB_TOOL_LIMIT","OMB_TOOL_SCHEMA_PROFILE","OMB_MCP_CONFIG","OMB_MCP_RESTART","OMB_MCP_RESULT_BUDGET","OMB_HOOK_URL","OMB_HOOK_TOKEN_FILE","OMB_HOOK_TIMEOUT_MS","OMB_PERMISSION_TOOL_SCOPE","OMB_CONNECTOR_UPSTREAM_URL","OMB_CONNECTOR_UPSTREAM_HEADERS","OMB_CONNECTOR_TOKEN","OMB_CONNECTOR_ALLOWED_TOOLS","OMB_CONNECTOR_SERVICE_SLUGS","OMB_CONNECTOR_APP_TOOLS","\
1557
- OMB_CONNECTOR_APP_TOOL_NAMES","OMB_GATE_NAME","OMB_GATE_UPSTREAM","OMB_GATE_BUDGET","OMB_GATE_SPILL_DIR","OMB_GATE_SPILL_HINT","OMB_GATE_TOOL_SCOPE","OMB_GATE_DIRECTORY","OMB_GATE_APPS","OMB_REMOTE_MCP_SERVER","OMB_REMOTE_MCP_DIRECTORY","OMB_REMOTE_MCP_APPS","OMB_CONTROL_URL","OMB_CONTROL_TOKEN","OMB_COMPUTER_JOURNAL","OMB_CUA_ARGS","OMB_CUA_COMMAND","OMB_CUA_PLATFORM","OMB_PHONE_TOKEN","OMB_ADB_PATH","OMB_RESOURCES_PATH","OMB_CODEX_AUTH_SOCKET","OMB_CODEX_AUTH_SECRET","OMB_COPILOT_MCP_CONFIG","\
1558
- OMB_BROWSER_PROFILE","OMB_BOX_PROBE","OMB_EXTRA_PATH","OMB_TEST_SEALED_PATH"]),BOX_ENV_OMB_PREFIXES=["OMB_MCP_TOKEN_","OMB_GATE_CONFIG_","OMB_REMOTE_MCP_CONFIG_"],BOX_ENV_PREFIXES=["LC_","OPENMAUSBOT_","NPM_CONFIG_","npm_config_","ANTHROPIC_","CLAUDE_","CODEX_","OPENAI_","OPENCODE_","OPENROUTER_","GEMINI_","GOOGLE_","GROK_","XAI_","MISTRAL_","CEREBRAS_","GROQ_","GREENFERENCE_","MODELGO_","META_","MINIMAX_","KIMI_","MOONSHOT_","CURSOR_","FACTORY_","CLINE_","HERMES_","MUSE_","PI_","DWEB_","UNSLOTH\
1559
- _","FAKE_CLAUDE_","MCP_","ANTIGRAVITY_","AGY_"],BOX_ENV_NEVER=new Set(["OMB_LICENSE_KEY","OMB_INSTALLATION_CREDENTIAL","OMB_LOOPBACK_TRUST","OMB_CLOUD_SECRETS_FD","OMB_DATA_DIR","OMB_STATIC_DIR","OMB_DUCKDB_DIR","OMB_PORT","OMB_WEBHOOK_PORT","OPENMAUSBOT_TOKEN","OPENMAUSBOT_URL"]),BOX_ENV_NEVER_PREFIXES=["OMB_CLOUD_"];function boxEnvironmentAllows(name,deny=new Set,allow=new Set){return BOX_ENV_NEVER.has(name)||BOX_ENV_NEVER_PREFIXES.some(prefix=>name.startsWith(prefix))?!1:allow.has(name)&&!name.
1560
- startsWith("OMB_")?!0:deny.has(name)?!1:name.startsWith("OMB_")?BOX_ENV_OMB_NAMES.has(name)||BOX_ENV_OMB_PREFIXES.some(prefix=>name.startsWith(prefix)):BOX_ENV_NAMES.has(name)||BOX_ENV_PREFIXES.some(prefix=>name.startsWith(prefix))}function boxEnvironment(env,deny=new Set,allow=new Set){let kept={};for(let[name,value]of Object.entries(env))value===void 0||!boxEnvironmentAllows(name,deny,allow)||(kept[name]=value);return kept}import{createServer as createServer4,request as httpRequest3}from"node:http";var HARNESS_GATE_PREFIX="/api/internal/";function harnessTarget(url2,allow=[HARNESS_GATE_PREFIX]){let raw=url2.split("?")[0];if(!raw.startsWith("/")||raw.startsWith("//")||raw.includes("..")||raw.includes("\\"))return null;let parsed;try{parsed=new URL(url2,"http://127.0.0.1")}catch{return null}return allow.some(prefix=>parsed.pathname.startsWith(prefix))?parsed.pathname+parsed.search:null}var HOP_BY_HOP3=new Set(["conn\
1555
+ _EXECUTABLE_PATH","BROWSER","BASH_MAX_TIMEOUT_MS","ELECTRON_RUN_AS_NODE","PYTHONUNBUFFERED","PYTHONDONTWRITEBYTECODE","GIT_AUTHOR_NAME","GIT_AUTHOR_EMAIL","GIT_COMMITTER_NAME","GIT_COMMITTER_EMAIL"]),BOX_ENV_OMB_NAMES=new Set(["OMB_HARNESS_URL","OMB_BOT_ID","OMB_THREAD_ID","OMB_COMMS_TOKEN","OMB_EXTERNAL_RUNTIME","OMB_CHIEF_OF_STAFF","OMB_MAUSBOT","OMB_PLUGIN_READ","OMB_SKILL_AUTHORING_ENABLED","OMB_MEMORY_ENABLED","OMB_SHARED_COMPUTERS_ENABLED","OMB_VOICE_NOTES","OMB_X_RESEARCH","OMB_RESEARCH",
1556
+ "OMB_TEAM_PEOPLE","OMB_COMPUTER_SELECTION","OMB_ROOM","OMB_IMAGE_GENERATION","OMB_MEETINGS","OMB_TOOLS_OFF","OMB_AGENTS_TOOL_BRIDGE","OMB_AGENTS_DEFER_TOOLS","OMB_TOOL_LIMIT","OMB_TOOL_SCHEMA_PROFILE","OMB_MCP_CONFIG","OMB_MCP_RESTART","OMB_MCP_RESULT_BUDGET","OMB_HOOK_URL","OMB_HOOK_TOKEN_FILE","OMB_HOOK_TIMEOUT_MS","OMB_PERMISSION_TOOL_SCOPE","OMB_CONNECTOR_UPSTREAM_URL","OMB_CONNECTOR_UPSTREAM_HEADERS","OMB_CONNECTOR_TOKEN","OMB_CONNECTOR_ALLOWED_TOOLS","OMB_CONNECTOR_SERVICE_SLUGS","OMB_CONN\
1557
+ ECTOR_APP_TOOLS","OMB_CONNECTOR_APP_TOOL_NAMES","OMB_GATE_NAME","OMB_GATE_UPSTREAM","OMB_GATE_BUDGET","OMB_GATE_SPILL_DIR","OMB_GATE_SPILL_HINT","OMB_GATE_TOOL_SCOPE","OMB_GATE_DIRECTORY","OMB_GATE_APPS","OMB_REMOTE_MCP_SERVER","OMB_REMOTE_MCP_DIRECTORY","OMB_REMOTE_MCP_APPS","OMB_CONTROL_URL","OMB_CONTROL_TOKEN","OMB_COMPUTER_JOURNAL","OMB_CUA_ARGS","OMB_CUA_COMMAND","OMB_CUA_PLATFORM","OMB_PHONE_TOKEN","OMB_ADB_PATH","OMB_RESOURCES_PATH","OMB_CODEX_AUTH_SOCKET","OMB_CODEX_AUTH_SECRET","OMB_COP\
1558
+ ILOT_MCP_CONFIG","OMB_BROWSER_PROFILE","OMB_BOX_PROBE","OMB_EXTRA_PATH","OMB_TEST_SEALED_PATH"]),BOX_ENV_OMB_PREFIXES=["OMB_MCP_TOKEN_","OMB_GATE_CONFIG_","OMB_REMOTE_MCP_CONFIG_"],BOX_ENV_PREFIXES=["LC_","OPENMAUSBOT_","NPM_CONFIG_","npm_config_","ANTHROPIC_","CLAUDE_","CODEX_","OPENAI_","OPENCODE_","OPENROUTER_","GEMINI_","GOOGLE_","GROK_","XAI_","MISTRAL_","CEREBRAS_","GROQ_","GREENFERENCE_","MODELGO_","META_","MINIMAX_","KIMI_","MOONSHOT_","CURSOR_","FACTORY_","CLINE_","HERMES_","MUSE_","PI_",
1559
+ "DWEB_","UNSLOTH_","FAKE_CLAUDE_","MCP_","ANTIGRAVITY_","AGY_"],BOX_ENV_NEVER=new Set(["OMB_LICENSE_KEY","OMB_INSTALLATION_CREDENTIAL","OMB_LOOPBACK_TRUST","OMB_CLOUD_SECRETS_FD","OMB_DATA_DIR","OMB_STATIC_DIR","OMB_DUCKDB_DIR","OMB_PORT","OMB_WEBHOOK_PORT","LIMIXBOT_TOKEN","LIMIXBOT_URL","OPENMAUSBOT_TOKEN","OPENMAUSBOT_URL"]),BOX_ENV_NEVER_PREFIXES=["OMB_CLOUD_"];function boxEnvironmentAllows(name,deny=new Set,allow=new Set){return BOX_ENV_NEVER.has(name)||BOX_ENV_NEVER_PREFIXES.some(prefix=>name.
1560
+ startsWith(prefix))?!1:allow.has(name)&&!name.startsWith("OMB_")?!0:deny.has(name)?!1:name.startsWith("OMB_")?BOX_ENV_OMB_NAMES.has(name)||BOX_ENV_OMB_PREFIXES.some(prefix=>name.startsWith(prefix)):BOX_ENV_NAMES.has(name)||BOX_ENV_PREFIXES.some(prefix=>name.startsWith(prefix))}function boxEnvironment(env,deny=new Set,allow=new Set){let kept={};for(let[name,value]of Object.entries(env))value===void 0||!boxEnvironmentAllows(name,deny,allow)||(kept[name]=value);return kept}import{createServer as createServer4,request as httpRequest3}from"node:http";var HARNESS_GATE_PREFIX="/api/internal/";function harnessTarget(url2,allow=[HARNESS_GATE_PREFIX]){let raw=url2.split("?")[0];if(!raw.startsWith("/")||raw.startsWith("//")||raw.includes("..")||raw.includes("\\"))return null;let parsed;try{parsed=new URL(url2,"http://127.0.0.1")}catch{return null}return allow.some(prefix=>parsed.pathname.startsWith(prefix))?parsed.pathname+parsed.search:null}var HOP_BY_HOP3=new Set(["conn\
1561
1561
  ection","keep-alive","transfer-encoding","te","trailer","upgrade","proxy-connection"]);function openHarnessGate(options){let allow=options.allow??[HARNESS_GATE_PREFIX],sockets=new Set,gate={socketPath:options.socketPath,refused:0},server=createServer4((req,res)=>{let target=harnessTarget(req.url??"",allow);if(target===null){gate.refused+=1,res.writeHead(403,{"content-type":"application/json"}).end(JSON.stringify({error:"not_a_harness_route"})),req.resume();return}let headers={};for(let[name,value]of Object.
1562
1562
  entries(req.headers))value!==void 0&&!HOP_BY_HOP3.has(name)&&(headers[name]=value);headers.host=`127.0.0.1:${options.port}`;let upstream=httpRequest3({host:"127.0.0.1",port:options.port,method:req.method,path:target,headers},answer=>{let out={};for(let[name,value]of Object.entries(answer.headers))value!==void 0&&!HOP_BY_HOP3.has(name)&&(out[name]=value);res.writeHead(answer.statusCode??502,out),answer.pipe(res)});upstream.on("error",()=>{res.headersSent?res.destroy():res.writeHead(502,{"content-\
1563
1563
  type":"application/json"}).end(JSON.stringify({error:"harness_unreachable"}))}),req.pipe(upstream),res.on("close",()=>upstream.destroy())});return server.on("connection",socket=>{sockets.add(socket),socket.once("close",()=>sockets.delete(socket))}),server.on("upgrade",(_req,socket)=>{gate.refused+=1,socket.on("error",()=>socket.destroy()),socket.end(`HTTP/1.1 403 Forbidden\r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "limixbot",
3
- "version": "0.3.129",
3
+ "version": "0.3.131",
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",
@@ -57,6 +57,8 @@ python scripts/bot_factory.py pack --spec ./drafts/demo-support.json --out ./dra
57
57
 
58
58
  If the user's request is a natural-language description, the coding agent must **translate** it into the draft's structured fields by editing `spec.json`, and rerun validation; the CLI intentionally does not make hidden model calls or guess integrations.
59
59
 
60
+ To request plugins already reviewed by the owner, repeat `--plugin ID@SHA256` with the exact digest from the plugin library. The MCP draft tool accepts the same pins separated by spaces in `plugin_pins`. Show them in the plan. The owner chooses the target bot in the plugin library, opens the BotSpec JSON and confirms the version assignments. Existing tool approvals still apply.
61
+
60
62
  ## Workflow
61
63
 
62
64
  1. Determine whether the user wants a reusable template or a specific bot instance.
@@ -23,6 +23,20 @@
23
23
  "skills_policy"
24
24
  ],
25
25
  "properties": {
26
+ "plugins": {
27
+ "type": "array",
28
+ "maxItems": 20,
29
+ "uniqueItems": true,
30
+ "items": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": ["id", "sha256"],
34
+ "properties": {
35
+ "id": { "type": "string", "maxLength": 80, "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$" },
36
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
37
+ }
38
+ }
39
+ },
26
40
  "schema_version": {
27
41
  "const": "1.1"
28
42
  },
@@ -1,6 +1,6 @@
1
1
  # Integrate Factory into the existing Limix Bot repository
2
2
 
3
- **Never assume Limix Bot is an unmodified upstream OpenMausBot checkout.** The user's source repository is authoritative.
3
+ **Verify integration points in the current Limix Bot checkout.** The user's source repository is authoritative.
4
4
 
5
5
  ## Phase 0: Read-only discovery
6
6
 
@@ -22,3 +22,7 @@ Ví dụ yêu cầu: “Tạo bot hỗ trợ cửa hàng, giải đáp bằng ti
22
22
  - Chỉ dùng các công cụ/nguồn kiến thức đã được hệ thống kiểm tra quyền.
23
23
  - Nếu nội dung tiếng Việt mâu thuẫn với `SKILL.md`, không tự sửa quy tắc lõi: báo lỗi và yêu cầu rà soát.
24
24
  - Các lệnh kiểm tra chỉ kiểm tra cấu trúc; chất lượng bản dịch và an toàn ngữ nghĩa vẫn cần rà soát trước khi đưa lên production.
25
+
26
+ ## Gắn phiên bản plugin vào Bot Mẫu
27
+
28
+ Trong Kho Plugin kết hợp, lấy ID và SHA-256 của từng phiên bản đã duyệt. Khi tạo bản nháp, thêm `--plugin ID@SHA256` cho mỗi plugin hoặc truyền danh sách vào `plugin_pins` của công cụ tạo bản nháp. Xem lại bằng lệnh `plan`. Để áp dụng, trong kho chọn bot đích, mở tệp BotSpec JSON rồi xác nhận danh sách phiên bản. Quyền dùng công cụ của bot vẫn do quản trị viên cấp riêng.
@@ -47,6 +47,7 @@ def parser() -> argparse.ArgumentParser:
47
47
  p_draft.add_argument("--requirements", default="", help="Raw user description; an AI agent must still refine BotSpec")
48
48
  p_draft.add_argument("--requirements-file", type=Path)
49
49
  p_draft.add_argument("--channel", action="append", dest="channels", help="Override template channels, repeatable")
50
+ p_draft.add_argument("--plugin", action="append", dest="plugins", metavar="ID@SHA256", help="Request a reviewed plugin revision for this bot, repeatable")
50
51
  p_draft.add_argument("--out", type=Path, required=True)
51
52
  p_draft.add_argument("--force", action="store_true")
52
53
  for cmd in ("validate", "plan", "evaluate"):
@@ -95,7 +96,7 @@ def run(argv: list[str] | None = None) -> int:
95
96
  description = args.requirements
96
97
  if args.requirements_file is not None:
97
98
  description = args.requirements_file.read_text(encoding="utf-8")
98
- draft = make_draft(args.template, args.id, args.tenant, args.name, description, args.channels)
99
+ draft = make_draft(args.template, args.id, args.tenant, args.name, description, args.channels, args.plugins)
99
100
  save_draft(draft, args.out, args.force)
100
101
  out({"created": str(args.out), "status": "draft", "deployment_ready": False})
101
102
  elif args.command == "validate":
@@ -92,8 +92,26 @@ def validate_spec(spec: Any) -> list[str]:
92
92
  if type(value) is not bool:
93
93
  errors.append(f"{where} must be a boolean")
94
94
 
95
- if not obj(spec, "spec", FIELDS["root"]):
95
+ fields = FIELDS["root"] | ({"plugins"} if isinstance(spec, dict) and "plugins" in spec else set())
96
+ if not obj(spec, "spec", fields):
96
97
  return errors
98
+ plugins = spec.get("plugins", [])
99
+ if not isinstance(plugins, list) or len(plugins) > 20:
100
+ errors.append("plugins must be a list of up to 20 version pins")
101
+ else:
102
+ seen_plugins: set[str] = set()
103
+ for pin in plugins:
104
+ if not obj(pin, "plugin", {"id", "sha256"}):
105
+ continue
106
+ plugin_id = pin["id"]
107
+ if not isinstance(plugin_id, str) or len(plugin_id) > 80 or not re.fullmatch(r"[a-z0-9]+(?:[.-][a-z0-9]+)*", plugin_id):
108
+ errors.append("Invalid plugin id")
109
+ elif plugin_id in seen_plugins:
110
+ errors.append("Duplicate plugin id")
111
+ else:
112
+ seen_plugins.add(plugin_id)
113
+ if not isinstance(pin["sha256"], str) or not re.fullmatch(r"[0-9a-f]{64}", pin["sha256"]):
114
+ errors.append("Each plugin requires an exact lowercase sha256")
97
115
  if spec.get("schema_version") != "1.1":
98
116
  errors.append("schema_version must be 1.1 (migrate legacy 1.0 drafts)")
99
117
  if not isinstance(spec.get("template_id"), str) or not SLUG.fullmatch(spec["template_id"]):
@@ -20,7 +20,7 @@ def canonical_json(obj: Any) -> bytes:
20
20
 
21
21
 
22
22
  def make_draft(template: str, bot_id: str, tenant_id: str, display_name: str,
23
- requirements: str, channels: list[str] | None = None) -> dict[str, Any]:
23
+ requirements: str, channels: list[str] | None = None, plugin_pins: list[str] | None = None) -> dict[str, Any]:
24
24
  spec = copy.deepcopy(load_template(template))
25
25
  spec["id"] = bot_id
26
26
  spec["tenant_id"] = tenant_id
@@ -29,6 +29,13 @@ def make_draft(template: str, bot_id: str, tenant_id: str, display_name: str,
29
29
  spec["summary"] = requirements.strip()
30
30
  if channels is not None:
31
31
  spec["channels"] = [{"kind": channel, "credential_ref": None} for channel in channels]
32
+ if plugin_pins:
33
+ spec["plugins"] = []
34
+ for value in plugin_pins:
35
+ plugin_id, separator, digest = value.partition("@")
36
+ if not separator:
37
+ raise ValueError("Plugin pin must use id@sha256")
38
+ spec["plugins"].append({"id": plugin_id, "sha256": digest})
32
39
  errors = validate_spec(spec)
33
40
  if errors:
34
41
  raise ValueError("Invalid draft: " + "; ".join(errors))
@@ -57,6 +64,8 @@ def plan(spec: dict[str, Any]) -> dict[str, Any]:
57
64
  required = [{"type": "channel", "name": c["kind"], "credential_ref_set": bool(c["credential_ref"]), "binding": "unverified"} for c in spec["channels"]]
58
65
  required += [{"type": "tool", "name": t["name"], "binding": "unverified", "human_approval": t["approval"] == "human"} for t in spec["tools"]]
59
66
  required += [{"type": "knowledge", "name": c, "binding": "unverified"} for c in spec["knowledge"]["collections"]]
67
+ required += [{"type": "plugin", "name": pin["id"], "sha256": pin["sha256"], "binding": "requires_owner_assignment"}
68
+ for pin in spec.get("plugins", [])]
60
69
  return {
61
70
  "valid": True,
62
71
  "template_id": spec["template_id"],
@@ -75,9 +75,9 @@ def factory_capabilities() -> dict:
75
75
 
76
76
  @mcp.tool()
77
77
  def factory_create_draft(template: str, bot_id: str, tenant_id: str,
78
- display_name: str, requirements: str) -> dict:
79
- """Create a local, unprivileged draft from a vetted template; never deploy."""
80
- spec = make_draft(template, bot_id, tenant_id, display_name, requirements)
78
+ display_name: str, requirements: str, plugin_pins: str = "") -> dict:
79
+ """Create a local draft. Optionally request space-separated id@sha256 plugin revisions for owner review."""
80
+ spec = make_draft(template, bot_id, tenant_id, display_name, requirements, plugin_pins=plugin_pins.split())
81
81
  path = _safe_path(tenant_id, bot_id)
82
82
  save_draft(spec, path)
83
83
  return {"draft_path": str(path), "status": "draft_only"}
@@ -1,16 +0,0 @@
1
- import{c as Ie,t as s,l as se,aF as Hs,j as e,i as $e,ae as fe,a as O,r as u,S as Xe,ah as Vt,X as et,d as dt}from"./styles-Be5qq6WR.js";import{fn as _s,fo as Ks,_ as tt,bE as Us,dq as Zt,C as qs,fp as Ws,fq as Vs,E as Gt,fr as Zs,M as Yt,eB as Gs,p as Ys,fs as pt,bu as mt,ft as Jt,j as G,u as $,fu as Js,ag as st,af as Qt,A as Xt,S as ye,ab as Ae,T as es,R as Qs,fv as Xs,fw as en,fx as tn,fy as sn,fz as nn,fA as ut,fB as an,fC as rn,fD as on,fE as ln,a$ as cn,fF as dn,fG as pn,fH as mn,I as un,fI as Pe,bY as nt,fJ as xn,aH as M,aN as ee,el as hn,dS as fn,fK as gn,aI as Ve,cw as yn,e5 as bn,e6 as vn,fL as kn,fM as ts,fN as ss,fO as jn,fP as wn,fQ as Nn,fR as Sn,dV as Ze,aq as xt,fS as Fe,fT as Cn,fU as Ee,au as Pn,fV as ns,fW as ht,aj as Ge,fX as On,fY as En,fZ as Rn,f_ as as,f$ as Tn,g0 as ft,g1 as In,g2 as An,g3 as Mn,g4 as X,aX as ae,aZ as Q,g5 as Ln,g6 as Bn,g7 as $n,dc as Fn,aP as Dn,G as zn,da as is,ai as Hn,g8 as V,aW as pe,g9 as me,x as N,ga as _n,dw as Kn,gb as Me,aY as oe,gc as Un,gd as qn,ge as Wn,ep as Vn,gf as gt,gg as Zn,gh as Gn,gi as Yn,gj as Jn,gk as Qn,gl as Xn,az as ea,gm as rs,gn as ta,go as sa,gp as na,gq as aa,gr as ia,gs as ra,gt as oa,gu as la,gv as ca,gw as da,gx as pa,gy as ma,gz as at,g as ua,B as Ye,gA as xa,gB as ha,gC as fa,gD as ga,gE as ya,gF as ba,c5 as va,gG as os,D as yt,f3 as ka,gH as bt,gI as ja,gJ as wa,cT as vt,bC as Na,d9 as Sa,gK as Ca,gL as ls,gM as Se,gN as kt,gO as Pa,aL as De,e7 as Oa,gP as Ea,aR as Ra,dA as Ta,cx as Ia,gQ as Aa,gR as Ma,gS as La,aT as Ba}from"./App-CFt1bVwj.js";import{v as cs,d as je,a0 as Re,a1 as $a,a2 as Fa,a3 as jt,a4 as ze,a5 as Da,a6 as za,a7 as Ha,a8 as _a,a9 as Ka,aa as wt,ab as Ua,ac as qa,L as Oe,M as Wa,B as Je,P as we,r as ds,ad as Va,$ as Za,u as ps}from"./PlacesRail-CAV7kW3Y.js";import{C as Ga}from"./coins-CRTGCu3d.js";import{C as ke,a as Ya}from"./MenuMotion-DG5tk0i3.js";import{b as te,m as ms,i as Qe,f as it,c as he,d as Nt,e as Te,o as Ja,g as Qa,h as de,n as He,t as us,s as rt,j as xs,k as Xa,l as ei,p as ti,r as hs,q as si,u as ni,w as ai,x as fs,y as gs,z as St,B as ii,C as ys,R as Ct,D as ri,E as oi,F as li,G as ci,H as di,J as pi,O as mi,K as ui,L as bs,N as Pt,V as xi,P as hi,M as fi,A as gi,a as yi,S as bi,I as vi}from"./VisibilitySection-DdEr_5bZ.js";import{s as ki,r as ji,a as wi,R as Ni}from"./ComputerFilesPane-Ce9ODuX8.js";import{M as Ot}from"./monitor-Gc_xwWHG.js";import{a as vs,m as ks,b as Si,c as Ci}from"./mcp-servers-iT-sFJLT.js";import{R as Pi}from"./RoutinesPage-Cims3t6g.js";import{S as Oi}from"./SignedInSites-Dp2PSLBK.js";import"./index-DoClz3zG.js";import"./org-library-CwIWLSKR.js";import"./package-format-C4Kbcf94.js";import"./WorksOnGrid-wPPuMbjR.js";import"./ProIntroduction-DgDPOYzn.js";import"./remote-desktop-DDRRx8uY.js";const Ei=[["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"}]],Ri=Ie("calendar-plus",Ei);const Ti=[["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"}]],Ii=Ie("library",Ti);const Ai=[["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"}]],js=Ie("slack",Ai);const Mi=[["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"}]],Li=Ie("tag",Mi),Bi=[{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:Ks,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:js,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:tt,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Us,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:Zt,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:Ii,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:qs,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:Ws,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:Vs,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:Gt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Zs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Yt,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:Gs,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:Ga,keywords:["tokens","cost","billing"]}],Et={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 $i(t,n=se()){if(!t||n==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const a=t.lastRun;if(a&&!Object.hasOwn(Et,a.status))return null;try{return[s("botOverview.routine.line",{schedule:Ys(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:pt(t.nextRunAt)})]:[],...a?[s(Et[a.status],{time:pt(a.at)})]:[]].join(" ")}catch{return null}}const Rt={"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"},Tt={"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 It(t,n){return!n||n.map(a=>a||"General").join(", ")!==t?t:n.map(a=>a||s("botAccess.teams.general")).join(", ")}const At=t=>Object.hasOwn(Tt,t)?s(Tt[t]):t,Mt=(t,n,a)=>Number(t)===1?n:a,Fi=[{line:/^Can talk to all (\d+) other bots, in any department\.$/,key:()=>"botOverview.line.talksToAll",params:([,t])=>({count:Number(t)})},{line:/^Also in charge of these departments: (.+)\.$/,key:()=>"botOverview.line.alsoInCharge",params:([,t],n)=>({departments:It(t,n)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>Mt(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])=>Mt(t,"botOverview.line.peersTeamsOne","botOverview.line.peersTeamsMany"),params:([,t])=>({count:Number(t)})},{line:/^Coordinates its (?:section|department) as Chief of Staff\.$/,key:()=>"botOverview.line.chief",params:()=>({role:s("sidebar.bot.chiefOfStaff")})},{line:/^May also coordinate these (?:teams|departments): (.+)\.$/,key:()=>"botOverview.line.alsoTeams",params:([,t],n)=>({teams:It(t,n)})}],Di=t=>se()!=="en"&&Object.hasOwn(Hs[se()]??{},t);function zi(t,n){for(const a of Fi){const l=a.line.exec(t);if(!l)continue;const i=a.key(l);return Di(i)?s(i,a.params(l,n)):t}return null}function _e(t,n){if(Object.hasOwn(Rt,t))return s(Rt[t]);const a=zi(t,n);if(a!==null)return a;const l=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(l)return s(l[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(l[1]),apps:l[2]});const i=se()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(i)return s("botOverview.line.computerNotOnCloud",{preference:At(i[1])});const o=/^Computer preference: (.+)\.$/.exec(t);if(o)return s("botOverview.line.computer",{preference:At(o[1])});const d=/^Works in (.+)\.$/.exec(t);if(d)return s("botOverview.line.folder",{folder:d[1]});const p=/^Knows how to (.+)\.$/.exec(t);if(p)return s("botOverview.line.skill",{skill:p[1]});const r=/^Listens for “(.+)” webhooks\.$/.exec(t);return r?s("botOverview.line.webhook",{name:r[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 Hi(t,n=se()){const a=/^(\w+): /.exec(t)?.[1];return n==="en"||!a||!Object.hasOwn(Lt,a)?t:`${s(Lt[a])}: ${t.slice(a.length+2)}`}function _i({data:t,error:n,open:a,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":a,className:"flex w-full items-center justify-between gap-3 text-left",children:[e.jsx("span",{className:"text-[15px] font-medium text-ink",children:t?s("botOverview.promptPreviewCount",{bytes:t.totalBytes.toLocaleString($e()),tokens:t.approxTokens.toLocaleString($e())}):s("botOverview.promptPreview")}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",a&&"rotate-180")})]}),a&&!t&&n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),a&&!t&&!n&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),a&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(i=>e.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:i.bytes.toLocaleString($e())})})]}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:i.text})]},i.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function Ki({overview:t,refreshError:n,prompt:a,promptError:l,onOpen:i,onSetup:o}){const[d,p]=u.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const c=(t.setup??[]).filter(f=>!f.done),m=(f,k)=>s(`botOverview.setup.${f}`)||k;return e.jsxs("div",{className:"flex flex-col gap-4",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),c.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botSetup.ideas")}),e.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:s("botSetup.optional")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:c.map(f=>e.jsx("li",{children:f.section?e.jsxs("button",{type:"button",onClick:()=>i(f.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:m(f.id,f.label)}),e.jsx(ke,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-secondary rtl:-scale-x-100"})]}):e.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[e.jsx(mt,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:m(f.id,f.label)})]})},f.id))}),o&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:o,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(tt,{size:14})," ",s("botSetup.withBot")]}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("botSetup.help")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:t.who.name}),t.who.title&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:t.who.title}),t.who.blurb&&e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:t.who.blurb}),t.who.soulLead&&e.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:t.who.soulLead}),e.jsx("button",{type:"button",onClick:()=>i("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:s("botOverview.readAll")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.does")}),t.does.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.doesEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.does.map((f,k)=>e.jsx("li",{children:$i(t.doesRoutines?.[k])??_e(f)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((f,k)=>e.jsx("li",{children:_e(f,t.managedSections)},k))})]}),e.jsx(_i,{data:a,error:l,open:d,onToggle:()=>p(f=>!f)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>i("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ke,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((f,k)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Hi(f.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",Jt(f.at)]})]},k))})]})]})}function Ui({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(cs,{size:14,"aria-hidden":"true"})]})]})}function qi(t){if(!t||typeof t!="object")return null;const{available:n,managementUrl:a}=t;if(n!==!0||typeof a!="string")return null;try{return new URL(a).protocol==="https:"?a:null}catch{return null}}function ws(t){const[n,a]=u.useState(null);return u.useEffect(()=>{const l=new AbortController;return G(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(i=>{l.signal.aborted||a({botId:t,url:qi(i)})}).catch(()=>{l.signal.aborted||a({botId:t,url:null})}),()=>l.abort()},[t]),n?.botId===t?n.url:null}const re="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Ke="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ie=t=>t instanceof Error?t.message:String(t);function Ns(t){const n=[],a=(i,o,d)=>{i&&n.push(s(i===1?o:d,{count:i}))};a(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),a(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),a(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),a(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=n.length?n.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Wi(t,n){const a=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?n:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=si(t.path),i=t.path===te?l:t.path===ni?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),o=d=>s(d===1?"memory.journal.line.one":"memory.journal.line.many",{count:d});return t.kind==="created"?s("memory.journal.created",{who:a,topic:i,detail:t.added?s("memory.journal.withLines",{lines:o(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:a,topic:i}):t.added&&!t.removed?s("memory.journal.added",{who:a,lines:o(t.added),topic:i}):t.removed&&!t.added?s("memory.journal.removed",{who:a,lines:o(t.removed),topic:i}):s("memory.journal.rewrote",{who:a,lines:o(Math.max(t.added,t.removed)),topic:i})}function Ss({changed:t,stale:n,busy:a,onReviewed:l}){return e.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s(n?"memory.lendingReviewStale":"memory.lendingReview")}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.lendingReviewChanged")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(i=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:i},i))})]}),e.jsx("button",{type:"button",className:O(re,"mt-3"),disabled:a,onClick:l,children:s("memory.lendingReviewed")})]})}function Vi({bot:t,active:n=!0,onToggle:a}){const{capabilities:l}=je(),[i,o]=u.useState(null),[d,p]=u.useState(null),[r,c]=u.useState(null),[m,f]=u.useState(null),[k,g]=u.useState(null),[v,j]=u.useState(null),[S,b]=u.useState(null),[w,x]=u.useState(!1),[P,L]=u.useState(null),[D,B]=u.useState(""),[I,H]=u.useState(null),[A,h]=u.useState(!1),[T,F]=u.useState(null),[_,K]=u.useState(!1),[J,Y]=u.useState(!1),{state:U,dispatch:y}=$(),z=Js(U.config),[le,ue]=u.useState(!1),[ge,E]=u.useState(""),q=async C=>{const[R,Le,zs]=await Promise.all([it(t.id),he(t.id),Nt(t.id).catch(()=>null)]);if(o(R),F(R.lendingReview??null),p(Le),H(zs),C){const Be=await Te(t.id,C);c({path:Be.path,text:Be.text,hash:Be.hash,dirty:!1,readOnly:C.startsWith("memory/log/")})}};u.useEffect(()=>{if(!n)return;let C=!1;j(null);const R=r?.dirty===!0;return q(R?void 0:r?.path??te).catch(Le=>{C||j(ie(Le))}),()=>{C=!0}},[n,t.id]);const Z=async C=>{j(null),f(null);try{const R=await Te(t.id,C);c({path:R.path,text:R.text,hash:R.hash,dirty:!1,readOnly:C.startsWith("memory/log/")})}catch(R){j(ie(R))}},W=async C=>{if(r){x(!0),j(null);try{const R=await rt(t.id,r.path,r.text,C);if(!R.ok){f({path:r.path,current:R.current,currentHash:R.currentHash});return}f(null),g(null),c({...r,text:R.doc.text,hash:R.doc.hash,dirty:!1}),o(R.overview),p(await he(t.id))}catch(R){j(ie(R))}finally{x(!1)}}},ce=()=>{!m||!r||(g(r.text),c({...r,text:m.current,hash:m.currentHash,dirty:!1}),f(null))},Ne=async C=>{if(window.confirm(s("memory.confirmDelete",{name:C.name}))){j(null);try{const{overview:R}=await xs(t.id,C.path);o(R),p(await he(t.id)),r?.path===C.path&&c(null)}catch(R){j(ie(R))}}},lt=async()=>{const C=Xa(D);if(!C){j(s("memory.topicNameError"));return}B(""),await Z(`memory/${C}`),c(R=>R&&{...R,dirty:!0,text:R.text||Zi(C)})},Ls=async C=>{L(C.id),j(null);try{const R=await hs(t.id,C.id);o(R.overview),p(await he(t.id)),r?.path===C.path&&!r.dirty&&c({...r,text:R.text,hash:R.hash}),b(s("memory.restored",{path:C.path}))}catch(R){j(ie(R))}finally{L(null)}},ct=async C=>{j(null),b(null);try{await Ja(t.id,C)}catch(R){j(ie(R))}},Bs=()=>{const C=t.memoryUpkeep===!1;y({type:"updateBot",botId:t.id,patch:{memoryUpkeep:C}}),H(R=>R&&{...R,enabled:C})},$s=async()=>{if(!le){ue(!0),E("");try{const C=await G("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!z}})});y({type:"configStatus",config:C})}catch(C){E(C instanceof Error?C.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},Fs=async()=>{h(!0),j(null),b(null);try{const{report:C,overview:R}=await us(t.id);o(R),p(await he(t.id)),H(await Nt(t.id)),r&&!r.dirty&&await Z(r.path),b(`${Ns(C)}.${C.note?` ${C.note}`:""}`)}catch(C){j(ie(C))}finally{h(!1)}},Ds=l.host.homeDir;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.title")}),e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.memoryEnabled!==!1,disabled:t.busy,onChange:C=>a(C.target.checked)}),s("memory.enable")]}),e.jsxs("p",{className:"mt-1 text-[13px] text-ink-secondary",children:[s("memory.enableHelp"),t.busy?` ${s("memory.busyHelp")}`:""]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.notesHelp")}),i&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:i.workspacePath,children:st(i.workspacePath,Ds)}),e.jsx("button",{type:"button",className:re,onClick:()=>{ct("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(re,"inline-flex items-center gap-1.5"),onClick:()=>{ct("folder")},children:[e.jsx(Qt,{size:14}),s("memory.showFileManager")]})]})]}),T&&e.jsx(Ss,{changed:T.changed,stale:_,busy:J,onReviewed:()=>{Y(!0),ms(t.id,T.token).then(()=>{F(null),K(!1)}).catch(C=>{if(C instanceof Xt&&C.status===409)return K(!0),q();j(ie(C))}).finally(()=>Y(!1))}}),i&&e.jsx(Yi,{index:i.index}),t.memoryEnabled!==!1&&e.jsx(Gi,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:Bs,onTidy:()=>{Fs()},rooms:{enabled:z,saving:le,error:ge,onToggle:()=>{$s()}}}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:r.path}),r.path!==te&&e.jsx("button",{type:"button",className:Ke,onClick:()=>{Z(te)},children:s("memory.backToIndex")})]}),m&&e.jsx(Cs,{botName:t.name,busy:w,onReload:ce,onOverwrite:()=>{W(m.currentHash)}}),e.jsx("textarea",{className:O(Qe,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:r.text,readOnly:r.readOnly,placeholder:r.path===te?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":r.path===te?s("memory.botMemory"):s("memory.fileLabel",{path:r.path}),onChange:C=>c({...r,text:C.target.value,dirty:!0})}),r.readOnly?e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.logsReadOnly")}):e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{W(r.hash)},disabled:w||!r.dirty,className:re,children:w?s("memory.saving"):s("memory.save")}),r.dirty&&e.jsx("button",{type:"button",className:Ke,disabled:w,onClick:()=>{Z(r.path)},children:s("memory.discard")})]}),k!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:k}),e.jsx("button",{type:"button",className:O(Ke,"mt-1"),onClick:()=>g(null),children:s("memory.dismissDraft")})]})]}),i&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx($t,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:i.topics,selected:r?.path,onOpen:C=>{Z(C.path)},onDelete:C=>{Ne(C)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(Qe,"py-1.5 text-[13px]"),value:D,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:C=>B(C.target.value),onKeyDown:C=>{C.key==="Enter"&&lt()}}),e.jsx("button",{type:"button",className:re,disabled:!D.trim(),onClick:()=>{lt()},children:s("memory.newTopic")})]}),i.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx($t,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:i.logs,selected:r?.path,onOpen:C=>{Z(C.path)},onDelete:C=>{Ne(C)}})})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.changes")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.changesHelp")}),e.jsx("div",{className:"mt-3",children:e.jsx(ot,{rows:d,botName:t.name,reverting:P,onRevert:C=>{Ls(C)}})})]}),S&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:S}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function Zi(t){return`---
2
- title: ${t.replace(/\.md$/,"")}
3
- description:
4
- aliases: []
5
- ---
6
-
7
- `}function Gi({enabled:t,status:n,tidying:a,onToggle:l,onTidy:i,rooms:o}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.upkeep.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.upkeep.help")})]}),e.jsx(ye,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&o&&e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:s("memory.learnFromRooms.title")}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.subtitle")}),n&&!n.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),o.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:o.error})]}),e.jsx(ye,{checked:o.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:o.saving,onClick:o.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&n&&!n.modelSteps&&e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.upkeep.noModelSteps")}),t&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",className:re,disabled:a,onClick:i,children:a?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[n?.lastTidy?s("memory.upkeep.lastTidy",{time:Re(n.lastTidy.at,se()),summary:Ns(n.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),n?.lastCapture&&He(n.lastCapture)?` ${s(He(n.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:He(n.lastCapture),time:Re(n.lastCapture.at,se())})}`:""]})]})]})}function Yi({index:t}){const n=Qa(t),a=n.level==="over"?"bg-danger":n.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",n.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[e.jsx("span",{className:"font-medium text-ink",children:s("memory.capacity.title")}),e.jsx("span",{className:O("text-[12px]",n.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes)})})]}),e.jsx(Bt,{label:s("memory.capacity.lines"),share:n.lineShare,fill:a}),e.jsx(Bt,{label:s("memory.capacity.size"),share:n.byteShare,fill:a}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",n.level==="over"?"text-danger":"text-ink-secondary"),children:n.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})}),n.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:de(t.bytes),maxBytes:de(t.maxBytes),maxLoaded:t.maxLines})})]})}function Bt({label:t,share:n,fill:a}){const l=`${Math.min(100,Math.round(n*100))}%`;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"w-10 shrink-0",children:t}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":s("memory.capacity.used",{label:t}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(n*100)),children:e.jsx("div",{className:O("h-full rounded-full",a),style:{width:l}})})]})}function Cs({botName:t,busy:n,onReload:a,onOverwrite:l}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:n,onClick:a,children:s("memory.reload")}),e.jsx("button",{type:"button",className:re,disabled:n,onClick:l,children:s("memory.overwrite")})]})]})}function $t({title:t,hint:n,files:a,selected:l,onOpen:i,onDelete:o}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:t}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:n}),a.length===0?e.jsx("div",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.noneYet")}):e.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:a.map(d=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===d.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>i(d),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:d.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[de(d.bytes)," · ",Re(d.modifiedAt,se())]})]}),e.jsx("button",{type:"button",onClick:()=>o(d),"aria-label":s("memory.deleteFile",{name:d.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(es,{size:14})})]},d.path))})]})}function ot({rows:t,botName:n,reverting:a,onRevert:l,now:i=Date.now()}){return t?t.length===0?e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.noChanges")}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(o=>{const d=ei(o),p=ti(o);return e.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{children:Wi(o,n)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Re(o.at,se(),i)}),d&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:p?s(p,o.threadTitle?{title:o.threadTitle}:void 0):d})]})]}),o.canRevert?e.jsxs("button",{type:"button",disabled:a!==null,onClick:()=>l(o),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(Qs,{size:12}),a===o.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:o.revertUnavailableReason,children:s("memory.cantUndo")})]}),o.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",o.added," −",o.removed," · ",s("memory.showChanged")]}),e.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[12px] leading-relaxed text-ink",children:o.diff})]})]},o.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Ji({bot:t,rows:n,refreshError:a,onRollback:l,rollingBack:i}){if(!n)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(n.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const o=[...n].sort((d,p)=>p.at-d.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),o.map(d=>e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{className:"text-ink-secondary",children:Jt(d.at)})," · ",e.jsxs("span",{children:[d.actor," via ",d.via]})," · ",e.jsx("span",{children:d.summary})]}),d.field==="soul"&&d.canRestore===!0&&e.jsx("button",{type:"button",disabled:i,onClick:()=>l(d.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:s("history.undo")})]}),d.field==="soul"&&d.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:d.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${d.id}`))]})}function Qi({bot:t,bare:n=!1}){const{state:a,dispatch:l}=$(),i=Xs(t),o=a.instances.find(d=>d.instanceId===t.modelSelection.instanceId);return i.turns===0?e.jsx("div",{className:O(n?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:n?void 0:"rounded-xl bg-card p-4",children:[!n&&e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("usage.title")}),e.jsxs("button",{onClick:()=>l({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ke,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:O("grid grid-cols-3 gap-3 text-[13px]",!n&&"mt-3"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colTurns")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:i.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:en(i)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:nn(i),children:tn(sn(i))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colCost")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:ut(i.costUsd)?an(i.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:ut(i.costUsd)?s("usage.costLine",{caption:rn(o?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Xi=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],er=["circle","rounded","square"],tr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},sr={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"},nr=t=>{const n=sr[t];return n?s(n):t};function ar({bot:t,activeState:n,onPatch:a,onClose:l}){const i=on(t,a),{fileRef:o,crop:d,uploading:p,generating:r,busy:c,error:m,upload:f,removeImage:k,generate:g}=i,v=d!=="mascot"&&!!t.avatarUrl,[j,S]=u.useState(v?"upload":"bot"),b=u.useRef(null);u.useEffect(()=>{b.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const w=h=>a(d==="mascot"?h:{...h,avatarCrop:"mascot"}),x=t.mascotBody??"cursor",P=$a(),L=Fa(t.mascotBody,t.color,P),[D,B]=u.useState(()=>!!P||jt(x)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=P&&L!==x&&jt(L)?ze(L):null,H=(h,T)=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":!v&&x===h,"aria-label":s("mascot.useBody",{name:T}),title:T,onClick:()=>w({mascotBody:h}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&x===h?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Wa,{color:t.color,faceColor:t.mascotFaceColor,bodyId:h,size:40,animated:!1,trackPointer:!1})},h),A=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,"data-look":"popover",onKeyDown:A,className:"popover-surface absolute inset-x-[-5px] top-[80px] z-30 overflow-hidden rounded-2xl border border-ink/[0.08] bg-menu text-left shadow-2xl shadow-black/50",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Xi.map(([h,T])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===h,"data-avatar-tab":h,onClick:()=>S(h),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===h?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(T)},h)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:c,onClick:()=>a(ln),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:Da.map(h=>H(h,ze(h)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:cn.map(h=>e.jsx("button",{type:"button",disabled:c,"aria-pressed":t.color===h,"aria-label":s("mascot.useColor",{color:_a(h)}),title:s(Ha[h]),onClick:()=>w({color:h}),className:O("size-6 rounded-full disabled:opacity-50",t.color===h&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:za(h)}},h))}),e.jsx(ai,{bot:t,disabled:c,onPatch:w}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":D,onClick:()=>B(h=>!h),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(fe,{size:13,"aria-hidden":"true",className:O("transition-transform",D&&"rotate-180")})]}),D&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[Ka.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:wt(h)}),h===P&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:wt(h)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":h,children:Ua[h].bodies.map(T=>H(T,ze(T)))})]},h)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),qa.map(h=>e.jsx("button",{type:"button",disabled:c,"data-avatar-face":h,"aria-pressed":n===h,onClick:()=>w({mascotExpression:h}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",n===h?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:nr(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(dn,{botLabel:t.title||t.name,disabled:p,generating:r,onGenerate:g})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(pn,{busy:c,onUpload:h=>{f(h)}}),v&&e.jsx(mn,{bot:t,disabled:c,onPatch:a}),e.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:h=>{f(h.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:c,onClick:()=>o.current?.click(),onDragOver:h=>h.preventDefault(),onDrop:h=>{h.preventDefault(),f(h.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[p?e.jsx(Oe,{size:22,className:"animate-spin"}):e.jsx(un,{size:22}),e.jsx("span",{children:s("botPanel.avatar.drop")}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:s("botPanel.avatar.types")})]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2.5",children:[e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:s("botPanel.avatar.shape")}),e.jsx(Pe,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?d:null,onChange:h=>a({avatarCrop:h}),options:er.map(h=>({value:h,label:s(tr[h]),disabled:c||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:k,disabled:c,"aria-label":s("botIdentity.removeAvatar"),title:s("botPanel.avatar.remove"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:e.jsx(es,{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 ir=()=>s("place.off");function Ps(t){const{dispatch:n}=$();return(a="computer")=>{fn(t.id,a),n({type:"toggleSettings",open:!1}),n({type:"toggleComputer",open:!0})}}function rr(t,n){const[a,l]=u.useState(null);return u.useEffect(()=>{if(!n)return;let i=!1;return G(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(o=>{i||l({botId:t.id,count:o.sites?.length??0})}).catch(()=>{}),()=>{i=!0}},[t.id,n]),a?.botId===t.id?a.count:null}function Os(t){const{state:n}=$(),{capabilities:a}=je(),l=a.host?.platform??"other",i=gn(t),o=t.computer??"auto",d=n.config?.browserEngine?.myChrome===!0&&(n.config?.browserProfiles??[]).some(g=>g.id===t.browserProfile&&g.browser==="chrome"),p=g=>g==="browser"&&d?s("settings.profiles.myChrome"):vn(g,l),r=g=>{const{view:v,reachable:j}=i[g];return{value:g,label:p(g),disabled:!j,hint:!j||bn(v)?v.line:void 0}},c=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...i.local.policy?[r("local")]:[],...i.browser.policy||o==="browser"?[r("browser")]:[],...i.cloud.policy?[r("cloud")]:[],...i.vm.policy||o==="vm"?[r("vm")]:[],...o==="off"?[{value:o,label:ir(),disabled:!0}]:[]],m=t.tasks?.find(g=>g.threadId===t.threadId)?.surface,f=m&&m!==o?p(m):null,k=c.find(g=>g.value===o)?.label??(o==="auto"||o==="off"?void 0:p(o));return{options:c,current:o,currentLabel:k,usingNow:f}}function or({bot:t,derived:n}){const{dispatch:a}=$(),{options:l,current:i,usingNow:o}=Os(t),[d,p]=u.useState(null),{patch:r,approvalMode:c}=n,m=f=>{if(!(f===i||f==="off")){if(f==="local"&&c==="auto"){p({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}r(f==="browser"?{computer:"browser",browser:!0}:{computer:f==="auto"?null:f})}};return e.jsxs(e.Fragment,{children:[e.jsx(M,{children:e.jsx("div",{role:"radiogroup","aria-label":s("computer.simple.whereWorks",{name:t.name}),className:"flex flex-col divide-y divide-ink/[0.05]",children:l.map(f=>e.jsx(Ve,{"data-panel-choice":f.value,title:f.label,hint:f.hint,checked:i===f.value,disabled:f.disabled,onClick:()=>m(f.value)},f.value))})}),o&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:o})}),e.jsx(yn,{open:d!==null,onCancel:()=>p(null),onConfirm:()=>{const f=d;p(null),f&&a({type:"updateBot",botId:f.botId,patch:f.patch})}})]})}function lr({bot:t,derived:n,onOpen:a}){const l=Ps(t),i=nt(),{browserEnabled:o}=n,d=rr(t,o&&t.computer!=="off"&&i!==!1),{currentLabel:p,usingNow:r}=Os(t),c=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(k=>k.kind==="screen"&&(k.hasImage||k.png)),f=m?xn({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")}: ${c}`,onClick:()=>l(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[f?e.jsx("img",{src:f,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(Je,{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(Je,{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(Ot,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:c}),e.jsxs(M,{anchor:"where",children:[e.jsx(ee,{"data-panel-page":"where",icon:Ot,title:s("computer.simple.whereWorks",{name:t.name}),hint:r?s("computer.simple.usingNow",{place:r}):void 0,value:p,onClick:()=>a("where")}),e.jsx(ee,{"data-panel-page":"browser",icon:hn,title:s("settings.sites.title"),value:d??void 0,onClick:()=>a("browser")})]})]})}const cr=3,Ft="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",dr=8,pr=200,xe=new Map,Ue=new Set,Dt=t=>`${t.threadId}@${as(t)}`;function mr(t,n){const[,a]=u.useState(0),i=n.filter(p=>p.threadId!==t.threadId).map(Dt).filter(p=>!xe.has(p)&&!Ue.has(p)).join(",");u.useEffect(()=>{if(i)for(const p of i.split(",")){Ue.add(p);const r=p.slice(0,p.lastIndexOf("@"));G(`/api/threads/${encodeURIComponent(r)}/messages?limit=${dr}`,{background:!0}).then(c=>{xe.set(p,Ge({messages:c.messages??[],activeLeafId:c.activeLeafId??void 0})),xe.size>pr&&xe.delete(xe.keys().next().value),a(m=>m+1)}).catch(()=>{}).finally(()=>Ue.delete(p))}},[i]);const o=Ge(t),d=new Map(n.map(p=>[p.threadId,Dt(p)]));return p=>p===t.threadId?o:xe.get(d.get(p)??"")}function ur({bot:t}){const{state:n,dispatch:a}=$(),l=kn(),i=!ts(ss,!0),[o,d]=u.useState(""),[p,r]=u.useState(!1),[c,m]=u.useState(!1),[f,k]=u.useState(!1),g=jn(n.config),v=u.useMemo(()=>{const{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}=wn(t.id,a,g);return{onRename:y,onRegenerateTitle:z,onDelete:le,onMove:ue,onPin:ge,onArchive:E}},[t.id,a,g]),j=Nn(t),S=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],b=(j?Sn({...t,tasks:S},j):S).filter(y=>!y.routineRunId).map(y=>{const z=Ze(t,y.threadId);return{...y,busy:z.busy,activity:z.activity,waitingForTeammates:z.waitingForTeammates,turnStartedAt:z.turnStartedAt??void 0,queued:!!n.pendingQueued[y.threadId]?.length}}),w=xt(b.filter(y=>!Fe(y)||y.threadId===t.threadId)),x=xt(b.filter(y=>Fe(y)&&y.threadId!==t.threadId)),P=o.trim(),L=w.filter((y,z)=>z<cr||y.threadId===t.threadId),D=mr(t,[...P||c?w:L,...f?x:[]]),B=y=>{const z=D(y);return z?On(Ze(t,y),z,n.instances,!1):void 0},I=Cn(w,P),H=P?[...I,...w.filter(y=>!I.includes(y)&&B(y.threadId)?.toLowerCase().includes(P.toLowerCase()))]:w,A=P?H:c?w:L,h=w.length-L.length,T=t.projects?.find(y=>y.id===t.tasks?.find(z=>z.threadId===t.threadId)?.projectId),F=()=>{i&&a({type:"toggleSettings",open:!1})},_=y=>{y.threadId!==t.threadId&&Tn(a,t,y.threadId,!1),F()},K=()=>{a({type:"newTask",botId:t.id,...T?{projectId:T.id}:{}}),F()},J=()=>{d(""),r(!1)},Y=w.length>=2||p||w.some(y=>y.threadId===t.threadId&&Fe(y)),U=y=>e.jsx("div",{role:"listitem","data-conversation":y.threadId,children:e.jsx(En,{panel:!0,preview:B(y.threadId),task:y,ownerId:t.id,current:y.threadId===t.threadId,folders:t.projects,now:Rn(as(y),l),locale:se(),onSelect:_,...v})},y.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(Ee,{action:Y&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":p,onClick:()=>p?J():r(!0),className:O("-me-1 flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink",p&&"bg-ink/[0.06] text-ink"),children:e.jsx(Xe,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",Y&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:K,className:O(ns,"flex-1"),children:[e.jsx(Pn,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&p&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:o,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Escape"&&(y.preventDefault(),y.stopPropagation(),J())},placeholder:s("botPanel.conversations.searchPlaceholder",{name:t.name}),"aria-label":s("botPanel.conversations.searchPlaceholder",{name:t.name}),className:"mb-1.5 w-full rounded-[8px] border border-hairline/60 bg-inset px-3 py-1.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-focus"}),Y&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",Ft),children:A.map(U)}),Y&&P&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:P})}),Y&&!P&&h>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":c,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:[c?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),c?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:h})]}),!P&&x.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":f,onClick:()=>k(y=>!y),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[f?e.jsx(ht,{size:14,"aria-hidden":"true"}):e.jsx(fe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:x.length})]}),!P&&f&&x.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:x.length}),className:O("flex flex-col gap-px",Ft),children:x.map(U)})]})}function xr({bot:t}){const{dispatch:n}=$(),a=Vt();return t.defaultBot?a?e.jsx(ft,{placement:"panel-card"}):e.jsxs(M,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:[In.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>n({type:"send",botId:t.id,text:s(l),threadId:t.threadId}),className:"flex h-9 w-full items-center px-3.5 text-left text-[14px] text-ink transition-colors hover:bg-ink/[0.03]",children:e.jsx("span",{className:"truncate",children:s(l)})},l)),e.jsx(ft,{placement:"panel"})]}):null}const hr=["find","start-fresh","usage","activity","inspector"];function fr({item:t}){const n=t.key==="usage";return e.jsxs("button",{type:"button","data-panel-item":t.key,disabled:t.disabled,title:t.title,"aria-pressed":t.active||void 0,onClick:t.onSelect,className:O(Q,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:O("min-w-0 truncate text-[14px] font-medium",!n&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",n?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ke,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function gr({bot:t,derived:n,onOpen:a}){const{items:l}=An(t),{dispatch:i}=$(),o=n.botRoutines.filter(p=>p.enabled).length,d=hr.flatMap(p=>l.filter(r=>r.key===p));return e.jsxs("div",{"data-panel-tabpanel":"details",children:[e.jsx("section",{"data-panel-card":"model",className:"pt-2",children:e.jsx("div",{"data-panel-row":"model",className:O(Q,"rounded-[8px]"),children:e.jsx(Mn,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(X,{icon:tt}),e.jsx(ae,{title:s("model.simple.model")})]})})})}),e.jsx(ur,{bot:t}),e.jsx(xr,{bot:t}),d.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(Ee,{children:s("botPanel.section.conversation")}),d.map(p=>e.jsx(fr,{item:p},p.key))]}),n.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(Ee,{action:e.jsx(Ln,{"data-panel-automations":"",onClick:()=>i({type:"showRoutines",view:"list"}),children:s("sidebar.nav.automations")}),children:s("botSettings.simple.routines")}),e.jsxs("button",{type:"button","data-panel-page":"routines",title:s("botPanel.routines.emptyHint"),onClick:()=>a("routines"),className:O(ns,"w-full"),children:[e.jsx(Ri,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(M,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(ee,{"data-panel-page":"routines",icon:Bn,title:s("botSettings.simple.routines"),value:o>0?s("botPanel.routinesOn",{count:o}):s("botPanel.none"),onClick:()=>a("routines")})})]})}const Es=/^\s*[-*]\s+(.+?)\s*$/;function yr(t){return t.split(`
8
- `).flatMap((n,a)=>{const l=Es.exec(n)?.[1];return l?[{line:a,text:l}]:[]})}function br(t,n){const a=t.split(`
9
- `);return Es.test(a[n]??"")?(a.splice(n,1),a.join(`
10
- `)):t}function vr(t,n){const a=t.replace(/\s+$/,""),l=`- ${n.trim().replace(/\s*\n\s*/g," ")}`;return a?`${a}
11
- ${l}
12
- `:`${l}
13
- `}function Rs(t){return t.flatMap(n=>{const a=yr(n.text).map(i=>({path:n.path,...i}));if(a.length||n.path===te)return a;const l=n.text.split(`
14
- `).map(i=>i.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:n.path,line:null,text:l}]:[]})}async function kr(t,n){if(!n)return[await Te(t,te)];const a=await it(t,!0);return Promise.all([te,...a.topics.map(l=>l.path)].map(l=>Te(t,l,!0)))}function Ts(t){const n=!!$().state.config?.team,[a,l]=u.useState({botId:t.id,docs:null,error:!1}),i=t.memoryEnabled!==!1,o=async(r,c)=>{try{const m=await kr(r,n);c?.()||l({botId:r,docs:m,error:!1})}catch{c?.()||l({botId:r,docs:null,error:!0})}},d=!!t.busy;u.useEffect(()=>{if(!i)return;let r=!1;return o(t.id,()=>r),()=>{r=!0}},[t.id,i,d,n]);const p=a.botId===t.id;return{docs:p?a.docs:null,error:p&&a.error,mine:n,setDoc:r=>l(c=>({botId:t.id,docs:(c.botId===t.id?c.docs??[]:[]).map(m=>m.path===r.path?r:m),error:!1})),reload:()=>o(t.id)}}function jr(t,n=Ge(t)){const a=[],l=[],i=new Set;for(const c of[...n].reverse()){const m=c.publishedPage;m?.state==="live"&&m.url&&!i.has(m.url)&&(i.add(m.url),a.push({messageId:c.id,title:m.title||m.url,url:m.url})),c.kind==="app"&&c.app?.doc&&l.push({messageId:c.id,title:c.app.title})}const o=ki(t),d=[],p=new Set;for(const c of o.values())p.has(c.file.path)||(p.add(c.file.path),d.push(c));const r=ji(t).filter(c=>!o.has(c));return{pages:a,apps:l,shared:d,unshared:r}}const wr=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function Is({bot:t,onOpen:n}){const{dispatch:a}=$(),{capabilities:l}=je(),i=$n(),o=!ts(ss,!0),d=fs(t),p=Ts(t),{pages:r,apps:c,shared:m,unshared:f}=u.useMemo(()=>jr(t),[t]),k=b=>{a({type:"focusMessage",threadId:t.threadId,messageId:b}),o&&a({type:"toggleSettings",open:!1})},g=d.skills.filter(gs).length,v=p.docs?Rs(p.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?p.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}),S=e.jsxs(M,{anchor:"keeps",children:[e.jsx(ee,{"data-panel-page":"memory",icon:Zt,title:s("botPanel.memoryRow"),value:j,onClick:()=>n("memory")}),e.jsx(ee,{"data-panel-page":"skills",icon:Fn,title:s("botSettings.simple.skills"),value:d.loading?void 0:g>0?g:s("botPanel.none"),onClick:()=>n("skills")}),e.jsx(ee,{"data-panel-page":"folder",icon:Dn,title:s("computer.files.folder"),value:t.cwd?st(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>n("folder")})]});return r.length+c.length+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")}),S]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[r.length>0&&e.jsx(M,{label:s("botPanel.library.pages"),anchor:"pages",children:r.map(b=>e.jsx(ee,{"data-panel-row":"page",icon:zn,title:e.jsx("span",{className:"block truncate",children:b.title}),hint:e.jsx("span",{className:"block truncate",children:b.url}),onClick:()=>i(b.url)},b.url))}),c.length>0&&e.jsx(M,{label:s("botPanel.library.apps"),anchor:"apps",children:c.map(b=>e.jsx(ee,{"data-panel-row":"app",icon:is,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(Ee,{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(Hn,{file:b.file,message:b.message,linked:b.file.linked,className:"w-full max-w-none"})},`${b.message.messageId}:${b.file.path}`)),f.map(b=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:wr(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")}),S]})}function Nr({bot:t,browserEnabled:n,onOpenBrowser:a}){const{state:l}=$(),i=nt(),o=t.browserProfile??"",d=(l.config?.browserProfiles??[]).find(m=>m.id===o),p=o==="guest",r=d?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,c=o&&!p?l.bots.filter(m=>m.browserProfile===o).map(m=>m.name):[t.name];return e.jsx(M,{anchor:"logins",children:n?p?e.jsx(V,{children:s("settings.profiles.temporaryHint")}):r?e.jsx(V,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[i!==!1&&(o===""||d)&&e.jsx(pe,{children:e.jsx(Oi,{bare:!0,target:{bot:t.id},sharedBy:c,disabled:!!t.busy},`${t.id}:${o}`)}),e.jsx(V,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(me,{"data-panel-action":"add-login",icon:we,onClick:a,children:s("botSettings.simple.addLogin")})]}):e.jsx(V,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const Sr=[["all",()=>N("Tất cả","All")],["added",()=>N("Bot đang có","On this bot")],["more",()=>N("Chưa thêm","Not added")]],Cr=t=>({bundled:N("Có sẵn","Built in"),library:N("Đã tải về","Downloaded"),imported:N("Từ máy tính","From this computer")})[t],qe="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-hairline/60 bg-raised px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50";async function zt(t,n){const a=await fetch(t,n===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)}),l=await a.json().catch(()=>({}));if(!a.ok)throw new Error(l.error??N(`Lỗi ${a.status}`,`Error ${a.status}`));return l.skills??[]}function Pr({botId:t,botName:n,onClose:a,onOpenSettings:l}){const[i,o]=u.useState(null),[d,p]=u.useState(""),[r,c]=u.useState("all"),[m,f]=u.useState(""),[k,g]=u.useState(""),v=`/api/limix/skill-store/${encodeURIComponent(t)}`;u.useEffect(()=>{let x=!1;return zt(v).then(P=>{x||o(P)}).catch(P=>{x||(o([]),g(P.message))}),()=>{x=!0}},[v]),u.useEffect(()=>{const x=P=>{P.key==="Escape"&&a()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a]);const j=u.useMemo(()=>{const x=d.trim().toLowerCase();return(i??[]).filter(P=>(r==="all"||(r==="added"?P.added:!P.added))&&(!x||`${P.name} ${P.description}`.toLowerCase().includes(x)))},[i,d,r]),S=async(x,P)=>{if(!m){f(x.name),g("");try{o(await zt(v,{name:x.name,kind:x.kind,add:P}))}catch(L){g(L instanceof Error?L.message:N("Không đổi được kỹ năng này.","Couldn't change this skill."))}finally{f("")}}},b=(i??[]).filter(x=>x.added).length,w=e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-6",onMouseDown:x=>x.stopPropagation(),children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"limix-skill-store-title",className:"flex max-h-full w-full max-w-[640px] flex-col rounded-2xl border border-hairline/50 bg-panel shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 px-6 pb-3 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"limix-skill-store-title",className:"text-[17px] font-semibold text-ink",children:N("Kho kỹ năng","Skills Store")}),e.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:N(`Chọn kỹ năng cho ${n}. Bot sẽ nhận hướng dẫn của những kỹ năng bạn thêm. Để dùng một kỹ năng, gõ dấu / rồi nhập tên kỹ năng trong khung chat.`,`Pick skills just for ${n}. Only added skills go into the bot's prompt, so it never gets overloaded. Type /skill-name in chat to call one.`)})]}),e.jsx("button",{type:"button",onClick:a,"aria-label":N("Đóng","Close"),className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised hover:text-ink",children:e.jsx(et,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-6 pb-3",children:[e.jsxs("label",{className:"flex min-w-[200px] flex-1 items-center gap-2 rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsx(Xe,{size:14,className:"text-ink-tertiary"}),e.jsx("input",{value:d,onChange:x=>p(x.target.value),placeholder:N("Tìm kỹ năng…","Search skills…"),"aria-label":N("Tìm kỹ năng","Search skills"),className:"w-full bg-transparent text-[14px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsx("div",{className:"flex gap-1",role:"tablist","aria-label":N("Lọc kỹ năng","Filter skills"),children:Sr.map(([x,P])=>e.jsxs("button",{type:"button",role:"tab","aria-selected":r===x,onClick:()=>c(x),className:`rounded-lg px-2.5 py-1.5 text-[13px] ${r===x?"bg-raised text-ink":"text-ink-secondary hover:bg-raised"}`,children:[P(),x==="added"&&i?` ${b}`:""]},x))})]}),k&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[12px] text-danger",children:k}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6",children:i===null?e.jsxs("p",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(Oe,{size:14,className:"animate-spin"}),N("Đang tải kho…","Loading the store…")]}):j.length===0?e.jsx("p",{className:"py-6 text-[13px] text-ink-secondary",children:i.length===0?N("Kho chưa có kỹ năng nào.","The store has no skills yet."):N("Không tìm thấy kỹ năng phù hợp.","No matching skills.")}):e.jsx("ul",{className:"flex flex-col divide-y divide-hairline/40 rounded-xl border border-hairline/40",children:j.map(x=>e.jsxs("li",{className:"flex items-start gap-3 px-3 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-mono text-[13px] text-ink",children:x.name}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:x.core?N("Kỹ năng gốc","Core skill"):Cr(x.kind)}),x.warnings>0&&e.jsxs("span",{className:"text-[12px] text-warning",children:[x.warnings," ",N("cảnh báo","warnings")]})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] leading-relaxed text-ink-secondary",children:x.description})]}),x.core?e.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 px-1 py-1.5 text-[12px] text-ink-secondary",children:[e.jsx(dt,{size:14}),N("Luôn bật","Always on")]}):x.added?e.jsxs("button",{type:"button",className:qe,disabled:!!m,onClick:()=>{S(x,!1)},"aria-label":N(`Bỏ ${x.name} khỏi bot`,`Remove ${x.name} from this bot`),children:[m===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(dt,{size:14}),N("Đã thêm","Added")]}):e.jsxs("button",{type:"button",className:qe,disabled:!!m||!x.ready,onClick:()=>{S(x,!0)},"aria-label":N(`Thêm ${x.name} cho bot`,`Add ${x.name} to this bot`),children:[m===x.name?e.jsx(Oe,{size:14,className:"animate-spin"}):e.jsx(we,{size:14}),N("Thêm","Add")]})]},`${x.kind}:${x.name}`))})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 pb-5 pt-3",children:[e.jsx("p",{className:"text-[12px] text-ink-tertiary",children:N('Bấm "Đã thêm" để bỏ kỹ năng khỏi bot này.','Press "Added" to remove a skill from this bot.')}),e.jsx("button",{type:"button",className:qe,onClick:l,children:N("Tải thêm kỹ năng","Get more skills")})]})]})});return typeof document>"u"?w:ds.createPortal(w,document.body)}const be=()=>window.ogb?.limixMessenger,Ht=[{kind:"telegram",label:"Telegram",placeholder:"123456789:AA…",howTo:()=>N("Tạo bot với @BotFather (lệnh /newbot), rồi dán token vào đây.","Make a bot with @BotFather (/newbot), then paste its token here."),where:t=>`@${t.username}`,linkFrom:t=>N(`Nhắn cho @${t.username}: `,`Send @${t.username}: `)},{kind:"discord",label:"Discord",placeholder:"MTA…",howTo:()=>N("Vào discord.com/developers → New Application → Bot → Reset Token, dán token vào đây. Mời bot vào server: OAuth2 → URL Generator → chọn bot và quyền Send Messages. Trong server, gọi bot bằng @tên-bot.","At discord.com/developers: New Application → Bot → Reset Token, paste it here. Invite it with OAuth2 → URL Generator (bot, Send Messages). In a server, call it with @its-name."),where:t=>`@${t.username}`,linkFrom:()=>N("Nhắn riêng cho bot trên Discord: ","Send the bot a direct message on Discord: ")},{kind:"zalo",label:"Zalo",howTo:()=>N("Quét mã QR bằng ứng dụng Zalo của tài khoản sẽ làm bot.","Scan the QR code with the Zalo app of the account that will be the bot."),note:()=>N("Nên dùng tài khoản Zalo phụ: đây là cách đăng nhập không chính thức (như Zalo Web), Zalo có thể khoá tài khoản. Mở Zalo Web bằng tài khoản này ở nơi khác sẽ ngắt bot.","Use a spare Zalo account: this sign-in is unofficial (like Zalo Web) and Zalo may lock the account. Opening Zalo Web with it elsewhere disconnects the bot."),where:t=>t.name||t.username||"Zalo",linkFrom:()=>N("Từ Zalo của bạn, nhắn cho tài khoản bot: ","From your own Zalo, message the bot's account: ")},{kind:"facebook",label:"Facebook Page",placeholder:"EAA…",howTo:()=>N("Dán Page Access Token: developers.facebook.com → tạo app → thêm Messenger → Access Tokens → chọn Page → Generate token.","Paste a Page access token: developers.facebook.com → create an app → add Messenger → Access Tokens → pick the Page → Generate token."),note:()=>N("Bot trả lời khách nhắn vào Page sau khoảng 10–20 giây. Muốn trả lời mọi khách, app Meta cần được duyệt quyền pages_messaging.","The bot answers people who message the Page within about 10–20 seconds. To answer everyone, the Meta app needs pages_messaging approved."),where:t=>t.name||"Page",linkFrom:()=>N("Từ Facebook cá nhân, nhắn cho Page: ","From your own Facebook, message the Page: ")},{kind:"messenger",label:"Messenger",howTo:()=>N("Đăng nhập Facebook trong cửa sổ của app (nhập cả mã PIN khôi phục tin nhắn nếu Facebook hỏi), rồi đóng cửa sổ. App giữ một cửa sổ Facebook ẩn, đọc tin mới và gõ câu trả lời.","Sign in to Facebook in the app's window (enter the chat-restore PIN if Facebook asks), then close it. The app keeps a hidden Facebook window that reads new messages and types the replies."),note:()=>N("Thử nghiệm, tài khoản cá nhân. Chỉ chạy khi app đang mở trên máy này. Nên dùng tài khoản phụ: Facebook không có cách chính thức cho tài khoản cá nhân và có thể khoá tài khoản. Ai nhắn cũng được trả lời ở chế độ an toàn.","Beta, personal accounts. Runs only while the app is open on this computer. Use a spare account: Facebook has no official way for personal accounts and may lock it. Everyone is answered in safe mode."),where:()=>N("tài khoản Facebook đã đăng nhập","the signed-in Facebook account"),linkFrom:()=>""}],ne="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:cursor-not-allowed disabled:opacity-50";function Or({bot:t,className:n}){const[a,l]=u.useState("telegram"),[i,o]=u.useState({});u.useEffect(()=>{let r=!0;o({});for(const c of Ht.filter(m=>m.kind!=="messenger"||be()))G(`/api/bots/${t.id}/${c.kind}`).then(m=>{r&&o(f=>({...f,[c.kind]:m}))}).catch(()=>{});return()=>{r=!1}},[t.id]);const d=Ht.filter(r=>r.kind!=="messenger"||be()),p=d.find(r=>r.kind===a);return e.jsxs("div",{className:O("rounded-xl bg-card p-4",n),"data-testid":"channels-card",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:N("Kênh chat","Chat channels")}),e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:N(`Cho ${t.name} trả lời tin nhắn ngoài app.`,`Let ${t.name} answer messages outside the app.`)}),e.jsx("div",{role:"tablist",className:"mt-3 flex flex-wrap gap-1.5",children:d.map(r=>{const c=i[r.kind];return e.jsxs("button",{type:"button",role:"tab","aria-selected":a===r.kind,onClick:()=>l(r.kind),"data-testid":`channel-tab-${r.kind}`,className:O("flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-[13px]",a===r.kind?"bg-control text-ink":"text-ink-secondary hover:bg-raised-hover"),children:[c?.connected&&e.jsx("span",{className:O("size-1.5 rounded-full",c.error?"bg-danger":c.enabled?"bg-success":"bg-ink-tertiary")}),r.label]},r.kind)})}),e.jsx(Er,{bot:t,channel:p,view:i[a],onView:r=>o(c=>({...c,[a]:r}))},`${t.id}:${a}`)]})}function Er({bot:t,channel:n,view:a,onView:l}){const i=`/api/bots/${t.id}/${n.kind}`,[o,d]=u.useState(""),[p,r]=u.useState(null),[c,m]=u.useState(!1),[f,k]=u.useState(null),g=!!(a?.login&&!a.login.error&&!a.connected);u.useEffect(()=>{if(!g&&!p)return;let S=!0;const b=setInterval(()=>{G(i).then(w=>{S&&(l(w),w.linkExpiresAt||r(null))}).catch(()=>{})},2e3);return()=>{S=!1,clearInterval(b)}},[g,p,i,l]);const v=async S=>{m(!0),k(null);try{const{code:b,...w}=await S();l(w),b&&r(b)}catch(b){k(b instanceof Error?b.message:String(b))}finally{m(!1)}},j=(S,b="")=>v(()=>G(`${i}${b}`,{method:"POST",body:JSON.stringify(S??{})}));return a?e.jsxs("div",{className:"mt-3 text-[13px]","data-testid":`channel-${n.kind}`,children:[!a.connected&&e.jsxs("div",{className:"flex flex-col gap-2 text-ink-secondary",children:[e.jsx("span",{children:n.howTo()}),n.note&&e.jsx("span",{className:"text-[12px]",children:n.note()}),n.placeholder?e.jsxs("form",{className:"flex gap-2",onSubmit:S=>{S.preventDefault(),o.trim()&&j({token:o.trim()}).then(()=>d(""))},children:[e.jsx("input",{type:"password",autoComplete:"off",spellCheck:!1,value:o,onChange:S=>d(S.target.value),placeholder:n.placeholder,"aria-label":N(`Token ${n.label}`,`${n.label} token`),className:"min-w-0 flex-1 rounded-lg bg-inset px-3 py-1.5 font-mono text-[13px] text-ink outline-none","data-testid":`channel-token-${n.kind}`}),e.jsx("button",{type:"submit",disabled:c||!o.trim(),className:ne,"data-testid":`channel-connect-${n.kind}`,children:N("Kết nối","Connect")})]}):n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ne,"self-start"),disabled:c,onClick:()=>{v(async()=>await be().signIn(t.id))},"data-testid":"channel-signin-messenger",children:N("Mở cửa sổ đăng nhập Facebook","Open the Facebook sign-in window")}):e.jsx(Rr,{view:a,busy:c,start:()=>{j({},"/login")},cancel:()=>{v(()=>G(`${i}/login`,{method:"DELETE"}))}})]}),a.connected&&e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsx("span",{children:N(`${t.name} trả lời tin nhắn gửi tới ${n.where(a)}.`,`${t.name} answers messages sent to ${n.where(a)}.`)}),e.jsx(ye,{"aria-label":N(`Bật ${n.label}`,`${n.label} on`),checked:a.enabled===!0,disabled:c,onClick:()=>{j({enabled:!a.enabled})},"data-testid":`channel-switch-${n.kind}`})]}),n.note&&(n.kind==="facebook"||n.kind==="messenger")&&e.jsx("span",{className:"text-[12px] text-ink-secondary",children:n.note()}),n.kind==="messenger"?e.jsx("button",{type:"button",className:O(ne,"self-start"),onClick:()=>{be()?.show(t.id)},children:N("Mở cửa sổ Messenger của bot","Show the bot's Messenger window")}):e.jsxs("div",{className:"flex flex-col gap-2 text-ink-secondary",children:[a.owner&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:N(`Chủ bot: ${a.owner}`,`Owner: ${a.owner}`)}),e.jsx("button",{type:"button",className:ne,disabled:c,onClick:()=>{j({},"/unlink")},children:N("Bỏ liên kết","Unlink")})]}),a.admins?.map(S=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:s("channels.admin.account",{name:S.name,id:S.id})}),e.jsx("button",{type:"button",className:ne,disabled:c,"aria-label":s("channels.admin.removeNamed",{name:S.name,id:S.id}),onClick:()=>{j({id:S.id},"/remove-admin")},children:s("channels.admin.remove")})]},S.id)),e.jsx("span",{children:s("channels.admin.explain")}),p&&a.linkExpiresAt?e.jsxs("span",{className:"text-ink","data-testid":`channel-code-${n.kind}`,children:[n.linkFrom(a),e.jsxs("code",{className:"rounded bg-inset px-1.5 py-0.5 font-mono",children:["/link ",p]}),N(" (hết hạn sau 15 phút)"," (expires in 15 minutes)")]}):e.jsx("button",{type:"button",className:O(ne,"self-start"),disabled:c,onClick:()=>{j({},"/link")},"data-testid":`channel-link-${n.kind}`,children:a.owner?s("channels.admin.invite"):N("Tạo mã liên kết","Make a link code")})]}),e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời cả người khác","Answer other people too"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:n.kind==="zalo"?N("Người khác có thể nhắn riêng cho bot với quyền khách.","Other people can message the bot privately as guests."):N("Người khác và nhóm nhắn được bot ở chế độ an toàn: không dùng công cụ, không thấy cuộc trò chuyện của bạn.","Others and groups can write to the bot in safe mode: no tools, none of your conversations.")})]}),e.jsx(ye,{"aria-label":N("Trả lời cả người khác","Answer other people too"),checked:a.access==="everyone",disabled:c,onClick:()=>{j({access:a.access==="everyone"?"owner":"everyone",...a.groupMentions!==void 0?{groupMentions:a.groupMentions}:{}})},"data-testid":`channel-everyone-${n.kind}`})]}),n.kind==="zalo"&&e.jsxs("label",{className:"flex items-center justify-between gap-3 text-ink",children:[e.jsxs("span",{children:[N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),e.jsx("span",{className:"block text-[12px] text-ink-secondary",children:N("Chủ bot đã liên kết luôn có toàn quyền khi gọi bot trong nhóm. Bật tùy chọn này để các thành viên khác cũng có thể gọi bot với quyền khách.","The linked owner always has full access when mentioning the bot in a group. Turn this on to let other members mention it with guest access.")})]}),e.jsx(ye,{"aria-label":N("Trả lời khi được @gọi trong nhóm","Reply to @mentions in groups"),checked:a.groupMentions??a.access==="everyone",disabled:c,onClick:()=>{j({groupMentions:!(a.groupMentions??a.access==="everyone")})},"data-testid":"channel-zalo-group-mentions"})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",className:ne,disabled:c,onClick:()=>{v(async()=>{const S=await G(i,{method:"DELETE"});return n.kind==="messenger"&&await be()?.signOut(t.id),S})},"data-testid":`channel-remove-${n.kind}`,children:N("Gỡ kết nối","Disconnect")})})]}),(f||a.error)&&e.jsx("div",{role:"alert",className:"mt-2 text-[13px] text-danger",children:f??a.error})]}):e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:"…"})}function Rr({view:t,busy:n,start:a,cancel:l}){const i=t.login;return!i||i.error?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[i?.error&&e.jsx("span",{className:"text-danger",children:i.error}),e.jsx("button",{type:"button",className:O(ne,"self-start"),disabled:n,onClick:a,"data-testid":"channel-qr-zalo",children:N("Tạo mã QR đăng nhập","Show a sign-in QR code")})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[i.qr?e.jsx("img",{src:i.qr,alt:N("Mã QR đăng nhập Zalo","Zalo sign-in QR code"),className:"size-44 rounded-lg bg-white p-1.5","data-testid":"channel-qr-image"}):e.jsx("div",{className:"flex size-44 items-center justify-center rounded-lg bg-inset",children:"…"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-ink",children:i.scanned?N(`${i.scanned} đã quét. Xác nhận đăng nhập trong ứng dụng Zalo.`,`${i.scanned} scanned it. Confirm the sign-in in the Zalo app.`):N("Mở Zalo trên điện thoại → biểu tượng quét mã → quét mã này.","Open Zalo on the phone → scan icon → scan this code.")}),e.jsx("button",{type:"button",className:O(ne,"self-start"),onClick:l,children:N("Huỷ","Cancel")})]})]})}const Tr=5,Ir={instanceId:"",model:""},As=(t,n)=>`${t}\0${n}`,Ar=new Set;function _t({bot:t,current:n,exclude:a,onPick:l,label:i,title:o,buttonRef:d,className:p,children:r,...c}){const{state:m,dispatch:f,refreshInstances:k,refreshModels:g}=$(),[v,j]=u.useState(!1),[S,b]=u.useState(""),[w,x]=u.useState(()=>new Set),[P,L]=u.useState(!1),[D,B]=u.useState(null),[I,H]=u.useState(null),A=u.useRef(null),h=d??A,T=u.useRef(null),F=u.useRef(null),_=u.useRef(!1),K=u.useId(),J=Ya(v),Y=u.useRef({contains:E=>[h.current,T.current].some(q=>q?.contains(E))});Vn(v,Y,()=>j(!1)),u.useLayoutEffect(()=>{if(!v)return;const E=q=>{if(q?.type==="scroll"&&q.target instanceof Node&&T.current?.contains(q.target))return;const Z=h.current?.getBoundingClientRect(),W=T.current;!Z||!W||H(ce=>Yn(Z,{width:gt,height:W.offsetHeight},{width:window.innerWidth,height:window.innerHeight},ce??void 0))};return E(),window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[v,h]),u.useEffect(()=>{if(!v||!I||!_.current)return;_.current=!1;const E=T.current;(E?.querySelector("[data-menu-search]")??E?.querySelector("[data-current-model]")??E?.querySelector("[data-menu-row]:not(:disabled)")??E)?.focus({preventScroll:!0})},[v,I]);const U=E=>{j(!1),E&&h.current?.focus({preventScroll:!0})},y=()=>{b(""),x(new Set),H(null),_.current=!0,j(!0),L(!0),k().catch(()=>{}).finally(()=>L(!1))},z=E=>{D||(B(E.instanceId),g(E.instanceId).catch(()=>{}).finally(()=>B(null)))},le=()=>{U(!1),f({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const E=Qn(m.instances,n?.instanceId).flatMap(W=>{const ce=W.models.options.filter(Ne=>!a.has(As(W.instanceId,Ne.id)));return ce.length===W.models.options.length?[W]:ce.length?[{...W,models:{...W.models,options:ce}}]:[]}),q=Xn({instances:m.instances,listed:E,selection:n??Ir,bot:{name:t.name,selection:t.modelSelection},query:S,expanded:w,probing:Ar,loading:P,refreshing:D}),Z=q.groups.map(W=>W.instance.instanceId===t.modelSelection.instanceId?{...W,note:s("botPanel.backups.sameAccount")}:W);return{...q,groups:Z,...n?{}:{current:null}}},ge=E=>{if(!(E.nativeEvent.isComposing||E.defaultPrevented)){if(E.key!=="Escape")return Jn(E,{query:S,typed:F,close:()=>U(!0)});E.preventDefault(),E.stopPropagation(),S?b(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",...c,"aria-label":i,title:o,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?K:void 0,onClick:()=>v?U(!1):y(),onKeyDown:E=>{E.key==="Escape"&&v?(E.preventDefault(),E.stopPropagation(),U(!1)):(E.key==="ArrowDown"||E.key==="ArrowUp")&&!v&&(E.preventDefault(),y())},className:p,children:r}),J.shown&&ds.createPortal(e.jsx("div",{ref:T,id:K,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...J.exitProps,onKeyDown:ge,onPointerMove:Zn,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??gt,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",J.className),children:e.jsx(Gn,{menu:ue(),query:S,bot:t,botModel:{label:"",title:""},idPrefix:K,onQuery:b,onPick:(E,q)=>{E.policy||(l({instanceId:E.instanceId,model:q}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:E=>x(q=>{const Z=new Set(q);return Z.delete(E.instanceId)||Z.add(E.instanceId),Z}),onSetUp:le,onCheckAgain:z,onManage:le})}),document.body)]})}function Mr({bot:t,onChange:n}){const{state:a}=$(),l=t.fallback??[],i=u.useRef(null),o=p=>new Set([t.modelSelection,...l.filter((r,c)=>c!==p)].map(r=>As(r.instanceId,r.model))),d=p=>{const r=a.instances.find(f=>f.instanceId===p.instanceId),c=r?.models.options.find(f=>f.id===p.model),m=Un(r,p.model);return{instance:r,name:m,short:r&&c?qn(c.label,Wn(r)):m}};return e.jsx(M,{anchor:"backups",children:e.jsxs(pe,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:_n}),e.jsx(ae,{title:s("botPanel.backups.title")})]}),e.jsx("p",{className:"-mt-1 pl-[38px] text-[13px] leading-[1.35] text-ink-secondary",children:s("botPanel.backups.hint",{name:t.name})}),l.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:l.map((p,r)=>{const{instance:c,name:m,short:f}=d(p);return e.jsxs("li",{"data-backup":p.instanceId,className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"w-3 shrink-0 text-[12px] tabular-nums text-ink-tertiary","aria-hidden":"true",children:r+1}),e.jsxs(_t,{bot:t,current:p,exclude:o(r),onPick:k=>n(l.map((g,v)=>v===r?k:g)),label:s("botPanel.backups.row",{position:r+1,model:m}),title:c?`${c.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:[c?e.jsx(Kn,{instance:c,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),!c&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(fe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Me,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{n(l.filter((k,g)=>g!==r)),i.current?.focus({preventScroll:!0})}})]},r)})}),l.length<Tr&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(_t,{bot:t,current:null,exclude:o(null),onPick:p=>n([...l,p]),label:s("model.fallback.add"),buttonRef:i,"data-panel-action":"backup-add",className:O(oe,"aria-expanded:bg-raised-hover"),children:[e.jsx(we,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function Lr({bot:t}){const{dispatch:n}=$(),[a,l]=u.useState(!1),[i,o]=u.useState(!1),[d,p]=u.useState(0),r=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(u.useEffect(()=>{if(!r)return;let m=!0;return G(`/api/bots/${t.id}/system-prompt`).then(f=>{m&&l(f.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,r,d]),!r||!a)return null;const c=async()=>{o(!0);try{await us(t.id)}catch(m){n({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{o(!1),p(m=>m+1)}};return e.jsx(M,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:Q,children:[e.jsx(X,{icon:ea}),e.jsx(ae,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:i,onClick:()=>{c()},className:oe,children:i?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const Br=5;function $r({bot:t}){const{dispatch:n,flushBotPatches:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),p=u.useCallback(()=>St(t.id).then(c=>i(c.rows.slice(0,Br)),()=>{}),[t.id]);if(u.useEffect(()=>{p()},[p,t.soul]),!l.length)return null;const r=async c=>{if(!o){d(c.id);try{await a(t.id);const{revision:m}=await St(t.id);await ii(t.id,c.id,m)}catch(m){n({type:"error",message:m instanceof Error&&m.message?m.message:s("botOverview.undoFailed")})}finally{d(null),await p()}}};return e.jsxs("div",{"data-panel-row":"soul-changes",className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("memory.changes")}),e.jsx(ot,{rows:l,botName:t.name,reverting:o,onRevert:c=>{r(c)}})]})}const We={ask:()=>s("botSettings.simple.ask"),full:()=>s("botSettings.simple.justDoIt"),auto:()=>s("botSettings.simple.decide"),edits:()=>s("approvalMode.edits.label"),custom:()=>s("botPanel.acts.custom")};function Fr({bot:t,derived:n,onOpen:a,editingInstructions:l=!1,onEditInstructions:i}){const{state:o,dispatch:d,flushBotPatches:p}=$(),{capabilities:r,ready:c}=je(),m=rs(t),{servers:f}=vs(),k=ta(Ze(t)),g=sa(),v=ws(t.id),j=ys(),[S,b]=u.useState(null),{patch:w,approvalMode:x,engine:P}=n,L=t.name,D=()=>{S!==null&&S.trim()!==t.title.trim()&&w({title:S.trim()}),b(null)},B=P?.driverKind==="antigravityAgent"&&x==="auto"?"ask":x,I=[{value:"ask",label:We.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:We.full(),tooltip:s("botSettings.simple.fullHint")},...B==="ask"||B==="full"?[]:[{value:B,label:We[B](),disabled:!0,tooltip:B==="custom"?s("botPanel.acts.customHint"):void 0}]],H=y=>{y===x||y!=="ask"&&y!=="full"||d({type:"updateBot",botId:t.id,patch:{approvalMode:y,applyToAllThreads:!0}})},A=!c||na(r,o.config),h=ha(g,{turnsHere:A,canLive:!0}),T=A?null:aa(r,!!ra()?.speechStart,ia(o.config)),F=oa.map(y=>({value:y.id,label:s(y.label),disabled:y.id==="turns"&&T!==null,tooltip:y.id==="turns"&&T?`${T.label}. ${T.reason}`:y.id==="live"?s("call.mode.liveHint"):la("turns")})),_=ca.map(y=>({value:y,label:s(Ct[y][0]),tooltip:s(Ct[y][1])})),K=()=>{const y=!t.notifications;y&&fa(),w({notifications:y})},J=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...m.apps.filter(y=>y.scope!==null).map(y=>y.label),...f?ks(f,t.mcpServers,t.id).map(y=>y.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(ri,{bot:t}),e.jsx(M,{anchor:"instructions",children:Y?e.jsxs(pe,{"data-panel-row":"soul",children:[e.jsx(oi,{bot:t,onPatch:w,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:L})}}),e.jsx($r,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{p(t.id),i?.(!1)},className:oe,children:s("botSettings.simple.done")})})]}):e.jsxs("button",{type:"button","data-panel-edit":"soul","aria-label":`${s("botSettings.simple.edit")}: ${s("botSettings.simple.instructions")}`,onClick:()=>i?.(!0),className:O(Q,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:Ae}),e.jsx(ae,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:li(t.soul??"")||s("botPanel.instructionsHint",{name:L})})}),e.jsx(ke,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(Lr,{bot:t}),e.jsx(M,{anchor:"approval",children:e.jsxs(pe,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Gt}),e.jsx(ae,{title:s("botSettings.simple.beforeActs",{name:L}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:L}),value:B,onChange:H,options:I})}),k.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(da,{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(Me,{"data-panel-action":`always-allow:${y}`,label:s("botAccess.always.remove",{entry:y}),onClick:()=>w({alwaysAllow:J.filter(z=>z!==y)})})]},y))]})]})}),e.jsx(Mr,{bot:t,onChange:y=>w({fallback:y})}),e.jsx(M,{anchor:"call",children:e.jsxs(pe,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:Va}),e.jsx(ae,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-call-mode",label:s("call.mode.menu"),value:h,onChange:pa,options:F})})]})}),e.jsxs(M,{anchor:"replies",children:[e.jsxs(pe,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(X,{icon:ma}),e.jsx(ae,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(Pe,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:y=>w({replyStyle:y}),options:_})})]}),e.jsx(at,{"data-panel-row":"notifications",icon:ua,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:K})]}),e.jsxs(M,{anchor:"uses",children:[e.jsx(ee,{"data-panel-page":"apps",icon:is,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>a?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(Q,"cursor-text"),children:[e.jsx(X,{icon:Li}),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:S??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ye.title,onChange:y=>b(y.target.value),onBlur:D,onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),y.currentTarget.blur()):y.key==="Escape"&&S!==null&&(y.preventDefault(),y.stopPropagation(),b(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),v&&e.jsxs("a",{"data-panel-row":"slack",href:v,target:"_blank",rel:"noopener noreferrer",className:O(Q,"hover:bg-ink/[0.03]"),children:[e.jsx(X,{icon:js}),e.jsx(ae,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(cs,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(ee,{"data-panel-page":"visibility",icon:Yt,title:s("botSettings.visibility.title"),value:ci(t.visibility),onClick:()=>a?.("visibility")})]}),t.yourAccess!=="view"&&!t.defaultBot&&e.jsx(Or,{bot:t,className:"mt-3.5"}),e.jsx(di,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(xa,{bot:t}),k.dialogs]})}const Dr=5;function zr({bot:t,onChanged:n}){const{dispatch:a}=$(),[l,i]=u.useState([]),[o,d]=u.useState(null),[p,r]=u.useState(null),c=u.useCallback(async()=>{const[g,v]=await Promise.all([it(t.id),he(t.id)]);d(j=>g.lendingReview?{value:g.lendingReview,stale:j?.stale??!1}:null),i(v.slice(0,Dr))},[t.id]);u.useEffect(()=>{c().catch(()=>{})},[c,t.busy]);const m=g=>a({type:"error",message:g instanceof Error&&g.message?g.message:s("common.tryAgain")}),f=async g=>{r(g.id);try{await hs(t.id,g.id),await n()}catch(v){m(v)}finally{r(null),await c().catch(()=>{})}},k=async g=>{r("review");try{await ms(t.id,g.value.token),d(null)}catch(v){v instanceof Xt&&v.status===409?(d({...g,stale:!0}),await c().catch(()=>{})):m(v)}finally{r(null)}};return e.jsxs(e.Fragment,{children:[o&&e.jsx(Ss,{changed:o.value.changed,stale:o.stale,busy:p!==null,onReviewed:()=>{k(o)}}),e.jsx(M,{children:e.jsx(at,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>a({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(M,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(ot,{rows:l,botName:t.name,reverting:p,onRevert:g=>{f(g)}})})})]})}const Hr="flex flex-col gap-3",Kt="https://www.skills.sh";function ve(t,n){return t instanceof Error&&t.message?t.message:n}function _r({bot:t,derived:n}){const{dispatch:a}=$(),l=rs(t),{servers:i,error:o}=vs(),{patch:d,canUseConnectedApps:p}=n,r=i?Si(i,t.id):[],c=new Set(ks(r,t.mcpServers,t.id).map(g=>g.name)),m=g=>{const v=wa(t,l.connectedSlugs,g.slug,g.scope===null);Object.keys(v).length>0&&d(v)},f=g=>{t.busy||o||d({mcpServers:Ci(r,t.mcpServers,g)})},k=p?l.phase==="loading"?s("common.checking"):l.phase==="unknown"?s("botSettings.simple.appsUnknown"):l.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[k&&e.jsx(V,{children:k}),p&&l.apps.map(g=>e.jsxs("div",{"data-simple-app":g.slug,className:Q,children:[e.jsx(ka,{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(bt,{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))]}),(r.length>0||o)&&e.jsxs(M,{label:s("connectors.tab.mcp"),children:[o&&e.jsx(V,{children:s("botAccess.mcpRefreshError")}),r.map(g=>e.jsxs("div",{"data-simple-mcp":g.name,className:Q,children:[e.jsx(X,{icon:Za}),e.jsx(ae,{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(bt,{color:t.color,checked:c.has(g.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:g.name}),disabled:!g.enabled||!!t.busy||o,onClick:()=>f(g.name),className:"disabled:cursor-not-allowed"})]},g.name))]}),e.jsx(M,{children:e.jsx(me,{"data-panel-link":"add-app",icon:we,onClick:()=>ja(a,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Kr({bot:t,derived:n}){const{state:a,dispatch:l}=$(),[i,o]=u.useState(()=>n.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(wi,{routines:n.botRoutines,runs:a.routineRuns,pausedBots:a.config?.pausedBots,heldBots:a.config?.heldBots,loading:a.routinesLoadState==="loading"&&n.botRoutines.length===0,error:a.routinesLoadState==="error",onOpen:o,onLogs:d=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:d.id}),onToggle:d=>l({type:"updateRoutine",routineId:d.id,patch:{enabled:!d.enabled}})}),e.jsx(M,{children:e.jsx(me,{"data-panel-action":"new-routine",icon:we,onClick:()=>o("new"),children:s("botPanel.routines.add")})}),e.jsx("p",{className:"mx-1 text-[13px] leading-normal text-ink-secondary",children:s("botPanel.routines.ask",{name:t.name})}),i&&e.jsx(Pi,{routine:i==="new"?void 0:i,bots:[t],lockedBotId:t.id,onClose:()=>o(null)},t.id)]})}function Ur({bot:t}){const n=Ts(t),[a,l]=u.useState(""),[i,o]=u.useState(null),[d,p]=u.useState(!1),[r,c]=u.useState(null),m=t.memoryEnabled!==!1,f=n.docs?Rs(n.docs):null,k=n.docs?.find(b=>b.path===te)??null;u.useEffect(()=>o(null),[t.id,m]);const g=async b=>{if(d)return!1;p(!0),c(null);try{return await b()}catch(w){return c(ve(w,s("botPanel.library.memoryError"))),!1}finally{p(!1)}},v=(b,w)=>g(async()=>{const x=await rt(t.id,b.path,w,b.exists?b.hash:void 0,n.mine);return x.ok?(n.setDoc(x.doc),!0):(await n.reload(),c(s("memory.conflict.title",{name:t.name})),!1)}),j=b=>{const w=n.docs?.find(x=>x.path===b.path);w&&(b.line!==null?v(w,br(w.text,b.line)):g(async()=>(await xs(t.id,w.path,n.mine),await n.reload(),!0)))},S=async()=>{!k||!a.trim()||await v(k,vr(k.text,a))&&l("")};return m&&i?.botId===t.id?e.jsx(qr,{bot:t,doc:i.doc,mine:n.mine,onDone:b=>{b&&n.setDoc(b),o(null),c(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[m?n.error?e.jsx(V,{tone:"warn",children:s("botPanel.library.memoryError")}):f===null?e.jsx(V,{children:s("common.checking")}):f.length===0?e.jsx(V,{children:s("botPanel.memory.empty")}):f.map(b=>e.jsxs("div",{"data-memory-note":b.line??b.path,className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:b.text}),e.jsx(Me,{label:s("botPanel.memory.forget"),disabled:d,onClick:()=>j(b)})]},`${b.path}:${b.line}:${b.text}`)):e.jsx(V,{children:s("botPanel.library.memoryOff",{name:t.name})}),r&&e.jsx(V,{tone:"warn",children:r})]}),m&&e.jsxs(M,{children:[e.jsx(os,{"data-panel-form":"memory-add",value:a,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:d||k===null,onChange:l,onSubmit:()=>{S()}}),k&&e.jsx(me,{"data-panel-link":"memory-text",icon:Ae,onClick:()=>o({botId:t.id,doc:k}),children:s("botPanel.memory.editText")})]}),m&&!n.mine&&e.jsx(zr,{bot:t,onChanged:n.reload})]})}function qr({bot:t,doc:n,mine:a,onDone:l}){const[i,o]=u.useState({text:n.text,hash:n.hash}),[d,p]=u.useState(n.text),[r,c]=u.useState(null),[m,f]=u.useState(null),[k,g]=u.useState(!1),[v,j]=u.useState(null),S=u.useRef(!0);u.useEffect(()=>(S.current=!0,()=>{S.current=!1}),[]);const b=async x=>{g(!0),j(null);try{const P=await rt(t.id,n.path,d,x,a);if(!S.current)return;P.ok?l(P.doc):c({current:P.current,currentHash:P.currentHash})}catch(P){j(ve(P,s("botPanel.library.memoryError")))}finally{g(!1)}},w=()=>{r&&(f(x=>x===null||x===d?d:`${x}
15
-
16
- ${d}`),o({text:r.current,hash:r.currentHash}),p(r.current),c(null))};return e.jsx(M,{children:e.jsxs(pe,{"data-panel-row":"memory-text",children:[r&&e.jsx(Cs,{botName:t.name,busy:k,onReload:w,onOverwrite:()=>{b(r.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(Qe,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:d,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:k,onChange:x=>p(x.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),m!==null&&e.jsxs("div",{"data-memory-draft":"",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:m}),e.jsx("button",{type:"button",className:O(oe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:oe,disabled:k,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:oe,disabled:k||d===i.text,onClick:()=>{b(i.hash)},children:k?s("memory.saving"):s("memory.save")})]})]})})}function Wr({bot:t}){const{request:n}=ba(),{state:a,dispatch:l}=$(),i=fs(t),[o,d]=u.useState(""),[p,r]=u.useState(!1),[c,m]=u.useState([]),f=va(a.config),k=async x=>{if(!i.working&&window.confirm(s(x.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:x.name}))){i.setWorking(x.name),i.setError("");try{await n(`/api/bots/${t.id}/skills/${encodeURIComponent(x.name)}`,{method:"DELETE"}),await i.refresh()}catch(P){i.setError(ve(P,s("botPanel.skills.removeFailed")))}finally{i.setWorking("")}}},g=async()=>{const x=o.trim();if(!(!x||p)){r(!0),i.setError(""),m([]);try{const P=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:x})});m(Pt(P.imported??[])),d(""),await i.refresh()}catch(P){i.setError(ve(P,s("botPanel.skills.importFailed")))}finally{r(!1)}}},v=async()=>{const x=await window.ogb?.pickFolder?.();if(!(!x||p)){r(!0),i.setError(""),m([]);try{const P=await n(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${x}`})});m(Pt(P.imported??[])),await i.refresh()}catch(P){i.setError(ve(P,s("botPanel.skills.importFailed")))}finally{r(!1)}}},[j,S]=u.useState(!1),b=()=>{S(!1),l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"})},w=()=>{if(f){S(!0);return}yt(Kt)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[i.loading?e.jsx(V,{children:s("skills.loading")}):i.skills.length===0?e.jsx(V,{children:s("botSettings.simple.noSkills")}):i.skills.map(x=>e.jsx(at,{"data-panel-row":`skill:${x.name}`,title:x.name,hint:x.description||x.source,label:s("botSettings.simple.skillToggle",{name:x.name}),color:t.color,checked:gs(x),disabled:!!i.working||x.core===!0,onChange:()=>{i.toggle(x)},extra:x.origin==="imported"||x.origin==="native"||x.origin==="bundled"?void 0:e.jsx(Me,{"data-panel-action":`remove-skill:${x.name}`,label:s("botPanel.skills.remove",{name:x.name}),disabled:!!i.working,onClick:()=>{k(x)}})},x.name)),i.error&&!i.reviewing&&e.jsx(V,{tone:"warn",children:i.error})]}),e.jsx(mi,{bot:t,onAdded:()=>{i.refresh()}}),e.jsxs(M,{children:[e.jsx(os,{"data-panel-form":"skill-import",value:o,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:p?s("skills.import.importing"):s("common.add"),disabled:p,onChange:d,onSubmit:()=>{g()}}),c.map(x=>e.jsx(V,{children:x},x)),e.jsx(me,{"data-panel-link":"skills-sh",onClick:()=>{yt(Kt)},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(Pr,{botId:t.id,botName:t.name,onOpenSettings:b,onClose:()=>{S(!1),i.refresh()}}),i.reviewing&&e.jsx(ui,{skill:i.reviewing.skill,text:i.reviewing.text,error:i.error,working:i.working===i.reviewing.skill.name,onCancel:()=>i.setReviewing(null),onEnable:()=>{i.enableReviewed()}})]})}function Vr({bot:t}){const{capabilities:n}=je(),a=n.host?.homeDir,{draft:l,setDraft:i,error:o,saving:d,canPick:p,save:r,pick:c}=pi(t),[m,f]=u.useState(!1),k=!!t.cwd||m,g=()=>{if(p){c();return}f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsx(Ve,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!k,disabled:d,onClick:()=>{f(!1),t.cwd&&r(null)}}),e.jsx(Ve,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:k,disabled:d,onClick:()=>{t.cwd||g()}})]}),k&&e.jsxs(M,{children:[p?e.jsxs("div",{className:Q,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?st(t.cwd,a):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:d,onClick:()=>{c()},className:oe,children:[e.jsx(Qt,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:Q,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&r(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>i(v.target.value),className:"h-8 min-w-0 flex-1 rounded-lg border border-hairline bg-inset px-2.5 font-mono text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("button",{type:"submit",disabled:d||l===null,className:oe,children:s("botAccess.folder.save")})]}),o&&e.jsx(V,{tone:"warn",children:o})]}),e.jsx(ga,{value:t.cwd,disabled:d,onChoose:r}),e.jsx(ya,{kind:"bots",id:t.id,folder:t.cwd})]})}function Zr({bot:t,derived:n}){const a=Ps(t);return e.jsx(Nr,{bot:t,browserEnabled:n.browserEnabled,onOpenBrowser:()=>a("browser")})}function Gr({bot:t}){return ys()?e.jsx(bs,{bot:t}):null}function Yr({page:t,onOpen:n,editingInstructions:a,onEditInstructions:l,...i}){switch(t){case"settings":return e.jsx(Fr,{...i,onOpen:n,editingInstructions:a,onEditInstructions:l});case"where":return e.jsx(or,{...i});case"apps":return e.jsx(_r,{...i});case"routines":return e.jsx(Kr,{...i});case"visibility":return e.jsx(Gr,{...i});case"memory":return e.jsx(Ur,{...i});case"skills":return e.jsx(Wr,{...i});case"folder":return e.jsx(Vr,{...i});case"browser":return e.jsx(Zr,{...i})}}const Ut="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function qt(t){const[n,a]=u.useState(null),l=u.useRef(!1),i=u.useRef(!1),o=u.useRef(null);u.useEffect(()=>{n!==null||!i.current||(i.current=!1,o.current?.focus())},[n]);const d=m=>{l.current=!1,a(m)},p=()=>{n!==null&&t(n),a(null)};return{draft:n,setDraft:a,start:d,onKeyDown:m=>{if(Sa(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),l.current=!0,i.current=!0,p()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l.current=!0,i.current=!0,a(null))},onBlur:()=>{l.current||p()},buttonRef:o}}function Jr({bot:t,activeState:n,patch:a,editorOpen:l,onToggleEditor:i}){const o=qt(r=>{const c=r.trim();c&&c!==t.name&&a({name:c})}),d=qt(r=>{const c=r.trim();c!==t.title.trim()&&a({title:c})}),p=t.title.trim();return e.jsxs("div",{className:"group/hero flex flex-col items-center text-center",children:[e.jsxs("button",{type:"button","data-panel-avatar":!0,"aria-label":s("botPanel.avatar.edit"),"aria-expanded":l,onClick:i,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(Je,{bot:t,size:64,state:n}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center rounded-[18px] bg-black/0 text-white opacity-0 transition-[opacity,background-color] group-hover:bg-black/40 group-hover:opacity-100 group-focus-visible:bg-black/40 group-focus-visible:opacity-100 group-focus-within:opacity-100 touch:opacity-100 motion-reduce:transition-none",children:e.jsx(vt,{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(Na,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:s("chat.chiefOfStaff")})]}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-[calc(100%+4px)] z-10 -translate-x-1/2 whitespace-nowrap rounded-md border border-hairline bg-menu px-[7px] py-0.5 text-[12px] text-ink opacity-0 transition-opacity group-hover:opacity-100",children:s("botPanel.avatar.edit")})]}),e.jsx("div",{"data-panel-name-row":!0,className:"mt-2 flex max-w-full items-center justify-center",children:e.jsx("h2",{id:"bot-settings-title",className:"flex min-w-0 justify-center",children:o.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ye.name,value:o.draft,onChange:r=>o.setDraft(r.target.value),onKeyDown:o.onKeyDown,onBlur:o.onBlur,className:O(Ut,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:o.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>o.start(t.name),className:"group/name relative inline-flex max-w-full items-center rounded-[8px] px-1.5 text-[17px] font-medium leading-6 text-ink hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"min-w-0 truncate",children:t.name}),e.jsx(vt,{size:13,"aria-hidden":"true",className:"absolute -right-4 shrink-0 text-ink-tertiary opacity-0 transition-opacity group-hover/name:opacity-100 group-focus-visible/name:opacity-100 group-focus-within/name:opacity-100 touch:opacity-100"})]})})}),d.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Ye.title,value:d.draft,onChange:r=>d.setDraft(r.target.value),onKeyDown:d.onKeyDown,onBlur:d.onBlur,className:O(Ut,"mt-[3px] w-[200px] max-w-full text-[13px]")}):p&&e.jsx("button",{ref:d.buttonRef,type:"button","data-panel-label":!0,onClick:()=>d.start(t.title),className:"mt-px max-w-full truncate rounded-md px-1.5 py-px text-[13px] text-ink-secondary hover:bg-ink/[0.04]",children:p})]})}function Ce(t,n){return t?ls(t,n):{tab:"details"}}function Qr({bot:t,derived:n,linkedSection:a,onClose:l}){const{dragProps:i}=ps(),o=Ca(),[d,p]=u.useState(()=>Ce(a,o).tab),[r,c]=u.useState(()=>{const h=Ce(a,o).page;return h?[h]:[]}),[m,f]=u.useState(()=>Ce(a,o).anchor??null),[k,g]=u.useState(!1),[v,j]=u.useState(()=>!!Ce(a,o).editInstructions),S=u.useRef(null),b=u.useRef(null),w=r.at(-1)??null,x=()=>S.current?.scrollTo({top:0}),P=h=>{p(h.tab),c(h.page?[h.page]:[]),f(h.anchor??null),g(!1),j(!!h.editInstructions),x()},L=h=>P({tab:h}),D=h=>{c(T=>[...T,h]),g(!1),x()},B=()=>{g(!1),b.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{c(h=>h.slice(0,-1)),x()};u.useEffect(()=>{a&&P(ls(a,o))},[a,o]),u.useEffect(()=>{m&&(S.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),f(null))},[m,w,d]);const H=h=>{if(h.key!=="Escape"||h.defaultPrevented)return;const T=h.target,F=typeof T?.closest=="function"?T.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(F&&!F.contains(h.currentTarget)&&F!==b.current&&!b.current?.contains(F))){if(k)B();else if(r.length>0)I();else return;h.preventDefault(),h.stopPropagation()}},A=r.length>1?s(Se[r[r.length-2]].title,{name:t.name}):s(kt[d]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:H,children:[e.jsxs("div",{...i,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(Pa,{bot:t,className:De}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":w==="settings"?"page":void 0,onClick:()=>P({tab:"details",page:"settings"}),className:De,children:e.jsx(Oa,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:De,children:e.jsx(et,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:S,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(Jr,{bot:t,activeState:n.activeState,patch:n.patch,editorOpen:k,onToggleEditor:()=>g(h=>!h)}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:B}),e.jsx(ar,{bot:t,activeState:n.activeState,onPatch:n.patch,onClose:B})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:Ea.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":d===h,"data-panel-tab":h,onClick:()=>L(h),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",d===h?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(kt[h])},h))})}),e.jsxs("div",{role:"tabpanel",children:[d==="details"&&e.jsx(gr,{bot:t,derived:n,onOpen:D}),d==="library"&&e.jsx(Is,{bot:t,onOpen:D}),d==="computer"&&e.jsx(lr,{bot:t,derived:n,onOpen:D})]})]}):e.jsxs("div",{"data-panel-page-view":w,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(Ra,{back:A,title:s(Se[w].title,{name:t.name}),intro:Se[w].intro?s(Se[w].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Hr),children:e.jsx(Yr,{page:w,bot:t,derived:n,onOpen:D,editingInstructions:v,onEditInstructions:j})})]})})]})}function Xr(t,n){const{state:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,p]=u.useState(!1),[r,c]=u.useState(null),[m,f]=u.useState(!1),k=u.useMemo(()=>JSON.stringify([t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),[t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),g=n.followEdits??!0,v=g?k:null,j=g?a.routines:null,S=g?a.webhooks:null;return u.useEffect(()=>{if(!n.overview&&!n.prompt)return;let b=!1;return(async()=>(await l(t.id),!b&&(n.overview&&G(`/api/bots/${t.id}/overview`).then(x=>{b||(o(x),p(!1))}).catch(()=>{b||p(!0)}),n.prompt&&G(`/api/bots/${t.id}/system-prompt`).then(x=>{b||(c(x),f(!1))}).catch(()=>{b||f(!0)}))))(),()=>{b=!0}},[t.id,n.overview,n.prompt,v,j,S,l]),{overview:i,overviewError:d,prompt:r,promptError:m}}function eo(t,n){const{dispatch:a,flushBotPatches:l}=$(),[i,o]=u.useState(null),[d,p]=u.useState(!1),[r,c]=u.useState(null),m=u.useRef(0),[f,k]=u.useState(!1),[g,v]=u.useState(null),j=u.useCallback(()=>{const w=++m.current;return p(!1),l(t.id).then(()=>G(`/api/bots/${t.id}/history?limit=100`)).then(x=>{w===m.current&&(o(x.rows),c(x.revision))}).catch(()=>{w===m.current&&p(!0)})},[t.id,l]);return u.useEffect(()=>{if(n)return j(),()=>{m.current++}},[n,j]),{rows:i,error:d,revision:r,rollingBack:f,rollbackTarget:g,setRollbackTarget:v,rollback:async w=>{if(!f){v(null),k(!0);try{await l(t.id),await G(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(w)})}catch(x){a({type:"error",message:x instanceof Error?x.message:s("botOverview.undoFailed")})}finally{await j(),k(!1)}}},requestRollback:w=>{r&&v({id:w,expectedRevision:r})}}}function to({history:t,returnFocusRef:n}){const{rollbackTarget:a,setRollbackTarget:l,rollback:i}=t;return e.jsx(Ta,{open:a!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:n,onCancel:()=>l(null),onConfirm:()=>{a&&i(a)}})}const so={memory:"memory",skills:"skills",folder:"access"},Ms=t=>t.labelKey?s(t.labelKey):t.label;function Wt(t,n){return n?[t.label,Ms(t),...t.keywords].some(a=>a.toLowerCase().includes(n)):!0}function ko({bot:t,overlay:n=!1}){const{state:a,dispatch:l}=$(),i=a.botSettingsSection,o=Ia(t),d=u.useRef(null),{dragProps:p}=ps(),[r,c]=u.useState(""),m=!a.botSettingsExpandAccordion,f=r.trim().toLowerCase(),g=!Vt(),v=!m&&!a.botSettingsExpandRemembered?i:null,j=ws(t.id),S=nt(),b=Aa(),w=Bi.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&S===!0&&!b),x=w.filter(A=>Wt(A,f)),{overview:P,overviewError:L,prompt:D,promptError:B}=Xr(t,{overview:i==="overview"&&!g,prompt:i==="overview"&&!g}),I=eo(t,i==="history"&&!g);u.useEffect(()=>{if(!m){if(f){c("");return}d.current?.querySelector(`[data-bot-settings-section="${i}"]`)?.scrollIntoView({block:"nearest"})}},[m,i,f]),u.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,h=d.current;h?.focus();const T=F=>{const _=h?.querySelector('[role="dialog"], [role="alertdialog"]');_&&_.getClientRects().length>0||h&&F.target instanceof Node&&!h.contains(F.target)||F.key==="Escape"&&!F.defaultPrevented&&(F.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T),A?.focus()}},[l]);const H=A=>{switch(A){case"overview":return P===null&&L?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Ki,{overview:P,refreshError:P!==null&&L,prompt:D,promptError:B,onOpen:h=>l({type:"toggleSettings",open:!0,section:h}),onSetup:o.canCoordinate&&!t.busy?()=>{l({type:"toggleSettings",open:!1}),l({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(vi,{bot:t,patch:o.patch,activeState:o.activeState,mascotMotion:o.mascotMotion});case"soul":return e.jsx(bi,{bot:t,patch:o.patch});case"slack":return j?e.jsx(Ui,{managementUrl:j}):null;case"skills":return e.jsx(yi,{bot:t});case"memory":return e.jsx(Vi,{bot:t,active:!m&&i==="memory",onToggle:h=>o.patch({memoryEnabled:h})});case"library":return e.jsx(Is,{bot:t,onOpen:h=>l({type:"toggleSettings",open:!0,section:so[h]??"overview"})});case"routines":return e.jsx(Ni,{bot:t,routines:o.botRoutines,runs:a.routineRuns});case"access":return e.jsx(gi,{bot:t,derived:o});case"model":return e.jsx(fi,{bot:t});case"permissions":return e.jsx(hi,{bot:t,derived:o});case"voice":return e.jsx(xi,{bot:t,derived:o});case"visibility":return e.jsx(bs,{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(Ji,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(Qi,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:d,id:g?Ma:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Ba(n,g),children:g?e.jsx(Qr,{bot:t,derived:o,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...p,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(La,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>l({type:"toggleSettings",open:!1}),"aria-label":s("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(et,{size:18,className:"pointer-events-none"})})]})]}),e.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[e.jsx(Xe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:r,onChange:A=>{c(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),r?c(""):l({type:"toggleSettings",open:!1}))},placeholder:s("botSettings.search"),"aria-label":s("botSettings.searchAria"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[x.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:r.trim()})}),w.map(A=>{const{id:h,icon:T}=A,F=Ms(A),_=Wt(A,f);if(!_&&h!=="memory")return null;const K=!m&&i===h;return e.jsxs("div",{"data-bot-settings-section":h,className:"border-b border-hairline/30",hidden:!_,children:[e.jsxs("button",{type:"button",onClick:()=>{if(i===h&&!m){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:h})},"aria-expanded":K,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",K?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(T,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:F}),e.jsx(fe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",K&&"rotate-180")})]}),h==="memory"?e.jsx("div",{hidden:!K,className:"px-4 pb-4 pt-1",children:H("memory")}):K&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:H(h)})]},h)})]})]})}),e.jsx(to,{history:I,returnFocusRef:d})]})}export{ko as BotSettingsDialog};