limixbot 0.3.23 → 0.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ActivityPanel-BkpnvFMV.js → ActivityPanel-CgPkGKZZ.js} +1 -1
- package/dist/assets/{App-5fWd2qWI.js → App-lurtH-qI.js} +90 -90
- package/dist/assets/{AppEventEditor-4U6g9rYH.js → AppEventEditor-G_71EWui.js} +1 -1
- package/dist/assets/BotSettingsDialog-BUvuLu53.js +16 -0
- package/dist/assets/{BrowserPanel-DKxFFmVF.js → BrowserPanel-DrKZNyYB.js} +1 -1
- package/dist/assets/{BrowserProfilesManager-DbsOGGoV.js → BrowserProfilesManager-CtiUbbdv.js} +1 -1
- package/dist/assets/{CloudAddDialog-I2EDWXA8.js → CloudAddDialog-D4BX2927.js} +1 -1
- package/dist/assets/{ComputerFilesPane-DA4Txmh9.js → ComputerFilesPane-RnmlJhlD.js} +1 -1
- package/dist/assets/{ComputerPanel-B3EgKF7M.js → ComputerPanel-D8upQSmd.js} +2 -2
- package/dist/assets/{DataPanel-DALLlVzz.js → DataPanel-MZcku4SL.js} +1 -1
- package/dist/assets/{DesktopViewer-BTFnhvej.js → DesktopViewer-p7N7cqle.js} +1 -1
- package/dist/assets/{FilesView-DfvDhNdO.js → FilesView-CDbtoPxh.js} +1 -1
- package/dist/assets/{GrokMoveDialog-CVgxiDZG.js → GrokMoveDialog-BebZb43R.js} +1 -1
- package/dist/assets/{InspectorPanel-B8d5f_Z7.js → InspectorPanel-BMkRIuTz.js} +1 -1
- package/dist/assets/{KeyboardShortcutsModal-C4Sy1Y5Q.js → KeyboardShortcutsModal-3XyVcNTZ.js} +1 -1
- package/dist/assets/{LiveDesktop-BdLw7_qb.js → LiveDesktop-BkRR5lCn.js} +1 -1
- package/dist/assets/{LocalVmWorkspace-Dd8v6HSb.js → LocalVmWorkspace-9l9iWtAy.js} +1 -1
- package/dist/assets/{MacLocalControl-DBItoJQX.js → MacLocalControl-B45d0l7H.js} +1 -1
- package/dist/assets/{MarkdownFilePreview-tXLtgk1m.js → MarkdownFilePreview-ChR-f9oD.js} +1 -1
- package/dist/assets/{MenuMotion-DnbwlBMa.js → MenuMotion-BBaxdyL_.js} +1 -1
- package/dist/assets/NewBotDialog-C_uQRhxy.js +1 -0
- package/dist/assets/{PhoneAppDialog-D4klvpz5.js → PhoneAppDialog-CDO1xUXD.js} +1 -1
- package/dist/assets/{PlacesRail-BYBRFGDz.js → PlacesRail-iu-rjh5s.js} +1 -1
- package/dist/assets/{PluginsPanel-DUOw0nhP.js → PluginsPanel-DlQBRYQB.js} +1 -1
- package/dist/assets/{ProIntroduction-B1eqbu20.js → ProIntroduction-RbtTSiR6.js} +1 -1
- package/dist/assets/{RemoteAgentSettingsPanel-B46lWStL.js → RemoteAgentSettingsPanel-C8r-80J4.js} +1 -1
- package/dist/assets/{RoomPanel-DBKyhryu.js → RoomPanel-BIUTnm5N.js} +1 -1
- package/dist/assets/{RoutinesPage-CCSHgNRs.js → RoutinesPage-DROK-336.js} +2 -2
- package/dist/assets/{SettingsModal-CwXiblca.js → SettingsModal--yYGUYK2.js} +3 -3
- package/dist/assets/{ShareTeamDialog-DuSs1saG.js → ShareTeamDialog-CVnQoRVQ.js} +1 -1
- package/dist/assets/{SignedInSites-BdxFX6Wt.js → SignedInSites-B-iBIlfL.js} +1 -1
- package/dist/assets/TeamLibraryPanel-CwVaJVC_.js +1 -0
- package/dist/assets/{TeamMapPage-PW3Ots-y.js → TeamMapPage-kXk9hCNu.js} +1 -1
- package/dist/assets/{TriggersPage-D5jH7bR3.js → TriggersPage-prZBUP3d.js} +1 -1
- package/dist/assets/{VisibilitySection-yE3ZIXKk.js → VisibilitySection-DJjvTyLx.js} +1 -1
- package/dist/assets/{WebhookTrigger-doGyrUZA.js → WebhookTrigger-BAFikH71.js} +1 -1
- package/dist/assets/{WorksOnGrid-DWvjM4aV.js → WorksOnGrid-DJmfLtP8.js} +1 -1
- package/dist/assets/{abnfDiagram-YUKMZFIV-Bs9i-eLj.js → abnfDiagram-YUKMZFIV-DUI6uevQ.js} +1 -1
- package/dist/assets/{activity-DIhOTAmd.js → activity-DVLFekjx.js} +1 -1
- package/dist/assets/{architectureDiagram-47P4ROYG-CR-7WHVu.js → architectureDiagram-47P4ROYG-CMELW5_4.js} +1 -1
- package/dist/assets/{blockDiagram-E7TT5TSB-Cx9qUsrY.js → blockDiagram-E7TT5TSB-C3xD0z1e.js} +1 -1
- package/dist/assets/{c4Diagram-CRA5TL53-CtuUaTlE.js → c4Diagram-CRA5TL53-Cm9X0GEV.js} +1 -1
- package/dist/assets/{calendar-days-DyyECwZf.js → calendar-days-CDvwJ_d4.js} +1 -1
- package/dist/assets/channel-CsOUN1ZX.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DIvFRpG0.js → chunk-2Q5K7J3B-LWcbjcjL.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-Cxp3RKyR.js → chunk-5VM5RSS4-B3rNoWeE.js} +1 -1
- package/dist/assets/{chunk-7TKQ45FW-DSOW_9p2.js → chunk-7TKQ45FW-FL9R0rHe.js} +1 -1
- package/dist/assets/{chunk-AW2ZBBNX-zV216OhN.js → chunk-AW2ZBBNX-JRef_4rd.js} +1 -1
- package/dist/assets/{chunk-FVRAUYC3-BOtXkSrZ.js → chunk-FVRAUYC3-C__loQFR.js} +2 -2
- package/dist/assets/{chunk-HTAEGDNF-DiV1eG2w.js → chunk-HTAEGDNF-Bx74_xmN.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BZJyqcw-.js → chunk-JWPE2WC7-B20vr3uH.js} +1 -1
- package/dist/assets/{chunk-KQW6MTUR-DabkPo_d.js → chunk-KQW6MTUR-DfO9J2pt.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CcZGTVYy.js → chunk-XXDRQBXY-BAPGqnqj.js} +1 -1
- package/dist/assets/{classDiagram-v2-K4WV4PDN-DfOdVcjL.js → classDiagram-v2-K4WV4PDN-C3VR3yN8.js} +1 -1
- package/dist/assets/{coins-s4HyWHyQ.js → coins-CueFc0mY.js} +1 -1
- package/dist/assets/{core-D7M03RiE.js → core-Bw6kaGwe.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-CqrD5E-Q.js → cose-bilkent-JH36ORCC-19p3m04s.js} +1 -1
- package/dist/assets/{cynefin-EF2NZ3EQ-fcIOWtrM.js → cynefin-EF2NZ3EQ-Tv0tce7B.js} +1 -1
- package/dist/assets/{cynefinDiagram-3GCD6N5R-Cx2XYJ57.js → cynefinDiagram-3GCD6N5R-Iin0JwlW.js} +1 -1
- package/dist/assets/{dagre-W4DXFKR2-D6f_32GP.js → dagre-W4DXFKR2-00TRmSmB.js} +1 -1
- package/dist/assets/{diagram-2UJZ2QOL-IxXxA3zr.js → diagram-2UJZ2QOL-DslMBjKt.js} +1 -1
- package/dist/assets/{diagram-OVF4WLC6-DzRS9og-.js → diagram-OVF4WLC6-C3o3f1eL.js} +1 -1
- package/dist/assets/{diagram-PFPMY2P6-CA4cF9TP.js → diagram-PFPMY2P6-RRy9F9wH.js} +1 -1
- package/dist/assets/{diagram-UMYRVEAY-B5YdB3mN.js → diagram-UMYRVEAY-CWfRKtkp.js} +1 -1
- package/dist/assets/{diagram-YEKJPTXX-D8jMUZQ7.js → diagram-YEKJPTXX-SlJKvYay.js} +1 -1
- package/dist/assets/{diagram-ZIFT7M5P-D9FKtuee.js → diagram-ZIFT7M5P-DqzI8_eN.js} +1 -1
- package/dist/assets/{ebnfDiagram-VR2GEFS7-BipEfLA3.js → ebnfDiagram-VR2GEFS7-CDsrBNMu.js} +1 -1
- package/dist/assets/{elk-IJKZMXRS-ByA43ZYx.js → elk-IJKZMXRS-iikFqO-X.js} +1 -1
- package/dist/assets/{erDiagram-O2IAPWRE-hlDRgJN-.js → erDiagram-O2IAPWRE-DzFCc0Gp.js} +1 -1
- package/dist/assets/{file-up-DXcOpz8w.js → file-up-BzW-KJx-.js} +1 -1
- package/dist/assets/{flowDiagram-OXPTDLAJ-BuCuOW1m.js → flowDiagram-OXPTDLAJ-U5nLRus2.js} +1 -1
- package/dist/assets/{ganttDiagram-R7TSEDQI-Bk16Ilgi.js → ganttDiagram-R7TSEDQI-h7xqrZ23.js} +1 -1
- package/dist/assets/{gitGraphDiagram-XJZIOB7I-CN3BXWBF.js → gitGraphDiagram-XJZIOB7I-Bo9ZX2g5.js} +1 -1
- package/dist/assets/{import-name-wz0BNJ-d.js → import-name-BN_-MYip.js} +1 -1
- package/dist/assets/{index-BJo4IICg.js → index-BEjJ5c6H.js} +2 -2
- package/dist/assets/{index-BR_1_bou.js → index-DkDFNBNq.js} +1 -1
- package/dist/assets/{infoDiagram-5W2HQ5XZ-DSUAydoj.js → infoDiagram-5W2HQ5XZ-CAZmFoiz.js} +1 -1
- package/dist/assets/{ishikawaDiagram-K3B6WC7H-C1_ZiQE2.js → ishikawaDiagram-K3B6WC7H-T1M7DtvG.js} +1 -1
- package/dist/assets/{journeyDiagram-COXZFDF6-CAGOqBTO.js → journeyDiagram-COXZFDF6-DzO0Gzq9.js} +1 -1
- package/dist/assets/{kanban-definition-P3RFRI5V-Dj3_9GgV.js → kanban-definition-P3RFRI5V-C0fM1UHu.js} +1 -1
- package/dist/assets/{mcp-servers-qzidl6IU.js → mcp-servers-C7oRQpN5.js} +1 -1
- package/dist/assets/{mermaid.core-CcbkAG9m.js → mermaid.core-mKZTdBWz.js} +4 -4
- package/dist/assets/{mindmap-definition-LZFPQGKD-C_gFeuC9.js → mindmap-definition-LZFPQGKD-DEgoC28p.js} +1 -1
- package/dist/assets/{minimize-DixQTKye.js → minimize-D-CvaOV-.js} +1 -1
- package/dist/assets/{monitor-IwDx0ohO.js → monitor-DRcE92Rj.js} +1 -1
- package/dist/assets/{new-bot-COptZjiW.js → new-bot-COj1uEQa.js} +1 -1
- package/dist/assets/{org-library-97Cfj4XD.js → org-library-BIb28h24.js} +1 -1
- package/dist/assets/{package-format-MbGfBQ0g.js → package-format-hON5OXLZ.js} +1 -1
- package/dist/assets/{pegDiagram-BGZESJAR-CYa91QJf.js → pegDiagram-BGZESJAR-Vatn56u_.js} +1 -1
- package/dist/assets/{pieDiagram-CAPJLFHJ-H4g7rmhD.js → pieDiagram-CAPJLFHJ-DniOgFo3.js} +1 -1
- package/dist/assets/{quadrantDiagram-GDMTTRAM-CkHV6SSw.js → quadrantDiagram-GDMTTRAM-BqhAQt5w.js} +1 -1
- package/dist/assets/{rail-SzaGJCSZ.js → rail-BWcrFQ2_.js} +1 -1
- package/dist/assets/{railroadDiagram-SM67HX2B-Kx3ccbrH.js → railroadDiagram-SM67HX2B-CxHs3JOs.js} +1 -1
- package/dist/assets/{remote-desktop-panel-CVuN83Ny.js → remote-desktop-panel-9XdtvJrd.js} +1 -1
- package/dist/assets/{requirementDiagram-X7JNWC4A-BcNRqLgf.js → requirementDiagram-X7JNWC4A-ChjhMFon.js} +1 -1
- package/dist/assets/{sankeyDiagram-UM26HJRW-CQP982o-.js → sankeyDiagram-UM26HJRW-B67bYF8E.js} +1 -1
- package/dist/assets/{sequenceDiagram-ZO4K6R2Y-BXkOAwlC.js → sequenceDiagram-ZO4K6R2Y-CTy7B-eu.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BtuN-EAh.js → sizeCapture-INFHLROL-uy6qiY-2.js} +1 -1
- package/dist/assets/{stateDiagram-v2-TBUQTH76-CmlsJGhT.js → stateDiagram-v2-TBUQTH76-BvYYPNqL.js} +1 -1
- package/dist/assets/{styles-ElM5u1od.js → styles-DlOxUga6.js} +1 -1
- package/dist/assets/{swimlanes-N4OXWK64-GH4PBeGD.js → swimlanes-N4OXWK64-CMSAKu-2.js} +1 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-BaaZdhur.js +8 -0
- package/dist/assets/{team-share-B2cRBtNk.js → team-share-BbQqJ5O6.js} +1 -1
- package/dist/assets/{timeline-definition-YOQAKGHF-j8Q7uetA.js → timeline-definition-YOQAKGHF-BOK1V5EC.js} +1 -1
- package/dist/assets/{usecaseDiagram-VIAY4XPW-Cz4ej3SQ.js → usecaseDiagram-VIAY4XPW-DEywfSfC.js} +1 -1
- package/dist/assets/{vennDiagram-BLWOH2XV-BZ3IAGpt.js → vennDiagram-BLWOH2XV-DN1iWw97.js} +1 -1
- package/dist/assets/{vi-CVDyZGky.js → vi-C-E3a4Tv.js} +2 -2
- package/dist/assets/{wardleyDiagram-YMQ3BMBF-Bc32JfGA.js → wardleyDiagram-YMQ3BMBF-BAIfK1We.js} +1 -1
- package/dist/assets/{xychartDiagram-TAQBALBS-s5XbB-l2.js → xychartDiagram-TAQBALBS-BLBD8FaQ.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/rail.html +4 -4
- package/dist-server/index.js +1787 -1759
- package/dist-server/openmausbot.js +1 -1
- package/dist-server/package.json +1 -1
- package/dist-server/pair-cli.js +1 -1
- package/dist-server/server/imported-skills.js +7 -2
- package/dist-server/server/index.js +8 -6
- package/dist-server/server/initial-greeting.js +4 -0
- package/dist-server/server/limix-bot-library.js +184 -0
- package/dist-server/server/limix-skill-hub.js +2 -2
- package/dist-server/server/limix-skill-store.js +179 -0
- package/dist-server/server/routes/bot-skills.js +21 -4
- package/dist-server/server/routes/teams.js +1 -1
- package/package.json +1 -1
- package/skills/windows-computer-automation/SKILL.md +53 -0
- package/skills/windows-computer-automation/assets/HERIONIX-LEADER-PROMPT.md +25 -0
- package/skills/windows-computer-automation/assets/control-policy.example.json +25 -0
- package/skills/windows-computer-automation/assets/mcp-servers.example.json +19 -0
- package/skills/windows-computer-automation/manifest.json +27 -0
- package/skills/windows-computer-automation/references/herionix-integration.md +72 -0
- package/skills/windows-computer-automation/references/routing.md +26 -0
- package/skills/windows-computer-automation/references/scenarios.md +44 -0
- package/skills/windows-computer-automation/references/security.md +24 -0
- package/skills/windows-computer-automation/scripts/policy_engine.py +235 -0
- package/skills/windows-computer-automation/scripts/test_policy_engine.py +107 -0
- package/dist/assets/BotSettingsDialog-DBAjMChc.js +0 -16
- package/dist/assets/NewBotDialog-sfd-FzAz.js +0 -1
- package/dist/assets/TeamLibraryPanel-Djaf5q_z.js +0 -1
- package/dist/assets/channel-DXuqtdcQ.js +0 -1
- package/dist/assets/swimlanesDiagram-K3J5GTZL-VqQY3wNh.js +0 -8
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Offline unit tests. These do not connect to a Windows machine."""
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from policy_engine import decide, in_roots, normal_windows_path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
CONFIG = {
|
|
9
|
+
"available": {"agent_desktop": True, "windows_mcp": True},
|
|
10
|
+
"allowed_read_roots": [r"C:\Users\Public\Documents\Herionix-Exports"],
|
|
11
|
+
"allowed_write_roots": [r"C:\Users\Public\Documents\Herionix-Exports"],
|
|
12
|
+
"system_tools_enabled": False,
|
|
13
|
+
"max_retries_per_step": 1,
|
|
14
|
+
"max_no_progress_cycles": 2,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TestPolicyEngine(unittest.TestCase):
|
|
19
|
+
def route(self, kind, operation, **kwargs):
|
|
20
|
+
return decide({"kind": kind, "operation": operation, **kwargs}, CONFIG)
|
|
21
|
+
|
|
22
|
+
def test_agent_desktop_ui_ref(self):
|
|
23
|
+
ans = self.route("ui", "click", observed=True, target={"ref_id": "@s123:e8"})
|
|
24
|
+
self.assertEqual((ans["status"], ans["tool"]), ("route", "desktop_click"))
|
|
25
|
+
self.assertFalse(ans["executed"])
|
|
26
|
+
|
|
27
|
+
def test_ui_must_observe(self):
|
|
28
|
+
self.assertEqual(self.route("ui", "click", target={"label": "Save"})["status"], "observe_first")
|
|
29
|
+
|
|
30
|
+
def test_windows_mcp_ui_fallback(self):
|
|
31
|
+
cfg = {**CONFIG, "available": {"agent_desktop": False, "windows_mcp": True}}
|
|
32
|
+
ans = decide({"kind": "ui", "operation": "click", "observed": True, "target": {"label": "Save"}}, cfg)
|
|
33
|
+
self.assertEqual((ans["provider"], ans["tool"]), ("windows_mcp", "Click"))
|
|
34
|
+
|
|
35
|
+
def test_stale_ref_pattern_rejected(self):
|
|
36
|
+
self.assertEqual(self.route("ui", "click", observed=True, target={"ref_id": "@e8"})["status"], "observe_first")
|
|
37
|
+
|
|
38
|
+
def test_no_approval_bypass(self):
|
|
39
|
+
self.assertEqual(self.route("ui", "click", observed=True, effect="send", approved=True, target={"ref_id": "@s1:e2"})["status"], "approval_required")
|
|
40
|
+
|
|
41
|
+
def test_powershell_blocked(self):
|
|
42
|
+
self.assertEqual(self.route("shell", "run")["status"], "blocked")
|
|
43
|
+
|
|
44
|
+
def test_registry_needs_approval_when_enabled(self):
|
|
45
|
+
cfg = {**CONFIG, "system_tools_enabled": True}
|
|
46
|
+
self.assertEqual(decide({"kind": "registry", "operation": "write"}, cfg)["status"], "approval_required")
|
|
47
|
+
|
|
48
|
+
def test_read_in_root(self):
|
|
49
|
+
ans = self.route("filesystem", "read", path=r"C:\Users\Public\Documents\Herionix-Exports\a.txt")
|
|
50
|
+
self.assertEqual(ans["tool"], "FileSystem")
|
|
51
|
+
|
|
52
|
+
def test_read_outside_root_needs_approval(self):
|
|
53
|
+
self.assertEqual(self.route("filesystem", "read", path=r"C:\Users\Me\secret.txt")["status"], "approval_required")
|
|
54
|
+
|
|
55
|
+
def test_write_allowed_only_new_inside_root(self):
|
|
56
|
+
req = {"path": r"C:\Users\Public\Documents\Herionix-Exports\new.csv", "target_exists": False}
|
|
57
|
+
self.assertEqual(self.route("filesystem", "write", **req)["status"], "route")
|
|
58
|
+
req["target_exists"] = True
|
|
59
|
+
self.assertEqual(self.route("filesystem", "write", **req)["status"], "approval_required")
|
|
60
|
+
|
|
61
|
+
def test_path_traversal_block(self):
|
|
62
|
+
attack = r"C:\Users\Public\Documents\Herionix-Exports\..\secret.txt"
|
|
63
|
+
self.assertFalse(in_roots(attack, CONFIG["allowed_write_roots"]))
|
|
64
|
+
self.assertEqual(self.route("filesystem", "write", path=attack, target_exists=False)["status"], "blocked")
|
|
65
|
+
|
|
66
|
+
def test_root_prefix_confusion(self):
|
|
67
|
+
attack = r"C:\Users\Public\Documents\Herionix-Exports-OTHER\x.txt"
|
|
68
|
+
self.assertFalse(in_roots(attack, CONFIG["allowed_write_roots"]))
|
|
69
|
+
|
|
70
|
+
def test_unc_and_ads_denied(self):
|
|
71
|
+
self.assertIsNone(normal_windows_path(r"\\server\share\x.txt"))
|
|
72
|
+
self.assertIsNone(normal_windows_path(r"C:\data\file.txt:stream"))
|
|
73
|
+
|
|
74
|
+
def test_delete_requires_approval(self):
|
|
75
|
+
self.assertEqual(self.route("filesystem", "delete", path=r"C:\Users\Public\Documents\Herionix-Exports\x.txt")["status"], "approval_required")
|
|
76
|
+
|
|
77
|
+
def test_max_no_progress_stops(self):
|
|
78
|
+
self.assertEqual(self.route("ui", "click", no_progress_cycles=2)["status"], "halted")
|
|
79
|
+
|
|
80
|
+
def test_duplicate_completed_stops(self):
|
|
81
|
+
self.assertEqual(self.route("ui", "click", step_completed=True)["status"], "already_complete")
|
|
82
|
+
|
|
83
|
+
def test_observe_prefers_accessibility(self):
|
|
84
|
+
ans = self.route("observe", "snapshot")
|
|
85
|
+
self.assertEqual(ans["tool"], "desktop_snapshot")
|
|
86
|
+
|
|
87
|
+
def test_system_observe_prefers_windows(self):
|
|
88
|
+
ans = self.route("observe", "snapshot", scope="system")
|
|
89
|
+
self.assertEqual(ans["provider"], "windows_mcp")
|
|
90
|
+
|
|
91
|
+
def test_both_unavailable(self):
|
|
92
|
+
cfg = {**CONFIG, "available": {"agent_desktop": False, "windows_mcp": False}}
|
|
93
|
+
ans = decide({"kind": "observe", "operation": "snapshot"}, cfg)
|
|
94
|
+
self.assertEqual(ans["status"], "unavailable")
|
|
95
|
+
|
|
96
|
+
def test_app_system(self):
|
|
97
|
+
self.assertEqual(self.route("app", "launch")["tool"], "App")
|
|
98
|
+
|
|
99
|
+
def test_process_kill_requires_approval(self):
|
|
100
|
+
self.assertEqual(self.route("process", "kill")["status"], "approval_required")
|
|
101
|
+
|
|
102
|
+
def test_missing_operation(self):
|
|
103
|
+
self.assertEqual(decide({"kind": "ui"}, CONFIG)["status"], "invalid_request")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if __name__ == "__main__":
|
|
107
|
+
unittest.main()
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{c as Ce,t as s,b as ee,av as Is,j as e,i as Ae,a9 as xe,a as O,r as x,S as Bt,ac as Dt,X as Ft}from"./styles-ElM5u1od.js";import{fg as As,fh as Ls,a2 as Ve,by as Ms,di as $t,w as Ts,fi as Bs,fj as Ds,K as zt,fk as Fs,R as Ht,eu as $s,x as zs,fl as st,bt as at,fm as _t,n as se,u as B,fn as Hs,ah as Ye,F as Ut,A as Kt,S as nt,ad as Pe,T as qt,W as _s,fo as Us,fp as Ks,fq as qs,fr as Ws,fs as Vs,ft as rt,fu as Ys,fv as Gs,fw as Js,fx as Qs,b9 as Xs,fy as Zs,fz as ea,fA as ta,I as sa,fB as je,bP as Ge,fC as aa,aI as L,aO as X,ed as na,dK as ra,fD as ia,aJ as He,cp as la,dZ as oa,d_ as ca,fE as da,fF as Wt,fG as Vt,fH as ua,fI as ma,fJ as pa,fK as xa,dN as _e,ar as it,fL as Le,fM as ha,fN as we,av as fa,fO as Yt,fP as lt,ak as Ue,fQ as ga,fR as ya,fS as va,fT as Gt,fU as ba,fV as ka,fW as ja,fX as wa,fY as Q,aX as te,aZ as J,fZ as Na,f_ as Sa,f$ as Ca,d5 as Pa,d as Oa,G as Ea,d3 as Jt,aj as Ra,g0 as W,aW as ce,g1 as de,g2 as Ia,dp as Aa,g3 as Oe,aY as re,g4 as La,g5 as Ma,g6 as Ta,eh as Ba,g7 as ot,g8 as Da,g9 as Fa,ga as $a,gb as za,gc as Ha,gd as _a,aC as Ua,ge as Qt,gf as Ka,gg as qa,gh as Wa,gi as Va,gj as Ya,gk as Ga,gl as Ja,gm as Qa,gn as Xa,go as Za,gp as en,gq as tn,gr as Je,k as sn,B as Ke,gs as an,gt as nn,gu as rn,gv as ln,bY as on,gw as Xt,J as ct,eY as cn,gx as dt,gy as dn,gz as un,cM as ut,bw as mn,d2 as pn,gA as xn,gB as Zt,gC as be,gD as mt,gE as hn,aM as Me,d$ as fn,gF as gn,aR as yn,C as vn,cq as bn,gG as kn,gH as jn,gI as wn,aT as Nn}from"./App-5fWd2qWI.js";import{z as es,d as ye,a1 as Ne,a2 as Sn,a3 as Cn,a4 as pt,a5 as Te,a6 as Pn,a7 as On,a8 as En,a9 as Rn,aa as In,ab as xt,ac as An,ad as Ln,L as Mn,N as Tn,B as qe,P as Ee,r as Bn,ae as Dn,a0 as Fn,u as ts}from"./PlacesRail-BYBRFGDz.js";import{C as $n}from"./coins-s4HyWHyQ.js";import{C as ge,a as zn}from"./MenuMotion-DnbwlBMa.js";import{b as Z,m as ss,i as We,f as Qe,c as pe,d as ht,e as Se,o as Hn,g as _n,h as oe,n as Be,t as as,s as Xe,j as ns,k as Un,l as Kn,p as qn,r as rs,q as Wn,u as Vn,w as Yn,x as is,y as ls,z as ft,B as Gn,C as os,R as gt,D as Jn,E as Qn,F as Xn,G as Zn,H as er,J as tr,O as sr,K as ar,L as cs,N as yt,V as nr,P as rr,M as ir,A as lr,a as or,S as cr,I as dr}from"./VisibilitySection-yE3ZIXKk.js";import{s as ur,r as mr,a as pr,R as xr}from"./ComputerFilesPane-DA4Txmh9.js";import{M as vt}from"./monitor-IwDx0ohO.js";import{a as ds,m as us,b as hr,c as fr}from"./mcp-servers-qzidl6IU.js";import{R as gr}from"./RoutinesPage-CCSHgNRs.js";import{S as yr}from"./SignedInSites-BdxFX6Wt.js";import"./index-BJo4IICg.js";import"./org-library-97Cfj4XD.js";import"./package-format-MbGfBQ0g.js";import"./WorksOnGrid-DWvjM4aV.js";import"./ProIntroduction-B1eqbu20.js";import"./remote-desktop-DDRRx8uY.js";const vr=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],br=Ce("calendar-plus",vr);const kr=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],jr=Ce("library",kr);const wr=[["rect",{width:"3",height:"8",x:"13",y:"2",rx:"1.5",key:"diqz80"}],["path",{d:"M19 8.5V10h1.5A1.5 1.5 0 1 0 19 8.5",key:"183iwg"}],["rect",{width:"3",height:"8",x:"8",y:"14",rx:"1.5",key:"hqg7r1"}],["path",{d:"M5 15.5V14H3.5A1.5 1.5 0 1 0 5 15.5",key:"76g71w"}],["rect",{width:"8",height:"3",x:"14",y:"13",rx:"1.5",key:"1kmz0a"}],["path",{d:"M15.5 19H14v1.5a1.5 1.5 0 1 0 1.5-1.5",key:"jc4sz0"}],["rect",{width:"8",height:"3",x:"2",y:"8",rx:"1.5",key:"1omvl4"}],["path",{d:"M8.5 5H10V3.5A1.5 1.5 0 1 0 8.5 5",key:"16f3cl"}]],ms=Ce("slack",wr);const Nr=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Sr=Ce("tag",Nr),Cr=[{id:"overview",label:"Overview",labelKey:"botSettings.sections.overview",icon:As,keywords:["summary","status","what it does","won't","prompt","what the model sees"]},{id:"identity",label:"Identity",labelKey:"botSettings.sections.identity",icon:Ls,keywords:["name","title","avatar","blurb","instructions"]},{id:"slack",label:"Slack",icon:ms,keywords:["slack","slack app","admin","message","direct messages","mentions"]},{id:"soul",label:"Soul",labelKey:"botSettings.sections.soul",icon:Ve,keywords:["standing instructions","instructions","persona","rules","soul.md"]},{id:"skills",label:"Skills",labelKey:"botSettings.sections.skills",icon:Ms,keywords:["skills","learned","procedures","teach"]},{id:"memory",label:"Memory",labelKey:"botSettings.sections.memory",icon:$t,keywords:["memory","notes","remember","topics"]},{id:"library",label:"Library",labelKey:"botPanel.tab.library",icon:jr,keywords:["library","made","pages","apps","files","published"]},{id:"routines",label:"Routines",labelKey:"botSettings.sections.routines",icon:Ts,keywords:["schedule","routines","cron","tasks"]},{id:"access",label:"Access",labelKey:"botSettings.sections.access",icon:Bs,keywords:["works on","computer","vm","cloud","vps","folder","workspace","browser","connected apps","composio","webhooks","always allow","grants","tool selection","tools","mcp","allow","exclude"]},{id:"model",label:"Model",labelKey:"botSettings.sections.model",icon:Ds,keywords:["engine","model","provider","cli","effort"]},{id:"permissions",label:"Permissions",labelKey:"botSettings.sections.permissions",icon:zt,keywords:["auto mode","approve","auto approve","review","routine approvals","coordination","chief of staff","section"]},{id:"voice",label:"Voice & alerts",labelKey:"botSettings.sections.voice",icon:Fs,keywords:["voice","alerts","notifications","speak"]},{id:"visibility",label:"Who can see it",labelKey:"botSettings.visibility.title",icon:Ht,keywords:["visibility","who can see","private","people","admins","members","access","hide"]},{id:"history",label:"History",labelKey:"botSettings.sections.history",icon:$s,keywords:["history","changes","undo","rollback","log"]},{id:"usage",label:"Usage",labelKey:"botSettings.sections.usage",icon:$n,keywords:["tokens","cost","billing"]}],bt={completed:"botOverview.routine.last.completed",failed:"botOverview.routine.last.failed",missed:"botOverview.routine.last.missed",cancelled:"botOverview.routine.last.cancelled",running:"botOverview.routine.last.running",queued:"botOverview.routine.last.queued",waiting:"botOverview.routine.last.waiting"};function Pr(t,a=ee()){if(!t||a==="en")return null;if(t.paused)return s("botOverview.routine.paused",{name:t.name});const n=t.lastRun;if(n&&!Object.hasOwn(bt,n.status))return null;try{return[s("botOverview.routine.line",{schedule:zs(t.schedule),name:t.name}),...t.nextRunAt!=null?[s("botOverview.routine.next",{time:st(t.nextRunAt)})]:[],...n?[s(bt[n.status],{time:st(n.at)})]:[]].join(" ")}catch{return null}}const kt={"Works in its private workspace.":"botOverview.line.privateWorkspace","Has the built-in browser.":"botOverview.line.browser","Has no connected apps.":"botOverview.line.noApps","Won't act on a schedule.":"botOverview.line.noSchedule","Can talk to the other bot.":"botOverview.line.talksToOne","Talks only to the bots chosen for it.":"botOverview.line.talksToChosen","Cannot initiate contact with other bots.":"botOverview.line.noPeerContact","Command approvals use Ask mode; saved permissions and provider rules still apply.":"botOverview.line.askMode","Command approvals follow the provider's custom configuration.":"botOverview.line.customApprovals","Asks before contacting other bots.":"botOverview.line.asksPeers","Can't use a computer.":"botOverview.line.noComputer","Profile proposal cards require your approval.":"botOverview.line.profileApproval","Connected apps could not be checked.":"botOverview.line.appsUnchecked"},jt={"Auto; availability is checked when a task starts":"botOverview.preference.auto","cloud computer":"botOverview.preference.cloud","Local VM":"botOverview.preference.vm","this computer":"botOverview.preference.local","browser only":"botOverview.preference.browser"};function wt(t,a){return!a||a.map(n=>n||"General").join(", ")!==t?t:a.map(n=>n||s("botAccess.teams.general")).join(", ")}const Nt=t=>Object.hasOwn(jt,t)?s(jt[t]):t,St=(t,a,n)=>Number(t)===1?a:n,Or=[{line:/^Can talk to all (\d+) other bots, in any department\.$/,key:()=>"botOverview.line.talksToAll",params:([,t])=>({count:Number(t)})},{line:/^Also in charge of these departments: (.+)\.$/,key:()=>"botOverview.line.alsoInCharge",params:([,t],a)=>({departments:wt(t,a)})},{line:/^Can talk to (\d+) other bots? in its (?:section|department)\.$/,key:([,t])=>St(t,"botOverview.line.peersSectionOne","botOverview.line.peersSectionMany"),params:([,t])=>({count:Number(t)})},{line:/^Can talk to (\d+) other bots? in its allowed (?:teams|departments)\.$/,key:([,t])=>St(t,"botOverview.line.peersTeamsOne","botOverview.line.peersTeamsMany"),params:([,t])=>({count:Number(t)})},{line:/^Coordinates its (?:section|department) as Chief of Staff\.$/,key:()=>"botOverview.line.chief",params:()=>({role:s("sidebar.bot.chiefOfStaff")})},{line:/^May also coordinate these (?:teams|departments): (.+)\.$/,key:()=>"botOverview.line.alsoTeams",params:([,t],a)=>({teams:wt(t,a)})}],Er=t=>ee()!=="en"&&Object.hasOwn(Is[ee()]??{},t);function Rr(t,a){for(const n of Or){const l=n.line.exec(t);if(!l)continue;const r=n.key(l);return Er(r)?s(r,n.params(l,a)):t}return null}function De(t,a){if(Object.hasOwn(kt,t))return s(kt[t]);const n=Rr(t,a);if(n!==null)return n;const l=/^Can use (\d+) connected apps?: (.+)\.$/.exec(t);if(l)return s(l[1]==="1"?"botOverview.line.appsOne":"botOverview.line.appsMany",{count:Number(l[1]),apps:l[2]});const r=ee()==="en"?null:/^Computer preference: (.+), which isn't available on My Cloud\.$/.exec(t);if(r)return s("botOverview.line.computerNotOnCloud",{preference:Nt(r[1])});const i=/^Computer preference: (.+)\.$/.exec(t);if(i)return s("botOverview.line.computer",{preference:Nt(i[1])});const c=/^Works in (.+)\.$/.exec(t);if(c)return s("botOverview.line.folder",{folder:c[1]});const d=/^Knows how to (.+)\.$/.exec(t);if(d)return s("botOverview.line.skill",{skill:d[1]});const o=/^Listens for “(.+)” webhooks\.$/.exec(t);return o?s("botOverview.line.webhook",{name:o[1]}):t}const Ct={name:"approval.applied.field.name",title:"approval.applied.field.title",description:"approval.applied.field.description",soul:"approval.applied.field.soul",cwd:"approval.applied.field.cwd",notifications:"approval.applied.field.notifications",speakReplies:"approval.applied.field.speakReplies"};function Ir(t,a=ee()){const n=/^(\w+): /.exec(t)?.[1];return a==="en"||!n||!Object.hasOwn(Ct,n)?t:`${s(Ct[n])}: ${t.slice(n.length+2)}`}function Ar({data:t,error:a,open:n,onToggle:l}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("button",{type:"button",onClick:l,"aria-expanded":n,className:"flex w-full items-center justify-between gap-3 text-left",children:[e.jsx("span",{className:"text-[15px] font-medium text-ink",children:t?s("botOverview.promptPreviewCount",{bytes:t.totalBytes.toLocaleString(Ae()),tokens:t.approxTokens.toLocaleString(Ae())}):s("botOverview.promptPreview")}),e.jsx(xe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",n&&"rotate-180")})]}),n&&!t&&a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.promptError")}),n&&!t&&!a&&e.jsx("div",{className:"mt-3 text-[13px] text-ink-secondary",children:s("botOverview.loading")}),n&&t&&e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[t.sections.map(r=>e.jsxs("details",{className:"rounded-lg border border-hairline/40 bg-inset px-3 py-2",children:[e.jsxs("summary",{className:"flex cursor-pointer items-center justify-between gap-3 text-[13px] text-ink",children:[e.jsx("span",{children:r.label}),e.jsx("span",{className:"shrink-0 tabular-nums text-ink-secondary",children:s("botOverview.bytes",{count:r.bytes.toLocaleString(Ae())})})]}),e.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-relaxed text-ink",children:r.text})]},r.id)),t.note&&e.jsx("div",{className:"text-[11px] text-ink-secondary",children:t.note})]})]})}function Lr({overview:t,refreshError:a,prompt:n,promptError:l,onOpen:r,onSetup:i}){const[c,d]=x.useState(!1);if(!t)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("botOverview.loading")});const u=(t.setup??[]).filter(h=>!h.done),m=(h,b)=>s(`botOverview.setup.${h}`)||b;return e.jsxs("div",{className:"flex flex-col gap-4",children:[a&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("botOverview.refreshError")}),u.length>0&&e.jsxs("div",{className:"rounded-xl border border-accent/30 bg-accent/[0.06] p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botSetup.ideas")}),e.jsx("p",{className:"mt-1 text-[13px] text-ink-secondary",children:s("botSetup.optional")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1",children:u.map(h=>e.jsx("li",{children:h.section?e.jsxs("button",{type:"button",onClick:()=>r(h.section),className:"flex w-full items-center gap-2.5 rounded-lg px-1 py-1 text-left text-[13px] text-ink hover:bg-inset",children:[e.jsx(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"flex-1",children:m(h.id,h.label)}),e.jsx(ge,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-secondary rtl:-scale-x-100"})]}):e.jsxs("div",{className:"flex items-center gap-2.5 px-1 py-1 text-[13px] text-ink",children:[e.jsx(at,{"aria-hidden":"true",size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{children:m(h.id,h.label)})]})},h.id))}),i&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink hover:brightness-110",children:[e.jsx(Ve,{size:14})," ",s("botSetup.withBot")]}),e.jsx("span",{className:"text-[12px] text-ink-secondary",children:s("botSetup.help")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:t.who.name}),t.who.title&&e.jsx("div",{className:"mt-0.5 text-[13px] text-ink-secondary",children:t.who.title}),t.who.blurb&&e.jsx("p",{className:"mt-2 text-[13px] leading-relaxed text-ink",children:t.who.blurb}),t.who.soulLead&&e.jsxs("div",{className:"mt-3 rounded-lg bg-inset px-3 py-2.5",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink-secondary",children:t.who.soulLead}),e.jsx("button",{type:"button",onClick:()=>r("soul"),className:"mt-1.5 rounded-md text-[12px] font-medium text-accent-text hover:underline",children:s("botOverview.readAll")})]})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.does")}),t.does.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.doesEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.does.map((h,b)=>e.jsx("li",{children:Pr(t.doesRoutines?.[b])??De(h)},b))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.canReach")}),t.reaches.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.reachEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.reaches.map((h,b)=>e.jsx("li",{children:De(h,t.managedSections)},b))})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.wont")}),e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] leading-relaxed text-ink",children:t.wont.map((h,b)=>e.jsx("li",{children:De(h,t.managedSections)},b))})]}),e.jsx(Ar,{data:n,error:l,open:c,onToggle:()=>d(h=>!h)}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("botOverview.recentChanges")}),e.jsxs("button",{type:"button",onClick:()=>r("history"),className:"shrink-0 text-[12px] text-ink-secondary hover:text-ink",children:[s("botOverview.viewAll")," ",e.jsx(ge,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),t.recent.length===0?e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("botOverview.recentEmpty")}):e.jsx("ul",{className:"mt-2 flex flex-col gap-1.5 text-[13px] text-ink",children:t.recent.map((h,b)=>e.jsxs("li",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"min-w-0 truncate",children:Ir(h.summary)}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:["· ",_t(h.at)]})]},b))})]})]})}function Mr({managementUrl:t}){return e.jsxs("div",{className:"flex flex-col gap-3 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx("p",{children:s("botSlack.body")}),e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"flex w-fit items-center gap-2 rounded-lg bg-control px-3 py-2 font-medium text-ink hover:bg-control/70",children:[s("botSlack.manage")," ",e.jsx(es,{size:14,"aria-hidden":"true"})]})]})}function Tr(t){if(!t||typeof t!="object")return null;const{available:a,managementUrl:n}=t;if(a!==!0||typeof n!="string")return null;try{return new URL(n).protocol==="https:"?n:null}catch{return null}}function ps(t){const[a,n]=x.useState(null);return x.useEffect(()=>{const l=new AbortController;return se(`/api/bots/${encodeURIComponent(t)}/slack-management`,{signal:l.signal,timeoutMs:1e4}).then(r=>{l.signal.aborted||n({botId:t,url:Tr(r)})}).catch(()=>{l.signal.aborted||n({botId:t,url:null})}),()=>l.abort()},[t]),a?.botId===t?a.url:null}const ne="rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover disabled:opacity-50",Fe="rounded-md px-2 py-1 text-[13px] text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-50",ae=t=>t instanceof Error?t.message:String(t);function xs(t){const a=[],n=(r,i,c)=>{r&&a.push(s(r===1?i:c,{count:r}))};n(t.expired,"memory.upkeep.summary.archived.one","memory.upkeep.summary.archived.many"),n(t.duplicates,"memory.upkeep.summary.merged.one","memory.upkeep.summary.merged.many"),n(t.superseded,"memory.upkeep.summary.crossed.one","memory.upkeep.summary.crossed.many"),n(t.organized,"memory.upkeep.summary.filed.one","memory.upkeep.summary.filed.many");const l=a.length?a.join(", "):s("memory.upkeep.summary.none");return l.charAt(0).toUpperCase()+l.slice(1)}function Br(t,a){const n=t.via==="team-setup"?s("memory.journal.actor.teamSetup"):t.actor==="bot"?a:t.actor==="import"?s("memory.journal.actor.import"):t.actor==="upkeep"?s("memory.journal.actor.upkeep"):s("memory.journal.actor.you"),l=Wn(t.path),r=t.path===Z?l:t.path===Vn?s("memory.journal.instructions"):t.path.startsWith("memory/log/")?s("memory.journal.log",{file:l}):s("memory.journal.topic",{file:l}),i=c=>s(c===1?"memory.journal.line.one":"memory.journal.line.many",{count:c});return t.kind==="created"?s("memory.journal.created",{who:n,topic:r,detail:t.added?s("memory.journal.withLines",{lines:i(t.added)}):""}):t.kind==="deleted"?s("memory.journal.deleted",{who:n,topic:r}):t.added&&!t.removed?s("memory.journal.added",{who:n,lines:i(t.added),topic:r}):t.removed&&!t.added?s("memory.journal.removed",{who:n,lines:i(t.removed),topic:r}):s("memory.journal.rewrote",{who:n,lines:i(Math.max(t.added,t.removed)),topic:r})}function hs({changed:t,stale:a,busy:n,onReviewed:l}){return e.jsxs("div",{role:"status",className:"rounded-xl border border-danger/40 bg-card p-4",children:[e.jsx("p",{className:"text-[13px] leading-relaxed text-ink",children:s(a?"memory.lendingReviewStale":"memory.lendingReview")}),t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.lendingReviewChanged")}),e.jsx("ul",{className:"mt-1 space-y-0.5",children:t.map(r=>e.jsx("li",{className:"break-all font-mono text-[12px] text-ink",children:r},r))})]}),e.jsx("button",{type:"button",className:O(ne,"mt-3"),disabled:n,onClick:l,children:s("memory.lendingReviewed")})]})}function Dr({bot:t,active:a=!0,onToggle:n}){const{capabilities:l}=ye(),[r,i]=x.useState(null),[c,d]=x.useState(null),[o,u]=x.useState(null),[m,h]=x.useState(null),[b,f]=x.useState(null),[v,j]=x.useState(null),[k,y]=x.useState(null),[N,S]=x.useState(!1),[E,M]=x.useState(null),[F,T]=x.useState(""),[I,z]=x.useState(null),[A,p]=x.useState(!1),[R,D]=x.useState(null),[H,_]=x.useState(!1),[G,Y]=x.useState(!1),{state:U,dispatch:g}=B(),$=Hs(U.config),[ie,ue]=x.useState(!1),[he,C]=x.useState(""),K=async w=>{const[P,Re,Rs]=await Promise.all([Qe(t.id),pe(t.id),ht(t.id).catch(()=>null)]);if(i(P),D(P.lendingReview??null),d(Re),z(Rs),w){const Ie=await Se(t.id,w);u({path:Ie.path,text:Ie.text,hash:Ie.hash,dirty:!1,readOnly:w.startsWith("memory/log/")})}};x.useEffect(()=>{if(!a)return;let w=!1;j(null);const P=o?.dirty===!0;return K(P?void 0:o?.path??Z).catch(Re=>{w||j(ae(Re))}),()=>{w=!0}},[a,t.id]);const V=async w=>{j(null),h(null);try{const P=await Se(t.id,w);u({path:P.path,text:P.text,hash:P.hash,dirty:!1,readOnly:w.startsWith("memory/log/")})}catch(P){j(ae(P))}},q=async w=>{if(o){S(!0),j(null);try{const P=await Xe(t.id,o.path,o.text,w);if(!P.ok){h({path:o.path,current:P.current,currentHash:P.currentHash});return}h(null),f(null),u({...o,text:P.doc.text,hash:P.doc.hash,dirty:!1}),i(P.overview),d(await pe(t.id))}catch(P){j(ae(P))}finally{S(!1)}}},le=()=>{!m||!o||(f(o.text),u({...o,text:m.current,hash:m.currentHash,dirty:!1}),h(null))},ve=async w=>{if(window.confirm(s("memory.confirmDelete",{name:w.name}))){j(null);try{const{overview:P}=await ns(t.id,w.path);i(P),d(await pe(t.id)),o?.path===w.path&&u(null)}catch(P){j(ae(P))}}},et=async()=>{const w=Un(F);if(!w){j(s("memory.topicNameError"));return}T(""),await V(`memory/${w}`),u(P=>P&&{...P,dirty:!0,text:P.text||Fr(w)})},Ss=async w=>{M(w.id),j(null);try{const P=await rs(t.id,w.id);i(P.overview),d(await pe(t.id)),o?.path===w.path&&!o.dirty&&u({...o,text:P.text,hash:P.hash}),y(s("memory.restored",{path:w.path}))}catch(P){j(ae(P))}finally{M(null)}},tt=async w=>{j(null),y(null);try{await Hn(t.id,w)}catch(P){j(ae(P))}},Cs=()=>{const w=t.memoryUpkeep===!1;g({type:"updateBot",botId:t.id,patch:{memoryUpkeep:w}}),z(P=>P&&{...P,enabled:w})},Ps=async()=>{if(!ie){ue(!0),C("");try{const w=await se("/api/config",{method:"PATCH",body:JSON.stringify({features:{roomMemoryCapture:!$}})});g({type:"configStatus",config:w})}catch(w){C(w instanceof Error?w.message:s("memory.learnFromRooms.error"))}finally{ue(!1)}}},Os=async()=>{p(!0),j(null),y(null);try{const{report:w,overview:P}=await as(t.id);i(P),d(await pe(t.id)),z(await ht(t.id)),o&&!o.dirty&&await V(o.path),y(`${xs(w)}.${w.note?` ${w.note}`:""}`)}catch(w){j(ae(w))}finally{p(!1)}},Es=l.host.homeDir;return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.title")}),e.jsxs("label",{className:"mt-3 flex items-center gap-2 text-[13px] text-ink",children:[e.jsx("input",{type:"checkbox",checked:t.memoryEnabled!==!1,disabled:t.busy,onChange:w=>n(w.target.checked)}),s("memory.enable")]}),e.jsxs("p",{className:"mt-1 text-[13px] text-ink-secondary",children:[s("memory.enableHelp"),t.busy?` ${s("memory.busyHelp")}`:""]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.notesHelp")}),r&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-secondary",title:r.workspacePath,children:Ye(r.workspacePath,Es)}),e.jsx("button",{type:"button",className:ne,onClick:()=>{tt("obsidian")},children:s("memory.openObsidian")}),e.jsxs("button",{type:"button",className:O(ne,"inline-flex items-center gap-1.5"),onClick:()=>{tt("folder")},children:[e.jsx(Ut,{size:14}),s("memory.showFileManager")]})]})]}),R&&e.jsx(hs,{changed:R.changed,stale:H,busy:G,onReviewed:()=>{Y(!0),ss(t.id,R.token).then(()=>{D(null),_(!1)}).catch(w=>{if(w instanceof Kt&&w.status===409)return _(!0),K();j(ae(w))}).finally(()=>Y(!1))}}),r&&e.jsx(zr,{index:r.index}),t.memoryEnabled!==!1&&e.jsx($r,{enabled:t.memoryUpkeep!==!1,status:I,tidying:A,onToggle:Cs,onTidy:()=>{Os()},rooms:{enabled:$,saving:ie,error:he,onToggle:()=>{Ps()}}}),o&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:o.path}),o.path!==Z&&e.jsx("button",{type:"button",className:Fe,onClick:()=>{V(Z)},children:s("memory.backToIndex")})]}),m&&e.jsx(fs,{botName:t.name,busy:N,onReload:le,onOverwrite:()=>{q(m.currentHash)}}),e.jsx("textarea",{className:O(We,"mt-2 min-h-[200px] resize-y font-mono text-[13px] leading-relaxed"),value:o.text,readOnly:o.readOnly,placeholder:o.path===Z?s("memory.indexPlaceholder"):s("memory.notePlaceholder"),"aria-label":o.path===Z?s("memory.botMemory"):s("memory.fileLabel",{path:o.path}),onChange:w=>u({...o,text:w.target.value,dirty:!0})}),o.readOnly?e.jsx("p",{className:"mt-2 text-[12px] text-ink-secondary",children:s("memory.logsReadOnly")}):e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{q(o.hash)},disabled:N||!o.dirty,className:ne,children:N?s("memory.saving"):s("memory.save")}),o.dirty&&e.jsx("button",{type:"button",className:Fe,disabled:N,onClick:()=>{V(o.path)},children:s("memory.discard")})]}),b!==null&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:b}),e.jsx("button",{type:"button",className:O(Fe,"mt-1"),onClick:()=>f(null),children:s("memory.dismissDraft")})]})]}),r&&e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx(Ot,{title:s("memory.topicFiles"),hint:s("memory.topicFilesHint"),files:r.topics,selected:o?.path,onOpen:w=>{V(w.path)},onDelete:w=>{ve(w)}}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("input",{className:O(We,"py-1.5 text-[13px]"),value:F,placeholder:s("memory.newTopicPlaceholder"),"aria-label":s("memory.newTopicLabel"),onChange:w=>T(w.target.value),onKeyDown:w=>{w.key==="Enter"&&et()}}),e.jsx("button",{type:"button",className:ne,disabled:!F.trim(),onClick:()=>{et()},children:s("memory.newTopic")})]}),r.logs.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(Ot,{title:s("memory.dailyLogs"),hint:s("memory.dailyLogsHint"),files:r.logs,selected:o?.path,onOpen:w=>{V(w.path)},onDelete:w=>{ve(w)}})})]}),e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.changes")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.changesHelp")}),e.jsx("div",{className:"mt-3",children:e.jsx(Ze,{rows:c,botName:t.name,reverting:E,onRevert:w=>{Ss(w)}})})]}),k&&e.jsx("div",{className:"text-[13px] text-ink-secondary",children:k}),v&&e.jsx("div",{className:"text-[13px] text-danger",children:v})]})}function Fr(t){return`---
|
|
2
|
-
title: ${t.replace(/\.md$/,"")}
|
|
3
|
-
description:
|
|
4
|
-
aliases: []
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
`}function $r({enabled:t,status:a,tidying:n,onToggle:l,onTidy:r,rooms:i}){return e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("memory.upkeep.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.upkeep.help")})]}),e.jsx(nt,{checked:t,"aria-label":s("memory.upkeep.title"),onClick:l})]}),t&&i&&e.jsxs("div",{className:"mt-3 flex items-start justify-between gap-3 border-t border-hairline/40 pt-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] font-medium text-ink",children:s("memory.learnFromRooms.title")}),e.jsx("p",{className:"mt-0.5 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.subtitle")}),a&&!a.modelSteps&&e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("memory.learnFromRooms.noModelSteps")}),i.error&&e.jsx("p",{role:"alert",className:"mt-1 text-[13px] text-danger",children:i.error})]}),e.jsx(nt,{checked:i.enabled,"aria-label":s("memory.learnFromRooms.title"),disabled:i.saving,onClick:i.onToggle,className:"disabled:cursor-wait disabled:opacity-50"})]}),t&&a&&!a.modelSteps&&e.jsx("p",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.upkeep.noModelSteps")}),t&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3",children:[e.jsx("button",{type:"button",className:ne,disabled:n,onClick:r,children:n?s("memory.upkeep.tidying"):s("memory.upkeep.tidyNow")}),e.jsxs("span",{className:"text-[13px] text-ink-secondary",children:[a?.lastTidy?s("memory.upkeep.lastTidy",{time:Ne(a.lastTidy.at,ee()),summary:xs(a.lastTidy).toLowerCase()}):s("memory.upkeep.notTidied"),a?.lastCapture&&Be(a.lastCapture)?` ${s(Be(a.lastCapture)===1?"memory.upkeep.lastNoticed.one":"memory.upkeep.lastNoticed.many",{count:Be(a.lastCapture),time:Ne(a.lastCapture.at,ee())})}`:""]})]})]})}function zr({index:t}){const a=_n(t),n=a.level==="over"?"bg-danger":a.level==="near"?"bg-warning":"bg-accent";return e.jsxs("div",{className:O("rounded-xl p-4",a.level==="over"?"border border-danger/30 bg-danger/10":"bg-card"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[13px]",children:[e.jsx("span",{className:"font-medium text-ink",children:s("memory.capacity.title")}),e.jsx("span",{className:O("text-[12px]",a.level==="over"?"text-danger":"text-ink-secondary"),children:s("memory.capacity.summary",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes)})})]}),e.jsx(Pt,{label:s("memory.capacity.lines"),share:a.lineShare,fill:n}),e.jsx(Pt,{label:s("memory.capacity.size"),share:a.byteShare,fill:n}),e.jsx("p",{className:O("mt-2 text-[13px] leading-relaxed",a.level==="over"?"text-danger":"text-ink-secondary"),children:a.warning??s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})}),a.warning&&e.jsx("p",{className:"mt-1 text-[12px] text-ink-secondary",children:s("memory.capacity.sentence",{lines:t.lines,maxLines:t.maxLines,bytes:oe(t.bytes),maxBytes:oe(t.maxBytes),maxLoaded:t.maxLines})})]})}function Pt({label:t,share:a,fill:n}){const l=`${Math.min(100,Math.round(a*100))}%`;return e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[12px] text-ink-secondary",children:[e.jsx("span",{className:"w-10 shrink-0",children:t}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-inset",role:"meter","aria-label":s("memory.capacity.used",{label:t}),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.min(100,Math.round(a*100)),children:e.jsx("div",{className:O("h-full rounded-full",n),style:{width:l}})})]})}function fs({botName:t,busy:a,onReload:n,onOverwrite:l}){return e.jsxs("div",{className:"mt-2 rounded-lg border border-warning/25 bg-warning/10 p-3 text-[13px] leading-relaxed text-ink",children:[e.jsx("div",{className:"font-medium",children:s("memory.conflict.title",{name:t})}),e.jsx("div",{className:"mt-0.5 text-ink-secondary",children:s("memory.conflict.help",{name:t})}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx("button",{type:"button",className:ne,disabled:a,onClick:n,children:s("memory.reload")}),e.jsx("button",{type:"button",className:ne,disabled:a,onClick:l,children:s("memory.overwrite")})]})]})}function Ot({title:t,hint:a,files:n,selected:l,onOpen:r,onDelete:i}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary",children:t}),e.jsx("div",{className:"mt-0.5 text-[12px] text-ink-secondary",children:a}),n.length===0?e.jsx("div",{className:"mt-2 text-[13px] text-ink-secondary",children:s("memory.noneYet")}):e.jsx("div",{className:"mt-2 overflow-hidden rounded-lg border border-hairline/40",children:n.map(c=>e.jsxs("div",{className:O("flex items-center gap-2 border-b border-hairline/40 px-3 py-2 last:border-b-0",l===c.path?"bg-control/60":"hover:bg-control/40"),children:[e.jsxs("button",{type:"button",onClick:()=>r(c),className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate font-mono text-[13px] text-ink",children:c.name}),e.jsxs("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:[oe(c.bytes)," · ",Ne(c.modifiedAt,ee())]})]}),e.jsx("button",{type:"button",onClick:()=>i(c),"aria-label":s("memory.deleteFile",{name:c.name}),title:s("memory.delete"),className:"shrink-0 rounded-md p-1 text-ink-secondary hover:bg-control hover:text-danger",children:e.jsx(qt,{size:14})})]},c.path))})]})}function Ze({rows:t,botName:a,reverting:n,onRevert:l,now:r=Date.now()}){return t?t.length===0?e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.noChanges")}):e.jsx("div",{className:"flex flex-col gap-2",children:t.map(i=>{const c=Kn(i),d=qn(i);return e.jsxs("div",{className:"rounded-lg bg-inset px-3 py-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{children:Br(i,a)})," · ",e.jsx("span",{className:"text-ink-secondary",children:Ne(i.at,ee(),r)}),c&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{className:"text-ink-secondary",children:d?s(d,i.threadTitle?{title:i.threadTitle}:void 0):c})]})]}),i.canRevert?e.jsxs("button",{type:"button",disabled:n!==null,onClick:()=>l(i),className:"inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:[e.jsx(_s,{size:12}),n===i.id?s("memory.undoing"):s("memory.undo")]}):e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",title:i.revertUnavailableReason,children:s("memory.cantUndo")})]}),i.diff&&e.jsxs("details",{className:"mt-1",children:[e.jsxs("summary",{className:"cursor-pointer text-[12px] text-ink-secondary",children:["+",i.added," −",i.removed," · ",s("memory.showChanged")]}),e.jsx("pre",{className:"mt-1 max-h-[240px] overflow-auto whitespace-pre-wrap rounded-md bg-card p-2 font-mono text-[12px] leading-relaxed text-ink",children:i.diff})]})]},i.id)})}):e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("memory.loading")})}function Hr({bot:t,rows:a,refreshError:n,onRollback:l,rollingBack:r}){if(!a)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.loading")});if(a.length===0)return e.jsx("div",{className:"text-[13px] text-ink-secondary",children:s("history.empty")});const i=[...a].sort((c,d)=>d.at-c.at);return e.jsxs("div",{className:"flex flex-col gap-2",children:[n&&e.jsx("div",{className:"rounded-lg bg-inset px-3 py-2 text-[13px] text-ink-secondary",children:s("history.refreshError")}),i.map(c=>e.jsxs("div",{className:"rounded-xl bg-card p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1 text-[13px] leading-relaxed text-ink",children:[e.jsx("span",{className:"text-ink-secondary",children:_t(c.at)})," · ",e.jsxs("span",{children:[c.actor," via ",c.via]})," · ",e.jsx("span",{children:c.summary})]}),c.field==="soul"&&c.canRestore===!0&&e.jsx("button",{type:"button",disabled:r,onClick:()=>l(c.id),className:"shrink-0 rounded-md px-2 py-1 text-[12px] font-medium text-accent-text hover:bg-accent/10 disabled:opacity-50",children:s("history.undo")})]}),c.field==="soul"&&c.canRestore!==!0&&e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary",children:c.restoreUnavailableReason??s("history.restoreUnavailable")})]},`${t.id}-${c.id}`))]})}function _r({bot:t,bare:a=!1}){const{state:n,dispatch:l}=B(),r=Us(t),i=n.instances.find(c=>c.instanceId===t.modelSelection.instanceId);return r.turns===0?e.jsx("div",{className:O(a?"":"rounded-xl bg-card p-4","text-[13px] text-ink-secondary"),children:s("usage.bot.empty")}):e.jsxs("div",{className:a?void 0:"rounded-xl bg-card p-4",children:[!a&&e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"text-[15px] font-medium text-ink",children:s("usage.title")}),e.jsxs("button",{onClick:()=>l({type:"toggleAppSettings",open:!0,section:"usage"}),className:"text-[12px] text-ink-secondary hover:text-ink",children:[s("usage.allBots")," ",e.jsx(ge,{size:14,"aria-hidden":"true",className:"inline align-[-2px] rtl:-scale-x-100"})]})]}),e.jsxs("div",{className:O("grid grid-cols-3 gap-3 text-[13px]",!a&&"mt-3"),children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colTurns")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:r.turns})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:Ks(r)}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",title:Vs(r),children:qs(Ws(r))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wide text-ink-secondary",children:s("usage.colCost")}),e.jsx("div",{className:"mt-0.5 tabular-nums text-ink",children:rt(r.costUsd)?Ys(r.costUsd):"—"})]})]}),e.jsx("div",{className:"mt-2 text-[12px] text-ink-secondary",children:rt(r.costUsd)?s("usage.costLine",{caption:Gs(i?.snapshot.billing)}):s("usage.bot.unpriced")})]})}const Ur=[["bot","botPanel.avatar.tabBot"],["generate","botPanel.avatar.tabGenerate"],["upload","botPanel.avatar.tabUpload"]],Kr=["circle","rounded","square"],qr={circle:"botPanel.avatar.circle",rounded:"botPanel.avatar.rounded",square:"botPanel.avatar.square"},Wr={idle:"botPanel.face.idle",happy:"botPanel.face.happy",curious:"botPanel.face.curious",drowsy:"botPanel.face.drowsy",working:"botPanel.face.working",thinking:"botPanel.face.thinking",listening:"botPanel.face.listening",sleeping:"botPanel.face.sleeping",suspicious:"botPanel.face.suspicious",proud:"botPanel.face.proud"},Vr=t=>{const a=Wr[t];return a?s(a):t};function Yr({bot:t,activeState:a,onPatch:n,onClose:l}){const r=Js(t,n),{fileRef:i,crop:c,uploading:d,generating:o,busy:u,error:m,upload:h,removeImage:b,generate:f}=r,v=c!=="mascot"&&!!t.avatarUrl,[j,k]=x.useState(v?"upload":"bot"),y=x.useRef(null);x.useEffect(()=>{y.current?.querySelector('[aria-selected="true"]')?.focus()},[]);const N=p=>n(c==="mascot"?p:{...p,avatarCrop:"mascot"}),S=t.mascotBody??"cursor",E=Sn(),M=Cn(t.mascotBody,t.color,E),[F,T]=x.useState(()=>!!E||pt(S)||!!(t.mascotExpression&&t.mascotExpression!=="idle")),I=E&&M!==S&&pt(M)?Te(M):null,z=(p,R)=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":!v&&S===p,"aria-label":s("mascot.useBody",{name:R}),title:R,onClick:()=>N({mascotBody:p}),className:O("flex h-[58px] items-center justify-center rounded-xl disabled:opacity-50",!v&&S===p?"bg-ink/[0.08] ring-[1.5px] ring-inset ring-ink/25":"hover:bg-ink/[0.05]"),children:e.jsx(Tn,{color:t.color,faceColor:t.mascotFaceColor,bodyId:p,size:40,animated:!1,trackPointer:!1})},p),A=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),l())};return e.jsxs("div",{role:"dialog","aria-label":s("botPanel.avatar.edit"),"data-panel-avatar-editor":!0,onKeyDown:A,className:"popover-surface absolute inset-x-[-5px] top-[80px] z-30 overflow-hidden rounded-2xl border border-ink/[0.08] bg-menu text-left shadow-2xl shadow-black/50",children:[e.jsxs("div",{ref:y,className:"flex items-center gap-0.5 border-b border-ink/[0.06] p-2",children:[Ur.map(([p,R])=>e.jsx("button",{type:"button",role:"tab","aria-selected":j===p,"data-avatar-tab":p,onClick:()=>k(p),className:O("rounded-lg px-[11px] py-[5px] text-[13px]",j===p?"bg-ink/[0.08] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(R)},p)),e.jsx("button",{type:"button","data-avatar-reset":!0,disabled:u,onClick:()=>n(Qs),className:"ml-auto rounded-lg px-[11px] py-[5px] text-[13px] text-ink-secondary hover:text-ink disabled:opacity-50",children:s("botPanel.avatar.reset")})]}),e.jsxs("div",{className:"p-3",children:[j==="bot"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:Pn.map(p=>z(p,Te(p)))}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2 px-1 pb-1 pt-3.5",children:Xs.map(p=>e.jsx("button",{type:"button",disabled:u,"aria-pressed":t.color===p,"aria-label":s("mascot.useColor",{color:Rn(p)}),title:s(En[p]),onClick:()=>N({color:p}),className:O("size-6 rounded-full disabled:opacity-50",t.color===p&&"ring-2 ring-ink/80 ring-offset-2 ring-offset-menu"),style:{background:On(p)}},p))}),e.jsx(Yn,{bot:t,disabled:u,onPatch:N}),e.jsxs("button",{type:"button","data-avatar-more":!0,"aria-expanded":F,onClick:()=>T(p=>!p),className:"mx-auto mt-2.5 flex items-center gap-1 rounded-full px-2.5 py-1 text-[12px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[s("botPanel.avatar.more"),e.jsx(xe,{size:13,"aria-hidden":"true",className:O("transition-transform",F&&"rotate-180")})]}),F&&e.jsxs("div",{"data-avatar-more-looks":!0,children:[In.map(p=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 px-1 pb-1.5 pt-2 text-[12px] text-ink-tertiary",children:[e.jsx("span",{children:xt(p)}),p===E&&I&&e.jsx("span",{"data-avatar-costume":!0,children:s("botPanel.avatar.costume",{name:I,skin:xt(p)})})]}),e.jsx("div",{className:"grid grid-cols-5 gap-1.5","data-festival-bodies":p,children:An[p].bodies.map(R=>z(R,Te(R)))})]},p)),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1.5 pt-2.5",role:"group","aria-label":s("botPanel.avatar.face"),children:[e.jsx("span",{className:"mr-0.5 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.face")}),Ln.map(p=>e.jsx("button",{type:"button",disabled:u,"data-avatar-face":p,"aria-pressed":a===p,onClick:()=>N({mascotExpression:p}),className:O("rounded-full px-2.5 py-1 text-[12px] disabled:opacity-50",a===p?"bg-ink/[0.15] text-ink":"bg-ink/[0.04] text-ink-secondary hover:text-ink"),children:Vr(p)},p))]})]})]}),j==="generate"&&e.jsx("div",{className:"[&>div:first-child]:mt-0 [&>div:first-child]:border-0 [&>div:first-child]:pt-0",children:e.jsx(Zs,{botLabel:t.title||t.name,disabled:d,generating:o,onGenerate:f})}),j==="upload"&&e.jsxs(e.Fragment,{children:[e.jsx(ea,{busy:u,onUpload:p=>{h(p)}}),v&&e.jsx(ta,{bot:t,disabled:u,onPatch:n}),e.jsx("input",{ref:i,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"sr-only",onChange:p=>{h(p.target.files?.[0])}}),e.jsxs("button",{type:"button","data-avatar-drop":!0,disabled:u,onClick:()=>i.current?.click(),onDragOver:p=>p.preventDefault(),onDrop:p=>{p.preventDefault(),h(p.dataTransfer.files?.[0])},className:"flex w-full flex-col items-center gap-1.5 rounded-xl border-[1.5px] border-dashed border-ink/15 px-3 py-6 text-center text-[13px] text-ink-secondary hover:border-ink/25 hover:text-ink disabled:opacity-50",children:[d?e.jsx(Mn,{size:22,className:"animate-spin"}):e.jsx(sa,{size:22}),e.jsx("span",{children:s("botPanel.avatar.drop")}),e.jsx("span",{className:"text-[12px] text-ink-tertiary",children:s("botPanel.avatar.types")})]}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2.5",children:[e.jsx("span",{className:"shrink-0 text-[12px] text-ink-secondary",children:s("botPanel.avatar.shape")}),e.jsx(je,{attr:"data-avatar-crop",label:s("botPanel.avatar.shape"),value:v?c:null,onChange:p=>n({avatarCrop:p}),options:Kr.map(p=>({value:p,label:s(qr[p]),disabled:u||!t.avatarUrl}))}),t.avatarUrl&&e.jsx("button",{type:"button",onClick:b,disabled:u,"aria-label":s("botIdentity.removeAvatar"),title:s("botPanel.avatar.remove"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50",children:e.jsx(qt,{size:14})})]}),!v&&e.jsx("p",{className:"mt-2 text-[12px] text-ink-tertiary",children:s("botPanel.avatar.uploadHint")})]}),m&&e.jsx("div",{role:"alert",className:"mt-3 text-[12px] text-danger",children:m})]})]})}const Gr=()=>s("place.off");function gs(t){const{dispatch:a}=B();return(n="computer")=>{ra(t.id,n),a({type:"toggleSettings",open:!1}),a({type:"toggleComputer",open:!0})}}function Jr(t,a){const[n,l]=x.useState(null);return x.useEffect(()=>{if(!a)return;let r=!1;return se(`/api/browser-sites?bot=${encodeURIComponent(t.id)}`).then(i=>{r||l({botId:t.id,count:i.sites?.length??0})}).catch(()=>{}),()=>{r=!0}},[t.id,a]),n?.botId===t.id?n.count:null}function ys(t){const{state:a}=B(),{capabilities:n}=ye(),l=n.host?.platform??"other",r=ia(t),i=t.computer??"auto",c=a.config?.browserEngine?.myChrome===!0&&(a.config?.browserProfiles??[]).some(f=>f.id===t.browserProfile&&f.browser==="chrome"),d=f=>f==="browser"&&c?s("settings.profiles.myChrome"):ca(f,l),o=f=>{const{view:v,reachable:j}=r[f];return{value:f,label:d(f),disabled:!j,hint:!j||oa(v)?v.line:void 0}},u=[{value:"auto",label:s("computer.simple.dest.letItChoose")},...r.local.policy?[o("local")]:[],...r.browser.policy||i==="browser"?[o("browser")]:[],...r.cloud.policy?[o("cloud")]:[],...r.vm.policy||i==="vm"?[o("vm")]:[],...i==="off"?[{value:i,label:Gr(),disabled:!0}]:[]],m=t.tasks?.find(f=>f.threadId===t.threadId)?.surface,h=m&&m!==i?d(m):null,b=u.find(f=>f.value===i)?.label??(i==="auto"||i==="off"?void 0:d(i));return{options:u,current:i,currentLabel:b,usingNow:h}}function Qr({bot:t,derived:a}){const{dispatch:n}=B(),{options:l,current:r,usingNow:i}=ys(t),[c,d]=x.useState(null),{patch:o,approvalMode:u}=a,m=h=>{if(!(h===r||h==="off")){if(h==="local"&&u==="auto"){d({botId:t.id,patch:{computer:"local",acknowledgeLocalAuto:!0}});return}o(h==="browser"?{computer:"browser",browser:!0}:{computer:h==="auto"?null:h})}};return e.jsxs(e.Fragment,{children:[e.jsx(L,{children:e.jsx("div",{role:"radiogroup","aria-label":s("computer.simple.whereWorks",{name:t.name}),className:"flex flex-col divide-y divide-ink/[0.05]",children:l.map(h=>e.jsx(He,{"data-panel-choice":h.value,title:h.label,hint:h.hint,checked:r===h.value,disabled:h.disabled,onClick:()=>m(h.value)},h.value))})}),i&&e.jsx("p",{"data-panel-using-now":!0,className:"mx-1 text-[13px] text-ink-secondary",children:s("computer.simple.usingNow",{place:i})}),e.jsx(la,{open:c!==null,onCancel:()=>d(null),onConfirm:()=>{const h=c;d(null),h&&n({type:"updateBot",botId:h.botId,patch:h.patch})}})]})}function Xr({bot:t,derived:a,onOpen:n}){const l=gs(t),r=Ge(),{browserEnabled:i}=a,c=Jr(t,i&&t.computer!=="off"&&r!==!1),{currentLabel:d,usingNow:o}=ys(t),u=s("computer.screenOf",{name:t.name}),m=[...t.messages].reverse().find(b=>b.kind==="screen"&&(b.hasImage||b.png)),h=m?aa({threadId:t.threadId,messageId:m.id},m.mime).src:null;return e.jsxs("div",{"data-panel-tabpanel":"computer",children:[e.jsxs("button",{type:"button","data-panel-action":"open-computer","aria-label":`${s("place.action.watch")}: ${u}`,onClick:()=>l(),className:"group relative mt-2.5 flex aspect-[16/10] w-full flex-col items-center justify-center gap-2 overflow-hidden rounded-xl bg-composer ring-1 ring-inset ring-ink/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[h?e.jsx("img",{src:h,alt:"",className:"absolute inset-0 size-full object-cover"}):t.busy?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-55",children:e.jsx(qe,{bot:t,size:52,animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] text-ink-secondary",children:s("botPanel.screen.working")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-60",children:e.jsx(qe,{bot:t,size:44,state:"sleeping",animated:!1})}),e.jsx("span",{className:"max-w-[80%] text-center text-[13px] font-medium text-ink",children:s("botPanel.screen.resting")})]}),e.jsxs("span",{"aria-hidden":"true",className:"absolute bottom-2.5 right-2.5 flex h-7 items-center gap-1.5 rounded-full border border-ink/10 bg-panel/80 px-2.5 text-[12px] text-ink opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 touch:opacity-100",children:[e.jsx(vt,{size:13,"aria-hidden":"true"}),s("place.action.watch")]})]}),e.jsx("div",{className:"mt-3 text-center text-[13px] text-ink-tertiary",children:u}),e.jsxs(L,{anchor:"where",children:[e.jsx(X,{"data-panel-page":"where",icon:vt,title:s("computer.simple.whereWorks",{name:t.name}),hint:o?s("computer.simple.usingNow",{place:o}):void 0,value:d,onClick:()=>n("where")}),e.jsx(X,{"data-panel-page":"browser",icon:na,title:s("settings.sites.title"),value:c??void 0,onClick:()=>n("browser")})]})]})}const Zr=3,Et="[&_.font-semibold]:font-medium [&_time]:text-[12px] [&_time]:text-ink-tertiary [&_span.bg-accent]:size-2",ei=8,ti=200,me=new Map,$e=new Set,Rt=t=>`${t.threadId}@${Gt(t)}`;function si(t,a){const[,n]=x.useState(0),r=a.filter(d=>d.threadId!==t.threadId).map(Rt).filter(d=>!me.has(d)&&!$e.has(d)).join(",");x.useEffect(()=>{if(r)for(const d of r.split(",")){$e.add(d);const o=d.slice(0,d.lastIndexOf("@"));se(`/api/threads/${encodeURIComponent(o)}/messages?limit=${ei}`,{background:!0}).then(u=>{me.set(d,Ue({messages:u.messages??[],activeLeafId:u.activeLeafId??void 0})),me.size>ti&&me.delete(me.keys().next().value),n(m=>m+1)}).catch(()=>{}).finally(()=>$e.delete(d))}},[r]);const i=Ue(t),c=new Map(a.map(d=>[d.threadId,Rt(d)]));return d=>d===t.threadId?i:me.get(c.get(d)??"")}function ai({bot:t}){const{state:a,dispatch:n}=B(),l=da(),r=!Wt(Vt,!0),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,m]=x.useState(!1),[h,b]=x.useState(!1),f=ua(a.config),v=x.useMemo(()=>{const{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:ue,onPin:he,onArchive:C}=ma(t.id,n,f);return{onRename:g,onRegenerateTitle:$,onDelete:ie,onMove:ue,onPin:he,onArchive:C}},[t.id,n,f]),j=pa(t),k=t.tasks??[{threadId:t.threadId,title:s("task.newShort"),createdAt:0}],y=(j?xa({...t,tasks:k},j):k).filter(g=>!g.routineRunId).map(g=>{const $=_e(t,g.threadId);return{...g,busy:$.busy,activity:$.activity,waitingForTeammates:$.waitingForTeammates,turnStartedAt:$.turnStartedAt??void 0,queued:!!a.pendingQueued[g.threadId]?.length}}),N=it(y.filter(g=>!Le(g)||g.threadId===t.threadId)),S=it(y.filter(g=>Le(g)&&g.threadId!==t.threadId)),E=i.trim(),M=N.filter((g,$)=>$<Zr||g.threadId===t.threadId),F=si(t,[...E||u?N:M,...h?S:[]]),T=g=>{const $=F(g);return $?ga(_e(t,g),$,a.instances,!1):void 0},I=ha(N,E),z=E?[...I,...N.filter(g=>!I.includes(g)&&T(g.threadId)?.toLowerCase().includes(E.toLowerCase()))]:N,A=E?z:u?N:M,p=N.length-M.length,R=t.projects?.find(g=>g.id===t.tasks?.find($=>$.threadId===t.threadId)?.projectId),D=()=>{r&&n({type:"toggleSettings",open:!1})},H=g=>{g.threadId!==t.threadId&&ba(n,t,g.threadId,!1),D()},_=()=>{n({type:"newTask",botId:t.id,...R?{projectId:R.id}:{}}),D()},G=()=>{c(""),o(!1)},Y=N.length>=2||d||N.some(g=>g.threadId===t.threadId&&Le(g)),U=g=>e.jsx("div",{role:"listitem","data-conversation":g.threadId,children:e.jsx(ya,{panel:!0,preview:T(g.threadId),task:g,ownerId:t.id,current:g.threadId===t.threadId,folders:t.projects,now:va(Gt(g),l),locale:ee(),onSelect:H,...v})},g.threadId);return e.jsxs("section",{"data-panel-card":"conversations","aria-label":s("botPanel.conversations.title"),children:[e.jsx(we,{action:Y&&e.jsx("button",{type:"button","data-conversations-search":!0,"aria-label":s("botPanel.conversations.search"),title:s("botPanel.conversations.search"),"aria-pressed":d,onClick:()=>d?G():o(!0),className:O("-me-1 flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-secondary transition-colors hover:bg-ink/[0.06] hover:text-ink",d&&"bg-ink/[0.06] text-ink"),children:e.jsx(Bt,{size:14,"aria-hidden":"true"})}),children:s("botPanel.conversations.title")}),e.jsx("div",{className:O("flex items-center gap-2",Y&&"mb-2"),children:t.yourAccess!=="view"&&j!=="team"&&e.jsxs("button",{type:"button","data-conversations-new":!0,"aria-label":s("botPanel.conversations.new"),onClick:_,className:O(Yt,"flex-1"),children:[e.jsx(fa,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.conversations.new")})]})}),Y&&d&&e.jsx("input",{autoFocus:!0,type:"search","data-conversations-query":!0,value:i,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),G())},placeholder:s("botPanel.conversations.searchPlaceholder",{name:t.name}),"aria-label":s("botPanel.conversations.searchPlaceholder",{name:t.name}),className:"mb-1.5 w-full rounded-[8px] border border-hairline/60 bg-inset px-3 py-1.5 text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-focus"}),Y&&e.jsx("div",{role:"list","aria-label":s("botPanel.conversations.title"),className:O("flex flex-col gap-px",Et),children:A.map(U)}),Y&&E&&A.length===0&&e.jsx("p",{className:"px-3 py-3 text-[13px] text-ink-secondary",children:s("task.noMatch",{query:E})}),Y&&!E&&p>0&&e.jsxs("button",{type:"button","data-conversations-more":!0,"aria-expanded":u,onClick:()=>m(g=>!g),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[u?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,"aria-hidden":"true"}),u?s("botPanel.conversations.showFewer"):s("botPanel.conversations.showMore",{count:p})]}),!E&&S.length>0&&e.jsxs("button",{type:"button","data-conversations-archived":!0,"aria-expanded":h,onClick:()=>b(g=>!g),className:"mt-0.5 flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-ink/[0.04] hover:text-ink",children:[h?e.jsx(lt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,"aria-hidden":"true"}),s("task.archivedList",{count:S.length})]}),!E&&h&&S.length>0&&e.jsx("div",{role:"list","aria-label":s("task.archivedList",{count:S.length}),className:O("flex flex-col gap-px",Et),children:S.map(U)})]})}function ni({bot:t}){const{dispatch:a}=B();return Dt()||!t.defaultBot?null:e.jsx(L,{label:s("botPanel.tryAsking"),anchor:"try-asking",children:ka.map(l=>e.jsx("button",{type:"button","data-panel-ask":l,onClick:()=>a({type:"send",botId:t.id,text:s(l),threadId:t.threadId}),className:"flex h-9 w-full items-center px-3.5 text-left text-[14px] text-ink transition-colors hover:bg-ink/[0.03]",children:e.jsx("span",{className:"truncate",children:s(l)})},l))})}const ri=["find","start-fresh","usage","activity","inspector"];function ii({item:t}){const a=t.key==="usage";return e.jsxs("button",{type:"button","data-panel-item":t.key,disabled:t.disabled,title:t.title,"aria-pressed":t.active||void 0,onClick:t.onSelect,className:O(J,"w-full rounded-[8px] text-left enabled:hover:bg-ink/[0.04] disabled:cursor-default disabled:opacity-45"),children:[e.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center text-ink-secondary [&_svg]:size-4","aria-hidden":"true",children:t.icon}),e.jsx("span",{className:O("min-w-0 truncate text-[14px] font-medium",!a&&"flex-1",t.active?"text-accent-text":"text-ink"),children:t.label}),t.trailing&&e.jsx("span",{className:O("flex items-center",a?"min-w-0 flex-1 justify-end text-right":"shrink-0"),children:t.trailing}),t.key!=="find"&&t.key!=="start-fresh"&&e.jsx(ge,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary rtl:-scale-x-100"})]})}function li({bot:t,derived:a,onOpen:n}){const{items:l}=ja(t),{dispatch:r}=B(),i=a.botRoutines.filter(d=>d.enabled).length,c=ri.flatMap(d=>l.filter(o=>o.key===d));return e.jsxs("div",{"data-panel-tabpanel":"details",children:[e.jsx("section",{"data-panel-card":"model",className:"pt-2",children:e.jsx("div",{"data-panel-row":"model",className:O(J,"rounded-[8px]"),children:e.jsx(wa,{bot:t,contained:!0,threadId:t.threadId,label:e.jsxs("span",{className:"flex shrink-0 items-center gap-2.5",children:[e.jsx(Q,{icon:Ve}),e.jsx(te,{title:s("model.simple.model")})]})})})}),e.jsx(ai,{bot:t}),e.jsx(ni,{bot:t}),c.length>0&&e.jsxs("section",{"data-panel-card":"conversation",children:[e.jsx(we,{children:s("botPanel.section.conversation")}),c.map(d=>e.jsx(ii,{item:d},d.key))]}),a.botRoutines.length===0?e.jsxs("section",{"data-panel-empty":"routines",children:[e.jsx(we,{action:e.jsx(Na,{"data-panel-automations":"",onClick:()=>r({type:"showRoutines",view:"list"}),children:s("sidebar.nav.automations")}),children:s("botSettings.simple.routines")}),e.jsxs("button",{type:"button","data-panel-page":"routines",title:s("botPanel.routines.emptyHint"),onClick:()=>n("routines"),className:O(Yt,"w-full"),children:[e.jsx(br,{size:15,"aria-hidden":"true",className:"shrink-0 text-ink-secondary"}),e.jsx("span",{className:"truncate",children:s("botPanel.routines.add")})]})]}):e.jsx(L,{label:s("botSettings.simple.routines"),anchor:"routines",children:e.jsx(X,{"data-panel-page":"routines",icon:Sa,title:s("botSettings.simple.routines"),value:i>0?s("botPanel.routinesOn",{count:i}):s("botPanel.none"),onClick:()=>n("routines")})})]})}const vs=/^\s*[-*]\s+(.+?)\s*$/;function oi(t){return t.split(`
|
|
8
|
-
`).flatMap((a,n)=>{const l=vs.exec(a)?.[1];return l?[{line:n,text:l}]:[]})}function ci(t,a){const n=t.split(`
|
|
9
|
-
`);return vs.test(n[a]??"")?(n.splice(a,1),n.join(`
|
|
10
|
-
`)):t}function di(t,a){const n=t.replace(/\s+$/,""),l=`- ${a.trim().replace(/\s*\n\s*/g," ")}`;return n?`${n}
|
|
11
|
-
${l}
|
|
12
|
-
`:`${l}
|
|
13
|
-
`}function bs(t){return t.flatMap(a=>{const n=oi(a.text).map(r=>({path:a.path,...r}));if(n.length||a.path===Z)return n;const l=a.text.split(`
|
|
14
|
-
`).map(r=>r.replace(/^#+\s*/,"").trim()).filter(Boolean).join(" ");return l?[{path:a.path,line:null,text:l}]:[]})}async function ui(t,a){if(!a)return[await Se(t,Z)];const n=await Qe(t,!0);return Promise.all([Z,...n.topics.map(l=>l.path)].map(l=>Se(t,l,!0)))}function ks(t){const a=!!B().state.config?.team,[n,l]=x.useState({botId:t.id,docs:null,error:!1}),r=t.memoryEnabled!==!1,i=async(o,u)=>{try{const m=await ui(o,a);u?.()||l({botId:o,docs:m,error:!1})}catch{u?.()||l({botId:o,docs:null,error:!0})}},c=!!t.busy;x.useEffect(()=>{if(!r)return;let o=!1;return i(t.id,()=>o),()=>{o=!0}},[t.id,r,c,a]);const d=n.botId===t.id;return{docs:d?n.docs:null,error:d&&n.error,mine:a,setDoc:o=>l(u=>({botId:t.id,docs:(u.botId===t.id?u.docs??[]:[]).map(m=>m.path===o.path?o:m),error:!1})),reload:()=>i(t.id)}}function mi(t,a=Ue(t)){const n=[],l=[],r=new Set;for(const u of[...a].reverse()){const m=u.publishedPage;m?.state==="live"&&m.url&&!r.has(m.url)&&(r.add(m.url),n.push({messageId:u.id,title:m.title||m.url,url:m.url})),u.kind==="app"&&u.app?.doc&&l.push({messageId:u.id,title:u.app.title})}const i=ur(t),c=[],d=new Set;for(const u of i.values())d.has(u.file.path)||(d.add(u.file.path),c.push(u));const o=mr(t).filter(u=>!i.has(u));return{pages:n,apps:l,shared:c,unshared:o}}const pi=t=>t.slice(Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))+1);function js({bot:t,onOpen:a}){const{dispatch:n}=B(),{capabilities:l}=ye(),r=Ca(),i=!Wt(Vt,!0),c=is(t),d=ks(t),{pages:o,apps:u,shared:m,unshared:h}=x.useMemo(()=>mi(t),[t]),b=y=>{n({type:"focusMessage",threadId:t.threadId,messageId:y}),i&&n({type:"toggleSettings",open:!1})},f=c.skills.filter(ls).length,v=d.docs?bs(d.docs).length:null,j=t.memoryEnabled===!1?s("botPanel.memory.off"):v===null?d.error?s("botPanel.memory.nothingYet"):void 0:v===0?s("botPanel.memory.nothingYet"):v===1?s("botPanel.memory.note"):s("botPanel.memory.notes",{count:v}),k=e.jsxs(L,{anchor:"keeps",children:[e.jsx(X,{"data-panel-page":"memory",icon:$t,title:s("botPanel.memoryRow"),value:j,onClick:()=>a("memory")}),e.jsx(X,{"data-panel-page":"skills",icon:Pa,title:s("botSettings.simple.skills"),value:c.loading?void 0:f>0?f:s("botPanel.none"),onClick:()=>a("skills")}),e.jsx(X,{"data-panel-page":"folder",icon:Oa,title:s("computer.files.folder"),value:t.cwd?Ye(t.cwd,l.host?.homeDir):s("botPanel.folder.private"),onClick:()=>a("folder")})]});return o.length+u.length+m.length+h.length===0?e.jsxs("div",{"data-panel-tabpanel":"library",children:[e.jsx("p",{"data-panel-empty":"library",className:"px-3 py-7 text-center text-[13px] leading-[18px] text-ink-tertiary",children:s("botPanel.library.empty")}),k]}):e.jsxs("div",{"data-panel-tabpanel":"library",children:[o.length>0&&e.jsx(L,{label:s("botPanel.library.pages"),anchor:"pages",children:o.map(y=>e.jsx(X,{"data-panel-row":"page",icon:Ea,title:e.jsx("span",{className:"block truncate",children:y.title}),hint:e.jsx("span",{className:"block truncate",children:y.url}),onClick:()=>r(y.url)},y.url))}),u.length>0&&e.jsx(L,{label:s("botPanel.library.apps"),anchor:"apps",children:u.map(y=>e.jsx(X,{"data-panel-row":"app",icon:Jt,title:e.jsx("span",{className:"block truncate",children:y.title}),onClick:()=>b(y.messageId)},y.messageId))}),m.length+h.length>0&&e.jsxs("section",{"data-panel-card":"files",children:[e.jsx(we,{children:s("botPanel.library.files")}),e.jsxs("ul",{className:"flex flex-col gap-1.5",children:[m.map(y=>e.jsx("li",{className:"min-w-0",children:e.jsx(Ra,{file:y.file,message:y.message,linked:y.file.linked,className:"w-full max-w-none"})},`${y.message.messageId}:${y.file.path}`)),h.map(y=>e.jsxs("li",{title:s("computer.files.notSharedHint"),className:"flex min-w-0 items-center gap-2 rounded-lg border border-hairline/40 px-2.5 py-2",children:[e.jsx(Pe,{size:14,className:"shrink-0 text-ink-secondary","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-ink",children:pi(y)}),e.jsx("span",{className:"shrink-0 text-[11px] text-ink-tertiary",children:s("computer.files.notShared")})]},y))]})]}),e.jsx("p",{className:"mt-3 text-center text-[12px] text-ink-tertiary",children:s("botPanel.library.scope")}),k]})}function xi({bot:t,browserEnabled:a,onOpenBrowser:n}){const{state:l}=B(),r=Ge(),i=t.browserProfile??"",c=(l.config?.browserProfiles??[]).find(m=>m.id===i),d=i==="guest",o=c?.browser==="chrome"&&l.config?.browserEngine?.myChrome===!0,u=i&&!d?l.bots.filter(m=>m.browserProfile===i).map(m=>m.name):[t.name];return e.jsx(L,{anchor:"logins",children:a?d?e.jsx(W,{children:s("settings.profiles.temporaryHint")}):o?e.jsx(W,{children:s("settings.profiles.myChromeHint")}):e.jsxs(e.Fragment,{children:[r!==!1&&(i===""||c)&&e.jsx(ce,{children:e.jsx(yr,{bare:!0,target:{bot:t.id},sharedBy:u,disabled:!!t.busy},`${t.id}:${i}`)}),e.jsx(W,{children:s("botSettings.simple.loginsHint",{name:t.name})}),e.jsx(de,{"data-panel-action":"add-login",icon:Ee,onClick:n,children:s("botSettings.simple.addLogin")})]}):e.jsx(W,{children:s("botSettings.simple.loginsOff",{name:t.name})})})}const hi=5,fi={instanceId:"",model:""},ws=(t,a)=>`${t}\0${a}`,gi=new Set;function It({bot:t,current:a,exclude:n,onPick:l,label:r,title:i,buttonRef:c,className:d,children:o,...u}){const{state:m,dispatch:h,refreshInstances:b,refreshModels:f}=B(),[v,j]=x.useState(!1),[k,y]=x.useState(""),[N,S]=x.useState(()=>new Set),[E,M]=x.useState(!1),[F,T]=x.useState(null),[I,z]=x.useState(null),A=x.useRef(null),p=c??A,R=x.useRef(null),D=x.useRef(null),H=x.useRef(!1),_=x.useId(),G=zn(v),Y=x.useRef({contains:C=>[p.current,R.current].some(K=>K?.contains(C))});Ba(v,Y,()=>j(!1)),x.useLayoutEffect(()=>{if(!v)return;const C=K=>{if(K?.type==="scroll"&&K.target instanceof Node&&R.current?.contains(K.target))return;const V=p.current?.getBoundingClientRect(),q=R.current;!V||!q||z(le=>$a(V,{width:ot,height:q.offsetHeight},{width:window.innerWidth,height:window.innerHeight},le??void 0))};return C(),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[v,p]),x.useEffect(()=>{if(!v||!I||!H.current)return;H.current=!1;const C=R.current;(C?.querySelector("[data-menu-search]")??C?.querySelector("[data-current-model]")??C?.querySelector("[data-menu-row]:not(:disabled)")??C)?.focus({preventScroll:!0})},[v,I]);const U=C=>{j(!1),C&&p.current?.focus({preventScroll:!0})},g=()=>{y(""),S(new Set),z(null),H.current=!0,j(!0),M(!0),b().catch(()=>{}).finally(()=>M(!1))},$=C=>{F||(T(C.instanceId),f(C.instanceId).catch(()=>{}).finally(()=>T(null)))},ie=()=>{U(!1),h({type:"toggleAppSettings",open:!0,section:"engines"})},ue=()=>{const C=Ha(m.instances,a?.instanceId).flatMap(q=>{const le=q.models.options.filter(ve=>!n.has(ws(q.instanceId,ve.id)));return le.length===q.models.options.length?[q]:le.length?[{...q,models:{...q.models,options:le}}]:[]}),K=_a({instances:m.instances,listed:C,selection:a??fi,bot:{name:t.name,selection:t.modelSelection},query:k,expanded:N,probing:gi,loading:E,refreshing:F}),V=K.groups.map(q=>q.instance.instanceId===t.modelSelection.instanceId?{...q,note:s("botPanel.backups.sameAccount")}:q);return{...K,groups:V,...a?{}:{current:null}}},he=C=>{if(!(C.nativeEvent.isComposing||C.defaultPrevented)){if(C.key!=="Escape")return za(C,{query:k,typed:D,close:()=>U(!0)});C.preventDefault(),C.stopPropagation(),k?y(""):U(!0)}};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:p,type:"button",...u,"aria-label":r,title:i,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?_:void 0,onClick:()=>v?U(!1):g(),onKeyDown:C=>{C.key==="Escape"&&v?(C.preventDefault(),C.stopPropagation(),U(!1)):(C.key==="ArrowDown"||C.key==="ArrowUp")&&!v&&(C.preventDefault(),g())},className:d,children:o}),G.shown&&Bn.createPortal(e.jsx("div",{ref:R,id:_,"data-backup-menu":!0,role:"dialog","aria-label":s("botPanel.backups.choose"),"aria-modal":"false",tabIndex:-1,...G.exitProps,onKeyDown:he,onPointerMove:Da,style:{position:"fixed",left:I?.left??0,top:I?.top,bottom:I?.bottom,width:I?.width??ot,maxHeight:I?.maxHeight,transformOrigin:I?.origin,visibility:I?void 0:"hidden"},className:O("menu-surface z-[80] flex flex-col overflow-hidden",G.className),children:e.jsx(Fa,{menu:ue(),query:k,bot:t,botModel:{label:"",title:""},idPrefix:_,onQuery:y,onPick:(C,K)=>{C.policy||(l({instanceId:C.instanceId,model:K}),U(!0))},onPickCurrent:()=>U(!0),onFollowBot:()=>U(!0),onToggle:C=>S(K=>{const V=new Set(K);return V.delete(C.instanceId)||V.add(C.instanceId),V}),onSetUp:ie,onCheckAgain:$,onManage:ie})}),document.body)]})}function yi({bot:t,onChange:a}){const{state:n}=B(),l=t.fallback??[],r=x.useRef(null),i=d=>new Set([t.modelSelection,...l.filter((o,u)=>u!==d)].map(o=>ws(o.instanceId,o.model))),c=d=>{const o=n.instances.find(h=>h.instanceId===d.instanceId),u=o?.models.options.find(h=>h.id===d.model),m=La(o,d.model);return{instance:o,name:m,short:o&&u?Ma(u.label,Ta(o)):m}};return e.jsx(L,{anchor:"backups",children:e.jsxs(ce,{"data-panel-row":"backups",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Ia}),e.jsx(te,{title:s("botPanel.backups.title")})]}),e.jsx("p",{className:"-mt-1 pl-[38px] text-[13px] leading-[1.35] text-ink-secondary",children:s("botPanel.backups.hint",{name:t.name})}),l.length>0&&e.jsx("ol",{"aria-label":s("botPanel.backups.title"),className:"flex flex-col gap-1 pl-[38px]",children:l.map((d,o)=>{const{instance:u,name:m,short:h}=c(d);return e.jsxs("li",{"data-backup":d.instanceId,className:"flex min-w-0 items-center gap-1.5",children:[e.jsx("span",{className:"w-3 shrink-0 text-[12px] tabular-nums text-ink-tertiary","aria-hidden":"true",children:o+1}),e.jsxs(It,{bot:t,current:d,exclude:i(o),onPick:b=>a(l.map((f,v)=>v===o?b:f)),label:s("botPanel.backups.row",{position:o+1,model:m}),title:u?`${u.displayName} · ${m}`:m,"data-panel-action":"backup-change",className:"group flex h-8 min-w-0 flex-1 items-center gap-2 rounded-[8px] bg-ink/[0.04] pl-2.5 pr-2 text-left text-[13px] text-ink hover:bg-ink/[0.07] aria-expanded:bg-ink/[0.08]",children:[u?e.jsx(Aa,{instance:u,size:14,subtle:!0}):e.jsx("span",{className:"size-3.5 shrink-0 rounded-full bg-ink/[0.08]","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:h}),!u&&e.jsx("span",{className:"shrink-0 text-[12px] text-warning",children:s("model.simple.unavailable")}),e.jsx(xe,{size:12,strokeWidth:2,"aria-hidden":"true",className:"shrink-0 text-ink-tertiary group-hover:text-ink-secondary"})]}),e.jsx(Oe,{"data-panel-action":"backup-remove",label:s("botPanel.backups.remove",{model:m}),onClick:()=>{a(l.filter((b,f)=>f!==o)),r.current?.focus({preventScroll:!0})}})]},o)})}),l.length<hi&&e.jsx("div",{className:"pl-[38px]",children:e.jsxs(It,{bot:t,current:null,exclude:i(null),onPick:d=>a([...l,d]),label:s("model.fallback.add"),buttonRef:r,"data-panel-action":"backup-add",className:O(re,"aria-expanded:bg-raised-hover"),children:[e.jsx(Ee,{size:14,"aria-hidden":"true"}),s("model.fallback.add")]})})]})})}function vi({bot:t}){const{dispatch:a}=B(),[n,l]=x.useState(!1),[r,i]=x.useState(!1),[c,d]=x.useState(0),o=t.memoryEnabled!==!1&&t.memoryUpkeep!==!1;if(x.useEffect(()=>{if(!o)return;let m=!0;return se(`/api/bots/${t.id}/system-prompt`).then(h=>{m&&l(h.heavy===!0)},()=>{}),()=>{m=!1}},[t.id,o,c]),!o||!n)return null;const u=async()=>{i(!0);try{await as(t.id)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("common.tryAgain")})}finally{i(!1),d(m=>m+1)}};return e.jsx(L,{anchor:"heavy",children:e.jsxs("div",{"data-panel-row":"heavy",className:J,children:[e.jsx(Q,{icon:Ua}),e.jsx(te,{title:s("botPanel.heavy")}),e.jsx("button",{type:"button","data-panel-action":"tidy-memory",disabled:r,onClick:()=>{u()},className:re,children:r?s("memory.upkeep.tidying"):s("botPanel.tidyMemory")})]})})}const bi=5;function ki({bot:t}){const{dispatch:a,flushBotPatches:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),d=x.useCallback(()=>ft(t.id).then(u=>r(u.rows.slice(0,bi)),()=>{}),[t.id]);if(x.useEffect(()=>{d()},[d,t.soul]),!l.length)return null;const o=async u=>{if(!i){c(u.id);try{await n(t.id);const{revision:m}=await ft(t.id);await Gn(t.id,u.id,m)}catch(m){a({type:"error",message:m instanceof Error&&m.message?m.message:s("botOverview.undoFailed")})}finally{c(null),await d()}}};return e.jsxs("div",{"data-panel-row":"soul-changes",className:"flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("memory.changes")}),e.jsx(Ze,{rows:l,botName:t.name,reverting:i,onRevert:u=>{o(u)}})]})}const ze={ask:()=>s("botSettings.simple.ask"),full:()=>s("botSettings.simple.justDoIt"),auto:()=>s("botSettings.simple.decide"),edits:()=>s("approvalMode.edits.label"),custom:()=>s("botPanel.acts.custom")};function ji({bot:t,derived:a,onOpen:n,editingInstructions:l=!1,onEditInstructions:r}){const{state:i,dispatch:c,flushBotPatches:d}=B(),{capabilities:o,ready:u}=ye(),m=Qt(t),{servers:h}=ds(),b=Ka(_e(t)),f=qa(),v=ps(t.id),j=os(),[k,y]=x.useState(null),{patch:N,approvalMode:S,engine:E}=a,M=t.name,F=()=>{k!==null&&k.trim()!==t.title.trim()&&N({title:k.trim()}),y(null)},T=E?.driverKind==="antigravityAgent"&&S==="auto"?"ask":S,I=[{value:"ask",label:ze.ask(),tooltip:s("botSettings.simple.askHint")},{value:"full",label:ze.full(),tooltip:s("botSettings.simple.fullHint")},...T==="ask"||T==="full"?[]:[{value:T,label:ze[T](),disabled:!0,tooltip:T==="custom"?s("botPanel.acts.customHint"):void 0}]],z=g=>{g===S||g!=="ask"&&g!=="full"||c({type:"updateBot",botId:t.id,patch:{approvalMode:g,applyToAllThreads:!0}})},A=!u||Wa(o,i.config),p=nn(f,{turnsHere:A,canLive:!0}),R=A?null:Va(o,!!Ga()?.speechStart,Ya(i.config)),D=Ja.map(g=>({value:g.id,label:s(g.label),disabled:g.id==="turns"&&R!==null,tooltip:g.id==="turns"&&R?`${R.label}. ${R.reason}`:g.id==="live"?s("call.mode.liveHint"):Qa("turns")})),H=Xa.map(g=>({value:g,label:s(gt[g][0]),tooltip:s(gt[g][1])})),_=()=>{const g=!t.notifications;g&&rn(),N({notifications:g})},G=t.alwaysAllow??[],Y=l||!!t.soulDrift,U=[...m.apps.filter(g=>g.scope!==null).map(g=>g.label),...h?us(h,t.mcpServers,t.id).map(g=>g.name):[]];return e.jsxs("div",{"data-panel-settings":!0,children:[e.jsx(Jn,{bot:t}),e.jsx(L,{anchor:"instructions",children:Y?e.jsxs(ce,{"data-panel-row":"soul",children:[e.jsx(Qn,{bot:t,onPatch:N,simple:{label:s("botSettings.simple.instructions"),placeholder:s("botSettings.simple.instructionsPlaceholder",{name:M})}}),e.jsx(ki,{bot:t}),l&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button","data-panel-done":"soul",onClick:()=>{d(t.id),r?.(!1)},className:re,children:s("botSettings.simple.done")})})]}):e.jsxs("button",{type:"button","data-panel-edit":"soul","aria-label":`${s("botSettings.simple.edit")}: ${s("botSettings.simple.instructions")}`,onClick:()=>r?.(!0),className:O(J,"w-full text-left hover:bg-ink/[0.03]"),children:[e.jsx(Q,{icon:Pe}),e.jsx(te,{title:s("botSettings.simple.instructions"),hint:e.jsx("span",{className:"line-clamp-1",children:Xn(t.soul??"")||s("botPanel.instructionsHint",{name:M})})}),e.jsx(ge,{size:15,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]})}),e.jsx(vi,{bot:t}),e.jsx(L,{anchor:"approval",children:e.jsxs(ce,{"data-panel-row":"approval",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:zt}),e.jsx(te,{title:s("botSettings.simple.beforeActs",{name:M}),hint:t.busy?s("approvalMode.whileWorking"):void 0})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-approval-choice",label:s("botSettings.simple.beforeActs",{name:M}),value:T,onChange:z,options:I})}),b.choice&&e.jsxs("div",{"data-panel-row":"thread-approval",className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botPanel.thisConversation")}),e.jsx("span",{className:"ms-auto flex",children:e.jsx(Za,{choice:b.choice})})]}),G.length>0&&e.jsxs("div",{"data-panel-row":"always-allow",className:"flex min-w-0 flex-col gap-1 pl-[38px]",children:[e.jsx("span",{className:"text-[13px] text-ink-secondary",children:s("botAccess.always.title")}),G.map(g=>e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:g}),e.jsx(Oe,{"data-panel-action":`always-allow:${g}`,label:s("botAccess.always.remove",{entry:g}),onClick:()=>N({alwaysAllow:G.filter($=>$!==g)})})]},g))]})]})}),e.jsx(yi,{bot:t,onChange:g=>N({fallback:g})}),e.jsx(L,{anchor:"call",children:e.jsxs(ce,{"data-panel-row":"call-mode",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:Dn}),e.jsx(te,{title:s("call.mode.menu")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-call-mode",label:s("call.mode.menu"),value:p,onChange:en,options:D})})]})}),e.jsxs(L,{anchor:"replies",children:[e.jsxs(ce,{"data-panel-row":"reply-style",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Q,{icon:tn}),e.jsx(te,{title:s("botSettings.replyStyle.title")})]}),e.jsx("div",{className:"pl-[38px]",children:e.jsx(je,{attr:"data-reply-style",label:s("botSettings.replyStyle.title"),value:t.replyStyle??"default",onChange:g=>N({replyStyle:g}),options:H})})]}),e.jsx(Je,{"data-panel-row":"notifications",icon:sn,title:s("voice.notifications.title"),color:t.color,checked:t.notifications,onChange:_})]}),e.jsxs(L,{anchor:"uses",children:[e.jsx(X,{"data-panel-page":"apps",icon:Jt,title:s("botPanel.appsRow"),value:U.length>0?U.join(", "):s("botPanel.appsNoneYet"),onClick:()=>n?.("apps")}),e.jsxs("label",{"data-panel-row":"job",className:O(J,"cursor-text"),children:[e.jsx(Q,{icon:Sr}),e.jsx("span",{className:"shrink-0 text-[14px] font-medium text-ink",children:s("botSettings.simple.job")}),e.jsx("input",{"data-panel-job":!0,value:k??t.title,placeholder:s("botSettings.simple.jobPlaceholder"),"aria-label":s("botSettings.simple.job"),maxLength:Ke.title,onChange:g=>y(g.target.value),onBlur:F,onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),g.currentTarget.blur()):g.key==="Escape"&&k!==null&&(g.preventDefault(),g.stopPropagation(),y(null))},className:"min-w-0 flex-1 bg-transparent text-right text-[13px] text-ink-secondary outline-none placeholder:text-ink-tertiary focus:text-ink"})]}),v&&e.jsxs("a",{"data-panel-row":"slack",href:v,target:"_blank",rel:"noopener noreferrer",className:O(J,"hover:bg-ink/[0.03]"),children:[e.jsx(Q,{icon:ms}),e.jsx(te,{title:s("botPanel.page.slack"),hint:s("botSlack.manage")}),e.jsx(es,{size:14,className:"shrink-0 text-ink-tertiary","aria-hidden":"true"})]}),j&&e.jsx(X,{"data-panel-page":"visibility",icon:Ht,title:s("botSettings.visibility.title"),value:Zn(t.visibility),onClick:()=>n?.("visibility")})]}),e.jsx(er,{bot:t,webhooksLink:!0,className:"mt-3.5"}),e.jsx(an,{bot:t}),b.dialogs]})}const wi=5;function Ni({bot:t,onChanged:a}){const{dispatch:n}=B(),[l,r]=x.useState([]),[i,c]=x.useState(null),[d,o]=x.useState(null),u=x.useCallback(async()=>{const[f,v]=await Promise.all([Qe(t.id),pe(t.id)]);c(j=>f.lendingReview?{value:f.lendingReview,stale:j?.stale??!1}:null),r(v.slice(0,wi))},[t.id]);x.useEffect(()=>{u().catch(()=>{})},[u,t.busy]);const m=f=>n({type:"error",message:f instanceof Error&&f.message?f.message:s("common.tryAgain")}),h=async f=>{o(f.id);try{await rs(t.id,f.id),await a()}catch(v){m(v)}finally{o(null),await u().catch(()=>{})}},b=async f=>{o("review");try{await ss(t.id,f.value.token),c(null)}catch(v){v instanceof Kt&&v.status===409?(c({...f,stale:!0}),await u().catch(()=>{})):m(v)}finally{o(null)}};return e.jsxs(e.Fragment,{children:[i&&e.jsx(hs,{changed:i.value.changed,stale:i.stale,busy:d!==null,onReviewed:()=>{b(i)}}),e.jsx(L,{children:e.jsx(Je,{"data-panel-row":"memory-upkeep",title:s("memory.upkeep.title"),checked:t.memoryUpkeep!==!1,color:t.color,onChange:()=>n({type:"updateBot",botId:t.id,patch:{memoryUpkeep:t.memoryUpkeep===!1}})})}),l.length>0&&e.jsx(L,{label:s("memory.changes"),children:e.jsx("div",{"data-panel-row":"memory-changes",className:"px-3.5 py-3",children:e.jsx(Ze,{rows:l,botName:t.name,reverting:d,onRevert:f=>{h(f)}})})})]})}const Si="flex flex-col gap-3",At="https://www.skills.sh";function fe(t,a){return t instanceof Error&&t.message?t.message:a}function Ci({bot:t,derived:a}){const{dispatch:n}=B(),l=Qt(t),{servers:r,error:i}=ds(),{patch:c,canUseConnectedApps:d}=a,o=r?hr(r,t.id):[],u=new Set(us(o,t.mcpServers,t.id).map(f=>f.name)),m=f=>{const v=un(t,l.connectedSlugs,f.slug,f.scope===null);Object.keys(v).length>0&&c(v)},h=f=>{t.busy||i||c({mcpServers:fr(o,t.mcpServers,f)})},b=d?l.phase==="loading"?s("common.checking"):l.phase==="unknown"?s("botSettings.simple.appsUnknown"):l.apps.length===0?s("botSettings.simple.appsNone"):null:s("botSettings.simple.appsCannot",{name:t.name});return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[b&&e.jsx(W,{children:b}),d&&l.apps.map(f=>e.jsxs("div",{"data-simple-app":f.slug,className:J,children:[e.jsx(cn,{card:f.card,className:"size-7 shrink-0"},`${f.card.logo}:${f.card.domain}`),e.jsx("div",{className:"min-w-0 flex-1 truncate text-[14px] font-medium text-ink",children:f.label}),e.jsx(dt,{color:t.color,checked:f.scope!==null,"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.label}),disabled:!!t.busy,onClick:()=>m(f),className:"disabled:cursor-not-allowed"})]},f.slug))]}),(o.length>0||i)&&e.jsxs(L,{label:s("connectors.tab.mcp"),children:[i&&e.jsx(W,{children:s("botAccess.mcpRefreshError")}),o.map(f=>e.jsxs("div",{"data-simple-mcp":f.name,className:J,children:[e.jsx(Q,{icon:Fn}),e.jsx(te,{title:e.jsx("span",{className:"block truncate",children:f.name}),hint:f.enabled?f.offFor?.includes(t.id)?s("mcp.offFor",{bots:t.name}):void 0:s("botAccess.mcpDisabled")}),e.jsx(dt,{color:t.color,checked:u.has(f.name),"aria-label":s("botSettings.simple.appToggle",{name:t.name,app:f.name}),disabled:!f.enabled||!!t.busy||i,onClick:()=>h(f.name),className:"disabled:cursor-not-allowed"})]},f.name))]}),e.jsx(L,{children:e.jsx(de,{"data-panel-link":"add-app",icon:Ee,onClick:()=>dn(n,t.id),children:s("botPanel.apps.connectAnother")})})]})}function Pi({bot:t,derived:a}){const{state:n,dispatch:l}=B(),[r,i]=x.useState(()=>a.botRoutines.length===0?"new":null);return e.jsxs(e.Fragment,{children:[e.jsx(pr,{routines:a.botRoutines,runs:n.routineRuns,pausedBots:n.config?.pausedBots,loading:n.routinesLoadState==="loading"&&a.botRoutines.length===0,error:n.routinesLoadState==="error",onOpen:i,onLogs:c=>l({type:"showRoutines",section:"logs",botId:t.id,routineId:c.id}),onToggle:c=>l({type:"updateRoutine",routineId:c.id,patch:{enabled:!c.enabled}})}),e.jsx(L,{children:e.jsx(de,{"data-panel-action":"new-routine",icon:Ee,onClick:()=>i("new"),children:s("botPanel.routines.add")})}),e.jsx("p",{className:"mx-1 text-[13px] leading-normal text-ink-secondary",children:s("botPanel.routines.ask",{name:t.name})}),r&&e.jsx(gr,{routine:r==="new"?void 0:r,bots:[t],lockedBotId:t.id,onClose:()=>i(null)},t.id)]})}function Oi({bot:t}){const a=ks(t),[n,l]=x.useState(""),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),m=t.memoryEnabled!==!1,h=a.docs?bs(a.docs):null,b=a.docs?.find(y=>y.path===Z)??null;x.useEffect(()=>i(null),[t.id,m]);const f=async y=>{if(c)return!1;d(!0),u(null);try{return await y()}catch(N){return u(fe(N,s("botPanel.library.memoryError"))),!1}finally{d(!1)}},v=(y,N)=>f(async()=>{const S=await Xe(t.id,y.path,N,y.exists?y.hash:void 0,a.mine);return S.ok?(a.setDoc(S.doc),!0):(await a.reload(),u(s("memory.conflict.title",{name:t.name})),!1)}),j=y=>{const N=a.docs?.find(S=>S.path===y.path);N&&(y.line!==null?v(N,ci(N.text,y.line)):f(async()=>(await ns(t.id,N.path,a.mine),await a.reload(),!0)))},k=async()=>{!b||!n.trim()||await v(b,di(b.text,n))&&l("")};return m&&r?.botId===t.id?e.jsx(Ei,{bot:t,doc:r.doc,mine:a.mine,onDone:y=>{y&&a.setDoc(y),i(null),u(null)}}):e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[m?a.error?e.jsx(W,{tone:"warn",children:s("botPanel.library.memoryError")}):h===null?e.jsx(W,{children:s("common.checking")}):h.length===0?e.jsx(W,{children:s("botPanel.memory.empty")}):h.map(y=>e.jsxs("div",{"data-memory-note":y.line??y.path,className:J,children:[e.jsx("div",{className:"min-w-0 flex-1 text-[13px] leading-[1.45] text-ink",children:y.text}),e.jsx(Oe,{label:s("botPanel.memory.forget"),disabled:c,onClick:()=>j(y)})]},`${y.path}:${y.line}:${y.text}`)):e.jsx(W,{children:s("botPanel.library.memoryOff",{name:t.name})}),o&&e.jsx(W,{tone:"warn",children:o})]}),m&&e.jsxs(L,{children:[e.jsx(Xt,{"data-panel-form":"memory-add",value:n,placeholder:s("botPanel.memory.addPlaceholder",{name:t.name}),label:s("botPanel.memory.addPlaceholder",{name:t.name}),action:s("common.add"),disabled:c||b===null,onChange:l,onSubmit:()=>{k()}}),b&&e.jsx(de,{"data-panel-link":"memory-text",icon:Pe,onClick:()=>i({botId:t.id,doc:b}),children:s("botPanel.memory.editText")})]}),m&&!a.mine&&e.jsx(Ni,{bot:t,onChanged:a.reload})]})}function Ei({bot:t,doc:a,mine:n,onDone:l}){const[r,i]=x.useState({text:a.text,hash:a.hash}),[c,d]=x.useState(a.text),[o,u]=x.useState(null),[m,h]=x.useState(null),[b,f]=x.useState(!1),[v,j]=x.useState(null),k=x.useRef(!0);x.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const y=async S=>{f(!0),j(null);try{const E=await Xe(t.id,a.path,c,S,n);if(!k.current)return;E.ok?l(E.doc):u({current:E.current,currentHash:E.currentHash})}catch(E){j(fe(E,s("botPanel.library.memoryError")))}finally{f(!1)}},N=()=>{o&&(h(S=>S===null||S===c?c:`${S}
|
|
15
|
-
|
|
16
|
-
${c}`),i({text:o.current,hash:o.currentHash}),d(o.current),u(null))};return e.jsx(L,{children:e.jsxs(ce,{"data-panel-row":"memory-text",children:[o&&e.jsx(fs,{botName:t.name,busy:b,onReload:N,onOverwrite:()=>{y(o.currentHash)}}),e.jsx("textarea",{"data-memory-text":"",className:O(We,"min-h-[280px] resize-y font-mono text-[13px] leading-relaxed"),value:c,placeholder:s("memory.indexPlaceholder"),"aria-label":s("memory.botMemory"),readOnly:b,onChange:S=>d(S.target.value)}),v&&e.jsx("div",{className:"text-[13px] text-warning",children:v}),m!==null&&e.jsxs("div",{"data-memory-draft":"",children:[e.jsx("div",{className:"mb-1 text-[12px] text-ink-secondary",children:s("memory.unsavedDraft")}),e.jsx("pre",{className:"max-h-[160px] overflow-auto whitespace-pre-wrap rounded-lg border border-hairline/40 bg-inset p-3 font-mono text-[12px] leading-relaxed text-ink",children:m}),e.jsx("button",{type:"button",className:O(re,"mt-1"),onClick:()=>h(null),children:s("memory.dismissDraft")})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{type:"button",className:re,disabled:b,onClick:()=>l(null),children:s("common.cancel")}),e.jsx("button",{type:"button","data-panel-done":"memory-text",className:re,disabled:b||c===r.text,onClick:()=>{y(r.hash)},children:b?s("memory.saving"):s("memory.save")})]})]})})}function Ri({bot:t}){const{request:a}=ln(),{state:n,dispatch:l}=B(),r=is(t),[i,c]=x.useState(""),[d,o]=x.useState(!1),[u,m]=x.useState([]),h=on(n.config),b=async k=>{if(!r.working&&window.confirm(s(k.origin==="library"?"skills.unassignConfirm":"botPanel.skills.removeConfirm",{name:k.name}))){r.setWorking(k.name),r.setError("");try{await a(`/api/bots/${t.id}/skills/${encodeURIComponent(k.name)}`,{method:"DELETE"}),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.removeFailed")))}finally{r.setWorking("")}}},f=async()=>{const k=i.trim();if(!(!k||d)){o(!0),r.setError(""),m([]);try{const y=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:k})});m(yt(y.imported??[])),c(""),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.importFailed")))}finally{o(!1)}}},v=async()=>{const k=await window.ogb?.pickFolder?.();if(!(!k||d)){o(!0),r.setError(""),m([]);try{const y=await a(`/api/bots/${t.id}/skills`,{method:"POST",body:JSON.stringify({source:`local-folder:${k}`})});m(yt(y.imported??[])),await r.refresh()}catch(y){r.setError(fe(y,s("botPanel.skills.importFailed")))}finally{o(!1)}}},j=()=>{if(h){l({type:"toggleSettings",open:!1}),l({type:"toggleAppSettings",open:!0,section:"skills"});return}ct(At)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[r.loading?e.jsx(W,{children:s("skills.loading")}):r.skills.length===0?e.jsx(W,{children:s("botSettings.simple.noSkills")}):r.skills.map(k=>e.jsx(Je,{"data-panel-row":`skill:${k.name}`,title:k.name,hint:k.description||k.source,label:s("botSettings.simple.skillToggle",{name:k.name}),color:t.color,checked:ls(k),disabled:!!r.working,onChange:()=>{r.toggle(k)},extra:k.origin==="imported"||k.origin==="native"?void 0:e.jsx(Oe,{"data-panel-action":`remove-skill:${k.name}`,label:s("botPanel.skills.remove",{name:k.name}),disabled:!!r.working,onClick:()=>{b(k)}})},k.name)),r.error&&!r.reviewing&&e.jsx(W,{tone:"warn",children:r.error})]}),e.jsx(sr,{bot:t,onAdded:()=>{r.refresh()}}),e.jsxs(L,{children:[e.jsx(Xt,{"data-panel-form":"skill-import",value:i,placeholder:s("botPanel.skills.importPlaceholder"),label:s("skills.import.label"),action:d?s("skills.import.importing"):s("common.add"),disabled:d,onChange:c,onSubmit:()=>{f()}}),u.map(k=>e.jsx(W,{children:k},k)),e.jsx(de,{"data-panel-link":"skills-sh",onClick:()=>{ct(At)},children:s("botPanel.skills.skillsSh")}),e.jsx(de,{"data-panel-link":"browse-skills",onClick:j,children:s("botPanel.skills.bundled")}),window.ogb?.pickFolder&&e.jsx(de,{"data-panel-link":"skills-folder",onClick:()=>{v()},children:s("botPanel.skills.fromFolder")})]}),r.reviewing&&e.jsx(ar,{skill:r.reviewing.skill,text:r.reviewing.text,error:r.error,working:r.working===r.reviewing.skill.name,onCancel:()=>r.setReviewing(null),onEnable:()=>{r.enableReviewed()}})]})}function Ii({bot:t}){const{capabilities:a}=ye(),n=a.host?.homeDir,{draft:l,setDraft:r,error:i,saving:c,canPick:d,save:o,pick:u}=tr(t),[m,h]=x.useState(!1),b=!!t.cwd||m,f=()=>{if(d){u();return}h(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs(L,{children:[e.jsx(He,{"data-panel-choice":"private",title:s("botPanel.folder.own"),hint:s("botPanel.folder.ownHint"),checked:!b,disabled:c,onClick:()=>{h(!1),t.cwd&&o(null)}}),e.jsx(He,{"data-panel-choice":"pick",title:s("botPanel.folder.pick"),hint:s("botPanel.folder.pickHint"),checked:b,disabled:c,onClick:()=>{t.cwd||f()}})]}),b&&e.jsxs(L,{children:[d?e.jsxs("div",{className:J,children:[e.jsx("div",{className:"min-w-0 flex-1 truncate rounded-lg border border-hairline/40 bg-inset px-3 py-2 font-mono text-[13px] text-ink",title:t.cwd,children:t.cwd?Ye(t.cwd,n):e.jsx("span",{className:"text-ink-secondary",children:s("botAccess.folder.private")})}),e.jsxs("button",{type:"button","data-panel-action":"pick-folder",disabled:c,onClick:()=>{u()},className:re,children:[e.jsx(Ut,{size:14,"aria-hidden":"true"}),s("botAccess.folder.choose")]})]}):e.jsxs("form",{"data-panel-form":"folder-path",className:J,onSubmit:v=>{v.preventDefault();const j=(l??t.cwd??"").trim();j&&o(j)},children:[e.jsx("input",{value:l??t.cwd??"",placeholder:s("botAccess.folder.placeholder"),"aria-label":s("botAccess.folder.title"),onChange:v=>r(v.target.value),className:"h-8 min-w-0 flex-1 rounded-lg border border-hairline bg-inset px-2.5 font-mono text-[13px] text-ink outline-none placeholder:text-ink-tertiary focus:border-accent-border"}),e.jsx("button",{type:"submit",disabled:c||l===null,className:re,children:s("botAccess.folder.save")})]}),i&&e.jsx(W,{tone:"warn",children:i})]})]})}function Ai({bot:t,derived:a}){const n=gs(t);return e.jsx(xi,{bot:t,browserEnabled:a.browserEnabled,onOpenBrowser:()=>n("browser")})}function Li({bot:t}){return os()?e.jsx(cs,{bot:t}):null}function Mi({page:t,onOpen:a,editingInstructions:n,onEditInstructions:l,...r}){switch(t){case"settings":return e.jsx(ji,{...r,onOpen:a,editingInstructions:n,onEditInstructions:l});case"where":return e.jsx(Qr,{...r});case"apps":return e.jsx(Ci,{...r});case"routines":return e.jsx(Pi,{...r});case"visibility":return e.jsx(Li,{...r});case"memory":return e.jsx(Oi,{...r});case"skills":return e.jsx(Ri,{...r});case"folder":return e.jsx(Ii,{...r});case"browser":return e.jsx(Ai,{...r})}}const Lt="rounded-lg border border-accent-border bg-inset px-2 py-[3px] text-center text-ink outline-none placeholder:text-ink-tertiary";function Mt(t){const[a,n]=x.useState(null),l=x.useRef(!1),r=x.useRef(!1),i=x.useRef(null);x.useEffect(()=>{a!==null||!r.current||(r.current=!1,i.current?.focus())},[a]);const c=m=>{l.current=!1,n(m)},d=()=>{a!==null&&t(a),n(null)};return{draft:a,setDraft:n,start:c,onKeyDown:m=>{if(pn(m.nativeEvent)){m.stopPropagation();return}m.key==="Enter"?(m.preventDefault(),l.current=!0,r.current=!0,d()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),l.current=!0,r.current=!0,n(null))},onBlur:()=>{l.current||d()},buttonRef:i}}function Ti({bot:t,activeState:a,patch:n,editorOpen:l,onToggleEditor:r}){const i=Mt(o=>{const u=o.trim();u&&u!==t.name&&n({name:u})}),c=Mt(o=>{const u=o.trim();u!==t.title.trim()&&n({title:u})}),d=t.title.trim();return e.jsxs("div",{className:"group/hero flex flex-col items-center text-center",children:[e.jsxs("button",{type:"button","data-panel-avatar":!0,"aria-label":s("botPanel.avatar.edit"),"aria-expanded":l,onClick:r,className:"group relative rounded-[18px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-border",children:[e.jsx(qe,{bot:t,size:64,state:a}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-center rounded-[18px] bg-black/0 text-white opacity-0 transition-[opacity,background-color] group-hover:bg-black/40 group-hover:opacity-100 group-focus-visible:bg-black/40 group-focus-visible:opacity-100 group-focus-within:opacity-100 touch:opacity-100 motion-reduce:transition-none",children:e.jsx(ut,{size:20})}),t.chiefOfStaff&&e.jsxs("span",{"data-panel-chief":!0,title:s("chat.chiefOfStaff"),className:"absolute -bottom-0.5 -right-0.5 flex size-[22px] items-center justify-center rounded-full bg-accent text-accent-ink ring-[3px] ring-app",children:[e.jsx(mn,{size:12,"aria-hidden":"true"}),e.jsx("span",{className:"sr-only",children:s("chat.chiefOfStaff")})]}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-[calc(100%+4px)] z-10 -translate-x-1/2 whitespace-nowrap rounded-md border border-hairline bg-menu px-[7px] py-0.5 text-[12px] text-ink opacity-0 transition-opacity group-hover:opacity-100",children:s("botPanel.avatar.edit")})]}),e.jsx("div",{"data-panel-name-row":!0,className:"mt-2 flex max-w-full items-center justify-center",children:e.jsx("h2",{id:"bot-settings-title",className:"flex min-w-0 justify-center",children:i.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-rename-input":!0,"aria-label":s("botSettings.simple.name"),maxLength:Ke.name,value:i.draft,onChange:o=>i.setDraft(o.target.value),onKeyDown:i.onKeyDown,onBlur:i.onBlur,className:O(Lt,"w-[220px] max-w-full text-[17px] font-medium leading-6")}):e.jsxs("button",{ref:i.buttonRef,type:"button","data-panel-rename":!0,title:s("botPanel.rename"),onClick:()=>i.start(t.name),className:"group/name relative inline-flex max-w-full items-center rounded-[8px] px-1.5 text-[17px] font-medium leading-6 text-ink hover:bg-ink/[0.04]",children:[e.jsx("span",{className:"min-w-0 truncate",children:t.name}),e.jsx(ut,{size:13,"aria-hidden":"true",className:"absolute -right-4 shrink-0 text-ink-tertiary opacity-0 transition-opacity group-hover/name:opacity-100 group-focus-visible/name:opacity-100 group-focus-within/name:opacity-100 touch:opacity-100"})]})})}),c.draft!==null?e.jsx("input",{autoFocus:!0,"data-panel-label-input":!0,"aria-label":s("botSettings.simple.job"),placeholder:s("botSettings.simple.jobPlaceholder"),maxLength:Ke.title,value:c.draft,onChange:o=>c.setDraft(o.target.value),onKeyDown:c.onKeyDown,onBlur:c.onBlur,className:O(Lt,"mt-[3px] w-[200px] max-w-full text-[13px]")}):d&&e.jsx("button",{ref:c.buttonRef,type:"button","data-panel-label":!0,onClick:()=>c.start(t.title),className:"mt-px max-w-full truncate rounded-md px-1.5 py-px text-[13px] text-ink-secondary hover:bg-ink/[0.04]",children:d})]})}function ke(t,a){return t?Zt(t,a):{tab:"details"}}function Bi({bot:t,derived:a,linkedSection:n,onClose:l}){const{dragProps:r}=ts(),i=xn(),[c,d]=x.useState(()=>ke(n,i).tab),[o,u]=x.useState(()=>{const p=ke(n,i).page;return p?[p]:[]}),[m,h]=x.useState(()=>ke(n,i).anchor??null),[b,f]=x.useState(!1),[v,j]=x.useState(()=>!!ke(n,i).editInstructions),k=x.useRef(null),y=x.useRef(null),N=o.at(-1)??null,S=()=>k.current?.scrollTo({top:0}),E=p=>{d(p.tab),u(p.page?[p.page]:[]),h(p.anchor??null),f(!1),j(!!p.editInstructions),S()},M=p=>E({tab:p}),F=p=>{u(R=>[...R,p]),f(!1),S()},T=()=>{f(!1),y.current?.querySelector("[data-panel-avatar]")?.focus()},I=()=>{u(p=>p.slice(0,-1)),S()};x.useEffect(()=>{n&&E(Zt(n,i))},[n,i]),x.useEffect(()=>{m&&(k.current?.querySelector(`[data-panel-card="${m}"]`)?.scrollIntoView({block:"start"}),h(null))},[m,N,c]);const z=p=>{if(p.key!=="Escape"||p.defaultPrevented)return;const R=p.target,D=typeof R?.closest=="function"?R.closest('[role="dialog"], [role="alertdialog"]'):null;if(!(D&&!D.contains(p.currentTarget)&&D!==y.current&&!y.current?.contains(D))){if(b)T();else if(o.length>0)I();else return;p.preventDefault(),p.stopPropagation()}},A=o.length>1?s(be[o[o.length-2]].title,{name:t.name}):s(mt[c]);return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",onKeyDown:z,children:[e.jsxs("div",{...r,className:"flex h-[50px] shrink-0 items-start justify-end gap-2.5 px-[13px] pt-[13px]",children:[e.jsx(hn,{bot:t,className:Me}),e.jsx("button",{type:"button","data-panel-gear":!0,"aria-label":s("botPanel.page.settings"),title:s("botPanel.page.settings"),"aria-current":N==="settings"?"page":void 0,onClick:()=>E({tab:"details",page:"settings"}),className:Me,children:e.jsx(fn,{size:16,className:"pointer-events-none"})}),e.jsx("button",{type:"button",onClick:l,"aria-label":s("botSettings.simple.close"),className:Me,children:e.jsx(Ft,{size:16,className:"pointer-events-none"})})]}),e.jsx("div",{ref:k,className:"@container relative min-h-0 flex-1 overflow-y-auto px-4 pb-7",children:N===null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mt-3.5",ref:y,children:[e.jsx(Ti,{bot:t,activeState:a.activeState,patch:a.patch,editorOpen:b,onToggleEditor:()=>f(p=>!p)}),b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-20","aria-hidden":"true","data-panel-scrim":!0,onClick:T}),e.jsx(Yr,{bot:t,activeState:a.activeState,onPatch:a.patch,onClose:T})]})]}),e.jsx("div",{role:"tablist","aria-label":s("botSettings.simple.tabs"),className:"sticky top-0 z-[1] -mx-4 mt-[15px] flex justify-center bg-app px-4 pb-2.5 pt-1 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-3 after:bg-linear-to-b after:from-app after:to-transparent",children:e.jsx("div",{className:"flex min-w-0 gap-0.5 rounded-full bg-ink/[0.05] p-[3px]",children:gn.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":c===p,"data-panel-tab":p,onClick:()=>M(p),className:O("h-[26px] min-w-0 shrink truncate rounded-full px-3 text-[13px] leading-[18px] transition-colors",c===p?"bg-ink/[0.1] font-medium text-ink":"text-ink-secondary hover:text-ink"),children:s(mt[p])},p))})}),e.jsxs("div",{role:"tabpanel",children:[c==="details"&&e.jsx(li,{bot:t,derived:a,onOpen:F}),c==="library"&&e.jsx(js,{bot:t,onOpen:F}),c==="computer"&&e.jsx(Xr,{bot:t,derived:a,onOpen:F})]})]}):e.jsxs("div",{"data-panel-page-view":N,children:[e.jsx("span",{id:"bot-settings-title",className:"sr-only",children:t.name}),e.jsx(yn,{back:A,title:s(be[N].title,{name:t.name}),intro:be[N].intro?s(be[N].intro,{name:t.name}):void 0,onBack:I}),e.jsx("div",{className:O("mt-4",Si),children:e.jsx(Mi,{page:N,bot:t,derived:a,onOpen:F,editingInstructions:v,onEditInstructions:j})})]})})]})}function Di(t,a){const{state:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),[m,h]=x.useState(!1),b=x.useMemo(()=>JSON.stringify([t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),[t.name,t.title,t.description,t.soul,t.computer,t.cloudBackend,t.cwd,t.autoApprove,t.section,t.composio,t.browser,t.mcpServers,t.chiefOfStaff,t.managedSections,t.modelSelection]),f=a.followEdits??!0,v=f?b:null,j=f?n.routines:null,k=f?n.webhooks:null;return x.useEffect(()=>{if(!a.overview&&!a.prompt)return;let y=!1;return(async()=>(await l(t.id),!y&&(a.overview&&se(`/api/bots/${t.id}/overview`).then(S=>{y||(i(S),d(!1))}).catch(()=>{y||d(!0)}),a.prompt&&se(`/api/bots/${t.id}/system-prompt`).then(S=>{y||(u(S),h(!1))}).catch(()=>{y||h(!0)}))))(),()=>{y=!0}},[t.id,a.overview,a.prompt,v,j,k,l]),{overview:r,overviewError:c,prompt:o,promptError:m}}function Fi(t,a){const{dispatch:n,flushBotPatches:l}=B(),[r,i]=x.useState(null),[c,d]=x.useState(!1),[o,u]=x.useState(null),m=x.useRef(0),[h,b]=x.useState(!1),[f,v]=x.useState(null),j=x.useCallback(()=>{const N=++m.current;return d(!1),l(t.id).then(()=>se(`/api/bots/${t.id}/history?limit=100`)).then(S=>{N===m.current&&(i(S.rows),u(S.revision))}).catch(()=>{N===m.current&&d(!0)})},[t.id,l]);return x.useEffect(()=>{if(a)return j(),()=>{m.current++}},[a,j]),{rows:r,error:c,revision:o,rollingBack:h,rollbackTarget:f,setRollbackTarget:v,rollback:async N=>{if(!h){v(null),b(!0);try{await l(t.id),await se(`/api/bots/${t.id}/history/rollback`,{method:"POST",body:JSON.stringify(N)})}catch(S){n({type:"error",message:S instanceof Error?S.message:s("botOverview.undoFailed")})}finally{await j(),b(!1)}}},requestRollback:N=>{o&&v({id:N,expectedRevision:o})}}}function $i({history:t,returnFocusRef:a}){const{rollbackTarget:n,setRollbackTarget:l,rollback:r}=t;return e.jsx(vn,{open:n!==null,title:s("botOverview.restoreSoul.title"),body:s("botOverview.restoreSoul.body"),confirmLabel:s("botOverview.restoreSoul.confirm"),tone:"neutral",returnFocusRef:a,onCancel:()=>l(null),onConfirm:()=>{n&&r(n)}})}const zi={memory:"memory",skills:"skills",folder:"access"},Ns=t=>t.labelKey?s(t.labelKey):t.label;function Tt(t,a){return a?[t.label,Ns(t),...t.keywords].some(n=>n.toLowerCase().includes(a)):!0}function nl({bot:t,overlay:a=!1}){const{state:n,dispatch:l}=B(),r=n.botSettingsSection,i=bn(t),c=x.useRef(null),{dragProps:d}=ts(),[o,u]=x.useState(""),m=!n.botSettingsExpandAccordion,h=o.trim().toLowerCase(),f=!Dt(),v=!m&&!n.botSettingsExpandRemembered?r:null,j=ps(t.id),k=Ge(),y=kn(),N=Cr.filter(A=>A.id!=="slack"||j!==null).filter(A=>A.id!=="visibility"||!window.ogb&&k===!0&&!y),S=N.filter(A=>Tt(A,h)),{overview:E,overviewError:M,prompt:F,promptError:T}=Di(t,{overview:r==="overview"&&!f,prompt:r==="overview"&&!f}),I=Fi(t,r==="history"&&!f);x.useEffect(()=>{if(!m){if(h){u("");return}c.current?.querySelector(`[data-bot-settings-section="${r}"]`)?.scrollIntoView({block:"nearest"})}},[m,r,h]),x.useEffect(()=>{const A=document.activeElement instanceof HTMLElement?document.activeElement:null,p=c.current;p?.focus();const R=D=>{const H=p?.querySelector('[role="dialog"], [role="alertdialog"]');H&&H.getClientRects().length>0||p&&D.target instanceof Node&&!p.contains(D.target)||D.key==="Escape"&&!D.defaultPrevented&&(D.preventDefault(),l({type:"toggleSettings",open:!1}))};return window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R),A?.focus()}},[l]);const z=A=>{switch(A){case"overview":return E===null&&M?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.overviewFailed")}):e.jsx(Lr,{overview:E,refreshError:E!==null&&M,prompt:F,promptError:T,onOpen:p=>l({type:"toggleSettings",open:!0,section:p}),onSetup:i.canCoordinate&&!t.busy?()=>{l({type:"toggleSettings",open:!1}),l({type:"send",botId:t.id,text:"/setup",threadId:t.threadId})}:void 0});case"identity":return e.jsx(dr,{bot:t,patch:i.patch,activeState:i.activeState,mascotMotion:i.mascotMotion});case"soul":return e.jsx(cr,{bot:t,patch:i.patch});case"slack":return j?e.jsx(Mr,{managementUrl:j}):null;case"skills":return e.jsx(or,{bot:t});case"memory":return e.jsx(Dr,{bot:t,active:!m&&r==="memory",onToggle:p=>i.patch({memoryEnabled:p})});case"library":return e.jsx(js,{bot:t,onOpen:p=>l({type:"toggleSettings",open:!0,section:zi[p]??"overview"})});case"routines":return e.jsx(xr,{bot:t,routines:i.botRoutines,runs:n.routineRuns});case"access":return e.jsx(lr,{bot:t,derived:i});case"model":return e.jsx(ir,{bot:t});case"permissions":return e.jsx(rr,{bot:t,derived:i});case"voice":return e.jsx(nr,{bot:t,derived:i});case"visibility":return e.jsx(cs,{bot:t});case"history":return I.rows===null&&I.error?e.jsx("div",{className:"rounded-xl bg-card p-4 text-[13px] text-ink-secondary",children:s("botSettings.historyFailed")}):e.jsx(Hr,{bot:t,rows:I.rows,refreshError:I.rows!==null&&I.error,onRollback:I.requestRollback,rollingBack:I.rollingBack||!I.revision});case"usage":return e.jsx(_r,{bot:t});default:return null}};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{ref:c,id:f?jn:void 0,role:"dialog","aria-labelledby":"bot-settings-title",tabIndex:-1,className:Nn(a,f),children:f?e.jsx(Bi,{bot:t,derived:i,linkedSection:v,onClose:()=>l({type:"toggleSettings",open:!1})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{...d,className:"flex shrink-0 items-center justify-between px-4 py-3",children:[e.jsx("span",{id:"bot-settings-title",className:"truncate text-[15px] font-semibold text-ink",children:t.name}),e.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(wn,{bot:t,className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink"}),e.jsx("button",{type:"button",onClick:()=>l({type:"toggleSettings",open:!1}),"aria-label":s("botSettings.simple.close"),className:"rounded-md p-1 text-ink-secondary hover:bg-control hover:text-ink",children:e.jsx(Ft,{size:18,className:"pointer-events-none"})})]})]}),e.jsxs("div",{className:"mx-4 mb-2 flex shrink-0 items-center gap-2 rounded-lg border border-transparent bg-control/70 px-2.5 py-2 focus-within:border-focus",children:[e.jsx(Bt,{size:14,className:"shrink-0 text-ink-secondary"}),e.jsx("input",{value:o,onChange:A=>{u(A.target.value),l({type:"toggleSettings",open:!0})},onKeyDown:A=>{A.key==="Escape"&&(A.stopPropagation(),o?u(""):l({type:"toggleSettings",open:!1}))},placeholder:s("botSettings.search"),"aria-label":s("botSettings.searchAria"),className:"w-full bg-transparent text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[S.length===0&&e.jsx("div",{className:"px-4 py-4 text-[13px] leading-relaxed text-ink-secondary",children:s("botSettings.searchNone",{query:o.trim()})}),N.map(A=>{const{id:p,icon:R}=A,D=Ns(A),H=Tt(A,h);if(!H&&p!=="memory")return null;const _=!m&&r===p;return e.jsxs("div",{"data-bot-settings-section":p,className:"border-b border-hairline/30",hidden:!H,children:[e.jsxs("button",{type:"button",onClick:()=>{if(r===p&&!m){l({type:"toggleSettings",open:!0});return}l({type:"toggleSettings",open:!0,section:p})},"aria-expanded":_,className:O("flex w-full shrink-0 items-center gap-2.5 px-4 py-2.5 text-left text-[14px]",_?"bg-control/60 text-ink":"text-ink-secondary hover:bg-control/40 hover:text-ink"),children:[e.jsx(R,{size:15,className:"shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:D}),e.jsx(xe,{size:16,className:O("shrink-0 text-ink-secondary transition-transform",_&&"rotate-180")})]}),p==="memory"?e.jsx("div",{hidden:!_,className:"px-4 pb-4 pt-1",children:z("memory")}):_&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:z(p)})]},p)})]})]})}),e.jsx($i,{history:I,returnFocusRef:c})]})}export{nl as BotSettingsDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as s,r as o,d as Ae,j as e,X as ve,f as Te,a as Q,ac as ye,ad as Le,h as De,k as Oe,ae as Me,af as Ue,ag as Fe,b as ze,ah as Ie,ai as Ke,aj as _e,ak as $e,p as le,z as He}from"./styles-ElM5u1od.js";import{n as C,K as Ve,u as k,bL as ee,bM as qe,bN as y,S as R,bO as Je,bP as we,bQ as te,bR as We,bS as Ye,bT as Xe,bU as Ze,bV as oe,bW as ce,bX as Ge,bY as Qe,bZ as et,b_ as je,D as M,b$ as tt,c0 as st,e as ke,c1 as nt,c2 as de,c3 as at,c4 as it,c5 as rt,c6 as lt,c7 as ot,c8 as ct,c9 as dt,ca as ut,cb as pt,cc as xt,cd as mt,ce as gt,cf as ue,cg as ht,ch as ft,ci as bt,cj as vt,ck as Se,cl as Ne,cm as yt,cn as wt,co as jt,cp as kt,cq as St,cr as pe,T as Ce,cs as Nt}from"./App-5fWd2qWI.js";import{B as xe,E as Ct,s as Et,r as me,p as Bt,c as Rt,a as Pt}from"./new-bot-COptZjiW.js";import{o as At}from"./index-BJo4IICg.js";import{I as Tt,S as Lt,a as Dt,A as Ot,M as Mt,P as Ut,V as Ft,v as zt,i as ge}from"./VisibilitySection-yE3ZIXKk.js";import{R as It}from"./RoutinesPage-CCSHgNRs.js";import{r as Kt,L as X,R as _t,U as $t,V as Ht,P as Vt}from"./PlacesRail-BYBRFGDz.js";import{p as qt,d as Jt,e as Wt,f as Yt}from"./team-share-B2cRBtNk.js";import{B as Xt}from"./BrowserProfilesManager-DbsOGGoV.js";function Zt(t){const n=[];for(const a of t){const i=a.source==="org"?s("newBot.presetsFromOrganization",{name:a.publisherName??a.packageName}):s("newBot.presetsImported"),r=n.find(l=>l.label===i);r?r.presets.push(a):n.push({label:i,presets:[a]})}return n}function Gt(t){const n={name:t.bot.name??t.name,title:t.bot.title??"",description:t.bot.description??"",soul:t.bot.soul??""},a=t.bot.appearance;return a&&(n.color=a.color,n.mascotExpression=a.mascotExpression??null,a.mascotBody&&(n.mascotBody=a.mascotBody)),n}function Qt(t){const n=t.bot.appearance?.avatar;if(!n)return null;let a;try{a=atob(n.data)}catch{return null}const i=new Uint8Array(a.length);for(let r=0;r<a.length;r+=1)i[r]=a.charCodeAt(r);return new File([i],`preset.${n.mime.slice(6)}`,{type:n.mime})}function es(t){const n=[t.source==="org"&&t.publisherName?s("newBot.presetFromOrg",{package:t.packageName,release:t.release,publisher:t.publisherName}):s("newBot.presetFrom",{package:t.packageName,release:t.release})];t.description&&n.push(t.description);const a=t.skills.map(i=>i.name).join(", ");return a&&n.push(s(t.skillsEnabled?"newBot.presetSkillsOn":"newBot.presetSkillsOff",{names:a})),t.notes.length&&n.push(s("newBot.presetNotes",{names:t.notes.join(", ")})),t.playbooks.length&&n.push(s("newBot.presetPlaybooks",{names:t.playbooks.join(", ")})),n.push(s("newBot.presetKeeps")),n}function ts(t){return{id:t.id,skills:t.skills.map(n=>n.name),notes:[...t.notes]}}function he(t){const n=a=>a?.trim()?a.trim():void 0;return{format:"package",version:2,kind:"library",name:n(t.name),presetName:n(t.name),presetDescription:n(t.description),release:n(t.release),notes:n(t.notes),includeMemory:t.includeNotes,...t.picture?{presetAvatar:t.picture}:{},...t.dryRun?{dryRun:!0}:{}}}function fe({preview:t,localSkips:n}){const a=t.document.package.presets?.[0],i=Object.keys(a?.seed?.memory??{}).length,r=[[s("teamShare.part.skills"),a?.skills?.length?`${a.skills.length} · ${a.skills.join(", ")}`:"0"],[s("teamShare.part.notes"),i?String(i):s("teamShare.none")],[s("teamShare.part.pictures"),a?.bot.appearance?.avatar?s("teamShare.yes"):s("teamShare.none")]],l=[...n,...t.skipped.map(d=>Jt(d,t.document))];return e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-medium text-ink-secondary",children:s("teamShare.included")}),e.jsx("dl",{className:"mt-2 grid grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-1.5 rounded-xl bg-raised/45 px-4 py-3 text-[13px]",children:r.map(([d,c])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-ink-secondary",children:d}),e.jsx("dd",{className:"max-w-[300px] truncate text-right text-ink",title:c,children:c})]},d))}),e.jsxs("p",{className:"mt-3 flex items-start gap-2 text-[13px] leading-relaxed text-ink-secondary",children:[e.jsx(Ve,{size:15,className:"mt-0.5 shrink-0 text-success"}),e.jsx("span",{children:s("presetShare.never")})]}),t.redacted.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.redacted")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:t.redacted.map(d=>e.jsx("li",{children:Wt(d,t.document)},d))})]}),l.length>0&&e.jsxs("div",{className:"mt-3 rounded-xl border border-hairline px-4 py-3 text-[13px] text-ink-secondary",children:[e.jsx("div",{className:"font-medium text-ink",children:s("teamShare.skipped")}),e.jsx("ul",{className:"mt-1 list-disc pl-5",children:l.map((d,c)=>e.jsx("li",{children:d},`${d}-${c}`))})]})]})}function ss({onClose:t}){const n=o.useRef(null),[a,i]=o.useState(""),[r,l]=o.useState(""),[d,c]=o.useState(""),[p,m]=o.useState(""),[w,P]=o.useState(!0),[A,g]=o.useState(!0),[h,v]=o.useState(null),[b,T]=o.useState(null),[f,L]=o.useState(!1),[I,$]=o.useState(null),[U,K]=o.useState(""),_=o.useRef(0);o.useEffect(()=>{let u=!1;return C("/api/bot-defaults").then(async({defaults:E})=>{!u&&E.profile.name?.trim()&&i(D=>D||E.profile.name.trim());const S=await qt([{id:"defaults",avatarUrl:E.profile.avatarUrl,avatarCrop:E.profile.avatarCrop}]);u||v({dataUrl:S.avatars.defaults,skipped:S.skipped.map(D=>`${s("teamShare.field.picture")} — ${Ae(`teamShare.skip.${D.reason}`,D.reason)}`)})}).catch(()=>{u||v({skipped:[]})}),()=>{u=!0}},[]);const q=u=>({name:a,description:r,release:d,notes:p,includeNotes:w,dryRun:u,...A&&h?.dataUrl?{picture:h.dataUrl}:{}});o.useEffect(()=>{if(!h)return;const u=++_.current,E=window.setTimeout(()=>{C("/api/teams/export",{method:"POST",body:JSON.stringify(he({...q(!0),release:void 0}))}).then(S=>{u===_.current&&(T(S),K(""),c(D=>D||S.document.package.release))}).catch(S=>{u===_.current&&(T(null),K(S instanceof Error?S.message:String(S)))})},250);return()=>window.clearTimeout(E)},[h,w,A]);const F=async()=>{if(!f){L(!0),K("");try{const u=await C("/api/teams/export",{method:"POST",body:JSON.stringify(he(q(!1)))});Yt(u.filename,u.document),$(u)}catch(u){K(u instanceof Error?u.message:String(u))}finally{L(!1)}}};o.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null;return n.current?.focus(),()=>{u?.isConnected&&u.focus()}},[]);const H=A?h?.skipped??[]:[],z="mt-1 w-full rounded-lg border border-hairline/50 bg-inset px-3 py-2 text-[14px] text-ink disabled:opacity-60";return Kt.createPortal(e.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/55 p-4",onMouseDown:u=>{u.target===u.currentTarget&&!f&&t()},children:e.jsxs("div",{ref:n,role:"dialog","aria-modal":"true","aria-labelledby":"share-preset-title",tabIndex:-1,className:"flex max-h-[90vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel text-ink shadow-2xl outline-none",onKeyDown:u=>{if(u.key==="Escape"&&!f&&(u.stopPropagation(),t()),u.key==="Tab"){const E=n.current?.querySelectorAll("input:enabled, textarea:enabled, button:enabled");if(!E?.length)return;const S=E[0],D=E[E.length-1];u.shiftKey&&document.activeElement===S?(u.preventDefault(),D.focus()):!u.shiftKey&&document.activeElement===D&&(u.preventDefault(),S.focus())}},children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-6 pb-2 pt-5",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"share-preset-title",className:"text-[17px] font-semibold",children:s("presetShare.title")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.intro")})]}),e.jsx("button",{"aria-label":s("presetShare.close"),disabled:f,onClick:t,className:"rounded-lg p-1.5 text-ink-secondary hover:bg-raised",children:e.jsx(ve,{size:18})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 pb-4 pt-2",children:I?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"flex items-center gap-2 text-[14px] font-medium text-ink",children:[e.jsx(Te,{size:16,className:"text-success"}),s("teamShare.saved",{filename:I.filename})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-ink-secondary",children:s("presetShare.savedHint")}),e.jsx("div",{className:"mt-4",children:e.jsx(fe,{preview:I,localSkips:H})})]}):e.jsxs(e.Fragment,{children:[b?e.jsx(fe,{preview:b,localSkips:H}):!U&&e.jsxs("div",{className:"flex items-center gap-2 py-6 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:15,className:"animate-spin"}),s("presetShare.preparing")]}),e.jsxs("fieldset",{className:"mt-4 space-y-2 text-[13px]",disabled:f,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:A,onChange:u=>g(u.target.checked)}),s("presetShare.includePicture")]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",className:"size-4 accent-accent",checked:w,onChange:u=>P(u.target.checked)}),s("presetShare.includeNotes")]})]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("presetShare.name"),e.jsx("input",{value:a,maxLength:100,disabled:f,onChange:u=>i(u.target.value),className:z})]}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("teamShare.release"),e.jsx("input",{value:d,maxLength:20,disabled:f,placeholder:"1.0.0",onChange:u=>c(u.target.value),className:z})]})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("presetShare.description"),e.jsx("input",{value:r,maxLength:300,disabled:f,onChange:u=>l(u.target.value),className:z})]}),e.jsxs("label",{className:"mt-3 block text-[13px] text-ink-secondary",children:[s("teamShare.notes"),e.jsx("textarea",{value:p,maxLength:4e3,rows:2,disabled:f,onChange:u=>m(u.target.value),className:z})]})]})}),U&&e.jsx("p",{role:"alert",className:"mx-6 mb-2 rounded-lg bg-danger/10 px-3 py-2 text-[13px] text-danger",children:U}),e.jsx("footer",{className:"flex justify-end gap-2 border-t border-hairline/35 px-6 py-3",children:I?e.jsx("button",{onClick:t,className:"rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white",children:s("teamShare.done")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:f,onClick:t,className:"rounded-lg px-3 py-2 text-[13px] text-ink-secondary hover:bg-raised",children:s("common.cancel")}),e.jsxs("button",{disabled:f||!b,onClick:()=>{F()},className:"flex items-center gap-2 rounded-lg bg-accent px-4 py-2 text-[13px] font-medium text-white disabled:opacity-40",children:[f&&e.jsx(X,{size:14,className:"animate-spin"}),f?s("teamShare.saving"):s("teamShare.save")]})]})})]})}),document.body)}function se(){const{dispatch:t}=k(),[n,a]=o.useState(!1),[i,r]=o.useState("");return{saving:n,error:i,save:async d=>{if(!n){a(!0),r("");try{const c=await C("/api/config",{method:"PATCH",body:JSON.stringify(d)});t({type:"configStatus",config:c})}catch(c){r(c instanceof Error?c.message:s("settings.experimental.error"))}finally{a(!1)}}}}}function Bs(){const{state:t}=k(),n=ee(t.config),a=qe(t.config),i=t.config?.browserEngine?.installable===!0,r=window.ogb?.platform==="win32"&&!a&&!i,{saving:l,error:d,save:c}=se();return e.jsx(y,{title:s("settings.experimental.browserAria"),subtitle:a?n?s("settings.experimental.browserOn"):s("settings.experimental.browserOff"):r?s("settings.experimental.browserWindows"):Je(t.config),message:d?e.jsx("p",{role:"alert",className:"text-danger",children:d}):null,children:e.jsx(R,{checked:n,"aria-label":s("settings.experimental.browserAria"),disabled:l||!n&&!a&&!i,onClick:()=>{c({features:{browser:!n}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function Rs(){const{state:t}=k(),n=we(),a=t.config?.browserEngine?.serverSites,{saving:i,error:r,save:l}=se();return a===void 0||n!==!0||!ee(t.config)?null:e.jsx(y,{title:s("settings.browser.serverSites"),subtitle:s("settings.browser.serverSitesDetail"),message:r?e.jsx("p",{role:"alert",className:"text-danger",children:r}):null,children:e.jsx(R,{checked:a,"aria-label":s("settings.browser.serverSites"),disabled:i,onClick:()=>{l({browserEngine:{egress:{localNetwork:!a}}})},className:"disabled:cursor-wait disabled:opacity-50"})})}function ns(){const{state:t}=k(),n=t.config?.browserEngine?.engine==="chrome",{saving:a,error:i,save:r}=se();return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"new-browser-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.newBrowser")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.newBrowserDetail")})]}),e.jsx(R,{checked:n,"aria-label":s("settings.experimental.newBrowserAria"),disabled:a,onClick:()=>{r({browserEngine:{engine:n?"agent-browser":"chrome"}})},className:"disabled:cursor-wait disabled:opacity-50"})]}),i?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:i}):null]})}function as(){const{state:t,dispatch:n}=k(),a=te(t.config),i=We(t.config),r=Ye(t.config),l=Xe(t.config),d=Ze(t.bots,t.instances),[c,p]=o.useState(String(l)),[m,w]=o.useState(!1),[P,A]=o.useState(!1),[g,h]=o.useState(""),v=o.useRef(!1);o.useEffect(()=>{m||p(String(l))},[l,m]);const b=async f=>{if(v.current)return!1;v.current=!0,A(!0),h("");try{const L=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:f})});return n({type:"configStatus",config:L}),!0}catch(L){return h(L instanceof Error?L.message:s("settings.experimental.error")),!1}finally{v.current=!1,A(!1)}},T=async()=>{if(!m)return;const f=Ge(c);if(f===null){h(s("settings.experimental.skillReviewStepsRange",{min:ce,max:oe}));return}await b({skillReviewSteps:f})&&w(!1)};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"skill-review-settings",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillReview")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(a?"settings.experimental.skillReviewDetail":"settings.experimental.skillReviewNeedsAuthoring")})]}),e.jsx(R,{checked:i,"aria-label":s("settings.experimental.skillReviewAria"),disabled:P||!a,onClick:()=>{b({skillReview:!i})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}),e.jsx(is,{engines:d}),i?e.jsxs("div",{className:"mt-3 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13px] text-ink",children:s("settings.experimental.skillAutoApply")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAutoApplyDetail")})]}),e.jsx(R,{checked:r,"aria-label":s("settings.experimental.skillAutoApplyAria"),disabled:P,onClick:()=>{b({skillAutoApply:!r})},className:"disabled:cursor-not-allowed disabled:opacity-50"})]}):null,i?e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("label",{htmlFor:"skill-review-steps",className:"text-[13px] text-ink",children:s("settings.experimental.skillReviewSteps")}),e.jsx("div",{className:`flex w-[96px] items-center rounded-lg border bg-inset ${g?"border-danger/60":"border-hairline/40 focus-within:border-focus"}`,children:e.jsx("input",{id:"skill-review-steps",type:"number",min:ce,max:oe,step:1,inputMode:"numeric",value:c,disabled:P,"aria-invalid":!!g,onChange:f=>{p(f.target.value),w(!0),h("")},onBlur:()=>{T()},onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()},className:"min-w-0 flex-1 bg-transparent px-3 py-1.5 text-[14px] tabular-nums text-ink focus:outline-none"})})]}):null,g?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:g}):null]})}function is({engines:t}){return t.length?e.jsx("p",{className:"mt-2 text-[12px] leading-relaxed text-ink-secondary","data-testid":"skill-review-engine-note",children:s("settings.experimental.skillReviewNoEngine",{engines:t.join(", ")})}):null}const rs=[{value:"off",label:"settings.experimental.shareSkillsOff"},{value:"ask",label:"settings.experimental.shareSkillsAsk"},{value:"auto",label:"settings.experimental.shareSkillsAuto"}];function ls(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState("");if(!Qe(t.config))return null;const d=te(t.config),c=et(t.config),p=async m=>{if(!(a||m===c)){i(!0),l("");try{const w=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{shareLearnedSkills:m}})});n({type:"configStatus",config:w})}catch(w){l(w instanceof Error?w.message:s("settings.experimental.error"))}finally{i(!1)}}};return e.jsxs("div",{className:"mt-4 border-t border-hairline/30 pt-4","data-testid":"share-learned-skills-settings",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.shareSkills")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s(d?"settings.experimental.shareSkillsDetail":"settings.experimental.shareSkillsNeedsAuthoring")})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded-xl bg-inset p-1",role:"radiogroup","aria-label":s("settings.experimental.shareSkillsAria"),children:rs.map(m=>e.jsx("button",{type:"button",role:"radio","aria-checked":c===m.value,disabled:a||!d,onClick:()=>{p(m.value)},className:Q("rounded-lg px-3 py-1.5 text-[13px] transition-colors disabled:cursor-not-allowed disabled:opacity-50",c===m.value?"bg-raised text-ink shadow":"text-ink-secondary hover:text-ink"),children:s(m.label)},m.value))})]}),r?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:r}):null]})}function os(){return e.jsxs(e.Fragment,{children:[e.jsx(as,{}),e.jsx(ls,{})]})}function Ps({title:t=s("settings.updates.title")}){const n=gt(),a=window.ogb?.updater;if(!n||!a)return null;const i=n.status==="checking"?s("settings.updates.checking"):n.status==="downloading"?n.percent==null?s("settings.updates.startingDownload"):s("settings.updates.downloading",{percent:Math.round(n.percent)}):n.status==="preparing"?s("settings.updates.preparing"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.readyInstall",{app:le(),version:n.version??""}):s("settings.updates.ready",{app:le(),version:n.version??""}):n.status==="installing"?ue(n)||(n.installMode==="handoff"?s("settings.updates.openingTerminal"):s("settings.updates.restarting")):n.status==="handed-off"?s("settings.updates.handedOff"):n.status==="error"?s("settings.updates.failed",{message:ue(n)??s("settings.updates.unknownError")}):s("settings.updates.latest");return e.jsx(y,{title:t,subtitle:i,children:e.jsx("button",{onClick:()=>{if(n.status==="downloaded")return void a.install();a.check()},disabled:n.status==="checking"||n.status==="downloading"||n.status==="preparing"||n.status==="installing"||n.retryable===!1,className:"ui-button",children:n.retryable===!1?s("settings.updates.quitReopen"):n.status==="downloaded"?n.installMode==="handoff"?s("settings.updates.install"):s("settings.updates.restart"):n.status==="preparing"?s("settings.updates.preparingShort"):n.status==="installing"?n.installMode==="handoff"?s("settings.updates.opening"):s("settings.updates.restartingShort"):s("settings.updates.check")})})}function Ee(){const{state:t,dispatch:n}=k(),a=t.config?.newBots?.effort??"",[i,r]=o.useState(!1),[l,d]=o.useState("");return{current:a,saving:i,error:l,save:async p=>{if(!i){r(!0),d("");try{const m=await C("/api/config",{method:"PATCH",body:JSON.stringify({newBots:{effort:vt(p)?p:null}})});n({type:"configStatus",config:m})}catch(m){d(m instanceof Error?m.message:s("settings.newBotEffort.error"))}finally{r(!1)}}}}}function Be({effort:t,className:n}){return e.jsxs(M,{size:"sm",className:n,value:t.current,disabled:t.saving,"aria-label":s("settings.newBotEffort.aria"),onChange:a=>{t.save(a.target.value)},children:[e.jsx("option",{value:"",children:s("settings.newBotEffort.default")}),ht.map(a=>e.jsx("option",{value:a,children:ft(a)},a))]})}function As(){const t=Ee();return e.jsx(y,{title:s("settings.newBotEffort.title"),subtitle:s("settings.newBotEffort.subtitle"),message:t.error?e.jsx("p",{role:"alert",className:"text-danger",children:t.error}):null,children:e.jsx(Be,{effort:t,className:"w-full max-w-[240px]"})})}function cs({onEdit:t,onShare:n}){const a=Ee();return e.jsx(y,{title:s("newBot.defaults"),subtitle:s("settings.newBotEffort.title"),message:a.error?e.jsx("p",{role:"alert",className:"text-danger",children:a.error}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Be,{effort:a,className:"w-auto"}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-share":!0,onClick:n,children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",className:"ui-button","data-new-bot-defaults":!0,onClick:t,children:s("newBot.edit")})]})})}function ds(){const{state:t,dispatch:n}=k(),[a,i]=o.useState(!1),[r,l]=o.useState(!1);return e.jsxs("div",{children:[e.jsx("button",{disabled:a,onClick:()=>{i(!0),l(!1),C("/api/config",{method:"PUT",body:JSON.stringify({onboarding:{...t.config?.onboarding?.completedAt?{}:_t().onboarding,hintsSeen:bt(t.config?.onboarding)}}),signal:AbortSignal.timeout(1e4)}).then(d=>{n({type:"configStatus",config:d}),n({type:"toggleTour",open:!0})}).catch(()=>l(!0)).finally(()=>i(!1))},className:"ui-button",children:s("settings.welcome.appTour")}),r&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:s("onboarding.tour.error")})]})}function Ts(){const{dispatch:t}=k();return e.jsx(y,{title:s("settings.welcome.title"),subtitle:s("settings.welcome.subtitleShort"),children:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsx(ds,{}),e.jsx("button",{onClick:()=>t({type:"toggleWelcome",open:!0}),className:"ui-button",children:s("settings.welcome.replay")})]})})}function Ls({simple:t=!1}){const{state:n}=k(),a=De(Oe(),n.config?.language);return e.jsx(y,{title:s("settings.language.title"),subtitle:Fe()?s("settings.language.subtitleComplete"):t?ze()==="en"?void 0:s("settings.simple.language.partial"):s("settings.language.subtitle"),children:e.jsxs(M,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:a,"aria-label":s("settings.language.aria"),onChange:i=>Ue(i.target.value),children:[e.jsx("option",{value:"",children:s(t?"settings.simple.language.system":"settings.language.system")}),Me.map(({code:i,label:r})=>e.jsx("option",{value:i,children:r},i))]})})}function Ds({simple:t=!1}){const n=ke();return e.jsx(y,{title:s("settings.sendKey.title"),subtitle:s(t?"settings.simple.sendKey":"settings.sendKey.subtitle",{key:de("mod-enter")}),children:e.jsx(M,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.sendKey.title"),onChange:a=>at(it(a.target.value)),children:nt.map(a=>e.jsx("option",{value:a,children:de(a)},a))})})}function Os({simple:t=!1}){const n=rt(),a=lt(ke());return e.jsx(y,{title:s("settings.followUp.title"),subtitle:s(t?"settings.simple.followUp":"settings.followUp.subtitle",{key:a}),children:e.jsxs(M,{size:"sm",variant:t?"ghost":"field",className:t?void 0:"w-full max-w-[240px]",value:n,"aria-label":s("settings.followUp.title"),onChange:i=>ot(ct(i.target.value)),children:[e.jsx("option",{value:"steer",children:s("settings.followUp.steer")}),e.jsx("option",{value:"queue",children:s("settings.followUp.queue")})]})})}function Ms({simple:t=!1}){const n=tt();return e.jsx(y,{title:s(t?"settings.userBubbles.simpleTitle":"settings.userBubbles.title"),subtitle:t?void 0:s("settings.userBubbles.subtitle"),children:e.jsx(R,{checked:n,"aria-label":s("settings.userBubbles.aria"),onClick:()=>st(!n)})})}function Us({simple:t=!1}){const n=ye();return e.jsx(y,{className:t?void 0:"rounded-2xl border border-accent-border/40 bg-raised-hover/40 py-4",title:s("settings.advancedMode.title"),subtitle:s(t?"settings.simple.advancedMode":"settings.advancedMode.subtitle"),children:e.jsx(R,{checked:n,"aria-label":s("settings.advancedMode.title"),onClick:()=>Le(!n)})})}function Fs(){const t=Ie();return e.jsx(y,{title:s("settings.threadDisplay.title"),subtitle:s("settings.threadDisplay.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.threadDisplay.show"),onClick:()=>Ke(!t)})})}function zs(){const t=dt();return e.jsx(y,{title:s("settings.pinnedCircles.title"),subtitle:s("settings.pinnedCircles.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.pinnedCircles.title"),onClick:()=>ut(!t)})})}function Is(){const t=_e();return e.jsx(y,{title:s("settings.runCard.title"),subtitle:s("settings.runCard.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.runCard.show"),onClick:()=>$e(!t)})})}function Ks(){const t=pt();return e.jsx(y,{title:s("settings.universalPins.title"),subtitle:s("settings.universalPins.subtitle"),children:e.jsx(R,{checked:t,"aria-label":s("settings.universalPins.title"),onClick:()=>xt(!t)})})}function _s(){const{state:t,dispatch:n}=k(),a=mt(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async()=>{if(!i){r(!0),d("");try{const p=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{showToolCalls:!a}})});n({type:"configStatus",config:p})}catch(p){d(p instanceof Error?p.message:s("settings.toolCalls.error"))}finally{r(!1)}}};return e.jsx(y,{title:s("settings.toolCalls.title"),subtitle:e.jsxs(e.Fragment,{children:[s("settings.toolCalls.subtitle")," ",s("settings.toolCalls.detail")]}),message:l?e.jsx("p",{role:"alert",className:"text-danger",children:l}):null,children:e.jsx(R,{checked:a,"aria-label":s("settings.toolCalls.aria"),disabled:i,onClick:()=>{c()},className:"disabled:cursor-wait disabled:opacity-50"})})}function $s(){const{state:t,dispatch:n}=k(),a=te(t.config),[i,r]=o.useState(!1),[l,d]=o.useState(""),c=async p=>{if(!i){r(!0),d("");try{const m=await C("/api/config",{method:"PATCH",body:JSON.stringify({features:{skillAuthoring:p}})});n({type:"configStatus",config:m})}catch(m){d(m instanceof Error?m.message:s("settings.experimental.error"))}finally{r(!1)}}};return e.jsxs(je,{title:s("settings.experimental.title"),subtitle:s("settings.experimental.subtitle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-medium text-ink",children:s("settings.experimental.skillAuthoring")}),e.jsx("div",{className:"mt-0.5 text-[12px] leading-relaxed text-ink-secondary",children:s("settings.experimental.skillAuthoringDetail")})]}),e.jsx(R,{checked:a,"aria-label":s("settings.experimental.skillAuthoringAria"),disabled:i,onClick:()=>{c(!a)},className:"disabled:cursor-wait disabled:opacity-50"})]}),l?e.jsx("p",{role:"alert",className:"mt-2 text-[12px] text-danger",children:l}):null,e.jsx(os,{}),e.jsx(ns,{})]})}function Hs(){const{state:t}=k(),n=t.config?.browserProfiles??[];return!ee(t.config)&&n.length===0?null:e.jsx(je,{title:s("settings.profiles.title"),subtitle:s("settings.profiles.sharedSubtitle"),children:e.jsx(Xt,{})})}const be=["Identity","Soul","Skills","Memory","Routines","Access","Model","Permissions","Voice & alerts"],us={Identity:"botSettings.sections.identity",Soul:"botSettings.sections.soul",Skills:"botSettings.sections.skills",Memory:"botSettings.sections.memory",Routines:"botSettings.sections.routines",Access:"botSettings.sections.access",Model:"botSettings.sections.model",Permissions:"botSettings.sections.permissions","Voice & alerts":"botSettings.sections.voice"};function Re(t){return e.jsx($t,{modal:!0,children:e.jsx(ps,{...t})})}function ps({defaultsMode:t=!1,onClose:n,onCreated:a,readyBotId:i}){const r=Ht(),l=k(),[,d]=o.useState(0),[c,p]=o.useState(()=>new xe(Ct,()=>d(x=>x+1))),[m,w]=o.useState("Identity"),[P,A]=o.useState(!1),[g,h]=o.useState(!1),v=g||l.state.botCreationPending,b=o.useRef(!1),T=o.useRef(!0),[f,L]=o.useState(""),[I,$]=o.useState(null),[U,K]=o.useState("everyone"),[_,q]=o.useState(""),F=Se(),H=l.state.config?.team?.name,[z,u]=o.useState(null),E=we(),S=He(),D=ye()?be:be.filter(x=>x!=="Model"),ne=!t&&typeof window<"u"&&!window.ogb&&E===!0,J=o.useRef(null),V=o.useRef(n);V.current=n,o.useEffect(()=>{let x=!1;return C("/api/bot-defaults").then(B=>{if(x)return;const j=Et(B,!t),N=t||!i?void 0:Ne(i),O=new xe(N?yt(j,N):j,()=>d(Y=>Y+1));N&&(O.role=N.id),p(O),A(!0)}).catch(B=>{x||L(String(B))}),()=>{x=!0}},[t,i]),o.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),o.useEffect(()=>()=>c.dispose(),[c]),o.useEffect(()=>{v&&J.current?.focus()},[v]),o.useEffect(()=>{const x=document.activeElement instanceof HTMLElement?document.activeElement:null;J.current?.focus();const B=j=>{if(!r())return;const N=J.current;if(!N||j.target instanceof Node&&!N.contains(j.target))return;const O=N.querySelector('[role="dialog"], [role="alertdialog"]');if(O&&O.getClientRects().length||(j.key==="Escape"&&(j.preventDefault(),V.current()),j.key!=="Tab"))return;const Y=[...N.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex="0"]')].filter(re=>re.getClientRects().length&&!re.closest("[hidden],fieldset:disabled")),Z=Y[0],G=Y.at(-1);if(!Z||!G){j.preventDefault(),N.focus();return}j.shiftKey&&(document.activeElement===Z||document.activeElement===N)?(j.preventDefault(),G.focus()):!j.shiftKey&&(document.activeElement===G||document.activeElement===N)&&(j.preventDefault(),Z.focus())};return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B),x?.isConnected&&x.focus()}},[r]);const ae=async()=>{if(!P||b.current||l.state.botCreationPending)return;if(!t&&c.bot.approvalMode==="auto"&&c.bot.computer==="local"&&!c.consent.acknowledgeLocalAuto){$("local");return}const x=ne?zt(U,_):null;if(x&&!x.ok){L(s("botSettings.visibility.needPeople"));return}b.current=!0,h(!0),L(""),l.dispatch({type:"botCreationPending",on:!0});try{if(t)await C("/api/config",{method:"PATCH",body:JSON.stringify({newBotDefaults:await Bt(c)})});else{const{bot:B,warnings:j,paused:N}=await Rt(c,void 0,void 0,void 0,x?.ok?x.visibility:void 0,F?me(z,c.bot.section,l.state.bots,F)??void 0:void 0);Pt(l.dispatch,B,j,{showThreads:S,source:c.preset?"preset":c.role?"template":"blank",role:c.role,paused:N});try{await a?.(B)}catch(O){l.dispatch({type:"error",message:O instanceof Error?O.message:String(O)})}}b.current=!1,T.current&&V.current()}catch(B){T.current&&L(B instanceof Error?B.message:String(B))}finally{b.current=!1,l.dispatch({type:"botCreationPending",on:!1}),T.current&&h(!1)}},W=c.bot,Pe={...l,state:{...l.state,bots:[W,...l.state.bots],routines:c.routines,routineRuns:[],routinesLoadState:"ready"},flushBotPatches:async()=>W,dispatch:x=>{x.type==="updateBot"&&x.botId===c.id?c.patch(x.patch):x.type==="setModel"&&x.botId===c.id?(c.setModel(x.selection),x.resetApprovalToAsk&&c.patch({approvalMode:"ask"})):x.type==="routinePatched"||x.type==="toggleSettings"||l.dispatch(x)}},ie=t?s("newBot.defaults"):s("sidebar.newBot");return e.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/60 p-3 sm:p-5",hidden:!t&&l.state.appSettingsOpen,children:e.jsxs("div",{ref:J,role:"dialog","aria-modal":"true","aria-label":ie,"aria-busy":v,tabIndex:-1,className:"flex h-[min(760px,94dvh)] w-full max-w-[900px] flex-col overflow-hidden rounded-2xl border border-hairline/50 bg-panel shadow-2xl outline-none",children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-hairline/40 px-5 py-4",children:[e.jsx("h2",{className:"text-[17px] font-semibold text-ink",children:ie}),e.jsx("button",{type:"button",onClick:()=>V.current(),"aria-label":s("common.close"),className:"flex size-8 shrink-0 items-center justify-center rounded-lg text-ink-secondary hover:bg-control hover:text-ink disabled:opacity-40",children:e.jsx(ve,{size:18,className:"pointer-events-none"})})]}),F&&!t&&H&&e.jsx(xs,{team:H}),ne&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 pt-3 text-[13px] text-ink-secondary","data-new-bot-visibility":!0,children:[e.jsxs("label",{className:"flex items-center gap-2",children:[s("botSettings.visibility.title"),e.jsxs(M,{size:"sm",value:U,disabled:v,onChange:x=>K(x.target.value),children:[e.jsx("option",{value:"everyone",children:s("botSettings.visibility.everyone")}),e.jsx("option",{value:"admins",children:s("botSettings.visibility.admins")}),e.jsx("option",{value:"people",children:s("botSettings.visibility.people")})]})]}),U==="people"&&e.jsx("input",{value:_,disabled:v,onChange:x=>q(x.target.value),placeholder:s("botSettings.visibility.peoplePlaceholder"),"aria-label":s("botSettings.visibility.peopleLabel"),className:"min-w-[16rem] flex-1 rounded-lg border border-hairline/40 bg-inset px-3 py-1.5 text-[13px] text-ink placeholder:text-ink-secondary focus:outline-none"})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col sm:flex-row",children:[e.jsx("nav",{"aria-label":s("newBot.sections"),className:"flex shrink-0 gap-1 overflow-x-auto border-b border-hairline/40 p-2 sm:w-40 sm:flex-col sm:border-b-0 sm:border-r",children:D.map(x=>e.jsx("button",{type:"button",onClick:()=>w(x),"aria-current":m===x?"page":void 0,className:Q("shrink-0 rounded-lg px-3 py-2 text-left text-[13px]",m===x?"bg-control text-ink":"text-ink-secondary hover:bg-control/50"),children:s(us[x])},x))}),e.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto p-4 sm:p-5",children:[!P&&!f&&e.jsxs("div",{role:"status",className:"flex items-center gap-2 text-[13px] text-ink-secondary",children:[e.jsx(X,{size:16,className:"animate-spin"}),s("newBot.loading")]}),P&&e.jsx("fieldset",{disabled:v,className:"min-w-0",children:e.jsx(wt,{value:Pe,children:e.jsx(jt.Provider,{value:{request:c.request,draft:!0,uploadAvatar:c.uploadAvatar},children:e.jsx(ms,{active:m,draft:c,defaultsMode:t,owner:F&&!t?{value:me(z,W.section,l.state.bots,F),choose:u}:void 0})})})})]})]}),f&&e.jsx("p",{role:"alert",className:"max-h-24 overflow-y-auto border-t border-hairline/40 px-5 py-3 text-[13px] text-danger",children:f}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-hairline/40 px-5 py-3",children:[e.jsx("button",{type:"button",onClick:()=>V.current(),className:"rounded-lg px-4 py-2 text-[13px] text-ink-secondary hover:bg-control",children:s("common.cancel")}),e.jsxs("button",{type:"button",disabled:!P||v||!t&&!W.name.trim(),onClick:()=>{ae()},className:"ui-button-primary flex items-center gap-2 rounded-lg bg-accent px-5 py-2 text-[13px] font-medium text-white hover:brightness-110 disabled:opacity-40",children:[v&&e.jsx(X,{size:15,className:"animate-spin"}),s(t?"newBot.saveDefaults":"newBot.create")]})]}),e.jsx(kt,{open:I==="local",onCancel:()=>$(null),onConfirm:()=>{c.consent.acknowledgeLocalAuto=!0,$(null),ae()}})]})})}function xs({team:t}){const n=typeof window>"u"?void 0:window.ogb?.workspaces;return e.jsxs("div",{"data-new-bot-shared":!0,className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-hairline/40 bg-raised/30 px-5 py-2.5 text-[13px] text-ink-secondary",children:[e.jsx("span",{children:s("newBot.sharedWith",{team:t})}),n?e.jsx("button",{type:"button",onClick:()=>{At(n).catch(()=>{})},className:"font-medium text-accent hover:underline",children:s("newBot.justForYou")}):e.jsx("span",{children:s("newBot.justForYou").replace(/\s*→$/,"")})]})}function ms({active:t,draft:n,defaultsMode:a,owner:i}){const r=n.bot,{state:l}=k(),d=Se(),c=St(r);return t==="Identity"?e.jsxs("div",{className:"space-y-4",children:[e.jsx(gs,{draft:n,defaultsMode:a}),e.jsx(Tt,{bot:r,patch:c.patch,activeState:c.activeState,mascotMotion:null,namePlaceholder:a?s("newBot.randomName"):void 0}),e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.team"),e.jsxs(M,{size:"lg",className:"mt-1.5 w-full",value:r.section??"",onChange:p=>n.patch({section:p.target.value}),children:[e.jsx("option",{value:"",children:s("teamSettings.general")}),[...new Set([...l.sections??[],...l.bots.map(p=>p.section??"")])].filter(Boolean).map(p=>e.jsx("option",{children:p},p))]})]}),i&&d&&e.jsxs("label",{className:"block text-[13px] text-ink-secondary","data-new-bot-reports-to":!0,children:[s("lookedAfter.newBot"),e.jsx(M,{size:"lg",className:"mt-1.5 w-full",value:i.value??"",onChange:p=>i.choose(p.target.value),children:d.people.map(p=>e.jsx("option",{value:p.email,children:p.you?s("owner.you",{name:p.name}):p.name},p.email))}),e.jsx("span",{className:"mt-1 block text-[12px]",children:s("lookedAfter.pickHint")})]})]}):t==="Soul"?e.jsx(Lt,{bot:r,patch:c.patch}):t==="Skills"?e.jsx(Dt,{bot:r}):t==="Memory"?e.jsx(hs,{draft:n}):t==="Routines"?e.jsx(fs,{draft:n}):t==="Access"?e.jsx(Ot,{bot:r,derived:c}):t==="Model"?e.jsx(Mt,{bot:r}):t==="Permissions"?e.jsx(Ut,{bot:r,derived:c}):e.jsx(Ft,{bot:r,derived:c})}function gs({draft:t,defaultsMode:n}){const[a,i]=o.useState([]),[r,l]=o.useState(0),[d,c]=o.useState(""),p=o.useRef(!1);o.useEffect(()=>{if(n)return;let g=!1;return C("/api/bot-presets").then(h=>{g||i(h.presets)}).catch(()=>{g||i([])}),()=>{g=!0}},[n,r]);const m=t.preset?a.find(g=>g.id===t.preset.id):void 0,w=async g=>{c("");const h=g.startsWith("preset:")?a.find(b=>b.id===g.slice(7)):void 0;if(!h){t.choosePreset(void 0);const b=pe.find(f=>f.id===g);t.chooseRole(b?.id);const T=b&&Ne(b.id)?.look;b&&t.patch({...Nt(b),...T});return}t.patch(Gt(h)),t.choosePreset(ts(h));const v=Qt(h);try{v?(t.patch({avatarUrl:await t.uploadAvatar(v),avatarCrop:h.bot.appearance.avatar.crop}),p.current=!0):p.current&&(t.patch({avatarUrl:""}),p.current=!1)}catch(b){c(b instanceof Error?b.message:String(b))}},P=async g=>{c("");try{await C(`/api/bot-presets/${encodeURIComponent(g.id)}`,{method:"DELETE"}),t.preset?.id===g.id&&t.choosePreset(void 0),l(h=>h+1)}catch(h){c(h instanceof Error?h.message:String(h))}},A=pe.map(g=>e.jsx("option",{value:g.id,children:g.title},g.id));return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[13px] text-ink-secondary",children:[s("newBot.startingRole"),e.jsxs(M,{size:"lg",className:"mt-1.5 w-full",value:t.preset?`preset:${t.preset.id}`:"",onChange:g=>{w(g.target.value)},children:[e.jsx("option",{value:"",children:s("newBot.customSettings")}),Zt(a).map(g=>e.jsx("optgroup",{label:g.label,children:g.presets.map(h=>e.jsx("option",{value:`preset:${h.id}`,children:h.name},h.id))},g.label)),a.length?e.jsx("optgroup",{label:s("newBot.builtInRoles"),children:A}):A]})]}),m&&e.jsxs("div",{className:"mt-2 space-y-1 rounded-lg bg-card px-3 py-2.5 text-[13px] text-ink-secondary","data-new-bot-preset":!0,children:[es(m).map((g,h)=>e.jsx("p",{className:"break-words",children:g},h)),m.source==="file"&&e.jsx("button",{type:"button",onClick:()=>{P(m)},className:"mt-1 rounded-md px-2 py-1 text-[12px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.presetRemove")})]}),d&&e.jsx("p",{role:"alert",className:"mt-2 text-[13px] text-danger",children:d})]})}function hs({draft:t}){const[n,a]=o.useState("MEMORY.md"),[i,r]=o.useState("");return e.jsxs("div",{className:"space-y-3",children:[e.jsx(M,{size:"lg",className:"w-full","aria-label":s("memory.fileLabel",{path:n}),value:n,onChange:l=>a(l.target.value),children:[...new Set(["MEMORY.md",...Object.keys(t.template.memory)])].map(l=>e.jsx("option",{children:l},l))}),e.jsx("textarea",{className:Q(ge,"min-h-72 font-mono"),"aria-label":s("memory.contents"),value:t.template.memory[n]??"",onChange:l=>t.setMemory(n,l.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:ge,"aria-label":s("memory.newTopicLabel"),placeholder:s("memory.newTopicLabel"),value:i,onChange:l=>r(l.target.value)}),e.jsx("button",{type:"button","aria-label":s("memory.addTopic"),disabled:!/^[a-zA-Z0-9_-]+$/.test(i),className:"rounded-lg bg-control px-3 disabled:opacity-40",onClick:()=>{const l=`memory/${i}.md`;l in t.template.memory||t.setMemory(l,""),a(l),r("")},children:e.jsx(Vt,{size:16})}),n!=="MEMORY.md"&&e.jsx("button",{type:"button","aria-label":s("memory.removeTopic"),className:"rounded-lg bg-control px-3",onClick:()=>{t.setMemory(n,null),a("MEMORY.md")},children:e.jsx(Ce,{size:16})})]})]})}function fs({draft:t}){const[n,a]=o.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{type:"button",className:"rounded-lg bg-accent px-3 py-2 text-[13px] text-white",onClick:()=>a("new"),children:s("computer.routines.create")}),t.routines.map(i=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-card p-3",children:[e.jsx("button",{type:"button",className:"min-w-0 flex-1 text-left text-[13px]",onClick:()=>a(i),children:i.name}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[12px] text-ink-secondary",children:[e.jsx("input",{type:"checkbox",checked:i.enabled,onChange:r=>t.setRoutineEnabled(i.id,r.target.checked)}),s("newBot.enabled")]}),e.jsx("button",{type:"button","aria-label":s("newBot.removeRoutine",{name:i.name}),onClick:()=>t.removeRoutine(i.id),className:"rounded p-1.5 hover:bg-control",children:e.jsx(Ce,{size:15})})]},i.id)),n&&e.jsx(It,{routine:n==="new"?void 0:n,bots:[t.bot],lockedBotId:t.id,onClose:()=>a(null)})]})}function bs({simple:t=!1}){const[n,a]=o.useState(!1),[i,r]=o.useState(!1),l=e.jsxs(e.Fragment,{children:[n&&e.jsx(Re,{defaultsMode:!0,onClose:()=>a(!1)}),i&&e.jsx(ss,{onClose:()=>r(!1)})]});if(t)return e.jsxs(e.Fragment,{children:[e.jsx(cs,{onEdit:()=>a(!0),onShare:()=>r(!0)}),l]});const d=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!0),className:"cursor-pointer rounded-lg px-3 py-1.5 text-[13px] text-ink-secondary hover:bg-control hover:text-ink",children:s("newBot.sharePreset")}),e.jsx("button",{type:"button",onClick:()=>a(!0),className:"cursor-pointer rounded-lg bg-control px-3 py-1.5 text-[13px] text-ink hover:bg-raised-hover",children:s("newBot.edit")})]}),l]});return e.jsx(y,{title:s("newBot.defaults"),children:d})}const Vs=Object.freeze(Object.defineProperty({__proto__:null,DefaultBotSettings:bs,NewBotDialog:Re},Symbol.toStringTag,{value:"Module"}));export{Us as A,Bs as B,Ms as C,bs as D,$s as E,Os as F,Ls as L,As as N,zs as P,Ts as R,Rs as S,_s as T,Ps as U,Hs as a,Ds as b,Fs as c,Ks as d,Is as e,Vs as f};
|