@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,2956 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
+
import { g as resolveStateDir, h as resolveOAuthPath } from "./paths-scjhy7N2.js";
|
|
3
|
+
import { D as DEFAULT_AGENT_ID, a as resolveAgentModelPrimary } from "./agent-scope-BbT4OG2N.js";
|
|
4
|
+
import { t as createSubsystemLogger } from "./subsystem-CAq3uyo7.js";
|
|
5
|
+
import { h as resolveUserPath } from "./utils-CKSrBNwq.js";
|
|
6
|
+
import { a as saveJsonFile, i as loadJsonFile, r as resolveCopilotApiToken, t as DEFAULT_COPILOT_API_BASE_URL } from "./github-copilot-token-CnxakiSC.js";
|
|
7
|
+
import { t as formatCliCommand } from "./command-format-DELazozB.js";
|
|
8
|
+
import { t as isTruthyEnvValue } from "./env-l7QVNj6j.js";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import { execFileSync, execSync } from "node:child_process";
|
|
12
|
+
import lockfile from "proper-lockfile";
|
|
13
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
14
|
+
import { getEnvApiKey, getOAuthApiKey, getOAuthProviders } from "@mariozechner/pi-ai";
|
|
15
|
+
import { BedrockClient, ListFoundationModelsCommand } from "@aws-sdk/client-bedrock";
|
|
16
|
+
|
|
17
|
+
//#region src/agents/defaults.ts
|
|
18
|
+
const DEFAULT_PROVIDER = "anthropic";
|
|
19
|
+
const DEFAULT_MODEL = "claude-opus-4-5";
|
|
20
|
+
const DEFAULT_CONTEXT_TOKENS = 2e5;
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/agents/auth-profiles/constants.ts
|
|
24
|
+
const AUTH_STORE_VERSION = 1;
|
|
25
|
+
const AUTH_PROFILE_FILENAME = "auth-profiles.json";
|
|
26
|
+
const LEGACY_AUTH_FILENAME = "auth.json";
|
|
27
|
+
const CLAUDE_CLI_PROFILE_ID = "anthropic:claude-cli";
|
|
28
|
+
const CODEX_CLI_PROFILE_ID = "openai-codex:codex-cli";
|
|
29
|
+
const QWEN_CLI_PROFILE_ID = "qwen-portal:qwen-cli";
|
|
30
|
+
const MINIMAX_CLI_PROFILE_ID = "minimax-portal:minimax-cli";
|
|
31
|
+
const AUTH_STORE_LOCK_OPTIONS = {
|
|
32
|
+
retries: {
|
|
33
|
+
retries: 10,
|
|
34
|
+
factor: 2,
|
|
35
|
+
minTimeout: 100,
|
|
36
|
+
maxTimeout: 1e4,
|
|
37
|
+
randomize: true
|
|
38
|
+
},
|
|
39
|
+
stale: 3e4
|
|
40
|
+
};
|
|
41
|
+
const EXTERNAL_CLI_SYNC_TTL_MS = 900 * 1e3;
|
|
42
|
+
const EXTERNAL_CLI_NEAR_EXPIRY_MS = 600 * 1e3;
|
|
43
|
+
const log$1 = createSubsystemLogger("agents/auth-profiles");
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/agents/auth-profiles/display.ts
|
|
47
|
+
function resolveAuthProfileDisplayLabel(params) {
|
|
48
|
+
const { cfg, store, profileId } = params;
|
|
49
|
+
const profile = store.profiles[profileId];
|
|
50
|
+
const email = cfg?.auth?.profiles?.[profileId]?.email?.trim() || (profile && "email" in profile ? profile.email?.trim() : void 0);
|
|
51
|
+
if (email) return `${profileId} (${email})`;
|
|
52
|
+
return profileId;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/agents/cli-credentials.ts
|
|
57
|
+
const log = createSubsystemLogger("agents/auth-profiles");
|
|
58
|
+
const QWEN_CLI_CREDENTIALS_RELATIVE_PATH = ".qwen/oauth_creds.json";
|
|
59
|
+
const MINIMAX_CLI_CREDENTIALS_RELATIVE_PATH = ".minimax/oauth_creds.json";
|
|
60
|
+
let qwenCliCache = null;
|
|
61
|
+
let minimaxCliCache = null;
|
|
62
|
+
function resolveQwenCliCredentialsPath(homeDir) {
|
|
63
|
+
const baseDir = homeDir ?? resolveUserPath("~");
|
|
64
|
+
return path.join(baseDir, QWEN_CLI_CREDENTIALS_RELATIVE_PATH);
|
|
65
|
+
}
|
|
66
|
+
function resolveMiniMaxCliCredentialsPath(homeDir) {
|
|
67
|
+
const baseDir = homeDir ?? resolveUserPath("~");
|
|
68
|
+
return path.join(baseDir, MINIMAX_CLI_CREDENTIALS_RELATIVE_PATH);
|
|
69
|
+
}
|
|
70
|
+
function readQwenCliCredentials(options) {
|
|
71
|
+
const raw = loadJsonFile(resolveQwenCliCredentialsPath(options?.homeDir));
|
|
72
|
+
if (!raw || typeof raw !== "object") return null;
|
|
73
|
+
const data = raw;
|
|
74
|
+
const accessToken = data.access_token;
|
|
75
|
+
const refreshToken = data.refresh_token;
|
|
76
|
+
const expiresAt = data.expiry_date;
|
|
77
|
+
if (typeof accessToken !== "string" || !accessToken) return null;
|
|
78
|
+
if (typeof refreshToken !== "string" || !refreshToken) return null;
|
|
79
|
+
if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt)) return null;
|
|
80
|
+
return {
|
|
81
|
+
type: "oauth",
|
|
82
|
+
provider: "qwen-portal",
|
|
83
|
+
access: accessToken,
|
|
84
|
+
refresh: refreshToken,
|
|
85
|
+
expires: expiresAt
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function readMiniMaxCliCredentials(options) {
|
|
89
|
+
const raw = loadJsonFile(resolveMiniMaxCliCredentialsPath(options?.homeDir));
|
|
90
|
+
if (!raw || typeof raw !== "object") return null;
|
|
91
|
+
const data = raw;
|
|
92
|
+
const accessToken = data.access_token;
|
|
93
|
+
const refreshToken = data.refresh_token;
|
|
94
|
+
const expiresAt = data.expiry_date;
|
|
95
|
+
if (typeof accessToken !== "string" || !accessToken) return null;
|
|
96
|
+
if (typeof refreshToken !== "string" || !refreshToken) return null;
|
|
97
|
+
if (typeof expiresAt !== "number" || !Number.isFinite(expiresAt)) return null;
|
|
98
|
+
return {
|
|
99
|
+
type: "oauth",
|
|
100
|
+
provider: "minimax-portal",
|
|
101
|
+
access: accessToken,
|
|
102
|
+
refresh: refreshToken,
|
|
103
|
+
expires: expiresAt
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function readQwenCliCredentialsCached(options) {
|
|
107
|
+
const ttlMs = options?.ttlMs ?? 0;
|
|
108
|
+
const now = Date.now();
|
|
109
|
+
const cacheKey = resolveQwenCliCredentialsPath(options?.homeDir);
|
|
110
|
+
if (ttlMs > 0 && qwenCliCache && qwenCliCache.cacheKey === cacheKey && now - qwenCliCache.readAt < ttlMs) return qwenCliCache.value;
|
|
111
|
+
const value = readQwenCliCredentials({ homeDir: options?.homeDir });
|
|
112
|
+
if (ttlMs > 0) qwenCliCache = {
|
|
113
|
+
value,
|
|
114
|
+
readAt: now,
|
|
115
|
+
cacheKey
|
|
116
|
+
};
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
function readMiniMaxCliCredentialsCached(options) {
|
|
120
|
+
const ttlMs = options?.ttlMs ?? 0;
|
|
121
|
+
const now = Date.now();
|
|
122
|
+
const cacheKey = resolveMiniMaxCliCredentialsPath(options?.homeDir);
|
|
123
|
+
if (ttlMs > 0 && minimaxCliCache && minimaxCliCache.cacheKey === cacheKey && now - minimaxCliCache.readAt < ttlMs) return minimaxCliCache.value;
|
|
124
|
+
const value = readMiniMaxCliCredentials({ homeDir: options?.homeDir });
|
|
125
|
+
if (ttlMs > 0) minimaxCliCache = {
|
|
126
|
+
value,
|
|
127
|
+
readAt: now,
|
|
128
|
+
cacheKey
|
|
129
|
+
};
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/agents/auth-profiles/external-cli-sync.ts
|
|
135
|
+
function shallowEqualOAuthCredentials(a, b) {
|
|
136
|
+
if (!a) return false;
|
|
137
|
+
if (a.type !== "oauth") return false;
|
|
138
|
+
return a.provider === b.provider && a.access === b.access && a.refresh === b.refresh && a.expires === b.expires && a.email === b.email && a.enterpriseUrl === b.enterpriseUrl && a.projectId === b.projectId && a.accountId === b.accountId;
|
|
139
|
+
}
|
|
140
|
+
function isExternalProfileFresh(cred, now) {
|
|
141
|
+
if (!cred) return false;
|
|
142
|
+
if (cred.type !== "oauth" && cred.type !== "token") return false;
|
|
143
|
+
if (cred.provider !== "qwen-portal" && cred.provider !== "minimax-portal") return false;
|
|
144
|
+
if (typeof cred.expires !== "number") return true;
|
|
145
|
+
return cred.expires > now + EXTERNAL_CLI_NEAR_EXPIRY_MS;
|
|
146
|
+
}
|
|
147
|
+
/** Sync external CLI credentials into the store for a given provider. */
|
|
148
|
+
function syncExternalCliCredentialsForProvider(store, profileId, provider, readCredentials, now) {
|
|
149
|
+
const existing = store.profiles[profileId];
|
|
150
|
+
const creds = !existing || existing.provider !== provider || !isExternalProfileFresh(existing, now) ? readCredentials() : null;
|
|
151
|
+
if (!creds) return false;
|
|
152
|
+
const existingOAuth = existing?.type === "oauth" ? existing : void 0;
|
|
153
|
+
if ((!existingOAuth || existingOAuth.provider !== provider || existingOAuth.expires <= now || creds.expires > existingOAuth.expires) && !shallowEqualOAuthCredentials(existingOAuth, creds)) {
|
|
154
|
+
store.profiles[profileId] = creds;
|
|
155
|
+
log$1.info(`synced ${provider} credentials from external cli`, {
|
|
156
|
+
profileId,
|
|
157
|
+
expires: new Date(creds.expires).toISOString()
|
|
158
|
+
});
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Sync OAuth credentials from external CLI tools (Qwen Code CLI, MiniMax CLI) into the store.
|
|
165
|
+
*
|
|
166
|
+
* Returns true if any credentials were updated.
|
|
167
|
+
*/
|
|
168
|
+
function syncExternalCliCredentials(store) {
|
|
169
|
+
let mutated = false;
|
|
170
|
+
const now = Date.now();
|
|
171
|
+
const existingQwen = store.profiles[QWEN_CLI_PROFILE_ID];
|
|
172
|
+
const qwenCreds = !existingQwen || existingQwen.provider !== "qwen-portal" || !isExternalProfileFresh(existingQwen, now) ? readQwenCliCredentialsCached({ ttlMs: EXTERNAL_CLI_SYNC_TTL_MS }) : null;
|
|
173
|
+
if (qwenCreds) {
|
|
174
|
+
const existing = store.profiles[QWEN_CLI_PROFILE_ID];
|
|
175
|
+
const existingOAuth = existing?.type === "oauth" ? existing : void 0;
|
|
176
|
+
if ((!existingOAuth || existingOAuth.provider !== "qwen-portal" || existingOAuth.expires <= now || qwenCreds.expires > existingOAuth.expires) && !shallowEqualOAuthCredentials(existingOAuth, qwenCreds)) {
|
|
177
|
+
store.profiles[QWEN_CLI_PROFILE_ID] = qwenCreds;
|
|
178
|
+
mutated = true;
|
|
179
|
+
log$1.info("synced qwen credentials from qwen cli", {
|
|
180
|
+
profileId: QWEN_CLI_PROFILE_ID,
|
|
181
|
+
expires: new Date(qwenCreds.expires).toISOString()
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (syncExternalCliCredentialsForProvider(store, MINIMAX_CLI_PROFILE_ID, "minimax-portal", () => readMiniMaxCliCredentialsCached({ ttlMs: EXTERNAL_CLI_SYNC_TTL_MS }), now)) mutated = true;
|
|
186
|
+
return mutated;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/agents/agent-paths.ts
|
|
191
|
+
function resolveOpenClawAgentDir() {
|
|
192
|
+
const override = process.env.OPENCLAW_AGENT_DIR?.trim() || process.env.PI_CODING_AGENT_DIR?.trim();
|
|
193
|
+
if (override) return resolveUserPath(override);
|
|
194
|
+
return resolveUserPath(path.join(resolveStateDir(), "agents", DEFAULT_AGENT_ID, "agent"));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/agents/auth-profiles/paths.ts
|
|
199
|
+
function resolveAuthStorePath(agentDir) {
|
|
200
|
+
const resolved = resolveUserPath(agentDir ?? resolveOpenClawAgentDir());
|
|
201
|
+
return path.join(resolved, AUTH_PROFILE_FILENAME);
|
|
202
|
+
}
|
|
203
|
+
function resolveLegacyAuthStorePath(agentDir) {
|
|
204
|
+
const resolved = resolveUserPath(agentDir ?? resolveOpenClawAgentDir());
|
|
205
|
+
return path.join(resolved, LEGACY_AUTH_FILENAME);
|
|
206
|
+
}
|
|
207
|
+
function resolveAuthStorePathForDisplay(agentDir) {
|
|
208
|
+
const pathname = resolveAuthStorePath(agentDir);
|
|
209
|
+
return pathname.startsWith("~") ? pathname : resolveUserPath(pathname);
|
|
210
|
+
}
|
|
211
|
+
function ensureAuthStoreFile(pathname) {
|
|
212
|
+
if (fs.existsSync(pathname)) return;
|
|
213
|
+
saveJsonFile(pathname, {
|
|
214
|
+
version: AUTH_STORE_VERSION,
|
|
215
|
+
profiles: {}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/agents/auth-profiles/store.ts
|
|
221
|
+
async function updateAuthProfileStoreWithLock(params) {
|
|
222
|
+
const authPath = resolveAuthStorePath(params.agentDir);
|
|
223
|
+
ensureAuthStoreFile(authPath);
|
|
224
|
+
let release;
|
|
225
|
+
try {
|
|
226
|
+
release = await lockfile.lock(authPath, AUTH_STORE_LOCK_OPTIONS);
|
|
227
|
+
const store = ensureAuthProfileStore(params.agentDir);
|
|
228
|
+
if (params.updater(store)) saveAuthProfileStore(store, params.agentDir);
|
|
229
|
+
return store;
|
|
230
|
+
} catch {
|
|
231
|
+
return null;
|
|
232
|
+
} finally {
|
|
233
|
+
if (release) try {
|
|
234
|
+
await release();
|
|
235
|
+
} catch {}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function coerceLegacyStore(raw) {
|
|
239
|
+
if (!raw || typeof raw !== "object") return null;
|
|
240
|
+
const record = raw;
|
|
241
|
+
if ("profiles" in record) return null;
|
|
242
|
+
const entries = {};
|
|
243
|
+
for (const [key, value] of Object.entries(record)) {
|
|
244
|
+
if (!value || typeof value !== "object") continue;
|
|
245
|
+
const typed = value;
|
|
246
|
+
if (typed.type !== "api_key" && typed.type !== "oauth" && typed.type !== "token") continue;
|
|
247
|
+
entries[key] = {
|
|
248
|
+
...typed,
|
|
249
|
+
provider: String(typed.provider ?? key)
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return Object.keys(entries).length > 0 ? entries : null;
|
|
253
|
+
}
|
|
254
|
+
function coerceAuthStore(raw) {
|
|
255
|
+
if (!raw || typeof raw !== "object") return null;
|
|
256
|
+
const record = raw;
|
|
257
|
+
if (!record.profiles || typeof record.profiles !== "object") return null;
|
|
258
|
+
const profiles = record.profiles;
|
|
259
|
+
const normalized = {};
|
|
260
|
+
for (const [key, value] of Object.entries(profiles)) {
|
|
261
|
+
if (!value || typeof value !== "object") continue;
|
|
262
|
+
const typed = value;
|
|
263
|
+
if (typed.type !== "api_key" && typed.type !== "oauth" && typed.type !== "token") continue;
|
|
264
|
+
if (!typed.provider) continue;
|
|
265
|
+
normalized[key] = typed;
|
|
266
|
+
}
|
|
267
|
+
const order = record.order && typeof record.order === "object" ? Object.entries(record.order).reduce((acc, [provider, value]) => {
|
|
268
|
+
if (!Array.isArray(value)) return acc;
|
|
269
|
+
const list = value.map((entry) => typeof entry === "string" ? entry.trim() : "").filter(Boolean);
|
|
270
|
+
if (list.length === 0) return acc;
|
|
271
|
+
acc[provider] = list;
|
|
272
|
+
return acc;
|
|
273
|
+
}, {}) : void 0;
|
|
274
|
+
return {
|
|
275
|
+
version: Number(record.version ?? AUTH_STORE_VERSION),
|
|
276
|
+
profiles: normalized,
|
|
277
|
+
order,
|
|
278
|
+
lastGood: record.lastGood && typeof record.lastGood === "object" ? record.lastGood : void 0,
|
|
279
|
+
usageStats: record.usageStats && typeof record.usageStats === "object" ? record.usageStats : void 0
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function mergeRecord(base, override) {
|
|
283
|
+
if (!base && !override) return;
|
|
284
|
+
if (!base) return { ...override };
|
|
285
|
+
if (!override) return { ...base };
|
|
286
|
+
return {
|
|
287
|
+
...base,
|
|
288
|
+
...override
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function mergeAuthProfileStores(base, override) {
|
|
292
|
+
if (Object.keys(override.profiles).length === 0 && !override.order && !override.lastGood && !override.usageStats) return base;
|
|
293
|
+
return {
|
|
294
|
+
version: Math.max(base.version, override.version ?? base.version),
|
|
295
|
+
profiles: {
|
|
296
|
+
...base.profiles,
|
|
297
|
+
...override.profiles
|
|
298
|
+
},
|
|
299
|
+
order: mergeRecord(base.order, override.order),
|
|
300
|
+
lastGood: mergeRecord(base.lastGood, override.lastGood),
|
|
301
|
+
usageStats: mergeRecord(base.usageStats, override.usageStats)
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function mergeOAuthFileIntoStore(store) {
|
|
305
|
+
const oauthRaw = loadJsonFile(resolveOAuthPath());
|
|
306
|
+
if (!oauthRaw || typeof oauthRaw !== "object") return false;
|
|
307
|
+
const oauthEntries = oauthRaw;
|
|
308
|
+
let mutated = false;
|
|
309
|
+
for (const [provider, creds] of Object.entries(oauthEntries)) {
|
|
310
|
+
if (!creds || typeof creds !== "object") continue;
|
|
311
|
+
const profileId = `${provider}:default`;
|
|
312
|
+
if (store.profiles[profileId]) continue;
|
|
313
|
+
store.profiles[profileId] = {
|
|
314
|
+
type: "oauth",
|
|
315
|
+
provider,
|
|
316
|
+
...creds
|
|
317
|
+
};
|
|
318
|
+
mutated = true;
|
|
319
|
+
}
|
|
320
|
+
return mutated;
|
|
321
|
+
}
|
|
322
|
+
function loadAuthProfileStore() {
|
|
323
|
+
const authPath = resolveAuthStorePath();
|
|
324
|
+
const asStore = coerceAuthStore(loadJsonFile(authPath));
|
|
325
|
+
if (asStore) {
|
|
326
|
+
if (syncExternalCliCredentials(asStore)) saveJsonFile(authPath, asStore);
|
|
327
|
+
return asStore;
|
|
328
|
+
}
|
|
329
|
+
const legacy = coerceLegacyStore(loadJsonFile(resolveLegacyAuthStorePath()));
|
|
330
|
+
if (legacy) {
|
|
331
|
+
const store = {
|
|
332
|
+
version: AUTH_STORE_VERSION,
|
|
333
|
+
profiles: {}
|
|
334
|
+
};
|
|
335
|
+
for (const [provider, cred] of Object.entries(legacy)) {
|
|
336
|
+
const profileId = `${provider}:default`;
|
|
337
|
+
if (cred.type === "api_key") store.profiles[profileId] = {
|
|
338
|
+
type: "api_key",
|
|
339
|
+
provider: String(cred.provider ?? provider),
|
|
340
|
+
key: cred.key,
|
|
341
|
+
...cred.email ? { email: cred.email } : {}
|
|
342
|
+
};
|
|
343
|
+
else if (cred.type === "token") store.profiles[profileId] = {
|
|
344
|
+
type: "token",
|
|
345
|
+
provider: String(cred.provider ?? provider),
|
|
346
|
+
token: cred.token,
|
|
347
|
+
...typeof cred.expires === "number" ? { expires: cred.expires } : {},
|
|
348
|
+
...cred.email ? { email: cred.email } : {}
|
|
349
|
+
};
|
|
350
|
+
else store.profiles[profileId] = {
|
|
351
|
+
type: "oauth",
|
|
352
|
+
provider: String(cred.provider ?? provider),
|
|
353
|
+
access: cred.access,
|
|
354
|
+
refresh: cred.refresh,
|
|
355
|
+
expires: cred.expires,
|
|
356
|
+
...cred.enterpriseUrl ? { enterpriseUrl: cred.enterpriseUrl } : {},
|
|
357
|
+
...cred.projectId ? { projectId: cred.projectId } : {},
|
|
358
|
+
...cred.accountId ? { accountId: cred.accountId } : {},
|
|
359
|
+
...cred.email ? { email: cred.email } : {}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
syncExternalCliCredentials(store);
|
|
363
|
+
return store;
|
|
364
|
+
}
|
|
365
|
+
const store = {
|
|
366
|
+
version: AUTH_STORE_VERSION,
|
|
367
|
+
profiles: {}
|
|
368
|
+
};
|
|
369
|
+
syncExternalCliCredentials(store);
|
|
370
|
+
return store;
|
|
371
|
+
}
|
|
372
|
+
function loadAuthProfileStoreForAgent(agentDir, _options) {
|
|
373
|
+
const authPath = resolveAuthStorePath(agentDir);
|
|
374
|
+
const asStore = coerceAuthStore(loadJsonFile(authPath));
|
|
375
|
+
if (asStore) {
|
|
376
|
+
if (syncExternalCliCredentials(asStore)) saveJsonFile(authPath, asStore);
|
|
377
|
+
return asStore;
|
|
378
|
+
}
|
|
379
|
+
if (agentDir) {
|
|
380
|
+
const mainStore = coerceAuthStore(loadJsonFile(resolveAuthStorePath()));
|
|
381
|
+
if (mainStore && Object.keys(mainStore.profiles).length > 0) {
|
|
382
|
+
saveJsonFile(authPath, mainStore);
|
|
383
|
+
log$1.info("inherited auth-profiles from main agent", { agentDir });
|
|
384
|
+
return mainStore;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
const legacy = coerceLegacyStore(loadJsonFile(resolveLegacyAuthStorePath(agentDir)));
|
|
388
|
+
const store = {
|
|
389
|
+
version: AUTH_STORE_VERSION,
|
|
390
|
+
profiles: {}
|
|
391
|
+
};
|
|
392
|
+
if (legacy) for (const [provider, cred] of Object.entries(legacy)) {
|
|
393
|
+
const profileId = `${provider}:default`;
|
|
394
|
+
if (cred.type === "api_key") store.profiles[profileId] = {
|
|
395
|
+
type: "api_key",
|
|
396
|
+
provider: String(cred.provider ?? provider),
|
|
397
|
+
key: cred.key,
|
|
398
|
+
...cred.email ? { email: cred.email } : {}
|
|
399
|
+
};
|
|
400
|
+
else if (cred.type === "token") store.profiles[profileId] = {
|
|
401
|
+
type: "token",
|
|
402
|
+
provider: String(cred.provider ?? provider),
|
|
403
|
+
token: cred.token,
|
|
404
|
+
...typeof cred.expires === "number" ? { expires: cred.expires } : {},
|
|
405
|
+
...cred.email ? { email: cred.email } : {}
|
|
406
|
+
};
|
|
407
|
+
else store.profiles[profileId] = {
|
|
408
|
+
type: "oauth",
|
|
409
|
+
provider: String(cred.provider ?? provider),
|
|
410
|
+
access: cred.access,
|
|
411
|
+
refresh: cred.refresh,
|
|
412
|
+
expires: cred.expires,
|
|
413
|
+
...cred.enterpriseUrl ? { enterpriseUrl: cred.enterpriseUrl } : {},
|
|
414
|
+
...cred.projectId ? { projectId: cred.projectId } : {},
|
|
415
|
+
...cred.accountId ? { accountId: cred.accountId } : {},
|
|
416
|
+
...cred.email ? { email: cred.email } : {}
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
const mergedOAuth = mergeOAuthFileIntoStore(store);
|
|
420
|
+
const syncedCli = syncExternalCliCredentials(store);
|
|
421
|
+
const shouldWrite = legacy !== null || mergedOAuth || syncedCli;
|
|
422
|
+
if (shouldWrite) saveJsonFile(authPath, store);
|
|
423
|
+
if (shouldWrite && legacy !== null) {
|
|
424
|
+
const legacyPath = resolveLegacyAuthStorePath(agentDir);
|
|
425
|
+
try {
|
|
426
|
+
fs.unlinkSync(legacyPath);
|
|
427
|
+
} catch (err) {
|
|
428
|
+
if (err?.code !== "ENOENT") log$1.warn("failed to delete legacy auth.json after migration", {
|
|
429
|
+
err,
|
|
430
|
+
legacyPath
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return store;
|
|
435
|
+
}
|
|
436
|
+
function ensureAuthProfileStore(agentDir, options) {
|
|
437
|
+
const store = loadAuthProfileStoreForAgent(agentDir, options);
|
|
438
|
+
const authPath = resolveAuthStorePath(agentDir);
|
|
439
|
+
const mainAuthPath = resolveAuthStorePath();
|
|
440
|
+
if (!agentDir || authPath === mainAuthPath) return store;
|
|
441
|
+
return mergeAuthProfileStores(loadAuthProfileStoreForAgent(void 0, options), store);
|
|
442
|
+
}
|
|
443
|
+
function saveAuthProfileStore(store, agentDir) {
|
|
444
|
+
saveJsonFile(resolveAuthStorePath(agentDir), {
|
|
445
|
+
version: AUTH_STORE_VERSION,
|
|
446
|
+
profiles: store.profiles,
|
|
447
|
+
order: store.order ?? void 0,
|
|
448
|
+
lastGood: store.lastGood ?? void 0,
|
|
449
|
+
usageStats: store.usageStats ?? void 0
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/agents/auth-profiles/profiles.ts
|
|
455
|
+
async function setAuthProfileOrder(params) {
|
|
456
|
+
const providerKey = normalizeProviderId(params.provider);
|
|
457
|
+
const sanitized = params.order && Array.isArray(params.order) ? params.order.map((entry) => String(entry).trim()).filter(Boolean) : [];
|
|
458
|
+
const deduped = [];
|
|
459
|
+
for (const entry of sanitized) if (!deduped.includes(entry)) deduped.push(entry);
|
|
460
|
+
return await updateAuthProfileStoreWithLock({
|
|
461
|
+
agentDir: params.agentDir,
|
|
462
|
+
updater: (store) => {
|
|
463
|
+
store.order = store.order ?? {};
|
|
464
|
+
if (deduped.length === 0) {
|
|
465
|
+
if (!store.order[providerKey]) return false;
|
|
466
|
+
delete store.order[providerKey];
|
|
467
|
+
if (Object.keys(store.order).length === 0) store.order = void 0;
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
store.order[providerKey] = deduped;
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function upsertAuthProfile(params) {
|
|
476
|
+
const store = ensureAuthProfileStore(params.agentDir);
|
|
477
|
+
store.profiles[params.profileId] = params.credential;
|
|
478
|
+
saveAuthProfileStore(store, params.agentDir);
|
|
479
|
+
}
|
|
480
|
+
function listProfilesForProvider(store, provider) {
|
|
481
|
+
const providerKey = normalizeProviderId(provider);
|
|
482
|
+
return Object.entries(store.profiles).filter(([, cred]) => normalizeProviderId(cred.provider) === providerKey).map(([id]) => id);
|
|
483
|
+
}
|
|
484
|
+
async function markAuthProfileGood(params) {
|
|
485
|
+
const { store, provider, profileId, agentDir } = params;
|
|
486
|
+
const updated = await updateAuthProfileStoreWithLock({
|
|
487
|
+
agentDir,
|
|
488
|
+
updater: (freshStore) => {
|
|
489
|
+
const profile = freshStore.profiles[profileId];
|
|
490
|
+
if (!profile || profile.provider !== provider) return false;
|
|
491
|
+
freshStore.lastGood = {
|
|
492
|
+
...freshStore.lastGood,
|
|
493
|
+
[provider]: profileId
|
|
494
|
+
};
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
if (updated) {
|
|
499
|
+
store.lastGood = updated.lastGood;
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
const profile = store.profiles[profileId];
|
|
503
|
+
if (!profile || profile.provider !== provider) return;
|
|
504
|
+
store.lastGood = {
|
|
505
|
+
...store.lastGood,
|
|
506
|
+
[provider]: profileId
|
|
507
|
+
};
|
|
508
|
+
saveAuthProfileStore(store, agentDir);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/agents/auth-profiles/repair.ts
|
|
513
|
+
function getProfileSuffix(profileId) {
|
|
514
|
+
const idx = profileId.indexOf(":");
|
|
515
|
+
if (idx < 0) return "";
|
|
516
|
+
return profileId.slice(idx + 1);
|
|
517
|
+
}
|
|
518
|
+
function isEmailLike(value) {
|
|
519
|
+
const trimmed = value.trim();
|
|
520
|
+
if (!trimmed) return false;
|
|
521
|
+
return trimmed.includes("@") && trimmed.includes(".");
|
|
522
|
+
}
|
|
523
|
+
function suggestOAuthProfileIdForLegacyDefault(params) {
|
|
524
|
+
const providerKey = normalizeProviderId(params.provider);
|
|
525
|
+
if (getProfileSuffix(params.legacyProfileId) !== "default") return null;
|
|
526
|
+
const legacyCfg = params.cfg?.auth?.profiles?.[params.legacyProfileId];
|
|
527
|
+
if (legacyCfg && normalizeProviderId(legacyCfg.provider) === providerKey && legacyCfg.mode !== "oauth") return null;
|
|
528
|
+
const oauthProfiles = listProfilesForProvider(params.store, providerKey).filter((id) => params.store.profiles[id]?.type === "oauth");
|
|
529
|
+
if (oauthProfiles.length === 0) return null;
|
|
530
|
+
const configuredEmail = legacyCfg?.email?.trim();
|
|
531
|
+
if (configuredEmail) {
|
|
532
|
+
const byEmail = oauthProfiles.find((id) => {
|
|
533
|
+
const cred = params.store.profiles[id];
|
|
534
|
+
if (!cred || cred.type !== "oauth") return false;
|
|
535
|
+
return cred.email?.trim() === configuredEmail || id === `${providerKey}:${configuredEmail}`;
|
|
536
|
+
});
|
|
537
|
+
if (byEmail) return byEmail;
|
|
538
|
+
}
|
|
539
|
+
const lastGood = params.store.lastGood?.[providerKey] ?? params.store.lastGood?.[params.provider];
|
|
540
|
+
if (lastGood && oauthProfiles.includes(lastGood)) return lastGood;
|
|
541
|
+
const nonLegacy = oauthProfiles.filter((id) => id !== params.legacyProfileId);
|
|
542
|
+
if (nonLegacy.length === 1) return nonLegacy[0] ?? null;
|
|
543
|
+
const emailLike = nonLegacy.filter((id) => isEmailLike(getProfileSuffix(id)));
|
|
544
|
+
if (emailLike.length === 1) return emailLike[0] ?? null;
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
function repairOAuthProfileIdMismatch(params) {
|
|
548
|
+
const legacyProfileId = params.legacyProfileId ?? `${normalizeProviderId(params.provider)}:default`;
|
|
549
|
+
const legacyCfg = params.cfg.auth?.profiles?.[legacyProfileId];
|
|
550
|
+
if (!legacyCfg) return {
|
|
551
|
+
config: params.cfg,
|
|
552
|
+
changes: [],
|
|
553
|
+
migrated: false
|
|
554
|
+
};
|
|
555
|
+
if (legacyCfg.mode !== "oauth") return {
|
|
556
|
+
config: params.cfg,
|
|
557
|
+
changes: [],
|
|
558
|
+
migrated: false
|
|
559
|
+
};
|
|
560
|
+
if (normalizeProviderId(legacyCfg.provider) !== normalizeProviderId(params.provider)) return {
|
|
561
|
+
config: params.cfg,
|
|
562
|
+
changes: [],
|
|
563
|
+
migrated: false
|
|
564
|
+
};
|
|
565
|
+
const toProfileId = suggestOAuthProfileIdForLegacyDefault({
|
|
566
|
+
cfg: params.cfg,
|
|
567
|
+
store: params.store,
|
|
568
|
+
provider: params.provider,
|
|
569
|
+
legacyProfileId
|
|
570
|
+
});
|
|
571
|
+
if (!toProfileId || toProfileId === legacyProfileId) return {
|
|
572
|
+
config: params.cfg,
|
|
573
|
+
changes: [],
|
|
574
|
+
migrated: false
|
|
575
|
+
};
|
|
576
|
+
const toCred = params.store.profiles[toProfileId];
|
|
577
|
+
const toEmail = toCred?.type === "oauth" ? toCred.email?.trim() : void 0;
|
|
578
|
+
const nextProfiles = { ...params.cfg.auth?.profiles };
|
|
579
|
+
delete nextProfiles[legacyProfileId];
|
|
580
|
+
nextProfiles[toProfileId] = {
|
|
581
|
+
...legacyCfg,
|
|
582
|
+
...toEmail ? { email: toEmail } : {}
|
|
583
|
+
};
|
|
584
|
+
const providerKey = normalizeProviderId(params.provider);
|
|
585
|
+
const nextOrder = (() => {
|
|
586
|
+
const order = params.cfg.auth?.order;
|
|
587
|
+
if (!order) return;
|
|
588
|
+
const resolvedKey = Object.keys(order).find((key) => normalizeProviderId(key) === providerKey);
|
|
589
|
+
if (!resolvedKey) return order;
|
|
590
|
+
const existing = order[resolvedKey];
|
|
591
|
+
if (!Array.isArray(existing)) return order;
|
|
592
|
+
const replaced = existing.map((id) => id === legacyProfileId ? toProfileId : id).filter((id) => typeof id === "string" && id.trim().length > 0);
|
|
593
|
+
const deduped = [];
|
|
594
|
+
for (const entry of replaced) if (!deduped.includes(entry)) deduped.push(entry);
|
|
595
|
+
return {
|
|
596
|
+
...order,
|
|
597
|
+
[resolvedKey]: deduped
|
|
598
|
+
};
|
|
599
|
+
})();
|
|
600
|
+
return {
|
|
601
|
+
config: {
|
|
602
|
+
...params.cfg,
|
|
603
|
+
auth: {
|
|
604
|
+
...params.cfg.auth,
|
|
605
|
+
profiles: nextProfiles,
|
|
606
|
+
...nextOrder ? { order: nextOrder } : {}
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
changes: [`Auth: migrate ${legacyProfileId} → ${toProfileId} (OAuth profile id)`],
|
|
610
|
+
migrated: true,
|
|
611
|
+
fromProfileId: legacyProfileId,
|
|
612
|
+
toProfileId
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/agents/auth-profiles/doctor.ts
|
|
618
|
+
function formatAuthDoctorHint(params) {
|
|
619
|
+
const providerKey = normalizeProviderId(params.provider);
|
|
620
|
+
if (providerKey !== "anthropic") return "";
|
|
621
|
+
const legacyProfileId = params.profileId ?? "anthropic:default";
|
|
622
|
+
const suggested = suggestOAuthProfileIdForLegacyDefault({
|
|
623
|
+
cfg: params.cfg,
|
|
624
|
+
store: params.store,
|
|
625
|
+
provider: providerKey,
|
|
626
|
+
legacyProfileId
|
|
627
|
+
});
|
|
628
|
+
if (!suggested || suggested === legacyProfileId) return "";
|
|
629
|
+
const storeOauthProfiles = listProfilesForProvider(params.store, providerKey).filter((id) => params.store.profiles[id]?.type === "oauth").join(", ");
|
|
630
|
+
const cfgMode = params.cfg?.auth?.profiles?.[legacyProfileId]?.mode;
|
|
631
|
+
const cfgProvider = params.cfg?.auth?.profiles?.[legacyProfileId]?.provider;
|
|
632
|
+
return [
|
|
633
|
+
"Doctor hint (for GitHub issue):",
|
|
634
|
+
`- provider: ${providerKey}`,
|
|
635
|
+
`- config: ${legacyProfileId}${cfgProvider || cfgMode ? ` (provider=${cfgProvider ?? "?"}, mode=${cfgMode ?? "?"})` : ""}`,
|
|
636
|
+
`- auth store oauth profiles: ${storeOauthProfiles || "(none)"}`,
|
|
637
|
+
`- suggested profile: ${suggested}`,
|
|
638
|
+
`Fix: run "${formatCliCommand("openclaw doctor --yes")}"`
|
|
639
|
+
].join("\n");
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region src/providers/qwen-portal-oauth.ts
|
|
644
|
+
const QWEN_OAUTH_TOKEN_ENDPOINT = `https://chat.qwen.ai/api/v1/oauth2/token`;
|
|
645
|
+
const QWEN_OAUTH_CLIENT_ID = "f0304373b74a44d2b584a3fb70ca9e56";
|
|
646
|
+
async function refreshQwenPortalCredentials(credentials) {
|
|
647
|
+
if (!credentials.refresh?.trim()) throw new Error("Qwen OAuth refresh token missing; re-authenticate.");
|
|
648
|
+
const response = await fetch(QWEN_OAUTH_TOKEN_ENDPOINT, {
|
|
649
|
+
method: "POST",
|
|
650
|
+
headers: {
|
|
651
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
652
|
+
Accept: "application/json"
|
|
653
|
+
},
|
|
654
|
+
body: new URLSearchParams({
|
|
655
|
+
grant_type: "refresh_token",
|
|
656
|
+
refresh_token: credentials.refresh,
|
|
657
|
+
client_id: QWEN_OAUTH_CLIENT_ID
|
|
658
|
+
})
|
|
659
|
+
});
|
|
660
|
+
if (!response.ok) {
|
|
661
|
+
const text = await response.text();
|
|
662
|
+
if (response.status === 400) throw new Error(`Qwen OAuth refresh token expired or invalid. Re-authenticate with \`${formatCliCommand("openclaw models auth login --provider qwen-portal")}\`.`);
|
|
663
|
+
throw new Error(`Qwen OAuth refresh failed: ${text || response.statusText}`);
|
|
664
|
+
}
|
|
665
|
+
const payload = await response.json();
|
|
666
|
+
if (!payload.access_token || !payload.expires_in) throw new Error("Qwen OAuth refresh response missing access token.");
|
|
667
|
+
return {
|
|
668
|
+
...credentials,
|
|
669
|
+
access: payload.access_token,
|
|
670
|
+
refresh: payload.refresh_token || credentials.refresh,
|
|
671
|
+
expires: Date.now() + payload.expires_in * 1e3
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region src/agents/chutes-oauth.ts
|
|
677
|
+
const CHUTES_OAUTH_ISSUER = "https://api.chutes.ai";
|
|
678
|
+
const CHUTES_AUTHORIZE_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/authorize`;
|
|
679
|
+
const CHUTES_TOKEN_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/token`;
|
|
680
|
+
const CHUTES_USERINFO_ENDPOINT = `${CHUTES_OAUTH_ISSUER}/idp/userinfo`;
|
|
681
|
+
const DEFAULT_EXPIRES_BUFFER_MS = 300 * 1e3;
|
|
682
|
+
function generateChutesPkce() {
|
|
683
|
+
const verifier = randomBytes(32).toString("hex");
|
|
684
|
+
return {
|
|
685
|
+
verifier,
|
|
686
|
+
challenge: createHash("sha256").update(verifier).digest("base64url")
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function parseOAuthCallbackInput(input, expectedState) {
|
|
690
|
+
const trimmed = input.trim();
|
|
691
|
+
if (!trimmed) return { error: "No input provided" };
|
|
692
|
+
try {
|
|
693
|
+
const url = new URL(trimmed);
|
|
694
|
+
const code = url.searchParams.get("code");
|
|
695
|
+
const state = url.searchParams.get("state");
|
|
696
|
+
if (!code) return { error: "Missing 'code' parameter in URL" };
|
|
697
|
+
if (!state) return { error: "Missing 'state' parameter. Paste the full URL." };
|
|
698
|
+
return {
|
|
699
|
+
code,
|
|
700
|
+
state
|
|
701
|
+
};
|
|
702
|
+
} catch {
|
|
703
|
+
if (!expectedState) return { error: "Paste the full redirect URL, not just the code." };
|
|
704
|
+
return {
|
|
705
|
+
code: trimmed,
|
|
706
|
+
state: expectedState
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
function coerceExpiresAt(expiresInSeconds, now) {
|
|
711
|
+
const value = now + Math.max(0, Math.floor(expiresInSeconds)) * 1e3 - DEFAULT_EXPIRES_BUFFER_MS;
|
|
712
|
+
return Math.max(value, now + 3e4);
|
|
713
|
+
}
|
|
714
|
+
async function fetchChutesUserInfo(params) {
|
|
715
|
+
const response = await (params.fetchFn ?? fetch)(CHUTES_USERINFO_ENDPOINT, { headers: { Authorization: `Bearer ${params.accessToken}` } });
|
|
716
|
+
if (!response.ok) return null;
|
|
717
|
+
const data = await response.json();
|
|
718
|
+
if (!data || typeof data !== "object") return null;
|
|
719
|
+
return data;
|
|
720
|
+
}
|
|
721
|
+
async function exchangeChutesCodeForTokens(params) {
|
|
722
|
+
const fetchFn = params.fetchFn ?? fetch;
|
|
723
|
+
const now = params.now ?? Date.now();
|
|
724
|
+
const body = new URLSearchParams({
|
|
725
|
+
grant_type: "authorization_code",
|
|
726
|
+
client_id: params.app.clientId,
|
|
727
|
+
code: params.code,
|
|
728
|
+
redirect_uri: params.app.redirectUri,
|
|
729
|
+
code_verifier: params.codeVerifier
|
|
730
|
+
});
|
|
731
|
+
if (params.app.clientSecret) body.set("client_secret", params.app.clientSecret);
|
|
732
|
+
const response = await fetchFn(CHUTES_TOKEN_ENDPOINT, {
|
|
733
|
+
method: "POST",
|
|
734
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
735
|
+
body
|
|
736
|
+
});
|
|
737
|
+
if (!response.ok) {
|
|
738
|
+
const text = await response.text();
|
|
739
|
+
throw new Error(`Chutes token exchange failed: ${text}`);
|
|
740
|
+
}
|
|
741
|
+
const data = await response.json();
|
|
742
|
+
const access = data.access_token?.trim();
|
|
743
|
+
const refresh = data.refresh_token?.trim();
|
|
744
|
+
const expiresIn = data.expires_in ?? 0;
|
|
745
|
+
if (!access) throw new Error("Chutes token exchange returned no access_token");
|
|
746
|
+
if (!refresh) throw new Error("Chutes token exchange returned no refresh_token");
|
|
747
|
+
const info = await fetchChutesUserInfo({
|
|
748
|
+
accessToken: access,
|
|
749
|
+
fetchFn
|
|
750
|
+
});
|
|
751
|
+
return {
|
|
752
|
+
access,
|
|
753
|
+
refresh,
|
|
754
|
+
expires: coerceExpiresAt(expiresIn, now),
|
|
755
|
+
email: info?.username,
|
|
756
|
+
accountId: info?.sub,
|
|
757
|
+
clientId: params.app.clientId
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
async function refreshChutesTokens(params) {
|
|
761
|
+
const fetchFn = params.fetchFn ?? fetch;
|
|
762
|
+
const now = params.now ?? Date.now();
|
|
763
|
+
const refreshToken = params.credential.refresh?.trim();
|
|
764
|
+
if (!refreshToken) throw new Error("Chutes OAuth credential is missing refresh token");
|
|
765
|
+
const clientId = params.credential.clientId?.trim() ?? process.env.CHUTES_CLIENT_ID?.trim();
|
|
766
|
+
if (!clientId) throw new Error("Missing CHUTES_CLIENT_ID for Chutes OAuth refresh (set env var or re-auth).");
|
|
767
|
+
const clientSecret = process.env.CHUTES_CLIENT_SECRET?.trim() || void 0;
|
|
768
|
+
const body = new URLSearchParams({
|
|
769
|
+
grant_type: "refresh_token",
|
|
770
|
+
client_id: clientId,
|
|
771
|
+
refresh_token: refreshToken
|
|
772
|
+
});
|
|
773
|
+
if (clientSecret) body.set("client_secret", clientSecret);
|
|
774
|
+
const response = await fetchFn(CHUTES_TOKEN_ENDPOINT, {
|
|
775
|
+
method: "POST",
|
|
776
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
777
|
+
body
|
|
778
|
+
});
|
|
779
|
+
if (!response.ok) {
|
|
780
|
+
const text = await response.text();
|
|
781
|
+
throw new Error(`Chutes token refresh failed: ${text}`);
|
|
782
|
+
}
|
|
783
|
+
const data = await response.json();
|
|
784
|
+
const access = data.access_token?.trim();
|
|
785
|
+
const newRefresh = data.refresh_token?.trim();
|
|
786
|
+
const expiresIn = data.expires_in ?? 0;
|
|
787
|
+
if (!access) throw new Error("Chutes token refresh returned no access_token");
|
|
788
|
+
return {
|
|
789
|
+
...params.credential,
|
|
790
|
+
access,
|
|
791
|
+
refresh: newRefresh || refreshToken,
|
|
792
|
+
expires: coerceExpiresAt(expiresIn, now),
|
|
793
|
+
clientId
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
//#endregion
|
|
798
|
+
//#region src/agents/auth-profiles/oauth.ts
|
|
799
|
+
const OAUTH_PROVIDER_IDS = new Set(getOAuthProviders().map((provider) => provider.id));
|
|
800
|
+
const isOAuthProvider = (provider) => OAUTH_PROVIDER_IDS.has(provider);
|
|
801
|
+
const resolveOAuthProvider = (provider) => isOAuthProvider(provider) ? provider : null;
|
|
802
|
+
function buildOAuthApiKey(provider, credentials) {
|
|
803
|
+
return provider === "google-gemini-cli" || provider === "google-antigravity" ? JSON.stringify({
|
|
804
|
+
token: credentials.access,
|
|
805
|
+
projectId: credentials.projectId
|
|
806
|
+
}) : credentials.access;
|
|
807
|
+
}
|
|
808
|
+
async function refreshOAuthTokenWithLock(params) {
|
|
809
|
+
const authPath = resolveAuthStorePath(params.agentDir);
|
|
810
|
+
ensureAuthStoreFile(authPath);
|
|
811
|
+
let release;
|
|
812
|
+
try {
|
|
813
|
+
release = await lockfile.lock(authPath, { ...AUTH_STORE_LOCK_OPTIONS });
|
|
814
|
+
const store = ensureAuthProfileStore(params.agentDir);
|
|
815
|
+
const cred = store.profiles[params.profileId];
|
|
816
|
+
if (!cred || cred.type !== "oauth") return null;
|
|
817
|
+
if (Date.now() < cred.expires) return {
|
|
818
|
+
apiKey: buildOAuthApiKey(cred.provider, cred),
|
|
819
|
+
newCredentials: cred
|
|
820
|
+
};
|
|
821
|
+
const oauthCreds = { [cred.provider]: cred };
|
|
822
|
+
const result = String(cred.provider) === "chutes" ? await (async () => {
|
|
823
|
+
const newCredentials = await refreshChutesTokens({ credential: cred });
|
|
824
|
+
return {
|
|
825
|
+
apiKey: newCredentials.access,
|
|
826
|
+
newCredentials
|
|
827
|
+
};
|
|
828
|
+
})() : String(cred.provider) === "qwen-portal" ? await (async () => {
|
|
829
|
+
const newCredentials = await refreshQwenPortalCredentials(cred);
|
|
830
|
+
return {
|
|
831
|
+
apiKey: newCredentials.access,
|
|
832
|
+
newCredentials
|
|
833
|
+
};
|
|
834
|
+
})() : await (async () => {
|
|
835
|
+
const oauthProvider = resolveOAuthProvider(cred.provider);
|
|
836
|
+
if (!oauthProvider) return null;
|
|
837
|
+
return await getOAuthApiKey(oauthProvider, oauthCreds);
|
|
838
|
+
})();
|
|
839
|
+
if (!result) return null;
|
|
840
|
+
store.profiles[params.profileId] = {
|
|
841
|
+
...cred,
|
|
842
|
+
...result.newCredentials,
|
|
843
|
+
type: "oauth"
|
|
844
|
+
};
|
|
845
|
+
saveAuthProfileStore(store, params.agentDir);
|
|
846
|
+
return result;
|
|
847
|
+
} finally {
|
|
848
|
+
if (release) try {
|
|
849
|
+
await release();
|
|
850
|
+
} catch {}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
async function tryResolveOAuthProfile(params) {
|
|
854
|
+
const { cfg, store, profileId } = params;
|
|
855
|
+
const cred = store.profiles[profileId];
|
|
856
|
+
if (!cred || cred.type !== "oauth") return null;
|
|
857
|
+
const profileConfig = cfg?.auth?.profiles?.[profileId];
|
|
858
|
+
if (profileConfig && profileConfig.provider !== cred.provider) return null;
|
|
859
|
+
if (profileConfig && profileConfig.mode !== cred.type) return null;
|
|
860
|
+
if (Date.now() < cred.expires) return {
|
|
861
|
+
apiKey: buildOAuthApiKey(cred.provider, cred),
|
|
862
|
+
provider: cred.provider,
|
|
863
|
+
email: cred.email
|
|
864
|
+
};
|
|
865
|
+
const refreshed = await refreshOAuthTokenWithLock({
|
|
866
|
+
profileId,
|
|
867
|
+
agentDir: params.agentDir
|
|
868
|
+
});
|
|
869
|
+
if (!refreshed) return null;
|
|
870
|
+
return {
|
|
871
|
+
apiKey: refreshed.apiKey,
|
|
872
|
+
provider: cred.provider,
|
|
873
|
+
email: cred.email
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
async function resolveApiKeyForProfile(params) {
|
|
877
|
+
const { cfg, store, profileId } = params;
|
|
878
|
+
const cred = store.profiles[profileId];
|
|
879
|
+
if (!cred) return null;
|
|
880
|
+
const profileConfig = cfg?.auth?.profiles?.[profileId];
|
|
881
|
+
if (profileConfig && profileConfig.provider !== cred.provider) return null;
|
|
882
|
+
if (profileConfig && profileConfig.mode !== cred.type) {
|
|
883
|
+
if (!(profileConfig.mode === "oauth" && cred.type === "token")) return null;
|
|
884
|
+
}
|
|
885
|
+
if (cred.type === "api_key") {
|
|
886
|
+
const key = cred.key?.trim();
|
|
887
|
+
if (!key) return null;
|
|
888
|
+
return {
|
|
889
|
+
apiKey: key,
|
|
890
|
+
provider: cred.provider,
|
|
891
|
+
email: cred.email
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
if (cred.type === "token") {
|
|
895
|
+
const token = cred.token?.trim();
|
|
896
|
+
if (!token) return null;
|
|
897
|
+
if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && cred.expires > 0 && Date.now() >= cred.expires) return null;
|
|
898
|
+
return {
|
|
899
|
+
apiKey: token,
|
|
900
|
+
provider: cred.provider,
|
|
901
|
+
email: cred.email
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
if (Date.now() < cred.expires) return {
|
|
905
|
+
apiKey: buildOAuthApiKey(cred.provider, cred),
|
|
906
|
+
provider: cred.provider,
|
|
907
|
+
email: cred.email
|
|
908
|
+
};
|
|
909
|
+
try {
|
|
910
|
+
const result = await refreshOAuthTokenWithLock({
|
|
911
|
+
profileId,
|
|
912
|
+
agentDir: params.agentDir
|
|
913
|
+
});
|
|
914
|
+
if (!result) return null;
|
|
915
|
+
return {
|
|
916
|
+
apiKey: result.apiKey,
|
|
917
|
+
provider: cred.provider,
|
|
918
|
+
email: cred.email
|
|
919
|
+
};
|
|
920
|
+
} catch (error) {
|
|
921
|
+
const refreshedStore = ensureAuthProfileStore(params.agentDir);
|
|
922
|
+
const refreshed = refreshedStore.profiles[profileId];
|
|
923
|
+
if (refreshed?.type === "oauth" && Date.now() < refreshed.expires) return {
|
|
924
|
+
apiKey: buildOAuthApiKey(refreshed.provider, refreshed),
|
|
925
|
+
provider: refreshed.provider,
|
|
926
|
+
email: refreshed.email ?? cred.email
|
|
927
|
+
};
|
|
928
|
+
const fallbackProfileId = suggestOAuthProfileIdForLegacyDefault({
|
|
929
|
+
cfg,
|
|
930
|
+
store: refreshedStore,
|
|
931
|
+
provider: cred.provider,
|
|
932
|
+
legacyProfileId: profileId
|
|
933
|
+
});
|
|
934
|
+
if (fallbackProfileId && fallbackProfileId !== profileId) try {
|
|
935
|
+
const fallbackResolved = await tryResolveOAuthProfile({
|
|
936
|
+
cfg,
|
|
937
|
+
store: refreshedStore,
|
|
938
|
+
profileId: fallbackProfileId,
|
|
939
|
+
agentDir: params.agentDir
|
|
940
|
+
});
|
|
941
|
+
if (fallbackResolved) return fallbackResolved;
|
|
942
|
+
} catch {}
|
|
943
|
+
if (params.agentDir) try {
|
|
944
|
+
const mainCred = ensureAuthProfileStore(void 0).profiles[profileId];
|
|
945
|
+
if (mainCred?.type === "oauth" && Date.now() < mainCred.expires) {
|
|
946
|
+
refreshedStore.profiles[profileId] = { ...mainCred };
|
|
947
|
+
saveAuthProfileStore(refreshedStore, params.agentDir);
|
|
948
|
+
log$1.info("inherited fresh OAuth credentials from main agent", {
|
|
949
|
+
profileId,
|
|
950
|
+
agentDir: params.agentDir,
|
|
951
|
+
expires: new Date(mainCred.expires).toISOString()
|
|
952
|
+
});
|
|
953
|
+
return {
|
|
954
|
+
apiKey: buildOAuthApiKey(mainCred.provider, mainCred),
|
|
955
|
+
provider: mainCred.provider,
|
|
956
|
+
email: mainCred.email
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
} catch {}
|
|
960
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
961
|
+
const hint = formatAuthDoctorHint({
|
|
962
|
+
cfg,
|
|
963
|
+
store: refreshedStore,
|
|
964
|
+
provider: cred.provider,
|
|
965
|
+
profileId
|
|
966
|
+
});
|
|
967
|
+
throw new Error(`OAuth token refresh failed for ${cred.provider}: ${message}. Please try again or re-authenticate.` + (hint ? `\n\n${hint}` : ""), { cause: error });
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/agents/auth-profiles/usage.ts
|
|
973
|
+
function resolveProfileUnusableUntil$1(stats) {
|
|
974
|
+
const values = [stats.cooldownUntil, stats.disabledUntil].filter((value) => typeof value === "number").filter((value) => Number.isFinite(value) && value > 0);
|
|
975
|
+
if (values.length === 0) return null;
|
|
976
|
+
return Math.max(...values);
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Check if a profile is currently in cooldown (due to rate limiting or errors).
|
|
980
|
+
*/
|
|
981
|
+
function isProfileInCooldown(store, profileId) {
|
|
982
|
+
const stats = store.usageStats?.[profileId];
|
|
983
|
+
if (!stats) return false;
|
|
984
|
+
const unusableUntil = resolveProfileUnusableUntil$1(stats);
|
|
985
|
+
return unusableUntil ? Date.now() < unusableUntil : false;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Mark a profile as successfully used. Resets error count and updates lastUsed.
|
|
989
|
+
* Uses store lock to avoid overwriting concurrent usage updates.
|
|
990
|
+
*/
|
|
991
|
+
async function markAuthProfileUsed(params) {
|
|
992
|
+
const { store, profileId, agentDir } = params;
|
|
993
|
+
const updated = await updateAuthProfileStoreWithLock({
|
|
994
|
+
agentDir,
|
|
995
|
+
updater: (freshStore) => {
|
|
996
|
+
if (!freshStore.profiles[profileId]) return false;
|
|
997
|
+
freshStore.usageStats = freshStore.usageStats ?? {};
|
|
998
|
+
freshStore.usageStats[profileId] = {
|
|
999
|
+
...freshStore.usageStats[profileId],
|
|
1000
|
+
lastUsed: Date.now(),
|
|
1001
|
+
errorCount: 0,
|
|
1002
|
+
cooldownUntil: void 0,
|
|
1003
|
+
disabledUntil: void 0,
|
|
1004
|
+
disabledReason: void 0,
|
|
1005
|
+
failureCounts: void 0
|
|
1006
|
+
};
|
|
1007
|
+
return true;
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
if (updated) {
|
|
1011
|
+
store.usageStats = updated.usageStats;
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (!store.profiles[profileId]) return;
|
|
1015
|
+
store.usageStats = store.usageStats ?? {};
|
|
1016
|
+
store.usageStats[profileId] = {
|
|
1017
|
+
...store.usageStats[profileId],
|
|
1018
|
+
lastUsed: Date.now(),
|
|
1019
|
+
errorCount: 0,
|
|
1020
|
+
cooldownUntil: void 0,
|
|
1021
|
+
disabledUntil: void 0,
|
|
1022
|
+
disabledReason: void 0,
|
|
1023
|
+
failureCounts: void 0
|
|
1024
|
+
};
|
|
1025
|
+
saveAuthProfileStore(store, agentDir);
|
|
1026
|
+
}
|
|
1027
|
+
function calculateAuthProfileCooldownMs(errorCount) {
|
|
1028
|
+
const normalized = Math.max(1, errorCount);
|
|
1029
|
+
return Math.min(3600 * 1e3, 60 * 1e3 * 5 ** Math.min(normalized - 1, 3));
|
|
1030
|
+
}
|
|
1031
|
+
function resolveAuthCooldownConfig(params) {
|
|
1032
|
+
const defaults = {
|
|
1033
|
+
billingBackoffHours: 5,
|
|
1034
|
+
billingMaxHours: 24,
|
|
1035
|
+
failureWindowHours: 24
|
|
1036
|
+
};
|
|
1037
|
+
const resolveHours = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
1038
|
+
const cooldowns = params.cfg?.auth?.cooldowns;
|
|
1039
|
+
const billingBackoffHours = resolveHours((() => {
|
|
1040
|
+
const map = cooldowns?.billingBackoffHoursByProvider;
|
|
1041
|
+
if (!map) return;
|
|
1042
|
+
for (const [key, value] of Object.entries(map)) if (normalizeProviderId(key) === params.providerId) return value;
|
|
1043
|
+
})() ?? cooldowns?.billingBackoffHours, defaults.billingBackoffHours);
|
|
1044
|
+
const billingMaxHours = resolveHours(cooldowns?.billingMaxHours, defaults.billingMaxHours);
|
|
1045
|
+
const failureWindowHours = resolveHours(cooldowns?.failureWindowHours, defaults.failureWindowHours);
|
|
1046
|
+
return {
|
|
1047
|
+
billingBackoffMs: billingBackoffHours * 60 * 60 * 1e3,
|
|
1048
|
+
billingMaxMs: billingMaxHours * 60 * 60 * 1e3,
|
|
1049
|
+
failureWindowMs: failureWindowHours * 60 * 60 * 1e3
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
function calculateAuthProfileBillingDisableMsWithConfig(params) {
|
|
1053
|
+
const normalized = Math.max(1, params.errorCount);
|
|
1054
|
+
const baseMs = Math.max(6e4, params.baseMs);
|
|
1055
|
+
const maxMs = Math.max(baseMs, params.maxMs);
|
|
1056
|
+
const raw = baseMs * 2 ** Math.min(normalized - 1, 10);
|
|
1057
|
+
return Math.min(maxMs, raw);
|
|
1058
|
+
}
|
|
1059
|
+
function resolveProfileUnusableUntilForDisplay(store, profileId) {
|
|
1060
|
+
const stats = store.usageStats?.[profileId];
|
|
1061
|
+
if (!stats) return null;
|
|
1062
|
+
return resolveProfileUnusableUntil$1(stats);
|
|
1063
|
+
}
|
|
1064
|
+
function computeNextProfileUsageStats(params) {
|
|
1065
|
+
const windowMs = params.cfgResolved.failureWindowMs;
|
|
1066
|
+
const windowExpired = typeof params.existing.lastFailureAt === "number" && params.existing.lastFailureAt > 0 && params.now - params.existing.lastFailureAt > windowMs;
|
|
1067
|
+
const nextErrorCount = (windowExpired ? 0 : params.existing.errorCount ?? 0) + 1;
|
|
1068
|
+
const failureCounts = windowExpired ? {} : { ...params.existing.failureCounts };
|
|
1069
|
+
failureCounts[params.reason] = (failureCounts[params.reason] ?? 0) + 1;
|
|
1070
|
+
const updatedStats = {
|
|
1071
|
+
...params.existing,
|
|
1072
|
+
errorCount: nextErrorCount,
|
|
1073
|
+
failureCounts,
|
|
1074
|
+
lastFailureAt: params.now
|
|
1075
|
+
};
|
|
1076
|
+
if (params.reason === "billing") {
|
|
1077
|
+
const backoffMs = calculateAuthProfileBillingDisableMsWithConfig({
|
|
1078
|
+
errorCount: failureCounts.billing ?? 1,
|
|
1079
|
+
baseMs: params.cfgResolved.billingBackoffMs,
|
|
1080
|
+
maxMs: params.cfgResolved.billingMaxMs
|
|
1081
|
+
});
|
|
1082
|
+
updatedStats.disabledUntil = params.now + backoffMs;
|
|
1083
|
+
updatedStats.disabledReason = "billing";
|
|
1084
|
+
} else {
|
|
1085
|
+
const backoffMs = calculateAuthProfileCooldownMs(nextErrorCount);
|
|
1086
|
+
updatedStats.cooldownUntil = params.now + backoffMs;
|
|
1087
|
+
}
|
|
1088
|
+
return updatedStats;
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Mark a profile as failed for a specific reason. Billing failures are treated
|
|
1092
|
+
* as "disabled" (longer backoff) vs the regular cooldown window.
|
|
1093
|
+
*/
|
|
1094
|
+
async function markAuthProfileFailure(params) {
|
|
1095
|
+
const { store, profileId, reason, agentDir, cfg } = params;
|
|
1096
|
+
const updated = await updateAuthProfileStoreWithLock({
|
|
1097
|
+
agentDir,
|
|
1098
|
+
updater: (freshStore) => {
|
|
1099
|
+
const profile = freshStore.profiles[profileId];
|
|
1100
|
+
if (!profile) return false;
|
|
1101
|
+
freshStore.usageStats = freshStore.usageStats ?? {};
|
|
1102
|
+
const existing = freshStore.usageStats[profileId] ?? {};
|
|
1103
|
+
const now = Date.now();
|
|
1104
|
+
const cfgResolved = resolveAuthCooldownConfig({
|
|
1105
|
+
cfg,
|
|
1106
|
+
providerId: normalizeProviderId(profile.provider)
|
|
1107
|
+
});
|
|
1108
|
+
freshStore.usageStats[profileId] = computeNextProfileUsageStats({
|
|
1109
|
+
existing,
|
|
1110
|
+
now,
|
|
1111
|
+
reason,
|
|
1112
|
+
cfgResolved
|
|
1113
|
+
});
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
if (updated) {
|
|
1118
|
+
store.usageStats = updated.usageStats;
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
if (!store.profiles[profileId]) return;
|
|
1122
|
+
store.usageStats = store.usageStats ?? {};
|
|
1123
|
+
const existing = store.usageStats[profileId] ?? {};
|
|
1124
|
+
const now = Date.now();
|
|
1125
|
+
const cfgResolved = resolveAuthCooldownConfig({
|
|
1126
|
+
cfg,
|
|
1127
|
+
providerId: normalizeProviderId(store.profiles[profileId]?.provider ?? "")
|
|
1128
|
+
});
|
|
1129
|
+
store.usageStats[profileId] = computeNextProfileUsageStats({
|
|
1130
|
+
existing,
|
|
1131
|
+
now,
|
|
1132
|
+
reason,
|
|
1133
|
+
cfgResolved
|
|
1134
|
+
});
|
|
1135
|
+
saveAuthProfileStore(store, agentDir);
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region src/agents/auth-profiles/order.ts
|
|
1140
|
+
function resolveProfileUnusableUntil(stats) {
|
|
1141
|
+
const values = [stats.cooldownUntil, stats.disabledUntil].filter((value) => typeof value === "number").filter((value) => Number.isFinite(value) && value > 0);
|
|
1142
|
+
if (values.length === 0) return null;
|
|
1143
|
+
return Math.max(...values);
|
|
1144
|
+
}
|
|
1145
|
+
function resolveAuthProfileOrder(params) {
|
|
1146
|
+
const { cfg, store, provider, preferredProfile } = params;
|
|
1147
|
+
const providerKey = normalizeProviderId(provider);
|
|
1148
|
+
const now = Date.now();
|
|
1149
|
+
const storedOrder = (() => {
|
|
1150
|
+
const order = store.order;
|
|
1151
|
+
if (!order) return;
|
|
1152
|
+
for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
|
|
1153
|
+
})();
|
|
1154
|
+
const configuredOrder = (() => {
|
|
1155
|
+
const order = cfg?.auth?.order;
|
|
1156
|
+
if (!order) return;
|
|
1157
|
+
for (const [key, value] of Object.entries(order)) if (normalizeProviderId(key) === providerKey) return value;
|
|
1158
|
+
})();
|
|
1159
|
+
const explicitOrder = storedOrder ?? configuredOrder;
|
|
1160
|
+
const explicitProfiles = cfg?.auth?.profiles ? Object.entries(cfg.auth.profiles).filter(([, profile]) => normalizeProviderId(profile.provider) === providerKey).map(([profileId]) => profileId) : [];
|
|
1161
|
+
const baseOrder = explicitOrder ?? (explicitProfiles.length > 0 ? explicitProfiles : listProfilesForProvider(store, providerKey));
|
|
1162
|
+
if (baseOrder.length === 0) return [];
|
|
1163
|
+
const filtered = baseOrder.filter((profileId) => {
|
|
1164
|
+
const cred = store.profiles[profileId];
|
|
1165
|
+
if (!cred) return false;
|
|
1166
|
+
if (normalizeProviderId(cred.provider) !== providerKey) return false;
|
|
1167
|
+
const profileConfig = cfg?.auth?.profiles?.[profileId];
|
|
1168
|
+
if (profileConfig) {
|
|
1169
|
+
if (normalizeProviderId(profileConfig.provider) !== providerKey) return false;
|
|
1170
|
+
if (profileConfig.mode !== cred.type) {
|
|
1171
|
+
if (!(profileConfig.mode === "oauth" && cred.type === "token")) return false;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
if (cred.type === "api_key") return Boolean(cred.key?.trim());
|
|
1175
|
+
if (cred.type === "token") {
|
|
1176
|
+
if (!cred.token?.trim()) return false;
|
|
1177
|
+
if (typeof cred.expires === "number" && Number.isFinite(cred.expires) && cred.expires > 0 && now >= cred.expires) return false;
|
|
1178
|
+
return true;
|
|
1179
|
+
}
|
|
1180
|
+
if (cred.type === "oauth") return Boolean(cred.access?.trim() || cred.refresh?.trim());
|
|
1181
|
+
return false;
|
|
1182
|
+
});
|
|
1183
|
+
const deduped = [];
|
|
1184
|
+
for (const entry of filtered) if (!deduped.includes(entry)) deduped.push(entry);
|
|
1185
|
+
if (explicitOrder && explicitOrder.length > 0) {
|
|
1186
|
+
const available = [];
|
|
1187
|
+
const inCooldown = [];
|
|
1188
|
+
for (const profileId of deduped) {
|
|
1189
|
+
const cooldownUntil = resolveProfileUnusableUntil(store.usageStats?.[profileId] ?? {}) ?? 0;
|
|
1190
|
+
if (typeof cooldownUntil === "number" && Number.isFinite(cooldownUntil) && cooldownUntil > 0 && now < cooldownUntil) inCooldown.push({
|
|
1191
|
+
profileId,
|
|
1192
|
+
cooldownUntil
|
|
1193
|
+
});
|
|
1194
|
+
else available.push(profileId);
|
|
1195
|
+
}
|
|
1196
|
+
const cooldownSorted = inCooldown.toSorted((a, b) => a.cooldownUntil - b.cooldownUntil).map((entry) => entry.profileId);
|
|
1197
|
+
const ordered = [...available, ...cooldownSorted];
|
|
1198
|
+
if (preferredProfile && ordered.includes(preferredProfile)) return [preferredProfile, ...ordered.filter((e) => e !== preferredProfile)];
|
|
1199
|
+
return ordered;
|
|
1200
|
+
}
|
|
1201
|
+
const sorted = orderProfilesByMode(deduped, store);
|
|
1202
|
+
if (preferredProfile && sorted.includes(preferredProfile)) return [preferredProfile, ...sorted.filter((e) => e !== preferredProfile)];
|
|
1203
|
+
return sorted;
|
|
1204
|
+
}
|
|
1205
|
+
function orderProfilesByMode(order, store) {
|
|
1206
|
+
const now = Date.now();
|
|
1207
|
+
const available = [];
|
|
1208
|
+
const inCooldown = [];
|
|
1209
|
+
for (const profileId of order) if (isProfileInCooldown(store, profileId)) inCooldown.push(profileId);
|
|
1210
|
+
else available.push(profileId);
|
|
1211
|
+
const sorted = available.map((profileId) => {
|
|
1212
|
+
const type = store.profiles[profileId]?.type;
|
|
1213
|
+
return {
|
|
1214
|
+
profileId,
|
|
1215
|
+
typeScore: type === "oauth" ? 0 : type === "token" ? 1 : type === "api_key" ? 2 : 3,
|
|
1216
|
+
lastUsed: store.usageStats?.[profileId]?.lastUsed ?? 0
|
|
1217
|
+
};
|
|
1218
|
+
}).toSorted((a, b) => {
|
|
1219
|
+
if (a.typeScore !== b.typeScore) return a.typeScore - b.typeScore;
|
|
1220
|
+
return a.lastUsed - b.lastUsed;
|
|
1221
|
+
}).map((entry) => entry.profileId);
|
|
1222
|
+
const cooldownSorted = inCooldown.map((profileId) => ({
|
|
1223
|
+
profileId,
|
|
1224
|
+
cooldownUntil: resolveProfileUnusableUntil(store.usageStats?.[profileId] ?? {}) ?? now
|
|
1225
|
+
})).toSorted((a, b) => a.cooldownUntil - b.cooldownUntil).map((entry) => entry.profileId);
|
|
1226
|
+
return [...sorted, ...cooldownSorted];
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
//#endregion
|
|
1230
|
+
//#region src/agents/auth-profiles.ts
|
|
1231
|
+
var auth_profiles_exports = /* @__PURE__ */ __exportAll({ ensureAuthProfileStore: () => ensureAuthProfileStore });
|
|
1232
|
+
|
|
1233
|
+
//#endregion
|
|
1234
|
+
//#region src/agents/bedrock-discovery.ts
|
|
1235
|
+
const DEFAULT_REFRESH_INTERVAL_SECONDS = 3600;
|
|
1236
|
+
const DEFAULT_CONTEXT_WINDOW = 32e3;
|
|
1237
|
+
const DEFAULT_MAX_TOKENS = 4096;
|
|
1238
|
+
const DEFAULT_COST = {
|
|
1239
|
+
input: 0,
|
|
1240
|
+
output: 0,
|
|
1241
|
+
cacheRead: 0,
|
|
1242
|
+
cacheWrite: 0
|
|
1243
|
+
};
|
|
1244
|
+
const discoveryCache = /* @__PURE__ */ new Map();
|
|
1245
|
+
let hasLoggedBedrockError = false;
|
|
1246
|
+
function normalizeProviderFilter(filter) {
|
|
1247
|
+
if (!filter || filter.length === 0) return [];
|
|
1248
|
+
const normalized = new Set(filter.map((entry) => entry.trim().toLowerCase()).filter((entry) => entry.length > 0));
|
|
1249
|
+
return Array.from(normalized).toSorted();
|
|
1250
|
+
}
|
|
1251
|
+
function buildCacheKey(params) {
|
|
1252
|
+
return JSON.stringify(params);
|
|
1253
|
+
}
|
|
1254
|
+
function includesTextModalities(modalities) {
|
|
1255
|
+
return (modalities ?? []).some((entry) => entry.toLowerCase() === "text");
|
|
1256
|
+
}
|
|
1257
|
+
function isActive(summary) {
|
|
1258
|
+
const status = summary.modelLifecycle?.status;
|
|
1259
|
+
return typeof status === "string" ? status.toUpperCase() === "ACTIVE" : false;
|
|
1260
|
+
}
|
|
1261
|
+
function mapInputModalities(summary) {
|
|
1262
|
+
const inputs = summary.inputModalities ?? [];
|
|
1263
|
+
const mapped = /* @__PURE__ */ new Set();
|
|
1264
|
+
for (const modality of inputs) {
|
|
1265
|
+
const lower = modality.toLowerCase();
|
|
1266
|
+
if (lower === "text") mapped.add("text");
|
|
1267
|
+
if (lower === "image") mapped.add("image");
|
|
1268
|
+
}
|
|
1269
|
+
if (mapped.size === 0) mapped.add("text");
|
|
1270
|
+
return Array.from(mapped);
|
|
1271
|
+
}
|
|
1272
|
+
function inferReasoningSupport(summary) {
|
|
1273
|
+
const haystack = `${summary.modelId ?? ""} ${summary.modelName ?? ""}`.toLowerCase();
|
|
1274
|
+
return haystack.includes("reasoning") || haystack.includes("thinking");
|
|
1275
|
+
}
|
|
1276
|
+
function resolveDefaultContextWindow(config) {
|
|
1277
|
+
const value = Math.floor(config?.defaultContextWindow ?? DEFAULT_CONTEXT_WINDOW);
|
|
1278
|
+
return value > 0 ? value : DEFAULT_CONTEXT_WINDOW;
|
|
1279
|
+
}
|
|
1280
|
+
function resolveDefaultMaxTokens(config) {
|
|
1281
|
+
const value = Math.floor(config?.defaultMaxTokens ?? DEFAULT_MAX_TOKENS);
|
|
1282
|
+
return value > 0 ? value : DEFAULT_MAX_TOKENS;
|
|
1283
|
+
}
|
|
1284
|
+
function matchesProviderFilter(summary, filter) {
|
|
1285
|
+
if (filter.length === 0) return true;
|
|
1286
|
+
const normalized = (summary.providerName ?? (typeof summary.modelId === "string" ? summary.modelId.split(".")[0] : void 0))?.trim().toLowerCase();
|
|
1287
|
+
if (!normalized) return false;
|
|
1288
|
+
return filter.includes(normalized);
|
|
1289
|
+
}
|
|
1290
|
+
function shouldIncludeSummary(summary, filter) {
|
|
1291
|
+
if (!summary.modelId?.trim()) return false;
|
|
1292
|
+
if (!matchesProviderFilter(summary, filter)) return false;
|
|
1293
|
+
if (summary.responseStreamingSupported !== true) return false;
|
|
1294
|
+
if (!includesTextModalities(summary.outputModalities)) return false;
|
|
1295
|
+
if (!isActive(summary)) return false;
|
|
1296
|
+
return true;
|
|
1297
|
+
}
|
|
1298
|
+
function toModelDefinition(summary, defaults) {
|
|
1299
|
+
const id = summary.modelId?.trim() ?? "";
|
|
1300
|
+
return {
|
|
1301
|
+
id,
|
|
1302
|
+
name: summary.modelName?.trim() || id,
|
|
1303
|
+
reasoning: inferReasoningSupport(summary),
|
|
1304
|
+
input: mapInputModalities(summary),
|
|
1305
|
+
cost: DEFAULT_COST,
|
|
1306
|
+
contextWindow: defaults.contextWindow,
|
|
1307
|
+
maxTokens: defaults.maxTokens
|
|
1308
|
+
};
|
|
1309
|
+
}
|
|
1310
|
+
async function discoverBedrockModels(params) {
|
|
1311
|
+
const refreshIntervalSeconds = Math.max(0, Math.floor(params.config?.refreshInterval ?? DEFAULT_REFRESH_INTERVAL_SECONDS));
|
|
1312
|
+
const providerFilter = normalizeProviderFilter(params.config?.providerFilter);
|
|
1313
|
+
const defaultContextWindow = resolveDefaultContextWindow(params.config);
|
|
1314
|
+
const defaultMaxTokens = resolveDefaultMaxTokens(params.config);
|
|
1315
|
+
const cacheKey = buildCacheKey({
|
|
1316
|
+
region: params.region,
|
|
1317
|
+
providerFilter,
|
|
1318
|
+
refreshIntervalSeconds,
|
|
1319
|
+
defaultContextWindow,
|
|
1320
|
+
defaultMaxTokens
|
|
1321
|
+
});
|
|
1322
|
+
const now = params.now?.() ?? Date.now();
|
|
1323
|
+
if (refreshIntervalSeconds > 0) {
|
|
1324
|
+
const cached = discoveryCache.get(cacheKey);
|
|
1325
|
+
if (cached?.value && cached.expiresAt > now) return cached.value;
|
|
1326
|
+
if (cached?.inFlight) return cached.inFlight;
|
|
1327
|
+
}
|
|
1328
|
+
const client = (params.clientFactory ?? ((region) => new BedrockClient({ region })))(params.region);
|
|
1329
|
+
const discoveryPromise = (async () => {
|
|
1330
|
+
const response = await client.send(new ListFoundationModelsCommand({}));
|
|
1331
|
+
const discovered = [];
|
|
1332
|
+
for (const summary of response.modelSummaries ?? []) {
|
|
1333
|
+
if (!shouldIncludeSummary(summary, providerFilter)) continue;
|
|
1334
|
+
discovered.push(toModelDefinition(summary, {
|
|
1335
|
+
contextWindow: defaultContextWindow,
|
|
1336
|
+
maxTokens: defaultMaxTokens
|
|
1337
|
+
}));
|
|
1338
|
+
}
|
|
1339
|
+
return discovered.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
1340
|
+
})();
|
|
1341
|
+
if (refreshIntervalSeconds > 0) discoveryCache.set(cacheKey, {
|
|
1342
|
+
expiresAt: now + refreshIntervalSeconds * 1e3,
|
|
1343
|
+
inFlight: discoveryPromise
|
|
1344
|
+
});
|
|
1345
|
+
try {
|
|
1346
|
+
const value = await discoveryPromise;
|
|
1347
|
+
if (refreshIntervalSeconds > 0) discoveryCache.set(cacheKey, {
|
|
1348
|
+
expiresAt: now + refreshIntervalSeconds * 1e3,
|
|
1349
|
+
value
|
|
1350
|
+
});
|
|
1351
|
+
return value;
|
|
1352
|
+
} catch (error) {
|
|
1353
|
+
if (refreshIntervalSeconds > 0) discoveryCache.delete(cacheKey);
|
|
1354
|
+
if (!hasLoggedBedrockError) {
|
|
1355
|
+
hasLoggedBedrockError = true;
|
|
1356
|
+
console.warn(`[bedrock-discovery] Failed to list models: ${String(error)}`);
|
|
1357
|
+
}
|
|
1358
|
+
return [];
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
//#endregion
|
|
1363
|
+
//#region src/agents/cloudflare-ai-gateway.ts
|
|
1364
|
+
const CLOUDFLARE_AI_GATEWAY_PROVIDER_ID = "cloudflare-ai-gateway";
|
|
1365
|
+
const CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID = "claude-sonnet-4-5";
|
|
1366
|
+
const CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF = `${CLOUDFLARE_AI_GATEWAY_PROVIDER_ID}/${CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID}`;
|
|
1367
|
+
const CLOUDFLARE_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
1368
|
+
const CLOUDFLARE_AI_GATEWAY_DEFAULT_MAX_TOKENS = 64e3;
|
|
1369
|
+
const CLOUDFLARE_AI_GATEWAY_DEFAULT_COST = {
|
|
1370
|
+
input: 3,
|
|
1371
|
+
output: 15,
|
|
1372
|
+
cacheRead: .3,
|
|
1373
|
+
cacheWrite: 3.75
|
|
1374
|
+
};
|
|
1375
|
+
function buildCloudflareAiGatewayModelDefinition(params) {
|
|
1376
|
+
return {
|
|
1377
|
+
id: params?.id?.trim() || CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_ID,
|
|
1378
|
+
name: params?.name ?? "Claude Sonnet 4.5",
|
|
1379
|
+
reasoning: params?.reasoning ?? true,
|
|
1380
|
+
input: params?.input ?? ["text", "image"],
|
|
1381
|
+
cost: CLOUDFLARE_AI_GATEWAY_DEFAULT_COST,
|
|
1382
|
+
contextWindow: CLOUDFLARE_AI_GATEWAY_DEFAULT_CONTEXT_WINDOW,
|
|
1383
|
+
maxTokens: CLOUDFLARE_AI_GATEWAY_DEFAULT_MAX_TOKENS
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function resolveCloudflareAiGatewayBaseUrl(params) {
|
|
1387
|
+
const accountId = params.accountId.trim();
|
|
1388
|
+
const gatewayId = params.gatewayId.trim();
|
|
1389
|
+
if (!accountId || !gatewayId) return "";
|
|
1390
|
+
return `https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/anthropic`;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
//#endregion
|
|
1394
|
+
//#region src/infra/shell-env.ts
|
|
1395
|
+
const DEFAULT_TIMEOUT_MS = 15e3;
|
|
1396
|
+
const DEFAULT_MAX_BUFFER_BYTES = 2 * 1024 * 1024;
|
|
1397
|
+
let lastAppliedKeys = [];
|
|
1398
|
+
let cachedShellPath;
|
|
1399
|
+
function resolveShell(env) {
|
|
1400
|
+
const shell = env.SHELL?.trim();
|
|
1401
|
+
return shell && shell.length > 0 ? shell : "/bin/sh";
|
|
1402
|
+
}
|
|
1403
|
+
function parseShellEnv(stdout) {
|
|
1404
|
+
const shellEnv = /* @__PURE__ */ new Map();
|
|
1405
|
+
const parts = stdout.toString("utf8").split("\0");
|
|
1406
|
+
for (const part of parts) {
|
|
1407
|
+
if (!part) continue;
|
|
1408
|
+
const eq = part.indexOf("=");
|
|
1409
|
+
if (eq <= 0) continue;
|
|
1410
|
+
const key = part.slice(0, eq);
|
|
1411
|
+
const value = part.slice(eq + 1);
|
|
1412
|
+
if (!key) continue;
|
|
1413
|
+
shellEnv.set(key, value);
|
|
1414
|
+
}
|
|
1415
|
+
return shellEnv;
|
|
1416
|
+
}
|
|
1417
|
+
function loadShellEnvFallback(opts) {
|
|
1418
|
+
const logger = opts.logger ?? console;
|
|
1419
|
+
const exec = opts.exec ?? execFileSync;
|
|
1420
|
+
if (!opts.enabled) {
|
|
1421
|
+
lastAppliedKeys = [];
|
|
1422
|
+
return {
|
|
1423
|
+
ok: true,
|
|
1424
|
+
applied: [],
|
|
1425
|
+
skippedReason: "disabled"
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
if (opts.expectedKeys.some((key) => Boolean(opts.env[key]?.trim()))) {
|
|
1429
|
+
lastAppliedKeys = [];
|
|
1430
|
+
return {
|
|
1431
|
+
ok: true,
|
|
1432
|
+
applied: [],
|
|
1433
|
+
skippedReason: "already-has-keys"
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
const timeoutMs = typeof opts.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) ? Math.max(0, opts.timeoutMs) : DEFAULT_TIMEOUT_MS;
|
|
1437
|
+
const shell = resolveShell(opts.env);
|
|
1438
|
+
let stdout;
|
|
1439
|
+
try {
|
|
1440
|
+
stdout = exec(shell, [
|
|
1441
|
+
"-l",
|
|
1442
|
+
"-c",
|
|
1443
|
+
"env -0"
|
|
1444
|
+
], {
|
|
1445
|
+
encoding: "buffer",
|
|
1446
|
+
timeout: timeoutMs,
|
|
1447
|
+
maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
|
|
1448
|
+
env: opts.env,
|
|
1449
|
+
stdio: [
|
|
1450
|
+
"ignore",
|
|
1451
|
+
"pipe",
|
|
1452
|
+
"pipe"
|
|
1453
|
+
]
|
|
1454
|
+
});
|
|
1455
|
+
} catch (err) {
|
|
1456
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1457
|
+
logger.warn(`[openclaw] shell env fallback failed: ${msg}`);
|
|
1458
|
+
lastAppliedKeys = [];
|
|
1459
|
+
return {
|
|
1460
|
+
ok: false,
|
|
1461
|
+
error: msg,
|
|
1462
|
+
applied: []
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
const shellEnv = parseShellEnv(stdout);
|
|
1466
|
+
const applied = [];
|
|
1467
|
+
for (const key of opts.expectedKeys) {
|
|
1468
|
+
if (opts.env[key]?.trim()) continue;
|
|
1469
|
+
const value = shellEnv.get(key);
|
|
1470
|
+
if (!value?.trim()) continue;
|
|
1471
|
+
opts.env[key] = value;
|
|
1472
|
+
applied.push(key);
|
|
1473
|
+
}
|
|
1474
|
+
lastAppliedKeys = applied;
|
|
1475
|
+
return {
|
|
1476
|
+
ok: true,
|
|
1477
|
+
applied
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
function shouldEnableShellEnvFallback(env) {
|
|
1481
|
+
return isTruthyEnvValue(env.OPENCLAW_LOAD_SHELL_ENV);
|
|
1482
|
+
}
|
|
1483
|
+
function shouldDeferShellEnvFallback(env) {
|
|
1484
|
+
return isTruthyEnvValue(env.OPENCLAW_DEFER_SHELL_ENV_FALLBACK);
|
|
1485
|
+
}
|
|
1486
|
+
function resolveShellEnvFallbackTimeoutMs(env) {
|
|
1487
|
+
const raw = env.OPENCLAW_SHELL_ENV_TIMEOUT_MS?.trim();
|
|
1488
|
+
if (!raw) return DEFAULT_TIMEOUT_MS;
|
|
1489
|
+
const parsed = Number.parseInt(raw, 10);
|
|
1490
|
+
if (!Number.isFinite(parsed)) return DEFAULT_TIMEOUT_MS;
|
|
1491
|
+
return Math.max(0, parsed);
|
|
1492
|
+
}
|
|
1493
|
+
function getShellPathFromLoginShell(opts) {
|
|
1494
|
+
if (cachedShellPath !== void 0) return cachedShellPath;
|
|
1495
|
+
if (process.platform === "win32") {
|
|
1496
|
+
cachedShellPath = null;
|
|
1497
|
+
return cachedShellPath;
|
|
1498
|
+
}
|
|
1499
|
+
const exec = opts.exec ?? execFileSync;
|
|
1500
|
+
const timeoutMs = typeof opts.timeoutMs === "number" && Number.isFinite(opts.timeoutMs) ? Math.max(0, opts.timeoutMs) : DEFAULT_TIMEOUT_MS;
|
|
1501
|
+
const shell = resolveShell(opts.env);
|
|
1502
|
+
let stdout;
|
|
1503
|
+
try {
|
|
1504
|
+
stdout = exec(shell, [
|
|
1505
|
+
"-l",
|
|
1506
|
+
"-c",
|
|
1507
|
+
"env -0"
|
|
1508
|
+
], {
|
|
1509
|
+
encoding: "buffer",
|
|
1510
|
+
timeout: timeoutMs,
|
|
1511
|
+
maxBuffer: DEFAULT_MAX_BUFFER_BYTES,
|
|
1512
|
+
env: opts.env,
|
|
1513
|
+
stdio: [
|
|
1514
|
+
"ignore",
|
|
1515
|
+
"pipe",
|
|
1516
|
+
"pipe"
|
|
1517
|
+
]
|
|
1518
|
+
});
|
|
1519
|
+
} catch {
|
|
1520
|
+
cachedShellPath = null;
|
|
1521
|
+
return cachedShellPath;
|
|
1522
|
+
}
|
|
1523
|
+
const shellPath = parseShellEnv(stdout).get("PATH")?.trim();
|
|
1524
|
+
cachedShellPath = shellPath && shellPath.length > 0 ? shellPath : null;
|
|
1525
|
+
return cachedShellPath;
|
|
1526
|
+
}
|
|
1527
|
+
function getShellEnvAppliedKeys() {
|
|
1528
|
+
return [...lastAppliedKeys];
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
//#endregion
|
|
1532
|
+
//#region src/agents/model-auth.ts
|
|
1533
|
+
const AWS_BEARER_ENV = "AWS_BEARER_TOKEN_BEDROCK";
|
|
1534
|
+
const AWS_ACCESS_KEY_ENV = "AWS_ACCESS_KEY_ID";
|
|
1535
|
+
const AWS_SECRET_KEY_ENV = "AWS_SECRET_ACCESS_KEY";
|
|
1536
|
+
const AWS_PROFILE_ENV = "AWS_PROFILE";
|
|
1537
|
+
function resolveProviderConfig(cfg, provider) {
|
|
1538
|
+
const providers = cfg?.models?.providers ?? {};
|
|
1539
|
+
const direct = providers[provider];
|
|
1540
|
+
if (direct) return direct;
|
|
1541
|
+
const normalized = normalizeProviderId(provider);
|
|
1542
|
+
if (normalized === provider) return Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
|
|
1543
|
+
return providers[normalized] ?? Object.entries(providers).find(([key]) => normalizeProviderId(key) === normalized)?.[1];
|
|
1544
|
+
}
|
|
1545
|
+
function getCustomProviderApiKey(cfg, provider) {
|
|
1546
|
+
return resolveProviderConfig(cfg, provider)?.apiKey?.trim() || void 0;
|
|
1547
|
+
}
|
|
1548
|
+
function resolveProviderAuthOverride(cfg, provider) {
|
|
1549
|
+
const auth = resolveProviderConfig(cfg, provider)?.auth;
|
|
1550
|
+
if (auth === "api-key" || auth === "aws-sdk" || auth === "oauth" || auth === "token") return auth;
|
|
1551
|
+
}
|
|
1552
|
+
function resolveEnvSourceLabel(params) {
|
|
1553
|
+
return `${params.envVars.some((envVar) => params.applied.has(envVar)) ? "shell env: " : "env: "}${params.label}`;
|
|
1554
|
+
}
|
|
1555
|
+
function resolveAwsSdkEnvVarName(env = process.env) {
|
|
1556
|
+
if (env[AWS_BEARER_ENV]?.trim()) return AWS_BEARER_ENV;
|
|
1557
|
+
if (env[AWS_ACCESS_KEY_ENV]?.trim() && env[AWS_SECRET_KEY_ENV]?.trim()) return AWS_ACCESS_KEY_ENV;
|
|
1558
|
+
if (env[AWS_PROFILE_ENV]?.trim()) return AWS_PROFILE_ENV;
|
|
1559
|
+
}
|
|
1560
|
+
function resolveAwsSdkAuthInfo() {
|
|
1561
|
+
const applied = new Set(getShellEnvAppliedKeys());
|
|
1562
|
+
if (process.env[AWS_BEARER_ENV]?.trim()) return {
|
|
1563
|
+
mode: "aws-sdk",
|
|
1564
|
+
source: resolveEnvSourceLabel({
|
|
1565
|
+
applied,
|
|
1566
|
+
envVars: [AWS_BEARER_ENV],
|
|
1567
|
+
label: AWS_BEARER_ENV
|
|
1568
|
+
})
|
|
1569
|
+
};
|
|
1570
|
+
if (process.env[AWS_ACCESS_KEY_ENV]?.trim() && process.env[AWS_SECRET_KEY_ENV]?.trim()) return {
|
|
1571
|
+
mode: "aws-sdk",
|
|
1572
|
+
source: resolveEnvSourceLabel({
|
|
1573
|
+
applied,
|
|
1574
|
+
envVars: [AWS_ACCESS_KEY_ENV, AWS_SECRET_KEY_ENV],
|
|
1575
|
+
label: `${AWS_ACCESS_KEY_ENV} + ${AWS_SECRET_KEY_ENV}`
|
|
1576
|
+
})
|
|
1577
|
+
};
|
|
1578
|
+
if (process.env[AWS_PROFILE_ENV]?.trim()) return {
|
|
1579
|
+
mode: "aws-sdk",
|
|
1580
|
+
source: resolveEnvSourceLabel({
|
|
1581
|
+
applied,
|
|
1582
|
+
envVars: [AWS_PROFILE_ENV],
|
|
1583
|
+
label: AWS_PROFILE_ENV
|
|
1584
|
+
})
|
|
1585
|
+
};
|
|
1586
|
+
return {
|
|
1587
|
+
mode: "aws-sdk",
|
|
1588
|
+
source: "aws-sdk default chain"
|
|
1589
|
+
};
|
|
1590
|
+
}
|
|
1591
|
+
async function resolveApiKeyForProvider(params) {
|
|
1592
|
+
const { provider, cfg, profileId, preferredProfile } = params;
|
|
1593
|
+
const store = params.store ?? ensureAuthProfileStore(params.agentDir);
|
|
1594
|
+
if (profileId) {
|
|
1595
|
+
const resolved = await resolveApiKeyForProfile({
|
|
1596
|
+
cfg,
|
|
1597
|
+
store,
|
|
1598
|
+
profileId,
|
|
1599
|
+
agentDir: params.agentDir
|
|
1600
|
+
});
|
|
1601
|
+
if (!resolved) throw new Error(`No credentials found for profile "${profileId}".`);
|
|
1602
|
+
const mode = store.profiles[profileId]?.type;
|
|
1603
|
+
return {
|
|
1604
|
+
apiKey: resolved.apiKey,
|
|
1605
|
+
profileId,
|
|
1606
|
+
source: `profile:${profileId}`,
|
|
1607
|
+
mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
|
|
1608
|
+
};
|
|
1609
|
+
}
|
|
1610
|
+
const authOverride = resolveProviderAuthOverride(cfg, provider);
|
|
1611
|
+
if (authOverride === "aws-sdk") return resolveAwsSdkAuthInfo();
|
|
1612
|
+
const order = resolveAuthProfileOrder({
|
|
1613
|
+
cfg,
|
|
1614
|
+
store,
|
|
1615
|
+
provider,
|
|
1616
|
+
preferredProfile
|
|
1617
|
+
});
|
|
1618
|
+
for (const candidate of order) try {
|
|
1619
|
+
const resolved = await resolveApiKeyForProfile({
|
|
1620
|
+
cfg,
|
|
1621
|
+
store,
|
|
1622
|
+
profileId: candidate,
|
|
1623
|
+
agentDir: params.agentDir
|
|
1624
|
+
});
|
|
1625
|
+
if (resolved) {
|
|
1626
|
+
const mode = store.profiles[candidate]?.type;
|
|
1627
|
+
return {
|
|
1628
|
+
apiKey: resolved.apiKey,
|
|
1629
|
+
profileId: candidate,
|
|
1630
|
+
source: `profile:${candidate}`,
|
|
1631
|
+
mode: mode === "oauth" ? "oauth" : mode === "token" ? "token" : "api-key"
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
} catch {}
|
|
1635
|
+
const envResolved = resolveEnvApiKey(provider);
|
|
1636
|
+
if (envResolved) return {
|
|
1637
|
+
apiKey: envResolved.apiKey,
|
|
1638
|
+
source: envResolved.source,
|
|
1639
|
+
mode: envResolved.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key"
|
|
1640
|
+
};
|
|
1641
|
+
const customKey = getCustomProviderApiKey(cfg, provider);
|
|
1642
|
+
if (customKey) return {
|
|
1643
|
+
apiKey: customKey,
|
|
1644
|
+
source: "models.json",
|
|
1645
|
+
mode: "api-key"
|
|
1646
|
+
};
|
|
1647
|
+
const normalized = normalizeProviderId(provider);
|
|
1648
|
+
if (authOverride === void 0 && normalized === "amazon-bedrock") return resolveAwsSdkAuthInfo();
|
|
1649
|
+
if (provider === "openai") {
|
|
1650
|
+
if (listProfilesForProvider(store, "openai-codex").length > 0) throw new Error("No API key found for provider \"openai\". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.2 (ChatGPT OAuth) or set OPENAI_API_KEY for openai/gpt-5.2.");
|
|
1651
|
+
}
|
|
1652
|
+
const authStorePath = resolveAuthStorePathForDisplay(params.agentDir);
|
|
1653
|
+
const resolvedAgentDir = path.dirname(authStorePath);
|
|
1654
|
+
throw new Error([
|
|
1655
|
+
`No API key found for provider "${provider}".`,
|
|
1656
|
+
`Auth store: ${authStorePath} (agentDir: ${resolvedAgentDir}).`,
|
|
1657
|
+
`Configure auth for this agent (${formatCliCommand("openclaw agents add <id>")}) or copy auth-profiles.json from the main agentDir.`
|
|
1658
|
+
].join(" "));
|
|
1659
|
+
}
|
|
1660
|
+
function resolveEnvApiKey(provider) {
|
|
1661
|
+
const normalized = normalizeProviderId(provider);
|
|
1662
|
+
const applied = new Set(getShellEnvAppliedKeys());
|
|
1663
|
+
const pick = (envVar) => {
|
|
1664
|
+
const value = process.env[envVar]?.trim();
|
|
1665
|
+
if (!value) return null;
|
|
1666
|
+
return {
|
|
1667
|
+
apiKey: value,
|
|
1668
|
+
source: applied.has(envVar) ? `shell env: ${envVar}` : `env: ${envVar}`
|
|
1669
|
+
};
|
|
1670
|
+
};
|
|
1671
|
+
if (normalized === "github-copilot") return pick("COPILOT_GITHUB_TOKEN") ?? pick("GH_TOKEN") ?? pick("GITHUB_TOKEN");
|
|
1672
|
+
if (normalized === "anthropic") return pick("ANTHROPIC_OAUTH_TOKEN") ?? pick("ANTHROPIC_API_KEY");
|
|
1673
|
+
if (normalized === "chutes") return pick("CHUTES_OAUTH_TOKEN") ?? pick("CHUTES_API_KEY");
|
|
1674
|
+
if (normalized === "zai") return pick("ZAI_API_KEY") ?? pick("Z_AI_API_KEY");
|
|
1675
|
+
if (normalized === "google-vertex") {
|
|
1676
|
+
const envKey = getEnvApiKey(normalized);
|
|
1677
|
+
if (!envKey) return null;
|
|
1678
|
+
return {
|
|
1679
|
+
apiKey: envKey,
|
|
1680
|
+
source: "gcloud adc"
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
if (normalized === "opencode") return pick("OPENCODE_API_KEY") ?? pick("OPENCODE_ZEN_API_KEY");
|
|
1684
|
+
if (normalized === "qwen-portal") return pick("QWEN_OAUTH_TOKEN") ?? pick("QWEN_PORTAL_API_KEY");
|
|
1685
|
+
if (normalized === "minimax-portal") return pick("MINIMAX_OAUTH_TOKEN") ?? pick("MINIMAX_API_KEY");
|
|
1686
|
+
if (normalized === "kimi-coding") return pick("KIMI_API_KEY") ?? pick("KIMICODE_API_KEY");
|
|
1687
|
+
const envVar = {
|
|
1688
|
+
openai: "OPENAI_API_KEY",
|
|
1689
|
+
google: "GEMINI_API_KEY",
|
|
1690
|
+
groq: "GROQ_API_KEY",
|
|
1691
|
+
deepgram: "DEEPGRAM_API_KEY",
|
|
1692
|
+
cerebras: "CEREBRAS_API_KEY",
|
|
1693
|
+
xai: "XAI_API_KEY",
|
|
1694
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
1695
|
+
"vercel-ai-gateway": "AI_GATEWAY_API_KEY",
|
|
1696
|
+
"cloudflare-ai-gateway": "CLOUDFLARE_AI_GATEWAY_API_KEY",
|
|
1697
|
+
moonshot: "MOONSHOT_API_KEY",
|
|
1698
|
+
minimax: "MINIMAX_API_KEY",
|
|
1699
|
+
xiaomi: "XIAOMI_API_KEY",
|
|
1700
|
+
synthetic: "SYNTHETIC_API_KEY",
|
|
1701
|
+
venice: "VENICE_API_KEY",
|
|
1702
|
+
mistral: "MISTRAL_API_KEY",
|
|
1703
|
+
opencode: "OPENCODE_API_KEY"
|
|
1704
|
+
}[normalized];
|
|
1705
|
+
if (!envVar) return null;
|
|
1706
|
+
return pick(envVar);
|
|
1707
|
+
}
|
|
1708
|
+
function resolveModelAuthMode(provider, cfg, store) {
|
|
1709
|
+
const resolved = provider?.trim();
|
|
1710
|
+
if (!resolved) return;
|
|
1711
|
+
const authOverride = resolveProviderAuthOverride(cfg, resolved);
|
|
1712
|
+
if (authOverride === "aws-sdk") return "aws-sdk";
|
|
1713
|
+
const authStore = store ?? ensureAuthProfileStore();
|
|
1714
|
+
const profiles = listProfilesForProvider(authStore, resolved);
|
|
1715
|
+
if (profiles.length > 0) {
|
|
1716
|
+
const modes = new Set(profiles.map((id) => authStore.profiles[id]?.type).filter((mode) => Boolean(mode)));
|
|
1717
|
+
if ([
|
|
1718
|
+
"oauth",
|
|
1719
|
+
"token",
|
|
1720
|
+
"api_key"
|
|
1721
|
+
].filter((k) => modes.has(k)).length >= 2) return "mixed";
|
|
1722
|
+
if (modes.has("oauth")) return "oauth";
|
|
1723
|
+
if (modes.has("token")) return "token";
|
|
1724
|
+
if (modes.has("api_key")) return "api-key";
|
|
1725
|
+
}
|
|
1726
|
+
if (authOverride === void 0 && normalizeProviderId(resolved) === "amazon-bedrock") return "aws-sdk";
|
|
1727
|
+
const envKey = resolveEnvApiKey(resolved);
|
|
1728
|
+
if (envKey?.apiKey) return envKey.source.includes("OAUTH_TOKEN") ? "oauth" : "api-key";
|
|
1729
|
+
if (getCustomProviderApiKey(cfg, resolved)) return "api-key";
|
|
1730
|
+
return "unknown";
|
|
1731
|
+
}
|
|
1732
|
+
async function getApiKeyForModel(params) {
|
|
1733
|
+
return resolveApiKeyForProvider({
|
|
1734
|
+
provider: params.model.provider,
|
|
1735
|
+
cfg: params.cfg,
|
|
1736
|
+
profileId: params.profileId,
|
|
1737
|
+
preferredProfile: params.preferredProfile,
|
|
1738
|
+
store: params.store,
|
|
1739
|
+
agentDir: params.agentDir
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
function requireApiKey(auth, provider) {
|
|
1743
|
+
const key = auth.apiKey?.trim();
|
|
1744
|
+
if (key) return key;
|
|
1745
|
+
throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth.mode}).`);
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
//#endregion
|
|
1749
|
+
//#region src/agents/synthetic-models.ts
|
|
1750
|
+
const SYNTHETIC_BASE_URL = "https://api.synthetic.new/anthropic";
|
|
1751
|
+
const SYNTHETIC_DEFAULT_MODEL_ID = "hf:MiniMaxAI/MiniMax-M2.1";
|
|
1752
|
+
const SYNTHETIC_DEFAULT_MODEL_REF = `synthetic/${SYNTHETIC_DEFAULT_MODEL_ID}`;
|
|
1753
|
+
const SYNTHETIC_DEFAULT_COST = {
|
|
1754
|
+
input: 0,
|
|
1755
|
+
output: 0,
|
|
1756
|
+
cacheRead: 0,
|
|
1757
|
+
cacheWrite: 0
|
|
1758
|
+
};
|
|
1759
|
+
const SYNTHETIC_MODEL_CATALOG = [
|
|
1760
|
+
{
|
|
1761
|
+
id: SYNTHETIC_DEFAULT_MODEL_ID,
|
|
1762
|
+
name: "MiniMax M2.1",
|
|
1763
|
+
reasoning: false,
|
|
1764
|
+
input: ["text"],
|
|
1765
|
+
contextWindow: 192e3,
|
|
1766
|
+
maxTokens: 65536
|
|
1767
|
+
},
|
|
1768
|
+
{
|
|
1769
|
+
id: "hf:moonshotai/Kimi-K2-Thinking",
|
|
1770
|
+
name: "Kimi K2 Thinking",
|
|
1771
|
+
reasoning: true,
|
|
1772
|
+
input: ["text"],
|
|
1773
|
+
contextWindow: 256e3,
|
|
1774
|
+
maxTokens: 8192
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
id: "hf:zai-org/GLM-4.7",
|
|
1778
|
+
name: "GLM-4.7",
|
|
1779
|
+
reasoning: false,
|
|
1780
|
+
input: ["text"],
|
|
1781
|
+
contextWindow: 198e3,
|
|
1782
|
+
maxTokens: 128e3
|
|
1783
|
+
},
|
|
1784
|
+
{
|
|
1785
|
+
id: "hf:deepseek-ai/DeepSeek-R1-0528",
|
|
1786
|
+
name: "DeepSeek R1 0528",
|
|
1787
|
+
reasoning: false,
|
|
1788
|
+
input: ["text"],
|
|
1789
|
+
contextWindow: 128e3,
|
|
1790
|
+
maxTokens: 8192
|
|
1791
|
+
},
|
|
1792
|
+
{
|
|
1793
|
+
id: "hf:deepseek-ai/DeepSeek-V3-0324",
|
|
1794
|
+
name: "DeepSeek V3 0324",
|
|
1795
|
+
reasoning: false,
|
|
1796
|
+
input: ["text"],
|
|
1797
|
+
contextWindow: 128e3,
|
|
1798
|
+
maxTokens: 8192
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
id: "hf:deepseek-ai/DeepSeek-V3.1",
|
|
1802
|
+
name: "DeepSeek V3.1",
|
|
1803
|
+
reasoning: false,
|
|
1804
|
+
input: ["text"],
|
|
1805
|
+
contextWindow: 128e3,
|
|
1806
|
+
maxTokens: 8192
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
id: "hf:deepseek-ai/DeepSeek-V3.1-Terminus",
|
|
1810
|
+
name: "DeepSeek V3.1 Terminus",
|
|
1811
|
+
reasoning: false,
|
|
1812
|
+
input: ["text"],
|
|
1813
|
+
contextWindow: 128e3,
|
|
1814
|
+
maxTokens: 8192
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
id: "hf:deepseek-ai/DeepSeek-V3.2",
|
|
1818
|
+
name: "DeepSeek V3.2",
|
|
1819
|
+
reasoning: false,
|
|
1820
|
+
input: ["text"],
|
|
1821
|
+
contextWindow: 159e3,
|
|
1822
|
+
maxTokens: 8192
|
|
1823
|
+
},
|
|
1824
|
+
{
|
|
1825
|
+
id: "hf:meta-llama/Llama-3.3-70B-Instruct",
|
|
1826
|
+
name: "Llama 3.3 70B Instruct",
|
|
1827
|
+
reasoning: false,
|
|
1828
|
+
input: ["text"],
|
|
1829
|
+
contextWindow: 128e3,
|
|
1830
|
+
maxTokens: 8192
|
|
1831
|
+
},
|
|
1832
|
+
{
|
|
1833
|
+
id: "hf:meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
|
|
1834
|
+
name: "Llama 4 Maverick 17B 128E Instruct FP8",
|
|
1835
|
+
reasoning: false,
|
|
1836
|
+
input: ["text"],
|
|
1837
|
+
contextWindow: 524e3,
|
|
1838
|
+
maxTokens: 8192
|
|
1839
|
+
},
|
|
1840
|
+
{
|
|
1841
|
+
id: "hf:moonshotai/Kimi-K2-Instruct-0905",
|
|
1842
|
+
name: "Kimi K2 Instruct 0905",
|
|
1843
|
+
reasoning: false,
|
|
1844
|
+
input: ["text"],
|
|
1845
|
+
contextWindow: 256e3,
|
|
1846
|
+
maxTokens: 8192
|
|
1847
|
+
},
|
|
1848
|
+
{
|
|
1849
|
+
id: "hf:moonshotai/Kimi-K2.5",
|
|
1850
|
+
name: "Kimi K2.5",
|
|
1851
|
+
reasoning: true,
|
|
1852
|
+
input: ["text"],
|
|
1853
|
+
contextWindow: 256e3,
|
|
1854
|
+
maxTokens: 8192
|
|
1855
|
+
},
|
|
1856
|
+
{
|
|
1857
|
+
id: "hf:openai/gpt-oss-120b",
|
|
1858
|
+
name: "GPT OSS 120B",
|
|
1859
|
+
reasoning: false,
|
|
1860
|
+
input: ["text"],
|
|
1861
|
+
contextWindow: 128e3,
|
|
1862
|
+
maxTokens: 8192
|
|
1863
|
+
},
|
|
1864
|
+
{
|
|
1865
|
+
id: "hf:Qwen/Qwen3-235B-A22B-Instruct-2507",
|
|
1866
|
+
name: "Qwen3 235B A22B Instruct 2507",
|
|
1867
|
+
reasoning: false,
|
|
1868
|
+
input: ["text"],
|
|
1869
|
+
contextWindow: 256e3,
|
|
1870
|
+
maxTokens: 8192
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
id: "hf:Qwen/Qwen3-Coder-480B-A35B-Instruct",
|
|
1874
|
+
name: "Qwen3 Coder 480B A35B Instruct",
|
|
1875
|
+
reasoning: false,
|
|
1876
|
+
input: ["text"],
|
|
1877
|
+
contextWindow: 256e3,
|
|
1878
|
+
maxTokens: 8192
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
id: "hf:Qwen/Qwen3-VL-235B-A22B-Instruct",
|
|
1882
|
+
name: "Qwen3 VL 235B A22B Instruct",
|
|
1883
|
+
reasoning: false,
|
|
1884
|
+
input: ["text", "image"],
|
|
1885
|
+
contextWindow: 25e4,
|
|
1886
|
+
maxTokens: 8192
|
|
1887
|
+
},
|
|
1888
|
+
{
|
|
1889
|
+
id: "hf:zai-org/GLM-4.5",
|
|
1890
|
+
name: "GLM-4.5",
|
|
1891
|
+
reasoning: false,
|
|
1892
|
+
input: ["text"],
|
|
1893
|
+
contextWindow: 128e3,
|
|
1894
|
+
maxTokens: 128e3
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
id: "hf:zai-org/GLM-4.6",
|
|
1898
|
+
name: "GLM-4.6",
|
|
1899
|
+
reasoning: false,
|
|
1900
|
+
input: ["text"],
|
|
1901
|
+
contextWindow: 198e3,
|
|
1902
|
+
maxTokens: 128e3
|
|
1903
|
+
},
|
|
1904
|
+
{
|
|
1905
|
+
id: "hf:deepseek-ai/DeepSeek-V3",
|
|
1906
|
+
name: "DeepSeek V3",
|
|
1907
|
+
reasoning: false,
|
|
1908
|
+
input: ["text"],
|
|
1909
|
+
contextWindow: 128e3,
|
|
1910
|
+
maxTokens: 8192
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
id: "hf:Qwen/Qwen3-235B-A22B-Thinking-2507",
|
|
1914
|
+
name: "Qwen3 235B A22B Thinking 2507",
|
|
1915
|
+
reasoning: true,
|
|
1916
|
+
input: ["text"],
|
|
1917
|
+
contextWindow: 256e3,
|
|
1918
|
+
maxTokens: 8192
|
|
1919
|
+
}
|
|
1920
|
+
];
|
|
1921
|
+
function buildSyntheticModelDefinition(entry) {
|
|
1922
|
+
return {
|
|
1923
|
+
id: entry.id,
|
|
1924
|
+
name: entry.name,
|
|
1925
|
+
reasoning: entry.reasoning,
|
|
1926
|
+
input: [...entry.input],
|
|
1927
|
+
cost: SYNTHETIC_DEFAULT_COST,
|
|
1928
|
+
contextWindow: entry.contextWindow,
|
|
1929
|
+
maxTokens: entry.maxTokens
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
//#endregion
|
|
1934
|
+
//#region src/agents/venice-models.ts
|
|
1935
|
+
const VENICE_BASE_URL = "https://api.venice.ai/api/v1";
|
|
1936
|
+
const VENICE_DEFAULT_MODEL_ID = "llama-3.3-70b";
|
|
1937
|
+
const VENICE_DEFAULT_MODEL_REF = `venice/${VENICE_DEFAULT_MODEL_ID}`;
|
|
1938
|
+
const VENICE_DEFAULT_COST = {
|
|
1939
|
+
input: 0,
|
|
1940
|
+
output: 0,
|
|
1941
|
+
cacheRead: 0,
|
|
1942
|
+
cacheWrite: 0
|
|
1943
|
+
};
|
|
1944
|
+
/**
|
|
1945
|
+
* Complete catalog of Venice AI models.
|
|
1946
|
+
*
|
|
1947
|
+
* Venice provides two privacy modes:
|
|
1948
|
+
* - "private": Fully private inference, no logging, ephemeral
|
|
1949
|
+
* - "anonymized": Proxied through Venice with metadata stripped (for proprietary models)
|
|
1950
|
+
*
|
|
1951
|
+
* Note: The `privacy` field is included for documentation purposes but is not
|
|
1952
|
+
* propagated to ModelDefinitionConfig as it's not part of the core model schema.
|
|
1953
|
+
* Privacy mode is determined by the model itself, not configurable at runtime.
|
|
1954
|
+
*
|
|
1955
|
+
* This catalog serves as a fallback when the Venice API is unreachable.
|
|
1956
|
+
*/
|
|
1957
|
+
const VENICE_MODEL_CATALOG = [
|
|
1958
|
+
{
|
|
1959
|
+
id: "llama-3.3-70b",
|
|
1960
|
+
name: "Llama 3.3 70B",
|
|
1961
|
+
reasoning: false,
|
|
1962
|
+
input: ["text"],
|
|
1963
|
+
contextWindow: 131072,
|
|
1964
|
+
maxTokens: 8192,
|
|
1965
|
+
privacy: "private"
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
id: "llama-3.2-3b",
|
|
1969
|
+
name: "Llama 3.2 3B",
|
|
1970
|
+
reasoning: false,
|
|
1971
|
+
input: ["text"],
|
|
1972
|
+
contextWindow: 131072,
|
|
1973
|
+
maxTokens: 8192,
|
|
1974
|
+
privacy: "private"
|
|
1975
|
+
},
|
|
1976
|
+
{
|
|
1977
|
+
id: "hermes-3-llama-3.1-405b",
|
|
1978
|
+
name: "Hermes 3 Llama 3.1 405B",
|
|
1979
|
+
reasoning: false,
|
|
1980
|
+
input: ["text"],
|
|
1981
|
+
contextWindow: 131072,
|
|
1982
|
+
maxTokens: 8192,
|
|
1983
|
+
privacy: "private"
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
id: "qwen3-235b-a22b-thinking-2507",
|
|
1987
|
+
name: "Qwen3 235B Thinking",
|
|
1988
|
+
reasoning: true,
|
|
1989
|
+
input: ["text"],
|
|
1990
|
+
contextWindow: 131072,
|
|
1991
|
+
maxTokens: 8192,
|
|
1992
|
+
privacy: "private"
|
|
1993
|
+
},
|
|
1994
|
+
{
|
|
1995
|
+
id: "qwen3-235b-a22b-instruct-2507",
|
|
1996
|
+
name: "Qwen3 235B Instruct",
|
|
1997
|
+
reasoning: false,
|
|
1998
|
+
input: ["text"],
|
|
1999
|
+
contextWindow: 131072,
|
|
2000
|
+
maxTokens: 8192,
|
|
2001
|
+
privacy: "private"
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
id: "qwen3-coder-480b-a35b-instruct",
|
|
2005
|
+
name: "Qwen3 Coder 480B",
|
|
2006
|
+
reasoning: false,
|
|
2007
|
+
input: ["text"],
|
|
2008
|
+
contextWindow: 262144,
|
|
2009
|
+
maxTokens: 8192,
|
|
2010
|
+
privacy: "private"
|
|
2011
|
+
},
|
|
2012
|
+
{
|
|
2013
|
+
id: "qwen3-next-80b",
|
|
2014
|
+
name: "Qwen3 Next 80B",
|
|
2015
|
+
reasoning: false,
|
|
2016
|
+
input: ["text"],
|
|
2017
|
+
contextWindow: 262144,
|
|
2018
|
+
maxTokens: 8192,
|
|
2019
|
+
privacy: "private"
|
|
2020
|
+
},
|
|
2021
|
+
{
|
|
2022
|
+
id: "qwen3-vl-235b-a22b",
|
|
2023
|
+
name: "Qwen3 VL 235B (Vision)",
|
|
2024
|
+
reasoning: false,
|
|
2025
|
+
input: ["text", "image"],
|
|
2026
|
+
contextWindow: 262144,
|
|
2027
|
+
maxTokens: 8192,
|
|
2028
|
+
privacy: "private"
|
|
2029
|
+
},
|
|
2030
|
+
{
|
|
2031
|
+
id: "qwen3-4b",
|
|
2032
|
+
name: "Venice Small (Qwen3 4B)",
|
|
2033
|
+
reasoning: true,
|
|
2034
|
+
input: ["text"],
|
|
2035
|
+
contextWindow: 32768,
|
|
2036
|
+
maxTokens: 8192,
|
|
2037
|
+
privacy: "private"
|
|
2038
|
+
},
|
|
2039
|
+
{
|
|
2040
|
+
id: "deepseek-v3.2",
|
|
2041
|
+
name: "DeepSeek V3.2",
|
|
2042
|
+
reasoning: true,
|
|
2043
|
+
input: ["text"],
|
|
2044
|
+
contextWindow: 163840,
|
|
2045
|
+
maxTokens: 8192,
|
|
2046
|
+
privacy: "private"
|
|
2047
|
+
},
|
|
2048
|
+
{
|
|
2049
|
+
id: "venice-uncensored",
|
|
2050
|
+
name: "Venice Uncensored (Dolphin-Mistral)",
|
|
2051
|
+
reasoning: false,
|
|
2052
|
+
input: ["text"],
|
|
2053
|
+
contextWindow: 32768,
|
|
2054
|
+
maxTokens: 8192,
|
|
2055
|
+
privacy: "private"
|
|
2056
|
+
},
|
|
2057
|
+
{
|
|
2058
|
+
id: "mistral-31-24b",
|
|
2059
|
+
name: "Venice Medium (Mistral)",
|
|
2060
|
+
reasoning: false,
|
|
2061
|
+
input: ["text", "image"],
|
|
2062
|
+
contextWindow: 131072,
|
|
2063
|
+
maxTokens: 8192,
|
|
2064
|
+
privacy: "private"
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
id: "google-gemma-3-27b-it",
|
|
2068
|
+
name: "Google Gemma 3 27B Instruct",
|
|
2069
|
+
reasoning: false,
|
|
2070
|
+
input: ["text", "image"],
|
|
2071
|
+
contextWindow: 202752,
|
|
2072
|
+
maxTokens: 8192,
|
|
2073
|
+
privacy: "private"
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
id: "openai-gpt-oss-120b",
|
|
2077
|
+
name: "OpenAI GPT OSS 120B",
|
|
2078
|
+
reasoning: false,
|
|
2079
|
+
input: ["text"],
|
|
2080
|
+
contextWindow: 131072,
|
|
2081
|
+
maxTokens: 8192,
|
|
2082
|
+
privacy: "private"
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
id: "zai-org-glm-4.7",
|
|
2086
|
+
name: "GLM 4.7",
|
|
2087
|
+
reasoning: true,
|
|
2088
|
+
input: ["text"],
|
|
2089
|
+
contextWindow: 202752,
|
|
2090
|
+
maxTokens: 8192,
|
|
2091
|
+
privacy: "private"
|
|
2092
|
+
},
|
|
2093
|
+
{
|
|
2094
|
+
id: "claude-opus-45",
|
|
2095
|
+
name: "Claude Opus 4.5 (via Venice)",
|
|
2096
|
+
reasoning: true,
|
|
2097
|
+
input: ["text", "image"],
|
|
2098
|
+
contextWindow: 202752,
|
|
2099
|
+
maxTokens: 8192,
|
|
2100
|
+
privacy: "anonymized"
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
id: "claude-sonnet-45",
|
|
2104
|
+
name: "Claude Sonnet 4.5 (via Venice)",
|
|
2105
|
+
reasoning: true,
|
|
2106
|
+
input: ["text", "image"],
|
|
2107
|
+
contextWindow: 202752,
|
|
2108
|
+
maxTokens: 8192,
|
|
2109
|
+
privacy: "anonymized"
|
|
2110
|
+
},
|
|
2111
|
+
{
|
|
2112
|
+
id: "openai-gpt-52",
|
|
2113
|
+
name: "GPT-5.2 (via Venice)",
|
|
2114
|
+
reasoning: true,
|
|
2115
|
+
input: ["text"],
|
|
2116
|
+
contextWindow: 262144,
|
|
2117
|
+
maxTokens: 8192,
|
|
2118
|
+
privacy: "anonymized"
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
id: "openai-gpt-52-codex",
|
|
2122
|
+
name: "GPT-5.2 Codex (via Venice)",
|
|
2123
|
+
reasoning: true,
|
|
2124
|
+
input: ["text", "image"],
|
|
2125
|
+
contextWindow: 262144,
|
|
2126
|
+
maxTokens: 8192,
|
|
2127
|
+
privacy: "anonymized"
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
id: "gemini-3-pro-preview",
|
|
2131
|
+
name: "Gemini 3 Pro (via Venice)",
|
|
2132
|
+
reasoning: true,
|
|
2133
|
+
input: ["text", "image"],
|
|
2134
|
+
contextWindow: 202752,
|
|
2135
|
+
maxTokens: 8192,
|
|
2136
|
+
privacy: "anonymized"
|
|
2137
|
+
},
|
|
2138
|
+
{
|
|
2139
|
+
id: "gemini-3-flash-preview",
|
|
2140
|
+
name: "Gemini 3 Flash (via Venice)",
|
|
2141
|
+
reasoning: true,
|
|
2142
|
+
input: ["text", "image"],
|
|
2143
|
+
contextWindow: 262144,
|
|
2144
|
+
maxTokens: 8192,
|
|
2145
|
+
privacy: "anonymized"
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
id: "grok-41-fast",
|
|
2149
|
+
name: "Grok 4.1 Fast (via Venice)",
|
|
2150
|
+
reasoning: true,
|
|
2151
|
+
input: ["text", "image"],
|
|
2152
|
+
contextWindow: 262144,
|
|
2153
|
+
maxTokens: 8192,
|
|
2154
|
+
privacy: "anonymized"
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
id: "grok-code-fast-1",
|
|
2158
|
+
name: "Grok Code Fast 1 (via Venice)",
|
|
2159
|
+
reasoning: true,
|
|
2160
|
+
input: ["text"],
|
|
2161
|
+
contextWindow: 262144,
|
|
2162
|
+
maxTokens: 8192,
|
|
2163
|
+
privacy: "anonymized"
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
id: "kimi-k2-thinking",
|
|
2167
|
+
name: "Kimi K2 Thinking (via Venice)",
|
|
2168
|
+
reasoning: true,
|
|
2169
|
+
input: ["text"],
|
|
2170
|
+
contextWindow: 262144,
|
|
2171
|
+
maxTokens: 8192,
|
|
2172
|
+
privacy: "anonymized"
|
|
2173
|
+
},
|
|
2174
|
+
{
|
|
2175
|
+
id: "minimax-m21",
|
|
2176
|
+
name: "MiniMax M2.1 (via Venice)",
|
|
2177
|
+
reasoning: true,
|
|
2178
|
+
input: ["text"],
|
|
2179
|
+
contextWindow: 202752,
|
|
2180
|
+
maxTokens: 8192,
|
|
2181
|
+
privacy: "anonymized"
|
|
2182
|
+
}
|
|
2183
|
+
];
|
|
2184
|
+
/**
|
|
2185
|
+
* Build a ModelDefinitionConfig from a Venice catalog entry.
|
|
2186
|
+
*
|
|
2187
|
+
* Note: The `privacy` field from the catalog is not included in the output
|
|
2188
|
+
* as ModelDefinitionConfig doesn't support custom metadata fields. Privacy
|
|
2189
|
+
* mode is inherent to each model and documented in the catalog/docs.
|
|
2190
|
+
*/
|
|
2191
|
+
function buildVeniceModelDefinition(entry) {
|
|
2192
|
+
return {
|
|
2193
|
+
id: entry.id,
|
|
2194
|
+
name: entry.name,
|
|
2195
|
+
reasoning: entry.reasoning,
|
|
2196
|
+
input: [...entry.input],
|
|
2197
|
+
cost: VENICE_DEFAULT_COST,
|
|
2198
|
+
contextWindow: entry.contextWindow,
|
|
2199
|
+
maxTokens: entry.maxTokens
|
|
2200
|
+
};
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* Discover models from Venice API with fallback to static catalog.
|
|
2204
|
+
* The /models endpoint is public and doesn't require authentication.
|
|
2205
|
+
*/
|
|
2206
|
+
async function discoverVeniceModels() {
|
|
2207
|
+
if (process.env.VITEST) return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
|
|
2208
|
+
try {
|
|
2209
|
+
const response = await fetch(`${VENICE_BASE_URL}/models`, { signal: AbortSignal.timeout(5e3) });
|
|
2210
|
+
if (!response.ok) {
|
|
2211
|
+
console.warn(`[venice-models] Failed to discover models: HTTP ${response.status}, using static catalog`);
|
|
2212
|
+
return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
|
|
2213
|
+
}
|
|
2214
|
+
const data = await response.json();
|
|
2215
|
+
if (!Array.isArray(data.data) || data.data.length === 0) {
|
|
2216
|
+
console.warn("[venice-models] No models found from API, using static catalog");
|
|
2217
|
+
return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
|
|
2218
|
+
}
|
|
2219
|
+
const catalogById = new Map(VENICE_MODEL_CATALOG.map((m) => [m.id, m]));
|
|
2220
|
+
const models = [];
|
|
2221
|
+
for (const apiModel of data.data) {
|
|
2222
|
+
const catalogEntry = catalogById.get(apiModel.id);
|
|
2223
|
+
if (catalogEntry) models.push(buildVeniceModelDefinition(catalogEntry));
|
|
2224
|
+
else {
|
|
2225
|
+
const isReasoning = apiModel.model_spec.capabilities.supportsReasoning || apiModel.id.toLowerCase().includes("thinking") || apiModel.id.toLowerCase().includes("reason") || apiModel.id.toLowerCase().includes("r1");
|
|
2226
|
+
const hasVision = apiModel.model_spec.capabilities.supportsVision;
|
|
2227
|
+
models.push({
|
|
2228
|
+
id: apiModel.id,
|
|
2229
|
+
name: apiModel.model_spec.name || apiModel.id,
|
|
2230
|
+
reasoning: isReasoning,
|
|
2231
|
+
input: hasVision ? ["text", "image"] : ["text"],
|
|
2232
|
+
cost: VENICE_DEFAULT_COST,
|
|
2233
|
+
contextWindow: apiModel.model_spec.availableContextTokens || 128e3,
|
|
2234
|
+
maxTokens: 8192
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
return models.length > 0 ? models : VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
|
|
2239
|
+
} catch (error) {
|
|
2240
|
+
console.warn(`[venice-models] Discovery failed: ${String(error)}, using static catalog`);
|
|
2241
|
+
return VENICE_MODEL_CATALOG.map(buildVeniceModelDefinition);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
//#endregion
|
|
2246
|
+
//#region src/agents/models-config.providers.ts
|
|
2247
|
+
const MINIMAX_API_BASE_URL = "https://api.minimax.chat/v1";
|
|
2248
|
+
const MINIMAX_PORTAL_BASE_URL = "https://api.minimax.io/anthropic";
|
|
2249
|
+
const MINIMAX_DEFAULT_MODEL_ID = "MiniMax-M2.1";
|
|
2250
|
+
const MINIMAX_DEFAULT_VISION_MODEL_ID = "MiniMax-VL-01";
|
|
2251
|
+
const MINIMAX_DEFAULT_CONTEXT_WINDOW = 2e5;
|
|
2252
|
+
const MINIMAX_DEFAULT_MAX_TOKENS = 8192;
|
|
2253
|
+
const MINIMAX_OAUTH_PLACEHOLDER = "minimax-oauth";
|
|
2254
|
+
const MINIMAX_API_COST = {
|
|
2255
|
+
input: 15,
|
|
2256
|
+
output: 60,
|
|
2257
|
+
cacheRead: 2,
|
|
2258
|
+
cacheWrite: 10
|
|
2259
|
+
};
|
|
2260
|
+
const XIAOMI_BASE_URL = "https://api.xiaomimimo.com/anthropic";
|
|
2261
|
+
const XIAOMI_DEFAULT_MODEL_ID = "mimo-v2-flash";
|
|
2262
|
+
const XIAOMI_DEFAULT_CONTEXT_WINDOW = 262144;
|
|
2263
|
+
const XIAOMI_DEFAULT_MAX_TOKENS = 8192;
|
|
2264
|
+
const XIAOMI_DEFAULT_COST = {
|
|
2265
|
+
input: 0,
|
|
2266
|
+
output: 0,
|
|
2267
|
+
cacheRead: 0,
|
|
2268
|
+
cacheWrite: 0
|
|
2269
|
+
};
|
|
2270
|
+
const MOONSHOT_BASE_URL = "https://api.moonshot.ai/v1";
|
|
2271
|
+
const MOONSHOT_DEFAULT_MODEL_ID = "kimi-k2.5";
|
|
2272
|
+
const MOONSHOT_DEFAULT_CONTEXT_WINDOW = 256e3;
|
|
2273
|
+
const MOONSHOT_DEFAULT_MAX_TOKENS = 8192;
|
|
2274
|
+
const MOONSHOT_DEFAULT_COST = {
|
|
2275
|
+
input: 0,
|
|
2276
|
+
output: 0,
|
|
2277
|
+
cacheRead: 0,
|
|
2278
|
+
cacheWrite: 0
|
|
2279
|
+
};
|
|
2280
|
+
const CAPTAINAPP_BASE_URL = "https://captainapp-proxy.captainapp.workers.dev/v1";
|
|
2281
|
+
const CAPTAINAPP_DEFAULT_MODEL_ID = "captainapp/kimi-k2.5";
|
|
2282
|
+
const CAPTAINAPP_DEFAULT_CONTEXT_WINDOW = 256e3;
|
|
2283
|
+
const CAPTAINAPP_DEFAULT_MAX_TOKENS = 8192;
|
|
2284
|
+
const CAPTAINAPP_DEFAULT_COST = {
|
|
2285
|
+
input: 5e-7,
|
|
2286
|
+
output: 1e-6,
|
|
2287
|
+
cacheRead: 0,
|
|
2288
|
+
cacheWrite: 0
|
|
2289
|
+
};
|
|
2290
|
+
const QWEN_PORTAL_BASE_URL = "https://portal.qwen.ai/v1";
|
|
2291
|
+
const QWEN_PORTAL_OAUTH_PLACEHOLDER = "qwen-oauth";
|
|
2292
|
+
const QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
2293
|
+
const QWEN_PORTAL_DEFAULT_MAX_TOKENS = 8192;
|
|
2294
|
+
const QWEN_PORTAL_DEFAULT_COST = {
|
|
2295
|
+
input: 0,
|
|
2296
|
+
output: 0,
|
|
2297
|
+
cacheRead: 0,
|
|
2298
|
+
cacheWrite: 0
|
|
2299
|
+
};
|
|
2300
|
+
const OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1";
|
|
2301
|
+
const OLLAMA_API_BASE_URL = "http://127.0.0.1:11434";
|
|
2302
|
+
const OLLAMA_DEFAULT_CONTEXT_WINDOW = 128e3;
|
|
2303
|
+
const OLLAMA_DEFAULT_MAX_TOKENS = 8192;
|
|
2304
|
+
const OLLAMA_DEFAULT_COST = {
|
|
2305
|
+
input: 0,
|
|
2306
|
+
output: 0,
|
|
2307
|
+
cacheRead: 0,
|
|
2308
|
+
cacheWrite: 0
|
|
2309
|
+
};
|
|
2310
|
+
async function discoverOllamaModels() {
|
|
2311
|
+
if (process.env.VITEST || false) return [];
|
|
2312
|
+
try {
|
|
2313
|
+
const response = await fetch(`${OLLAMA_API_BASE_URL}/api/tags`, { signal: AbortSignal.timeout(5e3) });
|
|
2314
|
+
if (!response.ok) {
|
|
2315
|
+
console.warn(`Failed to discover Ollama models: ${response.status}`);
|
|
2316
|
+
return [];
|
|
2317
|
+
}
|
|
2318
|
+
const data = await response.json();
|
|
2319
|
+
if (!data.models || data.models.length === 0) {
|
|
2320
|
+
console.warn("No Ollama models found on local instance");
|
|
2321
|
+
return [];
|
|
2322
|
+
}
|
|
2323
|
+
return data.models.map((model) => {
|
|
2324
|
+
const modelId = model.name;
|
|
2325
|
+
return {
|
|
2326
|
+
id: modelId,
|
|
2327
|
+
name: modelId,
|
|
2328
|
+
reasoning: modelId.toLowerCase().includes("r1") || modelId.toLowerCase().includes("reasoning"),
|
|
2329
|
+
input: ["text"],
|
|
2330
|
+
cost: OLLAMA_DEFAULT_COST,
|
|
2331
|
+
contextWindow: OLLAMA_DEFAULT_CONTEXT_WINDOW,
|
|
2332
|
+
maxTokens: OLLAMA_DEFAULT_MAX_TOKENS
|
|
2333
|
+
};
|
|
2334
|
+
});
|
|
2335
|
+
} catch (error) {
|
|
2336
|
+
console.warn(`Failed to discover Ollama models: ${String(error)}`);
|
|
2337
|
+
return [];
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
function normalizeApiKeyConfig(value) {
|
|
2341
|
+
const trimmed = value.trim();
|
|
2342
|
+
return /^\$\{([A-Z0-9_]+)\}$/.exec(trimmed)?.[1] ?? trimmed;
|
|
2343
|
+
}
|
|
2344
|
+
function resolveEnvApiKeyVarName(provider) {
|
|
2345
|
+
const resolved = resolveEnvApiKey(provider);
|
|
2346
|
+
if (!resolved) return;
|
|
2347
|
+
const match = /^(?:env: |shell env: )([A-Z0-9_]+)$/.exec(resolved.source);
|
|
2348
|
+
return match ? match[1] : void 0;
|
|
2349
|
+
}
|
|
2350
|
+
function resolveAwsSdkApiKeyVarName() {
|
|
2351
|
+
return resolveAwsSdkEnvVarName() ?? "AWS_PROFILE";
|
|
2352
|
+
}
|
|
2353
|
+
function resolveApiKeyFromProfiles(params) {
|
|
2354
|
+
const ids = listProfilesForProvider(params.store, params.provider);
|
|
2355
|
+
for (const id of ids) {
|
|
2356
|
+
const cred = params.store.profiles[id];
|
|
2357
|
+
if (!cred) continue;
|
|
2358
|
+
if (cred.type === "api_key") return cred.key;
|
|
2359
|
+
if (cred.type === "token") return cred.token;
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
function normalizeGoogleModelId(id) {
|
|
2363
|
+
if (id === "gemini-3-pro") return "gemini-3-pro-preview";
|
|
2364
|
+
if (id === "gemini-3-flash") return "gemini-3-flash-preview";
|
|
2365
|
+
return id;
|
|
2366
|
+
}
|
|
2367
|
+
function normalizeGoogleProvider(provider) {
|
|
2368
|
+
let mutated = false;
|
|
2369
|
+
const models = provider.models.map((model) => {
|
|
2370
|
+
const nextId = normalizeGoogleModelId(model.id);
|
|
2371
|
+
if (nextId === model.id) return model;
|
|
2372
|
+
mutated = true;
|
|
2373
|
+
return {
|
|
2374
|
+
...model,
|
|
2375
|
+
id: nextId
|
|
2376
|
+
};
|
|
2377
|
+
});
|
|
2378
|
+
return mutated ? {
|
|
2379
|
+
...provider,
|
|
2380
|
+
models
|
|
2381
|
+
} : provider;
|
|
2382
|
+
}
|
|
2383
|
+
function normalizeProviders(params) {
|
|
2384
|
+
const { providers } = params;
|
|
2385
|
+
if (!providers) return providers;
|
|
2386
|
+
const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
2387
|
+
let mutated = false;
|
|
2388
|
+
const next = {};
|
|
2389
|
+
for (const [key, provider] of Object.entries(providers)) {
|
|
2390
|
+
const normalizedKey = key.trim();
|
|
2391
|
+
let normalizedProvider = provider;
|
|
2392
|
+
if (normalizedProvider.apiKey && normalizeApiKeyConfig(normalizedProvider.apiKey) !== normalizedProvider.apiKey) {
|
|
2393
|
+
mutated = true;
|
|
2394
|
+
normalizedProvider = {
|
|
2395
|
+
...normalizedProvider,
|
|
2396
|
+
apiKey: normalizeApiKeyConfig(normalizedProvider.apiKey)
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
if (Array.isArray(normalizedProvider.models) && normalizedProvider.models.length > 0 && !normalizedProvider.apiKey?.trim()) if ((normalizedProvider.auth ?? (normalizedKey === "amazon-bedrock" ? "aws-sdk" : void 0)) === "aws-sdk") {
|
|
2400
|
+
const apiKey = resolveAwsSdkApiKeyVarName();
|
|
2401
|
+
mutated = true;
|
|
2402
|
+
normalizedProvider = {
|
|
2403
|
+
...normalizedProvider,
|
|
2404
|
+
apiKey
|
|
2405
|
+
};
|
|
2406
|
+
} else {
|
|
2407
|
+
const fromEnv = resolveEnvApiKeyVarName(normalizedKey);
|
|
2408
|
+
const fromProfiles = resolveApiKeyFromProfiles({
|
|
2409
|
+
provider: normalizedKey,
|
|
2410
|
+
store: authStore
|
|
2411
|
+
});
|
|
2412
|
+
const apiKey = fromEnv ?? fromProfiles;
|
|
2413
|
+
if (apiKey?.trim()) {
|
|
2414
|
+
mutated = true;
|
|
2415
|
+
normalizedProvider = {
|
|
2416
|
+
...normalizedProvider,
|
|
2417
|
+
apiKey
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
if (normalizedKey === "google") {
|
|
2422
|
+
const googleNormalized = normalizeGoogleProvider(normalizedProvider);
|
|
2423
|
+
if (googleNormalized !== normalizedProvider) mutated = true;
|
|
2424
|
+
normalizedProvider = googleNormalized;
|
|
2425
|
+
}
|
|
2426
|
+
next[key] = normalizedProvider;
|
|
2427
|
+
}
|
|
2428
|
+
return mutated ? next : providers;
|
|
2429
|
+
}
|
|
2430
|
+
function buildMinimaxProvider() {
|
|
2431
|
+
return {
|
|
2432
|
+
baseUrl: MINIMAX_API_BASE_URL,
|
|
2433
|
+
api: "openai-completions",
|
|
2434
|
+
models: [{
|
|
2435
|
+
id: MINIMAX_DEFAULT_MODEL_ID,
|
|
2436
|
+
name: "MiniMax M2.1",
|
|
2437
|
+
reasoning: false,
|
|
2438
|
+
input: ["text"],
|
|
2439
|
+
cost: MINIMAX_API_COST,
|
|
2440
|
+
contextWindow: MINIMAX_DEFAULT_CONTEXT_WINDOW,
|
|
2441
|
+
maxTokens: MINIMAX_DEFAULT_MAX_TOKENS
|
|
2442
|
+
}, {
|
|
2443
|
+
id: MINIMAX_DEFAULT_VISION_MODEL_ID,
|
|
2444
|
+
name: "MiniMax VL 01",
|
|
2445
|
+
reasoning: false,
|
|
2446
|
+
input: ["text", "image"],
|
|
2447
|
+
cost: MINIMAX_API_COST,
|
|
2448
|
+
contextWindow: MINIMAX_DEFAULT_CONTEXT_WINDOW,
|
|
2449
|
+
maxTokens: MINIMAX_DEFAULT_MAX_TOKENS
|
|
2450
|
+
}]
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2453
|
+
function buildMinimaxPortalProvider() {
|
|
2454
|
+
return {
|
|
2455
|
+
baseUrl: MINIMAX_PORTAL_BASE_URL,
|
|
2456
|
+
api: "anthropic-messages",
|
|
2457
|
+
models: [{
|
|
2458
|
+
id: MINIMAX_DEFAULT_MODEL_ID,
|
|
2459
|
+
name: "MiniMax M2.1",
|
|
2460
|
+
reasoning: false,
|
|
2461
|
+
input: ["text"],
|
|
2462
|
+
cost: MINIMAX_API_COST,
|
|
2463
|
+
contextWindow: MINIMAX_DEFAULT_CONTEXT_WINDOW,
|
|
2464
|
+
maxTokens: MINIMAX_DEFAULT_MAX_TOKENS
|
|
2465
|
+
}]
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
function buildMoonshotProvider() {
|
|
2469
|
+
return {
|
|
2470
|
+
baseUrl: MOONSHOT_BASE_URL,
|
|
2471
|
+
api: "openai-completions",
|
|
2472
|
+
models: [{
|
|
2473
|
+
id: MOONSHOT_DEFAULT_MODEL_ID,
|
|
2474
|
+
name: "Kimi K2.5",
|
|
2475
|
+
reasoning: false,
|
|
2476
|
+
input: ["text"],
|
|
2477
|
+
cost: MOONSHOT_DEFAULT_COST,
|
|
2478
|
+
contextWindow: MOONSHOT_DEFAULT_CONTEXT_WINDOW,
|
|
2479
|
+
maxTokens: MOONSHOT_DEFAULT_MAX_TOKENS
|
|
2480
|
+
}]
|
|
2481
|
+
};
|
|
2482
|
+
}
|
|
2483
|
+
function buildCaptainAppProvider(apiKey) {
|
|
2484
|
+
const [userId, userKey] = apiKey.includes(":") ? apiKey.split(":", 2) : [void 0, apiKey];
|
|
2485
|
+
return {
|
|
2486
|
+
baseUrl: CAPTAINAPP_BASE_URL,
|
|
2487
|
+
api: "openai-completions",
|
|
2488
|
+
apiKey: userKey || apiKey,
|
|
2489
|
+
headers: userId ? {
|
|
2490
|
+
"X-CaptainApp-User-ID": userId,
|
|
2491
|
+
"X-CaptainApp-User-Key": userKey || apiKey
|
|
2492
|
+
} : void 0,
|
|
2493
|
+
models: [{
|
|
2494
|
+
id: CAPTAINAPP_DEFAULT_MODEL_ID,
|
|
2495
|
+
name: "Kimi K2.5 (Metered)",
|
|
2496
|
+
reasoning: false,
|
|
2497
|
+
input: ["text"],
|
|
2498
|
+
cost: CAPTAINAPP_DEFAULT_COST,
|
|
2499
|
+
contextWindow: CAPTAINAPP_DEFAULT_CONTEXT_WINDOW,
|
|
2500
|
+
maxTokens: CAPTAINAPP_DEFAULT_MAX_TOKENS
|
|
2501
|
+
}]
|
|
2502
|
+
};
|
|
2503
|
+
}
|
|
2504
|
+
function buildQwenPortalProvider() {
|
|
2505
|
+
return {
|
|
2506
|
+
baseUrl: QWEN_PORTAL_BASE_URL,
|
|
2507
|
+
api: "openai-completions",
|
|
2508
|
+
models: [{
|
|
2509
|
+
id: "coder-model",
|
|
2510
|
+
name: "Qwen Coder",
|
|
2511
|
+
reasoning: false,
|
|
2512
|
+
input: ["text"],
|
|
2513
|
+
cost: QWEN_PORTAL_DEFAULT_COST,
|
|
2514
|
+
contextWindow: QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW,
|
|
2515
|
+
maxTokens: QWEN_PORTAL_DEFAULT_MAX_TOKENS
|
|
2516
|
+
}, {
|
|
2517
|
+
id: "vision-model",
|
|
2518
|
+
name: "Qwen Vision",
|
|
2519
|
+
reasoning: false,
|
|
2520
|
+
input: ["text", "image"],
|
|
2521
|
+
cost: QWEN_PORTAL_DEFAULT_COST,
|
|
2522
|
+
contextWindow: QWEN_PORTAL_DEFAULT_CONTEXT_WINDOW,
|
|
2523
|
+
maxTokens: QWEN_PORTAL_DEFAULT_MAX_TOKENS
|
|
2524
|
+
}]
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
function buildSyntheticProvider() {
|
|
2528
|
+
return {
|
|
2529
|
+
baseUrl: SYNTHETIC_BASE_URL,
|
|
2530
|
+
api: "anthropic-messages",
|
|
2531
|
+
models: SYNTHETIC_MODEL_CATALOG.map(buildSyntheticModelDefinition)
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
function buildXiaomiProvider() {
|
|
2535
|
+
return {
|
|
2536
|
+
baseUrl: XIAOMI_BASE_URL,
|
|
2537
|
+
api: "anthropic-messages",
|
|
2538
|
+
models: [{
|
|
2539
|
+
id: XIAOMI_DEFAULT_MODEL_ID,
|
|
2540
|
+
name: "Xiaomi MiMo V2 Flash",
|
|
2541
|
+
reasoning: false,
|
|
2542
|
+
input: ["text"],
|
|
2543
|
+
cost: XIAOMI_DEFAULT_COST,
|
|
2544
|
+
contextWindow: XIAOMI_DEFAULT_CONTEXT_WINDOW,
|
|
2545
|
+
maxTokens: XIAOMI_DEFAULT_MAX_TOKENS
|
|
2546
|
+
}]
|
|
2547
|
+
};
|
|
2548
|
+
}
|
|
2549
|
+
async function buildVeniceProvider() {
|
|
2550
|
+
return {
|
|
2551
|
+
baseUrl: VENICE_BASE_URL,
|
|
2552
|
+
api: "openai-completions",
|
|
2553
|
+
models: await discoverVeniceModels()
|
|
2554
|
+
};
|
|
2555
|
+
}
|
|
2556
|
+
async function buildOllamaProvider() {
|
|
2557
|
+
return {
|
|
2558
|
+
baseUrl: OLLAMA_BASE_URL,
|
|
2559
|
+
api: "openai-completions",
|
|
2560
|
+
models: await discoverOllamaModels()
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2563
|
+
async function resolveImplicitProviders(params) {
|
|
2564
|
+
const providers = {};
|
|
2565
|
+
const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
2566
|
+
const minimaxKey = resolveEnvApiKeyVarName("minimax") ?? resolveApiKeyFromProfiles({
|
|
2567
|
+
provider: "minimax",
|
|
2568
|
+
store: authStore
|
|
2569
|
+
});
|
|
2570
|
+
if (minimaxKey) providers.minimax = {
|
|
2571
|
+
...buildMinimaxProvider(),
|
|
2572
|
+
apiKey: minimaxKey
|
|
2573
|
+
};
|
|
2574
|
+
if (listProfilesForProvider(authStore, "minimax-portal").length > 0) providers["minimax-portal"] = {
|
|
2575
|
+
...buildMinimaxPortalProvider(),
|
|
2576
|
+
apiKey: MINIMAX_OAUTH_PLACEHOLDER
|
|
2577
|
+
};
|
|
2578
|
+
const moonshotKey = resolveEnvApiKeyVarName("moonshot") ?? resolveApiKeyFromProfiles({
|
|
2579
|
+
provider: "moonshot",
|
|
2580
|
+
store: authStore
|
|
2581
|
+
});
|
|
2582
|
+
if (moonshotKey) providers.moonshot = {
|
|
2583
|
+
...buildMoonshotProvider(),
|
|
2584
|
+
apiKey: moonshotKey
|
|
2585
|
+
};
|
|
2586
|
+
const captainappKey = resolveEnvApiKeyVarName("captainapp") ?? resolveApiKeyFromProfiles({
|
|
2587
|
+
provider: "captainapp",
|
|
2588
|
+
store: authStore
|
|
2589
|
+
});
|
|
2590
|
+
if (captainappKey) providers.captainapp = buildCaptainAppProvider(captainappKey);
|
|
2591
|
+
const syntheticKey = resolveEnvApiKeyVarName("synthetic") ?? resolveApiKeyFromProfiles({
|
|
2592
|
+
provider: "synthetic",
|
|
2593
|
+
store: authStore
|
|
2594
|
+
});
|
|
2595
|
+
if (syntheticKey) providers.synthetic = {
|
|
2596
|
+
...buildSyntheticProvider(),
|
|
2597
|
+
apiKey: syntheticKey
|
|
2598
|
+
};
|
|
2599
|
+
const veniceKey = resolveEnvApiKeyVarName("venice") ?? resolveApiKeyFromProfiles({
|
|
2600
|
+
provider: "venice",
|
|
2601
|
+
store: authStore
|
|
2602
|
+
});
|
|
2603
|
+
if (veniceKey) providers.venice = {
|
|
2604
|
+
...await buildVeniceProvider(),
|
|
2605
|
+
apiKey: veniceKey
|
|
2606
|
+
};
|
|
2607
|
+
if (listProfilesForProvider(authStore, "qwen-portal").length > 0) providers["qwen-portal"] = {
|
|
2608
|
+
...buildQwenPortalProvider(),
|
|
2609
|
+
apiKey: QWEN_PORTAL_OAUTH_PLACEHOLDER
|
|
2610
|
+
};
|
|
2611
|
+
const xiaomiKey = resolveEnvApiKeyVarName("xiaomi") ?? resolveApiKeyFromProfiles({
|
|
2612
|
+
provider: "xiaomi",
|
|
2613
|
+
store: authStore
|
|
2614
|
+
});
|
|
2615
|
+
if (xiaomiKey) providers.xiaomi = {
|
|
2616
|
+
...buildXiaomiProvider(),
|
|
2617
|
+
apiKey: xiaomiKey
|
|
2618
|
+
};
|
|
2619
|
+
const cloudflareProfiles = listProfilesForProvider(authStore, "cloudflare-ai-gateway");
|
|
2620
|
+
for (const profileId of cloudflareProfiles) {
|
|
2621
|
+
const cred = authStore.profiles[profileId];
|
|
2622
|
+
if (cred?.type !== "api_key") continue;
|
|
2623
|
+
const accountId = cred.metadata?.accountId?.trim();
|
|
2624
|
+
const gatewayId = cred.metadata?.gatewayId?.trim();
|
|
2625
|
+
if (!accountId || !gatewayId) continue;
|
|
2626
|
+
const baseUrl = resolveCloudflareAiGatewayBaseUrl({
|
|
2627
|
+
accountId,
|
|
2628
|
+
gatewayId
|
|
2629
|
+
});
|
|
2630
|
+
if (!baseUrl) continue;
|
|
2631
|
+
const apiKey = resolveEnvApiKeyVarName("cloudflare-ai-gateway") ?? cred.key?.trim() ?? "";
|
|
2632
|
+
if (!apiKey) continue;
|
|
2633
|
+
providers["cloudflare-ai-gateway"] = {
|
|
2634
|
+
baseUrl,
|
|
2635
|
+
api: "anthropic-messages",
|
|
2636
|
+
apiKey,
|
|
2637
|
+
models: [buildCloudflareAiGatewayModelDefinition()]
|
|
2638
|
+
};
|
|
2639
|
+
break;
|
|
2640
|
+
}
|
|
2641
|
+
const ollamaKey = resolveEnvApiKeyVarName("ollama") ?? resolveApiKeyFromProfiles({
|
|
2642
|
+
provider: "ollama",
|
|
2643
|
+
store: authStore
|
|
2644
|
+
});
|
|
2645
|
+
if (ollamaKey) providers.ollama = {
|
|
2646
|
+
...await buildOllamaProvider(),
|
|
2647
|
+
apiKey: ollamaKey
|
|
2648
|
+
};
|
|
2649
|
+
return providers;
|
|
2650
|
+
}
|
|
2651
|
+
async function resolveImplicitCopilotProvider(params) {
|
|
2652
|
+
const env = params.env ?? process.env;
|
|
2653
|
+
const authStore = ensureAuthProfileStore(params.agentDir, { allowKeychainPrompt: false });
|
|
2654
|
+
const hasProfile = listProfilesForProvider(authStore, "github-copilot").length > 0;
|
|
2655
|
+
const githubToken = (env.COPILOT_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN ?? "").trim();
|
|
2656
|
+
if (!hasProfile && !githubToken) return null;
|
|
2657
|
+
let selectedGithubToken = githubToken;
|
|
2658
|
+
if (!selectedGithubToken && hasProfile) {
|
|
2659
|
+
const profileId = listProfilesForProvider(authStore, "github-copilot")[0];
|
|
2660
|
+
const profile = profileId ? authStore.profiles[profileId] : void 0;
|
|
2661
|
+
if (profile && profile.type === "token") selectedGithubToken = profile.token;
|
|
2662
|
+
}
|
|
2663
|
+
let baseUrl = DEFAULT_COPILOT_API_BASE_URL;
|
|
2664
|
+
if (selectedGithubToken) try {
|
|
2665
|
+
baseUrl = (await resolveCopilotApiToken({
|
|
2666
|
+
githubToken: selectedGithubToken,
|
|
2667
|
+
env
|
|
2668
|
+
})).baseUrl;
|
|
2669
|
+
} catch {
|
|
2670
|
+
baseUrl = DEFAULT_COPILOT_API_BASE_URL;
|
|
2671
|
+
}
|
|
2672
|
+
return {
|
|
2673
|
+
baseUrl,
|
|
2674
|
+
models: []
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
async function resolveImplicitBedrockProvider(params) {
|
|
2678
|
+
const env = params.env ?? process.env;
|
|
2679
|
+
const discoveryConfig = params.config?.models?.bedrockDiscovery;
|
|
2680
|
+
const enabled = discoveryConfig?.enabled;
|
|
2681
|
+
const hasAwsCreds = resolveAwsSdkEnvVarName(env) !== void 0;
|
|
2682
|
+
if (enabled === false) return null;
|
|
2683
|
+
if (enabled !== true && !hasAwsCreds) return null;
|
|
2684
|
+
const region = discoveryConfig?.region ?? env.AWS_REGION ?? env.AWS_DEFAULT_REGION ?? "us-east-1";
|
|
2685
|
+
const models = await discoverBedrockModels({
|
|
2686
|
+
region,
|
|
2687
|
+
config: discoveryConfig
|
|
2688
|
+
});
|
|
2689
|
+
if (models.length === 0) return null;
|
|
2690
|
+
return {
|
|
2691
|
+
baseUrl: `https://bedrock-runtime.${region}.amazonaws.com`,
|
|
2692
|
+
api: "bedrock-converse-stream",
|
|
2693
|
+
auth: "aws-sdk",
|
|
2694
|
+
models
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
//#endregion
|
|
2699
|
+
//#region src/agents/model-selection.ts
|
|
2700
|
+
function normalizeAliasKey(value) {
|
|
2701
|
+
return value.trim().toLowerCase();
|
|
2702
|
+
}
|
|
2703
|
+
function modelKey(provider, model) {
|
|
2704
|
+
return `${provider}/${model}`;
|
|
2705
|
+
}
|
|
2706
|
+
function normalizeProviderId(provider) {
|
|
2707
|
+
const normalized = provider.trim().toLowerCase();
|
|
2708
|
+
if (normalized === "z.ai" || normalized === "z-ai") return "zai";
|
|
2709
|
+
if (normalized === "opencode-zen") return "opencode";
|
|
2710
|
+
if (normalized === "qwen") return "qwen-portal";
|
|
2711
|
+
if (normalized === "kimi-code") return "kimi-coding";
|
|
2712
|
+
return normalized;
|
|
2713
|
+
}
|
|
2714
|
+
function isCliProvider(provider, cfg) {
|
|
2715
|
+
const normalized = normalizeProviderId(provider);
|
|
2716
|
+
if (normalized === "claude-cli") return true;
|
|
2717
|
+
if (normalized === "codex-cli") return true;
|
|
2718
|
+
const backends = cfg?.agents?.defaults?.cliBackends ?? {};
|
|
2719
|
+
return Object.keys(backends).some((key) => normalizeProviderId(key) === normalized);
|
|
2720
|
+
}
|
|
2721
|
+
function normalizeAnthropicModelId(model) {
|
|
2722
|
+
const trimmed = model.trim();
|
|
2723
|
+
if (!trimmed) return trimmed;
|
|
2724
|
+
const lower = trimmed.toLowerCase();
|
|
2725
|
+
if (lower === "opus-4.5") return "claude-opus-4-5";
|
|
2726
|
+
if (lower === "sonnet-4.5") return "claude-sonnet-4-5";
|
|
2727
|
+
return trimmed;
|
|
2728
|
+
}
|
|
2729
|
+
function normalizeProviderModelId(provider, model) {
|
|
2730
|
+
if (provider === "anthropic") return normalizeAnthropicModelId(model);
|
|
2731
|
+
if (provider === "google") return normalizeGoogleModelId(model);
|
|
2732
|
+
return model;
|
|
2733
|
+
}
|
|
2734
|
+
function parseModelRef(raw, defaultProvider) {
|
|
2735
|
+
const trimmed = raw.trim();
|
|
2736
|
+
if (!trimmed) return null;
|
|
2737
|
+
const slash = trimmed.indexOf("/");
|
|
2738
|
+
if (slash === -1) {
|
|
2739
|
+
const provider = normalizeProviderId(defaultProvider);
|
|
2740
|
+
return {
|
|
2741
|
+
provider,
|
|
2742
|
+
model: normalizeProviderModelId(provider, trimmed)
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
const provider = normalizeProviderId(trimmed.slice(0, slash).trim());
|
|
2746
|
+
const model = trimmed.slice(slash + 1).trim();
|
|
2747
|
+
if (!provider || !model) return null;
|
|
2748
|
+
return {
|
|
2749
|
+
provider,
|
|
2750
|
+
model: normalizeProviderModelId(provider, model)
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
function buildModelAliasIndex(params) {
|
|
2754
|
+
const byAlias = /* @__PURE__ */ new Map();
|
|
2755
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
2756
|
+
const rawModels = params.cfg.agents?.defaults?.models ?? {};
|
|
2757
|
+
for (const [keyRaw, entryRaw] of Object.entries(rawModels)) {
|
|
2758
|
+
const parsed = parseModelRef(String(keyRaw ?? ""), params.defaultProvider);
|
|
2759
|
+
if (!parsed) continue;
|
|
2760
|
+
const alias = String(entryRaw?.alias ?? "").trim();
|
|
2761
|
+
if (!alias) continue;
|
|
2762
|
+
const aliasKey = normalizeAliasKey(alias);
|
|
2763
|
+
byAlias.set(aliasKey, {
|
|
2764
|
+
alias,
|
|
2765
|
+
ref: parsed
|
|
2766
|
+
});
|
|
2767
|
+
const key = modelKey(parsed.provider, parsed.model);
|
|
2768
|
+
const existing = byKey.get(key) ?? [];
|
|
2769
|
+
existing.push(alias);
|
|
2770
|
+
byKey.set(key, existing);
|
|
2771
|
+
}
|
|
2772
|
+
return {
|
|
2773
|
+
byAlias,
|
|
2774
|
+
byKey
|
|
2775
|
+
};
|
|
2776
|
+
}
|
|
2777
|
+
function resolveModelRefFromString(params) {
|
|
2778
|
+
const trimmed = params.raw.trim();
|
|
2779
|
+
if (!trimmed) return null;
|
|
2780
|
+
if (!trimmed.includes("/")) {
|
|
2781
|
+
const aliasKey = normalizeAliasKey(trimmed);
|
|
2782
|
+
const aliasMatch = params.aliasIndex?.byAlias.get(aliasKey);
|
|
2783
|
+
if (aliasMatch) return {
|
|
2784
|
+
ref: aliasMatch.ref,
|
|
2785
|
+
alias: aliasMatch.alias
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
const parsed = parseModelRef(trimmed, params.defaultProvider);
|
|
2789
|
+
if (!parsed) return null;
|
|
2790
|
+
return { ref: parsed };
|
|
2791
|
+
}
|
|
2792
|
+
function resolveConfiguredModelRef(params) {
|
|
2793
|
+
const rawModel = (() => {
|
|
2794
|
+
const raw = params.cfg.agents?.defaults?.model;
|
|
2795
|
+
if (typeof raw === "string") return raw.trim();
|
|
2796
|
+
return raw?.primary?.trim() ?? "";
|
|
2797
|
+
})();
|
|
2798
|
+
if (rawModel) {
|
|
2799
|
+
const trimmed = rawModel.trim();
|
|
2800
|
+
const aliasIndex = buildModelAliasIndex({
|
|
2801
|
+
cfg: params.cfg,
|
|
2802
|
+
defaultProvider: params.defaultProvider
|
|
2803
|
+
});
|
|
2804
|
+
if (!trimmed.includes("/")) {
|
|
2805
|
+
const aliasKey = normalizeAliasKey(trimmed);
|
|
2806
|
+
const aliasMatch = aliasIndex.byAlias.get(aliasKey);
|
|
2807
|
+
if (aliasMatch) return aliasMatch.ref;
|
|
2808
|
+
console.warn(`[openclaw] Model "${trimmed}" specified without provider. Falling back to "anthropic/${trimmed}". Please use "anthropic/${trimmed}" in your config.`);
|
|
2809
|
+
return {
|
|
2810
|
+
provider: "anthropic",
|
|
2811
|
+
model: trimmed
|
|
2812
|
+
};
|
|
2813
|
+
}
|
|
2814
|
+
const resolved = resolveModelRefFromString({
|
|
2815
|
+
raw: trimmed,
|
|
2816
|
+
defaultProvider: params.defaultProvider,
|
|
2817
|
+
aliasIndex
|
|
2818
|
+
});
|
|
2819
|
+
if (resolved) return resolved.ref;
|
|
2820
|
+
}
|
|
2821
|
+
return {
|
|
2822
|
+
provider: params.defaultProvider,
|
|
2823
|
+
model: params.defaultModel
|
|
2824
|
+
};
|
|
2825
|
+
}
|
|
2826
|
+
function resolveDefaultModelForAgent(params) {
|
|
2827
|
+
const agentModelOverride = params.agentId ? resolveAgentModelPrimary(params.cfg, params.agentId) : void 0;
|
|
2828
|
+
return resolveConfiguredModelRef({
|
|
2829
|
+
cfg: agentModelOverride && agentModelOverride.length > 0 ? {
|
|
2830
|
+
...params.cfg,
|
|
2831
|
+
agents: {
|
|
2832
|
+
...params.cfg.agents,
|
|
2833
|
+
defaults: {
|
|
2834
|
+
...params.cfg.agents?.defaults,
|
|
2835
|
+
model: {
|
|
2836
|
+
...typeof params.cfg.agents?.defaults?.model === "object" ? params.cfg.agents.defaults.model : void 0,
|
|
2837
|
+
primary: agentModelOverride
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
} : params.cfg,
|
|
2842
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2843
|
+
defaultModel: DEFAULT_MODEL
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
function buildAllowedModelSet(params) {
|
|
2847
|
+
const rawAllowlist = (() => {
|
|
2848
|
+
const modelMap = params.cfg.agents?.defaults?.models ?? {};
|
|
2849
|
+
return Object.keys(modelMap);
|
|
2850
|
+
})();
|
|
2851
|
+
const allowAny = rawAllowlist.length === 0;
|
|
2852
|
+
const defaultModel = params.defaultModel?.trim();
|
|
2853
|
+
const defaultKey = defaultModel && params.defaultProvider ? modelKey(params.defaultProvider, defaultModel) : void 0;
|
|
2854
|
+
const catalogKeys = new Set(params.catalog.map((entry) => modelKey(entry.provider, entry.id)));
|
|
2855
|
+
if (allowAny) {
|
|
2856
|
+
if (defaultKey) catalogKeys.add(defaultKey);
|
|
2857
|
+
return {
|
|
2858
|
+
allowAny: true,
|
|
2859
|
+
allowedCatalog: params.catalog,
|
|
2860
|
+
allowedKeys: catalogKeys
|
|
2861
|
+
};
|
|
2862
|
+
}
|
|
2863
|
+
const allowedKeys = /* @__PURE__ */ new Set();
|
|
2864
|
+
const configuredProviders = params.cfg.models?.providers ?? {};
|
|
2865
|
+
for (const raw of rawAllowlist) {
|
|
2866
|
+
const parsed = parseModelRef(String(raw), params.defaultProvider);
|
|
2867
|
+
if (!parsed) continue;
|
|
2868
|
+
const key = modelKey(parsed.provider, parsed.model);
|
|
2869
|
+
const providerKey = normalizeProviderId(parsed.provider);
|
|
2870
|
+
if (isCliProvider(parsed.provider, params.cfg)) allowedKeys.add(key);
|
|
2871
|
+
else if (catalogKeys.has(key)) allowedKeys.add(key);
|
|
2872
|
+
else if (configuredProviders[providerKey] != null) allowedKeys.add(key);
|
|
2873
|
+
}
|
|
2874
|
+
if (defaultKey) allowedKeys.add(defaultKey);
|
|
2875
|
+
const allowedCatalog = params.catalog.filter((entry) => allowedKeys.has(modelKey(entry.provider, entry.id)));
|
|
2876
|
+
if (allowedCatalog.length === 0 && allowedKeys.size === 0) {
|
|
2877
|
+
if (defaultKey) catalogKeys.add(defaultKey);
|
|
2878
|
+
return {
|
|
2879
|
+
allowAny: true,
|
|
2880
|
+
allowedCatalog: params.catalog,
|
|
2881
|
+
allowedKeys: catalogKeys
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
return {
|
|
2885
|
+
allowAny: false,
|
|
2886
|
+
allowedCatalog,
|
|
2887
|
+
allowedKeys
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
function getModelRefStatus(params) {
|
|
2891
|
+
const allowed = buildAllowedModelSet({
|
|
2892
|
+
cfg: params.cfg,
|
|
2893
|
+
catalog: params.catalog,
|
|
2894
|
+
defaultProvider: params.defaultProvider,
|
|
2895
|
+
defaultModel: params.defaultModel
|
|
2896
|
+
});
|
|
2897
|
+
const key = modelKey(params.ref.provider, params.ref.model);
|
|
2898
|
+
return {
|
|
2899
|
+
key,
|
|
2900
|
+
inCatalog: params.catalog.some((entry) => modelKey(entry.provider, entry.id) === key),
|
|
2901
|
+
allowAny: allowed.allowAny,
|
|
2902
|
+
allowed: allowed.allowAny || allowed.allowedKeys.has(key)
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
function resolveAllowedModelRef(params) {
|
|
2906
|
+
const trimmed = params.raw.trim();
|
|
2907
|
+
if (!trimmed) return { error: "invalid model: empty" };
|
|
2908
|
+
const aliasIndex = buildModelAliasIndex({
|
|
2909
|
+
cfg: params.cfg,
|
|
2910
|
+
defaultProvider: params.defaultProvider
|
|
2911
|
+
});
|
|
2912
|
+
const resolved = resolveModelRefFromString({
|
|
2913
|
+
raw: trimmed,
|
|
2914
|
+
defaultProvider: params.defaultProvider,
|
|
2915
|
+
aliasIndex
|
|
2916
|
+
});
|
|
2917
|
+
if (!resolved) return { error: `invalid model: ${trimmed}` };
|
|
2918
|
+
const status = getModelRefStatus({
|
|
2919
|
+
cfg: params.cfg,
|
|
2920
|
+
catalog: params.catalog,
|
|
2921
|
+
ref: resolved.ref,
|
|
2922
|
+
defaultProvider: params.defaultProvider,
|
|
2923
|
+
defaultModel: params.defaultModel
|
|
2924
|
+
});
|
|
2925
|
+
if (!status.allowed) return { error: `model not allowed: ${status.key}` };
|
|
2926
|
+
return {
|
|
2927
|
+
ref: resolved.ref,
|
|
2928
|
+
key: status.key
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2931
|
+
function resolveThinkingDefault(params) {
|
|
2932
|
+
const configured = params.cfg.agents?.defaults?.thinkingDefault;
|
|
2933
|
+
if (configured) return configured;
|
|
2934
|
+
if ((params.catalog?.find((entry) => entry.provider === params.provider && entry.id === params.model))?.reasoning) return "low";
|
|
2935
|
+
return "off";
|
|
2936
|
+
}
|
|
2937
|
+
/**
|
|
2938
|
+
* Resolve the model configured for Gmail hook processing.
|
|
2939
|
+
* Returns null if hooks.gmail.model is not set.
|
|
2940
|
+
*/
|
|
2941
|
+
function resolveHooksGmailModel(params) {
|
|
2942
|
+
const hooksModel = params.cfg.hooks?.gmail?.model;
|
|
2943
|
+
if (!hooksModel?.trim()) return null;
|
|
2944
|
+
const aliasIndex = buildModelAliasIndex({
|
|
2945
|
+
cfg: params.cfg,
|
|
2946
|
+
defaultProvider: params.defaultProvider
|
|
2947
|
+
});
|
|
2948
|
+
return resolveModelRefFromString({
|
|
2949
|
+
raw: hooksModel,
|
|
2950
|
+
defaultProvider: params.defaultProvider,
|
|
2951
|
+
aliasIndex
|
|
2952
|
+
})?.ref ?? null;
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
//#endregion
|
|
2956
|
+
export { exchangeChutesCodeForTokens as $, getCustomProviderApiKey as A, shouldDeferShellEnvFallback as B, VENICE_MODEL_CATALOG as C, SYNTHETIC_MODEL_CATALOG as D, SYNTHETIC_DEFAULT_MODEL_REF as E, resolveModelAuthMode as F, auth_profiles_exports as G, CLOUDFLARE_AI_GATEWAY_DEFAULT_MODEL_REF as H, getShellEnvAppliedKeys as I, markAuthProfileFailure as J, resolveAuthProfileOrder as K, getShellPathFromLoginShell as L, resolveApiKeyForProvider as M, resolveAwsSdkEnvVarName as N, buildSyntheticModelDefinition as O, resolveEnvApiKey as P, CHUTES_AUTHORIZE_ENDPOINT as Q, loadShellEnvFallback as R, VENICE_DEFAULT_MODEL_REF as S, SYNTHETIC_BASE_URL as T, buildCloudflareAiGatewayModelDefinition as U, shouldEnableShellEnvFallback as V, resolveCloudflareAiGatewayBaseUrl as W, resolveProfileUnusableUntilForDisplay as X, markAuthProfileUsed as Y, resolveApiKeyForProfile as Z, normalizeProviders as _, DEFAULT_MODEL as _t, modelKey as a, setAuthProfileOrder as at, resolveImplicitProviders as b, resolveAllowedModelRef as c, loadAuthProfileStore as ct, resolveHooksGmailModel as d, resolveAuthStorePathForDisplay as dt, generateChutesPkce as et, resolveModelRefFromString as f, resolveOpenClawAgentDir as ft, normalizeGoogleModelId as g, DEFAULT_CONTEXT_TOKENS as gt, buildXiaomiProvider as h, CODEX_CLI_PROFILE_ID as ht, isCliProvider as i, markAuthProfileGood as it, requireApiKey as j, getApiKeyForModel as k, resolveConfiguredModelRef as l, updateAuthProfileStoreWithLock as lt, XIAOMI_DEFAULT_MODEL_ID as m, CLAUDE_CLI_PROFILE_ID as mt, buildModelAliasIndex as n, repairOAuthProfileIdMismatch as nt, normalizeProviderId as o, upsertAuthProfile as ot, resolveThinkingDefault as p, resolveAuthProfileDisplayLabel as pt, isProfileInCooldown as q, getModelRefStatus as r, listProfilesForProvider as rt, parseModelRef as s, ensureAuthProfileStore as st, buildAllowedModelSet as t, parseOAuthCallbackInput as tt, resolveDefaultModelForAgent as u, resolveAuthStorePath as ut, resolveImplicitBedrockProvider as v, DEFAULT_PROVIDER as vt, buildVeniceModelDefinition as w, VENICE_BASE_URL as x, resolveImplicitCopilotProvider as y, resolveShellEnvFallbackTimeoutMs as z };
|