@code-yeongyu/senpi 2026.7.17 → 2026.7.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (641) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +5 -2
  3. package/dist/cli/neo/build-argv.d.ts.map +1 -1
  4. package/dist/cli/neo/build-argv.js +2 -0
  5. package/dist/cli/neo/build-argv.js.map +1 -1
  6. package/dist/core/agent-session-services.d.ts.map +1 -1
  7. package/dist/core/agent-session-services.js +11 -4
  8. package/dist/core/agent-session-services.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +5 -0
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +27 -5
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/compaction/compaction.d.ts.map +1 -1
  14. package/dist/core/compaction/compaction.js +20 -4
  15. package/dist/core/compaction/compaction.js.map +1 -1
  16. package/dist/core/dynamic-prompt/build.d.ts +7 -0
  17. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  18. package/dist/core/dynamic-prompt/build.js +5 -0
  19. package/dist/core/dynamic-prompt/build.js.map +1 -1
  20. package/dist/core/dynamic-prompt/workstation.d.ts +35 -0
  21. package/dist/core/dynamic-prompt/workstation.d.ts.map +1 -0
  22. package/dist/core/dynamic-prompt/workstation.js +81 -0
  23. package/dist/core/dynamic-prompt/workstation.js.map +1 -0
  24. package/dist/core/extensions/builtin/compaction/index.d.ts.map +1 -1
  25. package/dist/core/extensions/builtin/compaction/index.js +46 -4
  26. package/dist/core/extensions/builtin/compaction/index.js.map +1 -1
  27. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts +1 -0
  28. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.d.ts.map +1 -1
  29. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js +20 -2
  30. package/dist/core/extensions/builtin/compaction/repair-tool-pairs.js.map +1 -1
  31. package/dist/core/extensions/builtin/compaction/speculative.d.ts +7 -1
  32. package/dist/core/extensions/builtin/compaction/speculative.d.ts.map +1 -1
  33. package/dist/core/extensions/builtin/compaction/speculative.js +29 -11
  34. package/dist/core/extensions/builtin/compaction/speculative.js.map +1 -1
  35. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts +9 -7
  36. package/dist/core/extensions/builtin/compaction/todo-bridge.d.ts.map +1 -1
  37. package/dist/core/extensions/builtin/compaction/todo-bridge.js +34 -9
  38. package/dist/core/extensions/builtin/compaction/todo-bridge.js.map +1 -1
  39. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts +1 -0
  40. package/dist/core/extensions/builtin/gpt-apply-patch/constants.d.ts.map +1 -1
  41. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js +5 -1
  42. package/dist/core/extensions/builtin/gpt-apply-patch/constants.js.map +1 -1
  43. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts +2 -1
  44. package/dist/core/extensions/builtin/gpt-apply-patch/extension.d.ts.map +1 -1
  45. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js +48 -29
  46. package/dist/core/extensions/builtin/gpt-apply-patch/extension.js.map +1 -1
  47. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts +2 -2
  48. package/dist/core/extensions/builtin/gpt-apply-patch/index.d.ts.map +1 -1
  49. package/dist/core/extensions/builtin/gpt-apply-patch/index.js +2 -2
  50. package/dist/core/extensions/builtin/gpt-apply-patch/index.js.map +1 -1
  51. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts +1 -1
  52. package/dist/core/extensions/builtin/gpt-apply-patch/tool.d.ts.map +1 -1
  53. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js +5 -3
  54. package/dist/core/extensions/builtin/gpt-apply-patch/tool.js.map +1 -1
  55. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts +7 -6
  56. package/dist/core/extensions/builtin/gpt-apply-patch/types.d.ts.map +1 -1
  57. package/dist/core/extensions/builtin/gpt-apply-patch/types.js.map +1 -1
  58. package/dist/core/extensions/builtin/hooks/matcher.d.ts.map +1 -1
  59. package/dist/core/extensions/builtin/hooks/matcher.js +1 -0
  60. package/dist/core/extensions/builtin/hooks/matcher.js.map +1 -1
  61. package/dist/core/extensions/builtin/index.d.ts.map +1 -1
  62. package/dist/core/extensions/builtin/index.js +2 -0
  63. package/dist/core/extensions/builtin/index.js.map +1 -1
  64. package/dist/core/extensions/builtin/mcp/config-schema.d.ts +8 -1
  65. package/dist/core/extensions/builtin/mcp/config-schema.d.ts.map +1 -1
  66. package/dist/core/extensions/builtin/mcp/config-schema.js +23 -0
  67. package/dist/core/extensions/builtin/mcp/config-schema.js.map +1 -1
  68. package/dist/core/extensions/builtin/mcp/config.d.ts +13 -0
  69. package/dist/core/extensions/builtin/mcp/config.d.ts.map +1 -1
  70. package/dist/core/extensions/builtin/mcp/config.js +36 -0
  71. package/dist/core/extensions/builtin/mcp/config.js.map +1 -1
  72. package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +1 -1
  73. package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
  74. package/dist/core/extensions/builtin/mcp/expose/native-search.js +1 -1
  75. package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
  76. package/dist/core/extensions/builtin/mcp/expose/policy.js +1 -1
  77. package/dist/core/extensions/builtin/mcp/expose/policy.js.map +1 -1
  78. package/dist/core/extensions/builtin/mcp/expose/status.js +1 -1
  79. package/dist/core/extensions/builtin/mcp/expose/status.js.map +1 -1
  80. package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +3 -3
  81. package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/mcp/expose/tier-b.js +10 -10
  83. package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
  84. package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +3 -3
  85. package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +1 -1
  86. package/dist/core/extensions/builtin/mcp/expose/tool-search.js +14 -14
  87. package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +1 -1
  88. package/dist/core/extensions/builtin/mcp/index.js +5 -5
  89. package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
  90. package/dist/core/extensions/builtin/mcp/service-snapshot.d.ts.map +1 -1
  91. package/dist/core/extensions/builtin/mcp/service-snapshot.js +1 -0
  92. package/dist/core/extensions/builtin/mcp/service-snapshot.js.map +1 -1
  93. package/dist/core/extensions/builtin/mcp/service-types.d.ts +12 -0
  94. package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
  95. package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
  96. package/dist/core/extensions/builtin/mcp/service.d.ts +2 -2
  97. package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
  98. package/dist/core/extensions/builtin/mcp/service.js +4 -3
  99. package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
  100. package/dist/core/extensions/builtin/mcp/status.js +1 -0
  101. package/dist/core/extensions/builtin/mcp/status.js.map +1 -1
  102. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
  103. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +5 -1
  104. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
  105. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
  106. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +5 -1
  107. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
  108. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
  109. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +5 -1
  110. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
  111. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
  112. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +5 -1
  113. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
  114. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
  115. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +5 -1
  116. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
  117. package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js +2 -2
  118. package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js.map +1 -1
  119. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +1 -1
  120. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
  121. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +1 -1
  122. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
  123. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +1 -1
  124. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
  125. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +3 -3
  126. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
  127. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +3 -3
  128. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  129. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +1 -1
  130. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
  131. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts +3 -0
  132. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.d.ts.map +1 -0
  133. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js +80 -0
  134. package/dist/core/extensions/builtin/prompt-preset/grok-4.5.js.map +1 -0
  135. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +1 -1
  136. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
  137. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +1 -1
  138. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
  139. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -1
  140. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +5 -7
  141. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -1
  142. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  143. package/dist/core/extensions/builtin/prompt-preset/presets.js +14 -0
  144. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  145. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  146. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  147. package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
  148. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  149. package/dist/core/extensions/builtin/terminal/shared.d.ts +7 -0
  150. package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
  151. package/dist/core/extensions/builtin/terminal/shared.js +7 -0
  152. package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
  153. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
  154. package/dist/core/extensions/builtin/terminal/tools/bash.js +68 -6
  155. package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
  156. package/dist/core/extensions/builtin/todotools/commands.d.ts +18 -0
  157. package/dist/core/extensions/builtin/todotools/commands.d.ts.map +1 -0
  158. package/dist/core/extensions/builtin/todotools/commands.js +395 -0
  159. package/dist/core/extensions/builtin/todotools/commands.js.map +1 -0
  160. package/dist/core/extensions/builtin/todotools/index.d.ts +4 -1
  161. package/dist/core/extensions/builtin/todotools/index.d.ts.map +1 -1
  162. package/dist/core/extensions/builtin/todotools/index.js +17 -14
  163. package/dist/core/extensions/builtin/todotools/index.js.map +1 -1
  164. package/dist/core/extensions/builtin/todotools/markdown.d.ts +13 -0
  165. package/dist/core/extensions/builtin/todotools/markdown.d.ts.map +1 -0
  166. package/dist/core/extensions/builtin/todotools/markdown.js +82 -0
  167. package/dist/core/extensions/builtin/todotools/markdown.js.map +1 -0
  168. package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -1
  169. package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
  170. package/dist/core/extensions/builtin/todotools/prompt.js +50 -153
  171. package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
  172. package/dist/core/extensions/builtin/todotools/state.d.ts +67 -14
  173. package/dist/core/extensions/builtin/todotools/state.d.ts.map +1 -1
  174. package/dist/core/extensions/builtin/todotools/state.js +400 -35
  175. package/dist/core/extensions/builtin/todotools/state.js.map +1 -1
  176. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts +22 -0
  177. package/dist/core/extensions/builtin/todotools/tools/todo.d.ts.map +1 -0
  178. package/dist/core/extensions/builtin/todotools/tools/todo.js +229 -0
  179. package/dist/core/extensions/builtin/todotools/tools/todo.js.map +1 -0
  180. package/dist/core/extensions/builtin/video-in/index.d.ts +3 -0
  181. package/dist/core/extensions/builtin/video-in/index.d.ts.map +1 -0
  182. package/dist/core/extensions/builtin/video-in/index.js +111 -0
  183. package/dist/core/extensions/builtin/video-in/index.js.map +1 -0
  184. package/dist/core/extensions/builtin/websearch/index.d.ts.map +1 -1
  185. package/dist/core/extensions/builtin/websearch/index.js +20 -3
  186. package/dist/core/extensions/builtin/websearch/index.js.map +1 -1
  187. package/dist/core/extensions/index.d.ts +1 -0
  188. package/dist/core/extensions/index.d.ts.map +1 -1
  189. package/dist/core/extensions/index.js.map +1 -1
  190. package/dist/core/extensions/loader.d.ts +10 -1
  191. package/dist/core/extensions/loader.d.ts.map +1 -1
  192. package/dist/core/extensions/loader.js +64 -7
  193. package/dist/core/extensions/loader.js.map +1 -1
  194. package/dist/core/extensions/runner.d.ts +5 -2
  195. package/dist/core/extensions/runner.d.ts.map +1 -1
  196. package/dist/core/extensions/runner.js +49 -8
  197. package/dist/core/extensions/runner.js.map +1 -1
  198. package/dist/core/extensions/types.d.ts +49 -8
  199. package/dist/core/extensions/types.d.ts.map +1 -1
  200. package/dist/core/extensions/types.js.map +1 -1
  201. package/dist/core/model-registry.d.ts +5 -1
  202. package/dist/core/model-registry.d.ts.map +1 -1
  203. package/dist/core/model-registry.js +17 -2
  204. package/dist/core/model-registry.js.map +1 -1
  205. package/dist/core/model-runtime.d.ts +12 -1
  206. package/dist/core/model-runtime.d.ts.map +1 -1
  207. package/dist/core/model-runtime.js +51 -9
  208. package/dist/core/model-runtime.js.map +1 -1
  209. package/dist/core/prompt-templates.d.ts +1 -0
  210. package/dist/core/prompt-templates.d.ts.map +1 -1
  211. package/dist/core/prompt-templates.js +4 -4
  212. package/dist/core/prompt-templates.js.map +1 -1
  213. package/dist/core/provider-composer.d.ts +1 -1
  214. package/dist/core/provider-composer.d.ts.map +1 -1
  215. package/dist/core/provider-composer.js +8 -1
  216. package/dist/core/provider-composer.js.map +1 -1
  217. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  218. package/dist/core/remote-catalog-provider.js +16 -3
  219. package/dist/core/remote-catalog-provider.js.map +1 -1
  220. package/dist/core/resource-loader.d.ts +6 -0
  221. package/dist/core/resource-loader.d.ts.map +1 -1
  222. package/dist/core/resource-loader.js +27 -2
  223. package/dist/core/resource-loader.js.map +1 -1
  224. package/dist/core/settings-manager.d.ts +6 -0
  225. package/dist/core/settings-manager.d.ts.map +1 -1
  226. package/dist/core/settings-manager.js +20 -0
  227. package/dist/core/settings-manager.js.map +1 -1
  228. package/dist/core/tools/bash.d.ts.map +1 -1
  229. package/dist/core/tools/bash.js +20 -5
  230. package/dist/core/tools/bash.js.map +1 -1
  231. package/dist/core/tools/read.js +1 -1
  232. package/dist/core/tools/read.js.map +1 -1
  233. package/dist/extensions/index.d.ts +3 -0
  234. package/dist/extensions/index.d.ts.map +1 -0
  235. package/dist/extensions/index.js +3 -0
  236. package/dist/extensions/index.js.map +1 -0
  237. package/dist/extensions/llama/client.d.ts +61 -0
  238. package/dist/extensions/llama/client.d.ts.map +1 -0
  239. package/dist/extensions/llama/client.js +298 -0
  240. package/dist/extensions/llama/client.js.map +1 -0
  241. package/dist/extensions/llama/huggingface.d.ts +23 -0
  242. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  243. package/dist/extensions/llama/huggingface.js +139 -0
  244. package/dist/extensions/llama/huggingface.js.map +1 -0
  245. package/dist/extensions/llama/index.d.ts +3 -0
  246. package/dist/extensions/llama/index.d.ts.map +1 -0
  247. package/dist/extensions/llama/index.js +208 -0
  248. package/dist/extensions/llama/index.js.map +1 -0
  249. package/dist/extensions/llama/provider.d.ts +10 -0
  250. package/dist/extensions/llama/provider.d.ts.map +1 -0
  251. package/dist/extensions/llama/provider.js +106 -0
  252. package/dist/extensions/llama/provider.js.map +1 -0
  253. package/dist/extensions/llama/ui.d.ts +42 -0
  254. package/dist/extensions/llama/ui.d.ts.map +1 -0
  255. package/dist/extensions/llama/ui.js +400 -0
  256. package/dist/extensions/llama/ui.js.map +1 -0
  257. package/dist/index.d.ts +2 -2
  258. package/dist/index.d.ts.map +1 -1
  259. package/dist/index.js.map +1 -1
  260. package/dist/main.d.ts.map +1 -1
  261. package/dist/main.js +6 -4
  262. package/dist/main.js.map +1 -1
  263. package/dist/modes/interactive/components/assistant-message.d.ts +6 -7
  264. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  265. package/dist/modes/interactive/components/assistant-message.js +154 -114
  266. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  267. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  268. package/dist/modes/interactive/components/footer.js +4 -2
  269. package/dist/modes/interactive/components/footer.js.map +1 -1
  270. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  271. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  272. package/dist/modes/interactive/components/settings-selector.js +20 -0
  273. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  274. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  275. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  276. package/dist/modes/interactive/interactive-mode.js +87 -10
  277. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  278. package/dist/modes/interactive/streaming-reveal.d.ts +35 -0
  279. package/dist/modes/interactive/streaming-reveal.d.ts.map +1 -0
  280. package/dist/modes/interactive/streaming-reveal.js +268 -0
  281. package/dist/modes/interactive/streaming-reveal.js.map +1 -0
  282. package/dist/modes/interactive/tool-args-reveal.d.ts +20 -0
  283. package/dist/modes/interactive/tool-args-reveal.d.ts.map +1 -0
  284. package/dist/modes/interactive/tool-args-reveal.js +153 -0
  285. package/dist/modes/interactive/tool-args-reveal.js.map +1 -0
  286. package/dist/utils/child-process.d.ts +17 -1
  287. package/dist/utils/child-process.d.ts.map +1 -1
  288. package/dist/utils/child-process.js +41 -1
  289. package/dist/utils/child-process.js.map +1 -1
  290. package/docs/AGENTS.md +70 -0
  291. package/docs/custom-provider.md +28 -0
  292. package/docs/extensions.md +83 -5
  293. package/docs/index.md +1 -0
  294. package/docs/llama-cpp.md +99 -0
  295. package/docs/mcp.md +21 -5
  296. package/docs/neo.md +2 -1
  297. package/docs/prompt-templates.md +1 -0
  298. package/docs/providers.md +7 -0
  299. package/docs/tui.md +41 -26
  300. package/docs/usage.md +1 -0
  301. package/examples/AGENTS.md +3 -0
  302. package/examples/extensions/README.md +1 -1
  303. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +62 -0
  304. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  305. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +59 -19
  306. package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +0 -1
  307. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +69 -2
  308. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +6 -0
  309. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  310. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +19 -4
  311. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  312. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +3 -1
  313. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
  314. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +4 -2
  315. package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
  316. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  317. package/node_modules/@earendil-works/pi-ai/README.md +1 -1
  318. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  319. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +24 -4
  320. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  321. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
  322. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  323. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +25 -1
  324. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  325. package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
  326. package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +43 -9
  327. package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
  328. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +1 -0
  329. package/node_modules/@earendil-works/pi-ai/dist/compat.d.ts.map +1 -1
  330. package/node_modules/@earendil-works/pi-ai/dist/compat.js +1 -0
  331. package/node_modules/@earendil-works/pi-ai/dist/compat.js.map +1 -1
  332. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +15 -0
  333. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  334. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +15 -0
  335. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  336. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +4267 -22314
  337. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  338. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +436 -1988
  339. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts.map +1 -1
  340. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js +2 -1892
  341. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.js.map +1 -1
  342. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +10 -80
  343. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts.map +1 -1
  344. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js +2 -57
  345. package/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.js.map +1 -1
  346. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +43 -267
  347. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts.map +1 -1
  348. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js +2 -252
  349. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.js.map +1 -1
  350. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +184 -883
  351. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts.map +1 -1
  352. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js +2 -811
  353. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.js.map +1 -1
  354. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +10 -60
  355. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts.map +1 -1
  356. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js +2 -56
  357. package/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.js.map +1 -1
  358. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +168 -884
  359. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts.map +1 -1
  360. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js +2 -755
  361. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
  362. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +40 -286
  363. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts.map +1 -1
  364. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js +2 -236
  365. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
  366. package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -0
  367. package/node_modules/@earendil-works/pi-ai/dist/providers/data/ant-ling.json +1 -0
  368. package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -0
  369. package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -0
  370. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cerebras.json +1 -0
  371. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -0
  372. package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -0
  373. package/node_modules/@earendil-works/pi-ai/dist/providers/data/deepseek.json +1 -0
  374. package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -0
  375. package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -0
  376. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -0
  377. package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -0
  378. package/node_modules/@earendil-works/pi-ai/dist/providers/data/groq.json +1 -0
  379. package/node_modules/@earendil-works/pi-ai/dist/providers/data/huggingface.json +1 -0
  380. package/node_modules/@earendil-works/pi-ai/dist/providers/data/kimi-coding.json +1 -0
  381. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax-cn.json +1 -0
  382. package/node_modules/@earendil-works/pi-ai/dist/providers/data/minimax.json +1 -0
  383. package/node_modules/@earendil-works/pi-ai/dist/providers/data/mistral.json +1 -0
  384. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai-cn.json +1 -0
  385. package/node_modules/@earendil-works/pi-ai/dist/providers/data/moonshotai.json +1 -0
  386. package/node_modules/@earendil-works/pi-ai/dist/providers/data/nvidia.json +1 -0
  387. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -0
  388. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -0
  389. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -0
  390. package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -0
  391. package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -0
  392. package/node_modules/@earendil-works/pi-ai/dist/providers/data/together.json +1 -0
  393. package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -0
  394. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xai.json +1 -0
  395. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-ams.json +1 -0
  396. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-cn.json +1 -0
  397. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi-token-plan-sgp.json +1 -0
  398. package/node_modules/@earendil-works/pi-ai/dist/providers/data/xiaomi.json +1 -0
  399. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai-coding-cn.json +1 -0
  400. package/node_modules/@earendil-works/pi-ai/dist/providers/data/zai.json +1 -0
  401. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +7 -58
  402. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts.map +1 -1
  403. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js +2 -40
  404. package/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.js.map +1 -1
  405. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +49 -362
  406. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts.map +1 -1
  407. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js +2 -292
  408. package/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.js.map +1 -1
  409. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +85 -760
  410. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts.map +1 -1
  411. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js +2 -538
  412. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.js.map +1 -1
  413. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +31 -189
  414. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts.map +1 -1
  415. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js +2 -179
  416. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.js.map +1 -1
  417. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +49 -309
  418. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts.map +1 -1
  419. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js +2 -285
  420. package/node_modules/@earendil-works/pi-ai/dist/providers/google.models.js.map +1 -1
  421. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +22 -118
  422. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts.map +1 -1
  423. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js +2 -122
  424. package/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.js.map +1 -1
  425. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +196 -979
  426. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts.map +1 -1
  427. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js +2 -884
  428. package/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.js.map +1 -1
  429. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +16 -121
  430. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
  431. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +2 -98
  432. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
  433. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +10 -48
  434. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts.map +1 -1
  435. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js +2 -53
  436. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.js.map +1 -1
  437. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +10 -48
  438. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts.map +1 -1
  439. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js +2 -53
  440. package/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.js.map +1 -1
  441. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +91 -480
  442. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts.map +1 -1
  443. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js +2 -512
  444. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.js.map +1 -1
  445. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +31 -257
  446. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts.map +1 -1
  447. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +2 -185
  448. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
  449. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +31 -257
  450. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts.map +1 -1
  451. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +2 -185
  452. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
  453. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +58 -541
  454. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts.map +1 -1
  455. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js +2 -382
  456. package/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.js.map +1 -1
  457. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +22 -196
  458. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts.map +1 -1
  459. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js +2 -139
  460. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.js.map +1 -1
  461. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +184 -954
  462. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts.map +1 -1
  463. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js +2 -825
  464. package/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.js.map +1 -1
  465. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.d.ts +1 -1
  466. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.d.ts.map +1 -1
  467. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +2 -0
  468. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js.map +1 -1
  469. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +46 -335
  470. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
  471. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +2 -273
  472. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
  473. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +163 -1185
  474. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts.map +1 -1
  475. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js +2 -996
  476. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.js.map +1 -1
  477. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +1076 -5750
  478. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts.map +1 -1
  479. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +2 -4910
  480. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  481. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +49 -579
  482. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts.map +1 -1
  483. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js +2 -377
  484. package/node_modules/@earendil-works/pi-ai/dist/providers/together.models.js.map +1 -1
  485. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +752 -3336
  486. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts.map +1 -1
  487. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js +2 -3263
  488. package/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.js.map +1 -1
  489. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +10 -65
  490. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
  491. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +2 -57
  492. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
  493. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +10 -63
  494. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts.map +1 -1
  495. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js +2 -56
  496. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
  497. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +10 -63
  498. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts.map +1 -1
  499. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js +2 -56
  500. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
  501. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +10 -63
  502. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts.map +1 -1
  503. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js +2 -56
  504. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
  505. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +19 -126
  506. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts.map +1 -1
  507. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js +2 -110
  508. package/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.js.map +1 -1
  509. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +19 -144
  510. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts.map +1 -1
  511. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js +2 -111
  512. package/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.js.map +1 -1
  513. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +19 -144
  514. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts.map +1 -1
  515. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js +2 -111
  516. package/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.js.map +1 -1
  517. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.d.ts.map +1 -1
  518. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js +12 -0
  519. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/context-transformer.js.map +1 -1
  520. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts +1 -1
  521. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.d.ts.map +1 -1
  522. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js +4 -2
  523. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/index.js.map +1 -1
  524. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts +1 -0
  525. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.d.ts.map +1 -1
  526. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js +1 -1
  527. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/coerce-parameters.js.map +1 -1
  528. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts +1 -0
  529. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.d.ts.map +1 -1
  530. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js +1 -1
  531. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/format.js.map +1 -1
  532. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts +19 -0
  533. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.d.ts.map +1 -0
  534. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js +8 -0
  535. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-protocol.js.map +1 -0
  536. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts +11 -0
  537. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.d.ts.map +1 -1
  538. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js +40 -1
  539. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/invoke-tag-scanner.js.map +1 -1
  540. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts +2 -0
  541. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.d.ts.map +1 -1
  542. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js +7 -4
  543. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/parse.js.map +1 -1
  544. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts +2 -0
  545. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.d.ts.map +1 -1
  546. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js +104 -15
  547. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/anthropic-xml/stream.js.map +1 -1
  548. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts +15 -0
  549. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.d.ts.map +1 -0
  550. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.js +198 -0
  551. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/coerce-parameters.js.map +1 -0
  552. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.d.ts +3 -0
  553. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.d.ts.map +1 -0
  554. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.js +8 -0
  555. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/config.js.map +1 -0
  556. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.d.ts +6 -0
  557. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.d.ts.map +1 -0
  558. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.js +33 -0
  559. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/format.js.map +1 -0
  560. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.d.ts +6 -0
  561. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.d.ts.map +1 -0
  562. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.js +6 -0
  563. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/index.js.map +1 -0
  564. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.d.ts +4 -0
  565. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.d.ts.map +1 -0
  566. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.js +6 -0
  567. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/parse.js.map +1 -0
  568. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.d.ts +12 -0
  569. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.d.ts.map +1 -0
  570. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.js +46 -0
  571. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/repair.js.map +1 -0
  572. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.d.ts +4 -0
  573. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.d.ts.map +1 -0
  574. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.js +6 -0
  575. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/antml/stream.js.map +1 -0
  576. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts +8 -1
  577. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.d.ts.map +1 -1
  578. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js +129 -27
  579. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/gemma4.js.map +1 -1
  580. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.d.ts.map +1 -1
  581. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js +140 -6
  582. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/json-mix.js.map +1 -1
  583. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.d.ts.map +1 -1
  584. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js +28 -6
  585. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/morph-xml.js.map +1 -1
  586. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.d.ts.map +1 -1
  587. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js +51 -18
  588. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/protocols/yaml-xml.js.map +1 -1
  589. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.d.ts.map +1 -1
  590. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js +70 -9
  591. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/stream-wrapper.js.map +1 -1
  592. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts +6 -2
  593. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.d.ts.map +1 -1
  594. package/node_modules/@earendil-works/pi-ai/dist/tool-call-middleware/types.js.map +1 -1
  595. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +16 -3
  596. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  597. package/node_modules/@earendil-works/pi-ai/dist/types.js +4 -1
  598. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  599. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
  600. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +1 -0
  601. package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
  602. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.d.ts.map +1 -1
  603. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js +19 -2
  604. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-pair-repair.js.map +1 -1
  605. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts +19 -0
  606. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +1 -0
  607. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +215 -0
  608. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +1 -0
  609. package/node_modules/@earendil-works/pi-ai/package.json +2 -2
  610. package/node_modules/@earendil-works/pi-pty/dist/registry-session.d.ts +1 -1
  611. package/node_modules/@earendil-works/pi-pty/dist/registry-session.d.ts.map +1 -1
  612. package/node_modules/@earendil-works/pi-pty/dist/registry-session.js +25 -6
  613. package/node_modules/@earendil-works/pi-pty/dist/registry-session.js.map +1 -1
  614. package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts +6 -0
  615. package/node_modules/@earendil-works/pi-pty/dist/registry-types.d.ts.map +1 -1
  616. package/node_modules/@earendil-works/pi-pty/dist/registry-types.js.map +1 -1
  617. package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts +1 -0
  618. package/node_modules/@earendil-works/pi-pty/dist/registry.d.ts.map +1 -1
  619. package/node_modules/@earendil-works/pi-pty/dist/registry.js +9 -1
  620. package/node_modules/@earendil-works/pi-pty/dist/registry.js.map +1 -1
  621. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  622. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
  623. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  624. package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
  625. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  626. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +6 -1
  627. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  628. package/node_modules/@earendil-works/pi-tui/dist/tui.js +14 -2
  629. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  630. package/node_modules/@earendil-works/pi-tui/dist/utils.js +1 -1
  631. package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +1 -1
  632. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  633. package/package.json +6 -6
  634. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts +0 -4
  635. package/dist/core/extensions/builtin/todotools/tools/todoread.d.ts.map +0 -1
  636. package/dist/core/extensions/builtin/todotools/tools/todoread.js +0 -37
  637. package/dist/core/extensions/builtin/todotools/tools/todoread.js.map +0 -1
  638. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts +0 -10
  639. package/dist/core/extensions/builtin/todotools/tools/todowrite.d.ts.map +0 -1
  640. package/dist/core/extensions/builtin/todotools/tools/todowrite.js +0 -95
  641. package/dist/core/extensions/builtin/todotools/tools/todowrite.js.map +0 -1
@@ -1,28 +1,53 @@
1
1
  const TODO_SNAPSHOT_CUSTOM_TYPE = "compaction.todo-snapshot";
2
2
  const TODO_SNAPSHOT_SCHEMA = "senpi.compaction.todo-snapshot.v1";
3
+ const TODO_STATE_ENTRY_TYPE = "senpi.todo-state";
4
+ function isRecord(value) {
5
+ return typeof value === "object" && value !== null;
6
+ }
7
+ function isTodoStatus(value) {
8
+ // Legacy todowrite entries carried arbitrary status strings (e.g. "blocked").
9
+ // The bridge is a pass-through snapshot carrier, not a validator: preserve
10
+ // every string-status entry so restore never silently drops legacy todos.
11
+ return value === undefined || typeof value === "string";
12
+ }
13
+ function isTodoEntry(value) {
14
+ if (!isRecord(value))
15
+ return false;
16
+ const hasId = typeof value.id === "string";
17
+ const hasContent = typeof value.content === "string" || typeof value.text === "string";
18
+ return (hasId || hasContent) && isTodoStatus(value.status);
19
+ }
20
+ function isTodoPhase(value) {
21
+ if (!isRecord(value) || typeof value.name !== "string" || !Array.isArray(value.tasks))
22
+ return false;
23
+ return value.tasks.every(isTodoEntry);
24
+ }
3
25
  function isCustomTodoEntry(entry) {
4
- return entry.type === "custom" && entry.customType.startsWith("todowrite");
26
+ return (entry.type === "custom" &&
27
+ (entry.customType.startsWith("todowrite") || entry.customType === TODO_STATE_ENTRY_TYPE));
5
28
  }
6
29
  function isLegacyTodoListEntry(entry) {
7
30
  return entry.type === "custom" && entry.customType === "todo-list";
8
31
  }
9
32
  function readTodosFromEntry(entry) {
10
33
  const data = entry.data;
11
- if (typeof data !== "object" || data === null || !("todos" in data) || !Array.isArray(data.todos)) {
34
+ if (!isRecord(data))
12
35
  return [];
36
+ if (Array.isArray(data.todos))
37
+ return data.todos.filter(isTodoEntry);
38
+ if (Array.isArray(data.phases)) {
39
+ return data.phases.filter(isTodoPhase).flatMap((phase) => phase.tasks);
13
40
  }
14
- return data.todos.filter((todo) => {
15
- return typeof todo === "object" && todo !== null && "id" in todo && typeof todo.id === "string";
16
- });
41
+ return [];
17
42
  }
18
43
  function findLatestTodoSnapshot(ctx) {
19
44
  const entries = ctx.sessionManager.getEntries();
20
- for (let index = entries.length - 1; index >= 0; index--) {
45
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
21
46
  const entry = entries[index];
22
47
  if (entry.type !== "custom" || entry.customType !== TODO_SNAPSHOT_CUSTOM_TYPE)
23
48
  continue;
24
49
  const data = entry.data;
25
- if (typeof data === "object" && data !== null && "schema" in data && data.schema === TODO_SNAPSHOT_SCHEMA) {
50
+ if (isRecord(data) && data.schema === TODO_SNAPSHOT_SCHEMA && Array.isArray(data.todos)) {
26
51
  return data;
27
52
  }
28
53
  }
@@ -31,7 +56,7 @@ function findLatestTodoSnapshot(ctx) {
31
56
  export function findTodoEntries(ctxOrEntries, options) {
32
57
  if (Array.isArray(ctxOrEntries)) {
33
58
  return ctxOrEntries
34
- .filter(isLegacyTodoListEntry)
59
+ .filter((entry) => isLegacyTodoListEntry(entry) || isCustomTodoEntry(entry))
35
60
  .filter((entry) => options?.branchId === undefined || entry.parentId === options.branchId)
36
61
  .flatMap(readTodosFromEntry);
37
62
  }
@@ -75,7 +100,7 @@ export function restoreTodosIfMissing(piOrSnapshot, ctxOrCurrentTodos, _pi) {
75
100
  return;
76
101
  pi.sendMessage({
77
102
  customType: "compaction.todo-restore-request",
78
- content: `Restore missing todowrite todos from snapshot: ${JSON.stringify(snapshot.todos)}`,
103
+ content: `Restore missing todo tasks from snapshot: ${JSON.stringify(snapshot.todos)}`,
79
104
  display: false,
80
105
  details: snapshot,
81
106
  }, { triggerTurn: true, deliverAs: "nextTurn" });
@@ -1 +1 @@
1
- {"version":3,"file":"todo-bridge.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/todo-bridge.ts"],"names":[],"mappings":"AAGA,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AA+BjE,SAAS,iBAAiB,CAAC,KAAmB;IAC7C,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAmB;IACjD,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,KAAK,WAAW,CAAC;AACpE,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAkB;IAC7C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACnG,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAqB,EAAE;QACpD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;IACjG,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,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IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAErD,EAAE,CAAC,WAAW,CACb;QACC,UAAU,EAAE,iCAAiC;QAC7C,OAAO,EAAE,kDAAkD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3F,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,QAAQ;KACjB,EACD,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAC5C,CAAC;AACH,CAAC","sourcesContent":["import type { CustomEntry, SessionEntry } from \"../../../session-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\n\nconst TODO_SNAPSHOT_CUSTOM_TYPE = \"compaction.todo-snapshot\";\nconst TODO_SNAPSHOT_SCHEMA = \"senpi.compaction.todo-snapshot.v1\";\n\nexport interface TodoEntry {\n\tid: string;\n\tcontent?: string;\n\ttext?: string;\n\tstatus?: \"pending\" | \"in_progress\" | \"completed\" | \"cancelled\";\n}\n\nexport interface TodoSnapshotPayload {\n\tschema: typeof TODO_SNAPSHOT_SCHEMA;\n\ttodos: TodoEntry[] | SessionEntry[];\n\tcapturedAt: number;\n}\n\ninterface AppendEntryTarget {\n\tappendEntry<T = unknown>(customType: string, data?: T): void;\n}\n\ninterface SendMessageTarget extends AppendEntryTarget {\n\tsendMessage<T = unknown>(\n\t\tmessage: { customType: string; content: string; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): void;\n}\n\ninterface RestoreResult {\n\tapplied: boolean;\n\trestoredTodos: TodoEntry[];\n}\n\nfunction isCustomTodoEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType.startsWith(\"todowrite\");\n}\n\nfunction isLegacyTodoListEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType === \"todo-list\";\n}\n\nfunction readTodosFromEntry(entry: CustomEntry): TodoEntry[] {\n\tconst data = entry.data;\n\tif (typeof data !== \"object\" || data === null || !(\"todos\" in data) || !Array.isArray(data.todos)) {\n\t\treturn [];\n\t}\n\treturn data.todos.filter((todo): todo is TodoEntry => {\n\t\treturn typeof todo === \"object\" && todo !== null && \"id\" in todo && typeof todo.id === \"string\";\n\t});\n}\n\nfunction findLatestTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload | null {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== TODO_SNAPSHOT_CUSTOM_TYPE) continue;\n\t\tconst data = entry.data;\n\t\tif (typeof data === \"object\" && data !== null && \"schema\" in data && data.schema === TODO_SNAPSHOT_SCHEMA) {\n\t\t\treturn data as TodoSnapshotPayload;\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function findTodoEntries(ctx: ExtensionContext): SessionEntry[];\nexport function findTodoEntries(entries: SessionEntry[], options?: { branchId?: string }): TodoEntry[];\nexport function findTodoEntries(\n\tctxOrEntries: ExtensionContext | SessionEntry[],\n\toptions?: { branchId?: string },\n): SessionEntry[] | TodoEntry[] {\n\tif (Array.isArray(ctxOrEntries)) {\n\t\treturn ctxOrEntries\n\t\t\t.filter(isLegacyTodoListEntry)\n\t\t\t.filter((entry) => options?.branchId === undefined || entry.parentId === options.branchId)\n\t\t\t.flatMap(readTodosFromEntry);\n\t}\n\n\treturn ctxOrEntries.sessionManager.getEntries().filter(isCustomTodoEntry);\n}\n\nexport function createTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload {\n\treturn {\n\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\ttodos: findTodoEntries(ctx),\n\t\tcapturedAt: Date.now(),\n\t};\n}\n\nexport function persistTodoSnapshot(pi: AppendEntryTarget, snapshot: TodoSnapshotPayload): void {\n\tpi.appendEntry(TODO_SNAPSHOT_CUSTOM_TYPE, snapshot);\n}\n\nexport function captureTodoSnapshot(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function captureTodoSnapshot(currentTodos: TodoEntry[], pi: AppendEntryTarget, branchId?: string): void;\nexport function captureTodoSnapshot(\n\tpiOrTodos: ExtensionAPI | TodoEntry[],\n\tctxOrPi: ExtensionContext | AppendEntryTarget,\n\t_branchId?: string,\n): void {\n\tif (Array.isArray(piOrTodos)) {\n\t\tconst pi = ctxOrPi as AppendEntryTarget;\n\t\tpersistTodoSnapshot(pi, {\n\t\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\t\ttodos: piOrTodos,\n\t\t\tcapturedAt: Date.now(),\n\t\t});\n\t\treturn;\n\t}\n\n\tpersistTodoSnapshot(piOrTodos, createTodoSnapshot(ctxOrPi as ExtensionContext));\n}\n\nexport function restoreTodosIfMissing(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function restoreTodosIfMissing(\n\tsnapshot: TodoEntry[],\n\tcurrentTodos: TodoEntry[],\n\tpi: AppendEntryTarget,\n): RestoreResult;\nexport function restoreTodosIfMissing(\n\tpiOrSnapshot: ExtensionAPI | TodoEntry[],\n\tctxOrCurrentTodos: ExtensionContext | TodoEntry[],\n\t_pi?: AppendEntryTarget,\n): undefined | RestoreResult {\n\tif (Array.isArray(piOrSnapshot) && Array.isArray(ctxOrCurrentTodos)) {\n\t\tif (ctxOrCurrentTodos.length > 0) {\n\t\t\treturn { applied: false, restoredTodos: ctxOrCurrentTodos };\n\t\t}\n\t\treturn { applied: piOrSnapshot.length > 0, restoredTodos: piOrSnapshot };\n\t}\n\n\tconst pi = piOrSnapshot as SendMessageTarget;\n\tconst ctx = ctxOrCurrentTodos as ExtensionContext;\n\tif (findTodoEntries(ctx).length > 0) return;\n\n\tconst snapshot = findLatestTodoSnapshot(ctx);\n\tif (!snapshot || snapshot.todos.length === 0) return;\n\n\tpi.sendMessage(\n\t\t{\n\t\t\tcustomType: \"compaction.todo-restore-request\",\n\t\t\tcontent: `Restore missing todowrite todos from snapshot: ${JSON.stringify(snapshot.todos)}`,\n\t\t\tdisplay: false,\n\t\t\tdetails: snapshot,\n\t\t},\n\t\t{ triggerTurn: true, deliverAs: \"nextTurn\" },\n\t);\n}\n"]}
1
+ {"version":3,"file":"todo-bridge.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/compaction/todo-bridge.ts"],"names":[],"mappings":"AAIA,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AACjE,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAiCjD,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IACnC,8EAA8E;IAC9E,2EAA2E;IAC3E,0EAA0E;IAC1E,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACzD,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC;IAC3C,MAAM,UAAU,GAAG,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;IACvF,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpG,OAAO,KA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;QACtF,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,QAAQ;KACjB,EACD,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAC5C,CAAC;AACH,CAAC","sourcesContent":["import type { CustomEntry, SessionEntry } from \"../../../session-manager.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport type { TodoPhase } from \"../todotools/state.ts\";\n\nconst TODO_SNAPSHOT_CUSTOM_TYPE = \"compaction.todo-snapshot\";\nconst TODO_SNAPSHOT_SCHEMA = \"senpi.compaction.todo-snapshot.v1\";\nconst TODO_STATE_ENTRY_TYPE = \"senpi.todo-state\";\n\nexport interface TodoEntry {\n\tid?: string;\n\tcontent?: string;\n\ttext?: string;\n\tstatus?: string;\n}\n\nexport type TodoSnapshotItems = TodoEntry[] | TodoPhase[];\n\nexport interface TodoSnapshotPayload {\n\tschema: typeof TODO_SNAPSHOT_SCHEMA;\n\ttodos: TodoSnapshotItems | SessionEntry[];\n\tcapturedAt: number;\n}\n\ninterface AppendEntryTarget {\n\tappendEntry<T = unknown>(customType: string, data?: T): void;\n}\n\ninterface SendMessageTarget extends AppendEntryTarget {\n\tsendMessage<T = unknown>(\n\t\tmessage: { customType: string; content: string; display: boolean; details?: T },\n\t\toptions?: { triggerTurn?: boolean; deliverAs?: \"steer\" | \"followUp\" | \"nextTurn\" },\n\t): void;\n}\n\nexport interface RestoreResult<T extends TodoSnapshotItems = TodoSnapshotItems> {\n\tapplied: boolean;\n\trestoredTodos: T;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isTodoStatus(value: unknown): value is TodoEntry[\"status\"] {\n\t// Legacy todowrite entries carried arbitrary status strings (e.g. \"blocked\").\n\t// The bridge is a pass-through snapshot carrier, not a validator: preserve\n\t// every string-status entry so restore never silently drops legacy todos.\n\treturn value === undefined || typeof value === \"string\";\n}\n\nfunction isTodoEntry(value: unknown): value is TodoEntry {\n\tif (!isRecord(value)) return false;\n\tconst hasId = typeof value.id === \"string\";\n\tconst hasContent = typeof value.content === \"string\" || typeof value.text === \"string\";\n\treturn (hasId || hasContent) && isTodoStatus(value.status);\n}\n\nfunction isTodoPhase(value: unknown): value is TodoPhase {\n\tif (!isRecord(value) || typeof value.name !== \"string\" || !Array.isArray(value.tasks)) return false;\n\treturn value.tasks.every(isTodoEntry);\n}\n\nfunction isCustomTodoEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn (\n\t\tentry.type === \"custom\" &&\n\t\t(entry.customType.startsWith(\"todowrite\") || entry.customType === TODO_STATE_ENTRY_TYPE)\n\t);\n}\n\nfunction isLegacyTodoListEntry(entry: SessionEntry): entry is CustomEntry {\n\treturn entry.type === \"custom\" && entry.customType === \"todo-list\";\n}\n\nfunction readTodosFromEntry(entry: CustomEntry): TodoEntry[] {\n\tconst data = entry.data;\n\tif (!isRecord(data)) return [];\n\tif (Array.isArray(data.todos)) return data.todos.filter(isTodoEntry);\n\tif (Array.isArray(data.phases)) {\n\t\treturn data.phases.filter(isTodoPhase).flatMap((phase) => phase.tasks);\n\t}\n\treturn [];\n}\n\nfunction findLatestTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload | null {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let index = entries.length - 1; index >= 0; index -= 1) {\n\t\tconst entry = entries[index];\n\t\tif (entry.type !== \"custom\" || entry.customType !== TODO_SNAPSHOT_CUSTOM_TYPE) continue;\n\t\tconst data = entry.data;\n\t\tif (isRecord(data) && data.schema === TODO_SNAPSHOT_SCHEMA && Array.isArray(data.todos)) {\n\t\t\treturn data as unknown as TodoSnapshotPayload;\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function findTodoEntries(ctx: ExtensionContext): SessionEntry[];\nexport function findTodoEntries(entries: SessionEntry[], options?: { branchId?: string }): TodoEntry[];\nexport function findTodoEntries(\n\tctxOrEntries: ExtensionContext | SessionEntry[],\n\toptions?: { branchId?: string },\n): SessionEntry[] | TodoEntry[] {\n\tif (Array.isArray(ctxOrEntries)) {\n\t\treturn ctxOrEntries\n\t\t\t.filter((entry) => isLegacyTodoListEntry(entry) || isCustomTodoEntry(entry))\n\t\t\t.filter((entry) => options?.branchId === undefined || entry.parentId === options.branchId)\n\t\t\t.flatMap(readTodosFromEntry);\n\t}\n\n\treturn ctxOrEntries.sessionManager.getEntries().filter(isCustomTodoEntry);\n}\n\nexport function createTodoSnapshot(ctx: ExtensionContext): TodoSnapshotPayload {\n\treturn {\n\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\ttodos: findTodoEntries(ctx),\n\t\tcapturedAt: Date.now(),\n\t};\n}\n\nexport function persistTodoSnapshot(pi: AppendEntryTarget, snapshot: TodoSnapshotPayload): void {\n\tpi.appendEntry(TODO_SNAPSHOT_CUSTOM_TYPE, snapshot);\n}\n\nexport function captureTodoSnapshot(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function captureTodoSnapshot(currentTodos: TodoSnapshotItems, pi: AppendEntryTarget, branchId?: string): void;\nexport function captureTodoSnapshot(\n\tpiOrTodos: ExtensionAPI | TodoSnapshotItems,\n\tctxOrPi: ExtensionContext | AppendEntryTarget,\n\t_branchId?: string,\n): void {\n\tif (Array.isArray(piOrTodos)) {\n\t\tconst pi = ctxOrPi as AppendEntryTarget;\n\t\tpersistTodoSnapshot(pi, {\n\t\t\tschema: TODO_SNAPSHOT_SCHEMA,\n\t\t\ttodos: piOrTodos,\n\t\t\tcapturedAt: Date.now(),\n\t\t});\n\t\treturn;\n\t}\n\n\tpersistTodoSnapshot(piOrTodos, createTodoSnapshot(ctxOrPi as ExtensionContext));\n}\n\nexport function restoreTodosIfMissing(pi: ExtensionAPI, ctx: ExtensionContext): void;\nexport function restoreTodosIfMissing<T extends TodoSnapshotItems>(\n\tsnapshot: T,\n\tcurrentTodos: T,\n\tpi: AppendEntryTarget,\n): RestoreResult<T>;\nexport function restoreTodosIfMissing(\n\tpiOrSnapshot: ExtensionAPI | TodoSnapshotItems,\n\tctxOrCurrentTodos: ExtensionContext | TodoSnapshotItems,\n\t_pi?: AppendEntryTarget,\n): undefined | RestoreResult {\n\tif (Array.isArray(piOrSnapshot) && Array.isArray(ctxOrCurrentTodos)) {\n\t\tif (ctxOrCurrentTodos.length > 0) {\n\t\t\treturn { applied: false, restoredTodos: ctxOrCurrentTodos };\n\t\t}\n\t\treturn { applied: piOrSnapshot.length > 0, restoredTodos: piOrSnapshot };\n\t}\n\n\tconst pi = piOrSnapshot as SendMessageTarget;\n\tconst ctx = ctxOrCurrentTodos as ExtensionContext;\n\tif (findTodoEntries(ctx).length > 0) return;\n\n\tconst snapshot = findLatestTodoSnapshot(ctx);\n\tif (!snapshot || snapshot.todos.length === 0) return;\n\n\tpi.sendMessage(\n\t\t{\n\t\t\tcustomType: \"compaction.todo-restore-request\",\n\t\t\tcontent: `Restore missing todo tasks from snapshot: ${JSON.stringify(snapshot.todos)}`,\n\t\t\tdisplay: false,\n\t\t\tdetails: snapshot,\n\t\t},\n\t\t{ triggerTurn: true, deliverAs: \"nextTurn\" },\n\t);\n}\n"]}
@@ -5,4 +5,5 @@ export declare const APPLY_PATCH_PARAMS: Type.TObject<{
5
5
  export declare const APPLY_PATCH_FREEFORM_DESCRIPTION = "Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.";
6
6
  export declare const APPLY_PATCH_LARK_GRAMMAR = "start: begin_patch hunk+ end_patch\nbegin_patch: \"*** Begin Patch\" LF\nend_patch: \"*** End Patch\" LF?\n\nhunk: add_hunk | delete_hunk | update_hunk\nadd_hunk: \"*** Add File: \" filename LF add_line+\ndelete_hunk: \"*** Delete File: \" filename LF\nupdate_hunk: \"*** Update File: \" filename LF change_move? change?\n\nfilename: /(.+)/\nadd_line: \"+\" /(.*)/ LF -> line\n\nchange_move: \"*** Move to: \" filename LF\nchange: (change_context | change_line)+ eof_line?\nchange_context: (\"@@\" | \"@@ \" /(.+)/) LF\nchange_line: (\"+\" | \"-\" | \" \") /(.*)/ LF\neof_line: \"*** End of File\" LF\n\n%import common.LF\n";
7
7
  export declare const CODEX_APPLY_PATCH_DESCRIPTION = "Use the `apply_patch` tool to edit files.\nYour patch language is a stripped\u2011down, file\u2011oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high\u2011level envelope:\n\n*** Begin Patch\n[ one or more file sections ]\n*** End Patch\n\nWithin that envelope, you get a sequence of file operations.\nYou MUST include a header to specify the action you are taking.\nEach operation starts with one of three headers:\n\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\n*** Delete File: <path> - remove an existing file. Nothing follows.\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\n\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\nThen one or more \u201Chunks\u201D, each introduced by @@ (optionally followed by a hunk header).\nWithin a hunk each line starts with:\n\nFor instructions on [context_before] and [context_after]:\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change\u2019s [context_after] lines in the second change\u2019s [context_before] lines.\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\n@@ class BaseClass\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\n\n@@ class BaseClass\n@@ \t def method():\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\nThe full grammar definition is below:\nPatch := Begin { FileOp } End\nBegin := \"*** Begin Patch\" NEWLINE\nEnd := \"*** End Patch\" NEWLINE\nFileOp := AddFile | DeleteFile | UpdateFile\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\nDeleteFile := \"*** Delete File: \" path NEWLINE\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\nMoveTo := \"*** Move to: \" newPath NEWLINE\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\n\nA full patch can combine several operations:\n\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n*** Move to: src/main.py\n@@ def greet():\n-print(\"Hi\")\n+print(\"Hello, world!\")\n*** Delete File: obsolete.txt\n*** End Patch\n\nIt is important to remember:\n\n- You must include a header with your intended action (Add/Delete/Update)\n- You must prefix new lines with `+` even when creating a new file\n- File references can only be relative, NEVER ABSOLUTE.\n";
8
+ export declare const APPLY_PATCH_JSON_DESCRIPTION = "Use the `apply_patch` tool to edit files by passing the entire patch as the `input` string argument.\nUse the `apply_patch` tool to edit files.\nYour patch language is a stripped\u2011down, file\u2011oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high\u2011level envelope:\n\n*** Begin Patch\n[ one or more file sections ]\n*** End Patch\n\nWithin that envelope, you get a sequence of file operations.\nYou MUST include a header to specify the action you are taking.\nEach operation starts with one of three headers:\n\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\n*** Delete File: <path> - remove an existing file. Nothing follows.\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\n\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\nThen one or more \u201Chunks\u201D, each introduced by @@ (optionally followed by a hunk header).\nWithin a hunk each line starts with:\n\nFor instructions on [context_before] and [context_after]:\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change\u2019s [context_after] lines in the second change\u2019s [context_before] lines.\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\n@@ class BaseClass\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\n\n@@ class BaseClass\n@@ \t def method():\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\nThe full grammar definition is below:\nPatch := Begin { FileOp } End\nBegin := \"*** Begin Patch\" NEWLINE\nEnd := \"*** End Patch\" NEWLINE\nFileOp := AddFile | DeleteFile | UpdateFile\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\nDeleteFile := \"*** Delete File: \" path NEWLINE\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\nMoveTo := \"*** Move to: \" newPath NEWLINE\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\n\nA full patch can combine several operations:\n\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n*** Move to: src/main.py\n@@ def greet():\n-print(\"Hi\")\n+print(\"Hello, world!\")\n*** Delete File: obsolete.txt\n*** End Patch\n\nIt is important to remember:\n\n- You must include a header with your intended action (Add/Delete/Update)\n- You must prefix new lines with `+` even when creating a new file\n- File references can only be relative, NEVER ABSOLUTE.\n";
8
9
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,eAAO,MAAM,kBAAkB;;EAI7B,CAAC;AAEH,eAAO,MAAM,gCAAgC,yGAC0D,CAAC;AACxG,eAAO,MAAM,wBAAwB,onBAmBpC,CAAC;AACF,eAAO,MAAM,6BAA6B,k9FACu2F,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,eAAO,MAAM,kBAAkB;;EAI7B,CAAC;AAEH,eAAO,MAAM,gCAAgC,yGAC0D,CAAC;AACxG,eAAO,MAAM,wBAAwB,onBAmBpC,CAAC;AAIF,eAAO,MAAM,6BAA6B,k9FAAqC,CAAC;AAIhF,eAAO,MAAM,4BAA4B,wjGAAoJ,CAAC"}
@@ -25,5 +25,9 @@ eof_line: "*** End of File" LF
25
25
 
26
26
  %import common.LF
27
27
  `;
28
- export const CODEX_APPLY_PATCH_DESCRIPTION = 'Use the `apply_patch` tool to edit files.\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\n\n*** Begin Patch\n[ one or more file sections ]\n*** End Patch\n\nWithin that envelope, you get a sequence of file operations.\nYou MUST include a header to specify the action you are taking.\nEach operation starts with one of three headers:\n\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\n*** Delete File: <path> - remove an existing file. Nothing follows.\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\n\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\nWithin a hunk each line starts with:\n\nFor instructions on [context_before] and [context_after]:\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\n@@ class BaseClass\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\n\n@@ class BaseClass\n@@ \t def method():\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\nThe full grammar definition is below:\nPatch := Begin { FileOp } End\nBegin := "*** Begin Patch" NEWLINE\nEnd := "*** End Patch" NEWLINE\nFileOp := AddFile | DeleteFile | UpdateFile\nAddFile := "*** Add File: " path NEWLINE { "+" line NEWLINE }\nDeleteFile := "*** Delete File: " path NEWLINE\nUpdateFile := "*** Update File: " path NEWLINE [ MoveTo ] { Hunk }\nMoveTo := "*** Move to: " newPath NEWLINE\nHunk := "@@" [ header ] NEWLINE { HunkLine } [ "*** End of File" NEWLINE ]\nHunkLine := (" " | "-" | "+") text NEWLINE\n\nA full patch can combine several operations:\n\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n*** Move to: src/main.py\n@@ def greet():\n-print("Hi")\n+print("Hello, world!")\n*** Delete File: obsolete.txt\n*** End Patch\n\nIt is important to remember:\n\n- You must include a header with your intended action (Add/Delete/Update)\n- You must prefix new lines with `+` even when creating a new file\n- File references can only be relative, NEVER ABSOLUTE.\n';
28
+ const CODEX_APPLY_PATCH_DESCRIPTION_BODY = 'Use the `apply_patch` tool to edit files.\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\n\n*** Begin Patch\n[ one or more file sections ]\n*** End Patch\n\nWithin that envelope, you get a sequence of file operations.\nYou MUST include a header to specify the action you are taking.\nEach operation starts with one of three headers:\n\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\n*** Delete File: <path> - remove an existing file. Nothing follows.\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\n\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\nWithin a hunk each line starts with:\n\nFor instructions on [context_before] and [context_after]:\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\n@@ class BaseClass\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\n\n@@ class BaseClass\n@@ \t def method():\n[3 lines of pre-context]\n- [old_code]\n+ [new_code]\n[3 lines of post-context]\n\nThe full grammar definition is below:\nPatch := Begin { FileOp } End\nBegin := "*** Begin Patch" NEWLINE\nEnd := "*** End Patch" NEWLINE\nFileOp := AddFile | DeleteFile | UpdateFile\nAddFile := "*** Add File: " path NEWLINE { "+" line NEWLINE }\nDeleteFile := "*** Delete File: " path NEWLINE\nUpdateFile := "*** Update File: " path NEWLINE [ MoveTo ] { Hunk }\nMoveTo := "*** Move to: " newPath NEWLINE\nHunk := "@@" [ header ] NEWLINE { HunkLine } [ "*** End of File" NEWLINE ]\nHunkLine := (" " | "-" | "+") text NEWLINE\n\nA full patch can combine several operations:\n\n*** Begin Patch\n*** Add File: hello.txt\n+Hello world\n*** Update File: src/app.py\n*** Move to: src/main.py\n@@ def greet():\n-print("Hi")\n+print("Hello, world!")\n*** Delete File: obsolete.txt\n*** End Patch\n\nIt is important to remember:\n\n- You must include a header with your intended action (Add/Delete/Update)\n- You must prefix new lines with `+` even when creating a new file\n- File references can only be relative, NEVER ABSOLUTE.\n';
29
+ export const CODEX_APPLY_PATCH_DESCRIPTION = CODEX_APPLY_PATCH_DESCRIPTION_BODY;
30
+ // JSON-function variant of the tool description for Chat Completions targets, derived from
31
+ // CODEX_APPLY_PATCH_DESCRIPTION (which carries no freeform / "do not wrap in JSON" wording).
32
+ export const APPLY_PATCH_JSON_DESCRIPTION = `Use the \`apply_patch\` tool to edit files by passing the entire patch as the \`input\` string argument.\n${CODEX_APPLY_PATCH_DESCRIPTION_BODY}`;
29
33
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,gDAAgD;KAC7D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAC5C,sGAAsG,CAAC;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AACF,MAAM,CAAC,MAAM,6BAA6B,GACzC,g5FAAg5F,CAAC","sourcesContent":["import { Type } from \"typebox\";\n\nexport const APPLY_PATCH_PARAMS = Type.Object({\n\tinput: Type.String({\n\t\tdescription: \"The entire contents of the apply_patch command\",\n\t}),\n});\n\nexport const APPLY_PATCH_FREEFORM_DESCRIPTION =\n\t\"Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.\";\nexport const APPLY_PATCH_LARK_GRAMMAR = `start: begin_patch hunk+ end_patch\nbegin_patch: \"*** Begin Patch\" LF\nend_patch: \"*** End Patch\" LF?\n\nhunk: add_hunk | delete_hunk | update_hunk\nadd_hunk: \"*** Add File: \" filename LF add_line+\ndelete_hunk: \"*** Delete File: \" filename LF\nupdate_hunk: \"*** Update File: \" filename LF change_move? change?\n\nfilename: /(.+)/\nadd_line: \"+\" /(.*)/ LF -> line\n\nchange_move: \"*** Move to: \" filename LF\nchange: (change_context | change_line)+ eof_line?\nchange_context: (\"@@\" | \"@@ \" /(.+)/) LF\nchange_line: (\"+\" | \"-\" | \" \") /(.*)/ LF\neof_line: \"*** End of File\" LF\n\n%import common.LF\n`;\nexport const CODEX_APPLY_PATCH_DESCRIPTION =\n\t'Use the `apply_patch` tool to edit files.\\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\\n\\n*** Begin Patch\\n[ one or more file sections ]\\n*** End Patch\\n\\nWithin that envelope, you get a sequence of file operations.\\nYou MUST include a header to specify the action you are taking.\\nEach operation starts with one of three headers:\\n\\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\\n*** Delete File: <path> - remove an existing file. Nothing follows.\\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\\n\\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\\nWithin a hunk each line starts with:\\n\\nFor instructions on [context_before] and [context_after]:\\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\\n@@ class BaseClass\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\\n\\n@@ class BaseClass\\n@@ \\t def method():\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\nThe full grammar definition is below:\\nPatch := Begin { FileOp } End\\nBegin := \"*** Begin Patch\" NEWLINE\\nEnd := \"*** End Patch\" NEWLINE\\nFileOp := AddFile | DeleteFile | UpdateFile\\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\\nDeleteFile := \"*** Delete File: \" path NEWLINE\\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\\nMoveTo := \"*** Move to: \" newPath NEWLINE\\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\\n\\nA full patch can combine several operations:\\n\\n*** Begin Patch\\n*** Add File: hello.txt\\n+Hello world\\n*** Update File: src/app.py\\n*** Move to: src/main.py\\n@@ def greet():\\n-print(\"Hi\")\\n+print(\"Hello, world!\")\\n*** Delete File: obsolete.txt\\n*** End Patch\\n\\nIt is important to remember:\\n\\n- You must include a header with your intended action (Add/Delete/Update)\\n- You must prefix new lines with `+` even when creating a new file\\n- File references can only be relative, NEVER ABSOLUTE.\\n';\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,WAAW,EAAE,gDAAgD;KAC7D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAC5C,sGAAsG,CAAC;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;CAmBvC,CAAC;AACF,MAAM,kCAAkC,GACvC,g5FAAg5F,CAAC;AAEl5F,MAAM,CAAC,MAAM,6BAA6B,GAAG,kCAAkC,CAAC;AAEhF,2FAA2F;AAC3F,6FAA6F;AAC7F,MAAM,CAAC,MAAM,4BAA4B,GAAG,6GAA6G,kCAAkC,EAAE,CAAC","sourcesContent":["import { Type } from \"typebox\";\n\nexport const APPLY_PATCH_PARAMS = Type.Object({\n\tinput: Type.String({\n\t\tdescription: \"The entire contents of the apply_patch command\",\n\t}),\n});\n\nexport const APPLY_PATCH_FREEFORM_DESCRIPTION =\n\t\"Use the `apply_patch` tool to edit files. This is a FREEFORM tool, so do not wrap the patch in JSON.\";\nexport const APPLY_PATCH_LARK_GRAMMAR = `start: begin_patch hunk+ end_patch\nbegin_patch: \"*** Begin Patch\" LF\nend_patch: \"*** End Patch\" LF?\n\nhunk: add_hunk | delete_hunk | update_hunk\nadd_hunk: \"*** Add File: \" filename LF add_line+\ndelete_hunk: \"*** Delete File: \" filename LF\nupdate_hunk: \"*** Update File: \" filename LF change_move? change?\n\nfilename: /(.+)/\nadd_line: \"+\" /(.*)/ LF -> line\n\nchange_move: \"*** Move to: \" filename LF\nchange: (change_context | change_line)+ eof_line?\nchange_context: (\"@@\" | \"@@ \" /(.+)/) LF\nchange_line: (\"+\" | \"-\" | \" \") /(.*)/ LF\neof_line: \"*** End of File\" LF\n\n%import common.LF\n`;\nconst CODEX_APPLY_PATCH_DESCRIPTION_BODY =\n\t'Use the `apply_patch` tool to edit files.\\nYour patch language is a stripped‑down, file‑oriented diff format designed to be easy to parse and safe to apply. You can think of it as a high‑level envelope:\\n\\n*** Begin Patch\\n[ one or more file sections ]\\n*** End Patch\\n\\nWithin that envelope, you get a sequence of file operations.\\nYou MUST include a header to specify the action you are taking.\\nEach operation starts with one of three headers:\\n\\n*** Add File: <path> - create a new file. Every following line is a + line (the initial contents).\\n*** Delete File: <path> - remove an existing file. Nothing follows.\\n*** Update File: <path> - patch an existing file in place (optionally with a rename).\\n\\nMay be immediately followed by *** Move to: <new path> if you want to rename the file.\\nThen one or more “hunks”, each introduced by @@ (optionally followed by a hunk header).\\nWithin a hunk each line starts with:\\n\\nFor instructions on [context_before] and [context_after]:\\n- By default, show 3 lines of code immediately above and 3 lines immediately below each change. If a change is within 3 lines of a previous change, do NOT duplicate the first change’s [context_after] lines in the second change’s [context_before] lines.\\n- If 3 lines of context is insufficient to uniquely identify the snippet of code within the file, use the @@ operator to indicate the class or function to which the snippet belongs. For instance, we might have:\\n@@ class BaseClass\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\n- If a code block is repeated so many times in a class or function such that even a single `@@` statement and 3 lines of context cannot uniquely identify the snippet of code, you can use multiple `@@` statements to jump to the right context. For instance:\\n\\n@@ class BaseClass\\n@@ \\t def method():\\n[3 lines of pre-context]\\n- [old_code]\\n+ [new_code]\\n[3 lines of post-context]\\n\\nThe full grammar definition is below:\\nPatch := Begin { FileOp } End\\nBegin := \"*** Begin Patch\" NEWLINE\\nEnd := \"*** End Patch\" NEWLINE\\nFileOp := AddFile | DeleteFile | UpdateFile\\nAddFile := \"*** Add File: \" path NEWLINE { \"+\" line NEWLINE }\\nDeleteFile := \"*** Delete File: \" path NEWLINE\\nUpdateFile := \"*** Update File: \" path NEWLINE [ MoveTo ] { Hunk }\\nMoveTo := \"*** Move to: \" newPath NEWLINE\\nHunk := \"@@\" [ header ] NEWLINE { HunkLine } [ \"*** End of File\" NEWLINE ]\\nHunkLine := (\" \" | \"-\" | \"+\") text NEWLINE\\n\\nA full patch can combine several operations:\\n\\n*** Begin Patch\\n*** Add File: hello.txt\\n+Hello world\\n*** Update File: src/app.py\\n*** Move to: src/main.py\\n@@ def greet():\\n-print(\"Hi\")\\n+print(\"Hello, world!\")\\n*** Delete File: obsolete.txt\\n*** End Patch\\n\\nIt is important to remember:\\n\\n- You must include a header with your intended action (Add/Delete/Update)\\n- You must prefix new lines with `+` even when creating a new file\\n- File references can only be relative, NEVER ABSOLUTE.\\n';\n\nexport const CODEX_APPLY_PATCH_DESCRIPTION = CODEX_APPLY_PATCH_DESCRIPTION_BODY;\n\n// JSON-function variant of the tool description for Chat Completions targets, derived from\n// CODEX_APPLY_PATCH_DESCRIPTION (which carries no freeform / \"do not wrap in JSON\" wording).\nexport const APPLY_PATCH_JSON_DESCRIPTION = `Use the \\`apply_patch\\` tool to edit files by passing the entire patch as the \\`input\\` string argument.\\n${CODEX_APPLY_PATCH_DESCRIPTION_BODY}`;\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { Model } from "@earendil-works/pi-ai";
2
- import type { ApplyPatchExtensionAPI } from "./types.ts";
2
+ import type { ApplyPatchExtensionAPI, ApplyPatchWireMode } from "./types.ts";
3
+ export declare function getApplyPatchWireMode(model: Pick<Model<string>, "api" | "id"> | undefined): ApplyPatchWireMode;
3
4
  export declare function isOpenAIGptModel(model: Pick<Model<string>, "api" | "id"> | undefined): boolean;
4
5
  export declare function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void;
5
6
  export default registerApplyPatchExtension;
@@ -1 +1 @@
1
- {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAE,sBAAsB,EAAiB,MAAM,YAAY,CAAC;AAaxE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAE9F;AA+CD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAS5E;eAEc,2BAA2B"}
1
+ {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EACX,sBAAsB,EAGtB,kBAAkB,EAClB,MAAM,YAAY,CAAC;AAepB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,kBAAkB,CAK9G;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAE9F;AAkDD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAc5E;eAEc,2BAA2B"}
@@ -1,61 +1,80 @@
1
1
  import { createApplyPatchTool } from "./tool.js";
2
- // apply_patch ships as a freeform custom tool, which only the OpenAI Responses-family
3
- // APIs can carry (openai-completions throws on freeform tools). Gate on the model's API
4
- // rather than a provider allowlist so OpenAI-compatible custom providers (e.g. a proxy
5
- // exposing gpt-5.5 via openai-responses) also swap edit/write for apply_patch.
6
2
  const APPLY_PATCH_FREEFORM_APIS = new Set([
7
3
  "openai-responses",
8
4
  "azure-openai-responses",
9
5
  "openai-codex-responses",
10
6
  ]);
7
+ const APPLY_PATCH_JSON_APIS = new Set(["openai-completions"]);
11
8
  const EDIT_TOOL_NAMES = new Set(["write", "edit"]);
9
+ const APPLY_PATCH_NAME = "apply_patch";
10
+ function isGptId(model) {
11
+ return model?.id.startsWith("gpt-") ?? false;
12
+ }
13
+ export function getApplyPatchWireMode(model) {
14
+ if (!isGptId(model))
15
+ return "none";
16
+ if (APPLY_PATCH_FREEFORM_APIS.has(model.api))
17
+ return "freeform";
18
+ if (APPLY_PATCH_JSON_APIS.has(model.api))
19
+ return "json";
20
+ return "none";
21
+ }
12
22
  export function isOpenAIGptModel(model) {
13
- return model !== undefined && APPLY_PATCH_FREEFORM_APIS.has(model.api) && model.id.startsWith("gpt-");
23
+ return getApplyPatchWireMode(model) === "freeform";
14
24
  }
15
25
  function hasEditTools(toolNames) {
16
26
  return toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));
17
27
  }
18
28
  function withoutApplyPatch(toolNames) {
19
- return toolNames.filter((toolName) => toolName !== "apply_patch");
29
+ return toolNames.filter((toolName) => toolName !== APPLY_PATCH_NAME);
20
30
  }
21
31
  function replaceEditToolsWithApplyPatch(toolNames) {
32
+ const hadApplyPatch = toolNames.includes(APPLY_PATCH_NAME);
33
+ const insertIndex = toolNames.findIndex((toolName) => EDIT_TOOL_NAMES.has(toolName) || toolName === APPLY_PATCH_NAME);
22
34
  const filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));
23
- if (!hasEditTools(toolNames))
35
+ if (!hasEditTools(toolNames) && !hadApplyPatch)
24
36
  return filteredToolNames;
25
- return [...filteredToolNames, "apply_patch"];
26
- }
27
- function restoreEditToolsFromBaseline(currentToolNames, baselineToolNames) {
28
- const restoredToolNames = [
29
- ...withoutApplyPatch(currentToolNames),
30
- ...baselineToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName)),
31
- ];
32
- return [...new Set(restoredToolNames)];
37
+ const at = insertIndex === -1 ? filteredToolNames.length : Math.min(insertIndex, filteredToolNames.length);
38
+ return [...filteredToolNames.slice(0, at), APPLY_PATCH_NAME, ...filteredToolNames.slice(at)];
33
39
  }
34
- function syncToolset(pi, model, state) {
40
+ function syncToolset(pi, model, state, variants) {
41
+ const mode = getApplyPatchWireMode(model);
35
42
  const currentToolNames = pi.getActiveTools();
36
- if (isOpenAIGptModel(model)) {
37
- if (hasEditTools(currentToolNames))
38
- state.nonGptToolNames = withoutApplyPatch(currentToolNames);
43
+ if (mode !== "none") {
44
+ if (state.activeVariant !== mode) {
45
+ pi.registerTool(variants[mode]);
46
+ state.activeVariant = mode;
47
+ }
48
+ const activeEdit = currentToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName));
49
+ if (activeEdit.length > 0)
50
+ state.removedEditToolNames = activeEdit;
39
51
  pi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));
40
52
  return;
41
53
  }
42
- if (state.nonGptToolNames.length > 0) {
43
- const restoredToolNames = restoreEditToolsFromBaseline(currentToolNames, state.nonGptToolNames);
44
- state.nonGptToolNames = restoredToolNames;
45
- pi.setActiveTools(restoredToolNames);
54
+ if (state.removedEditToolNames.length === 0) {
55
+ if (currentToolNames.includes(APPLY_PATCH_NAME))
56
+ pi.setActiveTools(withoutApplyPatch(currentToolNames));
46
57
  return;
47
58
  }
48
- state.nonGptToolNames = withoutApplyPatch(currentToolNames);
49
- pi.setActiveTools(state.nonGptToolNames);
59
+ const registeredNames = new Set(pi.getAllTools().map((tool) => tool.name));
60
+ const restorable = state.removedEditToolNames.filter((toolName) => registeredNames.has(toolName));
61
+ const restored = [...withoutApplyPatch(currentToolNames), ...restorable];
62
+ state.removedEditToolNames = [];
63
+ pi.setActiveTools([...new Set(restored)]);
50
64
  }
51
65
  export function registerApplyPatchExtension(pi) {
52
- const state = { nonGptToolNames: [] };
53
- pi.registerTool(createApplyPatchTool());
66
+ const state = { removedEditToolNames: [] };
67
+ const variants = {
68
+ freeform: createApplyPatchTool("freeform"),
69
+ json: createApplyPatchTool("json"),
70
+ };
71
+ state.activeVariant = "freeform";
72
+ pi.registerTool(variants.freeform);
54
73
  pi.on("session_start", async (_event, ctx) => {
55
- syncToolset(pi, ctx.model, state);
74
+ syncToolset(pi, ctx.model, state, variants);
56
75
  });
57
76
  pi.on("model_select", async (event) => {
58
- syncToolset(pi, event.model, state);
77
+ syncToolset(pi, event.model, state, variants);
59
78
  });
60
79
  }
61
80
  export default registerApplyPatchExtension;
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,sFAAsF;AACtF,wFAAwF;AACxF,uFAAuF;AACvF,+EAA+E;AAC/E,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAM;IAC9C,kBAAkB;IAClB,wBAAwB;IACxB,wBAAwB;CACxB,CAAC,CAAC;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAEnD,MAAM,UAAU,gBAAgB,CAAC,KAAoD;IACpF,OAAO,KAAK,KAAK,SAAS,IAAI,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACvG,CAAC;AAED,SAAS,YAAY,CAAC,SAAmB;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ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,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,iBAAiB,GAAG,4BAA4B,CAAC,gBAAgB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QAChG,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC;QAC1C,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACrC,OAAO;IACR,CAAC;IAED,KAAK,CAAC,eAAe,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAC5D,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,EAA0B;IACrE,MAAM,KAAK,GAAkB,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;IACrD,EAAE,CAAC,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAC;IACxC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type { ApplyPatchExtensionAPI, BaselineState } from \"./types.ts\";\n\n// apply_patch ships as a freeform custom tool, which only the OpenAI Responses-family\n// APIs can carry (openai-completions throws on freeform tools). Gate on the model's API\n// rather than a provider allowlist so OpenAI-compatible custom providers (e.g. a proxy\n// exposing gpt-5.5 via openai-responses) also swap edit/write for apply_patch.\nconst APPLY_PATCH_FREEFORM_APIS = new Set<Api>([\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): boolean {\n\treturn model !== undefined && APPLY_PATCH_FREEFORM_APIS.has(model.api) && model.id.startsWith(\"gpt-\");\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== \"apply_patch\");\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames)) return filteredToolNames;\n\treturn [...filteredToolNames, \"apply_patch\"];\n}\n\nfunction restoreEditToolsFromBaseline(currentToolNames: string[], baselineToolNames: string[]): string[] {\n\tconst restoredToolNames = [\n\t\t...withoutApplyPatch(currentToolNames),\n\t\t...baselineToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName)),\n\t];\n\treturn [...new Set(restoredToolNames)];\n}\n\nfunction syncToolset(\n\tpi: Pick<ApplyPatchExtensionAPI, \"getActiveTools\" | \"setActiveTools\">,\n\tmodel: Model<string> | undefined,\n\tstate: BaselineState,\n): void {\n\tconst currentToolNames = pi.getActiveTools();\n\tif (isOpenAIGptModel(model)) {\n\t\tif (hasEditTools(currentToolNames)) state.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\n\tif (state.nonGptToolNames.length > 0) {\n\t\tconst restoredToolNames = restoreEditToolsFromBaseline(currentToolNames, state.nonGptToolNames);\n\t\tstate.nonGptToolNames = restoredToolNames;\n\t\tpi.setActiveTools(restoredToolNames);\n\t\treturn;\n\t}\n\n\tstate.nonGptToolNames = withoutApplyPatch(currentToolNames);\n\tpi.setActiveTools(state.nonGptToolNames);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: BaselineState = { nonGptToolNames: [] };\n\tpi.registerTool(createApplyPatchTool());\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/extension.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAQjD,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAM;IAC9C,kBAAkB;IAClB,wBAAwB;IACxB,wBAAwB;CACxB,CAAC,CAAC;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;AACnE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AACnD,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,SAAS,OAAO,CAAC,KAAoD;IACpE,OAAO,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAoD;IACzF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,UAAU,CAAC;IAChE,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IACxD,OAAO,MAAM,CAAC;AACf,C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,QAAQ,CAAC,CAAC,CAAC;IAClG,MAAM,QAAQ,GAAG,CAAC,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;IACzE,KAAK,CAAC,oBAAoB,GAAG,EAAE,CAAC;IAChC,EAAE,CAAC,cAAc,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,EAA0B;IACrE,MAAM,KAAK,GAAuE,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC;IAC/G,MAAM,QAAQ,GAAG;QAChB,QAAQ,EAAE,oBAAoB,CAAC,UAAU,CAAC;QAC1C,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC;KACzB,CAAC;IACX,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC;IACjC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACnC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE;QAC5C,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC","sourcesContent":["import type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { createApplyPatchTool } from \"./tool.ts\";\nimport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchToolsetState,\n\tApplyPatchToolVariant,\n\tApplyPatchWireMode,\n} from \"./types.ts\";\n\nconst APPLY_PATCH_FREEFORM_APIS = new Set<Api>([\n\t\"openai-responses\",\n\t\"azure-openai-responses\",\n\t\"openai-codex-responses\",\n]);\nconst APPLY_PATCH_JSON_APIS = new Set<Api>([\"openai-completions\"]);\nconst EDIT_TOOL_NAMES = new Set([\"write\", \"edit\"]);\nconst APPLY_PATCH_NAME = \"apply_patch\";\n\nfunction isGptId(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): model is Pick<Model<string>, \"api\" | \"id\"> {\n\treturn model?.id.startsWith(\"gpt-\") ?? false;\n}\n\nexport function getApplyPatchWireMode(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): ApplyPatchWireMode {\n\tif (!isGptId(model)) return \"none\";\n\tif (APPLY_PATCH_FREEFORM_APIS.has(model.api)) return \"freeform\";\n\tif (APPLY_PATCH_JSON_APIS.has(model.api)) return \"json\";\n\treturn \"none\";\n}\n\nexport function isOpenAIGptModel(model: Pick<Model<string>, \"api\" | \"id\"> | undefined): boolean {\n\treturn getApplyPatchWireMode(model) === \"freeform\";\n}\n\nfunction hasEditTools(toolNames: string[]): boolean {\n\treturn toolNames.some((toolName) => EDIT_TOOL_NAMES.has(toolName));\n}\n\nfunction withoutApplyPatch(toolNames: string[]): string[] {\n\treturn toolNames.filter((toolName) => toolName !== APPLY_PATCH_NAME);\n}\n\nfunction replaceEditToolsWithApplyPatch(toolNames: string[]): string[] {\n\tconst hadApplyPatch = toolNames.includes(APPLY_PATCH_NAME);\n\tconst insertIndex = toolNames.findIndex(\n\t\t(toolName) => EDIT_TOOL_NAMES.has(toolName) || toolName === APPLY_PATCH_NAME,\n\t);\n\tconst filteredToolNames = withoutApplyPatch(toolNames).filter((toolName) => !EDIT_TOOL_NAMES.has(toolName));\n\tif (!hasEditTools(toolNames) && !hadApplyPatch) return filteredToolNames;\n\tconst at = insertIndex === -1 ? filteredToolNames.length : Math.min(insertIndex, filteredToolNames.length);\n\treturn [...filteredToolNames.slice(0, at), APPLY_PATCH_NAME, ...filteredToolNames.slice(at)];\n}\n\nfunction syncToolset(\n\tpi: ApplyPatchExtensionAPI,\n\tmodel: Model<string> | undefined,\n\tstate: ApplyPatchToolsetState & { activeVariant?: ApplyPatchToolVariant },\n\tvariants: Readonly<Record<ApplyPatchToolVariant, ReturnType<typeof createApplyPatchTool>>>,\n): void {\n\tconst mode = getApplyPatchWireMode(model);\n\tconst currentToolNames = pi.getActiveTools();\n\tif (mode !== \"none\") {\n\t\tif (state.activeVariant !== mode) {\n\t\t\tpi.registerTool(variants[mode]);\n\t\t\tstate.activeVariant = mode;\n\t\t}\n\t\tconst activeEdit = currentToolNames.filter((toolName) => EDIT_TOOL_NAMES.has(toolName));\n\t\tif (activeEdit.length > 0) state.removedEditToolNames = activeEdit;\n\t\tpi.setActiveTools(replaceEditToolsWithApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\tif (state.removedEditToolNames.length === 0) {\n\t\tif (currentToolNames.includes(APPLY_PATCH_NAME)) pi.setActiveTools(withoutApplyPatch(currentToolNames));\n\t\treturn;\n\t}\n\tconst registeredNames = new Set(pi.getAllTools().map((tool) => tool.name));\n\tconst restorable = state.removedEditToolNames.filter((toolName) => registeredNames.has(toolName));\n\tconst restored = [...withoutApplyPatch(currentToolNames), ...restorable];\n\tstate.removedEditToolNames = [];\n\tpi.setActiveTools([...new Set(restored)]);\n}\n\nexport function registerApplyPatchExtension(pi: ApplyPatchExtensionAPI): void {\n\tconst state: ApplyPatchToolsetState & { activeVariant?: ApplyPatchToolVariant } = { removedEditToolNames: [] };\n\tconst variants = {\n\t\tfreeform: createApplyPatchTool(\"freeform\"),\n\t\tjson: createApplyPatchTool(\"json\"),\n\t} as const;\n\tstate.activeVariant = \"freeform\";\n\tpi.registerTool(variants.freeform);\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsyncToolset(pi, ctx.model, state, variants);\n\t});\n\tpi.on(\"model_select\", async (event) => {\n\t\tsyncToolset(pi, event.model, state, variants);\n\t});\n}\n\nexport default registerApplyPatchExtension;\n"]}
@@ -1,7 +1,7 @@
1
1
  export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from "./apply.ts";
2
- export { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS, CODEX_APPLY_PATCH_DESCRIPTION, } from "./constants.ts";
2
+ export { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_JSON_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS, CODEX_APPLY_PATCH_DESCRIPTION, } from "./constants.ts";
3
3
  export { ApplyPatchError } from "./errors.ts";
4
- export { default, isOpenAIGptModel, registerApplyPatchExtension } from "./extension.ts";
4
+ export { default, getApplyPatchWireMode, isOpenAIGptModel, registerApplyPatchExtension } from "./extension.ts";
5
5
  export { parsePatch } from "./parser.ts";
6
6
  export { clearApplyPatchRenderState, displayPath, formatInFlightCallText, formatPatchPreview, getApplyPatchRenderState, PATCH_PREVIEW_MAX_CHARS, PATCH_PREVIEW_MAX_LINES, renderPatchPreview, truncatePreview, } from "./preview-format.ts";
7
7
  export { seekSequence } from "./seek-sequence.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACV,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACX,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,UAAU,GACV,MAAM,YAAY,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from "./apply.js";
2
- export { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS, CODEX_APPLY_PATCH_DESCRIPTION, } from "./constants.js";
2
+ export { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_JSON_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS, CODEX_APPLY_PATCH_DESCRIPTION, } from "./constants.js";
3
3
  export { ApplyPatchError } from "./errors.js";
4
- export { default, isOpenAIGptModel, registerApplyPatchExtension } from "./extension.js";
4
+ export { default, getApplyPatchWireMode, isOpenAIGptModel, registerApplyPatchExtension } from "./extension.js";
5
5
  export { parsePatch } from "./parser.js";
6
6
  export { clearApplyPatchRenderState, displayPath, formatInFlightCallText, formatPatchPreview, getApplyPatchRenderState, PATCH_PREVIEW_MAX_CHARS, PATCH_PREVIEW_MAX_LINES, renderPatchPreview, truncatePreview, } from "./preview-format.js";
7
7
  export { seekSequence } from "./seek-sequence.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nexport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n\tCODEX_APPLY_PATCH_DESCRIPTION,\n} from \"./constants.ts\";\nexport { ApplyPatchError } from \"./errors.ts\";\nexport { default, isOpenAIGptModel, registerApplyPatchExtension } from \"./extension.ts\";\nexport { parsePatch } from \"./parser.ts\";\nexport {\n\tclearApplyPatchRenderState,\n\tdisplayPath,\n\tformatInFlightCallText,\n\tformatPatchPreview,\n\tgetApplyPatchRenderState,\n\tPATCH_PREVIEW_MAX_CHARS,\n\tPATCH_PREVIEW_MAX_LINES,\n\trenderPatchPreview,\n\ttruncatePreview,\n} from \"./preview-format.ts\";\nexport { seekSequence } from \"./seek-sequence.ts\";\nexport { StreamingPatchParser } from \"./streaming-parser.ts\";\nexport { extractPatchedPaths, normalizePatchText, stripHeredoc } from \"./text.ts\";\nexport { createApplyPatchTool } from \"./tool.ts\";\nexport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchFailure,\n\tApplyPatchParams,\n\tApplyPatchPreview,\n\tApplyPatchProgress,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tAtomicWriteOperations,\n\tFreeformToolFormat,\n\tParsedPatch,\n\tPatchChunk,\n} from \"./types.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EACN,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,0BAA0B,EAC1B,WAAW,EACX,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { __testWriteFileAtomic, applyPatch, applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nexport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n\tCODEX_APPLY_PATCH_DESCRIPTION,\n} from \"./constants.ts\";\nexport { ApplyPatchError } from \"./errors.ts\";\nexport { default, getApplyPatchWireMode, isOpenAIGptModel, registerApplyPatchExtension } from \"./extension.ts\";\nexport { parsePatch } from \"./parser.ts\";\nexport {\n\tclearApplyPatchRenderState,\n\tdisplayPath,\n\tformatInFlightCallText,\n\tformatPatchPreview,\n\tgetApplyPatchRenderState,\n\tPATCH_PREVIEW_MAX_CHARS,\n\tPATCH_PREVIEW_MAX_LINES,\n\trenderPatchPreview,\n\ttruncatePreview,\n} from \"./preview-format.ts\";\nexport { seekSequence } from \"./seek-sequence.ts\";\nexport { StreamingPatchParser } from \"./streaming-parser.ts\";\nexport { extractPatchedPaths, normalizePatchText, stripHeredoc } from \"./text.ts\";\nexport { createApplyPatchTool } from \"./tool.ts\";\nexport type {\n\tApplyPatchExtensionAPI,\n\tApplyPatchFailure,\n\tApplyPatchParams,\n\tApplyPatchPreview,\n\tApplyPatchProgress,\n\tApplyPatchProgressCallback,\n\tApplyPatchRecoveryInstructions,\n\tApplyPatchRenderState,\n\tApplyPatchResult,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tAtomicWriteOperations,\n\tFreeformToolFormat,\n\tParsedPatch,\n\tPatchChunk,\n} from \"./types.ts\";\n"]}
@@ -1,3 +1,3 @@
1
1
  import type { ApplyPatchToolDefinition } from "./types.ts";
2
- export declare function createApplyPatchTool(): ApplyPatchToolDefinition;
2
+ export declare function createApplyPatchTool(variant?: "freeform" | "json"): ApplyPatchToolDefinition;
3
3
  //# sourceMappingURL=tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAGX,wBAAwB,EAGxB,MAAM,YAAY,CAAC;AAqCpB,wBAAgB,oBAAoB,IAAI,wBAAwB,CA2F/D"}
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAGX,wBAAwB,EAGxB,MAAM,YAAY,CAAC;AAqCpB,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,UAAU,GAAG,MAAmB,GAAG,wBAAwB,CA4FxG"}
@@ -1,7 +1,7 @@
1
1
  import { Box, Container, Spacer, Text } from "@earendil-works/pi-tui";
2
2
  import { defineTool } from "../../types.js";
3
3
  import { applyPatchDetailed, buildPartialFailureText } from "./apply.js";
4
- import { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS } from "./constants.js";
4
+ import { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_JSON_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS, } from "./constants.js";
5
5
  import { normalizeApplyPatchArguments } from "./params.js";
6
6
  import { parsePatch } from "./parser.js";
7
7
  import { createPendingPatchUpdate } from "./preview.js";
@@ -32,11 +32,11 @@ function renderTextResult(result, theme) {
32
32
  component.addChild(new Text(theme.fg("toolOutput", text), 0, 0));
33
33
  return component;
34
34
  }
35
- export function createApplyPatchTool() {
35
+ export function createApplyPatchTool(variant = "freeform") {
36
36
  const tool = defineTool({
37
37
  name: "apply_patch",
38
38
  label: "ApplyPatch",
39
- description: APPLY_PATCH_FREEFORM_DESCRIPTION,
39
+ description: variant === "json" ? APPLY_PATCH_JSON_DESCRIPTION : APPLY_PATCH_FREEFORM_DESCRIPTION,
40
40
  parameters: APPLY_PATCH_PARAMS,
41
41
  prepareArguments: normalizeApplyPatchArguments,
42
42
  promptSnippet: "Apply Codex-format file patches with apply_patch",
@@ -109,6 +109,8 @@ export function createApplyPatchTool() {
109
109
  return renderTextResult(result, theme);
110
110
  },
111
111
  });
112
+ if (variant === "json")
113
+ return tool;
112
114
  return Object.assign(tool, {
113
115
  freeform: { type: "grammar", syntax: "lark", definition: APPLY_PATCH_LARK_GRAMMAR },
114
116
  });
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AASjE,SAAS,gBAAgB,CACxB,KAAa,EACb,OAA8B,EAC9B,SAAkB,EAClB,GAAW,EACX,QAAiB,EAC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CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;oBACvE,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACxG,CAAC;gBACD,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACD,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAA+B;KAChH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Box, Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext } from \"../../types.ts\";\nimport { defineTool } from \"../../types.ts\";\nimport { applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nimport { APPLY_PATCH_FREEFORM_DESCRIPTION, APPLY_PATCH_LARK_GRAMMAR, APPLY_PATCH_PARAMS } from \"./constants.ts\";\nimport { normalizeApplyPatchArguments } from \"./params.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { createPendingPatchUpdate } from \"./preview.ts\";\nimport { getApplyPatchRenderState, renderPatchPreview } from \"./preview-format.ts\";\nimport { renderStreamingPatchCall } from \"./streaming-render.ts\";\nimport type {\n\tApplyPatchRenderState,\n\tApplyPatchTheme,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tFreeformToolFormat,\n} from \"./types.ts\";\n\nfunction renderPreviewBox(\n\ttitle: string,\n\tdetails: ApplyPatchToolDetails,\n\tisPartial: boolean,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tif (!details.preview) return component;\n\tconst bgName = isPartial ? \"toolPendingBg\" : \"toolSuccessBg\";\n\tconst progress = details.progress;\n\tconst renderedTitle = progress ? `Applying patch (${progress.applied + progress.failed}/${progress.total})` : title;\n\tconst box = new Box(1, 1, (text: string) => theme.bg(bgName, text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(renderedTitle)), 0, 0));\n\tbox.addChild(new Spacer(1));\n\tbox.addChild(new Text(renderPatchPreview(details.preview, cwd, theme, expanded), 0, 0));\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nfunction renderTextResult(\n\tresult: AgentToolResult<ApplyPatchToolDetails | undefined>,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tconst text = result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.filter((value) => typeof value === \"string\" && value.length > 0)\n\t\t.join(\"\\n\");\n\tif (text) component.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\treturn component;\n}\n\nexport function createApplyPatchTool(): ApplyPatchToolDefinition {\n\tconst tool = defineTool<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>({\n\t\tname: \"apply_patch\",\n\t\tlabel: \"ApplyPatch\",\n\t\tdescription: APPLY_PATCH_FREEFORM_DESCRIPTION,\n\t\tparameters: APPLY_PATCH_PARAMS,\n\t\tprepareArguments: normalizeApplyPatchArguments,\n\t\tpromptSnippet: \"Apply Codex-format file patches with apply_patch\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use apply_patch for file edits instead of mutating files through bash, Python scripts, heredocs, or shell redirection.\",\n\t\t\t\"After apply_patch succeeds, do not re-read the edited files just to confirm the patch applied.\",\n\t\t],\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tparams,\n\t\t\t_signal,\n\t\t\tonUpdate,\n\t\t\tctx,\n\t\t): Promise<AgentToolResult<ApplyPatchToolDetails | undefined>> {\n\t\t\tconst normalizedParams = normalizeApplyPatchArguments(params);\n\t\t\tif (!normalizedParams.input) throw new Error(\"input is required\");\n\t\t\tlet totalOperations = 0;\n\t\t\ttry {\n\t\t\t\ttotalOperations = parsePatch(normalizedParams.input).length;\n\t\t\t} catch {\n\t\t\t\t// createPendingPatchUpdate keeps incomplete or invalid patch text renderable.\n\t\t\t}\n\t\t\tconst initialProgress = totalOperations > 0 ? { applied: 0, failed: 0, total: totalOperations } : undefined;\n\t\t\tconst pendingUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, initialProgress);\n\t\t\tonUpdate?.({ content: [{ type: \"text\", text: pendingUpdate.text }], details: pendingUpdate.details });\n\t\t\tconst preview = pendingUpdate.details?.preview;\n\t\t\tconst result = await applyPatchDetailed(ctx.cwd, normalizedParams.input, async (progress) => {\n\t\t\t\tconst progressUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, progress, preview);\n\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: progressUpdate.text }], details: progressUpdate.details });\n\t\t\t});\n\t\t\tif (result.failures.length > 0) {\n\t\t\t\tif (result.appliedFiles.length === 0) {\n\t\t\t\t\tconst firstFailure = result.failures[0];\n\t\t\t\t\tif (firstFailure) throw new Error(firstFailure.message);\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: buildPartialFailureText(result) }], details: { result } };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.summaries.join(\"\\n\") }],\n\t\t\t\tdetails: pendingUpdate.details?.preview ? { preview: pendingUpdate.details.preview, result } : { result },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context: ToolRenderContext<ApplyPatchRenderState, { input: string }>) {\n\t\t\tif (!context.executionStarted) {\n\t\t\t\tconst streaming = renderStreamingPatchCall(normalizeApplyPatchArguments(args), theme, context.state);\n\t\t\t\tif (streaming) return streaming;\n\t\t\t}\n\t\t\tif (!context.argsComplete) return new Text(theme.fg(\"toolTitle\", theme.bold(\"apply_patch: Patching\")), 0, 0);\n\t\t\tconst normalizedArgs = normalizeApplyPatchArguments(args);\n\t\t\tconst renderState = getApplyPatchRenderState(context.toolCallId, context.cwd, normalizedArgs.input);\n\t\t\tconst text = renderState.callText?.length ? `apply_patch: ${renderState.callText}` : \"apply_patch\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(text)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tif (result.details?.preview) {\n\t\t\t\tconst expanded = true;\n\t\t\t\treturn renderPreviewBox(\n\t\t\t\t\toptions.isPartial ? \"Applying patch\" : \"Applied patch\",\n\t\t\t\t\tresult.details,\n\t\t\t\t\toptions.isPartial,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\texpanded,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (result.details?.result) {\n\t\t\t\tconst component = new Container();\n\t\t\t\tconst box = new Box(1, 1, (text: string) =>\n\t\t\t\t\ttheme.bg(options.isPartial ? \"toolPendingBg\" : \"toolSuccessBg\", text),\n\t\t\t\t);\n\t\t\t\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(\"Applying patch\")), 0, 0));\n\t\t\t\tbox.addChild(new Spacer(1));\n\t\t\t\tif (result.details.preview) {\n\t\t\t\t\tconst expanded = options.isPartial ? true : (options.expanded ?? true);\n\t\t\t\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, context.cwd, theme, expanded), 0, 0));\n\t\t\t\t}\n\t\t\t\tcomponent.addChild(box);\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\treturn renderTextResult(result, theme);\n\t\t},\n\t});\n\n\treturn Object.assign(tool, {\n\t\tfreeform: { type: \"grammar\", syntax: \"lark\", definition: APPLY_PATCH_LARK_GRAMMAR } satisfies FreeformToolFormat,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YACD,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;KACD,CAAC,CAAC;IAEH,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,wBAAwB,EAA+B;KAChH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Box, Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport type { AgentToolResult, ToolRenderContext } from \"../../types.ts\";\nimport { defineTool } from \"../../types.ts\";\nimport { applyPatchDetailed, buildPartialFailureText } from \"./apply.ts\";\nimport {\n\tAPPLY_PATCH_FREEFORM_DESCRIPTION,\n\tAPPLY_PATCH_JSON_DESCRIPTION,\n\tAPPLY_PATCH_LARK_GRAMMAR,\n\tAPPLY_PATCH_PARAMS,\n} from \"./constants.ts\";\nimport { normalizeApplyPatchArguments } from \"./params.ts\";\nimport { parsePatch } from \"./parser.ts\";\nimport { createPendingPatchUpdate } from \"./preview.ts\";\nimport { getApplyPatchRenderState, renderPatchPreview } from \"./preview-format.ts\";\nimport { renderStreamingPatchCall } from \"./streaming-render.ts\";\nimport type {\n\tApplyPatchRenderState,\n\tApplyPatchTheme,\n\tApplyPatchToolDefinition,\n\tApplyPatchToolDetails,\n\tFreeformToolFormat,\n} from \"./types.ts\";\n\nfunction renderPreviewBox(\n\ttitle: string,\n\tdetails: ApplyPatchToolDetails,\n\tisPartial: boolean,\n\tcwd: string,\n\texpanded: boolean,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tif (!details.preview) return component;\n\tconst bgName = isPartial ? \"toolPendingBg\" : \"toolSuccessBg\";\n\tconst progress = details.progress;\n\tconst renderedTitle = progress ? `Applying patch (${progress.applied + progress.failed}/${progress.total})` : title;\n\tconst box = new Box(1, 1, (text: string) => theme.bg(bgName, text));\n\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(renderedTitle)), 0, 0));\n\tbox.addChild(new Spacer(1));\n\tbox.addChild(new Text(renderPatchPreview(details.preview, cwd, theme, expanded), 0, 0));\n\tcomponent.addChild(box);\n\treturn component;\n}\n\nfunction renderTextResult(\n\tresult: AgentToolResult<ApplyPatchToolDetails | undefined>,\n\ttheme: ApplyPatchTheme,\n): Container {\n\tconst component = new Container();\n\tconst text = result.content\n\t\t.filter((block) => block.type === \"text\")\n\t\t.map((block) => block.text)\n\t\t.filter((value) => typeof value === \"string\" && value.length > 0)\n\t\t.join(\"\\n\");\n\tif (text) component.addChild(new Text(theme.fg(\"toolOutput\", text), 0, 0));\n\treturn component;\n}\n\nexport function createApplyPatchTool(variant: \"freeform\" | \"json\" = \"freeform\"): ApplyPatchToolDefinition {\n\tconst tool = defineTool<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>({\n\t\tname: \"apply_patch\",\n\t\tlabel: \"ApplyPatch\",\n\t\tdescription: variant === \"json\" ? APPLY_PATCH_JSON_DESCRIPTION : APPLY_PATCH_FREEFORM_DESCRIPTION,\n\t\tparameters: APPLY_PATCH_PARAMS,\n\t\tprepareArguments: normalizeApplyPatchArguments,\n\t\tpromptSnippet: \"Apply Codex-format file patches with apply_patch\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use apply_patch for file edits instead of mutating files through bash, Python scripts, heredocs, or shell redirection.\",\n\t\t\t\"After apply_patch succeeds, do not re-read the edited files just to confirm the patch applied.\",\n\t\t],\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tparams,\n\t\t\t_signal,\n\t\t\tonUpdate,\n\t\t\tctx,\n\t\t): Promise<AgentToolResult<ApplyPatchToolDetails | undefined>> {\n\t\t\tconst normalizedParams = normalizeApplyPatchArguments(params);\n\t\t\tif (!normalizedParams.input) throw new Error(\"input is required\");\n\t\t\tlet totalOperations = 0;\n\t\t\ttry {\n\t\t\t\ttotalOperations = parsePatch(normalizedParams.input).length;\n\t\t\t} catch {\n\t\t\t\t// createPendingPatchUpdate keeps incomplete or invalid patch text renderable.\n\t\t\t}\n\t\t\tconst initialProgress = totalOperations > 0 ? { applied: 0, failed: 0, total: totalOperations } : undefined;\n\t\t\tconst pendingUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, initialProgress);\n\t\t\tonUpdate?.({ content: [{ type: \"text\", text: pendingUpdate.text }], details: pendingUpdate.details });\n\t\t\tconst preview = pendingUpdate.details?.preview;\n\t\t\tconst result = await applyPatchDetailed(ctx.cwd, normalizedParams.input, async (progress) => {\n\t\t\t\tconst progressUpdate = await createPendingPatchUpdate(ctx.cwd, normalizedParams.input, progress, preview);\n\t\t\t\tonUpdate?.({ content: [{ type: \"text\", text: progressUpdate.text }], details: progressUpdate.details });\n\t\t\t});\n\t\t\tif (result.failures.length > 0) {\n\t\t\t\tif (result.appliedFiles.length === 0) {\n\t\t\t\t\tconst firstFailure = result.failures[0];\n\t\t\t\t\tif (firstFailure) throw new Error(firstFailure.message);\n\t\t\t\t}\n\t\t\t\treturn { content: [{ type: \"text\", text: buildPartialFailureText(result) }], details: { result } };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: result.summaries.join(\"\\n\") }],\n\t\t\t\tdetails: pendingUpdate.details?.preview ? { preview: pendingUpdate.details.preview, result } : { result },\n\t\t\t};\n\t\t},\n\t\trenderCall(args, theme, context: ToolRenderContext<ApplyPatchRenderState, { input: string }>) {\n\t\t\tif (!context.executionStarted) {\n\t\t\t\tconst streaming = renderStreamingPatchCall(normalizeApplyPatchArguments(args), theme, context.state);\n\t\t\t\tif (streaming) return streaming;\n\t\t\t}\n\t\t\tif (!context.argsComplete) return new Text(theme.fg(\"toolTitle\", theme.bold(\"apply_patch: Patching\")), 0, 0);\n\t\t\tconst normalizedArgs = normalizeApplyPatchArguments(args);\n\t\t\tconst renderState = getApplyPatchRenderState(context.toolCallId, context.cwd, normalizedArgs.input);\n\t\t\tconst text = renderState.callText?.length ? `apply_patch: ${renderState.callText}` : \"apply_patch\";\n\t\t\treturn new Text(theme.fg(\"toolTitle\", theme.bold(text)), 0, 0);\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tif (result.details?.preview) {\n\t\t\t\tconst expanded = true;\n\t\t\t\treturn renderPreviewBox(\n\t\t\t\t\toptions.isPartial ? \"Applying patch\" : \"Applied patch\",\n\t\t\t\t\tresult.details,\n\t\t\t\t\toptions.isPartial,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\texpanded,\n\t\t\t\t\ttheme,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (result.details?.result) {\n\t\t\t\tconst component = new Container();\n\t\t\t\tconst box = new Box(1, 1, (text: string) =>\n\t\t\t\t\ttheme.bg(options.isPartial ? \"toolPendingBg\" : \"toolSuccessBg\", text),\n\t\t\t\t);\n\t\t\t\tbox.addChild(new Text(theme.fg(\"toolTitle\", theme.bold(\"Applying patch\")), 0, 0));\n\t\t\t\tbox.addChild(new Spacer(1));\n\t\t\t\tif (result.details.preview) {\n\t\t\t\t\tconst expanded = options.isPartial ? true : (options.expanded ?? true);\n\t\t\t\t\tbox.addChild(new Text(renderPatchPreview(result.details.preview, context.cwd, theme, expanded), 0, 0));\n\t\t\t\t}\n\t\t\t\tcomponent.addChild(box);\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\treturn renderTextResult(result, theme);\n\t\t},\n\t});\n\n\tif (variant === \"json\") return tool;\n\treturn Object.assign(tool, {\n\t\tfreeform: { type: \"grammar\", syntax: \"lark\", definition: APPLY_PATCH_LARK_GRAMMAR } satisfies FreeformToolFormat,\n\t});\n}\n"]}
@@ -19,8 +19,11 @@ export type PatchChunk = {
19
19
  newLines: string[];
20
20
  isEndOfFile: boolean;
21
21
  };
22
- export type BaselineState = {
23
- nonGptToolNames: string[];
22
+ export type ApplyPatchWireMode = "freeform" | "json" | "none";
23
+ export type ApplyPatchToolVariant = Exclude<ApplyPatchWireMode, "none">;
24
+ export type ApplyPatchToolsetState = {
25
+ /** Exactly the edit-family tools this extension removed at the last non-GPT to GPT transition. */
26
+ removedEditToolNames: string[];
24
27
  };
25
28
  export type FreeformToolFormat = {
26
29
  type: "grammar";
@@ -100,10 +103,8 @@ export type ApplyPatchRenderState = {
100
103
  streamingHunks?: ParsedPatch[];
101
104
  streamingError?: string;
102
105
  };
103
- export type ApplyPatchToolDefinition = ToolDefinition<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState> & {
104
- freeform: FreeformToolFormat;
105
- };
106
- export type ApplyPatchExtensionAPI = Pick<ExtensionAPI, "on" | "getActiveTools" | "setActiveTools"> & {
106
+ export type ApplyPatchToolDefinition = ToolDefinition<typeof APPLY_PATCH_PARAMS, ApplyPatchToolDetails | undefined, ApplyPatchRenderState>;
107
+ export type ApplyPatchExtensionAPI = Pick<ExtensionAPI, "on" | "getActiveTools" | "getAllTools" | "setActiveTools"> & {
107
108
  registerTool: (tool: ApplyPatchToolDefinition) => void;
108
109
  };
109
110
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/gpt-apply-patch/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,MAAM,WAAW,GACpB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ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