@spacebar_ai/moldclaw-core 2026.3.43 → 2026.3.45
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-CxV5zzzp.js +114 -0
- package/dist/acp-cli-2JoKJ0xt.js +2093 -0
- package/dist/actions.runtime-BJPd9nat.js +119 -0
- package/dist/actions.runtime-DVs4a2cB.js +133 -0
- package/dist/agent-scope-lZlwP1At.js +208 -0
- package/dist/agents-CmT3Jwvj.js +222 -0
- package/dist/agents-D7Pebhph.js +853 -0
- package/dist/agents.config-CX9CPNfP.js +17 -0
- package/dist/agents.config-DF9Zwn9n.js +121 -0
- package/dist/allow-list-B3f4EqAM.js +81 -0
- package/dist/allowlist-_YpK0-4h.js +142 -0
- package/dist/api-B44giplI.js +117 -0
- package/dist/audit-C3InXm7H.js +787 -0
- package/dist/audit-ChWS6RiF.js +54 -0
- package/dist/audit-channel.collect.runtime-DZzrS6v2.js +605 -0
- package/dist/audit-channel.runtime-B2XTOsSF.js +121 -0
- package/dist/audit-extra.async-C2G0mqmk.js +813 -0
- package/dist/audit-membership-runtime-DOv5-eHo.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-Cvh2wmWM.js +118 -0
- package/dist/auth-Ch3Rchm4.js +101 -0
- package/dist/auth-choice-Beq0dWPS.js +268 -0
- package/dist/auth-choice-DZYg94gS.js +122 -0
- package/dist/auth-choice-TVG_8lJj.js +507 -0
- package/dist/auth-choice-options-B_qxsjdj.js +123 -0
- package/dist/auth-choice-prompt-BayzDobT.js +115 -0
- package/dist/auth-choice-prompt-_UES859x.js +36 -0
- package/dist/auth-choice.apply-helpers-BhbNIV8X.js +66 -0
- package/dist/auth-choice.plugin-providers.runtime-CVC4Jzhp.js +119 -0
- package/dist/auth-profiles-C-Ul-Qkn.js +128139 -0
- package/dist/auth-profiles.runtime-Clyka_jV.js +116 -0
- package/dist/banner-CojBHPWr.js +342 -0
- package/dist/bluebubbles-BnLsj2Fy.d.ts +6 -0
- package/dist/bluebubbles-irYTGbfn.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-34O87pvK.js +949 -0
- package/dist/channel-B3Xo_4d8.js +1598 -0
- package/dist/channel-BEqDvL49.js +397 -0
- package/dist/channel-BLOk9WRE.js +214 -0
- package/dist/channel-BY5H2cdy.js +803 -0
- package/dist/channel-BeOtzXIH.js +4681 -0
- package/dist/channel-Bt8x_5Kj.js +306 -0
- package/dist/channel-C3E8XWLF.js +1321 -0
- package/dist/channel-C6ngVfGr.js +943 -0
- package/dist/channel-CVDBca2b.js +226 -0
- package/dist/channel-Cctli72q.js +562 -0
- package/dist/channel-DEAbU9Dj2.js +316 -0
- package/dist/channel-DIULkrBN.js +575 -0
- package/dist/channel-DXb4gsSd.js +619 -0
- package/dist/channel-Dap9LY-9.js +352 -0
- package/dist/channel-DcJdUnab.js +538 -0
- package/dist/channel-ZYCQj3hP.js +207 -0
- package/dist/channel-account-context-Baszl3_B.js +103 -0
- package/dist/channel-hlzhFHDl.js +497 -0
- package/dist/channel-options-PwBzYYtq.js +50 -0
- package/dist/channel-plugin-ids-TZIY4hFs.js +26 -0
- package/dist/channel-summary-CCEAV13o.js +111 -0
- package/dist/channel-tY2Hg5ac.js +542 -0
- package/dist/channel-vMWcWq1U.js +920 -0
- package/dist/channel.runtime-8qWgkCxX.js +404 -0
- package/dist/channel.runtime-C4jtgrbI.js +179 -0
- package/dist/channel.runtime-CJ4ug6Mp.js +127 -0
- package/dist/channel.runtime-ChKRJAZ8.js +4011 -0
- package/dist/channel.runtime-Cj54LYU-.js +418 -0
- package/dist/channel.runtime-KH06-bu1.js +870 -0
- package/dist/channel.runtime-_GYnBh2X.js +199 -0
- package/dist/channel.runtime-go7Pzt6N.js +241 -0
- package/dist/channel.runtime-iypIZ0EU.js +171 -0
- package/dist/channel.runtime-mukTWpon.js +182 -0
- package/dist/channel.runtime-oNtF1sc3.js +218 -0
- package/dist/channel.setup-BZfok6kX.js +11 -0
- package/dist/channel.setup-CbXfZ2dq.js +9 -0
- package/dist/channel.setup-CfyM55np.js +8 -0
- package/dist/channel.setup-CoG-gJ6n.js +9 -0
- package/dist/channel.setup-Cp4PH_rc.js +57 -0
- package/dist/channel.setup-V2w9Jk9j.js +6 -0
- package/dist/channel.setup-t7F5WZE7.js +8 -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-H5ThmyG8.js +1118 -0
- package/dist/channels-cQ-6NFCQ.js +404 -0
- package/dist/channels-cli-TmchKLFS.js +291 -0
- package/dist/channels-status-issues-DXnkXEeJ.js +16 -0
- package/dist/clawbot-cli-Cpbxu8dD.js +118 -0
- package/dist/cleanup-utils-D0L17RsX.js +96 -0
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/cli--2bGSKdX.js +154 -0
- package/dist/command-registry-BaVPDmwn.js +242 -0
- package/dist/command-registry-DhLyeSbO.js +14 -0
- package/dist/command-secret-gateway-C5D_-jb0.js +111 -0
- package/dist/compact.runtime-C9a0kRAg.js +116 -0
- package/dist/completion-cli-Bg95upyk.js +17 -0
- package/dist/completion-cli-CrPdlnCH.js +445 -0
- package/dist/config-BbvDRSYp.js +31 -0
- package/dist/config-CwBv71QC.js +44 -0
- package/dist/config-cli-jsZsYhAl.js +678 -0
- package/dist/config-guard-DTaXXqly.js +118 -0
- package/dist/config-validation-Q6U1sP84.js +262 -0
- package/dist/config-value-DT3-5958.js +132 -0
- package/dist/configure-BJfMiVej.js +1100 -0
- package/dist/configure-Cist3Iza.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-Bktbk7iP.js +639 -0
- package/dist/daemon-cli-BXyH8DBL.js +339 -0
- package/dist/daemon-install-mxcGYsRJ.js +180 -0
- package/dist/deliver-BPYUKaSp.js +111 -0
- package/dist/deliver-runtime-CwnLQZTN.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-D253m0er.js +311 -0
- package/dist/directory-config-helpers-DpFcAbmo.d.ts +38 -0
- package/dist/directory.static-BXv9MXqm.js +44 -0
- package/dist/discord-DwFf1qp7.js +114 -0
- package/dist/discovery-DzRM1wzK.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-BPl6HiiZ.js +90 -0
- package/dist/doctor-config-flow-BHR1Ayyh.js +2437 -0
- package/dist/doctor-config-flow-PXVtrfkE.js +112 -0
- package/dist/enable-Cyagpq3b.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-DofujQf3.js +26437 -0
- package/dist/gateway-install-token-vvtOvufH.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-BvwsCVKl.d.ts +12 -0
- package/dist/googlechat-DzoFLiDG.js +307 -0
- package/dist/group-access-DpiQnd-G.d.ts +61 -0
- package/dist/health-CqUU_ecm.js +570 -0
- package/dist/health-Dzn8BT5I.js +113 -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-DtBvd1lb.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-C7Z59nbV.js +31 -0
- package/dist/imessage-scXvYYHX.js +115 -0
- package/dist/inbound-reply-dispatch-gzPJFtkc.js +71 -0
- package/dist/inbound-reply-dispatch-n7U3qg15.d.ts +72 -0
- package/dist/index.js +2 -2
- package/dist/install-target-B4n74f_B.js +574 -0
- package/dist/installs-e1WEcS2x.js +532 -0
- package/dist/io-BaBxjB1v.js +9739 -0
- package/dist/io-CgHb1Jld.js +29 -0
- package/dist/irc-DxJ7uOKl.js +672 -0
- package/dist/library-DjjiKiBC.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-BBiBiGgL.js +530 -0
- package/dist/llm-slug-generator-BQ09Fz6D.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-B2ElPfmb.js +112 -0
- package/dist/login-qr-Di3uPIK1.js +233 -0
- package/dist/logs-cli-CNzOvZ2d.js +256 -0
- package/dist/manager-runtime-2RwW64dE.js +111 -0
- package/dist/manager.runtime-BacHmSFL.js +715 -0
- package/dist/manifest-registry-CS_p1OBQ.js +1329 -0
- package/dist/matrix-43_RGLZN.d.ts +68 -0
- package/dist/matrix-6-xpfQHf.js +1269 -0
- package/dist/matrix-DKYdZvGK.js +1495 -0
- package/dist/mcp-cli-Ci2jvv3s.js +87 -0
- package/dist/media-understanding.runtime-0668UZMb.js +116 -0
- package/dist/memory-cli-BGfRJOPh.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-D9Gmg9vM.js +390 -0
- package/dist/model-picker-VOam6Dfa.js +112 -0
- package/dist/model-picker.runtime-B8h4yaGk.js +125 -0
- package/dist/model-selection-bBBxfXdb.js +653 -0
- package/dist/model-suppression.runtime-IpdzuuaW.js +116 -0
- package/dist/models-CEr8OkSA.js +118 -0
- package/dist/models-FgjlnyvT.js +2514 -0
- package/dist/models-cli-CdXULEZe.js +309 -0
- package/dist/models-config-UQxq76ac.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-BGAB5pZp.js +772 -0
- package/dist/monitor-C_1qA4q5.js +6823 -0
- package/dist/monitor-D8WcCUuA.js +782 -0
- package/dist/monitor-DesGoihT.js +113 -0
- package/dist/monitor-DhrUY3U6.js +3468 -0
- package/dist/monitor-DsDCIG87.js +3076 -0
- package/dist/monitor-dBB-luY7.js +115 -0
- package/dist/monitor-shared-CkicpwVc.js +444 -0
- package/dist/msteams-qmY7xMCK.js +852 -0
- package/dist/node-cli-B_2nTm80.js +2503 -0
- package/dist/node-resolve-BYC2FbO2.js +835 -0
- package/dist/nodes-cli-CBX71Wd_.js +1380 -0
- package/dist/nostr-BFKRoOlz.d.ts +7 -0
- package/dist/nostr-OB78XVlq.js +8744 -0
- package/dist/npm-resolution-DZJB3Hgh.js +60 -0
- package/dist/oauth-env-CLG8KOrz.js +10 -0
- package/dist/onboard-BON0C360.js +48 -0
- package/dist/onboard-DsKI17iq.js +25 -0
- package/dist/onboard-DyBwXVGT.js +589 -0
- package/dist/onboard-channels-BaVA02kK.js +1241 -0
- package/dist/onboard-channels-JJVMXpKl.js +205 -0
- package/dist/onboard-custom-D6YDrk9n.js +571 -0
- package/dist/onboard-custom-DqsNalL1.js +114 -0
- package/dist/onboard-helpers-DiSRTpZC.js +335 -0
- package/dist/onboard-helpers-DqZsjdb8.js +113 -0
- package/dist/onboard-hooks-pzEPZAvl.js +72 -0
- package/dist/onboard-remote-DFMLELsg.js +181 -0
- package/dist/onboard-remote-DmMYxY80.js +117 -0
- package/dist/onboard-search-B7FsNd7m.js +302 -0
- package/dist/onboard-skills-BJRdI-K3.js +133 -0
- package/dist/onboard-skills-Cg1YQAZa.js +117 -0
- package/dist/outbound-media-BHD4aJEX.d.ts +11 -0
- package/dist/outbound-media-CrraEXXv.js +11 -0
- package/dist/pairing-access-CzHpaM0R.d.ts +21 -0
- package/dist/pairing-cli-DSQTYgc0.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-vSSbBDFG.js +111 -0
- package/dist/pi-tools.before-tool-call.runtime-C5yLUogH.js +381 -0
- package/dist/plugin-install-B1RfdrdV.js +117 -0
- package/dist/plugin-install-C9aaL42Y.js +184 -0
- package/dist/plugin-install-plan-BlfDt117.js +49 -0
- package/dist/plugin-registry-D2P9SYJ9.js +113 -0
- package/dist/plugin-registry-QtjVXmj3.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-CAULK-lt.js +111 -0
- package/dist/plugins-cli-BGAgYy3Z.js +917 -0
- package/dist/policy-WKZJ8cPK.js +143 -0
- package/dist/preflight-audio.runtime-Bc6Hv-u4.js +116 -0
- package/dist/probe-B7a_VBCB.js +47 -0
- package/dist/probe-BLioBOhT.js +6329 -0
- package/dist/probe-BkM5pykD.js +21 -0
- package/dist/probe-DOEaWez2.js +1793 -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/program-zG0CuBsn.js +253 -0
- package/dist/prompt-select-styled-B-D6NQFO.js +2673 -0
- package/dist/provider-api-key-auth.runtime-DgGM_pHf.js +121 -0
- package/dist/provider-auth-choice-BOQA0idb.js +126 -0
- package/dist/provider-auth-choice-helpers-hzDkh3f1.js +48 -0
- package/dist/provider-auth-choice-preference-BPcuoO9b.js +189 -0
- package/dist/provider-auth-choice.runtime-B4E0A4J8.js +123 -0
- package/dist/provider-auth-choices-0KaDNPBQ.js +57 -0
- package/dist/provider-auth-guidance-BxxMxMEt.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-DFAIaPZT.js +111 -0
- package/dist/provider-self-hosted-setup-CclMg3QB.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-Cn_OrdMP.js +111 -0
- package/dist/provider-usage-kxemdMp2.js +633 -0
- package/dist/provider-wizard-BMc1Dzks.js +152 -0
- package/dist/push-apns-CuIs_G0k.js +1038 -0
- package/dist/pw-ai-DUe4BbH2.js +1867 -0
- package/dist/qmd-manager-CAAFp7qK.js +1570 -0
- package/dist/qr-cli-9H9go9JE.js +113 -0
- package/dist/qr-cli-Bxxttvx3.js +369 -0
- package/dist/reactions-Dx2ypGlm.js +281 -0
- package/dist/read-only-account-inspect.discord.runtime-D_RVd1-r.js +116 -0
- package/dist/read-only-account-inspect.slack.runtime-Ckl92Rhy.js +116 -0
- package/dist/read-only-account-inspect.telegram.runtime-D97ssjQk.js +116 -0
- package/dist/redact-snapshot-ojhTflxp.js +2663 -0
- package/dist/register.agent-DlBmy_RL.js +439 -0
- package/dist/register.backup-8nOYtJqg.js +625 -0
- package/dist/register.configure-BV_GUQ5w.js +252 -0
- package/dist/register.maintenance-BafAHBum.js +574 -0
- package/dist/register.message-CHhfcEq2.js +709 -0
- package/dist/register.onboard-DjPNnlnr.js +192 -0
- package/dist/register.setup-BMGXI9PG.js +212 -0
- package/dist/register.status-health-sessions-BJMsh2AL.js +498 -0
- package/dist/register.subclis-B7nrik3-.js +315 -0
- package/dist/register.subclis-BCoAVyGn.js +13 -0
- package/dist/replies-BU4AvOyD.js +110 -0
- package/dist/resolve-channels-CDfj5NGq.js +226 -0
- package/dist/resolve-channels-Cz120Lvf.js +262 -0
- package/dist/resolve-route-DdX-HBVt.js +538 -0
- package/dist/resolve-users-Bc6nRqpb.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-Cf8vXm6i.js +424 -0
- package/dist/runtime-Bitmi8Er.d.ts +26 -0
- package/dist/runtime-discord-ops.runtime-DWBnG-Hf.js +9078 -0
- package/dist/runtime-slack-ops.runtime-oYfbYvX4.js +4556 -0
- package/dist/runtime-telegram-ops.runtime-EPGDYN1f.js +133 -0
- package/dist/runtime-whatsapp-login.runtime-BGJoKM2h.js +114 -0
- package/dist/runtime-whatsapp-outbound.runtime-D3Sag6Bv.js +117 -0
- package/dist/sandbox-cli-waaYyhsC.js +535 -0
- package/dist/search-manager-BjDsOXzB.js +16 -0
- package/dist/search-manager-D-G9UaXe.js +386 -0
- package/dist/secrets-cli-BmeEhlzt.js +2070 -0
- package/dist/security-cli-CSsLnFuN.js +575 -0
- package/dist/send-6o7piqfv.js +100 -0
- package/dist/send-99FyFLgk.js +629 -0
- package/dist/send-B1pX9_Oc.js +283 -0
- package/dist/send-Dg5-AjXW.js +1025 -0
- package/dist/send-LdV9TRoN.js +631 -0
- package/dist/server-node-events-BAUUKNFW.js +506 -0
- package/dist/server-zI_K-D05.js +107 -0
- package/dist/sessions-DJGywtY2.js +112 -0
- package/dist/sessions-WR0GKdGl.js +218 -0
- package/dist/setup-2LvBON2J.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-ByqF8Nvc.js +166 -0
- package/dist/setup-core-COkq8Zop.js +205 -0
- package/dist/setup-core-C_o77DVV.js +143 -0
- package/dist/setup-core-tAdHbqi9.js +47 -0
- package/dist/setup-surface-DMHtZByF.js +490 -0
- package/dist/setup-wizard-helpers-r0J6l8ST.d.ts +203 -0
- package/dist/setup.finalize-pTkXn8pV.js +522 -0
- package/dist/setup.gateway-config-D1wiUQe6.js +343 -0
- package/dist/shared-BaM_tMxk.js +102 -0
- package/dist/shared-BgUgXsM9.js +75 -0
- package/dist/shared-CezRuVfl.js +96 -0
- package/dist/shared-DQgf3R0B.js +298 -0
- package/dist/shared-RA6kxQfu.js +182 -0
- package/dist/signal-xxP4dGx7.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-BIlG41ei.js +763 -0
- package/dist/skills-status-B08PtBc_.js +21 -0
- package/dist/skills-status-CzM008aB.js +169 -0
- package/dist/slack-Bzt3M7d8.js +114 -0
- package/dist/slash-commands.runtime-EYqj8SbV.js +128 -0
- package/dist/slash-dispatch.runtime-vWH92PUY.js +141 -0
- package/dist/slash-skill-commands.runtime-sUTjM3J0.js +116 -0
- package/dist/src-Iso9-DPo.js +1701 -0
- package/dist/status-8S882KRO.js +43 -0
- package/dist/status-BF7h_jTB.js +126 -0
- package/dist/status-DxOIyRm9.js +131 -0
- package/dist/status-HlvixAOq.js +606 -0
- package/dist/status-json-CShBo8A6.js +288 -0
- package/dist/status-qhtgsJFd.js +1599 -0
- package/dist/status.link-channel-D3dLYZiH.js +143 -0
- package/dist/status.scan.deps.runtime-mCmOLzpG.js +126 -0
- package/dist/status.scan.runtime-CYuUlDeg.js +119 -0
- package/dist/status.summary-BjB1aTjV.js +592 -0
- package/dist/status.summary.runtime-DW4MOt1Z.js +118 -0
- package/dist/status.update-BxblMS7P.js +77 -0
- package/dist/subagent-orphan-recovery-CCVopsdP.js +307 -0
- package/dist/subagent-registry-runtime-oG47Fzvg.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-CVy1tJGY.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-Dug8pd82.js +114 -0
- package/dist/text-chunking-CQ6ttpWs.js +84 -0
- package/dist/text-chunking-DDUU_vAF.d.ts +79 -0
- package/dist/tlon-BnckVr_7.js +433 -0
- package/dist/tui-DXTge9Ac.js +3834 -0
- package/dist/tui-cli-BRUfLUTd.js +137 -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--iP08xRA.js +31 -0
- package/dist/update-CtxBD-Cf.js +1036 -0
- package/dist/update-cli-DPE3GCHJ.js +1503 -0
- package/dist/update-offset-store-BlBY7dWj.js +112 -0
- package/dist/update-runner-Cfcrhf2j.js +1496 -0
- package/dist/upsert-with-lock-BZU7Le8n.js +33 -0
- package/dist/usage-Czgwvg0h.js +115 -0
- package/dist/web-BGDXhunB.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-CjxuEE9C.d.ts +106 -0
- package/dist/webhook-targets-Dtt6rH4N.js +181 -0
- package/dist/webhooks-cli-Wl9y6AWW.js +350 -0
- package/dist/whatsapp-D64cBQ_9.js +114 -0
- package/dist/whatsapp-actions-CVoTcagb.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-DxoY8M22.js +415 -0
- package/dist/zalouser-DTHIrPvs.js +30911 -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 +1 -1
- package/dist/accounts-CS8U4v8C.js +0 -114
- package/dist/accounts-gLr-Udmt.d.ts +0 -103
- 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-U2sAfO4_.d.ts +0 -6
- package/dist/bot-DW12K3bO.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-dPA4nFkn.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-CpU1oflo.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-73A52W6E.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-B5JDcyF9.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-De-T7C31.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-B5pYs_d7.d.ts +0 -6
- package/dist/hooks-cli-B7uGJs2O.js +0 -1000
- package/dist/hooks-status-CfceaUSg.js +0 -78
- package/dist/http-registry-C-KXqwnj.d.ts +0 -20
- package/dist/identity-file-sshkKKIr.js +0 -60
- package/dist/image-generation-CafM5hZh.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-DmL0KWLe.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-CGsemKWJ.js +0 -530
- package/dist/line-CKU3ER-n.d.ts +0 -75
- 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-DiABGjJR.js +0 -1269
- package/dist/matrix-fC6NrFM5.d.ts +0 -68
- 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-B1bbs9Qd.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-BKB5JH9M.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-D8scBiYq.d.ts +0 -7
- package/dist/nostr-DBTFTxKs.js +0 -8744
- 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-CgNYEQWb.d.ts +0 -11
- package/dist/outbound-media-DYRO2vTD.js +0 -11
- package/dist/pairing-access-Dsiu5Mvl.d.ts +0 -21
- package/dist/pairing-cli-BOnv0TYn.js +0 -217
- package/dist/perplexity-EZwC3y2b.js +0 -24
- package/dist/persistent-dedupe-DMLOqJ23.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-Cw6qIhO-.d.ts +0 -18
- package/dist/provider-models-BCId_Lfu.js +0 -2113
- package/dist/provider-models-Ok-DrSiY.d.ts +0 -867
- package/dist/provider-ollama-setup-B6XJZ0So.js +0 -314
- package/dist/provider-ollama-setup-lGDdTl0b.d.ts +0 -32
- package/dist/provider-onboard-CSPi7jOK.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-Df91By-J.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-D61jzMiI.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-BSPXdMuK.d.ts +0 -37
- package/dist/setup-DGszQH0_.js +0 -387
- 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-Ck9wDR0b.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-DzB11ONk.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-BKldC9YN.d.ts +0 -22692
- package/dist/types-MeyueBE0.d.ts +0 -45
- 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-C2qHVxw1.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-DP_EkQa4.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-C9OQRYRw.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
|
@@ -0,0 +1,2673 @@
|
|
|
1
|
+
import { o as getResolvedLoggerSettings } from "./logger-BFfIIIKH.js";
|
|
2
|
+
import { _ as resolveStateDir, d as resolveIsNixMode, h as resolveOAuthDir, t as CONFIG_PATH, u as resolveGatewayPort, x as resolveRequiredHomeDir } from "./paths-D6AgsMTU.js";
|
|
3
|
+
import { n as defaultRuntime } from "./runtime-_tQz41uA.js";
|
|
4
|
+
import { t as isTruthyEnvValue$1 } from "./env-D42cffog.js";
|
|
5
|
+
import { C as sleep, S as shortenHomePath, y as resolveUserPath } from "./utils-C7ykRPCQ.js";
|
|
6
|
+
import { h as isWSLEnv, p as isWSL } from "./setup-binary-CcAv8NXz.js";
|
|
7
|
+
import { $a as DEFAULT_OAUTH_WARN_MS, AE as updateAuthProfileStoreWithLock, Ad as resolveDmAllowState, Fn as loadmoldClawPlugins, LC as loadCronStore, Pn as resolvePluginProviders, RC as resolveCronStorePath, T as listChannelPlugins, Vb as loadModelCatalog, Xc as analyzeBootstrapBudget, Zc as buildBootstrapInjectionStats, ch as hasConfiguredMemorySecretInput, d as resolveProfileUnusableUntilForDisplay, eo as buildAuthHealthSummary, fE as resolveBootstrapMaxChars, hE as repairOAuthProfileIdMismatch, km as noteOpenAIOAuthTlsPrerequisites, mE as resolveApiKeyForProfile, mf as resolveBootstrapContextForRun, pE as resolveBootstrapTotalMaxChars, rC as loadSessionStore, sx as resolveApiKeyForProvider, to as formatRemainingShort, wE as ensureAuthProfileStore, y as resolveAgentSessionDirs, zC as saveCronStore } from "./auth-profiles-C-Ul-Qkn.js";
|
|
8
|
+
import { O as DEFAULT_MODEL, g as resolveHooksGmailModel, i as getModelRefStatus, k as DEFAULT_PROVIDER, m as resolveConfiguredModelRef } from "./model-selection-bBBxfXdb.js";
|
|
9
|
+
import { a as resolveAgentDir, m as resolveDefaultAgentId, p as resolveAgentWorkspaceDir } from "./agent-scope-lZlwP1At.js";
|
|
10
|
+
import { S as parseAgentSessionKey } from "./session-key-UoG7Kfw5.js";
|
|
11
|
+
import { n as runCommandWithTimeout, r as runExec } from "./exec-CvEtXqTZ.js";
|
|
12
|
+
import { t as resolvemoldClawPackageRoot } from "./moldclaw-root-Cb6HRlUO.js";
|
|
13
|
+
import { t as DEFAULT_AGENTS_FILENAME } from "./workspace-DJ_S272u.js";
|
|
14
|
+
import { f as readConfigFileSnapshot, y as writeConfigFile } from "./io-BaBxjB1v.js";
|
|
15
|
+
import { a as hasConfiguredSecretInput, d as resolveSecretInputRef } from "./types.secrets-Ca-9L8vU.js";
|
|
16
|
+
import { P as cleanStaleLockFiles, at as DEFAULT_SANDBOX_IMAGE, rt as DEFAULT_SANDBOX_BROWSER_IMAGE, z as resolveSandboxScope } from "./workspace-dirs-CGeIPpGN.js";
|
|
17
|
+
import { m as resolveGatewayAuth } from "./config-BwkGZjD5.js";
|
|
18
|
+
import { t as formatCliCommand } from "./command-format-C_z0Ru-7.js";
|
|
19
|
+
import { r as isLoopbackHost, u as resolveGatewayBindHost } from "./net-K181nxTH.js";
|
|
20
|
+
import { d as readGatewayTokenEnv } from "./credentials-D-5Pb-aZ.js";
|
|
21
|
+
import { C as parseBrowserMajorVersion, T as resolveGoogleChromeExecutableForPlatform, at as resolveConfiguredSecretInputWithFallback, ct as hasAmbiguousGatewayAuthModeConfig, w as readBrowserVersion } from "./routes-CcJNnwTF.js";
|
|
22
|
+
import { a as inspectPortUsage, c as formatPortDiagnostics } from "./ports-Ca74cFb2.js";
|
|
23
|
+
import { n as isPrimarySessionTranscriptFileName, t as formatSessionArchiveTimestamp } from "./artifacts-CeyjTq21.js";
|
|
24
|
+
import { f as resolveMainSessionKey } from "./lazy-runtime-BoGB4usD.js";
|
|
25
|
+
import { c as resolveSessionTranscriptsDirForAgent, i as resolveSessionFilePathOptions, l as resolveStorePath, r as resolveSessionFilePath } from "./paths-ApLcu1Uu.js";
|
|
26
|
+
import { n as callGateway, t as buildGatewayConnectionDetails } from "./call-gdDAt07d.js";
|
|
27
|
+
import { t as resolveMemorySearchConfig } from "./memory-search-tTD5o_rU.js";
|
|
28
|
+
import { r as resolveMemoryBackendConfig } from "./search-manager-D-G9UaXe.js";
|
|
29
|
+
import { n as logConfigUpdated } from "./logging-CdisccbY.js";
|
|
30
|
+
import { i as stylePromptTitle, n as stylePromptHint, r as stylePromptMessage, t as note$1 } from "./note-dOl5kPAy.js";
|
|
31
|
+
import { f as resolveGatewaySystemdServiceName, h as resolveNodeLaunchAgentLabel, l as resolveGatewayLaunchAgentLabel, p as resolveGatewayWindowsTaskName } from "./constants-BHwb0DmS.js";
|
|
32
|
+
import { a as resolveSystemNodeInfo, r as renderSystemNodeWarning } from "./runtime-paths-BfFqPvDh.js";
|
|
33
|
+
import { n as buildGatewayInstallPlan, r as gatewayInstallErrorHint, t as resolveGatewayInstallToken } from "./gateway-install-token-vvtOvufH.js";
|
|
34
|
+
import { n as GATEWAY_DAEMON_RUNTIME_OPTIONS, t as DEFAULT_GATEWAY_DAEMON_RUNTIME } from "./daemon-runtime-BR9EstPe.js";
|
|
35
|
+
import { f as printWizardHeader, m as randomToken, n as applyWizardMetadata, s as guardCancel } from "./onboard-helpers-DiSRTpZC.js";
|
|
36
|
+
import { i as launchAgentPlistExists, n as isLaunchAgentListed, r as isLaunchAgentLoaded, s as repairLaunchAgentBootstrap } from "./launchd-DTK8FAln.js";
|
|
37
|
+
import { n as resolveGatewayService, t as describeGatewayServiceRestart } from "./service-D-iBQb7Y.js";
|
|
38
|
+
import { i as isSystemdUserServiceAvailable, u as uninstallLegacySystemdUnits } from "./systemd-C3JL-Eyf.js";
|
|
39
|
+
import { c as buildPlatformRuntimeLogHints, i as auditGatewayServiceConfig, n as renderSystemdUnavailableHints, o as needsNodeRuntimeMigration, r as SERVICE_AUDIT_CODES, s as readEmbeddedGatewayToken, t as isSystemdUnavailableDetail, u as formatRuntimeStatus } from "./systemd-hints-DabP9g6b.js";
|
|
40
|
+
import { t as readLastGatewayErrorLine } from "./diagnostics-BKzgYuW7.js";
|
|
41
|
+
import { n as renderGatewayServiceCleanupHints, t as findExtraGatewayServices } from "./inspect-kDEu5Qgf.js";
|
|
42
|
+
import { t as buildWorkspaceSkillStatus } from "./skills-status-CzM008aB.js";
|
|
43
|
+
import { r as healthCommand } from "./health-CqUU_ecm.js";
|
|
44
|
+
import { i as resolveControlUiDistIndexPathForRoot, r as resolveControlUiDistIndexHealth } from "./control-ui-assets-C1YDYi82.js";
|
|
45
|
+
import { p as normalizeStoredCronJobs, t as runGatewayUpdate } from "./update-runner-Cfcrhf2j.js";
|
|
46
|
+
import { t as collectChannelStatusIssues } from "./channels-status-issues-DXnkXEeJ.js";
|
|
47
|
+
import { n as resolveProviderAuthLoginCommand, t as buildProviderAuthRecoveryHint } from "./provider-auth-guidance-BxxMxMEt.js";
|
|
48
|
+
import { t as ensureSystemdUserLingerInteractive } from "./systemd-linger-C6Aja8xE.js";
|
|
49
|
+
import { t as formatHealthCheckFailure } from "./health-format-BN81wqbV.js";
|
|
50
|
+
import { n as doctorShellCompletion } from "./doctor-completion-BPl6HiiZ.js";
|
|
51
|
+
import { a as runLegacyStateMigrations, i as detectLegacyStateMigrations, r as loadAndMaybeMigrateDoctorConfig } from "./doctor-config-flow-BHR1Ayyh.js";
|
|
52
|
+
import { t as resolveDefaultChannelAccountContext } from "./channel-account-context-Baszl3_B.js";
|
|
53
|
+
import fs from "node:fs";
|
|
54
|
+
import path from "node:path";
|
|
55
|
+
import { execFile } from "node:child_process";
|
|
56
|
+
import os from "node:os";
|
|
57
|
+
import { promisify } from "node:util";
|
|
58
|
+
import fs$1 from "node:fs/promises";
|
|
59
|
+
import { confirm, intro, outro, select } from "@clack/prompts";
|
|
60
|
+
//#region src/commands/doctor-auth.ts
|
|
61
|
+
async function maybeRepairAnthropicOAuthProfileId(cfg, prompter) {
|
|
62
|
+
const repair = repairOAuthProfileIdMismatch({
|
|
63
|
+
cfg,
|
|
64
|
+
store: ensureAuthProfileStore(),
|
|
65
|
+
provider: "anthropic",
|
|
66
|
+
legacyProfileId: "anthropic:default"
|
|
67
|
+
});
|
|
68
|
+
if (!repair.migrated || repair.changes.length === 0) return cfg;
|
|
69
|
+
note$1(repair.changes.map((c) => `- ${c}`).join("\n"), "Auth profiles");
|
|
70
|
+
if (!await prompter.confirm({
|
|
71
|
+
message: "Update Anthropic OAuth profile id in config now?",
|
|
72
|
+
initialValue: true
|
|
73
|
+
})) return cfg;
|
|
74
|
+
return repair.config;
|
|
75
|
+
}
|
|
76
|
+
function pruneAuthOrder(order, profileIds) {
|
|
77
|
+
if (!order) return {
|
|
78
|
+
next: order,
|
|
79
|
+
changed: false
|
|
80
|
+
};
|
|
81
|
+
let changed = false;
|
|
82
|
+
const next = {};
|
|
83
|
+
for (const [provider, list] of Object.entries(order)) {
|
|
84
|
+
const filtered = list.filter((id) => !profileIds.has(id));
|
|
85
|
+
if (filtered.length !== list.length) changed = true;
|
|
86
|
+
if (filtered.length > 0) next[provider] = filtered;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
next: Object.keys(next).length > 0 ? next : void 0,
|
|
90
|
+
changed
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function pruneAuthProfiles(cfg, profileIds) {
|
|
94
|
+
const profiles = cfg.auth?.profiles;
|
|
95
|
+
const order = cfg.auth?.order;
|
|
96
|
+
const nextProfiles = profiles ? { ...profiles } : void 0;
|
|
97
|
+
let changed = false;
|
|
98
|
+
if (nextProfiles) {
|
|
99
|
+
for (const id of profileIds) if (id in nextProfiles) {
|
|
100
|
+
delete nextProfiles[id];
|
|
101
|
+
changed = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const prunedOrder = pruneAuthOrder(order, profileIds);
|
|
105
|
+
if (prunedOrder.changed) changed = true;
|
|
106
|
+
if (!changed) return {
|
|
107
|
+
next: cfg,
|
|
108
|
+
changed: false
|
|
109
|
+
};
|
|
110
|
+
const nextAuth = nextProfiles || prunedOrder.next ? {
|
|
111
|
+
...cfg.auth,
|
|
112
|
+
profiles: nextProfiles && Object.keys(nextProfiles).length > 0 ? nextProfiles : void 0,
|
|
113
|
+
order: prunedOrder.next
|
|
114
|
+
} : void 0;
|
|
115
|
+
return {
|
|
116
|
+
next: {
|
|
117
|
+
...cfg,
|
|
118
|
+
auth: nextAuth
|
|
119
|
+
},
|
|
120
|
+
changed: true
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async function maybeRemoveDeprecatedCliAuthProfiles(cfg, prompter) {
|
|
124
|
+
const store = ensureAuthProfileStore(void 0, { allowKeychainPrompt: false });
|
|
125
|
+
const deprecatedEntries = resolvePluginProviders({
|
|
126
|
+
config: cfg,
|
|
127
|
+
env: process.env,
|
|
128
|
+
bundledProviderAllowlistCompat: true,
|
|
129
|
+
bundledProviderVitestCompat: true
|
|
130
|
+
}).flatMap((provider) => (provider.deprecatedProfileIds ?? []).filter((profileId) => store.profiles[profileId] || cfg.auth?.profiles?.[profileId]).map((profileId) => ({
|
|
131
|
+
profileId,
|
|
132
|
+
providerId: provider.id,
|
|
133
|
+
providerLabel: provider.label
|
|
134
|
+
})));
|
|
135
|
+
const deprecated = new Set(deprecatedEntries.map((entry) => entry.profileId));
|
|
136
|
+
if (deprecated.size === 0) return cfg;
|
|
137
|
+
const lines = ["Deprecated external CLI auth profiles detected (no longer supported):"];
|
|
138
|
+
for (const entry of deprecatedEntries) {
|
|
139
|
+
const authCommand = resolveProviderAuthLoginCommand({
|
|
140
|
+
provider: entry.providerId,
|
|
141
|
+
config: cfg,
|
|
142
|
+
env: process.env
|
|
143
|
+
}) ?? formatCliCommand("moldclaw configure");
|
|
144
|
+
lines.push(`- ${entry.profileId} (${entry.providerLabel}): use ${authCommand}`);
|
|
145
|
+
}
|
|
146
|
+
note$1(lines.join("\n"), "Auth profiles");
|
|
147
|
+
if (!await prompter.confirmRepair({
|
|
148
|
+
message: "Remove deprecated CLI auth profiles now?",
|
|
149
|
+
initialValue: true
|
|
150
|
+
})) return cfg;
|
|
151
|
+
await updateAuthProfileStoreWithLock({ updater: (nextStore) => {
|
|
152
|
+
let mutated = false;
|
|
153
|
+
for (const id of deprecated) {
|
|
154
|
+
if (nextStore.profiles[id]) {
|
|
155
|
+
delete nextStore.profiles[id];
|
|
156
|
+
mutated = true;
|
|
157
|
+
}
|
|
158
|
+
if (nextStore.usageStats?.[id]) {
|
|
159
|
+
delete nextStore.usageStats[id];
|
|
160
|
+
mutated = true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (nextStore.order) for (const [provider, list] of Object.entries(nextStore.order)) {
|
|
164
|
+
const filtered = list.filter((id) => !deprecated.has(id));
|
|
165
|
+
if (filtered.length !== list.length) {
|
|
166
|
+
mutated = true;
|
|
167
|
+
if (filtered.length > 0) nextStore.order[provider] = filtered;
|
|
168
|
+
else delete nextStore.order[provider];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (nextStore.lastGood) {
|
|
172
|
+
for (const [provider, profileId] of Object.entries(nextStore.lastGood)) if (deprecated.has(profileId)) {
|
|
173
|
+
delete nextStore.lastGood[provider];
|
|
174
|
+
mutated = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return mutated;
|
|
178
|
+
} });
|
|
179
|
+
const pruned = pruneAuthProfiles(cfg, deprecated);
|
|
180
|
+
if (pruned.changed) note$1(Array.from(deprecated.values()).map((id) => `- removed ${id} from config`).join("\n"), "Doctor changes");
|
|
181
|
+
return pruned.next;
|
|
182
|
+
}
|
|
183
|
+
function resolveUnusableProfileHint(params) {
|
|
184
|
+
if (params.kind === "disabled") {
|
|
185
|
+
if (params.reason === "billing") return "Top up credits (provider billing) or switch provider.";
|
|
186
|
+
if (params.reason === "auth_permanent" || params.reason === "auth") return "Refresh or replace credentials, then retry.";
|
|
187
|
+
}
|
|
188
|
+
return "Wait for cooldown or switch provider.";
|
|
189
|
+
}
|
|
190
|
+
function formatAuthIssueHint(issue) {
|
|
191
|
+
if (issue.reasonCode === "invalid_expires") return "Invalid token expires metadata. Set a future Unix ms timestamp or remove expires.";
|
|
192
|
+
if (issue.provider === "anthropic" && issue.profileId === "anthropic:claude-cli") return `Deprecated profile. ${buildProviderAuthRecoveryHint({ provider: "anthropic" })}`;
|
|
193
|
+
if (issue.provider === "openai-codex" && issue.profileId === "openai-codex:codex-cli") return `Deprecated profile. ${buildProviderAuthRecoveryHint({ provider: "openai-codex" })}`;
|
|
194
|
+
return buildProviderAuthRecoveryHint({ provider: issue.provider }).replace(/^Run /, "Re-auth via ");
|
|
195
|
+
}
|
|
196
|
+
function formatAuthIssueLine(issue) {
|
|
197
|
+
const remaining = issue.remainingMs !== void 0 ? ` (${formatRemainingShort(issue.remainingMs)})` : "";
|
|
198
|
+
const hint = formatAuthIssueHint(issue);
|
|
199
|
+
const reason = issue.reasonCode ? ` [${issue.reasonCode}]` : "";
|
|
200
|
+
return `- ${issue.profileId}: ${issue.status}${reason}${remaining}${hint ? ` — ${hint}` : ""}`;
|
|
201
|
+
}
|
|
202
|
+
async function noteAuthProfileHealth(params) {
|
|
203
|
+
const store = ensureAuthProfileStore(void 0, { allowKeychainPrompt: params.allowKeychainPrompt });
|
|
204
|
+
const unusable = (() => {
|
|
205
|
+
const now = Date.now();
|
|
206
|
+
const out = [];
|
|
207
|
+
for (const profileId of Object.keys(store.usageStats ?? {})) {
|
|
208
|
+
const until = resolveProfileUnusableUntilForDisplay(store, profileId);
|
|
209
|
+
if (!until || now >= until) continue;
|
|
210
|
+
const stats = store.usageStats?.[profileId];
|
|
211
|
+
const remaining = formatRemainingShort(until - now);
|
|
212
|
+
const disabledActive = typeof stats?.disabledUntil === "number" && now < stats.disabledUntil;
|
|
213
|
+
const kind = disabledActive ? `disabled${stats.disabledReason ? `:${stats.disabledReason}` : ""}` : "cooldown";
|
|
214
|
+
const hint = resolveUnusableProfileHint({
|
|
215
|
+
kind: disabledActive ? "disabled" : "cooldown",
|
|
216
|
+
reason: stats?.disabledReason
|
|
217
|
+
});
|
|
218
|
+
out.push(`- ${profileId}: ${kind} (${remaining})${hint ? ` — ${hint}` : ""}`);
|
|
219
|
+
}
|
|
220
|
+
return out;
|
|
221
|
+
})();
|
|
222
|
+
if (unusable.length > 0) note$1(unusable.join("\n"), "Auth profile cooldowns");
|
|
223
|
+
let summary = buildAuthHealthSummary({
|
|
224
|
+
store,
|
|
225
|
+
cfg: params.cfg,
|
|
226
|
+
warnAfterMs: DEFAULT_OAUTH_WARN_MS
|
|
227
|
+
});
|
|
228
|
+
const findIssues = () => summary.profiles.filter((profile) => (profile.type === "oauth" || profile.type === "token") && (profile.status === "expired" || profile.status === "expiring" || profile.status === "missing"));
|
|
229
|
+
let issues = findIssues();
|
|
230
|
+
if (issues.length === 0) return;
|
|
231
|
+
if (await params.prompter.confirmRepair({
|
|
232
|
+
message: "Refresh expiring OAuth tokens now? (static tokens need re-auth)",
|
|
233
|
+
initialValue: true
|
|
234
|
+
})) {
|
|
235
|
+
const refreshTargets = issues.filter((issue) => issue.type === "oauth" && [
|
|
236
|
+
"expired",
|
|
237
|
+
"expiring",
|
|
238
|
+
"missing"
|
|
239
|
+
].includes(issue.status));
|
|
240
|
+
const errors = [];
|
|
241
|
+
for (const profile of refreshTargets) try {
|
|
242
|
+
await resolveApiKeyForProfile({
|
|
243
|
+
cfg: params.cfg,
|
|
244
|
+
store,
|
|
245
|
+
profileId: profile.profileId
|
|
246
|
+
});
|
|
247
|
+
} catch (err) {
|
|
248
|
+
errors.push(`- ${profile.profileId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
249
|
+
}
|
|
250
|
+
if (errors.length > 0) note$1(errors.join("\n"), "OAuth refresh errors");
|
|
251
|
+
summary = buildAuthHealthSummary({
|
|
252
|
+
store: ensureAuthProfileStore(void 0, { allowKeychainPrompt: false }),
|
|
253
|
+
cfg: params.cfg,
|
|
254
|
+
warnAfterMs: DEFAULT_OAUTH_WARN_MS
|
|
255
|
+
});
|
|
256
|
+
issues = findIssues();
|
|
257
|
+
}
|
|
258
|
+
if (issues.length > 0) note$1(issues.map((issue) => formatAuthIssueLine({
|
|
259
|
+
profileId: issue.profileId,
|
|
260
|
+
provider: issue.provider,
|
|
261
|
+
status: issue.status,
|
|
262
|
+
reasonCode: issue.reasonCode,
|
|
263
|
+
remainingMs: issue.remainingMs
|
|
264
|
+
})).join("\n"), "Model auth");
|
|
265
|
+
}
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/commands/doctor-bootstrap-size.ts
|
|
268
|
+
function formatInt(value) {
|
|
269
|
+
return new Intl.NumberFormat("en-US").format(Math.max(0, Math.floor(value)));
|
|
270
|
+
}
|
|
271
|
+
function formatPercent(numerator, denominator) {
|
|
272
|
+
if (!Number.isFinite(denominator) || denominator <= 0) return "0%";
|
|
273
|
+
return `${Math.min(100, Math.max(0, Math.round(numerator / denominator * 100)))}%`;
|
|
274
|
+
}
|
|
275
|
+
function formatCauses(causes) {
|
|
276
|
+
if (causes.length === 0) return "unknown";
|
|
277
|
+
return causes.map((cause) => cause === "per-file-limit" ? "max/file" : "max/total").join(", ");
|
|
278
|
+
}
|
|
279
|
+
async function noteBootstrapFileSize(cfg) {
|
|
280
|
+
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
|
281
|
+
const bootstrapMaxChars = resolveBootstrapMaxChars(cfg);
|
|
282
|
+
const bootstrapTotalMaxChars = resolveBootstrapTotalMaxChars(cfg);
|
|
283
|
+
const { bootstrapFiles, contextFiles } = await resolveBootstrapContextForRun({
|
|
284
|
+
workspaceDir,
|
|
285
|
+
config: cfg
|
|
286
|
+
});
|
|
287
|
+
const analysis = analyzeBootstrapBudget({
|
|
288
|
+
files: buildBootstrapInjectionStats({
|
|
289
|
+
bootstrapFiles,
|
|
290
|
+
injectedFiles: contextFiles
|
|
291
|
+
}),
|
|
292
|
+
bootstrapMaxChars,
|
|
293
|
+
bootstrapTotalMaxChars
|
|
294
|
+
});
|
|
295
|
+
if (!analysis.hasTruncation && analysis.nearLimitFiles.length === 0 && !analysis.totalNearLimit) return analysis;
|
|
296
|
+
const lines = [];
|
|
297
|
+
if (analysis.hasTruncation) {
|
|
298
|
+
lines.push("Workspace bootstrap files exceed limits and will be truncated:");
|
|
299
|
+
for (const file of analysis.truncatedFiles) {
|
|
300
|
+
const truncatedChars = Math.max(0, file.rawChars - file.injectedChars);
|
|
301
|
+
lines.push(`- ${file.name}: ${formatInt(file.rawChars)} raw / ${formatInt(file.injectedChars)} injected (${formatPercent(truncatedChars, file.rawChars)} truncated; ${formatCauses(file.causes)})`);
|
|
302
|
+
}
|
|
303
|
+
} else lines.push("Workspace bootstrap files are near configured limits:");
|
|
304
|
+
const nonTruncatedNearLimit = analysis.nearLimitFiles.filter((file) => !file.truncated);
|
|
305
|
+
if (nonTruncatedNearLimit.length > 0) for (const file of nonTruncatedNearLimit) lines.push(`- ${file.name}: ${formatInt(file.rawChars)} chars (${formatPercent(file.rawChars, bootstrapMaxChars)} of max/file ${formatInt(bootstrapMaxChars)})`);
|
|
306
|
+
lines.push(`Total bootstrap injected chars: ${formatInt(analysis.totals.injectedChars)} (${formatPercent(analysis.totals.injectedChars, bootstrapTotalMaxChars)} of max/total ${formatInt(bootstrapTotalMaxChars)}).`);
|
|
307
|
+
lines.push(`Total bootstrap raw chars (before truncation): ${formatInt(analysis.totals.rawChars)}.`);
|
|
308
|
+
const needsPerFileTip = analysis.truncatedFiles.some((file) => file.causes.includes("per-file-limit")) || analysis.nearLimitFiles.length > 0;
|
|
309
|
+
const needsTotalTip = analysis.truncatedFiles.some((file) => file.causes.includes("total-limit")) || analysis.totalNearLimit;
|
|
310
|
+
if (needsPerFileTip || needsTotalTip) lines.push("");
|
|
311
|
+
if (needsPerFileTip) lines.push("- Tip: tune `agents.defaults.bootstrapMaxChars` for per-file limits.");
|
|
312
|
+
if (needsTotalTip) lines.push("- Tip: tune `agents.defaults.bootstrapTotalMaxChars` for total-budget limits.");
|
|
313
|
+
note$1(lines.join("\n"), "Bootstrap file size");
|
|
314
|
+
return analysis;
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/commands/doctor-browser.ts
|
|
318
|
+
const CHROME_MCP_MIN_MAJOR = 144;
|
|
319
|
+
const REMOTE_DEBUGGING_PAGES = [
|
|
320
|
+
"chrome://inspect/#remote-debugging",
|
|
321
|
+
"brave://inspect/#remote-debugging",
|
|
322
|
+
"edge://inspect/#remote-debugging"
|
|
323
|
+
].join(", ");
|
|
324
|
+
function asRecord(value) {
|
|
325
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
326
|
+
}
|
|
327
|
+
function collectChromeMcpProfiles(cfg) {
|
|
328
|
+
const browser = asRecord(cfg.browser);
|
|
329
|
+
if (!browser) return [];
|
|
330
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
331
|
+
if ((typeof browser.defaultProfile === "string" ? browser.defaultProfile.trim() : "") === "user") profiles.set("user", { name: "user" });
|
|
332
|
+
const configuredProfiles = asRecord(browser.profiles);
|
|
333
|
+
if (!configuredProfiles) return [...profiles.values()].toSorted((a, b) => a.name.localeCompare(b.name));
|
|
334
|
+
for (const [profileName, rawProfile] of Object.entries(configuredProfiles)) {
|
|
335
|
+
const profile = asRecord(rawProfile);
|
|
336
|
+
if ((typeof profile?.driver === "string" ? profile.driver.trim() : "") === "existing-session") {
|
|
337
|
+
const userDataDir = typeof profile?.userDataDir === "string" ? profile.userDataDir.trim() : void 0;
|
|
338
|
+
profiles.set(profileName, {
|
|
339
|
+
name: profileName,
|
|
340
|
+
userDataDir: userDataDir || void 0
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return [...profiles.values()].toSorted((a, b) => a.name.localeCompare(b.name));
|
|
345
|
+
}
|
|
346
|
+
async function noteChromeMcpBrowserReadiness(cfg, deps) {
|
|
347
|
+
const profiles = collectChromeMcpProfiles(cfg);
|
|
348
|
+
if (profiles.length === 0) return;
|
|
349
|
+
const noteFn = deps?.noteFn ?? note$1;
|
|
350
|
+
const platform = deps?.platform ?? process.platform;
|
|
351
|
+
const resolveChromeExecutable = deps?.resolveChromeExecutable ?? resolveGoogleChromeExecutableForPlatform;
|
|
352
|
+
const readVersion = deps?.readVersion ?? readBrowserVersion;
|
|
353
|
+
const explicitProfiles = profiles.filter((profile) => profile.userDataDir);
|
|
354
|
+
const autoConnectProfiles = profiles.filter((profile) => !profile.userDataDir);
|
|
355
|
+
const profileLabel = profiles.map((profile) => profile.name).join(", ");
|
|
356
|
+
if (autoConnectProfiles.length === 0) {
|
|
357
|
+
noteFn([
|
|
358
|
+
`- Chrome MCP existing-session is configured for profile(s): ${profileLabel}.`,
|
|
359
|
+
"- These profiles use an explicit Chromium user data directory instead of Chrome's default auto-connect path.",
|
|
360
|
+
`- Verify the matching Chromium-based browser is version ${CHROME_MCP_MIN_MAJOR}+ on the same host as the Gateway or node.`,
|
|
361
|
+
`- Enable remote debugging in that browser's inspect page (${REMOTE_DEBUGGING_PAGES}).`,
|
|
362
|
+
"- Keep the browser running and accept the attach consent prompt the first time moldClaw connects."
|
|
363
|
+
].join("\n"), "Browser");
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const chrome = resolveChromeExecutable(platform);
|
|
367
|
+
const autoProfileLabel = autoConnectProfiles.map((profile) => profile.name).join(", ");
|
|
368
|
+
if (!chrome) {
|
|
369
|
+
const lines = [
|
|
370
|
+
`- Chrome MCP existing-session is configured for profile(s): ${profileLabel}.`,
|
|
371
|
+
`- Google Chrome was not found on this host for auto-connect profile(s): ${autoProfileLabel}. moldClaw does not bundle Chrome.`,
|
|
372
|
+
`- Install Google Chrome ${CHROME_MCP_MIN_MAJOR}+ on the same host as the Gateway or node, or set browser.profiles.<name>.userDataDir for a different Chromium-based browser.`,
|
|
373
|
+
`- Enable remote debugging in the browser inspect page (${REMOTE_DEBUGGING_PAGES}).`,
|
|
374
|
+
"- Keep the browser running and accept the attach consent prompt the first time moldClaw connects.",
|
|
375
|
+
"- Docker, headless, and sandbox browser flows stay on raw CDP; this check only applies to host-local Chrome MCP attach."
|
|
376
|
+
];
|
|
377
|
+
if (explicitProfiles.length > 0) lines.push(`- Profiles with explicit userDataDir skip Chrome auto-detection: ${explicitProfiles.map((profile) => profile.name).join(", ")}.`);
|
|
378
|
+
noteFn(lines.join("\n"), "Browser");
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const versionRaw = readVersion(chrome.path);
|
|
382
|
+
const major = parseBrowserMajorVersion(versionRaw);
|
|
383
|
+
const lines = [`- Chrome MCP existing-session is configured for profile(s): ${profileLabel}.`, `- Chrome path: ${chrome.path}`];
|
|
384
|
+
if (!versionRaw || major === null) lines.push(`- Could not determine the installed Chrome version. Chrome MCP requires Google Chrome ${CHROME_MCP_MIN_MAJOR}+ on this host.`);
|
|
385
|
+
else if (major < CHROME_MCP_MIN_MAJOR) lines.push(`- Detected Chrome ${versionRaw}, which is too old for Chrome MCP existing-session attach. Upgrade to Chrome ${CHROME_MCP_MIN_MAJOR}+.`);
|
|
386
|
+
else lines.push(`- Detected Chrome ${versionRaw}.`);
|
|
387
|
+
lines.push(`- Enable remote debugging in the browser inspect page (${REMOTE_DEBUGGING_PAGES}).`);
|
|
388
|
+
lines.push("- Keep the browser running and accept the attach consent prompt the first time moldClaw connects.");
|
|
389
|
+
if (explicitProfiles.length > 0) lines.push(`- Profiles with explicit userDataDir still need manual validation of the matching Chromium-based browser: ${explicitProfiles.map((profile) => profile.name).join(", ")}.`);
|
|
390
|
+
noteFn(lines.join("\n"), "Browser");
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/commands/doctor-cron.ts
|
|
394
|
+
function pluralize(count, noun) {
|
|
395
|
+
return `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
396
|
+
}
|
|
397
|
+
function formatLegacyIssuePreview(issues) {
|
|
398
|
+
const lines = [];
|
|
399
|
+
if (issues.jobId) lines.push(`- ${pluralize(issues.jobId, "job")} still uses legacy \`jobId\``);
|
|
400
|
+
if (issues.legacyScheduleString) lines.push(`- ${pluralize(issues.legacyScheduleString, "job")} stores schedule as a bare string`);
|
|
401
|
+
if (issues.legacyScheduleCron) lines.push(`- ${pluralize(issues.legacyScheduleCron, "job")} still uses \`schedule.cron\``);
|
|
402
|
+
if (issues.legacyPayloadKind) lines.push(`- ${pluralize(issues.legacyPayloadKind, "job")} needs payload kind normalization`);
|
|
403
|
+
if (issues.legacyPayloadProvider) lines.push(`- ${pluralize(issues.legacyPayloadProvider, "job")} still uses payload \`provider\` as a delivery alias`);
|
|
404
|
+
if (issues.legacyTopLevelPayloadFields) lines.push(`- ${pluralize(issues.legacyTopLevelPayloadFields, "job")} still uses top-level payload fields`);
|
|
405
|
+
if (issues.legacyTopLevelDeliveryFields) lines.push(`- ${pluralize(issues.legacyTopLevelDeliveryFields, "job")} still uses top-level delivery fields`);
|
|
406
|
+
if (issues.legacyDeliveryMode) lines.push(`- ${pluralize(issues.legacyDeliveryMode, "job")} still uses delivery mode \`deliver\``);
|
|
407
|
+
return lines;
|
|
408
|
+
}
|
|
409
|
+
function trimString(value) {
|
|
410
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
411
|
+
}
|
|
412
|
+
function migrateLegacyNotifyFallback(params) {
|
|
413
|
+
let changed = false;
|
|
414
|
+
const warnings = [];
|
|
415
|
+
for (const raw of params.jobs) {
|
|
416
|
+
if (!("notify" in raw)) continue;
|
|
417
|
+
const jobName = trimString(raw.name) ?? trimString(raw.id) ?? "<unnamed>";
|
|
418
|
+
if (!(raw.notify === true)) {
|
|
419
|
+
delete raw.notify;
|
|
420
|
+
changed = true;
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
const delivery = raw.delivery && typeof raw.delivery === "object" && !Array.isArray(raw.delivery) ? raw.delivery : null;
|
|
424
|
+
const mode = trimString(delivery?.mode)?.toLowerCase();
|
|
425
|
+
const to = trimString(delivery?.to);
|
|
426
|
+
if (mode === "webhook" && to) {
|
|
427
|
+
delete raw.notify;
|
|
428
|
+
changed = true;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
if ((mode === void 0 || mode === "none" || mode === "webhook") && params.legacyWebhook) {
|
|
432
|
+
raw.delivery = {
|
|
433
|
+
...delivery,
|
|
434
|
+
mode: "webhook",
|
|
435
|
+
to: mode === "none" ? params.legacyWebhook : to ?? params.legacyWebhook
|
|
436
|
+
};
|
|
437
|
+
delete raw.notify;
|
|
438
|
+
changed = true;
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
if (!params.legacyWebhook) {
|
|
442
|
+
warnings.push(`Cron job "${jobName}" still uses legacy notify fallback, but cron.webhook is unset so doctor cannot migrate it automatically.`);
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
warnings.push(`Cron job "${jobName}" uses legacy notify fallback alongside delivery mode "${mode}". Migrate it manually so webhook delivery does not replace existing announce behavior.`);
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
changed,
|
|
449
|
+
warnings
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
async function maybeRepairLegacyCronStore(params) {
|
|
453
|
+
const storePath = resolveCronStorePath(params.cfg.cron?.store);
|
|
454
|
+
const rawJobs = (await loadCronStore(storePath)).jobs ?? [];
|
|
455
|
+
if (rawJobs.length === 0) return;
|
|
456
|
+
const normalized = normalizeStoredCronJobs(rawJobs);
|
|
457
|
+
const legacyWebhook = trimString(params.cfg.cron?.webhook);
|
|
458
|
+
const notifyCount = rawJobs.filter((job) => job.notify === true).length;
|
|
459
|
+
const previewLines = formatLegacyIssuePreview(normalized.issues);
|
|
460
|
+
if (notifyCount > 0) previewLines.push(`- ${pluralize(notifyCount, "job")} still uses legacy \`notify: true\` webhook fallback`);
|
|
461
|
+
if (previewLines.length === 0) return;
|
|
462
|
+
note$1([
|
|
463
|
+
`Legacy cron job storage detected at ${shortenHomePath(storePath)}.`,
|
|
464
|
+
...previewLines,
|
|
465
|
+
`Repair with ${formatCliCommand("moldclaw doctor --fix")} to normalize the store before the next scheduler run.`
|
|
466
|
+
].join("\n"), "Cron");
|
|
467
|
+
if (!await params.prompter.confirm({
|
|
468
|
+
message: "Repair legacy cron jobs now?",
|
|
469
|
+
initialValue: true
|
|
470
|
+
})) return;
|
|
471
|
+
const notifyMigration = migrateLegacyNotifyFallback({
|
|
472
|
+
jobs: rawJobs,
|
|
473
|
+
legacyWebhook
|
|
474
|
+
});
|
|
475
|
+
const changed = normalized.mutated || notifyMigration.changed;
|
|
476
|
+
if (!changed && notifyMigration.warnings.length === 0) return;
|
|
477
|
+
if (changed) {
|
|
478
|
+
await saveCronStore(storePath, {
|
|
479
|
+
version: 1,
|
|
480
|
+
jobs: rawJobs
|
|
481
|
+
});
|
|
482
|
+
note$1(`Cron store normalized at ${shortenHomePath(storePath)}.`, "Doctor changes");
|
|
483
|
+
}
|
|
484
|
+
if (notifyMigration.warnings.length > 0) note$1(notifyMigration.warnings.join("\n"), "Doctor warnings");
|
|
485
|
+
}
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/commands/doctor-format.ts
|
|
488
|
+
function formatGatewayRuntimeSummary(runtime) {
|
|
489
|
+
return formatRuntimeStatus(runtime);
|
|
490
|
+
}
|
|
491
|
+
function buildGatewayRuntimeHints(runtime, options = {}) {
|
|
492
|
+
const hints = [];
|
|
493
|
+
if (!runtime) return hints;
|
|
494
|
+
const platform = options.platform ?? process.platform;
|
|
495
|
+
const env = options.env ?? process.env;
|
|
496
|
+
const fileLog = (() => {
|
|
497
|
+
try {
|
|
498
|
+
return getResolvedLoggerSettings().file;
|
|
499
|
+
} catch {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
502
|
+
})();
|
|
503
|
+
if (platform === "linux" && isSystemdUnavailableDetail(runtime.detail)) {
|
|
504
|
+
hints.push(...renderSystemdUnavailableHints({ wsl: isWSLEnv() }));
|
|
505
|
+
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
|
506
|
+
return hints;
|
|
507
|
+
}
|
|
508
|
+
if (runtime.cachedLabel && platform === "darwin") {
|
|
509
|
+
const label = resolveGatewayLaunchAgentLabel(env.MOLDCLAW_PROFILE);
|
|
510
|
+
hints.push(`LaunchAgent label cached but plist missing. Clear with: launchctl bootout gui/$UID/${label}`);
|
|
511
|
+
hints.push(`Then reinstall: ${formatCliCommand("moldclaw gateway install", env)}`);
|
|
512
|
+
}
|
|
513
|
+
if (runtime.missingUnit) {
|
|
514
|
+
hints.push(`Service not installed. Run: ${formatCliCommand("moldclaw gateway install", env)}`);
|
|
515
|
+
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
|
516
|
+
return hints;
|
|
517
|
+
}
|
|
518
|
+
if (runtime.status === "stopped") {
|
|
519
|
+
hints.push("Service is loaded but not running (likely exited immediately).");
|
|
520
|
+
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
|
521
|
+
hints.push(...buildPlatformRuntimeLogHints({
|
|
522
|
+
platform,
|
|
523
|
+
env,
|
|
524
|
+
systemdServiceName: resolveGatewaySystemdServiceName(env.MOLDCLAW_PROFILE),
|
|
525
|
+
windowsTaskName: resolveGatewayWindowsTaskName(env.MOLDCLAW_PROFILE)
|
|
526
|
+
}));
|
|
527
|
+
}
|
|
528
|
+
return hints;
|
|
529
|
+
}
|
|
530
|
+
//#endregion
|
|
531
|
+
//#region src/commands/doctor-gateway-daemon-flow.ts
|
|
532
|
+
async function maybeRepairLaunchAgentBootstrap(params) {
|
|
533
|
+
if (process.platform !== "darwin") return false;
|
|
534
|
+
if (!await isLaunchAgentListed({ env: params.env })) return false;
|
|
535
|
+
if (await isLaunchAgentLoaded({ env: params.env })) return false;
|
|
536
|
+
if (!await launchAgentPlistExists(params.env)) return false;
|
|
537
|
+
note$1("LaunchAgent is listed but not loaded in launchd.", `${params.title} LaunchAgent`);
|
|
538
|
+
if (!await params.prompter.confirmSkipInNonInteractive({
|
|
539
|
+
message: `Repair ${params.title} LaunchAgent bootstrap now?`,
|
|
540
|
+
initialValue: true
|
|
541
|
+
})) return false;
|
|
542
|
+
params.runtime.log(`Bootstrapping ${params.title} LaunchAgent...`);
|
|
543
|
+
const repair = await repairLaunchAgentBootstrap({ env: params.env });
|
|
544
|
+
if (!repair.ok) {
|
|
545
|
+
params.runtime.error(`${params.title} LaunchAgent bootstrap failed: ${repair.detail ?? "unknown error"}`);
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
if (!await isLaunchAgentLoaded({ env: params.env })) {
|
|
549
|
+
params.runtime.error(`${params.title} LaunchAgent still not loaded after repair.`);
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
note$1(`${params.title} LaunchAgent repaired.`, `${params.title} LaunchAgent`);
|
|
553
|
+
return true;
|
|
554
|
+
}
|
|
555
|
+
async function maybeRepairGatewayDaemon(params) {
|
|
556
|
+
if (params.healthOk) return;
|
|
557
|
+
const service = resolveGatewayService();
|
|
558
|
+
let loaded = false;
|
|
559
|
+
try {
|
|
560
|
+
loaded = await service.isLoaded({ env: process.env });
|
|
561
|
+
} catch {
|
|
562
|
+
loaded = false;
|
|
563
|
+
}
|
|
564
|
+
let serviceRuntime;
|
|
565
|
+
if (loaded) serviceRuntime = await service.readRuntime(process.env).catch(() => void 0);
|
|
566
|
+
if (process.platform === "darwin" && params.cfg.gateway?.mode !== "remote") {
|
|
567
|
+
const gatewayRepaired = await maybeRepairLaunchAgentBootstrap({
|
|
568
|
+
env: process.env,
|
|
569
|
+
title: "Gateway",
|
|
570
|
+
runtime: params.runtime,
|
|
571
|
+
prompter: params.prompter
|
|
572
|
+
});
|
|
573
|
+
await maybeRepairLaunchAgentBootstrap({
|
|
574
|
+
env: {
|
|
575
|
+
...process.env,
|
|
576
|
+
MOLDCLAW_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel()
|
|
577
|
+
},
|
|
578
|
+
title: "Node",
|
|
579
|
+
runtime: params.runtime,
|
|
580
|
+
prompter: params.prompter
|
|
581
|
+
});
|
|
582
|
+
if (gatewayRepaired) {
|
|
583
|
+
loaded = await service.isLoaded({ env: process.env });
|
|
584
|
+
if (loaded) serviceRuntime = await service.readRuntime(process.env).catch(() => void 0);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
if (params.cfg.gateway?.mode !== "remote") {
|
|
588
|
+
const diagnostics = await inspectPortUsage(resolveGatewayPort(params.cfg, process.env));
|
|
589
|
+
if (diagnostics.status === "busy") note$1(formatPortDiagnostics(diagnostics).join("\n"), "Gateway port");
|
|
590
|
+
else if (loaded && serviceRuntime?.status === "running") {
|
|
591
|
+
const lastError = await readLastGatewayErrorLine(process.env);
|
|
592
|
+
if (lastError) note$1(`Last gateway error: ${lastError}`, "Gateway");
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (!loaded) {
|
|
596
|
+
if (process.platform === "linux") {
|
|
597
|
+
if (!await isSystemdUserServiceAvailable().catch(() => false)) {
|
|
598
|
+
note$1(renderSystemdUnavailableHints({ wsl: await isWSL() }).join("\n"), "Gateway");
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
note$1("Gateway service not installed.", "Gateway");
|
|
603
|
+
if (params.cfg.gateway?.mode !== "remote") {
|
|
604
|
+
if (await params.prompter.confirmSkipInNonInteractive({
|
|
605
|
+
message: "Install gateway service now?",
|
|
606
|
+
initialValue: true
|
|
607
|
+
})) {
|
|
608
|
+
const daemonRuntime = await params.prompter.select({
|
|
609
|
+
message: "Gateway service runtime",
|
|
610
|
+
options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
|
611
|
+
initialValue: DEFAULT_GATEWAY_DAEMON_RUNTIME
|
|
612
|
+
}, DEFAULT_GATEWAY_DAEMON_RUNTIME);
|
|
613
|
+
const tokenResolution = await resolveGatewayInstallToken({
|
|
614
|
+
config: params.cfg,
|
|
615
|
+
env: process.env
|
|
616
|
+
});
|
|
617
|
+
for (const warning of tokenResolution.warnings) note$1(warning, "Gateway");
|
|
618
|
+
if (tokenResolution.unavailableReason) {
|
|
619
|
+
note$1([
|
|
620
|
+
"Gateway service install aborted.",
|
|
621
|
+
tokenResolution.unavailableReason,
|
|
622
|
+
"Fix gateway auth config/token input and rerun doctor."
|
|
623
|
+
].join("\n"), "Gateway");
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
const port = resolveGatewayPort(params.cfg, process.env);
|
|
627
|
+
const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
|
|
628
|
+
env: process.env,
|
|
629
|
+
port,
|
|
630
|
+
runtime: daemonRuntime,
|
|
631
|
+
warn: (message, title) => note$1(message, title),
|
|
632
|
+
config: params.cfg
|
|
633
|
+
});
|
|
634
|
+
try {
|
|
635
|
+
await service.install({
|
|
636
|
+
env: process.env,
|
|
637
|
+
stdout: process.stdout,
|
|
638
|
+
programArguments,
|
|
639
|
+
workingDirectory,
|
|
640
|
+
environment
|
|
641
|
+
});
|
|
642
|
+
} catch (err) {
|
|
643
|
+
note$1(`Gateway service install failed: ${String(err)}`, "Gateway");
|
|
644
|
+
note$1(gatewayInstallErrorHint(), "Gateway");
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
const summary = formatGatewayRuntimeSummary(serviceRuntime);
|
|
651
|
+
const hints = buildGatewayRuntimeHints(serviceRuntime, {
|
|
652
|
+
platform: process.platform,
|
|
653
|
+
env: process.env
|
|
654
|
+
});
|
|
655
|
+
if (summary || hints.length > 0) {
|
|
656
|
+
const lines = [];
|
|
657
|
+
if (summary) lines.push(`Runtime: ${summary}`);
|
|
658
|
+
lines.push(...hints);
|
|
659
|
+
note$1(lines.join("\n"), "Gateway");
|
|
660
|
+
}
|
|
661
|
+
if (serviceRuntime?.status !== "running") {
|
|
662
|
+
if (await params.prompter.confirmSkipInNonInteractive({
|
|
663
|
+
message: "Start gateway service now?",
|
|
664
|
+
initialValue: true
|
|
665
|
+
})) {
|
|
666
|
+
const restartStatus = describeGatewayServiceRestart("Gateway", await service.restart({
|
|
667
|
+
env: process.env,
|
|
668
|
+
stdout: process.stdout
|
|
669
|
+
}));
|
|
670
|
+
if (!restartStatus.scheduled) await sleep(1500);
|
|
671
|
+
else note$1(restartStatus.message, "Gateway");
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (process.platform === "darwin") {
|
|
675
|
+
const label = resolveGatewayLaunchAgentLabel(process.env.MOLDCLAW_PROFILE);
|
|
676
|
+
note$1(`LaunchAgent loaded; stopping requires "${formatCliCommand("moldclaw gateway stop")}" or launchctl bootout gui/$UID/${label}.`, "Gateway");
|
|
677
|
+
}
|
|
678
|
+
if (serviceRuntime?.status === "running") {
|
|
679
|
+
if (await params.prompter.confirmSkipInNonInteractive({
|
|
680
|
+
message: "Restart gateway service now?",
|
|
681
|
+
initialValue: true
|
|
682
|
+
})) {
|
|
683
|
+
const restartStatus = describeGatewayServiceRestart("Gateway", await service.restart({
|
|
684
|
+
env: process.env,
|
|
685
|
+
stdout: process.stdout
|
|
686
|
+
}));
|
|
687
|
+
if (restartStatus.scheduled) {
|
|
688
|
+
note$1(restartStatus.message, "Gateway");
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
await sleep(1500);
|
|
692
|
+
try {
|
|
693
|
+
await healthCommand({
|
|
694
|
+
json: false,
|
|
695
|
+
timeoutMs: 1e4
|
|
696
|
+
}, params.runtime);
|
|
697
|
+
} catch (err) {
|
|
698
|
+
if (String(err).includes("gateway closed")) {
|
|
699
|
+
note$1("Gateway not running.", "Gateway");
|
|
700
|
+
note$1(params.gatewayDetailsMessage, "Gateway connection");
|
|
701
|
+
} else params.runtime.error(formatHealthCheckFailure(err));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
//#endregion
|
|
707
|
+
//#region src/commands/doctor-gateway-health.ts
|
|
708
|
+
async function checkGatewayHealth(params) {
|
|
709
|
+
const gatewayDetails = buildGatewayConnectionDetails({ config: params.cfg });
|
|
710
|
+
const timeoutMs = typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 1e4;
|
|
711
|
+
let healthOk = false;
|
|
712
|
+
try {
|
|
713
|
+
await healthCommand({
|
|
714
|
+
json: false,
|
|
715
|
+
timeoutMs,
|
|
716
|
+
config: params.cfg
|
|
717
|
+
}, params.runtime);
|
|
718
|
+
healthOk = true;
|
|
719
|
+
} catch (err) {
|
|
720
|
+
if (String(err).includes("gateway closed")) {
|
|
721
|
+
note$1("Gateway not running.", "Gateway");
|
|
722
|
+
note$1(gatewayDetails.message, "Gateway connection");
|
|
723
|
+
} else params.runtime.error(formatHealthCheckFailure(err));
|
|
724
|
+
}
|
|
725
|
+
if (healthOk) try {
|
|
726
|
+
const issues = collectChannelStatusIssues(await callGateway({
|
|
727
|
+
method: "channels.status",
|
|
728
|
+
params: {
|
|
729
|
+
probe: true,
|
|
730
|
+
timeoutMs: 5e3
|
|
731
|
+
},
|
|
732
|
+
timeoutMs: 6e3
|
|
733
|
+
}));
|
|
734
|
+
if (issues.length > 0) note$1(issues.map((issue) => `- ${issue.channel} ${issue.accountId}: ${issue.message}${issue.fix ? ` (${issue.fix})` : ""}`).join("\n"), "Channel warnings");
|
|
735
|
+
} catch {}
|
|
736
|
+
return { healthOk };
|
|
737
|
+
}
|
|
738
|
+
async function probeGatewayMemoryStatus(params) {
|
|
739
|
+
const timeoutMs = typeof params.timeoutMs === "number" && params.timeoutMs > 0 ? params.timeoutMs : 8e3;
|
|
740
|
+
try {
|
|
741
|
+
const payload = await callGateway({
|
|
742
|
+
method: "doctor.memory.status",
|
|
743
|
+
timeoutMs,
|
|
744
|
+
config: params.cfg
|
|
745
|
+
});
|
|
746
|
+
return {
|
|
747
|
+
checked: true,
|
|
748
|
+
ready: payload.embedding.ok,
|
|
749
|
+
error: payload.embedding.error
|
|
750
|
+
};
|
|
751
|
+
} catch (err) {
|
|
752
|
+
return {
|
|
753
|
+
checked: true,
|
|
754
|
+
ready: false,
|
|
755
|
+
error: `gateway memory probe unavailable: ${err instanceof Error ? err.message : String(err)}`
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/commands/doctor-gateway-auth-token.ts
|
|
761
|
+
async function resolveGatewayAuthTokenForService(cfg, env) {
|
|
762
|
+
const resolved = await resolveConfiguredSecretInputWithFallback({
|
|
763
|
+
config: cfg,
|
|
764
|
+
env,
|
|
765
|
+
value: cfg.gateway?.auth?.token,
|
|
766
|
+
path: "gateway.auth.token",
|
|
767
|
+
unresolvedReasonStyle: "detailed",
|
|
768
|
+
readFallback: () => readGatewayTokenEnv(env)
|
|
769
|
+
});
|
|
770
|
+
if (resolved.value) return { token: resolved.value };
|
|
771
|
+
if (!resolved.secretRefConfigured) return {};
|
|
772
|
+
if (resolved.unresolvedRefReason?.includes("resolved to an empty value")) return { unavailableReason: resolved.unresolvedRefReason };
|
|
773
|
+
return { unavailableReason: `gateway.auth.token SecretRef is configured but unresolved (${resolved.unresolvedRefReason ?? "unknown reason"}).` };
|
|
774
|
+
}
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region src/commands/doctor-gateway-services.ts
|
|
777
|
+
const execFileAsync$1 = promisify(execFile);
|
|
778
|
+
function detectGatewayRuntime(programArguments) {
|
|
779
|
+
const first = programArguments?.[0];
|
|
780
|
+
if (first) {
|
|
781
|
+
const base = path.basename(first).toLowerCase();
|
|
782
|
+
if (base === "bun" || base === "bun.exe") return "bun";
|
|
783
|
+
if (base === "node" || base === "node.exe") return "node";
|
|
784
|
+
}
|
|
785
|
+
return DEFAULT_GATEWAY_DAEMON_RUNTIME;
|
|
786
|
+
}
|
|
787
|
+
function findGatewayEntrypoint(programArguments) {
|
|
788
|
+
if (!programArguments || programArguments.length === 0) return null;
|
|
789
|
+
const gatewayIndex = programArguments.indexOf("gateway");
|
|
790
|
+
if (gatewayIndex <= 0) return null;
|
|
791
|
+
return programArguments[gatewayIndex - 1] ?? null;
|
|
792
|
+
}
|
|
793
|
+
async function normalizeExecutablePath(value) {
|
|
794
|
+
const resolvedPath = path.resolve(value);
|
|
795
|
+
try {
|
|
796
|
+
return await fs$1.realpath(resolvedPath);
|
|
797
|
+
} catch {
|
|
798
|
+
return resolvedPath;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
function extractDetailPath(detail, prefix) {
|
|
802
|
+
if (!detail.startsWith(prefix)) return null;
|
|
803
|
+
const value = detail.slice(prefix.length).trim();
|
|
804
|
+
return value.length > 0 ? value : null;
|
|
805
|
+
}
|
|
806
|
+
async function cleanupLegacyLaunchdService(params) {
|
|
807
|
+
if (typeof process.getuid !== "function") return null;
|
|
808
|
+
await execFileAsync$1("launchctl", [
|
|
809
|
+
"bootout",
|
|
810
|
+
`gui/${process.getuid()}`,
|
|
811
|
+
params.plistPath
|
|
812
|
+
]).catch(() => void 0);
|
|
813
|
+
await execFileAsync$1("launchctl", ["unload", params.plistPath]).catch(() => void 0);
|
|
814
|
+
const trashDir = path.join(os.homedir(), ".Trash");
|
|
815
|
+
try {
|
|
816
|
+
await fs$1.mkdir(trashDir, { recursive: true });
|
|
817
|
+
} catch {}
|
|
818
|
+
try {
|
|
819
|
+
await fs$1.access(params.plistPath);
|
|
820
|
+
} catch {
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
const dest = path.join(trashDir, `${params.label}-${Date.now()}.plist`);
|
|
824
|
+
try {
|
|
825
|
+
await fs$1.rename(params.plistPath, dest);
|
|
826
|
+
return dest;
|
|
827
|
+
} catch {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
function classifyLegacyServices(legacyServices) {
|
|
832
|
+
const darwinUserServices = [];
|
|
833
|
+
const linuxUserServices = [];
|
|
834
|
+
const failed = [];
|
|
835
|
+
for (const svc of legacyServices) {
|
|
836
|
+
if (svc.platform === "darwin") {
|
|
837
|
+
if (svc.scope === "user") darwinUserServices.push(svc);
|
|
838
|
+
else failed.push(`${svc.label} (${svc.scope})`);
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
if (svc.platform === "linux") {
|
|
842
|
+
if (svc.scope === "user") linuxUserServices.push(svc);
|
|
843
|
+
else failed.push(`${svc.label} (${svc.scope})`);
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
failed.push(`${svc.label} (${svc.platform})`);
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
darwinUserServices,
|
|
850
|
+
linuxUserServices,
|
|
851
|
+
failed
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
async function cleanupLegacyDarwinServices(services) {
|
|
855
|
+
const removed = [];
|
|
856
|
+
const failed = [];
|
|
857
|
+
for (const svc of services) {
|
|
858
|
+
const plistPath = extractDetailPath(svc.detail, "plist:");
|
|
859
|
+
if (!plistPath) {
|
|
860
|
+
failed.push(`${svc.label} (missing plist path)`);
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const dest = await cleanupLegacyLaunchdService({
|
|
864
|
+
label: svc.label,
|
|
865
|
+
plistPath
|
|
866
|
+
});
|
|
867
|
+
removed.push(dest ? `${svc.label} -> ${dest}` : svc.label);
|
|
868
|
+
}
|
|
869
|
+
return {
|
|
870
|
+
removed,
|
|
871
|
+
failed
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
async function cleanupLegacyLinuxUserServices(services, runtime) {
|
|
875
|
+
const removed = [];
|
|
876
|
+
const failed = [];
|
|
877
|
+
try {
|
|
878
|
+
const removedUnits = await uninstallLegacySystemdUnits({
|
|
879
|
+
env: process.env,
|
|
880
|
+
stdout: process.stdout
|
|
881
|
+
});
|
|
882
|
+
const removedByLabel = new Map(removedUnits.map((unit) => [`${unit.name}.service`, unit]));
|
|
883
|
+
for (const svc of services) {
|
|
884
|
+
const removedUnit = removedByLabel.get(svc.label);
|
|
885
|
+
if (!removedUnit) {
|
|
886
|
+
failed.push(`${svc.label} (legacy unit name not recognized)`);
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
removed.push(`${svc.label} -> ${removedUnit.unitPath}`);
|
|
890
|
+
}
|
|
891
|
+
} catch (err) {
|
|
892
|
+
runtime.error(`Legacy Linux gateway cleanup failed: ${String(err)}`);
|
|
893
|
+
for (const svc of services) failed.push(`${svc.label} (linux cleanup failed)`);
|
|
894
|
+
}
|
|
895
|
+
return {
|
|
896
|
+
removed,
|
|
897
|
+
failed
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
async function maybeRepairGatewayServiceConfig(cfg, mode, runtime, prompter) {
|
|
901
|
+
if (resolveIsNixMode(process.env)) {
|
|
902
|
+
note$1("Nix mode detected; skip service updates.", "Gateway");
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
if (mode === "remote") {
|
|
906
|
+
note$1("Gateway mode is remote; skipped local service audit.", "Gateway");
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const service = resolveGatewayService();
|
|
910
|
+
let command = null;
|
|
911
|
+
try {
|
|
912
|
+
command = await service.readCommand(process.env);
|
|
913
|
+
} catch {
|
|
914
|
+
command = null;
|
|
915
|
+
}
|
|
916
|
+
if (!command) return;
|
|
917
|
+
const tokenRefConfigured = Boolean(resolveSecretInputRef({
|
|
918
|
+
value: cfg.gateway?.auth?.token,
|
|
919
|
+
defaults: cfg.secrets?.defaults
|
|
920
|
+
}).ref);
|
|
921
|
+
const gatewayTokenResolution = await resolveGatewayAuthTokenForService(cfg, process.env);
|
|
922
|
+
if (gatewayTokenResolution.unavailableReason) note$1(`Unable to verify gateway service token drift: ${gatewayTokenResolution.unavailableReason}`, "Gateway service config");
|
|
923
|
+
const expectedGatewayToken = tokenRefConfigured ? void 0 : gatewayTokenResolution.token;
|
|
924
|
+
const audit = await auditGatewayServiceConfig({
|
|
925
|
+
env: process.env,
|
|
926
|
+
command,
|
|
927
|
+
expectedGatewayToken
|
|
928
|
+
});
|
|
929
|
+
const serviceToken = readEmbeddedGatewayToken(command);
|
|
930
|
+
if (tokenRefConfigured && serviceToken) audit.issues.push({
|
|
931
|
+
code: SERVICE_AUDIT_CODES.gatewayTokenMismatch,
|
|
932
|
+
message: "Gateway service MOLDCLAW_GATEWAY_TOKEN should be unset when gateway.auth.token is SecretRef-managed",
|
|
933
|
+
detail: "service token is stale",
|
|
934
|
+
level: "recommended"
|
|
935
|
+
});
|
|
936
|
+
const needsNodeRuntime = needsNodeRuntimeMigration(audit.issues);
|
|
937
|
+
const systemNodeInfo = needsNodeRuntime ? await resolveSystemNodeInfo({ env: process.env }) : null;
|
|
938
|
+
const systemNodePath = systemNodeInfo?.supported ? systemNodeInfo.path : null;
|
|
939
|
+
if (needsNodeRuntime && !systemNodePath) {
|
|
940
|
+
const warning = renderSystemNodeWarning(systemNodeInfo);
|
|
941
|
+
if (warning) note$1(warning, "Gateway runtime");
|
|
942
|
+
note$1("System Node 22 LTS (22.16+) or Node 24 not found. Install via Homebrew/apt/choco and rerun doctor to migrate off Bun/version managers.", "Gateway runtime");
|
|
943
|
+
}
|
|
944
|
+
const port = resolveGatewayPort(cfg, process.env);
|
|
945
|
+
const runtimeChoice = detectGatewayRuntime(command.programArguments);
|
|
946
|
+
const { programArguments } = await buildGatewayInstallPlan({
|
|
947
|
+
env: process.env,
|
|
948
|
+
port,
|
|
949
|
+
runtime: needsNodeRuntime && systemNodePath ? "node" : runtimeChoice,
|
|
950
|
+
nodePath: systemNodePath ?? void 0,
|
|
951
|
+
warn: (message, title) => note$1(message, title),
|
|
952
|
+
config: cfg
|
|
953
|
+
});
|
|
954
|
+
const expectedEntrypoint = findGatewayEntrypoint(programArguments);
|
|
955
|
+
const currentEntrypoint = findGatewayEntrypoint(command.programArguments);
|
|
956
|
+
const normalizedExpectedEntrypoint = expectedEntrypoint ? await normalizeExecutablePath(expectedEntrypoint) : null;
|
|
957
|
+
const normalizedCurrentEntrypoint = currentEntrypoint ? await normalizeExecutablePath(currentEntrypoint) : null;
|
|
958
|
+
if (normalizedExpectedEntrypoint && normalizedCurrentEntrypoint && normalizedExpectedEntrypoint !== normalizedCurrentEntrypoint) audit.issues.push({
|
|
959
|
+
code: SERVICE_AUDIT_CODES.gatewayEntrypointMismatch,
|
|
960
|
+
message: "Gateway service entrypoint does not match the current install.",
|
|
961
|
+
detail: `${currentEntrypoint} -> ${expectedEntrypoint}`,
|
|
962
|
+
level: "recommended"
|
|
963
|
+
});
|
|
964
|
+
if (audit.issues.length === 0) return;
|
|
965
|
+
note$1(audit.issues.map((issue) => issue.detail ? `- ${issue.message} (${issue.detail})` : `- ${issue.message}`).join("\n"), "Gateway service config");
|
|
966
|
+
const needsAggressive = audit.issues.filter((issue) => issue.level === "aggressive").length > 0;
|
|
967
|
+
if (needsAggressive && !prompter.shouldForce) note$1("Custom or unexpected service edits detected. Rerun with --force to overwrite.", "Gateway service config");
|
|
968
|
+
if (!(needsAggressive ? await prompter.confirmAggressive({
|
|
969
|
+
message: "Overwrite gateway service config with current defaults now?",
|
|
970
|
+
initialValue: Boolean(prompter.shouldForce)
|
|
971
|
+
}) : await prompter.confirmRepair({
|
|
972
|
+
message: "Update gateway service config to the recommended defaults now?",
|
|
973
|
+
initialValue: true
|
|
974
|
+
}))) return;
|
|
975
|
+
const serviceEmbeddedToken = readEmbeddedGatewayToken(command);
|
|
976
|
+
const gatewayTokenForRepair = expectedGatewayToken ?? serviceEmbeddedToken;
|
|
977
|
+
const configuredGatewayToken = typeof cfg.gateway?.auth?.token === "string" ? cfg.gateway.auth.token.trim() || void 0 : void 0;
|
|
978
|
+
let cfgForServiceInstall = cfg;
|
|
979
|
+
if (!tokenRefConfigured && !configuredGatewayToken && gatewayTokenForRepair) {
|
|
980
|
+
const nextCfg = {
|
|
981
|
+
...cfg,
|
|
982
|
+
gateway: {
|
|
983
|
+
...cfg.gateway,
|
|
984
|
+
auth: {
|
|
985
|
+
...cfg.gateway?.auth,
|
|
986
|
+
mode: cfg.gateway?.auth?.mode ?? "token",
|
|
987
|
+
token: gatewayTokenForRepair
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
try {
|
|
992
|
+
await writeConfigFile(nextCfg);
|
|
993
|
+
cfgForServiceInstall = nextCfg;
|
|
994
|
+
note$1(expectedGatewayToken ? "Persisted gateway.auth.token from environment before reinstalling service." : "Persisted gateway.auth.token from existing service definition before reinstalling service.", "Gateway");
|
|
995
|
+
} catch (err) {
|
|
996
|
+
runtime.error(`Failed to persist gateway.auth.token before service repair: ${String(err)}`);
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
const updatedPort = resolveGatewayPort(cfgForServiceInstall, process.env);
|
|
1001
|
+
const updatedPlan = await buildGatewayInstallPlan({
|
|
1002
|
+
env: process.env,
|
|
1003
|
+
port: updatedPort,
|
|
1004
|
+
runtime: needsNodeRuntime && systemNodePath ? "node" : runtimeChoice,
|
|
1005
|
+
nodePath: systemNodePath ?? void 0,
|
|
1006
|
+
warn: (message, title) => note$1(message, title),
|
|
1007
|
+
config: cfgForServiceInstall
|
|
1008
|
+
});
|
|
1009
|
+
try {
|
|
1010
|
+
await service.install({
|
|
1011
|
+
env: process.env,
|
|
1012
|
+
stdout: process.stdout,
|
|
1013
|
+
programArguments: updatedPlan.programArguments,
|
|
1014
|
+
workingDirectory: updatedPlan.workingDirectory,
|
|
1015
|
+
environment: updatedPlan.environment
|
|
1016
|
+
});
|
|
1017
|
+
} catch (err) {
|
|
1018
|
+
runtime.error(`Gateway service update failed: ${String(err)}`);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
async function maybeScanExtraGatewayServices(options, runtime, prompter) {
|
|
1022
|
+
const extraServices = await findExtraGatewayServices(process.env, { deep: options.deep });
|
|
1023
|
+
if (extraServices.length === 0) return;
|
|
1024
|
+
note$1(extraServices.map((svc) => `- ${svc.label} (${svc.scope}, ${svc.detail})`).join("\n"), "Other gateway-like services detected");
|
|
1025
|
+
const legacyServices = extraServices.filter((svc) => svc.legacy === true);
|
|
1026
|
+
if (legacyServices.length > 0) {
|
|
1027
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
1028
|
+
message: "Remove legacy gateway services (clawdbot/moltbot) now?",
|
|
1029
|
+
initialValue: true
|
|
1030
|
+
})) {
|
|
1031
|
+
const removed = [];
|
|
1032
|
+
const { darwinUserServices, linuxUserServices, failed } = classifyLegacyServices(legacyServices);
|
|
1033
|
+
if (darwinUserServices.length > 0) {
|
|
1034
|
+
const result = await cleanupLegacyDarwinServices(darwinUserServices);
|
|
1035
|
+
removed.push(...result.removed);
|
|
1036
|
+
failed.push(...result.failed);
|
|
1037
|
+
}
|
|
1038
|
+
if (linuxUserServices.length > 0) {
|
|
1039
|
+
const result = await cleanupLegacyLinuxUserServices(linuxUserServices, runtime);
|
|
1040
|
+
removed.push(...result.removed);
|
|
1041
|
+
failed.push(...result.failed);
|
|
1042
|
+
}
|
|
1043
|
+
if (removed.length > 0) note$1(removed.map((line) => `- ${line}`).join("\n"), "Legacy gateway removed");
|
|
1044
|
+
if (failed.length > 0) note$1(failed.map((line) => `- ${line}`).join("\n"), "Legacy gateway cleanup skipped");
|
|
1045
|
+
if (removed.length > 0) runtime.log("Legacy gateway services removed. Installing moldClaw gateway next.");
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
const cleanupHints = renderGatewayServiceCleanupHints();
|
|
1049
|
+
if (cleanupHints.length > 0) note$1(cleanupHints.map((hint) => `- ${hint}`).join("\n"), "Cleanup hints");
|
|
1050
|
+
note$1([
|
|
1051
|
+
"Recommendation: run a single gateway per machine for most setups.",
|
|
1052
|
+
"One gateway supports multiple agents.",
|
|
1053
|
+
"If you need multiple gateways (e.g., a rescue bot on the same host), isolate ports + config/state (see docs: /gateway#multiple-gateways-same-host)."
|
|
1054
|
+
].join("\n"), "Gateway recommendation");
|
|
1055
|
+
}
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region src/commands/doctor-install.ts
|
|
1058
|
+
function noteSourceInstallIssues(root) {
|
|
1059
|
+
if (!root) return;
|
|
1060
|
+
const workspaceMarker = path.join(root, "pnpm-workspace.yaml");
|
|
1061
|
+
if (!fs.existsSync(workspaceMarker)) return;
|
|
1062
|
+
const warnings = [];
|
|
1063
|
+
const nodeModules = path.join(root, "node_modules");
|
|
1064
|
+
const pnpmStore = path.join(nodeModules, ".pnpm");
|
|
1065
|
+
const tsxBin = path.join(nodeModules, ".bin", "tsx");
|
|
1066
|
+
const srcEntry = path.join(root, "src", "entry.ts");
|
|
1067
|
+
if (fs.existsSync(nodeModules) && !fs.existsSync(pnpmStore)) warnings.push("- node_modules was not installed by pnpm (missing node_modules/.pnpm). Run: pnpm install");
|
|
1068
|
+
if (fs.existsSync(path.join(root, "package-lock.json"))) warnings.push("- package-lock.json present in a pnpm workspace. If you ran npm install, remove it and reinstall with pnpm.");
|
|
1069
|
+
if (fs.existsSync(srcEntry) && !fs.existsSync(tsxBin)) warnings.push("- tsx binary is missing for source runs. Run: pnpm install");
|
|
1070
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "Install");
|
|
1071
|
+
}
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/commands/doctor-memory-search.ts
|
|
1074
|
+
/**
|
|
1075
|
+
* Check whether memory search has a usable embedding provider.
|
|
1076
|
+
* Runs as part of `moldclaw doctor` — config-only, no network calls.
|
|
1077
|
+
*/
|
|
1078
|
+
async function noteMemorySearchHealth(cfg, opts) {
|
|
1079
|
+
const agentId = resolveDefaultAgentId(cfg);
|
|
1080
|
+
const agentDir = resolveAgentDir(cfg, agentId);
|
|
1081
|
+
const resolved = resolveMemorySearchConfig(cfg, agentId);
|
|
1082
|
+
const hasRemoteApiKey = hasConfiguredMemorySecretInput(resolved?.remote?.apiKey);
|
|
1083
|
+
if (!resolved) {
|
|
1084
|
+
note$1("Memory search is explicitly disabled (enabled: false).", "Memory search");
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
if (resolveMemoryBackendConfig({
|
|
1088
|
+
cfg,
|
|
1089
|
+
agentId
|
|
1090
|
+
}).backend === "qmd") return;
|
|
1091
|
+
if (resolved.provider !== "auto") {
|
|
1092
|
+
if (resolved.provider === "local") {
|
|
1093
|
+
if (hasLocalEmbeddings(resolved.local, true)) {
|
|
1094
|
+
if (opts?.gatewayMemoryProbe?.checked && !opts.gatewayMemoryProbe.ready) {
|
|
1095
|
+
const detail = opts.gatewayMemoryProbe.error?.trim();
|
|
1096
|
+
note$1([
|
|
1097
|
+
"Memory search provider is set to \"local\" and a model path is configured,",
|
|
1098
|
+
"but the gateway reports local embeddings are not ready.",
|
|
1099
|
+
detail ? `Gateway probe: ${detail}` : null,
|
|
1100
|
+
"",
|
|
1101
|
+
`Verify: ${formatCliCommand("moldclaw memory status --deep")}`
|
|
1102
|
+
].filter(Boolean).join("\n"), "Memory search");
|
|
1103
|
+
}
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
note$1([
|
|
1107
|
+
"Memory search provider is set to \"local\" but no local model file was found.",
|
|
1108
|
+
"",
|
|
1109
|
+
"Fix (pick one):",
|
|
1110
|
+
`- Install node-llama-cpp and set a local model path in config`,
|
|
1111
|
+
`- Switch to a remote provider: ${formatCliCommand("moldclaw config set agents.defaults.memorySearch.provider openai")}`,
|
|
1112
|
+
"",
|
|
1113
|
+
`Verify: ${formatCliCommand("moldclaw memory status --deep")}`
|
|
1114
|
+
].join("\n"), "Memory search");
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
if (hasRemoteApiKey || await hasApiKeyForProvider(resolved.provider, cfg, agentDir)) return;
|
|
1118
|
+
if (opts?.gatewayMemoryProbe?.checked && opts.gatewayMemoryProbe.ready) {
|
|
1119
|
+
note$1([
|
|
1120
|
+
`Memory search provider is set to "${resolved.provider}" but the API key was not found in the CLI environment.`,
|
|
1121
|
+
"The running gateway reports memory embeddings are ready for the default agent.",
|
|
1122
|
+
`Verify: ${formatCliCommand("moldclaw memory status --deep")}`
|
|
1123
|
+
].join("\n"), "Memory search");
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
const gatewayProbeWarning = buildGatewayProbeWarning(opts?.gatewayMemoryProbe);
|
|
1127
|
+
const envVar = providerEnvVar(resolved.provider);
|
|
1128
|
+
note$1([
|
|
1129
|
+
`Memory search provider is set to "${resolved.provider}" but no API key was found.`,
|
|
1130
|
+
`Semantic recall will not work without a valid API key.`,
|
|
1131
|
+
gatewayProbeWarning ? gatewayProbeWarning : null,
|
|
1132
|
+
"",
|
|
1133
|
+
"Fix (pick one):",
|
|
1134
|
+
`- Set ${envVar} in your environment`,
|
|
1135
|
+
`- Configure credentials: ${formatCliCommand("moldclaw configure --section model")}`,
|
|
1136
|
+
`- To disable: ${formatCliCommand("moldclaw config set agents.defaults.memorySearch.enabled false")}`,
|
|
1137
|
+
"",
|
|
1138
|
+
`Verify: ${formatCliCommand("moldclaw memory status --deep")}`
|
|
1139
|
+
].join("\n"), "Memory search");
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
if (hasLocalEmbeddings(resolved.local)) return;
|
|
1143
|
+
for (const provider of [
|
|
1144
|
+
"openai",
|
|
1145
|
+
"gemini",
|
|
1146
|
+
"voyage",
|
|
1147
|
+
"mistral"
|
|
1148
|
+
]) if (hasRemoteApiKey || await hasApiKeyForProvider(provider, cfg, agentDir)) return;
|
|
1149
|
+
if (opts?.gatewayMemoryProbe?.checked && opts.gatewayMemoryProbe.ready) {
|
|
1150
|
+
note$1([
|
|
1151
|
+
"Memory search provider is set to \"auto\" but the API key was not found in the CLI environment.",
|
|
1152
|
+
"The running gateway reports memory embeddings are ready for the default agent.",
|
|
1153
|
+
`Verify: ${formatCliCommand("moldclaw memory status --deep")}`
|
|
1154
|
+
].join("\n"), "Memory search");
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
const gatewayProbeWarning = buildGatewayProbeWarning(opts?.gatewayMemoryProbe);
|
|
1158
|
+
note$1([
|
|
1159
|
+
"Memory search is enabled but no embedding provider is configured.",
|
|
1160
|
+
"Semantic recall will not work without an embedding provider.",
|
|
1161
|
+
gatewayProbeWarning ? gatewayProbeWarning : null,
|
|
1162
|
+
"",
|
|
1163
|
+
"Fix (pick one):",
|
|
1164
|
+
"- Set OPENAI_API_KEY, GEMINI_API_KEY, VOYAGE_API_KEY, or MISTRAL_API_KEY in your environment",
|
|
1165
|
+
`- Configure credentials: ${formatCliCommand("moldclaw configure --section model")}`,
|
|
1166
|
+
`- For local embeddings: configure agents.defaults.memorySearch.provider and local model path`,
|
|
1167
|
+
`- To disable: ${formatCliCommand("moldclaw config set agents.defaults.memorySearch.enabled false")}`,
|
|
1168
|
+
"",
|
|
1169
|
+
`Verify: ${formatCliCommand("moldclaw memory status --deep")}`
|
|
1170
|
+
].join("\n"), "Memory search");
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Check whether local embeddings are available.
|
|
1174
|
+
*
|
|
1175
|
+
* When `useDefaultFallback` is true (explicit `provider: "local"`), an empty
|
|
1176
|
+
* modelPath is treated as available because the runtime falls back to
|
|
1177
|
+
* DEFAULT_LOCAL_MODEL (an auto-downloaded HuggingFace model).
|
|
1178
|
+
*
|
|
1179
|
+
* When false (provider: "auto"), we only consider local available if the user
|
|
1180
|
+
* explicitly configured a local file path — matching `canAutoSelectLocal()`
|
|
1181
|
+
* in the runtime, which skips local for empty/hf: model paths.
|
|
1182
|
+
*/
|
|
1183
|
+
function hasLocalEmbeddings(local, useDefaultFallback = false) {
|
|
1184
|
+
const modelPath = local.modelPath?.trim() || (useDefaultFallback ? "hf:ggml-org/embeddinggemma-300m-qat-q8_0-GGUF/embeddinggemma-300m-qat-Q8_0.gguf" : void 0);
|
|
1185
|
+
if (!modelPath) return false;
|
|
1186
|
+
if (/^(hf:|https?:)/i.test(modelPath)) return true;
|
|
1187
|
+
const resolved = resolveUserPath(modelPath);
|
|
1188
|
+
try {
|
|
1189
|
+
return fs.statSync(resolved).isFile();
|
|
1190
|
+
} catch {
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
async function hasApiKeyForProvider(provider, cfg, agentDir) {
|
|
1195
|
+
const authProvider = provider === "gemini" ? "google" : provider;
|
|
1196
|
+
try {
|
|
1197
|
+
await resolveApiKeyForProvider({
|
|
1198
|
+
provider: authProvider,
|
|
1199
|
+
cfg,
|
|
1200
|
+
agentDir
|
|
1201
|
+
});
|
|
1202
|
+
return true;
|
|
1203
|
+
} catch {
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
function providerEnvVar(provider) {
|
|
1208
|
+
switch (provider) {
|
|
1209
|
+
case "openai": return "OPENAI_API_KEY";
|
|
1210
|
+
case "gemini": return "GEMINI_API_KEY";
|
|
1211
|
+
case "voyage": return "VOYAGE_API_KEY";
|
|
1212
|
+
default: return `${provider.toUpperCase()}_API_KEY`;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
function buildGatewayProbeWarning(probe) {
|
|
1216
|
+
if (!probe?.checked || probe.ready) return null;
|
|
1217
|
+
const detail = probe.error?.trim();
|
|
1218
|
+
return detail ? `Gateway memory probe for default agent is not ready: ${detail}` : "Gateway memory probe for default agent is not ready.";
|
|
1219
|
+
}
|
|
1220
|
+
//#endregion
|
|
1221
|
+
//#region src/commands/doctor-platform-notes.ts
|
|
1222
|
+
const execFileAsync = promisify(execFile);
|
|
1223
|
+
function resolveHomeDir() {
|
|
1224
|
+
return process.env.HOME ?? os.homedir();
|
|
1225
|
+
}
|
|
1226
|
+
async function noteMacLaunchAgentOverrides() {
|
|
1227
|
+
if (process.platform !== "darwin") return;
|
|
1228
|
+
const home = resolveHomeDir();
|
|
1229
|
+
const markerPath = [path.join(home, ".moldclaw", "disable-launchagent")].find((candidate) => fs.existsSync(candidate));
|
|
1230
|
+
if (!markerPath) return;
|
|
1231
|
+
const displayMarkerPath = shortenHomePath(markerPath);
|
|
1232
|
+
note$1([
|
|
1233
|
+
`- LaunchAgent writes are disabled via ${displayMarkerPath}.`,
|
|
1234
|
+
"- To restore default behavior:",
|
|
1235
|
+
` rm ${displayMarkerPath}`
|
|
1236
|
+
].filter((line) => Boolean(line)).join("\n"), "Gateway (macOS)");
|
|
1237
|
+
}
|
|
1238
|
+
async function launchctlGetenv(name) {
|
|
1239
|
+
try {
|
|
1240
|
+
const result = await execFileAsync("/bin/launchctl", ["getenv", name], { encoding: "utf8" });
|
|
1241
|
+
const value = String(result.stdout ?? "").trim();
|
|
1242
|
+
return value.length > 0 ? value : void 0;
|
|
1243
|
+
} catch {
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
function hasConfigGatewayCreds(cfg) {
|
|
1248
|
+
const localPassword = cfg.gateway?.auth?.password;
|
|
1249
|
+
const remoteToken = cfg.gateway?.remote?.token;
|
|
1250
|
+
const remotePassword = cfg.gateway?.remote?.password;
|
|
1251
|
+
return Boolean(hasConfiguredSecretInput(cfg.gateway?.auth?.token, cfg.secrets?.defaults) || hasConfiguredSecretInput(localPassword, cfg.secrets?.defaults) || hasConfiguredSecretInput(remoteToken, cfg.secrets?.defaults) || hasConfiguredSecretInput(remotePassword, cfg.secrets?.defaults));
|
|
1252
|
+
}
|
|
1253
|
+
async function noteMacLaunchctlGatewayEnvOverrides(cfg, deps) {
|
|
1254
|
+
if ((deps?.platform ?? process.platform) !== "darwin") return;
|
|
1255
|
+
if (!hasConfigGatewayCreds(cfg)) return;
|
|
1256
|
+
const getenv = deps?.getenv ?? launchctlGetenv;
|
|
1257
|
+
const deprecatedLaunchctlEntries = [["MOLDCLAW_GATEWAY_TOKEN", await getenv("MOLDCLAW_GATEWAY_TOKEN")], ["MOLDCLAW_GATEWAY_PASSWORD", await getenv("MOLDCLAW_GATEWAY_PASSWORD")]].filter((entry) => Boolean(entry[1]?.trim()));
|
|
1258
|
+
if (deprecatedLaunchctlEntries.length > 0) {
|
|
1259
|
+
const lines = ["- Deprecated launchctl environment variables detected (ignored).", ...deprecatedLaunchctlEntries.map(([key]) => `- \`${key}\` is set; use \`MOLDCLAW_${key.slice(key.indexOf("_") + 1)}\` instead.`)];
|
|
1260
|
+
(deps?.noteFn ?? note$1)(lines.join("\n"), "Gateway (macOS)");
|
|
1261
|
+
}
|
|
1262
|
+
const tokenEntries = [["MOLDCLAW_GATEWAY_TOKEN", await getenv("MOLDCLAW_GATEWAY_TOKEN")]];
|
|
1263
|
+
const passwordEntries = [["MOLDCLAW_GATEWAY_PASSWORD", await getenv("MOLDCLAW_GATEWAY_PASSWORD")]];
|
|
1264
|
+
const tokenEntry = tokenEntries.find(([, value]) => value?.trim());
|
|
1265
|
+
const passwordEntry = passwordEntries.find(([, value]) => value?.trim());
|
|
1266
|
+
const envToken = tokenEntry?.[1]?.trim() ?? "";
|
|
1267
|
+
const envPassword = passwordEntry?.[1]?.trim() ?? "";
|
|
1268
|
+
const envTokenKey = tokenEntry?.[0];
|
|
1269
|
+
const envPasswordKey = passwordEntry?.[0];
|
|
1270
|
+
if (!envToken && !envPassword) return;
|
|
1271
|
+
const lines = [
|
|
1272
|
+
"- launchctl environment overrides detected (can cause confusing unauthorized errors).",
|
|
1273
|
+
envToken && envTokenKey ? `- \`${envTokenKey}\` is set; it overrides config tokens.` : void 0,
|
|
1274
|
+
envPassword ? `- \`${envPasswordKey ?? "MOLDCLAW_GATEWAY_PASSWORD"}\` is set; it overrides config passwords.` : void 0,
|
|
1275
|
+
"- Clear overrides and restart the app/gateway:",
|
|
1276
|
+
envTokenKey ? ` launchctl unsetenv ${envTokenKey}` : void 0,
|
|
1277
|
+
envPasswordKey ? ` launchctl unsetenv ${envPasswordKey}` : void 0
|
|
1278
|
+
].filter((line) => Boolean(line));
|
|
1279
|
+
(deps?.noteFn ?? note$1)(lines.join("\n"), "Gateway (macOS)");
|
|
1280
|
+
}
|
|
1281
|
+
function noteDeprecatedLegacyEnvVars(env = process.env, deps) {
|
|
1282
|
+
const entries = Object.entries(env).filter(([key, value]) => key.startsWith("MOLDCLAW_") && value?.trim()).map(([key]) => key);
|
|
1283
|
+
if (entries.length === 0) return;
|
|
1284
|
+
const lines = [
|
|
1285
|
+
"- Deprecated legacy environment variables detected (ignored).",
|
|
1286
|
+
"- Use MOLDCLAW_* equivalents instead:",
|
|
1287
|
+
...entries.map((key) => {
|
|
1288
|
+
return ` ${key} -> MOLDCLAW_${key.slice(key.indexOf("_") + 1)}`;
|
|
1289
|
+
})
|
|
1290
|
+
];
|
|
1291
|
+
(deps?.noteFn ?? note$1)(lines.join("\n"), "Environment");
|
|
1292
|
+
}
|
|
1293
|
+
function isTruthyEnvValue(value) {
|
|
1294
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
1295
|
+
}
|
|
1296
|
+
function isTmpCompileCachePath(cachePath) {
|
|
1297
|
+
const normalized = cachePath.trim().replace(/\/+$/, "");
|
|
1298
|
+
return normalized === "/tmp" || normalized.startsWith("/tmp/") || normalized === "/private/tmp" || normalized.startsWith("/private/tmp/");
|
|
1299
|
+
}
|
|
1300
|
+
function noteStartupOptimizationHints(env = process.env, deps) {
|
|
1301
|
+
const platform = deps?.platform ?? process.platform;
|
|
1302
|
+
if (platform === "win32") return;
|
|
1303
|
+
const arch = deps?.arch ?? os.arch();
|
|
1304
|
+
const totalMemBytes = deps?.totalMemBytes ?? os.totalmem();
|
|
1305
|
+
if (!(platform === "linux" && (arch === "arm" || arch === "arm64" || platform === "linux" && totalMemBytes > 0 && totalMemBytes <= 8 * 1024 ** 3))) return;
|
|
1306
|
+
const noteFn = deps?.noteFn ?? note$1;
|
|
1307
|
+
const compileCache = env.NODE_COMPILE_CACHE?.trim() ?? "";
|
|
1308
|
+
const disableCompileCache = env.NODE_DISABLE_COMPILE_CACHE?.trim() ?? "";
|
|
1309
|
+
const noRespawn = env.MOLDCLAW_NO_RESPAWN?.trim() ?? "";
|
|
1310
|
+
const lines = [];
|
|
1311
|
+
if (!compileCache) lines.push("- NODE_COMPILE_CACHE is not set; repeated CLI runs can be slower on small hosts (Pi/VM).");
|
|
1312
|
+
else if (isTmpCompileCachePath(compileCache)) lines.push("- NODE_COMPILE_CACHE points to /tmp; use /var/tmp so cache survives reboots and warms startup reliably.");
|
|
1313
|
+
if (isTruthyEnvValue(disableCompileCache)) lines.push("- NODE_DISABLE_COMPILE_CACHE is set; startup compile cache is disabled.");
|
|
1314
|
+
if (noRespawn !== "1") lines.push("- MOLDCLAW_NO_RESPAWN is not set to 1; set it to avoid extra startup overhead from self-respawn.");
|
|
1315
|
+
if (lines.length === 0) return;
|
|
1316
|
+
const suggestions = [
|
|
1317
|
+
"- Suggested env for low-power hosts:",
|
|
1318
|
+
" export NODE_COMPILE_CACHE=/var/tmp/moldclaw-compile-cache",
|
|
1319
|
+
" mkdir -p /var/tmp/moldclaw-compile-cache",
|
|
1320
|
+
" export MOLDCLAW_NO_RESPAWN=1",
|
|
1321
|
+
isTruthyEnvValue(disableCompileCache) ? " unset NODE_DISABLE_COMPILE_CACHE" : void 0
|
|
1322
|
+
].filter((line) => Boolean(line));
|
|
1323
|
+
noteFn([...lines, ...suggestions].join("\n"), "Startup optimization");
|
|
1324
|
+
}
|
|
1325
|
+
//#endregion
|
|
1326
|
+
//#region src/commands/doctor-prompter.ts
|
|
1327
|
+
function createDoctorPrompter(params) {
|
|
1328
|
+
const yes = params.options.yes === true;
|
|
1329
|
+
const requestedNonInteractive = params.options.nonInteractive === true;
|
|
1330
|
+
const shouldRepair = params.options.repair === true || yes;
|
|
1331
|
+
const shouldForce = params.options.force === true;
|
|
1332
|
+
const isTty = Boolean(process.stdin.isTTY);
|
|
1333
|
+
const nonInteractive = requestedNonInteractive || !isTty && !yes;
|
|
1334
|
+
const canPrompt = isTty && !yes && !nonInteractive;
|
|
1335
|
+
const confirmDefault = async (p) => {
|
|
1336
|
+
if (nonInteractive) return false;
|
|
1337
|
+
if (shouldRepair) return true;
|
|
1338
|
+
if (!canPrompt) return Boolean(p.initialValue ?? false);
|
|
1339
|
+
return guardCancel(await confirm({
|
|
1340
|
+
...p,
|
|
1341
|
+
message: stylePromptMessage(p.message)
|
|
1342
|
+
}), params.runtime);
|
|
1343
|
+
};
|
|
1344
|
+
return {
|
|
1345
|
+
confirm: confirmDefault,
|
|
1346
|
+
confirmRepair: async (p) => {
|
|
1347
|
+
if (nonInteractive) return false;
|
|
1348
|
+
return confirmDefault(p);
|
|
1349
|
+
},
|
|
1350
|
+
confirmAggressive: async (p) => {
|
|
1351
|
+
if (nonInteractive) return false;
|
|
1352
|
+
if (shouldRepair && shouldForce) return true;
|
|
1353
|
+
if (shouldRepair && !shouldForce) return false;
|
|
1354
|
+
if (!canPrompt) return Boolean(p.initialValue ?? false);
|
|
1355
|
+
return guardCancel(await confirm({
|
|
1356
|
+
...p,
|
|
1357
|
+
message: stylePromptMessage(p.message)
|
|
1358
|
+
}), params.runtime);
|
|
1359
|
+
},
|
|
1360
|
+
confirmSkipInNonInteractive: async (p) => {
|
|
1361
|
+
if (nonInteractive) return false;
|
|
1362
|
+
if (shouldRepair) return true;
|
|
1363
|
+
return confirmDefault(p);
|
|
1364
|
+
},
|
|
1365
|
+
select: async (p, fallback) => {
|
|
1366
|
+
if (!canPrompt || shouldRepair) return fallback;
|
|
1367
|
+
return guardCancel(await select({
|
|
1368
|
+
...p,
|
|
1369
|
+
message: stylePromptMessage(p.message),
|
|
1370
|
+
options: p.options.map((opt) => opt.hint === void 0 ? opt : {
|
|
1371
|
+
...opt,
|
|
1372
|
+
hint: stylePromptHint(opt.hint)
|
|
1373
|
+
})
|
|
1374
|
+
}), params.runtime);
|
|
1375
|
+
},
|
|
1376
|
+
shouldRepair,
|
|
1377
|
+
shouldForce
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
//#endregion
|
|
1381
|
+
//#region src/commands/doctor-sandbox.ts
|
|
1382
|
+
function resolveSandboxScript(scriptRel) {
|
|
1383
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
1384
|
+
candidates.add(process.cwd());
|
|
1385
|
+
const argv1 = process.argv[1];
|
|
1386
|
+
if (argv1) {
|
|
1387
|
+
const normalized = path.resolve(argv1);
|
|
1388
|
+
candidates.add(path.resolve(path.dirname(normalized), ".."));
|
|
1389
|
+
candidates.add(path.resolve(path.dirname(normalized)));
|
|
1390
|
+
}
|
|
1391
|
+
for (const root of candidates) {
|
|
1392
|
+
const scriptPath = path.join(root, scriptRel);
|
|
1393
|
+
if (fs.existsSync(scriptPath)) return {
|
|
1394
|
+
scriptPath,
|
|
1395
|
+
cwd: root
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
return null;
|
|
1399
|
+
}
|
|
1400
|
+
async function runSandboxScript(scriptRel, runtime) {
|
|
1401
|
+
const script = resolveSandboxScript(scriptRel);
|
|
1402
|
+
if (!script) {
|
|
1403
|
+
note$1(`Unable to locate ${scriptRel}. Run it from the repo root.`, "Sandbox");
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
runtime.log(`Running ${scriptRel}...`);
|
|
1407
|
+
const result = await runCommandWithTimeout(["bash", script.scriptPath], {
|
|
1408
|
+
timeoutMs: 1200 * 1e3,
|
|
1409
|
+
cwd: script.cwd
|
|
1410
|
+
});
|
|
1411
|
+
if (result.code !== 0) {
|
|
1412
|
+
runtime.error(`Failed running ${scriptRel}: ${result.stderr.trim() || result.stdout.trim() || "unknown error"}`);
|
|
1413
|
+
return false;
|
|
1414
|
+
}
|
|
1415
|
+
runtime.log(`Completed ${scriptRel}.`);
|
|
1416
|
+
return true;
|
|
1417
|
+
}
|
|
1418
|
+
async function isDockerAvailable() {
|
|
1419
|
+
try {
|
|
1420
|
+
await runExec("docker", [
|
|
1421
|
+
"version",
|
|
1422
|
+
"--format",
|
|
1423
|
+
"{{.Server.Version}}"
|
|
1424
|
+
], { timeoutMs: 5e3 });
|
|
1425
|
+
return true;
|
|
1426
|
+
} catch {
|
|
1427
|
+
return false;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
async function dockerImageExists(image) {
|
|
1431
|
+
try {
|
|
1432
|
+
await runExec("docker", [
|
|
1433
|
+
"image",
|
|
1434
|
+
"inspect",
|
|
1435
|
+
image
|
|
1436
|
+
], { timeoutMs: 5e3 });
|
|
1437
|
+
return true;
|
|
1438
|
+
} catch (error) {
|
|
1439
|
+
const stderr = error?.stderr || error?.message || "";
|
|
1440
|
+
if (String(stderr).includes("No such image")) return false;
|
|
1441
|
+
throw error;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function resolveSandboxDockerImage(cfg) {
|
|
1445
|
+
const image = cfg.agents?.defaults?.sandbox?.docker?.image?.trim();
|
|
1446
|
+
return image ? image : DEFAULT_SANDBOX_IMAGE;
|
|
1447
|
+
}
|
|
1448
|
+
function resolveSandboxBackend(cfg) {
|
|
1449
|
+
return cfg.agents?.defaults?.sandbox?.backend?.trim() || "docker";
|
|
1450
|
+
}
|
|
1451
|
+
function resolveSandboxBrowserImage(cfg) {
|
|
1452
|
+
const image = cfg.agents?.defaults?.sandbox?.browser?.image?.trim();
|
|
1453
|
+
return image ? image : DEFAULT_SANDBOX_BROWSER_IMAGE;
|
|
1454
|
+
}
|
|
1455
|
+
function updateSandboxDockerImage(cfg, image) {
|
|
1456
|
+
return {
|
|
1457
|
+
...cfg,
|
|
1458
|
+
agents: {
|
|
1459
|
+
...cfg.agents,
|
|
1460
|
+
defaults: {
|
|
1461
|
+
...cfg.agents?.defaults,
|
|
1462
|
+
sandbox: {
|
|
1463
|
+
...cfg.agents?.defaults?.sandbox,
|
|
1464
|
+
docker: {
|
|
1465
|
+
...cfg.agents?.defaults?.sandbox?.docker,
|
|
1466
|
+
image
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
function updateSandboxBrowserImage(cfg, image) {
|
|
1474
|
+
return {
|
|
1475
|
+
...cfg,
|
|
1476
|
+
agents: {
|
|
1477
|
+
...cfg.agents,
|
|
1478
|
+
defaults: {
|
|
1479
|
+
...cfg.agents?.defaults,
|
|
1480
|
+
sandbox: {
|
|
1481
|
+
...cfg.agents?.defaults?.sandbox,
|
|
1482
|
+
browser: {
|
|
1483
|
+
...cfg.agents?.defaults?.sandbox?.browser,
|
|
1484
|
+
image
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
async function handleMissingSandboxImage(params, runtime, prompter) {
|
|
1492
|
+
if (await dockerImageExists(params.image)) return;
|
|
1493
|
+
const buildHint = params.buildScript ? `Build it with ${params.buildScript}.` : "Build or pull it first.";
|
|
1494
|
+
note$1(`Sandbox ${params.kind} image missing: ${params.image}. ${buildHint}`, "Sandbox");
|
|
1495
|
+
let built = false;
|
|
1496
|
+
if (params.buildScript) {
|
|
1497
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
1498
|
+
message: `Build ${params.kind} sandbox image now?`,
|
|
1499
|
+
initialValue: true
|
|
1500
|
+
})) built = await runSandboxScript(params.buildScript, runtime);
|
|
1501
|
+
}
|
|
1502
|
+
if (built) return;
|
|
1503
|
+
}
|
|
1504
|
+
async function maybeRepairSandboxImages(cfg, runtime, prompter) {
|
|
1505
|
+
const sandbox = cfg.agents?.defaults?.sandbox;
|
|
1506
|
+
const mode = sandbox?.mode ?? "off";
|
|
1507
|
+
if (!sandbox || mode === "off") return cfg;
|
|
1508
|
+
const backend = resolveSandboxBackend(cfg);
|
|
1509
|
+
if (backend !== "docker") {
|
|
1510
|
+
if (sandbox.browser?.enabled) note$1(`Sandbox backend "${backend}" selected. Docker browser health checks are skipped; browser sandbox currently requires the docker backend.`, "Sandbox");
|
|
1511
|
+
return cfg;
|
|
1512
|
+
}
|
|
1513
|
+
if (!await isDockerAvailable()) {
|
|
1514
|
+
note$1([
|
|
1515
|
+
`Sandbox mode is enabled (mode: "${mode}") but Docker is not available.`,
|
|
1516
|
+
"Docker is required for sandbox mode to function.",
|
|
1517
|
+
"Isolated sessions (cron jobs, sub-agents) will fail without Docker.",
|
|
1518
|
+
"",
|
|
1519
|
+
"Options:",
|
|
1520
|
+
"- Install Docker and restart the gateway",
|
|
1521
|
+
"- Disable sandbox mode: moldclaw config set agents.defaults.sandbox.mode off"
|
|
1522
|
+
].join("\n"), "Sandbox");
|
|
1523
|
+
return cfg;
|
|
1524
|
+
}
|
|
1525
|
+
let next = cfg;
|
|
1526
|
+
const changes = [];
|
|
1527
|
+
const dockerImage = resolveSandboxDockerImage(cfg);
|
|
1528
|
+
await handleMissingSandboxImage({
|
|
1529
|
+
kind: "base",
|
|
1530
|
+
image: dockerImage,
|
|
1531
|
+
buildScript: dockerImage === "moldclaw-sandbox-common:bookworm-slim" ? "scripts/sandbox-common-setup.sh" : dockerImage === "moldclaw-sandbox:bookworm-slim" ? "scripts/sandbox-setup.sh" : void 0,
|
|
1532
|
+
updateConfig: (image) => {
|
|
1533
|
+
next = updateSandboxDockerImage(next, image);
|
|
1534
|
+
changes.push(`Updated agents.defaults.sandbox.docker.image → ${image}`);
|
|
1535
|
+
}
|
|
1536
|
+
}, runtime, prompter);
|
|
1537
|
+
if (sandbox.browser?.enabled) await handleMissingSandboxImage({
|
|
1538
|
+
kind: "browser",
|
|
1539
|
+
image: resolveSandboxBrowserImage(cfg),
|
|
1540
|
+
buildScript: "scripts/sandbox-browser-setup.sh",
|
|
1541
|
+
updateConfig: (image) => {
|
|
1542
|
+
next = updateSandboxBrowserImage(next, image);
|
|
1543
|
+
changes.push(`Updated agents.defaults.sandbox.browser.image → ${image}`);
|
|
1544
|
+
}
|
|
1545
|
+
}, runtime, prompter);
|
|
1546
|
+
if (changes.length > 0) note$1(changes.join("\n"), "Doctor changes");
|
|
1547
|
+
return next;
|
|
1548
|
+
}
|
|
1549
|
+
function noteSandboxScopeWarnings(cfg) {
|
|
1550
|
+
const globalSandbox = cfg.agents?.defaults?.sandbox;
|
|
1551
|
+
const agents = Array.isArray(cfg.agents?.list) ? cfg.agents.list : [];
|
|
1552
|
+
const warnings = [];
|
|
1553
|
+
for (const agent of agents) {
|
|
1554
|
+
const agentId = agent.id;
|
|
1555
|
+
const agentSandbox = agent.sandbox;
|
|
1556
|
+
if (!agentSandbox) continue;
|
|
1557
|
+
if (resolveSandboxScope({
|
|
1558
|
+
scope: agentSandbox.scope ?? globalSandbox?.scope,
|
|
1559
|
+
perSession: agentSandbox.perSession ?? globalSandbox?.perSession
|
|
1560
|
+
}) !== "shared") continue;
|
|
1561
|
+
const overrides = [];
|
|
1562
|
+
if (agentSandbox.docker && Object.keys(agentSandbox.docker).length > 0) overrides.push("docker");
|
|
1563
|
+
if (agentSandbox.browser && Object.keys(agentSandbox.browser).length > 0) overrides.push("browser");
|
|
1564
|
+
if (agentSandbox.prune && Object.keys(agentSandbox.prune).length > 0) overrides.push("prune");
|
|
1565
|
+
if (overrides.length === 0) continue;
|
|
1566
|
+
warnings.push([`- agents.list (id "${agentId}") sandbox ${overrides.join("/")} overrides ignored.`, ` scope resolves to "shared".`].join("\n"));
|
|
1567
|
+
}
|
|
1568
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "Sandbox");
|
|
1569
|
+
}
|
|
1570
|
+
//#endregion
|
|
1571
|
+
//#region src/commands/doctor-security.ts
|
|
1572
|
+
function collectImplicitHeartbeatDirectPolicyWarnings(cfg) {
|
|
1573
|
+
const warnings = [];
|
|
1574
|
+
const maybeWarn = (params) => {
|
|
1575
|
+
const heartbeat = params.heartbeat;
|
|
1576
|
+
if (!heartbeat || heartbeat.target === void 0 || heartbeat.target === "none") return;
|
|
1577
|
+
if (heartbeat.directPolicy !== void 0) return;
|
|
1578
|
+
warnings.push(`- ${params.label}: heartbeat delivery is configured while ${params.pathHint} is unset.`, " Heartbeat now allows direct/DM targets by default. Set it explicitly to \"allow\" or \"block\" to pin upgrade behavior.");
|
|
1579
|
+
};
|
|
1580
|
+
maybeWarn({
|
|
1581
|
+
label: "Heartbeat defaults",
|
|
1582
|
+
heartbeat: cfg.agents?.defaults?.heartbeat,
|
|
1583
|
+
pathHint: "agents.defaults.heartbeat.directPolicy"
|
|
1584
|
+
});
|
|
1585
|
+
for (const agent of cfg.agents?.list ?? []) maybeWarn({
|
|
1586
|
+
label: `Heartbeat agent "${agent.id}"`,
|
|
1587
|
+
heartbeat: agent.heartbeat,
|
|
1588
|
+
pathHint: `heartbeat.directPolicy for agent "${agent.id}"`
|
|
1589
|
+
});
|
|
1590
|
+
return warnings;
|
|
1591
|
+
}
|
|
1592
|
+
async function noteSecurityWarnings(cfg) {
|
|
1593
|
+
const warnings = [];
|
|
1594
|
+
const auditHint = `- Run: ${formatCliCommand("moldclaw security audit --deep")}`;
|
|
1595
|
+
if (cfg.approvals?.exec?.enabled === false) warnings.push("- Note: approvals.exec.enabled=false disables approval forwarding only.", " Host exec gating still comes from ~/.moldclaw/exec-approvals.json.", ` Check local policy with: ${formatCliCommand("moldclaw approvals get --gateway")}`);
|
|
1596
|
+
warnings.push(...collectImplicitHeartbeatDirectPolicyWarnings(cfg));
|
|
1597
|
+
const gatewayBind = cfg.gateway?.bind ?? "loopback";
|
|
1598
|
+
const customBindHost = cfg.gateway?.customBindHost?.trim();
|
|
1599
|
+
const bindMode = [
|
|
1600
|
+
"auto",
|
|
1601
|
+
"lan",
|
|
1602
|
+
"loopback",
|
|
1603
|
+
"custom",
|
|
1604
|
+
"tailnet"
|
|
1605
|
+
].includes(gatewayBind) ? gatewayBind : void 0;
|
|
1606
|
+
const resolvedBindHost = bindMode ? await resolveGatewayBindHost(bindMode, customBindHost) : "0.0.0.0";
|
|
1607
|
+
const isExposed = !isLoopbackHost(resolvedBindHost);
|
|
1608
|
+
const resolvedAuth = resolveGatewayAuth({
|
|
1609
|
+
authConfig: cfg.gateway?.auth,
|
|
1610
|
+
env: process.env,
|
|
1611
|
+
tailscaleMode: cfg.gateway?.tailscale?.mode ?? "off"
|
|
1612
|
+
});
|
|
1613
|
+
const authToken = resolvedAuth.token?.trim() ?? "";
|
|
1614
|
+
const authPassword = resolvedAuth.password?.trim() ?? "";
|
|
1615
|
+
const hasToken = authToken.length > 0 || hasConfiguredSecretInput(cfg.gateway?.auth?.token, cfg.secrets?.defaults);
|
|
1616
|
+
const hasPassword = authPassword.length > 0 || hasConfiguredSecretInput(cfg.gateway?.auth?.password, cfg.secrets?.defaults);
|
|
1617
|
+
const hasSharedSecret = resolvedAuth.mode === "token" && hasToken || resolvedAuth.mode === "password" && hasPassword;
|
|
1618
|
+
const bindDescriptor = `"${gatewayBind}" (${resolvedBindHost})`;
|
|
1619
|
+
const saferRemoteAccessLines = [
|
|
1620
|
+
" Safer remote access: keep bind loopback and use Tailscale Serve/Funnel or an SSH tunnel.",
|
|
1621
|
+
" Example tunnel: ssh -N -L 28789:127.0.0.1:28789 user@gateway-host",
|
|
1622
|
+
" Docs: https://docs.moldclaw.ai/gateway/remote"
|
|
1623
|
+
];
|
|
1624
|
+
if (isExposed) if (!hasSharedSecret) {
|
|
1625
|
+
const authFixLines = resolvedAuth.mode === "password" ? [` Fix: ${formatCliCommand("moldclaw configure")} to set a password`, ` Or switch to token: ${formatCliCommand("moldclaw config set gateway.auth.mode token")}`] : [` Fix: ${formatCliCommand("moldclaw doctor --fix")} to generate a token`, ` Or set token directly: ${formatCliCommand("moldclaw config set gateway.auth.mode token")}`];
|
|
1626
|
+
warnings.push(`- CRITICAL: Gateway bound to ${bindDescriptor} without authentication.`, ` Anyone on your network (or internet if port-forwarded) can fully control your agent.`, ` Fix: ${formatCliCommand("moldclaw config set gateway.bind loopback")}`, ...saferRemoteAccessLines, ...authFixLines);
|
|
1627
|
+
} else warnings.push(`- WARNING: Gateway bound to ${bindDescriptor} (network-accessible).`, ` Ensure your auth credentials are strong and not exposed.`, ...saferRemoteAccessLines);
|
|
1628
|
+
const warnDmPolicy = async (params) => {
|
|
1629
|
+
const dmPolicy = params.dmPolicy;
|
|
1630
|
+
const policyPath = params.policyPath ?? `${params.allowFromPath}policy`;
|
|
1631
|
+
const { hasWildcard, allowCount, isMultiUserDm } = await resolveDmAllowState({
|
|
1632
|
+
provider: params.provider,
|
|
1633
|
+
accountId: params.accountId,
|
|
1634
|
+
allowFrom: params.allowFrom,
|
|
1635
|
+
normalizeEntry: params.normalizeEntry
|
|
1636
|
+
});
|
|
1637
|
+
const dmScope = cfg.session?.dmScope ?? "main";
|
|
1638
|
+
if (dmPolicy === "open") {
|
|
1639
|
+
const allowFromPath = `${params.allowFromPath}allowFrom`;
|
|
1640
|
+
warnings.push(`- ${params.label} DMs: OPEN (${policyPath}="open"). Anyone can DM it.`);
|
|
1641
|
+
if (!hasWildcard) warnings.push(`- ${params.label} DMs: config invalid — "open" requires ${allowFromPath} to include "*".`);
|
|
1642
|
+
}
|
|
1643
|
+
if (dmPolicy === "disabled") {
|
|
1644
|
+
warnings.push(`- ${params.label} DMs: disabled (${policyPath}="disabled").`);
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
if (dmPolicy !== "open" && allowCount === 0) {
|
|
1648
|
+
warnings.push(`- ${params.label} DMs: locked (${policyPath}="${dmPolicy}") with no allowlist; unknown senders will be blocked / get a pairing code.`);
|
|
1649
|
+
warnings.push(` ${params.approveHint}`);
|
|
1650
|
+
}
|
|
1651
|
+
if (dmScope === "main" && isMultiUserDm) warnings.push(`- ${params.label} DMs: multiple senders share the main session; run: ` + formatCliCommand("moldclaw config set session.dmScope \"per-channel-peer\"") + " (or \"per-account-channel-peer\" for multi-account channels) to isolate sessions.");
|
|
1652
|
+
};
|
|
1653
|
+
for (const plugin of listChannelPlugins()) {
|
|
1654
|
+
if (!plugin.security) continue;
|
|
1655
|
+
const { defaultAccountId, account, enabled, configured, diagnostics } = await resolveDefaultChannelAccountContext(plugin, cfg, {
|
|
1656
|
+
mode: "read_only",
|
|
1657
|
+
commandName: "doctor"
|
|
1658
|
+
});
|
|
1659
|
+
for (const diagnostic of diagnostics) warnings.push(`- [secrets] ${diagnostic}`);
|
|
1660
|
+
if (!enabled) continue;
|
|
1661
|
+
if (!configured) continue;
|
|
1662
|
+
const dmPolicy = plugin.security.resolveDmPolicy?.({
|
|
1663
|
+
cfg,
|
|
1664
|
+
accountId: defaultAccountId,
|
|
1665
|
+
account
|
|
1666
|
+
});
|
|
1667
|
+
if (dmPolicy) await warnDmPolicy({
|
|
1668
|
+
label: plugin.meta.label ?? plugin.id,
|
|
1669
|
+
provider: plugin.id,
|
|
1670
|
+
accountId: defaultAccountId,
|
|
1671
|
+
dmPolicy: dmPolicy.policy,
|
|
1672
|
+
allowFrom: dmPolicy.allowFrom,
|
|
1673
|
+
policyPath: dmPolicy.policyPath,
|
|
1674
|
+
allowFromPath: dmPolicy.allowFromPath,
|
|
1675
|
+
approveHint: dmPolicy.approveHint,
|
|
1676
|
+
normalizeEntry: dmPolicy.normalizeEntry
|
|
1677
|
+
});
|
|
1678
|
+
if (plugin.security.collectWarnings) {
|
|
1679
|
+
const extra = await plugin.security.collectWarnings({
|
|
1680
|
+
cfg,
|
|
1681
|
+
accountId: defaultAccountId,
|
|
1682
|
+
account
|
|
1683
|
+
});
|
|
1684
|
+
if (extra?.length) warnings.push(...extra);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
const lines = warnings.length > 0 ? warnings : ["- No channel security warnings detected."];
|
|
1688
|
+
lines.push(auditHint);
|
|
1689
|
+
note$1(lines.join("\n"), "Security");
|
|
1690
|
+
}
|
|
1691
|
+
//#endregion
|
|
1692
|
+
//#region src/commands/doctor-session-locks.ts
|
|
1693
|
+
const DEFAULT_STALE_MS = 1800 * 1e3;
|
|
1694
|
+
function formatAge(ageMs) {
|
|
1695
|
+
if (ageMs === null) return "unknown";
|
|
1696
|
+
const seconds = Math.floor(ageMs / 1e3);
|
|
1697
|
+
if (seconds < 60) return `${seconds}s`;
|
|
1698
|
+
const minutes = Math.floor(seconds / 60);
|
|
1699
|
+
const remainingSeconds = seconds % 60;
|
|
1700
|
+
if (minutes < 60) return `${minutes}m${remainingSeconds}s`;
|
|
1701
|
+
return `${Math.floor(minutes / 60)}h${minutes % 60}m`;
|
|
1702
|
+
}
|
|
1703
|
+
function formatLockLine(lock) {
|
|
1704
|
+
const pidStatus = lock.pid === null ? "pid=missing" : `pid=${lock.pid} (${lock.pidAlive ? "alive" : "dead"})`;
|
|
1705
|
+
const ageStatus = `age=${formatAge(lock.ageMs)}`;
|
|
1706
|
+
const staleStatus = lock.stale ? `stale=yes (${lock.staleReasons.join(", ") || "unknown"})` : "stale=no";
|
|
1707
|
+
const removedStatus = lock.removed ? " [removed]" : "";
|
|
1708
|
+
return `- ${shortenHomePath(lock.lockPath)} ${pidStatus} ${ageStatus} ${staleStatus}${removedStatus}`;
|
|
1709
|
+
}
|
|
1710
|
+
async function noteSessionLockHealth(params) {
|
|
1711
|
+
const shouldRepair = params?.shouldRepair === true;
|
|
1712
|
+
const staleMs = params?.staleMs ?? DEFAULT_STALE_MS;
|
|
1713
|
+
let sessionDirs = [];
|
|
1714
|
+
try {
|
|
1715
|
+
sessionDirs = await resolveAgentSessionDirs(resolveStateDir(process.env));
|
|
1716
|
+
} catch (err) {
|
|
1717
|
+
note$1(`- Failed to inspect session lock files: ${String(err)}`, "Session locks");
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
if (sessionDirs.length === 0) return;
|
|
1721
|
+
const allLocks = [];
|
|
1722
|
+
for (const sessionsDir of sessionDirs) {
|
|
1723
|
+
const result = await cleanStaleLockFiles({
|
|
1724
|
+
sessionsDir,
|
|
1725
|
+
staleMs,
|
|
1726
|
+
removeStale: shouldRepair
|
|
1727
|
+
});
|
|
1728
|
+
allLocks.push(...result.locks);
|
|
1729
|
+
}
|
|
1730
|
+
if (allLocks.length === 0) return;
|
|
1731
|
+
const staleCount = allLocks.filter((lock) => lock.stale).length;
|
|
1732
|
+
const removedCount = allLocks.filter((lock) => lock.removed).length;
|
|
1733
|
+
const lines = [`- Found ${allLocks.length} session lock file${allLocks.length === 1 ? "" : "s"}.`, ...allLocks.toSorted((a, b) => a.lockPath.localeCompare(b.lockPath)).map(formatLockLine)];
|
|
1734
|
+
if (staleCount > 0 && !shouldRepair) {
|
|
1735
|
+
lines.push(`- ${staleCount} lock file${staleCount === 1 ? " is" : "s are"} stale.`);
|
|
1736
|
+
lines.push("- Run \"moldclaw doctor --fix\" to remove stale lock files automatically.");
|
|
1737
|
+
}
|
|
1738
|
+
if (shouldRepair && removedCount > 0) lines.push(`- Removed ${removedCount} stale session lock file${removedCount === 1 ? "" : "s"}.`);
|
|
1739
|
+
note$1(lines.join("\n"), "Session locks");
|
|
1740
|
+
}
|
|
1741
|
+
//#endregion
|
|
1742
|
+
//#region src/commands/doctor-state-integrity.ts
|
|
1743
|
+
function existsDir(dir) {
|
|
1744
|
+
try {
|
|
1745
|
+
return fs.existsSync(dir) && fs.statSync(dir).isDirectory();
|
|
1746
|
+
} catch {
|
|
1747
|
+
return false;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
function existsFile(filePath) {
|
|
1751
|
+
try {
|
|
1752
|
+
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
|
|
1753
|
+
} catch {
|
|
1754
|
+
return false;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
function canWriteDir(dir) {
|
|
1758
|
+
try {
|
|
1759
|
+
fs.accessSync(dir, fs.constants.W_OK);
|
|
1760
|
+
return true;
|
|
1761
|
+
} catch {
|
|
1762
|
+
return false;
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
function ensureDir(dir) {
|
|
1766
|
+
try {
|
|
1767
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
1768
|
+
return { ok: true };
|
|
1769
|
+
} catch (err) {
|
|
1770
|
+
return {
|
|
1771
|
+
ok: false,
|
|
1772
|
+
error: String(err)
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
function dirPermissionHint(dir) {
|
|
1777
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : null;
|
|
1778
|
+
const gid = typeof process.getgid === "function" ? process.getgid() : null;
|
|
1779
|
+
try {
|
|
1780
|
+
const stat = fs.statSync(dir);
|
|
1781
|
+
if (uid !== null && stat.uid !== uid) return `Owner mismatch (uid ${stat.uid}). Run: sudo chown -R $USER "${dir}"`;
|
|
1782
|
+
if (gid !== null && stat.gid !== gid) return `Group mismatch (gid ${stat.gid}). If access fails, run: sudo chown -R $USER "${dir}"`;
|
|
1783
|
+
} catch {
|
|
1784
|
+
return null;
|
|
1785
|
+
}
|
|
1786
|
+
return null;
|
|
1787
|
+
}
|
|
1788
|
+
function addUserRwx(mode) {
|
|
1789
|
+
return mode & 511 | 448;
|
|
1790
|
+
}
|
|
1791
|
+
function countJsonlLines(filePath) {
|
|
1792
|
+
try {
|
|
1793
|
+
const raw = fs.readFileSync(filePath, "utf-8");
|
|
1794
|
+
if (!raw) return 0;
|
|
1795
|
+
let count = 0;
|
|
1796
|
+
for (let i = 0; i < raw.length; i += 1) if (raw[i] === "\n") count += 1;
|
|
1797
|
+
if (!raw.endsWith("\n")) count += 1;
|
|
1798
|
+
return count;
|
|
1799
|
+
} catch {
|
|
1800
|
+
return 0;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
function findOtherStateDirs(stateDir) {
|
|
1804
|
+
const resolvedState = path.resolve(stateDir);
|
|
1805
|
+
const roots = process.platform === "darwin" ? ["/Users"] : process.platform === "linux" ? ["/home"] : [];
|
|
1806
|
+
const found = [];
|
|
1807
|
+
for (const root of roots) {
|
|
1808
|
+
let entries = [];
|
|
1809
|
+
try {
|
|
1810
|
+
entries = fs.readdirSync(root, { withFileTypes: true });
|
|
1811
|
+
} catch {
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
for (const entry of entries) {
|
|
1815
|
+
if (!entry.isDirectory()) continue;
|
|
1816
|
+
if (entry.name.startsWith(".")) continue;
|
|
1817
|
+
const candidates = [".moldclaw"].map((dir) => path.resolve(root, entry.name, dir));
|
|
1818
|
+
for (const candidate of candidates) {
|
|
1819
|
+
if (candidate === resolvedState) continue;
|
|
1820
|
+
if (existsDir(candidate)) found.push(candidate);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return found;
|
|
1825
|
+
}
|
|
1826
|
+
function isPathUnderRoot(targetPath, rootPath) {
|
|
1827
|
+
const normalizedTarget = path.resolve(targetPath);
|
|
1828
|
+
const normalizedRoot = path.resolve(rootPath);
|
|
1829
|
+
const rootToken = path.parse(normalizedRoot).root;
|
|
1830
|
+
if (normalizedRoot === rootToken) return normalizedTarget.startsWith(rootToken);
|
|
1831
|
+
return normalizedTarget === normalizedRoot || normalizedTarget.startsWith(`${normalizedRoot}${path.sep}`);
|
|
1832
|
+
}
|
|
1833
|
+
function tryResolveRealPath(targetPath) {
|
|
1834
|
+
try {
|
|
1835
|
+
return fs.realpathSync(targetPath);
|
|
1836
|
+
} catch {
|
|
1837
|
+
return null;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
function decodeMountInfoPath(value) {
|
|
1841
|
+
return value.replace(/\\([0-7]{3})/g, (_, octal) => String.fromCharCode(Number.parseInt(octal, 8)));
|
|
1842
|
+
}
|
|
1843
|
+
function escapeControlCharsForTerminal(value) {
|
|
1844
|
+
let escaped = "";
|
|
1845
|
+
for (const char of value) {
|
|
1846
|
+
if (char === "\x1B") {
|
|
1847
|
+
escaped += "\\x1b";
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
if (char === "\r") {
|
|
1851
|
+
escaped += "\\r";
|
|
1852
|
+
continue;
|
|
1853
|
+
}
|
|
1854
|
+
if (char === "\n") {
|
|
1855
|
+
escaped += "\\n";
|
|
1856
|
+
continue;
|
|
1857
|
+
}
|
|
1858
|
+
if (char === " ") {
|
|
1859
|
+
escaped += "\\t";
|
|
1860
|
+
continue;
|
|
1861
|
+
}
|
|
1862
|
+
const code = char.charCodeAt(0);
|
|
1863
|
+
if (code >= 0 && code <= 8 || code === 11 || code === 12 || code >= 14 && code <= 31) {
|
|
1864
|
+
escaped += `\\x${code.toString(16).padStart(2, "0")}`;
|
|
1865
|
+
continue;
|
|
1866
|
+
}
|
|
1867
|
+
if (code === 127) {
|
|
1868
|
+
escaped += "\\x7f";
|
|
1869
|
+
continue;
|
|
1870
|
+
}
|
|
1871
|
+
escaped += char;
|
|
1872
|
+
}
|
|
1873
|
+
return escaped;
|
|
1874
|
+
}
|
|
1875
|
+
function parseLinuxMountInfo(rawMountInfo) {
|
|
1876
|
+
const entries = [];
|
|
1877
|
+
for (const line of rawMountInfo.split("\n")) {
|
|
1878
|
+
const trimmed = line.trim();
|
|
1879
|
+
if (!trimmed) continue;
|
|
1880
|
+
const separatorIndex = trimmed.indexOf(" - ");
|
|
1881
|
+
if (separatorIndex === -1) continue;
|
|
1882
|
+
const left = trimmed.slice(0, separatorIndex);
|
|
1883
|
+
const right = trimmed.slice(separatorIndex + 3);
|
|
1884
|
+
const leftFields = left.split(" ");
|
|
1885
|
+
const rightFields = right.split(" ");
|
|
1886
|
+
if (leftFields.length < 5 || rightFields.length < 2) continue;
|
|
1887
|
+
entries.push({
|
|
1888
|
+
mountPoint: decodeMountInfoPath(leftFields[4]),
|
|
1889
|
+
fsType: rightFields[0],
|
|
1890
|
+
source: decodeMountInfoPath(rightFields[1])
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
return entries;
|
|
1894
|
+
}
|
|
1895
|
+
function isPathUnderRootWithPathOps(targetPath, rootPath, pathOps) {
|
|
1896
|
+
const normalizedTarget = pathOps.resolve(targetPath);
|
|
1897
|
+
const normalizedRoot = pathOps.resolve(rootPath);
|
|
1898
|
+
const rootToken = pathOps.parse(normalizedRoot).root;
|
|
1899
|
+
if (normalizedRoot === rootToken) return normalizedTarget.startsWith(rootToken);
|
|
1900
|
+
return normalizedTarget === normalizedRoot || normalizedTarget.startsWith(`${normalizedRoot}${pathOps.sep}`);
|
|
1901
|
+
}
|
|
1902
|
+
function findLinuxMountInfoEntryForPath(targetPath, entries, pathOps) {
|
|
1903
|
+
const normalizedTarget = pathOps.resolve(targetPath);
|
|
1904
|
+
let bestMatch = null;
|
|
1905
|
+
for (const entry of entries) {
|
|
1906
|
+
if (!isPathUnderRootWithPathOps(normalizedTarget, entry.mountPoint, pathOps)) continue;
|
|
1907
|
+
if (!bestMatch || pathOps.resolve(entry.mountPoint).length > pathOps.resolve(bestMatch.mountPoint).length) bestMatch = entry;
|
|
1908
|
+
}
|
|
1909
|
+
return bestMatch;
|
|
1910
|
+
}
|
|
1911
|
+
function isMmcDevicePath(devicePath, pathOps) {
|
|
1912
|
+
const name = pathOps.basename(devicePath);
|
|
1913
|
+
return /^mmcblk\d+(?:p\d+)?$/.test(name);
|
|
1914
|
+
}
|
|
1915
|
+
function tryReadLinuxMountInfo() {
|
|
1916
|
+
try {
|
|
1917
|
+
return fs.readFileSync("/proc/self/mountinfo", "utf8");
|
|
1918
|
+
} catch {
|
|
1919
|
+
return null;
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
function detectLinuxSdBackedStateDir(stateDir, deps) {
|
|
1923
|
+
if ((deps?.platform ?? process.platform) !== "linux") return null;
|
|
1924
|
+
const linuxPath = path.posix;
|
|
1925
|
+
const resolvedStatePath = (deps?.resolveRealPath ?? tryResolveRealPath)(stateDir) ?? linuxPath.resolve(stateDir);
|
|
1926
|
+
const mountInfo = deps?.mountInfo ?? tryReadLinuxMountInfo();
|
|
1927
|
+
if (!mountInfo) return null;
|
|
1928
|
+
const mountEntry = findLinuxMountInfoEntryForPath(resolvedStatePath, parseLinuxMountInfo(mountInfo), linuxPath);
|
|
1929
|
+
if (!mountEntry) return null;
|
|
1930
|
+
const sourceCandidates = [mountEntry.source];
|
|
1931
|
+
if (mountEntry.source.startsWith("/dev/")) {
|
|
1932
|
+
const resolvedDevicePath = (deps?.resolveDeviceRealPath ?? tryResolveRealPath)(mountEntry.source);
|
|
1933
|
+
if (resolvedDevicePath) sourceCandidates.push(linuxPath.resolve(resolvedDevicePath));
|
|
1934
|
+
}
|
|
1935
|
+
if (!sourceCandidates.some((candidate) => isMmcDevicePath(candidate, linuxPath))) return null;
|
|
1936
|
+
return {
|
|
1937
|
+
path: linuxPath.resolve(resolvedStatePath),
|
|
1938
|
+
mountPoint: linuxPath.resolve(mountEntry.mountPoint),
|
|
1939
|
+
fsType: mountEntry.fsType,
|
|
1940
|
+
source: mountEntry.source
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
function formatLinuxSdBackedStateDirWarning(displayStateDir, linuxSdBackedStateDir) {
|
|
1944
|
+
const displayMountPoint = linuxSdBackedStateDir.mountPoint === "/" ? "/" : shortenHomePath(linuxSdBackedStateDir.mountPoint);
|
|
1945
|
+
return [
|
|
1946
|
+
`- State directory appears to be on SD/eMMC storage (${displayStateDir}; device ${escapeControlCharsForTerminal(linuxSdBackedStateDir.source)}, fs ${escapeControlCharsForTerminal(linuxSdBackedStateDir.fsType)}, mount ${escapeControlCharsForTerminal(displayMountPoint)}).`,
|
|
1947
|
+
"- SD/eMMC media can be slower for random I/O and wear faster under session/log churn.",
|
|
1948
|
+
"- For better startup and state durability, prefer SSD/NVMe (or USB SSD on Raspberry Pi) for MOLDCLAW_STATE_DIR."
|
|
1949
|
+
].join("\n");
|
|
1950
|
+
}
|
|
1951
|
+
function detectMacCloudSyncedStateDir(stateDir, deps) {
|
|
1952
|
+
if ((deps?.platform ?? process.platform) !== "darwin") return null;
|
|
1953
|
+
const homedir = deps?.homedir ?? os.homedir();
|
|
1954
|
+
const roots = [{
|
|
1955
|
+
storage: "iCloud Drive",
|
|
1956
|
+
root: path.join(homedir, "Library", "Mobile Documents", "com~apple~CloudDocs")
|
|
1957
|
+
}, {
|
|
1958
|
+
storage: "CloudStorage provider",
|
|
1959
|
+
root: path.join(homedir, "Library", "CloudStorage")
|
|
1960
|
+
}];
|
|
1961
|
+
const realPath = (deps?.resolveRealPath ?? tryResolveRealPath)(stateDir);
|
|
1962
|
+
const candidates = realPath ? [path.resolve(realPath)] : [path.resolve(stateDir)];
|
|
1963
|
+
for (const candidate of candidates) for (const { storage, root } of roots) if (isPathUnderRoot(candidate, root)) return {
|
|
1964
|
+
path: candidate,
|
|
1965
|
+
storage
|
|
1966
|
+
};
|
|
1967
|
+
return null;
|
|
1968
|
+
}
|
|
1969
|
+
function isRecord(value) {
|
|
1970
|
+
return typeof value === "object" && value !== null;
|
|
1971
|
+
}
|
|
1972
|
+
function isPairingPolicy(value) {
|
|
1973
|
+
return typeof value === "string" && value.trim().toLowerCase() === "pairing";
|
|
1974
|
+
}
|
|
1975
|
+
function hasPairingPolicy(value) {
|
|
1976
|
+
if (!isRecord(value)) return false;
|
|
1977
|
+
if (isPairingPolicy(value.dmPolicy)) return true;
|
|
1978
|
+
if (isRecord(value.dm) && isPairingPolicy(value.dm.policy)) return true;
|
|
1979
|
+
if (!isRecord(value.accounts)) return false;
|
|
1980
|
+
for (const accountCfg of Object.values(value.accounts)) if (hasPairingPolicy(accountCfg)) return true;
|
|
1981
|
+
return false;
|
|
1982
|
+
}
|
|
1983
|
+
function isSlashRoutingSessionKey(sessionKey) {
|
|
1984
|
+
const raw = sessionKey.trim().toLowerCase();
|
|
1985
|
+
if (!raw) return false;
|
|
1986
|
+
const scoped = parseAgentSessionKey(raw)?.rest ?? raw;
|
|
1987
|
+
return /^[^:]+:slash:[^:]+(?:$|:)/.test(scoped);
|
|
1988
|
+
}
|
|
1989
|
+
function shouldRequireOAuthDir(cfg, env) {
|
|
1990
|
+
if (env.MOLDCLAW_OAUTH_DIR?.trim()) return true;
|
|
1991
|
+
const channels = cfg.channels;
|
|
1992
|
+
if (!isRecord(channels)) return false;
|
|
1993
|
+
if (isRecord(channels.whatsapp)) return true;
|
|
1994
|
+
for (const [channelId, channelCfg] of Object.entries(channels)) {
|
|
1995
|
+
if (channelId === "defaults" || channelId === "modelByChannel") continue;
|
|
1996
|
+
if (hasPairingPolicy(channelCfg)) return true;
|
|
1997
|
+
}
|
|
1998
|
+
return false;
|
|
1999
|
+
}
|
|
2000
|
+
async function noteStateIntegrity(cfg, prompter, configPath) {
|
|
2001
|
+
const warnings = [];
|
|
2002
|
+
const changes = [];
|
|
2003
|
+
const env = process.env;
|
|
2004
|
+
const homedir = () => resolveRequiredHomeDir(env, os.homedir);
|
|
2005
|
+
const stateDir = resolveStateDir(env, homedir);
|
|
2006
|
+
const defaultStateDir = path.join(homedir(), ".moldclaw");
|
|
2007
|
+
const oauthDir = resolveOAuthDir(env, stateDir);
|
|
2008
|
+
const agentId = resolveDefaultAgentId(cfg);
|
|
2009
|
+
const sessionsDir = resolveSessionTranscriptsDirForAgent(agentId, env, homedir);
|
|
2010
|
+
const storePath = resolveStorePath(cfg.session?.store, { agentId });
|
|
2011
|
+
const storeDir = path.dirname(storePath);
|
|
2012
|
+
const absoluteStorePath = path.resolve(storePath);
|
|
2013
|
+
const displayStateDir = shortenHomePath(stateDir);
|
|
2014
|
+
const displayOauthDir = shortenHomePath(oauthDir);
|
|
2015
|
+
const displaySessionsDir = shortenHomePath(sessionsDir);
|
|
2016
|
+
const displayStoreDir = shortenHomePath(storeDir);
|
|
2017
|
+
const displayConfigPath = configPath ? shortenHomePath(configPath) : void 0;
|
|
2018
|
+
const requireOAuthDir = shouldRequireOAuthDir(cfg, env);
|
|
2019
|
+
const cloudSyncedStateDir = detectMacCloudSyncedStateDir(stateDir);
|
|
2020
|
+
const linuxSdBackedStateDir = detectLinuxSdBackedStateDir(stateDir);
|
|
2021
|
+
if (cloudSyncedStateDir) warnings.push([
|
|
2022
|
+
`- State directory is under macOS cloud-synced storage (${displayStateDir}; ${cloudSyncedStateDir.storage}).`,
|
|
2023
|
+
"- This can cause slow I/O and sync/lock races for sessions and credentials.",
|
|
2024
|
+
"- Prefer a local non-synced state dir (for example: ~/.moldclaw).",
|
|
2025
|
+
` Set locally: MOLDCLAW_STATE_DIR=~/.moldclaw ${formatCliCommand("moldclaw doctor")}`
|
|
2026
|
+
].join("\n"));
|
|
2027
|
+
if (linuxSdBackedStateDir) warnings.push(formatLinuxSdBackedStateDirWarning(displayStateDir, linuxSdBackedStateDir));
|
|
2028
|
+
let stateDirExists = existsDir(stateDir);
|
|
2029
|
+
if (!stateDirExists) {
|
|
2030
|
+
warnings.push(`- CRITICAL: state directory missing (${displayStateDir}). Sessions, credentials, logs, and config are stored there.`);
|
|
2031
|
+
if (cfg.gateway?.mode === "remote") warnings.push("- Gateway is in remote mode; run doctor on the remote host where the gateway runs.");
|
|
2032
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2033
|
+
message: `Create ${displayStateDir} now?`,
|
|
2034
|
+
initialValue: false
|
|
2035
|
+
})) {
|
|
2036
|
+
const created = ensureDir(stateDir);
|
|
2037
|
+
if (created.ok) {
|
|
2038
|
+
changes.push(`- Created ${displayStateDir}`);
|
|
2039
|
+
stateDirExists = true;
|
|
2040
|
+
} else warnings.push(`- Failed to create ${displayStateDir}: ${created.error}`);
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
if (stateDirExists && !canWriteDir(stateDir)) {
|
|
2044
|
+
warnings.push(`- State directory not writable (${displayStateDir}).`);
|
|
2045
|
+
const hint = dirPermissionHint(stateDir);
|
|
2046
|
+
if (hint) warnings.push(` ${hint}`);
|
|
2047
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2048
|
+
message: `Repair permissions on ${displayStateDir}?`,
|
|
2049
|
+
initialValue: true
|
|
2050
|
+
})) try {
|
|
2051
|
+
const target = addUserRwx(fs.statSync(stateDir).mode);
|
|
2052
|
+
fs.chmodSync(stateDir, target);
|
|
2053
|
+
changes.push(`- Repaired permissions on ${displayStateDir}`);
|
|
2054
|
+
} catch (err) {
|
|
2055
|
+
warnings.push(`- Failed to repair ${displayStateDir}: ${String(err)}`);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
if (stateDirExists && process.platform !== "win32") try {
|
|
2059
|
+
const dirLstat = fs.lstatSync(stateDir);
|
|
2060
|
+
const isDirSymlink = dirLstat.isSymbolicLink();
|
|
2061
|
+
const stat = isDirSymlink ? fs.statSync(stateDir) : dirLstat;
|
|
2062
|
+
if (!(isDirSymlink ? fs.realpathSync(stateDir) : stateDir).startsWith("/nix/store/") && (stat.mode & 63) !== 0) {
|
|
2063
|
+
warnings.push(`- State directory permissions are too open (${displayStateDir}). Recommend chmod 700.`);
|
|
2064
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2065
|
+
message: `Tighten permissions on ${displayStateDir} to 700?`,
|
|
2066
|
+
initialValue: true
|
|
2067
|
+
})) {
|
|
2068
|
+
fs.chmodSync(stateDir, 448);
|
|
2069
|
+
changes.push(`- Tightened permissions on ${displayStateDir} to 700`);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
} catch (err) {
|
|
2073
|
+
warnings.push(`- Failed to read ${displayStateDir} permissions: ${String(err)}`);
|
|
2074
|
+
}
|
|
2075
|
+
if (configPath && existsFile(configPath) && process.platform !== "win32") try {
|
|
2076
|
+
const configLstat = fs.lstatSync(configPath);
|
|
2077
|
+
const isSymlink = configLstat.isSymbolicLink();
|
|
2078
|
+
const stat = isSymlink ? fs.statSync(configPath) : configLstat;
|
|
2079
|
+
if (!(isSymlink ? fs.realpathSync(configPath) : configPath).startsWith("/nix/store/") && (stat.mode & 63) !== 0) {
|
|
2080
|
+
warnings.push(`- Config file is group/world readable (${displayConfigPath ?? configPath}). Recommend chmod 600.`);
|
|
2081
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2082
|
+
message: `Tighten permissions on ${displayConfigPath ?? configPath} to 600?`,
|
|
2083
|
+
initialValue: true
|
|
2084
|
+
})) {
|
|
2085
|
+
fs.chmodSync(configPath, 384);
|
|
2086
|
+
changes.push(`- Tightened permissions on ${displayConfigPath ?? configPath} to 600`);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
} catch (err) {
|
|
2090
|
+
warnings.push(`- Failed to read config permissions (${displayConfigPath ?? configPath}): ${String(err)}`);
|
|
2091
|
+
}
|
|
2092
|
+
if (stateDirExists) {
|
|
2093
|
+
const dirCandidates = /* @__PURE__ */ new Map();
|
|
2094
|
+
dirCandidates.set(sessionsDir, "Sessions dir");
|
|
2095
|
+
dirCandidates.set(storeDir, "Session store dir");
|
|
2096
|
+
if (requireOAuthDir) dirCandidates.set(oauthDir, "OAuth dir");
|
|
2097
|
+
else if (!existsDir(oauthDir)) warnings.push(`- OAuth dir not present (${displayOauthDir}). Skipping create because no WhatsApp/pairing channel config is active.`);
|
|
2098
|
+
const displayDirFor = (dir) => {
|
|
2099
|
+
if (dir === sessionsDir) return displaySessionsDir;
|
|
2100
|
+
if (dir === storeDir) return displayStoreDir;
|
|
2101
|
+
if (dir === oauthDir) return displayOauthDir;
|
|
2102
|
+
return shortenHomePath(dir);
|
|
2103
|
+
};
|
|
2104
|
+
for (const [dir, label] of dirCandidates) {
|
|
2105
|
+
const displayDir = displayDirFor(dir);
|
|
2106
|
+
if (!existsDir(dir)) {
|
|
2107
|
+
warnings.push(`- CRITICAL: ${label} missing (${displayDir}).`);
|
|
2108
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2109
|
+
message: `Create ${label} at ${displayDir}?`,
|
|
2110
|
+
initialValue: true
|
|
2111
|
+
})) {
|
|
2112
|
+
const created = ensureDir(dir);
|
|
2113
|
+
if (created.ok) changes.push(`- Created ${label}: ${displayDir}`);
|
|
2114
|
+
else warnings.push(`- Failed to create ${displayDir}: ${created.error}`);
|
|
2115
|
+
}
|
|
2116
|
+
continue;
|
|
2117
|
+
}
|
|
2118
|
+
if (!canWriteDir(dir)) {
|
|
2119
|
+
warnings.push(`- ${label} not writable (${displayDir}).`);
|
|
2120
|
+
const hint = dirPermissionHint(dir);
|
|
2121
|
+
if (hint) warnings.push(` ${hint}`);
|
|
2122
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2123
|
+
message: `Repair permissions on ${label}?`,
|
|
2124
|
+
initialValue: true
|
|
2125
|
+
})) try {
|
|
2126
|
+
const target = addUserRwx(fs.statSync(dir).mode);
|
|
2127
|
+
fs.chmodSync(dir, target);
|
|
2128
|
+
changes.push(`- Repaired permissions on ${label}: ${displayDir}`);
|
|
2129
|
+
} catch (err) {
|
|
2130
|
+
warnings.push(`- Failed to repair ${displayDir}: ${String(err)}`);
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
const extraStateDirs = /* @__PURE__ */ new Set();
|
|
2136
|
+
if (path.resolve(stateDir) !== path.resolve(defaultStateDir)) {
|
|
2137
|
+
if (existsDir(defaultStateDir)) extraStateDirs.add(defaultStateDir);
|
|
2138
|
+
}
|
|
2139
|
+
for (const other of findOtherStateDirs(stateDir)) extraStateDirs.add(other);
|
|
2140
|
+
if (extraStateDirs.size > 0) warnings.push([
|
|
2141
|
+
"- Multiple state directories detected. This can split session history.",
|
|
2142
|
+
...Array.from(extraStateDirs).map((dir) => ` - ${shortenHomePath(dir)}`),
|
|
2143
|
+
` Active state dir: ${displayStateDir}`
|
|
2144
|
+
].join("\n"));
|
|
2145
|
+
const store = loadSessionStore(storePath);
|
|
2146
|
+
const sessionPathOpts = resolveSessionFilePathOptions({
|
|
2147
|
+
agentId,
|
|
2148
|
+
storePath
|
|
2149
|
+
});
|
|
2150
|
+
const entries = Object.entries(store).filter(([, entry]) => entry && typeof entry === "object");
|
|
2151
|
+
if (entries.length > 0) {
|
|
2152
|
+
const recentTranscriptCandidates = entries.slice().toSorted((a, b) => {
|
|
2153
|
+
const aUpdated = typeof a[1].updatedAt === "number" ? a[1].updatedAt : 0;
|
|
2154
|
+
return (typeof b[1].updatedAt === "number" ? b[1].updatedAt : 0) - aUpdated;
|
|
2155
|
+
}).slice(0, 5).filter(([key]) => !isSlashRoutingSessionKey(key));
|
|
2156
|
+
const missing = recentTranscriptCandidates.filter(([, entry]) => {
|
|
2157
|
+
const sessionId = entry.sessionId;
|
|
2158
|
+
if (!sessionId) return false;
|
|
2159
|
+
return !existsFile(resolveSessionFilePath(sessionId, entry, sessionPathOpts));
|
|
2160
|
+
});
|
|
2161
|
+
if (missing.length > 0) warnings.push([
|
|
2162
|
+
`- ${missing.length}/${recentTranscriptCandidates.length} recent sessions are missing transcripts.`,
|
|
2163
|
+
` Verify sessions in store: ${formatCliCommand(`moldclaw sessions --store "${absoluteStorePath}"`)}`,
|
|
2164
|
+
` Preview cleanup impact: ${formatCliCommand(`moldclaw sessions cleanup --store "${absoluteStorePath}" --dry-run`)}`,
|
|
2165
|
+
` Prune missing entries: ${formatCliCommand(`moldclaw sessions cleanup --store "${absoluteStorePath}" --enforce --fix-missing`)}`
|
|
2166
|
+
].join("\n"));
|
|
2167
|
+
const mainEntry = store[resolveMainSessionKey(cfg)];
|
|
2168
|
+
if (mainEntry?.sessionId) {
|
|
2169
|
+
const transcriptPath = resolveSessionFilePath(mainEntry.sessionId, mainEntry, sessionPathOpts);
|
|
2170
|
+
if (!existsFile(transcriptPath)) warnings.push(`- Main session transcript missing (${shortenHomePath(transcriptPath)}). History will appear to reset.`);
|
|
2171
|
+
else {
|
|
2172
|
+
const lineCount = countJsonlLines(transcriptPath);
|
|
2173
|
+
if (lineCount <= 1) warnings.push(`- Main session transcript has only ${lineCount} line. Session history may not be appending.`);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (existsDir(sessionsDir)) {
|
|
2178
|
+
const referencedTranscriptPaths = /* @__PURE__ */ new Set();
|
|
2179
|
+
for (const [, entry] of entries) {
|
|
2180
|
+
if (!entry?.sessionId) continue;
|
|
2181
|
+
try {
|
|
2182
|
+
referencedTranscriptPaths.add(path.resolve(resolveSessionFilePath(entry.sessionId, entry, sessionPathOpts)));
|
|
2183
|
+
} catch {}
|
|
2184
|
+
}
|
|
2185
|
+
const orphanTranscriptPaths = fs.readdirSync(sessionsDir, { withFileTypes: true }).filter((entry) => entry.isFile() && isPrimarySessionTranscriptFileName(entry.name)).map((entry) => path.resolve(path.join(sessionsDir, entry.name))).filter((filePath) => !referencedTranscriptPaths.has(filePath));
|
|
2186
|
+
if (orphanTranscriptPaths.length > 0) {
|
|
2187
|
+
warnings.push(`- Found ${orphanTranscriptPaths.length} orphan transcript file(s) in ${displaySessionsDir}. They are not referenced by sessions.json and can consume disk over time.`);
|
|
2188
|
+
if (await prompter.confirmSkipInNonInteractive({
|
|
2189
|
+
message: `Archive ${orphanTranscriptPaths.length} orphan transcript file(s) in ${displaySessionsDir}?`,
|
|
2190
|
+
initialValue: false
|
|
2191
|
+
})) {
|
|
2192
|
+
let archived = 0;
|
|
2193
|
+
const archivedAt = formatSessionArchiveTimestamp();
|
|
2194
|
+
for (const orphanPath of orphanTranscriptPaths) {
|
|
2195
|
+
const archivedPath = `${orphanPath}.deleted.${archivedAt}`;
|
|
2196
|
+
try {
|
|
2197
|
+
fs.renameSync(orphanPath, archivedPath);
|
|
2198
|
+
archived += 1;
|
|
2199
|
+
} catch (err) {
|
|
2200
|
+
warnings.push(`- Failed to archive orphan transcript ${shortenHomePath(orphanPath)}: ${String(err)}`);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
if (archived > 0) changes.push(`- Archived ${archived} orphan transcript file(s) in ${displaySessionsDir}`);
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "State integrity");
|
|
2208
|
+
if (changes.length > 0) note$1(changes.join("\n"), "Doctor changes");
|
|
2209
|
+
}
|
|
2210
|
+
function noteWorkspaceBackupTip(workspaceDir) {
|
|
2211
|
+
if (!existsDir(workspaceDir)) return;
|
|
2212
|
+
const gitMarker = path.join(workspaceDir, ".git");
|
|
2213
|
+
if (fs.existsSync(gitMarker)) return;
|
|
2214
|
+
note$1([
|
|
2215
|
+
"- Tip: back up the workspace in a private git repo (GitHub or GitLab).",
|
|
2216
|
+
"- Keep ~/.moldclaw out of git; it contains credentials and session history.",
|
|
2217
|
+
"- Details: /concepts/agent-workspace#git-backup-recommended"
|
|
2218
|
+
].join("\n"), "Workspace");
|
|
2219
|
+
}
|
|
2220
|
+
//#endregion
|
|
2221
|
+
//#region src/commands/doctor-ui.ts
|
|
2222
|
+
async function maybeRepairUiProtocolFreshness(_runtime, prompter) {
|
|
2223
|
+
const root = await resolvemoldClawPackageRoot({
|
|
2224
|
+
moduleUrl: import.meta.url,
|
|
2225
|
+
argv1: process.argv[1],
|
|
2226
|
+
cwd: process.cwd()
|
|
2227
|
+
});
|
|
2228
|
+
if (!root) return;
|
|
2229
|
+
const schemaPath = path.join(root, "src/gateway/protocol/schema.ts");
|
|
2230
|
+
const uiIndexPath = (await resolveControlUiDistIndexHealth({
|
|
2231
|
+
root,
|
|
2232
|
+
argv1: process.argv[1]
|
|
2233
|
+
})).indexPath ?? resolveControlUiDistIndexPathForRoot(root);
|
|
2234
|
+
try {
|
|
2235
|
+
const [schemaStats, uiStats] = await Promise.all([fs$1.stat(schemaPath).catch(() => null), fs$1.stat(uiIndexPath).catch(() => null)]);
|
|
2236
|
+
if (schemaStats && !uiStats) {
|
|
2237
|
+
note$1(["- Control UI assets are missing.", "- Run: pnpm ui:build"].join("\n"), "UI");
|
|
2238
|
+
const uiSourcesPath = path.join(root, "ui/package.json");
|
|
2239
|
+
if (!await fs$1.stat(uiSourcesPath).catch(() => null)) {
|
|
2240
|
+
note$1("Skipping UI build: ui/ sources not present.", "UI");
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
if (await prompter.confirmRepair({
|
|
2244
|
+
message: "Build Control UI assets now?",
|
|
2245
|
+
initialValue: true
|
|
2246
|
+
})) {
|
|
2247
|
+
note$1("Building Control UI assets... (this may take a moment)", "UI");
|
|
2248
|
+
const uiScriptPath = path.join(root, "scripts/ui.js");
|
|
2249
|
+
const buildResult = await runCommandWithTimeout([
|
|
2250
|
+
process.execPath,
|
|
2251
|
+
uiScriptPath,
|
|
2252
|
+
"build"
|
|
2253
|
+
], {
|
|
2254
|
+
cwd: root,
|
|
2255
|
+
timeoutMs: 12e4,
|
|
2256
|
+
env: {
|
|
2257
|
+
...process.env,
|
|
2258
|
+
FORCE_COLOR: "1"
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
if (buildResult.code === 0) note$1("UI build complete.", "UI");
|
|
2262
|
+
else note$1([`UI build failed (exit ${buildResult.code ?? "unknown"}).`, buildResult.stderr.trim() ? buildResult.stderr.trim() : null].filter(Boolean).join("\n"), "UI");
|
|
2263
|
+
}
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
if (!schemaStats || !uiStats) return;
|
|
2267
|
+
if (schemaStats.mtime > uiStats.mtime) {
|
|
2268
|
+
const gitLog = await runCommandWithTimeout([
|
|
2269
|
+
"git",
|
|
2270
|
+
"-C",
|
|
2271
|
+
root,
|
|
2272
|
+
"log",
|
|
2273
|
+
`--since=${uiStats.mtime.toISOString()}`,
|
|
2274
|
+
"--format=%h %s",
|
|
2275
|
+
"src/gateway/protocol/schema.ts"
|
|
2276
|
+
], { timeoutMs: 5e3 }).catch(() => null);
|
|
2277
|
+
if (gitLog && gitLog.code === 0 && gitLog.stdout.trim()) {
|
|
2278
|
+
note$1(`UI assets are older than the protocol schema.\nFunctional changes since last build:\n${gitLog.stdout.trim().split("\n").map((l) => `- ${l}`).join("\n")}`, "UI Freshness");
|
|
2279
|
+
if (await prompter.confirmAggressive({
|
|
2280
|
+
message: "Rebuild UI now? (Detected protocol mismatch requiring update)",
|
|
2281
|
+
initialValue: true
|
|
2282
|
+
})) {
|
|
2283
|
+
const uiSourcesPath = path.join(root, "ui/package.json");
|
|
2284
|
+
if (!await fs$1.stat(uiSourcesPath).catch(() => null)) {
|
|
2285
|
+
note$1("Skipping UI rebuild: ui/ sources not present.", "UI");
|
|
2286
|
+
return;
|
|
2287
|
+
}
|
|
2288
|
+
note$1("Rebuilding stale UI assets... (this may take a moment)", "UI");
|
|
2289
|
+
const uiScriptPath = path.join(root, "scripts/ui.js");
|
|
2290
|
+
const buildResult = await runCommandWithTimeout([
|
|
2291
|
+
process.execPath,
|
|
2292
|
+
uiScriptPath,
|
|
2293
|
+
"build"
|
|
2294
|
+
], {
|
|
2295
|
+
cwd: root,
|
|
2296
|
+
timeoutMs: 12e4,
|
|
2297
|
+
env: {
|
|
2298
|
+
...process.env,
|
|
2299
|
+
FORCE_COLOR: "1"
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
if (buildResult.code === 0) note$1("UI rebuild complete.", "UI");
|
|
2303
|
+
else note$1([`UI rebuild failed (exit ${buildResult.code ?? "unknown"}).`, buildResult.stderr.trim() ? buildResult.stderr.trim() : null].filter(Boolean).join("\n"), "UI");
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
} catch {}
|
|
2308
|
+
}
|
|
2309
|
+
//#endregion
|
|
2310
|
+
//#region src/commands/doctor-update.ts
|
|
2311
|
+
async function detectmoldClawGitCheckout(root) {
|
|
2312
|
+
const res = await runCommandWithTimeout([
|
|
2313
|
+
"git",
|
|
2314
|
+
"-C",
|
|
2315
|
+
root,
|
|
2316
|
+
"rev-parse",
|
|
2317
|
+
"--show-toplevel"
|
|
2318
|
+
], { timeoutMs: 5e3 }).catch(() => null);
|
|
2319
|
+
if (!res) return "unknown";
|
|
2320
|
+
if (res.code !== 0) {
|
|
2321
|
+
if (res.stderr.toLowerCase().includes("not a git repository")) return "not-git";
|
|
2322
|
+
return "unknown";
|
|
2323
|
+
}
|
|
2324
|
+
return res.stdout.trim() === root ? "git" : "not-git";
|
|
2325
|
+
}
|
|
2326
|
+
async function maybeOfferUpdateBeforeDoctor(params) {
|
|
2327
|
+
if (!(!isTruthyEnvValue$1(process.env.MOLDCLAW_UPDATE_IN_PROGRESS) && params.options.nonInteractive !== true && params.options.yes !== true && params.options.repair !== true && Boolean(process.stdin.isTTY)) || !params.root) return { updated: false };
|
|
2328
|
+
const git = await detectmoldClawGitCheckout(params.root);
|
|
2329
|
+
if (git === "git") {
|
|
2330
|
+
if (!await params.confirm({
|
|
2331
|
+
message: "Update moldClaw from git before running doctor?",
|
|
2332
|
+
initialValue: true
|
|
2333
|
+
})) return { updated: false };
|
|
2334
|
+
note$1("Running update (fetch/rebase/build/ui:build/doctor)…", "Update");
|
|
2335
|
+
const result = await runGatewayUpdate({
|
|
2336
|
+
cwd: params.root,
|
|
2337
|
+
argv1: process.argv[1]
|
|
2338
|
+
});
|
|
2339
|
+
note$1([
|
|
2340
|
+
`Status: ${result.status}`,
|
|
2341
|
+
`Mode: ${result.mode}`,
|
|
2342
|
+
result.root ? `Root: ${result.root}` : null,
|
|
2343
|
+
result.reason ? `Reason: ${result.reason}` : null
|
|
2344
|
+
].filter(Boolean).join("\n"), "Update result");
|
|
2345
|
+
if (result.status === "ok") {
|
|
2346
|
+
params.outro("Update completed (doctor already ran as part of the update).");
|
|
2347
|
+
return {
|
|
2348
|
+
updated: true,
|
|
2349
|
+
handled: true
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
return {
|
|
2353
|
+
updated: true,
|
|
2354
|
+
handled: false
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
if (git === "not-git") note$1(["This install is not a git checkout.", `Run \`${formatCliCommand("moldclaw update")}\` to update via your package manager (npm/pnpm), then rerun doctor.`].join("\n"), "Update");
|
|
2358
|
+
return { updated: false };
|
|
2359
|
+
}
|
|
2360
|
+
//#endregion
|
|
2361
|
+
//#region src/commands/doctor-workspace.ts
|
|
2362
|
+
const MEMORY_SYSTEM_PROMPT = [
|
|
2363
|
+
"Memory system not found in workspace.",
|
|
2364
|
+
"Paste this into your agent:",
|
|
2365
|
+
"",
|
|
2366
|
+
"Install the memory system by applying:",
|
|
2367
|
+
"https://github.com/moldclaw/moldclaw/commit/9ffea23f31ca1df5183b25668f8f814bee0fb34e",
|
|
2368
|
+
"https://github.com/moldclaw/moldclaw/commit/7d1fee70e76f2f634f1b41fca927ee663914183a"
|
|
2369
|
+
].join("\n");
|
|
2370
|
+
async function shouldSuggestMemorySystem(workspaceDir) {
|
|
2371
|
+
const memoryPaths = [path.join(workspaceDir, "MEMORY.md"), path.join(workspaceDir, "memory.md")];
|
|
2372
|
+
for (const memoryPath of memoryPaths) try {
|
|
2373
|
+
await fs.promises.access(memoryPath);
|
|
2374
|
+
return false;
|
|
2375
|
+
} catch {}
|
|
2376
|
+
const agentsPath = path.join(workspaceDir, DEFAULT_AGENTS_FILENAME);
|
|
2377
|
+
try {
|
|
2378
|
+
const content = await fs.promises.readFile(agentsPath, "utf-8");
|
|
2379
|
+
if (/memory\.md/i.test(content)) return false;
|
|
2380
|
+
} catch {}
|
|
2381
|
+
return true;
|
|
2382
|
+
}
|
|
2383
|
+
function detectLegacyWorkspaceDirs(params) {
|
|
2384
|
+
return {
|
|
2385
|
+
activeWorkspace: path.resolve(params.workspaceDir),
|
|
2386
|
+
legacyDirs: []
|
|
2387
|
+
};
|
|
2388
|
+
}
|
|
2389
|
+
function formatLegacyWorkspaceWarning(detection) {
|
|
2390
|
+
return [
|
|
2391
|
+
"Extra workspace directories detected (may contain old agent files):",
|
|
2392
|
+
...detection.legacyDirs.map((dir) => `- ${shortenHomePath(dir)}`),
|
|
2393
|
+
`Active workspace: ${shortenHomePath(detection.activeWorkspace)}`,
|
|
2394
|
+
"If unused, archive or move to Trash."
|
|
2395
|
+
].join("\n");
|
|
2396
|
+
}
|
|
2397
|
+
//#endregion
|
|
2398
|
+
//#region src/commands/doctor-workspace-status.ts
|
|
2399
|
+
function noteWorkspaceStatus(cfg) {
|
|
2400
|
+
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
|
2401
|
+
const legacyWorkspace = detectLegacyWorkspaceDirs({ workspaceDir });
|
|
2402
|
+
if (legacyWorkspace.legacyDirs.length > 0) note$1(formatLegacyWorkspaceWarning(legacyWorkspace), "Extra workspace");
|
|
2403
|
+
const skillsReport = buildWorkspaceSkillStatus(workspaceDir, { config: cfg });
|
|
2404
|
+
note$1([
|
|
2405
|
+
`Eligible: ${skillsReport.skills.filter((s) => s.eligible).length}`,
|
|
2406
|
+
`Missing requirements: ${skillsReport.skills.filter((s) => !s.eligible && !s.disabled && !s.blockedByAllowlist).length}`,
|
|
2407
|
+
`Blocked by allowlist: ${skillsReport.skills.filter((s) => s.blockedByAllowlist).length}`
|
|
2408
|
+
].join("\n"), "Skills status");
|
|
2409
|
+
const pluginRegistry = loadmoldClawPlugins({
|
|
2410
|
+
config: cfg,
|
|
2411
|
+
workspaceDir,
|
|
2412
|
+
logger: {
|
|
2413
|
+
info: () => {},
|
|
2414
|
+
warn: () => {},
|
|
2415
|
+
error: () => {},
|
|
2416
|
+
debug: () => {}
|
|
2417
|
+
}
|
|
2418
|
+
});
|
|
2419
|
+
if (pluginRegistry.plugins.length > 0) {
|
|
2420
|
+
const loaded = pluginRegistry.plugins.filter((p) => p.status === "loaded");
|
|
2421
|
+
const disabled = pluginRegistry.plugins.filter((p) => p.status === "disabled");
|
|
2422
|
+
const errored = pluginRegistry.plugins.filter((p) => p.status === "error");
|
|
2423
|
+
note$1([
|
|
2424
|
+
`Loaded: ${loaded.length}`,
|
|
2425
|
+
`Disabled: ${disabled.length}`,
|
|
2426
|
+
`Errors: ${errored.length}`,
|
|
2427
|
+
errored.length > 0 ? `- ${errored.slice(0, 10).map((p) => p.id).join("\n- ")}${errored.length > 10 ? "\n- ..." : ""}` : null
|
|
2428
|
+
].filter((line) => Boolean(line)).join("\n"), "Plugins");
|
|
2429
|
+
}
|
|
2430
|
+
if (pluginRegistry.diagnostics.length > 0) note$1(pluginRegistry.diagnostics.map((diag) => {
|
|
2431
|
+
const prefix = diag.level.toUpperCase();
|
|
2432
|
+
const plugin = diag.pluginId ? ` ${diag.pluginId}` : "";
|
|
2433
|
+
const source = diag.source ? ` (${diag.source})` : "";
|
|
2434
|
+
return `- ${prefix}${plugin}: ${diag.message}${source}`;
|
|
2435
|
+
}).join("\n"), "Plugin diagnostics");
|
|
2436
|
+
return { workspaceDir };
|
|
2437
|
+
}
|
|
2438
|
+
//#endregion
|
|
2439
|
+
//#region src/commands/doctor.ts
|
|
2440
|
+
const intro$1 = (message) => intro(stylePromptTitle(message) ?? message);
|
|
2441
|
+
const outro$1 = (message) => outro(stylePromptTitle(message) ?? message);
|
|
2442
|
+
function resolveMode(cfg) {
|
|
2443
|
+
return cfg.gateway?.mode === "remote" ? "remote" : "local";
|
|
2444
|
+
}
|
|
2445
|
+
async function doctorCommand(runtime = defaultRuntime, options = {}) {
|
|
2446
|
+
const prompter = createDoctorPrompter({
|
|
2447
|
+
runtime,
|
|
2448
|
+
options
|
|
2449
|
+
});
|
|
2450
|
+
printWizardHeader(runtime);
|
|
2451
|
+
intro$1("moldClaw doctor");
|
|
2452
|
+
const root = await resolvemoldClawPackageRoot({
|
|
2453
|
+
moduleUrl: import.meta.url,
|
|
2454
|
+
argv1: process.argv[1],
|
|
2455
|
+
cwd: process.cwd()
|
|
2456
|
+
});
|
|
2457
|
+
if ((await maybeOfferUpdateBeforeDoctor({
|
|
2458
|
+
runtime,
|
|
2459
|
+
options,
|
|
2460
|
+
root,
|
|
2461
|
+
confirm: (p) => prompter.confirm(p),
|
|
2462
|
+
outro: outro$1
|
|
2463
|
+
})).handled) return;
|
|
2464
|
+
await maybeRepairUiProtocolFreshness(runtime, prompter);
|
|
2465
|
+
noteSourceInstallIssues(root);
|
|
2466
|
+
noteDeprecatedLegacyEnvVars();
|
|
2467
|
+
noteStartupOptimizationHints();
|
|
2468
|
+
const configResult = await loadAndMaybeMigrateDoctorConfig({
|
|
2469
|
+
options,
|
|
2470
|
+
confirm: (p) => prompter.confirm(p)
|
|
2471
|
+
});
|
|
2472
|
+
let cfg = configResult.cfg;
|
|
2473
|
+
const cfgForPersistence = structuredClone(cfg);
|
|
2474
|
+
const sourceConfigValid = configResult.sourceConfigValid ?? true;
|
|
2475
|
+
const configPath = configResult.path ?? CONFIG_PATH;
|
|
2476
|
+
if (!cfg.gateway?.mode) {
|
|
2477
|
+
const lines = [
|
|
2478
|
+
"gateway.mode is unset; gateway start will be blocked.",
|
|
2479
|
+
`Fix: run ${formatCliCommand("moldclaw configure")} and set Gateway mode (local/remote).`,
|
|
2480
|
+
`Or set directly: ${formatCliCommand("moldclaw config set gateway.mode local")}`
|
|
2481
|
+
];
|
|
2482
|
+
if (!fs.existsSync(configPath)) lines.push(`Missing config: run ${formatCliCommand("moldclaw setup")} first.`);
|
|
2483
|
+
note$1(lines.join("\n"), "Gateway");
|
|
2484
|
+
}
|
|
2485
|
+
if (resolveMode(cfg) === "local" && hasAmbiguousGatewayAuthModeConfig(cfg)) note$1([
|
|
2486
|
+
"gateway.auth.token and gateway.auth.password are both configured while gateway.auth.mode is unset.",
|
|
2487
|
+
"Set an explicit mode to avoid ambiguous auth selection and startup/runtime failures.",
|
|
2488
|
+
`Set token mode: ${formatCliCommand("moldclaw config set gateway.auth.mode token")}`,
|
|
2489
|
+
`Set password mode: ${formatCliCommand("moldclaw config set gateway.auth.mode password")}`
|
|
2490
|
+
].join("\n"), "Gateway auth");
|
|
2491
|
+
cfg = await maybeRepairAnthropicOAuthProfileId(cfg, prompter);
|
|
2492
|
+
cfg = await maybeRemoveDeprecatedCliAuthProfiles(cfg, prompter);
|
|
2493
|
+
await noteAuthProfileHealth({
|
|
2494
|
+
cfg,
|
|
2495
|
+
prompter,
|
|
2496
|
+
allowKeychainPrompt: options.nonInteractive !== true && Boolean(process.stdin.isTTY)
|
|
2497
|
+
});
|
|
2498
|
+
const gatewayDetails = buildGatewayConnectionDetails({ config: cfg });
|
|
2499
|
+
if (gatewayDetails.remoteFallbackNote) note$1(gatewayDetails.remoteFallbackNote, "Gateway");
|
|
2500
|
+
if (resolveMode(cfg) === "local" && sourceConfigValid) {
|
|
2501
|
+
const gatewayTokenRef = resolveSecretInputRef({
|
|
2502
|
+
value: cfg.gateway?.auth?.token,
|
|
2503
|
+
defaults: cfg.secrets?.defaults
|
|
2504
|
+
}).ref;
|
|
2505
|
+
const auth = resolveGatewayAuth({
|
|
2506
|
+
authConfig: cfg.gateway?.auth,
|
|
2507
|
+
tailscaleMode: cfg.gateway?.tailscale?.mode ?? "off"
|
|
2508
|
+
});
|
|
2509
|
+
if (auth.mode !== "password" && (auth.mode !== "token" || !auth.token)) if (gatewayTokenRef) note$1([
|
|
2510
|
+
"Gateway token is managed via SecretRef and is currently unavailable.",
|
|
2511
|
+
"Doctor will not overwrite gateway.auth.token with a plaintext value.",
|
|
2512
|
+
"Resolve/rotate the external secret source, then rerun doctor."
|
|
2513
|
+
].join("\n"), "Gateway auth");
|
|
2514
|
+
else {
|
|
2515
|
+
note$1("Gateway auth is off or missing a token. Token auth is now the recommended default (including loopback).", "Gateway auth");
|
|
2516
|
+
if (options.generateGatewayToken === true ? true : options.nonInteractive === true ? false : await prompter.confirmRepair({
|
|
2517
|
+
message: "Generate and configure a gateway token now?",
|
|
2518
|
+
initialValue: true
|
|
2519
|
+
})) {
|
|
2520
|
+
const nextToken = randomToken();
|
|
2521
|
+
cfg = {
|
|
2522
|
+
...cfg,
|
|
2523
|
+
gateway: {
|
|
2524
|
+
...cfg.gateway,
|
|
2525
|
+
auth: {
|
|
2526
|
+
...cfg.gateway?.auth,
|
|
2527
|
+
mode: "token",
|
|
2528
|
+
token: nextToken
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
};
|
|
2532
|
+
note$1("Gateway token configured.", "Gateway auth");
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
const legacyState = await detectLegacyStateMigrations({ cfg });
|
|
2537
|
+
if (legacyState.preview.length > 0) {
|
|
2538
|
+
note$1(legacyState.preview.join("\n"), "Legacy state detected");
|
|
2539
|
+
if (options.nonInteractive === true ? true : await prompter.confirm({
|
|
2540
|
+
message: "Migrate legacy state (sessions/agent/WhatsApp auth) now?",
|
|
2541
|
+
initialValue: true
|
|
2542
|
+
})) {
|
|
2543
|
+
const migrated = await runLegacyStateMigrations({ detected: legacyState });
|
|
2544
|
+
if (migrated.changes.length > 0) note$1(migrated.changes.join("\n"), "Doctor changes");
|
|
2545
|
+
if (migrated.warnings.length > 0) note$1(migrated.warnings.join("\n"), "Doctor warnings");
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
await noteStateIntegrity(cfg, prompter, configResult.path ?? CONFIG_PATH);
|
|
2549
|
+
await noteSessionLockHealth({ shouldRepair: prompter.shouldRepair });
|
|
2550
|
+
await maybeRepairLegacyCronStore({
|
|
2551
|
+
cfg,
|
|
2552
|
+
options,
|
|
2553
|
+
prompter
|
|
2554
|
+
});
|
|
2555
|
+
cfg = await maybeRepairSandboxImages(cfg, runtime, prompter);
|
|
2556
|
+
noteSandboxScopeWarnings(cfg);
|
|
2557
|
+
await maybeScanExtraGatewayServices(options, runtime, prompter);
|
|
2558
|
+
await maybeRepairGatewayServiceConfig(cfg, resolveMode(cfg), runtime, prompter);
|
|
2559
|
+
await noteMacLaunchAgentOverrides();
|
|
2560
|
+
await noteMacLaunchctlGatewayEnvOverrides(cfg);
|
|
2561
|
+
await noteSecurityWarnings(cfg);
|
|
2562
|
+
await noteChromeMcpBrowserReadiness(cfg);
|
|
2563
|
+
await noteOpenAIOAuthTlsPrerequisites({
|
|
2564
|
+
cfg,
|
|
2565
|
+
deep: options.deep === true
|
|
2566
|
+
});
|
|
2567
|
+
if (cfg.hooks?.gmail?.model?.trim()) {
|
|
2568
|
+
const hooksModelRef = resolveHooksGmailModel({
|
|
2569
|
+
cfg,
|
|
2570
|
+
defaultProvider: DEFAULT_PROVIDER
|
|
2571
|
+
});
|
|
2572
|
+
if (!hooksModelRef) note$1(`- hooks.gmail.model "${cfg.hooks.gmail.model}" could not be resolved`, "Hooks");
|
|
2573
|
+
else {
|
|
2574
|
+
const { provider: defaultProvider, model: defaultModel } = resolveConfiguredModelRef({
|
|
2575
|
+
cfg,
|
|
2576
|
+
defaultProvider: DEFAULT_PROVIDER,
|
|
2577
|
+
defaultModel: DEFAULT_MODEL
|
|
2578
|
+
});
|
|
2579
|
+
const catalog = await loadModelCatalog({ config: cfg });
|
|
2580
|
+
const status = getModelRefStatus({
|
|
2581
|
+
cfg,
|
|
2582
|
+
catalog,
|
|
2583
|
+
ref: hooksModelRef,
|
|
2584
|
+
defaultProvider,
|
|
2585
|
+
defaultModel
|
|
2586
|
+
});
|
|
2587
|
+
const warnings = [];
|
|
2588
|
+
if (!status.allowed) warnings.push(`- hooks.gmail.model "${status.key}" not in agents.defaults.models allowlist (will use primary instead)`);
|
|
2589
|
+
if (!status.inCatalog) warnings.push(`- hooks.gmail.model "${status.key}" not in the model catalog (may fail at runtime)`);
|
|
2590
|
+
if (warnings.length > 0) note$1(warnings.join("\n"), "Hooks");
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
if (options.nonInteractive !== true && process.platform === "linux" && resolveMode(cfg) === "local") {
|
|
2594
|
+
const service = resolveGatewayService();
|
|
2595
|
+
let loaded = false;
|
|
2596
|
+
try {
|
|
2597
|
+
loaded = await service.isLoaded({ env: process.env });
|
|
2598
|
+
} catch {
|
|
2599
|
+
loaded = false;
|
|
2600
|
+
}
|
|
2601
|
+
if (loaded) await ensureSystemdUserLingerInteractive({
|
|
2602
|
+
runtime,
|
|
2603
|
+
prompter: {
|
|
2604
|
+
confirm: async (p) => prompter.confirm(p),
|
|
2605
|
+
note: note$1
|
|
2606
|
+
},
|
|
2607
|
+
reason: "Gateway runs as a systemd user service. Without lingering, systemd stops the user session on logout/idle and kills the Gateway.",
|
|
2608
|
+
requireConfirm: true
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
noteWorkspaceStatus(cfg);
|
|
2612
|
+
await noteBootstrapFileSize(cfg);
|
|
2613
|
+
await doctorShellCompletion(runtime, prompter, { nonInteractive: options.nonInteractive });
|
|
2614
|
+
const { healthOk } = await checkGatewayHealth({
|
|
2615
|
+
runtime,
|
|
2616
|
+
cfg,
|
|
2617
|
+
timeoutMs: options.nonInteractive === true ? 3e3 : 1e4
|
|
2618
|
+
});
|
|
2619
|
+
const gatewayMemoryProbe = healthOk ? await probeGatewayMemoryStatus({
|
|
2620
|
+
cfg,
|
|
2621
|
+
timeoutMs: options.nonInteractive === true ? 3e3 : 1e4
|
|
2622
|
+
}) : {
|
|
2623
|
+
checked: false,
|
|
2624
|
+
ready: false
|
|
2625
|
+
};
|
|
2626
|
+
await noteMemorySearchHealth(cfg, { gatewayMemoryProbe });
|
|
2627
|
+
await maybeRepairGatewayDaemon({
|
|
2628
|
+
cfg,
|
|
2629
|
+
runtime,
|
|
2630
|
+
prompter,
|
|
2631
|
+
options,
|
|
2632
|
+
gatewayDetailsMessage: gatewayDetails.message,
|
|
2633
|
+
healthOk
|
|
2634
|
+
});
|
|
2635
|
+
if (configResult.shouldWriteConfig || JSON.stringify(cfg) !== JSON.stringify(cfgForPersistence)) {
|
|
2636
|
+
cfg = applyWizardMetadata(cfg, {
|
|
2637
|
+
command: "doctor",
|
|
2638
|
+
mode: resolveMode(cfg)
|
|
2639
|
+
});
|
|
2640
|
+
await writeConfigFile(cfg);
|
|
2641
|
+
logConfigUpdated(runtime);
|
|
2642
|
+
const backupPath = `${CONFIG_PATH}.bak`;
|
|
2643
|
+
if (fs.existsSync(backupPath)) runtime.log(`Backup: ${shortenHomePath(backupPath)}`);
|
|
2644
|
+
} else if (!prompter.shouldRepair) runtime.log(`Run "${formatCliCommand("moldclaw doctor --fix")}" to apply changes.`);
|
|
2645
|
+
if (options.workspaceSuggestions !== false) {
|
|
2646
|
+
const workspaceDir = resolveAgentWorkspaceDir(cfg, resolveDefaultAgentId(cfg));
|
|
2647
|
+
noteWorkspaceBackupTip(workspaceDir);
|
|
2648
|
+
if (await shouldSuggestMemorySystem(workspaceDir)) note$1(MEMORY_SYSTEM_PROMPT, "Workspace");
|
|
2649
|
+
}
|
|
2650
|
+
const finalSnapshot = await readConfigFileSnapshot();
|
|
2651
|
+
if (finalSnapshot.exists && !finalSnapshot.valid) {
|
|
2652
|
+
runtime.error("Invalid config:");
|
|
2653
|
+
for (const issue of finalSnapshot.issues) {
|
|
2654
|
+
const path = issue.path || "<root>";
|
|
2655
|
+
runtime.error(`- ${path}: ${issue.message}`);
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
outro$1("Doctor complete.");
|
|
2659
|
+
}
|
|
2660
|
+
//#endregion
|
|
2661
|
+
//#region src/terminal/prompt-select-styled.ts
|
|
2662
|
+
function selectStyled(params) {
|
|
2663
|
+
return select({
|
|
2664
|
+
...params,
|
|
2665
|
+
message: stylePromptMessage(params.message),
|
|
2666
|
+
options: params.options.map((opt) => opt.hint === void 0 ? opt : {
|
|
2667
|
+
...opt,
|
|
2668
|
+
hint: stylePromptHint(opt.hint)
|
|
2669
|
+
})
|
|
2670
|
+
});
|
|
2671
|
+
}
|
|
2672
|
+
//#endregion
|
|
2673
|
+
export { doctorCommand as n, selectStyled as t };
|