@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
@@ -0,0 +1,2070 @@
1
+ import "./redact-fatrROh9.js";
2
+ import "./errors-DOJWZqNo.js";
3
+ import "./unhandled-rejections-CTvNvnT0.js";
4
+ import "./logger-BFfIIIKH.js";
5
+ import { _ as resolveStateDir } from "./paths-D6AgsMTU.js";
6
+ import "./tmp-moldclaw-dir-DWF-d8qD.js";
7
+ import { r as theme } from "./theme-BSXzMzAA.js";
8
+ import { t as danger } from "./globals-DESrFYmC.js";
9
+ import { n as defaultRuntime } from "./runtime-_tQz41uA.js";
10
+ import "./ansi-BPhP6LBZ.js";
11
+ import "./subsystem-CPmDTJ2P.js";
12
+ import "./boolean-B6zcAynR.js";
13
+ import "./env-D42cffog.js";
14
+ import "./warning-filter-B1UOeM0G.js";
15
+ import { g as resolveConfigDir, y as resolveUserPath } from "./utils-C7ykRPCQ.js";
16
+ import { t as formatDocsLink } from "./links-BcahUP5U.js";
17
+ import { y as resolveAuthStorePath } from "./setup-binary-CcAv8NXz.js";
18
+ import { Bd as hasConfiguredPlaintextSecretValue, DE as loadAuthProfileStoreForSecretsRuntime, Vd as isExpectedResolvedSecretValue, bx as isNonSecretApiKeyMarker, xx as isSecretRefHeaderValueMarker, yd as prepareSecretsRuntimeSnapshot, zd as assertExpectedResolvedSecretValue } from "./auth-profiles-smABVXzp.js";
19
+ import { w as normalizeProviderId } from "./model-selection-bBBxfXdb.js";
20
+ import { a as resolveAgentDir, i as resolveAgentConfig, m as resolveDefaultAgentId, r as listAgentIds } from "./agent-scope-lZlwP1At.js";
21
+ import { c as normalizeAgentId } from "./session-key-UoG7Kfw5.js";
22
+ import "./boundary-file-read-tPYh_8fH.js";
23
+ import "./logger-BGzLUitz.js";
24
+ import "./exec-CvEtXqTZ.js";
25
+ import "./workspace-DJ_S272u.js";
26
+ import { i as createConfigIO } from "./io-BaBxjB1v.js";
27
+ import "./host-env-security-DQ2i_W12.js";
28
+ import "./safe-text-Cnulee_z.js";
29
+ import "./version-T8nMYUnU.js";
30
+ import { d as resolveSecretInputRef, i as coerceSecretRef } from "./types.secrets-Ca-9L8vU.js";
31
+ import "./env-substitution-68cyvF5h.js";
32
+ import "./config-state-h5jUoHya.js";
33
+ import "./network-mode-BtWXzwYn.js";
34
+ import { t as isSafeExecutableValue } from "./exec-safety-Bpmt08lt.js";
35
+ import "./registry-C1pRrsQl.js";
36
+ import "./manifest-registry-CS_p1OBQ.js";
37
+ import "./ip-C4YAIpr4.js";
38
+ import { a as formatExecSecretRefIdValidationMessage, c as isValidSecretProviderAlias, l as resolveDefaultSecretProviderAlias, o as isValidExecSecretRefId, u as secretRefKey } from "./ref-contract-4C9nIZsw.js";
39
+ import { C as SecretProviderSchema } from "./zod-schema.core-DvwgNmpd.js";
40
+ import "./config-CwBv71QC.js";
41
+ import "./audit-fs-CMb-YUHX.js";
42
+ import { t as runTasksWithConcurrency } from "./run-with-concurrency-FCQhTT5R.js";
43
+ import { i as resolveSecretRefValues, r as resolveSecretRefValue, t as isProviderScopedSecretResolutionError } from "./resolve-PSlwZjg3.js";
44
+ import { a as parseDotPath, c as writeTextFileAtomic, n as isNonEmptyString, o as parseEnvValue, r as isRecord, s as toDotPath, t as describeUnknownError } from "./shared-dXUb11iF.js";
45
+ import "./provider-web-search-CcUC9ktE.js";
46
+ import "./text-runtime-Cfq-Uyx0.js";
47
+ import "./workspace-dirs-CGeIPpGN.js";
48
+ import "./config-BwkGZjD5.js";
49
+ import "./tailnet-fFTz5Twr.js";
50
+ import "./net-K181nxTH.js";
51
+ import "./credentials-D-5Pb-aZ.js";
52
+ import "./routes-CcJNnwTF.js";
53
+ import "./frontmatter-Cgg0ICvh.js";
54
+ import "./env-overrides-DBQl3LRc.js";
55
+ import "./path-alias-guards-BtSO7sk7.js";
56
+ import "./skills-DE_MXFSN.js";
57
+ import "./ports-Ca74cFb2.js";
58
+ import "./ports-lsof-CoiADo0p.js";
59
+ import "./ssh-tunnel-DsY-9yao.js";
60
+ import "./image-ops-Ck_D_vpe.js";
61
+ import "./fs-safe-CRXFoBmh.js";
62
+ import "./mime-DGFQe4XX.js";
63
+ import "./server-middleware-Djfoa1s0.js";
64
+ import "./message-channel-DFE4FuE_.js";
65
+ import "./resolve-route-DdX-HBVt.js";
66
+ import "./internal-hooks-83AcmxP3.js";
67
+ import "./lazy-runtime-BoGB4usD.js";
68
+ import "./config-schema-BNU4GQh_.js";
69
+ import "./method-scopes-B2ZKSsxQ.js";
70
+ import "./session-cost-usage-DWgQk6XT.js";
71
+ import "./paths-ApLcu1Uu.js";
72
+ import "./routing-DQ-fpTaA.js";
73
+ import "./send-B1pX9_Oc.js";
74
+ import "./node-resolve-BYC2FbO2.js";
75
+ import "./provider-stream-Chz_EFw3.js";
76
+ import "./identity-file-Diub2a0t.js";
77
+ import "./provider-models-xnyxy6mO.js";
78
+ import "./secret-file-p1IhQzwJ.js";
79
+ import "./logging-Dy7UYzIN.js";
80
+ import "./runtime-env-BlEtPF6b.js";
81
+ import { d as PROVIDER_ENV_VARS, p as listKnownSecretEnvVarNames } from "./registry-BFMbkmgR.js";
82
+ import "./provider-onboard-B9ionepI.js";
83
+ import "./model-definitions-Cyyzm6Kr.js";
84
+ import "./usage-Czgwvg0h.js";
85
+ import "./device-identity-IG5DngWM.js";
86
+ import "./auth-Ch3Rchm4.js";
87
+ import "./subscription-DaA1urx-.js";
88
+ import "./diagnostic-DTPopFvh.js";
89
+ import "./message-hook-mappers-CeiHXgSQ.js";
90
+ import "./json-store--7cBPxTG.js";
91
+ import "./call-gdDAt07d.js";
92
+ import "./multimodal-BJBBn_4F.js";
93
+ import "./memory-search-tTD5o_rU.js";
94
+ import "./query-expansion-D_Mm5Hhi.js";
95
+ import "./search-manager-BS5Db0A6.js";
96
+ import "./core-BwKq3krw.js";
97
+ import "./issue-format-B0SI57Es.js";
98
+ import "./logging-CdisccbY.js";
99
+ import "./note-dOl5kPAy.js";
100
+ import "./state-paths-DsMoTg25.js";
101
+ import "./config-value-DT3-5958.js";
102
+ import { _ as getPath, g as deletePathStrict, h as resolvePlanTargetAgainstRegistry, l as discoverAuthProfileSecretTargets, m as listAuthProfileSecretTargetEntries, p as isKnownSecretTargetType, u as discoverConfigSecretTargets, v as setPathCreateStrict } from "./command-secret-targets-BFF4x_RB.js";
103
+ import "./brave-w4Fo8WZ3.js";
104
+ import "./provider-usage-kxemdMp2.js";
105
+ import "./perplexity-CXwMDD3u.js";
106
+ import "./restart-stale-pids-CPF1_61W.js";
107
+ import "./delivery-queue-BOf5wYIc.js";
108
+ import "./pairing-token-bu1e6z6X.js";
109
+ import "./accounts-J2OhhhQi.js";
110
+ import "./process-runtime-D27SftX_.js";
111
+ import "./audit-CpfSjvyo.js";
112
+ import "./cli-runtime-DTCHPjCi.js";
113
+ import "./cli-utils-BCuSS4l6.js";
114
+ import "./help-format-BFzPm_8V.js";
115
+ import "./progress-Cwq59vgZ.js";
116
+ import "./gateway-runtime-CBm3CCoA.js";
117
+ import { n as callGatewayFromCli, t as addGatewayClientOptions } from "./gateway-rpc-C0Vk51W7.js";
118
+ import fs from "node:fs";
119
+ import path from "node:path";
120
+ import os from "node:os";
121
+ import { isDeepStrictEqual } from "node:util";
122
+ import { confirm, select, text } from "@clack/prompts";
123
+ //#region src/secrets/auth-profiles-scan.ts
124
+ function getAuthProfileFieldName(pathPattern) {
125
+ const segments = pathPattern.split(".").filter(Boolean);
126
+ return segments[segments.length - 1] ?? "";
127
+ }
128
+ const AUTH_PROFILE_FIELD_SPEC_BY_TYPE = (() => {
129
+ const defaults = {
130
+ api_key: {
131
+ valueField: "key",
132
+ refField: "keyRef"
133
+ },
134
+ token: {
135
+ valueField: "token",
136
+ refField: "tokenRef"
137
+ }
138
+ };
139
+ for (const target of listAuthProfileSecretTargetEntries()) {
140
+ if (!target.authProfileType) continue;
141
+ defaults[target.authProfileType] = {
142
+ valueField: getAuthProfileFieldName(target.pathPattern),
143
+ refField: target.refPathPattern !== void 0 ? getAuthProfileFieldName(target.refPathPattern) : defaults[target.authProfileType].refField
144
+ };
145
+ }
146
+ return defaults;
147
+ })();
148
+ function getAuthProfileFieldSpec(type) {
149
+ return AUTH_PROFILE_FIELD_SPEC_BY_TYPE[type];
150
+ }
151
+ function toSecretCredentialVisit(params) {
152
+ const spec = getAuthProfileFieldSpec(params.kind);
153
+ return {
154
+ kind: params.kind,
155
+ profileId: params.profileId,
156
+ provider: params.provider,
157
+ profile: params.profile,
158
+ valueField: spec.valueField,
159
+ refField: spec.refField,
160
+ value: params.profile[spec.valueField],
161
+ refValue: params.profile[spec.refField]
162
+ };
163
+ }
164
+ function* iterateAuthProfileCredentials(profiles) {
165
+ for (const [profileId, value] of Object.entries(profiles)) {
166
+ if (!isRecord(value) || !isNonEmptyString(value.provider)) continue;
167
+ const provider = String(value.provider);
168
+ if (value.type === "api_key" || value.type === "token") {
169
+ yield toSecretCredentialVisit({
170
+ kind: value.type,
171
+ profileId,
172
+ provider,
173
+ profile: value
174
+ });
175
+ continue;
176
+ }
177
+ if (value.type === "oauth") yield {
178
+ kind: "oauth",
179
+ profileId,
180
+ provider,
181
+ profile: value,
182
+ hasAccess: isNonEmptyString(value.access),
183
+ hasRefresh: isNonEmptyString(value.refresh)
184
+ };
185
+ }
186
+ }
187
+ //#endregion
188
+ //#region src/secrets/config-io.ts
189
+ const silentConfigIoLogger = {
190
+ error: () => {},
191
+ warn: () => {}
192
+ };
193
+ function createSecretsConfigIO(params) {
194
+ return createConfigIO({
195
+ env: params.env,
196
+ logger: silentConfigIoLogger
197
+ });
198
+ }
199
+ //#endregion
200
+ //#region src/secrets/plan.ts
201
+ const FORBIDDEN_PATH_SEGMENTS = new Set([
202
+ "__proto__",
203
+ "prototype",
204
+ "constructor"
205
+ ]);
206
+ function isObjectRecord(value) {
207
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
208
+ }
209
+ function isSecretProviderConfigShape(value) {
210
+ return SecretProviderSchema.safeParse(value).success;
211
+ }
212
+ function hasForbiddenPathSegment(segments) {
213
+ return segments.some((segment) => FORBIDDEN_PATH_SEGMENTS.has(segment));
214
+ }
215
+ function resolveValidatedPlanTarget(candidate) {
216
+ if (!isKnownSecretTargetType(candidate.type)) return null;
217
+ const path = typeof candidate.path === "string" ? candidate.path.trim() : "";
218
+ if (!path) return null;
219
+ const segments = Array.isArray(candidate.pathSegments) && candidate.pathSegments.length > 0 ? candidate.pathSegments.map((segment) => String(segment).trim()).filter(Boolean) : parseDotPath(path);
220
+ if (segments.length === 0 || hasForbiddenPathSegment(segments) || path !== toDotPath(segments)) return null;
221
+ return resolvePlanTargetAgainstRegistry({
222
+ type: candidate.type,
223
+ pathSegments: segments,
224
+ providerId: candidate.providerId,
225
+ accountId: candidate.accountId
226
+ });
227
+ }
228
+ function isSecretsApplyPlan(value) {
229
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
230
+ const typed = value;
231
+ if (typed.version !== 1 || typed.protocolVersion !== 1 || !Array.isArray(typed.targets)) return false;
232
+ for (const target of typed.targets) {
233
+ if (!target || typeof target !== "object") return false;
234
+ const candidate = target;
235
+ const ref = candidate.ref;
236
+ const resolved = resolveValidatedPlanTarget({
237
+ type: candidate.type,
238
+ path: candidate.path,
239
+ pathSegments: candidate.pathSegments,
240
+ agentId: candidate.agentId,
241
+ providerId: candidate.providerId,
242
+ accountId: candidate.accountId,
243
+ authProfileProvider: candidate.authProfileProvider
244
+ });
245
+ if (!isKnownSecretTargetType(candidate.type) || typeof candidate.path !== "string" || !candidate.path.trim() || candidate.pathSegments !== void 0 && !Array.isArray(candidate.pathSegments) || !resolved || !ref || typeof ref !== "object" || ref.source !== "env" && ref.source !== "file" && ref.source !== "exec" || typeof ref.provider !== "string" || ref.provider.trim().length === 0 || typeof ref.id !== "string" || ref.id.trim().length === 0 || ref.source === "exec" && !isValidExecSecretRefId(ref.id)) return false;
246
+ if (resolved.entry.configFile === "auth-profiles.json") {
247
+ if (typeof candidate.agentId !== "string" || candidate.agentId.trim().length === 0) return false;
248
+ if (candidate.authProfileProvider !== void 0 && (typeof candidate.authProfileProvider !== "string" || candidate.authProfileProvider.trim().length === 0)) return false;
249
+ }
250
+ }
251
+ if (typed.providerUpserts !== void 0) {
252
+ if (!isObjectRecord(typed.providerUpserts)) return false;
253
+ for (const [providerAlias, providerValue] of Object.entries(typed.providerUpserts)) {
254
+ if (!isValidSecretProviderAlias(providerAlias)) return false;
255
+ if (!isSecretProviderConfigShape(providerValue)) return false;
256
+ }
257
+ }
258
+ if (typed.providerDeletes !== void 0) {
259
+ if (!Array.isArray(typed.providerDeletes) || typed.providerDeletes.some((providerAlias) => typeof providerAlias !== "string" || !isValidSecretProviderAlias(providerAlias))) return false;
260
+ }
261
+ return true;
262
+ }
263
+ function normalizeSecretsPlanOptions(options) {
264
+ return {
265
+ scrubEnv: options?.scrubEnv ?? true,
266
+ scrubAuthProfilesForProviderTargets: options?.scrubAuthProfilesForProviderTargets ?? true,
267
+ scrubLegacyAuthJson: options?.scrubLegacyAuthJson ?? true
268
+ };
269
+ }
270
+ //#endregion
271
+ //#region src/secrets/auth-store-paths.ts
272
+ function listAuthProfileStorePaths$1(config, stateDir) {
273
+ const paths = /* @__PURE__ */ new Set();
274
+ paths.add(path.join(resolveUserPath(stateDir), "agents", "main", "agent", "auth-profiles.json"));
275
+ const agentsRoot = path.join(resolveUserPath(stateDir), "agents");
276
+ if (fs.existsSync(agentsRoot)) for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true })) {
277
+ if (!entry.isDirectory()) continue;
278
+ paths.add(path.join(agentsRoot, entry.name, "agent", "auth-profiles.json"));
279
+ }
280
+ for (const agentId of listAgentIds(config)) {
281
+ if (agentId === "main") {
282
+ paths.add(path.join(resolveUserPath(stateDir), "agents", "main", "agent", "auth-profiles.json"));
283
+ continue;
284
+ }
285
+ const agentDir = resolveAgentDir(config, agentId);
286
+ paths.add(resolveUserPath(resolveAuthStorePath(agentDir)));
287
+ }
288
+ return [...paths];
289
+ }
290
+ //#endregion
291
+ //#region src/secrets/storage-scan.ts
292
+ function parseEnvAssignmentValue(raw) {
293
+ return parseEnvValue(raw);
294
+ }
295
+ function listAuthProfileStorePaths(config, stateDir) {
296
+ return listAuthProfileStorePaths$1(config, stateDir);
297
+ }
298
+ function listLegacyAuthJsonPaths(stateDir) {
299
+ const out = [];
300
+ const agentsRoot = path.join(resolveUserPath(stateDir), "agents");
301
+ if (!fs.existsSync(agentsRoot)) return out;
302
+ for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true })) {
303
+ if (!entry.isDirectory()) continue;
304
+ const candidate = path.join(agentsRoot, entry.name, "agent", "auth.json");
305
+ if (fs.existsSync(candidate)) out.push(candidate);
306
+ }
307
+ return out;
308
+ }
309
+ function resolveActiveAgentDir(stateDir, env = process.env) {
310
+ const override = env.MOLDCLAW_AGENT_DIR?.trim() || env.PI_CODING_AGENT_DIR?.trim();
311
+ if (override) return resolveUserPath(override);
312
+ return path.join(resolveUserPath(stateDir), "agents", "main", "agent");
313
+ }
314
+ function listAgentModelsJsonPaths(config, stateDir, env = process.env) {
315
+ const resolvedStateDir = resolveUserPath(stateDir);
316
+ const paths = /* @__PURE__ */ new Set();
317
+ paths.add(path.join(resolvedStateDir, "agents", "main", "agent", "models.json"));
318
+ paths.add(path.join(resolveActiveAgentDir(stateDir, env), "models.json"));
319
+ const agentsRoot = path.join(resolvedStateDir, "agents");
320
+ if (fs.existsSync(agentsRoot)) for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true })) {
321
+ if (!entry.isDirectory()) continue;
322
+ paths.add(path.join(agentsRoot, entry.name, "agent", "models.json"));
323
+ }
324
+ for (const agentId of listAgentIds(config)) {
325
+ if (agentId === "main") {
326
+ paths.add(path.join(resolvedStateDir, "agents", "main", "agent", "models.json"));
327
+ continue;
328
+ }
329
+ const agentDir = resolveAgentDir(config, agentId);
330
+ paths.add(path.join(resolveUserPath(agentDir), "models.json"));
331
+ }
332
+ return [...paths];
333
+ }
334
+ function readJsonObjectIfExists(filePath, options = {}) {
335
+ if (!fs.existsSync(filePath)) return { value: null };
336
+ try {
337
+ const stats = fs.statSync(filePath);
338
+ if (options.requireRegularFile && !stats.isFile()) return {
339
+ value: null,
340
+ error: `Refusing to read non-regular file: ${filePath}`
341
+ };
342
+ if (typeof options.maxBytes === "number" && Number.isFinite(options.maxBytes) && options.maxBytes >= 0 && stats.size > options.maxBytes) return {
343
+ value: null,
344
+ error: `Refusing to read oversized JSON (${stats.size} bytes): ${filePath}`
345
+ };
346
+ const raw = fs.readFileSync(filePath, "utf8");
347
+ const parsed = JSON.parse(raw);
348
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return { value: null };
349
+ return { value: parsed };
350
+ } catch (err) {
351
+ return {
352
+ value: null,
353
+ error: err instanceof Error ? err.message : String(err)
354
+ };
355
+ }
356
+ }
357
+ //#endregion
358
+ //#region src/secrets/apply.ts
359
+ function resolveTarget(target) {
360
+ const resolved = resolveValidatedPlanTarget(target);
361
+ if (!resolved) throw new Error(`Invalid plan target path for ${target.type}: ${target.path}`);
362
+ return resolved;
363
+ }
364
+ function scrubEnvRaw(raw, migratedValues, allowedEnvKeys) {
365
+ if (migratedValues.size === 0 || allowedEnvKeys.size === 0) return {
366
+ nextRaw: raw,
367
+ removed: 0
368
+ };
369
+ const lines = raw.split(/\r?\n/);
370
+ const nextLines = [];
371
+ let removed = 0;
372
+ for (const line of lines) {
373
+ const match = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
374
+ if (!match) {
375
+ nextLines.push(line);
376
+ continue;
377
+ }
378
+ const envKey = match[1] ?? "";
379
+ if (!allowedEnvKeys.has(envKey)) {
380
+ nextLines.push(line);
381
+ continue;
382
+ }
383
+ const parsedValue = parseEnvAssignmentValue(match[2] ?? "");
384
+ if (migratedValues.has(parsedValue)) {
385
+ removed += 1;
386
+ continue;
387
+ }
388
+ nextLines.push(line);
389
+ }
390
+ const hadTrailingNewline = raw.endsWith("\n");
391
+ const joined = nextLines.join("\n");
392
+ return {
393
+ nextRaw: hadTrailingNewline || joined.length === 0 ? `${joined}${joined.endsWith("\n") ? "" : "\n"}` : joined,
394
+ removed
395
+ };
396
+ }
397
+ function applyProviderPlanMutations(params) {
398
+ const currentProviders = isRecord(params.config.secrets?.providers) ? structuredClone(params.config.secrets?.providers) : {};
399
+ let changed = false;
400
+ for (const providerAlias of params.deletes ?? []) {
401
+ if (!Object.prototype.hasOwnProperty.call(currentProviders, providerAlias)) continue;
402
+ delete currentProviders[providerAlias];
403
+ changed = true;
404
+ }
405
+ for (const [providerAlias, providerConfig] of Object.entries(params.upserts ?? {})) {
406
+ const previous = currentProviders[providerAlias];
407
+ if (isDeepStrictEqual(previous, providerConfig)) continue;
408
+ currentProviders[providerAlias] = structuredClone(providerConfig);
409
+ changed = true;
410
+ }
411
+ if (!changed) return false;
412
+ params.config.secrets ??= {};
413
+ if (Object.keys(currentProviders).length === 0) {
414
+ if ("providers" in params.config.secrets) delete params.config.secrets.providers;
415
+ return true;
416
+ }
417
+ params.config.secrets.providers = currentProviders;
418
+ return true;
419
+ }
420
+ async function projectPlanState(params) {
421
+ const { snapshot, writeOptions } = await createSecretsConfigIO({ env: params.env }).readConfigFileSnapshotForWrite();
422
+ if (!snapshot.valid) throw new Error("Cannot apply secrets plan: config is invalid.");
423
+ const options = normalizeSecretsPlanOptions(params.plan.options);
424
+ const nextConfig = structuredClone(snapshot.config);
425
+ const stateDir = resolveStateDir(params.env, os.homedir);
426
+ const changedFiles = /* @__PURE__ */ new Set();
427
+ const warnings = [];
428
+ const configPath = resolveUserPath(snapshot.path);
429
+ if (applyProviderPlanMutations({
430
+ config: nextConfig,
431
+ upserts: params.plan.providerUpserts,
432
+ deletes: params.plan.providerDeletes
433
+ })) changedFiles.add(configPath);
434
+ const targetMutations = applyConfigTargetMutations({
435
+ planTargets: params.plan.targets,
436
+ nextConfig,
437
+ stateDir,
438
+ authStoreByPath: /* @__PURE__ */ new Map(),
439
+ changedFiles
440
+ });
441
+ if (targetMutations.configChanged) changedFiles.add(configPath);
442
+ const authStoreByPath = scrubAuthStoresForProviderTargets({
443
+ nextConfig,
444
+ stateDir,
445
+ providerTargets: targetMutations.providerTargets,
446
+ scrubbedValues: targetMutations.scrubbedValues,
447
+ authStoreByPath: targetMutations.authStoreByPath,
448
+ changedFiles,
449
+ warnings,
450
+ enabled: options.scrubAuthProfilesForProviderTargets
451
+ });
452
+ const authJsonByPath = scrubLegacyAuthJsonStores({
453
+ stateDir,
454
+ changedFiles,
455
+ enabled: options.scrubLegacyAuthJson
456
+ });
457
+ const envRawByPath = scrubEnvFiles({
458
+ env: params.env,
459
+ scrubbedValues: targetMutations.scrubbedValues,
460
+ changedFiles,
461
+ enabled: options.scrubEnv
462
+ });
463
+ await validateProjectedSecretsState({
464
+ env: params.env,
465
+ nextConfig,
466
+ resolvedTargets: targetMutations.resolvedTargets,
467
+ authStoreByPath
468
+ });
469
+ return {
470
+ nextConfig,
471
+ configPath,
472
+ configWriteOptions: writeOptions,
473
+ authStoreByPath,
474
+ authJsonByPath,
475
+ envRawByPath,
476
+ changedFiles,
477
+ warnings
478
+ };
479
+ }
480
+ function applyConfigTargetMutations(params) {
481
+ const resolvedTargets = params.planTargets.map((target) => ({
482
+ target,
483
+ resolved: resolveTarget(target)
484
+ }));
485
+ const scrubbedValues = /* @__PURE__ */ new Set();
486
+ const providerTargets = /* @__PURE__ */ new Set();
487
+ let configChanged = false;
488
+ for (const { target, resolved } of resolvedTargets) {
489
+ if (resolved.entry.configFile === "auth-profiles.json") {
490
+ if (applyAuthProfileTargetMutation({
491
+ target,
492
+ resolved,
493
+ nextConfig: params.nextConfig,
494
+ stateDir: params.stateDir,
495
+ authStoreByPath: params.authStoreByPath,
496
+ scrubbedValues
497
+ })) {
498
+ const agentId = String(target.agentId ?? "").trim();
499
+ if (!agentId) throw new Error(`Missing required agentId for auth-profiles target ${target.path}.`);
500
+ params.changedFiles.add(resolveAuthStorePathForAgent({
501
+ nextConfig: params.nextConfig,
502
+ stateDir: params.stateDir,
503
+ agentId
504
+ }));
505
+ }
506
+ continue;
507
+ }
508
+ const targetPathSegments = resolved.pathSegments;
509
+ if (resolved.entry.secretShape === "sibling_ref") {
510
+ const previous = getPath(params.nextConfig, targetPathSegments);
511
+ if (isNonEmptyString(previous)) scrubbedValues.add(previous.trim());
512
+ const refPathSegments = resolved.refPathSegments;
513
+ if (!refPathSegments) throw new Error(`Missing sibling ref path for target ${target.type}.`);
514
+ const wroteRef = setPathCreateStrict(params.nextConfig, refPathSegments, target.ref);
515
+ const deletedLegacy = deletePathStrict(params.nextConfig, targetPathSegments);
516
+ if (wroteRef || deletedLegacy) configChanged = true;
517
+ continue;
518
+ }
519
+ const previous = getPath(params.nextConfig, targetPathSegments);
520
+ if (isNonEmptyString(previous)) scrubbedValues.add(previous.trim());
521
+ if (setPathCreateStrict(params.nextConfig, targetPathSegments, target.ref)) configChanged = true;
522
+ if (resolved.entry.trackProviderShadowing && resolved.providerId) providerTargets.add(normalizeProviderId(resolved.providerId));
523
+ }
524
+ return {
525
+ resolvedTargets,
526
+ scrubbedValues,
527
+ providerTargets,
528
+ configChanged,
529
+ authStoreByPath: params.authStoreByPath
530
+ };
531
+ }
532
+ function scrubAuthStoresForProviderTargets(params) {
533
+ if (!params.enabled || params.providerTargets.size === 0) return params.authStoreByPath;
534
+ for (const authStorePath of listAuthProfileStorePaths(params.nextConfig, params.stateDir)) {
535
+ const parsed = params.authStoreByPath.get(authStorePath) ?? readJsonObjectIfExists(authStorePath).value;
536
+ if (!parsed || !isRecord(parsed.profiles)) continue;
537
+ const nextStore = structuredClone(parsed);
538
+ let mutated = false;
539
+ for (const profile of iterateAuthProfileCredentials(nextStore.profiles)) {
540
+ const provider = normalizeProviderId(profile.provider);
541
+ if (!params.providerTargets.has(provider)) continue;
542
+ if (profile.kind === "api_key" || profile.kind === "token") {
543
+ if (isNonEmptyString(profile.value)) params.scrubbedValues.add(profile.value.trim());
544
+ if (profile.valueField in profile.profile) {
545
+ delete profile.profile[profile.valueField];
546
+ mutated = true;
547
+ }
548
+ if (profile.refField in profile.profile) {
549
+ delete profile.profile[profile.refField];
550
+ mutated = true;
551
+ }
552
+ continue;
553
+ }
554
+ if (profile.kind === "oauth" && (profile.hasAccess || profile.hasRefresh)) params.warnings.push(`Provider "${provider}" has OAuth credentials in ${authStorePath}; those still take precedence and are out of scope for static SecretRef migration.`);
555
+ }
556
+ if (mutated) {
557
+ params.authStoreByPath.set(authStorePath, nextStore);
558
+ params.changedFiles.add(authStorePath);
559
+ }
560
+ }
561
+ return params.authStoreByPath;
562
+ }
563
+ function ensureMutableAuthStore(store) {
564
+ const next = store ? structuredClone(store) : {};
565
+ if (!isRecord(next.profiles)) next.profiles = {};
566
+ if (typeof next.version !== "number" || !Number.isFinite(next.version)) next.version = 1;
567
+ return next;
568
+ }
569
+ function resolveAuthStoreForTarget(params) {
570
+ const agentId = String(params.target.agentId ?? "").trim();
571
+ if (!agentId) throw new Error(`Missing required agentId for auth-profiles target ${params.target.path}.`);
572
+ const authStorePath = resolveAuthStorePathForAgent({
573
+ nextConfig: params.nextConfig,
574
+ stateDir: params.stateDir,
575
+ agentId
576
+ });
577
+ const loaded = params.authStoreByPath.get(authStorePath) ?? readJsonObjectIfExists(authStorePath).value;
578
+ const store = ensureMutableAuthStore(isRecord(loaded) ? loaded : void 0);
579
+ params.authStoreByPath.set(authStorePath, store);
580
+ return {
581
+ path: authStorePath,
582
+ store
583
+ };
584
+ }
585
+ function asConfigPathRoot(store) {
586
+ return store;
587
+ }
588
+ function resolveAuthStorePathForAgent(params) {
589
+ const normalizedAgentId = normalizeAgentId(params.agentId);
590
+ const configuredAgentDir = resolveAgentConfig(params.nextConfig, normalizedAgentId)?.agentDir?.trim();
591
+ if (configuredAgentDir) return resolveUserPath(resolveAuthStorePath(configuredAgentDir));
592
+ return path.join(resolveUserPath(params.stateDir), "agents", normalizedAgentId, "agent", "auth-profiles.json");
593
+ }
594
+ function ensureAuthProfileContainer(params) {
595
+ let changed = false;
596
+ const profilePathSegments = params.resolved.pathSegments.slice(0, 2);
597
+ const profileId = profilePathSegments[1];
598
+ if (!profileId) throw new Error(`Invalid auth profile target path: ${params.target.path}`);
599
+ const current = getPath(params.store, profilePathSegments);
600
+ const expectedType = params.resolved.entry.authProfileType;
601
+ if (isRecord(current)) {
602
+ if (expectedType && typeof current.type === "string" && current.type !== expectedType) throw new Error(`Auth profile "${profileId}" type mismatch for ${params.target.path}: expected "${expectedType}", got "${current.type}".`);
603
+ if (!isNonEmptyString(current.provider) && isNonEmptyString(params.target.authProfileProvider)) {
604
+ const wroteProvider = setPathCreateStrict(asConfigPathRoot(params.store), [...profilePathSegments, "provider"], params.target.authProfileProvider);
605
+ changed = changed || wroteProvider;
606
+ }
607
+ return changed;
608
+ }
609
+ if (!expectedType) throw new Error(`Auth profile target ${params.target.path} is missing auth profile type metadata.`);
610
+ const provider = String(params.target.authProfileProvider ?? "").trim();
611
+ if (!provider) throw new Error(`Cannot create auth profile "${profileId}" for ${params.target.path} without authProfileProvider.`);
612
+ const wroteProfile = setPathCreateStrict(asConfigPathRoot(params.store), profilePathSegments, {
613
+ type: expectedType,
614
+ provider
615
+ });
616
+ changed = changed || wroteProfile;
617
+ return changed;
618
+ }
619
+ function applyAuthProfileTargetMutation(params) {
620
+ if (params.resolved.entry.configFile !== "auth-profiles.json") return false;
621
+ const { store } = resolveAuthStoreForTarget({
622
+ target: params.target,
623
+ nextConfig: params.nextConfig,
624
+ stateDir: params.stateDir,
625
+ authStoreByPath: params.authStoreByPath
626
+ });
627
+ let changed = ensureAuthProfileContainer({
628
+ target: params.target,
629
+ resolved: params.resolved,
630
+ store
631
+ });
632
+ const targetPathSegments = params.resolved.pathSegments;
633
+ if (params.resolved.entry.secretShape === "sibling_ref") {
634
+ const previous = getPath(store, targetPathSegments);
635
+ if (isNonEmptyString(previous)) params.scrubbedValues.add(previous.trim());
636
+ const refPathSegments = params.resolved.refPathSegments;
637
+ if (!refPathSegments) throw new Error(`Missing sibling ref path for auth-profiles target ${params.target.path}.`);
638
+ const wroteRef = setPathCreateStrict(asConfigPathRoot(store), refPathSegments, params.target.ref);
639
+ const deletedPlaintext = deletePathStrict(asConfigPathRoot(store), targetPathSegments);
640
+ changed = changed || wroteRef || deletedPlaintext;
641
+ return changed;
642
+ }
643
+ const previous = getPath(store, targetPathSegments);
644
+ if (isNonEmptyString(previous)) params.scrubbedValues.add(previous.trim());
645
+ const wroteRef = setPathCreateStrict(asConfigPathRoot(store), targetPathSegments, params.target.ref);
646
+ changed = changed || wroteRef;
647
+ return changed;
648
+ }
649
+ function scrubLegacyAuthJsonStores(params) {
650
+ const authJsonByPath = /* @__PURE__ */ new Map();
651
+ if (!params.enabled) return authJsonByPath;
652
+ for (const authJsonPath of listLegacyAuthJsonPaths(params.stateDir)) {
653
+ const parsed = readJsonObjectIfExists(authJsonPath).value;
654
+ if (!parsed) continue;
655
+ let mutated = false;
656
+ const nextParsed = structuredClone(parsed);
657
+ for (const [providerId, value] of Object.entries(nextParsed)) {
658
+ if (!isRecord(value)) continue;
659
+ if (value.type === "api_key" && isNonEmptyString(value.key)) {
660
+ delete nextParsed[providerId];
661
+ mutated = true;
662
+ }
663
+ }
664
+ if (mutated) {
665
+ authJsonByPath.set(authJsonPath, nextParsed);
666
+ params.changedFiles.add(authJsonPath);
667
+ }
668
+ }
669
+ return authJsonByPath;
670
+ }
671
+ function scrubEnvFiles(params) {
672
+ const envRawByPath = /* @__PURE__ */ new Map();
673
+ if (!params.enabled || params.scrubbedValues.size === 0) return envRawByPath;
674
+ const envPath = path.join(resolveConfigDir(params.env, os.homedir), ".env");
675
+ if (!fs.existsSync(envPath)) return envRawByPath;
676
+ const current = fs.readFileSync(envPath, "utf8");
677
+ const scrubbed = scrubEnvRaw(current, params.scrubbedValues, new Set(listKnownSecretEnvVarNames()));
678
+ if (scrubbed.removed > 0 && scrubbed.nextRaw !== current) {
679
+ envRawByPath.set(envPath, scrubbed.nextRaw);
680
+ params.changedFiles.add(envPath);
681
+ }
682
+ return envRawByPath;
683
+ }
684
+ async function validateProjectedSecretsState(params) {
685
+ const cache = {};
686
+ for (const { target, resolved: resolvedTarget } of params.resolvedTargets) assertExpectedResolvedSecretValue({
687
+ value: await resolveSecretRefValue(target.ref, {
688
+ config: params.nextConfig,
689
+ env: params.env,
690
+ cache
691
+ }),
692
+ expected: resolvedTarget.entry.expectedResolvedValue,
693
+ errorMessage: resolvedTarget.entry.expectedResolvedValue === "string" ? `Ref ${target.ref.source}:${target.ref.provider}:${target.ref.id} is not a non-empty string.` : `Ref ${target.ref.source}:${target.ref.provider}:${target.ref.id} is not string/object.`
694
+ });
695
+ const authStoreLookup = /* @__PURE__ */ new Map();
696
+ for (const [authStorePath, store] of params.authStoreByPath.entries()) authStoreLookup.set(resolveUserPath(authStorePath), store);
697
+ await prepareSecretsRuntimeSnapshot({
698
+ config: params.nextConfig,
699
+ env: params.env,
700
+ loadAuthStore: (agentDir) => {
701
+ const storePath = resolveUserPath(resolveAuthStorePath(agentDir));
702
+ const override = authStoreLookup.get(storePath);
703
+ if (override) return structuredClone(override);
704
+ return loadAuthProfileStoreForSecretsRuntime(agentDir);
705
+ }
706
+ });
707
+ }
708
+ function captureFileSnapshot(pathname) {
709
+ if (!fs.existsSync(pathname)) return {
710
+ existed: false,
711
+ content: "",
712
+ mode: 384
713
+ };
714
+ const stat = fs.statSync(pathname);
715
+ return {
716
+ existed: true,
717
+ content: fs.readFileSync(pathname, "utf8"),
718
+ mode: stat.mode & 511
719
+ };
720
+ }
721
+ function restoreFileSnapshot(pathname, snapshot) {
722
+ if (!snapshot.existed) {
723
+ if (fs.existsSync(pathname)) fs.rmSync(pathname, { force: true });
724
+ return;
725
+ }
726
+ writeTextFileAtomic(pathname, snapshot.content, snapshot.mode || 384);
727
+ }
728
+ function toJsonWrite(pathname, value) {
729
+ return {
730
+ path: pathname,
731
+ content: `${JSON.stringify(value, null, 2)}\n`,
732
+ mode: 384
733
+ };
734
+ }
735
+ async function runSecretsApply(params) {
736
+ const env = params.env ?? process.env;
737
+ const projected = await projectPlanState({
738
+ plan: params.plan,
739
+ env
740
+ });
741
+ const changedFiles = [...projected.changedFiles].toSorted();
742
+ if (!params.write) return {
743
+ mode: "dry-run",
744
+ changed: changedFiles.length > 0,
745
+ changedFiles,
746
+ warningCount: projected.warnings.length,
747
+ warnings: projected.warnings
748
+ };
749
+ if (changedFiles.length === 0) return {
750
+ mode: "write",
751
+ changed: false,
752
+ changedFiles: [],
753
+ warningCount: projected.warnings.length,
754
+ warnings: projected.warnings
755
+ };
756
+ const io = createSecretsConfigIO({ env });
757
+ const snapshots = /* @__PURE__ */ new Map();
758
+ const capture = (pathname) => {
759
+ if (!snapshots.has(pathname)) snapshots.set(pathname, captureFileSnapshot(pathname));
760
+ };
761
+ capture(projected.configPath);
762
+ const writes = [];
763
+ for (const [pathname, value] of projected.authStoreByPath.entries()) {
764
+ capture(pathname);
765
+ writes.push(toJsonWrite(pathname, value));
766
+ }
767
+ for (const [pathname, value] of projected.authJsonByPath.entries()) {
768
+ capture(pathname);
769
+ writes.push(toJsonWrite(pathname, value));
770
+ }
771
+ for (const [pathname, raw] of projected.envRawByPath.entries()) {
772
+ capture(pathname);
773
+ writes.push({
774
+ path: pathname,
775
+ content: raw,
776
+ mode: 384
777
+ });
778
+ }
779
+ try {
780
+ await io.writeConfigFile(projected.nextConfig, projected.configWriteOptions);
781
+ for (const write of writes) writeTextFileAtomic(write.path, write.content, write.mode);
782
+ } catch (err) {
783
+ for (const [pathname, snapshot] of snapshots.entries()) try {
784
+ restoreFileSnapshot(pathname, snapshot);
785
+ } catch {}
786
+ throw new Error(`Secrets apply failed: ${String(err)}`, { cause: err });
787
+ }
788
+ return {
789
+ mode: "write",
790
+ changed: changedFiles.length > 0,
791
+ changedFiles,
792
+ warningCount: projected.warnings.length,
793
+ warnings: projected.warnings
794
+ };
795
+ }
796
+ //#endregion
797
+ //#region src/secrets/audit.ts
798
+ const REF_RESOLVE_FALLBACK_CONCURRENCY = 8;
799
+ const MAX_AUDIT_MODELS_JSON_BYTES = 5 * 1024 * 1024;
800
+ const ALWAYS_SENSITIVE_MODEL_PROVIDER_HEADER_NAMES = new Set([
801
+ "authorization",
802
+ "proxy-authorization",
803
+ "x-api-key",
804
+ "api-key",
805
+ "apikey",
806
+ "x-auth-token",
807
+ "auth-token",
808
+ "x-access-token",
809
+ "access-token",
810
+ "x-secret-key",
811
+ "secret-key"
812
+ ]);
813
+ const SENSITIVE_MODEL_PROVIDER_HEADER_NAME_FRAGMENTS = [
814
+ "api-key",
815
+ "apikey",
816
+ "token",
817
+ "secret",
818
+ "password",
819
+ "credential"
820
+ ];
821
+ function isLikelySensitiveModelProviderHeaderName(value) {
822
+ const normalized = value.trim().toLowerCase();
823
+ if (!normalized) return false;
824
+ if (ALWAYS_SENSITIVE_MODEL_PROVIDER_HEADER_NAMES.has(normalized)) return true;
825
+ return SENSITIVE_MODEL_PROVIDER_HEADER_NAME_FRAGMENTS.some((fragment) => normalized.includes(fragment));
826
+ }
827
+ function addFinding(collector, finding) {
828
+ collector.findings.push(finding);
829
+ }
830
+ function collectProviderRefPath(collector, providerId, configPath) {
831
+ const key = normalizeProviderId(providerId);
832
+ const existing = collector.configProviderRefPaths.get(key);
833
+ if (existing) {
834
+ existing.push(configPath);
835
+ return;
836
+ }
837
+ collector.configProviderRefPaths.set(key, [configPath]);
838
+ }
839
+ function trackAuthProviderState(collector, provider, mode) {
840
+ const key = normalizeProviderId(provider);
841
+ const existing = collector.authProviderState.get(key);
842
+ if (existing) {
843
+ existing.hasUsableStaticOrOAuth = true;
844
+ existing.modes.add(mode);
845
+ return;
846
+ }
847
+ collector.authProviderState.set(key, {
848
+ hasUsableStaticOrOAuth: true,
849
+ modes: new Set([mode])
850
+ });
851
+ }
852
+ function collectEnvPlaintext(params) {
853
+ if (!fs.existsSync(params.envPath)) return;
854
+ params.collector.filesScanned.add(params.envPath);
855
+ const knownKeys = new Set(listKnownSecretEnvVarNames());
856
+ const lines = fs.readFileSync(params.envPath, "utf8").split(/\r?\n/);
857
+ for (const line of lines) {
858
+ const match = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
859
+ if (!match) continue;
860
+ const key = match[1] ?? "";
861
+ if (!knownKeys.has(key)) continue;
862
+ if (!parseEnvAssignmentValue(match[2] ?? "")) continue;
863
+ addFinding(params.collector, {
864
+ code: "PLAINTEXT_FOUND",
865
+ severity: "warn",
866
+ file: params.envPath,
867
+ jsonPath: `$env.${key}`,
868
+ message: `Potential secret found in .env (${key}).`
869
+ });
870
+ }
871
+ }
872
+ function collectConfigSecrets(params) {
873
+ const defaults = params.config.secrets?.defaults;
874
+ for (const target of discoverConfigSecretTargets(params.config)) {
875
+ if (!target.entry.includeInAudit) continue;
876
+ const { ref } = resolveSecretInputRef({
877
+ value: target.value,
878
+ refValue: target.refValue,
879
+ defaults
880
+ });
881
+ if (ref) {
882
+ params.collector.refAssignments.push({
883
+ file: params.configPath,
884
+ path: target.path,
885
+ ref,
886
+ expected: target.entry.expectedResolvedValue,
887
+ provider: target.providerId
888
+ });
889
+ if (target.entry.trackProviderShadowing && target.providerId) collectProviderRefPath(params.collector, target.providerId, target.path);
890
+ continue;
891
+ }
892
+ const hasPlaintext = hasConfiguredPlaintextSecretValue(target.value, target.entry.expectedResolvedValue);
893
+ if (target.entry.id === "models.providers.*.headers.*" && !isLikelySensitiveModelProviderHeaderName(target.pathSegments.at(-1) ?? "")) continue;
894
+ if (!hasPlaintext) continue;
895
+ addFinding(params.collector, {
896
+ code: "PLAINTEXT_FOUND",
897
+ severity: "warn",
898
+ file: params.configPath,
899
+ jsonPath: target.path,
900
+ message: `${target.path} is stored as plaintext.`,
901
+ provider: target.providerId
902
+ });
903
+ }
904
+ }
905
+ function collectAuthStoreSecrets(params) {
906
+ if (!fs.existsSync(params.authStorePath)) return;
907
+ params.collector.filesScanned.add(params.authStorePath);
908
+ const parsedResult = readJsonObjectIfExists(params.authStorePath);
909
+ if (parsedResult.error) {
910
+ addFinding(params.collector, {
911
+ code: "REF_UNRESOLVED",
912
+ severity: "error",
913
+ file: params.authStorePath,
914
+ jsonPath: "<root>",
915
+ message: `Invalid JSON in auth-profiles store: ${parsedResult.error}`
916
+ });
917
+ return;
918
+ }
919
+ const parsed = parsedResult.value;
920
+ if (!parsed || !isRecord(parsed.profiles)) return;
921
+ for (const entry of iterateAuthProfileCredentials(parsed.profiles)) {
922
+ if (entry.kind === "api_key" || entry.kind === "token") {
923
+ const { ref } = resolveSecretInputRef({
924
+ value: entry.value,
925
+ refValue: entry.refValue,
926
+ defaults: params.defaults
927
+ });
928
+ if (ref) {
929
+ params.collector.refAssignments.push({
930
+ file: params.authStorePath,
931
+ path: `profiles.${entry.profileId}.${entry.valueField}`,
932
+ ref,
933
+ expected: "string",
934
+ provider: entry.provider
935
+ });
936
+ trackAuthProviderState(params.collector, entry.provider, entry.kind);
937
+ }
938
+ if (isNonEmptyString(entry.value)) {
939
+ addFinding(params.collector, {
940
+ code: "PLAINTEXT_FOUND",
941
+ severity: "warn",
942
+ file: params.authStorePath,
943
+ jsonPath: `profiles.${entry.profileId}.${entry.valueField}`,
944
+ message: entry.kind === "api_key" ? "Auth profile API key is stored as plaintext." : "Auth profile token is stored as plaintext.",
945
+ provider: entry.provider,
946
+ profileId: entry.profileId
947
+ });
948
+ trackAuthProviderState(params.collector, entry.provider, entry.kind);
949
+ }
950
+ continue;
951
+ }
952
+ if (entry.hasAccess || entry.hasRefresh) {
953
+ addFinding(params.collector, {
954
+ code: "LEGACY_RESIDUE",
955
+ severity: "info",
956
+ file: params.authStorePath,
957
+ jsonPath: `profiles.${entry.profileId}`,
958
+ message: "OAuth credentials are present (out of scope for static SecretRef migration).",
959
+ provider: entry.provider,
960
+ profileId: entry.profileId
961
+ });
962
+ trackAuthProviderState(params.collector, entry.provider, "oauth");
963
+ }
964
+ }
965
+ }
966
+ function collectAuthJsonResidue(params) {
967
+ for (const authJsonPath of listLegacyAuthJsonPaths(params.stateDir)) {
968
+ params.collector.filesScanned.add(authJsonPath);
969
+ const parsedResult = readJsonObjectIfExists(authJsonPath);
970
+ if (parsedResult.error) {
971
+ addFinding(params.collector, {
972
+ code: "REF_UNRESOLVED",
973
+ severity: "error",
974
+ file: authJsonPath,
975
+ jsonPath: "<root>",
976
+ message: `Invalid JSON in legacy auth.json: ${parsedResult.error}`
977
+ });
978
+ continue;
979
+ }
980
+ const parsed = parsedResult.value;
981
+ if (!parsed) continue;
982
+ for (const [providerId, value] of Object.entries(parsed)) {
983
+ if (!isRecord(value)) continue;
984
+ if (value.type === "api_key" && isNonEmptyString(value.key)) addFinding(params.collector, {
985
+ code: "LEGACY_RESIDUE",
986
+ severity: "warn",
987
+ file: authJsonPath,
988
+ jsonPath: providerId,
989
+ message: "Legacy auth.json contains static api_key credentials.",
990
+ provider: providerId
991
+ });
992
+ }
993
+ }
994
+ }
995
+ function collectModelsJsonSecrets(params) {
996
+ if (!fs.existsSync(params.modelsJsonPath)) return;
997
+ params.collector.filesScanned.add(params.modelsJsonPath);
998
+ const parsedResult = readJsonObjectIfExists(params.modelsJsonPath, {
999
+ requireRegularFile: true,
1000
+ maxBytes: MAX_AUDIT_MODELS_JSON_BYTES
1001
+ });
1002
+ if (parsedResult.error) {
1003
+ addFinding(params.collector, {
1004
+ code: "REF_UNRESOLVED",
1005
+ severity: "error",
1006
+ file: params.modelsJsonPath,
1007
+ jsonPath: "<root>",
1008
+ message: `Invalid JSON in models.json: ${parsedResult.error}`
1009
+ });
1010
+ return;
1011
+ }
1012
+ const parsed = parsedResult.value;
1013
+ if (!parsed || !isRecord(parsed.providers)) return;
1014
+ for (const [providerId, providerValue] of Object.entries(parsed.providers)) {
1015
+ if (!isRecord(providerValue)) continue;
1016
+ const apiKey = providerValue.apiKey;
1017
+ if (coerceSecretRef(apiKey)) addFinding(params.collector, {
1018
+ code: "REF_UNRESOLVED",
1019
+ severity: "error",
1020
+ file: params.modelsJsonPath,
1021
+ jsonPath: `providers.${providerId}.apiKey`,
1022
+ message: "models.json contains an unresolved SecretRef object; regenerate models.json.",
1023
+ provider: providerId
1024
+ });
1025
+ else if (isNonEmptyString(apiKey) && !isNonSecretApiKeyMarker(apiKey)) addFinding(params.collector, {
1026
+ code: "PLAINTEXT_FOUND",
1027
+ severity: "warn",
1028
+ file: params.modelsJsonPath,
1029
+ jsonPath: `providers.${providerId}.apiKey`,
1030
+ message: "models.json provider apiKey is stored as plaintext.",
1031
+ provider: providerId
1032
+ });
1033
+ const headers = isRecord(providerValue.headers) ? providerValue.headers : void 0;
1034
+ if (!headers) continue;
1035
+ for (const [headerKey, headerValue] of Object.entries(headers)) {
1036
+ const headerPath = `providers.${providerId}.headers.${headerKey}`;
1037
+ if (coerceSecretRef(headerValue)) {
1038
+ addFinding(params.collector, {
1039
+ code: "REF_UNRESOLVED",
1040
+ severity: "error",
1041
+ file: params.modelsJsonPath,
1042
+ jsonPath: headerPath,
1043
+ message: "models.json contains an unresolved SecretRef object for provider headers; regenerate models.json.",
1044
+ provider: providerId
1045
+ });
1046
+ continue;
1047
+ }
1048
+ if (!isNonEmptyString(headerValue)) continue;
1049
+ if (isSecretRefHeaderValueMarker(headerValue)) continue;
1050
+ if (!isLikelySensitiveModelProviderHeaderName(headerKey)) continue;
1051
+ addFinding(params.collector, {
1052
+ code: "PLAINTEXT_FOUND",
1053
+ severity: "warn",
1054
+ file: params.modelsJsonPath,
1055
+ jsonPath: headerPath,
1056
+ message: "models.json provider header value is stored as plaintext.",
1057
+ provider: providerId
1058
+ });
1059
+ }
1060
+ }
1061
+ }
1062
+ async function collectUnresolvedRefFindings(params) {
1063
+ const cache = {};
1064
+ const refsByProvider = /* @__PURE__ */ new Map();
1065
+ for (const assignment of params.collector.refAssignments) {
1066
+ const providerKey = `${assignment.ref.source}:${assignment.ref.provider}`;
1067
+ let refsForProvider = refsByProvider.get(providerKey);
1068
+ if (!refsForProvider) {
1069
+ refsForProvider = /* @__PURE__ */ new Map();
1070
+ refsByProvider.set(providerKey, refsForProvider);
1071
+ }
1072
+ refsForProvider.set(secretRefKey(assignment.ref), assignment.ref);
1073
+ }
1074
+ const resolvedByRefKey = /* @__PURE__ */ new Map();
1075
+ const errorsByRefKey = /* @__PURE__ */ new Map();
1076
+ for (const refsForProvider of refsByProvider.values()) {
1077
+ const refs = [...refsForProvider.values()];
1078
+ const provider = refs[0]?.provider;
1079
+ try {
1080
+ const resolved = await resolveSecretRefValues(refs, {
1081
+ config: params.config,
1082
+ env: params.env,
1083
+ cache
1084
+ });
1085
+ for (const [key, value] of resolved.entries()) resolvedByRefKey.set(key, value);
1086
+ continue;
1087
+ } catch (err) {
1088
+ if (provider && isProviderScopedSecretResolutionError(err)) {
1089
+ for (const ref of refs) errorsByRefKey.set(secretRefKey(ref), err);
1090
+ continue;
1091
+ }
1092
+ }
1093
+ const fallback = await runTasksWithConcurrency({
1094
+ tasks: refs.map((ref) => async () => ({
1095
+ key: secretRefKey(ref),
1096
+ resolved: await resolveSecretRefValue(ref, {
1097
+ config: params.config,
1098
+ env: params.env,
1099
+ cache
1100
+ })
1101
+ })),
1102
+ limit: Math.min(REF_RESOLVE_FALLBACK_CONCURRENCY, refs.length),
1103
+ errorMode: "continue",
1104
+ onTaskError: (error, index) => {
1105
+ const ref = refs[index];
1106
+ if (!ref) return;
1107
+ errorsByRefKey.set(secretRefKey(ref), error);
1108
+ }
1109
+ });
1110
+ for (const result of fallback.results) {
1111
+ if (!result) continue;
1112
+ resolvedByRefKey.set(result.key, result.resolved);
1113
+ }
1114
+ }
1115
+ for (const assignment of params.collector.refAssignments) {
1116
+ const key = secretRefKey(assignment.ref);
1117
+ const resolveErr = errorsByRefKey.get(key);
1118
+ if (resolveErr) {
1119
+ addFinding(params.collector, {
1120
+ code: "REF_UNRESOLVED",
1121
+ severity: "error",
1122
+ file: assignment.file,
1123
+ jsonPath: assignment.path,
1124
+ message: `Failed to resolve ${assignment.ref.source}:${assignment.ref.provider}:${assignment.ref.id} (${describeUnknownError(resolveErr)}).`,
1125
+ provider: assignment.provider
1126
+ });
1127
+ continue;
1128
+ }
1129
+ if (!resolvedByRefKey.has(key)) {
1130
+ addFinding(params.collector, {
1131
+ code: "REF_UNRESOLVED",
1132
+ severity: "error",
1133
+ file: assignment.file,
1134
+ jsonPath: assignment.path,
1135
+ message: `Failed to resolve ${assignment.ref.source}:${assignment.ref.provider}:${assignment.ref.id} (resolved value is missing).`,
1136
+ provider: assignment.provider
1137
+ });
1138
+ continue;
1139
+ }
1140
+ if (!isExpectedResolvedSecretValue(resolvedByRefKey.get(key), assignment.expected)) addFinding(params.collector, {
1141
+ code: "REF_UNRESOLVED",
1142
+ severity: "error",
1143
+ file: assignment.file,
1144
+ jsonPath: assignment.path,
1145
+ message: assignment.expected === "string" ? `Failed to resolve ${assignment.ref.source}:${assignment.ref.provider}:${assignment.ref.id} (resolved value is not a non-empty string).` : `Failed to resolve ${assignment.ref.source}:${assignment.ref.provider}:${assignment.ref.id} (resolved value is not a string/object).`,
1146
+ provider: assignment.provider
1147
+ });
1148
+ }
1149
+ }
1150
+ function collectShadowingFindings(collector) {
1151
+ for (const [provider, paths] of collector.configProviderRefPaths.entries()) {
1152
+ const authState = collector.authProviderState.get(provider);
1153
+ if (!authState?.hasUsableStaticOrOAuth) continue;
1154
+ const modeText = [...authState.modes].join("/");
1155
+ for (const configPath of paths) addFinding(collector, {
1156
+ code: "REF_SHADOWED",
1157
+ severity: "warn",
1158
+ file: "moldclaw.json",
1159
+ jsonPath: configPath,
1160
+ message: `Auth profile credentials (${modeText}) take precedence for provider "${provider}", so this config ref may never be used.`,
1161
+ provider
1162
+ });
1163
+ }
1164
+ }
1165
+ function summarizeFindings(findings) {
1166
+ return {
1167
+ plaintextCount: findings.filter((entry) => entry.code === "PLAINTEXT_FOUND").length,
1168
+ unresolvedRefCount: findings.filter((entry) => entry.code === "REF_UNRESOLVED").length,
1169
+ shadowedRefCount: findings.filter((entry) => entry.code === "REF_SHADOWED").length,
1170
+ legacyResidueCount: findings.filter((entry) => entry.code === "LEGACY_RESIDUE").length
1171
+ };
1172
+ }
1173
+ async function runSecretsAudit(params = {}) {
1174
+ const env = params.env ?? process.env;
1175
+ const snapshot = await createSecretsConfigIO({ env }).readConfigFileSnapshot();
1176
+ const configPath = resolveUserPath(snapshot.path);
1177
+ const defaults = snapshot.valid ? snapshot.config.secrets?.defaults : void 0;
1178
+ const collector = {
1179
+ findings: [],
1180
+ refAssignments: [],
1181
+ configProviderRefPaths: /* @__PURE__ */ new Map(),
1182
+ authProviderState: /* @__PURE__ */ new Map(),
1183
+ filesScanned: new Set([configPath])
1184
+ };
1185
+ const stateDir = resolveStateDir(env, os.homedir);
1186
+ const envPath = path.join(resolveConfigDir(env, os.homedir), ".env");
1187
+ const config = snapshot.valid ? snapshot.config : {};
1188
+ if (snapshot.valid) {
1189
+ collectConfigSecrets({
1190
+ config,
1191
+ configPath,
1192
+ collector
1193
+ });
1194
+ for (const authStorePath of listAuthProfileStorePaths(config, stateDir)) collectAuthStoreSecrets({
1195
+ authStorePath,
1196
+ collector,
1197
+ defaults
1198
+ });
1199
+ for (const modelsJsonPath of listAgentModelsJsonPaths(config, stateDir, env)) collectModelsJsonSecrets({
1200
+ modelsJsonPath,
1201
+ collector
1202
+ });
1203
+ await collectUnresolvedRefFindings({
1204
+ collector,
1205
+ config,
1206
+ env
1207
+ });
1208
+ collectShadowingFindings(collector);
1209
+ } else addFinding(collector, {
1210
+ code: "REF_UNRESOLVED",
1211
+ severity: "error",
1212
+ file: configPath,
1213
+ jsonPath: "<root>",
1214
+ message: "Config is invalid; cannot validate secret references reliably."
1215
+ });
1216
+ collectEnvPlaintext({
1217
+ envPath,
1218
+ collector
1219
+ });
1220
+ collectAuthJsonResidue({
1221
+ stateDir,
1222
+ collector
1223
+ });
1224
+ const summary = summarizeFindings(collector.findings);
1225
+ return {
1226
+ version: 1,
1227
+ status: summary.unresolvedRefCount > 0 ? "unresolved" : collector.findings.length > 0 ? "findings" : "clean",
1228
+ filesScanned: [...collector.filesScanned].toSorted(),
1229
+ summary,
1230
+ findings: collector.findings
1231
+ };
1232
+ }
1233
+ function resolveSecretsAuditExitCode(report, check) {
1234
+ if (report.summary.unresolvedRefCount > 0) return 2;
1235
+ if (check && report.findings.length > 0) return 1;
1236
+ return 0;
1237
+ }
1238
+ //#endregion
1239
+ //#region src/secrets/configure-plan.ts
1240
+ function getSecretProviders$1(config) {
1241
+ if (!isRecord(config.secrets?.providers)) return {};
1242
+ return config.secrets.providers;
1243
+ }
1244
+ function configureCandidateSortKey(candidate) {
1245
+ if (candidate.configFile === "auth-profiles.json") return `auth-profiles:${candidate.agentId ?? ""}:${candidate.path}`;
1246
+ return `moldclaw:${candidate.path}`;
1247
+ }
1248
+ function resolveAuthProfileProvider(store, pathSegments) {
1249
+ const profileId = pathSegments[1];
1250
+ if (!profileId) return;
1251
+ const profile = store.profiles?.[profileId];
1252
+ if (!isRecord(profile) || typeof profile.provider !== "string") return;
1253
+ const provider = profile.provider.trim();
1254
+ return provider.length > 0 ? provider : void 0;
1255
+ }
1256
+ function buildConfigureCandidatesForScope(params) {
1257
+ const authoredConfig = params.authoredmoldClawConfig ?? params.config;
1258
+ const hasPathInAuthoredConfig = (pathSegments) => hasPath(authoredConfig, pathSegments);
1259
+ const moldclawCandidates = discoverConfigSecretTargets(params.config).filter((entry) => entry.entry.includeInConfigure).map((entry) => {
1260
+ const resolved = resolveSecretInputRef({
1261
+ value: entry.value,
1262
+ refValue: entry.refValue,
1263
+ defaults: params.config.secrets?.defaults
1264
+ });
1265
+ const pathExists = hasPathInAuthoredConfig(entry.pathSegments);
1266
+ const refPathExists = entry.refPathSegments ? hasPathInAuthoredConfig(entry.refPathSegments) : false;
1267
+ return {
1268
+ type: entry.entry.targetType,
1269
+ path: entry.path,
1270
+ pathSegments: [...entry.pathSegments],
1271
+ label: entry.path,
1272
+ configFile: "moldclaw.json",
1273
+ expectedResolvedValue: entry.entry.expectedResolvedValue,
1274
+ ...resolved.ref ? { existingRef: resolved.ref } : {},
1275
+ ...pathExists || refPathExists ? {} : { isDerived: true },
1276
+ ...entry.providerId ? { providerId: entry.providerId } : {},
1277
+ ...entry.accountId ? { accountId: entry.accountId } : {}
1278
+ };
1279
+ });
1280
+ const authCandidates = params.authProfiles === void 0 ? [] : discoverAuthProfileSecretTargets(params.authProfiles.store).filter((entry) => entry.entry.includeInConfigure).map((entry) => {
1281
+ const authProfiles = params.authProfiles;
1282
+ if (!authProfiles) throw new Error("Missing auth profile scope for configure candidate discovery.");
1283
+ const authProfileProvider = resolveAuthProfileProvider(authProfiles.store, entry.pathSegments);
1284
+ const resolved = resolveSecretInputRef({
1285
+ value: entry.value,
1286
+ refValue: entry.refValue,
1287
+ defaults: params.config.secrets?.defaults
1288
+ });
1289
+ return {
1290
+ type: entry.entry.targetType,
1291
+ path: entry.path,
1292
+ pathSegments: [...entry.pathSegments],
1293
+ label: `${entry.path} (auth profile, agent ${authProfiles.agentId})`,
1294
+ configFile: "auth-profiles.json",
1295
+ expectedResolvedValue: entry.entry.expectedResolvedValue,
1296
+ ...resolved.ref ? { existingRef: resolved.ref } : {},
1297
+ agentId: authProfiles.agentId,
1298
+ ...authProfileProvider ? { authProfileProvider } : {}
1299
+ };
1300
+ });
1301
+ return [...moldclawCandidates, ...authCandidates].toSorted((a, b) => configureCandidateSortKey(a).localeCompare(configureCandidateSortKey(b)));
1302
+ }
1303
+ function hasPath(root, segments) {
1304
+ if (segments.length === 0) return false;
1305
+ let cursor = root;
1306
+ for (let index = 0; index < segments.length; index += 1) {
1307
+ const segment = segments[index] ?? "";
1308
+ if (Array.isArray(cursor)) {
1309
+ if (!/^\d+$/.test(segment)) return false;
1310
+ const parsedIndex = Number.parseInt(segment, 10);
1311
+ if (!Number.isFinite(parsedIndex) || parsedIndex < 0 || parsedIndex >= cursor.length) return false;
1312
+ if (index === segments.length - 1) return true;
1313
+ cursor = cursor[parsedIndex];
1314
+ continue;
1315
+ }
1316
+ if (!isRecord(cursor)) return false;
1317
+ if (!Object.prototype.hasOwnProperty.call(cursor, segment)) return false;
1318
+ if (index === segments.length - 1) return true;
1319
+ cursor = cursor[segment];
1320
+ }
1321
+ return false;
1322
+ }
1323
+ function collectConfigureProviderChanges(params) {
1324
+ const originalProviders = getSecretProviders$1(params.original);
1325
+ const nextProviders = getSecretProviders$1(params.next);
1326
+ const upserts = {};
1327
+ const deletes = [];
1328
+ for (const [providerAlias, nextProviderConfig] of Object.entries(nextProviders)) {
1329
+ const current = originalProviders[providerAlias];
1330
+ if (isDeepStrictEqual(current, nextProviderConfig)) continue;
1331
+ upserts[providerAlias] = structuredClone(nextProviderConfig);
1332
+ }
1333
+ for (const providerAlias of Object.keys(originalProviders)) if (!Object.prototype.hasOwnProperty.call(nextProviders, providerAlias)) deletes.push(providerAlias);
1334
+ return {
1335
+ upserts,
1336
+ deletes: deletes.toSorted()
1337
+ };
1338
+ }
1339
+ function hasConfigurePlanChanges(params) {
1340
+ return params.selectedTargets.size > 0 || Object.keys(params.providerChanges.upserts).length > 0 || params.providerChanges.deletes.length > 0;
1341
+ }
1342
+ function buildSecretsConfigurePlan(params) {
1343
+ return {
1344
+ version: 1,
1345
+ protocolVersion: 1,
1346
+ generatedAt: params.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1347
+ generatedBy: "moldclaw secrets configure",
1348
+ targets: [...params.selectedTargets.values()].map((entry) => ({
1349
+ type: entry.type,
1350
+ path: entry.path,
1351
+ pathSegments: [...entry.pathSegments],
1352
+ ref: entry.ref,
1353
+ ...entry.agentId ? { agentId: entry.agentId } : {},
1354
+ ...entry.providerId ? { providerId: entry.providerId } : {},
1355
+ ...entry.accountId ? { accountId: entry.accountId } : {},
1356
+ ...entry.authProfileProvider ? { authProfileProvider: entry.authProfileProvider } : {}
1357
+ })),
1358
+ ...Object.keys(params.providerChanges.upserts).length > 0 ? { providerUpserts: params.providerChanges.upserts } : {},
1359
+ ...params.providerChanges.deletes.length > 0 ? { providerDeletes: params.providerChanges.deletes } : {},
1360
+ options: {
1361
+ scrubEnv: true,
1362
+ scrubAuthProfilesForProviderTargets: true,
1363
+ scrubLegacyAuthJson: true
1364
+ }
1365
+ };
1366
+ }
1367
+ //#endregion
1368
+ //#region src/secrets/configure.ts
1369
+ const ENV_NAME_PATTERN = /^[A-Z][A-Z0-9_]{0,127}$/;
1370
+ const WINDOWS_ABS_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
1371
+ const WINDOWS_UNC_PATH_PATTERN = /^\\\\[^\\]+\\[^\\]+/;
1372
+ function isAbsolutePathValue(value) {
1373
+ return path.isAbsolute(value) || WINDOWS_ABS_PATH_PATTERN.test(value) || WINDOWS_UNC_PATH_PATTERN.test(value);
1374
+ }
1375
+ function parseCsv(value) {
1376
+ return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
1377
+ }
1378
+ function parseOptionalPositiveInt(value, max) {
1379
+ const trimmed = value.trim();
1380
+ if (!trimmed) return;
1381
+ if (!/^\d+$/.test(trimmed)) return;
1382
+ const parsed = Number.parseInt(trimmed, 10);
1383
+ if (!Number.isFinite(parsed) || parsed <= 0 || parsed > max) return;
1384
+ return parsed;
1385
+ }
1386
+ function getSecretProviders(config) {
1387
+ if (!isRecord(config.secrets?.providers)) return {};
1388
+ return config.secrets.providers;
1389
+ }
1390
+ function setSecretProvider(config, providerAlias, providerConfig) {
1391
+ config.secrets ??= {};
1392
+ if (!isRecord(config.secrets.providers)) config.secrets.providers = {};
1393
+ config.secrets.providers[providerAlias] = providerConfig;
1394
+ }
1395
+ function removeSecretProvider(config, providerAlias) {
1396
+ if (!isRecord(config.secrets?.providers)) return false;
1397
+ const providers = config.secrets.providers;
1398
+ if (!Object.prototype.hasOwnProperty.call(providers, providerAlias)) return false;
1399
+ delete providers[providerAlias];
1400
+ if (Object.keys(providers).length === 0) delete config.secrets?.providers;
1401
+ if (isRecord(config.secrets?.defaults)) {
1402
+ const defaults = config.secrets.defaults;
1403
+ if (defaults?.env === providerAlias) delete defaults.env;
1404
+ if (defaults?.file === providerAlias) delete defaults.file;
1405
+ if (defaults?.exec === providerAlias) delete defaults.exec;
1406
+ if (defaults && defaults.env === void 0 && defaults.file === void 0 && defaults.exec === void 0) delete config.secrets?.defaults;
1407
+ }
1408
+ return true;
1409
+ }
1410
+ function providerHint(provider) {
1411
+ if (provider.source === "env") return provider.allowlist?.length ? `env (${provider.allowlist.length} allowlisted)` : "env";
1412
+ if (provider.source === "file") return `file (${provider.mode ?? "json"})`;
1413
+ return `exec (${provider.jsonOnly === false ? "json+text" : "json"})`;
1414
+ }
1415
+ function toSourceChoices(config) {
1416
+ const hasSource = (source) => Object.values(config.secrets?.providers ?? {}).some((provider) => provider?.source === source);
1417
+ const choices = [{
1418
+ value: "env",
1419
+ label: "env"
1420
+ }];
1421
+ if (hasSource("file")) choices.push({
1422
+ value: "file",
1423
+ label: "file"
1424
+ });
1425
+ if (hasSource("exec")) choices.push({
1426
+ value: "exec",
1427
+ label: "exec"
1428
+ });
1429
+ return choices;
1430
+ }
1431
+ function assertNoCancel(value, message) {
1432
+ if (typeof value === "symbol") throw new Error(message);
1433
+ return value;
1434
+ }
1435
+ const AUTH_PROFILE_ID_PATTERN = /^[A-Za-z0-9:_-]{1,128}$/;
1436
+ function validateEnvNameCsv(value) {
1437
+ const entries = parseCsv(value);
1438
+ for (const entry of entries) if (!ENV_NAME_PATTERN.test(entry)) return `Invalid env name: ${entry}`;
1439
+ }
1440
+ async function promptEnvNameCsv(params) {
1441
+ const raw = assertNoCancel(await text({
1442
+ message: params.message,
1443
+ initialValue: params.initialValue,
1444
+ validate: (value) => validateEnvNameCsv(String(value ?? ""))
1445
+ }), "Secrets configure cancelled.");
1446
+ return parseCsv(String(raw ?? ""));
1447
+ }
1448
+ async function promptOptionalPositiveInt(params) {
1449
+ const raw = assertNoCancel(await text({
1450
+ message: params.message,
1451
+ initialValue: params.initialValue === void 0 ? "" : String(params.initialValue),
1452
+ validate: (value) => {
1453
+ const trimmed = String(value ?? "").trim();
1454
+ if (!trimmed) return;
1455
+ if (parseOptionalPositiveInt(trimmed, params.max) === void 0) return `Must be an integer between 1 and ${params.max}`;
1456
+ }
1457
+ }), "Secrets configure cancelled.");
1458
+ return parseOptionalPositiveInt(String(raw ?? ""), params.max);
1459
+ }
1460
+ function configureCandidateKey(candidate) {
1461
+ if (candidate.configFile === "auth-profiles.json") return `auth-profiles:${String(candidate.agentId ?? "").trim()}:${candidate.path}`;
1462
+ return `moldclaw:${candidate.path}`;
1463
+ }
1464
+ function hasSourceChoice(sourceChoices, source) {
1465
+ return sourceChoices.some((entry) => entry.value === source);
1466
+ }
1467
+ function resolveCandidateProviderHint(candidate) {
1468
+ if (typeof candidate.authProfileProvider === "string" && candidate.authProfileProvider.trim()) return candidate.authProfileProvider.trim().toLowerCase();
1469
+ if (typeof candidate.providerId === "string" && candidate.providerId.trim()) return candidate.providerId.trim().toLowerCase();
1470
+ }
1471
+ function resolveSuggestedEnvSecretId(candidate) {
1472
+ const hintedProvider = resolveCandidateProviderHint(candidate);
1473
+ if (!hintedProvider) return;
1474
+ const envCandidates = PROVIDER_ENV_VARS[hintedProvider];
1475
+ if (!Array.isArray(envCandidates) || envCandidates.length === 0) return;
1476
+ return envCandidates[0];
1477
+ }
1478
+ function resolveConfigureAgentId(config, explicitAgentId) {
1479
+ const knownAgentIds = new Set(listAgentIds(config));
1480
+ if (!explicitAgentId) return resolveDefaultAgentId(config);
1481
+ const normalized = normalizeAgentId(explicitAgentId);
1482
+ if (knownAgentIds.has(normalized)) return normalized;
1483
+ const known = [...knownAgentIds].toSorted().join(", ");
1484
+ throw new Error(`Unknown agent id "${explicitAgentId}". Known agents: ${known || "none configured"}.`);
1485
+ }
1486
+ function normalizeAuthStoreForConfigure(raw, storePath) {
1487
+ if (!raw) return {
1488
+ version: 1,
1489
+ profiles: {}
1490
+ };
1491
+ if (!isRecord(raw.profiles)) throw new Error(`Cannot run interactive secrets configure because ${storePath} is invalid (missing "profiles" object).`);
1492
+ return {
1493
+ version: typeof raw.version === "number" && Number.isFinite(raw.version) ? raw.version : 1,
1494
+ profiles: raw.profiles,
1495
+ ...isRecord(raw.order) ? { order: raw.order } : {},
1496
+ ...isRecord(raw.lastGood) ? { lastGood: raw.lastGood } : {},
1497
+ ...isRecord(raw.usageStats) ? { usageStats: raw.usageStats } : {}
1498
+ };
1499
+ }
1500
+ function loadAuthProfileStoreForConfigure(params) {
1501
+ const storePath = resolveAuthStorePath(resolveAgentDir(params.config, params.agentId));
1502
+ const parsed = readJsonObjectIfExists(storePath);
1503
+ if (parsed.error) throw new Error(`Cannot run interactive secrets configure because ${storePath} could not be read: ${parsed.error}`);
1504
+ return normalizeAuthStoreForConfigure(parsed.value, storePath);
1505
+ }
1506
+ async function promptNewAuthProfileCandidate(agentId) {
1507
+ const profileId = assertNoCancel(await text({
1508
+ message: "Auth profile id",
1509
+ validate: (value) => {
1510
+ const trimmed = String(value ?? "").trim();
1511
+ if (!trimmed) return "Required";
1512
+ if (!AUTH_PROFILE_ID_PATTERN.test(trimmed)) return "Use letters/numbers/\":\"/\"_\"/\"-\" only.";
1513
+ }
1514
+ }), "Secrets configure cancelled.");
1515
+ const credentialType = assertNoCancel(await select({
1516
+ message: "Auth profile credential type",
1517
+ options: [{
1518
+ value: "api_key",
1519
+ label: "api_key (key/keyRef)"
1520
+ }, {
1521
+ value: "token",
1522
+ label: "token (token/tokenRef)"
1523
+ }]
1524
+ }), "Secrets configure cancelled.");
1525
+ const provider = assertNoCancel(await text({
1526
+ message: "Provider id",
1527
+ validate: (value) => String(value ?? "").trim().length > 0 ? void 0 : "Required"
1528
+ }), "Secrets configure cancelled.");
1529
+ const profileIdTrimmed = String(profileId).trim();
1530
+ const providerTrimmed = String(provider).trim();
1531
+ if (credentialType === "token") return {
1532
+ type: "auth-profiles.token.token",
1533
+ path: `profiles.${profileIdTrimmed}.token`,
1534
+ pathSegments: [
1535
+ "profiles",
1536
+ profileIdTrimmed,
1537
+ "token"
1538
+ ],
1539
+ label: `profiles.${profileIdTrimmed}.token (auth profile, agent ${agentId})`,
1540
+ configFile: "auth-profiles.json",
1541
+ agentId,
1542
+ authProfileProvider: providerTrimmed,
1543
+ expectedResolvedValue: "string"
1544
+ };
1545
+ return {
1546
+ type: "auth-profiles.api_key.key",
1547
+ path: `profiles.${profileIdTrimmed}.key`,
1548
+ pathSegments: [
1549
+ "profiles",
1550
+ profileIdTrimmed,
1551
+ "key"
1552
+ ],
1553
+ label: `profiles.${profileIdTrimmed}.key (auth profile, agent ${agentId})`,
1554
+ configFile: "auth-profiles.json",
1555
+ agentId,
1556
+ authProfileProvider: providerTrimmed,
1557
+ expectedResolvedValue: "string"
1558
+ };
1559
+ }
1560
+ async function promptProviderAlias(params) {
1561
+ const alias = assertNoCancel(await text({
1562
+ message: "Provider alias",
1563
+ initialValue: "default",
1564
+ validate: (value) => {
1565
+ const trimmed = String(value ?? "").trim();
1566
+ if (!trimmed) return "Required";
1567
+ if (!isValidSecretProviderAlias(trimmed)) return "Must match /^[a-z][a-z0-9_-]{0,63}$/";
1568
+ if (params.existingAliases.has(trimmed)) return "Alias already exists";
1569
+ }
1570
+ }), "Secrets configure cancelled.");
1571
+ return String(alias).trim();
1572
+ }
1573
+ async function promptProviderSource(initial) {
1574
+ return assertNoCancel(await select({
1575
+ message: "Provider source",
1576
+ options: [
1577
+ {
1578
+ value: "env",
1579
+ label: "env"
1580
+ },
1581
+ {
1582
+ value: "file",
1583
+ label: "file"
1584
+ },
1585
+ {
1586
+ value: "exec",
1587
+ label: "exec"
1588
+ }
1589
+ ],
1590
+ initialValue: initial
1591
+ }), "Secrets configure cancelled.");
1592
+ }
1593
+ async function promptEnvProvider(base) {
1594
+ const allowlist = await promptEnvNameCsv({
1595
+ message: "Env allowlist (comma-separated, blank for unrestricted)",
1596
+ initialValue: base?.allowlist?.join(",") ?? ""
1597
+ });
1598
+ return {
1599
+ source: "env",
1600
+ ...allowlist.length > 0 ? { allowlist } : {}
1601
+ };
1602
+ }
1603
+ async function promptFileProvider(base) {
1604
+ const filePath = assertNoCancel(await text({
1605
+ message: "File path (absolute)",
1606
+ initialValue: base?.path ?? "",
1607
+ validate: (value) => {
1608
+ const trimmed = String(value ?? "").trim();
1609
+ if (!trimmed) return "Required";
1610
+ if (!isAbsolutePathValue(trimmed)) return "Must be an absolute path";
1611
+ }
1612
+ }), "Secrets configure cancelled.");
1613
+ const mode = assertNoCancel(await select({
1614
+ message: "File mode",
1615
+ options: [{
1616
+ value: "json",
1617
+ label: "json"
1618
+ }, {
1619
+ value: "singleValue",
1620
+ label: "singleValue"
1621
+ }],
1622
+ initialValue: base?.mode ?? "json"
1623
+ }), "Secrets configure cancelled.");
1624
+ const timeoutMs = await promptOptionalPositiveInt({
1625
+ message: "Timeout ms (blank for default)",
1626
+ initialValue: base?.timeoutMs,
1627
+ max: 12e4
1628
+ });
1629
+ const maxBytes = await promptOptionalPositiveInt({
1630
+ message: "Max bytes (blank for default)",
1631
+ initialValue: base?.maxBytes,
1632
+ max: 20 * 1024 * 1024
1633
+ });
1634
+ return {
1635
+ source: "file",
1636
+ path: String(filePath).trim(),
1637
+ mode,
1638
+ ...timeoutMs ? { timeoutMs } : {},
1639
+ ...maxBytes ? { maxBytes } : {}
1640
+ };
1641
+ }
1642
+ async function parseArgsInput(rawValue) {
1643
+ const trimmed = rawValue.trim();
1644
+ if (!trimmed) return;
1645
+ const parsed = JSON.parse(trimmed);
1646
+ if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) throw new Error("args must be a JSON array of strings");
1647
+ return parsed;
1648
+ }
1649
+ async function promptExecProvider(base) {
1650
+ const command = assertNoCancel(await text({
1651
+ message: "Command path (absolute)",
1652
+ initialValue: base?.command ?? "",
1653
+ validate: (value) => {
1654
+ const trimmed = String(value ?? "").trim();
1655
+ if (!trimmed) return "Required";
1656
+ if (!isAbsolutePathValue(trimmed)) return "Must be an absolute path";
1657
+ if (!isSafeExecutableValue(trimmed)) return "Command value is not allowed";
1658
+ }
1659
+ }), "Secrets configure cancelled.");
1660
+ const argsRaw = assertNoCancel(await text({
1661
+ message: "Args JSON array (blank for none)",
1662
+ initialValue: JSON.stringify(base?.args ?? []),
1663
+ validate: (value) => {
1664
+ const trimmed = String(value ?? "").trim();
1665
+ if (!trimmed) return;
1666
+ try {
1667
+ const parsed = JSON.parse(trimmed);
1668
+ if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) return "Must be a JSON array of strings";
1669
+ return;
1670
+ } catch {
1671
+ return "Must be valid JSON";
1672
+ }
1673
+ }
1674
+ }), "Secrets configure cancelled.");
1675
+ const timeoutMs = await promptOptionalPositiveInt({
1676
+ message: "Timeout ms (blank for default)",
1677
+ initialValue: base?.timeoutMs,
1678
+ max: 12e4
1679
+ });
1680
+ const noOutputTimeoutMs = await promptOptionalPositiveInt({
1681
+ message: "No-output timeout ms (blank for default)",
1682
+ initialValue: base?.noOutputTimeoutMs,
1683
+ max: 12e4
1684
+ });
1685
+ const maxOutputBytes = await promptOptionalPositiveInt({
1686
+ message: "Max output bytes (blank for default)",
1687
+ initialValue: base?.maxOutputBytes,
1688
+ max: 20 * 1024 * 1024
1689
+ });
1690
+ const jsonOnly = assertNoCancel(await confirm({
1691
+ message: "Require JSON-only response?",
1692
+ initialValue: base?.jsonOnly ?? true
1693
+ }), "Secrets configure cancelled.");
1694
+ const passEnv = await promptEnvNameCsv({
1695
+ message: "Pass-through env vars (comma-separated, blank for none)",
1696
+ initialValue: base?.passEnv?.join(",") ?? ""
1697
+ });
1698
+ const trustedDirsRaw = assertNoCancel(await text({
1699
+ message: "Trusted dirs (comma-separated absolute paths, blank for none)",
1700
+ initialValue: base?.trustedDirs?.join(",") ?? "",
1701
+ validate: (value) => {
1702
+ const entries = parseCsv(String(value ?? ""));
1703
+ for (const entry of entries) if (!isAbsolutePathValue(entry)) return `Trusted dir must be absolute: ${entry}`;
1704
+ }
1705
+ }), "Secrets configure cancelled.");
1706
+ const allowInsecurePath = assertNoCancel(await confirm({
1707
+ message: "Allow insecure command path checks?",
1708
+ initialValue: base?.allowInsecurePath ?? false
1709
+ }), "Secrets configure cancelled.");
1710
+ const allowSymlinkCommand = assertNoCancel(await confirm({
1711
+ message: "Allow symlink command path?",
1712
+ initialValue: base?.allowSymlinkCommand ?? false
1713
+ }), "Secrets configure cancelled.");
1714
+ const args = await parseArgsInput(String(argsRaw ?? ""));
1715
+ const trustedDirs = parseCsv(String(trustedDirsRaw ?? ""));
1716
+ return {
1717
+ source: "exec",
1718
+ command: String(command).trim(),
1719
+ ...args && args.length > 0 ? { args } : {},
1720
+ ...timeoutMs ? { timeoutMs } : {},
1721
+ ...noOutputTimeoutMs ? { noOutputTimeoutMs } : {},
1722
+ ...maxOutputBytes ? { maxOutputBytes } : {},
1723
+ ...jsonOnly ? { jsonOnly } : { jsonOnly: false },
1724
+ ...passEnv.length > 0 ? { passEnv } : {},
1725
+ ...trustedDirs.length > 0 ? { trustedDirs } : {},
1726
+ ...allowInsecurePath ? { allowInsecurePath: true } : {},
1727
+ ...allowSymlinkCommand ? { allowSymlinkCommand: true } : {},
1728
+ ...isRecord(base?.env) ? { env: base.env } : {}
1729
+ };
1730
+ }
1731
+ async function promptProviderConfig(source, current) {
1732
+ if (source === "env") return await promptEnvProvider(current?.source === "env" ? current : void 0);
1733
+ if (source === "file") return await promptFileProvider(current?.source === "file" ? current : void 0);
1734
+ return await promptExecProvider(current?.source === "exec" ? current : void 0);
1735
+ }
1736
+ async function configureProvidersInteractive(config) {
1737
+ while (true) {
1738
+ const providers = getSecretProviders(config);
1739
+ const providerEntries = Object.entries(providers).toSorted(([left], [right]) => left.localeCompare(right));
1740
+ const actionOptions = [{
1741
+ value: "add",
1742
+ label: "Add provider",
1743
+ hint: "Define a new env/file/exec provider"
1744
+ }];
1745
+ if (providerEntries.length > 0) {
1746
+ actionOptions.push({
1747
+ value: "edit",
1748
+ label: "Edit provider",
1749
+ hint: "Update an existing provider"
1750
+ });
1751
+ actionOptions.push({
1752
+ value: "remove",
1753
+ label: "Remove provider",
1754
+ hint: "Delete a provider alias"
1755
+ });
1756
+ }
1757
+ actionOptions.push({
1758
+ value: "continue",
1759
+ label: "Continue",
1760
+ hint: "Move to credential mapping"
1761
+ });
1762
+ const action = assertNoCancel(await select({
1763
+ message: providerEntries.length > 0 ? "Configure secret providers" : "Configure secret providers (only env refs are available until file/exec providers are added)",
1764
+ options: actionOptions
1765
+ }), "Secrets configure cancelled.");
1766
+ if (action === "continue") return;
1767
+ if (action === "add") {
1768
+ const source = await promptProviderSource();
1769
+ setSecretProvider(config, await promptProviderAlias({ existingAliases: new Set(providerEntries.map(([providerAlias]) => providerAlias)) }), await promptProviderConfig(source));
1770
+ continue;
1771
+ }
1772
+ if (action === "edit") {
1773
+ const alias = assertNoCancel(await select({
1774
+ message: "Select provider to edit",
1775
+ options: providerEntries.map(([providerAlias, providerConfig]) => ({
1776
+ value: providerAlias,
1777
+ label: providerAlias,
1778
+ hint: providerHint(providerConfig)
1779
+ }))
1780
+ }), "Secrets configure cancelled.");
1781
+ const current = providers[alias];
1782
+ if (!current) continue;
1783
+ const nextProviderConfig = await promptProviderConfig(await promptProviderSource(current.source), current);
1784
+ if (!isDeepStrictEqual(current, nextProviderConfig)) setSecretProvider(config, alias, nextProviderConfig);
1785
+ continue;
1786
+ }
1787
+ if (action === "remove") {
1788
+ const alias = assertNoCancel(await select({
1789
+ message: "Select provider to remove",
1790
+ options: providerEntries.map(([providerAlias, providerConfig]) => ({
1791
+ value: providerAlias,
1792
+ label: providerAlias,
1793
+ hint: providerHint(providerConfig)
1794
+ }))
1795
+ }), "Secrets configure cancelled.");
1796
+ if (assertNoCancel(await confirm({
1797
+ message: `Remove provider "${alias}"?`,
1798
+ initialValue: false
1799
+ }), "Secrets configure cancelled.")) removeSecretProvider(config, alias);
1800
+ }
1801
+ }
1802
+ }
1803
+ async function runSecretsConfigureInteractive(params = {}) {
1804
+ if (!process.stdin.isTTY) throw new Error("secrets configure requires an interactive TTY.");
1805
+ if (params.providersOnly && params.skipProviderSetup) throw new Error("Cannot combine --providers-only with --skip-provider-setup.");
1806
+ const env = params.env ?? process.env;
1807
+ const { snapshot } = await createSecretsConfigIO({ env }).readConfigFileSnapshotForWrite();
1808
+ if (!snapshot.valid) throw new Error("Cannot run interactive secrets configure because config is invalid.");
1809
+ const stagedConfig = structuredClone(snapshot.config);
1810
+ if (!params.skipProviderSetup) await configureProvidersInteractive(stagedConfig);
1811
+ const providerChanges = collectConfigureProviderChanges({
1812
+ original: snapshot.config,
1813
+ next: stagedConfig
1814
+ });
1815
+ const selectedByPath = /* @__PURE__ */ new Map();
1816
+ if (!params.providersOnly) {
1817
+ const configureAgentId = resolveConfigureAgentId(snapshot.config, params.agentId);
1818
+ const authStore = loadAuthProfileStoreForConfigure({
1819
+ config: snapshot.config,
1820
+ agentId: configureAgentId
1821
+ });
1822
+ const candidates = buildConfigureCandidatesForScope({
1823
+ config: stagedConfig,
1824
+ authoredmoldClawConfig: snapshot.resolved,
1825
+ authProfiles: {
1826
+ agentId: configureAgentId,
1827
+ store: authStore
1828
+ }
1829
+ });
1830
+ if (candidates.length === 0) throw new Error("No configurable secret-bearing fields found for this agent scope.");
1831
+ const sourceChoices = toSourceChoices(stagedConfig);
1832
+ const hasDerivedCandidates = candidates.some((candidate) => candidate.isDerived === true);
1833
+ let showDerivedCandidates = false;
1834
+ while (true) {
1835
+ const visibleCandidates = showDerivedCandidates ? candidates : candidates.filter((candidate) => candidate.isDerived !== true);
1836
+ const options = visibleCandidates.map((candidate) => ({
1837
+ value: configureCandidateKey(candidate),
1838
+ label: candidate.label,
1839
+ hint: [candidate.configFile === "auth-profiles.json" ? "auth-profiles.json" : "moldclaw.json", candidate.isDerived === true ? "derived" : void 0].filter(Boolean).join(" | ")
1840
+ }));
1841
+ options.push({
1842
+ value: "__create_auth_profile__",
1843
+ label: "Create auth profile mapping",
1844
+ hint: `Add a new auth-profiles target for agent ${configureAgentId}`
1845
+ });
1846
+ if (hasDerivedCandidates) options.push({
1847
+ value: "__toggle_derived__",
1848
+ label: showDerivedCandidates ? "Hide derived targets" : "Show derived targets",
1849
+ hint: showDerivedCandidates ? "Show only fields authored directly in config" : "Include normalized/derived aliases"
1850
+ });
1851
+ if (selectedByPath.size > 0) options.unshift({
1852
+ value: "__done__",
1853
+ label: "Done",
1854
+ hint: "Finish and run preflight"
1855
+ });
1856
+ const selectedPath = assertNoCancel(await select({
1857
+ message: "Select credential field",
1858
+ options
1859
+ }), "Secrets configure cancelled.");
1860
+ if (selectedPath === "__done__") break;
1861
+ if (selectedPath === "__create_auth_profile__") {
1862
+ const createdCandidate = await promptNewAuthProfileCandidate(configureAgentId);
1863
+ const key = configureCandidateKey(createdCandidate);
1864
+ const existingIndex = candidates.findIndex((entry) => configureCandidateKey(entry) === key);
1865
+ if (existingIndex >= 0) candidates[existingIndex] = createdCandidate;
1866
+ else candidates.push(createdCandidate);
1867
+ continue;
1868
+ }
1869
+ if (selectedPath === "__toggle_derived__") {
1870
+ showDerivedCandidates = !showDerivedCandidates;
1871
+ continue;
1872
+ }
1873
+ const candidate = visibleCandidates.find((entry) => configureCandidateKey(entry) === selectedPath);
1874
+ if (!candidate) throw new Error(`Unknown configure target: ${selectedPath}`);
1875
+ const candidateKey = configureCandidateKey(candidate);
1876
+ const existingRef = selectedByPath.get(candidateKey)?.ref ?? candidate.existingRef;
1877
+ const source = assertNoCancel(await select({
1878
+ message: "Secret source",
1879
+ options: sourceChoices,
1880
+ initialValue: existingRef && hasSourceChoice(sourceChoices, existingRef.source) ? existingRef.source : void 0
1881
+ }), "Secrets configure cancelled.");
1882
+ const defaultAlias = resolveDefaultSecretProviderAlias(stagedConfig, source, { preferFirstProviderForSource: true });
1883
+ const provider = assertNoCancel(await text({
1884
+ message: "Provider alias",
1885
+ initialValue: existingRef?.source === source ? existingRef.provider : defaultAlias,
1886
+ validate: (value) => {
1887
+ const trimmed = String(value ?? "").trim();
1888
+ if (!trimmed) return "Required";
1889
+ if (!isValidSecretProviderAlias(trimmed)) return "Must match /^[a-z][a-z0-9_-]{0,63}$/";
1890
+ }
1891
+ }), "Secrets configure cancelled.");
1892
+ const providerAlias = String(provider).trim();
1893
+ let suggestedId = existingRef?.source === source ? existingRef.id : void 0;
1894
+ if (!suggestedId && source === "env") suggestedId = resolveSuggestedEnvSecretId(candidate);
1895
+ if (!suggestedId && source === "file") {
1896
+ const configuredProvider = stagedConfig.secrets?.providers?.[providerAlias];
1897
+ if (configuredProvider?.source === "file" && configuredProvider.mode === "singleValue") suggestedId = "value";
1898
+ }
1899
+ const id = assertNoCancel(await text({
1900
+ message: "Secret id",
1901
+ initialValue: suggestedId,
1902
+ validate: (value) => {
1903
+ const trimmed = String(value ?? "").trim();
1904
+ if (!trimmed) return "Required";
1905
+ if (source === "exec" && !isValidExecSecretRefId(trimmed)) return formatExecSecretRefIdValidationMessage();
1906
+ }
1907
+ }), "Secrets configure cancelled.");
1908
+ const ref = {
1909
+ source,
1910
+ provider: providerAlias,
1911
+ id: String(id).trim()
1912
+ };
1913
+ assertExpectedResolvedSecretValue({
1914
+ value: await resolveSecretRefValue(ref, {
1915
+ config: stagedConfig,
1916
+ env
1917
+ }),
1918
+ expected: candidate.expectedResolvedValue,
1919
+ errorMessage: candidate.expectedResolvedValue === "string" ? `Ref ${ref.source}:${ref.provider}:${ref.id} did not resolve to a non-empty string.` : `Ref ${ref.source}:${ref.provider}:${ref.id} did not resolve to a supported value type.`
1920
+ });
1921
+ const next = {
1922
+ ...candidate,
1923
+ ref
1924
+ };
1925
+ selectedByPath.set(candidateKey, next);
1926
+ if (!assertNoCancel(await confirm({
1927
+ message: "Configure another credential?",
1928
+ initialValue: true
1929
+ }), "Secrets configure cancelled.")) break;
1930
+ }
1931
+ }
1932
+ if (!hasConfigurePlanChanges({
1933
+ selectedTargets: selectedByPath,
1934
+ providerChanges
1935
+ })) throw new Error("No secrets changes were selected.");
1936
+ const plan = buildSecretsConfigurePlan({
1937
+ selectedTargets: selectedByPath,
1938
+ providerChanges
1939
+ });
1940
+ return {
1941
+ plan,
1942
+ preflight: await runSecretsApply({
1943
+ plan,
1944
+ env,
1945
+ write: false
1946
+ })
1947
+ };
1948
+ }
1949
+ //#endregion
1950
+ //#region src/cli/secrets-cli.ts
1951
+ function readPlanFile(pathname) {
1952
+ const raw = fs.readFileSync(pathname, "utf8");
1953
+ const parsed = JSON.parse(raw);
1954
+ if (!isSecretsApplyPlan(parsed)) throw new Error(`Invalid secrets plan file: ${pathname}`);
1955
+ return parsed;
1956
+ }
1957
+ function registerSecretsCli(program) {
1958
+ const secrets = program.command("secrets").description("Secrets runtime controls").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/gateway/security", "docs.moldclaw.ai/gateway/security")}\n`);
1959
+ addGatewayClientOptions(secrets.command("reload").description("Re-resolve secret references and atomically swap runtime snapshot").option("--json", "Output JSON", false)).action(async (opts) => {
1960
+ try {
1961
+ const result = await callGatewayFromCli("secrets.reload", opts, void 0, { expectFinal: false });
1962
+ if (opts.json) {
1963
+ defaultRuntime.log(JSON.stringify(result, null, 2));
1964
+ return;
1965
+ }
1966
+ const warningCount = Number(result?.warningCount ?? 0);
1967
+ if (Number.isFinite(warningCount) && warningCount > 0) {
1968
+ defaultRuntime.log(`Secrets reloaded with ${warningCount} warning(s).`);
1969
+ return;
1970
+ }
1971
+ defaultRuntime.log("Secrets reloaded.");
1972
+ } catch (err) {
1973
+ defaultRuntime.error(danger(String(err)));
1974
+ defaultRuntime.exit(1);
1975
+ }
1976
+ });
1977
+ secrets.command("audit").description("Audit plaintext secrets, unresolved refs, and precedence drift").option("--check", "Exit non-zero when findings are present", false).option("--json", "Output JSON", false).action(async (opts) => {
1978
+ try {
1979
+ const report = await runSecretsAudit();
1980
+ if (opts.json) defaultRuntime.log(JSON.stringify(report, null, 2));
1981
+ else {
1982
+ defaultRuntime.log(`Secrets audit: ${report.status}. plaintext=${report.summary.plaintextCount}, unresolved=${report.summary.unresolvedRefCount}, shadowed=${report.summary.shadowedRefCount}, legacy=${report.summary.legacyResidueCount}.`);
1983
+ if (report.findings.length > 0) {
1984
+ for (const finding of report.findings.slice(0, 20)) defaultRuntime.log(`- [${finding.code}] ${finding.file}:${finding.jsonPath} ${finding.message}`);
1985
+ if (report.findings.length > 20) defaultRuntime.log(`... ${report.findings.length - 20} more finding(s).`);
1986
+ }
1987
+ }
1988
+ const exitCode = resolveSecretsAuditExitCode(report, Boolean(opts.check));
1989
+ if (exitCode !== 0) defaultRuntime.exit(exitCode);
1990
+ } catch (err) {
1991
+ defaultRuntime.error(danger(String(err)));
1992
+ defaultRuntime.exit(2);
1993
+ }
1994
+ });
1995
+ secrets.command("configure").description("Interactive secrets helper (provider setup + SecretRef mapping + preflight)").option("--apply", "Apply changes immediately after preflight", false).option("--yes", "Skip apply confirmation prompt", false).option("--providers-only", "Configure secrets.providers only, skip credential mapping", false).option("--skip-provider-setup", "Skip provider setup and only map credential fields to existing providers", false).option("--agent <id>", "Agent id for auth-profiles targets (default: configured default agent)").option("--plan-out <path>", "Write generated plan JSON to a file").option("--json", "Output JSON", false).action(async (opts) => {
1996
+ try {
1997
+ const configured = await runSecretsConfigureInteractive({
1998
+ providersOnly: Boolean(opts.providersOnly),
1999
+ skipProviderSetup: Boolean(opts.skipProviderSetup),
2000
+ agentId: typeof opts.agent === "string" ? opts.agent : void 0
2001
+ });
2002
+ if (opts.planOut) fs.writeFileSync(opts.planOut, `${JSON.stringify(configured.plan, null, 2)}\n`, "utf8");
2003
+ if (opts.json) defaultRuntime.log(JSON.stringify({
2004
+ plan: configured.plan,
2005
+ preflight: configured.preflight
2006
+ }, null, 2));
2007
+ else {
2008
+ defaultRuntime.log(`Preflight: changed=${configured.preflight.changed}, files=${configured.preflight.changedFiles.length}, warnings=${configured.preflight.warningCount}.`);
2009
+ if (configured.preflight.warningCount > 0) for (const warning of configured.preflight.warnings) defaultRuntime.log(`- warning: ${warning}`);
2010
+ const providerUpserts = Object.keys(configured.plan.providerUpserts ?? {}).length;
2011
+ const providerDeletes = configured.plan.providerDeletes?.length ?? 0;
2012
+ defaultRuntime.log(`Plan: targets=${configured.plan.targets.length}, providerUpserts=${providerUpserts}, providerDeletes=${providerDeletes}.`);
2013
+ if (opts.planOut) defaultRuntime.log(`Plan written to ${opts.planOut}`);
2014
+ }
2015
+ let shouldApply = Boolean(opts.apply);
2016
+ if (!shouldApply && !opts.json) {
2017
+ const approved = await confirm({
2018
+ message: "Apply this plan now?",
2019
+ initialValue: true
2020
+ });
2021
+ if (typeof approved === "boolean") shouldApply = approved;
2022
+ }
2023
+ if (shouldApply) {
2024
+ if (Boolean(opts.apply) && !opts.yes && !opts.json) {
2025
+ if (await confirm({
2026
+ message: "This migration is one-way for migrated plaintext values. Continue with apply?",
2027
+ initialValue: true
2028
+ }) !== true) {
2029
+ defaultRuntime.log("Apply cancelled.");
2030
+ return;
2031
+ }
2032
+ }
2033
+ const result = await runSecretsApply({
2034
+ plan: configured.plan,
2035
+ write: true
2036
+ });
2037
+ if (opts.json) {
2038
+ defaultRuntime.log(JSON.stringify(result, null, 2));
2039
+ return;
2040
+ }
2041
+ defaultRuntime.log(result.changed ? `Secrets applied. Updated ${result.changedFiles.length} file(s).` : "Secrets apply: no changes.");
2042
+ }
2043
+ } catch (err) {
2044
+ defaultRuntime.error(danger(String(err)));
2045
+ defaultRuntime.exit(1);
2046
+ }
2047
+ });
2048
+ secrets.command("apply").description("Apply a previously generated secrets plan").requiredOption("--from <path>", "Path to plan JSON").option("--dry-run", "Validate/preflight only", false).option("--json", "Output JSON", false).action(async (opts) => {
2049
+ try {
2050
+ const result = await runSecretsApply({
2051
+ plan: readPlanFile(opts.from),
2052
+ write: !opts.dryRun
2053
+ });
2054
+ if (opts.json) {
2055
+ defaultRuntime.log(JSON.stringify(result, null, 2));
2056
+ return;
2057
+ }
2058
+ if (opts.dryRun) {
2059
+ defaultRuntime.log(result.changed ? `Secrets apply dry run: ${result.changedFiles.length} file(s) would change.` : "Secrets apply dry run: no changes.");
2060
+ return;
2061
+ }
2062
+ defaultRuntime.log(result.changed ? `Secrets applied. Updated ${result.changedFiles.length} file(s).` : "Secrets apply: no changes.");
2063
+ } catch (err) {
2064
+ defaultRuntime.error(danger(String(err)));
2065
+ defaultRuntime.exit(1);
2066
+ }
2067
+ });
2068
+ }
2069
+ //#endregion
2070
+ export { registerSecretsCli };