@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,2585 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
+
import { Z as loadOpenClawPlugins, _r as loadModelCatalog, _t as printWizardHeader, ft as guardCancel, st as applyWizardMetadata, yt as randomToken } from "./reply-5UNWRwMn.js";
|
|
3
|
+
import { d as resolveIsNixMode, f as resolveLegacyStateDirs, g as resolveStateDir, m as resolveOAuthDir, p as resolveNewStateDir, t as CONFIG_PATH, u as resolveGatewayPort } from "./paths-scjhy7N2.js";
|
|
4
|
+
import { E as DEFAULT_ACCOUNT_ID, N as normalizeAgentId, O as DEFAULT_MAIN_KEY, c as resolveDefaultAgentId, d as DEFAULT_AGENTS_FILENAME, k as buildAgentMainSessionKey, s as resolveAgentWorkspaceDir } from "./agent-scope-BbT4OG2N.js";
|
|
5
|
+
import { V as getResolvedLoggerSettings, c as defaultRuntime } from "./subsystem-CAq3uyo7.js";
|
|
6
|
+
import { _ as shortenHomePath, p as resolveHomeDir$1, v as sleep } from "./utils-CKSrBNwq.js";
|
|
7
|
+
import { n as runExec, t as runCommandWithTimeout } from "./exec-HEWTMJ7j.js";
|
|
8
|
+
import { t as resolveOpenClawPackageRoot } from "./openclaw-root-Cvotktkd.js";
|
|
9
|
+
import { X as resolveProfileUnusableUntilForDisplay, Z as resolveApiKeyForProfile, _t as DEFAULT_MODEL, d as resolveHooksGmailModel, ht as CODEX_CLI_PROFILE_ID, l as resolveConfiguredModelRef, lt as updateAuthProfileStoreWithLock, mt as CLAUDE_CLI_PROFILE_ID, nt as repairOAuthProfileIdMismatch, r as getModelRefStatus, st as ensureAuthProfileStore, vt as DEFAULT_PROVIDER } from "./model-selection-Cv5Ox_tY.js";
|
|
10
|
+
import { t as formatCliCommand } from "./command-format-DELazozB.js";
|
|
11
|
+
import { t as isTruthyEnvValue } from "./env-l7QVNj6j.js";
|
|
12
|
+
import { c as writeConfigFile, n as migrateLegacyConfig, o as readConfigFileSnapshot, u as OpenClawSchema } from "./config-BtSTwPcH.js";
|
|
13
|
+
import { n as listChannelPlugins } from "./plugins-QJjTXliB.js";
|
|
14
|
+
import { L as resolveMainSessionKey, P as canonicalizeMainSessionAlias, Q as resolveSandboxScope, ct as DEFAULT_SANDBOX_COMMON_IMAGE, d as loadSessionStore, lt as DEFAULT_SANDBOX_IMAGE, m as saveSessionStore, st as DEFAULT_SANDBOX_BROWSER_IMAGE } from "./sandbox-knontqD9.js";
|
|
15
|
+
import { d as inspectPortUsage, p as formatPortDiagnostics } from "./chrome-BZ9K48w9.js";
|
|
16
|
+
import { a as resolveSessionTranscriptsDirForAgent, n as resolveSessionFilePath, o as resolveStorePath } from "./paths-B-q1nXdY.js";
|
|
17
|
+
import { n as isWSL, r as isWSLEnv } from "./dispatcher-Dyv7T-1r.js";
|
|
18
|
+
import { n as callGateway, t as buildGatewayConnectionDetails } from "./call-B7EveN4V.js";
|
|
19
|
+
import { i as readChannelAllowFromStore } from "./pairing-store-DDLNuzmx.js";
|
|
20
|
+
import { n as stylePromptMessage, r as stylePromptTitle, t as stylePromptHint } from "./prompt-style-DYJdrXyV.js";
|
|
21
|
+
import { d as resolveGatewaySystemdServiceName, f as resolveGatewayWindowsTaskName, l as resolveGatewayLaunchAgentLabel, m as resolveNodeLaunchAgentLabel } from "./constants-hpmbslG7.js";
|
|
22
|
+
import { t as resolveChannelDefaultAccountId } from "./helpers-BtbBZVKZ.js";
|
|
23
|
+
import { n as logConfigUpdated } from "./logging-DhiLkhLw.js";
|
|
24
|
+
import { t as note$1 } from "./note-CQhSvgQv.js";
|
|
25
|
+
import { t as applyPluginAutoEnable } from "./plugin-auto-enable-DBhXb_0x.js";
|
|
26
|
+
import { i as healthCommand, t as formatHealthCheckFailure } from "./health-format-B0tMTk3C.js";
|
|
27
|
+
import { t as runGatewayUpdate } from "./update-runner-CxGU142L.js";
|
|
28
|
+
import { a as resolveGatewayBindHost, n as isLoopbackHost } from "./net-CFCxaipF.js";
|
|
29
|
+
import { i as resolveGatewayAuth } from "./auth-y1BLPUhX.js";
|
|
30
|
+
import { t as buildWorkspaceSkillStatus } from "./skills-status-CENcKr3I.js";
|
|
31
|
+
import { a as repairLaunchAgentBootstrap, i as launchAgentPlistExists, n as isLaunchAgentListed, o as resolveGatewayLogPaths, r as isLaunchAgentLoaded, t as resolveGatewayService } from "./service-BZNBq9hq.js";
|
|
32
|
+
import { r as isSystemdUserServiceAvailable } from "./systemd-0Qa_nGqe.js";
|
|
33
|
+
import { a as renderGatewayServiceCleanupHints, i as findExtraGatewayServices, n as auditGatewayServiceConfig, o as readLastGatewayErrorLine, r as needsNodeRuntimeMigration, t as SERVICE_AUDIT_CODES } from "./service-audit-Bw3M2OEI.js";
|
|
34
|
+
import { t as collectChannelStatusIssues } from "./channels-status-issues-YohTjZ-I.js";
|
|
35
|
+
import { a as gatewayInstallErrorHint, d as renderSystemNodeWarning, i as buildGatewayInstallPlan, n as GATEWAY_DAEMON_RUNTIME_OPTIONS, p as resolveSystemNodeInfo, t as DEFAULT_GATEWAY_DAEMON_RUNTIME } from "./daemon-runtime-DXUfrXBC.js";
|
|
36
|
+
import { t as ensureSystemdUserLingerInteractive } from "./systemd-linger-DKUFHcLn.js";
|
|
37
|
+
import { n as buildAuthHealthSummary, r as formatRemainingShort, t as DEFAULT_OAUTH_WARN_MS } from "./auth-health-Bj7Gjbv0.js";
|
|
38
|
+
import { n as renderSystemdUnavailableHints, t as isSystemdUnavailableDetail } from "./systemd-hints-Cv3RN_mZ.js";
|
|
39
|
+
import os from "node:os";
|
|
40
|
+
import path from "node:path";
|
|
41
|
+
import fs from "node:fs";
|
|
42
|
+
import JSON5 from "json5";
|
|
43
|
+
import fs$1 from "node:fs/promises";
|
|
44
|
+
import { execFile } from "node:child_process";
|
|
45
|
+
import { promisify } from "node:util";
|
|
46
|
+
import { confirm, intro, outro, select } from "@clack/prompts";
|
|
47
|
+
|
|
48
|
+
//#region src/commands/doctor-auth.ts
|
|
49
|
+
async function maybeRepairAnthropicOAuthProfileId(cfg, prompter) {
|
|
50
|
+
const repair = repairOAuthProfileIdMismatch({
|
|
51
|
+
cfg,
|
|
52
|
+
store: ensureAuthProfileStore(),
|
|
53
|
+
provider: "anthropic",
|
|
54
|
+
legacyProfileId: "anthropic:default"
|
|
55
|
+
});
|
|
56
|
+
if (!repair.migrated || repair.changes.length === 0) return cfg;
|
|
57
|
+
note$1(repair.changes.map((c) => `- ${c}`).join("\n"), "Auth profiles");
|
|
58
|
+
if (!await prompter.confirm({
|
|
59
|
+
message: "Update Anthropic OAuth profile id in config now?",
|
|
60
|
+
initialValue: true
|
|
61
|
+
})) return cfg;
|
|
62
|
+
return repair.config;
|
|
63
|
+
}
|
|
64
|
+
function pruneAuthOrder(order, profileIds) {
|
|
65
|
+
if (!order) return {
|
|
66
|
+
next: order,
|
|
67
|
+
changed: false
|
|
68
|
+
};
|
|
69
|
+
let changed = false;
|
|
70
|
+
const next = {};
|
|
71
|
+
for (const [provider, list] of Object.entries(order)) {
|
|
72
|
+
const filtered = list.filter((id) => !profileIds.has(id));
|
|
73
|
+
if (filtered.length !== list.length) changed = true;
|
|
74
|
+
if (filtered.length > 0) next[provider] = filtered;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
next: Object.keys(next).length > 0 ? next : void 0,
|
|
78
|
+
changed
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function pruneAuthProfiles(cfg, profileIds) {
|
|
82
|
+
const profiles = cfg.auth?.profiles;
|
|
83
|
+
const order = cfg.auth?.order;
|
|
84
|
+
const nextProfiles = profiles ? { ...profiles } : void 0;
|
|
85
|
+
let changed = false;
|
|
86
|
+
if (nextProfiles) {
|
|
87
|
+
for (const id of profileIds) if (id in nextProfiles) {
|
|
88
|
+
delete nextProfiles[id];
|
|
89
|
+
changed = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const prunedOrder = pruneAuthOrder(order, profileIds);
|
|
93
|
+
if (prunedOrder.changed) changed = true;
|
|
94
|
+
if (!changed) return {
|
|
95
|
+
next: cfg,
|
|
96
|
+
changed: false
|
|
97
|
+
};
|
|
98
|
+
const nextAuth = nextProfiles || prunedOrder.next ? {
|
|
99
|
+
...cfg.auth,
|
|
100
|
+
profiles: nextProfiles && Object.keys(nextProfiles).length > 0 ? nextProfiles : void 0,
|
|
101
|
+
order: prunedOrder.next
|
|
102
|
+
} : void 0;
|
|
103
|
+
return {
|
|
104
|
+
next: {
|
|
105
|
+
...cfg,
|
|
106
|
+
auth: nextAuth
|
|
107
|
+
},
|
|
108
|
+
changed: true
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function maybeRemoveDeprecatedCliAuthProfiles(cfg, prompter) {
|
|
112
|
+
const store = ensureAuthProfileStore(void 0, { allowKeychainPrompt: false });
|
|
113
|
+
const deprecated = /* @__PURE__ */ new Set();
|
|
114
|
+
if (store.profiles[CLAUDE_CLI_PROFILE_ID] || cfg.auth?.profiles?.[CLAUDE_CLI_PROFILE_ID]) deprecated.add(CLAUDE_CLI_PROFILE_ID);
|
|
115
|
+
if (store.profiles[CODEX_CLI_PROFILE_ID] || cfg.auth?.profiles?.[CODEX_CLI_PROFILE_ID]) deprecated.add(CODEX_CLI_PROFILE_ID);
|
|
116
|
+
if (deprecated.size === 0) return cfg;
|
|
117
|
+
const lines = ["Deprecated external CLI auth profiles detected (no longer supported):"];
|
|
118
|
+
if (deprecated.has(CLAUDE_CLI_PROFILE_ID)) lines.push(`- ${CLAUDE_CLI_PROFILE_ID} (Anthropic): use setup-token → ${formatCliCommand("openclaw models auth setup-token")}`);
|
|
119
|
+
if (deprecated.has(CODEX_CLI_PROFILE_ID)) lines.push(`- ${CODEX_CLI_PROFILE_ID} (OpenAI Codex): use OAuth → ${formatCliCommand("openclaw models auth login --provider openai-codex")}`);
|
|
120
|
+
note$1(lines.join("\n"), "Auth profiles");
|
|
121
|
+
if (!await prompter.confirmRepair({
|
|
122
|
+
message: "Remove deprecated CLI auth profiles now?",
|
|
123
|
+
initialValue: true
|
|
124
|
+
})) return cfg;
|
|
125
|
+
await updateAuthProfileStoreWithLock({ updater: (nextStore) => {
|
|
126
|
+
let mutated = false;
|
|
127
|
+
for (const id of deprecated) {
|
|
128
|
+
if (nextStore.profiles[id]) {
|
|
129
|
+
delete nextStore.profiles[id];
|
|
130
|
+
mutated = true;
|
|
131
|
+
}
|
|
132
|
+
if (nextStore.usageStats?.[id]) {
|
|
133
|
+
delete nextStore.usageStats[id];
|
|
134
|
+
mutated = true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (nextStore.order) for (const [provider, list] of Object.entries(nextStore.order)) {
|
|
138
|
+
const filtered = list.filter((id) => !deprecated.has(id));
|
|
139
|
+
if (filtered.length !== list.length) {
|
|
140
|
+
mutated = true;
|
|
141
|
+
if (filtered.length > 0) nextStore.order[provider] = filtered;
|
|
142
|
+
else delete nextStore.order[provider];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (nextStore.lastGood) {
|
|
146
|
+
for (const [provider, profileId] of Object.entries(nextStore.lastGood)) if (deprecated.has(profileId)) {
|
|
147
|
+
delete nextStore.lastGood[provider];
|
|
148
|
+
mutated = true;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return mutated;
|
|
152
|
+
} });
|
|
153
|
+
const pruned = pruneAuthProfiles(cfg, deprecated);
|
|
154
|
+
if (pruned.changed) note$1(Array.from(deprecated.values()).map((id) => `- removed ${id} from config`).join("\n"), "Doctor changes");
|
|
155
|
+
return pruned.next;
|
|
156
|
+
}
|
|
157
|
+
function formatAuthIssueHint(issue) {
|
|
158
|
+
if (issue.provider === "anthropic" && issue.profileId === CLAUDE_CLI_PROFILE_ID) return `Deprecated profile. Use ${formatCliCommand("openclaw models auth setup-token")} or ${formatCliCommand("openclaw configure")}.`;
|
|
159
|
+
if (issue.provider === "openai-codex" && issue.profileId === CODEX_CLI_PROFILE_ID) return `Deprecated profile. Use ${formatCliCommand("openclaw models auth login --provider openai-codex")} or ${formatCliCommand("openclaw configure")}.`;
|
|
160
|
+
return `Re-auth via \`${formatCliCommand("openclaw configure")}\` or \`${formatCliCommand("openclaw onboard")}\`.`;
|
|
161
|
+
}
|
|
162
|
+
function formatAuthIssueLine(issue) {
|
|
163
|
+
const remaining = issue.remainingMs !== void 0 ? ` (${formatRemainingShort(issue.remainingMs)})` : "";
|
|
164
|
+
const hint = formatAuthIssueHint(issue);
|
|
165
|
+
return `- ${issue.profileId}: ${issue.status}${remaining}${hint ? ` — ${hint}` : ""}`;
|
|
166
|
+
}
|
|
167
|
+
async function noteAuthProfileHealth(params) {
|
|
168
|
+
const store = ensureAuthProfileStore(void 0, { allowKeychainPrompt: params.allowKeychainPrompt });
|
|
169
|
+
const unusable = (() => {
|
|
170
|
+
const now = Date.now();
|
|
171
|
+
const out = [];
|
|
172
|
+
for (const profileId of Object.keys(store.usageStats ?? {})) {
|
|
173
|
+
const until = resolveProfileUnusableUntilForDisplay(store, profileId);
|
|
174
|
+
if (!until || now >= until) continue;
|
|
175
|
+
const stats = store.usageStats?.[profileId];
|
|
176
|
+
const remaining = formatRemainingShort(until - now);
|
|
177
|
+
const kind = typeof stats?.disabledUntil === "number" && now < stats.disabledUntil ? `disabled${stats.disabledReason ? `:${stats.disabledReason}` : ""}` : "cooldown";
|
|
178
|
+
const hint = kind.startsWith("disabled:billing") ? "Top up credits (provider billing) or switch provider." : "Wait for cooldown or switch provider.";
|
|
179
|
+
out.push(`- ${profileId}: ${kind} (${remaining})${hint ? ` — ${hint}` : ""}`);
|
|
180
|
+
}
|
|
181
|
+
return out;
|
|
182
|
+
})();
|
|
183
|
+
if (unusable.length > 0) note$1(unusable.join("\n"), "Auth profile cooldowns");
|
|
184
|
+
let summary = buildAuthHealthSummary({
|
|
185
|
+
store,
|
|
186
|
+
cfg: params.cfg,
|
|
187
|
+
warnAfterMs: DEFAULT_OAUTH_WARN_MS
|
|
188
|
+
});
|
|
189
|
+
const findIssues = () => summary.profiles.filter((profile) => (profile.type === "oauth" || profile.type === "token") && (profile.status === "expired" || profile.status === "expiring" || profile.status === "missing"));
|
|
190
|
+
let issues = findIssues();
|
|
191
|
+
if (issues.length === 0) return;
|
|
192
|
+
if (await params.prompter.confirmRepair({
|
|
193
|
+
message: "Refresh expiring OAuth tokens now? (static tokens need re-auth)",
|
|
194
|
+
initialValue: true
|
|
195
|
+
})) {
|
|
196
|
+
const refreshTargets = issues.filter((issue) => issue.type === "oauth" && [
|
|
197
|
+
"expired",
|
|
198
|
+
"expiring",
|
|
199
|
+
"missing"
|
|
200
|
+
].includes(issue.status));
|
|
201
|
+
const errors = [];
|
|
202
|
+
for (const profile of refreshTargets) try {
|
|
203
|
+
await resolveApiKeyForProfile({
|
|
204
|
+
cfg: params.cfg,
|
|
205
|
+
store,
|
|
206
|
+
profileId: profile.profileId
|
|
207
|
+
});
|
|
208
|
+
} catch (err) {
|
|
209
|
+
errors.push(`- ${profile.profileId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
210
|
+
}
|
|
211
|
+
if (errors.length > 0) note$1(errors.join("\n"), "OAuth refresh errors");
|
|
212
|
+
summary = buildAuthHealthSummary({
|
|
213
|
+
store: ensureAuthProfileStore(void 0, { allowKeychainPrompt: false }),
|
|
214
|
+
cfg: params.cfg,
|
|
215
|
+
warnAfterMs: DEFAULT_OAUTH_WARN_MS
|
|
216
|
+
});
|
|
217
|
+
issues = findIssues();
|
|
218
|
+
}
|
|
219
|
+
if (issues.length > 0) note$1(issues.map((issue) => formatAuthIssueLine({
|
|
220
|
+
profileId: issue.profileId,
|
|
221
|
+
provider: issue.provider,
|
|
222
|
+
status: issue.status,
|
|
223
|
+
remainingMs: issue.remainingMs
|
|
224
|
+
})).join("\n"), "Model auth");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/commands/doctor-legacy-config.ts
|
|
229
|
+
function normalizeLegacyConfigValues(cfg) {
|
|
230
|
+
const changes = [];
|
|
231
|
+
let next = cfg;
|
|
232
|
+
const legacyAckReaction = cfg.messages?.ackReaction?.trim();
|
|
233
|
+
const hasWhatsAppConfig = cfg.channels?.whatsapp !== void 0;
|
|
234
|
+
if (legacyAckReaction && hasWhatsAppConfig) {
|
|
235
|
+
if (!(cfg.channels?.whatsapp?.ackReaction !== void 0)) {
|
|
236
|
+
const legacyScope = cfg.messages?.ackReactionScope ?? "group-mentions";
|
|
237
|
+
let direct = true;
|
|
238
|
+
let group = "mentions";
|
|
239
|
+
if (legacyScope === "all") {
|
|
240
|
+
direct = true;
|
|
241
|
+
group = "always";
|
|
242
|
+
} else if (legacyScope === "direct") {
|
|
243
|
+
direct = true;
|
|
244
|
+
group = "never";
|
|
245
|
+
} else if (legacyScope === "group-all") {
|
|
246
|
+
direct = false;
|
|
247
|
+
group = "always";
|
|
248
|
+
} else if (legacyScope === "group-mentions") {
|
|
249
|
+
direct = false;
|
|
250
|
+
group = "mentions";
|
|
251
|
+
}
|
|
252
|
+
next = {
|
|
253
|
+
...next,
|
|
254
|
+
channels: {
|
|
255
|
+
...next.channels,
|
|
256
|
+
whatsapp: {
|
|
257
|
+
...next.channels?.whatsapp,
|
|
258
|
+
ackReaction: {
|
|
259
|
+
emoji: legacyAckReaction,
|
|
260
|
+
direct,
|
|
261
|
+
group
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
changes.push(`Copied messages.ackReaction → channels.whatsapp.ackReaction (scope: ${legacyScope}).`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return {
|
|
270
|
+
config: next,
|
|
271
|
+
changes
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/infra/state-migrations.fs.ts
|
|
277
|
+
function safeReadDir(dir) {
|
|
278
|
+
try {
|
|
279
|
+
return fs.readdirSync(dir, { withFileTypes: true });
|
|
280
|
+
} catch {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function existsDir$1(dir) {
|
|
285
|
+
try {
|
|
286
|
+
return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
|
|
287
|
+
} catch {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function ensureDir$1(dir) {
|
|
292
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
293
|
+
}
|
|
294
|
+
function fileExists(p) {
|
|
295
|
+
try {
|
|
296
|
+
return fs.existsSync(p) && fs.statSync(p).isFile();
|
|
297
|
+
} catch {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function isLegacyWhatsAppAuthFile(name) {
|
|
302
|
+
if (name === "creds.json" || name === "creds.json.bak") return true;
|
|
303
|
+
if (!name.endsWith(".json")) return false;
|
|
304
|
+
return /^(app-state-sync|session|sender-key|pre-key)-/.test(name);
|
|
305
|
+
}
|
|
306
|
+
function readSessionStoreJson5(storePath) {
|
|
307
|
+
try {
|
|
308
|
+
const raw = fs.readFileSync(storePath, "utf-8");
|
|
309
|
+
const parsed = JSON5.parse(raw);
|
|
310
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return {
|
|
311
|
+
store: parsed,
|
|
312
|
+
ok: true
|
|
313
|
+
};
|
|
314
|
+
} catch {}
|
|
315
|
+
return {
|
|
316
|
+
store: {},
|
|
317
|
+
ok: false
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/infra/state-migrations.ts
|
|
323
|
+
let autoMigrateStateDirChecked = false;
|
|
324
|
+
function isSurfaceGroupKey(key) {
|
|
325
|
+
return key.includes(":group:") || key.includes(":channel:");
|
|
326
|
+
}
|
|
327
|
+
function isLegacyGroupKey(key) {
|
|
328
|
+
const trimmed = key.trim();
|
|
329
|
+
if (!trimmed) return false;
|
|
330
|
+
if (trimmed.startsWith("group:")) return true;
|
|
331
|
+
const lower = trimmed.toLowerCase();
|
|
332
|
+
if (!lower.includes("@g.us")) return false;
|
|
333
|
+
if (!trimmed.includes(":")) return true;
|
|
334
|
+
if (lower.startsWith("whatsapp:") && !trimmed.includes(":group:")) return true;
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
function canonicalizeSessionKeyForAgent(params) {
|
|
338
|
+
const agentId = normalizeAgentId(params.agentId);
|
|
339
|
+
const raw = params.key.trim();
|
|
340
|
+
if (!raw) return raw;
|
|
341
|
+
if (raw.toLowerCase() === "global" || raw.toLowerCase() === "unknown") return raw.toLowerCase();
|
|
342
|
+
const canonicalMain = canonicalizeMainSessionAlias({
|
|
343
|
+
cfg: { session: {
|
|
344
|
+
scope: params.scope,
|
|
345
|
+
mainKey: params.mainKey
|
|
346
|
+
} },
|
|
347
|
+
agentId,
|
|
348
|
+
sessionKey: raw
|
|
349
|
+
});
|
|
350
|
+
if (canonicalMain !== raw) return canonicalMain.toLowerCase();
|
|
351
|
+
if (raw.toLowerCase().startsWith("agent:")) return raw.toLowerCase();
|
|
352
|
+
if (raw.toLowerCase().startsWith("subagent:")) return `agent:${agentId}:subagent:${raw.slice(9)}`.toLowerCase();
|
|
353
|
+
if (raw.startsWith("group:")) {
|
|
354
|
+
const id = raw.slice(6).trim();
|
|
355
|
+
if (!id) return raw;
|
|
356
|
+
return `agent:${agentId}:${id.toLowerCase().includes("@g.us") ? "whatsapp" : "unknown"}:group:${id}`.toLowerCase();
|
|
357
|
+
}
|
|
358
|
+
if (!raw.includes(":") && raw.toLowerCase().includes("@g.us")) return `agent:${agentId}:whatsapp:group:${raw}`.toLowerCase();
|
|
359
|
+
if (raw.toLowerCase().startsWith("whatsapp:") && raw.toLowerCase().includes("@g.us")) {
|
|
360
|
+
const cleaned = raw.slice(9).trim().replace(/^group:/i, "").trim();
|
|
361
|
+
if (cleaned && !isSurfaceGroupKey(raw)) return `agent:${agentId}:whatsapp:group:${cleaned}`.toLowerCase();
|
|
362
|
+
}
|
|
363
|
+
if (isSurfaceGroupKey(raw)) return `agent:${agentId}:${raw}`.toLowerCase();
|
|
364
|
+
return `agent:${agentId}:${raw}`.toLowerCase();
|
|
365
|
+
}
|
|
366
|
+
function pickLatestLegacyDirectEntry(store) {
|
|
367
|
+
let best = null;
|
|
368
|
+
let bestUpdated = -1;
|
|
369
|
+
for (const [key, entry] of Object.entries(store)) {
|
|
370
|
+
if (!entry || typeof entry !== "object") continue;
|
|
371
|
+
const normalized = key.trim();
|
|
372
|
+
if (!normalized) continue;
|
|
373
|
+
if (normalized === "global") continue;
|
|
374
|
+
if (normalized.startsWith("agent:")) continue;
|
|
375
|
+
if (normalized.toLowerCase().startsWith("subagent:")) continue;
|
|
376
|
+
if (isLegacyGroupKey(normalized) || isSurfaceGroupKey(normalized)) continue;
|
|
377
|
+
const updatedAt = typeof entry.updatedAt === "number" ? entry.updatedAt : 0;
|
|
378
|
+
if (updatedAt > bestUpdated) {
|
|
379
|
+
bestUpdated = updatedAt;
|
|
380
|
+
best = entry;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return best;
|
|
384
|
+
}
|
|
385
|
+
function normalizeSessionEntry(entry) {
|
|
386
|
+
const sessionId = typeof entry.sessionId === "string" ? entry.sessionId : null;
|
|
387
|
+
if (!sessionId) return null;
|
|
388
|
+
const updatedAt = typeof entry.updatedAt === "number" && Number.isFinite(entry.updatedAt) ? entry.updatedAt : Date.now();
|
|
389
|
+
const normalized = {
|
|
390
|
+
...entry,
|
|
391
|
+
sessionId,
|
|
392
|
+
updatedAt
|
|
393
|
+
};
|
|
394
|
+
const rec = normalized;
|
|
395
|
+
if (typeof rec.groupChannel !== "string" && typeof rec.room === "string") rec.groupChannel = rec.room;
|
|
396
|
+
delete rec.room;
|
|
397
|
+
return normalized;
|
|
398
|
+
}
|
|
399
|
+
function resolveUpdatedAt(entry) {
|
|
400
|
+
return typeof entry.updatedAt === "number" && Number.isFinite(entry.updatedAt) ? entry.updatedAt : 0;
|
|
401
|
+
}
|
|
402
|
+
function mergeSessionEntry(params) {
|
|
403
|
+
if (!params.existing) return params.incoming;
|
|
404
|
+
const existingUpdated = resolveUpdatedAt(params.existing);
|
|
405
|
+
const incomingUpdated = resolveUpdatedAt(params.incoming);
|
|
406
|
+
if (incomingUpdated > existingUpdated) return params.incoming;
|
|
407
|
+
if (incomingUpdated < existingUpdated) return params.existing;
|
|
408
|
+
return params.preferIncomingOnTie ? params.incoming : params.existing;
|
|
409
|
+
}
|
|
410
|
+
function canonicalizeSessionStore(params) {
|
|
411
|
+
const canonical = {};
|
|
412
|
+
const meta = /* @__PURE__ */ new Map();
|
|
413
|
+
const legacyKeys = [];
|
|
414
|
+
for (const [key, entry] of Object.entries(params.store)) {
|
|
415
|
+
if (!entry || typeof entry !== "object") continue;
|
|
416
|
+
const canonicalKey = canonicalizeSessionKeyForAgent({
|
|
417
|
+
key,
|
|
418
|
+
agentId: params.agentId,
|
|
419
|
+
mainKey: params.mainKey,
|
|
420
|
+
scope: params.scope
|
|
421
|
+
});
|
|
422
|
+
const isCanonical = canonicalKey === key;
|
|
423
|
+
if (!isCanonical) legacyKeys.push(key);
|
|
424
|
+
const existing = canonical[canonicalKey];
|
|
425
|
+
if (!existing) {
|
|
426
|
+
canonical[canonicalKey] = entry;
|
|
427
|
+
meta.set(canonicalKey, {
|
|
428
|
+
isCanonical,
|
|
429
|
+
updatedAt: resolveUpdatedAt(entry)
|
|
430
|
+
});
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
const existingMeta = meta.get(canonicalKey);
|
|
434
|
+
const incomingUpdated = resolveUpdatedAt(entry);
|
|
435
|
+
const existingUpdated = existingMeta?.updatedAt ?? resolveUpdatedAt(existing);
|
|
436
|
+
if (incomingUpdated > existingUpdated) {
|
|
437
|
+
canonical[canonicalKey] = entry;
|
|
438
|
+
meta.set(canonicalKey, {
|
|
439
|
+
isCanonical,
|
|
440
|
+
updatedAt: incomingUpdated
|
|
441
|
+
});
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (incomingUpdated < existingUpdated) continue;
|
|
445
|
+
if (existingMeta?.isCanonical && !isCanonical) continue;
|
|
446
|
+
if (!existingMeta?.isCanonical && isCanonical) {
|
|
447
|
+
canonical[canonicalKey] = entry;
|
|
448
|
+
meta.set(canonicalKey, {
|
|
449
|
+
isCanonical,
|
|
450
|
+
updatedAt: incomingUpdated
|
|
451
|
+
});
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
store: canonical,
|
|
457
|
+
legacyKeys
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function listLegacySessionKeys(params) {
|
|
461
|
+
const legacy = [];
|
|
462
|
+
for (const key of Object.keys(params.store)) if (canonicalizeSessionKeyForAgent({
|
|
463
|
+
key,
|
|
464
|
+
agentId: params.agentId,
|
|
465
|
+
mainKey: params.mainKey,
|
|
466
|
+
scope: params.scope
|
|
467
|
+
}) !== key) legacy.push(key);
|
|
468
|
+
return legacy;
|
|
469
|
+
}
|
|
470
|
+
function emptyDirOrMissing(dir) {
|
|
471
|
+
if (!existsDir$1(dir)) return true;
|
|
472
|
+
return safeReadDir(dir).length === 0;
|
|
473
|
+
}
|
|
474
|
+
function removeDirIfEmpty(dir) {
|
|
475
|
+
if (!existsDir$1(dir)) return;
|
|
476
|
+
if (!emptyDirOrMissing(dir)) return;
|
|
477
|
+
try {
|
|
478
|
+
fs.rmdirSync(dir);
|
|
479
|
+
} catch {}
|
|
480
|
+
}
|
|
481
|
+
function resolveSymlinkTarget(linkPath) {
|
|
482
|
+
try {
|
|
483
|
+
const target = fs.readlinkSync(linkPath);
|
|
484
|
+
return path.resolve(path.dirname(linkPath), target);
|
|
485
|
+
} catch {
|
|
486
|
+
return null;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function formatStateDirMigration(legacyDir, targetDir) {
|
|
490
|
+
return `State dir: ${legacyDir} → ${targetDir} (legacy path now symlinked)`;
|
|
491
|
+
}
|
|
492
|
+
function isDirPath(filePath) {
|
|
493
|
+
try {
|
|
494
|
+
return fs.statSync(filePath).isDirectory();
|
|
495
|
+
} catch {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
async function autoMigrateLegacyStateDir(params) {
|
|
500
|
+
if (autoMigrateStateDirChecked) return {
|
|
501
|
+
migrated: false,
|
|
502
|
+
skipped: true,
|
|
503
|
+
changes: [],
|
|
504
|
+
warnings: []
|
|
505
|
+
};
|
|
506
|
+
autoMigrateStateDirChecked = true;
|
|
507
|
+
if ((params.env ?? process.env).OPENCLAW_STATE_DIR?.trim()) return {
|
|
508
|
+
migrated: false,
|
|
509
|
+
skipped: true,
|
|
510
|
+
changes: [],
|
|
511
|
+
warnings: []
|
|
512
|
+
};
|
|
513
|
+
const homedir = params.homedir ?? os.homedir;
|
|
514
|
+
const targetDir = resolveNewStateDir(homedir);
|
|
515
|
+
const legacyDirs = resolveLegacyStateDirs(homedir);
|
|
516
|
+
let legacyDir = legacyDirs.find((dir) => {
|
|
517
|
+
try {
|
|
518
|
+
return fs.existsSync(dir);
|
|
519
|
+
} catch {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
const warnings = [];
|
|
524
|
+
const changes = [];
|
|
525
|
+
let legacyStat = null;
|
|
526
|
+
try {
|
|
527
|
+
legacyStat = legacyDir ? fs.lstatSync(legacyDir) : null;
|
|
528
|
+
} catch {
|
|
529
|
+
legacyStat = null;
|
|
530
|
+
}
|
|
531
|
+
if (!legacyStat) return {
|
|
532
|
+
migrated: false,
|
|
533
|
+
skipped: false,
|
|
534
|
+
changes,
|
|
535
|
+
warnings
|
|
536
|
+
};
|
|
537
|
+
if (!legacyStat.isDirectory() && !legacyStat.isSymbolicLink()) {
|
|
538
|
+
warnings.push(`Legacy state path is not a directory: ${legacyDir}`);
|
|
539
|
+
return {
|
|
540
|
+
migrated: false,
|
|
541
|
+
skipped: false,
|
|
542
|
+
changes,
|
|
543
|
+
warnings
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
let symlinkDepth = 0;
|
|
547
|
+
while (legacyStat.isSymbolicLink()) {
|
|
548
|
+
const legacyTarget = legacyDir ? resolveSymlinkTarget(legacyDir) : null;
|
|
549
|
+
if (!legacyTarget) {
|
|
550
|
+
warnings.push(`Legacy state dir is a symlink (${legacyDir ?? "unknown"}); could not resolve target.`);
|
|
551
|
+
return {
|
|
552
|
+
migrated: false,
|
|
553
|
+
skipped: false,
|
|
554
|
+
changes,
|
|
555
|
+
warnings
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
if (path.resolve(legacyTarget) === path.resolve(targetDir)) return {
|
|
559
|
+
migrated: false,
|
|
560
|
+
skipped: false,
|
|
561
|
+
changes,
|
|
562
|
+
warnings
|
|
563
|
+
};
|
|
564
|
+
if (legacyDirs.some((dir) => path.resolve(dir) === path.resolve(legacyTarget))) {
|
|
565
|
+
legacyDir = legacyTarget;
|
|
566
|
+
try {
|
|
567
|
+
legacyStat = fs.lstatSync(legacyDir);
|
|
568
|
+
} catch {
|
|
569
|
+
legacyStat = null;
|
|
570
|
+
}
|
|
571
|
+
if (!legacyStat) {
|
|
572
|
+
warnings.push(`Legacy state dir missing after symlink resolution: ${legacyDir}`);
|
|
573
|
+
return {
|
|
574
|
+
migrated: false,
|
|
575
|
+
skipped: false,
|
|
576
|
+
changes,
|
|
577
|
+
warnings
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
if (!legacyStat.isDirectory() && !legacyStat.isSymbolicLink()) {
|
|
581
|
+
warnings.push(`Legacy state path is not a directory: ${legacyDir}`);
|
|
582
|
+
return {
|
|
583
|
+
migrated: false,
|
|
584
|
+
skipped: false,
|
|
585
|
+
changes,
|
|
586
|
+
warnings
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
symlinkDepth += 1;
|
|
590
|
+
if (symlinkDepth > 2) {
|
|
591
|
+
warnings.push(`Legacy state dir symlink chain too deep: ${legacyDir}`);
|
|
592
|
+
return {
|
|
593
|
+
migrated: false,
|
|
594
|
+
skipped: false,
|
|
595
|
+
changes,
|
|
596
|
+
warnings
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
warnings.push(`Legacy state dir is a symlink (${legacyDir ?? "unknown"} → ${legacyTarget}); skipping auto-migration.`);
|
|
602
|
+
return {
|
|
603
|
+
migrated: false,
|
|
604
|
+
skipped: false,
|
|
605
|
+
changes,
|
|
606
|
+
warnings
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (isDirPath(targetDir)) {
|
|
610
|
+
warnings.push(`State dir migration skipped: target already exists (${targetDir}). Remove or merge manually.`);
|
|
611
|
+
return {
|
|
612
|
+
migrated: false,
|
|
613
|
+
skipped: false,
|
|
614
|
+
changes,
|
|
615
|
+
warnings
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
if (!legacyDir) throw new Error("Legacy state dir not found");
|
|
620
|
+
fs.renameSync(legacyDir, targetDir);
|
|
621
|
+
} catch (err) {
|
|
622
|
+
warnings.push(`Failed to move legacy state dir (${legacyDir ?? "unknown"} → ${targetDir}): ${String(err)}`);
|
|
623
|
+
return {
|
|
624
|
+
migrated: false,
|
|
625
|
+
skipped: false,
|
|
626
|
+
changes,
|
|
627
|
+
warnings
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
try {
|
|
631
|
+
if (!legacyDir) throw new Error("Legacy state dir not found");
|
|
632
|
+
fs.symlinkSync(targetDir, legacyDir, "dir");
|
|
633
|
+
changes.push(formatStateDirMigration(legacyDir, targetDir));
|
|
634
|
+
} catch (err) {
|
|
635
|
+
try {
|
|
636
|
+
if (process.platform === "win32") {
|
|
637
|
+
if (!legacyDir) throw new Error("Legacy state dir not found", { cause: err });
|
|
638
|
+
fs.symlinkSync(targetDir, legacyDir, "junction");
|
|
639
|
+
changes.push(formatStateDirMigration(legacyDir, targetDir));
|
|
640
|
+
} else throw err;
|
|
641
|
+
} catch (fallbackErr) {
|
|
642
|
+
try {
|
|
643
|
+
if (!legacyDir) throw new Error("Legacy state dir not found", { cause: fallbackErr });
|
|
644
|
+
fs.renameSync(targetDir, legacyDir);
|
|
645
|
+
warnings.push(`State dir migration rolled back (failed to link legacy path): ${String(fallbackErr)}`);
|
|
646
|
+
return {
|
|
647
|
+
migrated: false,
|
|
648
|
+
skipped: false,
|
|
649
|
+
changes: [],
|
|
650
|
+
warnings
|
|
651
|
+
};
|
|
652
|
+
} catch (rollbackErr) {
|
|
653
|
+
warnings.push(`State dir moved but failed to link legacy path (${legacyDir ?? "unknown"} → ${targetDir}): ${String(fallbackErr)}`);
|
|
654
|
+
warnings.push(`Rollback failed; set OPENCLAW_STATE_DIR=${targetDir} to avoid split state: ${String(rollbackErr)}`);
|
|
655
|
+
changes.push(`State dir: ${legacyDir ?? "unknown"} → ${targetDir}`);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return {
|
|
660
|
+
migrated: changes.length > 0,
|
|
661
|
+
skipped: false,
|
|
662
|
+
changes,
|
|
663
|
+
warnings
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
async function detectLegacyStateMigrations(params) {
|
|
667
|
+
const env = params.env ?? process.env;
|
|
668
|
+
const stateDir = resolveStateDir(env, params.homedir ?? os.homedir);
|
|
669
|
+
const oauthDir = resolveOAuthDir(env, stateDir);
|
|
670
|
+
const targetAgentId = normalizeAgentId(resolveDefaultAgentId(params.cfg));
|
|
671
|
+
const rawMainKey = params.cfg.session?.mainKey;
|
|
672
|
+
const targetMainKey = typeof rawMainKey === "string" && rawMainKey.trim().length > 0 ? rawMainKey.trim() : DEFAULT_MAIN_KEY;
|
|
673
|
+
const targetScope = params.cfg.session?.scope;
|
|
674
|
+
const sessionsLegacyDir = path.join(stateDir, "sessions");
|
|
675
|
+
const sessionsLegacyStorePath = path.join(sessionsLegacyDir, "sessions.json");
|
|
676
|
+
const sessionsTargetDir = path.join(stateDir, "agents", targetAgentId, "sessions");
|
|
677
|
+
const sessionsTargetStorePath = path.join(sessionsTargetDir, "sessions.json");
|
|
678
|
+
const legacySessionEntries = safeReadDir(sessionsLegacyDir);
|
|
679
|
+
const hasLegacySessions = fileExists(sessionsLegacyStorePath) || legacySessionEntries.some((e) => e.isFile() && e.name.endsWith(".jsonl"));
|
|
680
|
+
const targetSessionParsed = fileExists(sessionsTargetStorePath) ? readSessionStoreJson5(sessionsTargetStorePath) : {
|
|
681
|
+
store: {},
|
|
682
|
+
ok: true
|
|
683
|
+
};
|
|
684
|
+
const legacyKeys = targetSessionParsed.ok ? listLegacySessionKeys({
|
|
685
|
+
store: targetSessionParsed.store,
|
|
686
|
+
agentId: targetAgentId,
|
|
687
|
+
mainKey: targetMainKey,
|
|
688
|
+
scope: targetScope
|
|
689
|
+
}) : [];
|
|
690
|
+
const legacyAgentDir = path.join(stateDir, "agent");
|
|
691
|
+
const targetAgentDir = path.join(stateDir, "agents", targetAgentId, "agent");
|
|
692
|
+
const hasLegacyAgentDir = existsDir$1(legacyAgentDir);
|
|
693
|
+
const targetWhatsAppAuthDir = path.join(oauthDir, "whatsapp", DEFAULT_ACCOUNT_ID);
|
|
694
|
+
const hasLegacyWhatsAppAuth = fileExists(path.join(oauthDir, "creds.json")) && !fileExists(path.join(targetWhatsAppAuthDir, "creds.json"));
|
|
695
|
+
const preview = [];
|
|
696
|
+
if (hasLegacySessions) preview.push(`- Sessions: ${sessionsLegacyDir} → ${sessionsTargetDir}`);
|
|
697
|
+
if (legacyKeys.length > 0) preview.push(`- Sessions: canonicalize legacy keys in ${sessionsTargetStorePath}`);
|
|
698
|
+
if (hasLegacyAgentDir) preview.push(`- Agent dir: ${legacyAgentDir} → ${targetAgentDir}`);
|
|
699
|
+
if (hasLegacyWhatsAppAuth) preview.push(`- WhatsApp auth: ${oauthDir} → ${targetWhatsAppAuthDir} (keep oauth.json)`);
|
|
700
|
+
return {
|
|
701
|
+
targetAgentId,
|
|
702
|
+
targetMainKey,
|
|
703
|
+
targetScope,
|
|
704
|
+
stateDir,
|
|
705
|
+
oauthDir,
|
|
706
|
+
sessions: {
|
|
707
|
+
legacyDir: sessionsLegacyDir,
|
|
708
|
+
legacyStorePath: sessionsLegacyStorePath,
|
|
709
|
+
targetDir: sessionsTargetDir,
|
|
710
|
+
targetStorePath: sessionsTargetStorePath,
|
|
711
|
+
hasLegacy: hasLegacySessions || legacyKeys.length > 0,
|
|
712
|
+
legacyKeys
|
|
713
|
+
},
|
|
714
|
+
agentDir: {
|
|
715
|
+
legacyDir: legacyAgentDir,
|
|
716
|
+
targetDir: targetAgentDir,
|
|
717
|
+
hasLegacy: hasLegacyAgentDir
|
|
718
|
+
},
|
|
719
|
+
whatsappAuth: {
|
|
720
|
+
legacyDir: oauthDir,
|
|
721
|
+
targetDir: targetWhatsAppAuthDir,
|
|
722
|
+
hasLegacy: hasLegacyWhatsAppAuth
|
|
723
|
+
},
|
|
724
|
+
preview
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
async function migrateLegacySessions(detected, now) {
|
|
728
|
+
const changes = [];
|
|
729
|
+
const warnings = [];
|
|
730
|
+
if (!detected.sessions.hasLegacy) return {
|
|
731
|
+
changes,
|
|
732
|
+
warnings
|
|
733
|
+
};
|
|
734
|
+
ensureDir$1(detected.sessions.targetDir);
|
|
735
|
+
const legacyParsed = fileExists(detected.sessions.legacyStorePath) ? readSessionStoreJson5(detected.sessions.legacyStorePath) : {
|
|
736
|
+
store: {},
|
|
737
|
+
ok: true
|
|
738
|
+
};
|
|
739
|
+
const targetParsed = fileExists(detected.sessions.targetStorePath) ? readSessionStoreJson5(detected.sessions.targetStorePath) : {
|
|
740
|
+
store: {},
|
|
741
|
+
ok: true
|
|
742
|
+
};
|
|
743
|
+
const legacyStore = legacyParsed.store;
|
|
744
|
+
const targetStore = targetParsed.store;
|
|
745
|
+
const canonicalizedTarget = canonicalizeSessionStore({
|
|
746
|
+
store: targetStore,
|
|
747
|
+
agentId: detected.targetAgentId,
|
|
748
|
+
mainKey: detected.targetMainKey,
|
|
749
|
+
scope: detected.targetScope
|
|
750
|
+
});
|
|
751
|
+
const canonicalizedLegacy = canonicalizeSessionStore({
|
|
752
|
+
store: legacyStore,
|
|
753
|
+
agentId: detected.targetAgentId,
|
|
754
|
+
mainKey: detected.targetMainKey,
|
|
755
|
+
scope: detected.targetScope
|
|
756
|
+
});
|
|
757
|
+
const merged = { ...canonicalizedTarget.store };
|
|
758
|
+
for (const [key, entry] of Object.entries(canonicalizedLegacy.store)) merged[key] = mergeSessionEntry({
|
|
759
|
+
existing: merged[key],
|
|
760
|
+
incoming: entry,
|
|
761
|
+
preferIncomingOnTie: false
|
|
762
|
+
});
|
|
763
|
+
const mainKey = buildAgentMainSessionKey({
|
|
764
|
+
agentId: detected.targetAgentId,
|
|
765
|
+
mainKey: detected.targetMainKey
|
|
766
|
+
});
|
|
767
|
+
if (!merged[mainKey]) {
|
|
768
|
+
const latest = pickLatestLegacyDirectEntry(legacyStore);
|
|
769
|
+
if (latest?.sessionId) {
|
|
770
|
+
merged[mainKey] = latest;
|
|
771
|
+
changes.push(`Migrated latest direct-chat session → ${mainKey}`);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (!legacyParsed.ok) warnings.push(`Legacy sessions store unreadable; left in place at ${detected.sessions.legacyStorePath}`);
|
|
775
|
+
if ((legacyParsed.ok || targetParsed.ok) && (Object.keys(legacyStore).length > 0 || Object.keys(targetStore).length > 0)) {
|
|
776
|
+
const normalized = {};
|
|
777
|
+
for (const [key, entry] of Object.entries(merged)) {
|
|
778
|
+
const normalizedEntry = normalizeSessionEntry(entry);
|
|
779
|
+
if (!normalizedEntry) continue;
|
|
780
|
+
normalized[key] = normalizedEntry;
|
|
781
|
+
}
|
|
782
|
+
await saveSessionStore(detected.sessions.targetStorePath, normalized);
|
|
783
|
+
changes.push(`Merged sessions store → ${detected.sessions.targetStorePath}`);
|
|
784
|
+
if (canonicalizedTarget.legacyKeys.length > 0) changes.push(`Canonicalized ${canonicalizedTarget.legacyKeys.length} legacy session key(s)`);
|
|
785
|
+
}
|
|
786
|
+
const entries = safeReadDir(detected.sessions.legacyDir);
|
|
787
|
+
for (const entry of entries) {
|
|
788
|
+
if (!entry.isFile()) continue;
|
|
789
|
+
if (entry.name === "sessions.json") continue;
|
|
790
|
+
const from = path.join(detected.sessions.legacyDir, entry.name);
|
|
791
|
+
const to = path.join(detected.sessions.targetDir, entry.name);
|
|
792
|
+
if (fileExists(to)) continue;
|
|
793
|
+
try {
|
|
794
|
+
fs.renameSync(from, to);
|
|
795
|
+
changes.push(`Moved ${entry.name} → agents/${detected.targetAgentId}/sessions`);
|
|
796
|
+
} catch (err) {
|
|
797
|
+
warnings.push(`Failed moving ${from}: ${String(err)}`);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
if (legacyParsed.ok) try {
|
|
801
|
+
if (fileExists(detected.sessions.legacyStorePath)) fs.rmSync(detected.sessions.legacyStorePath, { force: true });
|
|
802
|
+
} catch {}
|
|
803
|
+
removeDirIfEmpty(detected.sessions.legacyDir);
|
|
804
|
+
if (safeReadDir(detected.sessions.legacyDir).filter((e) => e.isFile()).length > 0) {
|
|
805
|
+
const backupDir = `${detected.sessions.legacyDir}.legacy-${now()}`;
|
|
806
|
+
try {
|
|
807
|
+
fs.renameSync(detected.sessions.legacyDir, backupDir);
|
|
808
|
+
warnings.push(`Left legacy sessions at ${backupDir}`);
|
|
809
|
+
} catch {}
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
changes,
|
|
813
|
+
warnings
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
async function migrateLegacyAgentDir(detected, now) {
|
|
817
|
+
const changes = [];
|
|
818
|
+
const warnings = [];
|
|
819
|
+
if (!detected.agentDir.hasLegacy) return {
|
|
820
|
+
changes,
|
|
821
|
+
warnings
|
|
822
|
+
};
|
|
823
|
+
ensureDir$1(detected.agentDir.targetDir);
|
|
824
|
+
const entries = safeReadDir(detected.agentDir.legacyDir);
|
|
825
|
+
for (const entry of entries) {
|
|
826
|
+
const from = path.join(detected.agentDir.legacyDir, entry.name);
|
|
827
|
+
const to = path.join(detected.agentDir.targetDir, entry.name);
|
|
828
|
+
if (fs.existsSync(to)) continue;
|
|
829
|
+
try {
|
|
830
|
+
fs.renameSync(from, to);
|
|
831
|
+
changes.push(`Moved agent file ${entry.name} → agents/${detected.targetAgentId}/agent`);
|
|
832
|
+
} catch (err) {
|
|
833
|
+
warnings.push(`Failed moving ${from}: ${String(err)}`);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
removeDirIfEmpty(detected.agentDir.legacyDir);
|
|
837
|
+
if (!emptyDirOrMissing(detected.agentDir.legacyDir)) {
|
|
838
|
+
const backupDir = path.join(detected.stateDir, "agents", detected.targetAgentId, `agent.legacy-${now()}`);
|
|
839
|
+
try {
|
|
840
|
+
fs.renameSync(detected.agentDir.legacyDir, backupDir);
|
|
841
|
+
warnings.push(`Left legacy agent dir at ${backupDir}`);
|
|
842
|
+
} catch (err) {
|
|
843
|
+
warnings.push(`Failed relocating legacy agent dir: ${String(err)}`);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return {
|
|
847
|
+
changes,
|
|
848
|
+
warnings
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
async function migrateLegacyWhatsAppAuth(detected) {
|
|
852
|
+
const changes = [];
|
|
853
|
+
const warnings = [];
|
|
854
|
+
if (!detected.whatsappAuth.hasLegacy) return {
|
|
855
|
+
changes,
|
|
856
|
+
warnings
|
|
857
|
+
};
|
|
858
|
+
ensureDir$1(detected.whatsappAuth.targetDir);
|
|
859
|
+
const entries = safeReadDir(detected.whatsappAuth.legacyDir);
|
|
860
|
+
for (const entry of entries) {
|
|
861
|
+
if (!entry.isFile()) continue;
|
|
862
|
+
if (entry.name === "oauth.json") continue;
|
|
863
|
+
if (!isLegacyWhatsAppAuthFile(entry.name)) continue;
|
|
864
|
+
const from = path.join(detected.whatsappAuth.legacyDir, entry.name);
|
|
865
|
+
const to = path.join(detected.whatsappAuth.targetDir, entry.name);
|
|
866
|
+
if (fileExists(to)) continue;
|
|
867
|
+
try {
|
|
868
|
+
fs.renameSync(from, to);
|
|
869
|
+
changes.push(`Moved WhatsApp auth ${entry.name} → whatsapp/default`);
|
|
870
|
+
} catch (err) {
|
|
871
|
+
warnings.push(`Failed moving ${from}: ${String(err)}`);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return {
|
|
875
|
+
changes,
|
|
876
|
+
warnings
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
async function runLegacyStateMigrations(params) {
|
|
880
|
+
const now = params.now ?? (() => Date.now());
|
|
881
|
+
const detected = params.detected;
|
|
882
|
+
const sessions = await migrateLegacySessions(detected, now);
|
|
883
|
+
const agentDir = await migrateLegacyAgentDir(detected, now);
|
|
884
|
+
const whatsappAuth = await migrateLegacyWhatsAppAuth(detected);
|
|
885
|
+
return {
|
|
886
|
+
changes: [
|
|
887
|
+
...sessions.changes,
|
|
888
|
+
...agentDir.changes,
|
|
889
|
+
...whatsappAuth.changes
|
|
890
|
+
],
|
|
891
|
+
warnings: [
|
|
892
|
+
...sessions.warnings,
|
|
893
|
+
...agentDir.warnings,
|
|
894
|
+
...whatsappAuth.warnings
|
|
895
|
+
]
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region src/commands/doctor-config-flow.ts
|
|
901
|
+
function isRecord(value) {
|
|
902
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
903
|
+
}
|
|
904
|
+
function normalizeIssuePath(path) {
|
|
905
|
+
return path.filter((part) => typeof part !== "symbol");
|
|
906
|
+
}
|
|
907
|
+
function isUnrecognizedKeysIssue(issue) {
|
|
908
|
+
return issue.code === "unrecognized_keys";
|
|
909
|
+
}
|
|
910
|
+
function formatPath(parts) {
|
|
911
|
+
if (parts.length === 0) return "<root>";
|
|
912
|
+
let out = "";
|
|
913
|
+
for (const part of parts) {
|
|
914
|
+
if (typeof part === "number") {
|
|
915
|
+
out += `[${part}]`;
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
out = out ? `${out}.${part}` : part;
|
|
919
|
+
}
|
|
920
|
+
return out || "<root>";
|
|
921
|
+
}
|
|
922
|
+
function resolvePathTarget(root, path) {
|
|
923
|
+
let current = root;
|
|
924
|
+
for (const part of path) {
|
|
925
|
+
if (typeof part === "number") {
|
|
926
|
+
if (!Array.isArray(current)) return null;
|
|
927
|
+
if (part < 0 || part >= current.length) return null;
|
|
928
|
+
current = current[part];
|
|
929
|
+
continue;
|
|
930
|
+
}
|
|
931
|
+
if (!current || typeof current !== "object" || Array.isArray(current)) return null;
|
|
932
|
+
const record = current;
|
|
933
|
+
if (!(part in record)) return null;
|
|
934
|
+
current = record[part];
|
|
935
|
+
}
|
|
936
|
+
return current;
|
|
937
|
+
}
|
|
938
|
+
function stripUnknownConfigKeys(config) {
|
|
939
|
+
const parsed = OpenClawSchema.safeParse(config);
|
|
940
|
+
if (parsed.success) return {
|
|
941
|
+
config,
|
|
942
|
+
removed: []
|
|
943
|
+
};
|
|
944
|
+
const next = structuredClone(config);
|
|
945
|
+
const removed = [];
|
|
946
|
+
for (const issue of parsed.error.issues) {
|
|
947
|
+
if (!isUnrecognizedKeysIssue(issue)) continue;
|
|
948
|
+
const path = normalizeIssuePath(issue.path);
|
|
949
|
+
const target = resolvePathTarget(next, path);
|
|
950
|
+
if (!target || typeof target !== "object" || Array.isArray(target)) continue;
|
|
951
|
+
const record = target;
|
|
952
|
+
for (const key of issue.keys) {
|
|
953
|
+
if (typeof key !== "string") continue;
|
|
954
|
+
if (!(key in record)) continue;
|
|
955
|
+
delete record[key];
|
|
956
|
+
removed.push(formatPath([...path, key]));
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return {
|
|
960
|
+
config: next,
|
|
961
|
+
removed
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function noteOpencodeProviderOverrides(cfg) {
|
|
965
|
+
const providers = cfg.models?.providers;
|
|
966
|
+
if (!providers) return;
|
|
967
|
+
const overrides = [];
|
|
968
|
+
if (providers.opencode) overrides.push("opencode");
|
|
969
|
+
if (providers["opencode-zen"]) overrides.push("opencode-zen");
|
|
970
|
+
if (overrides.length === 0) return;
|
|
971
|
+
const lines = overrides.flatMap((id) => {
|
|
972
|
+
const providerEntry = providers[id];
|
|
973
|
+
const api = isRecord(providerEntry) && typeof providerEntry.api === "string" ? providerEntry.api : void 0;
|
|
974
|
+
return [`- models.providers.${id} is set; this overrides the built-in OpenCode Zen catalog.`, api ? `- models.providers.${id}.api=${api}` : null].filter((line) => Boolean(line));
|
|
975
|
+
});
|
|
976
|
+
lines.push("- Remove these entries to restore per-model API routing + costs (then re-run onboarding if needed).");
|
|
977
|
+
note$1(lines.join("\n"), "OpenCode Zen");
|
|
978
|
+
}
|
|
979
|
+
async function maybeMigrateLegacyConfig() {
|
|
980
|
+
const changes = [];
|
|
981
|
+
const home = resolveHomeDir$1();
|
|
982
|
+
if (!home) return changes;
|
|
983
|
+
const targetDir = path.join(home, ".openclaw");
|
|
984
|
+
const targetPath = path.join(targetDir, "openclaw.json");
|
|
985
|
+
try {
|
|
986
|
+
await fs$1.access(targetPath);
|
|
987
|
+
return changes;
|
|
988
|
+
} catch {}
|
|
989
|
+
const legacyCandidates = [
|
|
990
|
+
path.join(home, ".clawdbot", "clawdbot.json"),
|
|
991
|
+
path.join(home, ".moltbot", "moltbot.json"),
|
|
992
|
+
path.join(home, ".moldbot", "moldbot.json")
|
|
993
|
+
];
|
|
994
|
+
let legacyPath = null;
|
|
995
|
+
for (const candidate of legacyCandidates) try {
|
|
996
|
+
await fs$1.access(candidate);
|
|
997
|
+
legacyPath = candidate;
|
|
998
|
+
break;
|
|
999
|
+
} catch {}
|
|
1000
|
+
if (!legacyPath) return changes;
|
|
1001
|
+
await fs$1.mkdir(targetDir, { recursive: true });
|
|
1002
|
+
try {
|
|
1003
|
+
await fs$1.copyFile(legacyPath, targetPath, fs$1.constants.COPYFILE_EXCL);
|
|
1004
|
+
changes.push(`Migrated legacy config: ${legacyPath} -> ${targetPath}`);
|
|
1005
|
+
} catch {}
|
|
1006
|
+
return changes;
|
|
1007
|
+
}
|
|
1008
|
+
async function loadAndMaybeMigrateDoctorConfig(params) {
|
|
1009
|
+
const shouldRepair = params.options.repair === true || params.options.yes === true;
|
|
1010
|
+
const stateDirResult = await autoMigrateLegacyStateDir({ env: process.env });
|
|
1011
|
+
if (stateDirResult.changes.length > 0) note$1(stateDirResult.changes.map((entry) => `- ${entry}`).join("\n"), "Doctor changes");
|
|
1012
|
+
if (stateDirResult.warnings.length > 0) note$1(stateDirResult.warnings.map((entry) => `- ${entry}`).join("\n"), "Doctor warnings");
|
|
1013
|
+
const legacyConfigChanges = await maybeMigrateLegacyConfig();
|
|
1014
|
+
if (legacyConfigChanges.length > 0) note$1(legacyConfigChanges.map((entry) => `- ${entry}`).join("\n"), "Doctor changes");
|
|
1015
|
+
let snapshot = await readConfigFileSnapshot();
|
|
1016
|
+
const baseCfg = snapshot.config ?? {};
|
|
1017
|
+
let cfg = baseCfg;
|
|
1018
|
+
let candidate = structuredClone(baseCfg);
|
|
1019
|
+
let pendingChanges = false;
|
|
1020
|
+
let shouldWriteConfig = false;
|
|
1021
|
+
const fixHints = [];
|
|
1022
|
+
if (snapshot.exists && !snapshot.valid && snapshot.legacyIssues.length === 0) note$1("Config invalid; doctor will run with best-effort config.", "Config");
|
|
1023
|
+
const warnings = snapshot.warnings ?? [];
|
|
1024
|
+
if (warnings.length > 0) note$1(warnings.map((issue) => `- ${issue.path}: ${issue.message}`).join("\n"), "Config warnings");
|
|
1025
|
+
if (snapshot.legacyIssues.length > 0) {
|
|
1026
|
+
note$1(snapshot.legacyIssues.map((issue) => `- ${issue.path}: ${issue.message}`).join("\n"), "Legacy config keys detected");
|
|
1027
|
+
const { config: migrated, changes } = migrateLegacyConfig(snapshot.parsed);
|
|
1028
|
+
if (changes.length > 0) note$1(changes.join("\n"), "Doctor changes");
|
|
1029
|
+
if (migrated) {
|
|
1030
|
+
candidate = migrated;
|
|
1031
|
+
pendingChanges = pendingChanges || changes.length > 0;
|
|
1032
|
+
}
|
|
1033
|
+
if (shouldRepair) {
|
|
1034
|
+
if (migrated) cfg = migrated;
|
|
1035
|
+
} else fixHints.push(`Run "${formatCliCommand("openclaw doctor --fix")}" to apply legacy migrations.`);
|
|
1036
|
+
}
|
|
1037
|
+
const normalized = normalizeLegacyConfigValues(candidate);
|
|
1038
|
+
if (normalized.changes.length > 0) {
|
|
1039
|
+
note$1(normalized.changes.join("\n"), "Doctor changes");
|
|
1040
|
+
candidate = normalized.config;
|
|
1041
|
+
pendingChanges = true;
|
|
1042
|
+
if (shouldRepair) cfg = normalized.config;
|
|
1043
|
+
else fixHints.push(`Run "${formatCliCommand("openclaw doctor --fix")}" to apply these changes.`);
|
|
1044
|
+
}
|
|
1045
|
+
const autoEnable = applyPluginAutoEnable({
|
|
1046
|
+
config: candidate,
|
|
1047
|
+
env: process.env
|
|
1048
|
+
});
|
|
1049
|
+
if (autoEnable.changes.length > 0) {
|
|
1050
|
+
note$1(autoEnable.changes.join("\n"), "Doctor changes");
|
|
1051
|
+
candidate = autoEnable.config;
|
|
1052
|
+
pendingChanges = true;
|
|
1053
|
+
if (shouldRepair) cfg = autoEnable.config;
|
|
1054
|
+
else fixHints.push(`Run "${formatCliCommand("openclaw doctor --fix")}" to apply these changes.`);
|
|
1055
|
+
}
|
|
1056
|
+
const unknown = stripUnknownConfigKeys(candidate);
|
|
1057
|
+
if (unknown.removed.length > 0) {
|
|
1058
|
+
const lines = unknown.removed.map((path) => `- ${path}`).join("\n");
|
|
1059
|
+
candidate = unknown.config;
|
|
1060
|
+
pendingChanges = true;
|
|
1061
|
+
if (shouldRepair) {
|
|
1062
|
+
cfg = unknown.config;
|
|
1063
|
+
note$1(lines, "Doctor changes");
|
|
1064
|
+
} else {
|
|
1065
|
+
note$1(lines, "Unknown config keys");
|
|
1066
|
+
fixHints.push("Run \"openclaw doctor --fix\" to remove these keys.");
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
if (!shouldRepair && pendingChanges) {
|
|
1070
|
+
if (await params.confirm({
|
|
1071
|
+
message: "Apply recommended config repairs now?",
|
|
1072
|
+
initialValue: true
|
|
1073
|
+
})) {
|
|
1074
|
+
cfg = candidate;
|
|
1075
|
+
shouldWriteConfig = true;
|
|
1076
|
+
} else if (fixHints.length > 0) note$1(fixHints.join("\n"), "Doctor");
|
|
1077
|
+
}
|
|
1078
|
+
noteOpencodeProviderOverrides(cfg);
|
|
1079
|
+
return {
|
|
1080
|
+
cfg,
|
|
1081
|
+
path: snapshot.path ?? CONFIG_PATH,
|
|
1082
|
+
shouldWriteConfig
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
//#endregion
|
|
1087
|
+
//#region src/commands/doctor-format.ts
|
|
1088
|
+
function formatGatewayRuntimeSummary(runtime) {
|
|
1089
|
+
if (!runtime) return null;
|
|
1090
|
+
const status = runtime.status ?? "unknown";
|
|
1091
|
+
const details = [];
|
|
1092
|
+
if (runtime.pid) details.push(`pid ${runtime.pid}`);
|
|
1093
|
+
if (runtime.state && runtime.state.toLowerCase() !== status) details.push(`state ${runtime.state}`);
|
|
1094
|
+
if (runtime.subState) details.push(`sub ${runtime.subState}`);
|
|
1095
|
+
if (runtime.lastExitStatus !== void 0) details.push(`last exit ${runtime.lastExitStatus}`);
|
|
1096
|
+
if (runtime.lastExitReason) details.push(`reason ${runtime.lastExitReason}`);
|
|
1097
|
+
if (runtime.lastRunResult) details.push(`last run ${runtime.lastRunResult}`);
|
|
1098
|
+
if (runtime.lastRunTime) details.push(`last run time ${runtime.lastRunTime}`);
|
|
1099
|
+
if (runtime.detail) details.push(runtime.detail);
|
|
1100
|
+
return details.length > 0 ? `${status} (${details.join(", ")})` : status;
|
|
1101
|
+
}
|
|
1102
|
+
function buildGatewayRuntimeHints(runtime, options = {}) {
|
|
1103
|
+
const hints = [];
|
|
1104
|
+
if (!runtime) return hints;
|
|
1105
|
+
const platform = options.platform ?? process.platform;
|
|
1106
|
+
const env = options.env ?? process.env;
|
|
1107
|
+
const fileLog = (() => {
|
|
1108
|
+
try {
|
|
1109
|
+
return getResolvedLoggerSettings().file;
|
|
1110
|
+
} catch {
|
|
1111
|
+
return null;
|
|
1112
|
+
}
|
|
1113
|
+
})();
|
|
1114
|
+
if (platform === "linux" && isSystemdUnavailableDetail(runtime.detail)) {
|
|
1115
|
+
hints.push(...renderSystemdUnavailableHints({ wsl: isWSLEnv() }));
|
|
1116
|
+
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
|
1117
|
+
return hints;
|
|
1118
|
+
}
|
|
1119
|
+
if (runtime.cachedLabel && platform === "darwin") {
|
|
1120
|
+
const label = resolveGatewayLaunchAgentLabel(env.OPENCLAW_PROFILE);
|
|
1121
|
+
hints.push(`LaunchAgent label cached but plist missing. Clear with: launchctl bootout gui/$UID/${label}`);
|
|
1122
|
+
hints.push(`Then reinstall: ${formatCliCommand("openclaw gateway install", env)}`);
|
|
1123
|
+
}
|
|
1124
|
+
if (runtime.missingUnit) {
|
|
1125
|
+
hints.push(`Service not installed. Run: ${formatCliCommand("openclaw gateway install", env)}`);
|
|
1126
|
+
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
|
1127
|
+
return hints;
|
|
1128
|
+
}
|
|
1129
|
+
if (runtime.status === "stopped") {
|
|
1130
|
+
hints.push("Service is loaded but not running (likely exited immediately).");
|
|
1131
|
+
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
|
1132
|
+
if (platform === "darwin") {
|
|
1133
|
+
const logs = resolveGatewayLogPaths(env);
|
|
1134
|
+
hints.push(`Launchd stdout (if installed): ${logs.stdoutPath}`);
|
|
1135
|
+
hints.push(`Launchd stderr (if installed): ${logs.stderrPath}`);
|
|
1136
|
+
} else if (platform === "linux") {
|
|
1137
|
+
const unit = resolveGatewaySystemdServiceName(env.OPENCLAW_PROFILE);
|
|
1138
|
+
hints.push(`Logs: journalctl --user -u ${unit}.service -n 200 --no-pager`);
|
|
1139
|
+
} else if (platform === "win32") {
|
|
1140
|
+
const task = resolveGatewayWindowsTaskName(env.OPENCLAW_PROFILE);
|
|
1141
|
+
hints.push(`Logs: schtasks /Query /TN "${task}" /V /FO LIST`);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
return hints;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
//#endregion
|
|
1148
|
+
//#region src/commands/doctor-gateway-daemon-flow.ts
|
|
1149
|
+
async function maybeRepairLaunchAgentBootstrap(params) {
|
|
1150
|
+
if (process.platform !== "darwin") return false;
|
|
1151
|
+
if (!await isLaunchAgentListed({ env: params.env })) return false;
|
|
1152
|
+
if (await isLaunchAgentLoaded({ env: params.env })) return false;
|
|
1153
|
+
if (!await launchAgentPlistExists(params.env)) return false;
|
|
1154
|
+
note$1("LaunchAgent is listed but not loaded in launchd.", `${params.title} LaunchAgent`);
|
|
1155
|
+
if (!await params.prompter.confirmSkipInNonInteractive({
|
|
1156
|
+
message: `Repair ${params.title} LaunchAgent bootstrap now?`,
|
|
1157
|
+
initialValue: true
|
|
1158
|
+
})) return false;
|
|
1159
|
+
params.runtime.log(`Bootstrapping ${params.title} LaunchAgent...`);
|
|
1160
|
+
const repair = await repairLaunchAgentBootstrap({ env: params.env });
|
|
1161
|
+
if (!repair.ok) {
|
|
1162
|
+
params.runtime.error(`${params.title} LaunchAgent bootstrap failed: ${repair.detail ?? "unknown error"}`);
|
|
1163
|
+
return false;
|
|
1164
|
+
}
|
|
1165
|
+
if (!await isLaunchAgentLoaded({ env: params.env })) {
|
|
1166
|
+
params.runtime.error(`${params.title} LaunchAgent still not loaded after repair.`);
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
note$1(`${params.title} LaunchAgent repaired.`, `${params.title} LaunchAgent`);
|
|
1170
|
+
return true;
|
|
1171
|
+
}
|
|
1172
|
+
async function maybeRepairGatewayDaemon(params) {
|
|
1173
|
+
if (params.healthOk) return;
|
|
1174
|
+
const service = resolveGatewayService();
|
|
1175
|
+
let loaded = false;
|
|
1176
|
+
try {
|
|
1177
|
+
loaded = await service.isLoaded({ env: process.env });
|
|
1178
|
+
} catch {
|
|
1179
|
+
loaded = false;
|
|
1180
|
+
}
|
|
1181
|
+
let serviceRuntime;
|
|
1182
|
+
if (loaded) serviceRuntime = await service.readRuntime(process.env).catch(() => void 0);
|
|
1183
|
+
if (process.platform === "darwin" && params.cfg.gateway?.mode !== "remote") {
|
|
1184
|
+
const gatewayRepaired = await maybeRepairLaunchAgentBootstrap({
|
|
1185
|
+
env: process.env,
|
|
1186
|
+
title: "Gateway",
|
|
1187
|
+
runtime: params.runtime,
|
|
1188
|
+
prompter: params.prompter
|
|
1189
|
+
});
|
|
1190
|
+
await maybeRepairLaunchAgentBootstrap({
|
|
1191
|
+
env: {
|
|
1192
|
+
...process.env,
|
|
1193
|
+
OPENCLAW_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel()
|
|
1194
|
+
},
|
|
1195
|
+
title: "Node",
|
|
1196
|
+
runtime: params.runtime,
|
|
1197
|
+
prompter: params.prompter
|
|
1198
|
+
});
|
|
1199
|
+
if (gatewayRepaired) {
|
|
1200
|
+
loaded = await service.isLoaded({ env: process.env });
|
|
1201
|
+
if (loaded) serviceRuntime = await service.readRuntime(process.env).catch(() => void 0);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (params.cfg.gateway?.mode !== "remote") {
|
|
1205
|
+
const diagnostics = await inspectPortUsage(resolveGatewayPort(params.cfg, process.env));
|
|
1206
|
+
if (diagnostics.status === "busy") note$1(formatPortDiagnostics(diagnostics).join("\n"), "Gateway port");
|
|
1207
|
+
else if (loaded && serviceRuntime?.status === "running") {
|
|
1208
|
+
const lastError = await readLastGatewayErrorLine(process.env);
|
|
1209
|
+
if (lastError) note$1(`Last gateway error: ${lastError}`, "Gateway");
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
if (!loaded) {
|
|
1213
|
+
if (process.platform === "linux") {
|
|
1214
|
+
if (!await isSystemdUserServiceAvailable().catch(() => false)) {
|
|
1215
|
+
note$1(renderSystemdUnavailableHints({ wsl: await isWSL() }).join("\n"), "Gateway");
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
note$1("Gateway service not installed.", "Gateway");
|
|
1220
|
+
if (params.cfg.gateway?.mode !== "remote") {
|
|
1221
|
+
if (await params.prompter.confirmSkipInNonInteractive({
|
|
1222
|
+
message: "Install gateway service now?",
|
|
1223
|
+
initialValue: true
|
|
1224
|
+
})) {
|
|
1225
|
+
const daemonRuntime = await params.prompter.select({
|
|
1226
|
+
message: "Gateway service runtime",
|
|
1227
|
+
options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
|
1228
|
+
initialValue: DEFAULT_GATEWAY_DAEMON_RUNTIME
|
|
1229
|
+
}, DEFAULT_GATEWAY_DAEMON_RUNTIME);
|
|
1230
|
+
const port = resolveGatewayPort(params.cfg, process.env);
|
|
1231
|
+
const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
|
|
1232
|
+
env: process.env,
|
|
1233
|
+
port,
|
|
1234
|
+
token: params.cfg.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN,
|
|
1235
|
+
runtime: daemonRuntime,
|
|
1236
|
+
warn: (message, title) => note$1(message, title),
|
|
1237
|
+
config: params.cfg
|
|
1238
|
+
});
|
|
1239
|
+
try {
|
|
1240
|
+
await service.install({
|
|
1241
|
+
env: process.env,
|
|
1242
|
+
stdout: process.stdout,
|
|
1243
|
+
programArguments,
|
|
1244
|
+
workingDirectory,
|
|
1245
|
+
environment
|
|
1246
|
+
});
|
|
1247
|
+
} catch (err) {
|
|
1248
|
+
note$1(`Gateway service install failed: ${String(err)}`, "Gateway");
|
|
1249
|
+
note$1(gatewayInstallErrorHint(), "Gateway");
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
const summary = formatGatewayRuntimeSummary(serviceRuntime);
|
|
1256
|
+
const hints = buildGatewayRuntimeHints(serviceRuntime, {
|
|
1257
|
+
platform: process.platform,
|
|
1258
|
+
env: process.env
|
|
1259
|
+
});
|
|
1260
|
+
if (summary || hints.length > 0) {
|
|
1261
|
+
const lines = [];
|
|
1262
|
+
if (summary) lines.push(`Runtime: ${summary}`);
|
|
1263
|
+
lines.push(...hints);
|
|
1264
|
+
note$1(lines.join("\n"), "Gateway");
|
|
1265
|
+
}
|
|
1266
|
+
if (serviceRuntime?.status !== "running") {
|
|
1267
|
+
if (await params.prompter.confirmSkipInNonInteractive({
|
|
1268
|
+
message: "Start gateway service now?",
|
|
1269
|
+
initialValue: true
|
|
1270
|
+
})) {
|
|
1271
|
+
await service.restart({
|
|
1272
|
+
env: process.env,
|
|
1273
|
+
stdout: process.stdout
|
|
1274
|
+
});
|
|
1275
|
+
await sleep(1500);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
if (process.platform === "darwin") {
|
|
1279
|
+
const label = resolveGatewayLaunchAgentLabel(process.env.OPENCLAW_PROFILE);
|
|
1280
|
+
note$1(`LaunchAgent loaded; stopping requires "${formatCliCommand("openclaw gateway stop")}" or launchctl bootout gui/$UID/${label}.`, "Gateway");
|
|
1281
|
+
}
|
|
1282
|
+
if (serviceRuntime?.status === "running") {
|
|
1283
|
+
if (await params.prompter.confirmSkipInNonInteractive({
|
|
1284
|
+
message: "Restart gateway service now?",
|
|
1285
|
+
initialValue: true
|
|
1286
|
+
})) {
|
|
1287
|
+
await service.restart({
|
|
1288
|
+
env: process.env,
|
|
1289
|
+
stdout: process.stdout
|
|
1290
|
+
});
|
|
1291
|
+
await sleep(1500);
|
|
1292
|
+
try {
|
|
1293
|
+
await healthCommand({
|
|
1294
|
+
json: false,
|
|
1295
|
+
timeoutMs: 1e4
|
|
1296
|
+
}, params.runtime);
|
|
1297
|
+
} catch (err) {
|
|
1298
|
+
if (String(err).includes("gateway closed")) {
|
|
1299
|
+
note$1("Gateway not running.", "Gateway");
|
|
1300
|
+
note$1(params.gatewayDetailsMessage, "Gateway connection");
|
|
1301
|
+
} else params.runtime.error(formatHealthCheckFailure(err));
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
//#endregion
|
|
1308
|
+
//#region src/commands/doctor-gateway-health.ts
|
|
1309
|
+
async function checkGatewayHealth(params) {
|
|
1310
|
+
const gatewayDetails = buildGatewayConnectionDetails({ config: params.cfg });
|
|
1311
|
+
const timeoutMs = typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 1e4;
|
|
1312
|
+
let healthOk = false;
|
|
1313
|
+
try {
|
|
1314
|
+
await healthCommand({
|
|
1315
|
+
json: false,
|
|
1316
|
+
timeoutMs,
|
|
1317
|
+
config: params.cfg
|
|
1318
|
+
}, params.runtime);
|
|
1319
|
+
healthOk = true;
|
|
1320
|
+
} catch (err) {
|
|
1321
|
+
if (String(err).includes("gateway closed")) {
|
|
1322
|
+
note$1("Gateway not running.", "Gateway");
|
|
1323
|
+
note$1(gatewayDetails.message, "Gateway connection");
|
|
1324
|
+
} else params.runtime.error(formatHealthCheckFailure(err));
|
|
1325
|
+
}
|
|
1326
|
+
if (healthOk) try {
|
|
1327
|
+
const issues = collectChannelStatusIssues(await callGateway({
|
|
1328
|
+
method: "channels.status",
|
|
1329
|
+
params: {
|
|
1330
|
+
probe: true,
|
|
1331
|
+
timeoutMs: 5e3
|
|
1332
|
+
},
|
|
1333
|
+
timeoutMs: 6e3
|
|
1334
|
+
}));
|
|
1335
|
+
if (issues.length > 0) note$1(issues.map((issue) => `- ${issue.channel} ${issue.accountId}: ${issue.message}${issue.fix ? ` (${issue.fix})` : ""}`).join("\n"), "Channel warnings");
|
|
1336
|
+
} catch {}
|
|
1337
|
+
return { healthOk };
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region src/commands/doctor-gateway-services.ts
|
|
1342
|
+
const execFileAsync$1 = promisify(execFile);
|
|
1343
|
+
function detectGatewayRuntime(programArguments) {
|
|
1344
|
+
const first = programArguments?.[0];
|
|
1345
|
+
if (first) {
|
|
1346
|
+
const base = path.basename(first).toLowerCase();
|
|
1347
|
+
if (base === "bun" || base === "bun.exe") return "bun";
|
|
1348
|
+
if (base === "node" || base === "node.exe") return "node";
|
|
1349
|
+
}
|
|
1350
|
+
return DEFAULT_GATEWAY_DAEMON_RUNTIME;
|
|
1351
|
+
}
|
|
1352
|
+
function findGatewayEntrypoint(programArguments) {
|
|
1353
|
+
if (!programArguments || programArguments.length === 0) return null;
|
|
1354
|
+
const gatewayIndex = programArguments.indexOf("gateway");
|
|
1355
|
+
if (gatewayIndex <= 0) return null;
|
|
1356
|
+
return programArguments[gatewayIndex - 1] ?? null;
|
|
1357
|
+
}
|
|
1358
|
+
function normalizeExecutablePath(value) {
|
|
1359
|
+
return path.resolve(value);
|
|
1360
|
+
}
|
|
1361
|
+
function extractDetailPath(detail, prefix) {
|
|
1362
|
+
if (!detail.startsWith(prefix)) return null;
|
|
1363
|
+
const value = detail.slice(prefix.length).trim();
|
|
1364
|
+
return value.length > 0 ? value : null;
|
|
1365
|
+
}
|
|
1366
|
+
async function cleanupLegacyLaunchdService(params) {
|
|
1367
|
+
await execFileAsync$1("launchctl", [
|
|
1368
|
+
"bootout",
|
|
1369
|
+
typeof process.getuid === "function" ? `gui/${process.getuid()}` : "gui/501",
|
|
1370
|
+
params.plistPath
|
|
1371
|
+
]).catch(() => void 0);
|
|
1372
|
+
await execFileAsync$1("launchctl", ["unload", params.plistPath]).catch(() => void 0);
|
|
1373
|
+
const trashDir = path.join(os.homedir(), ".Trash");
|
|
1374
|
+
try {
|
|
1375
|
+
await fs$1.mkdir(trashDir, { recursive: true });
|
|
1376
|
+
} catch {}
|
|
1377
|
+
try {
|
|
1378
|
+
await fs$1.access(params.plistPath);
|
|
1379
|
+
} catch {
|
|
1380
|
+
return null;
|
|
1381
|
+
}
|
|
1382
|
+
const dest = path.join(trashDir, `${params.label}-${Date.now()}.plist`);
|
|
1383
|
+
try {
|
|
1384
|
+
await fs$1.rename(params.plistPath, dest);
|
|
1385
|
+
return dest;
|
|
1386
|
+
} catch {
|
|
1387
|
+
return null;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
async function maybeRepairGatewayServiceConfig(cfg, mode, runtime, prompter) {
|
|
1391
|
+
if (resolveIsNixMode(process.env)) {
|
|
1392
|
+
note$1("Nix mode detected; skip service updates.", "Gateway");
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
if (mode === "remote") {
|
|
1396
|
+
note$1("Gateway mode is remote; skipped local service audit.", "Gateway");
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
const service = resolveGatewayService();
|
|
1400
|
+
let command = null;
|
|
1401
|
+
try {
|
|
1402
|
+
command = await service.readCommand(process.env);
|
|
1403
|
+
} catch {
|
|
1404
|
+
command = null;
|
|
1405
|
+
}
|
|
1406
|
+
if (!command) return;
|
|
1407
|
+
const audit = await auditGatewayServiceConfig({
|
|
1408
|
+
env: process.env,
|
|
1409
|
+
command
|
|
1410
|
+
});
|
|
1411
|
+
const needsNodeRuntime = needsNodeRuntimeMigration(audit.issues);
|
|
1412
|
+
const systemNodeInfo = needsNodeRuntime ? await resolveSystemNodeInfo({ env: process.env }) : null;
|
|
1413
|
+
const systemNodePath = systemNodeInfo?.supported ? systemNodeInfo.path : null;
|
|
1414
|
+
if (needsNodeRuntime && !systemNodePath) {
|
|
1415
|
+
const warning = renderSystemNodeWarning(systemNodeInfo);
|
|
1416
|
+
if (warning) note$1(warning, "Gateway runtime");
|
|
1417
|
+
note$1("System Node 22+ not found. Install via Homebrew/apt/choco and rerun doctor to migrate off Bun/version managers.", "Gateway runtime");
|
|
1418
|
+
}
|
|
1419
|
+
const port = resolveGatewayPort(cfg, process.env);
|
|
1420
|
+
const runtimeChoice = detectGatewayRuntime(command.programArguments);
|
|
1421
|
+
const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
|
|
1422
|
+
env: process.env,
|
|
1423
|
+
port,
|
|
1424
|
+
token: cfg.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN,
|
|
1425
|
+
runtime: needsNodeRuntime && systemNodePath ? "node" : runtimeChoice,
|
|
1426
|
+
nodePath: systemNodePath ?? void 0,
|
|
1427
|
+
warn: (message, title) => note$1(message, title),
|
|
1428
|
+
config: cfg
|
|
1429
|
+
});
|
|
1430
|
+
const expectedEntrypoint = findGatewayEntrypoint(programArguments);
|
|
1431
|
+
const currentEntrypoint = findGatewayEntrypoint(command.programArguments);
|
|
1432
|
+
if (expectedEntrypoint && currentEntrypoint && normalizeExecutablePath(expectedEntrypoint) !== normalizeExecutablePath(currentEntrypoint)) audit.issues.push({
|
|
1433
|
+
code: SERVICE_AUDIT_CODES.gatewayEntrypointMismatch,
|
|
1434
|
+
message: "Gateway service entrypoint does not match the current install.",
|
|
1435
|
+
detail: `${currentEntrypoint} -> ${expectedEntrypoint}`,
|
|
1436
|
+
level: "recommended"
|
|
1437
|
+
});
|
|
1438
|
+
if (audit.issues.length === 0) return;
|
|
1439
|
+
note$1(audit.issues.map((issue) => issue.detail ? `- ${issue.message} (${issue.detail})` : `- ${issue.message}`).join("\n"), "Gateway service config");
|
|
1440
|
+
const needsAggressive = audit.issues.filter((issue) => issue.level === "aggressive").length > 0;
|
|
1441
|
+
if (needsAggressive && !prompter.shouldForce) note$1("Custom or unexpected service edits detected. Rerun with --force to overwrite.", "Gateway service config");
|
|
1442
|
+
if (!(needsAggressive ? await prompter.confirmAggressive({
|
|
1443
|
+
message: "Overwrite gateway service config with current defaults now?",
|
|
1444
|
+
initialValue: Boolean(prompter.shouldForce)
|
|
1445
|
+
}) : await prompter.confirmRepair({
|
|
1446
|
+
message: "Update gateway service config to the recommended defaults now?",
|
|
1447
|
+
initialValue: true
|
|
1448
|
+
}))) return;
|
|
1449
|
+
try {
|
|
1450
|
+
await service.install({
|
|
1451
|
+
env: process.env,
|
|
1452
|
+
stdout: process.stdout,
|
|
1453
|
+
programArguments,
|
|
1454
|
+
workingDirectory,
|
|
1455
|
+
environment
|
|
1456
|
+
});
|
|
1457
|
+
} catch (err) {
|
|
1458
|
+
runtime.error(`Gateway service update failed: ${String(err)}`);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
async function maybeScanExtraGatewayServices(options, runtime, prompter) {
|
|
1462
|
+
const extraServices = await findExtraGatewayServices(process.env, { deep: options.deep });
|
|
1463
|
+
if (extraServices.length === 0) return;
|
|
1464
|
+
note$1(extraServices.map((svc) => `- ${svc.label} (${svc.scope}, ${svc.detail})`).join("\n"), "Other gateway-like services detected");
|
|
1465
|
+
const legacyServices = extraServices.filter((svc) => svc.legacy === true);
|
|
1466
|
+
if (legacyServices.length > 0) {
|
|
1467
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
1468
|
+
message: "Remove legacy gateway services (clawdbot/moltbot) now?",
|
|
1469
|
+
initialValue: true
|
|
1470
|
+
})) {
|
|
1471
|
+
const removed = [];
|
|
1472
|
+
const failed = [];
|
|
1473
|
+
for (const svc of legacyServices) {
|
|
1474
|
+
if (svc.platform !== "darwin") {
|
|
1475
|
+
failed.push(`${svc.label} (${svc.platform})`);
|
|
1476
|
+
continue;
|
|
1477
|
+
}
|
|
1478
|
+
if (svc.scope !== "user") {
|
|
1479
|
+
failed.push(`${svc.label} (${svc.scope})`);
|
|
1480
|
+
continue;
|
|
1481
|
+
}
|
|
1482
|
+
const plistPath = extractDetailPath(svc.detail, "plist:");
|
|
1483
|
+
if (!plistPath) {
|
|
1484
|
+
failed.push(`${svc.label} (missing plist path)`);
|
|
1485
|
+
continue;
|
|
1486
|
+
}
|
|
1487
|
+
const dest = await cleanupLegacyLaunchdService({
|
|
1488
|
+
label: svc.label,
|
|
1489
|
+
plistPath
|
|
1490
|
+
});
|
|
1491
|
+
removed.push(dest ? `${svc.label} -> ${dest}` : svc.label);
|
|
1492
|
+
}
|
|
1493
|
+
if (removed.length > 0) note$1(removed.map((line) => `- ${line}`).join("\n"), "Legacy gateway removed");
|
|
1494
|
+
if (failed.length > 0) note$1(failed.map((line) => `- ${line}`).join("\n"), "Legacy gateway cleanup skipped");
|
|
1495
|
+
if (removed.length > 0) runtime.log("Legacy gateway services removed. Installing OpenClaw gateway next.");
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
const cleanupHints = renderGatewayServiceCleanupHints();
|
|
1499
|
+
if (cleanupHints.length > 0) note$1(cleanupHints.map((hint) => `- ${hint}`).join("\n"), "Cleanup hints");
|
|
1500
|
+
note$1([
|
|
1501
|
+
"Recommendation: run a single gateway per machine for most setups.",
|
|
1502
|
+
"One gateway supports multiple agents.",
|
|
1503
|
+
"If you need multiple gateways (e.g., a rescue bot on the same host), isolate ports + config/state (see docs: /gateway#multiple-gateways-same-host)."
|
|
1504
|
+
].join("\n"), "Gateway recommendation");
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
//#endregion
|
|
1508
|
+
//#region src/commands/doctor-install.ts
|
|
1509
|
+
function noteSourceInstallIssues(root) {
|
|
1510
|
+
if (!root) return;
|
|
1511
|
+
const workspaceMarker = path.join(root, "pnpm-workspace.yaml");
|
|
1512
|
+
if (!fs.existsSync(workspaceMarker)) return;
|
|
1513
|
+
const warnings = [];
|
|
1514
|
+
const nodeModules = path.join(root, "node_modules");
|
|
1515
|
+
const pnpmStore = path.join(nodeModules, ".pnpm");
|
|
1516
|
+
const tsxBin = path.join(nodeModules, ".bin", "tsx");
|
|
1517
|
+
const srcEntry = path.join(root, "src", "entry.ts");
|
|
1518
|
+
if (fs.existsSync(nodeModules) && !fs.existsSync(pnpmStore)) warnings.push("- node_modules was not installed by pnpm (missing node_modules/.pnpm). Run: pnpm install");
|
|
1519
|
+
if (fs.existsSync(path.join(root, "package-lock.json"))) warnings.push("- package-lock.json present in a pnpm workspace. If you ran npm install, remove it and reinstall with pnpm.");
|
|
1520
|
+
if (fs.existsSync(srcEntry) && !fs.existsSync(tsxBin)) warnings.push("- tsx binary is missing for source runs. Run: pnpm install");
|
|
1521
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "Install");
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
//#endregion
|
|
1525
|
+
//#region src/commands/doctor-platform-notes.ts
|
|
1526
|
+
const execFileAsync = promisify(execFile);
|
|
1527
|
+
function resolveHomeDir() {
|
|
1528
|
+
return process.env.HOME ?? os.homedir();
|
|
1529
|
+
}
|
|
1530
|
+
async function noteMacLaunchAgentOverrides() {
|
|
1531
|
+
if (process.platform !== "darwin") return;
|
|
1532
|
+
const home = resolveHomeDir();
|
|
1533
|
+
const markerPath = [path.join(home, ".openclaw", "disable-launchagent")].find((candidate) => fs.existsSync(candidate));
|
|
1534
|
+
if (!markerPath) return;
|
|
1535
|
+
const displayMarkerPath = shortenHomePath(markerPath);
|
|
1536
|
+
note$1([
|
|
1537
|
+
`- LaunchAgent writes are disabled via ${displayMarkerPath}.`,
|
|
1538
|
+
"- To restore default behavior:",
|
|
1539
|
+
` rm ${displayMarkerPath}`
|
|
1540
|
+
].filter((line) => Boolean(line)).join("\n"), "Gateway (macOS)");
|
|
1541
|
+
}
|
|
1542
|
+
async function launchctlGetenv(name) {
|
|
1543
|
+
try {
|
|
1544
|
+
const result = await execFileAsync("/bin/launchctl", ["getenv", name], { encoding: "utf8" });
|
|
1545
|
+
const value = String(result.stdout ?? "").trim();
|
|
1546
|
+
return value.length > 0 ? value : void 0;
|
|
1547
|
+
} catch {
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
function hasConfigGatewayCreds(cfg) {
|
|
1552
|
+
const localToken = typeof cfg.gateway?.auth?.token === "string" ? cfg.gateway?.auth?.token.trim() : "";
|
|
1553
|
+
const localPassword = typeof cfg.gateway?.auth?.password === "string" ? cfg.gateway?.auth?.password.trim() : "";
|
|
1554
|
+
const remoteToken = typeof cfg.gateway?.remote?.token === "string" ? cfg.gateway?.remote?.token.trim() : "";
|
|
1555
|
+
const remotePassword = typeof cfg.gateway?.remote?.password === "string" ? cfg.gateway?.remote?.password.trim() : "";
|
|
1556
|
+
return Boolean(localToken || localPassword || remoteToken || remotePassword);
|
|
1557
|
+
}
|
|
1558
|
+
async function noteMacLaunchctlGatewayEnvOverrides(cfg, deps) {
|
|
1559
|
+
if ((deps?.platform ?? process.platform) !== "darwin") return;
|
|
1560
|
+
if (!hasConfigGatewayCreds(cfg)) return;
|
|
1561
|
+
const getenv = deps?.getenv ?? launchctlGetenv;
|
|
1562
|
+
const deprecatedLaunchctlEntries = [
|
|
1563
|
+
["MOLTBOT_GATEWAY_TOKEN", await getenv("MOLTBOT_GATEWAY_TOKEN")],
|
|
1564
|
+
["MOLTBOT_GATEWAY_PASSWORD", await getenv("MOLTBOT_GATEWAY_PASSWORD")],
|
|
1565
|
+
["CLAWDBOT_GATEWAY_TOKEN", await getenv("CLAWDBOT_GATEWAY_TOKEN")],
|
|
1566
|
+
["CLAWDBOT_GATEWAY_PASSWORD", await getenv("CLAWDBOT_GATEWAY_PASSWORD")]
|
|
1567
|
+
].filter((entry) => Boolean(entry[1]?.trim()));
|
|
1568
|
+
if (deprecatedLaunchctlEntries.length > 0) {
|
|
1569
|
+
const lines = ["- Deprecated launchctl environment variables detected (ignored).", ...deprecatedLaunchctlEntries.map(([key]) => `- \`${key}\` is set; use \`OPENCLAW_${key.slice(key.indexOf("_") + 1)}\` instead.`)];
|
|
1570
|
+
(deps?.noteFn ?? note$1)(lines.join("\n"), "Gateway (macOS)");
|
|
1571
|
+
}
|
|
1572
|
+
const tokenEntries = [["OPENCLAW_GATEWAY_TOKEN", await getenv("OPENCLAW_GATEWAY_TOKEN")]];
|
|
1573
|
+
const passwordEntries = [["OPENCLAW_GATEWAY_PASSWORD", await getenv("OPENCLAW_GATEWAY_PASSWORD")]];
|
|
1574
|
+
const tokenEntry = tokenEntries.find(([, value]) => value?.trim());
|
|
1575
|
+
const passwordEntry = passwordEntries.find(([, value]) => value?.trim());
|
|
1576
|
+
const envToken = tokenEntry?.[1]?.trim() ?? "";
|
|
1577
|
+
const envPassword = passwordEntry?.[1]?.trim() ?? "";
|
|
1578
|
+
const envTokenKey = tokenEntry?.[0];
|
|
1579
|
+
const envPasswordKey = passwordEntry?.[0];
|
|
1580
|
+
if (!envToken && !envPassword) return;
|
|
1581
|
+
const lines = [
|
|
1582
|
+
"- launchctl environment overrides detected (can cause confusing unauthorized errors).",
|
|
1583
|
+
envToken && envTokenKey ? `- \`${envTokenKey}\` is set; it overrides config tokens.` : void 0,
|
|
1584
|
+
envPassword ? `- \`${envPasswordKey ?? "OPENCLAW_GATEWAY_PASSWORD"}\` is set; it overrides config passwords.` : void 0,
|
|
1585
|
+
"- Clear overrides and restart the app/gateway:",
|
|
1586
|
+
envTokenKey ? ` launchctl unsetenv ${envTokenKey}` : void 0,
|
|
1587
|
+
envPasswordKey ? ` launchctl unsetenv ${envPasswordKey}` : void 0
|
|
1588
|
+
].filter((line) => Boolean(line));
|
|
1589
|
+
(deps?.noteFn ?? note$1)(lines.join("\n"), "Gateway (macOS)");
|
|
1590
|
+
}
|
|
1591
|
+
function noteDeprecatedLegacyEnvVars(env = process.env, deps) {
|
|
1592
|
+
const entries = Object.entries(env).filter(([key, value]) => (key.startsWith("MOLTBOT_") || key.startsWith("CLAWDBOT_")) && value?.trim()).map(([key]) => key);
|
|
1593
|
+
if (entries.length === 0) return;
|
|
1594
|
+
const lines = [
|
|
1595
|
+
"- Deprecated legacy environment variables detected (ignored).",
|
|
1596
|
+
"- Use OPENCLAW_* equivalents instead:",
|
|
1597
|
+
...entries.map((key) => {
|
|
1598
|
+
return ` ${key} -> OPENCLAW_${key.slice(key.indexOf("_") + 1)}`;
|
|
1599
|
+
})
|
|
1600
|
+
];
|
|
1601
|
+
(deps?.noteFn ?? note$1)(lines.join("\n"), "Environment");
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
//#endregion
|
|
1605
|
+
//#region src/commands/doctor-prompter.ts
|
|
1606
|
+
function createDoctorPrompter(params) {
|
|
1607
|
+
const yes = params.options.yes === true;
|
|
1608
|
+
const requestedNonInteractive = params.options.nonInteractive === true;
|
|
1609
|
+
const shouldRepair = params.options.repair === true || yes;
|
|
1610
|
+
const shouldForce = params.options.force === true;
|
|
1611
|
+
const isTty = Boolean(process.stdin.isTTY);
|
|
1612
|
+
const nonInteractive = requestedNonInteractive || !isTty && !yes;
|
|
1613
|
+
const canPrompt = isTty && !yes && !nonInteractive;
|
|
1614
|
+
const confirmDefault = async (p) => {
|
|
1615
|
+
if (nonInteractive) return false;
|
|
1616
|
+
if (shouldRepair) return true;
|
|
1617
|
+
if (!canPrompt) return Boolean(p.initialValue ?? false);
|
|
1618
|
+
return guardCancel(await confirm({
|
|
1619
|
+
...p,
|
|
1620
|
+
message: stylePromptMessage(p.message)
|
|
1621
|
+
}), params.runtime);
|
|
1622
|
+
};
|
|
1623
|
+
return {
|
|
1624
|
+
confirm: confirmDefault,
|
|
1625
|
+
confirmRepair: async (p) => {
|
|
1626
|
+
if (nonInteractive) return false;
|
|
1627
|
+
return confirmDefault(p);
|
|
1628
|
+
},
|
|
1629
|
+
confirmAggressive: async (p) => {
|
|
1630
|
+
if (nonInteractive) return false;
|
|
1631
|
+
if (shouldRepair && shouldForce) return true;
|
|
1632
|
+
if (shouldRepair && !shouldForce) return false;
|
|
1633
|
+
if (!canPrompt) return Boolean(p.initialValue ?? false);
|
|
1634
|
+
return guardCancel(await confirm({
|
|
1635
|
+
...p,
|
|
1636
|
+
message: stylePromptMessage(p.message)
|
|
1637
|
+
}), params.runtime);
|
|
1638
|
+
},
|
|
1639
|
+
confirmSkipInNonInteractive: async (p) => {
|
|
1640
|
+
if (nonInteractive) return false;
|
|
1641
|
+
if (shouldRepair) return true;
|
|
1642
|
+
return confirmDefault(p);
|
|
1643
|
+
},
|
|
1644
|
+
select: async (p, fallback) => {
|
|
1645
|
+
if (!canPrompt || shouldRepair) return fallback;
|
|
1646
|
+
return guardCancel(await select({
|
|
1647
|
+
...p,
|
|
1648
|
+
message: stylePromptMessage(p.message),
|
|
1649
|
+
options: p.options.map((opt) => opt.hint === void 0 ? opt : {
|
|
1650
|
+
...opt,
|
|
1651
|
+
hint: stylePromptHint(opt.hint)
|
|
1652
|
+
})
|
|
1653
|
+
}), params.runtime);
|
|
1654
|
+
},
|
|
1655
|
+
shouldRepair,
|
|
1656
|
+
shouldForce
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
//#endregion
|
|
1661
|
+
//#region src/commands/doctor-sandbox.ts
|
|
1662
|
+
function resolveSandboxScript(scriptRel) {
|
|
1663
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
1664
|
+
candidates.add(process.cwd());
|
|
1665
|
+
const argv1 = process.argv[1];
|
|
1666
|
+
if (argv1) {
|
|
1667
|
+
const normalized = path.resolve(argv1);
|
|
1668
|
+
candidates.add(path.resolve(path.dirname(normalized), ".."));
|
|
1669
|
+
candidates.add(path.resolve(path.dirname(normalized)));
|
|
1670
|
+
}
|
|
1671
|
+
for (const root of candidates) {
|
|
1672
|
+
const scriptPath = path.join(root, scriptRel);
|
|
1673
|
+
if (fs.existsSync(scriptPath)) return {
|
|
1674
|
+
scriptPath,
|
|
1675
|
+
cwd: root
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
return null;
|
|
1679
|
+
}
|
|
1680
|
+
async function runSandboxScript(scriptRel, runtime) {
|
|
1681
|
+
const script = resolveSandboxScript(scriptRel);
|
|
1682
|
+
if (!script) {
|
|
1683
|
+
note$1(`Unable to locate ${scriptRel}. Run it from the repo root.`, "Sandbox");
|
|
1684
|
+
return false;
|
|
1685
|
+
}
|
|
1686
|
+
runtime.log(`Running ${scriptRel}...`);
|
|
1687
|
+
const result = await runCommandWithTimeout(["bash", script.scriptPath], {
|
|
1688
|
+
timeoutMs: 1200 * 1e3,
|
|
1689
|
+
cwd: script.cwd
|
|
1690
|
+
});
|
|
1691
|
+
if (result.code !== 0) {
|
|
1692
|
+
runtime.error(`Failed running ${scriptRel}: ${result.stderr.trim() || result.stdout.trim() || "unknown error"}`);
|
|
1693
|
+
return false;
|
|
1694
|
+
}
|
|
1695
|
+
runtime.log(`Completed ${scriptRel}.`);
|
|
1696
|
+
return true;
|
|
1697
|
+
}
|
|
1698
|
+
async function isDockerAvailable() {
|
|
1699
|
+
try {
|
|
1700
|
+
await runExec("docker", [
|
|
1701
|
+
"version",
|
|
1702
|
+
"--format",
|
|
1703
|
+
"{{.Server.Version}}"
|
|
1704
|
+
], { timeoutMs: 5e3 });
|
|
1705
|
+
return true;
|
|
1706
|
+
} catch {
|
|
1707
|
+
return false;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
async function dockerImageExists(image) {
|
|
1711
|
+
try {
|
|
1712
|
+
await runExec("docker", [
|
|
1713
|
+
"image",
|
|
1714
|
+
"inspect",
|
|
1715
|
+
image
|
|
1716
|
+
], { timeoutMs: 5e3 });
|
|
1717
|
+
return true;
|
|
1718
|
+
} catch (error) {
|
|
1719
|
+
const stderr = error?.stderr || error?.message || "";
|
|
1720
|
+
if (String(stderr).includes("No such image")) return false;
|
|
1721
|
+
throw error;
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function resolveSandboxDockerImage(cfg) {
|
|
1725
|
+
const image = cfg.agents?.defaults?.sandbox?.docker?.image?.trim();
|
|
1726
|
+
return image ? image : DEFAULT_SANDBOX_IMAGE;
|
|
1727
|
+
}
|
|
1728
|
+
function resolveSandboxBrowserImage(cfg) {
|
|
1729
|
+
const image = cfg.agents?.defaults?.sandbox?.browser?.image?.trim();
|
|
1730
|
+
return image ? image : DEFAULT_SANDBOX_BROWSER_IMAGE;
|
|
1731
|
+
}
|
|
1732
|
+
function updateSandboxDockerImage(cfg, image) {
|
|
1733
|
+
return {
|
|
1734
|
+
...cfg,
|
|
1735
|
+
agents: {
|
|
1736
|
+
...cfg.agents,
|
|
1737
|
+
defaults: {
|
|
1738
|
+
...cfg.agents?.defaults,
|
|
1739
|
+
sandbox: {
|
|
1740
|
+
...cfg.agents?.defaults?.sandbox,
|
|
1741
|
+
docker: {
|
|
1742
|
+
...cfg.agents?.defaults?.sandbox?.docker,
|
|
1743
|
+
image
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
function updateSandboxBrowserImage(cfg, image) {
|
|
1751
|
+
return {
|
|
1752
|
+
...cfg,
|
|
1753
|
+
agents: {
|
|
1754
|
+
...cfg.agents,
|
|
1755
|
+
defaults: {
|
|
1756
|
+
...cfg.agents?.defaults,
|
|
1757
|
+
sandbox: {
|
|
1758
|
+
...cfg.agents?.defaults?.sandbox,
|
|
1759
|
+
browser: {
|
|
1760
|
+
...cfg.agents?.defaults?.sandbox?.browser,
|
|
1761
|
+
image
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
async function handleMissingSandboxImage(params, runtime, prompter) {
|
|
1769
|
+
if (await dockerImageExists(params.image)) return;
|
|
1770
|
+
const buildHint = params.buildScript ? `Build it with ${params.buildScript}.` : "Build or pull it first.";
|
|
1771
|
+
note$1(`Sandbox ${params.kind} image missing: ${params.image}. ${buildHint}`, "Sandbox");
|
|
1772
|
+
let built = false;
|
|
1773
|
+
if (params.buildScript) {
|
|
1774
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
1775
|
+
message: `Build ${params.kind} sandbox image now?`,
|
|
1776
|
+
initialValue: true
|
|
1777
|
+
})) built = await runSandboxScript(params.buildScript, runtime);
|
|
1778
|
+
}
|
|
1779
|
+
if (built) return;
|
|
1780
|
+
}
|
|
1781
|
+
async function maybeRepairSandboxImages(cfg, runtime, prompter) {
|
|
1782
|
+
const sandbox = cfg.agents?.defaults?.sandbox;
|
|
1783
|
+
const mode = sandbox?.mode ?? "off";
|
|
1784
|
+
if (!sandbox || mode === "off") return cfg;
|
|
1785
|
+
if (!await isDockerAvailable()) {
|
|
1786
|
+
note$1("Docker not available; skipping sandbox image checks.", "Sandbox");
|
|
1787
|
+
return cfg;
|
|
1788
|
+
}
|
|
1789
|
+
let next = cfg;
|
|
1790
|
+
const changes = [];
|
|
1791
|
+
const dockerImage = resolveSandboxDockerImage(cfg);
|
|
1792
|
+
await handleMissingSandboxImage({
|
|
1793
|
+
kind: "base",
|
|
1794
|
+
image: dockerImage,
|
|
1795
|
+
buildScript: dockerImage === DEFAULT_SANDBOX_COMMON_IMAGE ? "scripts/sandbox-common-setup.sh" : dockerImage === DEFAULT_SANDBOX_IMAGE ? "scripts/sandbox-setup.sh" : void 0,
|
|
1796
|
+
updateConfig: (image) => {
|
|
1797
|
+
next = updateSandboxDockerImage(next, image);
|
|
1798
|
+
changes.push(`Updated agents.defaults.sandbox.docker.image → ${image}`);
|
|
1799
|
+
}
|
|
1800
|
+
}, runtime, prompter);
|
|
1801
|
+
if (sandbox.browser?.enabled) await handleMissingSandboxImage({
|
|
1802
|
+
kind: "browser",
|
|
1803
|
+
image: resolveSandboxBrowserImage(cfg),
|
|
1804
|
+
buildScript: "scripts/sandbox-browser-setup.sh",
|
|
1805
|
+
updateConfig: (image) => {
|
|
1806
|
+
next = updateSandboxBrowserImage(next, image);
|
|
1807
|
+
changes.push(`Updated agents.defaults.sandbox.browser.image → ${image}`);
|
|
1808
|
+
}
|
|
1809
|
+
}, runtime, prompter);
|
|
1810
|
+
if (changes.length > 0) note$1(changes.join("\n"), "Doctor changes");
|
|
1811
|
+
return next;
|
|
1812
|
+
}
|
|
1813
|
+
function noteSandboxScopeWarnings(cfg) {
|
|
1814
|
+
const globalSandbox = cfg.agents?.defaults?.sandbox;
|
|
1815
|
+
const agents = Array.isArray(cfg.agents?.list) ? cfg.agents.list : [];
|
|
1816
|
+
const warnings = [];
|
|
1817
|
+
for (const agent of agents) {
|
|
1818
|
+
const agentId = agent.id;
|
|
1819
|
+
const agentSandbox = agent.sandbox;
|
|
1820
|
+
if (!agentSandbox) continue;
|
|
1821
|
+
if (resolveSandboxScope({
|
|
1822
|
+
scope: agentSandbox.scope ?? globalSandbox?.scope,
|
|
1823
|
+
perSession: agentSandbox.perSession ?? globalSandbox?.perSession
|
|
1824
|
+
}) !== "shared") continue;
|
|
1825
|
+
const overrides = [];
|
|
1826
|
+
if (agentSandbox.docker && Object.keys(agentSandbox.docker).length > 0) overrides.push("docker");
|
|
1827
|
+
if (agentSandbox.browser && Object.keys(agentSandbox.browser).length > 0) overrides.push("browser");
|
|
1828
|
+
if (agentSandbox.prune && Object.keys(agentSandbox.prune).length > 0) overrides.push("prune");
|
|
1829
|
+
if (overrides.length === 0) continue;
|
|
1830
|
+
warnings.push([`- agents.list (id "${agentId}") sandbox ${overrides.join("/")} overrides ignored.`, ` scope resolves to "shared".`].join("\n"));
|
|
1831
|
+
}
|
|
1832
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "Sandbox");
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
//#endregion
|
|
1836
|
+
//#region src/commands/doctor-security.ts
|
|
1837
|
+
async function noteSecurityWarnings(cfg) {
|
|
1838
|
+
const warnings = [];
|
|
1839
|
+
const auditHint = `- Run: ${formatCliCommand("openclaw security audit --deep")}`;
|
|
1840
|
+
const gatewayBind = cfg.gateway?.bind ?? "loopback";
|
|
1841
|
+
const customBindHost = cfg.gateway?.customBindHost?.trim();
|
|
1842
|
+
const bindMode = [
|
|
1843
|
+
"auto",
|
|
1844
|
+
"lan",
|
|
1845
|
+
"loopback",
|
|
1846
|
+
"custom",
|
|
1847
|
+
"tailnet"
|
|
1848
|
+
].includes(gatewayBind) ? gatewayBind : void 0;
|
|
1849
|
+
const resolvedBindHost = bindMode ? await resolveGatewayBindHost(bindMode, customBindHost) : "0.0.0.0";
|
|
1850
|
+
const isExposed = !isLoopbackHost(resolvedBindHost);
|
|
1851
|
+
const resolvedAuth = resolveGatewayAuth({
|
|
1852
|
+
authConfig: cfg.gateway?.auth,
|
|
1853
|
+
env: process.env,
|
|
1854
|
+
tailscaleMode: cfg.gateway?.tailscale?.mode ?? "off"
|
|
1855
|
+
});
|
|
1856
|
+
const authToken = resolvedAuth.token?.trim() ?? "";
|
|
1857
|
+
const authPassword = resolvedAuth.password?.trim() ?? "";
|
|
1858
|
+
const hasToken = authToken.length > 0;
|
|
1859
|
+
const hasPassword = authPassword.length > 0;
|
|
1860
|
+
const hasSharedSecret = resolvedAuth.mode === "token" && hasToken || resolvedAuth.mode === "password" && hasPassword;
|
|
1861
|
+
const bindDescriptor = `"${gatewayBind}" (${resolvedBindHost})`;
|
|
1862
|
+
if (isExposed) if (!hasSharedSecret) {
|
|
1863
|
+
const authFixLines = resolvedAuth.mode === "password" ? [` Fix: ${formatCliCommand("openclaw configure")} to set a password`, ` Or switch to token: ${formatCliCommand("openclaw config set gateway.auth.mode token")}`] : [` Fix: ${formatCliCommand("openclaw doctor --fix")} to generate a token`, ` Or set token directly: ${formatCliCommand("openclaw config set gateway.auth.mode token")}`];
|
|
1864
|
+
warnings.push(`- CRITICAL: Gateway bound to ${bindDescriptor} without authentication.`, ` Anyone on your network (or internet if port-forwarded) can fully control your agent.`, ` Fix: ${formatCliCommand("openclaw config set gateway.bind loopback")}`, ...authFixLines);
|
|
1865
|
+
} else warnings.push(`- WARNING: Gateway bound to ${bindDescriptor} (network-accessible).`, ` Ensure your auth credentials are strong and not exposed.`);
|
|
1866
|
+
const warnDmPolicy = async (params) => {
|
|
1867
|
+
const dmPolicy = params.dmPolicy;
|
|
1868
|
+
const policyPath = params.policyPath ?? `${params.allowFromPath}policy`;
|
|
1869
|
+
const configAllowFrom = (params.allowFrom ?? []).map((v) => String(v).trim());
|
|
1870
|
+
const hasWildcard = configAllowFrom.includes("*");
|
|
1871
|
+
const storeAllowFrom = await readChannelAllowFromStore(params.provider).catch(() => []);
|
|
1872
|
+
const normalizedCfg = configAllowFrom.filter((v) => v !== "*").map((v) => params.normalizeEntry ? params.normalizeEntry(v) : v).map((v) => v.trim()).filter(Boolean);
|
|
1873
|
+
const normalizedStore = storeAllowFrom.map((v) => params.normalizeEntry ? params.normalizeEntry(v) : v).map((v) => v.trim()).filter(Boolean);
|
|
1874
|
+
const allowCount = Array.from(new Set([...normalizedCfg, ...normalizedStore])).length;
|
|
1875
|
+
const dmScope = cfg.session?.dmScope ?? "main";
|
|
1876
|
+
const isMultiUserDm = hasWildcard || allowCount > 1;
|
|
1877
|
+
if (dmPolicy === "open") {
|
|
1878
|
+
const allowFromPath = `${params.allowFromPath}allowFrom`;
|
|
1879
|
+
warnings.push(`- ${params.label} DMs: OPEN (${policyPath}="open"). Anyone can DM it.`);
|
|
1880
|
+
if (!hasWildcard) warnings.push(`- ${params.label} DMs: config invalid — "open" requires ${allowFromPath} to include "*".`);
|
|
1881
|
+
}
|
|
1882
|
+
if (dmPolicy === "disabled") {
|
|
1883
|
+
warnings.push(`- ${params.label} DMs: disabled (${policyPath}="disabled").`);
|
|
1884
|
+
return;
|
|
1885
|
+
}
|
|
1886
|
+
if (dmPolicy !== "open" && allowCount === 0) {
|
|
1887
|
+
warnings.push(`- ${params.label} DMs: locked (${policyPath}="${dmPolicy}") with no allowlist; unknown senders will be blocked / get a pairing code.`);
|
|
1888
|
+
warnings.push(` ${params.approveHint}`);
|
|
1889
|
+
}
|
|
1890
|
+
if (dmScope === "main" && isMultiUserDm) warnings.push(`- ${params.label} DMs: multiple senders share the main session; set session.dmScope="per-channel-peer" (or "per-account-channel-peer" for multi-account channels) to isolate sessions.`);
|
|
1891
|
+
};
|
|
1892
|
+
for (const plugin of listChannelPlugins()) {
|
|
1893
|
+
if (!plugin.security) continue;
|
|
1894
|
+
const defaultAccountId = resolveChannelDefaultAccountId({
|
|
1895
|
+
plugin,
|
|
1896
|
+
cfg,
|
|
1897
|
+
accountIds: plugin.config.listAccountIds(cfg)
|
|
1898
|
+
});
|
|
1899
|
+
const account = plugin.config.resolveAccount(cfg, defaultAccountId);
|
|
1900
|
+
if (!(plugin.config.isEnabled ? plugin.config.isEnabled(account, cfg) : true)) continue;
|
|
1901
|
+
if (!(plugin.config.isConfigured ? await plugin.config.isConfigured(account, cfg) : true)) continue;
|
|
1902
|
+
const dmPolicy = plugin.security.resolveDmPolicy?.({
|
|
1903
|
+
cfg,
|
|
1904
|
+
accountId: defaultAccountId,
|
|
1905
|
+
account
|
|
1906
|
+
});
|
|
1907
|
+
if (dmPolicy) await warnDmPolicy({
|
|
1908
|
+
label: plugin.meta.label ?? plugin.id,
|
|
1909
|
+
provider: plugin.id,
|
|
1910
|
+
dmPolicy: dmPolicy.policy,
|
|
1911
|
+
allowFrom: dmPolicy.allowFrom,
|
|
1912
|
+
policyPath: dmPolicy.policyPath,
|
|
1913
|
+
allowFromPath: dmPolicy.allowFromPath,
|
|
1914
|
+
approveHint: dmPolicy.approveHint,
|
|
1915
|
+
normalizeEntry: dmPolicy.normalizeEntry
|
|
1916
|
+
});
|
|
1917
|
+
if (plugin.security.collectWarnings) {
|
|
1918
|
+
const extra = await plugin.security.collectWarnings({
|
|
1919
|
+
cfg,
|
|
1920
|
+
accountId: defaultAccountId,
|
|
1921
|
+
account
|
|
1922
|
+
});
|
|
1923
|
+
if (extra?.length) warnings.push(...extra);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
const lines = warnings.length > 0 ? warnings : ["- No channel security warnings detected."];
|
|
1927
|
+
lines.push(auditHint);
|
|
1928
|
+
note$1(lines.join("\n"), "Security");
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
//#endregion
|
|
1932
|
+
//#region src/commands/doctor-state-integrity.ts
|
|
1933
|
+
function existsDir(dir) {
|
|
1934
|
+
try {
|
|
1935
|
+
return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
|
|
1936
|
+
} catch {
|
|
1937
|
+
return false;
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
function existsFile(filePath) {
|
|
1941
|
+
try {
|
|
1942
|
+
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
|
|
1943
|
+
} catch {
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
function canWriteDir(dir) {
|
|
1948
|
+
try {
|
|
1949
|
+
fs.accessSync(dir, fs.constants.W_OK);
|
|
1950
|
+
return true;
|
|
1951
|
+
} catch {
|
|
1952
|
+
return false;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
function ensureDir(dir) {
|
|
1956
|
+
try {
|
|
1957
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1958
|
+
return { ok: true };
|
|
1959
|
+
} catch (err) {
|
|
1960
|
+
return {
|
|
1961
|
+
ok: false,
|
|
1962
|
+
error: String(err)
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
function dirPermissionHint(dir) {
|
|
1967
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : null;
|
|
1968
|
+
const gid = typeof process.getgid === "function" ? process.getgid() : null;
|
|
1969
|
+
try {
|
|
1970
|
+
const stat = fs.statSync(dir);
|
|
1971
|
+
if (uid !== null && stat.uid !== uid) return `Owner mismatch (uid ${stat.uid}). Run: sudo chown -R $USER "${dir}"`;
|
|
1972
|
+
if (gid !== null && stat.gid !== gid) return `Group mismatch (gid ${stat.gid}). If access fails, run: sudo chown -R $USER "${dir}"`;
|
|
1973
|
+
} catch {
|
|
1974
|
+
return null;
|
|
1975
|
+
}
|
|
1976
|
+
return null;
|
|
1977
|
+
}
|
|
1978
|
+
function addUserRwx(mode) {
|
|
1979
|
+
return mode & 511 | 448;
|
|
1980
|
+
}
|
|
1981
|
+
function countJsonlLines(filePath) {
|
|
1982
|
+
try {
|
|
1983
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
1984
|
+
if (!raw) return 0;
|
|
1985
|
+
let count = 0;
|
|
1986
|
+
for (let i = 0; i < raw.length; i += 1) if (raw[i] === "\n") count += 1;
|
|
1987
|
+
if (!raw.endsWith("\n")) count += 1;
|
|
1988
|
+
return count;
|
|
1989
|
+
} catch {
|
|
1990
|
+
return 0;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function findOtherStateDirs(stateDir) {
|
|
1994
|
+
const resolvedState = path.resolve(stateDir);
|
|
1995
|
+
const roots = process.platform === "darwin" ? ["/Users"] : process.platform === "linux" ? ["/home"] : [];
|
|
1996
|
+
const found = [];
|
|
1997
|
+
for (const root of roots) {
|
|
1998
|
+
let entries = [];
|
|
1999
|
+
try {
|
|
2000
|
+
entries = fs.readdirSync(root, { withFileTypes: true });
|
|
2001
|
+
} catch {
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
2004
|
+
for (const entry of entries) {
|
|
2005
|
+
if (!entry.isDirectory()) continue;
|
|
2006
|
+
if (entry.name.startsWith(".")) continue;
|
|
2007
|
+
const candidates = [".openclaw"].map((dir) => path.resolve(root, entry.name, dir));
|
|
2008
|
+
for (const candidate of candidates) {
|
|
2009
|
+
if (candidate === resolvedState) continue;
|
|
2010
|
+
if (existsDir(candidate)) found.push(candidate);
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
return found;
|
|
2015
|
+
}
|
|
2016
|
+
async function noteStateIntegrity(cfg, prompter, configPath) {
|
|
2017
|
+
const warnings = [];
|
|
2018
|
+
const changes = [];
|
|
2019
|
+
const env = process.env;
|
|
2020
|
+
const homedir = os.homedir;
|
|
2021
|
+
const stateDir = resolveStateDir(env, homedir);
|
|
2022
|
+
const defaultStateDir = path.join(homedir(), ".openclaw");
|
|
2023
|
+
const oauthDir = resolveOAuthDir(env, stateDir);
|
|
2024
|
+
const agentId = resolveDefaultAgentId(cfg);
|
|
2025
|
+
const sessionsDir = resolveSessionTranscriptsDirForAgent(agentId, env, homedir);
|
|
2026
|
+
const storePath = resolveStorePath(cfg.session?.store, { agentId });
|
|
2027
|
+
const storeDir = path.dirname(storePath);
|
|
2028
|
+
const displayStateDir = shortenHomePath(stateDir);
|
|
2029
|
+
const displayOauthDir = shortenHomePath(oauthDir);
|
|
2030
|
+
const displaySessionsDir = shortenHomePath(sessionsDir);
|
|
2031
|
+
const displayStoreDir = shortenHomePath(storeDir);
|
|
2032
|
+
const displayConfigPath = configPath ? shortenHomePath(configPath) : void 0;
|
|
2033
|
+
let stateDirExists = existsDir(stateDir);
|
|
2034
|
+
if (!stateDirExists) {
|
|
2035
|
+
warnings.push(`- CRITICAL: state directory missing (${displayStateDir}). Sessions, credentials, logs, and config are stored there.`);
|
|
2036
|
+
if (cfg.gateway?.mode === "remote") warnings.push("- Gateway is in remote mode; run doctor on the remote host where the gateway runs.");
|
|
2037
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2038
|
+
message: `Create ${displayStateDir} now?`,
|
|
2039
|
+
initialValue: false
|
|
2040
|
+
})) {
|
|
2041
|
+
const created = ensureDir(stateDir);
|
|
2042
|
+
if (created.ok) {
|
|
2043
|
+
changes.push(`- Created ${displayStateDir}`);
|
|
2044
|
+
stateDirExists = true;
|
|
2045
|
+
} else warnings.push(`- Failed to create ${displayStateDir}: ${created.error}`);
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
if (stateDirExists && !canWriteDir(stateDir)) {
|
|
2049
|
+
warnings.push(`- State directory not writable (${displayStateDir}).`);
|
|
2050
|
+
const hint = dirPermissionHint(stateDir);
|
|
2051
|
+
if (hint) warnings.push(` ${hint}`);
|
|
2052
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2053
|
+
message: `Repair permissions on ${displayStateDir}?`,
|
|
2054
|
+
initialValue: true
|
|
2055
|
+
})) try {
|
|
2056
|
+
const target = addUserRwx(fs.statSync(stateDir).mode);
|
|
2057
|
+
fs.chmodSync(stateDir, target);
|
|
2058
|
+
changes.push(`- Repaired permissions on ${displayStateDir}`);
|
|
2059
|
+
} catch (err) {
|
|
2060
|
+
warnings.push(`- Failed to repair ${displayStateDir}: ${String(err)}`);
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
if (stateDirExists && process.platform !== "win32") try {
|
|
2064
|
+
if ((fs.statSync(stateDir).mode & 63) !== 0) {
|
|
2065
|
+
warnings.push(`- State directory permissions are too open (${displayStateDir}). Recommend chmod 700.`);
|
|
2066
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2067
|
+
message: `Tighten permissions on ${displayStateDir} to 700?`,
|
|
2068
|
+
initialValue: true
|
|
2069
|
+
})) {
|
|
2070
|
+
fs.chmodSync(stateDir, 448);
|
|
2071
|
+
changes.push(`- Tightened permissions on ${displayStateDir} to 700`);
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
} catch (err) {
|
|
2075
|
+
warnings.push(`- Failed to read ${displayStateDir} permissions: ${String(err)}`);
|
|
2076
|
+
}
|
|
2077
|
+
if (configPath && existsFile(configPath) && process.platform !== "win32") try {
|
|
2078
|
+
if ((fs.statSync(configPath).mode & 63) !== 0) {
|
|
2079
|
+
warnings.push(`- Config file is group/world readable (${displayConfigPath ?? configPath}). Recommend chmod 600.`);
|
|
2080
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2081
|
+
message: `Tighten permissions on ${displayConfigPath ?? configPath} to 600?`,
|
|
2082
|
+
initialValue: true
|
|
2083
|
+
})) {
|
|
2084
|
+
fs.chmodSync(configPath, 384);
|
|
2085
|
+
changes.push(`- Tightened permissions on ${displayConfigPath ?? configPath} to 600`);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
} catch (err) {
|
|
2089
|
+
warnings.push(`- Failed to read config permissions (${displayConfigPath ?? configPath}): ${String(err)}`);
|
|
2090
|
+
}
|
|
2091
|
+
if (stateDirExists) {
|
|
2092
|
+
const dirCandidates = /* @__PURE__ */ new Map();
|
|
2093
|
+
dirCandidates.set(sessionsDir, "Sessions dir");
|
|
2094
|
+
dirCandidates.set(storeDir, "Session store dir");
|
|
2095
|
+
dirCandidates.set(oauthDir, "OAuth dir");
|
|
2096
|
+
const displayDirFor = (dir) => {
|
|
2097
|
+
if (dir === sessionsDir) return displaySessionsDir;
|
|
2098
|
+
if (dir === storeDir) return displayStoreDir;
|
|
2099
|
+
if (dir === oauthDir) return displayOauthDir;
|
|
2100
|
+
return shortenHomePath(dir);
|
|
2101
|
+
};
|
|
2102
|
+
for (const [dir, label] of dirCandidates) {
|
|
2103
|
+
const displayDir = displayDirFor(dir);
|
|
2104
|
+
if (!existsDir(dir)) {
|
|
2105
|
+
warnings.push(`- CRITICAL: ${label} missing (${displayDir}).`);
|
|
2106
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2107
|
+
message: `Create ${label} at ${displayDir}?`,
|
|
2108
|
+
initialValue: true
|
|
2109
|
+
})) {
|
|
2110
|
+
const created = ensureDir(dir);
|
|
2111
|
+
if (created.ok) changes.push(`- Created ${label}: ${displayDir}`);
|
|
2112
|
+
else warnings.push(`- Failed to create ${displayDir}: ${created.error}`);
|
|
2113
|
+
}
|
|
2114
|
+
continue;
|
|
2115
|
+
}
|
|
2116
|
+
if (!canWriteDir(dir)) {
|
|
2117
|
+
warnings.push(`- ${label} not writable (${displayDir}).`);
|
|
2118
|
+
const hint = dirPermissionHint(dir);
|
|
2119
|
+
if (hint) warnings.push(` ${hint}`);
|
|
2120
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2121
|
+
message: `Repair permissions on ${label}?`,
|
|
2122
|
+
initialValue: true
|
|
2123
|
+
})) try {
|
|
2124
|
+
const target = addUserRwx(fs.statSync(dir).mode);
|
|
2125
|
+
fs.chmodSync(dir, target);
|
|
2126
|
+
changes.push(`- Repaired permissions on ${label}: ${displayDir}`);
|
|
2127
|
+
} catch (err) {
|
|
2128
|
+
warnings.push(`- Failed to repair ${displayDir}: ${String(err)}`);
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
const extraStateDirs = /* @__PURE__ */ new Set();
|
|
2134
|
+
if (path.resolve(stateDir) !== path.resolve(defaultStateDir)) {
|
|
2135
|
+
if (existsDir(defaultStateDir)) extraStateDirs.add(defaultStateDir);
|
|
2136
|
+
}
|
|
2137
|
+
for (const other of findOtherStateDirs(stateDir)) extraStateDirs.add(other);
|
|
2138
|
+
if (extraStateDirs.size > 0) warnings.push([
|
|
2139
|
+
"- Multiple state directories detected. This can split session history.",
|
|
2140
|
+
...Array.from(extraStateDirs).map((dir) => ` - ${shortenHomePath(dir)}`),
|
|
2141
|
+
` Active state dir: ${displayStateDir}`
|
|
2142
|
+
].join("\n"));
|
|
2143
|
+
const store = loadSessionStore(storePath);
|
|
2144
|
+
const entries = Object.entries(store).filter(([, entry]) => entry && typeof entry === "object");
|
|
2145
|
+
if (entries.length > 0) {
|
|
2146
|
+
const recent = entries.slice().toSorted((a, b) => {
|
|
2147
|
+
const aUpdated = typeof a[1].updatedAt === "number" ? a[1].updatedAt : 0;
|
|
2148
|
+
return (typeof b[1].updatedAt === "number" ? b[1].updatedAt : 0) - aUpdated;
|
|
2149
|
+
}).slice(0, 5);
|
|
2150
|
+
const missing = recent.filter(([, entry]) => {
|
|
2151
|
+
const sessionId = entry.sessionId;
|
|
2152
|
+
if (!sessionId) return false;
|
|
2153
|
+
return !existsFile(resolveSessionFilePath(sessionId, entry, { agentId }));
|
|
2154
|
+
});
|
|
2155
|
+
if (missing.length > 0) warnings.push(`- ${missing.length}/${recent.length} recent sessions are missing transcripts. Check for deleted session files or split state dirs.`);
|
|
2156
|
+
const mainEntry = store[resolveMainSessionKey(cfg)];
|
|
2157
|
+
if (mainEntry?.sessionId) {
|
|
2158
|
+
const transcriptPath = resolveSessionFilePath(mainEntry.sessionId, mainEntry, { agentId });
|
|
2159
|
+
if (!existsFile(transcriptPath)) warnings.push(`- Main session transcript missing (${shortenHomePath(transcriptPath)}). History will appear to reset.`);
|
|
2160
|
+
else {
|
|
2161
|
+
const lineCount = countJsonlLines(transcriptPath);
|
|
2162
|
+
if (lineCount <= 1) warnings.push(`- Main session transcript has only ${lineCount} line. Session history may not be appending.`);
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "State integrity");
|
|
2167
|
+
if (changes.length > 0) note$1(changes.join("\n"), "Doctor changes");
|
|
2168
|
+
}
|
|
2169
|
+
function noteWorkspaceBackupTip(workspaceDir) {
|
|
2170
|
+
if (!existsDir(workspaceDir)) return;
|
|
2171
|
+
const gitMarker = path.join(workspaceDir, ".git");
|
|
2172
|
+
if (fs.existsSync(gitMarker)) return;
|
|
2173
|
+
note$1([
|
|
2174
|
+
"- Tip: back up the workspace in a private git repo (GitHub or GitLab).",
|
|
2175
|
+
"- Keep ~/.openclaw out of git; it contains credentials and session history.",
|
|
2176
|
+
"- Details: /concepts/agent-workspace#git-backup-recommended"
|
|
2177
|
+
].join("\n"), "Workspace");
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
//#endregion
|
|
2181
|
+
//#region src/commands/doctor-ui.ts
|
|
2182
|
+
async function maybeRepairUiProtocolFreshness(_runtime, prompter) {
|
|
2183
|
+
const root = await resolveOpenClawPackageRoot({
|
|
2184
|
+
moduleUrl: import.meta.url,
|
|
2185
|
+
argv1: process.argv[1],
|
|
2186
|
+
cwd: process.cwd()
|
|
2187
|
+
});
|
|
2188
|
+
if (!root) return;
|
|
2189
|
+
const schemaPath = path.join(root, "src/gateway/protocol/schema.ts");
|
|
2190
|
+
const uiIndexPath = path.join(root, "dist/control-ui/index.html");
|
|
2191
|
+
try {
|
|
2192
|
+
const [schemaStats, uiStats] = await Promise.all([fs$1.stat(schemaPath).catch(() => null), fs$1.stat(uiIndexPath).catch(() => null)]);
|
|
2193
|
+
if (schemaStats && !uiStats) {
|
|
2194
|
+
note$1(["- Control UI assets are missing.", "- Run: pnpm ui:build"].join("\n"), "UI");
|
|
2195
|
+
const uiSourcesPath = path.join(root, "ui/package.json");
|
|
2196
|
+
if (!await fs$1.stat(uiSourcesPath).catch(() => null)) {
|
|
2197
|
+
note$1("Skipping UI build: ui/ sources not present.", "UI");
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
if (await prompter.confirmRepair({
|
|
2201
|
+
message: "Build Control UI assets now?",
|
|
2202
|
+
initialValue: true
|
|
2203
|
+
})) {
|
|
2204
|
+
note$1("Building Control UI assets... (this may take a moment)", "UI");
|
|
2205
|
+
const uiScriptPath = path.join(root, "scripts/ui.js");
|
|
2206
|
+
const buildResult = await runCommandWithTimeout([
|
|
2207
|
+
process.execPath,
|
|
2208
|
+
uiScriptPath,
|
|
2209
|
+
"build"
|
|
2210
|
+
], {
|
|
2211
|
+
cwd: root,
|
|
2212
|
+
timeoutMs: 12e4,
|
|
2213
|
+
env: {
|
|
2214
|
+
...process.env,
|
|
2215
|
+
FORCE_COLOR: "1"
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
if (buildResult.code === 0) note$1("UI build complete.", "UI");
|
|
2219
|
+
else note$1([`UI build failed (exit ${buildResult.code ?? "unknown"}).`, buildResult.stderr.trim() ? buildResult.stderr.trim() : null].filter(Boolean).join("\n"), "UI");
|
|
2220
|
+
}
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
if (!schemaStats || !uiStats) return;
|
|
2224
|
+
if (schemaStats.mtime > uiStats.mtime) {
|
|
2225
|
+
const gitLog = await runCommandWithTimeout([
|
|
2226
|
+
"git",
|
|
2227
|
+
"-C",
|
|
2228
|
+
root,
|
|
2229
|
+
"log",
|
|
2230
|
+
`--since=${uiStats.mtime.toISOString()}`,
|
|
2231
|
+
"--format=%h %s",
|
|
2232
|
+
"src/gateway/protocol/schema.ts"
|
|
2233
|
+
], { timeoutMs: 5e3 }).catch(() => null);
|
|
2234
|
+
if (gitLog && gitLog.code === 0 && gitLog.stdout.trim()) {
|
|
2235
|
+
note$1(`UI assets are older than the protocol schema.\nFunctional changes since last build:\n${gitLog.stdout.trim().split("\n").map((l) => `- ${l}`).join("\n")}`, "UI Freshness");
|
|
2236
|
+
if (await prompter.confirmAggressive({
|
|
2237
|
+
message: "Rebuild UI now? (Detected protocol mismatch requiring update)",
|
|
2238
|
+
initialValue: true
|
|
2239
|
+
})) {
|
|
2240
|
+
const uiSourcesPath = path.join(root, "ui/package.json");
|
|
2241
|
+
if (!await fs$1.stat(uiSourcesPath).catch(() => null)) {
|
|
2242
|
+
note$1("Skipping UI rebuild: ui/ sources not present.", "UI");
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
note$1("Rebuilding stale UI assets... (this may take a moment)", "UI");
|
|
2246
|
+
const uiScriptPath = path.join(root, "scripts/ui.js");
|
|
2247
|
+
const buildResult = await runCommandWithTimeout([
|
|
2248
|
+
process.execPath,
|
|
2249
|
+
uiScriptPath,
|
|
2250
|
+
"build"
|
|
2251
|
+
], {
|
|
2252
|
+
cwd: root,
|
|
2253
|
+
timeoutMs: 12e4,
|
|
2254
|
+
env: {
|
|
2255
|
+
...process.env,
|
|
2256
|
+
FORCE_COLOR: "1"
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
if (buildResult.code === 0) note$1("UI rebuild complete.", "UI");
|
|
2260
|
+
else note$1([`UI rebuild failed (exit ${buildResult.code ?? "unknown"}).`, buildResult.stderr.trim() ? buildResult.stderr.trim() : null].filter(Boolean).join("\n"), "UI");
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
} catch {}
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
//#endregion
|
|
2268
|
+
//#region src/commands/doctor-update.ts
|
|
2269
|
+
async function detectOpenClawGitCheckout(root) {
|
|
2270
|
+
const res = await runCommandWithTimeout([
|
|
2271
|
+
"git",
|
|
2272
|
+
"-C",
|
|
2273
|
+
root,
|
|
2274
|
+
"rev-parse",
|
|
2275
|
+
"--show-toplevel"
|
|
2276
|
+
], { timeoutMs: 5e3 }).catch(() => null);
|
|
2277
|
+
if (!res) return "unknown";
|
|
2278
|
+
if (res.code !== 0) {
|
|
2279
|
+
if (res.stderr.toLowerCase().includes("not a git repository")) return "not-git";
|
|
2280
|
+
return "unknown";
|
|
2281
|
+
}
|
|
2282
|
+
return res.stdout.trim() === root ? "git" : "not-git";
|
|
2283
|
+
}
|
|
2284
|
+
async function maybeOfferUpdateBeforeDoctor(params) {
|
|
2285
|
+
if (!(!isTruthyEnvValue(process.env.OPENCLAW_UPDATE_IN_PROGRESS) && params.options.nonInteractive !== true && params.options.yes !== true && params.options.repair !== true && Boolean(process.stdin.isTTY)) || !params.root) return { updated: false };
|
|
2286
|
+
const git = await detectOpenClawGitCheckout(params.root);
|
|
2287
|
+
if (git === "git") {
|
|
2288
|
+
if (!await params.confirm({
|
|
2289
|
+
message: "Update OpenClaw from git before running doctor?",
|
|
2290
|
+
initialValue: true
|
|
2291
|
+
})) return { updated: false };
|
|
2292
|
+
note$1("Running update (fetch/rebase/build/ui:build/doctor)…", "Update");
|
|
2293
|
+
const result = await runGatewayUpdate({
|
|
2294
|
+
cwd: params.root,
|
|
2295
|
+
argv1: process.argv[1]
|
|
2296
|
+
});
|
|
2297
|
+
note$1([
|
|
2298
|
+
`Status: ${result.status}`,
|
|
2299
|
+
`Mode: ${result.mode}`,
|
|
2300
|
+
result.root ? `Root: ${result.root}` : null,
|
|
2301
|
+
result.reason ? `Reason: ${result.reason}` : null
|
|
2302
|
+
].filter(Boolean).join("\n"), "Update result");
|
|
2303
|
+
if (result.status === "ok") {
|
|
2304
|
+
params.outro("Update completed (doctor already ran as part of the update).");
|
|
2305
|
+
return {
|
|
2306
|
+
updated: true,
|
|
2307
|
+
handled: true
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
return {
|
|
2311
|
+
updated: true,
|
|
2312
|
+
handled: false
|
|
2313
|
+
};
|
|
2314
|
+
}
|
|
2315
|
+
if (git === "not-git") note$1(["This install is not a git checkout.", `Run \`${formatCliCommand("openclaw update")}\` to update via your package manager (npm/pnpm), then rerun doctor.`].join("\n"), "Update");
|
|
2316
|
+
return { updated: false };
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
//#endregion
|
|
2320
|
+
//#region src/commands/doctor-workspace.ts
|
|
2321
|
+
const MEMORY_SYSTEM_PROMPT = [
|
|
2322
|
+
"Memory system not found in workspace.",
|
|
2323
|
+
"Paste this into your agent:",
|
|
2324
|
+
"",
|
|
2325
|
+
"Install the memory system by applying:",
|
|
2326
|
+
"https://github.com/openclaw/openclaw/commit/9ffea23f31ca1df5183b25668f8f814bee0fb34e",
|
|
2327
|
+
"https://github.com/openclaw/openclaw/commit/7d1fee70e76f2f634f1b41fca927ee663914183a"
|
|
2328
|
+
].join("\n");
|
|
2329
|
+
async function shouldSuggestMemorySystem(workspaceDir) {
|
|
2330
|
+
const memoryPaths = [path.join(workspaceDir, "MEMORY.md"), path.join(workspaceDir, "memory.md")];
|
|
2331
|
+
for (const memoryPath of memoryPaths) try {
|
|
2332
|
+
await fs.promises.access(memoryPath);
|
|
2333
|
+
return false;
|
|
2334
|
+
} catch {}
|
|
2335
|
+
const agentsPath = path.join(workspaceDir, DEFAULT_AGENTS_FILENAME);
|
|
2336
|
+
try {
|
|
2337
|
+
const content = await fs.promises.readFile(agentsPath, "utf-8");
|
|
2338
|
+
if (/memory\.md/i.test(content)) return false;
|
|
2339
|
+
} catch {}
|
|
2340
|
+
return true;
|
|
2341
|
+
}
|
|
2342
|
+
function detectLegacyWorkspaceDirs(params) {
|
|
2343
|
+
return {
|
|
2344
|
+
activeWorkspace: path.resolve(params.workspaceDir),
|
|
2345
|
+
legacyDirs: []
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
function formatLegacyWorkspaceWarning(detection) {
|
|
2349
|
+
return [
|
|
2350
|
+
"Extra workspace directories detected (may contain old agent files):",
|
|
2351
|
+
...detection.legacyDirs.map((dir) => `- ${shortenHomePath(dir)}`),
|
|
2352
|
+
`Active workspace: ${shortenHomePath(detection.activeWorkspace)}`,
|
|
2353
|
+
"If unused, archive or move to Trash."
|
|
2354
|
+
].join("\n");
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
//#endregion
|
|
2358
|
+
//#region src/commands/doctor-workspace-status.ts
|
|
2359
|
+
function noteWorkspaceStatus(cfg) {
|
|
2360
|
+
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
|
2361
|
+
const legacyWorkspace = detectLegacyWorkspaceDirs({ workspaceDir });
|
|
2362
|
+
if (legacyWorkspace.legacyDirs.length > 0) note$1(formatLegacyWorkspaceWarning(legacyWorkspace), "Extra workspace");
|
|
2363
|
+
const skillsReport = buildWorkspaceSkillStatus(workspaceDir, { config: cfg });
|
|
2364
|
+
note$1([
|
|
2365
|
+
`Eligible: ${skillsReport.skills.filter((s) => s.eligible).length}`,
|
|
2366
|
+
`Missing requirements: ${skillsReport.skills.filter((s) => !s.eligible && !s.disabled && !s.blockedByAllowlist).length}`,
|
|
2367
|
+
`Blocked by allowlist: ${skillsReport.skills.filter((s) => s.blockedByAllowlist).length}`
|
|
2368
|
+
].join("\n"), "Skills status");
|
|
2369
|
+
const pluginRegistry = loadOpenClawPlugins({
|
|
2370
|
+
config: cfg,
|
|
2371
|
+
workspaceDir,
|
|
2372
|
+
logger: {
|
|
2373
|
+
info: () => {},
|
|
2374
|
+
warn: () => {},
|
|
2375
|
+
error: () => {},
|
|
2376
|
+
debug: () => {}
|
|
2377
|
+
}
|
|
2378
|
+
});
|
|
2379
|
+
if (pluginRegistry.plugins.length > 0) {
|
|
2380
|
+
const loaded = pluginRegistry.plugins.filter((p) => p.status === "loaded");
|
|
2381
|
+
const disabled = pluginRegistry.plugins.filter((p) => p.status === "disabled");
|
|
2382
|
+
const errored = pluginRegistry.plugins.filter((p) => p.status === "error");
|
|
2383
|
+
note$1([
|
|
2384
|
+
`Loaded: ${loaded.length}`,
|
|
2385
|
+
`Disabled: ${disabled.length}`,
|
|
2386
|
+
`Errors: ${errored.length}`,
|
|
2387
|
+
errored.length > 0 ? `- ${errored.slice(0, 10).map((p) => p.id).join("\n- ")}${errored.length > 10 ? "\n- ..." : ""}` : null
|
|
2388
|
+
].filter((line) => Boolean(line)).join("\n"), "Plugins");
|
|
2389
|
+
}
|
|
2390
|
+
if (pluginRegistry.diagnostics.length > 0) note$1(pluginRegistry.diagnostics.map((diag) => {
|
|
2391
|
+
const prefix = diag.level.toUpperCase();
|
|
2392
|
+
const plugin = diag.pluginId ? ` ${diag.pluginId}` : "";
|
|
2393
|
+
const source = diag.source ? ` (${diag.source})` : "";
|
|
2394
|
+
return `- ${prefix}${plugin}: ${diag.message}${source}`;
|
|
2395
|
+
}).join("\n"), "Plugin diagnostics");
|
|
2396
|
+
return { workspaceDir };
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
//#endregion
|
|
2400
|
+
//#region src/commands/doctor.ts
|
|
2401
|
+
var doctor_exports = /* @__PURE__ */ __exportAll({ doctorCommand: () => doctorCommand });
|
|
2402
|
+
const intro$1 = (message) => intro(stylePromptTitle(message) ?? message);
|
|
2403
|
+
const outro$1 = (message) => outro(stylePromptTitle(message) ?? message);
|
|
2404
|
+
function resolveMode(cfg) {
|
|
2405
|
+
return cfg.gateway?.mode === "remote" ? "remote" : "local";
|
|
2406
|
+
}
|
|
2407
|
+
async function doctorCommand(runtime = defaultRuntime, options = {}) {
|
|
2408
|
+
const prompter = createDoctorPrompter({
|
|
2409
|
+
runtime,
|
|
2410
|
+
options
|
|
2411
|
+
});
|
|
2412
|
+
printWizardHeader(runtime);
|
|
2413
|
+
intro$1("OpenClaw doctor");
|
|
2414
|
+
const root = await resolveOpenClawPackageRoot({
|
|
2415
|
+
moduleUrl: import.meta.url,
|
|
2416
|
+
argv1: process.argv[1],
|
|
2417
|
+
cwd: process.cwd()
|
|
2418
|
+
});
|
|
2419
|
+
if ((await maybeOfferUpdateBeforeDoctor({
|
|
2420
|
+
runtime,
|
|
2421
|
+
options,
|
|
2422
|
+
root,
|
|
2423
|
+
confirm: (p) => prompter.confirm(p),
|
|
2424
|
+
outro: outro$1
|
|
2425
|
+
})).handled) return;
|
|
2426
|
+
await maybeRepairUiProtocolFreshness(runtime, prompter);
|
|
2427
|
+
noteSourceInstallIssues(root);
|
|
2428
|
+
noteDeprecatedLegacyEnvVars();
|
|
2429
|
+
const configResult = await loadAndMaybeMigrateDoctorConfig({
|
|
2430
|
+
options,
|
|
2431
|
+
confirm: (p) => prompter.confirm(p)
|
|
2432
|
+
});
|
|
2433
|
+
let cfg = configResult.cfg;
|
|
2434
|
+
const configPath = configResult.path ?? CONFIG_PATH;
|
|
2435
|
+
if (!cfg.gateway?.mode) {
|
|
2436
|
+
const lines = [
|
|
2437
|
+
"gateway.mode is unset; gateway start will be blocked.",
|
|
2438
|
+
`Fix: run ${formatCliCommand("openclaw configure")} and set Gateway mode (local/remote).`,
|
|
2439
|
+
`Or set directly: ${formatCliCommand("openclaw config set gateway.mode local")}`
|
|
2440
|
+
];
|
|
2441
|
+
if (!fs.existsSync(configPath)) lines.push(`Missing config: run ${formatCliCommand("openclaw setup")} first.`);
|
|
2442
|
+
note$1(lines.join("\n"), "Gateway");
|
|
2443
|
+
}
|
|
2444
|
+
cfg = await maybeRepairAnthropicOAuthProfileId(cfg, prompter);
|
|
2445
|
+
cfg = await maybeRemoveDeprecatedCliAuthProfiles(cfg, prompter);
|
|
2446
|
+
await noteAuthProfileHealth({
|
|
2447
|
+
cfg,
|
|
2448
|
+
prompter,
|
|
2449
|
+
allowKeychainPrompt: options.nonInteractive !== true && Boolean(process.stdin.isTTY)
|
|
2450
|
+
});
|
|
2451
|
+
const gatewayDetails = buildGatewayConnectionDetails({ config: cfg });
|
|
2452
|
+
if (gatewayDetails.remoteFallbackNote) note$1(gatewayDetails.remoteFallbackNote, "Gateway");
|
|
2453
|
+
if (resolveMode(cfg) === "local") {
|
|
2454
|
+
const auth = resolveGatewayAuth({
|
|
2455
|
+
authConfig: cfg.gateway?.auth,
|
|
2456
|
+
tailscaleMode: cfg.gateway?.tailscale?.mode ?? "off"
|
|
2457
|
+
});
|
|
2458
|
+
if (auth.mode !== "password" && (auth.mode !== "token" || !auth.token)) {
|
|
2459
|
+
note$1("Gateway auth is off or missing a token. Token auth is now the recommended default (including loopback).", "Gateway auth");
|
|
2460
|
+
if (options.generateGatewayToken === true ? true : options.nonInteractive === true ? false : await prompter.confirmRepair({
|
|
2461
|
+
message: "Generate and configure a gateway token now?",
|
|
2462
|
+
initialValue: true
|
|
2463
|
+
})) {
|
|
2464
|
+
const nextToken = randomToken();
|
|
2465
|
+
cfg = {
|
|
2466
|
+
...cfg,
|
|
2467
|
+
gateway: {
|
|
2468
|
+
...cfg.gateway,
|
|
2469
|
+
auth: {
|
|
2470
|
+
...cfg.gateway?.auth,
|
|
2471
|
+
mode: "token",
|
|
2472
|
+
token: nextToken
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
note$1("Gateway token configured.", "Gateway auth");
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
const legacyState = await detectLegacyStateMigrations({ cfg });
|
|
2481
|
+
if (legacyState.preview.length > 0) {
|
|
2482
|
+
note$1(legacyState.preview.join("\n"), "Legacy state detected");
|
|
2483
|
+
if (options.nonInteractive === true ? true : await prompter.confirm({
|
|
2484
|
+
message: "Migrate legacy state (sessions/agent/WhatsApp auth) now?",
|
|
2485
|
+
initialValue: true
|
|
2486
|
+
})) {
|
|
2487
|
+
const migrated = await runLegacyStateMigrations({ detected: legacyState });
|
|
2488
|
+
if (migrated.changes.length > 0) note$1(migrated.changes.join("\n"), "Doctor changes");
|
|
2489
|
+
if (migrated.warnings.length > 0) note$1(migrated.warnings.join("\n"), "Doctor warnings");
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
await noteStateIntegrity(cfg, prompter, configResult.path ?? CONFIG_PATH);
|
|
2493
|
+
cfg = await maybeRepairSandboxImages(cfg, runtime, prompter);
|
|
2494
|
+
noteSandboxScopeWarnings(cfg);
|
|
2495
|
+
await maybeScanExtraGatewayServices(options, runtime, prompter);
|
|
2496
|
+
await maybeRepairGatewayServiceConfig(cfg, resolveMode(cfg), runtime, prompter);
|
|
2497
|
+
await noteMacLaunchAgentOverrides();
|
|
2498
|
+
await noteMacLaunchctlGatewayEnvOverrides(cfg);
|
|
2499
|
+
await noteSecurityWarnings(cfg);
|
|
2500
|
+
if (cfg.hooks?.gmail?.model?.trim()) {
|
|
2501
|
+
const hooksModelRef = resolveHooksGmailModel({
|
|
2502
|
+
cfg,
|
|
2503
|
+
defaultProvider: DEFAULT_PROVIDER
|
|
2504
|
+
});
|
|
2505
|
+
if (!hooksModelRef) note$1(`- hooks.gmail.model "${cfg.hooks.gmail.model}" could not be resolved`, "Hooks");
|
|
2506
|
+
else {
|
|
2507
|
+
const { provider: defaultProvider, model: defaultModel } = resolveConfiguredModelRef({
|
|
2508
|
+
cfg,
|
|
2509
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2510
|
+
defaultModel: DEFAULT_MODEL
|
|
2511
|
+
});
|
|
2512
|
+
const catalog = await loadModelCatalog({ config: cfg });
|
|
2513
|
+
const status = getModelRefStatus({
|
|
2514
|
+
cfg,
|
|
2515
|
+
catalog,
|
|
2516
|
+
ref: hooksModelRef,
|
|
2517
|
+
defaultProvider,
|
|
2518
|
+
defaultModel
|
|
2519
|
+
});
|
|
2520
|
+
const warnings = [];
|
|
2521
|
+
if (!status.allowed) warnings.push(`- hooks.gmail.model "${status.key}" not in agents.defaults.models allowlist (will use primary instead)`);
|
|
2522
|
+
if (!status.inCatalog) warnings.push(`- hooks.gmail.model "${status.key}" not in the model catalog (may fail at runtime)`);
|
|
2523
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "Hooks");
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
if (options.nonInteractive !== true && process.platform === "linux" && resolveMode(cfg) === "local") {
|
|
2527
|
+
const service = resolveGatewayService();
|
|
2528
|
+
let loaded = false;
|
|
2529
|
+
try {
|
|
2530
|
+
loaded = await service.isLoaded({ env: process.env });
|
|
2531
|
+
} catch {
|
|
2532
|
+
loaded = false;
|
|
2533
|
+
}
|
|
2534
|
+
if (loaded) await ensureSystemdUserLingerInteractive({
|
|
2535
|
+
runtime,
|
|
2536
|
+
prompter: {
|
|
2537
|
+
confirm: async (p) => prompter.confirm(p),
|
|
2538
|
+
note: note$1
|
|
2539
|
+
},
|
|
2540
|
+
reason: "Gateway runs as a systemd user service. Without lingering, systemd stops the user session on logout/idle and kills the Gateway.",
|
|
2541
|
+
requireConfirm: true
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
noteWorkspaceStatus(cfg);
|
|
2545
|
+
const { healthOk } = await checkGatewayHealth({
|
|
2546
|
+
runtime,
|
|
2547
|
+
cfg,
|
|
2548
|
+
timeoutMs: options.nonInteractive === true ? 3e3 : 1e4
|
|
2549
|
+
});
|
|
2550
|
+
await maybeRepairGatewayDaemon({
|
|
2551
|
+
cfg,
|
|
2552
|
+
runtime,
|
|
2553
|
+
prompter,
|
|
2554
|
+
options,
|
|
2555
|
+
gatewayDetailsMessage: gatewayDetails.message,
|
|
2556
|
+
healthOk
|
|
2557
|
+
});
|
|
2558
|
+
if (prompter.shouldRepair || configResult.shouldWriteConfig) {
|
|
2559
|
+
cfg = applyWizardMetadata(cfg, {
|
|
2560
|
+
command: "doctor",
|
|
2561
|
+
mode: resolveMode(cfg)
|
|
2562
|
+
});
|
|
2563
|
+
await writeConfigFile(cfg);
|
|
2564
|
+
logConfigUpdated(runtime);
|
|
2565
|
+
const backupPath = `${CONFIG_PATH}.bak`;
|
|
2566
|
+
if (fs.existsSync(backupPath)) runtime.log(`Backup: ${shortenHomePath(backupPath)}`);
|
|
2567
|
+
} else runtime.log(`Run "${formatCliCommand("openclaw doctor --fix")}" to apply changes.`);
|
|
2568
|
+
if (options.workspaceSuggestions !== false) {
|
|
2569
|
+
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
|
2570
|
+
noteWorkspaceBackupTip(workspaceDir);
|
|
2571
|
+
if (await shouldSuggestMemorySystem(workspaceDir)) note$1(MEMORY_SYSTEM_PROMPT, "Workspace");
|
|
2572
|
+
}
|
|
2573
|
+
const finalSnapshot = await readConfigFileSnapshot();
|
|
2574
|
+
if (finalSnapshot.exists && !finalSnapshot.valid) {
|
|
2575
|
+
runtime.error("Invalid config:");
|
|
2576
|
+
for (const issue of finalSnapshot.issues) {
|
|
2577
|
+
const path = issue.path || "<root>";
|
|
2578
|
+
runtime.error(`- ${path}: ${issue.message}`);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
outro$1("Doctor complete.");
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
//#endregion
|
|
2585
|
+
export { doctor_exports as n, loadAndMaybeMigrateDoctorConfig as r, doctorCommand as t };
|