@termix-it/cryptoclaw 1.0.0
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 +1615 -0
- package/LICENSE +21 -0
- package/README-header.png +0 -0
- package/README.md +331 -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/cryptoclaw.mjs +14 -0
- package/dist/accounts-BPjR5SyC.js +251 -0
- package/dist/accounts-CIGHxE7R.js +251 -0
- package/dist/acp-cli-DBWmJpUJ.js +924 -0
- package/dist/acp-cli-DG9nygBk.js +926 -0
- package/dist/agent-3MZVCC-N.js +702 -0
- package/dist/agent-IDE9krld.js +702 -0
- package/dist/agent-scope-DBl1We79.js +370 -0
- package/dist/agent-scope-DLfFOxP6.js +370 -0
- package/dist/agent-scope-e_oNRhGi.js +606 -0
- package/dist/archive-Dy3Ezb-5.js +85 -0
- package/dist/archive-iT9wNsml.js +85 -0
- package/dist/audit-Bj_dxNaD.js +1853 -0
- package/dist/audit-jaTyyQX1.js +1853 -0
- package/dist/auth-RTEHx2eI.js +192 -0
- package/dist/auth-health-BlspzqyF.js +149 -0
- package/dist/auth-health-CCM6Z3vK.js +149 -0
- package/dist/auth-phxCaFNX.js +192 -0
- package/dist/auth-profiles-DoD7YxsD.js +2939 -0
- package/dist/boolean-BsqeuxE6.js +30 -0
- package/dist/brew-CAcErcKz.js +46 -0
- package/dist/brew-CqnNFIkD.js +46 -0
- package/dist/build-info.json +5 -0
- package/dist/call-D2DXG0AC.js +278 -0
- package/dist/call-DqxlETxE.js +278 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17765 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/channel-options-BHpXOBuP.js +32 -0
- package/dist/channel-options-DUkxROTo.js +62 -0
- package/dist/channel-selection-BdigfMZZ.js +51 -0
- package/dist/channel-selection-D7jFTFec.js +51 -0
- package/dist/channel-summary-CobMoKN6.js +1120 -0
- package/dist/channel-summary-DS0kcHm2.js +1120 -0
- package/dist/channels-cli-D7ZNRrq7.js +1414 -0
- package/dist/channels-cli-DBwffwqw.js +1413 -0
- package/dist/channels-status-issues-C2UGSPvH.js +18 -0
- package/dist/channels-status-issues-Dxmd7zYk.js +18 -0
- package/dist/chrome-CwbWzmh4.js +1973 -0
- package/dist/chrome-SVqOMFxA.js +1953 -0
- package/dist/clack-prompter-k_egRADS.js +92 -0
- package/dist/clack-prompter-nSmn5cZ2.js +92 -0
- package/dist/cli/daemon-cli.js +2 -0
- package/dist/cli-C9xiWnx9.js +86 -0
- package/dist/cli-D6C9z94O.js +88 -0
- package/dist/cli-utils-B7iQwCY5.js +43 -0
- package/dist/cli-utils-CgOu3WAB.js +43 -0
- package/dist/client-BaTYzXOU.js +1617 -0
- package/dist/client-N6zH1neq.js +1617 -0
- package/dist/command-format-9IsYy-9N.js +52 -0
- package/dist/command-format-B0bnyrEA.js +38 -0
- package/dist/command-format-n_udBm8l.js +52 -0
- package/dist/command-options-DL1PhuUF.js +33 -0
- package/dist/commands-Dpeoos11.js +230 -0
- package/dist/completion-cli-B5nR7jt8.js +434 -0
- package/dist/completion-cli-CZ8zPqPs.js +773 -0
- package/dist/config-DSpb2aMV.js +4916 -0
- package/dist/config-IwiWafT3.js +5657 -0
- package/dist/config-dQK4rbfx.js +4916 -0
- package/dist/config-guard-DwIb5Y-v.js +5719 -0
- package/dist/configure-7M9mLC4o.js +896 -0
- package/dist/configure-CivCcvkA.js +896 -0
- package/dist/constants-C2T4hQIk.js +65 -0
- package/dist/constants-DBvu3LzZ.js +65 -0
- package/dist/control-service-BXC31sNw.js +61 -0
- package/dist/control-service-lVzEzp9f.js +61 -0
- package/dist/control-ui/apple-touch-icon.png +0 -0
- package/dist/control-ui/assets/index-DQ-7PWhX.js +7553 -0
- package/dist/control-ui/assets/index-DQ-7PWhX.js.map +1 -0
- package/dist/control-ui/assets/index-nlpH70Eh.css +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-DS8ytfYQ.js +455 -0
- package/dist/cron-cli-Djb3HUdz.js +457 -0
- package/dist/daemon-cli-KoaJ2nJX.js +758 -0
- package/dist/daemon-cli-ZQIKLvAO.js +758 -0
- package/dist/daemon-runtime-CHWbAfKs.js +517 -0
- package/dist/daemon-runtime-DEjUQVjL.js +517 -0
- package/dist/deliver-DVRzRmNN.js +2557 -0
- package/dist/deliver-OfX6bSYR.js +2587 -0
- package/dist/deliver-sPBfRlXT.js +2587 -0
- package/dist/deps-BSdWD2wF.js +27 -0
- package/dist/deps-CZOfeWEp.js +27 -0
- package/dist/devices-cli-DHSpDnCS.js +207 -0
- package/dist/devices-cli-b9iF_uOi.js +205 -0
- package/dist/directory-cli-D0dTuAem.js +247 -0
- package/dist/directory-cli-qniSxsHo.js +245 -0
- package/dist/dispatcher-DA3u3CwV.js +160 -0
- package/dist/dns-cli-C0JUNb9O.js +201 -0
- package/dist/dns-cli-DwwMpMuN.js +199 -0
- package/dist/docs-cli-BlFHCHDz.js +161 -0
- package/dist/docs-cli-BpSPrY3Y.js +160 -0
- package/dist/doctor-Da1XgFcW.js +2584 -0
- package/dist/doctor-qrtookj-.js +2585 -0
- package/dist/entry.js +1156 -0
- package/dist/env-B2Cd_6IS.js +32 -0
- package/dist/errors--S5IAxQx.js +1952 -0
- package/dist/exec-CLQSz0CI.js +246 -0
- package/dist/exec-CW_QjkBi.js +246 -0
- package/dist/exec-D7I5LU33.js +1099 -0
- package/dist/exec-approvals-CuXem6Li.js +1043 -0
- package/dist/exec-approvals-P7vwSw4O.js +1043 -0
- package/dist/exec-approvals-cli-Csgqkksl.js +386 -0
- package/dist/exec-approvals-cli-Dk4yHE2L.js +388 -0
- package/dist/extensionAPI.js +64497 -0
- package/dist/format-B7OjpGnt.js +34 -0
- package/dist/format-Dv1wz41T.js +34 -0
- package/dist/gateway-cli-CJ7H2DgV.js +17352 -0
- package/dist/gateway-cli-CrKl-bIH.js +17352 -0
- package/dist/gateway-rpc--CH0NWWR.js +28 -0
- package/dist/gateway-rpc-BPfCU2Vi.js +28 -0
- package/dist/github-copilot-auth-CcPEEb3Q.js +1190 -0
- package/dist/github-copilot-auth-h3beCc_l.js +1190 -0
- package/dist/github-copilot-token-C1sArkX4.js +103 -0
- package/dist/github-copilot-token-DL6Pou2p.js +103 -0
- package/dist/github-copilot-token-hMl1wyZp.js +103 -0
- package/dist/gmail-setup-utils-CnVYPhaQ.js +428 -0
- package/dist/gmail-setup-utils-pZ9NnOvB.js +428 -0
- package/dist/health-format-BcsR5dtU.js +1211 -0
- package/dist/health-format-Pl8qK65t.js +1212 -0
- package/dist/help-format-BzWwbeSF.js +17 -0
- package/dist/help-format-CUnac_bT.js +17 -0
- package/dist/helpers-5yebzF4C.js +25 -0
- package/dist/helpers-CQI-5xS9.js +25 -0
- package/dist/helpers-CzQjTUbz.js +10 -0
- package/dist/helpers-OUt4hxkS.js +10 -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-BKHTdsn4.js +1058 -0
- package/dist/hooks-cli-zkLY25DX.js +1060 -0
- package/dist/hooks-status-BETsyuUR.js +443 -0
- package/dist/hooks-status-nPgxLL-x.js +443 -0
- package/dist/image-BFNcQzKp.js +629 -0
- package/dist/image-CC_YKDB-.js +1421 -0
- package/dist/image-DAsWVn7Q.js +629 -0
- package/dist/index.js +5900 -0
- package/dist/installs-Byb3s_8P.js +425 -0
- package/dist/installs-CELeuogN.js +425 -0
- package/dist/is-main-B6kCyqsv.js +25 -0
- package/dist/is-main-CBExsRNQ.js +25 -0
- package/dist/links-Brcj2Oc-.js +15 -0
- package/dist/links-cf9h8BXu.js +15 -0
- package/dist/loader-CU4bkeKe.js +61131 -0
- package/dist/logging-5MtSkLpb.js +1 -0
- package/dist/logging-BJRQDTME.js +15 -0
- package/dist/logging-CD55MXc7.js +15 -0
- package/dist/logging-kuFzZMsG.js +1 -0
- package/dist/login-qr-BCr2GKX6.js +475 -0
- package/dist/login-qr-BMbekoZW.js +478 -0
- package/dist/login-qr-HIPJAnbT.js +478 -0
- package/dist/logs-cli-CM7-XOcZ.js +230 -0
- package/dist/logs-cli-aqjT7oHu.js +228 -0
- package/dist/manager-C5m5qpB0.js +2871 -0
- package/dist/manager-CtGvmGvM.js +2872 -0
- package/dist/manager-DpZlm3gk.js +2870 -0
- package/dist/manifest-registry-BdTzIlta.js +669 -0
- package/dist/manifest-registry-DVQHMj0y.js +669 -0
- package/dist/message-channel-CfYBy4y3.js +110 -0
- package/dist/message-channel-CvHWS3C2.js +110 -0
- package/dist/model-selection-Av0fLq51.js +2940 -0
- package/dist/model-selection-DuI_Ue9Q.js +2691 -0
- package/dist/models-cli-C0JOZ5oP.js +2541 -0
- package/dist/models-cli-gmkzOpbq.js +2543 -0
- package/dist/net-D4G66Xui.js +137 -0
- package/dist/net-YrbuVTd2.js +137 -0
- package/dist/node-cli-BND9LLkM.js +1457 -0
- package/dist/node-cli-DNRB94ib.js +1459 -0
- package/dist/node-service-DTgDFo7M.js +67 -0
- package/dist/node-service-JEBcPQat.js +67 -0
- package/dist/nodes-cli-BCWlqHyR.js +1208 -0
- package/dist/nodes-cli-DWSo5dX7.js +1210 -0
- package/dist/nodes-screen-CMvShBEB.js +157 -0
- package/dist/nodes-screen-Cok3-EJw.js +157 -0
- package/dist/note-C5M2AQOP.js +73 -0
- package/dist/note-DEz9ZK7G.js +73 -0
- package/dist/onboard-channels-B75LjjVZ.js +671 -0
- package/dist/onboard-channels-DJz2TusQ.js +671 -0
- package/dist/onboard-skills-ByHkU9nx.js +3615 -0
- package/dist/onboard-skills-Wknr7pxR.js +3615 -0
- package/dist/onboarding-BejDjkx5.js +3455 -0
- package/dist/openclaw-root-YSGWCNem.js +84 -0
- package/dist/openclaw-root-_zPXSqgo.js +84 -0
- package/dist/pairing-cli-CFqD3IdI.js +122 -0
- package/dist/pairing-cli-Cn5vt4oI.js +120 -0
- package/dist/pairing-store-BHzy16_t.js +391 -0
- package/dist/pairing-store-BOhO49Bi.js +391 -0
- package/dist/parse-BZz5lHzQ.js +23 -0
- package/dist/parse-Bw0oH-rT.js +23 -0
- package/dist/parse-log-line-BxDgv4Uo.js +44 -0
- package/dist/parse-log-line-CUrpqe1w.js +44 -0
- package/dist/parse-timeout-D1XX_zN_.js +16 -0
- package/dist/parse-timeout-Du-wHHNi.js +16 -0
- package/dist/path-env-DQ-mM2ya.js +77 -0
- package/dist/path-env-eQ-HoQtS.js +77 -0
- package/dist/paths-C3yk0MGu.js +43 -0
- package/dist/paths-C90k-Dud.js +166 -0
- package/dist/paths-CGrNQEMk.js +201 -0
- package/dist/paths-D2ytuv-2.js +201 -0
- package/dist/paths-Dlp4VNXa.js +40 -0
- package/dist/paths-KUslkJRs.js +43 -0
- package/dist/pi-embedded-helpers-B7ARjDEK.js +1298 -0
- package/dist/pi-embedded-helpers-CQ9sq3Uu.js +8475 -0
- package/dist/pi-embedded-helpers-FPVRDeKf.js +1298 -0
- package/dist/pi-model-discovery-DWTTaAgY.js +20 -0
- package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
- package/dist/pi-model-discovery-EwKVHlZB.js +20 -0
- package/dist/pi-tools.policy-Du4RZy9R.js +230 -0
- package/dist/plugin-auto-enable-EBxTHjFJ.js +461 -0
- package/dist/plugin-auto-enable-RwRwIUKC.js +461 -0
- package/dist/plugin-sdk/index.d.ts +8453 -0
- package/dist/plugin-sdk/index.js +23445 -0
- package/dist/plugin-sdk/pi-model-discovery-Dw3A6oXH.js +37 -0
- package/dist/plugins-BI-p2ba9.js +495 -0
- package/dist/plugins-Dk4UBZwz.js +496 -0
- package/dist/plugins-cli-CMg0G56J.js +441 -0
- package/dist/plugins-cli-CX7QeUjq.js +443 -0
- package/dist/ports-nXmd4Efh.js +96 -0
- package/dist/program-EAMJAB_2.js +191 -0
- package/dist/progress-D-Oc-KAH.js +133 -0
- package/dist/progress-DTEUicRP.js +133 -0
- package/dist/prompt-style-BBlJlXtd.js +9 -0
- package/dist/prompt-style-BntC_Eoo.js +9 -0
- package/dist/prompts-C2D9_VZC.js +10 -0
- package/dist/prompts-FbZThK8w.js +10 -0
- package/dist/pw-ai-D2jD_dho.js +1651 -0
- package/dist/pw-ai-D6JUaD41.js +1650 -0
- package/dist/pw-ai-ba2bHPGA.js +1649 -0
- package/dist/qmd-manager-B-ijyM7o.js +615 -0
- package/dist/qmd-manager-C_Jah5eo.js +618 -0
- package/dist/qmd-manager-xo4abL0u.js +618 -0
- package/dist/redact-1PNP01B_.js +97 -0
- package/dist/redact-BIMJ3ntQ.js +94 -0
- package/dist/redact-CVRUv382.js +97 -0
- package/dist/register.subclis-CJGimm3-.js +348 -0
- package/dist/reply-DfepuqG0.js +61133 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-DkckwrRx.js +2410 -0
- package/dist/routes-Q42qtNl1.js +2410 -0
- package/dist/rpc-B4lvrGrD.js +95 -0
- package/dist/rpc-CbWcXAQK.js +95 -0
- package/dist/run-main-JFY3X4Xh.js +194 -0
- package/dist/sandbox-BGqDfFaH.js +2945 -0
- package/dist/sandbox-D_Tt3WRq.js +2945 -0
- package/dist/sandbox-cli-CaxqKiTq.js +461 -0
- package/dist/sandbox-cli-DA0Cbrzl.js +463 -0
- package/dist/security-cli-BZjA_GAD.js +508 -0
- package/dist/security-cli-Ct-pfF2h.js +506 -0
- package/dist/server-context-B9ez46MY.js +740 -0
- package/dist/server-context-C53lhEx_.js +740 -0
- package/dist/server-node-events-Cb6QOeDH.js +218 -0
- package/dist/server-node-events-DONmQvJg.js +216 -0
- package/dist/service-C0ccl5rU.js +680 -0
- package/dist/service-audit-AsnhO40e.js +542 -0
- package/dist/service-audit-BM-iyLL7.js +542 -0
- package/dist/service-mrQPgOXl.js +680 -0
- package/dist/session-cost-usage-B3HzifR9.js +692 -0
- package/dist/session-cost-usage-DH3c4xJA.js +692 -0
- package/dist/session-key-C-ig2pxJ.js +177 -0
- package/dist/session-key-CYpWeuht.js +177 -0
- package/dist/shared-CBcCIWC0.js +74 -0
- package/dist/shared-CtNMbLRE.js +150 -0
- package/dist/shared-DCh7fkR2.js +150 -0
- package/dist/shared-Na5zjEUc.js +74 -0
- package/dist/skill-scanner-AfOudYI1.js +255 -0
- package/dist/skill-scanner-BoGjHXUZ.js +255 -0
- package/dist/skills-7V483a6m.js +693 -0
- package/dist/skills-CsZRBUj0.js +694 -0
- package/dist/skills-cli-DQaq5LBX.js +290 -0
- package/dist/skills-cli-dVugbaAb.js +288 -0
- package/dist/skills-status-4_4zVBvV.js +187 -0
- package/dist/skills-status-cD4rfMR9.js +187 -0
- package/dist/sqlite-C4DljFNL.js +215 -0
- package/dist/sqlite-CvQzxS7q.js +197 -0
- package/dist/sqlite-Dnmf3LS7.js +215 -0
- package/dist/status-BakhDLuG.js +27 -0
- package/dist/status-BqtiImKF.js +21 -0
- package/dist/status-DHPz4Mg_.js +3364 -0
- package/dist/status-DSoYX3Ep.js +27 -0
- package/dist/status-Drziap9H.js +21 -0
- package/dist/subsystem-Btuh5yZj.js +834 -0
- package/dist/system-cli-CUQswQPX.js +83 -0
- package/dist/system-cli-Cz7in_Xr.js +81 -0
- package/dist/systemd-CFHiVC1D.js +438 -0
- package/dist/systemd-hints-CgQqk98i.js +19 -0
- package/dist/systemd-hints-DKVCFZS3.js +19 -0
- package/dist/systemd-kY3NnWdi.js +438 -0
- package/dist/systemd-linger-CFK5jDdq.js +75 -0
- package/dist/systemd-linger-CxBBzOjC.js +75 -0
- package/dist/table-DAOPkdc_.js +279 -0
- package/dist/table-DDQGlZSe.js +279 -0
- package/dist/tailnet-CZq_ZSNX.js +42 -0
- package/dist/tailnet-D5wOWpOX.js +42 -0
- package/dist/tailscale-BY0igR48.js +252 -0
- package/dist/tailscale-CCLcQalf.js +225 -0
- package/dist/tool-display-B2rS2o6B.js +795 -0
- package/dist/tool-display-Zbh1CRw5.js +795 -0
- package/dist/transcript-events-BOK6eOU8.js +17 -0
- package/dist/transcript-events-D2kT5WSz.js +17 -0
- package/dist/transcript-events-JLH5W4He.js +17 -0
- package/dist/tui-DFVs6pRO.js +2672 -0
- package/dist/tui-cli-CBKZVd1C.js +58 -0
- package/dist/tui-cli-DexeJOgZ.js +56 -0
- package/dist/tui-qPHLsB-x.js +2672 -0
- package/dist/update-B2q3duJD.js +317 -0
- package/dist/update-DNnej3C6.js +317 -0
- package/dist/update-cli-BPUtZjbl.js +1031 -0
- package/dist/update-cli-ehTYbpaU.js +1032 -0
- package/dist/update-runner-BfncKnU6.js +1375 -0
- package/dist/update-runner-DAeygRSU.js +1375 -0
- package/dist/usage-format-C4JfTbSp.js +36 -0
- package/dist/usage-format-DvowRSs-.js +36 -0
- package/dist/utils-7IMqr8vR.js +189 -0
- package/dist/utils-D7jskKIf.js +192 -0
- package/dist/wallet-manager-7KHKMCbT.js +264 -0
- package/dist/wallet-manager-CT1ykq2O.js +264 -0
- package/dist/webhooks-cli-C0CV-1jG.js +310 -0
- package/dist/webhooks-cli-DT16BygW.js +312 -0
- package/dist/widearea-dns-BJZTAyT3.js +127 -0
- package/dist/widearea-dns-Dk82I4Xa.js +127 -0
- package/dist/ws-6_dFpKWQ.js +13 -0
- package/dist/ws-D64QKPe6.js +13 -0
- package/dist/ws-log-BhQmGM0R.js +267 -0
- package/dist/ws-log-DsyLcTqD.js +267 -0
- package/dist/wsl-C24YfxH9.js +160 -0
- package/docs/.i18n/README.md +31 -0
- package/docs/.i18n/glossary.zh-CN.json +210 -0
- package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
- package/docs/CNAME +1 -0
- package/docs/assets/macos-onboarding/01-macos-warning.jpeg +0 -0
- package/docs/assets/macos-onboarding/02-local-networks.jpeg +0 -0
- package/docs/assets/macos-onboarding/03-security-notice.png +0 -0
- package/docs/assets/macos-onboarding/04-choose-gateway.png +0 -0
- package/docs/assets/macos-onboarding/05-permissions.png +0 -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/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 +476 -0
- package/docs/channels/feishu.md +577 -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 +769 -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 +70 -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 +202 -0
- package/docs/cli/health.md +21 -0
- package/docs/cli/hooks.md +304 -0
- package/docs/cli/index.md +1031 -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 +43 -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/features.md +53 -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 +204 -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 +1736 -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 +225 -0
- package/docs/gateway/configuration-examples.md +606 -0
- package/docs/gateway/configuration.md +3411 -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 +362 -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/network-model.md +17 -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 +129 -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 +2829 -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 +192 -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/exe-dev.md +126 -0
- package/docs/install/fly.md +486 -0
- package/docs/install/gcp.md +503 -0
- package/docs/install/hetzner.md +330 -0
- package/docs/install/index.md +187 -0
- package/docs/install/installer.md +123 -0
- package/docs/install/macos-vm.md +281 -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/northflank.mdx +53 -0
- package/docs/install/railway.mdx +99 -0
- package/docs/install/render.mdx +165 -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/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/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.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 +277 -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/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/credits.md +27 -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/reference/wizard.md +268 -0
- package/docs/scripts.md +28 -0
- package/docs/security/formal-verification.md +164 -0
- package/docs/start/bootstrapping.md +41 -0
- package/docs/start/docs-directory.md +64 -0
- package/docs/start/getting-started.md +120 -0
- package/docs/start/hubs.md +197 -0
- package/docs/start/lore.md +219 -0
- package/docs/start/onboarding.md +80 -0
- package/docs/start/openclaw.md +224 -0
- package/docs/start/pairing.md +86 -0
- package/docs/start/quickstart.md +22 -0
- package/docs/start/setup.md +162 -0
- package/docs/start/showcase.md +416 -0
- package/docs/start/wizard-cli-automation.md +141 -0
- package/docs/start/wizard-cli-reference.md +244 -0
- package/docs/start/wizard.md +108 -0
- package/docs/style.css +3 -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 +512 -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 +74 -0
- package/docs/tools/web.md +261 -0
- package/docs/tts.md +396 -0
- package/docs/tui.md +162 -0
- package/docs/vps.md +43 -0
- package/docs/web/control-ui.md +223 -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 +629 -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/features.md +59 -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/network-model.md +23 -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 +186 -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/exe-dev.md +127 -0
- package/docs/zh-CN/install/fly.md +490 -0
- package/docs/zh-CN/install/gcp.md +510 -0
- package/docs/zh-CN/install/hetzner.md +337 -0
- package/docs/zh-CN/install/index.md +193 -0
- package/docs/zh-CN/install/installer.md +128 -0
- package/docs/zh-CN/install/macos-vm.md +288 -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/northflank.mdx +60 -0
- package/docs/zh-CN/install/railway.mdx +106 -0
- package/docs/zh-CN/install/render.mdx +169 -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/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/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.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/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/credits.md +34 -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/scripts.md +35 -0
- package/docs/zh-CN/security/formal-verification.md +171 -0
- package/docs/zh-CN/start/docs-directory.md +70 -0
- package/docs/zh-CN/start/getting-started.md +206 -0
- package/docs/zh-CN/start/hubs.md +200 -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/quickstart.md +88 -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/blockchain/cryptoclaw.plugin.json +17 -0
- package/extensions/blockchain/index.ts +284 -0
- package/extensions/blockchain/node_modules/.bin/cryptoclaw +21 -0
- package/extensions/blockchain/node_modules/.bin/tsc +21 -0
- package/extensions/blockchain/node_modules/.bin/tsserver +21 -0
- package/extensions/blockchain/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/extensions/blockchain/package.json +16 -0
- package/extensions/blockchain/src/evm/chains.ts +150 -0
- package/extensions/blockchain/src/evm/services/abi/erc1155.ts +128 -0
- package/extensions/blockchain/src/evm/services/abi/erc20.ts +96 -0
- package/extensions/blockchain/src/evm/services/abi/erc721.ts +130 -0
- package/extensions/blockchain/src/evm/services/abi/erc8004-identity.ts +158 -0
- package/extensions/blockchain/src/evm/services/abi/erc8004-reputation.ts +120 -0
- package/extensions/blockchain/src/evm/services/abi/router-v2.ts +115 -0
- package/extensions/blockchain/src/evm/services/abi/router-v3.ts +81 -0
- package/extensions/blockchain/src/evm/services/agent-identity-config.test.ts +117 -0
- package/extensions/blockchain/src/evm/services/agent-identity-config.ts +75 -0
- package/extensions/blockchain/src/evm/services/agent-identity-store.ts +37 -0
- package/extensions/blockchain/src/evm/services/agent-identity.ts +262 -0
- package/extensions/blockchain/src/evm/services/balance.ts +76 -0
- package/extensions/blockchain/src/evm/services/blocks.ts +25 -0
- package/extensions/blockchain/src/evm/services/clients.ts +48 -0
- package/extensions/blockchain/src/evm/services/contracts.ts +52 -0
- package/extensions/blockchain/src/evm/services/dex-config.test.ts +145 -0
- package/extensions/blockchain/src/evm/services/dex-config.ts +164 -0
- package/extensions/blockchain/src/evm/services/ens.ts +27 -0
- package/extensions/blockchain/src/evm/services/security.test.ts +127 -0
- package/extensions/blockchain/src/evm/services/security.ts +110 -0
- package/extensions/blockchain/src/evm/services/swap.test.ts +204 -0
- package/extensions/blockchain/src/evm/services/swap.ts +534 -0
- package/extensions/blockchain/src/evm/services/tokens.ts +118 -0
- package/extensions/blockchain/src/evm/services/transactions.ts +54 -0
- package/extensions/blockchain/src/evm/services/transfer.ts +174 -0
- package/extensions/blockchain/src/evm/services/utils.ts +18 -0
- package/extensions/blockchain/src/evm/tools/block-tools.ts +34 -0
- package/extensions/blockchain/src/evm/tools/contract-tools.ts +138 -0
- package/extensions/blockchain/src/evm/tools/identity-tools.ts +305 -0
- package/extensions/blockchain/src/evm/tools/network-tools.ts +58 -0
- package/extensions/blockchain/src/evm/tools/nft-tools.ts +103 -0
- package/extensions/blockchain/src/evm/tools/security-tools.ts +38 -0
- package/extensions/blockchain/src/evm/tools/swap-tools.ts +314 -0
- package/extensions/blockchain/src/evm/tools/token-tools.ts +167 -0
- package/extensions/blockchain/src/evm/tools/tx-tools.ts +73 -0
- package/extensions/blockchain/src/evm/tools/wallet-tools.ts +196 -0
- package/extensions/blockchain/src/tx-gate/confirmation.ts +55 -0
- package/extensions/blockchain/src/tx-gate/spending-limits.ts +94 -0
- package/extensions/blockchain/src/wallet/active-wallet.ts +27 -0
- package/extensions/blockchain/src/wallet/key-guard.test.ts +156 -0
- package/extensions/blockchain/src/wallet/key-guard.ts +80 -0
- package/extensions/blockchain/src/wallet/keystore.ts +88 -0
- package/extensions/blockchain/src/wallet/wallet-manager.test.ts +215 -0
- package/extensions/blockchain/src/wallet/wallet-manager.ts +212 -0
- package/extensions/copilot-proxy/README.md +24 -0
- package/extensions/copilot-proxy/index.ts +149 -0
- package/extensions/copilot-proxy/node_modules/.bin/cryptoclaw +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/acorn +21 -0
- package/extensions/diagnostics-otel/node_modules/.bin/cryptoclaw +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 +227 -0
- package/extensions/diagnostics-otel/src/service.ts +635 -0
- package/extensions/discord/index.ts +17 -0
- package/extensions/discord/node_modules/.bin/cryptoclaw +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/imessage/index.ts +17 -0
- package/extensions/imessage/node_modules/.bin/cryptoclaw +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/memory-core/index.ts +38 -0
- package/extensions/memory-core/node_modules/.bin/cryptoclaw +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/arrow2csv +21 -0
- package/extensions/memory-lancedb/node_modules/.bin/cryptoclaw +21 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
- package/extensions/memory-lancedb/openclaw.plugin.json +60 -0
- package/extensions/memory-lancedb/package.json +19 -0
- package/extensions/nostr/CHANGELOG.md +80 -0
- package/extensions/nostr/README.md +136 -0
- package/extensions/nostr/index.ts +68 -0
- package/extensions/nostr/node_modules/.bin/cryptoclaw +21 -0
- package/extensions/nostr/node_modules/.bin/tsc +21 -0
- package/extensions/nostr/node_modules/.bin/tsserver +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/signal/index.ts +17 -0
- package/extensions/signal/node_modules/.bin/cryptoclaw +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/cryptoclaw +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/cryptoclaw +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/voice-call/CHANGELOG.md +115 -0
- package/extensions/voice-call/README.md +139 -0
- package/extensions/voice-call/index.ts +493 -0
- package/extensions/voice-call/node_modules/.bin/cryptoclaw +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 +224 -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/cryptoclaw +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/package.json +242 -0
- package/skills/aave-bsc/SKILL.md +55 -0
- package/skills/agent-identity/SKILL.md +48 -0
- package/skills/bird/SKILL.md +224 -0
- package/skills/canvas/SKILL.md +204 -0
- package/skills/coding-agent/SKILL.md +285 -0
- package/skills/coingecko/SKILL.md +114 -0
- package/skills/contract-deployer/SKILL.md +42 -0
- package/skills/debank/SKILL.md +143 -0
- package/skills/defi-dashboard/SKILL.md +49 -0
- package/skills/defillama/SKILL.md +117 -0
- package/skills/discord/SKILL.md +578 -0
- package/skills/dune/SKILL.md +178 -0
- package/skills/etherscan/SKILL.md +117 -0
- package/skills/four-meme/SKILL.md +80 -0
- package/skills/gas-tracker/SKILL.md +43 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/macro-calendar/SKILL.md +132 -0
- package/skills/market-data/SKILL.md +44 -0
- package/skills/nft-manager/SKILL.md +46 -0
- package/skills/portfolio-tracker/SKILL.md +55 -0
- package/skills/security-check/SKILL.md +153 -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/token-swap/SKILL.md +71 -0
- package/skills/wallet-manager/SKILL.md +65 -0
- package/skills/whale-watcher/SKILL.md +43 -0
|
@@ -0,0 +1,1952 @@
|
|
|
1
|
+
import { o as createSubsystemLogger } from "./entry.js";
|
|
2
|
+
import { t as formatCliCommand } from "./command-format-B0bnyrEA.js";
|
|
3
|
+
import { t as CONFIG_DIR } from "./utils-7IMqr8vR.js";
|
|
4
|
+
import { t as runCommandWithTimeout } from "./exec-CLQSz0CI.js";
|
|
5
|
+
import { t as rawDataToString } from "./ws-D64QKPe6.js";
|
|
6
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import { randomBytes } from "node:crypto";
|
|
11
|
+
import fs$1 from "node:fs/promises";
|
|
12
|
+
import { createServer } from "node:http";
|
|
13
|
+
import WebSocket, { WebSocketServer } from "ws";
|
|
14
|
+
import net from "node:net";
|
|
15
|
+
|
|
16
|
+
//#region src/browser/constants.ts
|
|
17
|
+
const DEFAULT_CRYPTOCLAW_BROWSER_ENABLED = true;
|
|
18
|
+
const DEFAULT_BROWSER_EVALUATE_ENABLED = true;
|
|
19
|
+
const DEFAULT_CRYPTOCLAW_BROWSER_COLOR = "#FF4500";
|
|
20
|
+
const DEFAULT_CRYPTOCLAW_BROWSER_PROFILE_NAME = "openclaw";
|
|
21
|
+
const DEFAULT_BROWSER_DEFAULT_PROFILE_NAME = "chrome";
|
|
22
|
+
const DEFAULT_AI_SNAPSHOT_MAX_CHARS = 8e4;
|
|
23
|
+
const DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS = 1e4;
|
|
24
|
+
const DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH = 6;
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/browser/extension-relay.ts
|
|
28
|
+
const RELAY_AUTH_HEADER = "x-openclaw-relay-token";
|
|
29
|
+
function headerValue(value) {
|
|
30
|
+
if (!value) return;
|
|
31
|
+
if (Array.isArray(value)) return value[0];
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function getHeader(req, name) {
|
|
35
|
+
return headerValue(req.headers[name.toLowerCase()]);
|
|
36
|
+
}
|
|
37
|
+
function isLoopbackHost$1(host) {
|
|
38
|
+
const h = host.trim().toLowerCase();
|
|
39
|
+
return h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0" || h === "[::1]" || h === "::1" || h === "[::]" || h === "::";
|
|
40
|
+
}
|
|
41
|
+
function isLoopbackAddress(ip) {
|
|
42
|
+
if (!ip) return false;
|
|
43
|
+
if (ip === "127.0.0.1") return true;
|
|
44
|
+
if (ip.startsWith("127.")) return true;
|
|
45
|
+
if (ip === "::1") return true;
|
|
46
|
+
if (ip.startsWith("::ffff:127.")) return true;
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
function parseBaseUrl(raw) {
|
|
50
|
+
const parsed = new URL(raw.trim().replace(/\/$/, ""));
|
|
51
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error(`extension relay cdpUrl must be http(s), got ${parsed.protocol}`);
|
|
52
|
+
const host = parsed.hostname;
|
|
53
|
+
const port = parsed.port?.trim() !== "" ? Number(parsed.port) : parsed.protocol === "https:" ? 443 : 80;
|
|
54
|
+
if (!Number.isFinite(port) || port <= 0 || port > 65535) throw new Error(`extension relay cdpUrl has invalid port: ${parsed.port || "(empty)"}`);
|
|
55
|
+
return {
|
|
56
|
+
host,
|
|
57
|
+
port,
|
|
58
|
+
baseUrl: parsed.toString().replace(/\/$/, "")
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function text(res, status, bodyText) {
|
|
62
|
+
const body = Buffer.from(bodyText);
|
|
63
|
+
res.write(`HTTP/1.1 ${status} ${status === 200 ? "OK" : "ERR"}\r\nContent-Type: text/plain; charset=utf-8\r
|
|
64
|
+
Content-Length: ${body.length}\r\nConnection: close\r
|
|
65
|
+
\r
|
|
66
|
+
`);
|
|
67
|
+
res.write(body);
|
|
68
|
+
res.end();
|
|
69
|
+
}
|
|
70
|
+
function rejectUpgrade(socket, status, bodyText) {
|
|
71
|
+
text(socket, status, bodyText);
|
|
72
|
+
try {
|
|
73
|
+
socket.destroy();
|
|
74
|
+
} catch {}
|
|
75
|
+
}
|
|
76
|
+
const serversByPort = /* @__PURE__ */ new Map();
|
|
77
|
+
const relayAuthByPort = /* @__PURE__ */ new Map();
|
|
78
|
+
function relayAuthTokenForUrl(url) {
|
|
79
|
+
try {
|
|
80
|
+
const parsed = new URL(url);
|
|
81
|
+
if (!isLoopbackHost$1(parsed.hostname)) return null;
|
|
82
|
+
const port = parsed.port?.trim() !== "" ? Number(parsed.port) : parsed.protocol === "https:" || parsed.protocol === "wss:" ? 443 : 80;
|
|
83
|
+
if (!Number.isFinite(port)) return null;
|
|
84
|
+
return relayAuthByPort.get(port) ?? null;
|
|
85
|
+
} catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function getChromeExtensionRelayAuthHeaders(url) {
|
|
90
|
+
const token = relayAuthTokenForUrl(url);
|
|
91
|
+
if (!token) return {};
|
|
92
|
+
return { [RELAY_AUTH_HEADER]: token };
|
|
93
|
+
}
|
|
94
|
+
async function ensureChromeExtensionRelayServer(opts) {
|
|
95
|
+
const info = parseBaseUrl(opts.cdpUrl);
|
|
96
|
+
if (!isLoopbackHost$1(info.host)) throw new Error(`extension relay requires loopback cdpUrl host (got ${info.host})`);
|
|
97
|
+
const existing = serversByPort.get(info.port);
|
|
98
|
+
if (existing) return existing;
|
|
99
|
+
let extensionWs = null;
|
|
100
|
+
const cdpClients = /* @__PURE__ */ new Set();
|
|
101
|
+
const connectedTargets = /* @__PURE__ */ new Map();
|
|
102
|
+
const pendingExtension = /* @__PURE__ */ new Map();
|
|
103
|
+
let nextExtensionId = 1;
|
|
104
|
+
const sendToExtension = async (payload) => {
|
|
105
|
+
const ws = extensionWs;
|
|
106
|
+
if (!ws || ws.readyState !== WebSocket.OPEN) throw new Error("Chrome extension not connected");
|
|
107
|
+
ws.send(JSON.stringify(payload));
|
|
108
|
+
return await new Promise((resolve, reject) => {
|
|
109
|
+
const timer = setTimeout(() => {
|
|
110
|
+
pendingExtension.delete(payload.id);
|
|
111
|
+
reject(/* @__PURE__ */ new Error(`extension request timeout: ${payload.params.method}`));
|
|
112
|
+
}, 3e4);
|
|
113
|
+
pendingExtension.set(payload.id, {
|
|
114
|
+
resolve,
|
|
115
|
+
reject,
|
|
116
|
+
timer
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const broadcastToCdpClients = (evt) => {
|
|
121
|
+
const msg = JSON.stringify(evt);
|
|
122
|
+
for (const ws of cdpClients) {
|
|
123
|
+
if (ws.readyState !== WebSocket.OPEN) continue;
|
|
124
|
+
ws.send(msg);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const sendResponseToCdp = (ws, res) => {
|
|
128
|
+
if (ws.readyState !== WebSocket.OPEN) return;
|
|
129
|
+
ws.send(JSON.stringify(res));
|
|
130
|
+
};
|
|
131
|
+
const ensureTargetEventsForClient = (ws, mode) => {
|
|
132
|
+
for (const target of connectedTargets.values()) if (mode === "autoAttach") ws.send(JSON.stringify({
|
|
133
|
+
method: "Target.attachedToTarget",
|
|
134
|
+
params: {
|
|
135
|
+
sessionId: target.sessionId,
|
|
136
|
+
targetInfo: {
|
|
137
|
+
...target.targetInfo,
|
|
138
|
+
attached: true
|
|
139
|
+
},
|
|
140
|
+
waitingForDebugger: false
|
|
141
|
+
}
|
|
142
|
+
}));
|
|
143
|
+
else ws.send(JSON.stringify({
|
|
144
|
+
method: "Target.targetCreated",
|
|
145
|
+
params: { targetInfo: {
|
|
146
|
+
...target.targetInfo,
|
|
147
|
+
attached: true
|
|
148
|
+
} }
|
|
149
|
+
}));
|
|
150
|
+
};
|
|
151
|
+
const routeCdpCommand = async (cmd) => {
|
|
152
|
+
switch (cmd.method) {
|
|
153
|
+
case "Browser.getVersion": return {
|
|
154
|
+
protocolVersion: "1.3",
|
|
155
|
+
product: "Chrome/CryptoClaw-Extension-Relay",
|
|
156
|
+
revision: "0",
|
|
157
|
+
userAgent: "CryptoClaw-Extension-Relay",
|
|
158
|
+
jsVersion: "V8"
|
|
159
|
+
};
|
|
160
|
+
case "Browser.setDownloadBehavior": return {};
|
|
161
|
+
case "Target.setAutoAttach":
|
|
162
|
+
case "Target.setDiscoverTargets": return {};
|
|
163
|
+
case "Target.getTargets": return { targetInfos: Array.from(connectedTargets.values()).map((t) => ({
|
|
164
|
+
...t.targetInfo,
|
|
165
|
+
attached: true
|
|
166
|
+
})) };
|
|
167
|
+
case "Target.getTargetInfo": {
|
|
168
|
+
const params = cmd.params ?? {};
|
|
169
|
+
const targetId = typeof params.targetId === "string" ? params.targetId : void 0;
|
|
170
|
+
if (targetId) {
|
|
171
|
+
for (const t of connectedTargets.values()) if (t.targetId === targetId) return { targetInfo: t.targetInfo };
|
|
172
|
+
}
|
|
173
|
+
if (cmd.sessionId && connectedTargets.has(cmd.sessionId)) {
|
|
174
|
+
const t = connectedTargets.get(cmd.sessionId);
|
|
175
|
+
if (t) return { targetInfo: t.targetInfo };
|
|
176
|
+
}
|
|
177
|
+
return { targetInfo: Array.from(connectedTargets.values())[0]?.targetInfo };
|
|
178
|
+
}
|
|
179
|
+
case "Target.attachToTarget": {
|
|
180
|
+
const params = cmd.params ?? {};
|
|
181
|
+
const targetId = typeof params.targetId === "string" ? params.targetId : void 0;
|
|
182
|
+
if (!targetId) throw new Error("targetId required");
|
|
183
|
+
for (const t of connectedTargets.values()) if (t.targetId === targetId) return { sessionId: t.sessionId };
|
|
184
|
+
throw new Error("target not found");
|
|
185
|
+
}
|
|
186
|
+
default: return await sendToExtension({
|
|
187
|
+
id: nextExtensionId++,
|
|
188
|
+
method: "forwardCDPCommand",
|
|
189
|
+
params: {
|
|
190
|
+
method: cmd.method,
|
|
191
|
+
sessionId: cmd.sessionId,
|
|
192
|
+
params: cmd.params
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const relayAuthToken = randomBytes(32).toString("base64url");
|
|
198
|
+
const server = createServer((req, res) => {
|
|
199
|
+
const path = new URL(req.url ?? "/", info.baseUrl).pathname;
|
|
200
|
+
if (path.startsWith("/json")) {
|
|
201
|
+
const token = getHeader(req, RELAY_AUTH_HEADER);
|
|
202
|
+
if (!token || token !== relayAuthToken) {
|
|
203
|
+
res.writeHead(401);
|
|
204
|
+
res.end("Unauthorized");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (req.method === "HEAD" && path === "/") {
|
|
209
|
+
res.writeHead(200);
|
|
210
|
+
res.end();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (path === "/") {
|
|
214
|
+
res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
|
|
215
|
+
res.end("OK");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (path === "/extension/status") {
|
|
219
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
220
|
+
res.end(JSON.stringify({ connected: Boolean(extensionWs) }));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const cdpWsUrl = `${`ws://${req.headers.host?.trim() || `${info.host}:${info.port}`}`}/cdp`;
|
|
224
|
+
if ((path === "/json/version" || path === "/json/version/") && (req.method === "GET" || req.method === "PUT")) {
|
|
225
|
+
const payload = {
|
|
226
|
+
Browser: "CryptoClaw/extension-relay",
|
|
227
|
+
"Protocol-Version": "1.3"
|
|
228
|
+
};
|
|
229
|
+
if (extensionWs) payload.webSocketDebuggerUrl = cdpWsUrl;
|
|
230
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
231
|
+
res.end(JSON.stringify(payload));
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (new Set([
|
|
235
|
+
"/json",
|
|
236
|
+
"/json/",
|
|
237
|
+
"/json/list",
|
|
238
|
+
"/json/list/"
|
|
239
|
+
]).has(path) && (req.method === "GET" || req.method === "PUT")) {
|
|
240
|
+
const list = Array.from(connectedTargets.values()).map((t) => ({
|
|
241
|
+
id: t.targetId,
|
|
242
|
+
type: t.targetInfo.type ?? "page",
|
|
243
|
+
title: t.targetInfo.title ?? "",
|
|
244
|
+
description: t.targetInfo.title ?? "",
|
|
245
|
+
url: t.targetInfo.url ?? "",
|
|
246
|
+
webSocketDebuggerUrl: cdpWsUrl,
|
|
247
|
+
devtoolsFrontendUrl: `/devtools/inspector.html?ws=${cdpWsUrl.replace("ws://", "")}`
|
|
248
|
+
}));
|
|
249
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
250
|
+
res.end(JSON.stringify(list));
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const activateMatch = path.match(/^\/json\/activate\/(.+)$/);
|
|
254
|
+
if (activateMatch && (req.method === "GET" || req.method === "PUT")) {
|
|
255
|
+
const targetId = decodeURIComponent(activateMatch[1] ?? "").trim();
|
|
256
|
+
if (!targetId) {
|
|
257
|
+
res.writeHead(400);
|
|
258
|
+
res.end("targetId required");
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
(async () => {
|
|
262
|
+
try {
|
|
263
|
+
await sendToExtension({
|
|
264
|
+
id: nextExtensionId++,
|
|
265
|
+
method: "forwardCDPCommand",
|
|
266
|
+
params: {
|
|
267
|
+
method: "Target.activateTarget",
|
|
268
|
+
params: { targetId }
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
} catch {}
|
|
272
|
+
})();
|
|
273
|
+
res.writeHead(200);
|
|
274
|
+
res.end("OK");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const closeMatch = path.match(/^\/json\/close\/(.+)$/);
|
|
278
|
+
if (closeMatch && (req.method === "GET" || req.method === "PUT")) {
|
|
279
|
+
const targetId = decodeURIComponent(closeMatch[1] ?? "").trim();
|
|
280
|
+
if (!targetId) {
|
|
281
|
+
res.writeHead(400);
|
|
282
|
+
res.end("targetId required");
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
(async () => {
|
|
286
|
+
try {
|
|
287
|
+
await sendToExtension({
|
|
288
|
+
id: nextExtensionId++,
|
|
289
|
+
method: "forwardCDPCommand",
|
|
290
|
+
params: {
|
|
291
|
+
method: "Target.closeTarget",
|
|
292
|
+
params: { targetId }
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
} catch {}
|
|
296
|
+
})();
|
|
297
|
+
res.writeHead(200);
|
|
298
|
+
res.end("OK");
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
res.writeHead(404);
|
|
302
|
+
res.end("not found");
|
|
303
|
+
});
|
|
304
|
+
const wssExtension = new WebSocketServer({ noServer: true });
|
|
305
|
+
const wssCdp = new WebSocketServer({ noServer: true });
|
|
306
|
+
server.on("upgrade", (req, socket, head) => {
|
|
307
|
+
const pathname = new URL(req.url ?? "/", info.baseUrl).pathname;
|
|
308
|
+
const remote = req.socket.remoteAddress;
|
|
309
|
+
if (!isLoopbackAddress(remote)) {
|
|
310
|
+
rejectUpgrade(socket, 403, "Forbidden");
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const origin = headerValue(req.headers.origin);
|
|
314
|
+
if (origin && !origin.startsWith("chrome-extension://")) {
|
|
315
|
+
rejectUpgrade(socket, 403, "Forbidden: invalid origin");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (pathname === "/extension") {
|
|
319
|
+
if (extensionWs) {
|
|
320
|
+
rejectUpgrade(socket, 409, "Extension already connected");
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
wssExtension.handleUpgrade(req, socket, head, (ws) => {
|
|
324
|
+
wssExtension.emit("connection", ws, req);
|
|
325
|
+
});
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
if (pathname === "/cdp") {
|
|
329
|
+
const token = getHeader(req, RELAY_AUTH_HEADER);
|
|
330
|
+
if (!token || token !== relayAuthToken) {
|
|
331
|
+
rejectUpgrade(socket, 401, "Unauthorized");
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (!extensionWs) {
|
|
335
|
+
rejectUpgrade(socket, 503, "Extension not connected");
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
wssCdp.handleUpgrade(req, socket, head, (ws) => {
|
|
339
|
+
wssCdp.emit("connection", ws, req);
|
|
340
|
+
});
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
rejectUpgrade(socket, 404, "Not Found");
|
|
344
|
+
});
|
|
345
|
+
wssExtension.on("connection", (ws) => {
|
|
346
|
+
extensionWs = ws;
|
|
347
|
+
const ping = setInterval(() => {
|
|
348
|
+
if (ws.readyState !== WebSocket.OPEN) return;
|
|
349
|
+
ws.send(JSON.stringify({ method: "ping" }));
|
|
350
|
+
}, 5e3);
|
|
351
|
+
ws.on("message", (data) => {
|
|
352
|
+
let parsed = null;
|
|
353
|
+
try {
|
|
354
|
+
parsed = JSON.parse(rawDataToString(data));
|
|
355
|
+
} catch {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (parsed && typeof parsed === "object" && "id" in parsed && typeof parsed.id === "number") {
|
|
359
|
+
const pending = pendingExtension.get(parsed.id);
|
|
360
|
+
if (!pending) return;
|
|
361
|
+
pendingExtension.delete(parsed.id);
|
|
362
|
+
clearTimeout(pending.timer);
|
|
363
|
+
if ("error" in parsed && typeof parsed.error === "string" && parsed.error.trim()) pending.reject(new Error(parsed.error));
|
|
364
|
+
else pending.resolve(parsed.result);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
if (parsed && typeof parsed === "object" && "method" in parsed) {
|
|
368
|
+
if (parsed.method === "pong") return;
|
|
369
|
+
if (parsed.method !== "forwardCDPEvent") return;
|
|
370
|
+
const evt = parsed;
|
|
371
|
+
const method = evt.params?.method;
|
|
372
|
+
const params = evt.params?.params;
|
|
373
|
+
const sessionId = evt.params?.sessionId;
|
|
374
|
+
if (!method || typeof method !== "string") return;
|
|
375
|
+
if (method === "Target.attachedToTarget") {
|
|
376
|
+
const attached = params ?? {};
|
|
377
|
+
if ((attached?.targetInfo?.type ?? "page") !== "page") return;
|
|
378
|
+
if (attached?.sessionId && attached?.targetInfo?.targetId) {
|
|
379
|
+
const prev = connectedTargets.get(attached.sessionId);
|
|
380
|
+
const nextTargetId = attached.targetInfo.targetId;
|
|
381
|
+
const prevTargetId = prev?.targetId;
|
|
382
|
+
const changedTarget = Boolean(prev && prevTargetId && prevTargetId !== nextTargetId);
|
|
383
|
+
connectedTargets.set(attached.sessionId, {
|
|
384
|
+
sessionId: attached.sessionId,
|
|
385
|
+
targetId: nextTargetId,
|
|
386
|
+
targetInfo: attached.targetInfo
|
|
387
|
+
});
|
|
388
|
+
if (changedTarget && prevTargetId) broadcastToCdpClients({
|
|
389
|
+
method: "Target.detachedFromTarget",
|
|
390
|
+
params: {
|
|
391
|
+
sessionId: attached.sessionId,
|
|
392
|
+
targetId: prevTargetId
|
|
393
|
+
},
|
|
394
|
+
sessionId: attached.sessionId
|
|
395
|
+
});
|
|
396
|
+
if (!prev || changedTarget) broadcastToCdpClients({
|
|
397
|
+
method,
|
|
398
|
+
params,
|
|
399
|
+
sessionId
|
|
400
|
+
});
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (method === "Target.detachedFromTarget") {
|
|
405
|
+
const detached = params ?? {};
|
|
406
|
+
if (detached?.sessionId) connectedTargets.delete(detached.sessionId);
|
|
407
|
+
broadcastToCdpClients({
|
|
408
|
+
method,
|
|
409
|
+
params,
|
|
410
|
+
sessionId
|
|
411
|
+
});
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (method === "Target.targetInfoChanged") {
|
|
415
|
+
const targetInfo = (params ?? {})?.targetInfo;
|
|
416
|
+
const targetId = targetInfo?.targetId;
|
|
417
|
+
if (targetId && (targetInfo?.type ?? "page") === "page") for (const [sid, target] of connectedTargets) {
|
|
418
|
+
if (target.targetId !== targetId) continue;
|
|
419
|
+
connectedTargets.set(sid, {
|
|
420
|
+
...target,
|
|
421
|
+
targetInfo: {
|
|
422
|
+
...target.targetInfo,
|
|
423
|
+
...targetInfo
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
broadcastToCdpClients({
|
|
429
|
+
method,
|
|
430
|
+
params,
|
|
431
|
+
sessionId
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
ws.on("close", () => {
|
|
436
|
+
clearInterval(ping);
|
|
437
|
+
extensionWs = null;
|
|
438
|
+
for (const [, pending] of pendingExtension) {
|
|
439
|
+
clearTimeout(pending.timer);
|
|
440
|
+
pending.reject(/* @__PURE__ */ new Error("extension disconnected"));
|
|
441
|
+
}
|
|
442
|
+
pendingExtension.clear();
|
|
443
|
+
connectedTargets.clear();
|
|
444
|
+
for (const client of cdpClients) try {
|
|
445
|
+
client.close(1011, "extension disconnected");
|
|
446
|
+
} catch {}
|
|
447
|
+
cdpClients.clear();
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
wssCdp.on("connection", (ws) => {
|
|
451
|
+
cdpClients.add(ws);
|
|
452
|
+
ws.on("message", async (data) => {
|
|
453
|
+
let cmd = null;
|
|
454
|
+
try {
|
|
455
|
+
cmd = JSON.parse(rawDataToString(data));
|
|
456
|
+
} catch {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (!cmd || typeof cmd !== "object") return;
|
|
460
|
+
if (typeof cmd.id !== "number" || typeof cmd.method !== "string") return;
|
|
461
|
+
if (!extensionWs) {
|
|
462
|
+
sendResponseToCdp(ws, {
|
|
463
|
+
id: cmd.id,
|
|
464
|
+
sessionId: cmd.sessionId,
|
|
465
|
+
error: { message: "Extension not connected" }
|
|
466
|
+
});
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
try {
|
|
470
|
+
const result = await routeCdpCommand(cmd);
|
|
471
|
+
if (cmd.method === "Target.setAutoAttach" && !cmd.sessionId) ensureTargetEventsForClient(ws, "autoAttach");
|
|
472
|
+
if (cmd.method === "Target.setDiscoverTargets") {
|
|
473
|
+
if ((cmd.params ?? {}).discover === true) ensureTargetEventsForClient(ws, "discover");
|
|
474
|
+
}
|
|
475
|
+
if (cmd.method === "Target.attachToTarget") {
|
|
476
|
+
const params = cmd.params ?? {};
|
|
477
|
+
const targetId = typeof params.targetId === "string" ? params.targetId : void 0;
|
|
478
|
+
if (targetId) {
|
|
479
|
+
const target = Array.from(connectedTargets.values()).find((t) => t.targetId === targetId);
|
|
480
|
+
if (target) ws.send(JSON.stringify({
|
|
481
|
+
method: "Target.attachedToTarget",
|
|
482
|
+
params: {
|
|
483
|
+
sessionId: target.sessionId,
|
|
484
|
+
targetInfo: {
|
|
485
|
+
...target.targetInfo,
|
|
486
|
+
attached: true
|
|
487
|
+
},
|
|
488
|
+
waitingForDebugger: false
|
|
489
|
+
}
|
|
490
|
+
}));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
sendResponseToCdp(ws, {
|
|
494
|
+
id: cmd.id,
|
|
495
|
+
sessionId: cmd.sessionId,
|
|
496
|
+
result
|
|
497
|
+
});
|
|
498
|
+
} catch (err) {
|
|
499
|
+
sendResponseToCdp(ws, {
|
|
500
|
+
id: cmd.id,
|
|
501
|
+
sessionId: cmd.sessionId,
|
|
502
|
+
error: { message: err instanceof Error ? err.message : String(err) }
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
ws.on("close", () => {
|
|
507
|
+
cdpClients.delete(ws);
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
await new Promise((resolve, reject) => {
|
|
511
|
+
server.listen(info.port, info.host, () => resolve());
|
|
512
|
+
server.once("error", reject);
|
|
513
|
+
});
|
|
514
|
+
const port = server.address()?.port ?? info.port;
|
|
515
|
+
const host = info.host;
|
|
516
|
+
const relay = {
|
|
517
|
+
host,
|
|
518
|
+
port,
|
|
519
|
+
baseUrl: `${new URL(info.baseUrl).protocol}//${host}:${port}`,
|
|
520
|
+
cdpWsUrl: `ws://${host}:${port}/cdp`,
|
|
521
|
+
extensionConnected: () => Boolean(extensionWs),
|
|
522
|
+
stop: async () => {
|
|
523
|
+
serversByPort.delete(port);
|
|
524
|
+
relayAuthByPort.delete(port);
|
|
525
|
+
try {
|
|
526
|
+
extensionWs?.close(1001, "server stopping");
|
|
527
|
+
} catch {}
|
|
528
|
+
for (const ws of cdpClients) try {
|
|
529
|
+
ws.close(1001, "server stopping");
|
|
530
|
+
} catch {}
|
|
531
|
+
await new Promise((resolve) => {
|
|
532
|
+
server.close(() => resolve());
|
|
533
|
+
});
|
|
534
|
+
wssExtension.close();
|
|
535
|
+
wssCdp.close();
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
relayAuthByPort.set(port, relayAuthToken);
|
|
539
|
+
serversByPort.set(port, relay);
|
|
540
|
+
return relay;
|
|
541
|
+
}
|
|
542
|
+
async function stopChromeExtensionRelayServer(opts) {
|
|
543
|
+
const info = parseBaseUrl(opts.cdpUrl);
|
|
544
|
+
const existing = serversByPort.get(info.port);
|
|
545
|
+
if (!existing) return false;
|
|
546
|
+
await existing.stop();
|
|
547
|
+
relayAuthByPort.delete(info.port);
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region src/browser/cdp.helpers.ts
|
|
553
|
+
function isLoopbackHost(host) {
|
|
554
|
+
const h = host.trim().toLowerCase();
|
|
555
|
+
return h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0" || h === "[::1]" || h === "::1" || h === "[::]" || h === "::";
|
|
556
|
+
}
|
|
557
|
+
function getHeadersWithAuth(url, headers = {}) {
|
|
558
|
+
const mergedHeaders = {
|
|
559
|
+
...getChromeExtensionRelayAuthHeaders(url),
|
|
560
|
+
...headers
|
|
561
|
+
};
|
|
562
|
+
try {
|
|
563
|
+
const parsed = new URL(url);
|
|
564
|
+
if (Object.keys(mergedHeaders).some((key) => key.toLowerCase() === "authorization")) return mergedHeaders;
|
|
565
|
+
if (parsed.username || parsed.password) {
|
|
566
|
+
const auth = Buffer.from(`${parsed.username}:${parsed.password}`).toString("base64");
|
|
567
|
+
return {
|
|
568
|
+
...mergedHeaders,
|
|
569
|
+
Authorization: `Basic ${auth}`
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
} catch {}
|
|
573
|
+
return mergedHeaders;
|
|
574
|
+
}
|
|
575
|
+
function appendCdpPath(cdpUrl, path) {
|
|
576
|
+
const url = new URL(cdpUrl);
|
|
577
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}${path.startsWith("/") ? path : `/${path}`}`;
|
|
578
|
+
return url.toString();
|
|
579
|
+
}
|
|
580
|
+
function createCdpSender(ws) {
|
|
581
|
+
let nextId = 1;
|
|
582
|
+
const pending = /* @__PURE__ */ new Map();
|
|
583
|
+
const send = (method, params) => {
|
|
584
|
+
const id = nextId++;
|
|
585
|
+
const msg = {
|
|
586
|
+
id,
|
|
587
|
+
method,
|
|
588
|
+
params
|
|
589
|
+
};
|
|
590
|
+
ws.send(JSON.stringify(msg));
|
|
591
|
+
return new Promise((resolve, reject) => {
|
|
592
|
+
pending.set(id, {
|
|
593
|
+
resolve,
|
|
594
|
+
reject
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
};
|
|
598
|
+
const closeWithError = (err) => {
|
|
599
|
+
for (const [, p] of pending) p.reject(err);
|
|
600
|
+
pending.clear();
|
|
601
|
+
try {
|
|
602
|
+
ws.close();
|
|
603
|
+
} catch {}
|
|
604
|
+
};
|
|
605
|
+
ws.on("message", (data) => {
|
|
606
|
+
try {
|
|
607
|
+
const parsed = JSON.parse(rawDataToString(data));
|
|
608
|
+
if (typeof parsed.id !== "number") return;
|
|
609
|
+
const p = pending.get(parsed.id);
|
|
610
|
+
if (!p) return;
|
|
611
|
+
pending.delete(parsed.id);
|
|
612
|
+
if (parsed.error?.message) {
|
|
613
|
+
p.reject(new Error(parsed.error.message));
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
p.resolve(parsed.result);
|
|
617
|
+
} catch {}
|
|
618
|
+
});
|
|
619
|
+
ws.on("close", () => {
|
|
620
|
+
closeWithError(/* @__PURE__ */ new Error("CDP socket closed"));
|
|
621
|
+
});
|
|
622
|
+
return {
|
|
623
|
+
send,
|
|
624
|
+
closeWithError
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
async function fetchJson(url, timeoutMs = 1500, init) {
|
|
628
|
+
const ctrl = new AbortController();
|
|
629
|
+
const t = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
630
|
+
try {
|
|
631
|
+
const headers = getHeadersWithAuth(url, init?.headers || {});
|
|
632
|
+
const res = await fetch(url, {
|
|
633
|
+
...init,
|
|
634
|
+
headers,
|
|
635
|
+
signal: ctrl.signal
|
|
636
|
+
});
|
|
637
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
638
|
+
return await res.json();
|
|
639
|
+
} finally {
|
|
640
|
+
clearTimeout(t);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
async function withCdpSocket(wsUrl, fn, opts) {
|
|
644
|
+
const headers = getHeadersWithAuth(wsUrl, opts?.headers ?? {});
|
|
645
|
+
const ws = new WebSocket(wsUrl, {
|
|
646
|
+
handshakeTimeout: 5e3,
|
|
647
|
+
...Object.keys(headers).length ? { headers } : {}
|
|
648
|
+
});
|
|
649
|
+
const { send, closeWithError } = createCdpSender(ws);
|
|
650
|
+
await new Promise((resolve, reject) => {
|
|
651
|
+
ws.once("open", () => resolve());
|
|
652
|
+
ws.once("error", (err) => reject(err));
|
|
653
|
+
});
|
|
654
|
+
try {
|
|
655
|
+
return await fn(send);
|
|
656
|
+
} catch (err) {
|
|
657
|
+
closeWithError(err instanceof Error ? err : new Error(String(err)));
|
|
658
|
+
throw err;
|
|
659
|
+
} finally {
|
|
660
|
+
try {
|
|
661
|
+
ws.close();
|
|
662
|
+
} catch {}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/browser/cdp.ts
|
|
668
|
+
function normalizeCdpWsUrl(wsUrl, cdpUrl) {
|
|
669
|
+
const ws = new URL(wsUrl);
|
|
670
|
+
const cdp = new URL(cdpUrl);
|
|
671
|
+
if (isLoopbackHost(ws.hostname) && !isLoopbackHost(cdp.hostname)) {
|
|
672
|
+
ws.hostname = cdp.hostname;
|
|
673
|
+
const cdpPort = cdp.port || (cdp.protocol === "https:" ? "443" : "80");
|
|
674
|
+
if (cdpPort) ws.port = cdpPort;
|
|
675
|
+
ws.protocol = cdp.protocol === "https:" ? "wss:" : "ws:";
|
|
676
|
+
}
|
|
677
|
+
if (cdp.protocol === "https:" && ws.protocol === "ws:") ws.protocol = "wss:";
|
|
678
|
+
if (!ws.username && !ws.password && (cdp.username || cdp.password)) {
|
|
679
|
+
ws.username = cdp.username;
|
|
680
|
+
ws.password = cdp.password;
|
|
681
|
+
}
|
|
682
|
+
for (const [key, value] of cdp.searchParams.entries()) if (!ws.searchParams.has(key)) ws.searchParams.append(key, value);
|
|
683
|
+
return ws.toString();
|
|
684
|
+
}
|
|
685
|
+
async function captureScreenshot(opts) {
|
|
686
|
+
return await withCdpSocket(opts.wsUrl, async (send) => {
|
|
687
|
+
await send("Page.enable");
|
|
688
|
+
let clip;
|
|
689
|
+
if (opts.fullPage) {
|
|
690
|
+
const metrics = await send("Page.getLayoutMetrics");
|
|
691
|
+
const size = metrics?.cssContentSize ?? metrics?.contentSize;
|
|
692
|
+
const width = Number(size?.width ?? 0);
|
|
693
|
+
const height = Number(size?.height ?? 0);
|
|
694
|
+
if (width > 0 && height > 0) clip = {
|
|
695
|
+
x: 0,
|
|
696
|
+
y: 0,
|
|
697
|
+
width,
|
|
698
|
+
height,
|
|
699
|
+
scale: 1
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
const format = opts.format ?? "png";
|
|
703
|
+
const quality = format === "jpeg" ? Math.max(0, Math.min(100, Math.round(opts.quality ?? 85))) : void 0;
|
|
704
|
+
const base64 = (await send("Page.captureScreenshot", {
|
|
705
|
+
format,
|
|
706
|
+
...quality !== void 0 ? { quality } : {},
|
|
707
|
+
fromSurface: true,
|
|
708
|
+
captureBeyondViewport: true,
|
|
709
|
+
...clip ? { clip } : {}
|
|
710
|
+
}))?.data;
|
|
711
|
+
if (!base64) throw new Error("Screenshot failed: missing data");
|
|
712
|
+
return Buffer.from(base64, "base64");
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
async function createTargetViaCdp(opts) {
|
|
716
|
+
const version = await fetchJson(appendCdpPath(opts.cdpUrl, "/json/version"), 1500);
|
|
717
|
+
const wsUrlRaw = String(version?.webSocketDebuggerUrl ?? "").trim();
|
|
718
|
+
const wsUrl = wsUrlRaw ? normalizeCdpWsUrl(wsUrlRaw, opts.cdpUrl) : "";
|
|
719
|
+
if (!wsUrl) throw new Error("CDP /json/version missing webSocketDebuggerUrl");
|
|
720
|
+
return await withCdpSocket(wsUrl, async (send) => {
|
|
721
|
+
const created = await send("Target.createTarget", { url: opts.url });
|
|
722
|
+
const targetId = String(created?.targetId ?? "").trim();
|
|
723
|
+
if (!targetId) throw new Error("CDP Target.createTarget returned no targetId");
|
|
724
|
+
return { targetId };
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
function axValue(v) {
|
|
728
|
+
if (!v || typeof v !== "object") return "";
|
|
729
|
+
const value = v.value;
|
|
730
|
+
if (typeof value === "string") return value;
|
|
731
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
732
|
+
return "";
|
|
733
|
+
}
|
|
734
|
+
function formatAriaSnapshot(nodes, limit) {
|
|
735
|
+
const byId = /* @__PURE__ */ new Map();
|
|
736
|
+
for (const n of nodes) if (n.nodeId) byId.set(n.nodeId, n);
|
|
737
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
738
|
+
for (const n of nodes) for (const c of n.childIds ?? []) referenced.add(c);
|
|
739
|
+
const root = nodes.find((n) => n.nodeId && !referenced.has(n.nodeId)) ?? nodes[0];
|
|
740
|
+
if (!root?.nodeId) return [];
|
|
741
|
+
const out = [];
|
|
742
|
+
const stack = [{
|
|
743
|
+
id: root.nodeId,
|
|
744
|
+
depth: 0
|
|
745
|
+
}];
|
|
746
|
+
while (stack.length && out.length < limit) {
|
|
747
|
+
const popped = stack.pop();
|
|
748
|
+
if (!popped) break;
|
|
749
|
+
const { id, depth } = popped;
|
|
750
|
+
const n = byId.get(id);
|
|
751
|
+
if (!n) continue;
|
|
752
|
+
const role = axValue(n.role);
|
|
753
|
+
const name = axValue(n.name);
|
|
754
|
+
const value = axValue(n.value);
|
|
755
|
+
const description = axValue(n.description);
|
|
756
|
+
const ref = `ax${out.length + 1}`;
|
|
757
|
+
out.push({
|
|
758
|
+
ref,
|
|
759
|
+
role: role || "unknown",
|
|
760
|
+
name: name || "",
|
|
761
|
+
...value ? { value } : {},
|
|
762
|
+
...description ? { description } : {},
|
|
763
|
+
...typeof n.backendDOMNodeId === "number" ? { backendDOMNodeId: n.backendDOMNodeId } : {},
|
|
764
|
+
depth
|
|
765
|
+
});
|
|
766
|
+
const children = (n.childIds ?? []).filter((c) => byId.has(c));
|
|
767
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
768
|
+
const child = children[i];
|
|
769
|
+
if (child) stack.push({
|
|
770
|
+
id: child,
|
|
771
|
+
depth: depth + 1
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return out;
|
|
776
|
+
}
|
|
777
|
+
async function snapshotAria(opts) {
|
|
778
|
+
const limit = Math.max(1, Math.min(2e3, Math.floor(opts.limit ?? 500)));
|
|
779
|
+
return await withCdpSocket(opts.wsUrl, async (send) => {
|
|
780
|
+
await send("Accessibility.enable").catch(() => {});
|
|
781
|
+
const res = await send("Accessibility.getFullAXTree");
|
|
782
|
+
return { nodes: formatAriaSnapshot(Array.isArray(res?.nodes) ? res.nodes : [], limit) };
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region src/infra/ports-format.ts
|
|
788
|
+
function classifyPortListener(listener, port) {
|
|
789
|
+
const raw = `${listener.commandLine ?? ""} ${listener.command ?? ""}`.trim().toLowerCase();
|
|
790
|
+
if (raw.includes("cryptoclaw") || raw.includes("openclaw")) return "gateway";
|
|
791
|
+
if (raw.includes("ssh")) {
|
|
792
|
+
const portToken = String(port);
|
|
793
|
+
const tunnelPattern = new RegExp(`-(l|r)\\s*${portToken}\\b|-(l|r)${portToken}\\b|:${portToken}\\b`);
|
|
794
|
+
if (!raw || tunnelPattern.test(raw)) return "ssh";
|
|
795
|
+
return "ssh";
|
|
796
|
+
}
|
|
797
|
+
return "unknown";
|
|
798
|
+
}
|
|
799
|
+
function buildPortHints(listeners, port) {
|
|
800
|
+
if (listeners.length === 0) return [];
|
|
801
|
+
const kinds = new Set(listeners.map((listener) => classifyPortListener(listener, port)));
|
|
802
|
+
const hints = [];
|
|
803
|
+
if (kinds.has("gateway")) hints.push(`Gateway already running locally. Stop it (${formatCliCommand("cryptoclaw gateway stop")}) or use a different port.`);
|
|
804
|
+
if (kinds.has("ssh")) hints.push("SSH tunnel already bound to this port. Close the tunnel or use a different local port in -L.");
|
|
805
|
+
if (kinds.has("unknown")) hints.push("Another process is listening on this port.");
|
|
806
|
+
if (listeners.length > 1) hints.push("Multiple listeners detected; ensure only one gateway/tunnel per port unless intentionally running isolated profiles.");
|
|
807
|
+
return hints;
|
|
808
|
+
}
|
|
809
|
+
function formatPortListener(listener) {
|
|
810
|
+
return `${listener.pid ? `pid ${listener.pid}` : "pid ?"}${listener.user ? ` ${listener.user}` : ""}: ${listener.commandLine || listener.command || "unknown"}${listener.address ? ` (${listener.address})` : ""}`;
|
|
811
|
+
}
|
|
812
|
+
function formatPortDiagnostics(diagnostics) {
|
|
813
|
+
if (diagnostics.status !== "busy") return [`Port ${diagnostics.port} is free.`];
|
|
814
|
+
const lines = [`Port ${diagnostics.port} is already in use.`];
|
|
815
|
+
for (const listener of diagnostics.listeners) lines.push(`- ${formatPortListener(listener)}`);
|
|
816
|
+
for (const hint of diagnostics.hints) lines.push(`- ${hint}`);
|
|
817
|
+
return lines;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
//#endregion
|
|
821
|
+
//#region src/infra/ports-lsof.ts
|
|
822
|
+
const LSOF_CANDIDATES = process.platform === "darwin" ? ["/usr/sbin/lsof", "/usr/bin/lsof"] : ["/usr/bin/lsof", "/usr/sbin/lsof"];
|
|
823
|
+
async function canExecute(path) {
|
|
824
|
+
try {
|
|
825
|
+
await fs$1.access(path, fs.constants.X_OK);
|
|
826
|
+
return true;
|
|
827
|
+
} catch {
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
async function resolveLsofCommand() {
|
|
832
|
+
for (const candidate of LSOF_CANDIDATES) if (await canExecute(candidate)) return candidate;
|
|
833
|
+
return "lsof";
|
|
834
|
+
}
|
|
835
|
+
function resolveLsofCommandSync() {
|
|
836
|
+
for (const candidate of LSOF_CANDIDATES) try {
|
|
837
|
+
fs.accessSync(candidate, fs.constants.X_OK);
|
|
838
|
+
return candidate;
|
|
839
|
+
} catch {}
|
|
840
|
+
return "lsof";
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
//#endregion
|
|
844
|
+
//#region src/infra/ports-inspect.ts
|
|
845
|
+
function isErrno$1(err) {
|
|
846
|
+
return Boolean(err && typeof err === "object" && "code" in err);
|
|
847
|
+
}
|
|
848
|
+
async function runCommandSafe(argv, timeoutMs = 5e3) {
|
|
849
|
+
try {
|
|
850
|
+
const res = await runCommandWithTimeout(argv, { timeoutMs });
|
|
851
|
+
return {
|
|
852
|
+
stdout: res.stdout,
|
|
853
|
+
stderr: res.stderr,
|
|
854
|
+
code: res.code ?? 1
|
|
855
|
+
};
|
|
856
|
+
} catch (err) {
|
|
857
|
+
return {
|
|
858
|
+
stdout: "",
|
|
859
|
+
stderr: "",
|
|
860
|
+
code: 1,
|
|
861
|
+
error: String(err)
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
function parseLsofFieldOutput(output) {
|
|
866
|
+
const lines = output.split(/\r?\n/).filter(Boolean);
|
|
867
|
+
const listeners = [];
|
|
868
|
+
let current = {};
|
|
869
|
+
for (const line of lines) if (line.startsWith("p")) {
|
|
870
|
+
if (current.pid || current.command) listeners.push(current);
|
|
871
|
+
const pid = Number.parseInt(line.slice(1), 10);
|
|
872
|
+
current = Number.isFinite(pid) ? { pid } : {};
|
|
873
|
+
} else if (line.startsWith("c")) current.command = line.slice(1);
|
|
874
|
+
else if (line.startsWith("n")) {
|
|
875
|
+
if (!current.address) current.address = line.slice(1);
|
|
876
|
+
}
|
|
877
|
+
if (current.pid || current.command) listeners.push(current);
|
|
878
|
+
return listeners;
|
|
879
|
+
}
|
|
880
|
+
async function resolveUnixCommandLine(pid) {
|
|
881
|
+
const res = await runCommandSafe([
|
|
882
|
+
"ps",
|
|
883
|
+
"-p",
|
|
884
|
+
String(pid),
|
|
885
|
+
"-o",
|
|
886
|
+
"command="
|
|
887
|
+
]);
|
|
888
|
+
if (res.code !== 0) return;
|
|
889
|
+
return res.stdout.trim() || void 0;
|
|
890
|
+
}
|
|
891
|
+
async function resolveUnixUser(pid) {
|
|
892
|
+
const res = await runCommandSafe([
|
|
893
|
+
"ps",
|
|
894
|
+
"-p",
|
|
895
|
+
String(pid),
|
|
896
|
+
"-o",
|
|
897
|
+
"user="
|
|
898
|
+
]);
|
|
899
|
+
if (res.code !== 0) return;
|
|
900
|
+
return res.stdout.trim() || void 0;
|
|
901
|
+
}
|
|
902
|
+
async function readUnixListeners(port) {
|
|
903
|
+
const errors = [];
|
|
904
|
+
const res = await runCommandSafe([
|
|
905
|
+
await resolveLsofCommand(),
|
|
906
|
+
"-nP",
|
|
907
|
+
`-iTCP:${port}`,
|
|
908
|
+
"-sTCP:LISTEN",
|
|
909
|
+
"-FpFcn"
|
|
910
|
+
]);
|
|
911
|
+
if (res.code === 0) {
|
|
912
|
+
const listeners = parseLsofFieldOutput(res.stdout);
|
|
913
|
+
await Promise.all(listeners.map(async (listener) => {
|
|
914
|
+
if (!listener.pid) return;
|
|
915
|
+
const [commandLine, user] = await Promise.all([resolveUnixCommandLine(listener.pid), resolveUnixUser(listener.pid)]);
|
|
916
|
+
if (commandLine) listener.commandLine = commandLine;
|
|
917
|
+
if (user) listener.user = user;
|
|
918
|
+
}));
|
|
919
|
+
return {
|
|
920
|
+
listeners,
|
|
921
|
+
detail: res.stdout.trim() || void 0,
|
|
922
|
+
errors
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
const stderr = res.stderr.trim();
|
|
926
|
+
if (res.code === 1 && !res.error && !stderr) return {
|
|
927
|
+
listeners: [],
|
|
928
|
+
detail: void 0,
|
|
929
|
+
errors
|
|
930
|
+
};
|
|
931
|
+
if (res.error) errors.push(res.error);
|
|
932
|
+
const detail = [stderr, res.stdout.trim()].filter(Boolean).join("\n");
|
|
933
|
+
if (detail) errors.push(detail);
|
|
934
|
+
return {
|
|
935
|
+
listeners: [],
|
|
936
|
+
detail: void 0,
|
|
937
|
+
errors
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
function parseNetstatListeners(output, port) {
|
|
941
|
+
const listeners = [];
|
|
942
|
+
const portToken = `:${port}`;
|
|
943
|
+
for (const rawLine of output.split(/\r?\n/)) {
|
|
944
|
+
const line = rawLine.trim();
|
|
945
|
+
if (!line) continue;
|
|
946
|
+
if (!line.toLowerCase().includes("listen")) continue;
|
|
947
|
+
if (!line.includes(portToken)) continue;
|
|
948
|
+
const parts = line.split(/\s+/);
|
|
949
|
+
if (parts.length < 4) continue;
|
|
950
|
+
const pidRaw = parts.at(-1);
|
|
951
|
+
const pid = pidRaw ? Number.parseInt(pidRaw, 10) : NaN;
|
|
952
|
+
const localAddr = parts[1];
|
|
953
|
+
const listener = {};
|
|
954
|
+
if (Number.isFinite(pid)) listener.pid = pid;
|
|
955
|
+
if (localAddr?.includes(portToken)) listener.address = localAddr;
|
|
956
|
+
listeners.push(listener);
|
|
957
|
+
}
|
|
958
|
+
return listeners;
|
|
959
|
+
}
|
|
960
|
+
async function resolveWindowsImageName(pid) {
|
|
961
|
+
const res = await runCommandSafe([
|
|
962
|
+
"tasklist",
|
|
963
|
+
"/FI",
|
|
964
|
+
`PID eq ${pid}`,
|
|
965
|
+
"/FO",
|
|
966
|
+
"LIST"
|
|
967
|
+
]);
|
|
968
|
+
if (res.code !== 0) return;
|
|
969
|
+
for (const rawLine of res.stdout.split(/\r?\n/)) {
|
|
970
|
+
const line = rawLine.trim();
|
|
971
|
+
if (!line.toLowerCase().startsWith("image name:")) continue;
|
|
972
|
+
return line.slice(11).trim() || void 0;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
async function resolveWindowsCommandLine(pid) {
|
|
976
|
+
const res = await runCommandSafe([
|
|
977
|
+
"wmic",
|
|
978
|
+
"process",
|
|
979
|
+
"where",
|
|
980
|
+
`ProcessId=${pid}`,
|
|
981
|
+
"get",
|
|
982
|
+
"CommandLine",
|
|
983
|
+
"/value"
|
|
984
|
+
]);
|
|
985
|
+
if (res.code !== 0) return;
|
|
986
|
+
for (const rawLine of res.stdout.split(/\r?\n/)) {
|
|
987
|
+
const line = rawLine.trim();
|
|
988
|
+
if (!line.toLowerCase().startsWith("commandline=")) continue;
|
|
989
|
+
return line.slice(12).trim() || void 0;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
async function readWindowsListeners(port) {
|
|
993
|
+
const errors = [];
|
|
994
|
+
const res = await runCommandSafe([
|
|
995
|
+
"netstat",
|
|
996
|
+
"-ano",
|
|
997
|
+
"-p",
|
|
998
|
+
"tcp"
|
|
999
|
+
]);
|
|
1000
|
+
if (res.code !== 0) {
|
|
1001
|
+
if (res.error) errors.push(res.error);
|
|
1002
|
+
const detail = [res.stderr.trim(), res.stdout.trim()].filter(Boolean).join("\n");
|
|
1003
|
+
if (detail) errors.push(detail);
|
|
1004
|
+
return {
|
|
1005
|
+
listeners: [],
|
|
1006
|
+
errors
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
const listeners = parseNetstatListeners(res.stdout, port);
|
|
1010
|
+
await Promise.all(listeners.map(async (listener) => {
|
|
1011
|
+
if (!listener.pid) return;
|
|
1012
|
+
const [imageName, commandLine] = await Promise.all([resolveWindowsImageName(listener.pid), resolveWindowsCommandLine(listener.pid)]);
|
|
1013
|
+
if (imageName) listener.command = imageName;
|
|
1014
|
+
if (commandLine) listener.commandLine = commandLine;
|
|
1015
|
+
}));
|
|
1016
|
+
return {
|
|
1017
|
+
listeners,
|
|
1018
|
+
detail: res.stdout.trim() || void 0,
|
|
1019
|
+
errors
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
async function tryListenOnHost(port, host) {
|
|
1023
|
+
try {
|
|
1024
|
+
await new Promise((resolve, reject) => {
|
|
1025
|
+
const tester = net.createServer().once("error", (err) => reject(err)).once("listening", () => {
|
|
1026
|
+
tester.close(() => resolve());
|
|
1027
|
+
}).listen({
|
|
1028
|
+
port,
|
|
1029
|
+
host,
|
|
1030
|
+
exclusive: true
|
|
1031
|
+
});
|
|
1032
|
+
});
|
|
1033
|
+
return "free";
|
|
1034
|
+
} catch (err) {
|
|
1035
|
+
if (isErrno$1(err) && err.code === "EADDRINUSE") return "busy";
|
|
1036
|
+
if (isErrno$1(err) && (err.code === "EADDRNOTAVAIL" || err.code === "EAFNOSUPPORT")) return "skip";
|
|
1037
|
+
return "unknown";
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
async function checkPortInUse(port) {
|
|
1041
|
+
const hosts = [
|
|
1042
|
+
"127.0.0.1",
|
|
1043
|
+
"0.0.0.0",
|
|
1044
|
+
"::1",
|
|
1045
|
+
"::"
|
|
1046
|
+
];
|
|
1047
|
+
let sawUnknown = false;
|
|
1048
|
+
for (const host of hosts) {
|
|
1049
|
+
const result = await tryListenOnHost(port, host);
|
|
1050
|
+
if (result === "busy") return "busy";
|
|
1051
|
+
if (result === "unknown") sawUnknown = true;
|
|
1052
|
+
}
|
|
1053
|
+
return sawUnknown ? "unknown" : "free";
|
|
1054
|
+
}
|
|
1055
|
+
async function inspectPortUsage(port) {
|
|
1056
|
+
const errors = [];
|
|
1057
|
+
const result = process.platform === "win32" ? await readWindowsListeners(port) : await readUnixListeners(port);
|
|
1058
|
+
errors.push(...result.errors);
|
|
1059
|
+
let listeners = result.listeners;
|
|
1060
|
+
let status = listeners.length > 0 ? "busy" : "unknown";
|
|
1061
|
+
if (listeners.length === 0) status = await checkPortInUse(port);
|
|
1062
|
+
if (status !== "busy") listeners = [];
|
|
1063
|
+
const hints = buildPortHints(listeners, port);
|
|
1064
|
+
if (status === "busy" && listeners.length === 0) hints.push("Port is in use but process details are unavailable (install lsof or run as an admin user).");
|
|
1065
|
+
return {
|
|
1066
|
+
port,
|
|
1067
|
+
status,
|
|
1068
|
+
listeners,
|
|
1069
|
+
hints,
|
|
1070
|
+
detail: result.detail,
|
|
1071
|
+
errors: errors.length > 0 ? errors : void 0
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region src/infra/ports.ts
|
|
1077
|
+
var PortInUseError = class extends Error {
|
|
1078
|
+
constructor(port, details) {
|
|
1079
|
+
super(`Port ${port} is already in use.`);
|
|
1080
|
+
this.name = "PortInUseError";
|
|
1081
|
+
this.port = port;
|
|
1082
|
+
this.details = details;
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
function isErrno(err) {
|
|
1086
|
+
return Boolean(err && typeof err === "object" && "code" in err);
|
|
1087
|
+
}
|
|
1088
|
+
async function describePortOwner(port) {
|
|
1089
|
+
const diagnostics = await inspectPortUsage(port);
|
|
1090
|
+
if (diagnostics.listeners.length === 0) return;
|
|
1091
|
+
return formatPortDiagnostics(diagnostics).join("\n");
|
|
1092
|
+
}
|
|
1093
|
+
async function ensurePortAvailable(port) {
|
|
1094
|
+
try {
|
|
1095
|
+
await new Promise((resolve, reject) => {
|
|
1096
|
+
const tester = net.createServer().once("error", (err) => reject(err)).once("listening", () => {
|
|
1097
|
+
tester.close(() => resolve());
|
|
1098
|
+
}).listen(port);
|
|
1099
|
+
});
|
|
1100
|
+
} catch (err) {
|
|
1101
|
+
if (isErrno(err) && err.code === "EADDRINUSE") throw new PortInUseError(port, await describePortOwner(port));
|
|
1102
|
+
throw err;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/browser/chrome.executables.ts
|
|
1108
|
+
const CHROMIUM_BUNDLE_IDS = new Set([
|
|
1109
|
+
"com.google.Chrome",
|
|
1110
|
+
"com.google.Chrome.beta",
|
|
1111
|
+
"com.google.Chrome.canary",
|
|
1112
|
+
"com.google.Chrome.dev",
|
|
1113
|
+
"com.brave.Browser",
|
|
1114
|
+
"com.brave.Browser.beta",
|
|
1115
|
+
"com.brave.Browser.nightly",
|
|
1116
|
+
"com.microsoft.Edge",
|
|
1117
|
+
"com.microsoft.EdgeBeta",
|
|
1118
|
+
"com.microsoft.EdgeDev",
|
|
1119
|
+
"com.microsoft.EdgeCanary",
|
|
1120
|
+
"org.chromium.Chromium",
|
|
1121
|
+
"com.vivaldi.Vivaldi",
|
|
1122
|
+
"com.operasoftware.Opera",
|
|
1123
|
+
"com.operasoftware.OperaGX",
|
|
1124
|
+
"com.yandex.desktop.yandex-browser",
|
|
1125
|
+
"company.thebrowser.Browser"
|
|
1126
|
+
]);
|
|
1127
|
+
const CHROMIUM_DESKTOP_IDS = new Set([
|
|
1128
|
+
"google-chrome.desktop",
|
|
1129
|
+
"google-chrome-beta.desktop",
|
|
1130
|
+
"google-chrome-unstable.desktop",
|
|
1131
|
+
"brave-browser.desktop",
|
|
1132
|
+
"microsoft-edge.desktop",
|
|
1133
|
+
"microsoft-edge-beta.desktop",
|
|
1134
|
+
"microsoft-edge-dev.desktop",
|
|
1135
|
+
"microsoft-edge-canary.desktop",
|
|
1136
|
+
"chromium.desktop",
|
|
1137
|
+
"chromium-browser.desktop",
|
|
1138
|
+
"vivaldi.desktop",
|
|
1139
|
+
"vivaldi-stable.desktop",
|
|
1140
|
+
"opera.desktop",
|
|
1141
|
+
"opera-gx.desktop",
|
|
1142
|
+
"yandex-browser.desktop",
|
|
1143
|
+
"org.chromium.Chromium.desktop"
|
|
1144
|
+
]);
|
|
1145
|
+
const CHROMIUM_EXE_NAMES = new Set([
|
|
1146
|
+
"chrome.exe",
|
|
1147
|
+
"msedge.exe",
|
|
1148
|
+
"brave.exe",
|
|
1149
|
+
"brave-browser.exe",
|
|
1150
|
+
"chromium.exe",
|
|
1151
|
+
"vivaldi.exe",
|
|
1152
|
+
"opera.exe",
|
|
1153
|
+
"launcher.exe",
|
|
1154
|
+
"yandex.exe",
|
|
1155
|
+
"yandexbrowser.exe",
|
|
1156
|
+
"google chrome",
|
|
1157
|
+
"google chrome canary",
|
|
1158
|
+
"brave browser",
|
|
1159
|
+
"microsoft edge",
|
|
1160
|
+
"chromium",
|
|
1161
|
+
"chrome",
|
|
1162
|
+
"brave",
|
|
1163
|
+
"msedge",
|
|
1164
|
+
"brave-browser",
|
|
1165
|
+
"google-chrome",
|
|
1166
|
+
"google-chrome-stable",
|
|
1167
|
+
"google-chrome-beta",
|
|
1168
|
+
"google-chrome-unstable",
|
|
1169
|
+
"microsoft-edge",
|
|
1170
|
+
"microsoft-edge-beta",
|
|
1171
|
+
"microsoft-edge-dev",
|
|
1172
|
+
"microsoft-edge-canary",
|
|
1173
|
+
"chromium-browser",
|
|
1174
|
+
"vivaldi",
|
|
1175
|
+
"vivaldi-stable",
|
|
1176
|
+
"opera",
|
|
1177
|
+
"opera-stable",
|
|
1178
|
+
"opera-gx",
|
|
1179
|
+
"yandex-browser"
|
|
1180
|
+
]);
|
|
1181
|
+
function exists$1(filePath) {
|
|
1182
|
+
try {
|
|
1183
|
+
return fs.existsSync(filePath);
|
|
1184
|
+
} catch {
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function execText(command, args, timeoutMs = 1200, maxBuffer = 1024 * 1024) {
|
|
1189
|
+
try {
|
|
1190
|
+
const output = execFileSync(command, args, {
|
|
1191
|
+
timeout: timeoutMs,
|
|
1192
|
+
encoding: "utf8",
|
|
1193
|
+
maxBuffer
|
|
1194
|
+
});
|
|
1195
|
+
return String(output ?? "").trim() || null;
|
|
1196
|
+
} catch {
|
|
1197
|
+
return null;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
function inferKindFromIdentifier(identifier) {
|
|
1201
|
+
const id = identifier.toLowerCase();
|
|
1202
|
+
if (id.includes("brave")) return "brave";
|
|
1203
|
+
if (id.includes("edge")) return "edge";
|
|
1204
|
+
if (id.includes("chromium")) return "chromium";
|
|
1205
|
+
if (id.includes("canary")) return "canary";
|
|
1206
|
+
if (id.includes("opera") || id.includes("vivaldi") || id.includes("yandex") || id.includes("thebrowser")) return "chromium";
|
|
1207
|
+
return "chrome";
|
|
1208
|
+
}
|
|
1209
|
+
function inferKindFromExecutableName(name) {
|
|
1210
|
+
const lower = name.toLowerCase();
|
|
1211
|
+
if (lower.includes("brave")) return "brave";
|
|
1212
|
+
if (lower.includes("edge") || lower.includes("msedge")) return "edge";
|
|
1213
|
+
if (lower.includes("chromium")) return "chromium";
|
|
1214
|
+
if (lower.includes("canary") || lower.includes("sxs")) return "canary";
|
|
1215
|
+
if (lower.includes("opera") || lower.includes("vivaldi") || lower.includes("yandex")) return "chromium";
|
|
1216
|
+
return "chrome";
|
|
1217
|
+
}
|
|
1218
|
+
function detectDefaultChromiumExecutable(platform) {
|
|
1219
|
+
if (platform === "darwin") return detectDefaultChromiumExecutableMac();
|
|
1220
|
+
if (platform === "linux") return detectDefaultChromiumExecutableLinux();
|
|
1221
|
+
if (platform === "win32") return detectDefaultChromiumExecutableWindows();
|
|
1222
|
+
return null;
|
|
1223
|
+
}
|
|
1224
|
+
function detectDefaultChromiumExecutableMac() {
|
|
1225
|
+
const bundleId = detectDefaultBrowserBundleIdMac();
|
|
1226
|
+
if (!bundleId || !CHROMIUM_BUNDLE_IDS.has(bundleId)) return null;
|
|
1227
|
+
const appPathRaw = execText("/usr/bin/osascript", ["-e", `POSIX path of (path to application id "${bundleId}")`]);
|
|
1228
|
+
if (!appPathRaw) return null;
|
|
1229
|
+
const appPath = appPathRaw.trim().replace(/\/$/, "");
|
|
1230
|
+
const exeName = execText("/usr/bin/defaults", [
|
|
1231
|
+
"read",
|
|
1232
|
+
path.join(appPath, "Contents", "Info"),
|
|
1233
|
+
"CFBundleExecutable"
|
|
1234
|
+
]);
|
|
1235
|
+
if (!exeName) return null;
|
|
1236
|
+
const exePath = path.join(appPath, "Contents", "MacOS", exeName.trim());
|
|
1237
|
+
if (!exists$1(exePath)) return null;
|
|
1238
|
+
return {
|
|
1239
|
+
kind: inferKindFromIdentifier(bundleId),
|
|
1240
|
+
path: exePath
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
function detectDefaultBrowserBundleIdMac() {
|
|
1244
|
+
const plistPath = path.join(os.homedir(), "Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist");
|
|
1245
|
+
if (!exists$1(plistPath)) return null;
|
|
1246
|
+
const handlersRaw = execText("/usr/bin/plutil", [
|
|
1247
|
+
"-extract",
|
|
1248
|
+
"LSHandlers",
|
|
1249
|
+
"json",
|
|
1250
|
+
"-o",
|
|
1251
|
+
"-",
|
|
1252
|
+
"--",
|
|
1253
|
+
plistPath
|
|
1254
|
+
], 2e3, 5 * 1024 * 1024);
|
|
1255
|
+
if (!handlersRaw) return null;
|
|
1256
|
+
let handlers;
|
|
1257
|
+
try {
|
|
1258
|
+
handlers = JSON.parse(handlersRaw);
|
|
1259
|
+
} catch {
|
|
1260
|
+
return null;
|
|
1261
|
+
}
|
|
1262
|
+
if (!Array.isArray(handlers)) return null;
|
|
1263
|
+
const resolveScheme = (scheme) => {
|
|
1264
|
+
let candidate = null;
|
|
1265
|
+
for (const entry of handlers) {
|
|
1266
|
+
if (!entry || typeof entry !== "object") continue;
|
|
1267
|
+
const record = entry;
|
|
1268
|
+
if (record.LSHandlerURLScheme !== scheme) continue;
|
|
1269
|
+
const role = typeof record.LSHandlerRoleAll === "string" && record.LSHandlerRoleAll || typeof record.LSHandlerRoleViewer === "string" && record.LSHandlerRoleViewer || null;
|
|
1270
|
+
if (role) candidate = role;
|
|
1271
|
+
}
|
|
1272
|
+
return candidate;
|
|
1273
|
+
};
|
|
1274
|
+
return resolveScheme("http") ?? resolveScheme("https");
|
|
1275
|
+
}
|
|
1276
|
+
function detectDefaultChromiumExecutableLinux() {
|
|
1277
|
+
const desktopId = execText("xdg-settings", ["get", "default-web-browser"]) || execText("xdg-mime", [
|
|
1278
|
+
"query",
|
|
1279
|
+
"default",
|
|
1280
|
+
"x-scheme-handler/http"
|
|
1281
|
+
]);
|
|
1282
|
+
if (!desktopId) return null;
|
|
1283
|
+
const trimmed = desktopId.trim();
|
|
1284
|
+
if (!CHROMIUM_DESKTOP_IDS.has(trimmed)) return null;
|
|
1285
|
+
const desktopPath = findDesktopFilePath(trimmed);
|
|
1286
|
+
if (!desktopPath) return null;
|
|
1287
|
+
const execLine = readDesktopExecLine(desktopPath);
|
|
1288
|
+
if (!execLine) return null;
|
|
1289
|
+
const command = extractExecutableFromExecLine(execLine);
|
|
1290
|
+
if (!command) return null;
|
|
1291
|
+
const resolved = resolveLinuxExecutablePath(command);
|
|
1292
|
+
if (!resolved) return null;
|
|
1293
|
+
const exeName = path.posix.basename(resolved).toLowerCase();
|
|
1294
|
+
if (!CHROMIUM_EXE_NAMES.has(exeName)) return null;
|
|
1295
|
+
return {
|
|
1296
|
+
kind: inferKindFromExecutableName(exeName),
|
|
1297
|
+
path: resolved
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
function detectDefaultChromiumExecutableWindows() {
|
|
1301
|
+
const progId = readWindowsProgId();
|
|
1302
|
+
const command = (progId ? readWindowsCommandForProgId(progId) : null) || readWindowsCommandForProgId("http");
|
|
1303
|
+
if (!command) return null;
|
|
1304
|
+
const exePath = extractWindowsExecutablePath(expandWindowsEnvVars(command));
|
|
1305
|
+
if (!exePath) return null;
|
|
1306
|
+
if (!exists$1(exePath)) return null;
|
|
1307
|
+
const exeName = path.win32.basename(exePath).toLowerCase();
|
|
1308
|
+
if (!CHROMIUM_EXE_NAMES.has(exeName)) return null;
|
|
1309
|
+
return {
|
|
1310
|
+
kind: inferKindFromExecutableName(exeName),
|
|
1311
|
+
path: exePath
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
function findDesktopFilePath(desktopId) {
|
|
1315
|
+
const candidates = [
|
|
1316
|
+
path.join(os.homedir(), ".local", "share", "applications", desktopId),
|
|
1317
|
+
path.join("/usr/local/share/applications", desktopId),
|
|
1318
|
+
path.join("/usr/share/applications", desktopId),
|
|
1319
|
+
path.join("/var/lib/snapd/desktop/applications", desktopId)
|
|
1320
|
+
];
|
|
1321
|
+
for (const candidate of candidates) if (exists$1(candidate)) return candidate;
|
|
1322
|
+
return null;
|
|
1323
|
+
}
|
|
1324
|
+
function readDesktopExecLine(desktopPath) {
|
|
1325
|
+
try {
|
|
1326
|
+
const lines = fs.readFileSync(desktopPath, "utf8").split(/\r?\n/);
|
|
1327
|
+
for (const line of lines) if (line.startsWith("Exec=")) return line.slice(5).trim();
|
|
1328
|
+
} catch {}
|
|
1329
|
+
return null;
|
|
1330
|
+
}
|
|
1331
|
+
function extractExecutableFromExecLine(execLine) {
|
|
1332
|
+
const tokens = splitExecLine(execLine);
|
|
1333
|
+
for (const token of tokens) {
|
|
1334
|
+
if (!token) continue;
|
|
1335
|
+
if (token === "env") continue;
|
|
1336
|
+
if (token.includes("=") && !token.startsWith("/") && !token.includes("\\")) continue;
|
|
1337
|
+
return token.replace(/^["']|["']$/g, "");
|
|
1338
|
+
}
|
|
1339
|
+
return null;
|
|
1340
|
+
}
|
|
1341
|
+
function splitExecLine(line) {
|
|
1342
|
+
const tokens = [];
|
|
1343
|
+
let current = "";
|
|
1344
|
+
let inQuotes = false;
|
|
1345
|
+
let quoteChar = "";
|
|
1346
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
1347
|
+
const ch = line[i];
|
|
1348
|
+
if ((ch === "\"" || ch === "'") && (!inQuotes || ch === quoteChar)) {
|
|
1349
|
+
if (inQuotes) {
|
|
1350
|
+
inQuotes = false;
|
|
1351
|
+
quoteChar = "";
|
|
1352
|
+
} else {
|
|
1353
|
+
inQuotes = true;
|
|
1354
|
+
quoteChar = ch;
|
|
1355
|
+
}
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
if (!inQuotes && /\s/.test(ch)) {
|
|
1359
|
+
if (current) {
|
|
1360
|
+
tokens.push(current);
|
|
1361
|
+
current = "";
|
|
1362
|
+
}
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
current += ch;
|
|
1366
|
+
}
|
|
1367
|
+
if (current) tokens.push(current);
|
|
1368
|
+
return tokens;
|
|
1369
|
+
}
|
|
1370
|
+
function resolveLinuxExecutablePath(command) {
|
|
1371
|
+
const cleaned = command.trim().replace(/%[a-zA-Z]/g, "");
|
|
1372
|
+
if (!cleaned) return null;
|
|
1373
|
+
if (cleaned.startsWith("/")) return cleaned;
|
|
1374
|
+
const resolved = execText("which", [cleaned], 800);
|
|
1375
|
+
return resolved ? resolved.trim() : null;
|
|
1376
|
+
}
|
|
1377
|
+
function readWindowsProgId() {
|
|
1378
|
+
const output = execText("reg", [
|
|
1379
|
+
"query",
|
|
1380
|
+
"HKCU\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
1381
|
+
"/v",
|
|
1382
|
+
"ProgId"
|
|
1383
|
+
]);
|
|
1384
|
+
if (!output) return null;
|
|
1385
|
+
return output.match(/ProgId\s+REG_\w+\s+(.+)$/im)?.[1]?.trim() || null;
|
|
1386
|
+
}
|
|
1387
|
+
function readWindowsCommandForProgId(progId) {
|
|
1388
|
+
const output = execText("reg", [
|
|
1389
|
+
"query",
|
|
1390
|
+
progId === "http" ? "HKCR\\http\\shell\\open\\command" : `HKCR\\${progId}\\shell\\open\\command`,
|
|
1391
|
+
"/ve"
|
|
1392
|
+
]);
|
|
1393
|
+
if (!output) return null;
|
|
1394
|
+
return output.match(/REG_\w+\s+(.+)$/im)?.[1]?.trim() || null;
|
|
1395
|
+
}
|
|
1396
|
+
function expandWindowsEnvVars(value) {
|
|
1397
|
+
return value.replace(/%([^%]+)%/g, (_match, name) => {
|
|
1398
|
+
const key = String(name ?? "").trim();
|
|
1399
|
+
return key ? process.env[key] ?? `%${key}%` : _match;
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
function extractWindowsExecutablePath(command) {
|
|
1403
|
+
const quoted = command.match(/"([^"]+\\.exe)"/i);
|
|
1404
|
+
if (quoted?.[1]) return quoted[1];
|
|
1405
|
+
const unquoted = command.match(/([^\\s]+\\.exe)/i);
|
|
1406
|
+
if (unquoted?.[1]) return unquoted[1];
|
|
1407
|
+
return null;
|
|
1408
|
+
}
|
|
1409
|
+
function findFirstExecutable(candidates) {
|
|
1410
|
+
for (const candidate of candidates) if (exists$1(candidate.path)) return candidate;
|
|
1411
|
+
return null;
|
|
1412
|
+
}
|
|
1413
|
+
function findChromeExecutableMac() {
|
|
1414
|
+
return findFirstExecutable([
|
|
1415
|
+
{
|
|
1416
|
+
kind: "chrome",
|
|
1417
|
+
path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
kind: "chrome",
|
|
1421
|
+
path: path.join(os.homedir(), "Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
kind: "brave",
|
|
1425
|
+
path: "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
kind: "brave",
|
|
1429
|
+
path: path.join(os.homedir(), "Applications/Brave Browser.app/Contents/MacOS/Brave Browser")
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
kind: "edge",
|
|
1433
|
+
path: "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
kind: "edge",
|
|
1437
|
+
path: path.join(os.homedir(), "Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge")
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
kind: "chromium",
|
|
1441
|
+
path: "/Applications/Chromium.app/Contents/MacOS/Chromium"
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
kind: "chromium",
|
|
1445
|
+
path: path.join(os.homedir(), "Applications/Chromium.app/Contents/MacOS/Chromium")
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
kind: "canary",
|
|
1449
|
+
path: "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
kind: "canary",
|
|
1453
|
+
path: path.join(os.homedir(), "Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary")
|
|
1454
|
+
}
|
|
1455
|
+
]);
|
|
1456
|
+
}
|
|
1457
|
+
function findChromeExecutableLinux() {
|
|
1458
|
+
return findFirstExecutable([
|
|
1459
|
+
{
|
|
1460
|
+
kind: "chrome",
|
|
1461
|
+
path: "/usr/bin/google-chrome"
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
kind: "chrome",
|
|
1465
|
+
path: "/usr/bin/google-chrome-stable"
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
kind: "chrome",
|
|
1469
|
+
path: "/usr/bin/chrome"
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
kind: "brave",
|
|
1473
|
+
path: "/usr/bin/brave-browser"
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
kind: "brave",
|
|
1477
|
+
path: "/usr/bin/brave-browser-stable"
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
kind: "brave",
|
|
1481
|
+
path: "/usr/bin/brave"
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
kind: "brave",
|
|
1485
|
+
path: "/snap/bin/brave"
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
kind: "edge",
|
|
1489
|
+
path: "/usr/bin/microsoft-edge"
|
|
1490
|
+
},
|
|
1491
|
+
{
|
|
1492
|
+
kind: "edge",
|
|
1493
|
+
path: "/usr/bin/microsoft-edge-stable"
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
kind: "chromium",
|
|
1497
|
+
path: "/usr/bin/chromium"
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
kind: "chromium",
|
|
1501
|
+
path: "/usr/bin/chromium-browser"
|
|
1502
|
+
},
|
|
1503
|
+
{
|
|
1504
|
+
kind: "chromium",
|
|
1505
|
+
path: "/snap/bin/chromium"
|
|
1506
|
+
}
|
|
1507
|
+
]);
|
|
1508
|
+
}
|
|
1509
|
+
function findChromeExecutableWindows() {
|
|
1510
|
+
const localAppData = process.env.LOCALAPPDATA ?? "";
|
|
1511
|
+
const programFiles = process.env.ProgramFiles ?? "C:\\Program Files";
|
|
1512
|
+
const programFilesX86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
1513
|
+
const joinWin = path.win32.join;
|
|
1514
|
+
const candidates = [];
|
|
1515
|
+
if (localAppData) {
|
|
1516
|
+
candidates.push({
|
|
1517
|
+
kind: "chrome",
|
|
1518
|
+
path: joinWin(localAppData, "Google", "Chrome", "Application", "chrome.exe")
|
|
1519
|
+
});
|
|
1520
|
+
candidates.push({
|
|
1521
|
+
kind: "brave",
|
|
1522
|
+
path: joinWin(localAppData, "BraveSoftware", "Brave-Browser", "Application", "brave.exe")
|
|
1523
|
+
});
|
|
1524
|
+
candidates.push({
|
|
1525
|
+
kind: "edge",
|
|
1526
|
+
path: joinWin(localAppData, "Microsoft", "Edge", "Application", "msedge.exe")
|
|
1527
|
+
});
|
|
1528
|
+
candidates.push({
|
|
1529
|
+
kind: "chromium",
|
|
1530
|
+
path: joinWin(localAppData, "Chromium", "Application", "chrome.exe")
|
|
1531
|
+
});
|
|
1532
|
+
candidates.push({
|
|
1533
|
+
kind: "canary",
|
|
1534
|
+
path: joinWin(localAppData, "Google", "Chrome SxS", "Application", "chrome.exe")
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
candidates.push({
|
|
1538
|
+
kind: "chrome",
|
|
1539
|
+
path: joinWin(programFiles, "Google", "Chrome", "Application", "chrome.exe")
|
|
1540
|
+
});
|
|
1541
|
+
candidates.push({
|
|
1542
|
+
kind: "chrome",
|
|
1543
|
+
path: joinWin(programFilesX86, "Google", "Chrome", "Application", "chrome.exe")
|
|
1544
|
+
});
|
|
1545
|
+
candidates.push({
|
|
1546
|
+
kind: "brave",
|
|
1547
|
+
path: joinWin(programFiles, "BraveSoftware", "Brave-Browser", "Application", "brave.exe")
|
|
1548
|
+
});
|
|
1549
|
+
candidates.push({
|
|
1550
|
+
kind: "brave",
|
|
1551
|
+
path: joinWin(programFilesX86, "BraveSoftware", "Brave-Browser", "Application", "brave.exe")
|
|
1552
|
+
});
|
|
1553
|
+
candidates.push({
|
|
1554
|
+
kind: "edge",
|
|
1555
|
+
path: joinWin(programFiles, "Microsoft", "Edge", "Application", "msedge.exe")
|
|
1556
|
+
});
|
|
1557
|
+
candidates.push({
|
|
1558
|
+
kind: "edge",
|
|
1559
|
+
path: joinWin(programFilesX86, "Microsoft", "Edge", "Application", "msedge.exe")
|
|
1560
|
+
});
|
|
1561
|
+
return findFirstExecutable(candidates);
|
|
1562
|
+
}
|
|
1563
|
+
function resolveBrowserExecutableForPlatform(resolved, platform) {
|
|
1564
|
+
if (resolved.executablePath) {
|
|
1565
|
+
if (!exists$1(resolved.executablePath)) throw new Error(`browser.executablePath not found: ${resolved.executablePath}`);
|
|
1566
|
+
return {
|
|
1567
|
+
kind: "custom",
|
|
1568
|
+
path: resolved.executablePath
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
const detected = detectDefaultChromiumExecutable(platform);
|
|
1572
|
+
if (detected) return detected;
|
|
1573
|
+
if (platform === "darwin") return findChromeExecutableMac();
|
|
1574
|
+
if (platform === "linux") return findChromeExecutableLinux();
|
|
1575
|
+
if (platform === "win32") return findChromeExecutableWindows();
|
|
1576
|
+
return null;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
//#endregion
|
|
1580
|
+
//#region src/browser/chrome.profile-decoration.ts
|
|
1581
|
+
function decoratedMarkerPath(userDataDir) {
|
|
1582
|
+
return path.join(userDataDir, ".openclaw-profile-decorated");
|
|
1583
|
+
}
|
|
1584
|
+
function safeReadJson(filePath) {
|
|
1585
|
+
try {
|
|
1586
|
+
if (!fs.existsSync(filePath)) return null;
|
|
1587
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
1588
|
+
const parsed = JSON.parse(raw);
|
|
1589
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
|
|
1590
|
+
return parsed;
|
|
1591
|
+
} catch {
|
|
1592
|
+
return null;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
function safeWriteJson(filePath, data) {
|
|
1596
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
1597
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
|
1598
|
+
}
|
|
1599
|
+
function setDeep(obj, keys, value) {
|
|
1600
|
+
let node = obj;
|
|
1601
|
+
for (const key of keys.slice(0, -1)) {
|
|
1602
|
+
const next = node[key];
|
|
1603
|
+
if (typeof next !== "object" || next === null || Array.isArray(next)) node[key] = {};
|
|
1604
|
+
node = node[key];
|
|
1605
|
+
}
|
|
1606
|
+
node[keys[keys.length - 1] ?? ""] = value;
|
|
1607
|
+
}
|
|
1608
|
+
function parseHexRgbToSignedArgbInt(hex) {
|
|
1609
|
+
const cleaned = hex.trim().replace(/^#/, "");
|
|
1610
|
+
if (!/^[0-9a-fA-F]{6}$/.test(cleaned)) return null;
|
|
1611
|
+
const argbUnsigned = 255 << 24 | Number.parseInt(cleaned, 16);
|
|
1612
|
+
return argbUnsigned > 2147483647 ? argbUnsigned - 4294967296 : argbUnsigned;
|
|
1613
|
+
}
|
|
1614
|
+
function isProfileDecorated(userDataDir, desiredName, desiredColorHex) {
|
|
1615
|
+
const desiredColorInt = parseHexRgbToSignedArgbInt(desiredColorHex);
|
|
1616
|
+
const localStatePath = path.join(userDataDir, "Local State");
|
|
1617
|
+
const preferencesPath = path.join(userDataDir, "Default", "Preferences");
|
|
1618
|
+
const profile = safeReadJson(localStatePath)?.profile;
|
|
1619
|
+
const infoCache = typeof profile === "object" && profile !== null && !Array.isArray(profile) ? profile.info_cache : null;
|
|
1620
|
+
const info = typeof infoCache === "object" && infoCache !== null && !Array.isArray(infoCache) && typeof infoCache.Default === "object" && infoCache.Default !== null && !Array.isArray(infoCache.Default) ? infoCache.Default : null;
|
|
1621
|
+
const prefs = safeReadJson(preferencesPath);
|
|
1622
|
+
const browserTheme = (() => {
|
|
1623
|
+
const browser = prefs?.browser;
|
|
1624
|
+
const theme = typeof browser === "object" && browser !== null && !Array.isArray(browser) ? browser.theme : null;
|
|
1625
|
+
return typeof theme === "object" && theme !== null && !Array.isArray(theme) ? theme : null;
|
|
1626
|
+
})();
|
|
1627
|
+
const autogeneratedTheme = (() => {
|
|
1628
|
+
const autogenerated = prefs?.autogenerated;
|
|
1629
|
+
const theme = typeof autogenerated === "object" && autogenerated !== null && !Array.isArray(autogenerated) ? autogenerated.theme : null;
|
|
1630
|
+
return typeof theme === "object" && theme !== null && !Array.isArray(theme) ? theme : null;
|
|
1631
|
+
})();
|
|
1632
|
+
const nameOk = typeof info?.name === "string" ? info.name === desiredName : true;
|
|
1633
|
+
if (desiredColorInt == null) return nameOk;
|
|
1634
|
+
const localSeedOk = typeof info?.profile_color_seed === "number" ? info.profile_color_seed === desiredColorInt : false;
|
|
1635
|
+
const prefOk = typeof browserTheme?.user_color2 === "number" && browserTheme.user_color2 === desiredColorInt || typeof autogeneratedTheme?.color === "number" && autogeneratedTheme.color === desiredColorInt;
|
|
1636
|
+
return nameOk && localSeedOk && prefOk;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Best-effort profile decoration (name + lobster-orange). Chrome preference keys
|
|
1640
|
+
* vary by version; we keep this conservative and idempotent.
|
|
1641
|
+
*/
|
|
1642
|
+
function decorateOpenClawProfile(userDataDir, opts) {
|
|
1643
|
+
const desiredName = opts?.name ?? DEFAULT_CRYPTOCLAW_BROWSER_PROFILE_NAME;
|
|
1644
|
+
const desiredColor = (opts?.color ?? DEFAULT_CRYPTOCLAW_BROWSER_COLOR).toUpperCase();
|
|
1645
|
+
const desiredColorInt = parseHexRgbToSignedArgbInt(desiredColor);
|
|
1646
|
+
const localStatePath = path.join(userDataDir, "Local State");
|
|
1647
|
+
const preferencesPath = path.join(userDataDir, "Default", "Preferences");
|
|
1648
|
+
const localState = safeReadJson(localStatePath) ?? {};
|
|
1649
|
+
setDeep(localState, [
|
|
1650
|
+
"profile",
|
|
1651
|
+
"info_cache",
|
|
1652
|
+
"Default",
|
|
1653
|
+
"name"
|
|
1654
|
+
], desiredName);
|
|
1655
|
+
setDeep(localState, [
|
|
1656
|
+
"profile",
|
|
1657
|
+
"info_cache",
|
|
1658
|
+
"Default",
|
|
1659
|
+
"shortcut_name"
|
|
1660
|
+
], desiredName);
|
|
1661
|
+
setDeep(localState, [
|
|
1662
|
+
"profile",
|
|
1663
|
+
"info_cache",
|
|
1664
|
+
"Default",
|
|
1665
|
+
"user_name"
|
|
1666
|
+
], desiredName);
|
|
1667
|
+
setDeep(localState, [
|
|
1668
|
+
"profile",
|
|
1669
|
+
"info_cache",
|
|
1670
|
+
"Default",
|
|
1671
|
+
"profile_color"
|
|
1672
|
+
], desiredColor);
|
|
1673
|
+
setDeep(localState, [
|
|
1674
|
+
"profile",
|
|
1675
|
+
"info_cache",
|
|
1676
|
+
"Default",
|
|
1677
|
+
"user_color"
|
|
1678
|
+
], desiredColor);
|
|
1679
|
+
if (desiredColorInt != null) {
|
|
1680
|
+
setDeep(localState, [
|
|
1681
|
+
"profile",
|
|
1682
|
+
"info_cache",
|
|
1683
|
+
"Default",
|
|
1684
|
+
"profile_color_seed"
|
|
1685
|
+
], desiredColorInt);
|
|
1686
|
+
setDeep(localState, [
|
|
1687
|
+
"profile",
|
|
1688
|
+
"info_cache",
|
|
1689
|
+
"Default",
|
|
1690
|
+
"profile_highlight_color"
|
|
1691
|
+
], desiredColorInt);
|
|
1692
|
+
setDeep(localState, [
|
|
1693
|
+
"profile",
|
|
1694
|
+
"info_cache",
|
|
1695
|
+
"Default",
|
|
1696
|
+
"default_avatar_fill_color"
|
|
1697
|
+
], desiredColorInt);
|
|
1698
|
+
setDeep(localState, [
|
|
1699
|
+
"profile",
|
|
1700
|
+
"info_cache",
|
|
1701
|
+
"Default",
|
|
1702
|
+
"default_avatar_stroke_color"
|
|
1703
|
+
], desiredColorInt);
|
|
1704
|
+
}
|
|
1705
|
+
safeWriteJson(localStatePath, localState);
|
|
1706
|
+
const prefs = safeReadJson(preferencesPath) ?? {};
|
|
1707
|
+
setDeep(prefs, ["profile", "name"], desiredName);
|
|
1708
|
+
setDeep(prefs, ["profile", "profile_color"], desiredColor);
|
|
1709
|
+
setDeep(prefs, ["profile", "user_color"], desiredColor);
|
|
1710
|
+
if (desiredColorInt != null) {
|
|
1711
|
+
setDeep(prefs, [
|
|
1712
|
+
"autogenerated",
|
|
1713
|
+
"theme",
|
|
1714
|
+
"color"
|
|
1715
|
+
], desiredColorInt);
|
|
1716
|
+
setDeep(prefs, [
|
|
1717
|
+
"browser",
|
|
1718
|
+
"theme",
|
|
1719
|
+
"user_color2"
|
|
1720
|
+
], desiredColorInt);
|
|
1721
|
+
}
|
|
1722
|
+
safeWriteJson(preferencesPath, prefs);
|
|
1723
|
+
try {
|
|
1724
|
+
fs.writeFileSync(decoratedMarkerPath(userDataDir), `${Date.now()}\n`, "utf-8");
|
|
1725
|
+
} catch {}
|
|
1726
|
+
}
|
|
1727
|
+
function ensureProfileCleanExit(userDataDir) {
|
|
1728
|
+
const preferencesPath = path.join(userDataDir, "Default", "Preferences");
|
|
1729
|
+
const prefs = safeReadJson(preferencesPath) ?? {};
|
|
1730
|
+
setDeep(prefs, ["exit_type"], "Normal");
|
|
1731
|
+
setDeep(prefs, ["exited_cleanly"], true);
|
|
1732
|
+
safeWriteJson(preferencesPath, prefs);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
//#endregion
|
|
1736
|
+
//#region src/browser/chrome.ts
|
|
1737
|
+
const log = createSubsystemLogger("browser").child("chrome");
|
|
1738
|
+
function exists(filePath) {
|
|
1739
|
+
try {
|
|
1740
|
+
return fs.existsSync(filePath);
|
|
1741
|
+
} catch {
|
|
1742
|
+
return false;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
function resolveBrowserExecutable(resolved) {
|
|
1746
|
+
return resolveBrowserExecutableForPlatform(resolved, process.platform);
|
|
1747
|
+
}
|
|
1748
|
+
function resolveOpenClawUserDataDir(profileName = DEFAULT_CRYPTOCLAW_BROWSER_PROFILE_NAME) {
|
|
1749
|
+
return path.join(CONFIG_DIR, "browser", profileName, "user-data");
|
|
1750
|
+
}
|
|
1751
|
+
function cdpUrlForPort(cdpPort) {
|
|
1752
|
+
return `http://127.0.0.1:${cdpPort}`;
|
|
1753
|
+
}
|
|
1754
|
+
async function isChromeReachable(cdpUrl, timeoutMs = 500) {
|
|
1755
|
+
const version = await fetchChromeVersion(cdpUrl, timeoutMs);
|
|
1756
|
+
return Boolean(version);
|
|
1757
|
+
}
|
|
1758
|
+
async function fetchChromeVersion(cdpUrl, timeoutMs = 500) {
|
|
1759
|
+
const ctrl = new AbortController();
|
|
1760
|
+
const t = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
1761
|
+
try {
|
|
1762
|
+
const versionUrl = appendCdpPath(cdpUrl, "/json/version");
|
|
1763
|
+
const res = await fetch(versionUrl, {
|
|
1764
|
+
signal: ctrl.signal,
|
|
1765
|
+
headers: getHeadersWithAuth(versionUrl)
|
|
1766
|
+
});
|
|
1767
|
+
if (!res.ok) return null;
|
|
1768
|
+
const data = await res.json();
|
|
1769
|
+
if (!data || typeof data !== "object") return null;
|
|
1770
|
+
return data;
|
|
1771
|
+
} catch {
|
|
1772
|
+
return null;
|
|
1773
|
+
} finally {
|
|
1774
|
+
clearTimeout(t);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
async function getChromeWebSocketUrl(cdpUrl, timeoutMs = 500) {
|
|
1778
|
+
const version = await fetchChromeVersion(cdpUrl, timeoutMs);
|
|
1779
|
+
const wsUrl = String(version?.webSocketDebuggerUrl ?? "").trim();
|
|
1780
|
+
if (!wsUrl) return null;
|
|
1781
|
+
return normalizeCdpWsUrl(wsUrl, cdpUrl);
|
|
1782
|
+
}
|
|
1783
|
+
async function canOpenWebSocket(wsUrl, timeoutMs = 800) {
|
|
1784
|
+
return await new Promise((resolve) => {
|
|
1785
|
+
const headers = getHeadersWithAuth(wsUrl);
|
|
1786
|
+
const ws = new WebSocket(wsUrl, {
|
|
1787
|
+
handshakeTimeout: timeoutMs,
|
|
1788
|
+
...Object.keys(headers).length ? { headers } : {}
|
|
1789
|
+
});
|
|
1790
|
+
const timer = setTimeout(() => {
|
|
1791
|
+
try {
|
|
1792
|
+
ws.terminate();
|
|
1793
|
+
} catch {}
|
|
1794
|
+
resolve(false);
|
|
1795
|
+
}, Math.max(50, timeoutMs + 25));
|
|
1796
|
+
ws.once("open", () => {
|
|
1797
|
+
clearTimeout(timer);
|
|
1798
|
+
try {
|
|
1799
|
+
ws.close();
|
|
1800
|
+
} catch {}
|
|
1801
|
+
resolve(true);
|
|
1802
|
+
});
|
|
1803
|
+
ws.once("error", () => {
|
|
1804
|
+
clearTimeout(timer);
|
|
1805
|
+
resolve(false);
|
|
1806
|
+
});
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
async function isChromeCdpReady(cdpUrl, timeoutMs = 500, handshakeTimeoutMs = 800) {
|
|
1810
|
+
const wsUrl = await getChromeWebSocketUrl(cdpUrl, timeoutMs);
|
|
1811
|
+
if (!wsUrl) return false;
|
|
1812
|
+
return await canOpenWebSocket(wsUrl, handshakeTimeoutMs);
|
|
1813
|
+
}
|
|
1814
|
+
async function launchOpenClawChrome(resolved, profile) {
|
|
1815
|
+
if (!profile.cdpIsLoopback) throw new Error(`Profile "${profile.name}" is remote; cannot launch local Chrome.`);
|
|
1816
|
+
await ensurePortAvailable(profile.cdpPort);
|
|
1817
|
+
const exe = resolveBrowserExecutable(resolved);
|
|
1818
|
+
if (!exe) throw new Error("No supported browser found (Chrome/Brave/Edge/Chromium on macOS, Linux, or Windows).");
|
|
1819
|
+
const userDataDir = resolveOpenClawUserDataDir(profile.name);
|
|
1820
|
+
fs.mkdirSync(userDataDir, { recursive: true });
|
|
1821
|
+
const needsDecorate = !isProfileDecorated(userDataDir, profile.name, (profile.color ?? DEFAULT_CRYPTOCLAW_BROWSER_COLOR).toUpperCase());
|
|
1822
|
+
const spawnOnce = () => {
|
|
1823
|
+
const args = [
|
|
1824
|
+
`--remote-debugging-port=${profile.cdpPort}`,
|
|
1825
|
+
`--user-data-dir=${userDataDir}`,
|
|
1826
|
+
"--no-first-run",
|
|
1827
|
+
"--no-default-browser-check",
|
|
1828
|
+
"--disable-sync",
|
|
1829
|
+
"--disable-background-networking",
|
|
1830
|
+
"--disable-component-update",
|
|
1831
|
+
"--disable-features=Translate,MediaRouter",
|
|
1832
|
+
"--disable-session-crashed-bubble",
|
|
1833
|
+
"--hide-crash-restore-bubble",
|
|
1834
|
+
"--password-store=basic"
|
|
1835
|
+
];
|
|
1836
|
+
if (resolved.headless) {
|
|
1837
|
+
args.push("--headless=new");
|
|
1838
|
+
args.push("--disable-gpu");
|
|
1839
|
+
}
|
|
1840
|
+
if (resolved.noSandbox) {
|
|
1841
|
+
args.push("--no-sandbox");
|
|
1842
|
+
args.push("--disable-setuid-sandbox");
|
|
1843
|
+
}
|
|
1844
|
+
if (process.platform === "linux") args.push("--disable-dev-shm-usage");
|
|
1845
|
+
args.push("about:blank");
|
|
1846
|
+
return spawn(exe.path, args, {
|
|
1847
|
+
stdio: "pipe",
|
|
1848
|
+
env: {
|
|
1849
|
+
...process.env,
|
|
1850
|
+
HOME: os.homedir()
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
};
|
|
1854
|
+
const startedAt = Date.now();
|
|
1855
|
+
const localStatePath = path.join(userDataDir, "Local State");
|
|
1856
|
+
const preferencesPath = path.join(userDataDir, "Default", "Preferences");
|
|
1857
|
+
if (!exists(localStatePath) || !exists(preferencesPath)) {
|
|
1858
|
+
const bootstrap = spawnOnce();
|
|
1859
|
+
const deadline = Date.now() + 1e4;
|
|
1860
|
+
while (Date.now() < deadline) {
|
|
1861
|
+
if (exists(localStatePath) && exists(preferencesPath)) break;
|
|
1862
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
1863
|
+
}
|
|
1864
|
+
try {
|
|
1865
|
+
bootstrap.kill("SIGTERM");
|
|
1866
|
+
} catch {}
|
|
1867
|
+
const exitDeadline = Date.now() + 5e3;
|
|
1868
|
+
while (Date.now() < exitDeadline) {
|
|
1869
|
+
if (bootstrap.exitCode != null) break;
|
|
1870
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
if (needsDecorate) try {
|
|
1874
|
+
decorateOpenClawProfile(userDataDir, {
|
|
1875
|
+
name: profile.name,
|
|
1876
|
+
color: profile.color
|
|
1877
|
+
});
|
|
1878
|
+
log.info(`🦞 cryptoclaw browser profile decorated (${profile.color})`);
|
|
1879
|
+
} catch (err) {
|
|
1880
|
+
log.warn(`cryptoclaw browser profile decoration failed: ${String(err)}`);
|
|
1881
|
+
}
|
|
1882
|
+
try {
|
|
1883
|
+
ensureProfileCleanExit(userDataDir);
|
|
1884
|
+
} catch (err) {
|
|
1885
|
+
log.warn(`cryptoclaw browser clean-exit prefs failed: ${String(err)}`);
|
|
1886
|
+
}
|
|
1887
|
+
const proc = spawnOnce();
|
|
1888
|
+
const readyDeadline = Date.now() + 15e3;
|
|
1889
|
+
while (Date.now() < readyDeadline) {
|
|
1890
|
+
if (await isChromeReachable(profile.cdpUrl, 500)) break;
|
|
1891
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
1892
|
+
}
|
|
1893
|
+
if (!await isChromeReachable(profile.cdpUrl, 500)) {
|
|
1894
|
+
try {
|
|
1895
|
+
proc.kill("SIGKILL");
|
|
1896
|
+
} catch {}
|
|
1897
|
+
throw new Error(`Failed to start Chrome CDP on port ${profile.cdpPort} for profile "${profile.name}".`);
|
|
1898
|
+
}
|
|
1899
|
+
const pid = proc.pid ?? -1;
|
|
1900
|
+
log.info(`🦞 cryptoclaw browser started (${exe.kind}) profile "${profile.name}" on 127.0.0.1:${profile.cdpPort} (pid ${pid})`);
|
|
1901
|
+
return {
|
|
1902
|
+
pid,
|
|
1903
|
+
exe,
|
|
1904
|
+
userDataDir,
|
|
1905
|
+
cdpPort: profile.cdpPort,
|
|
1906
|
+
startedAt,
|
|
1907
|
+
proc
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
async function stopOpenClawChrome(running, timeoutMs = 2500) {
|
|
1911
|
+
const proc = running.proc;
|
|
1912
|
+
if (proc.killed) return;
|
|
1913
|
+
try {
|
|
1914
|
+
proc.kill("SIGTERM");
|
|
1915
|
+
} catch {}
|
|
1916
|
+
const start = Date.now();
|
|
1917
|
+
while (Date.now() - start < timeoutMs) {
|
|
1918
|
+
if (!proc.exitCode && proc.killed) break;
|
|
1919
|
+
if (!await isChromeReachable(cdpUrlForPort(running.cdpPort), 200)) return;
|
|
1920
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
1921
|
+
}
|
|
1922
|
+
try {
|
|
1923
|
+
proc.kill("SIGKILL");
|
|
1924
|
+
} catch {}
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
//#endregion
|
|
1928
|
+
//#region src/infra/errors.ts
|
|
1929
|
+
function extractErrorCode(err) {
|
|
1930
|
+
if (!err || typeof err !== "object") return;
|
|
1931
|
+
const code = err.code;
|
|
1932
|
+
if (typeof code === "string") return code;
|
|
1933
|
+
if (typeof code === "number") return String(code);
|
|
1934
|
+
}
|
|
1935
|
+
function formatErrorMessage(err) {
|
|
1936
|
+
if (err instanceof Error) return err.message || err.name || "Error";
|
|
1937
|
+
if (typeof err === "string") return err;
|
|
1938
|
+
if (typeof err === "number" || typeof err === "boolean" || typeof err === "bigint") return String(err);
|
|
1939
|
+
try {
|
|
1940
|
+
return JSON.stringify(err);
|
|
1941
|
+
} catch {
|
|
1942
|
+
return Object.prototype.toString.call(err);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
function formatUncaughtError(err) {
|
|
1946
|
+
if (extractErrorCode(err) === "INVALID_CONFIG") return formatErrorMessage(err);
|
|
1947
|
+
if (err instanceof Error) return err.stack ?? err.message ?? err.name;
|
|
1948
|
+
return formatErrorMessage(err);
|
|
1949
|
+
}
|
|
1950
|
+
|
|
1951
|
+
//#endregion
|
|
1952
|
+
export { DEFAULT_CRYPTOCLAW_BROWSER_ENABLED as A, stopChromeExtensionRelayServer as C, DEFAULT_BROWSER_DEFAULT_PROFILE_NAME as D, DEFAULT_AI_SNAPSHOT_MAX_CHARS as E, DEFAULT_BROWSER_EVALUATE_ENABLED as O, ensureChromeExtensionRelayServer as S, DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS as T, formatAriaSnapshot as _, isChromeCdpReady as a, appendCdpPath as b, resolveOpenClawUserDataDir as c, ensurePortAvailable as d, inspectPortUsage as f, createTargetViaCdp as g, captureScreenshot as h, getChromeWebSocketUrl as i, DEFAULT_CRYPTOCLAW_BROWSER_PROFILE_NAME as j, DEFAULT_CRYPTOCLAW_BROWSER_COLOR as k, stopOpenClawChrome as l, formatPortDiagnostics as m, formatErrorMessage as n, isChromeReachable as o, resolveLsofCommandSync as p, formatUncaughtError as r, launchOpenClawChrome as s, extractErrorCode as t, resolveBrowserExecutableForPlatform as u, normalizeCdpWsUrl as v, DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH as w, getHeadersWithAuth as x, snapshotAria as y };
|