@spacebar_ai/moldclaw-core 2026.3.41 → 2026.3.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts-5qY-dKca.d.ts +103 -0
- package/dist/accounts-SqdHz2ZP.js +114 -0
- package/dist/acp-cli-E6bcNqiE.js +2093 -0
- package/dist/actions.runtime-BU_XMuLk.js +119 -0
- package/dist/actions.runtime-CY5h8lqH.js +133 -0
- package/dist/agent-scope-lZlwP1At.js +208 -0
- package/dist/agents-C4SkadR1.js +853 -0
- package/dist/agents-RfwqGCzE.js +222 -0
- package/dist/agents.config-CX9CPNfP.js +17 -0
- package/dist/agents.config-DF9Zwn9n.js +121 -0
- package/dist/allow-list-3WSjz1zl.js +81 -0
- package/dist/allowlist-DNbDjFjw.js +142 -0
- package/dist/api-BEOpJ7dR.js +117 -0
- package/dist/audit-CpJz_eu6.js +787 -0
- package/dist/audit-CpfSjvyo.js +54 -0
- package/dist/audit-channel.collect.runtime-BeGotloZ.js +605 -0
- package/dist/audit-channel.runtime-BJDZ7ETt.js +121 -0
- package/dist/audit-extra.async-C2G0mqmk.js +813 -0
- package/dist/audit-membership-runtime-B1FqJsPV.js +162 -0
- package/dist/audit.deep.runtime-DyL9O_sU.js +25 -0
- package/dist/audit.nondeep.runtime-C6jFgJfH.js +832 -0
- package/dist/audit.runtime-Dnlsn23e.js +118 -0
- package/dist/auth-Ch3Rchm4.js +101 -0
- package/dist/auth-choice-CEFSlnLT.js +122 -0
- package/dist/auth-choice-CVCef-eU.js +268 -0
- package/dist/auth-choice-Cez-pXrg.js +507 -0
- package/dist/auth-choice-options-DO78mvPe.js +123 -0
- package/dist/auth-choice-prompt-CUkC7Mmb.js +36 -0
- package/dist/auth-choice-prompt-DCuQRiVl.js +115 -0
- package/dist/auth-choice.apply-helpers-BhbNIV8X.js +66 -0
- package/dist/auth-choice.plugin-providers.runtime-4BhqvEw_.js +119 -0
- package/dist/auth-profiles-smABVXzp.js +128040 -0
- package/dist/auth-profiles.runtime-Cr-ojtTc.js +116 -0
- package/dist/banner-CojBHPWr.js +342 -0
- package/dist/bluebubbles-BnLsj2Fy.d.ts +6 -0
- package/dist/bluebubbles-CVk7M3Bl.js +64 -0
- package/dist/bot-DdyrB2z9.d.ts +478 -0
- package/dist/brave-w4Fo8WZ3.js +24 -0
- package/dist/browser-cli-DWFs3P_i.js +1494 -0
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.d.ts +1 -1
- package/dist/bundled/boot-md/handler.js +35 -35
- package/dist/bundled/bootstrap-extra-files/handler.d.ts +1 -1
- package/dist/bundled/bootstrap-extra-files/handler.js +1 -1
- package/dist/bundled/command-logger/handler.d.ts +1 -1
- package/dist/bundled/session-memory/handler.d.ts +1 -1
- package/dist/bundled/session-memory/handler.js +36 -36
- package/dist/call-Do7wTSr7.js +39 -0
- package/dist/call-gdDAt07d.js +640 -0
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/channel-B26pkce0.js +214 -0
- package/dist/channel-BJHp0AQC.js +352 -0
- package/dist/channel-BKFOv51P.js +4681 -0
- package/dist/channel-BNgpOY8v.js +538 -0
- package/dist/channel-BcQAAo2P.js +226 -0
- package/dist/channel-BvNdnhbx.js +1598 -0
- package/dist/channel-C1Rda3Jd.js +306 -0
- package/dist/channel-C87DG-F7.js +803 -0
- package/dist/channel-CIip0kvZ.js +619 -0
- package/dist/channel-CTPxoT_E2.js +316 -0
- package/dist/channel-CklaCzUG.js +562 -0
- package/dist/channel-CoJnAdLs.js +920 -0
- package/dist/channel-D3tafL1_.js +949 -0
- package/dist/channel-DFMrP2uu.js +542 -0
- package/dist/channel-DMd5cJQe.js +397 -0
- package/dist/channel-Dm34kxAJ.js +207 -0
- package/dist/channel-DmwF9udn.js +1321 -0
- package/dist/channel-account-context-Bjur9nlh.js +103 -0
- package/dist/channel-bGnST659.js +943 -0
- package/dist/channel-hIgbkTZf.js +575 -0
- package/dist/channel-m_TGrDKo.js +497 -0
- package/dist/channel-options-DoUPBMa8.js +50 -0
- package/dist/channel-plugin-ids-TZIY4hFs.js +26 -0
- package/dist/channel-summary-qD54bOBO.js +111 -0
- package/dist/channel.runtime-B0H04Dkk.js +199 -0
- package/dist/channel.runtime-BU1f3NkV.js +418 -0
- package/dist/channel.runtime-Bj1sfLep.js +4011 -0
- package/dist/channel.runtime-BtPAAJc3.js +870 -0
- package/dist/channel.runtime-Bx-10m_j.js +171 -0
- package/dist/channel.runtime-CI_TBywQ.js +179 -0
- package/dist/channel.runtime-CSLj14-Z.js +182 -0
- package/dist/channel.runtime-D-lTSYAd.js +404 -0
- package/dist/channel.runtime-DJqIOSji.js +127 -0
- package/dist/channel.runtime-Ec8aQ9V2.js +241 -0
- package/dist/channel.runtime-ax5a1jBm.js +218 -0
- package/dist/channel.setup-B-ncdYLT.js +9 -0
- package/dist/channel.setup-BY4bh5dm.js +9 -0
- package/dist/channel.setup-BovsdMnL.js +57 -0
- package/dist/channel.setup-CXzXA25h.js +6 -0
- package/dist/channel.setup-DcZUEufN.js +8 -0
- package/dist/channel.setup-E6zceRsE.js +8 -0
- package/dist/channel.setup-Pc7nGbdX.js +11 -0
- package/dist/channels/plugins/actions/discord.d.ts +2 -2
- package/dist/channels/plugins/actions/discord.js +35 -35
- package/dist/channels/plugins/actions/signal.d.ts +1 -1
- package/dist/channels/plugins/actions/signal.js +35 -35
- package/dist/channels/plugins/actions/telegram.d.ts +2 -2
- package/dist/channels/plugins/actions/telegram.js +35 -35
- package/dist/channels/plugins/agent-tools/whatsapp-login.d.ts +3 -3
- package/dist/channels/plugins/agent-tools/whatsapp-login.js +35 -35
- package/dist/channels-CPtE5ND6.js +404 -0
- package/dist/channels-Cj8ZolHI.js +1118 -0
- package/dist/channels-cli-D2sKrntt.js +291 -0
- package/dist/channels-status-issues-CzIHODg2.js +16 -0
- package/dist/clawbot-cli-BcwEDmUn.js +118 -0
- package/dist/cleanup-utils-D0L17RsX.js +96 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli-BvGVPKnD.js +154 -0
- package/dist/command-registry-CADQzTAg.js +14 -0
- package/dist/command-registry-ktiJNAJd.js +242 -0
- package/dist/command-secret-gateway-CXp10RTM.js +111 -0
- package/dist/compact.runtime-DyKL-Iar.js +116 -0
- package/dist/completion-cli-Bz4STrpt.js +17 -0
- package/dist/completion-cli-pVda2OFb.js +445 -0
- package/dist/config-BbvDRSYp.js +31 -0
- package/dist/config-CwBv71QC.js +44 -0
- package/dist/config-cli-Y0uXHbOw.js +678 -0
- package/dist/config-guard-BpW5g7JE.js +118 -0
- package/dist/config-validation-B-vLIsbo.js +262 -0
- package/dist/config-value-DT3-5958.js +132 -0
- package/dist/configure-B9U-jCqP.js +1100 -0
- package/dist/configure-BJ3Wrs5b.js +243 -0
- package/dist/control-ui-assets-C1YDYi82.js +232 -0
- package/dist/control-ui-shared-Dm5Dh0Lo.js +29 -0
- package/dist/core-BwKq3krw.js +150 -0
- package/dist/core-hjBwfDsW.d.ts +87 -0
- package/dist/cron-cli-DTDgfoMh.js +639 -0
- package/dist/daemon-cli-C-dkAXR1.js +339 -0
- package/dist/daemon-install-Oy0Q5pMF.js +180 -0
- package/dist/deliver-DNGnDqF9.js +111 -0
- package/dist/deliver-runtime-CCNZIhET.js +111 -0
- package/dist/device-id-cli-XvwZbIyC.js +52 -0
- package/dist/device-identity-IG5DngWM.js +365 -0
- package/dist/devices-cli-DIsxj4xp.js +342 -0
- package/dist/diagnostic-DTPopFvh.js +310 -0
- package/dist/directory-cli-DTSY3Ktr.js +311 -0
- package/dist/directory-config-helpers-DpFcAbmo.d.ts +38 -0
- package/dist/directory.static-CBRAUwUW.js +44 -0
- package/dist/discord-CrgxhEWw.js +114 -0
- package/dist/discovery-DrG7wmAR.js +48 -0
- package/dist/dm-policy-shared-DKoGdUpY.d.ts +95 -0
- package/dist/dns-cli-BJiz6CLK.js +217 -0
- package/dist/docs-cli-Dq2Yi5qO.js +174 -0
- package/dist/doctor-completion-D3GeVcFP.js +90 -0
- package/dist/doctor-config-flow-B1cMjr8h.js +112 -0
- package/dist/doctor-config-flow-BUe7JpV3.js +2437 -0
- package/dist/enable-Bc8bCuVe.js +24 -0
- package/dist/entry.js +4 -4
- package/dist/exec-approvals-cli-kLAev6bP.js +421 -0
- package/dist/extensions/acpx/index.d.ts +1 -1
- package/dist/extensions/amazon-bedrock/index.d.ts +1 -1
- package/dist/extensions/amazon-bedrock/index.js +4 -4
- package/dist/extensions/anthropic/index.d.ts +1 -1
- package/dist/extensions/anthropic/index.js +35 -35
- package/dist/extensions/bluebubbles/index.d.ts +1 -1
- package/dist/extensions/bluebubbles/index.js +39 -39
- package/dist/extensions/bluebubbles/setup-entry.d.ts +2 -2
- package/dist/extensions/bluebubbles/setup-entry.js +39 -39
- package/dist/extensions/brave/index.d.ts +1 -1
- package/dist/extensions/brave/index.js +5 -5
- package/dist/extensions/byteplus/index.d.ts +1 -1
- package/dist/extensions/byteplus/index.js +35 -35
- package/dist/extensions/cloudflare-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/cloudflare-ai-gateway/index.js +36 -36
- package/dist/extensions/copilot-proxy/index.d.ts +1 -1
- package/dist/extensions/copilot-proxy/index.js +4 -4
- package/dist/extensions/device-pair/index.d.ts +1 -1
- package/dist/extensions/device-pair/index.js +4 -4
- package/dist/extensions/diagnostics-otel/index.d.ts +1 -1
- package/dist/extensions/diagnostics-otel/index.js +4 -4
- package/dist/extensions/diffs/index.d.ts +1 -1
- package/dist/extensions/discord/index.d.ts +1 -1
- package/dist/extensions/discord/index.js +40 -40
- package/dist/extensions/discord/setup-entry.d.ts +1 -1
- package/dist/extensions/discord/setup-entry.js +38 -38
- package/dist/extensions/elevenlabs/index.d.ts +1 -1
- package/dist/extensions/elevenlabs/index.js +35 -35
- package/dist/extensions/feishu/index.d.ts +2 -2
- package/dist/extensions/feishu/index.js +40 -40
- package/dist/extensions/feishu/setup-entry.d.ts +2 -2
- package/dist/extensions/feishu/setup-entry.js +37 -37
- package/dist/extensions/firecrawl/index.d.ts +1 -1
- package/dist/extensions/firecrawl/index.js +35 -35
- package/dist/extensions/github-copilot/index.d.ts +1 -1
- package/dist/extensions/github-copilot/index.js +35 -35
- package/dist/extensions/google/index.d.ts +1 -1
- package/dist/extensions/google/index.js +35 -35
- package/dist/extensions/googlechat/index.d.ts +1 -1
- package/dist/extensions/googlechat/index.js +38 -38
- package/dist/extensions/googlechat/setup-entry.d.ts +1 -1
- package/dist/extensions/googlechat/setup-entry.js +38 -38
- package/dist/extensions/huggingface/index.d.ts +1 -1
- package/dist/extensions/huggingface/index.js +35 -35
- package/dist/extensions/imessage/index.d.ts +1 -1
- package/dist/extensions/imessage/index.js +39 -39
- package/dist/extensions/imessage/setup-entry.d.ts +1 -1
- package/dist/extensions/imessage/setup-entry.js +39 -39
- package/dist/extensions/irc/index.d.ts +1 -1
- package/dist/extensions/irc/index.js +38 -38
- package/dist/extensions/irc/setup-entry.d.ts +2 -2
- package/dist/extensions/irc/setup-entry.js +38 -38
- package/dist/extensions/kakao-talkchannel/index.d.ts +1 -1
- package/dist/extensions/kakao-talkchannel/index.js +4 -4
- package/dist/extensions/kilocode/index.d.ts +1 -1
- package/dist/extensions/kilocode/index.js +35 -35
- package/dist/extensions/kimi-coding/index.d.ts +1 -1
- package/dist/extensions/kimi-coding/index.js +35 -35
- package/dist/extensions/line/index.d.ts +1 -1
- package/dist/extensions/line/index.js +37 -37
- package/dist/extensions/line/setup-entry.d.ts +1 -1
- package/dist/extensions/line/setup-entry.js +37 -37
- package/dist/extensions/llm-task/index.d.ts +1 -1
- package/dist/extensions/llm-task/index.js +35 -35
- package/dist/extensions/lobster/index.d.ts +1 -1
- package/dist/extensions/lobster/index.js +4 -4
- package/dist/extensions/matrix/index.d.ts +1 -1
- package/dist/extensions/matrix/index.js +40 -40
- package/dist/extensions/matrix/setup-entry.d.ts +2 -2
- package/dist/extensions/matrix/setup-entry.js +40 -40
- package/dist/extensions/mattermost/index.d.ts +1 -1
- package/dist/extensions/mattermost/index.js +37 -37
- package/dist/extensions/mattermost/setup-entry.d.ts +2 -2
- package/dist/extensions/mattermost/setup-entry.js +37 -37
- package/dist/extensions/memory-core/index.d.ts +1 -1
- package/dist/extensions/memory-core/index.js +4 -4
- package/dist/extensions/memory-lancedb/index.d.ts +1 -1
- package/dist/extensions/memory-lancedb/index.js +4 -4
- package/dist/extensions/microsoft/index.d.ts +1 -1
- package/dist/extensions/microsoft/index.js +35 -35
- package/dist/extensions/minimax/index.d.ts +1 -1
- package/dist/extensions/minimax/index.js +35 -35
- package/dist/extensions/mistral/index.d.ts +1 -1
- package/dist/extensions/mistral/index.js +35 -35
- package/dist/extensions/modelstudio/index.d.ts +1 -1
- package/dist/extensions/modelstudio/index.js +35 -35
- package/dist/extensions/moonshot/index.d.ts +1 -1
- package/dist/extensions/moonshot/index.js +35 -35
- package/dist/extensions/msteams/index.d.ts +1 -1
- package/dist/extensions/msteams/index.js +40 -40
- package/dist/extensions/msteams/setup-entry.d.ts +1 -1
- package/dist/extensions/msteams/setup-entry.js +40 -40
- package/dist/extensions/nextcloud-talk/index.d.ts +1 -1
- package/dist/extensions/nextcloud-talk/index.js +37 -37
- package/dist/extensions/nextcloud-talk/setup-entry.d.ts +2 -2
- package/dist/extensions/nextcloud-talk/setup-entry.js +37 -37
- package/dist/extensions/nostr/index.d.ts +1 -1
- package/dist/extensions/nostr/index.js +37 -37
- package/dist/extensions/nostr/setup-entry.d.ts +1 -1
- package/dist/extensions/nostr/setup-entry.js +37 -37
- package/dist/extensions/nvidia/index.d.ts +1 -1
- package/dist/extensions/nvidia/index.js +4 -4
- package/dist/extensions/ollama/index.d.ts +1 -1
- package/dist/extensions/ollama/index.js +7 -7
- package/dist/extensions/open-prose/index.d.ts +1 -1
- package/dist/extensions/open-prose/index.js +4 -4
- package/dist/extensions/openai/index.d.ts +1 -1
- package/dist/extensions/openai/index.js +35 -35
- package/dist/extensions/opencode/index.d.ts +1 -1
- package/dist/extensions/opencode/index.js +35 -35
- package/dist/extensions/opencode-go/index.d.ts +1 -1
- package/dist/extensions/opencode-go/index.js +35 -35
- package/dist/extensions/openrouter/index.d.ts +1 -1
- package/dist/extensions/openrouter/index.js +35 -35
- package/dist/extensions/openshell/index.d.ts +1 -1
- package/dist/extensions/openshell/index.js +35 -35
- package/dist/extensions/perplexity/index.d.ts +1 -1
- package/dist/extensions/perplexity/index.js +5 -5
- package/dist/extensions/phone-control/index.d.ts +1 -1
- package/dist/extensions/phone-control/index.js +4 -4
- package/dist/extensions/qianfan/index.d.ts +1 -1
- package/dist/extensions/qianfan/index.js +35 -35
- package/dist/extensions/qwen-portal-auth/index.d.ts +1 -1
- package/dist/extensions/qwen-portal-auth/index.js +35 -35
- package/dist/extensions/sglang/index.d.ts +1 -1
- package/dist/extensions/sglang/index.js +35 -35
- package/dist/extensions/signal/index.d.ts +1 -1
- package/dist/extensions/signal/index.js +38 -38
- package/dist/extensions/signal/setup-entry.d.ts +1 -1
- package/dist/extensions/signal/setup-entry.js +38 -38
- package/dist/extensions/slack/index.d.ts +1 -1
- package/dist/extensions/slack/index.js +39 -39
- package/dist/extensions/slack/setup-entry.d.ts +1 -1
- package/dist/extensions/slack/setup-entry.js +38 -38
- package/dist/extensions/synology-chat/index.d.ts +1 -1
- package/dist/extensions/synology-chat/index.js +37 -37
- package/dist/extensions/synology-chat/setup-entry.d.ts +1 -1
- package/dist/extensions/synology-chat/setup-entry.js +37 -37
- package/dist/extensions/synthetic/index.d.ts +1 -1
- package/dist/extensions/synthetic/index.js +35 -35
- package/dist/extensions/talk-voice/index.d.ts +1 -1
- package/dist/extensions/talk-voice/index.js +35 -35
- package/dist/extensions/telegram/index.d.ts +1 -1
- package/dist/extensions/telegram/index.js +38 -38
- package/dist/extensions/telegram/setup-entry.d.ts +1 -1
- package/dist/extensions/telegram/setup-entry.js +37 -37
- package/dist/extensions/thread-ownership/index.d.ts +1 -1
- package/dist/extensions/thread-ownership/index.js +4 -4
- package/dist/extensions/tlon/index.d.ts +1 -1
- package/dist/extensions/tlon/index.js +37 -37
- package/dist/extensions/tlon/setup-entry.d.ts +1 -1
- package/dist/extensions/tlon/setup-entry.js +37 -37
- package/dist/extensions/together/index.d.ts +1 -1
- package/dist/extensions/together/index.js +35 -35
- package/dist/extensions/twitch/index.d.ts +2 -2
- package/dist/extensions/twitch/index.js +37 -37
- package/dist/extensions/venice/index.d.ts +1 -1
- package/dist/extensions/venice/index.js +35 -35
- package/dist/extensions/vercel-ai-gateway/index.d.ts +1 -1
- package/dist/extensions/vercel-ai-gateway/index.js +36 -36
- package/dist/extensions/vllm/index.d.ts +1 -1
- package/dist/extensions/vllm/index.js +35 -35
- package/dist/extensions/voice-call/index.d.ts +1 -1
- package/dist/extensions/voice-call/index.js +35 -35
- package/dist/extensions/volcengine/index.d.ts +1 -1
- package/dist/extensions/volcengine/index.js +35 -35
- package/dist/extensions/whatsapp/index.d.ts +1 -1
- package/dist/extensions/whatsapp/index.js +38 -38
- package/dist/extensions/whatsapp/setup-entry.d.ts +1 -1
- package/dist/extensions/whatsapp/setup-entry.js +38 -38
- package/dist/extensions/xai/index.d.ts +1 -1
- package/dist/extensions/xai/index.js +35 -35
- package/dist/extensions/xiaomi/index.d.ts +1 -1
- package/dist/extensions/xiaomi/index.js +35 -35
- package/dist/extensions/zai/index.d.ts +1 -1
- package/dist/extensions/zai/index.js +35 -35
- package/dist/extensions/zalo/index.d.ts +1 -1
- package/dist/extensions/zalo/index.js +39 -39
- package/dist/extensions/zalo/setup-entry.d.ts +1 -1
- package/dist/extensions/zalo/setup-entry.js +39 -39
- package/dist/extensions/zalouser/index.d.ts +1 -1
- package/dist/extensions/zalouser/index.js +40 -40
- package/dist/extensions/zalouser/setup-entry.d.ts +1 -1
- package/dist/extensions/zalouser/setup-entry.js +40 -40
- package/dist/feishu-fIcnHDTd.d.ts +36 -0
- package/dist/gateway-cli-0c-8h93_.js +26437 -0
- package/dist/gateway-install-token-1PwJvrBY.js +163 -0
- package/dist/gateway-rpc-C0Vk51W7.js +26 -0
- package/dist/gateway-runtime-CBm3CCoA.js +69 -0
- package/dist/git-commit-BTWXFY41.js +177 -0
- package/dist/git-commit-D6GTN5Yt.js +2 -0
- package/dist/googlechat-BQr4xgoZ.js +307 -0
- package/dist/googlechat-BvwsCVKl.d.ts +12 -0
- package/dist/group-access-DpiQnd-G.d.ts +61 -0
- package/dist/health-6yZQGADY.js +113 -0
- package/dist/health-C9DYGyRe.js +570 -0
- package/dist/heartbeat-summary-Dct2lqJj.js +57 -0
- package/dist/help-CtwSApfq.js +81 -0
- package/dist/hooks-9gokOxZ5.d.ts +6 -0
- package/dist/hooks-cli-BegKzHZT.js +1000 -0
- package/dist/hooks-status-Bm_pGORf.js +78 -0
- package/dist/http-registry-D-S6a1Na.d.ts +20 -0
- package/dist/identity-file-Diub2a0t.js +60 -0
- package/dist/image-generation-CbIVzmAR.d.ts +9 -0
- package/dist/imessage-Bgok9kfl.js +31 -0
- package/dist/imessage-VIHePprL.js +115 -0
- package/dist/inbound-reply-dispatch-B53GAGWq.js +71 -0
- package/dist/inbound-reply-dispatch-n7U3qg15.d.ts +72 -0
- package/dist/index.js +2 -2
- package/dist/install-target-oz1pjfHH.js +574 -0
- package/dist/installs-CUFm5V8a.js +532 -0
- package/dist/io-BaBxjB1v.js +9739 -0
- package/dist/io-CgHb1Jld.js +29 -0
- package/dist/irc-CaRKzGvW.js +672 -0
- package/dist/library-C5SNBCMb.js +112 -0
- package/dist/lifecycle-core-Dn8PK6nk.js +382 -0
- package/dist/line/accounts.d.ts +2 -2
- package/dist/line/send.d.ts +1 -1
- package/dist/line/send.js +7 -7
- package/dist/line/template-messages.d.ts +1 -1
- package/dist/line-B5QFpgN_.d.ts +75 -0
- package/dist/line-fePrrQOD.js +530 -0
- package/dist/llm-slug-generator-hKae3XDA.js +67 -0
- package/dist/llm-slug-generator.d.ts +1 -1
- package/dist/llm-slug-generator.js +36 -36
- package/dist/logging-CdisccbY.js +13 -0
- package/dist/logging-LKQSgX1d.js +30 -0
- package/dist/login-qr-C1YWh4nE.js +233 -0
- package/dist/login-qr-WFluMDMb.js +112 -0
- package/dist/logs-cli-CNzOvZ2d.js +256 -0
- package/dist/manager-runtime-DgMhLTkR.js +111 -0
- package/dist/manager.runtime-hUWgpPt2.js +715 -0
- package/dist/manifest-registry-CS_p1OBQ.js +1329 -0
- package/dist/matrix-43_RGLZN.d.ts +68 -0
- package/dist/matrix-CCFxHfxa.js +1269 -0
- package/dist/matrix-DWs_qIkJ.js +1495 -0
- package/dist/mcp-cli-Ci2jvv3s.js +87 -0
- package/dist/media-understanding.runtime-Cdr6iTW6.js +116 -0
- package/dist/memory-cli-LZbyF0Iu.js +111 -0
- package/dist/memory-search-BHhETk6u.js +17 -0
- package/dist/memory-search-tTD5o_rU.js +204 -0
- package/dist/method-scopes-B2ZKSsxQ.js +2452 -0
- package/dist/model-auth-markers-LqZ4qhrZ.d.ts +20 -0
- package/dist/model-picker-CTR5mo4v.js +112 -0
- package/dist/model-picker-DG4z_dBs.js +390 -0
- package/dist/model-picker.runtime-DMQ9Pj9_.js +125 -0
- package/dist/model-selection-bBBxfXdb.js +653 -0
- package/dist/model-suppression.runtime-BVG75tZ7.js +116 -0
- package/dist/models-BjkVLfgw.js +2514 -0
- package/dist/models-ZO01Q4cx.js +118 -0
- package/dist/models-cli-DemdF-bm.js +309 -0
- package/dist/models-config-B2Jja8ua.js +111 -0
- package/dist/models-config.providers.discovery-puxTsH39.d.ts +18 -0
- package/dist/moldclaw-root-Cb6HRlUO.js +92 -0
- package/dist/monitor-BP4idxJD.js +782 -0
- package/dist/monitor-B_eP8Eim.js +772 -0
- package/dist/monitor-CRHYNl5J.js +3468 -0
- package/dist/monitor-Ci1Xg4g3.js +113 -0
- package/dist/monitor-DEodDl3z.js +6823 -0
- package/dist/monitor-DJlNKuMz.js +115 -0
- package/dist/monitor-DvFwDS9w.js +3076 -0
- package/dist/monitor-shared--cEjSf8s.js +444 -0
- package/dist/msteams-CV2a8uE8.js +852 -0
- package/dist/node-cli-Of2g7DSd.js +2503 -0
- package/dist/node-resolve-BYC2FbO2.js +835 -0
- package/dist/nodes-cli-CPHM6Upj.js +1380 -0
- package/dist/nostr-BFKRoOlz.d.ts +7 -0
- package/dist/nostr-lHpcBzz4.js +8744 -0
- package/dist/npm-resolution-kqHN85wB.js +60 -0
- package/dist/oauth-env-CLG8KOrz.js +10 -0
- package/dist/onboard-BON0C360.js +48 -0
- package/dist/onboard-CRkIBgOI.js +589 -0
- package/dist/onboard-DsKI17iq.js +25 -0
- package/dist/onboard-channels-BY3IbBBf.js +1241 -0
- package/dist/onboard-channels-CLKdRxvW.js +205 -0
- package/dist/onboard-custom-BjPrMo_R.js +571 -0
- package/dist/onboard-custom-DqcPiZBN.js +114 -0
- package/dist/onboard-helpers-BkrOY5OE.js +113 -0
- package/dist/onboard-helpers-DiSRTpZC.js +335 -0
- package/dist/onboard-hooks-pzEPZAvl.js +72 -0
- package/dist/onboard-remote-ChyLC6Dk.js +181 -0
- package/dist/onboard-remote-DHmK9ntl.js +117 -0
- package/dist/onboard-search-BgA3jEMW.js +302 -0
- package/dist/onboard-skills-BMo_NvnW.js +133 -0
- package/dist/onboard-skills-Bba-Z2p8.js +117 -0
- package/dist/outbound-media-BHD4aJEX.d.ts +11 -0
- package/dist/outbound-media-DSno0N82.js +11 -0
- package/dist/pairing-access-CzHpaM0R.d.ts +21 -0
- package/dist/pairing-cli-CmklqK0q.js +217 -0
- package/dist/perplexity-CXwMDD3u.js +24 -0
- package/dist/persistent-dedupe-B9vrAf8t.d.ts +26 -0
- package/dist/pi-model-discovery-runtime-BrK7tcaO.js +111 -0
- package/dist/pi-tools.before-tool-call.runtime-C5yLUogH.js +381 -0
- package/dist/plugin-install-C4AWJIFP.js +117 -0
- package/dist/plugin-install-CB3J1hfV.js +184 -0
- package/dist/plugin-install-plan-7itZiegi.js +49 -0
- package/dist/plugin-registry-DX_GFoiz.js +113 -0
- package/dist/plugin-registry-e3cxTtvb.js +49 -0
- package/dist/plugin-sdk/account-resolution.js +35 -35
- package/dist/plugin-sdk/acp-runtime.js +35 -35
- package/dist/plugin-sdk/agent-runtime.js +35 -35
- package/dist/plugin-sdk/bluebubbles.js +37 -37
- package/dist/plugin-sdk/channel-config-helpers.js +35 -35
- package/dist/plugin-sdk/channel-policy.js +35 -35
- package/dist/plugin-sdk/channel-runtime.js +35 -35
- package/dist/plugin-sdk/compat.js +36 -36
- package/dist/plugin-sdk/config-runtime.js +35 -35
- package/dist/plugin-sdk/conversation-runtime.js +35 -35
- package/dist/plugin-sdk/copilot-proxy.js +4 -4
- package/dist/plugin-sdk/core.js +4 -4
- package/dist/plugin-sdk/device-pair.js +4 -4
- package/dist/plugin-sdk/discord.js +35 -35
- package/dist/plugin-sdk/feishu.js +35 -35
- package/dist/plugin-sdk/gateway-runtime.js +10 -10
- package/dist/plugin-sdk/googlechat.js +37 -37
- package/dist/plugin-sdk/image-generation-runtime.js +35 -35
- package/dist/plugin-sdk/image-generation.js +35 -35
- package/dist/plugin-sdk/imessage.js +36 -36
- package/dist/plugin-sdk/index.js +35 -35
- package/dist/plugin-sdk/infra-runtime.js +35 -35
- package/dist/plugin-sdk/irc.js +37 -37
- package/dist/plugin-sdk/line.js +36 -36
- package/dist/plugin-sdk/llm-task.js +35 -35
- package/dist/plugin-sdk/lobster.js +4 -4
- package/dist/plugin-sdk/matrix.js +37 -37
- package/dist/plugin-sdk/mattermost.js +36 -36
- package/dist/plugin-sdk/media-runtime.js +35 -35
- package/dist/plugin-sdk/media-understanding-runtime.js +35 -35
- package/dist/plugin-sdk/media-understanding.js +35 -35
- package/dist/plugin-sdk/memory-lancedb.js +4 -4
- package/dist/plugin-sdk/minimax-portal-auth.js +4 -4
- package/dist/plugin-sdk/msteams.js +38 -38
- package/dist/plugin-sdk/nextcloud-talk.js +36 -36
- package/dist/plugin-sdk/nostr.js +36 -36
- package/dist/plugin-sdk/ollama-setup.js +9 -9
- package/dist/plugin-sdk/open-prose.js +4 -4
- package/dist/plugin-sdk/phone-control.js +4 -4
- package/dist/plugin-sdk/plugin-runtime.js +35 -35
- package/dist/plugin-sdk/provider-auth.js +35 -35
- package/dist/plugin-sdk/provider-models.js +5 -5
- package/dist/plugin-sdk/provider-onboard.js +4 -4
- package/dist/plugin-sdk/provider-setup.js +39 -39
- package/dist/plugin-sdk/provider-stream.js +4 -4
- package/dist/plugin-sdk/provider-usage.js +4 -4
- package/dist/plugin-sdk/qwen-portal-auth.js +35 -35
- package/dist/plugin-sdk/reply-history.js +35 -35
- package/dist/plugin-sdk/reply-runtime.js +35 -35
- package/dist/plugin-sdk/routing.js +3 -3
- package/dist/plugin-sdk/sandbox.js +35 -35
- package/dist/plugin-sdk/security-runtime.js +35 -35
- package/dist/plugin-sdk/self-hosted-provider-setup.js +37 -37
- package/dist/plugin-sdk/setup.js +35 -35
- package/dist/plugin-sdk/signal.js +35 -35
- package/dist/plugin-sdk/slack.js +35 -35
- package/dist/plugin-sdk/speech-runtime.js +35 -35
- package/dist/plugin-sdk/speech.js +35 -35
- package/dist/plugin-sdk/src/secrets/secure-file-store.d.ts +26 -0
- package/dist/plugin-sdk/src/subscription/provider.d.ts +5 -3
- package/dist/plugin-sdk/synology-chat.js +36 -36
- package/dist/plugin-sdk/talk-voice.js +4 -4
- package/dist/plugin-sdk/telegram.js +35 -35
- package/dist/plugin-sdk/text-runtime.js +7 -7
- package/dist/plugin-sdk/thread-ownership.js +4 -4
- package/dist/plugin-sdk/tlon.js +36 -36
- package/dist/plugin-sdk/twitch.js +35 -35
- package/dist/plugin-sdk/voice-call.js +35 -35
- package/dist/plugin-sdk/whatsapp.js +35 -35
- package/dist/plugin-sdk/zalo.js +38 -38
- package/dist/plugin-sdk/zalouser.js +38 -38
- package/dist/plugins/runtime/index.d.ts +1 -1
- package/dist/plugins/runtime/index.js +35 -35
- package/dist/plugins-DF5FaTO0.js +111 -0
- package/dist/plugins-cli-CvTJemqC.js +917 -0
- package/dist/policy-CNXISK_a.js +143 -0
- package/dist/preflight-audio.runtime-RP000oxo.js +116 -0
- package/dist/probe-BkM5pykD.js +21 -0
- package/dist/probe-DKbRTJv5.js +1793 -0
- package/dist/probe-DkrfRsjU.js +47 -0
- package/dist/probe-DpcJ0WeP.js +129 -0
- package/dist/probe-auth-BcNjX8hy.js +40 -0
- package/dist/probe-auth-DhuAb8ls.js +48 -0
- package/dist/probe-wciBj-aL.js +6329 -0
- package/dist/program-C8-p0mW5.js +253 -0
- package/dist/prompt-select-styled-DH0pVoc0.js +2673 -0
- package/dist/provider-api-key-auth.runtime-CAFeIQ1u.js +121 -0
- package/dist/provider-auth-choice-CB_HzdTl.js +126 -0
- package/dist/provider-auth-choice-helpers-hzDkh3f1.js +48 -0
- package/dist/provider-auth-choice-preference-BHCXvNSE.js +189 -0
- package/dist/provider-auth-choice.runtime-Dx4ms2C5.js +123 -0
- package/dist/provider-auth-choices-0KaDNPBQ.js +57 -0
- package/dist/provider-auth-guidance-BaAUiNr_.js +34 -0
- package/dist/provider-auth-result-Bto1bYtS.d.ts +18 -0
- package/dist/provider-models-DxOmeToO.d.ts +867 -0
- package/dist/provider-models-xnyxy6mO.js +2113 -0
- package/dist/provider-ollama-setup-DBYK__ov.d.ts +32 -0
- package/dist/provider-ollama-setup-QzgCxj44.js +314 -0
- package/dist/provider-onboard-B9ionepI.js +139 -0
- package/dist/provider-onboard-CURxJ_UX.d.ts +40 -0
- package/dist/provider-runtime.runtime-4xwmsl5L.js +111 -0
- package/dist/provider-self-hosted-setup-BHd24EDG.js +182 -0
- package/dist/provider-self-hosted-setup-qeY8BYSy.d.ts +61 -0
- package/dist/provider-stream-Chz_EFw3.js +512 -0
- package/dist/provider-usage-C11Q7UwS.js +111 -0
- package/dist/provider-usage-kxemdMp2.js +633 -0
- package/dist/provider-wizard-CanJoxNC.js +152 -0
- package/dist/push-apns-Dsajnm8C.js +1038 -0
- package/dist/pw-ai-DUe4BbH2.js +1867 -0
- package/dist/qmd-manager-CAAFp7qK.js +1570 -0
- package/dist/qr-cli-Bu2jqTPY.js +113 -0
- package/dist/qr-cli-Bu9Z-X48.js +369 -0
- package/dist/reactions-Cpfum4iU.js +281 -0
- package/dist/read-only-account-inspect.discord.runtime-BK0LaMgC.js +116 -0
- package/dist/read-only-account-inspect.slack.runtime-DgKiC5wT.js +116 -0
- package/dist/read-only-account-inspect.telegram.runtime-mxfgFVOU.js +116 -0
- package/dist/redact-snapshot-DD8A4tdd.js +2663 -0
- package/dist/register.agent-DU4FtrU2.js +439 -0
- package/dist/register.backup-8nOYtJqg.js +625 -0
- package/dist/register.configure-DmtecqIH.js +252 -0
- package/dist/register.maintenance-Dir3ulKP.js +574 -0
- package/dist/register.message-Cfl-f3Ju.js +709 -0
- package/dist/register.onboard-Bv7WVzEi.js +192 -0
- package/dist/register.setup-BIyeI8RY.js +212 -0
- package/dist/register.status-health-sessions-C69WQcF4.js +498 -0
- package/dist/register.subclis-B_4KCgTd.js +315 -0
- package/dist/register.subclis-BeXsmgBL.js +13 -0
- package/dist/replies-DdcFUmki.js +110 -0
- package/dist/resolve-channels-DRZqPV5o.js +226 -0
- package/dist/resolve-channels-DxW1kqxA.js +262 -0
- package/dist/resolve-route-DdX-HBVt.js +538 -0
- package/dist/resolve-users-rgCQvkLs.js +143 -0
- package/dist/root-help-QAkoA7GD.js +32 -0
- package/dist/routes-CcJNnwTF.js +7097 -0
- package/dist/rpc-DDUAlBbH.js +67 -0
- package/dist/run-main-D9ci5pn7.js +424 -0
- package/dist/runtime-Bitmi8Er.d.ts +26 -0
- package/dist/runtime-discord-ops.runtime-T4sf7aRB.js +9078 -0
- package/dist/runtime-slack-ops.runtime-BQpP48mC.js +4556 -0
- package/dist/runtime-telegram-ops.runtime-cVO5dqOp.js +133 -0
- package/dist/runtime-whatsapp-login.runtime-DtNx0dSY.js +114 -0
- package/dist/runtime-whatsapp-outbound.runtime-Bw47QbFK.js +117 -0
- package/dist/sandbox-cli-DsFwjbjC.js +535 -0
- package/dist/search-manager-BRAK8fEe.js +16 -0
- package/dist/search-manager-BS5Db0A6.js +386 -0
- package/dist/secrets-cli-D3J46TJp.js +2070 -0
- package/dist/security-cli-B866M9cB.js +575 -0
- package/dist/send-B1pX9_Oc.js +283 -0
- package/dist/send-B2RrLg83.js +100 -0
- package/dist/send-DFnV__Aq.js +1025 -0
- package/dist/send-DZIH6CJt.js +629 -0
- package/dist/send-sl9WnKbW.js +631 -0
- package/dist/server-node-events-BT6egg20.js +506 -0
- package/dist/server-zI_K-D05.js +107 -0
- package/dist/sessions-C8kiAcoJ.js +112 -0
- package/dist/sessions-DLBpp52_.js +218 -0
- package/dist/setup-C7eOzMiC.js +387 -0
- package/dist/setup-CFIMq-Pz.d.ts +37 -0
- package/dist/setup-binary-CcAv8NXz.js +406 -0
- package/dist/setup-browser-C4eRV3h6.js +70 -0
- package/dist/setup-core-BnR486P-.js +143 -0
- package/dist/setup-core-CIswIiu5.js +166 -0
- package/dist/setup-core-CcbcrXXg.js +47 -0
- package/dist/setup-core-nZSw5BSv.js +205 -0
- package/dist/setup-surface-C5iSpT4M.js +490 -0
- package/dist/setup-wizard-helpers-r0J6l8ST.d.ts +203 -0
- package/dist/setup.finalize-adiRfo0U.js +522 -0
- package/dist/setup.gateway-config-BwFWKDfT.js +343 -0
- package/dist/shared-12TimyeF.js +182 -0
- package/dist/shared-9EWO34-k.js +298 -0
- package/dist/shared-B4vUbaRR.js +75 -0
- package/dist/shared-bNWpW3Dd.js +96 -0
- package/dist/shared-lU1y5dvS.js +102 -0
- package/dist/signal-DBlETRu9.js +114 -0
- package/dist/skills-Bio8GwTE.js +20 -0
- package/dist/skills-DE_MXFSN.js +853 -0
- package/dist/skills-cli-BGuW-tKw.js +292 -0
- package/dist/skills-install--rnorIoJ.js +763 -0
- package/dist/skills-status-B08PtBc_.js +21 -0
- package/dist/skills-status-CzM008aB.js +169 -0
- package/dist/slack-C4T53Nc-.js +114 -0
- package/dist/slash-commands.runtime-B7fsD8Be.js +128 -0
- package/dist/slash-dispatch.runtime-t0PAX4vQ.js +141 -0
- package/dist/slash-skill-commands.runtime-DIhPnEfR.js +116 -0
- package/dist/src-DrDirlvw.js +1701 -0
- package/dist/status-Bld14WSA.js +131 -0
- package/dist/status-CgeO4RuH.js +43 -0
- package/dist/status-HlvixAOq.js +606 -0
- package/dist/status-Rom_Lf3c.js +1599 -0
- package/dist/status-TwbMH6Am.js +126 -0
- package/dist/status-json-DMW7cmuK.js +288 -0
- package/dist/status.link-channel-V4LkB6Gq.js +143 -0
- package/dist/status.scan.deps.runtime-BE3X-dcP.js +126 -0
- package/dist/status.scan.runtime-BxVY4mty.js +119 -0
- package/dist/status.summary-CzLM0vVr.js +592 -0
- package/dist/status.summary.runtime-BSBnHZ1Q.js +118 -0
- package/dist/status.update-BxblMS7P.js +77 -0
- package/dist/subagent-orphan-recovery-BpRPryEj.js +307 -0
- package/dist/subagent-registry-runtime-DYYU5p3X.js +111 -0
- package/dist/subscription-CpFdxuFS.js +33 -0
- package/dist/subscription-DaA1urx-.js +102 -0
- package/dist/subscription-cli-Bvto9EmO.js +134 -0
- package/dist/synology-chat-3nwk-Nj0.js +297 -0
- package/dist/system-cli-BvNps8sl.js +94 -0
- package/dist/telegram/audit.d.ts +1 -1
- package/dist/telegram/audit.js +1 -1
- package/dist/telegram/token.d.ts +1 -1
- package/dist/telegram/token.js +35 -35
- package/dist/telegram-RtKXoEsF.js +114 -0
- package/dist/text-chunking-BD5mQe2R.js +84 -0
- package/dist/text-chunking-DDUU_vAF.d.ts +79 -0
- package/dist/tlon-z-kYmJE-.js +433 -0
- package/dist/tui-cli-CzSK08Rh.js +137 -0
- package/dist/tui-wV7R1Tlc.js +3834 -0
- package/dist/types-2H_e7eWT.d.ts +45 -0
- package/dist/types-ZKnGUchG.d.ts +22692 -0
- package/dist/types.base-BFiQZ4J9.d.ts +188 -0
- package/dist/ui-BWVHreeR.js +31 -0
- package/dist/update-D1Wgh1Tj.js +1036 -0
- package/dist/update-cli-CZh99uyY.js +1503 -0
- package/dist/update-offset-store-D5xTdUr0.js +112 -0
- package/dist/update-runner-GbKfoCHs.js +1496 -0
- package/dist/upsert-with-lock-BZU7Le8n.js +33 -0
- package/dist/usage-Czgwvg0h.js +115 -0
- package/dist/web-CMczmL90.js +112 -0
- package/dist/web-shared-B5Q0mIJq.d.ts +45 -0
- package/dist/webhook-request-guards-CsKDhZJr.d.ts +76 -0
- package/dist/webhook-targets-BSmFtesN.js +181 -0
- package/dist/webhook-targets-CjxuEE9C.d.ts +106 -0
- package/dist/webhooks-cli-Wl9y6AWW.js +350 -0
- package/dist/whatsapp-VzRW8MdR.js +114 -0
- package/dist/whatsapp-actions-Cg1Wxv8W.js +167 -0
- package/dist/workspace-DJ_S272u.js +484 -0
- package/dist/workspace-DbZSqjw0.js +289 -0
- package/dist/workspace-cli-D93DLmAh.js +154 -0
- package/dist/workspace-dirs-CGeIPpGN.js +2003 -0
- package/dist/zalo-CK2dlGmu.d.ts +9 -0
- package/dist/zalo-Db7s2boL.js +415 -0
- package/dist/zalouser-Jh5YTJX3.js +30911 -0
- package/docs/reference/templates/AGENTS.dev.md +83 -0
- package/docs/reference/templates/AGENTS.md +219 -0
- package/docs/reference/templates/BOOT.md +11 -0
- package/docs/reference/templates/BOOTSTRAP.md +62 -0
- package/docs/reference/templates/HEARTBEAT.md +12 -0
- package/docs/reference/templates/IDENTITY.dev.md +47 -0
- package/docs/reference/templates/IDENTITY.md +29 -0
- package/docs/reference/templates/SOUL.dev.md +76 -0
- package/docs/reference/templates/SOUL.md +43 -0
- package/docs/reference/templates/TOOLS.dev.md +24 -0
- package/docs/reference/templates/TOOLS.md +47 -0
- package/docs/reference/templates/USER.dev.md +18 -0
- package/docs/reference/templates/USER.md +23 -0
- package/extensions/discord/src/monitor/allow-list.ts +8 -1
- package/extensions/discord/src/monitor/message-handler.preflight.ts +4 -1
- package/package.json +2 -1
- package/dist/accounts-CDr-lDaV.d.ts +0 -103
- package/dist/accounts-CS8U4v8C.js +0 -114
- package/dist/acp-cli-BGT0jXcC.js +0 -2093
- package/dist/actions.runtime-BfckTw6c.js +0 -119
- package/dist/actions.runtime-Cl9mBfqH.js +0 -133
- package/dist/agent-scope-C-YmLnnb.js +0 -208
- package/dist/agents-CydD54p8.js +0 -222
- package/dist/agents-DpQsZO6O.js +0 -853
- package/dist/agents.config-XU7IsYE-.js +0 -121
- package/dist/agents.config-ssoQXuvF.js +0 -17
- package/dist/allow-list-Cfn6lmMK.js +0 -81
- package/dist/allowlist-CCYXVpM9.js +0 -142
- package/dist/api-BoXoFKxy.js +0 -117
- package/dist/audit-Bv05N5o9.js +0 -787
- package/dist/audit-CIWW1Aqm.js +0 -54
- package/dist/audit-channel.collect.runtime-Bi7yrdcO.js +0 -605
- package/dist/audit-channel.runtime-C_NDweiW.js +0 -121
- package/dist/audit-extra.async-Dp7OKSXg.js +0 -813
- package/dist/audit-membership-runtime-B8FQ6VtN.js +0 -162
- package/dist/audit.deep.runtime-CXhobL6b.js +0 -25
- package/dist/audit.nondeep.runtime-CrEm3T16.js +0 -832
- package/dist/audit.runtime-CJPKj1Zg.js +0 -118
- package/dist/auth-Byfp0flq.js +0 -101
- package/dist/auth-choice-BgOjdeXN.js +0 -507
- package/dist/auth-choice-CD1Heq0M.js +0 -122
- package/dist/auth-choice-ePNfg0iQ.js +0 -268
- package/dist/auth-choice-options-BlewQWI0.js +0 -123
- package/dist/auth-choice-prompt-BP2b6aXz.js +0 -36
- package/dist/auth-choice-prompt-Cmwl4n97.js +0 -115
- package/dist/auth-choice.apply-helpers-Dq-nxuuX.js +0 -66
- package/dist/auth-choice.plugin-providers.runtime-B23kOUzQ.js +0 -119
- package/dist/auth-profiles-1kPLbBwI.js +0 -127823
- package/dist/auth-profiles.runtime-DAfSjku1.js +0 -116
- package/dist/banner-DeOsobLO.js +0 -342
- package/dist/bluebubbles-BsLGedBM.js +0 -64
- package/dist/bluebubbles-CnT9wiS4.d.ts +0 -6
- package/dist/bot-CuzVYwa_.d.ts +0 -478
- package/dist/brave-BoWimrLe.js +0 -24
- package/dist/browser-cli-D_S3wEYE.js +0 -1494
- package/dist/call-ByEzDJ1_.js +0 -640
- package/dist/call-CHCWVg-O.js +0 -39
- package/dist/channel-3VC0oOMu.js +0 -214
- package/dist/channel-B9fCBPiS.js +0 -207
- package/dist/channel-B9q775cM.js +0 -562
- package/dist/channel-BG3UK54j.js +0 -803
- package/dist/channel-BRQAdMML.js +0 -352
- package/dist/channel-BmlLp933.js +0 -1321
- package/dist/channel-By6KvdTG.js +0 -920
- package/dist/channel-C8rRsdf6.js +0 -226
- package/dist/channel-CLEDBbXE.js +0 -943
- package/dist/channel-CMvBAG7o.js +0 -306
- package/dist/channel-CmlxxjHY.js +0 -1598
- package/dist/channel-CqG6_xN0.js +0 -949
- package/dist/channel-DNueHKs92.js +0 -316
- package/dist/channel-DUtyN7BX.js +0 -4681
- package/dist/channel-DWD6GrfZ.js +0 -538
- package/dist/channel-DaRYMYzj.js +0 -619
- package/dist/channel-Dj6BgLp8.js +0 -575
- package/dist/channel-account-context-Ba3u5D21.js +0 -103
- package/dist/channel-crabk6Em.js +0 -542
- package/dist/channel-i8uqQaK2.js +0 -497
- package/dist/channel-options-xljvwHS2.js +0 -50
- package/dist/channel-plugin-ids-DAgknSG4.js +0 -26
- package/dist/channel-summary-dHTMCG75.js +0 -111
- package/dist/channel-xVWQ96Ni.js +0 -397
- package/dist/channel.runtime-B6PoZ4BV.js +0 -182
- package/dist/channel.runtime-BPZmo57e.js +0 -404
- package/dist/channel.runtime-B_1uGR-U.js +0 -199
- package/dist/channel.runtime-BiXnPU0d.js +0 -218
- package/dist/channel.runtime-BpvDc9sv.js +0 -870
- package/dist/channel.runtime-CUua3W80.js +0 -418
- package/dist/channel.runtime-CaCBTd0A.js +0 -179
- package/dist/channel.runtime-D0FfYvUj.js +0 -4011
- package/dist/channel.runtime-DhoJtpvJ.js +0 -241
- package/dist/channel.runtime-Kj9EXNE0.js +0 -127
- package/dist/channel.runtime-r4tPuPyh.js +0 -171
- package/dist/channel.setup-B7d_grfe.js +0 -6
- package/dist/channel.setup-C0vu1fhi.js +0 -9
- package/dist/channel.setup-CAI0FNHj.js +0 -11
- package/dist/channel.setup-CkDVwv5R.js +0 -57
- package/dist/channel.setup-Cpd00YqQ.js +0 -8
- package/dist/channel.setup-DbBz1-WT.js +0 -9
- package/dist/channel.setup-GZnAvD9g.js +0 -8
- package/dist/channels-5H484RSw.js +0 -1118
- package/dist/channels-BnPudfyx.js +0 -404
- package/dist/channels-cli-WIC-QeH_.js +0 -291
- package/dist/channels-status-issues-RDmzovJU.js +0 -16
- package/dist/clawbot-cli-BgutNwf8.js +0 -118
- package/dist/cleanup-utils-DBl1Aij1.js +0 -96
- package/dist/cli-1P7u6zqu.js +0 -154
- package/dist/command-registry-B8jovrws.js +0 -232
- package/dist/command-registry-DtDl1FVm.js +0 -14
- package/dist/command-secret-gateway-BgUo3FxJ.js +0 -111
- package/dist/compact.runtime-CXbXM0AU.js +0 -116
- package/dist/completion-cli-Cik_owAE.js +0 -17
- package/dist/completion-cli-RU3P2RSl.js +0 -445
- package/dist/config-5HUpB1L1.js +0 -31
- package/dist/config-cli-QHaUHoZI.js +0 -433
- package/dist/config-guard-C9Sn3pE-.js +0 -118
- package/dist/config-sW57gztj.js +0 -44
- package/dist/config-validation-5LkjIKNt.js +0 -262
- package/dist/config-value-CtTWALxG.js +0 -132
- package/dist/configure-BmR2TPLf.js +0 -243
- package/dist/configure-DaLN-5xM.js +0 -1100
- package/dist/control-ui-assets-CH3MYmAo.js +0 -232
- package/dist/control-ui-shared-CA77PTml.js +0 -29
- package/dist/core-CvDzLs7B.js +0 -150
- package/dist/core-jm751KJ9.d.ts +0 -87
- package/dist/cron-cli-tguLpzyq.js +0 -639
- package/dist/daemon-cli-ptosOkL8.js +0 -339
- package/dist/daemon-install-DzU4EnVa.js +0 -180
- package/dist/deliver-DwxFoHM3.js +0 -111
- package/dist/deliver-runtime-DOdDyaPI.js +0 -111
- package/dist/device-id-cli-GopvlxxZ.js +0 -52
- package/dist/device-identity-CRfhC3_s.js +0 -365
- package/dist/devices-cli-ain7ESqU.js +0 -342
- package/dist/diagnostic-D96Xaqrj.js +0 -310
- package/dist/directory-cli-fh1UxGgY.js +0 -311
- package/dist/directory-config-helpers-Coivm0Mt.d.ts +0 -38
- package/dist/directory.static-CKjJUNGl.js +0 -44
- package/dist/discord-CflhwDEM.js +0 -114
- package/dist/discovery-x0ZqY4AB.js +0 -48
- package/dist/dm-policy-shared-DKzsSLlO.d.ts +0 -95
- package/dist/dns-cli-DCHyKjGf.js +0 -217
- package/dist/docs-cli-D3OoqYSP.js +0 -174
- package/dist/doctor-completion-Bq2eP87s.js +0 -90
- package/dist/doctor-config-flow-D8XRG9Ku.js +0 -2437
- package/dist/doctor-config-flow-DGiF1HGc.js +0 -112
- package/dist/enable-0QSF4YGH.js +0 -24
- package/dist/exec-approvals-cli-Bncym0Gd.js +0 -421
- package/dist/feishu-C1dM8pl2.d.ts +0 -36
- package/dist/gateway-cli-DYscsmA-.js +0 -26437
- package/dist/gateway-install-token-CNv17ac9.js +0 -163
- package/dist/gateway-rpc-BGC1Rxvg.js +0 -26
- package/dist/gateway-runtime-D89mSQPB.js +0 -69
- package/dist/git-commit-CeLH5Ozm.js +0 -2
- package/dist/git-commit-DUKRiCP-.js +0 -177
- package/dist/googlechat-BgXeXjd1.js +0 -307
- package/dist/googlechat-CNZQb1jd.d.ts +0 -12
- package/dist/group-access-Deh1tVNr.d.ts +0 -61
- package/dist/health-BEjzWwaB.js +0 -570
- package/dist/health-FjqrWQL6.js +0 -113
- package/dist/heartbeat-summary-CfdSA9M1.js +0 -57
- package/dist/help-BZeVprq1.js +0 -81
- package/dist/hooks-06OUQvAV.d.ts +0 -6
- package/dist/hooks-cli-B7uGJs2O.js +0 -1000
- package/dist/hooks-status-CfceaUSg.js +0 -78
- package/dist/http-registry-DYskWhOr.d.ts +0 -20
- package/dist/identity-file-sshkKKIr.js +0 -60
- package/dist/image-generation-D4o3j8o6.d.ts +0 -9
- package/dist/imessage-BcV3WGx_.js +0 -31
- package/dist/imessage-Dhje7Ty-.js +0 -115
- package/dist/inbound-reply-dispatch-C73_7SOl.js +0 -71
- package/dist/inbound-reply-dispatch-D6_HNqH8.d.ts +0 -72
- package/dist/install-target-D7NRhfzc.js +0 -574
- package/dist/installs-Bj6jblqc.js +0 -532
- package/dist/io-CMfWWPXQ.js +0 -9738
- package/dist/io-CV844hAM.js +0 -29
- package/dist/irc-DKi1fDYI.js +0 -672
- package/dist/library-rygTG3oA.js +0 -112
- package/dist/lifecycle-core-BPlvShWY.js +0 -382
- package/dist/line-B8gTtl3Y.d.ts +0 -75
- package/dist/line-CGsemKWJ.js +0 -530
- package/dist/llm-slug-generator-DlhVyMqT.js +0 -67
- package/dist/logging-5wu9k6w4.js +0 -30
- package/dist/logging-CxP9suT8.js +0 -13
- package/dist/login-qr-BcDsiwHs.js +0 -233
- package/dist/login-qr-Y8pJ5yV4.js +0 -112
- package/dist/logs-cli-XI9oVXpH.js +0 -256
- package/dist/manager-runtime-DkIlXBhD.js +0 -111
- package/dist/manager.runtime-Q0q2rJCC.js +0 -715
- package/dist/manifest-registry-DAd0SRAP.js +0 -1329
- package/dist/matrix-BI0DBBrG.js +0 -1495
- package/dist/matrix-D2JoHzb4.d.ts +0 -68
- package/dist/matrix-DiABGjJR.js +0 -1269
- package/dist/mcp-cli-BOyn_DLL.js +0 -87
- package/dist/media-understanding.runtime-DjUa7Dka.js +0 -116
- package/dist/memory-cli-CJd_vl-Y.js +0 -111
- package/dist/memory-search-CEEItIFR.js +0 -17
- package/dist/memory-search-Cv1SBrn7.js +0 -204
- package/dist/method-scopes-CQE7-bZ-.js +0 -2452
- package/dist/model-auth-markers-BFoM4IPf.d.ts +0 -20
- package/dist/model-picker-D6_89XHg.js +0 -112
- package/dist/model-picker-Svaw-APs.js +0 -390
- package/dist/model-picker.runtime-Chi9nV7A.js +0 -125
- package/dist/model-selection-hL8i1Jbs.js +0 -653
- package/dist/model-suppression.runtime-DjWJZ0X-.js +0 -116
- package/dist/models-7qj1dG_W.js +0 -118
- package/dist/models-BPOB_xJF.js +0 -2514
- package/dist/models-cli-DdlOVUjS.js +0 -309
- package/dist/models-config-CBqUS-jX.js +0 -111
- package/dist/models-config.providers.discovery-Dc905FWG.d.ts +0 -18
- package/dist/moldclaw-root-D6PbhbZk.js +0 -88
- package/dist/monitor-BPYhkEqF.js +0 -782
- package/dist/monitor-BuTcQ24j.js +0 -3468
- package/dist/monitor-CuXvNhFh.js +0 -113
- package/dist/monitor-D-TqSIHF.js +0 -6823
- package/dist/monitor-DRSgo9u2.js +0 -3076
- package/dist/monitor-DcHch39z.js +0 -772
- package/dist/monitor-DsHBMrXp.js +0 -115
- package/dist/monitor-shared-CL8T4gt1.js +0 -444
- package/dist/msteams-7FMwTvQG.js +0 -852
- package/dist/node-cli-BCjaSCZM.js +0 -2503
- package/dist/node-resolve-D5Hvcgyx.js +0 -835
- package/dist/nodes-cli-Dd_SNbkt.js +0 -1380
- package/dist/nostr-DBTFTxKs.js +0 -8744
- package/dist/nostr-DLqaIuZx.d.ts +0 -7
- package/dist/npm-resolution-CYfb3MHG.js +0 -60
- package/dist/oauth-env-zPt5RywA.js +0 -10
- package/dist/onboard-BEFQQeig.js +0 -25
- package/dist/onboard-CJHNyxJh.js +0 -48
- package/dist/onboard-D_3UeLEN.js +0 -589
- package/dist/onboard-channels-B_JL0Djc.js +0 -1241
- package/dist/onboard-channels-CqZzHt2C.js +0 -205
- package/dist/onboard-custom-CER3Ggbq.js +0 -571
- package/dist/onboard-custom-bNRdGECb.js +0 -114
- package/dist/onboard-helpers-BK0Hsb7Y.js +0 -335
- package/dist/onboard-helpers-CXZ5RPoR.js +0 -113
- package/dist/onboard-hooks-1NsxEDjH.js +0 -72
- package/dist/onboard-remote-DuKhC_7W.js +0 -117
- package/dist/onboard-remote-OwRcDuB3.js +0 -181
- package/dist/onboard-search-Cy8dOq2W.js +0 -302
- package/dist/onboard-skills-D5phRa6r.js +0 -117
- package/dist/onboard-skills-c9qWCNe9.js +0 -133
- package/dist/outbound-media-CXKqTh2X.d.ts +0 -11
- package/dist/outbound-media-DYRO2vTD.js +0 -11
- package/dist/pairing-access-BwJu1mkk.d.ts +0 -21
- package/dist/pairing-cli-BOnv0TYn.js +0 -217
- package/dist/perplexity-EZwC3y2b.js +0 -24
- package/dist/persistent-dedupe-hNES5tS1.d.ts +0 -26
- package/dist/pi-model-discovery-runtime-BToY3A6K.js +0 -111
- package/dist/pi-tools.before-tool-call.runtime-D_acPtld.js +0 -381
- package/dist/plugin-install-CgJpSjYd.js +0 -184
- package/dist/plugin-install-Cl1A4EF6.js +0 -117
- package/dist/plugin-install-plan-Dc2Z4DeU.js +0 -49
- package/dist/plugin-registry-B1UaWrQD.js +0 -49
- package/dist/plugin-registry-Cy8biwnn.js +0 -113
- package/dist/plugins-CXwvg50F.js +0 -111
- package/dist/plugins-cli-Uvzp2aYV.js +0 -917
- package/dist/policy-DsMBbEe7.js +0 -143
- package/dist/preflight-audio.runtime-hWsZIYvc.js +0 -116
- package/dist/probe-CNsSf1Uf.js +0 -6329
- package/dist/probe-CqOIrPhb.js +0 -47
- package/dist/probe-DH6gDw-h.js +0 -129
- package/dist/probe-DM16PLf4.js +0 -21
- package/dist/probe-DvAEEWYr.js +0 -1793
- package/dist/probe-auth-COfgCble.js +0 -48
- package/dist/probe-auth-I_5TX1Eh.js +0 -40
- package/dist/program-Dz80sgTU.js +0 -253
- package/dist/prompt-select-styled-wQehwFxK.js +0 -2673
- package/dist/provider-api-key-auth.runtime-BR9GU4ya.js +0 -121
- package/dist/provider-auth-choice-CdhA84kr.js +0 -126
- package/dist/provider-auth-choice-helpers-kabp_0zA.js +0 -48
- package/dist/provider-auth-choice-preference-se3zAM_2.js +0 -189
- package/dist/provider-auth-choice.runtime-BMc8-xNQ.js +0 -123
- package/dist/provider-auth-choices-CYsCViGi.js +0 -57
- package/dist/provider-auth-guidance-CMjUWlNf.js +0 -34
- package/dist/provider-auth-result-5xgWoVGi.d.ts +0 -18
- package/dist/provider-models-BCId_Lfu.js +0 -2113
- package/dist/provider-models-D-eFl9oH.d.ts +0 -867
- package/dist/provider-ollama-setup-B6XJZ0So.js +0 -314
- package/dist/provider-ollama-setup-BF1vhob8.d.ts +0 -32
- package/dist/provider-onboard-BjXHP3IZ.d.ts +0 -40
- package/dist/provider-onboard-Ca0TaNud.js +0 -139
- package/dist/provider-runtime.runtime-DwwkHw_7.js +0 -111
- package/dist/provider-self-hosted-setup-BEKLVGpj.js +0 -182
- package/dist/provider-self-hosted-setup-BQ5BIlpi.d.ts +0 -61
- package/dist/provider-stream-DrUD69ai.js +0 -512
- package/dist/provider-usage-BgKHCnjr.js +0 -111
- package/dist/provider-usage-D8EZpFz9.js +0 -633
- package/dist/provider-wizard-DMdb-zj_.js +0 -152
- package/dist/push-apns-BPH6d4VV.js +0 -1038
- package/dist/pw-ai-DttfldtL.js +0 -1867
- package/dist/qmd-manager-CybcDUfk.js +0 -1570
- package/dist/qr-cli-8NcmJ8Ft.js +0 -369
- package/dist/qr-cli-DWe0Our3.js +0 -113
- package/dist/reactions-D6N0LR16.js +0 -281
- package/dist/read-only-account-inspect.discord.runtime-CqUWTRfl.js +0 -116
- package/dist/read-only-account-inspect.slack.runtime-9-jpln3q.js +0 -116
- package/dist/read-only-account-inspect.telegram.runtime-EKPI1D7n.js +0 -116
- package/dist/redact-snapshot-DwJEIVk9.js +0 -2663
- package/dist/register.agent-D3YdDirP.js +0 -439
- package/dist/register.backup-dR27qCuo.js +0 -625
- package/dist/register.configure-BjFhkkka.js +0 -252
- package/dist/register.maintenance-DiMQJIOa.js +0 -574
- package/dist/register.message-CdZsKYH1.js +0 -709
- package/dist/register.onboard-B0rV1eaO.js +0 -192
- package/dist/register.setup-wKMvohzo.js +0 -212
- package/dist/register.status-health-sessions-BJ68m6pt.js +0 -498
- package/dist/register.subclis-CnnrWt2a.js +0 -315
- package/dist/register.subclis-lSvTkC6z.js +0 -13
- package/dist/replies-BABt9b48.js +0 -110
- package/dist/resolve-channels-BqZFl2Ux.js +0 -262
- package/dist/resolve-channels-DjQLXb7B.js +0 -226
- package/dist/resolve-route-CSHDsa_m.js +0 -538
- package/dist/resolve-users-BG6HaSR5.js +0 -143
- package/dist/root-help-ohmaCyC_.js +0 -32
- package/dist/routes-4k2kpvoT.js +0 -7097
- package/dist/rpc-Cnwn4Q6L.js +0 -67
- package/dist/run-main-VYlacKA0.js +0 -424
- package/dist/runtime-Cy8pqYUB.d.ts +0 -26
- package/dist/runtime-discord-ops.runtime-DafrU-rI.js +0 -9078
- package/dist/runtime-slack-ops.runtime-CdXBKXwd.js +0 -4556
- package/dist/runtime-telegram-ops.runtime-B12sF7gE.js +0 -133
- package/dist/runtime-whatsapp-login.runtime-CqEudH37.js +0 -114
- package/dist/runtime-whatsapp-outbound.runtime-D5m2qyn-.js +0 -117
- package/dist/sandbox-cli-CHJiEWXB.js +0 -535
- package/dist/search-manager-BtNC3-i_.js +0 -16
- package/dist/search-manager-C7J7B3_a.js +0 -386
- package/dist/secrets-cli-C6yIWBbN.js +0 -2070
- package/dist/security-cli-BVu9BkjD.js +0 -575
- package/dist/send-BSreC7rr.js +0 -631
- package/dist/send-BsLHQG_B.js +0 -1025
- package/dist/send-BuNhp8PH.js +0 -283
- package/dist/send-DOCswVar.js +0 -100
- package/dist/send-Dl0LLErk.js +0 -629
- package/dist/server-node-events-Bq2067EG.js +0 -506
- package/dist/server-y38L7N5H.js +0 -107
- package/dist/sessions-BV8gXURR.js +0 -112
- package/dist/sessions-dl1Kc-Ci.js +0 -218
- package/dist/setup-DGszQH0_.js +0 -387
- package/dist/setup-DR5rRw9y.d.ts +0 -37
- package/dist/setup-binary-C17YnmA8.js +0 -406
- package/dist/setup-browser-CPx-nEsr.js +0 -70
- package/dist/setup-core-BByHN1ME.js +0 -143
- package/dist/setup-core-C0KPlBmL.js +0 -47
- package/dist/setup-core-Cq37G6of.js +0 -166
- package/dist/setup-core-uO84_Y75.js +0 -205
- package/dist/setup-surface-BEMi7Rmb.js +0 -490
- package/dist/setup-wizard-helpers-BtuGx_gN.d.ts +0 -203
- package/dist/setup.finalize-BzPBa8zW.js +0 -522
- package/dist/setup.gateway-config-DdwkF-8e.js +0 -343
- package/dist/shared-BCw4SKjB.js +0 -96
- package/dist/shared-CjNzsULP.js +0 -75
- package/dist/shared-Cu1BE7ZE.js +0 -298
- package/dist/shared-DSClmyUn.js +0 -182
- package/dist/shared-DyJdGH6y.js +0 -102
- package/dist/signal-Dyv4NZsB.js +0 -114
- package/dist/skills-CbB5b27M.js +0 -853
- package/dist/skills-CnfI7Szw.js +0 -20
- package/dist/skills-cli-CavB1f_3.js +0 -292
- package/dist/skills-install-B1OBdgd0.js +0 -763
- package/dist/skills-status-B3gAmIbW.js +0 -169
- package/dist/skills-status-DrHhFgU9.js +0 -21
- package/dist/slack-BRzqnoAz.js +0 -114
- package/dist/slash-commands.runtime-BK88kgds.js +0 -128
- package/dist/slash-dispatch.runtime-COGywwJE.js +0 -141
- package/dist/slash-skill-commands.runtime-Ti4brxgh.js +0 -116
- package/dist/src-DUR6OQxI.js +0 -1701
- package/dist/status-C6dgQY9a.js +0 -131
- package/dist/status-CNK0Q7QH.js +0 -606
- package/dist/status-DBcX0DSC.js +0 -43
- package/dist/status-DKgFgbwv.js +0 -1599
- package/dist/status-Wn5lhNAc.js +0 -126
- package/dist/status-json-D2EkWqAl.js +0 -288
- package/dist/status.link-channel-D3ULIdEa.js +0 -143
- package/dist/status.scan.deps.runtime-BsjWTAm4.js +0 -126
- package/dist/status.scan.runtime-D4HbzROD.js +0 -119
- package/dist/status.summary-C3YxPrDK.js +0 -592
- package/dist/status.summary.runtime-DAkXPSaK.js +0 -118
- package/dist/status.update-B4NnN9P1.js +0 -77
- package/dist/subagent-orphan-recovery-QiQEBv36.js +0 -307
- package/dist/subagent-registry-runtime-BJatPQFK.js +0 -111
- package/dist/subscription-BhZORXN9.js +0 -100
- package/dist/subscription-QEUjQRMv.js +0 -33
- package/dist/subscription-cli-HrULlAgc.js +0 -134
- package/dist/synology-chat-DB76GWMN.js +0 -297
- package/dist/system-cli-D8jDwWuL.js +0 -94
- package/dist/telegram-BHiiqKkQ.js +0 -114
- package/dist/text-chunking-Baonm9Lu.js +0 -84
- package/dist/text-chunking-Y3dPBOuZ.d.ts +0 -79
- package/dist/tlon-DLESxNgD.js +0 -433
- package/dist/tui-C75zi2Cl.js +0 -3834
- package/dist/tui-cli-DFwx5e6i.js +0 -137
- package/dist/types-BBJ3Qz7j.d.ts +0 -45
- package/dist/types-Ckufs_BY.d.ts +0 -22692
- package/dist/types.base-Cw0-zIvE.d.ts +0 -188
- package/dist/ui-B55NOIB6.js +0 -31
- package/dist/update--ojavYQ4.js +0 -1036
- package/dist/update-cli-Cvj5aWYM.js +0 -1503
- package/dist/update-offset-store-upatuWwX.js +0 -112
- package/dist/update-runner-DHkY_-76.js +0 -1496
- package/dist/upsert-with-lock-C171GLaR.js +0 -33
- package/dist/usage-N3bxnbmt.js +0 -115
- package/dist/web-RdvT7gKa.js +0 -112
- package/dist/web-shared-HSGD3yGt.d.ts +0 -45
- package/dist/webhook-request-guards-CosLyl01.d.ts +0 -76
- package/dist/webhook-targets-Bfnag-du.js +0 -181
- package/dist/webhook-targets-Di17rt8e.d.ts +0 -106
- package/dist/webhooks-cli-ZpnXrq7G.js +0 -350
- package/dist/whatsapp-DNTAyZHt.js +0 -114
- package/dist/whatsapp-actions-o1zKQzKZ.js +0 -167
- package/dist/workspace-CpWi5wPr.js +0 -479
- package/dist/workspace-Ii7aRS7c.js +0 -289
- package/dist/workspace-dirs-x10McA9t.js +0 -2003
- package/dist/zalo-BN3VCrRY.d.ts +0 -9
- package/dist/zalo-zm_bYCKg.js +0 -415
- package/dist/zalouser-CvVEUvc5.js +0 -30911
- /package/dist/{account-id-B3YSn4hl.d.ts → account-id-B8ce6G_4.d.ts} +0 -0
- /package/dist/{acpx-CnNv70m2.d.ts → acpx-Ci50I9T2.d.ts} +0 -0
- /package/dist/{agent-media-payload-DE2pEcsz.d.ts → agent-media-payload-en-gS5p6.d.ts} +0 -0
- /package/dist/{allow-from-DPpHnT2A.d.ts → allow-from-cMeQ47Ot.d.ts} +0 -0
- /package/dist/{allowlist-resolution-CLFiZ6nE.d.ts → allowlist-resolution-DoAWbfXV.d.ts} +0 -0
- /package/dist/{bluebubbles-Duhu-Jer.d.ts → bluebubbles-C6yYmUl0.d.ts} +0 -0
- /package/dist/{boolean-param-BhFjB3gp.d.ts → boolean-param-CdO2TFTk.d.ts} +0 -0
- /package/dist/{channel-config-schema-DnnVMdjR.d.ts → channel-config-schema-Chp38wel.d.ts} +0 -0
- /package/dist/{channel-policy-Baq-Z06b.d.ts → channel-policy-g2h6AbYQ.d.ts} +0 -0
- /package/dist/{chat-type-DpiBgwuG.d.ts → chat-type-BLt59pPT.d.ts} +0 -0
- /package/dist/{command-format-vi4xq8e8.d.ts → command-format-BDJC05Jp.d.ts} +0 -0
- /package/dist/{diffs-DK7fVSDo.d.ts → diffs-D_iNKCyn.d.ts} +0 -0
- /package/dist/{directory-runtime-BTLPaysA.d.ts → directory-runtime-DhMex6HY.d.ts} +0 -0
- /package/dist/{exec-C01wtBHu.d.ts → exec-pjfUY4KM.d.ts} +0 -0
- /package/dist/{gaxios-fetch-compat-wZ38b3w3.js → gaxios-fetch-compat-B_vtINdV.js} +0 -0
- /package/dist/{history-CwXuP2TW.d.ts → history-aqSS5VGQ.d.ts} +0 -0
- /package/dist/{inbound-envelope-SggrBs9m.d.ts → inbound-envelope-C5hWuZod.d.ts} +0 -0
- /package/dist/{index-apAZHsDo.d.ts → index-DXVQFYGX.d.ts} +0 -0
- /package/dist/{json-store-r75IZGk9.d.ts → json-store-UnqQ5aV3.d.ts} +0 -0
- /package/dist/{keyed-async-queue-DHIr7yNe.d.ts → keyed-async-queue-guucpLw3.d.ts} +0 -0
- /package/dist/{links-HeQ3r_L0.d.ts → links-Bar0meEK.d.ts} +0 -0
- /package/dist/{markdown-to-line-CDb4Jy3V.d.ts → markdown-to-line-D8uH_KOj.d.ts} +0 -0
- /package/dist/{mattermost-DtCsxpgg.d.ts → mattermost-xl7jAFJL.d.ts} +0 -0
- /package/dist/{net-BATPDwdQ.d.ts → net-rGOKGds6.d.ts} +0 -0
- /package/dist/{nextcloud-talk-Bb2wHOwp.d.ts → nextcloud-talk-De2CZ9dV.d.ts} +0 -0
- /package/dist/{oauth-utils-u567CLT0.d.ts → oauth-utils-DzN1AlEH.d.ts} +0 -0
- /package/dist/{parse-finite-number-l3tNlrZh.d.ts → parse-finite-number-odgyqhi0.d.ts} +0 -0
- /package/dist/{provider-usage.types-C6061OVN.d.ts → provider-usage.types-EDE9o-H_.d.ts} +0 -0
- /package/dist/{reply-history-BDsFnZFl.d.ts → reply-history-CVuU31xe.d.ts} +0 -0
- /package/dist/{reply-payload-CCvM4W9u.d.ts → reply-payload-CHkpBYwL.d.ts} +0 -0
- /package/dist/{request-url-C54l4-xC.d.ts → request-url-DHisbiHY.d.ts} +0 -0
- /package/dist/{run-command-D3RqWcHu.d.ts → run-command-y0Cndsb1.d.ts} +0 -0
- /package/dist/{secret-input-schema-BLBt-NAP.d.ts → secret-input-schema-b1vpYDQN.d.ts} +0 -0
- /package/dist/{session-key-BQ2-bR-9.d.ts → session-key-DTHQl57f.d.ts} +0 -0
- /package/dist/{ssh-config-C4mcH9Ly.js → ssh-config-hEHBfU2_.js} +0 -0
- /package/dist/{testing-DLkhGsoz.d.ts → testing-DszuZXgK.d.ts} +0 -0
- /package/dist/{thinking-DRkjX18p.d.ts → thinking-IwXTGSeT.d.ts} +0 -0
- /package/dist/{tool-send-CMMD1uDu.d.ts → tool-send-DWHRmKpz.d.ts} +0 -0
- /package/dist/{vllm-defaults-CcGuf4hL.d.ts → vllm-defaults-CrxZgE6-.d.ts} +0 -0
- /package/dist/{wait-Daog8bxM.d.ts → wait-wDWw_MTI.d.ts} +0 -0
- /package/dist/{webhook-memory-guards-C5MrExwT.d.ts → webhook-memory-guards-DreORuJy.d.ts} +0 -0
- /package/dist/{windows-spawn-j2l-dqu8.d.ts → windows-spawn-BIzH92x2.d.ts} +0 -0
- /package/dist/{zod-schema.agent-runtime-krMrBnIn.d.ts → zod-schema.agent-runtime-CP2rmis3.d.ts} +0 -0
- /package/dist/{zod-schema.core-BNDieZDZ.d.ts → zod-schema.core-Foi1tYwi.d.ts} +0 -0
|
@@ -1,2437 +0,0 @@
|
|
|
1
|
-
import { _ as resolveStateDir, h as resolveOAuthDir, m as resolveNewStateDir, p as resolveLegacyStateDirs, t as CONFIG_PATH } from "./paths-D6AgsMTU.js";
|
|
2
|
-
import { _ as resolveHomeDir, d as isRecord } from "./utils-C7ykRPCQ.js";
|
|
3
|
-
import { Bn as applyPluginAutoEnable, Em as inspectTelegramAccount, Kx as resolveTelegramAccount, Nw as shouldMoveSingleAccountChannelKey, Wx as listTelegramAccountIds, _m as fetchTelegramChatId, cm as resolveChannelAllowFromPath, eC as collectProviderDangerousNameMatchingScopes, ff as resolveMergedSafeBinProfileFixtures, rg as isWithinDir, rm as readChannelAllowFromStore, sC as saveSessionStore, uf as listInterpreterLikeSafeBins, vm as isNumericTelegramUserId, ym as normalizeTelegramAllowFromEntry, yu as resolveCommandSecretRefsViaGateway } from "./auth-profiles-1kPLbBwI.js";
|
|
4
|
-
import { m as resolveDefaultAgentId } from "./agent-scope-C-YmLnnb.js";
|
|
5
|
-
import { c as normalizeAgentId, n as DEFAULT_MAIN_KEY, r as buildAgentMainSessionKey } from "./session-key-UoG7Kfw5.js";
|
|
6
|
-
import { n as normalizeAccountId, r as normalizeOptionalAccountId, t as DEFAULT_ACCOUNT_ID } from "./account-id-BuyZMNja.js";
|
|
7
|
-
import { Rt as resolveCommandResolutionFromArgv, St as normalizeTrustedSafeBinDirs, T as moldClawSchema, an as formatSlackStreamModeMigrationMessage, bt as isTrustedSafeBinPath, f as readConfigFileSnapshot, fn as resolveDiscordPreviewStreamMode, hn as resolveTelegramPreviewStreamMode, mn as resolveSlackStreamingMode, on as formatSlackStreamingBooleanMigrationMessage, pn as resolveSlackNativeStreaming, yt as getTrustedSafeBinDirs } from "./io-CMfWWPXQ.js";
|
|
8
|
-
import { c as normalizeChatChannelId } from "./registry-C1pRrsQl.js";
|
|
9
|
-
import { n as parseToolsBySenderTypedKey, r as migrateLegacyConfig } from "./config-sW57gztj.js";
|
|
10
|
-
import { t as describeUnknownError } from "./shared-dXUb11iF.js";
|
|
11
|
-
import { t as formatCliCommand } from "./command-format-C_z0Ru-7.js";
|
|
12
|
-
import { l as canonicalizeMainSessionAlias } from "./lazy-runtime-BoGB4usD.js";
|
|
13
|
-
import { r as listRouteBindings } from "./bindings-EA8JT6o1.js";
|
|
14
|
-
import { n as formatSetExplicitDefaultInstruction, r as formatSetExplicitDefaultToConfiguredInstruction, t as formatChannelAccountsDefaultPath } from "./routing-DQ-fpTaA.js";
|
|
15
|
-
import { n as formatConfigIssueLines } from "./issue-format-B0SI57Es.js";
|
|
16
|
-
import { t as note } from "./note-dOl5kPAy.js";
|
|
17
|
-
import { n as getChannelsCommandSecretTargetIds } from "./command-secret-targets-BFF4x_RB.js";
|
|
18
|
-
import { a as isMattermostMutableAllowEntry, i as isMSTeamsMutableAllowEntry, n as isGoogleChatMutableAllowEntry, o as isSlackMutableAllowEntry, r as isIrcMutableAllowEntry, s as isZalouserMutableGroupEntry, t as isDiscordMutableAllowEntry } from "./mutable-allowlist-detectors-DsNiGmWW.js";
|
|
19
|
-
import fs from "node:fs";
|
|
20
|
-
import path from "node:path";
|
|
21
|
-
import os from "node:os";
|
|
22
|
-
import JSON5 from "json5";
|
|
23
|
-
import fs$1 from "node:fs/promises";
|
|
24
|
-
//#region src/commands/doctor-config-analysis.ts
|
|
25
|
-
function normalizeIssuePath(path) {
|
|
26
|
-
return path.filter((part) => typeof part !== "symbol");
|
|
27
|
-
}
|
|
28
|
-
function isUnrecognizedKeysIssue(issue) {
|
|
29
|
-
return issue.code === "unrecognized_keys";
|
|
30
|
-
}
|
|
31
|
-
function formatConfigPath(parts) {
|
|
32
|
-
if (parts.length === 0) return "<root>";
|
|
33
|
-
let out = "";
|
|
34
|
-
for (const part of parts) {
|
|
35
|
-
if (typeof part === "number") {
|
|
36
|
-
out += `[${part}]`;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
out = out ? `${out}.${part}` : part;
|
|
40
|
-
}
|
|
41
|
-
return out || "<root>";
|
|
42
|
-
}
|
|
43
|
-
function resolveConfigPathTarget(root, path) {
|
|
44
|
-
let current = root;
|
|
45
|
-
for (const part of path) {
|
|
46
|
-
if (typeof part === "number") {
|
|
47
|
-
if (!Array.isArray(current)) return null;
|
|
48
|
-
if (part < 0 || part >= current.length) return null;
|
|
49
|
-
current = current[part];
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (!current || typeof current !== "object" || Array.isArray(current)) return null;
|
|
53
|
-
const record = current;
|
|
54
|
-
if (!(part in record)) return null;
|
|
55
|
-
current = record[part];
|
|
56
|
-
}
|
|
57
|
-
return current;
|
|
58
|
-
}
|
|
59
|
-
function stripUnknownConfigKeys(config) {
|
|
60
|
-
const parsed = moldClawSchema.safeParse(config);
|
|
61
|
-
if (parsed.success) return {
|
|
62
|
-
config,
|
|
63
|
-
removed: []
|
|
64
|
-
};
|
|
65
|
-
const next = structuredClone(config);
|
|
66
|
-
const removed = [];
|
|
67
|
-
for (const issue of parsed.error.issues) {
|
|
68
|
-
if (!isUnrecognizedKeysIssue(issue)) continue;
|
|
69
|
-
const issuePath = normalizeIssuePath(issue.path);
|
|
70
|
-
const target = resolveConfigPathTarget(next, issuePath);
|
|
71
|
-
if (!target || typeof target !== "object" || Array.isArray(target)) continue;
|
|
72
|
-
const record = target;
|
|
73
|
-
for (const key of issue.keys) {
|
|
74
|
-
if (typeof key !== "string" || !(key in record)) continue;
|
|
75
|
-
delete record[key];
|
|
76
|
-
removed.push(formatConfigPath([...issuePath, key]));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
config: next,
|
|
81
|
-
removed
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function noteOpencodeProviderOverrides(cfg) {
|
|
85
|
-
const providers = cfg.models?.providers;
|
|
86
|
-
if (!providers) return;
|
|
87
|
-
const overrides = [];
|
|
88
|
-
if (providers.opencode) overrides.push("opencode");
|
|
89
|
-
if (providers["opencode-zen"]) overrides.push("opencode-zen");
|
|
90
|
-
if (providers["opencode-go"]) overrides.push("opencode-go");
|
|
91
|
-
if (overrides.length === 0) return;
|
|
92
|
-
const lines = overrides.flatMap((id) => {
|
|
93
|
-
const providerLabel = id === "opencode-go" ? "OpenCode Go" : "OpenCode Zen";
|
|
94
|
-
const providerEntry = providers[id];
|
|
95
|
-
const api = isRecord(providerEntry) && typeof providerEntry.api === "string" ? providerEntry.api : void 0;
|
|
96
|
-
return [`- models.providers.${id} is set; this overrides the built-in ${providerLabel} catalog.`, api ? `- models.providers.${id}.api=${api}` : null].filter((line) => Boolean(line));
|
|
97
|
-
});
|
|
98
|
-
lines.push("- Remove these entries to restore per-model API routing + costs (then re-run setup if needed).");
|
|
99
|
-
note(lines.join("\n"), "OpenCode");
|
|
100
|
-
}
|
|
101
|
-
function noteIncludeConfinementWarning(snapshot) {
|
|
102
|
-
const includeIssue = (snapshot.issues ?? []).find((issue) => issue.message.includes("Include path escapes config directory") || issue.message.includes("Include path resolves outside config directory"));
|
|
103
|
-
if (!includeIssue) return;
|
|
104
|
-
note([
|
|
105
|
-
`- $include paths must stay under: ${path.dirname(snapshot.path ?? CONFIG_PATH)}`,
|
|
106
|
-
"- Move shared include files under that directory and update to relative paths like \"./shared/common.json\".",
|
|
107
|
-
`- Error: ${includeIssue.message}`
|
|
108
|
-
].join("\n"), "Doctor warnings");
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/commands/doctor-legacy-config.ts
|
|
112
|
-
function normalizeCompatibilityConfigValues(cfg) {
|
|
113
|
-
const changes = [];
|
|
114
|
-
let next = cfg;
|
|
115
|
-
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
116
|
-
const normalizeDmAliases = (params) => {
|
|
117
|
-
let changed = false;
|
|
118
|
-
let updated = params.entry;
|
|
119
|
-
const rawDm = updated.dm;
|
|
120
|
-
const dm = isRecord(rawDm) ? structuredClone(rawDm) : null;
|
|
121
|
-
let dmChanged = false;
|
|
122
|
-
const allowFromEqual = (a, b) => {
|
|
123
|
-
if (!Array.isArray(a) || !Array.isArray(b)) return false;
|
|
124
|
-
const na = a.map((v) => String(v).trim()).filter(Boolean);
|
|
125
|
-
const nb = b.map((v) => String(v).trim()).filter(Boolean);
|
|
126
|
-
if (na.length !== nb.length) return false;
|
|
127
|
-
return na.every((v, i) => v === nb[i]);
|
|
128
|
-
};
|
|
129
|
-
const topDmPolicy = updated.dmPolicy;
|
|
130
|
-
const legacyDmPolicy = dm?.policy;
|
|
131
|
-
if (topDmPolicy === void 0 && legacyDmPolicy !== void 0) {
|
|
132
|
-
updated = {
|
|
133
|
-
...updated,
|
|
134
|
-
dmPolicy: legacyDmPolicy
|
|
135
|
-
};
|
|
136
|
-
changed = true;
|
|
137
|
-
if (dm) {
|
|
138
|
-
delete dm.policy;
|
|
139
|
-
dmChanged = true;
|
|
140
|
-
}
|
|
141
|
-
changes.push(`Moved ${params.pathPrefix}.dm.policy → ${params.pathPrefix}.dmPolicy.`);
|
|
142
|
-
} else if (topDmPolicy !== void 0 && legacyDmPolicy !== void 0) {
|
|
143
|
-
if (topDmPolicy === legacyDmPolicy) {
|
|
144
|
-
if (dm) {
|
|
145
|
-
delete dm.policy;
|
|
146
|
-
dmChanged = true;
|
|
147
|
-
changes.push(`Removed ${params.pathPrefix}.dm.policy (dmPolicy already set).`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const topAllowFrom = updated.allowFrom;
|
|
152
|
-
const legacyAllowFrom = dm?.allowFrom;
|
|
153
|
-
if (topAllowFrom === void 0 && legacyAllowFrom !== void 0) {
|
|
154
|
-
updated = {
|
|
155
|
-
...updated,
|
|
156
|
-
allowFrom: legacyAllowFrom
|
|
157
|
-
};
|
|
158
|
-
changed = true;
|
|
159
|
-
if (dm) {
|
|
160
|
-
delete dm.allowFrom;
|
|
161
|
-
dmChanged = true;
|
|
162
|
-
}
|
|
163
|
-
changes.push(`Moved ${params.pathPrefix}.dm.allowFrom → ${params.pathPrefix}.allowFrom.`);
|
|
164
|
-
} else if (topAllowFrom !== void 0 && legacyAllowFrom !== void 0) {
|
|
165
|
-
if (allowFromEqual(topAllowFrom, legacyAllowFrom)) {
|
|
166
|
-
if (dm) {
|
|
167
|
-
delete dm.allowFrom;
|
|
168
|
-
dmChanged = true;
|
|
169
|
-
changes.push(`Removed ${params.pathPrefix}.dm.allowFrom (allowFrom already set).`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (dm && isRecord(rawDm) && dmChanged) if (Object.keys(dm).length === 0) {
|
|
174
|
-
if (updated.dm !== void 0) {
|
|
175
|
-
const { dm: _ignored, ...rest } = updated;
|
|
176
|
-
updated = rest;
|
|
177
|
-
changed = true;
|
|
178
|
-
changes.push(`Removed empty ${params.pathPrefix}.dm after migration.`);
|
|
179
|
-
}
|
|
180
|
-
} else {
|
|
181
|
-
updated = {
|
|
182
|
-
...updated,
|
|
183
|
-
dm
|
|
184
|
-
};
|
|
185
|
-
changed = true;
|
|
186
|
-
}
|
|
187
|
-
return {
|
|
188
|
-
entry: updated,
|
|
189
|
-
changed
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
const normalizePreviewStreamingAliases = (params) => {
|
|
193
|
-
let updated = params.entry;
|
|
194
|
-
const hadLegacyStreamMode = updated.streamMode !== void 0;
|
|
195
|
-
const beforeStreaming = updated.streaming;
|
|
196
|
-
const resolved = params.resolveStreaming(updated);
|
|
197
|
-
if (!(hadLegacyStreamMode || typeof beforeStreaming === "boolean" || typeof beforeStreaming === "string" && beforeStreaming !== resolved)) return {
|
|
198
|
-
entry: updated,
|
|
199
|
-
changed: false
|
|
200
|
-
};
|
|
201
|
-
let changed = false;
|
|
202
|
-
if (beforeStreaming !== resolved) {
|
|
203
|
-
updated = {
|
|
204
|
-
...updated,
|
|
205
|
-
streaming: resolved
|
|
206
|
-
};
|
|
207
|
-
changed = true;
|
|
208
|
-
}
|
|
209
|
-
if (hadLegacyStreamMode) {
|
|
210
|
-
const { streamMode: _ignored, ...rest } = updated;
|
|
211
|
-
updated = rest;
|
|
212
|
-
changed = true;
|
|
213
|
-
changes.push(`Moved ${params.pathPrefix}.streamMode → ${params.pathPrefix}.streaming (${resolved}).`);
|
|
214
|
-
}
|
|
215
|
-
if (typeof beforeStreaming === "boolean") changes.push(`Normalized ${params.pathPrefix}.streaming boolean → enum (${resolved}).`);
|
|
216
|
-
else if (typeof beforeStreaming === "string" && beforeStreaming !== resolved) changes.push(`Normalized ${params.pathPrefix}.streaming (${beforeStreaming}) → (${resolved}).`);
|
|
217
|
-
return {
|
|
218
|
-
entry: updated,
|
|
219
|
-
changed
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
const normalizeSlackStreamingAliases = (params) => {
|
|
223
|
-
let updated = params.entry;
|
|
224
|
-
const hadLegacyStreamMode = updated.streamMode !== void 0;
|
|
225
|
-
const legacyStreaming = updated.streaming;
|
|
226
|
-
const beforeStreaming = updated.streaming;
|
|
227
|
-
const beforeNativeStreaming = updated.nativeStreaming;
|
|
228
|
-
const resolvedStreaming = resolveSlackStreamingMode(updated);
|
|
229
|
-
const resolvedNativeStreaming = resolveSlackNativeStreaming(updated);
|
|
230
|
-
if (!(hadLegacyStreamMode || typeof legacyStreaming === "boolean" || typeof legacyStreaming === "string" && legacyStreaming !== resolvedStreaming)) return {
|
|
231
|
-
entry: updated,
|
|
232
|
-
changed: false
|
|
233
|
-
};
|
|
234
|
-
let changed = false;
|
|
235
|
-
if (beforeStreaming !== resolvedStreaming) {
|
|
236
|
-
updated = {
|
|
237
|
-
...updated,
|
|
238
|
-
streaming: resolvedStreaming
|
|
239
|
-
};
|
|
240
|
-
changed = true;
|
|
241
|
-
}
|
|
242
|
-
if (typeof beforeNativeStreaming !== "boolean" || beforeNativeStreaming !== resolvedNativeStreaming) {
|
|
243
|
-
updated = {
|
|
244
|
-
...updated,
|
|
245
|
-
nativeStreaming: resolvedNativeStreaming
|
|
246
|
-
};
|
|
247
|
-
changed = true;
|
|
248
|
-
}
|
|
249
|
-
if (hadLegacyStreamMode) {
|
|
250
|
-
const { streamMode: _ignored, ...rest } = updated;
|
|
251
|
-
updated = rest;
|
|
252
|
-
changed = true;
|
|
253
|
-
changes.push(formatSlackStreamModeMigrationMessage(params.pathPrefix, resolvedStreaming));
|
|
254
|
-
}
|
|
255
|
-
if (typeof legacyStreaming === "boolean") changes.push(formatSlackStreamingBooleanMigrationMessage(params.pathPrefix, resolvedNativeStreaming));
|
|
256
|
-
else if (typeof legacyStreaming === "string" && legacyStreaming !== resolvedStreaming) changes.push(`Normalized ${params.pathPrefix}.streaming (${legacyStreaming}) → (${resolvedStreaming}).`);
|
|
257
|
-
return {
|
|
258
|
-
entry: updated,
|
|
259
|
-
changed
|
|
260
|
-
};
|
|
261
|
-
};
|
|
262
|
-
const normalizeStreamingAliasesForProvider = (params) => {
|
|
263
|
-
if (params.provider === "telegram") return normalizePreviewStreamingAliases({
|
|
264
|
-
entry: params.entry,
|
|
265
|
-
pathPrefix: params.pathPrefix,
|
|
266
|
-
resolveStreaming: resolveTelegramPreviewStreamMode
|
|
267
|
-
});
|
|
268
|
-
if (params.provider === "discord") return normalizePreviewStreamingAliases({
|
|
269
|
-
entry: params.entry,
|
|
270
|
-
pathPrefix: params.pathPrefix,
|
|
271
|
-
resolveStreaming: resolveDiscordPreviewStreamMode
|
|
272
|
-
});
|
|
273
|
-
return normalizeSlackStreamingAliases({
|
|
274
|
-
entry: params.entry,
|
|
275
|
-
pathPrefix: params.pathPrefix
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
const normalizeProvider = (provider) => {
|
|
279
|
-
const rawEntry = next.channels?.[provider];
|
|
280
|
-
if (!isRecord(rawEntry)) return;
|
|
281
|
-
let updated = rawEntry;
|
|
282
|
-
let changed = false;
|
|
283
|
-
if (provider !== "telegram") {
|
|
284
|
-
const base = normalizeDmAliases({
|
|
285
|
-
provider,
|
|
286
|
-
entry: rawEntry,
|
|
287
|
-
pathPrefix: `channels.${provider}`
|
|
288
|
-
});
|
|
289
|
-
updated = base.entry;
|
|
290
|
-
changed = base.changed;
|
|
291
|
-
}
|
|
292
|
-
const providerStreaming = normalizeStreamingAliasesForProvider({
|
|
293
|
-
provider,
|
|
294
|
-
entry: updated,
|
|
295
|
-
pathPrefix: `channels.${provider}`
|
|
296
|
-
});
|
|
297
|
-
updated = providerStreaming.entry;
|
|
298
|
-
changed = changed || providerStreaming.changed;
|
|
299
|
-
const rawAccounts = updated.accounts;
|
|
300
|
-
if (isRecord(rawAccounts)) {
|
|
301
|
-
let accountsChanged = false;
|
|
302
|
-
const accounts = { ...rawAccounts };
|
|
303
|
-
for (const [accountId, rawAccount] of Object.entries(rawAccounts)) {
|
|
304
|
-
if (!isRecord(rawAccount)) continue;
|
|
305
|
-
let accountEntry = rawAccount;
|
|
306
|
-
let accountChanged = false;
|
|
307
|
-
if (provider !== "telegram") {
|
|
308
|
-
const res = normalizeDmAliases({
|
|
309
|
-
provider,
|
|
310
|
-
entry: rawAccount,
|
|
311
|
-
pathPrefix: `channels.${provider}.accounts.${accountId}`
|
|
312
|
-
});
|
|
313
|
-
accountEntry = res.entry;
|
|
314
|
-
accountChanged = res.changed;
|
|
315
|
-
}
|
|
316
|
-
const accountStreaming = normalizeStreamingAliasesForProvider({
|
|
317
|
-
provider,
|
|
318
|
-
entry: accountEntry,
|
|
319
|
-
pathPrefix: `channels.${provider}.accounts.${accountId}`
|
|
320
|
-
});
|
|
321
|
-
accountEntry = accountStreaming.entry;
|
|
322
|
-
accountChanged = accountChanged || accountStreaming.changed;
|
|
323
|
-
if (accountChanged) {
|
|
324
|
-
accounts[accountId] = accountEntry;
|
|
325
|
-
accountsChanged = true;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (accountsChanged) {
|
|
329
|
-
updated = {
|
|
330
|
-
...updated,
|
|
331
|
-
accounts
|
|
332
|
-
};
|
|
333
|
-
changed = true;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (changed) next = {
|
|
337
|
-
...next,
|
|
338
|
-
channels: {
|
|
339
|
-
...next.channels,
|
|
340
|
-
[provider]: updated
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
};
|
|
344
|
-
const normalizeLegacyBrowserProfiles = () => {
|
|
345
|
-
const rawBrowser = next.browser;
|
|
346
|
-
if (!isRecord(rawBrowser)) return;
|
|
347
|
-
const browser = structuredClone(rawBrowser);
|
|
348
|
-
let browserChanged = false;
|
|
349
|
-
if ("relayBindHost" in browser) {
|
|
350
|
-
delete browser.relayBindHost;
|
|
351
|
-
browserChanged = true;
|
|
352
|
-
changes.push("Removed browser.relayBindHost (legacy Chrome extension relay setting; host-local Chrome now uses Chrome MCP existing-session attach).");
|
|
353
|
-
}
|
|
354
|
-
const rawProfiles = browser.profiles;
|
|
355
|
-
if (!isRecord(rawProfiles)) {
|
|
356
|
-
if (!browserChanged) return;
|
|
357
|
-
next = {
|
|
358
|
-
...next,
|
|
359
|
-
browser
|
|
360
|
-
};
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const profiles = { ...rawProfiles };
|
|
364
|
-
let profilesChanged = false;
|
|
365
|
-
for (const [profileName, rawProfile] of Object.entries(rawProfiles)) {
|
|
366
|
-
if (!isRecord(rawProfile)) continue;
|
|
367
|
-
if ((typeof rawProfile.driver === "string" ? rawProfile.driver.trim() : "") !== "extension") continue;
|
|
368
|
-
profiles[profileName] = {
|
|
369
|
-
...rawProfile,
|
|
370
|
-
driver: "existing-session"
|
|
371
|
-
};
|
|
372
|
-
profilesChanged = true;
|
|
373
|
-
changes.push(`Moved browser.profiles.${profileName}.driver "extension" → "existing-session" (Chrome MCP attach).`);
|
|
374
|
-
}
|
|
375
|
-
if (profilesChanged) {
|
|
376
|
-
browser.profiles = profiles;
|
|
377
|
-
browserChanged = true;
|
|
378
|
-
}
|
|
379
|
-
if (!browserChanged) return;
|
|
380
|
-
next = {
|
|
381
|
-
...next,
|
|
382
|
-
browser
|
|
383
|
-
};
|
|
384
|
-
};
|
|
385
|
-
const seedMissingDefaultAccountsFromSingleAccountBase = () => {
|
|
386
|
-
const channels = next.channels;
|
|
387
|
-
if (!channels) return;
|
|
388
|
-
let channelsChanged = false;
|
|
389
|
-
const nextChannels = { ...channels };
|
|
390
|
-
for (const [channelId, rawChannel] of Object.entries(channels)) {
|
|
391
|
-
if (!isRecord(rawChannel)) continue;
|
|
392
|
-
const rawAccounts = rawChannel.accounts;
|
|
393
|
-
if (!isRecord(rawAccounts)) continue;
|
|
394
|
-
const accountKeys = Object.keys(rawAccounts);
|
|
395
|
-
if (accountKeys.length === 0) continue;
|
|
396
|
-
if (accountKeys.some((key) => key.trim().toLowerCase() === "default")) continue;
|
|
397
|
-
const keysToMove = Object.entries(rawChannel).filter(([key, value]) => key !== "accounts" && key !== "enabled" && value !== void 0 && shouldMoveSingleAccountChannelKey({
|
|
398
|
-
channelKey: channelId,
|
|
399
|
-
key
|
|
400
|
-
})).map(([key]) => key);
|
|
401
|
-
if (keysToMove.length === 0) continue;
|
|
402
|
-
const defaultAccount = {};
|
|
403
|
-
for (const key of keysToMove) {
|
|
404
|
-
const value = rawChannel[key];
|
|
405
|
-
defaultAccount[key] = value && typeof value === "object" ? structuredClone(value) : value;
|
|
406
|
-
}
|
|
407
|
-
const nextChannel = { ...rawChannel };
|
|
408
|
-
for (const key of keysToMove) delete nextChannel[key];
|
|
409
|
-
nextChannel.accounts = {
|
|
410
|
-
...rawAccounts,
|
|
411
|
-
[DEFAULT_ACCOUNT_ID]: defaultAccount
|
|
412
|
-
};
|
|
413
|
-
nextChannels[channelId] = nextChannel;
|
|
414
|
-
channelsChanged = true;
|
|
415
|
-
changes.push(`Moved channels.${channelId} single-account top-level values into channels.${channelId}.accounts.default.`);
|
|
416
|
-
}
|
|
417
|
-
if (!channelsChanged) return;
|
|
418
|
-
next = {
|
|
419
|
-
...next,
|
|
420
|
-
channels: nextChannels
|
|
421
|
-
};
|
|
422
|
-
};
|
|
423
|
-
normalizeProvider("telegram");
|
|
424
|
-
normalizeProvider("slack");
|
|
425
|
-
normalizeProvider("discord");
|
|
426
|
-
seedMissingDefaultAccountsFromSingleAccountBase();
|
|
427
|
-
normalizeLegacyBrowserProfiles();
|
|
428
|
-
const normalizeBrowserSsrFPolicyAlias = () => {
|
|
429
|
-
const rawBrowser = next.browser;
|
|
430
|
-
if (!isRecord(rawBrowser)) return;
|
|
431
|
-
const rawSsrFPolicy = rawBrowser.ssrfPolicy;
|
|
432
|
-
if (!isRecord(rawSsrFPolicy) || !("allowPrivateNetwork" in rawSsrFPolicy)) return;
|
|
433
|
-
const legacyAllowPrivateNetwork = rawSsrFPolicy.allowPrivateNetwork;
|
|
434
|
-
const currentDangerousAllowPrivateNetwork = rawSsrFPolicy.dangerouslyAllowPrivateNetwork;
|
|
435
|
-
let resolvedDangerousAllowPrivateNetwork = currentDangerousAllowPrivateNetwork;
|
|
436
|
-
if (typeof legacyAllowPrivateNetwork === "boolean" || typeof currentDangerousAllowPrivateNetwork === "boolean") resolvedDangerousAllowPrivateNetwork = legacyAllowPrivateNetwork === true || currentDangerousAllowPrivateNetwork === true;
|
|
437
|
-
else if (currentDangerousAllowPrivateNetwork === void 0) resolvedDangerousAllowPrivateNetwork = legacyAllowPrivateNetwork;
|
|
438
|
-
const nextSsrFPolicy = { ...rawSsrFPolicy };
|
|
439
|
-
delete nextSsrFPolicy.allowPrivateNetwork;
|
|
440
|
-
if (resolvedDangerousAllowPrivateNetwork !== void 0) nextSsrFPolicy.dangerouslyAllowPrivateNetwork = resolvedDangerousAllowPrivateNetwork;
|
|
441
|
-
const migratedBrowser = { ...next.browser };
|
|
442
|
-
migratedBrowser.ssrfPolicy = nextSsrFPolicy;
|
|
443
|
-
next = {
|
|
444
|
-
...next,
|
|
445
|
-
browser: migratedBrowser
|
|
446
|
-
};
|
|
447
|
-
changes.push(`Moved browser.ssrfPolicy.allowPrivateNetwork → browser.ssrfPolicy.dangerouslyAllowPrivateNetwork (${String(resolvedDangerousAllowPrivateNetwork)}).`);
|
|
448
|
-
};
|
|
449
|
-
normalizeBrowserSsrFPolicyAlias();
|
|
450
|
-
const legacyAckReaction = cfg.messages?.ackReaction?.trim();
|
|
451
|
-
const hasWhatsAppConfig = cfg.channels?.whatsapp !== void 0;
|
|
452
|
-
if (legacyAckReaction && hasWhatsAppConfig) {
|
|
453
|
-
if (!(cfg.channels?.whatsapp?.ackReaction !== void 0)) {
|
|
454
|
-
const legacyScope = cfg.messages?.ackReactionScope ?? "group-mentions";
|
|
455
|
-
let direct = true;
|
|
456
|
-
let group = "mentions";
|
|
457
|
-
if (legacyScope === "all") {
|
|
458
|
-
direct = true;
|
|
459
|
-
group = "always";
|
|
460
|
-
} else if (legacyScope === "direct") {
|
|
461
|
-
direct = true;
|
|
462
|
-
group = "never";
|
|
463
|
-
} else if (legacyScope === "group-all") {
|
|
464
|
-
direct = false;
|
|
465
|
-
group = "always";
|
|
466
|
-
} else if (legacyScope === "group-mentions") {
|
|
467
|
-
direct = false;
|
|
468
|
-
group = "mentions";
|
|
469
|
-
}
|
|
470
|
-
next = {
|
|
471
|
-
...next,
|
|
472
|
-
channels: {
|
|
473
|
-
...next.channels,
|
|
474
|
-
whatsapp: {
|
|
475
|
-
...next.channels?.whatsapp,
|
|
476
|
-
ackReaction: {
|
|
477
|
-
emoji: legacyAckReaction,
|
|
478
|
-
direct,
|
|
479
|
-
group
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
changes.push(`Copied messages.ackReaction → channels.whatsapp.ackReaction (scope: ${legacyScope}).`);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return {
|
|
488
|
-
config: next,
|
|
489
|
-
changes
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
//#endregion
|
|
493
|
-
//#region src/infra/state-migrations.fs.ts
|
|
494
|
-
function safeReadDir(dir) {
|
|
495
|
-
try {
|
|
496
|
-
return fs.readdirSync(dir, { withFileTypes: true });
|
|
497
|
-
} catch {
|
|
498
|
-
return [];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
function existsDir(dir) {
|
|
502
|
-
try {
|
|
503
|
-
return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
|
|
504
|
-
} catch {
|
|
505
|
-
return false;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
function ensureDir(dir) {
|
|
509
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
510
|
-
}
|
|
511
|
-
function fileExists(p) {
|
|
512
|
-
try {
|
|
513
|
-
return fs.existsSync(p) && fs.statSync(p).isFile();
|
|
514
|
-
} catch {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
function isLegacyWhatsAppAuthFile(name) {
|
|
519
|
-
if (name === "creds.json" || name === "creds.json.bak") return true;
|
|
520
|
-
if (!name.endsWith(".json")) return false;
|
|
521
|
-
return /^(app-state-sync|session|sender-key|pre-key)-/.test(name);
|
|
522
|
-
}
|
|
523
|
-
function readSessionStoreJson5(storePath) {
|
|
524
|
-
try {
|
|
525
|
-
const raw = fs.readFileSync(storePath, "utf-8");
|
|
526
|
-
const parsed = JSON5.parse(raw);
|
|
527
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return {
|
|
528
|
-
store: parsed,
|
|
529
|
-
ok: true
|
|
530
|
-
};
|
|
531
|
-
} catch {}
|
|
532
|
-
return {
|
|
533
|
-
store: {},
|
|
534
|
-
ok: false
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
//#endregion
|
|
538
|
-
//#region src/infra/state-migrations.ts
|
|
539
|
-
let autoMigrateStateDirChecked = false;
|
|
540
|
-
function isSurfaceGroupKey(key) {
|
|
541
|
-
return key.includes(":group:") || key.includes(":channel:");
|
|
542
|
-
}
|
|
543
|
-
function isLegacyGroupKey(key) {
|
|
544
|
-
const trimmed = key.trim();
|
|
545
|
-
if (!trimmed) return false;
|
|
546
|
-
if (trimmed.startsWith("group:")) return true;
|
|
547
|
-
const lower = trimmed.toLowerCase();
|
|
548
|
-
if (!lower.includes("@g.us")) return false;
|
|
549
|
-
if (!trimmed.includes(":")) return true;
|
|
550
|
-
if (lower.startsWith("whatsapp:") && !trimmed.includes(":group:")) return true;
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
|
-
function buildFileCopyPreview(plan) {
|
|
554
|
-
return `- ${plan.label}: ${plan.sourcePath} → ${plan.targetPath}`;
|
|
555
|
-
}
|
|
556
|
-
async function runFileCopyPlans(plans) {
|
|
557
|
-
const changes = [];
|
|
558
|
-
const warnings = [];
|
|
559
|
-
for (const plan of plans) {
|
|
560
|
-
if (fileExists(plan.targetPath)) continue;
|
|
561
|
-
try {
|
|
562
|
-
ensureDir(path.dirname(plan.targetPath));
|
|
563
|
-
fs.copyFileSync(plan.sourcePath, plan.targetPath);
|
|
564
|
-
changes.push(`Copied ${plan.label} → ${plan.targetPath}`);
|
|
565
|
-
} catch (err) {
|
|
566
|
-
warnings.push(`Failed migrating ${plan.label} (${plan.sourcePath}): ${String(err)}`);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return {
|
|
570
|
-
changes,
|
|
571
|
-
warnings
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
function canonicalizeSessionKeyForAgent(params) {
|
|
575
|
-
const agentId = normalizeAgentId(params.agentId);
|
|
576
|
-
const raw = params.key.trim();
|
|
577
|
-
if (!raw) return raw;
|
|
578
|
-
if (raw.toLowerCase() === "global" || raw.toLowerCase() === "unknown") return raw.toLowerCase();
|
|
579
|
-
const canonicalMain = canonicalizeMainSessionAlias({
|
|
580
|
-
cfg: { session: {
|
|
581
|
-
scope: params.scope,
|
|
582
|
-
mainKey: params.mainKey
|
|
583
|
-
} },
|
|
584
|
-
agentId,
|
|
585
|
-
sessionKey: raw
|
|
586
|
-
});
|
|
587
|
-
if (canonicalMain !== raw) return canonicalMain.toLowerCase();
|
|
588
|
-
if (raw.toLowerCase().startsWith("agent:")) return raw.toLowerCase();
|
|
589
|
-
if (raw.toLowerCase().startsWith("subagent:")) return `agent:${agentId}:subagent:${raw.slice(9)}`.toLowerCase();
|
|
590
|
-
if (raw.startsWith("group:")) {
|
|
591
|
-
const id = raw.slice(6).trim();
|
|
592
|
-
if (!id) return raw;
|
|
593
|
-
return `agent:${agentId}:${id.toLowerCase().includes("@g.us") ? "whatsapp" : "unknown"}:group:${id}`.toLowerCase();
|
|
594
|
-
}
|
|
595
|
-
if (!raw.includes(":") && raw.toLowerCase().includes("@g.us")) return `agent:${agentId}:whatsapp:group:${raw}`.toLowerCase();
|
|
596
|
-
if (raw.toLowerCase().startsWith("whatsapp:") && raw.toLowerCase().includes("@g.us")) {
|
|
597
|
-
const cleaned = raw.slice(9).trim().replace(/^group:/i, "").trim();
|
|
598
|
-
if (cleaned && !isSurfaceGroupKey(raw)) return `agent:${agentId}:whatsapp:group:${cleaned}`.toLowerCase();
|
|
599
|
-
}
|
|
600
|
-
if (isSurfaceGroupKey(raw)) return `agent:${agentId}:${raw}`.toLowerCase();
|
|
601
|
-
return `agent:${agentId}:${raw}`.toLowerCase();
|
|
602
|
-
}
|
|
603
|
-
function pickLatestLegacyDirectEntry(store) {
|
|
604
|
-
let best = null;
|
|
605
|
-
let bestUpdated = -1;
|
|
606
|
-
for (const [key, entry] of Object.entries(store)) {
|
|
607
|
-
if (!entry || typeof entry !== "object") continue;
|
|
608
|
-
const normalized = key.trim();
|
|
609
|
-
if (!normalized) continue;
|
|
610
|
-
if (normalized === "global") continue;
|
|
611
|
-
if (normalized.startsWith("agent:")) continue;
|
|
612
|
-
if (normalized.toLowerCase().startsWith("subagent:")) continue;
|
|
613
|
-
if (isLegacyGroupKey(normalized) || isSurfaceGroupKey(normalized)) continue;
|
|
614
|
-
const updatedAt = typeof entry.updatedAt === "number" ? entry.updatedAt : 0;
|
|
615
|
-
if (updatedAt > bestUpdated) {
|
|
616
|
-
bestUpdated = updatedAt;
|
|
617
|
-
best = entry;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
return best;
|
|
621
|
-
}
|
|
622
|
-
function normalizeSessionEntry(entry) {
|
|
623
|
-
const sessionId = typeof entry.sessionId === "string" ? entry.sessionId : null;
|
|
624
|
-
if (!sessionId) return null;
|
|
625
|
-
const updatedAt = typeof entry.updatedAt === "number" && Number.isFinite(entry.updatedAt) ? entry.updatedAt : Date.now();
|
|
626
|
-
const normalized = {
|
|
627
|
-
...entry,
|
|
628
|
-
sessionId,
|
|
629
|
-
updatedAt
|
|
630
|
-
};
|
|
631
|
-
const rec = normalized;
|
|
632
|
-
if (typeof rec.groupChannel !== "string" && typeof rec.room === "string") rec.groupChannel = rec.room;
|
|
633
|
-
delete rec.room;
|
|
634
|
-
return normalized;
|
|
635
|
-
}
|
|
636
|
-
function resolveUpdatedAt(entry) {
|
|
637
|
-
return typeof entry.updatedAt === "number" && Number.isFinite(entry.updatedAt) ? entry.updatedAt : 0;
|
|
638
|
-
}
|
|
639
|
-
function mergeSessionEntry(params) {
|
|
640
|
-
if (!params.existing) return params.incoming;
|
|
641
|
-
const existingUpdated = resolveUpdatedAt(params.existing);
|
|
642
|
-
const incomingUpdated = resolveUpdatedAt(params.incoming);
|
|
643
|
-
if (incomingUpdated > existingUpdated) return params.incoming;
|
|
644
|
-
if (incomingUpdated < existingUpdated) return params.existing;
|
|
645
|
-
return params.preferIncomingOnTie ? params.incoming : params.existing;
|
|
646
|
-
}
|
|
647
|
-
function canonicalizeSessionStore(params) {
|
|
648
|
-
const canonical = {};
|
|
649
|
-
const meta = /* @__PURE__ */ new Map();
|
|
650
|
-
const legacyKeys = [];
|
|
651
|
-
for (const [key, entry] of Object.entries(params.store)) {
|
|
652
|
-
if (!entry || typeof entry !== "object") continue;
|
|
653
|
-
const canonicalKey = canonicalizeSessionKeyForAgent({
|
|
654
|
-
key,
|
|
655
|
-
agentId: params.agentId,
|
|
656
|
-
mainKey: params.mainKey,
|
|
657
|
-
scope: params.scope
|
|
658
|
-
});
|
|
659
|
-
const isCanonical = canonicalKey === key;
|
|
660
|
-
if (!isCanonical) legacyKeys.push(key);
|
|
661
|
-
const existing = canonical[canonicalKey];
|
|
662
|
-
if (!existing) {
|
|
663
|
-
canonical[canonicalKey] = entry;
|
|
664
|
-
meta.set(canonicalKey, {
|
|
665
|
-
isCanonical,
|
|
666
|
-
updatedAt: resolveUpdatedAt(entry)
|
|
667
|
-
});
|
|
668
|
-
continue;
|
|
669
|
-
}
|
|
670
|
-
const existingMeta = meta.get(canonicalKey);
|
|
671
|
-
const incomingUpdated = resolveUpdatedAt(entry);
|
|
672
|
-
const existingUpdated = existingMeta?.updatedAt ?? resolveUpdatedAt(existing);
|
|
673
|
-
if (incomingUpdated > existingUpdated) {
|
|
674
|
-
canonical[canonicalKey] = entry;
|
|
675
|
-
meta.set(canonicalKey, {
|
|
676
|
-
isCanonical,
|
|
677
|
-
updatedAt: incomingUpdated
|
|
678
|
-
});
|
|
679
|
-
continue;
|
|
680
|
-
}
|
|
681
|
-
if (incomingUpdated < existingUpdated) continue;
|
|
682
|
-
if (existingMeta?.isCanonical && !isCanonical) continue;
|
|
683
|
-
if (!existingMeta?.isCanonical && isCanonical) {
|
|
684
|
-
canonical[canonicalKey] = entry;
|
|
685
|
-
meta.set(canonicalKey, {
|
|
686
|
-
isCanonical,
|
|
687
|
-
updatedAt: incomingUpdated
|
|
688
|
-
});
|
|
689
|
-
continue;
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
return {
|
|
693
|
-
store: canonical,
|
|
694
|
-
legacyKeys
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
function listLegacySessionKeys(params) {
|
|
698
|
-
const legacy = [];
|
|
699
|
-
for (const key of Object.keys(params.store)) if (canonicalizeSessionKeyForAgent({
|
|
700
|
-
key,
|
|
701
|
-
agentId: params.agentId,
|
|
702
|
-
mainKey: params.mainKey,
|
|
703
|
-
scope: params.scope
|
|
704
|
-
}) !== key) legacy.push(key);
|
|
705
|
-
return legacy;
|
|
706
|
-
}
|
|
707
|
-
function emptyDirOrMissing(dir) {
|
|
708
|
-
if (!existsDir(dir)) return true;
|
|
709
|
-
return safeReadDir(dir).length === 0;
|
|
710
|
-
}
|
|
711
|
-
function removeDirIfEmpty(dir) {
|
|
712
|
-
if (!existsDir(dir)) return;
|
|
713
|
-
if (!emptyDirOrMissing(dir)) return;
|
|
714
|
-
try {
|
|
715
|
-
fs.rmdirSync(dir);
|
|
716
|
-
} catch {}
|
|
717
|
-
}
|
|
718
|
-
function resolveSymlinkTarget(linkPath) {
|
|
719
|
-
try {
|
|
720
|
-
const target = fs.readlinkSync(linkPath);
|
|
721
|
-
return path.resolve(path.dirname(linkPath), target);
|
|
722
|
-
} catch {
|
|
723
|
-
return null;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
function formatStateDirMigration(legacyDir, targetDir) {
|
|
727
|
-
return `State dir: ${legacyDir} → ${targetDir} (legacy path now symlinked)`;
|
|
728
|
-
}
|
|
729
|
-
function isDirPath(filePath) {
|
|
730
|
-
try {
|
|
731
|
-
return fs.statSync(filePath).isDirectory();
|
|
732
|
-
} catch {
|
|
733
|
-
return false;
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
function isLegacyTreeSymlinkMirror(currentDir, realTargetDir) {
|
|
737
|
-
let entries;
|
|
738
|
-
try {
|
|
739
|
-
entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
740
|
-
} catch {
|
|
741
|
-
return false;
|
|
742
|
-
}
|
|
743
|
-
if (entries.length === 0) return false;
|
|
744
|
-
for (const entry of entries) {
|
|
745
|
-
const entryPath = path.join(currentDir, entry.name);
|
|
746
|
-
let stat;
|
|
747
|
-
try {
|
|
748
|
-
stat = fs.lstatSync(entryPath);
|
|
749
|
-
} catch {
|
|
750
|
-
return false;
|
|
751
|
-
}
|
|
752
|
-
if (stat.isSymbolicLink()) {
|
|
753
|
-
const resolvedTarget = resolveSymlinkTarget(entryPath);
|
|
754
|
-
if (!resolvedTarget) return false;
|
|
755
|
-
let resolvedRealTarget;
|
|
756
|
-
try {
|
|
757
|
-
resolvedRealTarget = fs.realpathSync(resolvedTarget);
|
|
758
|
-
} catch {
|
|
759
|
-
return false;
|
|
760
|
-
}
|
|
761
|
-
if (!isWithinDir(realTargetDir, resolvedRealTarget)) return false;
|
|
762
|
-
continue;
|
|
763
|
-
}
|
|
764
|
-
if (stat.isDirectory()) {
|
|
765
|
-
if (!isLegacyTreeSymlinkMirror(entryPath, realTargetDir)) return false;
|
|
766
|
-
continue;
|
|
767
|
-
}
|
|
768
|
-
return false;
|
|
769
|
-
}
|
|
770
|
-
return true;
|
|
771
|
-
}
|
|
772
|
-
function isLegacyDirSymlinkMirror(legacyDir, targetDir) {
|
|
773
|
-
let realTargetDir;
|
|
774
|
-
try {
|
|
775
|
-
realTargetDir = fs.realpathSync(targetDir);
|
|
776
|
-
} catch {
|
|
777
|
-
return false;
|
|
778
|
-
}
|
|
779
|
-
return isLegacyTreeSymlinkMirror(legacyDir, realTargetDir);
|
|
780
|
-
}
|
|
781
|
-
async function autoMigrateLegacyStateDir(params) {
|
|
782
|
-
if (autoMigrateStateDirChecked) return {
|
|
783
|
-
migrated: false,
|
|
784
|
-
skipped: true,
|
|
785
|
-
changes: [],
|
|
786
|
-
warnings: []
|
|
787
|
-
};
|
|
788
|
-
autoMigrateStateDirChecked = true;
|
|
789
|
-
if ((params.env ?? process.env).MOLDCLAW_STATE_DIR?.trim()) return {
|
|
790
|
-
migrated: false,
|
|
791
|
-
skipped: true,
|
|
792
|
-
changes: [],
|
|
793
|
-
warnings: []
|
|
794
|
-
};
|
|
795
|
-
const homedir = params.homedir ?? os.homedir;
|
|
796
|
-
const targetDir = resolveNewStateDir(homedir);
|
|
797
|
-
const legacyDirs = resolveLegacyStateDirs(homedir);
|
|
798
|
-
let legacyDir = legacyDirs.find((dir) => {
|
|
799
|
-
try {
|
|
800
|
-
return fs.existsSync(dir);
|
|
801
|
-
} catch {
|
|
802
|
-
return false;
|
|
803
|
-
}
|
|
804
|
-
});
|
|
805
|
-
const warnings = [];
|
|
806
|
-
const changes = [];
|
|
807
|
-
let legacyStat = null;
|
|
808
|
-
try {
|
|
809
|
-
legacyStat = legacyDir ? fs.lstatSync(legacyDir) : null;
|
|
810
|
-
} catch {
|
|
811
|
-
legacyStat = null;
|
|
812
|
-
}
|
|
813
|
-
if (!legacyStat) return {
|
|
814
|
-
migrated: false,
|
|
815
|
-
skipped: false,
|
|
816
|
-
changes,
|
|
817
|
-
warnings
|
|
818
|
-
};
|
|
819
|
-
if (!legacyStat.isDirectory() && !legacyStat.isSymbolicLink()) {
|
|
820
|
-
warnings.push(`Legacy state path is not a directory: ${legacyDir}`);
|
|
821
|
-
return {
|
|
822
|
-
migrated: false,
|
|
823
|
-
skipped: false,
|
|
824
|
-
changes,
|
|
825
|
-
warnings
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
let symlinkDepth = 0;
|
|
829
|
-
while (legacyStat.isSymbolicLink()) {
|
|
830
|
-
const legacyTarget = legacyDir ? resolveSymlinkTarget(legacyDir) : null;
|
|
831
|
-
if (!legacyTarget) {
|
|
832
|
-
warnings.push(`Legacy state dir is a symlink (${legacyDir ?? "unknown"}); could not resolve target.`);
|
|
833
|
-
return {
|
|
834
|
-
migrated: false,
|
|
835
|
-
skipped: false,
|
|
836
|
-
changes,
|
|
837
|
-
warnings
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
if (path.resolve(legacyTarget) === path.resolve(targetDir)) return {
|
|
841
|
-
migrated: false,
|
|
842
|
-
skipped: false,
|
|
843
|
-
changes,
|
|
844
|
-
warnings
|
|
845
|
-
};
|
|
846
|
-
if (legacyDirs.some((dir) => path.resolve(dir) === path.resolve(legacyTarget))) {
|
|
847
|
-
legacyDir = legacyTarget;
|
|
848
|
-
try {
|
|
849
|
-
legacyStat = fs.lstatSync(legacyDir);
|
|
850
|
-
} catch {
|
|
851
|
-
legacyStat = null;
|
|
852
|
-
}
|
|
853
|
-
if (!legacyStat) {
|
|
854
|
-
warnings.push(`Legacy state dir missing after symlink resolution: ${legacyDir}`);
|
|
855
|
-
return {
|
|
856
|
-
migrated: false,
|
|
857
|
-
skipped: false,
|
|
858
|
-
changes,
|
|
859
|
-
warnings
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
if (!legacyStat.isDirectory() && !legacyStat.isSymbolicLink()) {
|
|
863
|
-
warnings.push(`Legacy state path is not a directory: ${legacyDir}`);
|
|
864
|
-
return {
|
|
865
|
-
migrated: false,
|
|
866
|
-
skipped: false,
|
|
867
|
-
changes,
|
|
868
|
-
warnings
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
symlinkDepth += 1;
|
|
872
|
-
if (symlinkDepth > 2) {
|
|
873
|
-
warnings.push(`Legacy state dir symlink chain too deep: ${legacyDir}`);
|
|
874
|
-
return {
|
|
875
|
-
migrated: false,
|
|
876
|
-
skipped: false,
|
|
877
|
-
changes,
|
|
878
|
-
warnings
|
|
879
|
-
};
|
|
880
|
-
}
|
|
881
|
-
continue;
|
|
882
|
-
}
|
|
883
|
-
warnings.push(`Legacy state dir is a symlink (${legacyDir ?? "unknown"} → ${legacyTarget}); skipping auto-migration.`);
|
|
884
|
-
return {
|
|
885
|
-
migrated: false,
|
|
886
|
-
skipped: false,
|
|
887
|
-
changes,
|
|
888
|
-
warnings
|
|
889
|
-
};
|
|
890
|
-
}
|
|
891
|
-
if (isDirPath(targetDir)) {
|
|
892
|
-
if (legacyDir && isLegacyDirSymlinkMirror(legacyDir, targetDir)) return {
|
|
893
|
-
migrated: false,
|
|
894
|
-
skipped: false,
|
|
895
|
-
changes,
|
|
896
|
-
warnings
|
|
897
|
-
};
|
|
898
|
-
warnings.push(`State dir migration skipped: target already exists (${targetDir}). Remove or merge manually.`);
|
|
899
|
-
return {
|
|
900
|
-
migrated: false,
|
|
901
|
-
skipped: false,
|
|
902
|
-
changes,
|
|
903
|
-
warnings
|
|
904
|
-
};
|
|
905
|
-
}
|
|
906
|
-
try {
|
|
907
|
-
if (!legacyDir) throw new Error("Legacy state dir not found");
|
|
908
|
-
fs.renameSync(legacyDir, targetDir);
|
|
909
|
-
} catch (err) {
|
|
910
|
-
warnings.push(`Failed to move legacy state dir (${legacyDir ?? "unknown"} → ${targetDir}): ${String(err)}`);
|
|
911
|
-
return {
|
|
912
|
-
migrated: false,
|
|
913
|
-
skipped: false,
|
|
914
|
-
changes,
|
|
915
|
-
warnings
|
|
916
|
-
};
|
|
917
|
-
}
|
|
918
|
-
try {
|
|
919
|
-
if (!legacyDir) throw new Error("Legacy state dir not found");
|
|
920
|
-
fs.symlinkSync(targetDir, legacyDir, "dir");
|
|
921
|
-
changes.push(formatStateDirMigration(legacyDir, targetDir));
|
|
922
|
-
} catch (err) {
|
|
923
|
-
try {
|
|
924
|
-
if (process.platform === "win32") {
|
|
925
|
-
if (!legacyDir) throw new Error("Legacy state dir not found", { cause: err });
|
|
926
|
-
fs.symlinkSync(targetDir, legacyDir, "junction");
|
|
927
|
-
changes.push(formatStateDirMigration(legacyDir, targetDir));
|
|
928
|
-
} else throw err;
|
|
929
|
-
} catch (fallbackErr) {
|
|
930
|
-
try {
|
|
931
|
-
if (!legacyDir) throw new Error("Legacy state dir not found", { cause: fallbackErr });
|
|
932
|
-
fs.renameSync(targetDir, legacyDir);
|
|
933
|
-
warnings.push(`State dir migration rolled back (failed to link legacy path): ${String(fallbackErr)}`);
|
|
934
|
-
return {
|
|
935
|
-
migrated: false,
|
|
936
|
-
skipped: false,
|
|
937
|
-
changes: [],
|
|
938
|
-
warnings
|
|
939
|
-
};
|
|
940
|
-
} catch (rollbackErr) {
|
|
941
|
-
warnings.push(`State dir moved but failed to link legacy path (${legacyDir ?? "unknown"} → ${targetDir}): ${String(fallbackErr)}`);
|
|
942
|
-
warnings.push(`Rollback failed; set MOLDCLAW_STATE_DIR=${targetDir} to avoid split state: ${String(rollbackErr)}`);
|
|
943
|
-
changes.push(`State dir: ${legacyDir ?? "unknown"} → ${targetDir}`);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
return {
|
|
948
|
-
migrated: changes.length > 0,
|
|
949
|
-
skipped: false,
|
|
950
|
-
changes,
|
|
951
|
-
warnings
|
|
952
|
-
};
|
|
953
|
-
}
|
|
954
|
-
async function detectLegacyStateMigrations(params) {
|
|
955
|
-
const env = params.env ?? process.env;
|
|
956
|
-
const stateDir = resolveStateDir(env, params.homedir ?? os.homedir);
|
|
957
|
-
const oauthDir = resolveOAuthDir(env, stateDir);
|
|
958
|
-
const targetAgentId = normalizeAgentId(resolveDefaultAgentId(params.cfg));
|
|
959
|
-
const rawMainKey = params.cfg.session?.mainKey;
|
|
960
|
-
const targetMainKey = typeof rawMainKey === "string" && rawMainKey.trim().length > 0 ? rawMainKey.trim() : DEFAULT_MAIN_KEY;
|
|
961
|
-
const targetScope = params.cfg.session?.scope;
|
|
962
|
-
const sessionsLegacyDir = path.join(stateDir, "sessions");
|
|
963
|
-
const sessionsLegacyStorePath = path.join(sessionsLegacyDir, "sessions.json");
|
|
964
|
-
const sessionsTargetDir = path.join(stateDir, "agents", targetAgentId, "sessions");
|
|
965
|
-
const sessionsTargetStorePath = path.join(sessionsTargetDir, "sessions.json");
|
|
966
|
-
const legacySessionEntries = safeReadDir(sessionsLegacyDir);
|
|
967
|
-
const hasLegacySessions = fileExists(sessionsLegacyStorePath) || legacySessionEntries.some((e) => e.isFile() && e.name.endsWith(".jsonl"));
|
|
968
|
-
const targetSessionParsed = fileExists(sessionsTargetStorePath) ? readSessionStoreJson5(sessionsTargetStorePath) : {
|
|
969
|
-
store: {},
|
|
970
|
-
ok: true
|
|
971
|
-
};
|
|
972
|
-
const legacyKeys = targetSessionParsed.ok ? listLegacySessionKeys({
|
|
973
|
-
store: targetSessionParsed.store,
|
|
974
|
-
agentId: targetAgentId,
|
|
975
|
-
mainKey: targetMainKey,
|
|
976
|
-
scope: targetScope
|
|
977
|
-
}) : [];
|
|
978
|
-
const legacyAgentDir = path.join(stateDir, "agent");
|
|
979
|
-
const targetAgentDir = path.join(stateDir, "agents", targetAgentId, "agent");
|
|
980
|
-
const hasLegacyAgentDir = existsDir(legacyAgentDir);
|
|
981
|
-
const targetWhatsAppAuthDir = path.join(oauthDir, "whatsapp", DEFAULT_ACCOUNT_ID);
|
|
982
|
-
const hasLegacyWhatsAppAuth = fileExists(path.join(oauthDir, "creds.json")) && !fileExists(path.join(targetWhatsAppAuthDir, "creds.json"));
|
|
983
|
-
const legacyTelegramAllowFromPath = resolveChannelAllowFromPath("telegram", env);
|
|
984
|
-
const telegramPairingAllowFromPlans = fileExists(legacyTelegramAllowFromPath) ? Array.from(new Set(listTelegramAccountIds(params.cfg).map((accountId) => resolveChannelAllowFromPath("telegram", env, accountId)))).filter((targetPath) => !fileExists(targetPath)).map((targetPath) => ({
|
|
985
|
-
label: "Telegram pairing allowFrom",
|
|
986
|
-
sourcePath: legacyTelegramAllowFromPath,
|
|
987
|
-
targetPath
|
|
988
|
-
})) : [];
|
|
989
|
-
const hasLegacyTelegramAllowFrom = telegramPairingAllowFromPlans.length > 0;
|
|
990
|
-
const preview = [];
|
|
991
|
-
if (hasLegacySessions) preview.push(`- Sessions: ${sessionsLegacyDir} → ${sessionsTargetDir}`);
|
|
992
|
-
if (legacyKeys.length > 0) preview.push(`- Sessions: canonicalize legacy keys in ${sessionsTargetStorePath}`);
|
|
993
|
-
if (hasLegacyAgentDir) preview.push(`- Agent dir: ${legacyAgentDir} → ${targetAgentDir}`);
|
|
994
|
-
if (hasLegacyWhatsAppAuth) preview.push(`- WhatsApp auth: ${oauthDir} → ${targetWhatsAppAuthDir} (keep oauth.json)`);
|
|
995
|
-
if (hasLegacyTelegramAllowFrom) preview.push(...telegramPairingAllowFromPlans.map(buildFileCopyPreview));
|
|
996
|
-
return {
|
|
997
|
-
targetAgentId,
|
|
998
|
-
targetMainKey,
|
|
999
|
-
targetScope,
|
|
1000
|
-
stateDir,
|
|
1001
|
-
oauthDir,
|
|
1002
|
-
sessions: {
|
|
1003
|
-
legacyDir: sessionsLegacyDir,
|
|
1004
|
-
legacyStorePath: sessionsLegacyStorePath,
|
|
1005
|
-
targetDir: sessionsTargetDir,
|
|
1006
|
-
targetStorePath: sessionsTargetStorePath,
|
|
1007
|
-
hasLegacy: hasLegacySessions || legacyKeys.length > 0,
|
|
1008
|
-
legacyKeys
|
|
1009
|
-
},
|
|
1010
|
-
agentDir: {
|
|
1011
|
-
legacyDir: legacyAgentDir,
|
|
1012
|
-
targetDir: targetAgentDir,
|
|
1013
|
-
hasLegacy: hasLegacyAgentDir
|
|
1014
|
-
},
|
|
1015
|
-
whatsappAuth: {
|
|
1016
|
-
legacyDir: oauthDir,
|
|
1017
|
-
targetDir: targetWhatsAppAuthDir,
|
|
1018
|
-
hasLegacy: hasLegacyWhatsAppAuth
|
|
1019
|
-
},
|
|
1020
|
-
pairingAllowFrom: {
|
|
1021
|
-
hasLegacyTelegram: hasLegacyTelegramAllowFrom,
|
|
1022
|
-
copyPlans: telegramPairingAllowFromPlans
|
|
1023
|
-
},
|
|
1024
|
-
preview
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
async function migrateLegacySessions(detected, now) {
|
|
1028
|
-
const changes = [];
|
|
1029
|
-
const warnings = [];
|
|
1030
|
-
if (!detected.sessions.hasLegacy) return {
|
|
1031
|
-
changes,
|
|
1032
|
-
warnings
|
|
1033
|
-
};
|
|
1034
|
-
ensureDir(detected.sessions.targetDir);
|
|
1035
|
-
const legacyParsed = fileExists(detected.sessions.legacyStorePath) ? readSessionStoreJson5(detected.sessions.legacyStorePath) : {
|
|
1036
|
-
store: {},
|
|
1037
|
-
ok: true
|
|
1038
|
-
};
|
|
1039
|
-
const targetParsed = fileExists(detected.sessions.targetStorePath) ? readSessionStoreJson5(detected.sessions.targetStorePath) : {
|
|
1040
|
-
store: {},
|
|
1041
|
-
ok: true
|
|
1042
|
-
};
|
|
1043
|
-
const legacyStore = legacyParsed.store;
|
|
1044
|
-
const targetStore = targetParsed.store;
|
|
1045
|
-
const canonicalizedTarget = canonicalizeSessionStore({
|
|
1046
|
-
store: targetStore,
|
|
1047
|
-
agentId: detected.targetAgentId,
|
|
1048
|
-
mainKey: detected.targetMainKey,
|
|
1049
|
-
scope: detected.targetScope
|
|
1050
|
-
});
|
|
1051
|
-
const canonicalizedLegacy = canonicalizeSessionStore({
|
|
1052
|
-
store: legacyStore,
|
|
1053
|
-
agentId: detected.targetAgentId,
|
|
1054
|
-
mainKey: detected.targetMainKey,
|
|
1055
|
-
scope: detected.targetScope
|
|
1056
|
-
});
|
|
1057
|
-
const merged = { ...canonicalizedTarget.store };
|
|
1058
|
-
for (const [key, entry] of Object.entries(canonicalizedLegacy.store)) merged[key] = mergeSessionEntry({
|
|
1059
|
-
existing: merged[key],
|
|
1060
|
-
incoming: entry,
|
|
1061
|
-
preferIncomingOnTie: false
|
|
1062
|
-
});
|
|
1063
|
-
const mainKey = buildAgentMainSessionKey({
|
|
1064
|
-
agentId: detected.targetAgentId,
|
|
1065
|
-
mainKey: detected.targetMainKey
|
|
1066
|
-
});
|
|
1067
|
-
if (!merged[mainKey]) {
|
|
1068
|
-
const latest = pickLatestLegacyDirectEntry(legacyStore);
|
|
1069
|
-
if (latest?.sessionId) {
|
|
1070
|
-
merged[mainKey] = latest;
|
|
1071
|
-
changes.push(`Migrated latest direct-chat session → ${mainKey}`);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
if (!legacyParsed.ok) warnings.push(`Legacy sessions store unreadable; left in place at ${detected.sessions.legacyStorePath}`);
|
|
1075
|
-
if ((legacyParsed.ok || targetParsed.ok) && (Object.keys(legacyStore).length > 0 || Object.keys(targetStore).length > 0)) {
|
|
1076
|
-
const normalized = {};
|
|
1077
|
-
for (const [key, entry] of Object.entries(merged)) {
|
|
1078
|
-
const normalizedEntry = normalizeSessionEntry(entry);
|
|
1079
|
-
if (!normalizedEntry) continue;
|
|
1080
|
-
normalized[key] = normalizedEntry;
|
|
1081
|
-
}
|
|
1082
|
-
await saveSessionStore(detected.sessions.targetStorePath, normalized, { skipMaintenance: true });
|
|
1083
|
-
changes.push(`Merged sessions store → ${detected.sessions.targetStorePath}`);
|
|
1084
|
-
if (canonicalizedTarget.legacyKeys.length > 0) changes.push(`Canonicalized ${canonicalizedTarget.legacyKeys.length} legacy session key(s)`);
|
|
1085
|
-
}
|
|
1086
|
-
const entries = safeReadDir(detected.sessions.legacyDir);
|
|
1087
|
-
for (const entry of entries) {
|
|
1088
|
-
if (!entry.isFile()) continue;
|
|
1089
|
-
if (entry.name === "sessions.json") continue;
|
|
1090
|
-
const from = path.join(detected.sessions.legacyDir, entry.name);
|
|
1091
|
-
const to = path.join(detected.sessions.targetDir, entry.name);
|
|
1092
|
-
if (fileExists(to)) continue;
|
|
1093
|
-
try {
|
|
1094
|
-
fs.renameSync(from, to);
|
|
1095
|
-
changes.push(`Moved ${entry.name} → agents/${detected.targetAgentId}/sessions`);
|
|
1096
|
-
} catch (err) {
|
|
1097
|
-
warnings.push(`Failed moving ${from}: ${String(err)}`);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
if (legacyParsed.ok) try {
|
|
1101
|
-
if (fileExists(detected.sessions.legacyStorePath)) fs.rmSync(detected.sessions.legacyStorePath, { force: true });
|
|
1102
|
-
} catch {}
|
|
1103
|
-
removeDirIfEmpty(detected.sessions.legacyDir);
|
|
1104
|
-
if (safeReadDir(detected.sessions.legacyDir).filter((e) => e.isFile()).length > 0) {
|
|
1105
|
-
const backupDir = `${detected.sessions.legacyDir}.legacy-${now()}`;
|
|
1106
|
-
try {
|
|
1107
|
-
fs.renameSync(detected.sessions.legacyDir, backupDir);
|
|
1108
|
-
warnings.push(`Left legacy sessions at ${backupDir}`);
|
|
1109
|
-
} catch {}
|
|
1110
|
-
}
|
|
1111
|
-
return {
|
|
1112
|
-
changes,
|
|
1113
|
-
warnings
|
|
1114
|
-
};
|
|
1115
|
-
}
|
|
1116
|
-
async function migrateLegacyAgentDir(detected, now) {
|
|
1117
|
-
const changes = [];
|
|
1118
|
-
const warnings = [];
|
|
1119
|
-
if (!detected.agentDir.hasLegacy) return {
|
|
1120
|
-
changes,
|
|
1121
|
-
warnings
|
|
1122
|
-
};
|
|
1123
|
-
ensureDir(detected.agentDir.targetDir);
|
|
1124
|
-
const entries = safeReadDir(detected.agentDir.legacyDir);
|
|
1125
|
-
for (const entry of entries) {
|
|
1126
|
-
const from = path.join(detected.agentDir.legacyDir, entry.name);
|
|
1127
|
-
const to = path.join(detected.agentDir.targetDir, entry.name);
|
|
1128
|
-
if (fs.existsSync(to)) continue;
|
|
1129
|
-
try {
|
|
1130
|
-
fs.renameSync(from, to);
|
|
1131
|
-
changes.push(`Moved agent file ${entry.name} → agents/${detected.targetAgentId}/agent`);
|
|
1132
|
-
} catch (err) {
|
|
1133
|
-
warnings.push(`Failed moving ${from}: ${String(err)}`);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
removeDirIfEmpty(detected.agentDir.legacyDir);
|
|
1137
|
-
if (!emptyDirOrMissing(detected.agentDir.legacyDir)) {
|
|
1138
|
-
const backupDir = path.join(detected.stateDir, "agents", detected.targetAgentId, `agent.legacy-${now()}`);
|
|
1139
|
-
try {
|
|
1140
|
-
fs.renameSync(detected.agentDir.legacyDir, backupDir);
|
|
1141
|
-
warnings.push(`Left legacy agent dir at ${backupDir}`);
|
|
1142
|
-
} catch (err) {
|
|
1143
|
-
warnings.push(`Failed relocating legacy agent dir: ${String(err)}`);
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
return {
|
|
1147
|
-
changes,
|
|
1148
|
-
warnings
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
async function migrateLegacyWhatsAppAuth(detected) {
|
|
1152
|
-
const changes = [];
|
|
1153
|
-
const warnings = [];
|
|
1154
|
-
if (!detected.whatsappAuth.hasLegacy) return {
|
|
1155
|
-
changes,
|
|
1156
|
-
warnings
|
|
1157
|
-
};
|
|
1158
|
-
ensureDir(detected.whatsappAuth.targetDir);
|
|
1159
|
-
const entries = safeReadDir(detected.whatsappAuth.legacyDir);
|
|
1160
|
-
for (const entry of entries) {
|
|
1161
|
-
if (!entry.isFile()) continue;
|
|
1162
|
-
if (entry.name === "oauth.json") continue;
|
|
1163
|
-
if (!isLegacyWhatsAppAuthFile(entry.name)) continue;
|
|
1164
|
-
const from = path.join(detected.whatsappAuth.legacyDir, entry.name);
|
|
1165
|
-
const to = path.join(detected.whatsappAuth.targetDir, entry.name);
|
|
1166
|
-
if (fileExists(to)) continue;
|
|
1167
|
-
try {
|
|
1168
|
-
fs.renameSync(from, to);
|
|
1169
|
-
changes.push(`Moved WhatsApp auth ${entry.name} → whatsapp/default`);
|
|
1170
|
-
} catch (err) {
|
|
1171
|
-
warnings.push(`Failed moving ${from}: ${String(err)}`);
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
return {
|
|
1175
|
-
changes,
|
|
1176
|
-
warnings
|
|
1177
|
-
};
|
|
1178
|
-
}
|
|
1179
|
-
async function migrateLegacyTelegramPairingAllowFrom(detected) {
|
|
1180
|
-
const changes = [];
|
|
1181
|
-
const warnings = [];
|
|
1182
|
-
if (!detected.pairingAllowFrom.hasLegacyTelegram) return {
|
|
1183
|
-
changes,
|
|
1184
|
-
warnings
|
|
1185
|
-
};
|
|
1186
|
-
return await runFileCopyPlans(detected.pairingAllowFrom.copyPlans);
|
|
1187
|
-
}
|
|
1188
|
-
async function runLegacyStateMigrations(params) {
|
|
1189
|
-
const now = params.now ?? (() => Date.now());
|
|
1190
|
-
const detected = params.detected;
|
|
1191
|
-
const sessions = await migrateLegacySessions(detected, now);
|
|
1192
|
-
const agentDir = await migrateLegacyAgentDir(detected, now);
|
|
1193
|
-
const whatsappAuth = await migrateLegacyWhatsAppAuth(detected);
|
|
1194
|
-
const telegramPairingAllowFrom = await migrateLegacyTelegramPairingAllowFrom(detected);
|
|
1195
|
-
return {
|
|
1196
|
-
changes: [
|
|
1197
|
-
...sessions.changes,
|
|
1198
|
-
...agentDir.changes,
|
|
1199
|
-
...whatsappAuth.changes,
|
|
1200
|
-
...telegramPairingAllowFrom.changes
|
|
1201
|
-
],
|
|
1202
|
-
warnings: [
|
|
1203
|
-
...sessions.warnings,
|
|
1204
|
-
...agentDir.warnings,
|
|
1205
|
-
...whatsappAuth.warnings,
|
|
1206
|
-
...telegramPairingAllowFrom.warnings
|
|
1207
|
-
]
|
|
1208
|
-
};
|
|
1209
|
-
}
|
|
1210
|
-
//#endregion
|
|
1211
|
-
//#region src/commands/doctor-config-flow.ts
|
|
1212
|
-
function asObjectRecord(value) {
|
|
1213
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1214
|
-
return value;
|
|
1215
|
-
}
|
|
1216
|
-
function normalizeBindingChannelKey(raw) {
|
|
1217
|
-
const normalized = normalizeChatChannelId(raw);
|
|
1218
|
-
if (normalized) return normalized;
|
|
1219
|
-
return (raw ?? "").trim().toLowerCase();
|
|
1220
|
-
}
|
|
1221
|
-
function collectChannelsMissingDefaultAccount(cfg) {
|
|
1222
|
-
const channels = asObjectRecord(cfg.channels);
|
|
1223
|
-
if (!channels) return [];
|
|
1224
|
-
const contexts = [];
|
|
1225
|
-
for (const [channelKey, rawChannel] of Object.entries(channels)) {
|
|
1226
|
-
const channel = asObjectRecord(rawChannel);
|
|
1227
|
-
if (!channel) continue;
|
|
1228
|
-
const accounts = asObjectRecord(channel.accounts);
|
|
1229
|
-
if (!accounts) continue;
|
|
1230
|
-
const normalizedAccountIds = Array.from(new Set(Object.keys(accounts).map((accountId) => normalizeAccountId(accountId)).filter(Boolean))).toSorted((a, b) => a.localeCompare(b));
|
|
1231
|
-
if (normalizedAccountIds.length === 0 || normalizedAccountIds.includes("default")) continue;
|
|
1232
|
-
contexts.push({
|
|
1233
|
-
channelKey,
|
|
1234
|
-
channel,
|
|
1235
|
-
normalizedAccountIds
|
|
1236
|
-
});
|
|
1237
|
-
}
|
|
1238
|
-
return contexts;
|
|
1239
|
-
}
|
|
1240
|
-
function collectMissingDefaultAccountBindingWarnings(cfg) {
|
|
1241
|
-
const bindings = listRouteBindings(cfg);
|
|
1242
|
-
const warnings = [];
|
|
1243
|
-
for (const { channelKey, normalizedAccountIds } of collectChannelsMissingDefaultAccount(cfg)) {
|
|
1244
|
-
const accountIdSet = new Set(normalizedAccountIds);
|
|
1245
|
-
const channelPattern = normalizeBindingChannelKey(channelKey);
|
|
1246
|
-
let hasWildcardBinding = false;
|
|
1247
|
-
const coveredAccountIds = /* @__PURE__ */ new Set();
|
|
1248
|
-
for (const binding of bindings) {
|
|
1249
|
-
const bindingRecord = asObjectRecord(binding);
|
|
1250
|
-
if (!bindingRecord) continue;
|
|
1251
|
-
const match = asObjectRecord(bindingRecord.match);
|
|
1252
|
-
if (!match) continue;
|
|
1253
|
-
const matchChannel = typeof match.channel === "string" ? normalizeBindingChannelKey(match.channel) : "";
|
|
1254
|
-
if (!matchChannel || matchChannel !== channelPattern) continue;
|
|
1255
|
-
const rawAccountId = typeof match.accountId === "string" ? match.accountId.trim() : "";
|
|
1256
|
-
if (!rawAccountId) continue;
|
|
1257
|
-
if (rawAccountId === "*") {
|
|
1258
|
-
hasWildcardBinding = true;
|
|
1259
|
-
continue;
|
|
1260
|
-
}
|
|
1261
|
-
const normalizedBindingAccountId = normalizeAccountId(rawAccountId);
|
|
1262
|
-
if (accountIdSet.has(normalizedBindingAccountId)) coveredAccountIds.add(normalizedBindingAccountId);
|
|
1263
|
-
}
|
|
1264
|
-
if (hasWildcardBinding) continue;
|
|
1265
|
-
const uncoveredAccountIds = normalizedAccountIds.filter((accountId) => !coveredAccountIds.has(accountId));
|
|
1266
|
-
if (uncoveredAccountIds.length === 0) continue;
|
|
1267
|
-
if (coveredAccountIds.size > 0) {
|
|
1268
|
-
warnings.push(`- channels.${channelKey}: accounts.default is missing and account bindings only cover a subset of configured accounts. Uncovered accounts: ${uncoveredAccountIds.join(", ")}. Add bindings[].match.accountId for uncovered accounts (or "*"), or add ${formatChannelAccountsDefaultPath(channelKey)}.`);
|
|
1269
|
-
continue;
|
|
1270
|
-
}
|
|
1271
|
-
warnings.push(`- channels.${channelKey}: accounts.default is missing and no valid account-scoped binding exists for configured accounts (${normalizedAccountIds.join(", ")}). Channel-only bindings (no accountId) match only default. Add bindings[].match.accountId for one of these accounts (or "*"), or add ${formatChannelAccountsDefaultPath(channelKey)}.`);
|
|
1272
|
-
}
|
|
1273
|
-
return warnings;
|
|
1274
|
-
}
|
|
1275
|
-
function collectMissingExplicitDefaultAccountWarnings(cfg) {
|
|
1276
|
-
const warnings = [];
|
|
1277
|
-
for (const { channelKey, channel, normalizedAccountIds } of collectChannelsMissingDefaultAccount(cfg)) {
|
|
1278
|
-
if (normalizedAccountIds.length < 2) continue;
|
|
1279
|
-
const preferredDefault = normalizeOptionalAccountId(typeof channel.defaultAccount === "string" ? channel.defaultAccount : void 0);
|
|
1280
|
-
if (preferredDefault) {
|
|
1281
|
-
if (normalizedAccountIds.includes(preferredDefault)) continue;
|
|
1282
|
-
warnings.push(`- channels.${channelKey}: defaultAccount is set to "${preferredDefault}" but does not match configured accounts (${normalizedAccountIds.join(", ")}). ${formatSetExplicitDefaultToConfiguredInstruction({ channelKey })} to avoid fallback routing.`);
|
|
1283
|
-
continue;
|
|
1284
|
-
}
|
|
1285
|
-
warnings.push(`- channels.${channelKey}: multiple accounts are configured but no explicit default is set. ${formatSetExplicitDefaultInstruction(channelKey)} to avoid fallback routing.`);
|
|
1286
|
-
}
|
|
1287
|
-
return warnings;
|
|
1288
|
-
}
|
|
1289
|
-
function collectTelegramAccountScopes(cfg) {
|
|
1290
|
-
const scopes = [];
|
|
1291
|
-
const telegram = asObjectRecord(cfg.channels?.telegram);
|
|
1292
|
-
if (!telegram) return scopes;
|
|
1293
|
-
scopes.push({
|
|
1294
|
-
prefix: "channels.telegram",
|
|
1295
|
-
account: telegram
|
|
1296
|
-
});
|
|
1297
|
-
const accounts = asObjectRecord(telegram.accounts);
|
|
1298
|
-
if (!accounts) return scopes;
|
|
1299
|
-
for (const key of Object.keys(accounts)) {
|
|
1300
|
-
const account = asObjectRecord(accounts[key]);
|
|
1301
|
-
if (!account) continue;
|
|
1302
|
-
scopes.push({
|
|
1303
|
-
prefix: `channels.telegram.accounts.${key}`,
|
|
1304
|
-
account
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
return scopes;
|
|
1308
|
-
}
|
|
1309
|
-
function collectTelegramAllowFromLists(prefix, account) {
|
|
1310
|
-
const refs = [{
|
|
1311
|
-
pathLabel: `${prefix}.allowFrom`,
|
|
1312
|
-
holder: account,
|
|
1313
|
-
key: "allowFrom"
|
|
1314
|
-
}, {
|
|
1315
|
-
pathLabel: `${prefix}.groupAllowFrom`,
|
|
1316
|
-
holder: account,
|
|
1317
|
-
key: "groupAllowFrom"
|
|
1318
|
-
}];
|
|
1319
|
-
const groups = asObjectRecord(account.groups);
|
|
1320
|
-
if (!groups) return refs;
|
|
1321
|
-
for (const groupId of Object.keys(groups)) {
|
|
1322
|
-
const group = asObjectRecord(groups[groupId]);
|
|
1323
|
-
if (!group) continue;
|
|
1324
|
-
refs.push({
|
|
1325
|
-
pathLabel: `${prefix}.groups.${groupId}.allowFrom`,
|
|
1326
|
-
holder: group,
|
|
1327
|
-
key: "allowFrom"
|
|
1328
|
-
});
|
|
1329
|
-
const topics = asObjectRecord(group.topics);
|
|
1330
|
-
if (!topics) continue;
|
|
1331
|
-
for (const topicId of Object.keys(topics)) {
|
|
1332
|
-
const topic = asObjectRecord(topics[topicId]);
|
|
1333
|
-
if (!topic) continue;
|
|
1334
|
-
refs.push({
|
|
1335
|
-
pathLabel: `${prefix}.groups.${groupId}.topics.${topicId}.allowFrom`,
|
|
1336
|
-
holder: topic,
|
|
1337
|
-
key: "allowFrom"
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
return refs;
|
|
1342
|
-
}
|
|
1343
|
-
function scanTelegramAllowFromUsernameEntries(cfg) {
|
|
1344
|
-
const hits = [];
|
|
1345
|
-
const scanList = (pathLabel, list) => {
|
|
1346
|
-
if (!Array.isArray(list)) return;
|
|
1347
|
-
for (const entry of list) {
|
|
1348
|
-
const normalized = normalizeTelegramAllowFromEntry(entry);
|
|
1349
|
-
if (!normalized || normalized === "*") continue;
|
|
1350
|
-
if (isNumericTelegramUserId(normalized)) continue;
|
|
1351
|
-
hits.push({
|
|
1352
|
-
path: pathLabel,
|
|
1353
|
-
entry: String(entry).trim()
|
|
1354
|
-
});
|
|
1355
|
-
}
|
|
1356
|
-
};
|
|
1357
|
-
for (const scope of collectTelegramAccountScopes(cfg)) for (const ref of collectTelegramAllowFromLists(scope.prefix, scope.account)) scanList(ref.pathLabel, ref.holder[ref.key]);
|
|
1358
|
-
return hits;
|
|
1359
|
-
}
|
|
1360
|
-
async function maybeRepairTelegramAllowFromUsernames(cfg) {
|
|
1361
|
-
if (scanTelegramAllowFromUsernameEntries(cfg).length === 0) return {
|
|
1362
|
-
config: cfg,
|
|
1363
|
-
changes: []
|
|
1364
|
-
};
|
|
1365
|
-
const { resolvedConfig } = await resolveCommandSecretRefsViaGateway({
|
|
1366
|
-
config: cfg,
|
|
1367
|
-
commandName: "doctor --fix",
|
|
1368
|
-
targetIds: getChannelsCommandSecretTargetIds(),
|
|
1369
|
-
mode: "read_only_status"
|
|
1370
|
-
});
|
|
1371
|
-
const hasConfiguredUnavailableToken = listTelegramAccountIds(cfg).some((accountId) => {
|
|
1372
|
-
const inspected = inspectTelegramAccount({
|
|
1373
|
-
cfg,
|
|
1374
|
-
accountId
|
|
1375
|
-
});
|
|
1376
|
-
return inspected.enabled && inspected.tokenStatus === "configured_unavailable";
|
|
1377
|
-
});
|
|
1378
|
-
const tokenResolutionWarnings = [];
|
|
1379
|
-
const tokens = Array.from(new Set(listTelegramAccountIds(resolvedConfig).map((accountId) => {
|
|
1380
|
-
try {
|
|
1381
|
-
return resolveTelegramAccount({
|
|
1382
|
-
cfg: resolvedConfig,
|
|
1383
|
-
accountId
|
|
1384
|
-
});
|
|
1385
|
-
} catch (error) {
|
|
1386
|
-
tokenResolutionWarnings.push(`- Telegram account ${accountId}: failed to inspect bot token (${describeUnknownError(error)}).`);
|
|
1387
|
-
return null;
|
|
1388
|
-
}
|
|
1389
|
-
}).filter((account) => Boolean(account)).map((account) => account.tokenSource === "none" ? "" : account.token).map((token) => token.trim()).filter(Boolean)));
|
|
1390
|
-
if (tokens.length === 0) return {
|
|
1391
|
-
config: cfg,
|
|
1392
|
-
changes: [...tokenResolutionWarnings, hasConfiguredUnavailableToken ? `- Telegram allowFrom contains @username entries, but configured Telegram bot credentials are unavailable in this command path; cannot auto-resolve (start the gateway or make the secret source available, then rerun doctor --fix).` : `- Telegram allowFrom contains @username entries, but no Telegram bot token is configured; cannot auto-resolve (run setup or replace with numeric sender IDs).`]
|
|
1393
|
-
};
|
|
1394
|
-
const resolveUserId = async (raw) => {
|
|
1395
|
-
const trimmed = raw.trim();
|
|
1396
|
-
if (!trimmed) return null;
|
|
1397
|
-
const stripped = normalizeTelegramAllowFromEntry(trimmed);
|
|
1398
|
-
if (!stripped || stripped === "*") return null;
|
|
1399
|
-
if (isNumericTelegramUserId(stripped)) return stripped;
|
|
1400
|
-
if (/\s/.test(stripped)) return null;
|
|
1401
|
-
const username = stripped.startsWith("@") ? stripped : `@${stripped}`;
|
|
1402
|
-
for (const token of tokens) {
|
|
1403
|
-
const controller = new AbortController();
|
|
1404
|
-
const timeout = setTimeout(() => controller.abort(), 4e3);
|
|
1405
|
-
try {
|
|
1406
|
-
const id = await fetchTelegramChatId({
|
|
1407
|
-
token,
|
|
1408
|
-
chatId: username,
|
|
1409
|
-
signal: controller.signal
|
|
1410
|
-
});
|
|
1411
|
-
if (id) return id;
|
|
1412
|
-
} catch {} finally {
|
|
1413
|
-
clearTimeout(timeout);
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
return null;
|
|
1417
|
-
};
|
|
1418
|
-
const changes = [];
|
|
1419
|
-
const next = structuredClone(cfg);
|
|
1420
|
-
const repairList = async (pathLabel, holder, key) => {
|
|
1421
|
-
const raw = holder[key];
|
|
1422
|
-
if (!Array.isArray(raw)) return;
|
|
1423
|
-
const out = [];
|
|
1424
|
-
const replaced = [];
|
|
1425
|
-
for (const entry of raw) {
|
|
1426
|
-
const normalized = normalizeTelegramAllowFromEntry(entry);
|
|
1427
|
-
if (!normalized) continue;
|
|
1428
|
-
if (normalized === "*") {
|
|
1429
|
-
out.push("*");
|
|
1430
|
-
continue;
|
|
1431
|
-
}
|
|
1432
|
-
if (isNumericTelegramUserId(normalized)) {
|
|
1433
|
-
out.push(normalized);
|
|
1434
|
-
continue;
|
|
1435
|
-
}
|
|
1436
|
-
const resolved = await resolveUserId(String(entry));
|
|
1437
|
-
if (resolved) {
|
|
1438
|
-
out.push(resolved);
|
|
1439
|
-
replaced.push({
|
|
1440
|
-
from: String(entry).trim(),
|
|
1441
|
-
to: resolved
|
|
1442
|
-
});
|
|
1443
|
-
} else out.push(String(entry).trim());
|
|
1444
|
-
}
|
|
1445
|
-
const deduped = [];
|
|
1446
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1447
|
-
for (const entry of out) {
|
|
1448
|
-
const k = String(entry).trim();
|
|
1449
|
-
if (!k || seen.has(k)) continue;
|
|
1450
|
-
seen.add(k);
|
|
1451
|
-
deduped.push(entry);
|
|
1452
|
-
}
|
|
1453
|
-
holder[key] = deduped;
|
|
1454
|
-
if (replaced.length > 0) {
|
|
1455
|
-
for (const rep of replaced.slice(0, 5)) changes.push(`- ${pathLabel}: resolved ${rep.from} -> ${rep.to}`);
|
|
1456
|
-
if (replaced.length > 5) changes.push(`- ${pathLabel}: resolved ${replaced.length - 5} more @username entries`);
|
|
1457
|
-
}
|
|
1458
|
-
};
|
|
1459
|
-
const repairAccount = async (prefix, account) => {
|
|
1460
|
-
for (const ref of collectTelegramAllowFromLists(prefix, account)) await repairList(ref.pathLabel, ref.holder, ref.key);
|
|
1461
|
-
};
|
|
1462
|
-
for (const scope of collectTelegramAccountScopes(next)) await repairAccount(scope.prefix, scope.account);
|
|
1463
|
-
if (changes.length === 0) return {
|
|
1464
|
-
config: cfg,
|
|
1465
|
-
changes: []
|
|
1466
|
-
};
|
|
1467
|
-
return {
|
|
1468
|
-
config: next,
|
|
1469
|
-
changes
|
|
1470
|
-
};
|
|
1471
|
-
}
|
|
1472
|
-
function collectDiscordAccountScopes(cfg) {
|
|
1473
|
-
const scopes = [];
|
|
1474
|
-
const discord = asObjectRecord(cfg.channels?.discord);
|
|
1475
|
-
if (!discord) return scopes;
|
|
1476
|
-
scopes.push({
|
|
1477
|
-
prefix: "channels.discord",
|
|
1478
|
-
account: discord
|
|
1479
|
-
});
|
|
1480
|
-
const accounts = asObjectRecord(discord.accounts);
|
|
1481
|
-
if (!accounts) return scopes;
|
|
1482
|
-
for (const key of Object.keys(accounts)) {
|
|
1483
|
-
const account = asObjectRecord(accounts[key]);
|
|
1484
|
-
if (!account) continue;
|
|
1485
|
-
scopes.push({
|
|
1486
|
-
prefix: `channels.discord.accounts.${key}`,
|
|
1487
|
-
account
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
return scopes;
|
|
1491
|
-
}
|
|
1492
|
-
function collectDiscordIdLists(prefix, account) {
|
|
1493
|
-
const refs = [{
|
|
1494
|
-
pathLabel: `${prefix}.allowFrom`,
|
|
1495
|
-
holder: account,
|
|
1496
|
-
key: "allowFrom"
|
|
1497
|
-
}];
|
|
1498
|
-
const dm = asObjectRecord(account.dm);
|
|
1499
|
-
if (dm) {
|
|
1500
|
-
refs.push({
|
|
1501
|
-
pathLabel: `${prefix}.dm.allowFrom`,
|
|
1502
|
-
holder: dm,
|
|
1503
|
-
key: "allowFrom"
|
|
1504
|
-
});
|
|
1505
|
-
refs.push({
|
|
1506
|
-
pathLabel: `${prefix}.dm.groupChannels`,
|
|
1507
|
-
holder: dm,
|
|
1508
|
-
key: "groupChannels"
|
|
1509
|
-
});
|
|
1510
|
-
}
|
|
1511
|
-
const execApprovals = asObjectRecord(account.execApprovals);
|
|
1512
|
-
if (execApprovals) refs.push({
|
|
1513
|
-
pathLabel: `${prefix}.execApprovals.approvers`,
|
|
1514
|
-
holder: execApprovals,
|
|
1515
|
-
key: "approvers"
|
|
1516
|
-
});
|
|
1517
|
-
const guilds = asObjectRecord(account.guilds);
|
|
1518
|
-
if (!guilds) return refs;
|
|
1519
|
-
for (const guildId of Object.keys(guilds)) {
|
|
1520
|
-
const guild = asObjectRecord(guilds[guildId]);
|
|
1521
|
-
if (!guild) continue;
|
|
1522
|
-
refs.push({
|
|
1523
|
-
pathLabel: `${prefix}.guilds.${guildId}.users`,
|
|
1524
|
-
holder: guild,
|
|
1525
|
-
key: "users"
|
|
1526
|
-
});
|
|
1527
|
-
refs.push({
|
|
1528
|
-
pathLabel: `${prefix}.guilds.${guildId}.roles`,
|
|
1529
|
-
holder: guild,
|
|
1530
|
-
key: "roles"
|
|
1531
|
-
});
|
|
1532
|
-
const channels = asObjectRecord(guild.channels);
|
|
1533
|
-
if (!channels) continue;
|
|
1534
|
-
for (const channelId of Object.keys(channels)) {
|
|
1535
|
-
const channel = asObjectRecord(channels[channelId]);
|
|
1536
|
-
if (!channel) continue;
|
|
1537
|
-
refs.push({
|
|
1538
|
-
pathLabel: `${prefix}.guilds.${guildId}.channels.${channelId}.users`,
|
|
1539
|
-
holder: channel,
|
|
1540
|
-
key: "users"
|
|
1541
|
-
});
|
|
1542
|
-
refs.push({
|
|
1543
|
-
pathLabel: `${prefix}.guilds.${guildId}.channels.${channelId}.roles`,
|
|
1544
|
-
holder: channel,
|
|
1545
|
-
key: "roles"
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
return refs;
|
|
1550
|
-
}
|
|
1551
|
-
function scanDiscordNumericIdEntries(cfg) {
|
|
1552
|
-
const hits = [];
|
|
1553
|
-
const scanList = (pathLabel, list) => {
|
|
1554
|
-
if (!Array.isArray(list)) return;
|
|
1555
|
-
for (const [index, entry] of list.entries()) {
|
|
1556
|
-
if (typeof entry !== "number") continue;
|
|
1557
|
-
hits.push({
|
|
1558
|
-
path: `${pathLabel}[${index}]`,
|
|
1559
|
-
entry
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
for (const scope of collectDiscordAccountScopes(cfg)) for (const ref of collectDiscordIdLists(scope.prefix, scope.account)) scanList(ref.pathLabel, ref.holder[ref.key]);
|
|
1564
|
-
return hits;
|
|
1565
|
-
}
|
|
1566
|
-
function maybeRepairDiscordNumericIds(cfg) {
|
|
1567
|
-
if (scanDiscordNumericIdEntries(cfg).length === 0) return {
|
|
1568
|
-
config: cfg,
|
|
1569
|
-
changes: []
|
|
1570
|
-
};
|
|
1571
|
-
const next = structuredClone(cfg);
|
|
1572
|
-
const changes = [];
|
|
1573
|
-
const repairList = (pathLabel, holder, key) => {
|
|
1574
|
-
const raw = holder[key];
|
|
1575
|
-
if (!Array.isArray(raw)) return;
|
|
1576
|
-
let converted = 0;
|
|
1577
|
-
const updated = raw.map((entry) => {
|
|
1578
|
-
if (typeof entry === "number") {
|
|
1579
|
-
converted += 1;
|
|
1580
|
-
return String(entry);
|
|
1581
|
-
}
|
|
1582
|
-
return entry;
|
|
1583
|
-
});
|
|
1584
|
-
if (converted === 0) return;
|
|
1585
|
-
holder[key] = updated;
|
|
1586
|
-
changes.push(`- ${pathLabel}: converted ${converted} numeric ${converted === 1 ? "entry" : "entries"} to strings`);
|
|
1587
|
-
};
|
|
1588
|
-
for (const scope of collectDiscordAccountScopes(next)) for (const ref of collectDiscordIdLists(scope.prefix, scope.account)) repairList(ref.pathLabel, ref.holder, ref.key);
|
|
1589
|
-
if (changes.length === 0) return {
|
|
1590
|
-
config: cfg,
|
|
1591
|
-
changes: []
|
|
1592
|
-
};
|
|
1593
|
-
return {
|
|
1594
|
-
config: next,
|
|
1595
|
-
changes
|
|
1596
|
-
};
|
|
1597
|
-
}
|
|
1598
|
-
function addMutableAllowlistHits(params) {
|
|
1599
|
-
if (!Array.isArray(params.list)) return;
|
|
1600
|
-
for (const entry of params.list) {
|
|
1601
|
-
const text = String(entry).trim();
|
|
1602
|
-
if (!text || text === "*") continue;
|
|
1603
|
-
if (!params.detector(text)) continue;
|
|
1604
|
-
params.hits.push({
|
|
1605
|
-
channel: params.channel,
|
|
1606
|
-
path: params.pathLabel,
|
|
1607
|
-
entry: text,
|
|
1608
|
-
dangerousFlagPath: params.dangerousFlagPath
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
function scanMutableAllowlistEntries(cfg) {
|
|
1613
|
-
const hits = [];
|
|
1614
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "discord")) {
|
|
1615
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1616
|
-
addMutableAllowlistHits({
|
|
1617
|
-
hits,
|
|
1618
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
1619
|
-
list: scope.account.allowFrom,
|
|
1620
|
-
detector: isDiscordMutableAllowEntry,
|
|
1621
|
-
channel: "discord",
|
|
1622
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1623
|
-
});
|
|
1624
|
-
const dm = asObjectRecord(scope.account.dm);
|
|
1625
|
-
if (dm) addMutableAllowlistHits({
|
|
1626
|
-
hits,
|
|
1627
|
-
pathLabel: `${scope.prefix}.dm.allowFrom`,
|
|
1628
|
-
list: dm.allowFrom,
|
|
1629
|
-
detector: isDiscordMutableAllowEntry,
|
|
1630
|
-
channel: "discord",
|
|
1631
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1632
|
-
});
|
|
1633
|
-
const guilds = asObjectRecord(scope.account.guilds);
|
|
1634
|
-
if (!guilds) continue;
|
|
1635
|
-
for (const [guildId, guildRaw] of Object.entries(guilds)) {
|
|
1636
|
-
const guild = asObjectRecord(guildRaw);
|
|
1637
|
-
if (!guild) continue;
|
|
1638
|
-
addMutableAllowlistHits({
|
|
1639
|
-
hits,
|
|
1640
|
-
pathLabel: `${scope.prefix}.guilds.${guildId}.users`,
|
|
1641
|
-
list: guild.users,
|
|
1642
|
-
detector: isDiscordMutableAllowEntry,
|
|
1643
|
-
channel: "discord",
|
|
1644
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1645
|
-
});
|
|
1646
|
-
const channels = asObjectRecord(guild.channels);
|
|
1647
|
-
if (!channels) continue;
|
|
1648
|
-
for (const [channelId, channelRaw] of Object.entries(channels)) {
|
|
1649
|
-
const channel = asObjectRecord(channelRaw);
|
|
1650
|
-
if (!channel) continue;
|
|
1651
|
-
addMutableAllowlistHits({
|
|
1652
|
-
hits,
|
|
1653
|
-
pathLabel: `${scope.prefix}.guilds.${guildId}.channels.${channelId}.users`,
|
|
1654
|
-
list: channel.users,
|
|
1655
|
-
detector: isDiscordMutableAllowEntry,
|
|
1656
|
-
channel: "discord",
|
|
1657
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "slack")) {
|
|
1663
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1664
|
-
addMutableAllowlistHits({
|
|
1665
|
-
hits,
|
|
1666
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
1667
|
-
list: scope.account.allowFrom,
|
|
1668
|
-
detector: isSlackMutableAllowEntry,
|
|
1669
|
-
channel: "slack",
|
|
1670
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1671
|
-
});
|
|
1672
|
-
const dm = asObjectRecord(scope.account.dm);
|
|
1673
|
-
if (dm) addMutableAllowlistHits({
|
|
1674
|
-
hits,
|
|
1675
|
-
pathLabel: `${scope.prefix}.dm.allowFrom`,
|
|
1676
|
-
list: dm.allowFrom,
|
|
1677
|
-
detector: isSlackMutableAllowEntry,
|
|
1678
|
-
channel: "slack",
|
|
1679
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1680
|
-
});
|
|
1681
|
-
const channels = asObjectRecord(scope.account.channels);
|
|
1682
|
-
if (!channels) continue;
|
|
1683
|
-
for (const [channelKey, channelRaw] of Object.entries(channels)) {
|
|
1684
|
-
const channel = asObjectRecord(channelRaw);
|
|
1685
|
-
if (!channel) continue;
|
|
1686
|
-
addMutableAllowlistHits({
|
|
1687
|
-
hits,
|
|
1688
|
-
pathLabel: `${scope.prefix}.channels.${channelKey}.users`,
|
|
1689
|
-
list: channel.users,
|
|
1690
|
-
detector: isSlackMutableAllowEntry,
|
|
1691
|
-
channel: "slack",
|
|
1692
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1693
|
-
});
|
|
1694
|
-
}
|
|
1695
|
-
}
|
|
1696
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "googlechat")) {
|
|
1697
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1698
|
-
addMutableAllowlistHits({
|
|
1699
|
-
hits,
|
|
1700
|
-
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
1701
|
-
list: scope.account.groupAllowFrom,
|
|
1702
|
-
detector: isGoogleChatMutableAllowEntry,
|
|
1703
|
-
channel: "googlechat",
|
|
1704
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1705
|
-
});
|
|
1706
|
-
const dm = asObjectRecord(scope.account.dm);
|
|
1707
|
-
if (dm) addMutableAllowlistHits({
|
|
1708
|
-
hits,
|
|
1709
|
-
pathLabel: `${scope.prefix}.dm.allowFrom`,
|
|
1710
|
-
list: dm.allowFrom,
|
|
1711
|
-
detector: isGoogleChatMutableAllowEntry,
|
|
1712
|
-
channel: "googlechat",
|
|
1713
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1714
|
-
});
|
|
1715
|
-
const groups = asObjectRecord(scope.account.groups);
|
|
1716
|
-
if (!groups) continue;
|
|
1717
|
-
for (const [groupKey, groupRaw] of Object.entries(groups)) {
|
|
1718
|
-
const group = asObjectRecord(groupRaw);
|
|
1719
|
-
if (!group) continue;
|
|
1720
|
-
addMutableAllowlistHits({
|
|
1721
|
-
hits,
|
|
1722
|
-
pathLabel: `${scope.prefix}.groups.${groupKey}.users`,
|
|
1723
|
-
list: group.users,
|
|
1724
|
-
detector: isGoogleChatMutableAllowEntry,
|
|
1725
|
-
channel: "googlechat",
|
|
1726
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1727
|
-
});
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "msteams")) {
|
|
1731
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1732
|
-
addMutableAllowlistHits({
|
|
1733
|
-
hits,
|
|
1734
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
1735
|
-
list: scope.account.allowFrom,
|
|
1736
|
-
detector: isMSTeamsMutableAllowEntry,
|
|
1737
|
-
channel: "msteams",
|
|
1738
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1739
|
-
});
|
|
1740
|
-
addMutableAllowlistHits({
|
|
1741
|
-
hits,
|
|
1742
|
-
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
1743
|
-
list: scope.account.groupAllowFrom,
|
|
1744
|
-
detector: isMSTeamsMutableAllowEntry,
|
|
1745
|
-
channel: "msteams",
|
|
1746
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1749
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "mattermost")) {
|
|
1750
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1751
|
-
addMutableAllowlistHits({
|
|
1752
|
-
hits,
|
|
1753
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
1754
|
-
list: scope.account.allowFrom,
|
|
1755
|
-
detector: isMattermostMutableAllowEntry,
|
|
1756
|
-
channel: "mattermost",
|
|
1757
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1758
|
-
});
|
|
1759
|
-
addMutableAllowlistHits({
|
|
1760
|
-
hits,
|
|
1761
|
-
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
1762
|
-
list: scope.account.groupAllowFrom,
|
|
1763
|
-
detector: isMattermostMutableAllowEntry,
|
|
1764
|
-
channel: "mattermost",
|
|
1765
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1766
|
-
});
|
|
1767
|
-
}
|
|
1768
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "irc")) {
|
|
1769
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1770
|
-
addMutableAllowlistHits({
|
|
1771
|
-
hits,
|
|
1772
|
-
pathLabel: `${scope.prefix}.allowFrom`,
|
|
1773
|
-
list: scope.account.allowFrom,
|
|
1774
|
-
detector: isIrcMutableAllowEntry,
|
|
1775
|
-
channel: "irc",
|
|
1776
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1777
|
-
});
|
|
1778
|
-
addMutableAllowlistHits({
|
|
1779
|
-
hits,
|
|
1780
|
-
pathLabel: `${scope.prefix}.groupAllowFrom`,
|
|
1781
|
-
list: scope.account.groupAllowFrom,
|
|
1782
|
-
detector: isIrcMutableAllowEntry,
|
|
1783
|
-
channel: "irc",
|
|
1784
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1785
|
-
});
|
|
1786
|
-
const groups = asObjectRecord(scope.account.groups);
|
|
1787
|
-
if (!groups) continue;
|
|
1788
|
-
for (const [groupKey, groupRaw] of Object.entries(groups)) {
|
|
1789
|
-
const group = asObjectRecord(groupRaw);
|
|
1790
|
-
if (!group) continue;
|
|
1791
|
-
addMutableAllowlistHits({
|
|
1792
|
-
hits,
|
|
1793
|
-
pathLabel: `${scope.prefix}.groups.${groupKey}.allowFrom`,
|
|
1794
|
-
list: group.allowFrom,
|
|
1795
|
-
detector: isIrcMutableAllowEntry,
|
|
1796
|
-
channel: "irc",
|
|
1797
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1798
|
-
});
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
for (const scope of collectProviderDangerousNameMatchingScopes(cfg, "zalouser")) {
|
|
1802
|
-
if (scope.dangerousNameMatchingEnabled) continue;
|
|
1803
|
-
const groups = asObjectRecord(scope.account.groups);
|
|
1804
|
-
if (!groups) continue;
|
|
1805
|
-
for (const entry of Object.keys(groups)) {
|
|
1806
|
-
if (!isZalouserMutableGroupEntry(entry)) continue;
|
|
1807
|
-
hits.push({
|
|
1808
|
-
channel: "zalouser",
|
|
1809
|
-
path: `${scope.prefix}.groups`,
|
|
1810
|
-
entry,
|
|
1811
|
-
dangerousFlagPath: scope.dangerousFlagPath
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
return hits;
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Scan all channel configs for dmPolicy="open" without allowFrom including "*".
|
|
1819
|
-
* This configuration is rejected by the schema validator but can easily occur when
|
|
1820
|
-
* users (or integrations) set dmPolicy to "open" without realising that an explicit
|
|
1821
|
-
* allowFrom wildcard is also required.
|
|
1822
|
-
*/
|
|
1823
|
-
function maybeRepairOpenPolicyAllowFrom(cfg) {
|
|
1824
|
-
const channels = cfg.channels;
|
|
1825
|
-
if (!channels || typeof channels !== "object") return {
|
|
1826
|
-
config: cfg,
|
|
1827
|
-
changes: []
|
|
1828
|
-
};
|
|
1829
|
-
const next = structuredClone(cfg);
|
|
1830
|
-
const changes = [];
|
|
1831
|
-
const resolveAllowFromMode = (channelName) => {
|
|
1832
|
-
if (channelName === "googlechat") return "nestedOnly";
|
|
1833
|
-
if (channelName === "discord" || channelName === "slack") return "topOrNested";
|
|
1834
|
-
return "topOnly";
|
|
1835
|
-
};
|
|
1836
|
-
const hasWildcard = (list) => list?.some((v) => String(v).trim() === "*") ?? false;
|
|
1837
|
-
const ensureWildcard = (account, prefix, mode) => {
|
|
1838
|
-
const dmEntry = account.dm;
|
|
1839
|
-
const dm = dmEntry && typeof dmEntry === "object" && !Array.isArray(dmEntry) ? dmEntry : void 0;
|
|
1840
|
-
if ((account.dmPolicy ?? dm?.policy ?? void 0) !== "open") return;
|
|
1841
|
-
const topAllowFrom = account.allowFrom;
|
|
1842
|
-
const nestedAllowFrom = dm?.allowFrom;
|
|
1843
|
-
if (mode === "nestedOnly") {
|
|
1844
|
-
if (hasWildcard(nestedAllowFrom)) return;
|
|
1845
|
-
if (Array.isArray(nestedAllowFrom)) {
|
|
1846
|
-
nestedAllowFrom.push("*");
|
|
1847
|
-
changes.push(`- ${prefix}.dm.allowFrom: added "*" (required by dmPolicy="open")`);
|
|
1848
|
-
return;
|
|
1849
|
-
}
|
|
1850
|
-
const nextDm = dm ?? {};
|
|
1851
|
-
nextDm.allowFrom = ["*"];
|
|
1852
|
-
account.dm = nextDm;
|
|
1853
|
-
changes.push(`- ${prefix}.dm.allowFrom: set to ["*"] (required by dmPolicy="open")`);
|
|
1854
|
-
return;
|
|
1855
|
-
}
|
|
1856
|
-
if (mode === "topOrNested") {
|
|
1857
|
-
if (hasWildcard(topAllowFrom) || hasWildcard(nestedAllowFrom)) return;
|
|
1858
|
-
if (Array.isArray(topAllowFrom)) {
|
|
1859
|
-
topAllowFrom.push("*");
|
|
1860
|
-
changes.push(`- ${prefix}.allowFrom: added "*" (required by dmPolicy="open")`);
|
|
1861
|
-
} else if (Array.isArray(nestedAllowFrom)) {
|
|
1862
|
-
nestedAllowFrom.push("*");
|
|
1863
|
-
changes.push(`- ${prefix}.dm.allowFrom: added "*" (required by dmPolicy="open")`);
|
|
1864
|
-
} else {
|
|
1865
|
-
account.allowFrom = ["*"];
|
|
1866
|
-
changes.push(`- ${prefix}.allowFrom: set to ["*"] (required by dmPolicy="open")`);
|
|
1867
|
-
}
|
|
1868
|
-
return;
|
|
1869
|
-
}
|
|
1870
|
-
if (hasWildcard(topAllowFrom)) return;
|
|
1871
|
-
if (Array.isArray(topAllowFrom)) {
|
|
1872
|
-
topAllowFrom.push("*");
|
|
1873
|
-
changes.push(`- ${prefix}.allowFrom: added "*" (required by dmPolicy="open")`);
|
|
1874
|
-
} else {
|
|
1875
|
-
account.allowFrom = ["*"];
|
|
1876
|
-
changes.push(`- ${prefix}.allowFrom: set to ["*"] (required by dmPolicy="open")`);
|
|
1877
|
-
}
|
|
1878
|
-
};
|
|
1879
|
-
const nextChannels = next.channels;
|
|
1880
|
-
for (const [channelName, channelConfig] of Object.entries(nextChannels)) {
|
|
1881
|
-
if (!channelConfig || typeof channelConfig !== "object") continue;
|
|
1882
|
-
const allowFromMode = resolveAllowFromMode(channelName);
|
|
1883
|
-
ensureWildcard(channelConfig, `channels.${channelName}`, allowFromMode);
|
|
1884
|
-
const accounts = channelConfig.accounts;
|
|
1885
|
-
if (accounts && typeof accounts === "object") {
|
|
1886
|
-
for (const [accountName, accountConfig] of Object.entries(accounts)) if (accountConfig && typeof accountConfig === "object") ensureWildcard(accountConfig, `channels.${channelName}.accounts.${accountName}`, allowFromMode);
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
if (changes.length === 0) return {
|
|
1890
|
-
config: cfg,
|
|
1891
|
-
changes: []
|
|
1892
|
-
};
|
|
1893
|
-
return {
|
|
1894
|
-
config: next,
|
|
1895
|
-
changes
|
|
1896
|
-
};
|
|
1897
|
-
}
|
|
1898
|
-
function hasAllowFromEntries(list) {
|
|
1899
|
-
return Array.isArray(list) && list.map((v) => String(v).trim()).filter(Boolean).length > 0;
|
|
1900
|
-
}
|
|
1901
|
-
async function maybeRepairAllowlistPolicyAllowFrom(cfg) {
|
|
1902
|
-
const channels = cfg.channels;
|
|
1903
|
-
if (!channels || typeof channels !== "object") return {
|
|
1904
|
-
config: cfg,
|
|
1905
|
-
changes: []
|
|
1906
|
-
};
|
|
1907
|
-
const resolveAllowFromMode = (channelName) => {
|
|
1908
|
-
if (channelName === "googlechat") return "nestedOnly";
|
|
1909
|
-
if (channelName === "discord" || channelName === "slack") return "topOrNested";
|
|
1910
|
-
return "topOnly";
|
|
1911
|
-
};
|
|
1912
|
-
const next = structuredClone(cfg);
|
|
1913
|
-
const changes = [];
|
|
1914
|
-
const applyRecoveredAllowFrom = (params) => {
|
|
1915
|
-
const count = params.allowFrom.length;
|
|
1916
|
-
const noun = count === 1 ? "entry" : "entries";
|
|
1917
|
-
if (params.mode === "nestedOnly") {
|
|
1918
|
-
const dmEntry = params.account.dm;
|
|
1919
|
-
const dm = dmEntry && typeof dmEntry === "object" && !Array.isArray(dmEntry) ? dmEntry : {};
|
|
1920
|
-
dm.allowFrom = params.allowFrom;
|
|
1921
|
-
params.account.dm = dm;
|
|
1922
|
-
changes.push(`- ${params.prefix}.dm.allowFrom: restored ${count} sender ${noun} from pairing store (dmPolicy="allowlist").`);
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
if (params.mode === "topOrNested") {
|
|
1926
|
-
const dmEntry = params.account.dm;
|
|
1927
|
-
const dm = dmEntry && typeof dmEntry === "object" && !Array.isArray(dmEntry) ? dmEntry : void 0;
|
|
1928
|
-
const nestedAllowFrom = dm?.allowFrom;
|
|
1929
|
-
if (dm && !Array.isArray(params.account.allowFrom) && Array.isArray(nestedAllowFrom)) {
|
|
1930
|
-
dm.allowFrom = params.allowFrom;
|
|
1931
|
-
changes.push(`- ${params.prefix}.dm.allowFrom: restored ${count} sender ${noun} from pairing store (dmPolicy="allowlist").`);
|
|
1932
|
-
return;
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
params.account.allowFrom = params.allowFrom;
|
|
1936
|
-
changes.push(`- ${params.prefix}.allowFrom: restored ${count} sender ${noun} from pairing store (dmPolicy="allowlist").`);
|
|
1937
|
-
};
|
|
1938
|
-
const recoverAllowFromForAccount = async (params) => {
|
|
1939
|
-
const dmEntry = params.account.dm;
|
|
1940
|
-
const dm = dmEntry && typeof dmEntry === "object" && !Array.isArray(dmEntry) ? dmEntry : void 0;
|
|
1941
|
-
if ((params.account.dmPolicy ?? dm?.policy) !== "allowlist") return;
|
|
1942
|
-
const topAllowFrom = params.account.allowFrom;
|
|
1943
|
-
const nestedAllowFrom = dm?.allowFrom;
|
|
1944
|
-
if (hasAllowFromEntries(topAllowFrom) || hasAllowFromEntries(nestedAllowFrom)) return;
|
|
1945
|
-
const normalizedChannelId = (normalizeChatChannelId(params.channelName) ?? params.channelName).trim().toLowerCase();
|
|
1946
|
-
if (!normalizedChannelId) return;
|
|
1947
|
-
const normalizedAccountId = normalizeAccountId(params.accountId) || "default";
|
|
1948
|
-
const fromStore = await readChannelAllowFromStore(normalizedChannelId, process.env, normalizedAccountId).catch(() => []);
|
|
1949
|
-
const recovered = Array.from(new Set(fromStore.map((entry) => String(entry).trim()))).filter(Boolean);
|
|
1950
|
-
if (recovered.length === 0) return;
|
|
1951
|
-
applyRecoveredAllowFrom({
|
|
1952
|
-
account: params.account,
|
|
1953
|
-
allowFrom: recovered,
|
|
1954
|
-
mode: resolveAllowFromMode(params.channelName),
|
|
1955
|
-
prefix: params.prefix
|
|
1956
|
-
});
|
|
1957
|
-
};
|
|
1958
|
-
const nextChannels = next.channels;
|
|
1959
|
-
for (const [channelName, channelConfig] of Object.entries(nextChannels)) {
|
|
1960
|
-
if (!channelConfig || typeof channelConfig !== "object") continue;
|
|
1961
|
-
await recoverAllowFromForAccount({
|
|
1962
|
-
channelName,
|
|
1963
|
-
account: channelConfig,
|
|
1964
|
-
prefix: `channels.${channelName}`
|
|
1965
|
-
});
|
|
1966
|
-
const accounts = channelConfig.accounts;
|
|
1967
|
-
if (!accounts || typeof accounts !== "object") continue;
|
|
1968
|
-
for (const [accountId, accountConfig] of Object.entries(accounts)) {
|
|
1969
|
-
if (!accountConfig || typeof accountConfig !== "object") continue;
|
|
1970
|
-
await recoverAllowFromForAccount({
|
|
1971
|
-
channelName,
|
|
1972
|
-
account: accountConfig,
|
|
1973
|
-
accountId,
|
|
1974
|
-
prefix: `channels.${channelName}.accounts.${accountId}`
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
if (changes.length === 0) return {
|
|
1979
|
-
config: cfg,
|
|
1980
|
-
changes: []
|
|
1981
|
-
};
|
|
1982
|
-
return {
|
|
1983
|
-
config: next,
|
|
1984
|
-
changes
|
|
1985
|
-
};
|
|
1986
|
-
}
|
|
1987
|
-
/**
|
|
1988
|
-
* Scan all channel configs for dmPolicy="allowlist" without any allowFrom entries.
|
|
1989
|
-
* This configuration blocks all DMs because no sender can match the empty
|
|
1990
|
-
* allowlist. Common after upgrades that remove external allowlist
|
|
1991
|
-
* file support.
|
|
1992
|
-
*/
|
|
1993
|
-
function detectEmptyAllowlistPolicy(cfg) {
|
|
1994
|
-
const channels = cfg.channels;
|
|
1995
|
-
if (!channels || typeof channels !== "object") return [];
|
|
1996
|
-
const warnings = [];
|
|
1997
|
-
const usesSenderBasedGroupAllowlist = (channelName) => {
|
|
1998
|
-
if (!channelName) return true;
|
|
1999
|
-
return !(channelName === "discord" || channelName === "slack" || channelName === "googlechat");
|
|
2000
|
-
};
|
|
2001
|
-
const allowsGroupAllowFromFallback = (channelName) => {
|
|
2002
|
-
if (!channelName) return true;
|
|
2003
|
-
return !(channelName === "googlechat" || channelName === "imessage" || channelName === "matrix" || channelName === "msteams" || channelName === "irc");
|
|
2004
|
-
};
|
|
2005
|
-
const checkAccount = (account, prefix, parent, channelName) => {
|
|
2006
|
-
const dmEntry = account.dm;
|
|
2007
|
-
const dm = dmEntry && typeof dmEntry === "object" && !Array.isArray(dmEntry) ? dmEntry : void 0;
|
|
2008
|
-
const parentDmEntry = parent?.dm;
|
|
2009
|
-
const parentDm = parentDmEntry && typeof parentDmEntry === "object" && !Array.isArray(parentDmEntry) ? parentDmEntry : void 0;
|
|
2010
|
-
const dmPolicy = account.dmPolicy ?? dm?.policy ?? parent?.dmPolicy ?? parentDm?.policy ?? void 0;
|
|
2011
|
-
const topAllowFrom = account.allowFrom ?? parent?.allowFrom;
|
|
2012
|
-
const nestedAllowFrom = dm?.allowFrom;
|
|
2013
|
-
const parentNestedAllowFrom = parentDm?.allowFrom;
|
|
2014
|
-
const effectiveAllowFrom = topAllowFrom ?? nestedAllowFrom ?? parentNestedAllowFrom;
|
|
2015
|
-
if (dmPolicy === "allowlist" && !hasAllowFromEntries(effectiveAllowFrom)) warnings.push(`- ${prefix}.dmPolicy is "allowlist" but allowFrom is empty — all DMs will be blocked. Add sender IDs to ${prefix}.allowFrom, or run "${formatCliCommand("moldclaw doctor --fix")}" to auto-migrate from pairing store when entries exist.`);
|
|
2016
|
-
if ((account.groupPolicy ?? parent?.groupPolicy ?? void 0) === "allowlist" && usesSenderBasedGroupAllowlist(channelName)) {
|
|
2017
|
-
const rawGroupAllowFrom = account.groupAllowFrom ?? parent?.groupAllowFrom;
|
|
2018
|
-
const groupAllowFrom = hasAllowFromEntries(rawGroupAllowFrom) ? rawGroupAllowFrom : void 0;
|
|
2019
|
-
const fallbackToAllowFrom = allowsGroupAllowFromFallback(channelName);
|
|
2020
|
-
if (!hasAllowFromEntries(groupAllowFrom ?? (fallbackToAllowFrom ? effectiveAllowFrom : void 0))) if (fallbackToAllowFrom) warnings.push(`- ${prefix}.groupPolicy is "allowlist" but groupAllowFrom (and allowFrom) is empty — all group messages will be silently dropped. Add sender IDs to ${prefix}.groupAllowFrom or ${prefix}.allowFrom, or set groupPolicy to "open".`);
|
|
2021
|
-
else warnings.push(`- ${prefix}.groupPolicy is "allowlist" but groupAllowFrom is empty — this channel does not fall back to allowFrom, so all group messages will be silently dropped. Add sender IDs to ${prefix}.groupAllowFrom, or set groupPolicy to "open".`);
|
|
2022
|
-
}
|
|
2023
|
-
};
|
|
2024
|
-
for (const [channelName, channelConfig] of Object.entries(channels)) {
|
|
2025
|
-
if (!channelConfig || typeof channelConfig !== "object") continue;
|
|
2026
|
-
checkAccount(channelConfig, `channels.${channelName}`, void 0, channelName);
|
|
2027
|
-
const accounts = channelConfig.accounts;
|
|
2028
|
-
if (accounts && typeof accounts === "object") for (const [accountId, account] of Object.entries(accounts)) {
|
|
2029
|
-
if (!account || typeof account !== "object") continue;
|
|
2030
|
-
checkAccount(account, `channels.${channelName}.accounts.${accountId}`, channelConfig, channelName);
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
return warnings;
|
|
2034
|
-
}
|
|
2035
|
-
function normalizeConfiguredSafeBins(entries) {
|
|
2036
|
-
if (!Array.isArray(entries)) return [];
|
|
2037
|
-
return Array.from(new Set(entries.map((entry) => typeof entry === "string" ? entry.trim().toLowerCase() : "").filter((entry) => entry.length > 0))).toSorted();
|
|
2038
|
-
}
|
|
2039
|
-
function normalizeConfiguredTrustedSafeBinDirs(entries) {
|
|
2040
|
-
if (!Array.isArray(entries)) return [];
|
|
2041
|
-
return normalizeTrustedSafeBinDirs(entries.filter((entry) => typeof entry === "string"));
|
|
2042
|
-
}
|
|
2043
|
-
function collectExecSafeBinScopes(cfg) {
|
|
2044
|
-
const scopes = [];
|
|
2045
|
-
const globalExec = asObjectRecord(cfg.tools?.exec);
|
|
2046
|
-
const globalTrustedDirs = normalizeConfiguredTrustedSafeBinDirs(globalExec?.safeBinTrustedDirs);
|
|
2047
|
-
if (globalExec) {
|
|
2048
|
-
const safeBins = normalizeConfiguredSafeBins(globalExec.safeBins);
|
|
2049
|
-
if (safeBins.length > 0) scopes.push({
|
|
2050
|
-
scopePath: "tools.exec",
|
|
2051
|
-
safeBins,
|
|
2052
|
-
exec: globalExec,
|
|
2053
|
-
mergedProfiles: resolveMergedSafeBinProfileFixtures({ global: globalExec }) ?? {},
|
|
2054
|
-
trustedSafeBinDirs: getTrustedSafeBinDirs({ extraDirs: globalTrustedDirs })
|
|
2055
|
-
});
|
|
2056
|
-
}
|
|
2057
|
-
const agents = Array.isArray(cfg.agents?.list) ? cfg.agents.list : [];
|
|
2058
|
-
for (const agent of agents) {
|
|
2059
|
-
if (!agent || typeof agent !== "object" || typeof agent.id !== "string") continue;
|
|
2060
|
-
const agentExec = asObjectRecord(agent.tools?.exec);
|
|
2061
|
-
if (!agentExec) continue;
|
|
2062
|
-
const safeBins = normalizeConfiguredSafeBins(agentExec.safeBins);
|
|
2063
|
-
if (safeBins.length === 0) continue;
|
|
2064
|
-
scopes.push({
|
|
2065
|
-
scopePath: `agents.list.${agent.id}.tools.exec`,
|
|
2066
|
-
safeBins,
|
|
2067
|
-
exec: agentExec,
|
|
2068
|
-
mergedProfiles: resolveMergedSafeBinProfileFixtures({
|
|
2069
|
-
global: globalExec,
|
|
2070
|
-
local: agentExec
|
|
2071
|
-
}) ?? {},
|
|
2072
|
-
trustedSafeBinDirs: getTrustedSafeBinDirs({ extraDirs: [...globalTrustedDirs, ...normalizeConfiguredTrustedSafeBinDirs(agentExec.safeBinTrustedDirs)] })
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
return scopes;
|
|
2076
|
-
}
|
|
2077
|
-
function scanExecSafeBinCoverage(cfg) {
|
|
2078
|
-
const hits = [];
|
|
2079
|
-
for (const scope of collectExecSafeBinScopes(cfg)) {
|
|
2080
|
-
const interpreterBins = new Set(listInterpreterLikeSafeBins(scope.safeBins));
|
|
2081
|
-
for (const bin of scope.safeBins) {
|
|
2082
|
-
if (scope.mergedProfiles[bin]) continue;
|
|
2083
|
-
hits.push({
|
|
2084
|
-
scopePath: scope.scopePath,
|
|
2085
|
-
bin,
|
|
2086
|
-
isInterpreter: interpreterBins.has(bin)
|
|
2087
|
-
});
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
return hits;
|
|
2091
|
-
}
|
|
2092
|
-
function scanExecSafeBinTrustedDirHints(cfg) {
|
|
2093
|
-
const hits = [];
|
|
2094
|
-
for (const scope of collectExecSafeBinScopes(cfg)) for (const bin of scope.safeBins) {
|
|
2095
|
-
const resolution = resolveCommandResolutionFromArgv([bin]);
|
|
2096
|
-
if (!resolution?.resolvedPath) continue;
|
|
2097
|
-
if (isTrustedSafeBinPath({
|
|
2098
|
-
resolvedPath: resolution.resolvedPath,
|
|
2099
|
-
trustedDirs: scope.trustedSafeBinDirs
|
|
2100
|
-
})) continue;
|
|
2101
|
-
hits.push({
|
|
2102
|
-
scopePath: scope.scopePath,
|
|
2103
|
-
bin,
|
|
2104
|
-
resolvedPath: resolution.resolvedPath
|
|
2105
|
-
});
|
|
2106
|
-
}
|
|
2107
|
-
return hits;
|
|
2108
|
-
}
|
|
2109
|
-
function maybeRepairExecSafeBinProfiles(cfg) {
|
|
2110
|
-
const next = structuredClone(cfg);
|
|
2111
|
-
const changes = [];
|
|
2112
|
-
const warnings = [];
|
|
2113
|
-
for (const scope of collectExecSafeBinScopes(next)) {
|
|
2114
|
-
const interpreterBins = new Set(listInterpreterLikeSafeBins(scope.safeBins));
|
|
2115
|
-
const missingBins = scope.safeBins.filter((bin) => !scope.mergedProfiles[bin]);
|
|
2116
|
-
if (missingBins.length === 0) continue;
|
|
2117
|
-
const profileHolder = asObjectRecord(scope.exec.safeBinProfiles) ?? (scope.exec.safeBinProfiles = {});
|
|
2118
|
-
for (const bin of missingBins) {
|
|
2119
|
-
if (interpreterBins.has(bin)) {
|
|
2120
|
-
warnings.push(`- ${scope.scopePath}.safeBins includes interpreter/runtime '${bin}' without profile; remove it from safeBins or use explicit allowlist entries.`);
|
|
2121
|
-
continue;
|
|
2122
|
-
}
|
|
2123
|
-
if (profileHolder[bin] !== void 0) continue;
|
|
2124
|
-
profileHolder[bin] = {};
|
|
2125
|
-
changes.push(`- ${scope.scopePath}.safeBinProfiles.${bin}: added scaffold profile {} (review and tighten flags/positionals).`);
|
|
2126
|
-
}
|
|
2127
|
-
}
|
|
2128
|
-
if (changes.length === 0 && warnings.length === 0) return {
|
|
2129
|
-
config: cfg,
|
|
2130
|
-
changes: [],
|
|
2131
|
-
warnings: []
|
|
2132
|
-
};
|
|
2133
|
-
return {
|
|
2134
|
-
config: next,
|
|
2135
|
-
changes,
|
|
2136
|
-
warnings
|
|
2137
|
-
};
|
|
2138
|
-
}
|
|
2139
|
-
function collectLegacyToolsBySenderKeyHits(value, pathParts, hits) {
|
|
2140
|
-
if (Array.isArray(value)) {
|
|
2141
|
-
for (const [index, entry] of value.entries()) collectLegacyToolsBySenderKeyHits(entry, [...pathParts, index], hits);
|
|
2142
|
-
return;
|
|
2143
|
-
}
|
|
2144
|
-
const record = asObjectRecord(value);
|
|
2145
|
-
if (!record) return;
|
|
2146
|
-
const toolsBySender = asObjectRecord(record.toolsBySender);
|
|
2147
|
-
if (toolsBySender) {
|
|
2148
|
-
const path = [...pathParts, "toolsBySender"];
|
|
2149
|
-
const pathLabel = formatConfigPath(path);
|
|
2150
|
-
for (const rawKey of Object.keys(toolsBySender)) {
|
|
2151
|
-
const trimmed = rawKey.trim();
|
|
2152
|
-
if (!trimmed || trimmed === "*" || parseToolsBySenderTypedKey(trimmed)) continue;
|
|
2153
|
-
hits.push({
|
|
2154
|
-
toolsBySenderPath: path,
|
|
2155
|
-
pathLabel,
|
|
2156
|
-
key: rawKey,
|
|
2157
|
-
targetKey: `id:${trimmed}`
|
|
2158
|
-
});
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
for (const [key, nested] of Object.entries(record)) {
|
|
2162
|
-
if (key === "toolsBySender") continue;
|
|
2163
|
-
collectLegacyToolsBySenderKeyHits(nested, [...pathParts, key], hits);
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
function scanLegacyToolsBySenderKeys(cfg) {
|
|
2167
|
-
const hits = [];
|
|
2168
|
-
collectLegacyToolsBySenderKeyHits(cfg, [], hits);
|
|
2169
|
-
return hits;
|
|
2170
|
-
}
|
|
2171
|
-
function maybeRepairLegacyToolsBySenderKeys(cfg) {
|
|
2172
|
-
const next = structuredClone(cfg);
|
|
2173
|
-
const hits = scanLegacyToolsBySenderKeys(next);
|
|
2174
|
-
if (hits.length === 0) return {
|
|
2175
|
-
config: cfg,
|
|
2176
|
-
changes: []
|
|
2177
|
-
};
|
|
2178
|
-
const summary = /* @__PURE__ */ new Map();
|
|
2179
|
-
let changed = false;
|
|
2180
|
-
for (const hit of hits) {
|
|
2181
|
-
const toolsBySender = asObjectRecord(resolveConfigPathTarget(next, hit.toolsBySenderPath));
|
|
2182
|
-
if (!toolsBySender || !(hit.key in toolsBySender)) continue;
|
|
2183
|
-
const row = summary.get(hit.pathLabel) ?? {
|
|
2184
|
-
migrated: 0,
|
|
2185
|
-
dropped: 0,
|
|
2186
|
-
examples: []
|
|
2187
|
-
};
|
|
2188
|
-
if (toolsBySender[hit.targetKey] === void 0) {
|
|
2189
|
-
toolsBySender[hit.targetKey] = toolsBySender[hit.key];
|
|
2190
|
-
row.migrated++;
|
|
2191
|
-
if (row.examples.length < 3) row.examples.push(`${hit.key} -> ${hit.targetKey}`);
|
|
2192
|
-
} else {
|
|
2193
|
-
row.dropped++;
|
|
2194
|
-
if (row.examples.length < 3) row.examples.push(`${hit.key} (kept existing ${hit.targetKey})`);
|
|
2195
|
-
}
|
|
2196
|
-
delete toolsBySender[hit.key];
|
|
2197
|
-
summary.set(hit.pathLabel, row);
|
|
2198
|
-
changed = true;
|
|
2199
|
-
}
|
|
2200
|
-
if (!changed) return {
|
|
2201
|
-
config: cfg,
|
|
2202
|
-
changes: []
|
|
2203
|
-
};
|
|
2204
|
-
const changes = [];
|
|
2205
|
-
for (const [pathLabel, row] of summary) {
|
|
2206
|
-
if (row.migrated > 0) {
|
|
2207
|
-
const suffix = row.examples.length > 0 ? ` (${row.examples.join(", ")})` : "";
|
|
2208
|
-
changes.push(`- ${pathLabel}: migrated ${row.migrated} legacy key${row.migrated === 1 ? "" : "s"} to typed id: entries${suffix}.`);
|
|
2209
|
-
}
|
|
2210
|
-
if (row.dropped > 0) changes.push(`- ${pathLabel}: removed ${row.dropped} legacy key${row.dropped === 1 ? "" : "s"} where typed id: entries already existed.`);
|
|
2211
|
-
}
|
|
2212
|
-
return {
|
|
2213
|
-
config: next,
|
|
2214
|
-
changes
|
|
2215
|
-
};
|
|
2216
|
-
}
|
|
2217
|
-
async function maybeMigrateLegacyConfig() {
|
|
2218
|
-
const changes = [];
|
|
2219
|
-
const home = resolveHomeDir();
|
|
2220
|
-
if (!home) return changes;
|
|
2221
|
-
const targetDir = path.join(home, ".moldclaw");
|
|
2222
|
-
const targetPath = path.join(targetDir, "moldclaw.json");
|
|
2223
|
-
try {
|
|
2224
|
-
await fs$1.access(targetPath);
|
|
2225
|
-
return changes;
|
|
2226
|
-
} catch {}
|
|
2227
|
-
const legacyCandidates = [
|
|
2228
|
-
path.join(home, ".clawdbot", "clawdbot.json"),
|
|
2229
|
-
path.join(home, ".moldbot", "moldbot.json"),
|
|
2230
|
-
path.join(home, ".moltbot", "moltbot.json")
|
|
2231
|
-
];
|
|
2232
|
-
let legacyPath = null;
|
|
2233
|
-
for (const candidate of legacyCandidates) try {
|
|
2234
|
-
await fs$1.access(candidate);
|
|
2235
|
-
legacyPath = candidate;
|
|
2236
|
-
break;
|
|
2237
|
-
} catch {}
|
|
2238
|
-
if (!legacyPath) return changes;
|
|
2239
|
-
await fs$1.mkdir(targetDir, { recursive: true });
|
|
2240
|
-
try {
|
|
2241
|
-
await fs$1.copyFile(legacyPath, targetPath, fs$1.constants.COPYFILE_EXCL);
|
|
2242
|
-
changes.push(`Migrated legacy config: ${legacyPath} -> ${targetPath}`);
|
|
2243
|
-
} catch {}
|
|
2244
|
-
return changes;
|
|
2245
|
-
}
|
|
2246
|
-
async function loadAndMaybeMigrateDoctorConfig(params) {
|
|
2247
|
-
const shouldRepair = params.options.repair === true || params.options.yes === true;
|
|
2248
|
-
const stateDirResult = await autoMigrateLegacyStateDir({ env: process.env });
|
|
2249
|
-
if (stateDirResult.changes.length > 0) note(stateDirResult.changes.map((entry) => `- ${entry}`).join("\n"), "Doctor changes");
|
|
2250
|
-
if (stateDirResult.warnings.length > 0) note(stateDirResult.warnings.map((entry) => `- ${entry}`).join("\n"), "Doctor warnings");
|
|
2251
|
-
const legacyConfigChanges = await maybeMigrateLegacyConfig();
|
|
2252
|
-
if (legacyConfigChanges.length > 0) note(legacyConfigChanges.map((entry) => `- ${entry}`).join("\n"), "Doctor changes");
|
|
2253
|
-
let snapshot = await readConfigFileSnapshot();
|
|
2254
|
-
const baseCfg = snapshot.config ?? {};
|
|
2255
|
-
let cfg = baseCfg;
|
|
2256
|
-
let candidate = structuredClone(baseCfg);
|
|
2257
|
-
let pendingChanges = false;
|
|
2258
|
-
let shouldWriteConfig = false;
|
|
2259
|
-
const fixHints = [];
|
|
2260
|
-
if (snapshot.exists && !snapshot.valid && snapshot.legacyIssues.length === 0) {
|
|
2261
|
-
note("Config invalid; doctor will run with best-effort config.", "Config");
|
|
2262
|
-
noteIncludeConfinementWarning(snapshot);
|
|
2263
|
-
}
|
|
2264
|
-
const warnings = snapshot.warnings ?? [];
|
|
2265
|
-
if (warnings.length > 0) note(formatConfigIssueLines(warnings, "-").join("\n"), "Config warnings");
|
|
2266
|
-
if (snapshot.legacyIssues.length > 0) {
|
|
2267
|
-
note(formatConfigIssueLines(snapshot.legacyIssues, "-").join("\n"), "Compatibility config keys detected");
|
|
2268
|
-
const { config: migrated, changes } = migrateLegacyConfig(snapshot.parsed);
|
|
2269
|
-
if (changes.length > 0) note(changes.join("\n"), "Doctor changes");
|
|
2270
|
-
if (migrated) {
|
|
2271
|
-
candidate = migrated;
|
|
2272
|
-
pendingChanges = pendingChanges || changes.length > 0;
|
|
2273
|
-
}
|
|
2274
|
-
if (shouldRepair) {
|
|
2275
|
-
if (migrated) cfg = migrated;
|
|
2276
|
-
} else fixHints.push(`Run "${formatCliCommand("moldclaw doctor --fix")}" to apply compatibility migrations.`);
|
|
2277
|
-
}
|
|
2278
|
-
const normalized = normalizeCompatibilityConfigValues(candidate);
|
|
2279
|
-
if (normalized.changes.length > 0) {
|
|
2280
|
-
note(normalized.changes.join("\n"), "Doctor changes");
|
|
2281
|
-
candidate = normalized.config;
|
|
2282
|
-
pendingChanges = true;
|
|
2283
|
-
if (shouldRepair) cfg = normalized.config;
|
|
2284
|
-
else fixHints.push(`Run "${formatCliCommand("moldclaw doctor --fix")}" to apply these changes.`);
|
|
2285
|
-
}
|
|
2286
|
-
const autoEnable = applyPluginAutoEnable({
|
|
2287
|
-
config: candidate,
|
|
2288
|
-
env: process.env
|
|
2289
|
-
});
|
|
2290
|
-
if (autoEnable.changes.length > 0) {
|
|
2291
|
-
note(autoEnable.changes.join("\n"), "Doctor changes");
|
|
2292
|
-
candidate = autoEnable.config;
|
|
2293
|
-
pendingChanges = true;
|
|
2294
|
-
if (shouldRepair) cfg = autoEnable.config;
|
|
2295
|
-
else fixHints.push(`Run "${formatCliCommand("moldclaw doctor --fix")}" to apply these changes.`);
|
|
2296
|
-
}
|
|
2297
|
-
const missingDefaultAccountBindingWarnings = collectMissingDefaultAccountBindingWarnings(candidate);
|
|
2298
|
-
if (missingDefaultAccountBindingWarnings.length > 0) note(missingDefaultAccountBindingWarnings.join("\n"), "Doctor warnings");
|
|
2299
|
-
const missingExplicitDefaultWarnings = collectMissingExplicitDefaultAccountWarnings(candidate);
|
|
2300
|
-
if (missingExplicitDefaultWarnings.length > 0) note(missingExplicitDefaultWarnings.join("\n"), "Doctor warnings");
|
|
2301
|
-
if (shouldRepair) {
|
|
2302
|
-
const repair = await maybeRepairTelegramAllowFromUsernames(candidate);
|
|
2303
|
-
if (repair.changes.length > 0) {
|
|
2304
|
-
note(repair.changes.join("\n"), "Doctor changes");
|
|
2305
|
-
candidate = repair.config;
|
|
2306
|
-
pendingChanges = true;
|
|
2307
|
-
cfg = repair.config;
|
|
2308
|
-
}
|
|
2309
|
-
const discordRepair = maybeRepairDiscordNumericIds(candidate);
|
|
2310
|
-
if (discordRepair.changes.length > 0) {
|
|
2311
|
-
note(discordRepair.changes.join("\n"), "Doctor changes");
|
|
2312
|
-
candidate = discordRepair.config;
|
|
2313
|
-
pendingChanges = true;
|
|
2314
|
-
cfg = discordRepair.config;
|
|
2315
|
-
}
|
|
2316
|
-
const allowFromRepair = maybeRepairOpenPolicyAllowFrom(candidate);
|
|
2317
|
-
if (allowFromRepair.changes.length > 0) {
|
|
2318
|
-
note(allowFromRepair.changes.join("\n"), "Doctor changes");
|
|
2319
|
-
candidate = allowFromRepair.config;
|
|
2320
|
-
pendingChanges = true;
|
|
2321
|
-
cfg = allowFromRepair.config;
|
|
2322
|
-
}
|
|
2323
|
-
const allowlistRepair = await maybeRepairAllowlistPolicyAllowFrom(candidate);
|
|
2324
|
-
if (allowlistRepair.changes.length > 0) {
|
|
2325
|
-
note(allowlistRepair.changes.join("\n"), "Doctor changes");
|
|
2326
|
-
candidate = allowlistRepair.config;
|
|
2327
|
-
pendingChanges = true;
|
|
2328
|
-
cfg = allowlistRepair.config;
|
|
2329
|
-
}
|
|
2330
|
-
const emptyAllowlistWarnings = detectEmptyAllowlistPolicy(candidate);
|
|
2331
|
-
if (emptyAllowlistWarnings.length > 0) note(emptyAllowlistWarnings.join("\n"), "Doctor warnings");
|
|
2332
|
-
const toolsBySenderRepair = maybeRepairLegacyToolsBySenderKeys(candidate);
|
|
2333
|
-
if (toolsBySenderRepair.changes.length > 0) {
|
|
2334
|
-
note(toolsBySenderRepair.changes.join("\n"), "Doctor changes");
|
|
2335
|
-
candidate = toolsBySenderRepair.config;
|
|
2336
|
-
pendingChanges = true;
|
|
2337
|
-
cfg = toolsBySenderRepair.config;
|
|
2338
|
-
}
|
|
2339
|
-
const safeBinProfileRepair = maybeRepairExecSafeBinProfiles(candidate);
|
|
2340
|
-
if (safeBinProfileRepair.changes.length > 0) {
|
|
2341
|
-
note(safeBinProfileRepair.changes.join("\n"), "Doctor changes");
|
|
2342
|
-
candidate = safeBinProfileRepair.config;
|
|
2343
|
-
pendingChanges = true;
|
|
2344
|
-
cfg = safeBinProfileRepair.config;
|
|
2345
|
-
}
|
|
2346
|
-
if (safeBinProfileRepair.warnings.length > 0) note(safeBinProfileRepair.warnings.join("\n"), "Doctor warnings");
|
|
2347
|
-
} else {
|
|
2348
|
-
const hits = scanTelegramAllowFromUsernameEntries(candidate);
|
|
2349
|
-
if (hits.length > 0) note([`- Telegram allowFrom contains ${hits.length} non-numeric entries (e.g. ${hits[0]?.entry ?? "@"}); Telegram authorization requires numeric sender IDs.`, `- Run "${formatCliCommand("moldclaw doctor --fix")}" to auto-resolve @username entries to numeric IDs (requires a Telegram bot token).`].join("\n"), "Doctor warnings");
|
|
2350
|
-
const discordHits = scanDiscordNumericIdEntries(candidate);
|
|
2351
|
-
if (discordHits.length > 0) note([`- Discord allowlists contain ${discordHits.length} numeric entries (e.g. ${discordHits[0]?.path}=${discordHits[0]?.entry}).`, `- Discord IDs must be strings; run "${formatCliCommand("moldclaw doctor --fix")}" to convert numeric IDs to quoted strings.`].join("\n"), "Doctor warnings");
|
|
2352
|
-
const allowFromScan = maybeRepairOpenPolicyAllowFrom(candidate);
|
|
2353
|
-
if (allowFromScan.changes.length > 0) note([...allowFromScan.changes, `- Run "${formatCliCommand("moldclaw doctor --fix")}" to add missing allowFrom wildcards.`].join("\n"), "Doctor warnings");
|
|
2354
|
-
const emptyAllowlistWarnings = detectEmptyAllowlistPolicy(candidate);
|
|
2355
|
-
if (emptyAllowlistWarnings.length > 0) note(emptyAllowlistWarnings.join("\n"), "Doctor warnings");
|
|
2356
|
-
const toolsBySenderHits = scanLegacyToolsBySenderKeys(candidate);
|
|
2357
|
-
if (toolsBySenderHits.length > 0) {
|
|
2358
|
-
const sample = toolsBySenderHits[0];
|
|
2359
|
-
const sampleLabel = sample ? `${sample.pathLabel}.${sample.key}` : "toolsBySender";
|
|
2360
|
-
note([
|
|
2361
|
-
`- Found ${toolsBySenderHits.length} legacy untyped toolsBySender key${toolsBySenderHits.length === 1 ? "" : "s"} (for example ${sampleLabel}).`,
|
|
2362
|
-
"- Untyped sender keys are deprecated; use explicit prefixes (id:, e164:, username:, name:).",
|
|
2363
|
-
`- Run "${formatCliCommand("moldclaw doctor --fix")}" to migrate legacy keys to typed id: entries.`
|
|
2364
|
-
].join("\n"), "Doctor warnings");
|
|
2365
|
-
}
|
|
2366
|
-
const safeBinCoverage = scanExecSafeBinCoverage(candidate);
|
|
2367
|
-
if (safeBinCoverage.length > 0) {
|
|
2368
|
-
const interpreterHits = safeBinCoverage.filter((hit) => hit.isInterpreter);
|
|
2369
|
-
const customHits = safeBinCoverage.filter((hit) => !hit.isInterpreter);
|
|
2370
|
-
const lines = [];
|
|
2371
|
-
if (interpreterHits.length > 0) {
|
|
2372
|
-
for (const hit of interpreterHits.slice(0, 5)) lines.push(`- ${hit.scopePath}.safeBins includes interpreter/runtime '${hit.bin}' without profile.`);
|
|
2373
|
-
if (interpreterHits.length > 5) lines.push(`- ${interpreterHits.length - 5} more interpreter/runtime safeBins entries are missing profiles.`);
|
|
2374
|
-
}
|
|
2375
|
-
if (customHits.length > 0) {
|
|
2376
|
-
for (const hit of customHits.slice(0, 5)) lines.push(`- ${hit.scopePath}.safeBins entry '${hit.bin}' is missing safeBinProfiles.${hit.bin}.`);
|
|
2377
|
-
if (customHits.length > 5) lines.push(`- ${customHits.length - 5} more custom safeBins entries are missing profiles.`);
|
|
2378
|
-
}
|
|
2379
|
-
lines.push(`- Run "${formatCliCommand("moldclaw doctor --fix")}" to scaffold missing custom safeBinProfiles entries.`);
|
|
2380
|
-
note(lines.join("\n"), "Doctor warnings");
|
|
2381
|
-
}
|
|
2382
|
-
const safeBinTrustedDirHints = scanExecSafeBinTrustedDirHints(candidate);
|
|
2383
|
-
if (safeBinTrustedDirHints.length > 0) {
|
|
2384
|
-
const lines = safeBinTrustedDirHints.slice(0, 5).map((hit) => `- ${hit.scopePath}.safeBins entry '${hit.bin}' resolves to '${hit.resolvedPath}' outside trusted safe-bin dirs.`);
|
|
2385
|
-
if (safeBinTrustedDirHints.length > 5) lines.push(`- ${safeBinTrustedDirHints.length - 5} more safeBins entries resolve outside trusted safe-bin dirs.`);
|
|
2386
|
-
lines.push("- If intentional, add the binary directory to tools.exec.safeBinTrustedDirs (global or agent scope).");
|
|
2387
|
-
note(lines.join("\n"), "Doctor warnings");
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
const mutableAllowlistHits = scanMutableAllowlistEntries(candidate);
|
|
2391
|
-
if (mutableAllowlistHits.length > 0) {
|
|
2392
|
-
const channels = Array.from(new Set(mutableAllowlistHits.map((hit) => hit.channel))).toSorted();
|
|
2393
|
-
const exampleLines = mutableAllowlistHits.slice(0, 8).map((hit) => `- ${hit.path}: ${hit.entry}`).join("\n");
|
|
2394
|
-
const remaining = mutableAllowlistHits.length > 8 ? `- +${mutableAllowlistHits.length - 8} more mutable allowlist entries.` : null;
|
|
2395
|
-
const flagPaths = Array.from(new Set(mutableAllowlistHits.map((hit) => hit.dangerousFlagPath)));
|
|
2396
|
-
const flagHint = flagPaths.length === 1 ? flagPaths[0] : `${flagPaths[0]} (and ${flagPaths.length - 1} other scope flags)`;
|
|
2397
|
-
note([
|
|
2398
|
-
`- Found ${mutableAllowlistHits.length} mutable allowlist ${mutableAllowlistHits.length === 1 ? "entry" : "entries"} across ${channels.join(", ")} while name matching is disabled by default.`,
|
|
2399
|
-
exampleLines,
|
|
2400
|
-
...remaining ? [remaining] : [],
|
|
2401
|
-
`- Option A (break-glass): enable ${flagHint}=true to keep name/email/nick matching.`,
|
|
2402
|
-
"- Option B (recommended): resolve names/emails/nicks to stable sender IDs and rewrite the allowlist entries."
|
|
2403
|
-
].join("\n"), "Doctor warnings");
|
|
2404
|
-
}
|
|
2405
|
-
const unknown = stripUnknownConfigKeys(candidate);
|
|
2406
|
-
if (unknown.removed.length > 0) {
|
|
2407
|
-
const lines = unknown.removed.map((path) => `- ${path}`).join("\n");
|
|
2408
|
-
candidate = unknown.config;
|
|
2409
|
-
pendingChanges = true;
|
|
2410
|
-
if (shouldRepair) {
|
|
2411
|
-
cfg = unknown.config;
|
|
2412
|
-
note(lines, "Doctor changes");
|
|
2413
|
-
} else {
|
|
2414
|
-
note(lines, "Unknown config keys");
|
|
2415
|
-
fixHints.push("Run \"moldclaw doctor --fix\" to remove these keys.");
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
if (!shouldRepair && pendingChanges) {
|
|
2419
|
-
if (await params.confirm({
|
|
2420
|
-
message: "Apply recommended config repairs now?",
|
|
2421
|
-
initialValue: true
|
|
2422
|
-
})) {
|
|
2423
|
-
cfg = candidate;
|
|
2424
|
-
shouldWriteConfig = true;
|
|
2425
|
-
} else if (fixHints.length > 0) note(fixHints.join("\n"), "Doctor");
|
|
2426
|
-
}
|
|
2427
|
-
if (shouldRepair && pendingChanges) shouldWriteConfig = true;
|
|
2428
|
-
noteOpencodeProviderOverrides(cfg);
|
|
2429
|
-
return {
|
|
2430
|
-
cfg,
|
|
2431
|
-
path: snapshot.path ?? CONFIG_PATH,
|
|
2432
|
-
shouldWriteConfig,
|
|
2433
|
-
sourceConfigValid: snapshot.valid
|
|
2434
|
-
};
|
|
2435
|
-
}
|
|
2436
|
-
//#endregion
|
|
2437
|
-
export { runLegacyStateMigrations as a, detectLegacyStateMigrations as i, collectMissingExplicitDefaultAccountWarnings as n, loadAndMaybeMigrateDoctorConfig as r, collectMissingDefaultAccountBindingWarnings as t };
|