@averyyy/pi-coding-agent 1.5.0-piclient.3 → 1.5.2-piclient.1

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 (359) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/dist/bundle/chunks/anthropic-messages-KT6DV7MK.js +6 -0
  3. package/dist/bundle/chunks/{azure-openai-responses-M725JFGO.js → azure-openai-responses-E2Z734ES.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +3 -3
  5. package/dist/bundle/chunks/chunk-27POX4KP.js +82 -0
  6. package/dist/bundle/chunks/{chunk-NWAB6VML.js → chunk-BWM3ZYWS.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-GJFZM2RZ.js → chunk-D2CMHQWH.js} +9 -9
  8. package/dist/bundle/chunks/chunk-DGLLW4Y4.js +1590 -0
  9. package/dist/bundle/chunks/{chunk-N4CTF6DK.js → chunk-ECEUFETK.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-3UW3IQIY.js → chunk-FA5D3PPT.js} +1 -1
  11. package/dist/bundle/chunks/chunk-GFUN2N5K.js +2 -0
  12. package/dist/bundle/chunks/{chunk-OW4KH7CI.js → chunk-H36DQSY7.js} +1 -1
  13. package/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
  14. package/dist/bundle/chunks/chunk-IYMNLY6C.js +4 -0
  15. package/dist/bundle/chunks/chunk-M4NMEBFE.js +2 -0
  16. package/dist/bundle/chunks/chunk-P4REYYCM.js +55 -0
  17. package/dist/bundle/chunks/chunk-RRE46THK.js +35 -0
  18. package/dist/bundle/chunks/chunk-RZHIIJ2O.js +2 -0
  19. package/dist/bundle/chunks/chunk-SHIWNICN.js +8 -0
  20. package/dist/bundle/chunks/{chunk-WATJAG5U.js → chunk-TCESBBFS.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-GO33PKBT.js → chunk-V5KN6SNQ.js} +1 -1
  22. package/dist/bundle/chunks/chunk-V7WCKBVO.js +19 -0
  23. package/dist/bundle/chunks/{chunk-OXKIVFVM.js → chunk-VZFAYNKC.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-JM6XUN2B.js → chunk-YAD6BXOQ.js} +5 -1
  25. package/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  26. package/dist/bundle/chunks/{cli-2Q4CKMZK.js → cli-OTDOMRGW.js} +7 -7
  27. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-JEJELFEJ.js → cloudflare-workers-ai-system-one-6TWKBBSR.js} +1 -1
  28. package/dist/bundle/chunks/codemode-worker.js +2 -0
  29. package/dist/bundle/chunks/{easter-egg-3d-UEH5CVEM.js → easter-egg-3d-FREKSIW6.js} +1 -1
  30. package/dist/bundle/chunks/{execute-BOGNP5CQ.js → execute-MJMW76MP.js} +5 -3
  31. package/dist/bundle/chunks/github-copilot.js +1 -1
  32. package/dist/bundle/chunks/google-antigravity-runtime.js +2 -2
  33. package/dist/bundle/chunks/{google-generative-ai-UTHMOBSC.js → google-generative-ai-YSOYXY5K.js} +1 -1
  34. package/dist/bundle/chunks/{google-vertex-MKY2BEE7.js → google-vertex-X3ELXR2J.js} +1 -1
  35. package/dist/bundle/chunks/{llama-cpp-classify-CYHVVBOQ.js → llama-cpp-classify-R6PVLK5I.js} +1 -1
  36. package/dist/bundle/chunks/{mistral-conversations-U2CRJEWX.js → mistral-conversations-J4IL2HMK.js} +1 -1
  37. package/dist/bundle/chunks/openai-codex-responses-GULSUKQ4.js +10 -0
  38. package/dist/bundle/chunks/{openai-completions-VPNLDI5K.js → openai-completions-ZGWBSKNR.js} +3 -3
  39. package/dist/bundle/chunks/{openai-decisions-UZ6HF7LF.js → openai-decisions-BU2ER6AQ.js} +1 -1
  40. package/dist/bundle/chunks/openai-responses-WDSDROXC.js +4 -0
  41. package/dist/bundle/chunks/{openrouter-images-P5CYCO4P.js → openrouter-images-MK6H7N26.js} +1 -1
  42. package/dist/bundle/chunks/{pi-messages-XPX326L5.js → pi-messages-7PPZFV3U.js} +1 -1
  43. package/dist/bundle/chunks/{runtime-2Z3FBQRD.js → runtime-X3ZHEI2F.js} +1 -1
  44. package/dist/bundle/chunks/{typesafe-system-one-NKVLMGFF.js → typesafe-system-one-LXDZKNJW.js} +1 -1
  45. package/dist/bundle/chunks/virtual-modules-J7Z5J7IR.js +2 -0
  46. package/dist/bundle/cli-runtime.js +1 -1
  47. package/dist/bundle/index.js +1 -1
  48. package/dist/bundle/rpc-entry.js +1 -1
  49. package/dist/cli/args.js +1 -1
  50. package/dist/cli/args.js.map +1 -1
  51. package/dist/cli/auth-command.d.ts.map +1 -1
  52. package/dist/cli/auth-command.js +26 -2
  53. package/dist/cli/auth-command.js.map +1 -1
  54. package/dist/cli/auth-login.d.ts +15 -0
  55. package/dist/cli/auth-login.d.ts.map +1 -0
  56. package/dist/cli/auth-login.js +234 -0
  57. package/dist/cli/auth-login.js.map +1 -0
  58. package/dist/cli/auth-logout.d.ts +14 -0
  59. package/dist/cli/auth-logout.d.ts.map +1 -0
  60. package/dist/cli/auth-logout.js +74 -0
  61. package/dist/cli/auth-logout.js.map +1 -0
  62. package/dist/cli/auth-terminal.d.ts +17 -0
  63. package/dist/cli/auth-terminal.d.ts.map +1 -0
  64. package/dist/cli/auth-terminal.js +63 -0
  65. package/dist/cli/auth-terminal.js.map +1 -0
  66. package/dist/cli/config-selector.d.ts.map +1 -1
  67. package/dist/cli/config-selector.js +3 -1
  68. package/dist/cli/config-selector.js.map +1 -1
  69. package/dist/core/agent-session-runtime.d.ts +5 -0
  70. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  71. package/dist/core/agent-session-runtime.js +17 -2
  72. package/dist/core/agent-session-runtime.js.map +1 -1
  73. package/dist/core/agent-session.d.ts +25 -6
  74. package/dist/core/agent-session.d.ts.map +1 -1
  75. package/dist/core/agent-session.js +137 -54
  76. package/dist/core/agent-session.js.map +1 -1
  77. package/dist/core/auth-storage.d.ts.map +1 -1
  78. package/dist/core/auth-storage.js +3 -2
  79. package/dist/core/auth-storage.js.map +1 -1
  80. package/dist/core/bash-executor.d.ts.map +1 -1
  81. package/dist/core/bash-executor.js +3 -1
  82. package/dist/core/bash-executor.js.map +1 -1
  83. package/dist/core/cache-warmer.d.ts +4 -37
  84. package/dist/core/cache-warmer.d.ts.map +1 -1
  85. package/dist/core/cache-warmer.js +11 -97
  86. package/dist/core/cache-warmer.js.map +1 -1
  87. package/dist/core/compaction/utils.d.ts.map +1 -1
  88. package/dist/core/compaction/utils.js +2 -1
  89. package/dist/core/compaction/utils.js.map +1 -1
  90. package/dist/core/extensions/index.d.ts +1 -1
  91. package/dist/core/extensions/index.d.ts.map +1 -1
  92. package/dist/core/extensions/index.js.map +1 -1
  93. package/dist/core/extensions/loader.d.ts.map +1 -1
  94. package/dist/core/extensions/loader.js +10 -5
  95. package/dist/core/extensions/loader.js.map +1 -1
  96. package/dist/core/extensions/runner.d.ts +1 -0
  97. package/dist/core/extensions/runner.d.ts.map +1 -1
  98. package/dist/core/extensions/runner.js +9 -1
  99. package/dist/core/extensions/runner.js.map +1 -1
  100. package/dist/core/extensions/types.d.ts +28 -6
  101. package/dist/core/extensions/types.d.ts.map +1 -1
  102. package/dist/core/extensions/types.js.map +1 -1
  103. package/dist/core/keybindings.d.ts +2 -2
  104. package/dist/core/keybindings.js +1 -1
  105. package/dist/core/keybindings.js.map +1 -1
  106. package/dist/core/mcp-servers.d.ts +12 -37
  107. package/dist/core/mcp-servers.d.ts.map +1 -1
  108. package/dist/core/mcp-servers.js +42 -121
  109. package/dist/core/mcp-servers.js.map +1 -1
  110. package/dist/core/model-config.d.ts +52 -0
  111. package/dist/core/model-config.d.ts.map +1 -1
  112. package/dist/core/model-resolver.d.ts.map +1 -1
  113. package/dist/core/model-resolver.js +20 -19
  114. package/dist/core/model-resolver.js.map +1 -1
  115. package/dist/core/model-runtime.d.ts +2 -0
  116. package/dist/core/model-runtime.d.ts.map +1 -1
  117. package/dist/core/model-runtime.js +8 -4
  118. package/dist/core/model-runtime.js.map +1 -1
  119. package/dist/core/package-manager.d.ts +10 -1
  120. package/dist/core/package-manager.d.ts.map +1 -1
  121. package/dist/core/package-manager.js +50 -5
  122. package/dist/core/package-manager.js.map +1 -1
  123. package/dist/core/pi-ai-schemas.d.ts +4 -0
  124. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  125. package/dist/core/pi-server-client.d.ts.map +1 -1
  126. package/dist/core/pi-server-client.js +1 -0
  127. package/dist/core/pi-server-client.js.map +1 -1
  128. package/dist/core/preferred-providers.d.ts +17 -0
  129. package/dist/core/preferred-providers.d.ts.map +1 -0
  130. package/dist/core/preferred-providers.js +24 -0
  131. package/dist/core/preferred-providers.js.map +1 -0
  132. package/dist/core/prompt-templates.d.ts.map +1 -1
  133. package/dist/core/prompt-templates.js +18 -2
  134. package/dist/core/prompt-templates.js.map +1 -1
  135. package/dist/core/provider-composer.d.ts.map +1 -1
  136. package/dist/core/provider-composer.js +3 -1
  137. package/dist/core/provider-composer.js.map +1 -1
  138. package/dist/core/provider-matching.d.ts +6 -0
  139. package/dist/core/provider-matching.d.ts.map +1 -0
  140. package/dist/core/provider-matching.js +8 -0
  141. package/dist/core/provider-matching.js.map +1 -0
  142. package/dist/core/radius-mcp.d.ts +13 -0
  143. package/dist/core/radius-mcp.d.ts.map +1 -0
  144. package/dist/core/radius-mcp.js +29 -0
  145. package/dist/core/radius-mcp.js.map +1 -0
  146. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  147. package/dist/core/remote-catalog-provider.js +2 -0
  148. package/dist/core/remote-catalog-provider.js.map +1 -1
  149. package/dist/core/runtime-credentials.d.ts +8 -0
  150. package/dist/core/runtime-credentials.d.ts.map +1 -1
  151. package/dist/core/runtime-credentials.js +15 -1
  152. package/dist/core/runtime-credentials.js.map +1 -1
  153. package/dist/core/session-cwd.d.ts +7 -0
  154. package/dist/core/session-cwd.d.ts.map +1 -1
  155. package/dist/core/session-cwd.js +9 -1
  156. package/dist/core/session-cwd.js.map +1 -1
  157. package/dist/core/settings-defaults.d.ts +1 -1
  158. package/dist/core/settings-defaults.d.ts.map +1 -1
  159. package/dist/core/settings-defaults.js +1 -1
  160. package/dist/core/settings-defaults.js.map +1 -1
  161. package/dist/core/tools/bash.d.ts +1 -6
  162. package/dist/core/tools/bash.d.ts.map +1 -1
  163. package/dist/core/tools/bash.js +34 -9
  164. package/dist/core/tools/bash.js.map +1 -1
  165. package/dist/core/tools/edit-diff.d.ts +23 -14
  166. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  167. package/dist/core/tools/edit-diff.js +182 -41
  168. package/dist/core/tools/edit-diff.js.map +1 -1
  169. package/dist/core/tools/edit.d.ts.map +1 -1
  170. package/dist/core/tools/edit.js +8 -7
  171. package/dist/core/tools/edit.js.map +1 -1
  172. package/dist/core/tools/find.d.ts.map +1 -1
  173. package/dist/core/tools/find.js +82 -36
  174. package/dist/core/tools/find.js.map +1 -1
  175. package/dist/core/tools/grep.d.ts +5 -3
  176. package/dist/core/tools/grep.d.ts.map +1 -1
  177. package/dist/core/tools/grep.js +87 -75
  178. package/dist/core/tools/grep.js.map +1 -1
  179. package/dist/core/tools/ls.d.ts.map +1 -1
  180. package/dist/core/tools/ls.js +2 -1
  181. package/dist/core/tools/ls.js.map +1 -1
  182. package/dist/core/tools/powershell.d.ts.map +1 -1
  183. package/dist/core/tools/powershell.js +15 -2
  184. package/dist/core/tools/powershell.js.map +1 -1
  185. package/dist/core/tools/read.d.ts +8 -0
  186. package/dist/core/tools/read.d.ts.map +1 -1
  187. package/dist/core/tools/read.js +141 -25
  188. package/dist/core/tools/read.js.map +1 -1
  189. package/dist/core/tools/truncate.d.ts +4 -14
  190. package/dist/core/tools/truncate.d.ts.map +1 -1
  191. package/dist/core/tools/truncate.js +23 -29
  192. package/dist/core/tools/truncate.js.map +1 -1
  193. package/dist/extensions/codemode/execute.js +4 -4
  194. package/dist/extensions/codemode/execute.js.map +1 -1
  195. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  196. package/dist/extensions/codemode/tool.js +34 -12
  197. package/dist/extensions/codemode/tool.js.map +1 -1
  198. package/dist/extensions/llama/client.d.ts +2 -0
  199. package/dist/extensions/llama/client.d.ts.map +1 -1
  200. package/dist/extensions/llama/client.js +23 -2
  201. package/dist/extensions/llama/client.js.map +1 -1
  202. package/dist/extensions/llama/ui.d.ts.map +1 -1
  203. package/dist/extensions/llama/ui.js +15 -3
  204. package/dist/extensions/llama/ui.js.map +1 -1
  205. package/dist/extensions/mcp/cli.d.ts +2 -0
  206. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  207. package/dist/extensions/mcp/cli.js +49 -14
  208. package/dist/extensions/mcp/cli.js.map +1 -1
  209. package/dist/extensions/mcp/config.d.ts.map +1 -1
  210. package/dist/extensions/mcp/config.js +4 -7
  211. package/dist/extensions/mcp/config.js.map +1 -1
  212. package/dist/extensions/mcp/index.d.ts.map +1 -1
  213. package/dist/extensions/mcp/index.js +4 -3
  214. package/dist/extensions/mcp/index.js.map +1 -1
  215. package/dist/extensions/mcp/oauth.d.ts +11 -49
  216. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  217. package/dist/extensions/mcp/oauth.js +56 -319
  218. package/dist/extensions/mcp/oauth.js.map +1 -1
  219. package/dist/extensions/mcp/resources.d.ts +1 -1
  220. package/dist/extensions/mcp/resources.d.ts.map +1 -1
  221. package/dist/extensions/mcp/resources.js +4 -3
  222. package/dist/extensions/mcp/resources.js.map +1 -1
  223. package/dist/extensions/mcp/runtime.d.ts +4 -3
  224. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  225. package/dist/extensions/mcp/runtime.js +7 -5
  226. package/dist/extensions/mcp/runtime.js.map +1 -1
  227. package/dist/extensions/mcp/tools.d.ts +2 -23
  228. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  229. package/dist/extensions/mcp/tools.js +6 -58
  230. package/dist/extensions/mcp/tools.js.map +1 -1
  231. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  232. package/dist/extensions/tool-search/tool.js +18 -6
  233. package/dist/extensions/tool-search/tool.js.map +1 -1
  234. package/dist/index.d.ts +1 -1
  235. package/dist/index.d.ts.map +1 -1
  236. package/dist/index.js.map +1 -1
  237. package/dist/main.d.ts.map +1 -1
  238. package/dist/main.js +63 -11
  239. package/dist/main.js.map +1 -1
  240. package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
  241. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  242. package/dist/modes/interactive/components/branch-summary-message.js +12 -4
  243. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  244. package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
  245. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  246. package/dist/modes/interactive/components/compaction-summary-message.js +12 -4
  247. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  248. package/dist/modes/interactive/components/custom-message.d.ts +5 -2
  249. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  250. package/dist/modes/interactive/components/custom-message.js +10 -3
  251. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  252. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  253. package/dist/modes/interactive/components/diff.js +11 -5
  254. package/dist/modes/interactive/components/diff.js.map +1 -1
  255. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  256. package/dist/modes/interactive/components/extension-selector.js +9 -1
  257. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  258. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  259. package/dist/modes/interactive/components/login-dialog.js +1 -18
  260. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  261. package/dist/modes/interactive/components/mermaid.d.ts +2 -1
  262. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  263. package/dist/modes/interactive/components/mermaid.js +25 -20
  264. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  265. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  266. package/dist/modes/interactive/components/model-selector.js +14 -6
  267. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  268. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  269. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  270. package/dist/modes/interactive/components/oauth-selector.js +32 -5
  271. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  272. package/dist/modes/interactive/components/provider-brand.d.ts +14 -0
  273. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  274. package/dist/modes/interactive/components/provider-brand.js +66 -0
  275. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  276. package/dist/modes/interactive/components/radius-login-selector.d.ts +1 -2
  277. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  278. package/dist/modes/interactive/components/radius-login-selector.js +6 -37
  279. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  280. package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
  281. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  282. package/dist/modes/interactive/components/skill-invocation-message.js +12 -4
  283. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  284. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  285. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  286. package/dist/modes/interactive/components/tree-selector.js +19 -10
  287. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  288. package/dist/modes/interactive/interactive-mode.d.ts +13 -1
  289. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  290. package/dist/modes/interactive/interactive-mode.js +164 -91
  291. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  292. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  293. package/dist/modes/interactive/theme/theme.js +4 -0
  294. package/dist/modes/interactive/theme/theme.js.map +1 -1
  295. package/dist/modes/print-mode.d.ts.map +1 -1
  296. package/dist/modes/print-mode.js +19 -10
  297. package/dist/modes/print-mode.js.map +1 -1
  298. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  299. package/dist/modes/rpc/rpc-mode.js +53 -23
  300. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  301. package/dist/package-manager-cli.d.ts.map +1 -1
  302. package/dist/package-manager-cli.js +39 -8
  303. package/dist/package-manager-cli.js.map +1 -1
  304. package/dist/utils/changelog.d.ts +2 -2
  305. package/dist/utils/changelog.d.ts.map +1 -1
  306. package/dist/utils/changelog.js +12 -6
  307. package/dist/utils/changelog.js.map +1 -1
  308. package/dist/utils/image-resize.d.ts.map +1 -1
  309. package/dist/utils/image-resize.js +3 -1
  310. package/dist/utils/image-resize.js.map +1 -1
  311. package/dist/utils/terminal-question.d.ts +8 -0
  312. package/dist/utils/terminal-question.d.ts.map +1 -0
  313. package/dist/utils/terminal-question.js +24 -0
  314. package/dist/utils/terminal-question.js.map +1 -0
  315. package/dist/utils/web-url.d.ts +12 -0
  316. package/dist/utils/web-url.d.ts.map +1 -0
  317. package/dist/utils/web-url.js +20 -0
  318. package/dist/utils/web-url.js.map +1 -0
  319. package/docs/cli.md +14 -1
  320. package/docs/extensions.md +27 -7
  321. package/docs/keybindings.md +1 -1
  322. package/docs/llama-cpp.md +5 -8
  323. package/docs/models-configuration.md +6 -1
  324. package/docs/models.md +2 -1
  325. package/docs/prompt-templates.md +1 -1
  326. package/docs/providers.md +1 -1
  327. package/docs/rpc.md +4 -2
  328. package/docs/sessions.md +7 -1
  329. package/docs/settings.md +1 -1
  330. package/docs/tui.md +1 -1
  331. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  332. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  333. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  334. package/examples/extensions/gondolin/package-lock.json +2 -2
  335. package/examples/extensions/gondolin/package.json +1 -1
  336. package/examples/extensions/plan-mode/index.ts +23 -13
  337. package/examples/extensions/plan-mode/utils.ts +42 -16
  338. package/examples/extensions/subagent/README.md +14 -11
  339. package/examples/extensions/subagent/index.ts +392 -171
  340. package/examples/extensions/with-deps/package-lock.json +2 -2
  341. package/examples/extensions/with-deps/package.json +1 -1
  342. package/examples/tsconfig.json +63 -35
  343. package/package.json +7 -7
  344. package/schemas/models.schema.json +29 -0
  345. package/schemas/settings.schema.json +1 -1
  346. package/dist/bundle/chunks/anthropic-messages-WU4RRDFO.js +0 -6
  347. package/dist/bundle/chunks/chunk-4RKLODCT.js +0 -2
  348. package/dist/bundle/chunks/chunk-7FMRLQ6P.js +0 -1590
  349. package/dist/bundle/chunks/chunk-G23G7KNC.js +0 -4
  350. package/dist/bundle/chunks/chunk-LTLKVIE2.js +0 -65
  351. package/dist/bundle/chunks/chunk-O5CTLHDX.js +0 -82
  352. package/dist/bundle/chunks/chunk-OV4EHN3Q.js +0 -2
  353. package/dist/bundle/chunks/chunk-PWQUNMKT.js +0 -4
  354. package/dist/bundle/chunks/chunk-UKVNB6C4.js +0 -2
  355. package/dist/bundle/chunks/chunk-USJZMAIR.js +0 -2
  356. package/dist/bundle/chunks/chunk-YH5RGRHQ.js +0 -7
  357. package/dist/bundle/chunks/openai-codex-responses-DK2NKO47.js +0 -10
  358. package/dist/bundle/chunks/openai-responses-S5QT5K5D.js +0 -4
  359. package/dist/bundle/chunks/virtual-modules-CTTKTI6Z.js +0 -2
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import type { AgentToolResult } from "@earendil-works/pi-agent-core";
13
13
  import type { ImageContent, TextContent } from "@earendil-works/pi-ai";
14
- import { type CallToolResult, type ContentBlock, type McpRequestOptions, type Tool as McpTool } from "@earendil-works/pi-mcp";
14
+ import { type CallToolResult, type ContentBlock, type McpOutputSaver, type McpRequestOptions, type Tool as McpTool } from "@earendil-works/pi-mcp";
15
15
  import type { TSchema } from "typebox";
16
16
  import type { ToolDefinition, ToolExposure, ToolNamespace, ToolRenderers } from "../../core/extensions/types.ts";
17
17
  import { READ_MCP_RESOURCE_TOOL } from "../../core/mcp-servers.ts";
@@ -21,8 +21,6 @@ import type { McpExposure } from "./config.ts";
21
21
  * description; they differ only in which tool the MCP extension activates to reach them.
22
22
  */
23
23
  export declare function toToolExposure(exposure: McpExposure): ToolExposure;
24
- /** Model-facing text of an MCP result beyond this is cut in the middle. */
25
- export declare const MCP_OUTPUT_MAX_BYTES: number;
26
24
  /** Tool that reads the resources named by resource links. */
27
25
  export { READ_MCP_RESOURCE_TOOL };
28
26
  export interface McpToolDetails {
@@ -31,35 +29,16 @@ export interface McpToolDetails {
31
29
  /** Temp file with the full text output, when the model-facing text was truncated. */
32
30
  fullOutputPath?: string;
33
31
  }
34
- /**
35
- * Saves the full text of a truncated result, or a binary resource, and returns the file path.
36
- * `extension` includes the dot, for example `.txt`.
37
- */
38
- export type McpOutputSaver = (data: string | Uint8Array, extension: string) => Promise<string>;
32
+ /** Saves the full text of a truncated result, or a binary resource, to a temp file and returns its path. */
39
33
  export declare function saveToTempFile(data: string | Uint8Array, extension: string): Promise<string>;
40
34
  export interface McpToolCaller {
41
35
  callTool(name: string, args: Record<string, unknown>, options: McpRequestOptions): Promise<CallToolResult>;
42
36
  }
43
- /**
44
- * `mcp__<server>__<tool>`, sanitized and shortened with a hash suffix when too long. Like Codex,
45
- * everything but `[A-Za-z0-9_]` becomes `_`, so the name is also the identifier codemode scripts
46
- * call it by. `isTaken` reports names used by a different MCP tool: sanitizing can map two tools to
47
- * one name (`a-b` and `a_b`), which then get the hash suffix.
48
- */
49
- export declare function createMcpToolName(server: string, tool: string, isTaken?: (name: string) => boolean): string;
50
37
  /**
51
38
  * Output schema of every MCP tool: the `CallToolResult` scripts receive (without `_meta`, which
52
39
  * {@link convertMcpResult} drops), with the tool's own output schema as `structuredContent`.
53
40
  */
54
41
  export declare function createMcpResultSchema(structuredContentSchema: Record<string, unknown> | undefined): TSchema;
55
- /**
56
- * Keep model-facing text within {@link MCP_OUTPUT_MAX_BYTES}. Longer text becomes one text block in
57
- * Codex's truncation format, followed by the path of the file with the full text; images follow it.
58
- */
59
- export declare function limitMcpContent(content: (TextContent | ImageContent)[], saveOutput?: McpOutputSaver): Promise<{
60
- content: (TextContent | ImageContent)[];
61
- fullOutputPath?: string;
62
- }>;
63
42
  export interface ConvertMcpResultOptions {
64
43
  /** Saves truncated text and binary resources. Default: a temp file. */
65
44
  saveOutput?: McpOutputSaver;
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAa,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,IAAI,IAAI,OAAO,EAEpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAEX,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAMnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,YAAY,CAElE;AAID,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,QAAY,CAAC;AAG9C,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,qFAAqF;IACrF,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,MA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AAcD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,CAAC;IACtB,SAAS,EAAE,aAAa,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,mEAAmE;IACnE,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC;CAClC,GAAG,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,CA8B1C;AAED,yGAAyG;AACzG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAqCnE"}
@@ -9,12 +9,11 @@
9
9
  * the tool's `structuredContent`, and every MCP tool declares a `CallToolResult` output schema. MCP
10
10
  * errors (`isError`) are error results for the model, but scripts still resolve to the result.
11
11
  */
12
- import { createHash } from "node:crypto";
13
- import { toLlmContent, } from "@earendil-works/pi-mcp";
12
+ import { limitMcpContent, normalizeMcpInputSchema, toLlmContent, } from "@earendil-works/pi-mcp";
14
13
  import { Container, Spacer, Text } from "@earendil-works/pi-tui";
15
14
  import { READ_MCP_RESOURCE_TOOL } from "../../core/mcp-servers.js";
16
15
  import { formatToolCallWithArgs, getTextOutput, replaceTabs } from "../../core/tools/render-utils.js";
17
- import { formatSize, truncateMiddle } from "../../core/tools/truncate.js";
16
+ import { formatSize } from "../../core/tools/truncate.js";
18
17
  import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
19
18
  import { VisualLinePreview } from "../../modes/interactive/components/visual-truncate.js";
20
19
  import { writeOutputFile } from "../../utils/output-files.js";
@@ -25,30 +24,14 @@ import { writeOutputFile } from "../../utils/output-files.js";
25
24
  export function toToolExposure(exposure) {
26
25
  return exposure === "codemode" ? "deferred" : exposure;
27
26
  }
28
- /** Provider tool names are limited to 64 characters of `[A-Za-z0-9_-]`. */
29
- const MAX_TOOL_NAME_LENGTH = 64;
30
- /** Model-facing text of an MCP result beyond this is cut in the middle. */
31
- export const MCP_OUTPUT_MAX_BYTES = 20 * 1024;
32
27
  /** Visual (wrapped) result lines shown before the output is expanded. */
33
28
  const OUTPUT_PREVIEW_LINES = 5;
34
29
  /** Tool that reads the resources named by resource links. */
35
30
  export { READ_MCP_RESOURCE_TOOL };
31
+ /** Saves the full text of a truncated result, or a binary resource, to a temp file and returns its path. */
36
32
  export function saveToTempFile(data, extension) {
37
33
  return writeOutputFile("pi-mcp", extension, data);
38
34
  }
39
- /**
40
- * `mcp__<server>__<tool>`, sanitized and shortened with a hash suffix when too long. Like Codex,
41
- * everything but `[A-Za-z0-9_]` becomes `_`, so the name is also the identifier codemode scripts
42
- * call it by. `isTaken` reports names used by a different MCP tool: sanitizing can map two tools to
43
- * one name (`a-b` and `a_b`), which then get the hash suffix.
44
- */
45
- export function createMcpToolName(server, tool, isTaken = () => false) {
46
- const name = `mcp__${server}__${tool}`.replace(/[^A-Za-z0-9_]/g, "_");
47
- if (name.length <= MAX_TOOL_NAME_LENGTH && !isTaken(name))
48
- return name;
49
- const hash = createHash("sha256").update(`${server}\0${tool}`).digest("hex").slice(0, 8);
50
- return `${name.slice(0, MAX_TOOL_NAME_LENGTH - hash.length - 1)}_${hash}`;
51
- }
52
35
  function textOf(content) {
53
36
  return content
54
37
  .filter((block) => block.type === "text")
@@ -128,31 +111,6 @@ export function createMcpResultSchema(structuredContentSchema) {
128
111
  additionalProperties: true,
129
112
  };
130
113
  }
131
- /**
132
- * Keep model-facing text within {@link MCP_OUTPUT_MAX_BYTES}. Longer text becomes one text block in
133
- * Codex's truncation format, followed by the path of the file with the full text; images follow it.
134
- */
135
- export async function limitMcpContent(content, saveOutput = saveToTempFile) {
136
- const combined = textOf(content);
137
- const truncation = truncateMiddle(combined, MCP_OUTPUT_MAX_BYTES);
138
- if (!truncation.truncated)
139
- return { content };
140
- let fullOutputPath;
141
- let where;
142
- try {
143
- fullOutputPath = await saveOutput(combined, ".txt");
144
- where = `[Full output: ${fullOutputPath} (read it with offset/limit)]`;
145
- }
146
- catch (error) {
147
- where = `[Could not save the full output: ${error instanceof Error ? error.message : String(error)}]`;
148
- }
149
- const tokens = Math.ceil(truncation.totalBytes / 4);
150
- const text = `Warning: truncated output (original token count: ${tokens})\nTotal output lines: ${truncation.totalLines}\n\n${truncation.content}\n\n${where}`;
151
- return {
152
- content: [{ type: "text", text }, ...content.filter((block) => block.type === "image")],
153
- ...(fullOutputPath ? { fullOutputPath } : {}),
154
- };
155
- }
156
114
  /** File extension for a saved binary resource: the one its URI ends in, else `.bin`. */
157
115
  function extensionOf(uri) {
158
116
  const path = URL.canParse(uri) ? new URL(uri).pathname : uri;
@@ -206,7 +164,7 @@ export async function convertMcpResult(server, tool, result, options = {}) {
206
164
  if (result.isError && textOf(converted) === "") {
207
165
  converted.push({ type: "text", text: `MCP tool ${server}/${tool} returned an error` });
208
166
  }
209
- const { content, fullOutputPath } = await limitMcpContent(converted, options.saveOutput);
167
+ const { content, fullOutputPath } = await limitMcpContent(converted, options.saveOutput ?? saveToTempFile);
210
168
  const { _meta: _ignored, ...scriptResult } = result;
211
169
  return {
212
170
  content,
@@ -215,17 +173,6 @@ export async function convertMcpResult(server, tool, result, options = {}) {
215
173
  ...(result.isError ? { isError: true } : {}),
216
174
  };
217
175
  }
218
- /**
219
- * Tool input schemas must be objects. MCP servers may omit `type`, and some providers reject object
220
- * schemas without `properties`.
221
- */
222
- function toParameters(schema) {
223
- return {
224
- ...schema,
225
- type: schema.type ?? "object",
226
- ...(schema.properties === undefined ? { properties: {} } : {}),
227
- };
228
- }
229
176
  const ANNOTATION_HINTS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
230
177
  /** The boolean hints of an MCP tool's annotations, or undefined when it has none. */
231
178
  function toToolAnnotations(tool) {
@@ -246,7 +193,8 @@ export function createMcpToolDefinition(options) {
246
193
  name: options.name,
247
194
  label,
248
195
  description: tool.description?.trim() || title || `MCP tool ${tool.name} from server ${server}`,
249
- parameters: toParameters(tool.inputSchema),
196
+ // An object schema, which is what TypeBox schemas are at runtime.
197
+ parameters: normalizeMcpInputSchema(tool.inputSchema),
250
198
  outputSchema: createMcpResultSchema(tool.outputSchema),
251
199
  exposure: toToolExposure(options.exposure),
252
200
  namespace: options.namespace,
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/extensions/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAKN,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AASjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAqB;IACnD,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,2EAA2E;AAC3E,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC9C,yEAAyE;AACzE,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,CA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;AACH,CAAC","sourcesContent":["/**\n * Adapts MCP tools to pi tool definitions.\n *\n * Results map onto pi's model-facing content (text and images). Text over 20KB keeps its start and\n * end with the middle cut out, like Codex does, and the full text is saved to a temp file the model\n * can read. Binary resources other than images are saved to temp files too, and resource links name\n * the `read_mcp_resource` tool. Codemode scripts receive the whole `CallToolResult` without `_meta`\n * (`content` blocks as sent by the server, `structuredContent`, `isError`), never truncated: it is\n * the tool's `structuredContent`, and every MCP tool declares a `CallToolResult` output schema. MCP\n * errors (`isError`) are error results for the model, but scripts still resolve to the result.\n */\n\nimport { createHash } from \"node:crypto\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, JsonValue, TextContent } from \"@earendil-works/pi-ai\";\nimport {\n\ttype CallToolResult,\n\ttype ContentBlock,\n\ttype McpRequestOptions,\n\ttype Tool as McpTool,\n\ttoLlmContent,\n} from \"@earendil-works/pi-mcp\";\nimport { Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { TSchema } from \"typebox\";\nimport type {\n\tToolAnnotations,\n\tToolDefinition,\n\tToolExposure,\n\tToolNamespace,\n\tToolRenderers,\n} from \"../../core/extensions/types.ts\";\nimport { READ_MCP_RESOURCE_TOOL } from \"../../core/mcp-servers.ts\";\nimport { formatToolCallWithArgs, getTextOutput, replaceTabs } from \"../../core/tools/render-utils.ts\";\nimport { formatSize, truncateMiddle } from \"../../core/tools/truncate.ts\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { VisualLinePreview } from \"../../modes/interactive/components/visual-truncate.ts\";\nimport { writeOutputFile } from \"../../utils/output-files.ts\";\nimport type { McpExposure } from \"./config.ts\";\n\n/**\n * Tool exposure of an MCP exposure. `codemode` and `deferred` both leave tools out of the codemode\n * description; they differ only in which tool the MCP extension activates to reach them.\n */\nexport function toToolExposure(exposure: McpExposure): ToolExposure {\n\treturn exposure === \"codemode\" ? \"deferred\" : exposure;\n}\n\n/** Provider tool names are limited to 64 characters of `[A-Za-z0-9_-]`. */\nconst MAX_TOOL_NAME_LENGTH = 64;\n/** Model-facing text of an MCP result beyond this is cut in the middle. */\nexport const MCP_OUTPUT_MAX_BYTES = 20 * 1024;\n/** Visual (wrapped) result lines shown before the output is expanded. */\nconst OUTPUT_PREVIEW_LINES = 5;\n/** Tool that reads the resources named by resource links. */\nexport { READ_MCP_RESOURCE_TOOL };\n\nexport interface McpToolDetails {\n\tserver: string;\n\ttool: string;\n\t/** Temp file with the full text output, when the model-facing text was truncated. */\n\tfullOutputPath?: string;\n}\n\n/**\n * Saves the full text of a truncated result, or a binary resource, and returns the file path.\n * `extension` includes the dot, for example `.txt`.\n */\nexport type McpOutputSaver = (data: string | Uint8Array, extension: string) => Promise<string>;\n\nexport function saveToTempFile(data: string | Uint8Array, extension: string): Promise<string> {\n\treturn writeOutputFile(\"pi-mcp\", extension, data);\n}\n\nexport interface McpToolCaller {\n\tcallTool(name: string, args: Record<string, unknown>, options: McpRequestOptions): Promise<CallToolResult>;\n}\n\n/**\n * `mcp__<server>__<tool>`, sanitized and shortened with a hash suffix when too long. Like Codex,\n * everything but `[A-Za-z0-9_]` becomes `_`, so the name is also the identifier codemode scripts\n * call it by. `isTaken` reports names used by a different MCP tool: sanitizing can map two tools to\n * one name (`a-b` and `a_b`), which then get the hash suffix.\n */\nexport function createMcpToolName(\n\tserver: string,\n\ttool: string,\n\tisTaken: (name: string) => boolean = () => false,\n): string {\n\tconst name = `mcp__${server}__${tool}`.replace(/[^A-Za-z0-9_]/g, \"_\");\n\tif (name.length <= MAX_TOOL_NAME_LENGTH && !isTaken(name)) return name;\n\tconst hash = createHash(\"sha256\").update(`${server}\\0${tool}`).digest(\"hex\").slice(0, 8);\n\treturn `${name.slice(0, MAX_TOOL_NAME_LENGTH - hash.length - 1)}_${hash}`;\n}\n\nfunction textOf(content: readonly (TextContent | ImageContent)[]): string {\n\treturn content\n\t\t.filter((block): block is TextContent => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\n/**\n * MCP content blocks as one compact type with the fields of text and image blocks, which scripts\n * read most (`image(block)` takes an image block as is). Rendered into every MCP tool's declaration.\n */\nconst CONTENT_BLOCK_SCHEMA = {\n\ttype: \"object\",\n\tproperties: {\n\t\ttype: { enum: [\"text\", \"image\", \"audio\", \"resource_link\", \"resource\"] },\n\t\ttext: { type: \"string\" },\n\t\tdata: { type: \"string\" },\n\t\tmimeType: { type: \"string\" },\n\t},\n\trequired: [\"type\"],\n\tadditionalProperties: true,\n};\n\n/** Keywords whose values are data, so a `$ref` key in them is not a reference. */\nconst SCHEMA_DATA_KEYWORDS: ReadonlySet<string> = new Set([\"const\", \"enum\", \"default\", \"examples\"]);\n/** Keywords whose values map names to schemas, so their keys are names, not keywords. */\nconst SCHEMA_MAP_KEYWORDS: ReadonlySet<string> = new Set([\n\t\"properties\",\n\t\"patternProperties\",\n\t\"dependentSchemas\",\n\t\"dependencies\",\n\t\"$defs\",\n\t\"definitions\",\n]);\n\n/**\n * `schema` as a subschema at the JSON pointer `pointer` (`#/properties/structuredContent`) of\n * another schema: its local references (`#`, `#/$defs/Item`) are rewritten to point below\n * `pointer`, so they resolve to the same subschemas as before.\n */\nfunction relocateSchema(schema: unknown, pointer: string): unknown {\n\tif (Array.isArray(schema)) return schema.map((item) => relocateSchema(item, pointer));\n\tif (typeof schema !== \"object\" || schema === null) return schema;\n\tconst relocated: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(schema)) {\n\t\tif (key === \"$ref\" && typeof value === \"string\" && (value === \"#\" || value.startsWith(\"#/\"))) {\n\t\t\trelocated[key] = `${pointer}${value.slice(1)}`;\n\t\t} else if (SCHEMA_DATA_KEYWORDS.has(key)) {\n\t\t\trelocated[key] = value;\n\t\t} else if (SCHEMA_MAP_KEYWORDS.has(key) && typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n\t\t\trelocated[key] = Object.fromEntries(\n\t\t\t\tObject.entries(value).map(([name, subschema]) => [name, relocateSchema(subschema, pointer)]),\n\t\t\t);\n\t\t} else {\n\t\t\trelocated[key] = relocateSchema(value, pointer);\n\t\t}\n\t}\n\treturn relocated;\n}\n\n/**\n * Output schema of every MCP tool: the `CallToolResult` scripts receive (without `_meta`, which\n * {@link convertMcpResult} drops), with the tool's own output schema as `structuredContent`.\n */\nexport function createMcpResultSchema(structuredContentSchema: Record<string, unknown> | undefined): TSchema {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: {\n\t\t\tcontent: { type: \"array\", items: CONTENT_BLOCK_SCHEMA },\n\t\t\t// Servers may send structured content without declaring a schema for it, and it may be any JSON value.\n\t\t\tstructuredContent: structuredContentSchema\n\t\t\t\t? relocateSchema(structuredContentSchema, \"#/properties/structuredContent\")\n\t\t\t\t: {},\n\t\t\tisError: { type: \"boolean\" },\n\t\t},\n\t\trequired: [\"content\"],\n\t\t// Fields newer protocol versions add.\n\t\tadditionalProperties: true,\n\t} as unknown as TSchema;\n}\n\n/**\n * Keep model-facing text within {@link MCP_OUTPUT_MAX_BYTES}. Longer text becomes one text block in\n * Codex's truncation format, followed by the path of the file with the full text; images follow it.\n */\nexport async function limitMcpContent(\n\tcontent: (TextContent | ImageContent)[],\n\tsaveOutput: McpOutputSaver = saveToTempFile,\n): Promise<{ content: (TextContent | ImageContent)[]; fullOutputPath?: string }> {\n\tconst combined = textOf(content);\n\tconst truncation = truncateMiddle(combined, MCP_OUTPUT_MAX_BYTES);\n\tif (!truncation.truncated) return { content };\n\tlet fullOutputPath: string | undefined;\n\tlet where: string;\n\ttry {\n\t\tfullOutputPath = await saveOutput(combined, \".txt\");\n\t\twhere = `[Full output: ${fullOutputPath} (read it with offset/limit)]`;\n\t} catch (error) {\n\t\twhere = `[Could not save the full output: ${error instanceof Error ? error.message : String(error)}]`;\n\t}\n\tconst tokens = Math.ceil(truncation.totalBytes / 4);\n\tconst text = `Warning: truncated output (original token count: ${tokens})\\nTotal output lines: ${truncation.totalLines}\\n\\n${truncation.content}\\n\\n${where}`;\n\treturn {\n\t\tcontent: [{ type: \"text\", text }, ...content.filter((block) => block.type === \"image\")],\n\t\t...(fullOutputPath ? { fullOutputPath } : {}),\n\t};\n}\n\nexport interface ConvertMcpResultOptions {\n\t/** Saves truncated text and binary resources. Default: a temp file. */\n\tsaveOutput?: McpOutputSaver;\n\t/** Whether the server's resources can be read with `read_mcp_resource`, which resource links then name. */\n\treadableResources?: boolean;\n}\n\n/** File extension for a saved binary resource: the one its URI ends in, else `.bin`. */\nfunction extensionOf(uri: string): string {\n\tconst path = URL.canParse(uri) ? new URL(uri).pathname : uri;\n\treturn /\\.[A-Za-z0-9]{1,8}$/.exec(path)?.[0] ?? \".bin\";\n}\n\n/** Blobs of these types are shown as text. */\nfunction isTextMimeType(mimeType: string | undefined): boolean {\n\tif (!mimeType) return false;\n\tconst type = mimeType.split(\";\", 1)[0].trim().toLowerCase();\n\treturn type.startsWith(\"text/\") || type === \"application/json\" || type.endsWith(\"+json\") || type.endsWith(\"+xml\");\n}\n\n/** Model-facing content of one block of `server`'s result. */\nasync function blockToContent(\n\tserver: string,\n\tblock: ContentBlock,\n\toptions: ConvertMcpResultOptions,\n): Promise<(TextContent | ImageContent)[]> {\n\tif (block.type === \"resource_link\") {\n\t\tconst details = [block.mimeType, block.size === undefined ? undefined : formatSize(block.size)].filter(Boolean);\n\t\tconst read = options.readableResources ? `. Read it with ${READ_MCP_RESOURCE_TOOL} (server \"${server}\")` : \"\";\n\t\tconst description = block.description ? `: ${block.description}` : \"\";\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `[Resource ${block.uri} \"${block.title ?? block.name}\"${details.length > 0 ? ` (${details.join(\", \")})` : \"\"}${description}${read}]`,\n\t\t\t},\n\t\t];\n\t}\n\tif (block.type === \"resource\" && \"blob\" in block.resource && !block.resource.mimeType?.startsWith(\"image/\")) {\n\t\tconst { uri, mimeType, blob } = block.resource;\n\t\tconst data = Buffer.from(blob, \"base64\");\n\t\tif (isTextMimeType(mimeType)) return [{ type: \"text\", text: data.toString(\"utf8\") }];\n\t\tconst kind = `${mimeType ?? \"unknown type\"}, ${formatSize(data.length)}`;\n\t\ttry {\n\t\t\tconst path = await (options.saveOutput ?? saveToTempFile)(data, extensionOf(uri));\n\t\t\treturn [{ type: \"text\", text: `[Binary resource ${uri} (${kind}) saved to ${path}]` }];\n\t\t} catch (error) {\n\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\treturn [{ type: \"text\", text: `[Binary resource ${uri} (${kind}) could not be saved: ${reason}]` }];\n\t\t}\n\t}\n\treturn toLlmContent({ content: [block] });\n}\n\n/** Model-facing content of `server`'s content blocks, before the output limit. */\nexport async function toModelContent(\n\tserver: string,\n\tblocks: readonly ContentBlock[],\n\toptions: ConvertMcpResultOptions = {},\n): Promise<(TextContent | ImageContent)[]> {\n\treturn (await Promise.all(blocks.map((block) => blockToContent(server, block, options)))).flat();\n}\n\n/** Convert an MCP result. `isError` results become error results that keep the structured result. */\nexport async function convertMcpResult(\n\tserver: string,\n\ttool: string,\n\tresult: CallToolResult,\n\toptions: ConvertMcpResultOptions = {},\n): Promise<AgentToolResult<McpToolDetails>> {\n\t// Without content blocks, toLlmContent falls back to the structured content as JSON.\n\tconst converted: (TextContent | ImageContent)[] =\n\t\tresult.content.length > 0 ? await toModelContent(server, result.content, options) : toLlmContent(result);\n\tif (result.isError && textOf(converted) === \"\") {\n\t\tconverted.push({ type: \"text\", text: `MCP tool ${server}/${tool} returned an error` });\n\t}\n\tconst { content, fullOutputPath } = await limitMcpContent(converted, options.saveOutput);\n\tconst { _meta: _ignored, ...scriptResult } = result;\n\treturn {\n\t\tcontent,\n\t\tdetails: { server, tool, ...(fullOutputPath ? { fullOutputPath } : {}) },\n\t\tstructuredContent: scriptResult as unknown as JsonValue,\n\t\t...(result.isError ? { isError: true } : {}),\n\t};\n}\n\n/**\n * Tool input schemas must be objects. MCP servers may omit `type`, and some providers reject object\n * schemas without `properties`.\n */\nfunction toParameters(schema: Record<string, unknown>): TSchema {\n\treturn {\n\t\t...schema,\n\t\ttype: schema.type ?? \"object\",\n\t\t...(schema.properties === undefined ? { properties: {} } : {}),\n\t} as unknown as TSchema;\n}\n\nconst ANNOTATION_HINTS = [\"readOnlyHint\", \"destructiveHint\", \"idempotentHint\", \"openWorldHint\"] as const;\n\n/** The boolean hints of an MCP tool's annotations, or undefined when it has none. */\nfunction toToolAnnotations(tool: McpTool): ToolAnnotations | undefined {\n\tconst annotations: ToolAnnotations = {};\n\tfor (const hint of ANNOTATION_HINTS) {\n\t\tconst value = tool.annotations?.[hint];\n\t\tif (typeof value === \"boolean\") annotations[hint] = value;\n\t}\n\treturn Object.keys(annotations).length > 0 ? annotations : undefined;\n}\n\nexport function createMcpToolDefinition(options: {\n\tserver: string;\n\ttool: McpTool;\n\tname: string;\n\texposure: McpExposure;\n\tnamespace: ToolNamespace;\n\ttimeoutMs: number;\n\tgetClient: () => Promise<McpToolCaller>;\n\t/** Whether `read_mcp_resource` can read the server's resources. */\n\treadableResources?: () => boolean;\n}): ToolDefinition<TSchema, McpToolDetails> {\n\tconst { server, tool } = options;\n\tconst title = tool.title ?? tool.annotations?.title;\n\tconst annotations = toToolAnnotations(tool);\n\tconst label = `${server}/${tool.name}`;\n\treturn {\n\t\tname: options.name,\n\t\tlabel,\n\t\tdescription: tool.description?.trim() || title || `MCP tool ${tool.name} from server ${server}`,\n\t\tparameters: toParameters(tool.inputSchema),\n\t\toutputSchema: createMcpResultSchema(tool.outputSchema),\n\t\texposure: toToolExposure(options.exposure),\n\t\tnamespace: options.namespace,\n\t\t...(annotations ? { annotations } : {}),\n\t\t...createMcpToolRenderers(label),\n\t\tasync execute(_toolCallId, params, signal, onUpdate) {\n\t\t\tconst client = await options.getClient();\n\t\t\tconst result = await client.callTool(tool.name, (params ?? {}) as Record<string, unknown>, {\n\t\t\t\tsignal,\n\t\t\t\ttimeoutMs: options.timeoutMs,\n\t\t\t\tonProgress: (progress) => {\n\t\t\t\t\tconst total = progress.total === undefined ? \"\" : `/${progress.total}`;\n\t\t\t\t\tconst text = progress.message ?? `Progress ${progress.progress}${total}`;\n\t\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text }], details: { server, tool: tool.name } });\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn convertMcpResult(server, tool.name, result, { readableResources: options.readableResources?.() });\n\t\t},\n\t};\n}\n\n/** Renderers of calls to an MCP tool, labeled `server/tool`, also used before the tool is registered. */\nexport function createMcpToolRenderers(label: string): ToolRenderers {\n\treturn {\n\t\trenderCall(args, theme, context) {\n\t\t\tconst component = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tcomponent.setText(formatToolCallWithArgs(label, args, theme, context.expanded));\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tconst output = getTextOutput(result, context.showImages).trim();\n\t\t\tif (!output) return component;\n\t\t\tconst color = context.isError ? \"error\" : \"toolOutput\";\n\t\t\tconst styled = replaceTabs(output)\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.map((line) => theme.fg(color, line))\n\t\t\t\t.join(\"\\n\");\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tif (options.expanded) {\n\t\t\t\tcomponent.addChild(new Text(styled, 0, 0));\n\t\t\t} else {\n\t\t\t\t// Limit wrapped lines, not logical ones: MCP results are often one long JSON line.\n\t\t\t\tcomponent.addChild(\n\t\t\t\t\tnew VisualLinePreview({\n\t\t\t\t\t\ttext: styled,\n\t\t\t\t\t\tmaxVisualLines: OUTPUT_PREVIEW_LINES,\n\t\t\t\t\t\tkeep: \"start\",\n\t\t\t\t\t\tformatHint: (hidden) =>\n\t\t\t\t\t\t\t`${theme.fg(\"muted\", `... (${hidden} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tconst fullOutputPath = (result.details as McpToolDetails | undefined)?.fullOutputPath;\n\t\t\t\tif (fullOutputPath) component.addChild(new Text(theme.fg(\"muted\", `Full output: ${fullOutputPath}`), 0, 0));\n\t\t\t}\n\t\t\treturn component;\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/extensions/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAGN,eAAe,EAIf,uBAAuB,EACvB,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AASjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAqB;IACnD,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,yEAAyE;AACzE,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,CAAC;AASlC,4GAA4G;AAC5G,MAAM,UAAU,cAAc,CAAC,IAAyB,EAAE,SAAiB;IAC1E,OAAO,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC;AAMD,SAAS,MAAM,CAAC,OAAgD;IAC/D,OAAO,OAAO;SACZ,MAAM,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AAI,cAAc;oBAAE,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,cAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC7G,CAAC;YACD,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Adapts MCP tools to pi tool definitions.\n *\n * Results map onto pi's model-facing content (text and images). Text over 20KB keeps its start and\n * end with the middle cut out, like Codex does, and the full text is saved to a temp file the model\n * can read. Binary resources other than images are saved to temp files too, and resource links name\n * the `read_mcp_resource` tool. Codemode scripts receive the whole `CallToolResult` without `_meta`\n * (`content` blocks as sent by the server, `structuredContent`, `isError`), never truncated: it is\n * the tool's `structuredContent`, and every MCP tool declares a `CallToolResult` output schema. MCP\n * errors (`isError`) are error results for the model, but scripts still resolve to the result.\n */\n\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, JsonValue, TextContent } from \"@earendil-works/pi-ai\";\nimport {\n\ttype CallToolResult,\n\ttype ContentBlock,\n\tlimitMcpContent,\n\ttype McpOutputSaver,\n\ttype McpRequestOptions,\n\ttype Tool as McpTool,\n\tnormalizeMcpInputSchema,\n\ttoLlmContent,\n} from \"@earendil-works/pi-mcp\";\nimport { Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { TSchema } from \"typebox\";\nimport type {\n\tToolAnnotations,\n\tToolDefinition,\n\tToolExposure,\n\tToolNamespace,\n\tToolRenderers,\n} from \"../../core/extensions/types.ts\";\nimport { READ_MCP_RESOURCE_TOOL } from \"../../core/mcp-servers.ts\";\nimport { formatToolCallWithArgs, getTextOutput, replaceTabs } from \"../../core/tools/render-utils.ts\";\nimport { formatSize } from \"../../core/tools/truncate.ts\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { VisualLinePreview } from \"../../modes/interactive/components/visual-truncate.ts\";\nimport { writeOutputFile } from \"../../utils/output-files.ts\";\nimport type { McpExposure } from \"./config.ts\";\n\n/**\n * Tool exposure of an MCP exposure. `codemode` and `deferred` both leave tools out of the codemode\n * description; they differ only in which tool the MCP extension activates to reach them.\n */\nexport function toToolExposure(exposure: McpExposure): ToolExposure {\n\treturn exposure === \"codemode\" ? \"deferred\" : exposure;\n}\n\n/** Visual (wrapped) result lines shown before the output is expanded. */\nconst OUTPUT_PREVIEW_LINES = 5;\n/** Tool that reads the resources named by resource links. */\nexport { READ_MCP_RESOURCE_TOOL };\n\nexport interface McpToolDetails {\n\tserver: string;\n\ttool: string;\n\t/** Temp file with the full text output, when the model-facing text was truncated. */\n\tfullOutputPath?: string;\n}\n\n/** Saves the full text of a truncated result, or a binary resource, to a temp file and returns its path. */\nexport function saveToTempFile(data: string | Uint8Array, extension: string): Promise<string> {\n\treturn writeOutputFile(\"pi-mcp\", extension, data);\n}\n\nexport interface McpToolCaller {\n\tcallTool(name: string, args: Record<string, unknown>, options: McpRequestOptions): Promise<CallToolResult>;\n}\n\nfunction textOf(content: readonly (TextContent | ImageContent)[]): string {\n\treturn content\n\t\t.filter((block): block is TextContent => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.join(\"\\n\");\n}\n\n/**\n * MCP content blocks as one compact type with the fields of text and image blocks, which scripts\n * read most (`image(block)` takes an image block as is). Rendered into every MCP tool's declaration.\n */\nconst CONTENT_BLOCK_SCHEMA = {\n\ttype: \"object\",\n\tproperties: {\n\t\ttype: { enum: [\"text\", \"image\", \"audio\", \"resource_link\", \"resource\"] },\n\t\ttext: { type: \"string\" },\n\t\tdata: { type: \"string\" },\n\t\tmimeType: { type: \"string\" },\n\t},\n\trequired: [\"type\"],\n\tadditionalProperties: true,\n};\n\n/** Keywords whose values are data, so a `$ref` key in them is not a reference. */\nconst SCHEMA_DATA_KEYWORDS: ReadonlySet<string> = new Set([\"const\", \"enum\", \"default\", \"examples\"]);\n/** Keywords whose values map names to schemas, so their keys are names, not keywords. */\nconst SCHEMA_MAP_KEYWORDS: ReadonlySet<string> = new Set([\n\t\"properties\",\n\t\"patternProperties\",\n\t\"dependentSchemas\",\n\t\"dependencies\",\n\t\"$defs\",\n\t\"definitions\",\n]);\n\n/**\n * `schema` as a subschema at the JSON pointer `pointer` (`#/properties/structuredContent`) of\n * another schema: its local references (`#`, `#/$defs/Item`) are rewritten to point below\n * `pointer`, so they resolve to the same subschemas as before.\n */\nfunction relocateSchema(schema: unknown, pointer: string): unknown {\n\tif (Array.isArray(schema)) return schema.map((item) => relocateSchema(item, pointer));\n\tif (typeof schema !== \"object\" || schema === null) return schema;\n\tconst relocated: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(schema)) {\n\t\tif (key === \"$ref\" && typeof value === \"string\" && (value === \"#\" || value.startsWith(\"#/\"))) {\n\t\t\trelocated[key] = `${pointer}${value.slice(1)}`;\n\t\t} else if (SCHEMA_DATA_KEYWORDS.has(key)) {\n\t\t\trelocated[key] = value;\n\t\t} else if (SCHEMA_MAP_KEYWORDS.has(key) && typeof value === \"object\" && value !== null && !Array.isArray(value)) {\n\t\t\trelocated[key] = Object.fromEntries(\n\t\t\t\tObject.entries(value).map(([name, subschema]) => [name, relocateSchema(subschema, pointer)]),\n\t\t\t);\n\t\t} else {\n\t\t\trelocated[key] = relocateSchema(value, pointer);\n\t\t}\n\t}\n\treturn relocated;\n}\n\n/**\n * Output schema of every MCP tool: the `CallToolResult` scripts receive (without `_meta`, which\n * {@link convertMcpResult} drops), with the tool's own output schema as `structuredContent`.\n */\nexport function createMcpResultSchema(structuredContentSchema: Record<string, unknown> | undefined): TSchema {\n\treturn {\n\t\ttype: \"object\",\n\t\tproperties: {\n\t\t\tcontent: { type: \"array\", items: CONTENT_BLOCK_SCHEMA },\n\t\t\t// Servers may send structured content without declaring a schema for it, and it may be any JSON value.\n\t\t\tstructuredContent: structuredContentSchema\n\t\t\t\t? relocateSchema(structuredContentSchema, \"#/properties/structuredContent\")\n\t\t\t\t: {},\n\t\t\tisError: { type: \"boolean\" },\n\t\t},\n\t\trequired: [\"content\"],\n\t\t// Fields newer protocol versions add.\n\t\tadditionalProperties: true,\n\t} as unknown as TSchema;\n}\n\nexport interface ConvertMcpResultOptions {\n\t/** Saves truncated text and binary resources. Default: a temp file. */\n\tsaveOutput?: McpOutputSaver;\n\t/** Whether the server's resources can be read with `read_mcp_resource`, which resource links then name. */\n\treadableResources?: boolean;\n}\n\n/** File extension for a saved binary resource: the one its URI ends in, else `.bin`. */\nfunction extensionOf(uri: string): string {\n\tconst path = URL.canParse(uri) ? new URL(uri).pathname : uri;\n\treturn /\\.[A-Za-z0-9]{1,8}$/.exec(path)?.[0] ?? \".bin\";\n}\n\n/** Blobs of these types are shown as text. */\nfunction isTextMimeType(mimeType: string | undefined): boolean {\n\tif (!mimeType) return false;\n\tconst type = mimeType.split(\";\", 1)[0].trim().toLowerCase();\n\treturn type.startsWith(\"text/\") || type === \"application/json\" || type.endsWith(\"+json\") || type.endsWith(\"+xml\");\n}\n\n/** Model-facing content of one block of `server`'s result. */\nasync function blockToContent(\n\tserver: string,\n\tblock: ContentBlock,\n\toptions: ConvertMcpResultOptions,\n): Promise<(TextContent | ImageContent)[]> {\n\tif (block.type === \"resource_link\") {\n\t\tconst details = [block.mimeType, block.size === undefined ? undefined : formatSize(block.size)].filter(Boolean);\n\t\tconst read = options.readableResources ? `. Read it with ${READ_MCP_RESOURCE_TOOL} (server \"${server}\")` : \"\";\n\t\tconst description = block.description ? `: ${block.description}` : \"\";\n\t\treturn [\n\t\t\t{\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: `[Resource ${block.uri} \"${block.title ?? block.name}\"${details.length > 0 ? ` (${details.join(\", \")})` : \"\"}${description}${read}]`,\n\t\t\t},\n\t\t];\n\t}\n\tif (block.type === \"resource\" && \"blob\" in block.resource && !block.resource.mimeType?.startsWith(\"image/\")) {\n\t\tconst { uri, mimeType, blob } = block.resource;\n\t\tconst data = Buffer.from(blob, \"base64\");\n\t\tif (isTextMimeType(mimeType)) return [{ type: \"text\", text: data.toString(\"utf8\") }];\n\t\tconst kind = `${mimeType ?? \"unknown type\"}, ${formatSize(data.length)}`;\n\t\ttry {\n\t\t\tconst path = await (options.saveOutput ?? saveToTempFile)(data, extensionOf(uri));\n\t\t\treturn [{ type: \"text\", text: `[Binary resource ${uri} (${kind}) saved to ${path}]` }];\n\t\t} catch (error) {\n\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\treturn [{ type: \"text\", text: `[Binary resource ${uri} (${kind}) could not be saved: ${reason}]` }];\n\t\t}\n\t}\n\treturn toLlmContent({ content: [block] });\n}\n\n/** Model-facing content of `server`'s content blocks, before the output limit. */\nexport async function toModelContent(\n\tserver: string,\n\tblocks: readonly ContentBlock[],\n\toptions: ConvertMcpResultOptions = {},\n): Promise<(TextContent | ImageContent)[]> {\n\treturn (await Promise.all(blocks.map((block) => blockToContent(server, block, options)))).flat();\n}\n\n/** Convert an MCP result. `isError` results become error results that keep the structured result. */\nexport async function convertMcpResult(\n\tserver: string,\n\ttool: string,\n\tresult: CallToolResult,\n\toptions: ConvertMcpResultOptions = {},\n): Promise<AgentToolResult<McpToolDetails>> {\n\t// Without content blocks, toLlmContent falls back to the structured content as JSON.\n\tconst converted: (TextContent | ImageContent)[] =\n\t\tresult.content.length > 0 ? await toModelContent(server, result.content, options) : toLlmContent(result);\n\tif (result.isError && textOf(converted) === \"\") {\n\t\tconverted.push({ type: \"text\", text: `MCP tool ${server}/${tool} returned an error` });\n\t}\n\tconst { content, fullOutputPath } = await limitMcpContent(converted, options.saveOutput ?? saveToTempFile);\n\tconst { _meta: _ignored, ...scriptResult } = result;\n\treturn {\n\t\tcontent,\n\t\tdetails: { server, tool, ...(fullOutputPath ? { fullOutputPath } : {}) },\n\t\tstructuredContent: scriptResult as unknown as JsonValue,\n\t\t...(result.isError ? { isError: true } : {}),\n\t};\n}\n\nconst ANNOTATION_HINTS = [\"readOnlyHint\", \"destructiveHint\", \"idempotentHint\", \"openWorldHint\"] as const;\n\n/** The boolean hints of an MCP tool's annotations, or undefined when it has none. */\nfunction toToolAnnotations(tool: McpTool): ToolAnnotations | undefined {\n\tconst annotations: ToolAnnotations = {};\n\tfor (const hint of ANNOTATION_HINTS) {\n\t\tconst value = tool.annotations?.[hint];\n\t\tif (typeof value === \"boolean\") annotations[hint] = value;\n\t}\n\treturn Object.keys(annotations).length > 0 ? annotations : undefined;\n}\n\nexport function createMcpToolDefinition(options: {\n\tserver: string;\n\ttool: McpTool;\n\tname: string;\n\texposure: McpExposure;\n\tnamespace: ToolNamespace;\n\ttimeoutMs: number;\n\tgetClient: () => Promise<McpToolCaller>;\n\t/** Whether `read_mcp_resource` can read the server's resources. */\n\treadableResources?: () => boolean;\n}): ToolDefinition<TSchema, McpToolDetails> {\n\tconst { server, tool } = options;\n\tconst title = tool.title ?? tool.annotations?.title;\n\tconst annotations = toToolAnnotations(tool);\n\tconst label = `${server}/${tool.name}`;\n\treturn {\n\t\tname: options.name,\n\t\tlabel,\n\t\tdescription: tool.description?.trim() || title || `MCP tool ${tool.name} from server ${server}`,\n\t\t// An object schema, which is what TypeBox schemas are at runtime.\n\t\tparameters: normalizeMcpInputSchema(tool.inputSchema) as unknown as TSchema,\n\t\toutputSchema: createMcpResultSchema(tool.outputSchema),\n\t\texposure: toToolExposure(options.exposure),\n\t\tnamespace: options.namespace,\n\t\t...(annotations ? { annotations } : {}),\n\t\t...createMcpToolRenderers(label),\n\t\tasync execute(_toolCallId, params, signal, onUpdate) {\n\t\t\tconst client = await options.getClient();\n\t\t\tconst result = await client.callTool(tool.name, (params ?? {}) as Record<string, unknown>, {\n\t\t\t\tsignal,\n\t\t\t\ttimeoutMs: options.timeoutMs,\n\t\t\t\tonProgress: (progress) => {\n\t\t\t\t\tconst total = progress.total === undefined ? \"\" : `/${progress.total}`;\n\t\t\t\t\tconst text = progress.message ?? `Progress ${progress.progress}${total}`;\n\t\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text }], details: { server, tool: tool.name } });\n\t\t\t\t},\n\t\t\t});\n\t\t\treturn convertMcpResult(server, tool.name, result, { readableResources: options.readableResources?.() });\n\t\t},\n\t};\n}\n\n/** Renderers of calls to an MCP tool, labeled `server/tool`, also used before the tool is registered. */\nexport function createMcpToolRenderers(label: string): ToolRenderers {\n\treturn {\n\t\trenderCall(args, theme, context) {\n\t\t\tconst component = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tcomponent.setText(formatToolCallWithArgs(label, args, theme, context.expanded));\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tconst output = getTextOutput(result, context.showImages).trim();\n\t\t\tif (!output) return component;\n\t\t\tconst color = context.isError ? \"error\" : \"toolOutput\";\n\t\t\tconst styled = replaceTabs(output)\n\t\t\t\t.split(\"\\n\")\n\t\t\t\t.map((line) => theme.fg(color, line))\n\t\t\t\t.join(\"\\n\");\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tif (options.expanded) {\n\t\t\t\tcomponent.addChild(new Text(styled, 0, 0));\n\t\t\t} else {\n\t\t\t\t// Limit wrapped lines, not logical ones: MCP results are often one long JSON line.\n\t\t\t\tcomponent.addChild(\n\t\t\t\t\tnew VisualLinePreview({\n\t\t\t\t\t\ttext: styled,\n\t\t\t\t\t\tmaxVisualLines: OUTPUT_PREVIEW_LINES,\n\t\t\t\t\t\tkeep: \"start\",\n\t\t\t\t\t\tformatHint: (hidden) =>\n\t\t\t\t\t\t\t`${theme.fg(\"muted\", `... (${hidden} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tconst fullOutputPath = (result.details as McpToolDetails | undefined)?.fullOutputPath;\n\t\t\t\tif (fullOutputPath) component.addChild(new Text(theme.fg(\"muted\", `Full output: ${fullOutputPath}`), 0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AAW,qBAAqB;IACrC,iCAAiC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC,CAAC;CAChF;AA2BD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2VAAyX,CAAC;AAE9Z,wBAAgB,8BAA8B,CAC7C,OAAO,GAAE,qBAA0B,GACjC,cAAc,CAAC,OAAO,gBAAgB,EAAE,qBAAqB,CAAC,CAyBhE"}
@@ -7,6 +7,7 @@
7
7
  * next model call. Loading goes through the active tool set, so it is recorded in the transcript
8
8
  * like any other tool change and survives `/tree`, resume, and fork on that branch.
9
9
  */
10
+ import { resolveSchemaRef } from "@earendil-works/pi-codemode/declarations";
10
11
  import { Type } from "typebox";
11
12
  export const TOOL_SEARCH_TOOL_NAME = "tool_search";
12
13
  export const DEFAULT_TOOL_SEARCH_LIMIT = 8;
@@ -64,24 +65,35 @@ export function tokenize(text) {
64
65
  function isObject(value) {
65
66
  return typeof value === "object" && value !== null && !Array.isArray(value);
66
67
  }
67
- /** Schema descriptions and property names, recursively. */
68
- function schemaText(schema, parts) {
68
+ /**
69
+ * Schema descriptions and property names, recursively, following local `$ref`s into `root`. `seen` holds the
70
+ * subschemas already reached through a reference, so recursive and shared definitions are read once, and
71
+ * definitions no property references are not read.
72
+ */
73
+ function schemaText(schema, root, parts, seen) {
69
74
  if (!isObject(schema))
70
75
  return;
76
+ if (typeof schema.$ref === "string") {
77
+ const target = resolveSchemaRef(schema.$ref, root);
78
+ if (isObject(target) && !seen.has(target)) {
79
+ seen.add(target);
80
+ schemaText(target, root, parts, seen);
81
+ }
82
+ }
71
83
  if (typeof schema.description === "string")
72
84
  parts.push(schema.description);
73
85
  if (isObject(schema.properties)) {
74
86
  for (const [name, property] of Object.entries(schema.properties)) {
75
87
  parts.push(name);
76
- schemaText(property, parts);
88
+ schemaText(property, root, parts, seen);
77
89
  }
78
90
  }
79
- schemaText(schema.items, parts);
91
+ schemaText(schema.items, root, parts, seen);
80
92
  for (const key of ["anyOf", "oneOf", "allOf"]) {
81
93
  const variants = schema[key];
82
94
  if (Array.isArray(variants))
83
95
  for (const variant of variants)
84
- schemaText(variant, parts);
96
+ schemaText(variant, root, parts, seen);
85
97
  }
86
98
  }
87
99
  /**
@@ -90,7 +102,7 @@ function schemaText(schema, parts) {
90
102
  */
91
103
  export function createToolSearchDocument(tool, namespace) {
92
104
  const parts = [tool.description];
93
- schemaText(tool.parameters, parts);
105
+ schemaText(tool.parameters, tool.parameters, parts, new Set([tool.parameters]));
94
106
  const namespaceText = namespace
95
107
  ? [namespace.name, namespace.description ?? "", namespace.instructions ?? ""].join(" ")
96
108
  : "";
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/extensions/tool-search/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAS5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAqB3C,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAE7E,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IAC/C,GAAG;IACH,IAAI;IACJ,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;CACN,CAAC,CAAC;AAEH,wFAAwF;AACxF,SAAS,IAAI,CAAC,IAAY;IACzB,I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AC;QACnG,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tool discovery: a BM25 ranker over tool metadata, shared by `searchTools()` in codemode scripts and\n * the optional `tool_search` tool.\n *\n * `tool_search` searches tools that are not declared to\n * the model (`codemode` and `deferred` exposure) and loads the matches, so they are declared for the\n * next model call. Loading goes through the active tool set, so it is recorded in the transcript\n * like any other tool change and survives `/tree`, resume, and fork on that branch.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport type {\n\tExtensionAPI,\n\tToolDefinition,\n\tToolExposure,\n\tToolInfo,\n\tToolNamespace,\n} from \"../../core/extensions/types.ts\";\n\nexport const TOOL_SEARCH_TOOL_NAME = \"tool_search\";\nexport const DEFAULT_TOOL_SEARCH_LIMIT = 8;\n\n/** A tool as the ranker sees it: its name and the texts built by {@link createToolSearchDocument}. */\nexport interface ToolSearchDocument {\n\tname: string;\n\t/** Description, schema descriptions, and property names. */\n\ttext: string;\n\t/** Name, description, and instructions of the tool's namespace. */\n\tnamespaceText?: string;\n}\n\nexport interface ToolSearchMatch {\n\tname: string;\n\tscore: number;\n}\n\n/** Ranks tools for a query. BM25 today; a hybrid ranker with embeddings can replace it. */\nexport interface ToolRanker {\n\trank(query: string, documents: readonly ToolSearchDocument[], limit: number): ToolSearchMatch[];\n}\n\nconst wordSegmenter = new Intl.Segmenter(undefined, { granularity: \"word\" });\n\nconst STOP_WORDS: ReadonlySet<string> = new Set([\n\t\"a\",\n\t\"an\",\n\t\"and\",\n\t\"are\",\n\t\"as\",\n\t\"at\",\n\t\"be\",\n\t\"by\",\n\t\"for\",\n\t\"from\",\n\t\"in\",\n\t\"is\",\n\t\"it\",\n\t\"of\",\n\t\"on\",\n\t\"or\",\n\t\"that\",\n\t\"the\",\n\t\"this\",\n\t\"to\",\n\t\"with\",\n]);\n\n/** Naive singular form, so `issues` matches `issue` and `searches` matches `search`. */\nfunction stem(term: string): string {\n\tif (term.length > 4 && term.endsWith(\"ies\")) return `${term.slice(0, -3)}y`;\n\tif (term.length > 4 && /(ches|shes|sses|xes|zes)$/.test(term)) return term.slice(0, -2);\n\tif (term.length > 3 && term.endsWith(\"s\") && !term.endsWith(\"ss\")) return term.slice(0, -1);\n\treturn term;\n}\n\n/** Unicode word segmentation with identifier boundaries and English stop words/singular forms. */\nexport function tokenize(text: string): string[] {\n\tconst normalized = text\n\t\t.normalize(\"NFC\")\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n\t\t.toLowerCase()\n\t\t.replace(/[^\\p{L}\\p{M}\\p{N}]+/gu, \" \");\n\t// The segmenter costs about 15 times a split. Plain ASCII splits into the same words at spaces, so only other\n\t// text, such as Chinese written without spaces, goes through it.\n\tconst words = /^[a-z0-9 ]*$/.test(normalized)\n\t\t? normalized.split(\" \")\n\t\t: Array.from(wordSegmenter.segment(normalized), (segment) => (segment.isWordLike ? segment.segment : \"\"));\n\treturn words\n\t\t.filter((word) => word.length > 0 && !STOP_WORDS.has(word))\n\t\t.map((word) => (/^[a-z0-9]+$/.test(word) ? stem(word) : word));\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Schema descriptions and property names, recursively. */\nfunction schemaText(schema: unknown, parts: string[]): void {\n\tif (!isObject(schema)) return;\n\tif (typeof schema.description === \"string\") parts.push(schema.description);\n\tif (isObject(schema.properties)) {\n\t\tfor (const [name, property] of Object.entries(schema.properties)) {\n\t\t\tparts.push(name);\n\t\t\tschemaText(property, parts);\n\t\t}\n\t}\n\tschemaText(schema.items, parts);\n\tfor (const key of [\"anyOf\", \"oneOf\", \"allOf\"]) {\n\t\tconst variants = schema[key];\n\t\tif (Array.isArray(variants)) for (const variant of variants) schemaText(variant, parts);\n\t}\n}\n\n/**\n * Search text of a tool: the description and the schema descriptions and property names, and\n * separately the namespace name, description, and instructions. The ranker reads the name from `name`.\n */\nexport function createToolSearchDocument(\n\ttool: Pick<ToolInfo, \"name\" | \"description\" | \"parameters\">,\n\tnamespace?: ToolNamespace,\n): ToolSearchDocument {\n\tconst parts = [tool.description];\n\tschemaText(tool.parameters, parts);\n\tconst namespaceText = namespace\n\t\t? [namespace.name, namespace.description ?? \"\", namespace.instructions ?? \"\"].join(\" \")\n\t\t: \"\";\n\treturn { name: tool.name, text: parts.filter((part) => part.trim()).join(\" \"), namespaceText };\n}\n\n/** Lowercase with characters invalid in script identifiers as `_`, so `dev-radius` matches `dev_radius`. */\nfunction normalizeName(name: string): string {\n\treturn name\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_$]/g, \"_\");\n}\n\n/**\n * Whether the whole query is the tool's name: its full name or a suffix after a `__` separator, so\n * `thread_read` and `app__thread_read` both name `mcp__app__thread_read`.\n */\nfunction isExactNameQuery(query: string, name: string): boolean {\n\tconst normalized = normalizeName(name);\n\treturn normalized === query || normalized.endsWith(`__${query}`);\n}\n\n/** A document split into the fields the ranker weighs differently. */\ninterface IndexedDocument {\n\tname: string;\n\t/** Terms of the name, for example `mcp`, `app`, `thread`, `read` for `mcp__app__thread_read`. */\n\tnameTerms: ReadonlySet<string>;\n\t/** Terms of the last `__` segment of the name, the part models say: `thread`, `read`. */\n\tlocalNameTerms: readonly string[];\n\ttextCounts: ReadonlyMap<string, number>;\n\ttextLength: number;\n\tnamespaceTerms: ReadonlySet<string>;\n}\n\nfunction indexDocument(document: ToolSearchDocument): IndexedDocument {\n\tconst textCounts = new Map<string, number>();\n\tfor (const term of tokenize(document.text)) textCounts.set(term, (textCounts.get(term) ?? 0) + 1);\n\tconst segments = document.name.split(\"__\");\n\treturn {\n\t\tname: document.name,\n\t\tnameTerms: new Set(tokenize(document.name)),\n\t\tlocalNameTerms: [...new Set(tokenize(segments[segments.length - 1]))],\n\t\ttextCounts,\n\t\ttextLength: [...textCounts.values()].reduce((sum, count) => sum + count, 0),\n\t\tnamespaceTerms: new Set(tokenize(document.namespaceText ?? \"\")),\n\t};\n}\n\n/**\n * A query term in the name counts this many times its IDF. The text part of a term is at most\n * `k1 + 1` (2.2) times its IDF and about 1 for a single mention, so a name match beats any number of\n * mentions in the description.\n */\nconst NAME_WEIGHT = 3;\n\n/**\n * A query term in the namespace name, description, or instructions counts this many times its IDF. They\n * are shared by every tool of the server, so they help find the server but not the tool in it.\n */\nconst NAMESPACE_WEIGHT = 0.5;\n\n/**\n * Okapi BM25 over the description, with the name and the namespace as separate fields:\n * - a tool that matches more of the query's terms, in any field, ranks above one that matches\n * fewer, whatever their scores: for `screenshot window`, a tool whose description has both words\n * beats `window`, whose name has one;\n * - a query term in the name scores more than any number of mentions in the description;\n * - a tool whose whole local name is in the query (`app` in `peekaboo app` for\n * `mcp__peekaboo__app`) gets a bonus worth one more match of every query term, so among tools\n * matching as many terms it mostly wins over tools that only mention the words;\n * - a query that is exactly a tool's name ranks that tool first, before coverage.\n *\n * The description alone is length-normalized, so a long name or long namespace instructions do\n * not lower a tool's score. Ties keep document order.\n */\nexport class Bm25Ranker implements ToolRanker {\n\tprivate readonly k1: number;\n\tprivate readonly b: number;\n\n\tconstructor(options: { k1?: number; b?: number } = {}) {\n\t\tthis.k1 = options.k1 ?? 1.2;\n\t\tthis.b = options.b ?? 0.75;\n\t}\n\n\trank(query: string, documents: readonly ToolSearchDocument[], limit: number): ToolSearchMatch[] {\n\t\tconst queryTerms = new Set(tokenize(query));\n\t\tif (queryTerms.size === 0 || documents.length === 0 || limit <= 0) return [];\n\t\tconst indexed = documents.map(indexDocument);\n\t\tconst averageLength = indexed.reduce((sum, document) => sum + document.textLength, 0) / indexed.length || 1;\n\t\tconst idf = new Map(\n\t\t\t[...queryTerms].map((term) => {\n\t\t\t\tconst frequency = indexed.filter(\n\t\t\t\t\t(document) =>\n\t\t\t\t\t\tdocument.nameTerms.has(term) || document.textCounts.has(term) || document.namespaceTerms.has(term),\n\t\t\t\t).length;\n\t\t\t\treturn [term, Math.log(1 + (indexed.length - frequency + 0.5) / (frequency + 0.5))] as const;\n\t\t\t}),\n\t\t);\n\t\tconst fullNameBonus = [...idf.values()].reduce((sum, value) => sum + value, 0);\n\t\tconst exactQuery = normalizeName(query);\n\t\tconst matches: (ToolSearchMatch & { covered: number; exact: boolean })[] = [];\n\t\tfor (const document of indexed) {\n\t\t\tconst norm = this.k1 * (1 - this.b + (this.b * document.textLength) / averageLength);\n\t\t\tlet score = 0;\n\t\t\tlet covered = 0;\n\t\t\tfor (const term of queryTerms) {\n\t\t\t\tconst count = document.textCounts.get(term) ?? 0;\n\t\t\t\tconst weight =\n\t\t\t\t\t(document.nameTerms.has(term) ? NAME_WEIGHT : 0) +\n\t\t\t\t\t(document.namespaceTerms.has(term) ? NAMESPACE_WEIGHT : 0) +\n\t\t\t\t\t(count * (this.k1 + 1)) / (count + norm);\n\t\t\t\tif (weight > 0) covered++;\n\t\t\t\tscore += (idf.get(term) ?? 0) * weight;\n\t\t\t}\n\t\t\tif (score === 0) continue;\n\t\t\tconst local = document.localNameTerms;\n\t\t\tif (local.length > 0 && local.every((term) => queryTerms.has(term))) score += fullNameBonus;\n\t\t\tmatches.push({ name: document.name, score, covered, exact: isExactNameQuery(exactQuery, document.name) });\n\t\t}\n\t\treturn matches\n\t\t\t.sort((a, b) => Number(b.exact) - Number(a.exact) || b.covered - a.covered || b.score - a.score)\n\t\t\t.slice(0, limit)\n\t\t\t.map(({ name, score }) => ({ name, score }));\n\t}\n}\n\nexport const toolSearchSchema = Type.Object({\n\tquery: Type.String({ description: \"Search query for deferred tools.\" }),\n\tlimit: Type.Optional(\n\t\tType.Number({ description: `Maximum number of tools to return. Defaults to ${DEFAULT_TOOL_SEARCH_LIMIT}.` }),\n\t),\n});\n\nexport type ToolSearchInput = Static<typeof toolSearchSchema>;\n\nexport interface ToolSearchResultTool {\n\tname: string;\n\tdescription: string;\n}\n\nexport interface ToolSearchToolDetails {\n\t/** Tools loaded by this call. */\n\tloaded: string[];\n}\n\nexport interface ToolSearchToolOptions {\n\t/**\n\t * The session's tools. `tool_search` searches the tools that are not declared to the model and\n\t * activates the matches. Without it, the tool finds nothing. An `ExtensionAPI` fits.\n\t */\n\ttools?: Pick<ExtensionAPI, \"getAllTools\" | \"getActiveTools\" | \"setActiveTools\">;\n}\n\n/** Whether `tool_search` can load a tool with this exposure. */\nfunction isSearchable(exposure: ToolExposure): boolean {\n\treturn exposure === \"codemode\" || exposure === \"deferred\";\n}\n\n/**\n * Rank the searchable tools that are not active yet and activate the matches, so the next model\n * call declares them. Activation is recorded in the transcript like any tool change.\n */\nfunction searchAndLoad(\n\ttools: NonNullable<ToolSearchToolOptions[\"tools\"]>,\n\tquery: string,\n\tlimit: number,\n): ToolSearchResultTool[] {\n\tconst active = tools.getActiveTools();\n\tconst candidates = tools.getAllTools().filter((tool) => isSearchable(tool.exposure) && !active.includes(tool.name));\n\tconst documents = candidates.map((tool) => createToolSearchDocument(tool, tool.namespace));\n\tconst matches = new Bm25Ranker().rank(query, documents, limit);\n\tif (matches.length > 0) tools.setActiveTools([...active, ...matches.map((match) => match.name)]);\n\treturn matches.map((match) => ({\n\t\tname: match.name,\n\t\tdescription: candidates.find((tool) => tool.name === match.name)?.description ?? \"\",\n\t}));\n}\n\n/**\n * The `tool_search` description. It does not list the searchable tools or their namespaces, so it\n * stays the same while tools are registered, for example when MCP servers connect.\n */\nexport const TOOL_SEARCH_DESCRIPTION = `# Tool discovery\\n\\nSearches over deferred tool metadata with BM25 and exposes matching tools for the next model call.\\n\\nSome of the tools, such as tools of MCP servers, may not have been provided to you upfront, and you should use this tool (\\`${TOOL_SEARCH_TOOL_NAME}\\`) to search for the required tools. For MCP tool discovery, always use \\`${TOOL_SEARCH_TOOL_NAME}\\`.`;\n\nexport function createToolSearchToolDefinition(\n\toptions: ToolSearchToolOptions = {},\n): ToolDefinition<typeof toolSearchSchema, ToolSearchToolDetails> {\n\treturn {\n\t\tname: TOOL_SEARCH_TOOL_NAME,\n\t\tlabel: TOOL_SEARCH_TOOL_NAME,\n\t\tdescription: TOOL_SEARCH_DESCRIPTION,\n\t\tpromptSnippet: \"Search for tools that are not loaded yet and load the matches\",\n\t\tparameters: toolSearchSchema,\n\t\t// Searching is not something scripts need; it changes what the model sees.\n\t\texposure: \"model-only\",\n\t\t// A query can match any tool that is not declared yet.\n\t\treachesTools: () => \"all\",\n\t\tasync execute(_toolCallId, { query, limit }) {\n\t\t\tif (query.trim() === \"\") throw new Error(\"query must not be empty\");\n\t\t\tconst max = limit ?? DEFAULT_TOOL_SEARCH_LIMIT;\n\t\t\tif (!Number.isInteger(max) || max <= 0) throw new Error(\"limit must be a positive integer\");\n\t\t\tconst tools = options.tools ? searchAndLoad(options.tools, query, max) : [];\n\t\t\tconst text =\n\t\t\t\ttools.length === 0\n\t\t\t\t\t? \"No matching tools found.\"\n\t\t\t\t\t: `Loaded ${tools.length} tool${tools.length === 1 ? \"\" : \"s\"}. They are available from your next call:\\n${tools\n\t\t\t\t\t\t\t.map((tool) => `- ${tool.name}: ${tool.description.trim().split(/\\r?\\n/)[0]}`)\n\t\t\t\t\t\t\t.join(\"\\n\")}`;\n\t\t\treturn { content: [{ type: \"text\", text }], details: { loaded: tools.map((tool) => tool.name) } };\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../src/extensions/tool-search/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAS5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAqB3C,MAAM,aAAa,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAE7E,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IAC/C,GAAG;IACH,IAAI;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,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAC5F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5E,MAAM,IAAI,GACT,KAAK,CAAC,MAAM,KAAK,CAAC;gBACjB,CAAC,CAAC,0BAA0B;gBAC5B,CAAC,CAAC,UAAU,KAAK,CAAC,MAAM,QAAQ,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,8CAA8C,KAAK;qBAC7G,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;qBAC7E,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACnG,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tool discovery: a BM25 ranker over tool metadata, shared by `searchTools()` in codemode scripts and\n * the optional `tool_search` tool.\n *\n * `tool_search` searches tools that are not declared to\n * the model (`codemode` and `deferred` exposure) and loads the matches, so they are declared for the\n * next model call. Loading goes through the active tool set, so it is recorded in the transcript\n * like any other tool change and survives `/tree`, resume, and fork on that branch.\n */\n\nimport { resolveSchemaRef } from \"@earendil-works/pi-codemode/declarations\";\nimport { type Static, Type } from \"typebox\";\nimport type {\n\tExtensionAPI,\n\tToolDefinition,\n\tToolExposure,\n\tToolInfo,\n\tToolNamespace,\n} from \"../../core/extensions/types.ts\";\n\nexport const TOOL_SEARCH_TOOL_NAME = \"tool_search\";\nexport const DEFAULT_TOOL_SEARCH_LIMIT = 8;\n\n/** A tool as the ranker sees it: its name and the texts built by {@link createToolSearchDocument}. */\nexport interface ToolSearchDocument {\n\tname: string;\n\t/** Description, schema descriptions, and property names. */\n\ttext: string;\n\t/** Name, description, and instructions of the tool's namespace. */\n\tnamespaceText?: string;\n}\n\nexport interface ToolSearchMatch {\n\tname: string;\n\tscore: number;\n}\n\n/** Ranks tools for a query. BM25 today; a hybrid ranker with embeddings can replace it. */\nexport interface ToolRanker {\n\trank(query: string, documents: readonly ToolSearchDocument[], limit: number): ToolSearchMatch[];\n}\n\nconst wordSegmenter = new Intl.Segmenter(undefined, { granularity: \"word\" });\n\nconst STOP_WORDS: ReadonlySet<string> = new Set([\n\t\"a\",\n\t\"an\",\n\t\"and\",\n\t\"are\",\n\t\"as\",\n\t\"at\",\n\t\"be\",\n\t\"by\",\n\t\"for\",\n\t\"from\",\n\t\"in\",\n\t\"is\",\n\t\"it\",\n\t\"of\",\n\t\"on\",\n\t\"or\",\n\t\"that\",\n\t\"the\",\n\t\"this\",\n\t\"to\",\n\t\"with\",\n]);\n\n/** Naive singular form, so `issues` matches `issue` and `searches` matches `search`. */\nfunction stem(term: string): string {\n\tif (term.length > 4 && term.endsWith(\"ies\")) return `${term.slice(0, -3)}y`;\n\tif (term.length > 4 && /(ches|shes|sses|xes|zes)$/.test(term)) return term.slice(0, -2);\n\tif (term.length > 3 && term.endsWith(\"s\") && !term.endsWith(\"ss\")) return term.slice(0, -1);\n\treturn term;\n}\n\n/** Unicode word segmentation with identifier boundaries and English stop words/singular forms. */\nexport function tokenize(text: string): string[] {\n\tconst normalized = text\n\t\t.normalize(\"NFC\")\n\t\t.replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n\t\t.replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n\t\t.toLowerCase()\n\t\t.replace(/[^\\p{L}\\p{M}\\p{N}]+/gu, \" \");\n\t// The segmenter costs about 15 times a split. Plain ASCII splits into the same words at spaces, so only other\n\t// text, such as Chinese written without spaces, goes through it.\n\tconst words = /^[a-z0-9 ]*$/.test(normalized)\n\t\t? normalized.split(\" \")\n\t\t: Array.from(wordSegmenter.segment(normalized), (segment) => (segment.isWordLike ? segment.segment : \"\"));\n\treturn words\n\t\t.filter((word) => word.length > 0 && !STOP_WORDS.has(word))\n\t\t.map((word) => (/^[a-z0-9]+$/.test(word) ? stem(word) : word));\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Schema descriptions and property names, recursively, following local `$ref`s into `root`. `seen` holds the\n * subschemas already reached through a reference, so recursive and shared definitions are read once, and\n * definitions no property references are not read.\n */\nfunction schemaText(schema: unknown, root: unknown, parts: string[], seen: Set<unknown>): void {\n\tif (!isObject(schema)) return;\n\tif (typeof schema.$ref === \"string\") {\n\t\tconst target = resolveSchemaRef(schema.$ref, root);\n\t\tif (isObject(target) && !seen.has(target)) {\n\t\t\tseen.add(target);\n\t\t\tschemaText(target, root, parts, seen);\n\t\t}\n\t}\n\tif (typeof schema.description === \"string\") parts.push(schema.description);\n\tif (isObject(schema.properties)) {\n\t\tfor (const [name, property] of Object.entries(schema.properties)) {\n\t\t\tparts.push(name);\n\t\t\tschemaText(property, root, parts, seen);\n\t\t}\n\t}\n\tschemaText(schema.items, root, parts, seen);\n\tfor (const key of [\"anyOf\", \"oneOf\", \"allOf\"]) {\n\t\tconst variants = schema[key];\n\t\tif (Array.isArray(variants)) for (const variant of variants) schemaText(variant, root, parts, seen);\n\t}\n}\n\n/**\n * Search text of a tool: the description and the schema descriptions and property names, and\n * separately the namespace name, description, and instructions. The ranker reads the name from `name`.\n */\nexport function createToolSearchDocument(\n\ttool: Pick<ToolInfo, \"name\" | \"description\" | \"parameters\">,\n\tnamespace?: ToolNamespace,\n): ToolSearchDocument {\n\tconst parts = [tool.description];\n\tschemaText(tool.parameters, tool.parameters, parts, new Set([tool.parameters]));\n\tconst namespaceText = namespace\n\t\t? [namespace.name, namespace.description ?? \"\", namespace.instructions ?? \"\"].join(\" \")\n\t\t: \"\";\n\treturn { name: tool.name, text: parts.filter((part) => part.trim()).join(\" \"), namespaceText };\n}\n\n/** Lowercase with characters invalid in script identifiers as `_`, so `dev-radius` matches `dev_radius`. */\nfunction normalizeName(name: string): string {\n\treturn name\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9_$]/g, \"_\");\n}\n\n/**\n * Whether the whole query is the tool's name: its full name or a suffix after a `__` separator, so\n * `thread_read` and `app__thread_read` both name `mcp__app__thread_read`.\n */\nfunction isExactNameQuery(query: string, name: string): boolean {\n\tconst normalized = normalizeName(name);\n\treturn normalized === query || normalized.endsWith(`__${query}`);\n}\n\n/** A document split into the fields the ranker weighs differently. */\ninterface IndexedDocument {\n\tname: string;\n\t/** Terms of the name, for example `mcp`, `app`, `thread`, `read` for `mcp__app__thread_read`. */\n\tnameTerms: ReadonlySet<string>;\n\t/** Terms of the last `__` segment of the name, the part models say: `thread`, `read`. */\n\tlocalNameTerms: readonly string[];\n\ttextCounts: ReadonlyMap<string, number>;\n\ttextLength: number;\n\tnamespaceTerms: ReadonlySet<string>;\n}\n\nfunction indexDocument(document: ToolSearchDocument): IndexedDocument {\n\tconst textCounts = new Map<string, number>();\n\tfor (const term of tokenize(document.text)) textCounts.set(term, (textCounts.get(term) ?? 0) + 1);\n\tconst segments = document.name.split(\"__\");\n\treturn {\n\t\tname: document.name,\n\t\tnameTerms: new Set(tokenize(document.name)),\n\t\tlocalNameTerms: [...new Set(tokenize(segments[segments.length - 1]))],\n\t\ttextCounts,\n\t\ttextLength: [...textCounts.values()].reduce((sum, count) => sum + count, 0),\n\t\tnamespaceTerms: new Set(tokenize(document.namespaceText ?? \"\")),\n\t};\n}\n\n/**\n * A query term in the name counts this many times its IDF. The text part of a term is at most\n * `k1 + 1` (2.2) times its IDF and about 1 for a single mention, so a name match beats any number of\n * mentions in the description.\n */\nconst NAME_WEIGHT = 3;\n\n/**\n * A query term in the namespace name, description, or instructions counts this many times its IDF. They\n * are shared by every tool of the server, so they help find the server but not the tool in it.\n */\nconst NAMESPACE_WEIGHT = 0.5;\n\n/**\n * Okapi BM25 over the description, with the name and the namespace as separate fields:\n * - a tool that matches more of the query's terms, in any field, ranks above one that matches\n * fewer, whatever their scores: for `screenshot window`, a tool whose description has both words\n * beats `window`, whose name has one;\n * - a query term in the name scores more than any number of mentions in the description;\n * - a tool whose whole local name is in the query (`app` in `peekaboo app` for\n * `mcp__peekaboo__app`) gets a bonus worth one more match of every query term, so among tools\n * matching as many terms it mostly wins over tools that only mention the words;\n * - a query that is exactly a tool's name ranks that tool first, before coverage.\n *\n * The description alone is length-normalized, so a long name or long namespace instructions do\n * not lower a tool's score. Ties keep document order.\n */\nexport class Bm25Ranker implements ToolRanker {\n\tprivate readonly k1: number;\n\tprivate readonly b: number;\n\n\tconstructor(options: { k1?: number; b?: number } = {}) {\n\t\tthis.k1 = options.k1 ?? 1.2;\n\t\tthis.b = options.b ?? 0.75;\n\t}\n\n\trank(query: string, documents: readonly ToolSearchDocument[], limit: number): ToolSearchMatch[] {\n\t\tconst queryTerms = new Set(tokenize(query));\n\t\tif (queryTerms.size === 0 || documents.length === 0 || limit <= 0) return [];\n\t\tconst indexed = documents.map(indexDocument);\n\t\tconst averageLength = indexed.reduce((sum, document) => sum + document.textLength, 0) / indexed.length || 1;\n\t\tconst idf = new Map(\n\t\t\t[...queryTerms].map((term) => {\n\t\t\t\tconst frequency = indexed.filter(\n\t\t\t\t\t(document) =>\n\t\t\t\t\t\tdocument.nameTerms.has(term) || document.textCounts.has(term) || document.namespaceTerms.has(term),\n\t\t\t\t).length;\n\t\t\t\treturn [term, Math.log(1 + (indexed.length - frequency + 0.5) / (frequency + 0.5))] as const;\n\t\t\t}),\n\t\t);\n\t\tconst fullNameBonus = [...idf.values()].reduce((sum, value) => sum + value, 0);\n\t\tconst exactQuery = normalizeName(query);\n\t\tconst matches: (ToolSearchMatch & { covered: number; exact: boolean })[] = [];\n\t\tfor (const document of indexed) {\n\t\t\tconst norm = this.k1 * (1 - this.b + (this.b * document.textLength) / averageLength);\n\t\t\tlet score = 0;\n\t\t\tlet covered = 0;\n\t\t\tfor (const term of queryTerms) {\n\t\t\t\tconst count = document.textCounts.get(term) ?? 0;\n\t\t\t\tconst weight =\n\t\t\t\t\t(document.nameTerms.has(term) ? NAME_WEIGHT : 0) +\n\t\t\t\t\t(document.namespaceTerms.has(term) ? NAMESPACE_WEIGHT : 0) +\n\t\t\t\t\t(count * (this.k1 + 1)) / (count + norm);\n\t\t\t\tif (weight > 0) covered++;\n\t\t\t\tscore += (idf.get(term) ?? 0) * weight;\n\t\t\t}\n\t\t\tif (score === 0) continue;\n\t\t\tconst local = document.localNameTerms;\n\t\t\tif (local.length > 0 && local.every((term) => queryTerms.has(term))) score += fullNameBonus;\n\t\t\tmatches.push({ name: document.name, score, covered, exact: isExactNameQuery(exactQuery, document.name) });\n\t\t}\n\t\treturn matches\n\t\t\t.sort((a, b) => Number(b.exact) - Number(a.exact) || b.covered - a.covered || b.score - a.score)\n\t\t\t.slice(0, limit)\n\t\t\t.map(({ name, score }) => ({ name, score }));\n\t}\n}\n\nexport const toolSearchSchema = Type.Object({\n\tquery: Type.String({ description: \"Search query for deferred tools.\" }),\n\tlimit: Type.Optional(\n\t\tType.Number({ description: `Maximum number of tools to return. Defaults to ${DEFAULT_TOOL_SEARCH_LIMIT}.` }),\n\t),\n});\n\nexport type ToolSearchInput = Static<typeof toolSearchSchema>;\n\nexport interface ToolSearchResultTool {\n\tname: string;\n\tdescription: string;\n}\n\nexport interface ToolSearchToolDetails {\n\t/** Tools loaded by this call. */\n\tloaded: string[];\n}\n\nexport interface ToolSearchToolOptions {\n\t/**\n\t * The session's tools. `tool_search` searches the tools that are not declared to the model and\n\t * activates the matches. Without it, the tool finds nothing. An `ExtensionAPI` fits.\n\t */\n\ttools?: Pick<ExtensionAPI, \"getAllTools\" | \"getActiveTools\" | \"setActiveTools\">;\n}\n\n/** Whether `tool_search` can load a tool with this exposure. */\nfunction isSearchable(exposure: ToolExposure): boolean {\n\treturn exposure === \"codemode\" || exposure === \"deferred\";\n}\n\n/**\n * Rank the searchable tools that are not active yet and activate the matches, so the next model\n * call declares them. Activation is recorded in the transcript like any tool change.\n */\nfunction searchAndLoad(\n\ttools: NonNullable<ToolSearchToolOptions[\"tools\"]>,\n\tquery: string,\n\tlimit: number,\n): ToolSearchResultTool[] {\n\tconst active = tools.getActiveTools();\n\tconst candidates = tools.getAllTools().filter((tool) => isSearchable(tool.exposure) && !active.includes(tool.name));\n\tconst documents = candidates.map((tool) => createToolSearchDocument(tool, tool.namespace));\n\tconst matches = new Bm25Ranker().rank(query, documents, limit);\n\tif (matches.length > 0) tools.setActiveTools([...active, ...matches.map((match) => match.name)]);\n\treturn matches.map((match) => ({\n\t\tname: match.name,\n\t\tdescription: candidates.find((tool) => tool.name === match.name)?.description ?? \"\",\n\t}));\n}\n\n/**\n * The `tool_search` description. It does not list the searchable tools or their namespaces, so it\n * stays the same while tools are registered, for example when MCP servers connect.\n */\nexport const TOOL_SEARCH_DESCRIPTION = `# Tool discovery\\n\\nSearches over deferred tool metadata with BM25 and exposes matching tools for the next model call.\\n\\nSome of the tools, such as tools of MCP servers, may not have been provided to you upfront, and you should use this tool (\\`${TOOL_SEARCH_TOOL_NAME}\\`) to search for the required tools. For MCP tool discovery, always use \\`${TOOL_SEARCH_TOOL_NAME}\\`.`;\n\nexport function createToolSearchToolDefinition(\n\toptions: ToolSearchToolOptions = {},\n): ToolDefinition<typeof toolSearchSchema, ToolSearchToolDetails> {\n\treturn {\n\t\tname: TOOL_SEARCH_TOOL_NAME,\n\t\tlabel: TOOL_SEARCH_TOOL_NAME,\n\t\tdescription: TOOL_SEARCH_DESCRIPTION,\n\t\tpromptSnippet: \"Search for tools that are not loaded yet and load the matches\",\n\t\tparameters: toolSearchSchema,\n\t\t// Searching is not something scripts need; it changes what the model sees.\n\t\texposure: \"model-only\",\n\t\t// A query can match any tool that is not declared yet.\n\t\treachesTools: () => \"all\",\n\t\tasync execute(_toolCallId, { query, limit }) {\n\t\t\tif (query.trim() === \"\") throw new Error(\"query must not be empty\");\n\t\t\tconst max = limit ?? DEFAULT_TOOL_SEARCH_LIMIT;\n\t\t\tif (!Number.isInteger(max) || max <= 0) throw new Error(\"limit must be a positive integer\");\n\t\t\tconst tools = options.tools ? searchAndLoad(options.tools, query, max) : [];\n\t\t\tconst text =\n\t\t\t\ttools.length === 0\n\t\t\t\t\t? \"No matching tools found.\"\n\t\t\t\t\t: `Loaded ${tools.length} tool${tools.length === 1 ? \"\" : \"s\"}. They are available from your next call:\\n${tools\n\t\t\t\t\t\t\t.map((tool) => `- ${tool.name}: ${tool.description.trim().split(/\\r?\\n/)[0]}`)\n\t\t\t\t\t\t\t.join(\"\\n\")}`;\n\t\t\treturn { content: [{ type: \"text\", text }], details: { loaded: tools.map((tool) => tool.name) } };\n\t\t},\n\t};\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { readStoredCredential } from "./core/auth-storage.ts";
5
5
  export type { CacheWarmingDecision, CacheWarmingStatus } from "./core/cache-warmer.ts";
6
6
  export { type BranchPreparation, type BranchSummaryResult, type CollectEntriesResult, type CompactionResult, type CutPointResult, calculateContextTokens, collectEntriesForBranchSummary, compact, DEFAULT_COMPACTION_SETTINGS, estimateTokens, type FileOperations, findCutPoint, findTurnStartIndex, type GenerateBranchSummaryOptions, generateBranchSummary, generateSummary, generateSummaryWithUsage, getLastAssistantUsage, prepareBranchEntries, serializeConversation, shouldCompact, } from "./core/compaction/index.ts";
7
7
  export { createEventBus, type EventBus, type EventBusController } from "./core/event-bus.ts";
8
- export type { AfterProviderResponseEvent, AgentActivityOutcome, AgentBeforeSettleEvent, AgentBeforeSettleEventResult, AgentEndEvent, AgentSettledEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BeforeAgentStartCustomEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeAgentStartUserEvent, BeforeProviderHeadersEvent, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BoundaryContextPreview, BoundaryResult, BoundaryState, BuildSystemPromptOptions, CacheWarmingDecisionEvent, CacheWarmingDecisionEventResult, CompactionEntryDraft, CompactOptions, ContextEditEntryDraft, ContextEvent, ContextEventResult, ContextUsage, ContextWithSystemEvent, CustomEntryDraft, CustomMessageEntryDraft, CustomToolCallEvent, EditToolCallEvent, EntryRenderer, EntryRenderOptions, ExecOptions, ExecResult, ExecuteToolOptions, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionToolContext, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionVirtualModel, ExtensionWidgetOptions, FindToolCallEvent, GrepToolCallEvent, InlineExtension, InputEvent, InputEventResult, InputSource, KeybindingHints, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, MarkdownTransformContext, MarkdownTransformer, McpServersChangeEvent, MessageEndEvent, MessageEndEventResult, MessageRenderer, MessageRenderOptions, MessageStartEvent, MessageUpdateEvent, ModelSelectEvent, ModelSelectSource, NormalizedBuildSystemPromptOptions, PowerShellToolCallEvent, ProjectTrustContext, ProjectTrustEvent, ProjectTrustEventDecision, ProjectTrustEventResult, ProjectTrustHandler, ProviderConfig, ProviderModelConfig, ProviderStreamEvent, ReadToolCallEvent, RegisteredCommand, RegisteredTool, ResolvedCommand, ResourcesDiscoverEvent, ResourcesDiscoverResult, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeForkEvent, SessionBeforeForkResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionBoundaryDraft, SessionCompactEvent, SessionCompactFailedEvent, SessionInfoChangedEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SlashCommandInfo, SlashCommandSource, SourceInfo, TerminalInputHandler, ThinkingLevelSelectEvent, ToolAnnotations, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionEndEvent, ToolExecutionMode, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolExposure, ToolInfo, ToolLoadout, ToolLoadoutChanges, ToolNamespace, ToolRendererResolver, ToolRenderers, ToolRenderResultOptions, ToolResultEvent, ToolResultEventResult, TurnEndEvent, TurnEndEventResult, TurnStartEvent, UIPromptEndEvent, UIPromptKind, UIPromptStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, } from "./core/extensions/index.ts";
8
+ export type { AfterProviderResponseEvent, AgentActivityOutcome, AgentBeforeSettleEvent, AgentBeforeSettleEventResult, AgentEndEvent, AgentSettledEvent, AgentStartEvent, AgentToolResult, AgentToolUpdateCallback, AppKeybinding, AutocompleteProviderFactory, BashToolCallEvent, BeforeAgentStartCustomEvent, BeforeAgentStartEvent, BeforeAgentStartEventResult, BeforeAgentStartUserEvent, BeforeProviderHeadersEvent, BeforeProviderRequestEvent, BeforeProviderRequestEventResult, BoundaryContextPreview, BoundaryResult, BoundaryState, BuildSystemPromptOptions, CacheWarmingDecisionEvent, CacheWarmingDecisionEventResult, CompactionEntryDraft, CompactOptions, ContextEditEntryDraft, ContextEvent, ContextEventResult, ContextUsage, ContextWithSystemEvent, CustomEntryDraft, CustomMessageEntryDraft, CustomToolCallEvent, EditToolCallEvent, EntryRenderer, EntryRenderOptions, ExecOptions, ExecResult, ExecuteToolOptions, Extension, ExtensionActions, ExtensionAPI, ExtensionCommandContext, ExtensionCommandContextActions, ExtensionContext, ExtensionContextActions, ExtensionError, ExtensionEvent, ExtensionFactory, ExtensionFlag, ExtensionHandler, ExtensionRuntime, ExtensionShortcut, ExtensionToolContext, ExtensionUIContext, ExtensionUIDialogOptions, ExtensionVirtualModel, ExtensionWidgetOptions, FindToolCallEvent, GrepToolCallEvent, InlineExtension, InputEvent, InputEventResult, InputSource, KeybindingHints, KeybindingsManager, LoadExtensionsResult, LsToolCallEvent, MarkdownMessageType, MarkdownTransformContext, MarkdownTransformer, MarkdownTransformerOptions, MarkdownTransformerRegistration, McpServersChangeEvent, MessageEndEvent, MessageEndEventResult, MessageRenderer, MessageRenderOptions, MessageStartEvent, MessageUpdateEvent, ModelSelectEvent, ModelSelectSource, NormalizedBuildSystemPromptOptions, PowerShellToolCallEvent, ProjectTrustContext, ProjectTrustEvent, ProjectTrustEventDecision, ProjectTrustEventResult, ProjectTrustHandler, ProviderConfig, ProviderModelConfig, ProviderStreamEvent, ReadToolCallEvent, RegisteredCommand, RegisteredTool, ResolvedCommand, ResourcesDiscoverEvent, ResourcesDiscoverResult, SessionBeforeCompactEvent, SessionBeforeCompactResult, SessionBeforeForkEvent, SessionBeforeForkResult, SessionBeforeSwitchEvent, SessionBeforeSwitchResult, SessionBeforeTreeEvent, SessionBeforeTreeResult, SessionBoundaryDraft, SessionCompactEvent, SessionCompactFailedEvent, SessionInfoChangedEvent, SessionShutdownEvent, SessionStartEvent, SessionTreeEvent, SlashCommandInfo, SlashCommandSource, SourceInfo, TerminalInputHandler, ThinkingLevelSelectEvent, ToolAnnotations, ToolCallEvent, ToolCallEventResult, ToolDefinition, ToolExecutionEndEvent, ToolExecutionMode, ToolExecutionStartEvent, ToolExecutionUpdateEvent, ToolExposure, ToolInfo, ToolLoadout, ToolLoadoutChanges, ToolNamespace, ToolRendererResolver, ToolRenderers, ToolRenderResultOptions, ToolResultEvent, ToolResultEventResult, TurnEndEvent, TurnEndEventResult, TurnStartEvent, UIPromptEndEvent, UIPromptKind, UIPromptStartEvent, UserBashEvent, UserBashEventResult, WidgetPlacement, WorkingIndicatorOptions, WriteToolCallEvent, } from "./core/extensions/index.ts";
9
9
  export { createExtensionRuntime, defineTool, discoverAndLoadExtensions, ExtensionRunner, isBashToolResult, isEditToolResult, isFindToolResult, isGrepToolResult, isLsToolResult, isReadToolResult, isToolCallEventType, isWriteToolResult, wrapRegisteredTool, wrapRegisteredTools, } from "./core/extensions/index.ts";
10
10
  export type { ReadonlyFooterDataProvider } from "./core/footer-data-provider.ts";
11
11
  export type { RegisteredMcpServer } from "./core/mcp-servers.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EACN,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,OAAO,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,eAAe,EACf,KAAK,YAAY,GACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvF,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,OAAO,EACP,2BAA2B,EAC3B,cAAc,EACd,KAAK,cAAc,EACnB,YAAY,EACZ,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,GACb,MAAM,4BAA4B,CAAC;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