@captain-app/openclaw 2026.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1528 -0
- package/LICENSE +21 -0
- package/README-header.png +0 -0
- package/README.md +539 -0
- package/assets/avatar-placeholder.svg +19 -0
- package/assets/chrome-extension/README.md +22 -0
- package/assets/chrome-extension/background.js +438 -0
- package/assets/chrome-extension/icons/icon128.png +0 -0
- package/assets/chrome-extension/icons/icon16.png +0 -0
- package/assets/chrome-extension/icons/icon32.png +0 -0
- package/assets/chrome-extension/icons/icon48.png +0 -0
- package/assets/chrome-extension/manifest.json +25 -0
- package/assets/chrome-extension/options.html +196 -0
- package/assets/chrome-extension/options.js +59 -0
- package/assets/dmg-background-small.png +0 -0
- package/assets/dmg-background.png +0 -0
- package/dist/accounts-ClnuDahN.js +250 -0
- package/dist/accounts-DzBgAM3C.js +251 -0
- package/dist/acp-cli-BEDDkzXH.js +926 -0
- package/dist/acp-cli-CwV4mdnW.js +923 -0
- package/dist/agent-CArjbSeE.js +695 -0
- package/dist/agent-CB7x5HLT.js +695 -0
- package/dist/agent-scope-BbT4OG2N.js +545 -0
- package/dist/agent-scope-C_O6Vpl0.js +545 -0
- package/dist/agent-scope-Csu2B6AM.js +606 -0
- package/dist/archive-CWrnG1CH.js +85 -0
- package/dist/archive-ccN9aDgq.js +85 -0
- package/dist/audit-DXPkQ275.js +1686 -0
- package/dist/audit-eH7nwgsM.js +1686 -0
- package/dist/auth-health-Bj7Gjbv0.js +149 -0
- package/dist/auth-health-CjjJhHey.js +149 -0
- package/dist/auth-nnRYiqpH.js +192 -0
- package/dist/auth-profiles-DVLfuixr.js +2954 -0
- package/dist/auth-y1BLPUhX.js +192 -0
- package/dist/boolean-Wzu0-e0P.js +30 -0
- package/dist/brew-Cqi8b49_.js +46 -0
- package/dist/brew-DyBGNK8A.js +46 -0
- package/dist/build-info.json +5 -0
- package/dist/call-B7EveN4V.js +252 -0
- package/dist/call-vuUQIjOj.js +252 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17780 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/channel-options-CJfmOkol.js +32 -0
- package/dist/channel-options-lFguMTz1.js +62 -0
- package/dist/channel-selection-BmND9mWj.js +51 -0
- package/dist/channel-selection-cGhL9G0c.js +51 -0
- package/dist/channel-summary-B4G513Eb.js +1154 -0
- package/dist/channel-summary-MCwBCa5y.js +1154 -0
- package/dist/channels-cli-C2Of1mZG.js +1411 -0
- package/dist/channels-cli-DFynrP1H.js +1413 -0
- package/dist/channels-status-issues-YohTjZ-I.js +18 -0
- package/dist/channels-status-issues-ZcR1U-m5.js +18 -0
- package/dist/chrome-B3IuUad-.js +1953 -0
- package/dist/chrome-BZ9K48w9.js +1973 -0
- package/dist/clack-prompter-B9yLhyOm.js +92 -0
- package/dist/clack-prompter-BybM9xdL.js +92 -0
- package/dist/cli/daemon-cli.js +2 -0
- package/dist/cli-BJZdJwug.js +89 -0
- package/dist/cli-BQSoKu3d.js +86 -0
- package/dist/cli-utils-CO4jEMn0.js +43 -0
- package/dist/cli-utils-gtE-0a0D.js +43 -0
- package/dist/client-DPqNOpK3.js +1609 -0
- package/dist/client-DySXIFCA.js +1609 -0
- package/dist/command-format-CFzL448l.js +52 -0
- package/dist/command-format-DELazozB.js +52 -0
- package/dist/command-format-ayFsmwwz.js +38 -0
- package/dist/command-options-CsjxK4cZ.js +33 -0
- package/dist/commands-BRe9VTyU.js +229 -0
- package/dist/completion-cli-DlkjK0iC.js +390 -0
- package/dist/completion-cli-E6Pt41AL.js +387 -0
- package/dist/config-BtSTwPcH.js +4882 -0
- package/dist/config-DfMIMT-f.js +4881 -0
- package/dist/config-_d7_WcRv.js +5623 -0
- package/dist/config-guard-wSnm-U8a.js +5628 -0
- package/dist/configure-CPHAFKlg.js +895 -0
- package/dist/configure-DK1XgXYx.js +894 -0
- package/dist/constants-CNTiY-ZN.js +65 -0
- package/dist/constants-hpmbslG7.js +65 -0
- package/dist/control-service-CqX5g_ko.js +61 -0
- package/dist/control-service-o6xe3hEb.js +61 -0
- package/dist/control-ui/apple-touch-icon.png +0 -0
- package/dist/control-ui/assets/index-RwcW4Xl0.css +1 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js +4584 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js.map +1 -0
- package/dist/control-ui/favicon-32.png +0 -0
- package/dist/control-ui/favicon.ico +0 -0
- package/dist/control-ui/favicon.svg +22 -0
- package/dist/control-ui/index.html +17 -0
- package/dist/cron-cli-BoSaDgvH.js +453 -0
- package/dist/cron-cli-qVandvsD.js +456 -0
- package/dist/daemon-cli-C4gGWa15.js +760 -0
- package/dist/daemon-cli-DV_X0Krf.js +761 -0
- package/dist/daemon-runtime-D5hbSrdO.js +460 -0
- package/dist/daemon-runtime-DXUfrXBC.js +460 -0
- package/dist/deliver-BxK5nI2P.js +2587 -0
- package/dist/deliver-Dwzg9LUd.js +2557 -0
- package/dist/deliver-qpYZp20m.js +2587 -0
- package/dist/deps-CUXtMV9d.js +27 -0
- package/dist/deps-WBvZpFV_.js +27 -0
- package/dist/devices-cli-B2s18Qrh.js +207 -0
- package/dist/devices-cli-D1UEtMUJ.js +204 -0
- package/dist/directory-cli-BXQbrkfM.js +247 -0
- package/dist/directory-cli-CqA7tRbq.js +244 -0
- package/dist/dispatcher-Dyv7T-1r.js +160 -0
- package/dist/dns-cli-CWxKD22D.js +198 -0
- package/dist/dns-cli-CzKr_Fxj.js +201 -0
- package/dist/docs-cli-BNyxUbWr.js +159 -0
- package/dist/docs-cli-DYpTbo3i.js +161 -0
- package/dist/doctor-C8fDYZLq.js +2583 -0
- package/dist/doctor-hYcqp7c0.js +2585 -0
- package/dist/entry.js +1326 -0
- package/dist/env-l7QVNj6j.js +32 -0
- package/dist/errors-CMCg46fK.js +1952 -0
- package/dist/exec-B8JKbXKW.js +246 -0
- package/dist/exec-BMnoMcZW.js +1099 -0
- package/dist/exec-HEWTMJ7j.js +246 -0
- package/dist/exec-approvals-DtrnHx6M.js +1026 -0
- package/dist/exec-approvals-Y42bE8ud.js +1026 -0
- package/dist/exec-approvals-cli-CIedYxP3.js +385 -0
- package/dist/exec-approvals-cli-xpbxnj4O.js +388 -0
- package/dist/extensionAPI.js +66572 -0
- package/dist/format-Dzy9uRLE.js +34 -0
- package/dist/format-sj0fELBK.js +34 -0
- package/dist/gateway-cli-5A-KNLEC.js +16635 -0
- package/dist/gateway-cli-B8kS4chb.js +16637 -0
- package/dist/gateway-rpc-15n38Ize.js +28 -0
- package/dist/gateway-rpc-TMVRgGfj.js +28 -0
- package/dist/github-copilot-auth-DVZj4Zgh.js +1104 -0
- package/dist/github-copilot-auth-DeGYyLY9.js +1104 -0
- package/dist/github-copilot-token-B3SA95yo.js +103 -0
- package/dist/github-copilot-token-C8XFYz0i.js +103 -0
- package/dist/github-copilot-token-CnxakiSC.js +103 -0
- package/dist/gmail-setup-utils-CWPC386a.js +428 -0
- package/dist/gmail-setup-utils-eJVB5Ewp.js +428 -0
- package/dist/health-format-B0tMTk3C.js +1189 -0
- package/dist/health-format-DaURVaUn.js +1188 -0
- package/dist/help-format-CEsRHU2f.js +17 -0
- package/dist/help-format-GuCWws6r.js +17 -0
- package/dist/helpers-BEJ-phFf.js +25 -0
- package/dist/helpers-BtbBZVKZ.js +10 -0
- package/dist/helpers-C12w9zxf.js +10 -0
- package/dist/helpers-CzjGJZmJ.js +25 -0
- package/dist/hooks/bundled/boot-md/HOOK.md +19 -0
- package/dist/hooks/bundled/command-logger/HOOK.md +122 -0
- package/dist/hooks/bundled/session-memory/HOOK.md +109 -0
- package/dist/hooks/bundled/soul-evil/HOOK.md +71 -0
- package/dist/hooks-cli-BZCMAnW2.js +1058 -0
- package/dist/hooks-cli-D0CEFg3P.js +1061 -0
- package/dist/hooks-status-Bn7_O8PM.js +443 -0
- package/dist/hooks-status-BrWVfIn0.js +443 -0
- package/dist/image-BS022pvv.js +1421 -0
- package/dist/image-BzJtY34J.js +629 -0
- package/dist/image-CBqmIbQQ.js +629 -0
- package/dist/index.js +5809 -0
- package/dist/installs-BP4K5L33.js +388 -0
- package/dist/installs-DOpTt7VZ.js +388 -0
- package/dist/is-main-B4o72sqg.js +25 -0
- package/dist/is-main-PYGa3tDA.js +25 -0
- package/dist/links-B4nk2iDf.js +15 -0
- package/dist/links-DwjRqxgR.js +15 -0
- package/dist/loader-Cn4EV_pf.js +63690 -0
- package/dist/logging-CS3tbYDj.js +15 -0
- package/dist/logging-CY-Q5cwf.js +1 -0
- package/dist/logging-DhiLkhLw.js +15 -0
- package/dist/logging-pqyrk15z.js +1 -0
- package/dist/login-qr-CD164Aw1.js +478 -0
- package/dist/login-qr-D7Zdgji2.js +478 -0
- package/dist/login-qr-YgILJ4VC.js +475 -0
- package/dist/logs-cli-BdS0Uv0I.js +227 -0
- package/dist/logs-cli-CqSN1GzB.js +230 -0
- package/dist/manager-CfGY5zND.js +2870 -0
- package/dist/manager-CjuBqFRL.js +2870 -0
- package/dist/manager-CoBEAQKm.js +2872 -0
- package/dist/manifest-registry-Bwjq9Iev.js +668 -0
- package/dist/manifest-registry-D2Yntqcb.js +668 -0
- package/dist/message-channel-Cjsiqxok.js +105 -0
- package/dist/message-channel-D6v_oPAg.js +105 -0
- package/dist/model-selection-Cv5Ox_tY.js +2956 -0
- package/dist/model-selection-Dr-5U5-l.js +2708 -0
- package/dist/models-cli-B39ckynD.js +2541 -0
- package/dist/models-cli-DoiYsBYw.js +2544 -0
- package/dist/net-CFCxaipF.js +137 -0
- package/dist/net-DKJPqXuW.js +137 -0
- package/dist/node-cli-C_FYF-RA.js +1456 -0
- package/dist/node-cli-DWPoNsQS.js +1459 -0
- package/dist/node-service-DcJREOww.js +67 -0
- package/dist/node-service-DuZ9Us9h.js +67 -0
- package/dist/nodes-cli-Elo6tlen.js +1210 -0
- package/dist/nodes-cli-zqryRUWB.js +1207 -0
- package/dist/nodes-screen-C4aCrxie.js +157 -0
- package/dist/nodes-screen-D4PSynkR.js +157 -0
- package/dist/note-CQhSvgQv.js +73 -0
- package/dist/note-_C44YfAQ.js +73 -0
- package/dist/onboard-channels-CHBDi-ZA.js +670 -0
- package/dist/onboard-channels-DOEKyxaL.js +670 -0
- package/dist/onboard-skills-BUTXREDZ.js +3327 -0
- package/dist/onboard-skills-CSLYZmZA.js +3327 -0
- package/dist/onboarding-CgKb8b39.js +3232 -0
- package/dist/openclaw-root-9ILYSmJ9.js +84 -0
- package/dist/openclaw-root-Cvotktkd.js +84 -0
- package/dist/pairing-cli-B4UGR2at.js +114 -0
- package/dist/pairing-cli-BWDDl8cf.js +117 -0
- package/dist/pairing-labels-ClZ-fTWT.js +9 -0
- package/dist/pairing-labels-Ds7BPOkj.js +9 -0
- package/dist/pairing-store-DDLNuzmx.js +391 -0
- package/dist/pairing-store-DRn08lZD.js +391 -0
- package/dist/parse-87ybtYW1.js +23 -0
- package/dist/parse-OCFfznr3.js +23 -0
- package/dist/parse-log-line-C9aL5PUL.js +44 -0
- package/dist/parse-log-line-DxRaGzQb.js +44 -0
- package/dist/parse-timeout-CFqNj7No.js +16 -0
- package/dist/parse-timeout-DV8NQQWk.js +16 -0
- package/dist/path-env-C7kiJUgG.js +77 -0
- package/dist/path-env-DEj4CiFN.js +77 -0
- package/dist/paths-B-q1nXdY.js +43 -0
- package/dist/paths-B1kfl4h5.js +164 -0
- package/dist/paths-B4kigINg.js +40 -0
- package/dist/paths-CHGbP1-A.js +43 -0
- package/dist/paths-scjhy7N2.js +180 -0
- package/dist/pi-embedded-helpers-C19wUpMB.js +8451 -0
- package/dist/pi-embedded-helpers-CT5VuLCb.js +1293 -0
- package/dist/pi-embedded-helpers-Dl8e5Rf8.js +1293 -0
- package/dist/pi-model-discovery-B6CsmK6Y.js +20 -0
- package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
- package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
- package/dist/pi-tools.policy-BvkSDFDN.js +229 -0
- package/dist/plugin-auto-enable-Bd_StZzz.js +461 -0
- package/dist/plugin-auto-enable-DBhXb_0x.js +461 -0
- package/dist/plugin-sdk/agent-scope-DdwUKIOe.js +606 -0
- package/dist/plugin-sdk/chrome-G8apFa5p.js +1953 -0
- package/dist/plugin-sdk/command-format-qUVxzqYm.js +52 -0
- package/dist/plugin-sdk/config-Cm1M7tgH.js +5623 -0
- package/dist/plugin-sdk/deliver-Cl8uowiO.js +2557 -0
- package/dist/plugin-sdk/exec-Cm9b2r9Q.js +1107 -0
- package/dist/plugin-sdk/github-copilot-token-BHNcM4_B.js +103 -0
- package/dist/plugin-sdk/image-7PgoS2VD.js +1421 -0
- package/dist/plugin-sdk/index.d.ts +8908 -0
- package/dist/plugin-sdk/index.js +70888 -0
- package/dist/plugin-sdk/login-qr-qTALvWi2.js +475 -0
- package/dist/plugin-sdk/manager-Cs3EQZCb.js +2870 -0
- package/dist/plugin-sdk/model-selection-BgC1E1a7.js +2708 -0
- package/dist/plugin-sdk/paths-BYpoyRv5.js +164 -0
- package/dist/plugin-sdk/paths-DNQE-bvr.js +40 -0
- package/dist/plugin-sdk/pi-embedded-helpers-5jNqW_dE.js +8755 -0
- package/dist/plugin-sdk/pi-model-discovery-BUGEht9A.js +20 -0
- package/dist/plugin-sdk/pw-ai-COTtei4a.js +1649 -0
- package/dist/plugin-sdk/qmd-manager-ClSwiAJl.js +615 -0
- package/dist/plugin-sdk/redact-2AzjOfk2.js +94 -0
- package/dist/plugin-sdk/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/plugin-sdk/sqlite-gCW7MlLs.js +215 -0
- package/dist/plugin-sdk/transcript-events-DGF257vD.js +17 -0
- package/dist/plugins-C3Bm-HQV.js +494 -0
- package/dist/plugins-QJjTXliB.js +495 -0
- package/dist/plugins-cli-DTci0JQb.js +443 -0
- package/dist/plugins-cli-wJsN1HHK.js +440 -0
- package/dist/ports-CiW9dmMq.js +96 -0
- package/dist/program-BWpTHh1I.js +188 -0
- package/dist/progress-Bcjniu7m.js +133 -0
- package/dist/progress-CvaSPjS9.js +133 -0
- package/dist/prompt-style-CFsleyxV.js +9 -0
- package/dist/prompt-style-DYJdrXyV.js +9 -0
- package/dist/prompts-Bt9fwsg2.js +10 -0
- package/dist/prompts-CudpZgTI.js +10 -0
- package/dist/pw-ai-08F3GD-3.js +1649 -0
- package/dist/pw-ai-ZmHxHQnx.js +1651 -0
- package/dist/pw-ai-tNPuRNn3.js +1649 -0
- package/dist/qmd-manager-2r-4n3sP.js +617 -0
- package/dist/qmd-manager-CF52nuBg.js +615 -0
- package/dist/qmd-manager-HEm5H2mk.js +616 -0
- package/dist/redact-BICFkpn7.js +97 -0
- package/dist/redact-BIMJ3ntQ.js +94 -0
- package/dist/redact-KzWHRS5J.js +97 -0
- package/dist/register.subclis-D2K25c84.js +348 -0
- package/dist/register.subclis-Dd8LbOLi.js +342 -0
- package/dist/reply-5UNWRwMn.js +63693 -0
- package/dist/restart-sentinel-Cr0vUxB8.js +65 -0
- package/dist/restart-sentinel-DUemCjgU.js +65 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-C6UpTPas.js +2410 -0
- package/dist/routes-ClNyEvlm.js +2410 -0
- package/dist/rpc-D0mf7DIw.js +95 -0
- package/dist/rpc-DYdOrgd9.js +95 -0
- package/dist/run-main-CojI7gWx.js +194 -0
- package/dist/runtime-guard-68M_evhb.js +60 -0
- package/dist/runtime-guard-DkjmhnBD.js +60 -0
- package/dist/sandbox-Ca81z3Tw.js +2924 -0
- package/dist/sandbox-cli-D75GApgp.js +459 -0
- package/dist/sandbox-cli-E4SJsC1C.js +462 -0
- package/dist/sandbox-knontqD9.js +2925 -0
- package/dist/security-cli-BLihvXO-.js +503 -0
- package/dist/security-cli-IGQCsK4g.js +506 -0
- package/dist/server-context-B9GX5GOI.js +740 -0
- package/dist/server-context-BFH7HB_M.js +740 -0
- package/dist/server-node-events-CTdHBiEA.js +218 -0
- package/dist/server-node-events-DAV14qPr.js +215 -0
- package/dist/service-BZNBq9hq.js +680 -0
- package/dist/service-C-BLXx9U.js +680 -0
- package/dist/service-audit-BfJv4NqZ.js +542 -0
- package/dist/service-audit-Bw3M2OEI.js +542 -0
- package/dist/shared-5SH-45AX.js +74 -0
- package/dist/shared-BxRm5uLU.js +74 -0
- package/dist/shared-C80Rmxsd.js +150 -0
- package/dist/shared-fGK6_D2v.js +150 -0
- package/dist/skills-Bhp0l6UK.js +693 -0
- package/dist/skills-Tky2kCMO.js +694 -0
- package/dist/skills-cli-6rCClAE4.js +287 -0
- package/dist/skills-cli-C4nLCrLw.js +290 -0
- package/dist/skills-status-CENcKr3I.js +187 -0
- package/dist/skills-status-DX1eUYvk.js +187 -0
- package/dist/sqlite-CmdZSZRx.js +197 -0
- package/dist/sqlite-Dnmf3LS7.js +215 -0
- package/dist/sqlite-QDf0yuU0.js +215 -0
- package/dist/status-BSfGAp2D.js +27 -0
- package/dist/status-Bp_2NMjt.js +27 -0
- package/dist/status-C0ANDr0T.js +3140 -0
- package/dist/status-CCHBIZnm.js +21 -0
- package/dist/status-Vuqbw2Bb.js +21 -0
- package/dist/status.update-BZW5r8Su.js +79 -0
- package/dist/status.update-BnD93_O8.js +79 -0
- package/dist/subsystem-CAq3uyo7.js +834 -0
- package/dist/system-cli-Bb9zmCO1.js +83 -0
- package/dist/system-cli-TIIQ04ls.js +80 -0
- package/dist/systemd-0Qa_nGqe.js +438 -0
- package/dist/systemd-Czb0Xsm7.js +438 -0
- package/dist/systemd-hints-CWoEOQRb.js +19 -0
- package/dist/systemd-hints-Cv3RN_mZ.js +19 -0
- package/dist/systemd-linger-CsdvcIoS.js +75 -0
- package/dist/systemd-linger-DKUFHcLn.js +75 -0
- package/dist/table-DNPESyNj.js +279 -0
- package/dist/table-DS4-gmkV.js +279 -0
- package/dist/tailnet-Bg_vE5qi.js +42 -0
- package/dist/tailnet-CrNWlQRJ.js +42 -0
- package/dist/tailscale-CBv58toW.js +252 -0
- package/dist/tailscale-DCnMs7_q.js +225 -0
- package/dist/tool-display-BEACy9rK.js +795 -0
- package/dist/tool-display-NYQnSpdo.js +795 -0
- package/dist/transcript-events-CsB1Saa6.js +17 -0
- package/dist/transcript-events-DDYvbmRV.js +17 -0
- package/dist/transcript-events-JLH5W4He.js +17 -0
- package/dist/tui--NY0rnjr.js +2542 -0
- package/dist/tui-DqJfGtvM.js +2543 -0
- package/dist/tui-cli-BuHNY6wF.js +54 -0
- package/dist/tui-cli-LMFV982e.js +57 -0
- package/dist/update-CRpHtCgz.js +317 -0
- package/dist/update-D3qruxhj.js +317 -0
- package/dist/update-cli-CFF-pslM.js +948 -0
- package/dist/update-cli-cn9pEMX7.js +951 -0
- package/dist/update-runner-CxGU142L.js +1221 -0
- package/dist/update-runner-DNobz_ft.js +1221 -0
- package/dist/utils-CKSrBNwq.js +192 -0
- package/dist/utils-DX85MiPR.js +188 -0
- package/dist/webhooks-cli-BGtt2HAR.js +312 -0
- package/dist/webhooks-cli-DHLZrEO_.js +309 -0
- package/dist/widearea-dns-BpG7ATO8.js +127 -0
- package/dist/widearea-dns-D4wkCJly.js +127 -0
- package/dist/ws-3zr8WUwL.js +13 -0
- package/dist/ws-log-BXcT2xQk.js +267 -0
- package/dist/ws-log-DbDIUsgz.js +267 -0
- package/dist/ws-lzrgabja.js +13 -0
- package/dist/wsl-D2O2qOrl.js +160 -0
- package/docs/.i18n/README.md +31 -0
- package/docs/.i18n/glossary.zh-CN.json +190 -0
- package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
- package/docs/CNAME +1 -0
- package/docs/_config.yml +53 -0
- package/docs/_layouts/default.html +145 -0
- package/docs/assets/markdown.css +179 -0
- package/docs/assets/openclaw-logo-text-dark.png +0 -0
- package/docs/assets/openclaw-logo-text.png +0 -0
- package/docs/assets/pixel-lobster.svg +60 -0
- package/docs/assets/showcase/agents-ui.jpg +0 -0
- package/docs/assets/showcase/bambu-cli.png +0 -0
- package/docs/assets/showcase/codexmonitor.png +0 -0
- package/docs/assets/showcase/gohome-grafana.png +0 -0
- package/docs/assets/showcase/ios-testflight.jpg +0 -0
- package/docs/assets/showcase/oura-health.png +0 -0
- package/docs/assets/showcase/padel-cli.svg +11 -0
- package/docs/assets/showcase/padel-screenshot.jpg +0 -0
- package/docs/assets/showcase/papla-tts.jpg +0 -0
- package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
- package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
- package/docs/assets/showcase/roborock-status.svg +13 -0
- package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
- package/docs/assets/showcase/snag.png +0 -0
- package/docs/assets/showcase/tesco-shop.jpg +0 -0
- package/docs/assets/showcase/wienerlinien.png +0 -0
- package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
- package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
- package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
- package/docs/assets/terminal.css +473 -0
- package/docs/assets/theme.js +55 -0
- package/docs/automation/auth-monitoring.md +44 -0
- package/docs/automation/cron-jobs.md +468 -0
- package/docs/automation/cron-vs-heartbeat.md +282 -0
- package/docs/automation/gmail-pubsub.md +256 -0
- package/docs/automation/poll.md +69 -0
- package/docs/automation/webhook.md +163 -0
- package/docs/bedrock.md +176 -0
- package/docs/brave-search.md +41 -0
- package/docs/broadcast-groups.md +442 -0
- package/docs/channels/bluebubbles.md +338 -0
- package/docs/channels/discord.md +475 -0
- package/docs/channels/feishu.md +507 -0
- package/docs/channels/googlechat.md +250 -0
- package/docs/channels/grammy.md +31 -0
- package/docs/channels/imessage.md +299 -0
- package/docs/channels/index.md +46 -0
- package/docs/channels/line.md +186 -0
- package/docs/channels/location.md +56 -0
- package/docs/channels/matrix.md +233 -0
- package/docs/channels/mattermost.md +138 -0
- package/docs/channels/msteams.md +768 -0
- package/docs/channels/nextcloud-talk.md +136 -0
- package/docs/channels/nostr.md +233 -0
- package/docs/channels/signal.md +202 -0
- package/docs/channels/slack.md +548 -0
- package/docs/channels/telegram.md +750 -0
- package/docs/channels/tlon.md +132 -0
- package/docs/channels/troubleshooting.md +29 -0
- package/docs/channels/twitch.md +379 -0
- package/docs/channels/whatsapp.md +404 -0
- package/docs/channels/zalo.md +189 -0
- package/docs/channels/zalouser.md +140 -0
- package/docs/cli/acp.md +170 -0
- package/docs/cli/agent.md +24 -0
- package/docs/cli/agents.md +75 -0
- package/docs/cli/approvals.md +50 -0
- package/docs/cli/browser.md +107 -0
- package/docs/cli/channels.md +79 -0
- package/docs/cli/config.md +50 -0
- package/docs/cli/configure.md +33 -0
- package/docs/cli/cron.md +42 -0
- package/docs/cli/dashboard.md +16 -0
- package/docs/cli/devices.md +67 -0
- package/docs/cli/directory.md +63 -0
- package/docs/cli/dns.md +23 -0
- package/docs/cli/docs.md +15 -0
- package/docs/cli/doctor.md +41 -0
- package/docs/cli/gateway.md +199 -0
- package/docs/cli/health.md +21 -0
- package/docs/cli/hooks.md +304 -0
- package/docs/cli/index.md +1029 -0
- package/docs/cli/logs.md +24 -0
- package/docs/cli/memory.md +45 -0
- package/docs/cli/message.md +239 -0
- package/docs/cli/models.md +79 -0
- package/docs/cli/node.md +112 -0
- package/docs/cli/nodes.md +73 -0
- package/docs/cli/onboard.md +29 -0
- package/docs/cli/pairing.md +21 -0
- package/docs/cli/plugins.md +62 -0
- package/docs/cli/reset.md +17 -0
- package/docs/cli/sandbox.md +152 -0
- package/docs/cli/security.md +26 -0
- package/docs/cli/sessions.md +16 -0
- package/docs/cli/setup.md +29 -0
- package/docs/cli/skills.md +26 -0
- package/docs/cli/status.md +26 -0
- package/docs/cli/system.md +60 -0
- package/docs/cli/tui.md +23 -0
- package/docs/cli/uninstall.md +17 -0
- package/docs/cli/update.md +98 -0
- package/docs/cli/voicecall.md +34 -0
- package/docs/cli/webhooks.md +25 -0
- package/docs/concepts/agent-loop.md +146 -0
- package/docs/concepts/agent-workspace.md +233 -0
- package/docs/concepts/agent.md +123 -0
- package/docs/concepts/architecture.md +129 -0
- package/docs/concepts/channel-routing.md +114 -0
- package/docs/concepts/compaction.md +61 -0
- package/docs/concepts/context.md +161 -0
- package/docs/concepts/group-messages.md +84 -0
- package/docs/concepts/groups.md +373 -0
- package/docs/concepts/markdown-formatting.md +130 -0
- package/docs/concepts/memory.md +546 -0
- package/docs/concepts/messages.md +154 -0
- package/docs/concepts/model-failover.md +149 -0
- package/docs/concepts/model-providers.md +316 -0
- package/docs/concepts/models.md +208 -0
- package/docs/concepts/multi-agent.md +376 -0
- package/docs/concepts/oauth.md +145 -0
- package/docs/concepts/presence.md +102 -0
- package/docs/concepts/queue.md +89 -0
- package/docs/concepts/retry.md +69 -0
- package/docs/concepts/session-pruning.md +122 -0
- package/docs/concepts/session-tool.md +193 -0
- package/docs/concepts/session.md +188 -0
- package/docs/concepts/sessions.md +10 -0
- package/docs/concepts/streaming.md +135 -0
- package/docs/concepts/system-prompt.md +115 -0
- package/docs/concepts/timezone.md +91 -0
- package/docs/concepts/typebox.md +289 -0
- package/docs/concepts/typing-indicators.md +68 -0
- package/docs/concepts/usage-tracking.md +35 -0
- package/docs/date-time.md +128 -0
- package/docs/debug/node-issue.md +83 -0
- package/docs/debugging.md +162 -0
- package/docs/diagnostics/flags.md +91 -0
- package/docs/docs.json +1587 -0
- package/docs/environment.md +81 -0
- package/docs/experiments/onboarding-config-protocol.md +40 -0
- package/docs/experiments/plans/cron-add-hardening.md +63 -0
- package/docs/experiments/plans/group-policy-hardening.md +40 -0
- package/docs/experiments/plans/openresponses-gateway.md +123 -0
- package/docs/experiments/proposals/model-config.md +36 -0
- package/docs/experiments/research/memory.md +228 -0
- package/docs/gateway/authentication.md +145 -0
- package/docs/gateway/background-process.md +93 -0
- package/docs/gateway/bonjour.md +167 -0
- package/docs/gateway/bridge-protocol.md +89 -0
- package/docs/gateway/cli-backends.md +223 -0
- package/docs/gateway/configuration-examples.md +606 -0
- package/docs/gateway/configuration.md +3393 -0
- package/docs/gateway/discovery.md +116 -0
- package/docs/gateway/doctor.md +282 -0
- package/docs/gateway/gateway-lock.md +34 -0
- package/docs/gateway/health.md +35 -0
- package/docs/gateway/heartbeat.md +302 -0
- package/docs/gateway/index.md +328 -0
- package/docs/gateway/local-models.md +150 -0
- package/docs/gateway/logging.md +113 -0
- package/docs/gateway/multiple-gateways.md +112 -0
- package/docs/gateway/openai-http-api.md +118 -0
- package/docs/gateway/openresponses-http-api.md +317 -0
- package/docs/gateway/pairing.md +99 -0
- package/docs/gateway/protocol.md +221 -0
- package/docs/gateway/remote-gateway-readme.md +157 -0
- package/docs/gateway/remote.md +127 -0
- package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +128 -0
- package/docs/gateway/sandboxing.md +193 -0
- package/docs/gateway/security/formal-verification.md +164 -0
- package/docs/gateway/security/index.md +825 -0
- package/docs/gateway/tailscale.md +127 -0
- package/docs/gateway/tools-invoke-http-api.md +85 -0
- package/docs/gateway/troubleshooting.md +767 -0
- package/docs/help/faq.md +2830 -0
- package/docs/help/index.md +21 -0
- package/docs/help/troubleshooting.md +98 -0
- package/docs/hooks/soul-evil.md +69 -0
- package/docs/hooks.md +913 -0
- package/docs/images/feishu-step2-create-app.png +0 -0
- package/docs/images/feishu-step3-credentials.png +0 -0
- package/docs/images/feishu-step4-permissions.png +0 -0
- package/docs/images/feishu-step5-bot-capability.png +0 -0
- package/docs/images/feishu-step6-event-subscription.png +0 -0
- package/docs/images/groups-flow.svg +52 -0
- package/docs/images/mobile-ui-screenshot.png +0 -0
- package/docs/index.md +258 -0
- package/docs/install/ansible.md +208 -0
- package/docs/install/bun.md +59 -0
- package/docs/install/development-channels.md +75 -0
- package/docs/install/docker.md +567 -0
- package/docs/install/index.md +185 -0
- package/docs/install/installer.md +123 -0
- package/docs/install/migrating.md +192 -0
- package/docs/install/nix.md +96 -0
- package/docs/install/node.md +78 -0
- package/docs/install/uninstall.md +128 -0
- package/docs/install/updating.md +228 -0
- package/docs/logging.md +350 -0
- package/docs/multi-agent-sandbox-tools.md +395 -0
- package/docs/network.md +54 -0
- package/docs/nodes/audio.md +114 -0
- package/docs/nodes/camera.md +156 -0
- package/docs/nodes/images.md +72 -0
- package/docs/nodes/index.md +341 -0
- package/docs/nodes/location-command.md +113 -0
- package/docs/nodes/media-understanding.md +379 -0
- package/docs/nodes/talk.md +90 -0
- package/docs/nodes/voicewake.md +65 -0
- package/docs/northflank.mdx +53 -0
- package/docs/perplexity.md +80 -0
- package/docs/pi-dev.md +70 -0
- package/docs/pi.md +612 -0
- package/docs/platforms/android.md +148 -0
- package/docs/platforms/digitalocean.md +262 -0
- package/docs/platforms/exe-dev.md +125 -0
- package/docs/platforms/fly.md +486 -0
- package/docs/platforms/gcp.md +503 -0
- package/docs/platforms/hetzner.md +330 -0
- package/docs/platforms/index.md +53 -0
- package/docs/platforms/ios.md +107 -0
- package/docs/platforms/linux.md +94 -0
- package/docs/platforms/mac/bundled-gateway.md +73 -0
- package/docs/platforms/mac/canvas.md +125 -0
- package/docs/platforms/mac/child-process.md +69 -0
- package/docs/platforms/mac/dev-setup.md +102 -0
- package/docs/platforms/mac/health.md +34 -0
- package/docs/platforms/mac/icon.md +31 -0
- package/docs/platforms/mac/logging.md +57 -0
- package/docs/platforms/mac/menu-bar.md +81 -0
- package/docs/platforms/mac/peekaboo.md +65 -0
- package/docs/platforms/mac/permissions.md +44 -0
- package/docs/platforms/mac/release.md +85 -0
- package/docs/platforms/mac/remote.md +83 -0
- package/docs/platforms/mac/signing.md +47 -0
- package/docs/platforms/mac/skills.md +33 -0
- package/docs/platforms/mac/voice-overlay.md +60 -0
- package/docs/platforms/mac/voicewake.md +67 -0
- package/docs/platforms/mac/webchat.md +41 -0
- package/docs/platforms/mac/xpc.md +61 -0
- package/docs/platforms/macos-vm.md +281 -0
- package/docs/platforms/macos.md +203 -0
- package/docs/platforms/oracle.md +303 -0
- package/docs/platforms/raspberry-pi.md +358 -0
- package/docs/platforms/windows.md +159 -0
- package/docs/plugin.md +664 -0
- package/docs/plugins/agent-tools.md +99 -0
- package/docs/plugins/manifest.md +71 -0
- package/docs/plugins/voice-call.md +284 -0
- package/docs/plugins/zalouser.md +81 -0
- package/docs/prose.md +134 -0
- package/docs/providers/anthropic.md +152 -0
- package/docs/providers/claude-max-api-proxy.md +148 -0
- package/docs/providers/cloudflare-ai-gateway.md +71 -0
- package/docs/providers/deepgram.md +93 -0
- package/docs/providers/github-copilot.md +72 -0
- package/docs/providers/glm.md +33 -0
- package/docs/providers/index.md +63 -0
- package/docs/providers/minimax.md +208 -0
- package/docs/providers/models.md +51 -0
- package/docs/providers/moonshot.md +142 -0
- package/docs/providers/ollama.md +223 -0
- package/docs/providers/openai.md +62 -0
- package/docs/providers/opencode.md +36 -0
- package/docs/providers/openrouter.md +37 -0
- package/docs/providers/qwen.md +53 -0
- package/docs/providers/synthetic.md +99 -0
- package/docs/providers/venice.md +267 -0
- package/docs/providers/vercel-ai-gateway.md +50 -0
- package/docs/providers/xiaomi.md +64 -0
- package/docs/providers/zai.md +36 -0
- package/docs/railway.mdx +99 -0
- package/docs/refactor/clawnet.md +417 -0
- package/docs/refactor/exec-host.md +316 -0
- package/docs/refactor/outbound-session-mirroring.md +85 -0
- package/docs/refactor/plugin-sdk.md +214 -0
- package/docs/refactor/strict-config.md +93 -0
- package/docs/reference/AGENTS.default.md +124 -0
- package/docs/reference/RELEASING.md +120 -0
- package/docs/reference/api-usage-costs.md +137 -0
- package/docs/reference/device-models.md +47 -0
- package/docs/reference/rpc.md +43 -0
- package/docs/reference/session-management-compaction.md +285 -0
- package/docs/reference/templates/AGENTS.dev.md +83 -0
- package/docs/reference/templates/AGENTS.md +218 -0
- package/docs/reference/templates/BOOT.md +10 -0
- package/docs/reference/templates/BOOTSTRAP.md +61 -0
- package/docs/reference/templates/HEARTBEAT.md +11 -0
- package/docs/reference/templates/IDENTITY.dev.md +47 -0
- package/docs/reference/templates/IDENTITY.md +27 -0
- package/docs/reference/templates/SOUL.dev.md +76 -0
- package/docs/reference/templates/SOUL.md +42 -0
- package/docs/reference/templates/TOOLS.dev.md +24 -0
- package/docs/reference/templates/TOOLS.md +46 -0
- package/docs/reference/templates/USER.dev.md +18 -0
- package/docs/reference/templates/USER.md +22 -0
- package/docs/reference/test.md +50 -0
- package/docs/reference/transcript-hygiene.md +129 -0
- package/docs/render.mdx +165 -0
- package/docs/scripts.md +28 -0
- package/docs/security/formal-verification.md +164 -0
- package/docs/start/getting-started.md +208 -0
- package/docs/start/hubs.md +185 -0
- package/docs/start/lore.md +219 -0
- package/docs/start/onboarding.md +110 -0
- package/docs/start/openclaw.md +241 -0
- package/docs/start/pairing.md +86 -0
- package/docs/start/setup.md +149 -0
- package/docs/start/showcase.md +416 -0
- package/docs/start/wizard.md +349 -0
- package/docs/testing.md +368 -0
- package/docs/token-use.md +112 -0
- package/docs/tools/agent-send.md +53 -0
- package/docs/tools/apply-patch.md +50 -0
- package/docs/tools/browser-linux-troubleshooting.md +139 -0
- package/docs/tools/browser-login.md +68 -0
- package/docs/tools/browser.md +576 -0
- package/docs/tools/chrome-extension.md +178 -0
- package/docs/tools/clawhub.md +257 -0
- package/docs/tools/creating-skills.md +54 -0
- package/docs/tools/elevated.md +57 -0
- package/docs/tools/exec-approvals.md +246 -0
- package/docs/tools/exec.md +179 -0
- package/docs/tools/firecrawl.md +61 -0
- package/docs/tools/index.md +509 -0
- package/docs/tools/llm-task.md +115 -0
- package/docs/tools/lobster.md +342 -0
- package/docs/tools/reactions.md +22 -0
- package/docs/tools/skills-config.md +76 -0
- package/docs/tools/skills.md +300 -0
- package/docs/tools/slash-commands.md +198 -0
- package/docs/tools/subagents.md +151 -0
- package/docs/tools/thinking.md +73 -0
- package/docs/tools/web.md +261 -0
- package/docs/tts.md +396 -0
- package/docs/tui.md +159 -0
- package/docs/vps.md +43 -0
- package/docs/web/control-ui.md +221 -0
- package/docs/web/dashboard.md +46 -0
- package/docs/web/index.md +116 -0
- package/docs/web/webchat.md +49 -0
- package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
- package/docs/whatsapp-openclaw.jpg +0 -0
- package/docs/zh-CN/AGENTS.md +59 -0
- package/docs/zh-CN/automation/auth-monitoring.md +47 -0
- package/docs/zh-CN/automation/cron-jobs.md +424 -0
- package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
- package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
- package/docs/zh-CN/automation/poll.md +76 -0
- package/docs/zh-CN/automation/webhook.md +163 -0
- package/docs/zh-CN/bedrock.md +170 -0
- package/docs/zh-CN/brave-search.md +48 -0
- package/docs/zh-CN/broadcast-groups.md +449 -0
- package/docs/zh-CN/channels/bluebubbles.md +271 -0
- package/docs/zh-CN/channels/discord.md +468 -0
- package/docs/zh-CN/channels/feishu.md +513 -0
- package/docs/zh-CN/channels/googlechat.md +257 -0
- package/docs/zh-CN/channels/grammy.md +38 -0
- package/docs/zh-CN/channels/imessage.md +302 -0
- package/docs/zh-CN/channels/index.md +53 -0
- package/docs/zh-CN/channels/line.md +180 -0
- package/docs/zh-CN/channels/location.md +63 -0
- package/docs/zh-CN/channels/matrix.md +221 -0
- package/docs/zh-CN/channels/mattermost.md +144 -0
- package/docs/zh-CN/channels/msteams.md +775 -0
- package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
- package/docs/zh-CN/channels/nostr.md +240 -0
- package/docs/zh-CN/channels/signal.md +209 -0
- package/docs/zh-CN/channels/slack.md +531 -0
- package/docs/zh-CN/channels/telegram.md +751 -0
- package/docs/zh-CN/channels/tlon.md +136 -0
- package/docs/zh-CN/channels/troubleshooting.md +36 -0
- package/docs/zh-CN/channels/twitch.md +385 -0
- package/docs/zh-CN/channels/whatsapp.md +411 -0
- package/docs/zh-CN/channels/zalo.md +196 -0
- package/docs/zh-CN/channels/zalouser.md +147 -0
- package/docs/zh-CN/cli/acp.md +173 -0
- package/docs/zh-CN/cli/agent.md +30 -0
- package/docs/zh-CN/cli/agents.md +82 -0
- package/docs/zh-CN/cli/approvals.md +57 -0
- package/docs/zh-CN/cli/browser.md +114 -0
- package/docs/zh-CN/cli/channels.md +86 -0
- package/docs/zh-CN/cli/config.md +57 -0
- package/docs/zh-CN/cli/configure.md +38 -0
- package/docs/zh-CN/cli/cron.md +43 -0
- package/docs/zh-CN/cli/dashboard.md +23 -0
- package/docs/zh-CN/cli/devices.md +74 -0
- package/docs/zh-CN/cli/directory.md +70 -0
- package/docs/zh-CN/cli/dns.md +30 -0
- package/docs/zh-CN/cli/docs.md +22 -0
- package/docs/zh-CN/cli/doctor.md +48 -0
- package/docs/zh-CN/cli/gateway.md +206 -0
- package/docs/zh-CN/cli/health.md +28 -0
- package/docs/zh-CN/cli/hooks.md +311 -0
- package/docs/zh-CN/cli/index.md +1032 -0
- package/docs/zh-CN/cli/logs.md +31 -0
- package/docs/zh-CN/cli/memory.md +52 -0
- package/docs/zh-CN/cli/message.md +246 -0
- package/docs/zh-CN/cli/models.md +85 -0
- package/docs/zh-CN/cli/node.md +115 -0
- package/docs/zh-CN/cli/nodes.md +80 -0
- package/docs/zh-CN/cli/onboard.md +36 -0
- package/docs/zh-CN/cli/pairing.md +28 -0
- package/docs/zh-CN/cli/plugins.md +66 -0
- package/docs/zh-CN/cli/reset.md +24 -0
- package/docs/zh-CN/cli/sandbox.md +158 -0
- package/docs/zh-CN/cli/security.md +33 -0
- package/docs/zh-CN/cli/sessions.md +23 -0
- package/docs/zh-CN/cli/setup.md +36 -0
- package/docs/zh-CN/cli/skills.md +33 -0
- package/docs/zh-CN/cli/status.md +33 -0
- package/docs/zh-CN/cli/system.md +63 -0
- package/docs/zh-CN/cli/tui.md +30 -0
- package/docs/zh-CN/cli/uninstall.md +24 -0
- package/docs/zh-CN/cli/update.md +101 -0
- package/docs/zh-CN/cli/voicecall.md +41 -0
- package/docs/zh-CN/cli/webhooks.md +32 -0
- package/docs/zh-CN/concepts/agent-loop.md +146 -0
- package/docs/zh-CN/concepts/agent-workspace.md +219 -0
- package/docs/zh-CN/concepts/agent.md +115 -0
- package/docs/zh-CN/concepts/architecture.md +123 -0
- package/docs/zh-CN/concepts/channel-routing.md +117 -0
- package/docs/zh-CN/concepts/compaction.md +67 -0
- package/docs/zh-CN/concepts/context.md +168 -0
- package/docs/zh-CN/concepts/group-messages.md +91 -0
- package/docs/zh-CN/concepts/groups.md +379 -0
- package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
- package/docs/zh-CN/concepts/memory.md +412 -0
- package/docs/zh-CN/concepts/messages.md +141 -0
- package/docs/zh-CN/concepts/model-failover.md +145 -0
- package/docs/zh-CN/concepts/model-providers.md +320 -0
- package/docs/zh-CN/concepts/models.md +196 -0
- package/docs/zh-CN/concepts/multi-agent.md +372 -0
- package/docs/zh-CN/concepts/oauth.md +151 -0
- package/docs/zh-CN/concepts/presence.md +99 -0
- package/docs/zh-CN/concepts/queue.md +94 -0
- package/docs/zh-CN/concepts/retry.md +76 -0
- package/docs/zh-CN/concepts/session-pruning.md +129 -0
- package/docs/zh-CN/concepts/session-tool.md +200 -0
- package/docs/zh-CN/concepts/session.md +166 -0
- package/docs/zh-CN/concepts/sessions.md +17 -0
- package/docs/zh-CN/concepts/streaming.md +133 -0
- package/docs/zh-CN/concepts/system-prompt.md +101 -0
- package/docs/zh-CN/concepts/timezone.md +96 -0
- package/docs/zh-CN/concepts/typebox.md +284 -0
- package/docs/zh-CN/concepts/typing-indicators.md +74 -0
- package/docs/zh-CN/concepts/usage-tracking.md +42 -0
- package/docs/zh-CN/date-time.md +129 -0
- package/docs/zh-CN/debug/node-issue.md +90 -0
- package/docs/zh-CN/debugging.md +160 -0
- package/docs/zh-CN/diagnostics/flags.md +98 -0
- package/docs/zh-CN/environment.md +88 -0
- package/docs/zh-CN/experiments/onboarding-config-protocol.md +47 -0
- package/docs/zh-CN/experiments/plans/cron-add-hardening.md +70 -0
- package/docs/zh-CN/experiments/plans/group-policy-hardening.md +45 -0
- package/docs/zh-CN/experiments/plans/openresponses-gateway.md +121 -0
- package/docs/zh-CN/experiments/proposals/model-config.md +42 -0
- package/docs/zh-CN/experiments/research/memory.md +235 -0
- package/docs/zh-CN/gateway/authentication.md +142 -0
- package/docs/zh-CN/gateway/background-process.md +100 -0
- package/docs/zh-CN/gateway/bonjour.md +174 -0
- package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
- package/docs/zh-CN/gateway/cli-backends.md +213 -0
- package/docs/zh-CN/gateway/configuration-examples.md +587 -0
- package/docs/zh-CN/gateway/configuration.md +3332 -0
- package/docs/zh-CN/gateway/discovery.md +123 -0
- package/docs/zh-CN/gateway/doctor.md +238 -0
- package/docs/zh-CN/gateway/gateway-lock.md +41 -0
- package/docs/zh-CN/gateway/health.md +42 -0
- package/docs/zh-CN/gateway/heartbeat.md +274 -0
- package/docs/zh-CN/gateway/index.md +335 -0
- package/docs/zh-CN/gateway/local-models.md +157 -0
- package/docs/zh-CN/gateway/logging.md +114 -0
- package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
- package/docs/zh-CN/gateway/openai-http-api.md +125 -0
- package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
- package/docs/zh-CN/gateway/pairing.md +99 -0
- package/docs/zh-CN/gateway/protocol.md +220 -0
- package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
- package/docs/zh-CN/gateway/remote.md +133 -0
- package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
- package/docs/zh-CN/gateway/sandboxing.md +188 -0
- package/docs/zh-CN/gateway/security/formal-verification.md +169 -0
- package/docs/zh-CN/gateway/security/index.md +777 -0
- package/docs/zh-CN/gateway/tailscale.md +124 -0
- package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
- package/docs/zh-CN/gateway/troubleshooting.md +771 -0
- package/docs/zh-CN/help/faq.md +2628 -0
- package/docs/zh-CN/help/index.md +28 -0
- package/docs/zh-CN/help/troubleshooting.md +104 -0
- package/docs/zh-CN/hooks/soul-evil.md +72 -0
- package/docs/zh-CN/hooks.md +919 -0
- package/docs/zh-CN/index.md +264 -0
- package/docs/zh-CN/install/ansible.md +215 -0
- package/docs/zh-CN/install/bun.md +65 -0
- package/docs/zh-CN/install/development-channels.md +81 -0
- package/docs/zh-CN/install/docker.md +532 -0
- package/docs/zh-CN/install/index.md +193 -0
- package/docs/zh-CN/install/installer.md +128 -0
- package/docs/zh-CN/install/migrating.md +199 -0
- package/docs/zh-CN/install/nix.md +99 -0
- package/docs/zh-CN/install/node.md +85 -0
- package/docs/zh-CN/install/uninstall.md +135 -0
- package/docs/zh-CN/install/updating.md +233 -0
- package/docs/zh-CN/logging.md +329 -0
- package/docs/zh-CN/multi-agent-sandbox-tools.md +401 -0
- package/docs/zh-CN/network.md +59 -0
- package/docs/zh-CN/nodes/audio.md +120 -0
- package/docs/zh-CN/nodes/camera.md +162 -0
- package/docs/zh-CN/nodes/images.md +79 -0
- package/docs/zh-CN/nodes/index.md +348 -0
- package/docs/zh-CN/nodes/location-command.md +120 -0
- package/docs/zh-CN/nodes/media-understanding.md +380 -0
- package/docs/zh-CN/nodes/talk.md +97 -0
- package/docs/zh-CN/nodes/voicewake.md +72 -0
- package/docs/zh-CN/northflank.mdx +60 -0
- package/docs/zh-CN/perplexity.md +84 -0
- package/docs/zh-CN/pi-dev.md +77 -0
- package/docs/zh-CN/pi.md +619 -0
- package/docs/zh-CN/platforms/android.md +155 -0
- package/docs/zh-CN/platforms/digitalocean.md +269 -0
- package/docs/zh-CN/platforms/exe-dev.md +127 -0
- package/docs/zh-CN/platforms/fly.md +490 -0
- package/docs/zh-CN/platforms/gcp.md +510 -0
- package/docs/zh-CN/platforms/hetzner.md +337 -0
- package/docs/zh-CN/platforms/index.md +60 -0
- package/docs/zh-CN/platforms/ios.md +114 -0
- package/docs/zh-CN/platforms/linux.md +101 -0
- package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
- package/docs/zh-CN/platforms/mac/canvas.md +128 -0
- package/docs/zh-CN/platforms/mac/child-process.md +73 -0
- package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
- package/docs/zh-CN/platforms/mac/health.md +41 -0
- package/docs/zh-CN/platforms/mac/icon.md +38 -0
- package/docs/zh-CN/platforms/mac/logging.md +64 -0
- package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
- package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
- package/docs/zh-CN/platforms/mac/permissions.md +46 -0
- package/docs/zh-CN/platforms/mac/release.md +92 -0
- package/docs/zh-CN/platforms/mac/remote.md +90 -0
- package/docs/zh-CN/platforms/mac/signing.md +54 -0
- package/docs/zh-CN/platforms/mac/skills.md +40 -0
- package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
- package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
- package/docs/zh-CN/platforms/mac/webchat.md +43 -0
- package/docs/zh-CN/platforms/mac/xpc.md +68 -0
- package/docs/zh-CN/platforms/macos-vm.md +288 -0
- package/docs/zh-CN/platforms/macos.md +193 -0
- package/docs/zh-CN/platforms/oracle.md +310 -0
- package/docs/zh-CN/platforms/raspberry-pi.md +365 -0
- package/docs/zh-CN/platforms/windows.md +156 -0
- package/docs/zh-CN/plugin.md +639 -0
- package/docs/zh-CN/plugins/agent-tools.md +99 -0
- package/docs/zh-CN/plugins/manifest.md +68 -0
- package/docs/zh-CN/plugins/voice-call.md +250 -0
- package/docs/zh-CN/plugins/zalouser.md +88 -0
- package/docs/zh-CN/prose.md +141 -0
- package/docs/zh-CN/providers/anthropic.md +159 -0
- package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
- package/docs/zh-CN/providers/deepgram.md +97 -0
- package/docs/zh-CN/providers/github-copilot.md +67 -0
- package/docs/zh-CN/providers/glm.md +39 -0
- package/docs/zh-CN/providers/index.md +68 -0
- package/docs/zh-CN/providers/minimax.md +206 -0
- package/docs/zh-CN/providers/models.md +55 -0
- package/docs/zh-CN/providers/moonshot.md +145 -0
- package/docs/zh-CN/providers/ollama.md +230 -0
- package/docs/zh-CN/providers/openai.md +68 -0
- package/docs/zh-CN/providers/opencode.md +41 -0
- package/docs/zh-CN/providers/openrouter.md +43 -0
- package/docs/zh-CN/providers/qwen.md +55 -0
- package/docs/zh-CN/providers/synthetic.md +102 -0
- package/docs/zh-CN/providers/venice.md +274 -0
- package/docs/zh-CN/providers/vercel-ai-gateway.md +57 -0
- package/docs/zh-CN/providers/xiaomi.md +68 -0
- package/docs/zh-CN/providers/zai.md +41 -0
- package/docs/zh-CN/railway.mdx +106 -0
- package/docs/zh-CN/refactor/clawnet.md +424 -0
- package/docs/zh-CN/refactor/exec-host.md +323 -0
- package/docs/zh-CN/refactor/outbound-session-mirroring.md +92 -0
- package/docs/zh-CN/refactor/plugin-sdk.md +221 -0
- package/docs/zh-CN/refactor/strict-config.md +100 -0
- package/docs/zh-CN/reference/AGENTS.default.md +131 -0
- package/docs/zh-CN/reference/RELEASING.md +123 -0
- package/docs/zh-CN/reference/api-usage-costs.md +136 -0
- package/docs/zh-CN/reference/device-models.md +54 -0
- package/docs/zh-CN/reference/rpc.md +48 -0
- package/docs/zh-CN/reference/session-management-compaction.md +287 -0
- package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
- package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
- package/docs/zh-CN/reference/templates/BOOT.md +17 -0
- package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
- package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
- package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
- package/docs/zh-CN/reference/templates/IDENTITY.md +35 -0
- package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
- package/docs/zh-CN/reference/templates/SOUL.md +49 -0
- package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
- package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
- package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
- package/docs/zh-CN/reference/templates/USER.md +30 -0
- package/docs/zh-CN/reference/test.md +57 -0
- package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
- package/docs/zh-CN/render.mdx +169 -0
- package/docs/zh-CN/scripts.md +35 -0
- package/docs/zh-CN/security/formal-verification.md +171 -0
- package/docs/zh-CN/start/getting-started.md +206 -0
- package/docs/zh-CN/start/hubs.md +191 -0
- package/docs/zh-CN/start/lore.md +226 -0
- package/docs/zh-CN/start/onboarding.md +105 -0
- package/docs/zh-CN/start/openclaw.md +248 -0
- package/docs/zh-CN/start/pairing.md +89 -0
- package/docs/zh-CN/start/setup.md +153 -0
- package/docs/zh-CN/start/showcase.md +423 -0
- package/docs/zh-CN/start/wizard.md +331 -0
- package/docs/zh-CN/testing.md +375 -0
- package/docs/zh-CN/token-use.md +119 -0
- package/docs/zh-CN/tools/agent-send.md +59 -0
- package/docs/zh-CN/tools/apply-patch.md +57 -0
- package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
- package/docs/zh-CN/tools/browser-login.md +75 -0
- package/docs/zh-CN/tools/browser.md +553 -0
- package/docs/zh-CN/tools/chrome-extension.md +183 -0
- package/docs/zh-CN/tools/clawhub.md +209 -0
- package/docs/zh-CN/tools/creating-skills.md +61 -0
- package/docs/zh-CN/tools/elevated.md +64 -0
- package/docs/zh-CN/tools/exec-approvals.md +234 -0
- package/docs/zh-CN/tools/exec.md +169 -0
- package/docs/zh-CN/tools/firecrawl.md +68 -0
- package/docs/zh-CN/tools/index.md +515 -0
- package/docs/zh-CN/tools/llm-task.md +117 -0
- package/docs/zh-CN/tools/lobster.md +349 -0
- package/docs/zh-CN/tools/reactions.md +29 -0
- package/docs/zh-CN/tools/skills-config.md +78 -0
- package/docs/zh-CN/tools/skills.md +279 -0
- package/docs/zh-CN/tools/slash-commands.md +205 -0
- package/docs/zh-CN/tools/subagents.md +156 -0
- package/docs/zh-CN/tools/thinking.md +80 -0
- package/docs/zh-CN/tools/web.md +257 -0
- package/docs/zh-CN/tts.md +375 -0
- package/docs/zh-CN/tui.md +166 -0
- package/docs/zh-CN/vps.md +47 -0
- package/docs/zh-CN/web/control-ui.md +191 -0
- package/docs/zh-CN/web/dashboard.md +53 -0
- package/docs/zh-CN/web/index.md +118 -0
- package/docs/zh-CN/web/webchat.md +56 -0
- package/extensions/bluebubbles/README.md +45 -0
- package/extensions/bluebubbles/index.ts +19 -0
- package/extensions/bluebubbles/node_modules/.bin/openclaw +21 -0
- package/extensions/bluebubbles/openclaw.plugin.json +9 -0
- package/extensions/bluebubbles/package.json +36 -0
- package/extensions/bluebubbles/src/accounts.ts +88 -0
- package/extensions/bluebubbles/src/actions.test.ts +650 -0
- package/extensions/bluebubbles/src/actions.ts +438 -0
- package/extensions/bluebubbles/src/attachments.test.ts +345 -0
- package/extensions/bluebubbles/src/attachments.ts +300 -0
- package/extensions/bluebubbles/src/channel.ts +414 -0
- package/extensions/bluebubbles/src/chat.test.ts +461 -0
- package/extensions/bluebubbles/src/chat.ts +378 -0
- package/extensions/bluebubbles/src/config-schema.ts +51 -0
- package/extensions/bluebubbles/src/media-send.ts +174 -0
- package/extensions/bluebubbles/src/monitor.test.ts +2342 -0
- package/extensions/bluebubbles/src/monitor.ts +2490 -0
- package/extensions/bluebubbles/src/onboarding.ts +352 -0
- package/extensions/bluebubbles/src/probe.ts +135 -0
- package/extensions/bluebubbles/src/reactions.test.ts +392 -0
- package/extensions/bluebubbles/src/reactions.ts +188 -0
- package/extensions/bluebubbles/src/runtime.ts +14 -0
- package/extensions/bluebubbles/src/send.test.ts +808 -0
- package/extensions/bluebubbles/src/send.ts +467 -0
- package/extensions/bluebubbles/src/targets.test.ts +183 -0
- package/extensions/bluebubbles/src/targets.ts +422 -0
- package/extensions/bluebubbles/src/types.ts +127 -0
- package/extensions/copilot-proxy/README.md +24 -0
- package/extensions/copilot-proxy/index.ts +148 -0
- package/extensions/copilot-proxy/node_modules/.bin/openclaw +21 -0
- package/extensions/copilot-proxy/openclaw.plugin.json +9 -0
- package/extensions/copilot-proxy/package.json +14 -0
- package/extensions/diagnostics-otel/index.ts +15 -0
- package/extensions/diagnostics-otel/node_modules/.bin/openclaw +21 -0
- package/extensions/diagnostics-otel/openclaw.plugin.json +8 -0
- package/extensions/diagnostics-otel/package.json +27 -0
- package/extensions/diagnostics-otel/src/service.test.ts +226 -0
- package/extensions/diagnostics-otel/src/service.ts +635 -0
- package/extensions/discord/index.ts +17 -0
- package/extensions/discord/node_modules/.bin/openclaw +21 -0
- package/extensions/discord/openclaw.plugin.json +9 -0
- package/extensions/discord/package.json +14 -0
- package/extensions/discord/src/channel.ts +422 -0
- package/extensions/discord/src/runtime.ts +14 -0
- package/extensions/feishu/README.md +47 -0
- package/extensions/feishu/index.ts +15 -0
- package/extensions/feishu/node_modules/.bin/openclaw +21 -0
- package/extensions/feishu/openclaw.plugin.json +9 -0
- package/extensions/feishu/package.json +33 -0
- package/extensions/feishu/src/channel.ts +276 -0
- package/extensions/feishu/src/config-schema.ts +46 -0
- package/extensions/feishu/src/onboarding.ts +278 -0
- package/extensions/google-antigravity-auth/README.md +24 -0
- package/extensions/google-antigravity-auth/index.ts +461 -0
- package/extensions/google-antigravity-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-antigravity-auth/openclaw.plugin.json +9 -0
- package/extensions/google-antigravity-auth/package.json +14 -0
- package/extensions/google-gemini-cli-auth/README.md +35 -0
- package/extensions/google-gemini-cli-auth/index.ts +88 -0
- package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-gemini-cli-auth/oauth.test.ts +240 -0
- package/extensions/google-gemini-cli-auth/oauth.ts +662 -0
- package/extensions/google-gemini-cli-auth/openclaw.plugin.json +9 -0
- package/extensions/google-gemini-cli-auth/package.json +14 -0
- package/extensions/googlechat/index.ts +19 -0
- package/extensions/googlechat/node_modules/.bin/openclaw +21 -0
- package/extensions/googlechat/openclaw.plugin.json +9 -0
- package/extensions/googlechat/package.json +39 -0
- package/extensions/googlechat/src/accounts.ts +147 -0
- package/extensions/googlechat/src/actions.ts +181 -0
- package/extensions/googlechat/src/api.test.ts +61 -0
- package/extensions/googlechat/src/api.ts +282 -0
- package/extensions/googlechat/src/auth.ts +123 -0
- package/extensions/googlechat/src/channel.ts +583 -0
- package/extensions/googlechat/src/monitor.test.ts +22 -0
- package/extensions/googlechat/src/monitor.ts +949 -0
- package/extensions/googlechat/src/onboarding.ts +269 -0
- package/extensions/googlechat/src/runtime.ts +14 -0
- package/extensions/googlechat/src/targets.test.ts +32 -0
- package/extensions/googlechat/src/targets.ts +65 -0
- package/extensions/googlechat/src/types.config.ts +3 -0
- package/extensions/googlechat/src/types.ts +73 -0
- package/extensions/imessage/index.ts +17 -0
- package/extensions/imessage/node_modules/.bin/openclaw +21 -0
- package/extensions/imessage/openclaw.plugin.json +9 -0
- package/extensions/imessage/package.json +14 -0
- package/extensions/imessage/src/channel.ts +294 -0
- package/extensions/imessage/src/runtime.ts +14 -0
- package/extensions/line/index.ts +19 -0
- package/extensions/line/node_modules/.bin/openclaw +21 -0
- package/extensions/line/openclaw.plugin.json +9 -0
- package/extensions/line/package.json +29 -0
- package/extensions/line/src/card-command.ts +344 -0
- package/extensions/line/src/channel.logout.test.ts +99 -0
- package/extensions/line/src/channel.sendPayload.test.ts +306 -0
- package/extensions/line/src/channel.ts +780 -0
- package/extensions/line/src/runtime.ts +14 -0
- package/extensions/llm-task/README.md +97 -0
- package/extensions/llm-task/index.ts +6 -0
- package/extensions/llm-task/node_modules/.bin/openclaw +21 -0
- package/extensions/llm-task/openclaw.plugin.json +21 -0
- package/extensions/llm-task/package.json +14 -0
- package/extensions/llm-task/src/llm-task-tool.test.ts +138 -0
- package/extensions/llm-task/src/llm-task-tool.ts +245 -0
- package/extensions/lobster/README.md +75 -0
- package/extensions/lobster/SKILL.md +97 -0
- package/extensions/lobster/index.ts +14 -0
- package/extensions/lobster/node_modules/.bin/openclaw +21 -0
- package/extensions/lobster/openclaw.plugin.json +10 -0
- package/extensions/lobster/package.json +14 -0
- package/extensions/lobster/src/lobster-tool.test.ts +247 -0
- package/extensions/lobster/src/lobster-tool.ts +328 -0
- package/extensions/matrix/CHANGELOG.md +87 -0
- package/extensions/matrix/index.ts +17 -0
- package/extensions/matrix/node_modules/.bin/markdown-it +21 -0
- package/extensions/matrix/node_modules/.bin/openclaw +21 -0
- package/extensions/matrix/openclaw.plugin.json +9 -0
- package/extensions/matrix/package.json +36 -0
- package/extensions/matrix/src/actions.ts +195 -0
- package/extensions/matrix/src/channel.directory.test.ts +64 -0
- package/extensions/matrix/src/channel.ts +439 -0
- package/extensions/matrix/src/config-schema.ts +62 -0
- package/extensions/matrix/src/directory-live.ts +188 -0
- package/extensions/matrix/src/group-mentions.ts +66 -0
- package/extensions/matrix/src/matrix/accounts.test.ts +82 -0
- package/extensions/matrix/src/matrix/accounts.ts +65 -0
- package/extensions/matrix/src/matrix/actions/client.ts +57 -0
- package/extensions/matrix/src/matrix/actions/messages.ts +128 -0
- package/extensions/matrix/src/matrix/actions/pins.ts +76 -0
- package/extensions/matrix/src/matrix/actions/reactions.ts +96 -0
- package/extensions/matrix/src/matrix/actions/room.ts +85 -0
- package/extensions/matrix/src/matrix/actions/summary.ts +75 -0
- package/extensions/matrix/src/matrix/actions/types.ts +84 -0
- package/extensions/matrix/src/matrix/actions.ts +15 -0
- package/extensions/matrix/src/matrix/active-client.ts +11 -0
- package/extensions/matrix/src/matrix/client/config.ts +160 -0
- package/extensions/matrix/src/matrix/client/create-client.ts +123 -0
- package/extensions/matrix/src/matrix/client/logging.ts +36 -0
- package/extensions/matrix/src/matrix/client/runtime.ts +4 -0
- package/extensions/matrix/src/matrix/client/shared.ts +170 -0
- package/extensions/matrix/src/matrix/client/storage.ts +131 -0
- package/extensions/matrix/src/matrix/client/types.ts +34 -0
- package/extensions/matrix/src/matrix/client.test.ts +56 -0
- package/extensions/matrix/src/matrix/client.ts +5 -0
- package/extensions/matrix/src/matrix/credentials.ts +105 -0
- package/extensions/matrix/src/matrix/deps.ts +60 -0
- package/extensions/matrix/src/matrix/format.test.ts +33 -0
- package/extensions/matrix/src/matrix/format.ts +22 -0
- package/extensions/matrix/src/matrix/index.ts +11 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.test.ts +45 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.ts +103 -0
- package/extensions/matrix/src/matrix/monitor/auto-join.ts +71 -0
- package/extensions/matrix/src/matrix/monitor/direct.ts +104 -0
- package/extensions/matrix/src/matrix/monitor/events.ts +101 -0
- package/extensions/matrix/src/matrix/monitor/handler.ts +661 -0
- package/extensions/matrix/src/matrix/monitor/index.ts +338 -0
- package/extensions/matrix/src/matrix/monitor/location.ts +100 -0
- package/extensions/matrix/src/matrix/monitor/media.test.ts +102 -0
- package/extensions/matrix/src/matrix/monitor/media.ts +113 -0
- package/extensions/matrix/src/matrix/monitor/mentions.ts +31 -0
- package/extensions/matrix/src/matrix/monitor/replies.ts +97 -0
- package/extensions/matrix/src/matrix/monitor/room-info.ts +55 -0
- package/extensions/matrix/src/matrix/monitor/rooms.test.ts +39 -0
- package/extensions/matrix/src/matrix/monitor/rooms.ts +47 -0
- package/extensions/matrix/src/matrix/monitor/threads.ts +68 -0
- package/extensions/matrix/src/matrix/monitor/types.ts +39 -0
- package/extensions/matrix/src/matrix/poll-types.test.ts +21 -0
- package/extensions/matrix/src/matrix/poll-types.ts +166 -0
- package/extensions/matrix/src/matrix/probe.ts +70 -0
- package/extensions/matrix/src/matrix/send/client.ts +66 -0
- package/extensions/matrix/src/matrix/send/formatting.ts +89 -0
- package/extensions/matrix/src/matrix/send/media.ts +229 -0
- package/extensions/matrix/src/matrix/send/targets.test.ts +98 -0
- package/extensions/matrix/src/matrix/send/targets.ts +136 -0
- package/extensions/matrix/src/matrix/send/types.ts +109 -0
- package/extensions/matrix/src/matrix/send.test.ts +171 -0
- package/extensions/matrix/src/matrix/send.ts +260 -0
- package/extensions/matrix/src/onboarding.ts +449 -0
- package/extensions/matrix/src/outbound.ts +52 -0
- package/extensions/matrix/src/resolve-targets.test.ts +48 -0
- package/extensions/matrix/src/resolve-targets.ts +135 -0
- package/extensions/matrix/src/runtime.ts +14 -0
- package/extensions/matrix/src/tool-actions.ts +164 -0
- package/extensions/matrix/src/types.ts +95 -0
- package/extensions/mattermost/index.ts +17 -0
- package/extensions/mattermost/node_modules/.bin/openclaw +21 -0
- package/extensions/mattermost/openclaw.plugin.json +9 -0
- package/extensions/mattermost/package.json +28 -0
- package/extensions/mattermost/src/channel.test.ts +48 -0
- package/extensions/mattermost/src/channel.ts +337 -0
- package/extensions/mattermost/src/config-schema.ts +55 -0
- package/extensions/mattermost/src/group-mentions.ts +15 -0
- package/extensions/mattermost/src/mattermost/accounts.ts +128 -0
- package/extensions/mattermost/src/mattermost/client.ts +220 -0
- package/extensions/mattermost/src/mattermost/index.ts +9 -0
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +166 -0
- package/extensions/mattermost/src/mattermost/monitor.ts +987 -0
- package/extensions/mattermost/src/mattermost/probe.ts +74 -0
- package/extensions/mattermost/src/mattermost/send.ts +231 -0
- package/extensions/mattermost/src/normalize.ts +46 -0
- package/extensions/mattermost/src/onboarding-helpers.ts +44 -0
- package/extensions/mattermost/src/onboarding.ts +186 -0
- package/extensions/mattermost/src/runtime.ts +14 -0
- package/extensions/mattermost/src/types.ts +50 -0
- package/extensions/memory-core/index.ts +38 -0
- package/extensions/memory-core/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-core/openclaw.plugin.json +9 -0
- package/extensions/memory-core/package.json +17 -0
- package/extensions/memory-lancedb/config.ts +139 -0
- package/extensions/memory-lancedb/index.test.ts +295 -0
- package/extensions/memory-lancedb/index.ts +608 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
- package/extensions/memory-lancedb/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-lancedb/openclaw.plugin.json +60 -0
- package/extensions/memory-lancedb/package.json +19 -0
- package/extensions/minimax-portal-auth/README.md +33 -0
- package/extensions/minimax-portal-auth/index.ts +155 -0
- package/extensions/minimax-portal-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/minimax-portal-auth/oauth.ts +247 -0
- package/extensions/minimax-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/minimax-portal-auth/package.json +14 -0
- package/extensions/msteams/CHANGELOG.md +83 -0
- package/extensions/msteams/index.ts +17 -0
- package/extensions/msteams/node_modules/.bin/openclaw +21 -0
- package/extensions/msteams/openclaw.plugin.json +9 -0
- package/extensions/msteams/package.json +39 -0
- package/extensions/msteams/src/attachments/download.ts +283 -0
- package/extensions/msteams/src/attachments/graph.ts +353 -0
- package/extensions/msteams/src/attachments/html.ts +90 -0
- package/extensions/msteams/src/attachments/payload.ts +22 -0
- package/extensions/msteams/src/attachments/shared.ts +291 -0
- package/extensions/msteams/src/attachments/types.ts +37 -0
- package/extensions/msteams/src/attachments.test.ts +459 -0
- package/extensions/msteams/src/attachments.ts +18 -0
- package/extensions/msteams/src/channel.directory.test.ts +48 -0
- package/extensions/msteams/src/channel.ts +459 -0
- package/extensions/msteams/src/conversation-store-fs.test.ts +88 -0
- package/extensions/msteams/src/conversation-store-fs.ts +165 -0
- package/extensions/msteams/src/conversation-store-memory.ts +47 -0
- package/extensions/msteams/src/conversation-store.ts +41 -0
- package/extensions/msteams/src/directory-live.ts +205 -0
- package/extensions/msteams/src/errors.test.ts +45 -0
- package/extensions/msteams/src/errors.ts +190 -0
- package/extensions/msteams/src/file-consent-helpers.test.ts +243 -0
- package/extensions/msteams/src/file-consent-helpers.ts +73 -0
- package/extensions/msteams/src/file-consent.ts +126 -0
- package/extensions/msteams/src/graph-chat.ts +53 -0
- package/extensions/msteams/src/graph-upload.ts +453 -0
- package/extensions/msteams/src/inbound.test.ts +66 -0
- package/extensions/msteams/src/inbound.ts +48 -0
- package/extensions/msteams/src/index.ts +4 -0
- package/extensions/msteams/src/media-helpers.test.ts +189 -0
- package/extensions/msteams/src/media-helpers.ts +86 -0
- package/extensions/msteams/src/messenger.test.ts +248 -0
- package/extensions/msteams/src/messenger.ts +495 -0
- package/extensions/msteams/src/monitor-handler/inbound-media.ts +128 -0
- package/extensions/msteams/src/monitor-handler/message-handler.ts +640 -0
- package/extensions/msteams/src/monitor-handler.ts +162 -0
- package/extensions/msteams/src/monitor-types.ts +5 -0
- package/extensions/msteams/src/monitor.ts +295 -0
- package/extensions/msteams/src/onboarding.ts +431 -0
- package/extensions/msteams/src/outbound.ts +46 -0
- package/extensions/msteams/src/pending-uploads.ts +89 -0
- package/extensions/msteams/src/policy.test.ts +209 -0
- package/extensions/msteams/src/policy.ts +273 -0
- package/extensions/msteams/src/polls-store-memory.ts +32 -0
- package/extensions/msteams/src/polls-store.test.ts +38 -0
- package/extensions/msteams/src/polls.test.ts +72 -0
- package/extensions/msteams/src/polls.ts +315 -0
- package/extensions/msteams/src/probe.test.ts +58 -0
- package/extensions/msteams/src/probe.ts +107 -0
- package/extensions/msteams/src/reply-dispatcher.ts +130 -0
- package/extensions/msteams/src/resolve-allowlist.ts +297 -0
- package/extensions/msteams/src/runtime.ts +14 -0
- package/extensions/msteams/src/sdk-types.ts +19 -0
- package/extensions/msteams/src/sdk.ts +33 -0
- package/extensions/msteams/src/send-context.ts +164 -0
- package/extensions/msteams/src/send.ts +519 -0
- package/extensions/msteams/src/sent-message-cache.test.ts +15 -0
- package/extensions/msteams/src/sent-message-cache.ts +47 -0
- package/extensions/msteams/src/storage.ts +25 -0
- package/extensions/msteams/src/store-fs.ts +83 -0
- package/extensions/msteams/src/token.ts +19 -0
- package/extensions/nextcloud-talk/index.ts +17 -0
- package/extensions/nextcloud-talk/node_modules/.bin/openclaw +21 -0
- package/extensions/nextcloud-talk/openclaw.plugin.json +9 -0
- package/extensions/nextcloud-talk/package.json +33 -0
- package/extensions/nextcloud-talk/src/accounts.ts +174 -0
- package/extensions/nextcloud-talk/src/channel.ts +409 -0
- package/extensions/nextcloud-talk/src/config-schema.ts +78 -0
- package/extensions/nextcloud-talk/src/format.ts +79 -0
- package/extensions/nextcloud-talk/src/inbound.ts +317 -0
- package/extensions/nextcloud-talk/src/monitor.ts +246 -0
- package/extensions/nextcloud-talk/src/normalize.ts +39 -0
- package/extensions/nextcloud-talk/src/onboarding.ts +343 -0
- package/extensions/nextcloud-talk/src/policy.test.ts +33 -0
- package/extensions/nextcloud-talk/src/policy.ts +180 -0
- package/extensions/nextcloud-talk/src/room-info.ts +125 -0
- package/extensions/nextcloud-talk/src/runtime.ts +14 -0
- package/extensions/nextcloud-talk/src/send.ts +210 -0
- package/extensions/nextcloud-talk/src/signature.ts +72 -0
- package/extensions/nextcloud-talk/src/types.ts +179 -0
- package/extensions/nostr/CHANGELOG.md +74 -0
- package/extensions/nostr/README.md +136 -0
- package/extensions/nostr/index.ts +68 -0
- package/extensions/nostr/node_modules/.bin/openclaw +21 -0
- package/extensions/nostr/openclaw.plugin.json +9 -0
- package/extensions/nostr/package.json +34 -0
- package/extensions/nostr/src/channel.test.ts +151 -0
- package/extensions/nostr/src/channel.ts +353 -0
- package/extensions/nostr/src/config-schema.ts +90 -0
- package/extensions/nostr/src/metrics.ts +478 -0
- package/extensions/nostr/src/nostr-bus.fuzz.test.ts +533 -0
- package/extensions/nostr/src/nostr-bus.integration.test.ts +448 -0
- package/extensions/nostr/src/nostr-bus.test.ts +199 -0
- package/extensions/nostr/src/nostr-bus.ts +715 -0
- package/extensions/nostr/src/nostr-profile-http.test.ts +378 -0
- package/extensions/nostr/src/nostr-profile-http.ts +519 -0
- package/extensions/nostr/src/nostr-profile-import.test.ts +119 -0
- package/extensions/nostr/src/nostr-profile-import.ts +262 -0
- package/extensions/nostr/src/nostr-profile.fuzz.test.ts +477 -0
- package/extensions/nostr/src/nostr-profile.test.ts +410 -0
- package/extensions/nostr/src/nostr-profile.ts +277 -0
- package/extensions/nostr/src/nostr-state-store.test.ts +131 -0
- package/extensions/nostr/src/nostr-state-store.ts +226 -0
- package/extensions/nostr/src/runtime.ts +14 -0
- package/extensions/nostr/src/seen-tracker.ts +303 -0
- package/extensions/nostr/src/types.test.ts +157 -0
- package/extensions/nostr/src/types.ts +101 -0
- package/extensions/nostr/test/setup.ts +5 -0
- package/extensions/open-prose/README.md +25 -0
- package/extensions/open-prose/index.ts +5 -0
- package/extensions/open-prose/node_modules/.bin/openclaw +21 -0
- package/extensions/open-prose/openclaw.plugin.json +11 -0
- package/extensions/open-prose/package.json +14 -0
- package/extensions/open-prose/skills/prose/LICENSE +21 -0
- package/extensions/open-prose/skills/prose/SKILL.md +323 -0
- package/extensions/open-prose/skills/prose/alt-borges.md +141 -0
- package/extensions/open-prose/skills/prose/alts/arabian-nights.md +358 -0
- package/extensions/open-prose/skills/prose/alts/borges.md +360 -0
- package/extensions/open-prose/skills/prose/alts/folk.md +322 -0
- package/extensions/open-prose/skills/prose/alts/homer.md +346 -0
- package/extensions/open-prose/skills/prose/alts/kafka.md +373 -0
- package/extensions/open-prose/skills/prose/compiler.md +2971 -0
- package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +4 -0
- package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +6 -0
- package/extensions/open-prose/skills/prose/examples/03-code-review.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +14 -0
- package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/07-refactor.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +25 -0
- package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +27 -0
- package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +43 -0
- package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +48 -0
- package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +23 -0
- package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +36 -0
- package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +71 -0
- package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +35 -0
- package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +63 -0
- package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +86 -0
- package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +114 -0
- package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +100 -0
- package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +105 -0
- package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +37 -0
- package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +1572 -0
- package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +218 -0
- package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +42 -0
- package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +145 -0
- package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +168 -0
- package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +204 -0
- package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +296 -0
- package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +237 -0
- package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +1474 -0
- package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +455 -0
- package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +277 -0
- package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +38 -0
- package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +46 -0
- package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +50 -0
- package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +261 -0
- package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +159 -0
- package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +637 -0
- package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +148 -0
- package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +225 -0
- package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +356 -0
- package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +445 -0
- package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +210 -0
- package/extensions/open-prose/skills/prose/examples/README.md +391 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/README.md +22 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +18 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +223 -0
- package/extensions/open-prose/skills/prose/guidance/antipatterns.md +951 -0
- package/extensions/open-prose/skills/prose/guidance/patterns.md +700 -0
- package/extensions/open-prose/skills/prose/guidance/system-prompt.md +180 -0
- package/extensions/open-prose/skills/prose/help.md +144 -0
- package/extensions/open-prose/skills/prose/lib/README.md +108 -0
- package/extensions/open-prose/skills/prose/lib/calibrator.prose +215 -0
- package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +174 -0
- package/extensions/open-prose/skills/prose/lib/error-forensics.prose +250 -0
- package/extensions/open-prose/skills/prose/lib/inspector.prose +196 -0
- package/extensions/open-prose/skills/prose/lib/profiler.prose +460 -0
- package/extensions/open-prose/skills/prose/lib/program-improver.prose +275 -0
- package/extensions/open-prose/skills/prose/lib/project-memory.prose +118 -0
- package/extensions/open-prose/skills/prose/lib/user-memory.prose +93 -0
- package/extensions/open-prose/skills/prose/lib/vm-improver.prose +243 -0
- package/extensions/open-prose/skills/prose/primitives/session.md +593 -0
- package/extensions/open-prose/skills/prose/prose.md +1237 -0
- package/extensions/open-prose/skills/prose/state/filesystem.md +498 -0
- package/extensions/open-prose/skills/prose/state/in-context.md +384 -0
- package/extensions/open-prose/skills/prose/state/postgres.md +880 -0
- package/extensions/open-prose/skills/prose/state/sqlite.md +574 -0
- package/extensions/qwen-portal-auth/README.md +24 -0
- package/extensions/qwen-portal-auth/index.ts +130 -0
- package/extensions/qwen-portal-auth/oauth.ts +190 -0
- package/extensions/qwen-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/signal/index.ts +17 -0
- package/extensions/signal/node_modules/.bin/openclaw +21 -0
- package/extensions/signal/openclaw.plugin.json +9 -0
- package/extensions/signal/package.json +14 -0
- package/extensions/signal/src/channel.ts +315 -0
- package/extensions/signal/src/runtime.ts +14 -0
- package/extensions/slack/index.ts +17 -0
- package/extensions/slack/node_modules/.bin/openclaw +21 -0
- package/extensions/slack/openclaw.plugin.json +9 -0
- package/extensions/slack/package.json +14 -0
- package/extensions/slack/src/channel.ts +604 -0
- package/extensions/slack/src/runtime.ts +14 -0
- package/extensions/telegram/index.ts +17 -0
- package/extensions/telegram/node_modules/.bin/openclaw +21 -0
- package/extensions/telegram/openclaw.plugin.json +9 -0
- package/extensions/telegram/package.json +14 -0
- package/extensions/telegram/src/channel.ts +482 -0
- package/extensions/telegram/src/runtime.ts +14 -0
- package/extensions/tlon/README.md +5 -0
- package/extensions/tlon/index.ts +17 -0
- package/extensions/tlon/node_modules/.bin/openclaw +21 -0
- package/extensions/tlon/openclaw.plugin.json +9 -0
- package/extensions/tlon/package.json +33 -0
- package/extensions/tlon/src/channel.ts +392 -0
- package/extensions/tlon/src/config-schema.test.ts +31 -0
- package/extensions/tlon/src/config-schema.ts +43 -0
- package/extensions/tlon/src/monitor/discovery.ts +76 -0
- package/extensions/tlon/src/monitor/history.ts +90 -0
- package/extensions/tlon/src/monitor/index.ts +553 -0
- package/extensions/tlon/src/monitor/processed-messages.test.ts +23 -0
- package/extensions/tlon/src/monitor/processed-messages.ts +46 -0
- package/extensions/tlon/src/monitor/utils.ts +105 -0
- package/extensions/tlon/src/onboarding.ts +214 -0
- package/extensions/tlon/src/runtime.ts +14 -0
- package/extensions/tlon/src/targets.ts +89 -0
- package/extensions/tlon/src/types.ts +92 -0
- package/extensions/tlon/src/urbit/auth.ts +18 -0
- package/extensions/tlon/src/urbit/http-api.ts +38 -0
- package/extensions/tlon/src/urbit/send.test.ts +38 -0
- package/extensions/tlon/src/urbit/send.ts +131 -0
- package/extensions/tlon/src/urbit/sse-client.test.ts +40 -0
- package/extensions/tlon/src/urbit/sse-client.ts +395 -0
- package/extensions/twitch/CHANGELOG.md +45 -0
- package/extensions/twitch/README.md +89 -0
- package/extensions/twitch/index.ts +20 -0
- package/extensions/twitch/node_modules/.bin/openclaw +21 -0
- package/extensions/twitch/openclaw.plugin.json +9 -0
- package/extensions/twitch/package.json +20 -0
- package/extensions/twitch/src/access-control.test.ts +489 -0
- package/extensions/twitch/src/access-control.ts +166 -0
- package/extensions/twitch/src/actions.ts +173 -0
- package/extensions/twitch/src/client-manager-registry.ts +115 -0
- package/extensions/twitch/src/config-schema.ts +82 -0
- package/extensions/twitch/src/config.test.ts +87 -0
- package/extensions/twitch/src/config.ts +116 -0
- package/extensions/twitch/src/monitor.ts +261 -0
- package/extensions/twitch/src/onboarding.test.ts +311 -0
- package/extensions/twitch/src/onboarding.ts +417 -0
- package/extensions/twitch/src/outbound.test.ts +373 -0
- package/extensions/twitch/src/outbound.ts +184 -0
- package/extensions/twitch/src/plugin.test.ts +39 -0
- package/extensions/twitch/src/plugin.ts +274 -0
- package/extensions/twitch/src/probe.test.ts +195 -0
- package/extensions/twitch/src/probe.ts +120 -0
- package/extensions/twitch/src/resolver.ts +137 -0
- package/extensions/twitch/src/runtime.ts +14 -0
- package/extensions/twitch/src/send.test.ts +289 -0
- package/extensions/twitch/src/send.ts +136 -0
- package/extensions/twitch/src/status.test.ts +270 -0
- package/extensions/twitch/src/status.ts +178 -0
- package/extensions/twitch/src/token.test.ts +171 -0
- package/extensions/twitch/src/token.ts +91 -0
- package/extensions/twitch/src/twitch-client.test.ts +589 -0
- package/extensions/twitch/src/twitch-client.ts +277 -0
- package/extensions/twitch/src/types.ts +141 -0
- package/extensions/twitch/src/utils/markdown.ts +98 -0
- package/extensions/twitch/src/utils/twitch.ts +78 -0
- package/extensions/twitch/test/setup.ts +7 -0
- package/extensions/voice-call/CHANGELOG.md +109 -0
- package/extensions/voice-call/README.md +139 -0
- package/extensions/voice-call/index.ts +493 -0
- package/extensions/voice-call/node_modules/.bin/openclaw +21 -0
- package/extensions/voice-call/openclaw.plugin.json +559 -0
- package/extensions/voice-call/package.json +19 -0
- package/extensions/voice-call/src/allowlist.ts +19 -0
- package/extensions/voice-call/src/cli.ts +279 -0
- package/extensions/voice-call/src/config.test.ts +234 -0
- package/extensions/voice-call/src/config.ts +523 -0
- package/extensions/voice-call/src/core-bridge.ts +159 -0
- package/extensions/voice-call/src/manager/context.ts +21 -0
- package/extensions/voice-call/src/manager/events.ts +188 -0
- package/extensions/voice-call/src/manager/lookup.ts +35 -0
- package/extensions/voice-call/src/manager/outbound.ts +275 -0
- package/extensions/voice-call/src/manager/state.ts +48 -0
- package/extensions/voice-call/src/manager/store.ts +91 -0
- package/extensions/voice-call/src/manager/timers.ts +89 -0
- package/extensions/voice-call/src/manager/twiml.ts +9 -0
- package/extensions/voice-call/src/manager.test.ts +194 -0
- package/extensions/voice-call/src/manager.ts +887 -0
- package/extensions/voice-call/src/media-stream.test.ts +96 -0
- package/extensions/voice-call/src/media-stream.ts +411 -0
- package/extensions/voice-call/src/providers/base.ts +67 -0
- package/extensions/voice-call/src/providers/index.ts +10 -0
- package/extensions/voice-call/src/providers/mock.ts +165 -0
- package/extensions/voice-call/src/providers/plivo.test.ts +27 -0
- package/extensions/voice-call/src/providers/plivo.ts +515 -0
- package/extensions/voice-call/src/providers/stt-openai-realtime.ts +311 -0
- package/extensions/voice-call/src/providers/telnyx.ts +371 -0
- package/extensions/voice-call/src/providers/tts-openai.ts +259 -0
- package/extensions/voice-call/src/providers/twilio/api.ts +42 -0
- package/extensions/voice-call/src/providers/twilio/webhook.ts +32 -0
- package/extensions/voice-call/src/providers/twilio.test.ts +60 -0
- package/extensions/voice-call/src/providers/twilio.ts +626 -0
- package/extensions/voice-call/src/response-generator.ts +158 -0
- package/extensions/voice-call/src/runtime.ts +212 -0
- package/extensions/voice-call/src/telephony-audio.ts +90 -0
- package/extensions/voice-call/src/telephony-tts.ts +104 -0
- package/extensions/voice-call/src/tunnel.ts +314 -0
- package/extensions/voice-call/src/types.ts +272 -0
- package/extensions/voice-call/src/utils.ts +14 -0
- package/extensions/voice-call/src/voice-mapping.ts +67 -0
- package/extensions/voice-call/src/webhook-security.test.ts +377 -0
- package/extensions/voice-call/src/webhook-security.ts +689 -0
- package/extensions/voice-call/src/webhook.ts +491 -0
- package/extensions/whatsapp/index.ts +17 -0
- package/extensions/whatsapp/node_modules/.bin/openclaw +21 -0
- package/extensions/whatsapp/openclaw.plugin.json +9 -0
- package/extensions/whatsapp/package.json +14 -0
- package/extensions/whatsapp/src/channel.ts +508 -0
- package/extensions/whatsapp/src/runtime.ts +14 -0
- package/extensions/zalo/CHANGELOG.md +89 -0
- package/extensions/zalo/README.md +50 -0
- package/extensions/zalo/index.ts +19 -0
- package/extensions/zalo/node_modules/.bin/openclaw +21 -0
- package/extensions/zalo/openclaw.plugin.json +9 -0
- package/extensions/zalo/package.json +36 -0
- package/extensions/zalo/src/accounts.ts +80 -0
- package/extensions/zalo/src/actions.ts +67 -0
- package/extensions/zalo/src/api.ts +208 -0
- package/extensions/zalo/src/channel.directory.test.ts +43 -0
- package/extensions/zalo/src/channel.ts +414 -0
- package/extensions/zalo/src/config-schema.ts +24 -0
- package/extensions/zalo/src/monitor.ts +753 -0
- package/extensions/zalo/src/monitor.webhook.test.ts +73 -0
- package/extensions/zalo/src/onboarding.ts +401 -0
- package/extensions/zalo/src/probe.ts +46 -0
- package/extensions/zalo/src/proxy.ts +21 -0
- package/extensions/zalo/src/runtime.ts +14 -0
- package/extensions/zalo/src/send.ts +124 -0
- package/extensions/zalo/src/status-issues.ts +53 -0
- package/extensions/zalo/src/token.ts +63 -0
- package/extensions/zalo/src/types.ts +42 -0
- package/extensions/zalouser/CHANGELOG.md +61 -0
- package/extensions/zalouser/README.md +225 -0
- package/extensions/zalouser/index.ts +31 -0
- package/extensions/zalouser/node_modules/.bin/openclaw +21 -0
- package/extensions/zalouser/openclaw.plugin.json +9 -0
- package/extensions/zalouser/package.json +36 -0
- package/extensions/zalouser/src/accounts.ts +135 -0
- package/extensions/zalouser/src/channel.test.ts +18 -0
- package/extensions/zalouser/src/channel.ts +686 -0
- package/extensions/zalouser/src/config-schema.ts +27 -0
- package/extensions/zalouser/src/monitor.ts +590 -0
- package/extensions/zalouser/src/onboarding.ts +504 -0
- package/extensions/zalouser/src/probe.ts +28 -0
- package/extensions/zalouser/src/runtime.ts +14 -0
- package/extensions/zalouser/src/send.ts +160 -0
- package/extensions/zalouser/src/status-issues.test.ts +57 -0
- package/extensions/zalouser/src/status-issues.ts +89 -0
- package/extensions/zalouser/src/tool.ts +164 -0
- package/extensions/zalouser/src/types.ts +108 -0
- package/extensions/zalouser/src/zca.ts +202 -0
- package/openclaw.mjs +14 -0
- package/package.json +245 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +96 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/bird/SKILL.md +224 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +131 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +198 -0
- package/skills/clawhub/SKILL.md +77 -0
- package/skills/coding-agent/SKILL.md +284 -0
- package/skills/discord/SKILL.md +578 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/food-order/SKILL.md +48 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/ghostly-projects/SKILL.md +160 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +74 -0
- package/skills/linear/SKILL.md +111 -0
- package/skills/linear/linear.sh +204 -0
- package/skills/local-places/SERVER_README.md +101 -0
- package/skills/local-places/SKILL.md +102 -0
- package/skills/local-places/pyproject.toml +21 -0
- package/skills/local-places/src/local_places/__init__.py +2 -0
- package/skills/local-places/src/local_places/google_places.py +314 -0
- package/skills/local-places/src/local_places/main.py +65 -0
- package/skills/local-places/src/local_places/schemas.py +107 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/model-usage/references/codexbar-cli.md +33 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/nano-banana-pro/SKILL.md +58 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/notion/SKILL.md +172 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-image-gen/SKILL.md +89 -0
- package/skills/openai-image-gen/scripts/gen.py +240 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +52 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +51 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +115 -0
- package/skills/sherpa-onnx-tts/SKILL.md +103 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +370 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +111 -0
- package/skills/skill-creator/scripts/quick_validate.py +101 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +46 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +135 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +95 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +54 -0
|
@@ -0,0 +1,2410 @@
|
|
|
1
|
+
import { f as resolveConfigDir } from "./utils-CKSrBNwq.js";
|
|
2
|
+
import { n as runExec } from "./exec-HEWTMJ7j.js";
|
|
3
|
+
import { t as parseBooleanValue } from "./boolean-Wzu0-e0P.js";
|
|
4
|
+
import { c as writeConfigFile, i as loadConfig } from "./config-BtSTwPcH.js";
|
|
5
|
+
import { A as DEFAULT_BROWSER_DEFAULT_PROFILE_NAME, D as DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH, O as DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS, a as resolveOpenClawUserDataDir, h as captureScreenshot, k as DEFAULT_AI_SNAPSHOT_MAX_CHARS, m as resolveBrowserExecutableForPlatform, y as snapshotAria } from "./chrome-BZ9K48w9.js";
|
|
6
|
+
import { a as resolveProfile, c as getUsedColors, d as deriveDefaultBrowserCdpPortRange, f as getPwAiModule$1, l as getUsedPorts, n as movePathToTrash, o as allocateCdpPort, r as parseHttpUrl, s as allocateColor, u as isValidProfileName } from "./server-context-B9GX5GOI.js";
|
|
7
|
+
import os from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import fs$1 from "node:fs/promises";
|
|
11
|
+
import crypto from "node:crypto";
|
|
12
|
+
import { pipeline } from "node:stream/promises";
|
|
13
|
+
import { lookup } from "node:dns";
|
|
14
|
+
import { lookup as lookup$1 } from "node:dns/promises";
|
|
15
|
+
import { Agent } from "undici";
|
|
16
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
17
|
+
|
|
18
|
+
//#region src/browser/routes/agent.act.shared.ts
|
|
19
|
+
const ACT_KINDS = [
|
|
20
|
+
"click",
|
|
21
|
+
"close",
|
|
22
|
+
"drag",
|
|
23
|
+
"evaluate",
|
|
24
|
+
"fill",
|
|
25
|
+
"hover",
|
|
26
|
+
"scrollIntoView",
|
|
27
|
+
"press",
|
|
28
|
+
"resize",
|
|
29
|
+
"select",
|
|
30
|
+
"type",
|
|
31
|
+
"wait"
|
|
32
|
+
];
|
|
33
|
+
function isActKind(value) {
|
|
34
|
+
if (typeof value !== "string") return false;
|
|
35
|
+
return ACT_KINDS.includes(value);
|
|
36
|
+
}
|
|
37
|
+
const ALLOWED_CLICK_MODIFIERS = new Set([
|
|
38
|
+
"Alt",
|
|
39
|
+
"Control",
|
|
40
|
+
"ControlOrMeta",
|
|
41
|
+
"Meta",
|
|
42
|
+
"Shift"
|
|
43
|
+
]);
|
|
44
|
+
function parseClickButton(raw) {
|
|
45
|
+
if (raw === "left" || raw === "right" || raw === "middle") return raw;
|
|
46
|
+
}
|
|
47
|
+
function parseClickModifiers(raw) {
|
|
48
|
+
if (raw.filter((m) => !ALLOWED_CLICK_MODIFIERS.has(m)).length) return { error: "modifiers must be Alt|Control|ControlOrMeta|Meta|Shift" };
|
|
49
|
+
return { modifiers: raw.length ? raw : void 0 };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/browser/routes/utils.ts
|
|
54
|
+
/**
|
|
55
|
+
* Extract profile name from query string or body and get profile context.
|
|
56
|
+
* Query string takes precedence over body for consistency with GET routes.
|
|
57
|
+
*/
|
|
58
|
+
function getProfileContext(req, ctx) {
|
|
59
|
+
let profileName;
|
|
60
|
+
if (typeof req.query.profile === "string") profileName = req.query.profile.trim() || void 0;
|
|
61
|
+
if (!profileName && req.body && typeof req.body === "object") {
|
|
62
|
+
const body = req.body;
|
|
63
|
+
if (typeof body.profile === "string") profileName = body.profile.trim() || void 0;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
return ctx.forProfile(profileName);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
return {
|
|
69
|
+
error: String(err),
|
|
70
|
+
status: 404
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function jsonError(res, status, message) {
|
|
75
|
+
res.status(status).json({ error: message });
|
|
76
|
+
}
|
|
77
|
+
function toStringOrEmpty(value) {
|
|
78
|
+
if (typeof value === "string") return value.trim();
|
|
79
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value).trim();
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
function toNumber(value) {
|
|
83
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
84
|
+
if (typeof value === "string" && value.trim()) {
|
|
85
|
+
const parsed = Number(value);
|
|
86
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function toBoolean(value) {
|
|
90
|
+
return parseBooleanValue(value, {
|
|
91
|
+
truthy: [
|
|
92
|
+
"true",
|
|
93
|
+
"1",
|
|
94
|
+
"yes"
|
|
95
|
+
],
|
|
96
|
+
falsy: [
|
|
97
|
+
"false",
|
|
98
|
+
"0",
|
|
99
|
+
"no"
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function toStringArray(value) {
|
|
104
|
+
if (!Array.isArray(value)) return;
|
|
105
|
+
const strings = value.map((v) => toStringOrEmpty(v)).filter(Boolean);
|
|
106
|
+
return strings.length ? strings : void 0;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/browser/routes/agent.shared.ts
|
|
111
|
+
const SELECTOR_UNSUPPORTED_MESSAGE = [
|
|
112
|
+
"Error: 'selector' is not supported. Use 'ref' from snapshot instead.",
|
|
113
|
+
"",
|
|
114
|
+
"Example workflow:",
|
|
115
|
+
"1. snapshot action to get page state with refs",
|
|
116
|
+
"2. act with ref: \"e123\" to interact with element",
|
|
117
|
+
"",
|
|
118
|
+
"This is more reliable for modern SPAs."
|
|
119
|
+
].join("\n");
|
|
120
|
+
function readBody(req) {
|
|
121
|
+
const body = req.body;
|
|
122
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return {};
|
|
123
|
+
return body;
|
|
124
|
+
}
|
|
125
|
+
function handleRouteError(ctx, res, err) {
|
|
126
|
+
const mapped = ctx.mapTabError(err);
|
|
127
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
128
|
+
jsonError(res, 500, String(err));
|
|
129
|
+
}
|
|
130
|
+
function resolveProfileContext(req, res, ctx) {
|
|
131
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
132
|
+
if ("error" in profileCtx) {
|
|
133
|
+
jsonError(res, profileCtx.status, profileCtx.error);
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return profileCtx;
|
|
137
|
+
}
|
|
138
|
+
async function getPwAiModule() {
|
|
139
|
+
return await getPwAiModule$1({ mode: "soft" });
|
|
140
|
+
}
|
|
141
|
+
async function requirePwAi(res, feature) {
|
|
142
|
+
const mod = await getPwAiModule();
|
|
143
|
+
if (mod) return mod;
|
|
144
|
+
jsonError(res, 501, [
|
|
145
|
+
`Playwright is not available in this gateway build; '${feature}' is unsupported.`,
|
|
146
|
+
"Install the full Playwright package (not playwright-core) and restart the gateway, or reinstall with browser support.",
|
|
147
|
+
"Docs: /tools/browser#playwright-requirement"
|
|
148
|
+
].join("\n"));
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/browser/routes/agent.act.ts
|
|
154
|
+
function registerBrowserAgentActRoutes(app, ctx) {
|
|
155
|
+
app.post("/act", async (req, res) => {
|
|
156
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
157
|
+
if (!profileCtx) return;
|
|
158
|
+
const body = readBody(req);
|
|
159
|
+
const kindRaw = toStringOrEmpty(body.kind);
|
|
160
|
+
if (!isActKind(kindRaw)) return jsonError(res, 400, "kind is required");
|
|
161
|
+
const kind = kindRaw;
|
|
162
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
163
|
+
if (Object.hasOwn(body, "selector") && kind !== "wait") return jsonError(res, 400, SELECTOR_UNSUPPORTED_MESSAGE);
|
|
164
|
+
try {
|
|
165
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
166
|
+
const cdpUrl = profileCtx.profile.cdpUrl;
|
|
167
|
+
const pw = await requirePwAi(res, `act:${kind}`);
|
|
168
|
+
if (!pw) return;
|
|
169
|
+
const evaluateEnabled = ctx.state().resolved.evaluateEnabled;
|
|
170
|
+
switch (kind) {
|
|
171
|
+
case "click": {
|
|
172
|
+
const ref = toStringOrEmpty(body.ref);
|
|
173
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
174
|
+
const doubleClick = toBoolean(body.doubleClick) ?? false;
|
|
175
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
176
|
+
const buttonRaw = toStringOrEmpty(body.button) || "";
|
|
177
|
+
const button = buttonRaw ? parseClickButton(buttonRaw) : void 0;
|
|
178
|
+
if (buttonRaw && !button) return jsonError(res, 400, "button must be left|right|middle");
|
|
179
|
+
const parsedModifiers = parseClickModifiers(toStringArray(body.modifiers) ?? []);
|
|
180
|
+
if (parsedModifiers.error) return jsonError(res, 400, parsedModifiers.error);
|
|
181
|
+
const modifiers = parsedModifiers.modifiers;
|
|
182
|
+
const clickRequest = {
|
|
183
|
+
cdpUrl,
|
|
184
|
+
targetId: tab.targetId,
|
|
185
|
+
ref,
|
|
186
|
+
doubleClick
|
|
187
|
+
};
|
|
188
|
+
if (button) clickRequest.button = button;
|
|
189
|
+
if (modifiers) clickRequest.modifiers = modifiers;
|
|
190
|
+
if (timeoutMs) clickRequest.timeoutMs = timeoutMs;
|
|
191
|
+
await pw.clickViaPlaywright(clickRequest);
|
|
192
|
+
return res.json({
|
|
193
|
+
ok: true,
|
|
194
|
+
targetId: tab.targetId,
|
|
195
|
+
url: tab.url
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
case "type": {
|
|
199
|
+
const ref = toStringOrEmpty(body.ref);
|
|
200
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
201
|
+
if (typeof body.text !== "string") return jsonError(res, 400, "text is required");
|
|
202
|
+
const text = body.text;
|
|
203
|
+
const submit = toBoolean(body.submit) ?? false;
|
|
204
|
+
const slowly = toBoolean(body.slowly) ?? false;
|
|
205
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
206
|
+
const typeRequest = {
|
|
207
|
+
cdpUrl,
|
|
208
|
+
targetId: tab.targetId,
|
|
209
|
+
ref,
|
|
210
|
+
text,
|
|
211
|
+
submit,
|
|
212
|
+
slowly
|
|
213
|
+
};
|
|
214
|
+
if (timeoutMs) typeRequest.timeoutMs = timeoutMs;
|
|
215
|
+
await pw.typeViaPlaywright(typeRequest);
|
|
216
|
+
return res.json({
|
|
217
|
+
ok: true,
|
|
218
|
+
targetId: tab.targetId
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
case "press": {
|
|
222
|
+
const key = toStringOrEmpty(body.key);
|
|
223
|
+
if (!key) return jsonError(res, 400, "key is required");
|
|
224
|
+
const delayMs = toNumber(body.delayMs);
|
|
225
|
+
await pw.pressKeyViaPlaywright({
|
|
226
|
+
cdpUrl,
|
|
227
|
+
targetId: tab.targetId,
|
|
228
|
+
key,
|
|
229
|
+
delayMs: delayMs ?? void 0
|
|
230
|
+
});
|
|
231
|
+
return res.json({
|
|
232
|
+
ok: true,
|
|
233
|
+
targetId: tab.targetId
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
case "hover": {
|
|
237
|
+
const ref = toStringOrEmpty(body.ref);
|
|
238
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
239
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
240
|
+
await pw.hoverViaPlaywright({
|
|
241
|
+
cdpUrl,
|
|
242
|
+
targetId: tab.targetId,
|
|
243
|
+
ref,
|
|
244
|
+
timeoutMs: timeoutMs ?? void 0
|
|
245
|
+
});
|
|
246
|
+
return res.json({
|
|
247
|
+
ok: true,
|
|
248
|
+
targetId: tab.targetId
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
case "scrollIntoView": {
|
|
252
|
+
const ref = toStringOrEmpty(body.ref);
|
|
253
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
254
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
255
|
+
const scrollRequest = {
|
|
256
|
+
cdpUrl,
|
|
257
|
+
targetId: tab.targetId,
|
|
258
|
+
ref
|
|
259
|
+
};
|
|
260
|
+
if (timeoutMs) scrollRequest.timeoutMs = timeoutMs;
|
|
261
|
+
await pw.scrollIntoViewViaPlaywright(scrollRequest);
|
|
262
|
+
return res.json({
|
|
263
|
+
ok: true,
|
|
264
|
+
targetId: tab.targetId
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
case "drag": {
|
|
268
|
+
const startRef = toStringOrEmpty(body.startRef);
|
|
269
|
+
const endRef = toStringOrEmpty(body.endRef);
|
|
270
|
+
if (!startRef || !endRef) return jsonError(res, 400, "startRef and endRef are required");
|
|
271
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
272
|
+
await pw.dragViaPlaywright({
|
|
273
|
+
cdpUrl,
|
|
274
|
+
targetId: tab.targetId,
|
|
275
|
+
startRef,
|
|
276
|
+
endRef,
|
|
277
|
+
timeoutMs: timeoutMs ?? void 0
|
|
278
|
+
});
|
|
279
|
+
return res.json({
|
|
280
|
+
ok: true,
|
|
281
|
+
targetId: tab.targetId
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
case "select": {
|
|
285
|
+
const ref = toStringOrEmpty(body.ref);
|
|
286
|
+
const values = toStringArray(body.values);
|
|
287
|
+
if (!ref || !values?.length) return jsonError(res, 400, "ref and values are required");
|
|
288
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
289
|
+
await pw.selectOptionViaPlaywright({
|
|
290
|
+
cdpUrl,
|
|
291
|
+
targetId: tab.targetId,
|
|
292
|
+
ref,
|
|
293
|
+
values,
|
|
294
|
+
timeoutMs: timeoutMs ?? void 0
|
|
295
|
+
});
|
|
296
|
+
return res.json({
|
|
297
|
+
ok: true,
|
|
298
|
+
targetId: tab.targetId
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
case "fill": {
|
|
302
|
+
const fields = (Array.isArray(body.fields) ? body.fields : []).map((field) => {
|
|
303
|
+
if (!field || typeof field !== "object") return null;
|
|
304
|
+
const rec = field;
|
|
305
|
+
const ref = toStringOrEmpty(rec.ref);
|
|
306
|
+
const type = toStringOrEmpty(rec.type);
|
|
307
|
+
if (!ref || !type) return null;
|
|
308
|
+
const value = typeof rec.value === "string" || typeof rec.value === "number" || typeof rec.value === "boolean" ? rec.value : void 0;
|
|
309
|
+
return value === void 0 ? {
|
|
310
|
+
ref,
|
|
311
|
+
type
|
|
312
|
+
} : {
|
|
313
|
+
ref,
|
|
314
|
+
type,
|
|
315
|
+
value
|
|
316
|
+
};
|
|
317
|
+
}).filter((field) => field !== null);
|
|
318
|
+
if (!fields.length) return jsonError(res, 400, "fields are required");
|
|
319
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
320
|
+
await pw.fillFormViaPlaywright({
|
|
321
|
+
cdpUrl,
|
|
322
|
+
targetId: tab.targetId,
|
|
323
|
+
fields,
|
|
324
|
+
timeoutMs: timeoutMs ?? void 0
|
|
325
|
+
});
|
|
326
|
+
return res.json({
|
|
327
|
+
ok: true,
|
|
328
|
+
targetId: tab.targetId
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
case "resize": {
|
|
332
|
+
const width = toNumber(body.width);
|
|
333
|
+
const height = toNumber(body.height);
|
|
334
|
+
if (!width || !height) return jsonError(res, 400, "width and height are required");
|
|
335
|
+
await pw.resizeViewportViaPlaywright({
|
|
336
|
+
cdpUrl,
|
|
337
|
+
targetId: tab.targetId,
|
|
338
|
+
width,
|
|
339
|
+
height
|
|
340
|
+
});
|
|
341
|
+
return res.json({
|
|
342
|
+
ok: true,
|
|
343
|
+
targetId: tab.targetId,
|
|
344
|
+
url: tab.url
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
case "wait": {
|
|
348
|
+
const timeMs = toNumber(body.timeMs);
|
|
349
|
+
const text = toStringOrEmpty(body.text) || void 0;
|
|
350
|
+
const textGone = toStringOrEmpty(body.textGone) || void 0;
|
|
351
|
+
const selector = toStringOrEmpty(body.selector) || void 0;
|
|
352
|
+
const url = toStringOrEmpty(body.url) || void 0;
|
|
353
|
+
const loadStateRaw = toStringOrEmpty(body.loadState);
|
|
354
|
+
const loadState = loadStateRaw === "load" || loadStateRaw === "domcontentloaded" || loadStateRaw === "networkidle" ? loadStateRaw : void 0;
|
|
355
|
+
const fn = toStringOrEmpty(body.fn) || void 0;
|
|
356
|
+
const timeoutMs = toNumber(body.timeoutMs) ?? void 0;
|
|
357
|
+
if (fn && !evaluateEnabled) return jsonError(res, 403, ["wait --fn is disabled by config (browser.evaluateEnabled=false).", "Docs: /gateway/configuration#browser-openclaw-managed-browser"].join("\n"));
|
|
358
|
+
if (timeMs === void 0 && !text && !textGone && !selector && !url && !loadState && !fn) return jsonError(res, 400, "wait requires at least one of: timeMs, text, textGone, selector, url, loadState, fn");
|
|
359
|
+
await pw.waitForViaPlaywright({
|
|
360
|
+
cdpUrl,
|
|
361
|
+
targetId: tab.targetId,
|
|
362
|
+
timeMs,
|
|
363
|
+
text,
|
|
364
|
+
textGone,
|
|
365
|
+
selector,
|
|
366
|
+
url,
|
|
367
|
+
loadState,
|
|
368
|
+
fn,
|
|
369
|
+
timeoutMs
|
|
370
|
+
});
|
|
371
|
+
return res.json({
|
|
372
|
+
ok: true,
|
|
373
|
+
targetId: tab.targetId
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
case "evaluate": {
|
|
377
|
+
if (!evaluateEnabled) return jsonError(res, 403, ["act:evaluate is disabled by config (browser.evaluateEnabled=false).", "Docs: /gateway/configuration#browser-openclaw-managed-browser"].join("\n"));
|
|
378
|
+
const fn = toStringOrEmpty(body.fn);
|
|
379
|
+
if (!fn) return jsonError(res, 400, "fn is required");
|
|
380
|
+
const ref = toStringOrEmpty(body.ref) || void 0;
|
|
381
|
+
const result = await pw.evaluateViaPlaywright({
|
|
382
|
+
cdpUrl,
|
|
383
|
+
targetId: tab.targetId,
|
|
384
|
+
fn,
|
|
385
|
+
ref
|
|
386
|
+
});
|
|
387
|
+
return res.json({
|
|
388
|
+
ok: true,
|
|
389
|
+
targetId: tab.targetId,
|
|
390
|
+
url: tab.url,
|
|
391
|
+
result
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
case "close":
|
|
395
|
+
await pw.closePageViaPlaywright({
|
|
396
|
+
cdpUrl,
|
|
397
|
+
targetId: tab.targetId
|
|
398
|
+
});
|
|
399
|
+
return res.json({
|
|
400
|
+
ok: true,
|
|
401
|
+
targetId: tab.targetId
|
|
402
|
+
});
|
|
403
|
+
default: return jsonError(res, 400, "unsupported kind");
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
handleRouteError(ctx, res, err);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
app.post("/hooks/file-chooser", async (req, res) => {
|
|
410
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
411
|
+
if (!profileCtx) return;
|
|
412
|
+
const body = readBody(req);
|
|
413
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
414
|
+
const ref = toStringOrEmpty(body.ref) || void 0;
|
|
415
|
+
const inputRef = toStringOrEmpty(body.inputRef) || void 0;
|
|
416
|
+
const element = toStringOrEmpty(body.element) || void 0;
|
|
417
|
+
const paths = toStringArray(body.paths) ?? [];
|
|
418
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
419
|
+
if (!paths.length) return jsonError(res, 400, "paths are required");
|
|
420
|
+
try {
|
|
421
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
422
|
+
const pw = await requirePwAi(res, "file chooser hook");
|
|
423
|
+
if (!pw) return;
|
|
424
|
+
if (inputRef || element) {
|
|
425
|
+
if (ref) return jsonError(res, 400, "ref cannot be combined with inputRef/element");
|
|
426
|
+
await pw.setInputFilesViaPlaywright({
|
|
427
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
428
|
+
targetId: tab.targetId,
|
|
429
|
+
inputRef,
|
|
430
|
+
element,
|
|
431
|
+
paths
|
|
432
|
+
});
|
|
433
|
+
} else {
|
|
434
|
+
await pw.armFileUploadViaPlaywright({
|
|
435
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
436
|
+
targetId: tab.targetId,
|
|
437
|
+
paths,
|
|
438
|
+
timeoutMs: timeoutMs ?? void 0
|
|
439
|
+
});
|
|
440
|
+
if (ref) await pw.clickViaPlaywright({
|
|
441
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
442
|
+
targetId: tab.targetId,
|
|
443
|
+
ref
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
res.json({ ok: true });
|
|
447
|
+
} catch (err) {
|
|
448
|
+
handleRouteError(ctx, res, err);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
app.post("/hooks/dialog", async (req, res) => {
|
|
452
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
453
|
+
if (!profileCtx) return;
|
|
454
|
+
const body = readBody(req);
|
|
455
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
456
|
+
const accept = toBoolean(body.accept);
|
|
457
|
+
const promptText = toStringOrEmpty(body.promptText) || void 0;
|
|
458
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
459
|
+
if (accept === void 0) return jsonError(res, 400, "accept is required");
|
|
460
|
+
try {
|
|
461
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
462
|
+
const pw = await requirePwAi(res, "dialog hook");
|
|
463
|
+
if (!pw) return;
|
|
464
|
+
await pw.armDialogViaPlaywright({
|
|
465
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
466
|
+
targetId: tab.targetId,
|
|
467
|
+
accept,
|
|
468
|
+
promptText,
|
|
469
|
+
timeoutMs: timeoutMs ?? void 0
|
|
470
|
+
});
|
|
471
|
+
res.json({ ok: true });
|
|
472
|
+
} catch (err) {
|
|
473
|
+
handleRouteError(ctx, res, err);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
app.post("/wait/download", async (req, res) => {
|
|
477
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
478
|
+
if (!profileCtx) return;
|
|
479
|
+
const body = readBody(req);
|
|
480
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
481
|
+
const out = toStringOrEmpty(body.path) || void 0;
|
|
482
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
483
|
+
try {
|
|
484
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
485
|
+
const pw = await requirePwAi(res, "wait for download");
|
|
486
|
+
if (!pw) return;
|
|
487
|
+
const result = await pw.waitForDownloadViaPlaywright({
|
|
488
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
489
|
+
targetId: tab.targetId,
|
|
490
|
+
path: out,
|
|
491
|
+
timeoutMs: timeoutMs ?? void 0
|
|
492
|
+
});
|
|
493
|
+
res.json({
|
|
494
|
+
ok: true,
|
|
495
|
+
targetId: tab.targetId,
|
|
496
|
+
download: result
|
|
497
|
+
});
|
|
498
|
+
} catch (err) {
|
|
499
|
+
handleRouteError(ctx, res, err);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
app.post("/download", async (req, res) => {
|
|
503
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
504
|
+
if (!profileCtx) return;
|
|
505
|
+
const body = readBody(req);
|
|
506
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
507
|
+
const ref = toStringOrEmpty(body.ref);
|
|
508
|
+
const out = toStringOrEmpty(body.path);
|
|
509
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
510
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
511
|
+
if (!out) return jsonError(res, 400, "path is required");
|
|
512
|
+
try {
|
|
513
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
514
|
+
const pw = await requirePwAi(res, "download");
|
|
515
|
+
if (!pw) return;
|
|
516
|
+
const result = await pw.downloadViaPlaywright({
|
|
517
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
518
|
+
targetId: tab.targetId,
|
|
519
|
+
ref,
|
|
520
|
+
path: out,
|
|
521
|
+
timeoutMs: timeoutMs ?? void 0
|
|
522
|
+
});
|
|
523
|
+
res.json({
|
|
524
|
+
ok: true,
|
|
525
|
+
targetId: tab.targetId,
|
|
526
|
+
download: result
|
|
527
|
+
});
|
|
528
|
+
} catch (err) {
|
|
529
|
+
handleRouteError(ctx, res, err);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
app.post("/response/body", async (req, res) => {
|
|
533
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
534
|
+
if (!profileCtx) return;
|
|
535
|
+
const body = readBody(req);
|
|
536
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
537
|
+
const url = toStringOrEmpty(body.url);
|
|
538
|
+
const timeoutMs = toNumber(body.timeoutMs);
|
|
539
|
+
const maxChars = toNumber(body.maxChars);
|
|
540
|
+
if (!url) return jsonError(res, 400, "url is required");
|
|
541
|
+
try {
|
|
542
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
543
|
+
const pw = await requirePwAi(res, "response body");
|
|
544
|
+
if (!pw) return;
|
|
545
|
+
const result = await pw.responseBodyViaPlaywright({
|
|
546
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
547
|
+
targetId: tab.targetId,
|
|
548
|
+
url,
|
|
549
|
+
timeoutMs: timeoutMs ?? void 0,
|
|
550
|
+
maxChars: maxChars ?? void 0
|
|
551
|
+
});
|
|
552
|
+
res.json({
|
|
553
|
+
ok: true,
|
|
554
|
+
targetId: tab.targetId,
|
|
555
|
+
response: result
|
|
556
|
+
});
|
|
557
|
+
} catch (err) {
|
|
558
|
+
handleRouteError(ctx, res, err);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
app.post("/highlight", async (req, res) => {
|
|
562
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
563
|
+
if (!profileCtx) return;
|
|
564
|
+
const body = readBody(req);
|
|
565
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
566
|
+
const ref = toStringOrEmpty(body.ref);
|
|
567
|
+
if (!ref) return jsonError(res, 400, "ref is required");
|
|
568
|
+
try {
|
|
569
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
570
|
+
const pw = await requirePwAi(res, "highlight");
|
|
571
|
+
if (!pw) return;
|
|
572
|
+
await pw.highlightViaPlaywright({
|
|
573
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
574
|
+
targetId: tab.targetId,
|
|
575
|
+
ref
|
|
576
|
+
});
|
|
577
|
+
res.json({
|
|
578
|
+
ok: true,
|
|
579
|
+
targetId: tab.targetId
|
|
580
|
+
});
|
|
581
|
+
} catch (err) {
|
|
582
|
+
handleRouteError(ctx, res, err);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/browser/routes/agent.debug.ts
|
|
589
|
+
function registerBrowserAgentDebugRoutes(app, ctx) {
|
|
590
|
+
app.get("/console", async (req, res) => {
|
|
591
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
592
|
+
if (!profileCtx) return;
|
|
593
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
594
|
+
const level = typeof req.query.level === "string" ? req.query.level : "";
|
|
595
|
+
try {
|
|
596
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
597
|
+
const pw = await requirePwAi(res, "console messages");
|
|
598
|
+
if (!pw) return;
|
|
599
|
+
const messages = await pw.getConsoleMessagesViaPlaywright({
|
|
600
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
601
|
+
targetId: tab.targetId,
|
|
602
|
+
level: level.trim() || void 0
|
|
603
|
+
});
|
|
604
|
+
res.json({
|
|
605
|
+
ok: true,
|
|
606
|
+
messages,
|
|
607
|
+
targetId: tab.targetId
|
|
608
|
+
});
|
|
609
|
+
} catch (err) {
|
|
610
|
+
handleRouteError(ctx, res, err);
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
app.get("/errors", async (req, res) => {
|
|
614
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
615
|
+
if (!profileCtx) return;
|
|
616
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
617
|
+
const clear = toBoolean(req.query.clear) ?? false;
|
|
618
|
+
try {
|
|
619
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
620
|
+
const pw = await requirePwAi(res, "page errors");
|
|
621
|
+
if (!pw) return;
|
|
622
|
+
const result = await pw.getPageErrorsViaPlaywright({
|
|
623
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
624
|
+
targetId: tab.targetId,
|
|
625
|
+
clear
|
|
626
|
+
});
|
|
627
|
+
res.json({
|
|
628
|
+
ok: true,
|
|
629
|
+
targetId: tab.targetId,
|
|
630
|
+
...result
|
|
631
|
+
});
|
|
632
|
+
} catch (err) {
|
|
633
|
+
handleRouteError(ctx, res, err);
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
app.get("/requests", async (req, res) => {
|
|
637
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
638
|
+
if (!profileCtx) return;
|
|
639
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
640
|
+
const filter = typeof req.query.filter === "string" ? req.query.filter : "";
|
|
641
|
+
const clear = toBoolean(req.query.clear) ?? false;
|
|
642
|
+
try {
|
|
643
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
644
|
+
const pw = await requirePwAi(res, "network requests");
|
|
645
|
+
if (!pw) return;
|
|
646
|
+
const result = await pw.getNetworkRequestsViaPlaywright({
|
|
647
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
648
|
+
targetId: tab.targetId,
|
|
649
|
+
filter: filter.trim() || void 0,
|
|
650
|
+
clear
|
|
651
|
+
});
|
|
652
|
+
res.json({
|
|
653
|
+
ok: true,
|
|
654
|
+
targetId: tab.targetId,
|
|
655
|
+
...result
|
|
656
|
+
});
|
|
657
|
+
} catch (err) {
|
|
658
|
+
handleRouteError(ctx, res, err);
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
app.post("/trace/start", async (req, res) => {
|
|
662
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
663
|
+
if (!profileCtx) return;
|
|
664
|
+
const body = readBody(req);
|
|
665
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
666
|
+
const screenshots = toBoolean(body.screenshots) ?? void 0;
|
|
667
|
+
const snapshots = toBoolean(body.snapshots) ?? void 0;
|
|
668
|
+
const sources = toBoolean(body.sources) ?? void 0;
|
|
669
|
+
try {
|
|
670
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
671
|
+
const pw = await requirePwAi(res, "trace start");
|
|
672
|
+
if (!pw) return;
|
|
673
|
+
await pw.traceStartViaPlaywright({
|
|
674
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
675
|
+
targetId: tab.targetId,
|
|
676
|
+
screenshots,
|
|
677
|
+
snapshots,
|
|
678
|
+
sources
|
|
679
|
+
});
|
|
680
|
+
res.json({
|
|
681
|
+
ok: true,
|
|
682
|
+
targetId: tab.targetId
|
|
683
|
+
});
|
|
684
|
+
} catch (err) {
|
|
685
|
+
handleRouteError(ctx, res, err);
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
app.post("/trace/stop", async (req, res) => {
|
|
689
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
690
|
+
if (!profileCtx) return;
|
|
691
|
+
const body = readBody(req);
|
|
692
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
693
|
+
const out = toStringOrEmpty(body.path) || "";
|
|
694
|
+
try {
|
|
695
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
696
|
+
const pw = await requirePwAi(res, "trace stop");
|
|
697
|
+
if (!pw) return;
|
|
698
|
+
const id = crypto.randomUUID();
|
|
699
|
+
const dir = "/tmp/openclaw";
|
|
700
|
+
await fs$1.mkdir(dir, { recursive: true });
|
|
701
|
+
const tracePath = out.trim() || path.join(dir, `browser-trace-${id}.zip`);
|
|
702
|
+
await pw.traceStopViaPlaywright({
|
|
703
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
704
|
+
targetId: tab.targetId,
|
|
705
|
+
path: tracePath
|
|
706
|
+
});
|
|
707
|
+
res.json({
|
|
708
|
+
ok: true,
|
|
709
|
+
targetId: tab.targetId,
|
|
710
|
+
path: path.resolve(tracePath)
|
|
711
|
+
});
|
|
712
|
+
} catch (err) {
|
|
713
|
+
handleRouteError(ctx, res, err);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
//#endregion
|
|
719
|
+
//#region src/infra/net/ssrf.ts
|
|
720
|
+
var SsrFBlockedError = class extends Error {
|
|
721
|
+
constructor(message) {
|
|
722
|
+
super(message);
|
|
723
|
+
this.name = "SsrFBlockedError";
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
const PRIVATE_IPV6_PREFIXES = [
|
|
727
|
+
"fe80:",
|
|
728
|
+
"fec0:",
|
|
729
|
+
"fc",
|
|
730
|
+
"fd"
|
|
731
|
+
];
|
|
732
|
+
const BLOCKED_HOSTNAMES = new Set(["localhost", "metadata.google.internal"]);
|
|
733
|
+
function normalizeHostname(hostname) {
|
|
734
|
+
const normalized = hostname.trim().toLowerCase().replace(/\.$/, "");
|
|
735
|
+
if (normalized.startsWith("[") && normalized.endsWith("]")) return normalized.slice(1, -1);
|
|
736
|
+
return normalized;
|
|
737
|
+
}
|
|
738
|
+
function normalizeHostnameSet(values) {
|
|
739
|
+
if (!values || values.length === 0) return /* @__PURE__ */ new Set();
|
|
740
|
+
return new Set(values.map((value) => normalizeHostname(value)).filter(Boolean));
|
|
741
|
+
}
|
|
742
|
+
function parseIpv4(address) {
|
|
743
|
+
const parts = address.split(".");
|
|
744
|
+
if (parts.length !== 4) return null;
|
|
745
|
+
const numbers = parts.map((part) => Number.parseInt(part, 10));
|
|
746
|
+
if (numbers.some((value) => Number.isNaN(value) || value < 0 || value > 255)) return null;
|
|
747
|
+
return numbers;
|
|
748
|
+
}
|
|
749
|
+
function parseIpv4FromMappedIpv6(mapped) {
|
|
750
|
+
if (mapped.includes(".")) return parseIpv4(mapped);
|
|
751
|
+
const parts = mapped.split(":").filter(Boolean);
|
|
752
|
+
if (parts.length === 1) {
|
|
753
|
+
const value = Number.parseInt(parts[0], 16);
|
|
754
|
+
if (Number.isNaN(value) || value < 0 || value > 4294967295) return null;
|
|
755
|
+
return [
|
|
756
|
+
value >>> 24 & 255,
|
|
757
|
+
value >>> 16 & 255,
|
|
758
|
+
value >>> 8 & 255,
|
|
759
|
+
value & 255
|
|
760
|
+
];
|
|
761
|
+
}
|
|
762
|
+
if (parts.length !== 2) return null;
|
|
763
|
+
const high = Number.parseInt(parts[0], 16);
|
|
764
|
+
const low = Number.parseInt(parts[1], 16);
|
|
765
|
+
if (Number.isNaN(high) || Number.isNaN(low) || high < 0 || low < 0 || high > 65535 || low > 65535) return null;
|
|
766
|
+
const value = (high << 16) + low;
|
|
767
|
+
return [
|
|
768
|
+
value >>> 24 & 255,
|
|
769
|
+
value >>> 16 & 255,
|
|
770
|
+
value >>> 8 & 255,
|
|
771
|
+
value & 255
|
|
772
|
+
];
|
|
773
|
+
}
|
|
774
|
+
function isPrivateIpv4(parts) {
|
|
775
|
+
const [octet1, octet2] = parts;
|
|
776
|
+
if (octet1 === 0) return true;
|
|
777
|
+
if (octet1 === 10) return true;
|
|
778
|
+
if (octet1 === 127) return true;
|
|
779
|
+
if (octet1 === 169 && octet2 === 254) return true;
|
|
780
|
+
if (octet1 === 172 && octet2 >= 16 && octet2 <= 31) return true;
|
|
781
|
+
if (octet1 === 192 && octet2 === 168) return true;
|
|
782
|
+
if (octet1 === 100 && octet2 >= 64 && octet2 <= 127) return true;
|
|
783
|
+
return false;
|
|
784
|
+
}
|
|
785
|
+
function isPrivateIpAddress(address) {
|
|
786
|
+
let normalized = address.trim().toLowerCase();
|
|
787
|
+
if (normalized.startsWith("[") && normalized.endsWith("]")) normalized = normalized.slice(1, -1);
|
|
788
|
+
if (!normalized) return false;
|
|
789
|
+
if (normalized.startsWith("::ffff:")) {
|
|
790
|
+
const ipv4 = parseIpv4FromMappedIpv6(normalized.slice(7));
|
|
791
|
+
if (ipv4) return isPrivateIpv4(ipv4);
|
|
792
|
+
}
|
|
793
|
+
if (normalized.includes(":")) {
|
|
794
|
+
if (normalized === "::" || normalized === "::1") return true;
|
|
795
|
+
return PRIVATE_IPV6_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
796
|
+
}
|
|
797
|
+
const ipv4 = parseIpv4(normalized);
|
|
798
|
+
if (!ipv4) return false;
|
|
799
|
+
return isPrivateIpv4(ipv4);
|
|
800
|
+
}
|
|
801
|
+
function isBlockedHostname(hostname) {
|
|
802
|
+
const normalized = normalizeHostname(hostname);
|
|
803
|
+
if (!normalized) return false;
|
|
804
|
+
if (BLOCKED_HOSTNAMES.has(normalized)) return true;
|
|
805
|
+
return normalized.endsWith(".localhost") || normalized.endsWith(".local") || normalized.endsWith(".internal");
|
|
806
|
+
}
|
|
807
|
+
function createPinnedLookup(params) {
|
|
808
|
+
const normalizedHost = normalizeHostname(params.hostname);
|
|
809
|
+
const fallback = params.fallback ?? lookup;
|
|
810
|
+
const fallbackLookup = fallback;
|
|
811
|
+
const fallbackWithOptions = fallback;
|
|
812
|
+
const records = params.addresses.map((address) => ({
|
|
813
|
+
address,
|
|
814
|
+
family: address.includes(":") ? 6 : 4
|
|
815
|
+
}));
|
|
816
|
+
let index = 0;
|
|
817
|
+
return ((host, options, callback) => {
|
|
818
|
+
const cb = typeof options === "function" ? options : callback;
|
|
819
|
+
if (!cb) return;
|
|
820
|
+
const normalized = normalizeHostname(host);
|
|
821
|
+
if (!normalized || normalized !== normalizedHost) {
|
|
822
|
+
if (typeof options === "function" || options === void 0) return fallbackLookup(host, cb);
|
|
823
|
+
return fallbackWithOptions(host, options, cb);
|
|
824
|
+
}
|
|
825
|
+
const opts = typeof options === "object" && options !== null ? options : {};
|
|
826
|
+
const requestedFamily = typeof options === "number" ? options : typeof opts.family === "number" ? opts.family : 0;
|
|
827
|
+
const candidates = requestedFamily === 4 || requestedFamily === 6 ? records.filter((entry) => entry.family === requestedFamily) : records;
|
|
828
|
+
const usable = candidates.length > 0 ? candidates : records;
|
|
829
|
+
if (opts.all) {
|
|
830
|
+
cb(null, usable);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
const chosen = usable[index % usable.length];
|
|
834
|
+
index += 1;
|
|
835
|
+
cb(null, chosen.address, chosen.family);
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
async function resolvePinnedHostnameWithPolicy(hostname, params = {}) {
|
|
839
|
+
const normalized = normalizeHostname(hostname);
|
|
840
|
+
if (!normalized) throw new Error("Invalid hostname");
|
|
841
|
+
const allowPrivateNetwork = Boolean(params.policy?.allowPrivateNetwork);
|
|
842
|
+
const isExplicitAllowed = normalizeHostnameSet(params.policy?.allowedHostnames).has(normalized);
|
|
843
|
+
if (!allowPrivateNetwork && !isExplicitAllowed) {
|
|
844
|
+
if (isBlockedHostname(normalized)) throw new SsrFBlockedError(`Blocked hostname: ${hostname}`);
|
|
845
|
+
if (isPrivateIpAddress(normalized)) throw new SsrFBlockedError("Blocked: private/internal IP address");
|
|
846
|
+
}
|
|
847
|
+
const results = await (params.lookupFn ?? lookup$1)(normalized, { all: true });
|
|
848
|
+
if (results.length === 0) throw new Error(`Unable to resolve hostname: ${hostname}`);
|
|
849
|
+
if (!allowPrivateNetwork && !isExplicitAllowed) {
|
|
850
|
+
for (const entry of results) if (isPrivateIpAddress(entry.address)) throw new SsrFBlockedError("Blocked: resolves to private/internal IP address");
|
|
851
|
+
}
|
|
852
|
+
const addresses = Array.from(new Set(results.map((entry) => entry.address)));
|
|
853
|
+
if (addresses.length === 0) throw new Error(`Unable to resolve hostname: ${hostname}`);
|
|
854
|
+
return {
|
|
855
|
+
hostname: normalized,
|
|
856
|
+
addresses,
|
|
857
|
+
lookup: createPinnedLookup({
|
|
858
|
+
hostname: normalized,
|
|
859
|
+
addresses
|
|
860
|
+
})
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
async function resolvePinnedHostname(hostname, lookupFn = lookup$1) {
|
|
864
|
+
return await resolvePinnedHostnameWithPolicy(hostname, { lookupFn });
|
|
865
|
+
}
|
|
866
|
+
function createPinnedDispatcher(pinned) {
|
|
867
|
+
return new Agent({ connect: { lookup: pinned.lookup } });
|
|
868
|
+
}
|
|
869
|
+
async function closeDispatcher(dispatcher) {
|
|
870
|
+
if (!dispatcher) return;
|
|
871
|
+
const candidate = dispatcher;
|
|
872
|
+
try {
|
|
873
|
+
if (typeof candidate.close === "function") {
|
|
874
|
+
await candidate.close();
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
if (typeof candidate.destroy === "function") candidate.destroy();
|
|
878
|
+
} catch {}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
//#endregion
|
|
882
|
+
//#region src/media/constants.ts
|
|
883
|
+
const MAX_IMAGE_BYTES = 6 * 1024 * 1024;
|
|
884
|
+
const MAX_AUDIO_BYTES = 16 * 1024 * 1024;
|
|
885
|
+
const MAX_VIDEO_BYTES = 16 * 1024 * 1024;
|
|
886
|
+
const MAX_DOCUMENT_BYTES = 100 * 1024 * 1024;
|
|
887
|
+
function mediaKindFromMime(mime) {
|
|
888
|
+
if (!mime) return "unknown";
|
|
889
|
+
if (mime.startsWith("image/")) return "image";
|
|
890
|
+
if (mime.startsWith("audio/")) return "audio";
|
|
891
|
+
if (mime.startsWith("video/")) return "video";
|
|
892
|
+
if (mime === "application/pdf") return "document";
|
|
893
|
+
if (mime.startsWith("application/")) return "document";
|
|
894
|
+
return "unknown";
|
|
895
|
+
}
|
|
896
|
+
function maxBytesForKind(kind) {
|
|
897
|
+
switch (kind) {
|
|
898
|
+
case "image": return MAX_IMAGE_BYTES;
|
|
899
|
+
case "audio": return MAX_AUDIO_BYTES;
|
|
900
|
+
case "video": return MAX_VIDEO_BYTES;
|
|
901
|
+
case "document": return MAX_DOCUMENT_BYTES;
|
|
902
|
+
default: return MAX_DOCUMENT_BYTES;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
//#endregion
|
|
907
|
+
//#region src/media/mime.ts
|
|
908
|
+
const EXT_BY_MIME = {
|
|
909
|
+
"image/heic": ".heic",
|
|
910
|
+
"image/heif": ".heif",
|
|
911
|
+
"image/jpeg": ".jpg",
|
|
912
|
+
"image/png": ".png",
|
|
913
|
+
"image/webp": ".webp",
|
|
914
|
+
"image/gif": ".gif",
|
|
915
|
+
"audio/ogg": ".ogg",
|
|
916
|
+
"audio/mpeg": ".mp3",
|
|
917
|
+
"audio/x-m4a": ".m4a",
|
|
918
|
+
"audio/mp4": ".m4a",
|
|
919
|
+
"video/mp4": ".mp4",
|
|
920
|
+
"video/quicktime": ".mov",
|
|
921
|
+
"application/pdf": ".pdf",
|
|
922
|
+
"application/json": ".json",
|
|
923
|
+
"application/zip": ".zip",
|
|
924
|
+
"application/gzip": ".gz",
|
|
925
|
+
"application/x-tar": ".tar",
|
|
926
|
+
"application/x-7z-compressed": ".7z",
|
|
927
|
+
"application/vnd.rar": ".rar",
|
|
928
|
+
"application/msword": ".doc",
|
|
929
|
+
"application/vnd.ms-excel": ".xls",
|
|
930
|
+
"application/vnd.ms-powerpoint": ".ppt",
|
|
931
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": ".docx",
|
|
932
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": ".xlsx",
|
|
933
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": ".pptx",
|
|
934
|
+
"text/csv": ".csv",
|
|
935
|
+
"text/plain": ".txt",
|
|
936
|
+
"text/markdown": ".md"
|
|
937
|
+
};
|
|
938
|
+
const MIME_BY_EXT = {
|
|
939
|
+
...Object.fromEntries(Object.entries(EXT_BY_MIME).map(([mime, ext]) => [ext, mime])),
|
|
940
|
+
".jpeg": "image/jpeg"
|
|
941
|
+
};
|
|
942
|
+
const AUDIO_FILE_EXTENSIONS = new Set([
|
|
943
|
+
".aac",
|
|
944
|
+
".flac",
|
|
945
|
+
".m4a",
|
|
946
|
+
".mp3",
|
|
947
|
+
".oga",
|
|
948
|
+
".ogg",
|
|
949
|
+
".opus",
|
|
950
|
+
".wav"
|
|
951
|
+
]);
|
|
952
|
+
function normalizeHeaderMime(mime) {
|
|
953
|
+
if (!mime) return;
|
|
954
|
+
return mime.split(";")[0]?.trim().toLowerCase() || void 0;
|
|
955
|
+
}
|
|
956
|
+
async function sniffMime(buffer) {
|
|
957
|
+
if (!buffer) return;
|
|
958
|
+
try {
|
|
959
|
+
return (await fileTypeFromBuffer(buffer))?.mime ?? void 0;
|
|
960
|
+
} catch {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
function getFileExtension(filePath) {
|
|
965
|
+
if (!filePath) return;
|
|
966
|
+
try {
|
|
967
|
+
if (/^https?:\/\//i.test(filePath)) {
|
|
968
|
+
const url = new URL(filePath);
|
|
969
|
+
return path.extname(url.pathname).toLowerCase() || void 0;
|
|
970
|
+
}
|
|
971
|
+
} catch {}
|
|
972
|
+
return path.extname(filePath).toLowerCase() || void 0;
|
|
973
|
+
}
|
|
974
|
+
function isAudioFileName(fileName) {
|
|
975
|
+
const ext = getFileExtension(fileName);
|
|
976
|
+
if (!ext) return false;
|
|
977
|
+
return AUDIO_FILE_EXTENSIONS.has(ext);
|
|
978
|
+
}
|
|
979
|
+
function detectMime(opts) {
|
|
980
|
+
return detectMimeImpl(opts);
|
|
981
|
+
}
|
|
982
|
+
function isGenericMime(mime) {
|
|
983
|
+
if (!mime) return true;
|
|
984
|
+
const m = mime.toLowerCase();
|
|
985
|
+
return m === "application/octet-stream" || m === "application/zip";
|
|
986
|
+
}
|
|
987
|
+
async function detectMimeImpl(opts) {
|
|
988
|
+
const ext = getFileExtension(opts.filePath);
|
|
989
|
+
const extMime = ext ? MIME_BY_EXT[ext] : void 0;
|
|
990
|
+
const headerMime = normalizeHeaderMime(opts.headerMime);
|
|
991
|
+
const sniffed = await sniffMime(opts.buffer);
|
|
992
|
+
if (sniffed && (!isGenericMime(sniffed) || !extMime)) return sniffed;
|
|
993
|
+
if (extMime) return extMime;
|
|
994
|
+
if (headerMime && !isGenericMime(headerMime)) return headerMime;
|
|
995
|
+
if (sniffed) return sniffed;
|
|
996
|
+
if (headerMime) return headerMime;
|
|
997
|
+
}
|
|
998
|
+
function extensionForMime(mime) {
|
|
999
|
+
if (!mime) return;
|
|
1000
|
+
return EXT_BY_MIME[mime.toLowerCase()];
|
|
1001
|
+
}
|
|
1002
|
+
function isGifMedia(opts) {
|
|
1003
|
+
if (opts.contentType?.toLowerCase() === "image/gif") return true;
|
|
1004
|
+
return getFileExtension(opts.fileName) === ".gif";
|
|
1005
|
+
}
|
|
1006
|
+
function imageMimeFromFormat(format) {
|
|
1007
|
+
if (!format) return;
|
|
1008
|
+
switch (format.toLowerCase()) {
|
|
1009
|
+
case "jpg":
|
|
1010
|
+
case "jpeg": return "image/jpeg";
|
|
1011
|
+
case "heic": return "image/heic";
|
|
1012
|
+
case "heif": return "image/heif";
|
|
1013
|
+
case "png": return "image/png";
|
|
1014
|
+
case "webp": return "image/webp";
|
|
1015
|
+
case "gif": return "image/gif";
|
|
1016
|
+
default: return;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function kindFromMime(mime) {
|
|
1020
|
+
return mediaKindFromMime(mime);
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/media/store.ts
|
|
1025
|
+
const resolveMediaDir = () => path.join(resolveConfigDir(), "media");
|
|
1026
|
+
const MEDIA_MAX_BYTES = 5 * 1024 * 1024;
|
|
1027
|
+
const MAX_BYTES = MEDIA_MAX_BYTES;
|
|
1028
|
+
const DEFAULT_TTL_MS = 120 * 1e3;
|
|
1029
|
+
/**
|
|
1030
|
+
* Sanitize a filename for cross-platform safety.
|
|
1031
|
+
* Removes chars unsafe on Windows/SharePoint/all platforms.
|
|
1032
|
+
* Keeps: alphanumeric, dots, hyphens, underscores, Unicode letters/numbers.
|
|
1033
|
+
*/
|
|
1034
|
+
function sanitizeFilename(name) {
|
|
1035
|
+
const trimmed = name.trim();
|
|
1036
|
+
if (!trimmed) return "";
|
|
1037
|
+
return trimmed.replace(/[^\p{L}\p{N}._-]+/gu, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").slice(0, 60);
|
|
1038
|
+
}
|
|
1039
|
+
function getMediaDir() {
|
|
1040
|
+
return resolveMediaDir();
|
|
1041
|
+
}
|
|
1042
|
+
async function ensureMediaDir() {
|
|
1043
|
+
const mediaDir = resolveMediaDir();
|
|
1044
|
+
await fs$1.mkdir(mediaDir, {
|
|
1045
|
+
recursive: true,
|
|
1046
|
+
mode: 448
|
|
1047
|
+
});
|
|
1048
|
+
return mediaDir;
|
|
1049
|
+
}
|
|
1050
|
+
async function saveMediaBuffer(buffer, contentType, subdir = "inbound", maxBytes = MAX_BYTES, originalFilename) {
|
|
1051
|
+
if (buffer.byteLength > maxBytes) throw new Error(`Media exceeds ${(maxBytes / (1024 * 1024)).toFixed(0)}MB limit`);
|
|
1052
|
+
const dir = path.join(resolveMediaDir(), subdir);
|
|
1053
|
+
await fs$1.mkdir(dir, {
|
|
1054
|
+
recursive: true,
|
|
1055
|
+
mode: 448
|
|
1056
|
+
});
|
|
1057
|
+
const uuid = crypto.randomUUID();
|
|
1058
|
+
const headerExt = extensionForMime(contentType?.split(";")[0]?.trim() ?? void 0);
|
|
1059
|
+
const mime = await detectMime({
|
|
1060
|
+
buffer,
|
|
1061
|
+
headerMime: contentType
|
|
1062
|
+
});
|
|
1063
|
+
const ext = headerExt ?? extensionForMime(mime) ?? "";
|
|
1064
|
+
let id;
|
|
1065
|
+
if (originalFilename) {
|
|
1066
|
+
const base = path.parse(originalFilename).name;
|
|
1067
|
+
const sanitized = sanitizeFilename(base);
|
|
1068
|
+
id = sanitized ? `${sanitized}---${uuid}${ext}` : `${uuid}${ext}`;
|
|
1069
|
+
} else id = ext ? `${uuid}${ext}` : uuid;
|
|
1070
|
+
const dest = path.join(dir, id);
|
|
1071
|
+
await fs$1.writeFile(dest, buffer, { mode: 384 });
|
|
1072
|
+
return {
|
|
1073
|
+
id,
|
|
1074
|
+
path: dest,
|
|
1075
|
+
size: buffer.byteLength,
|
|
1076
|
+
contentType: mime
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
//#endregion
|
|
1081
|
+
//#region src/media/image-ops.ts
|
|
1082
|
+
function isBun() {
|
|
1083
|
+
return typeof process.versions.bun === "string";
|
|
1084
|
+
}
|
|
1085
|
+
function prefersSips() {
|
|
1086
|
+
return process.env.OPENCLAW_IMAGE_BACKEND === "sips" || process.env.OPENCLAW_IMAGE_BACKEND !== "sharp" && isBun() && process.platform === "darwin";
|
|
1087
|
+
}
|
|
1088
|
+
async function loadSharp() {
|
|
1089
|
+
const mod = await import("sharp");
|
|
1090
|
+
const sharp = mod.default ?? mod;
|
|
1091
|
+
return (buffer) => sharp(buffer, { failOnError: false });
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Reads EXIF orientation from JPEG buffer.
|
|
1095
|
+
* Returns orientation value 1-8, or null if not found/not JPEG.
|
|
1096
|
+
*
|
|
1097
|
+
* EXIF orientation values:
|
|
1098
|
+
* 1 = Normal, 2 = Flip H, 3 = Rotate 180, 4 = Flip V,
|
|
1099
|
+
* 5 = Rotate 270 CW + Flip H, 6 = Rotate 90 CW, 7 = Rotate 90 CW + Flip H, 8 = Rotate 270 CW
|
|
1100
|
+
*/
|
|
1101
|
+
function readJpegExifOrientation(buffer) {
|
|
1102
|
+
if (buffer.length < 2 || buffer[0] !== 255 || buffer[1] !== 216) return null;
|
|
1103
|
+
let offset = 2;
|
|
1104
|
+
while (offset < buffer.length - 4) {
|
|
1105
|
+
if (buffer[offset] !== 255) {
|
|
1106
|
+
offset++;
|
|
1107
|
+
continue;
|
|
1108
|
+
}
|
|
1109
|
+
const marker = buffer[offset + 1];
|
|
1110
|
+
if (marker === 255) {
|
|
1111
|
+
offset++;
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
if (marker === 225) {
|
|
1115
|
+
const exifStart = offset + 4;
|
|
1116
|
+
if (buffer.length > exifStart + 6 && buffer.toString("ascii", exifStart, exifStart + 4) === "Exif" && buffer[exifStart + 4] === 0 && buffer[exifStart + 5] === 0) {
|
|
1117
|
+
const tiffStart = exifStart + 6;
|
|
1118
|
+
if (buffer.length < tiffStart + 8) return null;
|
|
1119
|
+
const isLittleEndian = buffer.toString("ascii", tiffStart, tiffStart + 2) === "II";
|
|
1120
|
+
const readU16 = (pos) => isLittleEndian ? buffer.readUInt16LE(pos) : buffer.readUInt16BE(pos);
|
|
1121
|
+
const readU32 = (pos) => isLittleEndian ? buffer.readUInt32LE(pos) : buffer.readUInt32BE(pos);
|
|
1122
|
+
const ifd0Start = tiffStart + readU32(tiffStart + 4);
|
|
1123
|
+
if (buffer.length < ifd0Start + 2) return null;
|
|
1124
|
+
const numEntries = readU16(ifd0Start);
|
|
1125
|
+
for (let i = 0; i < numEntries; i++) {
|
|
1126
|
+
const entryOffset = ifd0Start + 2 + i * 12;
|
|
1127
|
+
if (buffer.length < entryOffset + 12) break;
|
|
1128
|
+
if (readU16(entryOffset) === 274) {
|
|
1129
|
+
const value = readU16(entryOffset + 8);
|
|
1130
|
+
return value >= 1 && value <= 8 ? value : null;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
return null;
|
|
1135
|
+
}
|
|
1136
|
+
if (marker >= 224 && marker <= 239) {
|
|
1137
|
+
const segmentLength = buffer.readUInt16BE(offset + 2);
|
|
1138
|
+
offset += 2 + segmentLength;
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
if (marker === 192 || marker === 218) break;
|
|
1142
|
+
offset++;
|
|
1143
|
+
}
|
|
1144
|
+
return null;
|
|
1145
|
+
}
|
|
1146
|
+
async function withTempDir(fn) {
|
|
1147
|
+
const dir = await fs$1.mkdtemp(path.join(os.tmpdir(), "openclaw-img-"));
|
|
1148
|
+
try {
|
|
1149
|
+
return await fn(dir);
|
|
1150
|
+
} finally {
|
|
1151
|
+
await fs$1.rm(dir, {
|
|
1152
|
+
recursive: true,
|
|
1153
|
+
force: true
|
|
1154
|
+
}).catch(() => {});
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
async function sipsMetadataFromBuffer(buffer) {
|
|
1158
|
+
return await withTempDir(async (dir) => {
|
|
1159
|
+
const input = path.join(dir, "in.img");
|
|
1160
|
+
await fs$1.writeFile(input, buffer);
|
|
1161
|
+
const { stdout } = await runExec("/usr/bin/sips", [
|
|
1162
|
+
"-g",
|
|
1163
|
+
"pixelWidth",
|
|
1164
|
+
"-g",
|
|
1165
|
+
"pixelHeight",
|
|
1166
|
+
input
|
|
1167
|
+
], {
|
|
1168
|
+
timeoutMs: 1e4,
|
|
1169
|
+
maxBuffer: 512 * 1024
|
|
1170
|
+
});
|
|
1171
|
+
const w = stdout.match(/pixelWidth:\s*([0-9]+)/);
|
|
1172
|
+
const h = stdout.match(/pixelHeight:\s*([0-9]+)/);
|
|
1173
|
+
if (!w?.[1] || !h?.[1]) return null;
|
|
1174
|
+
const width = Number.parseInt(w[1], 10);
|
|
1175
|
+
const height = Number.parseInt(h[1], 10);
|
|
1176
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
1177
|
+
if (width <= 0 || height <= 0) return null;
|
|
1178
|
+
return {
|
|
1179
|
+
width,
|
|
1180
|
+
height
|
|
1181
|
+
};
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
async function sipsResizeToJpeg(params) {
|
|
1185
|
+
return await withTempDir(async (dir) => {
|
|
1186
|
+
const input = path.join(dir, "in.img");
|
|
1187
|
+
const output = path.join(dir, "out.jpg");
|
|
1188
|
+
await fs$1.writeFile(input, params.buffer);
|
|
1189
|
+
await runExec("/usr/bin/sips", [
|
|
1190
|
+
"-Z",
|
|
1191
|
+
String(Math.max(1, Math.round(params.maxSide))),
|
|
1192
|
+
"-s",
|
|
1193
|
+
"format",
|
|
1194
|
+
"jpeg",
|
|
1195
|
+
"-s",
|
|
1196
|
+
"formatOptions",
|
|
1197
|
+
String(Math.max(1, Math.min(100, Math.round(params.quality)))),
|
|
1198
|
+
input,
|
|
1199
|
+
"--out",
|
|
1200
|
+
output
|
|
1201
|
+
], {
|
|
1202
|
+
timeoutMs: 2e4,
|
|
1203
|
+
maxBuffer: 1024 * 1024
|
|
1204
|
+
});
|
|
1205
|
+
return await fs$1.readFile(output);
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
async function sipsConvertToJpeg(buffer) {
|
|
1209
|
+
return await withTempDir(async (dir) => {
|
|
1210
|
+
const input = path.join(dir, "in.heic");
|
|
1211
|
+
const output = path.join(dir, "out.jpg");
|
|
1212
|
+
await fs$1.writeFile(input, buffer);
|
|
1213
|
+
await runExec("/usr/bin/sips", [
|
|
1214
|
+
"-s",
|
|
1215
|
+
"format",
|
|
1216
|
+
"jpeg",
|
|
1217
|
+
input,
|
|
1218
|
+
"--out",
|
|
1219
|
+
output
|
|
1220
|
+
], {
|
|
1221
|
+
timeoutMs: 2e4,
|
|
1222
|
+
maxBuffer: 1024 * 1024
|
|
1223
|
+
});
|
|
1224
|
+
return await fs$1.readFile(output);
|
|
1225
|
+
});
|
|
1226
|
+
}
|
|
1227
|
+
async function getImageMetadata(buffer) {
|
|
1228
|
+
if (prefersSips()) return await sipsMetadataFromBuffer(buffer).catch(() => null);
|
|
1229
|
+
try {
|
|
1230
|
+
const meta = await (await loadSharp())(buffer).metadata();
|
|
1231
|
+
const width = Number(meta.width ?? 0);
|
|
1232
|
+
const height = Number(meta.height ?? 0);
|
|
1233
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) return null;
|
|
1234
|
+
if (width <= 0 || height <= 0) return null;
|
|
1235
|
+
return {
|
|
1236
|
+
width,
|
|
1237
|
+
height
|
|
1238
|
+
};
|
|
1239
|
+
} catch {
|
|
1240
|
+
return null;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Applies rotation/flip to image buffer using sips based on EXIF orientation.
|
|
1245
|
+
*/
|
|
1246
|
+
async function sipsApplyOrientation(buffer, orientation) {
|
|
1247
|
+
const ops = [];
|
|
1248
|
+
switch (orientation) {
|
|
1249
|
+
case 2:
|
|
1250
|
+
ops.push("-f", "horizontal");
|
|
1251
|
+
break;
|
|
1252
|
+
case 3:
|
|
1253
|
+
ops.push("-r", "180");
|
|
1254
|
+
break;
|
|
1255
|
+
case 4:
|
|
1256
|
+
ops.push("-f", "vertical");
|
|
1257
|
+
break;
|
|
1258
|
+
case 5:
|
|
1259
|
+
ops.push("-r", "270", "-f", "horizontal");
|
|
1260
|
+
break;
|
|
1261
|
+
case 6:
|
|
1262
|
+
ops.push("-r", "90");
|
|
1263
|
+
break;
|
|
1264
|
+
case 7:
|
|
1265
|
+
ops.push("-r", "90", "-f", "horizontal");
|
|
1266
|
+
break;
|
|
1267
|
+
case 8:
|
|
1268
|
+
ops.push("-r", "270");
|
|
1269
|
+
break;
|
|
1270
|
+
default: return buffer;
|
|
1271
|
+
}
|
|
1272
|
+
return await withTempDir(async (dir) => {
|
|
1273
|
+
const input = path.join(dir, "in.jpg");
|
|
1274
|
+
const output = path.join(dir, "out.jpg");
|
|
1275
|
+
await fs$1.writeFile(input, buffer);
|
|
1276
|
+
await runExec("/usr/bin/sips", [
|
|
1277
|
+
...ops,
|
|
1278
|
+
input,
|
|
1279
|
+
"--out",
|
|
1280
|
+
output
|
|
1281
|
+
], {
|
|
1282
|
+
timeoutMs: 2e4,
|
|
1283
|
+
maxBuffer: 1024 * 1024
|
|
1284
|
+
});
|
|
1285
|
+
return await fs$1.readFile(output);
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
async function resizeToJpeg(params) {
|
|
1289
|
+
if (prefersSips()) {
|
|
1290
|
+
const normalized = await normalizeExifOrientationSips(params.buffer);
|
|
1291
|
+
if (params.withoutEnlargement !== false) {
|
|
1292
|
+
const meta = await getImageMetadata(normalized);
|
|
1293
|
+
if (meta) {
|
|
1294
|
+
const maxDim = Math.max(meta.width, meta.height);
|
|
1295
|
+
if (maxDim > 0 && maxDim <= params.maxSide) return await sipsResizeToJpeg({
|
|
1296
|
+
buffer: normalized,
|
|
1297
|
+
maxSide: maxDim,
|
|
1298
|
+
quality: params.quality
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
return await sipsResizeToJpeg({
|
|
1303
|
+
buffer: normalized,
|
|
1304
|
+
maxSide: params.maxSide,
|
|
1305
|
+
quality: params.quality
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
return await (await loadSharp())(params.buffer).rotate().resize({
|
|
1309
|
+
width: params.maxSide,
|
|
1310
|
+
height: params.maxSide,
|
|
1311
|
+
fit: "inside",
|
|
1312
|
+
withoutEnlargement: params.withoutEnlargement !== false
|
|
1313
|
+
}).jpeg({
|
|
1314
|
+
quality: params.quality,
|
|
1315
|
+
mozjpeg: true
|
|
1316
|
+
}).toBuffer();
|
|
1317
|
+
}
|
|
1318
|
+
async function convertHeicToJpeg(buffer) {
|
|
1319
|
+
if (prefersSips()) return await sipsConvertToJpeg(buffer);
|
|
1320
|
+
return await (await loadSharp())(buffer).jpeg({
|
|
1321
|
+
quality: 90,
|
|
1322
|
+
mozjpeg: true
|
|
1323
|
+
}).toBuffer();
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Checks if an image has an alpha channel (transparency).
|
|
1327
|
+
* Returns true if the image has alpha, false otherwise.
|
|
1328
|
+
*/
|
|
1329
|
+
async function hasAlphaChannel(buffer) {
|
|
1330
|
+
try {
|
|
1331
|
+
const meta = await (await loadSharp())(buffer).metadata();
|
|
1332
|
+
return meta.hasAlpha || meta.channels === 4;
|
|
1333
|
+
} catch {
|
|
1334
|
+
return false;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
/**
|
|
1338
|
+
* Resizes an image to PNG format, preserving alpha channel (transparency).
|
|
1339
|
+
* Falls back to sharp only (no sips fallback for PNG with alpha).
|
|
1340
|
+
*/
|
|
1341
|
+
async function resizeToPng(params) {
|
|
1342
|
+
const sharp = await loadSharp();
|
|
1343
|
+
const compressionLevel = params.compressionLevel ?? 6;
|
|
1344
|
+
return await sharp(params.buffer).rotate().resize({
|
|
1345
|
+
width: params.maxSide,
|
|
1346
|
+
height: params.maxSide,
|
|
1347
|
+
fit: "inside",
|
|
1348
|
+
withoutEnlargement: params.withoutEnlargement !== false
|
|
1349
|
+
}).png({ compressionLevel }).toBuffer();
|
|
1350
|
+
}
|
|
1351
|
+
async function optimizeImageToPng(buffer, maxBytes) {
|
|
1352
|
+
const sides = [
|
|
1353
|
+
2048,
|
|
1354
|
+
1536,
|
|
1355
|
+
1280,
|
|
1356
|
+
1024,
|
|
1357
|
+
800
|
|
1358
|
+
];
|
|
1359
|
+
const compressionLevels = [
|
|
1360
|
+
6,
|
|
1361
|
+
7,
|
|
1362
|
+
8,
|
|
1363
|
+
9
|
|
1364
|
+
];
|
|
1365
|
+
let smallest = null;
|
|
1366
|
+
for (const side of sides) for (const compressionLevel of compressionLevels) try {
|
|
1367
|
+
const out = await resizeToPng({
|
|
1368
|
+
buffer,
|
|
1369
|
+
maxSide: side,
|
|
1370
|
+
compressionLevel,
|
|
1371
|
+
withoutEnlargement: true
|
|
1372
|
+
});
|
|
1373
|
+
const size = out.length;
|
|
1374
|
+
if (!smallest || size < smallest.size) smallest = {
|
|
1375
|
+
buffer: out,
|
|
1376
|
+
size,
|
|
1377
|
+
resizeSide: side,
|
|
1378
|
+
compressionLevel
|
|
1379
|
+
};
|
|
1380
|
+
if (size <= maxBytes) return {
|
|
1381
|
+
buffer: out,
|
|
1382
|
+
optimizedSize: size,
|
|
1383
|
+
resizeSide: side,
|
|
1384
|
+
compressionLevel
|
|
1385
|
+
};
|
|
1386
|
+
} catch {}
|
|
1387
|
+
if (smallest) return {
|
|
1388
|
+
buffer: smallest.buffer,
|
|
1389
|
+
optimizedSize: smallest.size,
|
|
1390
|
+
resizeSide: smallest.resizeSide,
|
|
1391
|
+
compressionLevel: smallest.compressionLevel
|
|
1392
|
+
};
|
|
1393
|
+
throw new Error("Failed to optimize PNG image");
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Internal sips-only EXIF normalization (no sharp fallback).
|
|
1397
|
+
* Used by resizeToJpeg to normalize before sips resize.
|
|
1398
|
+
*/
|
|
1399
|
+
async function normalizeExifOrientationSips(buffer) {
|
|
1400
|
+
try {
|
|
1401
|
+
const orientation = readJpegExifOrientation(buffer);
|
|
1402
|
+
if (!orientation || orientation === 1) return buffer;
|
|
1403
|
+
return await sipsApplyOrientation(buffer, orientation);
|
|
1404
|
+
} catch {
|
|
1405
|
+
return buffer;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
//#endregion
|
|
1410
|
+
//#region src/browser/screenshot.ts
|
|
1411
|
+
const DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE = 2e3;
|
|
1412
|
+
const DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
|
|
1413
|
+
async function normalizeBrowserScreenshot(buffer, opts) {
|
|
1414
|
+
const maxSide = Math.max(1, Math.round(opts?.maxSide ?? DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE));
|
|
1415
|
+
const maxBytes = Math.max(1, Math.round(opts?.maxBytes ?? DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES));
|
|
1416
|
+
const meta = await getImageMetadata(buffer);
|
|
1417
|
+
const width = Number(meta?.width ?? 0);
|
|
1418
|
+
const height = Number(meta?.height ?? 0);
|
|
1419
|
+
const maxDim = Math.max(width, height);
|
|
1420
|
+
if (buffer.byteLength <= maxBytes && (maxDim === 0 || width <= maxSide && height <= maxSide)) return { buffer };
|
|
1421
|
+
const qualities = [
|
|
1422
|
+
85,
|
|
1423
|
+
75,
|
|
1424
|
+
65,
|
|
1425
|
+
55,
|
|
1426
|
+
45,
|
|
1427
|
+
35
|
|
1428
|
+
];
|
|
1429
|
+
const sideGrid = [
|
|
1430
|
+
maxDim > 0 ? Math.min(maxSide, maxDim) : maxSide,
|
|
1431
|
+
1800,
|
|
1432
|
+
1600,
|
|
1433
|
+
1400,
|
|
1434
|
+
1200,
|
|
1435
|
+
1e3,
|
|
1436
|
+
800
|
|
1437
|
+
].map((v) => Math.min(maxSide, v)).filter((v, i, arr) => v > 0 && arr.indexOf(v) === i).toSorted((a, b) => b - a);
|
|
1438
|
+
let smallest = null;
|
|
1439
|
+
for (const side of sideGrid) for (const quality of qualities) {
|
|
1440
|
+
const out = await resizeToJpeg({
|
|
1441
|
+
buffer,
|
|
1442
|
+
maxSide: side,
|
|
1443
|
+
quality,
|
|
1444
|
+
withoutEnlargement: true
|
|
1445
|
+
});
|
|
1446
|
+
if (!smallest || out.byteLength < smallest.size) smallest = {
|
|
1447
|
+
buffer: out,
|
|
1448
|
+
size: out.byteLength
|
|
1449
|
+
};
|
|
1450
|
+
if (out.byteLength <= maxBytes) return {
|
|
1451
|
+
buffer: out,
|
|
1452
|
+
contentType: "image/jpeg"
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
const best = smallest?.buffer ?? buffer;
|
|
1456
|
+
throw new Error(`Browser screenshot could not be reduced below ${(maxBytes / (1024 * 1024)).toFixed(0)}MB (got ${(best.byteLength / (1024 * 1024)).toFixed(2)}MB)`);
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
//#endregion
|
|
1460
|
+
//#region src/browser/routes/agent.snapshot.ts
|
|
1461
|
+
function registerBrowserAgentSnapshotRoutes(app, ctx) {
|
|
1462
|
+
app.post("/navigate", async (req, res) => {
|
|
1463
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1464
|
+
if (!profileCtx) return;
|
|
1465
|
+
const body = readBody(req);
|
|
1466
|
+
const url = toStringOrEmpty(body.url);
|
|
1467
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1468
|
+
if (!url) return jsonError(res, 400, "url is required");
|
|
1469
|
+
try {
|
|
1470
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1471
|
+
const pw = await requirePwAi(res, "navigate");
|
|
1472
|
+
if (!pw) return;
|
|
1473
|
+
const result = await pw.navigateViaPlaywright({
|
|
1474
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1475
|
+
targetId: tab.targetId,
|
|
1476
|
+
url
|
|
1477
|
+
});
|
|
1478
|
+
res.json({
|
|
1479
|
+
ok: true,
|
|
1480
|
+
targetId: tab.targetId,
|
|
1481
|
+
...result
|
|
1482
|
+
});
|
|
1483
|
+
} catch (err) {
|
|
1484
|
+
handleRouteError(ctx, res, err);
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
app.post("/pdf", async (req, res) => {
|
|
1488
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1489
|
+
if (!profileCtx) return;
|
|
1490
|
+
const targetId = toStringOrEmpty(readBody(req).targetId) || void 0;
|
|
1491
|
+
try {
|
|
1492
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1493
|
+
const pw = await requirePwAi(res, "pdf");
|
|
1494
|
+
if (!pw) return;
|
|
1495
|
+
const pdf = await pw.pdfViaPlaywright({
|
|
1496
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1497
|
+
targetId: tab.targetId
|
|
1498
|
+
});
|
|
1499
|
+
await ensureMediaDir();
|
|
1500
|
+
const saved = await saveMediaBuffer(pdf.buffer, "application/pdf", "browser", pdf.buffer.byteLength);
|
|
1501
|
+
res.json({
|
|
1502
|
+
ok: true,
|
|
1503
|
+
path: path.resolve(saved.path),
|
|
1504
|
+
targetId: tab.targetId,
|
|
1505
|
+
url: tab.url
|
|
1506
|
+
});
|
|
1507
|
+
} catch (err) {
|
|
1508
|
+
handleRouteError(ctx, res, err);
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
app.post("/screenshot", async (req, res) => {
|
|
1512
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1513
|
+
if (!profileCtx) return;
|
|
1514
|
+
const body = readBody(req);
|
|
1515
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1516
|
+
const fullPage = toBoolean(body.fullPage) ?? false;
|
|
1517
|
+
const ref = toStringOrEmpty(body.ref) || void 0;
|
|
1518
|
+
const element = toStringOrEmpty(body.element) || void 0;
|
|
1519
|
+
const type = body.type === "jpeg" ? "jpeg" : "png";
|
|
1520
|
+
if (fullPage && (ref || element)) return jsonError(res, 400, "fullPage is not supported for element screenshots");
|
|
1521
|
+
try {
|
|
1522
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1523
|
+
let buffer;
|
|
1524
|
+
if (profileCtx.profile.driver === "extension" || !tab.wsUrl || Boolean(ref) || Boolean(element)) {
|
|
1525
|
+
const pw = await requirePwAi(res, "screenshot");
|
|
1526
|
+
if (!pw) return;
|
|
1527
|
+
buffer = (await pw.takeScreenshotViaPlaywright({
|
|
1528
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1529
|
+
targetId: tab.targetId,
|
|
1530
|
+
ref,
|
|
1531
|
+
element,
|
|
1532
|
+
fullPage,
|
|
1533
|
+
type
|
|
1534
|
+
})).buffer;
|
|
1535
|
+
} else buffer = await captureScreenshot({
|
|
1536
|
+
wsUrl: tab.wsUrl ?? "",
|
|
1537
|
+
fullPage,
|
|
1538
|
+
format: type,
|
|
1539
|
+
quality: type === "jpeg" ? 85 : void 0
|
|
1540
|
+
});
|
|
1541
|
+
const normalized = await normalizeBrowserScreenshot(buffer, {
|
|
1542
|
+
maxSide: DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE,
|
|
1543
|
+
maxBytes: DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES
|
|
1544
|
+
});
|
|
1545
|
+
await ensureMediaDir();
|
|
1546
|
+
const saved = await saveMediaBuffer(normalized.buffer, normalized.contentType ?? `image/${type}`, "browser", DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES);
|
|
1547
|
+
res.json({
|
|
1548
|
+
ok: true,
|
|
1549
|
+
path: path.resolve(saved.path),
|
|
1550
|
+
targetId: tab.targetId,
|
|
1551
|
+
url: tab.url
|
|
1552
|
+
});
|
|
1553
|
+
} catch (err) {
|
|
1554
|
+
handleRouteError(ctx, res, err);
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
app.get("/snapshot", async (req, res) => {
|
|
1558
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1559
|
+
if (!profileCtx) return;
|
|
1560
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
1561
|
+
const mode = req.query.mode === "efficient" ? "efficient" : void 0;
|
|
1562
|
+
const labels = toBoolean(req.query.labels) ?? void 0;
|
|
1563
|
+
const format = (req.query.format === "aria" ? "aria" : req.query.format === "ai" ? "ai" : void 0) ?? (mode ? "ai" : await getPwAiModule() ? "ai" : "aria");
|
|
1564
|
+
const limitRaw = typeof req.query.limit === "string" ? Number(req.query.limit) : void 0;
|
|
1565
|
+
const hasMaxChars = Object.hasOwn(req.query, "maxChars");
|
|
1566
|
+
const maxCharsRaw = typeof req.query.maxChars === "string" ? Number(req.query.maxChars) : void 0;
|
|
1567
|
+
const limit = Number.isFinite(limitRaw) ? limitRaw : void 0;
|
|
1568
|
+
const resolvedMaxChars = format === "ai" ? hasMaxChars ? typeof maxCharsRaw === "number" && Number.isFinite(maxCharsRaw) && maxCharsRaw > 0 ? Math.floor(maxCharsRaw) : void 0 : mode === "efficient" ? DEFAULT_AI_SNAPSHOT_EFFICIENT_MAX_CHARS : DEFAULT_AI_SNAPSHOT_MAX_CHARS : void 0;
|
|
1569
|
+
const interactiveRaw = toBoolean(req.query.interactive);
|
|
1570
|
+
const compactRaw = toBoolean(req.query.compact);
|
|
1571
|
+
const depthRaw = toNumber(req.query.depth);
|
|
1572
|
+
const refsModeRaw = toStringOrEmpty(req.query.refs).trim();
|
|
1573
|
+
const refsMode = refsModeRaw === "aria" ? "aria" : refsModeRaw === "role" ? "role" : void 0;
|
|
1574
|
+
const interactive = interactiveRaw ?? (mode === "efficient" ? true : void 0);
|
|
1575
|
+
const compact = compactRaw ?? (mode === "efficient" ? true : void 0);
|
|
1576
|
+
const depth = depthRaw ?? (mode === "efficient" ? DEFAULT_AI_SNAPSHOT_EFFICIENT_DEPTH : void 0);
|
|
1577
|
+
const selector = toStringOrEmpty(req.query.selector);
|
|
1578
|
+
const frameSelector = toStringOrEmpty(req.query.frame);
|
|
1579
|
+
try {
|
|
1580
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
1581
|
+
if ((labels || mode === "efficient") && format === "aria") return jsonError(res, 400, "labels/mode=efficient require format=ai");
|
|
1582
|
+
if (format === "ai") {
|
|
1583
|
+
const pw = await requirePwAi(res, "ai snapshot");
|
|
1584
|
+
if (!pw) return;
|
|
1585
|
+
const snap = labels === true || mode === "efficient" || interactive === true || compact === true || depth !== void 0 || Boolean(selector.trim()) || Boolean(frameSelector.trim()) ? await pw.snapshotRoleViaPlaywright({
|
|
1586
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1587
|
+
targetId: tab.targetId,
|
|
1588
|
+
selector: selector.trim() || void 0,
|
|
1589
|
+
frameSelector: frameSelector.trim() || void 0,
|
|
1590
|
+
refsMode,
|
|
1591
|
+
options: {
|
|
1592
|
+
interactive: interactive ?? void 0,
|
|
1593
|
+
compact: compact ?? void 0,
|
|
1594
|
+
maxDepth: depth ?? void 0
|
|
1595
|
+
}
|
|
1596
|
+
}) : await pw.snapshotAiViaPlaywright({
|
|
1597
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1598
|
+
targetId: tab.targetId,
|
|
1599
|
+
...typeof resolvedMaxChars === "number" ? { maxChars: resolvedMaxChars } : {}
|
|
1600
|
+
}).catch(async (err) => {
|
|
1601
|
+
if (String(err).toLowerCase().includes("_snapshotforai")) return await pw.snapshotRoleViaPlaywright({
|
|
1602
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1603
|
+
targetId: tab.targetId,
|
|
1604
|
+
selector: selector.trim() || void 0,
|
|
1605
|
+
frameSelector: frameSelector.trim() || void 0,
|
|
1606
|
+
refsMode,
|
|
1607
|
+
options: {
|
|
1608
|
+
interactive: interactive ?? void 0,
|
|
1609
|
+
compact: compact ?? void 0,
|
|
1610
|
+
maxDepth: depth ?? void 0
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
throw err;
|
|
1614
|
+
});
|
|
1615
|
+
if (labels) {
|
|
1616
|
+
const labeled = await pw.screenshotWithLabelsViaPlaywright({
|
|
1617
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1618
|
+
targetId: tab.targetId,
|
|
1619
|
+
refs: "refs" in snap ? snap.refs : {},
|
|
1620
|
+
type: "png"
|
|
1621
|
+
});
|
|
1622
|
+
const normalized = await normalizeBrowserScreenshot(labeled.buffer, {
|
|
1623
|
+
maxSide: DEFAULT_BROWSER_SCREENSHOT_MAX_SIDE,
|
|
1624
|
+
maxBytes: DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES
|
|
1625
|
+
});
|
|
1626
|
+
await ensureMediaDir();
|
|
1627
|
+
const saved = await saveMediaBuffer(normalized.buffer, normalized.contentType ?? "image/png", "browser", DEFAULT_BROWSER_SCREENSHOT_MAX_BYTES);
|
|
1628
|
+
const imageType = normalized.contentType?.includes("jpeg") ? "jpeg" : "png";
|
|
1629
|
+
return res.json({
|
|
1630
|
+
ok: true,
|
|
1631
|
+
format,
|
|
1632
|
+
targetId: tab.targetId,
|
|
1633
|
+
url: tab.url,
|
|
1634
|
+
labels: true,
|
|
1635
|
+
labelsCount: labeled.labels,
|
|
1636
|
+
labelsSkipped: labeled.skipped,
|
|
1637
|
+
imagePath: path.resolve(saved.path),
|
|
1638
|
+
imageType,
|
|
1639
|
+
...snap
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
return res.json({
|
|
1643
|
+
ok: true,
|
|
1644
|
+
format,
|
|
1645
|
+
targetId: tab.targetId,
|
|
1646
|
+
url: tab.url,
|
|
1647
|
+
...snap
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
const snap = profileCtx.profile.driver === "extension" || !tab.wsUrl ? requirePwAi(res, "aria snapshot").then(async (pw) => {
|
|
1651
|
+
if (!pw) return null;
|
|
1652
|
+
return await pw.snapshotAriaViaPlaywright({
|
|
1653
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1654
|
+
targetId: tab.targetId,
|
|
1655
|
+
limit
|
|
1656
|
+
});
|
|
1657
|
+
}) : snapshotAria({
|
|
1658
|
+
wsUrl: tab.wsUrl ?? "",
|
|
1659
|
+
limit
|
|
1660
|
+
});
|
|
1661
|
+
const resolved = await Promise.resolve(snap);
|
|
1662
|
+
if (!resolved) return;
|
|
1663
|
+
return res.json({
|
|
1664
|
+
ok: true,
|
|
1665
|
+
format,
|
|
1666
|
+
targetId: tab.targetId,
|
|
1667
|
+
url: tab.url,
|
|
1668
|
+
...resolved
|
|
1669
|
+
});
|
|
1670
|
+
} catch (err) {
|
|
1671
|
+
handleRouteError(ctx, res, err);
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
//#endregion
|
|
1677
|
+
//#region src/browser/routes/agent.storage.ts
|
|
1678
|
+
function registerBrowserAgentStorageRoutes(app, ctx) {
|
|
1679
|
+
app.get("/cookies", async (req, res) => {
|
|
1680
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1681
|
+
if (!profileCtx) return;
|
|
1682
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
1683
|
+
try {
|
|
1684
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
1685
|
+
const pw = await requirePwAi(res, "cookies");
|
|
1686
|
+
if (!pw) return;
|
|
1687
|
+
const result = await pw.cookiesGetViaPlaywright({
|
|
1688
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1689
|
+
targetId: tab.targetId
|
|
1690
|
+
});
|
|
1691
|
+
res.json({
|
|
1692
|
+
ok: true,
|
|
1693
|
+
targetId: tab.targetId,
|
|
1694
|
+
...result
|
|
1695
|
+
});
|
|
1696
|
+
} catch (err) {
|
|
1697
|
+
handleRouteError(ctx, res, err);
|
|
1698
|
+
}
|
|
1699
|
+
});
|
|
1700
|
+
app.post("/cookies/set", async (req, res) => {
|
|
1701
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1702
|
+
if (!profileCtx) return;
|
|
1703
|
+
const body = readBody(req);
|
|
1704
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1705
|
+
const cookie = body.cookie && typeof body.cookie === "object" && !Array.isArray(body.cookie) ? body.cookie : null;
|
|
1706
|
+
if (!cookie) return jsonError(res, 400, "cookie is required");
|
|
1707
|
+
try {
|
|
1708
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1709
|
+
const pw = await requirePwAi(res, "cookies set");
|
|
1710
|
+
if (!pw) return;
|
|
1711
|
+
await pw.cookiesSetViaPlaywright({
|
|
1712
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1713
|
+
targetId: tab.targetId,
|
|
1714
|
+
cookie: {
|
|
1715
|
+
name: toStringOrEmpty(cookie.name),
|
|
1716
|
+
value: toStringOrEmpty(cookie.value),
|
|
1717
|
+
url: toStringOrEmpty(cookie.url) || void 0,
|
|
1718
|
+
domain: toStringOrEmpty(cookie.domain) || void 0,
|
|
1719
|
+
path: toStringOrEmpty(cookie.path) || void 0,
|
|
1720
|
+
expires: toNumber(cookie.expires) ?? void 0,
|
|
1721
|
+
httpOnly: toBoolean(cookie.httpOnly) ?? void 0,
|
|
1722
|
+
secure: toBoolean(cookie.secure) ?? void 0,
|
|
1723
|
+
sameSite: cookie.sameSite === "Lax" || cookie.sameSite === "None" || cookie.sameSite === "Strict" ? cookie.sameSite : void 0
|
|
1724
|
+
}
|
|
1725
|
+
});
|
|
1726
|
+
res.json({
|
|
1727
|
+
ok: true,
|
|
1728
|
+
targetId: tab.targetId
|
|
1729
|
+
});
|
|
1730
|
+
} catch (err) {
|
|
1731
|
+
handleRouteError(ctx, res, err);
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1734
|
+
app.post("/cookies/clear", async (req, res) => {
|
|
1735
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1736
|
+
if (!profileCtx) return;
|
|
1737
|
+
const targetId = toStringOrEmpty(readBody(req).targetId) || void 0;
|
|
1738
|
+
try {
|
|
1739
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1740
|
+
const pw = await requirePwAi(res, "cookies clear");
|
|
1741
|
+
if (!pw) return;
|
|
1742
|
+
await pw.cookiesClearViaPlaywright({
|
|
1743
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1744
|
+
targetId: tab.targetId
|
|
1745
|
+
});
|
|
1746
|
+
res.json({
|
|
1747
|
+
ok: true,
|
|
1748
|
+
targetId: tab.targetId
|
|
1749
|
+
});
|
|
1750
|
+
} catch (err) {
|
|
1751
|
+
handleRouteError(ctx, res, err);
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
app.get("/storage/:kind", async (req, res) => {
|
|
1755
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1756
|
+
if (!profileCtx) return;
|
|
1757
|
+
const kind = toStringOrEmpty(req.params.kind);
|
|
1758
|
+
if (kind !== "local" && kind !== "session") return jsonError(res, 400, "kind must be local|session");
|
|
1759
|
+
const targetId = typeof req.query.targetId === "string" ? req.query.targetId.trim() : "";
|
|
1760
|
+
const key = typeof req.query.key === "string" ? req.query.key : "";
|
|
1761
|
+
try {
|
|
1762
|
+
const tab = await profileCtx.ensureTabAvailable(targetId || void 0);
|
|
1763
|
+
const pw = await requirePwAi(res, "storage get");
|
|
1764
|
+
if (!pw) return;
|
|
1765
|
+
const result = await pw.storageGetViaPlaywright({
|
|
1766
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1767
|
+
targetId: tab.targetId,
|
|
1768
|
+
kind,
|
|
1769
|
+
key: key.trim() || void 0
|
|
1770
|
+
});
|
|
1771
|
+
res.json({
|
|
1772
|
+
ok: true,
|
|
1773
|
+
targetId: tab.targetId,
|
|
1774
|
+
...result
|
|
1775
|
+
});
|
|
1776
|
+
} catch (err) {
|
|
1777
|
+
handleRouteError(ctx, res, err);
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
app.post("/storage/:kind/set", async (req, res) => {
|
|
1781
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1782
|
+
if (!profileCtx) return;
|
|
1783
|
+
const kind = toStringOrEmpty(req.params.kind);
|
|
1784
|
+
if (kind !== "local" && kind !== "session") return jsonError(res, 400, "kind must be local|session");
|
|
1785
|
+
const body = readBody(req);
|
|
1786
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1787
|
+
const key = toStringOrEmpty(body.key);
|
|
1788
|
+
if (!key) return jsonError(res, 400, "key is required");
|
|
1789
|
+
const value = typeof body.value === "string" ? body.value : "";
|
|
1790
|
+
try {
|
|
1791
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1792
|
+
const pw = await requirePwAi(res, "storage set");
|
|
1793
|
+
if (!pw) return;
|
|
1794
|
+
await pw.storageSetViaPlaywright({
|
|
1795
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1796
|
+
targetId: tab.targetId,
|
|
1797
|
+
kind,
|
|
1798
|
+
key,
|
|
1799
|
+
value
|
|
1800
|
+
});
|
|
1801
|
+
res.json({
|
|
1802
|
+
ok: true,
|
|
1803
|
+
targetId: tab.targetId
|
|
1804
|
+
});
|
|
1805
|
+
} catch (err) {
|
|
1806
|
+
handleRouteError(ctx, res, err);
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
app.post("/storage/:kind/clear", async (req, res) => {
|
|
1810
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1811
|
+
if (!profileCtx) return;
|
|
1812
|
+
const kind = toStringOrEmpty(req.params.kind);
|
|
1813
|
+
if (kind !== "local" && kind !== "session") return jsonError(res, 400, "kind must be local|session");
|
|
1814
|
+
const targetId = toStringOrEmpty(readBody(req).targetId) || void 0;
|
|
1815
|
+
try {
|
|
1816
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1817
|
+
const pw = await requirePwAi(res, "storage clear");
|
|
1818
|
+
if (!pw) return;
|
|
1819
|
+
await pw.storageClearViaPlaywright({
|
|
1820
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1821
|
+
targetId: tab.targetId,
|
|
1822
|
+
kind
|
|
1823
|
+
});
|
|
1824
|
+
res.json({
|
|
1825
|
+
ok: true,
|
|
1826
|
+
targetId: tab.targetId
|
|
1827
|
+
});
|
|
1828
|
+
} catch (err) {
|
|
1829
|
+
handleRouteError(ctx, res, err);
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
app.post("/set/offline", async (req, res) => {
|
|
1833
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1834
|
+
if (!profileCtx) return;
|
|
1835
|
+
const body = readBody(req);
|
|
1836
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1837
|
+
const offline = toBoolean(body.offline);
|
|
1838
|
+
if (offline === void 0) return jsonError(res, 400, "offline is required");
|
|
1839
|
+
try {
|
|
1840
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1841
|
+
const pw = await requirePwAi(res, "offline");
|
|
1842
|
+
if (!pw) return;
|
|
1843
|
+
await pw.setOfflineViaPlaywright({
|
|
1844
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1845
|
+
targetId: tab.targetId,
|
|
1846
|
+
offline
|
|
1847
|
+
});
|
|
1848
|
+
res.json({
|
|
1849
|
+
ok: true,
|
|
1850
|
+
targetId: tab.targetId
|
|
1851
|
+
});
|
|
1852
|
+
} catch (err) {
|
|
1853
|
+
handleRouteError(ctx, res, err);
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
app.post("/set/headers", async (req, res) => {
|
|
1857
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1858
|
+
if (!profileCtx) return;
|
|
1859
|
+
const body = readBody(req);
|
|
1860
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1861
|
+
const headers = body.headers && typeof body.headers === "object" && !Array.isArray(body.headers) ? body.headers : null;
|
|
1862
|
+
if (!headers) return jsonError(res, 400, "headers is required");
|
|
1863
|
+
const parsed = {};
|
|
1864
|
+
for (const [k, v] of Object.entries(headers)) if (typeof v === "string") parsed[k] = v;
|
|
1865
|
+
try {
|
|
1866
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1867
|
+
const pw = await requirePwAi(res, "headers");
|
|
1868
|
+
if (!pw) return;
|
|
1869
|
+
await pw.setExtraHTTPHeadersViaPlaywright({
|
|
1870
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1871
|
+
targetId: tab.targetId,
|
|
1872
|
+
headers: parsed
|
|
1873
|
+
});
|
|
1874
|
+
res.json({
|
|
1875
|
+
ok: true,
|
|
1876
|
+
targetId: tab.targetId
|
|
1877
|
+
});
|
|
1878
|
+
} catch (err) {
|
|
1879
|
+
handleRouteError(ctx, res, err);
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1882
|
+
app.post("/set/credentials", async (req, res) => {
|
|
1883
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1884
|
+
if (!profileCtx) return;
|
|
1885
|
+
const body = readBody(req);
|
|
1886
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1887
|
+
const clear = toBoolean(body.clear) ?? false;
|
|
1888
|
+
const username = toStringOrEmpty(body.username) || void 0;
|
|
1889
|
+
const password = typeof body.password === "string" ? body.password : void 0;
|
|
1890
|
+
try {
|
|
1891
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1892
|
+
const pw = await requirePwAi(res, "http credentials");
|
|
1893
|
+
if (!pw) return;
|
|
1894
|
+
await pw.setHttpCredentialsViaPlaywright({
|
|
1895
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1896
|
+
targetId: tab.targetId,
|
|
1897
|
+
username,
|
|
1898
|
+
password,
|
|
1899
|
+
clear
|
|
1900
|
+
});
|
|
1901
|
+
res.json({
|
|
1902
|
+
ok: true,
|
|
1903
|
+
targetId: tab.targetId
|
|
1904
|
+
});
|
|
1905
|
+
} catch (err) {
|
|
1906
|
+
handleRouteError(ctx, res, err);
|
|
1907
|
+
}
|
|
1908
|
+
});
|
|
1909
|
+
app.post("/set/geolocation", async (req, res) => {
|
|
1910
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1911
|
+
if (!profileCtx) return;
|
|
1912
|
+
const body = readBody(req);
|
|
1913
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1914
|
+
const clear = toBoolean(body.clear) ?? false;
|
|
1915
|
+
const latitude = toNumber(body.latitude);
|
|
1916
|
+
const longitude = toNumber(body.longitude);
|
|
1917
|
+
const accuracy = toNumber(body.accuracy) ?? void 0;
|
|
1918
|
+
const origin = toStringOrEmpty(body.origin) || void 0;
|
|
1919
|
+
try {
|
|
1920
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1921
|
+
const pw = await requirePwAi(res, "geolocation");
|
|
1922
|
+
if (!pw) return;
|
|
1923
|
+
await pw.setGeolocationViaPlaywright({
|
|
1924
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1925
|
+
targetId: tab.targetId,
|
|
1926
|
+
latitude,
|
|
1927
|
+
longitude,
|
|
1928
|
+
accuracy,
|
|
1929
|
+
origin,
|
|
1930
|
+
clear
|
|
1931
|
+
});
|
|
1932
|
+
res.json({
|
|
1933
|
+
ok: true,
|
|
1934
|
+
targetId: tab.targetId
|
|
1935
|
+
});
|
|
1936
|
+
} catch (err) {
|
|
1937
|
+
handleRouteError(ctx, res, err);
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
app.post("/set/media", async (req, res) => {
|
|
1941
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1942
|
+
if (!profileCtx) return;
|
|
1943
|
+
const body = readBody(req);
|
|
1944
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1945
|
+
const schemeRaw = toStringOrEmpty(body.colorScheme);
|
|
1946
|
+
const colorScheme = schemeRaw === "dark" || schemeRaw === "light" || schemeRaw === "no-preference" ? schemeRaw : schemeRaw === "none" ? null : void 0;
|
|
1947
|
+
if (colorScheme === void 0) return jsonError(res, 400, "colorScheme must be dark|light|no-preference|none");
|
|
1948
|
+
try {
|
|
1949
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1950
|
+
const pw = await requirePwAi(res, "media emulation");
|
|
1951
|
+
if (!pw) return;
|
|
1952
|
+
await pw.emulateMediaViaPlaywright({
|
|
1953
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1954
|
+
targetId: tab.targetId,
|
|
1955
|
+
colorScheme
|
|
1956
|
+
});
|
|
1957
|
+
res.json({
|
|
1958
|
+
ok: true,
|
|
1959
|
+
targetId: tab.targetId
|
|
1960
|
+
});
|
|
1961
|
+
} catch (err) {
|
|
1962
|
+
handleRouteError(ctx, res, err);
|
|
1963
|
+
}
|
|
1964
|
+
});
|
|
1965
|
+
app.post("/set/timezone", async (req, res) => {
|
|
1966
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1967
|
+
if (!profileCtx) return;
|
|
1968
|
+
const body = readBody(req);
|
|
1969
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1970
|
+
const timezoneId = toStringOrEmpty(body.timezoneId);
|
|
1971
|
+
if (!timezoneId) return jsonError(res, 400, "timezoneId is required");
|
|
1972
|
+
try {
|
|
1973
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1974
|
+
const pw = await requirePwAi(res, "timezone");
|
|
1975
|
+
if (!pw) return;
|
|
1976
|
+
await pw.setTimezoneViaPlaywright({
|
|
1977
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
1978
|
+
targetId: tab.targetId,
|
|
1979
|
+
timezoneId
|
|
1980
|
+
});
|
|
1981
|
+
res.json({
|
|
1982
|
+
ok: true,
|
|
1983
|
+
targetId: tab.targetId
|
|
1984
|
+
});
|
|
1985
|
+
} catch (err) {
|
|
1986
|
+
handleRouteError(ctx, res, err);
|
|
1987
|
+
}
|
|
1988
|
+
});
|
|
1989
|
+
app.post("/set/locale", async (req, res) => {
|
|
1990
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
1991
|
+
if (!profileCtx) return;
|
|
1992
|
+
const body = readBody(req);
|
|
1993
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
1994
|
+
const locale = toStringOrEmpty(body.locale);
|
|
1995
|
+
if (!locale) return jsonError(res, 400, "locale is required");
|
|
1996
|
+
try {
|
|
1997
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
1998
|
+
const pw = await requirePwAi(res, "locale");
|
|
1999
|
+
if (!pw) return;
|
|
2000
|
+
await pw.setLocaleViaPlaywright({
|
|
2001
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
2002
|
+
targetId: tab.targetId,
|
|
2003
|
+
locale
|
|
2004
|
+
});
|
|
2005
|
+
res.json({
|
|
2006
|
+
ok: true,
|
|
2007
|
+
targetId: tab.targetId
|
|
2008
|
+
});
|
|
2009
|
+
} catch (err) {
|
|
2010
|
+
handleRouteError(ctx, res, err);
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
app.post("/set/device", async (req, res) => {
|
|
2014
|
+
const profileCtx = resolveProfileContext(req, res, ctx);
|
|
2015
|
+
if (!profileCtx) return;
|
|
2016
|
+
const body = readBody(req);
|
|
2017
|
+
const targetId = toStringOrEmpty(body.targetId) || void 0;
|
|
2018
|
+
const name = toStringOrEmpty(body.name);
|
|
2019
|
+
if (!name) return jsonError(res, 400, "name is required");
|
|
2020
|
+
try {
|
|
2021
|
+
const tab = await profileCtx.ensureTabAvailable(targetId);
|
|
2022
|
+
const pw = await requirePwAi(res, "device emulation");
|
|
2023
|
+
if (!pw) return;
|
|
2024
|
+
await pw.setDeviceViaPlaywright({
|
|
2025
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
2026
|
+
targetId: tab.targetId,
|
|
2027
|
+
name
|
|
2028
|
+
});
|
|
2029
|
+
res.json({
|
|
2030
|
+
ok: true,
|
|
2031
|
+
targetId: tab.targetId
|
|
2032
|
+
});
|
|
2033
|
+
} catch (err) {
|
|
2034
|
+
handleRouteError(ctx, res, err);
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
|
|
2039
|
+
//#endregion
|
|
2040
|
+
//#region src/browser/routes/agent.ts
|
|
2041
|
+
function registerBrowserAgentRoutes(app, ctx) {
|
|
2042
|
+
registerBrowserAgentSnapshotRoutes(app, ctx);
|
|
2043
|
+
registerBrowserAgentActRoutes(app, ctx);
|
|
2044
|
+
registerBrowserAgentDebugRoutes(app, ctx);
|
|
2045
|
+
registerBrowserAgentStorageRoutes(app, ctx);
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
//#endregion
|
|
2049
|
+
//#region src/browser/profiles-service.ts
|
|
2050
|
+
const HEX_COLOR_RE = /^#[0-9A-Fa-f]{6}$/;
|
|
2051
|
+
function createBrowserProfilesService(ctx) {
|
|
2052
|
+
const listProfiles = async () => {
|
|
2053
|
+
return await ctx.listProfiles();
|
|
2054
|
+
};
|
|
2055
|
+
const createProfile = async (params) => {
|
|
2056
|
+
const name = params.name.trim();
|
|
2057
|
+
const rawCdpUrl = params.cdpUrl?.trim() || void 0;
|
|
2058
|
+
const driver = params.driver === "extension" ? "extension" : void 0;
|
|
2059
|
+
if (!isValidProfileName(name)) throw new Error("invalid profile name: use lowercase letters, numbers, and hyphens only");
|
|
2060
|
+
const state = ctx.state();
|
|
2061
|
+
const resolvedProfiles = state.resolved.profiles;
|
|
2062
|
+
if (name in resolvedProfiles) throw new Error(`profile "${name}" already exists`);
|
|
2063
|
+
const cfg = loadConfig();
|
|
2064
|
+
const rawProfiles = cfg.browser?.profiles ?? {};
|
|
2065
|
+
if (name in rawProfiles) throw new Error(`profile "${name}" already exists`);
|
|
2066
|
+
const usedColors = getUsedColors(resolvedProfiles);
|
|
2067
|
+
const profileColor = params.color && HEX_COLOR_RE.test(params.color) ? params.color : allocateColor(usedColors);
|
|
2068
|
+
let profileConfig;
|
|
2069
|
+
if (rawCdpUrl) profileConfig = {
|
|
2070
|
+
cdpUrl: parseHttpUrl(rawCdpUrl, "browser.profiles.cdpUrl").normalized,
|
|
2071
|
+
...driver ? { driver } : {},
|
|
2072
|
+
color: profileColor
|
|
2073
|
+
};
|
|
2074
|
+
else {
|
|
2075
|
+
const cdpPort = allocateCdpPort(getUsedPorts(resolvedProfiles), deriveDefaultBrowserCdpPortRange(state.resolved.controlPort));
|
|
2076
|
+
if (cdpPort === null) throw new Error("no available CDP ports in range");
|
|
2077
|
+
profileConfig = {
|
|
2078
|
+
cdpPort,
|
|
2079
|
+
...driver ? { driver } : {},
|
|
2080
|
+
color: profileColor
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
await writeConfigFile({
|
|
2084
|
+
...cfg,
|
|
2085
|
+
browser: {
|
|
2086
|
+
...cfg.browser,
|
|
2087
|
+
profiles: {
|
|
2088
|
+
...rawProfiles,
|
|
2089
|
+
[name]: profileConfig
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
state.resolved.profiles[name] = profileConfig;
|
|
2094
|
+
const resolved = resolveProfile(state.resolved, name);
|
|
2095
|
+
if (!resolved) throw new Error(`profile "${name}" not found after creation`);
|
|
2096
|
+
return {
|
|
2097
|
+
ok: true,
|
|
2098
|
+
profile: name,
|
|
2099
|
+
cdpPort: resolved.cdpPort,
|
|
2100
|
+
cdpUrl: resolved.cdpUrl,
|
|
2101
|
+
color: resolved.color,
|
|
2102
|
+
isRemote: !resolved.cdpIsLoopback
|
|
2103
|
+
};
|
|
2104
|
+
};
|
|
2105
|
+
const deleteProfile = async (nameRaw) => {
|
|
2106
|
+
const name = nameRaw.trim();
|
|
2107
|
+
if (!name) throw new Error("profile name is required");
|
|
2108
|
+
if (!isValidProfileName(name)) throw new Error("invalid profile name");
|
|
2109
|
+
const cfg = loadConfig();
|
|
2110
|
+
const profiles = cfg.browser?.profiles ?? {};
|
|
2111
|
+
if (!(name in profiles)) throw new Error(`profile "${name}" not found`);
|
|
2112
|
+
if (name === (cfg.browser?.defaultProfile ?? DEFAULT_BROWSER_DEFAULT_PROFILE_NAME)) throw new Error(`cannot delete the default profile "${name}"; change browser.defaultProfile first`);
|
|
2113
|
+
let deleted = false;
|
|
2114
|
+
const state = ctx.state();
|
|
2115
|
+
if (resolveProfile(state.resolved, name)?.cdpIsLoopback) {
|
|
2116
|
+
try {
|
|
2117
|
+
await ctx.forProfile(name).stopRunningBrowser();
|
|
2118
|
+
} catch {}
|
|
2119
|
+
const userDataDir = resolveOpenClawUserDataDir(name);
|
|
2120
|
+
const profileDir = path.dirname(userDataDir);
|
|
2121
|
+
if (fs.existsSync(profileDir)) {
|
|
2122
|
+
await movePathToTrash(profileDir);
|
|
2123
|
+
deleted = true;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
const { [name]: _removed, ...remainingProfiles } = profiles;
|
|
2127
|
+
await writeConfigFile({
|
|
2128
|
+
...cfg,
|
|
2129
|
+
browser: {
|
|
2130
|
+
...cfg.browser,
|
|
2131
|
+
profiles: remainingProfiles
|
|
2132
|
+
}
|
|
2133
|
+
});
|
|
2134
|
+
delete state.resolved.profiles[name];
|
|
2135
|
+
state.profiles.delete(name);
|
|
2136
|
+
return {
|
|
2137
|
+
ok: true,
|
|
2138
|
+
profile: name,
|
|
2139
|
+
deleted
|
|
2140
|
+
};
|
|
2141
|
+
};
|
|
2142
|
+
return {
|
|
2143
|
+
listProfiles,
|
|
2144
|
+
createProfile,
|
|
2145
|
+
deleteProfile
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
//#endregion
|
|
2150
|
+
//#region src/browser/routes/basic.ts
|
|
2151
|
+
function registerBrowserBasicRoutes(app, ctx) {
|
|
2152
|
+
app.get("/profiles", async (_req, res) => {
|
|
2153
|
+
try {
|
|
2154
|
+
const profiles = await createBrowserProfilesService(ctx).listProfiles();
|
|
2155
|
+
res.json({ profiles });
|
|
2156
|
+
} catch (err) {
|
|
2157
|
+
jsonError(res, 500, String(err));
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
app.get("/", async (req, res) => {
|
|
2161
|
+
let current;
|
|
2162
|
+
try {
|
|
2163
|
+
current = ctx.state();
|
|
2164
|
+
} catch {
|
|
2165
|
+
return jsonError(res, 503, "browser server not started");
|
|
2166
|
+
}
|
|
2167
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2168
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2169
|
+
const [cdpHttp, cdpReady] = await Promise.all([profileCtx.isHttpReachable(300), profileCtx.isReachable(600)]);
|
|
2170
|
+
const profileState = current.profiles.get(profileCtx.profile.name);
|
|
2171
|
+
let detectedBrowser = null;
|
|
2172
|
+
let detectedExecutablePath = null;
|
|
2173
|
+
let detectError = null;
|
|
2174
|
+
try {
|
|
2175
|
+
const detected = resolveBrowserExecutableForPlatform(current.resolved, process.platform);
|
|
2176
|
+
if (detected) {
|
|
2177
|
+
detectedBrowser = detected.kind;
|
|
2178
|
+
detectedExecutablePath = detected.path;
|
|
2179
|
+
}
|
|
2180
|
+
} catch (err) {
|
|
2181
|
+
detectError = String(err);
|
|
2182
|
+
}
|
|
2183
|
+
res.json({
|
|
2184
|
+
enabled: current.resolved.enabled,
|
|
2185
|
+
profile: profileCtx.profile.name,
|
|
2186
|
+
running: cdpReady,
|
|
2187
|
+
cdpReady,
|
|
2188
|
+
cdpHttp,
|
|
2189
|
+
pid: profileState?.running?.pid ?? null,
|
|
2190
|
+
cdpPort: profileCtx.profile.cdpPort,
|
|
2191
|
+
cdpUrl: profileCtx.profile.cdpUrl,
|
|
2192
|
+
chosenBrowser: profileState?.running?.exe.kind ?? null,
|
|
2193
|
+
detectedBrowser,
|
|
2194
|
+
detectedExecutablePath,
|
|
2195
|
+
detectError,
|
|
2196
|
+
userDataDir: profileState?.running?.userDataDir ?? null,
|
|
2197
|
+
color: profileCtx.profile.color,
|
|
2198
|
+
headless: current.resolved.headless,
|
|
2199
|
+
noSandbox: current.resolved.noSandbox,
|
|
2200
|
+
executablePath: current.resolved.executablePath ?? null,
|
|
2201
|
+
attachOnly: current.resolved.attachOnly
|
|
2202
|
+
});
|
|
2203
|
+
});
|
|
2204
|
+
app.post("/start", async (req, res) => {
|
|
2205
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2206
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2207
|
+
try {
|
|
2208
|
+
await profileCtx.ensureBrowserAvailable();
|
|
2209
|
+
res.json({
|
|
2210
|
+
ok: true,
|
|
2211
|
+
profile: profileCtx.profile.name
|
|
2212
|
+
});
|
|
2213
|
+
} catch (err) {
|
|
2214
|
+
jsonError(res, 500, String(err));
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
app.post("/stop", async (req, res) => {
|
|
2218
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2219
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2220
|
+
try {
|
|
2221
|
+
const result = await profileCtx.stopRunningBrowser();
|
|
2222
|
+
res.json({
|
|
2223
|
+
ok: true,
|
|
2224
|
+
stopped: result.stopped,
|
|
2225
|
+
profile: profileCtx.profile.name
|
|
2226
|
+
});
|
|
2227
|
+
} catch (err) {
|
|
2228
|
+
jsonError(res, 500, String(err));
|
|
2229
|
+
}
|
|
2230
|
+
});
|
|
2231
|
+
app.post("/reset-profile", async (req, res) => {
|
|
2232
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2233
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2234
|
+
try {
|
|
2235
|
+
const result = await profileCtx.resetProfile();
|
|
2236
|
+
res.json({
|
|
2237
|
+
ok: true,
|
|
2238
|
+
profile: profileCtx.profile.name,
|
|
2239
|
+
...result
|
|
2240
|
+
});
|
|
2241
|
+
} catch (err) {
|
|
2242
|
+
jsonError(res, 500, String(err));
|
|
2243
|
+
}
|
|
2244
|
+
});
|
|
2245
|
+
app.post("/profiles/create", async (req, res) => {
|
|
2246
|
+
const name = toStringOrEmpty(req.body?.name);
|
|
2247
|
+
const color = toStringOrEmpty(req.body?.color);
|
|
2248
|
+
const cdpUrl = toStringOrEmpty(req.body?.cdpUrl);
|
|
2249
|
+
const driver = toStringOrEmpty(req.body?.driver);
|
|
2250
|
+
if (!name) return jsonError(res, 400, "name is required");
|
|
2251
|
+
try {
|
|
2252
|
+
const result = await createBrowserProfilesService(ctx).createProfile({
|
|
2253
|
+
name,
|
|
2254
|
+
color: color || void 0,
|
|
2255
|
+
cdpUrl: cdpUrl || void 0,
|
|
2256
|
+
driver: driver === "extension" ? "extension" : void 0
|
|
2257
|
+
});
|
|
2258
|
+
res.json(result);
|
|
2259
|
+
} catch (err) {
|
|
2260
|
+
const msg = String(err);
|
|
2261
|
+
if (msg.includes("already exists")) return jsonError(res, 409, msg);
|
|
2262
|
+
if (msg.includes("invalid profile name")) return jsonError(res, 400, msg);
|
|
2263
|
+
if (msg.includes("no available CDP ports")) return jsonError(res, 507, msg);
|
|
2264
|
+
if (msg.includes("cdpUrl")) return jsonError(res, 400, msg);
|
|
2265
|
+
jsonError(res, 500, msg);
|
|
2266
|
+
}
|
|
2267
|
+
});
|
|
2268
|
+
app.delete("/profiles/:name", async (req, res) => {
|
|
2269
|
+
const name = toStringOrEmpty(req.params.name);
|
|
2270
|
+
if (!name) return jsonError(res, 400, "profile name is required");
|
|
2271
|
+
try {
|
|
2272
|
+
const result = await createBrowserProfilesService(ctx).deleteProfile(name);
|
|
2273
|
+
res.json(result);
|
|
2274
|
+
} catch (err) {
|
|
2275
|
+
const msg = String(err);
|
|
2276
|
+
if (msg.includes("invalid profile name")) return jsonError(res, 400, msg);
|
|
2277
|
+
if (msg.includes("default profile")) return jsonError(res, 400, msg);
|
|
2278
|
+
if (msg.includes("not found")) return jsonError(res, 404, msg);
|
|
2279
|
+
jsonError(res, 500, msg);
|
|
2280
|
+
}
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
//#endregion
|
|
2285
|
+
//#region src/browser/routes/tabs.ts
|
|
2286
|
+
function registerBrowserTabRoutes(app, ctx) {
|
|
2287
|
+
app.get("/tabs", async (req, res) => {
|
|
2288
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2289
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2290
|
+
try {
|
|
2291
|
+
if (!await profileCtx.isReachable(300)) return res.json({
|
|
2292
|
+
running: false,
|
|
2293
|
+
tabs: []
|
|
2294
|
+
});
|
|
2295
|
+
const tabs = await profileCtx.listTabs();
|
|
2296
|
+
res.json({
|
|
2297
|
+
running: true,
|
|
2298
|
+
tabs
|
|
2299
|
+
});
|
|
2300
|
+
} catch (err) {
|
|
2301
|
+
jsonError(res, 500, String(err));
|
|
2302
|
+
}
|
|
2303
|
+
});
|
|
2304
|
+
app.post("/tabs/open", async (req, res) => {
|
|
2305
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2306
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2307
|
+
const url = toStringOrEmpty(req.body?.url);
|
|
2308
|
+
if (!url) return jsonError(res, 400, "url is required");
|
|
2309
|
+
try {
|
|
2310
|
+
await profileCtx.ensureBrowserAvailable();
|
|
2311
|
+
const tab = await profileCtx.openTab(url);
|
|
2312
|
+
res.json(tab);
|
|
2313
|
+
} catch (err) {
|
|
2314
|
+
jsonError(res, 500, String(err));
|
|
2315
|
+
}
|
|
2316
|
+
});
|
|
2317
|
+
app.post("/tabs/focus", async (req, res) => {
|
|
2318
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2319
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2320
|
+
const targetId = toStringOrEmpty(req.body?.targetId);
|
|
2321
|
+
if (!targetId) return jsonError(res, 400, "targetId is required");
|
|
2322
|
+
try {
|
|
2323
|
+
if (!await profileCtx.isReachable(300)) return jsonError(res, 409, "browser not running");
|
|
2324
|
+
await profileCtx.focusTab(targetId);
|
|
2325
|
+
res.json({ ok: true });
|
|
2326
|
+
} catch (err) {
|
|
2327
|
+
const mapped = ctx.mapTabError(err);
|
|
2328
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
2329
|
+
jsonError(res, 500, String(err));
|
|
2330
|
+
}
|
|
2331
|
+
});
|
|
2332
|
+
app.delete("/tabs/:targetId", async (req, res) => {
|
|
2333
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2334
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2335
|
+
const targetId = toStringOrEmpty(req.params.targetId);
|
|
2336
|
+
if (!targetId) return jsonError(res, 400, "targetId is required");
|
|
2337
|
+
try {
|
|
2338
|
+
if (!await profileCtx.isReachable(300)) return jsonError(res, 409, "browser not running");
|
|
2339
|
+
await profileCtx.closeTab(targetId);
|
|
2340
|
+
res.json({ ok: true });
|
|
2341
|
+
} catch (err) {
|
|
2342
|
+
const mapped = ctx.mapTabError(err);
|
|
2343
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
2344
|
+
jsonError(res, 500, String(err));
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
app.post("/tabs/action", async (req, res) => {
|
|
2348
|
+
const profileCtx = getProfileContext(req, ctx);
|
|
2349
|
+
if ("error" in profileCtx) return jsonError(res, profileCtx.status, profileCtx.error);
|
|
2350
|
+
const action = toStringOrEmpty(req.body?.action);
|
|
2351
|
+
const index = toNumber(req.body?.index);
|
|
2352
|
+
try {
|
|
2353
|
+
if (action === "list") {
|
|
2354
|
+
if (!await profileCtx.isReachable(300)) return res.json({
|
|
2355
|
+
ok: true,
|
|
2356
|
+
tabs: []
|
|
2357
|
+
});
|
|
2358
|
+
const tabs = await profileCtx.listTabs();
|
|
2359
|
+
return res.json({
|
|
2360
|
+
ok: true,
|
|
2361
|
+
tabs
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
if (action === "new") {
|
|
2365
|
+
await profileCtx.ensureBrowserAvailable();
|
|
2366
|
+
const tab = await profileCtx.openTab("about:blank");
|
|
2367
|
+
return res.json({
|
|
2368
|
+
ok: true,
|
|
2369
|
+
tab
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
if (action === "close") {
|
|
2373
|
+
const tabs = await profileCtx.listTabs();
|
|
2374
|
+
const target = typeof index === "number" ? tabs[index] : tabs.at(0);
|
|
2375
|
+
if (!target) return jsonError(res, 404, "tab not found");
|
|
2376
|
+
await profileCtx.closeTab(target.targetId);
|
|
2377
|
+
return res.json({
|
|
2378
|
+
ok: true,
|
|
2379
|
+
targetId: target.targetId
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
if (action === "select") {
|
|
2383
|
+
if (typeof index !== "number") return jsonError(res, 400, "index is required");
|
|
2384
|
+
const target = (await profileCtx.listTabs())[index];
|
|
2385
|
+
if (!target) return jsonError(res, 404, "tab not found");
|
|
2386
|
+
await profileCtx.focusTab(target.targetId);
|
|
2387
|
+
return res.json({
|
|
2388
|
+
ok: true,
|
|
2389
|
+
targetId: target.targetId
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2392
|
+
return jsonError(res, 400, "unknown tab action");
|
|
2393
|
+
} catch (err) {
|
|
2394
|
+
const mapped = ctx.mapTabError(err);
|
|
2395
|
+
if (mapped) return jsonError(res, mapped.status, mapped.message);
|
|
2396
|
+
jsonError(res, 500, String(err));
|
|
2397
|
+
}
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
//#endregion
|
|
2402
|
+
//#region src/browser/routes/index.ts
|
|
2403
|
+
function registerBrowserRoutes(app, ctx) {
|
|
2404
|
+
registerBrowserBasicRoutes(app, ctx);
|
|
2405
|
+
registerBrowserTabRoutes(app, ctx);
|
|
2406
|
+
registerBrowserAgentRoutes(app, ctx);
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
//#endregion
|
|
2410
|
+
export { resolvePinnedHostnameWithPolicy as C, resolvePinnedHostname as S, maxBytesForKind as _, optimizeImageToPng as a, closeDispatcher as b, saveMediaBuffer as c, getFileExtension as d, imageMimeFromFormat as f, MAX_IMAGE_BYTES as g, kindFromMime as h, hasAlphaChannel as i, detectMime as l, isGifMedia as m, convertHeicToJpeg as n, resizeToJpeg as o, isAudioFileName as p, getImageMetadata as r, getMediaDir as s, registerBrowserRoutes as t, extensionForMime as u, mediaKindFromMime as v, createPinnedDispatcher as x, SsrFBlockedError as y };
|