pi-agent-ide 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/chunk-6U5OU77O.js +3 -0
  3. package/dist/chunk-EURHXLN3.js +2 -0
  4. package/dist/{chunk-WMO6RNE2.js → chunk-F6IWZKOG.js} +6 -6
  5. package/dist/{chunk-HZEY4GT4.js → chunk-H445SHSJ.js} +2 -2
  6. package/dist/chunk-IG56UGSO.js +2 -0
  7. package/dist/chunk-IICJXZBU.js +6 -0
  8. package/dist/{chunk-XYS4FSCC.js → chunk-IM24DB3K.js} +1 -1
  9. package/dist/{chunk-PKKDDIWW.js → chunk-KOVPDKSJ.js} +1 -1
  10. package/dist/chunk-MXLSGMRZ.js +3 -0
  11. package/dist/chunk-OB46OPMZ.js +1 -0
  12. package/dist/chunk-PKSQT6TC.js +1 -0
  13. package/dist/{chunk-PNU3E7IO.js → chunk-Q6CZ6GBR.js} +2 -2
  14. package/dist/chunk-QUYXINGZ.js +7 -0
  15. package/dist/{chunk-OMVRLWMX.js → chunk-SBP3ABH4.js} +1 -1
  16. package/dist/{chunk-4GCWGE2C.js → chunk-SJ4UZ4GU.js} +1 -1
  17. package/dist/{chunk-2TRHFMCZ.js → chunk-SNF7PDDX.js} +1 -1
  18. package/dist/{chunk-YP46DVVP.js → chunk-STBJO3Z3.js} +1 -1
  19. package/dist/{chunk-76ZK5ODR.js → chunk-TQGE7RH6.js} +13 -13
  20. package/dist/{chunk-LEEQIQ7D.js → chunk-XDG7EQRN.js} +6 -6
  21. package/dist/chunk-YWQS33DF.js +1 -0
  22. package/dist/chunk-ZIWPKIBZ.js +1 -0
  23. package/dist/entry-11.js +1 -1
  24. package/dist/entry-13.js +1 -1
  25. package/dist/entry-14.js +1 -1
  26. package/dist/entry-15.js +1 -1
  27. package/dist/entry-17.js +1 -1
  28. package/dist/entry-25.js +1 -1
  29. package/dist/entry-26.js +1 -1
  30. package/dist/entry-27.js +1 -1
  31. package/dist/entry-28.js +1 -1
  32. package/dist/entry-29.js +1 -1
  33. package/dist/entry-31.js +13 -12
  34. package/dist/entry-33.js +2 -1
  35. package/dist/entry-37.js +2 -2
  36. package/dist/entry-42.js +1 -1
  37. package/dist/entry-44.js +1 -1
  38. package/dist/entry-45.js +20 -12
  39. package/dist/entry-46.js +1 -1
  40. package/dist/entry-49.js +1 -1
  41. package/dist/entry-50.js +1 -1
  42. package/dist/entry-51.js +7 -6
  43. package/dist/entry-52.js +1 -1
  44. package/dist/entry-53.js +1 -1
  45. package/dist/entry-54.js +1 -1
  46. package/dist/entry-56.js +1 -1
  47. package/dist/entry-58.js +1 -1
  48. package/dist/entry-60.js +1 -1
  49. package/dist/entry-62.js +1 -1
  50. package/dist/entry-65.js +1 -1
  51. package/dist/entry-66.js +1 -1
  52. package/dist/entry-68.js +1 -1
  53. package/dist/entry-70.js +1 -1
  54. package/dist/entry-75.js +1 -1
  55. package/dist/entry-77.js +51 -42
  56. package/dist/entry-78.js +14 -14
  57. package/dist/entry-79.js +1 -1
  58. package/dist/entry-82.js +5 -5
  59. package/dist/entry-83.js +1 -1
  60. package/dist/entry-84.js +1 -1
  61. package/dist/entry-85.js +1 -1
  62. package/dist/entry-86.js +1 -1
  63. package/dist/pi-agent-ide.js +34 -11
  64. package/docs/agent-guides/editing.md +5 -5
  65. package/docs/agent-guides/git-changes.md +10 -0
  66. package/docs/agent-guides/read-resources.md +9 -46
  67. package/docs/agent-guides/search-code.md +7 -1
  68. package/docs/agent-guides/select-code.md +1 -0
  69. package/docs/agent-guides/terminal.md +9 -1
  70. package/docs/configuration.md +1 -1
  71. package/docs/releases.md +4 -0
  72. package/docs/research/native-codemode-batch-decision.md +2 -0
  73. package/docs/structured-results.md +2 -2
  74. package/docs/tools.md +10 -2
  75. package/node_modules/pi-agent-doctor/package.json +1 -1
  76. package/node_modules/pi-agent-documentation/package.json +1 -1
  77. package/node_modules/pi-agent-filesystem/package.json +7 -7
  78. package/node_modules/pi-agent-filesystem-image/package.json +3 -3
  79. package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
  80. package/node_modules/pi-agent-filesystem-jq/src/jq.ts +4 -1
  81. package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
  82. package/node_modules/pi-agent-filesystem-text/package.json +3 -3
  83. package/node_modules/pi-agent-ide-ast/package.json +13 -13
  84. package/node_modules/pi-agent-ide-ast/src/extension.ts +0 -2
  85. package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
  86. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +0 -3
  87. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +8 -6
  88. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +13 -5
  89. package/node_modules/pi-agent-ide-changes/package.json +8 -8
  90. package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +66 -4
  91. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
  92. package/node_modules/pi-agent-ide-formatter/package.json +3 -3
  93. package/node_modules/pi-agent-ide-languages/package.json +2 -2
  94. package/node_modules/pi-agent-ide-lint/package.json +7 -7
  95. package/node_modules/pi-agent-ide-lsp/package.json +9 -9
  96. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
  97. package/node_modules/pi-agent-image/package.json +2 -2
  98. package/node_modules/pi-agent-invariant/package.json +1 -1
  99. package/node_modules/pi-agent-pdf/package.json +2 -2
  100. package/node_modules/pi-agent-read/package.json +7 -7
  101. package/node_modules/pi-agent-read/src/api/read-parameters.ts +3 -3
  102. package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -0
  103. package/node_modules/pi-agent-read/src/core/extension.ts +1 -1
  104. package/node_modules/pi-agent-read/src/core/read-core.ts +5 -1
  105. package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
  106. package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
  107. package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
  108. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
  109. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +99 -44
  110. package/node_modules/pi-agent-resource/package.json +1 -1
  111. package/node_modules/pi-agent-resource/src/index.ts +1 -0
  112. package/node_modules/pi-agent-resource/src/result-targets.ts +6 -3
  113. package/node_modules/{pi-agent-read/src/core/tools/read → pi-agent-resource/src}/temp-resource-store.ts +17 -7
  114. package/node_modules/pi-agent-search/package.json +5 -5
  115. package/node_modules/pi-agent-search/src/api/fuzzy.ts +5 -1
  116. package/node_modules/pi-agent-search/src/api/search-parameters.ts +2 -2
  117. package/node_modules/pi-agent-search/src/core/extension.ts +2 -1
  118. package/node_modules/pi-agent-search/src/core/search-core.ts +13 -4
  119. package/node_modules/pi-agent-search-text/package.json +7 -7
  120. package/node_modules/pi-agent-search-text/src/resolvers.ts +11 -1
  121. package/node_modules/pi-agent-search-text/src/scoped-search.ts +1 -1
  122. package/node_modules/pi-agent-search-text/src/search-presentation.ts +42 -32
  123. package/node_modules/pi-agent-search-text/src/search-recipe.ts +1 -1
  124. package/node_modules/pi-agent-search-text/src/search-renderer.ts +6 -0
  125. package/node_modules/pi-agent-search-text/src/search-result.ts +17 -3
  126. package/node_modules/pi-agent-text/package.json +2 -2
  127. package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
  128. package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
  129. package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
  130. package/node_modules/pi-agent-text-editor/package.json +9 -9
  131. package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
  132. package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
  133. package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
  134. package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
  135. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
  136. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
  137. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +35 -6
  138. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -1
  139. package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
  140. package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +232 -151
  141. package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
  142. package/node_modules/pi-agent-text-editor/src/core/result-input.ts +24 -4
  143. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +7 -2
  144. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +14 -13
  145. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
  146. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +152 -22
  147. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  148. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +76 -32
  149. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +381 -187
  150. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +4 -2
  151. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -2
  152. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
  153. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
  154. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
  155. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
  156. package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
  157. package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
  158. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +54 -5
  159. package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
  160. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
  161. package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
  162. package/node_modules/pi-agent-tool-ui/package.json +1 -1
  163. package/node_modules/pi-agent-web/package.json +7 -7
  164. package/node_modules/pi-agent-web/src/resolver.ts +11 -13
  165. package/node_modules/pi-agent-web-html/package.json +2 -2
  166. package/node_modules/pi-agent-web-image/package.json +3 -3
  167. package/node_modules/pi-agent-web-pdf/package.json +3 -3
  168. package/node_modules/pi-agent-web-text/package.json +3 -3
  169. package/package.json +35 -35
  170. package/src/composite/nested-tool-rendering.ts +64 -6
  171. package/src/composite/output-limits.ts +125 -0
  172. package/src/composite/responses-tools.ts +25 -0
  173. package/src/composite/text-results.ts +158 -7
  174. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
  175. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
  176. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
  177. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +4 -1
  178. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
  179. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
  180. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
  181. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
  182. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
  183. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
  184. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
  185. package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +11 -13
  186. package/src/extensions/pi-agent-read/package.json +7 -7
  187. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +3 -3
  188. package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -0
  189. package/src/extensions/pi-agent-read/src/core/extension.ts +1 -1
  190. package/src/extensions/pi-agent-read/src/core/read-core.ts +5 -1
  191. package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
  192. package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
  193. package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
  194. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
  195. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +99 -44
  196. package/src/extensions/pi-agent-search/package.json +5 -5
  197. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
  198. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +11 -1
  199. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +1 -1
  200. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +42 -32
  201. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +1 -1
  202. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +6 -0
  203. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +17 -3
  204. package/src/extensions/pi-agent-search/src/api/fuzzy.ts +5 -1
  205. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +2 -2
  206. package/src/extensions/pi-agent-search/src/core/extension.ts +2 -1
  207. package/src/extensions/pi-agent-search/src/core/search-core.ts +13 -4
  208. package/src/extensions/pi-agent-text-editor/package.json +9 -9
  209. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
  210. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
  211. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
  212. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
  213. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
  214. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +54 -5
  215. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
  216. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
  217. package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
  218. package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
  219. package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
  220. package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
  221. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
  222. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
  223. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +35 -6
  224. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -1
  225. package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
  226. package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +232 -151
  227. package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
  228. package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +24 -4
  229. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +7 -2
  230. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +14 -13
  231. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
  232. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +152 -22
  233. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
  234. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +76 -32
  235. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +381 -187
  236. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +4 -2
  237. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -2
  238. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
  239. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
  240. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
  241. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
  242. package/src/pi-agent-ide.ts +11 -0
  243. package/src/plugins/pi-agent-ide-ast/package.json +13 -13
  244. package/src/plugins/pi-agent-ide-ast/src/extension.ts +0 -2
  245. package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
  246. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +0 -3
  247. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +8 -6
  248. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +13 -5
  249. package/src/plugins/pi-agent-ide-changes/package.json +8 -8
  250. package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +66 -4
  251. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
  252. package/src/plugins/pi-agent-ide-debugger/index.ts +17 -7
  253. package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -0
  254. package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +93 -38
  255. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +3 -2
  256. package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
  257. package/src/plugins/pi-agent-ide-languages/package.json +2 -2
  258. package/src/plugins/pi-agent-ide-lint/package.json +7 -7
  259. package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
  260. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
  261. package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +3 -3
  262. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +3 -3
  263. package/src/plugins/pi-agent-ide-vision/index.ts +1 -0
  264. package/src/post-edit/gate.ts +13 -2
  265. package/dist/chunk-4XMY4H4V.js +0 -1
  266. package/dist/chunk-64M3SQPG.js +0 -3
  267. package/dist/chunk-CWD4O5PM.js +0 -3
  268. package/dist/chunk-D3WTDA6V.js +0 -2
  269. package/dist/chunk-EAZGN5ND.js +0 -7
  270. package/dist/chunk-GXEGY7GV.js +0 -1
  271. package/dist/chunk-MBUXFKIW.js +0 -3
  272. package/dist/chunk-PGIVHICI.js +0 -1
  273. package/dist/chunk-VMTR74FF.js +0 -2
  274. package/dist/chunk-WU6ZK6YD.js +0 -1
  275. package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +0 -105
@@ -202,6 +202,11 @@ export class DapClient {
202
202
  return response;
203
203
  }
204
204
 
205
+ /** Consume an already buffered control event without waiting for a new one. */
206
+ takeEvent(events: readonly string[]): DapEvent | undefined {
207
+ const index = this.#events.findIndex((event) => events.includes(event.event));
208
+ return index < 0 ? undefined : this.#events.splice(index, 1)[0];
209
+ }
205
210
  /** Wait for a matching event. Only the newest 128 control events can be replayed. */
206
211
  waitForEvent(event: string, timeoutMs = 30_000): Promise<DapEvent> {
207
212
  return this.waitForAnyEvent([event], timeoutMs);
@@ -51,7 +51,12 @@ export interface DebugBreakpoint {
51
51
  readonly id: string;
52
52
  readonly source: string;
53
53
  readonly file: string;
54
- readonly line: number;
54
+ /** Requested source line, kept when the adapter relocates the breakpoint. */
55
+ readonly requestedLine: number;
56
+ /** Current line reported by the adapter. */
57
+ line: number;
58
+ /** Adapter identity used by later binding-change events. */
59
+ adapterId?: number;
55
60
  verified: boolean;
56
61
  }
57
62
 
@@ -145,7 +150,11 @@ interface EvaluateBody {
145
150
  readonly variablesReference?: number;
146
151
  }
147
152
  interface SetBreakpointsBody {
148
- readonly breakpoints?: readonly { readonly verified?: boolean; readonly line?: number }[];
153
+ readonly breakpoints?: readonly {
154
+ readonly id?: number;
155
+ readonly verified?: boolean;
156
+ readonly line?: number;
157
+ }[];
149
158
  }
150
159
 
151
160
  /** Owns debug sessions and keeps DAP references scoped to their current stop. */
@@ -245,6 +254,7 @@ export class DebugSessionManager {
245
254
  id,
246
255
  source: `${session.source}/breakpoint/${id}`,
247
256
  file,
257
+ requestedLine: line,
248
258
  line,
249
259
  verified: false,
250
260
  };
@@ -353,6 +363,8 @@ export class DebugSessionManager {
353
363
  }
354
364
  const initialized = client.waitForAnyEvent(["initialized"], 30_000, signal);
355
365
  const launch = client.request(recipe.request, recipe.launch, { signal });
366
+ // Configuration can fail before launch is awaited; cleanup must not leave a rejected request unhandled.
367
+ void launch.catch(() => {});
356
368
  await initialized;
357
369
  await this.#configureBreakpoints(session, client, signal);
358
370
  const configurationDone = client.request("configurationDone", undefined, { signal });
@@ -403,12 +415,41 @@ export class DebugSessionManager {
403
415
  }
404
416
  }
405
417
 
418
+ /** Refresh execution state from events that arrived after a control wait ended. */
419
+ async refresh(session: DebugSession): Promise<void> {
420
+ if (session.client === undefined) return;
421
+ for (
422
+ let event = session.client.takeEvent(["breakpoint"]);
423
+ event !== undefined;
424
+ event = session.client.takeEvent(["breakpoint"])
425
+ ) {
426
+ this.#updateBreakpoint(session, event);
427
+ }
428
+ if (session.status === "terminated") return;
429
+ for (;;) {
430
+ const event = session.client.takeEvent([
431
+ ...(session.status === "running" ? ["stopped"] : []),
432
+ "terminated",
433
+ "exited",
434
+ ]);
435
+ if (event === undefined) return;
436
+ if (event.event === "stopped") await this.#captureStop(session, event);
437
+ else {
438
+ session.status = "terminated";
439
+ session.stop = undefined;
440
+ this.#notify(session);
441
+ await session.javaRuntime?.close();
442
+ return;
443
+ }
444
+ }
445
+ }
406
446
  /** Continue or step and wait for the next observable execution state. */
407
447
  async command(
408
448
  session: DebugSession,
409
449
  command: "continue" | "next" | "stepIn" | "stepOut",
410
450
  signal?: AbortSignal,
411
451
  ): Promise<DebugSession> {
452
+ await this.refresh(session);
412
453
  if (session.status !== "stopped" || session.stop === undefined) {
413
454
  throw new Error(`Cannot ${command} while session is ${session.status}`);
414
455
  }
@@ -429,10 +470,13 @@ export class DebugSessionManager {
429
470
  expression: string,
430
471
  signal?: AbortSignal,
431
472
  ): Promise<DebugEvaluation> {
473
+ await this.refresh(session);
432
474
  if (session.status !== "stopped" || session.stop?.frame === undefined) {
433
475
  throw new Error(`Cannot evaluate while session is ${session.status}`);
434
476
  }
435
477
  const trimmed = expression.trim();
478
+ const stop = session.stop;
479
+ const frameId = session.stop.frame.id;
436
480
  if (trimmed.length === 0) throw new Error("Debug evaluation requires an expression");
437
481
  const response = await requiredClient(session).request<EvaluateBody>(
438
482
  "evaluate",
@@ -442,6 +486,8 @@ export class DebugSessionManager {
442
486
  if (typeof response.result !== "string") {
443
487
  throw new Error("Debug adapter returned no evaluation result");
444
488
  }
489
+ session.stop = { ...stop, variables: await this.#readVariables(session, frameId) };
490
+ this.#notify(session);
445
491
  return {
446
492
  expression: trimmed,
447
493
  result: response.result,
@@ -759,13 +805,16 @@ export class DebugSessionManager {
759
805
  "setBreakpoints",
760
806
  {
761
807
  source: { path: file, name: path.basename(file) },
762
- breakpoints: breakpoints.map(({ line }) => ({ line })),
808
+ breakpoints: breakpoints.map(({ requestedLine }) => ({ line: requestedLine })),
763
809
  sourceModified: false,
764
810
  },
765
811
  { signal },
766
812
  );
767
813
  for (const [index, breakpoint] of breakpoints.entries()) {
768
- breakpoint.verified = response.breakpoints?.[index]?.verified === true;
814
+ const bound = response.breakpoints?.[index];
815
+ breakpoint.verified = bound?.verified === true;
816
+ breakpoint.line = bound?.line ?? breakpoint.requestedLine;
817
+ breakpoint.adapterId = bound?.id;
769
818
  }
770
819
  }
771
820
 
@@ -800,19 +849,7 @@ export class DebugSessionManager {
800
849
  return;
801
850
  }
802
851
  if (event.event === "breakpoint") {
803
- const changed = asRecord(body.breakpoint);
804
- const changedSource = asRecord(changed.source);
805
- for (const breakpoint of session.breakpoints.values()) {
806
- if (
807
- changed.verified === true &&
808
- typeof changed.line === "number" &&
809
- changed.line === breakpoint.line &&
810
- typeof changedSource.path === "string" &&
811
- sameFilePath(changedSource.path, breakpoint.file)
812
- ) {
813
- breakpoint.verified = true;
814
- }
815
- }
852
+ this.#updateBreakpoint(session, event);
816
853
  await this.#waitForStop(session, signal);
817
854
  return;
818
855
  }
@@ -887,6 +924,22 @@ export class DebugSessionManager {
887
924
  if (session.options.adapter === "shell") this.#notify(session);
888
925
  }
889
926
 
927
+ #updateBreakpoint(session: DebugSession, event: DapEvent): void {
928
+ const changed = asRecord(asRecord(event.body).breakpoint);
929
+ const source = asRecord(changed.source);
930
+ for (const breakpoint of session.breakpoints.values()) {
931
+ const matches =
932
+ typeof changed.id === "number" && breakpoint.adapterId !== undefined
933
+ ? changed.id === breakpoint.adapterId
934
+ : typeof source.path === "string" &&
935
+ sameFilePath(source.path, breakpoint.file) &&
936
+ changed.line === breakpoint.requestedLine;
937
+ if (!matches) continue;
938
+ if (typeof changed.line === "number") breakpoint.line = changed.line;
939
+ breakpoint.verified = changed.verified === true;
940
+ }
941
+ this.#notify(session);
942
+ }
890
943
  async #captureStop(session: DebugSession, event: DapEvent, notify = true): Promise<void> {
891
944
  const client = requiredClient(session);
892
945
  const body = asRecord(event.body);
@@ -902,27 +955,7 @@ export class DebugSessionManager {
902
955
  }
903
956
  }
904
957
  }
905
- const variables: DebugVariable[] = [];
906
- if (frame !== undefined) {
907
- const scopes =
908
- (await client.request<ScopesBody>("scopes", { frameId: frame.id })).scopes ?? [];
909
- const localScopes =
910
- session.options.adapter === "r"
911
- ? scopes
912
- : scopes.filter((item) =>
913
- [item.name.toLowerCase(), item.presentationHint?.toLowerCase()].some(
914
- (value) => value?.includes("local") === true || value === "variables",
915
- ),
916
- );
917
- for (const scope of localScopes) {
918
- const values = await client.request<VariablesBody>("variables", {
919
- variablesReference: scope.variablesReference,
920
- start: 0,
921
- count: 100,
922
- });
923
- variables.push(...(values.variables ?? []));
924
- }
925
- }
958
+ const variables = frame === undefined ? [] : await this.#readVariables(session, frame.id);
926
959
  session.stopGeneration++;
927
960
  session.stop = {
928
961
  generation: session.stopGeneration,
@@ -936,6 +969,28 @@ export class DebugSessionManager {
936
969
  if (notify) this.#notify(session);
937
970
  }
938
971
 
972
+ async #readVariables(session: DebugSession, frameId: number): Promise<DebugVariable[]> {
973
+ const client = requiredClient(session);
974
+ const scopes = (await client.request<ScopesBody>("scopes", { frameId })).scopes ?? [];
975
+ const localScopes =
976
+ session.options.adapter === "r"
977
+ ? scopes
978
+ : scopes.filter((item) =>
979
+ [item.name.toLowerCase(), item.presentationHint?.toLowerCase()].some(
980
+ (value) => value?.includes("local") === true || value === "variables",
981
+ ),
982
+ );
983
+ const variables: DebugVariable[] = [];
984
+ for (const scope of localScopes) {
985
+ const values = await client.request<VariablesBody>("variables", {
986
+ variablesReference: scope.variablesReference,
987
+ start: 0,
988
+ count: 100,
989
+ });
990
+ variables.push(...(values.variables ?? []));
991
+ }
992
+ return variables;
993
+ }
939
994
  #notify(session: DebugSession): void {
940
995
  const snapshot = this.snapshot(session);
941
996
  for (const listener of this.#changeListeners) listener(snapshot);
@@ -130,15 +130,16 @@ export default async function registerDiagnostics(pi: ExtensionAPI): Promise<voi
130
130
  { ...first, text: `${status}\n${first.text}` },
131
131
  ...updated.content.slice(1),
132
132
  ],
133
+ details: { ...updated.details, diagnosticStatus: status },
133
134
  };
134
135
  },
135
136
  };
136
137
  },
137
138
  });
138
139
  api.describe({
139
- path: "diagnostics:<path> — lint and language-server diagnostics with reporting tool and readiness. Pending results and snapshots are not completed checks.",
140
+ path: "diagnostics:<path> — lint and language-server diagnostics with reporting tool and readiness.",
140
141
  views:
141
- "diagnostics — diagnostics alongside source text, with reporting tool and readiness. Pending results and snapshots are not completed checks.",
142
+ "diagnostics — diagnostics alongside source text, with reporting tool and readiness.",
142
143
  });
143
144
  },
144
145
  } satisfies ReadPlugin;
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-formatter",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.7.1"
6
+ "pi-agent-doctor": "0.7.2"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "peerDependencies": {
14
14
  "@earendil-works/pi-coding-agent": "*",
15
- "pi-agent-ide": "0.7.1"
15
+ "pi-agent-ide": "0.7.2"
16
16
  },
17
17
  "peerDependenciesMeta": {
18
18
  "pi-agent-ide": {
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "pi-agent-ide-languages",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.7.1"
6
+ "pi-agent-doctor": "0.7.2"
7
7
  },
8
8
  "pi": {
9
9
  "extensions": [
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "pi-agent-ide-lint",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
- "pi-agent-doctor": "0.7.1",
7
- "pi-agent-invariant": "0.7.1",
8
- "pi-agent-read": "0.7.1",
9
- "pi-agent-resource": "0.7.1",
10
- "pi-agent-text": "0.7.1"
6
+ "pi-agent-doctor": "0.7.2",
7
+ "pi-agent-invariant": "0.7.2",
8
+ "pi-agent-read": "0.7.2",
9
+ "pi-agent-resource": "0.7.2",
10
+ "pi-agent-text": "0.7.2"
11
11
  },
12
12
  "pi": {
13
13
  "extensions": [
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@earendil-works/pi-coding-agent": "*",
19
- "pi-agent-ide": "0.7.1"
19
+ "pi-agent-ide": "0.7.2"
20
20
  },
21
21
  "peerDependenciesMeta": {
22
22
  "pi-agent-ide": {
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "pi-agent-ide-lsp",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "cross-spawn": "^7.0.6",
7
- "pi-agent-doctor": "0.7.1",
8
- "pi-agent-invariant": "0.7.1",
9
- "pi-agent-read": "0.7.1",
10
- "pi-agent-resource": "0.7.1",
11
- "pi-agent-search": "0.7.1",
12
- "pi-agent-text": "0.7.1",
13
- "pi-agent-text-editor": "0.7.1",
7
+ "pi-agent-doctor": "0.7.2",
8
+ "pi-agent-invariant": "0.7.2",
9
+ "pi-agent-read": "0.7.2",
10
+ "pi-agent-resource": "0.7.2",
11
+ "pi-agent-search": "0.7.2",
12
+ "pi-agent-text": "0.7.2",
13
+ "pi-agent-text-editor": "0.7.2",
14
14
  "vscode-jsonrpc": "^9.0.0",
15
15
  "vscode-uri": "^3.1.0"
16
16
  },
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@earendil-works/pi-coding-agent": "*",
24
- "pi-agent-ide": "0.7.1"
24
+ "pi-agent-ide": "0.7.2"
25
25
  },
26
26
  "peerDependenciesMeta": {
27
27
  "pi-agent-ide": {
@@ -108,7 +108,6 @@ export function createLspSearchResolver(
108
108
  );
109
109
  if (result.complete && result.hits.length)
110
110
  lines.unshift(`SEARCH#${result.sessionId}:all:match selects all exact symbol matches.`);
111
- if (!result.complete) lines.push("Incomplete results; not a complete edit scope.");
112
111
  if (result.hits.length > 100) lines.push("Preview shortened; full source targets retained.");
113
112
  return {
114
113
  content: [{ type: "text", text: [heading, ...lines].join("\n") }],
@@ -32,9 +32,9 @@ export function formatAgentTerminalSnapshot(snapshot: TerminalSessionSnapshot):
32
32
  snapshot.completionReason === undefined
33
33
  ? undefined
34
34
  : `completionReason: ${snapshot.completionReason}`,
35
- snapshot.waitReason === undefined || snapshot.status !== "running"
36
- ? undefined
37
- : `next: Read ${snapshot.source} to inspect it, then use write or insert to send input.`,
35
+ snapshot.status === "running" && snapshot.background
36
+ ? `next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${snapshot.source} to inspect output; use write or insert when input is needed.`
37
+ : undefined,
38
38
  `outputRange: ${snapshot.outputStart}-${snapshot.outputEnd}`,
39
39
  snapshot.truncated ? "retainedOutput: earlier data omitted from memory" : undefined,
40
40
  truncation.truncated ? `fullOutput: ${snapshot.fullOutputPath}` : undefined,
@@ -34,7 +34,7 @@ const createRunParameters = (profile: ShellProfile) =>
34
34
  background: Type.Optional(
35
35
  Type.Boolean({
36
36
  description:
37
- "Return immediately while the terminal session continues. Defaults to false.",
37
+ "Set true to return after an initial output preview instead of waiting for completion. Defaults to false.",
38
38
  }),
39
39
  ),
40
40
  timeoutSeconds: Type.Optional(
@@ -42,7 +42,7 @@ const createRunParameters = (profile: ShellProfile) =>
42
42
  minimum: 0.1,
43
43
  maximum: 86_400,
44
44
  description:
45
- "Maximum foreground wait in seconds before returning the live session as background. Defaults to 60.",
45
+ "Set the foreground wait limit in seconds. On expiry, the live session returns in background without stopping the process. Ignored when background is true. Defaults to 60.",
46
46
  }),
47
47
  ),
48
48
  cwd: Type.Optional(
@@ -91,7 +91,7 @@ export function registerTerminalTools(
91
91
  promptGuidelines: [
92
92
  `Do not use ${toolName} commands or scripts to edit files. Use the standalone editing tools instead. Commands that inherently generate files, such as formatters and code generators, are allowed.`,
93
93
  ],
94
- description: `Use ${toolName} to execute a command in the user's configured ${profile.displayName} shell (${profile.executable}). Every call creates an addressable terminal session. Set background to true to continue without waiting. A foreground wait automatically returns the live session as background on timeout, a stable interactive prompt, or turn abort. Background completion is delivered automatically and wakes the agent. Silent background sessions wake an idle agent once for inspection after two minutes, with no further stale reminders for that session. Sessions survive extension reloads and keep the same shell: source. Output uses the shared Read limits, keeps the tail, and links a complete log file when truncated.`,
94
+ description: `Use ${toolName} to execute a command in the user's configured shell. Each call creates a new terminal session and returns its shell: source for inspection and interaction.`,
95
95
  parameters: runParameters,
96
96
  outputSchema: shellOutputSchema,
97
97
  async execute(_toolCallId, input, signal, onUpdate, context) {
@@ -52,6 +52,7 @@ export default async function registerVision(
52
52
  setup(api) {
53
53
  for (const view of ["image", "sequence"]) {
54
54
  api.addView({
55
+ contentKind: "any",
55
56
  view,
56
57
  presenter: { id: `vision-${view}`, present: (document) => document },
57
58
  });
@@ -47,13 +47,24 @@ export async function runIdePostEditGate(
47
47
  }
48
48
  : {
49
49
  diffStatuses: [
50
- { text: `Formatting failed (${formatterName})`, tone: "error" as const },
50
+ {
51
+ text: `Formatting failed (${formatterName})`,
52
+ formatter: formatterName,
53
+ tone: "error" as const,
54
+ },
51
55
  ],
52
56
  }),
53
57
  };
54
58
  } catch {
55
59
  return {
56
- diffStatuses: [{ text: "Formatting failed", tone: "error" as const }],
60
+ diffStatuses: [
61
+ {
62
+ text: "Formatting failed",
63
+ tone: "error" as const,
64
+ formattingStatus: "failed",
65
+ ...(formatterName === undefined ? {} : { formatter: formatterName }),
66
+ },
67
+ ],
57
68
  formatting: {
58
69
  status: "failed",
59
70
  ...(formatterName === undefined ? {} : { formatter: formatterName }),
@@ -1 +0,0 @@
1
- import{d as k,e as S,h as m,i as M}from"./chunk-CWD4O5PM.js";import{a as p}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var T=t.Union([t.Literal("pending"),t.Literal("applied"),t.Literal("not-applied"),t.Literal("unknown")]),b=t.Object({source:t.String(),effect:T,state:t.Optional(t.Union([t.Literal("present"),t.Literal("absent"),t.Literal("unknown")]))},{additionalProperties:!1}),O={effect:T,files:t.Array(b)};function R(s){return t.Object({operation:t.Literal(s),...O,operationId:t.Optional(t.String()),...s==="delete"||s==="flush"?{}:{target:t.Optional(t.String()),targetUnavailable:t.Optional(t.String())}},{additionalProperties:!1})}p(R,"mutationDataSchema");function N(s){return S(R(s))}p(N,"mutationResultSchema");var U=t.Object({id:t.String(),operation:t.String(),effect:T,errors:t.Array(k)},{additionalProperties:!1}),D=t.Object({operation:t.Literal("flush"),...O,operations:t.Array(U)},{additionalProperties:!1}),_=S(D);function u(s){return typeof s=="object"&&s!==null}p(u,"record");function F(s,i,h=[]){let r=s.details,l=u(r)?r:{};if((u(r)&&u(r.nativeEditBatch)?r.nativeEditBatch:void 0)?.state==="accepted")return{status:"success",errors:[],data:{operation:i,effect:"pending",...i!=="delete"&&typeof r.metadata?.resultTarget=="string"?{target:r.metadata.resultTarget}:{},files:typeof l.source=="string"?[{source:l.source,effect:"pending"}]:[]}};let g=new Set(h.map(e=>e.resourceSource)),n=[],f=[],E=r.results;for(let e of E??[]){let o=e.data,y=[...new Set([...(o.files??[]).map(c=>c.path),...o.path?[o.path]:[]])];for(let c of y)f.push({source:c,...g.has(c)?{state:"present"}:{},effect:g.has(c)||o.ok===!0&&o.files?.some(L=>L.path===c)?"applied":r.effect??"unknown"});for(let c of o.errors??[])n.push({code:c.code??"MUTATION_FAILED",message:c.reason??"Mutation failed",source:c.path});o.ok===!1&&(o.errors?.length??0)===0&&n.push({code:"MUTATION_FAILED",message:"Mutation failed",...o.path?{source:o.path}:{}})}for(let e of g)f.some(o=>o.source===e)||f.push({source:e,effect:"applied",state:"present"});let a=u(r.metadata)&&u(r.metadata.semanticAction)?r.metadata.semanticAction:void 0;if(a){let e=a.effect==="not-applied"||a.effect==="unknown"?a.effect:a.ok===!1?"unknown":"applied",o=typeof a.source=="string"?a.source:void 0;o&&f.push({source:o,...a.kind==="file-operation"&&a.ok===!0?{state:i==="delete"||i==="move"?"absent":"present"}:{},effect:i==="copy"&&typeof a.target=="string"&&a.target!==o?"not-applied":e}),typeof a.target=="string"&&f.push({source:a.target,effect:e,...a.kind==="file-operation"&&a.ok===!0?{state:"present"}:{}}),u(a.error)&&n.push(m(a.error.message,typeof a.error.code=="string"?a.error.code:"MUTATION_FAILED",o)),typeof a.postProcessingError=="string"&&n.push(m(a.postProcessingError,"POST_EDIT_FAILED",o)),a.ok===!1&&n.length===0&&n.push(m("Resource operation failed","MUTATION_FAILED",o))}let d=[...new Map(f.map(e=>[e.source,e])).values()];if(Array.isArray(r.metadata?.resultFileStates))for(let e of r.metadata.resultFileStates){if(!u(e))continue;let o=d.find(y=>y.source===e.source);o&&(e.state==="present"||e.state==="absent")&&(o.state=e.state)}let A=d.some(e=>e.effect==="applied");s.isError&&n.length===0&&n.push({code:"MUTATION_FAILED",message:"Mutation failed"}),(E?.length??0)===0&&!a&&g.size===0&&n.length===0&&r.effect!=="not-applied"&&n.push({code:"UNKNOWN_RESULT",message:"Mutation effects were not reported"});let w=d.some(e=>e.effect==="unknown")||n.some(e=>e.code==="UNKNOWN_RESULT")?"unknown":A?"applied":"not-applied";return{status:n.length===0?"success":!a&&A&&d.some(e=>e.effect!=="applied")?"partial":"error",data:{operation:i,effect:w,files:d,...i!=="delete"&&typeof r.metadata?.resultTarget=="string"?{target:r.metadata.resultTarget}:{},...i!=="delete"&&typeof r.metadata?.targetUnavailable=="string"?{targetUnavailable:r.metadata.targetUnavailable}:{}},errors:n}}p(F,"mutationOutcome");function j(s,i,h=[],r){let l=F(s,i,h);return l.data&&r!==void 0&&(l.data.operationId=r),M(s,R(i),l)}p(j,"structuredMutation");export{R as a,N as b,D as c,_ as d,F as e,j as f};
@@ -1,3 +0,0 @@
1
- import{e as j}from"./chunk-PS2B6THP.js";import{i as T,o as m,t as L,u as C}from"./chunk-ZPT5D4VP.js";import{a as y}from"./chunk-ZC65Z3CK.js";import{a as d}from"./chunk-EI7MMDWY.js";function Te(e,n){let{lines:t,truncation:r,...i}=e,o=t?.map(a=>{let l=[a.lineNumber,L(a.content,n),a.lineEnding];return(a.presentation!==void 0||a.metadata!==void 0)&&l.push(a.presentation),a.metadata!==void 0&&l.push(a.metadata),l}),{content:s,...u}=r??{};return{...i,...o===void 0?{}:{storedLines:o},...r===void 0?{}:{truncation:u,truncatedText:L(s??"",n)}}}d(Te,"compactReadDetails");function H(e,n){let t=e;if(t.storedLines===void 0&&t.truncatedText===void 0)return e;let{storedLines:r,truncatedText:i,truncation:o,...s}=t;return{...s,...r===void 0?{}:{lines:r.map(([u,a,l,c,p])=>({lineNumber:u,content:C(a,n),lineEnding:l,...c==null?{}:{presentation:c},...p==null?{}:{metadata:p}}))},...o===void 0?{}:{truncation:{...o,content:C(i??"",n)}}}}d(H,"restoreReadDetails");import f from"node:path";import{homedir as G}from"node:os";import{createReadToolDefinition as X,getReadmePath as J}from"@earendil-works/pi-coding-agent";import{Text as Z}from"@earendil-works/pi-tui";var v=X(process.cwd()),K=new Set(["AGENTS.override.md","AGENTS.md","AGENTS.MD","CLAUDE.md","CLAUDE.MD"]);function $(e,n=process.cwd()){if(typeof e!="object"||e===null)return;let t=e,r=t.path;if(typeof r!="string"||r.length===0||r.includes("#")||!f.isAbsolute(r)&&/^[a-z][a-z\d+.-]*:/iu.test(r)||t.views!==void 0&&(!Array.isArray(t.views)||t.views.length>0)||t.offset!==void 0&&(typeof t.offset!="number"||!Number.isInteger(t.offset)||t.offset<1)||t.limit!==void 0&&(typeof t.limit!="number"||!Number.isInteger(t.limit)||t.limit<1))return;let i=r.startsWith("~/")?f.join(G(),r.slice(2)):r,o=f.resolve(n,i),s=f.basename(o),u=f.relative(f.dirname(J()),o),a=!f.isAbsolute(u)&&(u==="README.md"||u.startsWith(`docs${f.sep}`)||u.startsWith(`examples${f.sep}`));if(!(s!=="SKILL.md"&&!K.has(s)&&!a))return{path:r,...t.offset===void 0?{}:{offset:t.offset},...t.limit===void 0?{}:{limit:t.limit}}}d($,"nativeReadArguments");function A(e,n){return{...e,args:n,lastComponent:e.lastComponent instanceof Z?e.lastComponent:void 0}}d(A,"nativeReadContext");import{getLanguageFromPath as k,getMarkdownTheme as Y,highlightCode as E,keyHint as Q}from"@earendil-works/pi-coding-agent";import{Container as w,Markdown as _,Text as ee,truncateToWidth as S,visibleWidth as R,wrapTextWithAnsi as q}from"@earendil-works/pi-tui";var g=12;function ne(e,n,t){let r=typeof n=="number"?n:void 0,i=typeof t=="number"?t:void 0;if(r===void 0&&i===void 0)return{pathSuffix:"",qualifiers:[],details:[]};if(e==="inherited source"||e.includes("#")){let a=r??1,l=i===void 0?String(a):`${a}-${a+i-1}`;return{pathSuffix:"",qualifiers:[{text:`relative lines ${l}`}],details:[{label:"relative lines",value:l}]}}if(r!==void 0&&r<0)return{pathSuffix:"",qualifiers:[{text:`tail ${Math.abs(r)}`},...i===void 0?[]:[{text:`limit ${i}`}]],details:[{label:"tail",value:String(Math.abs(r))},...i===void 0?[]:[{label:"limit",value:String(i)}]]};let s=Math.max(1,r??1),u=i===void 0?String(s):`${s}-${s+i-1}`;return{pathSuffix:`:${u}`,qualifiers:[],details:[{label:"lines",value:u}]}}d(ne,"readWindowPresentation");function We(e,n,t){let r=$(e,t.cwd);if(r!==void 0)return y(v.renderCall)(r,n,A(t,r));if(typeof e.path=="string"&&e.path.startsWith("shell:"))return new w;let i=typeof e.path=="string"?e.path:"inherited source",o=ne(i,e.offset,e.limit),s=Array.isArray(e.views)?e.views.filter(l=>typeof l=="string"):[],u=[...o.qualifiers,...s.length===0?[]:[{text:`views ${s.join(",")}`}]],a=[...typeof e.path=="string"?[{label:"path",value:e.path}]:[],...o.details,...s.length===0?[]:[{label:"views",value:s.join(",")}]];return j(t.lastComponent,{tool:"read",primary:{text:`${i}${o.pathSuffix}`,color:typeof e.path=="string"?"accent":"muted",underline:typeof e.path=="string",truncate:"start"},qualifiers:u,details:a,expanded:t.expanded},n)}d(We,"renderReadCall");function je(e){let n=new WeakMap;return(t,r,i,o)=>{let s=e.nativeResources?$(o.args,o.cwd):void 0;if(s!==void 0&&!r.isPartial)return y(v.renderResult)({...t,details:{truncation:D(t.details).truncation}},r,i,A(o,s));if(r.isPartial||o.isError){let p=P(t),B=o.isError?"error":"dim";return new ee(i.fg(B,p),0,0)}let u=D(t.details).diagnosticCheck;if(u?.complete&&u.count===0)return new w;if(!me(t))return o.lastComponent instanceof w?o.lastComponent:new w;let a=n.get(t);a===void 0&&(a=H(D(t.details),P(t)),n.set(t,a));let c=(o.lastComponent instanceof b?o.lastComponent:void 0)??new b({result:t,details:a,options:e,expanded:r.expanded,theme:i});return c.update({result:t,details:a,options:e,expanded:r.expanded,theme:i}),c}}d(je,"createReadResultRenderer");var b=class{constructor(n){this.state=n}static{d(this,"ReadResultPanel")}cached;update(n){this.state.result===n.result&&this.state.details===n.details&&this.state.options===n.options&&this.state.expanded===n.expanded&&this.state.theme===n.theme||(this.state=n,this.invalidate())}render(n){if(this.cached?.width===n)return this.cached.lines;if(n<8){let c=[S(V(this.state,n),Math.max(1,n))];return this.cached={width:n,lines:c},c}let t=n-2,r=Math.max(1,t-2),i=oe(this.state,r),o=se(i.state,r).flatMap(c=>q(c,r)),s=ue(o,this.state.expanded,this.state.theme,i.hasHiddenRows),u=[le(this.state,t,this.state.theme)];for(let c of s)for(let p of q(c,r))u.push(I(p,t,this.state.theme));let a=fe(this.state.details,this.state.theme);a!==void 0&&u.push(I(a,t,this.state.theme)),u.push(this.state.theme.fg("borderMuted",`\u2570${"\u2500".repeat(t)}\u256F`));let l=u.map(c=>S(c,n));return this.cached={width:n,lines:l},l}invalidate(){this.cached=void 0}},te=100,re=g,ie=4;function oe(e,n){if(e.expanded)return{state:e,hasHiddenRows:!1};let t=N(e.details);if(t!==void 0&&t.length>te)return{state:{...e,details:{...e.details,lines:t.slice(0,re)}},hasHiddenRows:!0};if(t!==void 0)return{state:e,hasHiddenRows:!1};let r=Math.max(g,n*g*ie),i=e.result.content.map(s=>s.type!=="text"||s.text.length<=r?s:{...s,text:s.text.slice(0,r)}),o=i.some((s,u)=>{let a=e.result.content[u];return s.type==="text"&&a?.type==="text"&&s.text.length<a.text.length});return o?{state:{...e,result:{...e.result,content:i}},hasHiddenRows:o}:{state:e,hasHiddenRows:!1}}d(oe,"compactRenderInput");function se(e,n){let t=N(e.details),r=pe(e.result,t,e.details,!e.expanded);if(e.options.kind==="markdown"||Re(e.details,t,e.options.kind)){let a=new _(r,0,0,Y());return M(a.render(n),e.theme)}if(e.options.kind==="code-view"){let a=t===void 0?h(r).map(l=>O(l,e.theme,!1)):z(t)?ae(t,!e.expanded,e.theme):de(t,e.theme);return M(a,e.theme)}let i=t!==void 0&&z(t),o=t===void 0||i?h(r).map(x):t.map(({content:a})=>x(a)),s=W(e.details,t),u=s===void 0?o.map(a=>e.theme.fg("toolOutput",a)):i?U(t,s,!e.expanded,e.theme):E(o.join(`
2
- `),s);return M(u,e.theme)}d(se,"renderContentRows");function U(e,n,t,r){return e.flatMap(i=>{let o=x(i.content),s=E(o,n)[0]??r.fg("toolOutput",o),u=!1,a=m({source:"",content:i.content,lines:[i]},{compact:t});return h(a).map(l=>{if(!u&&o.length>0){let c=l.indexOf(o);if(c>=0)return u=!0,`${r.fg("toolOutput",l.slice(0,c))}${s}${r.fg("toolOutput",l.slice(c+o.length))}`}return r.fg("toolOutput",l)})})}d(U,"renderHighlightedPresentedLines");function ae(e,n,t){return e.flatMap(r=>{let i=T(r);if(i===void 0){let s=m({source:"",content:r.content,lines:[r]},{compact:n});return h(s).map(u=>O(u,t,!1))}let o=k(i.source);if(o===void 0){let s=m({source:"",content:r.content,lines:[r]},{compact:n});return h(s).map(u=>t.fg("toolOutput",u))}return U([r],o,n,t)})}d(ae,"renderPresentedCodeViewLines");function de(e,n){return e.map(t=>{let r=T(t);if(r===void 0)return O(t.content,n);let i=k(r.source),o=x(F(t.content));return i===void 0?n.fg("toolOutput",o):E(o,i)[0]??n.fg("toolOutput",o)})}d(de,"renderCodeViewLines");function F(e){return e.replace(/(?:[ \t]{2,}<!--[ \t]+scope-(?:begin|end)-[^\s>]+[ \t]+-->)+[ \t]*$/u,"")}d(F,"stripScopeMarkers");function O(e,n,t=!0){let r=x(t?F(e):e);return/^#{2,3}\s/u.test(r)?n.fg("mdHeading",n.bold(r.replace(/^#{2,3}\s+/u,""))):/^(?:Lines|Reason|Recovery):/u.test(r)?n.fg("dim",r):/^[\p{L}][^:]*:$/u.test(r)?n.fg("accent",n.bold(r)):/^\s*[-*]\s/u.test(r)?n.fg("mdListBullet",r):n.fg("toolOutput",r)}d(O,"renderCodeViewLabel");function ue(e,n,t,r=!1){if(n||e.length<=g&&!r)return e;let i=e.slice(0,g-1),o=e.length-i.length,s=r?"more rows":`${String(o)} more ${o===1?"row":"rows"}`;return[...i,`${t.fg("dim",`\u2026 ${s} \xB7 `)}${Q("app.tools.expand","to expand")}`]}d(ue,"compactRows");function le(e,n,t){let r=d(s=>t.fg("borderMuted",s),"frame"),i=S(` ${V(e,Math.max(1,n-1))} `,Math.max(0,n-1),""),o="\u2500".repeat(Math.max(0,n-R(i)-1));return`${r("\u256D\u2500")}${i}${r(`${o}\u256E`)}`}d(le,"renderTopBorder");function V(e,n){let t=e.options.label??he(W(e.details,N(e.details))),r=e.details.source??"read result",i=ce(e.details),o=e.theme.fg("accent",e.theme.bold(t)),s=i===void 0?"":e.theme.fg("dim",` \xB7 ${i}`),u=Math.max(1,n-R(o)-R(s)-2),a=xe(r,u);return`${o} ${e.theme.fg("muted",a)}${s}`}d(V,"readTitle");function ce(e){if(!(e.startLine===void 0||e.endLine===void 0||e.totalLines===void 0||e.totalLines<=0))return`${String(e.startLine)}\u2013${String(e.endLine)} / ${String(e.totalLines)}`}d(ce,"sourceRange");function fe(e,n){let t=e.truncation;if(t?.firstLineExceedsLimit===!0)return n.fg("warning","First source line is larger than the saved read limit");if(t?.truncated===!0)return n.fg("warning",`Saved result contains ${String(t.outputLines)} of ${String(t.totalLines)} rendered rows`)}d(fe,"readStatus");function I(e,n,t){let r=Math.max(0,n-2),i=S(e,r),o=` ${i}${" ".repeat(Math.max(0,r-R(i)))} `,s=t.fg("borderMuted","\u2502");return`${s}${o}${s}`}d(I,"framed");function pe(e,n,t,r){if(n!==void 0)return m({source:t.source??"",content:"",lines:n},{compact:r});let i=P(e);return t.truncation===void 0&&!(t.totalLines!==void 0&&t.endLine!==void 0&&t.endLine<t.totalLines)?i:i.replace(/\n\n\[(?:Showing lines|Output truncated|\d+ more lines in source)[\s\S]*\]$/u,"")}d(pe,"cleanText");function z(e){return e.some(n=>n.presentation!==void 0)}d(z,"hasPresentation");function h(e){let n=e.split(/\r\n|\r|\n/u);return n.at(-1)===""&&/(?:\r\n|\r|\n)$/u.test(e)&&n.pop(),n}d(h,"splitTextRows");function P(e){return e.content.flatMap(n=>n.type==="text"?[n.text]:[]).join(`
3
- `)}d(P,"textBlocks");function N(e){return e.lines}d(N,"readLines");function D(e){return typeof e=="object"&&e!==null?e:{}}d(D,"readDetails");function me(e){return e.content.some(n=>n.type==="text")}d(me,"hasTextContent");function W(e,n){let r=n?.map(T).find(i=>i!==void 0)?.source??e.source;return r===void 0?void 0:k(ge(r))}d(W,"languageFor");function Re(e,n,t){return t==="source"&&W(e,n)==="markdown"}d(Re,"isMarkdownSource");function ge(e){try{let n=new URL(e);return n.protocol==="file:"?n.pathname:`${n.pathname}${n.search}`}catch{return e.replace(/#[^/\\]*$/u,"").replace(/^[A-Za-z][A-Za-z\d+.-]*:(?=[/\\])/u,"")}}d(ge,"normalizeSourcePath");function x(e){let n="";for(let t of e.replaceAll(" "," ".repeat(4))){let r=y(t.codePointAt(0));n+=r<32||r===127?"\uFFFD":t}return n}d(x,"normalizeText");function he(e){return e===void 0?"TEXT":{javascript:"JS",json:"JSON",markdown:"MD",python:"PY",rust:"RS",typescript:"TS"}[e]??e.slice(0,4).toUpperCase()}d(he,"languageLabel");function M(e,n){return e.length===0?[n.fg("dim","Empty content")]:[...e]}d(M,"nonEmptyRows");function xe(e,n){return R(e)<=n?e:n<=1?"\u2026":`\u2026${e.slice(-(n-1))}`}d(xe,"truncateFromStart");export{Te as a,g as b,We as c,je as d};
@@ -1,3 +0,0 @@
1
- import{a as i}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as Ce}from"node:async_hooks";function oe(){return{pending:new Set,active:new Ce}}i(oe,"createSchedulerState");function ve(r,e){return r===void 0||e===void 0?!0:r.some(t=>e.some(n=>(t.mode==="write"||n.mode==="write")&&(t.resource==="*"||n.resource==="*"||t.resource===n.resource||t.recursive===!0&&n.resource.startsWith(t.resource.endsWith("/")?t.resource:`${t.resource}/`)||n.recursive===!0&&t.resource.startsWith(n.resource.endsWith("/")?n.resource:`${n.resource}/`))))}i(ve,"conflicts");function Re(r,e,t){if(e===void 0||!t&&e.some(o=>o.mode!=="read"))return!1;if(r===void 0)return!0;let n=new Map;for(let o of e){let s=o.group??o.resource;n.set(s,[...n.get(s)??[],o])}return[...n.values()].every(o=>o.some(s=>r.some(a=>(s.mode==="read"||a.mode==="write")&&(a.resource==="*"||s.resource===a.resource&&(s.recursive!==!0||a.recursive===!0)||a.recursive===!0&&s.resource.startsWith(a.resource.endsWith("/")?a.resource:`${a.resource}/`)))))}i(Re,"coveredAccess");async function we(r,e){if(e===void 0)return await r;e.throwIfAborted();let t,n=new Promise((o,s)=>{t=i(()=>s(e.reason),"abort"),e.addEventListener("abort",t,{once:!0})});try{return await Promise.race([r,n])}finally{e.removeEventListener("abort",t)}}i(we,"waitForDependencies");var U=class r{constructor(e=oe()){this.state=e}static{i(this,"ResourceScheduler")}run(e,t,n,o={}){let s=Promise.resolve(e),a=this.state.active.getStore();if(a?.open){let m=s.then(b=>{if(n?.throwIfAborted(),!Re(a.accesses,b,a.allowNestedWrites))throw Object.assign(new Error("Nested resource access must be covered by its parent reservation and permitted by its owner."),{code:"UNDECLARED_RESOURCE_ACCESS"});return b});a.nested??=new r;let y=a.nested.run(m,t,n,{allowNestedWrites:a.allowNestedWrites});return a.children.add(y),y.then(()=>a.children.delete(y),()=>a.children.delete(y)),y}let d=[...this.state.pending],u=s.catch(()=>{}),p,f=new Promise(m=>{p=m}),h={accesses:u,done:f};return this.state.pending.add(h),(async()=>{try{n?.throwIfAborted();let m=await we(s.then(async b=>(await Promise.all(d.map(q=>Promise.race([q.done,q.accesses.then(ye=>ve(b,ye)?q.done:void 0)]))),b)),n);n?.throwIfAborted();let y={accesses:m,children:new Set,open:!0,allowNestedWrites:o.allowNestedWrites===!0};try{return await this.state.active.run(y,t)}finally{for(;y.children.size>0;)await Promise.allSettled([...y.children]);y.open=!1}}finally{this.state.pending.delete(h),p()}})()}},Te=Symbol.for("pi-agent-resource.resource-scheduler-state"),be=globalThis,Ee=be[Te]??=oe(),Se=new U(Ee);import{realpath as xe,stat as Ae}from"node:fs/promises";import j from"node:path";import{fileURLToPath as Oe}from"node:url";async function se(r,e,t){if(/^[a-z][a-z\d+.-]*:/iu.test(r)&&!/^[a-z]:[\\/]/iu.test(r)&&!r.startsWith("file:"))return[{resource:r,mode:t}];let n=j.resolve(e,r.startsWith("file:")?Oe(r):r),[o,s]=await Promise.allSettled([xe(n),Ae(n,{bigint:!0})]),a;if(o.status==="fulfilled")a=o.value;else{let f=o.reason;if(!(f instanceof Error)||!("code"in f)||f.code!=="ENOENT")throw f;let h=j.dirname(n);if(h===n)a=n;else{let y=(await se(h,e,t)).find(b=>b.resource.startsWith("file:"));a=j.join(y?.resource.slice(5)??h,j.basename(n))}}let d=a.split(j.sep).join("/"),u=`file:${process.platform==="win32"?d.toLowerCase():d}`,p=[{resource:u,group:u,mode:t}];if(s.status==="fulfilled"){let f=s.value;f.isDirectory()&&(p[0]={resource:u,group:u,mode:t,recursive:!0}),f.ino!==0n&&p.push({resource:`inode:${f.dev}:${f.ino}`,group:u,mode:t,recursive:f.isDirectory()})}else{let f=s.reason;if(!(f instanceof Error)||!("code"in f)||f.code!=="ENOENT")throw f}return p}i(se,"resourceAccesses");import{Type as g}from"typebox";import{Value as ke}from"typebox/value";var D=g.Object({code:g.String(),message:g.String(),source:g.Optional(g.String())},{additionalProperties:!1});function ie(r){return{...g.Union([g.Object({status:g.Literal("success"),data:r,errors:g.Array(D,{maxItems:0})},{additionalProperties:!1}),g.Object({status:g.Union([g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(D,{minItems:1})},{additionalProperties:!1})]),type:"object",properties:{status:g.Union([g.Literal("success"),g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(D)},required:["status","errors"],additionalProperties:!1}}i(ie,"structuredResultSchema");var ae=1024*1024;function z(r){let e=new Set,t=i(n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(typeof n!="object"||e.has(n))throw new TypeError("Structured data must be finite, acyclic JSON");if(!Array.isArray(n)&&Object.getPrototypeOf(n)!==Object.prototype&&Object.getPrototypeOf(n)!==null)throw new TypeError("Structured data must not contain classes or raw byte buffers");e.add(n);for(let o of Array.isArray(n)?n:Object.values(n))t(o);e.delete(n)}},"visit");if(t(r),Buffer.byteLength(JSON.stringify(r))>ae)throw new RangeError("Structured data exceeds 1 MiB; return a smaller window or a full-result reference")}i(z,"assertJsonData");function ce(r,e="EXECUTION_FAILED",t){return{code:typeof r=="object"&&r!==null&&"code"in r&&typeof r.code=="string"?r.code:e,message:r instanceof Error?r.message:String(r),...t===void 0?{}:{source:t}}}i(ce,"resultError");function Ne(r,e,t){try{if(z(t),!ke.Check(ie(e),t))throw new TypeError("Result adapter returned data outside its public schema");return{...r,structuredContent:t,isError:t.status!=="success"}}catch(n){let o=ce(n,"INVALID_STRUCTURED_RESULT"),s={status:"error",errors:[o]};return z(s),{...r,content:[...r.content,{type:"text",text:o.message}],structuredContent:s,isError:!0}}}i(Ne,"withStructuredResult");function je(r,e){if(e.length===0)return;let t=r.trim();if(t.length===0||/[\r\n]/u.test(t))throw new TypeError("Content provider summary must be one non-empty line");return[t,...e.map(({description:n})=>n)].join(`
2
- `)}i(je,"renderContentDescription");import{Type as l}from"typebox";import{Value as He}from"typebox/value";import{Type as c}from"typebox";import{Value as Pe}from"typebox/value";var C={additionalProperties:!0},P=c.Function([],c.Unknown()),v=c.String({minLength:1}),Ie=c.Object({type:c.Literal("text"),text:c.String(),textSignature:c.Optional(c.String())},C),_e=c.Object({type:c.Literal("image"),data:c.String(),mimeType:c.String()},C),Ue=c.Object({type:c.Literal("custom"),kind:v,data:c.Unknown()},C),De=c.Array(c.Union([Ie,_e,Ue]),{minItems:1}),ue=c.Union([c.Object({source:v,link:c.Optional(v),read:P,write:c.Optional(c.Never())},C),c.Object({source:v,link:c.Optional(v),read:c.Optional(c.Never()),write:P},C),c.Object({source:v,link:c.Optional(v),read:P,write:P},C)]),Le=c.Object({id:v,tryResolve:P},C),$e=c.Union([c.Object({kind:c.Literal("not-handled")},C),c.Object({kind:c.Literal("resolved"),resource:ue},C),c.Object({kind:c.Literal("failed"),error:c.Unknown()},C)]);function J(r){return L(De,r)?$(()=>r.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}i(J,"isAgentContent");function le(r){return L(ue,r)?$(()=>{let e=r,t=!("read"in e)||typeof e.read=="function",n=!("write"in e)||typeof e.write=="function";return t&&n}):!1}i(le,"isResource");function We(r){return L(Le,r)}i(We,"isResourceResolver");function Ve(r){return L($e,r)?$(()=>{let e=r;return e.kind!=="resolved"||le(e.resource)}):!1}i(Ve,"isResourceResolutionAttempt");function L(r,e){return $(()=>Pe.Check(r,e))}i(L,"safeCheck");function $(r){try{return r()}catch{return!1}}i($,"safeEvaluate");var R={additionalProperties:!0},Me=l.Function([],l.Unknown()),W=l.String({minLength:1}),Fe=l.Object({provider:W,capability:l.Union([l.Literal("read"),l.Literal("write")])},R),Ke=l.Object({source:W,bytes:l.Unknown(),mediaType:l.Optional(l.String())},R),qe=l.Object({signal:l.Optional(l.Unknown())},R),ze=l.Object({id:W,description:W,tryConvert:Me},R),Je=l.Union([l.Object({kind:l.Literal("not-handled")},R),l.Object({kind:l.Literal("converted"),content:l.Unknown()},R),l.Object({kind:l.Literal("failed"),error:l.Unknown()},R)]),Be=l.Object({target:l.Unknown(),converter:l.Unknown(),priority:l.Optional(l.Number())},R);function A(r){return O(Fe,r)&&S(()=>r.provider.trim().length>0)}i(A,"isContentTarget");function B(r){return O(Ke,r)?S(()=>{let e=r;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}i(B,"isContentInput");function Y(r){return O(qe,r)?S(()=>{let e=r;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}i(Y,"isContentConversionContext");function de(r){return O(ze,r)?S(()=>{let e=r;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}i(de,"isContentConverter");function G(r){return O(Je,r)?S(()=>{let e=r;return e.kind!=="converted"||J(e.content)}):!1}i(G,"isContentConversionAttempt");function E(r){return O(Be,r)?S(()=>{let e=r;return A(e.target)&&de(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}i(E,"isContentConverterRegistration");function O(r,e){return S(()=>He.Check(r,e))}i(O,"safeCheck");function S(r){try{return r()}catch{return!1}}i(S,"safeEvaluate");var V=class extends Error{static{i(this,"UnsupportedContentError")}source;target;constructor(e,t){super(`No content converter for ${e} in ${t.provider}/${t.capability}`),this.name="UnsupportedContentError",this.source=e,this.target=t}};function Q(r){if(!A(r))throw new TypeError("Invalid content target");let e={...r},t=[],n=i(()=>[...t].sort((o,s)=>o.priority-s.priority||o.order-s.order),"snapshotConverters");return{target:e,register(o){if(!E(o))throw new TypeError("Invalid content converter registration");if(!k(e,o.target))throw new Error(`Content converter ${o.converter.id} targets ${o.target.provider}/${o.target.capability}, not ${e.provider}/${e.capability}`);if(t.some(({converter:s})=>s.id===o.converter.id))throw new Error(`Content converter ${o.converter.id} is already registered for ${e.provider}/${e.capability}`);t.push({converter:o.converter,priority:o.priority??0,order:t.length})},listDescriptions(){return n().map(({converter:o})=>({id:o.id,description:o.description}))},async convert(o,s){if(!B(o))throw new TypeError("Invalid content input");if(!Y(s))throw new TypeError("Invalid content conversion context");X(s.signal);let a=n();for(let{converter:d}of a){X(s.signal);let u=await d.tryConvert(o,s);if(X(s.signal),!G(u))throw new TypeError(`Content converter ${d.id} returned an invalid outcome`);if(u.kind!=="not-handled"){if(u.kind==="failed")throw u.error;return u.content}}throw new V(o.source,e)}}}i(Q,"createContentRunner");function k(r,e){return r.provider===e.provider&&r.capability===e.capability}i(k,"targetsEqual");function X(r){r?.throwIfAborted()}i(X,"throwIfAborted");import{Type as w}from"typebox";import{Value as Ye}from"typebox/value";var N="pi-agent-resource/content-conversion",H=2,I=`${N}/host/ready`,_=`${N}/converter/register`,fe={additionalProperties:!0},Ge=w.Function([],w.Unknown()),Xe=w.Object({protocol:w.Literal(N),apiVersion:w.Literal(H),target:w.Unknown()},fe),Qe=w.Object({registration:w.Unknown(),accept:Ge},fe);function Z(r){return pe(Xe,r)&&te(()=>A(r.target))}i(Z,"isContentHostReady");function ee(r){return pe(Qe,r)&&te(()=>E(r.registration))}i(ee,"isContentConverterRegistrationRequest");function pe(r,e){return te(()=>Ye.Check(r,e))}i(pe,"safeCheck");function te(r){try{return r()}catch{return!1}}i(te,"safeEvaluate");function Ze(r,e){let t=Q(e),n=r.events.on(_,o=>{if(!ee(o))throw new Error("Invalid content converter registration request");if(!k(t.target,o.registration.target))return;let s;try{t.register(o.registration),s=Promise.resolve()}catch(a){s=Promise.reject(a instanceof Error?a:new Error("Content converter registration failed",{cause:a}))}o.accept(s)});return r.on("session_shutdown",n),r.events.emit(I,{protocol:N,apiVersion:H,target:t.target}),{target:t.target,listDescriptions(){return t.listDescriptions()},convert(o,s){return t.convert(o,s)}}}i(Ze,"createContentHost");function et(r,e){if(!E(e))throw new TypeError("Invalid content converter registration");let t=i(()=>{let s,a={registration:e,accept(d){if(s!==void 0)throw new Error(`Content converter ${e.converter.id} registration was accepted more than once`);s=d}};return r.events.emit(_,a),s},"announce"),n=i(()=>{},"unsubscribe");n=r.events.on(I,s=>{if(!Z(s))throw new Error("Invalid content conversion host readiness event");if(!k(e.target,s.target))return;let a=t();if(a===void 0)throw new Error(`${s.target.provider}/${s.target.capability} announced readiness without accepting content converter ${e.converter.id}`);n(),a.catch(()=>{})}),r.on("session_shutdown",n);let o=t();if(o!==void 0)return n(),o}i(et,"connectContentConverter");import{createHash as ge,randomUUID as re}from"node:crypto";import{statSync as tt}from"node:fs";import{readFile as rt}from"node:fs/promises";import T from"node:path";import{fileURLToPath as nt}from"node:url";import{Type as M}from"typebox";var ot=M.Union([M.String(),M.Array(M.String())]),x="RESULT#",he="pi-agent-resource:result-targets",K=class{static{i(this,"ResultTargetStore")}#e=new Map;#o=new Map;#n=new Map;#t=new Map;clear(){this.#e.clear(),this.#o.clear(),this.#n.clear(),this.#t.clear()}register(e,t,n=!0){for(let s of e)this.refresh(s.source,t);let o=`${x}${re()}`;return this.#e.set(o,{state:"ready",targets:ne(e),complete:n,cwd:T.resolve(t)}),o}reserve(e){let t=`${x}${re()}`;return this.#e.set(t,{state:"pending",cwd:T.resolve(e)}),t}confirm(e,t,n){let o=this.#e.get(e);if(o?.state!=="pending"||o.cwd!==T.resolve(n))throw new Error("Only a pending result in this worktree can be confirmed.");for(let s of t)this.refresh(s.source,n);this.#e.set(e,{state:"ready",cwd:o.cwd,targets:ne(t),complete:!0})}reject(e,t){let n=this.#e.get(e);n?.state==="pending"&&this.#e.set(e,{state:"rejected",cwd:n.cwd,reason:t})}resolve(e,t){e=this.source(e,t);let n=this.#r(e),o=[],s=!0;for(let a of n){let d=this.#e.get(a);if(d===void 0)throw new Error("Result target expired or unknown; repeat Read/Search.");if(d.cwd!==T.resolve(t))throw new Error("Result target belongs to another worktree.");if(d.state==="pending")throw new Error("Result target is pending; its write has not been confirmed.");if(d.state==="rejected")throw new Error(d.reason);for(let u of d.targets)this.refresh(u.source,t);if(!this.#e.has(a))throw new Error("Result target expired after its snapshot changed; repeat Read/Search.");s&&=d.complete,o.push(...d.targets)}return{targets:ne(o),complete:s}}resolveOrdered(e,t){let n=this.resolve(e,t),o=[],s=new Set;for(let a of new Set(this.#r(this.source(e,t))))for(let d of this.resolve(a,t).targets)for(let u of d.ranges){let p=JSON.stringify([d.source,u]);s.has(p)||(s.add(p),o.push({...d,ranges:[u]}))}return{targets:o,complete:n.complete}}async verify(e,t){try{await me(e,t)}catch(n){if(!t?.aborted)for(let o of e.targets)this.invalidate(o.source);throw n}}publish(e,t,n,o=[]){let s=re();for(let p of o)this.refresh(p,n);let a=[];try{a=this.#r(e)}catch{}let d=`<system-result note="Internal reference; not part of the file. Do not edit."><uuid>${s}</uuid></system-result>
3
- ${t}`,u=e!==null&&typeof e=="object"&&"status"in e&&e.status==="success";if(u&&"data"in e){let p=e.data;if(p!==null&&typeof p=="object"&&"matches"in p&&Array.isArray(p.matches)){let f=p.matches;for(let h of f){if(h===null||typeof h!="object"||!("target"in h)||typeof h.target!="string"||!this.#e.has(h.target)||!("references"in h))continue;let m=h.references;m!==null&&typeof m=="object"&&"match"in m&&typeof m.match=="string"&&/^SEARCH#[A-F\d]+:\d+:match$/u.test(m.match)&&this.#o.set(m.match,h.target)}}}return this.#t.set(s,{cwd:T.resolve(n),digest:ge("sha256").update(d).digest("hex"),consumable:u,references:a,resources:o}),d}source(e,t,n=!1){if(Array.isArray(e))return e.map(f=>this.source(f,t,n));if(typeof e!="string")return e;let o=this.#o.get(e);if(o)return this.source(o,t,n);let s=/^<system-result\b[^>]*><uuid>([a-f\d-]{36})<\/uuid><\/system-result>(?:\n|$)/u.exec(e),a=s?.[1]??(e.startsWith(x)?e.slice(x.length):e),d=/^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/u.test(a);if(!s&&!d){if(e.startsWith("<system-result"))throw new Error("Invalid system result reference.");return e}let u=this.#t.get(a);if(!u&&!s&&e.startsWith(x)&&this.#e.has(e))return e;if(!u)throw new Error("Result reference expired or unknown; repeat the source tool.");if(u.cwd!==T.resolve(t))throw new Error("Result belongs to another worktree.");if(s&&ge("sha256").update(e).digest("hex")!==u.digest)throw new Error("Result text changed; pass the original result or its UUID.");for(let f of u.resources)this.refresh(f,t);if(!this.#t.has(a))throw new Error("Result reference expired; repeat the source tool.");if(!u.consumable)throw new Error("Only successful source results can be consumed.");for(let f of u.references)if(!this.#e.has(f))throw this.#t.delete(a),new Error("Result reference expired; repeat the source tool.");if(u.references.length===1)return u.references[0];if(u.references.length>1)return u.references;let p=u.resources.length===1?u.resources[0]:void 0;if(p&&(n===!0||n==="live"&&/^(?:shell|debug):/u.test(p)))return p;throw new Error("This result has no reusable text selection.")}invalidate(e){let t=new Set;for(let[n,o]of this.#e)o.state==="ready"&&o.targets.some(s=>F(s.source,o.cwd)===e)&&(this.#e.delete(n),t.add(n));for(let[n,o]of this.#t)(o.resources.some(s=>F(s,o.cwd)===e)||o.references.some(s=>t.has(s)))&&this.#t.delete(n)}refresh(e,t){let n=F(e,t),o=JSON.stringify([T.resolve(t),n]),s=st(e,t),a=this.#n.get(o);a&&a.stamp!==s&&this.invalidate(n),this.#n.set(o,{source:e,cwd:t,stamp:s})}refreshAll(){for(let e of[...this.#n.values()])this.refresh(e.source,e.cwd)}#r(e){if(typeof e=="string"&&e.startsWith(x))return[e];if(Array.isArray(e))return e.flatMap(n=>this.#r(n));if(e===null||typeof e!="object")throw new Error("Unsupported result input.");let t=e;if("status"in t){if(t.status!=="success")throw new Error("Only successful source results can be consumed.");return this.#r(t.data)}if(typeof t.target=="string"&&t.target.startsWith(x))return[t.target];if(t.kind==="resources"&&Array.isArray(t.resources))return this.#r(t.resources);throw new Error("This result has no supported source target; do not use preview text as a source.")}};function F(r,e){let t=r.startsWith("raw:")?r.slice(4):r;if(t.startsWith("file:"))try{return nt(t)}catch{}return T.resolve(e,t)}i(F,"sourcePath");function st(r,e){try{let t=tt(F(r,e),{bigint:!0});return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch{return}}i(st,"fileStamp");async function me(r,e){let t=new Map;for(let n of r.targets){e?.throwIfAborted();let o=t.get(n.source);if(o===void 0&&(o=await rt(n.source,{encoding:"utf8",signal:e}),t.set(n.source,o)),o!==n.expectedContent)throw new Error("Result target is stale; repeat Read/Search.")}}i(me,"verifyResultTargets");function ne(r){let e=new Map;for(let t of r){let n=e.get(t.source);if(n!==void 0&&n.expectedContent!==t.expectedContent)throw new Error("Result targets refer to different snapshots of the same source.");let o=n??{source:t.source,expectedContent:t.expectedContent,ranges:[],seen:new Set};for(let s of t.ranges){let a=JSON.stringify(s);o.seen.has(a)||(o.seen.add(a),o.ranges.push(structuredClone(s)))}e.set(t.source,o)}return[...e.values()].filter(t=>t.ranges.length>0).map(({seen:t,...n})=>({...n,ranges:n.ranges.sort((o,s)=>o.start.lineNumber-s.start.lineNumber||o.start.column-s.start.column||o.end.lineNumber-s.end.lineNumber||o.end.column-s.end.column)}))}i(ne,"combineTargets");function it(r){let e;if(r.events.emit(he,{accept:i(o=>{e=o},"accept")}),e!==void 0)return e;let t=new K,n=r.events.on(he,o=>{o!==null&&typeof o=="object"&&"accept"in o&&typeof o.accept=="function"&&o.accept(t)});return r.on("session_start",()=>{t.clear()}),r.on("session_shutdown",()=>{t.clear(),n()}),t}i(it,"connectResultTargets");export{U as a,Se as b,se as c,D as d,ie as e,ae as f,z as g,ce as h,Ne as i,je as j,J as k,le as l,We as m,Ve as n,A as o,B as p,Y as q,de as r,G as s,E as t,V as u,Q as v,k as w,N as x,H as y,I as z,_ as A,Z as B,ee as C,Ze as D,et as E,ot as F,K as G,me as H,it as I};
@@ -1,2 +0,0 @@
1
- import{e as m,i as g,m as x}from"./chunk-CWD4O5PM.js";import{a as i}from"./chunk-EI7MMDWY.js";import{Type as n}from"typebox";import{Value as y}from"typebox/value";import{Type as d}from"typebox";var c=d.Object({path:d.Optional(d.String({description:"What to read: a supported resource such as a file or directory path, URL, returned temp: reference, SEARCH# or RESULT# reference, or registered protocol source. Supply a path; an empty call cannot select a source."})),offset:d.Optional(d.Number({description:"For raw: sources, use a zero-based byte offset; negative offsets count from the file end. For other sources: first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end. For path#anchor, SEARCH or RESULT# selections, count from its containing line instead: 0 or 1 starts there, 2 starts one line later, -1 one line earlier. For image and sequence views, offset is a zero-based row-major grid cell index and requires limit."})),limit:d.Optional(d.Number({description:"For raw: sources, use a non-negative byte count (0 reads no bytes). Otherwise, maximum lines from the selected starting position. Output is bounded; omit for the default read. For image and sequence views, limit is the square grid cell size in pixels; omit offset to select cell 0, or omit both for the bounded full image."})),views:d.Optional(d.Array(d.String(),{description:`Optional source-specific presentations. Combine views when both presentations are needed, for example ["anchors", "ast"]. Omit for the source's default presentation.`}))}),O={path:"What to read: a resource path, unchanged source result or its UUID. Pass the whole result to compose tools. Supply a source; an empty call cannot select one. temp:<id> reads saved complete output until this runtime is disposed. raw:<local-file> reads original bytes from a regular file (relative, absolute or file:// path); raw: does not accept views.",offset:"For raw: sources, a zero-based integer byte offset; negative offsets count from the file end. For text sources, the first line to return, numbered from 1. Omit or use 0 to start at line 1; -1 starts at the last line, -10 at the tenth line from the end.",limit:"For raw: sources, a non-negative integer byte count (0 reads no bytes). For text sources, the maximum lines from the selected starting position. Omit for the bounded default read. Explicit ranges on other content require a source-specific handler; otherwise they fail.",views:"Optional source-specific presentations. Omit for the source's default presentation. Values may include settings after a colon; use the syntax below. Combine views only when their contracts allow it. Unknown views can be ignored and reported in ignoredViews; they do not add capabilities. raw: sources reject views."};function H(e){let r=i((o,u)=>({...o,description:[O[u],e[u]].filter(R=>R!==void 0).join(`
2
- `)}),"describe");return{...c,properties:{path:r(c.properties.path,"path"),offset:r(c.properties.offset,"offset"),limit:r(c.properties.limit,"limit"),views:r(c.properties.views,"views")}}}i(H,"describeReadParameters");import{Type as t}from"typebox";var w=t.Object({value:t.String(),kind:t.String(),state:t.Optional(t.String())},{additionalProperties:!1}),k=t.Object({lineNumber:t.Integer(),content:t.String(),lineEnding:t.String(),anchors:t.Optional(t.Array(t.String()))},{additionalProperties:!1}),L=t.Object({path:t.String(),offset:t.Integer()},{additionalProperties:!1}),f={source:t.String(),truncated:t.Boolean(),continuation:t.Optional(L),fullResult:t.Optional(t.String())},h=t.Object({...f,kind:t.Literal("text"),target:t.Optional(t.String()),lines:t.Array(k),startLine:t.Integer(),endLine:t.Integer(),totalLines:t.Integer(),references:t.Optional(t.Array(w))},{additionalProperties:!1}),b=t.Object({...f,kind:t.Literal("bytes"),bytes:t.Array(t.Integer({minimum:0,maximum:255})),byteOffset:t.Integer(),byteLength:t.Integer(),totalBytes:t.Integer()},{additionalProperties:!1}),P=t.Union([t.Object({type:t.Literal("text"),text:t.String()},{additionalProperties:!1}),t.Object({type:t.Literal("image"),mimeType:t.String()},{additionalProperties:!1})]),S=t.Object({...f,kind:t.Literal("native"),blocks:t.Array(P)},{additionalProperties:!1}),p=t.Union([t.Object({kind:t.Literal("recovery"),source:t.String(),candidates:t.Array(t.Object({path:t.String()},{additionalProperties:!1}))},{additionalProperties:!1}),h,b,S,t.Object({kind:t.Literal("resources"),source:t.Optional(t.String()),resources:t.Array(t.Union([h,b,S])),truncated:t.Boolean(),fullResult:t.Optional(t.String())},{additionalProperties:!1})]),v=m(p);function C(e){return{lineNumber:e.lineNumber,content:e.content,lineEnding:e.lineEnding,...e.anchors===void 0?{}:{anchors:[...e.anchors]}}}i(C,"publicLine");function T(e){if(e.kind==="resources"){let a=e.resources.map(s=>T(s));return{kind:e.kind,...e.source===void 0?{}:{source:e.source},resources:a,truncated:a.some(s=>typeof s=="object"&&s!==null&&"truncated"in s&&s.truncated===!0)}}if(e.kind==="bytes"){let a=e.bytes.slice(0,32768),s=e.truncated===!0||a.length<e.bytes.length;return{kind:e.kind,source:e.source,bytes:a,byteOffset:e.byteOffset,byteLength:a.length,totalBytes:e.totalBytes,truncated:s,...e.byteOffset+a.length<e.totalBytes?{continuation:{path:e.source,offset:e.byteOffset+a.length}}:{}}}if(e.kind==="native")return{kind:e.kind,source:e.source,truncated:!1,blocks:e.blocks.map(a=>{if(a.type==="text")return{type:a.type,text:a.text};if(a.type==="image")return{type:a.type,mimeType:a.mimeType};throw new TypeError("Custom content requires a structured adapter")})};let r=[],o=0;for(let a of e.lines){let s=C(a);if(o+=Buffer.byteLength(JSON.stringify(s)),r.length>=2e3||o>512*1024)break;r.push(s)}if(r.length===0&&e.lines.length>0)throw new RangeError("Selected line exceeds the structured window; use a raw byte range or a source-specific view");let u=r.length<e.lines.length,R=r.at(-1)?.lineNumber??e.startLine-1;return{kind:e.kind,source:e.source,lines:r,startLine:r[0]?.lineNumber??0,endLine:r.at(-1)?.lineNumber??0,totalLines:e.totalLines,truncated:u,...e.target===void 0?{}:{target:e.target},...e.references===void 0?{}:{references:e.references},...u||R<e.totalLines?{continuation:{path:e.source,offset:R+1}}:{}}}i(T,"publicData");function E(e){let r=e.details.failure;if(e.isError||r!==void 0)return g(e,p,{status:"error",...r?.candidates?.length&&r.source!==void 0?{data:{kind:"recovery",source:r.source,candidates:r.candidates}}:{},errors:[{code:r?.code??"READ_FAILED",message:r?.message??"Read failed",...r?.source===void 0?{}:{source:r.source}}]});try{if(e.script===void 0)throw new TypeError("Read handler must return structured script data");let o=T(e.script);return g(e,p,{status:"success",data:e.details.temporarySource!==void 0&&typeof o=="object"&&o!==null?{...o,fullResult:e.details.temporarySource}:o,errors:[]})}catch(o){return g(e,p,{status:"error",errors:[{code:o instanceof RangeError?"STRUCTURED_RESULT_TOO_LARGE":"STRUCTURED_ADAPTER_REQUIRED",message:o instanceof Error?o.message:String(o)}]})}}i(E,"structuredRead");var l=n.Function([],n.Unknown()),D=n.Object({resolver:n.Unknown(),matchesCall:n.Optional(l),renderCall:n.Optional(l),priority:n.Optional(n.Number()),renderResult:n.Optional(l),preserveTruncatedOutput:n.Optional(n.Boolean())}),A=n.Object({resolver:n.Unknown(),priority:n.Optional(n.Number())}),F=n.Object({id:n.String({pattern:"\\S"}),priority:n.Optional(n.Number()),resolve:l}),N=n.Object({view:n.String({pattern:"\\S"}),includes:n.Optional(n.Array(n.String({pattern:"\\S"}))),presenter:n.Object({id:n.String(),present:l}),priority:n.Optional(n.Number())}),U=n.Object({resolvedBy:n.String({pattern:"\\S"}),contentKind:n.Union([n.Literal("text"),n.Literal("any")])}),j=n.Union([n.Object({stage:n.Literal("pre-read"),handler:l}),n.Object({stage:n.Literal("read"),when:U,handler:l}),n.Object({stage:n.Literal("post-read"),handler:l})]);function J(e){if(!y.Check(A,e))return!1;let r=e,o=r.resolver;return typeof o.id=="string"&&o.id.length>0&&typeof o.tryResolve=="function"&&(!("priority"in r)||typeof r.priority=="number")}i(J,"isTextTargetResolverRegistration");function Y(e){if(!y.Check(D,e))return!1;let r=e;return x(r.resolver)?r.resolver.id!=="any"&&(!("priority"in r)||typeof r.priority=="number")&&(!("matchesCall"in r)||typeof r.matchesCall=="function")&&(!("renderCall"in r)||typeof r.renderCall=="function")&&"matchesCall"in r=="renderCall"in r&&(!("renderResult"in r)||typeof r.renderResult=="function"):!1}i(Y,"isResourceResolverRegistration");function X(e){return y.Check(j,e)}i(X,"isReadHandlerRegistration");function Z(e){return y.Check(N,e)}i(Z,"isReadViewRegistration");function $(e){return y.Check(F,e)}i($,"isFragmentResolverRegistration");function ee(e){return I(e)?e.kind==="not-handled"?!0:e.kind==="failed"?typeof e.message=="string"&&e.message.length>0:e.kind==="resolved"&&typeof e.originLine=="number":!1}i(ee,"isReadFragmentResolution");function I(e){return typeof e=="object"&&e!==null}i(I,"isRecord");export{c as a,H as b,p as c,v as d,E as e,J as f,Y as g,X as h,Z as i,$ as j,ee as k};
@@ -1,7 +0,0 @@
1
- import{a as d}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";var f=class i{static{s(this,"FileRange")}start;end;constructor(e,t=e){t.lineNumber<e.lineNumber&&([e,t]=[t,e]),this.start=e,this.end=t}static fromLines(e,t){let r=t??e;return new i({lineNumber:e},{lineNumber:r})}},l=class i{static{s(this,"FileMutationResult")}data;constructor(e){this.data=e??{}}get ok(){return this.data.ok??!1}get isPartial(){return this.data.isPartial??!1}get diffs(){return this.data.diffs??[]}get files(){return this.data.files??[]}get warnings(){return this.data.warnings??[]}get errors(){return this.data.errors??[]}get lintViolations(){return this.data.lintViolations??[]}get hints(){return this.data.hints??[]}get syntaxErrorSummary(){return this.data.syntaxErrorSummary}get path(){return this.data.path}get editRange(){let e=this.data.activeEdits,t=e?.[0];if(t?.range){let r=t.range.start,a=d(e).at(-1)?.range?.end??r;return new f(r,a)}return this.data.editRange}get resolvedStartLine(){return this.editRange?.start.lineNumber}get resolvedEndLine(){return this.editRange?.end.lineNumber}get freshAnchors(){return this.data.freshAnchors}get failurePoint(){return this.data.failurePoint}get recovery(){return this.data.recovery}get expectedAnchor(){return this.data.expectedAnchor}get currentAnchor(){return this.data.currentAnchor}get internalErrorType(){return this.data.internalErrorType}get internalErrorMessage(){return this.data.internalErrorMessage}get editCount(){return this.data.editCount}get editRanges(){return this.data.editRanges}get addedLines(){return this.data.addedLines}get removedLines(){return this.data.removedLines}get appliedPaths(){return this.data.appliedPaths}get beforeContentMap(){return this.data.beforeContentMap}get afterContent(){return this.data.afterContent}get skipCount(){return this.data.skipCount??0}get staleEdits(){return this.data.staleEdits??[]}get proposedDiff(){return this.data.proposedDiff}get editIndex(){return this.data.editIndex}get editIndices(){return this.data.editIndices}get staleDiagnostic(){return this.data.staleDiagnostic}get fileChangedStatement(){return this.data.fileChangedStatement}get affectedPaths(){let e=new Set;for(let t of this.files)e.add(t.path);for(let t of this.errors)t.path&&e.add(t.path);for(let t of this.warnings)t.file&&e.add(t.file);return[...e]}get didChange(){return this.ok&&(this.files.length>0||this.diffs.length>0)}get createdFiles(){return this.files.filter(e=>e.action==="created")}get overwrittenFiles(){return this.files.filter(e=>e.action==="overwritten"||e.action==="edited")}get staleCount(){return this.staleEdits.length}get summary(){if(!this.ok){let n=this.errors[0];return n?`Failed: ${n.code??"ERROR"}${n.reason?` \u2014 ${n.reason}`:""}`:"Mutation failed"}if(this.files.length===0&&this.diffs.length===0){let n=this.appliedPaths;return n&&n.length>0?`${n.length} path${n.length===1?"":"s"} affected`:"No changes"}let e=this.createdFiles.length,t=this.overwrittenFiles.length,r=[];if(e>0&&r.push(`Created ${e} ${e===1?"file":"files"}`),t>0&&r.push(`Edited ${t} ${t===1?"file":"files"}`),this.diffs.length>0){let n=0,a=0;for(let o of this.diffs)for(let u of o.split(`
2
- `))u.startsWith("+")&&!u.startsWith("+++")?n++:u.startsWith("-")&&!u.startsWith("---")&&a++;(n>0||a>0)&&r.push(`+${n}/-${a} lines`)}return r.join(", ")}getFileChange(e){return this.files.find(t=>t.path===e)}getDiffFor(e){let t=g(e);for(let r of this.diffs){let n=r.match(/^---\s+(.+)$/m);if(n&&(g(d(n[1]))===t||n[1]===e))return r}}getErrorsFor(e){return this.errors.filter(t=>t.path===e)}getWarningsFor(e){return this.warnings.filter(t=>t.file===e)}static fromFailureOptions(e){return new i({ok:!1,path:e.path,errors:[{path:e.path,code:e.code,reason:e.reason}],failurePoint:e.failurePoint,recovery:e.recovery,expectedAnchor:e.expectedAnchor,currentAnchor:e.currentAnchor,freshAnchors:e.freshLines?[...e.freshLines]:void 0,internalErrorType:e.internalError instanceof Error?e.internalError.name:void 0,internalErrorMessage:e.internalError instanceof Error?e.internalError.message:void 0})}static ensure(e){if(e instanceof i)return e;if(e&&typeof e=="object"){let t=e;return t.data&&typeof t.data=="object"?(Object.setPrototypeOf(t,i.prototype),t):new i(t)}return new i}};function g(i){return i.replace(/\\/g,"/").replace(/^a\//,"").replace(/^b\//,"")}s(g,"normalisePath");import{createTwoFilesPatch as p,diffLines as c}from"diff";function D(i,e,t,r=i){return{diff:p(i,r,e,t,"","",{context:3}).replace(/^(?:Index: .*\n)?={3,}\n?/m,"").trimEnd(),stats:m(e,t)}}s(D,"createUnifiedDiff");function m(i,e){let t=0,r=0;for(let n of c(i,e)){let a=h(n.value);n.removed&&(t+=a),n.added&&(r+=a)}return{removed:t,added:r}}s(m,"computeStats");function h(i){if(i.length===0)return 0;let e=i.replaceAll(`\r
3
- `,`
4
- `);return e.endsWith(`
5
- `)?e.slice(0,-1).split(`
6
- `).length:e.split(`
7
- `).length}s(h,"countDiffLines");function y(i,e){let t=c(i,e),r=[],n=0;for(let a of t){let o=h(a.value);o!==0&&(a.removed||(a.added&&r.push({start:n+1,end:n+o}),n+=o))}return E(r)}s(y,"computeChangedRanges");function E(i){if(i.length===0)return[];let e=[...i].sort((r,n)=>r.start-n.start),t=[d(e[0])];for(let r=1;r<e.length;r++){let n=d(t.at(-1)),a=d(e[r]);a.start<=n.end+1?n.end=Math.max(n.end,a.end):t.push(a)}return t}s(E,"mergeAdjacentRanges");export{f as a,l as b,D as c,y as d};
@@ -1 +0,0 @@
1
- import{F as d,e as c}from"./chunk-CWD4O5PM.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var y=t.Object({query:t.String({minLength:1,description:"Text to find, a Boolean expression, or a prefixed query described below, such as files:*.ts. Quote text to keep it literal, or use regex:<pattern> for regular-expression matching."}),path:t.Optional({...d,description:"File, directory, URL, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Results select only their registered ranges unless symbols: navigation follows external references."}),navigation:t.Optional(t.Literal("references",{description:"Only for symbols: queries. Explicitly follow symbols represented inside path to their references outside that scope. Without navigation, all returned ranges stay inside path."})),include:t.Optional(t.String({description:"Optional include glob for local search"})),exclude:t.Optional(t.String({description:"Optional exclude glob for local search"})),caseSensitive:t.Optional(t.Boolean({description:"Match letter case"})),wholeWord:t.Optional(t.Boolean({description:"Match complete words"})),limit:t.Optional(t.Integer({minimum:1,maximum:1e3,description:"Maximum detailed results returned to the agent (default 50)"}))},{additionalProperties:!1});import{Type as e}from"typebox";var u=e.Object({startLine:e.Integer(),startColumn:e.Integer(),endLine:e.Integer(),endColumn:e.Integer()},{additionalProperties:!1}),m=e.Object({line:e.Optional(e.String()),match:e.Optional(e.String())},{additionalProperties:!1}),p={source:e.String(),target:e.Optional(e.String()),range:u,matchedText:e.Optional(e.String()),textTruncated:e.Optional(e.Boolean()),references:e.Optional(m)},f=e.Object({...p,captures:e.Optional(e.Record(e.String(),e.Array(e.Object(p,{additionalProperties:!1})))),role:e.Optional(e.Union([e.Literal("definition"),e.Literal("reference")])),symbol:e.Optional(e.Object({id:e.String(),name:e.String(),kind:e.String(),source:e.String(),range:u},{additionalProperties:!1}))},{additionalProperties:!1}),g={target:e.Optional(e.String()),kind:e.Literal("matches"),truncated:e.Optional(e.Boolean()),fullResult:e.Optional(e.String()),complete:e.Boolean(),matches:e.Array(f),all:e.Optional(m),notices:e.Optional(e.Array(e.String()))},h=e.Object({status:e.Union([e.Literal("ready"),e.Literal("skipped")]),message:e.Optional(e.String()),candidates:e.Array(e.Object({identifier:e.String(),kind:e.Union([e.Literal("normalized"),e.Literal("component"),e.Literal("typo")]),reason:e.String(),matchCount:e.Integer(),fileCount:e.Integer(),selection:e.Object(g,{additionalProperties:!1})},{additionalProperties:!1}))},{additionalProperties:!1}),O=e.Union([e.Object({...g,fuzzy:e.Optional(h)},{additionalProperties:!1}),e.Object({kind:e.Literal("files"),complete:e.Boolean(),files:e.Array(e.String())},{additionalProperties:!1}),e.Object({kind:e.Literal("custom"),resolverId:e.String(),value:e.Unknown()},{additionalProperties:!1})]),P=c(O);function T(o,l,r,i){return{kind:"matches",...i?.target===void 0?{}:{target:i.target},truncated:o.length>100,complete:l,matches:o.slice(0,100).map((n,a)=>({source:n.source,...i?.matchTargets?.[a]===void 0?{}:{target:i.matchTargets[a]},range:{startLine:n.lineNumber,startColumn:n.startColumn,endLine:n.endLineNumber??n.lineNumber,endColumn:n.endColumn},...Buffer.byteLength(n.matchedText)<=4096?{matchedText:n.matchedText}:{textTruncated:!0},...r===void 0?{}:{references:{line:`SEARCH#${r}:${a+1}:line`,match:`SEARCH#${r}:${a+1}:match`}}})),...l&&r!==void 0?{all:{line:`SEARCH#${r}:all:line`,match:`SEARCH#${r}:all:match`}}:{}}}s(T,"selectionData");export{y as a,h as b,O as c,P as d,T as e};
@@ -1,3 +0,0 @@
1
- import{a as n}from"./chunk-EI7MMDWY.js";function o(e,t){let r=e.context===void 0?"":`
2
-
3
- ${e.context}`;return`[SYSTEM] ${e.toolName} blocked: ${e.field} anchor "${e.anchor}" is stale. If the required line is represented by one of the context lines below, use that anchor. Otherwise, reread only the relevant section of "${e.path}" and regenerate the anchor. (${t})${r}`}n(o,"formatStaleAnchorMessage");export{o as a};
@@ -1 +0,0 @@
1
- import{a as x,e as y,k as E}from"./chunk-4GCWGE2C.js";import{a as g,c as m}from"./chunk-CWD4O5PM.js";import{a as o}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as T}from"node:async_hooks";var u=new T,f=new T;function S(t){let e=f.getStore();e?e.push(t):t()}o(S,"afterPostEditScope");async function R(t){if(f.getStore())return t();let e=[];try{return await f.run(e,t)}finally{for(let r of e)r()}}o(R,"collectPostEditNotifications");function A(t,e){let r=u.getStore();return r?(r.set(t,e),!0):!1}o(A,"deferPostEdit");function v(t){return u.getStore()?.has(t)??!1}o(v,"hasDeferredPostEdit");function H(t){u.getStore()?.delete(t)}o(H,"forgetDeferredPostEdit");function j(t=process.cwd()){let e=new Map;return{run(r){return u.run(e,r)},forget(r){e.delete(r)},sources(){return[...e.keys()]},async finish(r){let c=[...e];e.clear();let a=[],i=[];if(await R(async()=>{let s=new g,P=await Promise.allSettled(c.map(([d,p])=>s.run(m(d,t,"write"),p)));for(let d of P){if(d.status==="rejected"){i.push(d.reason);continue}a.push(d.value);try{r?.(d.value)}catch(p){i.push(p)}}}),i.length>0)throw new AggregateError(i,`Some final post-processing failed; completed edits remain applied. ${i.map(s=>s instanceof Error?s.message:String(s)).join("; ")}`);return a}}}o(j,"createPostEditScope");import{Type as n}from"typebox";import{Value as l}from"typebox/value";var b=`${x}/post-edit/register`;function L(t){return l.Check(n.Object({formatting:n.Object({status:n.Union(["disabled","unavailable","skipped-syntax","unchanged","changed","failed","not-reported","deferred"].map(e=>n.Literal(e))),formatter:n.Optional(n.String())})}),t)}o(L,"isFormattingContribution");function z(t){return l.Check(n.Object({diffStatuses:n.Array(n.Object({text:n.String({minLength:1}),formatter:n.Optional(n.String()),tone:n.Optional(n.Union(["muted","success","warning","error"].map(e=>n.Literal(e))))}))}),t)}o(z,"isDiffStatusContribution");var h=n.Function([],n.Unknown()),w=n.Object({id:n.String({minLength:1}),handler:h}),k=n.Object({registration:w,accept:h});function C(t){return l.Check(w,t)}o(C,"isTextPostEditHandlerRegistration");function N(t){return l.Check(k,t)}o(N,"isTextPostEditHandlerRegistrationRequest");function U(t){if(typeof t!="object"||t===null)return!1;let e=t;return Array.isArray(e.hints)&&typeof e.scopeMarkers=="object"&&e.scopeMarkers!==null&&Array.isArray(e.warnings)}o(U,"isTextMutationResultContributionData");function V(t,e){if(!C(e))throw new TypeError("Invalid text editor post-edit handler registration");let r,c=o(()=>{let i={registration:e,accept(s){if(r!==void 0)throw new Error(`Post-edit handler ${e.id} was accepted more than once`);r=s}};return t.events.emit(b,i),r!==void 0},"announce"),a=o(()=>{},"unsubscribeReady");a=t.events.on(y,i=>{if(!E(i))throw new Error("Invalid pi-agent-text-editor core readiness event");if(!c())throw new Error("pi-agent-text-editor core announced readiness without accepting the post-edit handler");a()}),t.on("session_shutdown",()=>{a(),r?.()}),c()&&a()}o(V,"connectTextEditorPostEditHandler");export{S as a,R as b,A as c,v as d,H as e,j as f,b as g,L as h,z as i,C as j,N as k,U as l,V as m};