@spacebar_ai/moldclaw-core 2026.3.14 → 2026.3.16

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 (1074) hide show
  1. package/README.md +108 -3
  2. package/dist/account-id-plS5L20e.d.ts +1 -0
  3. package/dist/accounts-BAYVGC2k.js +109 -0
  4. package/dist/accounts-DrjRgReV.d.ts +103 -0
  5. package/dist/acp-cli-at_UYEOS.js +2088 -0
  6. package/dist/acpx-Chy1GQ_k.d.ts +5 -0
  7. package/dist/actions.runtime-C0F7dMfO.js +114 -0
  8. package/dist/actions.runtime-caI2LG9o.js +128 -0
  9. package/dist/agent-media-payload-CkpAqaOh.d.ts +16 -0
  10. package/dist/agents-B98yPGc5.js +853 -0
  11. package/dist/agents-BrLr08L3.js +217 -0
  12. package/dist/allow-from-BIwT4dl7.d.ts +42 -0
  13. package/dist/allow-list-CHt7yvAf.js +81 -0
  14. package/dist/allowlist-CxQo2wQc.js +142 -0
  15. package/dist/allowlist-resolution-B7ib7gye.d.ts +17 -0
  16. package/dist/api-Co7TNHbL.js +6953 -0
  17. package/dist/api-cEQ_ql_8.js +112 -0
  18. package/dist/audit-AnKnnlaZ.js +787 -0
  19. package/dist/audit-channel.collect.runtime-CAk1DFQ3.js +600 -0
  20. package/dist/audit-channel.runtime-5phdZp_m.js +116 -0
  21. package/dist/audit-extra.async-B8ZXFxic.js +813 -0
  22. package/dist/audit-hdKa3D-u.js +54 -0
  23. package/dist/audit-membership-runtime-CJV5XvGU.js +157 -0
  24. package/dist/audit.deep.runtime-DNMcRQrp.js +24 -0
  25. package/dist/audit.nondeep.runtime-DhNDL6yM.js +831 -0
  26. package/dist/audit.runtime-Bx7uWEh8.js +113 -0
  27. package/dist/auth-choice-C37W9MA7.js +268 -0
  28. package/dist/auth-choice-CNppOY_V.js +117 -0
  29. package/dist/auth-choice-XYFnp6fI.js +502 -0
  30. package/dist/auth-choice-options-D6oZY4Xo.js +123 -0
  31. package/dist/auth-choice-prompt-BhRqchJx.js +110 -0
  32. package/dist/auth-choice-prompt-C1xv0N08.js +36 -0
  33. package/dist/auth-choice.plugin-providers.runtime-DhLEtbmR.js +114 -0
  34. package/dist/auth-profiles-9zZdaXJK.js +127756 -0
  35. package/dist/auth-profiles.runtime-HONFDgiu.js +111 -0
  36. package/dist/bluebubbles-BY8JhO4y.js +64 -0
  37. package/dist/bluebubbles-CQjEnzK_.d.ts +6 -0
  38. package/dist/bluebubbles-RmcKgkBa.d.ts +45 -0
  39. package/dist/boolean-param-F1sMwnPu.d.ts +5 -0
  40. package/dist/bot-BGh-ATV7.d.ts +478 -0
  41. package/dist/brave-CljenznH.js +24 -0
  42. package/dist/browser-cli-CX8i0wf0.js +1492 -0
  43. package/dist/build-info.json +3 -3
  44. package/dist/bundled/boot-md/handler.d.ts +6 -0
  45. package/dist/bundled/boot-md/handler.js +26 -26
  46. package/dist/bundled/bootstrap-extra-files/handler.d.ts +6 -0
  47. package/dist/bundled/command-logger/handler.d.ts +9 -0
  48. package/dist/bundled/session-memory/handler.d.ts +9 -0
  49. package/dist/bundled/session-memory/handler.js +27 -27
  50. package/dist/call-Bc257L16.js +37 -0
  51. package/dist/call-DYFR7oGy.js +639 -0
  52. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  53. package/dist/channel-Bd-igGEW.js +803 -0
  54. package/dist/channel-BgRMb6bZ.js +575 -0
  55. package/dist/channel-BtcLrU6J.js +1598 -0
  56. package/dist/channel-Bwf6m_hD.js +538 -0
  57. package/dist/channel-C7-kgDBd.js +562 -0
  58. package/dist/channel-CEXOAxIc.js +949 -0
  59. package/dist/channel-CpZ3p9MJ.js +226 -0
  60. package/dist/channel-CqBlN6A2.js +619 -0
  61. package/dist/channel-DKhfHW4U.js +352 -0
  62. package/dist/channel-DS3t_KdJ2.js +316 -0
  63. package/dist/channel-DY24FA1v.js +4681 -0
  64. package/dist/channel-DYFGmImJ.js +542 -0
  65. package/dist/channel-DcyIqX5p.js +207 -0
  66. package/dist/channel-J-2XcAli.js +214 -0
  67. package/dist/channel-N616f4gZ.js +306 -0
  68. package/dist/channel-NY7aU2Gj.js +397 -0
  69. package/dist/channel-PNI8BOmm.js +1321 -0
  70. package/dist/channel-UcXepDJs.js +943 -0
  71. package/dist/channel-account-context-CL3hEq1j.js +103 -0
  72. package/dist/channel-config-schema-Q2nzcCCR.d.ts +1 -0
  73. package/dist/channel-jA_jodJo.js +920 -0
  74. package/dist/channel-options-CtgU5qkG.js +50 -0
  75. package/dist/channel-policy-7wXDp6d3.d.ts +1 -0
  76. package/dist/channel-rGI8uig4.js +497 -0
  77. package/dist/channel-summary-DGJZXo0r.js +106 -0
  78. package/dist/channel.runtime--WZvlNJM.js +413 -0
  79. package/dist/channel.runtime-B0ct42DL.js +122 -0
  80. package/dist/channel.runtime-BEZUZrYB.js +177 -0
  81. package/dist/channel.runtime-BMuWmsIC.js +166 -0
  82. package/dist/channel.runtime-BtvHP0po.js +4006 -0
  83. package/dist/channel.runtime-Cwf993pX.js +194 -0
  84. package/dist/channel.runtime-Cy4lEpTX.js +174 -0
  85. package/dist/channel.runtime-DAz6axda.js +865 -0
  86. package/dist/channel.runtime-DdQ2mOVh.js +236 -0
  87. package/dist/channel.runtime-Dy3HPgOU.js +399 -0
  88. package/dist/channel.runtime-iqfC25k7.js +213 -0
  89. package/dist/channel.setup-B4VYMZlQ.js +9 -0
  90. package/dist/channel.setup-BohGbCbI.js +57 -0
  91. package/dist/channel.setup-Bq2AQqqc.js +6 -0
  92. package/dist/channel.setup-BxiSfLp1.js +8 -0
  93. package/dist/channel.setup-DOUS6fjO.js +8 -0
  94. package/dist/channel.setup-DXhdYU3g.js +9 -0
  95. package/dist/channel.setup-N51CgfNy.js +11 -0
  96. package/dist/channels/plugins/actions/discord.d.ts +3 -0
  97. package/dist/channels/plugins/actions/discord.js +26 -26
  98. package/dist/channels/plugins/actions/signal.d.ts +2 -0
  99. package/dist/channels/plugins/actions/signal.js +26 -26
  100. package/dist/channels/plugins/actions/telegram.d.ts +3 -0
  101. package/dist/channels/plugins/actions/telegram.js +26 -26
  102. package/dist/channels/plugins/agent-tools/whatsapp-login.d.ts +4 -0
  103. package/dist/channels/plugins/agent-tools/whatsapp-login.js +26 -26
  104. package/dist/channels-CueeFf0q.js +404 -0
  105. package/dist/channels-PheAd73E.js +1113 -0
  106. package/dist/channels-cli-CXzVF84v.js +286 -0
  107. package/dist/channels-status-issues-BjWBQHhU.js +16 -0
  108. package/dist/chat-type-BlSN0vo4.d.ts +5 -0
  109. package/dist/clawbot-cli-BBehDXW1.js +113 -0
  110. package/dist/cli/daemon-cli.d.ts +58 -0
  111. package/dist/cli/daemon-cli.js +1 -1
  112. package/dist/cli-CIm7d5Id.js +149 -0
  113. package/dist/command-format-pq3tS8t2.d.ts +4 -0
  114. package/dist/command-registry-CDkp__KH.js +13 -0
  115. package/dist/command-registry-DSEkUBW1.js +212 -0
  116. package/dist/command-secret-gateway-CqP_o0n8.js +106 -0
  117. package/dist/compact.runtime-Qm_csEtG.js +111 -0
  118. package/dist/completion-cli-Ch1sgSLQ.js +445 -0
  119. package/dist/completion-cli-vF067Tso.js +16 -0
  120. package/dist/config-B2W1zTP1.js +44 -0
  121. package/dist/config-CMhKplgO.js +938 -0
  122. package/dist/config-DchtRsvs.js +30 -0
  123. package/dist/config-cli-C41d88_c.js +428 -0
  124. package/dist/config-guard-B_vjkXCQ.js +117 -0
  125. package/dist/config-schema-pPBCF4hz.js +31 -0
  126. package/dist/config-validation-6om9cBUx.js +262 -0
  127. package/dist/config-value-Dl3XEpA6.js +132 -0
  128. package/dist/configure-BxzvDSzu.js +1100 -0
  129. package/dist/configure-CLMLoWAn.js +238 -0
  130. package/dist/control-ui-shared-E8Nz6uKZ.js +29 -0
  131. package/dist/core-Cd3fMFKq.d.ts +87 -0
  132. package/dist/credentials-yYt6VWCq.js +268 -0
  133. package/dist/cron-cli-CA3lV3kh.js +634 -0
  134. package/dist/daemon-cli-BtQuIXEk.js +339 -0
  135. package/dist/daemon-install-BWKGzgMm.js +175 -0
  136. package/dist/deliver-CgMNmfTy.js +106 -0
  137. package/dist/deliver-runtime-Bn1KWoiQ.js +106 -0
  138. package/dist/devices-cli-D601npiL.js +340 -0
  139. package/dist/diagnostic-CkiYEGqt.js +310 -0
  140. package/dist/diffs-B5tZ8Coj.d.ts +1 -0
  141. package/dist/directory-cli-skEV8MT7.js +306 -0
  142. package/dist/directory-config-helpers-B-tiBKIv.d.ts +38 -0
  143. package/dist/directory-runtime-BEJ2fCIR.d.ts +1 -0
  144. package/dist/directory.static-CnyzoWbV.js +44 -0
  145. package/dist/discord-B_gbzPti.js +109 -0
  146. package/dist/discovery-CqI-e_Mv.js +48 -0
  147. package/dist/dm-policy-shared-nybkS1uP.d.ts +95 -0
  148. package/dist/dns-cli-Cjes3Ruw.js +216 -0
  149. package/dist/docs-cli-C3g3Gi_d.js +173 -0
  150. package/dist/doctor-completion-TvgV4SZH.js +90 -0
  151. package/dist/doctor-config-flow-0w9Ux7V8.js +107 -0
  152. package/dist/doctor-config-flow-DLzr8W7Y.js +2437 -0
  153. package/dist/enable-VYzv8b2z.js +24 -0
  154. package/dist/entry.d.ts +7 -0
  155. package/dist/entry.js +1 -1
  156. package/dist/env-overrides-DYVIkuvN.js +434 -0
  157. package/dist/env-overrides.runtime-6kijpIuu.js +17 -0
  158. package/dist/exec-approvals-cli-D_lkTG-l.js +419 -0
  159. package/dist/exec-sVmouhA9.d.ts +39 -0
  160. package/dist/extensions/acpx/index.d.ts +11 -0
  161. package/dist/extensions/acpx/index.js +1 -1
  162. package/dist/extensions/amazon-bedrock/index.d.ts +11 -0
  163. package/dist/extensions/anthropic/index.d.ts +11 -0
  164. package/dist/extensions/anthropic/index.js +26 -26
  165. package/dist/extensions/bluebubbles/index.d.ts +11 -0
  166. package/dist/extensions/bluebubbles/index.js +30 -30
  167. package/dist/extensions/bluebubbles/setup-entry.d.ts +59 -0
  168. package/dist/extensions/bluebubbles/setup-entry.js +30 -30
  169. package/dist/extensions/brave/index.d.ts +11 -0
  170. package/dist/extensions/brave/index.js +2 -2
  171. package/dist/extensions/byteplus/index.d.ts +11 -0
  172. package/dist/extensions/byteplus/index.js +26 -26
  173. package/dist/extensions/cloudflare-ai-gateway/index.d.ts +11 -0
  174. package/dist/extensions/cloudflare-ai-gateway/index.js +27 -27
  175. package/dist/extensions/copilot-proxy/index.d.ts +11 -0
  176. package/dist/extensions/device-pair/index.d.ts +12 -0
  177. package/dist/extensions/diagnostics-otel/index.d.ts +11 -0
  178. package/dist/extensions/diffs/index.d.ts +11 -0
  179. package/dist/extensions/discord/index.d.ts +11 -0
  180. package/dist/extensions/discord/index.js +31 -31
  181. package/dist/extensions/discord/setup-entry.d.ts +7 -0
  182. package/dist/extensions/discord/setup-entry.js +29 -29
  183. package/dist/extensions/elevenlabs/index.d.ts +11 -0
  184. package/dist/extensions/elevenlabs/index.js +26 -26
  185. package/dist/extensions/feishu/index.d.ts +229 -0
  186. package/dist/extensions/feishu/index.js +31 -31
  187. package/dist/extensions/feishu/setup-entry.d.ts +9 -0
  188. package/dist/extensions/feishu/setup-entry.js +28 -28
  189. package/dist/extensions/firecrawl/index.d.ts +11 -0
  190. package/dist/extensions/firecrawl/index.js +26 -26
  191. package/dist/extensions/github-copilot/index.d.ts +11 -0
  192. package/dist/extensions/github-copilot/index.js +27 -27
  193. package/dist/extensions/google/index.d.ts +11 -0
  194. package/dist/extensions/google/index.js +26 -26
  195. package/dist/extensions/googlechat/index.d.ts +11 -0
  196. package/dist/extensions/googlechat/index.js +30 -30
  197. package/dist/extensions/googlechat/setup-entry.d.ts +19 -0
  198. package/dist/extensions/googlechat/setup-entry.js +30 -30
  199. package/dist/extensions/huggingface/index.d.ts +11 -0
  200. package/dist/extensions/huggingface/index.js +26 -26
  201. package/dist/extensions/imessage/index.d.ts +11 -0
  202. package/dist/extensions/imessage/index.js +30 -30
  203. package/dist/extensions/imessage/setup-entry.d.ts +7 -0
  204. package/dist/extensions/imessage/setup-entry.js +30 -30
  205. package/dist/extensions/irc/index.d.ts +11 -0
  206. package/dist/extensions/irc/index.js +29 -29
  207. package/dist/extensions/irc/setup-entry.d.ts +8 -0
  208. package/dist/extensions/irc/setup-entry.js +29 -29
  209. package/dist/extensions/kakao-talkchannel/index.d.ts +19 -0
  210. package/dist/extensions/kakao-talkchannel/index.js +1762 -0
  211. package/dist/extensions/kakao-talkchannel/moldclaw.plugin.json +111 -0
  212. package/dist/extensions/kakao-talkchannel/package.json +12 -0
  213. package/dist/extensions/kilocode/index.d.ts +11 -0
  214. package/dist/extensions/kilocode/index.js +26 -26
  215. package/dist/extensions/kimi-coding/index.d.ts +11 -0
  216. package/dist/extensions/kimi-coding/index.js +26 -26
  217. package/dist/extensions/line/index.d.ts +11 -0
  218. package/dist/extensions/line/index.js +28 -28
  219. package/dist/extensions/line/setup-entry.d.ts +7 -0
  220. package/dist/extensions/line/setup-entry.js +28 -28
  221. package/dist/extensions/llm-task/index.d.ts +11 -0
  222. package/dist/extensions/llm-task/index.js +28 -28
  223. package/dist/extensions/lobster/index.d.ts +11 -0
  224. package/dist/extensions/matrix/index.d.ts +11 -0
  225. package/dist/extensions/matrix/index.js +31 -31
  226. package/dist/extensions/matrix/setup-entry.d.ts +20 -0
  227. package/dist/extensions/matrix/setup-entry.js +31 -31
  228. package/dist/extensions/mattermost/index.d.ts +11 -0
  229. package/dist/extensions/mattermost/index.js +28 -28
  230. package/dist/extensions/mattermost/setup-entry.d.ts +88 -0
  231. package/dist/extensions/mattermost/setup-entry.js +28 -28
  232. package/dist/extensions/memory-core/index.d.ts +11 -0
  233. package/dist/extensions/memory-lancedb/index.d.ts +25 -0
  234. package/dist/extensions/microsoft/index.d.ts +11 -0
  235. package/dist/extensions/microsoft/index.js +26 -26
  236. package/dist/extensions/minimax/index.d.ts +11 -0
  237. package/dist/extensions/minimax/index.js +26 -26
  238. package/dist/extensions/mistral/index.d.ts +11 -0
  239. package/dist/extensions/mistral/index.js +26 -26
  240. package/dist/extensions/modelstudio/index.d.ts +11 -0
  241. package/dist/extensions/modelstudio/index.js +26 -26
  242. package/dist/extensions/moonshot/index.d.ts +11 -0
  243. package/dist/extensions/moonshot/index.js +26 -26
  244. package/dist/extensions/msteams/index.d.ts +11 -0
  245. package/dist/extensions/msteams/index.js +31 -31
  246. package/dist/extensions/msteams/setup-entry.d.ts +11 -0
  247. package/dist/extensions/msteams/setup-entry.js +31 -31
  248. package/dist/extensions/nextcloud-talk/index.d.ts +11 -0
  249. package/dist/extensions/nextcloud-talk/index.js +28 -28
  250. package/dist/extensions/nextcloud-talk/setup-entry.d.ts +60 -0
  251. package/dist/extensions/nextcloud-talk/setup-entry.js +28 -28
  252. package/dist/extensions/nostr/index.d.ts +11 -0
  253. package/dist/extensions/nostr/index.js +28 -28
  254. package/dist/extensions/nostr/setup-entry.d.ts +49 -0
  255. package/dist/extensions/nostr/setup-entry.js +28 -28
  256. package/dist/extensions/nvidia/index.d.ts +11 -0
  257. package/dist/extensions/ollama/index.d.ts +11 -0
  258. package/dist/extensions/open-prose/index.d.ts +11 -0
  259. package/dist/extensions/openai/index.d.ts +11 -0
  260. package/dist/extensions/openai/index.js +26 -26
  261. package/dist/extensions/opencode/index.d.ts +11 -0
  262. package/dist/extensions/opencode/index.js +26 -26
  263. package/dist/extensions/opencode-go/index.d.ts +11 -0
  264. package/dist/extensions/opencode-go/index.js +26 -26
  265. package/dist/extensions/openrouter/index.d.ts +11 -0
  266. package/dist/extensions/openrouter/index.js +26 -26
  267. package/dist/extensions/openshell/index.d.ts +11 -0
  268. package/dist/extensions/openshell/index.js +26 -26
  269. package/dist/extensions/perplexity/index.d.ts +11 -0
  270. package/dist/extensions/perplexity/index.js +2 -2
  271. package/dist/extensions/phone-control/index.d.ts +12 -0
  272. package/dist/extensions/qianfan/index.d.ts +11 -0
  273. package/dist/extensions/qianfan/index.js +26 -26
  274. package/dist/extensions/qwen-portal-auth/index.d.ts +12 -0
  275. package/dist/extensions/qwen-portal-auth/index.js +26 -26
  276. package/dist/extensions/sglang/index.d.ts +11 -0
  277. package/dist/extensions/sglang/index.js +26 -26
  278. package/dist/extensions/signal/index.d.ts +11 -0
  279. package/dist/extensions/signal/index.js +29 -29
  280. package/dist/extensions/signal/setup-entry.d.ts +7 -0
  281. package/dist/extensions/signal/setup-entry.js +29 -29
  282. package/dist/extensions/slack/index.d.ts +11 -0
  283. package/dist/extensions/slack/index.js +30 -30
  284. package/dist/extensions/slack/setup-entry.d.ts +7 -0
  285. package/dist/extensions/slack/setup-entry.js +29 -29
  286. package/dist/extensions/synology-chat/index.d.ts +11 -0
  287. package/dist/extensions/synology-chat/index.js +28 -28
  288. package/dist/extensions/synology-chat/setup-entry.d.ts +138 -0
  289. package/dist/extensions/synology-chat/setup-entry.js +28 -28
  290. package/dist/extensions/synthetic/index.d.ts +11 -0
  291. package/dist/extensions/synthetic/index.js +26 -26
  292. package/dist/extensions/talk-voice/index.d.ts +12 -0
  293. package/dist/extensions/talk-voice/index.js +26 -26
  294. package/dist/extensions/telegram/index.d.ts +11 -0
  295. package/dist/extensions/telegram/index.js +29 -29
  296. package/dist/extensions/telegram/setup-entry.d.ts +7 -0
  297. package/dist/extensions/telegram/setup-entry.js +28 -28
  298. package/dist/extensions/thread-ownership/index.d.ts +12 -0
  299. package/dist/extensions/tlon/index.d.ts +11 -0
  300. package/dist/extensions/tlon/index.js +28 -28
  301. package/dist/extensions/tlon/setup-entry.d.ts +7 -0
  302. package/dist/extensions/tlon/setup-entry.js +28 -28
  303. package/dist/extensions/together/index.d.ts +11 -0
  304. package/dist/extensions/together/index.js +26 -26
  305. package/dist/extensions/twitch/index.d.ts +39 -0
  306. package/dist/extensions/twitch/index.js +28 -28
  307. package/dist/extensions/venice/index.d.ts +11 -0
  308. package/dist/extensions/venice/index.js +26 -26
  309. package/dist/extensions/vercel-ai-gateway/index.d.ts +11 -0
  310. package/dist/extensions/vercel-ai-gateway/index.js +26 -26
  311. package/dist/extensions/vllm/index.d.ts +11 -0
  312. package/dist/extensions/vllm/index.js +26 -26
  313. package/dist/extensions/voice-call/index.d.ts +11 -0
  314. package/dist/extensions/voice-call/index.js +26 -26
  315. package/dist/extensions/volcengine/index.d.ts +11 -0
  316. package/dist/extensions/volcengine/index.js +26 -26
  317. package/dist/extensions/whatsapp/index.d.ts +11 -0
  318. package/dist/extensions/whatsapp/index.js +29 -29
  319. package/dist/extensions/whatsapp/setup-entry.d.ts +7 -0
  320. package/dist/extensions/whatsapp/setup-entry.js +29 -29
  321. package/dist/extensions/xai/index.d.ts +11 -0
  322. package/dist/extensions/xai/index.js +26 -26
  323. package/dist/extensions/xiaomi/index.d.ts +11 -0
  324. package/dist/extensions/xiaomi/index.js +26 -26
  325. package/dist/extensions/zai/index.d.ts +11 -0
  326. package/dist/extensions/zai/index.js +26 -26
  327. package/dist/extensions/zalo/index.d.ts +11 -0
  328. package/dist/extensions/zalo/index.js +30 -30
  329. package/dist/extensions/zalo/setup-entry.d.ts +34 -0
  330. package/dist/extensions/zalo/setup-entry.js +30 -30
  331. package/dist/extensions/zalouser/index.d.ts +11 -0
  332. package/dist/extensions/zalouser/index.js +31 -31
  333. package/dist/extensions/zalouser/setup-entry.d.ts +42 -0
  334. package/dist/extensions/zalouser/setup-entry.js +31 -31
  335. package/dist/feishu-DCKEC3ao.d.ts +36 -0
  336. package/dist/gateway-cli-DN1Ii6J-.js +26432 -0
  337. package/dist/gateway-install-token-CJYFJBaC.js +163 -0
  338. package/dist/gateway-rpc-CroQg9MB.js +26 -0
  339. package/dist/gateway-runtime-D9FRZqKP.js +69 -0
  340. package/dist/googlechat-CBCkerAy.js +307 -0
  341. package/dist/googlechat-CSUNieHX.d.ts +12 -0
  342. package/dist/group-access-rSvkIglb.d.ts +61 -0
  343. package/dist/health-B6WwLJp4.js +570 -0
  344. package/dist/health-CAlJydXv.js +108 -0
  345. package/dist/history-BwNxb0sJ.d.ts +75 -0
  346. package/dist/hooks-BYlfU3Nf.d.ts +6 -0
  347. package/dist/hooks-cli-DuKmdo_H.js +995 -0
  348. package/dist/http-registry-DX_LVtuK.d.ts +20 -0
  349. package/dist/image-generation-DKkdRpve.d.ts +9 -0
  350. package/dist/imessage-7abjbe2Q.js +31 -0
  351. package/dist/imessage-DOH1yaDE.js +110 -0
  352. package/dist/inbound-envelope-CmvweL6U.d.ts +78 -0
  353. package/dist/inbound-reply-dispatch-BvnKTOec.js +71 -0
  354. package/dist/inbound-reply-dispatch-C7LjHRZN.d.ts +72 -0
  355. package/dist/index-DTQqfqj9.d.ts +1 -0
  356. package/dist/index.d.ts +27 -0
  357. package/dist/index.js +2 -2
  358. package/dist/infra/warning-filter.d.ts +10 -0
  359. package/dist/install-target-tXRD7VkM.js +574 -0
  360. package/dist/installs-C8fz8sm3.js +532 -0
  361. package/dist/io-C6XifaT4.js +9737 -0
  362. package/dist/io-C8awRnSW.js +28 -0
  363. package/dist/ipv4-d88_Jn2p.js +82 -0
  364. package/dist/irc-DpR6FXjN.js +672 -0
  365. package/dist/json-store-Sr_kk-II.d.ts +14 -0
  366. package/dist/keyed-async-queue-BA3BKukE.d.ts +19 -0
  367. package/dist/library-DOwowAGN.js +107 -0
  368. package/dist/lifecycle-core-BHHBoRTY.js +382 -0
  369. package/dist/line/accounts.d.ts +3 -0
  370. package/dist/line/send.d.ts +2 -0
  371. package/dist/line/send.js +4 -4
  372. package/dist/line/template-messages.d.ts +2 -0
  373. package/dist/line-8rsNbJCP.js +530 -0
  374. package/dist/line-D_cvIf6B.d.ts +75 -0
  375. package/dist/links-BOnvOj1z.d.ts +7 -0
  376. package/dist/llm-slug-generator-D9HjWtJT.js +67 -0
  377. package/dist/llm-slug-generator.d.ts +12 -0
  378. package/dist/llm-slug-generator.js +27 -27
  379. package/dist/logging-BhqLWxTD.js +13 -0
  380. package/dist/logging-DfaiL4OX.js +29 -0
  381. package/dist/login-qr-COBYR52w.js +233 -0
  382. package/dist/login-qr-xK4QIpPc.js +107 -0
  383. package/dist/logs-cli-RSSTw8L_.js +254 -0
  384. package/dist/manager-runtime-DL6JoSj9.js +106 -0
  385. package/dist/manager.runtime-Cbyhg1vB.js +710 -0
  386. package/dist/markdown-to-line-BTlEkOls.d.ts +91 -0
  387. package/dist/matrix-DX-jaB88.js +1490 -0
  388. package/dist/matrix-H6Yyj1QZ.d.ts +68 -0
  389. package/dist/matrix-J8s45tRw.js +1269 -0
  390. package/dist/mattermost-D75n6bRI.d.ts +6 -0
  391. package/dist/mcp-cli-CLc3_yCO.js +86 -0
  392. package/dist/media-understanding.runtime-BI0Lljbl.js +111 -0
  393. package/dist/memory-cli-CTp2cYrf.js +106 -0
  394. package/dist/method-scopes-Du8ODGFW.js +2586 -0
  395. package/dist/model-auth-markers-DEDakSUW.d.ts +20 -0
  396. package/dist/model-picker-CDBs7LJF.js +390 -0
  397. package/dist/model-picker-CRix4Wwv.js +107 -0
  398. package/dist/model-picker.runtime-CITyy3Rn.js +120 -0
  399. package/dist/model-suppression.runtime-Ce7D6QUT.js +111 -0
  400. package/dist/models-BK1eanuP.js +113 -0
  401. package/dist/models-X4Czy3uE.js +2514 -0
  402. package/dist/models-cli-C79Ulviy.js +304 -0
  403. package/dist/models-config-DALlu3S9.js +106 -0
  404. package/dist/models-config.providers.discovery-CSJ1STM1.d.ts +18 -0
  405. package/dist/monitor-B45a_RpX.js +3468 -0
  406. package/dist/monitor-C8KbJ-i0.js +767 -0
  407. package/dist/monitor-CIhrvegZ.js +3076 -0
  408. package/dist/monitor-CQut7klP.js +6823 -0
  409. package/dist/monitor-DZb5IJle.js +777 -0
  410. package/dist/monitor-DaFkdD27.js +108 -0
  411. package/dist/monitor-Do9Tp2Ii.js +110 -0
  412. package/dist/monitor-shared-CMK9cDOb.js +444 -0
  413. package/dist/msteams-A6H_wv5F.js +852 -0
  414. package/dist/net-DpMJgN-o.d.ts +19 -0
  415. package/dist/nextcloud-talk-f1pZ5Bge.d.ts +1 -0
  416. package/dist/node-cli-BXnmsjzL.js +2498 -0
  417. package/dist/node-resolve-CupmrA0Y.js +835 -0
  418. package/dist/nodes-cli-DZVrah_8.js +1375 -0
  419. package/dist/nostr-DMV534Ks.d.ts +7 -0
  420. package/dist/nostr-SAk3tjtR.js +8744 -0
  421. package/dist/npm-resolution-Dr9wssCY.js +60 -0
  422. package/dist/oauth-utils-DnyXdWU9.d.ts +10 -0
  423. package/dist/onboard-BE5pmb1g.js +589 -0
  424. package/dist/onboard-channels-3hNVY0E7.js +1241 -0
  425. package/dist/onboard-channels-vaO3nWLL.js +200 -0
  426. package/dist/onboard-custom-CI5uFyWH.js +571 -0
  427. package/dist/onboard-custom-eIvRswgv.js +109 -0
  428. package/dist/onboard-helpers-ChMWfUnl.js +335 -0
  429. package/dist/onboard-helpers-DRFi9oaD.js +108 -0
  430. package/dist/onboard-remote-BTspTgA4.js +112 -0
  431. package/dist/onboard-remote-so38yXlX.js +181 -0
  432. package/dist/onboard-search-DS0tZS24.js +297 -0
  433. package/dist/onboard-skills-B9DxCCiU.js +133 -0
  434. package/dist/onboard-skills-so0a_BJV.js +112 -0
  435. package/dist/outbound-media-BiJscGlR.js +11 -0
  436. package/dist/outbound-media-DJF-TuJu.d.ts +11 -0
  437. package/dist/pairing-access-CuiJP9xN.d.ts +21 -0
  438. package/dist/pairing-cli-DN0u1Cez.js +212 -0
  439. package/dist/parse-finite-number-B3FJTjyQ.d.ts +5 -0
  440. package/dist/perplexity-Bw1u3CAF.js +24 -0
  441. package/dist/persistent-dedupe-DR5Ka6BX.d.ts +26 -0
  442. package/dist/pi-model-discovery-runtime-iwKNCaYu.js +106 -0
  443. package/dist/pi-tools.before-tool-call.runtime-BM_N-JZe.js +380 -0
  444. package/dist/plugin-install--KVul05Z.js +184 -0
  445. package/dist/plugin-install-DVpPsLkS.js +112 -0
  446. package/dist/plugin-install-plan-Dwc6-coz.js +49 -0
  447. package/dist/plugin-registry-XRswugE9.js +108 -0
  448. package/dist/plugin-registry-jozQafRo.js +49 -0
  449. package/dist/plugin-sdk/account-resolution.js +26 -26
  450. package/dist/plugin-sdk/acp-runtime.js +26 -26
  451. package/dist/plugin-sdk/acpx.js +1 -1
  452. package/dist/plugin-sdk/agent-runtime.js +26 -26
  453. package/dist/plugin-sdk/bluebubbles.js +29 -29
  454. package/dist/plugin-sdk/channel-config-helpers.js +26 -26
  455. package/dist/plugin-sdk/channel-config-schema.js +2 -2
  456. package/dist/plugin-sdk/channel-policy.js +26 -26
  457. package/dist/plugin-sdk/channel-runtime.js +26 -26
  458. package/dist/plugin-sdk/compat.js +27 -27
  459. package/dist/plugin-sdk/config-runtime.js +28 -28
  460. package/dist/plugin-sdk/conversation-runtime.js +26 -26
  461. package/dist/plugin-sdk/discord.js +26 -26
  462. package/dist/plugin-sdk/feishu.js +27 -27
  463. package/dist/plugin-sdk/gateway-runtime.js +8 -8
  464. package/dist/plugin-sdk/googlechat.js +29 -29
  465. package/dist/plugin-sdk/image-generation-runtime.js +26 -26
  466. package/dist/plugin-sdk/image-generation.js +26 -26
  467. package/dist/plugin-sdk/imessage.js +27 -27
  468. package/dist/plugin-sdk/index.js +26 -26
  469. package/dist/plugin-sdk/infra-runtime.js +26 -26
  470. package/dist/plugin-sdk/irc.js +29 -29
  471. package/dist/plugin-sdk/line.js +27 -27
  472. package/dist/plugin-sdk/llm-task.js +26 -26
  473. package/dist/plugin-sdk/matrix.js +29 -29
  474. package/dist/plugin-sdk/mattermost.js +28 -28
  475. package/dist/plugin-sdk/media-runtime.js +26 -26
  476. package/dist/plugin-sdk/media-understanding-runtime.js +26 -26
  477. package/dist/plugin-sdk/media-understanding.js +26 -26
  478. package/dist/plugin-sdk/msteams.js +30 -30
  479. package/dist/plugin-sdk/nextcloud-talk.js +28 -28
  480. package/dist/plugin-sdk/nostr.js +27 -27
  481. package/dist/plugin-sdk/plugin-runtime.js +26 -26
  482. package/dist/plugin-sdk/provider-auth.js +28 -28
  483. package/dist/plugin-sdk/provider-setup.js +27 -27
  484. package/dist/plugin-sdk/provider-web-search.js +1 -1
  485. package/dist/plugin-sdk/qwen-portal-auth.js +26 -26
  486. package/dist/plugin-sdk/reply-history.js +26 -26
  487. package/dist/plugin-sdk/reply-runtime.js +26 -26
  488. package/dist/plugin-sdk/sandbox.js +26 -26
  489. package/dist/plugin-sdk/security-runtime.js +26 -26
  490. package/dist/plugin-sdk/self-hosted-provider-setup.js +27 -27
  491. package/dist/plugin-sdk/setup.js +27 -27
  492. package/dist/plugin-sdk/signal.js +26 -26
  493. package/dist/plugin-sdk/slack.js +26 -26
  494. package/dist/plugin-sdk/speech-runtime.js +26 -26
  495. package/dist/plugin-sdk/speech.js +26 -26
  496. package/dist/plugin-sdk/src/channels/plugins/setup-wizard-helpers.d.ts +3 -0
  497. package/dist/plugin-sdk/src/config/config-lock.d.ts +38 -0
  498. package/dist/plugin-sdk/src/config/config.d.ts +1 -1
  499. package/dist/plugin-sdk/src/config/io.d.ts +39 -0
  500. package/dist/plugin-sdk/src/config/types.gateway.d.ts +12 -0
  501. package/dist/plugin-sdk/src/config/types.secrets.d.ts +10 -0
  502. package/dist/plugin-sdk/src/config/zod-schema.d.ts +2 -0
  503. package/dist/plugin-sdk/src/gateway/credential-planner.d.ts +3 -1
  504. package/dist/plugin-sdk/src/secrets/provider-env-vars.d.ts +61 -0
  505. package/dist/plugin-sdk/src/secrets/sec1-placeholder.d.ts +181 -0
  506. package/dist/plugin-sdk/src/secrets/sec1-utils.d.ts +57 -0
  507. package/dist/plugin-sdk/synology-chat.js +27 -27
  508. package/dist/plugin-sdk/telegram.js +26 -26
  509. package/dist/plugin-sdk/text-runtime.js +4 -4
  510. package/dist/plugin-sdk/tlon.js +27 -27
  511. package/dist/plugin-sdk/twitch.js +26 -26
  512. package/dist/plugin-sdk/voice-call.js +26 -26
  513. package/dist/plugin-sdk/whatsapp.js +26 -26
  514. package/dist/plugin-sdk/zalo.js +30 -30
  515. package/dist/plugin-sdk/zalouser.js +29 -29
  516. package/dist/plugins/runtime/index.d.ts +22 -0
  517. package/dist/plugins/runtime/index.js +26 -26
  518. package/dist/plugins-C4PiDdjc.js +106 -0
  519. package/dist/plugins-cli-zhmliYNU.js +912 -0
  520. package/dist/policy-CcSolumc.js +143 -0
  521. package/dist/preflight-audio.runtime-BAbfqqzW.js +111 -0
  522. package/dist/probe-Bgt5c-cr.js +129 -0
  523. package/dist/probe-CPk5iGcg.js +47 -0
  524. package/dist/probe-DR4KRKXz.js +19 -0
  525. package/dist/probe-DnoCyJ_m.js +1793 -0
  526. package/dist/probe-VsLtK3vQ.js +6328 -0
  527. package/dist/probe-auth-BnsKrQt7.js +38 -0
  528. package/dist/probe-auth-DYdUG8l1.js +48 -0
  529. package/dist/program-8enYYBsc.js +247 -0
  530. package/dist/prompt-select-styled-DxBcUasv.js +2673 -0
  531. package/dist/provider-api-key-auth.runtime-DsLZyt6h.js +116 -0
  532. package/dist/provider-auth-choice-30EvRxqc.js +126 -0
  533. package/dist/provider-auth-choice-preference-DMr1WmRg.js +189 -0
  534. package/dist/provider-auth-choice.runtime-CI98BgQF.js +118 -0
  535. package/dist/provider-auth-guidance-WKDIi_wk.js +34 -0
  536. package/dist/provider-auth-result-Cs8wguSI.d.ts +18 -0
  537. package/dist/provider-models-EOys_Nvi.d.ts +867 -0
  538. package/dist/provider-ollama-setup-D89zlm9C.d.ts +32 -0
  539. package/dist/provider-onboard-BzOpgCLu.d.ts +40 -0
  540. package/dist/provider-runtime.runtime-Cm4as2KG.js +106 -0
  541. package/dist/provider-self-hosted-setup-Bmv_AQmw.d.ts +61 -0
  542. package/dist/provider-self-hosted-setup-CJwFVVB4.js +182 -0
  543. package/dist/provider-usage-CVNyLLDb.js +106 -0
  544. package/dist/provider-usage.types-CdTymHNu.d.ts +16 -0
  545. package/dist/provider-web-search-BJhXD5dH.js +2392 -0
  546. package/dist/provider-wizard-DMMYXjlW.js +152 -0
  547. package/dist/push-apns-BnWTdTEk.js +1038 -0
  548. package/dist/pw-ai-CtK_7Cy2.js +1866 -0
  549. package/dist/qr-cli-CA-BF0--.js +108 -0
  550. package/dist/qr-cli-D18HiUkh.js +369 -0
  551. package/dist/reactions-Df7XG8Uh.js +281 -0
  552. package/dist/read-only-account-inspect.discord.runtime-B-FP0mwb.js +111 -0
  553. package/dist/read-only-account-inspect.slack.runtime-DkWZ2ccW.js +111 -0
  554. package/dist/read-only-account-inspect.telegram.runtime-BnlTkn_e.js +111 -0
  555. package/dist/redact-snapshot-DVdstBvO.js +2661 -0
  556. package/dist/ref-contract-RPkB754Q.js +53 -0
  557. package/dist/register.agent-DVAxXQKW.js +434 -0
  558. package/dist/register.backup-CUuL5KUZ.js +624 -0
  559. package/dist/register.configure-bC0UEwfU.js +247 -0
  560. package/dist/register.maintenance-iIqvl_eT.js +569 -0
  561. package/dist/register.message-CEDd4z07.js +704 -0
  562. package/dist/register.onboard-Cejfnysy.js +187 -0
  563. package/dist/register.setup-DU7uHdYt.js +207 -0
  564. package/dist/register.status-health-sessions-BWphMXNR.js +493 -0
  565. package/dist/register.subclis-DnIweTEG.js +315 -0
  566. package/dist/register.subclis-gJX_Pbub.js +12 -0
  567. package/dist/registry-Dgwc-7eS.js +1183 -0
  568. package/dist/replies-D9PEZ8yn.js +110 -0
  569. package/dist/reply-history-lHgoC4l3.d.ts +1 -0
  570. package/dist/reply-payload-Bd2HuR4g.d.ts +46 -0
  571. package/dist/request-url-BcSJaiiu.d.ts +5 -0
  572. package/dist/resolve-BbsCHGLY.js +660 -0
  573. package/dist/resolve-channels-BtrGC95o.js +262 -0
  574. package/dist/resolve-channels-C1SthO1N.js +226 -0
  575. package/dist/resolve-users-CgSxHrU0.js +143 -0
  576. package/dist/routes-BZtqNrBf.js +7097 -0
  577. package/dist/rpc-D3KMxG4J.js +67 -0
  578. package/dist/run-command-C8b3dCZV.d.ts +16 -0
  579. package/dist/run-main-BlWJVotF.js +423 -0
  580. package/dist/runtime-RWGbO5Qy.d.ts +26 -0
  581. package/dist/runtime-discord-ops.runtime-DUXIYvQr.js +9073 -0
  582. package/dist/runtime-slack-ops.runtime-n1yFfyp1.js +4551 -0
  583. package/dist/runtime-telegram-ops.runtime-PZUWchjT.js +128 -0
  584. package/dist/runtime-whatsapp-login.runtime-xsuNyvGz.js +109 -0
  585. package/dist/runtime-whatsapp-outbound.runtime-5EfEyCsO.js +112 -0
  586. package/dist/sandbox-cli-Dw1nWNmQ.js +530 -0
  587. package/dist/search-manager-BJoRxOaf.js +15 -0
  588. package/dist/search-manager-DxkQvUrW.js +386 -0
  589. package/dist/secret-input-schema-Cp_La9qv.d.ts +19 -0
  590. package/dist/secrets-cli-BPyV2gSq.js +2065 -0
  591. package/dist/security-cli-EK4sSRfG.js +570 -0
  592. package/dist/send-B01Gvh9m.js +629 -0
  593. package/dist/send-B4L4wRJO.js +100 -0
  594. package/dist/send-BDcGrXt0.js +1025 -0
  595. package/dist/send-BRRtHxyR.js +283 -0
  596. package/dist/send-DU6dmMXW.js +631 -0
  597. package/dist/server-CWw5GFEg.js +106 -0
  598. package/dist/server-node-events-92cDVswC.js +501 -0
  599. package/dist/session-key-DbkfhOjM.d.ts +46 -0
  600. package/dist/sessions-B052uHA3.js +218 -0
  601. package/dist/sessions-Cef4dZNP.js +107 -0
  602. package/dist/setup-BlQPyDPy.js +387 -0
  603. package/dist/setup-DcSZ_pTn.d.ts +37 -0
  604. package/dist/setup-core-B9mdZYnU.js +166 -0
  605. package/dist/setup-core-Cj0sLkpP.js +47 -0
  606. package/dist/setup-core-CkZbebOv.js +143 -0
  607. package/dist/setup-core-MRNjnrJl.js +205 -0
  608. package/dist/setup-surface-3ZY0JtWE.js +490 -0
  609. package/dist/setup-wizard-helpers-Dwzb9Dcz.d.ts +203 -0
  610. package/dist/setup.finalize-B5ETm3Ui.js +517 -0
  611. package/dist/setup.gateway-config-C8hdtlbw.js +338 -0
  612. package/dist/setup.secret-input-BZSIeiqy.js +25 -0
  613. package/dist/shared--9_eQ_lc.js +75 -0
  614. package/dist/shared-CxkH3H0U.js +102 -0
  615. package/dist/shared-DTNL0hA9.js +298 -0
  616. package/dist/shared-HSP1OV-Q.js +96 -0
  617. package/dist/shared-UIjWb_3B.js +182 -0
  618. package/dist/signal-CTI6bSmB.js +109 -0
  619. package/dist/skills-4-r1mfJM.js +853 -0
  620. package/dist/skills-RNm54CBO.js +19 -0
  621. package/dist/skills-cli-te7dSs5p.js +291 -0
  622. package/dist/skills-install-Del-Ogv8.js +763 -0
  623. package/dist/skills-status-BZpoMXrR.js +169 -0
  624. package/dist/skills-status-Dq61Sz8U.js +20 -0
  625. package/dist/slack-oc-viUtl.js +109 -0
  626. package/dist/slash-commands.runtime-NdkD2LZV.js +123 -0
  627. package/dist/slash-dispatch.runtime-DQgeaF3J.js +136 -0
  628. package/dist/slash-skill-commands.runtime-DmOl2DnL.js +111 -0
  629. package/dist/src-0wtt7seR.js +1696 -0
  630. package/dist/status-5oR_gqv_.js +121 -0
  631. package/dist/status-BO8LY0hC.js +1599 -0
  632. package/dist/status-D_oHA9yO.js +126 -0
  633. package/dist/status-IrMacJRj.js +606 -0
  634. package/dist/status-Prdeg53E.js +43 -0
  635. package/dist/status-json-Da0hR-1Z.js +286 -0
  636. package/dist/status.link-channel-BgUJEZAz.js +138 -0
  637. package/dist/status.scan.deps.runtime-D9vHTxOW.js +121 -0
  638. package/dist/status.scan.runtime-D-EdD5CW.js +114 -0
  639. package/dist/status.summary--i6xduWH.js +592 -0
  640. package/dist/status.summary.runtime-BqMXjaBc.js +113 -0
  641. package/dist/subagent-orphan-recovery-DiRJcFQc.js +302 -0
  642. package/dist/subagent-registry-runtime-B66EYEYm.js +106 -0
  643. package/dist/synology-chat-BemXqdzG.js +297 -0
  644. package/dist/system-cli-CSuiia4-.js +92 -0
  645. package/dist/telegram/audit.d.ts +2 -0
  646. package/dist/telegram/audit.js +1 -1
  647. package/dist/telegram/token.d.ts +2 -0
  648. package/dist/telegram/token.js +26 -26
  649. package/dist/telegram-DLFcRv5a.js +109 -0
  650. package/dist/testing-DZrulv-n.d.ts +1755 -0
  651. package/dist/text-chunking-BaYBIUoR.d.ts +79 -0
  652. package/dist/text-chunking-C8kmbNfa.js +84 -0
  653. package/dist/thinking-D8aqmr3o.d.ts +13 -0
  654. package/dist/tlon-Bpr4f3yF.js +433 -0
  655. package/dist/tool-send-BHKm5ztm.d.ts +9 -0
  656. package/dist/tui-BY3QRgC1.js +3834 -0
  657. package/dist/tui-cli-CCfZOlV0.js +132 -0
  658. package/dist/types-CKx5nDZB.d.ts +45 -0
  659. package/dist/types-DBhDdMQd.d.ts +22670 -0
  660. package/dist/types.base-B_TkkSS8.d.ts +188 -0
  661. package/dist/types.secrets-Bojc4omL.js +92 -0
  662. package/dist/ui-1UpZZyI3.js +31 -0
  663. package/dist/update-BR4JvFpV.js +1036 -0
  664. package/dist/update-cli-BZv44lFq.js +1498 -0
  665. package/dist/update-offset-store-DGdBotIW.js +107 -0
  666. package/dist/update-runner-D34sooPe.js +1496 -0
  667. package/dist/vllm-defaults-BCGSJ7K0.d.ts +13 -0
  668. package/dist/wait-BU9vJv22.d.ts +4 -0
  669. package/dist/web-CXpU2D41.js +107 -0
  670. package/dist/web-shared-B4sL45ah.d.ts +45 -0
  671. package/dist/webhook-memory-guards-B7oLVseG.d.ts +43 -0
  672. package/dist/webhook-request-guards-CqIH7equ.d.ts +76 -0
  673. package/dist/webhook-targets-CAAGATtk.js +181 -0
  674. package/dist/webhook-targets-oQ0jd4r0.d.ts +106 -0
  675. package/dist/webhooks-cli-B46t2VT5.js +349 -0
  676. package/dist/whatsapp-Dniwd4Rv.js +109 -0
  677. package/dist/whatsapp-actions-fL46PsNs.js +162 -0
  678. package/dist/windows-spawn-DGeE98SH.d.ts +43 -0
  679. package/dist/workspace-dirs-d3Ms_ryk.js +2002 -0
  680. package/dist/zalo-Csulx0XK.d.ts +9 -0
  681. package/dist/zalo-gh0yAWmS.js +415 -0
  682. package/dist/zalouser-CuxRvztM.js +30911 -0
  683. package/dist/zod-schema.agent-runtime-B4MkB-_3.d.ts +10 -0
  684. package/dist/zod-schema.core-D5reNip6.js +541 -0
  685. package/dist/zod-schema.core-DN3RhEUG.d.ts +173 -0
  686. package/docs/SEC1.md +523 -0
  687. package/docs/SEC1_IMPLEMENTATION/CHANNELS_REPORT.md +173 -0
  688. package/docs/SEC1_IMPLEMENTATION/CORE_UTIL_REPORT.md +139 -0
  689. package/docs/SEC1_IMPLEMENTATION/DOCS_REPORT.md +134 -0
  690. package/docs/SEC1_IMPLEMENTATION/ENV_MAP_DRAFT.md +148 -0
  691. package/docs/SEC1_IMPLEMENTATION/INTEGRATION_REPORT.md +170 -0
  692. package/docs/SEC1_IMPLEMENTATION/PROVIDERS_REPORT.md +291 -0
  693. package/docs/SEC1_IMPLEMENTATION/QA_REPORT.md +249 -0
  694. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave1-channels.md +317 -0
  695. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave1-docs.md +212 -0
  696. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave1-security.md +368 -0
  697. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave2-critic-consolidated.md +195 -0
  698. package/docs/SEC1_IMPLEMENTATION/RECURSIVE_QA/wave3-fix-report.md +105 -0
  699. package/docs/SEC1_IMPLEMENTATION/STRATEGY.md +451 -0
  700. package/docs/SEC1_IMPLEMENTATION/TEST_REPORT.md +156 -0
  701. package/docs/pipeline-sdk/CLI_SPEC.md +609 -0
  702. package/docs/pipeline-sdk/PIPELINE_SDK_DESIGN.md +1372 -0
  703. package/extensions/kakao-talkchannel/MIGRATION_ARCH_ANALYSIS.md +455 -0
  704. package/extensions/kakao-talkchannel/MIGRATION_CODE_ANALYSIS.md +383 -0
  705. package/extensions/kakao-talkchannel/MIGRATION_STRATEGY.md +115 -0
  706. package/extensions/kakao-talkchannel/README.md +50 -0
  707. package/extensions/kakao-talkchannel/index.ts +20 -0
  708. package/extensions/kakao-talkchannel/moldclaw.plugin.json +98 -0
  709. package/extensions/kakao-talkchannel/package.json +12 -0
  710. package/extensions/kakao-talkchannel/src/adapters/config.ts +132 -0
  711. package/extensions/kakao-talkchannel/src/adapters/gateway.ts +974 -0
  712. package/extensions/kakao-talkchannel/src/adapters/outbound.ts +52 -0
  713. package/extensions/kakao-talkchannel/src/adapters/pairing.ts +35 -0
  714. package/extensions/kakao-talkchannel/src/adapters/security.ts +57 -0
  715. package/extensions/kakao-talkchannel/src/adapters/setup.ts +105 -0
  716. package/extensions/kakao-talkchannel/src/adapters/status.ts +117 -0
  717. package/extensions/kakao-talkchannel/src/channel.ts +58 -0
  718. package/extensions/kakao-talkchannel/src/commands/card.ts +413 -0
  719. package/extensions/kakao-talkchannel/src/config/schema.ts +129 -0
  720. package/extensions/kakao-talkchannel/src/kakao/callback.ts +133 -0
  721. package/extensions/kakao-talkchannel/src/kakao/limits.ts +129 -0
  722. package/extensions/kakao-talkchannel/src/kakao/payload.ts +138 -0
  723. package/extensions/kakao-talkchannel/src/kakao/response.ts +373 -0
  724. package/extensions/kakao-talkchannel/src/relay/client.ts +146 -0
  725. package/extensions/kakao-talkchannel/src/relay/session.ts +137 -0
  726. package/extensions/kakao-talkchannel/src/relay/sse.ts +258 -0
  727. package/extensions/kakao-talkchannel/src/relay/stream.ts +149 -0
  728. package/extensions/kakao-talkchannel/src/runtime.ts +21 -0
  729. package/extensions/kakao-talkchannel/src/types.ts +447 -0
  730. package/extensions/kakao-talkchannel/src/version.ts +3 -0
  731. package/extensions/kakao-talkchannel/tsconfig.json +19 -0
  732. package/package.json +23 -8
  733. package/skills/meshy/SKILL.md +69 -0
  734. package/skills/meshy/scripts/__pycache__/check_status.cpython-312.pyc +0 -0
  735. package/skills/meshy/scripts/__pycache__/image_to_3d.cpython-312.pyc +0 -0
  736. package/skills/meshy/scripts/__pycache__/text_to_3d.cpython-312.pyc +0 -0
  737. package/skills/meshy/scripts/check_status.py +147 -0
  738. package/skills/meshy/scripts/image_to_3d.py +229 -0
  739. package/skills/meshy/scripts/text_to_3d.py +214 -0
  740. package/skills/nano-banana-pro/scripts/generate_image.py +1 -1
  741. package/skills/openai-whisper-api/scripts/transcribe.sh +0 -0
  742. package/skills/tavily-search/SKILL.md +61 -0
  743. package/skills/tavily-search/scripts/__pycache__/search.cpython-312.pyc +0 -0
  744. package/skills/tavily-search/scripts/search.py +238 -0
  745. package/skills/video-frames/scripts/frame.sh +0 -0
  746. package/LICENSE +0 -21
  747. package/dist/accounts-UcSvD34O.js +0 -109
  748. package/dist/acp-cli-BPb8PgHP.js +0 -2088
  749. package/dist/actions.runtime-BL5QRooG.js +0 -114
  750. package/dist/actions.runtime-DSdfSo40.js +0 -128
  751. package/dist/agents-CHeX_5-H.js +0 -217
  752. package/dist/agents-DQRL9XKP.js +0 -853
  753. package/dist/allow-list-Boi79v-U.js +0 -81
  754. package/dist/allowlist-B2eBBeMF.js +0 -142
  755. package/dist/api-CFAtRSYL.js +0 -6953
  756. package/dist/api-D5JNJj8n.js +0 -112
  757. package/dist/audit-BM0GsdzV.js +0 -787
  758. package/dist/audit-BqRK9OSj.js +0 -54
  759. package/dist/audit-channel.collect.runtime-BPvDB8aq.js +0 -600
  760. package/dist/audit-channel.runtime-D3fzHiAo.js +0 -116
  761. package/dist/audit-extra.async-NveNIzX0.js +0 -813
  762. package/dist/audit-membership-runtime-mu470WFO.js +0 -157
  763. package/dist/audit.deep.runtime-RdxvW8Tj.js +0 -24
  764. package/dist/audit.nondeep.runtime-DDu8vA9Z.js +0 -831
  765. package/dist/audit.runtime-Y8C9W7s9.js +0 -113
  766. package/dist/auth-choice-C1CIxRsi.js +0 -268
  767. package/dist/auth-choice-CTvqWiDI.js +0 -117
  768. package/dist/auth-choice-Ddzko1B8.js +0 -502
  769. package/dist/auth-choice-options-BIAmAiCe.js +0 -123
  770. package/dist/auth-choice-prompt-B815kArz.js +0 -110
  771. package/dist/auth-choice-prompt-CGhTNCJx.js +0 -36
  772. package/dist/auth-choice.plugin-providers.runtime-AvAZ6S5W.js +0 -114
  773. package/dist/auth-profiles-BJcHzwPy.js +0 -127650
  774. package/dist/auth-profiles.runtime-CieFilK5.js +0 -111
  775. package/dist/bluebubbles-F8FGE9cH.js +0 -64
  776. package/dist/brave-BG5Yopn8.js +0 -24
  777. package/dist/browser-cli-Co7PJGZF.js +0 -1492
  778. package/dist/call-CoaQYq7c.js +0 -639
  779. package/dist/call-D3eu5Jjh.js +0 -37
  780. package/dist/channel-BftWD6yu.js +0 -1321
  781. package/dist/channel-Bub9U5Xg.js +0 -214
  782. package/dist/channel-C0oDs7TO.js +0 -4681
  783. package/dist/channel-C8CnEdkZ.js +0 -352
  784. package/dist/channel-CI-RC-xf.js +0 -497
  785. package/dist/channel-CY-hZCOJ.js +0 -397
  786. package/dist/channel-CbtGJB2x.js +0 -943
  787. package/dist/channel-CcfK3wP8.js +0 -803
  788. package/dist/channel-DBoDIeVj.js +0 -619
  789. package/dist/channel-DEq6Ecs-.js +0 -920
  790. package/dist/channel-DH4dhW1n.js +0 -226
  791. package/dist/channel-DQ_wdKg_.js +0 -575
  792. package/dist/channel-DT6qD1Ic.js +0 -207
  793. package/dist/channel-DZNAyxwr.js +0 -542
  794. package/dist/channel-DtakwAEe.js +0 -538
  795. package/dist/channel-DuYgH6p1.js +0 -562
  796. package/dist/channel-Hn-AN-d52.js +0 -316
  797. package/dist/channel-_R4hbD5h.js +0 -1598
  798. package/dist/channel-account-context-DXq8dlvI.js +0 -103
  799. package/dist/channel-kQmEVn3I.js +0 -306
  800. package/dist/channel-options-DHfxaklg.js +0 -50
  801. package/dist/channel-summary-DUpnoYhI.js +0 -106
  802. package/dist/channel-t-JxCWk6.js +0 -949
  803. package/dist/channel.runtime--GYriaXU.js +0 -213
  804. package/dist/channel.runtime-BJtn3GOH.js +0 -174
  805. package/dist/channel.runtime-BV7t_oNz.js +0 -166
  806. package/dist/channel.runtime-Bi8a3n9S.js +0 -865
  807. package/dist/channel.runtime-BjsYF0NN.js +0 -122
  808. package/dist/channel.runtime-BnI6YtmI.js +0 -413
  809. package/dist/channel.runtime-CQOftcCd.js +0 -194
  810. package/dist/channel.runtime-CuIAcPjZ.js +0 -4006
  811. package/dist/channel.runtime-DH1Q1G4k.js +0 -399
  812. package/dist/channel.runtime-DYYUPKxr.js +0 -236
  813. package/dist/channel.runtime-U5Gszsr5.js +0 -177
  814. package/dist/channel.setup-BQFHmgki.js +0 -9
  815. package/dist/channel.setup-BVoDwklu.js +0 -8
  816. package/dist/channel.setup-Bf73HsXr.js +0 -57
  817. package/dist/channel.setup-CblD4flM.js +0 -11
  818. package/dist/channel.setup-DgxlrPgz.js +0 -6
  819. package/dist/channel.setup-GLIAEVKL.js +0 -8
  820. package/dist/channel.setup-YTy5R1sz.js +0 -9
  821. package/dist/channels-CTL8iR9J.js +0 -404
  822. package/dist/channels-DBGvnjHY.js +0 -1113
  823. package/dist/channels-cli-BmVO5-sq.js +0 -286
  824. package/dist/channels-status-issues-kDtsWzA-.js +0 -16
  825. package/dist/clawbot-cli-DtcMJHqX.js +0 -113
  826. package/dist/cli-BNGECGVY.js +0 -149
  827. package/dist/command-registry-1SDrWgER.js +0 -13
  828. package/dist/command-registry-DNorYU4w.js +0 -212
  829. package/dist/command-secret-gateway-DqDZparO.js +0 -106
  830. package/dist/compact.runtime-C1ZN8UGb.js +0 -111
  831. package/dist/completion-cli-Q_Jt5Foc.js +0 -16
  832. package/dist/completion-cli-QkTXhuJh.js +0 -445
  833. package/dist/config-BbxrRaLf.js +0 -938
  834. package/dist/config-CkD8DJ7L.js +0 -44
  835. package/dist/config-cli-BoPrlYTp.js +0 -428
  836. package/dist/config-guard-CEhCvr_u.js +0 -117
  837. package/dist/config-schema-GQ6uWjXe.js +0 -31
  838. package/dist/config-validation-woE2_LpC.js +0 -262
  839. package/dist/config-value-Dh8m-CFf.js +0 -132
  840. package/dist/config-y4i5g7s4.js +0 -30
  841. package/dist/configure-DGRzwdFN.js +0 -1100
  842. package/dist/configure-S4AHE3k_.js +0 -238
  843. package/dist/control-ui-shared-kLBp4YlS.js +0 -29
  844. package/dist/credentials-D5uBf_C5.js +0 -265
  845. package/dist/cron-cli-lGupeVCW.js +0 -634
  846. package/dist/daemon-cli-Cs_edi0I.js +0 -339
  847. package/dist/daemon-install-DIFpP_qv.js +0 -175
  848. package/dist/deliver-DYa_DFZU.js +0 -106
  849. package/dist/deliver-runtime-DCW_o2Ot.js +0 -106
  850. package/dist/devices-cli-YsGOW2-w.js +0 -340
  851. package/dist/diagnostic-vMghIesG.js +0 -310
  852. package/dist/directory-cli-DtjMQjU5.js +0 -306
  853. package/dist/directory.static-DBZGvsdF.js +0 -44
  854. package/dist/discord-DYCu19HT.js +0 -109
  855. package/dist/discovery-DZYAoDF_.js +0 -48
  856. package/dist/dns-cli-DqW4pNgW.js +0 -216
  857. package/dist/docs-cli-Bu9TBlDU.js +0 -173
  858. package/dist/doctor-completion-B5hcQD5c.js +0 -90
  859. package/dist/doctor-config-flow-BBB2ZKfT.js +0 -107
  860. package/dist/doctor-config-flow-DDBYUS9f.js +0 -2437
  861. package/dist/enable-Tmsp8QuB.js +0 -24
  862. package/dist/env-overrides-BHxqjYZG.js +0 -434
  863. package/dist/env-overrides.runtime-Cz98bf-l.js +0 -17
  864. package/dist/exec-approvals-cli-wO5cYfMa.js +0 -419
  865. package/dist/gateway-cli-CFvDGhB9.js +0 -26429
  866. package/dist/gateway-install-token-CskJfo_N.js +0 -163
  867. package/dist/gateway-rpc-srYfBID9.js +0 -26
  868. package/dist/gateway-runtime-C76hUmUV.js +0 -69
  869. package/dist/googlechat-Cha5utST.js +0 -307
  870. package/dist/health-DDQYYsJy.js +0 -108
  871. package/dist/health-DXZykGaX.js +0 -570
  872. package/dist/hooks-cli-DfkurPYP.js +0 -995
  873. package/dist/imessage-B26k39pl.js +0 -110
  874. package/dist/imessage-Bp1_6cws.js +0 -31
  875. package/dist/inbound-reply-dispatch-DoIJLztA.js +0 -71
  876. package/dist/install-target-BjOuS4I8.js +0 -574
  877. package/dist/installs-Cz4k0W1Y.js +0 -532
  878. package/dist/io-B0OKifLZ.js +0 -28
  879. package/dist/io-DcoxdH6t.js +0 -9570
  880. package/dist/ipv4-CTQQ4_IW.js +0 -82
  881. package/dist/irc-B8vBDigm.js +0 -672
  882. package/dist/library-VCM_cQY4.js +0 -107
  883. package/dist/lifecycle-core-Ctz36PdQ.js +0 -382
  884. package/dist/line-B_uTLrdI.js +0 -530
  885. package/dist/llm-slug-generator-YWg0g2pj.js +0 -67
  886. package/dist/logging-S-5LPdfQ.js +0 -13
  887. package/dist/logging-ueBMCGMR.js +0 -29
  888. package/dist/login-qr-pcACm2Ng.js +0 -107
  889. package/dist/login-qr-pv-kxMfF.js +0 -233
  890. package/dist/logs-cli-RgADgSMO.js +0 -254
  891. package/dist/manager-runtime-BhTkoKmb.js +0 -106
  892. package/dist/manager.runtime-BjHzikoK.js +0 -710
  893. package/dist/matrix-C4EEu2Qp.js +0 -1490
  894. package/dist/matrix-Dfzcc5nV.js +0 -1269
  895. package/dist/mcp-cli-CJmOm9Oj.js +0 -86
  896. package/dist/media-understanding.runtime-DCETFCw_.js +0 -111
  897. package/dist/memory-cli-DFqd6tYx.js +0 -106
  898. package/dist/method-scopes-D-Q9dvbj.js +0 -2586
  899. package/dist/model-picker-Z-CUcuMr.js +0 -390
  900. package/dist/model-picker-v5mUsZ4J.js +0 -107
  901. package/dist/model-picker.runtime-A_z0dHfS.js +0 -120
  902. package/dist/model-suppression.runtime-QVWVJRr-.js +0 -111
  903. package/dist/models-Bbj0xV4F.js +0 -2514
  904. package/dist/models-D-OIjZqU.js +0 -113
  905. package/dist/models-cli-Bpn-5i4h.js +0 -304
  906. package/dist/models-config-Cwa5cJbC.js +0 -106
  907. package/dist/monitor-BchfCAaU.js +0 -6823
  908. package/dist/monitor-BydV44SP.js +0 -3076
  909. package/dist/monitor-CT8axwfm.js +0 -767
  910. package/dist/monitor-CZGWNOvn.js +0 -777
  911. package/dist/monitor-DN62r69g.js +0 -3468
  912. package/dist/monitor-DZ0fzJku.js +0 -110
  913. package/dist/monitor-DvNjzWFu.js +0 -108
  914. package/dist/monitor-shared-B-DBSlkQ.js +0 -444
  915. package/dist/msteams-Bf-wk2Rp.js +0 -852
  916. package/dist/node-cli-kH16TQI7.js +0 -2498
  917. package/dist/node-resolve-DfOpQmxm.js +0 -835
  918. package/dist/nodes-cli-CkAMXW5u.js +0 -1375
  919. package/dist/nostr-B8UGHclZ.js +0 -8744
  920. package/dist/npm-resolution-DmjlifII.js +0 -60
  921. package/dist/onboard-C883nfyw.js +0 -589
  922. package/dist/onboard-channels-Dc-BxN7p.js +0 -200
  923. package/dist/onboard-channels-j5EENtum.js +0 -1241
  924. package/dist/onboard-custom-0atne0C5.js +0 -571
  925. package/dist/onboard-custom-CWMqwjJx.js +0 -109
  926. package/dist/onboard-helpers-D3wWfH8F.js +0 -335
  927. package/dist/onboard-helpers-DZmRCe8l.js +0 -108
  928. package/dist/onboard-remote-Cn6kW-p0.js +0 -112
  929. package/dist/onboard-remote-Cx4w5VAk.js +0 -181
  930. package/dist/onboard-search-Ck9HRh2M.js +0 -297
  931. package/dist/onboard-skills-BtqrGioT.js +0 -133
  932. package/dist/onboard-skills-Dnw19Os8.js +0 -112
  933. package/dist/outbound-media-C5Nv4o18.js +0 -11
  934. package/dist/pairing-cli-Cwy9QZ_4.js +0 -212
  935. package/dist/perplexity-Brhpb45X.js +0 -24
  936. package/dist/pi-model-discovery-runtime-DIOdo6D8.js +0 -106
  937. package/dist/pi-tools.before-tool-call.runtime-CFM4gsDF.js +0 -380
  938. package/dist/plugin-install-BOV00hia.js +0 -112
  939. package/dist/plugin-install-Bak8fUBv.js +0 -184
  940. package/dist/plugin-install-plan-bKkEefRf.js +0 -49
  941. package/dist/plugin-registry-DxAXQUlZ.js +0 -108
  942. package/dist/plugin-registry-n0p3phem.js +0 -49
  943. package/dist/plugins-Ca3RK8Fi.js +0 -106
  944. package/dist/plugins-cli-BnC51H2R.js +0 -912
  945. package/dist/policy-BJv97w9e.js +0 -143
  946. package/dist/preflight-audio.runtime-BrFcf-6_.js +0 -111
  947. package/dist/probe-063xvvZc.js +0 -19
  948. package/dist/probe-BJEb2wGv.js +0 -1793
  949. package/dist/probe-CJQlxgsl.js +0 -47
  950. package/dist/probe-Caa2HznF.js +0 -6328
  951. package/dist/probe-CfL4tnJ6.js +0 -129
  952. package/dist/probe-auth-DN2Ec83-.js +0 -38
  953. package/dist/probe-auth-D_UKzu4m.js +0 -48
  954. package/dist/program-BOMdC7MC.js +0 -247
  955. package/dist/prompt-select-styled-DDnCfM3j.js +0 -2673
  956. package/dist/provider-api-key-auth.runtime-DUns3fwX.js +0 -116
  957. package/dist/provider-auth-choice-B_j1ctT2.js +0 -126
  958. package/dist/provider-auth-choice-preference-BaOBZ_Xn.js +0 -189
  959. package/dist/provider-auth-choice.runtime-DOako_zV.js +0 -118
  960. package/dist/provider-auth-guidance-CrjxnoNZ.js +0 -34
  961. package/dist/provider-runtime.runtime-BkOkgmTw.js +0 -106
  962. package/dist/provider-self-hosted-setup-BFDU6dRa.js +0 -182
  963. package/dist/provider-usage-CaDE0mqq.js +0 -106
  964. package/dist/provider-web-search-BR7etTjJ.js +0 -2392
  965. package/dist/provider-wizard-DCPdKUvb.js +0 -152
  966. package/dist/push-apns-B_OZjm4v.js +0 -1038
  967. package/dist/pw-ai-dG60P0hQ.js +0 -1866
  968. package/dist/qr-cli-DWfiw79I.js +0 -369
  969. package/dist/qr-cli-DwuKtyZQ.js +0 -108
  970. package/dist/reactions-CIGAPBn8.js +0 -281
  971. package/dist/read-only-account-inspect.discord.runtime-D54mnq8l.js +0 -111
  972. package/dist/read-only-account-inspect.slack.runtime-Bxs9ObMC.js +0 -111
  973. package/dist/read-only-account-inspect.telegram.runtime-UoVuf_Yo.js +0 -111
  974. package/dist/redact-snapshot-DZ3Vq-SC.js +0 -2657
  975. package/dist/ref-contract-D96lSYLs.js +0 -53
  976. package/dist/register.agent-2KmeahEL.js +0 -434
  977. package/dist/register.backup-ECBnWVR7.js +0 -624
  978. package/dist/register.configure-Doz1daCp.js +0 -247
  979. package/dist/register.maintenance-C33cV-WM.js +0 -569
  980. package/dist/register.message-CnL0NiF6.js +0 -704
  981. package/dist/register.onboard-BrYGZeQA.js +0 -187
  982. package/dist/register.setup-Bx6gEg6X.js +0 -207
  983. package/dist/register.status-health-sessions-FLb0CUOO.js +0 -493
  984. package/dist/register.subclis-BuqgaeIf.js +0 -12
  985. package/dist/register.subclis-DwdgfdnT.js +0 -315
  986. package/dist/registry-xhgvU89y.js +0 -1107
  987. package/dist/replies-hB2aipLu.js +0 -110
  988. package/dist/resolve-3ErMOltL.js +0 -660
  989. package/dist/resolve-channels-BV8GXuPe.js +0 -226
  990. package/dist/resolve-channels-CTY_XRIP.js +0 -262
  991. package/dist/resolve-users-DQ4Ne4Zc.js +0 -143
  992. package/dist/routes-BNDsNO_e.js +0 -7097
  993. package/dist/rpc-BLGTBWXq.js +0 -67
  994. package/dist/run-main-COAE4GlI.js +0 -423
  995. package/dist/runtime-discord-ops.runtime-Dxg-nlgd.js +0 -9073
  996. package/dist/runtime-slack-ops.runtime-Di474LJr.js +0 -4551
  997. package/dist/runtime-telegram-ops.runtime-Da8vgf3O.js +0 -128
  998. package/dist/runtime-whatsapp-login.runtime-DcouP4iF.js +0 -109
  999. package/dist/runtime-whatsapp-outbound.runtime-CYamaEJX.js +0 -112
  1000. package/dist/sandbox-cli-U5ZTxhxL.js +0 -530
  1001. package/dist/search-manager-CfizyEMk.js +0 -386
  1002. package/dist/search-manager-DaF2QP4s.js +0 -15
  1003. package/dist/secrets-cli-C0gytFip.js +0 -2065
  1004. package/dist/security-cli-C74EuLUO.js +0 -570
  1005. package/dist/send-BTLVBf_E.js +0 -631
  1006. package/dist/send-BlWWCEZE.js +0 -1025
  1007. package/dist/send-CfypD1B_.js +0 -100
  1008. package/dist/send-Cm9v3uhF.js +0 -283
  1009. package/dist/send-g2odQuYI.js +0 -629
  1010. package/dist/server-C8b5QJ2s.js +0 -106
  1011. package/dist/server-node-events-xqQe5xiu.js +0 -501
  1012. package/dist/sessions-CSSzvgPQ.js +0 -107
  1013. package/dist/sessions-z0GIvdKa.js +0 -218
  1014. package/dist/setup-D9XTmlF8.js +0 -387
  1015. package/dist/setup-core-BDrLOwYO.js +0 -143
  1016. package/dist/setup-core-CM7cY7_i.js +0 -166
  1017. package/dist/setup-core-CnmgANY-.js +0 -205
  1018. package/dist/setup-core-DgcjCKmG.js +0 -47
  1019. package/dist/setup-surface-DzRrVKYj.js +0 -490
  1020. package/dist/setup.finalize-UaPu_adv.js +0 -517
  1021. package/dist/setup.gateway-config-Djc1ceEh.js +0 -338
  1022. package/dist/setup.secret-input-BkczghbR.js +0 -25
  1023. package/dist/shared-BHizGoNk.js +0 -298
  1024. package/dist/shared-CUfYhQkP.js +0 -96
  1025. package/dist/shared-DYYqr9EC.js +0 -75
  1026. package/dist/shared-DthOxMRQ.js +0 -182
  1027. package/dist/shared-On_A5_hW.js +0 -102
  1028. package/dist/signal-D6px9PGZ.js +0 -109
  1029. package/dist/skills-B4h1k-SP.js +0 -853
  1030. package/dist/skills-Bto10BGB.js +0 -19
  1031. package/dist/skills-cli-CXGR3Y5j.js +0 -291
  1032. package/dist/skills-install-B1AlkK8C.js +0 -763
  1033. package/dist/skills-status-BsmJ_iSg.js +0 -20
  1034. package/dist/skills-status-DGdxY3OI.js +0 -169
  1035. package/dist/slack-B7vWFmxP.js +0 -109
  1036. package/dist/slash-commands.runtime-DXdAT84n.js +0 -123
  1037. package/dist/slash-dispatch.runtime-CNf2-9Aj.js +0 -136
  1038. package/dist/slash-skill-commands.runtime-CBjffHRX.js +0 -111
  1039. package/dist/src-Cp7P7T08.js +0 -1696
  1040. package/dist/status-158fWh4A.js +0 -43
  1041. package/dist/status-BJIVLJnb.js +0 -1599
  1042. package/dist/status-BQiBI6N9.js +0 -126
  1043. package/dist/status-CZipXGUu.js +0 -121
  1044. package/dist/status-ZZIVFLI-.js +0 -606
  1045. package/dist/status-json-BNUy5Mem.js +0 -286
  1046. package/dist/status.link-channel-B694y1Xu.js +0 -138
  1047. package/dist/status.scan.deps.runtime-BcoKEzQD.js +0 -121
  1048. package/dist/status.scan.runtime-CqScDt-p.js +0 -114
  1049. package/dist/status.summary-AMek7qvI.js +0 -592
  1050. package/dist/status.summary.runtime-XgkcQ_kr.js +0 -113
  1051. package/dist/subagent-orphan-recovery-CrCYTmFC.js +0 -302
  1052. package/dist/subagent-registry-runtime-Cg-YvLx3.js +0 -106
  1053. package/dist/synology-chat-0G85jIqQ.js +0 -297
  1054. package/dist/system-cli-kZtSxKNm.js +0 -92
  1055. package/dist/telegram-DV0Wy89w.js +0 -109
  1056. package/dist/text-chunking-C2J2Oeul.js +0 -84
  1057. package/dist/tlon-DmK1NUVP.js +0 -433
  1058. package/dist/tui-D3bNPLG7.js +0 -3834
  1059. package/dist/tui-cli-DtMp9k_s.js +0 -132
  1060. package/dist/types.secrets-DuSPmmWB.js +0 -80
  1061. package/dist/ui-CeGztSEL.js +0 -31
  1062. package/dist/update-De7VudzP.js +0 -1036
  1063. package/dist/update-cli-BH8Pb-So.js +0 -1498
  1064. package/dist/update-offset-store-syELkdEW.js +0 -107
  1065. package/dist/update-runner-Cq-Q40T9.js +0 -1496
  1066. package/dist/web-CjMtvfSq.js +0 -107
  1067. package/dist/webhook-targets-_jTR0Bb_.js +0 -181
  1068. package/dist/webhooks-cli-DQ6u2Qau.js +0 -349
  1069. package/dist/whatsapp-CyLk16SZ.js +0 -109
  1070. package/dist/whatsapp-actions-Dzr2Wzqw.js +0 -162
  1071. package/dist/workspace-dirs-L1_QQ9mB.js +0 -2002
  1072. package/dist/zalo-CrehfXvK.js +0 -415
  1073. package/dist/zalouser-D1QD-O-I.js +0 -30911
  1074. package/dist/zod-schema.core-CWxzqcUs.js +0 -541
@@ -0,0 +1,2065 @@
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 { m as defaultRuntime } from "./subsystem-S4LNMNHd.js";
10
+ import "./ansi-BPhP6LBZ.js";
11
+ import "./boolean-D8Ha5nYV.js";
12
+ import "./env-Dgex_t9p.js";
13
+ import "./warning-filter-gJuwHM7C.js";
14
+ import { g as resolveConfigDir, y as resolveUserPath } from "./utils-rjVNXUns.js";
15
+ import { t as formatDocsLink } from "./links-C5I443Xb.js";
16
+ import { y as resolveAuthStorePath } from "./setup-binary-Fw3cCSWL.js";
17
+ 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-9zZdaXJK.js";
18
+ import { w as normalizeProviderId } from "./model-selection-DfA4esOK.js";
19
+ import { a as resolveAgentDir, i as resolveAgentConfig, m as resolveDefaultAgentId, r as listAgentIds } from "./agent-scope-DA7O8MVG.js";
20
+ import { c as normalizeAgentId } from "./session-key-DyhRsRh-.js";
21
+ import "./boundary-file-read-Y1cMjPlu.js";
22
+ import "./logger-wrbK9-ju.js";
23
+ import "./exec-CoBTyh8B.js";
24
+ import "./workspace-CxNKYS0V.js";
25
+ import { i as createConfigIO } from "./io-C6XifaT4.js";
26
+ import "./host-env-security-xy11yVnm.js";
27
+ import "./safe-text-BcUvBreN.js";
28
+ import "./version-rW_3ob2o.js";
29
+ import { d as resolveSecretInputRef, i as coerceSecretRef } from "./types.secrets-Bojc4omL.js";
30
+ import "./env-substitution-C9xZMTDL.js";
31
+ import "./config-state-D1JkXt39.js";
32
+ import "./network-mode-CE-ihBf6.js";
33
+ import { t as isSafeExecutableValue } from "./exec-safety-DZmujax0.js";
34
+ import "./registry-DcDGl2X7.js";
35
+ import "./manifest-registry-_0xclaVY.js";
36
+ import "./ip-w605xvSx.js";
37
+ import { a as formatExecSecretRefIdValidationMessage, c as isValidSecretProviderAlias, l as resolveDefaultSecretProviderAlias, o as isValidExecSecretRefId, u as secretRefKey } from "./ref-contract-RPkB754Q.js";
38
+ import { C as SecretProviderSchema } from "./zod-schema.core-D5reNip6.js";
39
+ import "./config-B2W1zTP1.js";
40
+ import "./audit-fs-SjcfoPO7.js";
41
+ import { t as runTasksWithConcurrency } from "./run-with-concurrency-7GDKtTZb.js";
42
+ import { i as resolveSecretRefValues, r as resolveSecretRefValue, t as isProviderScopedSecretResolutionError } from "./resolve-BbsCHGLY.js";
43
+ import { a as parseDotPath, c as writeTextFileAtomic, n as isNonEmptyString, o as parseEnvValue, r as isRecord, s as toDotPath, t as describeUnknownError } from "./shared-BX98rtIr.js";
44
+ import "./provider-web-search-BJhXD5dH.js";
45
+ import "./text-runtime-CgEQ9Y9_.js";
46
+ import "./workspace-dirs-d3Ms_ryk.js";
47
+ import "./config-CMhKplgO.js";
48
+ import "./tailnet-KyAU6tj_.js";
49
+ import "./net-B_Iq_SVP.js";
50
+ import "./credentials-yYt6VWCq.js";
51
+ import "./routes-BZtqNrBf.js";
52
+ import "./frontmatter-BTDAgsA3.js";
53
+ import "./env-overrides-DYVIkuvN.js";
54
+ import "./path-alias-guards-B3ZKrId1.js";
55
+ import "./skills-4-r1mfJM.js";
56
+ import "./ports-BVwQuCIR.js";
57
+ import "./ports-lsof-DiY6GaAf.js";
58
+ import "./ssh-tunnel-BaHTFPzH.js";
59
+ import "./image-ops-Uw4rEShL.js";
60
+ import "./fs-safe-Da4H0IOU.js";
61
+ import "./mime-_IkgFMS2.js";
62
+ import "./server-middleware-BPq4bu3A.js";
63
+ import "./message-channel-CKeDAoOT.js";
64
+ import "./resolve-route-IkBfMjBz.js";
65
+ import "./internal-hooks-0x1JiQ5f.js";
66
+ import "./lazy-runtime-DdzFA4b9.js";
67
+ import "./config-schema-pPBCF4hz.js";
68
+ import "./method-scopes-Du8ODGFW.js";
69
+ import "./session-cost-usage-B-57mlS8.js";
70
+ import "./paths-CDWV-9nX.js";
71
+ import "./routing-3o2D0ix4.js";
72
+ import "./send-BRRtHxyR.js";
73
+ import "./node-resolve-CupmrA0Y.js";
74
+ import "./provider-stream-gVymYPmd.js";
75
+ import "./identity-file-DM4N5_7H.js";
76
+ import "./provider-models-BA3hqqPq.js";
77
+ import "./secret-file-Bjh19aoH.js";
78
+ import "./logging-BdFqMomc.js";
79
+ import "./runtime-env-CT-voxYE.js";
80
+ import { d as PROVIDER_ENV_VARS, p as listKnownSecretEnvVarNames } from "./registry-Dgwc-7eS.js";
81
+ import "./provider-onboard-CBC3kdk_.js";
82
+ import "./model-definitions-DwehIMlw.js";
83
+ import "./diagnostic-CkiYEGqt.js";
84
+ import "./message-hook-mappers-DORrSLHM.js";
85
+ import "./json-store-DlpyvQXN.js";
86
+ import "./call-DYFR7oGy.js";
87
+ import "./multimodal-BWF8MRkz.js";
88
+ import "./memory-search-BBG2BKIh.js";
89
+ import "./query-expansion-8R79qExs.js";
90
+ import "./search-manager-DxkQvUrW.js";
91
+ import "./core-EKuk2FxR.js";
92
+ import "./issue-format-i6sEuV4a.js";
93
+ import "./logging-BhqLWxTD.js";
94
+ import "./note-z78_JyNp.js";
95
+ import "./state-paths-C7dX__ql.js";
96
+ import "./config-value-Dl3XEpA6.js";
97
+ 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-CO_lZ_ZZ.js";
98
+ import "./brave-CljenznH.js";
99
+ import "./provider-usage-DzuzbNBv.js";
100
+ import "./perplexity-Bw1u3CAF.js";
101
+ import "./restart-stale-pids-CN9ElYwR.js";
102
+ import "./delivery-queue-DLjFP-0C.js";
103
+ import "./pairing-token-ANLRyJSu.js";
104
+ import "./accounts-BCaV8MsT.js";
105
+ import "./process-runtime-CicRKAFe.js";
106
+ import "./audit-hdKa3D-u.js";
107
+ import "./cli-runtime-DtIDS2w7.js";
108
+ import "./cli-utils-FHeUZLsT.js";
109
+ import "./help-format-1yV2Xzq7.js";
110
+ import "./progress-BQSTKUhd.js";
111
+ import "./gateway-runtime-D9FRZqKP.js";
112
+ import { n as callGatewayFromCli, t as addGatewayClientOptions } from "./gateway-rpc-CroQg9MB.js";
113
+ import fs from "node:fs";
114
+ import path from "node:path";
115
+ import os from "node:os";
116
+ import { isDeepStrictEqual } from "node:util";
117
+ import { confirm, select, text } from "@clack/prompts";
118
+ //#region src/secrets/auth-profiles-scan.ts
119
+ function getAuthProfileFieldName(pathPattern) {
120
+ const segments = pathPattern.split(".").filter(Boolean);
121
+ return segments[segments.length - 1] ?? "";
122
+ }
123
+ const AUTH_PROFILE_FIELD_SPEC_BY_TYPE = (() => {
124
+ const defaults = {
125
+ api_key: {
126
+ valueField: "key",
127
+ refField: "keyRef"
128
+ },
129
+ token: {
130
+ valueField: "token",
131
+ refField: "tokenRef"
132
+ }
133
+ };
134
+ for (const target of listAuthProfileSecretTargetEntries()) {
135
+ if (!target.authProfileType) continue;
136
+ defaults[target.authProfileType] = {
137
+ valueField: getAuthProfileFieldName(target.pathPattern),
138
+ refField: target.refPathPattern !== void 0 ? getAuthProfileFieldName(target.refPathPattern) : defaults[target.authProfileType].refField
139
+ };
140
+ }
141
+ return defaults;
142
+ })();
143
+ function getAuthProfileFieldSpec(type) {
144
+ return AUTH_PROFILE_FIELD_SPEC_BY_TYPE[type];
145
+ }
146
+ function toSecretCredentialVisit(params) {
147
+ const spec = getAuthProfileFieldSpec(params.kind);
148
+ return {
149
+ kind: params.kind,
150
+ profileId: params.profileId,
151
+ provider: params.provider,
152
+ profile: params.profile,
153
+ valueField: spec.valueField,
154
+ refField: spec.refField,
155
+ value: params.profile[spec.valueField],
156
+ refValue: params.profile[spec.refField]
157
+ };
158
+ }
159
+ function* iterateAuthProfileCredentials(profiles) {
160
+ for (const [profileId, value] of Object.entries(profiles)) {
161
+ if (!isRecord(value) || !isNonEmptyString(value.provider)) continue;
162
+ const provider = String(value.provider);
163
+ if (value.type === "api_key" || value.type === "token") {
164
+ yield toSecretCredentialVisit({
165
+ kind: value.type,
166
+ profileId,
167
+ provider,
168
+ profile: value
169
+ });
170
+ continue;
171
+ }
172
+ if (value.type === "oauth") yield {
173
+ kind: "oauth",
174
+ profileId,
175
+ provider,
176
+ profile: value,
177
+ hasAccess: isNonEmptyString(value.access),
178
+ hasRefresh: isNonEmptyString(value.refresh)
179
+ };
180
+ }
181
+ }
182
+ //#endregion
183
+ //#region src/secrets/config-io.ts
184
+ const silentConfigIoLogger = {
185
+ error: () => {},
186
+ warn: () => {}
187
+ };
188
+ function createSecretsConfigIO(params) {
189
+ return createConfigIO({
190
+ env: params.env,
191
+ logger: silentConfigIoLogger
192
+ });
193
+ }
194
+ //#endregion
195
+ //#region src/secrets/plan.ts
196
+ const FORBIDDEN_PATH_SEGMENTS = new Set([
197
+ "__proto__",
198
+ "prototype",
199
+ "constructor"
200
+ ]);
201
+ function isObjectRecord(value) {
202
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
203
+ }
204
+ function isSecretProviderConfigShape(value) {
205
+ return SecretProviderSchema.safeParse(value).success;
206
+ }
207
+ function hasForbiddenPathSegment(segments) {
208
+ return segments.some((segment) => FORBIDDEN_PATH_SEGMENTS.has(segment));
209
+ }
210
+ function resolveValidatedPlanTarget(candidate) {
211
+ if (!isKnownSecretTargetType(candidate.type)) return null;
212
+ const path = typeof candidate.path === "string" ? candidate.path.trim() : "";
213
+ if (!path) return null;
214
+ const segments = Array.isArray(candidate.pathSegments) && candidate.pathSegments.length > 0 ? candidate.pathSegments.map((segment) => String(segment).trim()).filter(Boolean) : parseDotPath(path);
215
+ if (segments.length === 0 || hasForbiddenPathSegment(segments) || path !== toDotPath(segments)) return null;
216
+ return resolvePlanTargetAgainstRegistry({
217
+ type: candidate.type,
218
+ pathSegments: segments,
219
+ providerId: candidate.providerId,
220
+ accountId: candidate.accountId
221
+ });
222
+ }
223
+ function isSecretsApplyPlan(value) {
224
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
225
+ const typed = value;
226
+ if (typed.version !== 1 || typed.protocolVersion !== 1 || !Array.isArray(typed.targets)) return false;
227
+ for (const target of typed.targets) {
228
+ if (!target || typeof target !== "object") return false;
229
+ const candidate = target;
230
+ const ref = candidate.ref;
231
+ const resolved = resolveValidatedPlanTarget({
232
+ type: candidate.type,
233
+ path: candidate.path,
234
+ pathSegments: candidate.pathSegments,
235
+ agentId: candidate.agentId,
236
+ providerId: candidate.providerId,
237
+ accountId: candidate.accountId,
238
+ authProfileProvider: candidate.authProfileProvider
239
+ });
240
+ 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;
241
+ if (resolved.entry.configFile === "auth-profiles.json") {
242
+ if (typeof candidate.agentId !== "string" || candidate.agentId.trim().length === 0) return false;
243
+ if (candidate.authProfileProvider !== void 0 && (typeof candidate.authProfileProvider !== "string" || candidate.authProfileProvider.trim().length === 0)) return false;
244
+ }
245
+ }
246
+ if (typed.providerUpserts !== void 0) {
247
+ if (!isObjectRecord(typed.providerUpserts)) return false;
248
+ for (const [providerAlias, providerValue] of Object.entries(typed.providerUpserts)) {
249
+ if (!isValidSecretProviderAlias(providerAlias)) return false;
250
+ if (!isSecretProviderConfigShape(providerValue)) return false;
251
+ }
252
+ }
253
+ if (typed.providerDeletes !== void 0) {
254
+ if (!Array.isArray(typed.providerDeletes) || typed.providerDeletes.some((providerAlias) => typeof providerAlias !== "string" || !isValidSecretProviderAlias(providerAlias))) return false;
255
+ }
256
+ return true;
257
+ }
258
+ function normalizeSecretsPlanOptions(options) {
259
+ return {
260
+ scrubEnv: options?.scrubEnv ?? true,
261
+ scrubAuthProfilesForProviderTargets: options?.scrubAuthProfilesForProviderTargets ?? true,
262
+ scrubLegacyAuthJson: options?.scrubLegacyAuthJson ?? true
263
+ };
264
+ }
265
+ //#endregion
266
+ //#region src/secrets/auth-store-paths.ts
267
+ function listAuthProfileStorePaths$1(config, stateDir) {
268
+ const paths = /* @__PURE__ */ new Set();
269
+ paths.add(path.join(resolveUserPath(stateDir), "agents", "main", "agent", "auth-profiles.json"));
270
+ const agentsRoot = path.join(resolveUserPath(stateDir), "agents");
271
+ if (fs.existsSync(agentsRoot)) for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true })) {
272
+ if (!entry.isDirectory()) continue;
273
+ paths.add(path.join(agentsRoot, entry.name, "agent", "auth-profiles.json"));
274
+ }
275
+ for (const agentId of listAgentIds(config)) {
276
+ if (agentId === "main") {
277
+ paths.add(path.join(resolveUserPath(stateDir), "agents", "main", "agent", "auth-profiles.json"));
278
+ continue;
279
+ }
280
+ const agentDir = resolveAgentDir(config, agentId);
281
+ paths.add(resolveUserPath(resolveAuthStorePath(agentDir)));
282
+ }
283
+ return [...paths];
284
+ }
285
+ //#endregion
286
+ //#region src/secrets/storage-scan.ts
287
+ function parseEnvAssignmentValue(raw) {
288
+ return parseEnvValue(raw);
289
+ }
290
+ function listAuthProfileStorePaths(config, stateDir) {
291
+ return listAuthProfileStorePaths$1(config, stateDir);
292
+ }
293
+ function listLegacyAuthJsonPaths(stateDir) {
294
+ const out = [];
295
+ const agentsRoot = path.join(resolveUserPath(stateDir), "agents");
296
+ if (!fs.existsSync(agentsRoot)) return out;
297
+ for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true })) {
298
+ if (!entry.isDirectory()) continue;
299
+ const candidate = path.join(agentsRoot, entry.name, "agent", "auth.json");
300
+ if (fs.existsSync(candidate)) out.push(candidate);
301
+ }
302
+ return out;
303
+ }
304
+ function resolveActiveAgentDir(stateDir, env = process.env) {
305
+ const override = env.MOLDCLAW_AGENT_DIR?.trim() || env.PI_CODING_AGENT_DIR?.trim();
306
+ if (override) return resolveUserPath(override);
307
+ return path.join(resolveUserPath(stateDir), "agents", "main", "agent");
308
+ }
309
+ function listAgentModelsJsonPaths(config, stateDir, env = process.env) {
310
+ const resolvedStateDir = resolveUserPath(stateDir);
311
+ const paths = /* @__PURE__ */ new Set();
312
+ paths.add(path.join(resolvedStateDir, "agents", "main", "agent", "models.json"));
313
+ paths.add(path.join(resolveActiveAgentDir(stateDir, env), "models.json"));
314
+ const agentsRoot = path.join(resolvedStateDir, "agents");
315
+ if (fs.existsSync(agentsRoot)) for (const entry of fs.readdirSync(agentsRoot, { withFileTypes: true })) {
316
+ if (!entry.isDirectory()) continue;
317
+ paths.add(path.join(agentsRoot, entry.name, "agent", "models.json"));
318
+ }
319
+ for (const agentId of listAgentIds(config)) {
320
+ if (agentId === "main") {
321
+ paths.add(path.join(resolvedStateDir, "agents", "main", "agent", "models.json"));
322
+ continue;
323
+ }
324
+ const agentDir = resolveAgentDir(config, agentId);
325
+ paths.add(path.join(resolveUserPath(agentDir), "models.json"));
326
+ }
327
+ return [...paths];
328
+ }
329
+ function readJsonObjectIfExists(filePath, options = {}) {
330
+ if (!fs.existsSync(filePath)) return { value: null };
331
+ try {
332
+ const stats = fs.statSync(filePath);
333
+ if (options.requireRegularFile && !stats.isFile()) return {
334
+ value: null,
335
+ error: `Refusing to read non-regular file: ${filePath}`
336
+ };
337
+ if (typeof options.maxBytes === "number" && Number.isFinite(options.maxBytes) && options.maxBytes >= 0 && stats.size > options.maxBytes) return {
338
+ value: null,
339
+ error: `Refusing to read oversized JSON (${stats.size} bytes): ${filePath}`
340
+ };
341
+ const raw = fs.readFileSync(filePath, "utf8");
342
+ const parsed = JSON.parse(raw);
343
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return { value: null };
344
+ return { value: parsed };
345
+ } catch (err) {
346
+ return {
347
+ value: null,
348
+ error: err instanceof Error ? err.message : String(err)
349
+ };
350
+ }
351
+ }
352
+ //#endregion
353
+ //#region src/secrets/apply.ts
354
+ function resolveTarget(target) {
355
+ const resolved = resolveValidatedPlanTarget(target);
356
+ if (!resolved) throw new Error(`Invalid plan target path for ${target.type}: ${target.path}`);
357
+ return resolved;
358
+ }
359
+ function scrubEnvRaw(raw, migratedValues, allowedEnvKeys) {
360
+ if (migratedValues.size === 0 || allowedEnvKeys.size === 0) return {
361
+ nextRaw: raw,
362
+ removed: 0
363
+ };
364
+ const lines = raw.split(/\r?\n/);
365
+ const nextLines = [];
366
+ let removed = 0;
367
+ for (const line of lines) {
368
+ const match = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
369
+ if (!match) {
370
+ nextLines.push(line);
371
+ continue;
372
+ }
373
+ const envKey = match[1] ?? "";
374
+ if (!allowedEnvKeys.has(envKey)) {
375
+ nextLines.push(line);
376
+ continue;
377
+ }
378
+ const parsedValue = parseEnvAssignmentValue(match[2] ?? "");
379
+ if (migratedValues.has(parsedValue)) {
380
+ removed += 1;
381
+ continue;
382
+ }
383
+ nextLines.push(line);
384
+ }
385
+ const hadTrailingNewline = raw.endsWith("\n");
386
+ const joined = nextLines.join("\n");
387
+ return {
388
+ nextRaw: hadTrailingNewline || joined.length === 0 ? `${joined}${joined.endsWith("\n") ? "" : "\n"}` : joined,
389
+ removed
390
+ };
391
+ }
392
+ function applyProviderPlanMutations(params) {
393
+ const currentProviders = isRecord(params.config.secrets?.providers) ? structuredClone(params.config.secrets?.providers) : {};
394
+ let changed = false;
395
+ for (const providerAlias of params.deletes ?? []) {
396
+ if (!Object.prototype.hasOwnProperty.call(currentProviders, providerAlias)) continue;
397
+ delete currentProviders[providerAlias];
398
+ changed = true;
399
+ }
400
+ for (const [providerAlias, providerConfig] of Object.entries(params.upserts ?? {})) {
401
+ const previous = currentProviders[providerAlias];
402
+ if (isDeepStrictEqual(previous, providerConfig)) continue;
403
+ currentProviders[providerAlias] = structuredClone(providerConfig);
404
+ changed = true;
405
+ }
406
+ if (!changed) return false;
407
+ params.config.secrets ??= {};
408
+ if (Object.keys(currentProviders).length === 0) {
409
+ if ("providers" in params.config.secrets) delete params.config.secrets.providers;
410
+ return true;
411
+ }
412
+ params.config.secrets.providers = currentProviders;
413
+ return true;
414
+ }
415
+ async function projectPlanState(params) {
416
+ const { snapshot, writeOptions } = await createSecretsConfigIO({ env: params.env }).readConfigFileSnapshotForWrite();
417
+ if (!snapshot.valid) throw new Error("Cannot apply secrets plan: config is invalid.");
418
+ const options = normalizeSecretsPlanOptions(params.plan.options);
419
+ const nextConfig = structuredClone(snapshot.config);
420
+ const stateDir = resolveStateDir(params.env, os.homedir);
421
+ const changedFiles = /* @__PURE__ */ new Set();
422
+ const warnings = [];
423
+ const configPath = resolveUserPath(snapshot.path);
424
+ if (applyProviderPlanMutations({
425
+ config: nextConfig,
426
+ upserts: params.plan.providerUpserts,
427
+ deletes: params.plan.providerDeletes
428
+ })) changedFiles.add(configPath);
429
+ const targetMutations = applyConfigTargetMutations({
430
+ planTargets: params.plan.targets,
431
+ nextConfig,
432
+ stateDir,
433
+ authStoreByPath: /* @__PURE__ */ new Map(),
434
+ changedFiles
435
+ });
436
+ if (targetMutations.configChanged) changedFiles.add(configPath);
437
+ const authStoreByPath = scrubAuthStoresForProviderTargets({
438
+ nextConfig,
439
+ stateDir,
440
+ providerTargets: targetMutations.providerTargets,
441
+ scrubbedValues: targetMutations.scrubbedValues,
442
+ authStoreByPath: targetMutations.authStoreByPath,
443
+ changedFiles,
444
+ warnings,
445
+ enabled: options.scrubAuthProfilesForProviderTargets
446
+ });
447
+ const authJsonByPath = scrubLegacyAuthJsonStores({
448
+ stateDir,
449
+ changedFiles,
450
+ enabled: options.scrubLegacyAuthJson
451
+ });
452
+ const envRawByPath = scrubEnvFiles({
453
+ env: params.env,
454
+ scrubbedValues: targetMutations.scrubbedValues,
455
+ changedFiles,
456
+ enabled: options.scrubEnv
457
+ });
458
+ await validateProjectedSecretsState({
459
+ env: params.env,
460
+ nextConfig,
461
+ resolvedTargets: targetMutations.resolvedTargets,
462
+ authStoreByPath
463
+ });
464
+ return {
465
+ nextConfig,
466
+ configPath,
467
+ configWriteOptions: writeOptions,
468
+ authStoreByPath,
469
+ authJsonByPath,
470
+ envRawByPath,
471
+ changedFiles,
472
+ warnings
473
+ };
474
+ }
475
+ function applyConfigTargetMutations(params) {
476
+ const resolvedTargets = params.planTargets.map((target) => ({
477
+ target,
478
+ resolved: resolveTarget(target)
479
+ }));
480
+ const scrubbedValues = /* @__PURE__ */ new Set();
481
+ const providerTargets = /* @__PURE__ */ new Set();
482
+ let configChanged = false;
483
+ for (const { target, resolved } of resolvedTargets) {
484
+ if (resolved.entry.configFile === "auth-profiles.json") {
485
+ if (applyAuthProfileTargetMutation({
486
+ target,
487
+ resolved,
488
+ nextConfig: params.nextConfig,
489
+ stateDir: params.stateDir,
490
+ authStoreByPath: params.authStoreByPath,
491
+ scrubbedValues
492
+ })) {
493
+ const agentId = String(target.agentId ?? "").trim();
494
+ if (!agentId) throw new Error(`Missing required agentId for auth-profiles target ${target.path}.`);
495
+ params.changedFiles.add(resolveAuthStorePathForAgent({
496
+ nextConfig: params.nextConfig,
497
+ stateDir: params.stateDir,
498
+ agentId
499
+ }));
500
+ }
501
+ continue;
502
+ }
503
+ const targetPathSegments = resolved.pathSegments;
504
+ if (resolved.entry.secretShape === "sibling_ref") {
505
+ const previous = getPath(params.nextConfig, targetPathSegments);
506
+ if (isNonEmptyString(previous)) scrubbedValues.add(previous.trim());
507
+ const refPathSegments = resolved.refPathSegments;
508
+ if (!refPathSegments) throw new Error(`Missing sibling ref path for target ${target.type}.`);
509
+ const wroteRef = setPathCreateStrict(params.nextConfig, refPathSegments, target.ref);
510
+ const deletedLegacy = deletePathStrict(params.nextConfig, targetPathSegments);
511
+ if (wroteRef || deletedLegacy) configChanged = true;
512
+ continue;
513
+ }
514
+ const previous = getPath(params.nextConfig, targetPathSegments);
515
+ if (isNonEmptyString(previous)) scrubbedValues.add(previous.trim());
516
+ if (setPathCreateStrict(params.nextConfig, targetPathSegments, target.ref)) configChanged = true;
517
+ if (resolved.entry.trackProviderShadowing && resolved.providerId) providerTargets.add(normalizeProviderId(resolved.providerId));
518
+ }
519
+ return {
520
+ resolvedTargets,
521
+ scrubbedValues,
522
+ providerTargets,
523
+ configChanged,
524
+ authStoreByPath: params.authStoreByPath
525
+ };
526
+ }
527
+ function scrubAuthStoresForProviderTargets(params) {
528
+ if (!params.enabled || params.providerTargets.size === 0) return params.authStoreByPath;
529
+ for (const authStorePath of listAuthProfileStorePaths(params.nextConfig, params.stateDir)) {
530
+ const parsed = params.authStoreByPath.get(authStorePath) ?? readJsonObjectIfExists(authStorePath).value;
531
+ if (!parsed || !isRecord(parsed.profiles)) continue;
532
+ const nextStore = structuredClone(parsed);
533
+ let mutated = false;
534
+ for (const profile of iterateAuthProfileCredentials(nextStore.profiles)) {
535
+ const provider = normalizeProviderId(profile.provider);
536
+ if (!params.providerTargets.has(provider)) continue;
537
+ if (profile.kind === "api_key" || profile.kind === "token") {
538
+ if (isNonEmptyString(profile.value)) params.scrubbedValues.add(profile.value.trim());
539
+ if (profile.valueField in profile.profile) {
540
+ delete profile.profile[profile.valueField];
541
+ mutated = true;
542
+ }
543
+ if (profile.refField in profile.profile) {
544
+ delete profile.profile[profile.refField];
545
+ mutated = true;
546
+ }
547
+ continue;
548
+ }
549
+ 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.`);
550
+ }
551
+ if (mutated) {
552
+ params.authStoreByPath.set(authStorePath, nextStore);
553
+ params.changedFiles.add(authStorePath);
554
+ }
555
+ }
556
+ return params.authStoreByPath;
557
+ }
558
+ function ensureMutableAuthStore(store) {
559
+ const next = store ? structuredClone(store) : {};
560
+ if (!isRecord(next.profiles)) next.profiles = {};
561
+ if (typeof next.version !== "number" || !Number.isFinite(next.version)) next.version = 1;
562
+ return next;
563
+ }
564
+ function resolveAuthStoreForTarget(params) {
565
+ const agentId = String(params.target.agentId ?? "").trim();
566
+ if (!agentId) throw new Error(`Missing required agentId for auth-profiles target ${params.target.path}.`);
567
+ const authStorePath = resolveAuthStorePathForAgent({
568
+ nextConfig: params.nextConfig,
569
+ stateDir: params.stateDir,
570
+ agentId
571
+ });
572
+ const loaded = params.authStoreByPath.get(authStorePath) ?? readJsonObjectIfExists(authStorePath).value;
573
+ const store = ensureMutableAuthStore(isRecord(loaded) ? loaded : void 0);
574
+ params.authStoreByPath.set(authStorePath, store);
575
+ return {
576
+ path: authStorePath,
577
+ store
578
+ };
579
+ }
580
+ function asConfigPathRoot(store) {
581
+ return store;
582
+ }
583
+ function resolveAuthStorePathForAgent(params) {
584
+ const normalizedAgentId = normalizeAgentId(params.agentId);
585
+ const configuredAgentDir = resolveAgentConfig(params.nextConfig, normalizedAgentId)?.agentDir?.trim();
586
+ if (configuredAgentDir) return resolveUserPath(resolveAuthStorePath(configuredAgentDir));
587
+ return path.join(resolveUserPath(params.stateDir), "agents", normalizedAgentId, "agent", "auth-profiles.json");
588
+ }
589
+ function ensureAuthProfileContainer(params) {
590
+ let changed = false;
591
+ const profilePathSegments = params.resolved.pathSegments.slice(0, 2);
592
+ const profileId = profilePathSegments[1];
593
+ if (!profileId) throw new Error(`Invalid auth profile target path: ${params.target.path}`);
594
+ const current = getPath(params.store, profilePathSegments);
595
+ const expectedType = params.resolved.entry.authProfileType;
596
+ if (isRecord(current)) {
597
+ 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}".`);
598
+ if (!isNonEmptyString(current.provider) && isNonEmptyString(params.target.authProfileProvider)) {
599
+ const wroteProvider = setPathCreateStrict(asConfigPathRoot(params.store), [...profilePathSegments, "provider"], params.target.authProfileProvider);
600
+ changed = changed || wroteProvider;
601
+ }
602
+ return changed;
603
+ }
604
+ if (!expectedType) throw new Error(`Auth profile target ${params.target.path} is missing auth profile type metadata.`);
605
+ const provider = String(params.target.authProfileProvider ?? "").trim();
606
+ if (!provider) throw new Error(`Cannot create auth profile "${profileId}" for ${params.target.path} without authProfileProvider.`);
607
+ const wroteProfile = setPathCreateStrict(asConfigPathRoot(params.store), profilePathSegments, {
608
+ type: expectedType,
609
+ provider
610
+ });
611
+ changed = changed || wroteProfile;
612
+ return changed;
613
+ }
614
+ function applyAuthProfileTargetMutation(params) {
615
+ if (params.resolved.entry.configFile !== "auth-profiles.json") return false;
616
+ const { store } = resolveAuthStoreForTarget({
617
+ target: params.target,
618
+ nextConfig: params.nextConfig,
619
+ stateDir: params.stateDir,
620
+ authStoreByPath: params.authStoreByPath
621
+ });
622
+ let changed = ensureAuthProfileContainer({
623
+ target: params.target,
624
+ resolved: params.resolved,
625
+ store
626
+ });
627
+ const targetPathSegments = params.resolved.pathSegments;
628
+ if (params.resolved.entry.secretShape === "sibling_ref") {
629
+ const previous = getPath(store, targetPathSegments);
630
+ if (isNonEmptyString(previous)) params.scrubbedValues.add(previous.trim());
631
+ const refPathSegments = params.resolved.refPathSegments;
632
+ if (!refPathSegments) throw new Error(`Missing sibling ref path for auth-profiles target ${params.target.path}.`);
633
+ const wroteRef = setPathCreateStrict(asConfigPathRoot(store), refPathSegments, params.target.ref);
634
+ const deletedPlaintext = deletePathStrict(asConfigPathRoot(store), targetPathSegments);
635
+ changed = changed || wroteRef || deletedPlaintext;
636
+ return changed;
637
+ }
638
+ const previous = getPath(store, targetPathSegments);
639
+ if (isNonEmptyString(previous)) params.scrubbedValues.add(previous.trim());
640
+ const wroteRef = setPathCreateStrict(asConfigPathRoot(store), targetPathSegments, params.target.ref);
641
+ changed = changed || wroteRef;
642
+ return changed;
643
+ }
644
+ function scrubLegacyAuthJsonStores(params) {
645
+ const authJsonByPath = /* @__PURE__ */ new Map();
646
+ if (!params.enabled) return authJsonByPath;
647
+ for (const authJsonPath of listLegacyAuthJsonPaths(params.stateDir)) {
648
+ const parsed = readJsonObjectIfExists(authJsonPath).value;
649
+ if (!parsed) continue;
650
+ let mutated = false;
651
+ const nextParsed = structuredClone(parsed);
652
+ for (const [providerId, value] of Object.entries(nextParsed)) {
653
+ if (!isRecord(value)) continue;
654
+ if (value.type === "api_key" && isNonEmptyString(value.key)) {
655
+ delete nextParsed[providerId];
656
+ mutated = true;
657
+ }
658
+ }
659
+ if (mutated) {
660
+ authJsonByPath.set(authJsonPath, nextParsed);
661
+ params.changedFiles.add(authJsonPath);
662
+ }
663
+ }
664
+ return authJsonByPath;
665
+ }
666
+ function scrubEnvFiles(params) {
667
+ const envRawByPath = /* @__PURE__ */ new Map();
668
+ if (!params.enabled || params.scrubbedValues.size === 0) return envRawByPath;
669
+ const envPath = path.join(resolveConfigDir(params.env, os.homedir), ".env");
670
+ if (!fs.existsSync(envPath)) return envRawByPath;
671
+ const current = fs.readFileSync(envPath, "utf8");
672
+ const scrubbed = scrubEnvRaw(current, params.scrubbedValues, new Set(listKnownSecretEnvVarNames()));
673
+ if (scrubbed.removed > 0 && scrubbed.nextRaw !== current) {
674
+ envRawByPath.set(envPath, scrubbed.nextRaw);
675
+ params.changedFiles.add(envPath);
676
+ }
677
+ return envRawByPath;
678
+ }
679
+ async function validateProjectedSecretsState(params) {
680
+ const cache = {};
681
+ for (const { target, resolved: resolvedTarget } of params.resolvedTargets) assertExpectedResolvedSecretValue({
682
+ value: await resolveSecretRefValue(target.ref, {
683
+ config: params.nextConfig,
684
+ env: params.env,
685
+ cache
686
+ }),
687
+ expected: resolvedTarget.entry.expectedResolvedValue,
688
+ 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.`
689
+ });
690
+ const authStoreLookup = /* @__PURE__ */ new Map();
691
+ for (const [authStorePath, store] of params.authStoreByPath.entries()) authStoreLookup.set(resolveUserPath(authStorePath), store);
692
+ await prepareSecretsRuntimeSnapshot({
693
+ config: params.nextConfig,
694
+ env: params.env,
695
+ loadAuthStore: (agentDir) => {
696
+ const storePath = resolveUserPath(resolveAuthStorePath(agentDir));
697
+ const override = authStoreLookup.get(storePath);
698
+ if (override) return structuredClone(override);
699
+ return loadAuthProfileStoreForSecretsRuntime(agentDir);
700
+ }
701
+ });
702
+ }
703
+ function captureFileSnapshot(pathname) {
704
+ if (!fs.existsSync(pathname)) return {
705
+ existed: false,
706
+ content: "",
707
+ mode: 384
708
+ };
709
+ const stat = fs.statSync(pathname);
710
+ return {
711
+ existed: true,
712
+ content: fs.readFileSync(pathname, "utf8"),
713
+ mode: stat.mode & 511
714
+ };
715
+ }
716
+ function restoreFileSnapshot(pathname, snapshot) {
717
+ if (!snapshot.existed) {
718
+ if (fs.existsSync(pathname)) fs.rmSync(pathname, { force: true });
719
+ return;
720
+ }
721
+ writeTextFileAtomic(pathname, snapshot.content, snapshot.mode || 384);
722
+ }
723
+ function toJsonWrite(pathname, value) {
724
+ return {
725
+ path: pathname,
726
+ content: `${JSON.stringify(value, null, 2)}\n`,
727
+ mode: 384
728
+ };
729
+ }
730
+ async function runSecretsApply(params) {
731
+ const env = params.env ?? process.env;
732
+ const projected = await projectPlanState({
733
+ plan: params.plan,
734
+ env
735
+ });
736
+ const changedFiles = [...projected.changedFiles].toSorted();
737
+ if (!params.write) return {
738
+ mode: "dry-run",
739
+ changed: changedFiles.length > 0,
740
+ changedFiles,
741
+ warningCount: projected.warnings.length,
742
+ warnings: projected.warnings
743
+ };
744
+ if (changedFiles.length === 0) return {
745
+ mode: "write",
746
+ changed: false,
747
+ changedFiles: [],
748
+ warningCount: projected.warnings.length,
749
+ warnings: projected.warnings
750
+ };
751
+ const io = createSecretsConfigIO({ env });
752
+ const snapshots = /* @__PURE__ */ new Map();
753
+ const capture = (pathname) => {
754
+ if (!snapshots.has(pathname)) snapshots.set(pathname, captureFileSnapshot(pathname));
755
+ };
756
+ capture(projected.configPath);
757
+ const writes = [];
758
+ for (const [pathname, value] of projected.authStoreByPath.entries()) {
759
+ capture(pathname);
760
+ writes.push(toJsonWrite(pathname, value));
761
+ }
762
+ for (const [pathname, value] of projected.authJsonByPath.entries()) {
763
+ capture(pathname);
764
+ writes.push(toJsonWrite(pathname, value));
765
+ }
766
+ for (const [pathname, raw] of projected.envRawByPath.entries()) {
767
+ capture(pathname);
768
+ writes.push({
769
+ path: pathname,
770
+ content: raw,
771
+ mode: 384
772
+ });
773
+ }
774
+ try {
775
+ await io.writeConfigFile(projected.nextConfig, projected.configWriteOptions);
776
+ for (const write of writes) writeTextFileAtomic(write.path, write.content, write.mode);
777
+ } catch (err) {
778
+ for (const [pathname, snapshot] of snapshots.entries()) try {
779
+ restoreFileSnapshot(pathname, snapshot);
780
+ } catch {}
781
+ throw new Error(`Secrets apply failed: ${String(err)}`, { cause: err });
782
+ }
783
+ return {
784
+ mode: "write",
785
+ changed: changedFiles.length > 0,
786
+ changedFiles,
787
+ warningCount: projected.warnings.length,
788
+ warnings: projected.warnings
789
+ };
790
+ }
791
+ //#endregion
792
+ //#region src/secrets/audit.ts
793
+ const REF_RESOLVE_FALLBACK_CONCURRENCY = 8;
794
+ const MAX_AUDIT_MODELS_JSON_BYTES = 5 * 1024 * 1024;
795
+ const ALWAYS_SENSITIVE_MODEL_PROVIDER_HEADER_NAMES = new Set([
796
+ "authorization",
797
+ "proxy-authorization",
798
+ "x-api-key",
799
+ "api-key",
800
+ "apikey",
801
+ "x-auth-token",
802
+ "auth-token",
803
+ "x-access-token",
804
+ "access-token",
805
+ "x-secret-key",
806
+ "secret-key"
807
+ ]);
808
+ const SENSITIVE_MODEL_PROVIDER_HEADER_NAME_FRAGMENTS = [
809
+ "api-key",
810
+ "apikey",
811
+ "token",
812
+ "secret",
813
+ "password",
814
+ "credential"
815
+ ];
816
+ function isLikelySensitiveModelProviderHeaderName(value) {
817
+ const normalized = value.trim().toLowerCase();
818
+ if (!normalized) return false;
819
+ if (ALWAYS_SENSITIVE_MODEL_PROVIDER_HEADER_NAMES.has(normalized)) return true;
820
+ return SENSITIVE_MODEL_PROVIDER_HEADER_NAME_FRAGMENTS.some((fragment) => normalized.includes(fragment));
821
+ }
822
+ function addFinding(collector, finding) {
823
+ collector.findings.push(finding);
824
+ }
825
+ function collectProviderRefPath(collector, providerId, configPath) {
826
+ const key = normalizeProviderId(providerId);
827
+ const existing = collector.configProviderRefPaths.get(key);
828
+ if (existing) {
829
+ existing.push(configPath);
830
+ return;
831
+ }
832
+ collector.configProviderRefPaths.set(key, [configPath]);
833
+ }
834
+ function trackAuthProviderState(collector, provider, mode) {
835
+ const key = normalizeProviderId(provider);
836
+ const existing = collector.authProviderState.get(key);
837
+ if (existing) {
838
+ existing.hasUsableStaticOrOAuth = true;
839
+ existing.modes.add(mode);
840
+ return;
841
+ }
842
+ collector.authProviderState.set(key, {
843
+ hasUsableStaticOrOAuth: true,
844
+ modes: new Set([mode])
845
+ });
846
+ }
847
+ function collectEnvPlaintext(params) {
848
+ if (!fs.existsSync(params.envPath)) return;
849
+ params.collector.filesScanned.add(params.envPath);
850
+ const knownKeys = new Set(listKnownSecretEnvVarNames());
851
+ const lines = fs.readFileSync(params.envPath, "utf8").split(/\r?\n/);
852
+ for (const line of lines) {
853
+ const match = line.match(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/);
854
+ if (!match) continue;
855
+ const key = match[1] ?? "";
856
+ if (!knownKeys.has(key)) continue;
857
+ if (!parseEnvAssignmentValue(match[2] ?? "")) continue;
858
+ addFinding(params.collector, {
859
+ code: "PLAINTEXT_FOUND",
860
+ severity: "warn",
861
+ file: params.envPath,
862
+ jsonPath: `$env.${key}`,
863
+ message: `Potential secret found in .env (${key}).`
864
+ });
865
+ }
866
+ }
867
+ function collectConfigSecrets(params) {
868
+ const defaults = params.config.secrets?.defaults;
869
+ for (const target of discoverConfigSecretTargets(params.config)) {
870
+ if (!target.entry.includeInAudit) continue;
871
+ const { ref } = resolveSecretInputRef({
872
+ value: target.value,
873
+ refValue: target.refValue,
874
+ defaults
875
+ });
876
+ if (ref) {
877
+ params.collector.refAssignments.push({
878
+ file: params.configPath,
879
+ path: target.path,
880
+ ref,
881
+ expected: target.entry.expectedResolvedValue,
882
+ provider: target.providerId
883
+ });
884
+ if (target.entry.trackProviderShadowing && target.providerId) collectProviderRefPath(params.collector, target.providerId, target.path);
885
+ continue;
886
+ }
887
+ const hasPlaintext = hasConfiguredPlaintextSecretValue(target.value, target.entry.expectedResolvedValue);
888
+ if (target.entry.id === "models.providers.*.headers.*" && !isLikelySensitiveModelProviderHeaderName(target.pathSegments.at(-1) ?? "")) continue;
889
+ if (!hasPlaintext) continue;
890
+ addFinding(params.collector, {
891
+ code: "PLAINTEXT_FOUND",
892
+ severity: "warn",
893
+ file: params.configPath,
894
+ jsonPath: target.path,
895
+ message: `${target.path} is stored as plaintext.`,
896
+ provider: target.providerId
897
+ });
898
+ }
899
+ }
900
+ function collectAuthStoreSecrets(params) {
901
+ if (!fs.existsSync(params.authStorePath)) return;
902
+ params.collector.filesScanned.add(params.authStorePath);
903
+ const parsedResult = readJsonObjectIfExists(params.authStorePath);
904
+ if (parsedResult.error) {
905
+ addFinding(params.collector, {
906
+ code: "REF_UNRESOLVED",
907
+ severity: "error",
908
+ file: params.authStorePath,
909
+ jsonPath: "<root>",
910
+ message: `Invalid JSON in auth-profiles store: ${parsedResult.error}`
911
+ });
912
+ return;
913
+ }
914
+ const parsed = parsedResult.value;
915
+ if (!parsed || !isRecord(parsed.profiles)) return;
916
+ for (const entry of iterateAuthProfileCredentials(parsed.profiles)) {
917
+ if (entry.kind === "api_key" || entry.kind === "token") {
918
+ const { ref } = resolveSecretInputRef({
919
+ value: entry.value,
920
+ refValue: entry.refValue,
921
+ defaults: params.defaults
922
+ });
923
+ if (ref) {
924
+ params.collector.refAssignments.push({
925
+ file: params.authStorePath,
926
+ path: `profiles.${entry.profileId}.${entry.valueField}`,
927
+ ref,
928
+ expected: "string",
929
+ provider: entry.provider
930
+ });
931
+ trackAuthProviderState(params.collector, entry.provider, entry.kind);
932
+ }
933
+ if (isNonEmptyString(entry.value)) {
934
+ addFinding(params.collector, {
935
+ code: "PLAINTEXT_FOUND",
936
+ severity: "warn",
937
+ file: params.authStorePath,
938
+ jsonPath: `profiles.${entry.profileId}.${entry.valueField}`,
939
+ message: entry.kind === "api_key" ? "Auth profile API key is stored as plaintext." : "Auth profile token is stored as plaintext.",
940
+ provider: entry.provider,
941
+ profileId: entry.profileId
942
+ });
943
+ trackAuthProviderState(params.collector, entry.provider, entry.kind);
944
+ }
945
+ continue;
946
+ }
947
+ if (entry.hasAccess || entry.hasRefresh) {
948
+ addFinding(params.collector, {
949
+ code: "LEGACY_RESIDUE",
950
+ severity: "info",
951
+ file: params.authStorePath,
952
+ jsonPath: `profiles.${entry.profileId}`,
953
+ message: "OAuth credentials are present (out of scope for static SecretRef migration).",
954
+ provider: entry.provider,
955
+ profileId: entry.profileId
956
+ });
957
+ trackAuthProviderState(params.collector, entry.provider, "oauth");
958
+ }
959
+ }
960
+ }
961
+ function collectAuthJsonResidue(params) {
962
+ for (const authJsonPath of listLegacyAuthJsonPaths(params.stateDir)) {
963
+ params.collector.filesScanned.add(authJsonPath);
964
+ const parsedResult = readJsonObjectIfExists(authJsonPath);
965
+ if (parsedResult.error) {
966
+ addFinding(params.collector, {
967
+ code: "REF_UNRESOLVED",
968
+ severity: "error",
969
+ file: authJsonPath,
970
+ jsonPath: "<root>",
971
+ message: `Invalid JSON in legacy auth.json: ${parsedResult.error}`
972
+ });
973
+ continue;
974
+ }
975
+ const parsed = parsedResult.value;
976
+ if (!parsed) continue;
977
+ for (const [providerId, value] of Object.entries(parsed)) {
978
+ if (!isRecord(value)) continue;
979
+ if (value.type === "api_key" && isNonEmptyString(value.key)) addFinding(params.collector, {
980
+ code: "LEGACY_RESIDUE",
981
+ severity: "warn",
982
+ file: authJsonPath,
983
+ jsonPath: providerId,
984
+ message: "Legacy auth.json contains static api_key credentials.",
985
+ provider: providerId
986
+ });
987
+ }
988
+ }
989
+ }
990
+ function collectModelsJsonSecrets(params) {
991
+ if (!fs.existsSync(params.modelsJsonPath)) return;
992
+ params.collector.filesScanned.add(params.modelsJsonPath);
993
+ const parsedResult = readJsonObjectIfExists(params.modelsJsonPath, {
994
+ requireRegularFile: true,
995
+ maxBytes: MAX_AUDIT_MODELS_JSON_BYTES
996
+ });
997
+ if (parsedResult.error) {
998
+ addFinding(params.collector, {
999
+ code: "REF_UNRESOLVED",
1000
+ severity: "error",
1001
+ file: params.modelsJsonPath,
1002
+ jsonPath: "<root>",
1003
+ message: `Invalid JSON in models.json: ${parsedResult.error}`
1004
+ });
1005
+ return;
1006
+ }
1007
+ const parsed = parsedResult.value;
1008
+ if (!parsed || !isRecord(parsed.providers)) return;
1009
+ for (const [providerId, providerValue] of Object.entries(parsed.providers)) {
1010
+ if (!isRecord(providerValue)) continue;
1011
+ const apiKey = providerValue.apiKey;
1012
+ if (coerceSecretRef(apiKey)) addFinding(params.collector, {
1013
+ code: "REF_UNRESOLVED",
1014
+ severity: "error",
1015
+ file: params.modelsJsonPath,
1016
+ jsonPath: `providers.${providerId}.apiKey`,
1017
+ message: "models.json contains an unresolved SecretRef object; regenerate models.json.",
1018
+ provider: providerId
1019
+ });
1020
+ else if (isNonEmptyString(apiKey) && !isNonSecretApiKeyMarker(apiKey)) addFinding(params.collector, {
1021
+ code: "PLAINTEXT_FOUND",
1022
+ severity: "warn",
1023
+ file: params.modelsJsonPath,
1024
+ jsonPath: `providers.${providerId}.apiKey`,
1025
+ message: "models.json provider apiKey is stored as plaintext.",
1026
+ provider: providerId
1027
+ });
1028
+ const headers = isRecord(providerValue.headers) ? providerValue.headers : void 0;
1029
+ if (!headers) continue;
1030
+ for (const [headerKey, headerValue] of Object.entries(headers)) {
1031
+ const headerPath = `providers.${providerId}.headers.${headerKey}`;
1032
+ if (coerceSecretRef(headerValue)) {
1033
+ addFinding(params.collector, {
1034
+ code: "REF_UNRESOLVED",
1035
+ severity: "error",
1036
+ file: params.modelsJsonPath,
1037
+ jsonPath: headerPath,
1038
+ message: "models.json contains an unresolved SecretRef object for provider headers; regenerate models.json.",
1039
+ provider: providerId
1040
+ });
1041
+ continue;
1042
+ }
1043
+ if (!isNonEmptyString(headerValue)) continue;
1044
+ if (isSecretRefHeaderValueMarker(headerValue)) continue;
1045
+ if (!isLikelySensitiveModelProviderHeaderName(headerKey)) continue;
1046
+ addFinding(params.collector, {
1047
+ code: "PLAINTEXT_FOUND",
1048
+ severity: "warn",
1049
+ file: params.modelsJsonPath,
1050
+ jsonPath: headerPath,
1051
+ message: "models.json provider header value is stored as plaintext.",
1052
+ provider: providerId
1053
+ });
1054
+ }
1055
+ }
1056
+ }
1057
+ async function collectUnresolvedRefFindings(params) {
1058
+ const cache = {};
1059
+ const refsByProvider = /* @__PURE__ */ new Map();
1060
+ for (const assignment of params.collector.refAssignments) {
1061
+ const providerKey = `${assignment.ref.source}:${assignment.ref.provider}`;
1062
+ let refsForProvider = refsByProvider.get(providerKey);
1063
+ if (!refsForProvider) {
1064
+ refsForProvider = /* @__PURE__ */ new Map();
1065
+ refsByProvider.set(providerKey, refsForProvider);
1066
+ }
1067
+ refsForProvider.set(secretRefKey(assignment.ref), assignment.ref);
1068
+ }
1069
+ const resolvedByRefKey = /* @__PURE__ */ new Map();
1070
+ const errorsByRefKey = /* @__PURE__ */ new Map();
1071
+ for (const refsForProvider of refsByProvider.values()) {
1072
+ const refs = [...refsForProvider.values()];
1073
+ const provider = refs[0]?.provider;
1074
+ try {
1075
+ const resolved = await resolveSecretRefValues(refs, {
1076
+ config: params.config,
1077
+ env: params.env,
1078
+ cache
1079
+ });
1080
+ for (const [key, value] of resolved.entries()) resolvedByRefKey.set(key, value);
1081
+ continue;
1082
+ } catch (err) {
1083
+ if (provider && isProviderScopedSecretResolutionError(err)) {
1084
+ for (const ref of refs) errorsByRefKey.set(secretRefKey(ref), err);
1085
+ continue;
1086
+ }
1087
+ }
1088
+ const fallback = await runTasksWithConcurrency({
1089
+ tasks: refs.map((ref) => async () => ({
1090
+ key: secretRefKey(ref),
1091
+ resolved: await resolveSecretRefValue(ref, {
1092
+ config: params.config,
1093
+ env: params.env,
1094
+ cache
1095
+ })
1096
+ })),
1097
+ limit: Math.min(REF_RESOLVE_FALLBACK_CONCURRENCY, refs.length),
1098
+ errorMode: "continue",
1099
+ onTaskError: (error, index) => {
1100
+ const ref = refs[index];
1101
+ if (!ref) return;
1102
+ errorsByRefKey.set(secretRefKey(ref), error);
1103
+ }
1104
+ });
1105
+ for (const result of fallback.results) {
1106
+ if (!result) continue;
1107
+ resolvedByRefKey.set(result.key, result.resolved);
1108
+ }
1109
+ }
1110
+ for (const assignment of params.collector.refAssignments) {
1111
+ const key = secretRefKey(assignment.ref);
1112
+ const resolveErr = errorsByRefKey.get(key);
1113
+ if (resolveErr) {
1114
+ addFinding(params.collector, {
1115
+ code: "REF_UNRESOLVED",
1116
+ severity: "error",
1117
+ file: assignment.file,
1118
+ jsonPath: assignment.path,
1119
+ message: `Failed to resolve ${assignment.ref.source}:${assignment.ref.provider}:${assignment.ref.id} (${describeUnknownError(resolveErr)}).`,
1120
+ provider: assignment.provider
1121
+ });
1122
+ continue;
1123
+ }
1124
+ if (!resolvedByRefKey.has(key)) {
1125
+ addFinding(params.collector, {
1126
+ code: "REF_UNRESOLVED",
1127
+ severity: "error",
1128
+ file: assignment.file,
1129
+ jsonPath: assignment.path,
1130
+ message: `Failed to resolve ${assignment.ref.source}:${assignment.ref.provider}:${assignment.ref.id} (resolved value is missing).`,
1131
+ provider: assignment.provider
1132
+ });
1133
+ continue;
1134
+ }
1135
+ if (!isExpectedResolvedSecretValue(resolvedByRefKey.get(key), assignment.expected)) addFinding(params.collector, {
1136
+ code: "REF_UNRESOLVED",
1137
+ severity: "error",
1138
+ file: assignment.file,
1139
+ jsonPath: assignment.path,
1140
+ 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).`,
1141
+ provider: assignment.provider
1142
+ });
1143
+ }
1144
+ }
1145
+ function collectShadowingFindings(collector) {
1146
+ for (const [provider, paths] of collector.configProviderRefPaths.entries()) {
1147
+ const authState = collector.authProviderState.get(provider);
1148
+ if (!authState?.hasUsableStaticOrOAuth) continue;
1149
+ const modeText = [...authState.modes].join("/");
1150
+ for (const configPath of paths) addFinding(collector, {
1151
+ code: "REF_SHADOWED",
1152
+ severity: "warn",
1153
+ file: "moldclaw.json",
1154
+ jsonPath: configPath,
1155
+ message: `Auth profile credentials (${modeText}) take precedence for provider "${provider}", so this config ref may never be used.`,
1156
+ provider
1157
+ });
1158
+ }
1159
+ }
1160
+ function summarizeFindings(findings) {
1161
+ return {
1162
+ plaintextCount: findings.filter((entry) => entry.code === "PLAINTEXT_FOUND").length,
1163
+ unresolvedRefCount: findings.filter((entry) => entry.code === "REF_UNRESOLVED").length,
1164
+ shadowedRefCount: findings.filter((entry) => entry.code === "REF_SHADOWED").length,
1165
+ legacyResidueCount: findings.filter((entry) => entry.code === "LEGACY_RESIDUE").length
1166
+ };
1167
+ }
1168
+ async function runSecretsAudit(params = {}) {
1169
+ const env = params.env ?? process.env;
1170
+ const snapshot = await createSecretsConfigIO({ env }).readConfigFileSnapshot();
1171
+ const configPath = resolveUserPath(snapshot.path);
1172
+ const defaults = snapshot.valid ? snapshot.config.secrets?.defaults : void 0;
1173
+ const collector = {
1174
+ findings: [],
1175
+ refAssignments: [],
1176
+ configProviderRefPaths: /* @__PURE__ */ new Map(),
1177
+ authProviderState: /* @__PURE__ */ new Map(),
1178
+ filesScanned: new Set([configPath])
1179
+ };
1180
+ const stateDir = resolveStateDir(env, os.homedir);
1181
+ const envPath = path.join(resolveConfigDir(env, os.homedir), ".env");
1182
+ const config = snapshot.valid ? snapshot.config : {};
1183
+ if (snapshot.valid) {
1184
+ collectConfigSecrets({
1185
+ config,
1186
+ configPath,
1187
+ collector
1188
+ });
1189
+ for (const authStorePath of listAuthProfileStorePaths(config, stateDir)) collectAuthStoreSecrets({
1190
+ authStorePath,
1191
+ collector,
1192
+ defaults
1193
+ });
1194
+ for (const modelsJsonPath of listAgentModelsJsonPaths(config, stateDir, env)) collectModelsJsonSecrets({
1195
+ modelsJsonPath,
1196
+ collector
1197
+ });
1198
+ await collectUnresolvedRefFindings({
1199
+ collector,
1200
+ config,
1201
+ env
1202
+ });
1203
+ collectShadowingFindings(collector);
1204
+ } else addFinding(collector, {
1205
+ code: "REF_UNRESOLVED",
1206
+ severity: "error",
1207
+ file: configPath,
1208
+ jsonPath: "<root>",
1209
+ message: "Config is invalid; cannot validate secret references reliably."
1210
+ });
1211
+ collectEnvPlaintext({
1212
+ envPath,
1213
+ collector
1214
+ });
1215
+ collectAuthJsonResidue({
1216
+ stateDir,
1217
+ collector
1218
+ });
1219
+ const summary = summarizeFindings(collector.findings);
1220
+ return {
1221
+ version: 1,
1222
+ status: summary.unresolvedRefCount > 0 ? "unresolved" : collector.findings.length > 0 ? "findings" : "clean",
1223
+ filesScanned: [...collector.filesScanned].toSorted(),
1224
+ summary,
1225
+ findings: collector.findings
1226
+ };
1227
+ }
1228
+ function resolveSecretsAuditExitCode(report, check) {
1229
+ if (report.summary.unresolvedRefCount > 0) return 2;
1230
+ if (check && report.findings.length > 0) return 1;
1231
+ return 0;
1232
+ }
1233
+ //#endregion
1234
+ //#region src/secrets/configure-plan.ts
1235
+ function getSecretProviders$1(config) {
1236
+ if (!isRecord(config.secrets?.providers)) return {};
1237
+ return config.secrets.providers;
1238
+ }
1239
+ function configureCandidateSortKey(candidate) {
1240
+ if (candidate.configFile === "auth-profiles.json") return `auth-profiles:${candidate.agentId ?? ""}:${candidate.path}`;
1241
+ return `moldclaw:${candidate.path}`;
1242
+ }
1243
+ function resolveAuthProfileProvider(store, pathSegments) {
1244
+ const profileId = pathSegments[1];
1245
+ if (!profileId) return;
1246
+ const profile = store.profiles?.[profileId];
1247
+ if (!isRecord(profile) || typeof profile.provider !== "string") return;
1248
+ const provider = profile.provider.trim();
1249
+ return provider.length > 0 ? provider : void 0;
1250
+ }
1251
+ function buildConfigureCandidatesForScope(params) {
1252
+ const authoredConfig = params.authoredmoldClawConfig ?? params.config;
1253
+ const hasPathInAuthoredConfig = (pathSegments) => hasPath(authoredConfig, pathSegments);
1254
+ const moldclawCandidates = discoverConfigSecretTargets(params.config).filter((entry) => entry.entry.includeInConfigure).map((entry) => {
1255
+ const resolved = resolveSecretInputRef({
1256
+ value: entry.value,
1257
+ refValue: entry.refValue,
1258
+ defaults: params.config.secrets?.defaults
1259
+ });
1260
+ const pathExists = hasPathInAuthoredConfig(entry.pathSegments);
1261
+ const refPathExists = entry.refPathSegments ? hasPathInAuthoredConfig(entry.refPathSegments) : false;
1262
+ return {
1263
+ type: entry.entry.targetType,
1264
+ path: entry.path,
1265
+ pathSegments: [...entry.pathSegments],
1266
+ label: entry.path,
1267
+ configFile: "moldclaw.json",
1268
+ expectedResolvedValue: entry.entry.expectedResolvedValue,
1269
+ ...resolved.ref ? { existingRef: resolved.ref } : {},
1270
+ ...pathExists || refPathExists ? {} : { isDerived: true },
1271
+ ...entry.providerId ? { providerId: entry.providerId } : {},
1272
+ ...entry.accountId ? { accountId: entry.accountId } : {}
1273
+ };
1274
+ });
1275
+ const authCandidates = params.authProfiles === void 0 ? [] : discoverAuthProfileSecretTargets(params.authProfiles.store).filter((entry) => entry.entry.includeInConfigure).map((entry) => {
1276
+ const authProfiles = params.authProfiles;
1277
+ if (!authProfiles) throw new Error("Missing auth profile scope for configure candidate discovery.");
1278
+ const authProfileProvider = resolveAuthProfileProvider(authProfiles.store, entry.pathSegments);
1279
+ const resolved = resolveSecretInputRef({
1280
+ value: entry.value,
1281
+ refValue: entry.refValue,
1282
+ defaults: params.config.secrets?.defaults
1283
+ });
1284
+ return {
1285
+ type: entry.entry.targetType,
1286
+ path: entry.path,
1287
+ pathSegments: [...entry.pathSegments],
1288
+ label: `${entry.path} (auth profile, agent ${authProfiles.agentId})`,
1289
+ configFile: "auth-profiles.json",
1290
+ expectedResolvedValue: entry.entry.expectedResolvedValue,
1291
+ ...resolved.ref ? { existingRef: resolved.ref } : {},
1292
+ agentId: authProfiles.agentId,
1293
+ ...authProfileProvider ? { authProfileProvider } : {}
1294
+ };
1295
+ });
1296
+ return [...moldclawCandidates, ...authCandidates].toSorted((a, b) => configureCandidateSortKey(a).localeCompare(configureCandidateSortKey(b)));
1297
+ }
1298
+ function hasPath(root, segments) {
1299
+ if (segments.length === 0) return false;
1300
+ let cursor = root;
1301
+ for (let index = 0; index < segments.length; index += 1) {
1302
+ const segment = segments[index] ?? "";
1303
+ if (Array.isArray(cursor)) {
1304
+ if (!/^\d+$/.test(segment)) return false;
1305
+ const parsedIndex = Number.parseInt(segment, 10);
1306
+ if (!Number.isFinite(parsedIndex) || parsedIndex < 0 || parsedIndex >= cursor.length) return false;
1307
+ if (index === segments.length - 1) return true;
1308
+ cursor = cursor[parsedIndex];
1309
+ continue;
1310
+ }
1311
+ if (!isRecord(cursor)) return false;
1312
+ if (!Object.prototype.hasOwnProperty.call(cursor, segment)) return false;
1313
+ if (index === segments.length - 1) return true;
1314
+ cursor = cursor[segment];
1315
+ }
1316
+ return false;
1317
+ }
1318
+ function collectConfigureProviderChanges(params) {
1319
+ const originalProviders = getSecretProviders$1(params.original);
1320
+ const nextProviders = getSecretProviders$1(params.next);
1321
+ const upserts = {};
1322
+ const deletes = [];
1323
+ for (const [providerAlias, nextProviderConfig] of Object.entries(nextProviders)) {
1324
+ const current = originalProviders[providerAlias];
1325
+ if (isDeepStrictEqual(current, nextProviderConfig)) continue;
1326
+ upserts[providerAlias] = structuredClone(nextProviderConfig);
1327
+ }
1328
+ for (const providerAlias of Object.keys(originalProviders)) if (!Object.prototype.hasOwnProperty.call(nextProviders, providerAlias)) deletes.push(providerAlias);
1329
+ return {
1330
+ upserts,
1331
+ deletes: deletes.toSorted()
1332
+ };
1333
+ }
1334
+ function hasConfigurePlanChanges(params) {
1335
+ return params.selectedTargets.size > 0 || Object.keys(params.providerChanges.upserts).length > 0 || params.providerChanges.deletes.length > 0;
1336
+ }
1337
+ function buildSecretsConfigurePlan(params) {
1338
+ return {
1339
+ version: 1,
1340
+ protocolVersion: 1,
1341
+ generatedAt: params.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1342
+ generatedBy: "moldclaw secrets configure",
1343
+ targets: [...params.selectedTargets.values()].map((entry) => ({
1344
+ type: entry.type,
1345
+ path: entry.path,
1346
+ pathSegments: [...entry.pathSegments],
1347
+ ref: entry.ref,
1348
+ ...entry.agentId ? { agentId: entry.agentId } : {},
1349
+ ...entry.providerId ? { providerId: entry.providerId } : {},
1350
+ ...entry.accountId ? { accountId: entry.accountId } : {},
1351
+ ...entry.authProfileProvider ? { authProfileProvider: entry.authProfileProvider } : {}
1352
+ })),
1353
+ ...Object.keys(params.providerChanges.upserts).length > 0 ? { providerUpserts: params.providerChanges.upserts } : {},
1354
+ ...params.providerChanges.deletes.length > 0 ? { providerDeletes: params.providerChanges.deletes } : {},
1355
+ options: {
1356
+ scrubEnv: true,
1357
+ scrubAuthProfilesForProviderTargets: true,
1358
+ scrubLegacyAuthJson: true
1359
+ }
1360
+ };
1361
+ }
1362
+ //#endregion
1363
+ //#region src/secrets/configure.ts
1364
+ const ENV_NAME_PATTERN = /^[A-Z][A-Z0-9_]{0,127}$/;
1365
+ const WINDOWS_ABS_PATH_PATTERN = /^[A-Za-z]:[\\/]/;
1366
+ const WINDOWS_UNC_PATH_PATTERN = /^\\\\[^\\]+\\[^\\]+/;
1367
+ function isAbsolutePathValue(value) {
1368
+ return path.isAbsolute(value) || WINDOWS_ABS_PATH_PATTERN.test(value) || WINDOWS_UNC_PATH_PATTERN.test(value);
1369
+ }
1370
+ function parseCsv(value) {
1371
+ return value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
1372
+ }
1373
+ function parseOptionalPositiveInt(value, max) {
1374
+ const trimmed = value.trim();
1375
+ if (!trimmed) return;
1376
+ if (!/^\d+$/.test(trimmed)) return;
1377
+ const parsed = Number.parseInt(trimmed, 10);
1378
+ if (!Number.isFinite(parsed) || parsed <= 0 || parsed > max) return;
1379
+ return parsed;
1380
+ }
1381
+ function getSecretProviders(config) {
1382
+ if (!isRecord(config.secrets?.providers)) return {};
1383
+ return config.secrets.providers;
1384
+ }
1385
+ function setSecretProvider(config, providerAlias, providerConfig) {
1386
+ config.secrets ??= {};
1387
+ if (!isRecord(config.secrets.providers)) config.secrets.providers = {};
1388
+ config.secrets.providers[providerAlias] = providerConfig;
1389
+ }
1390
+ function removeSecretProvider(config, providerAlias) {
1391
+ if (!isRecord(config.secrets?.providers)) return false;
1392
+ const providers = config.secrets.providers;
1393
+ if (!Object.prototype.hasOwnProperty.call(providers, providerAlias)) return false;
1394
+ delete providers[providerAlias];
1395
+ if (Object.keys(providers).length === 0) delete config.secrets?.providers;
1396
+ if (isRecord(config.secrets?.defaults)) {
1397
+ const defaults = config.secrets.defaults;
1398
+ if (defaults?.env === providerAlias) delete defaults.env;
1399
+ if (defaults?.file === providerAlias) delete defaults.file;
1400
+ if (defaults?.exec === providerAlias) delete defaults.exec;
1401
+ if (defaults && defaults.env === void 0 && defaults.file === void 0 && defaults.exec === void 0) delete config.secrets?.defaults;
1402
+ }
1403
+ return true;
1404
+ }
1405
+ function providerHint(provider) {
1406
+ if (provider.source === "env") return provider.allowlist?.length ? `env (${provider.allowlist.length} allowlisted)` : "env";
1407
+ if (provider.source === "file") return `file (${provider.mode ?? "json"})`;
1408
+ return `exec (${provider.jsonOnly === false ? "json+text" : "json"})`;
1409
+ }
1410
+ function toSourceChoices(config) {
1411
+ const hasSource = (source) => Object.values(config.secrets?.providers ?? {}).some((provider) => provider?.source === source);
1412
+ const choices = [{
1413
+ value: "env",
1414
+ label: "env"
1415
+ }];
1416
+ if (hasSource("file")) choices.push({
1417
+ value: "file",
1418
+ label: "file"
1419
+ });
1420
+ if (hasSource("exec")) choices.push({
1421
+ value: "exec",
1422
+ label: "exec"
1423
+ });
1424
+ return choices;
1425
+ }
1426
+ function assertNoCancel(value, message) {
1427
+ if (typeof value === "symbol") throw new Error(message);
1428
+ return value;
1429
+ }
1430
+ const AUTH_PROFILE_ID_PATTERN = /^[A-Za-z0-9:_-]{1,128}$/;
1431
+ function validateEnvNameCsv(value) {
1432
+ const entries = parseCsv(value);
1433
+ for (const entry of entries) if (!ENV_NAME_PATTERN.test(entry)) return `Invalid env name: ${entry}`;
1434
+ }
1435
+ async function promptEnvNameCsv(params) {
1436
+ const raw = assertNoCancel(await text({
1437
+ message: params.message,
1438
+ initialValue: params.initialValue,
1439
+ validate: (value) => validateEnvNameCsv(String(value ?? ""))
1440
+ }), "Secrets configure cancelled.");
1441
+ return parseCsv(String(raw ?? ""));
1442
+ }
1443
+ async function promptOptionalPositiveInt(params) {
1444
+ const raw = assertNoCancel(await text({
1445
+ message: params.message,
1446
+ initialValue: params.initialValue === void 0 ? "" : String(params.initialValue),
1447
+ validate: (value) => {
1448
+ const trimmed = String(value ?? "").trim();
1449
+ if (!trimmed) return;
1450
+ if (parseOptionalPositiveInt(trimmed, params.max) === void 0) return `Must be an integer between 1 and ${params.max}`;
1451
+ }
1452
+ }), "Secrets configure cancelled.");
1453
+ return parseOptionalPositiveInt(String(raw ?? ""), params.max);
1454
+ }
1455
+ function configureCandidateKey(candidate) {
1456
+ if (candidate.configFile === "auth-profiles.json") return `auth-profiles:${String(candidate.agentId ?? "").trim()}:${candidate.path}`;
1457
+ return `moldclaw:${candidate.path}`;
1458
+ }
1459
+ function hasSourceChoice(sourceChoices, source) {
1460
+ return sourceChoices.some((entry) => entry.value === source);
1461
+ }
1462
+ function resolveCandidateProviderHint(candidate) {
1463
+ if (typeof candidate.authProfileProvider === "string" && candidate.authProfileProvider.trim()) return candidate.authProfileProvider.trim().toLowerCase();
1464
+ if (typeof candidate.providerId === "string" && candidate.providerId.trim()) return candidate.providerId.trim().toLowerCase();
1465
+ }
1466
+ function resolveSuggestedEnvSecretId(candidate) {
1467
+ const hintedProvider = resolveCandidateProviderHint(candidate);
1468
+ if (!hintedProvider) return;
1469
+ const envCandidates = PROVIDER_ENV_VARS[hintedProvider];
1470
+ if (!Array.isArray(envCandidates) || envCandidates.length === 0) return;
1471
+ return envCandidates[0];
1472
+ }
1473
+ function resolveConfigureAgentId(config, explicitAgentId) {
1474
+ const knownAgentIds = new Set(listAgentIds(config));
1475
+ if (!explicitAgentId) return resolveDefaultAgentId(config);
1476
+ const normalized = normalizeAgentId(explicitAgentId);
1477
+ if (knownAgentIds.has(normalized)) return normalized;
1478
+ const known = [...knownAgentIds].toSorted().join(", ");
1479
+ throw new Error(`Unknown agent id "${explicitAgentId}". Known agents: ${known || "none configured"}.`);
1480
+ }
1481
+ function normalizeAuthStoreForConfigure(raw, storePath) {
1482
+ if (!raw) return {
1483
+ version: 1,
1484
+ profiles: {}
1485
+ };
1486
+ if (!isRecord(raw.profiles)) throw new Error(`Cannot run interactive secrets configure because ${storePath} is invalid (missing "profiles" object).`);
1487
+ return {
1488
+ version: typeof raw.version === "number" && Number.isFinite(raw.version) ? raw.version : 1,
1489
+ profiles: raw.profiles,
1490
+ ...isRecord(raw.order) ? { order: raw.order } : {},
1491
+ ...isRecord(raw.lastGood) ? { lastGood: raw.lastGood } : {},
1492
+ ...isRecord(raw.usageStats) ? { usageStats: raw.usageStats } : {}
1493
+ };
1494
+ }
1495
+ function loadAuthProfileStoreForConfigure(params) {
1496
+ const storePath = resolveAuthStorePath(resolveAgentDir(params.config, params.agentId));
1497
+ const parsed = readJsonObjectIfExists(storePath);
1498
+ if (parsed.error) throw new Error(`Cannot run interactive secrets configure because ${storePath} could not be read: ${parsed.error}`);
1499
+ return normalizeAuthStoreForConfigure(parsed.value, storePath);
1500
+ }
1501
+ async function promptNewAuthProfileCandidate(agentId) {
1502
+ const profileId = assertNoCancel(await text({
1503
+ message: "Auth profile id",
1504
+ validate: (value) => {
1505
+ const trimmed = String(value ?? "").trim();
1506
+ if (!trimmed) return "Required";
1507
+ if (!AUTH_PROFILE_ID_PATTERN.test(trimmed)) return "Use letters/numbers/\":\"/\"_\"/\"-\" only.";
1508
+ }
1509
+ }), "Secrets configure cancelled.");
1510
+ const credentialType = assertNoCancel(await select({
1511
+ message: "Auth profile credential type",
1512
+ options: [{
1513
+ value: "api_key",
1514
+ label: "api_key (key/keyRef)"
1515
+ }, {
1516
+ value: "token",
1517
+ label: "token (token/tokenRef)"
1518
+ }]
1519
+ }), "Secrets configure cancelled.");
1520
+ const provider = assertNoCancel(await text({
1521
+ message: "Provider id",
1522
+ validate: (value) => String(value ?? "").trim().length > 0 ? void 0 : "Required"
1523
+ }), "Secrets configure cancelled.");
1524
+ const profileIdTrimmed = String(profileId).trim();
1525
+ const providerTrimmed = String(provider).trim();
1526
+ if (credentialType === "token") return {
1527
+ type: "auth-profiles.token.token",
1528
+ path: `profiles.${profileIdTrimmed}.token`,
1529
+ pathSegments: [
1530
+ "profiles",
1531
+ profileIdTrimmed,
1532
+ "token"
1533
+ ],
1534
+ label: `profiles.${profileIdTrimmed}.token (auth profile, agent ${agentId})`,
1535
+ configFile: "auth-profiles.json",
1536
+ agentId,
1537
+ authProfileProvider: providerTrimmed,
1538
+ expectedResolvedValue: "string"
1539
+ };
1540
+ return {
1541
+ type: "auth-profiles.api_key.key",
1542
+ path: `profiles.${profileIdTrimmed}.key`,
1543
+ pathSegments: [
1544
+ "profiles",
1545
+ profileIdTrimmed,
1546
+ "key"
1547
+ ],
1548
+ label: `profiles.${profileIdTrimmed}.key (auth profile, agent ${agentId})`,
1549
+ configFile: "auth-profiles.json",
1550
+ agentId,
1551
+ authProfileProvider: providerTrimmed,
1552
+ expectedResolvedValue: "string"
1553
+ };
1554
+ }
1555
+ async function promptProviderAlias(params) {
1556
+ const alias = assertNoCancel(await text({
1557
+ message: "Provider alias",
1558
+ initialValue: "default",
1559
+ validate: (value) => {
1560
+ const trimmed = String(value ?? "").trim();
1561
+ if (!trimmed) return "Required";
1562
+ if (!isValidSecretProviderAlias(trimmed)) return "Must match /^[a-z][a-z0-9_-]{0,63}$/";
1563
+ if (params.existingAliases.has(trimmed)) return "Alias already exists";
1564
+ }
1565
+ }), "Secrets configure cancelled.");
1566
+ return String(alias).trim();
1567
+ }
1568
+ async function promptProviderSource(initial) {
1569
+ return assertNoCancel(await select({
1570
+ message: "Provider source",
1571
+ options: [
1572
+ {
1573
+ value: "env",
1574
+ label: "env"
1575
+ },
1576
+ {
1577
+ value: "file",
1578
+ label: "file"
1579
+ },
1580
+ {
1581
+ value: "exec",
1582
+ label: "exec"
1583
+ }
1584
+ ],
1585
+ initialValue: initial
1586
+ }), "Secrets configure cancelled.");
1587
+ }
1588
+ async function promptEnvProvider(base) {
1589
+ const allowlist = await promptEnvNameCsv({
1590
+ message: "Env allowlist (comma-separated, blank for unrestricted)",
1591
+ initialValue: base?.allowlist?.join(",") ?? ""
1592
+ });
1593
+ return {
1594
+ source: "env",
1595
+ ...allowlist.length > 0 ? { allowlist } : {}
1596
+ };
1597
+ }
1598
+ async function promptFileProvider(base) {
1599
+ const filePath = assertNoCancel(await text({
1600
+ message: "File path (absolute)",
1601
+ initialValue: base?.path ?? "",
1602
+ validate: (value) => {
1603
+ const trimmed = String(value ?? "").trim();
1604
+ if (!trimmed) return "Required";
1605
+ if (!isAbsolutePathValue(trimmed)) return "Must be an absolute path";
1606
+ }
1607
+ }), "Secrets configure cancelled.");
1608
+ const mode = assertNoCancel(await select({
1609
+ message: "File mode",
1610
+ options: [{
1611
+ value: "json",
1612
+ label: "json"
1613
+ }, {
1614
+ value: "singleValue",
1615
+ label: "singleValue"
1616
+ }],
1617
+ initialValue: base?.mode ?? "json"
1618
+ }), "Secrets configure cancelled.");
1619
+ const timeoutMs = await promptOptionalPositiveInt({
1620
+ message: "Timeout ms (blank for default)",
1621
+ initialValue: base?.timeoutMs,
1622
+ max: 12e4
1623
+ });
1624
+ const maxBytes = await promptOptionalPositiveInt({
1625
+ message: "Max bytes (blank for default)",
1626
+ initialValue: base?.maxBytes,
1627
+ max: 20 * 1024 * 1024
1628
+ });
1629
+ return {
1630
+ source: "file",
1631
+ path: String(filePath).trim(),
1632
+ mode,
1633
+ ...timeoutMs ? { timeoutMs } : {},
1634
+ ...maxBytes ? { maxBytes } : {}
1635
+ };
1636
+ }
1637
+ async function parseArgsInput(rawValue) {
1638
+ const trimmed = rawValue.trim();
1639
+ if (!trimmed) return;
1640
+ const parsed = JSON.parse(trimmed);
1641
+ if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) throw new Error("args must be a JSON array of strings");
1642
+ return parsed;
1643
+ }
1644
+ async function promptExecProvider(base) {
1645
+ const command = assertNoCancel(await text({
1646
+ message: "Command path (absolute)",
1647
+ initialValue: base?.command ?? "",
1648
+ validate: (value) => {
1649
+ const trimmed = String(value ?? "").trim();
1650
+ if (!trimmed) return "Required";
1651
+ if (!isAbsolutePathValue(trimmed)) return "Must be an absolute path";
1652
+ if (!isSafeExecutableValue(trimmed)) return "Command value is not allowed";
1653
+ }
1654
+ }), "Secrets configure cancelled.");
1655
+ const argsRaw = assertNoCancel(await text({
1656
+ message: "Args JSON array (blank for none)",
1657
+ initialValue: JSON.stringify(base?.args ?? []),
1658
+ validate: (value) => {
1659
+ const trimmed = String(value ?? "").trim();
1660
+ if (!trimmed) return;
1661
+ try {
1662
+ const parsed = JSON.parse(trimmed);
1663
+ if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) return "Must be a JSON array of strings";
1664
+ return;
1665
+ } catch {
1666
+ return "Must be valid JSON";
1667
+ }
1668
+ }
1669
+ }), "Secrets configure cancelled.");
1670
+ const timeoutMs = await promptOptionalPositiveInt({
1671
+ message: "Timeout ms (blank for default)",
1672
+ initialValue: base?.timeoutMs,
1673
+ max: 12e4
1674
+ });
1675
+ const noOutputTimeoutMs = await promptOptionalPositiveInt({
1676
+ message: "No-output timeout ms (blank for default)",
1677
+ initialValue: base?.noOutputTimeoutMs,
1678
+ max: 12e4
1679
+ });
1680
+ const maxOutputBytes = await promptOptionalPositiveInt({
1681
+ message: "Max output bytes (blank for default)",
1682
+ initialValue: base?.maxOutputBytes,
1683
+ max: 20 * 1024 * 1024
1684
+ });
1685
+ const jsonOnly = assertNoCancel(await confirm({
1686
+ message: "Require JSON-only response?",
1687
+ initialValue: base?.jsonOnly ?? true
1688
+ }), "Secrets configure cancelled.");
1689
+ const passEnv = await promptEnvNameCsv({
1690
+ message: "Pass-through env vars (comma-separated, blank for none)",
1691
+ initialValue: base?.passEnv?.join(",") ?? ""
1692
+ });
1693
+ const trustedDirsRaw = assertNoCancel(await text({
1694
+ message: "Trusted dirs (comma-separated absolute paths, blank for none)",
1695
+ initialValue: base?.trustedDirs?.join(",") ?? "",
1696
+ validate: (value) => {
1697
+ const entries = parseCsv(String(value ?? ""));
1698
+ for (const entry of entries) if (!isAbsolutePathValue(entry)) return `Trusted dir must be absolute: ${entry}`;
1699
+ }
1700
+ }), "Secrets configure cancelled.");
1701
+ const allowInsecurePath = assertNoCancel(await confirm({
1702
+ message: "Allow insecure command path checks?",
1703
+ initialValue: base?.allowInsecurePath ?? false
1704
+ }), "Secrets configure cancelled.");
1705
+ const allowSymlinkCommand = assertNoCancel(await confirm({
1706
+ message: "Allow symlink command path?",
1707
+ initialValue: base?.allowSymlinkCommand ?? false
1708
+ }), "Secrets configure cancelled.");
1709
+ const args = await parseArgsInput(String(argsRaw ?? ""));
1710
+ const trustedDirs = parseCsv(String(trustedDirsRaw ?? ""));
1711
+ return {
1712
+ source: "exec",
1713
+ command: String(command).trim(),
1714
+ ...args && args.length > 0 ? { args } : {},
1715
+ ...timeoutMs ? { timeoutMs } : {},
1716
+ ...noOutputTimeoutMs ? { noOutputTimeoutMs } : {},
1717
+ ...maxOutputBytes ? { maxOutputBytes } : {},
1718
+ ...jsonOnly ? { jsonOnly } : { jsonOnly: false },
1719
+ ...passEnv.length > 0 ? { passEnv } : {},
1720
+ ...trustedDirs.length > 0 ? { trustedDirs } : {},
1721
+ ...allowInsecurePath ? { allowInsecurePath: true } : {},
1722
+ ...allowSymlinkCommand ? { allowSymlinkCommand: true } : {},
1723
+ ...isRecord(base?.env) ? { env: base.env } : {}
1724
+ };
1725
+ }
1726
+ async function promptProviderConfig(source, current) {
1727
+ if (source === "env") return await promptEnvProvider(current?.source === "env" ? current : void 0);
1728
+ if (source === "file") return await promptFileProvider(current?.source === "file" ? current : void 0);
1729
+ return await promptExecProvider(current?.source === "exec" ? current : void 0);
1730
+ }
1731
+ async function configureProvidersInteractive(config) {
1732
+ while (true) {
1733
+ const providers = getSecretProviders(config);
1734
+ const providerEntries = Object.entries(providers).toSorted(([left], [right]) => left.localeCompare(right));
1735
+ const actionOptions = [{
1736
+ value: "add",
1737
+ label: "Add provider",
1738
+ hint: "Define a new env/file/exec provider"
1739
+ }];
1740
+ if (providerEntries.length > 0) {
1741
+ actionOptions.push({
1742
+ value: "edit",
1743
+ label: "Edit provider",
1744
+ hint: "Update an existing provider"
1745
+ });
1746
+ actionOptions.push({
1747
+ value: "remove",
1748
+ label: "Remove provider",
1749
+ hint: "Delete a provider alias"
1750
+ });
1751
+ }
1752
+ actionOptions.push({
1753
+ value: "continue",
1754
+ label: "Continue",
1755
+ hint: "Move to credential mapping"
1756
+ });
1757
+ const action = assertNoCancel(await select({
1758
+ message: providerEntries.length > 0 ? "Configure secret providers" : "Configure secret providers (only env refs are available until file/exec providers are added)",
1759
+ options: actionOptions
1760
+ }), "Secrets configure cancelled.");
1761
+ if (action === "continue") return;
1762
+ if (action === "add") {
1763
+ const source = await promptProviderSource();
1764
+ setSecretProvider(config, await promptProviderAlias({ existingAliases: new Set(providerEntries.map(([providerAlias]) => providerAlias)) }), await promptProviderConfig(source));
1765
+ continue;
1766
+ }
1767
+ if (action === "edit") {
1768
+ const alias = assertNoCancel(await select({
1769
+ message: "Select provider to edit",
1770
+ options: providerEntries.map(([providerAlias, providerConfig]) => ({
1771
+ value: providerAlias,
1772
+ label: providerAlias,
1773
+ hint: providerHint(providerConfig)
1774
+ }))
1775
+ }), "Secrets configure cancelled.");
1776
+ const current = providers[alias];
1777
+ if (!current) continue;
1778
+ const nextProviderConfig = await promptProviderConfig(await promptProviderSource(current.source), current);
1779
+ if (!isDeepStrictEqual(current, nextProviderConfig)) setSecretProvider(config, alias, nextProviderConfig);
1780
+ continue;
1781
+ }
1782
+ if (action === "remove") {
1783
+ const alias = assertNoCancel(await select({
1784
+ message: "Select provider to remove",
1785
+ options: providerEntries.map(([providerAlias, providerConfig]) => ({
1786
+ value: providerAlias,
1787
+ label: providerAlias,
1788
+ hint: providerHint(providerConfig)
1789
+ }))
1790
+ }), "Secrets configure cancelled.");
1791
+ if (assertNoCancel(await confirm({
1792
+ message: `Remove provider "${alias}"?`,
1793
+ initialValue: false
1794
+ }), "Secrets configure cancelled.")) removeSecretProvider(config, alias);
1795
+ }
1796
+ }
1797
+ }
1798
+ async function runSecretsConfigureInteractive(params = {}) {
1799
+ if (!process.stdin.isTTY) throw new Error("secrets configure requires an interactive TTY.");
1800
+ if (params.providersOnly && params.skipProviderSetup) throw new Error("Cannot combine --providers-only with --skip-provider-setup.");
1801
+ const env = params.env ?? process.env;
1802
+ const { snapshot } = await createSecretsConfigIO({ env }).readConfigFileSnapshotForWrite();
1803
+ if (!snapshot.valid) throw new Error("Cannot run interactive secrets configure because config is invalid.");
1804
+ const stagedConfig = structuredClone(snapshot.config);
1805
+ if (!params.skipProviderSetup) await configureProvidersInteractive(stagedConfig);
1806
+ const providerChanges = collectConfigureProviderChanges({
1807
+ original: snapshot.config,
1808
+ next: stagedConfig
1809
+ });
1810
+ const selectedByPath = /* @__PURE__ */ new Map();
1811
+ if (!params.providersOnly) {
1812
+ const configureAgentId = resolveConfigureAgentId(snapshot.config, params.agentId);
1813
+ const authStore = loadAuthProfileStoreForConfigure({
1814
+ config: snapshot.config,
1815
+ agentId: configureAgentId
1816
+ });
1817
+ const candidates = buildConfigureCandidatesForScope({
1818
+ config: stagedConfig,
1819
+ authoredmoldClawConfig: snapshot.resolved,
1820
+ authProfiles: {
1821
+ agentId: configureAgentId,
1822
+ store: authStore
1823
+ }
1824
+ });
1825
+ if (candidates.length === 0) throw new Error("No configurable secret-bearing fields found for this agent scope.");
1826
+ const sourceChoices = toSourceChoices(stagedConfig);
1827
+ const hasDerivedCandidates = candidates.some((candidate) => candidate.isDerived === true);
1828
+ let showDerivedCandidates = false;
1829
+ while (true) {
1830
+ const visibleCandidates = showDerivedCandidates ? candidates : candidates.filter((candidate) => candidate.isDerived !== true);
1831
+ const options = visibleCandidates.map((candidate) => ({
1832
+ value: configureCandidateKey(candidate),
1833
+ label: candidate.label,
1834
+ hint: [candidate.configFile === "auth-profiles.json" ? "auth-profiles.json" : "moldclaw.json", candidate.isDerived === true ? "derived" : void 0].filter(Boolean).join(" | ")
1835
+ }));
1836
+ options.push({
1837
+ value: "__create_auth_profile__",
1838
+ label: "Create auth profile mapping",
1839
+ hint: `Add a new auth-profiles target for agent ${configureAgentId}`
1840
+ });
1841
+ if (hasDerivedCandidates) options.push({
1842
+ value: "__toggle_derived__",
1843
+ label: showDerivedCandidates ? "Hide derived targets" : "Show derived targets",
1844
+ hint: showDerivedCandidates ? "Show only fields authored directly in config" : "Include normalized/derived aliases"
1845
+ });
1846
+ if (selectedByPath.size > 0) options.unshift({
1847
+ value: "__done__",
1848
+ label: "Done",
1849
+ hint: "Finish and run preflight"
1850
+ });
1851
+ const selectedPath = assertNoCancel(await select({
1852
+ message: "Select credential field",
1853
+ options
1854
+ }), "Secrets configure cancelled.");
1855
+ if (selectedPath === "__done__") break;
1856
+ if (selectedPath === "__create_auth_profile__") {
1857
+ const createdCandidate = await promptNewAuthProfileCandidate(configureAgentId);
1858
+ const key = configureCandidateKey(createdCandidate);
1859
+ const existingIndex = candidates.findIndex((entry) => configureCandidateKey(entry) === key);
1860
+ if (existingIndex >= 0) candidates[existingIndex] = createdCandidate;
1861
+ else candidates.push(createdCandidate);
1862
+ continue;
1863
+ }
1864
+ if (selectedPath === "__toggle_derived__") {
1865
+ showDerivedCandidates = !showDerivedCandidates;
1866
+ continue;
1867
+ }
1868
+ const candidate = visibleCandidates.find((entry) => configureCandidateKey(entry) === selectedPath);
1869
+ if (!candidate) throw new Error(`Unknown configure target: ${selectedPath}`);
1870
+ const candidateKey = configureCandidateKey(candidate);
1871
+ const existingRef = selectedByPath.get(candidateKey)?.ref ?? candidate.existingRef;
1872
+ const source = assertNoCancel(await select({
1873
+ message: "Secret source",
1874
+ options: sourceChoices,
1875
+ initialValue: existingRef && hasSourceChoice(sourceChoices, existingRef.source) ? existingRef.source : void 0
1876
+ }), "Secrets configure cancelled.");
1877
+ const defaultAlias = resolveDefaultSecretProviderAlias(stagedConfig, source, { preferFirstProviderForSource: true });
1878
+ const provider = assertNoCancel(await text({
1879
+ message: "Provider alias",
1880
+ initialValue: existingRef?.source === source ? existingRef.provider : defaultAlias,
1881
+ validate: (value) => {
1882
+ const trimmed = String(value ?? "").trim();
1883
+ if (!trimmed) return "Required";
1884
+ if (!isValidSecretProviderAlias(trimmed)) return "Must match /^[a-z][a-z0-9_-]{0,63}$/";
1885
+ }
1886
+ }), "Secrets configure cancelled.");
1887
+ const providerAlias = String(provider).trim();
1888
+ let suggestedId = existingRef?.source === source ? existingRef.id : void 0;
1889
+ if (!suggestedId && source === "env") suggestedId = resolveSuggestedEnvSecretId(candidate);
1890
+ if (!suggestedId && source === "file") {
1891
+ const configuredProvider = stagedConfig.secrets?.providers?.[providerAlias];
1892
+ if (configuredProvider?.source === "file" && configuredProvider.mode === "singleValue") suggestedId = "value";
1893
+ }
1894
+ const id = assertNoCancel(await text({
1895
+ message: "Secret id",
1896
+ initialValue: suggestedId,
1897
+ validate: (value) => {
1898
+ const trimmed = String(value ?? "").trim();
1899
+ if (!trimmed) return "Required";
1900
+ if (source === "exec" && !isValidExecSecretRefId(trimmed)) return formatExecSecretRefIdValidationMessage();
1901
+ }
1902
+ }), "Secrets configure cancelled.");
1903
+ const ref = {
1904
+ source,
1905
+ provider: providerAlias,
1906
+ id: String(id).trim()
1907
+ };
1908
+ assertExpectedResolvedSecretValue({
1909
+ value: await resolveSecretRefValue(ref, {
1910
+ config: stagedConfig,
1911
+ env
1912
+ }),
1913
+ expected: candidate.expectedResolvedValue,
1914
+ 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.`
1915
+ });
1916
+ const next = {
1917
+ ...candidate,
1918
+ ref
1919
+ };
1920
+ selectedByPath.set(candidateKey, next);
1921
+ if (!assertNoCancel(await confirm({
1922
+ message: "Configure another credential?",
1923
+ initialValue: true
1924
+ }), "Secrets configure cancelled.")) break;
1925
+ }
1926
+ }
1927
+ if (!hasConfigurePlanChanges({
1928
+ selectedTargets: selectedByPath,
1929
+ providerChanges
1930
+ })) throw new Error("No secrets changes were selected.");
1931
+ const plan = buildSecretsConfigurePlan({
1932
+ selectedTargets: selectedByPath,
1933
+ providerChanges
1934
+ });
1935
+ return {
1936
+ plan,
1937
+ preflight: await runSecretsApply({
1938
+ plan,
1939
+ env,
1940
+ write: false
1941
+ })
1942
+ };
1943
+ }
1944
+ //#endregion
1945
+ //#region src/cli/secrets-cli.ts
1946
+ function readPlanFile(pathname) {
1947
+ const raw = fs.readFileSync(pathname, "utf8");
1948
+ const parsed = JSON.parse(raw);
1949
+ if (!isSecretsApplyPlan(parsed)) throw new Error(`Invalid secrets plan file: ${pathname}`);
1950
+ return parsed;
1951
+ }
1952
+ function registerSecretsCli(program) {
1953
+ const secrets = program.command("secrets").description("Secrets runtime controls").addHelpText("after", () => `\n${theme.muted("Docs:")} ${formatDocsLink("/gateway/security", "docs.moldclaw.ai/gateway/security")}\n`);
1954
+ addGatewayClientOptions(secrets.command("reload").description("Re-resolve secret references and atomically swap runtime snapshot").option("--json", "Output JSON", false)).action(async (opts) => {
1955
+ try {
1956
+ const result = await callGatewayFromCli("secrets.reload", opts, void 0, { expectFinal: false });
1957
+ if (opts.json) {
1958
+ defaultRuntime.log(JSON.stringify(result, null, 2));
1959
+ return;
1960
+ }
1961
+ const warningCount = Number(result?.warningCount ?? 0);
1962
+ if (Number.isFinite(warningCount) && warningCount > 0) {
1963
+ defaultRuntime.log(`Secrets reloaded with ${warningCount} warning(s).`);
1964
+ return;
1965
+ }
1966
+ defaultRuntime.log("Secrets reloaded.");
1967
+ } catch (err) {
1968
+ defaultRuntime.error(danger(String(err)));
1969
+ defaultRuntime.exit(1);
1970
+ }
1971
+ });
1972
+ 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) => {
1973
+ try {
1974
+ const report = await runSecretsAudit();
1975
+ if (opts.json) defaultRuntime.log(JSON.stringify(report, null, 2));
1976
+ else {
1977
+ defaultRuntime.log(`Secrets audit: ${report.status}. plaintext=${report.summary.plaintextCount}, unresolved=${report.summary.unresolvedRefCount}, shadowed=${report.summary.shadowedRefCount}, legacy=${report.summary.legacyResidueCount}.`);
1978
+ if (report.findings.length > 0) {
1979
+ for (const finding of report.findings.slice(0, 20)) defaultRuntime.log(`- [${finding.code}] ${finding.file}:${finding.jsonPath} ${finding.message}`);
1980
+ if (report.findings.length > 20) defaultRuntime.log(`... ${report.findings.length - 20} more finding(s).`);
1981
+ }
1982
+ }
1983
+ const exitCode = resolveSecretsAuditExitCode(report, Boolean(opts.check));
1984
+ if (exitCode !== 0) defaultRuntime.exit(exitCode);
1985
+ } catch (err) {
1986
+ defaultRuntime.error(danger(String(err)));
1987
+ defaultRuntime.exit(2);
1988
+ }
1989
+ });
1990
+ 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) => {
1991
+ try {
1992
+ const configured = await runSecretsConfigureInteractive({
1993
+ providersOnly: Boolean(opts.providersOnly),
1994
+ skipProviderSetup: Boolean(opts.skipProviderSetup),
1995
+ agentId: typeof opts.agent === "string" ? opts.agent : void 0
1996
+ });
1997
+ if (opts.planOut) fs.writeFileSync(opts.planOut, `${JSON.stringify(configured.plan, null, 2)}\n`, "utf8");
1998
+ if (opts.json) defaultRuntime.log(JSON.stringify({
1999
+ plan: configured.plan,
2000
+ preflight: configured.preflight
2001
+ }, null, 2));
2002
+ else {
2003
+ defaultRuntime.log(`Preflight: changed=${configured.preflight.changed}, files=${configured.preflight.changedFiles.length}, warnings=${configured.preflight.warningCount}.`);
2004
+ if (configured.preflight.warningCount > 0) for (const warning of configured.preflight.warnings) defaultRuntime.log(`- warning: ${warning}`);
2005
+ const providerUpserts = Object.keys(configured.plan.providerUpserts ?? {}).length;
2006
+ const providerDeletes = configured.plan.providerDeletes?.length ?? 0;
2007
+ defaultRuntime.log(`Plan: targets=${configured.plan.targets.length}, providerUpserts=${providerUpserts}, providerDeletes=${providerDeletes}.`);
2008
+ if (opts.planOut) defaultRuntime.log(`Plan written to ${opts.planOut}`);
2009
+ }
2010
+ let shouldApply = Boolean(opts.apply);
2011
+ if (!shouldApply && !opts.json) {
2012
+ const approved = await confirm({
2013
+ message: "Apply this plan now?",
2014
+ initialValue: true
2015
+ });
2016
+ if (typeof approved === "boolean") shouldApply = approved;
2017
+ }
2018
+ if (shouldApply) {
2019
+ if (Boolean(opts.apply) && !opts.yes && !opts.json) {
2020
+ if (await confirm({
2021
+ message: "This migration is one-way for migrated plaintext values. Continue with apply?",
2022
+ initialValue: true
2023
+ }) !== true) {
2024
+ defaultRuntime.log("Apply cancelled.");
2025
+ return;
2026
+ }
2027
+ }
2028
+ const result = await runSecretsApply({
2029
+ plan: configured.plan,
2030
+ write: true
2031
+ });
2032
+ if (opts.json) {
2033
+ defaultRuntime.log(JSON.stringify(result, null, 2));
2034
+ return;
2035
+ }
2036
+ defaultRuntime.log(result.changed ? `Secrets applied. Updated ${result.changedFiles.length} file(s).` : "Secrets apply: no changes.");
2037
+ }
2038
+ } catch (err) {
2039
+ defaultRuntime.error(danger(String(err)));
2040
+ defaultRuntime.exit(1);
2041
+ }
2042
+ });
2043
+ 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) => {
2044
+ try {
2045
+ const result = await runSecretsApply({
2046
+ plan: readPlanFile(opts.from),
2047
+ write: !opts.dryRun
2048
+ });
2049
+ if (opts.json) {
2050
+ defaultRuntime.log(JSON.stringify(result, null, 2));
2051
+ return;
2052
+ }
2053
+ if (opts.dryRun) {
2054
+ defaultRuntime.log(result.changed ? `Secrets apply dry run: ${result.changedFiles.length} file(s) would change.` : "Secrets apply dry run: no changes.");
2055
+ return;
2056
+ }
2057
+ defaultRuntime.log(result.changed ? `Secrets applied. Updated ${result.changedFiles.length} file(s).` : "Secrets apply: no changes.");
2058
+ } catch (err) {
2059
+ defaultRuntime.error(danger(String(err)));
2060
+ defaultRuntime.exit(1);
2061
+ }
2062
+ });
2063
+ }
2064
+ //#endregion
2065
+ export { registerSecretsCli };