@spacebar_ai/moldclaw-core 2026.3.41 → 2026.3.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1144) hide show
  1. package/dist/accounts-5qY-dKca.d.ts +103 -0
  2. package/dist/accounts-SqdHz2ZP.js +114 -0
  3. package/dist/acp-cli-E6bcNqiE.js +2093 -0
  4. package/dist/actions.runtime-BU_XMuLk.js +119 -0
  5. package/dist/actions.runtime-CY5h8lqH.js +133 -0
  6. package/dist/agent-scope-lZlwP1At.js +208 -0
  7. package/dist/agents-C4SkadR1.js +853 -0
  8. package/dist/agents-RfwqGCzE.js +222 -0
  9. package/dist/agents.config-CX9CPNfP.js +17 -0
  10. package/dist/agents.config-DF9Zwn9n.js +121 -0
  11. package/dist/allow-list-3WSjz1zl.js +81 -0
  12. package/dist/allowlist-DNbDjFjw.js +142 -0
  13. package/dist/api-BEOpJ7dR.js +117 -0
  14. package/dist/audit-CpJz_eu6.js +787 -0
  15. package/dist/audit-CpfSjvyo.js +54 -0
  16. package/dist/audit-channel.collect.runtime-BeGotloZ.js +605 -0
  17. package/dist/audit-channel.runtime-BJDZ7ETt.js +121 -0
  18. package/dist/audit-extra.async-C2G0mqmk.js +813 -0
  19. package/dist/audit-membership-runtime-B1FqJsPV.js +162 -0
  20. package/dist/audit.deep.runtime-DyL9O_sU.js +25 -0
  21. package/dist/audit.nondeep.runtime-C6jFgJfH.js +832 -0
  22. package/dist/audit.runtime-Dnlsn23e.js +118 -0
  23. package/dist/auth-Ch3Rchm4.js +101 -0
  24. package/dist/auth-choice-CEFSlnLT.js +122 -0
  25. package/dist/auth-choice-CVCef-eU.js +268 -0
  26. package/dist/auth-choice-Cez-pXrg.js +507 -0
  27. package/dist/auth-choice-options-DO78mvPe.js +123 -0
  28. package/dist/auth-choice-prompt-CUkC7Mmb.js +36 -0
  29. package/dist/auth-choice-prompt-DCuQRiVl.js +115 -0
  30. package/dist/auth-choice.apply-helpers-BhbNIV8X.js +66 -0
  31. package/dist/auth-choice.plugin-providers.runtime-4BhqvEw_.js +119 -0
  32. package/dist/auth-profiles-smABVXzp.js +128040 -0
  33. package/dist/auth-profiles.runtime-Cr-ojtTc.js +116 -0
  34. package/dist/banner-CojBHPWr.js +342 -0
  35. package/dist/bluebubbles-BnLsj2Fy.d.ts +6 -0
  36. package/dist/bluebubbles-CVk7M3Bl.js +64 -0
  37. package/dist/bot-DdyrB2z9.d.ts +478 -0
  38. package/dist/brave-w4Fo8WZ3.js +24 -0
  39. package/dist/browser-cli-DWFs3P_i.js +1494 -0
  40. package/dist/build-info.json +3 -3
  41. package/dist/bundled/boot-md/handler.d.ts +1 -1
  42. package/dist/bundled/boot-md/handler.js +35 -35
  43. package/dist/bundled/bootstrap-extra-files/handler.d.ts +1 -1
  44. package/dist/bundled/bootstrap-extra-files/handler.js +1 -1
  45. package/dist/bundled/command-logger/handler.d.ts +1 -1
  46. package/dist/bundled/session-memory/handler.d.ts +1 -1
  47. package/dist/bundled/session-memory/handler.js +36 -36
  48. package/dist/call-Do7wTSr7.js +39 -0
  49. package/dist/call-gdDAt07d.js +640 -0
  50. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  51. package/dist/channel-B26pkce0.js +214 -0
  52. package/dist/channel-BJHp0AQC.js +352 -0
  53. package/dist/channel-BKFOv51P.js +4681 -0
  54. package/dist/channel-BNgpOY8v.js +538 -0
  55. package/dist/channel-BcQAAo2P.js +226 -0
  56. package/dist/channel-BvNdnhbx.js +1598 -0
  57. package/dist/channel-C1Rda3Jd.js +306 -0
  58. package/dist/channel-C87DG-F7.js +803 -0
  59. package/dist/channel-CIip0kvZ.js +619 -0
  60. package/dist/channel-CTPxoT_E2.js +316 -0
  61. package/dist/channel-CklaCzUG.js +562 -0
  62. package/dist/channel-CoJnAdLs.js +920 -0
  63. package/dist/channel-D3tafL1_.js +949 -0
  64. package/dist/channel-DFMrP2uu.js +542 -0
  65. package/dist/channel-DMd5cJQe.js +397 -0
  66. package/dist/channel-Dm34kxAJ.js +207 -0
  67. package/dist/channel-DmwF9udn.js +1321 -0
  68. package/dist/channel-account-context-Bjur9nlh.js +103 -0
  69. package/dist/channel-bGnST659.js +943 -0
  70. package/dist/channel-hIgbkTZf.js +575 -0
  71. package/dist/channel-m_TGrDKo.js +497 -0
  72. package/dist/channel-options-DoUPBMa8.js +50 -0
  73. package/dist/channel-plugin-ids-TZIY4hFs.js +26 -0
  74. package/dist/channel-summary-qD54bOBO.js +111 -0
  75. package/dist/channel.runtime-B0H04Dkk.js +199 -0
  76. package/dist/channel.runtime-BU1f3NkV.js +418 -0
  77. package/dist/channel.runtime-Bj1sfLep.js +4011 -0
  78. package/dist/channel.runtime-BtPAAJc3.js +870 -0
  79. package/dist/channel.runtime-Bx-10m_j.js +171 -0
  80. package/dist/channel.runtime-CI_TBywQ.js +179 -0
  81. package/dist/channel.runtime-CSLj14-Z.js +182 -0
  82. package/dist/channel.runtime-D-lTSYAd.js +404 -0
  83. package/dist/channel.runtime-DJqIOSji.js +127 -0
  84. package/dist/channel.runtime-Ec8aQ9V2.js +241 -0
  85. package/dist/channel.runtime-ax5a1jBm.js +218 -0
  86. package/dist/channel.setup-B-ncdYLT.js +9 -0
  87. package/dist/channel.setup-BY4bh5dm.js +9 -0
  88. package/dist/channel.setup-BovsdMnL.js +57 -0
  89. package/dist/channel.setup-CXzXA25h.js +6 -0
  90. package/dist/channel.setup-DcZUEufN.js +8 -0
  91. package/dist/channel.setup-E6zceRsE.js +8 -0
  92. package/dist/channel.setup-Pc7nGbdX.js +11 -0
  93. package/dist/channels/plugins/actions/discord.d.ts +2 -2
  94. package/dist/channels/plugins/actions/discord.js +35 -35
  95. package/dist/channels/plugins/actions/signal.d.ts +1 -1
  96. package/dist/channels/plugins/actions/signal.js +35 -35
  97. package/dist/channels/plugins/actions/telegram.d.ts +2 -2
  98. package/dist/channels/plugins/actions/telegram.js +35 -35
  99. package/dist/channels/plugins/agent-tools/whatsapp-login.d.ts +3 -3
  100. package/dist/channels/plugins/agent-tools/whatsapp-login.js +35 -35
  101. package/dist/channels-CPtE5ND6.js +404 -0
  102. package/dist/channels-Cj8ZolHI.js +1118 -0
  103. package/dist/channels-cli-D2sKrntt.js +291 -0
  104. package/dist/channels-status-issues-CzIHODg2.js +16 -0
  105. package/dist/clawbot-cli-BcwEDmUn.js +118 -0
  106. package/dist/cleanup-utils-D0L17RsX.js +96 -0
  107. package/dist/cli/daemon-cli.js +1 -1
  108. package/dist/cli-BvGVPKnD.js +154 -0
  109. package/dist/command-registry-CADQzTAg.js +14 -0
  110. package/dist/command-registry-ktiJNAJd.js +242 -0
  111. package/dist/command-secret-gateway-CXp10RTM.js +111 -0
  112. package/dist/compact.runtime-DyKL-Iar.js +116 -0
  113. package/dist/completion-cli-Bz4STrpt.js +17 -0
  114. package/dist/completion-cli-pVda2OFb.js +445 -0
  115. package/dist/config-BbvDRSYp.js +31 -0
  116. package/dist/config-CwBv71QC.js +44 -0
  117. package/dist/config-cli-Y0uXHbOw.js +678 -0
  118. package/dist/config-guard-BpW5g7JE.js +118 -0
  119. package/dist/config-validation-B-vLIsbo.js +262 -0
  120. package/dist/config-value-DT3-5958.js +132 -0
  121. package/dist/configure-B9U-jCqP.js +1100 -0
  122. package/dist/configure-BJ3Wrs5b.js +243 -0
  123. package/dist/control-ui-assets-C1YDYi82.js +232 -0
  124. package/dist/control-ui-shared-Dm5Dh0Lo.js +29 -0
  125. package/dist/core-BwKq3krw.js +150 -0
  126. package/dist/core-hjBwfDsW.d.ts +87 -0
  127. package/dist/cron-cli-DTDgfoMh.js +639 -0
  128. package/dist/daemon-cli-C-dkAXR1.js +339 -0
  129. package/dist/daemon-install-Oy0Q5pMF.js +180 -0
  130. package/dist/deliver-DNGnDqF9.js +111 -0
  131. package/dist/deliver-runtime-CCNZIhET.js +111 -0
  132. package/dist/device-id-cli-XvwZbIyC.js +52 -0
  133. package/dist/device-identity-IG5DngWM.js +365 -0
  134. package/dist/devices-cli-DIsxj4xp.js +342 -0
  135. package/dist/diagnostic-DTPopFvh.js +310 -0
  136. package/dist/directory-cli-DTSY3Ktr.js +311 -0
  137. package/dist/directory-config-helpers-DpFcAbmo.d.ts +38 -0
  138. package/dist/directory.static-CBRAUwUW.js +44 -0
  139. package/dist/discord-CrgxhEWw.js +114 -0
  140. package/dist/discovery-DrG7wmAR.js +48 -0
  141. package/dist/dm-policy-shared-DKoGdUpY.d.ts +95 -0
  142. package/dist/dns-cli-BJiz6CLK.js +217 -0
  143. package/dist/docs-cli-Dq2Yi5qO.js +174 -0
  144. package/dist/doctor-completion-D3GeVcFP.js +90 -0
  145. package/dist/doctor-config-flow-B1cMjr8h.js +112 -0
  146. package/dist/doctor-config-flow-BUe7JpV3.js +2437 -0
  147. package/dist/enable-Bc8bCuVe.js +24 -0
  148. package/dist/entry.js +4 -4
  149. package/dist/exec-approvals-cli-kLAev6bP.js +421 -0
  150. package/dist/extensions/acpx/index.d.ts +1 -1
  151. package/dist/extensions/amazon-bedrock/index.d.ts +1 -1
  152. package/dist/extensions/amazon-bedrock/index.js +4 -4
  153. package/dist/extensions/anthropic/index.d.ts +1 -1
  154. package/dist/extensions/anthropic/index.js +35 -35
  155. package/dist/extensions/bluebubbles/index.d.ts +1 -1
  156. package/dist/extensions/bluebubbles/index.js +39 -39
  157. package/dist/extensions/bluebubbles/setup-entry.d.ts +2 -2
  158. package/dist/extensions/bluebubbles/setup-entry.js +39 -39
  159. package/dist/extensions/brave/index.d.ts +1 -1
  160. package/dist/extensions/brave/index.js +5 -5
  161. package/dist/extensions/byteplus/index.d.ts +1 -1
  162. package/dist/extensions/byteplus/index.js +35 -35
  163. package/dist/extensions/cloudflare-ai-gateway/index.d.ts +1 -1
  164. package/dist/extensions/cloudflare-ai-gateway/index.js +36 -36
  165. package/dist/extensions/copilot-proxy/index.d.ts +1 -1
  166. package/dist/extensions/copilot-proxy/index.js +4 -4
  167. package/dist/extensions/device-pair/index.d.ts +1 -1
  168. package/dist/extensions/device-pair/index.js +4 -4
  169. package/dist/extensions/diagnostics-otel/index.d.ts +1 -1
  170. package/dist/extensions/diagnostics-otel/index.js +4 -4
  171. package/dist/extensions/diffs/index.d.ts +1 -1
  172. package/dist/extensions/discord/index.d.ts +1 -1
  173. package/dist/extensions/discord/index.js +40 -40
  174. package/dist/extensions/discord/setup-entry.d.ts +1 -1
  175. package/dist/extensions/discord/setup-entry.js +38 -38
  176. package/dist/extensions/elevenlabs/index.d.ts +1 -1
  177. package/dist/extensions/elevenlabs/index.js +35 -35
  178. package/dist/extensions/feishu/index.d.ts +2 -2
  179. package/dist/extensions/feishu/index.js +40 -40
  180. package/dist/extensions/feishu/setup-entry.d.ts +2 -2
  181. package/dist/extensions/feishu/setup-entry.js +37 -37
  182. package/dist/extensions/firecrawl/index.d.ts +1 -1
  183. package/dist/extensions/firecrawl/index.js +35 -35
  184. package/dist/extensions/github-copilot/index.d.ts +1 -1
  185. package/dist/extensions/github-copilot/index.js +35 -35
  186. package/dist/extensions/google/index.d.ts +1 -1
  187. package/dist/extensions/google/index.js +35 -35
  188. package/dist/extensions/googlechat/index.d.ts +1 -1
  189. package/dist/extensions/googlechat/index.js +38 -38
  190. package/dist/extensions/googlechat/setup-entry.d.ts +1 -1
  191. package/dist/extensions/googlechat/setup-entry.js +38 -38
  192. package/dist/extensions/huggingface/index.d.ts +1 -1
  193. package/dist/extensions/huggingface/index.js +35 -35
  194. package/dist/extensions/imessage/index.d.ts +1 -1
  195. package/dist/extensions/imessage/index.js +39 -39
  196. package/dist/extensions/imessage/setup-entry.d.ts +1 -1
  197. package/dist/extensions/imessage/setup-entry.js +39 -39
  198. package/dist/extensions/irc/index.d.ts +1 -1
  199. package/dist/extensions/irc/index.js +38 -38
  200. package/dist/extensions/irc/setup-entry.d.ts +2 -2
  201. package/dist/extensions/irc/setup-entry.js +38 -38
  202. package/dist/extensions/kakao-talkchannel/index.d.ts +1 -1
  203. package/dist/extensions/kakao-talkchannel/index.js +4 -4
  204. package/dist/extensions/kilocode/index.d.ts +1 -1
  205. package/dist/extensions/kilocode/index.js +35 -35
  206. package/dist/extensions/kimi-coding/index.d.ts +1 -1
  207. package/dist/extensions/kimi-coding/index.js +35 -35
  208. package/dist/extensions/line/index.d.ts +1 -1
  209. package/dist/extensions/line/index.js +37 -37
  210. package/dist/extensions/line/setup-entry.d.ts +1 -1
  211. package/dist/extensions/line/setup-entry.js +37 -37
  212. package/dist/extensions/llm-task/index.d.ts +1 -1
  213. package/dist/extensions/llm-task/index.js +35 -35
  214. package/dist/extensions/lobster/index.d.ts +1 -1
  215. package/dist/extensions/lobster/index.js +4 -4
  216. package/dist/extensions/matrix/index.d.ts +1 -1
  217. package/dist/extensions/matrix/index.js +40 -40
  218. package/dist/extensions/matrix/setup-entry.d.ts +2 -2
  219. package/dist/extensions/matrix/setup-entry.js +40 -40
  220. package/dist/extensions/mattermost/index.d.ts +1 -1
  221. package/dist/extensions/mattermost/index.js +37 -37
  222. package/dist/extensions/mattermost/setup-entry.d.ts +2 -2
  223. package/dist/extensions/mattermost/setup-entry.js +37 -37
  224. package/dist/extensions/memory-core/index.d.ts +1 -1
  225. package/dist/extensions/memory-core/index.js +4 -4
  226. package/dist/extensions/memory-lancedb/index.d.ts +1 -1
  227. package/dist/extensions/memory-lancedb/index.js +4 -4
  228. package/dist/extensions/microsoft/index.d.ts +1 -1
  229. package/dist/extensions/microsoft/index.js +35 -35
  230. package/dist/extensions/minimax/index.d.ts +1 -1
  231. package/dist/extensions/minimax/index.js +35 -35
  232. package/dist/extensions/mistral/index.d.ts +1 -1
  233. package/dist/extensions/mistral/index.js +35 -35
  234. package/dist/extensions/modelstudio/index.d.ts +1 -1
  235. package/dist/extensions/modelstudio/index.js +35 -35
  236. package/dist/extensions/moonshot/index.d.ts +1 -1
  237. package/dist/extensions/moonshot/index.js +35 -35
  238. package/dist/extensions/msteams/index.d.ts +1 -1
  239. package/dist/extensions/msteams/index.js +40 -40
  240. package/dist/extensions/msteams/setup-entry.d.ts +1 -1
  241. package/dist/extensions/msteams/setup-entry.js +40 -40
  242. package/dist/extensions/nextcloud-talk/index.d.ts +1 -1
  243. package/dist/extensions/nextcloud-talk/index.js +37 -37
  244. package/dist/extensions/nextcloud-talk/setup-entry.d.ts +2 -2
  245. package/dist/extensions/nextcloud-talk/setup-entry.js +37 -37
  246. package/dist/extensions/nostr/index.d.ts +1 -1
  247. package/dist/extensions/nostr/index.js +37 -37
  248. package/dist/extensions/nostr/setup-entry.d.ts +1 -1
  249. package/dist/extensions/nostr/setup-entry.js +37 -37
  250. package/dist/extensions/nvidia/index.d.ts +1 -1
  251. package/dist/extensions/nvidia/index.js +4 -4
  252. package/dist/extensions/ollama/index.d.ts +1 -1
  253. package/dist/extensions/ollama/index.js +7 -7
  254. package/dist/extensions/open-prose/index.d.ts +1 -1
  255. package/dist/extensions/open-prose/index.js +4 -4
  256. package/dist/extensions/openai/index.d.ts +1 -1
  257. package/dist/extensions/openai/index.js +35 -35
  258. package/dist/extensions/opencode/index.d.ts +1 -1
  259. package/dist/extensions/opencode/index.js +35 -35
  260. package/dist/extensions/opencode-go/index.d.ts +1 -1
  261. package/dist/extensions/opencode-go/index.js +35 -35
  262. package/dist/extensions/openrouter/index.d.ts +1 -1
  263. package/dist/extensions/openrouter/index.js +35 -35
  264. package/dist/extensions/openshell/index.d.ts +1 -1
  265. package/dist/extensions/openshell/index.js +35 -35
  266. package/dist/extensions/perplexity/index.d.ts +1 -1
  267. package/dist/extensions/perplexity/index.js +5 -5
  268. package/dist/extensions/phone-control/index.d.ts +1 -1
  269. package/dist/extensions/phone-control/index.js +4 -4
  270. package/dist/extensions/qianfan/index.d.ts +1 -1
  271. package/dist/extensions/qianfan/index.js +35 -35
  272. package/dist/extensions/qwen-portal-auth/index.d.ts +1 -1
  273. package/dist/extensions/qwen-portal-auth/index.js +35 -35
  274. package/dist/extensions/sglang/index.d.ts +1 -1
  275. package/dist/extensions/sglang/index.js +35 -35
  276. package/dist/extensions/signal/index.d.ts +1 -1
  277. package/dist/extensions/signal/index.js +38 -38
  278. package/dist/extensions/signal/setup-entry.d.ts +1 -1
  279. package/dist/extensions/signal/setup-entry.js +38 -38
  280. package/dist/extensions/slack/index.d.ts +1 -1
  281. package/dist/extensions/slack/index.js +39 -39
  282. package/dist/extensions/slack/setup-entry.d.ts +1 -1
  283. package/dist/extensions/slack/setup-entry.js +38 -38
  284. package/dist/extensions/synology-chat/index.d.ts +1 -1
  285. package/dist/extensions/synology-chat/index.js +37 -37
  286. package/dist/extensions/synology-chat/setup-entry.d.ts +1 -1
  287. package/dist/extensions/synology-chat/setup-entry.js +37 -37
  288. package/dist/extensions/synthetic/index.d.ts +1 -1
  289. package/dist/extensions/synthetic/index.js +35 -35
  290. package/dist/extensions/talk-voice/index.d.ts +1 -1
  291. package/dist/extensions/talk-voice/index.js +35 -35
  292. package/dist/extensions/telegram/index.d.ts +1 -1
  293. package/dist/extensions/telegram/index.js +38 -38
  294. package/dist/extensions/telegram/setup-entry.d.ts +1 -1
  295. package/dist/extensions/telegram/setup-entry.js +37 -37
  296. package/dist/extensions/thread-ownership/index.d.ts +1 -1
  297. package/dist/extensions/thread-ownership/index.js +4 -4
  298. package/dist/extensions/tlon/index.d.ts +1 -1
  299. package/dist/extensions/tlon/index.js +37 -37
  300. package/dist/extensions/tlon/setup-entry.d.ts +1 -1
  301. package/dist/extensions/tlon/setup-entry.js +37 -37
  302. package/dist/extensions/together/index.d.ts +1 -1
  303. package/dist/extensions/together/index.js +35 -35
  304. package/dist/extensions/twitch/index.d.ts +2 -2
  305. package/dist/extensions/twitch/index.js +37 -37
  306. package/dist/extensions/venice/index.d.ts +1 -1
  307. package/dist/extensions/venice/index.js +35 -35
  308. package/dist/extensions/vercel-ai-gateway/index.d.ts +1 -1
  309. package/dist/extensions/vercel-ai-gateway/index.js +36 -36
  310. package/dist/extensions/vllm/index.d.ts +1 -1
  311. package/dist/extensions/vllm/index.js +35 -35
  312. package/dist/extensions/voice-call/index.d.ts +1 -1
  313. package/dist/extensions/voice-call/index.js +35 -35
  314. package/dist/extensions/volcengine/index.d.ts +1 -1
  315. package/dist/extensions/volcengine/index.js +35 -35
  316. package/dist/extensions/whatsapp/index.d.ts +1 -1
  317. package/dist/extensions/whatsapp/index.js +38 -38
  318. package/dist/extensions/whatsapp/setup-entry.d.ts +1 -1
  319. package/dist/extensions/whatsapp/setup-entry.js +38 -38
  320. package/dist/extensions/xai/index.d.ts +1 -1
  321. package/dist/extensions/xai/index.js +35 -35
  322. package/dist/extensions/xiaomi/index.d.ts +1 -1
  323. package/dist/extensions/xiaomi/index.js +35 -35
  324. package/dist/extensions/zai/index.d.ts +1 -1
  325. package/dist/extensions/zai/index.js +35 -35
  326. package/dist/extensions/zalo/index.d.ts +1 -1
  327. package/dist/extensions/zalo/index.js +39 -39
  328. package/dist/extensions/zalo/setup-entry.d.ts +1 -1
  329. package/dist/extensions/zalo/setup-entry.js +39 -39
  330. package/dist/extensions/zalouser/index.d.ts +1 -1
  331. package/dist/extensions/zalouser/index.js +40 -40
  332. package/dist/extensions/zalouser/setup-entry.d.ts +1 -1
  333. package/dist/extensions/zalouser/setup-entry.js +40 -40
  334. package/dist/feishu-fIcnHDTd.d.ts +36 -0
  335. package/dist/gateway-cli-0c-8h93_.js +26437 -0
  336. package/dist/gateway-install-token-1PwJvrBY.js +163 -0
  337. package/dist/gateway-rpc-C0Vk51W7.js +26 -0
  338. package/dist/gateway-runtime-CBm3CCoA.js +69 -0
  339. package/dist/git-commit-BTWXFY41.js +177 -0
  340. package/dist/git-commit-D6GTN5Yt.js +2 -0
  341. package/dist/googlechat-BQr4xgoZ.js +307 -0
  342. package/dist/googlechat-BvwsCVKl.d.ts +12 -0
  343. package/dist/group-access-DpiQnd-G.d.ts +61 -0
  344. package/dist/health-6yZQGADY.js +113 -0
  345. package/dist/health-C9DYGyRe.js +570 -0
  346. package/dist/heartbeat-summary-Dct2lqJj.js +57 -0
  347. package/dist/help-CtwSApfq.js +81 -0
  348. package/dist/hooks-9gokOxZ5.d.ts +6 -0
  349. package/dist/hooks-cli-BegKzHZT.js +1000 -0
  350. package/dist/hooks-status-Bm_pGORf.js +78 -0
  351. package/dist/http-registry-D-S6a1Na.d.ts +20 -0
  352. package/dist/identity-file-Diub2a0t.js +60 -0
  353. package/dist/image-generation-CbIVzmAR.d.ts +9 -0
  354. package/dist/imessage-Bgok9kfl.js +31 -0
  355. package/dist/imessage-VIHePprL.js +115 -0
  356. package/dist/inbound-reply-dispatch-B53GAGWq.js +71 -0
  357. package/dist/inbound-reply-dispatch-n7U3qg15.d.ts +72 -0
  358. package/dist/index.js +2 -2
  359. package/dist/install-target-oz1pjfHH.js +574 -0
  360. package/dist/installs-CUFm5V8a.js +532 -0
  361. package/dist/io-BaBxjB1v.js +9739 -0
  362. package/dist/io-CgHb1Jld.js +29 -0
  363. package/dist/irc-CaRKzGvW.js +672 -0
  364. package/dist/library-C5SNBCMb.js +112 -0
  365. package/dist/lifecycle-core-Dn8PK6nk.js +382 -0
  366. package/dist/line/accounts.d.ts +2 -2
  367. package/dist/line/send.d.ts +1 -1
  368. package/dist/line/send.js +7 -7
  369. package/dist/line/template-messages.d.ts +1 -1
  370. package/dist/line-B5QFpgN_.d.ts +75 -0
  371. package/dist/line-fePrrQOD.js +530 -0
  372. package/dist/llm-slug-generator-hKae3XDA.js +67 -0
  373. package/dist/llm-slug-generator.d.ts +1 -1
  374. package/dist/llm-slug-generator.js +36 -36
  375. package/dist/logging-CdisccbY.js +13 -0
  376. package/dist/logging-LKQSgX1d.js +30 -0
  377. package/dist/login-qr-C1YWh4nE.js +233 -0
  378. package/dist/login-qr-WFluMDMb.js +112 -0
  379. package/dist/logs-cli-CNzOvZ2d.js +256 -0
  380. package/dist/manager-runtime-DgMhLTkR.js +111 -0
  381. package/dist/manager.runtime-hUWgpPt2.js +715 -0
  382. package/dist/manifest-registry-CS_p1OBQ.js +1329 -0
  383. package/dist/matrix-43_RGLZN.d.ts +68 -0
  384. package/dist/matrix-CCFxHfxa.js +1269 -0
  385. package/dist/matrix-DWs_qIkJ.js +1495 -0
  386. package/dist/mcp-cli-Ci2jvv3s.js +87 -0
  387. package/dist/media-understanding.runtime-Cdr6iTW6.js +116 -0
  388. package/dist/memory-cli-LZbyF0Iu.js +111 -0
  389. package/dist/memory-search-BHhETk6u.js +17 -0
  390. package/dist/memory-search-tTD5o_rU.js +204 -0
  391. package/dist/method-scopes-B2ZKSsxQ.js +2452 -0
  392. package/dist/model-auth-markers-LqZ4qhrZ.d.ts +20 -0
  393. package/dist/model-picker-CTR5mo4v.js +112 -0
  394. package/dist/model-picker-DG4z_dBs.js +390 -0
  395. package/dist/model-picker.runtime-DMQ9Pj9_.js +125 -0
  396. package/dist/model-selection-bBBxfXdb.js +653 -0
  397. package/dist/model-suppression.runtime-BVG75tZ7.js +116 -0
  398. package/dist/models-BjkVLfgw.js +2514 -0
  399. package/dist/models-ZO01Q4cx.js +118 -0
  400. package/dist/models-cli-DemdF-bm.js +309 -0
  401. package/dist/models-config-B2Jja8ua.js +111 -0
  402. package/dist/models-config.providers.discovery-puxTsH39.d.ts +18 -0
  403. package/dist/moldclaw-root-Cb6HRlUO.js +92 -0
  404. package/dist/monitor-BP4idxJD.js +782 -0
  405. package/dist/monitor-B_eP8Eim.js +772 -0
  406. package/dist/monitor-CRHYNl5J.js +3468 -0
  407. package/dist/monitor-Ci1Xg4g3.js +113 -0
  408. package/dist/monitor-DEodDl3z.js +6823 -0
  409. package/dist/monitor-DJlNKuMz.js +115 -0
  410. package/dist/monitor-DvFwDS9w.js +3076 -0
  411. package/dist/monitor-shared--cEjSf8s.js +444 -0
  412. package/dist/msteams-CV2a8uE8.js +852 -0
  413. package/dist/node-cli-Of2g7DSd.js +2503 -0
  414. package/dist/node-resolve-BYC2FbO2.js +835 -0
  415. package/dist/nodes-cli-CPHM6Upj.js +1380 -0
  416. package/dist/nostr-BFKRoOlz.d.ts +7 -0
  417. package/dist/nostr-lHpcBzz4.js +8744 -0
  418. package/dist/npm-resolution-kqHN85wB.js +60 -0
  419. package/dist/oauth-env-CLG8KOrz.js +10 -0
  420. package/dist/onboard-BON0C360.js +48 -0
  421. package/dist/onboard-CRkIBgOI.js +589 -0
  422. package/dist/onboard-DsKI17iq.js +25 -0
  423. package/dist/onboard-channels-BY3IbBBf.js +1241 -0
  424. package/dist/onboard-channels-CLKdRxvW.js +205 -0
  425. package/dist/onboard-custom-BjPrMo_R.js +571 -0
  426. package/dist/onboard-custom-DqcPiZBN.js +114 -0
  427. package/dist/onboard-helpers-BkrOY5OE.js +113 -0
  428. package/dist/onboard-helpers-DiSRTpZC.js +335 -0
  429. package/dist/onboard-hooks-pzEPZAvl.js +72 -0
  430. package/dist/onboard-remote-ChyLC6Dk.js +181 -0
  431. package/dist/onboard-remote-DHmK9ntl.js +117 -0
  432. package/dist/onboard-search-BgA3jEMW.js +302 -0
  433. package/dist/onboard-skills-BMo_NvnW.js +133 -0
  434. package/dist/onboard-skills-Bba-Z2p8.js +117 -0
  435. package/dist/outbound-media-BHD4aJEX.d.ts +11 -0
  436. package/dist/outbound-media-DSno0N82.js +11 -0
  437. package/dist/pairing-access-CzHpaM0R.d.ts +21 -0
  438. package/dist/pairing-cli-CmklqK0q.js +217 -0
  439. package/dist/perplexity-CXwMDD3u.js +24 -0
  440. package/dist/persistent-dedupe-B9vrAf8t.d.ts +26 -0
  441. package/dist/pi-model-discovery-runtime-BrK7tcaO.js +111 -0
  442. package/dist/pi-tools.before-tool-call.runtime-C5yLUogH.js +381 -0
  443. package/dist/plugin-install-C4AWJIFP.js +117 -0
  444. package/dist/plugin-install-CB3J1hfV.js +184 -0
  445. package/dist/plugin-install-plan-7itZiegi.js +49 -0
  446. package/dist/plugin-registry-DX_GFoiz.js +113 -0
  447. package/dist/plugin-registry-e3cxTtvb.js +49 -0
  448. package/dist/plugin-sdk/account-resolution.js +35 -35
  449. package/dist/plugin-sdk/acp-runtime.js +35 -35
  450. package/dist/plugin-sdk/agent-runtime.js +35 -35
  451. package/dist/plugin-sdk/bluebubbles.js +37 -37
  452. package/dist/plugin-sdk/channel-config-helpers.js +35 -35
  453. package/dist/plugin-sdk/channel-policy.js +35 -35
  454. package/dist/plugin-sdk/channel-runtime.js +35 -35
  455. package/dist/plugin-sdk/compat.js +36 -36
  456. package/dist/plugin-sdk/config-runtime.js +35 -35
  457. package/dist/plugin-sdk/conversation-runtime.js +35 -35
  458. package/dist/plugin-sdk/copilot-proxy.js +4 -4
  459. package/dist/plugin-sdk/core.js +4 -4
  460. package/dist/plugin-sdk/device-pair.js +4 -4
  461. package/dist/plugin-sdk/discord.js +35 -35
  462. package/dist/plugin-sdk/feishu.js +35 -35
  463. package/dist/plugin-sdk/gateway-runtime.js +10 -10
  464. package/dist/plugin-sdk/googlechat.js +37 -37
  465. package/dist/plugin-sdk/image-generation-runtime.js +35 -35
  466. package/dist/plugin-sdk/image-generation.js +35 -35
  467. package/dist/plugin-sdk/imessage.js +36 -36
  468. package/dist/plugin-sdk/index.js +35 -35
  469. package/dist/plugin-sdk/infra-runtime.js +35 -35
  470. package/dist/plugin-sdk/irc.js +37 -37
  471. package/dist/plugin-sdk/line.js +36 -36
  472. package/dist/plugin-sdk/llm-task.js +35 -35
  473. package/dist/plugin-sdk/lobster.js +4 -4
  474. package/dist/plugin-sdk/matrix.js +37 -37
  475. package/dist/plugin-sdk/mattermost.js +36 -36
  476. package/dist/plugin-sdk/media-runtime.js +35 -35
  477. package/dist/plugin-sdk/media-understanding-runtime.js +35 -35
  478. package/dist/plugin-sdk/media-understanding.js +35 -35
  479. package/dist/plugin-sdk/memory-lancedb.js +4 -4
  480. package/dist/plugin-sdk/minimax-portal-auth.js +4 -4
  481. package/dist/plugin-sdk/msteams.js +38 -38
  482. package/dist/plugin-sdk/nextcloud-talk.js +36 -36
  483. package/dist/plugin-sdk/nostr.js +36 -36
  484. package/dist/plugin-sdk/ollama-setup.js +9 -9
  485. package/dist/plugin-sdk/open-prose.js +4 -4
  486. package/dist/plugin-sdk/phone-control.js +4 -4
  487. package/dist/plugin-sdk/plugin-runtime.js +35 -35
  488. package/dist/plugin-sdk/provider-auth.js +35 -35
  489. package/dist/plugin-sdk/provider-models.js +5 -5
  490. package/dist/plugin-sdk/provider-onboard.js +4 -4
  491. package/dist/plugin-sdk/provider-setup.js +39 -39
  492. package/dist/plugin-sdk/provider-stream.js +4 -4
  493. package/dist/plugin-sdk/provider-usage.js +4 -4
  494. package/dist/plugin-sdk/qwen-portal-auth.js +35 -35
  495. package/dist/plugin-sdk/reply-history.js +35 -35
  496. package/dist/plugin-sdk/reply-runtime.js +35 -35
  497. package/dist/plugin-sdk/routing.js +3 -3
  498. package/dist/plugin-sdk/sandbox.js +35 -35
  499. package/dist/plugin-sdk/security-runtime.js +35 -35
  500. package/dist/plugin-sdk/self-hosted-provider-setup.js +37 -37
  501. package/dist/plugin-sdk/setup.js +35 -35
  502. package/dist/plugin-sdk/signal.js +35 -35
  503. package/dist/plugin-sdk/slack.js +35 -35
  504. package/dist/plugin-sdk/speech-runtime.js +35 -35
  505. package/dist/plugin-sdk/speech.js +35 -35
  506. package/dist/plugin-sdk/src/secrets/secure-file-store.d.ts +26 -0
  507. package/dist/plugin-sdk/src/subscription/provider.d.ts +5 -3
  508. package/dist/plugin-sdk/synology-chat.js +36 -36
  509. package/dist/plugin-sdk/talk-voice.js +4 -4
  510. package/dist/plugin-sdk/telegram.js +35 -35
  511. package/dist/plugin-sdk/text-runtime.js +7 -7
  512. package/dist/plugin-sdk/thread-ownership.js +4 -4
  513. package/dist/plugin-sdk/tlon.js +36 -36
  514. package/dist/plugin-sdk/twitch.js +35 -35
  515. package/dist/plugin-sdk/voice-call.js +35 -35
  516. package/dist/plugin-sdk/whatsapp.js +35 -35
  517. package/dist/plugin-sdk/zalo.js +38 -38
  518. package/dist/plugin-sdk/zalouser.js +38 -38
  519. package/dist/plugins/runtime/index.d.ts +1 -1
  520. package/dist/plugins/runtime/index.js +35 -35
  521. package/dist/plugins-DF5FaTO0.js +111 -0
  522. package/dist/plugins-cli-CvTJemqC.js +917 -0
  523. package/dist/policy-CNXISK_a.js +143 -0
  524. package/dist/preflight-audio.runtime-RP000oxo.js +116 -0
  525. package/dist/probe-BkM5pykD.js +21 -0
  526. package/dist/probe-DKbRTJv5.js +1793 -0
  527. package/dist/probe-DkrfRsjU.js +47 -0
  528. package/dist/probe-DpcJ0WeP.js +129 -0
  529. package/dist/probe-auth-BcNjX8hy.js +40 -0
  530. package/dist/probe-auth-DhuAb8ls.js +48 -0
  531. package/dist/probe-wciBj-aL.js +6329 -0
  532. package/dist/program-C8-p0mW5.js +253 -0
  533. package/dist/prompt-select-styled-DH0pVoc0.js +2673 -0
  534. package/dist/provider-api-key-auth.runtime-CAFeIQ1u.js +121 -0
  535. package/dist/provider-auth-choice-CB_HzdTl.js +126 -0
  536. package/dist/provider-auth-choice-helpers-hzDkh3f1.js +48 -0
  537. package/dist/provider-auth-choice-preference-BHCXvNSE.js +189 -0
  538. package/dist/provider-auth-choice.runtime-Dx4ms2C5.js +123 -0
  539. package/dist/provider-auth-choices-0KaDNPBQ.js +57 -0
  540. package/dist/provider-auth-guidance-BaAUiNr_.js +34 -0
  541. package/dist/provider-auth-result-Bto1bYtS.d.ts +18 -0
  542. package/dist/provider-models-DxOmeToO.d.ts +867 -0
  543. package/dist/provider-models-xnyxy6mO.js +2113 -0
  544. package/dist/provider-ollama-setup-DBYK__ov.d.ts +32 -0
  545. package/dist/provider-ollama-setup-QzgCxj44.js +314 -0
  546. package/dist/provider-onboard-B9ionepI.js +139 -0
  547. package/dist/provider-onboard-CURxJ_UX.d.ts +40 -0
  548. package/dist/provider-runtime.runtime-4xwmsl5L.js +111 -0
  549. package/dist/provider-self-hosted-setup-BHd24EDG.js +182 -0
  550. package/dist/provider-self-hosted-setup-qeY8BYSy.d.ts +61 -0
  551. package/dist/provider-stream-Chz_EFw3.js +512 -0
  552. package/dist/provider-usage-C11Q7UwS.js +111 -0
  553. package/dist/provider-usage-kxemdMp2.js +633 -0
  554. package/dist/provider-wizard-CanJoxNC.js +152 -0
  555. package/dist/push-apns-Dsajnm8C.js +1038 -0
  556. package/dist/pw-ai-DUe4BbH2.js +1867 -0
  557. package/dist/qmd-manager-CAAFp7qK.js +1570 -0
  558. package/dist/qr-cli-Bu2jqTPY.js +113 -0
  559. package/dist/qr-cli-Bu9Z-X48.js +369 -0
  560. package/dist/reactions-Cpfum4iU.js +281 -0
  561. package/dist/read-only-account-inspect.discord.runtime-BK0LaMgC.js +116 -0
  562. package/dist/read-only-account-inspect.slack.runtime-DgKiC5wT.js +116 -0
  563. package/dist/read-only-account-inspect.telegram.runtime-mxfgFVOU.js +116 -0
  564. package/dist/redact-snapshot-DD8A4tdd.js +2663 -0
  565. package/dist/register.agent-DU4FtrU2.js +439 -0
  566. package/dist/register.backup-8nOYtJqg.js +625 -0
  567. package/dist/register.configure-DmtecqIH.js +252 -0
  568. package/dist/register.maintenance-Dir3ulKP.js +574 -0
  569. package/dist/register.message-Cfl-f3Ju.js +709 -0
  570. package/dist/register.onboard-Bv7WVzEi.js +192 -0
  571. package/dist/register.setup-BIyeI8RY.js +212 -0
  572. package/dist/register.status-health-sessions-C69WQcF4.js +498 -0
  573. package/dist/register.subclis-B_4KCgTd.js +315 -0
  574. package/dist/register.subclis-BeXsmgBL.js +13 -0
  575. package/dist/replies-DdcFUmki.js +110 -0
  576. package/dist/resolve-channels-DRZqPV5o.js +226 -0
  577. package/dist/resolve-channels-DxW1kqxA.js +262 -0
  578. package/dist/resolve-route-DdX-HBVt.js +538 -0
  579. package/dist/resolve-users-rgCQvkLs.js +143 -0
  580. package/dist/root-help-QAkoA7GD.js +32 -0
  581. package/dist/routes-CcJNnwTF.js +7097 -0
  582. package/dist/rpc-DDUAlBbH.js +67 -0
  583. package/dist/run-main-D9ci5pn7.js +424 -0
  584. package/dist/runtime-Bitmi8Er.d.ts +26 -0
  585. package/dist/runtime-discord-ops.runtime-T4sf7aRB.js +9078 -0
  586. package/dist/runtime-slack-ops.runtime-BQpP48mC.js +4556 -0
  587. package/dist/runtime-telegram-ops.runtime-cVO5dqOp.js +133 -0
  588. package/dist/runtime-whatsapp-login.runtime-DtNx0dSY.js +114 -0
  589. package/dist/runtime-whatsapp-outbound.runtime-Bw47QbFK.js +117 -0
  590. package/dist/sandbox-cli-DsFwjbjC.js +535 -0
  591. package/dist/search-manager-BRAK8fEe.js +16 -0
  592. package/dist/search-manager-BS5Db0A6.js +386 -0
  593. package/dist/secrets-cli-D3J46TJp.js +2070 -0
  594. package/dist/security-cli-B866M9cB.js +575 -0
  595. package/dist/send-B1pX9_Oc.js +283 -0
  596. package/dist/send-B2RrLg83.js +100 -0
  597. package/dist/send-DFnV__Aq.js +1025 -0
  598. package/dist/send-DZIH6CJt.js +629 -0
  599. package/dist/send-sl9WnKbW.js +631 -0
  600. package/dist/server-node-events-BT6egg20.js +506 -0
  601. package/dist/server-zI_K-D05.js +107 -0
  602. package/dist/sessions-C8kiAcoJ.js +112 -0
  603. package/dist/sessions-DLBpp52_.js +218 -0
  604. package/dist/setup-C7eOzMiC.js +387 -0
  605. package/dist/setup-CFIMq-Pz.d.ts +37 -0
  606. package/dist/setup-binary-CcAv8NXz.js +406 -0
  607. package/dist/setup-browser-C4eRV3h6.js +70 -0
  608. package/dist/setup-core-BnR486P-.js +143 -0
  609. package/dist/setup-core-CIswIiu5.js +166 -0
  610. package/dist/setup-core-CcbcrXXg.js +47 -0
  611. package/dist/setup-core-nZSw5BSv.js +205 -0
  612. package/dist/setup-surface-C5iSpT4M.js +490 -0
  613. package/dist/setup-wizard-helpers-r0J6l8ST.d.ts +203 -0
  614. package/dist/setup.finalize-adiRfo0U.js +522 -0
  615. package/dist/setup.gateway-config-BwFWKDfT.js +343 -0
  616. package/dist/shared-12TimyeF.js +182 -0
  617. package/dist/shared-9EWO34-k.js +298 -0
  618. package/dist/shared-B4vUbaRR.js +75 -0
  619. package/dist/shared-bNWpW3Dd.js +96 -0
  620. package/dist/shared-lU1y5dvS.js +102 -0
  621. package/dist/signal-DBlETRu9.js +114 -0
  622. package/dist/skills-Bio8GwTE.js +20 -0
  623. package/dist/skills-DE_MXFSN.js +853 -0
  624. package/dist/skills-cli-BGuW-tKw.js +292 -0
  625. package/dist/skills-install--rnorIoJ.js +763 -0
  626. package/dist/skills-status-B08PtBc_.js +21 -0
  627. package/dist/skills-status-CzM008aB.js +169 -0
  628. package/dist/slack-C4T53Nc-.js +114 -0
  629. package/dist/slash-commands.runtime-B7fsD8Be.js +128 -0
  630. package/dist/slash-dispatch.runtime-t0PAX4vQ.js +141 -0
  631. package/dist/slash-skill-commands.runtime-DIhPnEfR.js +116 -0
  632. package/dist/src-DrDirlvw.js +1701 -0
  633. package/dist/status-Bld14WSA.js +131 -0
  634. package/dist/status-CgeO4RuH.js +43 -0
  635. package/dist/status-HlvixAOq.js +606 -0
  636. package/dist/status-Rom_Lf3c.js +1599 -0
  637. package/dist/status-TwbMH6Am.js +126 -0
  638. package/dist/status-json-DMW7cmuK.js +288 -0
  639. package/dist/status.link-channel-V4LkB6Gq.js +143 -0
  640. package/dist/status.scan.deps.runtime-BE3X-dcP.js +126 -0
  641. package/dist/status.scan.runtime-BxVY4mty.js +119 -0
  642. package/dist/status.summary-CzLM0vVr.js +592 -0
  643. package/dist/status.summary.runtime-BSBnHZ1Q.js +118 -0
  644. package/dist/status.update-BxblMS7P.js +77 -0
  645. package/dist/subagent-orphan-recovery-BpRPryEj.js +307 -0
  646. package/dist/subagent-registry-runtime-DYYU5p3X.js +111 -0
  647. package/dist/subscription-CpFdxuFS.js +33 -0
  648. package/dist/subscription-DaA1urx-.js +102 -0
  649. package/dist/subscription-cli-Bvto9EmO.js +134 -0
  650. package/dist/synology-chat-3nwk-Nj0.js +297 -0
  651. package/dist/system-cli-BvNps8sl.js +94 -0
  652. package/dist/telegram/audit.d.ts +1 -1
  653. package/dist/telegram/audit.js +1 -1
  654. package/dist/telegram/token.d.ts +1 -1
  655. package/dist/telegram/token.js +35 -35
  656. package/dist/telegram-RtKXoEsF.js +114 -0
  657. package/dist/text-chunking-BD5mQe2R.js +84 -0
  658. package/dist/text-chunking-DDUU_vAF.d.ts +79 -0
  659. package/dist/tlon-z-kYmJE-.js +433 -0
  660. package/dist/tui-cli-CzSK08Rh.js +137 -0
  661. package/dist/tui-wV7R1Tlc.js +3834 -0
  662. package/dist/types-2H_e7eWT.d.ts +45 -0
  663. package/dist/types-ZKnGUchG.d.ts +22692 -0
  664. package/dist/types.base-BFiQZ4J9.d.ts +188 -0
  665. package/dist/ui-BWVHreeR.js +31 -0
  666. package/dist/update-D1Wgh1Tj.js +1036 -0
  667. package/dist/update-cli-CZh99uyY.js +1503 -0
  668. package/dist/update-offset-store-D5xTdUr0.js +112 -0
  669. package/dist/update-runner-GbKfoCHs.js +1496 -0
  670. package/dist/upsert-with-lock-BZU7Le8n.js +33 -0
  671. package/dist/usage-Czgwvg0h.js +115 -0
  672. package/dist/web-CMczmL90.js +112 -0
  673. package/dist/web-shared-B5Q0mIJq.d.ts +45 -0
  674. package/dist/webhook-request-guards-CsKDhZJr.d.ts +76 -0
  675. package/dist/webhook-targets-BSmFtesN.js +181 -0
  676. package/dist/webhook-targets-CjxuEE9C.d.ts +106 -0
  677. package/dist/webhooks-cli-Wl9y6AWW.js +350 -0
  678. package/dist/whatsapp-VzRW8MdR.js +114 -0
  679. package/dist/whatsapp-actions-Cg1Wxv8W.js +167 -0
  680. package/dist/workspace-DJ_S272u.js +484 -0
  681. package/dist/workspace-DbZSqjw0.js +289 -0
  682. package/dist/workspace-cli-D93DLmAh.js +154 -0
  683. package/dist/workspace-dirs-CGeIPpGN.js +2003 -0
  684. package/dist/zalo-CK2dlGmu.d.ts +9 -0
  685. package/dist/zalo-Db7s2boL.js +415 -0
  686. package/dist/zalouser-Jh5YTJX3.js +30911 -0
  687. package/docs/reference/templates/AGENTS.dev.md +83 -0
  688. package/docs/reference/templates/AGENTS.md +219 -0
  689. package/docs/reference/templates/BOOT.md +11 -0
  690. package/docs/reference/templates/BOOTSTRAP.md +62 -0
  691. package/docs/reference/templates/HEARTBEAT.md +12 -0
  692. package/docs/reference/templates/IDENTITY.dev.md +47 -0
  693. package/docs/reference/templates/IDENTITY.md +29 -0
  694. package/docs/reference/templates/SOUL.dev.md +76 -0
  695. package/docs/reference/templates/SOUL.md +43 -0
  696. package/docs/reference/templates/TOOLS.dev.md +24 -0
  697. package/docs/reference/templates/TOOLS.md +47 -0
  698. package/docs/reference/templates/USER.dev.md +18 -0
  699. package/docs/reference/templates/USER.md +23 -0
  700. package/extensions/discord/src/monitor/allow-list.ts +8 -1
  701. package/extensions/discord/src/monitor/message-handler.preflight.ts +4 -1
  702. package/package.json +2 -1
  703. package/dist/accounts-CDr-lDaV.d.ts +0 -103
  704. package/dist/accounts-CS8U4v8C.js +0 -114
  705. package/dist/acp-cli-BGT0jXcC.js +0 -2093
  706. package/dist/actions.runtime-BfckTw6c.js +0 -119
  707. package/dist/actions.runtime-Cl9mBfqH.js +0 -133
  708. package/dist/agent-scope-C-YmLnnb.js +0 -208
  709. package/dist/agents-CydD54p8.js +0 -222
  710. package/dist/agents-DpQsZO6O.js +0 -853
  711. package/dist/agents.config-XU7IsYE-.js +0 -121
  712. package/dist/agents.config-ssoQXuvF.js +0 -17
  713. package/dist/allow-list-Cfn6lmMK.js +0 -81
  714. package/dist/allowlist-CCYXVpM9.js +0 -142
  715. package/dist/api-BoXoFKxy.js +0 -117
  716. package/dist/audit-Bv05N5o9.js +0 -787
  717. package/dist/audit-CIWW1Aqm.js +0 -54
  718. package/dist/audit-channel.collect.runtime-Bi7yrdcO.js +0 -605
  719. package/dist/audit-channel.runtime-C_NDweiW.js +0 -121
  720. package/dist/audit-extra.async-Dp7OKSXg.js +0 -813
  721. package/dist/audit-membership-runtime-B8FQ6VtN.js +0 -162
  722. package/dist/audit.deep.runtime-CXhobL6b.js +0 -25
  723. package/dist/audit.nondeep.runtime-CrEm3T16.js +0 -832
  724. package/dist/audit.runtime-CJPKj1Zg.js +0 -118
  725. package/dist/auth-Byfp0flq.js +0 -101
  726. package/dist/auth-choice-BgOjdeXN.js +0 -507
  727. package/dist/auth-choice-CD1Heq0M.js +0 -122
  728. package/dist/auth-choice-ePNfg0iQ.js +0 -268
  729. package/dist/auth-choice-options-BlewQWI0.js +0 -123
  730. package/dist/auth-choice-prompt-BP2b6aXz.js +0 -36
  731. package/dist/auth-choice-prompt-Cmwl4n97.js +0 -115
  732. package/dist/auth-choice.apply-helpers-Dq-nxuuX.js +0 -66
  733. package/dist/auth-choice.plugin-providers.runtime-B23kOUzQ.js +0 -119
  734. package/dist/auth-profiles-1kPLbBwI.js +0 -127823
  735. package/dist/auth-profiles.runtime-DAfSjku1.js +0 -116
  736. package/dist/banner-DeOsobLO.js +0 -342
  737. package/dist/bluebubbles-BsLGedBM.js +0 -64
  738. package/dist/bluebubbles-CnT9wiS4.d.ts +0 -6
  739. package/dist/bot-CuzVYwa_.d.ts +0 -478
  740. package/dist/brave-BoWimrLe.js +0 -24
  741. package/dist/browser-cli-D_S3wEYE.js +0 -1494
  742. package/dist/call-ByEzDJ1_.js +0 -640
  743. package/dist/call-CHCWVg-O.js +0 -39
  744. package/dist/channel-3VC0oOMu.js +0 -214
  745. package/dist/channel-B9fCBPiS.js +0 -207
  746. package/dist/channel-B9q775cM.js +0 -562
  747. package/dist/channel-BG3UK54j.js +0 -803
  748. package/dist/channel-BRQAdMML.js +0 -352
  749. package/dist/channel-BmlLp933.js +0 -1321
  750. package/dist/channel-By6KvdTG.js +0 -920
  751. package/dist/channel-C8rRsdf6.js +0 -226
  752. package/dist/channel-CLEDBbXE.js +0 -943
  753. package/dist/channel-CMvBAG7o.js +0 -306
  754. package/dist/channel-CmlxxjHY.js +0 -1598
  755. package/dist/channel-CqG6_xN0.js +0 -949
  756. package/dist/channel-DNueHKs92.js +0 -316
  757. package/dist/channel-DUtyN7BX.js +0 -4681
  758. package/dist/channel-DWD6GrfZ.js +0 -538
  759. package/dist/channel-DaRYMYzj.js +0 -619
  760. package/dist/channel-Dj6BgLp8.js +0 -575
  761. package/dist/channel-account-context-Ba3u5D21.js +0 -103
  762. package/dist/channel-crabk6Em.js +0 -542
  763. package/dist/channel-i8uqQaK2.js +0 -497
  764. package/dist/channel-options-xljvwHS2.js +0 -50
  765. package/dist/channel-plugin-ids-DAgknSG4.js +0 -26
  766. package/dist/channel-summary-dHTMCG75.js +0 -111
  767. package/dist/channel-xVWQ96Ni.js +0 -397
  768. package/dist/channel.runtime-B6PoZ4BV.js +0 -182
  769. package/dist/channel.runtime-BPZmo57e.js +0 -404
  770. package/dist/channel.runtime-B_1uGR-U.js +0 -199
  771. package/dist/channel.runtime-BiXnPU0d.js +0 -218
  772. package/dist/channel.runtime-BpvDc9sv.js +0 -870
  773. package/dist/channel.runtime-CUua3W80.js +0 -418
  774. package/dist/channel.runtime-CaCBTd0A.js +0 -179
  775. package/dist/channel.runtime-D0FfYvUj.js +0 -4011
  776. package/dist/channel.runtime-DhoJtpvJ.js +0 -241
  777. package/dist/channel.runtime-Kj9EXNE0.js +0 -127
  778. package/dist/channel.runtime-r4tPuPyh.js +0 -171
  779. package/dist/channel.setup-B7d_grfe.js +0 -6
  780. package/dist/channel.setup-C0vu1fhi.js +0 -9
  781. package/dist/channel.setup-CAI0FNHj.js +0 -11
  782. package/dist/channel.setup-CkDVwv5R.js +0 -57
  783. package/dist/channel.setup-Cpd00YqQ.js +0 -8
  784. package/dist/channel.setup-DbBz1-WT.js +0 -9
  785. package/dist/channel.setup-GZnAvD9g.js +0 -8
  786. package/dist/channels-5H484RSw.js +0 -1118
  787. package/dist/channels-BnPudfyx.js +0 -404
  788. package/dist/channels-cli-WIC-QeH_.js +0 -291
  789. package/dist/channels-status-issues-RDmzovJU.js +0 -16
  790. package/dist/clawbot-cli-BgutNwf8.js +0 -118
  791. package/dist/cleanup-utils-DBl1Aij1.js +0 -96
  792. package/dist/cli-1P7u6zqu.js +0 -154
  793. package/dist/command-registry-B8jovrws.js +0 -232
  794. package/dist/command-registry-DtDl1FVm.js +0 -14
  795. package/dist/command-secret-gateway-BgUo3FxJ.js +0 -111
  796. package/dist/compact.runtime-CXbXM0AU.js +0 -116
  797. package/dist/completion-cli-Cik_owAE.js +0 -17
  798. package/dist/completion-cli-RU3P2RSl.js +0 -445
  799. package/dist/config-5HUpB1L1.js +0 -31
  800. package/dist/config-cli-QHaUHoZI.js +0 -433
  801. package/dist/config-guard-C9Sn3pE-.js +0 -118
  802. package/dist/config-sW57gztj.js +0 -44
  803. package/dist/config-validation-5LkjIKNt.js +0 -262
  804. package/dist/config-value-CtTWALxG.js +0 -132
  805. package/dist/configure-BmR2TPLf.js +0 -243
  806. package/dist/configure-DaLN-5xM.js +0 -1100
  807. package/dist/control-ui-assets-CH3MYmAo.js +0 -232
  808. package/dist/control-ui-shared-CA77PTml.js +0 -29
  809. package/dist/core-CvDzLs7B.js +0 -150
  810. package/dist/core-jm751KJ9.d.ts +0 -87
  811. package/dist/cron-cli-tguLpzyq.js +0 -639
  812. package/dist/daemon-cli-ptosOkL8.js +0 -339
  813. package/dist/daemon-install-DzU4EnVa.js +0 -180
  814. package/dist/deliver-DwxFoHM3.js +0 -111
  815. package/dist/deliver-runtime-DOdDyaPI.js +0 -111
  816. package/dist/device-id-cli-GopvlxxZ.js +0 -52
  817. package/dist/device-identity-CRfhC3_s.js +0 -365
  818. package/dist/devices-cli-ain7ESqU.js +0 -342
  819. package/dist/diagnostic-D96Xaqrj.js +0 -310
  820. package/dist/directory-cli-fh1UxGgY.js +0 -311
  821. package/dist/directory-config-helpers-Coivm0Mt.d.ts +0 -38
  822. package/dist/directory.static-CKjJUNGl.js +0 -44
  823. package/dist/discord-CflhwDEM.js +0 -114
  824. package/dist/discovery-x0ZqY4AB.js +0 -48
  825. package/dist/dm-policy-shared-DKzsSLlO.d.ts +0 -95
  826. package/dist/dns-cli-DCHyKjGf.js +0 -217
  827. package/dist/docs-cli-D3OoqYSP.js +0 -174
  828. package/dist/doctor-completion-Bq2eP87s.js +0 -90
  829. package/dist/doctor-config-flow-D8XRG9Ku.js +0 -2437
  830. package/dist/doctor-config-flow-DGiF1HGc.js +0 -112
  831. package/dist/enable-0QSF4YGH.js +0 -24
  832. package/dist/exec-approvals-cli-Bncym0Gd.js +0 -421
  833. package/dist/feishu-C1dM8pl2.d.ts +0 -36
  834. package/dist/gateway-cli-DYscsmA-.js +0 -26437
  835. package/dist/gateway-install-token-CNv17ac9.js +0 -163
  836. package/dist/gateway-rpc-BGC1Rxvg.js +0 -26
  837. package/dist/gateway-runtime-D89mSQPB.js +0 -69
  838. package/dist/git-commit-CeLH5Ozm.js +0 -2
  839. package/dist/git-commit-DUKRiCP-.js +0 -177
  840. package/dist/googlechat-BgXeXjd1.js +0 -307
  841. package/dist/googlechat-CNZQb1jd.d.ts +0 -12
  842. package/dist/group-access-Deh1tVNr.d.ts +0 -61
  843. package/dist/health-BEjzWwaB.js +0 -570
  844. package/dist/health-FjqrWQL6.js +0 -113
  845. package/dist/heartbeat-summary-CfdSA9M1.js +0 -57
  846. package/dist/help-BZeVprq1.js +0 -81
  847. package/dist/hooks-06OUQvAV.d.ts +0 -6
  848. package/dist/hooks-cli-B7uGJs2O.js +0 -1000
  849. package/dist/hooks-status-CfceaUSg.js +0 -78
  850. package/dist/http-registry-DYskWhOr.d.ts +0 -20
  851. package/dist/identity-file-sshkKKIr.js +0 -60
  852. package/dist/image-generation-D4o3j8o6.d.ts +0 -9
  853. package/dist/imessage-BcV3WGx_.js +0 -31
  854. package/dist/imessage-Dhje7Ty-.js +0 -115
  855. package/dist/inbound-reply-dispatch-C73_7SOl.js +0 -71
  856. package/dist/inbound-reply-dispatch-D6_HNqH8.d.ts +0 -72
  857. package/dist/install-target-D7NRhfzc.js +0 -574
  858. package/dist/installs-Bj6jblqc.js +0 -532
  859. package/dist/io-CMfWWPXQ.js +0 -9738
  860. package/dist/io-CV844hAM.js +0 -29
  861. package/dist/irc-DKi1fDYI.js +0 -672
  862. package/dist/library-rygTG3oA.js +0 -112
  863. package/dist/lifecycle-core-BPlvShWY.js +0 -382
  864. package/dist/line-B8gTtl3Y.d.ts +0 -75
  865. package/dist/line-CGsemKWJ.js +0 -530
  866. package/dist/llm-slug-generator-DlhVyMqT.js +0 -67
  867. package/dist/logging-5wu9k6w4.js +0 -30
  868. package/dist/logging-CxP9suT8.js +0 -13
  869. package/dist/login-qr-BcDsiwHs.js +0 -233
  870. package/dist/login-qr-Y8pJ5yV4.js +0 -112
  871. package/dist/logs-cli-XI9oVXpH.js +0 -256
  872. package/dist/manager-runtime-DkIlXBhD.js +0 -111
  873. package/dist/manager.runtime-Q0q2rJCC.js +0 -715
  874. package/dist/manifest-registry-DAd0SRAP.js +0 -1329
  875. package/dist/matrix-BI0DBBrG.js +0 -1495
  876. package/dist/matrix-D2JoHzb4.d.ts +0 -68
  877. package/dist/matrix-DiABGjJR.js +0 -1269
  878. package/dist/mcp-cli-BOyn_DLL.js +0 -87
  879. package/dist/media-understanding.runtime-DjUa7Dka.js +0 -116
  880. package/dist/memory-cli-CJd_vl-Y.js +0 -111
  881. package/dist/memory-search-CEEItIFR.js +0 -17
  882. package/dist/memory-search-Cv1SBrn7.js +0 -204
  883. package/dist/method-scopes-CQE7-bZ-.js +0 -2452
  884. package/dist/model-auth-markers-BFoM4IPf.d.ts +0 -20
  885. package/dist/model-picker-D6_89XHg.js +0 -112
  886. package/dist/model-picker-Svaw-APs.js +0 -390
  887. package/dist/model-picker.runtime-Chi9nV7A.js +0 -125
  888. package/dist/model-selection-hL8i1Jbs.js +0 -653
  889. package/dist/model-suppression.runtime-DjWJZ0X-.js +0 -116
  890. package/dist/models-7qj1dG_W.js +0 -118
  891. package/dist/models-BPOB_xJF.js +0 -2514
  892. package/dist/models-cli-DdlOVUjS.js +0 -309
  893. package/dist/models-config-CBqUS-jX.js +0 -111
  894. package/dist/models-config.providers.discovery-Dc905FWG.d.ts +0 -18
  895. package/dist/moldclaw-root-D6PbhbZk.js +0 -88
  896. package/dist/monitor-BPYhkEqF.js +0 -782
  897. package/dist/monitor-BuTcQ24j.js +0 -3468
  898. package/dist/monitor-CuXvNhFh.js +0 -113
  899. package/dist/monitor-D-TqSIHF.js +0 -6823
  900. package/dist/monitor-DRSgo9u2.js +0 -3076
  901. package/dist/monitor-DcHch39z.js +0 -772
  902. package/dist/monitor-DsHBMrXp.js +0 -115
  903. package/dist/monitor-shared-CL8T4gt1.js +0 -444
  904. package/dist/msteams-7FMwTvQG.js +0 -852
  905. package/dist/node-cli-BCjaSCZM.js +0 -2503
  906. package/dist/node-resolve-D5Hvcgyx.js +0 -835
  907. package/dist/nodes-cli-Dd_SNbkt.js +0 -1380
  908. package/dist/nostr-DBTFTxKs.js +0 -8744
  909. package/dist/nostr-DLqaIuZx.d.ts +0 -7
  910. package/dist/npm-resolution-CYfb3MHG.js +0 -60
  911. package/dist/oauth-env-zPt5RywA.js +0 -10
  912. package/dist/onboard-BEFQQeig.js +0 -25
  913. package/dist/onboard-CJHNyxJh.js +0 -48
  914. package/dist/onboard-D_3UeLEN.js +0 -589
  915. package/dist/onboard-channels-B_JL0Djc.js +0 -1241
  916. package/dist/onboard-channels-CqZzHt2C.js +0 -205
  917. package/dist/onboard-custom-CER3Ggbq.js +0 -571
  918. package/dist/onboard-custom-bNRdGECb.js +0 -114
  919. package/dist/onboard-helpers-BK0Hsb7Y.js +0 -335
  920. package/dist/onboard-helpers-CXZ5RPoR.js +0 -113
  921. package/dist/onboard-hooks-1NsxEDjH.js +0 -72
  922. package/dist/onboard-remote-DuKhC_7W.js +0 -117
  923. package/dist/onboard-remote-OwRcDuB3.js +0 -181
  924. package/dist/onboard-search-Cy8dOq2W.js +0 -302
  925. package/dist/onboard-skills-D5phRa6r.js +0 -117
  926. package/dist/onboard-skills-c9qWCNe9.js +0 -133
  927. package/dist/outbound-media-CXKqTh2X.d.ts +0 -11
  928. package/dist/outbound-media-DYRO2vTD.js +0 -11
  929. package/dist/pairing-access-BwJu1mkk.d.ts +0 -21
  930. package/dist/pairing-cli-BOnv0TYn.js +0 -217
  931. package/dist/perplexity-EZwC3y2b.js +0 -24
  932. package/dist/persistent-dedupe-hNES5tS1.d.ts +0 -26
  933. package/dist/pi-model-discovery-runtime-BToY3A6K.js +0 -111
  934. package/dist/pi-tools.before-tool-call.runtime-D_acPtld.js +0 -381
  935. package/dist/plugin-install-CgJpSjYd.js +0 -184
  936. package/dist/plugin-install-Cl1A4EF6.js +0 -117
  937. package/dist/plugin-install-plan-Dc2Z4DeU.js +0 -49
  938. package/dist/plugin-registry-B1UaWrQD.js +0 -49
  939. package/dist/plugin-registry-Cy8biwnn.js +0 -113
  940. package/dist/plugins-CXwvg50F.js +0 -111
  941. package/dist/plugins-cli-Uvzp2aYV.js +0 -917
  942. package/dist/policy-DsMBbEe7.js +0 -143
  943. package/dist/preflight-audio.runtime-hWsZIYvc.js +0 -116
  944. package/dist/probe-CNsSf1Uf.js +0 -6329
  945. package/dist/probe-CqOIrPhb.js +0 -47
  946. package/dist/probe-DH6gDw-h.js +0 -129
  947. package/dist/probe-DM16PLf4.js +0 -21
  948. package/dist/probe-DvAEEWYr.js +0 -1793
  949. package/dist/probe-auth-COfgCble.js +0 -48
  950. package/dist/probe-auth-I_5TX1Eh.js +0 -40
  951. package/dist/program-Dz80sgTU.js +0 -253
  952. package/dist/prompt-select-styled-wQehwFxK.js +0 -2673
  953. package/dist/provider-api-key-auth.runtime-BR9GU4ya.js +0 -121
  954. package/dist/provider-auth-choice-CdhA84kr.js +0 -126
  955. package/dist/provider-auth-choice-helpers-kabp_0zA.js +0 -48
  956. package/dist/provider-auth-choice-preference-se3zAM_2.js +0 -189
  957. package/dist/provider-auth-choice.runtime-BMc8-xNQ.js +0 -123
  958. package/dist/provider-auth-choices-CYsCViGi.js +0 -57
  959. package/dist/provider-auth-guidance-CMjUWlNf.js +0 -34
  960. package/dist/provider-auth-result-5xgWoVGi.d.ts +0 -18
  961. package/dist/provider-models-BCId_Lfu.js +0 -2113
  962. package/dist/provider-models-D-eFl9oH.d.ts +0 -867
  963. package/dist/provider-ollama-setup-B6XJZ0So.js +0 -314
  964. package/dist/provider-ollama-setup-BF1vhob8.d.ts +0 -32
  965. package/dist/provider-onboard-BjXHP3IZ.d.ts +0 -40
  966. package/dist/provider-onboard-Ca0TaNud.js +0 -139
  967. package/dist/provider-runtime.runtime-DwwkHw_7.js +0 -111
  968. package/dist/provider-self-hosted-setup-BEKLVGpj.js +0 -182
  969. package/dist/provider-self-hosted-setup-BQ5BIlpi.d.ts +0 -61
  970. package/dist/provider-stream-DrUD69ai.js +0 -512
  971. package/dist/provider-usage-BgKHCnjr.js +0 -111
  972. package/dist/provider-usage-D8EZpFz9.js +0 -633
  973. package/dist/provider-wizard-DMdb-zj_.js +0 -152
  974. package/dist/push-apns-BPH6d4VV.js +0 -1038
  975. package/dist/pw-ai-DttfldtL.js +0 -1867
  976. package/dist/qmd-manager-CybcDUfk.js +0 -1570
  977. package/dist/qr-cli-8NcmJ8Ft.js +0 -369
  978. package/dist/qr-cli-DWe0Our3.js +0 -113
  979. package/dist/reactions-D6N0LR16.js +0 -281
  980. package/dist/read-only-account-inspect.discord.runtime-CqUWTRfl.js +0 -116
  981. package/dist/read-only-account-inspect.slack.runtime-9-jpln3q.js +0 -116
  982. package/dist/read-only-account-inspect.telegram.runtime-EKPI1D7n.js +0 -116
  983. package/dist/redact-snapshot-DwJEIVk9.js +0 -2663
  984. package/dist/register.agent-D3YdDirP.js +0 -439
  985. package/dist/register.backup-dR27qCuo.js +0 -625
  986. package/dist/register.configure-BjFhkkka.js +0 -252
  987. package/dist/register.maintenance-DiMQJIOa.js +0 -574
  988. package/dist/register.message-CdZsKYH1.js +0 -709
  989. package/dist/register.onboard-B0rV1eaO.js +0 -192
  990. package/dist/register.setup-wKMvohzo.js +0 -212
  991. package/dist/register.status-health-sessions-BJ68m6pt.js +0 -498
  992. package/dist/register.subclis-CnnrWt2a.js +0 -315
  993. package/dist/register.subclis-lSvTkC6z.js +0 -13
  994. package/dist/replies-BABt9b48.js +0 -110
  995. package/dist/resolve-channels-BqZFl2Ux.js +0 -262
  996. package/dist/resolve-channels-DjQLXb7B.js +0 -226
  997. package/dist/resolve-route-CSHDsa_m.js +0 -538
  998. package/dist/resolve-users-BG6HaSR5.js +0 -143
  999. package/dist/root-help-ohmaCyC_.js +0 -32
  1000. package/dist/routes-4k2kpvoT.js +0 -7097
  1001. package/dist/rpc-Cnwn4Q6L.js +0 -67
  1002. package/dist/run-main-VYlacKA0.js +0 -424
  1003. package/dist/runtime-Cy8pqYUB.d.ts +0 -26
  1004. package/dist/runtime-discord-ops.runtime-DafrU-rI.js +0 -9078
  1005. package/dist/runtime-slack-ops.runtime-CdXBKXwd.js +0 -4556
  1006. package/dist/runtime-telegram-ops.runtime-B12sF7gE.js +0 -133
  1007. package/dist/runtime-whatsapp-login.runtime-CqEudH37.js +0 -114
  1008. package/dist/runtime-whatsapp-outbound.runtime-D5m2qyn-.js +0 -117
  1009. package/dist/sandbox-cli-CHJiEWXB.js +0 -535
  1010. package/dist/search-manager-BtNC3-i_.js +0 -16
  1011. package/dist/search-manager-C7J7B3_a.js +0 -386
  1012. package/dist/secrets-cli-C6yIWBbN.js +0 -2070
  1013. package/dist/security-cli-BVu9BkjD.js +0 -575
  1014. package/dist/send-BSreC7rr.js +0 -631
  1015. package/dist/send-BsLHQG_B.js +0 -1025
  1016. package/dist/send-BuNhp8PH.js +0 -283
  1017. package/dist/send-DOCswVar.js +0 -100
  1018. package/dist/send-Dl0LLErk.js +0 -629
  1019. package/dist/server-node-events-Bq2067EG.js +0 -506
  1020. package/dist/server-y38L7N5H.js +0 -107
  1021. package/dist/sessions-BV8gXURR.js +0 -112
  1022. package/dist/sessions-dl1Kc-Ci.js +0 -218
  1023. package/dist/setup-DGszQH0_.js +0 -387
  1024. package/dist/setup-DR5rRw9y.d.ts +0 -37
  1025. package/dist/setup-binary-C17YnmA8.js +0 -406
  1026. package/dist/setup-browser-CPx-nEsr.js +0 -70
  1027. package/dist/setup-core-BByHN1ME.js +0 -143
  1028. package/dist/setup-core-C0KPlBmL.js +0 -47
  1029. package/dist/setup-core-Cq37G6of.js +0 -166
  1030. package/dist/setup-core-uO84_Y75.js +0 -205
  1031. package/dist/setup-surface-BEMi7Rmb.js +0 -490
  1032. package/dist/setup-wizard-helpers-BtuGx_gN.d.ts +0 -203
  1033. package/dist/setup.finalize-BzPBa8zW.js +0 -522
  1034. package/dist/setup.gateway-config-DdwkF-8e.js +0 -343
  1035. package/dist/shared-BCw4SKjB.js +0 -96
  1036. package/dist/shared-CjNzsULP.js +0 -75
  1037. package/dist/shared-Cu1BE7ZE.js +0 -298
  1038. package/dist/shared-DSClmyUn.js +0 -182
  1039. package/dist/shared-DyJdGH6y.js +0 -102
  1040. package/dist/signal-Dyv4NZsB.js +0 -114
  1041. package/dist/skills-CbB5b27M.js +0 -853
  1042. package/dist/skills-CnfI7Szw.js +0 -20
  1043. package/dist/skills-cli-CavB1f_3.js +0 -292
  1044. package/dist/skills-install-B1OBdgd0.js +0 -763
  1045. package/dist/skills-status-B3gAmIbW.js +0 -169
  1046. package/dist/skills-status-DrHhFgU9.js +0 -21
  1047. package/dist/slack-BRzqnoAz.js +0 -114
  1048. package/dist/slash-commands.runtime-BK88kgds.js +0 -128
  1049. package/dist/slash-dispatch.runtime-COGywwJE.js +0 -141
  1050. package/dist/slash-skill-commands.runtime-Ti4brxgh.js +0 -116
  1051. package/dist/src-DUR6OQxI.js +0 -1701
  1052. package/dist/status-C6dgQY9a.js +0 -131
  1053. package/dist/status-CNK0Q7QH.js +0 -606
  1054. package/dist/status-DBcX0DSC.js +0 -43
  1055. package/dist/status-DKgFgbwv.js +0 -1599
  1056. package/dist/status-Wn5lhNAc.js +0 -126
  1057. package/dist/status-json-D2EkWqAl.js +0 -288
  1058. package/dist/status.link-channel-D3ULIdEa.js +0 -143
  1059. package/dist/status.scan.deps.runtime-BsjWTAm4.js +0 -126
  1060. package/dist/status.scan.runtime-D4HbzROD.js +0 -119
  1061. package/dist/status.summary-C3YxPrDK.js +0 -592
  1062. package/dist/status.summary.runtime-DAkXPSaK.js +0 -118
  1063. package/dist/status.update-B4NnN9P1.js +0 -77
  1064. package/dist/subagent-orphan-recovery-QiQEBv36.js +0 -307
  1065. package/dist/subagent-registry-runtime-BJatPQFK.js +0 -111
  1066. package/dist/subscription-BhZORXN9.js +0 -100
  1067. package/dist/subscription-QEUjQRMv.js +0 -33
  1068. package/dist/subscription-cli-HrULlAgc.js +0 -134
  1069. package/dist/synology-chat-DB76GWMN.js +0 -297
  1070. package/dist/system-cli-D8jDwWuL.js +0 -94
  1071. package/dist/telegram-BHiiqKkQ.js +0 -114
  1072. package/dist/text-chunking-Baonm9Lu.js +0 -84
  1073. package/dist/text-chunking-Y3dPBOuZ.d.ts +0 -79
  1074. package/dist/tlon-DLESxNgD.js +0 -433
  1075. package/dist/tui-C75zi2Cl.js +0 -3834
  1076. package/dist/tui-cli-DFwx5e6i.js +0 -137
  1077. package/dist/types-BBJ3Qz7j.d.ts +0 -45
  1078. package/dist/types-Ckufs_BY.d.ts +0 -22692
  1079. package/dist/types.base-Cw0-zIvE.d.ts +0 -188
  1080. package/dist/ui-B55NOIB6.js +0 -31
  1081. package/dist/update--ojavYQ4.js +0 -1036
  1082. package/dist/update-cli-Cvj5aWYM.js +0 -1503
  1083. package/dist/update-offset-store-upatuWwX.js +0 -112
  1084. package/dist/update-runner-DHkY_-76.js +0 -1496
  1085. package/dist/upsert-with-lock-C171GLaR.js +0 -33
  1086. package/dist/usage-N3bxnbmt.js +0 -115
  1087. package/dist/web-RdvT7gKa.js +0 -112
  1088. package/dist/web-shared-HSGD3yGt.d.ts +0 -45
  1089. package/dist/webhook-request-guards-CosLyl01.d.ts +0 -76
  1090. package/dist/webhook-targets-Bfnag-du.js +0 -181
  1091. package/dist/webhook-targets-Di17rt8e.d.ts +0 -106
  1092. package/dist/webhooks-cli-ZpnXrq7G.js +0 -350
  1093. package/dist/whatsapp-DNTAyZHt.js +0 -114
  1094. package/dist/whatsapp-actions-o1zKQzKZ.js +0 -167
  1095. package/dist/workspace-CpWi5wPr.js +0 -479
  1096. package/dist/workspace-Ii7aRS7c.js +0 -289
  1097. package/dist/workspace-dirs-x10McA9t.js +0 -2003
  1098. package/dist/zalo-BN3VCrRY.d.ts +0 -9
  1099. package/dist/zalo-zm_bYCKg.js +0 -415
  1100. package/dist/zalouser-CvVEUvc5.js +0 -30911
  1101. /package/dist/{account-id-B3YSn4hl.d.ts → account-id-B8ce6G_4.d.ts} +0 -0
  1102. /package/dist/{acpx-CnNv70m2.d.ts → acpx-Ci50I9T2.d.ts} +0 -0
  1103. /package/dist/{agent-media-payload-DE2pEcsz.d.ts → agent-media-payload-en-gS5p6.d.ts} +0 -0
  1104. /package/dist/{allow-from-DPpHnT2A.d.ts → allow-from-cMeQ47Ot.d.ts} +0 -0
  1105. /package/dist/{allowlist-resolution-CLFiZ6nE.d.ts → allowlist-resolution-DoAWbfXV.d.ts} +0 -0
  1106. /package/dist/{bluebubbles-Duhu-Jer.d.ts → bluebubbles-C6yYmUl0.d.ts} +0 -0
  1107. /package/dist/{boolean-param-BhFjB3gp.d.ts → boolean-param-CdO2TFTk.d.ts} +0 -0
  1108. /package/dist/{channel-config-schema-DnnVMdjR.d.ts → channel-config-schema-Chp38wel.d.ts} +0 -0
  1109. /package/dist/{channel-policy-Baq-Z06b.d.ts → channel-policy-g2h6AbYQ.d.ts} +0 -0
  1110. /package/dist/{chat-type-DpiBgwuG.d.ts → chat-type-BLt59pPT.d.ts} +0 -0
  1111. /package/dist/{command-format-vi4xq8e8.d.ts → command-format-BDJC05Jp.d.ts} +0 -0
  1112. /package/dist/{diffs-DK7fVSDo.d.ts → diffs-D_iNKCyn.d.ts} +0 -0
  1113. /package/dist/{directory-runtime-BTLPaysA.d.ts → directory-runtime-DhMex6HY.d.ts} +0 -0
  1114. /package/dist/{exec-C01wtBHu.d.ts → exec-pjfUY4KM.d.ts} +0 -0
  1115. /package/dist/{gaxios-fetch-compat-wZ38b3w3.js → gaxios-fetch-compat-B_vtINdV.js} +0 -0
  1116. /package/dist/{history-CwXuP2TW.d.ts → history-aqSS5VGQ.d.ts} +0 -0
  1117. /package/dist/{inbound-envelope-SggrBs9m.d.ts → inbound-envelope-C5hWuZod.d.ts} +0 -0
  1118. /package/dist/{index-apAZHsDo.d.ts → index-DXVQFYGX.d.ts} +0 -0
  1119. /package/dist/{json-store-r75IZGk9.d.ts → json-store-UnqQ5aV3.d.ts} +0 -0
  1120. /package/dist/{keyed-async-queue-DHIr7yNe.d.ts → keyed-async-queue-guucpLw3.d.ts} +0 -0
  1121. /package/dist/{links-HeQ3r_L0.d.ts → links-Bar0meEK.d.ts} +0 -0
  1122. /package/dist/{markdown-to-line-CDb4Jy3V.d.ts → markdown-to-line-D8uH_KOj.d.ts} +0 -0
  1123. /package/dist/{mattermost-DtCsxpgg.d.ts → mattermost-xl7jAFJL.d.ts} +0 -0
  1124. /package/dist/{net-BATPDwdQ.d.ts → net-rGOKGds6.d.ts} +0 -0
  1125. /package/dist/{nextcloud-talk-Bb2wHOwp.d.ts → nextcloud-talk-De2CZ9dV.d.ts} +0 -0
  1126. /package/dist/{oauth-utils-u567CLT0.d.ts → oauth-utils-DzN1AlEH.d.ts} +0 -0
  1127. /package/dist/{parse-finite-number-l3tNlrZh.d.ts → parse-finite-number-odgyqhi0.d.ts} +0 -0
  1128. /package/dist/{provider-usage.types-C6061OVN.d.ts → provider-usage.types-EDE9o-H_.d.ts} +0 -0
  1129. /package/dist/{reply-history-BDsFnZFl.d.ts → reply-history-CVuU31xe.d.ts} +0 -0
  1130. /package/dist/{reply-payload-CCvM4W9u.d.ts → reply-payload-CHkpBYwL.d.ts} +0 -0
  1131. /package/dist/{request-url-C54l4-xC.d.ts → request-url-DHisbiHY.d.ts} +0 -0
  1132. /package/dist/{run-command-D3RqWcHu.d.ts → run-command-y0Cndsb1.d.ts} +0 -0
  1133. /package/dist/{secret-input-schema-BLBt-NAP.d.ts → secret-input-schema-b1vpYDQN.d.ts} +0 -0
  1134. /package/dist/{session-key-BQ2-bR-9.d.ts → session-key-DTHQl57f.d.ts} +0 -0
  1135. /package/dist/{ssh-config-C4mcH9Ly.js → ssh-config-hEHBfU2_.js} +0 -0
  1136. /package/dist/{testing-DLkhGsoz.d.ts → testing-DszuZXgK.d.ts} +0 -0
  1137. /package/dist/{thinking-DRkjX18p.d.ts → thinking-IwXTGSeT.d.ts} +0 -0
  1138. /package/dist/{tool-send-CMMD1uDu.d.ts → tool-send-DWHRmKpz.d.ts} +0 -0
  1139. /package/dist/{vllm-defaults-CcGuf4hL.d.ts → vllm-defaults-CrxZgE6-.d.ts} +0 -0
  1140. /package/dist/{wait-Daog8bxM.d.ts → wait-wDWw_MTI.d.ts} +0 -0
  1141. /package/dist/{webhook-memory-guards-C5MrExwT.d.ts → webhook-memory-guards-DreORuJy.d.ts} +0 -0
  1142. /package/dist/{windows-spawn-j2l-dqu8.d.ts → windows-spawn-BIzH92x2.d.ts} +0 -0
  1143. /package/dist/{zod-schema.agent-runtime-krMrBnIn.d.ts → zod-schema.agent-runtime-CP2rmis3.d.ts} +0 -0
  1144. /package/dist/{zod-schema.core-BNDieZDZ.d.ts → zod-schema.core-Foi1tYwi.d.ts} +0 -0
@@ -1,2673 +0,0 @@
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-C17YnmA8.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-1kPLbBwI.js";
8
- import { O as DEFAULT_MODEL, g as resolveHooksGmailModel, i as getModelRefStatus, k as DEFAULT_PROVIDER, m as resolveConfiguredModelRef } from "./model-selection-hL8i1Jbs.js";
9
- import { a as resolveAgentDir, m as resolveDefaultAgentId, p as resolveAgentWorkspaceDir } from "./agent-scope-C-YmLnnb.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-D6PbhbZk.js";
13
- import { t as DEFAULT_AGENTS_FILENAME } from "./workspace-CpWi5wPr.js";
14
- import { f as readConfigFileSnapshot, y as writeConfigFile } from "./io-CMfWWPXQ.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-x10McA9t.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-4k2kpvoT.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-ByEzDJ1_.js";
27
- import { t as resolveMemorySearchConfig } from "./memory-search-Cv1SBrn7.js";
28
- import { r as resolveMemoryBackendConfig } from "./search-manager-C7J7B3_a.js";
29
- import { n as logConfigUpdated } from "./logging-CxP9suT8.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-CNv17ac9.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-BK0Hsb7Y.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-B3gAmIbW.js";
43
- import { r as healthCommand } from "./health-BEjzWwaB.js";
44
- import { i as resolveControlUiDistIndexPathForRoot, r as resolveControlUiDistIndexHealth } from "./control-ui-assets-CH3MYmAo.js";
45
- import { p as normalizeStoredCronJobs, t as runGatewayUpdate } from "./update-runner-DHkY_-76.js";
46
- import { t as collectChannelStatusIssues } from "./channels-status-issues-RDmzovJU.js";
47
- import { n as resolveProviderAuthLoginCommand, t as buildProviderAuthRecoveryHint } from "./provider-auth-guidance-CMjUWlNf.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-Bq2eP87s.js";
51
- import { a as runLegacyStateMigrations, i as detectLegacyStateMigrations, r as loadAndMaybeMigrateDoctorConfig } from "./doctor-config-flow-D8XRG9Ku.js";
52
- import { t as resolveDefaultChannelAccountContext } from "./channel-account-context-Ba3u5D21.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 };