@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 +1 @@
1
- {"version":3,"file":"agent-session-tools.js","sourceRoot":"","sources":["../../src/core/agent-session-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,gCAAgC,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,MAAM,UAAU,sBAAsB,CAAC,IAAwB,EAAsB;IACpF,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,OAAO,GAAG,IAAI;SAClB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;IACT,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CAChD;AAED,MAAM,UAAU,yBAAyB,CAAC,UAAgC,EAAY;IACrF,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,MA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ession.\n *\n * Extracted from `agent-session.ts`. Every function here operates on the\n * internal session facade ({@link AgentSessionInternals}); `AgentSession`\n * keeps same-name delegates so call sites, dynamic dispatch, and test spies\n * keep working unchanged.\n */\n\nimport type { AgentTool } from \"@agent-forge/agent-core\";\nimport type { AgentSessionInternals, ToolDefinitionEntry } from \"./agent-session-internal.ts\";\nimport {\n\tinstallSessionBootstrapSkills,\n\trefreshSessionBootstrapSkills,\n\tSKILL_CONTRIBUTION_POINT_ID,\n\tSKILL_CONTRIBUTION_POINT_VERSION,\n} from \"./extensions/index.ts\";\nimport { t } from \"./i18n/index.ts\";\nimport type { Skill } from \"./skills.ts\";\nimport { createSyntheticSourceInfo } from \"./source-info.ts\";\nimport { buildSystemPrompt } from \"./system-prompt.ts\";\nimport type { ToolDefinition, ToolExecuteContext, ToolInfo } from \"./tools/tool-definition.ts\";\nimport { wrapToolDefinition } from \"./tools/tool-definition-wrapper.ts\";\n\nexport function normalizePromptSnippet(text: string | undefined): string | undefined {\n\tif (!text) return undefined;\n\tconst oneLine = text\n\t\t.replace(/[\\r\\n]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\treturn oneLine.length > 0 ? oneLine : undefined;\n}\n\nexport function normalizePromptGuidelines(guidelines: string[] | undefined): string[] {\n\tif (!guidelines || guidelines.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst unique = new Set<string>();\n\tfor (const guideline of guidelines) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\tunique.add(normalized);\n\t\t}\n\t}\n\treturn Array.from(unique);\n}\n\n/**\n * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.\n */\nexport function getAllTools(session: AgentSessionInternals): ToolInfo[] {\n\treturn Array.from(session._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({\n\t\tname: definition.name,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t\tsourceInfo,\n\t}));\n}\n\nexport function getToolDefinition(session: AgentSessionInternals, name: string): ToolDefinition | undefined {\n\treturn session._toolDefinitions.get(name)?.definition;\n}\n\n/**\n * Set active tools by name.\n * Only tools in the registry can be enabled. Unknown tool names are ignored.\n * Also rebuilds the system prompt to reflect the new tool set.\n * Changes take effect on the next agent turn.\n */\nexport function setActiveToolsByName(session: AgentSessionInternals, toolNames: string[]): void {\n\tconst tools: AgentTool[] = [];\n\tconst validToolNames: string[] = [];\n\tfor (const name of toolNames) {\n\t\tconst tool = session._toolRegistry.get(name);\n\t\tif (tool) {\n\t\t\ttools.push(tool);\n\t\t\tvalidToolNames.push(name);\n\t\t}\n\t}\n\tsession.agent.state.tools = tools;\n\n\t// Rebuild base system prompt with new tool set\n\tsession._baseSystemPrompt = session._rebuildSystemPrompt(validToolNames);\n\tsession.agent.state.systemPrompt = session._systemPromptOverride ?? session._baseSystemPrompt;\n}\n\nexport function rebuildSystemPrompt(session: AgentSessionInternals, toolNames: string[]): string {\n\tconst validToolNames = toolNames.filter((name) => session._toolRegistry.has(name));\n\tconst toolSnippets: Record<string, string> = {};\n\tconst promptGuidelines: string[] = [];\n\tfor (const name of validToolNames) {\n\t\tconst snippet = session._toolPromptSnippets.get(name);\n\t\tif (snippet) {\n\t\t\ttoolSnippets[name] = snippet;\n\t\t}\n\n\t\tconst toolGuidelines = session._toolPromptGuidelines.get(name);\n\t\tif (toolGuidelines) {\n\t\t\tpromptGuidelines.push(...toolGuidelines);\n\t\t}\n\t}\n\n\tconst loaderSystemPrompt = session._resourceLoader.getSystemPrompt();\n\tconst loaderAppendSystemPrompt = session._resourceLoader.getAppendSystemPrompt();\n\tconst appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join(\"\\n\\n\") : undefined;\n\tconst loadedSkills = session._getAvailableSkills();\n\tconst loadedContextFiles = session._resourceLoader.getAgentsFiles().agentsFiles;\n\n\tsession._baseSystemPromptOptions = {\n\t\tcwd: session._cwd,\n\t\tskills: loadedSkills,\n\t\tcontextFiles: loadedContextFiles,\n\t\tcustomPrompt: loaderSystemPrompt,\n\t\torientationPrompt: session._orientationPrompt,\n\t\tpreferenceCard: session._preferenceCard,\n\t\tappendSystemPrompt,\n\t\tselectedTools: validToolNames,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t};\n\treturn buildSystemPrompt(session._baseSystemPromptOptions);\n}\n\nexport function refreshToolRegistry(\n\tsession: AgentSessionInternals,\n\toptions?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean },\n): void {\n\tconst previousRegistryNames = new Set(session._toolRegistry.keys());\n\tconst previousActiveToolNames = session.getActiveToolNames();\n\tconst allowedToolNames = session._allowedToolNames;\n\tconst excludedToolNames = session._excludedToolNames;\n\tconst isAllowedTool = (name: string): boolean =>\n\t\t(!allowedToolNames || allowedToolNames.has(name)) && !excludedToolNames?.has(name);\n\n\tconst allCustomTools = session._customTools\n\t\t.map((definition) => ({\n\t\t\tdefinition,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t}))\n\t\t.filter((tool) => isAllowedTool(tool.definition.name));\n\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\tArray.from(session._baseToolDefinitions.entries())\n\t\t\t.filter(([name]) => isAllowedTool(name))\n\t\t\t.map(([name, definition]) => [\n\t\t\t\tname,\n\t\t\t\t{\n\t\t\t\t\tdefinition,\n\t\t\t\t\tsourceInfo:\n\t\t\t\t\t\tsession._baseToolSources.get(name) ??\n\t\t\t\t\t\tcreateSyntheticSourceInfo(`<bootstrap:${name}>`, { source: \"agent-forge.bootstrap-tools\" }),\n\t\t\t\t},\n\t\t\t]),\n\t);\n\tfor (const tool of allCustomTools) {\n\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\tdefinition: tool.definition,\n\t\t\tsourceInfo: tool.sourceInfo,\n\t\t});\n\t}\n\tsession._toolDefinitions = definitionRegistry;\n\tsession._toolPromptSnippets = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst snippet = normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t);\n\tsession._toolPromptGuidelines = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst guidelines = normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t);\n\t// Session-resolved execute context and dynamic-tool tracking replace the\n\t// former runner-mediated wrapper: tools receive the same session facts and\n\t// a tool that activates more tools during execute still surfaces them via\n\t// addedToolNames.\n\tconst executeContext = (): ToolExecuteContext => ({\n\t\tcwd: session.sessionManager.getCwd(),\n\t\tmodel: session.model,\n\t\tsessionManager: session.sessionManager,\n\t\tthinkingLevel: session.thinkingLevel,\n\t});\n\tconst wrapWithDynamicToolTracking = ({ definition }: { definition: ToolDefinition }): AgentTool => {\n\t\tconst tool = wrapToolDefinition(definition, executeContext);\n\t\tconst execute = tool.execute;\n\t\treturn {\n\t\t\t...tool,\n\t\t\texecute: async (toolCallId, params, signal, onUpdate) => {\n\t\t\t\tconst activeBefore = session.getActiveToolNames();\n\t\t\t\tconst result = await execute(toolCallId, params, signal, onUpdate);\n\t\t\t\tconst activeAfter = session.getActiveToolNames();\n\t\t\t\tif (!activeBefore.every((name) => activeAfter.includes(name))) return result;\n\n\t\t\t\tconst beforeNames = new Set(activeBefore);\n\t\t\t\tconst addedToolNames = activeAfter.filter((name) => !beforeNames.has(name));\n\t\t\t\tif (addedToolNames.length === 0) return result;\n\t\t\t\treturn {\n\t\t\t\t\t...result,\n\t\t\t\t\taddedToolNames: [...new Set([...(result.addedToolNames ?? []), ...addedToolNames])],\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t};\n\tconst wrappedExtensionTools = allCustomTools.map(wrapWithDynamicToolTracking);\n\tconst wrappedBuiltInTools = Array.from(session._baseToolDefinitions.values())\n\t\t.filter((definition) => isAllowedTool(definition.name))\n\t\t.map((definition) => wrapWithDynamicToolTracking({ definition }));\n\n\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\ttoolRegistry.set(tool.name, tool);\n\t}\n\tsession._toolRegistry = toolRegistry;\n\n\tconst nextActiveToolNames = (\n\t\toptions?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]\n\t).filter((name) => isAllowedTool(name));\n\n\tif (allowedToolNames) {\n\t\tfor (const toolName of session._toolRegistry.keys()) {\n\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t} else if (options?.includeAllExtensionTools) {\n\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\tnextActiveToolNames.push(tool.name);\n\t\t}\n\t} else if (!options?.activeToolNames) {\n\t\tfor (const toolName of session._toolRegistry.keys()) {\n\t\t\tif (previousRegistryNames.has(toolName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Deferred tools (e.g. MCP servers configured with deferredTools)\n\t\t\t// register but stay out of the default active set until tool_search\n\t\t\t// or an explicit activation names them.\n\t\t\tif (session._deferredToolPluginIds.has(session._baseToolSources.get(toolName)?.source ?? \"\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnextActiveToolNames.push(toolName);\n\t\t}\n\t}\n\n\tsession.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n}\n\nexport function syncCapabilityTools(session: AgentSessionInternals): void {\n\tconst tools = session._capabilityRuntime?.listTools() ?? [];\n\tsession._baseToolDefinitions = new Map(tools.map(({ name, definition }) => [name, definition as ToolDefinition]));\n\tsession._baseToolSources = new Map(\n\t\ttools.map(({ name, source }) => [name, createSyntheticSourceInfo(`<plugin:${source}:${name}>`, { source })]),\n\t);\n}\n\nexport function getCapabilitySkills(session: AgentSessionInternals): Skill[] {\n\tconst runtime = session._capabilityRuntime;\n\tif (!runtime) return [];\n\t// The skill contribution point is owned by the bootstrap-skills plugin. In\n\t// hosts that never install it (assistant suite, print mode) — or while that\n\t// owner is inactive — `listContributions` throws \"Contribution point is not\n\t// defined\". That state means \"no contributed skills\", not a failure: every\n\t// tool-registry change rebuilds the system prompt, so propagating the error\n\t// turned each rebuild into an error-level plugin.log record. Any other\n\t// failure still propagates.\n\tlet contributed: ReturnType<typeof runtime.listContributions>;\n\ttry {\n\t\tcontributed = runtime.listContributions(SKILL_CONTRIBUTION_POINT_ID, SKILL_CONTRIBUTION_POINT_VERSION);\n\t} catch (error) {\n\t\tif (!(error instanceof Error) || !error.message.startsWith(\"Contribution point is not defined\")) throw error;\n\t\treturn [];\n\t}\n\tconst contributedSkills = contributed\n\t\t.filter(\n\t\t\t(entry): entry is typeof entry & { value: Skill } =>\n\t\t\t\tentry.value !== null && typeof entry.value === \"object\" && \"name\" in entry.value,\n\t\t)\n\t\t.map((entry) => ({\n\t\t\t...entry.value,\n\t\t\tdisableModelInvocation: entry.value.disableModelInvocation === true,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<contribution:${entry.owner}:${entry.id}>`, {\n\t\t\t\tsource: entry.owner,\n\t\t\t\tbaseDir: entry.value.baseDir,\n\t\t\t}),\n\t\t}));\n\tconst contributedNames = new Set(contributedSkills.map((skill) => skill.name));\n\tconst legacyFilter = session._capabilitySkillsFilter;\n\tconst legacy = runtime\n\t\t.listSkills()\n\t\t.filter(({ definition }) => !contributedNames.has(definition.name))\n\t\t.map(({ definition, source }) => ({\n\t\t\t...definition,\n\t\t\tdisableModelInvocation: definition.disableModelInvocation === true,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<plugin:${source}:${definition.name}>`, {\n\t\t\t\tsource,\n\t\t\t\tbaseDir: definition.baseDir,\n\t\t\t}),\n\t\t}))\n\t\t// Suite association filtering (方案系统 M3): the assembler owns the\n\t\t// policy; the session only applies the injected function. The\n\t\t// bootstrap-skills contribution face is already loader-filtered and\n\t\t// must not be filtered twice.\n\t\t.filter((skill) => (legacyFilter ? legacyFilter([skill]).length > 0 : true));\n\treturn [...contributedSkills, ...legacy].sort(\n\t\t(left, right) => left.name.localeCompare(right.name) || left.sourceInfo.path.localeCompare(right.sourceInfo.path),\n\t);\n}\n\nexport function validateCapabilitySkillConflicts(session: AgentSessionInternals): void {\n\tconst resourceNames = new Set<string>();\n\tconst resourceFilePaths = new Set<string>();\n\tfor (const skill of session._resourceLoader.getSkills().skills) {\n\t\tif (resourceNames.has(skill.name))\n\t\t\tthrow new Error(t(\"Skill is duplicated in resources: {name}\", { name: skill.name }));\n\t\tresourceNames.add(skill.name);\n\t\tresourceFilePaths.add(skill.filePath);\n\t}\n\tfor (const skill of session._getCapabilitySkills()) {\n\t\t// bootstrap-skills mirrors the same on-disk SKILL.md into the capability\n\t\t// layer: same name AND same file is one skill seen through two channels,\n\t\t// not a conflict. Same name from a different file (e.g. an MCP server\n\t\t// contributing a skill that collides with a disk skill) is a real one.\n\t\tif (typeof skill.filePath === \"string\" && resourceFilePaths.has(skill.filePath)) continue;\n\t\tif (resourceNames.has(skill.name))\n\t\t\tthrow new Error(t(\"Skill conflicts with a resource skill: {name}\", { name: skill.name }));\n\t}\n}\n\nexport async function refreshBootstrapSkills(session: AgentSessionInternals): Promise<void> {\n\tconst runtime = session._capabilityRuntime;\n\tif (!runtime) return;\n\tsession._validateCapabilitySkillConflicts();\n\tif (session._bootstrapSkillsHandle) {\n\t\tawait refreshSessionBootstrapSkills(runtime, session._resourceLoader.getSkills().skills);\n\t} else {\n\t\tsession._bootstrapSkillsHandle = installSessionBootstrapSkills(\n\t\t\truntime,\n\t\t\tsession._resourceLoader.getSkills().skills,\n\t\t);\n\t}\n\tsession._baseSystemPrompt = session._rebuildSystemPrompt(session.getActiveToolNames());\n\tsession.agent.state.systemPrompt = session._baseSystemPrompt;\n}\n"]}
1
+ {"version":3,"file":"agent-session-tools.js","sourceRoot":"","sources":["../../src/core/agent-session-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,gCAAgC,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,MAAM,UAAU,sBAAsB,CAAC,IAAwB,EAAsB;IACpF,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,OAAO,GAAG,IAAI;SAClB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;IACT,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CAChD;AAED,MAAM,UAAU,yBAAyB,CAAC,UAAgC,EAAY;IACrF,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5C,OAAO,EAAE,CAAC;IACX,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACxB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AC,IAAI,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,+CAA+C,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5F,CAAC;AAAA,CACD;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAA8B,EAAiB;IAC3F,MAAM,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAC3C,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,OAAO,CAAC,iCAAiC,EAAE,CAAC;IAC5C,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACpC,MAAM,6BAA6B,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC;IAC1F,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,sBAAsB,GAAG,6BAA6B,CAC7D,OAAO,EACP,OAAO,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC,MAAM,CAC1C,CAAC;IACH,CAAC;IACD,OAAO,CAAC,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC;AAAA,CAC7D","sourcesContent":["/**\n * Tool registry, capability skills, and system-prompt assembly for\n * AgentSession.\n *\n * Extracted from `agent-session.ts`. Every function here operates on the\n * internal session facade ({@link AgentSessionInternals}); `AgentSession`\n * keeps same-name delegates so call sites, dynamic dispatch, and test spies\n * keep working unchanged.\n */\n\nimport type { AgentTool } from \"@agent-forge/agent-core\";\nimport type { AgentSessionInternals, ToolDefinitionEntry } from \"./agent-session-internal.ts\";\nimport {\n\tinstallSessionBootstrapSkills,\n\trefreshSessionBootstrapSkills,\n\tSKILL_CONTRIBUTION_POINT_ID,\n\tSKILL_CONTRIBUTION_POINT_VERSION,\n} from \"./extensions/index.ts\";\nimport { t } from \"./i18n/index.ts\";\nimport type { Skill } from \"./skills.ts\";\nimport { createSyntheticSourceInfo } from \"./source-info.ts\";\nimport { buildSystemPrompt } from \"./system-prompt.ts\";\nimport type { ToolDefinition, ToolExecuteContext, ToolInfo } from \"./tools/tool-definition.ts\";\nimport { wrapToolDefinition } from \"./tools/tool-definition-wrapper.ts\";\n\nexport function normalizePromptSnippet(text: string | undefined): string | undefined {\n\tif (!text) return undefined;\n\tconst oneLine = text\n\t\t.replace(/[\\r\\n]+/g, \" \")\n\t\t.replace(/\\s+/g, \" \")\n\t\t.trim();\n\treturn oneLine.length > 0 ? oneLine : undefined;\n}\n\nexport function normalizePromptGuidelines(guidelines: string[] | undefined): string[] {\n\tif (!guidelines || guidelines.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst unique = new Set<string>();\n\tfor (const guideline of guidelines) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\tunique.add(normalized);\n\t\t}\n\t}\n\treturn Array.from(unique);\n}\n\n/**\n * Get all configured tools with name, description, parameter schema, prompt guidelines, and source metadata.\n */\nexport function getAllTools(session: AgentSessionInternals): ToolInfo[] {\n\treturn Array.from(session._toolDefinitions.values()).map(({ definition, sourceInfo }) => ({\n\t\tname: definition.name,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\tpromptGuidelines: definition.promptGuidelines,\n\t\tsourceInfo,\n\t}));\n}\n\nexport function getToolDefinition(session: AgentSessionInternals, name: string): ToolDefinition | undefined {\n\treturn session._toolDefinitions.get(name)?.definition;\n}\n\n/**\n * Set active tools by name.\n * Only tools in the registry can be enabled. Unknown tool names are ignored.\n * Also rebuilds the system prompt to reflect the new tool set.\n * Changes take effect on the next agent turn.\n */\nexport function setActiveToolsByName(session: AgentSessionInternals, toolNames: string[]): void {\n\tconst tools: AgentTool[] = [];\n\tconst validToolNames: string[] = [];\n\tfor (const name of toolNames) {\n\t\tconst tool = session._toolRegistry.get(name);\n\t\tif (tool) {\n\t\t\ttools.push(tool);\n\t\t\tvalidToolNames.push(name);\n\t\t}\n\t}\n\tsession.agent.state.tools = tools;\n\n\t// Rebuild base system prompt with new tool set\n\tsession._baseSystemPrompt = session._rebuildSystemPrompt(validToolNames);\n\tsession.agent.state.systemPrompt = session._systemPromptOverride ?? session._baseSystemPrompt;\n}\n\nexport function rebuildSystemPrompt(session: AgentSessionInternals, toolNames: string[]): string {\n\tconst validToolNames = toolNames.filter((name) => session._toolRegistry.has(name));\n\tconst toolSnippets: Record<string, string> = {};\n\tconst promptGuidelines: string[] = [];\n\tfor (const name of validToolNames) {\n\t\tconst snippet = session._toolPromptSnippets.get(name);\n\t\tif (snippet) {\n\t\t\ttoolSnippets[name] = snippet;\n\t\t}\n\n\t\tconst toolGuidelines = session._toolPromptGuidelines.get(name);\n\t\tif (toolGuidelines) {\n\t\t\tpromptGuidelines.push(...toolGuidelines);\n\t\t}\n\t}\n\n\tconst loaderSystemPrompt = session._resourceLoader.getSystemPrompt();\n\tconst loaderAppendSystemPrompt = session._resourceLoader.getAppendSystemPrompt();\n\tconst appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join(\"\\n\\n\") : undefined;\n\tconst loadedSkills = session._getAvailableSkills();\n\tconst loadedContextFiles = session._resourceLoader.getAgentsFiles().agentsFiles;\n\t// Mountable capability cards (插件按需挂载与能力手册设计 §4): only cards whose\n\t// tools are still (partially) deferred; fully mounted ones drop off.\n\tconst activeToolNameSet = new Set(validToolNames);\n\tconst sourceByToolName = new Map(\n\t\tArray.from(session._toolDefinitions.entries()).map(([name, entry]) => [name, entry.sourceInfo.source] as const),\n\t);\n\tconst capabilityCards = session._deferredCapabilityCards\n\t\t.map((card) => ({\n\t\t\tpluginId: card.pluginId,\n\t\t\tdescription: card.description,\n\t\t\tdeferred: [...sourceByToolName.entries()].some(\n\t\t\t\t([name, source]) => source === card.pluginId && !activeToolNameSet.has(name),\n\t\t\t),\n\t\t}))\n\t\t.filter((card) => card.deferred)\n\t\t.map(({ pluginId, description }) => ({ pluginId, description }));\n\n\tsession._baseSystemPromptOptions = {\n\t\tcwd: session._cwd,\n\t\tskills: loadedSkills,\n\t\tcontextFiles: loadedContextFiles,\n\t\tcustomPrompt: loaderSystemPrompt,\n\t\torientationPrompt: session._orientationPrompt,\n\t\tpreferenceCard: session._preferenceCard,\n\t\tappendSystemPrompt,\n\t\tselectedTools: validToolNames,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tcapabilityCards,\n\t};\n\treturn buildSystemPrompt(session._baseSystemPromptOptions);\n}\n\nexport function refreshToolRegistry(\n\tsession: AgentSessionInternals,\n\toptions?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean },\n): void {\n\tconst previousRegistryNames = new Set(session._toolRegistry.keys());\n\tconst previousActiveToolNames = session.getActiveToolNames();\n\tconst allowedToolNames = session._allowedToolNames;\n\tconst excludedToolNames = session._excludedToolNames;\n\tconst isAllowedTool = (name: string): boolean =>\n\t\t(!allowedToolNames || allowedToolNames.has(name)) && !excludedToolNames?.has(name);\n\n\tconst allCustomTools = session._customTools\n\t\t.map((definition) => ({\n\t\t\tdefinition,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<sdk:${definition.name}>`, { source: \"sdk\" }),\n\t\t}))\n\t\t.filter((tool) => isAllowedTool(tool.definition.name));\n\tconst definitionRegistry = new Map<string, ToolDefinitionEntry>(\n\t\tArray.from(session._baseToolDefinitions.entries())\n\t\t\t.filter(([name]) => isAllowedTool(name))\n\t\t\t.map(([name, definition]) => [\n\t\t\t\tname,\n\t\t\t\t{\n\t\t\t\t\tdefinition,\n\t\t\t\t\t// syncCapabilityTools populates _baseToolSources in lockstep with\n\t\t\t\t\t// _baseToolDefinitions, so this fallback is a desync guard only;\n\t\t\t\t\t// the default coding tools surface rides the coding-tools package\n\t\t\t\t\t// id since D-082 批 1.\n\t\t\t\t\tsourceInfo:\n\t\t\t\t\t\tsession._baseToolSources.get(name) ??\n\t\t\t\t\t\tcreateSyntheticSourceInfo(`<bootstrap:${name}>`, { source: \"agent-forge.plugin.coding-tools\" }),\n\t\t\t\t},\n\t\t\t]),\n\t);\n\tfor (const tool of allCustomTools) {\n\t\tdefinitionRegistry.set(tool.definition.name, {\n\t\t\tdefinition: tool.definition,\n\t\t\tsourceInfo: tool.sourceInfo,\n\t\t});\n\t}\n\tsession._toolDefinitions = definitionRegistry;\n\tsession._toolPromptSnippets = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst snippet = normalizePromptSnippet(definition.promptSnippet);\n\t\t\t\treturn snippet ? ([definition.name, snippet] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string] => entry !== undefined),\n\t);\n\tsession._toolPromptGuidelines = new Map(\n\t\tArray.from(definitionRegistry.values())\n\t\t\t.map(({ definition }) => {\n\t\t\t\tconst guidelines = normalizePromptGuidelines(definition.promptGuidelines);\n\t\t\t\treturn guidelines.length > 0 ? ([definition.name, guidelines] as const) : undefined;\n\t\t\t})\n\t\t\t.filter((entry): entry is readonly [string, string[]] => entry !== undefined),\n\t);\n\t// Session-resolved execute context and dynamic-tool tracking replace the\n\t// former runner-mediated wrapper: tools receive the same session facts and\n\t// a tool that activates more tools during execute still surfaces them via\n\t// addedToolNames.\n\tconst executeContext = (): ToolExecuteContext => ({\n\t\tcwd: session.sessionManager.getCwd(),\n\t\tmodel: session.model,\n\t\tsessionManager: session.sessionManager,\n\t\tthinkingLevel: session.thinkingLevel,\n\t});\n\tconst wrapWithDynamicToolTracking = ({ definition }: { definition: ToolDefinition }): AgentTool => {\n\t\tconst tool = wrapToolDefinition(definition, executeContext);\n\t\tconst execute = tool.execute;\n\t\treturn {\n\t\t\t...tool,\n\t\t\texecute: async (toolCallId, params, signal, onUpdate) => {\n\t\t\t\tconst activeBefore = session.getActiveToolNames();\n\t\t\t\tconst result = await execute(toolCallId, params, signal, onUpdate);\n\t\t\t\tconst activeAfter = session.getActiveToolNames();\n\t\t\t\tif (!activeBefore.every((name) => activeAfter.includes(name))) return result;\n\n\t\t\t\tconst beforeNames = new Set(activeBefore);\n\t\t\t\tconst addedToolNames = activeAfter.filter((name) => !beforeNames.has(name));\n\t\t\t\tif (addedToolNames.length === 0) return result;\n\t\t\t\treturn {\n\t\t\t\t\t...result,\n\t\t\t\t\taddedToolNames: [...new Set([...(result.addedToolNames ?? []), ...addedToolNames])],\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t};\n\tconst wrappedExtensionTools = allCustomTools.map(wrapWithDynamicToolTracking);\n\tconst wrappedBuiltInTools = Array.from(session._baseToolDefinitions.values())\n\t\t.filter((definition) => isAllowedTool(definition.name))\n\t\t.map((definition) => wrapWithDynamicToolTracking({ definition }));\n\n\tconst toolRegistry = new Map(wrappedBuiltInTools.map((tool) => [tool.name, tool]));\n\tfor (const tool of wrappedExtensionTools as AgentTool[]) {\n\t\ttoolRegistry.set(tool.name, tool);\n\t}\n\tsession._toolRegistry = toolRegistry;\n\n\tconst nextActiveToolNames = (\n\t\toptions?.activeToolNames ? [...options.activeToolNames] : [...previousActiveToolNames]\n\t).filter((name) => isAllowedTool(name));\n\n\tif (allowedToolNames) {\n\t\tfor (const toolName of session._toolRegistry.keys()) {\n\t\t\tif (allowedToolNames.has(toolName)) {\n\t\t\t\tnextActiveToolNames.push(toolName);\n\t\t\t}\n\t\t}\n\t} else if (options?.includeAllExtensionTools) {\n\t\tfor (const tool of wrappedExtensionTools) {\n\t\t\tnextActiveToolNames.push(tool.name);\n\t\t}\n\t} else if (!options?.activeToolNames) {\n\t\tfor (const toolName of session._toolRegistry.keys()) {\n\t\t\tif (previousRegistryNames.has(toolName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// Deferred tools (e.g. MCP servers configured with deferredTools)\n\t\t\t// register but stay out of the default active set until tool_search\n\t\t\t// or an explicit activation names them.\n\t\t\tif (session._deferredToolPluginIds.has(session._baseToolSources.get(toolName)?.source ?? \"\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tnextActiveToolNames.push(toolName);\n\t\t}\n\t}\n\n\tsession.setActiveToolsByName([...new Set(nextActiveToolNames)]);\n}\n\nexport function syncCapabilityTools(session: AgentSessionInternals): void {\n\tconst tools = session._capabilityRuntime?.listTools() ?? [];\n\tsession._baseToolDefinitions = new Map(tools.map(({ name, definition }) => [name, definition as ToolDefinition]));\n\tsession._baseToolSources = new Map(\n\t\ttools.map(({ name, source }) => [name, createSyntheticSourceInfo(`<plugin:${source}:${name}>`, { source })]),\n\t);\n}\n\nexport function getCapabilitySkills(session: AgentSessionInternals): Skill[] {\n\tconst runtime = session._capabilityRuntime;\n\tif (!runtime) return [];\n\t// The skill contribution point is owned by the bootstrap-skills plugin. In\n\t// hosts that never install it (assistant suite, print mode) — or while that\n\t// owner is inactive — `listContributions` throws \"Contribution point is not\n\t// defined\". That state means \"no contributed skills\", not a failure: every\n\t// tool-registry change rebuilds the system prompt, so propagating the error\n\t// turned each rebuild into an error-level plugin.log record. Any other\n\t// failure still propagates.\n\tlet contributed: ReturnType<typeof runtime.listContributions>;\n\ttry {\n\t\tcontributed = runtime.listContributions(SKILL_CONTRIBUTION_POINT_ID, SKILL_CONTRIBUTION_POINT_VERSION);\n\t} catch (error) {\n\t\tif (!(error instanceof Error) || !error.message.startsWith(\"Contribution point is not defined\")) throw error;\n\t\treturn [];\n\t}\n\tconst contributedSkills = contributed\n\t\t.filter(\n\t\t\t(entry): entry is typeof entry & { value: Skill } =>\n\t\t\t\tentry.value !== null && typeof entry.value === \"object\" && \"name\" in entry.value,\n\t\t)\n\t\t.map((entry) => ({\n\t\t\t...entry.value,\n\t\t\tdisableModelInvocation: entry.value.disableModelInvocation === true,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<contribution:${entry.owner}:${entry.id}>`, {\n\t\t\t\tsource: entry.owner,\n\t\t\t\tbaseDir: entry.value.baseDir,\n\t\t\t}),\n\t\t}));\n\tconst contributedNames = new Set(contributedSkills.map((skill) => skill.name));\n\tconst legacyFilter = session._capabilitySkillsFilter;\n\tconst legacy = runtime\n\t\t.listSkills()\n\t\t.filter(({ definition }) => !contributedNames.has(definition.name))\n\t\t.map(({ definition, source }) => ({\n\t\t\t...definition,\n\t\t\tdisableModelInvocation: definition.disableModelInvocation === true,\n\t\t\tsourceInfo: createSyntheticSourceInfo(`<plugin:${source}:${definition.name}>`, {\n\t\t\t\tsource,\n\t\t\t\tbaseDir: definition.baseDir,\n\t\t\t}),\n\t\t}))\n\t\t// Suite association filtering (方案系统 M3): the assembler owns the\n\t\t// policy; the session only applies the injected function. The\n\t\t// bootstrap-skills contribution face is already loader-filtered and\n\t\t// must not be filtered twice.\n\t\t.filter((skill) => (legacyFilter ? legacyFilter([skill]).length > 0 : true));\n\treturn [...contributedSkills, ...legacy].sort(\n\t\t(left, right) => left.name.localeCompare(right.name) || left.sourceInfo.path.localeCompare(right.sourceInfo.path),\n\t);\n}\n\nexport function validateCapabilitySkillConflicts(session: AgentSessionInternals): void {\n\tconst resourceNames = new Set<string>();\n\tconst resourceFilePaths = new Set<string>();\n\tfor (const skill of session._resourceLoader.getSkills().skills) {\n\t\tif (resourceNames.has(skill.name))\n\t\t\tthrow new Error(t(\"Skill is duplicated in resources: {name}\", { name: skill.name }));\n\t\tresourceNames.add(skill.name);\n\t\tresourceFilePaths.add(skill.filePath);\n\t}\n\tfor (const skill of session._getCapabilitySkills()) {\n\t\t// bootstrap-skills mirrors the same on-disk SKILL.md into the capability\n\t\t// layer: same name AND same file is one skill seen through two channels,\n\t\t// not a conflict. Same name from a different file (e.g. an MCP server\n\t\t// contributing a skill that collides with a disk skill) is a real one.\n\t\tif (typeof skill.filePath === \"string\" && resourceFilePaths.has(skill.filePath)) continue;\n\t\tif (resourceNames.has(skill.name))\n\t\t\tthrow new Error(t(\"Skill conflicts with a resource skill: {name}\", { name: skill.name }));\n\t}\n}\n\nexport async function refreshBootstrapSkills(session: AgentSessionInternals): Promise<void> {\n\tconst runtime = session._capabilityRuntime;\n\tif (!runtime) return;\n\tsession._validateCapabilitySkillConflicts();\n\tif (session._bootstrapSkillsHandle) {\n\t\tawait refreshSessionBootstrapSkills(runtime, session._resourceLoader.getSkills().skills);\n\t} else {\n\t\tsession._bootstrapSkillsHandle = installSessionBootstrapSkills(\n\t\t\truntime,\n\t\t\tsession._resourceLoader.getSkills().skills,\n\t\t);\n\t}\n\tsession._baseSystemPrompt = session._rebuildSystemPrompt(session.getActiveToolNames());\n\tsession.agent.state.systemPrompt = session._baseSystemPrompt;\n}\n"]}
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * Modes use this class and add their own I/O layer on top.
14
14
  */
15
- import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@agent-forge/agent-core";
15
+ import type { Agent, AgentEvent, AgentMessage, AgentState, ThinkingLevel } from "@agent-forge/agent-core";
16
16
  import type { Api, Transport } from "@agent-forge/ai";
17
17
  import type { ImageContent, Model, TextContent } from "@agent-forge/ai/compat";
18
18
  import type { MemoryStorageComponentsV1 } from "@agent-forge/plugin-sdk";
@@ -38,7 +38,8 @@ import type { BranchSummaryEntry, SessionEntry, SessionManager } from "./session
38
38
  import type { SessionStartMetadata } from "./session-start.ts";
39
39
  import type { SettingsManager } from "./settings-manager.ts";
40
40
  import type { Skill } from "./skills.ts";
41
- import type { BashOperations } from "./tools/bash.ts";
41
+ import type { BashOperations } from "./tools/bash-operations.ts";
42
+ import { type DeferredCapabilityCardV1 } from "./tools/capability-mount.ts";
42
43
  import type { ToolDefinition, ToolInfo } from "./tools/tool-definition.ts";
43
44
  /** Parsed skill block from a user message */
44
45
  export interface ParsedSkillBlock {
@@ -188,18 +189,23 @@ export interface AgentSessionConfig {
188
189
  */
189
190
  deferredToolPluginIds?: readonly string[];
190
191
  /**
191
- * Override base tools (useful for custom runtimes).
192
- *
193
- * These are synthesized into minimal ToolDefinitions internally so AgentSession can keep
194
- * a definition-first registry even when callers provide plain AgentTool instances.
192
+ * On-demand capability cards (插件按需挂载与能力手册设计 §4/§5): manifests
193
+ * declaring `activation: "on-demand"` surface here. Registers the
194
+ * capability_mount / capability_unmount pair; the system prompt carries a
195
+ * one-line card per still-deferred capability, and mounting returns the
196
+ * plugin's AI manual. Cards may also arrive after construction through
197
+ * {@link registerDeferredCapabilityCards} (the sdk assembly resolves them
198
+ * once the plugin pool settles).
195
199
  */
196
- baseToolsOverride?: Record<string, AgentTool>;
200
+ deferredCapabilityCards?: readonly DeferredCapabilityCardV1[];
197
201
  /**
198
202
  * Bootstrap plugin ids to SKIP at session construction (宪法 §1: bootstrap
199
203
  * 插件可禁用)。Id values are the exported BOOTSTRAP_*_PLUGIN_ID constants
200
- * ("agent-forge.bootstrap-tools" etc.). A disabled bootstrap plugin leaves
204
+ * ("agent-forge.bootstrap-skills" etc.). A disabled bootstrap plugin leaves
201
205
  * its surface absent — visible via plugin rejections/diagnostics, never a
202
- * silent kernel downgrade.
206
+ * silent kernel downgrade. The default coding tools are no longer part of
207
+ * this family (D-082 批 1): they load through the bundled manifest channel,
208
+ * whose disable face is the sdk's `disabledPluginIds`.
203
209
  */
204
210
  disabledBootstrapPlugins?: readonly string[];
205
211
  /** Session start metadata dispatched to the capability lifecycle on session start. */
@@ -471,6 +477,8 @@ export declare class AgentSession {
471
477
  private _resourceLoader;
472
478
  private _customTools;
473
479
  private _deferredToolPluginIds;
480
+ private _deferredCapabilityCards;
481
+ private _capabilityMountToolsRegistered;
474
482
  /** Abort reason supplied to the in-flight abort(); consumed by the interruption marker. */
475
483
  private _pendingAbortReason;
476
484
  /** Set when the in-flight prompt run produced an aborted terminal assistant turn. */
@@ -487,7 +495,6 @@ export declare class AgentSession {
487
495
  * builds; listeners registered on the session survive runtime rebuilds.
488
496
  */
489
497
  private readonly _dispatchOutputArtifactCommit;
490
- private _bootstrapToolsHandle?;
491
498
  private _bootstrapSkillsHandle?;
492
499
  private _bootstrapRetryHandle?;
493
500
  private _bootstrapCompactionHandle?;
@@ -497,6 +504,12 @@ export declare class AgentSession {
497
504
  private _bootstrapLifecycleHandle?;
498
505
  private _capabilityPlugins;
499
506
  private _inlineCapabilityPlugins;
507
+ /**
508
+ * 宿主装配链经 loadCapabilityPluginManifest 声明的 configOverride(按解析后
509
+ * manifest 路径)。reload 重装载循环据此回放 sdk 注入的会话事实(D-082 批 1:
510
+ * coding-tools 的 cwd/read/bash 等),会话生命周期内随同路径显式装载覆盖。
511
+ */
512
+ private _capabilityPluginConfigOverrides;
500
513
  private _isDisposingCapabilityPlugins;
501
514
  /**
502
515
  * 工具表变更钩子的两道门(见 _buildRuntime 的 onToolRegistryChange):
@@ -515,7 +528,6 @@ export declare class AgentSession {
515
528
  private _initialActiveToolNames?;
516
529
  private _allowedToolNames?;
517
530
  private _excludedToolNames?;
518
- private _baseToolsOverride?;
519
531
  private _disabledBootstrapPlugins?;
520
532
  private _sessionStartEvent;
521
533
  private _capabilityMode;
@@ -1049,6 +1061,17 @@ export declare class AgentSession {
1049
1061
  private buildExtensionResourcePaths;
1050
1062
  private getExtensionSourceLabel;
1051
1063
  private _refreshToolRegistry;
1064
+ /** Registry tool names whose owning capability plugin is `pluginId`. */
1065
+ private _toolNamesForPlugin;
1066
+ private _readManual;
1067
+ private _createCapabilityMountTools;
1068
+ /**
1069
+ * Register on-demand capability cards after construction (插件按需挂载与能力手册设计 §4).
1070
+ * The sdk assembly calls this once the plugin pool settles, before loading;
1071
+ * first call also injects the capability_mount / capability_unmount pair.
1072
+ * Idempotent: later calls replace the card set.
1073
+ */
1074
+ registerDeferredCapabilityCards(cards: readonly DeferredCapabilityCardV1[]): void;
1052
1075
  private _syncCapabilityTools;
1053
1076
  private _getCapabilitySkills;
1054
1077
  private _getAvailableSkills;