@eminent337/aery 0.1.11 → 1.0.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 (547) hide show
  1. package/CHANGELOG.md +898 -898
  2. package/README.md +2 -32
  3. package/docs/compaction.md +14 -14
  4. package/docs/custom-provider.md +9 -9
  5. package/docs/development.md +2 -2
  6. package/docs/extensions.md +25 -25
  7. package/docs/json.md +4 -4
  8. package/docs/packages.md +2 -2
  9. package/docs/providers.md +1 -1
  10. package/docs/rpc.md +1 -1
  11. package/docs/sdk.md +22 -22
  12. package/docs/session.md +7 -7
  13. package/docs/termux.md +1 -1
  14. package/docs/themes.md +2 -2
  15. package/docs/tui.md +7 -7
  16. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  17. package/package.json +5 -5
  18. package/dist/bun/cli.d.ts +0 -3
  19. package/dist/bun/cli.d.ts.map +0 -1
  20. package/dist/bun/cli.js +0 -7
  21. package/dist/bun/cli.js.map +0 -1
  22. package/dist/bun/register-bedrock.d.ts +0 -2
  23. package/dist/bun/register-bedrock.d.ts.map +0 -1
  24. package/dist/bun/register-bedrock.js +0 -4
  25. package/dist/bun/register-bedrock.js.map +0 -1
  26. package/dist/cli/args.d.ts +0 -52
  27. package/dist/cli/args.d.ts.map +0 -1
  28. package/dist/cli/args.js +0 -321
  29. package/dist/cli/args.js.map +0 -1
  30. package/dist/cli/config-selector.d.ts +0 -14
  31. package/dist/cli/config-selector.d.ts.map +0 -1
  32. package/dist/cli/config-selector.js +0 -31
  33. package/dist/cli/config-selector.js.map +0 -1
  34. package/dist/cli/file-processor.d.ts +0 -15
  35. package/dist/cli/file-processor.d.ts.map +0 -1
  36. package/dist/cli/file-processor.js +0 -83
  37. package/dist/cli/file-processor.js.map +0 -1
  38. package/dist/cli/initial-message.d.ts +0 -18
  39. package/dist/cli/initial-message.d.ts.map +0 -1
  40. package/dist/cli/initial-message.js +0 -22
  41. package/dist/cli/initial-message.js.map +0 -1
  42. package/dist/cli/list-models.d.ts +0 -9
  43. package/dist/cli/list-models.d.ts.map +0 -1
  44. package/dist/cli/list-models.js +0 -97
  45. package/dist/cli/list-models.js.map +0 -1
  46. package/dist/cli/session-picker.d.ts +0 -9
  47. package/dist/cli/session-picker.d.ts.map +0 -1
  48. package/dist/cli/session-picker.js +0 -35
  49. package/dist/cli/session-picker.js.map +0 -1
  50. package/dist/cli.d.ts +0 -3
  51. package/dist/cli.d.ts.map +0 -1
  52. package/dist/cli.js +0 -15
  53. package/dist/cli.js.map +0 -1
  54. package/dist/config.d.ts +0 -77
  55. package/dist/config.d.ts.map +0 -1
  56. package/dist/config.js +0 -221
  57. package/dist/config.js.map +0 -1
  58. package/dist/core/agent-session-runtime.d.ts +0 -99
  59. package/dist/core/agent-session-runtime.d.ts.map +0 -1
  60. package/dist/core/agent-session-runtime.js +0 -261
  61. package/dist/core/agent-session-runtime.js.map +0 -1
  62. package/dist/core/agent-session-services.d.ts +0 -85
  63. package/dist/core/agent-session-services.d.ts.map +0 -1
  64. package/dist/core/agent-session-services.js +0 -116
  65. package/dist/core/agent-session-services.js.map +0 -1
  66. package/dist/core/agent-session.d.ts +0 -590
  67. package/dist/core/agent-session.d.ts.map +0 -1
  68. package/dist/core/agent-session.js +0 -2505
  69. package/dist/core/agent-session.js.map +0 -1
  70. package/dist/core/auth-storage.d.ts +0 -132
  71. package/dist/core/auth-storage.d.ts.map +0 -1
  72. package/dist/core/auth-storage.js +0 -422
  73. package/dist/core/auth-storage.js.map +0 -1
  74. package/dist/core/bash-executor.d.ts +0 -32
  75. package/dist/core/bash-executor.d.ts.map +0 -1
  76. package/dist/core/bash-executor.js +0 -108
  77. package/dist/core/bash-executor.js.map +0 -1
  78. package/dist/core/compaction/branch-summarization.d.ts +0 -88
  79. package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
  80. package/dist/core/compaction/branch-summarization.js +0 -243
  81. package/dist/core/compaction/branch-summarization.js.map +0 -1
  82. package/dist/core/compaction/compaction.d.ts +0 -121
  83. package/dist/core/compaction/compaction.d.ts.map +0 -1
  84. package/dist/core/compaction/compaction.js +0 -615
  85. package/dist/core/compaction/compaction.js.map +0 -1
  86. package/dist/core/compaction/index.d.ts +0 -7
  87. package/dist/core/compaction/index.d.ts.map +0 -1
  88. package/dist/core/compaction/index.js +0 -7
  89. package/dist/core/compaction/index.js.map +0 -1
  90. package/dist/core/compaction/utils.d.ts +0 -38
  91. package/dist/core/compaction/utils.d.ts.map +0 -1
  92. package/dist/core/compaction/utils.js +0 -153
  93. package/dist/core/compaction/utils.js.map +0 -1
  94. package/dist/core/defaults.d.ts +0 -3
  95. package/dist/core/defaults.d.ts.map +0 -1
  96. package/dist/core/defaults.js +0 -2
  97. package/dist/core/defaults.js.map +0 -1
  98. package/dist/core/diagnostics.d.ts +0 -15
  99. package/dist/core/diagnostics.d.ts.map +0 -1
  100. package/dist/core/diagnostics.js +0 -2
  101. package/dist/core/diagnostics.js.map +0 -1
  102. package/dist/core/event-bus.d.ts +0 -9
  103. package/dist/core/event-bus.d.ts.map +0 -1
  104. package/dist/core/event-bus.js +0 -25
  105. package/dist/core/event-bus.js.map +0 -1
  106. package/dist/core/exec.d.ts +0 -29
  107. package/dist/core/exec.d.ts.map +0 -1
  108. package/dist/core/exec.js +0 -75
  109. package/dist/core/exec.js.map +0 -1
  110. package/dist/core/export-html/ansi-to-html.d.ts +0 -22
  111. package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
  112. package/dist/core/export-html/ansi-to-html.js +0 -249
  113. package/dist/core/export-html/ansi-to-html.js.map +0 -1
  114. package/dist/core/export-html/index.d.ts +0 -37
  115. package/dist/core/export-html/index.d.ts.map +0 -1
  116. package/dist/core/export-html/index.js +0 -224
  117. package/dist/core/export-html/index.js.map +0 -1
  118. package/dist/core/export-html/template.css +0 -1017
  119. package/dist/core/export-html/template.html +0 -55
  120. package/dist/core/export-html/template.js +0 -1729
  121. package/dist/core/export-html/tool-renderer.d.ts +0 -40
  122. package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
  123. package/dist/core/export-html/tool-renderer.js +0 -95
  124. package/dist/core/export-html/tool-renderer.js.map +0 -1
  125. package/dist/core/export-html/vendor/highlight.min.js +0 -1213
  126. package/dist/core/export-html/vendor/marked.min.js +0 -6
  127. package/dist/core/extensions/index.d.ts +0 -12
  128. package/dist/core/extensions/index.d.ts.map +0 -1
  129. package/dist/core/extensions/index.js +0 -9
  130. package/dist/core/extensions/index.js.map +0 -1
  131. package/dist/core/extensions/loader.d.ts +0 -25
  132. package/dist/core/extensions/loader.d.ts.map +0 -1
  133. package/dist/core/extensions/loader.js +0 -436
  134. package/dist/core/extensions/loader.js.map +0 -1
  135. package/dist/core/extensions/runner.d.ts +0 -150
  136. package/dist/core/extensions/runner.d.ts.map +0 -1
  137. package/dist/core/extensions/runner.js +0 -706
  138. package/dist/core/extensions/runner.js.map +0 -1
  139. package/dist/core/extensions/types.d.ts +0 -1111
  140. package/dist/core/extensions/types.d.ts.map +0 -1
  141. package/dist/core/extensions/types.js +0 -45
  142. package/dist/core/extensions/types.js.map +0 -1
  143. package/dist/core/extensions/wrapper.d.ts +0 -20
  144. package/dist/core/extensions/wrapper.d.ts.map +0 -1
  145. package/dist/core/extensions/wrapper.js +0 -22
  146. package/dist/core/extensions/wrapper.js.map +0 -1
  147. package/dist/core/footer-data-provider.d.ts +0 -48
  148. package/dist/core/footer-data-provider.d.ts.map +0 -1
  149. package/dist/core/footer-data-provider.js +0 -314
  150. package/dist/core/footer-data-provider.js.map +0 -1
  151. package/dist/core/index.d.ts +0 -12
  152. package/dist/core/index.d.ts.map +0 -1
  153. package/dist/core/index.js +0 -12
  154. package/dist/core/index.js.map +0 -1
  155. package/dist/core/keybindings.d.ts +0 -353
  156. package/dist/core/keybindings.d.ts.map +0 -1
  157. package/dist/core/keybindings.js +0 -295
  158. package/dist/core/keybindings.js.map +0 -1
  159. package/dist/core/messages.d.ts +0 -77
  160. package/dist/core/messages.d.ts.map +0 -1
  161. package/dist/core/messages.js +0 -123
  162. package/dist/core/messages.js.map +0 -1
  163. package/dist/core/model-registry.d.ts +0 -132
  164. package/dist/core/model-registry.d.ts.map +0 -1
  165. package/dist/core/model-registry.js +0 -635
  166. package/dist/core/model-registry.js.map +0 -1
  167. package/dist/core/model-resolver.d.ts +0 -110
  168. package/dist/core/model-resolver.d.ts.map +0 -1
  169. package/dist/core/model-resolver.js +0 -486
  170. package/dist/core/model-resolver.js.map +0 -1
  171. package/dist/core/output-guard.d.ts +0 -6
  172. package/dist/core/output-guard.d.ts.map +0 -1
  173. package/dist/core/output-guard.js +0 -59
  174. package/dist/core/output-guard.js.map +0 -1
  175. package/dist/core/package-manager.d.ts +0 -194
  176. package/dist/core/package-manager.d.ts.map +0 -1
  177. package/dist/core/package-manager.js +0 -1882
  178. package/dist/core/package-manager.js.map +0 -1
  179. package/dist/core/prompt-templates.d.ts +0 -52
  180. package/dist/core/prompt-templates.d.ts.map +0 -1
  181. package/dist/core/prompt-templates.js +0 -250
  182. package/dist/core/prompt-templates.js.map +0 -1
  183. package/dist/core/resolve-config-value.d.ts +0 -23
  184. package/dist/core/resolve-config-value.d.ts.map +0 -1
  185. package/dist/core/resolve-config-value.js +0 -126
  186. package/dist/core/resolve-config-value.js.map +0 -1
  187. package/dist/core/resource-loader.d.ts +0 -194
  188. package/dist/core/resource-loader.d.ts.map +0 -1
  189. package/dist/core/resource-loader.js +0 -726
  190. package/dist/core/resource-loader.js.map +0 -1
  191. package/dist/core/sdk.d.ts +0 -99
  192. package/dist/core/sdk.d.ts.map +0 -1
  193. package/dist/core/sdk.js +0 -261
  194. package/dist/core/sdk.js.map +0 -1
  195. package/dist/core/session-cwd.d.ts +0 -19
  196. package/dist/core/session-cwd.d.ts.map +0 -1
  197. package/dist/core/session-cwd.js +0 -38
  198. package/dist/core/session-cwd.js.map +0 -1
  199. package/dist/core/session-manager.d.ts +0 -333
  200. package/dist/core/session-manager.d.ts.map +0 -1
  201. package/dist/core/session-manager.js +0 -1109
  202. package/dist/core/session-manager.js.map +0 -1
  203. package/dist/core/settings-manager.d.ts +0 -240
  204. package/dist/core/settings-manager.d.ts.map +0 -1
  205. package/dist/core/settings-manager.js +0 -711
  206. package/dist/core/settings-manager.js.map +0 -1
  207. package/dist/core/skills.d.ts +0 -60
  208. package/dist/core/skills.d.ts.map +0 -1
  209. package/dist/core/skills.js +0 -409
  210. package/dist/core/skills.js.map +0 -1
  211. package/dist/core/slash-commands.d.ts +0 -14
  212. package/dist/core/slash-commands.d.ts.map +0 -1
  213. package/dist/core/slash-commands.js +0 -24
  214. package/dist/core/slash-commands.js.map +0 -1
  215. package/dist/core/source-info.d.ts +0 -18
  216. package/dist/core/source-info.d.ts.map +0 -1
  217. package/dist/core/source-info.js +0 -19
  218. package/dist/core/source-info.js.map +0 -1
  219. package/dist/core/system-prompt.d.ts +0 -28
  220. package/dist/core/system-prompt.d.ts.map +0 -1
  221. package/dist/core/system-prompt.js +0 -120
  222. package/dist/core/system-prompt.js.map +0 -1
  223. package/dist/core/telemetry.d.ts +0 -3
  224. package/dist/core/telemetry.d.ts.map +0 -1
  225. package/dist/core/telemetry.js +0 -9
  226. package/dist/core/telemetry.js.map +0 -1
  227. package/dist/core/timings.d.ts +0 -8
  228. package/dist/core/timings.d.ts.map +0 -1
  229. package/dist/core/timings.js +0 -31
  230. package/dist/core/timings.js.map +0 -1
  231. package/dist/core/tools/bash.d.ts +0 -64
  232. package/dist/core/tools/bash.d.ts.map +0 -1
  233. package/dist/core/tools/bash.js +0 -355
  234. package/dist/core/tools/bash.js.map +0 -1
  235. package/dist/core/tools/edit-diff.d.ts +0 -85
  236. package/dist/core/tools/edit-diff.d.ts.map +0 -1
  237. package/dist/core/tools/edit-diff.js +0 -337
  238. package/dist/core/tools/edit-diff.js.map +0 -1
  239. package/dist/core/tools/edit.d.ts +0 -49
  240. package/dist/core/tools/edit.d.ts.map +0 -1
  241. package/dist/core/tools/edit.js +0 -323
  242. package/dist/core/tools/edit.js.map +0 -1
  243. package/dist/core/tools/file-mutation-queue.d.ts +0 -6
  244. package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
  245. package/dist/core/tools/file-mutation-queue.js +0 -37
  246. package/dist/core/tools/file-mutation-queue.js.map +0 -1
  247. package/dist/core/tools/find.d.ts +0 -35
  248. package/dist/core/tools/find.d.ts.map +0 -1
  249. package/dist/core/tools/find.js +0 -298
  250. package/dist/core/tools/find.js.map +0 -1
  251. package/dist/core/tools/grep.d.ts +0 -37
  252. package/dist/core/tools/grep.d.ts.map +0 -1
  253. package/dist/core/tools/grep.js +0 -304
  254. package/dist/core/tools/grep.js.map +0 -1
  255. package/dist/core/tools/index.d.ts +0 -40
  256. package/dist/core/tools/index.d.ts.map +0 -1
  257. package/dist/core/tools/index.js +0 -112
  258. package/dist/core/tools/index.js.map +0 -1
  259. package/dist/core/tools/ls.d.ts +0 -37
  260. package/dist/core/tools/ls.d.ts.map +0 -1
  261. package/dist/core/tools/ls.js +0 -169
  262. package/dist/core/tools/ls.js.map +0 -1
  263. package/dist/core/tools/path-utils.d.ts +0 -8
  264. package/dist/core/tools/path-utils.d.ts.map +0 -1
  265. package/dist/core/tools/path-utils.js +0 -81
  266. package/dist/core/tools/path-utils.js.map +0 -1
  267. package/dist/core/tools/read.d.ts +0 -35
  268. package/dist/core/tools/read.d.ts.map +0 -1
  269. package/dist/core/tools/read.js +0 -232
  270. package/dist/core/tools/read.js.map +0 -1
  271. package/dist/core/tools/render-utils.d.ts +0 -21
  272. package/dist/core/tools/render-utils.d.ts.map +0 -1
  273. package/dist/core/tools/render-utils.js +0 -49
  274. package/dist/core/tools/render-utils.js.map +0 -1
  275. package/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
  276. package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
  277. package/dist/core/tools/tool-definition-wrapper.js +0 -34
  278. package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
  279. package/dist/core/tools/truncate.d.ts +0 -70
  280. package/dist/core/tools/truncate.d.ts.map +0 -1
  281. package/dist/core/tools/truncate.js +0 -205
  282. package/dist/core/tools/truncate.js.map +0 -1
  283. package/dist/core/tools/write.d.ts +0 -26
  284. package/dist/core/tools/write.d.ts.map +0 -1
  285. package/dist/core/tools/write.js +0 -213
  286. package/dist/core/tools/write.js.map +0 -1
  287. package/dist/index.d.ts +0 -28
  288. package/dist/index.d.ts.map +0 -1
  289. package/dist/index.js +0 -41
  290. package/dist/index.js.map +0 -1
  291. package/dist/main.d.ts +0 -12
  292. package/dist/main.d.ts.map +0 -1
  293. package/dist/main.js +0 -589
  294. package/dist/main.js.map +0 -1
  295. package/dist/migrations.d.ts +0 -33
  296. package/dist/migrations.d.ts.map +0 -1
  297. package/dist/migrations.js +0 -281
  298. package/dist/migrations.js.map +0 -1
  299. package/dist/modes/index.d.ts +0 -9
  300. package/dist/modes/index.d.ts.map +0 -1
  301. package/dist/modes/index.js +0 -8
  302. package/dist/modes/index.js.map +0 -1
  303. package/dist/modes/interactive/assets/clankolas.png +0 -0
  304. package/dist/modes/interactive/components/armin.d.ts +0 -34
  305. package/dist/modes/interactive/components/armin.d.ts.map +0 -1
  306. package/dist/modes/interactive/components/armin.js +0 -333
  307. package/dist/modes/interactive/components/armin.js.map +0 -1
  308. package/dist/modes/interactive/components/assistant-message.d.ts +0 -20
  309. package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
  310. package/dist/modes/interactive/components/assistant-message.js +0 -121
  311. package/dist/modes/interactive/components/assistant-message.js.map +0 -1
  312. package/dist/modes/interactive/components/bash-execution.d.ts +0 -34
  313. package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
  314. package/dist/modes/interactive/components/bash-execution.js +0 -175
  315. package/dist/modes/interactive/components/bash-execution.js.map +0 -1
  316. package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
  317. package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
  318. package/dist/modes/interactive/components/bordered-loader.js +0 -54
  319. package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
  320. package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
  321. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
  322. package/dist/modes/interactive/components/branch-summary-message.js +0 -44
  323. package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
  324. package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
  325. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
  326. package/dist/modes/interactive/components/compaction-summary-message.js +0 -45
  327. package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
  328. package/dist/modes/interactive/components/config-selector.d.ts +0 -71
  329. package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
  330. package/dist/modes/interactive/components/config-selector.js +0 -479
  331. package/dist/modes/interactive/components/config-selector.js.map +0 -1
  332. package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
  333. package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
  334. package/dist/modes/interactive/components/countdown-timer.js +0 -33
  335. package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
  336. package/dist/modes/interactive/components/custom-editor.d.ts +0 -21
  337. package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
  338. package/dist/modes/interactive/components/custom-editor.js +0 -70
  339. package/dist/modes/interactive/components/custom-editor.js.map +0 -1
  340. package/dist/modes/interactive/components/custom-message.d.ts +0 -20
  341. package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
  342. package/dist/modes/interactive/components/custom-message.js +0 -79
  343. package/dist/modes/interactive/components/custom-message.js.map +0 -1
  344. package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
  345. package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
  346. package/dist/modes/interactive/components/daxnuts.js +0 -140
  347. package/dist/modes/interactive/components/daxnuts.js.map +0 -1
  348. package/dist/modes/interactive/components/diff.d.ts +0 -12
  349. package/dist/modes/interactive/components/diff.d.ts.map +0 -1
  350. package/dist/modes/interactive/components/diff.js +0 -133
  351. package/dist/modes/interactive/components/diff.js.map +0 -1
  352. package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
  353. package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
  354. package/dist/modes/interactive/components/dynamic-border.js +0 -21
  355. package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
  356. package/dist/modes/interactive/components/earendil-announcement.d.ts +0 -5
  357. package/dist/modes/interactive/components/earendil-announcement.d.ts.map +0 -1
  358. package/dist/modes/interactive/components/earendil-announcement.js +0 -40
  359. package/dist/modes/interactive/components/earendil-announcement.js.map +0 -1
  360. package/dist/modes/interactive/components/extension-editor.d.ts +0 -20
  361. package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
  362. package/dist/modes/interactive/components/extension-editor.js +0 -111
  363. package/dist/modes/interactive/components/extension-editor.js.map +0 -1
  364. package/dist/modes/interactive/components/extension-input.d.ts +0 -23
  365. package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
  366. package/dist/modes/interactive/components/extension-input.js +0 -61
  367. package/dist/modes/interactive/components/extension-input.js.map +0 -1
  368. package/dist/modes/interactive/components/extension-selector.d.ts +0 -24
  369. package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
  370. package/dist/modes/interactive/components/extension-selector.js +0 -78
  371. package/dist/modes/interactive/components/extension-selector.js.map +0 -1
  372. package/dist/modes/interactive/components/footer.d.ts +0 -27
  373. package/dist/modes/interactive/components/footer.d.ts.map +0 -1
  374. package/dist/modes/interactive/components/footer.js +0 -201
  375. package/dist/modes/interactive/components/footer.js.map +0 -1
  376. package/dist/modes/interactive/components/index.d.ts +0 -32
  377. package/dist/modes/interactive/components/index.d.ts.map +0 -1
  378. package/dist/modes/interactive/components/index.js +0 -33
  379. package/dist/modes/interactive/components/index.js.map +0 -1
  380. package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -8
  381. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
  382. package/dist/modes/interactive/components/keybinding-hints.js +0 -22
  383. package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
  384. package/dist/modes/interactive/components/login-dialog.d.ts +0 -42
  385. package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
  386. package/dist/modes/interactive/components/login-dialog.js +0 -145
  387. package/dist/modes/interactive/components/login-dialog.js.map +0 -1
  388. package/dist/modes/interactive/components/model-selector.d.ts +0 -47
  389. package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
  390. package/dist/modes/interactive/components/model-selector.js +0 -278
  391. package/dist/modes/interactive/components/model-selector.js.map +0 -1
  392. package/dist/modes/interactive/components/oauth-selector.d.ts +0 -19
  393. package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
  394. package/dist/modes/interactive/components/oauth-selector.js +0 -97
  395. package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
  396. package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -42
  397. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
  398. package/dist/modes/interactive/components/scoped-models-selector.js +0 -290
  399. package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
  400. package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
  401. package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
  402. package/dist/modes/interactive/components/session-selector-search.js +0 -155
  403. package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
  404. package/dist/modes/interactive/components/session-selector.d.ts +0 -96
  405. package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
  406. package/dist/modes/interactive/components/session-selector.js +0 -865
  407. package/dist/modes/interactive/components/session-selector.js.map +0 -1
  408. package/dist/modes/interactive/components/settings-selector.d.ts +0 -60
  409. package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
  410. package/dist/modes/interactive/components/settings-selector.js +0 -311
  411. package/dist/modes/interactive/components/settings-selector.js.map +0 -1
  412. package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
  413. package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
  414. package/dist/modes/interactive/components/show-images-selector.js +0 -39
  415. package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
  416. package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
  417. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
  418. package/dist/modes/interactive/components/skill-invocation-message.js +0 -47
  419. package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
  420. package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
  421. package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
  422. package/dist/modes/interactive/components/theme-selector.js +0 -50
  423. package/dist/modes/interactive/components/theme-selector.js.map +0 -1
  424. package/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
  425. package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
  426. package/dist/modes/interactive/components/thinking-selector.js +0 -51
  427. package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
  428. package/dist/modes/interactive/components/tool-execution.d.ts +0 -60
  429. package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
  430. package/dist/modes/interactive/components/tool-execution.js +0 -289
  431. package/dist/modes/interactive/components/tool-execution.js.map +0 -1
  432. package/dist/modes/interactive/components/tree-selector.d.ts +0 -89
  433. package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
  434. package/dist/modes/interactive/components/tree-selector.js +0 -1092
  435. package/dist/modes/interactive/components/tree-selector.js.map +0 -1
  436. package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
  437. package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
  438. package/dist/modes/interactive/components/user-message-selector.js +0 -114
  439. package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
  440. package/dist/modes/interactive/components/user-message.d.ts +0 -10
  441. package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
  442. package/dist/modes/interactive/components/user-message.js +0 -29
  443. package/dist/modes/interactive/components/user-message.js.map +0 -1
  444. package/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
  445. package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
  446. package/dist/modes/interactive/components/visual-truncate.js +0 -33
  447. package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
  448. package/dist/modes/interactive/interactive-mode.d.ts +0 -343
  449. package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
  450. package/dist/modes/interactive/interactive-mode.js +0 -4315
  451. package/dist/modes/interactive/interactive-mode.js.map +0 -1
  452. package/dist/modes/interactive/theme/aery.json +0 -84
  453. package/dist/modes/interactive/theme/dark.json +0 -85
  454. package/dist/modes/interactive/theme/light.json +0 -84
  455. package/dist/modes/interactive/theme/theme-schema.json +0 -335
  456. package/dist/modes/interactive/theme/theme.d.ts +0 -81
  457. package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
  458. package/dist/modes/interactive/theme/theme.js +0 -979
  459. package/dist/modes/interactive/theme/theme.js.map +0 -1
  460. package/dist/modes/print-mode.d.ts +0 -28
  461. package/dist/modes/print-mode.d.ts.map +0 -1
  462. package/dist/modes/print-mode.js +0 -141
  463. package/dist/modes/print-mode.js.map +0 -1
  464. package/dist/modes/rpc/jsonl.d.ts +0 -17
  465. package/dist/modes/rpc/jsonl.d.ts.map +0 -1
  466. package/dist/modes/rpc/jsonl.js +0 -49
  467. package/dist/modes/rpc/jsonl.js.map +0 -1
  468. package/dist/modes/rpc/rpc-client.d.ts +0 -224
  469. package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
  470. package/dist/modes/rpc/rpc-client.js +0 -410
  471. package/dist/modes/rpc/rpc-client.js.map +0 -1
  472. package/dist/modes/rpc/rpc-mode.d.ts +0 -20
  473. package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
  474. package/dist/modes/rpc/rpc-mode.js +0 -601
  475. package/dist/modes/rpc/rpc-mode.js.map +0 -1
  476. package/dist/modes/rpc/rpc-types.d.ts +0 -419
  477. package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
  478. package/dist/modes/rpc/rpc-types.js +0 -8
  479. package/dist/modes/rpc/rpc-types.js.map +0 -1
  480. package/dist/package-manager-cli.d.ts +0 -4
  481. package/dist/package-manager-cli.d.ts.map +0 -1
  482. package/dist/package-manager-cli.js +0 -234
  483. package/dist/package-manager-cli.js.map +0 -1
  484. package/dist/utils/changelog.d.ts +0 -21
  485. package/dist/utils/changelog.d.ts.map +0 -1
  486. package/dist/utils/changelog.js +0 -87
  487. package/dist/utils/changelog.js.map +0 -1
  488. package/dist/utils/child-process.d.ts +0 -11
  489. package/dist/utils/child-process.d.ts.map +0 -1
  490. package/dist/utils/child-process.js +0 -78
  491. package/dist/utils/child-process.js.map +0 -1
  492. package/dist/utils/clipboard-image.d.ts +0 -11
  493. package/dist/utils/clipboard-image.d.ts.map +0 -1
  494. package/dist/utils/clipboard-image.js +0 -245
  495. package/dist/utils/clipboard-image.js.map +0 -1
  496. package/dist/utils/clipboard-native.d.ts +0 -8
  497. package/dist/utils/clipboard-native.d.ts.map +0 -1
  498. package/dist/utils/clipboard-native.js +0 -14
  499. package/dist/utils/clipboard-native.js.map +0 -1
  500. package/dist/utils/clipboard.d.ts +0 -2
  501. package/dist/utils/clipboard.d.ts.map +0 -1
  502. package/dist/utils/clipboard.js +0 -78
  503. package/dist/utils/clipboard.js.map +0 -1
  504. package/dist/utils/exif-orientation.d.ts +0 -5
  505. package/dist/utils/exif-orientation.d.ts.map +0 -1
  506. package/dist/utils/exif-orientation.js +0 -158
  507. package/dist/utils/exif-orientation.js.map +0 -1
  508. package/dist/utils/frontmatter.d.ts +0 -8
  509. package/dist/utils/frontmatter.d.ts.map +0 -1
  510. package/dist/utils/frontmatter.js +0 -26
  511. package/dist/utils/frontmatter.js.map +0 -1
  512. package/dist/utils/git.d.ts +0 -26
  513. package/dist/utils/git.d.ts.map +0 -1
  514. package/dist/utils/git.js +0 -163
  515. package/dist/utils/git.js.map +0 -1
  516. package/dist/utils/image-convert.d.ts +0 -9
  517. package/dist/utils/image-convert.d.ts.map +0 -1
  518. package/dist/utils/image-convert.js +0 -39
  519. package/dist/utils/image-convert.js.map +0 -1
  520. package/dist/utils/image-resize.d.ts +0 -36
  521. package/dist/utils/image-resize.d.ts.map +0 -1
  522. package/dist/utils/image-resize.js +0 -137
  523. package/dist/utils/image-resize.js.map +0 -1
  524. package/dist/utils/mime.d.ts +0 -2
  525. package/dist/utils/mime.d.ts.map +0 -1
  526. package/dist/utils/mime.js +0 -26
  527. package/dist/utils/mime.js.map +0 -1
  528. package/dist/utils/paths.d.ts +0 -7
  529. package/dist/utils/paths.d.ts.map +0 -1
  530. package/dist/utils/paths.js +0 -19
  531. package/dist/utils/paths.js.map +0 -1
  532. package/dist/utils/photon.d.ts +0 -21
  533. package/dist/utils/photon.d.ts.map +0 -1
  534. package/dist/utils/photon.js +0 -121
  535. package/dist/utils/photon.js.map +0 -1
  536. package/dist/utils/shell.d.ts +0 -29
  537. package/dist/utils/shell.d.ts.map +0 -1
  538. package/dist/utils/shell.js +0 -203
  539. package/dist/utils/shell.js.map +0 -1
  540. package/dist/utils/sleep.d.ts +0 -5
  541. package/dist/utils/sleep.d.ts.map +0 -1
  542. package/dist/utils/sleep.js +0 -17
  543. package/dist/utils/sleep.js.map +0 -1
  544. package/dist/utils/tools-manager.d.ts +0 -3
  545. package/dist/utils/tools-manager.d.ts.map +0 -1
  546. package/dist/utils/tools-manager.js +0 -252
  547. package/dist/utils/tools-manager.js.map +0 -1
@@ -1,232 +0,0 @@
1
- import { Text } from "@aryee/aery-tui";
2
- import { Type } from "@sinclair/typebox";
3
- import { constants } from "fs";
4
- import { access as fsAccess, readFile as fsReadFile } from "fs/promises";
5
- import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
6
- import { getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.js";
7
- import { formatDimensionNote, resizeImage } from "../../utils/image-resize.js";
8
- import { detectSupportedImageMimeTypeFromFile } from "../../utils/mime.js";
9
- import { resolveReadPath } from "./path-utils.js";
10
- import { getTextOutput, invalidArgText, replaceTabs, shortenPath, str } from "./render-utils.js";
11
- import { wrapToolDefinition } from "./tool-definition-wrapper.js";
12
- import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "./truncate.js";
13
- const readSchema = Type.Object({
14
- path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
15
- offset: Type.Optional(Type.Number({ description: "Line number to start reading from (1-indexed)" })),
16
- limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" })),
17
- });
18
- const defaultReadOperations = {
19
- readFile: (path) => fsReadFile(path),
20
- access: (path) => fsAccess(path, constants.R_OK),
21
- detectImageMimeType: detectSupportedImageMimeTypeFromFile,
22
- };
23
- function formatReadCall(args, theme) {
24
- const rawPath = str(args?.file_path ?? args?.path);
25
- const path = rawPath !== null ? shortenPath(rawPath) : null;
26
- const offset = args?.offset;
27
- const limit = args?.limit;
28
- const invalidArg = invalidArgText(theme);
29
- let pathDisplay = path === null ? invalidArg : path ? theme.fg("accent", path) : theme.fg("toolOutput", "...");
30
- if (offset !== undefined || limit !== undefined) {
31
- const startLine = offset ?? 1;
32
- const endLine = limit !== undefined ? startLine + limit - 1 : "";
33
- pathDisplay += theme.fg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
34
- }
35
- return `${theme.fg("toolTitle", theme.bold("read"))} ${pathDisplay}`;
36
- }
37
- function trimTrailingEmptyLines(lines) {
38
- let end = lines.length;
39
- while (end > 0 && lines[end - 1] === "") {
40
- end--;
41
- }
42
- return lines.slice(0, end);
43
- }
44
- function getNonVisionImageNote(model) {
45
- if (!model || model.input.includes("image")) {
46
- return undefined;
47
- }
48
- return "[Current model does not support images. The image will be omitted from this request.]";
49
- }
50
- function formatReadResult(args, result, options, theme, showImages) {
51
- const rawPath = str(args?.file_path ?? args?.path);
52
- const output = getTextOutput(result, showImages);
53
- const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
54
- const renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split("\n");
55
- const lines = trimTrailingEmptyLines(renderedLines);
56
- const maxLines = options.expanded ? lines.length : 10;
57
- const displayLines = lines.slice(0, maxLines);
58
- const remaining = lines.length - maxLines;
59
- let text = `\n${displayLines.map((line) => (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line)))).join("\n")}`;
60
- if (remaining > 0) {
61
- text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")})`;
62
- }
63
- const truncation = result.details?.truncation;
64
- if (truncation?.truncated) {
65
- if (truncation.firstLineExceedsLimit) {
66
- text += `\n${theme.fg("warning", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;
67
- }
68
- else if (truncation.truncatedBy === "lines") {
69
- text += `\n${theme.fg("warning", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;
70
- }
71
- else {
72
- text += `\n${theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;
73
- }
74
- }
75
- return text;
76
- }
77
- export function createReadToolDefinition(cwd, options) {
78
- const autoResizeImages = options?.autoResizeImages ?? true;
79
- const ops = options?.operations ?? defaultReadOperations;
80
- return {
81
- name: "read",
82
- label: "read",
83
- description: `Read the contents of a file. Supports text files and images (jpg, png, gif, webp). 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.`,
84
- promptSnippet: "Read file contents",
85
- promptGuidelines: ["Use read to examine files instead of cat or sed."],
86
- parameters: readSchema,
87
- async execute(_toolCallId, { path, offset, limit }, signal, _onUpdate, ctx) {
88
- const absolutePath = resolveReadPath(path, cwd);
89
- return new Promise((resolve, reject) => {
90
- if (signal?.aborted) {
91
- reject(new Error("Operation aborted"));
92
- return;
93
- }
94
- let aborted = false;
95
- const onAbort = () => {
96
- aborted = true;
97
- reject(new Error("Operation aborted"));
98
- };
99
- signal?.addEventListener("abort", onAbort, { once: true });
100
- (async () => {
101
- try {
102
- // Check if file exists and is readable.
103
- await ops.access(absolutePath);
104
- if (aborted)
105
- return;
106
- const mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;
107
- let content;
108
- let details;
109
- const nonVisionImageNote = getNonVisionImageNote(ctx?.model);
110
- if (mimeType) {
111
- // Read image as binary.
112
- const buffer = await ops.readFile(absolutePath);
113
- const base64 = buffer.toString("base64");
114
- if (autoResizeImages) {
115
- // Resize image if needed before sending it back to the model.
116
- const resized = await resizeImage({ type: "image", data: base64, mimeType });
117
- if (!resized) {
118
- let textNote = `Read image file [${mimeType}]\n[Image omitted: could not be resized below the inline image size limit.]`;
119
- if (nonVisionImageNote)
120
- textNote += `\n${nonVisionImageNote}`;
121
- content = [{ type: "text", text: textNote }];
122
- }
123
- else {
124
- const dimensionNote = formatDimensionNote(resized);
125
- let textNote = `Read image file [${resized.mimeType}]`;
126
- if (dimensionNote)
127
- textNote += `\n${dimensionNote}`;
128
- if (nonVisionImageNote)
129
- textNote += `\n${nonVisionImageNote}`;
130
- content = [
131
- { type: "text", text: textNote },
132
- { type: "image", data: resized.data, mimeType: resized.mimeType },
133
- ];
134
- }
135
- }
136
- else {
137
- let textNote = `Read image file [${mimeType}]`;
138
- if (nonVisionImageNote)
139
- textNote += `\n${nonVisionImageNote}`;
140
- content = [
141
- { type: "text", text: textNote },
142
- { type: "image", data: base64, mimeType },
143
- ];
144
- }
145
- }
146
- else {
147
- // Read text content.
148
- const buffer = await ops.readFile(absolutePath);
149
- const textContent = buffer.toString("utf-8");
150
- const allLines = textContent.split("\n");
151
- const totalFileLines = allLines.length;
152
- // Apply offset if specified. Convert from 1-indexed input to 0-indexed array access.
153
- const startLine = offset ? Math.max(0, offset - 1) : 0;
154
- const startLineDisplay = startLine + 1;
155
- // Check if offset is out of bounds.
156
- if (startLine >= allLines.length) {
157
- throw new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);
158
- }
159
- let selectedContent;
160
- let userLimitedLines;
161
- // If limit is specified by the user, honor it first. Otherwise truncateHead decides.
162
- if (limit !== undefined) {
163
- const endLine = Math.min(startLine + limit, allLines.length);
164
- selectedContent = allLines.slice(startLine, endLine).join("\n");
165
- userLimitedLines = endLine - startLine;
166
- }
167
- else {
168
- selectedContent = allLines.slice(startLine).join("\n");
169
- }
170
- // Apply truncation, respecting both line and byte limits.
171
- const truncation = truncateHead(selectedContent);
172
- let outputText;
173
- if (truncation.firstLineExceedsLimit) {
174
- // First line alone exceeds the byte limit. Point the model at a bash fallback.
175
- const firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], "utf-8"));
176
- outputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;
177
- details = { truncation };
178
- }
179
- else if (truncation.truncated) {
180
- // Truncation occurred. Build an actionable continuation notice.
181
- const endLineDisplay = startLineDisplay + truncation.outputLines - 1;
182
- const nextOffset = endLineDisplay + 1;
183
- outputText = truncation.content;
184
- if (truncation.truncatedBy === "lines") {
185
- outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;
186
- }
187
- else {
188
- outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
189
- }
190
- details = { truncation };
191
- }
192
- else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
193
- // User-specified limit stopped early, but the file still has more content.
194
- const remaining = allLines.length - (startLine + userLimitedLines);
195
- const nextOffset = startLine + userLimitedLines + 1;
196
- outputText = `${truncation.content}\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
197
- }
198
- else {
199
- // No truncation and no remaining user-limited content.
200
- outputText = truncation.content;
201
- }
202
- content = [{ type: "text", text: outputText }];
203
- }
204
- if (aborted)
205
- return;
206
- signal?.removeEventListener("abort", onAbort);
207
- resolve({ content, details });
208
- }
209
- catch (error) {
210
- signal?.removeEventListener("abort", onAbort);
211
- if (!aborted)
212
- reject(error);
213
- }
214
- })();
215
- });
216
- },
217
- renderCall(args, theme, context) {
218
- const text = context.lastComponent ?? new Text("", 0, 0);
219
- text.setText(formatReadCall(args, theme));
220
- return text;
221
- },
222
- renderResult(result, options, theme, context) {
223
- const text = context.lastComponent ?? new Text("", 0, 0);
224
- text.setText(formatReadResult(context.args, result, options, theme, context.showImages));
225
- return text;
226
- },
227
- };
228
- }
229
- export function createReadTool(cwd, options) {
230
- return wrapToolDefinition(createReadToolDefinition(cwd, options));
231
- }
232
- //# sourceMappingURL=read.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read.js","sourceRoot":"","sources":["../../../src/core/tools/read.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAe,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACtD,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,OAAO,EAAE,MAAM,wDAAwD,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,oCAAoC,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,mBAAmB,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C,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAChG,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 type { AgentTool } from \"@aryee/aery-core\";\nimport type { Api, ImageContent, Model, TextContent } from \"@aryee/aery-ai\";\nimport { Text } from \"@aryee/aery-tui\";\nimport { type Static, Type } from \"@sinclair/typebox\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile } from \"fs/promises\";\nimport { keyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.js\";\nimport { formatDimensionNote, resizeImage } from \"../../utils/image-resize.js\";\nimport { detectSupportedImageMimeTypeFromFile } from \"../../utils/mime.js\";\nimport type { ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.js\";\nimport { resolveReadPath } from \"./path-utils.js\";\nimport { getTextOutput, invalidArgText, replaceTabs, shortenPath, str } from \"./render-utils.js\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.js\";\nimport { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, type TruncationResult, truncateHead } from \"./truncate.js\";\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 type ReadToolInput = Static<typeof readSchema>;\n\nexport interface ReadToolDetails {\n\ttruncation?: TruncationResult;\n}\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\nfunction formatReadCall(\n\targs: { path?: string; file_path?: string; offset?: number; limit?: number } | undefined,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst offset = args?.offset;\n\tconst limit = args?.limit;\n\tconst invalidArg = invalidArgText(theme);\n\tlet pathDisplay = path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\");\n\tif (offset !== undefined || limit !== undefined) {\n\t\tconst startLine = offset ?? 1;\n\t\tconst endLine = limit !== undefined ? startLine + limit - 1 : \"\";\n\t\tpathDisplay += theme.fg(\"warning\", `:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n\t}\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"read\"))} ${pathDisplay}`;\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 formatReadResult(\n\targs: { path?: string; file_path?: string; offset?: number; limit?: number } | undefined,\n\tresult: { content: (TextContent | ImageContent)[]; details?: ReadToolDetails },\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tshowImages: boolean,\n): string {\n\tconst rawPath = str(args?.file_path ?? args?.path);\n\tconst output = getTextOutput(result as any, showImages);\n\tconst lang = 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\")})`;\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). 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: \"Read file contents\",\n\t\tpromptGuidelines: [\"Use read to examine files instead of cat or sed.\"],\n\t\tparameters: readSchema,\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\tconst absolutePath = resolveReadPath(path, cwd);\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\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 base64 = buffer.toString(\"base64\");\n\t\t\t\t\t\t\t\tif (autoResizeImages) {\n\t\t\t\t\t\t\t\t\t// Resize image if needed before sending it back to the model.\n\t\t\t\t\t\t\t\t\tconst resized = await resizeImage({ type: \"image\", data: base64, mimeType });\n\t\t\t\t\t\t\t\t\tif (!resized) {\n\t\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]\\n[Image omitted: could not be resized below the inline image size limit.]`;\n\t\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\t\tcontent = [{ type: \"text\", text: textNote }];\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tconst dimensionNote = formatDimensionNote(resized);\n\t\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${resized.mimeType}]`;\n\t\t\t\t\t\t\t\t\t\tif (dimensionNote) textNote += `\\n${dimensionNote}`;\n\t\t\t\t\t\t\t\t\t\tif (nonVisionImageNote) textNote += `\\n${nonVisionImageNote}`;\n\t\t\t\t\t\t\t\t\t\tcontent = [\n\t\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\t{ type: \"image\", data: resized.data, mimeType: resized.mimeType },\n\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tlet textNote = `Read image file [${mimeType}]`;\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: base64, 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\ttext.setText(formatReadCall(args, theme));\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(formatReadResult(context.args, result as any, options, theme, context.showImages));\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,21 +0,0 @@
1
- import type { ImageContent, TextContent } from "@aryee/aery-ai";
2
- export declare function shortenPath(path: unknown): string;
3
- export declare function str(value: unknown): string | null;
4
- export declare function replaceTabs(text: string): string;
5
- export declare function normalizeDisplayText(text: string): string;
6
- export declare function getTextOutput(result: {
7
- content: Array<{
8
- type: string;
9
- text?: string;
10
- data?: string;
11
- mimeType?: string;
12
- }>;
13
- } | undefined, showImages: boolean): string;
14
- export type ToolRenderResultLike<TDetails> = {
15
- content: (TextContent | ImageContent)[];
16
- details: TDetails;
17
- };
18
- export declare function invalidArgText(theme: {
19
- fg: (name: any, text: string) => string;
20
- }): string;
21
- //# sourceMappingURL=render-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-utils.d.ts","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKhE,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAOjD;AAED,wBAAgB,GAAG,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAIjD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,SAAS,EACzG,UAAU,EAAE,OAAO,GACjB,MAAM,CAsBR;AAED,MAAM,MAAM,oBAAoB,CAAC,QAAQ,IAAI;IAC5C,OAAO,EAAE,CAAC,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;IACxC,OAAO,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,GAAG,MAAM,CAEzF","sourcesContent":["import * as os from \"node:os\";\nimport type { ImageContent, TextContent } from \"@aryee/aery-ai\";\nimport { getCapabilities, getImageDimensions, imageFallback } from \"@aryee/aery-tui\";\nimport stripAnsi from \"strip-ansi\";\nimport { sanitizeBinaryOutput } from \"../../utils/shell.js\";\n\nexport function shortenPath(path: unknown): string {\n\tif (typeof path !== \"string\") return \"\";\n\tconst home = os.homedir();\n\tif (path.startsWith(home)) {\n\t\treturn `~${path.slice(home.length)}`;\n\t}\n\treturn path;\n}\n\nexport function str(value: unknown): string | null {\n\tif (typeof value === \"string\") return value;\n\tif (value == null) return \"\";\n\treturn null;\n}\n\nexport function replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nexport function normalizeDisplayText(text: string): string {\n\treturn text.replace(/\\r/g, \"\");\n}\n\nexport function getTextOutput(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> } | undefined,\n\tshowImages: boolean,\n): string {\n\tif (!result) return \"\";\n\n\tconst textBlocks = result.content.filter((c) => c.type === \"text\");\n\tconst imageBlocks = result.content.filter((c) => c.type === \"image\");\n\n\tlet output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || \"\")).replace(/\\r/g, \"\")).join(\"\\n\");\n\n\tconst caps = getCapabilities();\n\tif (imageBlocks.length > 0 && (!caps.images || !showImages)) {\n\t\tconst imageIndicators = imageBlocks\n\t\t\t.map((img) => {\n\t\t\t\tconst mimeType = img.mimeType ?? \"image/unknown\";\n\t\t\t\tconst dims =\n\t\t\t\t\timg.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;\n\t\t\t\treturn imageFallback(mimeType, dims);\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t\toutput = output ? `${output}\\n${imageIndicators}` : imageIndicators;\n\t}\n\n\treturn output;\n}\n\nexport type ToolRenderResultLike<TDetails> = {\n\tcontent: (TextContent | ImageContent)[];\n\tdetails: TDetails;\n};\n\nexport function invalidArgText(theme: { fg: (name: any, text: string) => string }): string {\n\treturn theme.fg(\"error\", \"[invalid arg]\");\n}\n"]}
@@ -1,49 +0,0 @@
1
- import * as os from "node:os";
2
- import { getCapabilities, getImageDimensions, imageFallback } from "@aryee/aery-tui";
3
- import stripAnsi from "strip-ansi";
4
- import { sanitizeBinaryOutput } from "../../utils/shell.js";
5
- export function shortenPath(path) {
6
- if (typeof path !== "string")
7
- return "";
8
- const home = os.homedir();
9
- if (path.startsWith(home)) {
10
- return `~${path.slice(home.length)}`;
11
- }
12
- return path;
13
- }
14
- export function str(value) {
15
- if (typeof value === "string")
16
- return value;
17
- if (value == null)
18
- return "";
19
- return null;
20
- }
21
- export function replaceTabs(text) {
22
- return text.replace(/\t/g, " ");
23
- }
24
- export function normalizeDisplayText(text) {
25
- return text.replace(/\r/g, "");
26
- }
27
- export function getTextOutput(result, showImages) {
28
- if (!result)
29
- return "";
30
- const textBlocks = result.content.filter((c) => c.type === "text");
31
- const imageBlocks = result.content.filter((c) => c.type === "image");
32
- let output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || "")).replace(/\r/g, "")).join("\n");
33
- const caps = getCapabilities();
34
- if (imageBlocks.length > 0 && (!caps.images || !showImages)) {
35
- const imageIndicators = imageBlocks
36
- .map((img) => {
37
- const mimeType = img.mimeType ?? "image/unknown";
38
- const dims = img.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;
39
- return imageFallback(mimeType, dims);
40
- })
41
- .join("\n");
42
- output = output ? `${output}\n${imageIndicators}` : imageIndicators;
43
- }
44
- return output;
45
- }
46
- export function invalidArgText(theme) {
47
- return theme.fg("error", "[invalid arg]");
48
- }
49
- //# sourceMappingURL=render-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-utils.js","sourceRoot":"","sources":["../../../src/core/tools/render-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,eAAe,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-ai\";\nimport { getCapabilities, getImageDimensions, imageFallback } from \"@aryee/aery-tui\";\nimport stripAnsi from \"strip-ansi\";\nimport { sanitizeBinaryOutput } from \"../../utils/shell.js\";\n\nexport function shortenPath(path: unknown): string {\n\tif (typeof path !== \"string\") return \"\";\n\tconst home = os.homedir();\n\tif (path.startsWith(home)) {\n\t\treturn `~${path.slice(home.length)}`;\n\t}\n\treturn path;\n}\n\nexport function str(value: unknown): string | null {\n\tif (typeof value === \"string\") return value;\n\tif (value == null) return \"\";\n\treturn null;\n}\n\nexport function replaceTabs(text: string): string {\n\treturn text.replace(/\\t/g, \" \");\n}\n\nexport function normalizeDisplayText(text: string): string {\n\treturn text.replace(/\\r/g, \"\");\n}\n\nexport function getTextOutput(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> } | undefined,\n\tshowImages: boolean,\n): string {\n\tif (!result) return \"\";\n\n\tconst textBlocks = result.content.filter((c) => c.type === \"text\");\n\tconst imageBlocks = result.content.filter((c) => c.type === \"image\");\n\n\tlet output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || \"\")).replace(/\\r/g, \"\")).join(\"\\n\");\n\n\tconst caps = getCapabilities();\n\tif (imageBlocks.length > 0 && (!caps.images || !showImages)) {\n\t\tconst imageIndicators = imageBlocks\n\t\t\t.map((img) => {\n\t\t\t\tconst mimeType = img.mimeType ?? \"image/unknown\";\n\t\t\t\tconst dims =\n\t\t\t\t\timg.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;\n\t\t\t\treturn imageFallback(mimeType, dims);\n\t\t\t})\n\t\t\t.join(\"\\n\");\n\t\toutput = output ? `${output}\\n${imageIndicators}` : imageIndicators;\n\t}\n\n\treturn output;\n}\n\nexport type ToolRenderResultLike<TDetails> = {\n\tcontent: (TextContent | ImageContent)[];\n\tdetails: TDetails;\n};\n\nexport function invalidArgText(theme: { fg: (name: any, text: string) => string }): string {\n\treturn theme.fg(\"error\", \"[invalid arg]\");\n}\n"]}
@@ -1,14 +0,0 @@
1
- import type { AgentTool } from "@aryee/aery-core";
2
- import type { ExtensionContext, ToolDefinition } from "../extensions/types.js";
3
- /** Wrap a ToolDefinition into an AgentTool for the core runtime. */
4
- export declare function wrapToolDefinition<TDetails = unknown>(definition: ToolDefinition<any, TDetails>, ctxFactory?: () => ExtensionContext): AgentTool<any, TDetails>;
5
- /** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */
6
- export declare function wrapToolDefinitions(definitions: ToolDefinition<any, any>[], ctxFactory?: () => ExtensionContext): AgentTool<any>[];
7
- /**
8
- * Synthesize a minimal ToolDefinition from an AgentTool.
9
- *
10
- * This keeps AgentSession's internal registry definition-first even when a caller
11
- * provides plain AgentTool overrides that do not include prompt metadata or renderers.
12
- */
13
- export declare function createToolDefinitionFromAgentTool(tool: AgentTool<any>): ToolDefinition<any, unknown>;
14
- //# sourceMappingURL=tool-definition-wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-definition-wrapper.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE/E,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EACpD,UAAU,EAAE,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,EACzC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAW1B;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CAClC,WAAW,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACvC,UAAU,CAAC,EAAE,MAAM,gBAAgB,GACjC,SAAS,CAAC,GAAG,CAAC,EAAE,CAElB;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAUpG","sourcesContent":["import type { AgentTool } from \"@aryee/aery-core\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.js\";\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TDetails = unknown>(\n\tdefinition: ToolDefinition<any, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any, TDetails> {\n\treturn {\n\t\tname: definition.name,\n\t\tlabel: definition.label,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\tprepareArguments: definition.prepareArguments,\n\t\texecutionMode: definition.executionMode,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tdefinition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.() as ExtensionContext),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<any, any>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any>[] {\n\treturn definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));\n}\n\n/**\n * Synthesize a minimal ToolDefinition from an AgentTool.\n *\n * This keeps AgentSession's internal registry definition-first even when a caller\n * provides plain AgentTool overrides that do not include prompt metadata or renderers.\n */\nexport function createToolDefinitionFromAgentTool(tool: AgentTool<any>): ToolDefinition<any, unknown> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters as any,\n\t\tprepareArguments: tool.prepareArguments,\n\t\texecutionMode: tool.executionMode,\n\t\texecute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),\n\t};\n}\n"]}
@@ -1,34 +0,0 @@
1
- /** Wrap a ToolDefinition into an AgentTool for the core runtime. */
2
- export function wrapToolDefinition(definition, ctxFactory) {
3
- return {
4
- name: definition.name,
5
- label: definition.label,
6
- description: definition.description,
7
- parameters: definition.parameters,
8
- prepareArguments: definition.prepareArguments,
9
- executionMode: definition.executionMode,
10
- execute: (toolCallId, params, signal, onUpdate) => definition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.()),
11
- };
12
- }
13
- /** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */
14
- export function wrapToolDefinitions(definitions, ctxFactory) {
15
- return definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));
16
- }
17
- /**
18
- * Synthesize a minimal ToolDefinition from an AgentTool.
19
- *
20
- * This keeps AgentSession's internal registry definition-first even when a caller
21
- * provides plain AgentTool overrides that do not include prompt metadata or renderers.
22
- */
23
- export function createToolDefinitionFromAgentTool(tool) {
24
- return {
25
- name: tool.name,
26
- label: tool.label,
27
- description: tool.description,
28
- parameters: tool.parameters,
29
- prepareArguments: tool.prepareArguments,
30
- executionMode: tool.executionMode,
31
- execute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
32
- };
33
- }
34
- //# sourceMappingURL=tool-definition-wrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-definition-wrapper.js","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAGA,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CACjC,UAAyC,EACzC,UAAmC,EACR;IAC3B,OAAO;QACN,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;QAC7C,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CACjD,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAsB,CAAC;KAC7F,CAAC;AAAA,CACF;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB,CAClC,WAAuC,EACvC,UAAmC,EAChB;IACnB,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAAA,CACnF;AAED;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAAC,IAAoB,EAAgC;IACrG,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAiB;QAClC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;KAC3G,CAAC;AAAA,CACF","sourcesContent":["import type { AgentTool } from \"@aryee/aery-core\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.js\";\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TDetails = unknown>(\n\tdefinition: ToolDefinition<any, TDetails>,\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any, TDetails> {\n\treturn {\n\t\tname: definition.name,\n\t\tlabel: definition.label,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\tprepareArguments: definition.prepareArguments,\n\t\texecutionMode: definition.executionMode,\n\t\texecute: (toolCallId, params, signal, onUpdate) =>\n\t\t\tdefinition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.() as ExtensionContext),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<any, any>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<any>[] {\n\treturn definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));\n}\n\n/**\n * Synthesize a minimal ToolDefinition from an AgentTool.\n *\n * This keeps AgentSession's internal registry definition-first even when a caller\n * provides plain AgentTool overrides that do not include prompt metadata or renderers.\n */\nexport function createToolDefinitionFromAgentTool(tool: AgentTool<any>): ToolDefinition<any, unknown> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters as any,\n\t\tprepareArguments: tool.prepareArguments,\n\t\texecutionMode: tool.executionMode,\n\t\texecute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),\n\t};\n}\n"]}
@@ -1,70 +0,0 @@
1
- /**
2
- * Shared truncation utilities for tool outputs.
3
- *
4
- * Truncation is based on two independent limits - whichever is hit first wins:
5
- * - Line limit (default: 2000 lines)
6
- * - Byte limit (default: 50KB)
7
- *
8
- * Never returns partial lines (except bash tail truncation edge case).
9
- */
10
- export declare const DEFAULT_MAX_LINES = 2000;
11
- export declare const DEFAULT_MAX_BYTES: number;
12
- export declare const GREP_MAX_LINE_LENGTH = 500;
13
- export interface TruncationResult {
14
- /** The truncated content */
15
- content: string;
16
- /** Whether truncation occurred */
17
- truncated: boolean;
18
- /** Which limit was hit: "lines", "bytes", or null if not truncated */
19
- truncatedBy: "lines" | "bytes" | null;
20
- /** Total number of lines in the original content */
21
- totalLines: number;
22
- /** Total number of bytes in the original content */
23
- totalBytes: number;
24
- /** Number of complete lines in the truncated output */
25
- outputLines: number;
26
- /** Number of bytes in the truncated output */
27
- outputBytes: number;
28
- /** Whether the last line was partially truncated (only for tail truncation edge case) */
29
- lastLinePartial: boolean;
30
- /** Whether the first line exceeded the byte limit (for head truncation) */
31
- firstLineExceedsLimit: boolean;
32
- /** The max lines limit that was applied */
33
- maxLines: number;
34
- /** The max bytes limit that was applied */
35
- maxBytes: number;
36
- }
37
- export interface TruncationOptions {
38
- /** Maximum number of lines (default: 2000) */
39
- maxLines?: number;
40
- /** Maximum number of bytes (default: 50KB) */
41
- maxBytes?: number;
42
- }
43
- /**
44
- * Format bytes as human-readable size.
45
- */
46
- export declare function formatSize(bytes: number): string;
47
- /**
48
- * Truncate content from the head (keep first N lines/bytes).
49
- * Suitable for file reads where you want to see the beginning.
50
- *
51
- * Never returns partial lines. If first line exceeds byte limit,
52
- * returns empty content with firstLineExceedsLimit=true.
53
- */
54
- export declare function truncateHead(content: string, options?: TruncationOptions): TruncationResult;
55
- /**
56
- * Truncate content from the tail (keep last N lines/bytes).
57
- * Suitable for bash output where you want to see the end (errors, final results).
58
- *
59
- * May return partial first line if the last line of original content exceeds byte limit.
60
- */
61
- export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
62
- /**
63
- * Truncate a single line to max characters, adding [truncated] suffix.
64
- * Used for grep match lines.
65
- */
66
- export declare function truncateLine(line: string, maxChars?: number): {
67
- text: string;
68
- wasTruncated: boolean;
69
- };
70
- //# sourceMappingURL=truncate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"truncate.d.ts","sourceRoot":"","sources":["../../../src/core/tools/truncate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAChC,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,eAAe,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,qBAAqB,EAAE,OAAO,CAAC;IAC/B,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAkF/F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,gBAAgB,CAyE/F;AAuBD;;;GAGG;AACH,wBAAgB,YAAY,CAC3B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAA6B,GACrC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAKzC","sourcesContent":["/**\n * Shared truncation utilities for tool outputs.\n *\n * Truncation is based on two independent limits - whichever is hit first wins:\n * - Line limit (default: 2000 lines)\n * - Byte limit (default: 50KB)\n *\n * Never returns partial lines (except bash tail truncation edge case).\n */\n\nexport const DEFAULT_MAX_LINES = 2000;\nexport const DEFAULT_MAX_BYTES = 50 * 1024; // 50KB\nexport const GREP_MAX_LINE_LENGTH = 500; // Max chars per grep match line\n\nexport interface TruncationResult {\n\t/** The truncated content */\n\tcontent: string;\n\t/** Whether truncation occurred */\n\ttruncated: boolean;\n\t/** Which limit was hit: \"lines\", \"bytes\", or null if not truncated */\n\ttruncatedBy: \"lines\" | \"bytes\" | null;\n\t/** Total number of lines in the original content */\n\ttotalLines: number;\n\t/** Total number of bytes in the original content */\n\ttotalBytes: number;\n\t/** Number of complete lines in the truncated output */\n\toutputLines: number;\n\t/** Number of bytes in the truncated output */\n\toutputBytes: number;\n\t/** Whether the last line was partially truncated (only for tail truncation edge case) */\n\tlastLinePartial: boolean;\n\t/** Whether the first line exceeded the byte limit (for head truncation) */\n\tfirstLineExceedsLimit: boolean;\n\t/** The max lines limit that was applied */\n\tmaxLines: number;\n\t/** The max bytes limit that was applied */\n\tmaxBytes: number;\n}\n\nexport interface TruncationOptions {\n\t/** Maximum number of lines (default: 2000) */\n\tmaxLines?: number;\n\t/** Maximum number of bytes (default: 50KB) */\n\tmaxBytes?: number;\n}\n\n/**\n * Format bytes as human-readable size.\n */\nexport function formatSize(bytes: number): string {\n\tif (bytes < 1024) {\n\t\treturn `${bytes}B`;\n\t} else if (bytes < 1024 * 1024) {\n\t\treturn `${(bytes / 1024).toFixed(1)}KB`;\n\t} else {\n\t\treturn `${(bytes / (1024 * 1024)).toFixed(1)}MB`;\n\t}\n}\n\n/**\n * Truncate content from the head (keep first N lines/bytes).\n * Suitable for file reads where you want to see the beginning.\n *\n * Never returns partial lines. If first line exceeds byte limit,\n * returns empty content with firstLineExceedsLimit=true.\n */\nexport function truncateHead(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = Buffer.byteLength(content, \"utf-8\");\n\tconst lines = content.split(\"\\n\");\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Check if first line alone exceeds byte limit\n\tconst firstLineBytes = Buffer.byteLength(lines[0], \"utf-8\");\n\tif (firstLineBytes > maxBytes) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\ttruncated: true,\n\t\t\ttruncatedBy: \"bytes\",\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: 0,\n\t\t\toutputBytes: 0,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: true,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Collect complete lines that fit\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\n\tfor (let i = 0; i < lines.length && i < maxLines; i++) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = Buffer.byteLength(line, \"utf-8\") + (i > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.push(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = Buffer.byteLength(outputContent, \"utf-8\");\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial: false,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate content from the tail (keep last N lines/bytes).\n * Suitable for bash output where you want to see the end (errors, final results).\n *\n * May return partial first line if the last line of original content exceeds byte limit.\n */\nexport function truncateTail(content: string, options: TruncationOptions = {}): TruncationResult {\n\tconst maxLines = options.maxLines ?? DEFAULT_MAX_LINES;\n\tconst maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;\n\n\tconst totalBytes = Buffer.byteLength(content, \"utf-8\");\n\tconst lines = content.split(\"\\n\");\n\tconst totalLines = lines.length;\n\n\t// Check if no truncation needed\n\tif (totalLines <= maxLines && totalBytes <= maxBytes) {\n\t\treturn {\n\t\t\tcontent,\n\t\t\ttruncated: false,\n\t\t\ttruncatedBy: null,\n\t\t\ttotalLines,\n\t\t\ttotalBytes,\n\t\t\toutputLines: totalLines,\n\t\t\toutputBytes: totalBytes,\n\t\t\tlastLinePartial: false,\n\t\t\tfirstLineExceedsLimit: false,\n\t\t\tmaxLines,\n\t\t\tmaxBytes,\n\t\t};\n\t}\n\n\t// Work backwards from the end\n\tconst outputLinesArr: string[] = [];\n\tlet outputBytesCount = 0;\n\tlet truncatedBy: \"lines\" | \"bytes\" = \"lines\";\n\tlet lastLinePartial = false;\n\n\tfor (let i = lines.length - 1; i >= 0 && outputLinesArr.length < maxLines; i--) {\n\t\tconst line = lines[i];\n\t\tconst lineBytes = Buffer.byteLength(line, \"utf-8\") + (outputLinesArr.length > 0 ? 1 : 0); // +1 for newline\n\n\t\tif (outputBytesCount + lineBytes > maxBytes) {\n\t\t\ttruncatedBy = \"bytes\";\n\t\t\t// Edge case: if we haven't added ANY lines yet and this line exceeds maxBytes,\n\t\t\t// take the end of the line (partial)\n\t\t\tif (outputLinesArr.length === 0) {\n\t\t\t\tconst truncatedLine = truncateStringToBytesFromEnd(line, maxBytes);\n\t\t\t\toutputLinesArr.unshift(truncatedLine);\n\t\t\t\toutputBytesCount = Buffer.byteLength(truncatedLine, \"utf-8\");\n\t\t\t\tlastLinePartial = true;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\toutputLinesArr.unshift(line);\n\t\toutputBytesCount += lineBytes;\n\t}\n\n\t// If we exited due to line limit\n\tif (outputLinesArr.length >= maxLines && outputBytesCount <= maxBytes) {\n\t\ttruncatedBy = \"lines\";\n\t}\n\n\tconst outputContent = outputLinesArr.join(\"\\n\");\n\tconst finalOutputBytes = Buffer.byteLength(outputContent, \"utf-8\");\n\n\treturn {\n\t\tcontent: outputContent,\n\t\ttruncated: true,\n\t\ttruncatedBy,\n\t\ttotalLines,\n\t\ttotalBytes,\n\t\toutputLines: outputLinesArr.length,\n\t\toutputBytes: finalOutputBytes,\n\t\tlastLinePartial,\n\t\tfirstLineExceedsLimit: false,\n\t\tmaxLines,\n\t\tmaxBytes,\n\t};\n}\n\n/**\n * Truncate a string to fit within a byte limit (from the end).\n * Handles multi-byte UTF-8 characters correctly.\n */\nfunction truncateStringToBytesFromEnd(str: string, maxBytes: number): string {\n\tconst buf = Buffer.from(str, \"utf-8\");\n\tif (buf.length <= maxBytes) {\n\t\treturn str;\n\t}\n\n\t// Start from the end, skip maxBytes back\n\tlet start = buf.length - maxBytes;\n\n\t// Find a valid UTF-8 boundary (start of a character)\n\twhile (start < buf.length && (buf[start] & 0xc0) === 0x80) {\n\t\tstart++;\n\t}\n\n\treturn buf.slice(start).toString(\"utf-8\");\n}\n\n/**\n * Truncate a single line to max characters, adding [truncated] suffix.\n * Used for grep match lines.\n */\nexport function truncateLine(\n\tline: string,\n\tmaxChars: number = GREP_MAX_LINE_LENGTH,\n): { text: string; wasTruncated: boolean } {\n\tif (line.length <= maxChars) {\n\t\treturn { text: line, wasTruncated: false };\n\t}\n\treturn { text: `${line.slice(0, maxChars)}... [truncated]`, wasTruncated: true };\n}\n"]}