@captain-app/openclaw 2026.2.4
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/CHANGELOG.md +1528 -0
- package/LICENSE +21 -0
- package/README-header.png +0 -0
- package/README.md +539 -0
- package/assets/avatar-placeholder.svg +19 -0
- package/assets/chrome-extension/README.md +22 -0
- package/assets/chrome-extension/background.js +438 -0
- package/assets/chrome-extension/icons/icon128.png +0 -0
- package/assets/chrome-extension/icons/icon16.png +0 -0
- package/assets/chrome-extension/icons/icon32.png +0 -0
- package/assets/chrome-extension/icons/icon48.png +0 -0
- package/assets/chrome-extension/manifest.json +25 -0
- package/assets/chrome-extension/options.html +196 -0
- package/assets/chrome-extension/options.js +59 -0
- package/assets/dmg-background-small.png +0 -0
- package/assets/dmg-background.png +0 -0
- package/dist/accounts-ClnuDahN.js +250 -0
- package/dist/accounts-DzBgAM3C.js +251 -0
- package/dist/acp-cli-BEDDkzXH.js +926 -0
- package/dist/acp-cli-CwV4mdnW.js +923 -0
- package/dist/agent-CArjbSeE.js +695 -0
- package/dist/agent-CB7x5HLT.js +695 -0
- package/dist/agent-scope-BbT4OG2N.js +545 -0
- package/dist/agent-scope-C_O6Vpl0.js +545 -0
- package/dist/agent-scope-Csu2B6AM.js +606 -0
- package/dist/archive-CWrnG1CH.js +85 -0
- package/dist/archive-ccN9aDgq.js +85 -0
- package/dist/audit-DXPkQ275.js +1686 -0
- package/dist/audit-eH7nwgsM.js +1686 -0
- package/dist/auth-health-Bj7Gjbv0.js +149 -0
- package/dist/auth-health-CjjJhHey.js +149 -0
- package/dist/auth-nnRYiqpH.js +192 -0
- package/dist/auth-profiles-DVLfuixr.js +2954 -0
- package/dist/auth-y1BLPUhX.js +192 -0
- package/dist/boolean-Wzu0-e0P.js +30 -0
- package/dist/brew-Cqi8b49_.js +46 -0
- package/dist/brew-DyBGNK8A.js +46 -0
- package/dist/build-info.json +5 -0
- package/dist/call-B7EveN4V.js +252 -0
- package/dist/call-vuUQIjOj.js +252 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17780 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/channel-options-CJfmOkol.js +32 -0
- package/dist/channel-options-lFguMTz1.js +62 -0
- package/dist/channel-selection-BmND9mWj.js +51 -0
- package/dist/channel-selection-cGhL9G0c.js +51 -0
- package/dist/channel-summary-B4G513Eb.js +1154 -0
- package/dist/channel-summary-MCwBCa5y.js +1154 -0
- package/dist/channels-cli-C2Of1mZG.js +1411 -0
- package/dist/channels-cli-DFynrP1H.js +1413 -0
- package/dist/channels-status-issues-YohTjZ-I.js +18 -0
- package/dist/channels-status-issues-ZcR1U-m5.js +18 -0
- package/dist/chrome-B3IuUad-.js +1953 -0
- package/dist/chrome-BZ9K48w9.js +1973 -0
- package/dist/clack-prompter-B9yLhyOm.js +92 -0
- package/dist/clack-prompter-BybM9xdL.js +92 -0
- package/dist/cli/daemon-cli.js +2 -0
- package/dist/cli-BJZdJwug.js +89 -0
- package/dist/cli-BQSoKu3d.js +86 -0
- package/dist/cli-utils-CO4jEMn0.js +43 -0
- package/dist/cli-utils-gtE-0a0D.js +43 -0
- package/dist/client-DPqNOpK3.js +1609 -0
- package/dist/client-DySXIFCA.js +1609 -0
- package/dist/command-format-CFzL448l.js +52 -0
- package/dist/command-format-DELazozB.js +52 -0
- package/dist/command-format-ayFsmwwz.js +38 -0
- package/dist/command-options-CsjxK4cZ.js +33 -0
- package/dist/commands-BRe9VTyU.js +229 -0
- package/dist/completion-cli-DlkjK0iC.js +390 -0
- package/dist/completion-cli-E6Pt41AL.js +387 -0
- package/dist/config-BtSTwPcH.js +4882 -0
- package/dist/config-DfMIMT-f.js +4881 -0
- package/dist/config-_d7_WcRv.js +5623 -0
- package/dist/config-guard-wSnm-U8a.js +5628 -0
- package/dist/configure-CPHAFKlg.js +895 -0
- package/dist/configure-DK1XgXYx.js +894 -0
- package/dist/constants-CNTiY-ZN.js +65 -0
- package/dist/constants-hpmbslG7.js +65 -0
- package/dist/control-service-CqX5g_ko.js +61 -0
- package/dist/control-service-o6xe3hEb.js +61 -0
- package/dist/control-ui/apple-touch-icon.png +0 -0
- package/dist/control-ui/assets/index-RwcW4Xl0.css +1 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js +4584 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js.map +1 -0
- package/dist/control-ui/favicon-32.png +0 -0
- package/dist/control-ui/favicon.ico +0 -0
- package/dist/control-ui/favicon.svg +22 -0
- package/dist/control-ui/index.html +17 -0
- package/dist/cron-cli-BoSaDgvH.js +453 -0
- package/dist/cron-cli-qVandvsD.js +456 -0
- package/dist/daemon-cli-C4gGWa15.js +760 -0
- package/dist/daemon-cli-DV_X0Krf.js +761 -0
- package/dist/daemon-runtime-D5hbSrdO.js +460 -0
- package/dist/daemon-runtime-DXUfrXBC.js +460 -0
- package/dist/deliver-BxK5nI2P.js +2587 -0
- package/dist/deliver-Dwzg9LUd.js +2557 -0
- package/dist/deliver-qpYZp20m.js +2587 -0
- package/dist/deps-CUXtMV9d.js +27 -0
- package/dist/deps-WBvZpFV_.js +27 -0
- package/dist/devices-cli-B2s18Qrh.js +207 -0
- package/dist/devices-cli-D1UEtMUJ.js +204 -0
- package/dist/directory-cli-BXQbrkfM.js +247 -0
- package/dist/directory-cli-CqA7tRbq.js +244 -0
- package/dist/dispatcher-Dyv7T-1r.js +160 -0
- package/dist/dns-cli-CWxKD22D.js +198 -0
- package/dist/dns-cli-CzKr_Fxj.js +201 -0
- package/dist/docs-cli-BNyxUbWr.js +159 -0
- package/dist/docs-cli-DYpTbo3i.js +161 -0
- package/dist/doctor-C8fDYZLq.js +2583 -0
- package/dist/doctor-hYcqp7c0.js +2585 -0
- package/dist/entry.js +1326 -0
- package/dist/env-l7QVNj6j.js +32 -0
- package/dist/errors-CMCg46fK.js +1952 -0
- package/dist/exec-B8JKbXKW.js +246 -0
- package/dist/exec-BMnoMcZW.js +1099 -0
- package/dist/exec-HEWTMJ7j.js +246 -0
- package/dist/exec-approvals-DtrnHx6M.js +1026 -0
- package/dist/exec-approvals-Y42bE8ud.js +1026 -0
- package/dist/exec-approvals-cli-CIedYxP3.js +385 -0
- package/dist/exec-approvals-cli-xpbxnj4O.js +388 -0
- package/dist/extensionAPI.js +66572 -0
- package/dist/format-Dzy9uRLE.js +34 -0
- package/dist/format-sj0fELBK.js +34 -0
- package/dist/gateway-cli-5A-KNLEC.js +16635 -0
- package/dist/gateway-cli-B8kS4chb.js +16637 -0
- package/dist/gateway-rpc-15n38Ize.js +28 -0
- package/dist/gateway-rpc-TMVRgGfj.js +28 -0
- package/dist/github-copilot-auth-DVZj4Zgh.js +1104 -0
- package/dist/github-copilot-auth-DeGYyLY9.js +1104 -0
- package/dist/github-copilot-token-B3SA95yo.js +103 -0
- package/dist/github-copilot-token-C8XFYz0i.js +103 -0
- package/dist/github-copilot-token-CnxakiSC.js +103 -0
- package/dist/gmail-setup-utils-CWPC386a.js +428 -0
- package/dist/gmail-setup-utils-eJVB5Ewp.js +428 -0
- package/dist/health-format-B0tMTk3C.js +1189 -0
- package/dist/health-format-DaURVaUn.js +1188 -0
- package/dist/help-format-CEsRHU2f.js +17 -0
- package/dist/help-format-GuCWws6r.js +17 -0
- package/dist/helpers-BEJ-phFf.js +25 -0
- package/dist/helpers-BtbBZVKZ.js +10 -0
- package/dist/helpers-C12w9zxf.js +10 -0
- package/dist/helpers-CzjGJZmJ.js +25 -0
- package/dist/hooks/bundled/boot-md/HOOK.md +19 -0
- package/dist/hooks/bundled/command-logger/HOOK.md +122 -0
- package/dist/hooks/bundled/session-memory/HOOK.md +109 -0
- package/dist/hooks/bundled/soul-evil/HOOK.md +71 -0
- package/dist/hooks-cli-BZCMAnW2.js +1058 -0
- package/dist/hooks-cli-D0CEFg3P.js +1061 -0
- package/dist/hooks-status-Bn7_O8PM.js +443 -0
- package/dist/hooks-status-BrWVfIn0.js +443 -0
- package/dist/image-BS022pvv.js +1421 -0
- package/dist/image-BzJtY34J.js +629 -0
- package/dist/image-CBqmIbQQ.js +629 -0
- package/dist/index.js +5809 -0
- package/dist/installs-BP4K5L33.js +388 -0
- package/dist/installs-DOpTt7VZ.js +388 -0
- package/dist/is-main-B4o72sqg.js +25 -0
- package/dist/is-main-PYGa3tDA.js +25 -0
- package/dist/links-B4nk2iDf.js +15 -0
- package/dist/links-DwjRqxgR.js +15 -0
- package/dist/loader-Cn4EV_pf.js +63690 -0
- package/dist/logging-CS3tbYDj.js +15 -0
- package/dist/logging-CY-Q5cwf.js +1 -0
- package/dist/logging-DhiLkhLw.js +15 -0
- package/dist/logging-pqyrk15z.js +1 -0
- package/dist/login-qr-CD164Aw1.js +478 -0
- package/dist/login-qr-D7Zdgji2.js +478 -0
- package/dist/login-qr-YgILJ4VC.js +475 -0
- package/dist/logs-cli-BdS0Uv0I.js +227 -0
- package/dist/logs-cli-CqSN1GzB.js +230 -0
- package/dist/manager-CfGY5zND.js +2870 -0
- package/dist/manager-CjuBqFRL.js +2870 -0
- package/dist/manager-CoBEAQKm.js +2872 -0
- package/dist/manifest-registry-Bwjq9Iev.js +668 -0
- package/dist/manifest-registry-D2Yntqcb.js +668 -0
- package/dist/message-channel-Cjsiqxok.js +105 -0
- package/dist/message-channel-D6v_oPAg.js +105 -0
- package/dist/model-selection-Cv5Ox_tY.js +2956 -0
- package/dist/model-selection-Dr-5U5-l.js +2708 -0
- package/dist/models-cli-B39ckynD.js +2541 -0
- package/dist/models-cli-DoiYsBYw.js +2544 -0
- package/dist/net-CFCxaipF.js +137 -0
- package/dist/net-DKJPqXuW.js +137 -0
- package/dist/node-cli-C_FYF-RA.js +1456 -0
- package/dist/node-cli-DWPoNsQS.js +1459 -0
- package/dist/node-service-DcJREOww.js +67 -0
- package/dist/node-service-DuZ9Us9h.js +67 -0
- package/dist/nodes-cli-Elo6tlen.js +1210 -0
- package/dist/nodes-cli-zqryRUWB.js +1207 -0
- package/dist/nodes-screen-C4aCrxie.js +157 -0
- package/dist/nodes-screen-D4PSynkR.js +157 -0
- package/dist/note-CQhSvgQv.js +73 -0
- package/dist/note-_C44YfAQ.js +73 -0
- package/dist/onboard-channels-CHBDi-ZA.js +670 -0
- package/dist/onboard-channels-DOEKyxaL.js +670 -0
- package/dist/onboard-skills-BUTXREDZ.js +3327 -0
- package/dist/onboard-skills-CSLYZmZA.js +3327 -0
- package/dist/onboarding-CgKb8b39.js +3232 -0
- package/dist/openclaw-root-9ILYSmJ9.js +84 -0
- package/dist/openclaw-root-Cvotktkd.js +84 -0
- package/dist/pairing-cli-B4UGR2at.js +114 -0
- package/dist/pairing-cli-BWDDl8cf.js +117 -0
- package/dist/pairing-labels-ClZ-fTWT.js +9 -0
- package/dist/pairing-labels-Ds7BPOkj.js +9 -0
- package/dist/pairing-store-DDLNuzmx.js +391 -0
- package/dist/pairing-store-DRn08lZD.js +391 -0
- package/dist/parse-87ybtYW1.js +23 -0
- package/dist/parse-OCFfznr3.js +23 -0
- package/dist/parse-log-line-C9aL5PUL.js +44 -0
- package/dist/parse-log-line-DxRaGzQb.js +44 -0
- package/dist/parse-timeout-CFqNj7No.js +16 -0
- package/dist/parse-timeout-DV8NQQWk.js +16 -0
- package/dist/path-env-C7kiJUgG.js +77 -0
- package/dist/path-env-DEj4CiFN.js +77 -0
- package/dist/paths-B-q1nXdY.js +43 -0
- package/dist/paths-B1kfl4h5.js +164 -0
- package/dist/paths-B4kigINg.js +40 -0
- package/dist/paths-CHGbP1-A.js +43 -0
- package/dist/paths-scjhy7N2.js +180 -0
- package/dist/pi-embedded-helpers-C19wUpMB.js +8451 -0
- package/dist/pi-embedded-helpers-CT5VuLCb.js +1293 -0
- package/dist/pi-embedded-helpers-Dl8e5Rf8.js +1293 -0
- package/dist/pi-model-discovery-B6CsmK6Y.js +20 -0
- package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
- package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
- package/dist/pi-tools.policy-BvkSDFDN.js +229 -0
- package/dist/plugin-auto-enable-Bd_StZzz.js +461 -0
- package/dist/plugin-auto-enable-DBhXb_0x.js +461 -0
- package/dist/plugin-sdk/agent-scope-DdwUKIOe.js +606 -0
- package/dist/plugin-sdk/chrome-G8apFa5p.js +1953 -0
- package/dist/plugin-sdk/command-format-qUVxzqYm.js +52 -0
- package/dist/plugin-sdk/config-Cm1M7tgH.js +5623 -0
- package/dist/plugin-sdk/deliver-Cl8uowiO.js +2557 -0
- package/dist/plugin-sdk/exec-Cm9b2r9Q.js +1107 -0
- package/dist/plugin-sdk/github-copilot-token-BHNcM4_B.js +103 -0
- package/dist/plugin-sdk/image-7PgoS2VD.js +1421 -0
- package/dist/plugin-sdk/index.d.ts +8908 -0
- package/dist/plugin-sdk/index.js +70888 -0
- package/dist/plugin-sdk/login-qr-qTALvWi2.js +475 -0
- package/dist/plugin-sdk/manager-Cs3EQZCb.js +2870 -0
- package/dist/plugin-sdk/model-selection-BgC1E1a7.js +2708 -0
- package/dist/plugin-sdk/paths-BYpoyRv5.js +164 -0
- package/dist/plugin-sdk/paths-DNQE-bvr.js +40 -0
- package/dist/plugin-sdk/pi-embedded-helpers-5jNqW_dE.js +8755 -0
- package/dist/plugin-sdk/pi-model-discovery-BUGEht9A.js +20 -0
- package/dist/plugin-sdk/pw-ai-COTtei4a.js +1649 -0
- package/dist/plugin-sdk/qmd-manager-ClSwiAJl.js +615 -0
- package/dist/plugin-sdk/redact-2AzjOfk2.js +94 -0
- package/dist/plugin-sdk/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/plugin-sdk/sqlite-gCW7MlLs.js +215 -0
- package/dist/plugin-sdk/transcript-events-DGF257vD.js +17 -0
- package/dist/plugins-C3Bm-HQV.js +494 -0
- package/dist/plugins-QJjTXliB.js +495 -0
- package/dist/plugins-cli-DTci0JQb.js +443 -0
- package/dist/plugins-cli-wJsN1HHK.js +440 -0
- package/dist/ports-CiW9dmMq.js +96 -0
- package/dist/program-BWpTHh1I.js +188 -0
- package/dist/progress-Bcjniu7m.js +133 -0
- package/dist/progress-CvaSPjS9.js +133 -0
- package/dist/prompt-style-CFsleyxV.js +9 -0
- package/dist/prompt-style-DYJdrXyV.js +9 -0
- package/dist/prompts-Bt9fwsg2.js +10 -0
- package/dist/prompts-CudpZgTI.js +10 -0
- package/dist/pw-ai-08F3GD-3.js +1649 -0
- package/dist/pw-ai-ZmHxHQnx.js +1651 -0
- package/dist/pw-ai-tNPuRNn3.js +1649 -0
- package/dist/qmd-manager-2r-4n3sP.js +617 -0
- package/dist/qmd-manager-CF52nuBg.js +615 -0
- package/dist/qmd-manager-HEm5H2mk.js +616 -0
- package/dist/redact-BICFkpn7.js +97 -0
- package/dist/redact-BIMJ3ntQ.js +94 -0
- package/dist/redact-KzWHRS5J.js +97 -0
- package/dist/register.subclis-D2K25c84.js +348 -0
- package/dist/register.subclis-Dd8LbOLi.js +342 -0
- package/dist/reply-5UNWRwMn.js +63693 -0
- package/dist/restart-sentinel-Cr0vUxB8.js +65 -0
- package/dist/restart-sentinel-DUemCjgU.js +65 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-C6UpTPas.js +2410 -0
- package/dist/routes-ClNyEvlm.js +2410 -0
- package/dist/rpc-D0mf7DIw.js +95 -0
- package/dist/rpc-DYdOrgd9.js +95 -0
- package/dist/run-main-CojI7gWx.js +194 -0
- package/dist/runtime-guard-68M_evhb.js +60 -0
- package/dist/runtime-guard-DkjmhnBD.js +60 -0
- package/dist/sandbox-Ca81z3Tw.js +2924 -0
- package/dist/sandbox-cli-D75GApgp.js +459 -0
- package/dist/sandbox-cli-E4SJsC1C.js +462 -0
- package/dist/sandbox-knontqD9.js +2925 -0
- package/dist/security-cli-BLihvXO-.js +503 -0
- package/dist/security-cli-IGQCsK4g.js +506 -0
- package/dist/server-context-B9GX5GOI.js +740 -0
- package/dist/server-context-BFH7HB_M.js +740 -0
- package/dist/server-node-events-CTdHBiEA.js +218 -0
- package/dist/server-node-events-DAV14qPr.js +215 -0
- package/dist/service-BZNBq9hq.js +680 -0
- package/dist/service-C-BLXx9U.js +680 -0
- package/dist/service-audit-BfJv4NqZ.js +542 -0
- package/dist/service-audit-Bw3M2OEI.js +542 -0
- package/dist/shared-5SH-45AX.js +74 -0
- package/dist/shared-BxRm5uLU.js +74 -0
- package/dist/shared-C80Rmxsd.js +150 -0
- package/dist/shared-fGK6_D2v.js +150 -0
- package/dist/skills-Bhp0l6UK.js +693 -0
- package/dist/skills-Tky2kCMO.js +694 -0
- package/dist/skills-cli-6rCClAE4.js +287 -0
- package/dist/skills-cli-C4nLCrLw.js +290 -0
- package/dist/skills-status-CENcKr3I.js +187 -0
- package/dist/skills-status-DX1eUYvk.js +187 -0
- package/dist/sqlite-CmdZSZRx.js +197 -0
- package/dist/sqlite-Dnmf3LS7.js +215 -0
- package/dist/sqlite-QDf0yuU0.js +215 -0
- package/dist/status-BSfGAp2D.js +27 -0
- package/dist/status-Bp_2NMjt.js +27 -0
- package/dist/status-C0ANDr0T.js +3140 -0
- package/dist/status-CCHBIZnm.js +21 -0
- package/dist/status-Vuqbw2Bb.js +21 -0
- package/dist/status.update-BZW5r8Su.js +79 -0
- package/dist/status.update-BnD93_O8.js +79 -0
- package/dist/subsystem-CAq3uyo7.js +834 -0
- package/dist/system-cli-Bb9zmCO1.js +83 -0
- package/dist/system-cli-TIIQ04ls.js +80 -0
- package/dist/systemd-0Qa_nGqe.js +438 -0
- package/dist/systemd-Czb0Xsm7.js +438 -0
- package/dist/systemd-hints-CWoEOQRb.js +19 -0
- package/dist/systemd-hints-Cv3RN_mZ.js +19 -0
- package/dist/systemd-linger-CsdvcIoS.js +75 -0
- package/dist/systemd-linger-DKUFHcLn.js +75 -0
- package/dist/table-DNPESyNj.js +279 -0
- package/dist/table-DS4-gmkV.js +279 -0
- package/dist/tailnet-Bg_vE5qi.js +42 -0
- package/dist/tailnet-CrNWlQRJ.js +42 -0
- package/dist/tailscale-CBv58toW.js +252 -0
- package/dist/tailscale-DCnMs7_q.js +225 -0
- package/dist/tool-display-BEACy9rK.js +795 -0
- package/dist/tool-display-NYQnSpdo.js +795 -0
- package/dist/transcript-events-CsB1Saa6.js +17 -0
- package/dist/transcript-events-DDYvbmRV.js +17 -0
- package/dist/transcript-events-JLH5W4He.js +17 -0
- package/dist/tui--NY0rnjr.js +2542 -0
- package/dist/tui-DqJfGtvM.js +2543 -0
- package/dist/tui-cli-BuHNY6wF.js +54 -0
- package/dist/tui-cli-LMFV982e.js +57 -0
- package/dist/update-CRpHtCgz.js +317 -0
- package/dist/update-D3qruxhj.js +317 -0
- package/dist/update-cli-CFF-pslM.js +948 -0
- package/dist/update-cli-cn9pEMX7.js +951 -0
- package/dist/update-runner-CxGU142L.js +1221 -0
- package/dist/update-runner-DNobz_ft.js +1221 -0
- package/dist/utils-CKSrBNwq.js +192 -0
- package/dist/utils-DX85MiPR.js +188 -0
- package/dist/webhooks-cli-BGtt2HAR.js +312 -0
- package/dist/webhooks-cli-DHLZrEO_.js +309 -0
- package/dist/widearea-dns-BpG7ATO8.js +127 -0
- package/dist/widearea-dns-D4wkCJly.js +127 -0
- package/dist/ws-3zr8WUwL.js +13 -0
- package/dist/ws-log-BXcT2xQk.js +267 -0
- package/dist/ws-log-DbDIUsgz.js +267 -0
- package/dist/ws-lzrgabja.js +13 -0
- package/dist/wsl-D2O2qOrl.js +160 -0
- package/docs/.i18n/README.md +31 -0
- package/docs/.i18n/glossary.zh-CN.json +190 -0
- package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
- package/docs/CNAME +1 -0
- package/docs/_config.yml +53 -0
- package/docs/_layouts/default.html +145 -0
- package/docs/assets/markdown.css +179 -0
- package/docs/assets/openclaw-logo-text-dark.png +0 -0
- package/docs/assets/openclaw-logo-text.png +0 -0
- package/docs/assets/pixel-lobster.svg +60 -0
- package/docs/assets/showcase/agents-ui.jpg +0 -0
- package/docs/assets/showcase/bambu-cli.png +0 -0
- package/docs/assets/showcase/codexmonitor.png +0 -0
- package/docs/assets/showcase/gohome-grafana.png +0 -0
- package/docs/assets/showcase/ios-testflight.jpg +0 -0
- package/docs/assets/showcase/oura-health.png +0 -0
- package/docs/assets/showcase/padel-cli.svg +11 -0
- package/docs/assets/showcase/padel-screenshot.jpg +0 -0
- package/docs/assets/showcase/papla-tts.jpg +0 -0
- package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
- package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
- package/docs/assets/showcase/roborock-status.svg +13 -0
- package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
- package/docs/assets/showcase/snag.png +0 -0
- package/docs/assets/showcase/tesco-shop.jpg +0 -0
- package/docs/assets/showcase/wienerlinien.png +0 -0
- package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
- package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
- package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
- package/docs/assets/terminal.css +473 -0
- package/docs/assets/theme.js +55 -0
- package/docs/automation/auth-monitoring.md +44 -0
- package/docs/automation/cron-jobs.md +468 -0
- package/docs/automation/cron-vs-heartbeat.md +282 -0
- package/docs/automation/gmail-pubsub.md +256 -0
- package/docs/automation/poll.md +69 -0
- package/docs/automation/webhook.md +163 -0
- package/docs/bedrock.md +176 -0
- package/docs/brave-search.md +41 -0
- package/docs/broadcast-groups.md +442 -0
- package/docs/channels/bluebubbles.md +338 -0
- package/docs/channels/discord.md +475 -0
- package/docs/channels/feishu.md +507 -0
- package/docs/channels/googlechat.md +250 -0
- package/docs/channels/grammy.md +31 -0
- package/docs/channels/imessage.md +299 -0
- package/docs/channels/index.md +46 -0
- package/docs/channels/line.md +186 -0
- package/docs/channels/location.md +56 -0
- package/docs/channels/matrix.md +233 -0
- package/docs/channels/mattermost.md +138 -0
- package/docs/channels/msteams.md +768 -0
- package/docs/channels/nextcloud-talk.md +136 -0
- package/docs/channels/nostr.md +233 -0
- package/docs/channels/signal.md +202 -0
- package/docs/channels/slack.md +548 -0
- package/docs/channels/telegram.md +750 -0
- package/docs/channels/tlon.md +132 -0
- package/docs/channels/troubleshooting.md +29 -0
- package/docs/channels/twitch.md +379 -0
- package/docs/channels/whatsapp.md +404 -0
- package/docs/channels/zalo.md +189 -0
- package/docs/channels/zalouser.md +140 -0
- package/docs/cli/acp.md +170 -0
- package/docs/cli/agent.md +24 -0
- package/docs/cli/agents.md +75 -0
- package/docs/cli/approvals.md +50 -0
- package/docs/cli/browser.md +107 -0
- package/docs/cli/channels.md +79 -0
- package/docs/cli/config.md +50 -0
- package/docs/cli/configure.md +33 -0
- package/docs/cli/cron.md +42 -0
- package/docs/cli/dashboard.md +16 -0
- package/docs/cli/devices.md +67 -0
- package/docs/cli/directory.md +63 -0
- package/docs/cli/dns.md +23 -0
- package/docs/cli/docs.md +15 -0
- package/docs/cli/doctor.md +41 -0
- package/docs/cli/gateway.md +199 -0
- package/docs/cli/health.md +21 -0
- package/docs/cli/hooks.md +304 -0
- package/docs/cli/index.md +1029 -0
- package/docs/cli/logs.md +24 -0
- package/docs/cli/memory.md +45 -0
- package/docs/cli/message.md +239 -0
- package/docs/cli/models.md +79 -0
- package/docs/cli/node.md +112 -0
- package/docs/cli/nodes.md +73 -0
- package/docs/cli/onboard.md +29 -0
- package/docs/cli/pairing.md +21 -0
- package/docs/cli/plugins.md +62 -0
- package/docs/cli/reset.md +17 -0
- package/docs/cli/sandbox.md +152 -0
- package/docs/cli/security.md +26 -0
- package/docs/cli/sessions.md +16 -0
- package/docs/cli/setup.md +29 -0
- package/docs/cli/skills.md +26 -0
- package/docs/cli/status.md +26 -0
- package/docs/cli/system.md +60 -0
- package/docs/cli/tui.md +23 -0
- package/docs/cli/uninstall.md +17 -0
- package/docs/cli/update.md +98 -0
- package/docs/cli/voicecall.md +34 -0
- package/docs/cli/webhooks.md +25 -0
- package/docs/concepts/agent-loop.md +146 -0
- package/docs/concepts/agent-workspace.md +233 -0
- package/docs/concepts/agent.md +123 -0
- package/docs/concepts/architecture.md +129 -0
- package/docs/concepts/channel-routing.md +114 -0
- package/docs/concepts/compaction.md +61 -0
- package/docs/concepts/context.md +161 -0
- package/docs/concepts/group-messages.md +84 -0
- package/docs/concepts/groups.md +373 -0
- package/docs/concepts/markdown-formatting.md +130 -0
- package/docs/concepts/memory.md +546 -0
- package/docs/concepts/messages.md +154 -0
- package/docs/concepts/model-failover.md +149 -0
- package/docs/concepts/model-providers.md +316 -0
- package/docs/concepts/models.md +208 -0
- package/docs/concepts/multi-agent.md +376 -0
- package/docs/concepts/oauth.md +145 -0
- package/docs/concepts/presence.md +102 -0
- package/docs/concepts/queue.md +89 -0
- package/docs/concepts/retry.md +69 -0
- package/docs/concepts/session-pruning.md +122 -0
- package/docs/concepts/session-tool.md +193 -0
- package/docs/concepts/session.md +188 -0
- package/docs/concepts/sessions.md +10 -0
- package/docs/concepts/streaming.md +135 -0
- package/docs/concepts/system-prompt.md +115 -0
- package/docs/concepts/timezone.md +91 -0
- package/docs/concepts/typebox.md +289 -0
- package/docs/concepts/typing-indicators.md +68 -0
- package/docs/concepts/usage-tracking.md +35 -0
- package/docs/date-time.md +128 -0
- package/docs/debug/node-issue.md +83 -0
- package/docs/debugging.md +162 -0
- package/docs/diagnostics/flags.md +91 -0
- package/docs/docs.json +1587 -0
- package/docs/environment.md +81 -0
- package/docs/experiments/onboarding-config-protocol.md +40 -0
- package/docs/experiments/plans/cron-add-hardening.md +63 -0
- package/docs/experiments/plans/group-policy-hardening.md +40 -0
- package/docs/experiments/plans/openresponses-gateway.md +123 -0
- package/docs/experiments/proposals/model-config.md +36 -0
- package/docs/experiments/research/memory.md +228 -0
- package/docs/gateway/authentication.md +145 -0
- package/docs/gateway/background-process.md +93 -0
- package/docs/gateway/bonjour.md +167 -0
- package/docs/gateway/bridge-protocol.md +89 -0
- package/docs/gateway/cli-backends.md +223 -0
- package/docs/gateway/configuration-examples.md +606 -0
- package/docs/gateway/configuration.md +3393 -0
- package/docs/gateway/discovery.md +116 -0
- package/docs/gateway/doctor.md +282 -0
- package/docs/gateway/gateway-lock.md +34 -0
- package/docs/gateway/health.md +35 -0
- package/docs/gateway/heartbeat.md +302 -0
- package/docs/gateway/index.md +328 -0
- package/docs/gateway/local-models.md +150 -0
- package/docs/gateway/logging.md +113 -0
- package/docs/gateway/multiple-gateways.md +112 -0
- package/docs/gateway/openai-http-api.md +118 -0
- package/docs/gateway/openresponses-http-api.md +317 -0
- package/docs/gateway/pairing.md +99 -0
- package/docs/gateway/protocol.md +221 -0
- package/docs/gateway/remote-gateway-readme.md +157 -0
- package/docs/gateway/remote.md +127 -0
- package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +128 -0
- package/docs/gateway/sandboxing.md +193 -0
- package/docs/gateway/security/formal-verification.md +164 -0
- package/docs/gateway/security/index.md +825 -0
- package/docs/gateway/tailscale.md +127 -0
- package/docs/gateway/tools-invoke-http-api.md +85 -0
- package/docs/gateway/troubleshooting.md +767 -0
- package/docs/help/faq.md +2830 -0
- package/docs/help/index.md +21 -0
- package/docs/help/troubleshooting.md +98 -0
- package/docs/hooks/soul-evil.md +69 -0
- package/docs/hooks.md +913 -0
- package/docs/images/feishu-step2-create-app.png +0 -0
- package/docs/images/feishu-step3-credentials.png +0 -0
- package/docs/images/feishu-step4-permissions.png +0 -0
- package/docs/images/feishu-step5-bot-capability.png +0 -0
- package/docs/images/feishu-step6-event-subscription.png +0 -0
- package/docs/images/groups-flow.svg +52 -0
- package/docs/images/mobile-ui-screenshot.png +0 -0
- package/docs/index.md +258 -0
- package/docs/install/ansible.md +208 -0
- package/docs/install/bun.md +59 -0
- package/docs/install/development-channels.md +75 -0
- package/docs/install/docker.md +567 -0
- package/docs/install/index.md +185 -0
- package/docs/install/installer.md +123 -0
- package/docs/install/migrating.md +192 -0
- package/docs/install/nix.md +96 -0
- package/docs/install/node.md +78 -0
- package/docs/install/uninstall.md +128 -0
- package/docs/install/updating.md +228 -0
- package/docs/logging.md +350 -0
- package/docs/multi-agent-sandbox-tools.md +395 -0
- package/docs/network.md +54 -0
- package/docs/nodes/audio.md +114 -0
- package/docs/nodes/camera.md +156 -0
- package/docs/nodes/images.md +72 -0
- package/docs/nodes/index.md +341 -0
- package/docs/nodes/location-command.md +113 -0
- package/docs/nodes/media-understanding.md +379 -0
- package/docs/nodes/talk.md +90 -0
- package/docs/nodes/voicewake.md +65 -0
- package/docs/northflank.mdx +53 -0
- package/docs/perplexity.md +80 -0
- package/docs/pi-dev.md +70 -0
- package/docs/pi.md +612 -0
- package/docs/platforms/android.md +148 -0
- package/docs/platforms/digitalocean.md +262 -0
- package/docs/platforms/exe-dev.md +125 -0
- package/docs/platforms/fly.md +486 -0
- package/docs/platforms/gcp.md +503 -0
- package/docs/platforms/hetzner.md +330 -0
- package/docs/platforms/index.md +53 -0
- package/docs/platforms/ios.md +107 -0
- package/docs/platforms/linux.md +94 -0
- package/docs/platforms/mac/bundled-gateway.md +73 -0
- package/docs/platforms/mac/canvas.md +125 -0
- package/docs/platforms/mac/child-process.md +69 -0
- package/docs/platforms/mac/dev-setup.md +102 -0
- package/docs/platforms/mac/health.md +34 -0
- package/docs/platforms/mac/icon.md +31 -0
- package/docs/platforms/mac/logging.md +57 -0
- package/docs/platforms/mac/menu-bar.md +81 -0
- package/docs/platforms/mac/peekaboo.md +65 -0
- package/docs/platforms/mac/permissions.md +44 -0
- package/docs/platforms/mac/release.md +85 -0
- package/docs/platforms/mac/remote.md +83 -0
- package/docs/platforms/mac/signing.md +47 -0
- package/docs/platforms/mac/skills.md +33 -0
- package/docs/platforms/mac/voice-overlay.md +60 -0
- package/docs/platforms/mac/voicewake.md +67 -0
- package/docs/platforms/mac/webchat.md +41 -0
- package/docs/platforms/mac/xpc.md +61 -0
- package/docs/platforms/macos-vm.md +281 -0
- package/docs/platforms/macos.md +203 -0
- package/docs/platforms/oracle.md +303 -0
- package/docs/platforms/raspberry-pi.md +358 -0
- package/docs/platforms/windows.md +159 -0
- package/docs/plugin.md +664 -0
- package/docs/plugins/agent-tools.md +99 -0
- package/docs/plugins/manifest.md +71 -0
- package/docs/plugins/voice-call.md +284 -0
- package/docs/plugins/zalouser.md +81 -0
- package/docs/prose.md +134 -0
- package/docs/providers/anthropic.md +152 -0
- package/docs/providers/claude-max-api-proxy.md +148 -0
- package/docs/providers/cloudflare-ai-gateway.md +71 -0
- package/docs/providers/deepgram.md +93 -0
- package/docs/providers/github-copilot.md +72 -0
- package/docs/providers/glm.md +33 -0
- package/docs/providers/index.md +63 -0
- package/docs/providers/minimax.md +208 -0
- package/docs/providers/models.md +51 -0
- package/docs/providers/moonshot.md +142 -0
- package/docs/providers/ollama.md +223 -0
- package/docs/providers/openai.md +62 -0
- package/docs/providers/opencode.md +36 -0
- package/docs/providers/openrouter.md +37 -0
- package/docs/providers/qwen.md +53 -0
- package/docs/providers/synthetic.md +99 -0
- package/docs/providers/venice.md +267 -0
- package/docs/providers/vercel-ai-gateway.md +50 -0
- package/docs/providers/xiaomi.md +64 -0
- package/docs/providers/zai.md +36 -0
- package/docs/railway.mdx +99 -0
- package/docs/refactor/clawnet.md +417 -0
- package/docs/refactor/exec-host.md +316 -0
- package/docs/refactor/outbound-session-mirroring.md +85 -0
- package/docs/refactor/plugin-sdk.md +214 -0
- package/docs/refactor/strict-config.md +93 -0
- package/docs/reference/AGENTS.default.md +124 -0
- package/docs/reference/RELEASING.md +120 -0
- package/docs/reference/api-usage-costs.md +137 -0
- package/docs/reference/device-models.md +47 -0
- package/docs/reference/rpc.md +43 -0
- package/docs/reference/session-management-compaction.md +285 -0
- package/docs/reference/templates/AGENTS.dev.md +83 -0
- package/docs/reference/templates/AGENTS.md +218 -0
- package/docs/reference/templates/BOOT.md +10 -0
- package/docs/reference/templates/BOOTSTRAP.md +61 -0
- package/docs/reference/templates/HEARTBEAT.md +11 -0
- package/docs/reference/templates/IDENTITY.dev.md +47 -0
- package/docs/reference/templates/IDENTITY.md +27 -0
- package/docs/reference/templates/SOUL.dev.md +76 -0
- package/docs/reference/templates/SOUL.md +42 -0
- package/docs/reference/templates/TOOLS.dev.md +24 -0
- package/docs/reference/templates/TOOLS.md +46 -0
- package/docs/reference/templates/USER.dev.md +18 -0
- package/docs/reference/templates/USER.md +22 -0
- package/docs/reference/test.md +50 -0
- package/docs/reference/transcript-hygiene.md +129 -0
- package/docs/render.mdx +165 -0
- package/docs/scripts.md +28 -0
- package/docs/security/formal-verification.md +164 -0
- package/docs/start/getting-started.md +208 -0
- package/docs/start/hubs.md +185 -0
- package/docs/start/lore.md +219 -0
- package/docs/start/onboarding.md +110 -0
- package/docs/start/openclaw.md +241 -0
- package/docs/start/pairing.md +86 -0
- package/docs/start/setup.md +149 -0
- package/docs/start/showcase.md +416 -0
- package/docs/start/wizard.md +349 -0
- package/docs/testing.md +368 -0
- package/docs/token-use.md +112 -0
- package/docs/tools/agent-send.md +53 -0
- package/docs/tools/apply-patch.md +50 -0
- package/docs/tools/browser-linux-troubleshooting.md +139 -0
- package/docs/tools/browser-login.md +68 -0
- package/docs/tools/browser.md +576 -0
- package/docs/tools/chrome-extension.md +178 -0
- package/docs/tools/clawhub.md +257 -0
- package/docs/tools/creating-skills.md +54 -0
- package/docs/tools/elevated.md +57 -0
- package/docs/tools/exec-approvals.md +246 -0
- package/docs/tools/exec.md +179 -0
- package/docs/tools/firecrawl.md +61 -0
- package/docs/tools/index.md +509 -0
- package/docs/tools/llm-task.md +115 -0
- package/docs/tools/lobster.md +342 -0
- package/docs/tools/reactions.md +22 -0
- package/docs/tools/skills-config.md +76 -0
- package/docs/tools/skills.md +300 -0
- package/docs/tools/slash-commands.md +198 -0
- package/docs/tools/subagents.md +151 -0
- package/docs/tools/thinking.md +73 -0
- package/docs/tools/web.md +261 -0
- package/docs/tts.md +396 -0
- package/docs/tui.md +159 -0
- package/docs/vps.md +43 -0
- package/docs/web/control-ui.md +221 -0
- package/docs/web/dashboard.md +46 -0
- package/docs/web/index.md +116 -0
- package/docs/web/webchat.md +49 -0
- package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
- package/docs/whatsapp-openclaw.jpg +0 -0
- package/docs/zh-CN/AGENTS.md +59 -0
- package/docs/zh-CN/automation/auth-monitoring.md +47 -0
- package/docs/zh-CN/automation/cron-jobs.md +424 -0
- package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
- package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
- package/docs/zh-CN/automation/poll.md +76 -0
- package/docs/zh-CN/automation/webhook.md +163 -0
- package/docs/zh-CN/bedrock.md +170 -0
- package/docs/zh-CN/brave-search.md +48 -0
- package/docs/zh-CN/broadcast-groups.md +449 -0
- package/docs/zh-CN/channels/bluebubbles.md +271 -0
- package/docs/zh-CN/channels/discord.md +468 -0
- package/docs/zh-CN/channels/feishu.md +513 -0
- package/docs/zh-CN/channels/googlechat.md +257 -0
- package/docs/zh-CN/channels/grammy.md +38 -0
- package/docs/zh-CN/channels/imessage.md +302 -0
- package/docs/zh-CN/channels/index.md +53 -0
- package/docs/zh-CN/channels/line.md +180 -0
- package/docs/zh-CN/channels/location.md +63 -0
- package/docs/zh-CN/channels/matrix.md +221 -0
- package/docs/zh-CN/channels/mattermost.md +144 -0
- package/docs/zh-CN/channels/msteams.md +775 -0
- package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
- package/docs/zh-CN/channels/nostr.md +240 -0
- package/docs/zh-CN/channels/signal.md +209 -0
- package/docs/zh-CN/channels/slack.md +531 -0
- package/docs/zh-CN/channels/telegram.md +751 -0
- package/docs/zh-CN/channels/tlon.md +136 -0
- package/docs/zh-CN/channels/troubleshooting.md +36 -0
- package/docs/zh-CN/channels/twitch.md +385 -0
- package/docs/zh-CN/channels/whatsapp.md +411 -0
- package/docs/zh-CN/channels/zalo.md +196 -0
- package/docs/zh-CN/channels/zalouser.md +147 -0
- package/docs/zh-CN/cli/acp.md +173 -0
- package/docs/zh-CN/cli/agent.md +30 -0
- package/docs/zh-CN/cli/agents.md +82 -0
- package/docs/zh-CN/cli/approvals.md +57 -0
- package/docs/zh-CN/cli/browser.md +114 -0
- package/docs/zh-CN/cli/channels.md +86 -0
- package/docs/zh-CN/cli/config.md +57 -0
- package/docs/zh-CN/cli/configure.md +38 -0
- package/docs/zh-CN/cli/cron.md +43 -0
- package/docs/zh-CN/cli/dashboard.md +23 -0
- package/docs/zh-CN/cli/devices.md +74 -0
- package/docs/zh-CN/cli/directory.md +70 -0
- package/docs/zh-CN/cli/dns.md +30 -0
- package/docs/zh-CN/cli/docs.md +22 -0
- package/docs/zh-CN/cli/doctor.md +48 -0
- package/docs/zh-CN/cli/gateway.md +206 -0
- package/docs/zh-CN/cli/health.md +28 -0
- package/docs/zh-CN/cli/hooks.md +311 -0
- package/docs/zh-CN/cli/index.md +1032 -0
- package/docs/zh-CN/cli/logs.md +31 -0
- package/docs/zh-CN/cli/memory.md +52 -0
- package/docs/zh-CN/cli/message.md +246 -0
- package/docs/zh-CN/cli/models.md +85 -0
- package/docs/zh-CN/cli/node.md +115 -0
- package/docs/zh-CN/cli/nodes.md +80 -0
- package/docs/zh-CN/cli/onboard.md +36 -0
- package/docs/zh-CN/cli/pairing.md +28 -0
- package/docs/zh-CN/cli/plugins.md +66 -0
- package/docs/zh-CN/cli/reset.md +24 -0
- package/docs/zh-CN/cli/sandbox.md +158 -0
- package/docs/zh-CN/cli/security.md +33 -0
- package/docs/zh-CN/cli/sessions.md +23 -0
- package/docs/zh-CN/cli/setup.md +36 -0
- package/docs/zh-CN/cli/skills.md +33 -0
- package/docs/zh-CN/cli/status.md +33 -0
- package/docs/zh-CN/cli/system.md +63 -0
- package/docs/zh-CN/cli/tui.md +30 -0
- package/docs/zh-CN/cli/uninstall.md +24 -0
- package/docs/zh-CN/cli/update.md +101 -0
- package/docs/zh-CN/cli/voicecall.md +41 -0
- package/docs/zh-CN/cli/webhooks.md +32 -0
- package/docs/zh-CN/concepts/agent-loop.md +146 -0
- package/docs/zh-CN/concepts/agent-workspace.md +219 -0
- package/docs/zh-CN/concepts/agent.md +115 -0
- package/docs/zh-CN/concepts/architecture.md +123 -0
- package/docs/zh-CN/concepts/channel-routing.md +117 -0
- package/docs/zh-CN/concepts/compaction.md +67 -0
- package/docs/zh-CN/concepts/context.md +168 -0
- package/docs/zh-CN/concepts/group-messages.md +91 -0
- package/docs/zh-CN/concepts/groups.md +379 -0
- package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
- package/docs/zh-CN/concepts/memory.md +412 -0
- package/docs/zh-CN/concepts/messages.md +141 -0
- package/docs/zh-CN/concepts/model-failover.md +145 -0
- package/docs/zh-CN/concepts/model-providers.md +320 -0
- package/docs/zh-CN/concepts/models.md +196 -0
- package/docs/zh-CN/concepts/multi-agent.md +372 -0
- package/docs/zh-CN/concepts/oauth.md +151 -0
- package/docs/zh-CN/concepts/presence.md +99 -0
- package/docs/zh-CN/concepts/queue.md +94 -0
- package/docs/zh-CN/concepts/retry.md +76 -0
- package/docs/zh-CN/concepts/session-pruning.md +129 -0
- package/docs/zh-CN/concepts/session-tool.md +200 -0
- package/docs/zh-CN/concepts/session.md +166 -0
- package/docs/zh-CN/concepts/sessions.md +17 -0
- package/docs/zh-CN/concepts/streaming.md +133 -0
- package/docs/zh-CN/concepts/system-prompt.md +101 -0
- package/docs/zh-CN/concepts/timezone.md +96 -0
- package/docs/zh-CN/concepts/typebox.md +284 -0
- package/docs/zh-CN/concepts/typing-indicators.md +74 -0
- package/docs/zh-CN/concepts/usage-tracking.md +42 -0
- package/docs/zh-CN/date-time.md +129 -0
- package/docs/zh-CN/debug/node-issue.md +90 -0
- package/docs/zh-CN/debugging.md +160 -0
- package/docs/zh-CN/diagnostics/flags.md +98 -0
- package/docs/zh-CN/environment.md +88 -0
- package/docs/zh-CN/experiments/onboarding-config-protocol.md +47 -0
- package/docs/zh-CN/experiments/plans/cron-add-hardening.md +70 -0
- package/docs/zh-CN/experiments/plans/group-policy-hardening.md +45 -0
- package/docs/zh-CN/experiments/plans/openresponses-gateway.md +121 -0
- package/docs/zh-CN/experiments/proposals/model-config.md +42 -0
- package/docs/zh-CN/experiments/research/memory.md +235 -0
- package/docs/zh-CN/gateway/authentication.md +142 -0
- package/docs/zh-CN/gateway/background-process.md +100 -0
- package/docs/zh-CN/gateway/bonjour.md +174 -0
- package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
- package/docs/zh-CN/gateway/cli-backends.md +213 -0
- package/docs/zh-CN/gateway/configuration-examples.md +587 -0
- package/docs/zh-CN/gateway/configuration.md +3332 -0
- package/docs/zh-CN/gateway/discovery.md +123 -0
- package/docs/zh-CN/gateway/doctor.md +238 -0
- package/docs/zh-CN/gateway/gateway-lock.md +41 -0
- package/docs/zh-CN/gateway/health.md +42 -0
- package/docs/zh-CN/gateway/heartbeat.md +274 -0
- package/docs/zh-CN/gateway/index.md +335 -0
- package/docs/zh-CN/gateway/local-models.md +157 -0
- package/docs/zh-CN/gateway/logging.md +114 -0
- package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
- package/docs/zh-CN/gateway/openai-http-api.md +125 -0
- package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
- package/docs/zh-CN/gateway/pairing.md +99 -0
- package/docs/zh-CN/gateway/protocol.md +220 -0
- package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
- package/docs/zh-CN/gateway/remote.md +133 -0
- package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
- package/docs/zh-CN/gateway/sandboxing.md +188 -0
- package/docs/zh-CN/gateway/security/formal-verification.md +169 -0
- package/docs/zh-CN/gateway/security/index.md +777 -0
- package/docs/zh-CN/gateway/tailscale.md +124 -0
- package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
- package/docs/zh-CN/gateway/troubleshooting.md +771 -0
- package/docs/zh-CN/help/faq.md +2628 -0
- package/docs/zh-CN/help/index.md +28 -0
- package/docs/zh-CN/help/troubleshooting.md +104 -0
- package/docs/zh-CN/hooks/soul-evil.md +72 -0
- package/docs/zh-CN/hooks.md +919 -0
- package/docs/zh-CN/index.md +264 -0
- package/docs/zh-CN/install/ansible.md +215 -0
- package/docs/zh-CN/install/bun.md +65 -0
- package/docs/zh-CN/install/development-channels.md +81 -0
- package/docs/zh-CN/install/docker.md +532 -0
- package/docs/zh-CN/install/index.md +193 -0
- package/docs/zh-CN/install/installer.md +128 -0
- package/docs/zh-CN/install/migrating.md +199 -0
- package/docs/zh-CN/install/nix.md +99 -0
- package/docs/zh-CN/install/node.md +85 -0
- package/docs/zh-CN/install/uninstall.md +135 -0
- package/docs/zh-CN/install/updating.md +233 -0
- package/docs/zh-CN/logging.md +329 -0
- package/docs/zh-CN/multi-agent-sandbox-tools.md +401 -0
- package/docs/zh-CN/network.md +59 -0
- package/docs/zh-CN/nodes/audio.md +120 -0
- package/docs/zh-CN/nodes/camera.md +162 -0
- package/docs/zh-CN/nodes/images.md +79 -0
- package/docs/zh-CN/nodes/index.md +348 -0
- package/docs/zh-CN/nodes/location-command.md +120 -0
- package/docs/zh-CN/nodes/media-understanding.md +380 -0
- package/docs/zh-CN/nodes/talk.md +97 -0
- package/docs/zh-CN/nodes/voicewake.md +72 -0
- package/docs/zh-CN/northflank.mdx +60 -0
- package/docs/zh-CN/perplexity.md +84 -0
- package/docs/zh-CN/pi-dev.md +77 -0
- package/docs/zh-CN/pi.md +619 -0
- package/docs/zh-CN/platforms/android.md +155 -0
- package/docs/zh-CN/platforms/digitalocean.md +269 -0
- package/docs/zh-CN/platforms/exe-dev.md +127 -0
- package/docs/zh-CN/platforms/fly.md +490 -0
- package/docs/zh-CN/platforms/gcp.md +510 -0
- package/docs/zh-CN/platforms/hetzner.md +337 -0
- package/docs/zh-CN/platforms/index.md +60 -0
- package/docs/zh-CN/platforms/ios.md +114 -0
- package/docs/zh-CN/platforms/linux.md +101 -0
- package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
- package/docs/zh-CN/platforms/mac/canvas.md +128 -0
- package/docs/zh-CN/platforms/mac/child-process.md +73 -0
- package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
- package/docs/zh-CN/platforms/mac/health.md +41 -0
- package/docs/zh-CN/platforms/mac/icon.md +38 -0
- package/docs/zh-CN/platforms/mac/logging.md +64 -0
- package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
- package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
- package/docs/zh-CN/platforms/mac/permissions.md +46 -0
- package/docs/zh-CN/platforms/mac/release.md +92 -0
- package/docs/zh-CN/platforms/mac/remote.md +90 -0
- package/docs/zh-CN/platforms/mac/signing.md +54 -0
- package/docs/zh-CN/platforms/mac/skills.md +40 -0
- package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
- package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
- package/docs/zh-CN/platforms/mac/webchat.md +43 -0
- package/docs/zh-CN/platforms/mac/xpc.md +68 -0
- package/docs/zh-CN/platforms/macos-vm.md +288 -0
- package/docs/zh-CN/platforms/macos.md +193 -0
- package/docs/zh-CN/platforms/oracle.md +310 -0
- package/docs/zh-CN/platforms/raspberry-pi.md +365 -0
- package/docs/zh-CN/platforms/windows.md +156 -0
- package/docs/zh-CN/plugin.md +639 -0
- package/docs/zh-CN/plugins/agent-tools.md +99 -0
- package/docs/zh-CN/plugins/manifest.md +68 -0
- package/docs/zh-CN/plugins/voice-call.md +250 -0
- package/docs/zh-CN/plugins/zalouser.md +88 -0
- package/docs/zh-CN/prose.md +141 -0
- package/docs/zh-CN/providers/anthropic.md +159 -0
- package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
- package/docs/zh-CN/providers/deepgram.md +97 -0
- package/docs/zh-CN/providers/github-copilot.md +67 -0
- package/docs/zh-CN/providers/glm.md +39 -0
- package/docs/zh-CN/providers/index.md +68 -0
- package/docs/zh-CN/providers/minimax.md +206 -0
- package/docs/zh-CN/providers/models.md +55 -0
- package/docs/zh-CN/providers/moonshot.md +145 -0
- package/docs/zh-CN/providers/ollama.md +230 -0
- package/docs/zh-CN/providers/openai.md +68 -0
- package/docs/zh-CN/providers/opencode.md +41 -0
- package/docs/zh-CN/providers/openrouter.md +43 -0
- package/docs/zh-CN/providers/qwen.md +55 -0
- package/docs/zh-CN/providers/synthetic.md +102 -0
- package/docs/zh-CN/providers/venice.md +274 -0
- package/docs/zh-CN/providers/vercel-ai-gateway.md +57 -0
- package/docs/zh-CN/providers/xiaomi.md +68 -0
- package/docs/zh-CN/providers/zai.md +41 -0
- package/docs/zh-CN/railway.mdx +106 -0
- package/docs/zh-CN/refactor/clawnet.md +424 -0
- package/docs/zh-CN/refactor/exec-host.md +323 -0
- package/docs/zh-CN/refactor/outbound-session-mirroring.md +92 -0
- package/docs/zh-CN/refactor/plugin-sdk.md +221 -0
- package/docs/zh-CN/refactor/strict-config.md +100 -0
- package/docs/zh-CN/reference/AGENTS.default.md +131 -0
- package/docs/zh-CN/reference/RELEASING.md +123 -0
- package/docs/zh-CN/reference/api-usage-costs.md +136 -0
- package/docs/zh-CN/reference/device-models.md +54 -0
- package/docs/zh-CN/reference/rpc.md +48 -0
- package/docs/zh-CN/reference/session-management-compaction.md +287 -0
- package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
- package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
- package/docs/zh-CN/reference/templates/BOOT.md +17 -0
- package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
- package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
- package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
- package/docs/zh-CN/reference/templates/IDENTITY.md +35 -0
- package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
- package/docs/zh-CN/reference/templates/SOUL.md +49 -0
- package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
- package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
- package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
- package/docs/zh-CN/reference/templates/USER.md +30 -0
- package/docs/zh-CN/reference/test.md +57 -0
- package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
- package/docs/zh-CN/render.mdx +169 -0
- package/docs/zh-CN/scripts.md +35 -0
- package/docs/zh-CN/security/formal-verification.md +171 -0
- package/docs/zh-CN/start/getting-started.md +206 -0
- package/docs/zh-CN/start/hubs.md +191 -0
- package/docs/zh-CN/start/lore.md +226 -0
- package/docs/zh-CN/start/onboarding.md +105 -0
- package/docs/zh-CN/start/openclaw.md +248 -0
- package/docs/zh-CN/start/pairing.md +89 -0
- package/docs/zh-CN/start/setup.md +153 -0
- package/docs/zh-CN/start/showcase.md +423 -0
- package/docs/zh-CN/start/wizard.md +331 -0
- package/docs/zh-CN/testing.md +375 -0
- package/docs/zh-CN/token-use.md +119 -0
- package/docs/zh-CN/tools/agent-send.md +59 -0
- package/docs/zh-CN/tools/apply-patch.md +57 -0
- package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
- package/docs/zh-CN/tools/browser-login.md +75 -0
- package/docs/zh-CN/tools/browser.md +553 -0
- package/docs/zh-CN/tools/chrome-extension.md +183 -0
- package/docs/zh-CN/tools/clawhub.md +209 -0
- package/docs/zh-CN/tools/creating-skills.md +61 -0
- package/docs/zh-CN/tools/elevated.md +64 -0
- package/docs/zh-CN/tools/exec-approvals.md +234 -0
- package/docs/zh-CN/tools/exec.md +169 -0
- package/docs/zh-CN/tools/firecrawl.md +68 -0
- package/docs/zh-CN/tools/index.md +515 -0
- package/docs/zh-CN/tools/llm-task.md +117 -0
- package/docs/zh-CN/tools/lobster.md +349 -0
- package/docs/zh-CN/tools/reactions.md +29 -0
- package/docs/zh-CN/tools/skills-config.md +78 -0
- package/docs/zh-CN/tools/skills.md +279 -0
- package/docs/zh-CN/tools/slash-commands.md +205 -0
- package/docs/zh-CN/tools/subagents.md +156 -0
- package/docs/zh-CN/tools/thinking.md +80 -0
- package/docs/zh-CN/tools/web.md +257 -0
- package/docs/zh-CN/tts.md +375 -0
- package/docs/zh-CN/tui.md +166 -0
- package/docs/zh-CN/vps.md +47 -0
- package/docs/zh-CN/web/control-ui.md +191 -0
- package/docs/zh-CN/web/dashboard.md +53 -0
- package/docs/zh-CN/web/index.md +118 -0
- package/docs/zh-CN/web/webchat.md +56 -0
- package/extensions/bluebubbles/README.md +45 -0
- package/extensions/bluebubbles/index.ts +19 -0
- package/extensions/bluebubbles/node_modules/.bin/openclaw +21 -0
- package/extensions/bluebubbles/openclaw.plugin.json +9 -0
- package/extensions/bluebubbles/package.json +36 -0
- package/extensions/bluebubbles/src/accounts.ts +88 -0
- package/extensions/bluebubbles/src/actions.test.ts +650 -0
- package/extensions/bluebubbles/src/actions.ts +438 -0
- package/extensions/bluebubbles/src/attachments.test.ts +345 -0
- package/extensions/bluebubbles/src/attachments.ts +300 -0
- package/extensions/bluebubbles/src/channel.ts +414 -0
- package/extensions/bluebubbles/src/chat.test.ts +461 -0
- package/extensions/bluebubbles/src/chat.ts +378 -0
- package/extensions/bluebubbles/src/config-schema.ts +51 -0
- package/extensions/bluebubbles/src/media-send.ts +174 -0
- package/extensions/bluebubbles/src/monitor.test.ts +2342 -0
- package/extensions/bluebubbles/src/monitor.ts +2490 -0
- package/extensions/bluebubbles/src/onboarding.ts +352 -0
- package/extensions/bluebubbles/src/probe.ts +135 -0
- package/extensions/bluebubbles/src/reactions.test.ts +392 -0
- package/extensions/bluebubbles/src/reactions.ts +188 -0
- package/extensions/bluebubbles/src/runtime.ts +14 -0
- package/extensions/bluebubbles/src/send.test.ts +808 -0
- package/extensions/bluebubbles/src/send.ts +467 -0
- package/extensions/bluebubbles/src/targets.test.ts +183 -0
- package/extensions/bluebubbles/src/targets.ts +422 -0
- package/extensions/bluebubbles/src/types.ts +127 -0
- package/extensions/copilot-proxy/README.md +24 -0
- package/extensions/copilot-proxy/index.ts +148 -0
- package/extensions/copilot-proxy/node_modules/.bin/openclaw +21 -0
- package/extensions/copilot-proxy/openclaw.plugin.json +9 -0
- package/extensions/copilot-proxy/package.json +14 -0
- package/extensions/diagnostics-otel/index.ts +15 -0
- package/extensions/diagnostics-otel/node_modules/.bin/openclaw +21 -0
- package/extensions/diagnostics-otel/openclaw.plugin.json +8 -0
- package/extensions/diagnostics-otel/package.json +27 -0
- package/extensions/diagnostics-otel/src/service.test.ts +226 -0
- package/extensions/diagnostics-otel/src/service.ts +635 -0
- package/extensions/discord/index.ts +17 -0
- package/extensions/discord/node_modules/.bin/openclaw +21 -0
- package/extensions/discord/openclaw.plugin.json +9 -0
- package/extensions/discord/package.json +14 -0
- package/extensions/discord/src/channel.ts +422 -0
- package/extensions/discord/src/runtime.ts +14 -0
- package/extensions/feishu/README.md +47 -0
- package/extensions/feishu/index.ts +15 -0
- package/extensions/feishu/node_modules/.bin/openclaw +21 -0
- package/extensions/feishu/openclaw.plugin.json +9 -0
- package/extensions/feishu/package.json +33 -0
- package/extensions/feishu/src/channel.ts +276 -0
- package/extensions/feishu/src/config-schema.ts +46 -0
- package/extensions/feishu/src/onboarding.ts +278 -0
- package/extensions/google-antigravity-auth/README.md +24 -0
- package/extensions/google-antigravity-auth/index.ts +461 -0
- package/extensions/google-antigravity-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-antigravity-auth/openclaw.plugin.json +9 -0
- package/extensions/google-antigravity-auth/package.json +14 -0
- package/extensions/google-gemini-cli-auth/README.md +35 -0
- package/extensions/google-gemini-cli-auth/index.ts +88 -0
- package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-gemini-cli-auth/oauth.test.ts +240 -0
- package/extensions/google-gemini-cli-auth/oauth.ts +662 -0
- package/extensions/google-gemini-cli-auth/openclaw.plugin.json +9 -0
- package/extensions/google-gemini-cli-auth/package.json +14 -0
- package/extensions/googlechat/index.ts +19 -0
- package/extensions/googlechat/node_modules/.bin/openclaw +21 -0
- package/extensions/googlechat/openclaw.plugin.json +9 -0
- package/extensions/googlechat/package.json +39 -0
- package/extensions/googlechat/src/accounts.ts +147 -0
- package/extensions/googlechat/src/actions.ts +181 -0
- package/extensions/googlechat/src/api.test.ts +61 -0
- package/extensions/googlechat/src/api.ts +282 -0
- package/extensions/googlechat/src/auth.ts +123 -0
- package/extensions/googlechat/src/channel.ts +583 -0
- package/extensions/googlechat/src/monitor.test.ts +22 -0
- package/extensions/googlechat/src/monitor.ts +949 -0
- package/extensions/googlechat/src/onboarding.ts +269 -0
- package/extensions/googlechat/src/runtime.ts +14 -0
- package/extensions/googlechat/src/targets.test.ts +32 -0
- package/extensions/googlechat/src/targets.ts +65 -0
- package/extensions/googlechat/src/types.config.ts +3 -0
- package/extensions/googlechat/src/types.ts +73 -0
- package/extensions/imessage/index.ts +17 -0
- package/extensions/imessage/node_modules/.bin/openclaw +21 -0
- package/extensions/imessage/openclaw.plugin.json +9 -0
- package/extensions/imessage/package.json +14 -0
- package/extensions/imessage/src/channel.ts +294 -0
- package/extensions/imessage/src/runtime.ts +14 -0
- package/extensions/line/index.ts +19 -0
- package/extensions/line/node_modules/.bin/openclaw +21 -0
- package/extensions/line/openclaw.plugin.json +9 -0
- package/extensions/line/package.json +29 -0
- package/extensions/line/src/card-command.ts +344 -0
- package/extensions/line/src/channel.logout.test.ts +99 -0
- package/extensions/line/src/channel.sendPayload.test.ts +306 -0
- package/extensions/line/src/channel.ts +780 -0
- package/extensions/line/src/runtime.ts +14 -0
- package/extensions/llm-task/README.md +97 -0
- package/extensions/llm-task/index.ts +6 -0
- package/extensions/llm-task/node_modules/.bin/openclaw +21 -0
- package/extensions/llm-task/openclaw.plugin.json +21 -0
- package/extensions/llm-task/package.json +14 -0
- package/extensions/llm-task/src/llm-task-tool.test.ts +138 -0
- package/extensions/llm-task/src/llm-task-tool.ts +245 -0
- package/extensions/lobster/README.md +75 -0
- package/extensions/lobster/SKILL.md +97 -0
- package/extensions/lobster/index.ts +14 -0
- package/extensions/lobster/node_modules/.bin/openclaw +21 -0
- package/extensions/lobster/openclaw.plugin.json +10 -0
- package/extensions/lobster/package.json +14 -0
- package/extensions/lobster/src/lobster-tool.test.ts +247 -0
- package/extensions/lobster/src/lobster-tool.ts +328 -0
- package/extensions/matrix/CHANGELOG.md +87 -0
- package/extensions/matrix/index.ts +17 -0
- package/extensions/matrix/node_modules/.bin/markdown-it +21 -0
- package/extensions/matrix/node_modules/.bin/openclaw +21 -0
- package/extensions/matrix/openclaw.plugin.json +9 -0
- package/extensions/matrix/package.json +36 -0
- package/extensions/matrix/src/actions.ts +195 -0
- package/extensions/matrix/src/channel.directory.test.ts +64 -0
- package/extensions/matrix/src/channel.ts +439 -0
- package/extensions/matrix/src/config-schema.ts +62 -0
- package/extensions/matrix/src/directory-live.ts +188 -0
- package/extensions/matrix/src/group-mentions.ts +66 -0
- package/extensions/matrix/src/matrix/accounts.test.ts +82 -0
- package/extensions/matrix/src/matrix/accounts.ts +65 -0
- package/extensions/matrix/src/matrix/actions/client.ts +57 -0
- package/extensions/matrix/src/matrix/actions/messages.ts +128 -0
- package/extensions/matrix/src/matrix/actions/pins.ts +76 -0
- package/extensions/matrix/src/matrix/actions/reactions.ts +96 -0
- package/extensions/matrix/src/matrix/actions/room.ts +85 -0
- package/extensions/matrix/src/matrix/actions/summary.ts +75 -0
- package/extensions/matrix/src/matrix/actions/types.ts +84 -0
- package/extensions/matrix/src/matrix/actions.ts +15 -0
- package/extensions/matrix/src/matrix/active-client.ts +11 -0
- package/extensions/matrix/src/matrix/client/config.ts +160 -0
- package/extensions/matrix/src/matrix/client/create-client.ts +123 -0
- package/extensions/matrix/src/matrix/client/logging.ts +36 -0
- package/extensions/matrix/src/matrix/client/runtime.ts +4 -0
- package/extensions/matrix/src/matrix/client/shared.ts +170 -0
- package/extensions/matrix/src/matrix/client/storage.ts +131 -0
- package/extensions/matrix/src/matrix/client/types.ts +34 -0
- package/extensions/matrix/src/matrix/client.test.ts +56 -0
- package/extensions/matrix/src/matrix/client.ts +5 -0
- package/extensions/matrix/src/matrix/credentials.ts +105 -0
- package/extensions/matrix/src/matrix/deps.ts +60 -0
- package/extensions/matrix/src/matrix/format.test.ts +33 -0
- package/extensions/matrix/src/matrix/format.ts +22 -0
- package/extensions/matrix/src/matrix/index.ts +11 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.test.ts +45 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.ts +103 -0
- package/extensions/matrix/src/matrix/monitor/auto-join.ts +71 -0
- package/extensions/matrix/src/matrix/monitor/direct.ts +104 -0
- package/extensions/matrix/src/matrix/monitor/events.ts +101 -0
- package/extensions/matrix/src/matrix/monitor/handler.ts +661 -0
- package/extensions/matrix/src/matrix/monitor/index.ts +338 -0
- package/extensions/matrix/src/matrix/monitor/location.ts +100 -0
- package/extensions/matrix/src/matrix/monitor/media.test.ts +102 -0
- package/extensions/matrix/src/matrix/monitor/media.ts +113 -0
- package/extensions/matrix/src/matrix/monitor/mentions.ts +31 -0
- package/extensions/matrix/src/matrix/monitor/replies.ts +97 -0
- package/extensions/matrix/src/matrix/monitor/room-info.ts +55 -0
- package/extensions/matrix/src/matrix/monitor/rooms.test.ts +39 -0
- package/extensions/matrix/src/matrix/monitor/rooms.ts +47 -0
- package/extensions/matrix/src/matrix/monitor/threads.ts +68 -0
- package/extensions/matrix/src/matrix/monitor/types.ts +39 -0
- package/extensions/matrix/src/matrix/poll-types.test.ts +21 -0
- package/extensions/matrix/src/matrix/poll-types.ts +166 -0
- package/extensions/matrix/src/matrix/probe.ts +70 -0
- package/extensions/matrix/src/matrix/send/client.ts +66 -0
- package/extensions/matrix/src/matrix/send/formatting.ts +89 -0
- package/extensions/matrix/src/matrix/send/media.ts +229 -0
- package/extensions/matrix/src/matrix/send/targets.test.ts +98 -0
- package/extensions/matrix/src/matrix/send/targets.ts +136 -0
- package/extensions/matrix/src/matrix/send/types.ts +109 -0
- package/extensions/matrix/src/matrix/send.test.ts +171 -0
- package/extensions/matrix/src/matrix/send.ts +260 -0
- package/extensions/matrix/src/onboarding.ts +449 -0
- package/extensions/matrix/src/outbound.ts +52 -0
- package/extensions/matrix/src/resolve-targets.test.ts +48 -0
- package/extensions/matrix/src/resolve-targets.ts +135 -0
- package/extensions/matrix/src/runtime.ts +14 -0
- package/extensions/matrix/src/tool-actions.ts +164 -0
- package/extensions/matrix/src/types.ts +95 -0
- package/extensions/mattermost/index.ts +17 -0
- package/extensions/mattermost/node_modules/.bin/openclaw +21 -0
- package/extensions/mattermost/openclaw.plugin.json +9 -0
- package/extensions/mattermost/package.json +28 -0
- package/extensions/mattermost/src/channel.test.ts +48 -0
- package/extensions/mattermost/src/channel.ts +337 -0
- package/extensions/mattermost/src/config-schema.ts +55 -0
- package/extensions/mattermost/src/group-mentions.ts +15 -0
- package/extensions/mattermost/src/mattermost/accounts.ts +128 -0
- package/extensions/mattermost/src/mattermost/client.ts +220 -0
- package/extensions/mattermost/src/mattermost/index.ts +9 -0
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +166 -0
- package/extensions/mattermost/src/mattermost/monitor.ts +987 -0
- package/extensions/mattermost/src/mattermost/probe.ts +74 -0
- package/extensions/mattermost/src/mattermost/send.ts +231 -0
- package/extensions/mattermost/src/normalize.ts +46 -0
- package/extensions/mattermost/src/onboarding-helpers.ts +44 -0
- package/extensions/mattermost/src/onboarding.ts +186 -0
- package/extensions/mattermost/src/runtime.ts +14 -0
- package/extensions/mattermost/src/types.ts +50 -0
- package/extensions/memory-core/index.ts +38 -0
- package/extensions/memory-core/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-core/openclaw.plugin.json +9 -0
- package/extensions/memory-core/package.json +17 -0
- package/extensions/memory-lancedb/config.ts +139 -0
- package/extensions/memory-lancedb/index.test.ts +295 -0
- package/extensions/memory-lancedb/index.ts +608 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
- package/extensions/memory-lancedb/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-lancedb/openclaw.plugin.json +60 -0
- package/extensions/memory-lancedb/package.json +19 -0
- package/extensions/minimax-portal-auth/README.md +33 -0
- package/extensions/minimax-portal-auth/index.ts +155 -0
- package/extensions/minimax-portal-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/minimax-portal-auth/oauth.ts +247 -0
- package/extensions/minimax-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/minimax-portal-auth/package.json +14 -0
- package/extensions/msteams/CHANGELOG.md +83 -0
- package/extensions/msteams/index.ts +17 -0
- package/extensions/msteams/node_modules/.bin/openclaw +21 -0
- package/extensions/msteams/openclaw.plugin.json +9 -0
- package/extensions/msteams/package.json +39 -0
- package/extensions/msteams/src/attachments/download.ts +283 -0
- package/extensions/msteams/src/attachments/graph.ts +353 -0
- package/extensions/msteams/src/attachments/html.ts +90 -0
- package/extensions/msteams/src/attachments/payload.ts +22 -0
- package/extensions/msteams/src/attachments/shared.ts +291 -0
- package/extensions/msteams/src/attachments/types.ts +37 -0
- package/extensions/msteams/src/attachments.test.ts +459 -0
- package/extensions/msteams/src/attachments.ts +18 -0
- package/extensions/msteams/src/channel.directory.test.ts +48 -0
- package/extensions/msteams/src/channel.ts +459 -0
- package/extensions/msteams/src/conversation-store-fs.test.ts +88 -0
- package/extensions/msteams/src/conversation-store-fs.ts +165 -0
- package/extensions/msteams/src/conversation-store-memory.ts +47 -0
- package/extensions/msteams/src/conversation-store.ts +41 -0
- package/extensions/msteams/src/directory-live.ts +205 -0
- package/extensions/msteams/src/errors.test.ts +45 -0
- package/extensions/msteams/src/errors.ts +190 -0
- package/extensions/msteams/src/file-consent-helpers.test.ts +243 -0
- package/extensions/msteams/src/file-consent-helpers.ts +73 -0
- package/extensions/msteams/src/file-consent.ts +126 -0
- package/extensions/msteams/src/graph-chat.ts +53 -0
- package/extensions/msteams/src/graph-upload.ts +453 -0
- package/extensions/msteams/src/inbound.test.ts +66 -0
- package/extensions/msteams/src/inbound.ts +48 -0
- package/extensions/msteams/src/index.ts +4 -0
- package/extensions/msteams/src/media-helpers.test.ts +189 -0
- package/extensions/msteams/src/media-helpers.ts +86 -0
- package/extensions/msteams/src/messenger.test.ts +248 -0
- package/extensions/msteams/src/messenger.ts +495 -0
- package/extensions/msteams/src/monitor-handler/inbound-media.ts +128 -0
- package/extensions/msteams/src/monitor-handler/message-handler.ts +640 -0
- package/extensions/msteams/src/monitor-handler.ts +162 -0
- package/extensions/msteams/src/monitor-types.ts +5 -0
- package/extensions/msteams/src/monitor.ts +295 -0
- package/extensions/msteams/src/onboarding.ts +431 -0
- package/extensions/msteams/src/outbound.ts +46 -0
- package/extensions/msteams/src/pending-uploads.ts +89 -0
- package/extensions/msteams/src/policy.test.ts +209 -0
- package/extensions/msteams/src/policy.ts +273 -0
- package/extensions/msteams/src/polls-store-memory.ts +32 -0
- package/extensions/msteams/src/polls-store.test.ts +38 -0
- package/extensions/msteams/src/polls.test.ts +72 -0
- package/extensions/msteams/src/polls.ts +315 -0
- package/extensions/msteams/src/probe.test.ts +58 -0
- package/extensions/msteams/src/probe.ts +107 -0
- package/extensions/msteams/src/reply-dispatcher.ts +130 -0
- package/extensions/msteams/src/resolve-allowlist.ts +297 -0
- package/extensions/msteams/src/runtime.ts +14 -0
- package/extensions/msteams/src/sdk-types.ts +19 -0
- package/extensions/msteams/src/sdk.ts +33 -0
- package/extensions/msteams/src/send-context.ts +164 -0
- package/extensions/msteams/src/send.ts +519 -0
- package/extensions/msteams/src/sent-message-cache.test.ts +15 -0
- package/extensions/msteams/src/sent-message-cache.ts +47 -0
- package/extensions/msteams/src/storage.ts +25 -0
- package/extensions/msteams/src/store-fs.ts +83 -0
- package/extensions/msteams/src/token.ts +19 -0
- package/extensions/nextcloud-talk/index.ts +17 -0
- package/extensions/nextcloud-talk/node_modules/.bin/openclaw +21 -0
- package/extensions/nextcloud-talk/openclaw.plugin.json +9 -0
- package/extensions/nextcloud-talk/package.json +33 -0
- package/extensions/nextcloud-talk/src/accounts.ts +174 -0
- package/extensions/nextcloud-talk/src/channel.ts +409 -0
- package/extensions/nextcloud-talk/src/config-schema.ts +78 -0
- package/extensions/nextcloud-talk/src/format.ts +79 -0
- package/extensions/nextcloud-talk/src/inbound.ts +317 -0
- package/extensions/nextcloud-talk/src/monitor.ts +246 -0
- package/extensions/nextcloud-talk/src/normalize.ts +39 -0
- package/extensions/nextcloud-talk/src/onboarding.ts +343 -0
- package/extensions/nextcloud-talk/src/policy.test.ts +33 -0
- package/extensions/nextcloud-talk/src/policy.ts +180 -0
- package/extensions/nextcloud-talk/src/room-info.ts +125 -0
- package/extensions/nextcloud-talk/src/runtime.ts +14 -0
- package/extensions/nextcloud-talk/src/send.ts +210 -0
- package/extensions/nextcloud-talk/src/signature.ts +72 -0
- package/extensions/nextcloud-talk/src/types.ts +179 -0
- package/extensions/nostr/CHANGELOG.md +74 -0
- package/extensions/nostr/README.md +136 -0
- package/extensions/nostr/index.ts +68 -0
- package/extensions/nostr/node_modules/.bin/openclaw +21 -0
- package/extensions/nostr/openclaw.plugin.json +9 -0
- package/extensions/nostr/package.json +34 -0
- package/extensions/nostr/src/channel.test.ts +151 -0
- package/extensions/nostr/src/channel.ts +353 -0
- package/extensions/nostr/src/config-schema.ts +90 -0
- package/extensions/nostr/src/metrics.ts +478 -0
- package/extensions/nostr/src/nostr-bus.fuzz.test.ts +533 -0
- package/extensions/nostr/src/nostr-bus.integration.test.ts +448 -0
- package/extensions/nostr/src/nostr-bus.test.ts +199 -0
- package/extensions/nostr/src/nostr-bus.ts +715 -0
- package/extensions/nostr/src/nostr-profile-http.test.ts +378 -0
- package/extensions/nostr/src/nostr-profile-http.ts +519 -0
- package/extensions/nostr/src/nostr-profile-import.test.ts +119 -0
- package/extensions/nostr/src/nostr-profile-import.ts +262 -0
- package/extensions/nostr/src/nostr-profile.fuzz.test.ts +477 -0
- package/extensions/nostr/src/nostr-profile.test.ts +410 -0
- package/extensions/nostr/src/nostr-profile.ts +277 -0
- package/extensions/nostr/src/nostr-state-store.test.ts +131 -0
- package/extensions/nostr/src/nostr-state-store.ts +226 -0
- package/extensions/nostr/src/runtime.ts +14 -0
- package/extensions/nostr/src/seen-tracker.ts +303 -0
- package/extensions/nostr/src/types.test.ts +157 -0
- package/extensions/nostr/src/types.ts +101 -0
- package/extensions/nostr/test/setup.ts +5 -0
- package/extensions/open-prose/README.md +25 -0
- package/extensions/open-prose/index.ts +5 -0
- package/extensions/open-prose/node_modules/.bin/openclaw +21 -0
- package/extensions/open-prose/openclaw.plugin.json +11 -0
- package/extensions/open-prose/package.json +14 -0
- package/extensions/open-prose/skills/prose/LICENSE +21 -0
- package/extensions/open-prose/skills/prose/SKILL.md +323 -0
- package/extensions/open-prose/skills/prose/alt-borges.md +141 -0
- package/extensions/open-prose/skills/prose/alts/arabian-nights.md +358 -0
- package/extensions/open-prose/skills/prose/alts/borges.md +360 -0
- package/extensions/open-prose/skills/prose/alts/folk.md +322 -0
- package/extensions/open-prose/skills/prose/alts/homer.md +346 -0
- package/extensions/open-prose/skills/prose/alts/kafka.md +373 -0
- package/extensions/open-prose/skills/prose/compiler.md +2971 -0
- package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +4 -0
- package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +6 -0
- package/extensions/open-prose/skills/prose/examples/03-code-review.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +14 -0
- package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/07-refactor.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +25 -0
- package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +27 -0
- package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +43 -0
- package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +48 -0
- package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +23 -0
- package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +36 -0
- package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +71 -0
- package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +35 -0
- package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +63 -0
- package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +86 -0
- package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +114 -0
- package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +100 -0
- package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +105 -0
- package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +37 -0
- package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +1572 -0
- package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +218 -0
- package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +42 -0
- package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +145 -0
- package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +168 -0
- package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +204 -0
- package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +296 -0
- package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +237 -0
- package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +1474 -0
- package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +455 -0
- package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +277 -0
- package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +38 -0
- package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +46 -0
- package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +50 -0
- package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +261 -0
- package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +159 -0
- package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +637 -0
- package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +148 -0
- package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +225 -0
- package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +356 -0
- package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +445 -0
- package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +210 -0
- package/extensions/open-prose/skills/prose/examples/README.md +391 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/README.md +22 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +18 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +223 -0
- package/extensions/open-prose/skills/prose/guidance/antipatterns.md +951 -0
- package/extensions/open-prose/skills/prose/guidance/patterns.md +700 -0
- package/extensions/open-prose/skills/prose/guidance/system-prompt.md +180 -0
- package/extensions/open-prose/skills/prose/help.md +144 -0
- package/extensions/open-prose/skills/prose/lib/README.md +108 -0
- package/extensions/open-prose/skills/prose/lib/calibrator.prose +215 -0
- package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +174 -0
- package/extensions/open-prose/skills/prose/lib/error-forensics.prose +250 -0
- package/extensions/open-prose/skills/prose/lib/inspector.prose +196 -0
- package/extensions/open-prose/skills/prose/lib/profiler.prose +460 -0
- package/extensions/open-prose/skills/prose/lib/program-improver.prose +275 -0
- package/extensions/open-prose/skills/prose/lib/project-memory.prose +118 -0
- package/extensions/open-prose/skills/prose/lib/user-memory.prose +93 -0
- package/extensions/open-prose/skills/prose/lib/vm-improver.prose +243 -0
- package/extensions/open-prose/skills/prose/primitives/session.md +593 -0
- package/extensions/open-prose/skills/prose/prose.md +1237 -0
- package/extensions/open-prose/skills/prose/state/filesystem.md +498 -0
- package/extensions/open-prose/skills/prose/state/in-context.md +384 -0
- package/extensions/open-prose/skills/prose/state/postgres.md +880 -0
- package/extensions/open-prose/skills/prose/state/sqlite.md +574 -0
- package/extensions/qwen-portal-auth/README.md +24 -0
- package/extensions/qwen-portal-auth/index.ts +130 -0
- package/extensions/qwen-portal-auth/oauth.ts +190 -0
- package/extensions/qwen-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/signal/index.ts +17 -0
- package/extensions/signal/node_modules/.bin/openclaw +21 -0
- package/extensions/signal/openclaw.plugin.json +9 -0
- package/extensions/signal/package.json +14 -0
- package/extensions/signal/src/channel.ts +315 -0
- package/extensions/signal/src/runtime.ts +14 -0
- package/extensions/slack/index.ts +17 -0
- package/extensions/slack/node_modules/.bin/openclaw +21 -0
- package/extensions/slack/openclaw.plugin.json +9 -0
- package/extensions/slack/package.json +14 -0
- package/extensions/slack/src/channel.ts +604 -0
- package/extensions/slack/src/runtime.ts +14 -0
- package/extensions/telegram/index.ts +17 -0
- package/extensions/telegram/node_modules/.bin/openclaw +21 -0
- package/extensions/telegram/openclaw.plugin.json +9 -0
- package/extensions/telegram/package.json +14 -0
- package/extensions/telegram/src/channel.ts +482 -0
- package/extensions/telegram/src/runtime.ts +14 -0
- package/extensions/tlon/README.md +5 -0
- package/extensions/tlon/index.ts +17 -0
- package/extensions/tlon/node_modules/.bin/openclaw +21 -0
- package/extensions/tlon/openclaw.plugin.json +9 -0
- package/extensions/tlon/package.json +33 -0
- package/extensions/tlon/src/channel.ts +392 -0
- package/extensions/tlon/src/config-schema.test.ts +31 -0
- package/extensions/tlon/src/config-schema.ts +43 -0
- package/extensions/tlon/src/monitor/discovery.ts +76 -0
- package/extensions/tlon/src/monitor/history.ts +90 -0
- package/extensions/tlon/src/monitor/index.ts +553 -0
- package/extensions/tlon/src/monitor/processed-messages.test.ts +23 -0
- package/extensions/tlon/src/monitor/processed-messages.ts +46 -0
- package/extensions/tlon/src/monitor/utils.ts +105 -0
- package/extensions/tlon/src/onboarding.ts +214 -0
- package/extensions/tlon/src/runtime.ts +14 -0
- package/extensions/tlon/src/targets.ts +89 -0
- package/extensions/tlon/src/types.ts +92 -0
- package/extensions/tlon/src/urbit/auth.ts +18 -0
- package/extensions/tlon/src/urbit/http-api.ts +38 -0
- package/extensions/tlon/src/urbit/send.test.ts +38 -0
- package/extensions/tlon/src/urbit/send.ts +131 -0
- package/extensions/tlon/src/urbit/sse-client.test.ts +40 -0
- package/extensions/tlon/src/urbit/sse-client.ts +395 -0
- package/extensions/twitch/CHANGELOG.md +45 -0
- package/extensions/twitch/README.md +89 -0
- package/extensions/twitch/index.ts +20 -0
- package/extensions/twitch/node_modules/.bin/openclaw +21 -0
- package/extensions/twitch/openclaw.plugin.json +9 -0
- package/extensions/twitch/package.json +20 -0
- package/extensions/twitch/src/access-control.test.ts +489 -0
- package/extensions/twitch/src/access-control.ts +166 -0
- package/extensions/twitch/src/actions.ts +173 -0
- package/extensions/twitch/src/client-manager-registry.ts +115 -0
- package/extensions/twitch/src/config-schema.ts +82 -0
- package/extensions/twitch/src/config.test.ts +87 -0
- package/extensions/twitch/src/config.ts +116 -0
- package/extensions/twitch/src/monitor.ts +261 -0
- package/extensions/twitch/src/onboarding.test.ts +311 -0
- package/extensions/twitch/src/onboarding.ts +417 -0
- package/extensions/twitch/src/outbound.test.ts +373 -0
- package/extensions/twitch/src/outbound.ts +184 -0
- package/extensions/twitch/src/plugin.test.ts +39 -0
- package/extensions/twitch/src/plugin.ts +274 -0
- package/extensions/twitch/src/probe.test.ts +195 -0
- package/extensions/twitch/src/probe.ts +120 -0
- package/extensions/twitch/src/resolver.ts +137 -0
- package/extensions/twitch/src/runtime.ts +14 -0
- package/extensions/twitch/src/send.test.ts +289 -0
- package/extensions/twitch/src/send.ts +136 -0
- package/extensions/twitch/src/status.test.ts +270 -0
- package/extensions/twitch/src/status.ts +178 -0
- package/extensions/twitch/src/token.test.ts +171 -0
- package/extensions/twitch/src/token.ts +91 -0
- package/extensions/twitch/src/twitch-client.test.ts +589 -0
- package/extensions/twitch/src/twitch-client.ts +277 -0
- package/extensions/twitch/src/types.ts +141 -0
- package/extensions/twitch/src/utils/markdown.ts +98 -0
- package/extensions/twitch/src/utils/twitch.ts +78 -0
- package/extensions/twitch/test/setup.ts +7 -0
- package/extensions/voice-call/CHANGELOG.md +109 -0
- package/extensions/voice-call/README.md +139 -0
- package/extensions/voice-call/index.ts +493 -0
- package/extensions/voice-call/node_modules/.bin/openclaw +21 -0
- package/extensions/voice-call/openclaw.plugin.json +559 -0
- package/extensions/voice-call/package.json +19 -0
- package/extensions/voice-call/src/allowlist.ts +19 -0
- package/extensions/voice-call/src/cli.ts +279 -0
- package/extensions/voice-call/src/config.test.ts +234 -0
- package/extensions/voice-call/src/config.ts +523 -0
- package/extensions/voice-call/src/core-bridge.ts +159 -0
- package/extensions/voice-call/src/manager/context.ts +21 -0
- package/extensions/voice-call/src/manager/events.ts +188 -0
- package/extensions/voice-call/src/manager/lookup.ts +35 -0
- package/extensions/voice-call/src/manager/outbound.ts +275 -0
- package/extensions/voice-call/src/manager/state.ts +48 -0
- package/extensions/voice-call/src/manager/store.ts +91 -0
- package/extensions/voice-call/src/manager/timers.ts +89 -0
- package/extensions/voice-call/src/manager/twiml.ts +9 -0
- package/extensions/voice-call/src/manager.test.ts +194 -0
- package/extensions/voice-call/src/manager.ts +887 -0
- package/extensions/voice-call/src/media-stream.test.ts +96 -0
- package/extensions/voice-call/src/media-stream.ts +411 -0
- package/extensions/voice-call/src/providers/base.ts +67 -0
- package/extensions/voice-call/src/providers/index.ts +10 -0
- package/extensions/voice-call/src/providers/mock.ts +165 -0
- package/extensions/voice-call/src/providers/plivo.test.ts +27 -0
- package/extensions/voice-call/src/providers/plivo.ts +515 -0
- package/extensions/voice-call/src/providers/stt-openai-realtime.ts +311 -0
- package/extensions/voice-call/src/providers/telnyx.ts +371 -0
- package/extensions/voice-call/src/providers/tts-openai.ts +259 -0
- package/extensions/voice-call/src/providers/twilio/api.ts +42 -0
- package/extensions/voice-call/src/providers/twilio/webhook.ts +32 -0
- package/extensions/voice-call/src/providers/twilio.test.ts +60 -0
- package/extensions/voice-call/src/providers/twilio.ts +626 -0
- package/extensions/voice-call/src/response-generator.ts +158 -0
- package/extensions/voice-call/src/runtime.ts +212 -0
- package/extensions/voice-call/src/telephony-audio.ts +90 -0
- package/extensions/voice-call/src/telephony-tts.ts +104 -0
- package/extensions/voice-call/src/tunnel.ts +314 -0
- package/extensions/voice-call/src/types.ts +272 -0
- package/extensions/voice-call/src/utils.ts +14 -0
- package/extensions/voice-call/src/voice-mapping.ts +67 -0
- package/extensions/voice-call/src/webhook-security.test.ts +377 -0
- package/extensions/voice-call/src/webhook-security.ts +689 -0
- package/extensions/voice-call/src/webhook.ts +491 -0
- package/extensions/whatsapp/index.ts +17 -0
- package/extensions/whatsapp/node_modules/.bin/openclaw +21 -0
- package/extensions/whatsapp/openclaw.plugin.json +9 -0
- package/extensions/whatsapp/package.json +14 -0
- package/extensions/whatsapp/src/channel.ts +508 -0
- package/extensions/whatsapp/src/runtime.ts +14 -0
- package/extensions/zalo/CHANGELOG.md +89 -0
- package/extensions/zalo/README.md +50 -0
- package/extensions/zalo/index.ts +19 -0
- package/extensions/zalo/node_modules/.bin/openclaw +21 -0
- package/extensions/zalo/openclaw.plugin.json +9 -0
- package/extensions/zalo/package.json +36 -0
- package/extensions/zalo/src/accounts.ts +80 -0
- package/extensions/zalo/src/actions.ts +67 -0
- package/extensions/zalo/src/api.ts +208 -0
- package/extensions/zalo/src/channel.directory.test.ts +43 -0
- package/extensions/zalo/src/channel.ts +414 -0
- package/extensions/zalo/src/config-schema.ts +24 -0
- package/extensions/zalo/src/monitor.ts +753 -0
- package/extensions/zalo/src/monitor.webhook.test.ts +73 -0
- package/extensions/zalo/src/onboarding.ts +401 -0
- package/extensions/zalo/src/probe.ts +46 -0
- package/extensions/zalo/src/proxy.ts +21 -0
- package/extensions/zalo/src/runtime.ts +14 -0
- package/extensions/zalo/src/send.ts +124 -0
- package/extensions/zalo/src/status-issues.ts +53 -0
- package/extensions/zalo/src/token.ts +63 -0
- package/extensions/zalo/src/types.ts +42 -0
- package/extensions/zalouser/CHANGELOG.md +61 -0
- package/extensions/zalouser/README.md +225 -0
- package/extensions/zalouser/index.ts +31 -0
- package/extensions/zalouser/node_modules/.bin/openclaw +21 -0
- package/extensions/zalouser/openclaw.plugin.json +9 -0
- package/extensions/zalouser/package.json +36 -0
- package/extensions/zalouser/src/accounts.ts +135 -0
- package/extensions/zalouser/src/channel.test.ts +18 -0
- package/extensions/zalouser/src/channel.ts +686 -0
- package/extensions/zalouser/src/config-schema.ts +27 -0
- package/extensions/zalouser/src/monitor.ts +590 -0
- package/extensions/zalouser/src/onboarding.ts +504 -0
- package/extensions/zalouser/src/probe.ts +28 -0
- package/extensions/zalouser/src/runtime.ts +14 -0
- package/extensions/zalouser/src/send.ts +160 -0
- package/extensions/zalouser/src/status-issues.test.ts +57 -0
- package/extensions/zalouser/src/status-issues.ts +89 -0
- package/extensions/zalouser/src/tool.ts +164 -0
- package/extensions/zalouser/src/types.ts +108 -0
- package/extensions/zalouser/src/zca.ts +202 -0
- package/openclaw.mjs +14 -0
- package/package.json +245 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +96 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/bird/SKILL.md +224 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +131 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +198 -0
- package/skills/clawhub/SKILL.md +77 -0
- package/skills/coding-agent/SKILL.md +284 -0
- package/skills/discord/SKILL.md +578 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/food-order/SKILL.md +48 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/ghostly-projects/SKILL.md +160 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +74 -0
- package/skills/linear/SKILL.md +111 -0
- package/skills/linear/linear.sh +204 -0
- package/skills/local-places/SERVER_README.md +101 -0
- package/skills/local-places/SKILL.md +102 -0
- package/skills/local-places/pyproject.toml +21 -0
- package/skills/local-places/src/local_places/__init__.py +2 -0
- package/skills/local-places/src/local_places/google_places.py +314 -0
- package/skills/local-places/src/local_places/main.py +65 -0
- package/skills/local-places/src/local_places/schemas.py +107 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/model-usage/references/codexbar-cli.md +33 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/nano-banana-pro/SKILL.md +58 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/notion/SKILL.md +172 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-image-gen/SKILL.md +89 -0
- package/skills/openai-image-gen/scripts/gen.py +240 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +52 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +51 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +115 -0
- package/skills/sherpa-onnx-tts/SKILL.md +103 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +370 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +111 -0
- package/skills/skill-creator/scripts/quick_validate.py +101 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +46 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +135 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +95 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +54 -0
|
@@ -0,0 +1,2925 @@
|
|
|
1
|
+
import { r as STATE_DIR } from "./paths-scjhy7N2.js";
|
|
2
|
+
import { D as DEFAULT_AGENT_ID, E as DEFAULT_ACCOUNT_ID, F as resolveAgentIdFromSessionKey, M as normalizeAccountId$1, N as normalizeAgentId, P as normalizeMainKey, b as DEFAULT_USER_FILENAME, d as DEFAULT_AGENTS_FILENAME, f as DEFAULT_AGENT_WORKSPACE_DIR, h as DEFAULT_IDENTITY_FILENAME, k as buildAgentMainSessionKey, l as resolveSessionAgentId, m as DEFAULT_HEARTBEAT_FILENAME, n as resolveAgentConfig, p as DEFAULT_BOOTSTRAP_FILENAME, v as DEFAULT_SOUL_FILENAME, x as ensureAgentWorkspace, y as DEFAULT_TOOLS_FILENAME } from "./agent-scope-BbT4OG2N.js";
|
|
3
|
+
import { c as defaultRuntime, m as CHAT_CHANNEL_ORDER, p as CHANNEL_IDS, v as getChatChannelMeta, w as requireActivePluginRegistry } from "./subsystem-CAq3uyo7.js";
|
|
4
|
+
import { d as normalizeE164, h as resolveUserPath } from "./utils-CKSrBNwq.js";
|
|
5
|
+
import { t as formatCliCommand } from "./command-format-DELazozB.js";
|
|
6
|
+
import { i as loadConfig } from "./config-BtSTwPcH.js";
|
|
7
|
+
import { a as normalizeWhatsAppTarget, b as normalizeChatType, c as resolveTelegramAccount, m as resolveSlackReplyToMode, p as resolveSlackAccount, r as normalizeChannelId, v as resolveDiscordAccount } from "./plugins-QJjTXliB.js";
|
|
8
|
+
import { M as DEFAULT_OPENCLAW_BROWSER_COLOR, P as DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME, j as DEFAULT_BROWSER_EVALUATE_ENABLED } from "./chrome-BZ9K48w9.js";
|
|
9
|
+
import { o as syncSkillsToWorkspace } from "./skills-Tky2kCMO.js";
|
|
10
|
+
import { t as registerBrowserRoutes } from "./routes-ClNyEvlm.js";
|
|
11
|
+
import { a as resolveProfile, t as createBrowserRouteContext } from "./server-context-B9GX5GOI.js";
|
|
12
|
+
import { c as listDeliverableMessageChannels, l as normalizeMessageChannel } from "./message-channel-D6v_oPAg.js";
|
|
13
|
+
import { n as resolveWhatsAppAccount } from "./accounts-DzBgAM3C.js";
|
|
14
|
+
import { r as resolveSessionTranscriptPath, t as resolveDefaultSessionStorePath } from "./paths-B-q1nXdY.js";
|
|
15
|
+
import { t as emitSessionTranscriptUpdate } from "./transcript-events-CsB1Saa6.js";
|
|
16
|
+
import os from "node:os";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import JSON5 from "json5";
|
|
20
|
+
import fs$1 from "node:fs/promises";
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
22
|
+
import crypto from "node:crypto";
|
|
23
|
+
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
24
|
+
import express from "express";
|
|
25
|
+
|
|
26
|
+
//#region src/channels/conversation-label.ts
|
|
27
|
+
function extractConversationId(from) {
|
|
28
|
+
const trimmed = from?.trim();
|
|
29
|
+
if (!trimmed) return;
|
|
30
|
+
const parts = trimmed.split(":").filter(Boolean);
|
|
31
|
+
return parts.length > 0 ? parts[parts.length - 1] : trimmed;
|
|
32
|
+
}
|
|
33
|
+
function shouldAppendId(id) {
|
|
34
|
+
if (/^[0-9]+$/.test(id)) return true;
|
|
35
|
+
if (id.includes("@g.us")) return true;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
function resolveConversationLabel(ctx) {
|
|
39
|
+
const explicit = ctx.ConversationLabel?.trim();
|
|
40
|
+
if (explicit) return explicit;
|
|
41
|
+
const threadLabel = ctx.ThreadLabel?.trim();
|
|
42
|
+
if (threadLabel) return threadLabel;
|
|
43
|
+
if (normalizeChatType(ctx.ChatType) === "direct") return ctx.SenderName?.trim() || ctx.From?.trim() || void 0;
|
|
44
|
+
const base = ctx.GroupChannel?.trim() || ctx.GroupSubject?.trim() || ctx.GroupSpace?.trim() || ctx.From?.trim() || "";
|
|
45
|
+
if (!base) return;
|
|
46
|
+
const id = extractConversationId(ctx.From);
|
|
47
|
+
if (!id) return base;
|
|
48
|
+
if (!shouldAppendId(id)) return base;
|
|
49
|
+
if (base === id) return base;
|
|
50
|
+
if (base.includes(id)) return base;
|
|
51
|
+
if (base.toLowerCase().includes(" id:")) return base;
|
|
52
|
+
if (base.startsWith("#") || base.startsWith("@")) return base;
|
|
53
|
+
return `${base} id:${id}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/agents/sandbox/constants.ts
|
|
58
|
+
const DEFAULT_SANDBOX_WORKSPACE_ROOT = path.join(os.homedir(), ".openclaw", "sandboxes");
|
|
59
|
+
const DEFAULT_SANDBOX_IMAGE = "openclaw-sandbox:bookworm-slim";
|
|
60
|
+
const DEFAULT_SANDBOX_CONTAINER_PREFIX = "openclaw-sbx-";
|
|
61
|
+
const DEFAULT_SANDBOX_WORKDIR = "/workspace";
|
|
62
|
+
const DEFAULT_SANDBOX_IDLE_HOURS = 24;
|
|
63
|
+
const DEFAULT_SANDBOX_MAX_AGE_DAYS = 7;
|
|
64
|
+
const DEFAULT_TOOL_ALLOW = [
|
|
65
|
+
"exec",
|
|
66
|
+
"process",
|
|
67
|
+
"read",
|
|
68
|
+
"write",
|
|
69
|
+
"edit",
|
|
70
|
+
"apply_patch",
|
|
71
|
+
"image",
|
|
72
|
+
"sessions_list",
|
|
73
|
+
"sessions_history",
|
|
74
|
+
"sessions_send",
|
|
75
|
+
"sessions_spawn",
|
|
76
|
+
"session_status"
|
|
77
|
+
];
|
|
78
|
+
const DEFAULT_TOOL_DENY = [
|
|
79
|
+
"browser",
|
|
80
|
+
"canvas",
|
|
81
|
+
"nodes",
|
|
82
|
+
"cron",
|
|
83
|
+
"gateway",
|
|
84
|
+
...CHANNEL_IDS
|
|
85
|
+
];
|
|
86
|
+
const DEFAULT_SANDBOX_BROWSER_IMAGE = "openclaw-sandbox-browser:bookworm-slim";
|
|
87
|
+
const DEFAULT_SANDBOX_COMMON_IMAGE = "openclaw-sandbox-common:bookworm-slim";
|
|
88
|
+
const DEFAULT_SANDBOX_BROWSER_PREFIX = "openclaw-sbx-browser-";
|
|
89
|
+
const DEFAULT_SANDBOX_BROWSER_CDP_PORT = 9222;
|
|
90
|
+
const DEFAULT_SANDBOX_BROWSER_VNC_PORT = 5900;
|
|
91
|
+
const DEFAULT_SANDBOX_BROWSER_NOVNC_PORT = 6080;
|
|
92
|
+
const DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS = 12e3;
|
|
93
|
+
const SANDBOX_AGENT_WORKSPACE_MOUNT = "/agent";
|
|
94
|
+
const resolvedSandboxStateDir = STATE_DIR ?? path.join(os.homedir(), ".openclaw");
|
|
95
|
+
const SANDBOX_STATE_DIR = path.join(resolvedSandboxStateDir, "sandbox");
|
|
96
|
+
const SANDBOX_REGISTRY_PATH = path.join(SANDBOX_STATE_DIR, "containers.json");
|
|
97
|
+
const SANDBOX_BROWSER_REGISTRY_PATH = path.join(SANDBOX_STATE_DIR, "browsers.json");
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/agents/tool-policy.ts
|
|
101
|
+
const TOOL_NAME_ALIASES = {
|
|
102
|
+
bash: "exec",
|
|
103
|
+
"apply-patch": "apply_patch"
|
|
104
|
+
};
|
|
105
|
+
const TOOL_GROUPS = {
|
|
106
|
+
"group:memory": ["memory_search", "memory_get"],
|
|
107
|
+
"group:web": ["web_search", "web_fetch"],
|
|
108
|
+
"group:fs": [
|
|
109
|
+
"read",
|
|
110
|
+
"write",
|
|
111
|
+
"edit",
|
|
112
|
+
"apply_patch"
|
|
113
|
+
],
|
|
114
|
+
"group:runtime": ["exec", "process"],
|
|
115
|
+
"group:sessions": [
|
|
116
|
+
"sessions_list",
|
|
117
|
+
"sessions_history",
|
|
118
|
+
"sessions_send",
|
|
119
|
+
"sessions_spawn",
|
|
120
|
+
"session_status"
|
|
121
|
+
],
|
|
122
|
+
"group:ui": ["browser", "canvas"],
|
|
123
|
+
"group:automation": ["cron", "gateway"],
|
|
124
|
+
"group:messaging": ["message"],
|
|
125
|
+
"group:nodes": ["nodes"],
|
|
126
|
+
"group:openclaw": [
|
|
127
|
+
"browser",
|
|
128
|
+
"canvas",
|
|
129
|
+
"nodes",
|
|
130
|
+
"cron",
|
|
131
|
+
"message",
|
|
132
|
+
"gateway",
|
|
133
|
+
"agents_list",
|
|
134
|
+
"sessions_list",
|
|
135
|
+
"sessions_history",
|
|
136
|
+
"sessions_send",
|
|
137
|
+
"sessions_spawn",
|
|
138
|
+
"session_status",
|
|
139
|
+
"memory_search",
|
|
140
|
+
"memory_get",
|
|
141
|
+
"web_search",
|
|
142
|
+
"web_fetch",
|
|
143
|
+
"image"
|
|
144
|
+
]
|
|
145
|
+
};
|
|
146
|
+
const TOOL_PROFILES = {
|
|
147
|
+
minimal: { allow: ["session_status"] },
|
|
148
|
+
coding: { allow: [
|
|
149
|
+
"group:fs",
|
|
150
|
+
"group:runtime",
|
|
151
|
+
"group:sessions",
|
|
152
|
+
"group:memory",
|
|
153
|
+
"image"
|
|
154
|
+
] },
|
|
155
|
+
messaging: { allow: [
|
|
156
|
+
"group:messaging",
|
|
157
|
+
"sessions_list",
|
|
158
|
+
"sessions_history",
|
|
159
|
+
"sessions_send",
|
|
160
|
+
"session_status"
|
|
161
|
+
] },
|
|
162
|
+
full: {}
|
|
163
|
+
};
|
|
164
|
+
function normalizeToolName(name) {
|
|
165
|
+
const normalized = name.trim().toLowerCase();
|
|
166
|
+
return TOOL_NAME_ALIASES[normalized] ?? normalized;
|
|
167
|
+
}
|
|
168
|
+
function normalizeToolList(list) {
|
|
169
|
+
if (!list) return [];
|
|
170
|
+
return list.map(normalizeToolName).filter(Boolean);
|
|
171
|
+
}
|
|
172
|
+
function expandToolGroups(list) {
|
|
173
|
+
const normalized = normalizeToolList(list);
|
|
174
|
+
const expanded = [];
|
|
175
|
+
for (const value of normalized) {
|
|
176
|
+
const group = TOOL_GROUPS[value];
|
|
177
|
+
if (group) {
|
|
178
|
+
expanded.push(...group);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
expanded.push(value);
|
|
182
|
+
}
|
|
183
|
+
return Array.from(new Set(expanded));
|
|
184
|
+
}
|
|
185
|
+
function collectExplicitAllowlist(policies) {
|
|
186
|
+
const entries = [];
|
|
187
|
+
for (const policy of policies) {
|
|
188
|
+
if (!policy?.allow) continue;
|
|
189
|
+
for (const value of policy.allow) {
|
|
190
|
+
if (typeof value !== "string") continue;
|
|
191
|
+
const trimmed = value.trim();
|
|
192
|
+
if (trimmed) entries.push(trimmed);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return entries;
|
|
196
|
+
}
|
|
197
|
+
function buildPluginToolGroups(params) {
|
|
198
|
+
const all = [];
|
|
199
|
+
const byPlugin = /* @__PURE__ */ new Map();
|
|
200
|
+
for (const tool of params.tools) {
|
|
201
|
+
const meta = params.toolMeta(tool);
|
|
202
|
+
if (!meta) continue;
|
|
203
|
+
const name = normalizeToolName(tool.name);
|
|
204
|
+
all.push(name);
|
|
205
|
+
const pluginId = meta.pluginId.toLowerCase();
|
|
206
|
+
const list = byPlugin.get(pluginId) ?? [];
|
|
207
|
+
list.push(name);
|
|
208
|
+
byPlugin.set(pluginId, list);
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
all,
|
|
212
|
+
byPlugin
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function expandPluginGroups(list, groups) {
|
|
216
|
+
if (!list || list.length === 0) return list;
|
|
217
|
+
const expanded = [];
|
|
218
|
+
for (const entry of list) {
|
|
219
|
+
const normalized = normalizeToolName(entry);
|
|
220
|
+
if (normalized === "group:plugins") {
|
|
221
|
+
if (groups.all.length > 0) expanded.push(...groups.all);
|
|
222
|
+
else expanded.push(normalized);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const tools = groups.byPlugin.get(normalized);
|
|
226
|
+
if (tools && tools.length > 0) {
|
|
227
|
+
expanded.push(...tools);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
expanded.push(normalized);
|
|
231
|
+
}
|
|
232
|
+
return Array.from(new Set(expanded));
|
|
233
|
+
}
|
|
234
|
+
function expandPolicyWithPluginGroups(policy, groups) {
|
|
235
|
+
if (!policy) return;
|
|
236
|
+
return {
|
|
237
|
+
allow: expandPluginGroups(policy.allow, groups),
|
|
238
|
+
deny: expandPluginGroups(policy.deny, groups)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function stripPluginOnlyAllowlist(policy, groups, coreTools) {
|
|
242
|
+
if (!policy?.allow || policy.allow.length === 0) return {
|
|
243
|
+
policy,
|
|
244
|
+
unknownAllowlist: [],
|
|
245
|
+
strippedAllowlist: false
|
|
246
|
+
};
|
|
247
|
+
const normalized = normalizeToolList(policy.allow);
|
|
248
|
+
if (normalized.length === 0) return {
|
|
249
|
+
policy,
|
|
250
|
+
unknownAllowlist: [],
|
|
251
|
+
strippedAllowlist: false
|
|
252
|
+
};
|
|
253
|
+
const pluginIds = new Set(groups.byPlugin.keys());
|
|
254
|
+
const pluginTools = new Set(groups.all);
|
|
255
|
+
const unknownAllowlist = [];
|
|
256
|
+
let hasCoreEntry = false;
|
|
257
|
+
for (const entry of normalized) {
|
|
258
|
+
if (entry === "*") {
|
|
259
|
+
hasCoreEntry = true;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const isPluginEntry = entry === "group:plugins" || pluginIds.has(entry) || pluginTools.has(entry);
|
|
263
|
+
const isCoreEntry = expandToolGroups([entry]).some((tool) => coreTools.has(tool));
|
|
264
|
+
if (isCoreEntry) hasCoreEntry = true;
|
|
265
|
+
if (!isCoreEntry && !isPluginEntry) unknownAllowlist.push(entry);
|
|
266
|
+
}
|
|
267
|
+
const strippedAllowlist = !hasCoreEntry;
|
|
268
|
+
if (strippedAllowlist) {}
|
|
269
|
+
return {
|
|
270
|
+
policy: strippedAllowlist ? {
|
|
271
|
+
...policy,
|
|
272
|
+
allow: void 0
|
|
273
|
+
} : policy,
|
|
274
|
+
unknownAllowlist: Array.from(new Set(unknownAllowlist)),
|
|
275
|
+
strippedAllowlist
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function resolveToolProfilePolicy(profile) {
|
|
279
|
+
if (!profile) return;
|
|
280
|
+
const resolved = TOOL_PROFILES[profile];
|
|
281
|
+
if (!resolved) return;
|
|
282
|
+
if (!resolved.allow && !resolved.deny) return;
|
|
283
|
+
return {
|
|
284
|
+
allow: resolved.allow ? [...resolved.allow] : void 0,
|
|
285
|
+
deny: resolved.deny ? [...resolved.deny] : void 0
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/agents/sandbox/tool-policy.ts
|
|
291
|
+
function compilePattern(pattern) {
|
|
292
|
+
const normalized = pattern.trim().toLowerCase();
|
|
293
|
+
if (!normalized) return {
|
|
294
|
+
kind: "exact",
|
|
295
|
+
value: ""
|
|
296
|
+
};
|
|
297
|
+
if (normalized === "*") return { kind: "all" };
|
|
298
|
+
if (!normalized.includes("*")) return {
|
|
299
|
+
kind: "exact",
|
|
300
|
+
value: normalized
|
|
301
|
+
};
|
|
302
|
+
const escaped = normalized.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
303
|
+
return {
|
|
304
|
+
kind: "regex",
|
|
305
|
+
value: new RegExp(`^${escaped.replaceAll("\\*", ".*")}$`)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function compilePatterns(patterns) {
|
|
309
|
+
if (!Array.isArray(patterns)) return [];
|
|
310
|
+
return expandToolGroups(patterns).map(compilePattern).filter((pattern) => pattern.kind !== "exact" || pattern.value);
|
|
311
|
+
}
|
|
312
|
+
function matchesAny(name, patterns) {
|
|
313
|
+
for (const pattern of patterns) {
|
|
314
|
+
if (pattern.kind === "all") return true;
|
|
315
|
+
if (pattern.kind === "exact" && name === pattern.value) return true;
|
|
316
|
+
if (pattern.kind === "regex" && pattern.value.test(name)) return true;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
function isToolAllowed(policy, name) {
|
|
321
|
+
const normalized = name.trim().toLowerCase();
|
|
322
|
+
if (matchesAny(normalized, compilePatterns(policy.deny))) return false;
|
|
323
|
+
const allow = compilePatterns(policy.allow);
|
|
324
|
+
if (allow.length === 0) return true;
|
|
325
|
+
return matchesAny(normalized, allow);
|
|
326
|
+
}
|
|
327
|
+
function resolveSandboxToolPolicyForAgent(cfg, agentId) {
|
|
328
|
+
const agentConfig = cfg && agentId ? resolveAgentConfig(cfg, agentId) : void 0;
|
|
329
|
+
const agentAllow = agentConfig?.tools?.sandbox?.tools?.allow;
|
|
330
|
+
const agentDeny = agentConfig?.tools?.sandbox?.tools?.deny;
|
|
331
|
+
const globalAllow = cfg?.tools?.sandbox?.tools?.allow;
|
|
332
|
+
const globalDeny = cfg?.tools?.sandbox?.tools?.deny;
|
|
333
|
+
const allowSource = Array.isArray(agentAllow) ? {
|
|
334
|
+
source: "agent",
|
|
335
|
+
key: "agents.list[].tools.sandbox.tools.allow"
|
|
336
|
+
} : Array.isArray(globalAllow) ? {
|
|
337
|
+
source: "global",
|
|
338
|
+
key: "tools.sandbox.tools.allow"
|
|
339
|
+
} : {
|
|
340
|
+
source: "default",
|
|
341
|
+
key: "tools.sandbox.tools.allow"
|
|
342
|
+
};
|
|
343
|
+
const denySource = Array.isArray(agentDeny) ? {
|
|
344
|
+
source: "agent",
|
|
345
|
+
key: "agents.list[].tools.sandbox.tools.deny"
|
|
346
|
+
} : Array.isArray(globalDeny) ? {
|
|
347
|
+
source: "global",
|
|
348
|
+
key: "tools.sandbox.tools.deny"
|
|
349
|
+
} : {
|
|
350
|
+
source: "default",
|
|
351
|
+
key: "tools.sandbox.tools.deny"
|
|
352
|
+
};
|
|
353
|
+
const deny = Array.isArray(agentDeny) ? agentDeny : Array.isArray(globalDeny) ? globalDeny : [...DEFAULT_TOOL_DENY];
|
|
354
|
+
const allow = Array.isArray(agentAllow) ? agentAllow : Array.isArray(globalAllow) ? globalAllow : [...DEFAULT_TOOL_ALLOW];
|
|
355
|
+
const expandedDeny = expandToolGroups(deny);
|
|
356
|
+
let expandedAllow = expandToolGroups(allow);
|
|
357
|
+
if (!expandedDeny.map((v) => v.toLowerCase()).includes("image") && !expandedAllow.map((v) => v.toLowerCase()).includes("image")) expandedAllow = [...expandedAllow, "image"];
|
|
358
|
+
return {
|
|
359
|
+
allow: expandedAllow,
|
|
360
|
+
deny: expandedDeny,
|
|
361
|
+
sources: {
|
|
362
|
+
allow: allowSource,
|
|
363
|
+
deny: denySource
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/agents/sandbox/config.ts
|
|
370
|
+
function resolveSandboxScope(params) {
|
|
371
|
+
if (params.scope) return params.scope;
|
|
372
|
+
if (typeof params.perSession === "boolean") return params.perSession ? "session" : "shared";
|
|
373
|
+
return "agent";
|
|
374
|
+
}
|
|
375
|
+
function resolveSandboxDockerConfig(params) {
|
|
376
|
+
const agentDocker = params.scope === "shared" ? void 0 : params.agentDocker;
|
|
377
|
+
const globalDocker = params.globalDocker;
|
|
378
|
+
const env = agentDocker?.env ? {
|
|
379
|
+
...globalDocker?.env ?? { LANG: "C.UTF-8" },
|
|
380
|
+
...agentDocker.env
|
|
381
|
+
} : globalDocker?.env ?? { LANG: "C.UTF-8" };
|
|
382
|
+
const ulimits = agentDocker?.ulimits ? {
|
|
383
|
+
...globalDocker?.ulimits,
|
|
384
|
+
...agentDocker.ulimits
|
|
385
|
+
} : globalDocker?.ulimits;
|
|
386
|
+
const binds = [...globalDocker?.binds ?? [], ...agentDocker?.binds ?? []];
|
|
387
|
+
return {
|
|
388
|
+
image: agentDocker?.image ?? globalDocker?.image ?? DEFAULT_SANDBOX_IMAGE,
|
|
389
|
+
containerPrefix: agentDocker?.containerPrefix ?? globalDocker?.containerPrefix ?? DEFAULT_SANDBOX_CONTAINER_PREFIX,
|
|
390
|
+
workdir: agentDocker?.workdir ?? globalDocker?.workdir ?? DEFAULT_SANDBOX_WORKDIR,
|
|
391
|
+
readOnlyRoot: agentDocker?.readOnlyRoot ?? globalDocker?.readOnlyRoot ?? true,
|
|
392
|
+
tmpfs: agentDocker?.tmpfs ?? globalDocker?.tmpfs ?? [
|
|
393
|
+
"/tmp",
|
|
394
|
+
"/var/tmp",
|
|
395
|
+
"/run"
|
|
396
|
+
],
|
|
397
|
+
network: agentDocker?.network ?? globalDocker?.network ?? "none",
|
|
398
|
+
user: agentDocker?.user ?? globalDocker?.user,
|
|
399
|
+
capDrop: agentDocker?.capDrop ?? globalDocker?.capDrop ?? ["ALL"],
|
|
400
|
+
env,
|
|
401
|
+
setupCommand: agentDocker?.setupCommand ?? globalDocker?.setupCommand,
|
|
402
|
+
pidsLimit: agentDocker?.pidsLimit ?? globalDocker?.pidsLimit,
|
|
403
|
+
memory: agentDocker?.memory ?? globalDocker?.memory,
|
|
404
|
+
memorySwap: agentDocker?.memorySwap ?? globalDocker?.memorySwap,
|
|
405
|
+
cpus: agentDocker?.cpus ?? globalDocker?.cpus,
|
|
406
|
+
ulimits,
|
|
407
|
+
seccompProfile: agentDocker?.seccompProfile ?? globalDocker?.seccompProfile,
|
|
408
|
+
apparmorProfile: agentDocker?.apparmorProfile ?? globalDocker?.apparmorProfile,
|
|
409
|
+
dns: agentDocker?.dns ?? globalDocker?.dns,
|
|
410
|
+
extraHosts: agentDocker?.extraHosts ?? globalDocker?.extraHosts,
|
|
411
|
+
binds: binds.length ? binds : void 0
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function resolveSandboxBrowserConfig(params) {
|
|
415
|
+
const agentBrowser = params.scope === "shared" ? void 0 : params.agentBrowser;
|
|
416
|
+
const globalBrowser = params.globalBrowser;
|
|
417
|
+
return {
|
|
418
|
+
enabled: agentBrowser?.enabled ?? globalBrowser?.enabled ?? false,
|
|
419
|
+
image: agentBrowser?.image ?? globalBrowser?.image ?? DEFAULT_SANDBOX_BROWSER_IMAGE,
|
|
420
|
+
containerPrefix: agentBrowser?.containerPrefix ?? globalBrowser?.containerPrefix ?? DEFAULT_SANDBOX_BROWSER_PREFIX,
|
|
421
|
+
cdpPort: agentBrowser?.cdpPort ?? globalBrowser?.cdpPort ?? DEFAULT_SANDBOX_BROWSER_CDP_PORT,
|
|
422
|
+
vncPort: agentBrowser?.vncPort ?? globalBrowser?.vncPort ?? DEFAULT_SANDBOX_BROWSER_VNC_PORT,
|
|
423
|
+
noVncPort: agentBrowser?.noVncPort ?? globalBrowser?.noVncPort ?? DEFAULT_SANDBOX_BROWSER_NOVNC_PORT,
|
|
424
|
+
headless: agentBrowser?.headless ?? globalBrowser?.headless ?? false,
|
|
425
|
+
enableNoVnc: agentBrowser?.enableNoVnc ?? globalBrowser?.enableNoVnc ?? true,
|
|
426
|
+
allowHostControl: agentBrowser?.allowHostControl ?? globalBrowser?.allowHostControl ?? false,
|
|
427
|
+
autoStart: agentBrowser?.autoStart ?? globalBrowser?.autoStart ?? true,
|
|
428
|
+
autoStartTimeoutMs: agentBrowser?.autoStartTimeoutMs ?? globalBrowser?.autoStartTimeoutMs ?? DEFAULT_SANDBOX_BROWSER_AUTOSTART_TIMEOUT_MS
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function resolveSandboxPruneConfig(params) {
|
|
432
|
+
const agentPrune = params.scope === "shared" ? void 0 : params.agentPrune;
|
|
433
|
+
const globalPrune = params.globalPrune;
|
|
434
|
+
return {
|
|
435
|
+
idleHours: agentPrune?.idleHours ?? globalPrune?.idleHours ?? DEFAULT_SANDBOX_IDLE_HOURS,
|
|
436
|
+
maxAgeDays: agentPrune?.maxAgeDays ?? globalPrune?.maxAgeDays ?? DEFAULT_SANDBOX_MAX_AGE_DAYS
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function resolveSandboxConfigForAgent(cfg, agentId) {
|
|
440
|
+
const agent = cfg?.agents?.defaults?.sandbox;
|
|
441
|
+
let agentSandbox;
|
|
442
|
+
const agentConfig = cfg && agentId ? resolveAgentConfig(cfg, agentId) : void 0;
|
|
443
|
+
if (agentConfig?.sandbox) agentSandbox = agentConfig.sandbox;
|
|
444
|
+
const scope = resolveSandboxScope({
|
|
445
|
+
scope: agentSandbox?.scope ?? agent?.scope,
|
|
446
|
+
perSession: agentSandbox?.perSession ?? agent?.perSession
|
|
447
|
+
});
|
|
448
|
+
const toolPolicy = resolveSandboxToolPolicyForAgent(cfg, agentId);
|
|
449
|
+
return {
|
|
450
|
+
mode: agentSandbox?.mode ?? agent?.mode ?? "off",
|
|
451
|
+
scope,
|
|
452
|
+
workspaceAccess: agentSandbox?.workspaceAccess ?? agent?.workspaceAccess ?? "none",
|
|
453
|
+
workspaceRoot: agentSandbox?.workspaceRoot ?? agent?.workspaceRoot ?? DEFAULT_SANDBOX_WORKSPACE_ROOT,
|
|
454
|
+
docker: resolveSandboxDockerConfig({
|
|
455
|
+
scope,
|
|
456
|
+
globalDocker: agent?.docker,
|
|
457
|
+
agentDocker: agentSandbox?.docker
|
|
458
|
+
}),
|
|
459
|
+
browser: resolveSandboxBrowserConfig({
|
|
460
|
+
scope,
|
|
461
|
+
globalBrowser: agent?.browser,
|
|
462
|
+
agentBrowser: agentSandbox?.browser
|
|
463
|
+
}),
|
|
464
|
+
tools: {
|
|
465
|
+
allow: toolPolicy.allow,
|
|
466
|
+
deny: toolPolicy.deny
|
|
467
|
+
},
|
|
468
|
+
prune: resolveSandboxPruneConfig({
|
|
469
|
+
scope,
|
|
470
|
+
globalPrune: agent?.prune,
|
|
471
|
+
agentPrune: agentSandbox?.prune
|
|
472
|
+
})
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/browser/bridge-server.ts
|
|
478
|
+
async function startBrowserBridgeServer(params) {
|
|
479
|
+
const host = params.host ?? "127.0.0.1";
|
|
480
|
+
const port = params.port ?? 0;
|
|
481
|
+
const app = express();
|
|
482
|
+
app.use(express.json({ limit: "1mb" }));
|
|
483
|
+
const authToken = params.authToken?.trim();
|
|
484
|
+
if (authToken) app.use((req, res, next) => {
|
|
485
|
+
if (String(req.headers.authorization ?? "").trim() === `Bearer ${authToken}`) return next();
|
|
486
|
+
res.status(401).send("Unauthorized");
|
|
487
|
+
});
|
|
488
|
+
const state = {
|
|
489
|
+
server: null,
|
|
490
|
+
port,
|
|
491
|
+
resolved: params.resolved,
|
|
492
|
+
profiles: /* @__PURE__ */ new Map()
|
|
493
|
+
};
|
|
494
|
+
registerBrowserRoutes(app, createBrowserRouteContext({
|
|
495
|
+
getState: () => state,
|
|
496
|
+
onEnsureAttachTarget: params.onEnsureAttachTarget
|
|
497
|
+
}));
|
|
498
|
+
const server = await new Promise((resolve, reject) => {
|
|
499
|
+
const s = app.listen(port, host, () => resolve(s));
|
|
500
|
+
s.once("error", reject);
|
|
501
|
+
});
|
|
502
|
+
const resolvedPort = server.address()?.port ?? port;
|
|
503
|
+
state.server = server;
|
|
504
|
+
state.port = resolvedPort;
|
|
505
|
+
state.resolved.controlPort = resolvedPort;
|
|
506
|
+
return {
|
|
507
|
+
server,
|
|
508
|
+
port: resolvedPort,
|
|
509
|
+
baseUrl: `http://${host}:${resolvedPort}`,
|
|
510
|
+
state
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
async function stopBrowserBridgeServer(server) {
|
|
514
|
+
await new Promise((resolve) => {
|
|
515
|
+
server.close(() => resolve());
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/agents/sandbox/browser-bridges.ts
|
|
521
|
+
const BROWSER_BRIDGES = /* @__PURE__ */ new Map();
|
|
522
|
+
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/agents/sandbox/config-hash.ts
|
|
525
|
+
function isPrimitive(value) {
|
|
526
|
+
return value === null || typeof value !== "object" && typeof value !== "function";
|
|
527
|
+
}
|
|
528
|
+
function normalizeForHash(value) {
|
|
529
|
+
if (value === void 0) return;
|
|
530
|
+
if (Array.isArray(value)) {
|
|
531
|
+
const normalized = value.map(normalizeForHash).filter((item) => item !== void 0);
|
|
532
|
+
const primitives = normalized.filter(isPrimitive);
|
|
533
|
+
if (primitives.length === normalized.length) return [...primitives].toSorted((a, b) => primitiveToString(a).localeCompare(primitiveToString(b)));
|
|
534
|
+
return normalized;
|
|
535
|
+
}
|
|
536
|
+
if (value && typeof value === "object") {
|
|
537
|
+
const entries = Object.entries(value).toSorted(([a], [b]) => a.localeCompare(b));
|
|
538
|
+
const normalized = {};
|
|
539
|
+
for (const [key, entryValue] of entries) {
|
|
540
|
+
const next = normalizeForHash(entryValue);
|
|
541
|
+
if (next !== void 0) normalized[key] = next;
|
|
542
|
+
}
|
|
543
|
+
return normalized;
|
|
544
|
+
}
|
|
545
|
+
return value;
|
|
546
|
+
}
|
|
547
|
+
function primitiveToString(value) {
|
|
548
|
+
if (value === null) return "null";
|
|
549
|
+
if (typeof value === "string") return value;
|
|
550
|
+
if (typeof value === "number") return String(value);
|
|
551
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
552
|
+
return JSON.stringify(value);
|
|
553
|
+
}
|
|
554
|
+
function computeSandboxConfigHash(input) {
|
|
555
|
+
const payload = normalizeForHash(input);
|
|
556
|
+
const raw = JSON.stringify(payload);
|
|
557
|
+
return crypto.createHash("sha1").update(raw).digest("hex");
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/agents/sandbox/registry.ts
|
|
562
|
+
async function readRegistry() {
|
|
563
|
+
try {
|
|
564
|
+
const raw = await fs$1.readFile(SANDBOX_REGISTRY_PATH, "utf-8");
|
|
565
|
+
const parsed = JSON.parse(raw);
|
|
566
|
+
if (parsed && Array.isArray(parsed.entries)) return parsed;
|
|
567
|
+
} catch {}
|
|
568
|
+
return { entries: [] };
|
|
569
|
+
}
|
|
570
|
+
async function writeRegistry(registry) {
|
|
571
|
+
await fs$1.mkdir(SANDBOX_STATE_DIR, { recursive: true });
|
|
572
|
+
await fs$1.writeFile(SANDBOX_REGISTRY_PATH, `${JSON.stringify(registry, null, 2)}\n`, "utf-8");
|
|
573
|
+
}
|
|
574
|
+
async function updateRegistry(entry) {
|
|
575
|
+
const registry = await readRegistry();
|
|
576
|
+
const existing = registry.entries.find((item) => item.containerName === entry.containerName);
|
|
577
|
+
const next = registry.entries.filter((item) => item.containerName !== entry.containerName);
|
|
578
|
+
next.push({
|
|
579
|
+
...entry,
|
|
580
|
+
createdAtMs: existing?.createdAtMs ?? entry.createdAtMs,
|
|
581
|
+
image: existing?.image ?? entry.image,
|
|
582
|
+
configHash: entry.configHash ?? existing?.configHash
|
|
583
|
+
});
|
|
584
|
+
await writeRegistry({ entries: next });
|
|
585
|
+
}
|
|
586
|
+
async function removeRegistryEntry(containerName) {
|
|
587
|
+
const registry = await readRegistry();
|
|
588
|
+
const next = registry.entries.filter((item) => item.containerName !== containerName);
|
|
589
|
+
if (next.length === registry.entries.length) return;
|
|
590
|
+
await writeRegistry({ entries: next });
|
|
591
|
+
}
|
|
592
|
+
async function readBrowserRegistry() {
|
|
593
|
+
try {
|
|
594
|
+
const raw = await fs$1.readFile(SANDBOX_BROWSER_REGISTRY_PATH, "utf-8");
|
|
595
|
+
const parsed = JSON.parse(raw);
|
|
596
|
+
if (parsed && Array.isArray(parsed.entries)) return parsed;
|
|
597
|
+
} catch {}
|
|
598
|
+
return { entries: [] };
|
|
599
|
+
}
|
|
600
|
+
async function writeBrowserRegistry(registry) {
|
|
601
|
+
await fs$1.mkdir(SANDBOX_STATE_DIR, { recursive: true });
|
|
602
|
+
await fs$1.writeFile(SANDBOX_BROWSER_REGISTRY_PATH, `${JSON.stringify(registry, null, 2)}\n`, "utf-8");
|
|
603
|
+
}
|
|
604
|
+
async function updateBrowserRegistry(entry) {
|
|
605
|
+
const registry = await readBrowserRegistry();
|
|
606
|
+
const existing = registry.entries.find((item) => item.containerName === entry.containerName);
|
|
607
|
+
const next = registry.entries.filter((item) => item.containerName !== entry.containerName);
|
|
608
|
+
next.push({
|
|
609
|
+
...entry,
|
|
610
|
+
createdAtMs: existing?.createdAtMs ?? entry.createdAtMs,
|
|
611
|
+
image: existing?.image ?? entry.image
|
|
612
|
+
});
|
|
613
|
+
await writeBrowserRegistry({ entries: next });
|
|
614
|
+
}
|
|
615
|
+
async function removeBrowserRegistryEntry(containerName) {
|
|
616
|
+
const registry = await readBrowserRegistry();
|
|
617
|
+
const next = registry.entries.filter((item) => item.containerName !== containerName);
|
|
618
|
+
if (next.length === registry.entries.length) return;
|
|
619
|
+
await writeBrowserRegistry({ entries: next });
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
//#endregion
|
|
623
|
+
//#region src/agents/sandbox/shared.ts
|
|
624
|
+
function slugifySessionKey(value) {
|
|
625
|
+
const trimmed = value.trim() || "session";
|
|
626
|
+
const hash = crypto.createHash("sha1").update(trimmed).digest("hex").slice(0, 8);
|
|
627
|
+
return `${trimmed.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "session"}-${hash}`;
|
|
628
|
+
}
|
|
629
|
+
function resolveSandboxWorkspaceDir(root, sessionKey) {
|
|
630
|
+
const resolvedRoot = resolveUserPath(root);
|
|
631
|
+
const slug = slugifySessionKey(sessionKey);
|
|
632
|
+
return path.join(resolvedRoot, slug);
|
|
633
|
+
}
|
|
634
|
+
function resolveSandboxScopeKey(scope, sessionKey) {
|
|
635
|
+
const trimmed = sessionKey.trim() || "main";
|
|
636
|
+
if (scope === "shared") return "shared";
|
|
637
|
+
if (scope === "session") return trimmed;
|
|
638
|
+
return `agent:${resolveAgentIdFromSessionKey(trimmed)}`;
|
|
639
|
+
}
|
|
640
|
+
function resolveSandboxAgentId(scopeKey) {
|
|
641
|
+
const trimmed = scopeKey.trim();
|
|
642
|
+
if (!trimmed || trimmed === "shared") return;
|
|
643
|
+
const parts = trimmed.split(":").filter(Boolean);
|
|
644
|
+
if (parts[0] === "agent" && parts[1]) return normalizeAgentId(parts[1]);
|
|
645
|
+
return resolveAgentIdFromSessionKey(trimmed);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/agents/sandbox/docker.ts
|
|
650
|
+
const HOT_CONTAINER_WINDOW_MS = 300 * 1e3;
|
|
651
|
+
function execDocker(args, opts) {
|
|
652
|
+
return new Promise((resolve, reject) => {
|
|
653
|
+
const child = spawn("docker", args, { stdio: [
|
|
654
|
+
"ignore",
|
|
655
|
+
"pipe",
|
|
656
|
+
"pipe"
|
|
657
|
+
] });
|
|
658
|
+
let stdout = "";
|
|
659
|
+
let stderr = "";
|
|
660
|
+
child.stdout?.on("data", (chunk) => {
|
|
661
|
+
stdout += chunk.toString();
|
|
662
|
+
});
|
|
663
|
+
child.stderr?.on("data", (chunk) => {
|
|
664
|
+
stderr += chunk.toString();
|
|
665
|
+
});
|
|
666
|
+
child.on("close", (code) => {
|
|
667
|
+
const exitCode = code ?? 0;
|
|
668
|
+
if (exitCode !== 0 && !opts?.allowFailure) {
|
|
669
|
+
reject(new Error(stderr.trim() || `docker ${args.join(" ")} failed`));
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
resolve({
|
|
673
|
+
stdout,
|
|
674
|
+
stderr,
|
|
675
|
+
code: exitCode
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
async function readDockerPort(containerName, port) {
|
|
681
|
+
const result = await execDocker([
|
|
682
|
+
"port",
|
|
683
|
+
containerName,
|
|
684
|
+
`${port}/tcp`
|
|
685
|
+
], { allowFailure: true });
|
|
686
|
+
if (result.code !== 0) return null;
|
|
687
|
+
const match = (result.stdout.trim().split(/\r?\n/)[0] ?? "").match(/:(\d+)\s*$/);
|
|
688
|
+
if (!match) return null;
|
|
689
|
+
const mapped = Number.parseInt(match[1] ?? "", 10);
|
|
690
|
+
return Number.isFinite(mapped) ? mapped : null;
|
|
691
|
+
}
|
|
692
|
+
async function dockerImageExists(image) {
|
|
693
|
+
const result = await execDocker([
|
|
694
|
+
"image",
|
|
695
|
+
"inspect",
|
|
696
|
+
image
|
|
697
|
+
], { allowFailure: true });
|
|
698
|
+
if (result.code === 0) return true;
|
|
699
|
+
const stderr = result.stderr.trim();
|
|
700
|
+
if (stderr.includes("No such image")) return false;
|
|
701
|
+
throw new Error(`Failed to inspect sandbox image: ${stderr}`);
|
|
702
|
+
}
|
|
703
|
+
async function ensureDockerImage(image) {
|
|
704
|
+
if (await dockerImageExists(image)) return;
|
|
705
|
+
if (image === DEFAULT_SANDBOX_IMAGE) {
|
|
706
|
+
await execDocker(["pull", "debian:bookworm-slim"]);
|
|
707
|
+
await execDocker([
|
|
708
|
+
"tag",
|
|
709
|
+
"debian:bookworm-slim",
|
|
710
|
+
DEFAULT_SANDBOX_IMAGE
|
|
711
|
+
]);
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
throw new Error(`Sandbox image not found: ${image}. Build or pull it first.`);
|
|
715
|
+
}
|
|
716
|
+
async function dockerContainerState(name) {
|
|
717
|
+
const result = await execDocker([
|
|
718
|
+
"inspect",
|
|
719
|
+
"-f",
|
|
720
|
+
"{{.State.Running}}",
|
|
721
|
+
name
|
|
722
|
+
], { allowFailure: true });
|
|
723
|
+
if (result.code !== 0) return {
|
|
724
|
+
exists: false,
|
|
725
|
+
running: false
|
|
726
|
+
};
|
|
727
|
+
return {
|
|
728
|
+
exists: true,
|
|
729
|
+
running: result.stdout.trim() === "true"
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function normalizeDockerLimit(value) {
|
|
733
|
+
if (value === void 0 || value === null) return;
|
|
734
|
+
if (typeof value === "number") return Number.isFinite(value) ? String(value) : void 0;
|
|
735
|
+
const trimmed = value.trim();
|
|
736
|
+
return trimmed ? trimmed : void 0;
|
|
737
|
+
}
|
|
738
|
+
function formatUlimitValue(name, value) {
|
|
739
|
+
if (!name.trim()) return null;
|
|
740
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
741
|
+
const raw = String(value).trim();
|
|
742
|
+
return raw ? `${name}=${raw}` : null;
|
|
743
|
+
}
|
|
744
|
+
const soft = typeof value.soft === "number" ? Math.max(0, value.soft) : void 0;
|
|
745
|
+
const hard = typeof value.hard === "number" ? Math.max(0, value.hard) : void 0;
|
|
746
|
+
if (soft === void 0 && hard === void 0) return null;
|
|
747
|
+
if (soft === void 0) return `${name}=${hard}`;
|
|
748
|
+
if (hard === void 0) return `${name}=${soft}`;
|
|
749
|
+
return `${name}=${soft}:${hard}`;
|
|
750
|
+
}
|
|
751
|
+
function buildSandboxCreateArgs(params) {
|
|
752
|
+
const createdAtMs = params.createdAtMs ?? Date.now();
|
|
753
|
+
const args = [
|
|
754
|
+
"create",
|
|
755
|
+
"--name",
|
|
756
|
+
params.name
|
|
757
|
+
];
|
|
758
|
+
args.push("--label", "openclaw.sandbox=1");
|
|
759
|
+
args.push("--label", `openclaw.sessionKey=${params.scopeKey}`);
|
|
760
|
+
args.push("--label", `openclaw.createdAtMs=${createdAtMs}`);
|
|
761
|
+
if (params.configHash) args.push("--label", `openclaw.configHash=${params.configHash}`);
|
|
762
|
+
for (const [key, value] of Object.entries(params.labels ?? {})) if (key && value) args.push("--label", `${key}=${value}`);
|
|
763
|
+
if (params.cfg.readOnlyRoot) args.push("--read-only");
|
|
764
|
+
for (const entry of params.cfg.tmpfs) args.push("--tmpfs", entry);
|
|
765
|
+
if (params.cfg.network) args.push("--network", params.cfg.network);
|
|
766
|
+
if (params.cfg.user) args.push("--user", params.cfg.user);
|
|
767
|
+
for (const cap of params.cfg.capDrop) args.push("--cap-drop", cap);
|
|
768
|
+
args.push("--security-opt", "no-new-privileges");
|
|
769
|
+
if (params.cfg.seccompProfile) args.push("--security-opt", `seccomp=${params.cfg.seccompProfile}`);
|
|
770
|
+
if (params.cfg.apparmorProfile) args.push("--security-opt", `apparmor=${params.cfg.apparmorProfile}`);
|
|
771
|
+
for (const entry of params.cfg.dns ?? []) if (entry.trim()) args.push("--dns", entry);
|
|
772
|
+
for (const entry of params.cfg.extraHosts ?? []) if (entry.trim()) args.push("--add-host", entry);
|
|
773
|
+
if (typeof params.cfg.pidsLimit === "number" && params.cfg.pidsLimit > 0) args.push("--pids-limit", String(params.cfg.pidsLimit));
|
|
774
|
+
const memory = normalizeDockerLimit(params.cfg.memory);
|
|
775
|
+
if (memory) args.push("--memory", memory);
|
|
776
|
+
const memorySwap = normalizeDockerLimit(params.cfg.memorySwap);
|
|
777
|
+
if (memorySwap) args.push("--memory-swap", memorySwap);
|
|
778
|
+
if (typeof params.cfg.cpus === "number" && params.cfg.cpus > 0) args.push("--cpus", String(params.cfg.cpus));
|
|
779
|
+
for (const [name, value] of Object.entries(params.cfg.ulimits ?? {})) {
|
|
780
|
+
const formatted = formatUlimitValue(name, value);
|
|
781
|
+
if (formatted) args.push("--ulimit", formatted);
|
|
782
|
+
}
|
|
783
|
+
if (params.cfg.binds?.length) for (const bind of params.cfg.binds) args.push("-v", bind);
|
|
784
|
+
return args;
|
|
785
|
+
}
|
|
786
|
+
async function createSandboxContainer(params) {
|
|
787
|
+
const { name, cfg, workspaceDir, scopeKey } = params;
|
|
788
|
+
await ensureDockerImage(cfg.image);
|
|
789
|
+
const args = buildSandboxCreateArgs({
|
|
790
|
+
name,
|
|
791
|
+
cfg,
|
|
792
|
+
scopeKey,
|
|
793
|
+
configHash: params.configHash
|
|
794
|
+
});
|
|
795
|
+
args.push("--workdir", cfg.workdir);
|
|
796
|
+
const mainMountSuffix = params.workspaceAccess === "ro" && workspaceDir === params.agentWorkspaceDir ? ":ro" : "";
|
|
797
|
+
args.push("-v", `${workspaceDir}:${cfg.workdir}${mainMountSuffix}`);
|
|
798
|
+
if (params.workspaceAccess !== "none" && workspaceDir !== params.agentWorkspaceDir) {
|
|
799
|
+
const agentMountSuffix = params.workspaceAccess === "ro" ? ":ro" : "";
|
|
800
|
+
args.push("-v", `${params.agentWorkspaceDir}:${SANDBOX_AGENT_WORKSPACE_MOUNT}${agentMountSuffix}`);
|
|
801
|
+
}
|
|
802
|
+
args.push(cfg.image, "sleep", "infinity");
|
|
803
|
+
await execDocker(args);
|
|
804
|
+
await execDocker(["start", name]);
|
|
805
|
+
if (cfg.setupCommand?.trim()) await execDocker([
|
|
806
|
+
"exec",
|
|
807
|
+
"-i",
|
|
808
|
+
name,
|
|
809
|
+
"sh",
|
|
810
|
+
"-lc",
|
|
811
|
+
cfg.setupCommand
|
|
812
|
+
]);
|
|
813
|
+
}
|
|
814
|
+
async function readContainerConfigHash(containerName) {
|
|
815
|
+
const readLabel = async (label) => {
|
|
816
|
+
const result = await execDocker([
|
|
817
|
+
"inspect",
|
|
818
|
+
"-f",
|
|
819
|
+
`{{ index .Config.Labels "${label}" }}`,
|
|
820
|
+
containerName
|
|
821
|
+
], { allowFailure: true });
|
|
822
|
+
if (result.code !== 0) return null;
|
|
823
|
+
const raw = result.stdout.trim();
|
|
824
|
+
if (!raw || raw === "<no value>") return null;
|
|
825
|
+
return raw;
|
|
826
|
+
};
|
|
827
|
+
return await readLabel("openclaw.configHash");
|
|
828
|
+
}
|
|
829
|
+
function formatSandboxRecreateHint(params) {
|
|
830
|
+
if (params.scope === "session") return formatCliCommand(`openclaw sandbox recreate --session ${params.sessionKey}`);
|
|
831
|
+
if (params.scope === "agent") return formatCliCommand(`openclaw sandbox recreate --agent ${resolveSandboxAgentId(params.sessionKey) ?? "main"}`);
|
|
832
|
+
return formatCliCommand("openclaw sandbox recreate --all");
|
|
833
|
+
}
|
|
834
|
+
async function ensureSandboxContainer(params) {
|
|
835
|
+
const scopeKey = resolveSandboxScopeKey(params.cfg.scope, params.sessionKey);
|
|
836
|
+
const slug = params.cfg.scope === "shared" ? "shared" : slugifySessionKey(scopeKey);
|
|
837
|
+
const containerName = `${params.cfg.docker.containerPrefix}${slug}`.slice(0, 63);
|
|
838
|
+
const expectedHash = computeSandboxConfigHash({
|
|
839
|
+
docker: params.cfg.docker,
|
|
840
|
+
workspaceAccess: params.cfg.workspaceAccess,
|
|
841
|
+
workspaceDir: params.workspaceDir,
|
|
842
|
+
agentWorkspaceDir: params.agentWorkspaceDir
|
|
843
|
+
});
|
|
844
|
+
const now = Date.now();
|
|
845
|
+
const state = await dockerContainerState(containerName);
|
|
846
|
+
let hasContainer = state.exists;
|
|
847
|
+
let running = state.running;
|
|
848
|
+
let currentHash = null;
|
|
849
|
+
let hashMismatch = false;
|
|
850
|
+
let registryEntry;
|
|
851
|
+
if (hasContainer) {
|
|
852
|
+
registryEntry = (await readRegistry()).entries.find((entry) => entry.containerName === containerName);
|
|
853
|
+
currentHash = await readContainerConfigHash(containerName);
|
|
854
|
+
if (!currentHash) currentHash = registryEntry?.configHash ?? null;
|
|
855
|
+
hashMismatch = !currentHash || currentHash !== expectedHash;
|
|
856
|
+
if (hashMismatch) {
|
|
857
|
+
const lastUsedAtMs = registryEntry?.lastUsedAtMs;
|
|
858
|
+
if (running && (typeof lastUsedAtMs !== "number" || now - lastUsedAtMs < HOT_CONTAINER_WINDOW_MS)) {
|
|
859
|
+
const hint = formatSandboxRecreateHint({
|
|
860
|
+
scope: params.cfg.scope,
|
|
861
|
+
sessionKey: scopeKey
|
|
862
|
+
});
|
|
863
|
+
defaultRuntime.log(`Sandbox config changed for ${containerName} (recently used). Recreate to apply: ${hint}`);
|
|
864
|
+
} else {
|
|
865
|
+
await execDocker([
|
|
866
|
+
"rm",
|
|
867
|
+
"-f",
|
|
868
|
+
containerName
|
|
869
|
+
], { allowFailure: true });
|
|
870
|
+
hasContainer = false;
|
|
871
|
+
running = false;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
if (!hasContainer) await createSandboxContainer({
|
|
876
|
+
name: containerName,
|
|
877
|
+
cfg: params.cfg.docker,
|
|
878
|
+
workspaceDir: params.workspaceDir,
|
|
879
|
+
workspaceAccess: params.cfg.workspaceAccess,
|
|
880
|
+
agentWorkspaceDir: params.agentWorkspaceDir,
|
|
881
|
+
scopeKey,
|
|
882
|
+
configHash: expectedHash
|
|
883
|
+
});
|
|
884
|
+
else if (!running) await execDocker(["start", containerName]);
|
|
885
|
+
await updateRegistry({
|
|
886
|
+
containerName,
|
|
887
|
+
sessionKey: scopeKey,
|
|
888
|
+
createdAtMs: now,
|
|
889
|
+
lastUsedAtMs: now,
|
|
890
|
+
image: params.cfg.docker.image,
|
|
891
|
+
configHash: hashMismatch && running ? currentHash ?? void 0 : expectedHash
|
|
892
|
+
});
|
|
893
|
+
return containerName;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/agents/sandbox/browser.ts
|
|
898
|
+
async function waitForSandboxCdp(params) {
|
|
899
|
+
const deadline = Date.now() + Math.max(0, params.timeoutMs);
|
|
900
|
+
const url = `http://127.0.0.1:${params.cdpPort}/json/version`;
|
|
901
|
+
while (Date.now() < deadline) {
|
|
902
|
+
try {
|
|
903
|
+
const ctrl = new AbortController();
|
|
904
|
+
const t = setTimeout(() => ctrl.abort(), 1e3);
|
|
905
|
+
try {
|
|
906
|
+
if ((await fetch(url, { signal: ctrl.signal })).ok) return true;
|
|
907
|
+
} finally {
|
|
908
|
+
clearTimeout(t);
|
|
909
|
+
}
|
|
910
|
+
} catch {}
|
|
911
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
912
|
+
}
|
|
913
|
+
return false;
|
|
914
|
+
}
|
|
915
|
+
function buildSandboxBrowserResolvedConfig(params) {
|
|
916
|
+
return {
|
|
917
|
+
enabled: true,
|
|
918
|
+
evaluateEnabled: params.evaluateEnabled,
|
|
919
|
+
controlPort: params.controlPort,
|
|
920
|
+
cdpProtocol: "http",
|
|
921
|
+
cdpHost: "127.0.0.1",
|
|
922
|
+
cdpIsLoopback: true,
|
|
923
|
+
remoteCdpTimeoutMs: 1500,
|
|
924
|
+
remoteCdpHandshakeTimeoutMs: 3e3,
|
|
925
|
+
color: DEFAULT_OPENCLAW_BROWSER_COLOR,
|
|
926
|
+
executablePath: void 0,
|
|
927
|
+
headless: params.headless,
|
|
928
|
+
noSandbox: false,
|
|
929
|
+
attachOnly: true,
|
|
930
|
+
defaultProfile: DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME,
|
|
931
|
+
profiles: { [DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME]: {
|
|
932
|
+
cdpPort: params.cdpPort,
|
|
933
|
+
color: DEFAULT_OPENCLAW_BROWSER_COLOR
|
|
934
|
+
} }
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
async function ensureSandboxBrowserImage(image) {
|
|
938
|
+
if ((await execDocker([
|
|
939
|
+
"image",
|
|
940
|
+
"inspect",
|
|
941
|
+
image
|
|
942
|
+
], { allowFailure: true })).code === 0) return;
|
|
943
|
+
throw new Error(`Sandbox browser image not found: ${image}. Build it with scripts/sandbox-browser-setup.sh.`);
|
|
944
|
+
}
|
|
945
|
+
async function ensureSandboxBrowser(params) {
|
|
946
|
+
if (!params.cfg.browser.enabled) return null;
|
|
947
|
+
if (!isToolAllowed(params.cfg.tools, "browser")) return null;
|
|
948
|
+
const slug = params.cfg.scope === "shared" ? "shared" : slugifySessionKey(params.scopeKey);
|
|
949
|
+
const containerName = `${params.cfg.browser.containerPrefix}${slug}`.slice(0, 63);
|
|
950
|
+
const state = await dockerContainerState(containerName);
|
|
951
|
+
if (!state.exists) {
|
|
952
|
+
await ensureSandboxBrowserImage(params.cfg.browser.image ?? DEFAULT_SANDBOX_BROWSER_IMAGE);
|
|
953
|
+
const args = buildSandboxCreateArgs({
|
|
954
|
+
name: containerName,
|
|
955
|
+
cfg: params.cfg.docker,
|
|
956
|
+
scopeKey: params.scopeKey,
|
|
957
|
+
labels: { "openclaw.sandboxBrowser": "1" }
|
|
958
|
+
});
|
|
959
|
+
const mainMountSuffix = params.cfg.workspaceAccess === "ro" && params.workspaceDir === params.agentWorkspaceDir ? ":ro" : "";
|
|
960
|
+
args.push("-v", `${params.workspaceDir}:${params.cfg.docker.workdir}${mainMountSuffix}`);
|
|
961
|
+
if (params.cfg.workspaceAccess !== "none" && params.workspaceDir !== params.agentWorkspaceDir) {
|
|
962
|
+
const agentMountSuffix = params.cfg.workspaceAccess === "ro" ? ":ro" : "";
|
|
963
|
+
args.push("-v", `${params.agentWorkspaceDir}:${SANDBOX_AGENT_WORKSPACE_MOUNT}${agentMountSuffix}`);
|
|
964
|
+
}
|
|
965
|
+
args.push("-p", `127.0.0.1::${params.cfg.browser.cdpPort}`);
|
|
966
|
+
if (params.cfg.browser.enableNoVnc && !params.cfg.browser.headless) args.push("-p", `127.0.0.1::${params.cfg.browser.noVncPort}`);
|
|
967
|
+
args.push("-e", `OPENCLAW_BROWSER_HEADLESS=${params.cfg.browser.headless ? "1" : "0"}`);
|
|
968
|
+
args.push("-e", `OPENCLAW_BROWSER_ENABLE_NOVNC=${params.cfg.browser.enableNoVnc ? "1" : "0"}`);
|
|
969
|
+
args.push("-e", `OPENCLAW_BROWSER_CDP_PORT=${params.cfg.browser.cdpPort}`);
|
|
970
|
+
args.push("-e", `OPENCLAW_BROWSER_VNC_PORT=${params.cfg.browser.vncPort}`);
|
|
971
|
+
args.push("-e", `OPENCLAW_BROWSER_NOVNC_PORT=${params.cfg.browser.noVncPort}`);
|
|
972
|
+
args.push(params.cfg.browser.image);
|
|
973
|
+
await execDocker(args);
|
|
974
|
+
await execDocker(["start", containerName]);
|
|
975
|
+
} else if (!state.running) await execDocker(["start", containerName]);
|
|
976
|
+
const mappedCdp = await readDockerPort(containerName, params.cfg.browser.cdpPort);
|
|
977
|
+
if (!mappedCdp) throw new Error(`Failed to resolve CDP port mapping for ${containerName}.`);
|
|
978
|
+
const mappedNoVnc = params.cfg.browser.enableNoVnc && !params.cfg.browser.headless ? await readDockerPort(containerName, params.cfg.browser.noVncPort) : null;
|
|
979
|
+
const existing = BROWSER_BRIDGES.get(params.scopeKey);
|
|
980
|
+
const existingProfile = existing ? resolveProfile(existing.bridge.state.resolved, DEFAULT_OPENCLAW_BROWSER_PROFILE_NAME) : null;
|
|
981
|
+
const shouldReuse = existing && existing.containerName === containerName && existingProfile?.cdpPort === mappedCdp;
|
|
982
|
+
if (existing && !shouldReuse) {
|
|
983
|
+
await stopBrowserBridgeServer(existing.bridge.server).catch(() => void 0);
|
|
984
|
+
BROWSER_BRIDGES.delete(params.scopeKey);
|
|
985
|
+
}
|
|
986
|
+
const bridge = (() => {
|
|
987
|
+
if (shouldReuse && existing) return existing.bridge;
|
|
988
|
+
return null;
|
|
989
|
+
})();
|
|
990
|
+
const ensureBridge = async () => {
|
|
991
|
+
if (bridge) return bridge;
|
|
992
|
+
const onEnsureAttachTarget = params.cfg.browser.autoStart ? async () => {
|
|
993
|
+
const state = await dockerContainerState(containerName);
|
|
994
|
+
if (state.exists && !state.running) await execDocker(["start", containerName]);
|
|
995
|
+
if (!await waitForSandboxCdp({
|
|
996
|
+
cdpPort: mappedCdp,
|
|
997
|
+
timeoutMs: params.cfg.browser.autoStartTimeoutMs
|
|
998
|
+
})) throw new Error(`Sandbox browser CDP did not become reachable on 127.0.0.1:${mappedCdp} within ${params.cfg.browser.autoStartTimeoutMs}ms.`);
|
|
999
|
+
} : void 0;
|
|
1000
|
+
return await startBrowserBridgeServer({
|
|
1001
|
+
resolved: buildSandboxBrowserResolvedConfig({
|
|
1002
|
+
controlPort: 0,
|
|
1003
|
+
cdpPort: mappedCdp,
|
|
1004
|
+
headless: params.cfg.browser.headless,
|
|
1005
|
+
evaluateEnabled: params.evaluateEnabled ?? DEFAULT_BROWSER_EVALUATE_ENABLED
|
|
1006
|
+
}),
|
|
1007
|
+
onEnsureAttachTarget
|
|
1008
|
+
});
|
|
1009
|
+
};
|
|
1010
|
+
const resolvedBridge = await ensureBridge();
|
|
1011
|
+
if (!shouldReuse) BROWSER_BRIDGES.set(params.scopeKey, {
|
|
1012
|
+
bridge: resolvedBridge,
|
|
1013
|
+
containerName
|
|
1014
|
+
});
|
|
1015
|
+
const now = Date.now();
|
|
1016
|
+
await updateBrowserRegistry({
|
|
1017
|
+
containerName,
|
|
1018
|
+
sessionKey: params.scopeKey,
|
|
1019
|
+
createdAtMs: now,
|
|
1020
|
+
lastUsedAtMs: now,
|
|
1021
|
+
image: params.cfg.browser.image,
|
|
1022
|
+
cdpPort: mappedCdp,
|
|
1023
|
+
noVncPort: mappedNoVnc ?? void 0
|
|
1024
|
+
});
|
|
1025
|
+
const noVncUrl = mappedNoVnc && params.cfg.browser.enableNoVnc && !params.cfg.browser.headless ? `http://127.0.0.1:${mappedNoVnc}/vnc.html?autoconnect=1&resize=remote` : void 0;
|
|
1026
|
+
return {
|
|
1027
|
+
bridgeUrl: resolvedBridge.baseUrl,
|
|
1028
|
+
noVncUrl,
|
|
1029
|
+
containerName
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
//#endregion
|
|
1034
|
+
//#region src/agents/sandbox/prune.ts
|
|
1035
|
+
let lastPruneAtMs = 0;
|
|
1036
|
+
async function pruneSandboxContainers(cfg) {
|
|
1037
|
+
const now = Date.now();
|
|
1038
|
+
const idleHours = cfg.prune.idleHours;
|
|
1039
|
+
const maxAgeDays = cfg.prune.maxAgeDays;
|
|
1040
|
+
if (idleHours === 0 && maxAgeDays === 0) return;
|
|
1041
|
+
const registry = await readRegistry();
|
|
1042
|
+
for (const entry of registry.entries) {
|
|
1043
|
+
const idleMs = now - entry.lastUsedAtMs;
|
|
1044
|
+
const ageMs = now - entry.createdAtMs;
|
|
1045
|
+
if (idleHours > 0 && idleMs > idleHours * 60 * 60 * 1e3 || maxAgeDays > 0 && ageMs > maxAgeDays * 24 * 60 * 60 * 1e3) try {
|
|
1046
|
+
await execDocker([
|
|
1047
|
+
"rm",
|
|
1048
|
+
"-f",
|
|
1049
|
+
entry.containerName
|
|
1050
|
+
], { allowFailure: true });
|
|
1051
|
+
} catch {} finally {
|
|
1052
|
+
await removeRegistryEntry(entry.containerName);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
async function pruneSandboxBrowsers(cfg) {
|
|
1057
|
+
const now = Date.now();
|
|
1058
|
+
const idleHours = cfg.prune.idleHours;
|
|
1059
|
+
const maxAgeDays = cfg.prune.maxAgeDays;
|
|
1060
|
+
if (idleHours === 0 && maxAgeDays === 0) return;
|
|
1061
|
+
const registry = await readBrowserRegistry();
|
|
1062
|
+
for (const entry of registry.entries) {
|
|
1063
|
+
const idleMs = now - entry.lastUsedAtMs;
|
|
1064
|
+
const ageMs = now - entry.createdAtMs;
|
|
1065
|
+
if (idleHours > 0 && idleMs > idleHours * 60 * 60 * 1e3 || maxAgeDays > 0 && ageMs > maxAgeDays * 24 * 60 * 60 * 1e3) try {
|
|
1066
|
+
await execDocker([
|
|
1067
|
+
"rm",
|
|
1068
|
+
"-f",
|
|
1069
|
+
entry.containerName
|
|
1070
|
+
], { allowFailure: true });
|
|
1071
|
+
} catch {} finally {
|
|
1072
|
+
await removeBrowserRegistryEntry(entry.containerName);
|
|
1073
|
+
const bridge = BROWSER_BRIDGES.get(entry.sessionKey);
|
|
1074
|
+
if (bridge?.containerName === entry.containerName) {
|
|
1075
|
+
await stopBrowserBridgeServer(bridge.bridge.server).catch(() => void 0);
|
|
1076
|
+
BROWSER_BRIDGES.delete(entry.sessionKey);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
async function maybePruneSandboxes(cfg) {
|
|
1082
|
+
const now = Date.now();
|
|
1083
|
+
if (now - lastPruneAtMs < 300 * 1e3) return;
|
|
1084
|
+
lastPruneAtMs = now;
|
|
1085
|
+
try {
|
|
1086
|
+
await pruneSandboxContainers(cfg);
|
|
1087
|
+
await pruneSandboxBrowsers(cfg);
|
|
1088
|
+
} catch (error) {
|
|
1089
|
+
const message = error instanceof Error ? error.message : typeof error === "string" ? error : JSON.stringify(error);
|
|
1090
|
+
defaultRuntime.error?.(`Sandbox prune failed: ${message ?? "unknown error"}`);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/config/sessions/group.ts
|
|
1096
|
+
const getGroupSurfaces = () => new Set([...listDeliverableMessageChannels(), "webchat"]);
|
|
1097
|
+
function normalizeGroupLabel(raw) {
|
|
1098
|
+
const trimmed = raw?.trim().toLowerCase() ?? "";
|
|
1099
|
+
if (!trimmed) return "";
|
|
1100
|
+
return trimmed.replace(/\s+/g, "-").replace(/[^a-z0-9#@._+-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
1101
|
+
}
|
|
1102
|
+
function shortenGroupId(value) {
|
|
1103
|
+
const trimmed = value?.trim() ?? "";
|
|
1104
|
+
if (!trimmed) return "";
|
|
1105
|
+
if (trimmed.length <= 14) return trimmed;
|
|
1106
|
+
return `${trimmed.slice(0, 6)}...${trimmed.slice(-4)}`;
|
|
1107
|
+
}
|
|
1108
|
+
function buildGroupDisplayName(params) {
|
|
1109
|
+
const providerKey = (params.provider?.trim().toLowerCase() || "group").trim();
|
|
1110
|
+
const groupChannel = params.groupChannel?.trim();
|
|
1111
|
+
const space = params.space?.trim();
|
|
1112
|
+
const subject = params.subject?.trim();
|
|
1113
|
+
const detail = (groupChannel && space ? `${space}${groupChannel.startsWith("#") ? "" : "#"}${groupChannel}` : groupChannel || subject || space || "") || "";
|
|
1114
|
+
const fallbackId = params.id?.trim() || params.key;
|
|
1115
|
+
const rawLabel = detail || fallbackId;
|
|
1116
|
+
let token = normalizeGroupLabel(rawLabel);
|
|
1117
|
+
if (!token) token = normalizeGroupLabel(shortenGroupId(rawLabel));
|
|
1118
|
+
if (!params.groupChannel && token.startsWith("#")) token = token.replace(/^#+/, "");
|
|
1119
|
+
if (token && !/^[@#]/.test(token) && !token.startsWith("g-") && !token.includes("#")) token = `g-${token}`;
|
|
1120
|
+
return token ? `${providerKey}:${token}` : providerKey;
|
|
1121
|
+
}
|
|
1122
|
+
function resolveGroupSessionKey(ctx) {
|
|
1123
|
+
const from = typeof ctx.From === "string" ? ctx.From.trim() : "";
|
|
1124
|
+
const chatType = ctx.ChatType?.trim().toLowerCase();
|
|
1125
|
+
const normalizedChatType = chatType === "channel" ? "channel" : chatType === "group" ? "group" : void 0;
|
|
1126
|
+
const isWhatsAppGroupId = from.toLowerCase().endsWith("@g.us");
|
|
1127
|
+
if (!(normalizedChatType === "group" || normalizedChatType === "channel" || from.includes(":group:") || from.includes(":channel:") || isWhatsAppGroupId)) return null;
|
|
1128
|
+
const providerHint = ctx.Provider?.trim().toLowerCase();
|
|
1129
|
+
const parts = from.split(":").filter(Boolean);
|
|
1130
|
+
const head = parts[0]?.trim().toLowerCase() ?? "";
|
|
1131
|
+
const headIsSurface = head ? getGroupSurfaces().has(head) : false;
|
|
1132
|
+
const provider = headIsSurface ? head : providerHint ?? (isWhatsAppGroupId ? "whatsapp" : void 0);
|
|
1133
|
+
if (!provider) return null;
|
|
1134
|
+
const second = parts[1]?.trim().toLowerCase();
|
|
1135
|
+
const secondIsKind = second === "group" || second === "channel";
|
|
1136
|
+
const kind = secondIsKind ? second : from.includes(":channel:") || normalizedChatType === "channel" ? "channel" : "group";
|
|
1137
|
+
const finalId = (headIsSurface ? secondIsKind ? parts.slice(2).join(":") : parts.slice(1).join(":") : from).trim().toLowerCase();
|
|
1138
|
+
if (!finalId) return null;
|
|
1139
|
+
return {
|
|
1140
|
+
key: `${provider}:${kind}:${finalId}`,
|
|
1141
|
+
channel: provider,
|
|
1142
|
+
id: finalId,
|
|
1143
|
+
chatType: kind === "channel" ? "channel" : "group"
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/imessage/accounts.ts
|
|
1149
|
+
function resolveAccountConfig$1(cfg, accountId) {
|
|
1150
|
+
const accounts = cfg.channels?.imessage?.accounts;
|
|
1151
|
+
if (!accounts || typeof accounts !== "object") return;
|
|
1152
|
+
return accounts[accountId];
|
|
1153
|
+
}
|
|
1154
|
+
function mergeIMessageAccountConfig(cfg, accountId) {
|
|
1155
|
+
const { accounts: _ignored, ...base } = cfg.channels?.imessage ?? {};
|
|
1156
|
+
const account = resolveAccountConfig$1(cfg, accountId) ?? {};
|
|
1157
|
+
return {
|
|
1158
|
+
...base,
|
|
1159
|
+
...account
|
|
1160
|
+
};
|
|
1161
|
+
}
|
|
1162
|
+
function resolveIMessageAccount(params) {
|
|
1163
|
+
const accountId = normalizeAccountId$1(params.accountId);
|
|
1164
|
+
const baseEnabled = params.cfg.channels?.imessage?.enabled !== false;
|
|
1165
|
+
const merged = mergeIMessageAccountConfig(params.cfg, accountId);
|
|
1166
|
+
const accountEnabled = merged.enabled !== false;
|
|
1167
|
+
const configured = Boolean(merged.cliPath?.trim() || merged.dbPath?.trim() || merged.service || merged.region?.trim() || merged.allowFrom && merged.allowFrom.length > 0 || merged.groupAllowFrom && merged.groupAllowFrom.length > 0 || merged.dmPolicy || merged.groupPolicy || typeof merged.includeAttachments === "boolean" || typeof merged.mediaMaxMb === "number" || typeof merged.textChunkLimit === "number" || merged.groups && Object.keys(merged.groups).length > 0);
|
|
1168
|
+
return {
|
|
1169
|
+
accountId,
|
|
1170
|
+
enabled: baseEnabled && accountEnabled,
|
|
1171
|
+
name: merged.name?.trim() || void 0,
|
|
1172
|
+
config: merged,
|
|
1173
|
+
configured
|
|
1174
|
+
};
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/signal/accounts.ts
|
|
1179
|
+
function listConfiguredAccountIds(cfg) {
|
|
1180
|
+
const accounts = cfg.channels?.signal?.accounts;
|
|
1181
|
+
if (!accounts || typeof accounts !== "object") return [];
|
|
1182
|
+
return Object.keys(accounts).filter(Boolean);
|
|
1183
|
+
}
|
|
1184
|
+
function listSignalAccountIds(cfg) {
|
|
1185
|
+
const ids = listConfiguredAccountIds(cfg);
|
|
1186
|
+
if (ids.length === 0) return [DEFAULT_ACCOUNT_ID];
|
|
1187
|
+
return ids.toSorted((a, b) => a.localeCompare(b));
|
|
1188
|
+
}
|
|
1189
|
+
function resolveAccountConfig(cfg, accountId) {
|
|
1190
|
+
const accounts = cfg.channels?.signal?.accounts;
|
|
1191
|
+
if (!accounts || typeof accounts !== "object") return;
|
|
1192
|
+
return accounts[accountId];
|
|
1193
|
+
}
|
|
1194
|
+
function mergeSignalAccountConfig(cfg, accountId) {
|
|
1195
|
+
const { accounts: _ignored, ...base } = cfg.channels?.signal ?? {};
|
|
1196
|
+
const account = resolveAccountConfig(cfg, accountId) ?? {};
|
|
1197
|
+
return {
|
|
1198
|
+
...base,
|
|
1199
|
+
...account
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
function resolveSignalAccount(params) {
|
|
1203
|
+
const accountId = normalizeAccountId$1(params.accountId);
|
|
1204
|
+
const baseEnabled = params.cfg.channels?.signal?.enabled !== false;
|
|
1205
|
+
const merged = mergeSignalAccountConfig(params.cfg, accountId);
|
|
1206
|
+
const accountEnabled = merged.enabled !== false;
|
|
1207
|
+
const enabled = baseEnabled && accountEnabled;
|
|
1208
|
+
const host = merged.httpHost?.trim() || "127.0.0.1";
|
|
1209
|
+
const port = merged.httpPort ?? 8080;
|
|
1210
|
+
const baseUrl = merged.httpUrl?.trim() || `http://${host}:${port}`;
|
|
1211
|
+
const configured = Boolean(merged.account?.trim() || merged.httpUrl?.trim() || merged.cliPath?.trim() || merged.httpHost?.trim() || typeof merged.httpPort === "number" || typeof merged.autoStart === "boolean");
|
|
1212
|
+
return {
|
|
1213
|
+
accountId,
|
|
1214
|
+
enabled,
|
|
1215
|
+
name: merged.name?.trim() || void 0,
|
|
1216
|
+
baseUrl,
|
|
1217
|
+
configured,
|
|
1218
|
+
config: merged
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function listEnabledSignalAccounts(cfg) {
|
|
1222
|
+
return listSignalAccountIds(cfg).map((accountId) => resolveSignalAccount({
|
|
1223
|
+
cfg,
|
|
1224
|
+
accountId
|
|
1225
|
+
})).filter((account) => account.enabled);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/slack/threading-tool-context.ts
|
|
1230
|
+
function buildSlackThreadingToolContext(params) {
|
|
1231
|
+
const configuredReplyToMode = resolveSlackReplyToMode(resolveSlackAccount({
|
|
1232
|
+
cfg: params.cfg,
|
|
1233
|
+
accountId: params.accountId
|
|
1234
|
+
}), params.context.ChatType);
|
|
1235
|
+
const effectiveReplyToMode = params.context.ThreadLabel ? "all" : configuredReplyToMode;
|
|
1236
|
+
const threadId = params.context.MessageThreadId ?? params.context.ReplyToId;
|
|
1237
|
+
return {
|
|
1238
|
+
currentChannelId: params.context.To?.startsWith("channel:") ? params.context.To.slice(8) : void 0,
|
|
1239
|
+
currentThreadTs: threadId != null ? String(threadId) : void 0,
|
|
1240
|
+
replyToMode: effectiveReplyToMode,
|
|
1241
|
+
hasRepliedRef: params.hasRepliedRef
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
//#endregion
|
|
1246
|
+
//#region src/config/group-policy.ts
|
|
1247
|
+
function normalizeSenderKey(value) {
|
|
1248
|
+
const trimmed = value.trim();
|
|
1249
|
+
if (!trimmed) return "";
|
|
1250
|
+
return (trimmed.startsWith("@") ? trimmed.slice(1) : trimmed).toLowerCase();
|
|
1251
|
+
}
|
|
1252
|
+
function resolveToolsBySender(params) {
|
|
1253
|
+
const toolsBySender = params.toolsBySender;
|
|
1254
|
+
if (!toolsBySender) return;
|
|
1255
|
+
const entries = Object.entries(toolsBySender);
|
|
1256
|
+
if (entries.length === 0) return;
|
|
1257
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
1258
|
+
let wildcard;
|
|
1259
|
+
for (const [rawKey, policy] of entries) {
|
|
1260
|
+
if (!policy) continue;
|
|
1261
|
+
const key = normalizeSenderKey(rawKey);
|
|
1262
|
+
if (!key) continue;
|
|
1263
|
+
if (key === "*") {
|
|
1264
|
+
wildcard = policy;
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
if (!normalized.has(key)) normalized.set(key, policy);
|
|
1268
|
+
}
|
|
1269
|
+
const candidates = [];
|
|
1270
|
+
const pushCandidate = (value) => {
|
|
1271
|
+
const trimmed = value?.trim();
|
|
1272
|
+
if (!trimmed) return;
|
|
1273
|
+
candidates.push(trimmed);
|
|
1274
|
+
};
|
|
1275
|
+
pushCandidate(params.senderId);
|
|
1276
|
+
pushCandidate(params.senderE164);
|
|
1277
|
+
pushCandidate(params.senderUsername);
|
|
1278
|
+
pushCandidate(params.senderName);
|
|
1279
|
+
for (const candidate of candidates) {
|
|
1280
|
+
const key = normalizeSenderKey(candidate);
|
|
1281
|
+
if (!key) continue;
|
|
1282
|
+
const match = normalized.get(key);
|
|
1283
|
+
if (match) return match;
|
|
1284
|
+
}
|
|
1285
|
+
return wildcard;
|
|
1286
|
+
}
|
|
1287
|
+
function resolveChannelGroups(cfg, channel, accountId) {
|
|
1288
|
+
const normalizedAccountId = normalizeAccountId$1(accountId);
|
|
1289
|
+
const channelConfig = cfg.channels?.[channel];
|
|
1290
|
+
if (!channelConfig) return;
|
|
1291
|
+
return channelConfig.accounts?.[normalizedAccountId]?.groups ?? channelConfig.accounts?.[Object.keys(channelConfig.accounts ?? {}).find((key) => key.toLowerCase() === normalizedAccountId.toLowerCase()) ?? ""]?.groups ?? channelConfig.groups;
|
|
1292
|
+
}
|
|
1293
|
+
function resolveChannelGroupPolicy(params) {
|
|
1294
|
+
const { cfg, channel } = params;
|
|
1295
|
+
const groups = resolveChannelGroups(cfg, channel, params.accountId);
|
|
1296
|
+
const allowlistEnabled = Boolean(groups && Object.keys(groups).length > 0);
|
|
1297
|
+
const normalizedId = params.groupId?.trim();
|
|
1298
|
+
const groupConfig = normalizedId && groups ? groups[normalizedId] : void 0;
|
|
1299
|
+
const defaultConfig = groups?.["*"];
|
|
1300
|
+
return {
|
|
1301
|
+
allowlistEnabled,
|
|
1302
|
+
allowed: !allowlistEnabled || allowlistEnabled && Boolean(groups && Object.hasOwn(groups, "*")) || (normalizedId ? Boolean(groups && Object.hasOwn(groups, normalizedId)) : false),
|
|
1303
|
+
groupConfig,
|
|
1304
|
+
defaultConfig
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
function resolveChannelGroupRequireMention(params) {
|
|
1308
|
+
const { requireMentionOverride, overrideOrder = "after-config" } = params;
|
|
1309
|
+
const { groupConfig, defaultConfig } = resolveChannelGroupPolicy(params);
|
|
1310
|
+
const configMention = typeof groupConfig?.requireMention === "boolean" ? groupConfig.requireMention : typeof defaultConfig?.requireMention === "boolean" ? defaultConfig.requireMention : void 0;
|
|
1311
|
+
if (overrideOrder === "before-config" && typeof requireMentionOverride === "boolean") return requireMentionOverride;
|
|
1312
|
+
if (typeof configMention === "boolean") return configMention;
|
|
1313
|
+
if (overrideOrder !== "before-config" && typeof requireMentionOverride === "boolean") return requireMentionOverride;
|
|
1314
|
+
return true;
|
|
1315
|
+
}
|
|
1316
|
+
function resolveChannelGroupToolsPolicy(params) {
|
|
1317
|
+
const { groupConfig, defaultConfig } = resolveChannelGroupPolicy(params);
|
|
1318
|
+
const groupSenderPolicy = resolveToolsBySender({
|
|
1319
|
+
toolsBySender: groupConfig?.toolsBySender,
|
|
1320
|
+
senderId: params.senderId,
|
|
1321
|
+
senderName: params.senderName,
|
|
1322
|
+
senderUsername: params.senderUsername,
|
|
1323
|
+
senderE164: params.senderE164
|
|
1324
|
+
});
|
|
1325
|
+
if (groupSenderPolicy) return groupSenderPolicy;
|
|
1326
|
+
if (groupConfig?.tools) return groupConfig.tools;
|
|
1327
|
+
const defaultSenderPolicy = resolveToolsBySender({
|
|
1328
|
+
toolsBySender: defaultConfig?.toolsBySender,
|
|
1329
|
+
senderId: params.senderId,
|
|
1330
|
+
senderName: params.senderName,
|
|
1331
|
+
senderUsername: params.senderUsername,
|
|
1332
|
+
senderE164: params.senderE164
|
|
1333
|
+
});
|
|
1334
|
+
if (defaultSenderPolicy) return defaultSenderPolicy;
|
|
1335
|
+
if (defaultConfig?.tools) return defaultConfig.tools;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
//#endregion
|
|
1339
|
+
//#region src/channels/plugins/group-mentions.ts
|
|
1340
|
+
function normalizeDiscordSlug(value) {
|
|
1341
|
+
if (!value) return "";
|
|
1342
|
+
let text = value.trim().toLowerCase();
|
|
1343
|
+
if (!text) return "";
|
|
1344
|
+
text = text.replace(/^[@#]+/, "");
|
|
1345
|
+
text = text.replace(/[\s_]+/g, "-");
|
|
1346
|
+
text = text.replace(/[^a-z0-9-]+/g, "-");
|
|
1347
|
+
text = text.replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
1348
|
+
return text;
|
|
1349
|
+
}
|
|
1350
|
+
function normalizeSlackSlug(raw) {
|
|
1351
|
+
const trimmed = raw?.trim().toLowerCase() ?? "";
|
|
1352
|
+
if (!trimmed) return "";
|
|
1353
|
+
return trimmed.replace(/\s+/g, "-").replace(/[^a-z0-9#@._+-]+/g, "-").replace(/-{2,}/g, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
1354
|
+
}
|
|
1355
|
+
function parseTelegramGroupId(value) {
|
|
1356
|
+
const raw = value?.trim() ?? "";
|
|
1357
|
+
if (!raw) return {
|
|
1358
|
+
chatId: void 0,
|
|
1359
|
+
topicId: void 0
|
|
1360
|
+
};
|
|
1361
|
+
const parts = raw.split(":").filter(Boolean);
|
|
1362
|
+
if (parts.length >= 3 && parts[1] === "topic" && /^-?\d+$/.test(parts[0]) && /^\d+$/.test(parts[2])) return {
|
|
1363
|
+
chatId: parts[0],
|
|
1364
|
+
topicId: parts[2]
|
|
1365
|
+
};
|
|
1366
|
+
if (parts.length >= 2 && /^-?\d+$/.test(parts[0]) && /^\d+$/.test(parts[1])) return {
|
|
1367
|
+
chatId: parts[0],
|
|
1368
|
+
topicId: parts[1]
|
|
1369
|
+
};
|
|
1370
|
+
return {
|
|
1371
|
+
chatId: raw,
|
|
1372
|
+
topicId: void 0
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
function resolveTelegramRequireMention(params) {
|
|
1376
|
+
const { cfg, chatId, topicId } = params;
|
|
1377
|
+
if (!chatId) return;
|
|
1378
|
+
const groupConfig = cfg.channels?.telegram?.groups?.[chatId];
|
|
1379
|
+
const groupDefault = cfg.channels?.telegram?.groups?.["*"];
|
|
1380
|
+
const topicConfig = topicId && groupConfig?.topics ? groupConfig.topics[topicId] : void 0;
|
|
1381
|
+
const defaultTopicConfig = topicId && groupDefault?.topics ? groupDefault.topics[topicId] : void 0;
|
|
1382
|
+
if (typeof topicConfig?.requireMention === "boolean") return topicConfig.requireMention;
|
|
1383
|
+
if (typeof defaultTopicConfig?.requireMention === "boolean") return defaultTopicConfig.requireMention;
|
|
1384
|
+
if (typeof groupConfig?.requireMention === "boolean") return groupConfig.requireMention;
|
|
1385
|
+
if (typeof groupDefault?.requireMention === "boolean") return groupDefault.requireMention;
|
|
1386
|
+
}
|
|
1387
|
+
function resolveDiscordGuildEntry(guilds, groupSpace) {
|
|
1388
|
+
if (!guilds || Object.keys(guilds).length === 0) return null;
|
|
1389
|
+
const space = groupSpace?.trim() ?? "";
|
|
1390
|
+
if (space && guilds[space]) return guilds[space];
|
|
1391
|
+
const normalized = normalizeDiscordSlug(space);
|
|
1392
|
+
if (normalized && guilds[normalized]) return guilds[normalized];
|
|
1393
|
+
if (normalized) {
|
|
1394
|
+
const match = Object.values(guilds).find((entry) => normalizeDiscordSlug(entry?.slug ?? void 0) === normalized);
|
|
1395
|
+
if (match) return match;
|
|
1396
|
+
}
|
|
1397
|
+
return guilds["*"] ?? null;
|
|
1398
|
+
}
|
|
1399
|
+
function resolveTelegramGroupRequireMention(params) {
|
|
1400
|
+
const { chatId, topicId } = parseTelegramGroupId(params.groupId);
|
|
1401
|
+
const requireMention = resolveTelegramRequireMention({
|
|
1402
|
+
cfg: params.cfg,
|
|
1403
|
+
chatId,
|
|
1404
|
+
topicId
|
|
1405
|
+
});
|
|
1406
|
+
if (typeof requireMention === "boolean") return requireMention;
|
|
1407
|
+
return resolveChannelGroupRequireMention({
|
|
1408
|
+
cfg: params.cfg,
|
|
1409
|
+
channel: "telegram",
|
|
1410
|
+
groupId: chatId ?? params.groupId,
|
|
1411
|
+
accountId: params.accountId
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
function resolveWhatsAppGroupRequireMention(params) {
|
|
1415
|
+
return resolveChannelGroupRequireMention({
|
|
1416
|
+
cfg: params.cfg,
|
|
1417
|
+
channel: "whatsapp",
|
|
1418
|
+
groupId: params.groupId,
|
|
1419
|
+
accountId: params.accountId
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
function resolveIMessageGroupRequireMention(params) {
|
|
1423
|
+
return resolveChannelGroupRequireMention({
|
|
1424
|
+
cfg: params.cfg,
|
|
1425
|
+
channel: "imessage",
|
|
1426
|
+
groupId: params.groupId,
|
|
1427
|
+
accountId: params.accountId
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
function resolveDiscordGroupRequireMention(params) {
|
|
1431
|
+
const guildEntry = resolveDiscordGuildEntry(params.cfg.channels?.discord?.guilds, params.groupSpace);
|
|
1432
|
+
const channelEntries = guildEntry?.channels;
|
|
1433
|
+
if (channelEntries && Object.keys(channelEntries).length > 0) {
|
|
1434
|
+
const groupChannel = params.groupChannel;
|
|
1435
|
+
const channelSlug = normalizeDiscordSlug(groupChannel);
|
|
1436
|
+
const entry = (params.groupId ? channelEntries[params.groupId] : void 0) ?? (channelSlug ? channelEntries[channelSlug] ?? channelEntries[`#${channelSlug}`] : void 0) ?? (groupChannel ? channelEntries[normalizeDiscordSlug(groupChannel)] : void 0);
|
|
1437
|
+
if (entry && typeof entry.requireMention === "boolean") return entry.requireMention;
|
|
1438
|
+
}
|
|
1439
|
+
if (typeof guildEntry?.requireMention === "boolean") return guildEntry.requireMention;
|
|
1440
|
+
return true;
|
|
1441
|
+
}
|
|
1442
|
+
function resolveGoogleChatGroupRequireMention(params) {
|
|
1443
|
+
return resolveChannelGroupRequireMention({
|
|
1444
|
+
cfg: params.cfg,
|
|
1445
|
+
channel: "googlechat",
|
|
1446
|
+
groupId: params.groupId,
|
|
1447
|
+
accountId: params.accountId
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
function resolveGoogleChatGroupToolPolicy(params) {
|
|
1451
|
+
return resolveChannelGroupToolsPolicy({
|
|
1452
|
+
cfg: params.cfg,
|
|
1453
|
+
channel: "googlechat",
|
|
1454
|
+
groupId: params.groupId,
|
|
1455
|
+
accountId: params.accountId,
|
|
1456
|
+
senderId: params.senderId,
|
|
1457
|
+
senderName: params.senderName,
|
|
1458
|
+
senderUsername: params.senderUsername,
|
|
1459
|
+
senderE164: params.senderE164
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
function resolveSlackGroupRequireMention(params) {
|
|
1463
|
+
const channels = resolveSlackAccount({
|
|
1464
|
+
cfg: params.cfg,
|
|
1465
|
+
accountId: params.accountId
|
|
1466
|
+
}).channels ?? {};
|
|
1467
|
+
if (Object.keys(channels).length === 0) return true;
|
|
1468
|
+
const channelId = params.groupId?.trim();
|
|
1469
|
+
const channelName = params.groupChannel?.replace(/^#/, "");
|
|
1470
|
+
const normalizedName = normalizeSlackSlug(channelName);
|
|
1471
|
+
const candidates = [
|
|
1472
|
+
channelId ?? "",
|
|
1473
|
+
channelName ? `#${channelName}` : "",
|
|
1474
|
+
channelName ?? "",
|
|
1475
|
+
normalizedName
|
|
1476
|
+
].filter(Boolean);
|
|
1477
|
+
let matched;
|
|
1478
|
+
for (const candidate of candidates) if (candidate && channels[candidate]) {
|
|
1479
|
+
matched = channels[candidate];
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
const fallback = channels["*"];
|
|
1483
|
+
const resolved = matched ?? fallback;
|
|
1484
|
+
if (typeof resolved?.requireMention === "boolean") return resolved.requireMention;
|
|
1485
|
+
return true;
|
|
1486
|
+
}
|
|
1487
|
+
function resolveTelegramGroupToolPolicy(params) {
|
|
1488
|
+
const { chatId } = parseTelegramGroupId(params.groupId);
|
|
1489
|
+
return resolveChannelGroupToolsPolicy({
|
|
1490
|
+
cfg: params.cfg,
|
|
1491
|
+
channel: "telegram",
|
|
1492
|
+
groupId: chatId ?? params.groupId,
|
|
1493
|
+
accountId: params.accountId,
|
|
1494
|
+
senderId: params.senderId,
|
|
1495
|
+
senderName: params.senderName,
|
|
1496
|
+
senderUsername: params.senderUsername,
|
|
1497
|
+
senderE164: params.senderE164
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
function resolveWhatsAppGroupToolPolicy(params) {
|
|
1501
|
+
return resolveChannelGroupToolsPolicy({
|
|
1502
|
+
cfg: params.cfg,
|
|
1503
|
+
channel: "whatsapp",
|
|
1504
|
+
groupId: params.groupId,
|
|
1505
|
+
accountId: params.accountId,
|
|
1506
|
+
senderId: params.senderId,
|
|
1507
|
+
senderName: params.senderName,
|
|
1508
|
+
senderUsername: params.senderUsername,
|
|
1509
|
+
senderE164: params.senderE164
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
function resolveIMessageGroupToolPolicy(params) {
|
|
1513
|
+
return resolveChannelGroupToolsPolicy({
|
|
1514
|
+
cfg: params.cfg,
|
|
1515
|
+
channel: "imessage",
|
|
1516
|
+
groupId: params.groupId,
|
|
1517
|
+
accountId: params.accountId,
|
|
1518
|
+
senderId: params.senderId,
|
|
1519
|
+
senderName: params.senderName,
|
|
1520
|
+
senderUsername: params.senderUsername,
|
|
1521
|
+
senderE164: params.senderE164
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
function resolveDiscordGroupToolPolicy(params) {
|
|
1525
|
+
const guildEntry = resolveDiscordGuildEntry(params.cfg.channels?.discord?.guilds, params.groupSpace);
|
|
1526
|
+
const channelEntries = guildEntry?.channels;
|
|
1527
|
+
if (channelEntries && Object.keys(channelEntries).length > 0) {
|
|
1528
|
+
const groupChannel = params.groupChannel;
|
|
1529
|
+
const channelSlug = normalizeDiscordSlug(groupChannel);
|
|
1530
|
+
const entry = (params.groupId ? channelEntries[params.groupId] : void 0) ?? (channelSlug ? channelEntries[channelSlug] ?? channelEntries[`#${channelSlug}`] : void 0) ?? (groupChannel ? channelEntries[normalizeDiscordSlug(groupChannel)] : void 0);
|
|
1531
|
+
const senderPolicy = resolveToolsBySender({
|
|
1532
|
+
toolsBySender: entry?.toolsBySender,
|
|
1533
|
+
senderId: params.senderId,
|
|
1534
|
+
senderName: params.senderName,
|
|
1535
|
+
senderUsername: params.senderUsername,
|
|
1536
|
+
senderE164: params.senderE164
|
|
1537
|
+
});
|
|
1538
|
+
if (senderPolicy) return senderPolicy;
|
|
1539
|
+
if (entry?.tools) return entry.tools;
|
|
1540
|
+
}
|
|
1541
|
+
const guildSenderPolicy = resolveToolsBySender({
|
|
1542
|
+
toolsBySender: guildEntry?.toolsBySender,
|
|
1543
|
+
senderId: params.senderId,
|
|
1544
|
+
senderName: params.senderName,
|
|
1545
|
+
senderUsername: params.senderUsername,
|
|
1546
|
+
senderE164: params.senderE164
|
|
1547
|
+
});
|
|
1548
|
+
if (guildSenderPolicy) return guildSenderPolicy;
|
|
1549
|
+
if (guildEntry?.tools) return guildEntry.tools;
|
|
1550
|
+
}
|
|
1551
|
+
function resolveSlackGroupToolPolicy(params) {
|
|
1552
|
+
const channels = resolveSlackAccount({
|
|
1553
|
+
cfg: params.cfg,
|
|
1554
|
+
accountId: params.accountId
|
|
1555
|
+
}).channels ?? {};
|
|
1556
|
+
if (Object.keys(channels).length === 0) return;
|
|
1557
|
+
const channelId = params.groupId?.trim();
|
|
1558
|
+
const channelName = params.groupChannel?.replace(/^#/, "");
|
|
1559
|
+
const normalizedName = normalizeSlackSlug(channelName);
|
|
1560
|
+
const candidates = [
|
|
1561
|
+
channelId ?? "",
|
|
1562
|
+
channelName ? `#${channelName}` : "",
|
|
1563
|
+
channelName ?? "",
|
|
1564
|
+
normalizedName
|
|
1565
|
+
].filter(Boolean);
|
|
1566
|
+
let matched;
|
|
1567
|
+
for (const candidate of candidates) if (candidate && channels[candidate]) {
|
|
1568
|
+
matched = channels[candidate];
|
|
1569
|
+
break;
|
|
1570
|
+
}
|
|
1571
|
+
const resolved = matched ?? channels["*"];
|
|
1572
|
+
const senderPolicy = resolveToolsBySender({
|
|
1573
|
+
toolsBySender: resolved?.toolsBySender,
|
|
1574
|
+
senderId: params.senderId,
|
|
1575
|
+
senderName: params.senderName,
|
|
1576
|
+
senderUsername: params.senderUsername,
|
|
1577
|
+
senderE164: params.senderE164
|
|
1578
|
+
});
|
|
1579
|
+
if (senderPolicy) return senderPolicy;
|
|
1580
|
+
if (resolved?.tools) return resolved.tools;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
//#endregion
|
|
1584
|
+
//#region src/channels/dock.ts
|
|
1585
|
+
const formatLower = (allowFrom) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.toLowerCase());
|
|
1586
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1587
|
+
const DOCKS = {
|
|
1588
|
+
telegram: {
|
|
1589
|
+
id: "telegram",
|
|
1590
|
+
capabilities: {
|
|
1591
|
+
chatTypes: [
|
|
1592
|
+
"direct",
|
|
1593
|
+
"group",
|
|
1594
|
+
"channel",
|
|
1595
|
+
"thread"
|
|
1596
|
+
],
|
|
1597
|
+
nativeCommands: true,
|
|
1598
|
+
blockStreaming: true
|
|
1599
|
+
},
|
|
1600
|
+
outbound: { textChunkLimit: 4e3 },
|
|
1601
|
+
config: {
|
|
1602
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveTelegramAccount({
|
|
1603
|
+
cfg,
|
|
1604
|
+
accountId
|
|
1605
|
+
}).config.allowFrom ?? []).map((entry) => String(entry)),
|
|
1606
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.replace(/^(telegram|tg):/i, "")).map((entry) => entry.toLowerCase())
|
|
1607
|
+
},
|
|
1608
|
+
groups: {
|
|
1609
|
+
resolveRequireMention: resolveTelegramGroupRequireMention,
|
|
1610
|
+
resolveToolPolicy: resolveTelegramGroupToolPolicy
|
|
1611
|
+
},
|
|
1612
|
+
threading: {
|
|
1613
|
+
resolveReplyToMode: ({ cfg }) => cfg.channels?.telegram?.replyToMode ?? "first",
|
|
1614
|
+
buildToolContext: ({ context, hasRepliedRef }) => {
|
|
1615
|
+
const threadId = context.MessageThreadId ?? context.ReplyToId;
|
|
1616
|
+
return {
|
|
1617
|
+
currentChannelId: context.To?.trim() || void 0,
|
|
1618
|
+
currentThreadTs: threadId != null ? String(threadId) : void 0,
|
|
1619
|
+
hasRepliedRef
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
},
|
|
1624
|
+
whatsapp: {
|
|
1625
|
+
id: "whatsapp",
|
|
1626
|
+
capabilities: {
|
|
1627
|
+
chatTypes: ["direct", "group"],
|
|
1628
|
+
polls: true,
|
|
1629
|
+
reactions: true,
|
|
1630
|
+
media: true
|
|
1631
|
+
},
|
|
1632
|
+
commands: {
|
|
1633
|
+
enforceOwnerForCommands: true,
|
|
1634
|
+
skipWhenConfigEmpty: true
|
|
1635
|
+
},
|
|
1636
|
+
outbound: { textChunkLimit: 4e3 },
|
|
1637
|
+
config: {
|
|
1638
|
+
resolveAllowFrom: ({ cfg, accountId }) => resolveWhatsAppAccount({
|
|
1639
|
+
cfg,
|
|
1640
|
+
accountId
|
|
1641
|
+
}).allowFrom ?? [],
|
|
1642
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter((entry) => Boolean(entry)).map((entry) => entry === "*" ? entry : normalizeWhatsAppTarget(entry)).filter((entry) => Boolean(entry))
|
|
1643
|
+
},
|
|
1644
|
+
groups: {
|
|
1645
|
+
resolveRequireMention: resolveWhatsAppGroupRequireMention,
|
|
1646
|
+
resolveToolPolicy: resolveWhatsAppGroupToolPolicy,
|
|
1647
|
+
resolveGroupIntroHint: () => "WhatsApp IDs: SenderId is the participant JID; [message_id: ...] is the message id for reactions (use SenderId as participant)."
|
|
1648
|
+
},
|
|
1649
|
+
mentions: { stripPatterns: ({ ctx }) => {
|
|
1650
|
+
const selfE164 = (ctx.To ?? "").replace(/^whatsapp:/, "");
|
|
1651
|
+
if (!selfE164) return [];
|
|
1652
|
+
const escaped = escapeRegExp(selfE164);
|
|
1653
|
+
return [escaped, `@${escaped}`];
|
|
1654
|
+
} },
|
|
1655
|
+
threading: { buildToolContext: ({ context, hasRepliedRef }) => {
|
|
1656
|
+
return {
|
|
1657
|
+
currentChannelId: context.From?.trim() || context.To?.trim() || void 0,
|
|
1658
|
+
currentThreadTs: context.ReplyToId,
|
|
1659
|
+
hasRepliedRef
|
|
1660
|
+
};
|
|
1661
|
+
} }
|
|
1662
|
+
},
|
|
1663
|
+
discord: {
|
|
1664
|
+
id: "discord",
|
|
1665
|
+
capabilities: {
|
|
1666
|
+
chatTypes: [
|
|
1667
|
+
"direct",
|
|
1668
|
+
"channel",
|
|
1669
|
+
"thread"
|
|
1670
|
+
],
|
|
1671
|
+
polls: true,
|
|
1672
|
+
reactions: true,
|
|
1673
|
+
media: true,
|
|
1674
|
+
nativeCommands: true,
|
|
1675
|
+
threads: true
|
|
1676
|
+
},
|
|
1677
|
+
outbound: { textChunkLimit: 2e3 },
|
|
1678
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
1679
|
+
minChars: 1500,
|
|
1680
|
+
idleMs: 1e3
|
|
1681
|
+
} },
|
|
1682
|
+
elevated: { allowFromFallback: ({ cfg }) => cfg.channels?.discord?.dm?.allowFrom },
|
|
1683
|
+
config: {
|
|
1684
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveDiscordAccount({
|
|
1685
|
+
cfg,
|
|
1686
|
+
accountId
|
|
1687
|
+
}).config.dm?.allowFrom ?? []).map((entry) => String(entry)),
|
|
1688
|
+
formatAllowFrom: ({ allowFrom }) => formatLower(allowFrom)
|
|
1689
|
+
},
|
|
1690
|
+
groups: {
|
|
1691
|
+
resolveRequireMention: resolveDiscordGroupRequireMention,
|
|
1692
|
+
resolveToolPolicy: resolveDiscordGroupToolPolicy
|
|
1693
|
+
},
|
|
1694
|
+
mentions: { stripPatterns: () => ["<@!?\\d+>"] },
|
|
1695
|
+
threading: {
|
|
1696
|
+
resolveReplyToMode: ({ cfg }) => cfg.channels?.discord?.replyToMode ?? "off",
|
|
1697
|
+
buildToolContext: ({ context, hasRepliedRef }) => ({
|
|
1698
|
+
currentChannelId: context.To?.trim() || void 0,
|
|
1699
|
+
currentThreadTs: context.ReplyToId,
|
|
1700
|
+
hasRepliedRef
|
|
1701
|
+
})
|
|
1702
|
+
}
|
|
1703
|
+
},
|
|
1704
|
+
googlechat: {
|
|
1705
|
+
id: "googlechat",
|
|
1706
|
+
capabilities: {
|
|
1707
|
+
chatTypes: [
|
|
1708
|
+
"direct",
|
|
1709
|
+
"group",
|
|
1710
|
+
"thread"
|
|
1711
|
+
],
|
|
1712
|
+
reactions: true,
|
|
1713
|
+
media: true,
|
|
1714
|
+
threads: true,
|
|
1715
|
+
blockStreaming: true
|
|
1716
|
+
},
|
|
1717
|
+
outbound: { textChunkLimit: 4e3 },
|
|
1718
|
+
config: {
|
|
1719
|
+
resolveAllowFrom: ({ cfg, accountId }) => {
|
|
1720
|
+
const channel = cfg.channels?.googlechat;
|
|
1721
|
+
const normalized = normalizeAccountId$1(accountId);
|
|
1722
|
+
return ((channel?.accounts?.[normalized] ?? channel?.accounts?.[Object.keys(channel?.accounts ?? {}).find((key) => key.toLowerCase() === normalized.toLowerCase()) ?? ""])?.dm?.allowFrom ?? channel?.dm?.allowFrom ?? []).map((entry) => String(entry));
|
|
1723
|
+
},
|
|
1724
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry.replace(/^(googlechat|google-chat|gchat):/i, "").replace(/^user:/i, "").replace(/^users\//i, "").toLowerCase())
|
|
1725
|
+
},
|
|
1726
|
+
groups: {
|
|
1727
|
+
resolveRequireMention: resolveGoogleChatGroupRequireMention,
|
|
1728
|
+
resolveToolPolicy: resolveGoogleChatGroupToolPolicy
|
|
1729
|
+
},
|
|
1730
|
+
threading: {
|
|
1731
|
+
resolveReplyToMode: ({ cfg }) => cfg.channels?.googlechat?.replyToMode ?? "off",
|
|
1732
|
+
buildToolContext: ({ context, hasRepliedRef }) => {
|
|
1733
|
+
const threadId = context.MessageThreadId ?? context.ReplyToId;
|
|
1734
|
+
return {
|
|
1735
|
+
currentChannelId: context.To?.trim() || void 0,
|
|
1736
|
+
currentThreadTs: threadId != null ? String(threadId) : void 0,
|
|
1737
|
+
hasRepliedRef
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
slack: {
|
|
1743
|
+
id: "slack",
|
|
1744
|
+
capabilities: {
|
|
1745
|
+
chatTypes: [
|
|
1746
|
+
"direct",
|
|
1747
|
+
"channel",
|
|
1748
|
+
"thread"
|
|
1749
|
+
],
|
|
1750
|
+
reactions: true,
|
|
1751
|
+
media: true,
|
|
1752
|
+
nativeCommands: true,
|
|
1753
|
+
threads: true
|
|
1754
|
+
},
|
|
1755
|
+
outbound: { textChunkLimit: 4e3 },
|
|
1756
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
1757
|
+
minChars: 1500,
|
|
1758
|
+
idleMs: 1e3
|
|
1759
|
+
} },
|
|
1760
|
+
config: {
|
|
1761
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveSlackAccount({
|
|
1762
|
+
cfg,
|
|
1763
|
+
accountId
|
|
1764
|
+
}).dm?.allowFrom ?? []).map((entry) => String(entry)),
|
|
1765
|
+
formatAllowFrom: ({ allowFrom }) => formatLower(allowFrom)
|
|
1766
|
+
},
|
|
1767
|
+
groups: {
|
|
1768
|
+
resolveRequireMention: resolveSlackGroupRequireMention,
|
|
1769
|
+
resolveToolPolicy: resolveSlackGroupToolPolicy
|
|
1770
|
+
},
|
|
1771
|
+
threading: {
|
|
1772
|
+
resolveReplyToMode: ({ cfg, accountId, chatType }) => resolveSlackReplyToMode(resolveSlackAccount({
|
|
1773
|
+
cfg,
|
|
1774
|
+
accountId
|
|
1775
|
+
}), chatType),
|
|
1776
|
+
allowTagsWhenOff: true,
|
|
1777
|
+
buildToolContext: (params) => buildSlackThreadingToolContext(params)
|
|
1778
|
+
}
|
|
1779
|
+
},
|
|
1780
|
+
signal: {
|
|
1781
|
+
id: "signal",
|
|
1782
|
+
capabilities: {
|
|
1783
|
+
chatTypes: ["direct", "group"],
|
|
1784
|
+
reactions: true,
|
|
1785
|
+
media: true
|
|
1786
|
+
},
|
|
1787
|
+
outbound: { textChunkLimit: 4e3 },
|
|
1788
|
+
streaming: { blockStreamingCoalesceDefaults: {
|
|
1789
|
+
minChars: 1500,
|
|
1790
|
+
idleMs: 1e3
|
|
1791
|
+
} },
|
|
1792
|
+
config: {
|
|
1793
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveSignalAccount({
|
|
1794
|
+
cfg,
|
|
1795
|
+
accountId
|
|
1796
|
+
}).config.allowFrom ?? []).map((entry) => String(entry)),
|
|
1797
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean).map((entry) => entry === "*" ? "*" : normalizeE164(entry.replace(/^signal:/i, ""))).filter(Boolean)
|
|
1798
|
+
},
|
|
1799
|
+
threading: { buildToolContext: ({ context, hasRepliedRef }) => {
|
|
1800
|
+
return {
|
|
1801
|
+
currentChannelId: (context.ChatType?.toLowerCase() === "direct" ? context.From ?? context.To : context.To)?.trim() || void 0,
|
|
1802
|
+
currentThreadTs: context.ReplyToId,
|
|
1803
|
+
hasRepliedRef
|
|
1804
|
+
};
|
|
1805
|
+
} }
|
|
1806
|
+
},
|
|
1807
|
+
imessage: {
|
|
1808
|
+
id: "imessage",
|
|
1809
|
+
capabilities: {
|
|
1810
|
+
chatTypes: ["direct", "group"],
|
|
1811
|
+
reactions: true,
|
|
1812
|
+
media: true
|
|
1813
|
+
},
|
|
1814
|
+
outbound: { textChunkLimit: 4e3 },
|
|
1815
|
+
config: {
|
|
1816
|
+
resolveAllowFrom: ({ cfg, accountId }) => (resolveIMessageAccount({
|
|
1817
|
+
cfg,
|
|
1818
|
+
accountId
|
|
1819
|
+
}).config.allowFrom ?? []).map((entry) => String(entry)),
|
|
1820
|
+
formatAllowFrom: ({ allowFrom }) => allowFrom.map((entry) => String(entry).trim()).filter(Boolean)
|
|
1821
|
+
},
|
|
1822
|
+
groups: {
|
|
1823
|
+
resolveRequireMention: resolveIMessageGroupRequireMention,
|
|
1824
|
+
resolveToolPolicy: resolveIMessageGroupToolPolicy
|
|
1825
|
+
},
|
|
1826
|
+
threading: { buildToolContext: ({ context, hasRepliedRef }) => {
|
|
1827
|
+
return {
|
|
1828
|
+
currentChannelId: (context.ChatType?.toLowerCase() === "direct" ? context.From ?? context.To : context.To)?.trim() || void 0,
|
|
1829
|
+
currentThreadTs: context.ReplyToId,
|
|
1830
|
+
hasRepliedRef
|
|
1831
|
+
};
|
|
1832
|
+
} }
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
function buildDockFromPlugin(plugin) {
|
|
1836
|
+
return {
|
|
1837
|
+
id: plugin.id,
|
|
1838
|
+
capabilities: plugin.capabilities,
|
|
1839
|
+
commands: plugin.commands,
|
|
1840
|
+
outbound: plugin.outbound?.textChunkLimit ? { textChunkLimit: plugin.outbound.textChunkLimit } : void 0,
|
|
1841
|
+
streaming: plugin.streaming ? { blockStreamingCoalesceDefaults: plugin.streaming.blockStreamingCoalesceDefaults } : void 0,
|
|
1842
|
+
elevated: plugin.elevated,
|
|
1843
|
+
config: plugin.config ? {
|
|
1844
|
+
resolveAllowFrom: plugin.config.resolveAllowFrom,
|
|
1845
|
+
formatAllowFrom: plugin.config.formatAllowFrom
|
|
1846
|
+
} : void 0,
|
|
1847
|
+
groups: plugin.groups,
|
|
1848
|
+
mentions: plugin.mentions,
|
|
1849
|
+
threading: plugin.threading,
|
|
1850
|
+
agentPrompt: plugin.agentPrompt
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
function listPluginDockEntries() {
|
|
1854
|
+
const registry = requireActivePluginRegistry();
|
|
1855
|
+
const entries = [];
|
|
1856
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1857
|
+
for (const entry of registry.channels) {
|
|
1858
|
+
const plugin = entry.plugin;
|
|
1859
|
+
const id = String(plugin.id).trim();
|
|
1860
|
+
if (!id || seen.has(id)) continue;
|
|
1861
|
+
seen.add(id);
|
|
1862
|
+
if (CHAT_CHANNEL_ORDER.includes(plugin.id)) continue;
|
|
1863
|
+
const dock = entry.dock ?? buildDockFromPlugin(plugin);
|
|
1864
|
+
entries.push({
|
|
1865
|
+
id: plugin.id,
|
|
1866
|
+
dock,
|
|
1867
|
+
order: plugin.meta.order
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
return entries;
|
|
1871
|
+
}
|
|
1872
|
+
function listChannelDocks() {
|
|
1873
|
+
const baseEntries = CHAT_CHANNEL_ORDER.map((id) => ({
|
|
1874
|
+
id,
|
|
1875
|
+
dock: DOCKS[id],
|
|
1876
|
+
order: getChatChannelMeta(id).order
|
|
1877
|
+
}));
|
|
1878
|
+
const pluginEntries = listPluginDockEntries();
|
|
1879
|
+
const combined = [...baseEntries, ...pluginEntries];
|
|
1880
|
+
combined.sort((a, b) => {
|
|
1881
|
+
const indexA = CHAT_CHANNEL_ORDER.indexOf(a.id);
|
|
1882
|
+
const indexB = CHAT_CHANNEL_ORDER.indexOf(b.id);
|
|
1883
|
+
const orderA = a.order ?? (indexA === -1 ? 999 : indexA);
|
|
1884
|
+
const orderB = b.order ?? (indexB === -1 ? 999 : indexB);
|
|
1885
|
+
if (orderA !== orderB) return orderA - orderB;
|
|
1886
|
+
return String(a.id).localeCompare(String(b.id));
|
|
1887
|
+
});
|
|
1888
|
+
return combined.map((entry) => entry.dock);
|
|
1889
|
+
}
|
|
1890
|
+
function getChannelDock(id) {
|
|
1891
|
+
const core = DOCKS[id];
|
|
1892
|
+
if (core) return core;
|
|
1893
|
+
const pluginEntry = requireActivePluginRegistry().channels.find((entry) => entry.plugin.id === id);
|
|
1894
|
+
if (!pluginEntry) return;
|
|
1895
|
+
return pluginEntry.dock ?? buildDockFromPlugin(pluginEntry.plugin);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
//#endregion
|
|
1899
|
+
//#region src/config/sessions/metadata.ts
|
|
1900
|
+
const mergeOrigin = (existing, next) => {
|
|
1901
|
+
if (!existing && !next) return;
|
|
1902
|
+
const merged = existing ? { ...existing } : {};
|
|
1903
|
+
if (next?.label) merged.label = next.label;
|
|
1904
|
+
if (next?.provider) merged.provider = next.provider;
|
|
1905
|
+
if (next?.surface) merged.surface = next.surface;
|
|
1906
|
+
if (next?.chatType) merged.chatType = next.chatType;
|
|
1907
|
+
if (next?.from) merged.from = next.from;
|
|
1908
|
+
if (next?.to) merged.to = next.to;
|
|
1909
|
+
if (next?.accountId) merged.accountId = next.accountId;
|
|
1910
|
+
if (next?.threadId != null && next.threadId !== "") merged.threadId = next.threadId;
|
|
1911
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
1912
|
+
};
|
|
1913
|
+
function deriveSessionOrigin(ctx) {
|
|
1914
|
+
const label = resolveConversationLabel(ctx)?.trim();
|
|
1915
|
+
const provider = normalizeMessageChannel(typeof ctx.OriginatingChannel === "string" && ctx.OriginatingChannel || ctx.Surface || ctx.Provider);
|
|
1916
|
+
const surface = ctx.Surface?.trim().toLowerCase();
|
|
1917
|
+
const chatType = normalizeChatType(ctx.ChatType) ?? void 0;
|
|
1918
|
+
const from = ctx.From?.trim();
|
|
1919
|
+
const to = (typeof ctx.OriginatingTo === "string" ? ctx.OriginatingTo : ctx.To)?.trim() ?? void 0;
|
|
1920
|
+
const accountId = ctx.AccountId?.trim();
|
|
1921
|
+
const threadId = ctx.MessageThreadId ?? void 0;
|
|
1922
|
+
const origin = {};
|
|
1923
|
+
if (label) origin.label = label;
|
|
1924
|
+
if (provider) origin.provider = provider;
|
|
1925
|
+
if (surface) origin.surface = surface;
|
|
1926
|
+
if (chatType) origin.chatType = chatType;
|
|
1927
|
+
if (from) origin.from = from;
|
|
1928
|
+
if (to) origin.to = to;
|
|
1929
|
+
if (accountId) origin.accountId = accountId;
|
|
1930
|
+
if (threadId != null && threadId !== "") origin.threadId = threadId;
|
|
1931
|
+
return Object.keys(origin).length > 0 ? origin : void 0;
|
|
1932
|
+
}
|
|
1933
|
+
function snapshotSessionOrigin(entry) {
|
|
1934
|
+
if (!entry?.origin) return;
|
|
1935
|
+
return { ...entry.origin };
|
|
1936
|
+
}
|
|
1937
|
+
function deriveGroupSessionPatch(params) {
|
|
1938
|
+
const resolution = params.groupResolution ?? resolveGroupSessionKey(params.ctx);
|
|
1939
|
+
if (!resolution?.channel) return null;
|
|
1940
|
+
const channel = resolution.channel;
|
|
1941
|
+
const subject = params.ctx.GroupSubject?.trim();
|
|
1942
|
+
const space = params.ctx.GroupSpace?.trim();
|
|
1943
|
+
const explicitChannel = params.ctx.GroupChannel?.trim();
|
|
1944
|
+
const normalizedChannel = normalizeChannelId(channel);
|
|
1945
|
+
const isChannelProvider = Boolean(normalizedChannel && getChannelDock(normalizedChannel)?.capabilities.chatTypes.includes("channel"));
|
|
1946
|
+
const nextGroupChannel = explicitChannel ?? ((resolution.chatType === "channel" || isChannelProvider) && subject && subject.startsWith("#") ? subject : void 0);
|
|
1947
|
+
const nextSubject = nextGroupChannel ? void 0 : subject;
|
|
1948
|
+
const patch = {
|
|
1949
|
+
chatType: resolution.chatType ?? "group",
|
|
1950
|
+
channel,
|
|
1951
|
+
groupId: resolution.id
|
|
1952
|
+
};
|
|
1953
|
+
if (nextSubject) patch.subject = nextSubject;
|
|
1954
|
+
if (nextGroupChannel) patch.groupChannel = nextGroupChannel;
|
|
1955
|
+
if (space) patch.space = space;
|
|
1956
|
+
const displayName = buildGroupDisplayName({
|
|
1957
|
+
provider: channel,
|
|
1958
|
+
subject: nextSubject ?? params.existing?.subject,
|
|
1959
|
+
groupChannel: nextGroupChannel ?? params.existing?.groupChannel,
|
|
1960
|
+
space: space ?? params.existing?.space,
|
|
1961
|
+
id: resolution.id,
|
|
1962
|
+
key: params.sessionKey
|
|
1963
|
+
});
|
|
1964
|
+
if (displayName) patch.displayName = displayName;
|
|
1965
|
+
return patch;
|
|
1966
|
+
}
|
|
1967
|
+
function deriveSessionMetaPatch(params) {
|
|
1968
|
+
const groupPatch = deriveGroupSessionPatch(params);
|
|
1969
|
+
const origin = deriveSessionOrigin(params.ctx);
|
|
1970
|
+
if (!groupPatch && !origin) return null;
|
|
1971
|
+
const patch = groupPatch ? { ...groupPatch } : {};
|
|
1972
|
+
const mergedOrigin = mergeOrigin(params.existing?.origin, origin);
|
|
1973
|
+
if (mergedOrigin) patch.origin = mergedOrigin;
|
|
1974
|
+
return Object.keys(patch).length > 0 ? patch : null;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
//#endregion
|
|
1978
|
+
//#region src/config/sessions/main-session.ts
|
|
1979
|
+
function resolveMainSessionKey(cfg) {
|
|
1980
|
+
if (cfg?.session?.scope === "global") return "global";
|
|
1981
|
+
const agents = cfg?.agents?.list ?? [];
|
|
1982
|
+
return buildAgentMainSessionKey({
|
|
1983
|
+
agentId: normalizeAgentId(agents.find((agent) => agent?.default)?.id ?? agents[0]?.id ?? DEFAULT_AGENT_ID),
|
|
1984
|
+
mainKey: normalizeMainKey(cfg?.session?.mainKey)
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
function resolveMainSessionKeyFromConfig() {
|
|
1988
|
+
return resolveMainSessionKey(loadConfig());
|
|
1989
|
+
}
|
|
1990
|
+
function resolveAgentMainSessionKey(params) {
|
|
1991
|
+
const mainKey = normalizeMainKey(params.cfg?.session?.mainKey);
|
|
1992
|
+
return buildAgentMainSessionKey({
|
|
1993
|
+
agentId: params.agentId,
|
|
1994
|
+
mainKey
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
function resolveExplicitAgentSessionKey(params) {
|
|
1998
|
+
const agentId = params.agentId?.trim();
|
|
1999
|
+
if (!agentId) return;
|
|
2000
|
+
return resolveAgentMainSessionKey({
|
|
2001
|
+
cfg: params.cfg,
|
|
2002
|
+
agentId
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
function canonicalizeMainSessionAlias(params) {
|
|
2006
|
+
const raw = params.sessionKey.trim();
|
|
2007
|
+
if (!raw) return raw;
|
|
2008
|
+
const agentId = normalizeAgentId(params.agentId);
|
|
2009
|
+
const mainKey = normalizeMainKey(params.cfg?.session?.mainKey);
|
|
2010
|
+
const agentMainSessionKey = buildAgentMainSessionKey({
|
|
2011
|
+
agentId,
|
|
2012
|
+
mainKey
|
|
2013
|
+
});
|
|
2014
|
+
const agentMainAliasKey = buildAgentMainSessionKey({
|
|
2015
|
+
agentId,
|
|
2016
|
+
mainKey: "main"
|
|
2017
|
+
});
|
|
2018
|
+
const isMainAlias = raw === "main" || raw === mainKey || raw === agentMainSessionKey || raw === agentMainAliasKey;
|
|
2019
|
+
if (params.cfg?.session?.scope === "global" && isMainAlias) return "global";
|
|
2020
|
+
if (isMainAlias) return agentMainSessionKey;
|
|
2021
|
+
return raw;
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region src/config/sessions/types.ts
|
|
2026
|
+
function mergeSessionEntry(existing, patch) {
|
|
2027
|
+
const sessionId = patch.sessionId ?? existing?.sessionId ?? crypto.randomUUID();
|
|
2028
|
+
const updatedAt = Math.max(existing?.updatedAt ?? 0, patch.updatedAt ?? 0, Date.now());
|
|
2029
|
+
if (!existing) return {
|
|
2030
|
+
...patch,
|
|
2031
|
+
sessionId,
|
|
2032
|
+
updatedAt
|
|
2033
|
+
};
|
|
2034
|
+
return {
|
|
2035
|
+
...existing,
|
|
2036
|
+
...patch,
|
|
2037
|
+
sessionId,
|
|
2038
|
+
updatedAt
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
const DEFAULT_RESET_TRIGGERS = ["/new", "/reset"];
|
|
2042
|
+
const DEFAULT_IDLE_MINUTES = 60;
|
|
2043
|
+
|
|
2044
|
+
//#endregion
|
|
2045
|
+
//#region src/config/sessions/reset.ts
|
|
2046
|
+
const DEFAULT_RESET_MODE = "daily";
|
|
2047
|
+
const DEFAULT_RESET_AT_HOUR = 4;
|
|
2048
|
+
const THREAD_SESSION_MARKERS = [":thread:", ":topic:"];
|
|
2049
|
+
const GROUP_SESSION_MARKERS = [":group:", ":channel:"];
|
|
2050
|
+
function isThreadSessionKey(sessionKey) {
|
|
2051
|
+
const normalized = (sessionKey ?? "").toLowerCase();
|
|
2052
|
+
if (!normalized) return false;
|
|
2053
|
+
return THREAD_SESSION_MARKERS.some((marker) => normalized.includes(marker));
|
|
2054
|
+
}
|
|
2055
|
+
function resolveSessionResetType(params) {
|
|
2056
|
+
if (params.isThread || isThreadSessionKey(params.sessionKey)) return "thread";
|
|
2057
|
+
if (params.isGroup) return "group";
|
|
2058
|
+
const normalized = (params.sessionKey ?? "").toLowerCase();
|
|
2059
|
+
if (GROUP_SESSION_MARKERS.some((marker) => normalized.includes(marker))) return "group";
|
|
2060
|
+
return "dm";
|
|
2061
|
+
}
|
|
2062
|
+
function resolveThreadFlag(params) {
|
|
2063
|
+
if (params.messageThreadId != null) return true;
|
|
2064
|
+
if (params.threadLabel?.trim()) return true;
|
|
2065
|
+
if (params.threadStarterBody?.trim()) return true;
|
|
2066
|
+
if (params.parentSessionKey?.trim()) return true;
|
|
2067
|
+
return isThreadSessionKey(params.sessionKey);
|
|
2068
|
+
}
|
|
2069
|
+
function resolveDailyResetAtMs(now, atHour) {
|
|
2070
|
+
const normalizedAtHour = normalizeResetAtHour(atHour);
|
|
2071
|
+
const resetAt = new Date(now);
|
|
2072
|
+
resetAt.setHours(normalizedAtHour, 0, 0, 0);
|
|
2073
|
+
if (now < resetAt.getTime()) resetAt.setDate(resetAt.getDate() - 1);
|
|
2074
|
+
return resetAt.getTime();
|
|
2075
|
+
}
|
|
2076
|
+
function resolveSessionResetPolicy(params) {
|
|
2077
|
+
const sessionCfg = params.sessionCfg;
|
|
2078
|
+
const baseReset = params.resetOverride ?? sessionCfg?.reset;
|
|
2079
|
+
const typeReset = params.resetOverride ? void 0 : sessionCfg?.resetByType?.[params.resetType];
|
|
2080
|
+
const hasExplicitReset = Boolean(baseReset || sessionCfg?.resetByType);
|
|
2081
|
+
const legacyIdleMinutes = params.resetOverride ? void 0 : sessionCfg?.idleMinutes;
|
|
2082
|
+
const mode = typeReset?.mode ?? baseReset?.mode ?? (!hasExplicitReset && legacyIdleMinutes != null ? "idle" : DEFAULT_RESET_MODE);
|
|
2083
|
+
const atHour = normalizeResetAtHour(typeReset?.atHour ?? baseReset?.atHour ?? DEFAULT_RESET_AT_HOUR);
|
|
2084
|
+
const idleMinutesRaw = typeReset?.idleMinutes ?? baseReset?.idleMinutes ?? legacyIdleMinutes;
|
|
2085
|
+
let idleMinutes;
|
|
2086
|
+
if (idleMinutesRaw != null) {
|
|
2087
|
+
const normalized = Math.floor(idleMinutesRaw);
|
|
2088
|
+
if (Number.isFinite(normalized)) idleMinutes = Math.max(normalized, 1);
|
|
2089
|
+
} else if (mode === "idle") idleMinutes = DEFAULT_IDLE_MINUTES;
|
|
2090
|
+
return {
|
|
2091
|
+
mode,
|
|
2092
|
+
atHour,
|
|
2093
|
+
idleMinutes
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2096
|
+
function resolveChannelResetConfig(params) {
|
|
2097
|
+
const resetByChannel = params.sessionCfg?.resetByChannel;
|
|
2098
|
+
if (!resetByChannel) return;
|
|
2099
|
+
const normalized = normalizeMessageChannel(params.channel);
|
|
2100
|
+
const fallback = params.channel?.trim().toLowerCase();
|
|
2101
|
+
const key = normalized ?? fallback;
|
|
2102
|
+
if (!key) return;
|
|
2103
|
+
return resetByChannel[key] ?? resetByChannel[key.toLowerCase()];
|
|
2104
|
+
}
|
|
2105
|
+
function evaluateSessionFreshness(params) {
|
|
2106
|
+
const dailyResetAt = params.policy.mode === "daily" ? resolveDailyResetAtMs(params.now, params.policy.atHour) : void 0;
|
|
2107
|
+
const idleExpiresAt = params.policy.idleMinutes != null ? params.updatedAt + params.policy.idleMinutes * 6e4 : void 0;
|
|
2108
|
+
const staleDaily = dailyResetAt != null && params.updatedAt < dailyResetAt;
|
|
2109
|
+
const staleIdle = idleExpiresAt != null && params.now > idleExpiresAt;
|
|
2110
|
+
return {
|
|
2111
|
+
fresh: !(staleDaily || staleIdle),
|
|
2112
|
+
dailyResetAt,
|
|
2113
|
+
idleExpiresAt
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
function normalizeResetAtHour(value) {
|
|
2117
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return DEFAULT_RESET_AT_HOUR;
|
|
2118
|
+
const normalized = Math.floor(value);
|
|
2119
|
+
if (!Number.isFinite(normalized)) return DEFAULT_RESET_AT_HOUR;
|
|
2120
|
+
if (normalized < 0) return 0;
|
|
2121
|
+
if (normalized > 23) return 23;
|
|
2122
|
+
return normalized;
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
//#endregion
|
|
2126
|
+
//#region src/config/sessions/session-key.ts
|
|
2127
|
+
function deriveSessionKey(scope, ctx) {
|
|
2128
|
+
if (scope === "global") return "global";
|
|
2129
|
+
const resolvedGroup = resolveGroupSessionKey(ctx);
|
|
2130
|
+
if (resolvedGroup) return resolvedGroup.key;
|
|
2131
|
+
return (ctx.From ? normalizeE164(ctx.From) : "") || "unknown";
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Resolve the session key with a canonical direct-chat bucket (default: "main").
|
|
2135
|
+
* All non-group direct chats collapse to this bucket; groups stay isolated.
|
|
2136
|
+
*/
|
|
2137
|
+
function resolveSessionKey(scope, ctx, mainKey) {
|
|
2138
|
+
const explicit = ctx.SessionKey?.trim();
|
|
2139
|
+
if (explicit) return explicit.toLowerCase();
|
|
2140
|
+
const raw = deriveSessionKey(scope, ctx);
|
|
2141
|
+
if (scope === "global") return raw;
|
|
2142
|
+
const canonical = buildAgentMainSessionKey({
|
|
2143
|
+
agentId: DEFAULT_AGENT_ID,
|
|
2144
|
+
mainKey: normalizeMainKey(mainKey)
|
|
2145
|
+
});
|
|
2146
|
+
if (!(raw.includes(":group:") || raw.includes(":channel:"))) return canonical;
|
|
2147
|
+
return `agent:${DEFAULT_AGENT_ID}:${raw}`;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
//#endregion
|
|
2151
|
+
//#region src/utils/account-id.ts
|
|
2152
|
+
function normalizeAccountId(value) {
|
|
2153
|
+
if (typeof value !== "string") return;
|
|
2154
|
+
return value.trim() || void 0;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
//#endregion
|
|
2158
|
+
//#region src/utils/delivery-context.ts
|
|
2159
|
+
function normalizeDeliveryContext(context) {
|
|
2160
|
+
if (!context) return;
|
|
2161
|
+
const channel = typeof context.channel === "string" ? normalizeMessageChannel(context.channel) ?? context.channel.trim() : void 0;
|
|
2162
|
+
const to = typeof context.to === "string" ? context.to.trim() : void 0;
|
|
2163
|
+
const accountId = normalizeAccountId(context.accountId);
|
|
2164
|
+
const threadId = typeof context.threadId === "number" && Number.isFinite(context.threadId) ? Math.trunc(context.threadId) : typeof context.threadId === "string" ? context.threadId.trim() : void 0;
|
|
2165
|
+
const normalizedThreadId = typeof threadId === "string" ? threadId ? threadId : void 0 : threadId;
|
|
2166
|
+
if (!channel && !to && !accountId && normalizedThreadId == null) return;
|
|
2167
|
+
const normalized = {
|
|
2168
|
+
channel: channel || void 0,
|
|
2169
|
+
to: to || void 0,
|
|
2170
|
+
accountId
|
|
2171
|
+
};
|
|
2172
|
+
if (normalizedThreadId != null) normalized.threadId = normalizedThreadId;
|
|
2173
|
+
return normalized;
|
|
2174
|
+
}
|
|
2175
|
+
function normalizeSessionDeliveryFields(source) {
|
|
2176
|
+
if (!source) return {
|
|
2177
|
+
deliveryContext: void 0,
|
|
2178
|
+
lastChannel: void 0,
|
|
2179
|
+
lastTo: void 0,
|
|
2180
|
+
lastAccountId: void 0,
|
|
2181
|
+
lastThreadId: void 0
|
|
2182
|
+
};
|
|
2183
|
+
const merged = mergeDeliveryContext(normalizeDeliveryContext({
|
|
2184
|
+
channel: source.lastChannel ?? source.channel,
|
|
2185
|
+
to: source.lastTo,
|
|
2186
|
+
accountId: source.lastAccountId,
|
|
2187
|
+
threadId: source.lastThreadId
|
|
2188
|
+
}), normalizeDeliveryContext(source.deliveryContext));
|
|
2189
|
+
if (!merged) return {
|
|
2190
|
+
deliveryContext: void 0,
|
|
2191
|
+
lastChannel: void 0,
|
|
2192
|
+
lastTo: void 0,
|
|
2193
|
+
lastAccountId: void 0,
|
|
2194
|
+
lastThreadId: void 0
|
|
2195
|
+
};
|
|
2196
|
+
return {
|
|
2197
|
+
deliveryContext: merged,
|
|
2198
|
+
lastChannel: merged.channel,
|
|
2199
|
+
lastTo: merged.to,
|
|
2200
|
+
lastAccountId: merged.accountId,
|
|
2201
|
+
lastThreadId: merged.threadId
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
function deliveryContextFromSession(entry) {
|
|
2205
|
+
if (!entry) return;
|
|
2206
|
+
return normalizeSessionDeliveryFields({
|
|
2207
|
+
channel: entry.channel,
|
|
2208
|
+
lastChannel: entry.lastChannel,
|
|
2209
|
+
lastTo: entry.lastTo,
|
|
2210
|
+
lastAccountId: entry.lastAccountId,
|
|
2211
|
+
lastThreadId: entry.lastThreadId ?? entry.deliveryContext?.threadId ?? entry.origin?.threadId,
|
|
2212
|
+
deliveryContext: entry.deliveryContext
|
|
2213
|
+
}).deliveryContext;
|
|
2214
|
+
}
|
|
2215
|
+
function mergeDeliveryContext(primary, fallback) {
|
|
2216
|
+
const normalizedPrimary = normalizeDeliveryContext(primary);
|
|
2217
|
+
const normalizedFallback = normalizeDeliveryContext(fallback);
|
|
2218
|
+
if (!normalizedPrimary && !normalizedFallback) return;
|
|
2219
|
+
return normalizeDeliveryContext({
|
|
2220
|
+
channel: normalizedPrimary?.channel ?? normalizedFallback?.channel,
|
|
2221
|
+
to: normalizedPrimary?.to ?? normalizedFallback?.to,
|
|
2222
|
+
accountId: normalizedPrimary?.accountId ?? normalizedFallback?.accountId,
|
|
2223
|
+
threadId: normalizedPrimary?.threadId ?? normalizedFallback?.threadId
|
|
2224
|
+
});
|
|
2225
|
+
}
|
|
2226
|
+
function deliveryContextKey(context) {
|
|
2227
|
+
const normalized = normalizeDeliveryContext(context);
|
|
2228
|
+
if (!normalized?.channel || !normalized?.to) return;
|
|
2229
|
+
const threadId = normalized.threadId != null && normalized.threadId !== "" ? String(normalized.threadId) : "";
|
|
2230
|
+
return `${normalized.channel}|${normalized.to}|${normalized.accountId ?? ""}|${threadId}`;
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
//#endregion
|
|
2234
|
+
//#region src/config/cache-utils.ts
|
|
2235
|
+
function resolveCacheTtlMs(params) {
|
|
2236
|
+
const { envValue, defaultTtlMs } = params;
|
|
2237
|
+
if (envValue) {
|
|
2238
|
+
const parsed = Number.parseInt(envValue, 10);
|
|
2239
|
+
if (Number.isFinite(parsed) && parsed >= 0) return parsed;
|
|
2240
|
+
}
|
|
2241
|
+
return defaultTtlMs;
|
|
2242
|
+
}
|
|
2243
|
+
function isCacheEnabled(ttlMs) {
|
|
2244
|
+
return ttlMs > 0;
|
|
2245
|
+
}
|
|
2246
|
+
function getFileMtimeMs(filePath) {
|
|
2247
|
+
try {
|
|
2248
|
+
return fs.statSync(filePath).mtimeMs;
|
|
2249
|
+
} catch {
|
|
2250
|
+
return;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
//#endregion
|
|
2255
|
+
//#region src/config/sessions/store.ts
|
|
2256
|
+
const SESSION_STORE_CACHE = /* @__PURE__ */ new Map();
|
|
2257
|
+
const DEFAULT_SESSION_STORE_TTL_MS = 45e3;
|
|
2258
|
+
function isSessionStoreRecord(value) {
|
|
2259
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2260
|
+
}
|
|
2261
|
+
function getSessionStoreTtl() {
|
|
2262
|
+
return resolveCacheTtlMs({
|
|
2263
|
+
envValue: process.env.OPENCLAW_SESSION_CACHE_TTL_MS,
|
|
2264
|
+
defaultTtlMs: DEFAULT_SESSION_STORE_TTL_MS
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
function isSessionStoreCacheEnabled() {
|
|
2268
|
+
return isCacheEnabled(getSessionStoreTtl());
|
|
2269
|
+
}
|
|
2270
|
+
function isSessionStoreCacheValid(entry) {
|
|
2271
|
+
const now = Date.now();
|
|
2272
|
+
const ttl = getSessionStoreTtl();
|
|
2273
|
+
return now - entry.loadedAt <= ttl;
|
|
2274
|
+
}
|
|
2275
|
+
function invalidateSessionStoreCache(storePath) {
|
|
2276
|
+
SESSION_STORE_CACHE.delete(storePath);
|
|
2277
|
+
}
|
|
2278
|
+
function normalizeSessionEntryDelivery(entry) {
|
|
2279
|
+
const normalized = normalizeSessionDeliveryFields({
|
|
2280
|
+
channel: entry.channel,
|
|
2281
|
+
lastChannel: entry.lastChannel,
|
|
2282
|
+
lastTo: entry.lastTo,
|
|
2283
|
+
lastAccountId: entry.lastAccountId,
|
|
2284
|
+
lastThreadId: entry.lastThreadId ?? entry.deliveryContext?.threadId ?? entry.origin?.threadId,
|
|
2285
|
+
deliveryContext: entry.deliveryContext
|
|
2286
|
+
});
|
|
2287
|
+
const nextDelivery = normalized.deliveryContext;
|
|
2288
|
+
const sameDelivery = (entry.deliveryContext?.channel ?? void 0) === nextDelivery?.channel && (entry.deliveryContext?.to ?? void 0) === nextDelivery?.to && (entry.deliveryContext?.accountId ?? void 0) === nextDelivery?.accountId && (entry.deliveryContext?.threadId ?? void 0) === nextDelivery?.threadId;
|
|
2289
|
+
const sameLast = entry.lastChannel === normalized.lastChannel && entry.lastTo === normalized.lastTo && entry.lastAccountId === normalized.lastAccountId && entry.lastThreadId === normalized.lastThreadId;
|
|
2290
|
+
if (sameDelivery && sameLast) return entry;
|
|
2291
|
+
return {
|
|
2292
|
+
...entry,
|
|
2293
|
+
deliveryContext: nextDelivery,
|
|
2294
|
+
lastChannel: normalized.lastChannel,
|
|
2295
|
+
lastTo: normalized.lastTo,
|
|
2296
|
+
lastAccountId: normalized.lastAccountId,
|
|
2297
|
+
lastThreadId: normalized.lastThreadId
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
function normalizeSessionStore(store) {
|
|
2301
|
+
for (const [key, entry] of Object.entries(store)) {
|
|
2302
|
+
if (!entry) continue;
|
|
2303
|
+
const normalized = normalizeSessionEntryDelivery(entry);
|
|
2304
|
+
if (normalized !== entry) store[key] = normalized;
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
function loadSessionStore(storePath, opts = {}) {
|
|
2308
|
+
if (!opts.skipCache && isSessionStoreCacheEnabled()) {
|
|
2309
|
+
const cached = SESSION_STORE_CACHE.get(storePath);
|
|
2310
|
+
if (cached && isSessionStoreCacheValid(cached)) {
|
|
2311
|
+
if (getFileMtimeMs(storePath) === cached.mtimeMs) return structuredClone(cached.store);
|
|
2312
|
+
invalidateSessionStoreCache(storePath);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
let store = {};
|
|
2316
|
+
let mtimeMs = getFileMtimeMs(storePath);
|
|
2317
|
+
try {
|
|
2318
|
+
const raw = fs.readFileSync(storePath, "utf-8");
|
|
2319
|
+
const parsed = JSON5.parse(raw);
|
|
2320
|
+
if (isSessionStoreRecord(parsed)) store = parsed;
|
|
2321
|
+
mtimeMs = getFileMtimeMs(storePath) ?? mtimeMs;
|
|
2322
|
+
} catch {}
|
|
2323
|
+
for (const entry of Object.values(store)) {
|
|
2324
|
+
if (!entry || typeof entry !== "object") continue;
|
|
2325
|
+
const rec = entry;
|
|
2326
|
+
if (typeof rec.channel !== "string" && typeof rec.provider === "string") {
|
|
2327
|
+
rec.channel = rec.provider;
|
|
2328
|
+
delete rec.provider;
|
|
2329
|
+
}
|
|
2330
|
+
if (typeof rec.lastChannel !== "string" && typeof rec.lastProvider === "string") {
|
|
2331
|
+
rec.lastChannel = rec.lastProvider;
|
|
2332
|
+
delete rec.lastProvider;
|
|
2333
|
+
}
|
|
2334
|
+
if (typeof rec.groupChannel !== "string" && typeof rec.room === "string") {
|
|
2335
|
+
rec.groupChannel = rec.room;
|
|
2336
|
+
delete rec.room;
|
|
2337
|
+
} else if ("room" in rec) delete rec.room;
|
|
2338
|
+
}
|
|
2339
|
+
if (!opts.skipCache && isSessionStoreCacheEnabled()) SESSION_STORE_CACHE.set(storePath, {
|
|
2340
|
+
store: structuredClone(store),
|
|
2341
|
+
loadedAt: Date.now(),
|
|
2342
|
+
storePath,
|
|
2343
|
+
mtimeMs
|
|
2344
|
+
});
|
|
2345
|
+
return structuredClone(store);
|
|
2346
|
+
}
|
|
2347
|
+
function readSessionUpdatedAt(params) {
|
|
2348
|
+
try {
|
|
2349
|
+
return loadSessionStore(params.storePath)[params.sessionKey]?.updatedAt;
|
|
2350
|
+
} catch {
|
|
2351
|
+
return;
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
async function saveSessionStoreUnlocked(storePath, store) {
|
|
2355
|
+
invalidateSessionStoreCache(storePath);
|
|
2356
|
+
normalizeSessionStore(store);
|
|
2357
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
2358
|
+
const json = JSON.stringify(store, null, 2);
|
|
2359
|
+
if (process.platform === "win32") {
|
|
2360
|
+
try {
|
|
2361
|
+
await fs.promises.writeFile(storePath, json, "utf-8");
|
|
2362
|
+
} catch (err) {
|
|
2363
|
+
if ((err && typeof err === "object" && "code" in err ? String(err.code) : null) === "ENOENT") return;
|
|
2364
|
+
throw err;
|
|
2365
|
+
}
|
|
2366
|
+
return;
|
|
2367
|
+
}
|
|
2368
|
+
const tmp = `${storePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
2369
|
+
try {
|
|
2370
|
+
await fs.promises.writeFile(tmp, json, {
|
|
2371
|
+
mode: 384,
|
|
2372
|
+
encoding: "utf-8"
|
|
2373
|
+
});
|
|
2374
|
+
await fs.promises.rename(tmp, storePath);
|
|
2375
|
+
await fs.promises.chmod(storePath, 384);
|
|
2376
|
+
} catch (err) {
|
|
2377
|
+
if ((err && typeof err === "object" && "code" in err ? String(err.code) : null) === "ENOENT") {
|
|
2378
|
+
try {
|
|
2379
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
2380
|
+
await fs.promises.writeFile(storePath, json, {
|
|
2381
|
+
mode: 384,
|
|
2382
|
+
encoding: "utf-8"
|
|
2383
|
+
});
|
|
2384
|
+
await fs.promises.chmod(storePath, 384);
|
|
2385
|
+
} catch (err2) {
|
|
2386
|
+
if ((err2 && typeof err2 === "object" && "code" in err2 ? String(err2.code) : null) === "ENOENT") return;
|
|
2387
|
+
throw err2;
|
|
2388
|
+
}
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
throw err;
|
|
2392
|
+
} finally {
|
|
2393
|
+
await fs.promises.rm(tmp, { force: true });
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
async function saveSessionStore(storePath, store) {
|
|
2397
|
+
await withSessionStoreLock(storePath, async () => {
|
|
2398
|
+
await saveSessionStoreUnlocked(storePath, store);
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
async function updateSessionStore(storePath, mutator) {
|
|
2402
|
+
return await withSessionStoreLock(storePath, async () => {
|
|
2403
|
+
const store = loadSessionStore(storePath, { skipCache: true });
|
|
2404
|
+
const result = await mutator(store);
|
|
2405
|
+
await saveSessionStoreUnlocked(storePath, store);
|
|
2406
|
+
return result;
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
async function withSessionStoreLock(storePath, fn, opts = {}) {
|
|
2410
|
+
const timeoutMs = opts.timeoutMs ?? 1e4;
|
|
2411
|
+
const pollIntervalMs = opts.pollIntervalMs ?? 25;
|
|
2412
|
+
const staleMs = opts.staleMs ?? 3e4;
|
|
2413
|
+
const lockPath = `${storePath}.lock`;
|
|
2414
|
+
const startedAt = Date.now();
|
|
2415
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true });
|
|
2416
|
+
while (true) try {
|
|
2417
|
+
const handle = await fs.promises.open(lockPath, "wx");
|
|
2418
|
+
try {
|
|
2419
|
+
await handle.writeFile(JSON.stringify({
|
|
2420
|
+
pid: process.pid,
|
|
2421
|
+
startedAt: Date.now()
|
|
2422
|
+
}), "utf-8");
|
|
2423
|
+
} catch {}
|
|
2424
|
+
await handle.close();
|
|
2425
|
+
break;
|
|
2426
|
+
} catch (err) {
|
|
2427
|
+
const code = err && typeof err === "object" && "code" in err ? String(err.code) : null;
|
|
2428
|
+
if (code === "ENOENT") {
|
|
2429
|
+
await fs.promises.mkdir(path.dirname(storePath), { recursive: true }).catch(() => void 0);
|
|
2430
|
+
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
2431
|
+
continue;
|
|
2432
|
+
}
|
|
2433
|
+
if (code !== "EEXIST") throw err;
|
|
2434
|
+
const now = Date.now();
|
|
2435
|
+
if (now - startedAt > timeoutMs) throw new Error(`timeout acquiring session store lock: ${lockPath}`, { cause: err });
|
|
2436
|
+
try {
|
|
2437
|
+
if (now - (await fs.promises.stat(lockPath)).mtimeMs > staleMs) {
|
|
2438
|
+
await fs.promises.unlink(lockPath);
|
|
2439
|
+
continue;
|
|
2440
|
+
}
|
|
2441
|
+
} catch {}
|
|
2442
|
+
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
2443
|
+
}
|
|
2444
|
+
try {
|
|
2445
|
+
return await fn();
|
|
2446
|
+
} finally {
|
|
2447
|
+
await fs.promises.unlink(lockPath).catch(() => void 0);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
async function updateSessionStoreEntry(params) {
|
|
2451
|
+
const { storePath, sessionKey, update } = params;
|
|
2452
|
+
return await withSessionStoreLock(storePath, async () => {
|
|
2453
|
+
const store = loadSessionStore(storePath);
|
|
2454
|
+
const existing = store[sessionKey];
|
|
2455
|
+
if (!existing) return null;
|
|
2456
|
+
const patch = await update(existing);
|
|
2457
|
+
if (!patch) return existing;
|
|
2458
|
+
const next = mergeSessionEntry(existing, patch);
|
|
2459
|
+
store[sessionKey] = next;
|
|
2460
|
+
await saveSessionStoreUnlocked(storePath, store);
|
|
2461
|
+
return next;
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
async function recordSessionMetaFromInbound(params) {
|
|
2465
|
+
const { storePath, sessionKey, ctx } = params;
|
|
2466
|
+
const createIfMissing = params.createIfMissing ?? true;
|
|
2467
|
+
return await updateSessionStore(storePath, (store) => {
|
|
2468
|
+
const existing = store[sessionKey];
|
|
2469
|
+
const patch = deriveSessionMetaPatch({
|
|
2470
|
+
ctx,
|
|
2471
|
+
sessionKey,
|
|
2472
|
+
existing,
|
|
2473
|
+
groupResolution: params.groupResolution
|
|
2474
|
+
});
|
|
2475
|
+
if (!patch) return existing ?? null;
|
|
2476
|
+
if (!existing && !createIfMissing) return null;
|
|
2477
|
+
const next = mergeSessionEntry(existing, patch);
|
|
2478
|
+
store[sessionKey] = next;
|
|
2479
|
+
return next;
|
|
2480
|
+
});
|
|
2481
|
+
}
|
|
2482
|
+
async function updateLastRoute(params) {
|
|
2483
|
+
const { storePath, sessionKey, channel, to, accountId, threadId, ctx } = params;
|
|
2484
|
+
return await withSessionStoreLock(storePath, async () => {
|
|
2485
|
+
const store = loadSessionStore(storePath);
|
|
2486
|
+
const existing = store[sessionKey];
|
|
2487
|
+
const now = Date.now();
|
|
2488
|
+
const merged = mergeDeliveryContext(mergeDeliveryContext(normalizeDeliveryContext(params.deliveryContext), normalizeDeliveryContext({
|
|
2489
|
+
channel,
|
|
2490
|
+
to,
|
|
2491
|
+
accountId,
|
|
2492
|
+
threadId
|
|
2493
|
+
})), deliveryContextFromSession(existing));
|
|
2494
|
+
const normalized = normalizeSessionDeliveryFields({ deliveryContext: {
|
|
2495
|
+
channel: merged?.channel,
|
|
2496
|
+
to: merged?.to,
|
|
2497
|
+
accountId: merged?.accountId,
|
|
2498
|
+
threadId: merged?.threadId
|
|
2499
|
+
} });
|
|
2500
|
+
const metaPatch = ctx ? deriveSessionMetaPatch({
|
|
2501
|
+
ctx,
|
|
2502
|
+
sessionKey,
|
|
2503
|
+
existing,
|
|
2504
|
+
groupResolution: params.groupResolution
|
|
2505
|
+
}) : null;
|
|
2506
|
+
const basePatch = {
|
|
2507
|
+
updatedAt: Math.max(existing?.updatedAt ?? 0, now),
|
|
2508
|
+
deliveryContext: normalized.deliveryContext,
|
|
2509
|
+
lastChannel: normalized.lastChannel,
|
|
2510
|
+
lastTo: normalized.lastTo,
|
|
2511
|
+
lastAccountId: normalized.lastAccountId,
|
|
2512
|
+
lastThreadId: normalized.lastThreadId
|
|
2513
|
+
};
|
|
2514
|
+
const next = mergeSessionEntry(existing, metaPatch ? {
|
|
2515
|
+
...basePatch,
|
|
2516
|
+
...metaPatch
|
|
2517
|
+
} : basePatch);
|
|
2518
|
+
store[sessionKey] = next;
|
|
2519
|
+
await saveSessionStoreUnlocked(storePath, store);
|
|
2520
|
+
return next;
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
//#endregion
|
|
2525
|
+
//#region src/config/sessions/transcript.ts
|
|
2526
|
+
function stripQuery(value) {
|
|
2527
|
+
const noHash = value.split("#")[0] ?? value;
|
|
2528
|
+
return noHash.split("?")[0] ?? noHash;
|
|
2529
|
+
}
|
|
2530
|
+
function extractFileNameFromMediaUrl(value) {
|
|
2531
|
+
const trimmed = value.trim();
|
|
2532
|
+
if (!trimmed) return null;
|
|
2533
|
+
const cleaned = stripQuery(trimmed);
|
|
2534
|
+
try {
|
|
2535
|
+
const parsed = new URL(cleaned);
|
|
2536
|
+
const base = path.basename(parsed.pathname);
|
|
2537
|
+
if (!base) return null;
|
|
2538
|
+
try {
|
|
2539
|
+
return decodeURIComponent(base);
|
|
2540
|
+
} catch {
|
|
2541
|
+
return base;
|
|
2542
|
+
}
|
|
2543
|
+
} catch {
|
|
2544
|
+
const base = path.basename(cleaned);
|
|
2545
|
+
if (!base || base === "/" || base === ".") return null;
|
|
2546
|
+
return base;
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
function resolveMirroredTranscriptText(params) {
|
|
2550
|
+
const mediaUrls = params.mediaUrls?.filter((url) => url && url.trim()) ?? [];
|
|
2551
|
+
if (mediaUrls.length > 0) {
|
|
2552
|
+
const names = mediaUrls.map((url) => extractFileNameFromMediaUrl(url)).filter((name) => Boolean(name && name.trim()));
|
|
2553
|
+
if (names.length > 0) return names.join(", ");
|
|
2554
|
+
return "media";
|
|
2555
|
+
}
|
|
2556
|
+
const trimmed = (params.text ?? "").trim();
|
|
2557
|
+
return trimmed ? trimmed : null;
|
|
2558
|
+
}
|
|
2559
|
+
async function ensureSessionHeader(params) {
|
|
2560
|
+
if (fs.existsSync(params.sessionFile)) return;
|
|
2561
|
+
await fs.promises.mkdir(path.dirname(params.sessionFile), { recursive: true });
|
|
2562
|
+
const header = {
|
|
2563
|
+
type: "session",
|
|
2564
|
+
version: CURRENT_SESSION_VERSION,
|
|
2565
|
+
id: params.sessionId,
|
|
2566
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2567
|
+
cwd: process.cwd()
|
|
2568
|
+
};
|
|
2569
|
+
await fs.promises.writeFile(params.sessionFile, `${JSON.stringify(header)}\n`, "utf-8");
|
|
2570
|
+
}
|
|
2571
|
+
async function appendAssistantMessageToSessionTranscript(params) {
|
|
2572
|
+
const sessionKey = params.sessionKey.trim();
|
|
2573
|
+
if (!sessionKey) return {
|
|
2574
|
+
ok: false,
|
|
2575
|
+
reason: "missing sessionKey"
|
|
2576
|
+
};
|
|
2577
|
+
const mirrorText = resolveMirroredTranscriptText({
|
|
2578
|
+
text: params.text,
|
|
2579
|
+
mediaUrls: params.mediaUrls
|
|
2580
|
+
});
|
|
2581
|
+
if (!mirrorText) return {
|
|
2582
|
+
ok: false,
|
|
2583
|
+
reason: "empty text"
|
|
2584
|
+
};
|
|
2585
|
+
const storePath = params.storePath ?? resolveDefaultSessionStorePath(params.agentId);
|
|
2586
|
+
const entry = loadSessionStore(storePath, { skipCache: true })[sessionKey];
|
|
2587
|
+
if (!entry?.sessionId) return {
|
|
2588
|
+
ok: false,
|
|
2589
|
+
reason: `unknown sessionKey: ${sessionKey}`
|
|
2590
|
+
};
|
|
2591
|
+
const sessionFile = entry.sessionFile?.trim() || resolveSessionTranscriptPath(entry.sessionId, params.agentId);
|
|
2592
|
+
await ensureSessionHeader({
|
|
2593
|
+
sessionFile,
|
|
2594
|
+
sessionId: entry.sessionId
|
|
2595
|
+
});
|
|
2596
|
+
SessionManager.open(sessionFile).appendMessage({
|
|
2597
|
+
role: "assistant",
|
|
2598
|
+
content: [{
|
|
2599
|
+
type: "text",
|
|
2600
|
+
text: mirrorText
|
|
2601
|
+
}],
|
|
2602
|
+
api: "openai-responses",
|
|
2603
|
+
provider: "openclaw",
|
|
2604
|
+
model: "delivery-mirror",
|
|
2605
|
+
usage: {
|
|
2606
|
+
input: 0,
|
|
2607
|
+
output: 0,
|
|
2608
|
+
cacheRead: 0,
|
|
2609
|
+
cacheWrite: 0,
|
|
2610
|
+
totalTokens: 0,
|
|
2611
|
+
cost: {
|
|
2612
|
+
input: 0,
|
|
2613
|
+
output: 0,
|
|
2614
|
+
cacheRead: 0,
|
|
2615
|
+
cacheWrite: 0,
|
|
2616
|
+
total: 0
|
|
2617
|
+
}
|
|
2618
|
+
},
|
|
2619
|
+
stopReason: "stop",
|
|
2620
|
+
timestamp: Date.now()
|
|
2621
|
+
});
|
|
2622
|
+
if (!entry.sessionFile || entry.sessionFile !== sessionFile) await updateSessionStore(storePath, (current) => {
|
|
2623
|
+
current[sessionKey] = {
|
|
2624
|
+
...entry,
|
|
2625
|
+
sessionFile
|
|
2626
|
+
};
|
|
2627
|
+
});
|
|
2628
|
+
emitSessionTranscriptUpdate(sessionFile);
|
|
2629
|
+
return {
|
|
2630
|
+
ok: true,
|
|
2631
|
+
sessionFile
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
//#endregion
|
|
2636
|
+
//#region src/agents/sandbox/runtime-status.ts
|
|
2637
|
+
function shouldSandboxSession(cfg, sessionKey, mainSessionKey) {
|
|
2638
|
+
if (cfg.mode === "off") return false;
|
|
2639
|
+
if (cfg.mode === "all") return true;
|
|
2640
|
+
return sessionKey.trim() !== mainSessionKey.trim();
|
|
2641
|
+
}
|
|
2642
|
+
function resolveMainSessionKeyForSandbox(params) {
|
|
2643
|
+
if (params.cfg?.session?.scope === "global") return "global";
|
|
2644
|
+
return resolveAgentMainSessionKey({
|
|
2645
|
+
cfg: params.cfg,
|
|
2646
|
+
agentId: params.agentId
|
|
2647
|
+
});
|
|
2648
|
+
}
|
|
2649
|
+
function resolveComparableSessionKeyForSandbox(params) {
|
|
2650
|
+
return canonicalizeMainSessionAlias({
|
|
2651
|
+
cfg: params.cfg,
|
|
2652
|
+
agentId: params.agentId,
|
|
2653
|
+
sessionKey: params.sessionKey
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
function resolveSandboxRuntimeStatus(params) {
|
|
2657
|
+
const sessionKey = params.sessionKey?.trim() ?? "";
|
|
2658
|
+
const agentId = resolveSessionAgentId({
|
|
2659
|
+
sessionKey,
|
|
2660
|
+
config: params.cfg
|
|
2661
|
+
});
|
|
2662
|
+
const cfg = params.cfg;
|
|
2663
|
+
const sandboxCfg = resolveSandboxConfigForAgent(cfg, agentId);
|
|
2664
|
+
const mainSessionKey = resolveMainSessionKeyForSandbox({
|
|
2665
|
+
cfg,
|
|
2666
|
+
agentId
|
|
2667
|
+
});
|
|
2668
|
+
const sandboxed = sessionKey ? shouldSandboxSession(sandboxCfg, resolveComparableSessionKeyForSandbox({
|
|
2669
|
+
cfg,
|
|
2670
|
+
agentId,
|
|
2671
|
+
sessionKey
|
|
2672
|
+
}), mainSessionKey) : false;
|
|
2673
|
+
return {
|
|
2674
|
+
agentId,
|
|
2675
|
+
sessionKey,
|
|
2676
|
+
mainSessionKey,
|
|
2677
|
+
mode: sandboxCfg.mode,
|
|
2678
|
+
sandboxed,
|
|
2679
|
+
toolPolicy: resolveSandboxToolPolicyForAgent(cfg, agentId)
|
|
2680
|
+
};
|
|
2681
|
+
}
|
|
2682
|
+
function formatSandboxToolPolicyBlockedMessage(params) {
|
|
2683
|
+
const tool = params.toolName.trim().toLowerCase();
|
|
2684
|
+
if (!tool) return;
|
|
2685
|
+
const runtime = resolveSandboxRuntimeStatus({
|
|
2686
|
+
cfg: params.cfg,
|
|
2687
|
+
sessionKey: params.sessionKey
|
|
2688
|
+
});
|
|
2689
|
+
if (!runtime.sandboxed) return;
|
|
2690
|
+
const deny = new Set(expandToolGroups(runtime.toolPolicy.deny));
|
|
2691
|
+
const allow = expandToolGroups(runtime.toolPolicy.allow);
|
|
2692
|
+
const allowSet = allow.length > 0 ? new Set(allow) : null;
|
|
2693
|
+
const blockedByDeny = deny.has(tool);
|
|
2694
|
+
const blockedByAllow = allowSet ? !allowSet.has(tool) : false;
|
|
2695
|
+
if (!blockedByDeny && !blockedByAllow) return;
|
|
2696
|
+
const reasons = [];
|
|
2697
|
+
const fixes = [];
|
|
2698
|
+
if (blockedByDeny) {
|
|
2699
|
+
reasons.push("deny list");
|
|
2700
|
+
fixes.push(`Remove "${tool}" from ${runtime.toolPolicy.sources.deny.key}.`);
|
|
2701
|
+
}
|
|
2702
|
+
if (blockedByAllow) {
|
|
2703
|
+
reasons.push("allow list");
|
|
2704
|
+
fixes.push(`Add "${tool}" to ${runtime.toolPolicy.sources.allow.key} (or set it to [] to allow all).`);
|
|
2705
|
+
}
|
|
2706
|
+
const lines = [];
|
|
2707
|
+
lines.push(`Tool "${tool}" blocked by sandbox tool policy (mode=${runtime.mode}).`);
|
|
2708
|
+
lines.push(`Session: ${runtime.sessionKey || "(unknown)"}`);
|
|
2709
|
+
lines.push(`Reason: ${reasons.join(" + ")}`);
|
|
2710
|
+
lines.push("Fix:");
|
|
2711
|
+
lines.push(`- agents.defaults.sandbox.mode=off (disable sandbox)`);
|
|
2712
|
+
for (const fix of fixes) lines.push(`- ${fix}`);
|
|
2713
|
+
if (runtime.mode === "non-main") lines.push(`- Use main session key (direct): ${runtime.mainSessionKey}`);
|
|
2714
|
+
lines.push(`- See: ${formatCliCommand(`openclaw sandbox explain --session ${runtime.sessionKey}`)}`);
|
|
2715
|
+
return lines.join("\n");
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
//#endregion
|
|
2719
|
+
//#region src/agents/sandbox/workspace.ts
|
|
2720
|
+
async function ensureSandboxWorkspace(workspaceDir, seedFrom, skipBootstrap) {
|
|
2721
|
+
await fs$1.mkdir(workspaceDir, { recursive: true });
|
|
2722
|
+
if (seedFrom) {
|
|
2723
|
+
const seed = resolveUserPath(seedFrom);
|
|
2724
|
+
const files = [
|
|
2725
|
+
DEFAULT_AGENTS_FILENAME,
|
|
2726
|
+
DEFAULT_SOUL_FILENAME,
|
|
2727
|
+
DEFAULT_TOOLS_FILENAME,
|
|
2728
|
+
DEFAULT_IDENTITY_FILENAME,
|
|
2729
|
+
DEFAULT_USER_FILENAME,
|
|
2730
|
+
DEFAULT_BOOTSTRAP_FILENAME,
|
|
2731
|
+
DEFAULT_HEARTBEAT_FILENAME
|
|
2732
|
+
];
|
|
2733
|
+
for (const name of files) {
|
|
2734
|
+
const src = path.join(seed, name);
|
|
2735
|
+
const dest = path.join(workspaceDir, name);
|
|
2736
|
+
try {
|
|
2737
|
+
await fs$1.access(dest);
|
|
2738
|
+
} catch {
|
|
2739
|
+
try {
|
|
2740
|
+
const content = await fs$1.readFile(src, "utf-8");
|
|
2741
|
+
await fs$1.writeFile(dest, content, {
|
|
2742
|
+
encoding: "utf-8",
|
|
2743
|
+
flag: "wx"
|
|
2744
|
+
});
|
|
2745
|
+
} catch {}
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
await ensureAgentWorkspace({
|
|
2750
|
+
dir: workspaceDir,
|
|
2751
|
+
ensureBootstrapFiles: !skipBootstrap
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
//#endregion
|
|
2756
|
+
//#region src/agents/sandbox/context.ts
|
|
2757
|
+
async function resolveSandboxContext(params) {
|
|
2758
|
+
const rawSessionKey = params.sessionKey?.trim();
|
|
2759
|
+
if (!rawSessionKey) return null;
|
|
2760
|
+
const runtime = resolveSandboxRuntimeStatus({
|
|
2761
|
+
cfg: params.config,
|
|
2762
|
+
sessionKey: rawSessionKey
|
|
2763
|
+
});
|
|
2764
|
+
if (!runtime.sandboxed) return null;
|
|
2765
|
+
const cfg = resolveSandboxConfigForAgent(params.config, runtime.agentId);
|
|
2766
|
+
await maybePruneSandboxes(cfg);
|
|
2767
|
+
const agentWorkspaceDir = resolveUserPath(params.workspaceDir?.trim() || DEFAULT_AGENT_WORKSPACE_DIR);
|
|
2768
|
+
const workspaceRoot = resolveUserPath(cfg.workspaceRoot);
|
|
2769
|
+
const scopeKey = resolveSandboxScopeKey(cfg.scope, rawSessionKey);
|
|
2770
|
+
const sandboxWorkspaceDir = cfg.scope === "shared" ? workspaceRoot : resolveSandboxWorkspaceDir(workspaceRoot, scopeKey);
|
|
2771
|
+
const workspaceDir = cfg.workspaceAccess === "rw" ? agentWorkspaceDir : sandboxWorkspaceDir;
|
|
2772
|
+
if (workspaceDir === sandboxWorkspaceDir) {
|
|
2773
|
+
await ensureSandboxWorkspace(sandboxWorkspaceDir, agentWorkspaceDir, params.config?.agents?.defaults?.skipBootstrap);
|
|
2774
|
+
if (cfg.workspaceAccess !== "rw") try {
|
|
2775
|
+
await syncSkillsToWorkspace({
|
|
2776
|
+
sourceWorkspaceDir: agentWorkspaceDir,
|
|
2777
|
+
targetWorkspaceDir: sandboxWorkspaceDir,
|
|
2778
|
+
config: params.config
|
|
2779
|
+
});
|
|
2780
|
+
} catch (error) {
|
|
2781
|
+
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
|
2782
|
+
defaultRuntime.error?.(`Sandbox skill sync failed: ${message}`);
|
|
2783
|
+
}
|
|
2784
|
+
} else await fs$1.mkdir(workspaceDir, { recursive: true });
|
|
2785
|
+
const containerName = await ensureSandboxContainer({
|
|
2786
|
+
sessionKey: rawSessionKey,
|
|
2787
|
+
workspaceDir,
|
|
2788
|
+
agentWorkspaceDir,
|
|
2789
|
+
cfg
|
|
2790
|
+
});
|
|
2791
|
+
const browser = await ensureSandboxBrowser({
|
|
2792
|
+
scopeKey,
|
|
2793
|
+
workspaceDir,
|
|
2794
|
+
agentWorkspaceDir,
|
|
2795
|
+
cfg,
|
|
2796
|
+
evaluateEnabled: params.config?.browser?.evaluateEnabled ?? DEFAULT_BROWSER_EVALUATE_ENABLED
|
|
2797
|
+
});
|
|
2798
|
+
return {
|
|
2799
|
+
enabled: true,
|
|
2800
|
+
sessionKey: rawSessionKey,
|
|
2801
|
+
workspaceDir,
|
|
2802
|
+
agentWorkspaceDir,
|
|
2803
|
+
workspaceAccess: cfg.workspaceAccess,
|
|
2804
|
+
containerName,
|
|
2805
|
+
containerWorkdir: cfg.docker.workdir,
|
|
2806
|
+
docker: cfg.docker,
|
|
2807
|
+
tools: cfg.tools,
|
|
2808
|
+
browserAllowHostControl: cfg.browser.allowHostControl,
|
|
2809
|
+
browser: browser ?? void 0
|
|
2810
|
+
};
|
|
2811
|
+
}
|
|
2812
|
+
async function ensureSandboxWorkspaceForSession(params) {
|
|
2813
|
+
const rawSessionKey = params.sessionKey?.trim();
|
|
2814
|
+
if (!rawSessionKey) return null;
|
|
2815
|
+
const runtime = resolveSandboxRuntimeStatus({
|
|
2816
|
+
cfg: params.config,
|
|
2817
|
+
sessionKey: rawSessionKey
|
|
2818
|
+
});
|
|
2819
|
+
if (!runtime.sandboxed) return null;
|
|
2820
|
+
const cfg = resolveSandboxConfigForAgent(params.config, runtime.agentId);
|
|
2821
|
+
const agentWorkspaceDir = resolveUserPath(params.workspaceDir?.trim() || DEFAULT_AGENT_WORKSPACE_DIR);
|
|
2822
|
+
const workspaceRoot = resolveUserPath(cfg.workspaceRoot);
|
|
2823
|
+
const scopeKey = resolveSandboxScopeKey(cfg.scope, rawSessionKey);
|
|
2824
|
+
const sandboxWorkspaceDir = cfg.scope === "shared" ? workspaceRoot : resolveSandboxWorkspaceDir(workspaceRoot, scopeKey);
|
|
2825
|
+
const workspaceDir = cfg.workspaceAccess === "rw" ? agentWorkspaceDir : sandboxWorkspaceDir;
|
|
2826
|
+
if (workspaceDir === sandboxWorkspaceDir) {
|
|
2827
|
+
await ensureSandboxWorkspace(sandboxWorkspaceDir, agentWorkspaceDir, params.config?.agents?.defaults?.skipBootstrap);
|
|
2828
|
+
if (cfg.workspaceAccess !== "rw") try {
|
|
2829
|
+
await syncSkillsToWorkspace({
|
|
2830
|
+
sourceWorkspaceDir: agentWorkspaceDir,
|
|
2831
|
+
targetWorkspaceDir: sandboxWorkspaceDir,
|
|
2832
|
+
config: params.config
|
|
2833
|
+
});
|
|
2834
|
+
} catch (error) {
|
|
2835
|
+
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
|
2836
|
+
defaultRuntime.error?.(`Sandbox skill sync failed: ${message}`);
|
|
2837
|
+
}
|
|
2838
|
+
} else await fs$1.mkdir(workspaceDir, { recursive: true });
|
|
2839
|
+
return {
|
|
2840
|
+
workspaceDir,
|
|
2841
|
+
containerWorkdir: cfg.docker.workdir
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2844
|
+
|
|
2845
|
+
//#endregion
|
|
2846
|
+
//#region src/agents/sandbox/manage.ts
|
|
2847
|
+
async function listSandboxContainers() {
|
|
2848
|
+
const config = loadConfig();
|
|
2849
|
+
const registry = await readRegistry();
|
|
2850
|
+
const results = [];
|
|
2851
|
+
for (const entry of registry.entries) {
|
|
2852
|
+
const state = await dockerContainerState(entry.containerName);
|
|
2853
|
+
let actualImage = entry.image;
|
|
2854
|
+
if (state.exists) try {
|
|
2855
|
+
const result = await execDocker([
|
|
2856
|
+
"inspect",
|
|
2857
|
+
"-f",
|
|
2858
|
+
"{{.Config.Image}}",
|
|
2859
|
+
entry.containerName
|
|
2860
|
+
], { allowFailure: true });
|
|
2861
|
+
if (result.code === 0) actualImage = result.stdout.trim();
|
|
2862
|
+
} catch {}
|
|
2863
|
+
const configuredImage = resolveSandboxConfigForAgent(config, resolveSandboxAgentId(entry.sessionKey)).docker.image;
|
|
2864
|
+
results.push({
|
|
2865
|
+
...entry,
|
|
2866
|
+
image: actualImage,
|
|
2867
|
+
running: state.running,
|
|
2868
|
+
imageMatch: actualImage === configuredImage
|
|
2869
|
+
});
|
|
2870
|
+
}
|
|
2871
|
+
return results;
|
|
2872
|
+
}
|
|
2873
|
+
async function listSandboxBrowsers() {
|
|
2874
|
+
const config = loadConfig();
|
|
2875
|
+
const registry = await readBrowserRegistry();
|
|
2876
|
+
const results = [];
|
|
2877
|
+
for (const entry of registry.entries) {
|
|
2878
|
+
const state = await dockerContainerState(entry.containerName);
|
|
2879
|
+
let actualImage = entry.image;
|
|
2880
|
+
if (state.exists) try {
|
|
2881
|
+
const result = await execDocker([
|
|
2882
|
+
"inspect",
|
|
2883
|
+
"-f",
|
|
2884
|
+
"{{.Config.Image}}",
|
|
2885
|
+
entry.containerName
|
|
2886
|
+
], { allowFailure: true });
|
|
2887
|
+
if (result.code === 0) actualImage = result.stdout.trim();
|
|
2888
|
+
} catch {}
|
|
2889
|
+
const configuredImage = resolveSandboxConfigForAgent(config, resolveSandboxAgentId(entry.sessionKey)).browser.image;
|
|
2890
|
+
results.push({
|
|
2891
|
+
...entry,
|
|
2892
|
+
image: actualImage,
|
|
2893
|
+
running: state.running,
|
|
2894
|
+
imageMatch: actualImage === configuredImage
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2897
|
+
return results;
|
|
2898
|
+
}
|
|
2899
|
+
async function removeSandboxContainer(containerName) {
|
|
2900
|
+
try {
|
|
2901
|
+
await execDocker([
|
|
2902
|
+
"rm",
|
|
2903
|
+
"-f",
|
|
2904
|
+
containerName
|
|
2905
|
+
], { allowFailure: true });
|
|
2906
|
+
} catch {}
|
|
2907
|
+
await removeRegistryEntry(containerName);
|
|
2908
|
+
}
|
|
2909
|
+
async function removeSandboxBrowserContainer(containerName) {
|
|
2910
|
+
try {
|
|
2911
|
+
await execDocker([
|
|
2912
|
+
"rm",
|
|
2913
|
+
"-f",
|
|
2914
|
+
containerName
|
|
2915
|
+
], { allowFailure: true });
|
|
2916
|
+
} catch {}
|
|
2917
|
+
await removeBrowserRegistryEntry(containerName);
|
|
2918
|
+
for (const [sessionKey, bridge] of BROWSER_BRIDGES.entries()) if (bridge.containerName === containerName) {
|
|
2919
|
+
await stopBrowserBridgeServer(bridge.bridge.server).catch(() => void 0);
|
|
2920
|
+
BROWSER_BRIDGES.delete(sessionKey);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
//#endregion
|
|
2925
|
+
export { resolveSandboxToolPolicyForAgent as $, resolveSessionResetPolicy as A, snapshotSessionOrigin as B, normalizeDeliveryContext as C, resolveSessionKey as D, deriveSessionKey as E, resolveAgentMainSessionKey as F, resolveChannelGroupToolsPolicy as G, listChannelDocks as H, resolveExplicitAgentSessionKey as I, resolveIMessageAccount as J, listEnabledSignalAccounts as K, resolveMainSessionKey as L, resolveThreadFlag as M, DEFAULT_RESET_TRIGGERS as N, evaluateSessionFreshness as O, canonicalizeMainSessionAlias as P, resolveSandboxScope as Q, resolveMainSessionKeyFromConfig as R, mergeDeliveryContext as S, normalizeAccountId as T, resolveChannelGroupPolicy as U, getChannelDock as V, resolveChannelGroupRequireMention as W, resolveGroupSessionKey as X, buildGroupDisplayName as Y, resolveSandboxConfigForAgent as Z, updateSessionStoreEntry as _, ensureSandboxWorkspaceForSession as a, resolveToolProfilePolicy as at, deliveryContextFromSession as b, resolveSandboxRuntimeStatus as c, DEFAULT_SANDBOX_COMMON_IMAGE as ct, loadSessionStore as d, buildPluginToolGroups as et, readSessionUpdatedAt as f, updateSessionStore as g, updateLastRoute as h, removeSandboxContainer as i, normalizeToolName as it, resolveSessionResetType as j, resolveChannelResetConfig as k, appendAssistantMessageToSessionTranscript as l, DEFAULT_SANDBOX_IMAGE as lt, saveSessionStore as m, listSandboxContainers as n, expandPolicyWithPluginGroups as nt, resolveSandboxContext as o, stripPluginOnlyAllowlist as ot, recordSessionMetaFromInbound as p, resolveSignalAccount as q, removeSandboxBrowserContainer as r, expandToolGroups as rt, formatSandboxToolPolicyBlockedMessage as s, DEFAULT_SANDBOX_BROWSER_IMAGE as st, listSandboxBrowsers as t, collectExplicitAllowlist as tt, resolveMirroredTranscriptText as u, resolveConversationLabel as ut, isCacheEnabled as v, normalizeSessionDeliveryFields as w, deliveryContextKey as x, resolveCacheTtlMs as y, deriveSessionMetaPatch as z };
|