@captain-app/openclaw 2026.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1528 -0
- package/LICENSE +21 -0
- package/README-header.png +0 -0
- package/README.md +539 -0
- package/assets/avatar-placeholder.svg +19 -0
- package/assets/chrome-extension/README.md +22 -0
- package/assets/chrome-extension/background.js +438 -0
- package/assets/chrome-extension/icons/icon128.png +0 -0
- package/assets/chrome-extension/icons/icon16.png +0 -0
- package/assets/chrome-extension/icons/icon32.png +0 -0
- package/assets/chrome-extension/icons/icon48.png +0 -0
- package/assets/chrome-extension/manifest.json +25 -0
- package/assets/chrome-extension/options.html +196 -0
- package/assets/chrome-extension/options.js +59 -0
- package/assets/dmg-background-small.png +0 -0
- package/assets/dmg-background.png +0 -0
- package/dist/accounts-ClnuDahN.js +250 -0
- package/dist/accounts-DzBgAM3C.js +251 -0
- package/dist/acp-cli-BEDDkzXH.js +926 -0
- package/dist/acp-cli-CwV4mdnW.js +923 -0
- package/dist/agent-CArjbSeE.js +695 -0
- package/dist/agent-CB7x5HLT.js +695 -0
- package/dist/agent-scope-BbT4OG2N.js +545 -0
- package/dist/agent-scope-C_O6Vpl0.js +545 -0
- package/dist/agent-scope-Csu2B6AM.js +606 -0
- package/dist/archive-CWrnG1CH.js +85 -0
- package/dist/archive-ccN9aDgq.js +85 -0
- package/dist/audit-DXPkQ275.js +1686 -0
- package/dist/audit-eH7nwgsM.js +1686 -0
- package/dist/auth-health-Bj7Gjbv0.js +149 -0
- package/dist/auth-health-CjjJhHey.js +149 -0
- package/dist/auth-nnRYiqpH.js +192 -0
- package/dist/auth-profiles-DVLfuixr.js +2954 -0
- package/dist/auth-y1BLPUhX.js +192 -0
- package/dist/boolean-Wzu0-e0P.js +30 -0
- package/dist/brew-Cqi8b49_.js +46 -0
- package/dist/brew-DyBGNK8A.js +46 -0
- package/dist/build-info.json +5 -0
- package/dist/call-B7EveN4V.js +252 -0
- package/dist/call-vuUQIjOj.js +252 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -0
- package/dist/canvas-host/a2ui/a2ui.bundle.js +17780 -0
- package/dist/canvas-host/a2ui/index.html +307 -0
- package/dist/channel-options-CJfmOkol.js +32 -0
- package/dist/channel-options-lFguMTz1.js +62 -0
- package/dist/channel-selection-BmND9mWj.js +51 -0
- package/dist/channel-selection-cGhL9G0c.js +51 -0
- package/dist/channel-summary-B4G513Eb.js +1154 -0
- package/dist/channel-summary-MCwBCa5y.js +1154 -0
- package/dist/channels-cli-C2Of1mZG.js +1411 -0
- package/dist/channels-cli-DFynrP1H.js +1413 -0
- package/dist/channels-status-issues-YohTjZ-I.js +18 -0
- package/dist/channels-status-issues-ZcR1U-m5.js +18 -0
- package/dist/chrome-B3IuUad-.js +1953 -0
- package/dist/chrome-BZ9K48w9.js +1973 -0
- package/dist/clack-prompter-B9yLhyOm.js +92 -0
- package/dist/clack-prompter-BybM9xdL.js +92 -0
- package/dist/cli/daemon-cli.js +2 -0
- package/dist/cli-BJZdJwug.js +89 -0
- package/dist/cli-BQSoKu3d.js +86 -0
- package/dist/cli-utils-CO4jEMn0.js +43 -0
- package/dist/cli-utils-gtE-0a0D.js +43 -0
- package/dist/client-DPqNOpK3.js +1609 -0
- package/dist/client-DySXIFCA.js +1609 -0
- package/dist/command-format-CFzL448l.js +52 -0
- package/dist/command-format-DELazozB.js +52 -0
- package/dist/command-format-ayFsmwwz.js +38 -0
- package/dist/command-options-CsjxK4cZ.js +33 -0
- package/dist/commands-BRe9VTyU.js +229 -0
- package/dist/completion-cli-DlkjK0iC.js +390 -0
- package/dist/completion-cli-E6Pt41AL.js +387 -0
- package/dist/config-BtSTwPcH.js +4882 -0
- package/dist/config-DfMIMT-f.js +4881 -0
- package/dist/config-_d7_WcRv.js +5623 -0
- package/dist/config-guard-wSnm-U8a.js +5628 -0
- package/dist/configure-CPHAFKlg.js +895 -0
- package/dist/configure-DK1XgXYx.js +894 -0
- package/dist/constants-CNTiY-ZN.js +65 -0
- package/dist/constants-hpmbslG7.js +65 -0
- package/dist/control-service-CqX5g_ko.js +61 -0
- package/dist/control-service-o6xe3hEb.js +61 -0
- package/dist/control-ui/apple-touch-icon.png +0 -0
- package/dist/control-ui/assets/index-RwcW4Xl0.css +1 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js +4584 -0
- package/dist/control-ui/assets/index-ryaCcbyp.js.map +1 -0
- package/dist/control-ui/favicon-32.png +0 -0
- package/dist/control-ui/favicon.ico +0 -0
- package/dist/control-ui/favicon.svg +22 -0
- package/dist/control-ui/index.html +17 -0
- package/dist/cron-cli-BoSaDgvH.js +453 -0
- package/dist/cron-cli-qVandvsD.js +456 -0
- package/dist/daemon-cli-C4gGWa15.js +760 -0
- package/dist/daemon-cli-DV_X0Krf.js +761 -0
- package/dist/daemon-runtime-D5hbSrdO.js +460 -0
- package/dist/daemon-runtime-DXUfrXBC.js +460 -0
- package/dist/deliver-BxK5nI2P.js +2587 -0
- package/dist/deliver-Dwzg9LUd.js +2557 -0
- package/dist/deliver-qpYZp20m.js +2587 -0
- package/dist/deps-CUXtMV9d.js +27 -0
- package/dist/deps-WBvZpFV_.js +27 -0
- package/dist/devices-cli-B2s18Qrh.js +207 -0
- package/dist/devices-cli-D1UEtMUJ.js +204 -0
- package/dist/directory-cli-BXQbrkfM.js +247 -0
- package/dist/directory-cli-CqA7tRbq.js +244 -0
- package/dist/dispatcher-Dyv7T-1r.js +160 -0
- package/dist/dns-cli-CWxKD22D.js +198 -0
- package/dist/dns-cli-CzKr_Fxj.js +201 -0
- package/dist/docs-cli-BNyxUbWr.js +159 -0
- package/dist/docs-cli-DYpTbo3i.js +161 -0
- package/dist/doctor-C8fDYZLq.js +2583 -0
- package/dist/doctor-hYcqp7c0.js +2585 -0
- package/dist/entry.js +1326 -0
- package/dist/env-l7QVNj6j.js +32 -0
- package/dist/errors-CMCg46fK.js +1952 -0
- package/dist/exec-B8JKbXKW.js +246 -0
- package/dist/exec-BMnoMcZW.js +1099 -0
- package/dist/exec-HEWTMJ7j.js +246 -0
- package/dist/exec-approvals-DtrnHx6M.js +1026 -0
- package/dist/exec-approvals-Y42bE8ud.js +1026 -0
- package/dist/exec-approvals-cli-CIedYxP3.js +385 -0
- package/dist/exec-approvals-cli-xpbxnj4O.js +388 -0
- package/dist/extensionAPI.js +66572 -0
- package/dist/format-Dzy9uRLE.js +34 -0
- package/dist/format-sj0fELBK.js +34 -0
- package/dist/gateway-cli-5A-KNLEC.js +16635 -0
- package/dist/gateway-cli-B8kS4chb.js +16637 -0
- package/dist/gateway-rpc-15n38Ize.js +28 -0
- package/dist/gateway-rpc-TMVRgGfj.js +28 -0
- package/dist/github-copilot-auth-DVZj4Zgh.js +1104 -0
- package/dist/github-copilot-auth-DeGYyLY9.js +1104 -0
- package/dist/github-copilot-token-B3SA95yo.js +103 -0
- package/dist/github-copilot-token-C8XFYz0i.js +103 -0
- package/dist/github-copilot-token-CnxakiSC.js +103 -0
- package/dist/gmail-setup-utils-CWPC386a.js +428 -0
- package/dist/gmail-setup-utils-eJVB5Ewp.js +428 -0
- package/dist/health-format-B0tMTk3C.js +1189 -0
- package/dist/health-format-DaURVaUn.js +1188 -0
- package/dist/help-format-CEsRHU2f.js +17 -0
- package/dist/help-format-GuCWws6r.js +17 -0
- package/dist/helpers-BEJ-phFf.js +25 -0
- package/dist/helpers-BtbBZVKZ.js +10 -0
- package/dist/helpers-C12w9zxf.js +10 -0
- package/dist/helpers-CzjGJZmJ.js +25 -0
- package/dist/hooks/bundled/boot-md/HOOK.md +19 -0
- package/dist/hooks/bundled/command-logger/HOOK.md +122 -0
- package/dist/hooks/bundled/session-memory/HOOK.md +109 -0
- package/dist/hooks/bundled/soul-evil/HOOK.md +71 -0
- package/dist/hooks-cli-BZCMAnW2.js +1058 -0
- package/dist/hooks-cli-D0CEFg3P.js +1061 -0
- package/dist/hooks-status-Bn7_O8PM.js +443 -0
- package/dist/hooks-status-BrWVfIn0.js +443 -0
- package/dist/image-BS022pvv.js +1421 -0
- package/dist/image-BzJtY34J.js +629 -0
- package/dist/image-CBqmIbQQ.js +629 -0
- package/dist/index.js +5809 -0
- package/dist/installs-BP4K5L33.js +388 -0
- package/dist/installs-DOpTt7VZ.js +388 -0
- package/dist/is-main-B4o72sqg.js +25 -0
- package/dist/is-main-PYGa3tDA.js +25 -0
- package/dist/links-B4nk2iDf.js +15 -0
- package/dist/links-DwjRqxgR.js +15 -0
- package/dist/loader-Cn4EV_pf.js +63690 -0
- package/dist/logging-CS3tbYDj.js +15 -0
- package/dist/logging-CY-Q5cwf.js +1 -0
- package/dist/logging-DhiLkhLw.js +15 -0
- package/dist/logging-pqyrk15z.js +1 -0
- package/dist/login-qr-CD164Aw1.js +478 -0
- package/dist/login-qr-D7Zdgji2.js +478 -0
- package/dist/login-qr-YgILJ4VC.js +475 -0
- package/dist/logs-cli-BdS0Uv0I.js +227 -0
- package/dist/logs-cli-CqSN1GzB.js +230 -0
- package/dist/manager-CfGY5zND.js +2870 -0
- package/dist/manager-CjuBqFRL.js +2870 -0
- package/dist/manager-CoBEAQKm.js +2872 -0
- package/dist/manifest-registry-Bwjq9Iev.js +668 -0
- package/dist/manifest-registry-D2Yntqcb.js +668 -0
- package/dist/message-channel-Cjsiqxok.js +105 -0
- package/dist/message-channel-D6v_oPAg.js +105 -0
- package/dist/model-selection-Cv5Ox_tY.js +2956 -0
- package/dist/model-selection-Dr-5U5-l.js +2708 -0
- package/dist/models-cli-B39ckynD.js +2541 -0
- package/dist/models-cli-DoiYsBYw.js +2544 -0
- package/dist/net-CFCxaipF.js +137 -0
- package/dist/net-DKJPqXuW.js +137 -0
- package/dist/node-cli-C_FYF-RA.js +1456 -0
- package/dist/node-cli-DWPoNsQS.js +1459 -0
- package/dist/node-service-DcJREOww.js +67 -0
- package/dist/node-service-DuZ9Us9h.js +67 -0
- package/dist/nodes-cli-Elo6tlen.js +1210 -0
- package/dist/nodes-cli-zqryRUWB.js +1207 -0
- package/dist/nodes-screen-C4aCrxie.js +157 -0
- package/dist/nodes-screen-D4PSynkR.js +157 -0
- package/dist/note-CQhSvgQv.js +73 -0
- package/dist/note-_C44YfAQ.js +73 -0
- package/dist/onboard-channels-CHBDi-ZA.js +670 -0
- package/dist/onboard-channels-DOEKyxaL.js +670 -0
- package/dist/onboard-skills-BUTXREDZ.js +3327 -0
- package/dist/onboard-skills-CSLYZmZA.js +3327 -0
- package/dist/onboarding-CgKb8b39.js +3232 -0
- package/dist/openclaw-root-9ILYSmJ9.js +84 -0
- package/dist/openclaw-root-Cvotktkd.js +84 -0
- package/dist/pairing-cli-B4UGR2at.js +114 -0
- package/dist/pairing-cli-BWDDl8cf.js +117 -0
- package/dist/pairing-labels-ClZ-fTWT.js +9 -0
- package/dist/pairing-labels-Ds7BPOkj.js +9 -0
- package/dist/pairing-store-DDLNuzmx.js +391 -0
- package/dist/pairing-store-DRn08lZD.js +391 -0
- package/dist/parse-87ybtYW1.js +23 -0
- package/dist/parse-OCFfznr3.js +23 -0
- package/dist/parse-log-line-C9aL5PUL.js +44 -0
- package/dist/parse-log-line-DxRaGzQb.js +44 -0
- package/dist/parse-timeout-CFqNj7No.js +16 -0
- package/dist/parse-timeout-DV8NQQWk.js +16 -0
- package/dist/path-env-C7kiJUgG.js +77 -0
- package/dist/path-env-DEj4CiFN.js +77 -0
- package/dist/paths-B-q1nXdY.js +43 -0
- package/dist/paths-B1kfl4h5.js +164 -0
- package/dist/paths-B4kigINg.js +40 -0
- package/dist/paths-CHGbP1-A.js +43 -0
- package/dist/paths-scjhy7N2.js +180 -0
- package/dist/pi-embedded-helpers-C19wUpMB.js +8451 -0
- package/dist/pi-embedded-helpers-CT5VuLCb.js +1293 -0
- package/dist/pi-embedded-helpers-Dl8e5Rf8.js +1293 -0
- package/dist/pi-model-discovery-B6CsmK6Y.js +20 -0
- package/dist/pi-model-discovery-DsRqYJLy.js +20 -0
- package/dist/pi-model-discovery-EhM2JAQo.js +20 -0
- package/dist/pi-tools.policy-BvkSDFDN.js +229 -0
- package/dist/plugin-auto-enable-Bd_StZzz.js +461 -0
- package/dist/plugin-auto-enable-DBhXb_0x.js +461 -0
- package/dist/plugin-sdk/agent-scope-DdwUKIOe.js +606 -0
- package/dist/plugin-sdk/chrome-G8apFa5p.js +1953 -0
- package/dist/plugin-sdk/command-format-qUVxzqYm.js +52 -0
- package/dist/plugin-sdk/config-Cm1M7tgH.js +5623 -0
- package/dist/plugin-sdk/deliver-Cl8uowiO.js +2557 -0
- package/dist/plugin-sdk/exec-Cm9b2r9Q.js +1107 -0
- package/dist/plugin-sdk/github-copilot-token-BHNcM4_B.js +103 -0
- package/dist/plugin-sdk/image-7PgoS2VD.js +1421 -0
- package/dist/plugin-sdk/index.d.ts +8908 -0
- package/dist/plugin-sdk/index.js +70888 -0
- package/dist/plugin-sdk/login-qr-qTALvWi2.js +475 -0
- package/dist/plugin-sdk/manager-Cs3EQZCb.js +2870 -0
- package/dist/plugin-sdk/model-selection-BgC1E1a7.js +2708 -0
- package/dist/plugin-sdk/paths-BYpoyRv5.js +164 -0
- package/dist/plugin-sdk/paths-DNQE-bvr.js +40 -0
- package/dist/plugin-sdk/pi-embedded-helpers-5jNqW_dE.js +8755 -0
- package/dist/plugin-sdk/pi-model-discovery-BUGEht9A.js +20 -0
- package/dist/plugin-sdk/pw-ai-COTtei4a.js +1649 -0
- package/dist/plugin-sdk/qmd-manager-ClSwiAJl.js +615 -0
- package/dist/plugin-sdk/redact-2AzjOfk2.js +94 -0
- package/dist/plugin-sdk/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/plugin-sdk/sqlite-gCW7MlLs.js +215 -0
- package/dist/plugin-sdk/transcript-events-DGF257vD.js +17 -0
- package/dist/plugins-C3Bm-HQV.js +494 -0
- package/dist/plugins-QJjTXliB.js +495 -0
- package/dist/plugins-cli-DTci0JQb.js +443 -0
- package/dist/plugins-cli-wJsN1HHK.js +440 -0
- package/dist/ports-CiW9dmMq.js +96 -0
- package/dist/program-BWpTHh1I.js +188 -0
- package/dist/progress-Bcjniu7m.js +133 -0
- package/dist/progress-CvaSPjS9.js +133 -0
- package/dist/prompt-style-CFsleyxV.js +9 -0
- package/dist/prompt-style-DYJdrXyV.js +9 -0
- package/dist/prompts-Bt9fwsg2.js +10 -0
- package/dist/prompts-CudpZgTI.js +10 -0
- package/dist/pw-ai-08F3GD-3.js +1649 -0
- package/dist/pw-ai-ZmHxHQnx.js +1651 -0
- package/dist/pw-ai-tNPuRNn3.js +1649 -0
- package/dist/qmd-manager-2r-4n3sP.js +617 -0
- package/dist/qmd-manager-CF52nuBg.js +615 -0
- package/dist/qmd-manager-HEm5H2mk.js +616 -0
- package/dist/redact-BICFkpn7.js +97 -0
- package/dist/redact-BIMJ3ntQ.js +94 -0
- package/dist/redact-KzWHRS5J.js +97 -0
- package/dist/register.subclis-D2K25c84.js +348 -0
- package/dist/register.subclis-Dd8LbOLi.js +342 -0
- package/dist/reply-5UNWRwMn.js +63693 -0
- package/dist/restart-sentinel-Cr0vUxB8.js +65 -0
- package/dist/restart-sentinel-DUemCjgU.js +65 -0
- package/dist/rolldown-runtime-Cbj13DAv.js +20 -0
- package/dist/routes-C6UpTPas.js +2410 -0
- package/dist/routes-ClNyEvlm.js +2410 -0
- package/dist/rpc-D0mf7DIw.js +95 -0
- package/dist/rpc-DYdOrgd9.js +95 -0
- package/dist/run-main-CojI7gWx.js +194 -0
- package/dist/runtime-guard-68M_evhb.js +60 -0
- package/dist/runtime-guard-DkjmhnBD.js +60 -0
- package/dist/sandbox-Ca81z3Tw.js +2924 -0
- package/dist/sandbox-cli-D75GApgp.js +459 -0
- package/dist/sandbox-cli-E4SJsC1C.js +462 -0
- package/dist/sandbox-knontqD9.js +2925 -0
- package/dist/security-cli-BLihvXO-.js +503 -0
- package/dist/security-cli-IGQCsK4g.js +506 -0
- package/dist/server-context-B9GX5GOI.js +740 -0
- package/dist/server-context-BFH7HB_M.js +740 -0
- package/dist/server-node-events-CTdHBiEA.js +218 -0
- package/dist/server-node-events-DAV14qPr.js +215 -0
- package/dist/service-BZNBq9hq.js +680 -0
- package/dist/service-C-BLXx9U.js +680 -0
- package/dist/service-audit-BfJv4NqZ.js +542 -0
- package/dist/service-audit-Bw3M2OEI.js +542 -0
- package/dist/shared-5SH-45AX.js +74 -0
- package/dist/shared-BxRm5uLU.js +74 -0
- package/dist/shared-C80Rmxsd.js +150 -0
- package/dist/shared-fGK6_D2v.js +150 -0
- package/dist/skills-Bhp0l6UK.js +693 -0
- package/dist/skills-Tky2kCMO.js +694 -0
- package/dist/skills-cli-6rCClAE4.js +287 -0
- package/dist/skills-cli-C4nLCrLw.js +290 -0
- package/dist/skills-status-CENcKr3I.js +187 -0
- package/dist/skills-status-DX1eUYvk.js +187 -0
- package/dist/sqlite-CmdZSZRx.js +197 -0
- package/dist/sqlite-Dnmf3LS7.js +215 -0
- package/dist/sqlite-QDf0yuU0.js +215 -0
- package/dist/status-BSfGAp2D.js +27 -0
- package/dist/status-Bp_2NMjt.js +27 -0
- package/dist/status-C0ANDr0T.js +3140 -0
- package/dist/status-CCHBIZnm.js +21 -0
- package/dist/status-Vuqbw2Bb.js +21 -0
- package/dist/status.update-BZW5r8Su.js +79 -0
- package/dist/status.update-BnD93_O8.js +79 -0
- package/dist/subsystem-CAq3uyo7.js +834 -0
- package/dist/system-cli-Bb9zmCO1.js +83 -0
- package/dist/system-cli-TIIQ04ls.js +80 -0
- package/dist/systemd-0Qa_nGqe.js +438 -0
- package/dist/systemd-Czb0Xsm7.js +438 -0
- package/dist/systemd-hints-CWoEOQRb.js +19 -0
- package/dist/systemd-hints-Cv3RN_mZ.js +19 -0
- package/dist/systemd-linger-CsdvcIoS.js +75 -0
- package/dist/systemd-linger-DKUFHcLn.js +75 -0
- package/dist/table-DNPESyNj.js +279 -0
- package/dist/table-DS4-gmkV.js +279 -0
- package/dist/tailnet-Bg_vE5qi.js +42 -0
- package/dist/tailnet-CrNWlQRJ.js +42 -0
- package/dist/tailscale-CBv58toW.js +252 -0
- package/dist/tailscale-DCnMs7_q.js +225 -0
- package/dist/tool-display-BEACy9rK.js +795 -0
- package/dist/tool-display-NYQnSpdo.js +795 -0
- package/dist/transcript-events-CsB1Saa6.js +17 -0
- package/dist/transcript-events-DDYvbmRV.js +17 -0
- package/dist/transcript-events-JLH5W4He.js +17 -0
- package/dist/tui--NY0rnjr.js +2542 -0
- package/dist/tui-DqJfGtvM.js +2543 -0
- package/dist/tui-cli-BuHNY6wF.js +54 -0
- package/dist/tui-cli-LMFV982e.js +57 -0
- package/dist/update-CRpHtCgz.js +317 -0
- package/dist/update-D3qruxhj.js +317 -0
- package/dist/update-cli-CFF-pslM.js +948 -0
- package/dist/update-cli-cn9pEMX7.js +951 -0
- package/dist/update-runner-CxGU142L.js +1221 -0
- package/dist/update-runner-DNobz_ft.js +1221 -0
- package/dist/utils-CKSrBNwq.js +192 -0
- package/dist/utils-DX85MiPR.js +188 -0
- package/dist/webhooks-cli-BGtt2HAR.js +312 -0
- package/dist/webhooks-cli-DHLZrEO_.js +309 -0
- package/dist/widearea-dns-BpG7ATO8.js +127 -0
- package/dist/widearea-dns-D4wkCJly.js +127 -0
- package/dist/ws-3zr8WUwL.js +13 -0
- package/dist/ws-log-BXcT2xQk.js +267 -0
- package/dist/ws-log-DbDIUsgz.js +267 -0
- package/dist/ws-lzrgabja.js +13 -0
- package/dist/wsl-D2O2qOrl.js +160 -0
- package/docs/.i18n/README.md +31 -0
- package/docs/.i18n/glossary.zh-CN.json +190 -0
- package/docs/.i18n/zh-CN.tm.jsonl +1329 -0
- package/docs/CNAME +1 -0
- package/docs/_config.yml +53 -0
- package/docs/_layouts/default.html +145 -0
- package/docs/assets/markdown.css +179 -0
- package/docs/assets/openclaw-logo-text-dark.png +0 -0
- package/docs/assets/openclaw-logo-text.png +0 -0
- package/docs/assets/pixel-lobster.svg +60 -0
- package/docs/assets/showcase/agents-ui.jpg +0 -0
- package/docs/assets/showcase/bambu-cli.png +0 -0
- package/docs/assets/showcase/codexmonitor.png +0 -0
- package/docs/assets/showcase/gohome-grafana.png +0 -0
- package/docs/assets/showcase/ios-testflight.jpg +0 -0
- package/docs/assets/showcase/oura-health.png +0 -0
- package/docs/assets/showcase/padel-cli.svg +11 -0
- package/docs/assets/showcase/padel-screenshot.jpg +0 -0
- package/docs/assets/showcase/papla-tts.jpg +0 -0
- package/docs/assets/showcase/pr-review-telegram.jpg +0 -0
- package/docs/assets/showcase/roborock-screenshot.jpg +0 -0
- package/docs/assets/showcase/roborock-status.svg +13 -0
- package/docs/assets/showcase/roof-camera-sky.jpg +0 -0
- package/docs/assets/showcase/snag.png +0 -0
- package/docs/assets/showcase/tesco-shop.jpg +0 -0
- package/docs/assets/showcase/wienerlinien.png +0 -0
- package/docs/assets/showcase/wine-cellar-skill.jpg +0 -0
- package/docs/assets/showcase/winix-air-purifier.jpg +0 -0
- package/docs/assets/showcase/xuezh-pronunciation.jpeg +0 -0
- package/docs/assets/terminal.css +473 -0
- package/docs/assets/theme.js +55 -0
- package/docs/automation/auth-monitoring.md +44 -0
- package/docs/automation/cron-jobs.md +468 -0
- package/docs/automation/cron-vs-heartbeat.md +282 -0
- package/docs/automation/gmail-pubsub.md +256 -0
- package/docs/automation/poll.md +69 -0
- package/docs/automation/webhook.md +163 -0
- package/docs/bedrock.md +176 -0
- package/docs/brave-search.md +41 -0
- package/docs/broadcast-groups.md +442 -0
- package/docs/channels/bluebubbles.md +338 -0
- package/docs/channels/discord.md +475 -0
- package/docs/channels/feishu.md +507 -0
- package/docs/channels/googlechat.md +250 -0
- package/docs/channels/grammy.md +31 -0
- package/docs/channels/imessage.md +299 -0
- package/docs/channels/index.md +46 -0
- package/docs/channels/line.md +186 -0
- package/docs/channels/location.md +56 -0
- package/docs/channels/matrix.md +233 -0
- package/docs/channels/mattermost.md +138 -0
- package/docs/channels/msteams.md +768 -0
- package/docs/channels/nextcloud-talk.md +136 -0
- package/docs/channels/nostr.md +233 -0
- package/docs/channels/signal.md +202 -0
- package/docs/channels/slack.md +548 -0
- package/docs/channels/telegram.md +750 -0
- package/docs/channels/tlon.md +132 -0
- package/docs/channels/troubleshooting.md +29 -0
- package/docs/channels/twitch.md +379 -0
- package/docs/channels/whatsapp.md +404 -0
- package/docs/channels/zalo.md +189 -0
- package/docs/channels/zalouser.md +140 -0
- package/docs/cli/acp.md +170 -0
- package/docs/cli/agent.md +24 -0
- package/docs/cli/agents.md +75 -0
- package/docs/cli/approvals.md +50 -0
- package/docs/cli/browser.md +107 -0
- package/docs/cli/channels.md +79 -0
- package/docs/cli/config.md +50 -0
- package/docs/cli/configure.md +33 -0
- package/docs/cli/cron.md +42 -0
- package/docs/cli/dashboard.md +16 -0
- package/docs/cli/devices.md +67 -0
- package/docs/cli/directory.md +63 -0
- package/docs/cli/dns.md +23 -0
- package/docs/cli/docs.md +15 -0
- package/docs/cli/doctor.md +41 -0
- package/docs/cli/gateway.md +199 -0
- package/docs/cli/health.md +21 -0
- package/docs/cli/hooks.md +304 -0
- package/docs/cli/index.md +1029 -0
- package/docs/cli/logs.md +24 -0
- package/docs/cli/memory.md +45 -0
- package/docs/cli/message.md +239 -0
- package/docs/cli/models.md +79 -0
- package/docs/cli/node.md +112 -0
- package/docs/cli/nodes.md +73 -0
- package/docs/cli/onboard.md +29 -0
- package/docs/cli/pairing.md +21 -0
- package/docs/cli/plugins.md +62 -0
- package/docs/cli/reset.md +17 -0
- package/docs/cli/sandbox.md +152 -0
- package/docs/cli/security.md +26 -0
- package/docs/cli/sessions.md +16 -0
- package/docs/cli/setup.md +29 -0
- package/docs/cli/skills.md +26 -0
- package/docs/cli/status.md +26 -0
- package/docs/cli/system.md +60 -0
- package/docs/cli/tui.md +23 -0
- package/docs/cli/uninstall.md +17 -0
- package/docs/cli/update.md +98 -0
- package/docs/cli/voicecall.md +34 -0
- package/docs/cli/webhooks.md +25 -0
- package/docs/concepts/agent-loop.md +146 -0
- package/docs/concepts/agent-workspace.md +233 -0
- package/docs/concepts/agent.md +123 -0
- package/docs/concepts/architecture.md +129 -0
- package/docs/concepts/channel-routing.md +114 -0
- package/docs/concepts/compaction.md +61 -0
- package/docs/concepts/context.md +161 -0
- package/docs/concepts/group-messages.md +84 -0
- package/docs/concepts/groups.md +373 -0
- package/docs/concepts/markdown-formatting.md +130 -0
- package/docs/concepts/memory.md +546 -0
- package/docs/concepts/messages.md +154 -0
- package/docs/concepts/model-failover.md +149 -0
- package/docs/concepts/model-providers.md +316 -0
- package/docs/concepts/models.md +208 -0
- package/docs/concepts/multi-agent.md +376 -0
- package/docs/concepts/oauth.md +145 -0
- package/docs/concepts/presence.md +102 -0
- package/docs/concepts/queue.md +89 -0
- package/docs/concepts/retry.md +69 -0
- package/docs/concepts/session-pruning.md +122 -0
- package/docs/concepts/session-tool.md +193 -0
- package/docs/concepts/session.md +188 -0
- package/docs/concepts/sessions.md +10 -0
- package/docs/concepts/streaming.md +135 -0
- package/docs/concepts/system-prompt.md +115 -0
- package/docs/concepts/timezone.md +91 -0
- package/docs/concepts/typebox.md +289 -0
- package/docs/concepts/typing-indicators.md +68 -0
- package/docs/concepts/usage-tracking.md +35 -0
- package/docs/date-time.md +128 -0
- package/docs/debug/node-issue.md +83 -0
- package/docs/debugging.md +162 -0
- package/docs/diagnostics/flags.md +91 -0
- package/docs/docs.json +1587 -0
- package/docs/environment.md +81 -0
- package/docs/experiments/onboarding-config-protocol.md +40 -0
- package/docs/experiments/plans/cron-add-hardening.md +63 -0
- package/docs/experiments/plans/group-policy-hardening.md +40 -0
- package/docs/experiments/plans/openresponses-gateway.md +123 -0
- package/docs/experiments/proposals/model-config.md +36 -0
- package/docs/experiments/research/memory.md +228 -0
- package/docs/gateway/authentication.md +145 -0
- package/docs/gateway/background-process.md +93 -0
- package/docs/gateway/bonjour.md +167 -0
- package/docs/gateway/bridge-protocol.md +89 -0
- package/docs/gateway/cli-backends.md +223 -0
- package/docs/gateway/configuration-examples.md +606 -0
- package/docs/gateway/configuration.md +3393 -0
- package/docs/gateway/discovery.md +116 -0
- package/docs/gateway/doctor.md +282 -0
- package/docs/gateway/gateway-lock.md +34 -0
- package/docs/gateway/health.md +35 -0
- package/docs/gateway/heartbeat.md +302 -0
- package/docs/gateway/index.md +328 -0
- package/docs/gateway/local-models.md +150 -0
- package/docs/gateway/logging.md +113 -0
- package/docs/gateway/multiple-gateways.md +112 -0
- package/docs/gateway/openai-http-api.md +118 -0
- package/docs/gateway/openresponses-http-api.md +317 -0
- package/docs/gateway/pairing.md +99 -0
- package/docs/gateway/protocol.md +221 -0
- package/docs/gateway/remote-gateway-readme.md +157 -0
- package/docs/gateway/remote.md +127 -0
- package/docs/gateway/sandbox-vs-tool-policy-vs-elevated.md +128 -0
- package/docs/gateway/sandboxing.md +193 -0
- package/docs/gateway/security/formal-verification.md +164 -0
- package/docs/gateway/security/index.md +825 -0
- package/docs/gateway/tailscale.md +127 -0
- package/docs/gateway/tools-invoke-http-api.md +85 -0
- package/docs/gateway/troubleshooting.md +767 -0
- package/docs/help/faq.md +2830 -0
- package/docs/help/index.md +21 -0
- package/docs/help/troubleshooting.md +98 -0
- package/docs/hooks/soul-evil.md +69 -0
- package/docs/hooks.md +913 -0
- package/docs/images/feishu-step2-create-app.png +0 -0
- package/docs/images/feishu-step3-credentials.png +0 -0
- package/docs/images/feishu-step4-permissions.png +0 -0
- package/docs/images/feishu-step5-bot-capability.png +0 -0
- package/docs/images/feishu-step6-event-subscription.png +0 -0
- package/docs/images/groups-flow.svg +52 -0
- package/docs/images/mobile-ui-screenshot.png +0 -0
- package/docs/index.md +258 -0
- package/docs/install/ansible.md +208 -0
- package/docs/install/bun.md +59 -0
- package/docs/install/development-channels.md +75 -0
- package/docs/install/docker.md +567 -0
- package/docs/install/index.md +185 -0
- package/docs/install/installer.md +123 -0
- package/docs/install/migrating.md +192 -0
- package/docs/install/nix.md +96 -0
- package/docs/install/node.md +78 -0
- package/docs/install/uninstall.md +128 -0
- package/docs/install/updating.md +228 -0
- package/docs/logging.md +350 -0
- package/docs/multi-agent-sandbox-tools.md +395 -0
- package/docs/network.md +54 -0
- package/docs/nodes/audio.md +114 -0
- package/docs/nodes/camera.md +156 -0
- package/docs/nodes/images.md +72 -0
- package/docs/nodes/index.md +341 -0
- package/docs/nodes/location-command.md +113 -0
- package/docs/nodes/media-understanding.md +379 -0
- package/docs/nodes/talk.md +90 -0
- package/docs/nodes/voicewake.md +65 -0
- package/docs/northflank.mdx +53 -0
- package/docs/perplexity.md +80 -0
- package/docs/pi-dev.md +70 -0
- package/docs/pi.md +612 -0
- package/docs/platforms/android.md +148 -0
- package/docs/platforms/digitalocean.md +262 -0
- package/docs/platforms/exe-dev.md +125 -0
- package/docs/platforms/fly.md +486 -0
- package/docs/platforms/gcp.md +503 -0
- package/docs/platforms/hetzner.md +330 -0
- package/docs/platforms/index.md +53 -0
- package/docs/platforms/ios.md +107 -0
- package/docs/platforms/linux.md +94 -0
- package/docs/platforms/mac/bundled-gateway.md +73 -0
- package/docs/platforms/mac/canvas.md +125 -0
- package/docs/platforms/mac/child-process.md +69 -0
- package/docs/platforms/mac/dev-setup.md +102 -0
- package/docs/platforms/mac/health.md +34 -0
- package/docs/platforms/mac/icon.md +31 -0
- package/docs/platforms/mac/logging.md +57 -0
- package/docs/platforms/mac/menu-bar.md +81 -0
- package/docs/platforms/mac/peekaboo.md +65 -0
- package/docs/platforms/mac/permissions.md +44 -0
- package/docs/platforms/mac/release.md +85 -0
- package/docs/platforms/mac/remote.md +83 -0
- package/docs/platforms/mac/signing.md +47 -0
- package/docs/platforms/mac/skills.md +33 -0
- package/docs/platforms/mac/voice-overlay.md +60 -0
- package/docs/platforms/mac/voicewake.md +67 -0
- package/docs/platforms/mac/webchat.md +41 -0
- package/docs/platforms/mac/xpc.md +61 -0
- package/docs/platforms/macos-vm.md +281 -0
- package/docs/platforms/macos.md +203 -0
- package/docs/platforms/oracle.md +303 -0
- package/docs/platforms/raspberry-pi.md +358 -0
- package/docs/platforms/windows.md +159 -0
- package/docs/plugin.md +664 -0
- package/docs/plugins/agent-tools.md +99 -0
- package/docs/plugins/manifest.md +71 -0
- package/docs/plugins/voice-call.md +284 -0
- package/docs/plugins/zalouser.md +81 -0
- package/docs/prose.md +134 -0
- package/docs/providers/anthropic.md +152 -0
- package/docs/providers/claude-max-api-proxy.md +148 -0
- package/docs/providers/cloudflare-ai-gateway.md +71 -0
- package/docs/providers/deepgram.md +93 -0
- package/docs/providers/github-copilot.md +72 -0
- package/docs/providers/glm.md +33 -0
- package/docs/providers/index.md +63 -0
- package/docs/providers/minimax.md +208 -0
- package/docs/providers/models.md +51 -0
- package/docs/providers/moonshot.md +142 -0
- package/docs/providers/ollama.md +223 -0
- package/docs/providers/openai.md +62 -0
- package/docs/providers/opencode.md +36 -0
- package/docs/providers/openrouter.md +37 -0
- package/docs/providers/qwen.md +53 -0
- package/docs/providers/synthetic.md +99 -0
- package/docs/providers/venice.md +267 -0
- package/docs/providers/vercel-ai-gateway.md +50 -0
- package/docs/providers/xiaomi.md +64 -0
- package/docs/providers/zai.md +36 -0
- package/docs/railway.mdx +99 -0
- package/docs/refactor/clawnet.md +417 -0
- package/docs/refactor/exec-host.md +316 -0
- package/docs/refactor/outbound-session-mirroring.md +85 -0
- package/docs/refactor/plugin-sdk.md +214 -0
- package/docs/refactor/strict-config.md +93 -0
- package/docs/reference/AGENTS.default.md +124 -0
- package/docs/reference/RELEASING.md +120 -0
- package/docs/reference/api-usage-costs.md +137 -0
- package/docs/reference/device-models.md +47 -0
- package/docs/reference/rpc.md +43 -0
- package/docs/reference/session-management-compaction.md +285 -0
- package/docs/reference/templates/AGENTS.dev.md +83 -0
- package/docs/reference/templates/AGENTS.md +218 -0
- package/docs/reference/templates/BOOT.md +10 -0
- package/docs/reference/templates/BOOTSTRAP.md +61 -0
- package/docs/reference/templates/HEARTBEAT.md +11 -0
- package/docs/reference/templates/IDENTITY.dev.md +47 -0
- package/docs/reference/templates/IDENTITY.md +27 -0
- package/docs/reference/templates/SOUL.dev.md +76 -0
- package/docs/reference/templates/SOUL.md +42 -0
- package/docs/reference/templates/TOOLS.dev.md +24 -0
- package/docs/reference/templates/TOOLS.md +46 -0
- package/docs/reference/templates/USER.dev.md +18 -0
- package/docs/reference/templates/USER.md +22 -0
- package/docs/reference/test.md +50 -0
- package/docs/reference/transcript-hygiene.md +129 -0
- package/docs/render.mdx +165 -0
- package/docs/scripts.md +28 -0
- package/docs/security/formal-verification.md +164 -0
- package/docs/start/getting-started.md +208 -0
- package/docs/start/hubs.md +185 -0
- package/docs/start/lore.md +219 -0
- package/docs/start/onboarding.md +110 -0
- package/docs/start/openclaw.md +241 -0
- package/docs/start/pairing.md +86 -0
- package/docs/start/setup.md +149 -0
- package/docs/start/showcase.md +416 -0
- package/docs/start/wizard.md +349 -0
- package/docs/testing.md +368 -0
- package/docs/token-use.md +112 -0
- package/docs/tools/agent-send.md +53 -0
- package/docs/tools/apply-patch.md +50 -0
- package/docs/tools/browser-linux-troubleshooting.md +139 -0
- package/docs/tools/browser-login.md +68 -0
- package/docs/tools/browser.md +576 -0
- package/docs/tools/chrome-extension.md +178 -0
- package/docs/tools/clawhub.md +257 -0
- package/docs/tools/creating-skills.md +54 -0
- package/docs/tools/elevated.md +57 -0
- package/docs/tools/exec-approvals.md +246 -0
- package/docs/tools/exec.md +179 -0
- package/docs/tools/firecrawl.md +61 -0
- package/docs/tools/index.md +509 -0
- package/docs/tools/llm-task.md +115 -0
- package/docs/tools/lobster.md +342 -0
- package/docs/tools/reactions.md +22 -0
- package/docs/tools/skills-config.md +76 -0
- package/docs/tools/skills.md +300 -0
- package/docs/tools/slash-commands.md +198 -0
- package/docs/tools/subagents.md +151 -0
- package/docs/tools/thinking.md +73 -0
- package/docs/tools/web.md +261 -0
- package/docs/tts.md +396 -0
- package/docs/tui.md +159 -0
- package/docs/vps.md +43 -0
- package/docs/web/control-ui.md +221 -0
- package/docs/web/dashboard.md +46 -0
- package/docs/web/index.md +116 -0
- package/docs/web/webchat.md +49 -0
- package/docs/whatsapp-openclaw-ai-zh.jpg +0 -0
- package/docs/whatsapp-openclaw.jpg +0 -0
- package/docs/zh-CN/AGENTS.md +59 -0
- package/docs/zh-CN/automation/auth-monitoring.md +47 -0
- package/docs/zh-CN/automation/cron-jobs.md +424 -0
- package/docs/zh-CN/automation/cron-vs-heartbeat.md +286 -0
- package/docs/zh-CN/automation/gmail-pubsub.md +249 -0
- package/docs/zh-CN/automation/poll.md +76 -0
- package/docs/zh-CN/automation/webhook.md +163 -0
- package/docs/zh-CN/bedrock.md +170 -0
- package/docs/zh-CN/brave-search.md +48 -0
- package/docs/zh-CN/broadcast-groups.md +449 -0
- package/docs/zh-CN/channels/bluebubbles.md +271 -0
- package/docs/zh-CN/channels/discord.md +468 -0
- package/docs/zh-CN/channels/feishu.md +513 -0
- package/docs/zh-CN/channels/googlechat.md +257 -0
- package/docs/zh-CN/channels/grammy.md +38 -0
- package/docs/zh-CN/channels/imessage.md +302 -0
- package/docs/zh-CN/channels/index.md +53 -0
- package/docs/zh-CN/channels/line.md +180 -0
- package/docs/zh-CN/channels/location.md +63 -0
- package/docs/zh-CN/channels/matrix.md +221 -0
- package/docs/zh-CN/channels/mattermost.md +144 -0
- package/docs/zh-CN/channels/msteams.md +775 -0
- package/docs/zh-CN/channels/nextcloud-talk.md +142 -0
- package/docs/zh-CN/channels/nostr.md +240 -0
- package/docs/zh-CN/channels/signal.md +209 -0
- package/docs/zh-CN/channels/slack.md +531 -0
- package/docs/zh-CN/channels/telegram.md +751 -0
- package/docs/zh-CN/channels/tlon.md +136 -0
- package/docs/zh-CN/channels/troubleshooting.md +36 -0
- package/docs/zh-CN/channels/twitch.md +385 -0
- package/docs/zh-CN/channels/whatsapp.md +411 -0
- package/docs/zh-CN/channels/zalo.md +196 -0
- package/docs/zh-CN/channels/zalouser.md +147 -0
- package/docs/zh-CN/cli/acp.md +173 -0
- package/docs/zh-CN/cli/agent.md +30 -0
- package/docs/zh-CN/cli/agents.md +82 -0
- package/docs/zh-CN/cli/approvals.md +57 -0
- package/docs/zh-CN/cli/browser.md +114 -0
- package/docs/zh-CN/cli/channels.md +86 -0
- package/docs/zh-CN/cli/config.md +57 -0
- package/docs/zh-CN/cli/configure.md +38 -0
- package/docs/zh-CN/cli/cron.md +43 -0
- package/docs/zh-CN/cli/dashboard.md +23 -0
- package/docs/zh-CN/cli/devices.md +74 -0
- package/docs/zh-CN/cli/directory.md +70 -0
- package/docs/zh-CN/cli/dns.md +30 -0
- package/docs/zh-CN/cli/docs.md +22 -0
- package/docs/zh-CN/cli/doctor.md +48 -0
- package/docs/zh-CN/cli/gateway.md +206 -0
- package/docs/zh-CN/cli/health.md +28 -0
- package/docs/zh-CN/cli/hooks.md +311 -0
- package/docs/zh-CN/cli/index.md +1032 -0
- package/docs/zh-CN/cli/logs.md +31 -0
- package/docs/zh-CN/cli/memory.md +52 -0
- package/docs/zh-CN/cli/message.md +246 -0
- package/docs/zh-CN/cli/models.md +85 -0
- package/docs/zh-CN/cli/node.md +115 -0
- package/docs/zh-CN/cli/nodes.md +80 -0
- package/docs/zh-CN/cli/onboard.md +36 -0
- package/docs/zh-CN/cli/pairing.md +28 -0
- package/docs/zh-CN/cli/plugins.md +66 -0
- package/docs/zh-CN/cli/reset.md +24 -0
- package/docs/zh-CN/cli/sandbox.md +158 -0
- package/docs/zh-CN/cli/security.md +33 -0
- package/docs/zh-CN/cli/sessions.md +23 -0
- package/docs/zh-CN/cli/setup.md +36 -0
- package/docs/zh-CN/cli/skills.md +33 -0
- package/docs/zh-CN/cli/status.md +33 -0
- package/docs/zh-CN/cli/system.md +63 -0
- package/docs/zh-CN/cli/tui.md +30 -0
- package/docs/zh-CN/cli/uninstall.md +24 -0
- package/docs/zh-CN/cli/update.md +101 -0
- package/docs/zh-CN/cli/voicecall.md +41 -0
- package/docs/zh-CN/cli/webhooks.md +32 -0
- package/docs/zh-CN/concepts/agent-loop.md +146 -0
- package/docs/zh-CN/concepts/agent-workspace.md +219 -0
- package/docs/zh-CN/concepts/agent.md +115 -0
- package/docs/zh-CN/concepts/architecture.md +123 -0
- package/docs/zh-CN/concepts/channel-routing.md +117 -0
- package/docs/zh-CN/concepts/compaction.md +67 -0
- package/docs/zh-CN/concepts/context.md +168 -0
- package/docs/zh-CN/concepts/group-messages.md +91 -0
- package/docs/zh-CN/concepts/groups.md +379 -0
- package/docs/zh-CN/concepts/markdown-formatting.md +117 -0
- package/docs/zh-CN/concepts/memory.md +412 -0
- package/docs/zh-CN/concepts/messages.md +141 -0
- package/docs/zh-CN/concepts/model-failover.md +145 -0
- package/docs/zh-CN/concepts/model-providers.md +320 -0
- package/docs/zh-CN/concepts/models.md +196 -0
- package/docs/zh-CN/concepts/multi-agent.md +372 -0
- package/docs/zh-CN/concepts/oauth.md +151 -0
- package/docs/zh-CN/concepts/presence.md +99 -0
- package/docs/zh-CN/concepts/queue.md +94 -0
- package/docs/zh-CN/concepts/retry.md +76 -0
- package/docs/zh-CN/concepts/session-pruning.md +129 -0
- package/docs/zh-CN/concepts/session-tool.md +200 -0
- package/docs/zh-CN/concepts/session.md +166 -0
- package/docs/zh-CN/concepts/sessions.md +17 -0
- package/docs/zh-CN/concepts/streaming.md +133 -0
- package/docs/zh-CN/concepts/system-prompt.md +101 -0
- package/docs/zh-CN/concepts/timezone.md +96 -0
- package/docs/zh-CN/concepts/typebox.md +284 -0
- package/docs/zh-CN/concepts/typing-indicators.md +74 -0
- package/docs/zh-CN/concepts/usage-tracking.md +42 -0
- package/docs/zh-CN/date-time.md +129 -0
- package/docs/zh-CN/debug/node-issue.md +90 -0
- package/docs/zh-CN/debugging.md +160 -0
- package/docs/zh-CN/diagnostics/flags.md +98 -0
- package/docs/zh-CN/environment.md +88 -0
- package/docs/zh-CN/experiments/onboarding-config-protocol.md +47 -0
- package/docs/zh-CN/experiments/plans/cron-add-hardening.md +70 -0
- package/docs/zh-CN/experiments/plans/group-policy-hardening.md +45 -0
- package/docs/zh-CN/experiments/plans/openresponses-gateway.md +121 -0
- package/docs/zh-CN/experiments/proposals/model-config.md +42 -0
- package/docs/zh-CN/experiments/research/memory.md +235 -0
- package/docs/zh-CN/gateway/authentication.md +142 -0
- package/docs/zh-CN/gateway/background-process.md +100 -0
- package/docs/zh-CN/gateway/bonjour.md +174 -0
- package/docs/zh-CN/gateway/bridge-protocol.md +86 -0
- package/docs/zh-CN/gateway/cli-backends.md +213 -0
- package/docs/zh-CN/gateway/configuration-examples.md +587 -0
- package/docs/zh-CN/gateway/configuration.md +3332 -0
- package/docs/zh-CN/gateway/discovery.md +123 -0
- package/docs/zh-CN/gateway/doctor.md +238 -0
- package/docs/zh-CN/gateway/gateway-lock.md +41 -0
- package/docs/zh-CN/gateway/health.md +42 -0
- package/docs/zh-CN/gateway/heartbeat.md +274 -0
- package/docs/zh-CN/gateway/index.md +335 -0
- package/docs/zh-CN/gateway/local-models.md +157 -0
- package/docs/zh-CN/gateway/logging.md +114 -0
- package/docs/zh-CN/gateway/multiple-gateways.md +119 -0
- package/docs/zh-CN/gateway/openai-http-api.md +125 -0
- package/docs/zh-CN/gateway/openresponses-http-api.md +317 -0
- package/docs/zh-CN/gateway/pairing.md +99 -0
- package/docs/zh-CN/gateway/protocol.md +220 -0
- package/docs/zh-CN/gateway/remote-gateway-readme.md +164 -0
- package/docs/zh-CN/gateway/remote.md +133 -0
- package/docs/zh-CN/gateway/sandbox-vs-tool-policy-vs-elevated.md +135 -0
- package/docs/zh-CN/gateway/sandboxing.md +188 -0
- package/docs/zh-CN/gateway/security/formal-verification.md +169 -0
- package/docs/zh-CN/gateway/security/index.md +777 -0
- package/docs/zh-CN/gateway/tailscale.md +124 -0
- package/docs/zh-CN/gateway/tools-invoke-http-api.md +92 -0
- package/docs/zh-CN/gateway/troubleshooting.md +771 -0
- package/docs/zh-CN/help/faq.md +2628 -0
- package/docs/zh-CN/help/index.md +28 -0
- package/docs/zh-CN/help/troubleshooting.md +104 -0
- package/docs/zh-CN/hooks/soul-evil.md +72 -0
- package/docs/zh-CN/hooks.md +919 -0
- package/docs/zh-CN/index.md +264 -0
- package/docs/zh-CN/install/ansible.md +215 -0
- package/docs/zh-CN/install/bun.md +65 -0
- package/docs/zh-CN/install/development-channels.md +81 -0
- package/docs/zh-CN/install/docker.md +532 -0
- package/docs/zh-CN/install/index.md +193 -0
- package/docs/zh-CN/install/installer.md +128 -0
- package/docs/zh-CN/install/migrating.md +199 -0
- package/docs/zh-CN/install/nix.md +99 -0
- package/docs/zh-CN/install/node.md +85 -0
- package/docs/zh-CN/install/uninstall.md +135 -0
- package/docs/zh-CN/install/updating.md +233 -0
- package/docs/zh-CN/logging.md +329 -0
- package/docs/zh-CN/multi-agent-sandbox-tools.md +401 -0
- package/docs/zh-CN/network.md +59 -0
- package/docs/zh-CN/nodes/audio.md +120 -0
- package/docs/zh-CN/nodes/camera.md +162 -0
- package/docs/zh-CN/nodes/images.md +79 -0
- package/docs/zh-CN/nodes/index.md +348 -0
- package/docs/zh-CN/nodes/location-command.md +120 -0
- package/docs/zh-CN/nodes/media-understanding.md +380 -0
- package/docs/zh-CN/nodes/talk.md +97 -0
- package/docs/zh-CN/nodes/voicewake.md +72 -0
- package/docs/zh-CN/northflank.mdx +60 -0
- package/docs/zh-CN/perplexity.md +84 -0
- package/docs/zh-CN/pi-dev.md +77 -0
- package/docs/zh-CN/pi.md +619 -0
- package/docs/zh-CN/platforms/android.md +155 -0
- package/docs/zh-CN/platforms/digitalocean.md +269 -0
- package/docs/zh-CN/platforms/exe-dev.md +127 -0
- package/docs/zh-CN/platforms/fly.md +490 -0
- package/docs/zh-CN/platforms/gcp.md +510 -0
- package/docs/zh-CN/platforms/hetzner.md +337 -0
- package/docs/zh-CN/platforms/index.md +60 -0
- package/docs/zh-CN/platforms/ios.md +114 -0
- package/docs/zh-CN/platforms/linux.md +101 -0
- package/docs/zh-CN/platforms/mac/bundled-gateway.md +75 -0
- package/docs/zh-CN/platforms/mac/canvas.md +128 -0
- package/docs/zh-CN/platforms/mac/child-process.md +73 -0
- package/docs/zh-CN/platforms/mac/dev-setup.md +109 -0
- package/docs/zh-CN/platforms/mac/health.md +41 -0
- package/docs/zh-CN/platforms/mac/icon.md +38 -0
- package/docs/zh-CN/platforms/mac/logging.md +64 -0
- package/docs/zh-CN/platforms/mac/menu-bar.md +88 -0
- package/docs/zh-CN/platforms/mac/peekaboo.md +62 -0
- package/docs/zh-CN/platforms/mac/permissions.md +46 -0
- package/docs/zh-CN/platforms/mac/release.md +92 -0
- package/docs/zh-CN/platforms/mac/remote.md +90 -0
- package/docs/zh-CN/platforms/mac/signing.md +54 -0
- package/docs/zh-CN/platforms/mac/skills.md +40 -0
- package/docs/zh-CN/platforms/mac/voice-overlay.md +67 -0
- package/docs/zh-CN/platforms/mac/voicewake.md +74 -0
- package/docs/zh-CN/platforms/mac/webchat.md +43 -0
- package/docs/zh-CN/platforms/mac/xpc.md +68 -0
- package/docs/zh-CN/platforms/macos-vm.md +288 -0
- package/docs/zh-CN/platforms/macos.md +193 -0
- package/docs/zh-CN/platforms/oracle.md +310 -0
- package/docs/zh-CN/platforms/raspberry-pi.md +365 -0
- package/docs/zh-CN/platforms/windows.md +156 -0
- package/docs/zh-CN/plugin.md +639 -0
- package/docs/zh-CN/plugins/agent-tools.md +99 -0
- package/docs/zh-CN/plugins/manifest.md +68 -0
- package/docs/zh-CN/plugins/voice-call.md +250 -0
- package/docs/zh-CN/plugins/zalouser.md +88 -0
- package/docs/zh-CN/prose.md +141 -0
- package/docs/zh-CN/providers/anthropic.md +159 -0
- package/docs/zh-CN/providers/claude-max-api-proxy.md +155 -0
- package/docs/zh-CN/providers/deepgram.md +97 -0
- package/docs/zh-CN/providers/github-copilot.md +67 -0
- package/docs/zh-CN/providers/glm.md +39 -0
- package/docs/zh-CN/providers/index.md +68 -0
- package/docs/zh-CN/providers/minimax.md +206 -0
- package/docs/zh-CN/providers/models.md +55 -0
- package/docs/zh-CN/providers/moonshot.md +145 -0
- package/docs/zh-CN/providers/ollama.md +230 -0
- package/docs/zh-CN/providers/openai.md +68 -0
- package/docs/zh-CN/providers/opencode.md +41 -0
- package/docs/zh-CN/providers/openrouter.md +43 -0
- package/docs/zh-CN/providers/qwen.md +55 -0
- package/docs/zh-CN/providers/synthetic.md +102 -0
- package/docs/zh-CN/providers/venice.md +274 -0
- package/docs/zh-CN/providers/vercel-ai-gateway.md +57 -0
- package/docs/zh-CN/providers/xiaomi.md +68 -0
- package/docs/zh-CN/providers/zai.md +41 -0
- package/docs/zh-CN/railway.mdx +106 -0
- package/docs/zh-CN/refactor/clawnet.md +424 -0
- package/docs/zh-CN/refactor/exec-host.md +323 -0
- package/docs/zh-CN/refactor/outbound-session-mirroring.md +92 -0
- package/docs/zh-CN/refactor/plugin-sdk.md +221 -0
- package/docs/zh-CN/refactor/strict-config.md +100 -0
- package/docs/zh-CN/reference/AGENTS.default.md +131 -0
- package/docs/zh-CN/reference/RELEASING.md +123 -0
- package/docs/zh-CN/reference/api-usage-costs.md +136 -0
- package/docs/zh-CN/reference/device-models.md +54 -0
- package/docs/zh-CN/reference/rpc.md +48 -0
- package/docs/zh-CN/reference/session-management-compaction.md +287 -0
- package/docs/zh-CN/reference/templates/AGENTS.dev.md +89 -0
- package/docs/zh-CN/reference/templates/AGENTS.md +225 -0
- package/docs/zh-CN/reference/templates/BOOT.md +17 -0
- package/docs/zh-CN/reference/templates/BOOTSTRAP.md +68 -0
- package/docs/zh-CN/reference/templates/HEARTBEAT.md +18 -0
- package/docs/zh-CN/reference/templates/IDENTITY.dev.md +54 -0
- package/docs/zh-CN/reference/templates/IDENTITY.md +35 -0
- package/docs/zh-CN/reference/templates/SOUL.dev.md +83 -0
- package/docs/zh-CN/reference/templates/SOUL.md +49 -0
- package/docs/zh-CN/reference/templates/TOOLS.dev.md +31 -0
- package/docs/zh-CN/reference/templates/TOOLS.md +53 -0
- package/docs/zh-CN/reference/templates/USER.dev.md +25 -0
- package/docs/zh-CN/reference/templates/USER.md +30 -0
- package/docs/zh-CN/reference/test.md +57 -0
- package/docs/zh-CN/reference/transcript-hygiene.md +109 -0
- package/docs/zh-CN/render.mdx +169 -0
- package/docs/zh-CN/scripts.md +35 -0
- package/docs/zh-CN/security/formal-verification.md +171 -0
- package/docs/zh-CN/start/getting-started.md +206 -0
- package/docs/zh-CN/start/hubs.md +191 -0
- package/docs/zh-CN/start/lore.md +226 -0
- package/docs/zh-CN/start/onboarding.md +105 -0
- package/docs/zh-CN/start/openclaw.md +248 -0
- package/docs/zh-CN/start/pairing.md +89 -0
- package/docs/zh-CN/start/setup.md +153 -0
- package/docs/zh-CN/start/showcase.md +423 -0
- package/docs/zh-CN/start/wizard.md +331 -0
- package/docs/zh-CN/testing.md +375 -0
- package/docs/zh-CN/token-use.md +119 -0
- package/docs/zh-CN/tools/agent-send.md +59 -0
- package/docs/zh-CN/tools/apply-patch.md +57 -0
- package/docs/zh-CN/tools/browser-linux-troubleshooting.md +144 -0
- package/docs/zh-CN/tools/browser-login.md +75 -0
- package/docs/zh-CN/tools/browser.md +553 -0
- package/docs/zh-CN/tools/chrome-extension.md +183 -0
- package/docs/zh-CN/tools/clawhub.md +209 -0
- package/docs/zh-CN/tools/creating-skills.md +61 -0
- package/docs/zh-CN/tools/elevated.md +64 -0
- package/docs/zh-CN/tools/exec-approvals.md +234 -0
- package/docs/zh-CN/tools/exec.md +169 -0
- package/docs/zh-CN/tools/firecrawl.md +68 -0
- package/docs/zh-CN/tools/index.md +515 -0
- package/docs/zh-CN/tools/llm-task.md +117 -0
- package/docs/zh-CN/tools/lobster.md +349 -0
- package/docs/zh-CN/tools/reactions.md +29 -0
- package/docs/zh-CN/tools/skills-config.md +78 -0
- package/docs/zh-CN/tools/skills.md +279 -0
- package/docs/zh-CN/tools/slash-commands.md +205 -0
- package/docs/zh-CN/tools/subagents.md +156 -0
- package/docs/zh-CN/tools/thinking.md +80 -0
- package/docs/zh-CN/tools/web.md +257 -0
- package/docs/zh-CN/tts.md +375 -0
- package/docs/zh-CN/tui.md +166 -0
- package/docs/zh-CN/vps.md +47 -0
- package/docs/zh-CN/web/control-ui.md +191 -0
- package/docs/zh-CN/web/dashboard.md +53 -0
- package/docs/zh-CN/web/index.md +118 -0
- package/docs/zh-CN/web/webchat.md +56 -0
- package/extensions/bluebubbles/README.md +45 -0
- package/extensions/bluebubbles/index.ts +19 -0
- package/extensions/bluebubbles/node_modules/.bin/openclaw +21 -0
- package/extensions/bluebubbles/openclaw.plugin.json +9 -0
- package/extensions/bluebubbles/package.json +36 -0
- package/extensions/bluebubbles/src/accounts.ts +88 -0
- package/extensions/bluebubbles/src/actions.test.ts +650 -0
- package/extensions/bluebubbles/src/actions.ts +438 -0
- package/extensions/bluebubbles/src/attachments.test.ts +345 -0
- package/extensions/bluebubbles/src/attachments.ts +300 -0
- package/extensions/bluebubbles/src/channel.ts +414 -0
- package/extensions/bluebubbles/src/chat.test.ts +461 -0
- package/extensions/bluebubbles/src/chat.ts +378 -0
- package/extensions/bluebubbles/src/config-schema.ts +51 -0
- package/extensions/bluebubbles/src/media-send.ts +174 -0
- package/extensions/bluebubbles/src/monitor.test.ts +2342 -0
- package/extensions/bluebubbles/src/monitor.ts +2490 -0
- package/extensions/bluebubbles/src/onboarding.ts +352 -0
- package/extensions/bluebubbles/src/probe.ts +135 -0
- package/extensions/bluebubbles/src/reactions.test.ts +392 -0
- package/extensions/bluebubbles/src/reactions.ts +188 -0
- package/extensions/bluebubbles/src/runtime.ts +14 -0
- package/extensions/bluebubbles/src/send.test.ts +808 -0
- package/extensions/bluebubbles/src/send.ts +467 -0
- package/extensions/bluebubbles/src/targets.test.ts +183 -0
- package/extensions/bluebubbles/src/targets.ts +422 -0
- package/extensions/bluebubbles/src/types.ts +127 -0
- package/extensions/copilot-proxy/README.md +24 -0
- package/extensions/copilot-proxy/index.ts +148 -0
- package/extensions/copilot-proxy/node_modules/.bin/openclaw +21 -0
- package/extensions/copilot-proxy/openclaw.plugin.json +9 -0
- package/extensions/copilot-proxy/package.json +14 -0
- package/extensions/diagnostics-otel/index.ts +15 -0
- package/extensions/diagnostics-otel/node_modules/.bin/openclaw +21 -0
- package/extensions/diagnostics-otel/openclaw.plugin.json +8 -0
- package/extensions/diagnostics-otel/package.json +27 -0
- package/extensions/diagnostics-otel/src/service.test.ts +226 -0
- package/extensions/diagnostics-otel/src/service.ts +635 -0
- package/extensions/discord/index.ts +17 -0
- package/extensions/discord/node_modules/.bin/openclaw +21 -0
- package/extensions/discord/openclaw.plugin.json +9 -0
- package/extensions/discord/package.json +14 -0
- package/extensions/discord/src/channel.ts +422 -0
- package/extensions/discord/src/runtime.ts +14 -0
- package/extensions/feishu/README.md +47 -0
- package/extensions/feishu/index.ts +15 -0
- package/extensions/feishu/node_modules/.bin/openclaw +21 -0
- package/extensions/feishu/openclaw.plugin.json +9 -0
- package/extensions/feishu/package.json +33 -0
- package/extensions/feishu/src/channel.ts +276 -0
- package/extensions/feishu/src/config-schema.ts +46 -0
- package/extensions/feishu/src/onboarding.ts +278 -0
- package/extensions/google-antigravity-auth/README.md +24 -0
- package/extensions/google-antigravity-auth/index.ts +461 -0
- package/extensions/google-antigravity-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-antigravity-auth/openclaw.plugin.json +9 -0
- package/extensions/google-antigravity-auth/package.json +14 -0
- package/extensions/google-gemini-cli-auth/README.md +35 -0
- package/extensions/google-gemini-cli-auth/index.ts +88 -0
- package/extensions/google-gemini-cli-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/google-gemini-cli-auth/oauth.test.ts +240 -0
- package/extensions/google-gemini-cli-auth/oauth.ts +662 -0
- package/extensions/google-gemini-cli-auth/openclaw.plugin.json +9 -0
- package/extensions/google-gemini-cli-auth/package.json +14 -0
- package/extensions/googlechat/index.ts +19 -0
- package/extensions/googlechat/node_modules/.bin/openclaw +21 -0
- package/extensions/googlechat/openclaw.plugin.json +9 -0
- package/extensions/googlechat/package.json +39 -0
- package/extensions/googlechat/src/accounts.ts +147 -0
- package/extensions/googlechat/src/actions.ts +181 -0
- package/extensions/googlechat/src/api.test.ts +61 -0
- package/extensions/googlechat/src/api.ts +282 -0
- package/extensions/googlechat/src/auth.ts +123 -0
- package/extensions/googlechat/src/channel.ts +583 -0
- package/extensions/googlechat/src/monitor.test.ts +22 -0
- package/extensions/googlechat/src/monitor.ts +949 -0
- package/extensions/googlechat/src/onboarding.ts +269 -0
- package/extensions/googlechat/src/runtime.ts +14 -0
- package/extensions/googlechat/src/targets.test.ts +32 -0
- package/extensions/googlechat/src/targets.ts +65 -0
- package/extensions/googlechat/src/types.config.ts +3 -0
- package/extensions/googlechat/src/types.ts +73 -0
- package/extensions/imessage/index.ts +17 -0
- package/extensions/imessage/node_modules/.bin/openclaw +21 -0
- package/extensions/imessage/openclaw.plugin.json +9 -0
- package/extensions/imessage/package.json +14 -0
- package/extensions/imessage/src/channel.ts +294 -0
- package/extensions/imessage/src/runtime.ts +14 -0
- package/extensions/line/index.ts +19 -0
- package/extensions/line/node_modules/.bin/openclaw +21 -0
- package/extensions/line/openclaw.plugin.json +9 -0
- package/extensions/line/package.json +29 -0
- package/extensions/line/src/card-command.ts +344 -0
- package/extensions/line/src/channel.logout.test.ts +99 -0
- package/extensions/line/src/channel.sendPayload.test.ts +306 -0
- package/extensions/line/src/channel.ts +780 -0
- package/extensions/line/src/runtime.ts +14 -0
- package/extensions/llm-task/README.md +97 -0
- package/extensions/llm-task/index.ts +6 -0
- package/extensions/llm-task/node_modules/.bin/openclaw +21 -0
- package/extensions/llm-task/openclaw.plugin.json +21 -0
- package/extensions/llm-task/package.json +14 -0
- package/extensions/llm-task/src/llm-task-tool.test.ts +138 -0
- package/extensions/llm-task/src/llm-task-tool.ts +245 -0
- package/extensions/lobster/README.md +75 -0
- package/extensions/lobster/SKILL.md +97 -0
- package/extensions/lobster/index.ts +14 -0
- package/extensions/lobster/node_modules/.bin/openclaw +21 -0
- package/extensions/lobster/openclaw.plugin.json +10 -0
- package/extensions/lobster/package.json +14 -0
- package/extensions/lobster/src/lobster-tool.test.ts +247 -0
- package/extensions/lobster/src/lobster-tool.ts +328 -0
- package/extensions/matrix/CHANGELOG.md +87 -0
- package/extensions/matrix/index.ts +17 -0
- package/extensions/matrix/node_modules/.bin/markdown-it +21 -0
- package/extensions/matrix/node_modules/.bin/openclaw +21 -0
- package/extensions/matrix/openclaw.plugin.json +9 -0
- package/extensions/matrix/package.json +36 -0
- package/extensions/matrix/src/actions.ts +195 -0
- package/extensions/matrix/src/channel.directory.test.ts +64 -0
- package/extensions/matrix/src/channel.ts +439 -0
- package/extensions/matrix/src/config-schema.ts +62 -0
- package/extensions/matrix/src/directory-live.ts +188 -0
- package/extensions/matrix/src/group-mentions.ts +66 -0
- package/extensions/matrix/src/matrix/accounts.test.ts +82 -0
- package/extensions/matrix/src/matrix/accounts.ts +65 -0
- package/extensions/matrix/src/matrix/actions/client.ts +57 -0
- package/extensions/matrix/src/matrix/actions/messages.ts +128 -0
- package/extensions/matrix/src/matrix/actions/pins.ts +76 -0
- package/extensions/matrix/src/matrix/actions/reactions.ts +96 -0
- package/extensions/matrix/src/matrix/actions/room.ts +85 -0
- package/extensions/matrix/src/matrix/actions/summary.ts +75 -0
- package/extensions/matrix/src/matrix/actions/types.ts +84 -0
- package/extensions/matrix/src/matrix/actions.ts +15 -0
- package/extensions/matrix/src/matrix/active-client.ts +11 -0
- package/extensions/matrix/src/matrix/client/config.ts +160 -0
- package/extensions/matrix/src/matrix/client/create-client.ts +123 -0
- package/extensions/matrix/src/matrix/client/logging.ts +36 -0
- package/extensions/matrix/src/matrix/client/runtime.ts +4 -0
- package/extensions/matrix/src/matrix/client/shared.ts +170 -0
- package/extensions/matrix/src/matrix/client/storage.ts +131 -0
- package/extensions/matrix/src/matrix/client/types.ts +34 -0
- package/extensions/matrix/src/matrix/client.test.ts +56 -0
- package/extensions/matrix/src/matrix/client.ts +5 -0
- package/extensions/matrix/src/matrix/credentials.ts +105 -0
- package/extensions/matrix/src/matrix/deps.ts +60 -0
- package/extensions/matrix/src/matrix/format.test.ts +33 -0
- package/extensions/matrix/src/matrix/format.ts +22 -0
- package/extensions/matrix/src/matrix/index.ts +11 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.test.ts +45 -0
- package/extensions/matrix/src/matrix/monitor/allowlist.ts +103 -0
- package/extensions/matrix/src/matrix/monitor/auto-join.ts +71 -0
- package/extensions/matrix/src/matrix/monitor/direct.ts +104 -0
- package/extensions/matrix/src/matrix/monitor/events.ts +101 -0
- package/extensions/matrix/src/matrix/monitor/handler.ts +661 -0
- package/extensions/matrix/src/matrix/monitor/index.ts +338 -0
- package/extensions/matrix/src/matrix/monitor/location.ts +100 -0
- package/extensions/matrix/src/matrix/monitor/media.test.ts +102 -0
- package/extensions/matrix/src/matrix/monitor/media.ts +113 -0
- package/extensions/matrix/src/matrix/monitor/mentions.ts +31 -0
- package/extensions/matrix/src/matrix/monitor/replies.ts +97 -0
- package/extensions/matrix/src/matrix/monitor/room-info.ts +55 -0
- package/extensions/matrix/src/matrix/monitor/rooms.test.ts +39 -0
- package/extensions/matrix/src/matrix/monitor/rooms.ts +47 -0
- package/extensions/matrix/src/matrix/monitor/threads.ts +68 -0
- package/extensions/matrix/src/matrix/monitor/types.ts +39 -0
- package/extensions/matrix/src/matrix/poll-types.test.ts +21 -0
- package/extensions/matrix/src/matrix/poll-types.ts +166 -0
- package/extensions/matrix/src/matrix/probe.ts +70 -0
- package/extensions/matrix/src/matrix/send/client.ts +66 -0
- package/extensions/matrix/src/matrix/send/formatting.ts +89 -0
- package/extensions/matrix/src/matrix/send/media.ts +229 -0
- package/extensions/matrix/src/matrix/send/targets.test.ts +98 -0
- package/extensions/matrix/src/matrix/send/targets.ts +136 -0
- package/extensions/matrix/src/matrix/send/types.ts +109 -0
- package/extensions/matrix/src/matrix/send.test.ts +171 -0
- package/extensions/matrix/src/matrix/send.ts +260 -0
- package/extensions/matrix/src/onboarding.ts +449 -0
- package/extensions/matrix/src/outbound.ts +52 -0
- package/extensions/matrix/src/resolve-targets.test.ts +48 -0
- package/extensions/matrix/src/resolve-targets.ts +135 -0
- package/extensions/matrix/src/runtime.ts +14 -0
- package/extensions/matrix/src/tool-actions.ts +164 -0
- package/extensions/matrix/src/types.ts +95 -0
- package/extensions/mattermost/index.ts +17 -0
- package/extensions/mattermost/node_modules/.bin/openclaw +21 -0
- package/extensions/mattermost/openclaw.plugin.json +9 -0
- package/extensions/mattermost/package.json +28 -0
- package/extensions/mattermost/src/channel.test.ts +48 -0
- package/extensions/mattermost/src/channel.ts +337 -0
- package/extensions/mattermost/src/config-schema.ts +55 -0
- package/extensions/mattermost/src/group-mentions.ts +15 -0
- package/extensions/mattermost/src/mattermost/accounts.ts +128 -0
- package/extensions/mattermost/src/mattermost/client.ts +220 -0
- package/extensions/mattermost/src/mattermost/index.ts +9 -0
- package/extensions/mattermost/src/mattermost/monitor-helpers.ts +166 -0
- package/extensions/mattermost/src/mattermost/monitor.ts +987 -0
- package/extensions/mattermost/src/mattermost/probe.ts +74 -0
- package/extensions/mattermost/src/mattermost/send.ts +231 -0
- package/extensions/mattermost/src/normalize.ts +46 -0
- package/extensions/mattermost/src/onboarding-helpers.ts +44 -0
- package/extensions/mattermost/src/onboarding.ts +186 -0
- package/extensions/mattermost/src/runtime.ts +14 -0
- package/extensions/mattermost/src/types.ts +50 -0
- package/extensions/memory-core/index.ts +38 -0
- package/extensions/memory-core/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-core/openclaw.plugin.json +9 -0
- package/extensions/memory-core/package.json +17 -0
- package/extensions/memory-lancedb/config.ts +139 -0
- package/extensions/memory-lancedb/index.test.ts +295 -0
- package/extensions/memory-lancedb/index.ts +608 -0
- package/extensions/memory-lancedb/node_modules/.bin/openai +21 -0
- package/extensions/memory-lancedb/node_modules/.bin/openclaw +21 -0
- package/extensions/memory-lancedb/openclaw.plugin.json +60 -0
- package/extensions/memory-lancedb/package.json +19 -0
- package/extensions/minimax-portal-auth/README.md +33 -0
- package/extensions/minimax-portal-auth/index.ts +155 -0
- package/extensions/minimax-portal-auth/node_modules/.bin/openclaw +21 -0
- package/extensions/minimax-portal-auth/oauth.ts +247 -0
- package/extensions/minimax-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/minimax-portal-auth/package.json +14 -0
- package/extensions/msteams/CHANGELOG.md +83 -0
- package/extensions/msteams/index.ts +17 -0
- package/extensions/msteams/node_modules/.bin/openclaw +21 -0
- package/extensions/msteams/openclaw.plugin.json +9 -0
- package/extensions/msteams/package.json +39 -0
- package/extensions/msteams/src/attachments/download.ts +283 -0
- package/extensions/msteams/src/attachments/graph.ts +353 -0
- package/extensions/msteams/src/attachments/html.ts +90 -0
- package/extensions/msteams/src/attachments/payload.ts +22 -0
- package/extensions/msteams/src/attachments/shared.ts +291 -0
- package/extensions/msteams/src/attachments/types.ts +37 -0
- package/extensions/msteams/src/attachments.test.ts +459 -0
- package/extensions/msteams/src/attachments.ts +18 -0
- package/extensions/msteams/src/channel.directory.test.ts +48 -0
- package/extensions/msteams/src/channel.ts +459 -0
- package/extensions/msteams/src/conversation-store-fs.test.ts +88 -0
- package/extensions/msteams/src/conversation-store-fs.ts +165 -0
- package/extensions/msteams/src/conversation-store-memory.ts +47 -0
- package/extensions/msteams/src/conversation-store.ts +41 -0
- package/extensions/msteams/src/directory-live.ts +205 -0
- package/extensions/msteams/src/errors.test.ts +45 -0
- package/extensions/msteams/src/errors.ts +190 -0
- package/extensions/msteams/src/file-consent-helpers.test.ts +243 -0
- package/extensions/msteams/src/file-consent-helpers.ts +73 -0
- package/extensions/msteams/src/file-consent.ts +126 -0
- package/extensions/msteams/src/graph-chat.ts +53 -0
- package/extensions/msteams/src/graph-upload.ts +453 -0
- package/extensions/msteams/src/inbound.test.ts +66 -0
- package/extensions/msteams/src/inbound.ts +48 -0
- package/extensions/msteams/src/index.ts +4 -0
- package/extensions/msteams/src/media-helpers.test.ts +189 -0
- package/extensions/msteams/src/media-helpers.ts +86 -0
- package/extensions/msteams/src/messenger.test.ts +248 -0
- package/extensions/msteams/src/messenger.ts +495 -0
- package/extensions/msteams/src/monitor-handler/inbound-media.ts +128 -0
- package/extensions/msteams/src/monitor-handler/message-handler.ts +640 -0
- package/extensions/msteams/src/monitor-handler.ts +162 -0
- package/extensions/msteams/src/monitor-types.ts +5 -0
- package/extensions/msteams/src/monitor.ts +295 -0
- package/extensions/msteams/src/onboarding.ts +431 -0
- package/extensions/msteams/src/outbound.ts +46 -0
- package/extensions/msteams/src/pending-uploads.ts +89 -0
- package/extensions/msteams/src/policy.test.ts +209 -0
- package/extensions/msteams/src/policy.ts +273 -0
- package/extensions/msteams/src/polls-store-memory.ts +32 -0
- package/extensions/msteams/src/polls-store.test.ts +38 -0
- package/extensions/msteams/src/polls.test.ts +72 -0
- package/extensions/msteams/src/polls.ts +315 -0
- package/extensions/msteams/src/probe.test.ts +58 -0
- package/extensions/msteams/src/probe.ts +107 -0
- package/extensions/msteams/src/reply-dispatcher.ts +130 -0
- package/extensions/msteams/src/resolve-allowlist.ts +297 -0
- package/extensions/msteams/src/runtime.ts +14 -0
- package/extensions/msteams/src/sdk-types.ts +19 -0
- package/extensions/msteams/src/sdk.ts +33 -0
- package/extensions/msteams/src/send-context.ts +164 -0
- package/extensions/msteams/src/send.ts +519 -0
- package/extensions/msteams/src/sent-message-cache.test.ts +15 -0
- package/extensions/msteams/src/sent-message-cache.ts +47 -0
- package/extensions/msteams/src/storage.ts +25 -0
- package/extensions/msteams/src/store-fs.ts +83 -0
- package/extensions/msteams/src/token.ts +19 -0
- package/extensions/nextcloud-talk/index.ts +17 -0
- package/extensions/nextcloud-talk/node_modules/.bin/openclaw +21 -0
- package/extensions/nextcloud-talk/openclaw.plugin.json +9 -0
- package/extensions/nextcloud-talk/package.json +33 -0
- package/extensions/nextcloud-talk/src/accounts.ts +174 -0
- package/extensions/nextcloud-talk/src/channel.ts +409 -0
- package/extensions/nextcloud-talk/src/config-schema.ts +78 -0
- package/extensions/nextcloud-talk/src/format.ts +79 -0
- package/extensions/nextcloud-talk/src/inbound.ts +317 -0
- package/extensions/nextcloud-talk/src/monitor.ts +246 -0
- package/extensions/nextcloud-talk/src/normalize.ts +39 -0
- package/extensions/nextcloud-talk/src/onboarding.ts +343 -0
- package/extensions/nextcloud-talk/src/policy.test.ts +33 -0
- package/extensions/nextcloud-talk/src/policy.ts +180 -0
- package/extensions/nextcloud-talk/src/room-info.ts +125 -0
- package/extensions/nextcloud-talk/src/runtime.ts +14 -0
- package/extensions/nextcloud-talk/src/send.ts +210 -0
- package/extensions/nextcloud-talk/src/signature.ts +72 -0
- package/extensions/nextcloud-talk/src/types.ts +179 -0
- package/extensions/nostr/CHANGELOG.md +74 -0
- package/extensions/nostr/README.md +136 -0
- package/extensions/nostr/index.ts +68 -0
- package/extensions/nostr/node_modules/.bin/openclaw +21 -0
- package/extensions/nostr/openclaw.plugin.json +9 -0
- package/extensions/nostr/package.json +34 -0
- package/extensions/nostr/src/channel.test.ts +151 -0
- package/extensions/nostr/src/channel.ts +353 -0
- package/extensions/nostr/src/config-schema.ts +90 -0
- package/extensions/nostr/src/metrics.ts +478 -0
- package/extensions/nostr/src/nostr-bus.fuzz.test.ts +533 -0
- package/extensions/nostr/src/nostr-bus.integration.test.ts +448 -0
- package/extensions/nostr/src/nostr-bus.test.ts +199 -0
- package/extensions/nostr/src/nostr-bus.ts +715 -0
- package/extensions/nostr/src/nostr-profile-http.test.ts +378 -0
- package/extensions/nostr/src/nostr-profile-http.ts +519 -0
- package/extensions/nostr/src/nostr-profile-import.test.ts +119 -0
- package/extensions/nostr/src/nostr-profile-import.ts +262 -0
- package/extensions/nostr/src/nostr-profile.fuzz.test.ts +477 -0
- package/extensions/nostr/src/nostr-profile.test.ts +410 -0
- package/extensions/nostr/src/nostr-profile.ts +277 -0
- package/extensions/nostr/src/nostr-state-store.test.ts +131 -0
- package/extensions/nostr/src/nostr-state-store.ts +226 -0
- package/extensions/nostr/src/runtime.ts +14 -0
- package/extensions/nostr/src/seen-tracker.ts +303 -0
- package/extensions/nostr/src/types.test.ts +157 -0
- package/extensions/nostr/src/types.ts +101 -0
- package/extensions/nostr/test/setup.ts +5 -0
- package/extensions/open-prose/README.md +25 -0
- package/extensions/open-prose/index.ts +5 -0
- package/extensions/open-prose/node_modules/.bin/openclaw +21 -0
- package/extensions/open-prose/openclaw.plugin.json +11 -0
- package/extensions/open-prose/package.json +14 -0
- package/extensions/open-prose/skills/prose/LICENSE +21 -0
- package/extensions/open-prose/skills/prose/SKILL.md +323 -0
- package/extensions/open-prose/skills/prose/alt-borges.md +141 -0
- package/extensions/open-prose/skills/prose/alts/arabian-nights.md +358 -0
- package/extensions/open-prose/skills/prose/alts/borges.md +360 -0
- package/extensions/open-prose/skills/prose/alts/folk.md +322 -0
- package/extensions/open-prose/skills/prose/alts/homer.md +346 -0
- package/extensions/open-prose/skills/prose/alts/kafka.md +373 -0
- package/extensions/open-prose/skills/prose/compiler.md +2971 -0
- package/extensions/open-prose/skills/prose/examples/01-hello-world.prose +4 -0
- package/extensions/open-prose/skills/prose/examples/02-research-and-summarize.prose +6 -0
- package/extensions/open-prose/skills/prose/examples/03-code-review.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/04-write-and-refine.prose +14 -0
- package/extensions/open-prose/skills/prose/examples/05-debug-issue.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/06-explain-codebase.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/07-refactor.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/08-blog-post.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/09-research-with-agents.prose +25 -0
- package/extensions/open-prose/skills/prose/examples/10-code-review-agents.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/11-skills-and-imports.prose +27 -0
- package/extensions/open-prose/skills/prose/examples/12-secure-agent-permissions.prose +43 -0
- package/extensions/open-prose/skills/prose/examples/13-variables-and-context.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/14-composition-blocks.prose +48 -0
- package/extensions/open-prose/skills/prose/examples/15-inline-sequences.prose +23 -0
- package/extensions/open-prose/skills/prose/examples/16-parallel-reviews.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/17-parallel-research.prose +19 -0
- package/extensions/open-prose/skills/prose/examples/18-mixed-parallel-sequential.prose +36 -0
- package/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose +71 -0
- package/extensions/open-prose/skills/prose/examples/20-fixed-loops.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/21-pipeline-operations.prose +35 -0
- package/extensions/open-prose/skills/prose/examples/22-error-handling.prose +51 -0
- package/extensions/open-prose/skills/prose/examples/23-retry-with-backoff.prose +63 -0
- package/extensions/open-prose/skills/prose/examples/24-choice-blocks.prose +86 -0
- package/extensions/open-prose/skills/prose/examples/25-conditionals.prose +114 -0
- package/extensions/open-prose/skills/prose/examples/26-parameterized-blocks.prose +100 -0
- package/extensions/open-prose/skills/prose/examples/27-string-interpolation.prose +105 -0
- package/extensions/open-prose/skills/prose/examples/28-automated-pr-review.prose +37 -0
- package/extensions/open-prose/skills/prose/examples/28-gas-town.prose +1572 -0
- package/extensions/open-prose/skills/prose/examples/29-captains-chair.prose +218 -0
- package/extensions/open-prose/skills/prose/examples/30-captains-chair-simple.prose +42 -0
- package/extensions/open-prose/skills/prose/examples/31-captains-chair-with-memory.prose +145 -0
- package/extensions/open-prose/skills/prose/examples/33-pr-review-autofix.prose +168 -0
- package/extensions/open-prose/skills/prose/examples/34-content-pipeline.prose +204 -0
- package/extensions/open-prose/skills/prose/examples/35-feature-factory.prose +296 -0
- package/extensions/open-prose/skills/prose/examples/36-bug-hunter.prose +237 -0
- package/extensions/open-prose/skills/prose/examples/37-the-forge.prose +1474 -0
- package/extensions/open-prose/skills/prose/examples/38-skill-scan.prose +455 -0
- package/extensions/open-prose/skills/prose/examples/39-architect-by-simulation.prose +277 -0
- package/extensions/open-prose/skills/prose/examples/40-rlm-self-refine.prose +32 -0
- package/extensions/open-prose/skills/prose/examples/41-rlm-divide-conquer.prose +38 -0
- package/extensions/open-prose/skills/prose/examples/42-rlm-filter-recurse.prose +46 -0
- package/extensions/open-prose/skills/prose/examples/43-rlm-pairwise.prose +50 -0
- package/extensions/open-prose/skills/prose/examples/44-run-endpoint-ux-test.prose +261 -0
- package/extensions/open-prose/skills/prose/examples/45-plugin-release.prose +159 -0
- package/extensions/open-prose/skills/prose/examples/45-run-endpoint-ux-test-with-remediation.prose +637 -0
- package/extensions/open-prose/skills/prose/examples/46-run-endpoint-ux-test-fast.prose +148 -0
- package/extensions/open-prose/skills/prose/examples/46-workflow-crystallizer.prose +225 -0
- package/extensions/open-prose/skills/prose/examples/47-language-self-improvement.prose +356 -0
- package/extensions/open-prose/skills/prose/examples/48-habit-miner.prose +445 -0
- package/extensions/open-prose/skills/prose/examples/49-prose-run-retrospective.prose +210 -0
- package/extensions/open-prose/skills/prose/examples/README.md +391 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/README.md +22 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/iterative-refinement.prose +20 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/parallel-review.prose +18 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/simple-pipeline.prose +17 -0
- package/extensions/open-prose/skills/prose/examples/roadmap/syntax/open-prose-syntax.prose +223 -0
- package/extensions/open-prose/skills/prose/guidance/antipatterns.md +951 -0
- package/extensions/open-prose/skills/prose/guidance/patterns.md +700 -0
- package/extensions/open-prose/skills/prose/guidance/system-prompt.md +180 -0
- package/extensions/open-prose/skills/prose/help.md +144 -0
- package/extensions/open-prose/skills/prose/lib/README.md +108 -0
- package/extensions/open-prose/skills/prose/lib/calibrator.prose +215 -0
- package/extensions/open-prose/skills/prose/lib/cost-analyzer.prose +174 -0
- package/extensions/open-prose/skills/prose/lib/error-forensics.prose +250 -0
- package/extensions/open-prose/skills/prose/lib/inspector.prose +196 -0
- package/extensions/open-prose/skills/prose/lib/profiler.prose +460 -0
- package/extensions/open-prose/skills/prose/lib/program-improver.prose +275 -0
- package/extensions/open-prose/skills/prose/lib/project-memory.prose +118 -0
- package/extensions/open-prose/skills/prose/lib/user-memory.prose +93 -0
- package/extensions/open-prose/skills/prose/lib/vm-improver.prose +243 -0
- package/extensions/open-prose/skills/prose/primitives/session.md +593 -0
- package/extensions/open-prose/skills/prose/prose.md +1237 -0
- package/extensions/open-prose/skills/prose/state/filesystem.md +498 -0
- package/extensions/open-prose/skills/prose/state/in-context.md +384 -0
- package/extensions/open-prose/skills/prose/state/postgres.md +880 -0
- package/extensions/open-prose/skills/prose/state/sqlite.md +574 -0
- package/extensions/qwen-portal-auth/README.md +24 -0
- package/extensions/qwen-portal-auth/index.ts +130 -0
- package/extensions/qwen-portal-auth/oauth.ts +190 -0
- package/extensions/qwen-portal-auth/openclaw.plugin.json +9 -0
- package/extensions/signal/index.ts +17 -0
- package/extensions/signal/node_modules/.bin/openclaw +21 -0
- package/extensions/signal/openclaw.plugin.json +9 -0
- package/extensions/signal/package.json +14 -0
- package/extensions/signal/src/channel.ts +315 -0
- package/extensions/signal/src/runtime.ts +14 -0
- package/extensions/slack/index.ts +17 -0
- package/extensions/slack/node_modules/.bin/openclaw +21 -0
- package/extensions/slack/openclaw.plugin.json +9 -0
- package/extensions/slack/package.json +14 -0
- package/extensions/slack/src/channel.ts +604 -0
- package/extensions/slack/src/runtime.ts +14 -0
- package/extensions/telegram/index.ts +17 -0
- package/extensions/telegram/node_modules/.bin/openclaw +21 -0
- package/extensions/telegram/openclaw.plugin.json +9 -0
- package/extensions/telegram/package.json +14 -0
- package/extensions/telegram/src/channel.ts +482 -0
- package/extensions/telegram/src/runtime.ts +14 -0
- package/extensions/tlon/README.md +5 -0
- package/extensions/tlon/index.ts +17 -0
- package/extensions/tlon/node_modules/.bin/openclaw +21 -0
- package/extensions/tlon/openclaw.plugin.json +9 -0
- package/extensions/tlon/package.json +33 -0
- package/extensions/tlon/src/channel.ts +392 -0
- package/extensions/tlon/src/config-schema.test.ts +31 -0
- package/extensions/tlon/src/config-schema.ts +43 -0
- package/extensions/tlon/src/monitor/discovery.ts +76 -0
- package/extensions/tlon/src/monitor/history.ts +90 -0
- package/extensions/tlon/src/monitor/index.ts +553 -0
- package/extensions/tlon/src/monitor/processed-messages.test.ts +23 -0
- package/extensions/tlon/src/monitor/processed-messages.ts +46 -0
- package/extensions/tlon/src/monitor/utils.ts +105 -0
- package/extensions/tlon/src/onboarding.ts +214 -0
- package/extensions/tlon/src/runtime.ts +14 -0
- package/extensions/tlon/src/targets.ts +89 -0
- package/extensions/tlon/src/types.ts +92 -0
- package/extensions/tlon/src/urbit/auth.ts +18 -0
- package/extensions/tlon/src/urbit/http-api.ts +38 -0
- package/extensions/tlon/src/urbit/send.test.ts +38 -0
- package/extensions/tlon/src/urbit/send.ts +131 -0
- package/extensions/tlon/src/urbit/sse-client.test.ts +40 -0
- package/extensions/tlon/src/urbit/sse-client.ts +395 -0
- package/extensions/twitch/CHANGELOG.md +45 -0
- package/extensions/twitch/README.md +89 -0
- package/extensions/twitch/index.ts +20 -0
- package/extensions/twitch/node_modules/.bin/openclaw +21 -0
- package/extensions/twitch/openclaw.plugin.json +9 -0
- package/extensions/twitch/package.json +20 -0
- package/extensions/twitch/src/access-control.test.ts +489 -0
- package/extensions/twitch/src/access-control.ts +166 -0
- package/extensions/twitch/src/actions.ts +173 -0
- package/extensions/twitch/src/client-manager-registry.ts +115 -0
- package/extensions/twitch/src/config-schema.ts +82 -0
- package/extensions/twitch/src/config.test.ts +87 -0
- package/extensions/twitch/src/config.ts +116 -0
- package/extensions/twitch/src/monitor.ts +261 -0
- package/extensions/twitch/src/onboarding.test.ts +311 -0
- package/extensions/twitch/src/onboarding.ts +417 -0
- package/extensions/twitch/src/outbound.test.ts +373 -0
- package/extensions/twitch/src/outbound.ts +184 -0
- package/extensions/twitch/src/plugin.test.ts +39 -0
- package/extensions/twitch/src/plugin.ts +274 -0
- package/extensions/twitch/src/probe.test.ts +195 -0
- package/extensions/twitch/src/probe.ts +120 -0
- package/extensions/twitch/src/resolver.ts +137 -0
- package/extensions/twitch/src/runtime.ts +14 -0
- package/extensions/twitch/src/send.test.ts +289 -0
- package/extensions/twitch/src/send.ts +136 -0
- package/extensions/twitch/src/status.test.ts +270 -0
- package/extensions/twitch/src/status.ts +178 -0
- package/extensions/twitch/src/token.test.ts +171 -0
- package/extensions/twitch/src/token.ts +91 -0
- package/extensions/twitch/src/twitch-client.test.ts +589 -0
- package/extensions/twitch/src/twitch-client.ts +277 -0
- package/extensions/twitch/src/types.ts +141 -0
- package/extensions/twitch/src/utils/markdown.ts +98 -0
- package/extensions/twitch/src/utils/twitch.ts +78 -0
- package/extensions/twitch/test/setup.ts +7 -0
- package/extensions/voice-call/CHANGELOG.md +109 -0
- package/extensions/voice-call/README.md +139 -0
- package/extensions/voice-call/index.ts +493 -0
- package/extensions/voice-call/node_modules/.bin/openclaw +21 -0
- package/extensions/voice-call/openclaw.plugin.json +559 -0
- package/extensions/voice-call/package.json +19 -0
- package/extensions/voice-call/src/allowlist.ts +19 -0
- package/extensions/voice-call/src/cli.ts +279 -0
- package/extensions/voice-call/src/config.test.ts +234 -0
- package/extensions/voice-call/src/config.ts +523 -0
- package/extensions/voice-call/src/core-bridge.ts +159 -0
- package/extensions/voice-call/src/manager/context.ts +21 -0
- package/extensions/voice-call/src/manager/events.ts +188 -0
- package/extensions/voice-call/src/manager/lookup.ts +35 -0
- package/extensions/voice-call/src/manager/outbound.ts +275 -0
- package/extensions/voice-call/src/manager/state.ts +48 -0
- package/extensions/voice-call/src/manager/store.ts +91 -0
- package/extensions/voice-call/src/manager/timers.ts +89 -0
- package/extensions/voice-call/src/manager/twiml.ts +9 -0
- package/extensions/voice-call/src/manager.test.ts +194 -0
- package/extensions/voice-call/src/manager.ts +887 -0
- package/extensions/voice-call/src/media-stream.test.ts +96 -0
- package/extensions/voice-call/src/media-stream.ts +411 -0
- package/extensions/voice-call/src/providers/base.ts +67 -0
- package/extensions/voice-call/src/providers/index.ts +10 -0
- package/extensions/voice-call/src/providers/mock.ts +165 -0
- package/extensions/voice-call/src/providers/plivo.test.ts +27 -0
- package/extensions/voice-call/src/providers/plivo.ts +515 -0
- package/extensions/voice-call/src/providers/stt-openai-realtime.ts +311 -0
- package/extensions/voice-call/src/providers/telnyx.ts +371 -0
- package/extensions/voice-call/src/providers/tts-openai.ts +259 -0
- package/extensions/voice-call/src/providers/twilio/api.ts +42 -0
- package/extensions/voice-call/src/providers/twilio/webhook.ts +32 -0
- package/extensions/voice-call/src/providers/twilio.test.ts +60 -0
- package/extensions/voice-call/src/providers/twilio.ts +626 -0
- package/extensions/voice-call/src/response-generator.ts +158 -0
- package/extensions/voice-call/src/runtime.ts +212 -0
- package/extensions/voice-call/src/telephony-audio.ts +90 -0
- package/extensions/voice-call/src/telephony-tts.ts +104 -0
- package/extensions/voice-call/src/tunnel.ts +314 -0
- package/extensions/voice-call/src/types.ts +272 -0
- package/extensions/voice-call/src/utils.ts +14 -0
- package/extensions/voice-call/src/voice-mapping.ts +67 -0
- package/extensions/voice-call/src/webhook-security.test.ts +377 -0
- package/extensions/voice-call/src/webhook-security.ts +689 -0
- package/extensions/voice-call/src/webhook.ts +491 -0
- package/extensions/whatsapp/index.ts +17 -0
- package/extensions/whatsapp/node_modules/.bin/openclaw +21 -0
- package/extensions/whatsapp/openclaw.plugin.json +9 -0
- package/extensions/whatsapp/package.json +14 -0
- package/extensions/whatsapp/src/channel.ts +508 -0
- package/extensions/whatsapp/src/runtime.ts +14 -0
- package/extensions/zalo/CHANGELOG.md +89 -0
- package/extensions/zalo/README.md +50 -0
- package/extensions/zalo/index.ts +19 -0
- package/extensions/zalo/node_modules/.bin/openclaw +21 -0
- package/extensions/zalo/openclaw.plugin.json +9 -0
- package/extensions/zalo/package.json +36 -0
- package/extensions/zalo/src/accounts.ts +80 -0
- package/extensions/zalo/src/actions.ts +67 -0
- package/extensions/zalo/src/api.ts +208 -0
- package/extensions/zalo/src/channel.directory.test.ts +43 -0
- package/extensions/zalo/src/channel.ts +414 -0
- package/extensions/zalo/src/config-schema.ts +24 -0
- package/extensions/zalo/src/monitor.ts +753 -0
- package/extensions/zalo/src/monitor.webhook.test.ts +73 -0
- package/extensions/zalo/src/onboarding.ts +401 -0
- package/extensions/zalo/src/probe.ts +46 -0
- package/extensions/zalo/src/proxy.ts +21 -0
- package/extensions/zalo/src/runtime.ts +14 -0
- package/extensions/zalo/src/send.ts +124 -0
- package/extensions/zalo/src/status-issues.ts +53 -0
- package/extensions/zalo/src/token.ts +63 -0
- package/extensions/zalo/src/types.ts +42 -0
- package/extensions/zalouser/CHANGELOG.md +61 -0
- package/extensions/zalouser/README.md +225 -0
- package/extensions/zalouser/index.ts +31 -0
- package/extensions/zalouser/node_modules/.bin/openclaw +21 -0
- package/extensions/zalouser/openclaw.plugin.json +9 -0
- package/extensions/zalouser/package.json +36 -0
- package/extensions/zalouser/src/accounts.ts +135 -0
- package/extensions/zalouser/src/channel.test.ts +18 -0
- package/extensions/zalouser/src/channel.ts +686 -0
- package/extensions/zalouser/src/config-schema.ts +27 -0
- package/extensions/zalouser/src/monitor.ts +590 -0
- package/extensions/zalouser/src/onboarding.ts +504 -0
- package/extensions/zalouser/src/probe.ts +28 -0
- package/extensions/zalouser/src/runtime.ts +14 -0
- package/extensions/zalouser/src/send.ts +160 -0
- package/extensions/zalouser/src/status-issues.test.ts +57 -0
- package/extensions/zalouser/src/status-issues.ts +89 -0
- package/extensions/zalouser/src/tool.ts +164 -0
- package/extensions/zalouser/src/types.ts +108 -0
- package/extensions/zalouser/src/zca.ts +202 -0
- package/openclaw.mjs +14 -0
- package/package.json +245 -0
- package/skills/1password/SKILL.md +70 -0
- package/skills/1password/references/cli-examples.md +29 -0
- package/skills/1password/references/get-started.md +17 -0
- package/skills/apple-notes/SKILL.md +77 -0
- package/skills/apple-reminders/SKILL.md +96 -0
- package/skills/bear-notes/SKILL.md +107 -0
- package/skills/bird/SKILL.md +224 -0
- package/skills/blogwatcher/SKILL.md +69 -0
- package/skills/blucli/SKILL.md +47 -0
- package/skills/bluebubbles/SKILL.md +131 -0
- package/skills/camsnap/SKILL.md +45 -0
- package/skills/canvas/SKILL.md +198 -0
- package/skills/clawhub/SKILL.md +77 -0
- package/skills/coding-agent/SKILL.md +284 -0
- package/skills/discord/SKILL.md +578 -0
- package/skills/eightctl/SKILL.md +50 -0
- package/skills/food-order/SKILL.md +48 -0
- package/skills/gemini/SKILL.md +43 -0
- package/skills/ghostly-projects/SKILL.md +160 -0
- package/skills/gifgrep/SKILL.md +79 -0
- package/skills/github/SKILL.md +77 -0
- package/skills/gog/SKILL.md +116 -0
- package/skills/goplaces/SKILL.md +52 -0
- package/skills/healthcheck/SKILL.md +245 -0
- package/skills/himalaya/SKILL.md +257 -0
- package/skills/himalaya/references/configuration.md +184 -0
- package/skills/himalaya/references/message-composition.md +199 -0
- package/skills/imsg/SKILL.md +74 -0
- package/skills/linear/SKILL.md +111 -0
- package/skills/linear/linear.sh +204 -0
- package/skills/local-places/SERVER_README.md +101 -0
- package/skills/local-places/SKILL.md +102 -0
- package/skills/local-places/pyproject.toml +21 -0
- package/skills/local-places/src/local_places/__init__.py +2 -0
- package/skills/local-places/src/local_places/google_places.py +314 -0
- package/skills/local-places/src/local_places/main.py +65 -0
- package/skills/local-places/src/local_places/schemas.py +107 -0
- package/skills/mcporter/SKILL.md +61 -0
- package/skills/model-usage/SKILL.md +69 -0
- package/skills/model-usage/references/codexbar-cli.md +33 -0
- package/skills/model-usage/scripts/model_usage.py +310 -0
- package/skills/nano-banana-pro/SKILL.md +58 -0
- package/skills/nano-banana-pro/scripts/generate_image.py +184 -0
- package/skills/nano-pdf/SKILL.md +38 -0
- package/skills/notion/SKILL.md +172 -0
- package/skills/obsidian/SKILL.md +81 -0
- package/skills/openai-image-gen/SKILL.md +89 -0
- package/skills/openai-image-gen/scripts/gen.py +240 -0
- package/skills/openai-whisper/SKILL.md +38 -0
- package/skills/openai-whisper-api/SKILL.md +52 -0
- package/skills/openai-whisper-api/scripts/transcribe.sh +85 -0
- package/skills/openhue/SKILL.md +51 -0
- package/skills/oracle/SKILL.md +125 -0
- package/skills/ordercli/SKILL.md +78 -0
- package/skills/peekaboo/SKILL.md +190 -0
- package/skills/sag/SKILL.md +87 -0
- package/skills/session-logs/SKILL.md +115 -0
- package/skills/sherpa-onnx-tts/SKILL.md +103 -0
- package/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts +178 -0
- package/skills/skill-creator/SKILL.md +370 -0
- package/skills/skill-creator/license.txt +202 -0
- package/skills/skill-creator/scripts/init_skill.py +378 -0
- package/skills/skill-creator/scripts/package_skill.py +111 -0
- package/skills/skill-creator/scripts/quick_validate.py +101 -0
- package/skills/slack/SKILL.md +144 -0
- package/skills/songsee/SKILL.md +49 -0
- package/skills/sonoscli/SKILL.md +46 -0
- package/skills/spotify-player/SKILL.md +64 -0
- package/skills/summarize/SKILL.md +87 -0
- package/skills/things-mac/SKILL.md +86 -0
- package/skills/tmux/SKILL.md +135 -0
- package/skills/tmux/scripts/find-sessions.sh +112 -0
- package/skills/tmux/scripts/wait-for-text.sh +83 -0
- package/skills/trello/SKILL.md +95 -0
- package/skills/video-frames/SKILL.md +46 -0
- package/skills/video-frames/scripts/frame.sh +81 -0
- package/skills/voice-call/SKILL.md +45 -0
- package/skills/wacli/SKILL.md +72 -0
- package/skills/weather/SKILL.md +54 -0
|
@@ -0,0 +1,3327 @@
|
|
|
1
|
+
import { p as defaultRuntime } from "./entry.js";
|
|
2
|
+
import { C as buildAllowedModelSet, D as modelKey, J as SYNTHETIC_DEFAULT_MODEL_REF, O as normalizeProviderId, Q as getCustomProviderApiKey, S as resolveOpenClawAgentDir, W as VENICE_DEFAULT_MODEL_REF, _ as ensureAuthProfileStore, c as CHUTES_AUTHORIZE_ENDPOINT, d as parseOAuthCallbackInput, g as upsertAuthProfile, ht as DEFAULT_PROVIDER, j as resolveConfiguredModelRef, l as exchangeChutesCodeForTokens, mt as DEFAULT_MODEL, n as resolveAuthProfileOrder, nt as resolveEnvApiKey, p as listProfilesForProvider, u as generateChutesPkce, ut as CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF, w as buildModelAliasIndex } from "./auth-profiles-DVLfuixr.js";
|
|
3
|
+
import { t as formatCliCommand } from "./command-format-ayFsmwwz.js";
|
|
4
|
+
import { a as resolveAgentModelPrimary, c as resolveDefaultAgentId, r as resolveAgentDir, s as resolveAgentWorkspaceDir, w as resolveDefaultAgentWorkspaceDir } from "./agent-scope-C_O6Vpl0.js";
|
|
5
|
+
import { d as resolveConfigDir, m as resolveUserPath, o as ensureDir, t as CONFIG_DIR } from "./utils-DX85MiPR.js";
|
|
6
|
+
import { t as runCommandWithTimeout } from "./exec-B8JKbXKW.js";
|
|
7
|
+
import { n as resolveOpenClawPackageRootSync, t as resolveOpenClawPackageRoot } from "./openclaw-root-9ILYSmJ9.js";
|
|
8
|
+
import { t as resolveBrewExecutable } from "./brew-DyBGNK8A.js";
|
|
9
|
+
import { Kt as loadModelCatalog, m as openUrl, o as detectBinary, y as resolveNodeManagerOptions } from "./loader-Cn4EV_pf.js";
|
|
10
|
+
import { a as enablePluginInConfig } from "./onboard-channels-CHBDi-ZA.js";
|
|
11
|
+
import { R as fetchWithSsrFGuard } from "./deliver-BxK5nI2P.js";
|
|
12
|
+
import { _ as resolveSkillKey, d as hasBinary, i as loadWorkspaceSkillEntries, t as resolveSkillsInstallPreferences } from "./skills-Bhp0l6UK.js";
|
|
13
|
+
import { n as resolveWideAreaDiscoveryDomain } from "./widearea-dns-BpG7ATO8.js";
|
|
14
|
+
import { $ as setVeniceApiKey, A as applySyntheticProviderConfig, B as OPENROUTER_DEFAULT_MODEL_REF, C as applyMoonshotConfig, D as applyOpenrouterConfig, E as applyMoonshotProviderConfigCn, F as applyXiaomiConfig, G as setCloudflareAiGatewayConfig, H as XIAOMI_DEFAULT_MODEL_REF, I as applyXiaomiProviderConfig, J as setMinimaxApiKey, K as setGeminiApiKey, L as applyZaiConfig, M as applyVeniceProviderConfig, N as applyVercelAiGatewayConfig, O as applyOpenrouterProviderConfig, P as applyVercelAiGatewayProviderConfig, Q as setSyntheticApiKey, R as KIMI_CODING_MODEL_REF, S as applyKimiCodeProviderConfig, T as applyMoonshotProviderConfig, U as ZAI_DEFAULT_MODEL_REF, V as VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF, W as setAnthropicApiKey, X as setOpencodeZenApiKey, Y as setMoonshotApiKey, Z as setOpenrouterApiKey, _ as applyMinimaxProviderConfig, at as validateAnthropicSetupToken, b as applyCloudflareAiGatewayProviderConfig, d as resolvePluginProviders, et as setVercelAiGatewayApiKey, f as applyOpencodeZenConfig, g as applyMinimaxConfig, h as applyMinimaxApiProviderConfig, i as formatTokenK, it as buildTokenProfileId, j as applyVeniceConfig, k as applySyntheticConfig, l as createVpsAwareOAuthHandlers, m as applyMinimaxApiConfig, nt as setZaiApiKey, p as applyOpencodeZenProviderConfig, q as setKimiCodingApiKey, rt as writeOAuthCredentials, t as githubCopilotLoginCommand, tt as setXiaomiApiKey, u as isRemoteEnvironment, v as applyAuthProfileConfig, w as applyMoonshotConfigCn, x as applyKimiCodeConfig, y as applyCloudflareAiGatewayConfig, z as MOONSHOT_DEFAULT_MODEL_REF } from "./github-copilot-auth-DeGYyLY9.js";
|
|
15
|
+
import { t as buildWorkspaceSkillStatus } from "./skills-status-DX1eUYvk.js";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import fs from "node:fs";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
import { loginOpenAICodex } from "@mariozechner/pi-ai";
|
|
20
|
+
import { randomBytes } from "node:crypto";
|
|
21
|
+
import { createServer } from "node:http";
|
|
22
|
+
import { Readable } from "node:stream";
|
|
23
|
+
import { pipeline } from "node:stream/promises";
|
|
24
|
+
|
|
25
|
+
//#region src/infra/bonjour-discovery.ts
|
|
26
|
+
const DEFAULT_TIMEOUT_MS = 2e3;
|
|
27
|
+
const GATEWAY_SERVICE_TYPE = "_openclaw-gw._tcp";
|
|
28
|
+
function decodeDnsSdEscapes(value) {
|
|
29
|
+
let decoded = false;
|
|
30
|
+
const bytes = [];
|
|
31
|
+
let pending = "";
|
|
32
|
+
const flush = () => {
|
|
33
|
+
if (!pending) return;
|
|
34
|
+
bytes.push(...Buffer.from(pending, "utf8"));
|
|
35
|
+
pending = "";
|
|
36
|
+
};
|
|
37
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
38
|
+
const ch = value[i] ?? "";
|
|
39
|
+
if (ch === "\\" && i + 3 < value.length) {
|
|
40
|
+
const escaped = value.slice(i + 1, i + 4);
|
|
41
|
+
if (/^[0-9]{3}$/.test(escaped)) {
|
|
42
|
+
const byte = Number.parseInt(escaped, 10);
|
|
43
|
+
if (!Number.isFinite(byte) || byte < 0 || byte > 255) {
|
|
44
|
+
pending += ch;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
flush();
|
|
48
|
+
bytes.push(byte);
|
|
49
|
+
decoded = true;
|
|
50
|
+
i += 3;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
pending += ch;
|
|
55
|
+
}
|
|
56
|
+
if (!decoded) return value;
|
|
57
|
+
flush();
|
|
58
|
+
return Buffer.from(bytes).toString("utf8");
|
|
59
|
+
}
|
|
60
|
+
function isTailnetIPv4(address) {
|
|
61
|
+
const parts = address.split(".");
|
|
62
|
+
if (parts.length !== 4) return false;
|
|
63
|
+
const octets = parts.map((p) => Number.parseInt(p, 10));
|
|
64
|
+
if (octets.some((n) => !Number.isFinite(n) || n < 0 || n > 255)) return false;
|
|
65
|
+
const [a, b] = octets;
|
|
66
|
+
return a === 100 && b >= 64 && b <= 127;
|
|
67
|
+
}
|
|
68
|
+
function parseDigShortLines(stdout) {
|
|
69
|
+
return stdout.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
70
|
+
}
|
|
71
|
+
function parseDigTxt(stdout) {
|
|
72
|
+
const tokens = [];
|
|
73
|
+
for (const raw of stdout.split("\n")) {
|
|
74
|
+
const line = raw.trim();
|
|
75
|
+
if (!line) continue;
|
|
76
|
+
const matches = Array.from(line.matchAll(/"([^"]*)"/g), (m) => m[1] ?? "");
|
|
77
|
+
for (const m of matches) {
|
|
78
|
+
const unescaped = m.replaceAll("\\\\", "\\").replaceAll("\\\"", "\"").replaceAll("\\n", "\n");
|
|
79
|
+
tokens.push(unescaped);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return tokens;
|
|
83
|
+
}
|
|
84
|
+
function parseDigSrv(stdout) {
|
|
85
|
+
const line = stdout.split("\n").map((l) => l.trim()).find(Boolean);
|
|
86
|
+
if (!line) return null;
|
|
87
|
+
const parts = line.split(/\s+/).filter(Boolean);
|
|
88
|
+
if (parts.length < 4) return null;
|
|
89
|
+
const port = Number.parseInt(parts[2] ?? "", 10);
|
|
90
|
+
const hostRaw = parts[3] ?? "";
|
|
91
|
+
if (!Number.isFinite(port) || port <= 0) return null;
|
|
92
|
+
const host = hostRaw.replace(/\.$/, "");
|
|
93
|
+
if (!host) return null;
|
|
94
|
+
return {
|
|
95
|
+
host,
|
|
96
|
+
port
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function parseTailscaleStatusIPv4s(stdout) {
|
|
100
|
+
const parsed = stdout ? JSON.parse(stdout) : {};
|
|
101
|
+
const out = [];
|
|
102
|
+
const addIps = (value) => {
|
|
103
|
+
if (!value || typeof value !== "object") return;
|
|
104
|
+
const ips = value.TailscaleIPs;
|
|
105
|
+
if (!Array.isArray(ips)) return;
|
|
106
|
+
for (const ip of ips) {
|
|
107
|
+
if (typeof ip !== "string") continue;
|
|
108
|
+
const trimmed = ip.trim();
|
|
109
|
+
if (trimmed && isTailnetIPv4(trimmed)) out.push(trimmed);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
addIps(parsed.Self);
|
|
113
|
+
const peerObj = parsed.Peer;
|
|
114
|
+
if (peerObj && typeof peerObj === "object") for (const peer of Object.values(peerObj)) addIps(peer);
|
|
115
|
+
return [...new Set(out)];
|
|
116
|
+
}
|
|
117
|
+
function parseIntOrNull(value) {
|
|
118
|
+
if (!value) return;
|
|
119
|
+
const parsed = Number.parseInt(value, 10);
|
|
120
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
121
|
+
}
|
|
122
|
+
function parseTxtTokens(tokens) {
|
|
123
|
+
const txt = {};
|
|
124
|
+
for (const token of tokens) {
|
|
125
|
+
const idx = token.indexOf("=");
|
|
126
|
+
if (idx <= 0) continue;
|
|
127
|
+
const key = token.slice(0, idx).trim();
|
|
128
|
+
const value = decodeDnsSdEscapes(token.slice(idx + 1).trim());
|
|
129
|
+
if (!key) continue;
|
|
130
|
+
txt[key] = value;
|
|
131
|
+
}
|
|
132
|
+
return txt;
|
|
133
|
+
}
|
|
134
|
+
function parseDnsSdBrowse(stdout) {
|
|
135
|
+
const instances = /* @__PURE__ */ new Set();
|
|
136
|
+
for (const raw of stdout.split("\n")) {
|
|
137
|
+
const line = raw.trim();
|
|
138
|
+
if (!line || !line.includes(GATEWAY_SERVICE_TYPE)) continue;
|
|
139
|
+
if (!line.includes("Add")) continue;
|
|
140
|
+
const match = line.match(/_openclaw-gw\._tcp\.?\s+(.+)$/);
|
|
141
|
+
if (match?.[1]) instances.add(decodeDnsSdEscapes(match[1].trim()));
|
|
142
|
+
}
|
|
143
|
+
return Array.from(instances.values());
|
|
144
|
+
}
|
|
145
|
+
function parseDnsSdResolve(stdout, instanceName) {
|
|
146
|
+
const decodedInstanceName = decodeDnsSdEscapes(instanceName);
|
|
147
|
+
const beacon = { instanceName: decodedInstanceName };
|
|
148
|
+
let txt = {};
|
|
149
|
+
for (const raw of stdout.split("\n")) {
|
|
150
|
+
const line = raw.trim();
|
|
151
|
+
if (!line) continue;
|
|
152
|
+
if (line.includes("can be reached at")) {
|
|
153
|
+
const match = line.match(/can be reached at\s+([^\s:]+):(\d+)/i);
|
|
154
|
+
if (match?.[1]) beacon.host = match[1].replace(/\.$/, "");
|
|
155
|
+
if (match?.[2]) beacon.port = parseIntOrNull(match[2]);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (line.startsWith("txt") || line.includes("txtvers=")) txt = parseTxtTokens(line.split(/\s+/).filter(Boolean));
|
|
159
|
+
}
|
|
160
|
+
beacon.txt = Object.keys(txt).length ? txt : void 0;
|
|
161
|
+
if (txt.displayName) beacon.displayName = decodeDnsSdEscapes(txt.displayName);
|
|
162
|
+
if (txt.lanHost) beacon.lanHost = txt.lanHost;
|
|
163
|
+
if (txt.tailnetDns) beacon.tailnetDns = txt.tailnetDns;
|
|
164
|
+
if (txt.cliPath) beacon.cliPath = txt.cliPath;
|
|
165
|
+
beacon.gatewayPort = parseIntOrNull(txt.gatewayPort);
|
|
166
|
+
beacon.sshPort = parseIntOrNull(txt.sshPort);
|
|
167
|
+
if (txt.gatewayTls) {
|
|
168
|
+
const raw = txt.gatewayTls.trim().toLowerCase();
|
|
169
|
+
beacon.gatewayTls = raw === "1" || raw === "true" || raw === "yes";
|
|
170
|
+
}
|
|
171
|
+
if (txt.gatewayTlsSha256) beacon.gatewayTlsFingerprintSha256 = txt.gatewayTlsSha256;
|
|
172
|
+
if (txt.role) beacon.role = txt.role;
|
|
173
|
+
if (txt.transport) beacon.transport = txt.transport;
|
|
174
|
+
if (!beacon.displayName) beacon.displayName = decodedInstanceName;
|
|
175
|
+
return beacon;
|
|
176
|
+
}
|
|
177
|
+
async function discoverViaDnsSd(domain, timeoutMs, run) {
|
|
178
|
+
const instances = parseDnsSdBrowse((await run([
|
|
179
|
+
"dns-sd",
|
|
180
|
+
"-B",
|
|
181
|
+
GATEWAY_SERVICE_TYPE,
|
|
182
|
+
domain
|
|
183
|
+
], { timeoutMs })).stdout);
|
|
184
|
+
const results = [];
|
|
185
|
+
for (const instance of instances) {
|
|
186
|
+
const parsed = parseDnsSdResolve((await run([
|
|
187
|
+
"dns-sd",
|
|
188
|
+
"-L",
|
|
189
|
+
instance,
|
|
190
|
+
GATEWAY_SERVICE_TYPE,
|
|
191
|
+
domain
|
|
192
|
+
], { timeoutMs })).stdout, instance);
|
|
193
|
+
if (parsed) results.push({
|
|
194
|
+
...parsed,
|
|
195
|
+
domain
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return results;
|
|
199
|
+
}
|
|
200
|
+
async function discoverWideAreaViaTailnetDns(domain, timeoutMs, run) {
|
|
201
|
+
if (!domain || domain === "local.") return [];
|
|
202
|
+
const startedAt = Date.now();
|
|
203
|
+
const remainingMs = () => timeoutMs - (Date.now() - startedAt);
|
|
204
|
+
const tailscaleCandidates = ["tailscale", "/Applications/Tailscale.app/Contents/MacOS/Tailscale"];
|
|
205
|
+
let ips = [];
|
|
206
|
+
for (const candidate of tailscaleCandidates) try {
|
|
207
|
+
ips = parseTailscaleStatusIPv4s((await run([
|
|
208
|
+
candidate,
|
|
209
|
+
"status",
|
|
210
|
+
"--json"
|
|
211
|
+
], { timeoutMs: Math.max(1, Math.min(700, remainingMs())) })).stdout);
|
|
212
|
+
if (ips.length > 0) break;
|
|
213
|
+
} catch {}
|
|
214
|
+
if (ips.length === 0) return [];
|
|
215
|
+
if (remainingMs() <= 0) return [];
|
|
216
|
+
ips = ips.slice(0, 40);
|
|
217
|
+
const probeName = `${GATEWAY_SERVICE_TYPE}.${domain.replace(/\.$/, "")}`;
|
|
218
|
+
const concurrency = 6;
|
|
219
|
+
let nextIndex = 0;
|
|
220
|
+
let nameserver = null;
|
|
221
|
+
let ptrs = [];
|
|
222
|
+
const worker = async () => {
|
|
223
|
+
while (nameserver === null) {
|
|
224
|
+
const budget = remainingMs();
|
|
225
|
+
if (budget <= 0) return;
|
|
226
|
+
const i = nextIndex;
|
|
227
|
+
nextIndex += 1;
|
|
228
|
+
if (i >= ips.length) return;
|
|
229
|
+
const ip = ips[i] ?? "";
|
|
230
|
+
if (!ip) continue;
|
|
231
|
+
try {
|
|
232
|
+
const lines = parseDigShortLines((await run([
|
|
233
|
+
"dig",
|
|
234
|
+
"+short",
|
|
235
|
+
"+time=1",
|
|
236
|
+
"+tries=1",
|
|
237
|
+
`@${ip}`,
|
|
238
|
+
probeName,
|
|
239
|
+
"PTR"
|
|
240
|
+
], { timeoutMs: Math.max(1, Math.min(250, budget)) })).stdout);
|
|
241
|
+
if (lines.length === 0) continue;
|
|
242
|
+
nameserver = ip;
|
|
243
|
+
ptrs = lines;
|
|
244
|
+
return;
|
|
245
|
+
} catch {}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, ips.length) }, () => worker()));
|
|
249
|
+
if (!nameserver || ptrs.length === 0) return [];
|
|
250
|
+
if (remainingMs() <= 0) return [];
|
|
251
|
+
const nameserverArg = `@${String(nameserver)}`;
|
|
252
|
+
const results = [];
|
|
253
|
+
for (const ptr of ptrs) {
|
|
254
|
+
const budget = remainingMs();
|
|
255
|
+
if (budget <= 0) break;
|
|
256
|
+
const ptrName = ptr.trim().replace(/\.$/, "");
|
|
257
|
+
if (!ptrName) continue;
|
|
258
|
+
const instanceName = ptrName.replace(/\.?_openclaw-gw\._tcp\..*$/, "");
|
|
259
|
+
const srv = await run([
|
|
260
|
+
"dig",
|
|
261
|
+
"+short",
|
|
262
|
+
"+time=1",
|
|
263
|
+
"+tries=1",
|
|
264
|
+
nameserverArg,
|
|
265
|
+
ptrName,
|
|
266
|
+
"SRV"
|
|
267
|
+
], { timeoutMs: Math.max(1, Math.min(350, budget)) }).catch(() => null);
|
|
268
|
+
const srvParsed = srv ? parseDigSrv(srv.stdout) : null;
|
|
269
|
+
if (!srvParsed) continue;
|
|
270
|
+
const txtBudget = remainingMs();
|
|
271
|
+
if (txtBudget <= 0) {
|
|
272
|
+
results.push({
|
|
273
|
+
instanceName: instanceName || ptrName,
|
|
274
|
+
displayName: instanceName || ptrName,
|
|
275
|
+
domain,
|
|
276
|
+
host: srvParsed.host,
|
|
277
|
+
port: srvParsed.port
|
|
278
|
+
});
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const txt = await run([
|
|
282
|
+
"dig",
|
|
283
|
+
"+short",
|
|
284
|
+
"+time=1",
|
|
285
|
+
"+tries=1",
|
|
286
|
+
nameserverArg,
|
|
287
|
+
ptrName,
|
|
288
|
+
"TXT"
|
|
289
|
+
], { timeoutMs: Math.max(1, Math.min(350, txtBudget)) }).catch(() => null);
|
|
290
|
+
const txtTokens = txt ? parseDigTxt(txt.stdout) : [];
|
|
291
|
+
const txtMap = txtTokens.length > 0 ? parseTxtTokens(txtTokens) : {};
|
|
292
|
+
const beacon = {
|
|
293
|
+
instanceName: instanceName || ptrName,
|
|
294
|
+
displayName: txtMap.displayName || instanceName || ptrName,
|
|
295
|
+
domain,
|
|
296
|
+
host: srvParsed.host,
|
|
297
|
+
port: srvParsed.port,
|
|
298
|
+
txt: Object.keys(txtMap).length ? txtMap : void 0,
|
|
299
|
+
gatewayPort: parseIntOrNull(txtMap.gatewayPort),
|
|
300
|
+
sshPort: parseIntOrNull(txtMap.sshPort),
|
|
301
|
+
tailnetDns: txtMap.tailnetDns || void 0,
|
|
302
|
+
cliPath: txtMap.cliPath || void 0
|
|
303
|
+
};
|
|
304
|
+
if (txtMap.gatewayTls) {
|
|
305
|
+
const raw = txtMap.gatewayTls.trim().toLowerCase();
|
|
306
|
+
beacon.gatewayTls = raw === "1" || raw === "true" || raw === "yes";
|
|
307
|
+
}
|
|
308
|
+
if (txtMap.gatewayTlsSha256) beacon.gatewayTlsFingerprintSha256 = txtMap.gatewayTlsSha256;
|
|
309
|
+
if (txtMap.role) beacon.role = txtMap.role;
|
|
310
|
+
if (txtMap.transport) beacon.transport = txtMap.transport;
|
|
311
|
+
results.push(beacon);
|
|
312
|
+
}
|
|
313
|
+
return results;
|
|
314
|
+
}
|
|
315
|
+
function parseAvahiBrowse(stdout) {
|
|
316
|
+
const results = [];
|
|
317
|
+
let current = null;
|
|
318
|
+
for (const raw of stdout.split("\n")) {
|
|
319
|
+
const line = raw.trimEnd();
|
|
320
|
+
if (!line) continue;
|
|
321
|
+
if (line.startsWith("=") && line.includes(GATEWAY_SERVICE_TYPE)) {
|
|
322
|
+
if (current) results.push(current);
|
|
323
|
+
const marker = ` ${GATEWAY_SERVICE_TYPE}`;
|
|
324
|
+
const idx = line.indexOf(marker);
|
|
325
|
+
const left = idx >= 0 ? line.slice(0, idx).trim() : line;
|
|
326
|
+
const parts = left.split(/\s+/);
|
|
327
|
+
const instanceName = parts.length > 3 ? parts.slice(3).join(" ") : left;
|
|
328
|
+
current = {
|
|
329
|
+
instanceName,
|
|
330
|
+
displayName: instanceName
|
|
331
|
+
};
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
if (!current) continue;
|
|
335
|
+
const trimmed = line.trim();
|
|
336
|
+
if (trimmed.startsWith("hostname =")) {
|
|
337
|
+
const match = trimmed.match(/hostname\s*=\s*\[([^\]]+)\]/);
|
|
338
|
+
if (match?.[1]) current.host = match[1];
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
if (trimmed.startsWith("port =")) {
|
|
342
|
+
const match = trimmed.match(/port\s*=\s*\[(\d+)\]/);
|
|
343
|
+
if (match?.[1]) current.port = parseIntOrNull(match[1]);
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (trimmed.startsWith("txt =")) {
|
|
347
|
+
const txt = parseTxtTokens(Array.from(trimmed.matchAll(/"([^"]*)"/g), (m) => m[1]));
|
|
348
|
+
current.txt = Object.keys(txt).length ? txt : void 0;
|
|
349
|
+
if (txt.displayName) current.displayName = txt.displayName;
|
|
350
|
+
if (txt.lanHost) current.lanHost = txt.lanHost;
|
|
351
|
+
if (txt.tailnetDns) current.tailnetDns = txt.tailnetDns;
|
|
352
|
+
if (txt.cliPath) current.cliPath = txt.cliPath;
|
|
353
|
+
current.gatewayPort = parseIntOrNull(txt.gatewayPort);
|
|
354
|
+
current.sshPort = parseIntOrNull(txt.sshPort);
|
|
355
|
+
if (txt.gatewayTls) {
|
|
356
|
+
const raw = txt.gatewayTls.trim().toLowerCase();
|
|
357
|
+
current.gatewayTls = raw === "1" || raw === "true" || raw === "yes";
|
|
358
|
+
}
|
|
359
|
+
if (txt.gatewayTlsSha256) current.gatewayTlsFingerprintSha256 = txt.gatewayTlsSha256;
|
|
360
|
+
if (txt.role) current.role = txt.role;
|
|
361
|
+
if (txt.transport) current.transport = txt.transport;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (current) results.push(current);
|
|
365
|
+
return results;
|
|
366
|
+
}
|
|
367
|
+
async function discoverViaAvahi(domain, timeoutMs, run) {
|
|
368
|
+
const args = [
|
|
369
|
+
"avahi-browse",
|
|
370
|
+
"-rt",
|
|
371
|
+
GATEWAY_SERVICE_TYPE
|
|
372
|
+
];
|
|
373
|
+
if (domain && domain !== "local.") args.push("-d", domain.replace(/\.$/, ""));
|
|
374
|
+
return parseAvahiBrowse((await run(args, { timeoutMs })).stdout).map((beacon) => ({
|
|
375
|
+
...beacon,
|
|
376
|
+
domain
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
379
|
+
async function discoverGatewayBeacons(opts = {}) {
|
|
380
|
+
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
381
|
+
const platform = opts.platform ?? process.platform;
|
|
382
|
+
const run = opts.run ?? runCommandWithTimeout;
|
|
383
|
+
const wideAreaDomain = resolveWideAreaDiscoveryDomain({ configDomain: opts.wideAreaDomain });
|
|
384
|
+
const domainsRaw = Array.isArray(opts.domains) ? opts.domains : [];
|
|
385
|
+
const defaultDomains = ["local.", ...wideAreaDomain ? [wideAreaDomain] : []];
|
|
386
|
+
const domains = (domainsRaw.length > 0 ? domainsRaw : defaultDomains).map((d) => String(d).trim()).filter(Boolean).map((d) => d.endsWith(".") ? d : `${d}.`);
|
|
387
|
+
try {
|
|
388
|
+
if (platform === "darwin") {
|
|
389
|
+
const discovered = (await Promise.allSettled(domains.map(async (domain) => await discoverViaDnsSd(domain, timeoutMs, run)))).flatMap((r) => r.status === "fulfilled" ? r.value : []);
|
|
390
|
+
const wantsWideArea = wideAreaDomain ? domains.includes(wideAreaDomain) : false;
|
|
391
|
+
const hasWideArea = wideAreaDomain ? discovered.some((b) => b.domain === wideAreaDomain) : false;
|
|
392
|
+
if (wantsWideArea && !hasWideArea && wideAreaDomain) {
|
|
393
|
+
const fallback = await discoverWideAreaViaTailnetDns(wideAreaDomain, timeoutMs, run).catch(() => []);
|
|
394
|
+
return [...discovered, ...fallback];
|
|
395
|
+
}
|
|
396
|
+
return discovered;
|
|
397
|
+
}
|
|
398
|
+
if (platform === "linux") return (await Promise.allSettled(domains.map(async (domain) => await discoverViaAvahi(domain, timeoutMs, run)))).flatMap((r) => r.status === "fulfilled" ? r.value : []);
|
|
399
|
+
} catch {
|
|
400
|
+
return [];
|
|
401
|
+
}
|
|
402
|
+
return [];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/infra/control-ui-assets.ts
|
|
407
|
+
function resolveControlUiRepoRoot(argv1 = process.argv[1]) {
|
|
408
|
+
if (!argv1) return null;
|
|
409
|
+
const normalized = path.resolve(argv1);
|
|
410
|
+
const parts = normalized.split(path.sep);
|
|
411
|
+
const srcIndex = parts.lastIndexOf("src");
|
|
412
|
+
if (srcIndex !== -1) {
|
|
413
|
+
const root = parts.slice(0, srcIndex).join(path.sep);
|
|
414
|
+
if (fs.existsSync(path.join(root, "ui", "vite.config.ts"))) return root;
|
|
415
|
+
}
|
|
416
|
+
let dir = path.dirname(normalized);
|
|
417
|
+
for (let i = 0; i < 8; i++) {
|
|
418
|
+
if (fs.existsSync(path.join(dir, "package.json")) && fs.existsSync(path.join(dir, "ui", "vite.config.ts"))) return dir;
|
|
419
|
+
const parent = path.dirname(dir);
|
|
420
|
+
if (parent === dir) break;
|
|
421
|
+
dir = parent;
|
|
422
|
+
}
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
async function resolveControlUiDistIndexPath(argv1 = process.argv[1]) {
|
|
426
|
+
if (!argv1) return null;
|
|
427
|
+
const normalized = path.resolve(argv1);
|
|
428
|
+
const distDir = path.dirname(normalized);
|
|
429
|
+
if (path.basename(distDir) === "dist") return path.join(distDir, "control-ui", "index.html");
|
|
430
|
+
const packageRoot = await resolveOpenClawPackageRoot({ argv1: normalized });
|
|
431
|
+
if (!packageRoot) return null;
|
|
432
|
+
return path.join(packageRoot, "dist", "control-ui", "index.html");
|
|
433
|
+
}
|
|
434
|
+
function addCandidate(candidates, value) {
|
|
435
|
+
if (!value) return;
|
|
436
|
+
candidates.add(path.resolve(value));
|
|
437
|
+
}
|
|
438
|
+
function resolveControlUiRootOverrideSync(rootOverride) {
|
|
439
|
+
const resolved = path.resolve(rootOverride);
|
|
440
|
+
try {
|
|
441
|
+
const stats = fs.statSync(resolved);
|
|
442
|
+
if (stats.isFile()) return path.basename(resolved) === "index.html" ? path.dirname(resolved) : null;
|
|
443
|
+
if (stats.isDirectory()) {
|
|
444
|
+
const indexPath = path.join(resolved, "index.html");
|
|
445
|
+
return fs.existsSync(indexPath) ? resolved : null;
|
|
446
|
+
}
|
|
447
|
+
} catch {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
function resolveControlUiRootSync(opts = {}) {
|
|
453
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
454
|
+
const argv1 = opts.argv1 ?? process.argv[1];
|
|
455
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
456
|
+
const moduleDir = opts.moduleUrl ? path.dirname(fileURLToPath(opts.moduleUrl)) : null;
|
|
457
|
+
const argv1Dir = argv1 ? path.dirname(path.resolve(argv1)) : null;
|
|
458
|
+
const execDir = (() => {
|
|
459
|
+
try {
|
|
460
|
+
const execPath = opts.execPath ?? process.execPath;
|
|
461
|
+
return path.dirname(fs.realpathSync(execPath));
|
|
462
|
+
} catch {
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
})();
|
|
466
|
+
const packageRoot = resolveOpenClawPackageRootSync({
|
|
467
|
+
argv1,
|
|
468
|
+
moduleUrl: opts.moduleUrl,
|
|
469
|
+
cwd
|
|
470
|
+
});
|
|
471
|
+
addCandidate(candidates, execDir ? path.join(execDir, "control-ui") : null);
|
|
472
|
+
if (moduleDir) {
|
|
473
|
+
addCandidate(candidates, path.join(moduleDir, "control-ui"));
|
|
474
|
+
addCandidate(candidates, path.join(moduleDir, "../control-ui"));
|
|
475
|
+
addCandidate(candidates, path.join(moduleDir, "../../dist/control-ui"));
|
|
476
|
+
}
|
|
477
|
+
if (argv1Dir) {
|
|
478
|
+
addCandidate(candidates, path.join(argv1Dir, "dist", "control-ui"));
|
|
479
|
+
addCandidate(candidates, path.join(argv1Dir, "control-ui"));
|
|
480
|
+
}
|
|
481
|
+
if (packageRoot) addCandidate(candidates, path.join(packageRoot, "dist", "control-ui"));
|
|
482
|
+
addCandidate(candidates, path.join(cwd, "dist", "control-ui"));
|
|
483
|
+
for (const dir of candidates) {
|
|
484
|
+
const indexPath = path.join(dir, "index.html");
|
|
485
|
+
if (fs.existsSync(indexPath)) return dir;
|
|
486
|
+
}
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
function summarizeCommandOutput(text) {
|
|
490
|
+
const lines = text.split(/\r?\n/g).map((l) => l.trim()).filter(Boolean);
|
|
491
|
+
if (!lines.length) return;
|
|
492
|
+
const last = lines.at(-1);
|
|
493
|
+
if (!last) return;
|
|
494
|
+
return last.length > 240 ? `${last.slice(0, 239)}…` : last;
|
|
495
|
+
}
|
|
496
|
+
async function ensureControlUiAssetsBuilt(runtime = defaultRuntime, opts) {
|
|
497
|
+
const indexFromDist = await resolveControlUiDistIndexPath(process.argv[1]);
|
|
498
|
+
if (indexFromDist && fs.existsSync(indexFromDist)) return {
|
|
499
|
+
ok: true,
|
|
500
|
+
built: false
|
|
501
|
+
};
|
|
502
|
+
const repoRoot = resolveControlUiRepoRoot(process.argv[1]);
|
|
503
|
+
if (!repoRoot) return {
|
|
504
|
+
ok: false,
|
|
505
|
+
built: false,
|
|
506
|
+
message: `${indexFromDist ? `Missing Control UI assets at ${indexFromDist}` : "Missing Control UI assets"}. Build them with \`pnpm ui:build\` (auto-installs UI deps).`
|
|
507
|
+
};
|
|
508
|
+
const indexPath = path.join(repoRoot, "dist", "control-ui", "index.html");
|
|
509
|
+
if (fs.existsSync(indexPath)) return {
|
|
510
|
+
ok: true,
|
|
511
|
+
built: false
|
|
512
|
+
};
|
|
513
|
+
const uiScript = path.join(repoRoot, "scripts", "ui.js");
|
|
514
|
+
if (!fs.existsSync(uiScript)) return {
|
|
515
|
+
ok: false,
|
|
516
|
+
built: false,
|
|
517
|
+
message: `Control UI assets missing but ${uiScript} is unavailable.`
|
|
518
|
+
};
|
|
519
|
+
runtime.log("Control UI assets missing; building (ui:build, auto-installs UI deps)…");
|
|
520
|
+
const build = await runCommandWithTimeout([
|
|
521
|
+
process.execPath,
|
|
522
|
+
uiScript,
|
|
523
|
+
"build"
|
|
524
|
+
], {
|
|
525
|
+
cwd: repoRoot,
|
|
526
|
+
timeoutMs: opts?.timeoutMs ?? 10 * 6e4
|
|
527
|
+
});
|
|
528
|
+
if (build.code !== 0) return {
|
|
529
|
+
ok: false,
|
|
530
|
+
built: false,
|
|
531
|
+
message: `Control UI build failed: ${summarizeCommandOutput(build.stderr) ?? `exit ${build.code}`}`
|
|
532
|
+
};
|
|
533
|
+
if (!fs.existsSync(indexPath)) return {
|
|
534
|
+
ok: false,
|
|
535
|
+
built: true,
|
|
536
|
+
message: `Control UI build completed but ${indexPath} is still missing.`
|
|
537
|
+
};
|
|
538
|
+
return {
|
|
539
|
+
ok: true,
|
|
540
|
+
built: true
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region src/commands/auth-choice-options.ts
|
|
546
|
+
const AUTH_CHOICE_GROUP_DEFS = [
|
|
547
|
+
{
|
|
548
|
+
value: "openai",
|
|
549
|
+
label: "OpenAI",
|
|
550
|
+
hint: "Codex OAuth + API key",
|
|
551
|
+
choices: ["openai-codex", "openai-api-key"]
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
value: "anthropic",
|
|
555
|
+
label: "Anthropic",
|
|
556
|
+
hint: "setup-token + API key",
|
|
557
|
+
choices: ["token", "apiKey"]
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
value: "minimax",
|
|
561
|
+
label: "MiniMax",
|
|
562
|
+
hint: "M2.1 (recommended)",
|
|
563
|
+
choices: [
|
|
564
|
+
"minimax-portal",
|
|
565
|
+
"minimax-api",
|
|
566
|
+
"minimax-api-lightning"
|
|
567
|
+
]
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
value: "moonshot",
|
|
571
|
+
label: "Moonshot AI (Kimi K2.5)",
|
|
572
|
+
hint: "Kimi K2.5 + Kimi Coding",
|
|
573
|
+
choices: [
|
|
574
|
+
"moonshot-api-key",
|
|
575
|
+
"moonshot-api-key-cn",
|
|
576
|
+
"kimi-code-api-key"
|
|
577
|
+
]
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
value: "google",
|
|
581
|
+
label: "Google",
|
|
582
|
+
hint: "Gemini API key + OAuth",
|
|
583
|
+
choices: [
|
|
584
|
+
"gemini-api-key",
|
|
585
|
+
"google-antigravity",
|
|
586
|
+
"google-gemini-cli"
|
|
587
|
+
]
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
value: "openrouter",
|
|
591
|
+
label: "OpenRouter",
|
|
592
|
+
hint: "API key",
|
|
593
|
+
choices: ["openrouter-api-key"]
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
value: "qwen",
|
|
597
|
+
label: "Qwen",
|
|
598
|
+
hint: "OAuth",
|
|
599
|
+
choices: ["qwen-portal"]
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
value: "zai",
|
|
603
|
+
label: "Z.AI (GLM 4.7)",
|
|
604
|
+
hint: "API key",
|
|
605
|
+
choices: ["zai-api-key"]
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
value: "copilot",
|
|
609
|
+
label: "Copilot",
|
|
610
|
+
hint: "GitHub + local proxy",
|
|
611
|
+
choices: ["github-copilot", "copilot-proxy"]
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
value: "ai-gateway",
|
|
615
|
+
label: "Vercel AI Gateway",
|
|
616
|
+
hint: "API key",
|
|
617
|
+
choices: ["ai-gateway-api-key"]
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
value: "opencode-zen",
|
|
621
|
+
label: "OpenCode Zen",
|
|
622
|
+
hint: "API key",
|
|
623
|
+
choices: ["opencode-zen"]
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
value: "xiaomi",
|
|
627
|
+
label: "Xiaomi",
|
|
628
|
+
hint: "API key",
|
|
629
|
+
choices: ["xiaomi-api-key"]
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
value: "synthetic",
|
|
633
|
+
label: "Synthetic",
|
|
634
|
+
hint: "Anthropic-compatible (multi-model)",
|
|
635
|
+
choices: ["synthetic-api-key"]
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
value: "venice",
|
|
639
|
+
label: "Venice AI",
|
|
640
|
+
hint: "Privacy-focused (uncensored models)",
|
|
641
|
+
choices: ["venice-api-key"]
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
value: "cloudflare-ai-gateway",
|
|
645
|
+
label: "Cloudflare AI Gateway",
|
|
646
|
+
hint: "Account ID + Gateway ID + API key",
|
|
647
|
+
choices: ["cloudflare-ai-gateway-api-key"]
|
|
648
|
+
}
|
|
649
|
+
];
|
|
650
|
+
function buildAuthChoiceOptions(params) {
|
|
651
|
+
params.store;
|
|
652
|
+
const options = [];
|
|
653
|
+
options.push({
|
|
654
|
+
value: "token",
|
|
655
|
+
label: "Anthropic token (paste setup-token)",
|
|
656
|
+
hint: "run `claude setup-token` elsewhere, then paste the token here"
|
|
657
|
+
});
|
|
658
|
+
options.push({
|
|
659
|
+
value: "openai-codex",
|
|
660
|
+
label: "OpenAI Codex (ChatGPT OAuth)"
|
|
661
|
+
});
|
|
662
|
+
options.push({
|
|
663
|
+
value: "chutes",
|
|
664
|
+
label: "Chutes (OAuth)"
|
|
665
|
+
});
|
|
666
|
+
options.push({
|
|
667
|
+
value: "openai-api-key",
|
|
668
|
+
label: "OpenAI API key"
|
|
669
|
+
});
|
|
670
|
+
options.push({
|
|
671
|
+
value: "openrouter-api-key",
|
|
672
|
+
label: "OpenRouter API key"
|
|
673
|
+
});
|
|
674
|
+
options.push({
|
|
675
|
+
value: "ai-gateway-api-key",
|
|
676
|
+
label: "Vercel AI Gateway API key"
|
|
677
|
+
});
|
|
678
|
+
options.push({
|
|
679
|
+
value: "cloudflare-ai-gateway-api-key",
|
|
680
|
+
label: "Cloudflare AI Gateway",
|
|
681
|
+
hint: "Account ID + Gateway ID + API key"
|
|
682
|
+
});
|
|
683
|
+
options.push({
|
|
684
|
+
value: "moonshot-api-key",
|
|
685
|
+
label: "Kimi API key (.ai)"
|
|
686
|
+
});
|
|
687
|
+
options.push({
|
|
688
|
+
value: "moonshot-api-key-cn",
|
|
689
|
+
label: "Kimi API key (.cn)"
|
|
690
|
+
});
|
|
691
|
+
options.push({
|
|
692
|
+
value: "kimi-code-api-key",
|
|
693
|
+
label: "Kimi Code API key (subscription)"
|
|
694
|
+
});
|
|
695
|
+
options.push({
|
|
696
|
+
value: "synthetic-api-key",
|
|
697
|
+
label: "Synthetic API key"
|
|
698
|
+
});
|
|
699
|
+
options.push({
|
|
700
|
+
value: "venice-api-key",
|
|
701
|
+
label: "Venice AI API key",
|
|
702
|
+
hint: "Privacy-focused inference (uncensored models)"
|
|
703
|
+
});
|
|
704
|
+
options.push({
|
|
705
|
+
value: "github-copilot",
|
|
706
|
+
label: "GitHub Copilot (GitHub device login)",
|
|
707
|
+
hint: "Uses GitHub device flow"
|
|
708
|
+
});
|
|
709
|
+
options.push({
|
|
710
|
+
value: "gemini-api-key",
|
|
711
|
+
label: "Google Gemini API key"
|
|
712
|
+
});
|
|
713
|
+
options.push({
|
|
714
|
+
value: "google-antigravity",
|
|
715
|
+
label: "Google Antigravity OAuth",
|
|
716
|
+
hint: "Uses the bundled Antigravity auth plugin"
|
|
717
|
+
});
|
|
718
|
+
options.push({
|
|
719
|
+
value: "google-gemini-cli",
|
|
720
|
+
label: "Google Gemini CLI OAuth",
|
|
721
|
+
hint: "Uses the bundled Gemini CLI auth plugin"
|
|
722
|
+
});
|
|
723
|
+
options.push({
|
|
724
|
+
value: "zai-api-key",
|
|
725
|
+
label: "Z.AI (GLM 4.7) API key"
|
|
726
|
+
});
|
|
727
|
+
options.push({
|
|
728
|
+
value: "xiaomi-api-key",
|
|
729
|
+
label: "Xiaomi API key"
|
|
730
|
+
});
|
|
731
|
+
options.push({
|
|
732
|
+
value: "minimax-portal",
|
|
733
|
+
label: "MiniMax OAuth",
|
|
734
|
+
hint: "Oauth plugin for MiniMax"
|
|
735
|
+
});
|
|
736
|
+
options.push({
|
|
737
|
+
value: "qwen-portal",
|
|
738
|
+
label: "Qwen OAuth"
|
|
739
|
+
});
|
|
740
|
+
options.push({
|
|
741
|
+
value: "copilot-proxy",
|
|
742
|
+
label: "Copilot Proxy (local)",
|
|
743
|
+
hint: "Local proxy for VS Code Copilot models"
|
|
744
|
+
});
|
|
745
|
+
options.push({
|
|
746
|
+
value: "apiKey",
|
|
747
|
+
label: "Anthropic API key"
|
|
748
|
+
});
|
|
749
|
+
options.push({
|
|
750
|
+
value: "opencode-zen",
|
|
751
|
+
label: "OpenCode Zen (multi-model proxy)",
|
|
752
|
+
hint: "Claude, GPT, Gemini via opencode.ai/zen"
|
|
753
|
+
});
|
|
754
|
+
options.push({
|
|
755
|
+
value: "minimax-api",
|
|
756
|
+
label: "MiniMax M2.1"
|
|
757
|
+
});
|
|
758
|
+
options.push({
|
|
759
|
+
value: "minimax-api-lightning",
|
|
760
|
+
label: "MiniMax M2.1 Lightning",
|
|
761
|
+
hint: "Faster, higher output cost"
|
|
762
|
+
});
|
|
763
|
+
if (params.includeSkip) options.push({
|
|
764
|
+
value: "skip",
|
|
765
|
+
label: "Skip for now"
|
|
766
|
+
});
|
|
767
|
+
return options;
|
|
768
|
+
}
|
|
769
|
+
function buildAuthChoiceGroups(params) {
|
|
770
|
+
const options = buildAuthChoiceOptions({
|
|
771
|
+
...params,
|
|
772
|
+
includeSkip: false
|
|
773
|
+
});
|
|
774
|
+
const optionByValue = new Map(options.map((opt) => [opt.value, opt]));
|
|
775
|
+
return {
|
|
776
|
+
groups: AUTH_CHOICE_GROUP_DEFS.map((group) => ({
|
|
777
|
+
...group,
|
|
778
|
+
options: group.choices.map((choice) => optionByValue.get(choice)).filter((opt) => Boolean(opt))
|
|
779
|
+
})),
|
|
780
|
+
skipOption: params.includeSkip ? {
|
|
781
|
+
value: "skip",
|
|
782
|
+
label: "Skip for now"
|
|
783
|
+
} : void 0
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/commands/auth-choice-prompt.ts
|
|
789
|
+
const BACK_VALUE = "__back";
|
|
790
|
+
async function promptAuthChoiceGrouped(params) {
|
|
791
|
+
const { groups, skipOption } = buildAuthChoiceGroups(params);
|
|
792
|
+
const availableGroups = groups.filter((group) => group.options.length > 0);
|
|
793
|
+
while (true) {
|
|
794
|
+
const providerOptions = [...availableGroups.map((group) => ({
|
|
795
|
+
value: group.value,
|
|
796
|
+
label: group.label,
|
|
797
|
+
hint: group.hint
|
|
798
|
+
})), ...skipOption ? [skipOption] : []];
|
|
799
|
+
const providerSelection = await params.prompter.select({
|
|
800
|
+
message: "Model/auth provider",
|
|
801
|
+
options: providerOptions
|
|
802
|
+
});
|
|
803
|
+
if (providerSelection === "skip") return "skip";
|
|
804
|
+
const group = availableGroups.find((candidate) => candidate.value === providerSelection);
|
|
805
|
+
if (!group || group.options.length === 0) {
|
|
806
|
+
await params.prompter.note("No auth methods available for that provider.", "Model/auth choice");
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
const methodSelection = await params.prompter.select({
|
|
810
|
+
message: `${group.label} auth method`,
|
|
811
|
+
options: [...group.options, {
|
|
812
|
+
value: BACK_VALUE,
|
|
813
|
+
label: "Back"
|
|
814
|
+
}]
|
|
815
|
+
});
|
|
816
|
+
if (methodSelection === BACK_VALUE) continue;
|
|
817
|
+
return methodSelection;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
//#endregion
|
|
822
|
+
//#region src/commands/auth-choice.api-key.ts
|
|
823
|
+
const DEFAULT_KEY_PREVIEW = {
|
|
824
|
+
head: 4,
|
|
825
|
+
tail: 4
|
|
826
|
+
};
|
|
827
|
+
function normalizeApiKeyInput(raw) {
|
|
828
|
+
const trimmed = String(raw ?? "").trim();
|
|
829
|
+
if (!trimmed) return "";
|
|
830
|
+
const assignmentMatch = trimmed.match(/^(?:export\s+)?[A-Za-z_][A-Za-z0-9_]*\s*=\s*(.+)$/);
|
|
831
|
+
const valuePart = assignmentMatch ? assignmentMatch[1].trim() : trimmed;
|
|
832
|
+
const unquoted = valuePart.length >= 2 && (valuePart.startsWith("\"") && valuePart.endsWith("\"") || valuePart.startsWith("'") && valuePart.endsWith("'") || valuePart.startsWith("`") && valuePart.endsWith("`")) ? valuePart.slice(1, -1) : valuePart;
|
|
833
|
+
return (unquoted.endsWith(";") ? unquoted.slice(0, -1) : unquoted).trim();
|
|
834
|
+
}
|
|
835
|
+
const validateApiKeyInput = (value) => normalizeApiKeyInput(value).length > 0 ? void 0 : "Required";
|
|
836
|
+
function formatApiKeyPreview(raw, opts = {}) {
|
|
837
|
+
const trimmed = raw.trim();
|
|
838
|
+
if (!trimmed) return "…";
|
|
839
|
+
const head = opts.head ?? DEFAULT_KEY_PREVIEW.head;
|
|
840
|
+
const tail = opts.tail ?? DEFAULT_KEY_PREVIEW.tail;
|
|
841
|
+
if (trimmed.length <= head + tail) {
|
|
842
|
+
const shortHead = Math.min(2, trimmed.length);
|
|
843
|
+
const shortTail = Math.min(2, trimmed.length - shortHead);
|
|
844
|
+
if (shortTail <= 0) return `${trimmed.slice(0, shortHead)}…`;
|
|
845
|
+
return `${trimmed.slice(0, shortHead)}…${trimmed.slice(-shortTail)}`;
|
|
846
|
+
}
|
|
847
|
+
return `${trimmed.slice(0, head)}…${trimmed.slice(-tail)}`;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
//#endregion
|
|
851
|
+
//#region src/commands/auth-choice.apply.anthropic.ts
|
|
852
|
+
async function applyAuthChoiceAnthropic(params) {
|
|
853
|
+
if (params.authChoice === "setup-token" || params.authChoice === "oauth" || params.authChoice === "token") {
|
|
854
|
+
let nextConfig = params.config;
|
|
855
|
+
await params.prompter.note(["Run `claude setup-token` in your terminal.", "Then paste the generated token below."].join("\n"), "Anthropic setup-token");
|
|
856
|
+
const tokenRaw = await params.prompter.text({
|
|
857
|
+
message: "Paste Anthropic setup-token",
|
|
858
|
+
validate: (value) => validateAnthropicSetupToken(String(value ?? ""))
|
|
859
|
+
});
|
|
860
|
+
const token = String(tokenRaw).trim();
|
|
861
|
+
const profileNameRaw = await params.prompter.text({
|
|
862
|
+
message: "Token name (blank = default)",
|
|
863
|
+
placeholder: "default"
|
|
864
|
+
});
|
|
865
|
+
const provider = "anthropic";
|
|
866
|
+
const namedProfileId = buildTokenProfileId({
|
|
867
|
+
provider,
|
|
868
|
+
name: String(profileNameRaw ?? "")
|
|
869
|
+
});
|
|
870
|
+
upsertAuthProfile({
|
|
871
|
+
profileId: namedProfileId,
|
|
872
|
+
agentDir: params.agentDir,
|
|
873
|
+
credential: {
|
|
874
|
+
type: "token",
|
|
875
|
+
provider,
|
|
876
|
+
token
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
880
|
+
profileId: namedProfileId,
|
|
881
|
+
provider,
|
|
882
|
+
mode: "token"
|
|
883
|
+
});
|
|
884
|
+
return { config: nextConfig };
|
|
885
|
+
}
|
|
886
|
+
if (params.authChoice === "apiKey") {
|
|
887
|
+
if (params.opts?.tokenProvider && params.opts.tokenProvider !== "anthropic") return null;
|
|
888
|
+
let nextConfig = params.config;
|
|
889
|
+
let hasCredential = false;
|
|
890
|
+
const envKey = process.env.ANTHROPIC_API_KEY?.trim();
|
|
891
|
+
if (params.opts?.token) {
|
|
892
|
+
await setAnthropicApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
893
|
+
hasCredential = true;
|
|
894
|
+
}
|
|
895
|
+
if (!hasCredential && envKey) {
|
|
896
|
+
if (await params.prompter.confirm({
|
|
897
|
+
message: `Use existing ANTHROPIC_API_KEY (env, ${formatApiKeyPreview(envKey)})?`,
|
|
898
|
+
initialValue: true
|
|
899
|
+
})) {
|
|
900
|
+
await setAnthropicApiKey(envKey, params.agentDir);
|
|
901
|
+
hasCredential = true;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
if (!hasCredential) {
|
|
905
|
+
const key = await params.prompter.text({
|
|
906
|
+
message: "Enter Anthropic API key",
|
|
907
|
+
validate: validateApiKeyInput
|
|
908
|
+
});
|
|
909
|
+
await setAnthropicApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
910
|
+
}
|
|
911
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
912
|
+
profileId: "anthropic:default",
|
|
913
|
+
provider: "anthropic",
|
|
914
|
+
mode: "api_key"
|
|
915
|
+
});
|
|
916
|
+
return { config: nextConfig };
|
|
917
|
+
}
|
|
918
|
+
return null;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/commands/auth-choice.default-model.ts
|
|
923
|
+
async function applyDefaultModelChoice(params) {
|
|
924
|
+
if (params.setDefaultModel) {
|
|
925
|
+
const next = params.applyDefaultConfig(params.config);
|
|
926
|
+
if (params.noteDefault) await params.prompter.note(`Default model set to ${params.noteDefault}`, "Model configured");
|
|
927
|
+
return { config: next };
|
|
928
|
+
}
|
|
929
|
+
const next = params.applyProviderConfig(params.config);
|
|
930
|
+
await params.noteAgentModel(params.defaultModel);
|
|
931
|
+
return {
|
|
932
|
+
config: next,
|
|
933
|
+
agentModelOverride: params.defaultModel
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region src/commands/google-gemini-model-default.ts
|
|
939
|
+
const GOOGLE_GEMINI_DEFAULT_MODEL = "google/gemini-3-pro-preview";
|
|
940
|
+
function resolvePrimaryModel$1(model) {
|
|
941
|
+
if (typeof model === "string") return model;
|
|
942
|
+
if (model && typeof model === "object" && typeof model.primary === "string") return model.primary;
|
|
943
|
+
}
|
|
944
|
+
function applyGoogleGeminiModelDefault(cfg) {
|
|
945
|
+
if (resolvePrimaryModel$1(cfg.agents?.defaults?.model)?.trim() === GOOGLE_GEMINI_DEFAULT_MODEL) return {
|
|
946
|
+
next: cfg,
|
|
947
|
+
changed: false
|
|
948
|
+
};
|
|
949
|
+
return {
|
|
950
|
+
next: {
|
|
951
|
+
...cfg,
|
|
952
|
+
agents: {
|
|
953
|
+
...cfg.agents,
|
|
954
|
+
defaults: {
|
|
955
|
+
...cfg.agents?.defaults,
|
|
956
|
+
model: cfg.agents?.defaults?.model && typeof cfg.agents.defaults.model === "object" ? {
|
|
957
|
+
...cfg.agents.defaults.model,
|
|
958
|
+
primary: GOOGLE_GEMINI_DEFAULT_MODEL
|
|
959
|
+
} : { primary: GOOGLE_GEMINI_DEFAULT_MODEL }
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
changed: true
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/commands/opencode-zen-model-default.ts
|
|
969
|
+
const OPENCODE_ZEN_DEFAULT_MODEL = "opencode/claude-opus-4-5";
|
|
970
|
+
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/commands/auth-choice.apply.api-providers.ts
|
|
973
|
+
async function applyAuthChoiceApiProviders(params) {
|
|
974
|
+
let nextConfig = params.config;
|
|
975
|
+
let agentModelOverride;
|
|
976
|
+
const noteAgentModel = async (model) => {
|
|
977
|
+
if (!params.agentId) return;
|
|
978
|
+
await params.prompter.note(`Default model set to ${model} for agent "${params.agentId}".`, "Model configured");
|
|
979
|
+
};
|
|
980
|
+
let authChoice = params.authChoice;
|
|
981
|
+
if (authChoice === "apiKey" && params.opts?.tokenProvider && params.opts.tokenProvider !== "anthropic" && params.opts.tokenProvider !== "openai") {
|
|
982
|
+
if (params.opts.tokenProvider === "openrouter") authChoice = "openrouter-api-key";
|
|
983
|
+
else if (params.opts.tokenProvider === "vercel-ai-gateway") authChoice = "ai-gateway-api-key";
|
|
984
|
+
else if (params.opts.tokenProvider === "cloudflare-ai-gateway") authChoice = "cloudflare-ai-gateway-api-key";
|
|
985
|
+
else if (params.opts.tokenProvider === "moonshot") authChoice = "moonshot-api-key";
|
|
986
|
+
else if (params.opts.tokenProvider === "kimi-code" || params.opts.tokenProvider === "kimi-coding") authChoice = "kimi-code-api-key";
|
|
987
|
+
else if (params.opts.tokenProvider === "google") authChoice = "gemini-api-key";
|
|
988
|
+
else if (params.opts.tokenProvider === "zai") authChoice = "zai-api-key";
|
|
989
|
+
else if (params.opts.tokenProvider === "xiaomi") authChoice = "xiaomi-api-key";
|
|
990
|
+
else if (params.opts.tokenProvider === "synthetic") authChoice = "synthetic-api-key";
|
|
991
|
+
else if (params.opts.tokenProvider === "venice") authChoice = "venice-api-key";
|
|
992
|
+
else if (params.opts.tokenProvider === "opencode") authChoice = "opencode-zen";
|
|
993
|
+
}
|
|
994
|
+
if (authChoice === "openrouter-api-key") {
|
|
995
|
+
const store = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
996
|
+
const existingProfileId = resolveAuthProfileOrder({
|
|
997
|
+
cfg: nextConfig,
|
|
998
|
+
store,
|
|
999
|
+
provider: "openrouter"
|
|
1000
|
+
}).find((profileId) => Boolean(store.profiles[profileId]));
|
|
1001
|
+
const existingCred = existingProfileId ? store.profiles[existingProfileId] : void 0;
|
|
1002
|
+
let profileId = "openrouter:default";
|
|
1003
|
+
let mode = "api_key";
|
|
1004
|
+
let hasCredential = false;
|
|
1005
|
+
if (existingProfileId && existingCred?.type) {
|
|
1006
|
+
profileId = existingProfileId;
|
|
1007
|
+
mode = existingCred.type === "oauth" ? "oauth" : existingCred.type === "token" ? "token" : "api_key";
|
|
1008
|
+
hasCredential = true;
|
|
1009
|
+
}
|
|
1010
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "openrouter") {
|
|
1011
|
+
await setOpenrouterApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1012
|
+
hasCredential = true;
|
|
1013
|
+
}
|
|
1014
|
+
if (!hasCredential) {
|
|
1015
|
+
const envKey = resolveEnvApiKey("openrouter");
|
|
1016
|
+
if (envKey) {
|
|
1017
|
+
if (await params.prompter.confirm({
|
|
1018
|
+
message: `Use existing OPENROUTER_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1019
|
+
initialValue: true
|
|
1020
|
+
})) {
|
|
1021
|
+
await setOpenrouterApiKey(envKey.apiKey, params.agentDir);
|
|
1022
|
+
hasCredential = true;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
if (!hasCredential) {
|
|
1027
|
+
const key = await params.prompter.text({
|
|
1028
|
+
message: "Enter OpenRouter API key",
|
|
1029
|
+
validate: validateApiKeyInput
|
|
1030
|
+
});
|
|
1031
|
+
await setOpenrouterApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1032
|
+
hasCredential = true;
|
|
1033
|
+
}
|
|
1034
|
+
if (hasCredential) nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1035
|
+
profileId,
|
|
1036
|
+
provider: "openrouter",
|
|
1037
|
+
mode
|
|
1038
|
+
});
|
|
1039
|
+
{
|
|
1040
|
+
const applied = await applyDefaultModelChoice({
|
|
1041
|
+
config: nextConfig,
|
|
1042
|
+
setDefaultModel: params.setDefaultModel,
|
|
1043
|
+
defaultModel: OPENROUTER_DEFAULT_MODEL_REF,
|
|
1044
|
+
applyDefaultConfig: applyOpenrouterConfig,
|
|
1045
|
+
applyProviderConfig: applyOpenrouterProviderConfig,
|
|
1046
|
+
noteDefault: OPENROUTER_DEFAULT_MODEL_REF,
|
|
1047
|
+
noteAgentModel,
|
|
1048
|
+
prompter: params.prompter
|
|
1049
|
+
});
|
|
1050
|
+
nextConfig = applied.config;
|
|
1051
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1052
|
+
}
|
|
1053
|
+
return {
|
|
1054
|
+
config: nextConfig,
|
|
1055
|
+
agentModelOverride
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
if (authChoice === "ai-gateway-api-key") {
|
|
1059
|
+
let hasCredential = false;
|
|
1060
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "vercel-ai-gateway") {
|
|
1061
|
+
await setVercelAiGatewayApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1062
|
+
hasCredential = true;
|
|
1063
|
+
}
|
|
1064
|
+
const envKey = resolveEnvApiKey("vercel-ai-gateway");
|
|
1065
|
+
if (envKey) {
|
|
1066
|
+
if (await params.prompter.confirm({
|
|
1067
|
+
message: `Use existing AI_GATEWAY_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1068
|
+
initialValue: true
|
|
1069
|
+
})) {
|
|
1070
|
+
await setVercelAiGatewayApiKey(envKey.apiKey, params.agentDir);
|
|
1071
|
+
hasCredential = true;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (!hasCredential) {
|
|
1075
|
+
const key = await params.prompter.text({
|
|
1076
|
+
message: "Enter Vercel AI Gateway API key",
|
|
1077
|
+
validate: validateApiKeyInput
|
|
1078
|
+
});
|
|
1079
|
+
await setVercelAiGatewayApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1080
|
+
}
|
|
1081
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1082
|
+
profileId: "vercel-ai-gateway:default",
|
|
1083
|
+
provider: "vercel-ai-gateway",
|
|
1084
|
+
mode: "api_key"
|
|
1085
|
+
});
|
|
1086
|
+
{
|
|
1087
|
+
const applied = await applyDefaultModelChoice({
|
|
1088
|
+
config: nextConfig,
|
|
1089
|
+
setDefaultModel: params.setDefaultModel,
|
|
1090
|
+
defaultModel: VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
|
|
1091
|
+
applyDefaultConfig: applyVercelAiGatewayConfig,
|
|
1092
|
+
applyProviderConfig: applyVercelAiGatewayProviderConfig,
|
|
1093
|
+
noteDefault: VERCEL_AI_GATEWAY_DEFAULT_MODEL_REF,
|
|
1094
|
+
noteAgentModel,
|
|
1095
|
+
prompter: params.prompter
|
|
1096
|
+
});
|
|
1097
|
+
nextConfig = applied.config;
|
|
1098
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1099
|
+
}
|
|
1100
|
+
return {
|
|
1101
|
+
config: nextConfig,
|
|
1102
|
+
agentModelOverride
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
if (authChoice === "cloudflare-ai-gateway-api-key") {
|
|
1106
|
+
let hasCredential = false;
|
|
1107
|
+
let accountId = params.opts?.cloudflareAiGatewayAccountId?.trim() ?? "";
|
|
1108
|
+
let gatewayId = params.opts?.cloudflareAiGatewayGatewayId?.trim() ?? "";
|
|
1109
|
+
const ensureAccountGateway = async () => {
|
|
1110
|
+
if (!accountId) {
|
|
1111
|
+
const value = await params.prompter.text({
|
|
1112
|
+
message: "Enter Cloudflare Account ID",
|
|
1113
|
+
validate: (val) => String(val).trim() ? void 0 : "Account ID is required"
|
|
1114
|
+
});
|
|
1115
|
+
accountId = String(value).trim();
|
|
1116
|
+
}
|
|
1117
|
+
if (!gatewayId) {
|
|
1118
|
+
const value = await params.prompter.text({
|
|
1119
|
+
message: "Enter Cloudflare AI Gateway ID",
|
|
1120
|
+
validate: (val) => String(val).trim() ? void 0 : "Gateway ID is required"
|
|
1121
|
+
});
|
|
1122
|
+
gatewayId = String(value).trim();
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
const optsApiKey = normalizeApiKeyInput(params.opts?.cloudflareAiGatewayApiKey ?? "");
|
|
1126
|
+
if (!hasCredential && accountId && gatewayId && optsApiKey) {
|
|
1127
|
+
await setCloudflareAiGatewayConfig(accountId, gatewayId, optsApiKey, params.agentDir);
|
|
1128
|
+
hasCredential = true;
|
|
1129
|
+
}
|
|
1130
|
+
const envKey = resolveEnvApiKey("cloudflare-ai-gateway");
|
|
1131
|
+
if (!hasCredential && envKey) {
|
|
1132
|
+
if (await params.prompter.confirm({
|
|
1133
|
+
message: `Use existing CLOUDFLARE_AI_GATEWAY_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1134
|
+
initialValue: true
|
|
1135
|
+
})) {
|
|
1136
|
+
await ensureAccountGateway();
|
|
1137
|
+
await setCloudflareAiGatewayConfig(accountId, gatewayId, normalizeApiKeyInput(envKey.apiKey), params.agentDir);
|
|
1138
|
+
hasCredential = true;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
if (!hasCredential && optsApiKey) {
|
|
1142
|
+
await ensureAccountGateway();
|
|
1143
|
+
await setCloudflareAiGatewayConfig(accountId, gatewayId, optsApiKey, params.agentDir);
|
|
1144
|
+
hasCredential = true;
|
|
1145
|
+
}
|
|
1146
|
+
if (!hasCredential) {
|
|
1147
|
+
await ensureAccountGateway();
|
|
1148
|
+
const key = await params.prompter.text({
|
|
1149
|
+
message: "Enter Cloudflare AI Gateway API key",
|
|
1150
|
+
validate: validateApiKeyInput
|
|
1151
|
+
});
|
|
1152
|
+
await setCloudflareAiGatewayConfig(accountId, gatewayId, normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1153
|
+
hasCredential = true;
|
|
1154
|
+
}
|
|
1155
|
+
if (hasCredential) nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1156
|
+
profileId: "cloudflare-ai-gateway:default",
|
|
1157
|
+
provider: "cloudflare-ai-gateway",
|
|
1158
|
+
mode: "api_key"
|
|
1159
|
+
});
|
|
1160
|
+
{
|
|
1161
|
+
const applied = await applyDefaultModelChoice({
|
|
1162
|
+
config: nextConfig,
|
|
1163
|
+
setDefaultModel: params.setDefaultModel,
|
|
1164
|
+
defaultModel: CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
|
|
1165
|
+
applyDefaultConfig: (cfg) => applyCloudflareAiGatewayConfig(cfg, {
|
|
1166
|
+
accountId: accountId || params.opts?.cloudflareAiGatewayAccountId,
|
|
1167
|
+
gatewayId: gatewayId || params.opts?.cloudflareAiGatewayGatewayId
|
|
1168
|
+
}),
|
|
1169
|
+
applyProviderConfig: (cfg) => applyCloudflareAiGatewayProviderConfig(cfg, {
|
|
1170
|
+
accountId: accountId || params.opts?.cloudflareAiGatewayAccountId,
|
|
1171
|
+
gatewayId: gatewayId || params.opts?.cloudflareAiGatewayGatewayId
|
|
1172
|
+
}),
|
|
1173
|
+
noteDefault: CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF,
|
|
1174
|
+
noteAgentModel,
|
|
1175
|
+
prompter: params.prompter
|
|
1176
|
+
});
|
|
1177
|
+
nextConfig = applied.config;
|
|
1178
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1179
|
+
}
|
|
1180
|
+
return {
|
|
1181
|
+
config: nextConfig,
|
|
1182
|
+
agentModelOverride
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
if (authChoice === "moonshot-api-key") {
|
|
1186
|
+
let hasCredential = false;
|
|
1187
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "moonshot") {
|
|
1188
|
+
await setMoonshotApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1189
|
+
hasCredential = true;
|
|
1190
|
+
}
|
|
1191
|
+
const envKey = resolveEnvApiKey("moonshot");
|
|
1192
|
+
if (envKey) {
|
|
1193
|
+
if (await params.prompter.confirm({
|
|
1194
|
+
message: `Use existing MOONSHOT_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1195
|
+
initialValue: true
|
|
1196
|
+
})) {
|
|
1197
|
+
await setMoonshotApiKey(envKey.apiKey, params.agentDir);
|
|
1198
|
+
hasCredential = true;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
if (!hasCredential) {
|
|
1202
|
+
const key = await params.prompter.text({
|
|
1203
|
+
message: "Enter Moonshot API key",
|
|
1204
|
+
validate: validateApiKeyInput
|
|
1205
|
+
});
|
|
1206
|
+
await setMoonshotApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1207
|
+
}
|
|
1208
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1209
|
+
profileId: "moonshot:default",
|
|
1210
|
+
provider: "moonshot",
|
|
1211
|
+
mode: "api_key"
|
|
1212
|
+
});
|
|
1213
|
+
{
|
|
1214
|
+
const applied = await applyDefaultModelChoice({
|
|
1215
|
+
config: nextConfig,
|
|
1216
|
+
setDefaultModel: params.setDefaultModel,
|
|
1217
|
+
defaultModel: MOONSHOT_DEFAULT_MODEL_REF,
|
|
1218
|
+
applyDefaultConfig: applyMoonshotConfig,
|
|
1219
|
+
applyProviderConfig: applyMoonshotProviderConfig,
|
|
1220
|
+
noteAgentModel,
|
|
1221
|
+
prompter: params.prompter
|
|
1222
|
+
});
|
|
1223
|
+
nextConfig = applied.config;
|
|
1224
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1225
|
+
}
|
|
1226
|
+
return {
|
|
1227
|
+
config: nextConfig,
|
|
1228
|
+
agentModelOverride
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
if (authChoice === "moonshot-api-key-cn") {
|
|
1232
|
+
let hasCredential = false;
|
|
1233
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "moonshot") {
|
|
1234
|
+
await setMoonshotApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1235
|
+
hasCredential = true;
|
|
1236
|
+
}
|
|
1237
|
+
const envKey = resolveEnvApiKey("moonshot");
|
|
1238
|
+
if (envKey) {
|
|
1239
|
+
if (await params.prompter.confirm({
|
|
1240
|
+
message: `Use existing MOONSHOT_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1241
|
+
initialValue: true
|
|
1242
|
+
})) {
|
|
1243
|
+
await setMoonshotApiKey(envKey.apiKey, params.agentDir);
|
|
1244
|
+
hasCredential = true;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
if (!hasCredential) {
|
|
1248
|
+
const key = await params.prompter.text({
|
|
1249
|
+
message: "Enter Moonshot API key (.cn)",
|
|
1250
|
+
validate: validateApiKeyInput
|
|
1251
|
+
});
|
|
1252
|
+
await setMoonshotApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1253
|
+
}
|
|
1254
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1255
|
+
profileId: "moonshot:default",
|
|
1256
|
+
provider: "moonshot",
|
|
1257
|
+
mode: "api_key"
|
|
1258
|
+
});
|
|
1259
|
+
{
|
|
1260
|
+
const applied = await applyDefaultModelChoice({
|
|
1261
|
+
config: nextConfig,
|
|
1262
|
+
setDefaultModel: params.setDefaultModel,
|
|
1263
|
+
defaultModel: MOONSHOT_DEFAULT_MODEL_REF,
|
|
1264
|
+
applyDefaultConfig: applyMoonshotConfigCn,
|
|
1265
|
+
applyProviderConfig: applyMoonshotProviderConfigCn,
|
|
1266
|
+
noteAgentModel,
|
|
1267
|
+
prompter: params.prompter
|
|
1268
|
+
});
|
|
1269
|
+
nextConfig = applied.config;
|
|
1270
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1271
|
+
}
|
|
1272
|
+
return {
|
|
1273
|
+
config: nextConfig,
|
|
1274
|
+
agentModelOverride
|
|
1275
|
+
};
|
|
1276
|
+
}
|
|
1277
|
+
if (authChoice === "kimi-code-api-key") {
|
|
1278
|
+
let hasCredential = false;
|
|
1279
|
+
const tokenProvider = params.opts?.tokenProvider?.trim().toLowerCase();
|
|
1280
|
+
if (!hasCredential && params.opts?.token && (tokenProvider === "kimi-code" || tokenProvider === "kimi-coding")) {
|
|
1281
|
+
await setKimiCodingApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1282
|
+
hasCredential = true;
|
|
1283
|
+
}
|
|
1284
|
+
if (!hasCredential) await params.prompter.note(["Kimi Coding uses a dedicated endpoint and API key.", "Get your API key at: https://www.kimi.com/code/en"].join("\n"), "Kimi Coding");
|
|
1285
|
+
const envKey = resolveEnvApiKey("kimi-coding");
|
|
1286
|
+
if (envKey) {
|
|
1287
|
+
if (await params.prompter.confirm({
|
|
1288
|
+
message: `Use existing KIMI_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1289
|
+
initialValue: true
|
|
1290
|
+
})) {
|
|
1291
|
+
await setKimiCodingApiKey(envKey.apiKey, params.agentDir);
|
|
1292
|
+
hasCredential = true;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
if (!hasCredential) {
|
|
1296
|
+
const key = await params.prompter.text({
|
|
1297
|
+
message: "Enter Kimi Coding API key",
|
|
1298
|
+
validate: validateApiKeyInput
|
|
1299
|
+
});
|
|
1300
|
+
await setKimiCodingApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1301
|
+
}
|
|
1302
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1303
|
+
profileId: "kimi-coding:default",
|
|
1304
|
+
provider: "kimi-coding",
|
|
1305
|
+
mode: "api_key"
|
|
1306
|
+
});
|
|
1307
|
+
{
|
|
1308
|
+
const applied = await applyDefaultModelChoice({
|
|
1309
|
+
config: nextConfig,
|
|
1310
|
+
setDefaultModel: params.setDefaultModel,
|
|
1311
|
+
defaultModel: KIMI_CODING_MODEL_REF,
|
|
1312
|
+
applyDefaultConfig: applyKimiCodeConfig,
|
|
1313
|
+
applyProviderConfig: applyKimiCodeProviderConfig,
|
|
1314
|
+
noteDefault: KIMI_CODING_MODEL_REF,
|
|
1315
|
+
noteAgentModel,
|
|
1316
|
+
prompter: params.prompter
|
|
1317
|
+
});
|
|
1318
|
+
nextConfig = applied.config;
|
|
1319
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1320
|
+
}
|
|
1321
|
+
return {
|
|
1322
|
+
config: nextConfig,
|
|
1323
|
+
agentModelOverride
|
|
1324
|
+
};
|
|
1325
|
+
}
|
|
1326
|
+
if (authChoice === "gemini-api-key") {
|
|
1327
|
+
let hasCredential = false;
|
|
1328
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "google") {
|
|
1329
|
+
await setGeminiApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1330
|
+
hasCredential = true;
|
|
1331
|
+
}
|
|
1332
|
+
const envKey = resolveEnvApiKey("google");
|
|
1333
|
+
if (envKey) {
|
|
1334
|
+
if (await params.prompter.confirm({
|
|
1335
|
+
message: `Use existing GEMINI_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1336
|
+
initialValue: true
|
|
1337
|
+
})) {
|
|
1338
|
+
await setGeminiApiKey(envKey.apiKey, params.agentDir);
|
|
1339
|
+
hasCredential = true;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
if (!hasCredential) {
|
|
1343
|
+
const key = await params.prompter.text({
|
|
1344
|
+
message: "Enter Gemini API key",
|
|
1345
|
+
validate: validateApiKeyInput
|
|
1346
|
+
});
|
|
1347
|
+
await setGeminiApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1348
|
+
}
|
|
1349
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1350
|
+
profileId: "google:default",
|
|
1351
|
+
provider: "google",
|
|
1352
|
+
mode: "api_key"
|
|
1353
|
+
});
|
|
1354
|
+
if (params.setDefaultModel) {
|
|
1355
|
+
const applied = applyGoogleGeminiModelDefault(nextConfig);
|
|
1356
|
+
nextConfig = applied.next;
|
|
1357
|
+
if (applied.changed) await params.prompter.note(`Default model set to ${GOOGLE_GEMINI_DEFAULT_MODEL}`, "Model configured");
|
|
1358
|
+
} else {
|
|
1359
|
+
agentModelOverride = GOOGLE_GEMINI_DEFAULT_MODEL;
|
|
1360
|
+
await noteAgentModel(GOOGLE_GEMINI_DEFAULT_MODEL);
|
|
1361
|
+
}
|
|
1362
|
+
return {
|
|
1363
|
+
config: nextConfig,
|
|
1364
|
+
agentModelOverride
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
if (authChoice === "zai-api-key") {
|
|
1368
|
+
let hasCredential = false;
|
|
1369
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "zai") {
|
|
1370
|
+
await setZaiApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1371
|
+
hasCredential = true;
|
|
1372
|
+
}
|
|
1373
|
+
const envKey = resolveEnvApiKey("zai");
|
|
1374
|
+
if (envKey) {
|
|
1375
|
+
if (await params.prompter.confirm({
|
|
1376
|
+
message: `Use existing ZAI_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1377
|
+
initialValue: true
|
|
1378
|
+
})) {
|
|
1379
|
+
await setZaiApiKey(envKey.apiKey, params.agentDir);
|
|
1380
|
+
hasCredential = true;
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
if (!hasCredential) {
|
|
1384
|
+
const key = await params.prompter.text({
|
|
1385
|
+
message: "Enter Z.AI API key",
|
|
1386
|
+
validate: validateApiKeyInput
|
|
1387
|
+
});
|
|
1388
|
+
await setZaiApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1389
|
+
}
|
|
1390
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1391
|
+
profileId: "zai:default",
|
|
1392
|
+
provider: "zai",
|
|
1393
|
+
mode: "api_key"
|
|
1394
|
+
});
|
|
1395
|
+
{
|
|
1396
|
+
const applied = await applyDefaultModelChoice({
|
|
1397
|
+
config: nextConfig,
|
|
1398
|
+
setDefaultModel: params.setDefaultModel,
|
|
1399
|
+
defaultModel: ZAI_DEFAULT_MODEL_REF,
|
|
1400
|
+
applyDefaultConfig: applyZaiConfig,
|
|
1401
|
+
applyProviderConfig: (config) => ({
|
|
1402
|
+
...config,
|
|
1403
|
+
agents: {
|
|
1404
|
+
...config.agents,
|
|
1405
|
+
defaults: {
|
|
1406
|
+
...config.agents?.defaults,
|
|
1407
|
+
models: {
|
|
1408
|
+
...config.agents?.defaults?.models,
|
|
1409
|
+
[ZAI_DEFAULT_MODEL_REF]: {
|
|
1410
|
+
...config.agents?.defaults?.models?.[ZAI_DEFAULT_MODEL_REF],
|
|
1411
|
+
alias: config.agents?.defaults?.models?.[ZAI_DEFAULT_MODEL_REF]?.alias ?? "GLM"
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
}),
|
|
1417
|
+
noteDefault: ZAI_DEFAULT_MODEL_REF,
|
|
1418
|
+
noteAgentModel,
|
|
1419
|
+
prompter: params.prompter
|
|
1420
|
+
});
|
|
1421
|
+
nextConfig = applied.config;
|
|
1422
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1423
|
+
}
|
|
1424
|
+
return {
|
|
1425
|
+
config: nextConfig,
|
|
1426
|
+
agentModelOverride
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
if (authChoice === "xiaomi-api-key") {
|
|
1430
|
+
let hasCredential = false;
|
|
1431
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "xiaomi") {
|
|
1432
|
+
await setXiaomiApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1433
|
+
hasCredential = true;
|
|
1434
|
+
}
|
|
1435
|
+
const envKey = resolveEnvApiKey("xiaomi");
|
|
1436
|
+
if (envKey) {
|
|
1437
|
+
if (await params.prompter.confirm({
|
|
1438
|
+
message: `Use existing XIAOMI_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1439
|
+
initialValue: true
|
|
1440
|
+
})) {
|
|
1441
|
+
await setXiaomiApiKey(envKey.apiKey, params.agentDir);
|
|
1442
|
+
hasCredential = true;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
if (!hasCredential) {
|
|
1446
|
+
const key = await params.prompter.text({
|
|
1447
|
+
message: "Enter Xiaomi API key",
|
|
1448
|
+
validate: validateApiKeyInput
|
|
1449
|
+
});
|
|
1450
|
+
await setXiaomiApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1451
|
+
}
|
|
1452
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1453
|
+
profileId: "xiaomi:default",
|
|
1454
|
+
provider: "xiaomi",
|
|
1455
|
+
mode: "api_key"
|
|
1456
|
+
});
|
|
1457
|
+
{
|
|
1458
|
+
const applied = await applyDefaultModelChoice({
|
|
1459
|
+
config: nextConfig,
|
|
1460
|
+
setDefaultModel: params.setDefaultModel,
|
|
1461
|
+
defaultModel: XIAOMI_DEFAULT_MODEL_REF,
|
|
1462
|
+
applyDefaultConfig: applyXiaomiConfig,
|
|
1463
|
+
applyProviderConfig: applyXiaomiProviderConfig,
|
|
1464
|
+
noteDefault: XIAOMI_DEFAULT_MODEL_REF,
|
|
1465
|
+
noteAgentModel,
|
|
1466
|
+
prompter: params.prompter
|
|
1467
|
+
});
|
|
1468
|
+
nextConfig = applied.config;
|
|
1469
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1470
|
+
}
|
|
1471
|
+
return {
|
|
1472
|
+
config: nextConfig,
|
|
1473
|
+
agentModelOverride
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
if (authChoice === "synthetic-api-key") {
|
|
1477
|
+
if (params.opts?.token && params.opts?.tokenProvider === "synthetic") await setSyntheticApiKey(String(params.opts.token).trim(), params.agentDir);
|
|
1478
|
+
else {
|
|
1479
|
+
const key = await params.prompter.text({
|
|
1480
|
+
message: "Enter Synthetic API key",
|
|
1481
|
+
validate: (value) => value?.trim() ? void 0 : "Required"
|
|
1482
|
+
});
|
|
1483
|
+
await setSyntheticApiKey(String(key).trim(), params.agentDir);
|
|
1484
|
+
}
|
|
1485
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1486
|
+
profileId: "synthetic:default",
|
|
1487
|
+
provider: "synthetic",
|
|
1488
|
+
mode: "api_key"
|
|
1489
|
+
});
|
|
1490
|
+
{
|
|
1491
|
+
const applied = await applyDefaultModelChoice({
|
|
1492
|
+
config: nextConfig,
|
|
1493
|
+
setDefaultModel: params.setDefaultModel,
|
|
1494
|
+
defaultModel: SYNTHETIC_DEFAULT_MODEL_REF,
|
|
1495
|
+
applyDefaultConfig: applySyntheticConfig,
|
|
1496
|
+
applyProviderConfig: applySyntheticProviderConfig,
|
|
1497
|
+
noteDefault: SYNTHETIC_DEFAULT_MODEL_REF,
|
|
1498
|
+
noteAgentModel,
|
|
1499
|
+
prompter: params.prompter
|
|
1500
|
+
});
|
|
1501
|
+
nextConfig = applied.config;
|
|
1502
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1503
|
+
}
|
|
1504
|
+
return {
|
|
1505
|
+
config: nextConfig,
|
|
1506
|
+
agentModelOverride
|
|
1507
|
+
};
|
|
1508
|
+
}
|
|
1509
|
+
if (authChoice === "venice-api-key") {
|
|
1510
|
+
let hasCredential = false;
|
|
1511
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "venice") {
|
|
1512
|
+
await setVeniceApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1513
|
+
hasCredential = true;
|
|
1514
|
+
}
|
|
1515
|
+
if (!hasCredential) await params.prompter.note([
|
|
1516
|
+
"Venice AI provides privacy-focused inference with uncensored models.",
|
|
1517
|
+
"Get your API key at: https://venice.ai/settings/api",
|
|
1518
|
+
"Supports 'private' (fully private) and 'anonymized' (proxy) modes."
|
|
1519
|
+
].join("\n"), "Venice AI");
|
|
1520
|
+
const envKey = resolveEnvApiKey("venice");
|
|
1521
|
+
if (envKey) {
|
|
1522
|
+
if (await params.prompter.confirm({
|
|
1523
|
+
message: `Use existing VENICE_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1524
|
+
initialValue: true
|
|
1525
|
+
})) {
|
|
1526
|
+
await setVeniceApiKey(envKey.apiKey, params.agentDir);
|
|
1527
|
+
hasCredential = true;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
if (!hasCredential) {
|
|
1531
|
+
const key = await params.prompter.text({
|
|
1532
|
+
message: "Enter Venice AI API key",
|
|
1533
|
+
validate: validateApiKeyInput
|
|
1534
|
+
});
|
|
1535
|
+
await setVeniceApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1536
|
+
}
|
|
1537
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1538
|
+
profileId: "venice:default",
|
|
1539
|
+
provider: "venice",
|
|
1540
|
+
mode: "api_key"
|
|
1541
|
+
});
|
|
1542
|
+
{
|
|
1543
|
+
const applied = await applyDefaultModelChoice({
|
|
1544
|
+
config: nextConfig,
|
|
1545
|
+
setDefaultModel: params.setDefaultModel,
|
|
1546
|
+
defaultModel: VENICE_DEFAULT_MODEL_REF,
|
|
1547
|
+
applyDefaultConfig: applyVeniceConfig,
|
|
1548
|
+
applyProviderConfig: applyVeniceProviderConfig,
|
|
1549
|
+
noteDefault: VENICE_DEFAULT_MODEL_REF,
|
|
1550
|
+
noteAgentModel,
|
|
1551
|
+
prompter: params.prompter
|
|
1552
|
+
});
|
|
1553
|
+
nextConfig = applied.config;
|
|
1554
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1555
|
+
}
|
|
1556
|
+
return {
|
|
1557
|
+
config: nextConfig,
|
|
1558
|
+
agentModelOverride
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
if (authChoice === "opencode-zen") {
|
|
1562
|
+
let hasCredential = false;
|
|
1563
|
+
if (!hasCredential && params.opts?.token && params.opts?.tokenProvider === "opencode") {
|
|
1564
|
+
await setOpencodeZenApiKey(normalizeApiKeyInput(params.opts.token), params.agentDir);
|
|
1565
|
+
hasCredential = true;
|
|
1566
|
+
}
|
|
1567
|
+
if (!hasCredential) await params.prompter.note([
|
|
1568
|
+
"OpenCode Zen provides access to Claude, GPT, Gemini, and more models.",
|
|
1569
|
+
"Get your API key at: https://opencode.ai/auth",
|
|
1570
|
+
"Requires an active OpenCode Zen subscription."
|
|
1571
|
+
].join("\n"), "OpenCode Zen");
|
|
1572
|
+
const envKey = resolveEnvApiKey("opencode");
|
|
1573
|
+
if (envKey) {
|
|
1574
|
+
if (await params.prompter.confirm({
|
|
1575
|
+
message: `Use existing OPENCODE_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1576
|
+
initialValue: true
|
|
1577
|
+
})) {
|
|
1578
|
+
await setOpencodeZenApiKey(envKey.apiKey, params.agentDir);
|
|
1579
|
+
hasCredential = true;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
if (!hasCredential) {
|
|
1583
|
+
const key = await params.prompter.text({
|
|
1584
|
+
message: "Enter OpenCode Zen API key",
|
|
1585
|
+
validate: validateApiKeyInput
|
|
1586
|
+
});
|
|
1587
|
+
await setOpencodeZenApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1588
|
+
}
|
|
1589
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1590
|
+
profileId: "opencode:default",
|
|
1591
|
+
provider: "opencode",
|
|
1592
|
+
mode: "api_key"
|
|
1593
|
+
});
|
|
1594
|
+
{
|
|
1595
|
+
const applied = await applyDefaultModelChoice({
|
|
1596
|
+
config: nextConfig,
|
|
1597
|
+
setDefaultModel: params.setDefaultModel,
|
|
1598
|
+
defaultModel: OPENCODE_ZEN_DEFAULT_MODEL,
|
|
1599
|
+
applyDefaultConfig: applyOpencodeZenConfig,
|
|
1600
|
+
applyProviderConfig: applyOpencodeZenProviderConfig,
|
|
1601
|
+
noteDefault: OPENCODE_ZEN_DEFAULT_MODEL,
|
|
1602
|
+
noteAgentModel,
|
|
1603
|
+
prompter: params.prompter
|
|
1604
|
+
});
|
|
1605
|
+
nextConfig = applied.config;
|
|
1606
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1607
|
+
}
|
|
1608
|
+
return {
|
|
1609
|
+
config: nextConfig,
|
|
1610
|
+
agentModelOverride
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
return null;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
//#endregion
|
|
1617
|
+
//#region src/commands/auth-choice.apply.plugin-provider.ts
|
|
1618
|
+
function resolveProviderMatch(providers, rawProvider) {
|
|
1619
|
+
const normalized = normalizeProviderId(rawProvider);
|
|
1620
|
+
return providers.find((provider) => normalizeProviderId(provider.id) === normalized) ?? providers.find((provider) => provider.aliases?.some((alias) => normalizeProviderId(alias) === normalized) ?? false) ?? null;
|
|
1621
|
+
}
|
|
1622
|
+
function pickAuthMethod(provider, rawMethod) {
|
|
1623
|
+
const raw = rawMethod?.trim();
|
|
1624
|
+
if (!raw) return null;
|
|
1625
|
+
const normalized = raw.toLowerCase();
|
|
1626
|
+
return provider.auth.find((method) => method.id.toLowerCase() === normalized) ?? provider.auth.find((method) => method.label.toLowerCase() === normalized) ?? null;
|
|
1627
|
+
}
|
|
1628
|
+
function isPlainRecord(value) {
|
|
1629
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
1630
|
+
}
|
|
1631
|
+
function mergeConfigPatch(base, patch) {
|
|
1632
|
+
if (!isPlainRecord(base) || !isPlainRecord(patch)) return patch;
|
|
1633
|
+
const next = { ...base };
|
|
1634
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
1635
|
+
const existing = next[key];
|
|
1636
|
+
if (isPlainRecord(existing) && isPlainRecord(value)) next[key] = mergeConfigPatch(existing, value);
|
|
1637
|
+
else next[key] = value;
|
|
1638
|
+
}
|
|
1639
|
+
return next;
|
|
1640
|
+
}
|
|
1641
|
+
function applyDefaultModel(cfg, model) {
|
|
1642
|
+
const models = { ...cfg.agents?.defaults?.models };
|
|
1643
|
+
models[model] = models[model] ?? {};
|
|
1644
|
+
const existingModel = cfg.agents?.defaults?.model;
|
|
1645
|
+
return {
|
|
1646
|
+
...cfg,
|
|
1647
|
+
agents: {
|
|
1648
|
+
...cfg.agents,
|
|
1649
|
+
defaults: {
|
|
1650
|
+
...cfg.agents?.defaults,
|
|
1651
|
+
models,
|
|
1652
|
+
model: {
|
|
1653
|
+
...existingModel && typeof existingModel === "object" && "fallbacks" in existingModel ? { fallbacks: existingModel.fallbacks } : void 0,
|
|
1654
|
+
primary: model
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
async function applyAuthChoicePluginProvider(params, options) {
|
|
1661
|
+
if (params.authChoice !== options.authChoice) return null;
|
|
1662
|
+
const enableResult = enablePluginInConfig(params.config, options.pluginId);
|
|
1663
|
+
let nextConfig = enableResult.config;
|
|
1664
|
+
if (!enableResult.enabled) {
|
|
1665
|
+
await params.prompter.note(`${options.label} plugin is disabled (${enableResult.reason ?? "blocked"}).`, options.label);
|
|
1666
|
+
return { config: nextConfig };
|
|
1667
|
+
}
|
|
1668
|
+
const agentId = params.agentId ?? resolveDefaultAgentId(nextConfig);
|
|
1669
|
+
const defaultAgentId = resolveDefaultAgentId(nextConfig);
|
|
1670
|
+
const agentDir = params.agentDir ?? (agentId === defaultAgentId ? resolveOpenClawAgentDir() : resolveAgentDir(nextConfig, agentId));
|
|
1671
|
+
const workspaceDir = resolveAgentWorkspaceDir(nextConfig, agentId) ?? resolveDefaultAgentWorkspaceDir();
|
|
1672
|
+
const provider = resolveProviderMatch(resolvePluginProviders({
|
|
1673
|
+
config: nextConfig,
|
|
1674
|
+
workspaceDir
|
|
1675
|
+
}), options.providerId);
|
|
1676
|
+
if (!provider) {
|
|
1677
|
+
await params.prompter.note(`${options.label} auth plugin is not available. Enable it and re-run the wizard.`, options.label);
|
|
1678
|
+
return { config: nextConfig };
|
|
1679
|
+
}
|
|
1680
|
+
const method = pickAuthMethod(provider, options.methodId) ?? provider.auth[0];
|
|
1681
|
+
if (!method) {
|
|
1682
|
+
await params.prompter.note(`${options.label} auth method missing.`, options.label);
|
|
1683
|
+
return { config: nextConfig };
|
|
1684
|
+
}
|
|
1685
|
+
const isRemote = isRemoteEnvironment();
|
|
1686
|
+
const result = await method.run({
|
|
1687
|
+
config: nextConfig,
|
|
1688
|
+
agentDir,
|
|
1689
|
+
workspaceDir,
|
|
1690
|
+
prompter: params.prompter,
|
|
1691
|
+
runtime: params.runtime,
|
|
1692
|
+
isRemote,
|
|
1693
|
+
openUrl: async (url) => {
|
|
1694
|
+
await openUrl(url);
|
|
1695
|
+
},
|
|
1696
|
+
oauth: { createVpsAwareHandlers: (opts) => createVpsAwareOAuthHandlers(opts) }
|
|
1697
|
+
});
|
|
1698
|
+
if (result.configPatch) nextConfig = mergeConfigPatch(nextConfig, result.configPatch);
|
|
1699
|
+
for (const profile of result.profiles) {
|
|
1700
|
+
upsertAuthProfile({
|
|
1701
|
+
profileId: profile.profileId,
|
|
1702
|
+
credential: profile.credential,
|
|
1703
|
+
agentDir
|
|
1704
|
+
});
|
|
1705
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1706
|
+
profileId: profile.profileId,
|
|
1707
|
+
provider: profile.credential.provider,
|
|
1708
|
+
mode: profile.credential.type === "token" ? "token" : profile.credential.type,
|
|
1709
|
+
..."email" in profile.credential && profile.credential.email ? { email: profile.credential.email } : {}
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
let agentModelOverride;
|
|
1713
|
+
if (result.defaultModel) {
|
|
1714
|
+
if (params.setDefaultModel) {
|
|
1715
|
+
nextConfig = applyDefaultModel(nextConfig, result.defaultModel);
|
|
1716
|
+
await params.prompter.note(`Default model set to ${result.defaultModel}`, "Model configured");
|
|
1717
|
+
} else if (params.agentId) {
|
|
1718
|
+
agentModelOverride = result.defaultModel;
|
|
1719
|
+
await params.prompter.note(`Default model set to ${result.defaultModel} for agent "${params.agentId}".`, "Model configured");
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
if (result.notes && result.notes.length > 0) await params.prompter.note(result.notes.join("\n"), "Provider notes");
|
|
1723
|
+
return {
|
|
1724
|
+
config: nextConfig,
|
|
1725
|
+
agentModelOverride
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
//#endregion
|
|
1730
|
+
//#region src/commands/auth-choice.apply.copilot-proxy.ts
|
|
1731
|
+
async function applyAuthChoiceCopilotProxy(params) {
|
|
1732
|
+
return await applyAuthChoicePluginProvider(params, {
|
|
1733
|
+
authChoice: "copilot-proxy",
|
|
1734
|
+
pluginId: "copilot-proxy",
|
|
1735
|
+
providerId: "copilot-proxy",
|
|
1736
|
+
methodId: "local",
|
|
1737
|
+
label: "Copilot Proxy"
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
//#endregion
|
|
1742
|
+
//#region src/commands/auth-choice.apply.github-copilot.ts
|
|
1743
|
+
async function applyAuthChoiceGitHubCopilot(params) {
|
|
1744
|
+
if (params.authChoice !== "github-copilot") return null;
|
|
1745
|
+
let nextConfig = params.config;
|
|
1746
|
+
await params.prompter.note(["This will open a GitHub device login to authorize Copilot.", "Requires an active GitHub Copilot subscription."].join("\n"), "GitHub Copilot");
|
|
1747
|
+
if (!process.stdin.isTTY) {
|
|
1748
|
+
await params.prompter.note("GitHub Copilot login requires an interactive TTY.", "GitHub Copilot");
|
|
1749
|
+
return { config: nextConfig };
|
|
1750
|
+
}
|
|
1751
|
+
try {
|
|
1752
|
+
await githubCopilotLoginCommand({ yes: true }, params.runtime);
|
|
1753
|
+
} catch (err) {
|
|
1754
|
+
await params.prompter.note(`GitHub Copilot login failed: ${String(err)}`, "GitHub Copilot");
|
|
1755
|
+
return { config: nextConfig };
|
|
1756
|
+
}
|
|
1757
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1758
|
+
profileId: "github-copilot:github",
|
|
1759
|
+
provider: "github-copilot",
|
|
1760
|
+
mode: "token"
|
|
1761
|
+
});
|
|
1762
|
+
if (params.setDefaultModel) {
|
|
1763
|
+
const model = "github-copilot/gpt-4o";
|
|
1764
|
+
nextConfig = {
|
|
1765
|
+
...nextConfig,
|
|
1766
|
+
agents: {
|
|
1767
|
+
...nextConfig.agents,
|
|
1768
|
+
defaults: {
|
|
1769
|
+
...nextConfig.agents?.defaults,
|
|
1770
|
+
model: {
|
|
1771
|
+
...typeof nextConfig.agents?.defaults?.model === "object" ? nextConfig.agents.defaults.model : void 0,
|
|
1772
|
+
primary: model
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
};
|
|
1777
|
+
await params.prompter.note(`Default model set to ${model}`, "Model configured");
|
|
1778
|
+
}
|
|
1779
|
+
return { config: nextConfig };
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
//#endregion
|
|
1783
|
+
//#region src/commands/auth-choice.apply.google-antigravity.ts
|
|
1784
|
+
async function applyAuthChoiceGoogleAntigravity(params) {
|
|
1785
|
+
return await applyAuthChoicePluginProvider(params, {
|
|
1786
|
+
authChoice: "google-antigravity",
|
|
1787
|
+
pluginId: "google-antigravity-auth",
|
|
1788
|
+
providerId: "google-antigravity",
|
|
1789
|
+
methodId: "oauth",
|
|
1790
|
+
label: "Google Antigravity"
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
//#endregion
|
|
1795
|
+
//#region src/commands/auth-choice.apply.google-gemini-cli.ts
|
|
1796
|
+
async function applyAuthChoiceGoogleGeminiCli(params) {
|
|
1797
|
+
return await applyAuthChoicePluginProvider(params, {
|
|
1798
|
+
authChoice: "google-gemini-cli",
|
|
1799
|
+
pluginId: "google-gemini-cli-auth",
|
|
1800
|
+
providerId: "google-gemini-cli",
|
|
1801
|
+
methodId: "oauth",
|
|
1802
|
+
label: "Google Gemini CLI"
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
//#endregion
|
|
1807
|
+
//#region src/commands/auth-choice.apply.minimax.ts
|
|
1808
|
+
async function applyAuthChoiceMiniMax(params) {
|
|
1809
|
+
let nextConfig = params.config;
|
|
1810
|
+
let agentModelOverride;
|
|
1811
|
+
const noteAgentModel = async (model) => {
|
|
1812
|
+
if (!params.agentId) return;
|
|
1813
|
+
await params.prompter.note(`Default model set to ${model} for agent "${params.agentId}".`, "Model configured");
|
|
1814
|
+
};
|
|
1815
|
+
if (params.authChoice === "minimax-portal") return await applyAuthChoicePluginProvider(params, {
|
|
1816
|
+
authChoice: "minimax-portal",
|
|
1817
|
+
pluginId: "minimax-portal-auth",
|
|
1818
|
+
providerId: "minimax-portal",
|
|
1819
|
+
methodId: await params.prompter.select({
|
|
1820
|
+
message: "Select MiniMax endpoint",
|
|
1821
|
+
options: [{
|
|
1822
|
+
value: "oauth",
|
|
1823
|
+
label: "Global",
|
|
1824
|
+
hint: "OAuth for international users"
|
|
1825
|
+
}, {
|
|
1826
|
+
value: "oauth-cn",
|
|
1827
|
+
label: "CN",
|
|
1828
|
+
hint: "OAuth for users in China"
|
|
1829
|
+
}]
|
|
1830
|
+
}),
|
|
1831
|
+
label: "MiniMax"
|
|
1832
|
+
});
|
|
1833
|
+
if (params.authChoice === "minimax-cloud" || params.authChoice === "minimax-api" || params.authChoice === "minimax-api-lightning") {
|
|
1834
|
+
const modelId = params.authChoice === "minimax-api-lightning" ? "MiniMax-M2.1-lightning" : "MiniMax-M2.1";
|
|
1835
|
+
let hasCredential = false;
|
|
1836
|
+
const envKey = resolveEnvApiKey("minimax");
|
|
1837
|
+
if (envKey) {
|
|
1838
|
+
if (await params.prompter.confirm({
|
|
1839
|
+
message: `Use existing MINIMAX_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
1840
|
+
initialValue: true
|
|
1841
|
+
})) {
|
|
1842
|
+
await setMinimaxApiKey(envKey.apiKey, params.agentDir);
|
|
1843
|
+
hasCredential = true;
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
if (!hasCredential) {
|
|
1847
|
+
const key = await params.prompter.text({
|
|
1848
|
+
message: "Enter MiniMax API key",
|
|
1849
|
+
validate: validateApiKeyInput
|
|
1850
|
+
});
|
|
1851
|
+
await setMinimaxApiKey(normalizeApiKeyInput(String(key)), params.agentDir);
|
|
1852
|
+
}
|
|
1853
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
1854
|
+
profileId: "minimax:default",
|
|
1855
|
+
provider: "minimax",
|
|
1856
|
+
mode: "api_key"
|
|
1857
|
+
});
|
|
1858
|
+
{
|
|
1859
|
+
const modelRef = `minimax/${modelId}`;
|
|
1860
|
+
const applied = await applyDefaultModelChoice({
|
|
1861
|
+
config: nextConfig,
|
|
1862
|
+
setDefaultModel: params.setDefaultModel,
|
|
1863
|
+
defaultModel: modelRef,
|
|
1864
|
+
applyDefaultConfig: (config) => applyMinimaxApiConfig(config, modelId),
|
|
1865
|
+
applyProviderConfig: (config) => applyMinimaxApiProviderConfig(config, modelId),
|
|
1866
|
+
noteAgentModel,
|
|
1867
|
+
prompter: params.prompter
|
|
1868
|
+
});
|
|
1869
|
+
nextConfig = applied.config;
|
|
1870
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1871
|
+
}
|
|
1872
|
+
return {
|
|
1873
|
+
config: nextConfig,
|
|
1874
|
+
agentModelOverride
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
if (params.authChoice === "minimax") {
|
|
1878
|
+
const applied = await applyDefaultModelChoice({
|
|
1879
|
+
config: nextConfig,
|
|
1880
|
+
setDefaultModel: params.setDefaultModel,
|
|
1881
|
+
defaultModel: "lmstudio/minimax-m2.1-gs32",
|
|
1882
|
+
applyDefaultConfig: applyMinimaxConfig,
|
|
1883
|
+
applyProviderConfig: applyMinimaxProviderConfig,
|
|
1884
|
+
noteAgentModel,
|
|
1885
|
+
prompter: params.prompter
|
|
1886
|
+
});
|
|
1887
|
+
nextConfig = applied.config;
|
|
1888
|
+
agentModelOverride = applied.agentModelOverride ?? agentModelOverride;
|
|
1889
|
+
return {
|
|
1890
|
+
config: nextConfig,
|
|
1891
|
+
agentModelOverride
|
|
1892
|
+
};
|
|
1893
|
+
}
|
|
1894
|
+
return null;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
//#endregion
|
|
1898
|
+
//#region src/commands/chutes-oauth.ts
|
|
1899
|
+
function buildAuthorizeUrl(params) {
|
|
1900
|
+
return `${CHUTES_AUTHORIZE_ENDPOINT}?${new URLSearchParams({
|
|
1901
|
+
client_id: params.clientId,
|
|
1902
|
+
redirect_uri: params.redirectUri,
|
|
1903
|
+
response_type: "code",
|
|
1904
|
+
scope: params.scopes.join(" "),
|
|
1905
|
+
state: params.state,
|
|
1906
|
+
code_challenge: params.challenge,
|
|
1907
|
+
code_challenge_method: "S256"
|
|
1908
|
+
}).toString()}`;
|
|
1909
|
+
}
|
|
1910
|
+
async function waitForLocalCallback(params) {
|
|
1911
|
+
const redirectUrl = new URL(params.redirectUri);
|
|
1912
|
+
if (redirectUrl.protocol !== "http:") throw new Error(`Chutes OAuth redirect URI must be http:// (got ${params.redirectUri})`);
|
|
1913
|
+
const hostname = redirectUrl.hostname || "127.0.0.1";
|
|
1914
|
+
const port = redirectUrl.port ? Number.parseInt(redirectUrl.port, 10) : 80;
|
|
1915
|
+
const expectedPath = redirectUrl.pathname || "/";
|
|
1916
|
+
return await new Promise((resolve, reject) => {
|
|
1917
|
+
let timeout = null;
|
|
1918
|
+
const server = createServer((req, res) => {
|
|
1919
|
+
try {
|
|
1920
|
+
const requestUrl = new URL(req.url ?? "/", redirectUrl.origin);
|
|
1921
|
+
if (requestUrl.pathname !== expectedPath) {
|
|
1922
|
+
res.statusCode = 404;
|
|
1923
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
1924
|
+
res.end("Not found");
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
const code = requestUrl.searchParams.get("code")?.trim();
|
|
1928
|
+
const state = requestUrl.searchParams.get("state")?.trim();
|
|
1929
|
+
if (!code) {
|
|
1930
|
+
res.statusCode = 400;
|
|
1931
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
1932
|
+
res.end("Missing code");
|
|
1933
|
+
return;
|
|
1934
|
+
}
|
|
1935
|
+
if (!state || state !== params.expectedState) {
|
|
1936
|
+
res.statusCode = 400;
|
|
1937
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
1938
|
+
res.end("Invalid state");
|
|
1939
|
+
return;
|
|
1940
|
+
}
|
|
1941
|
+
res.statusCode = 200;
|
|
1942
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
1943
|
+
res.end([
|
|
1944
|
+
"<!doctype html>",
|
|
1945
|
+
"<html><head><meta charset='utf-8' /></head>",
|
|
1946
|
+
"<body><h2>Chutes OAuth complete</h2>",
|
|
1947
|
+
"<p>You can close this window and return to OpenClaw.</p></body></html>"
|
|
1948
|
+
].join(""));
|
|
1949
|
+
if (timeout) clearTimeout(timeout);
|
|
1950
|
+
server.close();
|
|
1951
|
+
resolve({
|
|
1952
|
+
code,
|
|
1953
|
+
state
|
|
1954
|
+
});
|
|
1955
|
+
} catch (err) {
|
|
1956
|
+
if (timeout) clearTimeout(timeout);
|
|
1957
|
+
server.close();
|
|
1958
|
+
reject(err);
|
|
1959
|
+
}
|
|
1960
|
+
});
|
|
1961
|
+
server.once("error", (err) => {
|
|
1962
|
+
if (timeout) clearTimeout(timeout);
|
|
1963
|
+
server.close();
|
|
1964
|
+
reject(err);
|
|
1965
|
+
});
|
|
1966
|
+
server.listen(port, hostname, () => {
|
|
1967
|
+
params.onProgress?.(`Waiting for OAuth callback on ${redirectUrl.origin}${expectedPath}…`);
|
|
1968
|
+
});
|
|
1969
|
+
timeout = setTimeout(() => {
|
|
1970
|
+
try {
|
|
1971
|
+
server.close();
|
|
1972
|
+
} catch {}
|
|
1973
|
+
reject(/* @__PURE__ */ new Error("OAuth callback timeout"));
|
|
1974
|
+
}, params.timeoutMs);
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
async function loginChutes(params) {
|
|
1978
|
+
const createPkce = params.createPkce ?? generateChutesPkce;
|
|
1979
|
+
const createState = params.createState ?? (() => randomBytes(16).toString("hex"));
|
|
1980
|
+
const { verifier, challenge } = createPkce();
|
|
1981
|
+
const state = createState();
|
|
1982
|
+
const timeoutMs = params.timeoutMs ?? 180 * 1e3;
|
|
1983
|
+
const url = buildAuthorizeUrl({
|
|
1984
|
+
clientId: params.app.clientId,
|
|
1985
|
+
redirectUri: params.app.redirectUri,
|
|
1986
|
+
scopes: params.app.scopes,
|
|
1987
|
+
state,
|
|
1988
|
+
challenge
|
|
1989
|
+
});
|
|
1990
|
+
let codeAndState;
|
|
1991
|
+
if (params.manual) {
|
|
1992
|
+
await params.onAuth({ url });
|
|
1993
|
+
params.onProgress?.("Waiting for redirect URL…");
|
|
1994
|
+
const input = await params.onPrompt({
|
|
1995
|
+
message: "Paste the redirect URL (or authorization code)",
|
|
1996
|
+
placeholder: `${params.app.redirectUri}?code=...&state=...`
|
|
1997
|
+
});
|
|
1998
|
+
const parsed = parseOAuthCallbackInput(String(input), state);
|
|
1999
|
+
if ("error" in parsed) throw new Error(parsed.error);
|
|
2000
|
+
if (parsed.state !== state) throw new Error("Invalid OAuth state");
|
|
2001
|
+
codeAndState = parsed;
|
|
2002
|
+
} else {
|
|
2003
|
+
const callback = waitForLocalCallback({
|
|
2004
|
+
redirectUri: params.app.redirectUri,
|
|
2005
|
+
expectedState: state,
|
|
2006
|
+
timeoutMs,
|
|
2007
|
+
onProgress: params.onProgress
|
|
2008
|
+
}).catch(async () => {
|
|
2009
|
+
params.onProgress?.("OAuth callback not detected; paste redirect URL…");
|
|
2010
|
+
const input = await params.onPrompt({
|
|
2011
|
+
message: "Paste the redirect URL (or authorization code)",
|
|
2012
|
+
placeholder: `${params.app.redirectUri}?code=...&state=...`
|
|
2013
|
+
});
|
|
2014
|
+
const parsed = parseOAuthCallbackInput(String(input), state);
|
|
2015
|
+
if ("error" in parsed) throw new Error(parsed.error);
|
|
2016
|
+
if (parsed.state !== state) throw new Error("Invalid OAuth state");
|
|
2017
|
+
return parsed;
|
|
2018
|
+
});
|
|
2019
|
+
await params.onAuth({ url });
|
|
2020
|
+
codeAndState = await callback;
|
|
2021
|
+
}
|
|
2022
|
+
params.onProgress?.("Exchanging code for tokens…");
|
|
2023
|
+
return await exchangeChutesCodeForTokens({
|
|
2024
|
+
app: params.app,
|
|
2025
|
+
code: codeAndState.code,
|
|
2026
|
+
codeVerifier: verifier,
|
|
2027
|
+
fetchFn: params.fetchFn
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
//#endregion
|
|
2032
|
+
//#region src/commands/auth-choice.apply.oauth.ts
|
|
2033
|
+
async function applyAuthChoiceOAuth(params) {
|
|
2034
|
+
if (params.authChoice === "chutes") {
|
|
2035
|
+
let nextConfig = params.config;
|
|
2036
|
+
const isRemote = isRemoteEnvironment();
|
|
2037
|
+
const redirectUri = process.env.CHUTES_OAUTH_REDIRECT_URI?.trim() || "http://127.0.0.1:1456/oauth-callback";
|
|
2038
|
+
const scopes = process.env.CHUTES_OAUTH_SCOPES?.trim() || "openid profile chutes:invoke";
|
|
2039
|
+
const clientId = process.env.CHUTES_CLIENT_ID?.trim() || String(await params.prompter.text({
|
|
2040
|
+
message: "Enter Chutes OAuth client id",
|
|
2041
|
+
placeholder: "cid_xxx",
|
|
2042
|
+
validate: (value) => value?.trim() ? void 0 : "Required"
|
|
2043
|
+
})).trim();
|
|
2044
|
+
const clientSecret = process.env.CHUTES_CLIENT_SECRET?.trim() || void 0;
|
|
2045
|
+
await params.prompter.note(isRemote ? [
|
|
2046
|
+
"You are running in a remote/VPS environment.",
|
|
2047
|
+
"A URL will be shown for you to open in your LOCAL browser.",
|
|
2048
|
+
"After signing in, paste the redirect URL back here.",
|
|
2049
|
+
"",
|
|
2050
|
+
`Redirect URI: ${redirectUri}`
|
|
2051
|
+
].join("\n") : [
|
|
2052
|
+
"Browser will open for Chutes authentication.",
|
|
2053
|
+
"If the callback doesn't auto-complete, paste the redirect URL.",
|
|
2054
|
+
"",
|
|
2055
|
+
`Redirect URI: ${redirectUri}`
|
|
2056
|
+
].join("\n"), "Chutes OAuth");
|
|
2057
|
+
const spin = params.prompter.progress("Starting OAuth flow…");
|
|
2058
|
+
try {
|
|
2059
|
+
const { onAuth, onPrompt } = createVpsAwareOAuthHandlers({
|
|
2060
|
+
isRemote,
|
|
2061
|
+
prompter: params.prompter,
|
|
2062
|
+
runtime: params.runtime,
|
|
2063
|
+
spin,
|
|
2064
|
+
openUrl,
|
|
2065
|
+
localBrowserMessage: "Complete sign-in in browser…"
|
|
2066
|
+
});
|
|
2067
|
+
const creds = await loginChutes({
|
|
2068
|
+
app: {
|
|
2069
|
+
clientId,
|
|
2070
|
+
clientSecret,
|
|
2071
|
+
redirectUri,
|
|
2072
|
+
scopes: scopes.split(/\s+/).filter(Boolean)
|
|
2073
|
+
},
|
|
2074
|
+
manual: isRemote,
|
|
2075
|
+
onAuth,
|
|
2076
|
+
onPrompt,
|
|
2077
|
+
onProgress: (msg) => spin.update(msg)
|
|
2078
|
+
});
|
|
2079
|
+
spin.stop("Chutes OAuth complete");
|
|
2080
|
+
const profileId = `chutes:${typeof creds.email === "string" && creds.email.trim() ? creds.email.trim() : "default"}`;
|
|
2081
|
+
await writeOAuthCredentials("chutes", creds, params.agentDir);
|
|
2082
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
2083
|
+
profileId,
|
|
2084
|
+
provider: "chutes",
|
|
2085
|
+
mode: "oauth"
|
|
2086
|
+
});
|
|
2087
|
+
} catch (err) {
|
|
2088
|
+
spin.stop("Chutes OAuth failed");
|
|
2089
|
+
params.runtime.error(String(err));
|
|
2090
|
+
await params.prompter.note([
|
|
2091
|
+
"Trouble with OAuth?",
|
|
2092
|
+
"Verify CHUTES_CLIENT_ID (and CHUTES_CLIENT_SECRET if required).",
|
|
2093
|
+
`Verify the OAuth app redirect URI includes: ${redirectUri}`,
|
|
2094
|
+
"Chutes docs: https://chutes.ai/docs/sign-in-with-chutes/overview"
|
|
2095
|
+
].join("\n"), "OAuth help");
|
|
2096
|
+
}
|
|
2097
|
+
return { config: nextConfig };
|
|
2098
|
+
}
|
|
2099
|
+
return null;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
//#endregion
|
|
2103
|
+
//#region src/infra/env-file.ts
|
|
2104
|
+
function escapeRegExp(value) {
|
|
2105
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2106
|
+
}
|
|
2107
|
+
function upsertSharedEnvVar(params) {
|
|
2108
|
+
const dir = resolveConfigDir(params.env ?? process.env);
|
|
2109
|
+
const filepath = path.join(dir, ".env");
|
|
2110
|
+
const key = params.key.trim();
|
|
2111
|
+
const value = params.value;
|
|
2112
|
+
let raw = "";
|
|
2113
|
+
if (fs.existsSync(filepath)) raw = fs.readFileSync(filepath, "utf8");
|
|
2114
|
+
const lines = raw.length ? raw.split(/\r?\n/) : [];
|
|
2115
|
+
const matcher = new RegExp(`^(\\s*(?:export\\s+)?)${escapeRegExp(key)}\\s*=`);
|
|
2116
|
+
let updated = false;
|
|
2117
|
+
let replaced = false;
|
|
2118
|
+
const nextLines = lines.map((line) => {
|
|
2119
|
+
const match = line.match(matcher);
|
|
2120
|
+
if (!match) return line;
|
|
2121
|
+
replaced = true;
|
|
2122
|
+
const next = `${match[1] ?? ""}${key}=${value}`;
|
|
2123
|
+
if (next !== line) updated = true;
|
|
2124
|
+
return next;
|
|
2125
|
+
});
|
|
2126
|
+
if (!replaced) {
|
|
2127
|
+
nextLines.push(`${key}=${value}`);
|
|
2128
|
+
updated = true;
|
|
2129
|
+
}
|
|
2130
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, {
|
|
2131
|
+
recursive: true,
|
|
2132
|
+
mode: 448
|
|
2133
|
+
});
|
|
2134
|
+
const output = `${nextLines.join("\n")}\n`;
|
|
2135
|
+
fs.writeFileSync(filepath, output, "utf8");
|
|
2136
|
+
fs.chmodSync(filepath, 384);
|
|
2137
|
+
return {
|
|
2138
|
+
path: filepath,
|
|
2139
|
+
updated,
|
|
2140
|
+
created: !raw
|
|
2141
|
+
};
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
//#endregion
|
|
2145
|
+
//#region src/commands/openai-codex-model-default.ts
|
|
2146
|
+
const OPENAI_CODEX_DEFAULT_MODEL = "openai-codex/gpt-5.2";
|
|
2147
|
+
function shouldSetOpenAICodexModel(model) {
|
|
2148
|
+
const trimmed = model?.trim();
|
|
2149
|
+
if (!trimmed) return true;
|
|
2150
|
+
const normalized = trimmed.toLowerCase();
|
|
2151
|
+
if (normalized.startsWith("openai-codex/")) return false;
|
|
2152
|
+
if (normalized.startsWith("openai/")) return true;
|
|
2153
|
+
return normalized === "gpt" || normalized === "gpt-mini";
|
|
2154
|
+
}
|
|
2155
|
+
function resolvePrimaryModel(model) {
|
|
2156
|
+
if (typeof model === "string") return model;
|
|
2157
|
+
if (model && typeof model === "object" && typeof model.primary === "string") return model.primary;
|
|
2158
|
+
}
|
|
2159
|
+
function applyOpenAICodexModelDefault(cfg) {
|
|
2160
|
+
if (!shouldSetOpenAICodexModel(resolvePrimaryModel(cfg.agents?.defaults?.model))) return {
|
|
2161
|
+
next: cfg,
|
|
2162
|
+
changed: false
|
|
2163
|
+
};
|
|
2164
|
+
return {
|
|
2165
|
+
next: {
|
|
2166
|
+
...cfg,
|
|
2167
|
+
agents: {
|
|
2168
|
+
...cfg.agents,
|
|
2169
|
+
defaults: {
|
|
2170
|
+
...cfg.agents?.defaults,
|
|
2171
|
+
model: cfg.agents?.defaults?.model && typeof cfg.agents.defaults.model === "object" ? {
|
|
2172
|
+
...cfg.agents.defaults.model,
|
|
2173
|
+
primary: OPENAI_CODEX_DEFAULT_MODEL
|
|
2174
|
+
} : { primary: OPENAI_CODEX_DEFAULT_MODEL }
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
},
|
|
2178
|
+
changed: true
|
|
2179
|
+
};
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
//#endregion
|
|
2183
|
+
//#region src/commands/auth-choice.apply.openai.ts
|
|
2184
|
+
async function applyAuthChoiceOpenAI(params) {
|
|
2185
|
+
let authChoice = params.authChoice;
|
|
2186
|
+
if (authChoice === "apiKey" && params.opts?.tokenProvider === "openai") authChoice = "openai-api-key";
|
|
2187
|
+
if (authChoice === "openai-api-key") {
|
|
2188
|
+
const envKey = resolveEnvApiKey("openai");
|
|
2189
|
+
if (envKey) {
|
|
2190
|
+
if (await params.prompter.confirm({
|
|
2191
|
+
message: `Use existing OPENAI_API_KEY (${envKey.source}, ${formatApiKeyPreview(envKey.apiKey)})?`,
|
|
2192
|
+
initialValue: true
|
|
2193
|
+
})) {
|
|
2194
|
+
const result = upsertSharedEnvVar({
|
|
2195
|
+
key: "OPENAI_API_KEY",
|
|
2196
|
+
value: envKey.apiKey
|
|
2197
|
+
});
|
|
2198
|
+
if (!process.env.OPENAI_API_KEY) process.env.OPENAI_API_KEY = envKey.apiKey;
|
|
2199
|
+
await params.prompter.note(`Copied OPENAI_API_KEY to ${result.path} for launchd compatibility.`, "OpenAI API key");
|
|
2200
|
+
return { config: params.config };
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
let key;
|
|
2204
|
+
if (params.opts?.token && params.opts?.tokenProvider === "openai") key = params.opts.token;
|
|
2205
|
+
else key = await params.prompter.text({
|
|
2206
|
+
message: "Enter OpenAI API key",
|
|
2207
|
+
validate: validateApiKeyInput
|
|
2208
|
+
});
|
|
2209
|
+
const trimmed = normalizeApiKeyInput(String(key));
|
|
2210
|
+
const result = upsertSharedEnvVar({
|
|
2211
|
+
key: "OPENAI_API_KEY",
|
|
2212
|
+
value: trimmed
|
|
2213
|
+
});
|
|
2214
|
+
process.env.OPENAI_API_KEY = trimmed;
|
|
2215
|
+
await params.prompter.note(`Saved OPENAI_API_KEY to ${result.path} for launchd compatibility.`, "OpenAI API key");
|
|
2216
|
+
return { config: params.config };
|
|
2217
|
+
}
|
|
2218
|
+
if (params.authChoice === "openai-codex") {
|
|
2219
|
+
let nextConfig = params.config;
|
|
2220
|
+
let agentModelOverride;
|
|
2221
|
+
const noteAgentModel = async (model) => {
|
|
2222
|
+
if (!params.agentId) return;
|
|
2223
|
+
await params.prompter.note(`Default model set to ${model} for agent "${params.agentId}".`, "Model configured");
|
|
2224
|
+
};
|
|
2225
|
+
const isRemote = isRemoteEnvironment();
|
|
2226
|
+
await params.prompter.note(isRemote ? [
|
|
2227
|
+
"You are running in a remote/VPS environment.",
|
|
2228
|
+
"A URL will be shown for you to open in your LOCAL browser.",
|
|
2229
|
+
"After signing in, paste the redirect URL back here."
|
|
2230
|
+
].join("\n") : [
|
|
2231
|
+
"Browser will open for OpenAI authentication.",
|
|
2232
|
+
"If the callback doesn't auto-complete, paste the redirect URL.",
|
|
2233
|
+
"OpenAI OAuth uses localhost:1455 for the callback."
|
|
2234
|
+
].join("\n"), "OpenAI Codex OAuth");
|
|
2235
|
+
const spin = params.prompter.progress("Starting OAuth flow…");
|
|
2236
|
+
try {
|
|
2237
|
+
const { onAuth, onPrompt } = createVpsAwareOAuthHandlers({
|
|
2238
|
+
isRemote,
|
|
2239
|
+
prompter: params.prompter,
|
|
2240
|
+
runtime: params.runtime,
|
|
2241
|
+
spin,
|
|
2242
|
+
openUrl,
|
|
2243
|
+
localBrowserMessage: "Complete sign-in in browser…"
|
|
2244
|
+
});
|
|
2245
|
+
const creds = await loginOpenAICodex({
|
|
2246
|
+
onAuth,
|
|
2247
|
+
onPrompt,
|
|
2248
|
+
onProgress: (msg) => spin.update(msg)
|
|
2249
|
+
});
|
|
2250
|
+
spin.stop("OpenAI OAuth complete");
|
|
2251
|
+
if (creds) {
|
|
2252
|
+
await writeOAuthCredentials("openai-codex", creds, params.agentDir);
|
|
2253
|
+
nextConfig = applyAuthProfileConfig(nextConfig, {
|
|
2254
|
+
profileId: "openai-codex:default",
|
|
2255
|
+
provider: "openai-codex",
|
|
2256
|
+
mode: "oauth"
|
|
2257
|
+
});
|
|
2258
|
+
if (params.setDefaultModel) {
|
|
2259
|
+
const applied = applyOpenAICodexModelDefault(nextConfig);
|
|
2260
|
+
nextConfig = applied.next;
|
|
2261
|
+
if (applied.changed) await params.prompter.note(`Default model set to ${OPENAI_CODEX_DEFAULT_MODEL}`, "Model configured");
|
|
2262
|
+
} else {
|
|
2263
|
+
agentModelOverride = OPENAI_CODEX_DEFAULT_MODEL;
|
|
2264
|
+
await noteAgentModel(OPENAI_CODEX_DEFAULT_MODEL);
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
} catch (err) {
|
|
2268
|
+
spin.stop("OpenAI OAuth failed");
|
|
2269
|
+
params.runtime.error(String(err));
|
|
2270
|
+
await params.prompter.note("Trouble with OAuth? See https://docs.openclaw.ai/start/faq", "OAuth help");
|
|
2271
|
+
}
|
|
2272
|
+
return {
|
|
2273
|
+
config: nextConfig,
|
|
2274
|
+
agentModelOverride
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
return null;
|
|
2278
|
+
}
|
|
2279
|
+
|
|
2280
|
+
//#endregion
|
|
2281
|
+
//#region src/commands/auth-choice.apply.qwen-portal.ts
|
|
2282
|
+
async function applyAuthChoiceQwenPortal(params) {
|
|
2283
|
+
return await applyAuthChoicePluginProvider(params, {
|
|
2284
|
+
authChoice: "qwen-portal",
|
|
2285
|
+
pluginId: "qwen-portal-auth",
|
|
2286
|
+
providerId: "qwen-portal",
|
|
2287
|
+
methodId: "device",
|
|
2288
|
+
label: "Qwen"
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
//#endregion
|
|
2293
|
+
//#region src/commands/auth-choice.apply.ts
|
|
2294
|
+
async function applyAuthChoice(params) {
|
|
2295
|
+
const handlers = [
|
|
2296
|
+
applyAuthChoiceAnthropic,
|
|
2297
|
+
applyAuthChoiceOpenAI,
|
|
2298
|
+
applyAuthChoiceOAuth,
|
|
2299
|
+
applyAuthChoiceApiProviders,
|
|
2300
|
+
applyAuthChoiceMiniMax,
|
|
2301
|
+
applyAuthChoiceGitHubCopilot,
|
|
2302
|
+
applyAuthChoiceGoogleAntigravity,
|
|
2303
|
+
applyAuthChoiceGoogleGeminiCli,
|
|
2304
|
+
applyAuthChoiceCopilotProxy,
|
|
2305
|
+
applyAuthChoiceQwenPortal
|
|
2306
|
+
];
|
|
2307
|
+
for (const handler of handlers) {
|
|
2308
|
+
const result = await handler(params);
|
|
2309
|
+
if (result) return result;
|
|
2310
|
+
}
|
|
2311
|
+
return { config: params.config };
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
//#endregion
|
|
2315
|
+
//#region src/commands/auth-choice.model-check.ts
|
|
2316
|
+
async function warnIfModelConfigLooksOff(config, prompter, options) {
|
|
2317
|
+
const agentModelOverride = options?.agentId ? resolveAgentModelPrimary(config, options.agentId) : void 0;
|
|
2318
|
+
const configWithModel = agentModelOverride && agentModelOverride.length > 0 ? {
|
|
2319
|
+
...config,
|
|
2320
|
+
agents: {
|
|
2321
|
+
...config.agents,
|
|
2322
|
+
defaults: {
|
|
2323
|
+
...config.agents?.defaults,
|
|
2324
|
+
model: {
|
|
2325
|
+
...typeof config.agents?.defaults?.model === "object" ? config.agents.defaults.model : void 0,
|
|
2326
|
+
primary: agentModelOverride
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
} : config;
|
|
2331
|
+
const ref = resolveConfiguredModelRef({
|
|
2332
|
+
cfg: configWithModel,
|
|
2333
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2334
|
+
defaultModel: DEFAULT_MODEL
|
|
2335
|
+
});
|
|
2336
|
+
const warnings = [];
|
|
2337
|
+
const catalog = await loadModelCatalog({
|
|
2338
|
+
config: configWithModel,
|
|
2339
|
+
useCache: false
|
|
2340
|
+
});
|
|
2341
|
+
if (catalog.length > 0) {
|
|
2342
|
+
if (!catalog.some((entry) => entry.provider === ref.provider && entry.id === ref.model)) warnings.push(`Model not found: ${ref.provider}/${ref.model}. Update agents.defaults.model or run /models list.`);
|
|
2343
|
+
}
|
|
2344
|
+
const store = ensureAuthProfileStore(options?.agentDir);
|
|
2345
|
+
const hasProfile = listProfilesForProvider(store, ref.provider).length > 0;
|
|
2346
|
+
const envKey = resolveEnvApiKey(ref.provider);
|
|
2347
|
+
const customKey = getCustomProviderApiKey(config, ref.provider);
|
|
2348
|
+
if (!hasProfile && !envKey && !customKey) warnings.push(`No auth configured for provider "${ref.provider}". The agent may fail until credentials are added.`);
|
|
2349
|
+
if (ref.provider === "openai") {
|
|
2350
|
+
if (listProfilesForProvider(store, "openai-codex").length > 0) warnings.push(`Detected OpenAI Codex OAuth. Consider setting agents.defaults.model to ${OPENAI_CODEX_DEFAULT_MODEL}.`);
|
|
2351
|
+
}
|
|
2352
|
+
if (warnings.length > 0) await prompter.note(warnings.join("\n"), "Model check");
|
|
2353
|
+
}
|
|
2354
|
+
|
|
2355
|
+
//#endregion
|
|
2356
|
+
//#region src/commands/auth-choice.preferred-provider.ts
|
|
2357
|
+
const PREFERRED_PROVIDER_BY_AUTH_CHOICE = {
|
|
2358
|
+
oauth: "anthropic",
|
|
2359
|
+
"setup-token": "anthropic",
|
|
2360
|
+
"claude-cli": "anthropic",
|
|
2361
|
+
token: "anthropic",
|
|
2362
|
+
apiKey: "anthropic",
|
|
2363
|
+
"openai-codex": "openai-codex",
|
|
2364
|
+
"codex-cli": "openai-codex",
|
|
2365
|
+
chutes: "chutes",
|
|
2366
|
+
"openai-api-key": "openai",
|
|
2367
|
+
"openrouter-api-key": "openrouter",
|
|
2368
|
+
"ai-gateway-api-key": "vercel-ai-gateway",
|
|
2369
|
+
"cloudflare-ai-gateway-api-key": "cloudflare-ai-gateway",
|
|
2370
|
+
"moonshot-api-key": "moonshot",
|
|
2371
|
+
"moonshot-api-key-cn": "moonshot",
|
|
2372
|
+
"kimi-code-api-key": "kimi-coding",
|
|
2373
|
+
"gemini-api-key": "google",
|
|
2374
|
+
"google-antigravity": "google-antigravity",
|
|
2375
|
+
"google-gemini-cli": "google-gemini-cli",
|
|
2376
|
+
"zai-api-key": "zai",
|
|
2377
|
+
"xiaomi-api-key": "xiaomi",
|
|
2378
|
+
"synthetic-api-key": "synthetic",
|
|
2379
|
+
"venice-api-key": "venice",
|
|
2380
|
+
"github-copilot": "github-copilot",
|
|
2381
|
+
"copilot-proxy": "copilot-proxy",
|
|
2382
|
+
"minimax-cloud": "minimax",
|
|
2383
|
+
"minimax-api": "minimax",
|
|
2384
|
+
"minimax-api-lightning": "minimax",
|
|
2385
|
+
minimax: "lmstudio",
|
|
2386
|
+
"opencode-zen": "opencode",
|
|
2387
|
+
"qwen-portal": "qwen-portal",
|
|
2388
|
+
"minimax-portal": "minimax-portal"
|
|
2389
|
+
};
|
|
2390
|
+
function resolvePreferredProviderForAuthChoice(choice) {
|
|
2391
|
+
return PREFERRED_PROVIDER_BY_AUTH_CHOICE[choice];
|
|
2392
|
+
}
|
|
2393
|
+
|
|
2394
|
+
//#endregion
|
|
2395
|
+
//#region src/commands/model-picker.ts
|
|
2396
|
+
const KEEP_VALUE = "__keep__";
|
|
2397
|
+
const MANUAL_VALUE = "__manual__";
|
|
2398
|
+
const PROVIDER_FILTER_THRESHOLD = 30;
|
|
2399
|
+
const HIDDEN_ROUTER_MODELS = new Set(["openrouter/auto"]);
|
|
2400
|
+
function hasAuthForProvider(provider, cfg, store) {
|
|
2401
|
+
if (listProfilesForProvider(store, provider).length > 0) return true;
|
|
2402
|
+
if (resolveEnvApiKey(provider)) return true;
|
|
2403
|
+
if (getCustomProviderApiKey(cfg, provider)) return true;
|
|
2404
|
+
return false;
|
|
2405
|
+
}
|
|
2406
|
+
function resolveConfiguredModelRaw(cfg) {
|
|
2407
|
+
const raw = cfg.agents?.defaults?.model;
|
|
2408
|
+
if (typeof raw === "string") return raw.trim();
|
|
2409
|
+
return raw?.primary?.trim() ?? "";
|
|
2410
|
+
}
|
|
2411
|
+
function resolveConfiguredModelKeys(cfg) {
|
|
2412
|
+
const models = cfg.agents?.defaults?.models ?? {};
|
|
2413
|
+
return Object.keys(models).map((key) => String(key ?? "").trim()).filter((key) => key.length > 0);
|
|
2414
|
+
}
|
|
2415
|
+
function normalizeModelKeys(values) {
|
|
2416
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2417
|
+
const next = [];
|
|
2418
|
+
for (const raw of values) {
|
|
2419
|
+
const value = String(raw ?? "").trim();
|
|
2420
|
+
if (!value || seen.has(value)) continue;
|
|
2421
|
+
seen.add(value);
|
|
2422
|
+
next.push(value);
|
|
2423
|
+
}
|
|
2424
|
+
return next;
|
|
2425
|
+
}
|
|
2426
|
+
async function promptManualModel(params) {
|
|
2427
|
+
const modelInput = await params.prompter.text({
|
|
2428
|
+
message: params.allowBlank ? "Default model (blank to keep)" : "Default model",
|
|
2429
|
+
initialValue: params.initialValue,
|
|
2430
|
+
placeholder: "provider/model",
|
|
2431
|
+
validate: params.allowBlank ? void 0 : (value) => value?.trim() ? void 0 : "Required"
|
|
2432
|
+
});
|
|
2433
|
+
const model = String(modelInput ?? "").trim();
|
|
2434
|
+
if (!model) return {};
|
|
2435
|
+
return { model };
|
|
2436
|
+
}
|
|
2437
|
+
async function promptDefaultModel(params) {
|
|
2438
|
+
const cfg = params.config;
|
|
2439
|
+
const allowKeep = params.allowKeep ?? true;
|
|
2440
|
+
const includeManual = params.includeManual ?? true;
|
|
2441
|
+
const ignoreAllowlist = params.ignoreAllowlist ?? false;
|
|
2442
|
+
const preferredProviderRaw = params.preferredProvider?.trim();
|
|
2443
|
+
const preferredProvider = preferredProviderRaw ? normalizeProviderId(preferredProviderRaw) : void 0;
|
|
2444
|
+
const configuredRaw = resolveConfiguredModelRaw(cfg);
|
|
2445
|
+
const resolved = resolveConfiguredModelRef({
|
|
2446
|
+
cfg,
|
|
2447
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2448
|
+
defaultModel: DEFAULT_MODEL
|
|
2449
|
+
});
|
|
2450
|
+
const resolvedKey = modelKey(resolved.provider, resolved.model);
|
|
2451
|
+
const configuredKey = configuredRaw ? resolvedKey : "";
|
|
2452
|
+
const catalog = await loadModelCatalog({
|
|
2453
|
+
config: cfg,
|
|
2454
|
+
useCache: false
|
|
2455
|
+
});
|
|
2456
|
+
if (catalog.length === 0) return promptManualModel({
|
|
2457
|
+
prompter: params.prompter,
|
|
2458
|
+
allowBlank: allowKeep,
|
|
2459
|
+
initialValue: configuredRaw || resolvedKey || void 0
|
|
2460
|
+
});
|
|
2461
|
+
const aliasIndex = buildModelAliasIndex({
|
|
2462
|
+
cfg,
|
|
2463
|
+
defaultProvider: DEFAULT_PROVIDER
|
|
2464
|
+
});
|
|
2465
|
+
let models = catalog;
|
|
2466
|
+
if (!ignoreAllowlist) {
|
|
2467
|
+
const { allowedCatalog } = buildAllowedModelSet({
|
|
2468
|
+
cfg,
|
|
2469
|
+
catalog,
|
|
2470
|
+
defaultProvider: DEFAULT_PROVIDER
|
|
2471
|
+
});
|
|
2472
|
+
models = allowedCatalog.length > 0 ? allowedCatalog : catalog;
|
|
2473
|
+
}
|
|
2474
|
+
if (models.length === 0) return promptManualModel({
|
|
2475
|
+
prompter: params.prompter,
|
|
2476
|
+
allowBlank: allowKeep,
|
|
2477
|
+
initialValue: configuredRaw || resolvedKey || void 0
|
|
2478
|
+
});
|
|
2479
|
+
const providers = Array.from(new Set(models.map((entry) => entry.provider))).toSorted((a, b) => a.localeCompare(b));
|
|
2480
|
+
const hasPreferredProvider = preferredProvider ? providers.includes(preferredProvider) : false;
|
|
2481
|
+
if (!hasPreferredProvider && providers.length > 1 && models.length > PROVIDER_FILTER_THRESHOLD) {
|
|
2482
|
+
const selection = await params.prompter.select({
|
|
2483
|
+
message: "Filter models by provider",
|
|
2484
|
+
options: [{
|
|
2485
|
+
value: "*",
|
|
2486
|
+
label: "All providers"
|
|
2487
|
+
}, ...providers.map((provider) => {
|
|
2488
|
+
const count = models.filter((entry) => entry.provider === provider).length;
|
|
2489
|
+
return {
|
|
2490
|
+
value: provider,
|
|
2491
|
+
label: provider,
|
|
2492
|
+
hint: `${count} model${count === 1 ? "" : "s"}`
|
|
2493
|
+
};
|
|
2494
|
+
})]
|
|
2495
|
+
});
|
|
2496
|
+
if (selection !== "*") models = models.filter((entry) => entry.provider === selection);
|
|
2497
|
+
}
|
|
2498
|
+
if (hasPreferredProvider && preferredProvider) models = models.filter((entry) => entry.provider === preferredProvider);
|
|
2499
|
+
const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
2500
|
+
const authCache = /* @__PURE__ */ new Map();
|
|
2501
|
+
const hasAuth = (provider) => {
|
|
2502
|
+
const cached = authCache.get(provider);
|
|
2503
|
+
if (cached !== void 0) return cached;
|
|
2504
|
+
const value = hasAuthForProvider(provider, cfg, authStore);
|
|
2505
|
+
authCache.set(provider, value);
|
|
2506
|
+
return value;
|
|
2507
|
+
};
|
|
2508
|
+
const options = [];
|
|
2509
|
+
if (allowKeep) options.push({
|
|
2510
|
+
value: KEEP_VALUE,
|
|
2511
|
+
label: configuredRaw ? `Keep current (${configuredRaw})` : `Keep current (default: ${resolvedKey})`,
|
|
2512
|
+
hint: configuredRaw && configuredRaw !== resolvedKey ? `resolves to ${resolvedKey}` : void 0
|
|
2513
|
+
});
|
|
2514
|
+
if (includeManual) options.push({
|
|
2515
|
+
value: MANUAL_VALUE,
|
|
2516
|
+
label: "Enter model manually"
|
|
2517
|
+
});
|
|
2518
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2519
|
+
const addModelOption = (entry) => {
|
|
2520
|
+
const key = modelKey(entry.provider, entry.id);
|
|
2521
|
+
if (seen.has(key)) return;
|
|
2522
|
+
if (HIDDEN_ROUTER_MODELS.has(key)) return;
|
|
2523
|
+
const hints = [];
|
|
2524
|
+
if (entry.name && entry.name !== entry.id) hints.push(entry.name);
|
|
2525
|
+
if (entry.contextWindow) hints.push(`ctx ${formatTokenK(entry.contextWindow)}`);
|
|
2526
|
+
if (entry.reasoning) hints.push("reasoning");
|
|
2527
|
+
const aliases = aliasIndex.byKey.get(key);
|
|
2528
|
+
if (aliases?.length) hints.push(`alias: ${aliases.join(", ")}`);
|
|
2529
|
+
if (!hasAuth(entry.provider)) hints.push("auth missing");
|
|
2530
|
+
options.push({
|
|
2531
|
+
value: key,
|
|
2532
|
+
label: key,
|
|
2533
|
+
hint: hints.length > 0 ? hints.join(" · ") : void 0
|
|
2534
|
+
});
|
|
2535
|
+
seen.add(key);
|
|
2536
|
+
};
|
|
2537
|
+
for (const entry of models) addModelOption(entry);
|
|
2538
|
+
if (configuredKey && !seen.has(configuredKey)) options.push({
|
|
2539
|
+
value: configuredKey,
|
|
2540
|
+
label: configuredKey,
|
|
2541
|
+
hint: "current (not in catalog)"
|
|
2542
|
+
});
|
|
2543
|
+
let initialValue = allowKeep ? KEEP_VALUE : configuredKey || void 0;
|
|
2544
|
+
if (allowKeep && hasPreferredProvider && preferredProvider && resolved.provider !== preferredProvider) {
|
|
2545
|
+
const firstModel = models[0];
|
|
2546
|
+
if (firstModel) initialValue = modelKey(firstModel.provider, firstModel.id);
|
|
2547
|
+
}
|
|
2548
|
+
const selection = await params.prompter.select({
|
|
2549
|
+
message: params.message ?? "Default model",
|
|
2550
|
+
options,
|
|
2551
|
+
initialValue
|
|
2552
|
+
});
|
|
2553
|
+
if (selection === KEEP_VALUE) return {};
|
|
2554
|
+
if (selection === MANUAL_VALUE) return promptManualModel({
|
|
2555
|
+
prompter: params.prompter,
|
|
2556
|
+
allowBlank: false,
|
|
2557
|
+
initialValue: configuredRaw || resolvedKey || void 0
|
|
2558
|
+
});
|
|
2559
|
+
return { model: String(selection) };
|
|
2560
|
+
}
|
|
2561
|
+
async function promptModelAllowlist(params) {
|
|
2562
|
+
const cfg = params.config;
|
|
2563
|
+
const existingKeys = resolveConfiguredModelKeys(cfg);
|
|
2564
|
+
const allowedKeys = normalizeModelKeys(params.allowedKeys ?? []);
|
|
2565
|
+
const allowedKeySet = allowedKeys.length > 0 ? new Set(allowedKeys) : null;
|
|
2566
|
+
const resolved = resolveConfiguredModelRef({
|
|
2567
|
+
cfg,
|
|
2568
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2569
|
+
defaultModel: DEFAULT_MODEL
|
|
2570
|
+
});
|
|
2571
|
+
const resolvedKey = modelKey(resolved.provider, resolved.model);
|
|
2572
|
+
const initialSeeds = normalizeModelKeys([
|
|
2573
|
+
...existingKeys,
|
|
2574
|
+
resolvedKey,
|
|
2575
|
+
...params.initialSelections ?? []
|
|
2576
|
+
]);
|
|
2577
|
+
const initialKeys = allowedKeySet ? initialSeeds.filter((key) => allowedKeySet.has(key)) : initialSeeds;
|
|
2578
|
+
const catalog = await loadModelCatalog({
|
|
2579
|
+
config: cfg,
|
|
2580
|
+
useCache: false
|
|
2581
|
+
});
|
|
2582
|
+
if (catalog.length === 0 && allowedKeys.length === 0) {
|
|
2583
|
+
const raw = await params.prompter.text({
|
|
2584
|
+
message: params.message ?? "Allowlist models (comma-separated provider/model; blank to keep current)",
|
|
2585
|
+
initialValue: existingKeys.join(", "),
|
|
2586
|
+
placeholder: "openai-codex/gpt-5.2, anthropic/claude-opus-4-5"
|
|
2587
|
+
});
|
|
2588
|
+
const parsed = String(raw ?? "").split(",").map((value) => value.trim()).filter((value) => value.length > 0);
|
|
2589
|
+
if (parsed.length === 0) return {};
|
|
2590
|
+
return { models: normalizeModelKeys(parsed) };
|
|
2591
|
+
}
|
|
2592
|
+
const aliasIndex = buildModelAliasIndex({
|
|
2593
|
+
cfg,
|
|
2594
|
+
defaultProvider: DEFAULT_PROVIDER
|
|
2595
|
+
});
|
|
2596
|
+
const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
2597
|
+
const authCache = /* @__PURE__ */ new Map();
|
|
2598
|
+
const hasAuth = (provider) => {
|
|
2599
|
+
const cached = authCache.get(provider);
|
|
2600
|
+
if (cached !== void 0) return cached;
|
|
2601
|
+
const value = hasAuthForProvider(provider, cfg, authStore);
|
|
2602
|
+
authCache.set(provider, value);
|
|
2603
|
+
return value;
|
|
2604
|
+
};
|
|
2605
|
+
const options = [];
|
|
2606
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2607
|
+
const addModelOption = (entry) => {
|
|
2608
|
+
const key = modelKey(entry.provider, entry.id);
|
|
2609
|
+
if (seen.has(key)) return;
|
|
2610
|
+
if (HIDDEN_ROUTER_MODELS.has(key)) return;
|
|
2611
|
+
const hints = [];
|
|
2612
|
+
if (entry.name && entry.name !== entry.id) hints.push(entry.name);
|
|
2613
|
+
if (entry.contextWindow) hints.push(`ctx ${formatTokenK(entry.contextWindow)}`);
|
|
2614
|
+
if (entry.reasoning) hints.push("reasoning");
|
|
2615
|
+
const aliases = aliasIndex.byKey.get(key);
|
|
2616
|
+
if (aliases?.length) hints.push(`alias: ${aliases.join(", ")}`);
|
|
2617
|
+
if (!hasAuth(entry.provider)) hints.push("auth missing");
|
|
2618
|
+
options.push({
|
|
2619
|
+
value: key,
|
|
2620
|
+
label: key,
|
|
2621
|
+
hint: hints.length > 0 ? hints.join(" · ") : void 0
|
|
2622
|
+
});
|
|
2623
|
+
seen.add(key);
|
|
2624
|
+
};
|
|
2625
|
+
const filteredCatalog = allowedKeySet ? catalog.filter((entry) => allowedKeySet.has(modelKey(entry.provider, entry.id))) : catalog;
|
|
2626
|
+
for (const entry of filteredCatalog) addModelOption(entry);
|
|
2627
|
+
const supplementalKeys = allowedKeySet ? allowedKeys : existingKeys;
|
|
2628
|
+
for (const key of supplementalKeys) {
|
|
2629
|
+
if (seen.has(key)) continue;
|
|
2630
|
+
options.push({
|
|
2631
|
+
value: key,
|
|
2632
|
+
label: key,
|
|
2633
|
+
hint: allowedKeySet ? "allowed (not in catalog)" : "configured (not in catalog)"
|
|
2634
|
+
});
|
|
2635
|
+
seen.add(key);
|
|
2636
|
+
}
|
|
2637
|
+
if (options.length === 0) return {};
|
|
2638
|
+
const selected = normalizeModelKeys((await params.prompter.multiselect({
|
|
2639
|
+
message: params.message ?? "Models in /model picker (multi-select)",
|
|
2640
|
+
options,
|
|
2641
|
+
initialValues: initialKeys.length > 0 ? initialKeys : void 0
|
|
2642
|
+
})).map((value) => String(value)));
|
|
2643
|
+
if (selected.length > 0) return { models: selected };
|
|
2644
|
+
if (existingKeys.length === 0) return { models: [] };
|
|
2645
|
+
if (!await params.prompter.confirm({
|
|
2646
|
+
message: "Clear the model allowlist? (shows all models)",
|
|
2647
|
+
initialValue: false
|
|
2648
|
+
})) return {};
|
|
2649
|
+
return { models: [] };
|
|
2650
|
+
}
|
|
2651
|
+
function applyPrimaryModel(cfg, model) {
|
|
2652
|
+
const defaults = cfg.agents?.defaults;
|
|
2653
|
+
const existingModel = defaults?.model;
|
|
2654
|
+
const existingModels = defaults?.models;
|
|
2655
|
+
const fallbacks = typeof existingModel === "object" && existingModel !== null && "fallbacks" in existingModel ? existingModel.fallbacks : void 0;
|
|
2656
|
+
return {
|
|
2657
|
+
...cfg,
|
|
2658
|
+
agents: {
|
|
2659
|
+
...cfg.agents,
|
|
2660
|
+
defaults: {
|
|
2661
|
+
...defaults,
|
|
2662
|
+
model: {
|
|
2663
|
+
...fallbacks ? { fallbacks } : void 0,
|
|
2664
|
+
primary: model
|
|
2665
|
+
},
|
|
2666
|
+
models: {
|
|
2667
|
+
...existingModels,
|
|
2668
|
+
[model]: existingModels?.[model] ?? {}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
};
|
|
2673
|
+
}
|
|
2674
|
+
function applyModelAllowlist(cfg, models) {
|
|
2675
|
+
const defaults = cfg.agents?.defaults;
|
|
2676
|
+
const normalized = normalizeModelKeys(models);
|
|
2677
|
+
if (normalized.length === 0) {
|
|
2678
|
+
if (!defaults?.models) return cfg;
|
|
2679
|
+
const { models: _ignored, ...restDefaults } = defaults;
|
|
2680
|
+
return {
|
|
2681
|
+
...cfg,
|
|
2682
|
+
agents: {
|
|
2683
|
+
...cfg.agents,
|
|
2684
|
+
defaults: restDefaults
|
|
2685
|
+
}
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
const existingModels = defaults?.models ?? {};
|
|
2689
|
+
const nextModels = {};
|
|
2690
|
+
for (const key of normalized) nextModels[key] = existingModels[key] ?? {};
|
|
2691
|
+
return {
|
|
2692
|
+
...cfg,
|
|
2693
|
+
agents: {
|
|
2694
|
+
...cfg.agents,
|
|
2695
|
+
defaults: {
|
|
2696
|
+
...defaults,
|
|
2697
|
+
models: nextModels
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
};
|
|
2701
|
+
}
|
|
2702
|
+
function applyModelFallbacksFromSelection(cfg, selection) {
|
|
2703
|
+
const normalized = normalizeModelKeys(selection);
|
|
2704
|
+
if (normalized.length <= 1) return cfg;
|
|
2705
|
+
const resolved = resolveConfiguredModelRef({
|
|
2706
|
+
cfg,
|
|
2707
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2708
|
+
defaultModel: DEFAULT_MODEL
|
|
2709
|
+
});
|
|
2710
|
+
const resolvedKey = modelKey(resolved.provider, resolved.model);
|
|
2711
|
+
if (!normalized.includes(resolvedKey)) return cfg;
|
|
2712
|
+
const defaults = cfg.agents?.defaults;
|
|
2713
|
+
const existingModel = defaults?.model;
|
|
2714
|
+
const existingPrimary = typeof existingModel === "string" ? existingModel : existingModel && typeof existingModel === "object" ? existingModel.primary : void 0;
|
|
2715
|
+
const fallbacks = normalized.filter((key) => key !== resolvedKey);
|
|
2716
|
+
return {
|
|
2717
|
+
...cfg,
|
|
2718
|
+
agents: {
|
|
2719
|
+
...cfg.agents,
|
|
2720
|
+
defaults: {
|
|
2721
|
+
...defaults,
|
|
2722
|
+
model: {
|
|
2723
|
+
...typeof existingModel === "object" ? existingModel : void 0,
|
|
2724
|
+
primary: existingPrimary ?? resolvedKey,
|
|
2725
|
+
fallbacks
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
//#endregion
|
|
2733
|
+
//#region src/commands/onboard-remote.ts
|
|
2734
|
+
const DEFAULT_GATEWAY_URL = "ws://127.0.0.1:18789";
|
|
2735
|
+
function pickHost(beacon) {
|
|
2736
|
+
return beacon.tailnetDns || beacon.lanHost || beacon.host;
|
|
2737
|
+
}
|
|
2738
|
+
function buildLabel(beacon) {
|
|
2739
|
+
const host = pickHost(beacon);
|
|
2740
|
+
const port = beacon.gatewayPort ?? beacon.port ?? 18789;
|
|
2741
|
+
return `${beacon.displayName ?? beacon.instanceName} (${host ? `${host}:${port}` : "host unknown"})`;
|
|
2742
|
+
}
|
|
2743
|
+
function ensureWsUrl(value) {
|
|
2744
|
+
const trimmed = value.trim();
|
|
2745
|
+
if (!trimmed) return DEFAULT_GATEWAY_URL;
|
|
2746
|
+
return trimmed;
|
|
2747
|
+
}
|
|
2748
|
+
async function promptRemoteGatewayConfig(cfg, prompter) {
|
|
2749
|
+
let selectedBeacon = null;
|
|
2750
|
+
let suggestedUrl = cfg.gateway?.remote?.url ?? DEFAULT_GATEWAY_URL;
|
|
2751
|
+
const hasBonjourTool = await detectBinary("dns-sd") || await detectBinary("avahi-browse");
|
|
2752
|
+
const wantsDiscover = hasBonjourTool ? await prompter.confirm({
|
|
2753
|
+
message: "Discover gateway on LAN (Bonjour)?",
|
|
2754
|
+
initialValue: true
|
|
2755
|
+
}) : false;
|
|
2756
|
+
if (!hasBonjourTool) await prompter.note(["Bonjour discovery requires dns-sd (macOS) or avahi-browse (Linux).", "Docs: https://docs.openclaw.ai/gateway/discovery"].join("\n"), "Discovery");
|
|
2757
|
+
if (wantsDiscover) {
|
|
2758
|
+
const wideAreaDomain = resolveWideAreaDiscoveryDomain({ configDomain: cfg.discovery?.wideArea?.domain });
|
|
2759
|
+
const spin = prompter.progress("Searching for gateways…");
|
|
2760
|
+
const beacons = await discoverGatewayBeacons({
|
|
2761
|
+
timeoutMs: 2e3,
|
|
2762
|
+
wideAreaDomain
|
|
2763
|
+
});
|
|
2764
|
+
spin.stop(beacons.length > 0 ? `Found ${beacons.length} gateway(s)` : "No gateways found");
|
|
2765
|
+
if (beacons.length > 0) {
|
|
2766
|
+
const selection = await prompter.select({
|
|
2767
|
+
message: "Select gateway",
|
|
2768
|
+
options: [...beacons.map((beacon, index) => ({
|
|
2769
|
+
value: String(index),
|
|
2770
|
+
label: buildLabel(beacon)
|
|
2771
|
+
})), {
|
|
2772
|
+
value: "manual",
|
|
2773
|
+
label: "Enter URL manually"
|
|
2774
|
+
}]
|
|
2775
|
+
});
|
|
2776
|
+
if (selection !== "manual") {
|
|
2777
|
+
const idx = Number.parseInt(String(selection), 10);
|
|
2778
|
+
selectedBeacon = Number.isFinite(idx) ? beacons[idx] ?? null : null;
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
if (selectedBeacon) {
|
|
2783
|
+
const host = pickHost(selectedBeacon);
|
|
2784
|
+
const port = selectedBeacon.gatewayPort ?? 18789;
|
|
2785
|
+
if (host) if (await prompter.select({
|
|
2786
|
+
message: "Connection method",
|
|
2787
|
+
options: [{
|
|
2788
|
+
value: "direct",
|
|
2789
|
+
label: `Direct gateway WS (${host}:${port})`
|
|
2790
|
+
}, {
|
|
2791
|
+
value: "ssh",
|
|
2792
|
+
label: "SSH tunnel (loopback)"
|
|
2793
|
+
}]
|
|
2794
|
+
}) === "direct") suggestedUrl = `ws://${host}:${port}`;
|
|
2795
|
+
else {
|
|
2796
|
+
suggestedUrl = DEFAULT_GATEWAY_URL;
|
|
2797
|
+
await prompter.note([
|
|
2798
|
+
"Start a tunnel before using the CLI:",
|
|
2799
|
+
`ssh -N -L 18789:127.0.0.1:18789 <user>@${host}${selectedBeacon.sshPort ? ` -p ${selectedBeacon.sshPort}` : ""}`,
|
|
2800
|
+
"Docs: https://docs.openclaw.ai/gateway/remote"
|
|
2801
|
+
].join("\n"), "SSH tunnel");
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
const urlInput = await prompter.text({
|
|
2805
|
+
message: "Gateway WebSocket URL",
|
|
2806
|
+
initialValue: suggestedUrl,
|
|
2807
|
+
validate: (value) => String(value).trim().startsWith("ws://") || String(value).trim().startsWith("wss://") ? void 0 : "URL must start with ws:// or wss://"
|
|
2808
|
+
});
|
|
2809
|
+
const url = ensureWsUrl(String(urlInput));
|
|
2810
|
+
const authChoice = await prompter.select({
|
|
2811
|
+
message: "Gateway auth",
|
|
2812
|
+
options: [{
|
|
2813
|
+
value: "token",
|
|
2814
|
+
label: "Token (recommended)"
|
|
2815
|
+
}, {
|
|
2816
|
+
value: "off",
|
|
2817
|
+
label: "No auth"
|
|
2818
|
+
}]
|
|
2819
|
+
});
|
|
2820
|
+
let token = cfg.gateway?.remote?.token ?? "";
|
|
2821
|
+
if (authChoice === "token") token = String(await prompter.text({
|
|
2822
|
+
message: "Gateway token",
|
|
2823
|
+
initialValue: token,
|
|
2824
|
+
validate: (value) => value?.trim() ? void 0 : "Required"
|
|
2825
|
+
})).trim();
|
|
2826
|
+
else token = "";
|
|
2827
|
+
return {
|
|
2828
|
+
...cfg,
|
|
2829
|
+
gateway: {
|
|
2830
|
+
...cfg.gateway,
|
|
2831
|
+
mode: "remote",
|
|
2832
|
+
remote: {
|
|
2833
|
+
url,
|
|
2834
|
+
token: token || void 0
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
}
|
|
2839
|
+
|
|
2840
|
+
//#endregion
|
|
2841
|
+
//#region src/agents/skills-install.ts
|
|
2842
|
+
function isNodeReadableStream(value) {
|
|
2843
|
+
return Boolean(value && typeof value.pipe === "function");
|
|
2844
|
+
}
|
|
2845
|
+
function summarizeInstallOutput(text) {
|
|
2846
|
+
const raw = text.trim();
|
|
2847
|
+
if (!raw) return;
|
|
2848
|
+
const lines = raw.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
2849
|
+
if (lines.length === 0) return;
|
|
2850
|
+
const preferred = lines.find((line) => /^error\b/i.test(line)) ?? lines.find((line) => /\b(err!|error:|failed)\b/i.test(line)) ?? lines.at(-1);
|
|
2851
|
+
if (!preferred) return;
|
|
2852
|
+
const normalized = preferred.replace(/\s+/g, " ").trim();
|
|
2853
|
+
const maxLen = 200;
|
|
2854
|
+
return normalized.length > maxLen ? `${normalized.slice(0, maxLen - 1)}…` : normalized;
|
|
2855
|
+
}
|
|
2856
|
+
function formatInstallFailureMessage(result) {
|
|
2857
|
+
const code = typeof result.code === "number" ? `exit ${result.code}` : "unknown exit";
|
|
2858
|
+
const summary = summarizeInstallOutput(result.stderr) ?? summarizeInstallOutput(result.stdout);
|
|
2859
|
+
if (!summary) return `Install failed (${code})`;
|
|
2860
|
+
return `Install failed (${code}): ${summary}`;
|
|
2861
|
+
}
|
|
2862
|
+
function resolveInstallId(spec, index) {
|
|
2863
|
+
return (spec.id ?? `${spec.kind}-${index}`).trim();
|
|
2864
|
+
}
|
|
2865
|
+
function findInstallSpec(entry, installId) {
|
|
2866
|
+
const specs = entry.metadata?.install ?? [];
|
|
2867
|
+
for (const [index, spec] of specs.entries()) if (resolveInstallId(spec, index) === installId) return spec;
|
|
2868
|
+
}
|
|
2869
|
+
function buildNodeInstallCommand(packageName, prefs) {
|
|
2870
|
+
switch (prefs.nodeManager) {
|
|
2871
|
+
case "pnpm": return [
|
|
2872
|
+
"pnpm",
|
|
2873
|
+
"add",
|
|
2874
|
+
"-g",
|
|
2875
|
+
packageName
|
|
2876
|
+
];
|
|
2877
|
+
case "yarn": return [
|
|
2878
|
+
"yarn",
|
|
2879
|
+
"global",
|
|
2880
|
+
"add",
|
|
2881
|
+
packageName
|
|
2882
|
+
];
|
|
2883
|
+
case "bun": return [
|
|
2884
|
+
"bun",
|
|
2885
|
+
"add",
|
|
2886
|
+
"-g",
|
|
2887
|
+
packageName
|
|
2888
|
+
];
|
|
2889
|
+
default: return [
|
|
2890
|
+
"npm",
|
|
2891
|
+
"install",
|
|
2892
|
+
"-g",
|
|
2893
|
+
packageName
|
|
2894
|
+
];
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
function buildInstallCommand(spec, prefs) {
|
|
2898
|
+
switch (spec.kind) {
|
|
2899
|
+
case "brew":
|
|
2900
|
+
if (!spec.formula) return {
|
|
2901
|
+
argv: null,
|
|
2902
|
+
error: "missing brew formula"
|
|
2903
|
+
};
|
|
2904
|
+
return { argv: [
|
|
2905
|
+
"brew",
|
|
2906
|
+
"install",
|
|
2907
|
+
spec.formula
|
|
2908
|
+
] };
|
|
2909
|
+
case "node":
|
|
2910
|
+
if (!spec.package) return {
|
|
2911
|
+
argv: null,
|
|
2912
|
+
error: "missing node package"
|
|
2913
|
+
};
|
|
2914
|
+
return { argv: buildNodeInstallCommand(spec.package, prefs) };
|
|
2915
|
+
case "go":
|
|
2916
|
+
if (!spec.module) return {
|
|
2917
|
+
argv: null,
|
|
2918
|
+
error: "missing go module"
|
|
2919
|
+
};
|
|
2920
|
+
return { argv: [
|
|
2921
|
+
"go",
|
|
2922
|
+
"install",
|
|
2923
|
+
spec.module
|
|
2924
|
+
] };
|
|
2925
|
+
case "uv":
|
|
2926
|
+
if (!spec.package) return {
|
|
2927
|
+
argv: null,
|
|
2928
|
+
error: "missing uv package"
|
|
2929
|
+
};
|
|
2930
|
+
return { argv: [
|
|
2931
|
+
"uv",
|
|
2932
|
+
"tool",
|
|
2933
|
+
"install",
|
|
2934
|
+
spec.package
|
|
2935
|
+
] };
|
|
2936
|
+
case "download": return {
|
|
2937
|
+
argv: null,
|
|
2938
|
+
error: "download install handled separately"
|
|
2939
|
+
};
|
|
2940
|
+
default: return {
|
|
2941
|
+
argv: null,
|
|
2942
|
+
error: "unsupported installer"
|
|
2943
|
+
};
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
function resolveDownloadTargetDir(entry, spec) {
|
|
2947
|
+
if (spec.targetDir?.trim()) return resolveUserPath(spec.targetDir);
|
|
2948
|
+
const key = resolveSkillKey(entry.skill, entry);
|
|
2949
|
+
return path.join(CONFIG_DIR, "tools", key);
|
|
2950
|
+
}
|
|
2951
|
+
function resolveArchiveType(spec, filename) {
|
|
2952
|
+
const explicit = spec.archive?.trim().toLowerCase();
|
|
2953
|
+
if (explicit) return explicit;
|
|
2954
|
+
const lower = filename.toLowerCase();
|
|
2955
|
+
if (lower.endsWith(".tar.gz") || lower.endsWith(".tgz")) return "tar.gz";
|
|
2956
|
+
if (lower.endsWith(".tar.bz2") || lower.endsWith(".tbz2")) return "tar.bz2";
|
|
2957
|
+
if (lower.endsWith(".zip")) return "zip";
|
|
2958
|
+
}
|
|
2959
|
+
async function downloadFile(url, destPath, timeoutMs) {
|
|
2960
|
+
const { response, release } = await fetchWithSsrFGuard({
|
|
2961
|
+
url,
|
|
2962
|
+
timeoutMs: Math.max(1e3, timeoutMs)
|
|
2963
|
+
});
|
|
2964
|
+
try {
|
|
2965
|
+
if (!response.ok || !response.body) throw new Error(`Download failed (${response.status} ${response.statusText})`);
|
|
2966
|
+
await ensureDir(path.dirname(destPath));
|
|
2967
|
+
const file = fs.createWriteStream(destPath);
|
|
2968
|
+
const body = response.body;
|
|
2969
|
+
await pipeline(isNodeReadableStream(body) ? body : Readable.fromWeb(body), file);
|
|
2970
|
+
return { bytes: (await fs.promises.stat(destPath)).size };
|
|
2971
|
+
} finally {
|
|
2972
|
+
await release();
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
async function extractArchive(params) {
|
|
2976
|
+
const { archivePath, archiveType, targetDir, stripComponents, timeoutMs } = params;
|
|
2977
|
+
if (archiveType === "zip") {
|
|
2978
|
+
if (!hasBinary("unzip")) return {
|
|
2979
|
+
stdout: "",
|
|
2980
|
+
stderr: "unzip not found on PATH",
|
|
2981
|
+
code: null
|
|
2982
|
+
};
|
|
2983
|
+
return await runCommandWithTimeout([
|
|
2984
|
+
"unzip",
|
|
2985
|
+
"-q",
|
|
2986
|
+
archivePath,
|
|
2987
|
+
"-d",
|
|
2988
|
+
targetDir
|
|
2989
|
+
], { timeoutMs });
|
|
2990
|
+
}
|
|
2991
|
+
if (!hasBinary("tar")) return {
|
|
2992
|
+
stdout: "",
|
|
2993
|
+
stderr: "tar not found on PATH",
|
|
2994
|
+
code: null
|
|
2995
|
+
};
|
|
2996
|
+
const argv = [
|
|
2997
|
+
"tar",
|
|
2998
|
+
"xf",
|
|
2999
|
+
archivePath,
|
|
3000
|
+
"-C",
|
|
3001
|
+
targetDir
|
|
3002
|
+
];
|
|
3003
|
+
if (typeof stripComponents === "number" && Number.isFinite(stripComponents)) argv.push("--strip-components", String(Math.max(0, Math.floor(stripComponents))));
|
|
3004
|
+
return await runCommandWithTimeout(argv, { timeoutMs });
|
|
3005
|
+
}
|
|
3006
|
+
async function installDownloadSpec(params) {
|
|
3007
|
+
const { entry, spec, timeoutMs } = params;
|
|
3008
|
+
const url = spec.url?.trim();
|
|
3009
|
+
if (!url) return {
|
|
3010
|
+
ok: false,
|
|
3011
|
+
message: "missing download url",
|
|
3012
|
+
stdout: "",
|
|
3013
|
+
stderr: "",
|
|
3014
|
+
code: null
|
|
3015
|
+
};
|
|
3016
|
+
let filename = "";
|
|
3017
|
+
try {
|
|
3018
|
+
const parsed = new URL(url);
|
|
3019
|
+
filename = path.basename(parsed.pathname);
|
|
3020
|
+
} catch {
|
|
3021
|
+
filename = path.basename(url);
|
|
3022
|
+
}
|
|
3023
|
+
if (!filename) filename = "download";
|
|
3024
|
+
const targetDir = resolveDownloadTargetDir(entry, spec);
|
|
3025
|
+
await ensureDir(targetDir);
|
|
3026
|
+
const archivePath = path.join(targetDir, filename);
|
|
3027
|
+
let downloaded = 0;
|
|
3028
|
+
try {
|
|
3029
|
+
downloaded = (await downloadFile(url, archivePath, timeoutMs)).bytes;
|
|
3030
|
+
} catch (err) {
|
|
3031
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3032
|
+
return {
|
|
3033
|
+
ok: false,
|
|
3034
|
+
message,
|
|
3035
|
+
stdout: "",
|
|
3036
|
+
stderr: message,
|
|
3037
|
+
code: null
|
|
3038
|
+
};
|
|
3039
|
+
}
|
|
3040
|
+
const archiveType = resolveArchiveType(spec, filename);
|
|
3041
|
+
if (!(spec.extract ?? Boolean(archiveType))) return {
|
|
3042
|
+
ok: true,
|
|
3043
|
+
message: `Downloaded to ${archivePath}`,
|
|
3044
|
+
stdout: `downloaded=${downloaded}`,
|
|
3045
|
+
stderr: "",
|
|
3046
|
+
code: 0
|
|
3047
|
+
};
|
|
3048
|
+
if (!archiveType) return {
|
|
3049
|
+
ok: false,
|
|
3050
|
+
message: "extract requested but archive type could not be detected",
|
|
3051
|
+
stdout: "",
|
|
3052
|
+
stderr: "",
|
|
3053
|
+
code: null
|
|
3054
|
+
};
|
|
3055
|
+
const extractResult = await extractArchive({
|
|
3056
|
+
archivePath,
|
|
3057
|
+
archiveType,
|
|
3058
|
+
targetDir,
|
|
3059
|
+
stripComponents: spec.stripComponents,
|
|
3060
|
+
timeoutMs
|
|
3061
|
+
});
|
|
3062
|
+
const success = extractResult.code === 0;
|
|
3063
|
+
return {
|
|
3064
|
+
ok: success,
|
|
3065
|
+
message: success ? `Downloaded and extracted to ${targetDir}` : formatInstallFailureMessage(extractResult),
|
|
3066
|
+
stdout: extractResult.stdout.trim(),
|
|
3067
|
+
stderr: extractResult.stderr.trim(),
|
|
3068
|
+
code: extractResult.code
|
|
3069
|
+
};
|
|
3070
|
+
}
|
|
3071
|
+
async function resolveBrewBinDir(timeoutMs, brewExe) {
|
|
3072
|
+
const exe = brewExe ?? (hasBinary("brew") ? "brew" : resolveBrewExecutable());
|
|
3073
|
+
if (!exe) return;
|
|
3074
|
+
const prefixResult = await runCommandWithTimeout([exe, "--prefix"], { timeoutMs: Math.min(timeoutMs, 3e4) });
|
|
3075
|
+
if (prefixResult.code === 0) {
|
|
3076
|
+
const prefix = prefixResult.stdout.trim();
|
|
3077
|
+
if (prefix) return path.join(prefix, "bin");
|
|
3078
|
+
}
|
|
3079
|
+
const envPrefix = process.env.HOMEBREW_PREFIX?.trim();
|
|
3080
|
+
if (envPrefix) return path.join(envPrefix, "bin");
|
|
3081
|
+
for (const candidate of ["/opt/homebrew/bin", "/usr/local/bin"]) try {
|
|
3082
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
3083
|
+
} catch {}
|
|
3084
|
+
}
|
|
3085
|
+
async function installSkill(params) {
|
|
3086
|
+
const timeoutMs = Math.min(Math.max(params.timeoutMs ?? 3e5, 1e3), 9e5);
|
|
3087
|
+
const entry = loadWorkspaceSkillEntries(resolveUserPath(params.workspaceDir)).find((item) => item.skill.name === params.skillName);
|
|
3088
|
+
if (!entry) return {
|
|
3089
|
+
ok: false,
|
|
3090
|
+
message: `Skill not found: ${params.skillName}`,
|
|
3091
|
+
stdout: "",
|
|
3092
|
+
stderr: "",
|
|
3093
|
+
code: null
|
|
3094
|
+
};
|
|
3095
|
+
const spec = findInstallSpec(entry, params.installId);
|
|
3096
|
+
if (!spec) return {
|
|
3097
|
+
ok: false,
|
|
3098
|
+
message: `Installer not found: ${params.installId}`,
|
|
3099
|
+
stdout: "",
|
|
3100
|
+
stderr: "",
|
|
3101
|
+
code: null
|
|
3102
|
+
};
|
|
3103
|
+
if (spec.kind === "download") return await installDownloadSpec({
|
|
3104
|
+
entry,
|
|
3105
|
+
spec,
|
|
3106
|
+
timeoutMs
|
|
3107
|
+
});
|
|
3108
|
+
const command = buildInstallCommand(spec, resolveSkillsInstallPreferences(params.config));
|
|
3109
|
+
if (command.error) return {
|
|
3110
|
+
ok: false,
|
|
3111
|
+
message: command.error,
|
|
3112
|
+
stdout: "",
|
|
3113
|
+
stderr: "",
|
|
3114
|
+
code: null
|
|
3115
|
+
};
|
|
3116
|
+
const brewExe = hasBinary("brew") ? "brew" : resolveBrewExecutable();
|
|
3117
|
+
if (spec.kind === "brew" && !brewExe) return {
|
|
3118
|
+
ok: false,
|
|
3119
|
+
message: "brew not installed",
|
|
3120
|
+
stdout: "",
|
|
3121
|
+
stderr: "",
|
|
3122
|
+
code: null
|
|
3123
|
+
};
|
|
3124
|
+
if (spec.kind === "uv" && !hasBinary("uv")) if (brewExe) {
|
|
3125
|
+
const brewResult = await runCommandWithTimeout([
|
|
3126
|
+
brewExe,
|
|
3127
|
+
"install",
|
|
3128
|
+
"uv"
|
|
3129
|
+
], { timeoutMs });
|
|
3130
|
+
if (brewResult.code !== 0) return {
|
|
3131
|
+
ok: false,
|
|
3132
|
+
message: "Failed to install uv (brew)",
|
|
3133
|
+
stdout: brewResult.stdout.trim(),
|
|
3134
|
+
stderr: brewResult.stderr.trim(),
|
|
3135
|
+
code: brewResult.code
|
|
3136
|
+
};
|
|
3137
|
+
} else return {
|
|
3138
|
+
ok: false,
|
|
3139
|
+
message: "uv not installed (install via brew)",
|
|
3140
|
+
stdout: "",
|
|
3141
|
+
stderr: "",
|
|
3142
|
+
code: null
|
|
3143
|
+
};
|
|
3144
|
+
if (!command.argv || command.argv.length === 0) return {
|
|
3145
|
+
ok: false,
|
|
3146
|
+
message: "invalid install command",
|
|
3147
|
+
stdout: "",
|
|
3148
|
+
stderr: "",
|
|
3149
|
+
code: null
|
|
3150
|
+
};
|
|
3151
|
+
if (spec.kind === "brew" && brewExe && command.argv[0] === "brew") command.argv[0] = brewExe;
|
|
3152
|
+
if (spec.kind === "go" && !hasBinary("go")) if (brewExe) {
|
|
3153
|
+
const brewResult = await runCommandWithTimeout([
|
|
3154
|
+
brewExe,
|
|
3155
|
+
"install",
|
|
3156
|
+
"go"
|
|
3157
|
+
], { timeoutMs });
|
|
3158
|
+
if (brewResult.code !== 0) return {
|
|
3159
|
+
ok: false,
|
|
3160
|
+
message: "Failed to install go (brew)",
|
|
3161
|
+
stdout: brewResult.stdout.trim(),
|
|
3162
|
+
stderr: brewResult.stderr.trim(),
|
|
3163
|
+
code: brewResult.code
|
|
3164
|
+
};
|
|
3165
|
+
} else return {
|
|
3166
|
+
ok: false,
|
|
3167
|
+
message: "go not installed (install via brew)",
|
|
3168
|
+
stdout: "",
|
|
3169
|
+
stderr: "",
|
|
3170
|
+
code: null
|
|
3171
|
+
};
|
|
3172
|
+
let env;
|
|
3173
|
+
if (spec.kind === "go" && brewExe) {
|
|
3174
|
+
const brewBin = await resolveBrewBinDir(timeoutMs, brewExe);
|
|
3175
|
+
if (brewBin) env = { GOBIN: brewBin };
|
|
3176
|
+
}
|
|
3177
|
+
const result = await (async () => {
|
|
3178
|
+
const argv = command.argv;
|
|
3179
|
+
if (!argv || argv.length === 0) return {
|
|
3180
|
+
code: null,
|
|
3181
|
+
stdout: "",
|
|
3182
|
+
stderr: "invalid install command"
|
|
3183
|
+
};
|
|
3184
|
+
try {
|
|
3185
|
+
return await runCommandWithTimeout(argv, {
|
|
3186
|
+
timeoutMs,
|
|
3187
|
+
env
|
|
3188
|
+
});
|
|
3189
|
+
} catch (err) {
|
|
3190
|
+
return {
|
|
3191
|
+
code: null,
|
|
3192
|
+
stdout: "",
|
|
3193
|
+
stderr: err instanceof Error ? err.message : String(err)
|
|
3194
|
+
};
|
|
3195
|
+
}
|
|
3196
|
+
})();
|
|
3197
|
+
const success = result.code === 0;
|
|
3198
|
+
return {
|
|
3199
|
+
ok: success,
|
|
3200
|
+
message: success ? "Installed" : formatInstallFailureMessage(result),
|
|
3201
|
+
stdout: result.stdout.trim(),
|
|
3202
|
+
stderr: result.stderr.trim(),
|
|
3203
|
+
code: result.code
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
//#endregion
|
|
3208
|
+
//#region src/commands/onboard-skills.ts
|
|
3209
|
+
function summarizeInstallFailure(message) {
|
|
3210
|
+
const cleaned = message.replace(/^Install failed(?:\s*\([^)]*\))?\s*:?\s*/i, "").trim();
|
|
3211
|
+
if (!cleaned) return;
|
|
3212
|
+
const maxLen = 140;
|
|
3213
|
+
return cleaned.length > maxLen ? `${cleaned.slice(0, maxLen - 1)}…` : cleaned;
|
|
3214
|
+
}
|
|
3215
|
+
function formatSkillHint(skill) {
|
|
3216
|
+
const desc = skill.description?.trim();
|
|
3217
|
+
const installLabel = skill.install[0]?.label?.trim();
|
|
3218
|
+
const combined = desc && installLabel ? `${desc} — ${installLabel}` : desc || installLabel;
|
|
3219
|
+
if (!combined) return "install";
|
|
3220
|
+
const maxLen = 90;
|
|
3221
|
+
return combined.length > maxLen ? `${combined.slice(0, maxLen - 1)}…` : combined;
|
|
3222
|
+
}
|
|
3223
|
+
function upsertSkillEntry(cfg, skillKey, patch) {
|
|
3224
|
+
const entries = { ...cfg.skills?.entries };
|
|
3225
|
+
entries[skillKey] = {
|
|
3226
|
+
...entries[skillKey] ?? {},
|
|
3227
|
+
...patch
|
|
3228
|
+
};
|
|
3229
|
+
return {
|
|
3230
|
+
...cfg,
|
|
3231
|
+
skills: {
|
|
3232
|
+
...cfg.skills,
|
|
3233
|
+
entries
|
|
3234
|
+
}
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
async function setupSkills(cfg, workspaceDir, runtime, prompter) {
|
|
3238
|
+
const report = buildWorkspaceSkillStatus(workspaceDir, { config: cfg });
|
|
3239
|
+
const eligible = report.skills.filter((s) => s.eligible);
|
|
3240
|
+
const missing = report.skills.filter((s) => !s.eligible && !s.disabled && !s.blockedByAllowlist);
|
|
3241
|
+
const blocked = report.skills.filter((s) => s.blockedByAllowlist);
|
|
3242
|
+
const needsBrewPrompt = process.platform !== "win32" && report.skills.some((skill) => skill.install.some((option) => option.kind === "brew")) && !await detectBinary("brew");
|
|
3243
|
+
await prompter.note([
|
|
3244
|
+
`Eligible: ${eligible.length}`,
|
|
3245
|
+
`Missing requirements: ${missing.length}`,
|
|
3246
|
+
`Blocked by allowlist: ${blocked.length}`
|
|
3247
|
+
].join("\n"), "Skills status");
|
|
3248
|
+
if (!await prompter.confirm({
|
|
3249
|
+
message: "Configure skills now? (recommended)",
|
|
3250
|
+
initialValue: true
|
|
3251
|
+
})) return cfg;
|
|
3252
|
+
if (needsBrewPrompt) {
|
|
3253
|
+
await prompter.note(["Many skill dependencies are shipped via Homebrew.", "Without brew, you'll need to build from source or download releases manually."].join("\n"), "Homebrew recommended");
|
|
3254
|
+
if (await prompter.confirm({
|
|
3255
|
+
message: "Show Homebrew install command?",
|
|
3256
|
+
initialValue: true
|
|
3257
|
+
})) await prompter.note(["Run:", "/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""].join("\n"), "Homebrew install");
|
|
3258
|
+
}
|
|
3259
|
+
const nodeManager = await prompter.select({
|
|
3260
|
+
message: "Preferred node manager for skill installs",
|
|
3261
|
+
options: resolveNodeManagerOptions()
|
|
3262
|
+
});
|
|
3263
|
+
let next = {
|
|
3264
|
+
...cfg,
|
|
3265
|
+
skills: {
|
|
3266
|
+
...cfg.skills,
|
|
3267
|
+
install: {
|
|
3268
|
+
...cfg.skills?.install,
|
|
3269
|
+
nodeManager
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
};
|
|
3273
|
+
const installable = missing.filter((skill) => skill.install.length > 0 && skill.missing.bins.length > 0);
|
|
3274
|
+
if (installable.length > 0) {
|
|
3275
|
+
const selected = (await prompter.multiselect({
|
|
3276
|
+
message: "Install missing skill dependencies",
|
|
3277
|
+
options: [{
|
|
3278
|
+
value: "__skip__",
|
|
3279
|
+
label: "Skip for now",
|
|
3280
|
+
hint: "Continue without installing dependencies"
|
|
3281
|
+
}, ...installable.map((skill) => ({
|
|
3282
|
+
value: skill.name,
|
|
3283
|
+
label: `${skill.emoji ?? "🧩"} ${skill.name}`,
|
|
3284
|
+
hint: formatSkillHint(skill)
|
|
3285
|
+
}))]
|
|
3286
|
+
})).filter((name) => name !== "__skip__");
|
|
3287
|
+
for (const name of selected) {
|
|
3288
|
+
const target = installable.find((s) => s.name === name);
|
|
3289
|
+
if (!target || target.install.length === 0) continue;
|
|
3290
|
+
const installId = target.install[0]?.id;
|
|
3291
|
+
if (!installId) continue;
|
|
3292
|
+
const spin = prompter.progress(`Installing ${name}…`);
|
|
3293
|
+
const result = await installSkill({
|
|
3294
|
+
workspaceDir,
|
|
3295
|
+
skillName: target.name,
|
|
3296
|
+
installId,
|
|
3297
|
+
config: next
|
|
3298
|
+
});
|
|
3299
|
+
if (result.ok) spin.stop(`Installed ${name}`);
|
|
3300
|
+
else {
|
|
3301
|
+
const code = result.code == null ? "" : ` (exit ${result.code})`;
|
|
3302
|
+
const detail = summarizeInstallFailure(result.message);
|
|
3303
|
+
spin.stop(`Install failed: ${name}${code}${detail ? ` — ${detail}` : ""}`);
|
|
3304
|
+
if (result.stderr) runtime.log(result.stderr.trim());
|
|
3305
|
+
else if (result.stdout) runtime.log(result.stdout.trim());
|
|
3306
|
+
runtime.log(`Tip: run \`${formatCliCommand("openclaw doctor")}\` to review skills + requirements.`);
|
|
3307
|
+
runtime.log("Docs: https://docs.openclaw.ai/skills");
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
for (const skill of missing) {
|
|
3312
|
+
if (!skill.primaryEnv || skill.missing.env.length === 0) continue;
|
|
3313
|
+
if (!await prompter.confirm({
|
|
3314
|
+
message: `Set ${skill.primaryEnv} for ${skill.name}?`,
|
|
3315
|
+
initialValue: false
|
|
3316
|
+
})) continue;
|
|
3317
|
+
const apiKey = String(await prompter.text({
|
|
3318
|
+
message: `Enter ${skill.primaryEnv}`,
|
|
3319
|
+
validate: (value) => value?.trim() ? void 0 : "Required"
|
|
3320
|
+
}));
|
|
3321
|
+
next = upsertSkillEntry(next, skill.skillKey, { apiKey: apiKey.trim() });
|
|
3322
|
+
}
|
|
3323
|
+
return next;
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
//#endregion
|
|
3327
|
+
export { resolveControlUiRootSync as _, applyModelFallbacksFromSelection as a, promptModelAllowlist as c, applyAuthChoice as d, upsertSharedEnvVar as f, resolveControlUiRootOverrideSync as g, ensureControlUiAssetsBuilt as h, applyModelAllowlist as i, resolvePreferredProviderForAuthChoice as l, promptAuthChoiceGrouped as m, installSkill as n, applyPrimaryModel as o, applyGoogleGeminiModelDefault as p, promptRemoteGatewayConfig as r, promptDefaultModel as s, setupSkills as t, warnIfModelConfigLooksOff as u, discoverGatewayBeacons as v };
|