@hanzo/bot 2026.3.7 → 2026.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accounts-D-CXitCL.js → accounts-BVV0eCmx.js} +2 -2
- package/dist/{accounts-Da-TWEIc.js → accounts-C04lw_uh.js} +4 -4
- package/dist/{accounts-DRUpcCkN.js → accounts-CtzU1wJb.js} +2 -2
- package/dist/{acp-cli-DYkqqqaJ.js → acp-cli-CDUVvPjD.js} +28 -24
- package/dist/{active-listener-DlziGqIg.js → active-listener-NprMzFx6.js} +2 -2
- package/dist/{agent-scope-C5bklqr1.js → agent-scope-BcruZHHR.js} +5 -5
- package/dist/{agents-CH9da9zi.js → agents-D8rH1P3g.js} +20 -19
- package/dist/{agents.config-BQ8I8wuY.js → agents.config-OuZqDEe6.js} +4 -4
- package/dist/{api-0IJLBHQk.js → api-Bgrt1pfd.js} +1 -1
- package/dist/{api-key-rotation-DuxfwUin.js → api-key-rotation-C0toONXd.js} +2 -2
- package/dist/{audio-preflight-CpAXC_Ct.js → audio-preflight-BEc8i-bS.js} +4 -4
- package/dist/{audio-preflight-BnfuyvxO.js → audio-preflight-D_s-peid.js} +4 -4
- package/dist/audio-preflight-d9iZknwY.js +102 -0
- package/dist/{audio-transcription-runner-GcMnO6sT.js → audio-transcription-runner-BePCnZfw.js} +1 -1
- package/dist/{audio-transcription-runner-CAOjjGxN.js → audio-transcription-runner-X1KzI7dF.js} +1 -1
- package/dist/{audio-transcription-runner-DCsEpXgz.js → audio-transcription-runner-bvBQs8UB.js} +13 -13
- package/dist/{audit-DCJbont3.js → audit-BWNRwu8g.js} +28 -28
- package/dist/{audit-membership-runtime-BIZ4bigJ.js → audit-membership-runtime-Bki8LzkA.js} +7 -6
- package/dist/{auth-CqlFkBrB.js → auth-CWHo884l.js} +5 -5
- package/dist/{auth-choice-9obtL17m.js → auth-choice-DUtpqOiw.js} +25 -22
- package/dist/{auth-choice-w2mL3d_M.js → auth-choice-n72qSpix.js} +15 -14
- package/dist/{auth-choice-options-DMoNPDm6.js → auth-choice-options-D13GahL8.js} +1 -1
- package/dist/{auth-choice-prompt-Btp8AqFI.js → auth-choice-prompt-8z7z_AUr.js} +1 -1
- package/dist/{auth-choice.apply-helpers-JU7nAiWC.js → auth-choice.apply-helpers-DMhFdoYH.js} +3 -3
- package/dist/{auth-mode-policy-slU2Nkgr.js → auth-mode-policy-BopOhrK8.js} +1 -1
- package/dist/{auth-profiles-BCHBDrea.js → auth-profiles-BtxyXCZY.js} +48 -925
- package/dist/{auth-token-BfzDARSk.js → auth-token-zcumGtdt.js} +3 -3
- package/dist/{banner-C4sx0Vaf.js → banner-C1G_GtAz.js} +3 -3
- package/dist/{bonjour-discovery-CzNIGZ7K.js → bonjour-discovery-C1SH2QqR.js} +3 -3
- package/dist/{browser-cli-qPNZkfDX.js → browser-cli-Bd81bwqM.js} +36 -32
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +6 -6
- package/dist/bundled/session-memory/handler.js +6 -6
- package/dist/{call-C4z2LJrI.js → call-DL23sPxF.js} +9 -8
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-account-context-DyLW8OD1.js → channel-account-context-DGbGZhGz.js} +3 -3
- package/dist/{channel-activity-Bch3Rz78.js → channel-activity-DItBzFyQ.js} +3 -3
- package/dist/{channel-options-ChtPFPQx.js → channel-options-DU65sVdF.js} +4 -4
- package/dist/{channel-selection-CXz2aSCs.js → channel-selection-BnXQH0vV.js} +2 -2
- package/dist/{channel-web-Bok0lFvq.js → channel-web-BbWnfun7.js} +25 -24
- package/dist/{channels-cli-B5oDUpEB.js → channels-cli-B8LCe0vu.js} +142 -135
- package/dist/{channels-status-issues-BAy-21Cb.js → channels-status-issues-DXNaEL8i.js} +1 -1
- package/dist/{chrome--CFg5C_H.js → chrome-B24-8NDM.js} +8 -8
- package/dist/{chrome-jCt9JCU8.js → chrome-C7OwLtx9.js} +8 -8
- package/dist/{chrome-TWq_09_a.js → chrome-D4EfbMKb.js} +7 -7
- package/dist/{clack-prompter-0Rux0QKP.js → clack-prompter-CNKAp_jq.js} +5 -5
- package/dist/clawbot-cli-Bv8oZgvA.js +36 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-DXbYdTNH.js +162 -0
- package/dist/{client-DWdu7Vc_.js → client-Bvvecv3V.js} +25 -142
- package/dist/{clipboard-Bfhk9cp3.js → clipboard-DwO9zZBK.js} +1 -1
- package/dist/{cloud-connect-BERMG0cQ.js → cloud-connect-CknfBF39.js} +89 -52
- package/dist/cloud-launch-7mm4ZKXy.js +172 -0
- package/dist/{command-poll-backoff.runtime-COz7plyi.js → command-poll-backoff.runtime-ClRAZFDL.js} +1 -1
- package/dist/{command-registry-DTMuq-Fw.js → command-registry-CTaJSsqV.js} +11 -11
- package/dist/{command-secret-targets-B2OuvZQf.js → command-secret-targets-C382v6Qd.js} +6 -6
- package/dist/{commands-BAjCW6P6.js → commands-BoGUirwW.js} +2 -2
- package/dist/{commands-registry-bwa5zMJ1.js → commands-registry-Dn_5_JYs.js} +6 -6
- package/dist/{compact-CenE94cW.js → compact-CuLMew-8.js} +141 -910
- package/dist/{completion-cli-spiS5-xU.js → completion-cli-CixfDHo4.js} +6 -6
- package/dist/{config-cli-w-RlQ3jB.js → config-cli-Bu2Eakz-.js} +22 -19
- package/dist/{config-guard-rlTIXCSD.js → config-guard-Bt2BdsMd.js} +5 -5
- package/dist/{config-validation-B3rr-h3d.js → config-validation-WdHwRX05.js} +6 -6
- package/dist/{configure-YxPFskRy.js → configure-ClIJiVqS.js} +32 -31
- package/dist/{control-ui-assets-CvLJNwEr.js → control-ui-assets-Co9rmXkB.js} +3 -3
- package/dist/{credentials-DVX7Krq5.js → credentials-SIFZMlmo.js} +1 -1
- package/dist/{cron-cli-DI9DN0vu.js → cron-cli-DR13ajr7.js} +32 -28
- package/dist/{daemon-cli-OBRBnIhu.js → daemon-cli-C6ZVajFI.js} +28 -28
- package/dist/{daemon-install-CGk2QyeB.js → daemon-install-DsDcMh2v.js} +43 -39
- package/dist/{daemon-install-helpers-C1QLEGFF.js → daemon-install-helpers-BtOiCRD1.js} +7 -35
- package/dist/{deliver-DPkEY6xb.js → deliver-Bge0HwrF.js} +13 -13
- package/dist/{deliver-BVtVDxwX.js → deliver-D8dBbzpu.js} +1 -1
- package/dist/{deliver-DmfS4khs.js → deliver-DudaV86i.js} +1 -1
- package/dist/{deliver-runtime-G0G5orrZ.js → deliver-runtime-C76IMU4W.js} +3 -3
- package/dist/{deliver-runtime-PxJvVUhh.js → deliver-runtime-qDmQqiF-.js} +3 -3
- package/dist/deliver-runtime-s0eLCemL.js +63 -0
- package/dist/{delivery-queue-DgdE_Ifa.js → delivery-queue-BVKd_xSI.js} +1 -1
- package/dist/deps-send-discord.runtime-C8HKp3uO.js +37 -0
- package/dist/deps-send-imessage.runtime-ECy162Cs.js +36 -0
- package/dist/deps-send-signal.runtime-XbioSg-_.js +35 -0
- package/dist/deps-send-slack.runtime-BM7Vp8vX.js +33 -0
- package/dist/deps-send-telegram.runtime-IFD4dAk7.js +39 -0
- package/dist/deps-send-whatsapp.runtime-BHuShWkA.js +124 -0
- package/dist/{deps-send-whatsapp.runtime-CrzuaVhC.js → deps-send-whatsapp.runtime-Cq-TLsJw.js} +7 -7
- package/dist/{deps-send-whatsapp.runtime-8bLqjmui.js → deps-send-whatsapp.runtime-Cv_awFtm.js} +7 -7
- package/dist/device-identity-DtdLP7QQ.js +148 -0
- package/dist/{devices-cli-C7xKmiR9.js → devices-cli-DZRtpqol.js} +25 -21
- package/dist/{diagnostic-DCevSIi3.js → diagnostic-CXxZq_XY.js} +3 -3
- package/dist/{diagnostics-vhe8iPOe.js → diagnostics-GQuagqCt.js} +1 -1
- package/dist/{directory-cli-BrLvL2oD.js → directory-cli-Tqim_rB9.js} +24 -21
- package/dist/{dns-cli-Dcytc0em.js → dns-cli-AcAZnW-T.js} +19 -16
- package/dist/{dock-D1Nz-RwP.js → dock-nMBfeGKa.js} +7 -7
- package/dist/{docs-cli-CjnLrTzs.js → docs-cli-C6mNYtxD.js} +17 -16
- package/dist/{doctor-completion-BKaFgAAN.js → doctor-completion-Dg6AJY6Q.js} +4 -4
- package/dist/{doctor-config-flow-Bp3eehAS.js → doctor-config-flow-CKY6Mr3X.js} +19 -19
- package/dist/{enable-pUSco1cm.js → enable-BWraNcrd.js} +2 -2
- package/dist/entry.js +6 -5
- package/dist/{errors-Dh5KARaE.js → errors-ClLWB67m.js} +1 -1
- package/dist/{exec-B45rafWZ.js → exec-B8Hv4Nkd.js} +1 -1
- package/dist/{exec-approvals-B5leCM6K.js → exec-approvals-Bh1osORd.js} +1 -1
- package/dist/{exec-approvals-allowlist-CSlk-iUy.js → exec-approvals-allowlist-dlIMsRq0.js} +1 -1
- package/dist/{exec-approvals-cli-B722kWhJ.js → exec-approvals-cli-B2V935Or.js} +33 -29
- package/dist/{exec-safe-bin-runtime-policy-C4OXhXIe.js → exec-safe-bin-runtime-policy-Ds-cMyOt.js} +2 -2
- package/dist/extensionAPI.js +6 -6
- package/dist/{fetch-COQIeEVX.js → fetch-BPh3R9xH.js} +3 -3
- package/dist/{fetch-TlhZeXdg.js → fetch-DyJnPUwL.js} +1 -1
- package/dist/{fetch-guard-BiNciKHu.js → fetch-guard-hL-C2yQz.js} +3 -3
- package/dist/{frontmatter-BIwJR052.js → frontmatter-B0viix_h.js} +2 -2
- package/dist/{fs-safe-DtMJsayp.js → fs-safe-CFIinCN2.js} +3 -3
- package/dist/gateway-cli-DjWebqxe.js +1436 -0
- package/dist/{gateway-install-token-tifgQqTq.js → gateway-install-token-olAkdWwV.js} +6 -6
- package/dist/gateway-lock-DNpln_70.js +192 -0
- package/dist/{gateway-rpc--AYNXZQF.js → gateway-rpc-B37zbuoK.js} +3 -3
- package/dist/{github-copilot-token-Byc_YVYE.js → github-copilot-token-BKQ4nXAw.js} +2 -23
- package/dist/{gmail-setup-utils-B1wEc-nz.js → gmail-setup-utils-DuoBM8ed.js} +3 -3
- package/dist/{health-DTtmaQPz.js → health-Cs-k6kLT.js} +18 -16
- package/dist/{helpers-CIEbwEWl.js → helpers-DDBxLojl.js} +1 -1
- package/dist/{hooks-cli-DJDBpL-Z.js → hooks-cli-Zqdxhm6M.js} +123 -116
- package/dist/{hooks-status-CFT0VML6.js → hooks-status-DqCwY9M6.js} +4 -4
- package/dist/{image-DSK1hSSV.js → image-BOybyCis.js} +1 -1
- package/dist/{image-DFnt4Uwg.js → image-m1GU1uco.js} +7 -7
- package/dist/{image-BdZcUz8M.js → image-nUHQF6BX.js} +1 -1
- package/dist/{image-ops-DBPCaLYI.js → image-ops-Bnk-bI_x.js} +1 -1
- package/dist/{image-runtime-ueqmfx1a.js → image-runtime-B5M_-diF.js} +3 -3
- package/dist/image-runtime-CesErRak.js +57 -0
- package/dist/{image-runtime-xqxW2PQA.js → image-runtime-y4msd5bn.js} +3 -3
- package/dist/{inspect-BVm4U2OP.js → inspect-CMuOPXUf.js} +2 -2
- package/dist/{install-safe-path-Df97RWiJ.js → install-safe-path-BxdyoAni.js} +3 -3
- package/dist/{installs-BGMsioU1.js → installs-c4kWJSG4.js} +8 -8
- package/dist/ip-C7WWCRN7.js +204 -0
- package/dist/{ipv4-Difv_P0_.js → ipv4-DcjwXncJ.js} +2 -2
- package/dist/{ir-CaGizvli.js → ir-BjnGKA2N.js} +8 -8
- package/dist/{issue-format-DjqrcimU.js → issue-format-BMPYbT1P.js} +1 -1
- package/dist/json-file-CNp4GTiH.js +25 -0
- package/dist/{lifecycle-core-BXWGDU3R.js → lifecycle-core-fN_BonzB.js} +10 -10
- package/dist/{links-C7eMwu1P.js → links-DZZ9QxWA.js} +1 -1
- package/dist/llm-slug-generator.js +6 -6
- package/dist/local-launch-C2RER-G3.js +126 -0
- package/dist/{logger-DB-PHqB2.js → logger-DyQjakwH.js} +2 -1
- package/dist/{logging-CS4C9VwV.js → logging--bXnY6uw.js} +1 -1
- package/dist/{login-B8HwtO61.js → login-DTK-M8Is.js} +6 -6
- package/dist/{login-qr-amd1X6Dw.js → login-qr-CmnyPjTv.js} +29 -16
- package/dist/{logs-cli-BH8DNgo2.js → logs-cli-BSlzurlM.js} +27 -23
- package/dist/machine-name-BWZ0tBHk.js +41 -0
- package/dist/{manager-BYSXh-I3.js → manager-BVqjeGyT.js} +11 -11
- package/dist/manager-runtime-CBdUM6c8.js +27 -0
- package/dist/{manifest-registry-9oWnIuht.js → manifest-registry-m_hXBIk-.js} +4 -4
- package/dist/{memory-cli-C6ocXZHW.js → memory-cli-yvsbLFgi.js} +15 -14
- package/dist/{message-channel-7mpcAPwa.js → message-channel-DOpIvru6.js} +34 -2
- package/dist/{model-catalog-B3fDLVsV.js → model-catalog-DtjVcDuN.js} +11 -5
- package/dist/{model-picker-V0gt2kzq.js → model-picker-oa-NsQXX.js} +5 -4
- package/dist/{models-D9CovevI.js → models-Bi78FQeE.js} +26 -25
- package/dist/{models-cli-CQBq_lri.js → models-cli-DUkH_80R.js} +126 -119
- package/dist/{models-config-Tnpb1ctj.js → models-config-D_IvpQGa.js} +3 -2
- package/dist/{node-cli-Cy9sSHy5.js → node-cli-B1iGQlR9.js} +61 -54
- package/dist/{node-command-policy-C9mK2tft.js → node-command-policy-CeKPGmlP.js} +2 -2
- package/dist/node-commands-sMomb3e1.js +20 -0
- package/dist/{node-service-DB36GYv5.js → node-service-BLMp6VWJ.js} +2 -2
- package/dist/{nodes-cli-DEtlooE3.js → nodes-cli-CD9qv7k5.js} +39 -35
- package/dist/{nodes-screen-DmJ2G431.js → nodes-screen-X8daVm8e.js} +5 -5
- package/dist/{note-DI9vedAF.js → note-C3wyXRP2.js} +2 -2
- package/dist/{npm-pack-install-_OjtFm2J.js → npm-pack-install-B0X6q-Co.js} +3 -3
- package/dist/{npm-resolution-DzmQqopk.js → npm-resolution-CavQ2ST5.js} +5 -5
- package/dist/{oauth-env-DKoO0B8-.js → oauth-env-9SRuwpTK.js} +1 -1
- package/dist/{oauth-tls-preflight-Dzh0FiLy.js → oauth-tls-preflight-C_9v9ytQ.js} +2 -2
- package/dist/{onboard-B_1mmscr.js → onboard-Dgav6iT6.js} +17 -17
- package/dist/{onboard-auth.credentials-CtuA7DuT.js → onboard-auth.credentials-CMsut-0h.js} +4 -3
- package/dist/{onboard-channels-C1ZeD4r3.js → onboard-channels-oAN4ja4v.js} +26 -25
- package/dist/{onboard-custom-BU2l3aiF.js → onboard-custom-B3RIFmaw.js} +7 -7
- package/dist/{onboard-helpers-Dtu3-e93.js → onboard-helpers-BkwNJPNU.js} +12 -12
- package/dist/{onboard-hooks-w-a3FVVK.js → onboard-hooks-BRCGmt7Q.js} +12 -11
- package/dist/{onboard-remote-C-HD7hQU.js → onboard-remote-CE5v5J2R.js} +5 -5
- package/dist/{onboard-skills-DvgdlwqH.js → onboard-skills-DD5L2MsA.js} +5 -5
- package/dist/{onboarding-DozRyXTe.js → onboarding-gbgi-zx9.js} +23 -23
- package/dist/{onboarding.finalize-BfSNnhpS.js → onboarding.finalize-dk1j3ozb.js} +135 -128
- package/dist/{onboarding.gateway-config-C02W81hD.js → onboarding.gateway-config-DNQfWDVc.js} +39 -34
- package/dist/{onboarding.secret-input-BO32ZliB.js → onboarding.secret-input-BDId1_5K.js} +2 -2
- package/dist/{openai-codex-model-default-gJryyHmS.js → openai-codex-model-default-EWrFsdir.js} +5 -5
- package/dist/{openai-model-default-D2LuX7D-.js → openai-model-default-CcOzYsIQ.js} +3 -3
- package/dist/{outbound-CXQEMm6n.js → outbound-DCuHHD3G.js} +8 -8
- package/dist/{outbound-attachment-D7sOzAQn.js → outbound-attachment-Bm82Qbyl.js} +3 -3
- package/dist/{pairing-cli-BkbpM3Mt.js → pairing-cli-dXCvRk1U.js} +23 -20
- package/dist/{pairing-labels-CjKrz2C9.js → pairing-labels-B_3GjgjR.js} +1 -1
- package/dist/{pairing-store-nyK6CFoT.js → pairing-store-CXFEv3Gr.js} +5 -5
- package/dist/{pairing-token-Tb0YsOGr.js → pairing-token-BIAdQuAM.js} +1 -1
- package/dist/{path-alias-guards-CUaIvLOE.js → path-alias-guards-Bz8AnRb7.js} +1 -1
- package/dist/{path-env-LTMy-Xkk.js → path-env-CgmdxEc7.js} +1 -1
- package/dist/{path-safety-DwIbN_B2.js → path-safety-EkGa1GqP.js} +1 -1
- package/dist/{paths-Dr0uMr7v.js → paths-BBXgPm_n.js} +2 -2
- package/dist/{paths-0GcCtgXm.js → paths-gTdorMgW.js} +1 -1
- package/dist/{pi-embedded-DBn841N-.js → pi-embedded-BHXPs-Ix.js} +24 -24
- package/dist/{pi-embedded-DYc6emwb.js → pi-embedded-DvWHP6Nn.js} +24 -24
- package/dist/{pi-embedded-helpers-BMC2HFyB.js → pi-embedded-helpers-CCkKNz_h.js} +5 -5
- package/dist/{pi-embedded-helpers-DLm1Mtr2.js → pi-embedded-helpers-Ck1qEeMH.js} +3 -3
- package/dist/{pi-embedded-helpers-BtnBVL-4.js → pi-embedded-helpers-xIXwvwuE.js} +3 -3
- package/dist/{pi-model-discovery-BUP6uy2Q.js → pi-model-discovery-6_opNECD.js} +2 -1
- package/dist/pi-model-discovery-runtime-8K2F-Fkl.js +20 -0
- package/dist/{pi-tools.before-tool-call.runtime-r5_UoU-W.js → pi-tools.before-tool-call.runtime-BrFKAhWX.js} +16 -13
- package/dist/{pi-tools.policy-C_cbrlt5.js → pi-tools.policy-U1G3dAzL.js} +9 -9
- package/dist/{plugin-auto-enable-DdGdWKDo.js → plugin-auto-enable-3v7X3qMK.js} +6 -6
- package/dist/{plugin-registry-FdOZQF3c.js → plugin-registry-Brz1ypl9.js} +5 -5
- package/dist/{plugins-D3Wuignn.js → plugins-CCkC0dRo.js} +7 -6
- package/dist/{plugins-cli-CV4ilsn4.js → plugins-cli-DGfFRLeo.js} +123 -116
- package/dist/{ports-BZsa4E0e.js → ports-BG0KrTF5.js} +3 -2
- package/dist/{ports-B8DmvnDT.js → ports-BxwhTkI2.js} +5 -29
- package/dist/ports-lsof-C-KFQ3hh.js +27 -0
- package/dist/{probe-D23qt8BT.js → probe-AK77B0YW.js} +4 -4
- package/dist/{program-GusnXq4M.js → program-DfJJCEJW.js} +125 -118
- package/dist/{progress-DLHMb9Nz.js → progress-DB5E2Y0L.js} +1 -1
- package/dist/{prompt-select-styled-B8L90ha2.js → prompt-select-styled-Cm8h3ln5.js} +50 -49
- package/dist/{provider-auth-helpers-DCzPHYBh.js → provider-auth-helpers-BWFf-ICH.js} +9 -8
- package/dist/{proxy-env-CKBWNd19.js → proxy-env-a_fwG5uV.js} +1 -1
- package/dist/{proxy-fetch-CuomJeW8.js → proxy-fetch-B-9MM6tH.js} +1 -1
- package/dist/{push-apns-BNjpWCK5.js → push-apns-D7Kl5IlU.js} +6 -6
- package/dist/{pw-ai-DbzNFC8m.js → pw-ai-BuJLXHSR.js} +28 -24
- package/dist/{pw-ai-pJMhS79V.js → pw-ai-DsYmOxCp.js} +1 -1
- package/dist/{pw-ai-C-Sy12jT.js → pw-ai-DweqbnMJ.js} +1 -1
- package/dist/{qmd-manager-BuqPkrhL.js → qmd-manager-ChOTfdZQ.js} +14 -13
- package/dist/{qr-cli-DCqr6_WR.js → qr-cli-CNV3ou88.js} +8 -7
- package/dist/{redact-snapshot-COg8NLLO.js → redact-snapshot-DDgxiqE4.js} +3 -3
- package/dist/{register.agent-yjg7wijd.js → register.agent-B6lw56u_.js} +147 -140
- package/dist/register.configure-A26LOYA5.js +173 -0
- package/dist/{register.maintenance-B1tKJXP8.js → register.maintenance-Bv41DKCC.js} +144 -136
- package/dist/{register.message-BJm9UQ1U.js → register.message-BTZUaOa_.js} +119 -112
- package/dist/{register.onboard-Si5PW3Ke.js → register.onboard-Cla_XQtJ.js} +47 -43
- package/dist/{register.setup-Dgd21xa5.js → register.setup-BO3qmf_4.js} +46 -42
- package/dist/{register.status-health-sessions-DijNX4q2.js → register.status-health-sessions-DQxR8MS5.js} +134 -127
- package/dist/{register.subclis-RfmNwdNw.js → register.subclis-CasWzZR5.js} +32 -32
- package/dist/{registry-CxLUHPLp.js → registry-DnJ84ILp.js} +6 -83
- package/dist/{resolve-configured-secret-input-string-ySbc3h26.js → resolve-configured-secret-input-string-D9uWNIsN.js} +2 -2
- package/dist/restart-D97MOP8K.js +782 -0
- package/dist/{rpc-DaYUgLOy.js → rpc-DyZoASXQ.js} +4 -4
- package/dist/run-loop-Zvh_699t.js +224 -0
- package/dist/{run-main-t3x2kkjY.js → run-main-CgFUs81l.js} +148 -133
- package/dist/{runtime-BkR9qMZk.js → runtime-BBknab-X.js} +6 -5
- package/dist/runtime-CvdZtNmJ.js +100 -0
- package/dist/{runtime-config-collectors-CCkqshyY.js → runtime-config-collectors-CML7zUqZ.js} +2 -2
- package/dist/{runtime-guard-BMUPc-7K.js → runtime-guard-jpG1v0SY.js} +1 -1
- package/dist/runtime-whatsapp-login.runtime-COI7KRKp.js +23 -0
- package/dist/runtime-whatsapp-outbound.runtime-la1XDkPQ.js +33 -0
- package/dist/{sandbox-DN9CY7lp.js → sandbox-DKscghPx.js} +19 -18
- package/dist/{sandbox-cli-BoXV0LgP.js → sandbox-cli-CPwPZJBq.js} +52 -48
- package/dist/{secrets-cli-CyF7PIF1.js → secrets-cli-BY0IyBZM.js} +31 -26
- package/dist/{security-cli-Dyvx1GHA.js → security-cli-CG6OlQ29.js} +66 -61
- package/dist/{send-7T5wUQDt.js → send-BSbPEzn5.js} +7 -7
- package/dist/{send-Ge3BmrKO.js → send-C2xEPjDg.js} +8 -8
- package/dist/{send-DGbx1H-1.js → send-CFNNbHEA.js} +11 -11
- package/dist/{send-rLuC3ZNP.js → send-CIW-foVz.js} +7 -7
- package/dist/{send-CGAq-Ure.js → send-CZtdjq0Y.js} +20 -20
- package/dist/{gateway-cli-D7jJhAZQ.js → server-CG9eco0N.js} +122 -1835
- package/dist/{server-BM8Bplbe.js → server-DfSS2w17.js} +36 -32
- package/dist/{server-context-B1j20KiF.js → server-context-CcW_Z5sB.js} +15 -15
- package/dist/{server-lifecycle-D8uRbSiN.js → server-lifecycle-DWK8vMXD.js} +2 -2
- package/dist/{server-middleware-C0e-wReR.js → server-middleware-BtyTo4hI.js} +2 -2
- package/dist/{server-node-events-C876mSJD.js → server-node-events-Ck1bPPa5.js} +117 -110
- package/dist/{service-BJxGQl0h.js → service-DnXLOpYd.js} +2 -2
- package/dist/{session-1LXasKCO.js → session-Dnt2qKJU.js} +4 -4
- package/dist/{session-cost-usage-BKD6u4HD.js → session-cost-usage-CBHvFXhD.js} +3 -3
- package/dist/{session-utils-CigqosOc.js → session-utils-t4ZmEDMj.js} +9 -8
- package/dist/{sessions-Db2DF_68.js → sessions-BkKVGWHa.js} +13 -12
- package/dist/{sessions-CwRdJvxU.js → sessions-D6VEpJTN.js} +7 -7
- package/dist/{shared-DcKZdze7.js → shared-DKj9yygb.js} +4 -4
- package/dist/{skill-commands-BFUWbeCU.js → skill-commands-Dyi0nIIE.js} +8 -8
- package/dist/{skill-scanner-B5APVdka.js → skill-scanner-C6efDeWr.js} +2 -2
- package/dist/{skills-DjMDgmlj.js → skills-Cp-zTGor.js} +8 -8
- package/dist/{skills-cli-CvDeA9Mz.js → skills-cli-BcLVYbwo.js} +19 -16
- package/dist/{skills-install-jLz2vwvm.js → skills-install-LXdiRh5j.js} +10 -10
- package/dist/{skills-status-CeHRbTXe.js → skills-status-NIhVZfqm.js} +5 -5
- package/dist/slash-commands.runtime-Bq0XWi2w.js +28 -0
- package/dist/slash-dispatch.runtime-7RhcnuYY.js +119 -0
- package/dist/{slash-dispatch.runtime-DLP2IeNv.js → slash-dispatch.runtime-D28-UnsO.js} +6 -6
- package/dist/{slash-dispatch.runtime-Vp6IDoCc.js → slash-dispatch.runtime-DzpJjr3K.js} +6 -6
- package/dist/slash-skill-commands.runtime-HWFM7WtA.js +34 -0
- package/dist/{sqlite-C0jSdAfK.js → sqlite-BOrw_KhN.js} +4 -4
- package/dist/stable-node-path-BghYt81T.js +32 -0
- package/dist/{status-D3cIxG_a.js → status-DN8lRmcz.js} +40 -40
- package/dist/{status-pXeXDUup.js → status-DNPn0STZ.js} +1 -1
- package/dist/{status.update-DeJopD-c.js → status.update-Cd4sMxYz.js} +4 -4
- package/dist/store-D8F_4CRR.js +701 -0
- package/dist/{store-BgCLFtxS.js → store-DCoVH3mG.js} +2 -2
- package/dist/{subagent-registry-runtime-COKZwsHd.js → subagent-registry-runtime-Bt-LYyrB.js} +6 -6
- package/dist/subagent-registry-runtime-DVd9wO_D.js +119 -0
- package/dist/{subagent-registry-runtime-BlAI3eqU.js → subagent-registry-runtime-a7xfwPB8.js} +6 -6
- package/dist/{subsystem-Cfn2Pryx.js → subsystem-C6poMade.js} +2 -94
- package/dist/{system-cli-GQBIKMxE.js → system-cli-Zu5LiJFn.js} +25 -21
- package/dist/{system-run-command-ZDr-0-G2.js → system-run-command-Kw0jxir0.js} +1 -1
- package/dist/{systemd-hints-CLH4_-IK.js → systemd-hints-Da4Q7Orc.js} +5 -5
- package/dist/{systemd-linger-PnO8ebUK.js → systemd-linger-NLcFYPEu.js} +2 -2
- package/dist/{systemd-tpTWQ79a.js → systemd-tjVNbfBk.js} +2 -2
- package/dist/{table-D9z5aFl9.js → table-BP6N5EYA.js} +2 -2
- package/dist/{tables-Bb1hkkgV.js → tables-D4LxfXpk.js} +2 -2
- package/dist/{tailnet-B-wq8YXh.js → tailnet-CInGXmk9.js} +1 -1
- package/dist/{tailscale-DOG3cjSj.js → tailscale-DRFhBuh-.js} +1 -1
- package/dist/{target-errors-D41KLMCY.js → target-errors-CkcKdefZ.js} +2 -2
- package/dist/{tokens-g3GBx2U9.js → tokens-C3eENCf9.js} +1 -1
- package/dist/{tool-display-CpQNRadF.js → tool-display-qTfeZx-b.js} +2 -2
- package/dist/{tool-images-Bkv3er-8.js → tool-images-BwtNIRsT.js} +2 -2
- package/dist/{trash-ChZlaria.js → trash-DHZNy01S.js} +2 -2
- package/dist/{tui-BdX0dbMg.js → tui-CW9for1h.js} +18 -18
- package/dist/tui-cli-ChrtbCqc.js +91 -0
- package/dist/types.secrets-CpVqMFti.js +81 -0
- package/dist/{update-BLXj6ysD.js → update-Bb-g7rqr.js} +4 -4
- package/dist/{update-cli-lYpdoDyw.js → update-cli-DHGCFiKY.js} +155 -148
- package/dist/{update-runner-DtN1XGSv.js → update-runner-BDHtvoca.js} +6 -6
- package/dist/web-CCim-JL4.js +123 -0
- package/dist/{web-BEuMJbx-.js → web-CREcqhe9.js} +6 -6
- package/dist/{web-BvId86u4.js → web-IBqHOVI2.js} +6 -6
- package/dist/{webhooks-cli-CvPAdGDn.js → webhooks-cli-C32h-6dI.js} +21 -18
- package/dist/{whatsapp-actions-DSjBUB00.js → whatsapp-actions-BZRxKavO.js} +31 -28
- package/dist/{widearea-dns-Blh7W-0q.js → widearea-dns-9PZLZ6zk.js} +1 -1
- package/dist/{with-timeout-BVwCWUvY.js → with-timeout-DKgjtZv2.js} +6 -43
- package/dist/{workspace-BrC46nbq.js → workspace-CedZZfvJ.js} +5 -5
- package/dist/{workspace-dirs-Cb43onAl.js → workspace-dirs-BgwJ2Axm.js} +1 -1
- package/dist/{ws-ChEZbUss.js → ws-BwH2d97O.js} +2 -2
- package/docs/es/concepts/sessions.md +1 -1
- package/docs/pt-BR/concepts/sessions.md +1 -1
- package/extensions/acpx/package.json +1 -1
- package/extensions/bluebubbles/package.json +1 -1
- package/extensions/ci-fix-loop/package.json +1 -1
- package/extensions/continuous-learning/package.json +1 -1
- package/extensions/copilot-proxy/package.json +1 -1
- package/extensions/diagnostics-otel/package.json +1 -1
- package/extensions/diffs/package.json +1 -1
- package/extensions/discord/package.json +1 -1
- package/extensions/feishu/package.json +1 -1
- package/extensions/flow/package.json +1 -1
- package/extensions/google-antigravity-auth/package.json +1 -1
- package/extensions/google-gemini-cli-auth/package.json +1 -1
- package/extensions/googlechat/node_modules/.bin/openclaw +2 -2
- package/extensions/googlechat/package.json +2 -2
- package/extensions/imessage/package.json +1 -1
- package/extensions/irc/package.json +1 -1
- package/extensions/line/package.json +1 -1
- package/extensions/llm-task/package.json +1 -1
- package/extensions/lobster/package.json +1 -1
- package/extensions/matrix/CHANGELOG.md +5 -0
- package/extensions/matrix/package.json +1 -1
- package/extensions/mattermost/package.json +1 -1
- package/extensions/memory-core/node_modules/.bin/openclaw +2 -2
- package/extensions/memory-core/package.json +2 -2
- package/extensions/memory-lancedb/package.json +1 -1
- package/extensions/minimax-portal-auth/package.json +1 -1
- package/extensions/msteams/CHANGELOG.md +5 -0
- package/extensions/msteams/package.json +1 -1
- package/extensions/nextcloud-talk/package.json +1 -1
- package/extensions/nostr/CHANGELOG.md +5 -0
- package/extensions/nostr/package.json +1 -1
- package/extensions/open-prose/package.json +1 -1
- package/extensions/self-improvement/package.json +1 -1
- package/extensions/signal/package.json +1 -1
- package/extensions/slack/package.json +1 -1
- package/extensions/synology-chat/package.json +1 -1
- package/extensions/telegram/package.json +1 -1
- package/extensions/tlon/package.json +1 -1
- package/extensions/twitch/CHANGELOG.md +5 -0
- package/extensions/twitch/package.json +1 -1
- package/extensions/voice-call/CHANGELOG.md +5 -0
- package/extensions/voice-call/package.json +1 -1
- package/extensions/whatsapp/package.json +1 -1
- package/extensions/zalo/CHANGELOG.md +5 -0
- package/extensions/zalo/package.json +1 -1
- package/extensions/zalouser/CHANGELOG.md +5 -0
- package/extensions/zalouser/package.json +1 -1
- package/package.json +2 -2
- package/dist/audio-preflight-Bk3KZQei.js +0 -98
- package/dist/clawbot-cli-DpO-ZwmI.js +0 -32
- package/dist/cli-1p9b3pE_.js +0 -155
- package/dist/deliver-runtime-CESEQ4NM.js +0 -59
- package/dist/deps-send-discord.runtime-dTfY4NLn.js +0 -34
- package/dist/deps-send-imessage.runtime-Cm_XDGKz.js +0 -33
- package/dist/deps-send-signal.runtime-9WH9ir2Z.js +0 -32
- package/dist/deps-send-slack.runtime-Cx_x379p.js +0 -30
- package/dist/deps-send-telegram.runtime-BFHbiOeI.js +0 -36
- package/dist/deps-send-whatsapp.runtime-BeJLvpI1.js +0 -117
- package/dist/image-runtime-Bq51vNRb.js +0 -53
- package/dist/manager-runtime-D2MqM9iK.js +0 -24
- package/dist/node-commands-DYz_oQFz.js +0 -12
- package/dist/pi-model-discovery-runtime-IFYIuVfT.js +0 -17
- package/dist/register.configure-a0uTvfCu.js +0 -166
- package/dist/runtime-whatsapp-login.runtime-CQLsSWjA.js +0 -20
- package/dist/runtime-whatsapp-outbound.runtime-DoZi3gnM.js +0 -40
- package/dist/slash-commands.runtime-Ckcj6TnD.js +0 -25
- package/dist/slash-dispatch.runtime-B5ykjP8B.js +0 -112
- package/dist/slash-skill-commands.runtime-DbzbD-ZQ.js +0 -31
- package/dist/subagent-registry-runtime-Bjh1H1uK.js +0 -112
- package/dist/tui-cli-C9UujwTv.js +0 -86
- package/dist/web-C14E8nHS.js +0 -116
- /package/dist/{allow-from-Do0aB7F6.js → allow-from-D5r7UcQr.js} +0 -0
- /package/dist/{boolean-DtWR5bt3.js → boolean-ydSOedIP.js} +0 -0
- /package/dist/{brew-sUdeII-D.js → brew-Djs-Lc5s.js} +0 -0
- /package/dist/{chat-envelope-CrWMMV_a.js → chat-envelope-DVKDDTSu.js} +0 -0
- /package/dist/{cli-utils-DK6017OO.js → cli-utils-CCaEbxAz.js} +0 -0
- /package/dist/{command-format-CLEQe4bk.js → command-format-MESnUO9S.js} +0 -0
- /package/dist/{command-options-j8s8APBQ.js → command-options-ZvhOayEd.js} +0 -0
- /package/dist/{command-poll-backoff-Cse56OCv.js → command-poll-backoff-Dal4OaUV.js} +0 -0
- /package/dist/{constants-BgSj-mRP.js → constants-CkIxhEvX.js} +0 -0
- /package/dist/{context-window-guard-BgcfPYTd.js → context-window-guard-BUJ2pfYi.js} +0 -0
- /package/dist/{daemon-runtime-VfkpXuRu.js → daemon-runtime-CbyS9Xgu.js} +0 -0
- /package/dist/{dangerous-name-matching-BAJAZtyB.js → dangerous-name-matching-PRkNIyQj.js} +0 -0
- /package/dist/{dangerous-tools-DjOwyW3J.js → dangerous-tools-B9LIt3MU.js} +0 -0
- /package/dist/{entry-status-DVwZos2N.js → entry-status-4cDL0OcK.js} +0 -0
- /package/dist/{fetch-timeout-BL0dTnkh.js → fetch-timeout-EpWPz-Eu.js} +0 -0
- /package/dist/{format-C-890_pY.js → format-DVLB9DNB.js} +0 -0
- /package/dist/{format-duration-BvkrOKhT.js → format-duration-CrBESKOT.js} +0 -0
- /package/dist/{format-relative-8cNYQsqb.js → format-relative-BsYuWm-Q.js} +0 -0
- /package/dist/{health-format-CqfOHMzL.js → health-format-BIotQmMH.js} +0 -0
- /package/dist/{heartbeat-visibility-_K4bnQDH.js → heartbeat-visibility-C_P1yurK.js} +0 -0
- /package/dist/{help-format-ncfKj8zq.js → help-format-Ce4Xueed.js} +0 -0
- /package/dist/{helpers-5EH85AYF.js → helpers-CpIyUra4.js} +0 -0
- /package/dist/{input-provenance-ByYWugDu.js → input-provenance-qgaZGYuK.js} +0 -0
- /package/dist/{json-files-UKlMS7yU.js → json-files-BH1UBATr.js} +0 -0
- /package/dist/{kill-tree-CeEi7v61.js → kill-tree-W9BwtYuE.js} +0 -0
- /package/dist/{legacy-names-D3aIn6ij.js → legacy-names-DV-6rguu.js} +0 -0
- /package/dist/{load-options-CLMiD1a9.js → load-options-BuY2PXsl.js} +0 -0
- /package/dist/{logging-DRwtiLIS.js → logging-kuFzZMsG.js} +0 -0
- /package/dist/{model-param-b-NJsgH2EF.js → model-param-b-4PN786ZX.js} +0 -0
- /package/dist/{mutable-allowlist-detectors-DiZDtmlZ.js → mutable-allowlist-detectors-TCG6mnbz.js} +0 -0
- /package/dist/{node-resolve-C8bjtxQk.js → node-resolve-DSu0lzHd.js} +0 -0
- /package/dist/{onboard-config-DFLATNN1.js → onboard-config-YMJ1PLAF.js} +0 -0
- /package/dist/{onboard-provider-auth-flags-CpVNpwzI.js → onboard-provider-auth-flags-DHzbi9kj.js} +0 -0
- /package/dist/{openclaw-root-BFfBQ6FD.js → openclaw-root-T5G2ldGE.js} +0 -0
- /package/dist/{parse-log-line-DxFrnzNo.js → parse-log-line-BrrE4onI.js} +0 -0
- /package/dist/{parse-port-CboE2EQm.js → parse-port-DjjWDROB.js} +0 -0
- /package/dist/{parse-timeout-uTDpUWKR.js → parse-timeout-BS3EWcf6.js} +0 -0
- /package/dist/{polls-D86s6oEI.js → polls-QrTzhQf5.js} +0 -0
- /package/dist/{program-context-DQD9Uf8U.js → program-context-BqyLhTGk.js} +0 -0
- /package/dist/{prompt-style-C1jf_-k5.js → prompt-style-DB_OyH4q.js} +0 -0
- /package/dist/{prompts-GoDC3iAV.js → prompts-DomsZukd.js} +0 -0
- /package/dist/{provider-env-vars-D3-Jf8PX.js → provider-env-vars-DYZiYet-.js} +0 -0
- /package/dist/{proxy-BNFyBgvu.js → proxy-CUsDSClP.js} +0 -0
- /package/dist/{redact-BsCSVGmT.js → redact-B1GVGbib.js} +0 -0
- /package/dist/{render-scQFEkLe.js → render-CUAKPmvZ.js} +0 -0
- /package/dist/{run-with-concurrency-CzLnwXXV.js → run-with-concurrency-CLARJMM7.js} +0 -0
- /package/dist/{runtime-status-CL_bKfj_.js → runtime-status-Fmu5gNYW.js} +0 -0
- /package/dist/{secret-equal-DxKrAcRs.js → secret-equal-BN0idTaZ.js} +0 -0
- /package/dist/{secure-random-CruxVpoI.js → secure-random-B2UrD2xa.js} +0 -0
- /package/dist/{session-key-k6urs9r-.js → session-key-CC77ya0a.js} +0 -0
- /package/dist/{stagger-DW-U0kcV.js → stagger-Cek4Eizw.js} +0 -0
- /package/dist/{targets-CwCifSLG.js → targets-CD5AQXRB.js} +0 -0
- /package/dist/{targets-xSi-e-_L.js → targets-DPUt073v.js} +0 -0
- /package/dist/{text-format-CFm4X8Ze.js → text-format-DarxU3JH.js} +0 -0
- /package/dist/{thinking-RV_E8HFV.js → thinking-C0gzzPsv.js} +0 -0
- /package/dist/{timeouts-G9Yto-nj.js → timeouts-DEnpCqGd.js} +0 -0
- /package/dist/{tool-catalog-omkiks3D.js → tool-catalog-3w4XiWhy.js} +0 -0
- /package/dist/{transcript-events-CtWhopMu.js → transcript-events-CdWLIofg.js} +0 -0
- /package/dist/{usage-format-BMWvYDjj.js → usage-format-zuuFSdkg.js} +0 -0
- /package/dist/{utils-cwpAMi-t.js → utils-BnC3HGtm.js} +0 -0
- /package/dist/{version-DdJhsIqk.js → version-DT-JIO28.js} +0 -0
- /package/dist/{windows-spawn-CsdZOQMr.js → windows-spawn-CVnPunjY.js} +0 -0
- /package/dist/{wsl-Cx5T6MYb.js → wsl-DLw4LET-.js} +0 -0
|
@@ -1,169 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
+
import { a as logVerbose, g as getResolvedLoggerSettings, h as getLogger, m as getChildLogger } from "./globals-d3aR1MYC.js";
|
|
3
|
+
import { g as resolveStateDir, i as isNixMode, r as STATE_DIR, t as CONFIG_PATH } from "./paths-BMo6kTge.js";
|
|
4
|
+
import { n as defaultRuntime } from "./runtime-CvdZtNmJ.js";
|
|
5
|
+
import { n as runtimeForLogger, t as createSubsystemLogger } from "./subsystem-C6poMade.js";
|
|
5
6
|
import { i as logAcceptedEnvOption, r as isTruthyEnvValue } from "./entry.js";
|
|
6
|
-
import {
|
|
7
|
-
import { t as formatCliCommand } from "./command-format-
|
|
8
|
-
import {
|
|
9
|
-
import { C as isCronRunSessionKey, E as parseAgentSessionKey, T as isSubagentSessionKey, _ as normalizeAccountId$1, c as normalizeAgentId, g as DEFAULT_ACCOUNT_ID, h as toAgentStoreSessionKey, l as normalizeMainKey, m as toAgentRequestSessionKey, o as classifySessionKeyShape, r as buildAgentMainSessionKey, t as DEFAULT_AGENT_ID, u as resolveAgentIdFromSessionKey } from "./session-key-
|
|
10
|
-
import { E as isPlainObject, S as sleep, T as truncateUtf16Safe, n as clamp, s as ensureDir, v as resolveUserPath
|
|
11
|
-
import { a as openBoundaryFileSync, f as isNotFoundPathError, g as matchesSkillFilter, i as openBoundaryFile, o as openVerifiedFileSync, s as sameFileIdentity, t as resolveOpenClawPackageRoot } from "./openclaw-root-
|
|
12
|
-
import { i as logWarn, t as logDebug } from "./logger-
|
|
13
|
-
import { n as runExec, t as runCommandWithTimeout } from "./exec-
|
|
14
|
-
import {
|
|
15
|
-
import "./
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import "./
|
|
19
|
-
import { i as
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import "./
|
|
24
|
-
import "./
|
|
25
|
-
import "./
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import "./
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import "./
|
|
33
|
-
import {
|
|
34
|
-
import "./
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import "./
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import { n as
|
|
47
|
-
import "./
|
|
48
|
-
import {
|
|
49
|
-
import { o as
|
|
50
|
-
import { i as
|
|
51
|
-
import {
|
|
52
|
-
import "./
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import "./
|
|
56
|
-
import { n as
|
|
57
|
-
import {
|
|
58
|
-
import "./
|
|
59
|
-
import { c as
|
|
60
|
-
import {
|
|
61
|
-
import "./
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import "./
|
|
65
|
-
import "./
|
|
66
|
-
import "./
|
|
67
|
-
import {
|
|
68
|
-
import "./
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import "./
|
|
73
|
-
import "./
|
|
74
|
-
import "./
|
|
75
|
-
import "./
|
|
76
|
-
import "./
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import "./
|
|
80
|
-
import {
|
|
81
|
-
import "./
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
84
|
-
import "./
|
|
85
|
-
import "./
|
|
86
|
-
import {
|
|
87
|
-
import {
|
|
88
|
-
import {
|
|
89
|
-
import { n as
|
|
90
|
-
import {
|
|
91
|
-
import { n as
|
|
92
|
-
import {
|
|
93
|
-
import {
|
|
94
|
-
import { t as
|
|
95
|
-
import { t as
|
|
96
|
-
import { n as
|
|
97
|
-
import "./
|
|
98
|
-
import "./
|
|
99
|
-
import {
|
|
100
|
-
import {
|
|
101
|
-
import {
|
|
102
|
-
import "./
|
|
103
|
-
import "./
|
|
104
|
-
import "./delivery-queue-DgdE_Ifa.js";
|
|
105
|
-
import "./send-7T5wUQDt.js";
|
|
106
|
-
import "./proxy-BNFyBgvu.js";
|
|
107
|
-
import "./timeouts-G9Yto-nj.js";
|
|
108
|
-
import { n as GATEWAY_AUTH_SURFACE_PATHS, p as isKnownSecretTargetId, r as evaluateGatewayAuthSurfaceStates } from "./runtime-config-collectors-CCkqshyY.js";
|
|
109
|
-
import "./command-secret-targets-B2OuvZQf.js";
|
|
110
|
-
import { C as normalizeControlUiBasePath, S as buildControlUiAvatarUrl, c as handleReset, w as resolveAssistantAvatarUrl, x as CONTROL_UI_AVATAR_PREFIX } from "./onboard-helpers-Dtu3-e93.js";
|
|
111
|
-
import "./prompt-style-C1jf_-k5.js";
|
|
112
|
-
import "./pairing-labels-CjKrz2C9.js";
|
|
113
|
-
import { i as resolveMemoryBackendConfig, r as getMemorySearchManager } from "./memory-cli-C6ocXZHW.js";
|
|
114
|
-
import { i as resolveMemorySearchConfig } from "./manager-BYSXh-I3.js";
|
|
115
|
-
import { t as formatDocsLink } from "./links-C7eMwu1P.js";
|
|
116
|
-
import { n as runCommandWithRuntime } from "./cli-utils-DK6017OO.js";
|
|
117
|
-
import { t as formatHelpExamples } from "./help-format-ncfKj8zq.js";
|
|
118
|
-
import { n as withProgress } from "./progress-DLHMb9Nz.js";
|
|
119
|
-
import { t as buildWorkspaceSkillStatus } from "./skills-status-CeHRbTXe.js";
|
|
120
|
-
import { i as onHeartbeatEvent, r as getLastHeartbeatEvent, t as resolveHeartbeatVisibility } from "./heartbeat-visibility-_K4bnQDH.js";
|
|
121
|
-
import { t as ensureOpenClawCliOnPath } from "./path-env-LTMy-Xkk.js";
|
|
122
|
-
import { n as DEFAULT_GATEWAY_HTTP_TOOL_DENY } from "./dangerous-tools-DjOwyW3J.js";
|
|
123
|
-
import { n as inheritOptionFromParent } from "./command-options-j8s8APBQ.js";
|
|
124
|
-
import { t as WizardCancelledError } from "./prompts-GoDC3iAV.js";
|
|
125
|
-
import { t as resolveChannelDefaultAccountId } from "./helpers-CIEbwEWl.js";
|
|
126
|
-
import { a as pruneAgentConfig, i as loadAgentIdentity, r as findAgentEntryIndex, t as applyAgentConfig } from "./agents.config-BQ8I8wuY.js";
|
|
127
|
-
import { t as isWithinDir } from "./path-safety-DwIbN_B2.js";
|
|
128
|
-
import "./install-safe-path-Df97RWiJ.js";
|
|
129
|
-
import "./skill-scanner-B5APVdka.js";
|
|
130
|
-
import { n as formatConfigIssueLines } from "./issue-format-DjqrcimU.js";
|
|
131
|
-
import { t as buildChannelAccountSnapshot } from "./status-pXeXDUup.js";
|
|
132
|
-
import "./channels-status-issues-BAy-21Cb.js";
|
|
133
|
-
import { a as buildBaseHints, i as applySensitiveHints, n as redactConfigSnapshot, o as mapSensitivePaths, r as restoreRedactedValues, s as applyDerivedTags, t as redactConfigObject } from "./redact-snapshot-COg8NLLO.js";
|
|
134
|
-
import "./daemon-install-helpers-C1QLEGFF.js";
|
|
135
|
-
import "./runtime-guard-BMUPc-7K.js";
|
|
136
|
-
import "./gateway-install-token-tifgQqTq.js";
|
|
137
|
-
import "./systemd-tpTWQ79a.js";
|
|
138
|
-
import "./service-BJxGQl0h.js";
|
|
139
|
-
import "./lifecycle-core-BXWGDU3R.js";
|
|
140
|
-
import "./systemd-hints-CLH4_-IK.js";
|
|
141
|
-
import { t as parsePort$1 } from "./parse-port-CboE2EQm.js";
|
|
142
|
-
import { n as addGatewayServiceCommands } from "./daemon-cli-OBRBnIhu.js";
|
|
143
|
-
import { t as probeGateway } from "./probe-D23qt8BT.js";
|
|
144
|
-
import "./diagnostics-vhe8iPOe.js";
|
|
145
|
-
import "./table-D9z5aFl9.js";
|
|
146
|
-
import { n as resolveWideAreaDiscoveryDomain, r as writeWideAreaGatewayZone } from "./widearea-dns-Blh7W-0q.js";
|
|
147
|
-
import { i as toOptionString, n as extractGatewayMiskeys, r as maybeExplainGatewayServiceStop, t as describeUnknownError } from "./shared-DcKZdze7.js";
|
|
148
|
-
import { t as discoverGatewayBeacons } from "./bonjour-discovery-CzNIGZ7K.js";
|
|
149
|
-
import { t as resolveConfiguredSecretInputString } from "./resolve-configured-secret-input-string-ySbc3h26.js";
|
|
150
|
-
import { i as pickGatewaySelfPresence, r as getStatusSummary } from "./status-D3cIxG_a.js";
|
|
151
|
-
import { a as styleHealthChannelLine, c as setHeartbeatsEnabled, l as startHeartbeatRunner, n as getHealthSnapshot, s as runHeartbeatOnce, t as formatHealthChannelLines, u as isCronSystemEvent } from "./health-DTtmaQPz.js";
|
|
152
|
-
import { a as resolveControlUiRootSync, i as resolveControlUiRootOverrideSync, t as ensureControlUiAssetsBuilt } from "./control-ui-assets-CvLJNwEr.js";
|
|
153
|
-
import { h as normalizeUpdateChannel, l as DEFAULT_PACKAGE_CHANNEL, n as checkUpdateStatus, o as resolveNpmChannelTag, r as compareSemverStrings } from "./channel-account-context-DyLW8OD1.js";
|
|
154
|
-
import { a as resolveCommandSecretsFromActiveRuntimeSnapshot, i as prepareSecretsRuntimeSnapshot, n as clearSecretsRuntimeSnapshot, r as getActiveSecretsRuntimeSnapshot, t as activateSecretsRuntimeSnapshot } from "./runtime-BkR9qMZk.js";
|
|
155
|
-
import "./onboarding.secret-input-BO32ZliB.js";
|
|
156
|
-
import { t as runOnboardingWizard } from "./onboarding-DozRyXTe.js";
|
|
157
|
-
import { a as sendApnsAlert, c as parseMessageWithAttachments, d as shouldLogWs, f as summarizeAgentEventForWsLog, i as resolveApnsAuthConfigFromEnv, l as formatForLog, n as normalizeApnsEnvironment, o as sendApnsBackgroundWake, p as setGatewayWsLogStyle, s as normalizeRpcAttachmentsToChatAttachments, t as loadApnsRegistration, u as logWs } from "./push-apns-BNjpWCK5.js";
|
|
158
|
-
import { T as resolveGmailHookRuntimeConfig, _ as buildGogWatchServeArgs, i as ensureTailscaleEndpoint, v as buildGogWatchStartArgs } from "./gmail-setup-utils-B1wEc-nz.js";
|
|
159
|
-
import { n as isNodeCommandAllowed, r as resolveNodeCommandAllowlist } from "./node-command-policy-C9mK2tft.js";
|
|
160
|
-
import { n as collectEnabledInsecureOrDangerousFlags } from "./audit-DCJbont3.js";
|
|
161
|
-
import "./node-service-DB36GYv5.js";
|
|
162
|
-
import "./status.update-DeJopD-c.js";
|
|
163
|
-
import { t as installSkill } from "./skills-install-jLz2vwvm.js";
|
|
164
|
-
import { t as runGatewayUpdate } from "./update-runner-DtN1XGSv.js";
|
|
165
|
-
import { i as shouldIncludeHook, r as resolveHookConfig, t as loadWorkspaceHookEntries } from "./workspace-BrC46nbq.js";
|
|
166
|
-
import { n as forceFreePortAndWait, r as waitForPortBindable } from "./ports-BZsa4E0e.js";
|
|
7
|
+
import { An as resolveSubagentMaxConcurrent, B as parseConfigJson5, Bn as buildAllowedModelSet, Dn as buildTalkConfigResponse, G as writeConfigFile, H as readConfigFileSnapshotForWrite, I as migrateLegacyConfig, K as validateConfigObjectWithPlugins, Kn as isCliProvider, Qn as resolveAllowedModelRef, St as looksLikeAvatarPath, U as resolveConfigSnapshotHash, V as readConfigFileSnapshot, Wn as getModelRefStatus, Yn as normalizeModelSelection, _t as isAvatarHttpUrl, ai as normalizeSecretInput, ar as resolveSubagentConfiguredModelSelection, di as DEFAULT_PROVIDER, er as resolveConfiguredModelRef, fn as applyMergePatch, ht as AVATAR_MAX_BYTES, kn as resolveAgentMaxConcurrent, li as DEFAULT_CONTEXT_TOKENS, mn as ensureControlUiAllowedOriginsForNonLoopbackBind, mt as parseByteSize, nr as resolveHooksGmailModel, pn as applyLegacyMigrations, pt as parseDurationMs, q as BotSchema, sr as resolveThinkingDefault, tr as resolveDefaultModelForAgent, ui as DEFAULT_MODEL, vt as isAvatarImageDataUrl, z as loadConfig } from "./auth-profiles-BtxyXCZY.js";
|
|
8
|
+
import { t as formatCliCommand } from "./command-format-MESnUO9S.js";
|
|
9
|
+
import { C as DEFAULT_SOUL_FILENAME, E as ensureAgentWorkspace, O as isWorkspaceOnboardingCompleted, S as DEFAULT_MEMORY_FILENAME, T as DEFAULT_USER_FILENAME, a as resolveAgentDir, b as DEFAULT_IDENTITY_FILENAME, c as resolveAgentModelFallbacksOverride, d as resolveDefaultAgentId, g as DEFAULT_AGENTS_FILENAME, i as resolveAgentConfig, l as resolveAgentSkillsFilter, m as resolveSessionAgentId, n as listAgentEntries, r as listAgentIds, u as resolveAgentWorkspaceDir, v as DEFAULT_BOOTSTRAP_FILENAME, w as DEFAULT_TOOLS_FILENAME, x as DEFAULT_MEMORY_ALT_FILENAME, y as DEFAULT_HEARTBEAT_FILENAME } from "./agent-scope-BcruZHHR.js";
|
|
10
|
+
import { C as isCronRunSessionKey, E as parseAgentSessionKey, T as isSubagentSessionKey, _ as normalizeAccountId$1, c as normalizeAgentId, g as DEFAULT_ACCOUNT_ID, h as toAgentStoreSessionKey, l as normalizeMainKey, m as toAgentRequestSessionKey, o as classifySessionKeyShape, r as buildAgentMainSessionKey, t as DEFAULT_AGENT_ID, u as resolveAgentIdFromSessionKey } from "./session-key-CC77ya0a.js";
|
|
11
|
+
import { E as isPlainObject, S as sleep, T as truncateUtf16Safe, n as clamp, s as ensureDir, v as resolveUserPath } from "./utils-BnC3HGtm.js";
|
|
12
|
+
import { a as openBoundaryFileSync, f as isNotFoundPathError, g as matchesSkillFilter, i as openBoundaryFile, o as openVerifiedFileSync, s as sameFileIdentity, t as resolveOpenClawPackageRoot } from "./openclaw-root-T5G2ldGE.js";
|
|
13
|
+
import { i as logWarn, t as logDebug } from "./logger-DyQjakwH.js";
|
|
14
|
+
import { n as runExec, t as runCommandWithTimeout } from "./exec-B8Hv4Nkd.js";
|
|
15
|
+
import { u as isTestDefaultMemorySlotDisabled } from "./manifest-registry-m_hXBIk-.js";
|
|
16
|
+
import { n as resolveRuntimeServiceVersion, t as VERSION } from "./version-DT-JIO28.js";
|
|
17
|
+
import { D as triggerInternalHook, E as registerInternalHook, T as createInternalHookEvent, d as getActivePluginRegistry, g as createEmptyPluginRegistry, t as CHANNEL_IDS, w as clearInternalHooks } from "./registry-DnJ84ILp.js";
|
|
18
|
+
import { i as isSilentReplyText, n as SILENT_REPLY_TOKEN } from "./tokens-C3eENCf9.js";
|
|
19
|
+
import { $ as getCliSessionId, $n as resolveAnnounceTargetFromKey, $t as normalizeGroupActivation, A as resolveAgentAvatar, An as normalizeMimeList, Ar as resolveTtsApiKey, At as normalizeRequiredName, Bt as isExternalHookSession, C as resolveAgentDeliveryPlan, Ct as normalizeCronJobCreate, D as createOutboundSendDeps$1, Dn as DEFAULT_INPUT_TIMEOUT_MS, Dr as getTtsProvider, Dt as normalizeOptionalSessionKey, E as createDefaultDeps, En as DEFAULT_INPUT_MAX_REDIRECTS, Er as clearBootstrapSnapshot, Et as normalizeOptionalAgentId, Fr as setTtsEnabled, Gr as stripHeartbeatToken, Ht as applyBrowserProxyPaths, I as buildHistoryContextFromEntries, Ir as setTtsProvider, J as createReplyDispatcher, Kn as listDescendantRunsForRequester, Ln as isAbortRequestText, Lr as textToSpeech, Lt as buildSafeExternalPrompt, Mr as resolveTtsConfig, Mt as buildDeliveryFromLegacyPayload, Nn as normalizeSendPolicy, Nr as resolveTtsPrefsPath, Nt as hasLegacyDeliveryHints, On as extractFileContentFromSource, Or as isTtsEnabled, Ot as normalizeOptionalText, P as createReplyPrefixOptions, Pn as resolveSendPolicy, Pr as resolveTtsProviderOrder, Pt as stripLegacyDeliveryFields, Q as buildBareSessionResetPrompt, Qn as runSubagentAnnounceFlow, Qt as unbindThreadBindingsBySessionKey, Rn as stopSubagentsForRequester, Rr as OPENAI_TTS_MODELS, Rt as detectSuspiciousPatterns, St as normalizeHttpWebhookUrl, T as createOutboundSendDeps, Tn as DEFAULT_INPUT_IMAGE_MIMES, Tt as inferLegacyName, Ut as persistBrowserProxyFiles, Vn as countActiveDescendantRuns, Vr as DEFAULT_HEARTBEAT_ACK_MAX_CHARS, Vt as closeTrackedBrowserTabsForSessions, Wn as initSubagentRegistry, Wt as resolveSessionAuthProfileOverride, Xt as applyVerboseOverride, Y as getTotalPendingReplies, Yt as applyModelOverrideToSessionEntry, Zn as resolveAgentTimeoutMs, Zt as parseVerboseOverride, _ as requestBodyErrorToText, _t as formatRestartSentinelMessage, a as getPluginToolMeta, an as formatZonedTimestamp, ar as getActiveEmbeddedRunCount, at as resolveOutboundSessionRoute, br as resolveAgentIdentity, c as loadBotPlugins, cr as resolveCronStyleNow, ct as resolveOutboundTarget, dr as getAgentRunContext, er as readLatestAssistantReply, et as setCliSessionId, fn as enqueueSystemEvent, fr as onAgentEvent, ft as resetDirectoryCache, g as readJsonBodyWithLimit, gn as requestHeartbeatNow, gr as resolveBootstrapWarningSignaturesSeen, gt as formatDoctorNonInteractiveHint, h as handleSlackHttpRequest, ht as consumeRestartSentinel, ir as abortEmbeddedPiRun, it as ensureOutboundSessionEntry, jn as resolveInputFileLimits, jr as resolveTtsAutoMode, jt as migrateLegacyCronPayload, kn as extractImageContentFromSource, kr as isTtsProviderConfigured, kt as normalizePayloadToSystemText, l as createPluginRuntime, lr as clearAgentRunContext, lt as resolveSessionDeliveryTarget, mt as runWithModelFallback, n as applyToolPolicyPipeline, nr as buildOutboundSessionContext, nt as createBotTools, o as resolvePluginTools, or as waitForEmbeddedPiRunEnd, p as resolveAgentOutboundIdentity, pn as isSystemEventContextChanged, pr as registerAgentRunContext, q as dispatchInboundMessage, r as buildDefaultToolPolicyPipelineSteps, rr as runEmbeddedPiAgent, tn as loadProviderUsageSummary, tr as clearSessionQueues, tt as runCliAgent, ur as emitAgentEvent, ut as resolveOutboundChannelPlugin, vr as getAcpSessionManager, w as resolveAgentOutboundTarget, wn as DEFAULT_INPUT_IMAGE_MAX_BYTES, wr as resolveUserTimezone, wt as normalizeCronJobPatch, x as agentCommandFromIngress, xn as ACP_SESSION_IDENTITY_RENDERER_VERSION, xt as writeRestartSentinel, yr as resolveAgentSessionDirs, yt as summarizeRestartSentinel, zr as OPENAI_TTS_VOICES, zt as getHookType } from "./compact-CuLMew-8.js";
|
|
20
|
+
import { i as resolveWhatsAppAccount } from "./accounts-C04lw_uh.js";
|
|
21
|
+
import { n as listChannelPlugins, o as normalizeWhatsAppTarget, r as normalizeChannelId, t as getChannelPlugin, v as buildChannelAccountBindings } from "./plugins-CCkC0dRo.js";
|
|
22
|
+
import { t as getMachineDisplayName } from "./machine-name-BWZ0tBHk.js";
|
|
23
|
+
import { j as runGlobalGatewayStopSafely, k as getGlobalHookRunner, o as normalizeReplyPayloadsForDelivery, t as deliverOutboundPayloads } from "./deliver-Bge0HwrF.js";
|
|
24
|
+
import { d as startDiagnosticHeartbeat, f as stopDiagnosticHeartbeat, h as isDiagnosticsEnabled } from "./diagnostic-CXxZq_XY.js";
|
|
25
|
+
import { _ as setCommandLaneConcurrency, c as setPreRestartDeferralCheck, m as getTotalQueueSize, n as deferGatewayRestartUntilIdle, o as scheduleGatewaySigusr1Restart, r as emitGatewayRestart, s as setGatewaySigusr1RestartPolicy, y as CommandLane } from "./restart-D97MOP8K.js";
|
|
26
|
+
import { c as detectMime } from "./image-ops-Bnk-bI_x.js";
|
|
27
|
+
import { b as resolveCronStorePath, x as saveCronStore, y as loadCronStore } from "./send-CZtdjq0Y.js";
|
|
28
|
+
import { _ as hasGatewayClientCap, h as GATEWAY_CLIENT_MODES, i as isGatewayMessageChannel, m as GATEWAY_CLIENT_IDS, n as isDeliverableMessageChannel, p as GATEWAY_CLIENT_CAPS, r as isGatewayCliClient, s as isWebchatClient, t as INTERNAL_MESSAGE_CHANNEL, u as normalizeMessageChannel, v as normalizeGatewayClientMode } from "./message-channel-DOpIvru6.js";
|
|
29
|
+
import { C as resolveToolProfilePolicy, _ as collectExplicitAllowlist, y as mergeAlsoAllowPolicy } from "./sandbox-DKscghPx.js";
|
|
30
|
+
import { i as listCoreToolSections, n as PROFILE_OPTIONS, o as resolveCoreToolProfiles } from "./tool-catalog-3w4XiWhy.js";
|
|
31
|
+
import { i as enableTailscaleServe, n as disableTailscaleServe, o as getTailnetHostname, r as enableTailscaleFunnel, t as disableTailscaleFunnel } from "./tailscale-DRFhBuh-.js";
|
|
32
|
+
import { t as safeEqualSecret } from "./secret-equal-BN0idTaZ.js";
|
|
33
|
+
import { n as pickPrimaryTailnetIPv4, r as pickPrimaryTailnetIPv6 } from "./tailnet-CInGXmk9.js";
|
|
34
|
+
import { c as normalizeHostHeader, d as resolveGatewayBindHost, f as resolveGatewayListenHosts, i as isLoopbackHost, l as pickPrimaryLanIPv4, n as isLocalishHost, o as isTrustedProxyAddress, r as isLoopbackAddress, s as isValidIPv4, t as rawDataToString, u as resolveClientIp } from "./ws-BwH2d97O.js";
|
|
35
|
+
import { a as resolveGatewayAuth, c as AUTH_RATE_LIMIT_SCOPE_SHARED_SECRET, i as isLocalDirectRequest, l as createAuthRateLimiter, n as authorizeHttpGatewayConnect, o as AUTH_RATE_LIMIT_SCOPE_DEVICE_TOKEN, r as authorizeWsControlUiGatewayConnect, s as AUTH_RATE_LIMIT_SCOPE_HOOK_AUTH, t as assertGatewayAuthConfigured, u as normalizeRateLimitClientIp } from "./auth-CWHo884l.js";
|
|
36
|
+
import { d as mergeGatewayTailscaleConfig, l as ensureGatewayStartupAuth, u as mergeGatewayAuthConfig } from "./server-context-CcW_Z5sB.js";
|
|
37
|
+
import { d as hasBinary } from "./frontmatter-B0viix_h.js";
|
|
38
|
+
import { i as loadWorkspaceSkillEntries, r as buildWorkspaceSkillSnapshot } from "./skills-Cp-zTGor.js";
|
|
39
|
+
import { n as assertNoPathAliasEscape } from "./path-alias-guards-Bz8AnRb7.js";
|
|
40
|
+
import { a as testRegexWithBoundedInput, i as compileSafeRegex } from "./redact-B1GVGbib.js";
|
|
41
|
+
import { r as formatErrorMessage } from "./errors-ClLWB67m.js";
|
|
42
|
+
import { i as openFileWithinRoot, l as writeFileWithinRoot, s as readLocalFileSafely, t as SafeOpenError } from "./fs-safe-CFIinCN2.js";
|
|
43
|
+
import { n as SsrFBlockedError } from "./proxy-env-a_fwG5uV.js";
|
|
44
|
+
import { t as movePathToTrash } from "./trash-DHZNy01S.js";
|
|
45
|
+
import { n as readJsonFile, r as writeJsonAtomic, t as createAsyncLock } from "./json-files-BH1UBATr.js";
|
|
46
|
+
import { $ as resolveMainSessionKeyFromConfig, A as readSessionPreviewItemsFromTranscript, B as evaluateSessionFreshness, C as normalizeSessionDeliveryFields, D as capArrayByJsonBytes, E as archiveSessionTranscripts, H as resolveSessionResetPolicy, I as stripInlineDirectiveTagsForDisplay, J as setSessionRuntimeModel, K as mergeSessionEntry, L as stripInlineDirectiveTagsFromMessageForDisplay, M as resolveSessionTranscriptCandidates, N as stripEnvelopeFromMessage, O as cleanupArchivedSessionTranscripts, P as stripEnvelopeFromMessages, Q as resolveMainSessionKey, R as jsonUtf8Bytes, T as archiveFileOnDisk, X as resolveAgentMainSessionKey, Y as canonicalizeMainSessionAlias, Z as resolveExplicitAgentSessionKey, ct as cleanStaleLockFiles, d as updateSessionStore, k as readSessionMessages, n as parseSessionThreadInfo, o as loadSessionStore, t as extractDeliveryInfo, tt as snapshotSessionOrigin, x as mergeDeliveryContext, y as deliveryContextFromSession } from "./sessions-BkKVGWHa.js";
|
|
47
|
+
import { c as resolveStorePath, i as resolveSessionTranscriptPath, n as resolveSessionFilePath, r as resolveSessionFilePathOptions, s as resolveSessionTranscriptsDirForAgent } from "./paths-gTdorMgW.js";
|
|
48
|
+
import { i as normalizeInputProvenance } from "./input-provenance-qgaZGYuK.js";
|
|
49
|
+
import { o as estimateBase64DecodedBytes } from "./tool-images-BwtNIRsT.js";
|
|
50
|
+
import { a as normalizeElevatedLevel, c as normalizeUsageDisplay, d as supportsXHighThinking, l as normalizeVerboseLevel, n as formatXHighModelHint, o as normalizeReasoningLevel, s as normalizeThinkLevel, t as formatThinkingLevels } from "./thinking-C0gzzPsv.js";
|
|
51
|
+
import { i as resetModelCatalogCacheForTest, n as loadModelCatalog } from "./model-catalog-DtjVcDuN.js";
|
|
52
|
+
import { g as registerUnhandledRejectionHandler } from "./audio-transcription-runner-bvBQs8UB.js";
|
|
53
|
+
import { t as fetchWithSsrFGuard } from "./fetch-guard-hL-C2yQz.js";
|
|
54
|
+
import { b as extractTextFromChatContent } from "./image-m1GU1uco.js";
|
|
55
|
+
import { a as ToolInputError } from "./target-errors-CkcKdefZ.js";
|
|
56
|
+
import { r as isRestartEnabled } from "./commands-BoGUirwW.js";
|
|
57
|
+
import { c as hasNonzeroUsage, i as loadSessionUsageTimeSeries, n as loadCostUsageSummary, r as loadSessionCostSummary, s as deriveSessionTotalTokens, t as discoverAllSessions } from "./session-cost-usage-CBHvFXhD.js";
|
|
58
|
+
import { i as normalizeDevicePublicKeyBase64Url, s as verifyDeviceSignature, t as deriveDeviceIdFromPublicKey } from "./device-identity-DtdLP7QQ.js";
|
|
59
|
+
import { $ as validateNodeListParams, $t as summarizeDeviceTokens, A as validateCronRemoveParams, At as validateWebLoginWaitParams, B as validateDeviceTokenRotateParams, Bt as buildDeviceAuthPayload, C as validateConfigSchemaLookupParams, Ct as validateSkillsUpdateParams, D as validateConnectParams, Dt as validateUpdateRunParams, E as validateConfigSetParams, Et as validateToolsCatalogParams, F as validateDevicePairApproveParams, Ft as PROTOCOL_VERSION, G as validateExecApprovalsNodeSetParams, Gt as ensureDeviceToken, H as validateExecApprovalResolveParams, Ht as normalizeDeviceMetadataForAuth, I as validateDevicePairListParams, It as ErrorCodes, J as validateModelsListParams, Jt as rejectDevicePairing, K as validateExecApprovalsSetParams, Kt as getPairedDevice, L as validateDevicePairRejectParams, Lt as errorShape, M as validateCronRunsParams, Mt as validateWizardNextParams, N as validateCronStatusParams, Nt as validateWizardStartParams, O as validateCronAddParams, Ot as validateWakeParams, P as validateCronUpdateParams, Pt as validateWizardStatusParams, Q as validateNodeInvokeResultParams, Qt as rotateDeviceToken, R as validateDevicePairRemoveParams, S as validateConfigPatchParams, St as validateSkillsStatusParams, T as validateConfigSchemaParams, Tt as validateTalkModeParams, U as validateExecApprovalsGetParams, V as validateExecApprovalRequestParams, Vt as buildDeviceAuthPayloadV3, W as validateExecApprovalsNodeGetParams, Wt as approveDevicePairing, X as validateNodeEventParams, Xt as requestDevicePairing, Y as validateNodeDescribeParams, Yt as removePairedDevice, Z as validateNodeInvokeParams, Zt as revokeDeviceToken, _ as validateChatHistoryParams, _t as validateSessionsResetParams, a as validateAgentParams, at as validateNodeRenameParams, b as validateConfigApplyParams, bt as validateSkillsBinsParams, c as validateAgentsDeleteParams, ct as validateRequestFrame, d as validateAgentsFilesSetParams, dt as validateSendParams, en as updatePairedDeviceMetadata, et as validateNodePairApproveParams, f as validateAgentsListParams, ft as validateSessionsCompactParams, g as validateChatAbortParams, gt as validateSessionsPreviewParams, h as validateChannelsStatusParams, ht as validateSessionsPatchParams, i as validateAgentIdentityParams, it as validateNodePairVerifyParams, j as validateCronRunParams, jt as validateWizardCancelParams, k as validateCronListParams, kt as validateWebLoginStartParams, l as validateAgentsFilesGetParams, lt as validateSecretsResolveParams, m as validateChannelsLogoutParams, mt as validateSessionsListParams, nn as roleScopesAllow, nt as validateNodePairRejectParams, o as validateAgentWaitParams, ot as validatePollParams, p as validateAgentsUpdateParams, pt as validateSessionsDeleteParams, q as validateLogsTailParams, qt as listDevicePairing, r as formatValidationErrors, rt as validateNodePairRequestParams, s as validateAgentsCreateParams, st as validatePushTestParams, tn as verifyDeviceToken, tt as validateNodePairListParams, u as validateAgentsFilesListParams, ut as validateSecretsResolveResult, v as validateChatInjectParams, vt as validateSessionsResolveParams, w as validateConfigSchemaLookupResult, wt as validateTalkConfigParams, x as validateConfigGetParams, xt as validateSkillsInstallParams, y as validateChatSendParams, yt as validateSessionsUsageParams, z as validateDeviceTokenRevokeParams, zt as parseSessionLabel } from "./client-Bvvecv3V.js";
|
|
60
|
+
import { c as ADMIN_SCOPE$3, d as isNodeRoleMethod, p as loadGatewayTlsRuntime$1, u as authorizeOperatorScopesForMethod } from "./call-DL23sPxF.js";
|
|
61
|
+
import { a as readChannelAllowFromStoreSync } from "./pairing-store-CXFEv3Gr.js";
|
|
62
|
+
import { a as mergeExecApprovalsSocketDefaults, c as readExecApprovalsSnapshot, p as saveExecApprovals, r as ensureExecApprovals, s as normalizeExecApprovals, t as DEFAULT_EXEC_APPROVAL_TIMEOUT_MS } from "./exec-approvals-Bh1osORd.js";
|
|
63
|
+
import { _ as matchSystemRunApprovalBinding, g as buildSystemRunApprovalBinding, h as resolveSystemRunApprovalRuntimeContext, m as resolveSystemRunApprovalRequestContext, v as missingSystemRunApprovalBinding, y as toSystemRunApprovalMismatchError } from "./nodes-screen-X8daVm8e.js";
|
|
64
|
+
import { n as resolveSystemRunCommand } from "./system-run-command-Kw0jxir0.js";
|
|
65
|
+
import { a as loadCombinedSessionStoreForGateway, c as resolveGatewaySessionStoreTarget, f as computeBackoff, i as listSessionsFromStore, l as resolveSessionModelRef, o as loadSessionEntry, p as sleepWithAbort, r as listAgentsForGateway, s as pruneLegacyStoreKeys, t as canonicalizeSpawnedByForAgent, u as lookupContextTokens } from "./session-utils-t4ZmEDMj.js";
|
|
66
|
+
import { _ as updatePairedNodeMetadata, a as getRemoteSkillEligibility, b as getSkillsSnapshotVersion, c as refreshRemoteBinsForConnectedNodes, d as setSkillsRemoteRegistry, f as approveNodePairing, g as requestNodePairing, h as renamePairedNode, l as refreshRemoteNodeBins, m as rejectNodePairing, o as primeRemoteSkillsCache, p as listNodePairing, s as recordRemoteNodeInfo, u as removeRemoteNodeInfo, v as verifyNodeToken, x as registerSkillsChangeListener } from "./skill-commands-Dyi0nIIE.js";
|
|
67
|
+
import { a as resolveSubagentToolPolicy, i as resolveGroupToolPolicy, r as resolveEffectiveToolPolicy } from "./pi-tools.policy-U1G3dAzL.js";
|
|
68
|
+
import { t as listAgentWorkspaceDirs } from "./workspace-dirs-BgwJ2Axm.js";
|
|
69
|
+
import { t as getChannelActivity } from "./channel-activity-DItBzFyQ.js";
|
|
70
|
+
import { n as normalizePollInput } from "./polls-QrTzhQf5.js";
|
|
71
|
+
import { i as startBrowserControlServiceFromConfig, n as createBrowserRouteDispatcher, r as createBrowserControlContext } from "./with-timeout-DKgjtZv2.js";
|
|
72
|
+
import { i as parseAbsoluteTimeMs, n as resolveCronStaggerMs, r as resolveDefaultCronStaggerMs, t as normalizeCronStaggerMs } from "./stagger-Cek4Eizw.js";
|
|
73
|
+
import { n as resolveMessageChannelSelection } from "./channel-selection-BnXQH0vV.js";
|
|
74
|
+
import { i as buildChannelUiCatalog, t as applyPluginAutoEnable } from "./plugin-auto-enable-3v7X3qMK.js";
|
|
75
|
+
import { n as GATEWAY_AUTH_SURFACE_PATHS, p as isKnownSecretTargetId, r as evaluateGatewayAuthSurfaceStates } from "./runtime-config-collectors-CML7zUqZ.js";
|
|
76
|
+
import { C as normalizeControlUiBasePath, S as buildControlUiAvatarUrl, w as resolveAssistantAvatarUrl, x as CONTROL_UI_AVATAR_PREFIX } from "./onboard-helpers-BkwNJPNU.js";
|
|
77
|
+
import { i as resolveMemoryBackendConfig, r as getMemorySearchManager } from "./memory-cli-yvsbLFgi.js";
|
|
78
|
+
import { i as resolveMemorySearchConfig } from "./manager-BVqjeGyT.js";
|
|
79
|
+
import { t as buildWorkspaceSkillStatus } from "./skills-status-NIhVZfqm.js";
|
|
80
|
+
import { i as onHeartbeatEvent, r as getLastHeartbeatEvent, t as resolveHeartbeatVisibility } from "./heartbeat-visibility-C_P1yurK.js";
|
|
81
|
+
import { t as ensureOpenClawCliOnPath } from "./path-env-CgmdxEc7.js";
|
|
82
|
+
import { n as DEFAULT_GATEWAY_HTTP_TOOL_DENY } from "./dangerous-tools-B9LIt3MU.js";
|
|
83
|
+
import { t as WizardCancelledError } from "./prompts-DomsZukd.js";
|
|
84
|
+
import { t as resolveChannelDefaultAccountId } from "./helpers-DDBxLojl.js";
|
|
85
|
+
import { a as pruneAgentConfig, i as loadAgentIdentity, r as findAgentEntryIndex, t as applyAgentConfig } from "./agents.config-OuZqDEe6.js";
|
|
86
|
+
import { t as isWithinDir } from "./path-safety-EkGa1GqP.js";
|
|
87
|
+
import { n as formatConfigIssueLines } from "./issue-format-BMPYbT1P.js";
|
|
88
|
+
import { t as buildChannelAccountSnapshot } from "./status-DNPn0STZ.js";
|
|
89
|
+
import { a as buildBaseHints, i as applySensitiveHints, n as redactConfigSnapshot, o as mapSensitivePaths, r as restoreRedactedValues, s as applyDerivedTags, t as redactConfigObject } from "./redact-snapshot-DDgxiqE4.js";
|
|
90
|
+
import { n as resolveWideAreaDiscoveryDomain, r as writeWideAreaGatewayZone } from "./widearea-dns-9PZLZ6zk.js";
|
|
91
|
+
import { r as getStatusSummary } from "./status-DN8lRmcz.js";
|
|
92
|
+
import { c as setHeartbeatsEnabled, l as startHeartbeatRunner, n as getHealthSnapshot, s as runHeartbeatOnce, u as isCronSystemEvent } from "./health-Cs-k6kLT.js";
|
|
93
|
+
import { a as resolveControlUiRootSync, i as resolveControlUiRootOverrideSync, t as ensureControlUiAssetsBuilt } from "./control-ui-assets-Co9rmXkB.js";
|
|
94
|
+
import { h as normalizeUpdateChannel, l as DEFAULT_PACKAGE_CHANNEL, n as checkUpdateStatus, o as resolveNpmChannelTag, r as compareSemverStrings } from "./channel-account-context-DGbGZhGz.js";
|
|
95
|
+
import { a as resolveCommandSecretsFromActiveRuntimeSnapshot, i as prepareSecretsRuntimeSnapshot, n as clearSecretsRuntimeSnapshot, r as getActiveSecretsRuntimeSnapshot, t as activateSecretsRuntimeSnapshot } from "./runtime-BBknab-X.js";
|
|
96
|
+
import { t as runOnboardingWizard } from "./onboarding-gbgi-zx9.js";
|
|
97
|
+
import { a as sendApnsAlert, c as parseMessageWithAttachments, d as shouldLogWs, f as summarizeAgentEventForWsLog, i as resolveApnsAuthConfigFromEnv, l as formatForLog, n as normalizeApnsEnvironment, o as sendApnsBackgroundWake, s as normalizeRpcAttachmentsToChatAttachments, t as loadApnsRegistration, u as logWs } from "./push-apns-D7Kl5IlU.js";
|
|
98
|
+
import { T as resolveGmailHookRuntimeConfig, _ as buildGogWatchServeArgs, i as ensureTailscaleEndpoint, v as buildGogWatchStartArgs } from "./gmail-setup-utils-DuoBM8ed.js";
|
|
99
|
+
import { n as isNodeCommandAllowed, r as resolveNodeCommandAllowlist } from "./node-command-policy-CeKPGmlP.js";
|
|
100
|
+
import { n as collectEnabledInsecureOrDangerousFlags } from "./audit-BWNRwu8g.js";
|
|
101
|
+
import { t as installSkill } from "./skills-install-LXdiRh5j.js";
|
|
102
|
+
import { t as runGatewayUpdate } from "./update-runner-BDHtvoca.js";
|
|
103
|
+
import { t as GatewayLockError } from "./gateway-lock-DNpln_70.js";
|
|
104
|
+
import { i as shouldIncludeHook, r as resolveHookConfig, t as loadWorkspaceHookEntries } from "./workspace-CedZZfvJ.js";
|
|
167
105
|
import { spawn, spawnSync } from "node:child_process";
|
|
168
106
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
169
107
|
import os from "node:os";
|
|
@@ -176,816 +114,14 @@ import fs$1 from "node:fs/promises";
|
|
|
176
114
|
import crypto, { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
177
115
|
import { z } from "zod";
|
|
178
116
|
import { CURRENT_SESSION_VERSION, SessionManager } from "@mariozechner/pi-coding-agent";
|
|
179
|
-
import
|
|
180
|
-
import
|
|
181
|
-
import { createServer as createServer$2 } from "node:https";
|
|
117
|
+
import http, { createServer } from "node:http";
|
|
118
|
+
import { createServer as createServer$1 } from "node:https";
|
|
182
119
|
import { WebSocketServer } from "ws";
|
|
183
120
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
184
121
|
import chokidar from "chokidar";
|
|
185
122
|
import { Cron } from "croner";
|
|
186
123
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
187
124
|
|
|
188
|
-
//#region src/infra/ssh-config.ts
|
|
189
|
-
function parsePort(value) {
|
|
190
|
-
if (!value) return;
|
|
191
|
-
const parsed = Number.parseInt(value, 10);
|
|
192
|
-
if (!Number.isFinite(parsed) || parsed <= 0) return;
|
|
193
|
-
return parsed;
|
|
194
|
-
}
|
|
195
|
-
function parseSshConfigOutput(output) {
|
|
196
|
-
const result = { identityFiles: [] };
|
|
197
|
-
const lines = output.split("\n");
|
|
198
|
-
for (const raw of lines) {
|
|
199
|
-
const line = raw.trim();
|
|
200
|
-
if (!line) continue;
|
|
201
|
-
const [key, ...rest] = line.split(/\s+/);
|
|
202
|
-
const value = rest.join(" ").trim();
|
|
203
|
-
if (!key || !value) continue;
|
|
204
|
-
switch (key) {
|
|
205
|
-
case "user":
|
|
206
|
-
result.user = value;
|
|
207
|
-
break;
|
|
208
|
-
case "hostname":
|
|
209
|
-
result.host = value;
|
|
210
|
-
break;
|
|
211
|
-
case "port":
|
|
212
|
-
result.port = parsePort(value);
|
|
213
|
-
break;
|
|
214
|
-
case "identityfile":
|
|
215
|
-
if (value !== "none") result.identityFiles.push(value);
|
|
216
|
-
break;
|
|
217
|
-
default: break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return result;
|
|
221
|
-
}
|
|
222
|
-
async function resolveSshConfig(target, opts = {}) {
|
|
223
|
-
const sshPath = "/usr/bin/ssh";
|
|
224
|
-
const args = ["-G"];
|
|
225
|
-
if (target.port > 0 && target.port !== 22) args.push("-p", String(target.port));
|
|
226
|
-
if (opts.identity?.trim()) args.push("-i", opts.identity.trim());
|
|
227
|
-
const userHost = target.user ? `${target.user}@${target.host}` : target.host;
|
|
228
|
-
args.push("--", userHost);
|
|
229
|
-
return await new Promise((resolve) => {
|
|
230
|
-
const child = spawn(sshPath, args, { stdio: [
|
|
231
|
-
"ignore",
|
|
232
|
-
"pipe",
|
|
233
|
-
"ignore"
|
|
234
|
-
] });
|
|
235
|
-
let stdout = "";
|
|
236
|
-
child.stdout?.setEncoding("utf8");
|
|
237
|
-
child.stdout?.on("data", (chunk) => {
|
|
238
|
-
stdout += String(chunk);
|
|
239
|
-
});
|
|
240
|
-
const timeoutMs = Math.max(200, opts.timeoutMs ?? 800);
|
|
241
|
-
const timer = setTimeout(() => {
|
|
242
|
-
try {
|
|
243
|
-
child.kill("SIGKILL");
|
|
244
|
-
} finally {
|
|
245
|
-
resolve(null);
|
|
246
|
-
}
|
|
247
|
-
}, timeoutMs);
|
|
248
|
-
child.once("error", () => {
|
|
249
|
-
clearTimeout(timer);
|
|
250
|
-
resolve(null);
|
|
251
|
-
});
|
|
252
|
-
child.once("exit", (code) => {
|
|
253
|
-
clearTimeout(timer);
|
|
254
|
-
if (code !== 0 || !stdout.trim()) {
|
|
255
|
-
resolve(null);
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
resolve(parseSshConfigOutput(stdout));
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/infra/ssh-tunnel.ts
|
|
265
|
-
function parseSshTarget(raw) {
|
|
266
|
-
const trimmed = raw.trim().replace(/^ssh\s+/, "");
|
|
267
|
-
if (!trimmed) return null;
|
|
268
|
-
const [userPart, hostPart] = trimmed.includes("@") ? (() => {
|
|
269
|
-
const idx = trimmed.indexOf("@");
|
|
270
|
-
const user = trimmed.slice(0, idx).trim();
|
|
271
|
-
const host = trimmed.slice(idx + 1).trim();
|
|
272
|
-
return [user || void 0, host];
|
|
273
|
-
})() : [void 0, trimmed];
|
|
274
|
-
const colonIdx = hostPart.lastIndexOf(":");
|
|
275
|
-
if (colonIdx > 0 && colonIdx < hostPart.length - 1) {
|
|
276
|
-
const host = hostPart.slice(0, colonIdx).trim();
|
|
277
|
-
const portRaw = hostPart.slice(colonIdx + 1).trim();
|
|
278
|
-
const port = Number.parseInt(portRaw, 10);
|
|
279
|
-
if (!host || !Number.isFinite(port) || port <= 0) return null;
|
|
280
|
-
if (host.startsWith("-")) return null;
|
|
281
|
-
return {
|
|
282
|
-
user: userPart,
|
|
283
|
-
host,
|
|
284
|
-
port
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
if (!hostPart) return null;
|
|
288
|
-
if (hostPart.startsWith("-")) return null;
|
|
289
|
-
return {
|
|
290
|
-
user: userPart,
|
|
291
|
-
host: hostPart,
|
|
292
|
-
port: 22
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
async function pickEphemeralPort() {
|
|
296
|
-
return await new Promise((resolve, reject) => {
|
|
297
|
-
const server = net.createServer();
|
|
298
|
-
server.once("error", reject);
|
|
299
|
-
server.listen(0, "127.0.0.1", () => {
|
|
300
|
-
const addr = server.address();
|
|
301
|
-
server.close(() => {
|
|
302
|
-
if (!addr || typeof addr === "string") {
|
|
303
|
-
reject(/* @__PURE__ */ new Error("failed to allocate a local port"));
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
resolve(addr.port);
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
async function canConnectLocal(port) {
|
|
312
|
-
return await new Promise((resolve) => {
|
|
313
|
-
const socket = net.connect({
|
|
314
|
-
host: "127.0.0.1",
|
|
315
|
-
port
|
|
316
|
-
});
|
|
317
|
-
const done = (ok) => {
|
|
318
|
-
socket.removeAllListeners();
|
|
319
|
-
socket.destroy();
|
|
320
|
-
resolve(ok);
|
|
321
|
-
};
|
|
322
|
-
socket.once("connect", () => done(true));
|
|
323
|
-
socket.once("error", () => done(false));
|
|
324
|
-
socket.setTimeout(250, () => done(false));
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
async function waitForLocalListener(port, timeoutMs) {
|
|
328
|
-
const startedAt = Date.now();
|
|
329
|
-
while (Date.now() - startedAt < timeoutMs) {
|
|
330
|
-
if (await canConnectLocal(port)) return;
|
|
331
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
332
|
-
}
|
|
333
|
-
throw new Error(`ssh tunnel did not start listening on localhost:${port}`);
|
|
334
|
-
}
|
|
335
|
-
async function startSshPortForward(opts) {
|
|
336
|
-
const parsed = parseSshTarget(opts.target);
|
|
337
|
-
if (!parsed) throw new Error(`invalid SSH target: ${opts.target}`);
|
|
338
|
-
let localPort = opts.localPortPreferred;
|
|
339
|
-
try {
|
|
340
|
-
await ensurePortAvailable(localPort);
|
|
341
|
-
} catch (err) {
|
|
342
|
-
if (isErrno(err) && err.code === "EADDRINUSE") localPort = await pickEphemeralPort();
|
|
343
|
-
else throw err;
|
|
344
|
-
}
|
|
345
|
-
const userHost = parsed.user ? `${parsed.user}@${parsed.host}` : parsed.host;
|
|
346
|
-
const args = [
|
|
347
|
-
"-N",
|
|
348
|
-
"-L",
|
|
349
|
-
`${localPort}:127.0.0.1:${opts.remotePort}`,
|
|
350
|
-
"-p",
|
|
351
|
-
String(parsed.port),
|
|
352
|
-
"-o",
|
|
353
|
-
"ExitOnForwardFailure=yes",
|
|
354
|
-
"-o",
|
|
355
|
-
"BatchMode=yes",
|
|
356
|
-
"-o",
|
|
357
|
-
"StrictHostKeyChecking=yes",
|
|
358
|
-
"-o",
|
|
359
|
-
"UpdateHostKeys=yes",
|
|
360
|
-
"-o",
|
|
361
|
-
"ConnectTimeout=5",
|
|
362
|
-
"-o",
|
|
363
|
-
"ServerAliveInterval=15",
|
|
364
|
-
"-o",
|
|
365
|
-
"ServerAliveCountMax=3"
|
|
366
|
-
];
|
|
367
|
-
if (opts.identity?.trim()) args.push("-i", opts.identity.trim());
|
|
368
|
-
args.push("--", userHost);
|
|
369
|
-
const stderr = [];
|
|
370
|
-
const child = spawn("/usr/bin/ssh", args, { stdio: [
|
|
371
|
-
"ignore",
|
|
372
|
-
"ignore",
|
|
373
|
-
"pipe"
|
|
374
|
-
] });
|
|
375
|
-
child.stderr?.setEncoding("utf8");
|
|
376
|
-
child.stderr?.on("data", (chunk) => {
|
|
377
|
-
const lines = String(chunk).split("\n").map((l) => l.trim()).filter(Boolean);
|
|
378
|
-
stderr.push(...lines);
|
|
379
|
-
});
|
|
380
|
-
const stop = async () => {
|
|
381
|
-
if (child.killed) return;
|
|
382
|
-
child.kill("SIGTERM");
|
|
383
|
-
await new Promise((resolve) => {
|
|
384
|
-
const t = setTimeout(() => {
|
|
385
|
-
try {
|
|
386
|
-
child.kill("SIGKILL");
|
|
387
|
-
} finally {
|
|
388
|
-
resolve();
|
|
389
|
-
}
|
|
390
|
-
}, 1500);
|
|
391
|
-
child.once("exit", () => {
|
|
392
|
-
clearTimeout(t);
|
|
393
|
-
resolve();
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
};
|
|
397
|
-
try {
|
|
398
|
-
await Promise.race([waitForLocalListener(localPort, Math.max(250, opts.timeoutMs)), new Promise((_, reject) => {
|
|
399
|
-
child.once("exit", (code, signal) => {
|
|
400
|
-
reject(/* @__PURE__ */ new Error(`ssh exited (${code ?? "null"}${signal ? `/${signal}` : ""})`));
|
|
401
|
-
});
|
|
402
|
-
})]);
|
|
403
|
-
} catch (err) {
|
|
404
|
-
await stop();
|
|
405
|
-
const suffix = stderr.length > 0 ? `\n${stderr.join("\n")}` : "";
|
|
406
|
-
throw new Error(`${err instanceof Error ? err.message : String(err)}${suffix}`, { cause: err });
|
|
407
|
-
}
|
|
408
|
-
return {
|
|
409
|
-
parsedTarget: parsed,
|
|
410
|
-
localPort,
|
|
411
|
-
remotePort: opts.remotePort,
|
|
412
|
-
pid: typeof child.pid === "number" ? child.pid : null,
|
|
413
|
-
stderr,
|
|
414
|
-
stop
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
//#endregion
|
|
419
|
-
//#region src/commands/gateway-status/helpers.ts
|
|
420
|
-
function parseIntOrNull(value) {
|
|
421
|
-
const s = typeof value === "string" ? value.trim() : typeof value === "number" || typeof value === "bigint" ? String(value) : "";
|
|
422
|
-
if (!s) return null;
|
|
423
|
-
const n = Number.parseInt(s, 10);
|
|
424
|
-
return Number.isFinite(n) ? n : null;
|
|
425
|
-
}
|
|
426
|
-
function parseTimeoutMs(raw, fallbackMs) {
|
|
427
|
-
const value = typeof raw === "string" ? raw.trim() : typeof raw === "number" || typeof raw === "bigint" ? String(raw) : "";
|
|
428
|
-
if (!value) return fallbackMs;
|
|
429
|
-
const parsed = Number.parseInt(value, 10);
|
|
430
|
-
if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(`invalid --timeout: ${value}`);
|
|
431
|
-
return parsed;
|
|
432
|
-
}
|
|
433
|
-
function normalizeWsUrl(value) {
|
|
434
|
-
const trimmed = value.trim();
|
|
435
|
-
if (!trimmed) return null;
|
|
436
|
-
if (!trimmed.startsWith("ws://") && !trimmed.startsWith("wss://")) return null;
|
|
437
|
-
return trimmed;
|
|
438
|
-
}
|
|
439
|
-
function resolveTargets(cfg, explicitUrl) {
|
|
440
|
-
const targets = [];
|
|
441
|
-
const add = (t) => {
|
|
442
|
-
if (!targets.some((x) => x.url === t.url)) targets.push(t);
|
|
443
|
-
};
|
|
444
|
-
const explicit = typeof explicitUrl === "string" ? normalizeWsUrl(explicitUrl) : null;
|
|
445
|
-
if (explicit) add({
|
|
446
|
-
id: "explicit",
|
|
447
|
-
kind: "explicit",
|
|
448
|
-
url: explicit,
|
|
449
|
-
active: true
|
|
450
|
-
});
|
|
451
|
-
const remoteUrl = typeof cfg.gateway?.remote?.url === "string" ? normalizeWsUrl(cfg.gateway.remote.url) : null;
|
|
452
|
-
if (remoteUrl) add({
|
|
453
|
-
id: "configRemote",
|
|
454
|
-
kind: "configRemote",
|
|
455
|
-
url: remoteUrl,
|
|
456
|
-
active: cfg.gateway?.mode === "remote"
|
|
457
|
-
});
|
|
458
|
-
add({
|
|
459
|
-
id: "localLoopback",
|
|
460
|
-
kind: "localLoopback",
|
|
461
|
-
url: `ws://127.0.0.1:${resolveGatewayPort(cfg)}`,
|
|
462
|
-
active: cfg.gateway?.mode !== "remote"
|
|
463
|
-
});
|
|
464
|
-
return targets;
|
|
465
|
-
}
|
|
466
|
-
function resolveProbeBudgetMs(overallMs, kind) {
|
|
467
|
-
if (kind === "localLoopback") return Math.min(800, overallMs);
|
|
468
|
-
if (kind === "sshTunnel") return Math.min(2e3, overallMs);
|
|
469
|
-
return Math.min(1500, overallMs);
|
|
470
|
-
}
|
|
471
|
-
function sanitizeSshTarget(value) {
|
|
472
|
-
if (typeof value !== "string") return null;
|
|
473
|
-
const trimmed = value.trim();
|
|
474
|
-
if (!trimmed) return null;
|
|
475
|
-
return trimmed.replace(/^ssh\\s+/, "");
|
|
476
|
-
}
|
|
477
|
-
function readGatewayTokenEnv(env = process.env) {
|
|
478
|
-
return env.OPENCLAW_GATEWAY_TOKEN?.trim() || env.CLAWDBOT_GATEWAY_TOKEN?.trim() || void 0;
|
|
479
|
-
}
|
|
480
|
-
function readGatewayPasswordEnv(env = process.env) {
|
|
481
|
-
return env.OPENCLAW_GATEWAY_PASSWORD?.trim() || env.CLAWDBOT_GATEWAY_PASSWORD?.trim() || void 0;
|
|
482
|
-
}
|
|
483
|
-
async function resolveAuthForTarget(cfg, target, overrides) {
|
|
484
|
-
const tokenOverride = overrides.token?.trim() ? overrides.token.trim() : void 0;
|
|
485
|
-
const passwordOverride = overrides.password?.trim() ? overrides.password.trim() : void 0;
|
|
486
|
-
if (tokenOverride || passwordOverride) return {
|
|
487
|
-
token: tokenOverride,
|
|
488
|
-
password: passwordOverride
|
|
489
|
-
};
|
|
490
|
-
const diagnostics = [];
|
|
491
|
-
const authMode = cfg.gateway?.auth?.mode;
|
|
492
|
-
const tokenOnly = authMode === "token";
|
|
493
|
-
const passwordOnly = authMode === "password";
|
|
494
|
-
const resolveToken = async (value, path) => {
|
|
495
|
-
const tokenResolution = await resolveConfiguredSecretInputString({
|
|
496
|
-
config: cfg,
|
|
497
|
-
env: process.env,
|
|
498
|
-
value,
|
|
499
|
-
path,
|
|
500
|
-
unresolvedReasonStyle: "detailed"
|
|
501
|
-
});
|
|
502
|
-
if (tokenResolution.unresolvedRefReason) diagnostics.push(tokenResolution.unresolvedRefReason);
|
|
503
|
-
return tokenResolution.value;
|
|
504
|
-
};
|
|
505
|
-
const resolvePassword = async (value, path) => {
|
|
506
|
-
const passwordResolution = await resolveConfiguredSecretInputString({
|
|
507
|
-
config: cfg,
|
|
508
|
-
env: process.env,
|
|
509
|
-
value,
|
|
510
|
-
path,
|
|
511
|
-
unresolvedReasonStyle: "detailed"
|
|
512
|
-
});
|
|
513
|
-
if (passwordResolution.unresolvedRefReason) diagnostics.push(passwordResolution.unresolvedRefReason);
|
|
514
|
-
return passwordResolution.value;
|
|
515
|
-
};
|
|
516
|
-
if (target.kind === "configRemote" || target.kind === "sshTunnel") {
|
|
517
|
-
const remoteTokenValue = cfg.gateway?.remote?.token;
|
|
518
|
-
const remotePasswordValue = (cfg.gateway?.remote)?.password;
|
|
519
|
-
const token = await resolveToken(remoteTokenValue, "gateway.remote.token");
|
|
520
|
-
return {
|
|
521
|
-
token,
|
|
522
|
-
password: token ? void 0 : await resolvePassword(remotePasswordValue, "gateway.remote.password"),
|
|
523
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
if (authMode === "none" || authMode === "trusted-proxy") return {};
|
|
527
|
-
const envToken = readGatewayTokenEnv();
|
|
528
|
-
const envPassword = readGatewayPasswordEnv();
|
|
529
|
-
if (tokenOnly) {
|
|
530
|
-
if (envToken) return { token: envToken };
|
|
531
|
-
return {
|
|
532
|
-
token: await resolveToken(cfg.gateway?.auth?.token, "gateway.auth.token"),
|
|
533
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
if (passwordOnly) {
|
|
537
|
-
if (envPassword) return { password: envPassword };
|
|
538
|
-
return {
|
|
539
|
-
password: await resolvePassword(cfg.gateway?.auth?.password, "gateway.auth.password"),
|
|
540
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
if (envToken) return { token: envToken };
|
|
544
|
-
const token = await resolveToken(cfg.gateway?.auth?.token, "gateway.auth.token");
|
|
545
|
-
if (token) return {
|
|
546
|
-
token,
|
|
547
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
548
|
-
};
|
|
549
|
-
if (envPassword) return {
|
|
550
|
-
password: envPassword,
|
|
551
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
552
|
-
};
|
|
553
|
-
return {
|
|
554
|
-
token,
|
|
555
|
-
password: await resolvePassword(cfg.gateway?.auth?.password, "gateway.auth.password"),
|
|
556
|
-
...diagnostics.length > 0 ? { diagnostics } : {}
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
function extractConfigSummary(snapshotUnknown) {
|
|
560
|
-
const snap = snapshotUnknown;
|
|
561
|
-
const path = typeof snap?.path === "string" ? snap.path : null;
|
|
562
|
-
const exists = Boolean(snap?.exists);
|
|
563
|
-
const valid = Boolean(snap?.valid);
|
|
564
|
-
const issuesRaw = Array.isArray(snap?.issues) ? snap.issues : [];
|
|
565
|
-
const legacyRaw = Array.isArray(snap?.legacyIssues) ? snap.legacyIssues : [];
|
|
566
|
-
const cfg = snap?.config ?? {};
|
|
567
|
-
const gateway = cfg.gateway ?? {};
|
|
568
|
-
const secretDefaults = (cfg.secrets ?? {}).defaults ?? void 0;
|
|
569
|
-
const wideArea = (cfg.discovery ?? {}).wideArea ?? {};
|
|
570
|
-
const remote = gateway.remote ?? {};
|
|
571
|
-
const auth = gateway.auth ?? {};
|
|
572
|
-
const controlUi = gateway.controlUi ?? {};
|
|
573
|
-
const tailscale = gateway.tailscale ?? {};
|
|
574
|
-
const authMode = typeof auth.mode === "string" ? auth.mode : null;
|
|
575
|
-
const authTokenConfigured = hasConfiguredSecretInput(auth.token, secretDefaults);
|
|
576
|
-
const authPasswordConfigured = hasConfiguredSecretInput(auth.password, secretDefaults);
|
|
577
|
-
const remoteUrl = typeof remote.url === "string" ? normalizeWsUrl(remote.url) : null;
|
|
578
|
-
const remoteTokenConfigured = hasConfiguredSecretInput(remote.token, secretDefaults);
|
|
579
|
-
const remotePasswordConfigured = hasConfiguredSecretInput(remote.password, secretDefaults);
|
|
580
|
-
const wideAreaEnabled = typeof wideArea.enabled === "boolean" ? wideArea.enabled : null;
|
|
581
|
-
return {
|
|
582
|
-
path,
|
|
583
|
-
exists,
|
|
584
|
-
valid,
|
|
585
|
-
issues: issuesRaw.filter((i) => Boolean(i && typeof i.path === "string" && typeof i.message === "string")).map((i) => ({
|
|
586
|
-
path: i.path,
|
|
587
|
-
message: i.message
|
|
588
|
-
})),
|
|
589
|
-
legacyIssues: legacyRaw.filter((i) => Boolean(i && typeof i.path === "string" && typeof i.message === "string")).map((i) => ({
|
|
590
|
-
path: i.path,
|
|
591
|
-
message: i.message
|
|
592
|
-
})),
|
|
593
|
-
gateway: {
|
|
594
|
-
mode: typeof gateway.mode === "string" ? gateway.mode : null,
|
|
595
|
-
bind: typeof gateway.bind === "string" ? gateway.bind : null,
|
|
596
|
-
port: parseIntOrNull(gateway.port),
|
|
597
|
-
controlUiEnabled: typeof controlUi.enabled === "boolean" ? controlUi.enabled : null,
|
|
598
|
-
controlUiBasePath: typeof controlUi.basePath === "string" ? controlUi.basePath : null,
|
|
599
|
-
authMode,
|
|
600
|
-
authTokenConfigured,
|
|
601
|
-
authPasswordConfigured,
|
|
602
|
-
remoteUrl,
|
|
603
|
-
remoteTokenConfigured,
|
|
604
|
-
remotePasswordConfigured,
|
|
605
|
-
tailscaleMode: typeof tailscale.mode === "string" ? tailscale.mode : null
|
|
606
|
-
},
|
|
607
|
-
discovery: { wideAreaEnabled }
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
function buildNetworkHints(cfg) {
|
|
611
|
-
const tailnetIPv4 = pickPrimaryTailnetIPv4();
|
|
612
|
-
const port = resolveGatewayPort(cfg);
|
|
613
|
-
return {
|
|
614
|
-
localLoopbackUrl: `ws://127.0.0.1:${port}`,
|
|
615
|
-
localTailnetUrl: tailnetIPv4 ? `ws://${tailnetIPv4}:${port}` : null,
|
|
616
|
-
tailnetIPv4: tailnetIPv4 ?? null
|
|
617
|
-
};
|
|
618
|
-
}
|
|
619
|
-
function renderTargetHeader(target, rich) {
|
|
620
|
-
const kindLabel = target.kind === "localLoopback" ? "Local loopback" : target.kind === "sshTunnel" ? "Remote over SSH" : target.kind === "configRemote" ? target.active ? "Remote (configured)" : "Remote (configured, inactive)" : "URL (explicit)";
|
|
621
|
-
return `${colorize(rich, theme.heading, kindLabel)} ${colorize(rich, theme.muted, target.url)}`;
|
|
622
|
-
}
|
|
623
|
-
function renderProbeSummaryLine(probe, rich) {
|
|
624
|
-
if (probe.ok) {
|
|
625
|
-
const latency = typeof probe.connectLatencyMs === "number" ? `${probe.connectLatencyMs}ms` : "unknown";
|
|
626
|
-
return `${colorize(rich, theme.success, "Connect: ok")} (${latency}) · ${colorize(rich, theme.success, "RPC: ok")}`;
|
|
627
|
-
}
|
|
628
|
-
const detail = probe.error ? ` - ${probe.error}` : "";
|
|
629
|
-
if (probe.connectLatencyMs != null) {
|
|
630
|
-
const latency = typeof probe.connectLatencyMs === "number" ? `${probe.connectLatencyMs}ms` : "unknown";
|
|
631
|
-
return `${colorize(rich, theme.success, "Connect: ok")} (${latency}) · ${colorize(rich, theme.error, "RPC: failed")}${detail}`;
|
|
632
|
-
}
|
|
633
|
-
return `${colorize(rich, theme.error, "Connect: failed")}${detail}`;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region src/commands/gateway-status.ts
|
|
638
|
-
async function gatewayStatusCommand(opts, runtime) {
|
|
639
|
-
const startedAt = Date.now();
|
|
640
|
-
const cfg = loadConfig();
|
|
641
|
-
const rich = isRich() && opts.json !== true;
|
|
642
|
-
const overallTimeoutMs = parseTimeoutMs(opts.timeout, 3e3);
|
|
643
|
-
const wideAreaDomain = resolveWideAreaDiscoveryDomain({ configDomain: cfg.discovery?.wideArea?.domain });
|
|
644
|
-
const baseTargets = resolveTargets(cfg, opts.url);
|
|
645
|
-
const network = buildNetworkHints(cfg);
|
|
646
|
-
const discoveryTimeoutMs = Math.min(1200, overallTimeoutMs);
|
|
647
|
-
const discoveryPromise = discoverGatewayBeacons({
|
|
648
|
-
timeoutMs: discoveryTimeoutMs,
|
|
649
|
-
wideAreaDomain
|
|
650
|
-
});
|
|
651
|
-
let sshTarget = sanitizeSshTarget(opts.ssh) ?? sanitizeSshTarget(cfg.gateway?.remote?.sshTarget);
|
|
652
|
-
let sshIdentity = sanitizeSshTarget(opts.sshIdentity) ?? sanitizeSshTarget(cfg.gateway?.remote?.sshIdentity);
|
|
653
|
-
const remotePort = resolveGatewayPort(cfg);
|
|
654
|
-
let sshTunnelError = null;
|
|
655
|
-
let sshTunnelStarted = false;
|
|
656
|
-
if (!sshTarget) sshTarget = inferSshTargetFromRemoteUrl(cfg.gateway?.remote?.url);
|
|
657
|
-
if (sshTarget) {
|
|
658
|
-
const resolved = await resolveSshTarget(sshTarget, sshIdentity, overallTimeoutMs);
|
|
659
|
-
if (resolved) {
|
|
660
|
-
sshTarget = resolved.target;
|
|
661
|
-
if (!sshIdentity && resolved.identity) sshIdentity = resolved.identity;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
const { discovery, probed } = await withProgress({
|
|
665
|
-
label: "Inspecting gateways…",
|
|
666
|
-
indeterminate: true,
|
|
667
|
-
enabled: opts.json !== true
|
|
668
|
-
}, async () => {
|
|
669
|
-
const tryStartTunnel = async () => {
|
|
670
|
-
if (!sshTarget) return null;
|
|
671
|
-
try {
|
|
672
|
-
const tunnel = await startSshPortForward({
|
|
673
|
-
target: sshTarget,
|
|
674
|
-
identity: sshIdentity ?? void 0,
|
|
675
|
-
localPortPreferred: remotePort,
|
|
676
|
-
remotePort,
|
|
677
|
-
timeoutMs: Math.min(1500, overallTimeoutMs)
|
|
678
|
-
});
|
|
679
|
-
sshTunnelStarted = true;
|
|
680
|
-
return tunnel;
|
|
681
|
-
} catch (err) {
|
|
682
|
-
sshTunnelError = err instanceof Error ? err.message : String(err);
|
|
683
|
-
return null;
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
const discoveryTask = discoveryPromise.catch(() => []);
|
|
687
|
-
const tunnelTask = sshTarget ? tryStartTunnel() : Promise.resolve(null);
|
|
688
|
-
const [discovery, tunnelFirst] = await Promise.all([discoveryTask, tunnelTask]);
|
|
689
|
-
if (!sshTarget && opts.sshAuto) {
|
|
690
|
-
const user = process.env.USER?.trim() || "";
|
|
691
|
-
const candidates = discovery.map((b) => {
|
|
692
|
-
const host = b.tailnetDns || b.lanHost || b.host;
|
|
693
|
-
if (!host?.trim()) return null;
|
|
694
|
-
const sshPort = typeof b.sshPort === "number" && b.sshPort > 0 ? b.sshPort : 22;
|
|
695
|
-
const base = user ? `${user}@${host.trim()}` : host.trim();
|
|
696
|
-
return sshPort !== 22 ? `${base}:${sshPort}` : base;
|
|
697
|
-
}).filter((candidate) => Boolean(candidate && parseSshTarget(candidate)));
|
|
698
|
-
if (candidates.length > 0) sshTarget = candidates[0] ?? null;
|
|
699
|
-
}
|
|
700
|
-
const tunnel = tunnelFirst || (sshTarget && !sshTunnelStarted && !sshTunnelError ? await tryStartTunnel() : null);
|
|
701
|
-
const tunnelTarget = tunnel ? {
|
|
702
|
-
id: "sshTunnel",
|
|
703
|
-
kind: "sshTunnel",
|
|
704
|
-
url: `ws://127.0.0.1:${tunnel.localPort}`,
|
|
705
|
-
active: true,
|
|
706
|
-
tunnel: {
|
|
707
|
-
kind: "ssh",
|
|
708
|
-
target: sshTarget ?? "",
|
|
709
|
-
localPort: tunnel.localPort,
|
|
710
|
-
remotePort,
|
|
711
|
-
pid: tunnel.pid
|
|
712
|
-
}
|
|
713
|
-
} : null;
|
|
714
|
-
const targets = tunnelTarget ? [tunnelTarget, ...baseTargets.filter((t) => t.url !== tunnelTarget.url)] : baseTargets;
|
|
715
|
-
try {
|
|
716
|
-
return {
|
|
717
|
-
discovery,
|
|
718
|
-
probed: await Promise.all(targets.map(async (target) => {
|
|
719
|
-
const authResolution = await resolveAuthForTarget(cfg, target, {
|
|
720
|
-
token: typeof opts.token === "string" ? opts.token : void 0,
|
|
721
|
-
password: typeof opts.password === "string" ? opts.password : void 0
|
|
722
|
-
});
|
|
723
|
-
const auth = {
|
|
724
|
-
token: authResolution.token,
|
|
725
|
-
password: authResolution.password
|
|
726
|
-
};
|
|
727
|
-
const timeoutMs = resolveProbeBudgetMs(overallTimeoutMs, target.kind);
|
|
728
|
-
const probe = await probeGateway({
|
|
729
|
-
url: target.url,
|
|
730
|
-
auth,
|
|
731
|
-
timeoutMs
|
|
732
|
-
});
|
|
733
|
-
return {
|
|
734
|
-
target,
|
|
735
|
-
probe,
|
|
736
|
-
configSummary: probe.configSnapshot ? extractConfigSummary(probe.configSnapshot) : null,
|
|
737
|
-
self: pickGatewaySelfPresence(probe.presence),
|
|
738
|
-
authDiagnostics: authResolution.diagnostics ?? []
|
|
739
|
-
};
|
|
740
|
-
}))
|
|
741
|
-
};
|
|
742
|
-
} finally {
|
|
743
|
-
if (tunnel) try {
|
|
744
|
-
await tunnel.stop();
|
|
745
|
-
} catch {}
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
const reachable = probed.filter((p) => p.probe.ok);
|
|
749
|
-
const ok = reachable.length > 0;
|
|
750
|
-
const multipleGateways = reachable.length > 1;
|
|
751
|
-
const primary = reachable.find((p) => p.target.kind === "explicit") ?? reachable.find((p) => p.target.kind === "sshTunnel") ?? reachable.find((p) => p.target.kind === "configRemote") ?? reachable.find((p) => p.target.kind === "localLoopback") ?? null;
|
|
752
|
-
const warnings = [];
|
|
753
|
-
if (sshTarget && !sshTunnelStarted) warnings.push({
|
|
754
|
-
code: "ssh_tunnel_failed",
|
|
755
|
-
message: sshTunnelError ? `SSH tunnel failed: ${String(sshTunnelError)}` : "SSH tunnel failed to start; falling back to direct probes."
|
|
756
|
-
});
|
|
757
|
-
if (multipleGateways) warnings.push({
|
|
758
|
-
code: "multiple_gateways",
|
|
759
|
-
message: "Unconventional setup: multiple reachable gateways detected. Usually one gateway per network is recommended unless you intentionally run isolated profiles, like a rescue bot (see docs: /gateway#multiple-gateways-same-host).",
|
|
760
|
-
targetIds: reachable.map((p) => p.target.id)
|
|
761
|
-
});
|
|
762
|
-
for (const result of probed) {
|
|
763
|
-
if (result.authDiagnostics.length === 0) continue;
|
|
764
|
-
for (const diagnostic of result.authDiagnostics) warnings.push({
|
|
765
|
-
code: "auth_secretref_unresolved",
|
|
766
|
-
message: diagnostic,
|
|
767
|
-
targetIds: [result.target.id]
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
if (opts.json) {
|
|
771
|
-
runtime.log(JSON.stringify({
|
|
772
|
-
ok,
|
|
773
|
-
ts: Date.now(),
|
|
774
|
-
durationMs: Date.now() - startedAt,
|
|
775
|
-
timeoutMs: overallTimeoutMs,
|
|
776
|
-
primaryTargetId: primary?.target.id ?? null,
|
|
777
|
-
warnings,
|
|
778
|
-
network,
|
|
779
|
-
discovery: {
|
|
780
|
-
timeoutMs: discoveryTimeoutMs,
|
|
781
|
-
count: discovery.length,
|
|
782
|
-
beacons: discovery.map((b) => ({
|
|
783
|
-
instanceName: b.instanceName,
|
|
784
|
-
displayName: b.displayName ?? null,
|
|
785
|
-
domain: b.domain ?? null,
|
|
786
|
-
host: b.host ?? null,
|
|
787
|
-
lanHost: b.lanHost ?? null,
|
|
788
|
-
tailnetDns: b.tailnetDns ?? null,
|
|
789
|
-
gatewayPort: b.gatewayPort ?? null,
|
|
790
|
-
sshPort: b.sshPort ?? null,
|
|
791
|
-
wsUrl: (() => {
|
|
792
|
-
const host = b.tailnetDns || b.lanHost || b.host;
|
|
793
|
-
const port = b.gatewayPort ?? 18789;
|
|
794
|
-
return host ? `ws://${host}:${port}` : null;
|
|
795
|
-
})()
|
|
796
|
-
}))
|
|
797
|
-
},
|
|
798
|
-
targets: probed.map((p) => ({
|
|
799
|
-
id: p.target.id,
|
|
800
|
-
kind: p.target.kind,
|
|
801
|
-
url: p.target.url,
|
|
802
|
-
active: p.target.active,
|
|
803
|
-
tunnel: p.target.tunnel ?? null,
|
|
804
|
-
connect: {
|
|
805
|
-
ok: p.probe.ok,
|
|
806
|
-
latencyMs: p.probe.connectLatencyMs,
|
|
807
|
-
error: p.probe.error,
|
|
808
|
-
close: p.probe.close
|
|
809
|
-
},
|
|
810
|
-
self: p.self,
|
|
811
|
-
config: p.configSummary,
|
|
812
|
-
health: p.probe.health,
|
|
813
|
-
summary: p.probe.status,
|
|
814
|
-
presence: p.probe.presence
|
|
815
|
-
}))
|
|
816
|
-
}, null, 2));
|
|
817
|
-
if (!ok) runtime.exit(1);
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
runtime.log(colorize(rich, theme.heading, "Gateway Status"));
|
|
821
|
-
runtime.log(ok ? `${colorize(rich, theme.success, "Reachable")}: yes` : `${colorize(rich, theme.error, "Reachable")}: no`);
|
|
822
|
-
runtime.log(colorize(rich, theme.muted, `Probe budget: ${overallTimeoutMs}ms`));
|
|
823
|
-
if (warnings.length > 0) {
|
|
824
|
-
runtime.log("");
|
|
825
|
-
runtime.log(colorize(rich, theme.warn, "Warning:"));
|
|
826
|
-
for (const w of warnings) runtime.log(`- ${w.message}`);
|
|
827
|
-
}
|
|
828
|
-
runtime.log("");
|
|
829
|
-
runtime.log(colorize(rich, theme.heading, "Discovery (this machine)"));
|
|
830
|
-
const discoveryDomains = wideAreaDomain ? `local. + ${wideAreaDomain}` : "local.";
|
|
831
|
-
runtime.log(discovery.length > 0 ? `Found ${discovery.length} gateway(s) via Bonjour (${discoveryDomains})` : `Found 0 gateways via Bonjour (${discoveryDomains})`);
|
|
832
|
-
if (discovery.length === 0) runtime.log(colorize(rich, theme.muted, "Tip: if the gateway is remote, mDNS won’t cross networks; use Wide-Area Bonjour (split DNS) or SSH tunnels."));
|
|
833
|
-
runtime.log("");
|
|
834
|
-
runtime.log(colorize(rich, theme.heading, "Targets"));
|
|
835
|
-
for (const p of probed) {
|
|
836
|
-
runtime.log(renderTargetHeader(p.target, rich));
|
|
837
|
-
runtime.log(` ${renderProbeSummaryLine(p.probe, rich)}`);
|
|
838
|
-
if (p.target.tunnel?.kind === "ssh") runtime.log(` ${colorize(rich, theme.muted, "ssh")}: ${colorize(rich, theme.command, p.target.tunnel.target)}`);
|
|
839
|
-
if (p.probe.ok && p.self) {
|
|
840
|
-
const host = p.self.host ?? "unknown";
|
|
841
|
-
const ip = p.self.ip ? ` (${p.self.ip})` : "";
|
|
842
|
-
const platform = p.self.platform ? ` · ${p.self.platform}` : "";
|
|
843
|
-
const version = p.self.version ? ` · app ${p.self.version}` : "";
|
|
844
|
-
runtime.log(` ${colorize(rich, theme.info, "Gateway")}: ${host}${ip}${platform}${version}`);
|
|
845
|
-
}
|
|
846
|
-
if (p.configSummary) {
|
|
847
|
-
const c = p.configSummary;
|
|
848
|
-
const wideArea = c.discovery.wideAreaEnabled === true ? "enabled" : c.discovery.wideAreaEnabled === false ? "disabled" : "unknown";
|
|
849
|
-
runtime.log(` ${colorize(rich, theme.info, "Wide-area discovery")}: ${wideArea}`);
|
|
850
|
-
}
|
|
851
|
-
runtime.log("");
|
|
852
|
-
}
|
|
853
|
-
if (!ok) runtime.exit(1);
|
|
854
|
-
}
|
|
855
|
-
function inferSshTargetFromRemoteUrl(rawUrl) {
|
|
856
|
-
if (typeof rawUrl !== "string") return null;
|
|
857
|
-
const trimmed = rawUrl.trim();
|
|
858
|
-
if (!trimmed) return null;
|
|
859
|
-
let host = null;
|
|
860
|
-
try {
|
|
861
|
-
host = new URL(trimmed).hostname || null;
|
|
862
|
-
} catch {
|
|
863
|
-
return null;
|
|
864
|
-
}
|
|
865
|
-
if (!host) return null;
|
|
866
|
-
const user = process.env.USER?.trim() || "";
|
|
867
|
-
return user ? `${user}@${host}` : host;
|
|
868
|
-
}
|
|
869
|
-
function buildSshTarget(input) {
|
|
870
|
-
const host = input.host?.trim() ?? "";
|
|
871
|
-
if (!host) return null;
|
|
872
|
-
const user = input.user?.trim() ?? "";
|
|
873
|
-
const base = user ? `${user}@${host}` : host;
|
|
874
|
-
const port = input.port ?? 22;
|
|
875
|
-
if (port && port !== 22) return `${base}:${port}`;
|
|
876
|
-
return base;
|
|
877
|
-
}
|
|
878
|
-
async function resolveSshTarget(rawTarget, identity, overallTimeoutMs) {
|
|
879
|
-
const parsed = parseSshTarget(rawTarget);
|
|
880
|
-
if (!parsed) return null;
|
|
881
|
-
const config = await resolveSshConfig(parsed, {
|
|
882
|
-
identity: identity ?? void 0,
|
|
883
|
-
timeoutMs: Math.min(800, overallTimeoutMs)
|
|
884
|
-
});
|
|
885
|
-
if (!config) return {
|
|
886
|
-
target: rawTarget,
|
|
887
|
-
identity: identity ?? void 0
|
|
888
|
-
};
|
|
889
|
-
const target = buildSshTarget({
|
|
890
|
-
user: config.user ?? parsed.user,
|
|
891
|
-
host: config.host ?? parsed.host,
|
|
892
|
-
port: config.port ?? parsed.port
|
|
893
|
-
});
|
|
894
|
-
if (!target) return {
|
|
895
|
-
target: rawTarget,
|
|
896
|
-
identity: identity ?? void 0
|
|
897
|
-
};
|
|
898
|
-
return {
|
|
899
|
-
target,
|
|
900
|
-
identity: identity ?? config.identityFiles.find((entry) => entry.trim().length > 0)?.trim() ?? void 0
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
//#endregion
|
|
905
|
-
//#region src/cli/gateway-cli/call.ts
|
|
906
|
-
const gatewayCallOpts = (cmd) => cmd.option("--url <url>", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)").option("--token <token>", "Gateway token (if required)").option("--password <password>", "Gateway password (password auth)").option("--timeout <ms>", "Timeout in ms", "10000").option("--expect-final", "Wait for final response (agent)", false).option("--json", "Output JSON", false);
|
|
907
|
-
const callGatewayCli = async (method, opts, params) => withProgress({
|
|
908
|
-
label: `Gateway ${method}`,
|
|
909
|
-
indeterminate: true,
|
|
910
|
-
enabled: opts.json !== true
|
|
911
|
-
}, async () => await callGateway({
|
|
912
|
-
url: opts.url,
|
|
913
|
-
token: opts.token,
|
|
914
|
-
password: opts.password,
|
|
915
|
-
method,
|
|
916
|
-
params,
|
|
917
|
-
expectFinal: Boolean(opts.expectFinal),
|
|
918
|
-
timeoutMs: Number(opts.timeout ?? 1e4),
|
|
919
|
-
clientName: GATEWAY_CLIENT_NAMES.CLI,
|
|
920
|
-
mode: GATEWAY_CLIENT_MODES.CLI
|
|
921
|
-
}));
|
|
922
|
-
|
|
923
|
-
//#endregion
|
|
924
|
-
//#region src/cli/gateway-cli/discover.ts
|
|
925
|
-
function parseDiscoverTimeoutMs(raw, fallbackMs) {
|
|
926
|
-
if (raw === void 0 || raw === null) return fallbackMs;
|
|
927
|
-
const value = typeof raw === "string" ? raw.trim() : typeof raw === "number" || typeof raw === "bigint" ? String(raw) : null;
|
|
928
|
-
if (value === null) throw new Error("invalid --timeout");
|
|
929
|
-
if (!value) return fallbackMs;
|
|
930
|
-
const parsed = Number.parseInt(value, 10);
|
|
931
|
-
if (!Number.isFinite(parsed) || parsed <= 0) throw new Error(`invalid --timeout: ${value}`);
|
|
932
|
-
return parsed;
|
|
933
|
-
}
|
|
934
|
-
function pickBeaconHost(beacon) {
|
|
935
|
-
const host = beacon.host || beacon.tailnetDns || beacon.lanHost;
|
|
936
|
-
return host?.trim() ? host.trim() : null;
|
|
937
|
-
}
|
|
938
|
-
function pickGatewayPort(beacon) {
|
|
939
|
-
const port = beacon.port ?? beacon.gatewayPort ?? 18789;
|
|
940
|
-
return port > 0 ? port : 18789;
|
|
941
|
-
}
|
|
942
|
-
function dedupeBeacons(beacons) {
|
|
943
|
-
const out = [];
|
|
944
|
-
const seen = /* @__PURE__ */ new Set();
|
|
945
|
-
for (const b of beacons) {
|
|
946
|
-
const host = pickBeaconHost(b) ?? "";
|
|
947
|
-
const key = [
|
|
948
|
-
b.domain ?? "",
|
|
949
|
-
b.instanceName ?? "",
|
|
950
|
-
b.displayName ?? "",
|
|
951
|
-
host,
|
|
952
|
-
String(b.port ?? ""),
|
|
953
|
-
String(b.gatewayPort ?? "")
|
|
954
|
-
].join("|");
|
|
955
|
-
if (seen.has(key)) continue;
|
|
956
|
-
seen.add(key);
|
|
957
|
-
out.push(b);
|
|
958
|
-
}
|
|
959
|
-
return out;
|
|
960
|
-
}
|
|
961
|
-
function renderBeaconLines(beacon, rich) {
|
|
962
|
-
const nameRaw = (beacon.displayName || beacon.instanceName || "Gateway").trim();
|
|
963
|
-
const domainRaw = (beacon.domain || "local.").trim();
|
|
964
|
-
const title = colorize(rich, theme.accentBright, nameRaw);
|
|
965
|
-
const domain = colorize(rich, theme.muted, domainRaw);
|
|
966
|
-
const host = pickBeaconHost(beacon);
|
|
967
|
-
const gatewayPort = pickGatewayPort(beacon);
|
|
968
|
-
const scheme = beacon.gatewayTls ? "wss" : "ws";
|
|
969
|
-
const wsUrl = host ? `${scheme}://${host}:${gatewayPort}` : null;
|
|
970
|
-
const lines = [`- ${title} ${domain}`];
|
|
971
|
-
if (beacon.tailnetDns) lines.push(` ${colorize(rich, theme.info, "tailnet")}: ${beacon.tailnetDns}`);
|
|
972
|
-
if (beacon.lanHost) lines.push(` ${colorize(rich, theme.info, "lan")}: ${beacon.lanHost}`);
|
|
973
|
-
if (beacon.host) lines.push(` ${colorize(rich, theme.info, "host")}: ${beacon.host}`);
|
|
974
|
-
if (wsUrl) lines.push(` ${colorize(rich, theme.muted, "ws")}: ${colorize(rich, theme.command, wsUrl)}`);
|
|
975
|
-
if (beacon.role) lines.push(` ${colorize(rich, theme.muted, "role")}: ${beacon.role}`);
|
|
976
|
-
if (beacon.transport) lines.push(` ${colorize(rich, theme.muted, "transport")}: ${beacon.transport}`);
|
|
977
|
-
if (beacon.gatewayTls) {
|
|
978
|
-
const fingerprint = beacon.gatewayTlsFingerprintSha256 ? `sha256 ${beacon.gatewayTlsFingerprintSha256}` : "enabled";
|
|
979
|
-
lines.push(` ${colorize(rich, theme.muted, "tls")}: ${fingerprint}`);
|
|
980
|
-
}
|
|
981
|
-
if (typeof beacon.sshPort === "number" && beacon.sshPort > 0 && host) {
|
|
982
|
-
const ssh = `ssh -N -L 18789:127.0.0.1:18789 <user>@${host} -p ${beacon.sshPort}`;
|
|
983
|
-
lines.push(` ${colorize(rich, theme.muted, "ssh")}: ${colorize(rich, theme.command, ssh)}`);
|
|
984
|
-
}
|
|
985
|
-
return lines;
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
//#endregion
|
|
989
125
|
//#region src/gateway/server/close-reason.ts
|
|
990
126
|
const CLOSE_REASON_MAX_BYTES = 120;
|
|
991
127
|
function truncateCloseReason(reason, maxBytes = CLOSE_REASON_MAX_BYTES) {
|
|
@@ -14371,7 +13507,7 @@ const nodeHandlers = {
|
|
|
14371
13507
|
const p = params;
|
|
14372
13508
|
const payloadJSON = typeof p.payloadJSON === "string" ? p.payloadJSON : p.payload !== void 0 ? JSON.stringify(p.payload) : null;
|
|
14373
13509
|
await respondUnavailableOnThrow(respond, async () => {
|
|
14374
|
-
const { handleNodeEvent } = await import("./server-node-events-
|
|
13510
|
+
const { handleNodeEvent } = await import("./server-node-events-Ck1bPPa5.js");
|
|
14375
13511
|
const nodeId = client?.connect?.device?.id ?? client?.connect?.client?.id ?? "node";
|
|
14376
13512
|
await handleNodeEvent({
|
|
14377
13513
|
deps: context.deps,
|
|
@@ -15958,7 +15094,7 @@ const usageHandlers = {
|
|
|
15958
15094
|
const resolved = resolveSessionUsageFileOrRespond(key, respond);
|
|
15959
15095
|
if (!resolved) return;
|
|
15960
15096
|
const { config, entry, agentId, sessionId, sessionFile } = resolved;
|
|
15961
|
-
const { loadSessionLogs } = await import("./session-cost-usage-
|
|
15097
|
+
const { loadSessionLogs } = await import("./session-cost-usage-CBHvFXhD.js").then((n) => n.a);
|
|
15962
15098
|
respond(true, { logs: await loadSessionLogs({
|
|
15963
15099
|
sessionId,
|
|
15964
15100
|
sessionEntry: entry,
|
|
@@ -16687,6 +15823,9 @@ function hasConnectedMobileNode(registry) {
|
|
|
16687
15823
|
|
|
16688
15824
|
//#endregion
|
|
16689
15825
|
//#region src/gateway/server-model-catalog.ts
|
|
15826
|
+
function __resetModelCatalogCacheForTest() {
|
|
15827
|
+
resetModelCatalogCacheForTest();
|
|
15828
|
+
}
|
|
16690
15829
|
async function loadGatewayModelCatalog() {
|
|
16691
15830
|
return await loadModelCatalog({ config: loadConfig() });
|
|
16692
15831
|
}
|
|
@@ -17510,7 +16649,7 @@ function normalizeAgentPayload(payload) {
|
|
|
17510
16649
|
async function startBrowserControlServerIfEnabled() {
|
|
17511
16650
|
if (isTruthyEnvValue(process.env.OPENCLAW_SKIP_BROWSER_CONTROL_SERVER)) return null;
|
|
17512
16651
|
const override = process.env.OPENCLAW_BROWSER_CONTROL_MODULE?.trim();
|
|
17513
|
-
const mod = override ? await import(override) : await import("./server-
|
|
16652
|
+
const mod = override ? await import(override) : await import("./server-DfSS2w17.js");
|
|
17514
16653
|
const start = typeof mod.startBrowserControlServiceFromConfig === "function" ? mod.startBrowserControlServiceFromConfig : mod.startBrowserControlServerFromConfig;
|
|
17515
16654
|
const stop = typeof mod.stopBrowserControlService === "function" ? mod.stopBrowserControlService : mod.stopBrowserControlServer;
|
|
17516
16655
|
if (!start) return null;
|
|
@@ -20842,9 +19981,9 @@ function createHooksRequestHandler(opts) {
|
|
|
20842
19981
|
}
|
|
20843
19982
|
function createGatewayHttpServer(opts) {
|
|
20844
19983
|
const { canvasHost, clients, controlUiEnabled, controlUiBasePath, controlUiRoot, openAiChatCompletionsEnabled, openAiChatCompletionsConfig, openResponsesEnabled, openResponsesConfig, strictTransportSecurityHeader, handleHooksRequest, handlePluginRequest, shouldEnforcePluginGatewayAuth, resolvedAuth, rateLimiter } = opts;
|
|
20845
|
-
const httpServer = opts.tlsOptions ? createServer$
|
|
19984
|
+
const httpServer = opts.tlsOptions ? createServer$1(opts.tlsOptions, (req, res) => {
|
|
20846
19985
|
handleRequest(req, res);
|
|
20847
|
-
}) : createServer
|
|
19986
|
+
}) : createServer((req, res) => {
|
|
20848
19987
|
handleRequest(req, res);
|
|
20849
19988
|
});
|
|
20850
19989
|
async function handleRequest(req, res) {
|
|
@@ -21104,189 +20243,6 @@ function createGatewayHooksRequestHandler(params) {
|
|
|
21104
20243
|
});
|
|
21105
20244
|
}
|
|
21106
20245
|
|
|
21107
|
-
//#endregion
|
|
21108
|
-
//#region src/infra/gateway-lock.ts
|
|
21109
|
-
const DEFAULT_TIMEOUT_MS = 5e3;
|
|
21110
|
-
const DEFAULT_POLL_INTERVAL_MS = 100;
|
|
21111
|
-
const DEFAULT_STALE_MS = 3e4;
|
|
21112
|
-
const DEFAULT_PORT_PROBE_TIMEOUT_MS = 1e3;
|
|
21113
|
-
var GatewayLockError = class extends Error {
|
|
21114
|
-
constructor(message, cause) {
|
|
21115
|
-
super(message);
|
|
21116
|
-
this.cause = cause;
|
|
21117
|
-
this.name = "GatewayLockError";
|
|
21118
|
-
}
|
|
21119
|
-
};
|
|
21120
|
-
function normalizeProcArg(arg) {
|
|
21121
|
-
return arg.replaceAll("\\", "/").toLowerCase();
|
|
21122
|
-
}
|
|
21123
|
-
function parseProcCmdline(raw) {
|
|
21124
|
-
return raw.split("\0").map((entry) => entry.trim()).filter(Boolean);
|
|
21125
|
-
}
|
|
21126
|
-
function isGatewayArgv(args) {
|
|
21127
|
-
const normalized = args.map(normalizeProcArg);
|
|
21128
|
-
if (!normalized.includes("gateway")) return false;
|
|
21129
|
-
const entryCandidates = [
|
|
21130
|
-
"dist/index.js",
|
|
21131
|
-
"dist/entry.js",
|
|
21132
|
-
"openclaw.mjs",
|
|
21133
|
-
"scripts/run-node.mjs",
|
|
21134
|
-
"src/index.ts"
|
|
21135
|
-
];
|
|
21136
|
-
if (normalized.some((arg) => entryCandidates.some((entry) => arg.endsWith(entry)))) return true;
|
|
21137
|
-
const exe = normalized[0] ?? "";
|
|
21138
|
-
return exe.endsWith("/openclaw") || exe === "openclaw";
|
|
21139
|
-
}
|
|
21140
|
-
function readLinuxCmdline(pid) {
|
|
21141
|
-
try {
|
|
21142
|
-
return parseProcCmdline(fs.readFileSync(`/proc/${pid}/cmdline`, "utf8"));
|
|
21143
|
-
} catch {
|
|
21144
|
-
return null;
|
|
21145
|
-
}
|
|
21146
|
-
}
|
|
21147
|
-
function readLinuxStartTime(pid) {
|
|
21148
|
-
try {
|
|
21149
|
-
const raw = fs.readFileSync(`/proc/${pid}/stat`, "utf8").trim();
|
|
21150
|
-
const closeParen = raw.lastIndexOf(")");
|
|
21151
|
-
if (closeParen < 0) return null;
|
|
21152
|
-
const fields = raw.slice(closeParen + 1).trim().split(/\s+/);
|
|
21153
|
-
const startTime = Number.parseInt(fields[19] ?? "", 10);
|
|
21154
|
-
return Number.isFinite(startTime) ? startTime : null;
|
|
21155
|
-
} catch {
|
|
21156
|
-
return null;
|
|
21157
|
-
}
|
|
21158
|
-
}
|
|
21159
|
-
async function checkPortFree(port, host = "127.0.0.1") {
|
|
21160
|
-
return await new Promise((resolve) => {
|
|
21161
|
-
const socket = net.createConnection({
|
|
21162
|
-
port,
|
|
21163
|
-
host
|
|
21164
|
-
});
|
|
21165
|
-
let settled = false;
|
|
21166
|
-
const finish = (result) => {
|
|
21167
|
-
if (settled) return;
|
|
21168
|
-
settled = true;
|
|
21169
|
-
clearTimeout(timer);
|
|
21170
|
-
socket.removeAllListeners();
|
|
21171
|
-
socket.destroy();
|
|
21172
|
-
resolve(result);
|
|
21173
|
-
};
|
|
21174
|
-
const timer = setTimeout(() => {
|
|
21175
|
-
finish(true);
|
|
21176
|
-
}, DEFAULT_PORT_PROBE_TIMEOUT_MS);
|
|
21177
|
-
socket.once("connect", () => {
|
|
21178
|
-
finish(false);
|
|
21179
|
-
});
|
|
21180
|
-
socket.once("error", () => {
|
|
21181
|
-
finish(true);
|
|
21182
|
-
});
|
|
21183
|
-
});
|
|
21184
|
-
}
|
|
21185
|
-
async function resolveGatewayOwnerStatus(pid, payload, platform, port) {
|
|
21186
|
-
if (port != null) {
|
|
21187
|
-
if (await checkPortFree(port)) return "dead";
|
|
21188
|
-
}
|
|
21189
|
-
if (!isPidAlive(pid)) return "dead";
|
|
21190
|
-
if (platform !== "linux") return "alive";
|
|
21191
|
-
const payloadStartTime = payload?.startTime;
|
|
21192
|
-
if (Number.isFinite(payloadStartTime)) {
|
|
21193
|
-
const currentStartTime = readLinuxStartTime(pid);
|
|
21194
|
-
if (currentStartTime == null) return "unknown";
|
|
21195
|
-
return currentStartTime === payloadStartTime ? "alive" : "dead";
|
|
21196
|
-
}
|
|
21197
|
-
const args = readLinuxCmdline(pid);
|
|
21198
|
-
if (!args) return "unknown";
|
|
21199
|
-
return isGatewayArgv(args) ? "alive" : "dead";
|
|
21200
|
-
}
|
|
21201
|
-
async function readLockPayload(lockPath) {
|
|
21202
|
-
try {
|
|
21203
|
-
const raw = await fs$1.readFile(lockPath, "utf8");
|
|
21204
|
-
const parsed = JSON.parse(raw);
|
|
21205
|
-
if (typeof parsed.pid !== "number") return null;
|
|
21206
|
-
if (typeof parsed.createdAt !== "string") return null;
|
|
21207
|
-
if (typeof parsed.configPath !== "string") return null;
|
|
21208
|
-
const startTime = typeof parsed.startTime === "number" ? parsed.startTime : void 0;
|
|
21209
|
-
return {
|
|
21210
|
-
pid: parsed.pid,
|
|
21211
|
-
createdAt: parsed.createdAt,
|
|
21212
|
-
configPath: parsed.configPath,
|
|
21213
|
-
startTime
|
|
21214
|
-
};
|
|
21215
|
-
} catch {
|
|
21216
|
-
return null;
|
|
21217
|
-
}
|
|
21218
|
-
}
|
|
21219
|
-
function resolveGatewayLockPath(env) {
|
|
21220
|
-
const configPath = resolveConfigPath(env, resolveStateDir(env));
|
|
21221
|
-
const hash = createHash("sha256").update(configPath).digest("hex").slice(0, 8);
|
|
21222
|
-
const lockDir = resolveGatewayLockDir();
|
|
21223
|
-
return {
|
|
21224
|
-
lockPath: path.join(lockDir, `gateway.${hash}.lock`),
|
|
21225
|
-
configPath
|
|
21226
|
-
};
|
|
21227
|
-
}
|
|
21228
|
-
async function acquireGatewayLock(opts = {}) {
|
|
21229
|
-
const env = opts.env ?? process.env;
|
|
21230
|
-
const allowInTests = opts.allowInTests === true;
|
|
21231
|
-
if (env.OPENCLAW_ALLOW_MULTI_GATEWAY === "1" || !allowInTests && (env.VITEST || env.NODE_ENV === "test")) return null;
|
|
21232
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
21233
|
-
const pollIntervalMs = opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
21234
|
-
const staleMs = opts.staleMs ?? DEFAULT_STALE_MS;
|
|
21235
|
-
const platform = opts.platform ?? process.platform;
|
|
21236
|
-
const port = opts.port;
|
|
21237
|
-
const { lockPath, configPath } = resolveGatewayLockPath(env);
|
|
21238
|
-
await fs$1.mkdir(path.dirname(lockPath), { recursive: true });
|
|
21239
|
-
const startedAt = Date.now();
|
|
21240
|
-
let lastPayload = null;
|
|
21241
|
-
while (Date.now() - startedAt < timeoutMs) try {
|
|
21242
|
-
const handle = await fs$1.open(lockPath, "wx");
|
|
21243
|
-
const startTime = platform === "linux" ? readLinuxStartTime(process.pid) : null;
|
|
21244
|
-
const payload = {
|
|
21245
|
-
pid: process.pid,
|
|
21246
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21247
|
-
configPath
|
|
21248
|
-
};
|
|
21249
|
-
if (typeof startTime === "number" && Number.isFinite(startTime)) payload.startTime = startTime;
|
|
21250
|
-
await handle.writeFile(JSON.stringify(payload), "utf8");
|
|
21251
|
-
return {
|
|
21252
|
-
lockPath,
|
|
21253
|
-
configPath,
|
|
21254
|
-
release: async () => {
|
|
21255
|
-
await handle.close().catch(() => void 0);
|
|
21256
|
-
await fs$1.rm(lockPath, { force: true });
|
|
21257
|
-
}
|
|
21258
|
-
};
|
|
21259
|
-
} catch (err) {
|
|
21260
|
-
if (err.code !== "EEXIST") throw new GatewayLockError(`failed to acquire gateway lock at ${lockPath}`, err);
|
|
21261
|
-
lastPayload = await readLockPayload(lockPath);
|
|
21262
|
-
const ownerPid = lastPayload?.pid;
|
|
21263
|
-
const ownerStatus = ownerPid ? await resolveGatewayOwnerStatus(ownerPid, lastPayload, platform, port) : "unknown";
|
|
21264
|
-
if (ownerStatus === "dead" && ownerPid) {
|
|
21265
|
-
await fs$1.rm(lockPath, { force: true });
|
|
21266
|
-
continue;
|
|
21267
|
-
}
|
|
21268
|
-
if (ownerStatus !== "alive") {
|
|
21269
|
-
let stale = false;
|
|
21270
|
-
if (lastPayload?.createdAt) {
|
|
21271
|
-
const createdAt = Date.parse(lastPayload.createdAt);
|
|
21272
|
-
stale = Number.isFinite(createdAt) ? Date.now() - createdAt > staleMs : false;
|
|
21273
|
-
}
|
|
21274
|
-
if (!stale) try {
|
|
21275
|
-
const st = await fs$1.stat(lockPath);
|
|
21276
|
-
stale = Date.now() - st.mtimeMs > staleMs;
|
|
21277
|
-
} catch {
|
|
21278
|
-
stale = false;
|
|
21279
|
-
}
|
|
21280
|
-
if (stale) {
|
|
21281
|
-
await fs$1.rm(lockPath, { force: true });
|
|
21282
|
-
continue;
|
|
21283
|
-
}
|
|
21284
|
-
}
|
|
21285
|
-
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
21286
|
-
}
|
|
21287
|
-
throw new GatewayLockError(`gateway already running${lastPayload?.pid ? ` (pid ${lastPayload.pid})` : ""}; lock timeout after ${timeoutMs}ms`);
|
|
21288
|
-
}
|
|
21289
|
-
|
|
21290
20246
|
//#endregion
|
|
21291
20247
|
//#region src/gateway/server/http-listen.ts
|
|
21292
20248
|
const EADDRINUSE_MAX_RETRIES = 4;
|
|
@@ -23645,8 +22601,8 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
23645
22601
|
});
|
|
23646
22602
|
if (!minimalTestGateway) cron.start().catch((err) => logCron.error(`failed to start: ${String(err)}`));
|
|
23647
22603
|
if (!minimalTestGateway) (async () => {
|
|
23648
|
-
const { recoverPendingDeliveries } = await import("./delivery-queue-
|
|
23649
|
-
const { deliverOutboundPayloads } = await import("./deliver-
|
|
22604
|
+
const { recoverPendingDeliveries } = await import("./delivery-queue-BVKd_xSI.js").then((n) => n.n);
|
|
22605
|
+
const { deliverOutboundPayloads } = await import("./deliver-Bge0HwrF.js").then((n) => n.n);
|
|
23650
22606
|
await recoverPendingDeliveries({
|
|
23651
22607
|
deliver: deliverOutboundPayloads,
|
|
23652
22608
|
log: log.child("delivery-recovery"),
|
|
@@ -23905,681 +22861,12 @@ async function startGatewayServer(port = 18789, opts = {}) {
|
|
|
23905
22861
|
}
|
|
23906
22862
|
|
|
23907
22863
|
//#endregion
|
|
23908
|
-
//#region src/
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
|
|
23914
|
-
try {
|
|
23915
|
-
const templateDir = await resolveWorkspaceTemplateDir();
|
|
23916
|
-
const raw = await fs.promises.readFile(path.join(templateDir, name), "utf-8");
|
|
23917
|
-
if (!raw.startsWith("---")) return raw;
|
|
23918
|
-
const endIndex = raw.indexOf("\n---", 3);
|
|
23919
|
-
if (endIndex === -1) return raw;
|
|
23920
|
-
return raw.slice(endIndex + 4).replace(/^\s+/, "");
|
|
23921
|
-
} catch {
|
|
23922
|
-
return fallback;
|
|
23923
|
-
}
|
|
23924
|
-
}
|
|
23925
|
-
const resolveDevWorkspaceDir = (env = process.env) => {
|
|
23926
|
-
const baseDir = resolveDefaultAgentWorkspaceDir(env, os.homedir);
|
|
23927
|
-
if (env.OPENCLAW_PROFILE?.trim().toLowerCase() === "dev") return baseDir;
|
|
23928
|
-
return `${baseDir}-${DEV_AGENT_WORKSPACE_SUFFIX}`;
|
|
23929
|
-
};
|
|
23930
|
-
async function writeFileIfMissing(filePath, content) {
|
|
23931
|
-
try {
|
|
23932
|
-
await fs.promises.writeFile(filePath, content, {
|
|
23933
|
-
encoding: "utf-8",
|
|
23934
|
-
flag: "wx"
|
|
23935
|
-
});
|
|
23936
|
-
} catch (err) {
|
|
23937
|
-
if (err.code !== "EEXIST") throw err;
|
|
23938
|
-
}
|
|
23939
|
-
}
|
|
23940
|
-
async function ensureDevWorkspace(dir) {
|
|
23941
|
-
const resolvedDir = resolveUserPath(dir);
|
|
23942
|
-
await fs.promises.mkdir(resolvedDir, { recursive: true });
|
|
23943
|
-
const [agents, soul, tools, identity, user] = await Promise.all([
|
|
23944
|
-
loadDevTemplate("AGENTS.dev.md", `# AGENTS.md - OpenClaw Dev Workspace\n\nDefault dev workspace for openclaw gateway --dev.\n`),
|
|
23945
|
-
loadDevTemplate("SOUL.dev.md", `# SOUL.md - Dev Persona\n\nProtocol droid for debugging and operations.\n`),
|
|
23946
|
-
loadDevTemplate("TOOLS.dev.md", `# TOOLS.md - User Tool Notes (editable)\n\nAdd your local tool notes here.\n`),
|
|
23947
|
-
loadDevTemplate("IDENTITY.dev.md", `# IDENTITY.md - Agent Identity\n\n- Name: ${DEV_IDENTITY_NAME}\n- Creature: protocol droid\n- Vibe: ${DEV_IDENTITY_THEME}\n- Emoji: ${DEV_IDENTITY_EMOJI}\n`),
|
|
23948
|
-
loadDevTemplate("USER.dev.md", `# USER.md - User Profile\n\n- Name:\n- Preferred address:\n- Notes:\n`)
|
|
23949
|
-
]);
|
|
23950
|
-
await writeFileIfMissing(path.join(resolvedDir, "AGENTS.md"), agents);
|
|
23951
|
-
await writeFileIfMissing(path.join(resolvedDir, "SOUL.md"), soul);
|
|
23952
|
-
await writeFileIfMissing(path.join(resolvedDir, "TOOLS.md"), tools);
|
|
23953
|
-
await writeFileIfMissing(path.join(resolvedDir, "IDENTITY.md"), identity);
|
|
23954
|
-
await writeFileIfMissing(path.join(resolvedDir, "USER.md"), user);
|
|
23955
|
-
}
|
|
23956
|
-
async function ensureDevGatewayConfig(opts) {
|
|
23957
|
-
const workspace = resolveDevWorkspaceDir();
|
|
23958
|
-
if (opts.reset) await handleReset("full", workspace, defaultRuntime);
|
|
23959
|
-
const configPath = createConfigIO().configPath;
|
|
23960
|
-
const configExists = fs.existsSync(configPath);
|
|
23961
|
-
if (!opts.reset && configExists) return;
|
|
23962
|
-
await writeConfigFile({
|
|
23963
|
-
gateway: {
|
|
23964
|
-
mode: "local",
|
|
23965
|
-
bind: "loopback"
|
|
23966
|
-
},
|
|
23967
|
-
agents: {
|
|
23968
|
-
defaults: {
|
|
23969
|
-
workspace,
|
|
23970
|
-
skipBootstrap: true
|
|
23971
|
-
},
|
|
23972
|
-
list: [{
|
|
23973
|
-
id: "dev",
|
|
23974
|
-
default: true,
|
|
23975
|
-
workspace,
|
|
23976
|
-
identity: {
|
|
23977
|
-
name: DEV_IDENTITY_NAME,
|
|
23978
|
-
theme: DEV_IDENTITY_THEME,
|
|
23979
|
-
emoji: DEV_IDENTITY_EMOJI
|
|
23980
|
-
}
|
|
23981
|
-
}]
|
|
23982
|
-
}
|
|
23983
|
-
});
|
|
23984
|
-
await ensureDevWorkspace(workspace);
|
|
23985
|
-
defaultRuntime.log(`Dev config ready: ${shortenHomePath(configPath)}`);
|
|
23986
|
-
defaultRuntime.log(`Dev workspace ready: ${shortenHomePath(resolveUserPath(workspace))}`);
|
|
23987
|
-
}
|
|
23988
|
-
|
|
23989
|
-
//#endregion
|
|
23990
|
-
//#region src/infra/supervisor-markers.ts
|
|
23991
|
-
const SUPERVISOR_HINT_ENV_VARS = [
|
|
23992
|
-
"LAUNCH_JOB_LABEL",
|
|
23993
|
-
"LAUNCH_JOB_NAME",
|
|
23994
|
-
"OPENCLAW_LAUNCHD_LABEL",
|
|
23995
|
-
"OPENCLAW_SYSTEMD_UNIT",
|
|
23996
|
-
"OPENCLAW_SERVICE_MARKER",
|
|
23997
|
-
"INVOCATION_ID",
|
|
23998
|
-
"SYSTEMD_EXEC_PID",
|
|
23999
|
-
"JOURNAL_STREAM"
|
|
24000
|
-
];
|
|
24001
|
-
function hasSupervisorHint(env = process.env) {
|
|
24002
|
-
return SUPERVISOR_HINT_ENV_VARS.some((key) => {
|
|
24003
|
-
const value = env[key];
|
|
24004
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
24005
|
-
});
|
|
24006
|
-
}
|
|
24007
|
-
|
|
24008
|
-
//#endregion
|
|
24009
|
-
//#region src/infra/process-respawn.ts
|
|
24010
|
-
function isTruthy(value) {
|
|
24011
|
-
if (!value) return false;
|
|
24012
|
-
const normalized = value.trim().toLowerCase();
|
|
24013
|
-
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
24014
|
-
}
|
|
24015
|
-
function isLikelySupervisedProcess(env = process.env) {
|
|
24016
|
-
return hasSupervisorHint(env);
|
|
24017
|
-
}
|
|
24018
|
-
/**
|
|
24019
|
-
* Attempt to restart this process with a fresh PID.
|
|
24020
|
-
* - supervised environments (launchd/systemd): caller should exit and let supervisor restart
|
|
24021
|
-
* - OPENCLAW_NO_RESPAWN=1: caller should keep in-process restart behavior (tests/dev)
|
|
24022
|
-
* - otherwise: spawn detached child with current argv/execArgv, then caller exits
|
|
24023
|
-
*/
|
|
24024
|
-
function restartGatewayProcessWithFreshPid() {
|
|
24025
|
-
if (isTruthy(process.env.OPENCLAW_NO_RESPAWN)) return { mode: "disabled" };
|
|
24026
|
-
if (isLikelySupervisedProcess(process.env)) {
|
|
24027
|
-
if (process.platform === "darwin" && process.env.OPENCLAW_LAUNCHD_LABEL?.trim()) {
|
|
24028
|
-
const restart = triggerOpenClawRestart();
|
|
24029
|
-
if (!restart.ok) return {
|
|
24030
|
-
mode: "failed",
|
|
24031
|
-
detail: restart.detail ?? "launchctl kickstart failed"
|
|
24032
|
-
};
|
|
24033
|
-
}
|
|
24034
|
-
return { mode: "supervised" };
|
|
24035
|
-
}
|
|
24036
|
-
try {
|
|
24037
|
-
const args = [...process.execArgv, ...process.argv.slice(1)];
|
|
24038
|
-
const child = spawn(process.execPath, args, {
|
|
24039
|
-
env: process.env,
|
|
24040
|
-
detached: true,
|
|
24041
|
-
stdio: "inherit"
|
|
24042
|
-
});
|
|
24043
|
-
child.unref();
|
|
24044
|
-
return {
|
|
24045
|
-
mode: "spawned",
|
|
24046
|
-
pid: child.pid ?? void 0
|
|
24047
|
-
};
|
|
24048
|
-
} catch (err) {
|
|
24049
|
-
return {
|
|
24050
|
-
mode: "failed",
|
|
24051
|
-
detail: err instanceof Error ? err.message : String(err)
|
|
24052
|
-
};
|
|
24053
|
-
}
|
|
24054
|
-
}
|
|
24055
|
-
|
|
24056
|
-
//#endregion
|
|
24057
|
-
//#region src/process/restart-recovery.ts
|
|
24058
|
-
/**
|
|
24059
|
-
* Returns an iteration hook for in-process restart loops.
|
|
24060
|
-
* The first call is considered initial startup and does nothing.
|
|
24061
|
-
* Each subsequent call represents a restart iteration and invokes `onRestart`.
|
|
24062
|
-
*/
|
|
24063
|
-
function createRestartIterationHook(onRestart) {
|
|
24064
|
-
let isFirstIteration = true;
|
|
24065
|
-
return () => {
|
|
24066
|
-
if (isFirstIteration) {
|
|
24067
|
-
isFirstIteration = false;
|
|
24068
|
-
return false;
|
|
24069
|
-
}
|
|
24070
|
-
onRestart();
|
|
24071
|
-
return true;
|
|
24072
|
-
};
|
|
24073
|
-
}
|
|
24074
|
-
|
|
24075
|
-
//#endregion
|
|
24076
|
-
//#region src/cli/gateway-cli/run-loop.ts
|
|
24077
|
-
const gatewayLog$1 = createSubsystemLogger("gateway");
|
|
24078
|
-
async function runGatewayLoop(params) {
|
|
24079
|
-
let lock = await acquireGatewayLock({ port: params.lockPort });
|
|
24080
|
-
let server = null;
|
|
24081
|
-
let shuttingDown = false;
|
|
24082
|
-
let restartResolver = null;
|
|
24083
|
-
const cleanupSignals = () => {
|
|
24084
|
-
process.removeListener("SIGTERM", onSigterm);
|
|
24085
|
-
process.removeListener("SIGINT", onSigint);
|
|
24086
|
-
process.removeListener("SIGUSR1", onSigusr1);
|
|
24087
|
-
};
|
|
24088
|
-
const exitProcess = (code) => {
|
|
24089
|
-
cleanupSignals();
|
|
24090
|
-
params.runtime.exit(code);
|
|
24091
|
-
};
|
|
24092
|
-
const releaseLockIfHeld = async () => {
|
|
24093
|
-
if (!lock) return false;
|
|
24094
|
-
await lock.release();
|
|
24095
|
-
lock = null;
|
|
24096
|
-
return true;
|
|
24097
|
-
};
|
|
24098
|
-
const reacquireLockForInProcessRestart = async () => {
|
|
24099
|
-
try {
|
|
24100
|
-
lock = await acquireGatewayLock({ port: params.lockPort });
|
|
24101
|
-
return true;
|
|
24102
|
-
} catch (err) {
|
|
24103
|
-
gatewayLog$1.error(`failed to reacquire gateway lock for in-process restart: ${String(err)}`);
|
|
24104
|
-
exitProcess(1);
|
|
24105
|
-
return false;
|
|
24106
|
-
}
|
|
24107
|
-
};
|
|
24108
|
-
const handleRestartAfterServerClose = async () => {
|
|
24109
|
-
const hadLock = await releaseLockIfHeld();
|
|
24110
|
-
const respawn = restartGatewayProcessWithFreshPid();
|
|
24111
|
-
if (respawn.mode === "spawned" || respawn.mode === "supervised") {
|
|
24112
|
-
const modeLabel = respawn.mode === "spawned" ? `spawned pid ${respawn.pid ?? "unknown"}` : "supervisor restart";
|
|
24113
|
-
gatewayLog$1.info(`restart mode: full process restart (${modeLabel})`);
|
|
24114
|
-
exitProcess(0);
|
|
24115
|
-
return;
|
|
24116
|
-
}
|
|
24117
|
-
if (respawn.mode === "failed") gatewayLog$1.warn(`full process restart failed (${respawn.detail ?? "unknown error"}); falling back to in-process restart`);
|
|
24118
|
-
else gatewayLog$1.info("restart mode: in-process restart (OPENCLAW_NO_RESPAWN)");
|
|
24119
|
-
if (hadLock && !await reacquireLockForInProcessRestart()) return;
|
|
24120
|
-
shuttingDown = false;
|
|
24121
|
-
restartResolver?.();
|
|
24122
|
-
};
|
|
24123
|
-
const handleStopAfterServerClose = async () => {
|
|
24124
|
-
await releaseLockIfHeld();
|
|
24125
|
-
exitProcess(0);
|
|
24126
|
-
};
|
|
24127
|
-
const DRAIN_TIMEOUT_MS = 3e4;
|
|
24128
|
-
const SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
24129
|
-
const request = (action, signal) => {
|
|
24130
|
-
if (shuttingDown) {
|
|
24131
|
-
gatewayLog$1.info(`received ${signal} during shutdown; ignoring`);
|
|
24132
|
-
return;
|
|
24133
|
-
}
|
|
24134
|
-
shuttingDown = true;
|
|
24135
|
-
const isRestart = action === "restart";
|
|
24136
|
-
gatewayLog$1.info(`received ${signal}; ${isRestart ? "restarting" : "shutting down"}`);
|
|
24137
|
-
const forceExitMs = isRestart ? DRAIN_TIMEOUT_MS + SHUTDOWN_TIMEOUT_MS : SHUTDOWN_TIMEOUT_MS;
|
|
24138
|
-
const forceExitTimer = setTimeout(() => {
|
|
24139
|
-
gatewayLog$1.error("shutdown timed out; exiting without full cleanup");
|
|
24140
|
-
exitProcess(0);
|
|
24141
|
-
}, forceExitMs);
|
|
24142
|
-
(async () => {
|
|
24143
|
-
try {
|
|
24144
|
-
if (isRestart) {
|
|
24145
|
-
markGatewayDraining();
|
|
24146
|
-
const activeTasks = getActiveTaskCount();
|
|
24147
|
-
if (activeTasks > 0) {
|
|
24148
|
-
gatewayLog$1.info(`draining ${activeTasks} active task(s) before restart (timeout ${DRAIN_TIMEOUT_MS}ms)`);
|
|
24149
|
-
const { drained } = await waitForActiveTasks(DRAIN_TIMEOUT_MS);
|
|
24150
|
-
if (drained) gatewayLog$1.info("all active tasks drained");
|
|
24151
|
-
else gatewayLog$1.warn("drain timeout reached; proceeding with restart");
|
|
24152
|
-
}
|
|
24153
|
-
}
|
|
24154
|
-
await server?.close({
|
|
24155
|
-
reason: isRestart ? "gateway restarting" : "gateway stopping",
|
|
24156
|
-
restartExpectedMs: isRestart ? 1500 : null
|
|
24157
|
-
});
|
|
24158
|
-
} catch (err) {
|
|
24159
|
-
gatewayLog$1.error(`shutdown error: ${String(err)}`);
|
|
24160
|
-
} finally {
|
|
24161
|
-
clearTimeout(forceExitTimer);
|
|
24162
|
-
server = null;
|
|
24163
|
-
if (isRestart) await handleRestartAfterServerClose();
|
|
24164
|
-
else await handleStopAfterServerClose();
|
|
24165
|
-
}
|
|
24166
|
-
})();
|
|
24167
|
-
};
|
|
24168
|
-
const onSigterm = () => {
|
|
24169
|
-
gatewayLog$1.info("signal SIGTERM received");
|
|
24170
|
-
request("stop", "SIGTERM");
|
|
24171
|
-
};
|
|
24172
|
-
const onSigint = () => {
|
|
24173
|
-
gatewayLog$1.info("signal SIGINT received");
|
|
24174
|
-
request("stop", "SIGINT");
|
|
24175
|
-
};
|
|
24176
|
-
const onSigusr1 = () => {
|
|
24177
|
-
gatewayLog$1.info("signal SIGUSR1 received");
|
|
24178
|
-
if (!consumeGatewaySigusr1RestartAuthorization() && !isGatewaySigusr1RestartExternallyAllowed()) {
|
|
24179
|
-
gatewayLog$1.warn("SIGUSR1 restart ignored (not authorized; commands.restart=false or use gateway tool).");
|
|
24180
|
-
return;
|
|
24181
|
-
}
|
|
24182
|
-
markGatewaySigusr1RestartHandled();
|
|
24183
|
-
request("restart", "SIGUSR1");
|
|
24184
|
-
};
|
|
24185
|
-
process.on("SIGTERM", onSigterm);
|
|
24186
|
-
process.on("SIGINT", onSigint);
|
|
24187
|
-
process.on("SIGUSR1", onSigusr1);
|
|
24188
|
-
try {
|
|
24189
|
-
const onIteration = createRestartIterationHook(() => {
|
|
24190
|
-
resetAllLanes();
|
|
24191
|
-
});
|
|
24192
|
-
while (true) {
|
|
24193
|
-
onIteration();
|
|
24194
|
-
server = await params.start();
|
|
24195
|
-
await new Promise((resolve) => {
|
|
24196
|
-
restartResolver = resolve;
|
|
24197
|
-
});
|
|
24198
|
-
}
|
|
24199
|
-
} finally {
|
|
24200
|
-
await releaseLockIfHeld();
|
|
24201
|
-
cleanupSignals();
|
|
24202
|
-
}
|
|
24203
|
-
}
|
|
24204
|
-
|
|
24205
|
-
//#endregion
|
|
24206
|
-
//#region src/cli/gateway-cli/run.ts
|
|
24207
|
-
const gatewayLog = createSubsystemLogger("gateway");
|
|
24208
|
-
const GATEWAY_RUN_VALUE_KEYS = [
|
|
24209
|
-
"port",
|
|
24210
|
-
"bind",
|
|
24211
|
-
"token",
|
|
24212
|
-
"auth",
|
|
24213
|
-
"password",
|
|
24214
|
-
"tailscale",
|
|
24215
|
-
"wsLog",
|
|
24216
|
-
"rawStreamPath"
|
|
24217
|
-
];
|
|
24218
|
-
const GATEWAY_RUN_BOOLEAN_KEYS = [
|
|
24219
|
-
"tailscaleResetOnExit",
|
|
24220
|
-
"allowUnconfigured",
|
|
24221
|
-
"dev",
|
|
24222
|
-
"reset",
|
|
24223
|
-
"force",
|
|
24224
|
-
"verbose",
|
|
24225
|
-
"claudeCliLogs",
|
|
24226
|
-
"compact",
|
|
24227
|
-
"rawStream"
|
|
24228
|
-
];
|
|
24229
|
-
const GATEWAY_AUTH_MODES = [
|
|
24230
|
-
"none",
|
|
24231
|
-
"token",
|
|
24232
|
-
"password",
|
|
24233
|
-
"trusted-proxy"
|
|
24234
|
-
];
|
|
24235
|
-
const GATEWAY_TAILSCALE_MODES = [
|
|
24236
|
-
"off",
|
|
24237
|
-
"serve",
|
|
24238
|
-
"funnel"
|
|
24239
|
-
];
|
|
24240
|
-
function parseEnumOption(raw, allowed) {
|
|
24241
|
-
if (!raw) return null;
|
|
24242
|
-
return allowed.includes(raw) ? raw : null;
|
|
24243
|
-
}
|
|
24244
|
-
function formatModeChoices(modes) {
|
|
24245
|
-
return modes.map((mode) => `"${mode}"`).join("|");
|
|
24246
|
-
}
|
|
24247
|
-
function formatModeErrorList(modes) {
|
|
24248
|
-
const quoted = modes.map((mode) => `"${mode}"`);
|
|
24249
|
-
if (quoted.length === 0) return "";
|
|
24250
|
-
if (quoted.length === 1) return quoted[0];
|
|
24251
|
-
if (quoted.length === 2) return `${quoted[0]} or ${quoted[1]}`;
|
|
24252
|
-
return `${quoted.slice(0, -1).join(", ")}, or ${quoted[quoted.length - 1]}`;
|
|
24253
|
-
}
|
|
24254
|
-
function resolveGatewayRunOptions(opts, command) {
|
|
24255
|
-
const resolved = { ...opts };
|
|
24256
|
-
for (const key of GATEWAY_RUN_VALUE_KEYS) {
|
|
24257
|
-
const inherited = inheritOptionFromParent(command, key);
|
|
24258
|
-
if (key === "wsLog") {
|
|
24259
|
-
resolved[key] = inherited ?? resolved[key];
|
|
24260
|
-
continue;
|
|
24261
|
-
}
|
|
24262
|
-
resolved[key] = resolved[key] ?? inherited;
|
|
24263
|
-
}
|
|
24264
|
-
for (const key of GATEWAY_RUN_BOOLEAN_KEYS) {
|
|
24265
|
-
const inherited = inheritOptionFromParent(command, key);
|
|
24266
|
-
resolved[key] = Boolean(resolved[key] || inherited);
|
|
24267
|
-
}
|
|
24268
|
-
return resolved;
|
|
24269
|
-
}
|
|
24270
|
-
async function runGatewayCommand$1(opts) {
|
|
24271
|
-
const isDevProfile = process.env.OPENCLAW_PROFILE?.trim().toLowerCase() === "dev";
|
|
24272
|
-
const devMode = Boolean(opts.dev) || isDevProfile;
|
|
24273
|
-
if (opts.reset && !devMode) {
|
|
24274
|
-
defaultRuntime.error("Use --reset with --dev.");
|
|
24275
|
-
defaultRuntime.exit(1);
|
|
24276
|
-
return;
|
|
24277
|
-
}
|
|
24278
|
-
setConsoleTimestampPrefix(true);
|
|
24279
|
-
setVerbose(Boolean(opts.verbose));
|
|
24280
|
-
if (opts.claudeCliLogs) {
|
|
24281
|
-
setConsoleSubsystemFilter(["agent/claude-cli"]);
|
|
24282
|
-
process.env.OPENCLAW_CLAUDE_CLI_LOG_OUTPUT = "1";
|
|
24283
|
-
}
|
|
24284
|
-
const wsLogRaw = opts.compact ? "compact" : opts.wsLog;
|
|
24285
|
-
const wsLogStyle = wsLogRaw === "compact" ? "compact" : wsLogRaw === "full" ? "full" : "auto";
|
|
24286
|
-
if (wsLogRaw !== void 0 && wsLogRaw !== "auto" && wsLogRaw !== "compact" && wsLogRaw !== "full") {
|
|
24287
|
-
defaultRuntime.error("Invalid --ws-log (use \"auto\", \"full\", \"compact\")");
|
|
24288
|
-
defaultRuntime.exit(1);
|
|
24289
|
-
}
|
|
24290
|
-
setGatewayWsLogStyle(wsLogStyle);
|
|
24291
|
-
if (opts.rawStream) process.env.OPENCLAW_RAW_STREAM = "1";
|
|
24292
|
-
const rawStreamPath = toOptionString(opts.rawStreamPath);
|
|
24293
|
-
if (rawStreamPath) process.env.OPENCLAW_RAW_STREAM_PATH = rawStreamPath;
|
|
24294
|
-
if (devMode) await ensureDevGatewayConfig({ reset: Boolean(opts.reset) });
|
|
24295
|
-
const cfg = loadConfig();
|
|
24296
|
-
const portOverride = parsePort$1(opts.port);
|
|
24297
|
-
if (opts.port !== void 0 && portOverride === null) {
|
|
24298
|
-
defaultRuntime.error("Invalid port");
|
|
24299
|
-
defaultRuntime.exit(1);
|
|
24300
|
-
}
|
|
24301
|
-
const port = portOverride ?? resolveGatewayPort(cfg);
|
|
24302
|
-
if (!Number.isFinite(port) || port <= 0) {
|
|
24303
|
-
defaultRuntime.error("Invalid port");
|
|
24304
|
-
defaultRuntime.exit(1);
|
|
24305
|
-
}
|
|
24306
|
-
const bindRaw = toOptionString(opts.bind) ?? cfg.gateway?.bind ?? "loopback";
|
|
24307
|
-
const bind = bindRaw === "loopback" || bindRaw === "lan" || bindRaw === "auto" || bindRaw === "custom" || bindRaw === "tailnet" ? bindRaw : null;
|
|
24308
|
-
if (!bind) {
|
|
24309
|
-
defaultRuntime.error("Invalid --bind (use \"loopback\", \"lan\", \"tailnet\", \"auto\", or \"custom\")");
|
|
24310
|
-
defaultRuntime.exit(1);
|
|
24311
|
-
return;
|
|
24312
|
-
}
|
|
24313
|
-
if (opts.force) try {
|
|
24314
|
-
const { killed, waitedMs, escalatedToSigkill } = await forceFreePortAndWait(port, {
|
|
24315
|
-
timeoutMs: 2e3,
|
|
24316
|
-
intervalMs: 100,
|
|
24317
|
-
sigtermTimeoutMs: 700
|
|
24318
|
-
});
|
|
24319
|
-
if (killed.length === 0) gatewayLog.info(`force: no listeners on port ${port}`);
|
|
24320
|
-
else {
|
|
24321
|
-
for (const proc of killed) gatewayLog.info(`force: killed pid ${proc.pid}${proc.command ? ` (${proc.command})` : ""} on port ${port}`);
|
|
24322
|
-
if (escalatedToSigkill) gatewayLog.info(`force: escalated to SIGKILL while freeing port ${port}`);
|
|
24323
|
-
if (waitedMs > 0) gatewayLog.info(`force: waited ${waitedMs}ms for port ${port} to free`);
|
|
24324
|
-
}
|
|
24325
|
-
const bindWaitMs = await waitForPortBindable(port, {
|
|
24326
|
-
timeoutMs: 3e3,
|
|
24327
|
-
intervalMs: 150,
|
|
24328
|
-
host: bind === "loopback" ? "127.0.0.1" : bind === "lan" ? "0.0.0.0" : bind === "custom" ? toOptionString(cfg.gateway?.customBindHost) : void 0
|
|
24329
|
-
});
|
|
24330
|
-
if (bindWaitMs > 0) gatewayLog.info(`force: waited ${bindWaitMs}ms for port ${port} to become bindable`);
|
|
24331
|
-
} catch (err) {
|
|
24332
|
-
defaultRuntime.error(`Force: ${String(err)}`);
|
|
24333
|
-
defaultRuntime.exit(1);
|
|
24334
|
-
return;
|
|
24335
|
-
}
|
|
24336
|
-
if (opts.token) {
|
|
24337
|
-
const token = toOptionString(opts.token);
|
|
24338
|
-
if (token) process.env.OPENCLAW_GATEWAY_TOKEN = token;
|
|
24339
|
-
}
|
|
24340
|
-
const authModeRaw = toOptionString(opts.auth);
|
|
24341
|
-
const authMode = parseEnumOption(authModeRaw, GATEWAY_AUTH_MODES);
|
|
24342
|
-
if (authModeRaw && !authMode) {
|
|
24343
|
-
defaultRuntime.error(`Invalid --auth (use ${formatModeErrorList(GATEWAY_AUTH_MODES)})`);
|
|
24344
|
-
defaultRuntime.exit(1);
|
|
24345
|
-
return;
|
|
24346
|
-
}
|
|
24347
|
-
const tailscaleRaw = toOptionString(opts.tailscale);
|
|
24348
|
-
const tailscaleMode = parseEnumOption(tailscaleRaw, GATEWAY_TAILSCALE_MODES);
|
|
24349
|
-
if (tailscaleRaw && !tailscaleMode) {
|
|
24350
|
-
defaultRuntime.error(`Invalid --tailscale (use ${formatModeErrorList(GATEWAY_TAILSCALE_MODES)})`);
|
|
24351
|
-
defaultRuntime.exit(1);
|
|
24352
|
-
return;
|
|
24353
|
-
}
|
|
24354
|
-
const passwordRaw = toOptionString(opts.password);
|
|
24355
|
-
const tokenRaw = toOptionString(opts.token);
|
|
24356
|
-
const snapshot = await readConfigFileSnapshot().catch(() => null);
|
|
24357
|
-
const configExists = snapshot?.exists ?? fs.existsSync(CONFIG_PATH);
|
|
24358
|
-
const configAuditPath = path.join(resolveStateDir(process.env), "logs", "config-audit.jsonl");
|
|
24359
|
-
const mode = cfg.gateway?.mode;
|
|
24360
|
-
if (!opts.allowUnconfigured && mode !== "local") {
|
|
24361
|
-
if (!configExists) defaultRuntime.error(`Missing config. Run \`${formatCliCommand("openclaw setup")}\` or set gateway.mode=local (or pass --allow-unconfigured).`);
|
|
24362
|
-
else {
|
|
24363
|
-
defaultRuntime.error(`Gateway start blocked: set gateway.mode=local (current: ${mode ?? "unset"}) or pass --allow-unconfigured.`);
|
|
24364
|
-
defaultRuntime.error(`Config write audit: ${configAuditPath}`);
|
|
24365
|
-
}
|
|
24366
|
-
defaultRuntime.exit(1);
|
|
24367
|
-
return;
|
|
24368
|
-
}
|
|
24369
|
-
const miskeys = extractGatewayMiskeys(snapshot?.parsed);
|
|
24370
|
-
const authOverride = authMode || passwordRaw || tokenRaw || authModeRaw ? {
|
|
24371
|
-
...authMode ? { mode: authMode } : {},
|
|
24372
|
-
...tokenRaw ? { token: tokenRaw } : {},
|
|
24373
|
-
...passwordRaw ? { password: passwordRaw } : {}
|
|
24374
|
-
} : void 0;
|
|
24375
|
-
const resolvedAuth = resolveGatewayAuth({
|
|
24376
|
-
authConfig: cfg.gateway?.auth,
|
|
24377
|
-
authOverride,
|
|
24378
|
-
env: process.env,
|
|
24379
|
-
tailscaleMode: tailscaleMode ?? cfg.gateway?.tailscale?.mode ?? "off"
|
|
24380
|
-
});
|
|
24381
|
-
const resolvedAuthMode = resolvedAuth.mode;
|
|
24382
|
-
const tokenValue = resolvedAuth.token;
|
|
24383
|
-
const passwordValue = resolvedAuth.password;
|
|
24384
|
-
const hasToken = typeof tokenValue === "string" && tokenValue.trim().length > 0;
|
|
24385
|
-
const hasPassword = typeof passwordValue === "string" && passwordValue.trim().length > 0;
|
|
24386
|
-
const tokenConfigured = hasToken || hasConfiguredSecretInput(authOverride?.token ?? cfg.gateway?.auth?.token, cfg.secrets?.defaults);
|
|
24387
|
-
const passwordConfigured = hasPassword || hasConfiguredSecretInput(authOverride?.password ?? cfg.gateway?.auth?.password, cfg.secrets?.defaults);
|
|
24388
|
-
const hasSharedSecret = resolvedAuthMode === "token" && tokenConfigured || resolvedAuthMode === "password" && passwordConfigured;
|
|
24389
|
-
const canBootstrapToken = resolvedAuthMode === "token" && !tokenConfigured;
|
|
24390
|
-
const authHints = [];
|
|
24391
|
-
if (miskeys.hasGatewayToken) authHints.push("Found \"gateway.token\" in config. Use \"gateway.auth.token\" instead.");
|
|
24392
|
-
if (miskeys.hasRemoteToken) authHints.push("\"gateway.remote.token\" is for remote CLI calls; it does not enable local gateway auth.");
|
|
24393
|
-
if (resolvedAuthMode === "password" && !passwordConfigured) {
|
|
24394
|
-
defaultRuntime.error([
|
|
24395
|
-
"Gateway auth is set to password, but no password is configured.",
|
|
24396
|
-
"Set gateway.auth.password (or OPENCLAW_GATEWAY_PASSWORD), or pass --password.",
|
|
24397
|
-
...authHints
|
|
24398
|
-
].filter(Boolean).join("\n"));
|
|
24399
|
-
defaultRuntime.exit(1);
|
|
24400
|
-
return;
|
|
24401
|
-
}
|
|
24402
|
-
if (resolvedAuthMode === "none") gatewayLog.warn("Gateway auth mode=none explicitly configured; all gateway connections are unauthenticated.");
|
|
24403
|
-
if (bind !== "loopback" && !hasSharedSecret && !canBootstrapToken && resolvedAuthMode !== "trusted-proxy" && resolvedAuthMode !== "iam") {
|
|
24404
|
-
defaultRuntime.error([
|
|
24405
|
-
`Refusing to bind gateway to ${bind} without auth.`,
|
|
24406
|
-
"Set gateway.auth.token/password (or OPENCLAW_GATEWAY_TOKEN/OPENCLAW_GATEWAY_PASSWORD) or pass --token/--password.",
|
|
24407
|
-
...authHints
|
|
24408
|
-
].filter(Boolean).join("\n"));
|
|
24409
|
-
defaultRuntime.exit(1);
|
|
24410
|
-
return;
|
|
24411
|
-
}
|
|
24412
|
-
const tailscaleOverride = tailscaleMode || opts.tailscaleResetOnExit ? {
|
|
24413
|
-
...tailscaleMode ? { mode: tailscaleMode } : {},
|
|
24414
|
-
...opts.tailscaleResetOnExit ? { resetOnExit: true } : {}
|
|
24415
|
-
} : void 0;
|
|
24416
|
-
try {
|
|
24417
|
-
await runGatewayLoop({
|
|
24418
|
-
runtime: defaultRuntime,
|
|
24419
|
-
lockPort: port,
|
|
24420
|
-
start: async () => await startGatewayServer(port, {
|
|
24421
|
-
bind,
|
|
24422
|
-
auth: authOverride,
|
|
24423
|
-
tailscale: tailscaleOverride
|
|
24424
|
-
})
|
|
24425
|
-
});
|
|
24426
|
-
} catch (err) {
|
|
24427
|
-
if (err instanceof GatewayLockError || err && typeof err === "object" && err.name === "GatewayLockError") {
|
|
24428
|
-
const errMessage = describeUnknownError(err);
|
|
24429
|
-
defaultRuntime.error(`Gateway failed to start: ${errMessage}\nIf the gateway is supervised, stop it with: ${formatCliCommand("openclaw gateway stop")}`);
|
|
24430
|
-
try {
|
|
24431
|
-
const diagnostics = await inspectPortUsage(port);
|
|
24432
|
-
if (diagnostics.status === "busy") for (const line of formatPortDiagnostics(diagnostics)) defaultRuntime.error(line);
|
|
24433
|
-
} catch {}
|
|
24434
|
-
await maybeExplainGatewayServiceStop();
|
|
24435
|
-
defaultRuntime.exit(1);
|
|
24436
|
-
return;
|
|
24437
|
-
}
|
|
24438
|
-
defaultRuntime.error(`Gateway failed to start: ${String(err)}`);
|
|
24439
|
-
defaultRuntime.exit(1);
|
|
24440
|
-
}
|
|
24441
|
-
}
|
|
24442
|
-
function addGatewayRunCommand(cmd) {
|
|
24443
|
-
return cmd.option("--port <port>", "Port for the gateway WebSocket").option("--bind <mode>", "Bind mode (\"loopback\"|\"lan\"|\"tailnet\"|\"auto\"|\"custom\"). Defaults to config gateway.bind (or loopback).").option("--token <token>", "Shared token required in connect.params.auth.token (default: OPENCLAW_GATEWAY_TOKEN env if set)").option("--auth <mode>", `Gateway auth mode (${formatModeChoices(GATEWAY_AUTH_MODES)})`).option("--password <password>", "Password for auth mode=password").option("--tailscale <mode>", `Tailscale exposure mode (${formatModeChoices(GATEWAY_TAILSCALE_MODES)})`).option("--tailscale-reset-on-exit", "Reset Tailscale serve/funnel configuration on shutdown", false).option("--allow-unconfigured", "Allow gateway start without gateway.mode=local in config", false).option("--dev", "Create a dev config + workspace if missing (no BOOTSTRAP.md)", false).option("--reset", "Reset dev config + credentials + sessions + workspace (requires --dev)", false).option("--force", "Kill any existing listener on the target port before starting", false).option("--verbose", "Verbose logging to stdout/stderr", false).option("--claude-cli-logs", "Only show claude-cli logs in the console (includes stdout/stderr)", false).option("--ws-log <style>", "WebSocket log style (\"auto\"|\"full\"|\"compact\")", "auto").option("--compact", "Alias for \"--ws-log compact\"", false).option("--raw-stream", "Log raw model stream events to jsonl", false).option("--raw-stream-path <path>", "Raw stream jsonl path").action(async (opts, command) => {
|
|
24444
|
-
await runGatewayCommand$1(resolveGatewayRunOptions(opts, command));
|
|
24445
|
-
});
|
|
24446
|
-
}
|
|
24447
|
-
|
|
24448
|
-
//#endregion
|
|
24449
|
-
//#region src/cli/gateway-cli/register.ts
|
|
24450
|
-
function runGatewayCommand(action, label) {
|
|
24451
|
-
return runCommandWithRuntime(defaultRuntime, action, (err) => {
|
|
24452
|
-
const message = String(err);
|
|
24453
|
-
defaultRuntime.error(label ? `${label}: ${message}` : message);
|
|
24454
|
-
defaultRuntime.exit(1);
|
|
24455
|
-
});
|
|
24456
|
-
}
|
|
24457
|
-
function parseDaysOption(raw, fallback = 30) {
|
|
24458
|
-
if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
|
|
24459
|
-
if (typeof raw === "string" && raw.trim() !== "") {
|
|
24460
|
-
const parsed = Number(raw);
|
|
24461
|
-
if (Number.isFinite(parsed)) return Math.max(1, Math.floor(parsed));
|
|
24462
|
-
}
|
|
24463
|
-
return fallback;
|
|
24464
|
-
}
|
|
24465
|
-
function resolveGatewayRpcOptions(opts, command) {
|
|
24466
|
-
const parentToken = inheritOptionFromParent(command, "token");
|
|
24467
|
-
const parentPassword = inheritOptionFromParent(command, "password");
|
|
24468
|
-
return {
|
|
24469
|
-
...opts,
|
|
24470
|
-
token: opts.token ?? parentToken,
|
|
24471
|
-
password: opts.password ?? parentPassword
|
|
24472
|
-
};
|
|
24473
|
-
}
|
|
24474
|
-
function renderCostUsageSummary(summary, days, rich) {
|
|
24475
|
-
const totalCost = formatUsd(summary.totals.totalCost) ?? "$0.00";
|
|
24476
|
-
const totalTokens = formatTokenCount(summary.totals.totalTokens) ?? "0";
|
|
24477
|
-
const lines = [colorize(rich, theme.heading, `Usage cost (${days} days)`), `${colorize(rich, theme.muted, "Total:")} ${totalCost} · ${totalTokens} tokens`];
|
|
24478
|
-
if (summary.totals.missingCostEntries > 0) lines.push(`${colorize(rich, theme.muted, "Missing entries:")} ${summary.totals.missingCostEntries}`);
|
|
24479
|
-
const latest = summary.daily.at(-1);
|
|
24480
|
-
if (latest) {
|
|
24481
|
-
const latestCost = formatUsd(latest.totalCost) ?? "$0.00";
|
|
24482
|
-
const latestTokens = formatTokenCount(latest.totalTokens) ?? "0";
|
|
24483
|
-
lines.push(`${colorize(rich, theme.muted, "Latest day:")} ${latest.date} · ${latestCost} · ${latestTokens} tokens`);
|
|
24484
|
-
}
|
|
24485
|
-
return lines;
|
|
24486
|
-
}
|
|
24487
|
-
function registerGatewayCli(program) {
|
|
24488
|
-
const gateway = addGatewayRunCommand(program.command("gateway").description("Run, inspect, and query the WebSocket Gateway").addHelpText("after", () => `\n${theme.heading("Examples:")}\n${formatHelpExamples([
|
|
24489
|
-
["openclaw gateway run", "Run the gateway in the foreground."],
|
|
24490
|
-
["openclaw gateway status", "Show service status and probe reachability."],
|
|
24491
|
-
["openclaw gateway discover", "Find local and wide-area gateway beacons."],
|
|
24492
|
-
["openclaw gateway call health", "Call a gateway RPC method directly."]
|
|
24493
|
-
])}\n\n${theme.muted("Docs:")} ${formatDocsLink("/cli/gateway", "docs.openclaw.ai/cli/gateway")}\n`));
|
|
24494
|
-
addGatewayRunCommand(gateway.command("run").description("Run the WebSocket Gateway (foreground)"));
|
|
24495
|
-
addGatewayServiceCommands(gateway, { statusDescription: "Show gateway service status + probe the Gateway" });
|
|
24496
|
-
gatewayCallOpts(gateway.command("call").description("Call a Gateway method").argument("<method>", "Method name (health/status/system-presence/cron.*)").option("--params <json>", "JSON object string for params", "{}").action(async (method, opts, command) => {
|
|
24497
|
-
await runGatewayCommand(async () => {
|
|
24498
|
-
const rpcOpts = resolveGatewayRpcOptions(opts, command);
|
|
24499
|
-
const result = await callGatewayCli(method, rpcOpts, JSON.parse(String(opts.params ?? "{}")));
|
|
24500
|
-
if (rpcOpts.json) {
|
|
24501
|
-
defaultRuntime.log(JSON.stringify(result, null, 2));
|
|
24502
|
-
return;
|
|
24503
|
-
}
|
|
24504
|
-
const rich = isRich();
|
|
24505
|
-
defaultRuntime.log(`${colorize(rich, theme.heading, "Gateway call")}: ${colorize(rich, theme.muted, String(method))}`);
|
|
24506
|
-
defaultRuntime.log(JSON.stringify(result, null, 2));
|
|
24507
|
-
}, "Gateway call failed");
|
|
24508
|
-
}));
|
|
24509
|
-
gatewayCallOpts(gateway.command("usage-cost").description("Fetch usage cost summary from session logs").option("--days <days>", "Number of days to include", "30").action(async (opts, command) => {
|
|
24510
|
-
await runGatewayCommand(async () => {
|
|
24511
|
-
const rpcOpts = resolveGatewayRpcOptions(opts, command);
|
|
24512
|
-
const days = parseDaysOption(opts.days);
|
|
24513
|
-
const result = await callGatewayCli("usage.cost", rpcOpts, { days });
|
|
24514
|
-
if (rpcOpts.json) {
|
|
24515
|
-
defaultRuntime.log(JSON.stringify(result, null, 2));
|
|
24516
|
-
return;
|
|
24517
|
-
}
|
|
24518
|
-
const rich = isRich();
|
|
24519
|
-
const summary = result;
|
|
24520
|
-
for (const line of renderCostUsageSummary(summary, days, rich)) defaultRuntime.log(line);
|
|
24521
|
-
}, "Gateway usage cost failed");
|
|
24522
|
-
}));
|
|
24523
|
-
gatewayCallOpts(gateway.command("health").description("Fetch Gateway health").action(async (opts, command) => {
|
|
24524
|
-
await runGatewayCommand(async () => {
|
|
24525
|
-
const rpcOpts = resolveGatewayRpcOptions(opts, command);
|
|
24526
|
-
const result = await callGatewayCli("health", rpcOpts);
|
|
24527
|
-
if (rpcOpts.json) {
|
|
24528
|
-
defaultRuntime.log(JSON.stringify(result, null, 2));
|
|
24529
|
-
return;
|
|
24530
|
-
}
|
|
24531
|
-
const rich = isRich();
|
|
24532
|
-
const obj = result && typeof result === "object" ? result : {};
|
|
24533
|
-
const durationMs = typeof obj.durationMs === "number" ? obj.durationMs : null;
|
|
24534
|
-
defaultRuntime.log(colorize(rich, theme.heading, "Gateway Health"));
|
|
24535
|
-
defaultRuntime.log(`${colorize(rich, theme.success, "OK")}${durationMs != null ? ` (${durationMs}ms)` : ""}`);
|
|
24536
|
-
if (obj.channels && typeof obj.channels === "object") for (const line of formatHealthChannelLines(obj)) defaultRuntime.log(styleHealthChannelLine(line, rich));
|
|
24537
|
-
});
|
|
24538
|
-
}));
|
|
24539
|
-
gateway.command("probe").description("Show gateway reachability + discovery + health + status summary (local + remote)").option("--url <url>", "Explicit Gateway WebSocket URL (still probes localhost)").option("--ssh <target>", "SSH target for remote gateway tunnel (user@host or user@host:port)").option("--ssh-identity <path>", "SSH identity file path").option("--ssh-auto", "Try to derive an SSH target from Bonjour discovery", false).option("--token <token>", "Gateway token (applies to all probes)").option("--password <password>", "Gateway password (applies to all probes)").option("--timeout <ms>", "Overall probe budget in ms", "3000").option("--json", "Output JSON", false).action(async (opts, command) => {
|
|
24540
|
-
await runGatewayCommand(async () => {
|
|
24541
|
-
await gatewayStatusCommand(resolveGatewayRpcOptions(opts, command), defaultRuntime);
|
|
24542
|
-
});
|
|
24543
|
-
});
|
|
24544
|
-
gateway.command("discover").description("Discover gateways via Bonjour (local + wide-area if configured)").option("--timeout <ms>", "Per-command timeout in ms", "2000").option("--json", "Output JSON", false).action(async (opts) => {
|
|
24545
|
-
await runGatewayCommand(async () => {
|
|
24546
|
-
const wideAreaDomain = resolveWideAreaDiscoveryDomain({ configDomain: loadConfig().discovery?.wideArea?.domain });
|
|
24547
|
-
const timeoutMs = parseDiscoverTimeoutMs(opts.timeout, 2e3);
|
|
24548
|
-
const domains = ["local.", ...wideAreaDomain ? [wideAreaDomain] : []];
|
|
24549
|
-
const deduped = dedupeBeacons(await withProgress({
|
|
24550
|
-
label: "Scanning for gateways…",
|
|
24551
|
-
indeterminate: true,
|
|
24552
|
-
enabled: opts.json !== true,
|
|
24553
|
-
delayMs: 0
|
|
24554
|
-
}, async () => await discoverGatewayBeacons({
|
|
24555
|
-
timeoutMs,
|
|
24556
|
-
wideAreaDomain
|
|
24557
|
-
}))).toSorted((a, b) => String(a.displayName || a.instanceName).localeCompare(String(b.displayName || b.instanceName)));
|
|
24558
|
-
if (opts.json) {
|
|
24559
|
-
const enriched = deduped.map((b) => {
|
|
24560
|
-
const host = pickBeaconHost(b);
|
|
24561
|
-
const port = pickGatewayPort(b);
|
|
24562
|
-
return {
|
|
24563
|
-
...b,
|
|
24564
|
-
wsUrl: host ? `ws://${host}:${port}` : null
|
|
24565
|
-
};
|
|
24566
|
-
});
|
|
24567
|
-
defaultRuntime.log(JSON.stringify({
|
|
24568
|
-
timeoutMs,
|
|
24569
|
-
domains,
|
|
24570
|
-
count: enriched.length,
|
|
24571
|
-
beacons: enriched
|
|
24572
|
-
}, null, 2));
|
|
24573
|
-
return;
|
|
24574
|
-
}
|
|
24575
|
-
const rich = isRich();
|
|
24576
|
-
defaultRuntime.log(colorize(rich, theme.heading, "Gateway Discovery"));
|
|
24577
|
-
defaultRuntime.log(colorize(rich, theme.muted, `Found ${deduped.length} gateway(s) · domains: ${domains.join(", ")}`));
|
|
24578
|
-
if (deduped.length === 0) return;
|
|
24579
|
-
for (const beacon of deduped) for (const line of renderBeaconLines(beacon, rich)) defaultRuntime.log(line);
|
|
24580
|
-
}, "gateway discover failed");
|
|
24581
|
-
});
|
|
24582
|
-
}
|
|
22864
|
+
//#region src/gateway/server.ts
|
|
22865
|
+
var server_exports = /* @__PURE__ */ __exportAll({
|
|
22866
|
+
__resetModelCatalogCacheForTest: () => __resetModelCatalogCacheForTest,
|
|
22867
|
+
startGatewayServer: () => startGatewayServer,
|
|
22868
|
+
truncateCloseReason: () => truncateCloseReason
|
|
22869
|
+
});
|
|
24583
22870
|
|
|
24584
22871
|
//#endregion
|
|
24585
|
-
export {
|
|
22872
|
+
export { startGatewayServer as n, server_exports as t };
|