pi-agent-ide 0.8.1 → 0.8.3

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 (417) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +5 -3
  3. package/dist/{chunk-TGC2ZACO.js → chunk-235QMMVA.js} +1 -1
  4. package/dist/{chunk-OI3HBIPK.js → chunk-4DIUPEDF.js} +1 -1
  5. package/dist/{chunk-2ITKAXHO.js → chunk-6FGLAVPJ.js} +1 -1
  6. package/dist/{chunk-7LOVUWNI.js → chunk-6H32W35W.js} +1 -1
  7. package/dist/{chunk-YHREORHH.js → chunk-6OJ565FL.js} +1 -1
  8. package/dist/{chunk-E2PHA4SQ.js → chunk-6R3Y4AD3.js} +1 -1
  9. package/dist/{chunk-VNTY7BKC.js → chunk-6T7PSDQW.js} +1 -1
  10. package/dist/{chunk-D4IA2MTA.js → chunk-6TJPMBUQ.js} +1 -1
  11. package/dist/{chunk-JKMXND6V.js → chunk-6XFUICD7.js} +1 -1
  12. package/dist/{chunk-A64JRDZK.js → chunk-AAC77UD4.js} +1 -1
  13. package/dist/{chunk-HFJGCYFO.js → chunk-ANM3Y5FO.js} +5 -5
  14. package/dist/{chunk-Q5X6OXNS.js → chunk-CPELC6JE.js} +1 -1
  15. package/dist/chunk-GBUJOR6V.js +28 -0
  16. package/dist/{chunk-3WO2NOEQ.js → chunk-GSOYVIQS.js} +1 -1
  17. package/dist/{chunk-AIT3YWR5.js → chunk-HSRH76JN.js} +1 -1
  18. package/dist/{chunk-ID4RJIVZ.js → chunk-HSZ4AQ6L.js} +1 -1
  19. package/dist/chunk-I6NPILT5.js +1 -0
  20. package/dist/chunk-K7SRNBIV.js +1 -0
  21. package/dist/{chunk-DXONCYWF.js → chunk-LCWBVOII.js} +3 -3
  22. package/dist/{chunk-EMRJP6EM.js → chunk-LEJKDYCK.js} +1 -1
  23. package/dist/{chunk-HCK7OIQ3.js → chunk-NJ7C4KMA.js} +1 -1
  24. package/dist/{chunk-BQAKA3FU.js → chunk-NUM3YQGK.js} +1 -1
  25. package/dist/chunk-OJEIX7OZ.js +1 -0
  26. package/dist/chunk-PBQDHYNX.js +1 -0
  27. package/dist/{chunk-4HWKBCBH.js → chunk-PJL3UVMJ.js} +1 -1
  28. package/dist/chunk-PT35ZFLH.js +33 -0
  29. package/dist/{chunk-AKNHSDGV.js → chunk-QT3EAHOG.js} +1 -1
  30. package/dist/{chunk-LLRUJD62.js → chunk-RIJMXO43.js} +1 -1
  31. package/dist/chunk-RMI3NMQY.js +23 -0
  32. package/dist/chunk-RQ7JJ7GV.js +4 -0
  33. package/dist/{chunk-AUL5FGGK.js → chunk-RVU73VKN.js} +1 -1
  34. package/dist/{chunk-WPBQ45ZL.js → chunk-RW2GTYQI.js} +1 -1
  35. package/dist/{chunk-BR7GRH4A.js → chunk-SDAH3ECM.js} +1 -1
  36. package/dist/chunk-SGQWRIRJ.js +10 -0
  37. package/dist/{chunk-N56WAVYA.js → chunk-SMIFCAAX.js} +1 -1
  38. package/dist/chunk-SWBJS3U4.js +1 -0
  39. package/dist/{chunk-WXGTU2M6.js → chunk-VMTOFEXF.js} +1 -1
  40. package/dist/{chunk-GEMDU6XW.js → chunk-VXP5BMW7.js} +1 -1
  41. package/dist/{chunk-LAJQSHEI.js → chunk-XAHU42FP.js} +3 -3
  42. package/dist/{chunk-ZV5ETNLQ.js → chunk-XBQR74IK.js} +1 -1
  43. package/dist/{chunk-TXG2H7YQ.js → chunk-XG7QNAKW.js} +1 -1
  44. package/dist/{chunk-PRLIHLCS.js → chunk-XLWCSJMR.js} +1 -1
  45. package/dist/{chunk-M4TVRCMZ.js → chunk-XXLLY66B.js} +1 -1
  46. package/dist/chunk-YFP4P2FV.js +1 -0
  47. package/dist/{chunk-SWA5B5B2.js → chunk-YIXP2ALP.js} +1 -1
  48. package/dist/{chunk-246NTPOS.js → chunk-ZJQRLVVV.js} +1 -1
  49. package/dist/entry-0.js +1 -1
  50. package/dist/entry-1.js +1 -1
  51. package/dist/entry-10.js +1 -1
  52. package/dist/entry-11.js +1 -1
  53. package/dist/entry-12.js +1 -1
  54. package/dist/entry-13.js +1 -1
  55. package/dist/entry-14.js +1 -1
  56. package/dist/entry-15.js +1 -1
  57. package/dist/entry-16.js +1 -1
  58. package/dist/entry-17.js +1 -1
  59. package/dist/entry-18.js +1 -1
  60. package/dist/entry-19.js +1 -0
  61. package/dist/entry-2.js +1 -1
  62. package/dist/entry-20.js +1 -1
  63. package/dist/entry-22.js +1 -1
  64. package/dist/entry-23.js +1 -1
  65. package/dist/entry-24.js +1 -1
  66. package/dist/entry-25.js +1 -1
  67. package/dist/entry-26.js +1 -1
  68. package/dist/entry-27.js +1 -2
  69. package/dist/entry-28.js +1 -1
  70. package/dist/entry-29.js +2 -4
  71. package/dist/entry-3.js +1 -1
  72. package/dist/entry-30.js +1 -1
  73. package/dist/entry-31.js +4 -1
  74. package/dist/entry-32.js +1 -1
  75. package/dist/entry-33.js +1 -18
  76. package/dist/entry-34.js +1 -1
  77. package/dist/entry-35.js +18 -1
  78. package/dist/entry-36.js +1 -1
  79. package/dist/entry-37.js +1 -1
  80. package/dist/entry-38.js +1 -1
  81. package/dist/entry-39.js +1 -1
  82. package/dist/entry-4.js +1 -1
  83. package/dist/entry-40.js +1 -1
  84. package/dist/entry-41.js +1 -1
  85. package/dist/entry-42.js +1 -1
  86. package/dist/entry-43.js +1 -1
  87. package/dist/entry-44.js +1 -1
  88. package/dist/entry-45.js +1 -1
  89. package/dist/entry-46.js +1 -1
  90. package/dist/entry-47.js +1 -25
  91. package/dist/entry-48.js +1 -1
  92. package/dist/entry-49.js +25 -1
  93. package/dist/entry-5.js +1 -1
  94. package/dist/entry-50.js +1 -1
  95. package/dist/entry-51.js +1 -1
  96. package/dist/entry-52.js +1 -3
  97. package/dist/entry-53.js +1 -13
  98. package/dist/entry-54.js +3 -1
  99. package/dist/entry-55.js +13 -1
  100. package/dist/entry-56.js +1 -1
  101. package/dist/entry-57.js +1 -1
  102. package/dist/entry-58.js +1 -1
  103. package/dist/entry-59.js +1 -1
  104. package/dist/entry-6.js +1 -1
  105. package/dist/entry-60.js +1 -1
  106. package/dist/entry-61.js +1 -1
  107. package/dist/entry-62.js +1 -1
  108. package/dist/entry-63.js +1 -0
  109. package/dist/entry-64.js +1 -1
  110. package/dist/entry-66.js +1 -1
  111. package/dist/entry-67.js +0 -1
  112. package/dist/entry-68.js +1 -1
  113. package/dist/entry-69.js +1 -1
  114. package/dist/entry-7.js +1 -1
  115. package/dist/entry-70.js +1 -1
  116. package/dist/entry-71.js +1 -1
  117. package/dist/entry-72.js +1 -1
  118. package/dist/entry-73.js +1 -0
  119. package/dist/entry-74.js +1 -1
  120. package/dist/entry-76.js +1 -1
  121. package/dist/entry-77.js +0 -1
  122. package/dist/entry-78.js +1 -1
  123. package/dist/entry-79.js +1 -80
  124. package/dist/entry-8.js +1 -1
  125. package/dist/entry-80.js +1 -22
  126. package/dist/entry-81.js +80 -2
  127. package/dist/entry-82.js +22 -1
  128. package/dist/entry-83.js +2 -1
  129. package/dist/entry-84.js +1 -1
  130. package/dist/entry-85.js +1 -3
  131. package/dist/entry-86.js +1 -1
  132. package/dist/entry-87.js +1 -1
  133. package/dist/entry-88.js +3 -1
  134. package/dist/entry-89.js +1 -0
  135. package/dist/entry-9.js +1 -1
  136. package/dist/entry-90.js +1 -0
  137. package/dist/entry-91.js +1 -0
  138. package/dist/pi-agent-ide.js +29 -36
  139. package/docs/agent-guides/debugger.md +2 -0
  140. package/docs/agent-guides/editing.md +3 -3
  141. package/docs/agent-guides/search-code.md +2 -2
  142. package/docs/agent-guides/select-code.md +9 -6
  143. package/docs/code-review.md +5 -0
  144. package/docs/configuration.md +36 -4
  145. package/docs/development.md +8 -0
  146. package/docs/directory-operations.md +1 -1
  147. package/docs/extensions.md +98 -1
  148. package/docs/structured-results.md +11 -6
  149. package/docs/user-hooks.md +2 -2
  150. package/node_modules/pi-agent-doctor/package.json +7 -7
  151. package/node_modules/pi-agent-doctor/runtime/entry-27.js +1 -0
  152. package/node_modules/pi-agent-documentation/package.json +2 -2
  153. package/node_modules/pi-agent-documentation/runtime/entry-28.js +1 -0
  154. package/node_modules/pi-agent-filesystem/package.json +8 -8
  155. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  156. package/node_modules/pi-agent-filesystem-jq/package.json +6 -6
  157. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  158. package/node_modules/pi-agent-filesystem-pdf/runtime/entry-32.js +2 -0
  159. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  160. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  161. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +6 -5
  162. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  163. package/node_modules/pi-agent-ide-changes/runtime/entry-36.js +1 -0
  164. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
  165. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  166. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  167. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  168. package/node_modules/pi-agent-ide-lint/runtime/entry-40.js +2 -0
  169. package/node_modules/pi-agent-ide-lsp/package.json +10 -10
  170. package/node_modules/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
  171. package/node_modules/pi-agent-image/package.json +3 -3
  172. package/node_modules/pi-agent-invariant/package.json +2 -2
  173. package/node_modules/pi-agent-pdf/package.json +3 -3
  174. package/node_modules/pi-agent-read/package.json +12 -12
  175. package/node_modules/pi-agent-read/runtime/entry-47.js +0 -1
  176. package/node_modules/pi-agent-read/runtime/entry-49.js +2 -0
  177. package/node_modules/pi-agent-resource/package.json +2 -2
  178. package/node_modules/pi-agent-resource/src/resource-error.ts +11 -0
  179. package/node_modules/pi-agent-search/package.json +9 -9
  180. package/node_modules/pi-agent-search/runtime/entry-52.js +0 -1
  181. package/node_modules/pi-agent-search/runtime/entry-53.js +1 -0
  182. package/node_modules/pi-agent-search/runtime/entry-54.js +2 -0
  183. package/node_modules/pi-agent-search/src/api/search-parameters.ts +6 -5
  184. package/node_modules/pi-agent-search-text/package.json +14 -14
  185. package/node_modules/pi-agent-search-text/runtime/entry-55.js +1 -0
  186. package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
  187. package/node_modules/pi-agent-text/package.json +3 -3
  188. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  189. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  190. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  191. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
  192. package/node_modules/pi-agent-text-editor/index.ts +2 -0
  193. package/node_modules/pi-agent-text-editor/package.json +26 -26
  194. package/node_modules/pi-agent-text-editor/runtime/entry-79.js +0 -1
  195. package/node_modules/pi-agent-text-editor/runtime/entry-80.js +1 -0
  196. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  197. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
  198. package/node_modules/pi-agent-text-editor/src/core/extension.ts +3 -1
  199. package/node_modules/pi-agent-text-editor/src/core/file-operation-tools.ts +45 -44
  200. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  201. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +27 -18
  202. package/node_modules/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
  203. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
  204. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +29 -6
  205. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
  206. package/node_modules/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
  207. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  208. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
  209. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  210. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
  211. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +14 -3
  212. package/node_modules/pi-agent-text-editor-stale-anchor/index.ts +17 -0
  213. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -5
  214. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +2 -0
  215. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  216. package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +1 -0
  217. package/node_modules/pi-agent-tool-ui/package.json +6 -2
  218. package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +1 -0
  219. package/node_modules/pi-agent-tool-ui/runtime/entry-86.js +1 -0
  220. package/node_modules/pi-agent-tool-ui/src/operation-approval.ts +271 -0
  221. package/node_modules/pi-agent-web/package.json +8 -8
  222. package/node_modules/pi-agent-web-html/package.json +3 -3
  223. package/node_modules/pi-agent-web-image/package.json +4 -4
  224. package/node_modules/pi-agent-web-image/runtime/entry-89.js +2 -0
  225. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  226. package/node_modules/pi-agent-web-pdf/runtime/entry-90.js +2 -0
  227. package/node_modules/pi-agent-web-text/package.json +4 -4
  228. package/node_modules/pi-agent-web-text/runtime/entry-91.js +2 -0
  229. package/package.json +62 -54
  230. package/src/api/approval.ts +5 -0
  231. package/src/api/settings.ts +198 -0
  232. package/src/backend/debugger-registration.ts +5 -1
  233. package/src/code-review/extension.ts +10 -4
  234. package/src/code-review/reviewer.ts +8 -0
  235. package/src/composite/host-version.ts +29 -5
  236. package/src/composite/ide-alias-rendering.ts +97 -0
  237. package/src/composite/nested-tool-rendering.ts +74 -4
  238. package/src/composite/search-facts.ts +45 -0
  239. package/src/composite/settings-documentation.ts +32 -23
  240. package/src/composite/settings-registry.ts +94 -0
  241. package/src/composite/text-results.ts +120 -8
  242. package/src/composite/tool-availability.ts +11 -2
  243. package/src/core/diagnostic-entry.ts +31 -8
  244. package/src/core/diagnostic-store.ts +19 -3
  245. package/src/core/extension.ts +7 -2
  246. package/src/core/reload-resource-store.ts +23 -3
  247. package/src/documentation/registry.ts +10 -2
  248. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  249. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  250. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +6 -6
  251. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  252. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-32.js +2 -0
  253. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  254. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-33.js +2 -0
  255. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +2 -0
  256. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  257. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  258. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  259. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +2 -0
  260. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  261. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-90.js +2 -0
  262. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  263. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-91.js +2 -0
  264. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +2 -0
  265. package/src/extensions/pi-agent-read/package.json +12 -12
  266. package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
  267. package/src/extensions/pi-agent-read/runtime/entry-48.js +1 -0
  268. package/src/extensions/pi-agent-read/runtime/entry-49.js +2 -0
  269. package/src/extensions/pi-agent-search/package.json +9 -9
  270. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +14 -14
  271. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +1 -0
  272. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +1 -0
  273. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
  274. package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
  275. package/src/extensions/pi-agent-search/runtime/entry-53.js +1 -0
  276. package/src/extensions/pi-agent-search/runtime/entry-54.js +2 -0
  277. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +6 -5
  278. package/src/extensions/pi-agent-text-editor/index.ts +2 -0
  279. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  280. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  281. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  282. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  283. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-63.js +1 -0
  284. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-64.js +2 -0
  285. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  286. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +2 -0
  287. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +14 -3
  288. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/index.ts +17 -0
  289. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -5
  290. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +2 -0
  291. package/src/extensions/pi-agent-text-editor/runtime/entry-79.js +0 -1
  292. package/src/extensions/pi-agent-text-editor/runtime/entry-80.js +1 -0
  293. package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +2 -0
  294. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -0
  295. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +5 -0
  296. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +3 -1
  297. package/src/extensions/pi-agent-text-editor/src/core/file-operation-tools.ts +45 -44
  298. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +2 -0
  299. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +27 -18
  300. package/src/extensions/pi-agent-text-editor/src/core/text-edit-origin.ts +38 -0
  301. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +106 -48
  302. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +29 -6
  303. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +39 -44
  304. package/src/extensions/pi-agent-text-editor/src/core/write-agent-result.ts +3 -1
  305. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +1 -1
  306. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +6 -5
  307. package/src/pi-agent-ide.ts +61 -14
  308. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  309. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +6 -5
  310. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  311. package/src/plugins/pi-agent-ide-changes/runtime/entry-36.js +1 -0
  312. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +6 -5
  313. package/src/plugins/pi-agent-ide-debugger/index.ts +159 -60
  314. package/src/plugins/pi-agent-ide-debugger/src/debugmcp-client.ts +118 -0
  315. package/src/plugins/pi-agent-ide-debugger/src/doctor-plugin.ts +47 -0
  316. package/src/plugins/pi-agent-ide-debugger/src/renderer.ts +2 -0
  317. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +146 -1
  318. package/src/plugins/pi-agent-ide-debugger/src/ui.ts +12 -0
  319. package/src/plugins/pi-agent-ide-debugger/src/vscode-backend.ts +497 -0
  320. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  321. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  322. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  323. package/src/plugins/pi-agent-ide-lint/runtime/entry-40.js +2 -0
  324. package/src/plugins/pi-agent-ide-lsp/package.json +10 -10
  325. package/src/plugins/pi-agent-ide-lsp/runtime/entry-41.js +2 -0
  326. package/src/plugins/pi-agent-ide-terminal/index.ts +3 -2
  327. package/src/plugins/pi-agent-ide-terminal/src/origin.ts +30 -0
  328. package/src/plugins/pi-agent-ide-terminal/src/session-manager.ts +34 -0
  329. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +11 -2
  330. package/src/plugins/pi-agent-ide-terminal/src/types.ts +9 -0
  331. package/src/plugins/pi-agent-ide-terminal/src/ui.ts +72 -26
  332. package/dist/chunk-ESPNEJHK.js +0 -1
  333. package/dist/chunk-GNACBJM3.js +0 -1
  334. package/dist/chunk-VMGZMXEM.js +0 -10
  335. package/dist/chunk-W3YFF6OO.js +0 -1
  336. package/dist/chunk-W7M3V7FR.js +0 -28
  337. package/dist/chunk-WMHSVEIT.js +0 -29
  338. package/dist/chunk-XSIKDVAR.js +0 -25
  339. package/dist/chunk-YTYLS2UM.js +0 -1
  340. package/dist/chunk-Z2QGNTGQ.js +0 -1
  341. package/dist/entry-21.js +0 -1
  342. package/node_modules/pi-agent-doctor/runtime/entry-20.js +0 -1
  343. package/node_modules/pi-agent-doctor/runtime/entry-21.js +0 -1
  344. package/node_modules/pi-agent-filesystem/runtime/entry-27.js +0 -2
  345. package/node_modules/pi-agent-filesystem-image/runtime/entry-28.js +0 -2
  346. package/node_modules/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  347. package/node_modules/pi-agent-ide-formatter/runtime/entry-36.js +0 -2
  348. package/node_modules/pi-agent-image/runtime/entry-40.js +0 -1
  349. package/node_modules/pi-agent-invariant/runtime/entry-41.js +0 -1
  350. package/node_modules/pi-agent-search/runtime/entry-49.js +0 -1
  351. package/node_modules/pi-agent-search-text/runtime/entry-53.js +0 -2
  352. package/node_modules/pi-agent-search-text/runtime/entry-54.js +0 -1
  353. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-58.js +0 -2
  354. package/node_modules/pi-agent-text-editor/runtime/entry-64.js +0 -1
  355. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-80.js +0 -2
  356. package/node_modules/pi-agent-tool-call-interception/runtime/entry-82.js +0 -1
  357. package/node_modules/pi-agent-tool-ui/runtime/entry-83.js +0 -1
  358. package/node_modules/pi-agent-web/runtime/entry-84.js +0 -2
  359. package/node_modules/pi-agent-web-html/runtime/entry-85.js +0 -2
  360. package/node_modules/pi-agent-web-image/runtime/entry-86.js +0 -2
  361. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-28.js +0 -2
  362. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-29.js +0 -2
  363. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-27.js +0 -2
  364. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-85.js +0 -2
  365. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-86.js +0 -2
  366. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-87.js +0 -2
  367. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-84.js +0 -2
  368. package/src/extensions/pi-agent-read/runtime/entry-43.js +0 -1
  369. package/src/extensions/pi-agent-read/runtime/entry-44.js +0 -1
  370. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-53.js +0 -2
  371. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-54.js +0 -1
  372. package/src/extensions/pi-agent-search/runtime/entry-49.js +0 -1
  373. package/src/extensions/pi-agent-search/runtime/entry-50.js +0 -1
  374. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-58.js +0 -2
  375. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-59.js +0 -1
  376. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-80.js +0 -2
  377. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-81.js +0 -2
  378. package/src/extensions/pi-agent-text-editor/runtime/entry-63.js +0 -1
  379. package/src/extensions/pi-agent-text-editor/runtime/entry-64.js +0 -1
  380. package/src/plugins/pi-agent-ide-ast/runtime/entry-32.js +0 -1
  381. package/src/plugins/pi-agent-ide-ast/runtime/entry-33.js +0 -2
  382. package/src/plugins/pi-agent-ide-formatter/runtime/entry-36.js +0 -2
  383. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-26.js +0 -0
  384. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-29.js +0 -0
  385. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
  386. /package/node_modules/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-31.js +0 -0
  387. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-text}/runtime/entry-33.js +0 -0
  388. /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-34.js +0 -0
  389. /package/node_modules/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
  390. /package/node_modules/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
  391. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
  392. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-39.js +0 -0
  393. /package/node_modules/{pi-agent-pdf → pi-agent-image}/runtime/entry-42.js +0 -0
  394. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-43.js +0 -0
  395. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-44.js +0 -0
  396. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-48.js +0 -0
  397. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-50.js +0 -0
  398. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-57.js +0 -0
  399. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text}/runtime/entry-59.js +0 -0
  400. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-60.js +0 -0
  401. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-61.js +0 -0
  402. /package/node_modules/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-62.js +0 -0
  403. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-63.js +0 -0
  404. /package/node_modules/{pi-agent-text-editor-stale-anchor → pi-agent-text-editor}/runtime/entry-81.js +0 -0
  405. /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-87.js +0 -0
  406. /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-88.js +0 -0
  407. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-30.js +0 -0
  408. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-text → pi-agent-filesystem-jq}/runtime/entry-31.js +0 -0
  409. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-88.js +0 -0
  410. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-exact → pi-agent-text-anchor-constant}/runtime/entry-60.js +0 -0
  411. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-61.js +0 -0
  412. /package/src/extensions/pi-agent-text-editor/plugins/{pi-agent-text-anchor-line-hash → pi-agent-text-anchor-exact}/runtime/entry-62.js +0 -0
  413. /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-34.js +0 -0
  414. /package/src/plugins/{pi-agent-ide-changes → pi-agent-ide-ast}/runtime/entry-35.js +0 -0
  415. /package/src/plugins/{pi-agent-ide-languages → pi-agent-ide-changes}/runtime/entry-37.js +0 -0
  416. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-formatter}/runtime/entry-38.js +0 -0
  417. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-languages}/runtime/entry-39.js +0 -0
@@ -8,6 +8,7 @@ import {
8
8
  createAssistantMessageEventStream,
9
9
  type Model,
10
10
  type SimpleStreamOptions,
11
+ type Provider,
11
12
  } from "@earendil-works/pi-ai";
12
13
 
13
14
  import type { GuardInterception } from "./coordinator.js";
@@ -39,7 +40,7 @@ interface StreamingSubscriber {
39
40
 
40
41
  interface SharedProviderState {
41
42
  api: string;
42
- readonly delegate: StreamSimple;
43
+ readonly originalStreamSimple: StreamSimple;
43
44
  readonly wrapper: WrappedStreamSimple;
44
45
  readonly subscribers: Set<StreamingSubscriber>;
45
46
  }
@@ -50,7 +51,7 @@ type WrappedStreamSimple = StreamSimple & { [streamingInterceptorState]?: Shared
50
51
  Install one shared stream wrapper for all interceptors using each active provider.
51
52
  */
52
53
  export function registerStreamingInterceptorProvider(
53
- pi: ExtensionAPI,
54
+ pi: Pick<ExtensionAPI, "on" | "registerProvider" | "unregisterProvider">,
54
55
  processStreamEvent: ProcessStreamEvent,
55
56
  markStreamEventProcessed: MarkStreamEventProcessed,
56
57
  finalizeStreamInterception: FinalizeStreamInterception,
@@ -64,52 +65,36 @@ export function registerStreamingInterceptorProvider(
64
65
  };
65
66
 
66
67
  const install = (model: Model<Api> | undefined, context: ExtensionContext): void => {
67
- if (!model) {
68
- return;
69
- }
70
-
68
+ if (!model) return;
71
69
  const provider = context.modelRegistry.getProvider(model.provider);
72
-
73
- if (!provider) {
74
- return;
75
- }
76
-
70
+ if (!provider) return;
71
+
72
+ const register = (wrapper: WrappedStreamSimple): void => {
73
+ const native = context.modelRegistry.getRegisteredNativeProvider(model.provider);
74
+ if (native) {
75
+ // Registering by name removes native authentication and discovery in Pi.
76
+ pi.registerProvider(withStreamSimple(native, wrapper));
77
+ } else {
78
+ const config = context.modelRegistry.getRegisteredProviderConfig(model.provider);
79
+ pi.registerProvider(model.provider, { ...config, api: model.api, streamSimple: wrapper });
80
+ }
81
+ };
77
82
  const active = installed.get(model.provider);
78
-
79
83
  if (active) {
80
84
  active.subscribers.add(subscriber);
81
-
82
- if (active.api === model.api && provider.streamSimple === active.wrapper) {
83
- return;
84
- }
85
-
85
+ if (active.api === model.api && provider.streamSimple === active.wrapper) return;
86
86
  active.api = model.api;
87
- const config = context.modelRegistry.getRegisteredProviderConfig(model.provider);
88
- pi.registerProvider(model.provider, {
89
- ...config,
90
- api: model.api,
91
- streamSimple: active.wrapper,
92
- });
87
+ register(active.wrapper);
93
88
  return;
94
89
  }
95
90
 
96
91
  const shared = (provider.streamSimple as WrappedStreamSimple)[streamingInterceptorState];
97
-
98
92
  if (shared) {
99
93
  shared.subscribers.add(subscriber);
100
94
  installed.set(model.provider, shared);
101
-
102
- if (shared.api === model.api) {
103
- return;
104
- }
105
-
95
+ if (shared.api === model.api) return;
106
96
  shared.api = model.api;
107
- const config = context.modelRegistry.getRegisteredProviderConfig(model.provider);
108
- pi.registerProvider(model.provider, {
109
- ...config,
110
- api: model.api,
111
- streamSimple: shared.wrapper,
112
- });
97
+ register(shared.wrapper);
113
98
  return;
114
99
  }
115
100
 
@@ -119,18 +104,12 @@ export function registerStreamingInterceptorProvider(
119
104
  wrapStream(delegate, currentModel, context, options, subscribers);
120
105
  const state: SharedProviderState = {
121
106
  api: model.api,
122
- delegate,
107
+ originalStreamSimple: provider.streamSimple,
123
108
  wrapper,
124
109
  subscribers,
125
110
  };
126
111
  wrapper[streamingInterceptorState] = state;
127
- const config = context.modelRegistry.getRegisteredProviderConfig(model.provider);
128
-
129
- pi.registerProvider(model.provider, {
130
- ...config,
131
- api: model.api,
132
- streamSimple: wrapper,
133
- });
112
+ register(wrapper);
134
113
  installed.set(model.provider, state);
135
114
  };
136
115
 
@@ -162,7 +141,15 @@ export function registerStreamingInterceptorProvider(
162
141
  for (const [provider, state] of installed) {
163
142
  state.subscribers.delete(subscriber);
164
143
 
165
- if (state.subscribers.size === 0) {
144
+ if (state.subscribers.size !== 0) continue;
145
+ const registry = subscriber.context?.modelRegistry;
146
+ const current = registry?.getProvider(provider);
147
+ if (current?.streamSimple !== state.wrapper) continue;
148
+ const native = registry?.getRegisteredNativeProvider(provider);
149
+ if (native) {
150
+ // Restore only our stream hook, retaining later auth/catalog updates.
151
+ pi.registerProvider(withStreamSimple(native, state.originalStreamSimple));
152
+ } else {
166
153
  pi.unregisterProvider(provider);
167
154
  }
168
155
  }
@@ -172,6 +159,14 @@ export function registerStreamingInterceptorProvider(
172
159
  });
173
160
  }
174
161
 
162
+ /** Preserve prototype methods and non-enumerable native provider fields. */
163
+ function withStreamSimple(provider: Provider, streamSimple: StreamSimple): Provider {
164
+ return Object.create(Object.getPrototypeOf(provider) as object | null, {
165
+ ...Object.getOwnPropertyDescriptors(provider),
166
+ streamSimple: { value: streamSimple, writable: true, enumerable: true, configurable: true },
167
+ }) as Provider;
168
+ }
169
+
175
170
  function wrapStream(
176
171
  delegate: StreamSimple,
177
172
  model: Model<Api>,
@@ -36,8 +36,10 @@ export function writeAgentResult(
36
36
  completions: readonly TextEditCompletion[],
37
37
  requestedPath: unknown,
38
38
  ): AgentToolResult<FileMutationBatchResult> {
39
- // Terminal input and other live resources keep their own action receipts.
39
+ // Semantic providers own their action receipts and need not emit file completions.
40
+ // Terminal input and other live resources also keep their own action receipts.
40
41
  if (
42
+ result.details.metadata?.semanticAction !== undefined ||
41
43
  (typeof requestedPath === "string" && requestedPath.startsWith("shell:")) ||
42
44
  completions.some((completion) => completion.resolvedBy !== "filesystem")
43
45
  )
@@ -3,7 +3,7 @@ import { resultInputSchema } from "pi-agent-resource";
3
3
 
4
4
  /** Build a structured source selector without changing legacy path semantics. */
5
5
  export function resultSourceProperty(description: string) {
6
- return Type.Optional({ ...resultInputSchema, description });
6
+ return Type.Optional(Type.Union(resultInputSchema.anyOf, { description }));
7
7
  }
8
8
 
9
9
  /** Build the source selector shared by text mutation schemas. */
@@ -15,11 +15,12 @@ import type { TextMutationToolRegistration } from "#src/api/mutation-tool.js";
15
15
 
16
16
  export const replaceSchema = Type.Object(
17
17
  {
18
- path: Type.Optional({
19
- ...resultInputSchema,
20
- description:
21
- "Source path, SEARCH# selector, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Omit start/end when the result selects the intended text. Changed or expired results are rejected without writing.",
22
- }),
18
+ path: Type.Optional(
19
+ Type.Union(resultInputSchema.anyOf, {
20
+ description:
21
+ "Source path, SEARCH# selector, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Omit start/end when the result selects the intended text. Changed or expired results are rejected without writing.",
22
+ }),
23
+ ),
23
24
  ...sourceRangeProperties(),
24
25
  text: Type.String({
25
26
  description:
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor-renderer",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "imports": {
6
6
  "#src/*": "./src/*"
7
7
  },
8
8
  "dependencies": {
9
- "pi-agent-invariant": "0.8.1",
10
- "pi-agent-text-editor": "0.8.1",
11
- "pi-agent-tool-call-interception": "0.8.1",
12
- "pi-agent-tool-ui": "0.8.1"
9
+ "pi-agent-invariant": "0.8.3",
10
+ "pi-agent-text-editor": "0.8.3",
11
+ "pi-agent-tool-call-interception": "0.8.3",
12
+ "pi-agent-tool-ui": "0.8.3"
13
13
  },
14
14
  "pi": {
15
15
  "extensions": [
16
- "./runtime/entry-80.js"
16
+ "./runtime/entry-82.js"
17
17
  ]
18
18
  },
19
19
  "peerDependencies": {
@@ -0,0 +1,2 @@
1
+ export * from "../../../dist/entry-82.js";
2
+ export { default } from "../../../dist/entry-82.js";
@@ -931,7 +931,7 @@ function wholeFileOperationSummary(details: unknown):
931
931
  typeof error.code === "string"
932
932
  ? error.code
933
933
  : undefined;
934
- cause = code === undefined ? "file operation failed" : wholeFileFailureCause(code);
934
+ cause = code === undefined ? GENERIC_FAILURE_CAUSE : wholeFileFailureCause(code);
935
935
  }
936
936
  const label =
937
937
  effect === "unknown"
@@ -951,8 +951,13 @@ function wholeFileOperationSummary(details: unknown):
951
951
  };
952
952
  }
953
953
 
954
+ const GENERIC_FAILURE_CAUSE = "file operation failed";
955
+
954
956
  function wholeFileFailureCause(code: string): string {
955
957
  switch (code) {
958
+ case "RESULT_INPUT_REJECTED": {
959
+ return "result input was rejected";
960
+ }
956
961
  case "WRITE_FAILED": {
957
962
  return "resource write failed";
958
963
  }
@@ -1000,7 +1005,7 @@ function wholeFileFailureCause(code: string): string {
1000
1005
  return "operation was canceled";
1001
1006
  }
1002
1007
  default: {
1003
- return "file operation failed";
1008
+ return GENERIC_FAILURE_CAUSE;
1004
1009
  }
1005
1010
  }
1006
1011
  }
@@ -1012,7 +1017,13 @@ function userFacingFailure(
1012
1017
  const causes = new Set(
1013
1018
  details?.results?.flatMap((result) =>
1014
1019
  // Provider reasons can contain private data; decode only public editor failure codes.
1015
- (result.data.errors ?? []).map((error) => wholeFileFailureCause(error.code ?? "")),
1020
+ (result.data.errors ?? []).map((error) => {
1021
+ const cause = wholeFileFailureCause(error.code ?? "");
1022
+ // A provider's own code still names the editor step that failed.
1023
+ return cause === GENERIC_FAILURE_CAUSE && error.stage !== undefined
1024
+ ? wholeFileFailureCause(error.stage)
1025
+ : cause;
1026
+ }),
1016
1027
  ),
1017
1028
  );
1018
1029
  return [
@@ -1,4 +1,5 @@
1
1
  import { requiredValue } from "pi-agent-invariant";
2
+ import { connectResultTargets } from "pi-agent-resource";
2
3
  import { connectReadPlugin } from "pi-agent-read/api/connect-plugin";
3
4
  import {
4
5
  READ_API_VERSION,
@@ -73,6 +74,7 @@ function createHandler(
73
74
  readonly handler: ToolCallInterceptorHandler;
74
75
  readonly add: (registration: TextMutationToolRegistration) => void;
75
76
  } {
77
+ const resultTargets = connectResultTargets(pi);
76
78
  const schemas = new Map<string, TextMutationToolRegistration>();
77
79
  const toolNames: string[] = [];
78
80
  const knownPaths = new Map<number, string>();
@@ -91,6 +93,21 @@ function createHandler(
91
93
  }
92
94
 
93
95
  const arguments_ = context.partialArgs ?? context.args;
96
+ // Issued selections belong to the result-input pipeline, not filename anchor inspection.
97
+ // This also leaves unsupported selector combinations and expired IDs to their owner.
98
+ try {
99
+ for (const field of [
100
+ schema.source.field,
101
+ ...(schema.source.targets ?? []).map((target) => target.field),
102
+ ]) {
103
+ const original = arguments_[field];
104
+ const source = resultTargets.source(original, context.cwd);
105
+ if (source !== original || (typeof source === "string" && source.startsWith("RESULT#")))
106
+ return;
107
+ }
108
+ } catch {
109
+ return;
110
+ }
94
111
  const source = resolveSource(
95
112
  arguments_,
96
113
  context,
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-text-editor-stale-anchor",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-invariant": "0.8.1",
7
- "pi-agent-read": "0.8.1",
8
- "pi-agent-text-editor": "0.8.1"
6
+ "pi-agent-invariant": "0.8.3",
7
+ "pi-agent-read": "0.8.3",
8
+ "pi-agent-resource": "0.8.3",
9
+ "pi-agent-text-editor": "0.8.3"
9
10
  },
10
11
  "pi": {
11
12
  "extensions": [
12
- "./runtime/entry-81.js"
13
+ "./runtime/entry-83.js"
13
14
  ]
14
15
  },
15
16
  "peerDependencies": {
@@ -0,0 +1,2 @@
1
+ export * from "../../../dist/entry-83.js";
2
+ export { default } from "../../../dist/entry-83.js";
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-tool-call-interception",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "types": "./src/index.ts",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./src/index.ts",
9
- "default": "./runtime/entry-82.js"
9
+ "default": "./runtime/entry-84.js"
10
10
  }
11
11
  },
12
12
  "dependencies": {
13
- "pi-agent-tool-ui": "0.8.1"
13
+ "pi-agent-tool-ui": "0.8.3"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "@earendil-works/pi-coding-agent": "*",
@@ -0,0 +1 @@
1
+ export * from "../../../dist/entry-84.js";
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "pi-agent-tool-ui",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "type": "module",
5
5
  "exports": {
6
+ "./operation-approval": {
7
+ "types": "./src/operation-approval.ts",
8
+ "default": "./runtime/entry-85.js"
9
+ },
6
10
  ".": {
7
11
  "types": "./src/index.ts",
8
- "default": "./runtime/entry-83.js"
12
+ "default": "./runtime/entry-86.js"
9
13
  }
10
14
  },
11
15
  "peerDependencies": {
@@ -0,0 +1 @@
1
+ export * from "../../../dist/entry-85.js";
@@ -0,0 +1 @@
1
+ export * from "../../../dist/entry-86.js";
@@ -0,0 +1,271 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+
3
+ /** Versioned synchronous channel; decisions return through accept(), not the bus. */
4
+ export const OPERATION_APPROVAL_EVENT = "pi-agent-ide/operation-approval/v1";
5
+ /** Non-context branch entry recording a user-selected session permission. */
6
+ export const OPERATION_PERMISSION_ENTRY = "pi-agent-ide/operation-permission/v1";
7
+ const APPROVAL_SERVICE_EVENT = "pi-agent-ide/operation-approval/service/v1";
8
+
9
+ export interface OperationApprovalContext {
10
+ readonly cwd: string;
11
+ readonly hasUI: boolean;
12
+ readonly mode: ExtensionContext["mode"];
13
+ readonly ui: Pick<ExtensionContext["ui"], "select">;
14
+ readonly sessionManager?: Pick<ExtensionContext["sessionManager"], "getBranch">;
15
+ }
16
+
17
+ /** The caller owns risk classification, category identity, target text and its one-operation permit. */
18
+ export interface OperationApprovalRequest {
19
+ /** Stable extension identity; permissions never cross owners. */
20
+ readonly owner: string;
21
+ /** Stable dialog category, independent of the target path or URL. */
22
+ readonly category: string;
23
+ /** Registered boolean setting used by the host's persistent YOLO policy. */
24
+ readonly yoloSetting?: string;
25
+ readonly title: string;
26
+ readonly message: string;
27
+ readonly signal?: AbortSignal;
28
+ }
29
+
30
+ /** Host policy is separate from the provider's technical guards and from session grants. */
31
+ export interface OperationApprovalOptions {
32
+ readonly isAllowed?: (
33
+ request: OperationApprovalRequest,
34
+ context: OperationApprovalContext,
35
+ ) => Promise<boolean>;
36
+ readonly remember?: (request: OperationApprovalRequest) => void;
37
+ }
38
+
39
+ interface ApprovalCall {
40
+ readonly context: OperationApprovalContext;
41
+ readonly request: OperationApprovalRequest;
42
+ accept(decision: Promise<boolean>): void;
43
+ }
44
+ type Events = Pick<ExtensionAPI["events"], "emit">;
45
+ interface ApprovalService {
46
+ handle(data: unknown): void;
47
+ setPolicy(policy: OperationApprovalOptions["isAllowed"]): void;
48
+ dispose(): void;
49
+ }
50
+
51
+ /** Install once per event bus; a later IDE host can attach policy to a standalone editor's service. */
52
+ export function registerOperationApproval(
53
+ pi: ExtensionAPI,
54
+ options: Pick<OperationApprovalOptions, "isAllowed"> = {},
55
+ ): void {
56
+ let installed: ApprovalService | undefined;
57
+ pi.events.emit(APPROVAL_SERVICE_EVENT, (service: ApprovalService) => {
58
+ installed = service;
59
+ });
60
+ if (installed !== undefined) {
61
+ if (options.isAllowed !== undefined) installed.setPolicy(options.isAllowed);
62
+ return;
63
+ }
64
+ const service = createOperationApproval(pi.events, {
65
+ ...options,
66
+ remember: (request) =>
67
+ pi.appendEntry(OPERATION_PERMISSION_ENTRY, {
68
+ owner: request.owner,
69
+ category: request.category,
70
+ }),
71
+ });
72
+ const unsubscribeRequest = pi.events.on(OPERATION_APPROVAL_EVENT, service.handle);
73
+ const unsubscribeService = pi.events.on(APPROVAL_SERVICE_EVENT, (probe) => {
74
+ (probe as (value: ApprovalService) => void)(service);
75
+ });
76
+ pi.on("session_shutdown", () => {
77
+ unsubscribeRequest();
78
+ unsubscribeService();
79
+ service.dispose();
80
+ });
81
+ }
82
+
83
+ /** Request permission through the shared service. Missing service and cancellation refuse. */
84
+ export async function confirmOperation(
85
+ events: Events | undefined,
86
+ context: OperationApprovalContext,
87
+ request: OperationApprovalRequest,
88
+ ): Promise<boolean> {
89
+ if (request.signal?.aborted || events === undefined) return false;
90
+ if (!request.owner.trim() || !request.category.trim())
91
+ throw new Error("Approval owner and category are required");
92
+ let decision: Promise<boolean> | undefined;
93
+ events.emit(OPERATION_APPROVAL_EVENT, {
94
+ context,
95
+ request,
96
+ accept(value) {
97
+ if (decision !== undefined) throw new Error("Operation approval was accepted twice");
98
+ decision = value;
99
+ },
100
+ } satisfies ApprovalCall);
101
+ return decision === undefined ? false : decision;
102
+ }
103
+
104
+ interface Pending {
105
+ readonly call: ApprovalCall;
106
+ readonly controller: AbortController;
107
+ readonly resolve: (answer: boolean) => void;
108
+ readonly cleanup: () => void;
109
+ }
110
+
111
+ /** One session-owned queue. Each request reads only the current branch's remembered grants. */
112
+ export function createOperationApproval(
113
+ events: Events,
114
+ options: OperationApprovalOptions = {},
115
+ ): ApprovalService {
116
+ const queue: Pending[] = [];
117
+ let current: Pending | undefined;
118
+ let draining = false;
119
+ let closed = false;
120
+ let blocked = false;
121
+ let isAllowed = options.isAllowed;
122
+
123
+ function setBlocked(active: boolean): void {
124
+ if (blocked === active) return;
125
+ blocked = active;
126
+ try {
127
+ events.emit(
128
+ "herdr:blocked",
129
+ active ? { active: true, label: "Waiting for operation approval" } : { active: false },
130
+ );
131
+ } catch {
132
+ // Advisory header listeners must never change permission.
133
+ }
134
+ }
135
+
136
+ function remembered(call: ApprovalCall): boolean {
137
+ return (
138
+ call.context.sessionManager?.getBranch().some((entry) => {
139
+ if (entry.type !== "custom" || entry.customType !== OPERATION_PERMISSION_ENTRY)
140
+ return false;
141
+ const data = entry.data as { owner?: unknown; category?: unknown } | null;
142
+ return data?.owner === call.request.owner && data.category === call.request.category;
143
+ }) ?? false
144
+ );
145
+ }
146
+
147
+ function active(pending: Pending): boolean {
148
+ return !closed && !pending.controller.signal.aborted;
149
+ }
150
+ async function drain(): Promise<void> {
151
+ draining = true;
152
+ while (queue.length > 0) {
153
+ const pending = queue.shift();
154
+ if (pending === undefined) break;
155
+ current = pending;
156
+ let approved = false;
157
+ try {
158
+ if (active(pending)) {
159
+ const call = pending.call;
160
+ approved = remembered(call);
161
+ if (!approved && isAllowed !== undefined) {
162
+ const policy = isAllowed;
163
+ approved =
164
+ (await untilCancelled(pending.controller.signal, () =>
165
+ policy(call.request, call.context),
166
+ )) === true;
167
+ }
168
+ if (!approved && call.context.hasUI && active(pending)) {
169
+ setBlocked(call.context.mode === "tui");
170
+ const canRemember =
171
+ options.remember !== undefined && call.context.sessionManager !== undefined;
172
+ const answer = await show(call, pending.controller.signal, canRemember);
173
+ approved = answer === "Allow once" || answer === "Allow for session";
174
+ if (answer === "Allow for session" && active(pending)) {
175
+ options.remember?.(call.request);
176
+ }
177
+ }
178
+ }
179
+ } catch {
180
+ // A failed policy, session write or dialog cannot grant permission or strand the queue.
181
+ approved = false;
182
+ }
183
+ current = undefined;
184
+ pending.cleanup();
185
+ setBlocked(false);
186
+ pending.resolve(approved && active(pending));
187
+ }
188
+ setBlocked(false);
189
+ draining = false;
190
+ }
191
+
192
+ return {
193
+ setPolicy(policy) {
194
+ isAllowed = policy;
195
+ },
196
+ handle(data) {
197
+ const call = data as ApprovalCall;
198
+ call.accept(
199
+ new Promise<boolean>((resolve) => {
200
+ if (closed || call.request.signal?.aborted) {
201
+ resolve(false);
202
+ return;
203
+ }
204
+ const controller = new AbortController();
205
+ const cancel = (): void => {
206
+ controller.abort();
207
+ if (current === pending) return;
208
+ const index = queue.indexOf(pending);
209
+ if (index !== -1) queue.splice(index, 1);
210
+ pending.cleanup();
211
+ resolve(false);
212
+ };
213
+ const pending: Pending = {
214
+ call,
215
+ controller,
216
+ resolve,
217
+ cleanup: () => call.request.signal?.removeEventListener("abort", cancel),
218
+ };
219
+ call.request.signal?.addEventListener("abort", cancel, { once: true });
220
+ queue.push(pending);
221
+ if (!draining) void drain();
222
+ }),
223
+ );
224
+ },
225
+ dispose() {
226
+ if (closed) return;
227
+ closed = true;
228
+ for (const pending of queue.splice(0)) {
229
+ pending.controller.abort();
230
+ pending.cleanup();
231
+ pending.resolve(false);
232
+ }
233
+ current?.controller.abort();
234
+ setBlocked(false);
235
+ },
236
+ };
237
+ }
238
+
239
+ function show(
240
+ call: ApprovalCall,
241
+ signal: AbortSignal,
242
+ canRemember: boolean,
243
+ ): Promise<string | undefined> {
244
+ const title = `${call.request.title}\n${call.request.message}\nScope: ${call.request.owner} / ${call.request.category}\nDisable confirmations in /agent-ide-settings (YOLO).`;
245
+ const choices = ["Deny", "Allow once", ...(canRemember ? ["Allow for session"] : [])];
246
+ return untilCancelled(signal, () => call.context.ui.select(title, choices, { signal }));
247
+ }
248
+
249
+ function untilCancelled<T>(signal: AbortSignal, action: () => Promise<T>): Promise<T | undefined> {
250
+ return new Promise((resolve, reject) => {
251
+ const finish = (answer?: T): void => {
252
+ signal.removeEventListener("abort", abort);
253
+ resolve(signal.aborted ? undefined : answer);
254
+ };
255
+ const abort = (): void => finish();
256
+ signal.addEventListener("abort", abort, { once: true });
257
+ if (signal.aborted) {
258
+ finish();
259
+ return;
260
+ }
261
+ const fail = (error: unknown): void => {
262
+ signal.removeEventListener("abort", abort);
263
+ reject(error);
264
+ };
265
+ try {
266
+ void action().then(finish, fail);
267
+ } catch (error) {
268
+ fail(error);
269
+ }
270
+ });
271
+ }