@code-yeongyu/senpi 2026.7.17 → 2026.7.20

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 (641) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +5 -2
  3. package/dist/cli/neo/build-argv.d.ts.map +1 -1
  4. package/dist/cli/neo/build-argv.js +2 -0
  5. package/dist/cli/neo/build-argv.js.map +1 -1
  6. package/dist/core/agent-session-services.d.ts.map +1 -1
  7. package/dist/core/agent-session-services.js +11 -4
  8. package/dist/core/agent-session-services.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +5 -0
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +27 -5
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/compaction/compaction.d.ts.map +1 -1
  14. package/dist/core/compaction/compaction.js +20 -4
  15. package/dist/core/compaction/compaction.js.map +1 -1
  16. package/dist/core/dynamic-prompt/build.d.ts +7 -0
  17. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  18. package/dist/core/dynamic-prompt/build.js +5 -0
  19. package/dist/core/dynamic-prompt/build.js.map +1 -1
  20. package/dist/core/dynamic-prompt/workstation.d.ts +35 -0
  21. package/dist/core/dynamic-prompt/workstation.d.ts.map +1 -0
  22. package/dist/core/dynamic-prompt/workstation.js +81 -0
  23. package/dist/core/dynamic-prompt/workstation.js.map +1 -0
  24. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  25. package/dist/core/extensions/builtin/compaction/index.js +46 -4
  26. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  27. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts +1 -0
  28. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
  29. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js +20 -2
  30. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
  31. package/dist/core/extensions/builtin/compaction/speculative.d.ts +7 -1
  32. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  33. package/dist/core/extensions/builtin/compaction/speculative.js +29 -11
  34. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  35. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts +9 -7
  36. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
  37. package/dist/core/extensions/builtin/compaction/todo-bridge.js +34 -9
  38. package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
  39. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts +1 -0
  40. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -1
  41. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js +5 -1
  42. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -1
  43. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts +2 -1
  44. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +48 -29
  46. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
  47. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +2 -2
  48. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  49. package/dist/core/extensions/builtin/gpt-apply-patch/index.js +2 -2
  50. package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
  51. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -1
  52. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  53. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +5 -3
  54. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  55. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts +7 -6
  56. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
  57. package/dist/core/extensions/builtin/gpt-apply-patch/types.js.map +1 -1
  58. package/dist/core/extensions/builtin/hooks/matcher.d.ts.map +1 -1
  59. package/dist/core/extensions/builtin/hooks/matcher.js +1 -0
  60. package/dist/core/extensions/builtin/hooks/matcher.js.map +1 -1
  61. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  62. package/dist/core/extensions/builtin/index.js +2 -0
  63. package/dist/core/extensions/builtin/index.js.map +1 -1
  64. package/dist/core/extensions/builtin/mcp/config-schema.d.ts +8 -1
  65. package/dist/core/extensions/builtin/mcp/config-schema.d.ts.map +1 -1
  66. package/dist/core/extensions/builtin/mcp/config-schema.js +23 -0
  67. package/dist/core/extensions/builtin/mcp/config-schema.js.map +1 -1
  68. package/dist/core/extensions/builtin/mcp/config.d.ts +13 -0
  69. package/dist/core/extensions/builtin/mcp/config.d.ts.map +1 -1
  70. package/dist/core/extensions/builtin/mcp/config.js +36 -0
  71. package/dist/core/extensions/builtin/mcp/config.js.map +1 -1
  72. package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +1 -1
  73. package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
  74. package/dist/core/extensions/builtin/mcp/expose/native-search.js +1 -1
  75. package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
  76. package/dist/core/extensions/builtin/mcp/expose/policy.js +1 -1
  77. package/dist/core/extensions/builtin/mcp/expose/policy.js.map +1 -1
  78. package/dist/core/extensions/builtin/mcp/expose/status.js +1 -1
  79. package/dist/core/extensions/builtin/mcp/expose/status.js.map +1 -1
  80. package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +3 -3
  81. package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/mcp/expose/tier-b.js +10 -10
  83. package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
  84. package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +3 -3
  85. package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/mcp/expose/tool-search.js +14 -14
  87. package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +1 -1
  88. package/dist/core/extensions/builtin/mcp/index.js +5 -5
  89. package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
  90. package/dist/core/extensions/builtin/mcp/service-snapshot.d.ts.map +1 -1
  91. package/dist/core/extensions/builtin/mcp/service-snapshot.js +1 -0
  92. package/dist/core/extensions/builtin/mcp/service-snapshot.js.map +1 -1
  93. package/dist/core/extensions/builtin/mcp/service-types.d.ts +12 -0
  94. package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
  95. package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
  96. package/dist/core/extensions/builtin/mcp/service.d.ts +2 -2
  97. package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
  98. package/dist/core/extensions/builtin/mcp/service.js +4 -3
  99. package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
  100. package/dist/core/extensions/builtin/mcp/status.js +1 -0
  101. package/dist/core/extensions/builtin/mcp/status.js.map +1 -1
  102. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
  103. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +5 -1
  104. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
  105. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
  106. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +5 -1
  107. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
  108. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +5 -1
  110. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
  111. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
  112. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +5 -1
  113. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
  114. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
  115. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +5 -1
  116. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
  117. package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js +2 -2
  118. package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js.map +1 -1
  119. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +1 -1
  120. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
  121. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +1 -1
  122. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
  123. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +1 -1
  124. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
  125. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +3 -3
  126. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
  127. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +3 -3
  128. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  129. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +1 -1
  130. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
  131. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts +3 -0
  132. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts.map +1 -0
  133. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js +80 -0
  134. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js.map +1 -0
  135. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +1 -1
  136. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
  137. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +1 -1
  138. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
  139. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  140. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +5 -7
  141. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  142. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  143. package/dist/core/extensions/builtin/prompt-preset/presets.js +14 -0
  144. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  145. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  146. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  147. package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
  148. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  149. package/dist/core/extensions/builtin/terminal/shared.d.ts +7 -0
  150. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  151. package/dist/core/extensions/builtin/terminal/shared.js +7 -0
  152. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  153. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
  154. package/dist/core/extensions/builtin/terminal/tools/bash.js +68 -6
  155. package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
  156. package/dist/core/extensions/builtin/todotools/commands.d.ts +18 -0
  157. package/dist/core/extensions/builtin/todotools/commands.d.ts.map +1 -0
  158. package/dist/core/extensions/builtin/todotools/commands.js +395 -0
  159. package/dist/core/extensions/builtin/todotools/commands.js.map +1 -0
  160. package/dist/core/extensions/builtin/todotools/index.d.ts +4 -1
  161. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
  162. package/dist/core/extensions/builtin/todotools/index.js +17 -14
  163. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  164. package/dist/core/extensions/builtin/todotools/markdown.d.ts +13 -0
  165. package/dist/core/extensions/builtin/todotools/markdown.d.ts.map +1 -0
  166. package/dist/core/extensions/builtin/todotools/markdown.js +82 -0
  167. package/dist/core/extensions/builtin/todotools/markdown.js.map +1 -0
  168. package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -1
  169. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  170. package/dist/core/extensions/builtin/todotools/prompt.js +50 -153
  171. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  172. package/dist/core/extensions/builtin/todotools/state.d.ts +67 -14
  173. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  174. package/dist/core/extensions/builtin/todotools/state.js +400 -35
  175. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  176. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +22 -0
  177. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -0
  178. package/dist/core/extensions/builtin/todotools/tools/todo.js +229 -0
  179. package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -0
  180. package/dist/core/extensions/builtin/video-in/index.d.ts +3 -0
  181. package/dist/core/extensions/builtin/video-in/index.d.ts.map +1 -0
  182. package/dist/core/extensions/builtin/video-in/index.js +111 -0
  183. package/dist/core/extensions/builtin/video-in/index.js.map +1 -0
  184. package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
  185. package/dist/core/extensions/builtin/websearch/index.js +20 -3
  186. package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
  187. package/dist/core/extensions/index.d.ts +1 -0
  188. package/dist/core/extensions/index.d.ts.map +1 -1
  189. package/dist/core/extensions/index.js.map +1 -1
  190. package/dist/core/extensions/loader.d.ts +10 -1
  191. package/dist/core/extensions/loader.d.ts.map +1 -1
  192. package/dist/core/extensions/loader.js +64 -7
  193. package/dist/core/extensions/loader.js.map +1 -1
  194. package/dist/core/extensions/runner.d.ts +5 -2
  195. package/dist/core/extensions/runner.d.ts.map +1 -1
  196. package/dist/core/extensions/runner.js +49 -8
  197. package/dist/core/extensions/runner.js.map +1 -1
  198. package/dist/core/extensions/types.d.ts +49 -8
  199. package/dist/core/extensions/types.d.ts.map +1 -1
  200. package/dist/core/extensions/types.js.map +1 -1
  201. package/dist/core/model-registry.d.ts +5 -1
  202. package/dist/core/model-registry.d.ts.map +1 -1
  203. package/dist/core/model-registry.js +17 -2
  204. package/dist/core/model-registry.js.map +1 -1
  205. package/dist/core/model-runtime.d.ts +12 -1
  206. package/dist/core/model-runtime.d.ts.map +1 -1
  207. package/dist/core/model-runtime.js +51 -9
  208. package/dist/core/model-runtime.js.map +1 -1
  209. package/dist/core/prompt-templates.d.ts +1 -0
  210. package/dist/core/prompt-templates.d.ts.map +1 -1
  211. package/dist/core/prompt-templates.js +4 -4
  212. package/dist/core/prompt-templates.js.map +1 -1
  213. package/dist/core/provider-composer.d.ts +1 -1
  214. package/dist/core/provider-composer.d.ts.map +1 -1
  215. package/dist/core/provider-composer.js +8 -1
  216. package/dist/core/provider-composer.js.map +1 -1
  217. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  218. package/dist/core/remote-catalog-provider.js +16 -3
  219. package/dist/core/remote-catalog-provider.js.map +1 -1
  220. package/dist/core/resource-loader.d.ts +6 -0
  221. package/dist/core/resource-loader.d.ts.map +1 -1
  222. package/dist/core/resource-loader.js +27 -2
  223. package/dist/core/resource-loader.js.map +1 -1
  224. package/dist/core/settings-manager.d.ts +6 -0
  225. package/dist/core/settings-manager.d.ts.map +1 -1
  226. package/dist/core/settings-manager.js +20 -0
  227. package/dist/core/settings-manager.js.map +1 -1
  228. package/dist/core/tools/bash.d.ts.map +1 -1
  229. package/dist/core/tools/bash.js +20 -5
  230. package/dist/core/tools/bash.js.map +1 -1
  231. package/dist/core/tools/read.js +1 -1
  232. package/dist/core/tools/read.js.map +1 -1
  233. package/dist/extensions/index.d.ts +3 -0
  234. package/dist/extensions/index.d.ts.map +1 -0
  235. package/dist/extensions/index.js +3 -0
  236. package/dist/extensions/index.js.map +1 -0
  237. package/dist/extensions/llama/client.d.ts +61 -0
  238. package/dist/extensions/llama/client.d.ts.map +1 -0
  239. package/dist/extensions/llama/client.js +298 -0
  240. package/dist/extensions/llama/client.js.map +1 -0
  241. package/dist/extensions/llama/huggingface.d.ts +23 -0
  242. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  243. package/dist/extensions/llama/huggingface.js +139 -0
  244. package/dist/extensions/llama/huggingface.js.map +1 -0
  245. package/dist/extensions/llama/index.d.ts +3 -0
  246. package/dist/extensions/llama/index.d.ts.map +1 -0
  247. package/dist/extensions/llama/index.js +208 -0
  248. package/dist/extensions/llama/index.js.map +1 -0
  249. package/dist/extensions/llama/provider.d.ts +10 -0
  250. package/dist/extensions/llama/provider.d.ts.map +1 -0
  251. package/dist/extensions/llama/provider.js +106 -0
  252. package/dist/extensions/llama/provider.js.map +1 -0
  253. package/dist/extensions/llama/ui.d.ts +42 -0
  254. package/dist/extensions/llama/ui.d.ts.map +1 -0
  255. package/dist/extensions/llama/ui.js +400 -0
  256. package/dist/extensions/llama/ui.js.map +1 -0
  257. package/dist/index.d.ts +2 -2
  258. package/dist/index.d.ts.map +1 -1
  259. package/dist/index.js.map +1 -1
  260. package/dist/main.d.ts.map +1 -1
  261. package/dist/main.js +6 -4
  262. package/dist/main.js.map +1 -1
  263. package/dist/modes/interactive/components/assistant-message.d.ts +6 -7
  264. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  265. package/dist/modes/interactive/components/assistant-message.js +154 -114
  266. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  267. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/footer.js +4 -2
  269. package/dist/modes/interactive/components/footer.js.map +1 -1
  270. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  271. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  272. package/dist/modes/interactive/components/settings-selector.js +20 -0
  273. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  274. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  275. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  276. package/dist/modes/interactive/interactive-mode.js +87 -10
  277. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  278. package/dist/modes/interactive/streaming-reveal.d.ts +35 -0
  279. package/dist/modes/interactive/streaming-reveal.d.ts.map +1 -0
  280. package/dist/modes/interactive/streaming-reveal.js +268 -0
  281. package/dist/modes/interactive/streaming-reveal.js.map +1 -0
  282. package/dist/modes/interactive/tool-args-reveal.d.ts +20 -0
  283. package/dist/modes/interactive/tool-args-reveal.d.ts.map +1 -0
  284. package/dist/modes/interactive/tool-args-reveal.js +153 -0
  285. package/dist/modes/interactive/tool-args-reveal.js.map +1 -0
  286. package/dist/utils/child-process.d.ts +17 -1
  287. package/dist/utils/child-process.d.ts.map +1 -1
  288. package/dist/utils/child-process.js +41 -1
  289. package/dist/utils/child-process.js.map +1 -1
  290. package/docs/AGENTS.md +70 -0
  291. package/docs/custom-provider.md +28 -0
  292. package/docs/extensions.md +83 -5
  293. package/docs/index.md +1 -0
  294. package/docs/llama-cpp.md +99 -0
  295. package/docs/mcp.md +21 -5
  296. package/docs/neo.md +2 -1
  297. package/docs/prompt-templates.md +1 -0
  298. package/docs/providers.md +7 -0
  299. package/docs/tui.md +41 -26
  300. package/docs/usage.md +1 -0
  301. package/examples/AGENTS.md +3 -0
  302. package/examples/extensions/README.md +1 -1
  303. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +62 -0
  304. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  305. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +59 -19
  306. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +0 -1
  307. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +69 -2
  308. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +6 -0
  309. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  310. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +19 -4
  311. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  312. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +3 -1
  313. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  314. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +4 -2
  315. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  316. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  317. package/node_modules/@earendil-works/pi-ai/README.md +1 -1
  318. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  319. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +24 -4
  320. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  321. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
  322. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  323. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +25 -1
  324. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  325. package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
  326. package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +43 -9
  327. package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
  328. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +1 -0
  329. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  330. package/node_modules/@earendil-works/pi-ai/dist/compat.js +1 -0
  331. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  332. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
  333. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  334. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
  335. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  336. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4267 -22314
  337. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  338. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +436 -1988
  339. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
  340. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +2 -1892
  341. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
  342. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +10 -80
  343. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts.map +1 -1
  344. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +2 -57
  345. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js.map +1 -1
  346. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +43 -267
  347. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
  348. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +2 -252
  349. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
  350. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +184 -883
  351. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
  352. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +2 -811
  353. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
  354. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +10 -60
  355. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts.map +1 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +2 -56
  357. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js.map +1 -1
  358. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +168 -884
  359. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
  360. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +2 -755
  361. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
  362. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +40 -286
  363. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +2 -236
  365. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -0
  367. package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -0
  368. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -0
  369. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -0
  370. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -0
  371. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -0
  372. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -0
  373. package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -0
  374. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -0
  375. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -0
  376. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -0
  377. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -0
  378. package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -0
  379. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -0
  380. package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -0
  381. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -0
  382. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -0
  383. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -0
  384. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -0
  385. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -0
  386. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -0
  387. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -0
  388. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -0
  389. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -0
  390. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -0
  391. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -0
  392. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -0
  393. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -0
  394. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -0
  395. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -0
  396. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -0
  397. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -0
  398. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -0
  399. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -0
  400. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -0
  401. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +7 -58
  402. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
  403. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -40
  404. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
  405. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +49 -362
  406. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
  407. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -292
  408. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
  409. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +85 -760
  410. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
  411. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +2 -538
  412. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
  413. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +31 -189
  414. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +2 -179
  416. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +49 -309
  418. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts.map +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +2 -285
  420. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js.map +1 -1
  421. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +22 -118
  422. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts.map +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +2 -122
  424. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js.map +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +196 -979
  426. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
  427. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +2 -884
  428. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +16 -121
  430. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +2 -98
  432. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +10 -48
  434. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts.map +1 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +2 -53
  436. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js.map +1 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +10 -48
  438. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts.map +1 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +2 -53
  440. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js.map +1 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +91 -480
  442. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts.map +1 -1
  443. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +2 -512
  444. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js.map +1 -1
  445. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +31 -257
  446. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
  447. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +2 -185
  448. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
  449. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +31 -257
  450. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
  451. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +2 -185
  452. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
  453. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +58 -541
  454. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts.map +1 -1
  455. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +2 -382
  456. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js.map +1 -1
  457. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +22 -196
  458. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
  459. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +2 -139
  460. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
  461. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +184 -954
  462. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
  463. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +2 -825
  464. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
  465. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.d.ts +1 -1
  466. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.d.ts.map +1 -1
  467. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +2 -0
  468. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
  469. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +46 -335
  470. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
  471. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +2 -273
  472. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
  473. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +163 -1185
  474. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
  475. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +2 -996
  476. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
  477. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +1076 -5750
  478. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
  479. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +2 -4910
  480. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  481. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +49 -579
  482. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
  483. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +2 -377
  484. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
  485. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +752 -3336
  486. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  487. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +2 -3263
  488. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  489. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +10 -65
  490. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
  491. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +2 -57
  492. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
  493. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +10 -63
  494. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
  495. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +2 -56
  496. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
  497. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +10 -63
  498. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
  499. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +2 -56
  500. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
  501. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +10 -63
  502. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
  503. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +2 -56
  504. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
  505. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +19 -126
  506. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts.map +1 -1
  507. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +2 -110
  508. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js.map +1 -1
  509. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +19 -144
  510. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
  511. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +2 -111
  512. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
  513. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +19 -144
  514. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
  515. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +2 -111
  516. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
  517. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
  518. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +12 -0
  519. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
  520. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
  521. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
  522. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +4 -2
  523. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
  524. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts +1 -0
  525. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts.map +1 -1
  526. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js +1 -1
  527. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js.map +1 -1
  528. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts +1 -0
  529. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts.map +1 -1
  530. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js +1 -1
  531. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js.map +1 -1
  532. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts +19 -0
  533. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts.map +1 -0
  534. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js +8 -0
  535. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js.map +1 -0
  536. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +11 -0
  537. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -1
  538. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +40 -1
  539. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -1
  540. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts +2 -0
  541. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts.map +1 -1
  542. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js +7 -4
  543. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js.map +1 -1
  544. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts +2 -0
  545. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -1
  546. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +104 -15
  547. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -1
  548. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts +15 -0
  549. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts.map +1 -0
  550. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.js +198 -0
  551. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.js.map +1 -0
  552. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.d.ts +3 -0
  553. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.d.ts.map +1 -0
  554. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.js +8 -0
  555. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.js.map +1 -0
  556. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.d.ts +6 -0
  557. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.d.ts.map +1 -0
  558. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.js +33 -0
  559. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.js.map +1 -0
  560. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.d.ts +6 -0
  561. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.d.ts.map +1 -0
  562. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.js +6 -0
  563. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.js.map +1 -0
  564. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.d.ts +4 -0
  565. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.d.ts.map +1 -0
  566. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.js +6 -0
  567. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.js.map +1 -0
  568. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.d.ts +12 -0
  569. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.d.ts.map +1 -0
  570. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.js +46 -0
  571. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.js.map +1 -0
  572. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.d.ts +4 -0
  573. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.d.ts.map +1 -0
  574. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.js +6 -0
  575. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.js.map +1 -0
  576. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts +8 -1
  577. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
  578. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +129 -27
  579. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
  580. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
  581. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js +140 -6
  582. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
  583. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
  584. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js +28 -6
  585. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
  586. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
  587. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js +51 -18
  588. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
  589. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
  590. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js +70 -9
  591. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
  592. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +6 -2
  593. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
  594. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
  595. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +16 -3
  596. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  597. package/node_modules/@earendil-works/pi-ai/dist/types.js +4 -1
  598. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  599. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  600. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -0
  601. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  602. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
  603. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js +19 -2
  604. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
  605. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts +19 -0
  606. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +1 -0
  607. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +215 -0
  608. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +1 -0
  609. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  610. package/node_modules/@earendil-works/pi-pty/dist/registry-session.d.ts +1 -1
  611. package/node_modules/@earendil-works/pi-pty/dist/registry-session.d.ts.map +1 -1
  612. package/node_modules/@earendil-works/pi-pty/dist/registry-session.js +25 -6
  613. package/node_modules/@earendil-works/pi-pty/dist/registry-session.js.map +1 -1
  614. package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts +6 -0
  615. package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts.map +1 -1
  616. package/node_modules/@earendil-works/pi-pty/dist/registry-types.js.map +1 -1
  617. package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts +1 -0
  618. package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts.map +1 -1
  619. package/node_modules/@earendil-works/pi-pty/dist/registry.js +9 -1
  620. package/node_modules/@earendil-works/pi-pty/dist/registry.js.map +1 -1
  621. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  622. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  623. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  624. package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  625. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  626. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +6 -1
  627. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  628. package/node_modules/@earendil-works/pi-tui/dist/tui.js +14 -2
  629. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  630. package/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
  631. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  632. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  633. package/package.json +6 -6
  634. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts +0 -4
  635. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +0 -1
  636. package/dist/core/extensions/builtin/todotools/tools/todoread.js +0 -37
  637. package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +0 -1
  638. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts +0 -10
  639. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +0 -1
  640. package/dist/core/extensions/builtin/todotools/tools/todowrite.js +0 -95
  641. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/status.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAQvD,MAAM,UAAU,2BAA2B,CAC1C,OAAuC,EACvC,YAA6B,EAC7B,QAAqB;IAErB,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,yDAAyD,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC7G,CAAC;IACD,+EAA+E;IAC/E,MAAM,IAAI,GACT,MAAM,CAAC,IAAI,KAAK,QAAQ;QACvB,CAAC,CAAC,gBAAgB,MAAM,CAAC,aAAa,CAAC,MAAM,gBAAgB,MAAM,CAAC,iBAAiB,CAAC,MAAM,4BAA4B;QACxH,CAAC,CAAC,SAAS,CAAC;IACd,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,IAAY,EACZ,UAA4B,EAC5B,YAA6B,EAC7B,QAAqB;IAErB,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QACvE,MAAM,OAAO,GAA0B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClE,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU;YACV,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;YAC/C,MAAM,EAAE,IAAI,CAAC,WAAW;YACxB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC,CAAC;QACJ,OAAO,2BAA2B,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;AACF,CAAC","sourcesContent":["import type { McpToolCatalogEntry } from \"../catalog.ts\";\nimport type { McpServerConfig, McpSettings } from \"../config-schema.ts\";\nimport type { ServerConnection } from \"../connection.ts\";\nimport { computeMcpExposurePolicy } from \"./policy.ts\";\n\nexport interface McpServerExposureStatus {\n\treadonly hint?: string;\n\treadonly toolCount: number | null;\n\treadonly mode?: \"direct\" | \"search\" | \"proxy\";\n}\n\nexport function getMcpCatalogExposureStatus(\n\tcatalog: readonly McpToolCatalogEntry[],\n\tserverConfig: McpServerConfig,\n\tsettings: McpSettings,\n): McpServerExposureStatus {\n\tconst policy = computeMcpExposurePolicy(catalog, serverConfig, settings);\n\tif (policy.filteredEntries.length === 0) {\n\t\treturn { hint: \"No MCP tools matched includeTools/excludeTools filters.\", toolCount: 0, mode: policy.mode };\n\t}\n\t// Report the total exposed tools; in search mode note how many are active now.\n\tconst hint =\n\t\tpolicy.mode === \"search\"\n\t\t\t? `search mode: ${policy.activeEntries.length} active now, ${policy.registeredEntries.length} searchable via mcp_search`\n\t\t\t: undefined;\n\treturn { hint, toolCount: policy.registeredEntries.length, mode: policy.mode };\n}\n\nexport async function getMcpServerExposureStatus(\n\tname: string,\n\tconnection: ServerConnection,\n\tserverConfig: McpServerConfig,\n\tsettings: McpSettings,\n): Promise<McpServerExposureStatus> {\n\ttry {\n\t\tconst result = await connection.client.listTools({}, { timeout: 500 });\n\t\tconst catalog: McpToolCatalogEntry[] = result.tools.map((tool) => ({\n\t\t\tannotations: tool.annotations,\n\t\t\tconnection,\n\t\t\tdescription: tool.description,\n\t\t\trequestTimeoutMs: serverConfig.requestTimeoutMs,\n\t\t\tschema: tool.inputSchema,\n\t\t\tserver: name,\n\t\t\ttool: tool.name,\n\t\t}));\n\t\treturn getMcpCatalogExposureStatus(catalog, serverConfig, settings);\n\t} catch {\n\t\treturn { toolCount: null };\n\t}\n}\n"]}
1
+ {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/status.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAQvD,MAAM,UAAU,2BAA2B,CAC1C,OAAuC,EACvC,YAA6B,EAC7B,QAAqB;IAErB,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,yDAAyD,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC7G,CAAC;IACD,+EAA+E;IAC/E,MAAM,IAAI,GACT,MAAM,CAAC,IAAI,KAAK,QAAQ;QACvB,CAAC,CAAC,gBAAgB,MAAM,CAAC,aAAa,CAAC,MAAM,gBAAgB,MAAM,CAAC,iBAAiB,CAAC,MAAM,6BAA6B;QACzH,CAAC,CAAC,SAAS,CAAC;IACd,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC/C,IAAY,EACZ,UAA4B,EAC5B,YAA6B,EAC7B,QAAqB;IAErB,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QACvE,MAAM,OAAO,GAA0B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClE,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU;YACV,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;YAC/C,MAAM,EAAE,IAAI,CAAC,WAAW;YACxB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC,CAAC;QACJ,OAAO,2BAA2B,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC5B,CAAC;AACF,CAAC","sourcesContent":["import type { McpToolCatalogEntry } from \"../catalog.ts\";\nimport type { McpServerConfig, McpSettings } from \"../config-schema.ts\";\nimport type { ServerConnection } from \"../connection.ts\";\nimport { computeMcpExposurePolicy } from \"./policy.ts\";\n\nexport interface McpServerExposureStatus {\n\treadonly hint?: string;\n\treadonly toolCount: number | null;\n\treadonly mode?: \"direct\" | \"search\" | \"proxy\";\n}\n\nexport function getMcpCatalogExposureStatus(\n\tcatalog: readonly McpToolCatalogEntry[],\n\tserverConfig: McpServerConfig,\n\tsettings: McpSettings,\n): McpServerExposureStatus {\n\tconst policy = computeMcpExposurePolicy(catalog, serverConfig, settings);\n\tif (policy.filteredEntries.length === 0) {\n\t\treturn { hint: \"No MCP tools matched includeTools/excludeTools filters.\", toolCount: 0, mode: policy.mode };\n\t}\n\t// Report the total exposed tools; in search mode note how many are active now.\n\tconst hint =\n\t\tpolicy.mode === \"search\"\n\t\t\t? `search mode: ${policy.activeEntries.length} active now, ${policy.registeredEntries.length} searchable via tool_search`\n\t\t\t: undefined;\n\treturn { hint, toolCount: policy.registeredEntries.length, mode: policy.mode };\n}\n\nexport async function getMcpServerExposureStatus(\n\tname: string,\n\tconnection: ServerConnection,\n\tserverConfig: McpServerConfig,\n\tsettings: McpSettings,\n): Promise<McpServerExposureStatus> {\n\ttry {\n\t\tconst result = await connection.client.listTools({}, { timeout: 500 });\n\t\tconst catalog: McpToolCatalogEntry[] = result.tools.map((tool) => ({\n\t\t\tannotations: tool.annotations,\n\t\t\tconnection,\n\t\t\tdescription: tool.description,\n\t\t\trequestTimeoutMs: serverConfig.requestTimeoutMs,\n\t\t\tschema: tool.inputSchema,\n\t\t\tserver: name,\n\t\t\ttool: tool.name,\n\t\t}));\n\t\treturn getMcpCatalogExposureStatus(catalog, serverConfig, settings);\n\t} catch {\n\t\treturn { toolCount: null };\n\t}\n}\n"]}
@@ -26,19 +26,19 @@ export interface McpTierBRegistration {
26
26
  readonly searchable: SearchableMcpTool[];
27
27
  /**
28
28
  * Replay activation markers found in session history through the SAME
29
- * activation path mcp_search uses (stub swap + stable ordering), so a
29
+ * activation path tool_search uses (stub swap + stable ordering), so a
30
30
  * resumed/compacted session restores its promoted tools without
31
31
  * re-searching. Returns the newly activated names (empty when nothing new).
32
32
  */
33
33
  rehydrateFromHistory(messages: readonly unknown[]): string[];
34
34
  /** Activate registered tools by name through the same stable path
35
- * mcp_search uses (skill lazy-reveal, todo 37). Unknown names ignored. */
35
+ * tool_search uses (skill lazy-reveal, todo 37). Unknown names ignored. */
36
36
  activate(names: readonly string[]): void;
37
37
  }
38
38
  /** Register MCP tools honouring Tier-B search mode + prompt-cache mitigations. */
39
39
  export declare function registerMcpTierBTools(pi: McpToolRegistrar, input: McpTierBRegistrationInput, warn?: WarnFn): McpTierBRegistration;
40
40
  /** A 30-70 token placeholder for an inactive search-mode tool. Keeps the tools
41
- * array length-stable under stubSwap; guides the model to mcp_search. */
41
+ * array length-stable under stubSwap; guides the model to tool_search. */
42
42
  export declare function buildMcpStubDefinition(name: string): McpToolDefinition;
43
43
  export {};
44
44
  //# sourceMappingURL=tier-b.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tier-b.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/tier-b.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAEN,KAAK,iBAAiB,EAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAIN,KAAK,iBAAiB,EAEtB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,gBAAgB,GAAG,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAAC;AACjG,KAAK,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAExC,MAAM,WAAW,yBAAyB;IACzC,wEAAwE;IACxE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC3D,0EAA0E;IAC1E,QAAQ,C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2,7 +2,7 @@
2
2
  //
3
3
  // Completes exposure:"auto": a server whose filtered tool count exceeds
4
4
  // searchThreshold enters SEARCH mode — the full catalog is registered but only
5
- // directTools stay active, and an always-active mcp_search promotes the rest on
5
+ // directTools stay active, and an always-active tool_search promotes the rest on
6
6
  // demand. Prompt-cache mitigations (SPEC §5): stable name sort everywhere;
7
7
  // activation turns accept a cache miss (documented); opt-in settings.stubSwap
8
8
  // registers 30-70-token stubs so the tools array stays length-stable and only
@@ -12,7 +12,7 @@ import { Type } from "typebox";
12
12
  import { registerToolsPreservingActiveSet } from "../active-set.js";
13
13
  import { createMcpProxyTool } from "./proxy.js";
14
14
  import { buildMcpToolDefinitions, mapMcpCatalogNames, } from "./register.js";
15
- import { createMcpSearchTool, MCP_SEARCH_TOOL_NAME, rehydrateActiveToolsFromHistory, unionStable, } from "./tool-search.js";
15
+ import { createMcpSearchTool, rehydrateActiveToolsFromHistory, TOOL_SEARCH_TOOL_NAME, unionStable, } from "./tool-search.js";
16
16
  const NOOP_REHYDRATE = () => [];
17
17
  /** Register MCP tools honouring Tier-B search mode + prompt-cache mitigations. */
18
18
  export function registerMcpTierBTools(pi, input, warn) {
@@ -76,14 +76,14 @@ export function registerMcpTierBTools(pi, input, warn) {
76
76
  activateMcpTools(unionStable(current, fresh));
77
77
  return fresh;
78
78
  };
79
- // mcp_search carries a distinct param schema, so register it on its own
79
+ // tool_search carries a distinct param schema, so register it on its own
80
80
  // rather than mixing it into the broadly-typed catalog def array.
81
81
  pi.registerTool(searchTool);
82
82
  if (!stubSwap) {
83
- // Default search mode: full defs registered, only directTools + mcp_search
83
+ // Default search mode: full defs registered, only directTools + tool_search
84
84
  // active. Newly promoted tools enter the array on their activation turn
85
85
  // (an accepted cache miss).
86
- const active = orderActiveSet([...currentBase, MCP_SEARCH_TOOL_NAME, ...activeMcpNames], reference);
86
+ const active = orderActiveSet([...currentBase, TOOL_SEARCH_TOOL_NAME, ...activeMcpNames], reference);
87
87
  registerToolsPreservingActiveSet(pi, fullDefs, active);
88
88
  return { activate, searchable, rehydrateFromHistory };
89
89
  }
@@ -96,7 +96,7 @@ export function registerMcpTierBTools(pi, input, warn) {
96
96
  stubbed.add(def.name);
97
97
  return buildMcpStubDefinition(def.name);
98
98
  });
99
- const active = orderActiveSet([...currentBase, MCP_SEARCH_TOOL_NAME, ...fullDefs.map((def) => def.name)], reference);
99
+ const active = orderActiveSet([...currentBase, TOOL_SEARCH_TOOL_NAME, ...fullDefs.map((def) => def.name)], reference);
100
100
  registerToolsPreservingActiveSet(pi, toRegister, active);
101
101
  return { activate, searchable, rehydrateFromHistory };
102
102
  }
@@ -113,7 +113,7 @@ function swapStubsToFull(pi, names, stubbed, fullByName) {
113
113
  }
114
114
  /** Order the active set deterministically WITHOUT disturbing non-MCP (base)
115
115
  * tools: base tools keep their existing relative order (by `reference` index,
116
- * new ones appended), MCP tools (incl. mcp_search) are sorted for cache
116
+ * new ones appended), MCP tools (incl. tool_search) are sorted for cache
117
117
  * stability. Sorting base tools would churn the system-prompt tool listing. */
118
118
  function orderActiveSet(names, reference) {
119
119
  const unique = [...new Set(names)];
@@ -125,17 +125,17 @@ function orderActiveSet(names, reference) {
125
125
  return [...base, ...mcp];
126
126
  }
127
127
  /** A 30-70 token placeholder for an inactive search-mode tool. Keeps the tools
128
- * array length-stable under stubSwap; guides the model to mcp_search. */
128
+ * array length-stable under stubSwap; guides the model to tool_search. */
129
129
  export function buildMcpStubDefinition(name) {
130
130
  return {
131
131
  name,
132
132
  label: name,
133
- description: `Inactive MCP tool. Run mcp_search to activate ${name}, then call it on your next turn.`,
133
+ description: `Inactive MCP tool. Run tool_search to activate ${name}, then call it on your next turn.`,
134
134
  parameters: Type.Object({}),
135
135
  executionMode: "parallel",
136
136
  async execute() {
137
137
  return {
138
- content: [{ type: "text", text: `${name} is not active. Use mcp_search to activate it, then call it.` }],
138
+ content: [{ type: "text", text: `${name} is not active. Use tool_search to activate it, then call it.` }],
139
139
  details: undefined,
140
140
  };
141
141
  },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AM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SAC1C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACtG,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpE,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED;yEACyE;AACzE,MAAM,UAAU,sBAAsB,CAAC,IAAY;IAClD,OAAO;QACN,IAAI;QACJ,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,iDAAiD,IAAI,mCAAmC;QACrG,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,aAAa,EAAE,UAAU;QACzB,KAAK,CAAC,OAAO;YACZ,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,8DAA8D,EAAE,CAAC;gBACxG,OAAO,EAAE,SAAS;aAClB,CAAC;QACH,CAAC;QACD,UAAU,CAAC,KAAK,EAAE,KAAK;YACtB,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,IAAI,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1E,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["// Tier-B adaptive exposure wiring (todo 32).\n//\n// Completes exposure:\"auto\": a server whose filtered tool count exceeds\n// searchThreshold enters SEARCH mode — the full catalog is registered but only\n// directTools stay active, and an always-active mcp_search promotes the rest on\n// demand. Prompt-cache mitigations (SPEC §5): stable name sort everywhere;\n// activation turns accept a cache miss (documented); opt-in settings.stubSwap\n// registers 30-70-token stubs so the tools array stays length-stable and only\n// the activated entry's bytes change (stub -> full) on promotion.\n\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { Type } from \"typebox\";\nimport type { ExtensionAPI } from \"../../../types.ts\";\nimport { registerToolsPreservingActiveSet } from \"../active-set.ts\";\nimport type { McpToolCatalogEntry } from \"../catalog.ts\";\nimport type { McpSettings } from \"../config-schema.ts\";\nimport { createMcpProxyTool } from \"./proxy.ts\";\nimport {\n\tbuildMcpToolDefinitions,\n\ttype McpToolDefinition,\n\ttype McpToolDetails,\n\tmapMcpCatalogNames,\n} from \"./register.ts\";\nimport {\n\tcreateMcpSearchTool,\n\tMCP_SEARCH_TOOL_NAME,\n\trehydrateActiveToolsFromHistory,\n\ttype SearchableMcpTool,\n\tunionStable,\n} from \"./tool-search.ts\";\n\ntype McpToolRegistrar = Pick<ExtensionAPI, \"getActiveTools\" | \"setActiveTools\" | \"registerTool\">;\ntype WarnFn = (message: string) => void;\n\nexport interface McpTierBRegistrationInput {\n\t/** Full catalog to register (all filtered tools across all servers). */\n\treadonly registeredEntries: readonly McpToolCatalogEntry[];\n\t/** Subset kept active immediately (direct-mode servers + directTools). */\n\treadonly activeEntries: readonly McpToolCatalogEntry[];\n\t/** True when at least one server resolved to search mode. */\n\treadonly searchMode: boolean;\n\t/** Tier-C proxy servers (todo 38): one always-active gateway tool each. */\n\treadonly proxyGateways?: readonly { server: string; entries: readonly McpToolCatalogEntry[] }[];\n\t/** Always-active utility tools (todo 39: mcp_list_resources/mcp_read_resource). */\n\treadonly utilityTools?: readonly McpToolDefinition[];\n\treadonly settings: McpSettings;\n}\n\nexport interface McpTierBRegistration {\n\t/** Searchable catalog (for reuse by /mcp status and list_changed). */\n\treadonly searchable: SearchableMcpTool[];\n\t/**\n\t * Replay activation markers found in session history through the SAME\n\t * activation path mcp_search uses (stub swap + stable ordering), so a\n\t * resumed/compacted session restores its promoted tools without\n\t * re-searching. Returns the newly activated names (empty when nothing new).\n\t */\n\trehydrateFromHistory(messages: readonly unknown[]): string[];\n\t/** Activate registered tools by name through the same stable path\n\t * mcp_search uses (skill lazy-reveal, todo 37). Unknown names ignored. */\n\tactivate(names: readonly string[]): void;\n}\n\nconst NOOP_REHYDRATE = (): string[] => [];\n\n/** Register MCP tools honouring Tier-B search mode + prompt-cache mitigations. */\nexport function registerMcpTierBTools(\n\tpi: McpToolRegistrar,\n\tinput: McpTierBRegistrationInput,\n\twarn?: WarnFn,\n): McpTierBRegistration {\n\tconst named = mapMcpCatalogNames(input.registeredEntries, warn);\n\tconst searchable: SearchableMcpTool[] = named.map(({ entry, name }) => ({\n\t\tname,\n\t\ttoolName: entry.tool,\n\t\tdescription: entry.description,\n\t\tserver: entry.server,\n\t}));\n\tconst fullDefs = buildMcpToolDefinitions(input.registeredEntries, warn);\n\tconst fullByName = new Map(fullDefs.map((def) => [def.name, def] as const));\n\tconst gatewayNames: string[] = [];\n\tfor (const gateway of input.proxyGateways ?? []) {\n\t\tconst tool = createMcpProxyTool(gateway.server, gateway.entries);\n\t\tpi.registerTool(tool);\n\t\tgatewayNames.push(tool.name);\n\t}\n\tfor (const tool of input.utilityTools ?? []) {\n\t\tpi.registerTool(tool);\n\t\tgatewayNames.push(tool.name);\n\t}\n\tconst activeMcpNames = [...mapMcpCatalogNames(input.activeEntries).map(({ name }) => name), ...gatewayNames];\n\tconst reference = pi.getActiveTools();\n\t// Base tools carry over; any stale mcp_* names from a prior generation are\n\t// dropped (membership = base + the intended mcp set; reference orders only).\n\tconst currentBase = reference.filter((name) => !name.startsWith(\"mcp_\"));\n\n\tif (!input.searchMode) {\n\t\tregisterToolsPreservingActiveSet(pi, fullDefs, orderActiveSet([...currentBase, ...activeMcpNames], reference));\n\t\t// Direct mode: everything registerable is already active, nothing to replay.\n\t\tconst activateDirect = (names: readonly string[]): void => {\n\t\t\tpi.setActiveTools(orderActiveSet(unionStable(pi.getActiveTools(), names), pi.getActiveTools()));\n\t\t};\n\t\treturn { activate: activateDirect, searchable, rehydrateFromHistory: NOOP_REHYDRATE };\n\t}\n\n\tconst stubSwap = input.settings.stubSwap === true;\n\tconst stubbed = new Set<string>();\n\tconst activateMcpTools = (names: readonly string[]): void => {\n\t\tif (stubSwap) swapStubsToFull(pi, names, stubbed, fullByName);\n\t\tpi.setActiveTools(orderActiveSet(names, pi.getActiveTools()));\n\t};\n\tconst searchTool = createMcpSearchTool({\n\t\tgetSearchableTools: () => searchable,\n\t\tgetActiveTools: () => pi.getActiveTools(),\n\t\tsetActiveTools: activateMcpTools,\n\t});\n\tconst registeredNames = new Set(fullDefs.map((def) => def.name));\n\tconst activate = (names: readonly string[]): void => {\n\t\tconst known = names.filter((name) => registeredNames.has(name));\n\t\tif (known.length === 0) return;\n\t\tactivateMcpTools(unionStable(pi.getActiveTools(), known));\n\t};\n\tconst rehydrateFromHistory = (messages: readonly unknown[]): string[] => {\n\t\tconst restored = rehydrateActiveToolsFromHistory(messages, registeredNames);\n\t\tconst current = pi.getActiveTools();\n\t\tconst fresh = restored.filter((name) => !current.includes(name));\n\t\tif (fresh.length === 0) return [];\n\t\tactivateMcpTools(unionStable(current, fresh));\n\t\treturn fresh;\n\t};\n\n\t// mcp_search carries a distinct param schema, so register it on its own\n\t// rather than mixing it into the broadly-typed catalog def array.\n\tpi.registerTool(searchTool);\n\n\tif (!stubSwap) {\n\t\t// Default search mode: full defs registered, only directTools + mcp_search\n\t\t// active. Newly promoted tools enter the array on their activation turn\n\t\t// (an accepted cache miss).\n\t\tconst active = orderActiveSet([...currentBase, MCP_SEARCH_TOOL_NAME, ...activeMcpNames], reference);\n\t\tregisterToolsPreservingActiveSet(pi, fullDefs, active);\n\t\treturn { activate, searchable, rehydrateFromHistory };\n\t}\n\n\t// stubSwap: every search-mode tool is registered as a tiny stub and kept\n\t// active so the tools array is length-stable; direct tools stay full.\n\tconst directActive = new Set(activeMcpNames);\n\tconst toRegister: McpToolDefinition[] = fullDefs.map((def) => {\n\t\tif (directActive.has(def.name)) return def;\n\t\tstubbed.add(def.name);\n\t\treturn buildMcpStubDefinition(def.name);\n\t});\n\tconst active = orderActiveSet([...currentBase, MCP_SEARCH_TOOL_NAME, ...fullDefs.map((def) => def.name)], reference);\n\tregisterToolsPreservingActiveSet(pi, toRegister, active);\n\treturn { activate, searchable, rehydrateFromHistory };\n}\n\nfunction swapStubsToFull(\n\tpi: McpToolRegistrar,\n\tnames: readonly string[],\n\tstubbed: Set<string>,\n\tfullByName: ReadonlyMap<string, McpToolDefinition>,\n): void {\n\tfor (const name of names) {\n\t\tif (!stubbed.has(name)) continue;\n\t\tconst full = fullByName.get(name);\n\t\tif (full === undefined) continue;\n\t\tpi.registerTool(full);\n\t\tstubbed.delete(name);\n\t}\n}\n\n/** Order the active set deterministically WITHOUT disturbing non-MCP (base)\n * tools: base tools keep their existing relative order (by `reference` index,\n * new ones appended), MCP tools (incl. mcp_search) are sorted for cache\n * stability. Sorting base tools would churn the system-prompt tool listing. */\nfunction orderActiveSet(names: readonly string[], reference: readonly string[]): string[] {\n\tconst unique = [...new Set(names)];\n\tconst rank = new Map(reference.map((name, index) => [name, index] as const));\n\tconst base = unique\n\t\t.filter((name) => !name.startsWith(\"mcp_\"))\n\t\t.sort((a, b) => (rank.get(a) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b) ?? Number.MAX_SAFE_INTEGER));\n\tconst mcp = unique.filter((name) => name.startsWith(\"mcp_\")).sort();\n\treturn [...base, ...mcp];\n}\n\n/** A 30-70 token placeholder for an inactive search-mode tool. Keeps the tools\n * array length-stable under stubSwap; guides the model to mcp_search. */\nexport function buildMcpStubDefinition(name: string): McpToolDefinition {\n\treturn {\n\t\tname,\n\t\tlabel: name,\n\t\tdescription: `Inactive MCP tool. Run mcp_search to activate ${name}, then call it on your next turn.`,\n\t\tparameters: Type.Object({}),\n\t\texecutionMode: \"parallel\",\n\t\tasync execute(): Promise<AgentToolResult<McpToolDetails | undefined>> {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `${name} is not active. Use mcp_search to activate it, then call it.` }],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t},\n\t\trenderCall(_args, theme) {\n\t\t\treturn new Text(theme.fg(\"toolOutput\", `${name} (inactive stub)`), 0, 0);\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"tier-b.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/tier-b.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,wEAAwE;AACxE,+EAA+E;AAC/E,iFAAiF;AACjF,2EAA2E;AAC3E,8EAA8E;AAC9E,8EAA8E;AAC9E,kEAAkE;AAGlE,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACN,uBAAuB,EAGvB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,mBAAmB,EACnB,+BAA+B,EAE/B,qBAAqB,EACrB,WAAW,GACX,MAAM,kBAAkB,CAAC;AAkC1B,MAAM,cAAc,GAAG,GAAa,EAAE,CAAC,EAAE,CAAC;AAE1C,kFAAkF;AAClF,MAAM,UAAU,qBAAqB,CACpC,EAAoB,EACpB,KAAgC,EAChC,IAAa;IAEb,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAChE,MAAM,UAAU,GAAwB,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,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;QACH,CAAC;QACD,UAAU,CAAC,KAAK,EAAE,KAAK;YACtB,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,IAAI,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1E,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["// Tier-B adaptive exposure wiring (todo 32).\n//\n// Completes exposure:\"auto\": a server whose filtered tool count exceeds\n// searchThreshold enters SEARCH mode — the full catalog is registered but only\n// directTools stay active, and an always-active tool_search promotes the rest on\n// demand. Prompt-cache mitigations (SPEC §5): stable name sort everywhere;\n// activation turns accept a cache miss (documented); opt-in settings.stubSwap\n// registers 30-70-token stubs so the tools array stays length-stable and only\n// the activated entry's bytes change (stub -> full) on promotion.\n\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { Type } from \"typebox\";\nimport type { ExtensionAPI } from \"../../../types.ts\";\nimport { registerToolsPreservingActiveSet } from \"../active-set.ts\";\nimport type { McpToolCatalogEntry } from \"../catalog.ts\";\nimport type { McpSettings } from \"../config-schema.ts\";\nimport { createMcpProxyTool } from \"./proxy.ts\";\nimport {\n\tbuildMcpToolDefinitions,\n\ttype McpToolDefinition,\n\ttype McpToolDetails,\n\tmapMcpCatalogNames,\n} from \"./register.ts\";\nimport {\n\tcreateMcpSearchTool,\n\trehydrateActiveToolsFromHistory,\n\ttype SearchableMcpTool,\n\tTOOL_SEARCH_TOOL_NAME,\n\tunionStable,\n} from \"./tool-search.ts\";\n\ntype McpToolRegistrar = Pick<ExtensionAPI, \"getActiveTools\" | \"setActiveTools\" | \"registerTool\">;\ntype WarnFn = (message: string) => void;\n\nexport interface McpTierBRegistrationInput {\n\t/** Full catalog to register (all filtered tools across all servers). */\n\treadonly registeredEntries: readonly McpToolCatalogEntry[];\n\t/** Subset kept active immediately (direct-mode servers + directTools). */\n\treadonly activeEntries: readonly McpToolCatalogEntry[];\n\t/** True when at least one server resolved to search mode. */\n\treadonly searchMode: boolean;\n\t/** Tier-C proxy servers (todo 38): one always-active gateway tool each. */\n\treadonly proxyGateways?: readonly { server: string; entries: readonly McpToolCatalogEntry[] }[];\n\t/** Always-active utility tools (todo 39: mcp_list_resources/mcp_read_resource). */\n\treadonly utilityTools?: readonly McpToolDefinition[];\n\treadonly settings: McpSettings;\n}\n\nexport interface McpTierBRegistration {\n\t/** Searchable catalog (for reuse by /mcp status and list_changed). */\n\treadonly searchable: SearchableMcpTool[];\n\t/**\n\t * Replay activation markers found in session history through the SAME\n\t * activation path tool_search uses (stub swap + stable ordering), so a\n\t * resumed/compacted session restores its promoted tools without\n\t * re-searching. Returns the newly activated names (empty when nothing new).\n\t */\n\trehydrateFromHistory(messages: readonly unknown[]): string[];\n\t/** Activate registered tools by name through the same stable path\n\t * tool_search uses (skill lazy-reveal, todo 37). Unknown names ignored. */\n\tactivate(names: readonly string[]): void;\n}\n\nconst NOOP_REHYDRATE = (): string[] => [];\n\n/** Register MCP tools honouring Tier-B search mode + prompt-cache mitigations. */\nexport function registerMcpTierBTools(\n\tpi: McpToolRegistrar,\n\tinput: McpTierBRegistrationInput,\n\twarn?: WarnFn,\n): McpTierBRegistration {\n\tconst named = mapMcpCatalogNames(input.registeredEntries, warn);\n\tconst searchable: SearchableMcpTool[] = named.map(({ entry, name }) => ({\n\t\tname,\n\t\ttoolName: entry.tool,\n\t\tdescription: entry.description,\n\t\tserver: entry.server,\n\t}));\n\tconst fullDefs = buildMcpToolDefinitions(input.registeredEntries, warn);\n\tconst fullByName = new Map(fullDefs.map((def) => [def.name, def] as const));\n\tconst gatewayNames: string[] = [];\n\tfor (const gateway of input.proxyGateways ?? []) {\n\t\tconst tool = createMcpProxyTool(gateway.server, gateway.entries);\n\t\tpi.registerTool(tool);\n\t\tgatewayNames.push(tool.name);\n\t}\n\tfor (const tool of input.utilityTools ?? []) {\n\t\tpi.registerTool(tool);\n\t\tgatewayNames.push(tool.name);\n\t}\n\tconst activeMcpNames = [...mapMcpCatalogNames(input.activeEntries).map(({ name }) => name), ...gatewayNames];\n\tconst reference = pi.getActiveTools();\n\t// Base tools carry over; any stale mcp_* names from a prior generation are\n\t// dropped (membership = base + the intended mcp set; reference orders only).\n\tconst currentBase = reference.filter((name) => !name.startsWith(\"mcp_\"));\n\n\tif (!input.searchMode) {\n\t\tregisterToolsPreservingActiveSet(pi, fullDefs, orderActiveSet([...currentBase, ...activeMcpNames], reference));\n\t\t// Direct mode: everything registerable is already active, nothing to replay.\n\t\tconst activateDirect = (names: readonly string[]): void => {\n\t\t\tpi.setActiveTools(orderActiveSet(unionStable(pi.getActiveTools(), names), pi.getActiveTools()));\n\t\t};\n\t\treturn { activate: activateDirect, searchable, rehydrateFromHistory: NOOP_REHYDRATE };\n\t}\n\n\tconst stubSwap = input.settings.stubSwap === true;\n\tconst stubbed = new Set<string>();\n\tconst activateMcpTools = (names: readonly string[]): void => {\n\t\tif (stubSwap) swapStubsToFull(pi, names, stubbed, fullByName);\n\t\tpi.setActiveTools(orderActiveSet(names, pi.getActiveTools()));\n\t};\n\tconst searchTool = createMcpSearchTool({\n\t\tgetSearchableTools: () => searchable,\n\t\tgetActiveTools: () => pi.getActiveTools(),\n\t\tsetActiveTools: activateMcpTools,\n\t});\n\tconst registeredNames = new Set(fullDefs.map((def) => def.name));\n\tconst activate = (names: readonly string[]): void => {\n\t\tconst known = names.filter((name) => registeredNames.has(name));\n\t\tif (known.length === 0) return;\n\t\tactivateMcpTools(unionStable(pi.getActiveTools(), known));\n\t};\n\tconst rehydrateFromHistory = (messages: readonly unknown[]): string[] => {\n\t\tconst restored = rehydrateActiveToolsFromHistory(messages, registeredNames);\n\t\tconst current = pi.getActiveTools();\n\t\tconst fresh = restored.filter((name) => !current.includes(name));\n\t\tif (fresh.length === 0) return [];\n\t\tactivateMcpTools(unionStable(current, fresh));\n\t\treturn fresh;\n\t};\n\n\t// tool_search carries a distinct param schema, so register it on its own\n\t// rather than mixing it into the broadly-typed catalog def array.\n\tpi.registerTool(searchTool);\n\n\tif (!stubSwap) {\n\t\t// Default search mode: full defs registered, only directTools + tool_search\n\t\t// active. Newly promoted tools enter the array on their activation turn\n\t\t// (an accepted cache miss).\n\t\tconst active = orderActiveSet([...currentBase, TOOL_SEARCH_TOOL_NAME, ...activeMcpNames], reference);\n\t\tregisterToolsPreservingActiveSet(pi, fullDefs, active);\n\t\treturn { activate, searchable, rehydrateFromHistory };\n\t}\n\n\t// stubSwap: every search-mode tool is registered as a tiny stub and kept\n\t// active so the tools array is length-stable; direct tools stay full.\n\tconst directActive = new Set(activeMcpNames);\n\tconst toRegister: McpToolDefinition[] = fullDefs.map((def) => {\n\t\tif (directActive.has(def.name)) return def;\n\t\tstubbed.add(def.name);\n\t\treturn buildMcpStubDefinition(def.name);\n\t});\n\tconst active = orderActiveSet(\n\t\t[...currentBase, TOOL_SEARCH_TOOL_NAME, ...fullDefs.map((def) => def.name)],\n\t\treference,\n\t);\n\tregisterToolsPreservingActiveSet(pi, toRegister, active);\n\treturn { activate, searchable, rehydrateFromHistory };\n}\n\nfunction swapStubsToFull(\n\tpi: McpToolRegistrar,\n\tnames: readonly string[],\n\tstubbed: Set<string>,\n\tfullByName: ReadonlyMap<string, McpToolDefinition>,\n): void {\n\tfor (const name of names) {\n\t\tif (!stubbed.has(name)) continue;\n\t\tconst full = fullByName.get(name);\n\t\tif (full === undefined) continue;\n\t\tpi.registerTool(full);\n\t\tstubbed.delete(name);\n\t}\n}\n\n/** Order the active set deterministically WITHOUT disturbing non-MCP (base)\n * tools: base tools keep their existing relative order (by `reference` index,\n * new ones appended), MCP tools (incl. tool_search) are sorted for cache\n * stability. Sorting base tools would churn the system-prompt tool listing. */\nfunction orderActiveSet(names: readonly string[], reference: readonly string[]): string[] {\n\tconst unique = [...new Set(names)];\n\tconst rank = new Map(reference.map((name, index) => [name, index] as const));\n\tconst base = unique\n\t\t.filter((name) => !name.startsWith(\"mcp_\"))\n\t\t.sort((a, b) => (rank.get(a) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b) ?? Number.MAX_SAFE_INTEGER));\n\tconst mcp = unique.filter((name) => name.startsWith(\"mcp_\")).sort();\n\treturn [...base, ...mcp];\n}\n\n/** A 30-70 token placeholder for an inactive search-mode tool. Keeps the tools\n * array length-stable under stubSwap; guides the model to tool_search. */\nexport function buildMcpStubDefinition(name: string): McpToolDefinition {\n\treturn {\n\t\tname,\n\t\tlabel: name,\n\t\tdescription: `Inactive MCP tool. Run tool_search to activate ${name}, then call it on your next turn.`,\n\t\tparameters: Type.Object({}),\n\t\texecutionMode: \"parallel\",\n\t\tasync execute(): Promise<AgentToolResult<McpToolDetails | undefined>> {\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: `${name} is not active. Use tool_search to activate it, then call it.` }],\n\t\t\t\tdetails: undefined,\n\t\t\t};\n\t\t},\n\t\trenderCall(_args, theme) {\n\t\t\treturn new Text(theme.fg(\"toolOutput\", `${name} (inactive stub)`), 0, 0);\n\t\t},\n\t};\n}\n"]}
@@ -1,10 +1,10 @@
1
1
  import { Type } from "typebox";
2
2
  import type { ToolDefinition } from "../../../types.ts";
3
3
  import { type Bm25Doc } from "./bm25.ts";
4
- export declare const MCP_SEARCH_TOOL_NAME = "mcp_search";
4
+ export declare const TOOL_SEARCH_TOOL_NAME = "tool_search";
5
5
  /** Stable, machine-parseable marker embedded in every activating result so
6
6
  * activations survive compaction/restart. Kept human-readable on purpose. */
7
- export declare const MCP_SEARCH_ACTIVATION_MARKER = "[mcp_search:activated]";
7
+ export declare const TOOL_SEARCH_ACTIVATION_MARKER = "[tool_search:activated]";
8
8
  export type SearchableMcpTool = Bm25Doc;
9
9
  export interface McpSearchDeps {
10
10
  /** Full current catalog (all MCP tools, active or not) to rank over. */
@@ -30,7 +30,7 @@ interface RankedMatch {
30
30
  }
31
31
  export declare function buildMcpSearchResultText(query: string, matches: readonly RankedMatch[], server: string | undefined): string;
32
32
  /**
33
- * Replay mcp_search activations recorded in prior history so a
33
+ * Replay tool_search activations recorded in prior history so a
34
34
  * compacted/restarted session restores its active tool set without re-searching.
35
35
  * Only names still present in `validNames` are restored (removed tools stay
36
36
  * dropped). Deterministic: returns a de-duplicated, sorted list.
@@ -1 +1 @@
1
- {"version":3,"file":"tool-search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/tool-search.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,WAAW,CAAC;AAEzD,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD;6EAC6E;AAC7E,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AAGrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAExC,MAAM,WAAW,aAAa;IAC7B,wEAAwE;IACxE,kBAAkB,IAAI,SAAS,iBAAiB,EAAE,CAAC;IACnD,0DAA0D;IAC1D,cAAc,IAAI,MAAM,EAAE,CAAC;IAC3B,4EAA4E;IAC5E,cAAc,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,QAAA,MAAM,YAAY;;;EAGhB,CAAC;AAGH,KAAK,aAAa,GAAG,cAAc,CAAC,OAAO,YAAY,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAmCtE;AAED,UAAU,WAAW;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;CAChC;AAED,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,MAA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EpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,aAAa,CAmCtE;AAED,UAAU,WAAW;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;CAChC;AAED,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,SAAS,WAAW,EAAE,EAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,CAgBR;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC9C,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,GAC7B,MAAM,EAAE,CAUV;AAsBD;2CAC2C;AAC3C,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAE1F"}
@@ -1,6 +1,6 @@
1
- // mcp_search tool + promotion engine (todo 31).
1
+ // tool_search tool + promotion engine (todo 31).
2
2
  //
3
- // `mcp_search` is an always-active tool that ranks the full MCP catalog with
3
+ // `tool_search` is an always-active tool that ranks the full MCP catalog with
4
4
  // the local BM25 engine and PROMOTES matched tools into the active set via
5
5
  // setActiveTools (effective the NEXT turn — senpi semantics). Promotion state
6
6
  // is derivable from history: each result embeds a stable activation marker so a
@@ -10,10 +10,10 @@
10
10
  import { Text } from "@earendil-works/pi-tui";
11
11
  import { Type } from "typebox";
12
12
  import { buildBm25Index } from "./bm25.js";
13
- export const MCP_SEARCH_TOOL_NAME = "mcp_search";
13
+ export const TOOL_SEARCH_TOOL_NAME = "tool_search";
14
14
  /** Stable, machine-parseable marker embedded in every activating result so
15
15
  * activations survive compaction/restart. Kept human-readable on purpose. */
16
- export const MCP_SEARCH_ACTIVATION_MARKER = "[mcp_search:activated]";
16
+ export const TOOL_SEARCH_ACTIVATION_MARKER = "[tool_search:activated]";
17
17
  const MAX_RESULTS = 10;
18
18
  const ParamsSchema = Type.Object({
19
19
  query: Type.String({ description: "Natural-language description of the capability you need." }),
@@ -21,7 +21,7 @@ const ParamsSchema = Type.Object({
21
21
  });
22
22
  export function createMcpSearchTool(deps) {
23
23
  return {
24
- name: MCP_SEARCH_TOOL_NAME,
24
+ name: TOOL_SEARCH_TOOL_NAME,
25
25
  label: "MCP tool search",
26
26
  description: "Search the catalog of available MCP tools by capability. Matched tools are activated and become callable on your NEXT turn. Use this before calling an MCP tool that is not already active.",
27
27
  promptSnippet: "Search MCP servers for a tool by capability; matched tools activate next turn.",
@@ -43,13 +43,13 @@ export function createMcpSearchTool(deps) {
43
43
  },
44
44
  renderCall(args, theme) {
45
45
  const filter = args.server ? ` @${args.server}` : "";
46
- return new Text(theme.fg("toolTitle", theme.bold(`${MCP_SEARCH_TOOL_NAME} "${args.query}"${filter}`)), 0, 0);
46
+ return new Text(theme.fg("toolTitle", theme.bold(`${TOOL_SEARCH_TOOL_NAME} "${args.query}"${filter}`)), 0, 0);
47
47
  },
48
48
  renderResult(result, options, theme) {
49
49
  const count = result.details?.activated.length ?? 0;
50
50
  const title = options.isPartial
51
- ? `${MCP_SEARCH_TOOL_NAME}: searching`
52
- : `${MCP_SEARCH_TOOL_NAME}: ${count} tool(s) activated`;
51
+ ? `${TOOL_SEARCH_TOOL_NAME}: searching`
52
+ : `${TOOL_SEARCH_TOOL_NAME}: ${count} tool(s) activated`;
53
53
  return new Text(theme.fg("toolOutput", title), 0, 0);
54
54
  },
55
55
  };
@@ -57,7 +57,7 @@ export function createMcpSearchTool(deps) {
57
57
  export function buildMcpSearchResultText(query, matches, server) {
58
58
  const scope = server ? ` on server "${server}"` : "";
59
59
  if (matches.length === 0) {
60
- return `No MCP tools matched "${query}"${scope}. No tools were activated; try different keywords or run mcp_search with a broader query. Your active tool set is unchanged.`;
60
+ return `No MCP tools matched "${query}"${scope}. No tools were activated; try different keywords or run tool_search with a broader query. Your active tool set is unchanged.`;
61
61
  }
62
62
  const bullets = matches
63
63
  .map((match) => `- ${match.name} — ${oneLine(match.doc.description) ?? "(no description)"}`)
@@ -68,11 +68,11 @@ export function buildMcpSearchResultText(query, matches, server) {
68
68
  "",
69
69
  bullets,
70
70
  "",
71
- `${MCP_SEARCH_ACTIVATION_MARKER} ${names}`,
71
+ `${TOOL_SEARCH_ACTIVATION_MARKER} ${names}`,
72
72
  ].join("\n");
73
73
  }
74
74
  /**
75
- * Replay mcp_search activations recorded in prior history so a
75
+ * Replay tool_search activations recorded in prior history so a
76
76
  * compacted/restarted session restores its active tool set without re-searching.
77
77
  * Only names still present in `validNames` are restored (removed tools stay
78
78
  * dropped). Deterministic: returns a de-duplicated, sorted list.
@@ -98,14 +98,14 @@ function extractActivationSegments(message) {
98
98
  return [];
99
99
  }
100
100
  const segments = [];
101
- let cursor = blob.indexOf(MCP_SEARCH_ACTIVATION_MARKER);
101
+ let cursor = blob.indexOf(TOOL_SEARCH_ACTIVATION_MARKER);
102
102
  while (cursor >= 0) {
103
- const rest = blob.slice(cursor + MCP_SEARCH_ACTIVATION_MARKER.length);
103
+ const rest = blob.slice(cursor + TOOL_SEARCH_ACTIVATION_MARKER.length);
104
104
  // Tool names are [a-zA-Z0-9_-]; stop at the first JSON string terminator
105
105
  // (quote / escape) or newline so we never swallow the rest of the blob.
106
106
  const end = rest.search(/["\\\n]/);
107
107
  segments.push(end < 0 ? rest : rest.slice(0, end));
108
- cursor = blob.indexOf(MCP_SEARCH_ACTIVATION_MARKER, cursor + MCP_SEARCH_ACTIVATION_MARKER.length);
108
+ cursor = blob.indexOf(TOOL_SEARCH_ACTIVATION_MARKER, cursor + TOOL_SEARCH_ACTIVATION_MARKER.length);
109
109
  }
110
110
  return segments;
111
111
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tool-search.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/tool-search.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,EAAE;AACF,6EAA6E;AAC7E,2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,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,OAAO,CAAC,IAAwB;IACxC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;AAC7E,CAAC","sourcesContent":["// mcp_search tool + promotion engine (todo 31).\n//\n// `mcp_search` is an always-active tool that ranks the full MCP catalog with\n// the local BM25 engine and PROMOTES matched tools into the active set via\n// setActiveTools (effective the NEXT turn — senpi semantics). Promotion state\n// is derivable from history: each result embeds a stable activation marker so a\n// compaction/restart can replay activations at session_start\n// (rehydrateActiveToolsFromHistory). Activated tools persist for the session;\n// there is no auto-eviction in v1. Every setActiveTools call is stable-sorted.\n\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../../../types.ts\";\nimport { type Bm25Doc, buildBm25Index } from \"./bm25.ts\";\n\nexport const MCP_SEARCH_TOOL_NAME = \"mcp_search\";\n/** Stable, machine-parseable marker embedded in every activating result so\n * activations survive compaction/restart. Kept human-readable on purpose. */\nexport const MCP_SEARCH_ACTIVATION_MARKER = \"[mcp_search:activated]\";\nconst MAX_RESULTS = 10;\n\nexport type SearchableMcpTool = Bm25Doc;\n\nexport interface McpSearchDeps {\n\t/** Full current catalog (all MCP tools, active or not) to rank over. */\n\tgetSearchableTools(): readonly SearchableMcpTool[];\n\t/** Current active tool names (includes non-MCP tools). */\n\tgetActiveTools(): string[];\n\t/** Replace the active set. Implementations should preserve registration. */\n\tsetActiveTools(names: readonly string[]): void;\n}\n\nexport interface McpSearchDetails {\n\tquery: string;\n\tactivated: string[];\n}\n\nconst ParamsSchema = Type.Object({\n\tquery: Type.String({ description: \"Natural-language description of the capability you need.\" }),\n\tserver: Type.Optional(Type.String({ description: \"Optional: restrict the search to a single MCP server name.\" })),\n});\ntype Params = Static<typeof ParamsSchema>;\n\ntype McpSearchTool = ToolDefinition<typeof ParamsSchema, McpSearchDetails, unknown>;\n\nexport function createMcpSearchTool(deps: McpSearchDeps): McpSearchTool {\n\treturn {\n\t\tname: MCP_SEARCH_TOOL_NAME,\n\t\tlabel: \"MCP tool search\",\n\t\tdescription:\n\t\t\t\"Search the catalog of available MCP tools by capability. Matched tools are activated and become callable on your NEXT turn. Use this before calling an MCP tool that is not already active.\",\n\t\tpromptSnippet: \"Search MCP servers for a tool by capability; matched tools activate next turn.\",\n\t\tparameters: ParamsSchema,\n\t\texecutionMode: \"parallel\",\n\t\tasync execute(_toolCallId, params: Params): Promise<AgentToolResult<McpSearchDetails>> {\n\t\t\tconst searchable = deps.getSearchableTools();\n\t\t\tconst index = buildBm25Index(searchable);\n\t\t\tconst matches = index.search(params.query, MAX_RESULTS, params.server ? { server: params.server } : {});\n\t\t\tconst activated = matches.map((match) => match.name);\n\t\t\tif (activated.length > 0) {\n\t\t\t\tdeps.setActiveTools(unionStable(deps.getActiveTools(), activated));\n\t\t\t}\n\t\t\tconst text = buildMcpSearchResultText(params.query, matches, params.server);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\tdetails: { activated, query: params.query },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme) {\n\t\t\tconst filter = args.server ? ` @${args.server}` : \"\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(`${MCP_SEARCH_TOOL_NAME} \"${args.query}\"${filter}`)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme) {\n\t\t\tconst count = result.details?.activated.length ?? 0;\n\t\t\tconst title = options.isPartial\n\t\t\t\t? `${MCP_SEARCH_TOOL_NAME}: searching`\n\t\t\t\t: `${MCP_SEARCH_TOOL_NAME}: ${count} tool(s) activated`;\n\t\t\treturn new Text(theme.fg(\"toolOutput\", title), 0, 0);\n\t\t},\n\t};\n}\n\ninterface RankedMatch {\n\treadonly name: string;\n\treadonly doc: SearchableMcpTool;\n}\n\nexport function buildMcpSearchResultText(\n\tquery: string,\n\tmatches: readonly RankedMatch[],\n\tserver: string | undefined,\n): string {\n\tconst scope = server ? ` on server \"${server}\"` : \"\";\n\tif (matches.length === 0) {\n\t\treturn `No MCP tools matched \"${query}\"${scope}. No tools were activated; try different keywords or run mcp_search with a broader query. Your active tool set is unchanged.`;\n\t}\n\tconst bullets = matches\n\t\t.map((match) => `- ${match.name} — ${oneLine(match.doc.description) ?? \"(no description)\"}`)\n\t\t.join(\"\\n\");\n\tconst names = matches.map((match) => match.name).join(\" \");\n\treturn [\n\t\t`Found ${matches.length} MCP tool(s) matching \"${query}\"${scope}. They are now active and callable from your NEXT turn:`,\n\t\t\"\",\n\t\tbullets,\n\t\t\"\",\n\t\t`${MCP_SEARCH_ACTIVATION_MARKER} ${names}`,\n\t].join(\"\\n\");\n}\n\n/**\n * Replay mcp_search activations recorded in prior history so a\n * compacted/restarted session restores its active tool set without re-searching.\n * Only names still present in `validNames` are restored (removed tools stay\n * dropped). Deterministic: returns a de-duplicated, sorted list.\n */\nexport function rehydrateActiveToolsFromHistory(\n\tmessages: readonly unknown[],\n\tvalidNames: ReadonlySet<string>,\n): string[] {\n\tconst restored = new Set<string>();\n\tfor (const message of messages) {\n\t\tfor (const segment of extractActivationSegments(message)) {\n\t\t\tfor (const name of segment.trim().split(/\\s+/)) {\n\t\t\t\tif (name.length > 0 && validNames.has(name)) restored.add(name);\n\t\t\t}\n\t\t}\n\t}\n\treturn [...restored].sort();\n}\n\nfunction extractActivationSegments(message: unknown): string[] {\n\tlet blob: string;\n\ttry {\n\t\tblob = JSON.stringify(message) ?? \"\";\n\t} catch {\n\t\treturn [];\n\t}\n\tconst segments: string[] = [];\n\tlet cursor = blob.indexOf(MCP_SEARCH_ACTIVATION_MARKER);\n\twhile (cursor >= 0) {\n\t\tconst rest = blob.slice(cursor + MCP_SEARCH_ACTIVATION_MARKER.length);\n\t\t// Tool names are [a-zA-Z0-9_-]; stop at the first JSON string terminator\n\t\t// (quote / escape) or newline so we never swallow the rest of the blob.\n\t\tconst end = rest.search(/[\"\\\\\\n]/);\n\t\tsegments.push(end < 0 ? rest : rest.slice(0, end));\n\t\tcursor = blob.indexOf(MCP_SEARCH_ACTIVATION_MARKER, cursor + MCP_SEARCH_ACTIVATION_MARKER.length);\n\t}\n\treturn segments;\n}\n\n/** Stable union: dedupe and sort so the active-tools array is byte-stable\n * across turns (prompt-cache friendly). */\nexport function unionStable(current: readonly string[], added: readonly string[]): string[] {\n\treturn [...new Set([...current, ...added])].sort();\n}\n\nfunction oneLine(text: string | undefined): string | undefined {\n\tif (text === undefined) return undefined;\n\tconst collapsed = text.replace(/\\s+/g, \" \").trim();\n\tif (collapsed.length === 0) return undefined;\n\treturn collapsed.length <= 100 ? collapsed : `${collapsed.slice(0, 97)}...`;\n}\n"]}
1
+ {"version":3,"file":"tool-search.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/tool-search.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,gFAAgF;AAChF,6DAA6D;AAC7D,8EAA8E;AAC9E,+EAA+E;AAG/E,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,EAAgB,cAAc,EAAE,MAAM,WAAW,CAAC;AAEzD,MAAM,CA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AG,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;AAC7E,CAAC","sourcesContent":["// tool_search tool + promotion engine (todo 31).\n//\n// `tool_search` is an always-active tool that ranks the full MCP catalog with\n// the local BM25 engine and PROMOTES matched tools into the active set via\n// setActiveTools (effective the NEXT turn — senpi semantics). Promotion state\n// is derivable from history: each result embeds a stable activation marker so a\n// compaction/restart can replay activations at session_start\n// (rehydrateActiveToolsFromHistory). Activated tools persist for the session;\n// there is no auto-eviction in v1. Every setActiveTools call is stable-sorted.\n\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { type Static, Type } from \"typebox\";\nimport type { ToolDefinition } from \"../../../types.ts\";\nimport { type Bm25Doc, buildBm25Index } from \"./bm25.ts\";\n\nexport const TOOL_SEARCH_TOOL_NAME = \"tool_search\";\n/** Stable, machine-parseable marker embedded in every activating result so\n * activations survive compaction/restart. Kept human-readable on purpose. */\nexport const TOOL_SEARCH_ACTIVATION_MARKER = \"[tool_search:activated]\";\nconst MAX_RESULTS = 10;\n\nexport type SearchableMcpTool = Bm25Doc;\n\nexport interface McpSearchDeps {\n\t/** Full current catalog (all MCP tools, active or not) to rank over. */\n\tgetSearchableTools(): readonly SearchableMcpTool[];\n\t/** Current active tool names (includes non-MCP tools). */\n\tgetActiveTools(): string[];\n\t/** Replace the active set. Implementations should preserve registration. */\n\tsetActiveTools(names: readonly string[]): void;\n}\n\nexport interface McpSearchDetails {\n\tquery: string;\n\tactivated: string[];\n}\n\nconst ParamsSchema = Type.Object({\n\tquery: Type.String({ description: \"Natural-language description of the capability you need.\" }),\n\tserver: Type.Optional(Type.String({ description: \"Optional: restrict the search to a single MCP server name.\" })),\n});\ntype Params = Static<typeof ParamsSchema>;\n\ntype McpSearchTool = ToolDefinition<typeof ParamsSchema, McpSearchDetails, unknown>;\n\nexport function createMcpSearchTool(deps: McpSearchDeps): McpSearchTool {\n\treturn {\n\t\tname: TOOL_SEARCH_TOOL_NAME,\n\t\tlabel: \"MCP tool search\",\n\t\tdescription:\n\t\t\t\"Search the catalog of available MCP tools by capability. Matched tools are activated and become callable on your NEXT turn. Use this before calling an MCP tool that is not already active.\",\n\t\tpromptSnippet: \"Search MCP servers for a tool by capability; matched tools activate next turn.\",\n\t\tparameters: ParamsSchema,\n\t\texecutionMode: \"parallel\",\n\t\tasync execute(_toolCallId, params: Params): Promise<AgentToolResult<McpSearchDetails>> {\n\t\t\tconst searchable = deps.getSearchableTools();\n\t\t\tconst index = buildBm25Index(searchable);\n\t\t\tconst matches = index.search(params.query, MAX_RESULTS, params.server ? { server: params.server } : {});\n\t\t\tconst activated = matches.map((match) => match.name);\n\t\t\tif (activated.length > 0) {\n\t\t\t\tdeps.setActiveTools(unionStable(deps.getActiveTools(), activated));\n\t\t\t}\n\t\t\tconst text = buildMcpSearchResultText(params.query, matches, params.server);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\tdetails: { activated, query: params.query },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme) {\n\t\t\tconst filter = args.server ? ` @${args.server}` : \"\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(`${TOOL_SEARCH_TOOL_NAME} \"${args.query}\"${filter}`)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme) {\n\t\t\tconst count = result.details?.activated.length ?? 0;\n\t\t\tconst title = options.isPartial\n\t\t\t\t? `${TOOL_SEARCH_TOOL_NAME}: searching`\n\t\t\t\t: `${TOOL_SEARCH_TOOL_NAME}: ${count} tool(s) activated`;\n\t\t\treturn new Text(theme.fg(\"toolOutput\", title), 0, 0);\n\t\t},\n\t};\n}\n\ninterface RankedMatch {\n\treadonly name: string;\n\treadonly doc: SearchableMcpTool;\n}\n\nexport function buildMcpSearchResultText(\n\tquery: string,\n\tmatches: readonly RankedMatch[],\n\tserver: string | undefined,\n): string {\n\tconst scope = server ? ` on server \"${server}\"` : \"\";\n\tif (matches.length === 0) {\n\t\treturn `No MCP tools matched \"${query}\"${scope}. No tools were activated; try different keywords or run tool_search with a broader query. Your active tool set is unchanged.`;\n\t}\n\tconst bullets = matches\n\t\t.map((match) => `- ${match.name} — ${oneLine(match.doc.description) ?? \"(no description)\"}`)\n\t\t.join(\"\\n\");\n\tconst names = matches.map((match) => match.name).join(\" \");\n\treturn [\n\t\t`Found ${matches.length} MCP tool(s) matching \"${query}\"${scope}. They are now active and callable from your NEXT turn:`,\n\t\t\"\",\n\t\tbullets,\n\t\t\"\",\n\t\t`${TOOL_SEARCH_ACTIVATION_MARKER} ${names}`,\n\t].join(\"\\n\");\n}\n\n/**\n * Replay tool_search activations recorded in prior history so a\n * compacted/restarted session restores its active tool set without re-searching.\n * Only names still present in `validNames` are restored (removed tools stay\n * dropped). Deterministic: returns a de-duplicated, sorted list.\n */\nexport function rehydrateActiveToolsFromHistory(\n\tmessages: readonly unknown[],\n\tvalidNames: ReadonlySet<string>,\n): string[] {\n\tconst restored = new Set<string>();\n\tfor (const message of messages) {\n\t\tfor (const segment of extractActivationSegments(message)) {\n\t\t\tfor (const name of segment.trim().split(/\\s+/)) {\n\t\t\t\tif (name.length > 0 && validNames.has(name)) restored.add(name);\n\t\t\t}\n\t\t}\n\t}\n\treturn [...restored].sort();\n}\n\nfunction extractActivationSegments(message: unknown): string[] {\n\tlet blob: string;\n\ttry {\n\t\tblob = JSON.stringify(message) ?? \"\";\n\t} catch {\n\t\treturn [];\n\t}\n\tconst segments: string[] = [];\n\tlet cursor = blob.indexOf(TOOL_SEARCH_ACTIVATION_MARKER);\n\twhile (cursor >= 0) {\n\t\tconst rest = blob.slice(cursor + TOOL_SEARCH_ACTIVATION_MARKER.length);\n\t\t// Tool names are [a-zA-Z0-9_-]; stop at the first JSON string terminator\n\t\t// (quote / escape) or newline so we never swallow the rest of the blob.\n\t\tconst end = rest.search(/[\"\\\\\\n]/);\n\t\tsegments.push(end < 0 ? rest : rest.slice(0, end));\n\t\tcursor = blob.indexOf(TOOL_SEARCH_ACTIVATION_MARKER, cursor + TOOL_SEARCH_ACTIVATION_MARKER.length);\n\t}\n\treturn segments;\n}\n\n/** Stable union: dedupe and sort so the active-tools array is byte-stable\n * across turns (prompt-cache friendly). */\nexport function unionStable(current: readonly string[], added: readonly string[]): string[] {\n\treturn [...new Set([...current, ...added])].sort();\n}\n\nfunction oneLine(text: string | undefined): string | undefined {\n\tif (text === undefined) return undefined;\n\tconst collapsed = text.replace(/\\s+/g, \" \").trim();\n\tif (collapsed.length === 0) return undefined;\n\treturn collapsed.length <= 100 ? collapsed : `${collapsed.slice(0, 97)}...`;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { registerMcpCommands } from "./commands.js";
2
2
  import { setMcpElicitationUiProvider } from "./elicitation.js";
3
3
  import { AnthropicNativeToolSearchAdapter } from "./expose/native-search.js";
4
- import { MCP_SEARCH_TOOL_NAME } from "./expose/tool-search.js";
4
+ import { TOOL_SEARCH_TOOL_NAME } from "./expose/tool-search.js";
5
5
  import { injectMcpInstructions, refreshMcpInstructionsForSession } from "./instructions.js";
6
6
  import { createMcpLogger } from "./log.js";
7
7
  import { registerMcpPromptCommands } from "./prompts.js";
@@ -22,19 +22,19 @@ export default function mcpExtension(pi) {
22
22
  // Native provider tool-search adapter (todo 33 — Anthropic, spike = GO).
23
23
  // Runs on every request but is a no-op unless settings.nativeToolSearch is
24
24
  // auto|true and the model is anthropic-messages; a 400 disables it for the
25
- // session and falls back to the always-registered local mcp_search.
25
+ // session and falls back to the always-registered local tool_search.
26
26
  const nativeAdapter = new AnthropicNativeToolSearchAdapter({
27
27
  enabled: () => {
28
28
  const setting = getMcpService().getNativeToolSearchSetting();
29
29
  return setting === true || setting === "auto";
30
30
  },
31
- isDeferrable: (name) => name.startsWith("mcp_") && name !== MCP_SEARCH_TOOL_NAME,
31
+ isDeferrable: (name) => name.startsWith("mcp_") && name !== TOOL_SEARCH_TOOL_NAME,
32
32
  onFallback: (reason) => createMcpLogger("service").warn(reason),
33
- searchToolName: MCP_SEARCH_TOOL_NAME,
33
+ searchToolName: TOOL_SEARCH_TOOL_NAME,
34
34
  });
35
35
  pi.on("before_provider_request", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model?.api, event.payload));
36
36
  pi.on("after_provider_response", (event) => nativeAdapter.noteResponseStatus(event.status));
37
- // Resumed/compacted sessions carry mcp_search activation markers in their
37
+ // Resumed/compacted sessions carry tool_search activation markers in their
38
38
  // history but re-enter search mode with only directTools active. The context
39
39
  // event (fired before each LLM call, with the full message history) replays
40
40
  // the markers as a safety net; the primary replay happens at attach time so
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACN,yBAAyB,EAGzB,sBAAsB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,m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AE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAChG,CAAC;AACH,CAAC","sourcesContent":["import type { ExtensionAPI, ExtensionContext, SessionStartEvent } from \"../../types.ts\";\nimport { registerMcpCommands } from \"./commands.ts\";\nimport { setMcpElicitationUiProvider } from \"./elicitation.ts\";\nimport { AnthropicNativeToolSearchAdapter } from \"./expose/native-search.ts\";\nimport { MCP_SEARCH_TOOL_NAME } from \"./expose/tool-search.ts\";\nimport { injectMcpInstructions, refreshMcpInstructionsForSession } from \"./instructions.ts\";\nimport { createMcpLogger } from \"./log.ts\";\nimport { registerMcpPromptCommands } from \"./prompts.ts\";\nimport { expandMcpResourceMentions } from \"./resources.ts\";\nimport { getMcpService } from \"./service.ts\";\nimport {\n\tparseSkillMcpDeclarations,\n\ttype SkillLike,\n\ttype SkillMcpDeclarations,\n\tskillActivationTargets,\n} from \"./skills.ts\";\nimport { reportMcpAsyncError, wrapAsync } from \"./wrap.ts\";\n\nexport default function mcpExtension(pi: ExtensionAPI): void {\n\tlet attachPromise: Promise<void> | undefined;\n\tconst sink = {\n\t\tlogger: {\n\t\t\terror(message: string, data?: unknown): void {\n\t\t\t\tcreateMcpLogger(\"service\").error(message, data);\n\t\t\t},\n\t\t},\n\t};\n\n\tregisterMcpCommands(pi);\n\n\t// Native provider tool-search adapter (todo 33 — Anthropic, spike = GO).\n\t// Runs on every request but is a no-op unless settings.nativeToolSearch is\n\t// auto|true and the model is anthropic-messages; a 400 disables it for the\n\t// session and falls back to the always-registered local mcp_search.\n\tconst nativeAdapter = new AnthropicNativeToolSearchAdapter({\n\t\tenabled: () => {\n\t\t\tconst setting = getMcpService().getNativeToolSearchSetting();\n\t\t\treturn setting === true || setting === \"auto\";\n\t\t},\n\t\tisDeferrable: (name) => name.startsWith(\"mcp_\") && name !== MCP_SEARCH_TOOL_NAME,\n\t\tonFallback: (reason) => createMcpLogger(\"service\").warn(reason),\n\t\tsearchToolName: MCP_SEARCH_TOOL_NAME,\n\t});\n\tpi.on(\"before_provider_request\", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model?.api, event.payload));\n\tpi.on(\"after_provider_response\", (event) => nativeAdapter.noteResponseStatus(event.status));\n\t// Resumed/compacted sessions carry mcp_search activation markers in their\n\t// history but re-enter search mode with only directTools active. The context\n\t// event (fired before each LLM call, with the full message history) replays\n\t// the markers as a safety net; the primary replay happens at attach time so\n\t// the FIRST turn's payload already carries previously promoted tools. Scans\n\t// once per registration (see McpService.maybeRehydrateFromHistory).\n\tpi.on(\"context\", (event) => {\n\t\tgetMcpService().maybeRehydrateFromHistory(event.messages);\n\t});\n\n\t// skills-carry-MCP (todo 37): skills declaring MCP servers (mcp.json\n\t// sidecar or SKILL.md frontmatter) register lazily with tools hidden;\n\t// loading a skill — /skill:<name> input or the model reading its SKILL.md —\n\t// reveals that skill's includeTools matches for the rest of the session.\n\tlet skillDecls: SkillMcpDeclarations = { servers: new Map(), warnings: [] };\n\tlet skillsByName = new Map<string, SkillLike>();\n\tconst loadedSkills = new Set<string>();\n\tconst revealSkill = (skillName: string): void => {\n\t\tif (loadedSkills.has(skillName) || !skillsByName.has(skillName)) return;\n\t\tloadedSkills.add(skillName);\n\t\tconst service = getMcpService();\n\t\tconst registered = service.getTierBSearchable();\n\t\tconst targets = skillActivationTargets(skillDecls, skillName, registered);\n\t\tif (targets.length > 0) service.activateSkillMcpTools(targets);\n\t};\n\tpi.on(\"input\", async (event, ctx) => {\n\t\tconst match = /^\\s*\\/skill:([A-Za-z0-9._-]+)/.exec(event.text);\n\t\tif (match) revealSkill(match[1]);\n\t\t// @mcp:<server>/<uri> mention expansion (todo 39): recognized mentions are\n\t\t// inlined via the sanctioned input transform; failures pass through\n\t\t// untouched with a one-line notice so submission is never blocked.\n\t\tif (event.text.includes(\"@mcp:\")) {\n\t\t\tconst expansion = await expandMcpResourceMentions(event.text, () => getMcpService().getMcpResourceServers());\n\t\t\tfor (const notice of expansion.notices) {\n\t\t\t\tcreateMcpLogger(\"resources\").warn(notice);\n\t\t\t\tvoid ctx.ui?.notify?.(notice, \"warning\");\n\t\t\t}\n\t\t\tif (expansion.changed) return { action: \"transform\", text: expansion.text };\n\t\t}\n\t\treturn undefined;\n\t});\n\tpi.on(\"tool_call\", (event) => {\n\t\tif (event.toolName !== \"read\") return undefined;\n\t\tconst path = (event.input as { path?: string }).path;\n\t\tif (path === undefined) return undefined;\n\t\tfor (const [name, skill] of skillsByName) {\n\t\t\tif (path === skill.filePath || path.endsWith(skill.filePath)) revealSkill(name);\n\t\t}\n\t\treturn undefined;\n\t});\n\n\t// Attach is SINGLE-FLIGHT. session_start handlers are dispatched\n\t// fire-and-forget, so a slow attach (a cold MCP server's boot + catalog\n\t// collection is awaited inside attachSession) can still be in flight when\n\t// before_agent_start fires. The old `attached` boolean was only set on\n\t// completion, so before_agent_start would start a SECOND concurrent attach —\n\t// which found the connection entries already created (still \"connecting\"),\n\t// collected an empty catalog, and registered no MCP tools for turn 1; the\n\t// first attach then landed the real registration turns later. Memoizing the\n\t// in-flight promise makes before_agent_start await the ORIGINAL attach, so\n\t// the first turn's payload deterministically carries the MCP tool set.\n\t// session_start always starts a fresh attach (reloads must re-sync config).\n\tconst attach = (event: SessionStartEvent, ctx: ExtensionContext): Promise<void> => {\n\t\tattachPromise = (async () => {\n\t\t\tconst service = getMcpService();\n\t\t\tawait service.attachSession(event, ctx, pi);\n\t\t\trefreshMcpInstructionsForSession(service);\n\t\t\tregisterMcpPromptCommands(pi, service.getMcpPromptServers());\n\t\t})();\n\t\treturn attachPromise;\n\t};\n\tpi.on(\n\t\t\"session_start\",\n\t\twrapAsync(\"mcp.session_start\", (event, ctx) => attach(event, ctx), sink),\n\t);\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\ttry {\n\t\t\t// Elicitation (todo 41): point mid-call forms at the live session UI.\n\t\t\tsetMcpElicitationUiProvider(() => ctx.ui);\n\t\t\tawait (attachPromise ?? attach({ type: \"session_start\", reason: \"startup\" }, ctx));\n\t\t\tconst skills = (event.systemPromptOptions.skills ?? []) as readonly SkillLike[];\n\t\t\tif (skills.length > 0) {\n\t\t\t\tskillsByName = new Map(skills.map((skill) => [skill.name, skill]));\n\t\t\t\tskillDecls = parseSkillMcpDeclarations(skills);\n\t\t\t\tconst declared = new Map(\n\t\t\t\t\t[...skillDecls.servers].map(([name, decl]) => [name, { raw: decl.raw, sourcePath: decl.sourcePath }]),\n\t\t\t\t);\n\t\t\t\tconst warnings = [\n\t\t\t\t\t...skillDecls.warnings,\n\t\t\t\t\t...(declared.size > 0 ? await getMcpService().attachSkillMcpServers(declared) : []),\n\t\t\t\t];\n\t\t\t\tfor (const warning of warnings) createMcpLogger(\"skills\").warn(warning);\n\t\t\t}\n\t\t\tconst systemPrompt = injectMcpInstructions(event.systemPrompt);\n\t\t\treturn systemPrompt === undefined ? undefined : { systemPrompt };\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\tawait reportMcpAsyncError(\"mcp.before_agent_start\", error, sink);\n\t\t\treturn undefined;\n\t\t}\n\t});\n\tpi.on(\n\t\t\"session_shutdown\",\n\t\twrapAsync(\"mcp.session_shutdown\", (event) => getMcpService().handleSessionShutdown(event), sink),\n\t);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACz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AAI,CAAC,CAAC;YACjE,OAAO,SAAS,CAAC;QAClB,CAAC;IACF,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CACJ,kBAAkB,EAClB,SAAS,CAAC,sBAAsB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAChG,CAAC;AACH,CAAC","sourcesContent":["import type { ExtensionAPI, ExtensionContext, SessionStartEvent } from \"../../types.ts\";\nimport { registerMcpCommands } from \"./commands.ts\";\nimport { setMcpElicitationUiProvider } from \"./elicitation.ts\";\nimport { AnthropicNativeToolSearchAdapter } from \"./expose/native-search.ts\";\nimport { TOOL_SEARCH_TOOL_NAME } from \"./expose/tool-search.ts\";\nimport { injectMcpInstructions, refreshMcpInstructionsForSession } from \"./instructions.ts\";\nimport { createMcpLogger } from \"./log.ts\";\nimport { registerMcpPromptCommands } from \"./prompts.ts\";\nimport { expandMcpResourceMentions } from \"./resources.ts\";\nimport { getMcpService } from \"./service.ts\";\nimport {\n\tparseSkillMcpDeclarations,\n\ttype SkillLike,\n\ttype SkillMcpDeclarations,\n\tskillActivationTargets,\n} from \"./skills.ts\";\nimport { reportMcpAsyncError, wrapAsync } from \"./wrap.ts\";\n\nexport default function mcpExtension(pi: ExtensionAPI): void {\n\tlet attachPromise: Promise<void> | undefined;\n\tconst sink = {\n\t\tlogger: {\n\t\t\terror(message: string, data?: unknown): void {\n\t\t\t\tcreateMcpLogger(\"service\").error(message, data);\n\t\t\t},\n\t\t},\n\t};\n\n\tregisterMcpCommands(pi);\n\n\t// Native provider tool-search adapter (todo 33 — Anthropic, spike = GO).\n\t// Runs on every request but is a no-op unless settings.nativeToolSearch is\n\t// auto|true and the model is anthropic-messages; a 400 disables it for the\n\t// session and falls back to the always-registered local tool_search.\n\tconst nativeAdapter = new AnthropicNativeToolSearchAdapter({\n\t\tenabled: () => {\n\t\t\tconst setting = getMcpService().getNativeToolSearchSetting();\n\t\t\treturn setting === true || setting === \"auto\";\n\t\t},\n\t\tisDeferrable: (name) => name.startsWith(\"mcp_\") && name !== TOOL_SEARCH_TOOL_NAME,\n\t\tonFallback: (reason) => createMcpLogger(\"service\").warn(reason),\n\t\tsearchToolName: TOOL_SEARCH_TOOL_NAME,\n\t});\n\tpi.on(\"before_provider_request\", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model?.api, event.payload));\n\tpi.on(\"after_provider_response\", (event) => nativeAdapter.noteResponseStatus(event.status));\n\t// Resumed/compacted sessions carry tool_search activation markers in their\n\t// history but re-enter search mode with only directTools active. The context\n\t// event (fired before each LLM call, with the full message history) replays\n\t// the markers as a safety net; the primary replay happens at attach time so\n\t// the FIRST turn's payload already carries previously promoted tools. Scans\n\t// once per registration (see McpService.maybeRehydrateFromHistory).\n\tpi.on(\"context\", (event) => {\n\t\tgetMcpService().maybeRehydrateFromHistory(event.messages);\n\t});\n\n\t// skills-carry-MCP (todo 37): skills declaring MCP servers (mcp.json\n\t// sidecar or SKILL.md frontmatter) register lazily with tools hidden;\n\t// loading a skill — /skill:<name> input or the model reading its SKILL.md —\n\t// reveals that skill's includeTools matches for the rest of the session.\n\tlet skillDecls: SkillMcpDeclarations = { servers: new Map(), warnings: [] };\n\tlet skillsByName = new Map<string, SkillLike>();\n\tconst loadedSkills = new Set<string>();\n\tconst revealSkill = (skillName: string): void => {\n\t\tif (loadedSkills.has(skillName) || !skillsByName.has(skillName)) return;\n\t\tloadedSkills.add(skillName);\n\t\tconst service = getMcpService();\n\t\tconst registered = service.getTierBSearchable();\n\t\tconst targets = skillActivationTargets(skillDecls, skillName, registered);\n\t\tif (targets.length > 0) service.activateSkillMcpTools(targets);\n\t};\n\tpi.on(\"input\", async (event, ctx) => {\n\t\tconst match = /^\\s*\\/skill:([A-Za-z0-9._-]+)/.exec(event.text);\n\t\tif (match) revealSkill(match[1]);\n\t\t// @mcp:<server>/<uri> mention expansion (todo 39): recognized mentions are\n\t\t// inlined via the sanctioned input transform; failures pass through\n\t\t// untouched with a one-line notice so submission is never blocked.\n\t\tif (event.text.includes(\"@mcp:\")) {\n\t\t\tconst expansion = await expandMcpResourceMentions(event.text, () => getMcpService().getMcpResourceServers());\n\t\t\tfor (const notice of expansion.notices) {\n\t\t\t\tcreateMcpLogger(\"resources\").warn(notice);\n\t\t\t\tvoid ctx.ui?.notify?.(notice, \"warning\");\n\t\t\t}\n\t\t\tif (expansion.changed) return { action: \"transform\", text: expansion.text };\n\t\t}\n\t\treturn undefined;\n\t});\n\tpi.on(\"tool_call\", (event) => {\n\t\tif (event.toolName !== \"read\") return undefined;\n\t\tconst path = (event.input as { path?: string }).path;\n\t\tif (path === undefined) return undefined;\n\t\tfor (const [name, skill] of skillsByName) {\n\t\t\tif (path === skill.filePath || path.endsWith(skill.filePath)) revealSkill(name);\n\t\t}\n\t\treturn undefined;\n\t});\n\n\t// Attach is SINGLE-FLIGHT. session_start handlers are dispatched\n\t// fire-and-forget, so a slow attach (a cold MCP server's boot + catalog\n\t// collection is awaited inside attachSession) can still be in flight when\n\t// before_agent_start fires. The old `attached` boolean was only set on\n\t// completion, so before_agent_start would start a SECOND concurrent attach —\n\t// which found the connection entries already created (still \"connecting\"),\n\t// collected an empty catalog, and registered no MCP tools for turn 1; the\n\t// first attach then landed the real registration turns later. Memoizing the\n\t// in-flight promise makes before_agent_start await the ORIGINAL attach, so\n\t// the first turn's payload deterministically carries the MCP tool set.\n\t// session_start always starts a fresh attach (reloads must re-sync config).\n\tconst attach = (event: SessionStartEvent, ctx: ExtensionContext): Promise<void> => {\n\t\tattachPromise = (async () => {\n\t\t\tconst service = getMcpService();\n\t\t\tawait service.attachSession(event, ctx, pi);\n\t\t\trefreshMcpInstructionsForSession(service);\n\t\t\tregisterMcpPromptCommands(pi, service.getMcpPromptServers());\n\t\t})();\n\t\treturn attachPromise;\n\t};\n\tpi.on(\n\t\t\"session_start\",\n\t\twrapAsync(\"mcp.session_start\", (event, ctx) => attach(event, ctx), sink),\n\t);\n\tpi.on(\"before_agent_start\", async (event, ctx) => {\n\t\ttry {\n\t\t\t// Elicitation (todo 41): point mid-call forms at the live session UI.\n\t\t\tsetMcpElicitationUiProvider(() => ctx.ui);\n\t\t\tawait (attachPromise ?? attach({ type: \"session_start\", reason: \"startup\" }, ctx));\n\t\t\tconst skills = (event.systemPromptOptions.skills ?? []) as readonly SkillLike[];\n\t\t\tif (skills.length > 0) {\n\t\t\t\tskillsByName = new Map(skills.map((skill) => [skill.name, skill]));\n\t\t\t\tskillDecls = parseSkillMcpDeclarations(skills);\n\t\t\t\tconst declared = new Map(\n\t\t\t\t\t[...skillDecls.servers].map(([name, decl]) => [name, { raw: decl.raw, sourcePath: decl.sourcePath }]),\n\t\t\t\t);\n\t\t\t\tconst warnings = [\n\t\t\t\t\t...skillDecls.warnings,\n\t\t\t\t\t...(declared.size > 0 ? await getMcpService().attachSkillMcpServers(declared) : []),\n\t\t\t\t];\n\t\t\t\tfor (const warning of warnings) createMcpLogger(\"skills\").warn(warning);\n\t\t\t}\n\t\t\tconst systemPrompt = injectMcpInstructions(event.systemPrompt);\n\t\t\treturn systemPrompt === undefined ? undefined : { systemPrompt };\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof Error)) throw error;\n\t\t\tawait reportMcpAsyncError(\"mcp.before_agent_start\", error, sink);\n\t\t\treturn undefined;\n\t\t}\n\t});\n\tpi.on(\n\t\t\"session_shutdown\",\n\t\twrapAsync(\"mcp.session_shutdown\", (event) => getMcpService().handleSessionShutdown(event), sink),\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"service-snapshot.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,KAAK,EAAE,kBAAkB,GAAG,SAAS,EACrC,GAAG,SAAa,GACd,iBAAiB,CAgBnB"}
1
+ {"version":3,"file":"service-snapshot.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEhF,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,UAAU,EAAE,gBAAgB,GAAG,SAAS,EACxC,KAAK,EAAE,kBAAkB,GAAG,SAAS,EACrC,GAAG,SAAa,GACd,iBAAiB,CAiBnB"}
@@ -3,6 +3,7 @@ export function buildMcpServerSnapshot(name, server, connection, entry, now = Da
3
3
  name,
4
4
  configState: server?.state ?? "removed",
5
5
  configHash: server?.configHash ?? null,
6
+ source: server?.source ?? null,
6
7
  sourcePath: server?.sourcePath ?? null,
7
8
  lifecycleState: connection?.state === "idle" && connection.generation === 0 && entry?.cachedCatalog !== undefined
8
9
  ? "cached"
@@ -1 +1 @@
1
- {"version":3,"file":"service-snapshot.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,sBAAsB,CACrC,IAAY,EACZ,MAAqC,EACrC,UAAwC,EACxC,KAAqC,EACrC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAEhB,OAAO;QACN,IAAI;QACJ,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS;QACvC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,cAAc,EACb,UAAU,EAAE,KAAK,KAAK,MAAM,IAAI,UAAU,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,EAAE,aAAa,KAAK,SAAS;YAChG,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,aAAa,CAAC;QACxC,UAAU,EAAE,UAAU,EAAE,UAAU,IAAI,IAAI;QAC1C,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,IAAI;QACrC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI;QACjD,QAAQ,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,WAAW;QAC9D,QAAQ,EAAE,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE;KAClG,CAAC;AACH,CAAC","sourcesContent":["import type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection } from \"./connection.ts\";\nimport type { McpConnectionEntry, McpServerSnapshot } from \"./service-types.ts\";\n\nexport function buildMcpServerSnapshot(\n\tname: string,\n\tserver: ResolvedMcpServer | undefined,\n\tconnection: ServerConnection | undefined,\n\tentry: McpConnectionEntry | undefined,\n\tnow = Date.now(),\n): McpServerSnapshot {\n\treturn {\n\t\tname,\n\t\tconfigState: server?.state ?? \"removed\",\n\t\tconfigHash: server?.configHash ?? null,\n\t\tsourcePath: server?.sourcePath ?? null,\n\t\tlifecycleState:\n\t\t\tconnection?.state === \"idle\" && connection.generation === 0 && entry?.cachedCatalog !== undefined\n\t\t\t\t? \"cached\"\n\t\t\t\t: (connection?.state ?? \"not_spawned\"),\n\t\tgeneration: connection?.generation ?? null,\n\t\tpid: connection?.getRootPid() ?? null,\n\t\tlastError: connection?.lastError?.message ?? null,\n\t\tuptimeMs: entry === undefined ? null : now - entry.createdAtMs,\n\t\tcounters: entry?.counters ?? { callCount: 0, errorCount: 0, totalLatencyMs: 0, reconnectCount: 0 },\n\t};\n}\n"]}
1
+ {"version":3,"file":"service-snapshot.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-snapshot.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,sBAAsB,CACrC,IAAY,EACZ,MAAqC,EACrC,UAAwC,EACxC,KAAqC,EACrC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAEhB,OAAO;QACN,IAAI;QACJ,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,SAAS;QACvC,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,IAAI;QAC9B,UAAU,EAAE,MAAM,EAAE,UAAU,IAAI,IAAI;QACtC,cAAc,EACb,UAAU,EAAE,KAAK,KAAK,MAAM,IAAI,UAAU,CAAC,UAAU,KAAK,CAAC,IAAI,KAAK,EAAE,aAAa,KAAK,SAAS;YAChG,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,aAAa,CAAC;QACxC,UAAU,EAAE,UAAU,EAAE,UAAU,IAAI,IAAI;QAC1C,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,IAAI;QACrC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,IAAI,IAAI;QACjD,QAAQ,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,WAAW;QAC9D,QAAQ,EAAE,KAAK,EAAE,QAAQ,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE;KAClG,CAAC;AACH,CAAC","sourcesContent":["import type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection } from \"./connection.ts\";\nimport type { McpConnectionEntry, McpServerSnapshot } from \"./service-types.ts\";\n\nexport function buildMcpServerSnapshot(\n\tname: string,\n\tserver: ResolvedMcpServer | undefined,\n\tconnection: ServerConnection | undefined,\n\tentry: McpConnectionEntry | undefined,\n\tnow = Date.now(),\n): McpServerSnapshot {\n\treturn {\n\t\tname,\n\t\tconfigState: server?.state ?? \"removed\",\n\t\tconfigHash: server?.configHash ?? null,\n\t\tsource: server?.source ?? null,\n\t\tsourcePath: server?.sourcePath ?? null,\n\t\tlifecycleState:\n\t\t\tconnection?.state === \"idle\" && connection.generation === 0 && entry?.cachedCatalog !== undefined\n\t\t\t\t? \"cached\"\n\t\t\t\t: (connection?.state ?? \"not_spawned\"),\n\t\tgeneration: connection?.generation ?? null,\n\t\tpid: connection?.getRootPid() ?? null,\n\t\tlastError: connection?.lastError?.message ?? null,\n\t\tuptimeMs: entry === undefined ? null : now - entry.createdAtMs,\n\t\tcounters: entry?.counters ?? { callCount: 0, errorCount: 0, totalLatencyMs: 0, reconnectCount: 0 },\n\t};\n}\n"]}
@@ -12,6 +12,17 @@ export type McpSessionContext = Pick<ExtensionContext, "cwd" | "isProjectTrusted
12
12
  * requirement narrow lets tests pass a two-line fake.
13
13
  */
14
14
  sessionManager?: Pick<ExtensionContext["sessionManager"], "getEntries">;
15
+ /**
16
+ * Extension-declared MCP servers. Read on every attach so reattach/reload
17
+ * paths pick up the current declarations without caching them in the MCP
18
+ * builtin.
19
+ */
20
+ getRegisteredMcpServers?: () => readonly {
21
+ name: string;
22
+ config: Record<string, unknown>;
23
+ extensionPath: string;
24
+ registrationCwd: string;
25
+ }[];
15
26
  };
16
27
  export interface McpSessionOptions {
17
28
  readonly agentDir?: string;
@@ -32,6 +43,7 @@ export interface McpServerSnapshot {
32
43
  name: string;
33
44
  configState: ResolvedMcpServer["state"] | "removed";
34
45
  configHash: string | null;
46
+ source: ResolvedMcpServer["source"] | null;
35
47
  sourcePath: string | null;
36
48
  lifecycleState: ServerConnectionState | "cached" | "not_spawned";
37
49
  generation: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;AAC1F,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,kBAAkB,CAAC,GAAG;IACpF;;;;OAIG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAAE,YAAY,CAAC,CAAC;CACxE,CAAC;AAEF,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;I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,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,iBAAiB,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0BAA0B,EAAE,OAAO,CAAC;IACpC,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,0FAA0F;IAC1F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;CAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtensionContext, SessionShutdownEvent, SessionStartEvent } from \"../../types.ts\";\nimport type { ServerAuthPlan } from \"./auth/context.ts\";\nimport type { McpCachedServerCatalog } from \"./catalog-cache.ts\";\nimport type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection, ServerConnectionState } from \"./connection.ts\";\nimport type { McpLogger } from \"./log.ts\";\n\nexport type McpDisposeReason = Extract<SessionShutdownEvent[\"reason\"], \"quit\" | \"reload\">;\nexport type McpSessionContext = Pick<ExtensionContext, \"cwd\" | \"isProjectTrusted\"> & {\n\t/**\n\t * Session history access, present on the real ExtensionContext. Only\n\t * getEntries is needed (attach-time promotion rehydration); keeping the\n\t * requirement narrow lets tests pass a two-line fake.\n\t */\n\tsessionManager?: Pick<ExtensionContext[\"sessionManager\"], \"getEntries\">;\n};\n\nexport interface McpSessionOptions {\n\treadonly agentDir?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly logDir?: string;\n\treadonly projectTrusted?: boolean;\n}\n\nexport interface McpServiceSnapshot {\n\tdisposed: boolean;\n\tdisposeCount: number;\n\tlastDisposeReason: McpDisposeReason | null;\n\tsessionStartCount: number;\n\tlastSessionStartReason: SessionStartEvent[\"reason\"] | null;\n\thasSessionContext: boolean;\n\tconnectionCount: number;\n}\n\nexport interface McpServerSnapshot {\n\tname: string;\n\tconfigState: ResolvedMcpServer[\"state\"] | \"removed\";\n\tconfigHash: string | null;\n\tsourcePath: string | null;\n\tlifecycleState: ServerConnectionState | \"cached\" | \"not_spawned\";\n\tgeneration: number | null;\n\tpid: number | null;\n\tlastError: string | null;\n\tuptimeMs: number | null;\n\tcounters: McpServerCounters;\n}\n\nexport interface McpServerCounters {\n\tcallCount: number;\n\terrorCount: number;\n\ttotalLatencyMs: number;\n\treconnectCount: number;\n}\n\nexport interface McpConnectionEntry {\n\treadonly key: string;\n\treadonly name: string;\n\treadonly configHash: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly createdAtMs: number;\n\treadonly counters: McpServerCounters;\n\treadonly agentDir?: string;\n\treadonly authPlan?: ServerAuthPlan;\n\tcachedCatalog?: McpCachedServerCatalog;\n\tcacheRefreshedAfterConnect: boolean;\n\t/** Full mcp tool names last registered for this server (list_changed diffing). */\n\tknownToolNames?: string[];\n\t/** Latest `/mcp status` list_changed delta line, e.g. \"2 added (inactive), 1 removed\". */\n\tlastListChangedDelta?: string;\n\t/** Teardown for the list_changed coalescer + subscription. */\n\tdisposeListChanged?: () => void;\n}\n"]}
1
+ {"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ExtensionContext, SessionShutdownEvent, SessionStartEvent } from \"../../types.ts\";\nimport type { ServerAuthPlan } from \"./auth/context.ts\";\nimport type { McpCachedServerCatalog } from \"./catalog-cache.ts\";\nimport type { ResolvedMcpServer } from \"./config-schema.ts\";\nimport type { ServerConnection, ServerConnectionState } from \"./connection.ts\";\nimport type { McpLogger } from \"./log.ts\";\n\nexport type McpDisposeReason = Extract<SessionShutdownEvent[\"reason\"], \"quit\" | \"reload\">;\nexport type McpSessionContext = Pick<ExtensionContext, \"cwd\" | \"isProjectTrusted\"> & {\n\t/**\n\t * Session history access, present on the real ExtensionContext. Only\n\t * getEntries is needed (attach-time promotion rehydration); keeping the\n\t * requirement narrow lets tests pass a two-line fake.\n\t */\n\tsessionManager?: Pick<ExtensionContext[\"sessionManager\"], \"getEntries\">;\n\t/**\n\t * Extension-declared MCP servers. Read on every attach so reattach/reload\n\t * paths pick up the current declarations without caching them in the MCP\n\t * builtin.\n\t */\n\tgetRegisteredMcpServers?: () => readonly {\n\t\tname: string;\n\t\tconfig: Record<string, unknown>;\n\t\textensionPath: string;\n\t\tregistrationCwd: string;\n\t}[];\n};\n\nexport interface McpSessionOptions {\n\treadonly agentDir?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly logDir?: string;\n\treadonly projectTrusted?: boolean;\n}\n\nexport interface McpServiceSnapshot {\n\tdisposed: boolean;\n\tdisposeCount: number;\n\tlastDisposeReason: McpDisposeReason | null;\n\tsessionStartCount: number;\n\tlastSessionStartReason: SessionStartEvent[\"reason\"] | null;\n\thasSessionContext: boolean;\n\tconnectionCount: number;\n}\n\nexport interface McpServerSnapshot {\n\tname: string;\n\tconfigState: ResolvedMcpServer[\"state\"] | \"removed\";\n\tconfigHash: string | null;\n\tsource: ResolvedMcpServer[\"source\"] | null;\n\tsourcePath: string | null;\n\tlifecycleState: ServerConnectionState | \"cached\" | \"not_spawned\";\n\tgeneration: number | null;\n\tpid: number | null;\n\tlastError: string | null;\n\tuptimeMs: number | null;\n\tcounters: McpServerCounters;\n}\n\nexport interface McpServerCounters {\n\tcallCount: number;\n\terrorCount: number;\n\ttotalLatencyMs: number;\n\treconnectCount: number;\n}\n\nexport interface McpConnectionEntry {\n\treadonly key: string;\n\treadonly name: string;\n\treadonly configHash: string;\n\treadonly connection: ServerConnection;\n\treadonly logger: McpLogger;\n\treadonly createdAtMs: number;\n\treadonly counters: McpServerCounters;\n\treadonly agentDir?: string;\n\treadonly authPlan?: ServerAuthPlan;\n\tcachedCatalog?: McpCachedServerCatalog;\n\tcacheRefreshedAfterConnect: boolean;\n\t/** Full mcp tool names last registered for this server (list_changed diffing). */\n\tknownToolNames?: string[];\n\t/** Latest `/mcp status` list_changed delta line, e.g. \"2 added (inactive), 1 removed\". */\n\tlastListChangedDelta?: string;\n\t/** Teardown for the list_changed coalescer + subscription. */\n\tdisposeListChanged?: () => void;\n}\n"]}
@@ -32,7 +32,7 @@ export declare class McpService {
32
32
  /** Connected servers that list resources (todo 39), for mention expansion. */
33
33
  getMcpResourceServers(): readonly McpResourceServer[];
34
34
  /** Reveal skill-owned tools (todo 37): activation is effective the next
35
- * turn, exactly like an mcp_search promotion. Unknown names are ignored. */
35
+ * turn, exactly like an tool_search promotion. Unknown names are ignored. */
36
36
  activateSkillMcpTools(names: readonly string[]): void;
37
37
  handleSessionShutdown(event: SessionShutdownEvent): Promise<void>;
38
38
  dispose(reason: McpDisposeReason): Promise<void>;
@@ -45,7 +45,7 @@ export declare class McpService {
45
45
  recordCall(name: string, elapsedMs: number, failed: boolean): void;
46
46
  getSnapshot(): McpServiceSnapshot;
47
47
  /**
48
- * Replay mcp_search activation markers from session history through the
48
+ * Replay tool_search activation markers from session history through the
49
49
  * live tier-B activation path (see tool-search.ts). Returns newly activated
50
50
  * names; safe to call repeatedly (already-active names are skipped).
51
51
  */