@ai-agent-forge/agent-forge 0.88.0 → 0.88.2

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 (445) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/bundled-plugins/agent-loop-policy/agent-forge.json +19 -0
  3. package/bundled-plugins/agent-loop-policy/dist/entry.d.ts +28 -0
  4. package/bundled-plugins/agent-loop-policy/dist/entry.d.ts.map +1 -0
  5. package/bundled-plugins/agent-loop-policy/dist/entry.js +69 -0
  6. package/bundled-plugins/agent-loop-policy/dist/entry.js.map +1 -0
  7. package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts +199 -0
  8. package/bundled-plugins/agent-loop-policy/dist/loop-guard.d.ts.map +1 -0
  9. package/bundled-plugins/agent-loop-policy/dist/loop-guard.js +208 -0
  10. package/bundled-plugins/agent-loop-policy/dist/loop-guard.js.map +1 -0
  11. package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts +17 -0
  12. package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.d.ts.map +1 -0
  13. package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js +18 -0
  14. package/bundled-plugins/agent-loop-policy/dist/run-loop-strategy.js.map +1 -0
  15. package/bundled-plugins/agent-loop-policy/plugin.json +7 -0
  16. package/bundled-plugins/coding-tools/agent-forge.json +19 -0
  17. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.d.ts +5 -44
  18. package/bundled-plugins/coding-tools/dist/bash.d.ts.map +1 -0
  19. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/bash.js +15 -119
  20. package/bundled-plugins/coding-tools/dist/bash.js.map +1 -0
  21. package/bundled-plugins/coding-tools/dist/capability.d.ts +25 -0
  22. package/bundled-plugins/coding-tools/dist/capability.d.ts.map +1 -0
  23. package/bundled-plugins/coding-tools/dist/capability.js +98 -0
  24. package/bundled-plugins/coding-tools/dist/capability.js.map +1 -0
  25. package/bundled-plugins/coding-tools/dist/config.d.ts +8 -0
  26. package/bundled-plugins/coding-tools/dist/config.d.ts.map +1 -0
  27. package/bundled-plugins/coding-tools/dist/config.js +8 -0
  28. package/bundled-plugins/coding-tools/dist/config.js.map +1 -0
  29. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.d.ts +3 -3
  30. package/bundled-plugins/coding-tools/dist/edit.d.ts.map +1 -0
  31. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/edit.js +12 -10
  32. package/bundled-plugins/coding-tools/dist/edit.js.map +1 -0
  33. package/bundled-plugins/coding-tools/dist/entry.d.ts +14 -0
  34. package/bundled-plugins/coding-tools/dist/entry.d.ts.map +1 -0
  35. package/bundled-plugins/coding-tools/dist/entry.js +23 -0
  36. package/bundled-plugins/coding-tools/dist/entry.js.map +1 -0
  37. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.d.ts +4 -4
  38. package/bundled-plugins/coding-tools/dist/find.d.ts.map +1 -0
  39. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/find.js +10 -8
  40. package/bundled-plugins/coding-tools/dist/find.js.map +1 -0
  41. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.d.ts +3 -3
  42. package/bundled-plugins/coding-tools/dist/grep.d.ts.map +1 -0
  43. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/grep.js +10 -8
  44. package/bundled-plugins/coding-tools/dist/grep.js.map +1 -0
  45. package/bundled-plugins/coding-tools/dist/index.d.ts +17 -0
  46. package/bundled-plugins/coding-tools/dist/index.d.ts.map +1 -0
  47. package/bundled-plugins/coding-tools/dist/index.js +17 -0
  48. package/bundled-plugins/coding-tools/dist/index.js.map +1 -0
  49. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.d.ts +3 -3
  50. package/bundled-plugins/coding-tools/dist/ls.d.ts.map +1 -0
  51. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js +8 -6
  52. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/ls.js.map +1 -1
  53. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.d.ts +2 -1
  54. package/bundled-plugins/coding-tools/dist/powershell.d.ts.map +1 -0
  55. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/powershell.js +6 -3
  56. package/bundled-plugins/coding-tools/dist/powershell.js.map +1 -0
  57. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.d.ts +3 -3
  58. package/bundled-plugins/coding-tools/dist/read.d.ts.map +1 -0
  59. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/read.js +15 -13
  60. package/bundled-plugins/coding-tools/dist/read.js.map +1 -0
  61. package/bundled-plugins/coding-tools/dist/types.d.ts +74 -0
  62. package/bundled-plugins/coding-tools/dist/types.d.ts.map +1 -0
  63. package/bundled-plugins/coding-tools/dist/types.js +28 -0
  64. package/bundled-plugins/coding-tools/dist/types.js.map +1 -0
  65. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.d.ts +2 -2
  66. package/bundled-plugins/coding-tools/dist/write.d.ts.map +1 -0
  67. package/{dist/core/tools → bundled-plugins/coding-tools/dist}/write.js +11 -9
  68. package/bundled-plugins/coding-tools/dist/write.js.map +1 -0
  69. package/bundled-plugins/coding-tools/plugin.json +10 -0
  70. package/bundled-plugins/compaction-policy/agent-forge.json +19 -0
  71. package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts +6 -0
  72. package/bundled-plugins/compaction-policy/dist/branch-summary-policy.d.ts.map +1 -0
  73. package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js +19 -0
  74. package/bundled-plugins/compaction-policy/dist/branch-summary-policy.js.map +1 -0
  75. package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts +6 -0
  76. package/bundled-plugins/compaction-policy/dist/compaction-policy.d.ts.map +1 -0
  77. package/bundled-plugins/compaction-policy/dist/compaction-policy.js +38 -0
  78. package/bundled-plugins/compaction-policy/dist/compaction-policy.js.map +1 -0
  79. package/bundled-plugins/compaction-policy/dist/entry.d.ts +13 -0
  80. package/bundled-plugins/compaction-policy/dist/entry.d.ts.map +1 -0
  81. package/bundled-plugins/compaction-policy/dist/entry.js +23 -0
  82. package/bundled-plugins/compaction-policy/dist/entry.js.map +1 -0
  83. package/bundled-plugins/compaction-policy/plugin.json +10 -0
  84. package/bundled-plugins/mcp-http/dist/index.d.ts +8 -0
  85. package/bundled-plugins/mcp-http/dist/index.d.ts.map +1 -0
  86. package/bundled-plugins/mcp-http/dist/index.js +8 -0
  87. package/bundled-plugins/mcp-http/dist/index.js.map +1 -0
  88. package/bundled-plugins/mcp-http/dist/mcp-http.d.ts.map +1 -0
  89. package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.js +1 -1
  90. package/bundled-plugins/mcp-http/dist/mcp-http.js.map +1 -0
  91. package/bundled-plugins/overflow-policy/agent-forge.json +19 -0
  92. package/bundled-plugins/overflow-policy/dist/entry.d.ts +16 -0
  93. package/bundled-plugins/overflow-policy/dist/entry.d.ts.map +1 -0
  94. package/bundled-plugins/overflow-policy/dist/entry.js +35 -0
  95. package/bundled-plugins/overflow-policy/dist/entry.js.map +1 -0
  96. package/bundled-plugins/overflow-policy/plugin.json +10 -0
  97. package/bundled-plugins/provider-failover/agent-forge.json +19 -0
  98. package/bundled-plugins/provider-failover/dist/entry.d.ts +8 -0
  99. package/bundled-plugins/provider-failover/dist/entry.d.ts.map +1 -0
  100. package/bundled-plugins/provider-failover/dist/entry.js +8 -0
  101. package/bundled-plugins/provider-failover/dist/entry.js.map +1 -0
  102. package/bundled-plugins/provider-failover/dist/provider-failover.d.ts +122 -0
  103. package/bundled-plugins/provider-failover/dist/provider-failover.d.ts.map +1 -0
  104. package/{dist/core/extensions → bundled-plugins/provider-failover/dist}/provider-failover.js +143 -56
  105. package/bundled-plugins/provider-failover/dist/provider-failover.js.map +1 -0
  106. package/bundled-plugins/provider-failover/plugin.json +7 -0
  107. package/bundled-plugins/retry-policy/agent-forge.json +19 -0
  108. package/bundled-plugins/retry-policy/dist/entry.d.ts +16 -0
  109. package/bundled-plugins/retry-policy/dist/entry.d.ts.map +1 -0
  110. package/bundled-plugins/retry-policy/dist/entry.js +34 -0
  111. package/bundled-plugins/retry-policy/dist/entry.js.map +1 -0
  112. package/bundled-plugins/retry-policy/plugin.json +10 -0
  113. package/dist/bundle/.build-manifest.json +109 -155
  114. package/dist/bundle/chunks/{anthropic-messages-ALDZBUKI.js → anthropic-messages-PLAKXR73.js} +1 -1
  115. package/dist/bundle/chunks/{azure-openai-responses-A2WJWZFB.js → azure-openai-responses-OUWQ2AZD.js} +1 -1
  116. package/dist/bundle/chunks/chunk-44I47ACN.js +13 -0
  117. package/dist/bundle/chunks/chunk-6F5JWGKE.js +4 -0
  118. package/dist/bundle/chunks/{chunk-CIX3FSBK.js → chunk-A3JYRWB6.js} +1 -1
  119. package/dist/bundle/chunks/{chunk-SQFG22WN.js → chunk-AC2FIS4G.js} +1 -1
  120. package/dist/bundle/chunks/chunk-HTC5K5SM.js +866 -0
  121. package/dist/bundle/chunks/{chunk-YJCQVXW5.js → chunk-HTEVUY7F.js} +1 -1
  122. package/dist/bundle/chunks/{chunk-Y7HXTASS.js → chunk-HV64ASMT.js} +1 -1
  123. package/dist/bundle/chunks/chunk-LSP24WNH.js +665 -0
  124. package/dist/bundle/chunks/{chunk-7ZY7IXZD.js → chunk-TRDNDS6A.js} +1 -1
  125. package/dist/bundle/chunks/{google-generative-ai-NIB4WONV.js → google-generative-ai-DLII6DAT.js} +1 -1
  126. package/dist/bundle/chunks/{google-vertex-DCPYUEUO.js → google-vertex-G7BZL7GM.js} +1 -1
  127. package/dist/bundle/chunks/image-resize-worker.js +4 -4
  128. package/dist/bundle/chunks/{mistral-conversations-OC6LA5XL.js → mistral-conversations-JXUK24ID.js} +1 -1
  129. package/dist/bundle/chunks/{openai-codex-responses-IO2X4Y7L.js → openai-codex-responses-5GSGFIPG.js} +1 -1
  130. package/dist/bundle/chunks/{openai-completions-XYQQHETU.js → openai-completions-EI2I6DTG.js} +1 -1
  131. package/dist/bundle/chunks/{openai-responses-DLIRN3CI.js → openai-responses-AUJQ3NWT.js} +1 -1
  132. package/dist/bundle/chunks/{pi-messages-E6RRYBO7.js → pi-messages-PWU2VJMR.js} +1 -1
  133. package/dist/bundle/chunks/virtual-modules-MRXD3RWG.js +5 -0
  134. package/dist/bundle/cli.js +1 -1
  135. package/dist/bundle/client.js +1 -1
  136. package/dist/bundle/index.js +3 -3
  137. package/dist/bundle/rpc-entry.js +1 -1
  138. package/dist/capabilities/builtin.d.ts +1 -1
  139. package/dist/capabilities/builtin.d.ts.map +1 -1
  140. package/dist/capabilities/builtin.js +5 -0
  141. package/dist/capabilities/builtin.js.map +1 -1
  142. package/dist/cli/plugin-command.d.ts.map +1 -1
  143. package/dist/cli/plugin-command.js +25 -3
  144. package/dist/cli/plugin-command.js.map +1 -1
  145. package/dist/config.d.ts +2 -3
  146. package/dist/config.d.ts.map +1 -1
  147. package/dist/config.js +2 -4
  148. package/dist/config.js.map +1 -1
  149. package/dist/core/agent-session-bash.d.ts +1 -1
  150. package/dist/core/agent-session-bash.d.ts.map +1 -1
  151. package/dist/core/agent-session-bash.js +1 -1
  152. package/dist/core/agent-session-bash.js.map +1 -1
  153. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  154. package/dist/core/agent-session-compaction.js +14 -1
  155. package/dist/core/agent-session-compaction.js.map +1 -1
  156. package/dist/core/agent-session-internal.d.ts +3 -1
  157. package/dist/core/agent-session-internal.d.ts.map +1 -1
  158. package/dist/core/agent-session-internal.js.map +1 -1
  159. package/dist/core/agent-session-loop.d.ts +4 -3
  160. package/dist/core/agent-session-loop.d.ts.map +1 -1
  161. package/dist/core/agent-session-loop.js +9 -6
  162. package/dist/core/agent-session-loop.js.map +1 -1
  163. package/dist/core/agent-session-retry.d.ts +1 -1
  164. package/dist/core/agent-session-retry.d.ts.map +1 -1
  165. package/dist/core/agent-session-retry.js +32 -3
  166. package/dist/core/agent-session-retry.js.map +1 -1
  167. package/dist/core/agent-session-services.d.ts +2 -0
  168. package/dist/core/agent-session-services.d.ts.map +1 -1
  169. package/dist/core/agent-session-services.js +31 -9
  170. package/dist/core/agent-session-services.js.map +1 -1
  171. package/dist/core/agent-session-store.d.ts.map +1 -1
  172. package/dist/core/agent-session-store.js +6 -1
  173. package/dist/core/agent-session-store.js.map +1 -1
  174. package/dist/core/agent-session-tools.d.ts.map +1 -1
  175. package/dist/core/agent-session-tools.js +18 -1
  176. package/dist/core/agent-session-tools.js.map +1 -1
  177. package/dist/core/agent-session.d.ts +34 -11
  178. package/dist/core/agent-session.d.ts.map +1 -1
  179. package/dist/core/agent-session.js +114 -38
  180. package/dist/core/agent-session.js.map +1 -1
  181. package/dist/core/bash-executor.d.ts +1 -1
  182. package/dist/core/bash-executor.d.ts.map +1 -1
  183. package/dist/core/bash-executor.js.map +1 -1
  184. package/dist/core/extensions/bootstrap-agent-loop.d.ts +23 -151
  185. package/dist/core/extensions/bootstrap-agent-loop.d.ts.map +1 -1
  186. package/dist/core/extensions/bootstrap-agent-loop.js +28 -290
  187. package/dist/core/extensions/bootstrap-agent-loop.js.map +1 -1
  188. package/dist/core/extensions/capability-runtime-types.d.ts +5 -3
  189. package/dist/core/extensions/capability-runtime-types.d.ts.map +1 -1
  190. package/dist/core/extensions/capability-runtime-types.js.map +1 -1
  191. package/dist/core/extensions/capability-runtime.d.ts.map +1 -1
  192. package/dist/core/extensions/capability-runtime.js +42 -6
  193. package/dist/core/extensions/capability-runtime.js.map +1 -1
  194. package/dist/core/extensions/index.d.ts +12 -5
  195. package/dist/core/extensions/index.d.ts.map +1 -1
  196. package/dist/core/extensions/index.js +12 -5
  197. package/dist/core/extensions/index.js.map +1 -1
  198. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  199. package/dist/core/extensions/virtual-modules.js +65 -0
  200. package/dist/core/extensions/virtual-modules.js.map +1 -1
  201. package/dist/core/facade/coding-agent-facade.d.ts +1 -1
  202. package/dist/core/facade/coding-agent-facade.d.ts.map +1 -1
  203. package/dist/core/facade/coding-agent-facade.js.map +1 -1
  204. package/dist/core/i18n/locales/zh-cn/cli.d.ts.map +1 -1
  205. package/dist/core/i18n/locales/zh-cn/cli.js +2 -0
  206. package/dist/core/i18n/locales/zh-cn/cli.js.map +1 -1
  207. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts +1 -1
  208. package/dist/core/i18n/locales/zh-cn/core-contract-core.d.ts.map +1 -1
  209. package/dist/core/i18n/locales/zh-cn/core-contract-core.js +1 -1
  210. package/dist/core/i18n/locales/zh-cn/core-contract-core.js.map +1 -1
  211. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.d.ts.map +1 -1
  212. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js +2 -4
  213. package/dist/core/i18n/locales/zh-cn/core-contract-extensions.js.map +1 -1
  214. package/dist/core/i18n/locales/zh-cn/core-errors.d.ts.map +1 -1
  215. package/dist/core/i18n/locales/zh-cn/core-errors.js +3 -1
  216. package/dist/core/i18n/locales/zh-cn/core-errors.js.map +1 -1
  217. package/dist/core/i18n/locales/zh-cn/index.d.ts.map +1 -1
  218. package/dist/core/i18n/locales/zh-cn/index.js +2 -0
  219. package/dist/core/i18n/locales/zh-cn/index.js.map +1 -1
  220. package/dist/core/i18n/locales/zh-cn/interactive-mode.d.ts.map +1 -1
  221. package/dist/core/i18n/locales/zh-cn/interactive-mode.js +5 -0
  222. package/dist/core/i18n/locales/zh-cn/interactive-mode.js.map +1 -1
  223. package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts +7 -0
  224. package/dist/core/i18n/locales/zh-cn/session-cleanup.d.ts.map +1 -0
  225. package/dist/core/i18n/locales/zh-cn/session-cleanup.js +15 -0
  226. package/dist/core/i18n/locales/zh-cn/session-cleanup.js.map +1 -0
  227. package/dist/core/i18n/locales/zh-cn/slash-commands.d.ts.map +1 -1
  228. package/dist/core/i18n/locales/zh-cn/slash-commands.js +1 -0
  229. package/dist/core/i18n/locales/zh-cn/slash-commands.js.map +1 -1
  230. package/dist/core/sdk.d.ts +10 -3
  231. package/dist/core/sdk.d.ts.map +1 -1
  232. package/dist/core/sdk.js +287 -78
  233. package/dist/core/sdk.js.map +1 -1
  234. package/dist/core/session-cleanup.d.ts +49 -0
  235. package/dist/core/session-cleanup.d.ts.map +1 -0
  236. package/dist/core/session-cleanup.js +159 -0
  237. package/dist/core/session-cleanup.js.map +1 -0
  238. package/dist/core/session-index.d.ts +75 -0
  239. package/dist/core/session-index.d.ts.map +1 -0
  240. package/dist/core/session-index.js +455 -0
  241. package/dist/core/session-index.js.map +1 -0
  242. package/dist/core/session-manager.d.ts +9 -0
  243. package/dist/core/session-manager.d.ts.map +1 -1
  244. package/dist/core/session-manager.js +202 -47
  245. package/dist/core/session-manager.js.map +1 -1
  246. package/dist/core/slash-commands.d.ts.map +1 -1
  247. package/dist/core/slash-commands.js +5 -0
  248. package/dist/core/slash-commands.js.map +1 -1
  249. package/dist/core/system-prompt.d.ts.map +1 -1
  250. package/dist/core/system-prompt.js +12 -1
  251. package/dist/core/system-prompt.js.map +1 -1
  252. package/dist/core/tools/bash-operations.d.ts +41 -0
  253. package/dist/core/tools/bash-operations.d.ts.map +1 -0
  254. package/dist/core/tools/bash-operations.js +113 -0
  255. package/dist/core/tools/bash-operations.js.map +1 -0
  256. package/dist/core/tools/capability-mount.d.ts +40 -0
  257. package/dist/core/tools/capability-mount.d.ts.map +1 -0
  258. package/dist/core/tools/capability-mount.js +112 -0
  259. package/dist/core/tools/capability-mount.js.map +1 -0
  260. package/dist/core/tools/index.d.ts +12 -36
  261. package/dist/core/tools/index.d.ts.map +1 -1
  262. package/dist/core/tools/index.js +1 -117
  263. package/dist/core/tools/index.js.map +1 -1
  264. package/dist/core/tools/readme-path.d.ts +3 -0
  265. package/dist/core/tools/readme-path.d.ts.map +1 -0
  266. package/dist/core/tools/readme-path.js +15 -0
  267. package/dist/core/tools/readme-path.js.map +1 -0
  268. package/dist/index.d.ts +3 -19
  269. package/dist/index.d.ts.map +1 -1
  270. package/dist/index.js +6 -39
  271. package/dist/index.js.map +1 -1
  272. package/dist/main.d.ts.map +1 -1
  273. package/dist/main.js +1 -0
  274. package/dist/main.js.map +1 -1
  275. package/dist/modes/interactive/components/assistant-message.d.ts +3 -0
  276. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  277. package/dist/modes/interactive/components/assistant-message.js +27 -5
  278. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  279. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  280. package/dist/modes/interactive/components/session-selector-search.js +5 -1
  281. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  282. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  283. package/dist/modes/interactive/components/session-selector.js +9 -0
  284. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  285. package/dist/modes/interactive/components/tool-execution.d.ts +17 -1
  286. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  287. package/dist/modes/interactive/components/tool-execution.js +52 -25
  288. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  289. package/dist/modes/interactive/components/tool-run-group.d.ts +44 -0
  290. package/dist/modes/interactive/components/tool-run-group.d.ts.map +1 -0
  291. package/dist/modes/interactive/components/tool-run-group.js +121 -0
  292. package/dist/modes/interactive/components/tool-run-group.js.map +1 -0
  293. package/dist/modes/interactive/interactive-commands.d.ts +2 -0
  294. package/dist/modes/interactive/interactive-commands.d.ts.map +1 -1
  295. package/dist/modes/interactive/interactive-commands.js +7 -0
  296. package/dist/modes/interactive/interactive-commands.js.map +1 -1
  297. package/dist/modes/interactive/interactive-mode.d.ts +18 -0
  298. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  299. package/dist/modes/interactive/interactive-mode.js +85 -3
  300. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  301. package/dist/plugins/ecosystem/cli.d.ts.map +1 -1
  302. package/dist/plugins/ecosystem/cli.js +20 -5
  303. package/dist/plugins/ecosystem/cli.js.map +1 -1
  304. package/dist/plugins/ecosystem/node-npm-registry-source.d.ts +7 -2
  305. package/dist/plugins/ecosystem/node-npm-registry-source.d.ts.map +1 -1
  306. package/dist/plugins/ecosystem/node-npm-registry-source.js +64 -9
  307. package/dist/plugins/ecosystem/node-npm-registry-source.js.map +1 -1
  308. package/dist/plugins/ecosystem/node-plugin-acquisition-host.d.ts.map +1 -1
  309. package/dist/plugins/ecosystem/node-plugin-acquisition-host.js +6 -0
  310. package/dist/plugins/ecosystem/node-plugin-acquisition-host.js.map +1 -1
  311. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts +7 -1
  312. package/dist/plugins/ecosystem/node-plugin-bootstrap.d.ts.map +1 -1
  313. package/dist/plugins/ecosystem/node-plugin-bootstrap.js +50 -3
  314. package/dist/plugins/ecosystem/node-plugin-bootstrap.js.map +1 -1
  315. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts +28 -16
  316. package/dist/plugins/ecosystem/plugin-bootstrap.d.ts.map +1 -1
  317. package/dist/plugins/ecosystem/plugin-bootstrap.js +35 -33
  318. package/dist/plugins/ecosystem/plugin-bootstrap.js.map +1 -1
  319. package/dist/profile/plugin-profiles.d.ts +1 -1
  320. package/dist/profile/plugin-profiles.d.ts.map +1 -1
  321. package/dist/profile/plugin-profiles.js +18 -0
  322. package/dist/profile/plugin-profiles.js.map +1 -1
  323. package/dist/profiles/builtin-suites.d.ts +19 -5
  324. package/dist/profiles/builtin-suites.d.ts.map +1 -1
  325. package/dist/profiles/builtin-suites.js +26 -6
  326. package/dist/profiles/builtin-suites.js.map +1 -1
  327. package/docs/settings.md +354 -354
  328. package/docs/usage.md +292 -292
  329. package/examples/extensions/bash-spawn-hook/index.ts +7 -2
  330. package/examples/extensions/built-in-tool-renderer/index.ts +4 -2
  331. package/examples/extensions/minimal-mode/index.ts +2 -2
  332. package/examples/extensions/truncated-tool/index.ts +1 -1
  333. package/examples/extensions/with-deps/package-lock.json +2 -2
  334. package/examples/extensions/with-deps/package.json +1 -1
  335. package/examples/extensions/with-deps/plugin.json +1 -1
  336. package/package.json +3 -2
  337. package/dist/bundle/chunks/chunk-6ZKDNZHA.js +0 -145
  338. package/dist/bundle/chunks/chunk-HLJEVRWP.js +0 -13
  339. package/dist/bundle/chunks/chunk-YGHQME4V.js +0 -1456
  340. package/dist/bundle/chunks/virtual-modules-KZ5DRH7Q.js +0 -2
  341. package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts +0 -7
  342. package/dist/core/extensions/bootstrap-branch-summary-policy.d.ts.map +0 -1
  343. package/dist/core/extensions/bootstrap-branch-summary-policy.js +0 -28
  344. package/dist/core/extensions/bootstrap-branch-summary-policy.js.map +0 -1
  345. package/dist/core/extensions/bootstrap-compaction-policy.d.ts +0 -7
  346. package/dist/core/extensions/bootstrap-compaction-policy.d.ts.map +0 -1
  347. package/dist/core/extensions/bootstrap-compaction-policy.js +0 -48
  348. package/dist/core/extensions/bootstrap-compaction-policy.js.map +0 -1
  349. package/dist/core/extensions/bootstrap-overflow-policy.d.ts +0 -7
  350. package/dist/core/extensions/bootstrap-overflow-policy.d.ts.map +0 -1
  351. package/dist/core/extensions/bootstrap-overflow-policy.js +0 -30
  352. package/dist/core/extensions/bootstrap-overflow-policy.js.map +0 -1
  353. package/dist/core/extensions/bootstrap-retry-policy.d.ts +0 -7
  354. package/dist/core/extensions/bootstrap-retry-policy.d.ts.map +0 -1
  355. package/dist/core/extensions/bootstrap-retry-policy.js +0 -29
  356. package/dist/core/extensions/bootstrap-retry-policy.js.map +0 -1
  357. package/dist/core/extensions/bootstrap-tools.d.ts +0 -20
  358. package/dist/core/extensions/bootstrap-tools.d.ts.map +0 -1
  359. package/dist/core/extensions/bootstrap-tools.js +0 -36
  360. package/dist/core/extensions/bootstrap-tools.js.map +0 -1
  361. package/dist/core/extensions/provider-failover.d.ts +0 -110
  362. package/dist/core/extensions/provider-failover.d.ts.map +0 -1
  363. package/dist/core/extensions/provider-failover.js.map +0 -1
  364. package/dist/core/tools/bash.d.ts.map +0 -1
  365. package/dist/core/tools/bash.js.map +0 -1
  366. package/dist/core/tools/edit.d.ts.map +0 -1
  367. package/dist/core/tools/edit.js.map +0 -1
  368. package/dist/core/tools/find.d.ts.map +0 -1
  369. package/dist/core/tools/find.js.map +0 -1
  370. package/dist/core/tools/grep.d.ts.map +0 -1
  371. package/dist/core/tools/grep.js.map +0 -1
  372. package/dist/core/tools/ls.d.ts.map +0 -1
  373. package/dist/core/tools/powershell.d.ts.map +0 -1
  374. package/dist/core/tools/powershell.js.map +0 -1
  375. package/dist/core/tools/read.d.ts.map +0 -1
  376. package/dist/core/tools/read.js.map +0 -1
  377. package/dist/core/tools/write.d.ts.map +0 -1
  378. package/dist/core/tools/write.js.map +0 -1
  379. package/dist/plugins/mcp-http.d.ts.map +0 -1
  380. package/dist/plugins/mcp-http.js.map +0 -1
  381. package/dist/profile/child-facade.d.ts +0 -44
  382. package/dist/profile/child-facade.d.ts.map +0 -1
  383. package/dist/profile/child-facade.js +0 -56
  384. package/dist/profile/child-facade.js.map +0 -1
  385. package/dist/profile/dependency-wiring.d.ts +0 -48
  386. package/dist/profile/dependency-wiring.d.ts.map +0 -1
  387. package/dist/profile/dependency-wiring.js +0 -56
  388. package/dist/profile/dependency-wiring.js.map +0 -1
  389. package/dist/profile/domain-recovery.d.ts +0 -60
  390. package/dist/profile/domain-recovery.d.ts.map +0 -1
  391. package/dist/profile/domain-recovery.js +0 -94
  392. package/dist/profile/domain-recovery.js.map +0 -1
  393. package/dist/profile/first-roles.d.ts +0 -30
  394. package/dist/profile/first-roles.d.ts.map +0 -1
  395. package/dist/profile/first-roles.js +0 -83
  396. package/dist/profile/first-roles.js.map +0 -1
  397. package/dist/profile/goal-plugin.d.ts +0 -38
  398. package/dist/profile/goal-plugin.d.ts.map +0 -1
  399. package/dist/profile/goal-plugin.js +0 -132
  400. package/dist/profile/goal-plugin.js.map +0 -1
  401. package/dist/profile/plan-plugin.d.ts +0 -44
  402. package/dist/profile/plan-plugin.d.ts.map +0 -1
  403. package/dist/profile/plan-plugin.js +0 -157
  404. package/dist/profile/plan-plugin.js.map +0 -1
  405. package/dist/profile/policy-manifest.d.ts +0 -53
  406. package/dist/profile/policy-manifest.d.ts.map +0 -1
  407. package/dist/profile/policy-manifest.js +0 -53
  408. package/dist/profile/policy-manifest.js.map +0 -1
  409. package/dist/profile/role-assembly.d.ts +0 -47
  410. package/dist/profile/role-assembly.d.ts.map +0 -1
  411. package/dist/profile/role-assembly.js +0 -31
  412. package/dist/profile/role-assembly.js.map +0 -1
  413. package/dist/profile/role-catalog.d.ts +0 -43
  414. package/dist/profile/role-catalog.d.ts.map +0 -1
  415. package/dist/profile/role-catalog.js +0 -132
  416. package/dist/profile/role-catalog.js.map +0 -1
  417. package/dist/profile/role-orchestrator.d.ts +0 -123
  418. package/dist/profile/role-orchestrator.d.ts.map +0 -1
  419. package/dist/profile/role-orchestrator.js +0 -195
  420. package/dist/profile/role-orchestrator.js.map +0 -1
  421. package/dist/profile/role-runner.d.ts +0 -99
  422. package/dist/profile/role-runner.d.ts.map +0 -1
  423. package/dist/profile/role-runner.js +0 -79
  424. package/dist/profile/role-runner.js.map +0 -1
  425. package/dist/profile/root-facade.d.ts +0 -36
  426. package/dist/profile/root-facade.d.ts.map +0 -1
  427. package/dist/profile/root-facade.js +0 -49
  428. package/dist/profile/root-facade.js.map +0 -1
  429. package/dist/profile/skill-discovery-wiring.d.ts +0 -58
  430. package/dist/profile/skill-discovery-wiring.d.ts.map +0 -1
  431. package/dist/profile/skill-discovery-wiring.js +0 -80
  432. package/dist/profile/skill-discovery-wiring.js.map +0 -1
  433. package/dist/profile/state-store.d.ts +0 -62
  434. package/dist/profile/state-store.d.ts.map +0 -1
  435. package/dist/profile/state-store.js +0 -144
  436. package/dist/profile/state-store.js.map +0 -1
  437. package/dist/profile/todo-plugin.d.ts +0 -37
  438. package/dist/profile/todo-plugin.d.ts.map +0 -1
  439. package/dist/profile/todo-plugin.js +0 -137
  440. package/dist/profile/todo-plugin.js.map +0 -1
  441. package/examples/extensions/mcp-stdio/index.d.ts +0 -64
  442. package/examples/extensions/mcp-stdio/index.d.ts.map +0 -1
  443. package/examples/extensions/mcp-stdio/index.js +0 -292
  444. package/examples/extensions/mcp-stdio/index.js.map +0 -1
  445. /package/{dist/plugins → bundled-plugins/mcp-http/dist}/mcp-http.d.ts +0 -0
@@ -1,292 +0,0 @@
1
- /**
2
- * MCP-like JSON-RPC 2.0 stdio bridge.
3
- *
4
- * This is intentionally an external capability plugin. It discovers tools
5
- * from one explicitly configured process and exposes them through the public
6
- * CapabilityAPI; policy, approval, and server selection remain host-owned.
7
- */
8
- import { spawn } from "node:child_process";
9
- import { Type } from "typebox";
10
- export class McpStdioError extends Error {
11
- reason;
12
- details;
13
- constructor(message, reason, details = {}) {
14
- super(message);
15
- this.name = "McpStdioError";
16
- this.reason = reason;
17
- this.details = details;
18
- }
19
- }
20
- const noResult = () => ({ content: [{ type: "text", text: "" }], details: undefined });
21
- function asRecord(value, label) {
22
- if (!value || typeof value !== "object" || Array.isArray(value)) {
23
- throw new McpStdioError(`${label} must be an object`, "malformed", { data: value });
24
- }
25
- return value;
26
- }
27
- function validateToolList(value) {
28
- const object = asRecord(value, "MCP tools/list result");
29
- if (!Array.isArray(object.tools)) {
30
- throw new McpStdioError("MCP tools/list result must contain tools[]", "malformed", { data: value });
31
- }
32
- return object.tools.map((tool, index) => {
33
- const record = asRecord(tool, `MCP tool at index ${index}`);
34
- if (typeof record.name !== "string" || !record.name.trim()) {
35
- throw new McpStdioError(`MCP tool at index ${index} requires a non-empty name`, "malformed", { data: tool });
36
- }
37
- if (record.inputSchema !== undefined && (typeof record.inputSchema !== "object" || record.inputSchema === null)) {
38
- throw new McpStdioError(`MCP tool has an invalid inputSchema: ${record.name}`, "malformed", { data: tool });
39
- }
40
- return record;
41
- });
42
- }
43
- function normalizeToolResult(value) {
44
- if (value && typeof value === "object" && Array.isArray(value.content)) {
45
- return value;
46
- }
47
- if (value === undefined)
48
- return noResult();
49
- return {
50
- content: [{ type: "text", text: typeof value === "string" ? value : JSON.stringify(value) }],
51
- details: undefined,
52
- };
53
- }
54
- /** Default line-delimited stdio transport. The command is never passed to a shell. */
55
- export function spawnMcpTransport(config) {
56
- const child = spawn(config.command, [...config.args], {
57
- cwd: config.cwd,
58
- env: config.env,
59
- shell: false,
60
- stdio: ["pipe", "pipe", "pipe"],
61
- });
62
- return createJsonRpcTransport(child, config.onStderr);
63
- }
64
- function createJsonRpcTransport(child, onStderr) {
65
- let nextId = 1;
66
- let closed = false;
67
- let stdout = "";
68
- let stderr = "";
69
- let closeRequested = false;
70
- const pending = new Map();
71
- const ignored = new Set();
72
- let fatalError;
73
- const failAll = (error) => {
74
- if (fatalError)
75
- return;
76
- fatalError = error;
77
- closed = true;
78
- for (const request of pending.values())
79
- request.reject(error);
80
- pending.clear();
81
- };
82
- child.stdout.setEncoding("utf8");
83
- child.stdout.on("data", (chunk) => {
84
- stdout += chunk;
85
- const lines = stdout.split(/\r?\n/);
86
- stdout = lines.pop() ?? "";
87
- for (const line of lines) {
88
- if (!line.trim())
89
- continue;
90
- let parsed;
91
- try {
92
- parsed = JSON.parse(line);
93
- }
94
- catch {
95
- failAll(new McpStdioError("Malformed JSON-RPC response", "malformed", { stdout: line, stderr }));
96
- return;
97
- }
98
- if (parsed.jsonrpc !== "2.0") {
99
- failAll(new McpStdioError("Invalid JSON-RPC response envelope", "protocol", { data: parsed, stderr }));
100
- return;
101
- }
102
- if (parsed.id === undefined) {
103
- if (typeof parsed.method === "string")
104
- continue;
105
- failAll(new McpStdioError("JSON-RPC response is missing an id", "protocol", { data: parsed, stderr }));
106
- return;
107
- }
108
- if (typeof parsed.id !== "number" && parsed.id !== null) {
109
- failAll(new McpStdioError("Invalid JSON-RPC response id", "protocol", { data: parsed, stderr }));
110
- return;
111
- }
112
- if (parsed.id === null)
113
- continue;
114
- const responseId = parsed.id;
115
- if (ignored.delete(responseId))
116
- continue;
117
- const request = pending.get(responseId);
118
- if (!request) {
119
- failAll(new McpStdioError(`Unknown JSON-RPC response id: ${responseId}`, "protocol", { data: parsed, stderr }));
120
- return;
121
- }
122
- pending.delete(responseId);
123
- if (parsed.error) {
124
- const message = typeof parsed.error.message === "string" ? parsed.error.message : "MCP request failed";
125
- request.reject(new McpStdioError(message, "remote", {
126
- method: request.method,
127
- requestId: responseId,
128
- data: parsed.error,
129
- stderr,
130
- }));
131
- }
132
- else if (!("result" in parsed)) {
133
- request.reject(new McpStdioError("JSON-RPC response has neither result nor error", "protocol", {
134
- method: request.method,
135
- requestId: responseId,
136
- data: parsed,
137
- stderr,
138
- }));
139
- }
140
- else {
141
- request.resolve(parsed.result);
142
- }
143
- }
144
- });
145
- child.stderr.setEncoding("utf8");
146
- child.stderr.on("data", (chunk) => {
147
- stderr += chunk;
148
- onStderr?.(chunk);
149
- });
150
- child.once("error", (error) => {
151
- failAll(new McpStdioError(`Failed to spawn MCP process: ${error.message}`, "spawn", { stdout, stderr }));
152
- });
153
- child.once("close", (exitCode) => {
154
- if (closed)
155
- return;
156
- failAll(new McpStdioError(`MCP process exited with code ${exitCode ?? "unknown"}`, "exit", {
157
- stdout,
158
- stderr,
159
- exitCode,
160
- }));
161
- });
162
- const request = (method, params, options = {}) => {
163
- if (fatalError || closed)
164
- return Promise.reject(fatalError ?? new McpStdioError("MCP transport is closed", "exit", { stderr }));
165
- if (options.signal?.aborted)
166
- return Promise.reject(new McpStdioError("MCP request aborted", "aborted", { method, stderr }));
167
- const id = nextId++;
168
- return new Promise((resolve, reject) => {
169
- let timeout;
170
- const abort = () => {
171
- if (!pending.delete(id))
172
- return;
173
- ignored.add(id);
174
- if (timeout)
175
- clearTimeout(timeout);
176
- reject(new McpStdioError("MCP request aborted", "aborted", { method, requestId: id, stderr }));
177
- };
178
- pending.set(id, {
179
- method,
180
- resolve: (result) => {
181
- if (timeout)
182
- clearTimeout(timeout);
183
- options.signal?.removeEventListener("abort", abort);
184
- resolve(result);
185
- },
186
- reject: (error) => {
187
- if (timeout)
188
- clearTimeout(timeout);
189
- options.signal?.removeEventListener("abort", abort);
190
- reject(error);
191
- },
192
- });
193
- options.signal?.addEventListener("abort", abort, { once: true });
194
- if (options.timeoutMs !== undefined) {
195
- timeout = setTimeout(() => {
196
- if (!pending.delete(id))
197
- return;
198
- ignored.add(id);
199
- options.signal?.removeEventListener("abort", abort);
200
- reject(new McpStdioError("MCP request timed out", "timed_out", { method, requestId: id, stderr }));
201
- }, options.timeoutMs);
202
- }
203
- child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", id, method, ...(params === undefined ? {} : { params }) })}\n`);
204
- });
205
- };
206
- return {
207
- request,
208
- notify(method, params) {
209
- if (fatalError || closed)
210
- throw fatalError ?? new McpStdioError("MCP transport is closed", "exit", { stderr });
211
- child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method, ...(params === undefined ? {} : { params }) })}\n`);
212
- },
213
- close() {
214
- if (closeRequested)
215
- return;
216
- closeRequested = true;
217
- closed = true;
218
- for (const request of pending.values())
219
- request.reject(new McpStdioError("MCP transport closed", "exit", { stdout, stderr }));
220
- pending.clear();
221
- child.stdin.end();
222
- if (!child.killed)
223
- child.kill();
224
- },
225
- get stderr() {
226
- return stderr;
227
- },
228
- };
229
- }
230
- function validateOptions(options) {
231
- if (!options.command.trim())
232
- throw new Error("MCP stdio command requires a non-empty command");
233
- if (options.timeoutMs !== undefined && (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0)) {
234
- throw new Error("MCP stdio timeoutMs must be a positive number");
235
- }
236
- }
237
- /** Create an asynchronously discovering MCP stdio capability plugin. */
238
- export function createMcpStdioPlugin(options) {
239
- validateOptions(options);
240
- const factory = options.transportFactory ?? spawnMcpTransport;
241
- return async (api) => {
242
- const transport = await factory({
243
- command: options.command,
244
- args: options.args ?? [],
245
- cwd: options.cwd,
246
- env: options.env,
247
- onStderr: options.onStderr,
248
- });
249
- try {
250
- asRecord(await transport.request("initialize", {
251
- protocolVersion: options.protocolVersion ?? "2024-11-05",
252
- capabilities: {},
253
- clientInfo: options.clientInfo ?? { name: "agent-forge-mcp-stdio", version: "0.1.0" },
254
- }, { timeoutMs: options.timeoutMs }), "MCP initialize result");
255
- await transport.notify("notifications/initialized");
256
- const discovered = validateToolList(await transport.request("tools/list", undefined, { timeoutMs: options.timeoutMs }));
257
- for (const remote of discovered) {
258
- const name = remote.name;
259
- const schema = (remote.inputSchema ?? Type.Object({}));
260
- const definition = {
261
- name,
262
- label: name,
263
- description: typeof remote.description === "string" ? remote.description : `MCP tool: ${name}`,
264
- parameters: schema,
265
- async execute(toolCallId, params, signal, _onUpdate, _ctx) {
266
- const input = params === undefined && typeof toolCallId !== "string" ? toolCallId : params;
267
- const result = await transport.request("tools/call", { name, arguments: input ?? {} }, { signal, timeoutMs: options.timeoutMs });
268
- return normalizeToolResult(result);
269
- },
270
- };
271
- api.registerTool(definition);
272
- }
273
- return {
274
- dispose: async () => {
275
- await transport.close();
276
- },
277
- };
278
- }
279
- catch (error) {
280
- await transport.close();
281
- throw error;
282
- }
283
- };
284
- }
285
- /**
286
- * Template entry only. A working MCP transport needs a user-selected command,
287
- * arguments, and timeout; never launch an unconfigured child process.
288
- */
289
- export default function mcpStdioExample(_api) {
290
- throw new Error("Configure createMcpStdioPlugin({ command, args, timeoutMs }) before installing this MCP stdio example.");
291
- }
292
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQ3C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAa/B,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC9B,MAAM,CAAiB;IACvB,OAAO,CAAkB;IAElC,YAAY,OAAe,EAAE,MAAsB,EAAE,OAAO,GAAoB,EAAE,EAAE;QACnF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAA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C,UAAU,CAAC,CAAC;YAC9B,CAAC;YACD,OAAO;gBACN,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;oBACpB,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;gBAAA,CACxB;aACD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,KAAK,CAAC;QACb,CAAC;IAAA,CACD,CAAC;AAAA,CACF;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,IAAmB,EAAS;IACnE,MAAM,IAAI,KAAK,CACd,wGAAwG,CACxG,CAAC;AAAA,CACF","sourcesContent":["/**\n * MCP-like JSON-RPC 2.0 stdio bridge.\n *\n * This is intentionally an external capability plugin. It discovers tools\n * from one explicitly configured process and exposes them through the public\n * CapabilityAPI; policy, approval, and server selection remain host-owned.\n */\n\nimport type { ChildProcessWithoutNullStreams } from \"node:child_process\";\nimport { spawn } from \"node:child_process\";\nimport type { AgentToolResult } from \"@agent-forge/agent-core\";\nimport type {\n\tCapabilityAPI,\n\tCapabilityPluginFactory,\n\tExtensionContext,\n\tToolDefinition,\n} from \"@agent-forge/coding-agent\";\nimport { Type } from \"typebox\";\n\nexport type McpErrorReason = \"spawn\" | \"exit\" | \"malformed\" | \"protocol\" | \"remote\" | \"aborted\" | \"timed_out\";\n\nexport interface McpErrorDetails {\n\tmethod?: string;\n\trequestId?: number;\n\tstdout?: string;\n\tstderr?: string;\n\texitCode?: number | null;\n\tdata?: unknown;\n}\n\nexport class McpStdioError extends Error {\n\treadonly reason: McpErrorReason;\n\treadonly details: McpErrorDetails;\n\n\tconstructor(message: string, reason: McpErrorReason, details: McpErrorDetails = {}) {\n\t\tsuper(message);\n\t\tthis.name = \"McpStdioError\";\n\t\tthis.reason = reason;\n\t\tthis.details = details;\n\t}\n}\n\nexport interface McpRequestOptions {\n\tsignal?: AbortSignal;\n\ttimeoutMs?: number;\n}\n\nexport interface McpStdioTransport {\n\trequest(method: string, params?: unknown, options?: McpRequestOptions): Promise<unknown>;\n\tnotify(method: string, params?: unknown): Promise<void> | void;\n\tclose(): Promise<void> | void;\n\treadonly stderr?: string;\n}\n\nexport interface McpStdioTransportConfig {\n\tcommand: string;\n\targs: readonly string[];\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\tonStderr?: (text: string) => void;\n}\n\nexport type McpStdioTransportFactory = (\n\tconfig: McpStdioTransportConfig,\n) => McpStdioTransport | Promise<McpStdioTransport>;\n\nexport interface McpStdioPluginOptions {\n\tcommand: string;\n\targs?: readonly string[];\n\tcwd?: string;\n\tenv?: NodeJS.ProcessEnv;\n\ttimeoutMs?: number;\n\ttransportFactory?: McpStdioTransportFactory;\n\tonStderr?: (text: string) => void;\n\tprotocolVersion?: string;\n\tclientInfo?: { name: string; version: string };\n}\n\ninterface JsonRpcResponse {\n\tjsonrpc?: unknown;\n\tid?: unknown;\n\tmethod?: unknown;\n\tresult?: unknown;\n\terror?: { code?: unknown; message?: unknown; data?: unknown };\n}\n\nconst noResult = (): AgentToolResult<unknown> => ({ content: [{ type: \"text\", text: \"\" }], details: undefined });\n\nfunction asRecord(value: unknown, label: string): Record<string, unknown> {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new McpStdioError(`${label} must be an object`, \"malformed\", { data: value });\n\t}\n\treturn value as Record<string, unknown>;\n}\n\nfunction validateToolList(value: unknown): readonly Record<string, unknown>[] {\n\tconst object = asRecord(value, \"MCP tools/list result\");\n\tif (!Array.isArray(object.tools)) {\n\t\tthrow new McpStdioError(\"MCP tools/list result must contain tools[]\", \"malformed\", { data: value });\n\t}\n\treturn object.tools.map((tool, index) => {\n\t\tconst record = asRecord(tool, `MCP tool at index ${index}`);\n\t\tif (typeof record.name !== \"string\" || !record.name.trim()) {\n\t\t\tthrow new McpStdioError(`MCP tool at index ${index} requires a non-empty name`, \"malformed\", { data: tool });\n\t\t}\n\t\tif (record.inputSchema !== undefined && (typeof record.inputSchema !== \"object\" || record.inputSchema === null)) {\n\t\t\tthrow new McpStdioError(`MCP tool has an invalid inputSchema: ${record.name}`, \"malformed\", { data: tool });\n\t\t}\n\t\treturn record;\n\t});\n}\n\nfunction normalizeToolResult(value: unknown): AgentToolResult<unknown> {\n\tif (value && typeof value === \"object\" && Array.isArray((value as { content?: unknown }).content)) {\n\t\treturn value as AgentToolResult<unknown>;\n\t}\n\tif (value === undefined) return noResult();\n\treturn {\n\t\tcontent: [{ type: \"text\", text: typeof value === \"string\" ? value : JSON.stringify(value) }],\n\t\tdetails: undefined,\n\t};\n}\n\n/** Default line-delimited stdio transport. The command is never passed to a shell. */\nexport function spawnMcpTransport(config: McpStdioTransportConfig): McpStdioTransport {\n\tconst child = spawn(config.command, [...config.args], {\n\t\tcwd: config.cwd,\n\t\tenv: config.env,\n\t\tshell: false,\n\t\tstdio: [\"pipe\", \"pipe\", \"pipe\"],\n\t});\n\treturn createJsonRpcTransport(child, config.onStderr);\n}\n\nfunction createJsonRpcTransport(\n\tchild: ChildProcessWithoutNullStreams,\n\tonStderr?: (text: string) => void,\n): McpStdioTransport {\n\tlet nextId = 1;\n\tlet closed = false;\n\tlet stdout = \"\";\n\tlet stderr = \"\";\n\tlet closeRequested = false;\n\tconst pending = new Map<\n\t\tnumber,\n\t\t{ method: string; resolve: (value: unknown) => void; reject: (error: unknown) => void }\n\t>();\n\tconst ignored = new Set<number>();\n\tlet fatalError: McpStdioError | undefined;\n\n\tconst failAll = (error: McpStdioError): void => {\n\t\tif (fatalError) return;\n\t\tfatalError = error;\n\t\tclosed = true;\n\t\tfor (const request of pending.values()) request.reject(error);\n\t\tpending.clear();\n\t};\n\n\tchild.stdout.setEncoding(\"utf8\");\n\tchild.stdout.on(\"data\", (chunk: string) => {\n\t\tstdout += chunk;\n\t\tconst lines = stdout.split(/\\r?\\n/);\n\t\tstdout = lines.pop() ?? \"\";\n\t\tfor (const line of lines) {\n\t\t\tif (!line.trim()) continue;\n\t\t\tlet parsed: JsonRpcResponse;\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(line) as JsonRpcResponse;\n\t\t\t} catch {\n\t\t\t\tfailAll(new McpStdioError(\"Malformed JSON-RPC response\", \"malformed\", { stdout: line, stderr }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.jsonrpc !== \"2.0\") {\n\t\t\t\tfailAll(new McpStdioError(\"Invalid JSON-RPC response envelope\", \"protocol\", { data: parsed, stderr }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.id === undefined) {\n\t\t\t\tif (typeof parsed.method === \"string\") continue;\n\t\t\t\tfailAll(new McpStdioError(\"JSON-RPC response is missing an id\", \"protocol\", { data: parsed, stderr }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (typeof parsed.id !== \"number\" && parsed.id !== null) {\n\t\t\t\tfailAll(new McpStdioError(\"Invalid JSON-RPC response id\", \"protocol\", { data: parsed, stderr }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.id === null) continue;\n\t\t\tconst responseId = parsed.id as number;\n\t\t\tif (ignored.delete(responseId)) continue;\n\t\t\tconst request = pending.get(responseId);\n\t\t\tif (!request) {\n\t\t\t\tfailAll(\n\t\t\t\t\tnew McpStdioError(`Unknown JSON-RPC response id: ${responseId}`, \"protocol\", { data: parsed, stderr }),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tpending.delete(responseId);\n\t\t\tif (parsed.error) {\n\t\t\t\tconst message = typeof parsed.error.message === \"string\" ? parsed.error.message : \"MCP request failed\";\n\t\t\t\trequest.reject(\n\t\t\t\t\tnew McpStdioError(message, \"remote\", {\n\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\trequestId: responseId,\n\t\t\t\t\t\tdata: parsed.error,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else if (!(\"result\" in parsed)) {\n\t\t\t\trequest.reject(\n\t\t\t\t\tnew McpStdioError(\"JSON-RPC response has neither result nor error\", \"protocol\", {\n\t\t\t\t\t\tmethod: request.method,\n\t\t\t\t\t\trequestId: responseId,\n\t\t\t\t\t\tdata: parsed,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\trequest.resolve(parsed.result);\n\t\t\t}\n\t\t}\n\t});\n\tchild.stderr.setEncoding(\"utf8\");\n\tchild.stderr.on(\"data\", (chunk: string) => {\n\t\tstderr += chunk;\n\t\tonStderr?.(chunk);\n\t});\n\tchild.once(\"error\", (error) => {\n\t\tfailAll(new McpStdioError(`Failed to spawn MCP process: ${error.message}`, \"spawn\", { stdout, stderr }));\n\t});\n\tchild.once(\"close\", (exitCode) => {\n\t\tif (closed) return;\n\t\tfailAll(\n\t\t\tnew McpStdioError(`MCP process exited with code ${exitCode ?? \"unknown\"}`, \"exit\", {\n\t\t\t\tstdout,\n\t\t\t\tstderr,\n\t\t\t\texitCode,\n\t\t\t}),\n\t\t);\n\t});\n\n\tconst request = (method: string, params?: unknown, options: McpRequestOptions = {}): Promise<unknown> => {\n\t\tif (fatalError || closed)\n\t\t\treturn Promise.reject(fatalError ?? new McpStdioError(\"MCP transport is closed\", \"exit\", { stderr }));\n\t\tif (options.signal?.aborted)\n\t\t\treturn Promise.reject(new McpStdioError(\"MCP request aborted\", \"aborted\", { method, stderr }));\n\t\tconst id = nextId++;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tlet timeout: NodeJS.Timeout | undefined;\n\t\t\tconst abort = (): void => {\n\t\t\t\tif (!pending.delete(id)) return;\n\t\t\t\tignored.add(id);\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\treject(new McpStdioError(\"MCP request aborted\", \"aborted\", { method, requestId: id, stderr }));\n\t\t\t};\n\t\t\tpending.set(id, {\n\t\t\t\tmethod,\n\t\t\t\tresolve: (result) => {\n\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\toptions.signal?.removeEventListener(\"abort\", abort);\n\t\t\t\t\tresolve(result);\n\t\t\t\t},\n\t\t\t\treject: (error) => {\n\t\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\t\toptions.signal?.removeEventListener(\"abort\", abort);\n\t\t\t\t\treject(error);\n\t\t\t\t},\n\t\t\t});\n\t\t\toptions.signal?.addEventListener(\"abort\", abort, { once: true });\n\t\t\tif (options.timeoutMs !== undefined) {\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tif (!pending.delete(id)) return;\n\t\t\t\t\tignored.add(id);\n\t\t\t\t\toptions.signal?.removeEventListener(\"abort\", abort);\n\t\t\t\t\treject(new McpStdioError(\"MCP request timed out\", \"timed_out\", { method, requestId: id, stderr }));\n\t\t\t\t}, options.timeoutMs);\n\t\t\t}\n\t\t\tchild.stdin.write(\n\t\t\t\t`${JSON.stringify({ jsonrpc: \"2.0\", id, method, ...(params === undefined ? {} : { params }) })}\\n`,\n\t\t\t);\n\t\t});\n\t};\n\treturn {\n\t\trequest,\n\t\tnotify(method, params) {\n\t\t\tif (fatalError || closed) throw fatalError ?? new McpStdioError(\"MCP transport is closed\", \"exit\", { stderr });\n\t\t\tchild.stdin.write(\n\t\t\t\t`${JSON.stringify({ jsonrpc: \"2.0\", method, ...(params === undefined ? {} : { params }) })}\\n`,\n\t\t\t);\n\t\t},\n\t\tclose() {\n\t\t\tif (closeRequested) return;\n\t\t\tcloseRequested = true;\n\t\t\tclosed = true;\n\t\t\tfor (const request of pending.values())\n\t\t\t\trequest.reject(new McpStdioError(\"MCP transport closed\", \"exit\", { stdout, stderr }));\n\t\t\tpending.clear();\n\t\t\tchild.stdin.end();\n\t\t\tif (!child.killed) child.kill();\n\t\t},\n\t\tget stderr() {\n\t\t\treturn stderr;\n\t\t},\n\t};\n}\n\nfunction validateOptions(options: McpStdioPluginOptions): void {\n\tif (!options.command.trim()) throw new Error(\"MCP stdio command requires a non-empty command\");\n\tif (options.timeoutMs !== undefined && (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0)) {\n\t\tthrow new Error(\"MCP stdio timeoutMs must be a positive number\");\n\t}\n}\n\n/** Create an asynchronously discovering MCP stdio capability plugin. */\nexport function createMcpStdioPlugin(options: McpStdioPluginOptions): CapabilityPluginFactory {\n\tvalidateOptions(options);\n\tconst factory = options.transportFactory ?? spawnMcpTransport;\n\treturn async (api: CapabilityAPI) => {\n\t\tconst transport = await factory({\n\t\t\tcommand: options.command,\n\t\t\targs: options.args ?? [],\n\t\t\tcwd: options.cwd,\n\t\t\tenv: options.env,\n\t\t\tonStderr: options.onStderr,\n\t\t});\n\t\ttry {\n\t\t\tasRecord(\n\t\t\t\tawait transport.request(\n\t\t\t\t\t\"initialize\",\n\t\t\t\t\t{\n\t\t\t\t\t\tprotocolVersion: options.protocolVersion ?? \"2024-11-05\",\n\t\t\t\t\t\tcapabilities: {},\n\t\t\t\t\t\tclientInfo: options.clientInfo ?? { name: \"agent-forge-mcp-stdio\", version: \"0.1.0\" },\n\t\t\t\t\t},\n\t\t\t\t\t{ timeoutMs: options.timeoutMs },\n\t\t\t\t),\n\t\t\t\t\"MCP initialize result\",\n\t\t\t);\n\t\t\tawait transport.notify(\"notifications/initialized\");\n\t\t\tconst discovered = validateToolList(\n\t\t\t\tawait transport.request(\"tools/list\", undefined, { timeoutMs: options.timeoutMs }),\n\t\t\t);\n\t\t\tfor (const remote of discovered) {\n\t\t\t\tconst name = remote.name as string;\n\t\t\t\tconst schema = (remote.inputSchema ?? Type.Object({})) as ToolDefinition[\"parameters\"];\n\t\t\t\tconst definition: ToolDefinition = {\n\t\t\t\t\tname,\n\t\t\t\t\tlabel: name,\n\t\t\t\t\tdescription: typeof remote.description === \"string\" ? remote.description : `MCP tool: ${name}`,\n\t\t\t\t\tparameters: schema,\n\t\t\t\t\tasync execute(toolCallId, params, signal, _onUpdate, _ctx: ExtensionContext) {\n\t\t\t\t\t\tconst input = params === undefined && typeof toolCallId !== \"string\" ? toolCallId : params;\n\t\t\t\t\t\tconst result = await transport.request(\n\t\t\t\t\t\t\t\"tools/call\",\n\t\t\t\t\t\t\t{ name, arguments: input ?? {} },\n\t\t\t\t\t\t\t{ signal, timeoutMs: options.timeoutMs },\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn normalizeToolResult(result);\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tapi.registerTool(definition);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tdispose: async () => {\n\t\t\t\t\tawait transport.close();\n\t\t\t\t},\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tawait transport.close();\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\n/**\n * Template entry only. A working MCP transport needs a user-selected command,\n * arguments, and timeout; never launch an unconfigured child process.\n */\nexport default function mcpStdioExample(_api: CapabilityAPI): never {\n\tthrow new Error(\n\t\t\"Configure createMcpStdioPlugin({ command, args, timeoutMs }) before installing this MCP stdio example.\",\n\t);\n}\n"]}