@hoilab/ada-cli 0.84.21 → 0.85.0

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 (1337) hide show
  1. package/CHANGELOG.md +49 -2
  2. package/README.es.md +174 -0
  3. package/README.md +203 -658
  4. package/dist/ada-publico.d.ts +35 -0
  5. package/dist/ada-publico.d.ts.map +1 -0
  6. package/dist/ada-publico.js +40 -0
  7. package/dist/ada-publico.js.map +1 -0
  8. package/dist/cli/args.d.ts +3 -0
  9. package/dist/cli/args.d.ts.map +1 -1
  10. package/dist/cli/args.js +11 -0
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/cli/audit-command.d.ts +15 -0
  13. package/dist/cli/audit-command.d.ts.map +1 -0
  14. package/dist/cli/audit-command.js +280 -0
  15. package/dist/cli/audit-command.js.map +1 -0
  16. package/dist/cli/banco-command.d.ts +15 -0
  17. package/dist/cli/banco-command.d.ts.map +1 -0
  18. package/dist/cli/banco-command.js +213 -0
  19. package/dist/cli/banco-command.js.map +1 -0
  20. package/dist/cli/cleanse-command.d.ts +11 -0
  21. package/dist/cli/cleanse-command.d.ts.map +1 -0
  22. package/dist/cli/cleanse-command.js +101 -0
  23. package/dist/cli/cleanse-command.js.map +1 -0
  24. package/dist/cli/commit-command.d.ts +31 -0
  25. package/dist/cli/commit-command.d.ts.map +1 -0
  26. package/dist/cli/commit-command.js +158 -0
  27. package/dist/cli/commit-command.js.map +1 -0
  28. package/dist/cli/computer-command.d.ts +12 -0
  29. package/dist/cli/computer-command.d.ts.map +1 -0
  30. package/dist/cli/computer-command.js +141 -0
  31. package/dist/cli/computer-command.js.map +1 -0
  32. package/dist/cli/discover-command.d.ts +18 -0
  33. package/dist/cli/discover-command.d.ts.map +1 -0
  34. package/dist/cli/discover-command.js +108 -0
  35. package/dist/cli/discover-command.js.map +1 -0
  36. package/dist/cli/file-processor.d.ts.map +1 -1
  37. package/dist/cli/file-processor.js +2 -1
  38. package/dist/cli/file-processor.js.map +1 -1
  39. package/dist/cli/hashline-command.d.ts +11 -0
  40. package/dist/cli/hashline-command.d.ts.map +1 -0
  41. package/dist/cli/hashline-command.js +106 -0
  42. package/dist/cli/hashline-command.js.map +1 -0
  43. package/dist/cli/home-screen.d.ts.map +1 -1
  44. package/dist/cli/home-screen.js +2 -2
  45. package/dist/cli/home-screen.js.map +1 -1
  46. package/dist/cli/import-command.d.ts +35 -0
  47. package/dist/cli/import-command.d.ts.map +1 -0
  48. package/dist/cli/import-command.js +164 -0
  49. package/dist/cli/import-command.js.map +1 -0
  50. package/dist/cli/politica-command.d.ts +20 -0
  51. package/dist/cli/politica-command.d.ts.map +1 -0
  52. package/dist/cli/politica-command.js +93 -0
  53. package/dist/cli/politica-command.js.map +1 -0
  54. package/dist/cli/refine-command.d.ts +18 -0
  55. package/dist/cli/refine-command.d.ts.map +1 -0
  56. package/dist/cli/refine-command.js +101 -0
  57. package/dist/cli/refine-command.js.map +1 -0
  58. package/dist/cli/review-command.d.ts +24 -0
  59. package/dist/cli/review-command.d.ts.map +1 -0
  60. package/dist/cli/review-command.js +168 -0
  61. package/dist/cli/review-command.js.map +1 -0
  62. package/dist/cli/schedule-command.d.ts +17 -0
  63. package/dist/cli/schedule-command.d.ts.map +1 -0
  64. package/dist/cli/schedule-command.js +117 -0
  65. package/dist/cli/schedule-command.js.map +1 -0
  66. package/dist/cli/serve-command.d.ts +72 -0
  67. package/dist/cli/serve-command.d.ts.map +1 -0
  68. package/dist/cli/serve-command.js +568 -0
  69. package/dist/cli/serve-command.js.map +1 -0
  70. package/dist/cli/startup-ui.d.ts.map +1 -1
  71. package/dist/cli/startup-ui.js +9 -3
  72. package/dist/cli/startup-ui.js.map +1 -1
  73. package/dist/cli/telegram-command.d.ts +18 -0
  74. package/dist/cli/telegram-command.d.ts.map +1 -0
  75. package/dist/cli/telegram-command.js +137 -0
  76. package/dist/cli/telegram-command.js.map +1 -0
  77. package/dist/cli/telemetria-command.d.ts +22 -0
  78. package/dist/cli/telemetria-command.d.ts.map +1 -0
  79. package/dist/cli/telemetria-command.js +127 -0
  80. package/dist/cli/telemetria-command.js.map +1 -0
  81. package/dist/cli/undo-command.d.ts +9 -0
  82. package/dist/cli/undo-command.d.ts.map +1 -0
  83. package/dist/cli/undo-command.js +56 -0
  84. package/dist/cli/undo-command.js.map +1 -0
  85. package/dist/cli/usage-command.d.ts +10 -0
  86. package/dist/cli/usage-command.d.ts.map +1 -0
  87. package/dist/cli/usage-command.js +209 -0
  88. package/dist/cli/usage-command.js.map +1 -0
  89. package/dist/cli/wiki-command.d.ts +9 -0
  90. package/dist/cli/wiki-command.d.ts.map +1 -0
  91. package/dist/cli/wiki-command.js +76 -0
  92. package/dist/cli/wiki-command.js.map +1 -0
  93. package/dist/cli.d.ts +6 -0
  94. package/dist/cli.d.ts.map +1 -1
  95. package/dist/cli.js +10 -11
  96. package/dist/cli.js.map +1 -1
  97. package/dist/config.d.ts +1 -1
  98. package/dist/config.d.ts.map +1 -1
  99. package/dist/config.js +3 -2
  100. package/dist/config.js.map +1 -1
  101. package/dist/core/ada.d.ts +58 -0
  102. package/dist/core/ada.d.ts.map +1 -0
  103. package/dist/core/ada.js +61 -0
  104. package/dist/core/ada.js.map +1 -0
  105. package/dist/core/advisor/guarda.d.ts +66 -0
  106. package/dist/core/advisor/guarda.d.ts.map +1 -0
  107. package/dist/core/advisor/guarda.js +191 -0
  108. package/dist/core/advisor/guarda.js.map +1 -0
  109. package/dist/core/advisor/runtime.d.ts +66 -0
  110. package/dist/core/advisor/runtime.d.ts.map +1 -0
  111. package/dist/core/advisor/runtime.js +121 -0
  112. package/dist/core/advisor/runtime.js.map +1 -0
  113. package/dist/core/advisor/sesion.d.ts +109 -0
  114. package/dist/core/advisor/sesion.d.ts.map +1 -0
  115. package/dist/core/advisor/sesion.js +139 -0
  116. package/dist/core/advisor/sesion.js.map +1 -0
  117. package/dist/core/agent-session.d.ts +85 -7
  118. package/dist/core/agent-session.d.ts.map +1 -1
  119. package/dist/core/agent-session.js +862 -78
  120. package/dist/core/agent-session.js.map +1 -1
  121. package/dist/core/agents/loader.d.ts +77 -0
  122. package/dist/core/agents/loader.d.ts.map +1 -0
  123. package/dist/core/agents/loader.js +154 -0
  124. package/dist/core/agents/loader.js.map +1 -0
  125. package/dist/core/aprobacion/generados.d.ts +37 -0
  126. package/dist/core/aprobacion/generados.d.ts.map +1 -0
  127. package/dist/core/aprobacion/generados.js +85 -0
  128. package/dist/core/aprobacion/generados.js.map +1 -0
  129. package/dist/core/aprobacion/politica-de-maquina.d.ts +90 -0
  130. package/dist/core/aprobacion/politica-de-maquina.d.ts.map +1 -0
  131. package/dist/core/aprobacion/politica-de-maquina.js +212 -0
  132. package/dist/core/aprobacion/politica-de-maquina.js.map +1 -0
  133. package/dist/core/aprobacion/politica.d.ts +90 -0
  134. package/dist/core/aprobacion/politica.d.ts.map +1 -0
  135. package/dist/core/aprobacion/politica.js +375 -0
  136. package/dist/core/aprobacion/politica.js.map +1 -0
  137. package/dist/core/arranque/atajos.d.ts +46 -0
  138. package/dist/core/arranque/atajos.d.ts.map +1 -0
  139. package/dist/core/arranque/atajos.js +113 -0
  140. package/dist/core/arranque/atajos.js.map +1 -0
  141. package/dist/core/audit/exportacion.d.ts +54 -0
  142. package/dist/core/audit/exportacion.d.ts.map +1 -0
  143. package/dist/core/audit/exportacion.js +265 -0
  144. package/dist/core/audit/exportacion.js.map +1 -0
  145. package/dist/core/audit/libro.d.ts +318 -0
  146. package/dist/core/audit/libro.d.ts.map +1 -0
  147. package/dist/core/audit/libro.js +508 -0
  148. package/dist/core/audit/libro.js.map +1 -0
  149. package/dist/core/audit/registro-sesion.d.ts +78 -0
  150. package/dist/core/audit/registro-sesion.d.ts.map +1 -0
  151. package/dist/core/audit/registro-sesion.js +202 -0
  152. package/dist/core/audit/registro-sesion.js.map +1 -0
  153. package/dist/core/audit/retencion.d.ts +82 -0
  154. package/dist/core/audit/retencion.d.ts.map +1 -0
  155. package/dist/core/audit/retencion.js +152 -0
  156. package/dist/core/audit/retencion.js.map +1 -0
  157. package/dist/core/audit/rutas.d.ts +23 -0
  158. package/dist/core/audit/rutas.d.ts.map +1 -0
  159. package/dist/core/audit/rutas.js +23 -0
  160. package/dist/core/audit/rutas.js.map +1 -0
  161. package/dist/core/auth-storage.d.ts +0 -3
  162. package/dist/core/auth-storage.d.ts.map +1 -1
  163. package/dist/core/auth-storage.js +21 -8
  164. package/dist/core/auth-storage.js.map +1 -1
  165. package/dist/core/banco/almacenamiento.d.ts +18 -0
  166. package/dist/core/banco/almacenamiento.d.ts.map +1 -0
  167. package/dist/core/banco/almacenamiento.js +50 -0
  168. package/dist/core/banco/almacenamiento.js.map +1 -0
  169. package/dist/core/banco/analisis.d.ts +37 -0
  170. package/dist/core/banco/analisis.d.ts.map +1 -0
  171. package/dist/core/banco/analisis.js +164 -0
  172. package/dist/core/banco/analisis.js.map +1 -0
  173. package/dist/core/banco/bloques.d.ts +39 -0
  174. package/dist/core/banco/bloques.d.ts.map +1 -0
  175. package/dist/core/banco/bloques.js +84 -0
  176. package/dist/core/banco/bloques.js.map +1 -0
  177. package/dist/core/banco/cargas.d.ts +84 -0
  178. package/dist/core/banco/cargas.d.ts.map +1 -0
  179. package/dist/core/banco/cargas.js +520 -0
  180. package/dist/core/banco/cargas.js.map +1 -0
  181. package/dist/core/banco/comparar.d.ts +29 -0
  182. package/dist/core/banco/comparar.d.ts.map +1 -0
  183. package/dist/core/banco/comparar.js +28 -0
  184. package/dist/core/banco/comparar.js.map +1 -0
  185. package/dist/core/banco/ejecutar.d.ts +44 -0
  186. package/dist/core/banco/ejecutar.d.ts.map +1 -0
  187. package/dist/core/banco/ejecutar.js +183 -0
  188. package/dist/core/banco/ejecutar.js.map +1 -0
  189. package/dist/core/banco/generar.d.ts +24 -0
  190. package/dist/core/banco/generar.d.ts.map +1 -0
  191. package/dist/core/banco/generar.js +159 -0
  192. package/dist/core/banco/generar.js.map +1 -0
  193. package/dist/core/banco/mutaciones.d.ts +25 -0
  194. package/dist/core/banco/mutaciones.d.ts.map +1 -0
  195. package/dist/core/banco/mutaciones.js +215 -0
  196. package/dist/core/banco/mutaciones.js.map +1 -0
  197. package/dist/core/banco/tipos.d.ts +121 -0
  198. package/dist/core/banco/tipos.d.ts.map +1 -0
  199. package/dist/core/banco/tipos.js +16 -0
  200. package/dist/core/banco/tipos.js.map +1 -0
  201. package/dist/core/blobs/almacen.d.ts +81 -0
  202. package/dist/core/blobs/almacen.d.ts.map +1 -0
  203. package/dist/core/blobs/almacen.js +198 -0
  204. package/dist/core/blobs/almacen.js.map +1 -0
  205. package/dist/core/blobs/broker.d.ts +103 -0
  206. package/dist/core/blobs/broker.d.ts.map +1 -0
  207. package/dist/core/blobs/broker.js +204 -0
  208. package/dist/core/blobs/broker.js.map +1 -0
  209. package/dist/core/blobs/index.d.ts +70 -0
  210. package/dist/core/blobs/index.d.ts.map +1 -0
  211. package/dist/core/blobs/index.js +232 -0
  212. package/dist/core/blobs/index.js.map +1 -0
  213. package/dist/core/blobs/payload.d.ts +55 -0
  214. package/dist/core/blobs/payload.d.ts.map +1 -0
  215. package/dist/core/blobs/payload.js +255 -0
  216. package/dist/core/blobs/payload.js.map +1 -0
  217. package/dist/core/blobs/proveedor.d.ts +85 -0
  218. package/dist/core/blobs/proveedor.d.ts.map +1 -0
  219. package/dist/core/blobs/proveedor.js +196 -0
  220. package/dist/core/blobs/proveedor.js.map +1 -0
  221. package/dist/core/browser/cdp.d.ts +41 -0
  222. package/dist/core/browser/cdp.d.ts.map +1 -0
  223. package/dist/core/browser/cdp.js +119 -0
  224. package/dist/core/browser/cdp.js.map +1 -0
  225. package/dist/core/browser/politica.d.ts +51 -0
  226. package/dist/core/browser/politica.d.ts.map +1 -0
  227. package/dist/core/browser/politica.js +123 -0
  228. package/dist/core/browser/politica.js.map +1 -0
  229. package/dist/core/browser/sesion.d.ts +52 -0
  230. package/dist/core/browser/sesion.d.ts.map +1 -0
  231. package/dist/core/browser/sesion.js +176 -0
  232. package/dist/core/browser/sesion.js.map +1 -0
  233. package/dist/core/browser/tools.d.ts +16 -0
  234. package/dist/core/browser/tools.d.ts.map +1 -0
  235. package/dist/core/browser/tools.js +279 -0
  236. package/dist/core/browser/tools.js.map +1 -0
  237. package/dist/core/commit/diff.d.ts +56 -0
  238. package/dist/core/commit/diff.d.ts.map +1 -0
  239. package/dist/core/commit/diff.js +145 -0
  240. package/dist/core/commit/diff.js.map +1 -0
  241. package/dist/core/commit/mensaje.d.ts +80 -0
  242. package/dist/core/commit/mensaje.d.ts.map +1 -0
  243. package/dist/core/commit/mensaje.js +207 -0
  244. package/dist/core/commit/mensaje.js.map +1 -0
  245. package/dist/core/compactar/index.d.ts +52 -0
  246. package/dist/core/compactar/index.d.ts.map +1 -0
  247. package/dist/core/compactar/index.js +91 -0
  248. package/dist/core/compactar/index.js.map +1 -0
  249. package/dist/core/compactar/registro-denso.d.ts +160 -0
  250. package/dist/core/compactar/registro-denso.d.ts.map +1 -0
  251. package/dist/core/compactar/registro-denso.js +620 -0
  252. package/dist/core/compactar/registro-denso.js.map +1 -0
  253. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  254. package/dist/core/compaction/branch-summarization.js +3 -0
  255. package/dist/core/compaction/branch-summarization.js.map +1 -1
  256. package/dist/core/compaction/compaction.d.ts +4 -3
  257. package/dist/core/compaction/compaction.d.ts.map +1 -1
  258. package/dist/core/compaction/compaction.js +41 -32
  259. package/dist/core/compaction/compaction.js.map +1 -1
  260. package/dist/core/computer/captura.d.ts +35 -0
  261. package/dist/core/computer/captura.d.ts.map +1 -0
  262. package/dist/core/computer/captura.js +140 -0
  263. package/dist/core/computer/captura.js.map +1 -0
  264. package/dist/core/computer/driver.d.ts +130 -0
  265. package/dist/core/computer/driver.d.ts.map +1 -0
  266. package/dist/core/computer/driver.js +206 -0
  267. package/dist/core/computer/driver.js.map +1 -0
  268. package/dist/core/computer/motor/actions.d.ts +109 -0
  269. package/dist/core/computer/motor/actions.d.ts.map +1 -0
  270. package/dist/core/computer/motor/actions.js +157 -0
  271. package/dist/core/computer/motor/actions.js.map +1 -0
  272. package/dist/core/computer/motor/bridge.d.ts +232 -0
  273. package/dist/core/computer/motor/bridge.d.ts.map +1 -0
  274. package/dist/core/computer/motor/bridge.js +2335 -0
  275. package/dist/core/computer/motor/bridge.js.map +1 -0
  276. package/dist/core/computer/motor/cdp.d.ts +107 -0
  277. package/dist/core/computer/motor/cdp.d.ts.map +1 -0
  278. package/dist/core/computer/motor/cdp.js +659 -0
  279. package/dist/core/computer/motor/cdp.js.map +1 -0
  280. package/dist/core/computer/motor/config.d.ts +23 -0
  281. package/dist/core/computer/motor/config.d.ts.map +1 -0
  282. package/dist/core/computer/motor/config.js +100 -0
  283. package/dist/core/computer/motor/config.js.map +1 -0
  284. package/dist/core/computer/motor/contract.d.ts +81 -0
  285. package/dist/core/computer/motor/contract.d.ts.map +1 -0
  286. package/dist/core/computer/motor/contract.js +14 -0
  287. package/dist/core/computer/motor/contract.js.map +1 -0
  288. package/dist/core/computer/motor/note.d.ts +37 -0
  289. package/dist/core/computer/motor/note.d.ts.map +1 -0
  290. package/dist/core/computer/motor/note.js +162 -0
  291. package/dist/core/computer/motor/note.js.map +1 -0
  292. package/dist/core/computer/motor/outline.d.ts +155 -0
  293. package/dist/core/computer/motor/outline.d.ts.map +1 -0
  294. package/dist/core/computer/motor/outline.js +590 -0
  295. package/dist/core/computer/motor/outline.js.map +1 -0
  296. package/dist/core/computer/motor/output.d.ts +18 -0
  297. package/dist/core/computer/motor/output.d.ts.map +1 -0
  298. package/dist/core/computer/motor/output.js +148 -0
  299. package/dist/core/computer/motor/output.js.map +1 -0
  300. package/dist/core/computer/motor/permissions.d.ts +41 -0
  301. package/dist/core/computer/motor/permissions.d.ts.map +1 -0
  302. package/dist/core/computer/motor/permissions.js +51 -0
  303. package/dist/core/computer/motor/permissions.js.map +1 -0
  304. package/dist/core/computer/motor/platform/architecture.d.ts +5 -0
  305. package/dist/core/computer/motor/platform/architecture.d.ts.map +1 -0
  306. package/dist/core/computer/motor/platform/architecture.js +21 -0
  307. package/dist/core/computer/motor/platform/architecture.js.map +1 -0
  308. package/dist/core/computer/motor/platform/coerce.d.ts +4 -0
  309. package/dist/core/computer/motor/platform/coerce.d.ts.map +1 -0
  310. package/dist/core/computer/motor/platform/coerce.js +17 -0
  311. package/dist/core/computer/motor/platform/coerce.js.map +1 -0
  312. package/dist/core/computer/motor/platform/index.d.ts +4 -0
  313. package/dist/core/computer/motor/platform/index.d.ts.map +1 -0
  314. package/dist/core/computer/motor/platform/index.js +79 -0
  315. package/dist/core/computer/motor/platform/index.js.map +1 -0
  316. package/dist/core/computer/motor/platform/linux/backend.d.ts +3 -0
  317. package/dist/core/computer/motor/platform/linux/backend.d.ts.map +1 -0
  318. package/dist/core/computer/motor/platform/linux/backend.js +173 -0
  319. package/dist/core/computer/motor/platform/linux/backend.js.map +1 -0
  320. package/dist/core/computer/motor/platform/linux/helper.d.ts +29 -0
  321. package/dist/core/computer/motor/platform/linux/helper.d.ts.map +1 -0
  322. package/dist/core/computer/motor/platform/linux/helper.js +261 -0
  323. package/dist/core/computer/motor/platform/linux/helper.js.map +1 -0
  324. package/dist/core/computer/motor/platform/macos/backend.d.ts +3 -0
  325. package/dist/core/computer/motor/platform/macos/backend.d.ts.map +1 -0
  326. package/dist/core/computer/motor/platform/macos/backend.js +124 -0
  327. package/dist/core/computer/motor/platform/macos/backend.js.map +1 -0
  328. package/dist/core/computer/motor/platform/macos/browser.d.ts +7 -0
  329. package/dist/core/computer/motor/platform/macos/browser.d.ts.map +1 -0
  330. package/dist/core/computer/motor/platform/macos/browser.js +101 -0
  331. package/dist/core/computer/motor/platform/macos/browser.js.map +1 -0
  332. package/dist/core/computer/motor/platform/macos/helper-path.mjs +34 -0
  333. package/dist/core/computer/motor/platform/macos/helper.d.ts +32 -0
  334. package/dist/core/computer/motor/platform/macos/helper.d.ts.map +1 -0
  335. package/dist/core/computer/motor/platform/macos/helper.js +277 -0
  336. package/dist/core/computer/motor/platform/macos/helper.js.map +1 -0
  337. package/dist/core/computer/motor/platform/macos/permissions.d.ts +4 -0
  338. package/dist/core/computer/motor/platform/macos/permissions.d.ts.map +1 -0
  339. package/dist/core/computer/motor/platform/macos/permissions.js +118 -0
  340. package/dist/core/computer/motor/platform/macos/permissions.js.map +1 -0
  341. package/dist/core/computer/motor/platform/types.d.ts +263 -0
  342. package/dist/core/computer/motor/platform/types.d.ts.map +1 -0
  343. package/dist/core/computer/motor/platform/types.js +2 -0
  344. package/dist/core/computer/motor/platform/types.js.map +1 -0
  345. package/dist/core/computer/motor/platform/windows/backend.d.ts +3 -0
  346. package/dist/core/computer/motor/platform/windows/backend.d.ts.map +1 -0
  347. package/dist/core/computer/motor/platform/windows/backend.js +163 -0
  348. package/dist/core/computer/motor/platform/windows/backend.js.map +1 -0
  349. package/dist/core/computer/motor/platform/windows/helper.d.ts +18 -0
  350. package/dist/core/computer/motor/platform/windows/helper.d.ts.map +1 -0
  351. package/dist/core/computer/motor/platform/windows/helper.js +174 -0
  352. package/dist/core/computer/motor/platform/windows/helper.js.map +1 -0
  353. package/dist/core/computer/motor/root-selection.d.ts +6 -0
  354. package/dist/core/computer/motor/root-selection.d.ts.map +1 -0
  355. package/dist/core/computer/motor/root-selection.js +28 -0
  356. package/dist/core/computer/motor/root-selection.js.map +1 -0
  357. package/dist/core/computer/motor/runtime.d.ts +50 -0
  358. package/dist/core/computer/motor/runtime.d.ts.map +1 -0
  359. package/dist/core/computer/motor/runtime.js +119 -0
  360. package/dist/core/computer/motor/runtime.js.map +1 -0
  361. package/dist/core/computer/motor/state.d.ts +68 -0
  362. package/dist/core/computer/motor/state.d.ts.map +1 -0
  363. package/dist/core/computer/motor/state.js +100 -0
  364. package/dist/core/computer/motor/state.js.map +1 -0
  365. package/dist/core/computer/motor/view.d.ts +6 -0
  366. package/dist/core/computer/motor/view.d.ts.map +1 -0
  367. package/dist/core/computer/motor/view.js +185 -0
  368. package/dist/core/computer/motor/view.js.map +1 -0
  369. package/dist/core/computer/motor-ada.d.ts +159 -0
  370. package/dist/core/computer/motor-ada.d.ts.map +1 -0
  371. package/dist/core/computer/motor-ada.js +412 -0
  372. package/dist/core/computer/motor-ada.js.map +1 -0
  373. package/dist/core/computer/politica.d.ts +56 -0
  374. package/dist/core/computer/politica.d.ts.map +1 -0
  375. package/dist/core/computer/politica.js +163 -0
  376. package/dist/core/computer/politica.js.map +1 -0
  377. package/dist/core/computer/tools.d.ts +26 -0
  378. package/dist/core/computer/tools.d.ts.map +1 -0
  379. package/dist/core/computer/tools.js +399 -0
  380. package/dist/core/computer/tools.js.map +1 -0
  381. package/dist/core/context-breakdown.d.ts +80 -0
  382. package/dist/core/context-breakdown.d.ts.map +1 -0
  383. package/dist/core/context-breakdown.js +87 -0
  384. package/dist/core/context-breakdown.js.map +1 -0
  385. package/dist/core/credenciales/cliente.d.ts +60 -0
  386. package/dist/core/credenciales/cliente.d.ts.map +1 -0
  387. package/dist/core/credenciales/cliente.js +81 -0
  388. package/dist/core/credenciales/cliente.js.map +1 -0
  389. package/dist/core/credenciales/pool.d.ts +96 -0
  390. package/dist/core/credenciales/pool.d.ts.map +1 -0
  391. package/dist/core/credenciales/pool.js +128 -0
  392. package/dist/core/credenciales/pool.js.map +1 -0
  393. package/dist/core/credenciales/reposo.d.ts +93 -0
  394. package/dist/core/credenciales/reposo.d.ts.map +1 -0
  395. package/dist/core/credenciales/reposo.js +489 -0
  396. package/dist/core/credenciales/reposo.js.map +1 -0
  397. package/dist/core/credenciales/servidor.d.ts +55 -0
  398. package/dist/core/credenciales/servidor.d.ts.map +1 -0
  399. package/dist/core/credenciales/servidor.js +205 -0
  400. package/dist/core/credenciales/servidor.js.map +1 -0
  401. package/dist/core/defaults.d.ts +1 -0
  402. package/dist/core/defaults.d.ts.map +1 -1
  403. package/dist/core/defaults.js +9 -0
  404. package/dist/core/defaults.js.map +1 -1
  405. package/dist/core/descubrimiento/comandos.d.ts +30 -0
  406. package/dist/core/descubrimiento/comandos.d.ts.map +1 -0
  407. package/dist/core/descubrimiento/comandos.js +76 -0
  408. package/dist/core/descubrimiento/comandos.js.map +1 -0
  409. package/dist/core/descubrimiento/mcp.d.ts +42 -0
  410. package/dist/core/descubrimiento/mcp.d.ts.map +1 -0
  411. package/dist/core/descubrimiento/mcp.js +130 -0
  412. package/dist/core/descubrimiento/mcp.js.map +1 -0
  413. package/dist/core/descubrimiento/reglas.d.ts +61 -0
  414. package/dist/core/descubrimiento/reglas.d.ts.map +1 -0
  415. package/dist/core/descubrimiento/reglas.js +134 -0
  416. package/dist/core/descubrimiento/reglas.js.map +1 -0
  417. package/dist/core/descubrimiento/skills.d.ts +57 -0
  418. package/dist/core/descubrimiento/skills.d.ts.map +1 -0
  419. package/dist/core/descubrimiento/skills.js +113 -0
  420. package/dist/core/descubrimiento/skills.js.map +1 -0
  421. package/dist/core/dificultad/clasificador.d.ts +133 -0
  422. package/dist/core/dificultad/clasificador.d.ts.map +1 -0
  423. package/dist/core/dificultad/clasificador.js +288 -0
  424. package/dist/core/dificultad/clasificador.js.map +1 -0
  425. package/dist/core/edicion/diario.d.ts +37 -0
  426. package/dist/core/edicion/diario.d.ts.map +1 -0
  427. package/dist/core/edicion/diario.js +51 -0
  428. package/dist/core/edicion/diario.js.map +1 -0
  429. package/dist/core/edicion/hashline.d.ts +71 -0
  430. package/dist/core/edicion/hashline.d.ts.map +1 -0
  431. package/dist/core/edicion/hashline.js +111 -0
  432. package/dist/core/edicion/hashline.js.map +1 -0
  433. package/dist/core/edicion/hueco.d.ts +64 -0
  434. package/dist/core/edicion/hueco.d.ts.map +1 -0
  435. package/dist/core/edicion/hueco.js +162 -0
  436. package/dist/core/edicion/hueco.js.map +1 -0
  437. package/dist/core/edicion/limpiar-carga.d.ts +39 -0
  438. package/dist/core/edicion/limpiar-carga.d.ts.map +1 -0
  439. package/dist/core/edicion/limpiar-carga.js +121 -0
  440. package/dist/core/edicion/limpiar-carga.js.map +1 -0
  441. package/dist/core/edicion/observador.d.ts +80 -0
  442. package/dist/core/edicion/observador.d.ts.map +1 -0
  443. package/dist/core/edicion/observador.js +183 -0
  444. package/dist/core/edicion/observador.js.map +1 -0
  445. package/dist/core/edicion/parecido.d.ts +53 -0
  446. package/dist/core/edicion/parecido.d.ts.map +1 -0
  447. package/dist/core/edicion/parecido.js +145 -0
  448. package/dist/core/edicion/parecido.js.map +1 -0
  449. package/dist/core/edicion/parseo.d.ts +58 -0
  450. package/dist/core/edicion/parseo.d.ts.map +1 -0
  451. package/dist/core/edicion/parseo.js +124 -0
  452. package/dist/core/edicion/parseo.js.map +1 -0
  453. package/dist/core/edicion/reparacion.d.ts +67 -0
  454. package/dist/core/edicion/reparacion.d.ts.map +1 -0
  455. package/dist/core/edicion/reparacion.js +202 -0
  456. package/dist/core/edicion/reparacion.js.map +1 -0
  457. package/dist/core/edicion/sangria.d.ts +121 -0
  458. package/dist/core/edicion/sangria.d.ts.map +1 -0
  459. package/dist/core/edicion/sangria.js +341 -0
  460. package/dist/core/edicion/sangria.js.map +1 -0
  461. package/dist/core/edicion/tipos.d.ts +58 -0
  462. package/dist/core/edicion/tipos.d.ts.map +1 -0
  463. package/dist/core/edicion/tipos.js +160 -0
  464. package/dist/core/edicion/tipos.js.map +1 -0
  465. package/dist/core/engine-personality.d.ts +12 -0
  466. package/dist/core/engine-personality.d.ts.map +1 -0
  467. package/dist/core/engine-personality.js +53 -0
  468. package/dist/core/engine-personality.js.map +1 -0
  469. package/dist/core/errores/proveedor.d.ts +53 -0
  470. package/dist/core/errores/proveedor.d.ts.map +1 -0
  471. package/dist/core/errores/proveedor.js +191 -0
  472. package/dist/core/errores/proveedor.js.map +1 -0
  473. package/dist/core/estructural/buscar.d.ts +61 -0
  474. package/dist/core/estructural/buscar.d.ts.map +1 -0
  475. package/dist/core/estructural/buscar.js +261 -0
  476. package/dist/core/estructural/buscar.js.map +1 -0
  477. package/dist/core/estructural/editar.d.ts +36 -0
  478. package/dist/core/estructural/editar.d.ts.map +1 -0
  479. package/dist/core/estructural/editar.js +123 -0
  480. package/dist/core/estructural/editar.js.map +1 -0
  481. package/dist/core/estructural/tools.d.ts +11 -0
  482. package/dist/core/estructural/tools.d.ts.map +1 -0
  483. package/dist/core/estructural/tools.js +100 -0
  484. package/dist/core/estructural/tools.js.map +1 -0
  485. package/dist/core/experimental.d.ts.map +1 -1
  486. package/dist/core/experimental.js +10 -1
  487. package/dist/core/experimental.js.map +1 -1
  488. package/dist/core/extensiones/suplantacion.d.ts +49 -0
  489. package/dist/core/extensiones/suplantacion.d.ts.map +1 -0
  490. package/dist/core/extensiones/suplantacion.js +61 -0
  491. package/dist/core/extensiones/suplantacion.js.map +1 -0
  492. package/dist/core/extensiones/vigilancia.d.ts +54 -0
  493. package/dist/core/extensiones/vigilancia.d.ts.map +1 -0
  494. package/dist/core/extensiones/vigilancia.js +217 -0
  495. package/dist/core/extensiones/vigilancia.js.map +1 -0
  496. package/dist/core/extensions/index.d.ts +1 -1
  497. package/dist/core/extensions/index.d.ts.map +1 -1
  498. package/dist/core/extensions/index.js.map +1 -1
  499. package/dist/core/extensions/loader.d.ts.map +1 -1
  500. package/dist/core/extensions/loader.js +21 -6
  501. package/dist/core/extensions/loader.js.map +1 -1
  502. package/dist/core/extensions/types.d.ts +23 -4
  503. package/dist/core/extensions/types.d.ts.map +1 -1
  504. package/dist/core/extensions/types.js.map +1 -1
  505. package/dist/core/harness/fuentes-de-contexto.d.ts +29 -0
  506. package/dist/core/harness/fuentes-de-contexto.d.ts.map +1 -0
  507. package/dist/core/harness/fuentes-de-contexto.js +44 -0
  508. package/dist/core/harness/fuentes-de-contexto.js.map +1 -0
  509. package/dist/core/harness/refine.d.ts +40 -0
  510. package/dist/core/harness/refine.d.ts.map +1 -0
  511. package/dist/core/harness/refine.js +109 -0
  512. package/dist/core/harness/refine.js.map +1 -0
  513. package/dist/core/harness/store.d.ts +75 -0
  514. package/dist/core/harness/store.d.ts.map +1 -0
  515. package/dist/core/harness/store.js +149 -0
  516. package/dist/core/harness/store.js.map +1 -0
  517. package/dist/core/hooks/contract.d.ts +85 -0
  518. package/dist/core/hooks/contract.d.ts.map +1 -0
  519. package/dist/core/hooks/contract.js +140 -0
  520. package/dist/core/hooks/contract.js.map +1 -0
  521. package/dist/core/hooks/runner.d.ts +42 -0
  522. package/dist/core/hooks/runner.d.ts.map +1 -0
  523. package/dist/core/hooks/runner.js +85 -0
  524. package/dist/core/hooks/runner.js.map +1 -0
  525. package/dist/core/hooks/session-hooks.d.ts +62 -0
  526. package/dist/core/hooks/session-hooks.d.ts.map +1 -0
  527. package/dist/core/hooks/session-hooks.js +84 -0
  528. package/dist/core/hooks/session-hooks.js.map +1 -0
  529. package/dist/core/importar/formatos.d.ts +69 -0
  530. package/dist/core/importar/formatos.d.ts.map +1 -0
  531. package/dist/core/importar/formatos.js +235 -0
  532. package/dist/core/importar/formatos.js.map +1 -0
  533. package/dist/core/interactivo/deteccion.d.ts +44 -0
  534. package/dist/core/interactivo/deteccion.d.ts.map +1 -0
  535. package/dist/core/interactivo/deteccion.js +82 -0
  536. package/dist/core/interactivo/deteccion.js.map +1 -0
  537. package/dist/core/interactivo/sesion.d.ts +50 -0
  538. package/dist/core/interactivo/sesion.d.ts.map +1 -0
  539. package/dist/core/interactivo/sesion.js +156 -0
  540. package/dist/core/interactivo/sesion.js.map +1 -0
  541. package/dist/core/interactivo/tools.d.ts +21 -0
  542. package/dist/core/interactivo/tools.d.ts.map +1 -0
  543. package/dist/core/interactivo/tools.js +122 -0
  544. package/dist/core/interactivo/tools.js.map +1 -0
  545. package/dist/core/keybindings.d.ts.map +1 -1
  546. package/dist/core/keybindings.js +2 -1
  547. package/dist/core/keybindings.js.map +1 -1
  548. package/dist/core/lectura/mapa.d.ts +70 -0
  549. package/dist/core/lectura/mapa.d.ts.map +1 -0
  550. package/dist/core/lectura/mapa.js +177 -0
  551. package/dist/core/lectura/mapa.js.map +1 -0
  552. package/dist/core/lectura/pdf.d.ts +49 -0
  553. package/dist/core/lectura/pdf.d.ts.map +1 -0
  554. package/dist/core/lectura/pdf.js +337 -0
  555. package/dist/core/lectura/pdf.js.map +1 -0
  556. package/dist/core/limpieza/comprobadores.d.ts +28 -0
  557. package/dist/core/limpieza/comprobadores.d.ts.map +1 -0
  558. package/dist/core/limpieza/comprobadores.js +311 -0
  559. package/dist/core/limpieza/comprobadores.js.map +1 -0
  560. package/dist/core/limpieza/parseo.d.ts +19 -0
  561. package/dist/core/limpieza/parseo.d.ts.map +1 -0
  562. package/dist/core/limpieza/parseo.js +124 -0
  563. package/dist/core/limpieza/parseo.js.map +1 -0
  564. package/dist/core/limpieza/reparacion.d.ts +77 -0
  565. package/dist/core/limpieza/reparacion.d.ts.map +1 -0
  566. package/dist/core/limpieza/reparacion.js +254 -0
  567. package/dist/core/limpieza/reparacion.js.map +1 -0
  568. package/dist/core/limpieza/tipos.d.ts +56 -0
  569. package/dist/core/limpieza/tipos.d.ts.map +1 -0
  570. package/dist/core/limpieza/tipos.js +9 -0
  571. package/dist/core/limpieza/tipos.js.map +1 -0
  572. package/dist/core/lsp/cliente.d.ts +52 -0
  573. package/dist/core/lsp/cliente.d.ts.map +1 -0
  574. package/dist/core/lsp/cliente.js +232 -0
  575. package/dist/core/lsp/cliente.js.map +1 -0
  576. package/dist/core/lsp/descubrimiento.d.ts +62 -0
  577. package/dist/core/lsp/descubrimiento.d.ts.map +1 -0
  578. package/dist/core/lsp/descubrimiento.js +152 -0
  579. package/dist/core/lsp/descubrimiento.js.map +1 -0
  580. package/dist/core/lsp/ediciones.d.ts +59 -0
  581. package/dist/core/lsp/ediciones.d.ts.map +1 -0
  582. package/dist/core/lsp/ediciones.js +89 -0
  583. package/dist/core/lsp/ediciones.js.map +1 -0
  584. package/dist/core/lsp/extension.d.ts +28 -0
  585. package/dist/core/lsp/extension.d.ts.map +1 -0
  586. package/dist/core/lsp/extension.js +34 -0
  587. package/dist/core/lsp/extension.js.map +1 -0
  588. package/dist/core/lsp/tools.d.ts +45 -0
  589. package/dist/core/lsp/tools.d.ts.map +1 -0
  590. package/dist/core/lsp/tools.js +265 -0
  591. package/dist/core/lsp/tools.js.map +1 -0
  592. package/dist/core/mcp/client.d.ts +60 -0
  593. package/dist/core/mcp/client.d.ts.map +1 -0
  594. package/dist/core/mcp/client.js +139 -0
  595. package/dist/core/mcp/client.js.map +1 -0
  596. package/dist/core/mcp/manager.d.ts +86 -0
  597. package/dist/core/mcp/manager.d.ts.map +1 -0
  598. package/dist/core/mcp/manager.js +124 -0
  599. package/dist/core/mcp/manager.js.map +1 -0
  600. package/dist/core/mcp/tools.d.ts +15 -0
  601. package/dist/core/mcp/tools.d.ts.map +1 -0
  602. package/dist/core/mcp/tools.js +84 -0
  603. package/dist/core/mcp/tools.js.map +1 -0
  604. package/dist/core/memory-engine/audit-export.d.ts +56 -0
  605. package/dist/core/memory-engine/audit-export.d.ts.map +1 -0
  606. package/dist/core/memory-engine/audit-export.js +100 -0
  607. package/dist/core/memory-engine/audit-export.js.map +1 -0
  608. package/dist/core/memory-engine/audit-indice.d.ts +153 -0
  609. package/dist/core/memory-engine/audit-indice.d.ts.map +1 -0
  610. package/dist/core/memory-engine/audit-indice.js +271 -0
  611. package/dist/core/memory-engine/audit-indice.js.map +1 -0
  612. package/dist/core/memory-engine/audit.d.ts +18 -6
  613. package/dist/core/memory-engine/audit.d.ts.map +1 -1
  614. package/dist/core/memory-engine/audit.js +32 -50
  615. package/dist/core/memory-engine/audit.js.map +1 -1
  616. package/dist/core/memory-engine/engine.d.ts +21 -4
  617. package/dist/core/memory-engine/engine.d.ts.map +1 -1
  618. package/dist/core/memory-engine/engine.js +219 -55
  619. package/dist/core/memory-engine/engine.js.map +1 -1
  620. package/dist/core/memory-engine/inverted-index.d.ts.map +1 -1
  621. package/dist/core/memory-engine/inverted-index.js +67 -10
  622. package/dist/core/memory-engine/inverted-index.js.map +1 -1
  623. package/dist/core/memory-engine/keychain.d.ts.map +1 -1
  624. package/dist/core/memory-engine/keychain.js +1 -6
  625. package/dist/core/memory-engine/keychain.js.map +1 -1
  626. package/dist/core/memory-engine/observation-store.d.ts +0 -1
  627. package/dist/core/memory-engine/observation-store.d.ts.map +1 -1
  628. package/dist/core/memory-engine/observation-store.js +40 -12
  629. package/dist/core/memory-engine/observation-store.js.map +1 -1
  630. package/dist/core/memory-engine/refinements.d.ts +51 -0
  631. package/dist/core/memory-engine/refinements.d.ts.map +1 -0
  632. package/dist/core/memory-engine/refinements.js +99 -0
  633. package/dist/core/memory-engine/refinements.js.map +1 -0
  634. package/dist/core/memory-engine/scanner.d.ts.map +1 -1
  635. package/dist/core/memory-engine/scanner.js +25 -5
  636. package/dist/core/memory-engine/scanner.js.map +1 -1
  637. package/dist/core/memory-engine/security.d.ts.map +1 -1
  638. package/dist/core/memory-engine/security.js +131 -23
  639. package/dist/core/memory-engine/security.js.map +1 -1
  640. package/dist/core/memory-engine/session-indexer.d.ts.map +1 -1
  641. package/dist/core/memory-engine/session-indexer.js +8 -2
  642. package/dist/core/memory-engine/session-indexer.js.map +1 -1
  643. package/dist/core/memory-engine/tools.d.ts +2 -2
  644. package/dist/core/memory-engine/tools.d.ts.map +1 -1
  645. package/dist/core/memory-engine/tools.js +41 -8
  646. package/dist/core/memory-engine/tools.js.map +1 -1
  647. package/dist/core/memory-engine/types.d.ts +2 -0
  648. package/dist/core/memory-engine/types.d.ts.map +1 -1
  649. package/dist/core/memory-engine/types.js.map +1 -1
  650. package/dist/core/memory-engine/vault.d.ts.map +1 -1
  651. package/dist/core/memory-engine/vault.js +2 -2
  652. package/dist/core/memory-engine/vault.js.map +1 -1
  653. package/dist/core/model-config.d.ts.map +1 -1
  654. package/dist/core/model-config.js +2 -1
  655. package/dist/core/model-config.js.map +1 -1
  656. package/dist/core/model-resolver.d.ts +1 -0
  657. package/dist/core/model-resolver.d.ts.map +1 -1
  658. package/dist/core/model-resolver.js +19 -7
  659. package/dist/core/model-resolver.js.map +1 -1
  660. package/dist/core/models-store.d.ts.map +1 -1
  661. package/dist/core/models-store.js +2 -1
  662. package/dist/core/models-store.js.map +1 -1
  663. package/dist/core/muestreo-restringido.d.ts +49 -0
  664. package/dist/core/muestreo-restringido.d.ts.map +1 -0
  665. package/dist/core/muestreo-restringido.js +65 -0
  666. package/dist/core/muestreo-restringido.js.map +1 -0
  667. package/dist/core/orphan-process-journal.d.ts +48 -0
  668. package/dist/core/orphan-process-journal.d.ts.map +1 -0
  669. package/dist/core/orphan-process-journal.js +116 -0
  670. package/dist/core/orphan-process-journal.js.map +1 -0
  671. package/dist/core/package-manager.d.ts.map +1 -1
  672. package/dist/core/package-manager.js +11 -6
  673. package/dist/core/package-manager.js.map +1 -1
  674. package/dist/core/pi-manifest.d.ts.map +1 -1
  675. package/dist/core/pi-manifest.js +2 -1
  676. package/dist/core/pi-manifest.js.map +1 -1
  677. package/dist/core/privacidad/categorias-especiales.d.ts +186 -0
  678. package/dist/core/privacidad/categorias-especiales.d.ts.map +1 -0
  679. package/dist/core/privacidad/categorias-especiales.js +745 -0
  680. package/dist/core/privacidad/categorias-especiales.js.map +1 -0
  681. package/dist/core/privacidad/tapar.d.ts +48 -0
  682. package/dist/core/privacidad/tapar.d.ts.map +1 -0
  683. package/dist/core/privacidad/tapar.js +66 -0
  684. package/dist/core/privacidad/tapar.js.map +1 -0
  685. package/dist/core/prompt-cache/diagnostics.d.ts +33 -0
  686. package/dist/core/prompt-cache/diagnostics.d.ts.map +1 -0
  687. package/dist/core/prompt-cache/diagnostics.js +100 -0
  688. package/dist/core/prompt-cache/diagnostics.js.map +1 -0
  689. package/dist/core/prompt-cache/index.d.ts +33 -0
  690. package/dist/core/prompt-cache/index.d.ts.map +1 -0
  691. package/dist/core/prompt-cache/index.js +189 -0
  692. package/dist/core/prompt-cache/index.js.map +1 -0
  693. package/dist/core/prompt-cache/payload.d.ts +58 -0
  694. package/dist/core/prompt-cache/payload.d.ts.map +1 -0
  695. package/dist/core/prompt-cache/payload.js +122 -0
  696. package/dist/core/prompt-cache/payload.js.map +1 -0
  697. package/dist/core/prompt-cache/stabilize.d.ts +65 -0
  698. package/dist/core/prompt-cache/stabilize.d.ts.map +1 -0
  699. package/dist/core/prompt-cache/stabilize.js +137 -0
  700. package/dist/core/prompt-cache/stabilize.js.map +1 -0
  701. package/dist/core/prompt-cache/stats.d.ts +55 -0
  702. package/dist/core/prompt-cache/stats.d.ts.map +1 -0
  703. package/dist/core/prompt-cache/stats.js +158 -0
  704. package/dist/core/prompt-cache/stats.js.map +1 -0
  705. package/dist/core/prompt-eleccion.d.ts +38 -0
  706. package/dist/core/prompt-eleccion.d.ts.map +1 -0
  707. package/dist/core/prompt-eleccion.js +46 -0
  708. package/dist/core/prompt-eleccion.js.map +1 -0
  709. package/dist/core/prompt-optimizer.d.ts +53 -0
  710. package/dist/core/prompt-optimizer.d.ts.map +1 -0
  711. package/dist/core/prompt-optimizer.js +138 -0
  712. package/dist/core/prompt-optimizer.js.map +1 -0
  713. package/dist/core/prompts/montar.d.ts +75 -0
  714. package/dist/core/prompts/montar.d.ts.map +1 -0
  715. package/dist/core/prompts/montar.js +146 -0
  716. package/dist/core/prompts/montar.js.map +1 -0
  717. package/dist/core/prompts/plantilla.d.ts +54 -0
  718. package/dist/core/prompts/plantilla.d.ts.map +1 -0
  719. package/dist/core/prompts/plantilla.js +153 -0
  720. package/dist/core/prompts/plantilla.js.map +1 -0
  721. package/dist/core/prompts/sistema.md +134 -0
  722. package/dist/core/provider-attribution.d.ts +24 -2
  723. package/dist/core/provider-attribution.d.ts.map +1 -1
  724. package/dist/core/provider-attribution.js +24 -42
  725. package/dist/core/provider-attribution.js.map +1 -1
  726. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  727. package/dist/core/remote-catalog-provider.js +2 -1
  728. package/dist/core/remote-catalog-provider.js.map +1 -1
  729. package/dist/core/remoto/destino.d.ts +38 -0
  730. package/dist/core/remoto/destino.d.ts.map +1 -0
  731. package/dist/core/remoto/destino.js +105 -0
  732. package/dist/core/remoto/destino.js.map +1 -0
  733. package/dist/core/remoto/ejecutor.d.ts +59 -0
  734. package/dist/core/remoto/ejecutor.d.ts.map +1 -0
  735. package/dist/core/remoto/ejecutor.js +225 -0
  736. package/dist/core/remoto/ejecutor.js.map +1 -0
  737. package/dist/core/remoto/ficheros.d.ts +29 -0
  738. package/dist/core/remoto/ficheros.d.ts.map +1 -0
  739. package/dist/core/remoto/ficheros.js +90 -0
  740. package/dist/core/remoto/ficheros.js.map +1 -0
  741. package/dist/core/remoto/registro-extension.d.ts +15 -0
  742. package/dist/core/remoto/registro-extension.d.ts.map +1 -0
  743. package/dist/core/remoto/registro-extension.js +17 -0
  744. package/dist/core/remoto/registro-extension.js.map +1 -0
  745. package/dist/core/remoto/tools.d.ts +28 -0
  746. package/dist/core/remoto/tools.d.ts.map +1 -0
  747. package/dist/core/remoto/tools.js +31 -0
  748. package/dist/core/remoto/tools.js.map +1 -0
  749. package/dist/core/resource-loader.d.ts +58 -0
  750. package/dist/core/resource-loader.d.ts.map +1 -1
  751. package/dist/core/resource-loader.js +326 -8
  752. package/dist/core/resource-loader.js.map +1 -1
  753. package/dist/core/revision/hallazgo.d.ts +51 -0
  754. package/dist/core/revision/hallazgo.d.ts.map +1 -0
  755. package/dist/core/revision/hallazgo.js +73 -0
  756. package/dist/core/revision/hallazgo.js.map +1 -0
  757. package/dist/core/revision/revisor.d.ts +81 -0
  758. package/dist/core/revision/revisor.d.ts.map +1 -0
  759. package/dist/core/revision/revisor.js +132 -0
  760. package/dist/core/revision/revisor.js.map +1 -0
  761. package/dist/core/revision/sarif.d.ts +30 -0
  762. package/dist/core/revision/sarif.d.ts.map +1 -0
  763. package/dist/core/revision/sarif.js +83 -0
  764. package/dist/core/revision/sarif.js.map +1 -0
  765. package/dist/core/scheduler/scheduler.d.ts +87 -0
  766. package/dist/core/scheduler/scheduler.d.ts.map +1 -0
  767. package/dist/core/scheduler/scheduler.js +178 -0
  768. package/dist/core/scheduler/scheduler.js.map +1 -0
  769. package/dist/core/sdk.d.ts +8 -0
  770. package/dist/core/sdk.d.ts.map +1 -1
  771. package/dist/core/sdk.js +11 -1
  772. package/dist/core/sdk.js.map +1 -1
  773. package/dist/core/sesion/cerrar-llamadas-abiertas.d.ts +49 -0
  774. package/dist/core/sesion/cerrar-llamadas-abiertas.d.ts.map +1 -0
  775. package/dist/core/sesion/cerrar-llamadas-abiertas.js +77 -0
  776. package/dist/core/sesion/cerrar-llamadas-abiertas.js.map +1 -0
  777. package/dist/core/session-manager.d.ts.map +1 -1
  778. package/dist/core/session-manager.js +2 -1
  779. package/dist/core/session-manager.js.map +1 -1
  780. package/dist/core/settings-diagnostics.d.ts +9 -0
  781. package/dist/core/settings-diagnostics.d.ts.map +1 -0
  782. package/dist/core/settings-diagnostics.js +21 -0
  783. package/dist/core/settings-diagnostics.js.map +1 -0
  784. package/dist/core/settings-manager.d.ts +156 -0
  785. package/dist/core/settings-manager.d.ts.map +1 -1
  786. package/dist/core/settings-manager.js +255 -10
  787. package/dist/core/settings-manager.js.map +1 -1
  788. package/dist/core/skills.d.ts.map +1 -1
  789. package/dist/core/skills.js +51 -33
  790. package/dist/core/skills.js.map +1 -1
  791. package/dist/core/slash-commands.d.ts.map +1 -1
  792. package/dist/core/slash-commands.js +2 -1
  793. package/dist/core/slash-commands.js.map +1 -1
  794. package/dist/core/system-prompt.d.ts +17 -0
  795. package/dist/core/system-prompt.d.ts.map +1 -1
  796. package/dist/core/system-prompt.js +13 -5
  797. package/dist/core/system-prompt.js.map +1 -1
  798. package/dist/core/telemetria/otlp.d.ts +122 -0
  799. package/dist/core/telemetria/otlp.d.ts.map +1 -0
  800. package/dist/core/telemetria/otlp.js +373 -0
  801. package/dist/core/telemetria/otlp.js.map +1 -0
  802. package/dist/core/tools/coercion-argumentos.d.ts +48 -0
  803. package/dist/core/tools/coercion-argumentos.d.ts.map +1 -0
  804. package/dist/core/tools/coercion-argumentos.js +99 -0
  805. package/dist/core/tools/coercion-argumentos.js.map +1 -0
  806. package/dist/core/tools/edit-diff.d.ts +0 -12
  807. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  808. package/dist/core/tools/edit-diff.js +234 -12
  809. package/dist/core/tools/edit-diff.js.map +1 -1
  810. package/dist/core/tools/edit.d.ts.map +1 -1
  811. package/dist/core/tools/edit.js +28 -5
  812. package/dist/core/tools/edit.js.map +1 -1
  813. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  814. package/dist/core/tools/file-mutation-queue.js +5 -0
  815. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  816. package/dist/core/tools/index.d.ts.map +1 -1
  817. package/dist/core/tools/index.js +2 -2
  818. package/dist/core/tools/index.js.map +1 -1
  819. package/dist/core/tools/json-tolerante.d.ts +30 -0
  820. package/dist/core/tools/json-tolerante.d.ts.map +1 -0
  821. package/dist/core/tools/json-tolerante.js +70 -0
  822. package/dist/core/tools/json-tolerante.js.map +1 -0
  823. package/dist/core/tools/project-memory-tool.d.ts.map +1 -1
  824. package/dist/core/tools/project-memory-tool.js +4 -1
  825. package/dist/core/tools/project-memory-tool.js.map +1 -1
  826. package/dist/core/tools/read.d.ts.map +1 -1
  827. package/dist/core/tools/read.js +17 -0
  828. package/dist/core/tools/read.js.map +1 -1
  829. package/dist/core/tools/tool-definition-wrapper.d.ts +14 -1
  830. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  831. package/dist/core/tools/tool-definition-wrapper.js +17 -1
  832. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  833. package/dist/core/trust-manager.d.ts.map +1 -1
  834. package/dist/core/trust-manager.js +2 -1
  835. package/dist/core/trust-manager.js.map +1 -1
  836. package/dist/core/turno-vacio/detectar.d.ts +38 -0
  837. package/dist/core/turno-vacio/detectar.d.ts.map +1 -0
  838. package/dist/core/turno-vacio/detectar.js +66 -0
  839. package/dist/core/turno-vacio/detectar.js.map +1 -0
  840. package/dist/core/undo/journal.d.ts +57 -0
  841. package/dist/core/undo/journal.d.ts.map +1 -0
  842. package/dist/core/undo/journal.js +178 -0
  843. package/dist/core/undo/journal.js.map +1 -0
  844. package/dist/core/urls-internas/auditoria.d.ts +10 -0
  845. package/dist/core/urls-internas/auditoria.d.ts.map +1 -0
  846. package/dist/core/urls-internas/auditoria.js +42 -0
  847. package/dist/core/urls-internas/auditoria.js.map +1 -0
  848. package/dist/core/urls-internas/boveda.d.ts +13 -0
  849. package/dist/core/urls-internas/boveda.d.ts.map +1 -0
  850. package/dist/core/urls-internas/boveda.js +40 -0
  851. package/dist/core/urls-internas/boveda.js.map +1 -0
  852. package/dist/core/urls-internas/lector.d.ts +30 -0
  853. package/dist/core/urls-internas/lector.d.ts.map +1 -0
  854. package/dist/core/urls-internas/lector.js +56 -0
  855. package/dist/core/urls-internas/lector.js.map +1 -0
  856. package/dist/core/urls-internas/memoria.d.ts +11 -0
  857. package/dist/core/urls-internas/memoria.d.ts.map +1 -0
  858. package/dist/core/urls-internas/memoria.js +25 -0
  859. package/dist/core/urls-internas/memoria.js.map +1 -0
  860. package/dist/core/urls-internas/parse.d.ts +28 -0
  861. package/dist/core/urls-internas/parse.d.ts.map +1 -0
  862. package/dist/core/urls-internas/parse.js +32 -0
  863. package/dist/core/urls-internas/parse.js.map +1 -0
  864. package/dist/core/urls-internas/reglas.d.ts +10 -0
  865. package/dist/core/urls-internas/reglas.d.ts.map +1 -0
  866. package/dist/core/urls-internas/reglas.js +31 -0
  867. package/dist/core/urls-internas/reglas.js.map +1 -0
  868. package/dist/core/usage/aggregate.d.ts +68 -0
  869. package/dist/core/usage/aggregate.d.ts.map +1 -0
  870. package/dist/core/usage/aggregate.js +93 -0
  871. package/dist/core/usage/aggregate.js.map +1 -0
  872. package/dist/core/usage/cuota/anthropic.d.ts +10 -0
  873. package/dist/core/usage/cuota/anthropic.d.ts.map +1 -0
  874. package/dist/core/usage/cuota/anthropic.js +63 -0
  875. package/dist/core/usage/cuota/anthropic.js.map +1 -0
  876. package/dist/core/usage/cuota/cache.d.ts +20 -0
  877. package/dist/core/usage/cuota/cache.d.ts.map +1 -0
  878. package/dist/core/usage/cuota/cache.js +36 -0
  879. package/dist/core/usage/cuota/cache.js.map +1 -0
  880. package/dist/core/usage/cuota/github-copilot.d.ts +9 -0
  881. package/dist/core/usage/cuota/github-copilot.d.ts.map +1 -0
  882. package/dist/core/usage/cuota/github-copilot.js +67 -0
  883. package/dist/core/usage/cuota/github-copilot.js.map +1 -0
  884. package/dist/core/usage/cuota/google-gemini.d.ts +9 -0
  885. package/dist/core/usage/cuota/google-gemini.d.ts.map +1 -0
  886. package/dist/core/usage/cuota/google-gemini.js +72 -0
  887. package/dist/core/usage/cuota/google-gemini.js.map +1 -0
  888. package/dist/core/usage/cuota/index.d.ts +25 -0
  889. package/dist/core/usage/cuota/index.d.ts.map +1 -0
  890. package/dist/core/usage/cuota/index.js +50 -0
  891. package/dist/core/usage/cuota/index.js.map +1 -0
  892. package/dist/core/usage/cuota/openai-codex.d.ts +9 -0
  893. package/dist/core/usage/cuota/openai-codex.d.ts.map +1 -0
  894. package/dist/core/usage/cuota/openai-codex.js +59 -0
  895. package/dist/core/usage/cuota/openai-codex.js.map +1 -0
  896. package/dist/core/usage/cuota/openrouter.d.ts +10 -0
  897. package/dist/core/usage/cuota/openrouter.d.ts.map +1 -0
  898. package/dist/core/usage/cuota/openrouter.js +47 -0
  899. package/dist/core/usage/cuota/openrouter.js.map +1 -0
  900. package/dist/core/usage/cuota/tipos.d.ts +50 -0
  901. package/dist/core/usage/cuota/tipos.d.ts.map +1 -0
  902. package/dist/core/usage/cuota/tipos.js +25 -0
  903. package/dist/core/usage/cuota/tipos.js.map +1 -0
  904. package/dist/core/web/busqueda-nativa.d.ts +82 -0
  905. package/dist/core/web/busqueda-nativa.d.ts.map +1 -0
  906. package/dist/core/web/busqueda-nativa.js +163 -0
  907. package/dist/core/web/busqueda-nativa.js.map +1 -0
  908. package/dist/core/web/destino.d.ts +58 -0
  909. package/dist/core/web/destino.d.ts.map +1 -0
  910. package/dist/core/web/destino.js +127 -0
  911. package/dist/core/web/destino.js.map +1 -0
  912. package/dist/core/web/proveedores/brave.d.ts +6 -0
  913. package/dist/core/web/proveedores/brave.d.ts.map +1 -0
  914. package/dist/core/web/proveedores/brave.js +20 -0
  915. package/dist/core/web/proveedores/brave.js.map +1 -0
  916. package/dist/core/web/proveedores/claves.d.ts +19 -0
  917. package/dist/core/web/proveedores/claves.d.ts.map +1 -0
  918. package/dist/core/web/proveedores/claves.js +36 -0
  919. package/dist/core/web/proveedores/claves.js.map +1 -0
  920. package/dist/core/web/proveedores/duckduckgo.d.ts +3 -0
  921. package/dist/core/web/proveedores/duckduckgo.d.ts.map +1 -0
  922. package/dist/core/web/proveedores/duckduckgo.js +109 -0
  923. package/dist/core/web/proveedores/duckduckgo.js.map +1 -0
  924. package/dist/core/web/proveedores/ecosia.d.ts +3 -0
  925. package/dist/core/web/proveedores/ecosia.d.ts.map +1 -0
  926. package/dist/core/web/proveedores/ecosia.js +72 -0
  927. package/dist/core/web/proveedores/ecosia.js.map +1 -0
  928. package/dist/core/web/proveedores/exa.d.ts +6 -0
  929. package/dist/core/web/proveedores/exa.d.ts.map +1 -0
  930. package/dist/core/web/proveedores/exa.js +24 -0
  931. package/dist/core/web/proveedores/exa.js.map +1 -0
  932. package/dist/core/web/proveedores/mojeek.d.ts +3 -0
  933. package/dist/core/web/proveedores/mojeek.d.ts.map +1 -0
  934. package/dist/core/web/proveedores/mojeek.js +65 -0
  935. package/dist/core/web/proveedores/mojeek.js.map +1 -0
  936. package/dist/core/web/proveedores/navegador.d.ts +10 -0
  937. package/dist/core/web/proveedores/navegador.d.ts.map +1 -0
  938. package/dist/core/web/proveedores/navegador.js +13 -0
  939. package/dist/core/web/proveedores/navegador.js.map +1 -0
  940. package/dist/core/web/proveedores/registro.d.ts +43 -0
  941. package/dist/core/web/proveedores/registro.d.ts.map +1 -0
  942. package/dist/core/web/proveedores/registro.js +49 -0
  943. package/dist/core/web/proveedores/registro.js.map +1 -0
  944. package/dist/core/web/proveedores/searxng.d.ts +9 -0
  945. package/dist/core/web/proveedores/searxng.d.ts.map +1 -0
  946. package/dist/core/web/proveedores/searxng.js +17 -0
  947. package/dist/core/web/proveedores/searxng.js.map +1 -0
  948. package/dist/core/web/proveedores/serper.d.ts +9 -0
  949. package/dist/core/web/proveedores/serper.d.ts.map +1 -0
  950. package/dist/core/web/proveedores/serper.js +19 -0
  951. package/dist/core/web/proveedores/serper.js.map +1 -0
  952. package/dist/core/web/proveedores/tavily.d.ts +6 -0
  953. package/dist/core/web/proveedores/tavily.d.ts.map +1 -0
  954. package/dist/core/web/proveedores/tavily.js +19 -0
  955. package/dist/core/web/proveedores/tavily.js.map +1 -0
  956. package/dist/core/web/proveedores/tipos.d.ts +36 -0
  957. package/dist/core/web/proveedores/tipos.d.ts.map +1 -0
  958. package/dist/core/web/proveedores/tipos.js +10 -0
  959. package/dist/core/web/proveedores/tipos.js.map +1 -0
  960. package/dist/core/web/registro-red.d.ts +43 -0
  961. package/dist/core/web/registro-red.d.ts.map +1 -0
  962. package/dist/core/web/registro-red.js +86 -0
  963. package/dist/core/web/registro-red.js.map +1 -0
  964. package/dist/core/web/scrapers/cisa-kev.d.ts +10 -0
  965. package/dist/core/web/scrapers/cisa-kev.d.ts.map +1 -0
  966. package/dist/core/web/scrapers/cisa-kev.js +38 -0
  967. package/dist/core/web/scrapers/cisa-kev.js.map +1 -0
  968. package/dist/core/web/scrapers/crates-io.d.ts +11 -0
  969. package/dist/core/web/scrapers/crates-io.d.ts.map +1 -0
  970. package/dist/core/web/scrapers/crates-io.js +29 -0
  971. package/dist/core/web/scrapers/crates-io.js.map +1 -0
  972. package/dist/core/web/scrapers/docs-rs.d.ts +10 -0
  973. package/dist/core/web/scrapers/docs-rs.d.ts.map +1 -0
  974. package/dist/core/web/scrapers/docs-rs.js +35 -0
  975. package/dist/core/web/scrapers/docs-rs.js.map +1 -0
  976. package/dist/core/web/scrapers/github.d.ts +3 -0
  977. package/dist/core/web/scrapers/github.d.ts.map +1 -0
  978. package/dist/core/web/scrapers/github.js +72 -0
  979. package/dist/core/web/scrapers/github.js.map +1 -0
  980. package/dist/core/web/scrapers/go-pkg.d.ts +7 -0
  981. package/dist/core/web/scrapers/go-pkg.d.ts.map +1 -0
  982. package/dist/core/web/scrapers/go-pkg.js +30 -0
  983. package/dist/core/web/scrapers/go-pkg.js.map +1 -0
  984. package/dist/core/web/scrapers/hex.d.ts +6 -0
  985. package/dist/core/web/scrapers/hex.d.ts.map +1 -0
  986. package/dist/core/web/scrapers/hex.js +27 -0
  987. package/dist/core/web/scrapers/hex.js.map +1 -0
  988. package/dist/core/web/scrapers/maven.d.ts +8 -0
  989. package/dist/core/web/scrapers/maven.d.ts.map +1 -0
  990. package/dist/core/web/scrapers/maven.js +41 -0
  991. package/dist/core/web/scrapers/maven.js.map +1 -0
  992. package/dist/core/web/scrapers/mdn.d.ts +6 -0
  993. package/dist/core/web/scrapers/mdn.d.ts.map +1 -0
  994. package/dist/core/web/scrapers/mdn.js +28 -0
  995. package/dist/core/web/scrapers/mdn.js.map +1 -0
  996. package/dist/core/web/scrapers/npm.d.ts +11 -0
  997. package/dist/core/web/scrapers/npm.d.ts.map +1 -0
  998. package/dist/core/web/scrapers/npm.js +57 -0
  999. package/dist/core/web/scrapers/npm.js.map +1 -0
  1000. package/dist/core/web/scrapers/nuget.d.ts +8 -0
  1001. package/dist/core/web/scrapers/nuget.d.ts.map +1 -0
  1002. package/dist/core/web/scrapers/nuget.js +22 -0
  1003. package/dist/core/web/scrapers/nuget.js.map +1 -0
  1004. package/dist/core/web/scrapers/nvd.d.ts +7 -0
  1005. package/dist/core/web/scrapers/nvd.d.ts.map +1 -0
  1006. package/dist/core/web/scrapers/nvd.js +37 -0
  1007. package/dist/core/web/scrapers/nvd.js.map +1 -0
  1008. package/dist/core/web/scrapers/pypi.d.ts +6 -0
  1009. package/dist/core/web/scrapers/pypi.d.ts.map +1 -0
  1010. package/dist/core/web/scrapers/pypi.js +31 -0
  1011. package/dist/core/web/scrapers/pypi.js.map +1 -0
  1012. package/dist/core/web/scrapers/registro.d.ts +13 -0
  1013. package/dist/core/web/scrapers/registro.d.ts.map +1 -0
  1014. package/dist/core/web/scrapers/registro.js +65 -0
  1015. package/dist/core/web/scrapers/registro.js.map +1 -0
  1016. package/dist/core/web/scrapers/rubygems.d.ts +6 -0
  1017. package/dist/core/web/scrapers/rubygems.d.ts.map +1 -0
  1018. package/dist/core/web/scrapers/rubygems.js +23 -0
  1019. package/dist/core/web/scrapers/rubygems.js.map +1 -0
  1020. package/dist/core/web/scrapers/stackoverflow.d.ts +3 -0
  1021. package/dist/core/web/scrapers/stackoverflow.d.ts.map +1 -0
  1022. package/dist/core/web/scrapers/stackoverflow.js +46 -0
  1023. package/dist/core/web/scrapers/stackoverflow.js.map +1 -0
  1024. package/dist/core/web/scrapers/tipos.d.ts +42 -0
  1025. package/dist/core/web/scrapers/tipos.d.ts.map +1 -0
  1026. package/dist/core/web/scrapers/tipos.js +23 -0
  1027. package/dist/core/web/scrapers/tipos.js.map +1 -0
  1028. package/dist/core/web/texto.d.ts +10 -0
  1029. package/dist/core/web/texto.d.ts.map +1 -0
  1030. package/dist/core/web/texto.js +26 -0
  1031. package/dist/core/web/texto.js.map +1 -0
  1032. package/dist/core/web/tools.d.ts +91 -0
  1033. package/dist/core/web/tools.d.ts.map +1 -0
  1034. package/dist/core/web/tools.js +304 -0
  1035. package/dist/core/web/tools.js.map +1 -0
  1036. package/dist/core/wiki/almacen.d.ts +33 -0
  1037. package/dist/core/wiki/almacen.d.ts.map +1 -0
  1038. package/dist/core/wiki/almacen.js +93 -0
  1039. package/dist/core/wiki/almacen.js.map +1 -0
  1040. package/dist/core/wiki/citas.d.ts +111 -0
  1041. package/dist/core/wiki/citas.d.ts.map +1 -0
  1042. package/dist/core/wiki/citas.js +146 -0
  1043. package/dist/core/wiki/citas.js.map +1 -0
  1044. package/dist/core/workflows/agent-runner.d.ts +88 -0
  1045. package/dist/core/workflows/agent-runner.d.ts.map +1 -0
  1046. package/dist/core/workflows/agent-runner.js +312 -0
  1047. package/dist/core/workflows/agent-runner.js.map +1 -0
  1048. package/dist/core/workflows/builtins.d.ts +41 -0
  1049. package/dist/core/workflows/builtins.d.ts.map +1 -0
  1050. package/dist/core/workflows/builtins.js +283 -0
  1051. package/dist/core/workflows/builtins.js.map +1 -0
  1052. package/dist/core/workflows/contrato/esquema.d.ts +32 -0
  1053. package/dist/core/workflows/contrato/esquema.d.ts.map +1 -0
  1054. package/dist/core/workflows/contrato/esquema.js +25 -0
  1055. package/dist/core/workflows/contrato/esquema.js.map +1 -0
  1056. package/dist/core/workflows/contrato/reparar-argumentos.d.ts +69 -0
  1057. package/dist/core/workflows/contrato/reparar-argumentos.d.ts.map +1 -0
  1058. package/dist/core/workflows/contrato/reparar-argumentos.js +117 -0
  1059. package/dist/core/workflows/contrato/reparar-argumentos.js.map +1 -0
  1060. package/dist/core/workflows/contrato/validador.d.ts +30 -0
  1061. package/dist/core/workflows/contrato/validador.d.ts.map +1 -0
  1062. package/dist/core/workflows/contrato/validador.js +56 -0
  1063. package/dist/core/workflows/contrato/validador.js.map +1 -0
  1064. package/dist/core/workflows/contrato/yield.d.ts +65 -0
  1065. package/dist/core/workflows/contrato/yield.d.ts.map +1 -0
  1066. package/dist/core/workflows/contrato/yield.js +80 -0
  1067. package/dist/core/workflows/contrato/yield.js.map +1 -0
  1068. package/dist/core/workflows/goal-engine/engine.d.ts +151 -0
  1069. package/dist/core/workflows/goal-engine/engine.d.ts.map +1 -0
  1070. package/dist/core/workflows/goal-engine/engine.js +503 -0
  1071. package/dist/core/workflows/goal-engine/engine.js.map +1 -0
  1072. package/dist/core/workflows/goal-engine/errors.d.ts +7 -0
  1073. package/dist/core/workflows/goal-engine/errors.d.ts.map +1 -0
  1074. package/dist/core/workflows/goal-engine/errors.js +9 -0
  1075. package/dist/core/workflows/goal-engine/errors.js.map +1 -0
  1076. package/dist/core/workflows/goal-engine/index.d.ts +13 -0
  1077. package/dist/core/workflows/goal-engine/index.d.ts.map +1 -0
  1078. package/dist/core/workflows/goal-engine/index.js +8 -0
  1079. package/dist/core/workflows/goal-engine/index.js.map +1 -0
  1080. package/dist/core/workflows/goal-engine/persistence.d.ts +31 -0
  1081. package/dist/core/workflows/goal-engine/persistence.d.ts.map +1 -0
  1082. package/dist/core/workflows/goal-engine/persistence.js +145 -0
  1083. package/dist/core/workflows/goal-engine/persistence.js.map +1 -0
  1084. package/dist/core/workflows/goal-engine/prompts.d.ts +37 -0
  1085. package/dist/core/workflows/goal-engine/prompts.d.ts.map +1 -0
  1086. package/dist/core/workflows/goal-engine/prompts.js +131 -0
  1087. package/dist/core/workflows/goal-engine/prompts.js.map +1 -0
  1088. package/dist/core/workflows/goal-engine/state.d.ts +41 -0
  1089. package/dist/core/workflows/goal-engine/state.d.ts.map +1 -0
  1090. package/dist/core/workflows/goal-engine/state.js +397 -0
  1091. package/dist/core/workflows/goal-engine/state.js.map +1 -0
  1092. package/dist/core/workflows/goal-engine/tools.d.ts +31 -0
  1093. package/dist/core/workflows/goal-engine/tools.d.ts.map +1 -0
  1094. package/dist/core/workflows/goal-engine/tools.js +211 -0
  1095. package/dist/core/workflows/goal-engine/tools.js.map +1 -0
  1096. package/dist/core/workflows/goal-engine/types.d.ts +286 -0
  1097. package/dist/core/workflows/goal-engine/types.d.ts.map +1 -0
  1098. package/dist/core/workflows/goal-engine/types.js +17 -0
  1099. package/dist/core/workflows/goal-engine/types.js.map +1 -0
  1100. package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts +23 -0
  1101. package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts.map +1 -0
  1102. package/dist/core/workflows/goal-engine/worktree-fingerprint.js +72 -0
  1103. package/dist/core/workflows/goal-engine/worktree-fingerprint.js.map +1 -0
  1104. package/dist/core/workflows/graph-sync.d.ts +67 -0
  1105. package/dist/core/workflows/graph-sync.d.ts.map +1 -0
  1106. package/dist/core/workflows/graph-sync.js +188 -0
  1107. package/dist/core/workflows/graph-sync.js.map +1 -0
  1108. package/dist/core/workflows/graph.d.ts +143 -0
  1109. package/dist/core/workflows/graph.d.ts.map +1 -0
  1110. package/dist/core/workflows/graph.js +319 -0
  1111. package/dist/core/workflows/graph.js.map +1 -0
  1112. package/dist/core/workflows/index.d.ts +26 -0
  1113. package/dist/core/workflows/index.d.ts.map +1 -0
  1114. package/dist/core/workflows/index.js +18 -0
  1115. package/dist/core/workflows/index.js.map +1 -0
  1116. package/dist/core/workflows/journal.d.ts +68 -0
  1117. package/dist/core/workflows/journal.d.ts.map +1 -0
  1118. package/dist/core/workflows/journal.js +83 -0
  1119. package/dist/core/workflows/journal.js.map +1 -0
  1120. package/dist/core/workflows/manager.d.ts +122 -0
  1121. package/dist/core/workflows/manager.d.ts.map +1 -0
  1122. package/dist/core/workflows/manager.js +351 -0
  1123. package/dist/core/workflows/manager.js.map +1 -0
  1124. package/dist/core/workflows/resolve-script.d.ts +35 -0
  1125. package/dist/core/workflows/resolve-script.d.ts.map +1 -0
  1126. package/dist/core/workflows/resolve-script.js +66 -0
  1127. package/dist/core/workflows/resolve-script.js.map +1 -0
  1128. package/dist/core/workflows/runtime.d.ts +62 -0
  1129. package/dist/core/workflows/runtime.d.ts.map +1 -0
  1130. package/dist/core/workflows/runtime.js +380 -0
  1131. package/dist/core/workflows/runtime.js.map +1 -0
  1132. package/dist/core/workflows/save-as-skill.d.ts +27 -0
  1133. package/dist/core/workflows/save-as-skill.d.ts.map +1 -0
  1134. package/dist/core/workflows/save-as-skill.js +54 -0
  1135. package/dist/core/workflows/save-as-skill.js.map +1 -0
  1136. package/dist/core/workflows/shared-store.d.ts +31 -0
  1137. package/dist/core/workflows/shared-store.d.ts.map +1 -0
  1138. package/dist/core/workflows/shared-store.js +80 -0
  1139. package/dist/core/workflows/shared-store.js.map +1 -0
  1140. package/dist/core/workflows/subagent-host.d.ts +50 -0
  1141. package/dist/core/workflows/subagent-host.d.ts.map +1 -0
  1142. package/dist/core/workflows/subagent-host.js +225 -0
  1143. package/dist/core/workflows/subagent-host.js.map +1 -0
  1144. package/dist/core/workflows/tool-workflow.d.ts +22 -0
  1145. package/dist/core/workflows/tool-workflow.d.ts.map +1 -0
  1146. package/dist/core/workflows/tool-workflow.js +120 -0
  1147. package/dist/core/workflows/tool-workflow.js.map +1 -0
  1148. package/dist/core/workflows/types.d.ts +191 -0
  1149. package/dist/core/workflows/types.d.ts.map +1 -0
  1150. package/dist/core/workflows/types.js +26 -0
  1151. package/dist/core/workflows/types.js.map +1 -0
  1152. package/dist/core/workflows/worktree.d.ts +42 -0
  1153. package/dist/core/workflows/worktree.d.ts.map +1 -0
  1154. package/dist/core/workflows/worktree.js +107 -0
  1155. package/dist/core/workflows/worktree.js.map +1 -0
  1156. package/dist/extensions/llama/index.d.ts.map +1 -1
  1157. package/dist/extensions/llama/index.js +2 -0
  1158. package/dist/extensions/llama/index.js.map +1 -1
  1159. package/dist/extensions/llama/provider.d.ts.map +1 -1
  1160. package/dist/extensions/llama/provider.js +6 -2
  1161. package/dist/extensions/llama/provider.js.map +1 -1
  1162. package/dist/extensions/remoto/index.d.ts +22 -0
  1163. package/dist/extensions/remoto/index.d.ts.map +1 -0
  1164. package/dist/extensions/remoto/index.js +54 -0
  1165. package/dist/extensions/remoto/index.js.map +1 -0
  1166. package/dist/index.d.ts +1 -13
  1167. package/dist/index.d.ts.map +1 -1
  1168. package/dist/index.js +7 -13
  1169. package/dist/index.js.map +1 -1
  1170. package/dist/main.d.ts +4 -0
  1171. package/dist/main.d.ts.map +1 -1
  1172. package/dist/main.js +26 -15
  1173. package/dist/main.js.map +1 -1
  1174. package/dist/migrations.d.ts.map +1 -1
  1175. package/dist/migrations.js +4 -3
  1176. package/dist/migrations.js.map +1 -1
  1177. package/dist/modes/acp/acp-mode.d.ts +42 -0
  1178. package/dist/modes/acp/acp-mode.d.ts.map +1 -0
  1179. package/dist/modes/acp/acp-mode.js +190 -0
  1180. package/dist/modes/acp/acp-mode.js.map +1 -0
  1181. package/dist/modes/acp/events.d.ts +74 -0
  1182. package/dist/modes/acp/events.d.ts.map +1 -0
  1183. package/dist/modes/acp/events.js +116 -0
  1184. package/dist/modes/acp/events.js.map +1 -0
  1185. package/dist/modes/interactive/components/home-screen.d.ts.map +1 -1
  1186. package/dist/modes/interactive/components/home-screen.js +2 -2
  1187. package/dist/modes/interactive/components/home-screen.js.map +1 -1
  1188. package/dist/modes/interactive/components/model-selector.d.ts +9 -3
  1189. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  1190. package/dist/modes/interactive/components/model-selector.js +56 -12
  1191. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  1192. package/dist/modes/interactive/components/prompt-optimization.d.ts +16 -0
  1193. package/dist/modes/interactive/components/prompt-optimization.d.ts.map +1 -0
  1194. package/dist/modes/interactive/components/prompt-optimization.js +46 -0
  1195. package/dist/modes/interactive/components/prompt-optimization.js.map +1 -0
  1196. package/dist/modes/interactive/components/settings-selector.d.ts +19 -2
  1197. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  1198. package/dist/modes/interactive/components/settings-selector.js +180 -56
  1199. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  1200. package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
  1201. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
  1202. package/dist/modes/interactive/components/settings-submenu.js +165 -0
  1203. package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
  1204. package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
  1205. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  1206. package/dist/modes/interactive/components/thinking-selector.js +74 -17
  1207. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  1208. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  1209. package/dist/modes/interactive/external-editor.js +2 -1
  1210. package/dist/modes/interactive/external-editor.js.map +1 -1
  1211. package/dist/modes/interactive/interactive-mode.d.ts +21 -1
  1212. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  1213. package/dist/modes/interactive/interactive-mode.js +709 -75
  1214. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  1215. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  1216. package/dist/modes/interactive/theme/theme.js +4 -3
  1217. package/dist/modes/interactive/theme/theme.js.map +1 -1
  1218. package/dist/modes/json-event.d.ts +16 -13
  1219. package/dist/modes/json-event.d.ts.map +1 -1
  1220. package/dist/modes/json-event.js +20 -6
  1221. package/dist/modes/json-event.js.map +1 -1
  1222. package/dist/modes/print-mode.d.ts.map +1 -1
  1223. package/dist/modes/print-mode.js +11 -0
  1224. package/dist/modes/print-mode.js.map +1 -1
  1225. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  1226. package/dist/modes/rpc/rpc-mode.js +173 -0
  1227. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  1228. package/dist/modes/rpc/rpc-types.d.ts +29 -0
  1229. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  1230. package/dist/modes/rpc/rpc-types.js.map +1 -1
  1231. package/dist/package-manager-cli.d.ts.map +1 -1
  1232. package/dist/package-manager-cli.js +27 -5
  1233. package/dist/package-manager-cli.js.map +1 -1
  1234. package/dist/server/attach.d.ts +56 -0
  1235. package/dist/server/attach.d.ts.map +1 -0
  1236. package/dist/server/attach.js +130 -0
  1237. package/dist/server/attach.js.map +1 -0
  1238. package/dist/server/extension-ops.d.ts +40 -0
  1239. package/dist/server/extension-ops.d.ts.map +1 -0
  1240. package/dist/server/extension-ops.js +146 -0
  1241. package/dist/server/extension-ops.js.map +1 -0
  1242. package/dist/server/pi-server-service.d.ts +85 -0
  1243. package/dist/server/pi-server-service.d.ts.map +1 -0
  1244. package/dist/server/pi-server-service.js +213 -0
  1245. package/dist/server/pi-server-service.js.map +1 -0
  1246. package/dist/server/scheduler-tick.d.ts +32 -0
  1247. package/dist/server/scheduler-tick.d.ts.map +1 -0
  1248. package/dist/server/scheduler-tick.js +47 -0
  1249. package/dist/server/scheduler-tick.js.map +1 -0
  1250. package/dist/server/serve.d.ts +25 -0
  1251. package/dist/server/serve.d.ts.map +1 -0
  1252. package/dist/server/serve.js +83 -0
  1253. package/dist/server/serve.js.map +1 -0
  1254. package/dist/server/transcript.d.ts +38 -0
  1255. package/dist/server/transcript.d.ts.map +1 -0
  1256. package/dist/server/transcript.js +176 -0
  1257. package/dist/server/transcript.js.map +1 -0
  1258. package/dist/skills/ada-engine/SKILL.md +153 -0
  1259. package/dist/skills/skill-creator/SKILL.md +90 -0
  1260. package/dist/telegram/api.d.ts +75 -0
  1261. package/dist/telegram/api.d.ts.map +1 -0
  1262. package/dist/telegram/api.js +104 -0
  1263. package/dist/telegram/api.js.map +1 -0
  1264. package/dist/telegram/bridge.d.ts +85 -0
  1265. package/dist/telegram/bridge.d.ts.map +1 -0
  1266. package/dist/telegram/bridge.js +182 -0
  1267. package/dist/telegram/bridge.js.map +1 -0
  1268. package/dist/telegram/journal.d.ts +67 -0
  1269. package/dist/telegram/journal.d.ts.map +1 -0
  1270. package/dist/telegram/journal.js +119 -0
  1271. package/dist/telegram/journal.js.map +1 -0
  1272. package/dist/telegram/servidor.d.ts +15 -0
  1273. package/dist/telegram/servidor.d.ts.map +1 -0
  1274. package/dist/telegram/servidor.js +74 -0
  1275. package/dist/telegram/servidor.js.map +1 -0
  1276. package/dist/utils/frontmatter.d.ts.map +1 -1
  1277. package/dist/utils/frontmatter.js +2 -1
  1278. package/dist/utils/frontmatter.js.map +1 -1
  1279. package/dist/utils/management-http.d.ts +5 -3
  1280. package/dist/utils/management-http.d.ts.map +1 -1
  1281. package/dist/utils/management-http.js +14 -10
  1282. package/dist/utils/management-http.js.map +1 -1
  1283. package/dist/utils/shell.d.ts +11 -0
  1284. package/dist/utils/shell.d.ts.map +1 -1
  1285. package/dist/utils/shell.js +11 -0
  1286. package/dist/utils/shell.js.map +1 -1
  1287. package/dist/utils/text.d.ts +8 -0
  1288. package/dist/utils/text.d.ts.map +1 -0
  1289. package/dist/utils/text.js +9 -0
  1290. package/dist/utils/text.js.map +1 -0
  1291. package/dist/utils/version-check.d.ts.map +1 -1
  1292. package/dist/utils/version-check.js +29 -1
  1293. package/dist/utils/version-check.js.map +1 -1
  1294. package/docs/compaction.md +25 -10
  1295. package/docs/compliance.md +241 -0
  1296. package/docs/containerization.md +24 -24
  1297. package/docs/custom-provider.md +15 -12
  1298. package/docs/development.md +47 -10
  1299. package/docs/docs.json +14 -2
  1300. package/docs/environment-variables.md +20 -17
  1301. package/docs/extensions.md +62 -51
  1302. package/docs/index.md +15 -21
  1303. package/docs/json.md +10 -5
  1304. package/docs/keybindings.md +5 -5
  1305. package/docs/llama-cpp.md +9 -7
  1306. package/docs/models.md +18 -12
  1307. package/docs/packages.md +45 -45
  1308. package/docs/prompt-templates.md +5 -5
  1309. package/docs/providers.md +12 -12
  1310. package/docs/quickstart.md +39 -39
  1311. package/docs/rpc.md +21 -15
  1312. package/docs/sdk.md +38 -38
  1313. package/docs/security.md +26 -21
  1314. package/docs/session-format.md +7 -7
  1315. package/docs/sessions.md +14 -14
  1316. package/docs/settings.md +47 -22
  1317. package/docs/shell-aliases.md +2 -2
  1318. package/docs/skills.md +14 -13
  1319. package/docs/terminal-setup.md +14 -14
  1320. package/docs/termux.md +7 -7
  1321. package/docs/themes.md +11 -11
  1322. package/docs/tmux.md +4 -4
  1323. package/docs/tui.md +3 -3
  1324. package/docs/usage.md +54 -54
  1325. package/docs/windows.md +2 -2
  1326. package/examples/extensions/border-status-editor.ts +1 -1
  1327. package/examples/extensions/git-checkpoint.ts +2 -2
  1328. package/examples/extensions/notify.ts +3 -1
  1329. package/examples/extensions/subagent/README.md +1 -1
  1330. package/examples/extensions/subagent/index.ts +6 -1
  1331. package/examples/extensions/titlebar-spinner.ts +1 -1
  1332. package/examples/rpc-extension-ui.ts +1 -1
  1333. package/examples/sdk/06-extensions.ts +1 -1
  1334. package/examples/sdk/12-full-control.ts +9 -0
  1335. package/examples/sdk/README.md +1 -1
  1336. package/npm-shrinkwrap.json +35 -261
  1337. package/package.json +9 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","s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U,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAmBxF;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO1F;AAED,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,EAAE,CAO5F;AAAA,wBAAgB,wBAAwB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,YAAY,EACtB,QAAQ,GAAE,MAAsB,GAC9B,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAW3B;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAQ7E;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,EAAE,CAO/E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAW1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createUpdateProjectMemoryTool } from \"./project-memory-tool.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"update_project_memory\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"update_project_memory\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}export function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tagentDir: string = getAgentDir(),\n): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tupdate_project_memory: createUpdateProjectMemoryTool(cwd, agentDir),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t\twrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tupdate_project_memory: wrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t};\n}"]}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,EACtB,KAAK,YAA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,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAW1F","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createUpdateProjectMemoryTool } from \"./project-memory-tool.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"update_project_memory\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"update_project_memory\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tagentDir: string = getAgentDir(),\n): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tupdate_project_memory: createUpdateProjectMemoryTool(cwd, agentDir),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t\twrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tupdate_project_memory: wrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t};\n}\n"]}
@@ -8,14 +8,14 @@ export { createReadTool, createReadToolDefinition, } from "./read.js";
8
8
  export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
9
9
  export { createWriteTool, createWriteToolDefinition, } from "./write.js";
10
10
  import { getAgentDir } from "../../config.js";
11
- import { createUpdateProjectMemoryTool } from "./project-memory-tool.js";
12
- import { wrapToolDefinition } from "./tool-definition-wrapper.js";
13
11
  import { createBashTool, createBashToolDefinition } from "./bash.js";
14
12
  import { createEditTool, createEditToolDefinition } from "./edit.js";
15
13
  import { createFindTool, createFindToolDefinition } from "./find.js";
16
14
  import { createGrepTool, createGrepToolDefinition } from "./grep.js";
17
15
  import { createLsTool, createLsToolDefinition } from "./ls.js";
16
+ import { createUpdateProjectMemoryTool } from "./project-memory-tool.js";
18
17
  import { createReadTool, createReadToolDefinition } from "./read.js";
18
+ import { wrapToolDefinition } from "./tool-definition-wrapper.js";
19
19
  import { createWriteTool, createWriteToolDefinition } from "./write.js";
20
20
  export const allToolNames = new Set([
21
21
  "read",
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EACZ,sBAAsB,GAKtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EAGV,YAAY,EACZ,YAAY,EACZ,YAAY,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,eAAe,EACf,yBAAyB,GAIzB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA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olInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { createUpdateProjectMemoryTool } from \"./project-memory-tool.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName =\n\t| \"read\"\n\t| \"bash\"\n\t| \"edit\"\n\t| \"write\"\n\t| \"grep\"\n\t| \"find\"\n\t| \"ls\"\n\t| \"update_project_memory\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"update_project_memory\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}export function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tagentDir: string = getAgentDir(),\n): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tupdate_project_memory: createUpdateProjectMemoryTool(cwd, agentDir),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t\twrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tupdate_project_memory: wrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t};\n}"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAON,cAAc,EACd,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,cAAc,EACd,wBAAwB,GAKxB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,YAAY,EAC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O,EAAE,KAAK,CAAC;QAC3C,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC;QACxC,EAAE,EAAE,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC;QAClC,qBAAqB,EAAE,kBAAkB,CAAC,6BAA6B,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;KAC5F,CAAC;AAAA,CACF","sourcesContent":["export {\n\ttype BashOperations,\n\ttype BashSpawnContext,\n\ttype BashSpawnHook,\n\ttype BashToolDetails,\n\ttype BashToolInput,\n\ttype BashToolOptions,\n\tcreateBashTool,\n\tcreateBashToolDefinition,\n\tcreateLocalBashOperations,\n} from \"./bash.ts\";\nexport {\n\tcreateEditTool,\n\tcreateEditToolDefinition,\n\ttype EditOperations,\n\ttype EditToolDetails,\n\ttype EditToolInput,\n\ttype EditToolOptions,\n} from \"./edit.ts\";\nexport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nexport {\n\tcreateFindTool,\n\tcreateFindToolDefinition,\n\ttype FindOperations,\n\ttype FindToolDetails,\n\ttype FindToolInput,\n\ttype FindToolOptions,\n} from \"./find.ts\";\nexport {\n\tcreateGrepTool,\n\tcreateGrepToolDefinition,\n\ttype GrepOperations,\n\ttype GrepToolDetails,\n\ttype GrepToolInput,\n\ttype GrepToolOptions,\n} from \"./grep.ts\";\nexport {\n\tcreateLsTool,\n\tcreateLsToolDefinition,\n\ttype LsOperations,\n\ttype LsToolDetails,\n\ttype LsToolInput,\n\ttype LsToolOptions,\n} from \"./ls.ts\";\nexport {\n\tcreateReadTool,\n\tcreateReadToolDefinition,\n\ttype ReadOperations,\n\ttype ReadToolDetails,\n\ttype ReadToolInput,\n\ttype ReadToolOptions,\n} from \"./read.ts\";\nexport {\n\tDEFAULT_MAX_BYTES,\n\tDEFAULT_MAX_LINES,\n\tformatSize,\n\ttype TruncationOptions,\n\ttype TruncationResult,\n\ttruncateHead,\n\ttruncateLine,\n\ttruncateTail,\n} from \"./truncate.ts\";\nexport {\n\tcreateWriteTool,\n\tcreateWriteToolDefinition,\n\ttype WriteOperations,\n\ttype WriteToolInput,\n\ttype WriteToolOptions,\n} from \"./write.ts\";\n\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { getAgentDir } from \"../../config.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type BashToolOptions, createBashTool, createBashToolDefinition } from \"./bash.ts\";\nimport { createEditTool, createEditToolDefinition, type EditToolOptions } from \"./edit.ts\";\nimport { createFindTool, createFindToolDefinition, type FindToolOptions } from \"./find.ts\";\nimport { createGrepTool, createGrepToolDefinition, type GrepToolOptions } from \"./grep.ts\";\nimport { createLsTool, createLsToolDefinition, type LsToolOptions } from \"./ls.ts\";\nimport { createUpdateProjectMemoryTool } from \"./project-memory-tool.ts\";\nimport { createReadTool, createReadToolDefinition, type ReadToolOptions } from \"./read.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { createWriteTool, createWriteToolDefinition, type WriteToolOptions } from \"./write.ts\";\n\nexport type Tool = AgentTool<any>;\nexport type ToolDef = ToolDefinition<any, any>;\nexport type ToolName = \"read\" | \"bash\" | \"edit\" | \"write\" | \"grep\" | \"find\" | \"ls\" | \"update_project_memory\";\nexport const allToolNames: Set<ToolName> = new Set([\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n\t\"update_project_memory\",\n]);\n\nexport interface ToolsOptions {\n\tread?: ReadToolOptions;\n\tbash?: BashToolOptions;\n\twrite?: WriteToolOptions;\n\tedit?: EditToolOptions;\n\tgrep?: GrepToolOptions;\n\tfind?: FindToolOptions;\n\tls?: LsToolOptions;\n}\n\nexport function createToolDefinition(toolName: ToolName, cwd: string, options?: ToolsOptions): ToolDef {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadToolDefinition(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashToolDefinition(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditToolDefinition(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteToolDefinition(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepToolDefinition(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindToolDefinition(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsToolDefinition(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createTool(toolName: ToolName, cwd: string, options?: ToolsOptions): Tool {\n\tswitch (toolName) {\n\t\tcase \"read\":\n\t\t\treturn createReadTool(cwd, options?.read);\n\t\tcase \"bash\":\n\t\t\treturn createBashTool(cwd, options?.bash);\n\t\tcase \"edit\":\n\t\t\treturn createEditTool(cwd, options?.edit);\n\t\tcase \"write\":\n\t\t\treturn createWriteTool(cwd, options?.write);\n\t\tcase \"grep\":\n\t\t\treturn createGrepTool(cwd, options?.grep);\n\t\tcase \"find\":\n\t\t\treturn createFindTool(cwd, options?.find);\n\t\tcase \"ls\":\n\t\t\treturn createLsTool(cwd, options?.ls);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown tool name: ${toolName}`);\n\t}\n}\n\nexport function createCodingToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateBashToolDefinition(cwd, options?.bash),\n\t\tcreateEditToolDefinition(cwd, options?.edit),\n\t\tcreateWriteToolDefinition(cwd, options?.write),\n\t];\n}\n\nexport function createReadOnlyToolDefinitions(cwd: string, options?: ToolsOptions): ToolDef[] {\n\treturn [\n\t\tcreateReadToolDefinition(cwd, options?.read),\n\t\tcreateGrepToolDefinition(cwd, options?.grep),\n\t\tcreateFindToolDefinition(cwd, options?.find),\n\t\tcreateLsToolDefinition(cwd, options?.ls),\n\t];\n}\nexport function createAllToolDefinitions(\n\tcwd: string,\n\toptions?: ToolsOptions,\n\tagentDir: string = getAgentDir(),\n): Record<ToolName, ToolDef> {\n\treturn {\n\t\tread: createReadToolDefinition(cwd, options?.read),\n\t\tbash: createBashToolDefinition(cwd, options?.bash),\n\t\tedit: createEditToolDefinition(cwd, options?.edit),\n\t\twrite: createWriteToolDefinition(cwd, options?.write),\n\t\tgrep: createGrepToolDefinition(cwd, options?.grep),\n\t\tfind: createFindToolDefinition(cwd, options?.find),\n\t\tls: createLsToolDefinition(cwd, options?.ls),\n\t\tupdate_project_memory: createUpdateProjectMemoryTool(cwd, agentDir),\n\t};\n}\n\nexport function createCodingTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateBashTool(cwd, options?.bash),\n\t\tcreateEditTool(cwd, options?.edit),\n\t\tcreateWriteTool(cwd, options?.write),\n\t\twrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t];\n}\n\nexport function createReadOnlyTools(cwd: string, options?: ToolsOptions): Tool[] {\n\treturn [\n\t\tcreateReadTool(cwd, options?.read),\n\t\tcreateGrepTool(cwd, options?.grep),\n\t\tcreateFindTool(cwd, options?.find),\n\t\tcreateLsTool(cwd, options?.ls),\n\t];\n}\n\nexport function createAllTools(cwd: string, options?: ToolsOptions): Record<ToolName, Tool> {\n\treturn {\n\t\tread: createReadTool(cwd, options?.read),\n\t\tbash: createBashTool(cwd, options?.bash),\n\t\tedit: createEditTool(cwd, options?.edit),\n\t\twrite: createWriteTool(cwd, options?.write),\n\t\tgrep: createGrepTool(cwd, options?.grep),\n\t\tfind: createFindTool(cwd, options?.find),\n\t\tls: createLsTool(cwd, options?.ls),\n\t\tupdate_project_memory: wrapToolDefinition(createUpdateProjectMemoryTool(cwd, getAgentDir())),\n\t};\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `JSON.parse` tolerando caracteres de control CRUDOS dentro de las cadenas.
3
+ *
4
+ * POR QUÉ VIVE AQUÍ Y NO SOLO EN `packages/ai`. Hay una copia de esta misma
5
+ * lógica en `ai/src/utils/validation.ts`, y no es duplicación por descuido: es
6
+ * que **aquel fichero no llega al cliente**. `@hoilab/ada-cli` declara
7
+ * `"@earendil-works/pi-ai": "^0.84.2"` y el shrinkwrap lo resuelve del
8
+ * registro, así que quien instala recibe el tarball de upstream. Medido sobre
9
+ * el tarball real: 2.066 ficheros, cero de `pi-ai`.
10
+ *
11
+ * `packages/coding-agent` SÍ se publica. Poner el arreglo también aquí es lo
12
+ * que hace que funcione para quien instala, no solo para quien ejecuta desde el
13
+ * árbol de fuentes. La puerta `check-fork-llega-al-usuario.mjs` existe para que
14
+ * esa diferencia no vuelva a pasar desapercibida.
15
+ *
16
+ * EL CASO, medido sobre la carga real de un modelo gratuito: 309 caracteres con
17
+ * 18 TABULADORES crudos dentro de literales de cadena. El JSON exige que un
18
+ * tabulador vaya escapado, así que `JSON.parse` contesta «Invalid control
19
+ * character» y se acabó el turno. Es lo que produce cualquier modelo al escribir
20
+ * código indentado con tabuladores dentro de un argumento — o sea,
21
+ * constantemente.
22
+ *
23
+ * Se escapan SOLO los de control y SOLO dentro de un literal de cadena. Fuera de
24
+ * las comillas no se toca nada, y una barra invertida previa se respeta para no
25
+ * romper un `\"` legítimo. Un JSON que ya era válido sale idéntico; uno roto de
26
+ * verdad sigue fallando, que es lo que le dice al modelo qué esperábamos.
27
+ */
28
+ /** Devuelve el valor parseado, o lanza como lo haría `JSON.parse`. */
29
+ export declare function parsearJsonTolerante(texto: string): unknown;
30
+ //# sourceMappingURL=json-tolerante.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-tolerante.d.ts","sourceRoot":"","sources":["../../../src/core/tools/json-tolerante.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,uEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAuC3D","sourcesContent":["/**\n * `JSON.parse` tolerando caracteres de control CRUDOS dentro de las cadenas.\n *\n * POR QUÉ VIVE AQUÍ Y NO SOLO EN `packages/ai`. Hay una copia de esta misma\n * lógica en `ai/src/utils/validation.ts`, y no es duplicación por descuido: es\n * que **aquel fichero no llega al cliente**. `@hoilab/ada-cli` declara\n * `\"@earendil-works/pi-ai\": \"^0.84.2\"` y el shrinkwrap lo resuelve del\n * registro, así que quien instala recibe el tarball de upstream. Medido sobre\n * el tarball real: 2.066 ficheros, cero de `pi-ai`.\n *\n * `packages/coding-agent` SÍ se publica. Poner el arreglo también aquí es lo\n * que hace que funcione para quien instala, no solo para quien ejecuta desde el\n * árbol de fuentes. La puerta `check-fork-llega-al-usuario.mjs` existe para que\n * esa diferencia no vuelva a pasar desapercibida.\n *\n * EL CASO, medido sobre la carga real de un modelo gratuito: 309 caracteres con\n * 18 TABULADORES crudos dentro de literales de cadena. El JSON exige que un\n * tabulador vaya escapado, así que `JSON.parse` contesta «Invalid control\n * character» y se acabó el turno. Es lo que produce cualquier modelo al escribir\n * código indentado con tabuladores dentro de un argumento — o sea,\n * constantemente.\n *\n * Se escapan SOLO los de control y SOLO dentro de un literal de cadena. Fuera de\n * las comillas no se toca nada, y una barra invertida previa se respeta para no\n * romper un `\\\"` legítimo. Un JSON que ya era válido sale idéntico; uno roto de\n * verdad sigue fallando, que es lo que le dice al modelo qué esperábamos.\n */\n\n/** Devuelve el valor parseado, o lanza como lo haría `JSON.parse`. */\nexport function parsearJsonTolerante(texto: string): unknown {\n\ttry {\n\t\treturn JSON.parse(texto);\n\t} catch {\n\t\t// Segunda oportunidad: escapar los controles crudos de dentro de cadenas.\n\t}\n\tlet dentro = false;\n\tlet escapando = false;\n\tlet salida = \"\";\n\tfor (const c of texto) {\n\t\tif (escapando) {\n\t\t\tsalida += c;\n\t\t\tescapando = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (c === \"\\\\\") {\n\t\t\tsalida += c;\n\t\t\tescapando = dentro;\n\t\t\tcontinue;\n\t\t}\n\t\tif (c === '\"') {\n\t\t\tdentro = !dentro;\n\t\t\tsalida += c;\n\t\t\tcontinue;\n\t\t}\n\t\tif (dentro && c < \" \") {\n\t\t\tsalida +=\n\t\t\t\tc === \"\\n\"\n\t\t\t\t\t? \"\\\\n\"\n\t\t\t\t\t: c === \"\\r\"\n\t\t\t\t\t\t? \"\\\\r\"\n\t\t\t\t\t\t: c === \"\\t\"\n\t\t\t\t\t\t\t? \"\\\\t\"\n\t\t\t\t\t\t\t: `\\\\u${c.charCodeAt(0).toString(16).padStart(4, \"0\")}`;\n\t\t\tcontinue;\n\t\t}\n\t\tsalida += c;\n\t}\n\treturn JSON.parse(salida);\n}\n"]}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * `JSON.parse` tolerando caracteres de control CRUDOS dentro de las cadenas.
3
+ *
4
+ * POR QUÉ VIVE AQUÍ Y NO SOLO EN `packages/ai`. Hay una copia de esta misma
5
+ * lógica en `ai/src/utils/validation.ts`, y no es duplicación por descuido: es
6
+ * que **aquel fichero no llega al cliente**. `@hoilab/ada-cli` declara
7
+ * `"@earendil-works/pi-ai": "^0.84.2"` y el shrinkwrap lo resuelve del
8
+ * registro, así que quien instala recibe el tarball de upstream. Medido sobre
9
+ * el tarball real: 2.066 ficheros, cero de `pi-ai`.
10
+ *
11
+ * `packages/coding-agent` SÍ se publica. Poner el arreglo también aquí es lo
12
+ * que hace que funcione para quien instala, no solo para quien ejecuta desde el
13
+ * árbol de fuentes. La puerta `check-fork-llega-al-usuario.mjs` existe para que
14
+ * esa diferencia no vuelva a pasar desapercibida.
15
+ *
16
+ * EL CASO, medido sobre la carga real de un modelo gratuito: 309 caracteres con
17
+ * 18 TABULADORES crudos dentro de literales de cadena. El JSON exige que un
18
+ * tabulador vaya escapado, así que `JSON.parse` contesta «Invalid control
19
+ * character» y se acabó el turno. Es lo que produce cualquier modelo al escribir
20
+ * código indentado con tabuladores dentro de un argumento — o sea,
21
+ * constantemente.
22
+ *
23
+ * Se escapan SOLO los de control y SOLO dentro de un literal de cadena. Fuera de
24
+ * las comillas no se toca nada, y una barra invertida previa se respeta para no
25
+ * romper un `\"` legítimo. Un JSON que ya era válido sale idéntico; uno roto de
26
+ * verdad sigue fallando, que es lo que le dice al modelo qué esperábamos.
27
+ */
28
+ /** Devuelve el valor parseado, o lanza como lo haría `JSON.parse`. */
29
+ export function parsearJsonTolerante(texto) {
30
+ try {
31
+ return JSON.parse(texto);
32
+ }
33
+ catch {
34
+ // Segunda oportunidad: escapar los controles crudos de dentro de cadenas.
35
+ }
36
+ let dentro = false;
37
+ let escapando = false;
38
+ let salida = "";
39
+ for (const c of texto) {
40
+ if (escapando) {
41
+ salida += c;
42
+ escapando = false;
43
+ continue;
44
+ }
45
+ if (c === "\\") {
46
+ salida += c;
47
+ escapando = dentro;
48
+ continue;
49
+ }
50
+ if (c === '"') {
51
+ dentro = !dentro;
52
+ salida += c;
53
+ continue;
54
+ }
55
+ if (dentro && c < " ") {
56
+ salida +=
57
+ c === "\n"
58
+ ? "\\n"
59
+ : c === "\r"
60
+ ? "\\r"
61
+ : c === "\t"
62
+ ? "\\t"
63
+ : `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`;
64
+ continue;
65
+ }
66
+ salida += c;
67
+ }
68
+ return JSON.parse(salida);
69
+ }
70
+ //# sourceMappingURL=json-tolerante.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-tolerante.js","sourceRoot":"","sources":["../../../src/core/tools/json-tolerante.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,uEAAsE;AACtE,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAW;IAC5D,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACR,0EAA0E;IAC3E,CAAC;IACD,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,CAAC,CAAC;YACZ,SAAS,GAAG,KAAK,CAAC;YAClB,SAAS;QACV,CAAC;QACD,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,CAAC;YACZ,SAAS,GAAG,MAAM,CAAC;YACnB,SAAS;QACV,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACf,MAAM,GAAG,CAAC,MAAM,CAAC;YACjB,MAAM,IAAI,CAAC,CAAC;YACZ,SAAS;QACV,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;YACvB,MAAM;gBACL,CAAC,KAAK,IAAI;oBACT,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,CAAC,KAAK,IAAI;wBACX,CAAC,CAAC,KAAK;wBACP,CAAC,CAAC,CAAC,KAAK,IAAI;4BACX,CAAC,CAAC,KAAK;4BACP,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;YAC5D,SAAS;QACV,CAAC;QACD,MAAM,IAAI,CAAC,CAAC;IACb,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAAA,CAC1B","sourcesContent":["/**\n * `JSON.parse` tolerando caracteres de control CRUDOS dentro de las cadenas.\n *\n * POR QUÉ VIVE AQUÍ Y NO SOLO EN `packages/ai`. Hay una copia de esta misma\n * lógica en `ai/src/utils/validation.ts`, y no es duplicación por descuido: es\n * que **aquel fichero no llega al cliente**. `@hoilab/ada-cli` declara\n * `\"@earendil-works/pi-ai\": \"^0.84.2\"` y el shrinkwrap lo resuelve del\n * registro, así que quien instala recibe el tarball de upstream. Medido sobre\n * el tarball real: 2.066 ficheros, cero de `pi-ai`.\n *\n * `packages/coding-agent` SÍ se publica. Poner el arreglo también aquí es lo\n * que hace que funcione para quien instala, no solo para quien ejecuta desde el\n * árbol de fuentes. La puerta `check-fork-llega-al-usuario.mjs` existe para que\n * esa diferencia no vuelva a pasar desapercibida.\n *\n * EL CASO, medido sobre la carga real de un modelo gratuito: 309 caracteres con\n * 18 TABULADORES crudos dentro de literales de cadena. El JSON exige que un\n * tabulador vaya escapado, así que `JSON.parse` contesta «Invalid control\n * character» y se acabó el turno. Es lo que produce cualquier modelo al escribir\n * código indentado con tabuladores dentro de un argumento — o sea,\n * constantemente.\n *\n * Se escapan SOLO los de control y SOLO dentro de un literal de cadena. Fuera de\n * las comillas no se toca nada, y una barra invertida previa se respeta para no\n * romper un `\\\"` legítimo. Un JSON que ya era válido sale idéntico; uno roto de\n * verdad sigue fallando, que es lo que le dice al modelo qué esperábamos.\n */\n\n/** Devuelve el valor parseado, o lanza como lo haría `JSON.parse`. */\nexport function parsearJsonTolerante(texto: string): unknown {\n\ttry {\n\t\treturn JSON.parse(texto);\n\t} catch {\n\t\t// Segunda oportunidad: escapar los controles crudos de dentro de cadenas.\n\t}\n\tlet dentro = false;\n\tlet escapando = false;\n\tlet salida = \"\";\n\tfor (const c of texto) {\n\t\tif (escapando) {\n\t\t\tsalida += c;\n\t\t\tescapando = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (c === \"\\\\\") {\n\t\t\tsalida += c;\n\t\t\tescapando = dentro;\n\t\t\tcontinue;\n\t\t}\n\t\tif (c === '\"') {\n\t\t\tdentro = !dentro;\n\t\t\tsalida += c;\n\t\t\tcontinue;\n\t\t}\n\t\tif (dentro && c < \" \") {\n\t\t\tsalida +=\n\t\t\t\tc === \"\\n\"\n\t\t\t\t\t? \"\\\\n\"\n\t\t\t\t\t: c === \"\\r\"\n\t\t\t\t\t\t? \"\\\\r\"\n\t\t\t\t\t\t: c === \"\\t\"\n\t\t\t\t\t\t\t? \"\\\\t\"\n\t\t\t\t\t\t\t: `\\\\u${c.charCodeAt(0).toString(16).padStart(4, \"0\")}`;\n\t\t\tcontinue;\n\t\t}\n\t\tsalida += c;\n\t}\n\treturn JSON.parse(salida);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"project-memory-tool.d.ts","sourceRoot":"","sources":["../../../src/core/tools/project-memory-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAIX,cAAc,EACd,MAAM,wBAAwB,CAAC;AAGhC,QAAA,MAAM,yBAAyB;;;EAU7B,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC5C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACd,cAAc,CAAC,OAAO,yBAAyB,EAAE,SAAS,CAAC,CAoC7D","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tExtensionContext,\n\tToolDefinition,\n} from \"../extensions/types.ts\";\nimport { saveProjectMemory } from \"../project-memory.ts\";\n\nconst updateProjectMemorySchema = Type.Object({\n\tcontent: Type.String({\n\t\tdescription:\n\t\t\t\"The complete new content of the shared project memory file (Markdown). The previous content is REPLACED by this value, so include everything worth keeping.\",\n\t}),\n\treason: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Short reason for the update (shown in the confirmation message)\",\n\t\t}),\n\t),\n});\n\nexport type UpdateProjectMemoryInput = Static<typeof updateProjectMemorySchema>;\n\n/**\n * Tool for persisting durable, cross-session project knowledge.\n *\n * The memory file is included in the context of every conversation in the\n * project (CLI and desktop), so facts written here are available to future\n * sessions. Use it for architecture notes, conventions, decisions and anything\n * the user asks to remember.\n */\nexport function createUpdateProjectMemoryTool(\n\tcwd: string,\n\tagentDir: string,\n): ToolDefinition<typeof updateProjectMemorySchema, undefined> {\n\treturn {\n\t\tname: \"update_project_memory\",\n\t\tlabel: \"update project memory\",\n\t\tdescription:\n\t\t\t\"Update the shared project memory: durable knowledge (architecture, conventions, decisions, user preferences) that persists across ALL conversations of this project. Write concise Markdown. Replaces the previous content entirely.\",\n\t\tpromptSnippet: \"Persist durable project knowledge shared across conversations\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use update_project_memory to save facts worth remembering across sessions (architecture, conventions, decisions, user preferences).\",\n\t\t\t\"Keep the memory concise: it is loaded into the context of every conversation in the project.\",\n\t\t],\n\t\tparameters: updateProjectMemorySchema,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: UpdateProjectMemoryInput,\n\t\t\t_signal: AbortSignal | undefined,\n\t\t\t_onUpdate: AgentToolUpdateCallback<undefined> | undefined,\n\t\t\t_ctx: ExtensionContext,\n\t\t): Promise<AgentToolResult<undefined>> {\n\t\t\tconst { content, reason } = input;\n\t\t\tawait saveProjectMemory(cwd, agentDir, content);\n\t\t\tconst summary = content.split(\"\\n\").find((l) => l.trim().length > 0)?.trim() ?? \"\";\n\t\t\tconst truncated = summary.length > 80 ? `${summary.slice(0, 80)}…` : summary;\n\t\t\treturn {\n\t\t\t\tdetails: undefined,\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: `Project memory updated${reason ? ` (${reason})` : \"\"}. ${\n\t\t\t\t\t\t\ttruncated ? `First line: ${truncated}` : \"Empty memory.\"\n\t\t\t\t\t\t}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"project-memory-tool.d.ts","sourceRoot":"","sources":["../../../src/core/tools/project-memory-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAIX,cAAc,EACd,MAAM,wBAAwB,CAAC;AAGhC,QAAA,MAAM,yBAAyB;;;EAU7B,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC5C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACd,cAAc,CAAC,OAAO,yBAAyB,EAAE,SAAS,CAAC,CAwC7D","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tExtensionContext,\n\tToolDefinition,\n} from \"../extensions/types.ts\";\nimport { saveProjectMemory } from \"../project-memory.ts\";\n\nconst updateProjectMemorySchema = Type.Object({\n\tcontent: Type.String({\n\t\tdescription:\n\t\t\t\"The complete new content of the shared project memory file (Markdown). The previous content is REPLACED by this value, so include everything worth keeping.\",\n\t}),\n\treason: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Short reason for the update (shown in the confirmation message)\",\n\t\t}),\n\t),\n});\n\nexport type UpdateProjectMemoryInput = Static<typeof updateProjectMemorySchema>;\n\n/**\n * Tool for persisting durable, cross-session project knowledge.\n *\n * The memory file is included in the context of every conversation in the\n * project (CLI and desktop), so facts written here are available to future\n * sessions. Use it for architecture notes, conventions, decisions and anything\n * the user asks to remember.\n */\nexport function createUpdateProjectMemoryTool(\n\tcwd: string,\n\tagentDir: string,\n): ToolDefinition<typeof updateProjectMemorySchema, undefined> {\n\treturn {\n\t\tname: \"update_project_memory\",\n\t\tlabel: \"update project memory\",\n\t\tdescription:\n\t\t\t\"Update the shared project memory: durable knowledge (architecture, conventions, decisions, user preferences) that persists across ALL conversations of this project. Write concise Markdown. Replaces the previous content entirely.\",\n\t\tpromptSnippet: \"Persist durable project knowledge shared across conversations\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use update_project_memory to save facts worth remembering across sessions (architecture, conventions, decisions, user preferences).\",\n\t\t\t\"Keep the memory concise: it is loaded into the context of every conversation in the project.\",\n\t\t],\n\t\tparameters: updateProjectMemorySchema,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: UpdateProjectMemoryInput,\n\t\t\t_signal: AbortSignal | undefined,\n\t\t\t_onUpdate: AgentToolUpdateCallback<undefined> | undefined,\n\t\t\t_ctx: ExtensionContext,\n\t\t): Promise<AgentToolResult<undefined>> {\n\t\t\tconst { content, reason } = input;\n\t\t\tawait saveProjectMemory(cwd, agentDir, content);\n\t\t\tconst summary =\n\t\t\t\tcontent\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.find((l) => l.trim().length > 0)\n\t\t\t\t\t?.trim() ?? \"\";\n\t\t\tconst truncated = summary.length > 80 ? `${summary.slice(0, 80)}…` : summary;\n\t\t\treturn {\n\t\t\t\tdetails: undefined,\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: `Project memory updated${reason ? ` (${reason})` : \"\"}. ${\n\t\t\t\t\t\t\ttruncated ? `First line: ${truncated}` : \"Empty memory.\"\n\t\t\t\t\t\t}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
@@ -30,7 +30,10 @@ export function createUpdateProjectMemoryTool(cwd, agentDir) {
30
30
  async execute(_toolCallId, input, _signal, _onUpdate, _ctx) {
31
31
  const { content, reason } = input;
32
32
  await saveProjectMemory(cwd, agentDir, content);
33
- const summary = content.split("\n").find((l) => l.trim().length > 0)?.trim() ?? "";
33
+ const summary = content
34
+ .split("\n")
35
+ .find((l) => l.trim().length > 0)
36
+ ?.trim() ?? "";
34
37
  const truncated = summary.length > 80 ? `${summary.slice(0, 80)}…` : summary;
35
38
  return {
36
39
  details: undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"project-memory-tool.js","sourceRoot":"","sources":["../../../src/core/tools/project-memory-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAO5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,yBAAyB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EACV,6JAA6J;KAC9J,CAAC;IACF,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,MAAM,CAAC;QACX,WAAW,EAAE,iEAAiE;KAC9E,CAAC,CACF;CACD,CAAC,CAAC;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC5C,GAAW,EACX,QAAgB,EAC8C;IAC9D,OAAO;QACN,IAAI,EAAE,uBAAuB;QAC7B,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EACV,sOAAsO;QACvO,aAAa,EAAE,+DAA+D;QAC9E,gBAAgB,EAAE;YACjB,qIAAqI;YACrI,8FAA8F;SAC9F;QACD,UAAU,EAAE,yBAAyB;QACrC,KAAK,CAAC,OAAO,CACZ,WAAmB,EACnB,KAA+B,EAC/B,OAAgC,EAChC,SAAyD,EACzD,IAAsB,EACgB;YACtC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;YAClC,MAAM,iBAAiB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAChD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACnF,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAG,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7E,OAAO;gBACN,OAAO,EAAE,SAAS;gBAClB,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yBAAyB,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,KAC1D,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,EAAE,CAAC,CAAC,CAAC,eAC1C,EAAE;qBACF;iBACD;aACD,CAAC;QAAA,CACF;KACD,CAAC;AAAA,CACF","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tExtensionContext,\n\tToolDefinition,\n} from \"../extensions/types.ts\";\nimport { saveProjectMemory } from \"../project-memory.ts\";\n\nconst updateProjectMemorySchema = Type.Object({\n\tcontent: Type.String({\n\t\tdescription:\n\t\t\t\"The complete new content of the shared project memory file (Markdown). The previous content is REPLACED by this value, so include everything worth keeping.\",\n\t}),\n\treason: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Short reason for the update (shown in the confirmation message)\",\n\t\t}),\n\t),\n});\n\nexport type UpdateProjectMemoryInput = Static<typeof updateProjectMemorySchema>;\n\n/**\n * Tool for persisting durable, cross-session project knowledge.\n *\n * The memory file is included in the context of every conversation in the\n * project (CLI and desktop), so facts written here are available to future\n * sessions. Use it for architecture notes, conventions, decisions and anything\n * the user asks to remember.\n */\nexport function createUpdateProjectMemoryTool(\n\tcwd: string,\n\tagentDir: string,\n): ToolDefinition<typeof updateProjectMemorySchema, undefined> {\n\treturn {\n\t\tname: \"update_project_memory\",\n\t\tlabel: \"update project memory\",\n\t\tdescription:\n\t\t\t\"Update the shared project memory: durable knowledge (architecture, conventions, decisions, user preferences) that persists across ALL conversations of this project. Write concise Markdown. Replaces the previous content entirely.\",\n\t\tpromptSnippet: \"Persist durable project knowledge shared across conversations\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use update_project_memory to save facts worth remembering across sessions (architecture, conventions, decisions, user preferences).\",\n\t\t\t\"Keep the memory concise: it is loaded into the context of every conversation in the project.\",\n\t\t],\n\t\tparameters: updateProjectMemorySchema,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: UpdateProjectMemoryInput,\n\t\t\t_signal: AbortSignal | undefined,\n\t\t\t_onUpdate: AgentToolUpdateCallback<undefined> | undefined,\n\t\t\t_ctx: ExtensionContext,\n\t\t): Promise<AgentToolResult<undefined>> {\n\t\t\tconst { content, reason } = input;\n\t\t\tawait saveProjectMemory(cwd, agentDir, content);\n\t\t\tconst summary = content.split(\"\\n\").find((l) => l.trim().length > 0)?.trim() ?? \"\";\n\t\t\tconst truncated = summary.length > 80 ? `${summary.slice(0, 80)}…` : summary;\n\t\t\treturn {\n\t\t\t\tdetails: undefined,\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: `Project memory updated${reason ? ` (${reason})` : \"\"}. ${\n\t\t\t\t\t\t\ttruncated ? `First line: ${truncated}` : \"Empty memory.\"\n\t\t\t\t\t\t}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"project-memory-tool.js","sourceRoot":"","sources":["../../../src/core/tools/project-memory-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAO5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,yBAAyB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC;QACpB,WAAW,EACV,6JAA6J;KAC9J,CAAC;IACF,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,IAAI,CAAC,MAAM,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ACF;KACD,CAAC;AAAA,CACF","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tExtensionContext,\n\tToolDefinition,\n} from \"../extensions/types.ts\";\nimport { saveProjectMemory } from \"../project-memory.ts\";\n\nconst updateProjectMemorySchema = Type.Object({\n\tcontent: Type.String({\n\t\tdescription:\n\t\t\t\"The complete new content of the shared project memory file (Markdown). The previous content is REPLACED by this value, so include everything worth keeping.\",\n\t}),\n\treason: Type.Optional(\n\t\tType.String({\n\t\t\tdescription: \"Short reason for the update (shown in the confirmation message)\",\n\t\t}),\n\t),\n});\n\nexport type UpdateProjectMemoryInput = Static<typeof updateProjectMemorySchema>;\n\n/**\n * Tool for persisting durable, cross-session project knowledge.\n *\n * The memory file is included in the context of every conversation in the\n * project (CLI and desktop), so facts written here are available to future\n * sessions. Use it for architecture notes, conventions, decisions and anything\n * the user asks to remember.\n */\nexport function createUpdateProjectMemoryTool(\n\tcwd: string,\n\tagentDir: string,\n): ToolDefinition<typeof updateProjectMemorySchema, undefined> {\n\treturn {\n\t\tname: \"update_project_memory\",\n\t\tlabel: \"update project memory\",\n\t\tdescription:\n\t\t\t\"Update the shared project memory: durable knowledge (architecture, conventions, decisions, user preferences) that persists across ALL conversations of this project. Write concise Markdown. Replaces the previous content entirely.\",\n\t\tpromptSnippet: \"Persist durable project knowledge shared across conversations\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use update_project_memory to save facts worth remembering across sessions (architecture, conventions, decisions, user preferences).\",\n\t\t\t\"Keep the memory concise: it is loaded into the context of every conversation in the project.\",\n\t\t],\n\t\tparameters: updateProjectMemorySchema,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: UpdateProjectMemoryInput,\n\t\t\t_signal: AbortSignal | undefined,\n\t\t\t_onUpdate: AgentToolUpdateCallback<undefined> | undefined,\n\t\t\t_ctx: ExtensionContext,\n\t\t): Promise<AgentToolResult<undefined>> {\n\t\t\tconst { content, reason } = input;\n\t\t\tawait saveProjectMemory(cwd, agentDir, content);\n\t\t\tconst summary =\n\t\t\t\tcontent\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.find((l) => l.trim().length > 0)\n\t\t\t\t\t?.trim() ?? \"\";\n\t\t\tconst truncated = summary.length > 80 ? `${summary.slice(0, 80)}…` : summary;\n\t\t\treturn {\n\t\t\t\tdetails: undefined,\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext: `Project memory updated${reason ? ` (${reason})` : \"\"}. ${\n\t\t\t\t\t\t\ttruncated ? `First line: ${truncated}` : \"Empty memory.\"\n\t\t\t\t\t\t}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAQ5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAItF,OAAO,EAAoD,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEtH,QAAA,MAAM,UAAU;;;;EAId,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;CAGnC,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AASD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,qCAAqC;IACrC,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,+CAA+C;IAC/C,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACnF;AAQD,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AA4ID,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CA8IhE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@earendil-works/pi-ai\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport { getExperimentalToolSampling } from \"../experimental.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n});\n\nexport const readToolSystemPromptContribution = {\n\tsnippet: \"Read file contents\",\n\tguidelines: [\"Use read to examine files instead of cat or sed.\"],\n} as const;\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\n\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\n\n/**\n * Pluggable operations for the read tool.\n * Override these to delegate file reading to remote systems (for example SSH).\n */\nexport interface ReadOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Check if file is readable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n\t/** Detect image MIME type, return null or undefined for non-images */\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n}\n\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\n\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Custom operations for file reading. Default: local filesystem */\n\toperations?: ReadOperations;\n}\n\ntype ReadRenderArgs = { path?: string; file_path?: string; offset?: number; limit?: number };\n\nfunction formatReadLineRange(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tif (args?.offset === undefined && args?.limit === undefined) return \"\";\n\tconst startLine = args.offset ?? 1;\n\tconst endLine = args.limit !== undefined ? startLine + args.limit - 1 : \"\";\n\treturn theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n}\n\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\tif (!model || model.input.includes(\"image\")) {\n\t\treturn undefined;\n\t}\n\treturn \"[Current model does not support images. The image will be omitted from this request.]\";\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\n\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tif (!rawPath) return undefined;\n\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\n\treturn undefined;\n}\n\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\n\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tif (!options.expanded && !isError) {\n\t\treturn \"\";\n\t}\n\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result, showImages);\n\tconst lang = !isError && rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t}\n\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\n\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tpromptSnippet: readToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...readToolSystemPromptContribution.guidelines],\n\t\tparameters: readSchema,\n\t\tconstrainedSampling: getExperimentalToolSampling(),\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, offset, limit }: { path: string; offset?: number; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(path, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t// Check if file exists and is readable.\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, { autoResizeImages });\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Read text content.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tconst totalFileLines = allLines.length;\n\t\t\t\t\t\t\t\t// Apply offset if specified. Convert from 1-indexed input to 0-indexed array access.\n\t\t\t\t\t\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\t// Check if offset is out of bounds.\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length) {\n\t\t\t\t\t\t\t\t\tthrow new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlet selectedContent: string;\n\t\t\t\t\t\t\t\tlet userLimitedLines: number | undefined;\n\t\t\t\t\t\t\t\t// If limit is specified by the user, honor it first. Otherwise truncateHead decides.\n\t\t\t\t\t\t\t\tif (limit !== undefined) {\n\t\t\t\t\t\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t\tuserLimitedLines = endLine - startLine;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Apply truncation, respecting both line and byte limits.\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\tlet outputText: string;\n\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t// First line alone exceeds the byte limit. Point the model at a bash fallback.\n\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], \"utf-8\"));\n\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t// Truncation occurred. Build an actionable continuation notice.\n\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\t\t\t\t\t\t// User-specified limit stopped early, but the file still has more content.\n\t\t\t\t\t\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// No truncation and no remaining user-limited content.\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details });\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification\n\t\t\t\t\t? formatCompactReadCall(classification, args, theme)\n\t\t\t\t\t: formatReadCall(args, theme, context.cwd),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAQ5C,OAAO,KAAK,EAAE,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAKtF,OAAO,EAAoD,KAAK,gBAAgB,EAAgB,MAAM,eAAe,CAAC;AAEtH,QAAA,MAAM,UAAU;;;;EAId,CAAC;AAEH,eAAO,MAAM,gCAAgC;;;CAGnC,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AASD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,qCAAqC;IACrC,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,+CAA+C;IAC/C,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;CACnF;AAQD,MAAM,WAAW,eAAe;IAC/B,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oEAAoE;IACpE,UAAU,CAAC,EAAE,cAAc,CAAC;CAC5B;AA4ID,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,eAAe,GACvB,cAAc,CAAC,OAAO,UAAU,EAAE,eAAe,GAAG,SAAS,CAAC,CA6JhE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAEnG","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@earendil-works/pi-ai\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport { getExperimentalToolSampling } from \"../experimental.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { mapearNoVisto, textoDelMapa } from \"../lectura/mapa.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n});\n\nexport const readToolSystemPromptContribution = {\n\tsnippet: \"Read file contents\",\n\tguidelines: [\"Use read to examine files instead of cat or sed.\"],\n} as const;\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\n\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\n\n/**\n * Pluggable operations for the read tool.\n * Override these to delegate file reading to remote systems (for example SSH).\n */\nexport interface ReadOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Check if file is readable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n\t/** Detect image MIME type, return null or undefined for non-images */\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n}\n\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\n\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Custom operations for file reading. Default: local filesystem */\n\toperations?: ReadOperations;\n}\n\ntype ReadRenderArgs = { path?: string; file_path?: string; offset?: number; limit?: number };\n\nfunction formatReadLineRange(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tif (args?.offset === undefined && args?.limit === undefined) return \"\";\n\tconst startLine = args.offset ?? 1;\n\tconst endLine = args.limit !== undefined ? startLine + args.limit - 1 : \"\";\n\treturn theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n}\n\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\tif (!model || model.input.includes(\"image\")) {\n\t\treturn undefined;\n\t}\n\treturn \"[Current model does not support images. The image will be omitted from this request.]\";\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\n\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tif (!rawPath) return undefined;\n\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\n\treturn undefined;\n}\n\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\n\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tif (!options.expanded && !isError) {\n\t\treturn \"\";\n\t}\n\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result, showImages);\n\tconst lang = !isError && rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t}\n\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\n\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tpromptSnippet: readToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...readToolSystemPromptContribution.guidelines],\n\t\tparameters: readSchema,\n\t\tconstrainedSampling: getExperimentalToolSampling(),\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, offset, limit }: { path: string; offset?: number; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(path, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t// Check if file exists and is readable.\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, { autoResizeImages });\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Read text content.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tconst totalFileLines = allLines.length;\n\t\t\t\t\t\t\t\t// Apply offset if specified. Convert from 1-indexed input to 0-indexed array access.\n\t\t\t\t\t\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\t// Check if offset is out of bounds.\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length) {\n\t\t\t\t\t\t\t\t\tthrow new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlet selectedContent: string;\n\t\t\t\t\t\t\t\tlet userLimitedLines: number | undefined;\n\t\t\t\t\t\t\t\t// If limit is specified by the user, honor it first. Otherwise truncateHead decides.\n\t\t\t\t\t\t\t\tif (limit !== undefined) {\n\t\t\t\t\t\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t\tuserLimitedLines = endLine - startLine;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Apply truncation, respecting both line and byte limits.\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\tlet outputText: string;\n\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t// First line alone exceeds the byte limit. Point the model at a bash fallback.\n\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], \"utf-8\"));\n\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t// Truncation occurred. Build an actionable continuation notice.\n\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Ada: y QUÉ hay detrás del corte, no solo cuánto.\n\t\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t\t// Medido sobre `core/agent-session.ts` (4.546 líneas, 162 KB): el\n\t\t\t\t\t\t\t\t\t// límite de 50 KB salta antes que el de 2.000 líneas, así que el\n\t\t\t\t\t\t\t\t\t// agente veía 1.415 líneas y nada más. El aviso decía cuántas\n\t\t\t\t\t\t\t\t\t// faltaban y nunca qué faltaba, así que su única salida era paginar\n\t\t\t\t\t\t\t\t\t// a ciegas o editar lo que sí vio, que es peor.\n\t\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t\t// El mapa lista 97 declaraciones invisibles con su línea, así que\n\t\t\t\t\t\t\t\t\t// `AgentSession._rebuildSystemPrompt` pasa de \"está en algún sitio\"\n\t\t\t\t\t\t\t\t\t// a \"línea 1539\". Ver `core/lectura/mapa.ts` para lo que NO hace:\n\t\t\t\t\t\t\t\t\t// no resume, no interpreta — nombres y números del árbol de\n\t\t\t\t\t\t\t\t\t// sintaxis, porque un mapa que miente es peor que no tenerlo.\n\t\t\t\t\t\t\t\t\tconst mapa = textoDelMapa(mapearNoVisto(path, allLines.join(\"\\n\"), endLineDisplay), path);\n\t\t\t\t\t\t\t\t\tif (mapa) outputText += `\\n\\n${mapa}`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\t\t\t\t\t\t// User-specified limit stopped early, but the file still has more content.\n\t\t\t\t\t\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// No truncation and no remaining user-limited content.\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details });\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification\n\t\t\t\t\t? formatCompactReadCall(classification, args, theme)\n\t\t\t\t\t: formatReadCall(args, theme, context.cwd),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
@@ -10,6 +10,7 @@ import { processImage } from "../../utils/image-process.js";
10
10
  import { detectSupportedImageMimeTypeFromFile } from "../../utils/mime.js";
11
11
  import { formatPathRelativeToCwdOrAbsolute } from "../../utils/paths.js";
12
12
  import { getExperimentalToolSampling } from "../experimental.js";
13
+ import { mapearNoVisto, textoDelMapa } from "../lectura/mapa.js";
13
14
  import { resolveReadPathAsync, resolveToCwd } from "./path-utils.js";
14
15
  import { getTextOutput, renderToolPath, replaceTabs, str } from "./render-utils.js";
15
16
  import { wrapToolDefinition } from "./tool-definition-wrapper.js";
@@ -234,6 +235,22 @@ export function createReadToolDefinition(cwd, options) {
234
235
  else {
235
236
  outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
236
237
  }
238
+ // Ada: y QUÉ hay detrás del corte, no solo cuánto.
239
+ //
240
+ // Medido sobre `core/agent-session.ts` (4.546 líneas, 162 KB): el
241
+ // límite de 50 KB salta antes que el de 2.000 líneas, así que el
242
+ // agente veía 1.415 líneas y nada más. El aviso decía cuántas
243
+ // faltaban y nunca qué faltaba, así que su única salida era paginar
244
+ // a ciegas o editar lo que sí vio, que es peor.
245
+ //
246
+ // El mapa lista 97 declaraciones invisibles con su línea, así que
247
+ // `AgentSession._rebuildSystemPrompt` pasa de "está en algún sitio"
248
+ // a "línea 1539". Ver `core/lectura/mapa.ts` para lo que NO hace:
249
+ // no resume, no interpreta — nombres y números del árbol de
250
+ // sintaxis, porque un mapa que miente es peor que no tenerlo.
251
+ const mapa = textoDelMapa(mapearNoVisto(path, allLines.join("\n"), endLineDisplay), path);
252
+ if (mapa)
253
+ outputText += `\n\n${mapa}`;
237
254
  details = { truncation };
238
255
  }
239
256
  else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGjG,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,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E,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACvG,IAAI,CAAC,OAAO,CACX,cAAc;gBACb,CAAC,CAAC,qBAAqB,CAAC,cAAc,EAAE,IAAI,EAAE,KAAK,CAAC;gBACpD,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAC3C,CAAC;YACF,OAAO,IAAI,CAAC;QAAA,CACZ;QACD,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YAC7C,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CACX,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CACxG,CAAC;YACF,OAAO,IAAI,CAAC;QAAA,CACZ;KACD,CAAC;AAAA,CACF;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB,EAAgC;IACpG,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@earendil-works/pi-ai\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport { getExperimentalToolSampling } from \"../experimental.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n});\n\nexport const readToolSystemPromptContribution = {\n\tsnippet: \"Read file contents\",\n\tguidelines: [\"Use read to examine files instead of cat or sed.\"],\n} as const;\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\n\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\n\n/**\n * Pluggable operations for the read tool.\n * Override these to delegate file reading to remote systems (for example SSH).\n */\nexport interface ReadOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Check if file is readable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n\t/** Detect image MIME type, return null or undefined for non-images */\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n}\n\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\n\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Custom operations for file reading. Default: local filesystem */\n\toperations?: ReadOperations;\n}\n\ntype ReadRenderArgs = { path?: string; file_path?: string; offset?: number; limit?: number };\n\nfunction formatReadLineRange(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tif (args?.offset === undefined && args?.limit === undefined) return \"\";\n\tconst startLine = args.offset ?? 1;\n\tconst endLine = args.limit !== undefined ? startLine + args.limit - 1 : \"\";\n\treturn theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n}\n\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\tif (!model || model.input.includes(\"image\")) {\n\t\treturn undefined;\n\t}\n\treturn \"[Current model does not support images. The image will be omitted from this request.]\";\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\n\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tif (!rawPath) return undefined;\n\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\n\treturn undefined;\n}\n\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\n\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tif (!options.expanded && !isError) {\n\t\treturn \"\";\n\t}\n\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result, showImages);\n\tconst lang = !isError && rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t}\n\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\n\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tpromptSnippet: readToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...readToolSystemPromptContribution.guidelines],\n\t\tparameters: readSchema,\n\t\tconstrainedSampling: getExperimentalToolSampling(),\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, offset, limit }: { path: string; offset?: number; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(path, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t// Check if file exists and is readable.\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, { autoResizeImages });\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Read text content.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tconst totalFileLines = allLines.length;\n\t\t\t\t\t\t\t\t// Apply offset if specified. Convert from 1-indexed input to 0-indexed array access.\n\t\t\t\t\t\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\t// Check if offset is out of bounds.\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length) {\n\t\t\t\t\t\t\t\t\tthrow new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlet selectedContent: string;\n\t\t\t\t\t\t\t\tlet userLimitedLines: number | undefined;\n\t\t\t\t\t\t\t\t// If limit is specified by the user, honor it first. Otherwise truncateHead decides.\n\t\t\t\t\t\t\t\tif (limit !== undefined) {\n\t\t\t\t\t\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t\tuserLimitedLines = endLine - startLine;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Apply truncation, respecting both line and byte limits.\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\tlet outputText: string;\n\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t// First line alone exceeds the byte limit. Point the model at a bash fallback.\n\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], \"utf-8\"));\n\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t// Truncation occurred. Build an actionable continuation notice.\n\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\t\t\t\t\t\t// User-specified limit stopped early, but the file still has more content.\n\t\t\t\t\t\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// No truncation and no remaining user-limited content.\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details });\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification\n\t\t\t\t\t? formatCompactReadCall(classification, args, theme)\n\t\t\t\t\t: formatReadCall(args, theme, context.cwd),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGjG,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,wDAAwD,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,a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OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAAA,CAClE","sourcesContent":["import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from \"node:path\";\nimport type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@earendil-works/pi-ai\";\nimport { Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { getReadmePath } from \"../../config.ts\";\nimport { keyHint, keyText } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode, type Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { processImage } from \"../../utils/image-process.ts\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.ts\";\nimport { formatPathRelativeToCwdOrAbsolute } from \"../../utils/paths.ts\";\nimport { getExperimentalToolSampling } from \"../experimental.ts\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { mapearNoVisto, textoDelMapa } from \"../lectura/mapa.ts\";\nimport { resolveReadPathAsync, resolveToCwd } from \"./path-utils.ts\";\nimport { getTextOutput, renderToolPath, replaceTabs, str } from \"./render-utils.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.ts\";\n\nconst readSchema = Type.Object({\n\tpath: Type.String({ description: \"Path to the file to read (relative or absolute)\" }),\n\toffset: Type.Optional(Type.Number({ description: \"Line number to start reading from (1-indexed)\" })),\n\tlimit: Type.Optional(Type.Number({ description: \"Maximum number of lines to read\" })),\n});\n\nexport const readToolSystemPromptContribution = {\n\tsnippet: \"Read file contents\",\n\tguidelines: [\"Use read to examine files instead of cat or sed.\"],\n} as const;\n\nexport type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\n\ninterface CompactReadClassification {\n\tkind: \"docs\" | \"resource\" | \"skill\";\n\tlabel: string;\n}\n\nconst COMPACT_RESOURCE_FILE_NAMES = new Set([\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"]);\n\n/**\n * Pluggable operations for the read tool.\n * Override these to delegate file reading to remote systems (for example SSH).\n */\nexport interface ReadOperations {\n\t/** Read file contents as a Buffer */\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\t/** Check if file is readable (throw if not) */\n\taccess: (absolutePath: string) => Promise<void>;\n\t/** Detect image MIME type, return null or undefined for non-images */\n\tdetectImageMimeType?: (absolutePath: string) => Promise<string | null | undefined>;\n}\n\nconst defaultReadOperations: ReadOperations = {\n\treadFile: (path) => fsReadFile(path),\n\taccess: (path) => fsAccess(path, constants.R_OK),\n\tdetectImageMimeType: detectSupportedImageMimeTypeFromFile,\n};\n\nexport interface ReadToolOptions {\n\t/** Whether to auto-resize images to 2000x2000 max. Default: true */\n\tautoResizeImages?: boolean;\n\t/** Custom operations for file reading. Default: local filesystem */\n\toperations?: ReadOperations;\n}\n\ntype ReadRenderArgs = { path?: string; file_path?: string; offset?: number; limit?: number };\n\nfunction formatReadLineRange(args: ReadRenderArgs | undefined, theme: Theme): string {\n\tif (args?.offset === undefined && args?.limit === undefined) return \"\";\n\tconst startLine = args.offset ?? 1;\n\tconst endLine = args.limit !== undefined ? startLine + args.limit - 1 : \"\";\n\treturn theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n}\n\nfunction formatReadCall(args: ReadRenderArgs | undefined, theme: Theme, cwd: string): string {\n\tconst pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}${formatReadLineRange(args, theme)}`;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction getNonVisionImageNote(model: Model<Api> | undefined): string | undefined {\n\tif (!model || model.input.includes(\"image\")) {\n\t\treturn undefined;\n\t}\n\treturn \"[Current model does not support images. The image will be omitted from this request.]\";\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nfunction getPiDocsClassification(absolutePath: string): CompactReadClassification | undefined {\n\tconst packageRoot = dirname(getReadmePath());\n\tconst relativePath = relative(resolvePath(packageRoot), resolvePath(absolutePath));\n\tif (\n\t\trelativePath === \"\" ||\n\t\trelativePath === \"..\" ||\n\t\trelativePath.startsWith(`..${sep}`) ||\n\t\tisAbsolute(relativePath)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst label = toPosixPath(relativePath);\n\tif (label === \"README.md\" || label.startsWith(\"docs/\") || label.startsWith(\"examples/\")) {\n\t\treturn { kind: \"docs\", label };\n\t}\n\treturn undefined;\n}\n\nfunction getCompactReadClassification(\n\targs: ReadRenderArgs | undefined,\n\tcwd: string,\n): CompactReadClassification | undefined {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tif (!rawPath) return undefined;\n\n\tconst absolutePath = resolveToCwd(rawPath, cwd);\n\tconst fileName = basename(absolutePath);\n\tif (fileName === \"SKILL.md\") {\n\t\treturn { kind: \"skill\", label: basename(dirname(absolutePath)) || fileName };\n\t}\n\n\tconst docsClassification = getPiDocsClassification(absolutePath);\n\tif (docsClassification) return docsClassification;\n\n\tif (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {\n\t\treturn { kind: \"resource\", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };\n\t}\n\n\treturn undefined;\n}\n\nfunction formatCompactReadCall(\n\tclassification: CompactReadClassification,\n\targs: ReadRenderArgs | undefined,\n\ttheme: Theme,\n): string {\n\tconst expandHint = theme.fg(\"dim\", ` (${keyText(\"app.tools.expand\")} to expand)`);\n\tif (classification.kind === \"skill\") {\n\t\treturn (\n\t\t\ttheme.fg(\"customMessageLabel\", `\\x1b[1m[skill]\\x1b[22m `) +\n\t\t\ttheme.fg(\"customMessageText\", classification.label) +\n\t\t\tformatReadLineRange(args, theme) +\n\t\t\texpandHint\n\t\t);\n\t}\n\n\treturn (\n\t\ttheme.fg(\"toolTitle\", theme.bold(`read ${classification.kind}`)) +\n\t\t\" \" +\n\t\ttheme.fg(\"accent\", classification.label) +\n\t\tformatReadLineRange(args, theme) +\n\t\texpandHint\n\t);\n}\n\nfunction formatReadResult(\n\targs: ReadRenderArgs | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: Theme,\n\tshowImages: boolean,\n\t_cwd: string,\n\tisError: boolean,\n): string {\n\tif (!options.expanded && !isError) {\n\t\treturn \"\";\n\t}\n\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result, showImages);\n\tconst lang = !isError && rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tconst renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split(\"\\n\");\n\tconst lines = trimTrailingEmptyLines(renderedLines);\n\tconst maxLines = options.expanded ? lines.length : 10;\n\tconst displayLines = lines.slice(0, maxLines);\n\tconst remaining = lines.length - maxLines;\n\tlet text = `\\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\tif (remaining > 0) {\n\t\ttext += `${theme.fg(\"muted\", `\\n... (${remaining} more lines,`)} ${keyHint(\"app.tools.expand\", \"to expand\")}${theme.fg(\"muted\", \")\")}`;\n\t}\n\n\tconst truncation = result.details?.truncation;\n\tif (truncation?.truncated) {\n\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;\n\t\t} else if (truncation.truncatedBy === \"lines\") {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;\n\t\t} else {\n\t\t\ttext += `\\n${theme.fg(\"warning\", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;\n\t\t}\n\t}\n\treturn text;\n}\n\nexport function createReadToolDefinition(\n\tcwd: string,\n\toptions?: ReadToolOptions,\n): ToolDefinition<typeof readSchema, ReadToolDetails | undefined> {\n\tconst autoResizeImages = options?.autoResizeImages ?? true;\n\tconst ops = options?.operations ?? defaultReadOperations;\n\treturn {\n\t\tname: \"read\",\n\t\tlabel: \"read\",\n\t\tdescription: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp, bmp). Images are sent as attachments. For text files, output is truncated to ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). Use offset/limit for large files. When you need the full file, continue with offset until complete.`,\n\t\tpromptSnippet: readToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...readToolSystemPromptContribution.guidelines],\n\t\tparameters: readSchema,\n\t\tconstrainedSampling: getExperimentalToolSampling(),\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, offset, limit }: { path: string; offset?: number; limit?: number },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?,\n\t\t) {\n\t\t\treturn new Promise<{ content: (TextContent | ImageContent)[]; details: ReadToolDetails | undefined }>(\n\t\t\t\t(resolve, reject) => {\n\t\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet aborted = false;\n\t\t\t\t\tconst onAbort = () => {\n\t\t\t\t\t\taborted = true;\n\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t};\n\t\t\t\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst absolutePath = await resolveReadPathAsync(path, cwd);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\t// Check if file exists and is readable.\n\t\t\t\t\t\t\tawait ops.access(absolutePath);\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tconst mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;\n\t\t\t\t\t\t\tlet content: (TextContent | ImageContent)[];\n\t\t\t\t\t\t\tlet details: ReadToolDetails | undefined;\n\t\t\t\t\t\t\tconst nonVisionImageNote = getNonVisionImageNote(ctx?.model);\n\t\t\t\t\t\t\tif (mimeType) {\n\t\t\t\t\t\t\t\t// Read image as binary.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst processed = await processImage(buffer, mimeType, { autoResizeImages });\n\t\t\t\t\t\t\t\tif (!processed.ok) {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n${processed.message}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${processed.mimeType}]`;\n\t\t\t\t\t\t\t\t\tif (processed.hints.length > 0) textNote += `\\n${processed.hints.join(\"\\n\")}`;\n\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\tcontent = [\n\t\t\t\t\t\t\t\t\t\t{ type: \"text\", text: textNote },\n\t\t\t\t\t\t\t\t\t\t{ type: \"image\", data: processed.data, mimeType: processed.mimeType },\n\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Read text content.\n\t\t\t\t\t\t\t\tconst buffer = await ops.readFile(absolutePath);\n\t\t\t\t\t\t\t\tconst textContent = buffer.toString(\"utf-8\");\n\t\t\t\t\t\t\t\tconst allLines = textContent.split(\"\\n\");\n\t\t\t\t\t\t\t\tconst totalFileLines = allLines.length;\n\t\t\t\t\t\t\t\t// Apply offset if specified. Convert from 1-indexed input to 0-indexed array access.\n\t\t\t\t\t\t\t\tconst startLine = offset ? Math.max(0, offset - 1) : 0;\n\t\t\t\t\t\t\t\tconst startLineDisplay = startLine + 1;\n\t\t\t\t\t\t\t\t// Check if offset is out of bounds.\n\t\t\t\t\t\t\t\tif (startLine >= allLines.length) {\n\t\t\t\t\t\t\t\t\tthrow new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlet selectedContent: string;\n\t\t\t\t\t\t\t\tlet userLimitedLines: number | undefined;\n\t\t\t\t\t\t\t\t// If limit is specified by the user, honor it first. Otherwise truncateHead decides.\n\t\t\t\t\t\t\t\tif (limit !== undefined) {\n\t\t\t\t\t\t\t\t\tconst endLine = Math.min(startLine + limit, allLines.length);\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine, endLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t\tuserLimitedLines = endLine - startLine;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tselectedContent = allLines.slice(startLine).join(\"\\n\");\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Apply truncation, respecting both line and byte limits.\n\t\t\t\t\t\t\t\tconst truncation = truncateHead(selectedContent);\n\t\t\t\t\t\t\t\tlet outputText: string;\n\t\t\t\t\t\t\t\tif (truncation.firstLineExceedsLimit) {\n\t\t\t\t\t\t\t\t\t// First line alone exceeds the byte limit. Point the model at a bash fallback.\n\t\t\t\t\t\t\t\t\tconst firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], \"utf-8\"));\n\t\t\t\t\t\t\t\t\toutputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (truncation.truncated) {\n\t\t\t\t\t\t\t\t\t// Truncation occurred. Build an actionable continuation notice.\n\t\t\t\t\t\t\t\t\tconst endLineDisplay = startLineDisplay + truncation.outputLines - 1;\n\t\t\t\t\t\t\t\t\tconst nextOffset = endLineDisplay + 1;\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t\tif (truncation.truncatedBy === \"lines\") {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\toutputText += `\\n\\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Ada: y QUÉ hay detrás del corte, no solo cuánto.\n\t\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t\t// Medido sobre `core/agent-session.ts` (4.546 líneas, 162 KB): el\n\t\t\t\t\t\t\t\t\t// límite de 50 KB salta antes que el de 2.000 líneas, así que el\n\t\t\t\t\t\t\t\t\t// agente veía 1.415 líneas y nada más. El aviso decía cuántas\n\t\t\t\t\t\t\t\t\t// faltaban y nunca qué faltaba, así que su única salida era paginar\n\t\t\t\t\t\t\t\t\t// a ciegas o editar lo que sí vio, que es peor.\n\t\t\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t\t\t// El mapa lista 97 declaraciones invisibles con su línea, así que\n\t\t\t\t\t\t\t\t\t// `AgentSession._rebuildSystemPrompt` pasa de \"está en algún sitio\"\n\t\t\t\t\t\t\t\t\t// a \"línea 1539\". Ver `core/lectura/mapa.ts` para lo que NO hace:\n\t\t\t\t\t\t\t\t\t// no resume, no interpreta — nombres y números del árbol de\n\t\t\t\t\t\t\t\t\t// sintaxis, porque un mapa que miente es peor que no tenerlo.\n\t\t\t\t\t\t\t\t\tconst mapa = textoDelMapa(mapearNoVisto(path, allLines.join(\"\\n\"), endLineDisplay), path);\n\t\t\t\t\t\t\t\t\tif (mapa) outputText += `\\n\\n${mapa}`;\n\t\t\t\t\t\t\t\t\tdetails = { truncation };\n\t\t\t\t\t\t\t\t} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {\n\t\t\t\t\t\t\t\t\t// User-specified limit stopped early, but the file still has more content.\n\t\t\t\t\t\t\t\t\tconst remaining = allLines.length - (startLine + userLimitedLines);\n\t\t\t\t\t\t\t\t\tconst nextOffset = startLine + userLimitedLines + 1;\n\t\t\t\t\t\t\t\t\toutputText = `${truncation.content}\\n\\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// No truncation and no remaining user-limited content.\n\t\t\t\t\t\t\t\t\toutputText = truncation.content;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: outputText }];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tresolve({ content, details });\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\tif (!aborted) reject(error);\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t},\n\t\t\t);\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\tconst classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;\n\t\t\ttext.setText(\n\t\t\t\tclassification\n\t\t\t\t\t? formatCompactReadCall(classification, args, theme)\n\t\t\t\t\t: formatReadCall(args, theme, context.cwd),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, options, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tformatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createReadTool(cwd: string, options?: ReadToolOptions): AgentTool<typeof readSchema> {\n\treturn wrapToolDefinition(createReadToolDefinition(cwd, options));\n}\n"]}