pi-agent-ide 0.8.4 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (649) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +24 -29
  3. package/dist/{chunk-CM3XGY72.js → chunk-2AY526TN.js} +1 -1
  4. package/dist/{chunk-LEJKDYCK.js → chunk-2TZDG2JH.js} +1 -1
  5. package/dist/{chunk-DUUOCBS3.js → chunk-35LZOKEW.js} +1 -1
  6. package/dist/chunk-3LVBARLW.js +33 -0
  7. package/dist/{chunk-XBQR74IK.js → chunk-4GBFIGH3.js} +1 -1
  8. package/dist/{chunk-PJL3UVMJ.js → chunk-4IWEKRSP.js} +1 -1
  9. package/dist/chunk-52PFWQMU.js +5 -0
  10. package/dist/chunk-5BGWNYQS.js +1 -0
  11. package/dist/chunk-5PC5INOL.js +1 -0
  12. package/dist/{chunk-QUYXINGZ.js → chunk-5S74Z6Y4.js} +3 -3
  13. package/dist/{chunk-XAHU42FP.js → chunk-6A3ORNW3.js} +2 -2
  14. package/dist/{chunk-ANM3Y5FO.js → chunk-6WCHBHFW.js} +5 -5
  15. package/dist/{chunk-IMGIDBCC.js → chunk-7D7PXIVV.js} +1 -1
  16. package/dist/chunk-7PVDTMEM.js +1 -0
  17. package/dist/chunk-AMIIOWFL.js +1 -0
  18. package/dist/{chunk-TOYN4W4F.js → chunk-B25LXXNV.js} +1 -1
  19. package/dist/chunk-BT2CFM7D.js +11 -0
  20. package/dist/chunk-C2JT2G5K.js +1 -0
  21. package/dist/chunk-DDH3FP4G.js +3 -0
  22. package/dist/{chunk-6T7PSDQW.js → chunk-DVNL5NZE.js} +1 -1
  23. package/dist/chunk-FEZLTM4L.js +1 -0
  24. package/dist/{chunk-CPELC6JE.js → chunk-FHRHYY4M.js} +1 -1
  25. package/dist/chunk-FXPY3V4L.js +10 -0
  26. package/dist/chunk-FYOU4RBH.js +2 -0
  27. package/dist/chunk-G4PRFO6G.js +1 -0
  28. package/dist/chunk-GS5ZRTUG.js +1 -0
  29. package/dist/{chunk-XXLLY66B.js → chunk-GXL4NMHR.js} +1 -1
  30. package/dist/{chunk-QT3EAHOG.js → chunk-H3GEEOOL.js} +1 -1
  31. package/dist/chunk-H5Z54BEU.js +25 -0
  32. package/dist/chunk-H7WAM5RH.js +23 -0
  33. package/dist/{chunk-Z2MNHSJ4.js → chunk-HGCJDIRR.js} +1 -1
  34. package/dist/chunk-HISGZD3C.js +81 -0
  35. package/dist/chunk-HKYVP2Q6.js +3 -0
  36. package/dist/chunk-HRBUY2FF.js +4 -0
  37. package/dist/chunk-IG5DXVDJ.js +1 -0
  38. package/dist/chunk-IOGWZNWT.js +1 -0
  39. package/dist/chunk-IUJUECXH.js +9 -0
  40. package/dist/chunk-KN6VPARZ.js +1 -0
  41. package/dist/{chunk-RW2GTYQI.js → chunk-LF325WYO.js} +1 -1
  42. package/dist/chunk-LXDF2NWX.js +1 -0
  43. package/dist/{chunk-YJ6T3PEP.js → chunk-MDD5ORB6.js} +1 -1
  44. package/dist/{chunk-S72FVLUX.js → chunk-MLFJU2US.js} +1 -1
  45. package/dist/chunk-MPNE25CY.js +5 -0
  46. package/dist/chunk-NA2NEU4V.js +1 -0
  47. package/dist/{chunk-ZJQRLVVV.js → chunk-O7V6G3OO.js} +1 -1
  48. package/dist/chunk-OBTT5INC.js +6 -0
  49. package/dist/{chunk-IICJXZBU.js → chunk-OMNKD7WW.js} +3 -3
  50. package/dist/chunk-OUCVZBOR.js +28 -0
  51. package/dist/chunk-PCGBM2D6.js +17 -0
  52. package/dist/{chunk-235QMMVA.js → chunk-PQWANILR.js} +1 -1
  53. package/dist/{chunk-QRJLIV6P.js → chunk-QJ6V5IAY.js} +6 -6
  54. package/dist/{chunk-SMIFCAAX.js → chunk-RIJRPAL2.js} +1 -1
  55. package/dist/chunk-RIOPUTUJ.js +6 -0
  56. package/dist/{chunk-RMI3NMQY.js → chunk-RIZARTUM.js} +2 -2
  57. package/dist/{chunk-NJ7C4KMA.js → chunk-SRFWT562.js} +1 -1
  58. package/dist/{chunk-U22JNO6N.js → chunk-STUZZM5B.js} +1 -1
  59. package/dist/chunk-T3Z4KXOX.js +2 -0
  60. package/dist/chunk-TSQ6FBTB.js +1 -0
  61. package/dist/chunk-U7YDLVFL.js +1 -0
  62. package/dist/{chunk-KZC7TI5M.js → chunk-UD3DMY3Q.js} +1 -1
  63. package/dist/{chunk-VXP5BMW7.js → chunk-USG6WHAT.js} +1 -1
  64. package/dist/{chunk-ZPT5D4VP.js → chunk-VDJSH3DQ.js} +2 -2
  65. package/dist/{chunk-VMTOFEXF.js → chunk-VMLPXSMK.js} +1 -1
  66. package/dist/chunk-VNWGT367.js +1 -0
  67. package/dist/chunk-WAJW4G4F.js +22 -0
  68. package/dist/chunk-WEE3NM6L.js +1 -0
  69. package/dist/{chunk-IM24DB3K.js → chunk-WES2E4VR.js} +1 -1
  70. package/dist/{chunk-RIJMXO43.js → chunk-WQIMM4SU.js} +1 -1
  71. package/dist/chunk-X2WFNMQR.js +9 -0
  72. package/dist/chunk-XCPIIDFS.js +4 -0
  73. package/dist/chunk-XE4W5YTE.js +2 -0
  74. package/dist/chunk-XUYIK4TX.js +1 -0
  75. package/dist/{chunk-AAC77UD4.js → chunk-YPYROPQF.js} +1 -1
  76. package/dist/chunk-ZXO4D5UB.js +1 -0
  77. package/dist/entry-0.js +1 -1
  78. package/dist/entry-1.js +1 -1
  79. package/dist/entry-10.js +1 -1
  80. package/dist/entry-11.js +1 -1
  81. package/dist/entry-12.js +1 -1
  82. package/dist/entry-13.js +1 -1
  83. package/dist/entry-14.js +1 -1
  84. package/dist/entry-15.js +1 -1
  85. package/dist/entry-16.js +1 -1
  86. package/dist/entry-17.js +1 -1
  87. package/dist/entry-18.js +1 -1
  88. package/dist/entry-19.js +1 -1
  89. package/dist/entry-2.js +1 -1
  90. package/dist/entry-20.js +1 -1
  91. package/dist/entry-21.js +1 -0
  92. package/dist/entry-22.js +1 -1
  93. package/dist/entry-24.js +1 -1
  94. package/dist/entry-25.js +1 -1
  95. package/dist/entry-26.js +1 -1
  96. package/dist/entry-27.js +1 -1
  97. package/dist/entry-28.js +1 -1
  98. package/dist/entry-29.js +1 -2
  99. package/dist/entry-3.js +1 -1
  100. package/dist/entry-30.js +1 -1
  101. package/dist/entry-31.js +2 -4
  102. package/dist/entry-32.js +1 -1
  103. package/dist/entry-33.js +1 -1
  104. package/dist/entry-34.js +1 -1
  105. package/dist/entry-35.js +1 -18
  106. package/dist/entry-36.js +1 -1
  107. package/dist/entry-37.js +1 -1
  108. package/dist/entry-38.js +15 -1
  109. package/dist/entry-39.js +1 -1
  110. package/dist/entry-4.js +1 -1
  111. package/dist/entry-40.js +1 -1
  112. package/dist/entry-41.js +1 -1
  113. package/dist/entry-42.js +1 -1
  114. package/dist/entry-43.js +1 -1
  115. package/dist/entry-44.js +1 -1
  116. package/dist/entry-45.js +1 -1
  117. package/dist/entry-46.js +1 -1
  118. package/dist/entry-47.js +1 -1
  119. package/dist/entry-48.js +1 -1
  120. package/dist/entry-49.js +1 -25
  121. package/dist/entry-5.js +1 -1
  122. package/dist/entry-50.js +1 -1
  123. package/dist/entry-51.js +1 -1
  124. package/dist/entry-52.js +1 -1
  125. package/dist/entry-53.js +1 -1
  126. package/dist/entry-54.js +1 -3
  127. package/dist/entry-55.js +1 -13
  128. package/dist/entry-56.js +1 -1
  129. package/dist/entry-57.js +1 -1
  130. package/dist/entry-58.js +1 -1
  131. package/dist/entry-59.js +1 -1
  132. package/dist/entry-6.js +1 -1
  133. package/dist/entry-60.js +1 -1
  134. package/dist/entry-61.js +1 -1
  135. package/dist/entry-62.js +1 -1
  136. package/dist/entry-63.js +1 -1
  137. package/dist/entry-64.js +1 -1
  138. package/dist/entry-65.js +1 -0
  139. package/dist/entry-66.js +1 -1
  140. package/dist/entry-67.js +1 -0
  141. package/dist/entry-68.js +0 -1
  142. package/dist/entry-69.js +1 -1
  143. package/dist/entry-7.js +1 -1
  144. package/dist/entry-70.js +0 -1
  145. package/dist/entry-71.js +1 -1
  146. package/dist/entry-72.js +1 -1
  147. package/dist/entry-73.js +1 -1
  148. package/dist/entry-74.js +1 -1
  149. package/dist/entry-75.js +1 -0
  150. package/dist/entry-76.js +1 -1
  151. package/dist/entry-77.js +1 -0
  152. package/dist/entry-78.js +0 -1
  153. package/dist/entry-79.js +1 -1
  154. package/dist/entry-8.js +1 -1
  155. package/dist/entry-80.js +0 -1
  156. package/dist/entry-81.js +1 -80
  157. package/dist/entry-82.js +1 -22
  158. package/dist/entry-83.js +1 -2
  159. package/dist/entry-84.js +1 -1
  160. package/dist/entry-85.js +1 -1
  161. package/dist/entry-86.js +2 -1
  162. package/dist/entry-87.js +1 -1
  163. package/dist/entry-88.js +1 -3
  164. package/dist/entry-89.js +1 -1
  165. package/dist/entry-9.js +1 -1
  166. package/dist/entry-90.js +1 -1
  167. package/dist/entry-91.js +3 -1
  168. package/dist/entry-92.js +1 -0
  169. package/dist/entry-93.js +1 -0
  170. package/dist/entry-94.js +1 -0
  171. package/dist/pi-agent-ide.js +13 -34
  172. package/docs/agent-guides/ast-search.md +58 -0
  173. package/docs/agent-guides/debugger.md +1 -1
  174. package/docs/agent-guides/editing.md +29 -58
  175. package/docs/agent-guides/git-changes.md +4 -14
  176. package/docs/agent-guides/search.md +38 -0
  177. package/docs/agent-guides/ssh.md +17 -49
  178. package/docs/agent-guides/terminal.md +9 -15
  179. package/docs/configuration.md +9 -13
  180. package/docs/extensions.md +82 -0
  181. package/docs/settings-help.md +2 -2
  182. package/docs/structured-results.md +33 -11
  183. package/docs/tools.md +24 -23
  184. package/node_modules/pi-agent-doctor/package.json +7 -7
  185. package/node_modules/pi-agent-doctor/runtime/entry-29.js +1 -0
  186. package/node_modules/pi-agent-doctor/src/workspace.ts +0 -5
  187. package/node_modules/pi-agent-documentation/package.json +2 -2
  188. package/node_modules/pi-agent-documentation/runtime/entry-30.js +1 -0
  189. package/node_modules/pi-agent-documentation/src/index.ts +26 -10
  190. package/node_modules/pi-agent-filesystem/index.ts +1 -1
  191. package/node_modules/pi-agent-filesystem/package.json +8 -8
  192. package/node_modules/pi-agent-filesystem-image/package.json +4 -4
  193. package/node_modules/pi-agent-filesystem-jq/index.ts +9 -63
  194. package/node_modules/pi-agent-filesystem-jq/package.json +12 -6
  195. package/node_modules/pi-agent-filesystem-jq/runtime/entry-33.js +1 -0
  196. package/node_modules/pi-agent-filesystem-jq/runtime/entry-34.js +2 -0
  197. package/node_modules/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
  198. package/node_modules/pi-agent-filesystem-pdf/package.json +4 -4
  199. package/node_modules/pi-agent-filesystem-text/package.json +4 -4
  200. package/node_modules/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  201. package/node_modules/pi-agent-ide-ast/package.json +15 -15
  202. package/node_modules/pi-agent-ide-ast/runtime/entry-37.js +1 -0
  203. package/node_modules/pi-agent-ide-ast/src/extension.ts +8 -8
  204. package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +104 -26
  205. package/node_modules/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
  206. package/node_modules/pi-agent-ide-changes/index.ts +1 -2
  207. package/node_modules/pi-agent-ide-changes/package.json +10 -10
  208. package/node_modules/pi-agent-ide-changes/runtime/entry-39.js +1 -0
  209. package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
  210. package/node_modules/pi-agent-ide-formatter/package.json +4 -4
  211. package/node_modules/pi-agent-ide-languages/package.json +3 -3
  212. package/node_modules/pi-agent-ide-languages/runtime/entry-42.js +2 -0
  213. package/node_modules/pi-agent-ide-lint/package.json +8 -8
  214. package/node_modules/pi-agent-ide-lint/runtime/entry-43.js +2 -0
  215. package/node_modules/pi-agent-ide-lsp/index.ts +22 -28
  216. package/node_modules/pi-agent-ide-lsp/package.json +14 -10
  217. package/node_modules/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  218. package/node_modules/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
  219. package/node_modules/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
  220. package/node_modules/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
  221. package/node_modules/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
  222. package/node_modules/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
  223. package/node_modules/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  224. package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
  225. package/node_modules/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
  226. package/node_modules/pi-agent-image/package.json +3 -3
  227. package/node_modules/pi-agent-image/src/image-converter.ts +24 -1
  228. package/node_modules/pi-agent-invariant/package.json +2 -2
  229. package/node_modules/pi-agent-pdf/package.json +3 -3
  230. package/node_modules/pi-agent-pdf/src/pdf-converter.ts +23 -1
  231. package/node_modules/pi-agent-read/package.json +12 -12
  232. package/node_modules/pi-agent-read/runtime/entry-49.js +0 -1
  233. package/node_modules/pi-agent-read/runtime/entry-52.js +2 -0
  234. package/node_modules/pi-agent-read/src/api/read-parameters.ts +4 -7
  235. package/node_modules/pi-agent-read/src/api/tools/read.ts +2 -0
  236. package/node_modules/pi-agent-read/src/core/extension.ts +0 -8
  237. package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
  238. package/node_modules/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
  239. package/node_modules/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
  240. package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +21 -8
  241. package/node_modules/pi-agent-resource/package.json +2 -2
  242. package/node_modules/pi-agent-resource/src/index.ts +8 -0
  243. package/node_modules/pi-agent-resource/src/resource-error-metadata.ts +89 -0
  244. package/node_modules/pi-agent-resource/src/resource-error.ts +6 -1
  245. package/node_modules/pi-agent-resource/src/result-images.ts +87 -0
  246. package/node_modules/pi-agent-resource/src/result-targets.ts +9 -3
  247. package/node_modules/pi-agent-resource/src/tool-result.ts +17 -0
  248. package/node_modules/pi-agent-search/package.json +9 -9
  249. package/node_modules/pi-agent-search/runtime/entry-54.js +0 -1
  250. package/node_modules/pi-agent-search/runtime/entry-55.js +1 -0
  251. package/node_modules/pi-agent-search/runtime/entry-57.js +2 -0
  252. package/node_modules/pi-agent-search/src/api/glob-list.ts +35 -0
  253. package/node_modules/pi-agent-search/src/api/search-parameters.ts +8 -8
  254. package/node_modules/pi-agent-search/src/api/search.ts +14 -2
  255. package/node_modules/pi-agent-search/src/core/extension.ts +11 -20
  256. package/node_modules/pi-agent-search/src/core/search-core.ts +30 -10
  257. package/node_modules/pi-agent-search-text/index.ts +34 -12
  258. package/node_modules/pi-agent-search-text/package.json +17 -15
  259. package/node_modules/pi-agent-search-text/runtime/entry-58.js +1 -0
  260. package/node_modules/pi-agent-search-text/runtime/entry-60.js +1 -0
  261. package/node_modules/pi-agent-search-text/src/file-search.ts +59 -25
  262. package/node_modules/pi-agent-search-text/src/resolvers.ts +61 -16
  263. package/node_modules/pi-agent-search-text/src/scoped-search.ts +9 -3
  264. package/node_modules/pi-agent-search-text/src/search-backend.ts +44 -48
  265. package/node_modules/pi-agent-search-text/src/search-presentation.ts +19 -15
  266. package/node_modules/pi-agent-search-text/src/search-recipe.ts +2 -1
  267. package/node_modules/pi-agent-search-text/src/search-result.ts +6 -2
  268. package/node_modules/pi-agent-search-text/src/search-session.ts +1 -0
  269. package/node_modules/pi-agent-search-text/src/tool-file-search.ts +146 -0
  270. package/node_modules/pi-agent-text/package.json +3 -3
  271. package/node_modules/pi-agent-text/runtime/entry-62.js +1 -0
  272. package/node_modules/pi-agent-text/src/text-converter.ts +1 -1
  273. package/node_modules/pi-agent-text-anchor-constant/package.json +4 -4
  274. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  275. package/node_modules/pi-agent-text-anchor-exact/package.json +5 -5
  276. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-64.js +1 -0
  277. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  278. package/node_modules/pi-agent-text-anchor-exact/src/anchor.ts +6 -1
  279. package/node_modules/pi-agent-text-anchor-line-hash/index.ts +1 -2
  280. package/node_modules/pi-agent-text-anchor-line-hash/package.json +7 -7
  281. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  282. package/node_modules/pi-agent-text-editor/package.json +26 -26
  283. package/node_modules/pi-agent-text-editor/runtime/entry-81.js +0 -1
  284. package/node_modules/pi-agent-text-editor/runtime/entry-82.js +1 -0
  285. package/node_modules/pi-agent-text-editor/runtime/entry-83.js +1 -0
  286. package/node_modules/pi-agent-text-editor/runtime/entry-84.js +2 -0
  287. package/node_modules/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
  288. package/node_modules/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
  289. package/node_modules/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
  290. package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
  291. package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
  292. package/node_modules/pi-agent-text-editor/src/core/extension.ts +13 -7
  293. package/node_modules/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
  294. package/node_modules/pi-agent-text-editor/src/core/image-write.ts +111 -0
  295. package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
  296. package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  297. package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +5 -1
  298. package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  299. package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
  300. package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
  301. package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
  302. package/node_modules/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
  303. package/node_modules/pi-agent-text-editor/src/tools/text-selection.ts +63 -74
  304. package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
  305. package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +7 -10
  306. package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +4 -10
  307. package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +8 -8
  308. package/node_modules/pi-agent-text-editor/src/tools/tool-text-move.ts +5 -8
  309. package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
  310. package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
  311. package/node_modules/pi-agent-text-editor-renderer/index.ts +6 -1
  312. package/node_modules/pi-agent-text-editor-renderer/package.json +6 -6
  313. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-85.js +2 -0
  314. package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
  315. package/node_modules/pi-agent-text-editor-stale-anchor/package.json +6 -6
  316. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  317. package/node_modules/pi-agent-tool-call-interception/package.json +3 -3
  318. package/node_modules/pi-agent-tool-call-interception/runtime/entry-87.js +1 -0
  319. package/node_modules/pi-agent-tool-ui/package.json +3 -3
  320. package/node_modules/pi-agent-tool-ui/runtime/entry-88.js +1 -0
  321. package/node_modules/pi-agent-tool-ui/runtime/entry-89.js +1 -0
  322. package/node_modules/pi-agent-web/index.ts +28 -6
  323. package/node_modules/pi-agent-web/package.json +8 -8
  324. package/node_modules/pi-agent-web-html/package.json +3 -3
  325. package/node_modules/pi-agent-web-html/src/html-converter.ts +1 -1
  326. package/node_modules/pi-agent-web-image/package.json +4 -4
  327. package/node_modules/pi-agent-web-image/runtime/entry-92.js +2 -0
  328. package/node_modules/pi-agent-web-pdf/package.json +4 -4
  329. package/node_modules/pi-agent-web-pdf/runtime/entry-93.js +2 -0
  330. package/node_modules/pi-agent-web-text/package.json +4 -4
  331. package/node_modules/pi-agent-web-text/runtime/entry-94.js +2 -0
  332. package/package.json +65 -58
  333. package/src/api/approval.ts +2 -0
  334. package/src/api/capabilities.ts +60 -0
  335. package/src/api/read.ts +2 -0
  336. package/src/api/standalone.ts +7 -0
  337. package/src/backend/doctor-workspace.ts +0 -3
  338. package/src/backend/process-metadata-worker.py +9 -18
  339. package/src/backend/process-metadata.ts +11 -44
  340. package/src/backend/registration.ts +0 -10
  341. package/src/backend/web-browser-worker.mjs +2 -17
  342. package/src/backend/web-browser.ts +1 -26
  343. package/src/composite/builtin-extensions.ts +8 -6
  344. package/src/composite/capabilities.ts +252 -0
  345. package/src/composite/capability-schemas.ts +53 -0
  346. package/src/composite/ide-alias-rendering.ts +18 -2
  347. package/src/composite/module-labels.ts +0 -4
  348. package/src/composite/preferences.ts +0 -36
  349. package/src/composite/responses-tools.ts +27 -9
  350. package/src/composite/settings-documentation.ts +1 -2
  351. package/src/composite/text-results.ts +61 -23
  352. package/src/composite/tool-availability.ts +28 -13
  353. package/src/documentation/extension.ts +39 -15
  354. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/index.ts +1 -1
  355. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +8 -8
  356. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +4 -4
  357. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/index.ts +9 -63
  358. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +12 -6
  359. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-33.js +1 -0
  360. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-34.js +2 -0
  361. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/api/jq.ts +112 -0
  362. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +4 -4
  363. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/runtime/entry-35.js +2 -0
  364. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +4 -4
  365. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-36.js +2 -0
  366. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-31.js +2 -0
  367. package/src/extensions/pi-agent-read/extensions/pi-agent-web/index.ts +28 -6
  368. package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +8 -8
  369. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +3 -3
  370. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/src/html-converter.ts +1 -1
  371. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +4 -4
  372. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-92.js +2 -0
  373. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +4 -4
  374. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-93.js +2 -0
  375. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +4 -4
  376. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/runtime/entry-94.js +2 -0
  377. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-90.js +2 -0
  378. package/src/extensions/pi-agent-read/package.json +12 -12
  379. package/src/extensions/pi-agent-read/runtime/entry-49.js +0 -1
  380. package/src/extensions/pi-agent-read/runtime/entry-50.js +1 -0
  381. package/src/extensions/pi-agent-read/runtime/entry-52.js +2 -0
  382. package/src/extensions/pi-agent-read/src/api/read-parameters.ts +4 -7
  383. package/src/extensions/pi-agent-read/src/api/tools/read.ts +2 -0
  384. package/src/extensions/pi-agent-read/src/core/extension.ts +0 -8
  385. package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +47 -14
  386. package/src/extensions/pi-agent-read/src/core/tools/read/result-target.ts +3 -1
  387. package/src/extensions/pi-agent-read/src/core/tools/read/structured-result.ts +14 -2
  388. package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +21 -8
  389. package/src/extensions/pi-agent-search/package.json +9 -9
  390. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/index.ts +34 -12
  391. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +17 -15
  392. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-58.js +1 -0
  393. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-59.js +1 -0
  394. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-60.js +1 -0
  395. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/file-search.ts +59 -25
  396. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +61 -16
  397. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +9 -3
  398. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-backend.ts +44 -48
  399. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +19 -15
  400. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +2 -1
  401. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +6 -2
  402. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-session.ts +1 -0
  403. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/tool-file-search.ts +146 -0
  404. package/src/extensions/pi-agent-search/runtime/entry-54.js +0 -1
  405. package/src/extensions/pi-agent-search/runtime/entry-55.js +1 -0
  406. package/src/extensions/pi-agent-search/runtime/entry-56.js +1 -0
  407. package/src/extensions/pi-agent-search/runtime/entry-57.js +2 -0
  408. package/src/extensions/pi-agent-search/src/api/glob-list.ts +35 -0
  409. package/src/extensions/pi-agent-search/src/api/search-parameters.ts +8 -8
  410. package/src/extensions/pi-agent-search/src/api/search.ts +14 -2
  411. package/src/extensions/pi-agent-search/src/core/extension.ts +11 -20
  412. package/src/extensions/pi-agent-search/src/core/search-core.ts +30 -10
  413. package/src/extensions/pi-agent-text-editor/package.json +26 -26
  414. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +4 -4
  415. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-63.js +2 -0
  416. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +5 -5
  417. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-64.js +1 -0
  418. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-65.js +2 -0
  419. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/src/anchor.ts +6 -1
  420. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/index.ts +1 -2
  421. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +7 -7
  422. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-66.js +1 -0
  423. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-67.js +2 -0
  424. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/index.ts +6 -1
  425. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +6 -6
  426. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-85.js +2 -0
  427. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +18 -5
  428. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +6 -6
  429. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-86.js +2 -0
  430. package/src/extensions/pi-agent-text-editor/runtime/entry-81.js +0 -1
  431. package/src/extensions/pi-agent-text-editor/runtime/entry-82.js +1 -0
  432. package/src/extensions/pi-agent-text-editor/runtime/entry-83.js +1 -0
  433. package/src/extensions/pi-agent-text-editor/runtime/entry-84.js +2 -0
  434. package/src/extensions/pi-agent-text-editor/src/api/edit-pipeline.ts +2 -0
  435. package/src/extensions/pi-agent-text-editor/src/api/mutation-tool.ts +23 -0
  436. package/src/extensions/pi-agent-text-editor/src/api/text-selection-anchor.ts +31 -1
  437. package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +11 -21
  438. package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +5 -5
  439. package/src/extensions/pi-agent-text-editor/src/core/extension.ts +13 -7
  440. package/src/extensions/pi-agent-text-editor/src/core/file-operation-guards.ts +22 -4
  441. package/src/extensions/pi-agent-text-editor/src/core/image-write.ts +111 -0
  442. package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +3 -0
  443. package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +2 -6
  444. package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +5 -1
  445. package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +17 -36
  446. package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +8 -2
  447. package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +103 -20
  448. package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +146 -62
  449. package/src/extensions/pi-agent-text-editor/src/core/tool-call-interceptor/streaming-provider.ts +14 -19
  450. package/src/extensions/pi-agent-text-editor/src/tools/text-selection.ts +63 -74
  451. package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +5 -5
  452. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +7 -10
  453. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +4 -10
  454. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +8 -8
  455. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-move.ts +5 -8
  456. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +3 -4
  457. package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +37 -22
  458. package/src/pi-agent-ide.ts +12 -16
  459. package/src/plugins/pi-agent-ide-ast/package.json +15 -15
  460. package/src/plugins/pi-agent-ide-ast/runtime/entry-37.js +1 -0
  461. package/src/plugins/pi-agent-ide-ast/src/extension.ts +8 -8
  462. package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +104 -26
  463. package/src/plugins/pi-agent-ide-ast/src/tool-ast-search.ts +210 -0
  464. package/src/plugins/pi-agent-ide-changes/index.ts +1 -2
  465. package/src/plugins/pi-agent-ide-changes/package.json +10 -10
  466. package/src/plugins/pi-agent-ide-changes/runtime/entry-39.js +1 -0
  467. package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +3 -3
  468. package/src/plugins/pi-agent-ide-debugger/index.ts +31 -13
  469. package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +2 -11
  470. package/src/plugins/pi-agent-ide-formatter/package.json +4 -4
  471. package/src/plugins/pi-agent-ide-languages/package.json +3 -3
  472. package/src/plugins/pi-agent-ide-languages/runtime/entry-42.js +2 -0
  473. package/src/plugins/pi-agent-ide-lint/package.json +8 -8
  474. package/src/plugins/pi-agent-ide-lint/runtime/entry-43.js +2 -0
  475. package/src/plugins/pi-agent-ide-lsp/index.ts +22 -28
  476. package/src/plugins/pi-agent-ide-lsp/package.json +14 -10
  477. package/src/plugins/pi-agent-ide-lsp/runtime/entry-44.js +2 -0
  478. package/src/plugins/pi-agent-ide-lsp/src/declaration-targets.ts +1 -1
  479. package/src/plugins/pi-agent-ide-lsp/src/lsp/code-views.ts +8 -84
  480. package/src/plugins/pi-agent-ide-lsp/src/lsp/index.ts +1 -6
  481. package/src/plugins/pi-agent-ide-lsp/src/lsp/symbol-search.ts +11 -11
  482. package/src/plugins/pi-agent-ide-lsp/src/manager-provider.ts +8 -0
  483. package/src/plugins/pi-agent-ide-lsp/src/rename-plan.ts +1 -1
  484. package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +234 -36
  485. package/src/plugins/pi-agent-ide-lsp/src/tool-lsp-search.ts +212 -0
  486. package/src/plugins/pi-agent-ide-processes/src/ui.ts +61 -16
  487. package/src/plugins/pi-agent-ide-terminal/index.ts +43 -1
  488. package/src/plugins/pi-agent-ide-terminal/src/resources.ts +0 -18
  489. package/src/plugins/pi-agent-ide-terminal/src/search.ts +0 -3
  490. package/src/plugins/pi-agent-ide-terminal/src/tools.ts +1 -3
  491. package/src/standalone/resource-host.ts +147 -0
  492. package/src/standalone/scoped-api.ts +457 -0
  493. package/dist/chunk-2RTCSZB3.js +0 -1
  494. package/dist/chunk-4DIUPEDF.js +0 -2
  495. package/dist/chunk-6EDOLYOV.js +0 -1
  496. package/dist/chunk-6FGLAVPJ.js +0 -1
  497. package/dist/chunk-6H32W35W.js +0 -1
  498. package/dist/chunk-6OJ565FL.js +0 -2
  499. package/dist/chunk-6R3Y4AD3.js +0 -1
  500. package/dist/chunk-6TJPMBUQ.js +0 -1
  501. package/dist/chunk-6XFUICD7.js +0 -1
  502. package/dist/chunk-BHSO2MDK.js +0 -6
  503. package/dist/chunk-GBUJOR6V.js +0 -28
  504. package/dist/chunk-GSOYVIQS.js +0 -1
  505. package/dist/chunk-HSRH76JN.js +0 -3
  506. package/dist/chunk-HSZ4AQ6L.js +0 -9
  507. package/dist/chunk-I6NPILT5.js +0 -1
  508. package/dist/chunk-K7SRNBIV.js +0 -1
  509. package/dist/chunk-LCWBVOII.js +0 -3
  510. package/dist/chunk-MKEC3U2M.js +0 -4
  511. package/dist/chunk-NUM3YQGK.js +0 -1
  512. package/dist/chunk-OM4LYD3S.js +0 -1
  513. package/dist/chunk-PLKYHUNT.js +0 -1
  514. package/dist/chunk-PT35ZFLH.js +0 -33
  515. package/dist/chunk-QIJMV2P2.js +0 -2
  516. package/dist/chunk-RVU73VKN.js +0 -2
  517. package/dist/chunk-SDAH3ECM.js +0 -5
  518. package/dist/chunk-SGQWRIRJ.js +0 -10
  519. package/dist/chunk-SWBJS3U4.js +0 -1
  520. package/dist/chunk-T7I2VX3J.js +0 -1
  521. package/dist/chunk-T7MWQQIF.js +0 -3
  522. package/dist/chunk-VDP5CQHM.js +0 -3
  523. package/dist/chunk-XG7QNAKW.js +0 -9
  524. package/dist/chunk-XLWCSJMR.js +0 -1
  525. package/dist/chunk-YFP4P2FV.js +0 -1
  526. package/dist/chunk-YIXP2ALP.js +0 -9
  527. package/dist/entry-23.js +0 -1
  528. package/docs/agent-guides/diagnostics.md +0 -5
  529. package/docs/agent-guides/json-reading.md +0 -57
  530. package/docs/agent-guides/read-resources.md +0 -17
  531. package/docs/agent-guides/search-code.md +0 -76
  532. package/docs/agent-guides/select-code.md +0 -119
  533. package/docs/agent-guides/vision.md +0 -11
  534. package/node_modules/pi-agent-doctor/runtime/entry-22.js +0 -1
  535. package/node_modules/pi-agent-doctor/runtime/entry-23.js +0 -1
  536. package/node_modules/pi-agent-filesystem/runtime/entry-29.js +0 -2
  537. package/node_modules/pi-agent-filesystem-image/runtime/entry-30.js +0 -2
  538. package/node_modules/pi-agent-filesystem-text/runtime/entry-33.js +0 -2
  539. package/node_modules/pi-agent-ide-ast/runtime/entry-34.js +0 -1
  540. package/node_modules/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
  541. package/node_modules/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
  542. package/node_modules/pi-agent-ide-ast/src/ast/selection.ts +0 -204
  543. package/node_modules/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
  544. package/node_modules/pi-agent-ide-ast/src/select-presentation.ts +0 -105
  545. package/node_modules/pi-agent-ide-ast/src/select-schema.ts +0 -387
  546. package/node_modules/pi-agent-ide-ast/src/selection-region.ts +0 -41
  547. package/node_modules/pi-agent-ide-ast/src/source-text.ts +0 -92
  548. package/node_modules/pi-agent-ide-ast/src/text-selection.ts +0 -214
  549. package/node_modules/pi-agent-ide-ast/src/tool-select.ts +0 -277
  550. package/node_modules/pi-agent-ide-changes/runtime/entry-36.js +0 -1
  551. package/node_modules/pi-agent-ide-changes/runtime/entry-37.js +0 -2
  552. package/node_modules/pi-agent-ide-languages/runtime/entry-39.js +0 -2
  553. package/node_modules/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
  554. package/node_modules/pi-agent-image/runtime/entry-42.js +0 -1
  555. package/node_modules/pi-agent-invariant/runtime/entry-43.js +0 -1
  556. package/node_modules/pi-agent-pdf/runtime/entry-44.js +0 -1
  557. package/node_modules/pi-agent-search/runtime/entry-52.js +0 -1
  558. package/node_modules/pi-agent-search-text/runtime/entry-55.js +0 -2
  559. package/node_modules/pi-agent-search-text/runtime/entry-57.js +0 -1
  560. package/node_modules/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
  561. package/node_modules/pi-agent-text-anchor-exact/runtime/entry-62.js +0 -2
  562. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-63.js +0 -1
  563. package/node_modules/pi-agent-text-anchor-line-hash/runtime/entry-64.js +0 -2
  564. package/node_modules/pi-agent-text-editor/runtime/entry-65.js +0 -1
  565. package/node_modules/pi-agent-text-editor/runtime/entry-67.js +0 -1
  566. package/node_modules/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
  567. package/node_modules/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +0 -2
  568. package/node_modules/pi-agent-tool-call-interception/runtime/entry-84.js +0 -1
  569. package/node_modules/pi-agent-tool-ui/runtime/entry-85.js +0 -1
  570. package/node_modules/pi-agent-tool-ui/runtime/entry-86.js +0 -1
  571. package/node_modules/pi-agent-web/runtime/entry-87.js +0 -2
  572. package/node_modules/pi-agent-web-html/runtime/entry-88.js +0 -2
  573. package/node_modules/pi-agent-web-image/runtime/entry-89.js +0 -2
  574. package/src/backend/vision-capture-worker.py +0 -319
  575. package/src/backend/vision-capture.ts +0 -165
  576. package/src/backend/vision-registration.ts +0 -104
  577. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/runtime/entry-30.js +0 -2
  578. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/runtime/entry-31.js +0 -2
  579. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/runtime/entry-33.js +0 -2
  580. package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/runtime/entry-29.js +0 -2
  581. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/runtime/entry-88.js +0 -2
  582. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/runtime/entry-89.js +0 -2
  583. package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/runtime/entry-90.js +0 -2
  584. package/src/extensions/pi-agent-read/extensions/pi-agent-web/runtime/entry-87.js +0 -2
  585. package/src/extensions/pi-agent-read/runtime/entry-45.js +0 -1
  586. package/src/extensions/pi-agent-read/runtime/entry-46.js +0 -1
  587. package/src/extensions/pi-agent-read/runtime/entry-47.js +0 -1
  588. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-55.js +0 -2
  589. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-56.js +0 -1
  590. package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/runtime/entry-57.js +0 -1
  591. package/src/extensions/pi-agent-search/runtime/entry-52.js +0 -1
  592. package/src/extensions/pi-agent-search/runtime/entry-53.js +0 -1
  593. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/runtime/entry-60.js +0 -2
  594. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/runtime/entry-62.js +0 -2
  595. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-63.js +0 -1
  596. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/runtime/entry-64.js +0 -2
  597. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/runtime/entry-82.js +0 -2
  598. package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/runtime/entry-83.js +0 -2
  599. package/src/extensions/pi-agent-text-editor/runtime/entry-65.js +0 -1
  600. package/src/extensions/pi-agent-text-editor/runtime/entry-66.js +0 -1
  601. package/src/extensions/pi-agent-text-editor/runtime/entry-67.js +0 -1
  602. package/src/plugins/pi-agent-ide-ast/runtime/entry-34.js +0 -1
  603. package/src/plugins/pi-agent-ide-ast/runtime/entry-35.js +0 -2
  604. package/src/plugins/pi-agent-ide-ast/src/ast/constructs.ts +0 -193
  605. package/src/plugins/pi-agent-ide-ast/src/ast/element-extent.ts +0 -59
  606. package/src/plugins/pi-agent-ide-ast/src/ast/selection.ts +0 -204
  607. package/src/plugins/pi-agent-ide-ast/src/geometry-selection.ts +0 -184
  608. package/src/plugins/pi-agent-ide-ast/src/select-presentation.ts +0 -105
  609. package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +0 -387
  610. package/src/plugins/pi-agent-ide-ast/src/selection-region.ts +0 -41
  611. package/src/plugins/pi-agent-ide-ast/src/source-text.ts +0 -92
  612. package/src/plugins/pi-agent-ide-ast/src/text-selection.ts +0 -214
  613. package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +0 -277
  614. package/src/plugins/pi-agent-ide-changes/runtime/entry-36.js +0 -1
  615. package/src/plugins/pi-agent-ide-changes/runtime/entry-37.js +0 -2
  616. package/src/plugins/pi-agent-ide-languages/runtime/entry-39.js +0 -2
  617. package/src/plugins/pi-agent-ide-lsp/src/code-view-resolvers.ts +0 -136
  618. package/src/plugins/pi-agent-ide-vision/index.ts +0 -439
  619. package/src/plugins/pi-agent-ide-vision/src/doctor-plugin.ts +0 -47
  620. package/src/plugins/pi-agent-ide-vision/src/vision.ts +0 -585
  621. package/src/plugins/pi-agent-ide-vision/src/windows-display-capture.ps1 +0 -30
  622. package/src/plugins/pi-agent-ide-vision/src/windows-window-capture.ps1 +0 -33
  623. /package/dist/{chunk-U2JKHKLK.js → chunk-3PMHFEJY.js} +0 -0
  624. /package/node_modules/{pi-agent-documentation → pi-agent-doctor}/runtime/entry-28.js +0 -0
  625. /package/node_modules/{pi-agent-filesystem-jq → pi-agent-filesystem}/runtime/entry-31.js +0 -0
  626. /package/node_modules/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-32.js +0 -0
  627. /package/node_modules/{pi-agent-ide-ast → pi-agent-filesystem-pdf}/runtime/entry-35.js +0 -0
  628. /package/node_modules/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-38.js +0 -0
  629. /package/node_modules/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  630. /package/node_modules/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
  631. /package/node_modules/{pi-agent-read → pi-agent-image}/runtime/entry-45.js +0 -0
  632. /package/node_modules/{pi-agent-read → pi-agent-invariant}/runtime/entry-46.js +0 -0
  633. /package/node_modules/{pi-agent-read → pi-agent-pdf}/runtime/entry-47.js +0 -0
  634. /package/node_modules/{pi-agent-resource → pi-agent-read}/runtime/entry-50.js +0 -0
  635. /package/node_modules/{pi-agent-search → pi-agent-read}/runtime/entry-51.js +0 -0
  636. /package/node_modules/{pi-agent-search → pi-agent-resource}/runtime/entry-53.js +0 -0
  637. /package/node_modules/{pi-agent-search-text → pi-agent-search}/runtime/entry-56.js +0 -0
  638. /package/node_modules/{pi-agent-text → pi-agent-search-text}/runtime/entry-59.js +0 -0
  639. /package/node_modules/{pi-agent-text-anchor-exact → pi-agent-search-text}/runtime/entry-61.js +0 -0
  640. /package/node_modules/{pi-agent-text-editor → pi-agent-text-anchor-line-hash}/runtime/entry-66.js +0 -0
  641. /package/node_modules/{pi-agent-web-pdf → pi-agent-web}/runtime/entry-90.js +0 -0
  642. /package/node_modules/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-91.js +0 -0
  643. /package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/{pi-agent-filesystem-pdf → pi-agent-filesystem-image}/runtime/entry-32.js +0 -0
  644. /package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/{pi-agent-web-text → pi-agent-web-html}/runtime/entry-91.js +0 -0
  645. /package/src/extensions/{pi-agent-search → pi-agent-read}/runtime/entry-51.js +0 -0
  646. /package/src/extensions/{pi-agent-text-editor/plugins/pi-agent-text-anchor-exact → pi-agent-search/plugins/pi-agent-search-text}/runtime/entry-61.js +0 -0
  647. /package/src/plugins/{pi-agent-ide-formatter → pi-agent-ide-ast}/runtime/entry-38.js +0 -0
  648. /package/src/plugins/{pi-agent-ide-lint → pi-agent-ide-changes}/runtime/entry-40.js +0 -0
  649. /package/src/plugins/{pi-agent-ide-lsp → pi-agent-ide-formatter}/runtime/entry-41.js +0 -0
@@ -1,28 +0,0 @@
1
- import{a as we,b as Se,c as Te}from"./chunk-PBQDHYNX.js";import{a as ye}from"./chunk-L2B4DTVS.js";import{a as ge,b as he,c as _}from"./chunk-RIJMXO43.js";import"./chunk-PJL3UVMJ.js";import{a as de}from"./chunk-47SPPIXK.js";import{a as me}from"./chunk-4DIUPEDF.js";import{a as ue,b as ce}from"./chunk-VAXLSPPU.js";import{e as pe}from"./chunk-I6NPILT5.js";import{c as fe}from"./chunk-W7CASEO3.js";import"./chunk-QUYXINGZ.js";import{a as D}from"./chunk-XLWCSJMR.js";import{e as te,f as ne}from"./chunk-T7I2VX3J.js";import{a as le}from"./chunk-XXLLY66B.js";import{c as se,d as ae}from"./chunk-235QMMVA.js";import{b as C}from"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import{a as oe}from"./chunk-BU7IZLKB.js";import{a as re,b as ie}from"./chunk-S5PL5DFQ.js";import{i as q,j as M}from"./chunk-LCWBVOII.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import ut from"node:path";import{stripVTControlCharacters as ct}from"node:util";import{truncateLine as dt}from"@earendil-works/pi-coding-agent";import{Text as E}from"@earendil-works/pi-tui";import{DEFAULT_MAX_BYTES as be,DEFAULT_MAX_LINES as xe,formatSize as at,truncateTail as lt}from"@earendil-works/pi-coding-agent";function $(t){return lt(t,{maxBytes:be-4096,maxLines:xe-32})}l($,"terminalOutputTail");function O(t){let e=$(t.output),n=[`session: ${t.source}`,`status: ${t.status}`,`shell: ${t.shell}`,`cwd: ${t.cwd}`,`elapsedMs: ${t.elapsedMs}`,t.exitCode===void 0?void 0:`exitCode: ${t.exitCode}`,t.signal===void 0?void 0:`signal: ${t.signal}`,t.error===void 0?void 0:`error: ${t.error}`,t.waitReason===void 0?void 0:`reason: ${t.waitReason}`,t.completionReason===void 0?void 0:`completionReason: ${t.completionReason}`,t.status==="running"&&t.background?`next: Continue independent work or finish your turn; completion or a one-time idle inspection notice will wake the agent. Read ${t.source} to inspect output; use write or insert when input is needed.`:void 0,`outputRange: ${t.outputStart}-${t.outputEnd}`,t.truncated?"retainedOutput: earlier data omitted from memory":void 0,e.truncated?`fullOutput: ${t.fullOutputPath}`:void 0].filter(o=>o!==void 0),r=e.content.trimEnd();if(!e.truncated)return`${n.join(`
2
- `)}
3
- output:${r.length===0?" (empty)":`
4
- ${r}`}`;let i=e.truncatedBy==="lines"?`${xe} line output budget`:`${at(be)} output budget`,a=`[Earlier output omitted: showing the last ${e.outputLines} of ${e.totalLines} lines (${i}). Full output: ${t.fullOutputPath}]`;return`${n.join(`
5
- `)}
6
- output:
7
- ${a}${r.length===0?"":`
8
- ${r}`}`}l(O,"formatAgentTerminalSnapshot");var mt=500;function ve(t,e,n,r,i){let a=e?"background":"wait",o=`${i.fg("toolTitle",r.displayName.toLocaleLowerCase())} ${i.fg("muted",`\xB7 ${B(n)} \xB7 ${a}`)}`;return new E(`${o}
9
- ${i.fg("accent",X(r.family))} ${t}`,0,0)}l(ve,"renderRunCall");function Re(t,e,n){let r=e.map(i=>` ${n.fg("dim",i)}`);return r.push(n.fg("success",t==="delete"?"\u2713 stopped":"\u2713 sent")),new E(r.join(`
10
- `),0,0)}l(Re,"renderTerminalActionResult");function Pe(t,e,n,r,i){let a=[gt(t,i),i.fg("accent",`${e} ${n}`)];return r.length>0&&a.push(...r.map(o=>` ${i.fg("dim",o)}`)),new E(a.join(`
11
- `),0,0)}l(Pe,"renderTerminalAction");function k(t,e,n,r){let i=ke(t,C,n);return r!==void 0&&i.splice(1,1,n.fg("accent",r)),new E(i.join(`
12
- `),0,0)}l(k,"renderTerminalResult");function Ee(t,e,n){if(e===!0?e="full":e===!1&&(e="compact"),e==="disabled"){if(!(t.status!==void 0&&!["running","completed"].includes(t.status)||t.exitCode!==void 0&&t.exitCode!==0||t.error!==void 0))return new E(I(t,(u,c)=>n.fg(u,c)),0,0);let o=N(t.output??"",C),s=[...o.omission===void 0?[]:[` ${n.fg("muted",o.omission)}`],...o.lines.map(u=>` ${n.fg("dim",u)}`),...t.error===void 0?[]:[` ${n.fg("error",t.error)}`],I(t,(u,c)=>n.fg(u,c))];return new E(s.join(`
13
- `),0,0)}if(e==="full"){let a=ke(t,Number.POSITIVE_INFINITY,n).slice(2);return new E(a.join(`
14
- `),0,0)}let r=N(t.output??"",C),i=[...r.omission===void 0?[]:[` ${n.fg("muted",r.omission)}`],...r.lines.map(a=>` ${n.fg("dim",a)}`)];return i.push(I(t,(a,o)=>n.fg(a,o))),new E(i.join(`
15
- `),0,0)}l(Ee,"renderRunResult");function Ae(t,e){let n=l((o,s)=>e?.fg(o,s)??s,"color"),i=[`${n("accent",t.shell.toLocaleLowerCase())} ${n("muted",`\xB7 ${B(t.cwd)} \xB7 ${t.background?"background":"wait"}`)}`,`${n("accent",X(t.shellFamily))} ${V(t.command,84)}`],a=pt(t.output,2);return a.length>0&&i.push(...a.map(o=>` ${n("dim",V(o,90))}`)),i.push(I(t,n)),i.join(`
16
- `)}l(Ae,"renderActiveTerminal");function ke(t,e,n){let r=(t.shell??"terminal").toLocaleLowerCase(),i=t.background===!0?"background":"wait",a=t.cwd===void 0?"workspace":B(t.cwd),o=t.shellFamily??"posix",s=[`${n.fg("accent",r)} ${n.fg("muted",`\xB7 ${a} \xB7 ${i}`)}`,`${n.fg("accent",X(o))} ${t.command??""}`],u=N(t.output??"",e);return u.omission!==void 0&&s.push(` ${n.fg("muted",u.omission)}`),u.lines.length>0&&s.push(...u.lines.map(c=>` ${n.fg("dim",c)}`)),s.push(I(t,(c,d)=>n.fg(c,d))),s}l(ke,"terminalCardLines");function pt(t,e){return N(t,e).lines}l(pt,"outputTail");function N(t,e){let n=$(ct(t).replaceAll("\r","")),r=n.content.split(`
17
- `).map(u=>dt(u.trimEnd(),mt).text);r.at(-1)===""&&r.pop();let i=Number.isFinite(e)?Math.max(0,e):r.length,a=Math.max(0,r.length-i),o=Math.max(0,n.totalLines-n.outputLines),s=a+o;return{lines:r.slice(a),...n.truncated||s>0?{omission:s>0?`\u2026 ${s} earlier lines`:"\u2026 earlier output omitted"}:{}}}l(N,"outputWindow");function I(t,e){let n=t.status??"running",r=ft(n),i=n==="completed"?"success":n==="running"?"accent":"error",a=[`${r} ${n}`,ht(t.elapsedMs??0)];return t.waitReason!==void 0&&a.push(`background \xB7 ${t.waitReason}`),t.completionReason!==void 0&&a.push(`reason ${t.completionReason}`),t.exitCode!==void 0?a.push(`exit ${t.exitCode}`):t.signal!==void 0&&a.push(`signal ${t.signal}`),e(i,a.join(" \xB7 "))}l(I,"statusLine");function ft(t){return t==="completed"?"\u2713":t==="running"?"\u25CF":t==="stopping"?"\u25CC":"\u2717"}l(ft,"statusIcon");function X(t){return t==="powershell"?"PS>":t==="cmd"?">":"$"}l(X,"promptMarker");function gt(t,e){let n=(t.shell??"terminal").toLocaleLowerCase(),r=t.cwd===void 0?"workspace":B(t.cwd),i=t.background===!0?"background":"wait",a=V(t.command??"process",48);return`${e.fg("toolTitle",n)} ${e.fg("muted",`\xB7 ${r} \xB7 ${i} \xB7 ${a}`)}`}l(gt,"terminalIdentity");function B(t){let e=process.env.HOME;return e!==void 0&&(t===e||t.startsWith(`${e}${ut.sep}`))?`~${t.slice(e.length)}`:t}l(B,"shortCwd");function V(t,e){let n=t.replaceAll(/\s+/gu," ").trim();return n.length<=e?n:`${n.slice(0,e-1)}\u2026`}l(V,"oneLine");function ht(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}l(ht,"formatElapsed");function Ce(t){return{id:"terminal",onDidChange:l(e=>t.onDidChange(e),"onDidChange"),list:l(()=>t.list().filter(e=>e.status==="running"||e.status==="stopping").map(e=>({source:e.source,kind:"terminal",title:e.shell.toLocaleLowerCase(),description:e.command,status:e.status==="stopping"?"stopping":"running",...e.pid===void 0?{}:{pid:e.pid,owned:!0},...e.remote===void 0?{}:{remote:e.remote,owned:!0},renderSummary:l(n=>Ae(e,n).split(`
18
- `),"renderSummary"),renderDetail:l(n=>k(e,!0,n),"renderDetail"),sendInput:l(n=>{Promise.resolve(t.write(e.source,n)).catch(()=>{})},"sendInput"),stop:l(()=>t.delete(e.source),"stop")})),"list")}}l(Ce,"terminalProcessProvider");import{setTimeout as bt}from"node:timers/promises";var yt="#d8dee9",Y="#111418",wt=["#000000","#cd0000","#00cd00","#cdcd00","#0000ee","#cd00cd","#00cdcd","#e5e5e5","#7f7f7f","#ff0000","#00ff00","#ffff00","#5c5cff","#ff00ff","#00ffff","#ffffff"];async function K(t,e,n,r=1){let i=t.get(e);if(i===void 0)throw new Error(`Unknown terminal session ${e}`);await i.screenReady;let{createCanvas:a}=await import("@napi-rs/canvas"),o=Math.max(0,Math.min(i.rows-1,n?.start??0)),s=Math.max(1,Math.min(i.rows-o,n?.count??i.rows)),u=i.cols*9+24,c=s*18+24,d=a(Math.max(1,Math.round(u*r)),Math.max(1,Math.round(c*r))),m=d.getContext("2d");m.scale(r,r),m.fillStyle=Y,m.fillRect(0,0,d.width,d.height),m.textBaseline="top";let p=i.screen.buffer.active,h=Math.max(0,p.baseY);for(let g=0;g<s;g+=1){let S=p.getLine(h+o+g);if(S!==void 0)for(let y=0;y<i.cols;y+=1){let v=S.getCell(y);v===void 0||v.getWidth()===0||St(m,v,y,g)}}return i.status==="running"&&p.cursorY>=o&&p.cursorY<o+s&&(m.fillStyle="rgba(216, 222, 233, 0.75)",m.fillRect(12+p.cursorX*9,12+(p.cursorY-o)*18+18-2,9,2)),d.toBuffer("image/png").toString("base64")}l(K,"renderTerminalScreen");function St(t,e,n,r){let i=$e(e,"foreground"),a=$e(e,"background");e.isInverse()&&([i,a]=[a,i]);let o=12+n*9,s=12+r*18;a!==Y&&(t.fillStyle=a,t.fillRect(o,s,9*Math.max(1,e.getWidth()),18));let u=e.getChars();u.length!==0&&(t.font=`${e.isBold()?"bold ":""}14px monospace`,t.fillStyle=i,t.fillText(u,o,s),e.isUnderline()&&t.fillRect(o,s+18-2,9*Math.max(1,e.getWidth()),1))}l(St,"drawCell");function $e(t,e){let n=e==="foreground";if(n?t.isFgDefault():t.isBgDefault())return n?yt:Y;let i=n?t.isFgRGB():t.isBgRGB(),a=n?t.getFgColor():t.getBgColor();return i?`#${a.toString(16).padStart(6,"0")}`:Tt(a)}l($e,"cellColor");function Tt(t){let e=wt[t];if(e!==void 0)return e;if(t>=232){let s=8+(t-232)*10;return Ie(s,s,s)}let n=Math.max(0,t-16),r=Math.floor(n/36),i=Math.floor(n%36/6),a=n%6,o=l(s=>s===0?0:55+s*40,"channel");return Ie(o(r),o(i),o(a))}l(Tt,"ansiColor");function Ie(t,e,n){return`#${[t,e,n].map(r=>r.toString(16).padStart(2,"0")).join("")}`}l(Ie,"rgb");var Z="\0pi-terminal-write\0",J="\0pi-terminal-keys\0";function xt(t){let e=t?.find(u=>u==="image"||u==="sequence"||u.startsWith("image:")||u.startsWith("sequence:"));if(e===void 0)return;let n=e.indexOf(":"),r=n<0?e:e.slice(0,n),i=new Map;if(n>=0)for(let u of e.slice(n+1).split(",")){let[c,d,m]=u.split("=");if(c===void 0||d===void 0||m!==void 0||d.length===0)throw new Error(`Invalid terminal ${r} view parameter: ${u}`);if(c!=="duration"&&c!=="interval"&&c!=="scale")throw new Error(`Unsupported terminal ${r} view parameter: ${c}`);let p=Number(d);if(!Number.isFinite(p))throw new Error(`Terminal ${c} must be a number`);i.set(c,p)}let a=i.get("duration")??2,o=i.get("interval")??.5,s=i.get("scale")??1;if(!(s>0&&s<=1))throw new Error("Terminal image scale must be greater than 0 and at most 1");if(r==="sequence"){if(!(a>0&&a<=10))throw new Error("Terminal sequence duration must be greater than 0 and at most 10 seconds");if(!(o>0))throw new Error("Terminal sequence interval must be greater than 0 seconds");if(Math.floor(a/o)+1>20)throw new Error("Terminal sequence capture is limited to 20 frames")}return{mode:r,duration:a,interval:o,scale:s}}l(xt,"parseTerminalVisualView");async function De(t,e){let n=new Map,r=new Map,i={protocol:re,apiVersion:ie,id:"terminal",setup(o){o.addResolver({resolver:vt(e),preserveTruncatedOutput:!0,renderResult(s,u,c){let d=s.details,m=d.source===void 0?void 0:e.get(d.source),p=m===void 0?{}:e.snapshot(m);return k(m===void 0?p:{...p,output:e.screenTail(m).join(`
19
- `)},u.expanded,c,"read terminal")}}),o.addHandler({stage:"pre-read",async handler(s){let u=s.request.path;if(u===void 0||!x(u))return{kind:"continue",context:s};let c;try{c=xt(s.request.views)}catch(m){return{kind:"return",result:z(u,m instanceof Error?m.message:String(m))}}if(c===void 0)return{kind:"continue",context:s};let d=e.get(u);if(d===void 0)return{kind:"return",result:z(u,`Unknown terminal session ${u}`)};try{e.markInspected(u);let m=c.mode==="image"?1:Math.floor(c.duration/c.interval)+1,p=[];for(let h=0;h<m;h+=1){s.resolverContext.signal?.throwIfAborted(),h>0&&await bt(c.interval*1e3,void 0,{signal:s.resolverContext.signal});let g=await K(e,u,void 0,c.scale);p.push({type:"image",data:g,mimeType:"image/png"})}return{kind:"return",result:{content:p,script:{kind:"native",source:d.source,blocks:p},details:{source:d.source,resolvedBy:"terminal",frames:m,mode:c.mode}}}}catch(m){return{kind:"return",result:z(u,m instanceof Error?m.message:String(m))}}}}),o.describe({path:"shell:<session> \u2014 terminal status and a bounded output tail with a full-log path when truncated.",views:"On shell:<session>, image[:scale=S] returns the virtual terminal screen; sequence[:duration=D,interval=I,scale=S] returns ordered PNG frames. Defaults: D=2 seconds, I=0.5 seconds, S=1. Scale satisfies 0 < S <= 1; sequences require 0 < D <= 10, I > 0, and at most 20 frames (floor(D/I)+1). Terminal captures do not support region or image grid selection; offset/limit do not crop their frames."})}},a={protocol:se,apiVersion:ae,id:"terminal",setup(o){o.addResolver({resolver:Rt(e)}),o.tool("write").addHandler({stage:"text-pre-edit",handler:l(async s=>(Me(s.input,e,n),await Le(s.input,e,r),Pt(s,Z)),"handler")}),o.tool("insert").addHandler({stage:"text-pre-edit",handler:l(async s=>(await Le(s.input,e,r),Me(s.input,e,n),Et(s)),"handler")});for(let s of["write","insert","delete"])o.addToolRenderer({tool:s,matches:l((u,c)=>$t(u,c),"matches"),renderCall(u,c,d){let m=u,p=typeof m.path=="string"?e.get(m.path):void 0,h=d.state;return p!==void 0&&(h.snapshot=e.snapshot(p)),Pe(h.snapshot??{},s,_e(s,m),[],c)},renderResult(u,c,d){let m=Ct(u.details);return Re(m.action,m.changedLines,d)}});o.describe("For shell:<session> resources, write sends exact terminal input, insert sends named keys at end, and delete terminates and removes the session. replace is unsupported."),o.tool("write").describe("When path is shell:<session>, send content exactly as terminal input without adding Enter."),o.tool("insert").describe("When path is shell:<session>, omit anchor or use end, keep before false, and put whitespace- or comma-separated named keys and chords such as Enter, Ctrl+C, Ctrl+Left, Ctrl+Shift+Left, Up, or Backspace in text. Use Unix caret forms such as ^C and ^U for control characters.")}};await Promise.all([oe(t,i),le(t,a)]),t.on("tool_result",async(o,s)=>{if(!R(o.input))return;let u=o.input.path;if(o.toolName==="replace"&&typeof u=="string"&&x(u)){let w=`replace is unsupported for ${u}; use write for text, insert for keys, or delete to terminate and remove the session.`;return M({content:[{type:"text",text:w}],details:o.details},D(o.toolName),{status:"error",errors:[q(w,"UNSUPPORTED_OPERATION",u)],data:{operation:"replace",effect:"not-applied",files:[{source:u,effect:"not-applied"}]}})}if(o.toolName==="delete"&&typeof u=="string"&&x(u)){let w=e.get(u);if(w===void 0)return;let A=e.snapshot(w);return e.delete(u).then(()=>M({content:[{type:"text",text:`Deleted terminal session ${u}.`}],details:{source:u,deleted:!0,snapshot:A,action:"delete",input:"session",changedLines:[]}},D(o.toolName),{status:"success",errors:[],data:{operation:"delete",effect:"applied",files:[{source:u,effect:"applied"}]}}),T=>M({content:[{type:"text",text:T instanceof Error?T.message:String(T)}],details:{source:u,deleted:!1}},D(o.toolName),{status:"error",errors:[q(T,"TERMINAL_DELETE_FAILED",u)],data:{operation:"delete",effect:"unknown",files:[{source:u,effect:"unknown"}]}}))}if(o.toolName!=="write"&&o.toolName!=="insert"||o.isError)return;let c=o.input.path;if(typeof c!="string"||!x(c))return;let d=e.get(c);if(d===void 0)return;let m=r.get(c)??e.screenRows(d);r.delete(c);let p=n.get(c)??d.outputStart+d.output.length;n.delete(c),await e.waitForOutputAfter(d,p);let h=e.snapshot(d),g=o.toolName,S=_e(g,o.input),y=e.screenChangeRegion(d,m,6),v=[{type:"text",text:`Sent ${S} to ${d.source}.`}];return s.model?.input.includes("image")===!0&&v.push({type:"image",data:await K(e,c,{start:y.startRow,count:y.lines.length}),mimeType:"image/png"}),{content:v,details:{source:d.source,action:g,status:d.status,snapshot:h,input:S,changedLines:y.lines},isError:o.isError,...o.structuredContent===void 0?{}:{structuredContent:o.structuredContent}}})}l(De,"registerTerminalResources");function vt(t){return{id:"terminal",async tryResolve(e){if(!x(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,async read(){t.markInspected(n.source);let r=t.snapshot(n);return[{type:"text",text:At(r)}]}}}}}}l(vt,"createReadResolver");function Rt(t){return{id:"terminal-input",async tryResolve(e){if(!x(e))return{kind:"not-handled"};let n=t.get(e);return n===void 0?{kind:"failed",error:new Error(`Unknown terminal session ${e}`)}:{kind:"resolved",resource:{source:n.source,skipPostEdit:!0,async read(){return[{type:"text",text:"terminal input"}]},async write(r){let i=kt(r),a=i.indexOf(Z),o=i.indexOf(J);if(a>=0){await t.write(n.source,i.slice(a+Z.length));return}if(o>=0){await t.sendKeys(n.source,i.slice(o+J.length).trim());return}throw new Error(`Unsupported text operation for ${n.source}`)}}}}}}l(Rt,"createInputResolver");function Pt(t,e){return!R(t.input)||!Oe(t.input.path)?t:{...t,input:{...t.input,content:`${e}${typeof t.input.content=="string"?t.input.content:""}`}}}l(Pt,"transformWriteInput");function Et(t){if(!R(t.input)||!Oe(t.input.path))return t;if(t.input.before===!0)throw new Error("Shell keys can only be inserted after the active input position");return{...t,input:{...t.input,anchor:"end",before:!1,text:`${J}${typeof t.input.text=="string"?t.input.text:""}`}}}l(Et,"transformInsertInput");function At(t){return O(t)}l(At,"formatSnapshot");function kt(t){if(t.length!==1||t[0].type!=="text")throw new Error("Terminal input must contain one text block");return t[0].text}l(kt,"singleText");function z(t,e){return{content:[{type:"text",text:e}],details:{source:t,failure:{code:"READ_FAILED",source:t,resolverId:"terminal",message:e}},isError:!0}}l(z,"failure");function x(t){return/^shell:[a-f\d]{12}$/u.test(t)}l(x,"isShellSource");function Oe(t){return typeof t=="string"&&x(t)}l(Oe,"isShellSourceValue");function Ct(t){if(!R(t)||!R(t.snapshot))throw new TypeError("Invalid terminal action result");let e=t.snapshot,n=t.action;if(n!=="write"&&n!=="insert"&&n!=="delete")throw new TypeError("Invalid terminal action");return{source:typeof t.source=="string"?t.source:"shell:unknown",action:n,input:typeof t.input=="string"?t.input:"",changedLines:Array.isArray(t.changedLines)?t.changedLines.filter(r=>typeof r=="string"):[],snapshot:{...typeof e.shell=="string"?{shell:e.shell}:{},...typeof e.cwd=="string"?{cwd:e.cwd}:{},...typeof e.command=="string"?{command:e.command}:{},...typeof e.background=="boolean"?{background:e.background}:{},...typeof e.status=="string"?{status:e.status}:{}}}}l(Ct,"terminalActionDetails");async function Le(t,e,n){if(!R(t)||typeof t.path!="string"||!x(t.path))return;let r=e.get(t.path);r!==void 0&&await r.screenReady,r!==void 0&&n.set(t.path,e.screenRows(r))}l(Le,"rememberScreen");function Me(t,e,n){if(!R(t)||typeof t.path!="string"||!x(t.path))return;let r=e.get(t.path);r!==void 0&&n.set(t.path,r.outputStart+r.output.length)}l(Me,"rememberOutputEnd");function _e(t,e){if(t==="delete")return"session";let n=t==="write"?e.content:e.text,r=typeof n=="string"?n:"";return t==="write"?`text ${JSON.stringify(r)}`:`keys ${r}`}l(_e,"terminalInputLabel");function $t(t,e){if(!R(t))return!1;if(e==="call")return typeof t.path=="string"&&x(t.path);let n=t.details;return R(n)&&typeof n.source=="string"&&x(n.source)}l($t,"isTerminalRenderValue");function R(t){return typeof t=="object"&&t!==null}l(R,"isRecord");async function Ne(t,e){await de(t,{protocol:ue,apiVersion:ce,id:"terminal",setup(r){r.addResolver({resolver:It(e),priority:100}),r.describe("path shell:<session> searches the retained text output of that terminal, including rows outside its current screen.")}})}l(Ne,"registerTerminalSearch");function It(t){return{readResources:l(e=>e.path?.startsWith("shell:")?[e.path]:[],"readResources"),id:"terminal",toScriptData(e){let n=U(e);return pe(n.matches,!1)},async tryResolve(e){if(e.path===void 0||!e.path.startsWith("shell:"))return{kind:"not-handled"};let n=t.get(e.path);if(n===void 0)return{kind:"failed",error:new Error(`Unknown terminal session ${e.path}`)};let r=t.snapshot(n),i=Lt(r,e);return{kind:"resolved",payload:{snapshot:r,query:e.query,matches:i}}},format(e){let n=U(e),r=n.matches.map(i=>`${n.snapshot.source}:${i.lineNumber}: ${i.lineText}`);return{content:[{type:"text",text:r.length===0?`No matches in ${n.snapshot.source}`:`${r.join(`
20
- `)}
21
-
22
- ${r.length} match${r.length===1?"":"es"} in ${n.snapshot.source}`}],details:{source:n.snapshot.source,payload:n}}},renderResult(e,n,r){let i=e.details,a=Q(i)?U(i.payload):U(void 0);return me(a.matches,!1,r,n.expanded===!0,void 0,[`Retained terminal output \xB7 ${a.snapshot.status} \xB7 read-only`])}}}l(It,"terminalSearchResolver");function Lt(t,e){let n=e.caseSensitive===!0?e.query:e.query.toLocaleLowerCase();if(n.length===0)return[];let r=[],i=e.limit??100;for(let[a,o]of t.output.replaceAll("\r","").split(`
23
- `).entries()){let s=e.caseSensitive===!0?o:o.toLocaleLowerCase(),u=0;for(;r.length<i;){let c=s.indexOf(n,u);if(c<0)break;let d=c+n.length;(e.wholeWord!==!0||Mt(s,c,d))&&r.push({source:t.source,lineNumber:a+1,startColumn:c,endColumn:d,matchedText:o.slice(c,d),lineText:o}),u=Math.max(d,c+1)}if(r.length>=i)break}return r}l(Lt,"findTerminalMatches");function Mt(t,e,n){return!/[\p{L}\p{N}_]/u.test(t[e-1]??"")&&!/[\p{L}\p{N}_]/u.test(t[n]??"")}l(Mt,"isWordBoundary");function U(t){if(!_t(t))throw new TypeError("Invalid terminal search result");return t}l(U,"parsePayload");function _t(t){return Q(t)&&typeof t.query=="string"&&Array.isArray(t.matches)&&Q(t.snapshot)&&typeof t.snapshot.source=="string"}l(_t,"isTerminalSearchPayload");function Q(t){return typeof t=="object"&&t!==null}l(Q,"isRecord");import{spawn as Ot}from"node:child_process";import{closeSync as Nt,mkdirSync as Bt,openSync as Ut,rmSync as Wt,writeSync as Ft}from"node:fs";import jt from"node:os";import Fe from"node:path";import{createRequire as Ht}from"node:module";import{randomUUID as Gt}from"node:crypto";import{stripVTControlCharacters as qt}from"node:util";import{StringDecoder as Vt}from"node:string_decoder";import Dt from"node:os";import Be from"node:path";var W={executable:"/bin/bash",displayName:"Bash over SSH",family:"posix",commandArgs:l(t=>["-lc",t],"commandArgs")};function Ue(t=process.platform,e=process.env){if(t==="win32"){let i=e.SHELL?.trim()||"powershell.exe",a=Be.win32.basename(i).toLowerCase();return a==="cmd"||a==="cmd.exe"?{executable:i,displayName:"Command Prompt",family:"cmd",commandArgs:l(o=>["/d","/s","/c",o],"commandArgs")}:{executable:i,displayName:a.startsWith("pwsh")?"PowerShell":"Windows PowerShell",family:"powershell",commandArgs:l(o=>["-NoLogo","-NoProfile","-Command",o],"commandArgs")}}let n=e.SHELL?.trim()||Dt.userInfo().shell||(t==="darwin"?"/bin/zsh":"/bin/bash"),r=Be.basename(n);return{executable:n,displayName:r==="zsh"?"zsh":r==="bash"?"Bash":r,family:"posix",commandArgs:l(i=>["-c",i],"commandArgs")}}l(Ue,"resolveShellProfile");function We(t){switch(t.family){case"powershell":return"Write PowerShell syntax. Use PowerShell cmdlets, `$env:NAME` for environment variables, and `;` or pipelines to compose commands.";case"cmd":return"Write Command Prompt syntax. Use `%NAME%` for environment variables and `&&` to chain successful commands.";case"posix":return`Write ${t.displayName} syntax. Use POSIX-style paths, \`$NAME\` for environment variables, and \`&&\` or pipelines to compose commands.`}}l(We,"shellSyntaxGuidance");var Ge=Ht(new URL("../src/plugins/pi-agent-ide-terminal/src/session-manager.ts",import.meta.url).href),je=1e6,Xt=100,Yt=30,Kt=2e3,zt=50,L=class{static{l(this,"TerminalSessionManager")}#l;#e=new Map;#r=new Set;#i=new Set;#o=new Map;#s=new Map;#u=!1;constructor(e=Qt){this.#l=e}onDidChange(e){return this.#r.add(e),()=>this.#r.delete(e)}onDidComplete(e){return this.#i.add(e),()=>this.#i.delete(e)}list(){return[...this.#e.values()].sort((e,n)=>n.startedAt-e.startedAt).map(e=>this.snapshot(e))}get(e){return this.#e.get(en(e))}snapshot(e,n=Date.now()){return{id:e.id,source:e.source,...e.origin===void 0?{}:{origin:e.origin},command:e.command,cwd:e.cwd,shell:e.shell.displayName,shellFamily:e.shell.family,...e.process===void 0?{}:{pid:e.process.pid},...e.remote===void 0?{}:{remote:{target:e.remote.target,pid:e.remote.process.pid,...e.remote.process.identity===void 0?{}:{identity:e.remote.process.identity}}},background:e.background,status:e.status,...e.waitReason===void 0?{}:{waitReason:e.waitReason},...e.completionReason===void 0?{}:{completionReason:e.completionReason},lastActivityAt:e.lastActivityAt,idleMs:Math.max(0,n-e.lastActivityAt),startedAt:e.startedAt,...e.endedAt===void 0?{}:{endedAt:e.endedAt},elapsedMs:(e.endedAt??n)-e.startedAt,...e.exitCode===void 0?{}:{exitCode:e.exitCode},...e.signal===void 0?{}:{signal:e.signal},...e.error===void 0?{}:{error:e.error},output:e.output,outputStart:e.outputStart,outputEnd:e.outputStart+e.output.length,truncated:e.outputStart>0,fullOutputPath:e.fullOutputPath,cols:e.cols,rows:e.rows}}start(e){let n=this.#c(e),{id:r,cols:i,rows:a}=n,o;try{let u=Ge("node-pty"),c={name:"xterm-256color",cols:i,rows:a,cwd:e.cwd,env:nn(tn()),...globalThis.process.platform==="win32"?{useConptyDll:!0}:{}};o=u.spawn(e.shell.executable,[...e.shell.commandArgs(e.command)],c)}catch(u){let c={...n,status:"failed",endedAt:Date.now(),error:F(u)};return this.#e.set(r,c),this.#n(r),n.resolveCompletion(c),queueMicrotask(()=>this.#a(c)),c}let s={...n,process:o};return this.#e.set(r,s),o.onData(u=>this.#d(s,u)),globalThis.process.platform==="win32"&&s.screen.onData(u=>{if(!P(s.status))try{o.write(u)}catch{}}),o.onExit(({exitCode:u,signal:c})=>{P(s.status)||(s.endedAt=Date.now(),s.exitCode=u,c!==0&&(s.signal=c),s.status=s.status==="stopping"?"stopped":u===0?"completed":"failed",(u===124||u===137)&&(s.completionReason="timeout"),this.#n(s.id),s.resolveCompletion(s),this.#t(s),this.#a(s))}),this.#t(s),s}#c(e){if(this.#u)throw new Error("Terminal session manager is closed");let n=this.#l();if(!/^[a-f0-9]{12}$/u.test(n)||this.#e.has(n)||this.#s.has(n))throw new Error("Terminal session IDs must be unique 12-character hexadecimal values");let r=sn(n);this.#o.set(n,Ut(r,"a",384));let i=e.cols??Xt,a=e.rows??Yt,o=Jt(i,a),s=l(c=>{},"resolveCompletion"),u=new Promise(c=>{s=c});return{id:n,source:`shell:${n}`,command:e.command,background:e.background,cwd:e.cwd,shell:e.shell,startedAt:Date.now(),lastActivityAt:Date.now(),cols:i,rows:a,fullOutputPath:r,screen:o,status:"running",output:"",outputStart:0,screenReady:Promise.resolve(),completion:u,resolveCompletion:s,completionDelivered:!1,staleReminderDelivered:!1}}async startRemote(e){let n=W,r=this.#c({...e,cwd:e.remote.location.source,shell:n}),i=new AbortController;this.#s.set(r.id,{abort:i,completion:r.completion});let a=l(()=>i.abort(),"abortStartup");e.signal?.addEventListener("abort",a,{once:!0}),e.signal?.aborted&&a();try{let o=await e.remote.backend.startProcess(n.executable,n.commandArgs(e.command),e.remote.location.path,{pty:{cols:r.cols,rows:r.rows},signal:i.signal}).finally(()=>e.signal?.removeEventListener("abort",a)),s={...r,remote:{target:e.remote.location.target,process:o}};this.#e.set(s.id,s);let u=new Vt("utf8");o.stdout.on("data",d=>this.#d(s,u.write(d))),o.stderr.resume();let c=l(()=>{this.#d(s,u.end()),s.endedAt=Date.now(),this.#n(s.id),s.resolveCompletion(s),this.#t(s),this.#a(s)},"finish");return o.completion.then(({exitCode:d})=>{s.exitCode=d,d<0&&(s.signal=-d),s.status=s.status==="stopping"?"stopped":d===0?"completed":"failed",(d===124||d===137)&&(s.completionReason="timeout"),c()},d=>{s.status="lost",s.error=F(d),c()}),this.#t(s),s}catch(o){let s={...r,status:"failed",endedAt:Date.now(),error:F(o)};return this.#e.set(s.id,s),this.#n(s.id),s.resolveCompletion(s),queueMicrotask(()=>this.#a(s)),s}finally{this.#s.delete(r.id)}}async wait(e,n){let r=this.required(e);return P(r.status)?r:n?.aborted===!0?(await this.stop(r.source,"cancelled"),r):await new Promise((i,a)=>{let o=l(()=>{this.stop(r.source,"cancelled").then(i,a)},"onAbort");n?.addEventListener("abort",o,{once:!0}),r.completion.then(s=>{n?.removeEventListener("abort",o),i(s)},a)})}async waitForForeground(e,n){let r=this.required(e);if(P(r.status))return{session:r};let i=n.interactiveDelayMs??3e3;return await new Promise(a=>{let o=!1,s,u=l(p=>{o||(p!==void 0&&P(r.status)&&(p=void 0),o=!0,clearTimeout(d),clearInterval(m),n.signal?.removeEventListener("abort",c),p!==void 0&&(r.background=!0,p!=="aborted"&&(r.waitReason=p),this.#t(r)),a({session:r,...p===void 0?{}:{reason:p}}))},"finish"),c=l(()=>u("aborted"),"onAbort"),d=setTimeout(()=>u("timeout"),n.timeoutMs),m=setInterval(()=>{if(!Zt(r)){s=void 0;return}s??=Date.now(),Date.now()-s>=i&&u("interactive")},Math.min(100,Math.max(10,i/2)));n.signal?.addEventListener("abort",c,{once:!0}),n.signal?.aborted===!0&&c(),r.completion.then(()=>u())})}async waitForOutputAfter(e,n){let r=Date.now()+300,i=n,a;for(;Date.now()<r;){let o=e.outputStart+e.output.length;if(o!==i)i=o,a=Date.now(),await e.screenReady;else if(a!==void 0&&Date.now()-a>=40)return;await ee(10)}await e.screenReady}screenRows(e){let n=e.screen.buffer.active;return Array.from({length:e.rows},(r,i)=>(n.getLine(n.baseY+i)?.translateToString(!0)??"").trimEnd())}screenChangeRegion(e,n,r=6){let i=this.screenRows(e),a=Math.max(1,Math.min(e.rows,r)),o=Math.max(0,e.screen.buffer.active.cursorY-Math.floor(a/2)),s=-1;for(let d=0;d<=e.rows-a;d+=1){let m=0;for(let p=d;p<d+a;p+=1){let h=n[p]??"",g=i[p]??"",S=g.length>0&&!n.includes(g),y=h.length>0&&g.length===0;h!==g&&(S||y)&&(m+=1)}m>s&&(s=m,o=d)}let u=e.screen.buffer.active;return{lines:i.slice(o,o+a).map((d,m)=>{if(o+m!==u.cursorY)return d;let h=d.padEnd(u.cursorX," ");return`${h.slice(0,u.cursorX)}\u258C${h.slice(u.cursorX)}`}),startRow:o}}screenChangeWindow(e,n,r=6){return this.screenChangeRegion(e,n,r).lines}screenTail(e,n=e.rows){let r=e.screen.buffer.active,i=Math.max(0,r.baseY),a=[];for(let o=0;o<e.rows;o+=1){let s=r.getLine(i+o)?.translateToString(!0).trimEnd();s!==void 0&&s.length>0&&a.push(s)}return a.slice(-Math.max(0,n))}markInspected(e){let n=this.required(e);n.status==="running"&&(n.lastActivityAt=Date.now(),this.#t(n))}write(e,n){let r=this.requiredRunning(e);if(r.remote)return r.remote.process.write(Buffer.from(n)).catch(i=>{throw r.error=F(i),this.#t(r),i});r.process?.write(n)}sendKeys(e,n){return this.write(e,rn(n))}async stop(e,n="stopped"){let r=this.required(e);return P(r.status)||(r.status="stopping",this.#t(r),await He(r,!1),await Promise.race([r.completion.then(()=>!0),ee(Kt).then(()=>!1)])||(await He(r,!0),await Promise.race([r.completion,ee(1e3)])),P(r.status)||(r.status=n,r.endedAt=Date.now(),this.#n(r.id),r.resolveCompletion(r),this.#a(r)),n==="cancelled"&&(r.status="cancelled"),this.#t(r)),r}async delete(e){let n=this.required(e);n.completionDelivered=!0,await this.stop(n.source),n.screen.dispose(),this.#n(n.id),Wt(n.fullOutputPath,{force:!0}),this.#e.delete(n.id),this.#t(n)}async screenLines(e){let n=this.required(e);await n.screenReady;let r=n.screen.buffer.active,i=[],a=Math.max(0,r.baseY);for(let o=a;o<a+n.rows;o+=1)i.push(r.getLine(o)?.translateToString(!0)??"");return i}cursor(e){let n=this.required(e);return{x:n.screen.buffer.active.cursorX,y:n.screen.buffer.active.cursorY}}async dispose(){if(this.#u)return;this.#u=!0;let e=[...this.#s.values()];for(let n of e)n.abort.abort();await Promise.all(e.map(n=>n.completion)),await Promise.all([...this.#e.values()].filter(n=>!P(n.status)).map(n=>this.stop(n.source)));for(let n of this.#e.values())n.screen.dispose(),this.#n(n.id);this.#r.clear(),this.#i.clear()}required(e){let n=this.get(e);if(n===void 0)throw new Error(`Unknown terminal session ${e}`);return n}requiredRunning(e){let n=this.required(e);if(n.status!=="running")throw new Error(`Terminal session ${n.source} is ${n.status}; input is unavailable`);return n}#d(e,n){e.lastActivityAt=Date.now();let r=qt(n),i=this.#o.get(e.id);if(i!==void 0&&Ft(i,r),e.output+=r,e.output.length>je){let a=e.output.length-je;e.output=e.output.slice(a),e.outputStart+=a}e.screenReady=e.screenReady.then(()=>new Promise(a=>{e.screen.write(n,a)})),this.#t(e)}#n(e){let n=this.#o.get(e);n!==void 0&&(Nt(n),this.#o.delete(e))}#t(e){for(let n of this.#r)n(e)}#a(e){for(let n of this.#i)n(e);this.#m()}#m(){let e=[...this.#e.values()].filter(n=>P(n.status)).sort((n,r)=>(r.endedAt??0)-(n.endedAt??0));for(let n of e.slice(zt))n.background&&!n.completionDelivered||(n.screen.dispose(),this.#n(n.id),this.#e.delete(n.id))}};function Zt(t){if(t.status!=="running")return!1;let e=t.screen.buffer.active,n=e.getLine(e.baseY+e.cursorY)?.translateToString(!0).trimEnd()??"";return/\[[^\]\n]{1,20}(?:\/[^\]\n]{1,20})+\]\s*[:?>]?\s*$/iu.test(n)||/(?:choose|select|enter|password|confirm|continue|proceed)[^\n]{0,60}[:?]\s*$/iu.test(n)||/^(?:❯|›)\s+\S/u.test(n)}l(Zt,"looksInteractive");function Jt(t,e){let{Terminal:n}=Ge("@xterm/headless");return new n({cols:t,rows:e,scrollback:2e3,allowProposedApi:!0})}l(Jt,"createScreen");function Qt(){return Gt().replaceAll("-","").slice(0,12)}l(Qt,"defaultSessionId");function en(t){return t.startsWith("shell:")?t.slice(6):t}l(en,"normalizeSessionId");function P(t){return t!=="running"&&t!=="stopping"}l(P,"isTerminalStatus");function tn(){return process.env}l(tn,"processEnvironment");function nn(t){return{...Object.fromEntries(Object.entries(t).filter(e=>e[1]!==void 0)),PAGER:"cat",GIT_PAGER:"cat",SYSTEMD_PAGER:"cat",GH_PAGER:"cat"}}l(nn,"cleanEnvironment");function rn(t){return t.split(/[\s,]+/u).filter(Boolean).map(on).join("")}l(rn,"encodeTerminalKeys");function on(t){if(/^\^[?@A-Z[\\\]^_]$/iu.test(t)){let d=t.slice(1).toUpperCase();return d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31)}let e=t.toLowerCase().split("+"),n=e.pop()??"",r=new Set(e);if([...r].some(d=>!["ctrl","control","alt","meta","shift"].includes(d)))throw new Error(`Unsupported terminal key ${t}`);let i=r.has("ctrl")||r.has("control"),a=r.has("alt")||r.has("meta"),o=r.has("shift");if(i&&n.length===1&&/[a-z@[\\\]^_?]/u.test(n)){let d=n.toUpperCase(),m=d==="?"?"\x7F":String.fromCharCode(d.charCodeAt(0)&31);return a?`\x1B${m}`:m}let s={enter:"\r",tab:" ",escape:"\x1B",esc:"\x1B",backspace:"\x7F",home:"\x1B[H",end:"\x1B[F",delete:"\x1B[3~"};if(!i&&!a&&!o&&s[n]!==void 0)return s[n];if(a&&!i&&!o&&s[n]!==void 0)return`\x1B${s[n]}`;let c={up:"A",down:"B",right:"C",left:"D",home:"H",end:"F"}[n];if(c!==void 0)return!i&&!a&&!o?`\x1B[${c}`:`\x1B[1;${1+(o?1:0)+(a?2:0)+(i?4:0)}${c}`;if(a&&!i&&n.length===1)return`\x1B${o?n.toUpperCase():n}`;throw new Error(`Unsupported terminal key ${t}`)}l(on,"encodeTerminalKey");async function He(t,e){if(t.remote){await t.remote.process.stop().catch(()=>{});return}let n=t.process;if(n!==void 0){if(globalThis.process.platform!=="win32")try{globalThis.process.kill(-n.pid,e?"SIGKILL":"SIGTERM");return}catch{try{n.kill(e?"SIGKILL":"SIGTERM")}catch{}return}await new Promise(r=>{let i=Ot("taskkill.exe",["/PID",String(n.pid),"/T",...e?["/F"]:[]],{windowsHide:!0,stdio:"ignore"});i.once("error",()=>r()),i.once("exit",()=>r())})}}l(He,"terminateProcessTree");function ee(t){return new Promise(e=>setTimeout(e,t))}l(ee,"delay");function F(t){return t instanceof Error?t.message:String(t)}l(F,"errorMessage");function sn(t){let e=Fe.join(jt.tmpdir(),`pi-agent-ide-terminal-${process.pid}`);return Bt(e,{recursive:!0,mode:448}),Fe.join(e,`${t}.log`)}l(sn,"createOutputLog");import{AgentSession as an}from"@earendil-works/pi-coding-agent";var j=Symbol.for("pi-agent-ide.terminal-steering-observers");function qe(t){let e=an.prototype,n=e[j]??ln(e);return n.listeners.add(t),()=>{n.listeners.delete(t),n.listeners.size===0&&n.restore()}}l(qe,"observeQueuedSteering");function ln(t){let e=t.prompt,n=t.steer,r=new Set,i=l(u=>{for(let c of[...r])c(u)},"notify"),a=l(function(u,c){return c?.streamingBehavior!=="steer"?e.call(this,u,c):e.call(this,u,{...c,preflightResult:l(d=>{c.preflightResult?.(d),d==="queued"&&i(this)},"preflightResult")})},"prompt"),o=l(async function(...u){let c=await n.apply(this,u);return c==="queued"&&i(this),c},"steer");t.prompt=a,t.steer=o;let s={listeners:r,restore:l(()=>{t[j]===s&&(t.prompt===a&&(t.prompt=e),t.steer===o&&(t.steer=n),delete t[j])},"restore")};return t[j]=s,s}l(ln,"installObservers");import Ke from"node:path";import{stripVTControlCharacters as cn}from"node:util";import{defineTool as dn}from"@earendil-works/pi-coding-agent";import{Type as b}from"typebox";import{Text as mn}from"@earendil-works/pi-tui";import{open as un}from"node:fs/promises";import{Type as f}from"typebox";var Ve=1024*1024,Xe=f.Object({output:f.String({description:"ANSI-free PTY output, up to 1 MiB. Longer output joins the first and last 512 KiB without adding labels or an omission marker. See output_ranges for the gap."}),truncated:f.Boolean({description:"Whether output omits bytes from the retained log. This is independent of whether the process has finished."}),full_output_path:f.String({description:"UTF-8 log of all output received so far. Available until the shell session is deleted."}),output_ranges:f.Array(f.Object({start:f.Integer(),end:f.Integer()}),{description:"Zero-based, end-exclusive UTF-8 byte ranges in the log, concatenated into output."}),exit_code:f.Optional(f.Number({description:"Process exit code, only when known."})),wall_time_seconds:f.Number(),session:f.String({description:"Session ID."}),source:f.String({description:"Persistent shell: source for Read, input and termination."}),status:f.Union(["running","completed","failed","stopping","stopped","cancelled","lost"].map(t=>f.Literal(t))),background:f.Boolean(),cwd:f.String({description:"Actual working directory; SSH sessions retain their canonical ssh:// target URI."}),remote:f.Optional(f.Object({target:f.String(),pid:f.Integer({minimum:1})},{description:"Remote process identity, never a local native PID."})),wait_reason:f.Optional(f.Union([f.Literal("timeout"),f.Literal("interactive"),f.Literal("steering")])),completion_reason:f.Optional(f.Literal("timeout")),signal:f.Optional(f.Number()),error:f.Optional(f.String())});async function Ye(t){let e=await un(t.fullOutputPath,"r");try{let n=(await e.stat()).size,r=l(async(s,u)=>{let c=Buffer.alloc(u),d=0;for(;d<u;){let m=await e.read(c,d,u-d,s+d);if(m.bytesRead===0)throw new Error("Shell output log ended before its snapshot size");d+=m.bytesRead}return c},"readRange"),i,a,o=n>Ve;if(!o)i=(await r(0,n)).toString("utf8"),a=[{start:0,end:n}];else{let s=Ve/2,u=await r(0,s),c=await r(n-s,s),d=new TextDecoder().decode(u,{stream:!0}),m=0;for(;m<c.length&&(c.readUInt8(m)&192)===128;)m++;let p=c.subarray(m).toString("utf8");i=d+p,a=[{start:0,end:Buffer.byteLength(d)},{start:n-s+m,end:n}]}return{output:i,truncated:o,full_output_path:t.fullOutputPath,output_ranges:a,...t.exitCode===void 0?{}:{exit_code:t.exitCode},wall_time_seconds:t.elapsedMs/1e3,session:t.id,source:t.source,status:t.status,background:t.background,cwd:t.cwd,...t.remote===void 0?{}:{remote:t.remote},...t.waitReason===void 0?{}:{wait_reason:t.waitReason},...t.completionReason===void 0?{}:{completion_reason:t.completionReason},...t.signal===void 0?{}:{signal:t.signal},...t.error===void 0?{}:{error:t.error}}}finally{await e.close()}}l(Ye,"structuredShellResult");var pn=l(t=>b.Object({command:b.String({minLength:1,description:`Command for ${t.displayName} (${t.executable}). ${We(t)}`}),background:b.Optional(b.Boolean({description:"Set true to return after an initial output preview instead of waiting for completion. Defaults to false."})),timeoutSeconds:b.Optional(b.Number({minimum:.1,maximum:86400,description:"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."})),cwd:b.Optional(b.String({description:"Working directory. Relative paths resolve from the current workspace."})),cols:b.Optional(b.Integer({minimum:20,maximum:300,description:"Virtual terminal width in cells"})),rows:b.Optional(b.Integer({minimum:5,maximum:120,description:"Virtual terminal height in cells"}))},{additionalProperties:!1}),"createRunParameters");function ze(t,e,n,r,i="compact",a=new _([]),o){let s=new Set,u=process.platform==="win32"?"powershell":"bash",c=pn(n);return t.registerTool(dn({name:u,exposure:"direct",namespace:{name:"ide_terminal",description:"Run shell commands in persistent terminal sessions."},annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},label:n.displayName,promptSnippet:`Execute ${n.displayName} commands in synchronous or background terminal sessions`,promptGuidelines:[`Do not use ${u} 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.`],description:`Use ${u} 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.`,parameters:c,outputSchema:Xe,async execute(d,m,p,h,g){r.bind(g);let S=o?.(d,g),y=a.resolve(m.cwd??g.cwd,g.cwd),v={command:m.command,background:m.background??!1,...m.cols===void 0?{}:{cols:m.cols},...m.rows===void 0?{}:{rows:m.rows}},w=y?await e.startRemote({...v,remote:y,...p===void 0?{}:{signal:p}}):e.start({...v,cwd:m.cwd===void 0?g.cwd:Ke.resolve(g.cwd,m.cwd),shell:n});if(w.origin??=S,m.background===!0&&w.status!=="failed")return await fn(e,w,h),w.status!=="running"&&(w.completionDelivered=!0),H(e.snapshot(w));if(w.status==="failed")return H(e.snapshot(w));let A=new AbortController;s.add(A);let T;try{T=await e.waitForForeground(w.source,{signal:p===void 0?A.signal:AbortSignal.any([p,A.signal]),timeoutMs:(m.timeoutSeconds??60)*1e3})}finally{s.delete(A)}return T.reason==="aborted"&&A.signal.aborted&&p?.aborted!==!0?(T.session.waitReason="steering",H(e.snapshot(T.session))):(T.reason==="aborted"&&r.notifyWaitTransition(T.session),H(e.snapshot(T.session)))},renderCall(d,m,p){if((p.expanded?"full":i)==="disabled")return new mn(m.fg("toolTitle",u),0,0);let g=typeof d.command=="string"?d.command:"",S=typeof d.cwd=="string"&&d.cwd.startsWith("ssh:"),y=typeof d.cwd=="string"?S?d.cwd:Ke.resolve(process.cwd(),d.cwd):process.cwd();return ve(g,d.background===!0,y,S?W:n,m)},renderResult(d,m,p){return Ee(d.details,m.expanded?"full":i,p)}})),()=>{for(let d of s)d.abort()}}l(ze,"registerTerminalTools");function Ze(t){let e=$(t.output).content;return{content:[{type:"text",text:O(t)}],details:{...t,output:e,outputStart:t.outputEnd-e.length,truncated:t.truncated||e.length<t.output.length},isError:t.status==="failed"||t.status==="lost"}}l(Ze,"terminalPreview");async function H(t){return{...Ze(t),structuredContent:await Ye(t)}}l(H,"terminalResult");async function fn(t,e,n){await new Promise(r=>{let i=!1,a,o=l(()=>{},"unsubscribe"),s=l(()=>{i||(i=!0,clearTimeout(a),o(),r())},"finish"),u=l(()=>{let c=t.snapshot(e);n?.(Ze(c)),(cn(c.output).replaceAll("\r","").split(`
24
- `).filter(m=>m.length>0).length>=C||c.status!=="running")&&s()},"publish");o=t.onDidChange(c=>{c.id===e.id&&u()}),a=setTimeout(s,2e3),u()})}l(fn,"captureInitialBackgroundPreview");import{Box as et,Container as tt}from"@earendil-works/pi-tui";var gn=120,hn=12e4,G=class{constructor(e,n,r=hn){this.pi=e;this.manager=n;this.staleIntervalMs=r;e.registerMessageRenderer("terminal-stale",(i,{expanded:a},o)=>Je(i.details,a,o)),e.registerMessageRenderer("terminal-completion",(i,{expanded:a},o)=>Qe(i.details,a,o)),e.registerEntryRenderer("terminal-stale-display",(i,{expanded:a},o)=>Je(i.data,a,o)),e.registerEntryRenderer("terminal-completion-display",(i,{expanded:a},o)=>Qe(i.data,a,o)),this.#u=[n.onDidChange(i=>this.#c(i)),n.onDidComplete(i=>{this.#a(i.id),i.background&&this.#m(i)})]}static{l(this,"TerminalUi")}#l=new Map;#e;#r=new Map;#i=new Set;#o;#s=!1;#u;bind(e){this.#o=e;for(let n of this.manager.list()){let r=this.manager.get(n.id);r===void 0||!r.background||(r.status==="running"?this.#c(r):r.status!=="stopping"&&this.#m(r))}}onAgentSettled(e){this.#o=e;for(let n of[...this.#i]){this.#i.delete(n);let r=this.manager.get(n);r!==void 0&&this.#c(r,!0)}}notifyWaitTransition(e){let n=this.#n(e);this.pi.sendMessage({customType:"terminal-wait-transition",display:!1,content:`Terminal wait ended; ${n.source} is still running in background. Read it to inspect output, then use write or insert to send input.`,details:n},{triggerTurn:!0,deliverAs:"steer"})}dispose(){this.#s=!0,this.#e!==void 0&&clearTimeout(this.#e),this.#e=void 0,this.#l.clear();for(let e of this.#r.values())clearTimeout(e);this.#r.clear(),this.#i.clear(),this.#o=void 0;for(let e of this.#u)e()}#c(e,n=!1){if(this.#a(e.id),this.#s||e.staleReminderDelivered||!e.background||e.status!=="running")return;let r=this.#n(e),i=Math.max(0,this.staleIntervalMs-r.idleMs);if(n&&i===0){this.#d(e);return}this.#r.set(e.id,setTimeout(()=>this.#d(e),i))}#d(e){if(this.#r.delete(e.id),this.#s||e.staleReminderDelivered||e.status!=="running"||!e.background)return;if(this.#o?.isIdle()!==!0){this.#i.add(e.id);return}e.staleReminderDelivered=!0;let n=this.#n(e);this.pi.sendMessage({customType:"terminal-stale",display:!1,content:Sn(n),details:n},{triggerTurn:!0,deliverAs:"followUp"}),this.pi.appendEntry("terminal-stale-display",{...n,...this.#t(n)})}#n(e){return{...this.manager.snapshot(e),...e.origin===void 0?{}:{origin:e.origin}}}#t(e){let n=e.origin;return n!==void 0&&n.sessionId===this.#o?.sessionManager.getSessionId()?{parentToolCallId:n.parentToolCallId}:{}}#a(e){let n=this.#r.get(e);n!==void 0&&clearTimeout(n),this.#r.delete(e),this.#i.delete(e)}#m(e){this.#s||e.completionDelivered||(this.#l.set(e.id,e),this.#e===void 0&&(this.#e=setTimeout(()=>{this.#e=void 0;let n=[...this.#l.values()].filter(a=>!a.completionDelivered);if(this.#l.clear(),this.#s||n.length===0)return;for(let a of n)a.completionDelivered=!0;let r=n.map(a=>this.#n(a));this.pi.sendMessage({customType:"terminal-completion",display:!1,content:wn(r),details:{sessions:r}},{triggerTurn:!0,deliverAs:"steer"});let i=new Map;for(let a of r){let o=this.#t(a).parentToolCallId,s=i.get(o)??[];s.push(a),i.set(o,s)}for(let[a,o]of i)this.pi.appendEntry("terminal-completion-display",{sessions:o,...a===void 0?{}:{parentToolCallId:a}})},gn)))}};function Je(t,e,n){let r=new tt;nt(t)&&r.addChild(k(t,e,n,"stale \xB7 inspect session"));let i=new et(1,1,a=>n.bg("toolPendingBg",a));return i.addChild(r),i}l(Je,"renderStale");function Qe(t,e,n){let r=new tt;for(let a of yn(t))r.addChild(k(a,e,n));let i=new et(1,1,a=>n.bg("toolSuccessBg",a));return i.addChild(r),i}l(Qe,"renderCompletion");function yn(t){return!it(t)||!Array.isArray(t.sessions)?[]:t.sessions.filter(nt)}l(yn,"completionSnapshots");function nt(t){return it(t)&&typeof t.id=="string"&&typeof t.source=="string"&&typeof t.command=="string"&&typeof t.cwd=="string"&&typeof t.shell=="string"&&typeof t.background=="boolean"&&typeof t.status=="string"&&typeof t.startedAt=="number"&&typeof t.elapsedMs=="number"&&typeof t.output=="string"}l(nt,"isTerminalSessionSnapshot");function wn(t){return`${t.length===1?"Background terminal completed:":"Background terminals completed:"}
25
- ${t.map(n=>{let r=n.exitCode===void 0?"":`, exit ${n.exitCode}`,i=n.completionReason===void 0?"":`, reason ${n.completionReason}`,a=n.output.trimEnd().slice(-2e3);return`- ${n.source}: ${n.status}${r}${i}, ${rt(n.elapsedMs)}
26
- ${a||"(no output)"}`}).join(`
27
- `)}`}l(wn,"formatCompletionMessage");function Sn(t){let e=t.output.trimEnd().slice(-2e3);return`Background terminal ${t.source} has produced no output for ${rt(t.idleMs)}. Inspect it with read. If it is healthy, keep waiting; otherwise send input or stop it.
28
- ${e||"(no output)"}`}l(Sn,"formatStaleMessage");function rt(t){return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`}l(rt,"formatElapsed");function it(t){return typeof t=="object"&&t!==null}l(it,"isRecord");function ot(t){let e=new Map;return t.on("tool_call",n=>{let r=n.parentToolCallId;e.set(n.toolCallId,r===void 0?n.toolCallId:e.get(r)??r)}),t.on("tool_result",n=>{e.delete(n.toolCallId)}),t.on("agent_end",()=>{e.clear()}),t.on("session_shutdown",()=>{e.clear()}),(n,r)=>({toolCallId:n,parentToolCallId:e.get(n)??n,sessionId:r.sessionManager.getSessionId()})}l(ot,"registerTerminalOrigins");function st(t){return t==="full"||t==="disabled"?t:"compact"}l(st,"toolPresentation");async function Tn(t,e){ne(t,[await te({id:"terminal",description:"Foreground and background commands, shell resources, and processes",triggers:[{tool:"bash"},{tool:"powershell"},...["read","write","insert","delete"].map(c=>({tool:c,resourcePrefixes:["shell:","process:"]}))]})]);let n=Se("terminal",L)??new L,r=Ue(),i=new _(await he(ge(fe()))),a=new G(t,n),o=ye(t).add(Ce(n));await Promise.all([De(t,n),Ne(t,n)]);let s=ze(t,n,r,a,st(e?.preferences["ui.terminal"]),i,ot(t)),u=l(()=>{},"removeSteeringObserver");t.on("session_start",(c,d)=>{a.bind(d),u(),u=qe(m=>{m.sessionManager===d.sessionManager&&s()})}),t.on("agent_settled",(c,d)=>a.onAgentSettled(d)),t.on("session_shutdown",async c=>{if(u(),a.dispose(),o(),c.reason!=="quit"){we("terminal",n);return}Te("terminal",n),await n.dispose()})}l(Tn,"registerTerminal");export{Tn as default};
@@ -1 +0,0 @@
1
- import{a as y}from"./chunk-NJ7C4KMA.js";import"./chunk-6H32W35W.js";import"./chunk-NUM3YQGK.js";import{a as b}from"./chunk-QT3EAHOG.js";import{a as k,b as E}from"./chunk-VXP5BMW7.js";import{b as S}from"./chunk-RW2GTYQI.js";import{a as u,b as w,c as v}from"./chunk-RIJMXO43.js";import{g as c}from"./chunk-PJL3UVMJ.js";import{a as p,b as h,d as P}from"./chunk-XG7QNAKW.js";import"./chunk-47SPPIXK.js";import"./chunk-4DIUPEDF.js";import"./chunk-VAXLSPPU.js";import"./chunk-I6NPILT5.js";import{c as f}from"./chunk-W7CASEO3.js";import"./chunk-TOYN4W4F.js";import"./chunk-YJ6T3PEP.js";import"./chunk-S72FVLUX.js";import"./chunk-XXLLY66B.js";import"./chunk-235QMMVA.js";import"./chunk-NNCZYO4Q.js";import"./chunk-IICJXZBU.js";import"./chunk-PS2B6THP.js";import"./chunk-BU7IZLKB.js";import"./chunk-S5PL5DFQ.js";import"./chunk-LCWBVOII.js";import"./chunk-DUUOCBS3.js";import"./chunk-T4FTT3U4.js";import"./chunk-ZPT5D4VP.js";import"./chunk-ZAWRSA7N.js";import"./chunk-OFILFO6D.js";import"./chunk-KINKBPPX.js";import{c as m}from"./chunk-IMGIDBCC.js";import"./chunk-BXGMMZT3.js";import"./chunk-756K3LJY.js";import"./chunk-ZC65Z3CK.js";import{a as i}from"./chunk-EI7MMDWY.js";import R from"node:path";function g(d){let n=i(o=>{let e=d.resolve(o);if(!e)throw new c("UNSUPPORTED_SOURCE",o,"not-applied");return e},"resolve");return{transport:i(o=>y(d,o),"transport"),async readText(o,e){let r=n(o);return(await r.backend.read(r.location.path,{signal:e})).bytes.toString("utf8")},async readSnapshot(o,e){let r=n(o),t=await r.backend.read(r.location.path,{signal:e});return{content:t.bytes.toString("utf8"),version:t.version}},async readBytes(o,e){let r=n(o);return(await r.backend.read(r.location.path,{signal:e})).bytes},async exists(o,e){let r=n(o);try{return await r.backend.stat(r.location.path,{signal:e}),!0}catch(t){if(t instanceof c&&t.code==="ENOENT")return!1;throw t}},async isFile(o,e){let r=n(o);return(await r.backend.stat(r.location.path,{signal:e})).kind==="file"},async entries(o,e){let r=n(o);return(await r.backend.list(r.location.path,{signal:e})).map(t=>({name:t.name,kind:t.kind==="symlink"?"other":t.kind}))}}}i(g,"createSshLspWorkspaceOwner");async function O(d){let n=new v(await w(u(f()))),o=g(n);await P(d,{workspace:i(e=>e.startsWith("ssh://")?o:void 0,"workspace"),async loadRegistry(e,r,t){t?.throwIfAborted();let s=n.resolve(e);if(s)return h.fromPackageDir(e,{signal:t,layerAccess:k(n,t),includeGlobal:!r,requireBuiltInEvidence:r,recipes:p,recipeEvidence:i(a=>E(s.backend,s.location.path,a,t),"recipeEvidence"),executableAvailability:i(a=>S(s.backend,s.location.path,a,t),"executableAvailability")});if(e.includes("://"))throw new c("UNSUPPORTED_SOURCE",e,"not-applied");return h.fromPackageDir(r?e:process.env.PI_AGENT_IDE_CONFIG_DIR??e,{signal:t,includeGlobal:!r,requireBuiltInEvidence:r,recipes:p})},async resolveProject(e,r,t){if(t?.throwIfAborted(),e.startsWith("ssh://")||r.startsWith("ssh://")){let a=n.resolve(e,r);if(!a)throw new c("UNSUPPORTED_SOURCE",e,"not-applied");let l=n.resolve(r);if(l&&l.location.target!==a.location.target)throw new c("UNSUPPORTED_SOURCE",e,"not-applied");return b(a.backend,a.location.path,l?.location.path,"lsp-servers",p,t)}let s=await m(r,e,"lsp-servers",p,t);return s===void 0?void 0:{cwd:s,external:s!==R.resolve(r)}}})}i(O,"registerOwnedLsp");export{O as default};
@@ -1,3 +0,0 @@
1
- import{a as N,b as B}from"./chunk-VDP5CQHM.js";import{a as O}from"./chunk-47SPPIXK.js";import{a as $,c as b,e as D,f as _,g as L,h as y,i as H}from"./chunk-4DIUPEDF.js";import{a as A,b as k}from"./chunk-VAXLSPPU.js";import{e as I}from"./chunk-I6NPILT5.js";import{a as z}from"./chunk-YJ6T3PEP.js";import{b as S,c as v}from"./chunk-S72FVLUX.js";import{d as T}from"./chunk-IICJXZBU.js";import{a as C}from"./chunk-BU7IZLKB.js";import{a as P,b as x}from"./chunk-S5PL5DFQ.js";import{F as E,l as W}from"./chunk-LCWBVOII.js";import{e as R}from"./chunk-756K3LJY.js";import{a as i}from"./chunk-EI7MMDWY.js";var M={protocol:S,apiVersion:v,id:"web-browser",setup(r){r.addCheck({id:"system-browser",title:"Browser web reads",async run(e){try{e.signal?.throwIfAborted();let t=e.workspace?await V(e.workspace,e.signal):await R(await N(e.env.PI_AGENT_IDE_BROWSER_PATH,e.env),["--version"],e.cwd,e.env,e.signal);return e.signal?.throwIfAborted(),[t.ok?{status:"pass",message:"Chrome/Chromium is available",detail:t.detail}:{status:"warn",message:"Chrome/Chromium cannot start",detail:t.detail}]}catch(t){return e.signal?.throwIfAborted(),[{status:"warn",message:"Browser reads are unavailable",detail:t instanceof Error?t.message:String(t)}]}}})}};async function V(r,e){if(!r.probeBrowser)throw new Error("Project owner does not provide a browser probe");return r.probeBrowser(e)}i(V,"probeOwnerBrowser");function F(r){return{id:"web",readResources:i(e=>e.path!==void 0&&/^https?:/iu.test(e.path)?[e.path]:[],"readResources"),async tryResolve(e,t){let o=e.path;if(o===void 0||!/^(?:https?:|web:)/iu.test(o))return{kind:"not-handled"};if(e.include!==void 0||e.exclude!==void 0)return{kind:"failed",error:new Error("File include/exclude globs do not apply to a web page.")};let s=q(e),a=await r.tryResolve(o,t);if(a.kind!=="resolved")return a;if(a.resource.read===void 0)return{kind:"failed",error:new Error(`Cannot read ${o}`)};let n=await a.resource.read({signal:t.signal});if(n.some(l=>l.type!=="text"))return{kind:"failed",error:new Error(`Web search requires text content: ${o}`)};let u=n.map(l=>l.type==="text"?l.text:"").join(`
2
- `),d=[],h=e.limit??50;for(let[l,m]of u.split(/\r\n|\n|\r/u).entries()){t.signal?.throwIfAborted();for(let c of m.matchAll(s)){if(c[0].length===0)continue;let p=c.index,f=p+c[0].length;if(!(e.wholeWord===!0&&(new RegExp("\\p{L}|\\p{N}|_","u").test(m[p-1]??"")||new RegExp("\\p{L}|\\p{N}|_","u").test(m[f]??"")))){if(d.length===h)return{kind:"resolved",payload:{source:o,matches:d,complete:!1}};d.push({source:o,lineNumber:l+1,startColumn:p,endColumn:f,matchedText:c[0],lineText:m})}}}let g=d.length===0&&D(e.query)?U(u,o,e.query,t.signal):void 0;return{kind:"resolved",payload:{source:o,matches:d,complete:!0,...g===void 0?{}:{fuzzy:g}}}},toScriptData(e){let t=e;return{...I(t.matches,t.complete),...t.fuzzy===void 0?{}:{fuzzy:{...t.fuzzy,candidates:t.fuzzy.candidates.map(o=>y(o))}}}},renderResult(e,t,o){let s=e.details;return $(s.matches,s.complete,o,t.expanded,void 0,["Web page \xB7 read-only",...s.complete?[]:["Limit reached \xB7 incomplete results"]])},format(e){let t=e,o=t.matches.length===0?`No matches in ${t.source}`:`${t.matches.length}${t.complete?"":"+"} matches in ${t.source}${t.complete?"":" (limit reached)"}`,s=[o];t.fuzzy?.status==="skipped"&&s.push(`Possible-name fallback skipped: ${t.fuzzy.message}`),t.fuzzy?.candidates.length&&s.push("Possible names \u2014 spelling suggestions, not equivalent behavior.",...t.fuzzy.candidates.map(n=>H(y(n))));let a=Buffer.byteLength(o);for(let n of t.matches){let u=`${t.source}:${n.lineNumber}:${n.startColumn+1} ${j(n)}`;if(a+=Buffer.byteLength(u)+1,a>48*1024){s.push("Output shortened. Narrow the query or lower the limit.");break}s.push(u)}return{content:[{type:"text",text:s.join(`
3
- `)}],details:t}}}}i(F,"createWebSearchResolver");function U(r,e,t,o){o?.throwIfAborted();let s=performance.now(),a=new _;if(a.addText(r),a.limited)return{status:"skipped",message:"name collection reached its byte or unique-name budget",candidates:[]};let n=[];for(let u of L(t,a.names)){if(o?.throwIfAborted(),performance.now()-s>b.timeoutMs)return{status:"skipped",message:"extra search reached its time budget",candidates:[]};let d=new RegExp(u.identifier.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),"gu"),h=[],g=!0,l=0;e:for(let[m,c]of r.split(/\r\n|\n|\r/u).entries()){if(performance.now()-s>b.timeoutMs)return{status:"skipped",message:"extra search reached its time budget",candidates:[]};o?.throwIfAborted();for(let p of c.matchAll(d)){let f=p.index,w=f+p[0].length;if(!(/[\p{L}\p{N}_$]/u.test(c[f-1]??"")||/[\p{L}\p{N}_$]/u.test(c[w]??""))){if(l+=Buffer.byteLength(c),h.length===b.matchesPerCandidate||l>b.verificationBytes){g=!1;break e}h.push({source:e,lineNumber:m+1,startColumn:f,endColumn:w,matchedText:p[0],lineText:c})}}}h.length>0&&n.push({...u,matches:h,complete:g})}return n.length===0?void 0:{status:"ready",candidates:n}}i(U,"searchFuzzyText");function j(r){let e=Math.max(0,r.startColumn-64),t=Math.min(r.lineText.length,r.startColumn+192);return`${e>0?"\u2026":""}${r.lineText.slice(e,t)}${t<r.lineText.length?"\u2026":""}`}i(j,"previewMatch");function q(r){let e=r.query,t=e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,o=e.startsWith("regex:")?e.slice(6):t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(o,r.caseSensitive===!0?"gu":"giu")}i(q,"searchPattern");var G={provider:"web",capability:"read"},J=T({kind:"markdown",label:"WEB"});async function Q(r){await K(r)}i(Q,"registerWeb");async function K(r,e){let t=E(r,G),o=B(t,{owner:e?.(t)}),s={protocol:P,apiVersion:x,id:"web",setup(n){n.addResolver({resolver:o,renderResult:J,preserveTruncatedOutput:!0}),n.describe({path:i(()=>W(e?"HTTP(S) URLs use local HTTP/browser execution; web:ssh://target/https://\u2026 explicitly uses the configured target. Web content is read-only. Target browser fallback requires target-installed Node, playwright-core and Chrome/Chromium. Browser reads enable page JavaScript and disable the Chromium sandbox, using a fresh temporary profile.":"HTTP(S) URL \u2014 remote content.",t.listDescriptions()),"path")})}},a={protocol:A,apiVersion:k,id:"web",setup(n){n.addResolver({resolver:F(o),priority:-100}),n.describe("HTTP(S) Search reuses converted page text for zero-result identifier spelling suggestions. Candidate groups carry the URL and line ranges, never editable SEARCH references."),n.addPromptGuideline(e?"Use search with an HTTP(S) path for local web execution or web:ssh://target/https://\u2026 for explicit target execution; no prior read is required.":"Use search with an HTTP(S) path to find text on a web page; no prior read is required.")}};await Promise.all([C(r,s),O(r,a),Promise.resolve(z(r,M))])}i(K,"registerWebWithOwner");export{Q as a,K as b};
@@ -1,9 +0,0 @@
1
- import{a as Ee}from"./chunk-NJ7C4KMA.js";import{a as xe}from"./chunk-6FGLAVPJ.js";import"./chunk-6H32W35W.js";import"./chunk-NUM3YQGK.js";import{a as X,d as ke}from"./chunk-6XFUICD7.js";import{a as Ae}from"./chunk-SMIFCAAX.js";import{a as Ie,b as Re}from"./chunk-VXP5BMW7.js";import{b as Ce}from"./chunk-RW2GTYQI.js";import{a as Pe,b as Se,c as Oe}from"./chunk-RIJMXO43.js";import"./chunk-VMTOFEXF.js";import{a as De}from"./chunk-CPELC6JE.js";import{a as K,g as D}from"./chunk-PJL3UVMJ.js";import{c as ve}from"./chunk-W7CASEO3.js";import{a as ue,b as fe,c as ge}from"./chunk-57F5GTHO.js";import"./chunk-TOYN4W4F.js";import{a as H,b as he,c as me,d as ye,e as we,g as be}from"./chunk-S72FVLUX.js";import"./chunk-LCWBVOII.js";import{d as le,e as L}from"./chunk-IMGIDBCC.js";import{a as de}from"./chunk-BXGMMZT3.js";import{d as pe}from"./chunk-756K3LJY.js";import{a as N}from"./chunk-ZC65Z3CK.js";import{a as s}from"./chunk-EI7MMDWY.js";import{mkdir as Ke,readFile as Xe,writeFile as Qe}from"node:fs/promises";async function Te(n,r,t,o){if(o?.throwIfAborted(),n.includes("://")&&!t||t&&t.source!==n)throw Object.assign(new Error("Doctor configuration needs its project owner"),{code:"UNSUPPORTED_SOURCE"});t||await Ke(le(n),{recursive:!0});let e=[],i=r.filter(f=>f.recipe.formatter!==void 0),a=r.filter(f=>f.recipe.linter!==void 0),u=r.filter(f=>f.recipe.lsp!==void 0);if(i.length>0){let f=t?(await t.configPaths("formatters",o)).project:L(n,"formatters"),{config:h,previous:p}=await Q(f,{version:1,formatters:{}},t,o),m=Z(h,"formatters");for(let w of i)m[w.recipe.id]??=w.recipe.formatter;await q(f,h,p,t,o)&&e.push(f)}if(a.length>0){let f=t?(await t.configPaths("linters",o)).project:L(n,"linters"),{config:h,previous:p}=await Q(f,{version:1,linters:{}},t,o),m=Z(h,"linters");for(let w of a)m[w.recipe.id]??=w.recipe.linter;await q(f,h,p,t,o)&&e.push(f)}if(u.length>0){let f=t?(await t.configPaths("lsp-servers",o)).project:L(n,"lsp-servers"),{config:h,previous:p}=await Q(f,{version:1,servers:{}},t,o),m=Z(h,"servers");for(let w of u){let g=N(w.recipe.lsp);m[w.recipe.id]??={command:g.command,transport:"stdio",rootMarkers:g.rootMarkers,...g.initializationOptions!==void 0&&{initializationOptions:g.initializationOptions},...g.settings!==void 0&&{settings:g.settings},...g.requireRootMarker!==void 0&&{requireRootMarker:g.requireRootMarker},languages:Object.fromEntries(Object.entries(g.languageIds).map(([y,C])=>[y,{extensions:C,...g.fileNames?.[y]&&{fileNames:g.fileNames[y]}}])),capabilities:["diagnostics"]}}await q(f,h,p,t,o)&&e.push(f)}return e}s(Te,"writeSuggestedConfigs");async function Q(n,r,t,o){let e;try{e=t?await t.readText(n,o):await Xe(n,{encoding:"utf8",signal:o})}catch(a){if(o?.throwIfAborted(),!(typeof a=="object"&&a!==null&&"code"in a&&a.code==="ENOENT"))throw a}if(o?.throwIfAborted(),e===void 0)return{config:r,previous:e};let i=JSON.parse(e);if(typeof i!="object"||i===null||Array.isArray(i))throw new Error(`${n} must contain an object`);return{config:i,previous:e}}s(Q,"readObject");function Z(n,r){let t=n[r];if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`${r} must be an object`);return t}s(Z,"objectMember");async function q(n,r,t,o,e){e?.throwIfAborted();let i=`${JSON.stringify(r,null,2)}
2
- `;return t===i?!1:(o?await o.writeText(n,i,t,e):await Qe(n,i,{encoding:"utf8",signal:e}),!0)}s(q,"writeJson");function je(n,r){let t=new Set,o;for(let e of n.trim().split(/\s+/u).filter(Boolean))if(["--apply","--no-apply","--agent"].includes(e))t.add(e);else if(e.startsWith("ssh://")&&o===void 0)o=e;else throw new TypeError("Use /pi-agent-ide-doctor [ssh://target/path] [--apply | --no-apply] [--agent]");if(t.has("--apply")&&t.has("--no-apply"))throw new TypeError("Choose --apply or --no-apply, not both");return{cwd:o??r,flags:t}}s(je,"parseDoctorArguments");var z=class{static{s(this,"DoctorCore")}plugins=new Map;languages=[];recipes=[];setupChecks=[];checks=[];queue=Promise.resolve();registerPlugin(r){let t=this.plugins.get(r.id);if(t!==void 0)return t;let o=this.queue.then(async()=>{let e=!0,i=[],a=[],u=[],f=[],h={addLanguage:s(p=>{V(p,i,r.id,"language",()=>e)},"addLanguage"),addToolRecipe:s(p=>{V(p,a,r.id,"tool recipe",()=>e)},"addToolRecipe"),addSetupCheck:s(p=>{V(p,u,r.id,"setup check",()=>e)},"addSetupCheck"),addCheck:s(p=>{V(p,f,r.id,"check",()=>e)},"addCheck")};try{await r.setup(h)}finally{e=!1}$e(this.languages,i,"language"),$e(this.recipes,a,"tool recipe"),this.languages.push(...i),this.recipes.push(...a),this.setupChecks.push(...u),this.checks.push(...f)});return this.plugins.set(r.id,o),this.queue=o.catch(()=>{}),o.catch(()=>{this.plugins.delete(r.id)}),o}async waitForPlugins(){await Promise.all(this.plugins.values())}snapshot(){return{languages:[...this.languages],recipes:[...this.recipes],setupChecks:[...this.setupChecks],checks:[...this.checks]}}};async function Ne(n,r){let t=[],o=[];for(let e of n.setupChecks)try{let i=await e.value.inspect(r);t.push(...(i.selections??[]).map(a=>({...a,pluginId:e.pluginId}))),o.push(...(i.actions??[]).map(a=>({...a,pluginId:e.pluginId})))}catch{}return{selections:t,actions:o}}s(Ne,"runContributedSetupChecks");async function Le(n,r){let t=[];for(let o of n.checks)try{t.push({pluginId:o.pluginId,title:o.value.title,findings:await o.value.run(r)})}catch(e){t.push({pluginId:o.pluginId,title:o.value.title,findings:[{status:"fail",message:e instanceof Error?e.message:String(e)}]})}return t}s(Le,"runContributedChecks");function $e(n,r,t){for(let o of r){let e=n.find(i=>i.value.id===o.value.id)?.pluginId;if(e!==void 0)throw new Error(`${t} ${o.value.id} is already owned by doctor plugin ${e}`)}}s($e,"assertAvailable");function V(n,r,t,o,e){if(!e())throw new Error(`Doctor plugin ${t} setup is complete`);if(!/^[a-z0-9][a-z0-9.-]*$/u.test(n.id))throw new Error(`Invalid ${o} ID: ${n.id}`);if(r.some(i=>i.value.id===n.id))throw new Error(`Doctor plugin ${t} registered ${o} ${n.id} twice`);r.push({pluginId:t,value:n})}s(V,"add");import st from"node:path";import{readFile as Ze}from"node:fs/promises";async function _e(n,r,t,o=process.env,e,i){e?.throwIfAborted();let a=t.filter(({value:g})=>g.languages.some(y=>r.has(y))),u=a.map(g=>g.value),f=i?await i.evidence(u,e):await de(n,u,void 0,e),h=await et(n,e,i),p=[...new Set(u.flatMap(g=>g.executables))],m=i?await i.executableAvailability(p.map(g=>({command:[g]})),e):void 0;if(e?.throwIfAborted(),m&&(m.length!==p.length||m.some(g=>typeof g!="boolean")))throw new TypeError("Invalid Doctor executable availability report");let w=[];for(let g of a){e?.throwIfAborted();let y=g.value,C=[],I=1,b=f.get(y.id),O=b?.config;O!==void 0&&(I+=6,C.push(`project config: ${O}`)),h.has(`${y.kind}:${y.id}`)&&(I+=6,C.push("Pi Agent IDE config"));let c=b?.dependency;c!==void 0&&(I+=4,C.push(`project dependency: ${c}`));let d=m?y.executables.find(l=>m[p.indexOf(l)]===!0):await qe(n,y.executables,o,e);d!==void 0&&(I+=3,C.push(`executable: ${d}`)),w.push({pluginId:g.pluginId,recipe:y,score:I,evidence:C,...d&&{executable:d}})}return w.sort((g,y)=>y.score-g.score||g.recipe.id.localeCompare(y.recipe.id))}s(_e,"discoverRecipeCandidates");function Ue(n,r,t=[]){let o=new Map,e=new Map(t.map(i=>[`${i.kind}:${i.languageId}`,i.toolId]));for(let i of r)for(let a of["formatter","linter","lsp"]){let u=e.get(`${a}:${i}`),f=u===void 0?4:7,h=n.filter(m=>m.recipe.kind===a&&m.recipe.languages.includes(i)&&m.executable!==void 0&&m.recipe.id!==u&&m.score>=f),p=h[0];p!==void 0&&(h.filter(m=>m.score===p.score).length>1||o.set(`${p.recipe.kind}:${p.recipe.id}`,p))}return[...o.values()]}s(Ue,"selectSuggestedRecipes");async function qe(n,r,t,o){for(let e of r)if(await pe(e,n,t,o))return e}s(qe,"firstExecutable");async function et(n,r,t){let o=new Set;for(let[e,i,a]of[["formatters","formatters","formatter"],["linters","linters","linter"],["lsp-servers","servers","lsp"]])try{r?.throwIfAborted();let u=t?(await t.configPaths(e,r)).project:L(n,e),f=t?await t.readText(u,r):await Ze(u,{encoding:"utf8",signal:r});if(r?.throwIfAborted(),f===void 0)continue;let h=JSON.parse(f);if(typeof h!="object"||h===null||Array.isArray(h))continue;let m=h[i];if(typeof m=="object"&&m!==null&&!Array.isArray(m))for(let w of Object.keys(m))o.add(`${a}:${w}`)}catch(u){if(r?.throwIfAborted(),!(u instanceof SyntaxError)&&!(typeof u=="object"&&u!==null&&"code"in u&&u.code==="ENOENT"))throw u}return o}s(et,"managedRecipeIds");import{execFile as tt}from"node:child_process";import{readdir as ot}from"node:fs/promises";import _ from"node:path";import{promisify as nt}from"node:util";var rt=nt(tt),it=new Set([".git",".hg",".svn","node_modules","vendor","build","dist","coverage",".cache",".next","target"]);async function Be(n,r){r?.throwIfAborted();try{let o=(await rt("git",["ls-files","--cached","--others","--exclude-standard","-z"],{cwd:n,encoding:"utf8",maxBuffer:16777216,signal:r})).stdout.split("\0").filter(Boolean).map(e=>_.resolve(n,e)).filter(e=>!Me(e));return r?.throwIfAborted(),o.length>0?o:await ee(n,r)}catch{return r?.throwIfAborted(),ee(n,r)}}s(Be,"collectProjectFiles");function Fe(n,r,t=process.platform){let o=new Map,e=t==="win32"?_.win32:_;for(let i of r){let a=new Set(i.extensions.map(p=>p.toLowerCase())),u=s(p=>t==="win32"?p.toLowerCase():p,"normalizeName"),f=new Set(i.fileNames?.map(u)),h=n.filter(p=>!p.split(_.sep).join("/").includes("/.pi/pi-agent-ide/")&&(a.has(e.extname(p).toLowerCase())||f.has(u(e.basename(p)))));h.length>0&&o.set(i.id,h)}return o}s(Fe,"detectProjectLanguages");async function ee(n,r){r?.throwIfAborted();let t=[];for(let o of await ot(n,{withFileTypes:!0})){if(o.isDirectory()&&it.has(o.name))continue;let e=_.join(n,o.name);Me(e)||(o.isDirectory()?t.push(...await ee(e,r)):o.isFile()&&t.push(e))}return t}s(ee,"walk");function Me(n){return n.split(_.sep).join("/").includes("/.pi/pi-agent-ide/")}s(Me,"isManagedIdeConfig");function at(n,r){if(n.includes("://")&&!r||r&&r.source!==n)throw Object.assign(new Error(`Doctor requires the owner of ${n}`),{code:"UNSUPPORTED_SOURCE"})}s(at,"assertWorkspace");async function te(n,r,t=process.env,o,e){o?.throwIfAborted(),at(r,e);let i=e?await e.files(o):await Be(r,o);o?.throwIfAborted();let a=Fe(i,n.languages.map(w=>w.value),e?.platform),u=new Set(a.keys()),f={cwd:r,files:i,detectedLanguageIds:u,detectedLanguages:a,env:e?{...e.toolPaths}:t,signal:o,workspace:e},[h,p]=await Promise.all([_e(r,u,n.recipes,e?{...e.toolPaths}:t,o,e),Ne(n,f)]);o?.throwIfAborted();let m=new Map;for(let w of u)for(let g of["formatter","linter","lsp"]){if(p.selections.some(b=>b.languageId===w&&b.kind===g))continue;let y=h.filter(b=>b.recipe.kind===g&&b.recipe.languages.includes(w)),C=s(b=>b.score-(b.executable===void 0?0:3),"nativeScore"),I=Math.max(1,...y.map(C));for(let b of y){if(b.executable!==void 0||C(b)!==I||I<=1)continue;let O=`${g}-${b.recipe.id}-unavailable`;m.set(O,{id:O,pluginId:b.pluginId,message:`Native project setup selects ${b.recipe.id}, but its executable is unavailable. Install ${b.recipe.executables.join(" or ")} and run Doctor again.`})}}return{cwd:r,files:i,detectedLanguages:a,candidates:h,selections:p.selections,actions:[...p.actions,...m.values()],suggestions:Ue(h,u,p.selections)}}s(te,"inspectDoctorSetup");async function Y(n,r,t=process.env,o,e){let i=await te(n,r,t,o,e),a=new Set(i.detectedLanguages.keys()),u={cwd:r,files:i.files,detectedLanguageIds:a,detectedLanguages:i.detectedLanguages,env:e?{...e.toolPaths}:t,signal:o,workspace:e},f=await Le(n,u);o?.throwIfAborted();let h=[{status:"pass",message:`Project: ${r}`},i.files.length>0?{status:"pass",message:`${i.files.length} project files inspected`}:{status:"warn",message:"No project files found"},a.size>0?{status:"pass",message:`Detected: ${[...a].join(", ")}`}:{status:"warn",message:"No registered project languages detected"}];return{...i,sections:[{title:"Project",pluginId:"doctor",findings:h},...f]}}s(Y,"runDoctor");function M(n){let r=["Pi Agent IDE doctor",""];for(let t of n.sections){r.push(`${t.title} (${t.pluginId})`);for(let o of t.findings)r.push(` ${o.status.toUpperCase().padEnd(4)} ${o.message}`),o.detail!==void 0&&r.push(` \`${o.detail}\``);r.push("")}if(n.actions.length>0){r.push("Setup needs attention");for(let t of n.actions)r.push(` ${t.message} [${t.pluginId}]`);r.push("")}if(n.suggestions.length>0){r.push("Suggested configuration");for(let t of n.suggestions){let o=t.evidence.length>0?` \u2014 ${t.evidence.join(", ")}`:"";r.push(` ${t.recipe.kind.padEnd(9)} ${t.recipe.id} [${t.pluginId}]${o}`)}r.push("")}return r.join(`
3
- `).trimEnd()}s(M,"formatDoctorReport");function oe(n){return n.actions.length>0||n.suggestions.length>0||n.sections.some(r=>r.findings.some(t=>t.status==="fail"))}s(oe,"doctorNeedsWork");function We(n){let r=n.candidates.map(t=>({owner:t.pluginId,id:t.recipe.id,kind:t.recipe.kind,languages:t.recipe.languages,evidence:t.evidence,documentation:t.recipe.documentation}));return["Finish configuring Pi Agent IDE for this project.","Preserve existing formatter, linter, compiler, and style rules. Do not invent or replace native project settings.","Do not install packages, write credentials, or change source files without the user's normal confirmation.","Pi Agent IDE project configs live in .pi/pi-agent-ide/.","Use only the relevant plugin contributions listed below; each owner remains responsible for its own scope.","",M(n),"","Relevant registered recipes:",JSON.stringify(r,null,2),"",`Project root: ${n.cwd.includes("://")?n.cwd:st.resolve(n.cwd)}`].join(`
4
- `)}s(We,"buildDoctorAgentPrompt");import{createHash as ct}from"node:crypto";var dt="doctor",ne=3;function Je(n,r){let t=ue(n,pt(r));t!==void 0&&t.catch(()=>{})}s(Je,"registerDoctorTipProvider");function pt(n){return{protocol:fe,apiVersion:ge,id:dt,async getTip(r){let t=await n(r),o=lt(t);if(o.length===0)return;let e=o.slice(0,ne).map(i=>`\u2022 ${i.message}`);return o.length>ne&&e.push(`\u2022 ${o.length-ne} more`),{id:`doctor-setup-${ut(o)}`,title:o.length===1?"Project setup needs attention":`${o.length} project setup items`,body:[...e,"Run /pi-agent-ide-doctor"].join(`
5
- `)}}}}s(pt,"createDoctorTipProvider");function lt(n){let r=n.actions.map(o=>({id:`action:${o.pluginId}:${o.id}`,message:o.message})),t=n.suggestions.map(o=>{let e=o.recipe.languages.filter(a=>n.detectedLanguages.has(a)).join(", "),i={debugger:"debugging",formatter:"formatting",linter:"linting",lsp:"language support"}[o.recipe.kind];return{id:`suggestion:${o.pluginId}:${o.recipe.kind}:${o.recipe.id}`,message:`Use ${o.recipe.name} for ${e} ${i}`}});return[...r,...t].sort((o,e)=>o.id.localeCompare(e.id))}s(lt,"setupItems");function ut(n){return ct("sha256").update(n.map(r=>`${r.id}\0${r.message}`).join("\0")).digest("hex").slice(0,12)}s(ut,"fingerprint");async function Ve(n,r){let t=new z;Je(n,async i=>(await t.waitForPlugins(),te(t.snapshot(),i.cwd,process.env,i.signal)));let o,e=n.events.on(we,i=>{if(!be(i))throw new Error("Invalid doctor plugin registration request");i.accept(t.registerPlugin(i.plugin))});n.on("session_shutdown",e),n.registerCommand("pi-agent-ide-doctor",{description:"Check and configure this project or an explicit ssh://target/path",handler:s(async(i,a)=>{let{cwd:u,flags:f}=je(i,a.cwd),h=await r?.(u);await t.waitForPlugins();let p=await Y(t.snapshot(),u,process.env,void 0,h);if(re(n,M(p)),p.suggestions.length>0&&!f.has("--no-apply")&&(f.has("--apply")||a.hasUI&&await a.ui.confirm("Apply suggested configuration?","Add detected tools to .pi/pi-agent-ide/. Existing entries and native tool settings are kept."))){let g=await Te(u,p.suggestions,h),y=g.length===0?"Pi Agent IDE configs are already up to date":`Updated ${g.length} Pi Agent IDE config ${g.length===1?"file":"files"}`;a.ui.notify(y,"info"),p=await Y(t.snapshot(),u,process.env,void 0,h),re(n,M(p))}if(!oe(p)&&!f.has("--agent"))return;(f.has("--agent")||a.hasUI&&await a.ui.confirm("Ask the agent to finish setup?","The agent will receive this redacted report and relevant plugin recipes."))&&(o={cwd:u,workspace:h},n.sendUserMessage(We(p)))},"handler")}),n.on("agent_end",async(i,a)=>{let u=o;if(u===void 0)return;o=void 0;let f=await Y(t.snapshot(),u.cwd,process.env,void 0,u.workspace);re(n,`Doctor recheck after agent setup
6
-
7
- ${M(f)}`),oe(f)?a.ui.notify("Pi Agent IDE setup still needs attention","warning"):a.ui.notify("Pi Agent IDE setup is ready","info")}),n.events.emit(ye,{protocol:he,apiVersion:me}),await t.waitForPlugins()}s(Ve,"registerDoctorWithOwner");function re(n,r){n.sendMessage({customType:"pi-agent-ide-doctor",content:r,display:!0},{triggerTurn:!1})}s(re,"sendReport");import{readFile as ze}from"node:fs/promises";import U from"node:path";import{Type as E}from"typebox";import{Value as ie}from"typebox/value";var ft=E.Object({directory:E.String(),device:E.String({pattern:"^[0-9]+$"}),inode:E.String({pattern:"^[0-9]+$"}),containerCreated:E.Boolean(),containerDevice:E.String({pattern:"^[0-9]+$"}),containerInode:E.String({pattern:"^[0-9]+$"})});async function Ye(n,r,t){t?.throwIfAborted();let o=n.resolve(r);if(!o)throw new D("UNSUPPORTED_SOURCE",r,"not-applied");let e=o.location,i=o.backend;if((await i.stat(e.path,{signal:t})).kind!=="directory")throw new D("NOT_DIRECTORY",e.source,"not-applied");let a=s(c=>{let d=n.resolve(c);if(!d||d.location.target!==e.target)throw new D("UNSUPPORTED_SOURCE",c,"not-applied");return d.location.path},"resolve"),u=await X({...i.target,workspace:e.path},"python3",["-c","import json,os,sys; keys=json.loads(sys.argv[1]); print(json.dumps({k:os.environ[k] for k in keys if k in os.environ}))",JSON.stringify(H)],e.source,{signal:t,timeoutMs:5e3,maxBytes:128*1024});if(u.exitCode!==0)throw new D("DEPENDENCY_UNAVAILABLE",e.source,"not-applied");let f=JSON.parse(u.stdout.toString("utf8")),h=E.Object(Object.fromEntries(H.map(c=>[c,E.Optional(E.String({maxLength:4096}))])),{additionalProperties:!1});if(!ie.Check(h,f))throw new D("INVALID_RESPONSE",e.source,"not-applied");let p=Ie(n),m=Ae(n),w=Ee(n,e.source),g=new Map,y=s(async(c,d,l)=>{let P=await ze(new URL(`./${c}`,new URL("../src/backend/doctor-workspace.ts",import.meta.url).href),{encoding:"utf8",signal:l}),S=await X(i.target,"python3",["-c",P,...d],e.source,{signal:l,timeoutMs:3e4,maxBytes:32*1024*1024});if(S.exitCode!==0)throw new D("DOCTOR_FAILED",e.source,"not-applied");return JSON.parse(S.stdout.toString("utf8"))},"executeWorker"),C=s(async(c,d,l)=>{l?.throwIfAborted();let P=await ze(new URL("./doctor-probe-worker.py",new URL("../src/backend/doctor-workspace.ts",import.meta.url).href),{encoding:"utf8",signal:l}),S=new AbortController,j=l?AbortSignal.any([l,S.signal]):S.signal,$=setTimeout(()=>S.abort(new D("TIMEOUT",e.source,"not-applied")),3e4),R,x=!1,T,k;try{R=await De(i.target,"python3",["-c",P,JSON.stringify({operation:"create",source:c})],i.target.workspace,{signal:j});let v=0,B=s(A=>(v+=A.length,v<=128*1024?!0:(S.abort(new D("BYTE_LIMIT",e.source,"not-applied")),!1)),"consume");R.stderr.on("data",A=>{B(A)});let G=R,W=new Promise((A,Ge)=>{let F=Buffer.alloc(0),se=!1;G.stdout.on("data",ae=>{if(!B(ae)||se)return;F=Buffer.concat([F,ae]);let ce=F.indexOf(`
8
- `);if(!(ce<0)){se=!0;try{A(JSON.parse(F.subarray(0,ce).toString("utf8")))}catch(He){Ge(He)}F=Buffer.alloc(0)}})}),J=await Promise.race([W,R.completion.then(()=>{throw new D("PROBE_FAILED",e.source,"not-applied")})]);if(l?.throwIfAborted(),!ie.Check(ft,J))throw new D("PROBE_FAILED",e.source,"not-applied");if(k=J,await R.write(Buffer.from(`retain
9
- `)),await R.end(),(await R.completion).exitCode!==0)throw new D("PROBE_FAILED",e.source,"not-applied")}catch(v){x=!0,T=l?.aborted?l.reason:S.signal.aborted?S.signal.reason:v}finally{clearTimeout($)}try{let v=await R?.stop();if(v?.exitCode===0&&k&&d(k),v?.exitCode===2)throw new D("PROBE_CLEANUP_FAILED",e.source,"unknown")}catch(v){throw new AggregateError(x?[T,v]:[v],"Doctor allocation cleanup failed",{cause:v})}if(x)throw T},"allocateProbe"),I=new Map,b=s(async c=>{for(;;){let d=I.get(c);if(d?.cleanup){await d.cleanup;continue}let l=d??{users:0};return l.users++,I.set(c,l),l}},"acquireContainer"),O=s(async(c,d)=>{d.users--,d.users===0&&(d.cleanup=Promise.resolve().then(async()=>{if(d.created&&await y("doctor-probe-worker.py",[JSON.stringify({operation:"remove-container",...d.created})])!==null)throw new D("PROBE_CLEANUP_FAILED",e.source,"unknown")}).finally(()=>{I.get(c)===d&&I.delete(c)}),await d.cleanup)},"releaseContainer");return{source:e.source,platform:"linux",toolPaths:f,probeCapture:s(c=>xe({...i.target,workspace:e.path},e.source,c),"probeCapture"),async probeBrowser(c){return await ke({...i.target,workspace:e.path},e.source,c),{ok:!0,detail:"Target Playwright and Chromium started without navigation"}},async files(c){let d=await y("doctor-inventory-worker.py",[e.path],c);if(!ie.Check(E.Array(E.String()),d))throw new D(typeof d=="object"&&d!==null&&"error"in d&&d.error==="BYTE_LIMIT"?"BYTE_LIMIT":"INVENTORY_FAILED",e.source,"not-applied");return d.map(l=>{let P=U.posix.resolve(e.path,l);if(U.posix.isAbsolute(l)||!(P.startsWith(`${e.path}/`)||e.path==="/"))throw new D("INVALID_RESPONSE",e.source,"not-applied");return K(e.target,P).source})},async readText(c,d){try{let l=await i.read(a(c),{signal:d}),P=l.bytes.toString("utf8");return g.set(c,{content:P,version:l.version}),P}catch(l){if(l instanceof D&&l.code==="ENOENT")return;throw l}},async writeText(c,d,l,P){let S=g.get(c);if(l!==void 0&&(!S||S.content!==l))throw new D("CONFLICT",c,"not-applied");await i.write(a(c),Buffer.from(d),l===void 0?null:S?.version??null,{signal:P})},configPaths:s((c,d)=>p.paths(e.source,c,d),"configPaths"),async exists(c,d){try{return await i.stat(a(c),{signal:d}),!0}catch(l){if(l instanceof D&&l.code==="ENOENT")return!1;throw l}},evidence:s((c,d)=>Re(i,e.path,c,d),"evidence"),executableAvailability:s((c,d)=>Ce(i,e.path,c,d),"executableAvailability"),run:s((c,d,l)=>m.run(c,{projectRoot:e.source,filePath:d,signal:l}),"run"),async withProbeCopy(c,d,l){l?.throwIfAborted();let P=a(c),S=U.posix.join(U.posix.dirname(P),".tmp"),j=await b(S),$,R=U.posix.basename(P),x=[],T;try{let v=j.allocation,B={};j.allocation=new Promise(A=>{B.resolve=A});let G=N(B.resolve);try{await v,l?.throwIfAborted(),await C(P,A=>{$=A,A.containerCreated&&(j.created={container:S,device:A.containerDevice,inode:A.containerInode})},l)}finally{G()}let W=U.posix.join(N($).directory,R),J=await i.lstat(P,{signal:l});await i.copy(P,W,J.revision,null,{signal:l}),l?.throwIfAborted(),x.push({value:await d(K(e.target,W).source)})}catch(v){T=v}let k=[];if($)try{if(await y("doctor-probe-worker.py",[JSON.stringify({operation:"remove",...$,name:R})])!==null)throw new D("PROBE_CLEANUP_FAILED",c,"unknown")}catch(v){k.push(v)}try{await O(S,j)}catch(v){k.push(v)}if(k.length>0)throw new AggregateError(x.length===0?[T,...k]:k,"Doctor probe cleanup failed",{cause:k[0]});if(x.length===0)throw T;return N(x[0]).value},start:s((c,d,l)=>w.start({rootUri:e.source,command:c,env:d,signal:l}),"start"),toNativeUri:s(c=>w.toServerUri(c),"toNativeUri"),fromNativeUri:s(c=>w.fromServerUri(c),"fromNativeUri")}}s(Ye,"createSshDoctorWorkspace");async function gt(n){let r=new Oe(await Se(Pe(ve())));await Ve(n,t=>t.startsWith("ssh://")?Ye(r,t):Promise.resolve(void 0))}s(gt,"registerOwnedDoctor");export{gt as default};
@@ -1 +0,0 @@
1
- import{H as d,f as c}from"./chunk-LCWBVOII.js";import{a as s}from"./chunk-EI7MMDWY.js";import{Type as t}from"typebox";var b=t.Object({query:t.String({minLength:1,description:"Text to find or a Boolean expression. Quote text to keep it literal. Use regex:<pattern> for regular expressions, files:<pattern> for file paths, ast:<pattern> for syntax patterns, symbols:<query> for language symbols, or process:<query> for running processes."}),path:t.Optional(t.Union(d.anyOf,{description:"File, directory, URL, docs:all for all packaged guide bodies, docs:<id> for one guide, unchanged Read/Search/Select/edit result, its UUID, or an array of such results. Use literal text or regex: for docs: sources. 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 or SSH files"})),exclude:t.Optional(t.String({description:"Optional exclude glob for local or SSH files"})),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 displayed items, including compact file summaries (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()))},O=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}),h=e.Union([e.Object({...g,fuzzy:e.Optional(O)},{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(h);function T(o,l,n,i){return{kind:"matches",...i?.target===void 0?{}:{target:i.target},truncated:o.length>100,complete:l,matches:o.slice(0,100).map((r,a)=>({source:r.source,...i?.matchTargets?.[a]===void 0?{}:{target:i.matchTargets[a]},range:{startLine:r.lineNumber,startColumn:r.startColumn,endLine:r.endLineNumber??r.lineNumber,endColumn:r.endColumn},...Buffer.byteLength(r.matchedText)<=4096?{matchedText:r.matchedText}:{textTruncated:!0},...n===void 0?{}:{references:{line:`SEARCH#${n}:${a+1}:line`,match:`SEARCH#${n}:${a+1}:match`}}})),...l&&n!==void 0?{all:{line:`SEARCH#${n}:all:line`,match:`SEARCH#${n}:all:match`}}:{}}}s(T,"selectionData");export{b as a,O as b,h as c,P as d,T as e};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-VMTOFEXF.js";import"./chunk-CPELC6JE.js";import"./chunk-PJL3UVMJ.js";import"./chunk-LCWBVOII.js";import"./chunk-EI7MMDWY.js";export{a as runOwnedSshCommand};
@@ -1,3 +0,0 @@
1
- import{a as i}from"./chunk-EI7MMDWY.js";import{AsyncLocalStorage as be}from"node:async_hooks";function ie(){return{pending:new Set,active:new be}}i(ie,"createSchedulerState");function Ee(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(Ee,"conflicts");function xe(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(xe,"coveredAccess");async function Ae(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(Ae,"waitForDependencies");var $=class r{constructor(e=ie()){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(S=>{if(n?.throwIfAborted(),!xe(a.accesses,S,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 S});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],c=s.catch(()=>{}),p,l=new Promise(m=>{p=m}),h={accesses:c,done:l};return this.state.pending.add(h),(async()=>{try{n?.throwIfAborted();let m=await Ae(s.then(async S=>(await Promise.all(d.map(z=>Promise.race([z.done,z.accesses.then(Se=>Ee(S,Se)?z.done:void 0)]))),S)),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()}})()}},Oe=Symbol.for("pi-agent-resource.resource-scheduler-state"),ke=globalThis,Ne=ke[Oe]??=ie(),Pe=new $(Ne);import{realpath as je,stat as Ie}from"node:fs/promises";import P from"node:path";import{fileURLToPath as _e}from"node:url";async function ae(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=P.resolve(e,r.startsWith("file:")?_e(r):r),[o,s]=await Promise.allSettled([je(n),Ie(n,{bigint:!0})]),a;if(o.status==="fulfilled")a=o.value;else{let l=o.reason;if(!(l instanceof Error)||!("code"in l)||l.code!=="ENOENT")throw l;let h=P.dirname(n);if(h===n)a=n;else{let y=(await ae(h,e,t)).find(S=>S.resource.startsWith("file:"));a=P.join(y?.resource.slice(5)??h,P.basename(n))}}let d=a.split(P.sep).join("/"),c=`file:${process.platform==="win32"?d.toLowerCase():d}`,p=[{resource:c,group:c,mode:t}];if(s.status==="fulfilled"){let l=s.value;l.isDirectory()&&(p[0]={resource:c,group:c,mode:t,recursive:!0}),l.ino!==0n&&p.push({resource:`inode:${l.dev}:${l.ino}`,group:c,mode:t,recursive:l.isDirectory()})}else{let l=s.reason;if(!(l instanceof Error)||!("code"in l)||l.code!=="ENOENT")throw l}return p}i(ae,"resourceAccesses");import{randomUUID as $e}from"node:crypto";import{mkdir as Ue,mkdtemp as Le,readFile as De,rm as He,writeFile as We}from"node:fs/promises";import{tmpdir as Ve}from"node:os";import ce from"node:path";var K=class{static{i(this,"TempResourceStore")}resolver;#e=new Map;#n=new Set;#o;#t;#r;constructor(e={}){this.#o=e.parentDirectory??Ve(),this.resolver={id:"temp",tryResolve:i(t=>Promise.resolve(this.#c(t)),"tryResolve")}}save(e){return this.#s(e,!1)}saveFile(e){return this.#s(e,!0)}async#s(e,t){if(this.#r!==void 0)throw new Error("Temporary resource store is closed");let n=this.#i(e,t);this.#n.add(n);try{return await n}finally{this.#n.delete(n)}}dispose(){return this.#r??=this.#a(),this.#r}async#i(e,t){let n=await this.#d(),o=$e(),s=`temp:${o}`,a=ce.join(n,`${o}.txt`);return await We(a,e,{encoding:"utf8",flag:"wx",mode:384}),t||this.#e.set(s,a),t?a:s}async#a(){await Promise.allSettled(this.#n),this.#e.clear(),this.#t!==void 0&&await He(await this.#t,{recursive:!0,force:!0})}#c(e){return e.startsWith("temp:")?this.#r!==void 0||!this.#e.has(e)?{kind:"failed",error:new Error(`Temporary resource ${e} does not exist in this runtime`)}:{kind:"resolved",resource:{source:e,read:i(()=>this.#u(e),"read")}}:{kind:"not-handled"}}async#u(e){let t=this.#e.get(e);if(this.#r!==void 0||t===void 0)throw new Error(`Temporary resource ${e} does not exist in this runtime`);return[{type:"text",text:await De(t,"utf8")}]}async#d(){return this.#t??=(async()=>(await Ue(this.#o,{recursive:!0}),Le(ce.join(this.#o,"pi-agent-read-"))))(),this.#t}};import{Type as g}from"typebox";import{Value as Me}from"typebox/value";var U=g.Object({code:g.String(),message:g.String(),source:g.Optional(g.String())},{additionalProperties:!1});function ue(r){return{...g.Union([g.Object({status:g.Literal("success"),data:r,errors:g.Array(U,{maxItems:0})},{additionalProperties:!1}),g.Object({status:g.Union([g.Literal("error"),g.Literal("partial")]),data:g.Optional(r),errors:g.Array(U,{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(U)},required:["status","errors"],additionalProperties:!1}}i(ue,"structuredResultSchema");var de=1024*1024;function q(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))>de)throw new RangeError("Structured data exceeds 1 MiB; return a smaller window or a full-result reference")}i(q,"assertJsonData");function le(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(le,"resultError");function Be(r,e,t){try{if(q(t),!Me.Check(ue(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=le(n,"INVALID_STRUCTURED_RESULT"),s={status:"error",errors:[o]};return q(s),{...r,content:[...r.content,{type:"text",text:o.message}],structuredContent:s,isError:!0}}}i(Be,"withStructuredResult");var fe=Symbol.for("pi-agent-resource.ResourceError"),J=class extends Error{constructor(t,n,o,s){if(!/^[A-Z][A-Z0-9_]*$/u.test(t))throw new TypeError("Invalid resource failure code");super(`${t}: ${n}`,s);this.code=t;this.source=n;this.effect=o;this.name="ResourceError"}static{i(this,"ResourceError")}[fe]=!0;static[Symbol.hasInstance](t){return typeof t=="object"&&t!==null&&t[fe]===!0}};function Fe(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(Fe,"renderContentDescription");import{Type as f}from"typebox";import{Value as et}from"typebox/value";import{Type as u}from"typebox";import{Value as ze}from"typebox/value";var C={additionalProperties:!0},j=u.Function([],u.Unknown()),v=u.String({minLength:1}),Ke=u.Object({type:u.Literal("text"),text:u.String(),textSignature:u.Optional(u.String())},C),qe=u.Object({type:u.Literal("image"),data:u.String(),mimeType:u.String()},C),Je=u.Object({type:u.Literal("custom"),kind:v,data:u.Unknown()},C),Ye=u.Array(u.Union([Ke,qe,Je]),{minItems:1}),pe=u.Union([u.Object({source:v,link:u.Optional(v),read:j,write:u.Optional(u.Never())},C),u.Object({source:v,link:u.Optional(v),read:u.Optional(u.Never()),write:j},C),u.Object({source:v,link:u.Optional(v),read:j,write:j},C)]),Ge=u.Object({id:v,tryResolve:j},C),Xe=u.Union([u.Object({kind:u.Literal("not-handled")},C),u.Object({kind:u.Literal("resolved"),resource:pe},C),u.Object({kind:u.Literal("failed"),error:u.Unknown()},C)]);function Y(r){return L(Ye,r)?D(()=>r.every(e=>e.type!=="text"||!("textSignature"in e)||typeof e.textSignature=="string")):!1}i(Y,"isAgentContent");function ge(r){return L(pe,r)?D(()=>{let e=r,t=!("read"in e)||typeof e.read=="function",n=!("write"in e)||typeof e.write=="function",o=!("readBytes"in e)||typeof e.readBytes=="function";return t&&n&&o}):!1}i(ge,"isResource");function Ze(r){return L(Ge,r)}i(Ze,"isResourceResolver");function Qe(r){return L(Xe,r)?D(()=>{let e=r;return e.kind!=="resolved"||ge(e.resource)}):!1}i(Qe,"isResourceResolutionAttempt");function L(r,e){return D(()=>ze.Check(r,e))}i(L,"safeCheck");function D(r){try{return r()}catch{return!1}}i(D,"safeEvaluate");var R={additionalProperties:!0},tt=f.Function([],f.Unknown()),H=f.String({minLength:1}),rt=f.Object({provider:H,capability:f.Union([f.Literal("read"),f.Literal("write")])},R),nt=f.Object({source:H,bytes:f.Unknown(),mediaType:f.Optional(f.String())},R),ot=f.Object({signal:f.Optional(f.Unknown())},R),st=f.Object({id:H,description:H,tryConvert:tt},R),it=f.Union([f.Object({kind:f.Literal("not-handled")},R),f.Object({kind:f.Literal("converted"),content:f.Unknown()},R),f.Object({kind:f.Literal("failed"),error:f.Unknown()},R)]),at=f.Object({target:f.Unknown(),converter:f.Unknown(),priority:f.Optional(f.Number())},R);function O(r){return k(rt,r)&&E(()=>r.provider.trim().length>0)}i(O,"isContentTarget");function G(r){return k(nt,r)?E(()=>{let e=r;return e.bytes instanceof Uint8Array&&(!("mediaType"in e)||typeof e.mediaType=="string")}):!1}i(G,"isContentInput");function X(r){return k(ot,r)?E(()=>{let e=r;return!("signal"in e)||e.signal instanceof AbortSignal}):!1}i(X,"isContentConversionContext");function he(r){return k(st,r)?E(()=>{let e=r;return e.id.trim().length>0&&e.description.trim().length>0&&!/[\r\n]/u.test(e.description)}):!1}i(he,"isContentConverter");function Z(r){return k(it,r)?E(()=>{let e=r;return e.kind!=="converted"||Y(e.content)}):!1}i(Z,"isContentConversionAttempt");function b(r){return k(at,r)?E(()=>{let e=r;return O(e.target)&&he(e.converter)&&(!("priority"in e)||typeof e.priority=="number"&&Number.isFinite(e.priority))}):!1}i(b,"isContentConverterRegistration");function k(r,e){return E(()=>et.Check(r,e))}i(k,"safeCheck");function E(r){try{return r()}catch{return!1}}i(E,"safeEvaluate");var W=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 ee(r){if(!O(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(!b(o))throw new TypeError("Invalid content converter registration");if(!x(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(!G(o))throw new TypeError("Invalid content input");if(!X(s))throw new TypeError("Invalid content conversion context");Q(s.signal);let a=n();for(let{converter:d}of a){Q(s.signal);let c=await d.tryConvert(o,s);if(Q(s.signal),!Z(c))throw new TypeError(`Content converter ${d.id} returned an invalid outcome`);if(c.kind!=="not-handled"){if(c.kind==="failed")throw c.error;return c.content}}throw new W(o.source,e)}}}i(ee,"createContentRunner");function x(r,e){return r.provider===e.provider&&r.capability===e.capability}i(x,"targetsEqual");function Q(r){r?.throwIfAborted()}i(Q,"throwIfAborted");import{Type as w}from"typebox";import{Value as ct}from"typebox/value";var N="pi-agent-resource/content-conversion",V=2,I=`${N}/host/ready`,_=`${N}/converter/register`,me={additionalProperties:!0},ut=w.Function([],w.Unknown()),dt=w.Object({protocol:w.Literal(N),apiVersion:w.Literal(V),target:w.Unknown()},me),lt=w.Object({registration:w.Unknown(),accept:ut},me);function te(r){return ye(dt,r)&&ne(()=>O(r.target))}i(te,"isContentHostReady");function re(r){return ye(lt,r)&&ne(()=>b(r.registration))}i(re,"isContentConverterRegistrationRequest");function ye(r,e){return ne(()=>ct.Check(r,e))}i(ye,"safeCheck");function ne(r){try{return r()}catch{return!1}}i(ne,"safeEvaluate");var Ce="pi-agent-resource:content-host-lookup";function ft(r,e){let t;if(r.events.emit(Ce,{target:e,accept(c){if(t)throw new Error("Multiple content hosts registered for one target");t=c}}),t)return ve(r,t),t.host;let n=ee(e),o=r.events.on(_,c=>{if(!re(c))throw new Error("Invalid content converter registration request");if(!x(n.target,c.registration.target))return;let p;try{n.register(c.registration),p=Promise.resolve()}catch(l){p=Promise.reject(l instanceof Error?l:new Error("Content converter registration failed",{cause:l}))}c.accept(p)}),s={target:n.target,listDescriptions(){return n.listDescriptions()},convert(c,p){return n.convert(c,p)}},a=r.events.on(Ce,c=>{if(!pt(c))throw new Error("Invalid content host lookup request");x(e,c.target)&&c.accept(d)}),d={host:s,owners:new Set,unsubscribe(){o(),a()}};return ve(r,d),r.events.emit(I,{protocol:N,apiVersion:V,target:n.target}),s}i(ft,"createContentHost");function pt(r){return typeof r=="object"&&r!==null&&"target"in r&&typeof r.target=="object"&&r.target!==null&&"provider"in r.target&&typeof r.target.provider=="string"&&"capability"in r.target&&typeof r.target.capability=="string"&&"accept"in r&&typeof r.accept=="function"}i(pt,"isHostLookup");function ve(r,e){e.owners.has(r)||(e.owners.add(r),r.on("session_shutdown",()=>{e.owners.delete(r),e.owners.size===0&&e.unsubscribe()}))}i(ve,"retainOwner");function gt(r,e){if(!b(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(!te(s))throw new Error("Invalid content conversion host readiness event");if(!x(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(gt,"connectContentConverter");import{createHash as Re,randomUUID as oe}from"node:crypto";import{statSync as ht}from"node:fs";import{readFile as mt}from"node:fs/promises";import T from"node:path";import{fileURLToPath as yt}from"node:url";import{Type as M}from"typebox";var Ct=M.Union([M.String(),M.Array(M.String())]),A="RESULT#",we="pi-agent-resource:result-targets",F=class{static{i(this,"ResultTargetStore")}#e=new Map;#n=new Map;#o=new Map;#t=new Map;clear(){this.#e.clear(),this.#n.clear(),this.#o.clear(),this.#t.clear()}register(e,t,n=!0){for(let s of e)this.refresh(s.source,t);let o=`${A}${oe()}`;return this.#e.set(o,{state:"ready",targets:se(e),complete:n,cwd:T.resolve(t)}),o}reserve(e){let t=`${A}${oe()}`;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:se(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 c of d.targets)this.refresh(c.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:se(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 c of d.ranges){let p=JSON.stringify([d.source,c]);s.has(p)||(s.add(p),o.push({...d,ranges:[c]}))}return{targets:o,complete:n.complete}}async verify(e,t){try{await Te(e,t)}catch(n){if(!t?.aborted)for(let o of e.targets)this.invalidate(o.source);throw n}}registerSearchReference(e,t,n){if(!/^SEARCH#[A-F\d]{4,64}:[1-9]\d*:(line|match)$/u.test(e))throw new Error("Only numbered Search references can alias a snapshot.");if(!this.#e.has(t))throw new Error("A Search reference needs a registered result target.");this.resolve(t,n),this.#n.set(e,t)}publish(e,t,n,o=[]){let s=oe();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}`,c=e!==null&&typeof e=="object"&&"status"in e&&e.status==="success";if(c&&"data"in e){let p=e.data;if(p!==null&&typeof p=="object"&&"matches"in p&&Array.isArray(p.matches)){let l=p.matches;for(let h of l){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.#n.set(m.match,h.target)}}}return this.#t.set(s,{cwd:T.resolve(n),digest:Re("sha256").update(d).digest("hex"),consumable:c,references:a,resources:o}),d}source(e,t,n=!1){if(Array.isArray(e))return e.map(l=>this.source(l,t,n));if(typeof e!="string")return e;let o=this.#n.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(A)?e.slice(A.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 c=this.#t.get(a);if(!c&&!s&&e.startsWith(A)&&this.#e.has(e))return e;if(!c)throw new Error("Result reference expired or unknown. Run Read/Search again and use the new result.");if(c.cwd!==T.resolve(t))throw new Error("Result belongs to another worktree.");if(s&&Re("sha256").update(e).digest("hex")!==c.digest)throw new Error("Result text changed; pass the original result or its UUID.");for(let l of c.resources)this.refresh(l,t);if(!this.#t.has(a))throw new Error("Result reference expired. Run Read/Search again and use the new result.");if(!c.consumable)throw new Error("Only successful source results can be consumed.");for(let l of c.references)if(!this.#e.has(l))throw this.#t.delete(a),new Error("Result reference expired. Run Read/Search again and use the new result.");if(c.references.length===1)return c.references[0];if(c.references.length>1)return c.references;let p=c.resources.length===1?c.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=>B(s.source,o.cwd)===e)&&(this.#e.delete(n),t.add(n));for(let[n,o]of this.#t)(o.resources.some(s=>B(s,o.cwd)===e)||o.references.some(s=>t.has(s)))&&this.#t.delete(n)}refresh(e,t){let n=B(e,t),o=JSON.stringify([T.resolve(t),n]),s=vt(e,t),a=this.#o.get(o);a&&a.stamp!==s&&this.invalidate(n),this.#o.set(o,{source:e,cwd:t,stamp:s})}refreshAll(){for(let e of[...this.#o.values()])this.refresh(e.source,e.cwd)}#r(e){if(typeof e=="string"&&e.startsWith(A))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(A))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 B(r,e){let t=r.startsWith("raw:")?r.slice(4):r;if(/^[a-z][a-z0-9+.-]*:\/\//iu.test(t)&&!t.startsWith("file:"))return t;if(t.startsWith("file:"))try{return yt(t)}catch{}return T.resolve(e,t)}i(B,"sourcePath");function vt(r,e){try{let t=ht(B(r,e),{bigint:!0});return`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch{return}}i(vt,"fileStamp");async function Te(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=n.readCurrent===void 0?await mt(n.source,{encoding:"utf8",signal:e}):await n.readCurrent(e),e?.throwIfAborted(),t.set(n.source,o)),o!==n.expectedContent)throw new Error("Result target is stale; repeat Read/Search.")}}i(Te,"verifyResultTargets");function se(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,...t.readCurrent===void 0?{}:{readCurrent:t.readCurrent},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(se,"combineTargets");function Rt(r){let e;if(r.events.emit(we,{accept:i(o=>{e=o},"accept")}),e!==void 0)return e;let t=new F,n=r.events.on(we,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(Rt,"connectResultTargets");export{$ as a,Pe as b,ae as c,K as d,U as e,ue as f,de as g,q as h,le as i,Be as j,J as k,Fe as l,Y as m,ge as n,Ze as o,Qe as p,O as q,G as r,X as s,he as t,Z as u,b as v,W as w,ee as x,x as y,N as z,V as A,I as B,_ as C,te as D,re as E,ft as F,gt as G,Ct as H,F as I,Te as J,Rt as K};
@@ -1,4 +0,0 @@
1
- import{a as v,b as O,c as _,d as z}from"./chunk-TOYN4W4F.js";import{a as F}from"./chunk-YJ6T3PEP.js";import{b as T,c as N}from"./chunk-S72FVLUX.js";import{a as M}from"./chunk-K5G4FDXD.js";import{a as j}from"./chunk-ZAWRSA7N.js";import{a as R,b}from"./chunk-OFILFO6D.js";import{b as P,c as E,g as D,i as S,k as I,l as $,o as A}from"./chunk-IMGIDBCC.js";import{a as u}from"./chunk-ZC65Z3CK.js";import{a as l}from"./chunk-EI7MMDWY.js";import le from"node:path";var p=[c("dart-analyze",["dart"],["dart"],["analysis_options.yaml","pubspec.yaml"],[".dart"],["dart","analyze","--format","machine","{file}"],"regex","https://dart.dev/tools/dart-analyze","^(?<severity>[^|]+)\\|[^|]+\\|(?<code>[^|]+)\\|(?<file>[^|]+)\\|(?<line>\\d+)\\|(?<column>\\d+)\\|\\d+\\|(?<message>.*)$",void 0,[0,1,2,3]),c("zig-ast-check",["zig"],["zig"],["build.zig","build.zig.zon","zls.json"],[".zig",".zon"],["zig","ast-check","{file}"],"gcc","https://ziglang.org/documentation/master/"),c("lintr",["r"],["Rscript"],[".lintr","DESCRIPTION"],[".r"],["Rscript","-e","print(lintr::lint(commandArgs(TRUE)[1]))","{file}"],"regex","https://lintr.r-lib.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[^:]+): \\[(?<code>[^\\]]+)\\] (?<message>.*)$"),c("clang-tidy",["c","cpp"],["clang-tidy"],[".clang-tidy","compile_commands.json"],[".c",".h",".cc",".cpp",".cxx",".hh",".hpp",".hxx"],["clang-tidy","{file}"],"clang","https://clang.llvm.org/extra/clang-tidy/"),c("eslint",["javascript","typescript","vue","svelte"],["eslint"],["eslint.config.js","eslint.config.mjs","eslint.config.cjs","eslint.config.ts","eslint.config.mts","eslint.config.cts",".eslintrc",".eslintrc.json",".eslintrc.js",".eslintrc.cjs",".eslintrc.yaml",".eslintrc.yml"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts",".vue",".svelte"],["eslint","--format","json","{file}"],"eslint-json","https://eslint.org/docs/latest/",void 0,["eslint"]),c("oxlint",["javascript","typescript"],["oxlint"],[".oxlintrc.json",".oxlintrc.jsonc","oxlint.config.ts","oxlint.config.mts"],[".js",".jsx",".mjs",".cjs",".ts",".tsx",".mts",".cts"],["oxlint","--format","sarif","{file}"],"sarif","https://oxc.rs/docs/guide/usage/linter.html",void 0,["oxlint"]),c("ruff",["python"],["ruff"],["pyproject.toml","ruff.toml",".ruff.toml"],[".py",".pyi"],["ruff","check","--output-format","concise","{file}"],"regex","https://docs.astral.sh/ruff/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<code>\\S+) (?<message>.+)$",["ruff"]),c("golangci-lint",["go"],["golangci-lint"],[".golangci.yml",".golangci.yaml","go.mod"],[".go"],["golangci-lint","run","--output.text.path=","--output.checkstyle.path=stdout","--show-stats=false","./..."],"checkstyle","https://golangci-lint.run/"),c("clippy",["rust"],["cargo"],["Cargo.toml","clippy.toml"],[".rs"],["cargo","clippy","--message-format","short"],"gcc","https://doc.rust-lang.org/clippy/"),c("dotnet-format",["csharp"],["dotnet"],[".editorconfig","global.json"],[".cs"],["dotnet","format","--verify-no-changes","--include","{relativeFile}"],"regex","https://learn.microsoft.com/dotnet/core/tools/dotnet-format","^(?<file>.+)\\((?<line>\\d+),(?<column>\\d+)\\): (?<severity>error|warning) (?<code>[^:]+): (?<message>.*?)(?: \\[.*\\])?$",void 0,[0,2]),c("checkstyle",["java"],["checkstyle"],["checkstyle.xml","pom.xml"],[".java"],["checkstyle","-c","checkstyle.xml","-f","xml","{file}"],"checkstyle","https://checkstyle.org/"),c("detekt",["kotlin"],["detekt"],["detekt.yml","build.gradle.kts"],[".kt",".kts"],["detekt","--input","{file}","--config","detekt.yml"],"regex","https://detekt.dev/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<message>.*?) \\[(?<code>[^\\]]+)\\]$",void 0,[0,2]),c("rubocop",["ruby"],["rubocop"],[".rubocop.yml","Gemfile"],[".rb",".rake"],["rubocop","--format","clang","{file}"],"regex","https://docs.rubocop.org/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?:\\[Correctable\\] )?(?<code>[^:]+): (?<message>.*)$"),c("phpcs",["php"],["phpcs"],["phpcs.xml","phpcs.xml.dist","composer.json"],[".php"],["phpcs","--report=checkstyle","{file}"],"checkstyle","https://github.com/PHPCSStandards/PHP_CodeSniffer",void 0,void 0,[0,1,2,3]),c("swiftlint",["swift"],["swiftlint"],[".swiftlint.yml","Package.swift"],[".swift"],["swiftlint","lint","--quiet","--reporter","checkstyle","{file}"],"checkstyle","https://github.com/realm/SwiftLint",void 0,void 0,[0,2]),c("scalafix",["scala"],["scalafix"],[".scalafix.conf"],[".scala",".sc"],["scalafix","--check","--files","{file}"],"gcc","https://scalacenter.github.io/scalafix/",void 0,void 0,[0,2,64,66]),c("credo",["elixir"],["mix"],["mix.exs",".credo.exs"],[".ex",".exs"],["mix","credo","--strict","--format","flycheck","--files-included","{file}"],"regex","https://hexdocs.pm/credo/","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>[A-Z]): (?<message>.+)$",void 0,Array.from({length:32},(t,e)=>e)),c("psscriptanalyzer",["powershell"],["pwsh"],["PSScriptAnalyzerSettings.psd1"],[".ps1",".psm1",".psd1"],["pwsh","-NoProfile","-NonInteractive","-CommandWithArgs",'$ErrorActionPreference="Stop";$options=@{};if(Test-Path -LiteralPath PSScriptAnalyzerSettings.psd1){$options.Settings="PSScriptAnalyzerSettings.psd1"};Invoke-ScriptAnalyzer -Path $args[0] @options | ForEach-Object {"$($_.ScriptPath):$($_.Line):$($_.Column): $($_.Severity): $($_.Message) [$($_.RuleName)]"}',"{file}"],"regex","https://learn.microsoft.com/powershell/module/psscriptanalyzer/invoke-scriptanalyzer","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): (?<severity>\\w+): (?<message>.+) \\[(?<code>[^\\]]+)\\]$",void 0,[0]),c("luacheck",["lua"],["luacheck"],[".luacheckrc"],[".lua"],["luacheck","--formatter","plain","--codes","--no-color","{file}"],"regex","https://github.com/lunarmodules/luacheck","^(?<file>.+):(?<line>\\d+):(?<column>\\d+): \\((?<code>(?<severity>[WE])\\d+)\\) (?<message>.+)$",void 0,[0,1,2]),c("shellcheck",["shell"],["shellcheck"],[".shellcheckrc"],[".sh",".bash",".zsh"],["shellcheck","-f","gcc","{file}"],"gcc","https://www.shellcheck.net/"),c("stylelint",["css"],["stylelint"],["stylelint.config.js",".stylelintrc.json"],[".css",".scss",".sass",".less"],["stylelint","--formatter","compact","{file}"],"regex","https://stylelint.io/","^(?<file>.+): line (?<line>\\d+), col (?<column>\\d+), (?<severity>error|warning) - (?<message>.+) \\((?<code>[^)]+)\\)$",["stylelint"],[0,2]),c("yamllint",["yaml"],["yamllint"],[".yamllint",".yamllint.yml"],[".yaml",".yml"],["yamllint","-f","parsable","{file}"],"regex","https://yamllint.readthedocs.io/","^(?<file>.+?):(?<line>\\d+):(?<column>\\d+): \\[(?<severity>[^\\]]+)\\] (?<message>.*?) \\((?<code>[^)]+)\\)$"),c("markdownlint",["markdown"],["markdownlint"],[".markdownlint.json",".markdownlint.yaml"],[".md",".mdx"],["markdownlint","{file}"],"regex","https://github.com/DavidAnson/markdownlint","^(?<file>.+?):(?<line>\\d+)(?::(?<column>\\d+))? (?<severity>error|warning) (?<code>MD\\d+)(?:/\\S+)? (?<message>.*)$"),c("sqlfluff",["sql"],["sqlfluff"],[".sqlfluff","pyproject.toml"],[".sql"],["sqlfluff","lint","--format","sarif","{file}"],"sarif","https://docs.sqlfluff.com/"),c("hadolint",["dockerfile"],["hadolint"],[".hadolint.yaml"],[".dockerfile"],["hadolint","--format","checkstyle","{file}"],"checkstyle","https://github.com/hadolint/hadolint",void 0,void 0,[0,1],void 0,["Dockerfile","Containerfile"]),c("tflint",["terraform"],["tflint"],[".tflint.hcl"],[".tf"],["tflint","--format","checkstyle"],"checkstyle","https://github.com/terraform-linters/tflint",void 0,void 0,[0,2]),c("cmake-lint",["cmake"],["cmake-lint"],[".cmake-format.py","CMakeLists.txt"],[".cmake"],["cmake-lint","{file}"],"regex","https://cmake-format.readthedocs.io/","^(?<file>.+?):(?<line>\\d+),(?<column>\\d+): \\[(?<code>(?<severity>[A-Z])\\d+)\\] (?<message>.*)$",void 0,[0,1],0,["CMakeLists.txt"]),c("htmlhint",["html"],["htmlhint"],[".htmlhintrc"],[".html",".htm"],["htmlhint","--format","checkstyle","--nocolor","{file}"],"checkstyle","https://htmlhint.com/"),c("jsonlint",["json"],["jsonlint"],[".jsonlintrc",".jsonlintrc.json",".jsonlintrc.yaml",".jsonlintrc.yml",".jsonlintrc.js",".jsonlintrc.cjs","jsonlint.config.js","jsonlint.config.cjs"],[".json"],["jsonlint","-q","{file}"],"regex","https://github.com/prantlf/jsonlint","^(?:Error: )?(?<message>Parse (?<severity>error) on line (?<line>\\d+)(?:, column (?<column>\\d+))?:[^\\n]*)$",["@prantlf/jsonlint","jsonlint"]),c("taplo-check",["toml"],["taplo"],["taplo.toml"],[".toml"],["taplo","check","--colors","never","{file}"],"regex","https://taplo.tamasfe.dev/","^(?<severity>error): (?<message>[^\\n]+)\\n\\s*\u250C\u2500 (?<file>.+):(?<line>\\d+):(?<column>\\d+)"),c("xmllint",["xml"],["xmllint"],[".xmllintrc"],[".xml",".xsd",".xsl"],["xmllint","--noout","{file}"],"regex","https://gnome.pages.gitlab.gnome.org/libxml2/xmllint.html","^(?<file>.+?):(?<line>\\d+): (?<severity>(?:parser |validity )?(?:error|warning)) : (?<message>.*)$",void 0,[0,1,2,3,4])];function c(t,e,n,r,o,s,f,i,a,d,m=[0,1],k,y){return{id:t,name:t,kind:"linter",languages:e,executables:n,configFiles:r,documentation:i,...d&&{dependencies:d},linter:{extensions:o,...y&&{fileNames:y},check:{command:s,successExitCodes:m},diagnostics:{format:f,...a&&{pattern:a},...k!==void 0&&{columnBase:k}}}}}l(c,"recipe");import x from"node:path";import ie from"node:os";import{fileURLToPath as re}from"node:url";function V(t,e){if(t.trim().length===0)return[];switch(e.format){case"pi-json":return H(t);case"eslint-json":return B(t);case"sarif":return Z(t);case"checkstyle":return X(t);case"gcc":case"clang":return K(t);case"regex":return Q(t,u(e.pattern),e.columnBase??1)}}l(V,"parseDiagnostics");function H(t){let e=JSON.parse(t);return Array.isArray(e.diagnostics)?e.diagnostics.flatMap(h):[]}l(H,"parsePiJson");function B(t){return JSON.parse(t).flatMap(n=>Array.isArray(n.messages)?n.messages.flatMap(r=>h(r).map(o=>({...o,...n.filePath&&{file:n.filePath}}))):[])}l(B,"parseEslintJson");function Z(t){return(JSON.parse(t).runs??[]).flatMap(n=>(n.results??[]).flatMap(r=>{let o=r.locations?.[0]?.physicalLocation,s=o?.region??{},f=r.message;return h({file:o?.artifactLocation?.uri,line:s.startLine,column:s.startColumn,message:f?.text,code:r.ruleId,severity:te(r.level)})}))}l(Z,"parseSarif");function X(t){let e=[];for(let n of t.matchAll(/<file\s+([^>]+)>([\s\S]*?)<\/file>/gu)){let r=q(u(n[1])).name;for(let o of u(n[2]).matchAll(/<error\s+([^>]+?)\/?>(?:<\/error>)?/gu)){let s=q(u(o[1]));e.push(...h({file:r,line:Number(s.line),column:Number(s.column??1),message:s.message,code:s.source,severity:s.severity}))}}return e}l(X,"parseCheckstyle");function q(t){return Object.fromEntries([...t.matchAll(/([\w-]+)="([^"]*)"/gu)].map(e=>[u(e[1]),ne(u(e[2]))]))}l(q,"xmlAttributes");function K(t){return Y(t,/^(?<file>.+?):(?<line>\d+):(?<column>\d+):\s*(?<severity>fatal error|error|warning|note|info|hint):\s*(?<message>.*?)(?:\s+\[(?<code>[^\]]+)\])?$/u)}l(K,"parseCompilerLines");function Q(t,e,n){return[...t.replaceAll(`\r
2
- `,`
3
- `).matchAll(new RegExp(e,"gmu"))].flatMap(r=>r.groups===void 0?[]:h({...r.groups,...r.groups.column!==void 0&&{column:Number(r.groups.column)+(1-n)}}))}l(Q,"parseRegexLines");function Y(t,e){return t.split(/\r?\n/u).flatMap(n=>{let r=n.match(e)?.groups;return r===void 0?[]:h(r)})}l(Y,"parseMatchingLines");function h(t){if(typeof t!="object"||t===null)return[];let e=t,n=J(e.line??e.startLine),r=J(e.column??e.startColumn,1),o=typeof e.message=="string"?e.message:void 0;return n===void 0||o===void 0?[]:[{...typeof e.file=="string"&&{file:e.file},code:U(e.code??e.ruleId,"lint"),message:o,line:n,column:r??1,severity:ee(e.severity)}]}l(h,"normalizeDiagnostic");function J(t,e){let n=typeof t=="string"?Number.parseInt(t,10):t;return typeof n=="number"&&Number.isInteger(n)&&n>=1?n:e}l(J,"numberValue");function U(t,e){return typeof t=="string"||typeof t=="number"?String(t):e}l(U,"stringValue");function ee(t){if(t===2)return"error";if(t===1)return"warning";let e=U(t,"warning").toLowerCase();return e.includes("error")||e==="e"||e==="f"||e==="fatal"?"error":e==="info"||e==="note"||e==="notice"?"info":e==="hint"?"hint":"warning"}l(ee,"severityValue");function te(t){return t==="error"||t==="warning"||t==="note"?t:"warning"}l(te,"sarifSeverity");function ne(t){return t.replace(/&#(x[0-9a-f]+|\d+);/giu,(e,n)=>{let r=n.toLowerCase().startsWith("x")?Number.parseInt(n.slice(1),16):Number(n);return r<=1114111?String.fromCodePoint(r):e}).replaceAll("&quot;",'"').replaceAll("&apos;","'").replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}l(ne,"decodeXml");var g=class t{constructor(e,n,r=new Map){this.linters=e;this.availableBuiltIns=n;this.evidence=r}static{l(this,"LintCommandRegistry")}static async fromDirectory(e,n={}){let r=await D(e,"linters",i=>A(i).linters,n),{available:o,evidence:s}=await I(e,r.entries.filter(i=>i.layer==="built-in").map(i=>({id:i.id,config:i.config.check})),p,n),f=[...r.entries].sort((i,a)=>i.layer==="built-in"&&a.layer==="built-in"?(s.get(a.id)?.score??0)-(s.get(i.id)?.score??0):0);return new t(f,o,s)}static fromConfig(e){return new t(Object.entries(e.linters).map(([n,r])=>({id:n,config:r,layer:"project",sourcePath:"<memory>"})),new Set)}resolve(e,n){return this.resolveEntry(e,n)?.config}resolveEntry(e,n){return S(this.linters,this.availableBuiltIns,this.evidence,e,n)}get entries(){return this.linters}};async function C(t,e){let n;try{let i=x.basename(t.check.command[0]??"").toLocaleLowerCase(),a=i==="ruff"||i==="ruff.exe",d=e.env??process.env;n=await $(t.check,{...e,...a&&!e.processAccess?{env:{...d,RUFF_CACHE_DIR:d.RUFF_CACHE_DIR??x.join(ie.tmpdir(),"pi-agent-ide","ruff-cache")}}:{}})}catch(i){return{ok:!1,diagnostics:[],failure:`command could not start: ${i instanceof Error?i.message:String(i)}`}}let r=t.diagnostics.format==="regex"||t.diagnostics.format==="clang"?[n.stdout,n.stderr].filter(i=>i.trim().length>0).join(`
4
- `):n.stdout.trim().length>0?n.stdout:n.stderr,o;try{o=V(r,t.diagnostics)}catch{return{ok:!1,diagnostics:[],failure:`invalid ${t.diagnostics.format} diagnostics: ${r.trim().slice(0,200)||"empty command output"}`}}let s=n.ok&&(n.exitCode===0||o.length>0),f=t.check.cwd==="file"?x.dirname(e.filePath):e.projectRoot;return o=o.filter(i=>{if(i.file===void 0)return!0;if(e.acceptsFile)return e.acceptsFile(i.file);let a=i.file.startsWith("file:")?re(i.file):i.file;return M(x.resolve(f,a),e.filePath)}).map(({file:i,...a})=>a),{ok:s,diagnostics:o,...!s&&{failure:n.stderr.trim().slice(0,200)||`command exited with code ${String(n.exitCode)}`}}}l(C,"runConfiguredLinter");function W(t,e=C){return{kind:"linter",name:"command-lint",priority:100,extensions:["*"],detect:l(()=>Promise.resolve(!0),"detect"),async lint({filePath:n,fix:r},o){let s=t.resolve(n,o.cwd);if(s===void 0)return{ok:!0,diagnostics:[]};let f=r===!0&&s.fix!==void 0?s.fix:s.check,i=await e({...s,check:f},{projectRoot:o.cwd,filePath:n});return{ok:i.ok,diagnostics:i.diagnostics}}}}l(W,"createCommandLinter");var G={protocol:T,apiVersion:N,id:"lint",setup(t){for(let e of p)t.addToolRecipe(e);t.addSetupCheck({id:"effective-config",inspect:oe}),t.addCheck({id:"config",title:"Linter",async run(e){try{let n=await g.fromDirectory(e.cwd,v(e)),r=se(n,e.files,e.cwd);return r.length===0?[{status:"skip",message:"No linter matches the inspected project files"}]:await Promise.all(r.map(async({entry:o,source:s})=>{let f=`${o.id} [${o.layer}] command ${JSON.stringify(o.config.check.command)}`;return z(e,s,async i=>{try{let a=await C(o.config,{projectRoot:e.cwd,filePath:i,env:e.env,signal:e.signal,processAccess:O(e)});return e.signal?.throwIfAborted(),a.ok?{status:"pass",message:`${f}: probe passed`,detail:o.sourcePath}:{status:"fail",message:`${f}: probe failed`,detail:a.failure??o.sourcePath}}catch(a){return e.signal?.throwIfAborted(),{status:"fail",message:`${f}: ${a instanceof Error?a.message:String(a)}`,detail:o.sourcePath}}})}))}catch(n){return e.signal?.throwIfAborted(),[{status:"fail",message:n instanceof Error?n.message:String(n)}]}}})}};async function oe(t){try{let e=await g.fromDirectory(t.cwd,v(t)),n=[],r=new Map;for(let[o,s]of t.detectedLanguages){let f=s.map(i=>e.resolveEntry(i,t.cwd)).find(i=>i!==void 0);f!==void 0&&(n.push({kind:"linter",languageId:o,toolId:f.id}),await _(t,f.config.check)||r.set(f.id,{id:`linter-${f.id}-unavailable`,message:`Configured linter ${f.id} cannot run ${JSON.stringify(f.config.check.command)}`}))}return{selections:n,actions:[...r.values()]}}catch(e){return t.signal?.throwIfAborted(),{actions:[{id:"linter-config-invalid",message:`Linter configuration cannot load: ${e instanceof Error?e.message:String(e)}`}]}}}l(oe,"inspectLinterSetup");function se(t,e,n){let r=new Map;for(let o of e){let s=t.resolveEntry(o,n);s!==void 0&&!r.has(s.id)&&r.set(s.id,{entry:s,source:o})}return[...r.values()]}l(se,"applicableLinters");async function ae(t){await ce(t)}l(ae,"registerLint");async function ce(t,e){let n=new Map,r=l((i,a=!1)=>{let d=JSON.stringify([i,a]),m=n.get(d);return m===void 0&&(m=e?e.loadRegistry(i,a):fe(i,a),n.set(d,m)),m},"registryFor"),o=l(async(i,a)=>{if(e)return e.resolveProject(i,a);if(i.includes("://")||a.includes("://"))throw Object.assign(new Error("Linter requires its resource owner"),{code:"UNSUPPORTED_SOURCE"});let d=await E(a,i,"linters",p);return d===void 0?void 0:{projectRoot:d,external:d!==le.resolve(a)}},"resolveProject"),s={kind:"linter",name:"pi-agent-ide-lint",priority:200,extensions:["*"],detect:l(async i=>(await r(i.cwd),!0),"detect"),async lint(i,a){let d=await o(i.filePath,a.cwd);if(d===void 0)return{ok:!0,diagnostics:[]};let m=await r(d.projectRoot,d.external);return W(m,e?.run).lint(i,{cwd:d.projectRoot})}},f={protocol:R,apiVersion:5,id:"lint",setup(i){i.addTool(s),i.addDiagnosticSource({id:"lint",async diagnose(a,d){let m=await o(a,d.cwd);if(m===void 0)return{status:"unavailable",diagnostics:[],reason:"No linter project found for this file"};let k=await r(m.projectRoot,m.external);d.signal.throwIfAborted();let y=k.resolve(a,m.projectRoot);if(!y)return{status:"unavailable",diagnostics:[],reason:"No linter configured for this file"};let L=P(y.check.command),w=await(e?.run??C)(y,{projectRoot:m.projectRoot,filePath:a,signal:d.signal});return!w.ok&&w.diagnostics.length===0?{status:"unavailable",diagnostics:[],reason:w.failure??"Lint check failed",source:L}:{status:"ready",diagnostics:w.diagnostics,source:L}}})}};await Promise.all([j(t,f),F(t,G)])}l(ce,"registerLintWithOwner");async function fe(t,e){let n=e?t:process.env.PI_AGENT_IDE_CONFIG_DIR??t;return g.fromDirectory(n,{includeGlobal:!e,requireBuiltInEvidence:!0})}l(fe,"loadRegistry");export{p as a,g as b,C as c,ae as d,ce as e};
@@ -1 +0,0 @@
1
- import{g as a}from"./chunk-PJL3UVMJ.js";import{a as c}from"./chunk-EI7MMDWY.js";import{readFile as l}from"node:fs/promises";import{Type as t}from"typebox";import{Value as p}from"typebox/value";var m=t.Object({pid:t.Integer({minimum:1}),parentPid:t.Integer({minimum:0}),command:t.String(),started:t.String(),identity:t.String({pattern:"^[a-f0-9-]+:[0-9]+$"}),executable:t.Union([t.String(),t.Null()])}),w=t.Object({processes:t.Array(m)}),f;async function P(i,n,r,o){return h(i,n,r,o,!1)}c(P,"readSshProcessMetadata");async function E(i,n,r,o){return(await h(i,n,r,o,!0))[0]}c(E,"findSshProcessMetadata");async function h(i,n,r,o,u){if(o?.throwIfAborted(),r!==void 0&&(!Number.isSafeInteger(r)||r<1))throw new Error("Invalid process PID");let d=i.resolve(n);if(!d)throw new a("UNSUPPORTED_SOURCE",n,"not-applied");f??=l(new URL("./process-metadata-worker.py",new URL("../src/backend/process-metadata.ts",import.meta.url).href),"utf8");let S=await d.backend.execute("python3",["-c",await f,...r===void 0?[]:[String(r)]],d.location.path,{signal:o});if(o?.throwIfAborted(),S.exitCode!==0)throw new a("CAPABILITY_UNAVAILABLE",n,"not-applied");let e;try{e=JSON.parse(S.stdout.toString("utf8"))}catch{throw new a("INVALID_RESPONSE",n,"not-applied")}if(typeof e=="object"&&e!==null&&"error"in e){if(u&&r!==void 0&&e.error==="ENOENT")return[];let s=new Set(["CAPABILITY_UNAVAILABLE","ENOENT","EACCES","BYTE_LIMIT"]);throw new a(typeof e.error=="string"&&s.has(e.error)?e.error:"INVALID_RESPONSE",n,"not-applied")}if(!p.Check(w,e)||r!==void 0&&(e.processes.length!==1||e.processes[0]?.pid!==r)||new Set(e.processes.map(s=>s.pid)).size!==e.processes.length)throw new a("INVALID_RESPONSE",n,"not-applied");return e.processes.map(s=>({...s,target:d.location.target,host:"ssh",owned:!1,resource:`process:ssh://${d.location.target}/${s.pid}`}))}c(h,"readSshProcessRows");export{P as a,E as b};
@@ -1 +0,0 @@
1
- import{a as w}from"./chunk-L2B4DTVS.js";import{c as S,d as M}from"./chunk-W7CASEO3.js";import{a as n}from"./chunk-EI7MMDWY.js";import{Container as _,Key as x,matchesKey as P,SelectList as k,Text as v,truncateToWidth as T,visibleWidth as A}from"@earendil-works/pi-tui";var I=class{constructor(e,o,s){this.registry=e;this.activityMode=o;e.onDidChange(()=>this.#s()),s.registerCommand("agent-ide-processes",{description:"Show active terminal and debugger processes created by Agent IDE",handler:n(async(d,c)=>{if(this.bind(c),c.mode!=="tui"){c.ui.notify("The Agent IDE process overlay requires the TUI.","info");return}await this.#r(c)},"handler")})}static{n(this,"AgentIdeProcessesUi")}#t;#i=!1;#e;bind(e){this.#i||(this.#t=e,this.#s())}dispose(){this.#i=!0,this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0,this.#t?.ui.setWidget("agent-ide-processes",void 0),this.#t?.ui.setStatus("agent-ide-processes",void 0),this.#t=void 0}#n(){return this.registry.list()}#s(){let e=this.#t;if(this.#i||e===void 0||!e.hasUI)return;let o=this.#n();if(this.activityMode==="off"||o.length===0){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",void 0),this.#e!==void 0&&clearInterval(this.#e),this.#e=void 0;return}if(this.activityMode==="compact"){e.ui.setWidget("agent-ide-processes",void 0),e.ui.setStatus("agent-ide-processes",`Agent IDE processes: ${o.length}`);return}e.ui.setStatus("agent-ide-processes",void 0),e.ui.setWidget("agent-ide-processes",(s,d)=>({invalidate(){},render:n(c=>q(o,c,d),"render")}),{placement:"belowEditor"}),this.#e??=setInterval(()=>this.#s(),1e3)}async#r(e){for(;;){if(this.#n().length===0){e.ui.notify("No active Agent IDE processes.","info");return}let o=n(()=>{},"disposeRefresh"),s,d;try{d=await e.ui.custom((g,a,O,E)=>{let h=this.#n(),l="list",f,$=n(r=>{let u=h.map(t=>({value:t.source,label:`${t.status} ${t.kind} ${t.title}`,description:t.description})),p=new k(u,Math.min(u.length,12),{selectedPrefix:n(t=>a.fg("accent",t),"selectedPrefix"),selectedText:n(t=>a.fg("accent",t),"selectedText"),description:n(t=>a.fg("muted",t),"description"),scrollInfo:n(t=>a.fg("dim",t),"scrollInfo"),noMatch:n(t=>a.fg("warning",t),"noMatch")}),y=u.findIndex(t=>t.value===r);return y>=0&&p.setSelectedIndex(y),p.onSelect=t=>{f=h.find(W=>W.source===t.value),l="detail",g.requestRender()},p.onCancel=()=>E(null),p},"createList"),m=$(),C=n(()=>{let r=f?.source??m.getSelectedItem()?.value;h=this.#n(),f=l==="list"?void 0:h.find(u=>u.source===r),m=$(r),g.requestRender()},"refresh");return o=this.registry.onDidChange(C),s=setInterval(C,1e3),{invalidate:n(()=>m.invalidate(),"invalidate"),render(r){let u=new _;l==="list"?(u.addChild(m),u.addChild(new v(a.fg("dim",h.length===0?"esc close":"enter view \xB7 d stop \xB7 esc close"),1,0))):f===void 0?(u.addChild(new v(a.fg("warning","Process is no longer active."),1,0)),u.addChild(new v(a.fg("dim","esc back"),1,0))):(u.addChild(f.renderDetail(a)),u.addChild(new v(a.fg(l==="confirm"?"warning":"dim",l==="confirm"?"Stop this process? y confirm \xB7 n/esc cancel":l==="input"?"input mode \xB7 type to send \xB7 esc stop input":f.sendInput===void 0?"esc back \xB7 d stop":"i input \xB7 esc back \xB7 d stop"),1,0)));let p=n(t=>a.fg("accent",t),"accent"),y=Math.max(1,r-2);return[D("Agent IDE Processes",`${h.length} active`,r,p),...u.render(y).map(t=>b(t,r,p)),R(r,p)]},handleInput(r){l==="list"?r==="d"?(f=h.find(u=>u.source===m.getSelectedItem()?.value),f!==void 0&&(l="confirm")):m.handleInput(r):l==="detail"?P(r,x.escape)?l="list":r==="d"&&f!==void 0?l="confirm":r==="i"&&f?.sendInput!==void 0&&(l="input"):l==="input"?P(r,x.escape)?l="detail":f?.sendInput?.(r):r==="y"&&f!==void 0?E({source:f.source}):(r==="n"||P(r,x.escape))&&(l="detail"),g.requestRender()}}},{overlay:!0,overlayOptions:{width:"75%",maxHeight:"80%",minWidth:52}})}finally{o(),s!==void 0&&clearInterval(s)}if(d===null)return;let c=this.#n().find(g=>g.source===d.source);c!==void 0&&await c.stop()}}};function q(i,e,o){if(i.length===0)return[];let s=n(c=>o.fg("accent",c),"accent"),d=[D("Agent IDE Processes",`${i.length} active`,e,s)];for(let[c,g]of i.entries()){for(let a of g.renderSummary(o))d.push(b(` ${a} `,e,s));c<i.length-1&&d.push(b("",e,s))}return d.push(R(e,s)),d}n(q,"renderProcessWidget");function D(i,e,o,s){if(o<=1)return s("\u256D");let d=o-2,c=`\u2500 ${i} `,g=` ${e} \u2500`,a="\u2500".repeat(Math.max(0,d-A(c)-A(g)));return s(`\u256D${T(`${c}${a}${g}`,d).padEnd(d,"\u2500")}\u256E`)}n(D,"borderTop");function b(i,e,o){if(e<=1)return o("\u2502");let s=e-2,d=T(i,s);return`${o("\u2502")}${d}${" ".repeat(Math.max(0,s-A(d)))}${o("\u2502")}`}n(b,"borderLine");function R(i,e){return e(i<=1?"\u2570":`\u2570${"\u2500".repeat(i-2)}\u256F`)}n(R,"borderBottom");async function L(i){let e=w(i),o=await M(S()),s=new I(e,K(o.preferences?.["processes.activity"]),i);i.on("session_start",(d,c)=>s.bind(c)),i.on("session_shutdown",()=>s.dispose())}n(L,"registerAgentIdeProcesses");function K(i){return i==="compact"||i==="off"?i:"detailed"}n(K,"activityMode");export{L as default};
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-ZPT5D4VP.js";import{a as l}from"./chunk-ZC65Z3CK.js";import{a as r}from"./chunk-EI7MMDWY.js";var u=Symbol.for("pi-agent-text-editor/TextSelectionAnchor"),d=class extends c{constructor(t,o,i){let s=i.map(a=>({start:{...a.start},end:{...a.end},...a.linewise===!0&&{linewise:!0}}));g(s);super(t,l(s[0]).start.lineNumber);this.source=o;if(o.length===0)throw new TypeError("Text selection anchor source must be non-empty");this.ranges=s}static{r(this,"TextSelectionAnchor")}[u]=!0;ranges;static is(t){if(!c.is(t))return!1;try{let o=t,i=o.ranges;return o[u]===!0&&typeof o.source=="string"&&o.source.length>0&&Array.isArray(i)&&i.length>0&&i.every(x)}catch{return!1}}};function g(n){if(n.length===0)throw new TypeError("Text selection anchor must contain at least one range");let e;for(let t of n){if(!x(t)||p(t.start,t.end)>0)throw new RangeError("Text selection anchor contains an invalid range");if(e!==void 0&&p(t.start,e.end)<0)throw new Error("Text selection anchor ranges must be ordered and must not overlap");e=t}}r(g,"assertSelectionRanges");function x(n){if(typeof n!="object"||n===null)return!1;let e=n;return f(e.start)&&f(e.end)&&(e.linewise===void 0||typeof e.linewise=="boolean")}r(x,"isTextSelectionRange");function f(n){if(typeof n!="object"||n===null)return!1;let e=n;return Number.isSafeInteger(e.lineNumber)&&(e.lineNumber??0)>=1&&Number.isSafeInteger(e.column)&&(e.column??-1)>=0}r(f,"isTextSelectionPosition");function p(n,e){return n.lineNumber-e.lineNumber||n.column-e.column}r(p,"comparePositions");export{d as a};