@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,4881 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
|
|
2
|
+
import { B as resolveConfigPath, F as CONFIG_PATH, G as resolveIsNixMode, H as resolveDefaultConfigCandidates, I as DEFAULT_GATEWAY_PORT, J as resolveOAuthDir, K as resolveLegacyStateDirs, L as STATE_DIR, R as isNixMode, U as resolveGatewayLockDir, V as resolveConfigPathCandidate, W as resolveGatewayPort, X as resolveStateDir, Y as resolveOAuthPath, Z as CHANNEL_IDS, ot as normalizeChatChannelId, q as resolveNewStateDir, z as resolveCanonicalConfigPath } from "./entry.js";
|
|
3
|
+
import { ct as shouldDeferShellEnvFallback, k as parseModelRef, lt as shouldEnableShellEnvFallback, ot as loadShellEnvFallback, pt as DEFAULT_CONTEXT_TOKENS, st as resolveShellEnvFallbackTimeoutMs } from "./auth-profiles-DVLfuixr.js";
|
|
4
|
+
import { D as DEFAULT_AGENT_ID, N as normalizeAgentId, c as resolveDefaultAgentId, s as resolveAgentWorkspaceDir } from "./agent-scope-C_O6Vpl0.js";
|
|
5
|
+
import { m as resolveUserPath } from "./utils-DX85MiPR.js";
|
|
6
|
+
import { c as resolveEnableState, l as resolveMemorySlotDecision, s as normalizePluginsConfig, t as loadPluginManifestRegistry } from "./manifest-registry-Bwjq9Iev.js";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import os from "node:os";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import JSON5 from "json5";
|
|
12
|
+
import crypto from "node:crypto";
|
|
13
|
+
import AjvPkg from "ajv";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
|
|
16
|
+
//#region src/version.ts
|
|
17
|
+
function readVersionFromPackageJson() {
|
|
18
|
+
try {
|
|
19
|
+
return createRequire(import.meta.url)("../package.json").version ?? null;
|
|
20
|
+
} catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function readVersionFromBuildInfo() {
|
|
25
|
+
try {
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
27
|
+
for (const candidate of ["../build-info.json", "./build-info.json"]) try {
|
|
28
|
+
const info = require(candidate);
|
|
29
|
+
if (info.version) return info.version;
|
|
30
|
+
} catch {}
|
|
31
|
+
return null;
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const VERSION = typeof __OPENCLAW_VERSION__ === "string" && __OPENCLAW_VERSION__ || process.env.OPENCLAW_BUNDLED_VERSION || readVersionFromPackageJson() || readVersionFromBuildInfo() || "0.0.0";
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/config/agent-dirs.ts
|
|
40
|
+
var DuplicateAgentDirError = class extends Error {
|
|
41
|
+
constructor(duplicates) {
|
|
42
|
+
super(formatDuplicateAgentDirError(duplicates));
|
|
43
|
+
this.name = "DuplicateAgentDirError";
|
|
44
|
+
this.duplicates = duplicates;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
function canonicalizeAgentDir(agentDir) {
|
|
48
|
+
const resolved = path.resolve(agentDir);
|
|
49
|
+
if (process.platform === "darwin" || process.platform === "win32") return resolved.toLowerCase();
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
52
|
+
function collectReferencedAgentIds(cfg) {
|
|
53
|
+
const ids = /* @__PURE__ */ new Set();
|
|
54
|
+
const agents = Array.isArray(cfg.agents?.list) ? cfg.agents?.list : [];
|
|
55
|
+
const defaultAgentId = agents.find((agent) => agent?.default)?.id ?? agents[0]?.id ?? DEFAULT_AGENT_ID;
|
|
56
|
+
ids.add(normalizeAgentId(defaultAgentId));
|
|
57
|
+
for (const entry of agents) if (entry?.id) ids.add(normalizeAgentId(entry.id));
|
|
58
|
+
const bindings = cfg.bindings;
|
|
59
|
+
if (Array.isArray(bindings)) for (const binding of bindings) {
|
|
60
|
+
const id = binding?.agentId;
|
|
61
|
+
if (typeof id === "string" && id.trim()) ids.add(normalizeAgentId(id));
|
|
62
|
+
}
|
|
63
|
+
return [...ids];
|
|
64
|
+
}
|
|
65
|
+
function resolveEffectiveAgentDir(cfg, agentId, deps) {
|
|
66
|
+
const id = normalizeAgentId(agentId);
|
|
67
|
+
const trimmed = (Array.isArray(cfg.agents?.list) ? cfg.agents?.list.find((agent) => normalizeAgentId(agent.id) === id)?.agentDir : void 0)?.trim();
|
|
68
|
+
if (trimmed) return resolveUserPath(trimmed);
|
|
69
|
+
const root = resolveStateDir(deps?.env ?? process.env, deps?.homedir ?? os.homedir);
|
|
70
|
+
return path.join(root, "agents", id, "agent");
|
|
71
|
+
}
|
|
72
|
+
function findDuplicateAgentDirs(cfg, deps) {
|
|
73
|
+
const byDir = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const agentId of collectReferencedAgentIds(cfg)) {
|
|
75
|
+
const agentDir = resolveEffectiveAgentDir(cfg, agentId, deps);
|
|
76
|
+
const key = canonicalizeAgentDir(agentDir);
|
|
77
|
+
const entry = byDir.get(key);
|
|
78
|
+
if (entry) entry.agentIds.push(agentId);
|
|
79
|
+
else byDir.set(key, {
|
|
80
|
+
agentDir,
|
|
81
|
+
agentIds: [agentId]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return [...byDir.values()].filter((v) => v.agentIds.length > 1);
|
|
85
|
+
}
|
|
86
|
+
function formatDuplicateAgentDirError(dups) {
|
|
87
|
+
return [
|
|
88
|
+
"Duplicate agentDir detected (multi-agent config).",
|
|
89
|
+
"Each agent must have a unique agentDir; sharing it causes auth/session state collisions and token invalidation.",
|
|
90
|
+
"",
|
|
91
|
+
"Conflicts:",
|
|
92
|
+
...dups.map((d) => `- ${d.agentDir}: ${d.agentIds.map((id) => `"${id}"`).join(", ")}`),
|
|
93
|
+
"",
|
|
94
|
+
"Fix: remove the shared agents.list[].agentDir override (or give each agent its own directory).",
|
|
95
|
+
"If you want to share credentials, copy auth-profiles.json instead of sharing the entire agentDir."
|
|
96
|
+
].join("\n");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/config/agent-limits.ts
|
|
101
|
+
const DEFAULT_AGENT_MAX_CONCURRENT = 4;
|
|
102
|
+
const DEFAULT_SUBAGENT_MAX_CONCURRENT = 8;
|
|
103
|
+
function resolveAgentMaxConcurrent(cfg) {
|
|
104
|
+
const raw = cfg?.agents?.defaults?.maxConcurrent;
|
|
105
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
|
|
106
|
+
return DEFAULT_AGENT_MAX_CONCURRENT;
|
|
107
|
+
}
|
|
108
|
+
function resolveSubagentMaxConcurrent(cfg) {
|
|
109
|
+
const raw = cfg?.agents?.defaults?.subagents?.maxConcurrent;
|
|
110
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
|
|
111
|
+
return DEFAULT_SUBAGENT_MAX_CONCURRENT;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/config/talk.ts
|
|
116
|
+
function readTalkApiKeyFromProfile(deps = {}) {
|
|
117
|
+
const fsImpl = deps.fs ?? fs;
|
|
118
|
+
const osImpl = deps.os ?? os;
|
|
119
|
+
const pathImpl = deps.path ?? path;
|
|
120
|
+
const home = osImpl.homedir();
|
|
121
|
+
const candidates = [
|
|
122
|
+
".profile",
|
|
123
|
+
".zprofile",
|
|
124
|
+
".zshrc",
|
|
125
|
+
".bashrc"
|
|
126
|
+
].map((name) => pathImpl.join(home, name));
|
|
127
|
+
for (const candidate of candidates) {
|
|
128
|
+
if (!fsImpl.existsSync(candidate)) continue;
|
|
129
|
+
try {
|
|
130
|
+
const value = fsImpl.readFileSync(candidate, "utf-8").match(/(?:^|\n)\s*(?:export\s+)?ELEVENLABS_API_KEY\s*=\s*["']?([^\n"']+)["']?/)?.[1]?.trim();
|
|
131
|
+
if (value) return value;
|
|
132
|
+
} catch {}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
function resolveTalkApiKey(env = process.env, deps = {}) {
|
|
137
|
+
const envValue = (env.ELEVENLABS_API_KEY ?? "").trim();
|
|
138
|
+
if (envValue) return envValue;
|
|
139
|
+
return readTalkApiKeyFromProfile(deps);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/config/defaults.ts
|
|
144
|
+
let defaultWarnState = { warned: false };
|
|
145
|
+
const DEFAULT_MODEL_ALIASES = {
|
|
146
|
+
opus: "anthropic/claude-opus-4-5",
|
|
147
|
+
sonnet: "anthropic/claude-sonnet-4-5",
|
|
148
|
+
gpt: "openai/gpt-5.2",
|
|
149
|
+
"gpt-mini": "openai/gpt-5-mini",
|
|
150
|
+
gemini: "google/gemini-3-pro-preview",
|
|
151
|
+
"gemini-flash": "google/gemini-3-flash-preview"
|
|
152
|
+
};
|
|
153
|
+
const DEFAULT_MODEL_COST = {
|
|
154
|
+
input: 0,
|
|
155
|
+
output: 0,
|
|
156
|
+
cacheRead: 0,
|
|
157
|
+
cacheWrite: 0
|
|
158
|
+
};
|
|
159
|
+
const DEFAULT_MODEL_INPUT = ["text"];
|
|
160
|
+
const DEFAULT_MODEL_MAX_TOKENS = 8192;
|
|
161
|
+
function isPositiveNumber(value) {
|
|
162
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
163
|
+
}
|
|
164
|
+
function resolveModelCost(raw) {
|
|
165
|
+
return {
|
|
166
|
+
input: typeof raw?.input === "number" ? raw.input : DEFAULT_MODEL_COST.input,
|
|
167
|
+
output: typeof raw?.output === "number" ? raw.output : DEFAULT_MODEL_COST.output,
|
|
168
|
+
cacheRead: typeof raw?.cacheRead === "number" ? raw.cacheRead : DEFAULT_MODEL_COST.cacheRead,
|
|
169
|
+
cacheWrite: typeof raw?.cacheWrite === "number" ? raw.cacheWrite : DEFAULT_MODEL_COST.cacheWrite
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function resolveAnthropicDefaultAuthMode(cfg) {
|
|
173
|
+
const profiles = cfg.auth?.profiles ?? {};
|
|
174
|
+
const anthropicProfiles = Object.entries(profiles).filter(([, profile]) => profile?.provider === "anthropic");
|
|
175
|
+
const order = cfg.auth?.order?.anthropic ?? [];
|
|
176
|
+
for (const profileId of order) {
|
|
177
|
+
const entry = profiles[profileId];
|
|
178
|
+
if (!entry || entry.provider !== "anthropic") continue;
|
|
179
|
+
if (entry.mode === "api_key") return "api_key";
|
|
180
|
+
if (entry.mode === "oauth" || entry.mode === "token") return "oauth";
|
|
181
|
+
}
|
|
182
|
+
const hasApiKey = anthropicProfiles.some(([, profile]) => profile?.mode === "api_key");
|
|
183
|
+
const hasOauth = anthropicProfiles.some(([, profile]) => profile?.mode === "oauth" || profile?.mode === "token");
|
|
184
|
+
if (hasApiKey && !hasOauth) return "api_key";
|
|
185
|
+
if (hasOauth && !hasApiKey) return "oauth";
|
|
186
|
+
if (process.env.ANTHROPIC_OAUTH_TOKEN?.trim()) return "oauth";
|
|
187
|
+
if (process.env.ANTHROPIC_API_KEY?.trim()) return "api_key";
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
function resolvePrimaryModelRef(raw) {
|
|
191
|
+
if (!raw || typeof raw !== "string") return null;
|
|
192
|
+
const trimmed = raw.trim();
|
|
193
|
+
if (!trimmed) return null;
|
|
194
|
+
return DEFAULT_MODEL_ALIASES[trimmed.toLowerCase()] ?? trimmed;
|
|
195
|
+
}
|
|
196
|
+
function applyMessageDefaults(cfg) {
|
|
197
|
+
const messages = cfg.messages;
|
|
198
|
+
if (messages?.ackReactionScope !== void 0) return cfg;
|
|
199
|
+
const nextMessages = messages ? { ...messages } : {};
|
|
200
|
+
nextMessages.ackReactionScope = "group-mentions";
|
|
201
|
+
return {
|
|
202
|
+
...cfg,
|
|
203
|
+
messages: nextMessages
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function applySessionDefaults(cfg, options = {}) {
|
|
207
|
+
const session = cfg.session;
|
|
208
|
+
if (!session || session.mainKey === void 0) return cfg;
|
|
209
|
+
const trimmed = session.mainKey.trim();
|
|
210
|
+
const warn = options.warn ?? console.warn;
|
|
211
|
+
const warnState = options.warnState ?? defaultWarnState;
|
|
212
|
+
const next = {
|
|
213
|
+
...cfg,
|
|
214
|
+
session: {
|
|
215
|
+
...session,
|
|
216
|
+
mainKey: "main"
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
if (trimmed && trimmed !== "main" && !warnState.warned) {
|
|
220
|
+
warnState.warned = true;
|
|
221
|
+
warn("session.mainKey is ignored; main session is always \"main\".");
|
|
222
|
+
}
|
|
223
|
+
return next;
|
|
224
|
+
}
|
|
225
|
+
function applyTalkApiKey(config) {
|
|
226
|
+
const resolved = resolveTalkApiKey();
|
|
227
|
+
if (!resolved) return config;
|
|
228
|
+
if (config.talk?.apiKey?.trim()) return config;
|
|
229
|
+
return {
|
|
230
|
+
...config,
|
|
231
|
+
talk: {
|
|
232
|
+
...config.talk,
|
|
233
|
+
apiKey: resolved
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function applyModelDefaults(cfg) {
|
|
238
|
+
let mutated = false;
|
|
239
|
+
let nextCfg = cfg;
|
|
240
|
+
const providerConfig = nextCfg.models?.providers;
|
|
241
|
+
if (providerConfig) {
|
|
242
|
+
const nextProviders = { ...providerConfig };
|
|
243
|
+
for (const [providerId, provider] of Object.entries(providerConfig)) {
|
|
244
|
+
const models = provider.models;
|
|
245
|
+
if (!Array.isArray(models) || models.length === 0) continue;
|
|
246
|
+
let providerMutated = false;
|
|
247
|
+
const nextModels = models.map((model) => {
|
|
248
|
+
const raw = model;
|
|
249
|
+
let modelMutated = false;
|
|
250
|
+
const reasoning = typeof raw.reasoning === "boolean" ? raw.reasoning : false;
|
|
251
|
+
if (raw.reasoning !== reasoning) modelMutated = true;
|
|
252
|
+
const input = raw.input ?? [...DEFAULT_MODEL_INPUT];
|
|
253
|
+
if (raw.input === void 0) modelMutated = true;
|
|
254
|
+
const cost = resolveModelCost(raw.cost);
|
|
255
|
+
if (!raw.cost || raw.cost.input !== cost.input || raw.cost.output !== cost.output || raw.cost.cacheRead !== cost.cacheRead || raw.cost.cacheWrite !== cost.cacheWrite) modelMutated = true;
|
|
256
|
+
const contextWindow = isPositiveNumber(raw.contextWindow) ? raw.contextWindow : DEFAULT_CONTEXT_TOKENS;
|
|
257
|
+
if (raw.contextWindow !== contextWindow) modelMutated = true;
|
|
258
|
+
const defaultMaxTokens = Math.min(DEFAULT_MODEL_MAX_TOKENS, contextWindow);
|
|
259
|
+
const maxTokens = isPositiveNumber(raw.maxTokens) ? raw.maxTokens : defaultMaxTokens;
|
|
260
|
+
if (raw.maxTokens !== maxTokens) modelMutated = true;
|
|
261
|
+
if (!modelMutated) return model;
|
|
262
|
+
providerMutated = true;
|
|
263
|
+
return {
|
|
264
|
+
...raw,
|
|
265
|
+
reasoning,
|
|
266
|
+
input,
|
|
267
|
+
cost,
|
|
268
|
+
contextWindow,
|
|
269
|
+
maxTokens
|
|
270
|
+
};
|
|
271
|
+
});
|
|
272
|
+
if (!providerMutated) continue;
|
|
273
|
+
nextProviders[providerId] = {
|
|
274
|
+
...provider,
|
|
275
|
+
models: nextModels
|
|
276
|
+
};
|
|
277
|
+
mutated = true;
|
|
278
|
+
}
|
|
279
|
+
if (mutated) nextCfg = {
|
|
280
|
+
...nextCfg,
|
|
281
|
+
models: {
|
|
282
|
+
...nextCfg.models,
|
|
283
|
+
providers: nextProviders
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
const existingAgent = nextCfg.agents?.defaults;
|
|
288
|
+
if (!existingAgent) return mutated ? nextCfg : cfg;
|
|
289
|
+
const existingModels = existingAgent.models ?? {};
|
|
290
|
+
if (Object.keys(existingModels).length === 0) return mutated ? nextCfg : cfg;
|
|
291
|
+
const nextModels = { ...existingModels };
|
|
292
|
+
for (const [alias, target] of Object.entries(DEFAULT_MODEL_ALIASES)) {
|
|
293
|
+
const entry = nextModels[target];
|
|
294
|
+
if (!entry) continue;
|
|
295
|
+
if (entry.alias !== void 0) continue;
|
|
296
|
+
nextModels[target] = {
|
|
297
|
+
...entry,
|
|
298
|
+
alias
|
|
299
|
+
};
|
|
300
|
+
mutated = true;
|
|
301
|
+
}
|
|
302
|
+
if (!mutated) return cfg;
|
|
303
|
+
return {
|
|
304
|
+
...nextCfg,
|
|
305
|
+
agents: {
|
|
306
|
+
...nextCfg.agents,
|
|
307
|
+
defaults: {
|
|
308
|
+
...existingAgent,
|
|
309
|
+
models: nextModels
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function applyAgentDefaults(cfg) {
|
|
315
|
+
const agents = cfg.agents;
|
|
316
|
+
const defaults = agents?.defaults;
|
|
317
|
+
const hasMax = typeof defaults?.maxConcurrent === "number" && Number.isFinite(defaults.maxConcurrent);
|
|
318
|
+
const hasSubMax = typeof defaults?.subagents?.maxConcurrent === "number" && Number.isFinite(defaults.subagents.maxConcurrent);
|
|
319
|
+
if (hasMax && hasSubMax) return cfg;
|
|
320
|
+
let mutated = false;
|
|
321
|
+
const nextDefaults = defaults ? { ...defaults } : {};
|
|
322
|
+
if (!hasMax) {
|
|
323
|
+
nextDefaults.maxConcurrent = DEFAULT_AGENT_MAX_CONCURRENT;
|
|
324
|
+
mutated = true;
|
|
325
|
+
}
|
|
326
|
+
const nextSubagents = defaults?.subagents ? { ...defaults.subagents } : {};
|
|
327
|
+
if (!hasSubMax) {
|
|
328
|
+
nextSubagents.maxConcurrent = DEFAULT_SUBAGENT_MAX_CONCURRENT;
|
|
329
|
+
mutated = true;
|
|
330
|
+
}
|
|
331
|
+
if (!mutated) return cfg;
|
|
332
|
+
return {
|
|
333
|
+
...cfg,
|
|
334
|
+
agents: {
|
|
335
|
+
...agents,
|
|
336
|
+
defaults: {
|
|
337
|
+
...nextDefaults,
|
|
338
|
+
subagents: nextSubagents
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function applyLoggingDefaults(cfg) {
|
|
344
|
+
const logging = cfg.logging;
|
|
345
|
+
if (!logging) return cfg;
|
|
346
|
+
if (logging.redactSensitive) return cfg;
|
|
347
|
+
return {
|
|
348
|
+
...cfg,
|
|
349
|
+
logging: {
|
|
350
|
+
...logging,
|
|
351
|
+
redactSensitive: "tools"
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function applyContextPruningDefaults(cfg) {
|
|
356
|
+
const defaults = cfg.agents?.defaults;
|
|
357
|
+
if (!defaults) return cfg;
|
|
358
|
+
const authMode = resolveAnthropicDefaultAuthMode(cfg);
|
|
359
|
+
if (!authMode) return cfg;
|
|
360
|
+
let mutated = false;
|
|
361
|
+
const nextDefaults = { ...defaults };
|
|
362
|
+
const contextPruning = defaults.contextPruning ?? {};
|
|
363
|
+
const heartbeat = defaults.heartbeat ?? {};
|
|
364
|
+
if (defaults.contextPruning?.mode === void 0) {
|
|
365
|
+
nextDefaults.contextPruning = {
|
|
366
|
+
...contextPruning,
|
|
367
|
+
mode: "cache-ttl",
|
|
368
|
+
ttl: defaults.contextPruning?.ttl ?? "1h"
|
|
369
|
+
};
|
|
370
|
+
mutated = true;
|
|
371
|
+
}
|
|
372
|
+
if (defaults.heartbeat?.every === void 0) {
|
|
373
|
+
nextDefaults.heartbeat = {
|
|
374
|
+
...heartbeat,
|
|
375
|
+
every: authMode === "oauth" ? "1h" : "30m"
|
|
376
|
+
};
|
|
377
|
+
mutated = true;
|
|
378
|
+
}
|
|
379
|
+
if (authMode === "api_key") {
|
|
380
|
+
const nextModels = defaults.models ? { ...defaults.models } : {};
|
|
381
|
+
let modelsMutated = false;
|
|
382
|
+
for (const [key, entry] of Object.entries(nextModels)) {
|
|
383
|
+
const parsed = parseModelRef(key, "anthropic");
|
|
384
|
+
if (!parsed || parsed.provider !== "anthropic") continue;
|
|
385
|
+
const current = entry ?? {};
|
|
386
|
+
const params = current.params ?? {};
|
|
387
|
+
if (typeof params.cacheRetention === "string") continue;
|
|
388
|
+
nextModels[key] = {
|
|
389
|
+
...current,
|
|
390
|
+
params: {
|
|
391
|
+
...params,
|
|
392
|
+
cacheRetention: "short"
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
modelsMutated = true;
|
|
396
|
+
}
|
|
397
|
+
const primary = resolvePrimaryModelRef(defaults.model?.primary ?? void 0);
|
|
398
|
+
if (primary) {
|
|
399
|
+
const parsedPrimary = parseModelRef(primary, "anthropic");
|
|
400
|
+
if (parsedPrimary?.provider === "anthropic") {
|
|
401
|
+
const key = `${parsedPrimary.provider}/${parsedPrimary.model}`;
|
|
402
|
+
const current = nextModels[key] ?? {};
|
|
403
|
+
const params = current.params ?? {};
|
|
404
|
+
if (typeof params.cacheRetention !== "string") {
|
|
405
|
+
nextModels[key] = {
|
|
406
|
+
...current,
|
|
407
|
+
params: {
|
|
408
|
+
...params,
|
|
409
|
+
cacheRetention: "short"
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
modelsMutated = true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (modelsMutated) {
|
|
417
|
+
nextDefaults.models = nextModels;
|
|
418
|
+
mutated = true;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (!mutated) return cfg;
|
|
422
|
+
return {
|
|
423
|
+
...cfg,
|
|
424
|
+
agents: {
|
|
425
|
+
...cfg.agents,
|
|
426
|
+
defaults: nextDefaults
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function applyCompactionDefaults(cfg) {
|
|
431
|
+
const defaults = cfg.agents?.defaults;
|
|
432
|
+
if (!defaults) return cfg;
|
|
433
|
+
const compaction = defaults?.compaction;
|
|
434
|
+
if (compaction?.mode) return cfg;
|
|
435
|
+
return {
|
|
436
|
+
...cfg,
|
|
437
|
+
agents: {
|
|
438
|
+
...cfg.agents,
|
|
439
|
+
defaults: {
|
|
440
|
+
...defaults,
|
|
441
|
+
compaction: {
|
|
442
|
+
...compaction,
|
|
443
|
+
mode: "safeguard"
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
//#endregion
|
|
451
|
+
//#region src/config/env-substitution.ts
|
|
452
|
+
/**
|
|
453
|
+
* Environment variable substitution for config values.
|
|
454
|
+
*
|
|
455
|
+
* Supports `${VAR_NAME}` syntax in string values, substituted at config load time.
|
|
456
|
+
* - Only uppercase env vars are matched: `[A-Z_][A-Z0-9_]*`
|
|
457
|
+
* - Escape with `$${}` to output literal `${}`
|
|
458
|
+
* - Missing env vars throw `MissingEnvVarError` with context
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```json5
|
|
462
|
+
* {
|
|
463
|
+
* models: {
|
|
464
|
+
* providers: {
|
|
465
|
+
* "vercel-gateway": {
|
|
466
|
+
* apiKey: "${VERCEL_GATEWAY_API_KEY}"
|
|
467
|
+
* }
|
|
468
|
+
* }
|
|
469
|
+
* }
|
|
470
|
+
* }
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
const ENV_VAR_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
|
|
474
|
+
var MissingEnvVarError = class extends Error {
|
|
475
|
+
constructor(varName, configPath) {
|
|
476
|
+
super(`Missing env var "${varName}" referenced at config path: ${configPath}`);
|
|
477
|
+
this.varName = varName;
|
|
478
|
+
this.configPath = configPath;
|
|
479
|
+
this.name = "MissingEnvVarError";
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
function isPlainObject$4(value) {
|
|
483
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
484
|
+
}
|
|
485
|
+
function substituteString(value, env, configPath) {
|
|
486
|
+
if (!value.includes("$")) return value;
|
|
487
|
+
const chunks = [];
|
|
488
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
489
|
+
const char = value[i];
|
|
490
|
+
if (char !== "$") {
|
|
491
|
+
chunks.push(char);
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const next = value[i + 1];
|
|
495
|
+
const afterNext = value[i + 2];
|
|
496
|
+
if (next === "$" && afterNext === "{") {
|
|
497
|
+
const start = i + 3;
|
|
498
|
+
const end = value.indexOf("}", start);
|
|
499
|
+
if (end !== -1) {
|
|
500
|
+
const name = value.slice(start, end);
|
|
501
|
+
if (ENV_VAR_NAME_PATTERN.test(name)) {
|
|
502
|
+
chunks.push(`\${${name}}`);
|
|
503
|
+
i = end;
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (next === "{") {
|
|
509
|
+
const start = i + 2;
|
|
510
|
+
const end = value.indexOf("}", start);
|
|
511
|
+
if (end !== -1) {
|
|
512
|
+
const name = value.slice(start, end);
|
|
513
|
+
if (ENV_VAR_NAME_PATTERN.test(name)) {
|
|
514
|
+
const envValue = env[name];
|
|
515
|
+
if (envValue === void 0 || envValue === "") throw new MissingEnvVarError(name, configPath);
|
|
516
|
+
chunks.push(envValue);
|
|
517
|
+
i = end;
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
chunks.push(char);
|
|
523
|
+
}
|
|
524
|
+
return chunks.join("");
|
|
525
|
+
}
|
|
526
|
+
function substituteAny(value, env, path) {
|
|
527
|
+
if (typeof value === "string") return substituteString(value, env, path);
|
|
528
|
+
if (Array.isArray(value)) return value.map((item, index) => substituteAny(item, env, `${path}[${index}]`));
|
|
529
|
+
if (isPlainObject$4(value)) {
|
|
530
|
+
const result = {};
|
|
531
|
+
for (const [key, val] of Object.entries(value)) result[key] = substituteAny(val, env, path ? `${path}.${key}` : key);
|
|
532
|
+
return result;
|
|
533
|
+
}
|
|
534
|
+
return value;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Resolves `${VAR_NAME}` environment variable references in config values.
|
|
538
|
+
*
|
|
539
|
+
* @param obj - The parsed config object (after JSON5 parse and $include resolution)
|
|
540
|
+
* @param env - Environment variables to use for substitution (defaults to process.env)
|
|
541
|
+
* @returns The config object with env vars substituted
|
|
542
|
+
* @throws {MissingEnvVarError} If a referenced env var is not set or empty
|
|
543
|
+
*/
|
|
544
|
+
function resolveConfigEnvVars(obj, env = process.env) {
|
|
545
|
+
return substituteAny(obj, env, "");
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/config/env-vars.ts
|
|
550
|
+
function collectConfigEnvVars(cfg) {
|
|
551
|
+
const envConfig = cfg?.env;
|
|
552
|
+
if (!envConfig) return {};
|
|
553
|
+
const entries = {};
|
|
554
|
+
if (envConfig.vars) for (const [key, value] of Object.entries(envConfig.vars)) {
|
|
555
|
+
if (!value) continue;
|
|
556
|
+
entries[key] = value;
|
|
557
|
+
}
|
|
558
|
+
for (const [key, value] of Object.entries(envConfig)) {
|
|
559
|
+
if (key === "shellEnv" || key === "vars") continue;
|
|
560
|
+
if (typeof value !== "string" || !value.trim()) continue;
|
|
561
|
+
entries[key] = value;
|
|
562
|
+
}
|
|
563
|
+
return entries;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/config/includes.ts
|
|
568
|
+
/**
|
|
569
|
+
* Config includes: $include directive for modular configs
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* ```json5
|
|
573
|
+
* {
|
|
574
|
+
* "$include": "./base.json5", // single file
|
|
575
|
+
* "$include": ["./a.json5", "./b.json5"] // merge multiple
|
|
576
|
+
* }
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
const INCLUDE_KEY = "$include";
|
|
580
|
+
const MAX_INCLUDE_DEPTH = 10;
|
|
581
|
+
var ConfigIncludeError = class extends Error {
|
|
582
|
+
constructor(message, includePath, cause) {
|
|
583
|
+
super(message);
|
|
584
|
+
this.includePath = includePath;
|
|
585
|
+
this.cause = cause;
|
|
586
|
+
this.name = "ConfigIncludeError";
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
var CircularIncludeError = class extends ConfigIncludeError {
|
|
590
|
+
constructor(chain) {
|
|
591
|
+
super(`Circular include detected: ${chain.join(" -> ")}`, chain[chain.length - 1]);
|
|
592
|
+
this.chain = chain;
|
|
593
|
+
this.name = "CircularIncludeError";
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
function isPlainObject$3(value) {
|
|
597
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
598
|
+
}
|
|
599
|
+
/** Deep merge: arrays concatenate, objects merge recursively, primitives: source wins */
|
|
600
|
+
function deepMerge(target, source) {
|
|
601
|
+
if (Array.isArray(target) && Array.isArray(source)) return [...target, ...source];
|
|
602
|
+
if (isPlainObject$3(target) && isPlainObject$3(source)) {
|
|
603
|
+
const result = { ...target };
|
|
604
|
+
for (const key of Object.keys(source)) result[key] = key in result ? deepMerge(result[key], source[key]) : source[key];
|
|
605
|
+
return result;
|
|
606
|
+
}
|
|
607
|
+
return source;
|
|
608
|
+
}
|
|
609
|
+
var IncludeProcessor = class IncludeProcessor {
|
|
610
|
+
constructor(basePath, resolver) {
|
|
611
|
+
this.basePath = basePath;
|
|
612
|
+
this.resolver = resolver;
|
|
613
|
+
this.visited = /* @__PURE__ */ new Set();
|
|
614
|
+
this.depth = 0;
|
|
615
|
+
this.visited.add(path.normalize(basePath));
|
|
616
|
+
}
|
|
617
|
+
process(obj) {
|
|
618
|
+
if (Array.isArray(obj)) return obj.map((item) => this.process(item));
|
|
619
|
+
if (!isPlainObject$3(obj)) return obj;
|
|
620
|
+
if (!(INCLUDE_KEY in obj)) return this.processObject(obj);
|
|
621
|
+
return this.processInclude(obj);
|
|
622
|
+
}
|
|
623
|
+
processObject(obj) {
|
|
624
|
+
const result = {};
|
|
625
|
+
for (const [key, value] of Object.entries(obj)) result[key] = this.process(value);
|
|
626
|
+
return result;
|
|
627
|
+
}
|
|
628
|
+
processInclude(obj) {
|
|
629
|
+
const includeValue = obj[INCLUDE_KEY];
|
|
630
|
+
const otherKeys = Object.keys(obj).filter((k) => k !== INCLUDE_KEY);
|
|
631
|
+
const included = this.resolveInclude(includeValue);
|
|
632
|
+
if (otherKeys.length === 0) return included;
|
|
633
|
+
if (!isPlainObject$3(included)) throw new ConfigIncludeError("Sibling keys require included content to be an object", typeof includeValue === "string" ? includeValue : INCLUDE_KEY);
|
|
634
|
+
const rest = {};
|
|
635
|
+
for (const key of otherKeys) rest[key] = this.process(obj[key]);
|
|
636
|
+
return deepMerge(included, rest);
|
|
637
|
+
}
|
|
638
|
+
resolveInclude(value) {
|
|
639
|
+
if (typeof value === "string") return this.loadFile(value);
|
|
640
|
+
if (Array.isArray(value)) return value.reduce((merged, item) => {
|
|
641
|
+
if (typeof item !== "string") throw new ConfigIncludeError(`Invalid $include array item: expected string, got ${typeof item}`, String(item));
|
|
642
|
+
return deepMerge(merged, this.loadFile(item));
|
|
643
|
+
}, {});
|
|
644
|
+
throw new ConfigIncludeError(`Invalid $include value: expected string or array of strings, got ${typeof value}`, String(value));
|
|
645
|
+
}
|
|
646
|
+
loadFile(includePath) {
|
|
647
|
+
const resolvedPath = this.resolvePath(includePath);
|
|
648
|
+
this.checkCircular(resolvedPath);
|
|
649
|
+
this.checkDepth(includePath);
|
|
650
|
+
const raw = this.readFile(includePath, resolvedPath);
|
|
651
|
+
const parsed = this.parseFile(includePath, resolvedPath, raw);
|
|
652
|
+
return this.processNested(resolvedPath, parsed);
|
|
653
|
+
}
|
|
654
|
+
resolvePath(includePath) {
|
|
655
|
+
const resolved = path.isAbsolute(includePath) ? includePath : path.resolve(path.dirname(this.basePath), includePath);
|
|
656
|
+
return path.normalize(resolved);
|
|
657
|
+
}
|
|
658
|
+
checkCircular(resolvedPath) {
|
|
659
|
+
if (this.visited.has(resolvedPath)) throw new CircularIncludeError([...this.visited, resolvedPath]);
|
|
660
|
+
}
|
|
661
|
+
checkDepth(includePath) {
|
|
662
|
+
if (this.depth >= MAX_INCLUDE_DEPTH) throw new ConfigIncludeError(`Maximum include depth (${MAX_INCLUDE_DEPTH}) exceeded at: ${includePath}`, includePath);
|
|
663
|
+
}
|
|
664
|
+
readFile(includePath, resolvedPath) {
|
|
665
|
+
try {
|
|
666
|
+
return this.resolver.readFile(resolvedPath);
|
|
667
|
+
} catch (err) {
|
|
668
|
+
throw new ConfigIncludeError(`Failed to read include file: ${includePath} (resolved: ${resolvedPath})`, includePath, err instanceof Error ? err : void 0);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
parseFile(includePath, resolvedPath, raw) {
|
|
672
|
+
try {
|
|
673
|
+
return this.resolver.parseJson(raw);
|
|
674
|
+
} catch (err) {
|
|
675
|
+
throw new ConfigIncludeError(`Failed to parse include file: ${includePath} (resolved: ${resolvedPath})`, includePath, err instanceof Error ? err : void 0);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
processNested(resolvedPath, parsed) {
|
|
679
|
+
const nested = new IncludeProcessor(resolvedPath, this.resolver);
|
|
680
|
+
nested.visited = new Set([...this.visited, resolvedPath]);
|
|
681
|
+
nested.depth = this.depth + 1;
|
|
682
|
+
return nested.process(parsed);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
const defaultResolver = {
|
|
686
|
+
readFile: (p) => fs.readFileSync(p, "utf-8"),
|
|
687
|
+
parseJson: (raw) => JSON5.parse(raw)
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* Resolves all $include directives in a parsed config object.
|
|
691
|
+
*/
|
|
692
|
+
function resolveConfigIncludes(obj, configPath, resolver = defaultResolver) {
|
|
693
|
+
return new IncludeProcessor(configPath, resolver).process(obj);
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/config/legacy.shared.ts
|
|
698
|
+
const isRecord$1 = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
699
|
+
const getRecord = (value) => isRecord$1(value) ? value : null;
|
|
700
|
+
const ensureRecord = (root, key) => {
|
|
701
|
+
const existing = root[key];
|
|
702
|
+
if (isRecord$1(existing)) return existing;
|
|
703
|
+
const next = {};
|
|
704
|
+
root[key] = next;
|
|
705
|
+
return next;
|
|
706
|
+
};
|
|
707
|
+
const mergeMissing = (target, source) => {
|
|
708
|
+
for (const [key, value] of Object.entries(source)) {
|
|
709
|
+
if (value === void 0) continue;
|
|
710
|
+
const existing = target[key];
|
|
711
|
+
if (existing === void 0) {
|
|
712
|
+
target[key] = value;
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
if (isRecord$1(existing) && isRecord$1(value)) mergeMissing(existing, value);
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
const AUDIO_TRANSCRIPTION_CLI_ALLOWLIST = new Set(["whisper"]);
|
|
719
|
+
const mapLegacyAudioTranscription = (value) => {
|
|
720
|
+
const transcriber = getRecord(value);
|
|
721
|
+
const command = Array.isArray(transcriber?.command) ? transcriber?.command : null;
|
|
722
|
+
if (!command || command.length === 0) return null;
|
|
723
|
+
const rawExecutable = String(command[0] ?? "").trim();
|
|
724
|
+
if (!rawExecutable) return null;
|
|
725
|
+
const executableName = rawExecutable.split(/[\\/]/).pop() ?? rawExecutable;
|
|
726
|
+
if (!AUDIO_TRANSCRIPTION_CLI_ALLOWLIST.has(executableName)) return null;
|
|
727
|
+
const args = command.slice(1).map((part) => String(part));
|
|
728
|
+
const timeoutSeconds = typeof transcriber?.timeoutSeconds === "number" ? transcriber?.timeoutSeconds : void 0;
|
|
729
|
+
const result = {
|
|
730
|
+
command: rawExecutable,
|
|
731
|
+
type: "cli"
|
|
732
|
+
};
|
|
733
|
+
if (args.length > 0) result.args = args;
|
|
734
|
+
if (timeoutSeconds !== void 0) result.timeoutSeconds = timeoutSeconds;
|
|
735
|
+
return result;
|
|
736
|
+
};
|
|
737
|
+
const getAgentsList = (agents) => {
|
|
738
|
+
const list = agents?.list;
|
|
739
|
+
return Array.isArray(list) ? list : [];
|
|
740
|
+
};
|
|
741
|
+
const resolveDefaultAgentIdFromRaw = (raw) => {
|
|
742
|
+
const list = getAgentsList(getRecord(raw.agents));
|
|
743
|
+
const defaultEntry = list.find((entry) => isRecord$1(entry) && entry.default === true && typeof entry.id === "string" && entry.id.trim() !== "");
|
|
744
|
+
if (defaultEntry) return defaultEntry.id.trim();
|
|
745
|
+
const routing = getRecord(raw.routing);
|
|
746
|
+
const routingDefault = typeof routing?.defaultAgentId === "string" ? routing.defaultAgentId.trim() : "";
|
|
747
|
+
if (routingDefault) return routingDefault;
|
|
748
|
+
const firstEntry = list.find((entry) => isRecord$1(entry) && typeof entry.id === "string" && entry.id.trim() !== "");
|
|
749
|
+
if (firstEntry) return firstEntry.id.trim();
|
|
750
|
+
return "main";
|
|
751
|
+
};
|
|
752
|
+
const ensureAgentEntry = (list, id) => {
|
|
753
|
+
const normalized = id.trim();
|
|
754
|
+
const existing = list.find((entry) => isRecord$1(entry) && typeof entry.id === "string" && entry.id.trim() === normalized);
|
|
755
|
+
if (existing) return existing;
|
|
756
|
+
const created = { id: normalized };
|
|
757
|
+
list.push(created);
|
|
758
|
+
return created;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
//#endregion
|
|
762
|
+
//#region src/config/legacy.migrations.part-1.ts
|
|
763
|
+
const LEGACY_CONFIG_MIGRATIONS_PART_1 = [
|
|
764
|
+
{
|
|
765
|
+
id: "bindings.match.provider->bindings.match.channel",
|
|
766
|
+
describe: "Move bindings[].match.provider to bindings[].match.channel",
|
|
767
|
+
apply: (raw, changes) => {
|
|
768
|
+
const bindings = Array.isArray(raw.bindings) ? raw.bindings : null;
|
|
769
|
+
if (!bindings) return;
|
|
770
|
+
let touched = false;
|
|
771
|
+
for (const entry of bindings) {
|
|
772
|
+
if (!isRecord$1(entry)) continue;
|
|
773
|
+
const match = getRecord(entry.match);
|
|
774
|
+
if (!match) continue;
|
|
775
|
+
if (typeof match.channel === "string" && match.channel.trim()) continue;
|
|
776
|
+
const provider = typeof match.provider === "string" ? match.provider.trim() : "";
|
|
777
|
+
if (!provider) continue;
|
|
778
|
+
match.channel = provider;
|
|
779
|
+
delete match.provider;
|
|
780
|
+
entry.match = match;
|
|
781
|
+
touched = true;
|
|
782
|
+
}
|
|
783
|
+
if (touched) {
|
|
784
|
+
raw.bindings = bindings;
|
|
785
|
+
changes.push("Moved bindings[].match.provider → bindings[].match.channel.");
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
id: "bindings.match.accountID->bindings.match.accountId",
|
|
791
|
+
describe: "Move bindings[].match.accountID to bindings[].match.accountId",
|
|
792
|
+
apply: (raw, changes) => {
|
|
793
|
+
const bindings = Array.isArray(raw.bindings) ? raw.bindings : null;
|
|
794
|
+
if (!bindings) return;
|
|
795
|
+
let touched = false;
|
|
796
|
+
for (const entry of bindings) {
|
|
797
|
+
if (!isRecord$1(entry)) continue;
|
|
798
|
+
const match = getRecord(entry.match);
|
|
799
|
+
if (!match) continue;
|
|
800
|
+
if (match.accountId !== void 0) continue;
|
|
801
|
+
const accountID = typeof match.accountID === "string" ? match.accountID.trim() : match.accountID;
|
|
802
|
+
if (!accountID) continue;
|
|
803
|
+
match.accountId = accountID;
|
|
804
|
+
delete match.accountID;
|
|
805
|
+
entry.match = match;
|
|
806
|
+
touched = true;
|
|
807
|
+
}
|
|
808
|
+
if (touched) {
|
|
809
|
+
raw.bindings = bindings;
|
|
810
|
+
changes.push("Moved bindings[].match.accountID → bindings[].match.accountId.");
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
id: "session.sendPolicy.rules.match.provider->match.channel",
|
|
816
|
+
describe: "Move session.sendPolicy.rules[].match.provider to match.channel",
|
|
817
|
+
apply: (raw, changes) => {
|
|
818
|
+
const session = getRecord(raw.session);
|
|
819
|
+
if (!session) return;
|
|
820
|
+
const sendPolicy = getRecord(session.sendPolicy);
|
|
821
|
+
if (!sendPolicy) return;
|
|
822
|
+
const rules = Array.isArray(sendPolicy.rules) ? sendPolicy.rules : null;
|
|
823
|
+
if (!rules) return;
|
|
824
|
+
let touched = false;
|
|
825
|
+
for (const rule of rules) {
|
|
826
|
+
if (!isRecord$1(rule)) continue;
|
|
827
|
+
const match = getRecord(rule.match);
|
|
828
|
+
if (!match) continue;
|
|
829
|
+
if (typeof match.channel === "string" && match.channel.trim()) continue;
|
|
830
|
+
const provider = typeof match.provider === "string" ? match.provider.trim() : "";
|
|
831
|
+
if (!provider) continue;
|
|
832
|
+
match.channel = provider;
|
|
833
|
+
delete match.provider;
|
|
834
|
+
rule.match = match;
|
|
835
|
+
touched = true;
|
|
836
|
+
}
|
|
837
|
+
if (touched) {
|
|
838
|
+
sendPolicy.rules = rules;
|
|
839
|
+
session.sendPolicy = sendPolicy;
|
|
840
|
+
raw.session = session;
|
|
841
|
+
changes.push("Moved session.sendPolicy.rules[].match.provider → match.channel.");
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
id: "messages.queue.byProvider->byChannel",
|
|
847
|
+
describe: "Move messages.queue.byProvider to messages.queue.byChannel",
|
|
848
|
+
apply: (raw, changes) => {
|
|
849
|
+
const messages = getRecord(raw.messages);
|
|
850
|
+
if (!messages) return;
|
|
851
|
+
const queue = getRecord(messages.queue);
|
|
852
|
+
if (!queue) return;
|
|
853
|
+
if (queue.byProvider === void 0) return;
|
|
854
|
+
if (queue.byChannel === void 0) {
|
|
855
|
+
queue.byChannel = queue.byProvider;
|
|
856
|
+
changes.push("Moved messages.queue.byProvider → messages.queue.byChannel.");
|
|
857
|
+
} else changes.push("Removed messages.queue.byProvider (messages.queue.byChannel already set).");
|
|
858
|
+
delete queue.byProvider;
|
|
859
|
+
messages.queue = queue;
|
|
860
|
+
raw.messages = messages;
|
|
861
|
+
}
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
id: "providers->channels",
|
|
865
|
+
describe: "Move provider config sections to channels.*",
|
|
866
|
+
apply: (raw, changes) => {
|
|
867
|
+
const legacyEntries = [
|
|
868
|
+
"whatsapp",
|
|
869
|
+
"telegram",
|
|
870
|
+
"discord",
|
|
871
|
+
"slack",
|
|
872
|
+
"signal",
|
|
873
|
+
"imessage",
|
|
874
|
+
"msteams"
|
|
875
|
+
].filter((key) => isRecord$1(raw[key]));
|
|
876
|
+
if (legacyEntries.length === 0) return;
|
|
877
|
+
const channels = ensureRecord(raw, "channels");
|
|
878
|
+
for (const key of legacyEntries) {
|
|
879
|
+
const legacy = getRecord(raw[key]);
|
|
880
|
+
if (!legacy) continue;
|
|
881
|
+
const channelEntry = ensureRecord(channels, key);
|
|
882
|
+
const hadEntries = Object.keys(channelEntry).length > 0;
|
|
883
|
+
mergeMissing(channelEntry, legacy);
|
|
884
|
+
channels[key] = channelEntry;
|
|
885
|
+
delete raw[key];
|
|
886
|
+
changes.push(hadEntries ? `Merged ${key} → channels.${key}.` : `Moved ${key} → channels.${key}.`);
|
|
887
|
+
}
|
|
888
|
+
raw.channels = channels;
|
|
889
|
+
}
|
|
890
|
+
},
|
|
891
|
+
{
|
|
892
|
+
id: "routing.allowFrom->channels.whatsapp.allowFrom",
|
|
893
|
+
describe: "Move routing.allowFrom to channels.whatsapp.allowFrom",
|
|
894
|
+
apply: (raw, changes) => {
|
|
895
|
+
const routing = raw.routing;
|
|
896
|
+
if (!routing || typeof routing !== "object") return;
|
|
897
|
+
const allowFrom = routing.allowFrom;
|
|
898
|
+
if (allowFrom === void 0) return;
|
|
899
|
+
const channels = getRecord(raw.channels);
|
|
900
|
+
const whatsapp = channels ? getRecord(channels.whatsapp) : null;
|
|
901
|
+
if (!whatsapp) {
|
|
902
|
+
delete routing.allowFrom;
|
|
903
|
+
if (Object.keys(routing).length === 0) delete raw.routing;
|
|
904
|
+
changes.push("Removed routing.allowFrom (channels.whatsapp not configured).");
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
if (whatsapp.allowFrom === void 0) {
|
|
908
|
+
whatsapp.allowFrom = allowFrom;
|
|
909
|
+
changes.push("Moved routing.allowFrom → channels.whatsapp.allowFrom.");
|
|
910
|
+
} else changes.push("Removed routing.allowFrom (channels.whatsapp.allowFrom already set).");
|
|
911
|
+
delete routing.allowFrom;
|
|
912
|
+
if (Object.keys(routing).length === 0) delete raw.routing;
|
|
913
|
+
channels.whatsapp = whatsapp;
|
|
914
|
+
raw.channels = channels;
|
|
915
|
+
}
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
id: "routing.groupChat.requireMention->groups.*.requireMention",
|
|
919
|
+
describe: "Move routing.groupChat.requireMention to channels.whatsapp/telegram/imessage groups",
|
|
920
|
+
apply: (raw, changes) => {
|
|
921
|
+
const routing = raw.routing;
|
|
922
|
+
if (!routing || typeof routing !== "object") return;
|
|
923
|
+
const groupChat = routing.groupChat && typeof routing.groupChat === "object" ? routing.groupChat : null;
|
|
924
|
+
if (!groupChat) return;
|
|
925
|
+
const requireMention = groupChat.requireMention;
|
|
926
|
+
if (requireMention === void 0) return;
|
|
927
|
+
const channels = ensureRecord(raw, "channels");
|
|
928
|
+
const applyTo = (key, options) => {
|
|
929
|
+
if (options?.requireExisting && !isRecord$1(channels[key])) return;
|
|
930
|
+
const section = channels[key] && typeof channels[key] === "object" ? channels[key] : {};
|
|
931
|
+
const groups = section.groups && typeof section.groups === "object" ? section.groups : {};
|
|
932
|
+
const defaultKey = "*";
|
|
933
|
+
const entry = groups[defaultKey] && typeof groups[defaultKey] === "object" ? groups[defaultKey] : {};
|
|
934
|
+
if (entry.requireMention === void 0) {
|
|
935
|
+
entry.requireMention = requireMention;
|
|
936
|
+
groups[defaultKey] = entry;
|
|
937
|
+
section.groups = groups;
|
|
938
|
+
channels[key] = section;
|
|
939
|
+
changes.push(`Moved routing.groupChat.requireMention → channels.${key}.groups."*".requireMention.`);
|
|
940
|
+
} else changes.push(`Removed routing.groupChat.requireMention (channels.${key}.groups."*" already set).`);
|
|
941
|
+
};
|
|
942
|
+
applyTo("whatsapp", { requireExisting: true });
|
|
943
|
+
applyTo("telegram");
|
|
944
|
+
applyTo("imessage");
|
|
945
|
+
delete groupChat.requireMention;
|
|
946
|
+
if (Object.keys(groupChat).length === 0) delete routing.groupChat;
|
|
947
|
+
if (Object.keys(routing).length === 0) delete raw.routing;
|
|
948
|
+
raw.channels = channels;
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
id: "gateway.token->gateway.auth.token",
|
|
953
|
+
describe: "Move gateway.token to gateway.auth.token",
|
|
954
|
+
apply: (raw, changes) => {
|
|
955
|
+
const gateway = raw.gateway;
|
|
956
|
+
if (!gateway || typeof gateway !== "object") return;
|
|
957
|
+
const token = gateway.token;
|
|
958
|
+
if (token === void 0) return;
|
|
959
|
+
const gatewayObj = gateway;
|
|
960
|
+
const auth = gatewayObj.auth && typeof gatewayObj.auth === "object" ? gatewayObj.auth : {};
|
|
961
|
+
if (auth.token === void 0) {
|
|
962
|
+
auth.token = token;
|
|
963
|
+
if (!auth.mode) auth.mode = "token";
|
|
964
|
+
changes.push("Moved gateway.token → gateway.auth.token.");
|
|
965
|
+
} else changes.push("Removed gateway.token (gateway.auth.token already set).");
|
|
966
|
+
delete gatewayObj.token;
|
|
967
|
+
if (Object.keys(auth).length > 0) gatewayObj.auth = auth;
|
|
968
|
+
raw.gateway = gatewayObj;
|
|
969
|
+
}
|
|
970
|
+
},
|
|
971
|
+
{
|
|
972
|
+
id: "telegram.requireMention->channels.telegram.groups.*.requireMention",
|
|
973
|
+
describe: "Move telegram.requireMention to channels.telegram.groups.*.requireMention",
|
|
974
|
+
apply: (raw, changes) => {
|
|
975
|
+
const channels = ensureRecord(raw, "channels");
|
|
976
|
+
const telegram = channels.telegram;
|
|
977
|
+
if (!telegram || typeof telegram !== "object") return;
|
|
978
|
+
const requireMention = telegram.requireMention;
|
|
979
|
+
if (requireMention === void 0) return;
|
|
980
|
+
const groups = telegram.groups && typeof telegram.groups === "object" ? telegram.groups : {};
|
|
981
|
+
const defaultKey = "*";
|
|
982
|
+
const entry = groups[defaultKey] && typeof groups[defaultKey] === "object" ? groups[defaultKey] : {};
|
|
983
|
+
if (entry.requireMention === void 0) {
|
|
984
|
+
entry.requireMention = requireMention;
|
|
985
|
+
groups[defaultKey] = entry;
|
|
986
|
+
telegram.groups = groups;
|
|
987
|
+
changes.push("Moved telegram.requireMention → channels.telegram.groups.\"*\".requireMention.");
|
|
988
|
+
} else changes.push("Removed telegram.requireMention (channels.telegram.groups.\"*\" already set).");
|
|
989
|
+
delete telegram.requireMention;
|
|
990
|
+
channels.telegram = telegram;
|
|
991
|
+
raw.channels = channels;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
];
|
|
995
|
+
|
|
996
|
+
//#endregion
|
|
997
|
+
//#region src/config/legacy.migrations.part-2.ts
|
|
998
|
+
const LEGACY_CONFIG_MIGRATIONS_PART_2 = [
|
|
999
|
+
{
|
|
1000
|
+
id: "agent.model-config-v2",
|
|
1001
|
+
describe: "Migrate legacy agent.model/allowedModels/modelAliases/modelFallbacks/imageModelFallbacks to agent.models + model lists",
|
|
1002
|
+
apply: (raw, changes) => {
|
|
1003
|
+
const agentRoot = getRecord(raw.agent);
|
|
1004
|
+
const defaults = getRecord(getRecord(raw.agents)?.defaults);
|
|
1005
|
+
const agent = agentRoot ?? defaults;
|
|
1006
|
+
if (!agent) return;
|
|
1007
|
+
const label = agentRoot ? "agent" : "agents.defaults";
|
|
1008
|
+
const legacyModel = typeof agent.model === "string" ? String(agent.model) : void 0;
|
|
1009
|
+
const legacyImageModel = typeof agent.imageModel === "string" ? String(agent.imageModel) : void 0;
|
|
1010
|
+
const legacyAllowed = Array.isArray(agent.allowedModels) ? agent.allowedModels.map(String) : [];
|
|
1011
|
+
const legacyModelFallbacks = Array.isArray(agent.modelFallbacks) ? agent.modelFallbacks.map(String) : [];
|
|
1012
|
+
const legacyImageModelFallbacks = Array.isArray(agent.imageModelFallbacks) ? agent.imageModelFallbacks.map(String) : [];
|
|
1013
|
+
const legacyAliases = agent.modelAliases && typeof agent.modelAliases === "object" ? agent.modelAliases : {};
|
|
1014
|
+
if (!(legacyModel || legacyImageModel || legacyAllowed.length > 0 || legacyModelFallbacks.length > 0 || legacyImageModelFallbacks.length > 0 || Object.keys(legacyAliases).length > 0)) return;
|
|
1015
|
+
const models = agent.models && typeof agent.models === "object" ? agent.models : {};
|
|
1016
|
+
const ensureModel = (rawKey) => {
|
|
1017
|
+
if (typeof rawKey !== "string") return;
|
|
1018
|
+
const key = rawKey.trim();
|
|
1019
|
+
if (!key) return;
|
|
1020
|
+
if (!models[key]) models[key] = {};
|
|
1021
|
+
};
|
|
1022
|
+
ensureModel(legacyModel);
|
|
1023
|
+
ensureModel(legacyImageModel);
|
|
1024
|
+
for (const key of legacyAllowed) ensureModel(key);
|
|
1025
|
+
for (const key of legacyModelFallbacks) ensureModel(key);
|
|
1026
|
+
for (const key of legacyImageModelFallbacks) ensureModel(key);
|
|
1027
|
+
for (const target of Object.values(legacyAliases)) {
|
|
1028
|
+
if (typeof target !== "string") continue;
|
|
1029
|
+
ensureModel(target);
|
|
1030
|
+
}
|
|
1031
|
+
for (const [alias, targetRaw] of Object.entries(legacyAliases)) {
|
|
1032
|
+
if (typeof targetRaw !== "string") continue;
|
|
1033
|
+
const target = targetRaw.trim();
|
|
1034
|
+
if (!target) continue;
|
|
1035
|
+
const entry = models[target] && typeof models[target] === "object" ? models[target] : {};
|
|
1036
|
+
if (!("alias" in entry)) {
|
|
1037
|
+
entry.alias = alias;
|
|
1038
|
+
models[target] = entry;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
const currentModel = agent.model && typeof agent.model === "object" ? agent.model : null;
|
|
1042
|
+
if (currentModel) {
|
|
1043
|
+
if (!currentModel.primary && legacyModel) currentModel.primary = legacyModel;
|
|
1044
|
+
if (legacyModelFallbacks.length > 0 && (!Array.isArray(currentModel.fallbacks) || currentModel.fallbacks.length === 0)) currentModel.fallbacks = legacyModelFallbacks;
|
|
1045
|
+
agent.model = currentModel;
|
|
1046
|
+
} else if (legacyModel || legacyModelFallbacks.length > 0) agent.model = {
|
|
1047
|
+
primary: legacyModel,
|
|
1048
|
+
fallbacks: legacyModelFallbacks.length ? legacyModelFallbacks : []
|
|
1049
|
+
};
|
|
1050
|
+
const currentImageModel = agent.imageModel && typeof agent.imageModel === "object" ? agent.imageModel : null;
|
|
1051
|
+
if (currentImageModel) {
|
|
1052
|
+
if (!currentImageModel.primary && legacyImageModel) currentImageModel.primary = legacyImageModel;
|
|
1053
|
+
if (legacyImageModelFallbacks.length > 0 && (!Array.isArray(currentImageModel.fallbacks) || currentImageModel.fallbacks.length === 0)) currentImageModel.fallbacks = legacyImageModelFallbacks;
|
|
1054
|
+
agent.imageModel = currentImageModel;
|
|
1055
|
+
} else if (legacyImageModel || legacyImageModelFallbacks.length > 0) agent.imageModel = {
|
|
1056
|
+
primary: legacyImageModel,
|
|
1057
|
+
fallbacks: legacyImageModelFallbacks.length ? legacyImageModelFallbacks : []
|
|
1058
|
+
};
|
|
1059
|
+
agent.models = models;
|
|
1060
|
+
if (legacyModel !== void 0) changes.push(`Migrated ${label}.model string → ${label}.model.primary.`);
|
|
1061
|
+
if (legacyModelFallbacks.length > 0) changes.push(`Migrated ${label}.modelFallbacks → ${label}.model.fallbacks.`);
|
|
1062
|
+
if (legacyImageModel !== void 0) changes.push(`Migrated ${label}.imageModel string → ${label}.imageModel.primary.`);
|
|
1063
|
+
if (legacyImageModelFallbacks.length > 0) changes.push(`Migrated ${label}.imageModelFallbacks → ${label}.imageModel.fallbacks.`);
|
|
1064
|
+
if (legacyAllowed.length > 0) changes.push(`Migrated ${label}.allowedModels → ${label}.models.`);
|
|
1065
|
+
if (Object.keys(legacyAliases).length > 0) changes.push(`Migrated ${label}.modelAliases → ${label}.models.*.alias.`);
|
|
1066
|
+
delete agent.allowedModels;
|
|
1067
|
+
delete agent.modelAliases;
|
|
1068
|
+
delete agent.modelFallbacks;
|
|
1069
|
+
delete agent.imageModelFallbacks;
|
|
1070
|
+
}
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
id: "routing.agents-v2",
|
|
1074
|
+
describe: "Move routing.agents/defaultAgentId to agents.list",
|
|
1075
|
+
apply: (raw, changes) => {
|
|
1076
|
+
const routing = getRecord(raw.routing);
|
|
1077
|
+
if (!routing) return;
|
|
1078
|
+
const routingAgents = getRecord(routing.agents);
|
|
1079
|
+
const agents = ensureRecord(raw, "agents");
|
|
1080
|
+
const list = getAgentsList(agents);
|
|
1081
|
+
if (routingAgents) {
|
|
1082
|
+
for (const [rawId, entryRaw] of Object.entries(routingAgents)) {
|
|
1083
|
+
const agentId = String(rawId ?? "").trim();
|
|
1084
|
+
const entry = getRecord(entryRaw);
|
|
1085
|
+
if (!agentId || !entry) continue;
|
|
1086
|
+
const target = ensureAgentEntry(list, agentId);
|
|
1087
|
+
const entryCopy = { ...entry };
|
|
1088
|
+
if ("mentionPatterns" in entryCopy) {
|
|
1089
|
+
const mentionPatterns = entryCopy.mentionPatterns;
|
|
1090
|
+
const groupChat = ensureRecord(target, "groupChat");
|
|
1091
|
+
if (groupChat.mentionPatterns === void 0) {
|
|
1092
|
+
groupChat.mentionPatterns = mentionPatterns;
|
|
1093
|
+
changes.push(`Moved routing.agents.${agentId}.mentionPatterns → agents.list (id "${agentId}").groupChat.mentionPatterns.`);
|
|
1094
|
+
} else changes.push(`Removed routing.agents.${agentId}.mentionPatterns (agents.list groupChat mentionPatterns already set).`);
|
|
1095
|
+
delete entryCopy.mentionPatterns;
|
|
1096
|
+
}
|
|
1097
|
+
const legacyGroupChat = getRecord(entryCopy.groupChat);
|
|
1098
|
+
if (legacyGroupChat) {
|
|
1099
|
+
mergeMissing(ensureRecord(target, "groupChat"), legacyGroupChat);
|
|
1100
|
+
delete entryCopy.groupChat;
|
|
1101
|
+
}
|
|
1102
|
+
const legacySandbox = getRecord(entryCopy.sandbox);
|
|
1103
|
+
if (legacySandbox) {
|
|
1104
|
+
const sandboxTools = getRecord(legacySandbox.tools);
|
|
1105
|
+
if (sandboxTools) {
|
|
1106
|
+
mergeMissing(ensureRecord(ensureRecord(ensureRecord(target, "tools"), "sandbox"), "tools"), sandboxTools);
|
|
1107
|
+
delete legacySandbox.tools;
|
|
1108
|
+
changes.push(`Moved routing.agents.${agentId}.sandbox.tools → agents.list (id "${agentId}").tools.sandbox.tools.`);
|
|
1109
|
+
}
|
|
1110
|
+
entryCopy.sandbox = legacySandbox;
|
|
1111
|
+
}
|
|
1112
|
+
mergeMissing(target, entryCopy);
|
|
1113
|
+
}
|
|
1114
|
+
delete routing.agents;
|
|
1115
|
+
changes.push("Moved routing.agents → agents.list.");
|
|
1116
|
+
}
|
|
1117
|
+
const defaultAgentId = typeof routing.defaultAgentId === "string" ? routing.defaultAgentId.trim() : "";
|
|
1118
|
+
if (defaultAgentId) {
|
|
1119
|
+
if (!list.some((entry) => isRecord$1(entry) && entry.default === true)) {
|
|
1120
|
+
const entry = ensureAgentEntry(list, defaultAgentId);
|
|
1121
|
+
entry.default = true;
|
|
1122
|
+
changes.push(`Moved routing.defaultAgentId → agents.list (id "${defaultAgentId}").default.`);
|
|
1123
|
+
} else changes.push("Removed routing.defaultAgentId (agents.list default already set).");
|
|
1124
|
+
delete routing.defaultAgentId;
|
|
1125
|
+
}
|
|
1126
|
+
if (list.length > 0) agents.list = list;
|
|
1127
|
+
if (Object.keys(routing).length === 0) delete raw.routing;
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
id: "routing.config-v2",
|
|
1132
|
+
describe: "Move routing bindings/groupChat/queue/agentToAgent/transcribeAudio",
|
|
1133
|
+
apply: (raw, changes) => {
|
|
1134
|
+
const routing = getRecord(raw.routing);
|
|
1135
|
+
if (!routing) return;
|
|
1136
|
+
if (routing.bindings !== void 0) {
|
|
1137
|
+
if (raw.bindings === void 0) {
|
|
1138
|
+
raw.bindings = routing.bindings;
|
|
1139
|
+
changes.push("Moved routing.bindings → bindings.");
|
|
1140
|
+
} else changes.push("Removed routing.bindings (bindings already set).");
|
|
1141
|
+
delete routing.bindings;
|
|
1142
|
+
}
|
|
1143
|
+
if (routing.agentToAgent !== void 0) {
|
|
1144
|
+
const tools = ensureRecord(raw, "tools");
|
|
1145
|
+
if (tools.agentToAgent === void 0) {
|
|
1146
|
+
tools.agentToAgent = routing.agentToAgent;
|
|
1147
|
+
changes.push("Moved routing.agentToAgent → tools.agentToAgent.");
|
|
1148
|
+
} else changes.push("Removed routing.agentToAgent (tools.agentToAgent already set).");
|
|
1149
|
+
delete routing.agentToAgent;
|
|
1150
|
+
}
|
|
1151
|
+
if (routing.queue !== void 0) {
|
|
1152
|
+
const messages = ensureRecord(raw, "messages");
|
|
1153
|
+
if (messages.queue === void 0) {
|
|
1154
|
+
messages.queue = routing.queue;
|
|
1155
|
+
changes.push("Moved routing.queue → messages.queue.");
|
|
1156
|
+
} else changes.push("Removed routing.queue (messages.queue already set).");
|
|
1157
|
+
delete routing.queue;
|
|
1158
|
+
}
|
|
1159
|
+
const groupChat = getRecord(routing.groupChat);
|
|
1160
|
+
if (groupChat) {
|
|
1161
|
+
const historyLimit = groupChat.historyLimit;
|
|
1162
|
+
if (historyLimit !== void 0) {
|
|
1163
|
+
const messagesGroup = ensureRecord(ensureRecord(raw, "messages"), "groupChat");
|
|
1164
|
+
if (messagesGroup.historyLimit === void 0) {
|
|
1165
|
+
messagesGroup.historyLimit = historyLimit;
|
|
1166
|
+
changes.push("Moved routing.groupChat.historyLimit → messages.groupChat.historyLimit.");
|
|
1167
|
+
} else changes.push("Removed routing.groupChat.historyLimit (messages.groupChat.historyLimit already set).");
|
|
1168
|
+
delete groupChat.historyLimit;
|
|
1169
|
+
}
|
|
1170
|
+
const mentionPatterns = groupChat.mentionPatterns;
|
|
1171
|
+
if (mentionPatterns !== void 0) {
|
|
1172
|
+
const messagesGroup = ensureRecord(ensureRecord(raw, "messages"), "groupChat");
|
|
1173
|
+
if (messagesGroup.mentionPatterns === void 0) {
|
|
1174
|
+
messagesGroup.mentionPatterns = mentionPatterns;
|
|
1175
|
+
changes.push("Moved routing.groupChat.mentionPatterns → messages.groupChat.mentionPatterns.");
|
|
1176
|
+
} else changes.push("Removed routing.groupChat.mentionPatterns (messages.groupChat.mentionPatterns already set).");
|
|
1177
|
+
delete groupChat.mentionPatterns;
|
|
1178
|
+
}
|
|
1179
|
+
if (Object.keys(groupChat).length === 0) delete routing.groupChat;
|
|
1180
|
+
else routing.groupChat = groupChat;
|
|
1181
|
+
}
|
|
1182
|
+
if (routing.transcribeAudio !== void 0) {
|
|
1183
|
+
const mapped = mapLegacyAudioTranscription(routing.transcribeAudio);
|
|
1184
|
+
if (mapped) {
|
|
1185
|
+
const mediaAudio = ensureRecord(ensureRecord(ensureRecord(raw, "tools"), "media"), "audio");
|
|
1186
|
+
if ((Array.isArray(mediaAudio.models) ? mediaAudio.models : []).length === 0) {
|
|
1187
|
+
mediaAudio.enabled = true;
|
|
1188
|
+
mediaAudio.models = [mapped];
|
|
1189
|
+
changes.push("Moved routing.transcribeAudio → tools.media.audio.models.");
|
|
1190
|
+
} else changes.push("Removed routing.transcribeAudio (tools.media.audio.models already set).");
|
|
1191
|
+
} else changes.push("Removed routing.transcribeAudio (unsupported transcription CLI).");
|
|
1192
|
+
delete routing.transcribeAudio;
|
|
1193
|
+
}
|
|
1194
|
+
const audio = getRecord(raw.audio);
|
|
1195
|
+
if (audio?.transcription !== void 0) {
|
|
1196
|
+
const mapped = mapLegacyAudioTranscription(audio.transcription);
|
|
1197
|
+
if (mapped) {
|
|
1198
|
+
const mediaAudio = ensureRecord(ensureRecord(ensureRecord(raw, "tools"), "media"), "audio");
|
|
1199
|
+
if ((Array.isArray(mediaAudio.models) ? mediaAudio.models : []).length === 0) {
|
|
1200
|
+
mediaAudio.enabled = true;
|
|
1201
|
+
mediaAudio.models = [mapped];
|
|
1202
|
+
changes.push("Moved audio.transcription → tools.media.audio.models.");
|
|
1203
|
+
} else changes.push("Removed audio.transcription (tools.media.audio.models already set).");
|
|
1204
|
+
delete audio.transcription;
|
|
1205
|
+
if (Object.keys(audio).length === 0) delete raw.audio;
|
|
1206
|
+
else raw.audio = audio;
|
|
1207
|
+
} else {
|
|
1208
|
+
delete audio.transcription;
|
|
1209
|
+
changes.push("Removed audio.transcription (unsupported transcription CLI).");
|
|
1210
|
+
if (Object.keys(audio).length === 0) delete raw.audio;
|
|
1211
|
+
else raw.audio = audio;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
if (Object.keys(routing).length === 0) delete raw.routing;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
];
|
|
1218
|
+
|
|
1219
|
+
//#endregion
|
|
1220
|
+
//#region src/config/legacy.migrations.part-3.ts
|
|
1221
|
+
const LEGACY_CONFIG_MIGRATIONS_PART_3 = [
|
|
1222
|
+
{
|
|
1223
|
+
id: "auth.anthropic-claude-cli-mode-oauth",
|
|
1224
|
+
describe: "Switch anthropic:claude-cli auth profile mode to oauth",
|
|
1225
|
+
apply: (raw, changes) => {
|
|
1226
|
+
const profiles = getRecord(getRecord(raw.auth)?.profiles);
|
|
1227
|
+
if (!profiles) return;
|
|
1228
|
+
const claudeCli = getRecord(profiles["anthropic:claude-cli"]);
|
|
1229
|
+
if (!claudeCli) return;
|
|
1230
|
+
if (claudeCli.mode !== "token") return;
|
|
1231
|
+
claudeCli.mode = "oauth";
|
|
1232
|
+
changes.push("Updated auth.profiles[\"anthropic:claude-cli\"].mode → \"oauth\".");
|
|
1233
|
+
}
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
id: "tools.bash->tools.exec",
|
|
1237
|
+
describe: "Move tools.bash to tools.exec",
|
|
1238
|
+
apply: (raw, changes) => {
|
|
1239
|
+
const tools = ensureRecord(raw, "tools");
|
|
1240
|
+
const bash = getRecord(tools.bash);
|
|
1241
|
+
if (!bash) return;
|
|
1242
|
+
if (tools.exec === void 0) {
|
|
1243
|
+
tools.exec = bash;
|
|
1244
|
+
changes.push("Moved tools.bash → tools.exec.");
|
|
1245
|
+
} else changes.push("Removed tools.bash (tools.exec already set).");
|
|
1246
|
+
delete tools.bash;
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
id: "messages.tts.enabled->auto",
|
|
1251
|
+
describe: "Move messages.tts.enabled to messages.tts.auto",
|
|
1252
|
+
apply: (raw, changes) => {
|
|
1253
|
+
const tts = getRecord(getRecord(raw.messages)?.tts);
|
|
1254
|
+
if (!tts) return;
|
|
1255
|
+
if (tts.auto !== void 0) {
|
|
1256
|
+
if ("enabled" in tts) {
|
|
1257
|
+
delete tts.enabled;
|
|
1258
|
+
changes.push("Removed messages.tts.enabled (messages.tts.auto already set).");
|
|
1259
|
+
}
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
if (typeof tts.enabled !== "boolean") return;
|
|
1263
|
+
tts.auto = tts.enabled ? "always" : "off";
|
|
1264
|
+
delete tts.enabled;
|
|
1265
|
+
changes.push(`Moved messages.tts.enabled → messages.tts.auto (${String(tts.auto)}).`);
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
id: "agent.defaults-v2",
|
|
1270
|
+
describe: "Move agent config to agents.defaults and tools",
|
|
1271
|
+
apply: (raw, changes) => {
|
|
1272
|
+
const agent = getRecord(raw.agent);
|
|
1273
|
+
if (!agent) return;
|
|
1274
|
+
const agents = ensureRecord(raw, "agents");
|
|
1275
|
+
const defaults = getRecord(agents.defaults) ?? {};
|
|
1276
|
+
const tools = ensureRecord(raw, "tools");
|
|
1277
|
+
const agentTools = getRecord(agent.tools);
|
|
1278
|
+
if (agentTools) {
|
|
1279
|
+
if (tools.allow === void 0 && agentTools.allow !== void 0) {
|
|
1280
|
+
tools.allow = agentTools.allow;
|
|
1281
|
+
changes.push("Moved agent.tools.allow → tools.allow.");
|
|
1282
|
+
}
|
|
1283
|
+
if (tools.deny === void 0 && agentTools.deny !== void 0) {
|
|
1284
|
+
tools.deny = agentTools.deny;
|
|
1285
|
+
changes.push("Moved agent.tools.deny → tools.deny.");
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
const elevated = getRecord(agent.elevated);
|
|
1289
|
+
if (elevated) if (tools.elevated === void 0) {
|
|
1290
|
+
tools.elevated = elevated;
|
|
1291
|
+
changes.push("Moved agent.elevated → tools.elevated.");
|
|
1292
|
+
} else changes.push("Removed agent.elevated (tools.elevated already set).");
|
|
1293
|
+
const bash = getRecord(agent.bash);
|
|
1294
|
+
if (bash) if (tools.exec === void 0) {
|
|
1295
|
+
tools.exec = bash;
|
|
1296
|
+
changes.push("Moved agent.bash → tools.exec.");
|
|
1297
|
+
} else changes.push("Removed agent.bash (tools.exec already set).");
|
|
1298
|
+
const sandbox = getRecord(agent.sandbox);
|
|
1299
|
+
if (sandbox) {
|
|
1300
|
+
const sandboxTools = getRecord(sandbox.tools);
|
|
1301
|
+
if (sandboxTools) {
|
|
1302
|
+
mergeMissing(ensureRecord(ensureRecord(tools, "sandbox"), "tools"), sandboxTools);
|
|
1303
|
+
delete sandbox.tools;
|
|
1304
|
+
changes.push("Moved agent.sandbox.tools → tools.sandbox.tools.");
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
const subagents = getRecord(agent.subagents);
|
|
1308
|
+
if (subagents) {
|
|
1309
|
+
const subagentTools = getRecord(subagents.tools);
|
|
1310
|
+
if (subagentTools) {
|
|
1311
|
+
mergeMissing(ensureRecord(ensureRecord(tools, "subagents"), "tools"), subagentTools);
|
|
1312
|
+
delete subagents.tools;
|
|
1313
|
+
changes.push("Moved agent.subagents.tools → tools.subagents.tools.");
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
const agentCopy = structuredClone(agent);
|
|
1317
|
+
delete agentCopy.tools;
|
|
1318
|
+
delete agentCopy.elevated;
|
|
1319
|
+
delete agentCopy.bash;
|
|
1320
|
+
if (isRecord$1(agentCopy.sandbox)) delete agentCopy.sandbox.tools;
|
|
1321
|
+
if (isRecord$1(agentCopy.subagents)) delete agentCopy.subagents.tools;
|
|
1322
|
+
mergeMissing(defaults, agentCopy);
|
|
1323
|
+
agents.defaults = defaults;
|
|
1324
|
+
raw.agents = agents;
|
|
1325
|
+
delete raw.agent;
|
|
1326
|
+
changes.push("Moved agent → agents.defaults.");
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
id: "identity->agents.list",
|
|
1331
|
+
describe: "Move identity to agents.list[].identity",
|
|
1332
|
+
apply: (raw, changes) => {
|
|
1333
|
+
const identity = getRecord(raw.identity);
|
|
1334
|
+
if (!identity) return;
|
|
1335
|
+
const agents = ensureRecord(raw, "agents");
|
|
1336
|
+
const list = getAgentsList(agents);
|
|
1337
|
+
const defaultId = resolveDefaultAgentIdFromRaw(raw);
|
|
1338
|
+
const entry = ensureAgentEntry(list, defaultId);
|
|
1339
|
+
if (entry.identity === void 0) {
|
|
1340
|
+
entry.identity = identity;
|
|
1341
|
+
changes.push(`Moved identity → agents.list (id "${defaultId}").identity.`);
|
|
1342
|
+
} else changes.push("Removed identity (agents.list identity already set).");
|
|
1343
|
+
agents.list = list;
|
|
1344
|
+
raw.agents = agents;
|
|
1345
|
+
delete raw.identity;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
];
|
|
1349
|
+
|
|
1350
|
+
//#endregion
|
|
1351
|
+
//#region src/config/legacy.migrations.ts
|
|
1352
|
+
const LEGACY_CONFIG_MIGRATIONS = [
|
|
1353
|
+
...LEGACY_CONFIG_MIGRATIONS_PART_1,
|
|
1354
|
+
...LEGACY_CONFIG_MIGRATIONS_PART_2,
|
|
1355
|
+
...LEGACY_CONFIG_MIGRATIONS_PART_3
|
|
1356
|
+
];
|
|
1357
|
+
|
|
1358
|
+
//#endregion
|
|
1359
|
+
//#region src/config/legacy.rules.ts
|
|
1360
|
+
const LEGACY_CONFIG_RULES = [
|
|
1361
|
+
{
|
|
1362
|
+
path: ["whatsapp"],
|
|
1363
|
+
message: "whatsapp config moved to channels.whatsapp (auto-migrated on load)."
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
path: ["telegram"],
|
|
1367
|
+
message: "telegram config moved to channels.telegram (auto-migrated on load)."
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
path: ["discord"],
|
|
1371
|
+
message: "discord config moved to channels.discord (auto-migrated on load)."
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
path: ["slack"],
|
|
1375
|
+
message: "slack config moved to channels.slack (auto-migrated on load)."
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
path: ["signal"],
|
|
1379
|
+
message: "signal config moved to channels.signal (auto-migrated on load)."
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
path: ["imessage"],
|
|
1383
|
+
message: "imessage config moved to channels.imessage (auto-migrated on load)."
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
path: ["msteams"],
|
|
1387
|
+
message: "msteams config moved to channels.msteams (auto-migrated on load)."
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
path: ["routing", "allowFrom"],
|
|
1391
|
+
message: "routing.allowFrom was removed; use channels.whatsapp.allowFrom instead (auto-migrated on load)."
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
path: ["routing", "bindings"],
|
|
1395
|
+
message: "routing.bindings was moved; use top-level bindings instead (auto-migrated on load)."
|
|
1396
|
+
},
|
|
1397
|
+
{
|
|
1398
|
+
path: ["routing", "agents"],
|
|
1399
|
+
message: "routing.agents was moved; use agents.list instead (auto-migrated on load)."
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
path: ["routing", "defaultAgentId"],
|
|
1403
|
+
message: "routing.defaultAgentId was moved; use agents.list[].default instead (auto-migrated on load)."
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
path: ["routing", "agentToAgent"],
|
|
1407
|
+
message: "routing.agentToAgent was moved; use tools.agentToAgent instead (auto-migrated on load)."
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
path: [
|
|
1411
|
+
"routing",
|
|
1412
|
+
"groupChat",
|
|
1413
|
+
"requireMention"
|
|
1414
|
+
],
|
|
1415
|
+
message: "routing.groupChat.requireMention was removed; use channels.whatsapp/telegram/imessage groups defaults (e.g. channels.whatsapp.groups.\"*\".requireMention) instead (auto-migrated on load)."
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
path: [
|
|
1419
|
+
"routing",
|
|
1420
|
+
"groupChat",
|
|
1421
|
+
"mentionPatterns"
|
|
1422
|
+
],
|
|
1423
|
+
message: "routing.groupChat.mentionPatterns was moved; use agents.list[].groupChat.mentionPatterns or messages.groupChat.mentionPatterns instead (auto-migrated on load)."
|
|
1424
|
+
},
|
|
1425
|
+
{
|
|
1426
|
+
path: ["routing", "queue"],
|
|
1427
|
+
message: "routing.queue was moved; use messages.queue instead (auto-migrated on load)."
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
path: ["routing", "transcribeAudio"],
|
|
1431
|
+
message: "routing.transcribeAudio was moved; use tools.media.audio.models instead (auto-migrated on load)."
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
path: ["telegram", "requireMention"],
|
|
1435
|
+
message: "telegram.requireMention was removed; use channels.telegram.groups.\"*\".requireMention instead (auto-migrated on load)."
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
path: ["identity"],
|
|
1439
|
+
message: "identity was moved; use agents.list[].identity instead (auto-migrated on load)."
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
path: ["agent"],
|
|
1443
|
+
message: "agent.* was moved; use agents.defaults (and tools.* for tool/elevated/exec settings) instead (auto-migrated on load)."
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
path: ["tools", "bash"],
|
|
1447
|
+
message: "tools.bash was removed; use tools.exec instead (auto-migrated on load)."
|
|
1448
|
+
},
|
|
1449
|
+
{
|
|
1450
|
+
path: ["agent", "model"],
|
|
1451
|
+
message: "agent.model string was replaced by agents.defaults.model.primary/fallbacks and agents.defaults.models (auto-migrated on load).",
|
|
1452
|
+
match: (value) => typeof value === "string"
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
path: ["agent", "imageModel"],
|
|
1456
|
+
message: "agent.imageModel string was replaced by agents.defaults.imageModel.primary/fallbacks (auto-migrated on load).",
|
|
1457
|
+
match: (value) => typeof value === "string"
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
path: ["agent", "allowedModels"],
|
|
1461
|
+
message: "agent.allowedModels was replaced by agents.defaults.models (auto-migrated on load)."
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
path: ["agent", "modelAliases"],
|
|
1465
|
+
message: "agent.modelAliases was replaced by agents.defaults.models.*.alias (auto-migrated on load)."
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
path: ["agent", "modelFallbacks"],
|
|
1469
|
+
message: "agent.modelFallbacks was replaced by agents.defaults.model.fallbacks (auto-migrated on load)."
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
path: ["agent", "imageModelFallbacks"],
|
|
1473
|
+
message: "agent.imageModelFallbacks was replaced by agents.defaults.imageModel.fallbacks (auto-migrated on load)."
|
|
1474
|
+
},
|
|
1475
|
+
{
|
|
1476
|
+
path: [
|
|
1477
|
+
"messages",
|
|
1478
|
+
"tts",
|
|
1479
|
+
"enabled"
|
|
1480
|
+
],
|
|
1481
|
+
message: "messages.tts.enabled was replaced by messages.tts.auto (auto-migrated on load)."
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
path: ["gateway", "token"],
|
|
1485
|
+
message: "gateway.token is ignored; use gateway.auth.token instead (auto-migrated on load)."
|
|
1486
|
+
}
|
|
1487
|
+
];
|
|
1488
|
+
|
|
1489
|
+
//#endregion
|
|
1490
|
+
//#region src/config/legacy.ts
|
|
1491
|
+
function findLegacyConfigIssues(raw) {
|
|
1492
|
+
if (!raw || typeof raw !== "object") return [];
|
|
1493
|
+
const root = raw;
|
|
1494
|
+
const issues = [];
|
|
1495
|
+
for (const rule of LEGACY_CONFIG_RULES) {
|
|
1496
|
+
let cursor = root;
|
|
1497
|
+
for (const key of rule.path) {
|
|
1498
|
+
if (!cursor || typeof cursor !== "object") {
|
|
1499
|
+
cursor = void 0;
|
|
1500
|
+
break;
|
|
1501
|
+
}
|
|
1502
|
+
cursor = cursor[key];
|
|
1503
|
+
}
|
|
1504
|
+
if (cursor !== void 0 && (!rule.match || rule.match(cursor, root))) issues.push({
|
|
1505
|
+
path: rule.path.join("."),
|
|
1506
|
+
message: rule.message
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
return issues;
|
|
1510
|
+
}
|
|
1511
|
+
function applyLegacyMigrations(raw) {
|
|
1512
|
+
if (!raw || typeof raw !== "object") return {
|
|
1513
|
+
next: null,
|
|
1514
|
+
changes: []
|
|
1515
|
+
};
|
|
1516
|
+
const next = structuredClone(raw);
|
|
1517
|
+
const changes = [];
|
|
1518
|
+
for (const migration of LEGACY_CONFIG_MIGRATIONS) migration.apply(next, changes);
|
|
1519
|
+
if (changes.length === 0) return {
|
|
1520
|
+
next: null,
|
|
1521
|
+
changes: []
|
|
1522
|
+
};
|
|
1523
|
+
return {
|
|
1524
|
+
next,
|
|
1525
|
+
changes
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
//#endregion
|
|
1530
|
+
//#region src/config/normalize-paths.ts
|
|
1531
|
+
const PATH_VALUE_RE = /^~(?=$|[\\/])/;
|
|
1532
|
+
const PATH_KEY_RE = /(dir|path|paths|file|root|workspace)$/i;
|
|
1533
|
+
const PATH_LIST_KEYS = new Set(["paths", "pathPrepend"]);
|
|
1534
|
+
function isPlainObject$2(value) {
|
|
1535
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1536
|
+
}
|
|
1537
|
+
function normalizeStringValue(key, value) {
|
|
1538
|
+
if (!PATH_VALUE_RE.test(value.trim())) return value;
|
|
1539
|
+
if (!key) return value;
|
|
1540
|
+
if (PATH_KEY_RE.test(key) || PATH_LIST_KEYS.has(key)) return resolveUserPath(value);
|
|
1541
|
+
return value;
|
|
1542
|
+
}
|
|
1543
|
+
function normalizeAny(key, value) {
|
|
1544
|
+
if (typeof value === "string") return normalizeStringValue(key, value);
|
|
1545
|
+
if (Array.isArray(value)) {
|
|
1546
|
+
const normalizeChildren = Boolean(key && PATH_LIST_KEYS.has(key));
|
|
1547
|
+
return value.map((entry) => {
|
|
1548
|
+
if (typeof entry === "string") return normalizeChildren ? normalizeStringValue(key, entry) : entry;
|
|
1549
|
+
if (Array.isArray(entry)) return normalizeAny(void 0, entry);
|
|
1550
|
+
if (isPlainObject$2(entry)) return normalizeAny(void 0, entry);
|
|
1551
|
+
return entry;
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
if (!isPlainObject$2(value)) return value;
|
|
1555
|
+
for (const [childKey, childValue] of Object.entries(value)) {
|
|
1556
|
+
const next = normalizeAny(childKey, childValue);
|
|
1557
|
+
if (next !== childValue) value[childKey] = next;
|
|
1558
|
+
}
|
|
1559
|
+
return value;
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Normalize "~" paths in path-ish config fields.
|
|
1563
|
+
*
|
|
1564
|
+
* Goal: accept `~/...` consistently across config file + env overrides, while
|
|
1565
|
+
* keeping the surface area small and predictable.
|
|
1566
|
+
*/
|
|
1567
|
+
function normalizeConfigPaths(cfg) {
|
|
1568
|
+
if (!cfg || typeof cfg !== "object") return cfg;
|
|
1569
|
+
normalizeAny(void 0, cfg);
|
|
1570
|
+
return cfg;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
//#endregion
|
|
1574
|
+
//#region src/config/config-paths.ts
|
|
1575
|
+
const BLOCKED_KEYS = new Set([
|
|
1576
|
+
"__proto__",
|
|
1577
|
+
"prototype",
|
|
1578
|
+
"constructor"
|
|
1579
|
+
]);
|
|
1580
|
+
function parseConfigPath(raw) {
|
|
1581
|
+
const trimmed = raw.trim();
|
|
1582
|
+
if (!trimmed) return {
|
|
1583
|
+
ok: false,
|
|
1584
|
+
error: "Invalid path. Use dot notation (e.g. foo.bar)."
|
|
1585
|
+
};
|
|
1586
|
+
const parts = trimmed.split(".").map((part) => part.trim());
|
|
1587
|
+
if (parts.some((part) => !part)) return {
|
|
1588
|
+
ok: false,
|
|
1589
|
+
error: "Invalid path. Use dot notation (e.g. foo.bar)."
|
|
1590
|
+
};
|
|
1591
|
+
if (parts.some((part) => BLOCKED_KEYS.has(part))) return {
|
|
1592
|
+
ok: false,
|
|
1593
|
+
error: "Invalid path segment."
|
|
1594
|
+
};
|
|
1595
|
+
return {
|
|
1596
|
+
ok: true,
|
|
1597
|
+
path: parts
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
function setConfigValueAtPath(root, path, value) {
|
|
1601
|
+
let cursor = root;
|
|
1602
|
+
for (let idx = 0; idx < path.length - 1; idx += 1) {
|
|
1603
|
+
const key = path[idx];
|
|
1604
|
+
const next = cursor[key];
|
|
1605
|
+
if (!isPlainObject$1(next)) cursor[key] = {};
|
|
1606
|
+
cursor = cursor[key];
|
|
1607
|
+
}
|
|
1608
|
+
cursor[path[path.length - 1]] = value;
|
|
1609
|
+
}
|
|
1610
|
+
function unsetConfigValueAtPath(root, path) {
|
|
1611
|
+
const stack = [];
|
|
1612
|
+
let cursor = root;
|
|
1613
|
+
for (let idx = 0; idx < path.length - 1; idx += 1) {
|
|
1614
|
+
const key = path[idx];
|
|
1615
|
+
const next = cursor[key];
|
|
1616
|
+
if (!isPlainObject$1(next)) return false;
|
|
1617
|
+
stack.push({
|
|
1618
|
+
node: cursor,
|
|
1619
|
+
key
|
|
1620
|
+
});
|
|
1621
|
+
cursor = next;
|
|
1622
|
+
}
|
|
1623
|
+
const leafKey = path[path.length - 1];
|
|
1624
|
+
if (!(leafKey in cursor)) return false;
|
|
1625
|
+
delete cursor[leafKey];
|
|
1626
|
+
for (let idx = stack.length - 1; idx >= 0; idx -= 1) {
|
|
1627
|
+
const { node, key } = stack[idx];
|
|
1628
|
+
const child = node[key];
|
|
1629
|
+
if (isPlainObject$1(child) && Object.keys(child).length === 0) delete node[key];
|
|
1630
|
+
else break;
|
|
1631
|
+
}
|
|
1632
|
+
return true;
|
|
1633
|
+
}
|
|
1634
|
+
function getConfigValueAtPath(root, path) {
|
|
1635
|
+
let cursor = root;
|
|
1636
|
+
for (const key of path) {
|
|
1637
|
+
if (!isPlainObject$1(cursor)) return;
|
|
1638
|
+
cursor = cursor[key];
|
|
1639
|
+
}
|
|
1640
|
+
return cursor;
|
|
1641
|
+
}
|
|
1642
|
+
function isPlainObject$1(value) {
|
|
1643
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
//#endregion
|
|
1647
|
+
//#region src/config/runtime-overrides.ts
|
|
1648
|
+
let overrides = {};
|
|
1649
|
+
function mergeOverrides(base, override) {
|
|
1650
|
+
if (!isPlainObject(base) || !isPlainObject(override)) return override;
|
|
1651
|
+
const next = { ...base };
|
|
1652
|
+
for (const [key, value] of Object.entries(override)) {
|
|
1653
|
+
if (value === void 0) continue;
|
|
1654
|
+
next[key] = mergeOverrides(base[key], value);
|
|
1655
|
+
}
|
|
1656
|
+
return next;
|
|
1657
|
+
}
|
|
1658
|
+
function isPlainObject(value) {
|
|
1659
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value) === "[object Object]";
|
|
1660
|
+
}
|
|
1661
|
+
function getConfigOverrides() {
|
|
1662
|
+
return overrides;
|
|
1663
|
+
}
|
|
1664
|
+
function resetConfigOverrides() {
|
|
1665
|
+
overrides = {};
|
|
1666
|
+
}
|
|
1667
|
+
function setConfigOverride(pathRaw, value) {
|
|
1668
|
+
const parsed = parseConfigPath(pathRaw);
|
|
1669
|
+
if (!parsed.ok || !parsed.path) return {
|
|
1670
|
+
ok: false,
|
|
1671
|
+
error: parsed.error ?? "Invalid path."
|
|
1672
|
+
};
|
|
1673
|
+
setConfigValueAtPath(overrides, parsed.path, value);
|
|
1674
|
+
return { ok: true };
|
|
1675
|
+
}
|
|
1676
|
+
function unsetConfigOverride(pathRaw) {
|
|
1677
|
+
const parsed = parseConfigPath(pathRaw);
|
|
1678
|
+
if (!parsed.ok || !parsed.path) return {
|
|
1679
|
+
ok: false,
|
|
1680
|
+
removed: false,
|
|
1681
|
+
error: parsed.error ?? "Invalid path."
|
|
1682
|
+
};
|
|
1683
|
+
return {
|
|
1684
|
+
ok: true,
|
|
1685
|
+
removed: unsetConfigValueAtPath(overrides, parsed.path)
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
function applyConfigOverrides(cfg) {
|
|
1689
|
+
if (!overrides || Object.keys(overrides).length === 0) return cfg;
|
|
1690
|
+
return mergeOverrides(cfg, overrides);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
//#endregion
|
|
1694
|
+
//#region src/plugins/schema-validator.ts
|
|
1695
|
+
const ajv = new AjvPkg({
|
|
1696
|
+
allErrors: true,
|
|
1697
|
+
strict: false,
|
|
1698
|
+
removeAdditional: false
|
|
1699
|
+
});
|
|
1700
|
+
const schemaCache = /* @__PURE__ */ new Map();
|
|
1701
|
+
function formatAjvErrors(errors) {
|
|
1702
|
+
if (!errors || errors.length === 0) return ["invalid config"];
|
|
1703
|
+
return errors.map((error) => {
|
|
1704
|
+
return `${error.instancePath?.replace(/^\//, "").replace(/\//g, ".") || "<root>"}: ${error.message ?? "invalid"}`;
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
function validateJsonSchemaValue(params) {
|
|
1708
|
+
let cached = schemaCache.get(params.cacheKey);
|
|
1709
|
+
if (!cached || cached.schema !== params.schema) {
|
|
1710
|
+
cached = {
|
|
1711
|
+
validate: ajv.compile(params.schema),
|
|
1712
|
+
schema: params.schema
|
|
1713
|
+
};
|
|
1714
|
+
schemaCache.set(params.cacheKey, cached);
|
|
1715
|
+
}
|
|
1716
|
+
if (cached.validate(params.value)) return { ok: true };
|
|
1717
|
+
return {
|
|
1718
|
+
ok: false,
|
|
1719
|
+
errors: formatAjvErrors(cached.validate.errors)
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
//#endregion
|
|
1724
|
+
//#region src/cli/parse-duration.ts
|
|
1725
|
+
function parseDurationMs(raw, opts) {
|
|
1726
|
+
const trimmed = String(raw ?? "").trim().toLowerCase();
|
|
1727
|
+
if (!trimmed) throw new Error("invalid duration (empty)");
|
|
1728
|
+
const m = /^(\d+(?:\.\d+)?)(ms|s|m|h|d)?$/.exec(trimmed);
|
|
1729
|
+
if (!m) throw new Error(`invalid duration: ${raw}`);
|
|
1730
|
+
const value = Number(m[1]);
|
|
1731
|
+
if (!Number.isFinite(value) || value < 0) throw new Error(`invalid duration: ${raw}`);
|
|
1732
|
+
const unit = m[2] ?? opts?.defaultUnit ?? "ms";
|
|
1733
|
+
const multiplier = unit === "ms" ? 1 : unit === "s" ? 1e3 : unit === "m" ? 6e4 : unit === "h" ? 36e5 : 864e5;
|
|
1734
|
+
const ms = Math.round(value * multiplier);
|
|
1735
|
+
if (!Number.isFinite(ms)) throw new Error(`invalid duration: ${raw}`);
|
|
1736
|
+
return ms;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
//#endregion
|
|
1740
|
+
//#region src/infra/exec-safety.ts
|
|
1741
|
+
const SHELL_METACHARS = /[;&|`$<>]/;
|
|
1742
|
+
const CONTROL_CHARS = /[\r\n]/;
|
|
1743
|
+
const QUOTE_CHARS = /["']/;
|
|
1744
|
+
const BARE_NAME_PATTERN = /^[A-Za-z0-9._+-]+$/;
|
|
1745
|
+
function isLikelyPath(value) {
|
|
1746
|
+
if (value.startsWith(".") || value.startsWith("~")) return true;
|
|
1747
|
+
if (value.includes("/") || value.includes("\\")) return true;
|
|
1748
|
+
return /^[A-Za-z]:[\\/]/.test(value);
|
|
1749
|
+
}
|
|
1750
|
+
function isSafeExecutableValue(value) {
|
|
1751
|
+
if (!value) return false;
|
|
1752
|
+
const trimmed = value.trim();
|
|
1753
|
+
if (!trimmed) return false;
|
|
1754
|
+
if (trimmed.includes("\0")) return false;
|
|
1755
|
+
if (CONTROL_CHARS.test(trimmed)) return false;
|
|
1756
|
+
if (SHELL_METACHARS.test(trimmed)) return false;
|
|
1757
|
+
if (QUOTE_CHARS.test(trimmed)) return false;
|
|
1758
|
+
if (isLikelyPath(trimmed)) return true;
|
|
1759
|
+
if (trimmed.startsWith("-")) return false;
|
|
1760
|
+
return BARE_NAME_PATTERN.test(trimmed);
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
//#endregion
|
|
1764
|
+
//#region src/config/zod-schema.core.ts
|
|
1765
|
+
const ModelApiSchema = z.union([
|
|
1766
|
+
z.literal("openai-completions"),
|
|
1767
|
+
z.literal("openai-responses"),
|
|
1768
|
+
z.literal("anthropic-messages"),
|
|
1769
|
+
z.literal("google-generative-ai"),
|
|
1770
|
+
z.literal("github-copilot"),
|
|
1771
|
+
z.literal("bedrock-converse-stream")
|
|
1772
|
+
]);
|
|
1773
|
+
const ModelCompatSchema = z.object({
|
|
1774
|
+
supportsStore: z.boolean().optional(),
|
|
1775
|
+
supportsDeveloperRole: z.boolean().optional(),
|
|
1776
|
+
supportsReasoningEffort: z.boolean().optional(),
|
|
1777
|
+
maxTokensField: z.union([z.literal("max_completion_tokens"), z.literal("max_tokens")]).optional()
|
|
1778
|
+
}).strict().optional();
|
|
1779
|
+
const ModelDefinitionSchema = z.object({
|
|
1780
|
+
id: z.string().min(1),
|
|
1781
|
+
name: z.string().min(1),
|
|
1782
|
+
api: ModelApiSchema.optional(),
|
|
1783
|
+
reasoning: z.boolean().optional(),
|
|
1784
|
+
input: z.array(z.union([z.literal("text"), z.literal("image")])).optional(),
|
|
1785
|
+
cost: z.object({
|
|
1786
|
+
input: z.number().optional(),
|
|
1787
|
+
output: z.number().optional(),
|
|
1788
|
+
cacheRead: z.number().optional(),
|
|
1789
|
+
cacheWrite: z.number().optional()
|
|
1790
|
+
}).strict().optional(),
|
|
1791
|
+
contextWindow: z.number().positive().optional(),
|
|
1792
|
+
maxTokens: z.number().positive().optional(),
|
|
1793
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
1794
|
+
compat: ModelCompatSchema
|
|
1795
|
+
}).strict();
|
|
1796
|
+
const ModelProviderSchema = z.object({
|
|
1797
|
+
baseUrl: z.string().min(1),
|
|
1798
|
+
apiKey: z.string().optional(),
|
|
1799
|
+
auth: z.union([
|
|
1800
|
+
z.literal("api-key"),
|
|
1801
|
+
z.literal("aws-sdk"),
|
|
1802
|
+
z.literal("oauth"),
|
|
1803
|
+
z.literal("token")
|
|
1804
|
+
]).optional(),
|
|
1805
|
+
api: ModelApiSchema.optional(),
|
|
1806
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
1807
|
+
authHeader: z.boolean().optional(),
|
|
1808
|
+
models: z.array(ModelDefinitionSchema)
|
|
1809
|
+
}).strict();
|
|
1810
|
+
const BedrockDiscoverySchema = z.object({
|
|
1811
|
+
enabled: z.boolean().optional(),
|
|
1812
|
+
region: z.string().optional(),
|
|
1813
|
+
providerFilter: z.array(z.string()).optional(),
|
|
1814
|
+
refreshInterval: z.number().int().nonnegative().optional(),
|
|
1815
|
+
defaultContextWindow: z.number().int().positive().optional(),
|
|
1816
|
+
defaultMaxTokens: z.number().int().positive().optional()
|
|
1817
|
+
}).strict().optional();
|
|
1818
|
+
const ModelsConfigSchema = z.object({
|
|
1819
|
+
mode: z.union([z.literal("merge"), z.literal("replace")]).optional(),
|
|
1820
|
+
providers: z.record(z.string(), ModelProviderSchema).optional(),
|
|
1821
|
+
bedrockDiscovery: BedrockDiscoverySchema
|
|
1822
|
+
}).strict().optional();
|
|
1823
|
+
const GroupChatSchema = z.object({
|
|
1824
|
+
mentionPatterns: z.array(z.string()).optional(),
|
|
1825
|
+
historyLimit: z.number().int().positive().optional()
|
|
1826
|
+
}).strict().optional();
|
|
1827
|
+
const DmConfigSchema = z.object({ historyLimit: z.number().int().min(0).optional() }).strict();
|
|
1828
|
+
const IdentitySchema = z.object({
|
|
1829
|
+
name: z.string().optional(),
|
|
1830
|
+
theme: z.string().optional(),
|
|
1831
|
+
emoji: z.string().optional(),
|
|
1832
|
+
avatar: z.string().optional()
|
|
1833
|
+
}).strict().optional();
|
|
1834
|
+
const QueueModeSchema = z.union([
|
|
1835
|
+
z.literal("steer"),
|
|
1836
|
+
z.literal("followup"),
|
|
1837
|
+
z.literal("collect"),
|
|
1838
|
+
z.literal("steer-backlog"),
|
|
1839
|
+
z.literal("steer+backlog"),
|
|
1840
|
+
z.literal("queue"),
|
|
1841
|
+
z.literal("interrupt")
|
|
1842
|
+
]);
|
|
1843
|
+
const QueueDropSchema = z.union([
|
|
1844
|
+
z.literal("old"),
|
|
1845
|
+
z.literal("new"),
|
|
1846
|
+
z.literal("summarize")
|
|
1847
|
+
]);
|
|
1848
|
+
const ReplyToModeSchema = z.union([
|
|
1849
|
+
z.literal("off"),
|
|
1850
|
+
z.literal("first"),
|
|
1851
|
+
z.literal("all")
|
|
1852
|
+
]);
|
|
1853
|
+
const GroupPolicySchema = z.enum([
|
|
1854
|
+
"open",
|
|
1855
|
+
"disabled",
|
|
1856
|
+
"allowlist"
|
|
1857
|
+
]);
|
|
1858
|
+
const DmPolicySchema = z.enum([
|
|
1859
|
+
"pairing",
|
|
1860
|
+
"allowlist",
|
|
1861
|
+
"open",
|
|
1862
|
+
"disabled"
|
|
1863
|
+
]);
|
|
1864
|
+
const BlockStreamingCoalesceSchema = z.object({
|
|
1865
|
+
minChars: z.number().int().positive().optional(),
|
|
1866
|
+
maxChars: z.number().int().positive().optional(),
|
|
1867
|
+
idleMs: z.number().int().nonnegative().optional()
|
|
1868
|
+
}).strict();
|
|
1869
|
+
const BlockStreamingChunkSchema = z.object({
|
|
1870
|
+
minChars: z.number().int().positive().optional(),
|
|
1871
|
+
maxChars: z.number().int().positive().optional(),
|
|
1872
|
+
breakPreference: z.union([
|
|
1873
|
+
z.literal("paragraph"),
|
|
1874
|
+
z.literal("newline"),
|
|
1875
|
+
z.literal("sentence")
|
|
1876
|
+
]).optional()
|
|
1877
|
+
}).strict();
|
|
1878
|
+
const MarkdownTableModeSchema = z.enum([
|
|
1879
|
+
"off",
|
|
1880
|
+
"bullets",
|
|
1881
|
+
"code"
|
|
1882
|
+
]);
|
|
1883
|
+
const MarkdownConfigSchema = z.object({ tables: MarkdownTableModeSchema.optional() }).strict().optional();
|
|
1884
|
+
const TtsProviderSchema = z.enum([
|
|
1885
|
+
"elevenlabs",
|
|
1886
|
+
"openai",
|
|
1887
|
+
"edge"
|
|
1888
|
+
]);
|
|
1889
|
+
const TtsModeSchema = z.enum(["final", "all"]);
|
|
1890
|
+
const TtsAutoSchema = z.enum([
|
|
1891
|
+
"off",
|
|
1892
|
+
"always",
|
|
1893
|
+
"inbound",
|
|
1894
|
+
"tagged"
|
|
1895
|
+
]);
|
|
1896
|
+
const TtsConfigSchema = z.object({
|
|
1897
|
+
auto: TtsAutoSchema.optional(),
|
|
1898
|
+
enabled: z.boolean().optional(),
|
|
1899
|
+
mode: TtsModeSchema.optional(),
|
|
1900
|
+
provider: TtsProviderSchema.optional(),
|
|
1901
|
+
summaryModel: z.string().optional(),
|
|
1902
|
+
modelOverrides: z.object({
|
|
1903
|
+
enabled: z.boolean().optional(),
|
|
1904
|
+
allowText: z.boolean().optional(),
|
|
1905
|
+
allowProvider: z.boolean().optional(),
|
|
1906
|
+
allowVoice: z.boolean().optional(),
|
|
1907
|
+
allowModelId: z.boolean().optional(),
|
|
1908
|
+
allowVoiceSettings: z.boolean().optional(),
|
|
1909
|
+
allowNormalization: z.boolean().optional(),
|
|
1910
|
+
allowSeed: z.boolean().optional()
|
|
1911
|
+
}).strict().optional(),
|
|
1912
|
+
elevenlabs: z.object({
|
|
1913
|
+
apiKey: z.string().optional(),
|
|
1914
|
+
baseUrl: z.string().optional(),
|
|
1915
|
+
voiceId: z.string().optional(),
|
|
1916
|
+
modelId: z.string().optional(),
|
|
1917
|
+
seed: z.number().int().min(0).max(4294967295).optional(),
|
|
1918
|
+
applyTextNormalization: z.enum([
|
|
1919
|
+
"auto",
|
|
1920
|
+
"on",
|
|
1921
|
+
"off"
|
|
1922
|
+
]).optional(),
|
|
1923
|
+
languageCode: z.string().optional(),
|
|
1924
|
+
voiceSettings: z.object({
|
|
1925
|
+
stability: z.number().min(0).max(1).optional(),
|
|
1926
|
+
similarityBoost: z.number().min(0).max(1).optional(),
|
|
1927
|
+
style: z.number().min(0).max(1).optional(),
|
|
1928
|
+
useSpeakerBoost: z.boolean().optional(),
|
|
1929
|
+
speed: z.number().min(.5).max(2).optional()
|
|
1930
|
+
}).strict().optional()
|
|
1931
|
+
}).strict().optional(),
|
|
1932
|
+
openai: z.object({
|
|
1933
|
+
apiKey: z.string().optional(),
|
|
1934
|
+
model: z.string().optional(),
|
|
1935
|
+
voice: z.string().optional()
|
|
1936
|
+
}).strict().optional(),
|
|
1937
|
+
edge: z.object({
|
|
1938
|
+
enabled: z.boolean().optional(),
|
|
1939
|
+
voice: z.string().optional(),
|
|
1940
|
+
lang: z.string().optional(),
|
|
1941
|
+
outputFormat: z.string().optional(),
|
|
1942
|
+
pitch: z.string().optional(),
|
|
1943
|
+
rate: z.string().optional(),
|
|
1944
|
+
volume: z.string().optional(),
|
|
1945
|
+
saveSubtitles: z.boolean().optional(),
|
|
1946
|
+
proxy: z.string().optional(),
|
|
1947
|
+
timeoutMs: z.number().int().min(1e3).max(12e4).optional()
|
|
1948
|
+
}).strict().optional(),
|
|
1949
|
+
prefsPath: z.string().optional(),
|
|
1950
|
+
maxTextLength: z.number().int().min(1).optional(),
|
|
1951
|
+
timeoutMs: z.number().int().min(1e3).max(12e4).optional()
|
|
1952
|
+
}).strict().optional();
|
|
1953
|
+
const HumanDelaySchema = z.object({
|
|
1954
|
+
mode: z.union([
|
|
1955
|
+
z.literal("off"),
|
|
1956
|
+
z.literal("natural"),
|
|
1957
|
+
z.literal("custom")
|
|
1958
|
+
]).optional(),
|
|
1959
|
+
minMs: z.number().int().nonnegative().optional(),
|
|
1960
|
+
maxMs: z.number().int().nonnegative().optional()
|
|
1961
|
+
}).strict();
|
|
1962
|
+
const CliBackendSchema = z.object({
|
|
1963
|
+
command: z.string(),
|
|
1964
|
+
args: z.array(z.string()).optional(),
|
|
1965
|
+
output: z.union([
|
|
1966
|
+
z.literal("json"),
|
|
1967
|
+
z.literal("text"),
|
|
1968
|
+
z.literal("jsonl")
|
|
1969
|
+
]).optional(),
|
|
1970
|
+
resumeOutput: z.union([
|
|
1971
|
+
z.literal("json"),
|
|
1972
|
+
z.literal("text"),
|
|
1973
|
+
z.literal("jsonl")
|
|
1974
|
+
]).optional(),
|
|
1975
|
+
input: z.union([z.literal("arg"), z.literal("stdin")]).optional(),
|
|
1976
|
+
maxPromptArgChars: z.number().int().positive().optional(),
|
|
1977
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
1978
|
+
clearEnv: z.array(z.string()).optional(),
|
|
1979
|
+
modelArg: z.string().optional(),
|
|
1980
|
+
modelAliases: z.record(z.string(), z.string()).optional(),
|
|
1981
|
+
sessionArg: z.string().optional(),
|
|
1982
|
+
sessionArgs: z.array(z.string()).optional(),
|
|
1983
|
+
resumeArgs: z.array(z.string()).optional(),
|
|
1984
|
+
sessionMode: z.union([
|
|
1985
|
+
z.literal("always"),
|
|
1986
|
+
z.literal("existing"),
|
|
1987
|
+
z.literal("none")
|
|
1988
|
+
]).optional(),
|
|
1989
|
+
sessionIdFields: z.array(z.string()).optional(),
|
|
1990
|
+
systemPromptArg: z.string().optional(),
|
|
1991
|
+
systemPromptMode: z.union([z.literal("append"), z.literal("replace")]).optional(),
|
|
1992
|
+
systemPromptWhen: z.union([
|
|
1993
|
+
z.literal("first"),
|
|
1994
|
+
z.literal("always"),
|
|
1995
|
+
z.literal("never")
|
|
1996
|
+
]).optional(),
|
|
1997
|
+
imageArg: z.string().optional(),
|
|
1998
|
+
imageMode: z.union([z.literal("repeat"), z.literal("list")]).optional(),
|
|
1999
|
+
serialize: z.boolean().optional()
|
|
2000
|
+
}).strict();
|
|
2001
|
+
const normalizeAllowFrom = (values) => (values ?? []).map((v) => String(v).trim()).filter(Boolean);
|
|
2002
|
+
const requireOpenAllowFrom = (params) => {
|
|
2003
|
+
if (params.policy !== "open") return;
|
|
2004
|
+
if (normalizeAllowFrom(params.allowFrom).includes("*")) return;
|
|
2005
|
+
params.ctx.addIssue({
|
|
2006
|
+
code: z.ZodIssueCode.custom,
|
|
2007
|
+
path: params.path,
|
|
2008
|
+
message: params.message
|
|
2009
|
+
});
|
|
2010
|
+
};
|
|
2011
|
+
const MSTeamsReplyStyleSchema = z.enum(["thread", "top-level"]);
|
|
2012
|
+
const RetryConfigSchema = z.object({
|
|
2013
|
+
attempts: z.number().int().min(1).optional(),
|
|
2014
|
+
minDelayMs: z.number().int().min(0).optional(),
|
|
2015
|
+
maxDelayMs: z.number().int().min(0).optional(),
|
|
2016
|
+
jitter: z.number().min(0).max(1).optional()
|
|
2017
|
+
}).strict().optional();
|
|
2018
|
+
const QueueModeBySurfaceSchema = z.object({
|
|
2019
|
+
whatsapp: QueueModeSchema.optional(),
|
|
2020
|
+
telegram: QueueModeSchema.optional(),
|
|
2021
|
+
discord: QueueModeSchema.optional(),
|
|
2022
|
+
slack: QueueModeSchema.optional(),
|
|
2023
|
+
mattermost: QueueModeSchema.optional(),
|
|
2024
|
+
signal: QueueModeSchema.optional(),
|
|
2025
|
+
imessage: QueueModeSchema.optional(),
|
|
2026
|
+
msteams: QueueModeSchema.optional(),
|
|
2027
|
+
webchat: QueueModeSchema.optional()
|
|
2028
|
+
}).strict().optional();
|
|
2029
|
+
const DebounceMsBySurfaceSchema = z.record(z.string(), z.number().int().nonnegative()).optional();
|
|
2030
|
+
const QueueSchema = z.object({
|
|
2031
|
+
mode: QueueModeSchema.optional(),
|
|
2032
|
+
byChannel: QueueModeBySurfaceSchema,
|
|
2033
|
+
debounceMs: z.number().int().nonnegative().optional(),
|
|
2034
|
+
debounceMsByChannel: DebounceMsBySurfaceSchema,
|
|
2035
|
+
cap: z.number().int().positive().optional(),
|
|
2036
|
+
drop: QueueDropSchema.optional()
|
|
2037
|
+
}).strict().optional();
|
|
2038
|
+
const InboundDebounceSchema = z.object({
|
|
2039
|
+
debounceMs: z.number().int().nonnegative().optional(),
|
|
2040
|
+
byChannel: DebounceMsBySurfaceSchema
|
|
2041
|
+
}).strict().optional();
|
|
2042
|
+
const TranscribeAudioSchema = z.object({
|
|
2043
|
+
command: z.array(z.string()).superRefine((value, ctx) => {
|
|
2044
|
+
const executable = value[0];
|
|
2045
|
+
if (!isSafeExecutableValue(executable)) ctx.addIssue({
|
|
2046
|
+
code: z.ZodIssueCode.custom,
|
|
2047
|
+
path: [0],
|
|
2048
|
+
message: "expected safe executable name or path"
|
|
2049
|
+
});
|
|
2050
|
+
}),
|
|
2051
|
+
timeoutSeconds: z.number().int().positive().optional()
|
|
2052
|
+
}).strict().optional();
|
|
2053
|
+
const HexColorSchema = z.string().regex(/^#?[0-9a-fA-F]{6}$/, "expected hex color (RRGGBB)");
|
|
2054
|
+
const ExecutableTokenSchema = z.string().refine(isSafeExecutableValue, "expected safe executable name or path");
|
|
2055
|
+
const MediaUnderstandingScopeSchema = z.object({
|
|
2056
|
+
default: z.union([z.literal("allow"), z.literal("deny")]).optional(),
|
|
2057
|
+
rules: z.array(z.object({
|
|
2058
|
+
action: z.union([z.literal("allow"), z.literal("deny")]),
|
|
2059
|
+
match: z.object({
|
|
2060
|
+
channel: z.string().optional(),
|
|
2061
|
+
chatType: z.union([
|
|
2062
|
+
z.literal("direct"),
|
|
2063
|
+
z.literal("group"),
|
|
2064
|
+
z.literal("channel")
|
|
2065
|
+
]).optional(),
|
|
2066
|
+
keyPrefix: z.string().optional()
|
|
2067
|
+
}).strict().optional()
|
|
2068
|
+
}).strict()).optional()
|
|
2069
|
+
}).strict().optional();
|
|
2070
|
+
const MediaUnderstandingCapabilitiesSchema = z.array(z.union([
|
|
2071
|
+
z.literal("image"),
|
|
2072
|
+
z.literal("audio"),
|
|
2073
|
+
z.literal("video")
|
|
2074
|
+
])).optional();
|
|
2075
|
+
const MediaUnderstandingAttachmentsSchema = z.object({
|
|
2076
|
+
mode: z.union([z.literal("first"), z.literal("all")]).optional(),
|
|
2077
|
+
maxAttachments: z.number().int().positive().optional(),
|
|
2078
|
+
prefer: z.union([
|
|
2079
|
+
z.literal("first"),
|
|
2080
|
+
z.literal("last"),
|
|
2081
|
+
z.literal("path"),
|
|
2082
|
+
z.literal("url")
|
|
2083
|
+
]).optional()
|
|
2084
|
+
}).strict().optional();
|
|
2085
|
+
const DeepgramAudioSchema = z.object({
|
|
2086
|
+
detectLanguage: z.boolean().optional(),
|
|
2087
|
+
punctuate: z.boolean().optional(),
|
|
2088
|
+
smartFormat: z.boolean().optional()
|
|
2089
|
+
}).strict().optional();
|
|
2090
|
+
const ProviderOptionValueSchema = z.union([
|
|
2091
|
+
z.string(),
|
|
2092
|
+
z.number(),
|
|
2093
|
+
z.boolean()
|
|
2094
|
+
]);
|
|
2095
|
+
const ProviderOptionsSchema = z.record(z.string(), z.record(z.string(), ProviderOptionValueSchema)).optional();
|
|
2096
|
+
const MediaUnderstandingModelSchema = z.object({
|
|
2097
|
+
provider: z.string().optional(),
|
|
2098
|
+
model: z.string().optional(),
|
|
2099
|
+
capabilities: MediaUnderstandingCapabilitiesSchema,
|
|
2100
|
+
type: z.union([z.literal("provider"), z.literal("cli")]).optional(),
|
|
2101
|
+
command: z.string().optional(),
|
|
2102
|
+
args: z.array(z.string()).optional(),
|
|
2103
|
+
prompt: z.string().optional(),
|
|
2104
|
+
maxChars: z.number().int().positive().optional(),
|
|
2105
|
+
maxBytes: z.number().int().positive().optional(),
|
|
2106
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2107
|
+
language: z.string().optional(),
|
|
2108
|
+
providerOptions: ProviderOptionsSchema,
|
|
2109
|
+
deepgram: DeepgramAudioSchema,
|
|
2110
|
+
baseUrl: z.string().optional(),
|
|
2111
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
2112
|
+
profile: z.string().optional(),
|
|
2113
|
+
preferredProfile: z.string().optional()
|
|
2114
|
+
}).strict().optional();
|
|
2115
|
+
const ToolsMediaUnderstandingSchema = z.object({
|
|
2116
|
+
enabled: z.boolean().optional(),
|
|
2117
|
+
scope: MediaUnderstandingScopeSchema,
|
|
2118
|
+
maxBytes: z.number().int().positive().optional(),
|
|
2119
|
+
maxChars: z.number().int().positive().optional(),
|
|
2120
|
+
prompt: z.string().optional(),
|
|
2121
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2122
|
+
language: z.string().optional(),
|
|
2123
|
+
providerOptions: ProviderOptionsSchema,
|
|
2124
|
+
deepgram: DeepgramAudioSchema,
|
|
2125
|
+
baseUrl: z.string().optional(),
|
|
2126
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
2127
|
+
attachments: MediaUnderstandingAttachmentsSchema,
|
|
2128
|
+
models: z.array(MediaUnderstandingModelSchema).optional()
|
|
2129
|
+
}).strict().optional();
|
|
2130
|
+
const ToolsMediaSchema = z.object({
|
|
2131
|
+
models: z.array(MediaUnderstandingModelSchema).optional(),
|
|
2132
|
+
concurrency: z.number().int().positive().optional(),
|
|
2133
|
+
image: ToolsMediaUnderstandingSchema.optional(),
|
|
2134
|
+
audio: ToolsMediaUnderstandingSchema.optional(),
|
|
2135
|
+
video: ToolsMediaUnderstandingSchema.optional()
|
|
2136
|
+
}).strict().optional();
|
|
2137
|
+
const LinkModelSchema = z.object({
|
|
2138
|
+
type: z.literal("cli").optional(),
|
|
2139
|
+
command: z.string().min(1),
|
|
2140
|
+
args: z.array(z.string()).optional(),
|
|
2141
|
+
timeoutSeconds: z.number().int().positive().optional()
|
|
2142
|
+
}).strict();
|
|
2143
|
+
const ToolsLinksSchema = z.object({
|
|
2144
|
+
enabled: z.boolean().optional(),
|
|
2145
|
+
scope: MediaUnderstandingScopeSchema,
|
|
2146
|
+
maxLinks: z.number().int().positive().optional(),
|
|
2147
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2148
|
+
models: z.array(LinkModelSchema).optional()
|
|
2149
|
+
}).strict().optional();
|
|
2150
|
+
const NativeCommandsSettingSchema = z.union([z.boolean(), z.literal("auto")]);
|
|
2151
|
+
const ProviderCommandsSchema = z.object({
|
|
2152
|
+
native: NativeCommandsSettingSchema.optional(),
|
|
2153
|
+
nativeSkills: NativeCommandsSettingSchema.optional()
|
|
2154
|
+
}).strict().optional();
|
|
2155
|
+
|
|
2156
|
+
//#endregion
|
|
2157
|
+
//#region src/config/zod-schema.agent-runtime.ts
|
|
2158
|
+
const HeartbeatSchema = z.object({
|
|
2159
|
+
every: z.string().optional(),
|
|
2160
|
+
activeHours: z.object({
|
|
2161
|
+
start: z.string().optional(),
|
|
2162
|
+
end: z.string().optional(),
|
|
2163
|
+
timezone: z.string().optional()
|
|
2164
|
+
}).strict().optional(),
|
|
2165
|
+
model: z.string().optional(),
|
|
2166
|
+
session: z.string().optional(),
|
|
2167
|
+
includeReasoning: z.boolean().optional(),
|
|
2168
|
+
target: z.string().optional(),
|
|
2169
|
+
to: z.string().optional(),
|
|
2170
|
+
prompt: z.string().optional(),
|
|
2171
|
+
ackMaxChars: z.number().int().nonnegative().optional()
|
|
2172
|
+
}).strict().superRefine((val, ctx) => {
|
|
2173
|
+
if (!val.every) return;
|
|
2174
|
+
try {
|
|
2175
|
+
parseDurationMs(val.every, { defaultUnit: "m" });
|
|
2176
|
+
} catch {
|
|
2177
|
+
ctx.addIssue({
|
|
2178
|
+
code: z.ZodIssueCode.custom,
|
|
2179
|
+
path: ["every"],
|
|
2180
|
+
message: "invalid duration (use ms, s, m, h)"
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
const active = val.activeHours;
|
|
2184
|
+
if (!active) return;
|
|
2185
|
+
const timePattern = /^([01]\d|2[0-3]|24):([0-5]\d)$/;
|
|
2186
|
+
const validateTime = (raw, opts, path) => {
|
|
2187
|
+
if (!raw) return;
|
|
2188
|
+
if (!timePattern.test(raw)) {
|
|
2189
|
+
ctx.addIssue({
|
|
2190
|
+
code: z.ZodIssueCode.custom,
|
|
2191
|
+
path: ["activeHours", path],
|
|
2192
|
+
message: "invalid time (use \"HH:MM\" 24h format)"
|
|
2193
|
+
});
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2196
|
+
const [hourStr, minuteStr] = raw.split(":");
|
|
2197
|
+
const hour = Number(hourStr);
|
|
2198
|
+
if (hour === 24 && Number(minuteStr) !== 0) {
|
|
2199
|
+
ctx.addIssue({
|
|
2200
|
+
code: z.ZodIssueCode.custom,
|
|
2201
|
+
path: ["activeHours", path],
|
|
2202
|
+
message: "invalid time (24:00 is the only allowed 24:xx value)"
|
|
2203
|
+
});
|
|
2204
|
+
return;
|
|
2205
|
+
}
|
|
2206
|
+
if (hour === 24 && !opts.allow24) ctx.addIssue({
|
|
2207
|
+
code: z.ZodIssueCode.custom,
|
|
2208
|
+
path: ["activeHours", path],
|
|
2209
|
+
message: "invalid time (start cannot be 24:00)"
|
|
2210
|
+
});
|
|
2211
|
+
};
|
|
2212
|
+
validateTime(active.start, { allow24: false }, "start");
|
|
2213
|
+
validateTime(active.end, { allow24: true }, "end");
|
|
2214
|
+
}).optional();
|
|
2215
|
+
const SandboxDockerSchema = z.object({
|
|
2216
|
+
image: z.string().optional(),
|
|
2217
|
+
containerPrefix: z.string().optional(),
|
|
2218
|
+
workdir: z.string().optional(),
|
|
2219
|
+
readOnlyRoot: z.boolean().optional(),
|
|
2220
|
+
tmpfs: z.array(z.string()).optional(),
|
|
2221
|
+
network: z.string().optional(),
|
|
2222
|
+
user: z.string().optional(),
|
|
2223
|
+
capDrop: z.array(z.string()).optional(),
|
|
2224
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
2225
|
+
setupCommand: z.string().optional(),
|
|
2226
|
+
pidsLimit: z.number().int().positive().optional(),
|
|
2227
|
+
memory: z.union([z.string(), z.number()]).optional(),
|
|
2228
|
+
memorySwap: z.union([z.string(), z.number()]).optional(),
|
|
2229
|
+
cpus: z.number().positive().optional(),
|
|
2230
|
+
ulimits: z.record(z.string(), z.union([
|
|
2231
|
+
z.string(),
|
|
2232
|
+
z.number(),
|
|
2233
|
+
z.object({
|
|
2234
|
+
soft: z.number().int().nonnegative().optional(),
|
|
2235
|
+
hard: z.number().int().nonnegative().optional()
|
|
2236
|
+
}).strict()
|
|
2237
|
+
])).optional(),
|
|
2238
|
+
seccompProfile: z.string().optional(),
|
|
2239
|
+
apparmorProfile: z.string().optional(),
|
|
2240
|
+
dns: z.array(z.string()).optional(),
|
|
2241
|
+
extraHosts: z.array(z.string()).optional(),
|
|
2242
|
+
binds: z.array(z.string()).optional()
|
|
2243
|
+
}).strict().optional();
|
|
2244
|
+
const SandboxBrowserSchema = z.object({
|
|
2245
|
+
enabled: z.boolean().optional(),
|
|
2246
|
+
image: z.string().optional(),
|
|
2247
|
+
containerPrefix: z.string().optional(),
|
|
2248
|
+
cdpPort: z.number().int().positive().optional(),
|
|
2249
|
+
vncPort: z.number().int().positive().optional(),
|
|
2250
|
+
noVncPort: z.number().int().positive().optional(),
|
|
2251
|
+
headless: z.boolean().optional(),
|
|
2252
|
+
enableNoVnc: z.boolean().optional(),
|
|
2253
|
+
allowHostControl: z.boolean().optional(),
|
|
2254
|
+
autoStart: z.boolean().optional(),
|
|
2255
|
+
autoStartTimeoutMs: z.number().int().positive().optional()
|
|
2256
|
+
}).strict().optional();
|
|
2257
|
+
const SandboxPruneSchema = z.object({
|
|
2258
|
+
idleHours: z.number().int().nonnegative().optional(),
|
|
2259
|
+
maxAgeDays: z.number().int().nonnegative().optional()
|
|
2260
|
+
}).strict().optional();
|
|
2261
|
+
const ToolPolicyBaseSchema = z.object({
|
|
2262
|
+
allow: z.array(z.string()).optional(),
|
|
2263
|
+
alsoAllow: z.array(z.string()).optional(),
|
|
2264
|
+
deny: z.array(z.string()).optional()
|
|
2265
|
+
}).strict();
|
|
2266
|
+
const ToolPolicySchema = ToolPolicyBaseSchema.superRefine((value, ctx) => {
|
|
2267
|
+
if (value.allow && value.allow.length > 0 && value.alsoAllow && value.alsoAllow.length > 0) ctx.addIssue({
|
|
2268
|
+
code: z.ZodIssueCode.custom,
|
|
2269
|
+
message: "tools policy cannot set both allow and alsoAllow in the same scope (merge alsoAllow into allow, or remove allow and use profile + alsoAllow)"
|
|
2270
|
+
});
|
|
2271
|
+
}).optional();
|
|
2272
|
+
const ToolsWebSearchSchema = z.object({
|
|
2273
|
+
enabled: z.boolean().optional(),
|
|
2274
|
+
provider: z.union([z.literal("brave"), z.literal("perplexity")]).optional(),
|
|
2275
|
+
apiKey: z.string().optional(),
|
|
2276
|
+
maxResults: z.number().int().positive().optional(),
|
|
2277
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2278
|
+
cacheTtlMinutes: z.number().nonnegative().optional(),
|
|
2279
|
+
perplexity: z.object({
|
|
2280
|
+
apiKey: z.string().optional(),
|
|
2281
|
+
baseUrl: z.string().optional(),
|
|
2282
|
+
model: z.string().optional()
|
|
2283
|
+
}).strict().optional()
|
|
2284
|
+
}).strict().optional();
|
|
2285
|
+
const ToolsWebFetchSchema = z.object({
|
|
2286
|
+
enabled: z.boolean().optional(),
|
|
2287
|
+
maxChars: z.number().int().positive().optional(),
|
|
2288
|
+
maxCharsCap: z.number().int().positive().optional(),
|
|
2289
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2290
|
+
cacheTtlMinutes: z.number().nonnegative().optional(),
|
|
2291
|
+
maxRedirects: z.number().int().nonnegative().optional(),
|
|
2292
|
+
userAgent: z.string().optional()
|
|
2293
|
+
}).strict().optional();
|
|
2294
|
+
const ToolsWebSchema = z.object({
|
|
2295
|
+
search: ToolsWebSearchSchema,
|
|
2296
|
+
fetch: ToolsWebFetchSchema
|
|
2297
|
+
}).strict().optional();
|
|
2298
|
+
const ToolProfileSchema = z.union([
|
|
2299
|
+
z.literal("minimal"),
|
|
2300
|
+
z.literal("coding"),
|
|
2301
|
+
z.literal("messaging"),
|
|
2302
|
+
z.literal("full")
|
|
2303
|
+
]).optional();
|
|
2304
|
+
const ToolPolicyWithProfileSchema = z.object({
|
|
2305
|
+
allow: z.array(z.string()).optional(),
|
|
2306
|
+
alsoAllow: z.array(z.string()).optional(),
|
|
2307
|
+
deny: z.array(z.string()).optional(),
|
|
2308
|
+
profile: ToolProfileSchema
|
|
2309
|
+
}).strict().superRefine((value, ctx) => {
|
|
2310
|
+
if (value.allow && value.allow.length > 0 && value.alsoAllow && value.alsoAllow.length > 0) ctx.addIssue({
|
|
2311
|
+
code: z.ZodIssueCode.custom,
|
|
2312
|
+
message: "tools.byProvider policy cannot set both allow and alsoAllow in the same scope (merge alsoAllow into allow, or remove allow and use profile + alsoAllow)"
|
|
2313
|
+
});
|
|
2314
|
+
});
|
|
2315
|
+
const ElevatedAllowFromSchema = z.record(z.string(), z.array(z.union([z.string(), z.number()]))).optional();
|
|
2316
|
+
const AgentSandboxSchema = z.object({
|
|
2317
|
+
mode: z.union([
|
|
2318
|
+
z.literal("off"),
|
|
2319
|
+
z.literal("non-main"),
|
|
2320
|
+
z.literal("all")
|
|
2321
|
+
]).optional(),
|
|
2322
|
+
workspaceAccess: z.union([
|
|
2323
|
+
z.literal("none"),
|
|
2324
|
+
z.literal("ro"),
|
|
2325
|
+
z.literal("rw")
|
|
2326
|
+
]).optional(),
|
|
2327
|
+
sessionToolsVisibility: z.union([z.literal("spawned"), z.literal("all")]).optional(),
|
|
2328
|
+
scope: z.union([
|
|
2329
|
+
z.literal("session"),
|
|
2330
|
+
z.literal("agent"),
|
|
2331
|
+
z.literal("shared")
|
|
2332
|
+
]).optional(),
|
|
2333
|
+
perSession: z.boolean().optional(),
|
|
2334
|
+
workspaceRoot: z.string().optional(),
|
|
2335
|
+
docker: SandboxDockerSchema,
|
|
2336
|
+
browser: SandboxBrowserSchema,
|
|
2337
|
+
prune: SandboxPruneSchema
|
|
2338
|
+
}).strict().optional();
|
|
2339
|
+
const AgentToolsSchema = z.object({
|
|
2340
|
+
profile: ToolProfileSchema,
|
|
2341
|
+
allow: z.array(z.string()).optional(),
|
|
2342
|
+
alsoAllow: z.array(z.string()).optional(),
|
|
2343
|
+
deny: z.array(z.string()).optional(),
|
|
2344
|
+
byProvider: z.record(z.string(), ToolPolicyWithProfileSchema).optional(),
|
|
2345
|
+
elevated: z.object({
|
|
2346
|
+
enabled: z.boolean().optional(),
|
|
2347
|
+
allowFrom: ElevatedAllowFromSchema
|
|
2348
|
+
}).strict().optional(),
|
|
2349
|
+
exec: z.object({
|
|
2350
|
+
host: z.enum([
|
|
2351
|
+
"sandbox",
|
|
2352
|
+
"gateway",
|
|
2353
|
+
"node"
|
|
2354
|
+
]).optional(),
|
|
2355
|
+
security: z.enum([
|
|
2356
|
+
"deny",
|
|
2357
|
+
"allowlist",
|
|
2358
|
+
"full"
|
|
2359
|
+
]).optional(),
|
|
2360
|
+
ask: z.enum([
|
|
2361
|
+
"off",
|
|
2362
|
+
"on-miss",
|
|
2363
|
+
"always"
|
|
2364
|
+
]).optional(),
|
|
2365
|
+
node: z.string().optional(),
|
|
2366
|
+
pathPrepend: z.array(z.string()).optional(),
|
|
2367
|
+
safeBins: z.array(z.string()).optional(),
|
|
2368
|
+
backgroundMs: z.number().int().positive().optional(),
|
|
2369
|
+
timeoutSec: z.number().int().positive().optional(),
|
|
2370
|
+
approvalRunningNoticeMs: z.number().int().nonnegative().optional(),
|
|
2371
|
+
cleanupMs: z.number().int().positive().optional(),
|
|
2372
|
+
notifyOnExit: z.boolean().optional(),
|
|
2373
|
+
applyPatch: z.object({
|
|
2374
|
+
enabled: z.boolean().optional(),
|
|
2375
|
+
allowModels: z.array(z.string()).optional()
|
|
2376
|
+
}).strict().optional()
|
|
2377
|
+
}).strict().optional(),
|
|
2378
|
+
sandbox: z.object({ tools: ToolPolicySchema }).strict().optional()
|
|
2379
|
+
}).strict().superRefine((value, ctx) => {
|
|
2380
|
+
if (value.allow && value.allow.length > 0 && value.alsoAllow && value.alsoAllow.length > 0) ctx.addIssue({
|
|
2381
|
+
code: z.ZodIssueCode.custom,
|
|
2382
|
+
message: "agent tools cannot set both allow and alsoAllow in the same scope (merge alsoAllow into allow, or remove allow and use profile + alsoAllow)"
|
|
2383
|
+
});
|
|
2384
|
+
}).optional();
|
|
2385
|
+
const MemorySearchSchema = z.object({
|
|
2386
|
+
enabled: z.boolean().optional(),
|
|
2387
|
+
sources: z.array(z.union([z.literal("memory"), z.literal("sessions")])).optional(),
|
|
2388
|
+
extraPaths: z.array(z.string()).optional(),
|
|
2389
|
+
experimental: z.object({ sessionMemory: z.boolean().optional() }).strict().optional(),
|
|
2390
|
+
provider: z.union([
|
|
2391
|
+
z.literal("openai"),
|
|
2392
|
+
z.literal("local"),
|
|
2393
|
+
z.literal("gemini")
|
|
2394
|
+
]).optional(),
|
|
2395
|
+
remote: z.object({
|
|
2396
|
+
baseUrl: z.string().optional(),
|
|
2397
|
+
apiKey: z.string().optional(),
|
|
2398
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
2399
|
+
batch: z.object({
|
|
2400
|
+
enabled: z.boolean().optional(),
|
|
2401
|
+
wait: z.boolean().optional(),
|
|
2402
|
+
concurrency: z.number().int().positive().optional(),
|
|
2403
|
+
pollIntervalMs: z.number().int().nonnegative().optional(),
|
|
2404
|
+
timeoutMinutes: z.number().int().positive().optional()
|
|
2405
|
+
}).strict().optional()
|
|
2406
|
+
}).strict().optional(),
|
|
2407
|
+
fallback: z.union([
|
|
2408
|
+
z.literal("openai"),
|
|
2409
|
+
z.literal("gemini"),
|
|
2410
|
+
z.literal("local"),
|
|
2411
|
+
z.literal("none")
|
|
2412
|
+
]).optional(),
|
|
2413
|
+
model: z.string().optional(),
|
|
2414
|
+
local: z.object({
|
|
2415
|
+
modelPath: z.string().optional(),
|
|
2416
|
+
modelCacheDir: z.string().optional()
|
|
2417
|
+
}).strict().optional(),
|
|
2418
|
+
store: z.object({
|
|
2419
|
+
driver: z.literal("sqlite").optional(),
|
|
2420
|
+
path: z.string().optional(),
|
|
2421
|
+
vector: z.object({
|
|
2422
|
+
enabled: z.boolean().optional(),
|
|
2423
|
+
extensionPath: z.string().optional()
|
|
2424
|
+
}).strict().optional()
|
|
2425
|
+
}).strict().optional(),
|
|
2426
|
+
chunking: z.object({
|
|
2427
|
+
tokens: z.number().int().positive().optional(),
|
|
2428
|
+
overlap: z.number().int().nonnegative().optional()
|
|
2429
|
+
}).strict().optional(),
|
|
2430
|
+
sync: z.object({
|
|
2431
|
+
onSessionStart: z.boolean().optional(),
|
|
2432
|
+
onSearch: z.boolean().optional(),
|
|
2433
|
+
watch: z.boolean().optional(),
|
|
2434
|
+
watchDebounceMs: z.number().int().nonnegative().optional(),
|
|
2435
|
+
intervalMinutes: z.number().int().nonnegative().optional(),
|
|
2436
|
+
sessions: z.object({
|
|
2437
|
+
deltaBytes: z.number().int().nonnegative().optional(),
|
|
2438
|
+
deltaMessages: z.number().int().nonnegative().optional()
|
|
2439
|
+
}).strict().optional()
|
|
2440
|
+
}).strict().optional(),
|
|
2441
|
+
query: z.object({
|
|
2442
|
+
maxResults: z.number().int().positive().optional(),
|
|
2443
|
+
minScore: z.number().min(0).max(1).optional(),
|
|
2444
|
+
hybrid: z.object({
|
|
2445
|
+
enabled: z.boolean().optional(),
|
|
2446
|
+
vectorWeight: z.number().min(0).max(1).optional(),
|
|
2447
|
+
textWeight: z.number().min(0).max(1).optional(),
|
|
2448
|
+
candidateMultiplier: z.number().int().positive().optional()
|
|
2449
|
+
}).strict().optional()
|
|
2450
|
+
}).strict().optional(),
|
|
2451
|
+
cache: z.object({
|
|
2452
|
+
enabled: z.boolean().optional(),
|
|
2453
|
+
maxEntries: z.number().int().positive().optional()
|
|
2454
|
+
}).strict().optional()
|
|
2455
|
+
}).strict().optional();
|
|
2456
|
+
const AgentModelSchema = z.union([z.string(), z.object({
|
|
2457
|
+
primary: z.string().optional(),
|
|
2458
|
+
fallbacks: z.array(z.string()).optional()
|
|
2459
|
+
}).strict()]);
|
|
2460
|
+
const AgentEntrySchema = z.object({
|
|
2461
|
+
id: z.string(),
|
|
2462
|
+
default: z.boolean().optional(),
|
|
2463
|
+
name: z.string().optional(),
|
|
2464
|
+
workspace: z.string().optional(),
|
|
2465
|
+
agentDir: z.string().optional(),
|
|
2466
|
+
model: AgentModelSchema.optional(),
|
|
2467
|
+
skills: z.array(z.string()).optional(),
|
|
2468
|
+
memorySearch: MemorySearchSchema,
|
|
2469
|
+
humanDelay: HumanDelaySchema.optional(),
|
|
2470
|
+
heartbeat: HeartbeatSchema,
|
|
2471
|
+
identity: IdentitySchema,
|
|
2472
|
+
groupChat: GroupChatSchema,
|
|
2473
|
+
subagents: z.object({
|
|
2474
|
+
allowAgents: z.array(z.string()).optional(),
|
|
2475
|
+
model: z.union([z.string(), z.object({
|
|
2476
|
+
primary: z.string().optional(),
|
|
2477
|
+
fallbacks: z.array(z.string()).optional()
|
|
2478
|
+
}).strict()]).optional(),
|
|
2479
|
+
thinking: z.string().optional()
|
|
2480
|
+
}).strict().optional(),
|
|
2481
|
+
sandbox: AgentSandboxSchema,
|
|
2482
|
+
tools: AgentToolsSchema
|
|
2483
|
+
}).strict();
|
|
2484
|
+
const ToolsSchema = z.object({
|
|
2485
|
+
profile: ToolProfileSchema,
|
|
2486
|
+
allow: z.array(z.string()).optional(),
|
|
2487
|
+
alsoAllow: z.array(z.string()).optional(),
|
|
2488
|
+
deny: z.array(z.string()).optional(),
|
|
2489
|
+
byProvider: z.record(z.string(), ToolPolicyWithProfileSchema).optional(),
|
|
2490
|
+
web: ToolsWebSchema,
|
|
2491
|
+
media: ToolsMediaSchema,
|
|
2492
|
+
links: ToolsLinksSchema,
|
|
2493
|
+
message: z.object({
|
|
2494
|
+
allowCrossContextSend: z.boolean().optional(),
|
|
2495
|
+
crossContext: z.object({
|
|
2496
|
+
allowWithinProvider: z.boolean().optional(),
|
|
2497
|
+
allowAcrossProviders: z.boolean().optional(),
|
|
2498
|
+
marker: z.object({
|
|
2499
|
+
enabled: z.boolean().optional(),
|
|
2500
|
+
prefix: z.string().optional(),
|
|
2501
|
+
suffix: z.string().optional()
|
|
2502
|
+
}).strict().optional()
|
|
2503
|
+
}).strict().optional(),
|
|
2504
|
+
broadcast: z.object({ enabled: z.boolean().optional() }).strict().optional()
|
|
2505
|
+
}).strict().optional(),
|
|
2506
|
+
agentToAgent: z.object({
|
|
2507
|
+
enabled: z.boolean().optional(),
|
|
2508
|
+
allow: z.array(z.string()).optional()
|
|
2509
|
+
}).strict().optional(),
|
|
2510
|
+
elevated: z.object({
|
|
2511
|
+
enabled: z.boolean().optional(),
|
|
2512
|
+
allowFrom: ElevatedAllowFromSchema
|
|
2513
|
+
}).strict().optional(),
|
|
2514
|
+
exec: z.object({
|
|
2515
|
+
host: z.enum([
|
|
2516
|
+
"sandbox",
|
|
2517
|
+
"gateway",
|
|
2518
|
+
"node"
|
|
2519
|
+
]).optional(),
|
|
2520
|
+
security: z.enum([
|
|
2521
|
+
"deny",
|
|
2522
|
+
"allowlist",
|
|
2523
|
+
"full"
|
|
2524
|
+
]).optional(),
|
|
2525
|
+
ask: z.enum([
|
|
2526
|
+
"off",
|
|
2527
|
+
"on-miss",
|
|
2528
|
+
"always"
|
|
2529
|
+
]).optional(),
|
|
2530
|
+
node: z.string().optional(),
|
|
2531
|
+
pathPrepend: z.array(z.string()).optional(),
|
|
2532
|
+
safeBins: z.array(z.string()).optional(),
|
|
2533
|
+
backgroundMs: z.number().int().positive().optional(),
|
|
2534
|
+
timeoutSec: z.number().int().positive().optional(),
|
|
2535
|
+
cleanupMs: z.number().int().positive().optional(),
|
|
2536
|
+
notifyOnExit: z.boolean().optional(),
|
|
2537
|
+
applyPatch: z.object({
|
|
2538
|
+
enabled: z.boolean().optional(),
|
|
2539
|
+
allowModels: z.array(z.string()).optional()
|
|
2540
|
+
}).strict().optional()
|
|
2541
|
+
}).strict().optional(),
|
|
2542
|
+
subagents: z.object({ tools: ToolPolicySchema }).strict().optional(),
|
|
2543
|
+
sandbox: z.object({ tools: ToolPolicySchema }).strict().optional()
|
|
2544
|
+
}).strict().superRefine((value, ctx) => {
|
|
2545
|
+
if (value.allow && value.allow.length > 0 && value.alsoAllow && value.alsoAllow.length > 0) ctx.addIssue({
|
|
2546
|
+
code: z.ZodIssueCode.custom,
|
|
2547
|
+
message: "tools cannot set both allow and alsoAllow in the same scope (merge alsoAllow into allow, or remove allow and use profile + alsoAllow)"
|
|
2548
|
+
});
|
|
2549
|
+
}).optional();
|
|
2550
|
+
|
|
2551
|
+
//#endregion
|
|
2552
|
+
//#region src/config/zod-schema.agent-defaults.ts
|
|
2553
|
+
const AgentDefaultsSchema = z.object({
|
|
2554
|
+
model: z.object({
|
|
2555
|
+
primary: z.string().optional(),
|
|
2556
|
+
fallbacks: z.array(z.string()).optional()
|
|
2557
|
+
}).strict().optional(),
|
|
2558
|
+
imageModel: z.object({
|
|
2559
|
+
primary: z.string().optional(),
|
|
2560
|
+
fallbacks: z.array(z.string()).optional()
|
|
2561
|
+
}).strict().optional(),
|
|
2562
|
+
models: z.record(z.string(), z.object({
|
|
2563
|
+
alias: z.string().optional(),
|
|
2564
|
+
params: z.record(z.string(), z.unknown()).optional()
|
|
2565
|
+
}).strict()).optional(),
|
|
2566
|
+
workspace: z.string().optional(),
|
|
2567
|
+
repoRoot: z.string().optional(),
|
|
2568
|
+
skipBootstrap: z.boolean().optional(),
|
|
2569
|
+
bootstrapMaxChars: z.number().int().positive().optional(),
|
|
2570
|
+
userTimezone: z.string().optional(),
|
|
2571
|
+
timeFormat: z.union([
|
|
2572
|
+
z.literal("auto"),
|
|
2573
|
+
z.literal("12"),
|
|
2574
|
+
z.literal("24")
|
|
2575
|
+
]).optional(),
|
|
2576
|
+
envelopeTimezone: z.string().optional(),
|
|
2577
|
+
envelopeTimestamp: z.union([z.literal("on"), z.literal("off")]).optional(),
|
|
2578
|
+
envelopeElapsed: z.union([z.literal("on"), z.literal("off")]).optional(),
|
|
2579
|
+
contextTokens: z.number().int().positive().optional(),
|
|
2580
|
+
cliBackends: z.record(z.string(), CliBackendSchema).optional(),
|
|
2581
|
+
memorySearch: MemorySearchSchema,
|
|
2582
|
+
contextPruning: z.object({
|
|
2583
|
+
mode: z.union([z.literal("off"), z.literal("cache-ttl")]).optional(),
|
|
2584
|
+
ttl: z.string().optional(),
|
|
2585
|
+
keepLastAssistants: z.number().int().nonnegative().optional(),
|
|
2586
|
+
softTrimRatio: z.number().min(0).max(1).optional(),
|
|
2587
|
+
hardClearRatio: z.number().min(0).max(1).optional(),
|
|
2588
|
+
minPrunableToolChars: z.number().int().nonnegative().optional(),
|
|
2589
|
+
tools: z.object({
|
|
2590
|
+
allow: z.array(z.string()).optional(),
|
|
2591
|
+
deny: z.array(z.string()).optional()
|
|
2592
|
+
}).strict().optional(),
|
|
2593
|
+
softTrim: z.object({
|
|
2594
|
+
maxChars: z.number().int().nonnegative().optional(),
|
|
2595
|
+
headChars: z.number().int().nonnegative().optional(),
|
|
2596
|
+
tailChars: z.number().int().nonnegative().optional()
|
|
2597
|
+
}).strict().optional(),
|
|
2598
|
+
hardClear: z.object({
|
|
2599
|
+
enabled: z.boolean().optional(),
|
|
2600
|
+
placeholder: z.string().optional()
|
|
2601
|
+
}).strict().optional()
|
|
2602
|
+
}).strict().optional(),
|
|
2603
|
+
compaction: z.object({
|
|
2604
|
+
mode: z.union([z.literal("default"), z.literal("safeguard")]).optional(),
|
|
2605
|
+
reserveTokensFloor: z.number().int().nonnegative().optional(),
|
|
2606
|
+
maxHistoryShare: z.number().min(.1).max(.9).optional(),
|
|
2607
|
+
memoryFlush: z.object({
|
|
2608
|
+
enabled: z.boolean().optional(),
|
|
2609
|
+
softThresholdTokens: z.number().int().nonnegative().optional(),
|
|
2610
|
+
prompt: z.string().optional(),
|
|
2611
|
+
systemPrompt: z.string().optional()
|
|
2612
|
+
}).strict().optional()
|
|
2613
|
+
}).strict().optional(),
|
|
2614
|
+
thinkingDefault: z.union([
|
|
2615
|
+
z.literal("off"),
|
|
2616
|
+
z.literal("minimal"),
|
|
2617
|
+
z.literal("low"),
|
|
2618
|
+
z.literal("medium"),
|
|
2619
|
+
z.literal("high"),
|
|
2620
|
+
z.literal("xhigh")
|
|
2621
|
+
]).optional(),
|
|
2622
|
+
verboseDefault: z.union([
|
|
2623
|
+
z.literal("off"),
|
|
2624
|
+
z.literal("on"),
|
|
2625
|
+
z.literal("full")
|
|
2626
|
+
]).optional(),
|
|
2627
|
+
elevatedDefault: z.union([
|
|
2628
|
+
z.literal("off"),
|
|
2629
|
+
z.literal("on"),
|
|
2630
|
+
z.literal("ask"),
|
|
2631
|
+
z.literal("full")
|
|
2632
|
+
]).optional(),
|
|
2633
|
+
blockStreamingDefault: z.union([z.literal("off"), z.literal("on")]).optional(),
|
|
2634
|
+
blockStreamingBreak: z.union([z.literal("text_end"), z.literal("message_end")]).optional(),
|
|
2635
|
+
blockStreamingChunk: BlockStreamingChunkSchema.optional(),
|
|
2636
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
2637
|
+
humanDelay: HumanDelaySchema.optional(),
|
|
2638
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2639
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
2640
|
+
typingIntervalSeconds: z.number().int().positive().optional(),
|
|
2641
|
+
typingMode: z.union([
|
|
2642
|
+
z.literal("never"),
|
|
2643
|
+
z.literal("instant"),
|
|
2644
|
+
z.literal("thinking"),
|
|
2645
|
+
z.literal("message")
|
|
2646
|
+
]).optional(),
|
|
2647
|
+
heartbeat: HeartbeatSchema,
|
|
2648
|
+
maxConcurrent: z.number().int().positive().optional(),
|
|
2649
|
+
subagents: z.object({
|
|
2650
|
+
maxConcurrent: z.number().int().positive().optional(),
|
|
2651
|
+
archiveAfterMinutes: z.number().int().positive().optional(),
|
|
2652
|
+
model: z.union([z.string(), z.object({
|
|
2653
|
+
primary: z.string().optional(),
|
|
2654
|
+
fallbacks: z.array(z.string()).optional()
|
|
2655
|
+
}).strict()]).optional(),
|
|
2656
|
+
thinking: z.string().optional()
|
|
2657
|
+
}).strict().optional(),
|
|
2658
|
+
sandbox: z.object({
|
|
2659
|
+
mode: z.union([
|
|
2660
|
+
z.literal("off"),
|
|
2661
|
+
z.literal("non-main"),
|
|
2662
|
+
z.literal("all")
|
|
2663
|
+
]).optional(),
|
|
2664
|
+
workspaceAccess: z.union([
|
|
2665
|
+
z.literal("none"),
|
|
2666
|
+
z.literal("ro"),
|
|
2667
|
+
z.literal("rw")
|
|
2668
|
+
]).optional(),
|
|
2669
|
+
sessionToolsVisibility: z.union([z.literal("spawned"), z.literal("all")]).optional(),
|
|
2670
|
+
scope: z.union([
|
|
2671
|
+
z.literal("session"),
|
|
2672
|
+
z.literal("agent"),
|
|
2673
|
+
z.literal("shared")
|
|
2674
|
+
]).optional(),
|
|
2675
|
+
perSession: z.boolean().optional(),
|
|
2676
|
+
workspaceRoot: z.string().optional(),
|
|
2677
|
+
docker: SandboxDockerSchema,
|
|
2678
|
+
browser: SandboxBrowserSchema,
|
|
2679
|
+
prune: SandboxPruneSchema
|
|
2680
|
+
}).strict().optional()
|
|
2681
|
+
}).strict().optional();
|
|
2682
|
+
|
|
2683
|
+
//#endregion
|
|
2684
|
+
//#region src/config/zod-schema.agents.ts
|
|
2685
|
+
const AgentsSchema = z.object({
|
|
2686
|
+
defaults: z.lazy(() => AgentDefaultsSchema).optional(),
|
|
2687
|
+
list: z.array(AgentEntrySchema).optional()
|
|
2688
|
+
}).strict().optional();
|
|
2689
|
+
const BindingsSchema = z.array(z.object({
|
|
2690
|
+
agentId: z.string(),
|
|
2691
|
+
match: z.object({
|
|
2692
|
+
channel: z.string(),
|
|
2693
|
+
accountId: z.string().optional(),
|
|
2694
|
+
peer: z.object({
|
|
2695
|
+
kind: z.union([
|
|
2696
|
+
z.literal("dm"),
|
|
2697
|
+
z.literal("group"),
|
|
2698
|
+
z.literal("channel")
|
|
2699
|
+
]),
|
|
2700
|
+
id: z.string()
|
|
2701
|
+
}).strict().optional(),
|
|
2702
|
+
guildId: z.string().optional(),
|
|
2703
|
+
teamId: z.string().optional()
|
|
2704
|
+
}).strict()
|
|
2705
|
+
}).strict()).optional();
|
|
2706
|
+
const BroadcastStrategySchema = z.enum(["parallel", "sequential"]);
|
|
2707
|
+
const BroadcastSchema = z.object({ strategy: BroadcastStrategySchema.optional() }).catchall(z.array(z.string())).optional();
|
|
2708
|
+
const AudioSchema = z.object({ transcription: TranscribeAudioSchema }).strict().optional();
|
|
2709
|
+
|
|
2710
|
+
//#endregion
|
|
2711
|
+
//#region src/config/zod-schema.approvals.ts
|
|
2712
|
+
const ExecApprovalForwardTargetSchema = z.object({
|
|
2713
|
+
channel: z.string().min(1),
|
|
2714
|
+
to: z.string().min(1),
|
|
2715
|
+
accountId: z.string().optional(),
|
|
2716
|
+
threadId: z.union([z.string(), z.number()]).optional()
|
|
2717
|
+
}).strict();
|
|
2718
|
+
const ExecApprovalForwardingSchema = z.object({
|
|
2719
|
+
enabled: z.boolean().optional(),
|
|
2720
|
+
mode: z.union([
|
|
2721
|
+
z.literal("session"),
|
|
2722
|
+
z.literal("targets"),
|
|
2723
|
+
z.literal("both")
|
|
2724
|
+
]).optional(),
|
|
2725
|
+
agentFilter: z.array(z.string()).optional(),
|
|
2726
|
+
sessionFilter: z.array(z.string()).optional(),
|
|
2727
|
+
targets: z.array(ExecApprovalForwardTargetSchema).optional()
|
|
2728
|
+
}).strict().optional();
|
|
2729
|
+
const ApprovalsSchema = z.object({ exec: ExecApprovalForwardingSchema }).strict().optional();
|
|
2730
|
+
|
|
2731
|
+
//#endregion
|
|
2732
|
+
//#region src/config/zod-schema.hooks.ts
|
|
2733
|
+
const HookMappingSchema = z.object({
|
|
2734
|
+
id: z.string().optional(),
|
|
2735
|
+
match: z.object({
|
|
2736
|
+
path: z.string().optional(),
|
|
2737
|
+
source: z.string().optional()
|
|
2738
|
+
}).optional(),
|
|
2739
|
+
action: z.union([z.literal("wake"), z.literal("agent")]).optional(),
|
|
2740
|
+
wakeMode: z.union([z.literal("now"), z.literal("next-heartbeat")]).optional(),
|
|
2741
|
+
name: z.string().optional(),
|
|
2742
|
+
sessionKey: z.string().optional(),
|
|
2743
|
+
messageTemplate: z.string().optional(),
|
|
2744
|
+
textTemplate: z.string().optional(),
|
|
2745
|
+
deliver: z.boolean().optional(),
|
|
2746
|
+
allowUnsafeExternalContent: z.boolean().optional(),
|
|
2747
|
+
channel: z.union([
|
|
2748
|
+
z.literal("last"),
|
|
2749
|
+
z.literal("whatsapp"),
|
|
2750
|
+
z.literal("telegram"),
|
|
2751
|
+
z.literal("discord"),
|
|
2752
|
+
z.literal("slack"),
|
|
2753
|
+
z.literal("signal"),
|
|
2754
|
+
z.literal("imessage"),
|
|
2755
|
+
z.literal("msteams")
|
|
2756
|
+
]).optional(),
|
|
2757
|
+
to: z.string().optional(),
|
|
2758
|
+
model: z.string().optional(),
|
|
2759
|
+
thinking: z.string().optional(),
|
|
2760
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2761
|
+
transform: z.object({
|
|
2762
|
+
module: z.string(),
|
|
2763
|
+
export: z.string().optional()
|
|
2764
|
+
}).strict().optional()
|
|
2765
|
+
}).strict().optional();
|
|
2766
|
+
const InternalHookHandlerSchema = z.object({
|
|
2767
|
+
event: z.string(),
|
|
2768
|
+
module: z.string(),
|
|
2769
|
+
export: z.string().optional()
|
|
2770
|
+
}).strict();
|
|
2771
|
+
const HookConfigSchema = z.object({
|
|
2772
|
+
enabled: z.boolean().optional(),
|
|
2773
|
+
env: z.record(z.string(), z.string()).optional()
|
|
2774
|
+
}).strict();
|
|
2775
|
+
const HookInstallRecordSchema = z.object({
|
|
2776
|
+
source: z.union([
|
|
2777
|
+
z.literal("npm"),
|
|
2778
|
+
z.literal("archive"),
|
|
2779
|
+
z.literal("path")
|
|
2780
|
+
]),
|
|
2781
|
+
spec: z.string().optional(),
|
|
2782
|
+
sourcePath: z.string().optional(),
|
|
2783
|
+
installPath: z.string().optional(),
|
|
2784
|
+
version: z.string().optional(),
|
|
2785
|
+
installedAt: z.string().optional(),
|
|
2786
|
+
hooks: z.array(z.string()).optional()
|
|
2787
|
+
}).strict();
|
|
2788
|
+
const InternalHooksSchema = z.object({
|
|
2789
|
+
enabled: z.boolean().optional(),
|
|
2790
|
+
handlers: z.array(InternalHookHandlerSchema).optional(),
|
|
2791
|
+
entries: z.record(z.string(), HookConfigSchema).optional(),
|
|
2792
|
+
load: z.object({ extraDirs: z.array(z.string()).optional() }).strict().optional(),
|
|
2793
|
+
installs: z.record(z.string(), HookInstallRecordSchema).optional()
|
|
2794
|
+
}).strict().optional();
|
|
2795
|
+
const HooksGmailSchema = z.object({
|
|
2796
|
+
account: z.string().optional(),
|
|
2797
|
+
label: z.string().optional(),
|
|
2798
|
+
topic: z.string().optional(),
|
|
2799
|
+
subscription: z.string().optional(),
|
|
2800
|
+
pushToken: z.string().optional(),
|
|
2801
|
+
hookUrl: z.string().optional(),
|
|
2802
|
+
includeBody: z.boolean().optional(),
|
|
2803
|
+
maxBytes: z.number().int().positive().optional(),
|
|
2804
|
+
renewEveryMinutes: z.number().int().positive().optional(),
|
|
2805
|
+
allowUnsafeExternalContent: z.boolean().optional(),
|
|
2806
|
+
serve: z.object({
|
|
2807
|
+
bind: z.string().optional(),
|
|
2808
|
+
port: z.number().int().positive().optional(),
|
|
2809
|
+
path: z.string().optional()
|
|
2810
|
+
}).strict().optional(),
|
|
2811
|
+
tailscale: z.object({
|
|
2812
|
+
mode: z.union([
|
|
2813
|
+
z.literal("off"),
|
|
2814
|
+
z.literal("serve"),
|
|
2815
|
+
z.literal("funnel")
|
|
2816
|
+
]).optional(),
|
|
2817
|
+
path: z.string().optional(),
|
|
2818
|
+
target: z.string().optional()
|
|
2819
|
+
}).strict().optional(),
|
|
2820
|
+
model: z.string().optional(),
|
|
2821
|
+
thinking: z.union([
|
|
2822
|
+
z.literal("off"),
|
|
2823
|
+
z.literal("minimal"),
|
|
2824
|
+
z.literal("low"),
|
|
2825
|
+
z.literal("medium"),
|
|
2826
|
+
z.literal("high")
|
|
2827
|
+
]).optional()
|
|
2828
|
+
}).strict().optional();
|
|
2829
|
+
|
|
2830
|
+
//#endregion
|
|
2831
|
+
//#region src/config/zod-schema.channels.ts
|
|
2832
|
+
const ChannelHeartbeatVisibilitySchema = z.object({
|
|
2833
|
+
showOk: z.boolean().optional(),
|
|
2834
|
+
showAlerts: z.boolean().optional(),
|
|
2835
|
+
useIndicator: z.boolean().optional()
|
|
2836
|
+
}).strict().optional();
|
|
2837
|
+
|
|
2838
|
+
//#endregion
|
|
2839
|
+
//#region src/config/telegram-custom-commands.ts
|
|
2840
|
+
const TELEGRAM_COMMAND_NAME_PATTERN = /^[a-z0-9_]{1,32}$/;
|
|
2841
|
+
function normalizeTelegramCommandName(value) {
|
|
2842
|
+
const trimmed = value.trim();
|
|
2843
|
+
if (!trimmed) return "";
|
|
2844
|
+
return (trimmed.startsWith("/") ? trimmed.slice(1) : trimmed).trim().toLowerCase();
|
|
2845
|
+
}
|
|
2846
|
+
function normalizeTelegramCommandDescription(value) {
|
|
2847
|
+
return value.trim();
|
|
2848
|
+
}
|
|
2849
|
+
function resolveTelegramCustomCommands(params) {
|
|
2850
|
+
const entries = Array.isArray(params.commands) ? params.commands : [];
|
|
2851
|
+
const reserved = params.reservedCommands ?? /* @__PURE__ */ new Set();
|
|
2852
|
+
const checkReserved = params.checkReserved !== false;
|
|
2853
|
+
const checkDuplicates = params.checkDuplicates !== false;
|
|
2854
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2855
|
+
const resolved = [];
|
|
2856
|
+
const issues = [];
|
|
2857
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
2858
|
+
const entry = entries[index];
|
|
2859
|
+
const normalized = normalizeTelegramCommandName(String(entry?.command ?? ""));
|
|
2860
|
+
if (!normalized) {
|
|
2861
|
+
issues.push({
|
|
2862
|
+
index,
|
|
2863
|
+
field: "command",
|
|
2864
|
+
message: "Telegram custom command is missing a command name."
|
|
2865
|
+
});
|
|
2866
|
+
continue;
|
|
2867
|
+
}
|
|
2868
|
+
if (!TELEGRAM_COMMAND_NAME_PATTERN.test(normalized)) {
|
|
2869
|
+
issues.push({
|
|
2870
|
+
index,
|
|
2871
|
+
field: "command",
|
|
2872
|
+
message: `Telegram custom command "/${normalized}" is invalid (use a-z, 0-9, underscore; max 32 chars).`
|
|
2873
|
+
});
|
|
2874
|
+
continue;
|
|
2875
|
+
}
|
|
2876
|
+
if (checkReserved && reserved.has(normalized)) {
|
|
2877
|
+
issues.push({
|
|
2878
|
+
index,
|
|
2879
|
+
field: "command",
|
|
2880
|
+
message: `Telegram custom command "/${normalized}" conflicts with a native command.`
|
|
2881
|
+
});
|
|
2882
|
+
continue;
|
|
2883
|
+
}
|
|
2884
|
+
if (checkDuplicates && seen.has(normalized)) {
|
|
2885
|
+
issues.push({
|
|
2886
|
+
index,
|
|
2887
|
+
field: "command",
|
|
2888
|
+
message: `Telegram custom command "/${normalized}" is duplicated.`
|
|
2889
|
+
});
|
|
2890
|
+
continue;
|
|
2891
|
+
}
|
|
2892
|
+
const description = normalizeTelegramCommandDescription(String(entry?.description ?? ""));
|
|
2893
|
+
if (!description) {
|
|
2894
|
+
issues.push({
|
|
2895
|
+
index,
|
|
2896
|
+
field: "description",
|
|
2897
|
+
message: `Telegram custom command "/${normalized}" is missing a description.`
|
|
2898
|
+
});
|
|
2899
|
+
continue;
|
|
2900
|
+
}
|
|
2901
|
+
if (checkDuplicates) seen.add(normalized);
|
|
2902
|
+
resolved.push({
|
|
2903
|
+
command: normalized,
|
|
2904
|
+
description
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2907
|
+
return {
|
|
2908
|
+
commands: resolved,
|
|
2909
|
+
issues
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2912
|
+
|
|
2913
|
+
//#endregion
|
|
2914
|
+
//#region src/config/zod-schema.providers-core.ts
|
|
2915
|
+
const ToolPolicyBySenderSchema$1 = z.record(z.string(), ToolPolicySchema).optional();
|
|
2916
|
+
const TelegramInlineButtonsScopeSchema = z.enum([
|
|
2917
|
+
"off",
|
|
2918
|
+
"dm",
|
|
2919
|
+
"group",
|
|
2920
|
+
"all",
|
|
2921
|
+
"allowlist"
|
|
2922
|
+
]);
|
|
2923
|
+
const TelegramCapabilitiesSchema = z.union([z.array(z.string()), z.object({ inlineButtons: TelegramInlineButtonsScopeSchema.optional() }).strict()]);
|
|
2924
|
+
const TelegramTopicSchema = z.object({
|
|
2925
|
+
requireMention: z.boolean().optional(),
|
|
2926
|
+
skills: z.array(z.string()).optional(),
|
|
2927
|
+
enabled: z.boolean().optional(),
|
|
2928
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
2929
|
+
systemPrompt: z.string().optional()
|
|
2930
|
+
}).strict();
|
|
2931
|
+
const TelegramGroupSchema = z.object({
|
|
2932
|
+
requireMention: z.boolean().optional(),
|
|
2933
|
+
tools: ToolPolicySchema,
|
|
2934
|
+
toolsBySender: ToolPolicyBySenderSchema$1,
|
|
2935
|
+
skills: z.array(z.string()).optional(),
|
|
2936
|
+
enabled: z.boolean().optional(),
|
|
2937
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
2938
|
+
systemPrompt: z.string().optional(),
|
|
2939
|
+
topics: z.record(z.string(), TelegramTopicSchema.optional()).optional()
|
|
2940
|
+
}).strict();
|
|
2941
|
+
const TelegramCustomCommandSchema = z.object({
|
|
2942
|
+
command: z.string().transform(normalizeTelegramCommandName),
|
|
2943
|
+
description: z.string().transform(normalizeTelegramCommandDescription)
|
|
2944
|
+
}).strict();
|
|
2945
|
+
const validateTelegramCustomCommands = (value, ctx) => {
|
|
2946
|
+
if (!value.customCommands || value.customCommands.length === 0) return;
|
|
2947
|
+
const { issues } = resolveTelegramCustomCommands({
|
|
2948
|
+
commands: value.customCommands,
|
|
2949
|
+
checkReserved: false,
|
|
2950
|
+
checkDuplicates: false
|
|
2951
|
+
});
|
|
2952
|
+
for (const issue of issues) ctx.addIssue({
|
|
2953
|
+
code: z.ZodIssueCode.custom,
|
|
2954
|
+
path: [
|
|
2955
|
+
"customCommands",
|
|
2956
|
+
issue.index,
|
|
2957
|
+
issue.field
|
|
2958
|
+
],
|
|
2959
|
+
message: issue.message
|
|
2960
|
+
});
|
|
2961
|
+
};
|
|
2962
|
+
const TelegramAccountSchemaBase = z.object({
|
|
2963
|
+
name: z.string().optional(),
|
|
2964
|
+
capabilities: TelegramCapabilitiesSchema.optional(),
|
|
2965
|
+
markdown: MarkdownConfigSchema,
|
|
2966
|
+
enabled: z.boolean().optional(),
|
|
2967
|
+
commands: ProviderCommandsSchema,
|
|
2968
|
+
customCommands: z.array(TelegramCustomCommandSchema).optional(),
|
|
2969
|
+
configWrites: z.boolean().optional(),
|
|
2970
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
2971
|
+
botToken: z.string().optional(),
|
|
2972
|
+
tokenFile: z.string().optional(),
|
|
2973
|
+
replyToMode: ReplyToModeSchema.optional(),
|
|
2974
|
+
groups: z.record(z.string(), TelegramGroupSchema.optional()).optional(),
|
|
2975
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
2976
|
+
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
2977
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
2978
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
2979
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
2980
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
2981
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
2982
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
2983
|
+
blockStreaming: z.boolean().optional(),
|
|
2984
|
+
draftChunk: BlockStreamingChunkSchema.optional(),
|
|
2985
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
2986
|
+
streamMode: z.enum([
|
|
2987
|
+
"off",
|
|
2988
|
+
"partial",
|
|
2989
|
+
"block"
|
|
2990
|
+
]).optional().default("partial"),
|
|
2991
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
2992
|
+
timeoutSeconds: z.number().int().positive().optional(),
|
|
2993
|
+
retry: RetryConfigSchema,
|
|
2994
|
+
network: z.object({ autoSelectFamily: z.boolean().optional() }).strict().optional(),
|
|
2995
|
+
proxy: z.string().optional(),
|
|
2996
|
+
webhookUrl: z.string().optional(),
|
|
2997
|
+
webhookSecret: z.string().optional(),
|
|
2998
|
+
webhookPath: z.string().optional(),
|
|
2999
|
+
actions: z.object({
|
|
3000
|
+
reactions: z.boolean().optional(),
|
|
3001
|
+
sendMessage: z.boolean().optional(),
|
|
3002
|
+
deleteMessage: z.boolean().optional(),
|
|
3003
|
+
sticker: z.boolean().optional()
|
|
3004
|
+
}).strict().optional(),
|
|
3005
|
+
reactionNotifications: z.enum([
|
|
3006
|
+
"off",
|
|
3007
|
+
"own",
|
|
3008
|
+
"all"
|
|
3009
|
+
]).optional(),
|
|
3010
|
+
reactionLevel: z.enum([
|
|
3011
|
+
"off",
|
|
3012
|
+
"ack",
|
|
3013
|
+
"minimal",
|
|
3014
|
+
"extensive"
|
|
3015
|
+
]).optional(),
|
|
3016
|
+
heartbeat: ChannelHeartbeatVisibilitySchema,
|
|
3017
|
+
linkPreview: z.boolean().optional()
|
|
3018
|
+
}).strict();
|
|
3019
|
+
const TelegramAccountSchema = TelegramAccountSchemaBase.superRefine((value, ctx) => {
|
|
3020
|
+
requireOpenAllowFrom({
|
|
3021
|
+
policy: value.dmPolicy,
|
|
3022
|
+
allowFrom: value.allowFrom,
|
|
3023
|
+
ctx,
|
|
3024
|
+
path: ["allowFrom"],
|
|
3025
|
+
message: "channels.telegram.dmPolicy=\"open\" requires channels.telegram.allowFrom to include \"*\""
|
|
3026
|
+
});
|
|
3027
|
+
validateTelegramCustomCommands(value, ctx);
|
|
3028
|
+
});
|
|
3029
|
+
const TelegramConfigSchema = TelegramAccountSchemaBase.extend({ accounts: z.record(z.string(), TelegramAccountSchema.optional()).optional() }).superRefine((value, ctx) => {
|
|
3030
|
+
requireOpenAllowFrom({
|
|
3031
|
+
policy: value.dmPolicy,
|
|
3032
|
+
allowFrom: value.allowFrom,
|
|
3033
|
+
ctx,
|
|
3034
|
+
path: ["allowFrom"],
|
|
3035
|
+
message: "channels.telegram.dmPolicy=\"open\" requires channels.telegram.allowFrom to include \"*\""
|
|
3036
|
+
});
|
|
3037
|
+
validateTelegramCustomCommands(value, ctx);
|
|
3038
|
+
const baseWebhookUrl = typeof value.webhookUrl === "string" ? value.webhookUrl.trim() : "";
|
|
3039
|
+
const baseWebhookSecret = typeof value.webhookSecret === "string" ? value.webhookSecret.trim() : "";
|
|
3040
|
+
if (baseWebhookUrl && !baseWebhookSecret) ctx.addIssue({
|
|
3041
|
+
code: z.ZodIssueCode.custom,
|
|
3042
|
+
message: "channels.telegram.webhookUrl requires channels.telegram.webhookSecret",
|
|
3043
|
+
path: ["webhookSecret"]
|
|
3044
|
+
});
|
|
3045
|
+
if (!value.accounts) return;
|
|
3046
|
+
for (const [accountId, account] of Object.entries(value.accounts)) {
|
|
3047
|
+
if (!account) continue;
|
|
3048
|
+
if (account.enabled === false) continue;
|
|
3049
|
+
if (!(typeof account.webhookUrl === "string" ? account.webhookUrl.trim() : "")) continue;
|
|
3050
|
+
if (!(typeof account.webhookSecret === "string" ? account.webhookSecret.trim() : "") && !baseWebhookSecret) ctx.addIssue({
|
|
3051
|
+
code: z.ZodIssueCode.custom,
|
|
3052
|
+
message: "channels.telegram.accounts.*.webhookUrl requires channels.telegram.webhookSecret or channels.telegram.accounts.*.webhookSecret",
|
|
3053
|
+
path: [
|
|
3054
|
+
"accounts",
|
|
3055
|
+
accountId,
|
|
3056
|
+
"webhookSecret"
|
|
3057
|
+
]
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
3061
|
+
const DiscordDmSchema = z.object({
|
|
3062
|
+
enabled: z.boolean().optional(),
|
|
3063
|
+
policy: DmPolicySchema.optional().default("pairing"),
|
|
3064
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3065
|
+
groupEnabled: z.boolean().optional(),
|
|
3066
|
+
groupChannels: z.array(z.union([z.string(), z.number()])).optional()
|
|
3067
|
+
}).strict().superRefine((value, ctx) => {
|
|
3068
|
+
requireOpenAllowFrom({
|
|
3069
|
+
policy: value.policy,
|
|
3070
|
+
allowFrom: value.allowFrom,
|
|
3071
|
+
ctx,
|
|
3072
|
+
path: ["allowFrom"],
|
|
3073
|
+
message: "channels.discord.dm.policy=\"open\" requires channels.discord.dm.allowFrom to include \"*\""
|
|
3074
|
+
});
|
|
3075
|
+
});
|
|
3076
|
+
const DiscordGuildChannelSchema = z.object({
|
|
3077
|
+
allow: z.boolean().optional(),
|
|
3078
|
+
requireMention: z.boolean().optional(),
|
|
3079
|
+
tools: ToolPolicySchema,
|
|
3080
|
+
toolsBySender: ToolPolicyBySenderSchema$1,
|
|
3081
|
+
skills: z.array(z.string()).optional(),
|
|
3082
|
+
enabled: z.boolean().optional(),
|
|
3083
|
+
users: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3084
|
+
systemPrompt: z.string().optional(),
|
|
3085
|
+
autoThread: z.boolean().optional()
|
|
3086
|
+
}).strict();
|
|
3087
|
+
const DiscordGuildSchema = z.object({
|
|
3088
|
+
slug: z.string().optional(),
|
|
3089
|
+
requireMention: z.boolean().optional(),
|
|
3090
|
+
tools: ToolPolicySchema,
|
|
3091
|
+
toolsBySender: ToolPolicyBySenderSchema$1,
|
|
3092
|
+
reactionNotifications: z.enum([
|
|
3093
|
+
"off",
|
|
3094
|
+
"own",
|
|
3095
|
+
"all",
|
|
3096
|
+
"allowlist"
|
|
3097
|
+
]).optional(),
|
|
3098
|
+
users: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3099
|
+
channels: z.record(z.string(), DiscordGuildChannelSchema.optional()).optional()
|
|
3100
|
+
}).strict();
|
|
3101
|
+
const DiscordAccountSchema = z.object({
|
|
3102
|
+
name: z.string().optional(),
|
|
3103
|
+
capabilities: z.array(z.string()).optional(),
|
|
3104
|
+
markdown: MarkdownConfigSchema,
|
|
3105
|
+
enabled: z.boolean().optional(),
|
|
3106
|
+
commands: ProviderCommandsSchema,
|
|
3107
|
+
configWrites: z.boolean().optional(),
|
|
3108
|
+
token: z.string().optional(),
|
|
3109
|
+
allowBots: z.boolean().optional(),
|
|
3110
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3111
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3112
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3113
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3114
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3115
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3116
|
+
blockStreaming: z.boolean().optional(),
|
|
3117
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3118
|
+
maxLinesPerMessage: z.number().int().positive().optional(),
|
|
3119
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
3120
|
+
retry: RetryConfigSchema,
|
|
3121
|
+
actions: z.object({
|
|
3122
|
+
reactions: z.boolean().optional(),
|
|
3123
|
+
stickers: z.boolean().optional(),
|
|
3124
|
+
emojiUploads: z.boolean().optional(),
|
|
3125
|
+
stickerUploads: z.boolean().optional(),
|
|
3126
|
+
polls: z.boolean().optional(),
|
|
3127
|
+
permissions: z.boolean().optional(),
|
|
3128
|
+
messages: z.boolean().optional(),
|
|
3129
|
+
threads: z.boolean().optional(),
|
|
3130
|
+
pins: z.boolean().optional(),
|
|
3131
|
+
search: z.boolean().optional(),
|
|
3132
|
+
memberInfo: z.boolean().optional(),
|
|
3133
|
+
roleInfo: z.boolean().optional(),
|
|
3134
|
+
roles: z.boolean().optional(),
|
|
3135
|
+
channelInfo: z.boolean().optional(),
|
|
3136
|
+
voiceStatus: z.boolean().optional(),
|
|
3137
|
+
events: z.boolean().optional(),
|
|
3138
|
+
moderation: z.boolean().optional(),
|
|
3139
|
+
channels: z.boolean().optional(),
|
|
3140
|
+
presence: z.boolean().optional()
|
|
3141
|
+
}).strict().optional(),
|
|
3142
|
+
replyToMode: ReplyToModeSchema.optional(),
|
|
3143
|
+
dm: DiscordDmSchema.optional(),
|
|
3144
|
+
guilds: z.record(z.string(), DiscordGuildSchema.optional()).optional(),
|
|
3145
|
+
heartbeat: ChannelHeartbeatVisibilitySchema,
|
|
3146
|
+
execApprovals: z.object({
|
|
3147
|
+
enabled: z.boolean().optional(),
|
|
3148
|
+
approvers: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3149
|
+
agentFilter: z.array(z.string()).optional(),
|
|
3150
|
+
sessionFilter: z.array(z.string()).optional()
|
|
3151
|
+
}).strict().optional(),
|
|
3152
|
+
intents: z.object({
|
|
3153
|
+
presence: z.boolean().optional(),
|
|
3154
|
+
guildMembers: z.boolean().optional()
|
|
3155
|
+
}).strict().optional(),
|
|
3156
|
+
pluralkit: z.object({
|
|
3157
|
+
enabled: z.boolean().optional(),
|
|
3158
|
+
token: z.string().optional()
|
|
3159
|
+
}).strict().optional()
|
|
3160
|
+
}).strict();
|
|
3161
|
+
const DiscordConfigSchema = DiscordAccountSchema.extend({ accounts: z.record(z.string(), DiscordAccountSchema.optional()).optional() });
|
|
3162
|
+
const GoogleChatDmSchema = z.object({
|
|
3163
|
+
enabled: z.boolean().optional(),
|
|
3164
|
+
policy: DmPolicySchema.optional().default("pairing"),
|
|
3165
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional()
|
|
3166
|
+
}).strict().superRefine((value, ctx) => {
|
|
3167
|
+
requireOpenAllowFrom({
|
|
3168
|
+
policy: value.policy,
|
|
3169
|
+
allowFrom: value.allowFrom,
|
|
3170
|
+
ctx,
|
|
3171
|
+
path: ["allowFrom"],
|
|
3172
|
+
message: "channels.googlechat.dm.policy=\"open\" requires channels.googlechat.dm.allowFrom to include \"*\""
|
|
3173
|
+
});
|
|
3174
|
+
});
|
|
3175
|
+
const GoogleChatGroupSchema = z.object({
|
|
3176
|
+
enabled: z.boolean().optional(),
|
|
3177
|
+
allow: z.boolean().optional(),
|
|
3178
|
+
requireMention: z.boolean().optional(),
|
|
3179
|
+
users: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3180
|
+
systemPrompt: z.string().optional()
|
|
3181
|
+
}).strict();
|
|
3182
|
+
const GoogleChatAccountSchema = z.object({
|
|
3183
|
+
name: z.string().optional(),
|
|
3184
|
+
capabilities: z.array(z.string()).optional(),
|
|
3185
|
+
enabled: z.boolean().optional(),
|
|
3186
|
+
configWrites: z.boolean().optional(),
|
|
3187
|
+
allowBots: z.boolean().optional(),
|
|
3188
|
+
requireMention: z.boolean().optional(),
|
|
3189
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3190
|
+
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3191
|
+
groups: z.record(z.string(), GoogleChatGroupSchema.optional()).optional(),
|
|
3192
|
+
serviceAccount: z.union([z.string(), z.record(z.string(), z.unknown())]).optional(),
|
|
3193
|
+
serviceAccountFile: z.string().optional(),
|
|
3194
|
+
audienceType: z.enum(["app-url", "project-number"]).optional(),
|
|
3195
|
+
audience: z.string().optional(),
|
|
3196
|
+
webhookPath: z.string().optional(),
|
|
3197
|
+
webhookUrl: z.string().optional(),
|
|
3198
|
+
botUser: z.string().optional(),
|
|
3199
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3200
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3201
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3202
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3203
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3204
|
+
blockStreaming: z.boolean().optional(),
|
|
3205
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3206
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
3207
|
+
replyToMode: ReplyToModeSchema.optional(),
|
|
3208
|
+
actions: z.object({ reactions: z.boolean().optional() }).strict().optional(),
|
|
3209
|
+
dm: GoogleChatDmSchema.optional(),
|
|
3210
|
+
typingIndicator: z.enum([
|
|
3211
|
+
"none",
|
|
3212
|
+
"message",
|
|
3213
|
+
"reaction"
|
|
3214
|
+
]).optional()
|
|
3215
|
+
}).strict();
|
|
3216
|
+
const GoogleChatConfigSchema = GoogleChatAccountSchema.extend({
|
|
3217
|
+
accounts: z.record(z.string(), GoogleChatAccountSchema.optional()).optional(),
|
|
3218
|
+
defaultAccount: z.string().optional()
|
|
3219
|
+
});
|
|
3220
|
+
const SlackDmSchema = z.object({
|
|
3221
|
+
enabled: z.boolean().optional(),
|
|
3222
|
+
policy: DmPolicySchema.optional().default("pairing"),
|
|
3223
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3224
|
+
groupEnabled: z.boolean().optional(),
|
|
3225
|
+
groupChannels: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3226
|
+
replyToMode: ReplyToModeSchema.optional()
|
|
3227
|
+
}).strict().superRefine((value, ctx) => {
|
|
3228
|
+
requireOpenAllowFrom({
|
|
3229
|
+
policy: value.policy,
|
|
3230
|
+
allowFrom: value.allowFrom,
|
|
3231
|
+
ctx,
|
|
3232
|
+
path: ["allowFrom"],
|
|
3233
|
+
message: "channels.slack.dm.policy=\"open\" requires channels.slack.dm.allowFrom to include \"*\""
|
|
3234
|
+
});
|
|
3235
|
+
});
|
|
3236
|
+
const SlackChannelSchema = z.object({
|
|
3237
|
+
enabled: z.boolean().optional(),
|
|
3238
|
+
allow: z.boolean().optional(),
|
|
3239
|
+
requireMention: z.boolean().optional(),
|
|
3240
|
+
tools: ToolPolicySchema,
|
|
3241
|
+
toolsBySender: ToolPolicyBySenderSchema$1,
|
|
3242
|
+
allowBots: z.boolean().optional(),
|
|
3243
|
+
users: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3244
|
+
skills: z.array(z.string()).optional(),
|
|
3245
|
+
systemPrompt: z.string().optional()
|
|
3246
|
+
}).strict();
|
|
3247
|
+
const SlackThreadSchema = z.object({
|
|
3248
|
+
historyScope: z.enum(["thread", "channel"]).optional(),
|
|
3249
|
+
inheritParent: z.boolean().optional()
|
|
3250
|
+
}).strict();
|
|
3251
|
+
const SlackReplyToModeByChatTypeSchema = z.object({
|
|
3252
|
+
direct: ReplyToModeSchema.optional(),
|
|
3253
|
+
group: ReplyToModeSchema.optional(),
|
|
3254
|
+
channel: ReplyToModeSchema.optional()
|
|
3255
|
+
}).strict();
|
|
3256
|
+
const SlackAccountSchema = z.object({
|
|
3257
|
+
name: z.string().optional(),
|
|
3258
|
+
mode: z.enum(["socket", "http"]).optional(),
|
|
3259
|
+
signingSecret: z.string().optional(),
|
|
3260
|
+
webhookPath: z.string().optional(),
|
|
3261
|
+
capabilities: z.array(z.string()).optional(),
|
|
3262
|
+
markdown: MarkdownConfigSchema,
|
|
3263
|
+
enabled: z.boolean().optional(),
|
|
3264
|
+
commands: ProviderCommandsSchema,
|
|
3265
|
+
configWrites: z.boolean().optional(),
|
|
3266
|
+
botToken: z.string().optional(),
|
|
3267
|
+
appToken: z.string().optional(),
|
|
3268
|
+
userToken: z.string().optional(),
|
|
3269
|
+
userTokenReadOnly: z.boolean().optional().default(true),
|
|
3270
|
+
allowBots: z.boolean().optional(),
|
|
3271
|
+
requireMention: z.boolean().optional(),
|
|
3272
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3273
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3274
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3275
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3276
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3277
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3278
|
+
blockStreaming: z.boolean().optional(),
|
|
3279
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3280
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
3281
|
+
reactionNotifications: z.enum([
|
|
3282
|
+
"off",
|
|
3283
|
+
"own",
|
|
3284
|
+
"all",
|
|
3285
|
+
"allowlist"
|
|
3286
|
+
]).optional(),
|
|
3287
|
+
reactionAllowlist: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3288
|
+
replyToMode: ReplyToModeSchema.optional(),
|
|
3289
|
+
replyToModeByChatType: SlackReplyToModeByChatTypeSchema.optional(),
|
|
3290
|
+
thread: SlackThreadSchema.optional(),
|
|
3291
|
+
actions: z.object({
|
|
3292
|
+
reactions: z.boolean().optional(),
|
|
3293
|
+
messages: z.boolean().optional(),
|
|
3294
|
+
pins: z.boolean().optional(),
|
|
3295
|
+
search: z.boolean().optional(),
|
|
3296
|
+
permissions: z.boolean().optional(),
|
|
3297
|
+
memberInfo: z.boolean().optional(),
|
|
3298
|
+
channelInfo: z.boolean().optional(),
|
|
3299
|
+
emojiList: z.boolean().optional()
|
|
3300
|
+
}).strict().optional(),
|
|
3301
|
+
slashCommand: z.object({
|
|
3302
|
+
enabled: z.boolean().optional(),
|
|
3303
|
+
name: z.string().optional(),
|
|
3304
|
+
sessionPrefix: z.string().optional(),
|
|
3305
|
+
ephemeral: z.boolean().optional()
|
|
3306
|
+
}).strict().optional(),
|
|
3307
|
+
dm: SlackDmSchema.optional(),
|
|
3308
|
+
channels: z.record(z.string(), SlackChannelSchema.optional()).optional(),
|
|
3309
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3310
|
+
}).strict();
|
|
3311
|
+
const SlackConfigSchema = SlackAccountSchema.extend({
|
|
3312
|
+
mode: z.enum(["socket", "http"]).optional().default("socket"),
|
|
3313
|
+
signingSecret: z.string().optional(),
|
|
3314
|
+
webhookPath: z.string().optional().default("/slack/events"),
|
|
3315
|
+
accounts: z.record(z.string(), SlackAccountSchema.optional()).optional()
|
|
3316
|
+
}).superRefine((value, ctx) => {
|
|
3317
|
+
const baseMode = value.mode ?? "socket";
|
|
3318
|
+
if (baseMode === "http" && !value.signingSecret) ctx.addIssue({
|
|
3319
|
+
code: z.ZodIssueCode.custom,
|
|
3320
|
+
message: "channels.slack.mode=\"http\" requires channels.slack.signingSecret",
|
|
3321
|
+
path: ["signingSecret"]
|
|
3322
|
+
});
|
|
3323
|
+
if (!value.accounts) return;
|
|
3324
|
+
for (const [accountId, account] of Object.entries(value.accounts)) {
|
|
3325
|
+
if (!account) continue;
|
|
3326
|
+
if (account.enabled === false) continue;
|
|
3327
|
+
if ((account.mode ?? baseMode) !== "http") continue;
|
|
3328
|
+
if (!(account.signingSecret ?? value.signingSecret)) ctx.addIssue({
|
|
3329
|
+
code: z.ZodIssueCode.custom,
|
|
3330
|
+
message: "channels.slack.accounts.*.mode=\"http\" requires channels.slack.signingSecret or channels.slack.accounts.*.signingSecret",
|
|
3331
|
+
path: [
|
|
3332
|
+
"accounts",
|
|
3333
|
+
accountId,
|
|
3334
|
+
"signingSecret"
|
|
3335
|
+
]
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
});
|
|
3339
|
+
const SignalAccountSchemaBase = z.object({
|
|
3340
|
+
name: z.string().optional(),
|
|
3341
|
+
capabilities: z.array(z.string()).optional(),
|
|
3342
|
+
markdown: MarkdownConfigSchema,
|
|
3343
|
+
enabled: z.boolean().optional(),
|
|
3344
|
+
configWrites: z.boolean().optional(),
|
|
3345
|
+
account: z.string().optional(),
|
|
3346
|
+
httpUrl: z.string().optional(),
|
|
3347
|
+
httpHost: z.string().optional(),
|
|
3348
|
+
httpPort: z.number().int().positive().optional(),
|
|
3349
|
+
cliPath: ExecutableTokenSchema.optional(),
|
|
3350
|
+
autoStart: z.boolean().optional(),
|
|
3351
|
+
startupTimeoutMs: z.number().int().min(1e3).max(12e4).optional(),
|
|
3352
|
+
receiveMode: z.union([z.literal("on-start"), z.literal("manual")]).optional(),
|
|
3353
|
+
ignoreAttachments: z.boolean().optional(),
|
|
3354
|
+
ignoreStories: z.boolean().optional(),
|
|
3355
|
+
sendReadReceipts: z.boolean().optional(),
|
|
3356
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
3357
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3358
|
+
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3359
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3360
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3361
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3362
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3363
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3364
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3365
|
+
blockStreaming: z.boolean().optional(),
|
|
3366
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3367
|
+
mediaMaxMb: z.number().int().positive().optional(),
|
|
3368
|
+
reactionNotifications: z.enum([
|
|
3369
|
+
"off",
|
|
3370
|
+
"own",
|
|
3371
|
+
"all",
|
|
3372
|
+
"allowlist"
|
|
3373
|
+
]).optional(),
|
|
3374
|
+
reactionAllowlist: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3375
|
+
actions: z.object({ reactions: z.boolean().optional() }).strict().optional(),
|
|
3376
|
+
reactionLevel: z.enum([
|
|
3377
|
+
"off",
|
|
3378
|
+
"ack",
|
|
3379
|
+
"minimal",
|
|
3380
|
+
"extensive"
|
|
3381
|
+
]).optional(),
|
|
3382
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3383
|
+
}).strict();
|
|
3384
|
+
const SignalAccountSchema = SignalAccountSchemaBase.superRefine((value, ctx) => {
|
|
3385
|
+
requireOpenAllowFrom({
|
|
3386
|
+
policy: value.dmPolicy,
|
|
3387
|
+
allowFrom: value.allowFrom,
|
|
3388
|
+
ctx,
|
|
3389
|
+
path: ["allowFrom"],
|
|
3390
|
+
message: "channels.signal.dmPolicy=\"open\" requires channels.signal.allowFrom to include \"*\""
|
|
3391
|
+
});
|
|
3392
|
+
});
|
|
3393
|
+
const SignalConfigSchema = SignalAccountSchemaBase.extend({ accounts: z.record(z.string(), SignalAccountSchema.optional()).optional() }).superRefine((value, ctx) => {
|
|
3394
|
+
requireOpenAllowFrom({
|
|
3395
|
+
policy: value.dmPolicy,
|
|
3396
|
+
allowFrom: value.allowFrom,
|
|
3397
|
+
ctx,
|
|
3398
|
+
path: ["allowFrom"],
|
|
3399
|
+
message: "channels.signal.dmPolicy=\"open\" requires channels.signal.allowFrom to include \"*\""
|
|
3400
|
+
});
|
|
3401
|
+
});
|
|
3402
|
+
const IMessageAccountSchemaBase = z.object({
|
|
3403
|
+
name: z.string().optional(),
|
|
3404
|
+
capabilities: z.array(z.string()).optional(),
|
|
3405
|
+
markdown: MarkdownConfigSchema,
|
|
3406
|
+
enabled: z.boolean().optional(),
|
|
3407
|
+
configWrites: z.boolean().optional(),
|
|
3408
|
+
cliPath: ExecutableTokenSchema.optional(),
|
|
3409
|
+
dbPath: z.string().optional(),
|
|
3410
|
+
remoteHost: z.string().optional(),
|
|
3411
|
+
service: z.union([
|
|
3412
|
+
z.literal("imessage"),
|
|
3413
|
+
z.literal("sms"),
|
|
3414
|
+
z.literal("auto")
|
|
3415
|
+
]).optional(),
|
|
3416
|
+
region: z.string().optional(),
|
|
3417
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
3418
|
+
allowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3419
|
+
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
|
3420
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3421
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3422
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3423
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3424
|
+
includeAttachments: z.boolean().optional(),
|
|
3425
|
+
mediaMaxMb: z.number().int().positive().optional(),
|
|
3426
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3427
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3428
|
+
blockStreaming: z.boolean().optional(),
|
|
3429
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3430
|
+
groups: z.record(z.string(), z.object({
|
|
3431
|
+
requireMention: z.boolean().optional(),
|
|
3432
|
+
tools: ToolPolicySchema,
|
|
3433
|
+
toolsBySender: ToolPolicyBySenderSchema$1
|
|
3434
|
+
}).strict().optional()).optional(),
|
|
3435
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3436
|
+
}).strict();
|
|
3437
|
+
const IMessageAccountSchema = IMessageAccountSchemaBase.superRefine((value, ctx) => {
|
|
3438
|
+
requireOpenAllowFrom({
|
|
3439
|
+
policy: value.dmPolicy,
|
|
3440
|
+
allowFrom: value.allowFrom,
|
|
3441
|
+
ctx,
|
|
3442
|
+
path: ["allowFrom"],
|
|
3443
|
+
message: "channels.imessage.dmPolicy=\"open\" requires channels.imessage.allowFrom to include \"*\""
|
|
3444
|
+
});
|
|
3445
|
+
});
|
|
3446
|
+
const IMessageConfigSchema = IMessageAccountSchemaBase.extend({ accounts: z.record(z.string(), IMessageAccountSchema.optional()).optional() }).superRefine((value, ctx) => {
|
|
3447
|
+
requireOpenAllowFrom({
|
|
3448
|
+
policy: value.dmPolicy,
|
|
3449
|
+
allowFrom: value.allowFrom,
|
|
3450
|
+
ctx,
|
|
3451
|
+
path: ["allowFrom"],
|
|
3452
|
+
message: "channels.imessage.dmPolicy=\"open\" requires channels.imessage.allowFrom to include \"*\""
|
|
3453
|
+
});
|
|
3454
|
+
});
|
|
3455
|
+
const BlueBubblesAllowFromEntry = z.union([z.string(), z.number()]);
|
|
3456
|
+
const BlueBubblesActionSchema = z.object({
|
|
3457
|
+
reactions: z.boolean().optional(),
|
|
3458
|
+
edit: z.boolean().optional(),
|
|
3459
|
+
unsend: z.boolean().optional(),
|
|
3460
|
+
reply: z.boolean().optional(),
|
|
3461
|
+
sendWithEffect: z.boolean().optional(),
|
|
3462
|
+
renameGroup: z.boolean().optional(),
|
|
3463
|
+
setGroupIcon: z.boolean().optional(),
|
|
3464
|
+
addParticipant: z.boolean().optional(),
|
|
3465
|
+
removeParticipant: z.boolean().optional(),
|
|
3466
|
+
leaveGroup: z.boolean().optional(),
|
|
3467
|
+
sendAttachment: z.boolean().optional()
|
|
3468
|
+
}).strict().optional();
|
|
3469
|
+
const BlueBubblesGroupConfigSchema = z.object({
|
|
3470
|
+
requireMention: z.boolean().optional(),
|
|
3471
|
+
tools: ToolPolicySchema,
|
|
3472
|
+
toolsBySender: ToolPolicyBySenderSchema$1
|
|
3473
|
+
}).strict();
|
|
3474
|
+
const BlueBubblesAccountSchemaBase = z.object({
|
|
3475
|
+
name: z.string().optional(),
|
|
3476
|
+
capabilities: z.array(z.string()).optional(),
|
|
3477
|
+
markdown: MarkdownConfigSchema,
|
|
3478
|
+
configWrites: z.boolean().optional(),
|
|
3479
|
+
enabled: z.boolean().optional(),
|
|
3480
|
+
serverUrl: z.string().optional(),
|
|
3481
|
+
password: z.string().optional(),
|
|
3482
|
+
webhookPath: z.string().optional(),
|
|
3483
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
3484
|
+
allowFrom: z.array(BlueBubblesAllowFromEntry).optional(),
|
|
3485
|
+
groupAllowFrom: z.array(BlueBubblesAllowFromEntry).optional(),
|
|
3486
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3487
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3488
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3489
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3490
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3491
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3492
|
+
mediaMaxMb: z.number().int().positive().optional(),
|
|
3493
|
+
sendReadReceipts: z.boolean().optional(),
|
|
3494
|
+
blockStreaming: z.boolean().optional(),
|
|
3495
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3496
|
+
groups: z.record(z.string(), BlueBubblesGroupConfigSchema.optional()).optional(),
|
|
3497
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3498
|
+
}).strict();
|
|
3499
|
+
const BlueBubblesAccountSchema = BlueBubblesAccountSchemaBase.superRefine((value, ctx) => {
|
|
3500
|
+
requireOpenAllowFrom({
|
|
3501
|
+
policy: value.dmPolicy,
|
|
3502
|
+
allowFrom: value.allowFrom,
|
|
3503
|
+
ctx,
|
|
3504
|
+
path: ["allowFrom"],
|
|
3505
|
+
message: "channels.bluebubbles.accounts.*.dmPolicy=\"open\" requires allowFrom to include \"*\""
|
|
3506
|
+
});
|
|
3507
|
+
});
|
|
3508
|
+
const BlueBubblesConfigSchema = BlueBubblesAccountSchemaBase.extend({
|
|
3509
|
+
accounts: z.record(z.string(), BlueBubblesAccountSchema.optional()).optional(),
|
|
3510
|
+
actions: BlueBubblesActionSchema
|
|
3511
|
+
}).superRefine((value, ctx) => {
|
|
3512
|
+
requireOpenAllowFrom({
|
|
3513
|
+
policy: value.dmPolicy,
|
|
3514
|
+
allowFrom: value.allowFrom,
|
|
3515
|
+
ctx,
|
|
3516
|
+
path: ["allowFrom"],
|
|
3517
|
+
message: "channels.bluebubbles.dmPolicy=\"open\" requires channels.bluebubbles.allowFrom to include \"*\""
|
|
3518
|
+
});
|
|
3519
|
+
});
|
|
3520
|
+
const MSTeamsChannelSchema = z.object({
|
|
3521
|
+
requireMention: z.boolean().optional(),
|
|
3522
|
+
tools: ToolPolicySchema,
|
|
3523
|
+
toolsBySender: ToolPolicyBySenderSchema$1,
|
|
3524
|
+
replyStyle: MSTeamsReplyStyleSchema.optional()
|
|
3525
|
+
}).strict();
|
|
3526
|
+
const MSTeamsTeamSchema = z.object({
|
|
3527
|
+
requireMention: z.boolean().optional(),
|
|
3528
|
+
tools: ToolPolicySchema,
|
|
3529
|
+
toolsBySender: ToolPolicyBySenderSchema$1,
|
|
3530
|
+
replyStyle: MSTeamsReplyStyleSchema.optional(),
|
|
3531
|
+
channels: z.record(z.string(), MSTeamsChannelSchema.optional()).optional()
|
|
3532
|
+
}).strict();
|
|
3533
|
+
const MSTeamsConfigSchema = z.object({
|
|
3534
|
+
enabled: z.boolean().optional(),
|
|
3535
|
+
capabilities: z.array(z.string()).optional(),
|
|
3536
|
+
markdown: MarkdownConfigSchema,
|
|
3537
|
+
configWrites: z.boolean().optional(),
|
|
3538
|
+
appId: z.string().optional(),
|
|
3539
|
+
appPassword: z.string().optional(),
|
|
3540
|
+
tenantId: z.string().optional(),
|
|
3541
|
+
webhook: z.object({
|
|
3542
|
+
port: z.number().int().positive().optional(),
|
|
3543
|
+
path: z.string().optional()
|
|
3544
|
+
}).strict().optional(),
|
|
3545
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
3546
|
+
allowFrom: z.array(z.string()).optional(),
|
|
3547
|
+
groupAllowFrom: z.array(z.string()).optional(),
|
|
3548
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3549
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3550
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3551
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3552
|
+
mediaAllowHosts: z.array(z.string()).optional(),
|
|
3553
|
+
mediaAuthAllowHosts: z.array(z.string()).optional(),
|
|
3554
|
+
requireMention: z.boolean().optional(),
|
|
3555
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3556
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3557
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3558
|
+
replyStyle: MSTeamsReplyStyleSchema.optional(),
|
|
3559
|
+
teams: z.record(z.string(), MSTeamsTeamSchema.optional()).optional(),
|
|
3560
|
+
mediaMaxMb: z.number().positive().optional(),
|
|
3561
|
+
sharePointSiteId: z.string().optional(),
|
|
3562
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3563
|
+
}).strict().superRefine((value, ctx) => {
|
|
3564
|
+
requireOpenAllowFrom({
|
|
3565
|
+
policy: value.dmPolicy,
|
|
3566
|
+
allowFrom: value.allowFrom,
|
|
3567
|
+
ctx,
|
|
3568
|
+
path: ["allowFrom"],
|
|
3569
|
+
message: "channels.msteams.dmPolicy=\"open\" requires channels.msteams.allowFrom to include \"*\""
|
|
3570
|
+
});
|
|
3571
|
+
});
|
|
3572
|
+
|
|
3573
|
+
//#endregion
|
|
3574
|
+
//#region src/config/zod-schema.providers-whatsapp.ts
|
|
3575
|
+
const ToolPolicyBySenderSchema = z.record(z.string(), ToolPolicySchema).optional();
|
|
3576
|
+
const WhatsAppAccountSchema = z.object({
|
|
3577
|
+
name: z.string().optional(),
|
|
3578
|
+
capabilities: z.array(z.string()).optional(),
|
|
3579
|
+
markdown: MarkdownConfigSchema,
|
|
3580
|
+
configWrites: z.boolean().optional(),
|
|
3581
|
+
enabled: z.boolean().optional(),
|
|
3582
|
+
sendReadReceipts: z.boolean().optional(),
|
|
3583
|
+
messagePrefix: z.string().optional(),
|
|
3584
|
+
authDir: z.string().optional(),
|
|
3585
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
3586
|
+
selfChatMode: z.boolean().optional(),
|
|
3587
|
+
allowFrom: z.array(z.string()).optional(),
|
|
3588
|
+
groupAllowFrom: z.array(z.string()).optional(),
|
|
3589
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3590
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3591
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3592
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3593
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3594
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3595
|
+
mediaMaxMb: z.number().int().positive().optional(),
|
|
3596
|
+
blockStreaming: z.boolean().optional(),
|
|
3597
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3598
|
+
groups: z.record(z.string(), z.object({
|
|
3599
|
+
requireMention: z.boolean().optional(),
|
|
3600
|
+
tools: ToolPolicySchema,
|
|
3601
|
+
toolsBySender: ToolPolicyBySenderSchema
|
|
3602
|
+
}).strict().optional()).optional(),
|
|
3603
|
+
ackReaction: z.object({
|
|
3604
|
+
emoji: z.string().optional(),
|
|
3605
|
+
direct: z.boolean().optional().default(true),
|
|
3606
|
+
group: z.enum([
|
|
3607
|
+
"always",
|
|
3608
|
+
"mentions",
|
|
3609
|
+
"never"
|
|
3610
|
+
]).optional().default("mentions")
|
|
3611
|
+
}).strict().optional(),
|
|
3612
|
+
debounceMs: z.number().int().nonnegative().optional().default(0),
|
|
3613
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3614
|
+
}).strict().superRefine((value, ctx) => {
|
|
3615
|
+
if (value.dmPolicy !== "open") return;
|
|
3616
|
+
if ((value.allowFrom ?? []).map((v) => String(v).trim()).filter(Boolean).includes("*")) return;
|
|
3617
|
+
ctx.addIssue({
|
|
3618
|
+
code: z.ZodIssueCode.custom,
|
|
3619
|
+
path: ["allowFrom"],
|
|
3620
|
+
message: "channels.whatsapp.accounts.*.dmPolicy=\"open\" requires allowFrom to include \"*\""
|
|
3621
|
+
});
|
|
3622
|
+
});
|
|
3623
|
+
const WhatsAppConfigSchema = z.object({
|
|
3624
|
+
accounts: z.record(z.string(), WhatsAppAccountSchema.optional()).optional(),
|
|
3625
|
+
capabilities: z.array(z.string()).optional(),
|
|
3626
|
+
markdown: MarkdownConfigSchema,
|
|
3627
|
+
configWrites: z.boolean().optional(),
|
|
3628
|
+
sendReadReceipts: z.boolean().optional(),
|
|
3629
|
+
dmPolicy: DmPolicySchema.optional().default("pairing"),
|
|
3630
|
+
messagePrefix: z.string().optional(),
|
|
3631
|
+
selfChatMode: z.boolean().optional(),
|
|
3632
|
+
allowFrom: z.array(z.string()).optional(),
|
|
3633
|
+
groupAllowFrom: z.array(z.string()).optional(),
|
|
3634
|
+
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
|
3635
|
+
historyLimit: z.number().int().min(0).optional(),
|
|
3636
|
+
dmHistoryLimit: z.number().int().min(0).optional(),
|
|
3637
|
+
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
|
3638
|
+
textChunkLimit: z.number().int().positive().optional(),
|
|
3639
|
+
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
3640
|
+
mediaMaxMb: z.number().int().positive().optional().default(50),
|
|
3641
|
+
blockStreaming: z.boolean().optional(),
|
|
3642
|
+
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
|
3643
|
+
actions: z.object({
|
|
3644
|
+
reactions: z.boolean().optional(),
|
|
3645
|
+
sendMessage: z.boolean().optional(),
|
|
3646
|
+
polls: z.boolean().optional()
|
|
3647
|
+
}).strict().optional(),
|
|
3648
|
+
groups: z.record(z.string(), z.object({
|
|
3649
|
+
requireMention: z.boolean().optional(),
|
|
3650
|
+
tools: ToolPolicySchema,
|
|
3651
|
+
toolsBySender: ToolPolicyBySenderSchema
|
|
3652
|
+
}).strict().optional()).optional(),
|
|
3653
|
+
ackReaction: z.object({
|
|
3654
|
+
emoji: z.string().optional(),
|
|
3655
|
+
direct: z.boolean().optional().default(true),
|
|
3656
|
+
group: z.enum([
|
|
3657
|
+
"always",
|
|
3658
|
+
"mentions",
|
|
3659
|
+
"never"
|
|
3660
|
+
]).optional().default("mentions")
|
|
3661
|
+
}).strict().optional(),
|
|
3662
|
+
debounceMs: z.number().int().nonnegative().optional().default(0),
|
|
3663
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3664
|
+
}).strict().superRefine((value, ctx) => {
|
|
3665
|
+
if (value.dmPolicy !== "open") return;
|
|
3666
|
+
if ((value.allowFrom ?? []).map((v) => String(v).trim()).filter(Boolean).includes("*")) return;
|
|
3667
|
+
ctx.addIssue({
|
|
3668
|
+
code: z.ZodIssueCode.custom,
|
|
3669
|
+
path: ["allowFrom"],
|
|
3670
|
+
message: "channels.whatsapp.dmPolicy=\"open\" requires channels.whatsapp.allowFrom to include \"*\""
|
|
3671
|
+
});
|
|
3672
|
+
});
|
|
3673
|
+
|
|
3674
|
+
//#endregion
|
|
3675
|
+
//#region src/config/zod-schema.providers.ts
|
|
3676
|
+
const ChannelsSchema = z.object({
|
|
3677
|
+
defaults: z.object({
|
|
3678
|
+
groupPolicy: GroupPolicySchema.optional(),
|
|
3679
|
+
heartbeat: ChannelHeartbeatVisibilitySchema
|
|
3680
|
+
}).strict().optional(),
|
|
3681
|
+
whatsapp: WhatsAppConfigSchema.optional(),
|
|
3682
|
+
telegram: TelegramConfigSchema.optional(),
|
|
3683
|
+
discord: DiscordConfigSchema.optional(),
|
|
3684
|
+
googlechat: GoogleChatConfigSchema.optional(),
|
|
3685
|
+
slack: SlackConfigSchema.optional(),
|
|
3686
|
+
signal: SignalConfigSchema.optional(),
|
|
3687
|
+
imessage: IMessageConfigSchema.optional(),
|
|
3688
|
+
bluebubbles: BlueBubblesConfigSchema.optional(),
|
|
3689
|
+
msteams: MSTeamsConfigSchema.optional()
|
|
3690
|
+
}).passthrough().optional();
|
|
3691
|
+
|
|
3692
|
+
//#endregion
|
|
3693
|
+
//#region src/config/zod-schema.session.ts
|
|
3694
|
+
const SessionResetConfigSchema = z.object({
|
|
3695
|
+
mode: z.union([z.literal("daily"), z.literal("idle")]).optional(),
|
|
3696
|
+
atHour: z.number().int().min(0).max(23).optional(),
|
|
3697
|
+
idleMinutes: z.number().int().positive().optional()
|
|
3698
|
+
}).strict();
|
|
3699
|
+
const SessionSendPolicySchema = z.object({
|
|
3700
|
+
default: z.union([z.literal("allow"), z.literal("deny")]).optional(),
|
|
3701
|
+
rules: z.array(z.object({
|
|
3702
|
+
action: z.union([z.literal("allow"), z.literal("deny")]),
|
|
3703
|
+
match: z.object({
|
|
3704
|
+
channel: z.string().optional(),
|
|
3705
|
+
chatType: z.union([
|
|
3706
|
+
z.literal("direct"),
|
|
3707
|
+
z.literal("group"),
|
|
3708
|
+
z.literal("channel")
|
|
3709
|
+
]).optional(),
|
|
3710
|
+
keyPrefix: z.string().optional()
|
|
3711
|
+
}).strict().optional()
|
|
3712
|
+
}).strict()).optional()
|
|
3713
|
+
}).strict();
|
|
3714
|
+
const SessionSchema = z.object({
|
|
3715
|
+
scope: z.union([z.literal("per-sender"), z.literal("global")]).optional(),
|
|
3716
|
+
dmScope: z.union([
|
|
3717
|
+
z.literal("main"),
|
|
3718
|
+
z.literal("per-peer"),
|
|
3719
|
+
z.literal("per-channel-peer"),
|
|
3720
|
+
z.literal("per-account-channel-peer")
|
|
3721
|
+
]).optional(),
|
|
3722
|
+
identityLinks: z.record(z.string(), z.array(z.string())).optional(),
|
|
3723
|
+
resetTriggers: z.array(z.string()).optional(),
|
|
3724
|
+
idleMinutes: z.number().int().positive().optional(),
|
|
3725
|
+
reset: SessionResetConfigSchema.optional(),
|
|
3726
|
+
resetByType: z.object({
|
|
3727
|
+
dm: SessionResetConfigSchema.optional(),
|
|
3728
|
+
group: SessionResetConfigSchema.optional(),
|
|
3729
|
+
thread: SessionResetConfigSchema.optional()
|
|
3730
|
+
}).strict().optional(),
|
|
3731
|
+
resetByChannel: z.record(z.string(), SessionResetConfigSchema).optional(),
|
|
3732
|
+
store: z.string().optional(),
|
|
3733
|
+
typingIntervalSeconds: z.number().int().positive().optional(),
|
|
3734
|
+
typingMode: z.union([
|
|
3735
|
+
z.literal("never"),
|
|
3736
|
+
z.literal("instant"),
|
|
3737
|
+
z.literal("thinking"),
|
|
3738
|
+
z.literal("message")
|
|
3739
|
+
]).optional(),
|
|
3740
|
+
mainKey: z.string().optional(),
|
|
3741
|
+
sendPolicy: SessionSendPolicySchema.optional(),
|
|
3742
|
+
agentToAgent: z.object({ maxPingPongTurns: z.number().int().min(0).max(5).optional() }).strict().optional()
|
|
3743
|
+
}).strict().optional();
|
|
3744
|
+
const MessagesSchema = z.object({
|
|
3745
|
+
messagePrefix: z.string().optional(),
|
|
3746
|
+
responsePrefix: z.string().optional(),
|
|
3747
|
+
groupChat: GroupChatSchema,
|
|
3748
|
+
queue: QueueSchema,
|
|
3749
|
+
inbound: InboundDebounceSchema,
|
|
3750
|
+
ackReaction: z.string().optional(),
|
|
3751
|
+
ackReactionScope: z.enum([
|
|
3752
|
+
"group-mentions",
|
|
3753
|
+
"group-all",
|
|
3754
|
+
"direct",
|
|
3755
|
+
"all"
|
|
3756
|
+
]).optional(),
|
|
3757
|
+
removeAckAfterReply: z.boolean().optional(),
|
|
3758
|
+
tts: TtsConfigSchema
|
|
3759
|
+
}).strict().optional();
|
|
3760
|
+
const CommandsSchema = z.object({
|
|
3761
|
+
native: NativeCommandsSettingSchema.optional().default("auto"),
|
|
3762
|
+
nativeSkills: NativeCommandsSettingSchema.optional().default("auto"),
|
|
3763
|
+
text: z.boolean().optional(),
|
|
3764
|
+
bash: z.boolean().optional(),
|
|
3765
|
+
bashForegroundMs: z.number().int().min(0).max(3e4).optional(),
|
|
3766
|
+
config: z.boolean().optional(),
|
|
3767
|
+
debug: z.boolean().optional(),
|
|
3768
|
+
restart: z.boolean().optional(),
|
|
3769
|
+
useAccessGroups: z.boolean().optional()
|
|
3770
|
+
}).strict().optional().default({
|
|
3771
|
+
native: "auto",
|
|
3772
|
+
nativeSkills: "auto"
|
|
3773
|
+
});
|
|
3774
|
+
|
|
3775
|
+
//#endregion
|
|
3776
|
+
//#region src/config/zod-schema.ts
|
|
3777
|
+
const BrowserSnapshotDefaultsSchema = z.object({ mode: z.literal("efficient").optional() }).strict().optional();
|
|
3778
|
+
const NodeHostSchema = z.object({ browserProxy: z.object({
|
|
3779
|
+
enabled: z.boolean().optional(),
|
|
3780
|
+
allowProfiles: z.array(z.string()).optional()
|
|
3781
|
+
}).strict().optional() }).strict().optional();
|
|
3782
|
+
const MemoryQmdPathSchema = z.object({
|
|
3783
|
+
path: z.string(),
|
|
3784
|
+
name: z.string().optional(),
|
|
3785
|
+
pattern: z.string().optional()
|
|
3786
|
+
}).strict();
|
|
3787
|
+
const MemoryQmdSessionSchema = z.object({
|
|
3788
|
+
enabled: z.boolean().optional(),
|
|
3789
|
+
exportDir: z.string().optional(),
|
|
3790
|
+
retentionDays: z.number().int().nonnegative().optional()
|
|
3791
|
+
}).strict();
|
|
3792
|
+
const MemoryQmdUpdateSchema = z.object({
|
|
3793
|
+
interval: z.string().optional(),
|
|
3794
|
+
debounceMs: z.number().int().nonnegative().optional(),
|
|
3795
|
+
onBoot: z.boolean().optional(),
|
|
3796
|
+
embedInterval: z.string().optional()
|
|
3797
|
+
}).strict();
|
|
3798
|
+
const MemoryQmdLimitsSchema = z.object({
|
|
3799
|
+
maxResults: z.number().int().positive().optional(),
|
|
3800
|
+
maxSnippetChars: z.number().int().positive().optional(),
|
|
3801
|
+
maxInjectedChars: z.number().int().positive().optional(),
|
|
3802
|
+
timeoutMs: z.number().int().nonnegative().optional()
|
|
3803
|
+
}).strict();
|
|
3804
|
+
const MemoryQmdSchema = z.object({
|
|
3805
|
+
command: z.string().optional(),
|
|
3806
|
+
includeDefaultMemory: z.boolean().optional(),
|
|
3807
|
+
paths: z.array(MemoryQmdPathSchema).optional(),
|
|
3808
|
+
sessions: MemoryQmdSessionSchema.optional(),
|
|
3809
|
+
update: MemoryQmdUpdateSchema.optional(),
|
|
3810
|
+
limits: MemoryQmdLimitsSchema.optional(),
|
|
3811
|
+
scope: SessionSendPolicySchema.optional()
|
|
3812
|
+
}).strict();
|
|
3813
|
+
const MemorySchema = z.object({
|
|
3814
|
+
backend: z.union([z.literal("builtin"), z.literal("qmd")]).optional(),
|
|
3815
|
+
citations: z.union([
|
|
3816
|
+
z.literal("auto"),
|
|
3817
|
+
z.literal("on"),
|
|
3818
|
+
z.literal("off")
|
|
3819
|
+
]).optional(),
|
|
3820
|
+
qmd: MemoryQmdSchema.optional()
|
|
3821
|
+
}).strict().optional();
|
|
3822
|
+
const OpenClawSchema = z.object({
|
|
3823
|
+
meta: z.object({
|
|
3824
|
+
lastTouchedVersion: z.string().optional(),
|
|
3825
|
+
lastTouchedAt: z.string().optional()
|
|
3826
|
+
}).strict().optional(),
|
|
3827
|
+
env: z.object({
|
|
3828
|
+
shellEnv: z.object({
|
|
3829
|
+
enabled: z.boolean().optional(),
|
|
3830
|
+
timeoutMs: z.number().int().nonnegative().optional()
|
|
3831
|
+
}).strict().optional(),
|
|
3832
|
+
vars: z.record(z.string(), z.string()).optional()
|
|
3833
|
+
}).catchall(z.string()).optional(),
|
|
3834
|
+
wizard: z.object({
|
|
3835
|
+
lastRunAt: z.string().optional(),
|
|
3836
|
+
lastRunVersion: z.string().optional(),
|
|
3837
|
+
lastRunCommit: z.string().optional(),
|
|
3838
|
+
lastRunCommand: z.string().optional(),
|
|
3839
|
+
lastRunMode: z.union([z.literal("local"), z.literal("remote")]).optional()
|
|
3840
|
+
}).strict().optional(),
|
|
3841
|
+
diagnostics: z.object({
|
|
3842
|
+
enabled: z.boolean().optional(),
|
|
3843
|
+
flags: z.array(z.string()).optional(),
|
|
3844
|
+
otel: z.object({
|
|
3845
|
+
enabled: z.boolean().optional(),
|
|
3846
|
+
endpoint: z.string().optional(),
|
|
3847
|
+
protocol: z.union([z.literal("http/protobuf"), z.literal("grpc")]).optional(),
|
|
3848
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
3849
|
+
serviceName: z.string().optional(),
|
|
3850
|
+
traces: z.boolean().optional(),
|
|
3851
|
+
metrics: z.boolean().optional(),
|
|
3852
|
+
logs: z.boolean().optional(),
|
|
3853
|
+
sampleRate: z.number().min(0).max(1).optional(),
|
|
3854
|
+
flushIntervalMs: z.number().int().nonnegative().optional()
|
|
3855
|
+
}).strict().optional(),
|
|
3856
|
+
cacheTrace: z.object({
|
|
3857
|
+
enabled: z.boolean().optional(),
|
|
3858
|
+
filePath: z.string().optional(),
|
|
3859
|
+
includeMessages: z.boolean().optional(),
|
|
3860
|
+
includePrompt: z.boolean().optional(),
|
|
3861
|
+
includeSystem: z.boolean().optional()
|
|
3862
|
+
}).strict().optional()
|
|
3863
|
+
}).strict().optional(),
|
|
3864
|
+
logging: z.object({
|
|
3865
|
+
level: z.union([
|
|
3866
|
+
z.literal("silent"),
|
|
3867
|
+
z.literal("fatal"),
|
|
3868
|
+
z.literal("error"),
|
|
3869
|
+
z.literal("warn"),
|
|
3870
|
+
z.literal("info"),
|
|
3871
|
+
z.literal("debug"),
|
|
3872
|
+
z.literal("trace")
|
|
3873
|
+
]).optional(),
|
|
3874
|
+
file: z.string().optional(),
|
|
3875
|
+
consoleLevel: z.union([
|
|
3876
|
+
z.literal("silent"),
|
|
3877
|
+
z.literal("fatal"),
|
|
3878
|
+
z.literal("error"),
|
|
3879
|
+
z.literal("warn"),
|
|
3880
|
+
z.literal("info"),
|
|
3881
|
+
z.literal("debug"),
|
|
3882
|
+
z.literal("trace")
|
|
3883
|
+
]).optional(),
|
|
3884
|
+
consoleStyle: z.union([
|
|
3885
|
+
z.literal("pretty"),
|
|
3886
|
+
z.literal("compact"),
|
|
3887
|
+
z.literal("json")
|
|
3888
|
+
]).optional(),
|
|
3889
|
+
redactSensitive: z.union([z.literal("off"), z.literal("tools")]).optional(),
|
|
3890
|
+
redactPatterns: z.array(z.string()).optional()
|
|
3891
|
+
}).strict().optional(),
|
|
3892
|
+
update: z.object({
|
|
3893
|
+
channel: z.union([
|
|
3894
|
+
z.literal("stable"),
|
|
3895
|
+
z.literal("beta"),
|
|
3896
|
+
z.literal("dev")
|
|
3897
|
+
]).optional(),
|
|
3898
|
+
checkOnStart: z.boolean().optional()
|
|
3899
|
+
}).strict().optional(),
|
|
3900
|
+
browser: z.object({
|
|
3901
|
+
enabled: z.boolean().optional(),
|
|
3902
|
+
evaluateEnabled: z.boolean().optional(),
|
|
3903
|
+
cdpUrl: z.string().optional(),
|
|
3904
|
+
remoteCdpTimeoutMs: z.number().int().nonnegative().optional(),
|
|
3905
|
+
remoteCdpHandshakeTimeoutMs: z.number().int().nonnegative().optional(),
|
|
3906
|
+
color: z.string().optional(),
|
|
3907
|
+
executablePath: z.string().optional(),
|
|
3908
|
+
headless: z.boolean().optional(),
|
|
3909
|
+
noSandbox: z.boolean().optional(),
|
|
3910
|
+
attachOnly: z.boolean().optional(),
|
|
3911
|
+
defaultProfile: z.string().optional(),
|
|
3912
|
+
snapshotDefaults: BrowserSnapshotDefaultsSchema,
|
|
3913
|
+
profiles: z.record(z.string().regex(/^[a-z0-9-]+$/, "Profile names must be alphanumeric with hyphens only"), z.object({
|
|
3914
|
+
cdpPort: z.number().int().min(1).max(65535).optional(),
|
|
3915
|
+
cdpUrl: z.string().optional(),
|
|
3916
|
+
driver: z.union([z.literal("clawd"), z.literal("extension")]).optional(),
|
|
3917
|
+
color: HexColorSchema
|
|
3918
|
+
}).strict().refine((value) => value.cdpPort || value.cdpUrl, { message: "Profile must set cdpPort or cdpUrl" })).optional()
|
|
3919
|
+
}).strict().optional(),
|
|
3920
|
+
ui: z.object({
|
|
3921
|
+
seamColor: HexColorSchema.optional(),
|
|
3922
|
+
assistant: z.object({
|
|
3923
|
+
name: z.string().max(50).optional(),
|
|
3924
|
+
avatar: z.string().max(200).optional()
|
|
3925
|
+
}).strict().optional()
|
|
3926
|
+
}).strict().optional(),
|
|
3927
|
+
auth: z.object({
|
|
3928
|
+
profiles: z.record(z.string(), z.object({
|
|
3929
|
+
provider: z.string(),
|
|
3930
|
+
mode: z.union([
|
|
3931
|
+
z.literal("api_key"),
|
|
3932
|
+
z.literal("oauth"),
|
|
3933
|
+
z.literal("token")
|
|
3934
|
+
]),
|
|
3935
|
+
email: z.string().optional()
|
|
3936
|
+
}).strict()).optional(),
|
|
3937
|
+
order: z.record(z.string(), z.array(z.string())).optional(),
|
|
3938
|
+
cooldowns: z.object({
|
|
3939
|
+
billingBackoffHours: z.number().positive().optional(),
|
|
3940
|
+
billingBackoffHoursByProvider: z.record(z.string(), z.number().positive()).optional(),
|
|
3941
|
+
billingMaxHours: z.number().positive().optional(),
|
|
3942
|
+
failureWindowHours: z.number().positive().optional()
|
|
3943
|
+
}).strict().optional()
|
|
3944
|
+
}).strict().optional(),
|
|
3945
|
+
models: ModelsConfigSchema,
|
|
3946
|
+
nodeHost: NodeHostSchema,
|
|
3947
|
+
agents: AgentsSchema,
|
|
3948
|
+
tools: ToolsSchema,
|
|
3949
|
+
bindings: BindingsSchema,
|
|
3950
|
+
broadcast: BroadcastSchema,
|
|
3951
|
+
audio: AudioSchema,
|
|
3952
|
+
media: z.object({ preserveFilenames: z.boolean().optional() }).strict().optional(),
|
|
3953
|
+
messages: MessagesSchema,
|
|
3954
|
+
commands: CommandsSchema,
|
|
3955
|
+
approvals: ApprovalsSchema,
|
|
3956
|
+
session: SessionSchema,
|
|
3957
|
+
cron: z.object({
|
|
3958
|
+
enabled: z.boolean().optional(),
|
|
3959
|
+
store: z.string().optional(),
|
|
3960
|
+
maxConcurrentRuns: z.number().int().positive().optional()
|
|
3961
|
+
}).strict().optional(),
|
|
3962
|
+
hooks: z.object({
|
|
3963
|
+
enabled: z.boolean().optional(),
|
|
3964
|
+
path: z.string().optional(),
|
|
3965
|
+
token: z.string().optional(),
|
|
3966
|
+
maxBodyBytes: z.number().int().positive().optional(),
|
|
3967
|
+
presets: z.array(z.string()).optional(),
|
|
3968
|
+
transformsDir: z.string().optional(),
|
|
3969
|
+
mappings: z.array(HookMappingSchema).optional(),
|
|
3970
|
+
gmail: HooksGmailSchema,
|
|
3971
|
+
internal: InternalHooksSchema
|
|
3972
|
+
}).strict().optional(),
|
|
3973
|
+
web: z.object({
|
|
3974
|
+
enabled: z.boolean().optional(),
|
|
3975
|
+
heartbeatSeconds: z.number().int().positive().optional(),
|
|
3976
|
+
reconnect: z.object({
|
|
3977
|
+
initialMs: z.number().positive().optional(),
|
|
3978
|
+
maxMs: z.number().positive().optional(),
|
|
3979
|
+
factor: z.number().positive().optional(),
|
|
3980
|
+
jitter: z.number().min(0).max(1).optional(),
|
|
3981
|
+
maxAttempts: z.number().int().min(0).optional()
|
|
3982
|
+
}).strict().optional()
|
|
3983
|
+
}).strict().optional(),
|
|
3984
|
+
channels: ChannelsSchema,
|
|
3985
|
+
discovery: z.object({
|
|
3986
|
+
wideArea: z.object({ enabled: z.boolean().optional() }).strict().optional(),
|
|
3987
|
+
mdns: z.object({ mode: z.enum([
|
|
3988
|
+
"off",
|
|
3989
|
+
"minimal",
|
|
3990
|
+
"full"
|
|
3991
|
+
]).optional() }).strict().optional()
|
|
3992
|
+
}).strict().optional(),
|
|
3993
|
+
canvasHost: z.object({
|
|
3994
|
+
enabled: z.boolean().optional(),
|
|
3995
|
+
root: z.string().optional(),
|
|
3996
|
+
port: z.number().int().positive().optional(),
|
|
3997
|
+
liveReload: z.boolean().optional()
|
|
3998
|
+
}).strict().optional(),
|
|
3999
|
+
talk: z.object({
|
|
4000
|
+
voiceId: z.string().optional(),
|
|
4001
|
+
voiceAliases: z.record(z.string(), z.string()).optional(),
|
|
4002
|
+
modelId: z.string().optional(),
|
|
4003
|
+
outputFormat: z.string().optional(),
|
|
4004
|
+
apiKey: z.string().optional(),
|
|
4005
|
+
interruptOnSpeech: z.boolean().optional()
|
|
4006
|
+
}).strict().optional(),
|
|
4007
|
+
gateway: z.object({
|
|
4008
|
+
port: z.number().int().positive().optional(),
|
|
4009
|
+
mode: z.union([z.literal("local"), z.literal("remote")]).optional(),
|
|
4010
|
+
bind: z.union([
|
|
4011
|
+
z.literal("auto"),
|
|
4012
|
+
z.literal("lan"),
|
|
4013
|
+
z.literal("loopback"),
|
|
4014
|
+
z.literal("custom"),
|
|
4015
|
+
z.literal("tailnet")
|
|
4016
|
+
]).optional(),
|
|
4017
|
+
controlUi: z.object({
|
|
4018
|
+
enabled: z.boolean().optional(),
|
|
4019
|
+
basePath: z.string().optional(),
|
|
4020
|
+
root: z.string().optional(),
|
|
4021
|
+
allowedOrigins: z.array(z.string()).optional(),
|
|
4022
|
+
allowInsecureAuth: z.boolean().optional(),
|
|
4023
|
+
dangerouslyDisableDeviceAuth: z.boolean().optional()
|
|
4024
|
+
}).strict().optional(),
|
|
4025
|
+
auth: z.object({
|
|
4026
|
+
mode: z.union([z.literal("token"), z.literal("password")]).optional(),
|
|
4027
|
+
token: z.string().optional(),
|
|
4028
|
+
password: z.string().optional(),
|
|
4029
|
+
allowTailscale: z.boolean().optional()
|
|
4030
|
+
}).strict().optional(),
|
|
4031
|
+
trustedProxies: z.array(z.string()).optional(),
|
|
4032
|
+
tailscale: z.object({
|
|
4033
|
+
mode: z.union([
|
|
4034
|
+
z.literal("off"),
|
|
4035
|
+
z.literal("serve"),
|
|
4036
|
+
z.literal("funnel")
|
|
4037
|
+
]).optional(),
|
|
4038
|
+
resetOnExit: z.boolean().optional()
|
|
4039
|
+
}).strict().optional(),
|
|
4040
|
+
remote: z.object({
|
|
4041
|
+
url: z.string().optional(),
|
|
4042
|
+
transport: z.union([z.literal("ssh"), z.literal("direct")]).optional(),
|
|
4043
|
+
token: z.string().optional(),
|
|
4044
|
+
password: z.string().optional(),
|
|
4045
|
+
tlsFingerprint: z.string().optional(),
|
|
4046
|
+
sshTarget: z.string().optional(),
|
|
4047
|
+
sshIdentity: z.string().optional()
|
|
4048
|
+
}).strict().optional(),
|
|
4049
|
+
reload: z.object({
|
|
4050
|
+
mode: z.union([
|
|
4051
|
+
z.literal("off"),
|
|
4052
|
+
z.literal("restart"),
|
|
4053
|
+
z.literal("hot"),
|
|
4054
|
+
z.literal("hybrid")
|
|
4055
|
+
]).optional(),
|
|
4056
|
+
debounceMs: z.number().int().min(0).optional()
|
|
4057
|
+
}).strict().optional(),
|
|
4058
|
+
tls: z.object({
|
|
4059
|
+
enabled: z.boolean().optional(),
|
|
4060
|
+
autoGenerate: z.boolean().optional(),
|
|
4061
|
+
certPath: z.string().optional(),
|
|
4062
|
+
keyPath: z.string().optional(),
|
|
4063
|
+
caPath: z.string().optional()
|
|
4064
|
+
}).optional(),
|
|
4065
|
+
http: z.object({ endpoints: z.object({
|
|
4066
|
+
chatCompletions: z.object({ enabled: z.boolean().optional() }).strict().optional(),
|
|
4067
|
+
responses: z.object({
|
|
4068
|
+
enabled: z.boolean().optional(),
|
|
4069
|
+
maxBodyBytes: z.number().int().positive().optional(),
|
|
4070
|
+
files: z.object({
|
|
4071
|
+
allowUrl: z.boolean().optional(),
|
|
4072
|
+
allowedMimes: z.array(z.string()).optional(),
|
|
4073
|
+
maxBytes: z.number().int().positive().optional(),
|
|
4074
|
+
maxChars: z.number().int().positive().optional(),
|
|
4075
|
+
maxRedirects: z.number().int().nonnegative().optional(),
|
|
4076
|
+
timeoutMs: z.number().int().positive().optional(),
|
|
4077
|
+
pdf: z.object({
|
|
4078
|
+
maxPages: z.number().int().positive().optional(),
|
|
4079
|
+
maxPixels: z.number().int().positive().optional(),
|
|
4080
|
+
minTextChars: z.number().int().nonnegative().optional()
|
|
4081
|
+
}).strict().optional()
|
|
4082
|
+
}).strict().optional(),
|
|
4083
|
+
images: z.object({
|
|
4084
|
+
allowUrl: z.boolean().optional(),
|
|
4085
|
+
allowedMimes: z.array(z.string()).optional(),
|
|
4086
|
+
maxBytes: z.number().int().positive().optional(),
|
|
4087
|
+
maxRedirects: z.number().int().nonnegative().optional(),
|
|
4088
|
+
timeoutMs: z.number().int().positive().optional()
|
|
4089
|
+
}).strict().optional()
|
|
4090
|
+
}).strict().optional()
|
|
4091
|
+
}).strict().optional() }).strict().optional(),
|
|
4092
|
+
nodes: z.object({
|
|
4093
|
+
browser: z.object({
|
|
4094
|
+
mode: z.union([
|
|
4095
|
+
z.literal("auto"),
|
|
4096
|
+
z.literal("manual"),
|
|
4097
|
+
z.literal("off")
|
|
4098
|
+
]).optional(),
|
|
4099
|
+
node: z.string().optional()
|
|
4100
|
+
}).strict().optional(),
|
|
4101
|
+
allowCommands: z.array(z.string()).optional(),
|
|
4102
|
+
denyCommands: z.array(z.string()).optional()
|
|
4103
|
+
}).strict().optional()
|
|
4104
|
+
}).strict().optional(),
|
|
4105
|
+
memory: MemorySchema,
|
|
4106
|
+
skills: z.object({
|
|
4107
|
+
allowBundled: z.array(z.string()).optional(),
|
|
4108
|
+
load: z.object({
|
|
4109
|
+
extraDirs: z.array(z.string()).optional(),
|
|
4110
|
+
watch: z.boolean().optional(),
|
|
4111
|
+
watchDebounceMs: z.number().int().min(0).optional()
|
|
4112
|
+
}).strict().optional(),
|
|
4113
|
+
install: z.object({
|
|
4114
|
+
preferBrew: z.boolean().optional(),
|
|
4115
|
+
nodeManager: z.union([
|
|
4116
|
+
z.literal("npm"),
|
|
4117
|
+
z.literal("pnpm"),
|
|
4118
|
+
z.literal("yarn"),
|
|
4119
|
+
z.literal("bun")
|
|
4120
|
+
]).optional()
|
|
4121
|
+
}).strict().optional(),
|
|
4122
|
+
entries: z.record(z.string(), z.object({
|
|
4123
|
+
enabled: z.boolean().optional(),
|
|
4124
|
+
apiKey: z.string().optional(),
|
|
4125
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
4126
|
+
config: z.record(z.string(), z.unknown()).optional()
|
|
4127
|
+
}).strict()).optional()
|
|
4128
|
+
}).strict().optional(),
|
|
4129
|
+
plugins: z.object({
|
|
4130
|
+
enabled: z.boolean().optional(),
|
|
4131
|
+
allow: z.array(z.string()).optional(),
|
|
4132
|
+
deny: z.array(z.string()).optional(),
|
|
4133
|
+
load: z.object({ paths: z.array(z.string()).optional() }).strict().optional(),
|
|
4134
|
+
slots: z.object({ memory: z.string().optional() }).strict().optional(),
|
|
4135
|
+
entries: z.record(z.string(), z.object({
|
|
4136
|
+
enabled: z.boolean().optional(),
|
|
4137
|
+
config: z.record(z.string(), z.unknown()).optional()
|
|
4138
|
+
}).strict()).optional(),
|
|
4139
|
+
installs: z.record(z.string(), z.object({
|
|
4140
|
+
source: z.union([
|
|
4141
|
+
z.literal("npm"),
|
|
4142
|
+
z.literal("archive"),
|
|
4143
|
+
z.literal("path")
|
|
4144
|
+
]),
|
|
4145
|
+
spec: z.string().optional(),
|
|
4146
|
+
sourcePath: z.string().optional(),
|
|
4147
|
+
installPath: z.string().optional(),
|
|
4148
|
+
version: z.string().optional(),
|
|
4149
|
+
installedAt: z.string().optional()
|
|
4150
|
+
}).strict()).optional()
|
|
4151
|
+
}).strict().optional()
|
|
4152
|
+
}).strict().superRefine((cfg, ctx) => {
|
|
4153
|
+
const agents = cfg.agents?.list ?? [];
|
|
4154
|
+
if (agents.length === 0) return;
|
|
4155
|
+
const agentIds = new Set(agents.map((agent) => agent.id));
|
|
4156
|
+
const broadcast = cfg.broadcast;
|
|
4157
|
+
if (!broadcast) return;
|
|
4158
|
+
for (const [peerId, ids] of Object.entries(broadcast)) {
|
|
4159
|
+
if (peerId === "strategy") continue;
|
|
4160
|
+
if (!Array.isArray(ids)) continue;
|
|
4161
|
+
for (let idx = 0; idx < ids.length; idx += 1) {
|
|
4162
|
+
const agentId = ids[idx];
|
|
4163
|
+
if (!agentIds.has(agentId)) ctx.addIssue({
|
|
4164
|
+
code: z.ZodIssueCode.custom,
|
|
4165
|
+
path: [
|
|
4166
|
+
"broadcast",
|
|
4167
|
+
peerId,
|
|
4168
|
+
idx
|
|
4169
|
+
],
|
|
4170
|
+
message: `Unknown agent id "${agentId}" (not in agents.list).`
|
|
4171
|
+
});
|
|
4172
|
+
}
|
|
4173
|
+
}
|
|
4174
|
+
});
|
|
4175
|
+
|
|
4176
|
+
//#endregion
|
|
4177
|
+
//#region src/config/validation.ts
|
|
4178
|
+
const AVATAR_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
|
|
4179
|
+
const AVATAR_DATA_RE = /^data:/i;
|
|
4180
|
+
const AVATAR_HTTP_RE = /^https?:\/\//i;
|
|
4181
|
+
const WINDOWS_ABS_RE = /^[a-zA-Z]:[\\/]/;
|
|
4182
|
+
function isWorkspaceAvatarPath(value, workspaceDir) {
|
|
4183
|
+
const workspaceRoot = path.resolve(workspaceDir);
|
|
4184
|
+
const resolved = path.resolve(workspaceRoot, value);
|
|
4185
|
+
const relative = path.relative(workspaceRoot, resolved);
|
|
4186
|
+
if (relative === "") return true;
|
|
4187
|
+
if (relative.startsWith("..")) return false;
|
|
4188
|
+
return !path.isAbsolute(relative);
|
|
4189
|
+
}
|
|
4190
|
+
function validateIdentityAvatar(config) {
|
|
4191
|
+
const agents = config.agents?.list;
|
|
4192
|
+
if (!Array.isArray(agents) || agents.length === 0) return [];
|
|
4193
|
+
const issues = [];
|
|
4194
|
+
for (const [index, entry] of agents.entries()) {
|
|
4195
|
+
if (!entry || typeof entry !== "object") continue;
|
|
4196
|
+
const avatarRaw = entry.identity?.avatar;
|
|
4197
|
+
if (typeof avatarRaw !== "string") continue;
|
|
4198
|
+
const avatar = avatarRaw.trim();
|
|
4199
|
+
if (!avatar) continue;
|
|
4200
|
+
if (AVATAR_DATA_RE.test(avatar) || AVATAR_HTTP_RE.test(avatar)) continue;
|
|
4201
|
+
if (avatar.startsWith("~")) {
|
|
4202
|
+
issues.push({
|
|
4203
|
+
path: `agents.list.${index}.identity.avatar`,
|
|
4204
|
+
message: "identity.avatar must be a workspace-relative path, http(s) URL, or data URI."
|
|
4205
|
+
});
|
|
4206
|
+
continue;
|
|
4207
|
+
}
|
|
4208
|
+
if (AVATAR_SCHEME_RE.test(avatar) && !WINDOWS_ABS_RE.test(avatar)) {
|
|
4209
|
+
issues.push({
|
|
4210
|
+
path: `agents.list.${index}.identity.avatar`,
|
|
4211
|
+
message: "identity.avatar must be a workspace-relative path, http(s) URL, or data URI."
|
|
4212
|
+
});
|
|
4213
|
+
continue;
|
|
4214
|
+
}
|
|
4215
|
+
if (!isWorkspaceAvatarPath(avatar, resolveAgentWorkspaceDir(config, entry.id ?? resolveDefaultAgentId(config)))) issues.push({
|
|
4216
|
+
path: `agents.list.${index}.identity.avatar`,
|
|
4217
|
+
message: "identity.avatar must stay within the agent workspace."
|
|
4218
|
+
});
|
|
4219
|
+
}
|
|
4220
|
+
return issues;
|
|
4221
|
+
}
|
|
4222
|
+
function validateConfigObject(raw) {
|
|
4223
|
+
const legacyIssues = findLegacyConfigIssues(raw);
|
|
4224
|
+
if (legacyIssues.length > 0) return {
|
|
4225
|
+
ok: false,
|
|
4226
|
+
issues: legacyIssues.map((iss) => ({
|
|
4227
|
+
path: iss.path,
|
|
4228
|
+
message: iss.message
|
|
4229
|
+
}))
|
|
4230
|
+
};
|
|
4231
|
+
const validated = OpenClawSchema.safeParse(raw);
|
|
4232
|
+
if (!validated.success) return {
|
|
4233
|
+
ok: false,
|
|
4234
|
+
issues: validated.error.issues.map((iss) => ({
|
|
4235
|
+
path: iss.path.join("."),
|
|
4236
|
+
message: iss.message
|
|
4237
|
+
}))
|
|
4238
|
+
};
|
|
4239
|
+
const duplicates = findDuplicateAgentDirs(validated.data);
|
|
4240
|
+
if (duplicates.length > 0) return {
|
|
4241
|
+
ok: false,
|
|
4242
|
+
issues: [{
|
|
4243
|
+
path: "agents.list",
|
|
4244
|
+
message: formatDuplicateAgentDirError(duplicates)
|
|
4245
|
+
}]
|
|
4246
|
+
};
|
|
4247
|
+
const avatarIssues = validateIdentityAvatar(validated.data);
|
|
4248
|
+
if (avatarIssues.length > 0) return {
|
|
4249
|
+
ok: false,
|
|
4250
|
+
issues: avatarIssues
|
|
4251
|
+
};
|
|
4252
|
+
return {
|
|
4253
|
+
ok: true,
|
|
4254
|
+
config: applyModelDefaults(applyAgentDefaults(applySessionDefaults(validated.data)))
|
|
4255
|
+
};
|
|
4256
|
+
}
|
|
4257
|
+
function isRecord(value) {
|
|
4258
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
4259
|
+
}
|
|
4260
|
+
function validateConfigObjectWithPlugins(raw) {
|
|
4261
|
+
const base = validateConfigObject(raw);
|
|
4262
|
+
if (!base.ok) return {
|
|
4263
|
+
ok: false,
|
|
4264
|
+
issues: base.issues,
|
|
4265
|
+
warnings: []
|
|
4266
|
+
};
|
|
4267
|
+
const config = base.config;
|
|
4268
|
+
const issues = [];
|
|
4269
|
+
const warnings = [];
|
|
4270
|
+
const pluginsConfig = config.plugins;
|
|
4271
|
+
const normalizedPlugins = normalizePluginsConfig(pluginsConfig);
|
|
4272
|
+
const registry = loadPluginManifestRegistry({
|
|
4273
|
+
config,
|
|
4274
|
+
workspaceDir: resolveAgentWorkspaceDir(config, resolveDefaultAgentId(config)) ?? void 0
|
|
4275
|
+
});
|
|
4276
|
+
const knownIds = new Set(registry.plugins.map((record) => record.id));
|
|
4277
|
+
for (const diag of registry.diagnostics) {
|
|
4278
|
+
let path = diag.pluginId ? `plugins.entries.${diag.pluginId}` : "plugins";
|
|
4279
|
+
if (!diag.pluginId && diag.message.includes("plugin path not found")) path = "plugins.load.paths";
|
|
4280
|
+
const message = `${diag.pluginId ? `plugin ${diag.pluginId}` : "plugin"}: ${diag.message}`;
|
|
4281
|
+
if (diag.level === "error") issues.push({
|
|
4282
|
+
path,
|
|
4283
|
+
message
|
|
4284
|
+
});
|
|
4285
|
+
else warnings.push({
|
|
4286
|
+
path,
|
|
4287
|
+
message
|
|
4288
|
+
});
|
|
4289
|
+
}
|
|
4290
|
+
const entries = pluginsConfig?.entries;
|
|
4291
|
+
if (entries && isRecord(entries)) {
|
|
4292
|
+
for (const pluginId of Object.keys(entries)) if (!knownIds.has(pluginId)) issues.push({
|
|
4293
|
+
path: `plugins.entries.${pluginId}`,
|
|
4294
|
+
message: `plugin not found: ${pluginId}`
|
|
4295
|
+
});
|
|
4296
|
+
}
|
|
4297
|
+
const allow = pluginsConfig?.allow ?? [];
|
|
4298
|
+
for (const pluginId of allow) {
|
|
4299
|
+
if (typeof pluginId !== "string" || !pluginId.trim()) continue;
|
|
4300
|
+
if (!knownIds.has(pluginId)) issues.push({
|
|
4301
|
+
path: "plugins.allow",
|
|
4302
|
+
message: `plugin not found: ${pluginId}`
|
|
4303
|
+
});
|
|
4304
|
+
}
|
|
4305
|
+
const deny = pluginsConfig?.deny ?? [];
|
|
4306
|
+
for (const pluginId of deny) {
|
|
4307
|
+
if (typeof pluginId !== "string" || !pluginId.trim()) continue;
|
|
4308
|
+
if (!knownIds.has(pluginId)) issues.push({
|
|
4309
|
+
path: "plugins.deny",
|
|
4310
|
+
message: `plugin not found: ${pluginId}`
|
|
4311
|
+
});
|
|
4312
|
+
}
|
|
4313
|
+
const memorySlot = normalizedPlugins.slots.memory;
|
|
4314
|
+
if (typeof memorySlot === "string" && memorySlot.trim() && !knownIds.has(memorySlot)) issues.push({
|
|
4315
|
+
path: "plugins.slots.memory",
|
|
4316
|
+
message: `plugin not found: ${memorySlot}`
|
|
4317
|
+
});
|
|
4318
|
+
const allowedChannels = new Set(["defaults", ...CHANNEL_IDS]);
|
|
4319
|
+
for (const record of registry.plugins) for (const channelId of record.channels) allowedChannels.add(channelId);
|
|
4320
|
+
if (config.channels && isRecord(config.channels)) for (const key of Object.keys(config.channels)) {
|
|
4321
|
+
const trimmed = key.trim();
|
|
4322
|
+
if (!trimmed) continue;
|
|
4323
|
+
if (!allowedChannels.has(trimmed)) issues.push({
|
|
4324
|
+
path: `channels.${trimmed}`,
|
|
4325
|
+
message: `unknown channel id: ${trimmed}`
|
|
4326
|
+
});
|
|
4327
|
+
}
|
|
4328
|
+
const heartbeatChannelIds = /* @__PURE__ */ new Set();
|
|
4329
|
+
for (const channelId of CHANNEL_IDS) heartbeatChannelIds.add(channelId.toLowerCase());
|
|
4330
|
+
for (const record of registry.plugins) for (const channelId of record.channels) {
|
|
4331
|
+
const trimmed = channelId.trim();
|
|
4332
|
+
if (trimmed) heartbeatChannelIds.add(trimmed.toLowerCase());
|
|
4333
|
+
}
|
|
4334
|
+
const validateHeartbeatTarget = (target, path) => {
|
|
4335
|
+
if (typeof target !== "string") return;
|
|
4336
|
+
const trimmed = target.trim();
|
|
4337
|
+
if (!trimmed) {
|
|
4338
|
+
issues.push({
|
|
4339
|
+
path,
|
|
4340
|
+
message: "heartbeat target must not be empty"
|
|
4341
|
+
});
|
|
4342
|
+
return;
|
|
4343
|
+
}
|
|
4344
|
+
const normalized = trimmed.toLowerCase();
|
|
4345
|
+
if (normalized === "last" || normalized === "none") return;
|
|
4346
|
+
if (normalizeChatChannelId(trimmed)) return;
|
|
4347
|
+
if (heartbeatChannelIds.has(normalized)) return;
|
|
4348
|
+
issues.push({
|
|
4349
|
+
path,
|
|
4350
|
+
message: `unknown heartbeat target: ${target}`
|
|
4351
|
+
});
|
|
4352
|
+
};
|
|
4353
|
+
validateHeartbeatTarget(config.agents?.defaults?.heartbeat?.target, "agents.defaults.heartbeat.target");
|
|
4354
|
+
if (Array.isArray(config.agents?.list)) for (const [index, entry] of config.agents.list.entries()) validateHeartbeatTarget(entry?.heartbeat?.target, `agents.list.${index}.heartbeat.target`);
|
|
4355
|
+
let selectedMemoryPluginId = null;
|
|
4356
|
+
const seenPlugins = /* @__PURE__ */ new Set();
|
|
4357
|
+
for (const record of registry.plugins) {
|
|
4358
|
+
const pluginId = record.id;
|
|
4359
|
+
if (seenPlugins.has(pluginId)) continue;
|
|
4360
|
+
seenPlugins.add(pluginId);
|
|
4361
|
+
const entry = normalizedPlugins.entries[pluginId];
|
|
4362
|
+
const entryHasConfig = Boolean(entry?.config);
|
|
4363
|
+
const enableState = resolveEnableState(pluginId, record.origin, normalizedPlugins);
|
|
4364
|
+
let enabled = enableState.enabled;
|
|
4365
|
+
let reason = enableState.reason;
|
|
4366
|
+
if (enabled) {
|
|
4367
|
+
const memoryDecision = resolveMemorySlotDecision({
|
|
4368
|
+
id: pluginId,
|
|
4369
|
+
kind: record.kind,
|
|
4370
|
+
slot: memorySlot,
|
|
4371
|
+
selectedId: selectedMemoryPluginId
|
|
4372
|
+
});
|
|
4373
|
+
if (!memoryDecision.enabled) {
|
|
4374
|
+
enabled = false;
|
|
4375
|
+
reason = memoryDecision.reason;
|
|
4376
|
+
}
|
|
4377
|
+
if (memoryDecision.selected && record.kind === "memory") selectedMemoryPluginId = pluginId;
|
|
4378
|
+
}
|
|
4379
|
+
if (enabled || entryHasConfig) if (record.configSchema) {
|
|
4380
|
+
const res = validateJsonSchemaValue({
|
|
4381
|
+
schema: record.configSchema,
|
|
4382
|
+
cacheKey: record.schemaCacheKey ?? record.manifestPath ?? pluginId,
|
|
4383
|
+
value: entry?.config ?? {}
|
|
4384
|
+
});
|
|
4385
|
+
if (!res.ok) for (const error of res.errors) issues.push({
|
|
4386
|
+
path: `plugins.entries.${pluginId}.config`,
|
|
4387
|
+
message: `invalid config: ${error}`
|
|
4388
|
+
});
|
|
4389
|
+
} else issues.push({
|
|
4390
|
+
path: `plugins.entries.${pluginId}`,
|
|
4391
|
+
message: `plugin schema missing for ${pluginId}`
|
|
4392
|
+
});
|
|
4393
|
+
if (!enabled && entryHasConfig) warnings.push({
|
|
4394
|
+
path: `plugins.entries.${pluginId}`,
|
|
4395
|
+
message: `plugin disabled (${reason ?? "disabled"}) but config is present`
|
|
4396
|
+
});
|
|
4397
|
+
}
|
|
4398
|
+
if (issues.length > 0) return {
|
|
4399
|
+
ok: false,
|
|
4400
|
+
issues,
|
|
4401
|
+
warnings
|
|
4402
|
+
};
|
|
4403
|
+
return {
|
|
4404
|
+
ok: true,
|
|
4405
|
+
config,
|
|
4406
|
+
warnings
|
|
4407
|
+
};
|
|
4408
|
+
}
|
|
4409
|
+
|
|
4410
|
+
//#endregion
|
|
4411
|
+
//#region src/config/version.ts
|
|
4412
|
+
const VERSION_RE = /^v?(\d+)\.(\d+)\.(\d+)(?:-(\d+))?/;
|
|
4413
|
+
function parseOpenClawVersion(raw) {
|
|
4414
|
+
if (!raw) return null;
|
|
4415
|
+
const match = raw.trim().match(VERSION_RE);
|
|
4416
|
+
if (!match) return null;
|
|
4417
|
+
const [, major, minor, patch, revision] = match;
|
|
4418
|
+
return {
|
|
4419
|
+
major: Number.parseInt(major, 10),
|
|
4420
|
+
minor: Number.parseInt(minor, 10),
|
|
4421
|
+
patch: Number.parseInt(patch, 10),
|
|
4422
|
+
revision: revision ? Number.parseInt(revision, 10) : 0
|
|
4423
|
+
};
|
|
4424
|
+
}
|
|
4425
|
+
function compareOpenClawVersions(a, b) {
|
|
4426
|
+
const parsedA = parseOpenClawVersion(a);
|
|
4427
|
+
const parsedB = parseOpenClawVersion(b);
|
|
4428
|
+
if (!parsedA || !parsedB) return null;
|
|
4429
|
+
if (parsedA.major !== parsedB.major) return parsedA.major < parsedB.major ? -1 : 1;
|
|
4430
|
+
if (parsedA.minor !== parsedB.minor) return parsedA.minor < parsedB.minor ? -1 : 1;
|
|
4431
|
+
if (parsedA.patch !== parsedB.patch) return parsedA.patch < parsedB.patch ? -1 : 1;
|
|
4432
|
+
if (parsedA.revision !== parsedB.revision) return parsedA.revision < parsedB.revision ? -1 : 1;
|
|
4433
|
+
return 0;
|
|
4434
|
+
}
|
|
4435
|
+
|
|
4436
|
+
//#endregion
|
|
4437
|
+
//#region src/config/io.ts
|
|
4438
|
+
const SHELL_ENV_EXPECTED_KEYS = [
|
|
4439
|
+
"OPENAI_API_KEY",
|
|
4440
|
+
"ANTHROPIC_API_KEY",
|
|
4441
|
+
"ANTHROPIC_OAUTH_TOKEN",
|
|
4442
|
+
"GEMINI_API_KEY",
|
|
4443
|
+
"ZAI_API_KEY",
|
|
4444
|
+
"OPENROUTER_API_KEY",
|
|
4445
|
+
"AI_GATEWAY_API_KEY",
|
|
4446
|
+
"MINIMAX_API_KEY",
|
|
4447
|
+
"SYNTHETIC_API_KEY",
|
|
4448
|
+
"ELEVENLABS_API_KEY",
|
|
4449
|
+
"TELEGRAM_BOT_TOKEN",
|
|
4450
|
+
"DISCORD_BOT_TOKEN",
|
|
4451
|
+
"SLACK_BOT_TOKEN",
|
|
4452
|
+
"SLACK_APP_TOKEN",
|
|
4453
|
+
"OPENCLAW_GATEWAY_TOKEN",
|
|
4454
|
+
"OPENCLAW_GATEWAY_PASSWORD"
|
|
4455
|
+
];
|
|
4456
|
+
const CONFIG_BACKUP_COUNT = 5;
|
|
4457
|
+
const loggedInvalidConfigs = /* @__PURE__ */ new Set();
|
|
4458
|
+
function hashConfigRaw(raw) {
|
|
4459
|
+
return crypto.createHash("sha256").update(raw ?? "").digest("hex");
|
|
4460
|
+
}
|
|
4461
|
+
function resolveConfigSnapshotHash(snapshot) {
|
|
4462
|
+
if (typeof snapshot.hash === "string") {
|
|
4463
|
+
const trimmed = snapshot.hash.trim();
|
|
4464
|
+
if (trimmed) return trimmed;
|
|
4465
|
+
}
|
|
4466
|
+
if (typeof snapshot.raw !== "string") return null;
|
|
4467
|
+
return hashConfigRaw(snapshot.raw);
|
|
4468
|
+
}
|
|
4469
|
+
function coerceConfig(value) {
|
|
4470
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
4471
|
+
return value;
|
|
4472
|
+
}
|
|
4473
|
+
async function rotateConfigBackups(configPath, ioFs) {
|
|
4474
|
+
if (CONFIG_BACKUP_COUNT <= 1) return;
|
|
4475
|
+
const backupBase = `${configPath}.bak`;
|
|
4476
|
+
const maxIndex = CONFIG_BACKUP_COUNT - 1;
|
|
4477
|
+
await ioFs.unlink(`${backupBase}.${maxIndex}`).catch(() => {});
|
|
4478
|
+
for (let index = maxIndex - 1; index >= 1; index -= 1) await ioFs.rename(`${backupBase}.${index}`, `${backupBase}.${index + 1}`).catch(() => {});
|
|
4479
|
+
await ioFs.rename(backupBase, `${backupBase}.1`).catch(() => {});
|
|
4480
|
+
}
|
|
4481
|
+
function warnOnConfigMiskeys(raw, logger) {
|
|
4482
|
+
if (!raw || typeof raw !== "object") return;
|
|
4483
|
+
const gateway = raw.gateway;
|
|
4484
|
+
if (!gateway || typeof gateway !== "object") return;
|
|
4485
|
+
if ("token" in gateway) logger.warn("Config uses \"gateway.token\". This key is ignored; use \"gateway.auth.token\" instead.");
|
|
4486
|
+
}
|
|
4487
|
+
function stampConfigVersion(cfg) {
|
|
4488
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4489
|
+
return {
|
|
4490
|
+
...cfg,
|
|
4491
|
+
meta: {
|
|
4492
|
+
...cfg.meta,
|
|
4493
|
+
lastTouchedVersion: VERSION,
|
|
4494
|
+
lastTouchedAt: now
|
|
4495
|
+
}
|
|
4496
|
+
};
|
|
4497
|
+
}
|
|
4498
|
+
function warnIfConfigFromFuture(cfg, logger) {
|
|
4499
|
+
const touched = cfg.meta?.lastTouchedVersion;
|
|
4500
|
+
if (!touched) return;
|
|
4501
|
+
const cmp = compareOpenClawVersions(VERSION, touched);
|
|
4502
|
+
if (cmp === null) return;
|
|
4503
|
+
if (cmp < 0) logger.warn(`Config was last written by a newer OpenClaw (${touched}); current version is ${VERSION}.`);
|
|
4504
|
+
}
|
|
4505
|
+
function applyConfigEnv(cfg, env) {
|
|
4506
|
+
const entries = collectConfigEnvVars(cfg);
|
|
4507
|
+
for (const [key, value] of Object.entries(entries)) {
|
|
4508
|
+
if (env[key]?.trim()) continue;
|
|
4509
|
+
env[key] = value;
|
|
4510
|
+
}
|
|
4511
|
+
}
|
|
4512
|
+
function resolveConfigPathForDeps(deps) {
|
|
4513
|
+
if (deps.configPath) return deps.configPath;
|
|
4514
|
+
return resolveConfigPath(deps.env, resolveStateDir(deps.env, deps.homedir));
|
|
4515
|
+
}
|
|
4516
|
+
function normalizeDeps(overrides = {}) {
|
|
4517
|
+
return {
|
|
4518
|
+
fs: overrides.fs ?? fs,
|
|
4519
|
+
json5: overrides.json5 ?? JSON5,
|
|
4520
|
+
env: overrides.env ?? process.env,
|
|
4521
|
+
homedir: overrides.homedir ?? os.homedir,
|
|
4522
|
+
configPath: overrides.configPath ?? "",
|
|
4523
|
+
logger: overrides.logger ?? console
|
|
4524
|
+
};
|
|
4525
|
+
}
|
|
4526
|
+
function parseConfigJson5(raw, json5 = JSON5) {
|
|
4527
|
+
try {
|
|
4528
|
+
return {
|
|
4529
|
+
ok: true,
|
|
4530
|
+
parsed: json5.parse(raw)
|
|
4531
|
+
};
|
|
4532
|
+
} catch (err) {
|
|
4533
|
+
return {
|
|
4534
|
+
ok: false,
|
|
4535
|
+
error: String(err)
|
|
4536
|
+
};
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
function createConfigIO(overrides = {}) {
|
|
4540
|
+
const deps = normalizeDeps(overrides);
|
|
4541
|
+
const requestedConfigPath = resolveConfigPathForDeps(deps);
|
|
4542
|
+
const configPath = (deps.configPath ? [requestedConfigPath] : resolveDefaultConfigCandidates(deps.env, deps.homedir)).find((candidate) => deps.fs.existsSync(candidate)) ?? requestedConfigPath;
|
|
4543
|
+
function loadConfig() {
|
|
4544
|
+
try {
|
|
4545
|
+
if (!deps.fs.existsSync(configPath)) {
|
|
4546
|
+
if (shouldEnableShellEnvFallback(deps.env) && !shouldDeferShellEnvFallback(deps.env)) loadShellEnvFallback({
|
|
4547
|
+
enabled: true,
|
|
4548
|
+
env: deps.env,
|
|
4549
|
+
expectedKeys: SHELL_ENV_EXPECTED_KEYS,
|
|
4550
|
+
logger: deps.logger,
|
|
4551
|
+
timeoutMs: resolveShellEnvFallbackTimeoutMs(deps.env)
|
|
4552
|
+
});
|
|
4553
|
+
return {};
|
|
4554
|
+
}
|
|
4555
|
+
const raw = deps.fs.readFileSync(configPath, "utf-8");
|
|
4556
|
+
const resolved = resolveConfigIncludes(deps.json5.parse(raw), configPath, {
|
|
4557
|
+
readFile: (p) => deps.fs.readFileSync(p, "utf-8"),
|
|
4558
|
+
parseJson: (raw) => deps.json5.parse(raw)
|
|
4559
|
+
});
|
|
4560
|
+
if (resolved && typeof resolved === "object" && "env" in resolved) applyConfigEnv(resolved, deps.env);
|
|
4561
|
+
const resolvedConfig = resolveConfigEnvVars(resolved, deps.env);
|
|
4562
|
+
warnOnConfigMiskeys(resolvedConfig, deps.logger);
|
|
4563
|
+
if (typeof resolvedConfig !== "object" || resolvedConfig === null) return {};
|
|
4564
|
+
const preValidationDuplicates = findDuplicateAgentDirs(resolvedConfig, {
|
|
4565
|
+
env: deps.env,
|
|
4566
|
+
homedir: deps.homedir
|
|
4567
|
+
});
|
|
4568
|
+
if (preValidationDuplicates.length > 0) throw new DuplicateAgentDirError(preValidationDuplicates);
|
|
4569
|
+
const validated = validateConfigObjectWithPlugins(resolvedConfig);
|
|
4570
|
+
if (!validated.ok) {
|
|
4571
|
+
const details = validated.issues.map((iss) => `- ${iss.path || "<root>"}: ${iss.message}`).join("\n");
|
|
4572
|
+
if (!loggedInvalidConfigs.has(configPath)) {
|
|
4573
|
+
loggedInvalidConfigs.add(configPath);
|
|
4574
|
+
deps.logger.error(`Invalid config at ${configPath}:\\n${details}`);
|
|
4575
|
+
}
|
|
4576
|
+
const error = /* @__PURE__ */ new Error("Invalid config");
|
|
4577
|
+
error.code = "INVALID_CONFIG";
|
|
4578
|
+
error.details = details;
|
|
4579
|
+
throw error;
|
|
4580
|
+
}
|
|
4581
|
+
if (validated.warnings.length > 0) {
|
|
4582
|
+
const details = validated.warnings.map((iss) => `- ${iss.path || "<root>"}: ${iss.message}`).join("\n");
|
|
4583
|
+
deps.logger.warn(`Config warnings:\\n${details}`);
|
|
4584
|
+
}
|
|
4585
|
+
warnIfConfigFromFuture(validated.config, deps.logger);
|
|
4586
|
+
const cfg = applyModelDefaults(applyCompactionDefaults(applyContextPruningDefaults(applyAgentDefaults(applySessionDefaults(applyLoggingDefaults(applyMessageDefaults(validated.config)))))));
|
|
4587
|
+
normalizeConfigPaths(cfg);
|
|
4588
|
+
const duplicates = findDuplicateAgentDirs(cfg, {
|
|
4589
|
+
env: deps.env,
|
|
4590
|
+
homedir: deps.homedir
|
|
4591
|
+
});
|
|
4592
|
+
if (duplicates.length > 0) throw new DuplicateAgentDirError(duplicates);
|
|
4593
|
+
applyConfigEnv(cfg, deps.env);
|
|
4594
|
+
if ((shouldEnableShellEnvFallback(deps.env) || cfg.env?.shellEnv?.enabled === true) && !shouldDeferShellEnvFallback(deps.env)) loadShellEnvFallback({
|
|
4595
|
+
enabled: true,
|
|
4596
|
+
env: deps.env,
|
|
4597
|
+
expectedKeys: SHELL_ENV_EXPECTED_KEYS,
|
|
4598
|
+
logger: deps.logger,
|
|
4599
|
+
timeoutMs: cfg.env?.shellEnv?.timeoutMs ?? resolveShellEnvFallbackTimeoutMs(deps.env)
|
|
4600
|
+
});
|
|
4601
|
+
return applyConfigOverrides(cfg);
|
|
4602
|
+
} catch (err) {
|
|
4603
|
+
if (err instanceof DuplicateAgentDirError) {
|
|
4604
|
+
deps.logger.error(err.message);
|
|
4605
|
+
throw err;
|
|
4606
|
+
}
|
|
4607
|
+
if (err?.code === "INVALID_CONFIG") return {};
|
|
4608
|
+
deps.logger.error(`Failed to read config at ${configPath}`, err);
|
|
4609
|
+
return {};
|
|
4610
|
+
}
|
|
4611
|
+
}
|
|
4612
|
+
async function readConfigFileSnapshot() {
|
|
4613
|
+
if (!deps.fs.existsSync(configPath)) {
|
|
4614
|
+
const hash = hashConfigRaw(null);
|
|
4615
|
+
return {
|
|
4616
|
+
path: configPath,
|
|
4617
|
+
exists: false,
|
|
4618
|
+
raw: null,
|
|
4619
|
+
parsed: {},
|
|
4620
|
+
valid: true,
|
|
4621
|
+
config: applyTalkApiKey(applyModelDefaults(applyCompactionDefaults(applyContextPruningDefaults(applyAgentDefaults(applySessionDefaults(applyMessageDefaults({}))))))),
|
|
4622
|
+
hash,
|
|
4623
|
+
issues: [],
|
|
4624
|
+
warnings: [],
|
|
4625
|
+
legacyIssues: []
|
|
4626
|
+
};
|
|
4627
|
+
}
|
|
4628
|
+
try {
|
|
4629
|
+
const raw = deps.fs.readFileSync(configPath, "utf-8");
|
|
4630
|
+
const hash = hashConfigRaw(raw);
|
|
4631
|
+
const parsedRes = parseConfigJson5(raw, deps.json5);
|
|
4632
|
+
if (!parsedRes.ok) return {
|
|
4633
|
+
path: configPath,
|
|
4634
|
+
exists: true,
|
|
4635
|
+
raw,
|
|
4636
|
+
parsed: {},
|
|
4637
|
+
valid: false,
|
|
4638
|
+
config: {},
|
|
4639
|
+
hash,
|
|
4640
|
+
issues: [{
|
|
4641
|
+
path: "",
|
|
4642
|
+
message: `JSON5 parse failed: ${parsedRes.error}`
|
|
4643
|
+
}],
|
|
4644
|
+
warnings: [],
|
|
4645
|
+
legacyIssues: []
|
|
4646
|
+
};
|
|
4647
|
+
let resolved;
|
|
4648
|
+
try {
|
|
4649
|
+
resolved = resolveConfigIncludes(parsedRes.parsed, configPath, {
|
|
4650
|
+
readFile: (p) => deps.fs.readFileSync(p, "utf-8"),
|
|
4651
|
+
parseJson: (raw) => deps.json5.parse(raw)
|
|
4652
|
+
});
|
|
4653
|
+
} catch (err) {
|
|
4654
|
+
const message = err instanceof ConfigIncludeError ? err.message : `Include resolution failed: ${String(err)}`;
|
|
4655
|
+
return {
|
|
4656
|
+
path: configPath,
|
|
4657
|
+
exists: true,
|
|
4658
|
+
raw,
|
|
4659
|
+
parsed: parsedRes.parsed,
|
|
4660
|
+
valid: false,
|
|
4661
|
+
config: coerceConfig(parsedRes.parsed),
|
|
4662
|
+
hash,
|
|
4663
|
+
issues: [{
|
|
4664
|
+
path: "",
|
|
4665
|
+
message
|
|
4666
|
+
}],
|
|
4667
|
+
warnings: [],
|
|
4668
|
+
legacyIssues: []
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
if (resolved && typeof resolved === "object" && "env" in resolved) applyConfigEnv(resolved, deps.env);
|
|
4672
|
+
let substituted;
|
|
4673
|
+
try {
|
|
4674
|
+
substituted = resolveConfigEnvVars(resolved, deps.env);
|
|
4675
|
+
} catch (err) {
|
|
4676
|
+
const message = err instanceof MissingEnvVarError ? err.message : `Env var substitution failed: ${String(err)}`;
|
|
4677
|
+
return {
|
|
4678
|
+
path: configPath,
|
|
4679
|
+
exists: true,
|
|
4680
|
+
raw,
|
|
4681
|
+
parsed: parsedRes.parsed,
|
|
4682
|
+
valid: false,
|
|
4683
|
+
config: coerceConfig(resolved),
|
|
4684
|
+
hash,
|
|
4685
|
+
issues: [{
|
|
4686
|
+
path: "",
|
|
4687
|
+
message
|
|
4688
|
+
}],
|
|
4689
|
+
warnings: [],
|
|
4690
|
+
legacyIssues: []
|
|
4691
|
+
};
|
|
4692
|
+
}
|
|
4693
|
+
const resolvedConfigRaw = substituted;
|
|
4694
|
+
const legacyIssues = findLegacyConfigIssues(resolvedConfigRaw);
|
|
4695
|
+
const validated = validateConfigObjectWithPlugins(resolvedConfigRaw);
|
|
4696
|
+
if (!validated.ok) return {
|
|
4697
|
+
path: configPath,
|
|
4698
|
+
exists: true,
|
|
4699
|
+
raw,
|
|
4700
|
+
parsed: parsedRes.parsed,
|
|
4701
|
+
valid: false,
|
|
4702
|
+
config: coerceConfig(resolvedConfigRaw),
|
|
4703
|
+
hash,
|
|
4704
|
+
issues: validated.issues,
|
|
4705
|
+
warnings: validated.warnings,
|
|
4706
|
+
legacyIssues
|
|
4707
|
+
};
|
|
4708
|
+
warnIfConfigFromFuture(validated.config, deps.logger);
|
|
4709
|
+
return {
|
|
4710
|
+
path: configPath,
|
|
4711
|
+
exists: true,
|
|
4712
|
+
raw,
|
|
4713
|
+
parsed: parsedRes.parsed,
|
|
4714
|
+
valid: true,
|
|
4715
|
+
config: normalizeConfigPaths(applyTalkApiKey(applyModelDefaults(applyAgentDefaults(applySessionDefaults(applyLoggingDefaults(applyMessageDefaults(validated.config))))))),
|
|
4716
|
+
hash,
|
|
4717
|
+
issues: [],
|
|
4718
|
+
warnings: validated.warnings,
|
|
4719
|
+
legacyIssues
|
|
4720
|
+
};
|
|
4721
|
+
} catch (err) {
|
|
4722
|
+
return {
|
|
4723
|
+
path: configPath,
|
|
4724
|
+
exists: true,
|
|
4725
|
+
raw: null,
|
|
4726
|
+
parsed: {},
|
|
4727
|
+
valid: false,
|
|
4728
|
+
config: {},
|
|
4729
|
+
hash: hashConfigRaw(null),
|
|
4730
|
+
issues: [{
|
|
4731
|
+
path: "",
|
|
4732
|
+
message: `read failed: ${String(err)}`
|
|
4733
|
+
}],
|
|
4734
|
+
warnings: [],
|
|
4735
|
+
legacyIssues: []
|
|
4736
|
+
};
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
async function writeConfigFile(cfg) {
|
|
4740
|
+
clearConfigCache();
|
|
4741
|
+
const validated = validateConfigObjectWithPlugins(cfg);
|
|
4742
|
+
if (!validated.ok) {
|
|
4743
|
+
const issue = validated.issues[0];
|
|
4744
|
+
const pathLabel = issue?.path ? issue.path : "<root>";
|
|
4745
|
+
throw new Error(`Config validation failed: ${pathLabel}: ${issue?.message ?? "invalid"}`);
|
|
4746
|
+
}
|
|
4747
|
+
if (validated.warnings.length > 0) {
|
|
4748
|
+
const details = validated.warnings.map((warning) => `- ${warning.path}: ${warning.message}`).join("\n");
|
|
4749
|
+
deps.logger.warn(`Config warnings:\n${details}`);
|
|
4750
|
+
}
|
|
4751
|
+
const dir = path.dirname(configPath);
|
|
4752
|
+
await deps.fs.promises.mkdir(dir, {
|
|
4753
|
+
recursive: true,
|
|
4754
|
+
mode: 448
|
|
4755
|
+
});
|
|
4756
|
+
const json = JSON.stringify(applyModelDefaults(stampConfigVersion(cfg)), null, 2).trimEnd().concat("\n");
|
|
4757
|
+
const tmp = path.join(dir, `${path.basename(configPath)}.${process.pid}.${crypto.randomUUID()}.tmp`);
|
|
4758
|
+
await deps.fs.promises.writeFile(tmp, json, {
|
|
4759
|
+
encoding: "utf-8",
|
|
4760
|
+
mode: 384
|
|
4761
|
+
});
|
|
4762
|
+
if (deps.fs.existsSync(configPath)) {
|
|
4763
|
+
await rotateConfigBackups(configPath, deps.fs.promises);
|
|
4764
|
+
await deps.fs.promises.copyFile(configPath, `${configPath}.bak`).catch(() => {});
|
|
4765
|
+
}
|
|
4766
|
+
try {
|
|
4767
|
+
await deps.fs.promises.rename(tmp, configPath);
|
|
4768
|
+
} catch (err) {
|
|
4769
|
+
const code = err.code;
|
|
4770
|
+
if (code === "EPERM" || code === "EEXIST") {
|
|
4771
|
+
await deps.fs.promises.copyFile(tmp, configPath);
|
|
4772
|
+
await deps.fs.promises.chmod(configPath, 384).catch(() => {});
|
|
4773
|
+
await deps.fs.promises.unlink(tmp).catch(() => {});
|
|
4774
|
+
return;
|
|
4775
|
+
}
|
|
4776
|
+
await deps.fs.promises.unlink(tmp).catch(() => {});
|
|
4777
|
+
throw err;
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
return {
|
|
4781
|
+
configPath,
|
|
4782
|
+
loadConfig,
|
|
4783
|
+
readConfigFileSnapshot,
|
|
4784
|
+
writeConfigFile
|
|
4785
|
+
};
|
|
4786
|
+
}
|
|
4787
|
+
const DEFAULT_CONFIG_CACHE_MS = 200;
|
|
4788
|
+
let configCache = null;
|
|
4789
|
+
function resolveConfigCacheMs(env) {
|
|
4790
|
+
const raw = env.OPENCLAW_CONFIG_CACHE_MS?.trim();
|
|
4791
|
+
if (raw === "" || raw === "0") return 0;
|
|
4792
|
+
if (!raw) return DEFAULT_CONFIG_CACHE_MS;
|
|
4793
|
+
const parsed = Number.parseInt(raw, 10);
|
|
4794
|
+
if (!Number.isFinite(parsed)) return DEFAULT_CONFIG_CACHE_MS;
|
|
4795
|
+
return Math.max(0, parsed);
|
|
4796
|
+
}
|
|
4797
|
+
function shouldUseConfigCache(env) {
|
|
4798
|
+
if (env.OPENCLAW_DISABLE_CONFIG_CACHE?.trim()) return false;
|
|
4799
|
+
return resolveConfigCacheMs(env) > 0;
|
|
4800
|
+
}
|
|
4801
|
+
function clearConfigCache() {
|
|
4802
|
+
configCache = null;
|
|
4803
|
+
}
|
|
4804
|
+
function loadConfig() {
|
|
4805
|
+
const io = createConfigIO();
|
|
4806
|
+
const configPath = io.configPath;
|
|
4807
|
+
const now = Date.now();
|
|
4808
|
+
if (shouldUseConfigCache(process.env)) {
|
|
4809
|
+
const cached = configCache;
|
|
4810
|
+
if (cached && cached.configPath === configPath && cached.expiresAt > now) return cached.config;
|
|
4811
|
+
}
|
|
4812
|
+
const config = io.loadConfig();
|
|
4813
|
+
if (shouldUseConfigCache(process.env)) {
|
|
4814
|
+
const cacheMs = resolveConfigCacheMs(process.env);
|
|
4815
|
+
if (cacheMs > 0) configCache = {
|
|
4816
|
+
configPath,
|
|
4817
|
+
expiresAt: now + cacheMs,
|
|
4818
|
+
config
|
|
4819
|
+
};
|
|
4820
|
+
}
|
|
4821
|
+
return config;
|
|
4822
|
+
}
|
|
4823
|
+
async function readConfigFileSnapshot() {
|
|
4824
|
+
return await createConfigIO().readConfigFileSnapshot();
|
|
4825
|
+
}
|
|
4826
|
+
async function writeConfigFile(cfg) {
|
|
4827
|
+
clearConfigCache();
|
|
4828
|
+
await createConfigIO().writeConfigFile(cfg);
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4831
|
+
//#endregion
|
|
4832
|
+
//#region src/config/legacy-migrate.ts
|
|
4833
|
+
function migrateLegacyConfig(raw) {
|
|
4834
|
+
const { next, changes } = applyLegacyMigrations(raw);
|
|
4835
|
+
if (!next) return {
|
|
4836
|
+
config: null,
|
|
4837
|
+
changes: []
|
|
4838
|
+
};
|
|
4839
|
+
const validated = validateConfigObjectWithPlugins(next);
|
|
4840
|
+
if (!validated.ok) {
|
|
4841
|
+
changes.push("Migration applied, but config still invalid; fix remaining issues manually.");
|
|
4842
|
+
return {
|
|
4843
|
+
config: null,
|
|
4844
|
+
changes
|
|
4845
|
+
};
|
|
4846
|
+
}
|
|
4847
|
+
return {
|
|
4848
|
+
config: validated.config,
|
|
4849
|
+
changes
|
|
4850
|
+
};
|
|
4851
|
+
}
|
|
4852
|
+
|
|
4853
|
+
//#endregion
|
|
4854
|
+
//#region src/config/config.ts
|
|
4855
|
+
var config_exports = /* @__PURE__ */ __exportAll({
|
|
4856
|
+
CONFIG_PATH: () => CONFIG_PATH,
|
|
4857
|
+
DEFAULT_GATEWAY_PORT: () => DEFAULT_GATEWAY_PORT,
|
|
4858
|
+
STATE_DIR: () => STATE_DIR,
|
|
4859
|
+
applyConfigOverrides: () => applyConfigOverrides,
|
|
4860
|
+
getConfigOverrides: () => getConfigOverrides,
|
|
4861
|
+
isNixMode: () => isNixMode,
|
|
4862
|
+
loadConfig: () => loadConfig,
|
|
4863
|
+
resetConfigOverrides: () => resetConfigOverrides,
|
|
4864
|
+
resolveCanonicalConfigPath: () => resolveCanonicalConfigPath,
|
|
4865
|
+
resolveConfigPath: () => resolveConfigPath,
|
|
4866
|
+
resolveConfigPathCandidate: () => resolveConfigPathCandidate,
|
|
4867
|
+
resolveDefaultConfigCandidates: () => resolveDefaultConfigCandidates,
|
|
4868
|
+
resolveGatewayLockDir: () => resolveGatewayLockDir,
|
|
4869
|
+
resolveGatewayPort: () => resolveGatewayPort,
|
|
4870
|
+
resolveIsNixMode: () => resolveIsNixMode,
|
|
4871
|
+
resolveLegacyStateDirs: () => resolveLegacyStateDirs,
|
|
4872
|
+
resolveNewStateDir: () => resolveNewStateDir,
|
|
4873
|
+
resolveOAuthDir: () => resolveOAuthDir,
|
|
4874
|
+
resolveOAuthPath: () => resolveOAuthPath,
|
|
4875
|
+
resolveStateDir: () => resolveStateDir,
|
|
4876
|
+
setConfigOverride: () => setConfigOverride,
|
|
4877
|
+
unsetConfigOverride: () => unsetConfigOverride
|
|
4878
|
+
});
|
|
4879
|
+
|
|
4880
|
+
//#endregion
|
|
4881
|
+
export { resolveSubagentMaxConcurrent as A, setConfigValueAtPath as C, MAX_INCLUDE_DEPTH as D, INCLUDE_KEY as E, collectConfigEnvVars as O, parseConfigPath as S, applyLegacyMigrations as T, getConfigOverrides as _, parseConfigJson5 as a, unsetConfigOverride as b, writeConfigFile as c, TELEGRAM_COMMAND_NAME_PATTERN as d, normalizeTelegramCommandName as f, validateJsonSchemaValue as g, parseDurationMs as h, loadConfig as i, VERSION as j, resolveAgentMaxConcurrent as k, validateConfigObjectWithPlugins as l, isSafeExecutableValue as m, migrateLegacyConfig as n, readConfigFileSnapshot as o, resolveTelegramCustomCommands as p, createConfigIO as r, resolveConfigSnapshotHash as s, config_exports as t, OpenClawSchema as u, resetConfigOverrides as v, unsetConfigValueAtPath as w, getConfigValueAtPath as x, setConfigOverride as y };
|